mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Status effects start processing immediately instead of on the next timer subsystem tick (#28747)
* Status effects start processing immediately instead of on the next timer subsystem tick * let's fix this while we're at it * hup * not technically efficient but better than not updating when needed
This commit is contained in:
@@ -145,6 +145,11 @@
|
||||
alert_type = /obj/screen/alert/status_effect/power_regen
|
||||
var/power_to_give = 0 //how much power is gained each tick
|
||||
|
||||
/datum/status_effect/cyborg_power_regen/on_creation(mob/living/new_owner, new_power_per_tick)
|
||||
. = ..()
|
||||
if(. && isnum(new_power_per_tick))
|
||||
power_to_give = new_power_per_tick
|
||||
|
||||
/obj/screen/alert/status_effect/power_regen
|
||||
name = "Power Regeneration"
|
||||
desc = "You are quickly regenerating power!"
|
||||
|
||||
@@ -4,26 +4,21 @@
|
||||
tick_interval = 0
|
||||
status_type = STATUS_EFFECT_REPLACE
|
||||
alert_type = null
|
||||
var/update_canmove = TRUE
|
||||
|
||||
/datum/status_effect/incapacitating/on_creation(mob/living/new_owner, updating_canmove)
|
||||
..()
|
||||
if(isnum(updating_canmove))
|
||||
update_canmove = updating_canmove
|
||||
if(update_canmove)
|
||||
owner.update_canmove()
|
||||
if(issilicon(owner))
|
||||
owner.update_stat()
|
||||
|
||||
/datum/status_effect/incapacitating/on_apply()
|
||||
/datum/status_effect/incapacitating/on_creation(mob/living/new_owner, set_duration, updating_canmove)
|
||||
if(isnum(set_duration))
|
||||
duration = set_duration
|
||||
. = ..()
|
||||
update_canmove = TRUE
|
||||
if(.)
|
||||
if(updating_canmove)
|
||||
owner.update_canmove()
|
||||
if(issilicon(owner))
|
||||
owner.update_stat()
|
||||
|
||||
/datum/status_effect/incapacitating/on_remove()
|
||||
if(update_canmove)
|
||||
owner.update_canmove()
|
||||
if(issilicon(owner)) //silicons need stat updates in addition to normal canmove updates
|
||||
owner.update_stat()
|
||||
owner.update_canmove()
|
||||
if(issilicon(owner)) //silicons need stat updates in addition to normal canmove updates
|
||||
owner.update_stat()
|
||||
|
||||
//STUN
|
||||
/datum/status_effect/incapacitating/stun
|
||||
@@ -45,13 +40,14 @@
|
||||
var/mob/living/carbon/human/human_owner
|
||||
|
||||
/datum/status_effect/incapacitating/sleeping/on_creation(mob/living/new_owner, updating_canmove)
|
||||
..()
|
||||
if(update_canmove)
|
||||
owner.update_stat()
|
||||
if(iscarbon(owner)) //to avoid repeated istypes
|
||||
carbon_owner = owner
|
||||
if(ishuman(owner))
|
||||
human_owner = owner
|
||||
. = ..()
|
||||
if(.)
|
||||
if(updating_canmove)
|
||||
owner.update_stat()
|
||||
if(iscarbon(owner)) //to avoid repeated istypes
|
||||
carbon_owner = owner
|
||||
if(ishuman(owner))
|
||||
human_owner = owner
|
||||
|
||||
/datum/status_effect/incapacitating/sleeping/Destroy()
|
||||
carbon_owner = null
|
||||
@@ -71,8 +67,7 @@
|
||||
|
||||
/datum/status_effect/incapacitating/sleeping/on_remove()
|
||||
..()
|
||||
if(update_canmove)
|
||||
owner.update_stat()
|
||||
owner.update_stat()
|
||||
|
||||
/obj/screen/alert/status_effect/asleep
|
||||
name = "Asleep"
|
||||
@@ -163,8 +158,13 @@
|
||||
"Move towards the mania motor.", "Come closer.", "Get over here already!", "Keep your eyes on the motor.")
|
||||
var/static/list/flee_messages = list("Oh, NOW you flee.", "Get back here!", "If you were smarter, you'd come back.", "Only fools run.", "You'll be back.")
|
||||
var/static/list/turnoff_messages = list("Why would they turn it-", "What are these idi-", "Fools, fools, all of-", "Are they trying to c-", "All this effort just f-")
|
||||
var/static/list/powerloss_messages = list("\"Oh, the id**ts di***t s***e en**** pow**...\"", "\"D*dn't **ey mak* an **te***c*i*n le**?\"", "\"The** f**ls for**t t* make a ***** *f-\"", \
|
||||
"\"No, *O, you **re so cl***-\"", "You hear a yell of frustration, cut off by static.")
|
||||
var/static/list/powerloss_messages = list("\"Oh, the id**ts di***t s***e en**** pow**...\"" = TRUE, "\"D*dn't **ey mak* an **te***c*i*n le**?\"" = TRUE, "\"The** f**ls for**t t* make a ***** *f-\"" = TRUE, \
|
||||
"\"No, *O, you **re so cl***-\"" = TRUE, "You hear a yell of frustration, cut off by static." = FALSE)
|
||||
|
||||
/datum/status_effect/maniamotor/on_creation(mob/living/new_owner, obj/structure/destructible/clockwork/powered/mania_motor/new_motor)
|
||||
. = ..()
|
||||
if(.)
|
||||
motor = new_motor
|
||||
|
||||
/datum/status_effect/maniamotor/Destroy()
|
||||
motor = null
|
||||
@@ -183,7 +183,8 @@
|
||||
if(motor.total_accessable_power() > motor.mania_cost)
|
||||
to_chat(owner, "<span class='sevtug[span_part]'>\"[text2ratvar(pick(turnoff_messages))]\"</span>")
|
||||
else
|
||||
to_chat(owner, "<span class='sevtug[span_part]'>[text2ratvar(pick(powerloss_messages))]</span>")
|
||||
var/pickedmessage = pick(powerloss_messages)
|
||||
to_chat(owner, "<span class='sevtug[span_part]'>[powerloss_messages[pickedmessage] ? "[text2ratvar(pickedmessage)]" : pickedmessage]</span>")
|
||||
warned_turnoff = TRUE
|
||||
severity = max(severity - 2, 0)
|
||||
if(!severity)
|
||||
@@ -246,6 +247,11 @@
|
||||
var/mutable_appearance/marked_underlay
|
||||
var/obj/item/weapon/twohanded/required/kinetic_crusher/hammer_synced
|
||||
|
||||
/datum/status_effect/crusher_mark/on_creation(mob/living/new_owner, obj/item/weapon/twohanded/required/kinetic_crusher/new_hammer_synced)
|
||||
. = ..()
|
||||
if(.)
|
||||
hammer_synced = new_hammer_synced
|
||||
|
||||
/datum/status_effect/crusher_mark/on_apply()
|
||||
if(owner.mob_size >= MOB_SIZE_LARGE)
|
||||
marked_underlay = mutable_appearance('icons/effects/effects.dmi', "shield2")
|
||||
|
||||
@@ -25,13 +25,18 @@
|
||||
on_remove_on_mob_delete = TRUE
|
||||
var/obj/item/borg/upgrade/modkit/bounty/reward_target
|
||||
|
||||
/datum/status_effect/syphon_mark/on_creation(mob/living/new_owner, obj/item/borg/upgrade/modkit/bounty/new_reward_target)
|
||||
. = ..()
|
||||
if(.)
|
||||
reward_target = new_reward_target
|
||||
|
||||
/datum/status_effect/syphon_mark/on_apply()
|
||||
if(owner.stat == DEAD)
|
||||
return FALSE
|
||||
return ..()
|
||||
|
||||
/datum/status_effect/syphon_mark/proc/get_kill()
|
||||
if(reward_target)
|
||||
if(!QDELETED(reward_target))
|
||||
reward_target.get_kill(owner)
|
||||
|
||||
/datum/status_effect/syphon_mark/tick()
|
||||
|
||||
@@ -20,20 +20,6 @@
|
||||
owner = new_owner
|
||||
if(owner)
|
||||
LAZYADD(owner.status_effects, src)
|
||||
addtimer(CALLBACK(src, .proc/start_ticking), 0) //Give us the minimum possible time to set any variables
|
||||
|
||||
/datum/status_effect/Destroy()
|
||||
STOP_PROCESSING(SSfastprocess, src)
|
||||
if(owner)
|
||||
owner.clear_alert(id)
|
||||
LAZYREMOVE(owner.status_effects, src)
|
||||
on_remove()
|
||||
owner = null
|
||||
return ..()
|
||||
|
||||
/datum/status_effect/proc/start_ticking()
|
||||
if(!src)
|
||||
return
|
||||
if(!owner || !on_apply())
|
||||
qdel(src)
|
||||
return
|
||||
@@ -45,6 +31,16 @@
|
||||
A.attached_effect = src //so the alert can reference us, if it needs to
|
||||
linked_alert = A //so we can reference the alert, if we need to
|
||||
START_PROCESSING(SSfastprocess, src)
|
||||
return TRUE
|
||||
|
||||
/datum/status_effect/Destroy()
|
||||
STOP_PROCESSING(SSfastprocess, src)
|
||||
if(owner)
|
||||
owner.clear_alert(id)
|
||||
LAZYREMOVE(owner.status_effects, src)
|
||||
on_remove()
|
||||
owner = null
|
||||
return ..()
|
||||
|
||||
/datum/status_effect/process()
|
||||
if(!owner)
|
||||
|
||||
@@ -234,8 +234,7 @@
|
||||
cyborg.visible_message("<span class='warning'>[cyborg] glows a brilliant orange!</span>")
|
||||
var/previous_color = cyborg.color
|
||||
cyborg.color = list("#EC8A2D", "#EC8A2D", "#EC8A2D", rgb(0,0,0))
|
||||
var/datum/status_effect/cyborg_power_regen/CPR = cyborg.apply_status_effect(STATUS_EFFECT_POWERREGEN)
|
||||
CPR.power_to_give = giving_power * 0.1 //ten ticks, restoring 10% each
|
||||
cyborg.apply_status_effect(STATUS_EFFECT_POWERREGEN, giving_power * 0.1) //ten ticks, restoring 10% each
|
||||
animate(cyborg, color = previous_color, time = 100)
|
||||
addtimer(CALLBACK(cyborg, /atom/proc/update_atom_colour), 100)
|
||||
|
||||
|
||||
@@ -60,6 +60,5 @@
|
||||
M = MM
|
||||
break
|
||||
if(!M)
|
||||
M = H.apply_status_effect(STATUS_EFFECT_MANIAMOTOR)
|
||||
M.motor = src
|
||||
M = H.apply_status_effect(STATUS_EFFECT_MANIAMOTOR, src)
|
||||
M.severity = Clamp(M.severity + ((11 - get_dist(src, H)) * efficiency * efficiency), 0, MAX_MANIA_SEVERITY)
|
||||
|
||||
@@ -133,9 +133,8 @@
|
||||
if(isliving(target))
|
||||
var/mob/living/L = target
|
||||
var/had_effect = (L.has_status_effect(STATUS_EFFECT_CRUSHERMARK)) //used as a boolean
|
||||
var/datum/status_effect/crusher_mark/CM = L.apply_status_effect(STATUS_EFFECT_CRUSHERMARK)
|
||||
var/datum/status_effect/crusher_mark/CM = L.apply_status_effect(STATUS_EFFECT_CRUSHERMARK, hammer_synced)
|
||||
if(hammer_synced)
|
||||
CM.hammer_synced = hammer_synced
|
||||
for(var/t in hammer_synced.trophies)
|
||||
var/obj/item/crusher_trophy/T = t
|
||||
T.on_mark_application(target, CM, had_effect)
|
||||
|
||||
@@ -11,10 +11,7 @@
|
||||
/mob/living/proc/AmountStun() //How many deciseconds remain in our stun
|
||||
var/datum/status_effect/incapacitating/stun/S = IsStun()
|
||||
if(S)
|
||||
if(S.isprocessing)
|
||||
return S.duration - world.time
|
||||
else
|
||||
return S.duration
|
||||
return S.duration - world.time
|
||||
return 0
|
||||
|
||||
/mob/living/proc/Stun(amount, updating = TRUE, ignore_canstun = FALSE) //Can't go below remaining duration
|
||||
@@ -23,14 +20,9 @@
|
||||
return
|
||||
var/datum/status_effect/incapacitating/stun/S = IsStun()
|
||||
if(S)
|
||||
if(S.isprocessing)
|
||||
S.duration = max(world.time + amount, S.duration)
|
||||
else
|
||||
S.duration = max(amount, S.duration)
|
||||
S.duration = max(world.time + amount, S.duration)
|
||||
else if(amount > 0)
|
||||
S = apply_status_effect(STATUS_EFFECT_STUN, updating)
|
||||
S.duration = amount
|
||||
S.update_canmove = updating
|
||||
S = apply_status_effect(STATUS_EFFECT_STUN, amount, updating)
|
||||
return S
|
||||
|
||||
/mob/living/proc/SetStun(amount, updating = TRUE, ignore_canstun = FALSE) //Sets remaining duration
|
||||
@@ -38,19 +30,14 @@
|
||||
var/datum/status_effect/incapacitating/stun/S = IsStun()
|
||||
if(amount <= 0)
|
||||
if(S)
|
||||
S.update_canmove = updating
|
||||
qdel(S)
|
||||
else
|
||||
if(absorb_stun(amount, ignore_canstun))
|
||||
return
|
||||
if(S)
|
||||
if(S.isprocessing)
|
||||
S.duration = world.time + amount
|
||||
else
|
||||
S.duration = amount
|
||||
S.duration = world.time + amount
|
||||
else
|
||||
S = apply_status_effect(STATUS_EFFECT_STUN, updating)
|
||||
S.duration = amount
|
||||
S = apply_status_effect(STATUS_EFFECT_STUN, amount, updating)
|
||||
return S
|
||||
|
||||
/mob/living/proc/AdjustStun(amount, updating = TRUE, ignore_canstun = FALSE) //Adds to remaining duration
|
||||
@@ -61,8 +48,7 @@
|
||||
if(S)
|
||||
S.duration += amount
|
||||
else if(amount > 0)
|
||||
S = apply_status_effect(STATUS_EFFECT_STUN, updating)
|
||||
S.duration = amount
|
||||
S = apply_status_effect(STATUS_EFFECT_STUN, amount, updating)
|
||||
return S
|
||||
|
||||
///////////////////////////////// KNOCKDOWN /////////////////////////////////////
|
||||
@@ -73,10 +59,7 @@
|
||||
/mob/living/proc/AmountKnockdown() //How many deciseconds remain in our knockdown
|
||||
var/datum/status_effect/incapacitating/knockdown/K = IsKnockdown()
|
||||
if(K)
|
||||
if(K.isprocessing)
|
||||
return K.duration - world.time
|
||||
else
|
||||
return K.duration
|
||||
return K.duration - world.time
|
||||
return 0
|
||||
|
||||
/mob/living/proc/Knockdown(amount, updating = TRUE, ignore_canknockdown = FALSE) //Can't go below remaining duration
|
||||
@@ -85,13 +68,9 @@
|
||||
return
|
||||
var/datum/status_effect/incapacitating/knockdown/K = IsKnockdown()
|
||||
if(K)
|
||||
if(K.isprocessing)
|
||||
K.duration = max(world.time + amount, K.duration)
|
||||
else
|
||||
K.duration = max(amount, K.duration)
|
||||
K.duration = max(world.time + amount, K.duration)
|
||||
else if(amount > 0)
|
||||
K = apply_status_effect(STATUS_EFFECT_KNOCKDOWN, updating)
|
||||
K.duration = amount
|
||||
K = apply_status_effect(STATUS_EFFECT_KNOCKDOWN, amount, updating)
|
||||
return K
|
||||
|
||||
/mob/living/proc/SetKnockdown(amount, updating = TRUE, ignore_canknockdown = FALSE) //Sets remaining duration
|
||||
@@ -99,19 +78,14 @@
|
||||
var/datum/status_effect/incapacitating/knockdown/K = IsKnockdown()
|
||||
if(amount <= 0)
|
||||
if(K)
|
||||
K.update_canmove = updating
|
||||
qdel(K)
|
||||
else
|
||||
if(absorb_stun(amount, ignore_canknockdown))
|
||||
return
|
||||
if(K)
|
||||
if(K.isprocessing)
|
||||
K.duration = world.time + amount
|
||||
else
|
||||
K.duration = amount
|
||||
K.duration = world.time + amount
|
||||
else
|
||||
K = apply_status_effect(STATUS_EFFECT_KNOCKDOWN, updating)
|
||||
K.duration = amount
|
||||
K = apply_status_effect(STATUS_EFFECT_KNOCKDOWN, amount, updating)
|
||||
return K
|
||||
|
||||
/mob/living/proc/AdjustKnockdown(amount, updating = TRUE, ignore_canknockdown = FALSE) //Adds to remaining duration
|
||||
@@ -122,8 +96,7 @@
|
||||
if(K)
|
||||
K.duration += amount
|
||||
else if(amount > 0)
|
||||
K = apply_status_effect(STATUS_EFFECT_KNOCKDOWN, updating)
|
||||
K.duration = amount
|
||||
K = apply_status_effect(STATUS_EFFECT_KNOCKDOWN, amount, updating)
|
||||
return K
|
||||
|
||||
///////////////////////////////////// STUN ABSORPTION /////////////////////////////////////
|
||||
|
||||
@@ -24,23 +24,16 @@
|
||||
/mob/living/proc/AmountUnconscious() //How many deciseconds remain in our unconsciousness
|
||||
var/datum/status_effect/incapacitating/unconscious/U = IsUnconscious()
|
||||
if(U)
|
||||
if(U.isprocessing)
|
||||
return U.duration - world.time
|
||||
else
|
||||
return U.duration
|
||||
return U.duration - world.time
|
||||
return 0
|
||||
|
||||
/mob/living/proc/Unconscious(amount, updating = TRUE, ignore_canunconscious = FALSE) //Can't go below remaining duration
|
||||
if((status_flags & CANUNCONSCIOUS) || ignore_canunconscious)
|
||||
var/datum/status_effect/incapacitating/unconscious/U = IsUnconscious()
|
||||
if(U)
|
||||
if(U.isprocessing)
|
||||
U.duration = max(world.time + amount, U.duration)
|
||||
else
|
||||
U.duration = max(amount, U.duration)
|
||||
U.duration = max(world.time + amount, U.duration)
|
||||
else if(amount > 0)
|
||||
U = apply_status_effect(STATUS_EFFECT_UNCONSCIOUS, updating)
|
||||
U.duration = amount
|
||||
U = apply_status_effect(STATUS_EFFECT_UNCONSCIOUS, amount, updating)
|
||||
return U
|
||||
|
||||
/mob/living/proc/SetUnconscious(amount, updating = TRUE, ignore_canunconscious = FALSE) //Sets remaining duration
|
||||
@@ -48,16 +41,11 @@
|
||||
var/datum/status_effect/incapacitating/unconscious/U = IsUnconscious()
|
||||
if(amount <= 0)
|
||||
if(U)
|
||||
U.update_canmove = updating
|
||||
qdel(U)
|
||||
else if(U)
|
||||
if(U.isprocessing)
|
||||
U.duration = world.time + amount
|
||||
else
|
||||
U.duration = amount
|
||||
U.duration = world.time + amount
|
||||
else
|
||||
U = apply_status_effect(STATUS_EFFECT_UNCONSCIOUS, updating)
|
||||
U.duration = amount
|
||||
U = apply_status_effect(STATUS_EFFECT_UNCONSCIOUS, amount, updating)
|
||||
return U
|
||||
|
||||
/mob/living/proc/AdjustUnconscious(amount, updating = TRUE, ignore_canunconscious = FALSE) //Adds to remaining duration
|
||||
@@ -66,8 +54,7 @@
|
||||
if(U)
|
||||
U.duration += amount
|
||||
else if(amount > 0)
|
||||
U = apply_status_effect(STATUS_EFFECT_UNCONSCIOUS, updating)
|
||||
U.duration = amount
|
||||
U = apply_status_effect(STATUS_EFFECT_UNCONSCIOUS, amount, updating)
|
||||
return U
|
||||
|
||||
/////////////////////////////////// SLEEPING ////////////////////////////////////
|
||||
@@ -78,38 +65,26 @@
|
||||
/mob/living/proc/AmountSleeping() //How many deciseconds remain in our sleep
|
||||
var/datum/status_effect/incapacitating/sleeping/S = IsSleeping()
|
||||
if(S)
|
||||
if(S.isprocessing)
|
||||
return S.duration - world.time
|
||||
else
|
||||
return S.duration
|
||||
return S.duration - world.time
|
||||
return 0
|
||||
|
||||
/mob/living/proc/Sleeping(amount, updating = TRUE) //Can't go below remaining duration
|
||||
var/datum/status_effect/incapacitating/sleeping/S = IsSleeping()
|
||||
if(S)
|
||||
if(S.isprocessing)
|
||||
S.duration = max(world.time + amount, S.duration)
|
||||
else
|
||||
S.duration = max(amount, S.duration)
|
||||
S.duration = max(world.time + amount, S.duration)
|
||||
else if(amount > 0)
|
||||
S = apply_status_effect(STATUS_EFFECT_SLEEPING, updating)
|
||||
S.duration = amount
|
||||
S = apply_status_effect(STATUS_EFFECT_SLEEPING, amount, updating)
|
||||
return S
|
||||
|
||||
/mob/living/proc/SetSleeping(amount, updating = TRUE) //Sets remaining duration
|
||||
var/datum/status_effect/incapacitating/sleeping/S = IsSleeping()
|
||||
if(amount <= 0)
|
||||
if(S)
|
||||
S.update_canmove = updating
|
||||
qdel(S)
|
||||
else if(S)
|
||||
if(S.isprocessing)
|
||||
S.duration = world.time + amount
|
||||
else
|
||||
S.duration = amount
|
||||
S.duration = world.time + amount
|
||||
else
|
||||
S = apply_status_effect(STATUS_EFFECT_SLEEPING, updating)
|
||||
S.duration = amount
|
||||
S = apply_status_effect(STATUS_EFFECT_SLEEPING, amount, updating)
|
||||
return S
|
||||
|
||||
/mob/living/proc/AdjustSleeping(amount, updating = TRUE) //Adds to remaining duration
|
||||
@@ -117,8 +92,7 @@
|
||||
if(S)
|
||||
S.duration += amount
|
||||
else if(amount > 0)
|
||||
S = apply_status_effect(STATUS_EFFECT_SLEEPING, updating)
|
||||
S.duration = amount
|
||||
S = apply_status_effect(STATUS_EFFECT_SLEEPING, amount, updating)
|
||||
return S
|
||||
|
||||
/////////////////////////////////// RESTING ////////////////////////////////////
|
||||
|
||||
@@ -448,8 +448,7 @@
|
||||
if(SM.reward_target == src) //we want to allow multiple people with bounty modkits to use them, but we need to replace our own marks so we don't multi-reward
|
||||
SM.reward_target = null
|
||||
qdel(SM)
|
||||
var/datum/status_effect/syphon_mark/SM = L.apply_status_effect(STATUS_EFFECT_SYPHONMARK)
|
||||
SM.reward_target = src
|
||||
L.apply_status_effect(STATUS_EFFECT_SYPHONMARK, src)
|
||||
|
||||
/obj/item/borg/upgrade/modkit/bounty/projectile_strike(obj/item/projectile/kinetic/K, turf/target_turf, atom/target, obj/item/weapon/gun/energy/kinetic_accelerator/KA)
|
||||
if(isliving(target))
|
||||
|
||||
Reference in New Issue
Block a user