Merge pull request #9592 from Ghommie/Ghommie-cit262
Porting movespeed modification system updates.
This commit is contained in:
@@ -152,8 +152,7 @@
|
||||
newcolor = BLOOD_COLOR_XENO
|
||||
add_atom_colour(newcolor, TEMPORARY_COLOUR_PRIORITY)
|
||||
// but only for a few seconds
|
||||
spawn(30)
|
||||
remove_atom_colour(TEMPORARY_COLOUR_PRIORITY, newcolor)
|
||||
addtimer(CALLBACK(src, /atom/.proc/remove_atom_colour, TEMPORARY_COLOUR_PRIORITY, newcolor), 6 SECONDS)
|
||||
|
||||
/mob/living/proc/phasein(obj/effect/decal/cleanable/B)
|
||||
if(src.notransform)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
/mob/living/carbon/Move(NewLoc, direct)
|
||||
. = ..()
|
||||
if(. && mob_has_gravity()) //floating is easy
|
||||
if(. && (movement_type & FLOATING)) //floating is easy
|
||||
if(HAS_TRAIT(src, TRAIT_NOHUNGER))
|
||||
nutrition = NUTRITION_LEVEL_FED - 1 //just less than feeling vigorous
|
||||
else if(nutrition && stat != DEAD)
|
||||
|
||||
@@ -946,7 +946,7 @@
|
||||
return FALSE
|
||||
|
||||
/mob/living/carbon/human/proc/clear_shove_slowdown()
|
||||
remove_movespeed_modifier(SHOVE_SLOWDOWN_ID)
|
||||
remove_movespeed_modifier(MOVESPEED_ID_SHOVE)
|
||||
var/active_item = get_active_held_item()
|
||||
if(is_type_in_typecache(active_item, GLOB.shove_disarming_types))
|
||||
visible_message("<span class='warning'>[src.name] regains their grip on \the [active_item]!</span>", "<span class='warning'>You regain your grip on \the [active_item]</span>", null, COMBAT_MESSAGE_RANGE)
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
var/bleed_mod = 1 // % bleeding modifier
|
||||
var/datum/armor/armor // internal armor datum
|
||||
|
||||
var/speed_mod = 0 //tick modifier for each step. Positive is slower, negative is faster.
|
||||
|
||||
var/hunger_mod = 1 //% of hunger rate taken per tick.
|
||||
|
||||
var/do_after_speed = 1 //Speed mod for do_after. Lower is better. If temporarily adjusting, please only modify using *= and /=, so you don't interrupt other calculations.
|
||||
|
||||
@@ -332,6 +332,8 @@ GLOBAL_LIST_EMPTY(roundstart_race_names)
|
||||
if("meat_type" in default_features) //I can't believe it's come to the meat
|
||||
H.type_of_meat = GLOB.meat_types[H.dna.features["meat_type"]]
|
||||
|
||||
C.add_movespeed_modifier(MOVESPEED_ID_SPECIES, TRUE, 100, override=TRUE, multiplicative_slowdown=speedmod, movetypes=(~FLYING))
|
||||
|
||||
SEND_SIGNAL(C, COMSIG_SPECIES_GAIN, src, old_species)
|
||||
|
||||
|
||||
@@ -348,6 +350,8 @@ GLOBAL_LIST_EMPTY(roundstart_race_names)
|
||||
for(var/X in inherent_traits)
|
||||
REMOVE_TRAIT(C, X, SPECIES_TRAIT)
|
||||
|
||||
C.remove_movespeed_modifier(MOVESPEED_ID_SPECIES)
|
||||
|
||||
if("meat_type" in default_features)
|
||||
C.type_of_meat = GLOB.meat_types[C.dna.features["meat_type"]]
|
||||
else
|
||||
@@ -1389,39 +1393,16 @@ GLOBAL_LIST_EMPTY(roundstart_race_names)
|
||||
/datum/species/proc/movement_delay(mob/living/carbon/human/H)
|
||||
. = 0 //We start at 0.
|
||||
var/flight = 0 //Check for flight and flying items
|
||||
var/ignoreslow = 0
|
||||
var/gravity = 0
|
||||
if(H.movement_type & FLYING)
|
||||
flight = 1
|
||||
|
||||
gravity = H.has_gravity()
|
||||
|
||||
if(gravity && !flight) //Check for chemicals and innate speedups and slowdowns if we're on the ground
|
||||
if(HAS_TRAIT(H, TRAIT_GOTTAGOFAST))
|
||||
. -= 1
|
||||
if(HAS_TRAIT(H, TRAIT_GOTTAGOREALLYFAST))
|
||||
. -= 2
|
||||
. += speedmod
|
||||
. += H.physiology.speed_mod
|
||||
|
||||
if (H.m_intent == MOVE_INTENT_WALK && HAS_TRAIT(H, TRAIT_SPEEDY_STEP))
|
||||
. -= 1.5
|
||||
|
||||
if(HAS_TRAIT(H, TRAIT_IGNORESLOWDOWN))
|
||||
ignoreslow = 1
|
||||
|
||||
if(!gravity)
|
||||
var/obj/item/tank/jetpack/J = H.back
|
||||
var/obj/item/clothing/suit/space/hardsuit/C = H.wear_suit
|
||||
var/obj/item/organ/cyberimp/chest/thrusters/T = H.getorganslot(ORGAN_SLOT_THRUSTERS)
|
||||
if(!istype(J) && istype(C))
|
||||
J = C.jetpack
|
||||
if(istype(J) && J.full_speed && J.allow_thrust(0.01, H)) //Prevents stacking
|
||||
. -= 0.4
|
||||
else if(istype(T) && T.allow_thrust(0.01, H))
|
||||
. -= 0.4
|
||||
|
||||
if(!ignoreslow && gravity)
|
||||
if(!HAS_TRAIT(H, TRAIT_IGNORESLOWDOWN) && gravity)
|
||||
if(H.wear_suit)
|
||||
. += H.wear_suit.slowdown
|
||||
if(H.shoes)
|
||||
@@ -1448,16 +1429,6 @@ GLOBAL_LIST_EMPTY(roundstart_race_names)
|
||||
var/grav_force = min(gravity - STANDARD_GRAVITY,3)
|
||||
. += 1 + grav_force
|
||||
|
||||
var/datum/component/mood/mood = H.GetComponent(/datum/component/mood)
|
||||
if(mood && !flight) //How can depression slow you down if you can just fly away from your problems?
|
||||
switch(mood.sanity)
|
||||
if(SANITY_INSANE to SANITY_CRAZY)
|
||||
. += 1.5
|
||||
if(SANITY_CRAZY to SANITY_UNSTABLE)
|
||||
. += 1
|
||||
if(SANITY_UNSTABLE to SANITY_DISTURBED)
|
||||
. += 0.5
|
||||
|
||||
if(HAS_TRAIT(H, TRAIT_FAT))
|
||||
. += (1.5 - flight)
|
||||
if(H.bodytemperature < BODYTEMP_COLD_DAMAGE_LIMIT && !HAS_TRAIT(H, TRAIT_RESISTCOLD))
|
||||
@@ -1940,8 +1911,8 @@ GLOBAL_LIST_EMPTY(roundstart_race_names)
|
||||
var/knocked_item = FALSE
|
||||
if(!is_type_in_typecache(target_held_item, GLOB.shove_disarming_types))
|
||||
target_held_item = null
|
||||
if(!target.has_movespeed_modifier(SHOVE_SLOWDOWN_ID))
|
||||
target.add_movespeed_modifier(SHOVE_SLOWDOWN_ID, multiplicative_slowdown = SHOVE_SLOWDOWN_STRENGTH)
|
||||
if(!target.has_movespeed_modifier(MOVESPEED_ID_SHOVE))
|
||||
target.add_movespeed_modifier(MOVESPEED_ID_SHOVE, multiplicative_slowdown = SHOVE_SLOWDOWN_STRENGTH)
|
||||
if(target_held_item)
|
||||
target.visible_message("<span class='danger'>[target.name]'s grip on \the [target_held_item] loosens!</span>",
|
||||
"<span class='danger'>Your grip on \the [target_held_item] loosens!</span>", null, COMBAT_MESSAGE_RANGE)
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
if(fly)
|
||||
fly.Remove(H)
|
||||
if(H.movement_type & FLYING)
|
||||
H.movement_type &= ~FLYING
|
||||
H.setMovetype(H.movement_type & ~FLYING)
|
||||
ToggleFlight(H,0)
|
||||
if(H.dna && H.dna.species && (H.dna.features["wings"] == "Angel"))
|
||||
if("wings" in H.dna.species.mutant_bodyparts)
|
||||
@@ -132,14 +132,14 @@
|
||||
if(flight && CanFly(H))
|
||||
stunmod = 2
|
||||
speedmod = -0.35
|
||||
H.movement_type |= FLYING
|
||||
H.setMovetype(H.movement_type | FLYING)
|
||||
override_float = TRUE
|
||||
H.pass_flags |= PASSTABLE
|
||||
H.OpenWings()
|
||||
else
|
||||
stunmod = 1
|
||||
speedmod = 0
|
||||
H.movement_type &= ~FLYING
|
||||
H.setMovetype(H.movement_type & ~FLYING)
|
||||
override_float = FALSE
|
||||
H.pass_flags &= ~PASSTABLE
|
||||
H.CloseWings()
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
if(changed)
|
||||
animate(src, transform = ntransform, time = 2, pixel_y = final_pixel_y, dir = final_dir, easing = EASE_IN|EASE_OUT)
|
||||
floating = 0 // If we were without gravity, the bouncing animation got stopped, so we make sure we restart it in next life().
|
||||
setMovetype(movement_type & ~FLOATING) // If we were without gravity, the bouncing animation got stopped, so we make sure we restart it in next life().
|
||||
|
||||
|
||||
/mob/living/carbon
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
if(digitalinvis)
|
||||
handle_diginvis() //AI becomes unable to see mob
|
||||
|
||||
if((movement_type & FLYING) && !floating) //TODO: Better floating
|
||||
if((movement_type & FLYING) && !(movement_type & FLOATING)) //TODO: Better floating
|
||||
float(on = TRUE)
|
||||
|
||||
if (client)
|
||||
|
||||
@@ -716,14 +716,14 @@
|
||||
var/fixed = 0
|
||||
if(anchored || (buckled && buckled.anchored))
|
||||
fixed = 1
|
||||
if(on && !floating && !fixed)
|
||||
if(on && !(movement_type & FLOATING) && !fixed)
|
||||
animate(src, pixel_y = pixel_y + 2, time = 10, loop = -1)
|
||||
sleep(10)
|
||||
animate(src, pixel_y = pixel_y - 2, time = 10, loop = -1)
|
||||
floating = TRUE
|
||||
else if(((!on || fixed) && floating))
|
||||
setMovetype(movement_type | FLOATING)
|
||||
else if(((!on || fixed) && (movement_type & FLOATING)))
|
||||
animate(src, pixel_y = get_standard_pixel_y_offset(lying), time = 10)
|
||||
floating = FALSE
|
||||
setMovetype(movement_type & ~FLOATING)
|
||||
|
||||
// The src mob is trying to strip an item from someone
|
||||
// Override if a certain type of mob should be behave differently when stripping items (can't, for example)
|
||||
@@ -795,7 +795,7 @@
|
||||
var/final_pixel_y = get_standard_pixel_y_offset(lying)
|
||||
animate(src, pixel_x = pixel_x + pixel_x_diff, pixel_y = pixel_y + pixel_y_diff , time = 2, loop = 6)
|
||||
animate(pixel_x = final_pixel_x , pixel_y = final_pixel_y , time = 2)
|
||||
floating = 0 // If we were without gravity, the bouncing animation got stopped, so we make sure to restart it in next life().
|
||||
setMovetype(movement_type & ~FLOATING) // If we were without gravity, the bouncing animation got stopped, so we make sure to restart it in next life().
|
||||
|
||||
/mob/living/proc/get_temperature(datum/gas_mixture/environment)
|
||||
var/loc_temp = environment ? environment.temperature : T0C
|
||||
|
||||
@@ -422,4 +422,4 @@
|
||||
if(!used_item)
|
||||
used_item = get_active_held_item()
|
||||
..()
|
||||
floating = 0 // If we were without gravity, the bouncing animation got stopped, so we make sure we restart the bouncing after the next movement.
|
||||
setMovetype(movement_type & ~FLOATING) // If we were without gravity, the bouncing animation got stopped, so we make sure we restart the bouncing after the next movement.
|
||||
|
||||
@@ -175,14 +175,17 @@
|
||||
status_flags = NONE
|
||||
mob_size = MOB_SIZE_LARGE
|
||||
gold_core_spawnable = NO_SPAWN
|
||||
var/slowed_by_webs = FALSE
|
||||
|
||||
/mob/living/simple_animal/hostile/poison/giant_spider/tarantula/movement_delay()
|
||||
var/turf/T = get_turf(src)
|
||||
if(locate(/obj/structure/spider/stickyweb) in T)
|
||||
speed = 2
|
||||
else
|
||||
speed = 7
|
||||
/mob/living/simple_animal/hostile/poison/giant_spider/tarantula/Moved(atom/oldloc, dir)
|
||||
. = ..()
|
||||
if(slowed_by_webs)
|
||||
if(!(locate(/obj/structure/spider/stickyweb) in loc))
|
||||
remove_movespeed_modifier(MOVESPEED_ID_TARANTULA_WEB)
|
||||
slowed_by_webs = FALSE
|
||||
else if(locate(/obj/structure/spider/stickyweb) in loc)
|
||||
add_movespeed_modifier(MOVESPEED_ID_TARANTULA_WEB, priority=100, multiplicative_slowdown=3)
|
||||
slowed_by_webs = TRUE
|
||||
|
||||
//midwives are the queen of the spiders, can send messages to all them and web faster. That rare round where you get a queen spider and turn your 'for honor' players into 'r6siege' players will be a fun one.
|
||||
/mob/living/simple_animal/hostile/poison/giant_spider/nurse/midwife
|
||||
|
||||
@@ -363,7 +363,7 @@
|
||||
density = initial(density)
|
||||
lying = 0
|
||||
. = 1
|
||||
movement_type = initial(movement_type)
|
||||
setMovetype(initial(movement_type))
|
||||
|
||||
/mob/living/simple_animal/proc/make_babies() // <3 <3 <3
|
||||
if(gender != FEMALE || stat || next_scan_time > world.time || !childtype || !animal_species || !SSticker.IsRoundInProgress())
|
||||
|
||||
@@ -100,7 +100,7 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, typecacheof(list(
|
||||
A.pipe_vision_img.plane = ABOVE_HUD_PLANE
|
||||
client.images += A.pipe_vision_img
|
||||
pipes_shown += A.pipe_vision_img
|
||||
movement_type |= VENTCRAWLING
|
||||
setMovetype(movement_type | VENTCRAWLING)
|
||||
|
||||
|
||||
/mob/living/proc/remove_ventcrawl()
|
||||
@@ -108,7 +108,7 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, typecacheof(list(
|
||||
for(var/image/current_image in pipes_shown)
|
||||
client.images -= current_image
|
||||
pipes_shown.len = 0
|
||||
movement_type &= ~VENTCRAWLING
|
||||
setMovetype(movement_type & ~VENTCRAWLING)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -961,3 +961,7 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0)
|
||||
|
||||
var/datum/language_holder/H = get_language_holder()
|
||||
H.open_language_menu(usr)
|
||||
|
||||
/mob/setMovetype(newval)
|
||||
. = ..()
|
||||
update_movespeed(FALSE)
|
||||
@@ -1,23 +1,29 @@
|
||||
|
||||
/*Current movespeed modification list format: list(id = list(
|
||||
priority,
|
||||
flags,
|
||||
legacy slowdown/speedup amount,
|
||||
movetype_flags,
|
||||
blacklisted_movetypes,
|
||||
conflict
|
||||
))
|
||||
*/
|
||||
|
||||
//ANY ADD/REMOVE DONE IN UPDATE_MOVESPEED MUST HAVE THE UPDATE ARGUMENT SET AS FALSE!
|
||||
/mob/proc/add_movespeed_modifier(id, update = TRUE, priority = 0, flags = NONE, override = FALSE, multiplicative_slowdown = 0)
|
||||
var/list/temp = list(priority, flags, multiplicative_slowdown) //build the modification list
|
||||
/mob/proc/add_movespeed_modifier(id, update=TRUE, priority=0, flags=NONE, override=FALSE, multiplicative_slowdown=0, movetypes=ALL, blacklisted_movetypes=NONE, conflict=FALSE)
|
||||
var/list/temp = list(priority, flags, multiplicative_slowdown, movetypes, blacklisted_movetypes, conflict) //build the modification list
|
||||
var/resort = TRUE
|
||||
if(LAZYACCESS(movespeed_modification, id))
|
||||
if(movespeed_modifier_identical_check(movespeed_modification[id], temp))
|
||||
var/list/existing_data = movespeed_modification[id]
|
||||
if(movespeed_modifier_identical_check(existing_data, temp))
|
||||
return FALSE
|
||||
if(!override)
|
||||
return FALSE
|
||||
else
|
||||
remove_movespeed_modifier(id, update)
|
||||
LAZYSET(movespeed_modification, id, list(priority, flags, multiplicative_slowdown))
|
||||
if(priority == existing_data[MOVESPEED_DATA_INDEX_PRIORITY])
|
||||
resort = FALSE // We don't need to re-sort if we're replacing something already there and it's the same priority
|
||||
LAZYSET(movespeed_modification, id, temp)
|
||||
if(update)
|
||||
update_movespeed(TRUE)
|
||||
update_movespeed(resort)
|
||||
return TRUE
|
||||
|
||||
/mob/proc/remove_movespeed_modifier(id, update = TRUE)
|
||||
@@ -55,9 +61,23 @@
|
||||
if(resort)
|
||||
sort_movespeed_modlist()
|
||||
. = 0
|
||||
var/list/conflict_tracker = list()
|
||||
for(var/id in get_movespeed_modifiers())
|
||||
var/list/data = movespeed_modification[id]
|
||||
. += data[MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN]
|
||||
if(!(data[MOVESPEED_DATA_INDEX_MOVETYPE] & movement_type)) // We don't affect any of these move types, skip
|
||||
continue
|
||||
if(data[MOVESPEED_DATA_INDEX_BL_MOVETYPE] & movement_type) // There's a movetype here that disables this modifier, skip
|
||||
continue
|
||||
var/conflict = data[MOVESPEED_DATA_INDEX_CONFLICT]
|
||||
var/amt = data[MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN]
|
||||
if(conflict)
|
||||
// Conflicting modifiers prioritize the larger slowdown or the larger speedup
|
||||
// We purposefuly don't handle mixing speedups and slowdowns on the same id
|
||||
if(abs(conflict_tracker[conflict]) < abs(amt))
|
||||
conflict_tracker[conflict] = amt
|
||||
else
|
||||
continue
|
||||
. += amt
|
||||
cached_multiplicative_slowdown = .
|
||||
|
||||
/mob/proc/get_movespeed_modifiers()
|
||||
|
||||
Reference in New Issue
Block a user