[MIRROR] Implements timed_action_flags for do_after-like procs (#1385)

* Implements timed_action_flags for do_after-like procs (#54409)

Originally I wanted to fix an issue where the `get_up()` `do_after()` would ignore the callback checks, because it was `uninterruptible`, so that made me refactor these procs to allow for higher granularity on checks and standardize behavior a bit more.
There's more work to be done for them, but one thing at a time.

* Removes the `uninterruptible` check in favor of the more granular `timed_action_flags`
* Cleans code on the `do_atom`, `do_after_mob`, `do_mob` and `do_after` procs to standardize them a little better.

* Implements timed_action_flags for do_after-like procs

* Update horror_form.dm

Co-authored-by: Rohesie <rohesie@gmail.com>
Co-authored-by: Azarak <azarak10@gmail.com>
This commit is contained in:
SkyratBot
2020-10-21 07:06:03 +02:00
committed by GitHub
co-authored by Rohesie Azarak
parent 4299f0555f
commit f02e30a50e
43 changed files with 155 additions and 130 deletions
+1 -1
View File
@@ -249,7 +249,7 @@
M.visible_message("<span class='warning'>[user] starts buckling [M] to [src]!</span>",\
"<span class='userdanger'>[user] starts buckling you to [src]!</span>",\
"<span class='hear'>You hear metal clanking.</span>")
if(!do_after(user, 2 SECONDS, TRUE, M))
if(!do_after(user, 2 SECONDS, M))
return FALSE
// Sanity check before we attempt to buckle. Is everything still in a kosher state for buckling after the 3 seconds have elapsed?
+9 -10
View File
@@ -77,13 +77,12 @@
user.last_special = world.time + CLICK_CD_BREAKOUT
to_chat(user, "<span class='notice'>You claw at the fabric of [src], trying to tear it open...</span>")
to_chat(loc, "<span class='warning'>Someone starts trying to break free of [src]!</span>")
if(do_after_mob(user, src, 12 SECONDS, TRUE))
if(user.loc != src)
return
// you are still in the bag? time to go unless you KO'd, honey!
// if they escape during this time and you rebag them the timer is still clocking down and does NOT reset so they can very easily get out.
if(user.incapacitated())
to_chat(loc, "<span class='warning'>The pressure subsides. It seems that they've stopped resisting...</span>")
return
loc.visible_message("<span class='warning'>[user] suddenly appears in front of [loc]!</span>", "<span class='userdanger'>[user] breaks free of [src]!</span>")
qdel(src)
if(!do_mob(user, src, 12 SECONDS, timed_action_flags = (IGNORE_TARGET_LOC_CHANGE|IGNORE_HELD_ITEM)))
return
// you are still in the bag? time to go unless you KO'd, honey!
// if they escape during this time and you rebag them the timer is still clocking down and does NOT reset so they can very easily get out.
if(user.incapacitated())
to_chat(loc, "<span class='warning'>The pressure subsides. It seems that they've stopped resisting...</span>")
return
loc.visible_message("<span class='warning'>[user] suddenly appears in front of [loc]!</span>", "<span class='userdanger'>[user] breaks free of [src]!</span>")
qdel(src)
+1 -1
View File
@@ -104,7 +104,7 @@
var/new_appearance = show_radial_menu(user, src, possible_appearances, custom_check = CALLBACK(src, .proc/check_menu, user, crayon), radius = 36, require_near = TRUE)
if(!new_appearance)
return FALSE
if(!do_after(user, 10, FALSE, src, TRUE))
if(!do_after(user, 1 SECONDS, src, timed_action_flags = IGNORE_HELD_ITEM))
return FALSE
if(!check_menu(user, crayon))
return FALSE
+4 -4
View File
@@ -498,7 +498,7 @@
"<span class='warning'>You overcharge the paddles and begin to place them onto [H]'s chest...</span>")
busy = TRUE
update_icon()
if(do_after(user, 15, TRUE, H))
if(do_after(user, 1.5 SECONDS, H))
user.visible_message("<span class='notice'>[user] places [src] on [H]'s chest.</span>",
"<span class='warning'>You place [src] on [H]'s chest and begin to charge them.</span>")
var/turf/T = get_turf(defib)
@@ -507,7 +507,7 @@
T.audible_message("<span class='warning'>\The [defib] lets out an urgent beep and lets out a steadily rising hum...</span>")
else
user.audible_message("<span class='warning'>[src] let out an urgent beep.</span>")
if(do_after(user, 15, TRUE, H)) //Takes longer due to overcharging
if(do_after(user, 1.5 SECONDS, H)) //Takes longer due to overcharging
if(!H)
busy = FALSE
update_icon()
@@ -548,11 +548,11 @@
user.visible_message("<span class='warning'>[user] begins to place [src] on [H]'s chest.</span>", "<span class='warning'>You begin to place [src] on [H]'s chest...</span>")
busy = TRUE
update_icon()
if(do_after(user, 30, TRUE, H)) //beginning to place the paddles on patient's chest to allow some time for people to move away to stop the process
if(do_after(user, 3 SECONDS, H)) //beginning to place the paddles on patient's chest to allow some time for people to move away to stop the process
user.visible_message("<span class='notice'>[user] places [src] on [H]'s chest.</span>", "<span class='warning'>You place [src] on [H]'s chest.</span>")
playsound(src, 'sound/machines/defib_charge.ogg', 75, FALSE)
var/obj/item/organ/heart = H.getorgan(/obj/item/organ/heart)
if(do_after(user, 20, TRUE, H)) //placed on chest and short delay to shock for dramatic effect, revive time is 5sec total
if(do_after(user, 2 SECONDS, H)) //placed on chest and short delay to shock for dramatic effect, revive time is 5sec total
if((!combat && !req_defib) || (req_defib && !defib.combat))
for(var/obj/item/clothing/C in H.get_equipped_items())
if((C.body_parts_covered & CHEST) && (C.clothing_flags & THICKMATERIAL)) //check to see if something is obscuring their chest.
+1 -1
View File
@@ -59,7 +59,7 @@
shaking = TRUE
start_shaking(user)
if(do_after(user, shake_time, needhand=TRUE, target=user, progress=TRUE))
if(do_after(user, shake_time))
var/answer = get_answer()
say(answer)
+1 -1
View File
@@ -165,7 +165,7 @@
/obj/item/food/monkeycube/suicide_act(mob/living/M)
M.visible_message("<span class='suicide'>[M] is putting [src] in [M.p_their()] mouth! It looks like [M.p_theyre()] trying to commit suicide!</span>")
var/eating_success = do_after(M, 10, TRUE, src, TRUE)
var/eating_success = do_after(M, 1 SECONDS, src)
if(QDELETED(M)) //qdeletion: the nuclear option of self-harm
return SHAME
if(!eating_success || QDELETED(src)) //checks if src is gone or if they failed to wait for a second
+2 -2
View File
@@ -12,7 +12,7 @@
/obj/item/book/granter/proc/turn_page(mob/user)
playsound(user, pick('sound/effects/pageturn1.ogg','sound/effects/pageturn2.ogg','sound/effects/pageturn3.ogg'), 30, TRUE)
if(do_after(user, 50, TRUE, src))
if(do_after(user, 5 SECONDS, src))
if(remarks.len)
to_chat(user, "<span class='notice'>[pick(remarks)]</span>")
else
@@ -57,7 +57,7 @@
on_reading_stopped()
reading = FALSE
return
if(do_after(user, 50, TRUE, src))
if(do_after(user, 5 SECONDS, src))
on_reading_finished(user)
reading = FALSE
return TRUE
+1 -1
View File
@@ -330,7 +330,7 @@
if(staffcooldown + staffwait > world.time)
return
user.visible_message("<span class='notice'>[user] chants deeply and waves [user.p_their()] staff!</span>")
if(do_after(user, 20,1,src))
if(do_after(user, 2 SECONDS, src))
target.add_atom_colour(conversion_color, WASHABLE_COLOUR_PRIORITY) //wololo
staffcooldown = world.time
+1 -1
View File
@@ -58,7 +58,7 @@
return
else if(istype(C) && C.has_status_effect(STATUS_EFFECT_CHOKINGSTRAND))
to_chat(C, "<span class='notice'>You attempt to remove the durathread strand from around your neck.</span>")
if(do_after(user, 15, null, C))
if(do_after(user, 1.5 SECONDS, C))
to_chat(C, "<span class='notice'>You succesfuly remove the durathread strand.</span>")
C.remove_status_effect(STATUS_EFFECT_CHOKINGSTRAND)
else
@@ -466,7 +466,7 @@
/obj/structure/chair/plastic/proc/snap_check(mob/living/carbon/Mob)
if (Mob.nutrition >= NUTRITION_LEVEL_FAT)
to_chat(Mob, "<span class='warning'>The chair begins to pop and crack, you're too heavy!</span>")
if(do_after(Mob, 60, 1, Mob, 0))
if(do_after(Mob, 6 SECONDS, progress = FALSE))
Mob.visible_message("<span class='notice'>The plastic chair snaps under [Mob]'s weight!</span>")
new /obj/effect/decal/cleanable/plastic(loc)
qdel(src)
@@ -335,7 +335,7 @@
if((user.a_intent != INTENT_HARM) && istype(I, /obj/item/paper) && (obj_integrity < max_integrity))
user.visible_message("<span class='notice'>[user] starts to patch the holes in [src].</span>", "<span class='notice'>You start patching some of the holes in [src]!</span>")
if(do_after(user, 20, TRUE, src))
if(do_after(user, 2 SECONDS, src))
obj_integrity = min(obj_integrity+4,max_integrity)
qdel(I)
user.visible_message("<span class='notice'>[user] patches some of the holes in [src].</span>", "<span class='notice'>You patch some of the holes in [src]!</span>")
+1 -1
View File
@@ -40,7 +40,7 @@
GM.visible_message("<span class='danger'>[user] starts to give [GM] a swirlie!</span>", "<span class='userdanger'>[user] starts to give you a swirlie...</span>")
swirlie = GM
var/was_alive = (swirlie.stat != DEAD)
if(do_after(user, 30, 0, target = src))
if(do_after(user, 3 SECONDS, target = src, timed_action_flags = IGNORE_HELD_ITEM))
GM.visible_message("<span class='danger'>[user] gives [GM] a swirlie!</span>", "<span class='userdanger'>[user] gives you a swirlie!</span>", "<span class='hear'>You hear a toilet flushing.</span>")
if(iscarbon(GM))
var/mob/living/carbon/C = GM