Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact(movement delay) #11484

Merged
merged 9 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2007,6 +2007,7 @@
#include "code\modules\mob\mob_defines.dm"
#include "code\modules\mob\mob_helpers.dm"
#include "code\modules\mob\mob_movement.dm"
#include "code\modules\mob\mob_mutations.dm"
#include "code\modules\mob\mob_transformation_simple.dm"
#include "code\modules\mob\say.dm"
#include "code\modules\mob\transform_procs.dm"
Expand Down Expand Up @@ -2053,6 +2054,7 @@
#include "code\modules\mob\living\carbon\carbon.dm"
#include "code\modules\mob\living\carbon\carbon_defense.dm"
#include "code\modules\mob\living\carbon\carbon_defines.dm"
#include "code\modules\mob\living\carbon\carbon_nutrition.dm"
#include "code\modules\mob\living\carbon\carbon_powers.dm"
#include "code\modules\mob\living\carbon\give.dm"
#include "code\modules\mob\living\carbon\hallucinations.dm"
Expand Down Expand Up @@ -2316,6 +2318,11 @@
#include "code\modules\mob\living\simple_animal\hostile\retaliate\exoplanet.dm"
#include "code\modules\mob\living\simple_animal\hostile\retaliate\king_of_goats.dm"
#include "code\modules\mob\living\simple_animal\hostile\retaliate\retaliate.dm"
#include "code\modules\mob\movement\movespeed_mob.dm"
#include "code\modules\mob\movement\movespeed_modifier.dm"
#include "code\modules\mob\movement\modifiers\mobs.dm"
#include "code\modules\mob\movement\modifiers\movespeed_species.dm"
#include "code\modules\mob\movement\modifiers\variable_slowdowns.dm"
#include "code\modules\mob\new_player\login.dm"
#include "code\modules\mob\new_player\logout.dm"
#include "code\modules\mob\new_player\new_player.dm"
Expand Down
5 changes: 4 additions & 1 deletion code/__defines/ces/signals_mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@
/// from turf CtrlClickOn(): (/mob)
#define SIGNAL_MOB_CTRL_CLICK "mob_ctrl_click"

// Called on '/mob/proc/add_spell' (/mob, )
/// Called on '/mob/proc/add_spell' (/mob, )
#define SIGNAL_MOB_SPELL_LEARNED "mob_spell_learned"

/// Called on '/mob/proc/update_movespeed()' (/mob)
#define SIGNAL_MOB_MOVESPEED_UPDATED "mob_movespeed_updated"
2 changes: 2 additions & 0 deletions code/__defines/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@
#define BP_ALL_LIMBS list(BP_CHEST, BP_GROIN, BP_HEAD, BP_L_ARM, BP_R_ARM, BP_L_HAND, BP_R_HAND, BP_L_LEG, BP_R_LEG, BP_L_FOOT, BP_R_FOOT)
#define BP_BY_DEPTH list(BP_HEAD, BP_L_HAND, BP_R_HAND, BP_L_ARM, BP_R_ARM, BP_L_FOOT, BP_R_FOOT, BP_L_LEG, BP_R_LEG, BP_GROIN, BP_CHEST)
#define BP_FEET list(BP_L_FOOT, BP_R_FOOT)
#define BP_LIMBS_LOCOMOTION list(BP_L_LEG, BP_R_LEG, BP_L_FOOT, BP_R_FOOT)
#define BP_LIMBS_ARM_LOCOMOTION list(BP_L_HAND, BP_R_HAND, BP_L_ARM, BP_R_ARM)

// Prosthetic helpers.
#define BP_IS_ROBOTIC(org) (org.status & ORGAN_ROBOTIC)
Expand Down
10 changes: 10 additions & 0 deletions code/__defines/movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@
#define DEL_TRANSFORMATION_MOVEMENT_HANDLER(X) X.RemoveMovementHandler(/datum/movement_handler/mob/transformation)

#define DELAY2GLIDESIZE(delay) (world.icon_size / max(Ceiling(delay / world.tick_lag), 1))

#define MOVESPEED_PRIORITY_HIGH 0
#define MOVESPEED_PRIORITY_NORMAL 1
#define MOVESPEED_PRIORITY_LAST 2

#define MOVESPEED_FLAG_OVERRIDING_SPEED (1<<0)
#define MOVESPEED_FLAG_SPACEMOVEMENT (1<<1)

#define MOVESPEED_ID_MOB_GRAB_STATE "mob_grab_state"
#define MOVESPEED_ID_MOB_WALK_RUN "mob_walk_run"
2 changes: 2 additions & 0 deletions code/_macros.dm
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@
#define LAZYADD(L, I) if(!L) { L = list(); } L += I;
// Insert I into L at position X, initalizing L if necessary
#define LAZYINSERT(L, I, X) if(!L) { L = list(); } L.Insert(X, I);
/// Use LAZYLISTDUPLICATE instead if you want it to null with no entries
#define LAZYCOPY(L) (L ? L.Copy() : list() )
// Adds I to L, initalizing L if necessary, if I is not already in L
#define LAZYDISTINCTADD(L, I) if(!L) { L = list(); } L |= I;
// Sets L[A] to I, initalizing L if necessary
Expand Down
3 changes: 2 additions & 1 deletion code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,11 @@
LE.icon_state = "eyelasers"
playsound(usr.loc, 'sound/effects/weapons/energy/taser2.ogg', 75, 1)
LE.launch(A)

/mob/living/carbon/human/LaserEyes()
if(nutrition>0)
..()
nutrition = max(nutrition - rand(1,5),0)
remove_nutrition(rand(1, 5))
handle_regular_hud_updates()
else
to_chat(src, "<span class='warning'>You're out of energy! You need food!</span>")
Expand Down
6 changes: 2 additions & 4 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,9 @@
if("mov_intent")
switch(usr.m_intent)
if(M_RUN)
usr.m_intent = M_WALK
usr.hud_used.move_intent.icon_state = "walking"
usr.set_m_intent(M_WALK)
if(M_WALK)
usr.m_intent = M_RUN
usr.hud_used.move_intent.icon_state = "running"
usr.set_m_intent(M_RUN)

if("Reset Machine")
usr.unset_machine()
Expand Down
2 changes: 1 addition & 1 deletion code/game/antagonist/outsider/wizard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ GLOBAL_DATUM_INIT(wizards, /datum/antagonist/wizard, new)
wizard.store_memory("<B>Remember:</B> do not forget to prepare your spells.")
wizard.current.real_name = "[pick(GLOB.wizard_first)] [pick(GLOB.wizard_second)]"
wizard.current.SetName(wizard.current.real_name)
wizard.current.mutations.Add(MUTATION_CLUMSY)
wizard.current.add_mutation(MUTATION_CLUMSY)
wizard.wizard = new()

/datum/antagonist/wizard/equip(mob/living/carbon/human/wizard_mob)
Expand Down
4 changes: 2 additions & 2 deletions code/game/dna/genes/disabilities.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/datum/dna/gene/disability/activate(mob/M, connected, flags)
if(mutation && !(mutation in M.mutations))
M.mutations.Add(mutation)
M.add_mutation(mutation)
if(disability)
M.disabilities|=disability
if(sdisability)
Expand All @@ -41,7 +41,7 @@

/datum/dna/gene/disability/deactivate(mob/M, connected, flags)
if(mutation && (mutation in M.mutations))
M.mutations.Remove(mutation)
M.remove_mutation(mutation)
if(disability)
M.disabilities &= (~disability)
if(sdisability)
Expand Down
4 changes: 2 additions & 2 deletions code/game/dna/genes/gene.dm
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@
return probinj(activation_prob,(flags&MUTCHK_FORCED))

/datum/dna/gene/basic/activate(mob/M)
M.mutations.Add(mutation)
M.add_mutation(mutation)
if(activation_messages.len)
var/msg = pick(activation_messages)
to_chat(M, "<span class='notice'>[msg]</span>")

/datum/dna/gene/basic/deactivate(mob/M)
M.mutations.Remove(mutation)
M.remove_mutation(mutation)
if(deactivation_messages.len)
var/msg = pick(deactivation_messages)
to_chat(M, "<span class='warning'>[msg]</span>")
2 changes: 1 addition & 1 deletion code/game/dna/genes/powers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
OnMobLife(mob/living/carbon/human/M)
if(!istype(M)) return
if(M.health <= 25)
M.mutations.Remove(MUTATION_HULK)
M.remove_mutation(MUTATION_HULK)
M.update_mutations() //update our mutation overlays
to_chat(M, "<span class='warning'>You suddenly feel very weak.</span>")
M.Weaken(3)
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/vampire/vampire_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
my_mob.visible_message(SPAN("danger", "A dark aura manifests itself around [my_mob], their eyes turning red and their composure changing to be more beast-like."),\
SPAN("danger", "You can resist no longer. The power of the Veil takes control over your mind: you are unable to speak or think. In people, you see nothing but prey to be feasted upon. You are reduced to an animal."))

my_mob.mutations.Add(MUTATION_HULK)
my_mob.add_mutation(MUTATION_HULK)
my_mob.update_mutations()

my_mob.set_sight(my_mob.sight|SEE_MOBS)
Expand All @@ -318,7 +318,7 @@
if(prob(force_stop ? 100 : blood_usable))
status &= ~VAMP_FRENZIED

my_mob.mutations.Remove(MUTATION_HULK)
my_mob.remove_mutation(MUTATION_HULK)
my_mob.update_mutations()

my_mob.set_sight(my_mob.sight&(~SEE_MOBS))
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/wizard/wizard_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
return

if(MUTATION_SKELETON in lich.mutations)
lich.mutations.Remove(MUTATION_SKELETON)
lich.remove_mutation(MUTATION_SKELETON)
to_chat(lich, SPAN_DANGER("You fell something bizarre, as if your mind is being sucked from your head!"))
to_chat(lich, SPAN_DANGER("You scream in dismay, realizing that your master is going to take over your body!"))
lich.spellremove()
Expand Down
6 changes: 3 additions & 3 deletions code/game/jobs/job/civilian.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/datum/job/bartender/equip(mob/living/carbon/human/H)
. = ..()
if(.)
H.mutations.Add(MUTATION_BARTENDER)
H.add_mutation(MUTATION_BARTENDER)

/datum/job/chef
title = "Chef"
Expand Down Expand Up @@ -51,7 +51,7 @@
H.dna.real_name = new_name
H.mind?.name = new_name
H.flavor_text = ""
H.mutations.Add(MUTATION_BARTENDER)
H.add_mutation(MUTATION_BARTENDER)
for(var/thing in H.flavor_texts)
H.flavor_texts[thing] = null

Expand Down Expand Up @@ -187,7 +187,7 @@
/datum/job/clown/equip(mob/living/carbon/human/H)
. = ..()
if(.)
H.mutations.Add(MUTATION_CLUMSY)
H.add_mutation(MUTATION_CLUMSY)
H.rename_self("clown")

/datum/job/mime
Expand Down
12 changes: 6 additions & 6 deletions code/game/machinery/wishgranter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@
insisting = 0

if (!(MUTATION_HULK in user.mutations))
user.mutations.Add(MUTATION_HULK)
user.add_mutation(MUTATION_HULK)

if (!(MUTATION_LASER in user.mutations))
user.mutations.Add(MUTATION_LASER)
user.add_mutation(MUTATION_LASER)

if (!(MUTATION_XRAY in user.mutations))
user.mutations.Add(MUTATION_XRAY)
user.add_mutation(MUTATION_XRAY)
user.set_sight(user.sight|SEE_MOBS|SEE_OBJS|SEE_TURFS)
user.set_see_in_dark(8)
user.set_see_invisible(SEE_INVISIBLE_LEVEL_TWO)

if (!(MUTATION_COLD_RESISTANCE in user.mutations))
user.mutations.Add(MUTATION_COLD_RESISTANCE)
user.add_mutation(MUTATION_COLD_RESISTANCE)

if (!(MUTATION_TK in user.mutations))
user.mutations.Add(MUTATION_TK)
user.add_mutation(MUTATION_TK)

if(!(MUTATION_HEAL in user.mutations))
user.mutations.Add(MUTATION_HEAL)
user.add_mutation(MUTATION_HEAL)

user.update_mutations()
user.mind.special_role = "Avatar of the Wish Granter"
Expand Down
5 changes: 5 additions & 0 deletions code/game/objects/objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,8 @@
var/turf/T = get_turf(src)
if(T)
T.update_turf_height()

/obj/proc/change_pull_slowdown(new_slowdown)
pull_slowdown = new_slowdown
if(pulledby)
pulledby.update_pull_slowdown()
2 changes: 1 addition & 1 deletion code/game/objects/structures/barricade/security.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
return FALSE

atom_flags |= ATOM_FLAG_UNPUSHABLE
pull_slowdown = PULL_SLOWDOWN_EXTREME
change_pull_slowdown(PULL_SLOWDOWN_EXTREME)
emagged = TRUE

var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/structures/fitness.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
flick("[icon_state]_hit", src)
playsound(src.loc, 'sound/effects/woodhit.ogg', 25, 1, -1)
user.do_attack_animation(src)
user.nutrition = user.nutrition - 5
user.remove_nutrition(5)
to_chat(user, "<span class='warning'>You [pick(hit_message)] \the [src].</span>")

/obj/structure/fitness/weightlifter
Expand Down Expand Up @@ -57,7 +57,7 @@
flick("[icon_state]_[weight]", src)
if(do_after(user, 20 + (weight * 10)))
playsound(src.loc, 'sound/effects/weightdrop.ogg', 25, 1)
user.nutrition -= weight * 10
user.remove_nutrition(weight * 10)
to_chat(user, "<span class='notice'>You lift the weights [qualifiers[weight]].</span>")
being_used = 0
else
Expand Down
5 changes: 1 addition & 4 deletions code/game/objects/structures/kitchen_spike.dm
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,11 @@
SPAN("italics", "You hear a squishy wet noise.</span>"))
if (H.can_feel_pain())
H.emote("scream")
H.nutrition -= slab_nutrition
H.remove_nutrition(slab_nutrition)
var/obj/item/reagent_containers/food/meat/new_meat = new slab_type(get_turf(src), rand(3,8))
if (istype(new_meat))
new_meat.SetName("[slab_name] [new_meat.name]")
new_meat.reagents.add_reagent(/datum/reagent/nutriment,slab_nutrition * nutrition_transfer_mod)
if (H.reagents)
H.reagents.trans_to_obj(new_meat, round(buckled_mob.reagents.total_volume / meat_limbs_left, 1))
return



10 changes: 10 additions & 0 deletions code/game/objects/structures/stool_bed_chair_nest/wheelchair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,13 @@
pulling = null
usr.pulledby = null
..()
if(ishuman(M))
var/mob/living/carbon/human/H = M
H.update_organ_movespeed()

/obj/structure/bed/chair/wheelchair/unbuckle_mob()
if(ishuman(buckled_mob))
var/mob/living/carbon/human/H = buckled_mob
H.update_organ_movespeed()

return ..()
2 changes: 0 additions & 2 deletions code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@

var/list/decals

var/movement_delay

var/changing_turf

var/footstep_sound = SFX_FOOTSTEP_PLATING
Expand Down
3 changes: 3 additions & 0 deletions code/modules/clothing/clothing_accessories.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
slowdown_accessory = 0
for(var/obj/item/clothing/accessory/A in accessories)
slowdown_accessory += A.slowdown
if(ismob(loc))
var/mob/M = loc
M.update_equipment_slowdown()

/**
* Attach accessory A to src
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/trays/tray.dm
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
nymph.visible_message("<span class='info'><b>[nymph]</b> begins rooting through [src], ripping out weeds and eating them noisily.</span>","<span class='info'>You begin rooting through [src], ripping out weeds and eating them noisily.</span>")
playsound(loc, 'sound/effects/plantshake.ogg', rand(50, 75), TRUE)
else if(nymph.nutrition > 100 && nutrilevel < 10)
nymph.nutrition -= ((10-nutrilevel)*5)
nymph.remove_nutrition((10 - nutrilevel) * 5)
nutrilevel = 10
nymph.visible_message("<span class='info'><b>[nymph]</b> secretes a trickle of green liquid, refilling [src].</span>","<span class='info'>You secrete a trickle of green liquid, refilling [src].</span>")
else
Expand Down
3 changes: 0 additions & 3 deletions code/modules/mob/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,3 @@ var/list/slot_equipment_priority = list( \
/mob/proc/is_item_in_hands(atom/A)
if(A && (l_hand == A || r_hand == A))
return TRUE

/mob/proc/update_equipment_slowdown()
return
12 changes: 5 additions & 7 deletions code/modules/mob/living/bot/remotebot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@

var/working = 0
var/next_movement_time = 0
var/speed = 10 //lower = better
var/obj/item/holding = null
var/obj/item/device/bot_controller/controller = null

/mob/living/bot/remotebot/movement_delay()
var/tally = ..()
tally += speed
if(holding)
tally += (2 * holding.w_class)
return tally
/mob/living/bot/remotebot/Initialize(mapload, ...)
. = ..()
add_movespeed_modifier(/datum/movespeed_modifier/remotebot)

/mob/living/bot/remotebot/_examine_text(mob/user)
. = ..()
Expand Down Expand Up @@ -68,12 +64,14 @@
working = 0
I.forceMove(src)
holding = I
add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/remotebot_holding, 2 * I.w_class)

/mob/living/bot/remotebot/proc/drop_holding()
if(working || !holding)
return
holding.forceMove(loc)
holding = null
remove_movespeed_modifier(/datum/movespeed_modifier/remotebot_holding)

/mob/living/bot/remotebot/proc/hit(atom/movable/a)
src.visible_message("<b>\The [src]</b> taps \the [a] with its claw.")
Expand Down
9 changes: 6 additions & 3 deletions code/modules/mob/living/carbon/alien/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/mob/living/carbon/alien/updatehealth()
if(is_ooc_dead())
return 0
return FALSE

if(status_flags & GODMODE)
health = maxHealth
Expand All @@ -29,8 +29,11 @@
health = maxHealth - getOxyLoss() - getToxLoss() - getFireLoss() - getBruteLoss() - getCloneLoss()
if(health <= 0)
death()
return 0
return 1
return FALSE

update_health_slowdown()

return TRUE


// Currently both Dionaea and larvae like to eat radiation, so I'm defining the
Expand Down
Loading
Loading