From 7eeaefe645773ca3e727cb298acf5bf1754ca6e5 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 9 Oct 2020 18:28:59 +0200 Subject: [PATCH] [MIRROR] Fixes some potential sleeps as detected by SpacemanDMM improvements (#1216) * Fix some potential sleeps as detected by SpacemanDMM improvements (#54230) overrides weren't detected by should not sleep, i think i've mostly fixed that with SpaceManiac/SpacemanDMM#214 Some of these are wacky but overall this pr is harmless signals shouldnt sleep even in weird 1 in a million situations or due to other people adding bad code overrides of changeling can_sting() use alert() and input() and that's just too fucked for me to fix in this pr * Fixes some potential sleeps as detected by SpacemanDMM improvements Co-authored-by: spookydonut --- code/datums/brain_damage/creepy_trauma.dm | 2 +- .../storage/concrete/bag_of_holding.dm | 32 +++++++------ code/datums/mutations/telekinesis.dm | 2 +- code/datums/wires/airlock.dm | 42 +++++++++-------- code/datums/wounds/bones.dm | 2 +- .../game/gamemodes/clown_ops/clown_weapons.dm | 3 +- code/game/machinery/computer/camera.dm | 2 +- code/game/machinery/doors/airlock.dm | 8 ++-- code/game/machinery/doors/airlock_types.dm | 4 +- .../embedded_controller/access_controller.dm | 8 ++-- code/game/objects/items.dm | 2 +- code/game/objects/items/puzzle_pieces.dm | 3 +- code/game/objects/items/stunbaton.dm | 4 +- code/game/objects/items/toys.dm | 11 +++-- .../antagonists/changeling/changeling.dm | 2 +- code/modules/mob/living/carbon/carbon.dm | 2 +- code/modules/mob/living/carbon/death.dm | 2 +- code/modules/mob/living/living.dm | 2 +- .../living/simple_animal/bot/SuperBeepsky.dm | 2 +- .../living/simple_animal/eldritch_demons.dm | 2 +- .../mob/living/simple_animal/friendly/dog.dm | 2 +- .../simple_animal/hostile/mecha_pilot.dm | 2 +- .../chemistry/recipes/pyrotechnics.dm | 45 ++++++++++--------- .../chemistry/recipes/slime_extracts.dm | 10 +++-- code/modules/surgery/bodyparts/_bodyparts.dm | 2 +- .../surgery/bodyparts/dismemberment.dm | 2 +- code/modules/vehicles/mecha/_mecha.dm | 4 +- code/modules/vehicles/mecha/combat/durand.dm | 2 +- 28 files changed, 111 insertions(+), 95 deletions(-) diff --git a/code/datums/brain_damage/creepy_trauma.dm b/code/datums/brain_damage/creepy_trauma.dm index aa810aed122..8be9d52173b 100644 --- a/code/datums/brain_damage/creepy_trauma.dm +++ b/code/datums/brain_damage/creepy_trauma.dm @@ -91,7 +91,7 @@ owner.vomit() fail = TRUE if(2) - owner.emote("cough") + INVOKE_ASYNC(owner, /mob.proc/emote, "cough") owner.dizziness += 10 fail = TRUE if(3) diff --git a/code/datums/components/storage/concrete/bag_of_holding.dm b/code/datums/components/storage/concrete/bag_of_holding.dm index 0f83d15cad9..9edbe00e9ea 100644 --- a/code/datums/components/storage/concrete/bag_of_holding.dm +++ b/code/datums/components/storage/concrete/bag_of_holding.dm @@ -5,19 +5,23 @@ var/list/obj/item/storage/backpack/holding/matching = typecache_filter_list(W.GetAllContents(), typecacheof(/obj/item/storage/backpack/holding)) matching -= A if(istype(W, /obj/item/storage/backpack/holding) || matching.len) - var/safety = alert(user, "Doing this will have extremely dire consequences for the station and its crew. Be sure you know what you're doing.", "Put in [A.name]?", "Proceed", "Abort") - if(safety != "Proceed" || QDELETED(A) || QDELETED(W) || QDELETED(user) || !user.canUseTopic(A, BE_CLOSE, iscarbon(user))) - return - var/turf/loccheck = get_turf(A) - to_chat(user, "The Bluespace interfaces of the two devices catastrophically malfunction!") - qdel(W) - playsound(loccheck,'sound/effects/supermatter.ogg', 200, TRUE) - - message_admins("[ADMIN_LOOKUPFLW(user)] detonated a bag of holding at [ADMIN_VERBOSEJMP(loccheck)].") - log_game("[key_name(user)] detonated a bag of holding at [loc_name(loccheck)].") - - user.gib(TRUE, TRUE, TRUE) - new/obj/singularity/boh_tear(loccheck) - qdel(A) + INVOKE_ASYNC(src, .proc/recursive_insertion, W, user) return . = ..() + +/datum/component/storage/concrete/bluespace/bag_of_holding/proc/recursive_insertion(obj/item/W, mob/living/user) + var/atom/A = parent + var/safety = alert(user, "Doing this will have extremely dire consequences for the station and its crew. Be sure you know what you're doing.", "Put in [A.name]?", "Proceed", "Abort") + if(safety != "Proceed" || QDELETED(A) || QDELETED(W) || QDELETED(user) || !user.canUseTopic(A, BE_CLOSE, iscarbon(user))) + return + var/turf/loccheck = get_turf(A) + to_chat(user, "The Bluespace interfaces of the two devices catastrophically malfunction!") + qdel(W) + playsound(loccheck,'sound/effects/supermatter.ogg', 200, TRUE) + + message_admins("[ADMIN_LOOKUPFLW(user)] detonated a bag of holding at [ADMIN_VERBOSEJMP(loccheck)].") + log_game("[key_name(user)] detonated a bag of holding at [loc_name(loccheck)].") + + user.gib(TRUE, TRUE, TRUE) + new/obj/singularity/boh_tear(loccheck) + qdel(A) diff --git a/code/datums/mutations/telekinesis.dm b/code/datums/mutations/telekinesis.dm index ffa762aa4fb..beee7f3537e 100644 --- a/code/datums/mutations/telekinesis.dm +++ b/code/datums/mutations/telekinesis.dm @@ -32,4 +32,4 @@ /datum/mutation/human/telekinesis/proc/on_ranged_attack(datum/source, atom/target) SIGNAL_HANDLER - target.attack_tk(owner) + INVOKE_ASYNC(target, /atom.proc/attack_tk, owner) diff --git a/code/datums/wires/airlock.dm b/code/datums/wires/airlock.dm index e0bec0c3995..6ed570b88f6 100644 --- a/code/datums/wires/airlock.dm +++ b/code/datums/wires/airlock.dm @@ -1,3 +1,8 @@ +#define AI_WIRE_NORMAL 0 +#define AI_WIRE_DISABLED 1 +#define AI_WIRE_HACKED 2 +#define AI_WIRE_DISABLED_HACKED -1 + /datum/wires/airlock holder_type = /obj/machinery/door/airlock proper_name = "Generic Airlock" @@ -108,16 +113,11 @@ A.emergency = FALSE A.update_icon() if(WIRE_AI) // Pulse to disable WIRE_AI control for 10 ticks (follows same rules as cutting). - if(A.aiControlDisabled == 0) - A.aiControlDisabled = 1 - else if(A.aiControlDisabled == -1) - A.aiControlDisabled = 2 - sleep(10) - if(A) - if(A.aiControlDisabled == 1) - A.aiControlDisabled = 0 - else if(A.aiControlDisabled == 2) - A.aiControlDisabled = -1 + if(A.aiControlDisabled == AI_WIRE_NORMAL) + A.aiControlDisabled = AI_WIRE_DISABLED + else if(A.aiControlDisabled == AI_WIRE_DISABLED_HACKED) + A.aiControlDisabled = AI_WIRE_HACKED + addtimer(CALLBACK(A, /obj/machinery/door/airlock.proc/reset_ai_wire), 1 SECONDS) if(WIRE_SHOCK) // Pulse to shock the door for 10 ticks. if(!A.secondsElectrified) A.set_electrified(MACHINE_DEFAULT_ELECTRIFY_TIME, usr) @@ -132,6 +132,12 @@ A.lights = !A.lights A.update_icon() +/obj/machinery/door/airlock/proc/reset_ai_wire() + if(aiControlDisabled == AI_WIRE_DISABLED) + aiControlDisabled = AI_WIRE_NORMAL + else if(aiControlDisabled == AI_WIRE_HACKED) + aiControlDisabled = AI_WIRE_DISABLED_HACKED + /datum/wires/airlock/on_cut(wire, mend) var/obj/machinery/door/airlock/A = holder switch(wire) @@ -154,15 +160,15 @@ A.bolt() if(WIRE_AI) // Cut to disable WIRE_AI control, mend to re-enable. if(mend) - if(A.aiControlDisabled == 1) // 0 = normal, 1 = locked out, 2 = overridden by WIRE_AI, -1 = previously overridden by WIRE_AI - A.aiControlDisabled = 0 - else if(A.aiControlDisabled == 2) - A.aiControlDisabled = -1 + if(A.aiControlDisabled == AI_WIRE_DISABLED) // 0 = normal, 1 = locked out, 2 = overridden by WIRE_AI, -1 = previously overridden by WIRE_AI + A.aiControlDisabled = AI_WIRE_NORMAL + else if(A.aiControlDisabled == AI_WIRE_HACKED) + A.aiControlDisabled = AI_WIRE_DISABLED_HACKED else - if(A.aiControlDisabled == 0) - A.aiControlDisabled = 1 - else if(A.aiControlDisabled == -1) - A.aiControlDisabled = 2 + if(A.aiControlDisabled == AI_WIRE_NORMAL) + A.aiControlDisabled = AI_WIRE_DISABLED + else if(A.aiControlDisabled == AI_WIRE_DISABLED_HACKED) + A.aiControlDisabled = AI_WIRE_HACKED if(WIRE_SHOCK) // Cut to shock the door, mend to unshock. if(mend) if(A.secondsElectrified) diff --git a/code/datums/wounds/bones.dm b/code/datums/wounds/bones.dm index 67575cf51d8..58cda92cffe 100644 --- a/code/datums/wounds/bones.dm +++ b/code/datums/wounds/bones.dm @@ -97,7 +97,7 @@ else victim.visible_message("[victim] weakly strikes [target] with [victim.p_their()] broken [limb.name], recoiling from pain!", \ "You fail to strike [target] as the fracture in your [limb.name] lights up in unbearable pain!", vision_distance=COMBAT_MESSAGE_RANGE) - victim.emote("scream") + INVOKE_ASYNC(victim, /mob.proc/emote, "scream") victim.Stun(0.5 SECONDS) limb.receive_damage(brute=rand(3,7)) return COMPONENT_NO_ATTACK_HAND diff --git a/code/game/gamemodes/clown_ops/clown_weapons.dm b/code/game/gamemodes/clown_ops/clown_weapons.dm index c08f3cf023a..b04f1abbd11 100644 --- a/code/game/gamemodes/clown_ops/clown_weapons.dm +++ b/code/game/gamemodes/clown_ops/clown_weapons.dm @@ -157,8 +157,7 @@ var/datum/component/slippery/slipper = GetComponent(/datum/component/slippery) slipper.Slip(src, hit_atom) if(thrownby && !caught) - sleep(1) - throw_at(thrownby, throw_range+2, throw_speed, null, TRUE) + addtimer(CALLBACK(src, /atom/movable.proc/throw_at, thrownby, throw_range+2, throw_speed, null, TRUE), 1) else return ..() diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index 4042a30def0..961bb940506 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -283,7 +283,7 @@ /obj/machinery/computer/security/telescreen/entertainment/proc/BigClick() SIGNAL_HANDLER - interact(usr) + INVOKE_ASYNC(src, /atom.proc/interact, usr) /obj/machinery/computer/security/telescreen/entertainment/proc/notify(on) if(on && icon_state == icon_state_off) diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index bb0517353b4..d405d7cf212 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -59,7 +59,7 @@ interaction_flags_machine = INTERACT_MACHINE_WIRES_IF_OPEN | INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OPEN_SILICON | INTERACT_MACHINE_REQUIRES_SILICON | INTERACT_MACHINE_OPEN var/security_level = 0 //How much are wires secured - var/aiControlDisabled = 0 //If 1, AI control is disabled until the AI hacks back in and disables the lock. If 2, the AI has bypassed the lock. If -1, the control is enabled but the AI had bypassed it earlier, so if it is disabled again the AI would have no trouble getting back in. + var/aiControlDisabled = AI_WIRE_NORMAL //If 1, AI control is disabled until the AI hacks back in and disables the lock. If 2, the AI has bypassed the lock. If -1, the control is enabled but the AI had bypassed it earlier, so if it is disabled again the AI would have no trouble getting back in. var/hackProof = FALSE // if true, this door can't be hacked by the AI var/secondsMainPowerLost = 0 //The number of seconds until power is restored. var/secondsBackupPowerLost = 0 //The number of seconds until power is restored. @@ -332,10 +332,10 @@ return (secondsElectrified != MACHINE_NOT_ELECTRIFIED) /obj/machinery/door/airlock/proc/canAIControl(mob/user) - return ((aiControlDisabled != 1) && !isAllPowerCut()) + return ((aiControlDisabled != AI_WIRE_DISABLED) && !isAllPowerCut()) /obj/machinery/door/airlock/proc/canAIHack() - return ((aiControlDisabled==1) && (!hackProof) && (!isAllPowerCut())); + return ((aiControlDisabled==AI_WIRE_DISABLED) && (!hackProof) && (!isAllPowerCut())); /obj/machinery/door/airlock/hasPower() return ((!secondsMainPowerLost || !secondsBackupPowerLost) && !(machine_stat & NOPOWER)) @@ -719,7 +719,7 @@ to_chat(user, "Transfer complete. Forcing airlock to execute program.") sleep(50) //disable blocked control - aiControlDisabled = 2 + aiControlDisabled = AI_WIRE_HACKED to_chat(user, "Receiving control information from airlock.") sleep(10) //bring up airlock dialog diff --git a/code/game/machinery/doors/airlock_types.dm b/code/game/machinery/doors/airlock_types.dm index 275022e6437..be8e56ed526 100644 --- a/code/game/machinery/doors/airlock_types.dm +++ b/code/game/machinery/doors/airlock_types.dm @@ -431,7 +431,7 @@ damage_deflection = 30 explosion_block = 3 hackProof = TRUE - aiControlDisabled = 1 + aiControlDisabled = AI_WIRE_DISABLED normal_integrity = 700 security_level = 1 @@ -446,7 +446,7 @@ overlays_file = 'icons/obj/doors/airlocks/cult/runed/overlays.dmi' assemblytype = /obj/structure/door_assembly/door_assembly_cult hackProof = TRUE - aiControlDisabled = 1 + aiControlDisabled = AI_WIRE_DISABLED req_access = list(ACCESS_BLOODCULT) damage_deflection = 10 var/openingoverlaytype = /obj/effect/temp_visual/cult/door diff --git a/code/game/machinery/embedded_controller/access_controller.dm b/code/game/machinery/embedded_controller/access_controller.dm index 5020560ae7d..922f10e70fc 100644 --- a/code/game/machinery/embedded_controller/access_controller.dm +++ b/code/game/machinery/embedded_controller/access_controller.dm @@ -78,9 +78,11 @@ controller.cycleClose(door) else controller.onlyClose(door) - sleep(20) - busy = FALSE - update_icon() + addtimer(CALLBACK(src, .proc/not_busy), 2 SECONDS) + +/obj/machinery/door_buttons/access_button/proc/not_busy() + busy = FALSE + update_icon() /obj/machinery/door_buttons/access_button/update_icon_state() if(machine_stat & NOPOWER) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index aaaed813409..53761c6b991 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -1026,7 +1026,7 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb S = null if(get_sharpness() && force >= 5) //if we've got something sharp with a decent force (ie, not plastic) - M.emote("scream") + INVOKE_ASYNC(M, /mob.proc/emote, "scream") M.visible_message("[M] looks like [M.p_theyve()] just bit something they shouldn't have!", \ "OH GOD! Was that a crunch? That didn't feel good at all!!") diff --git a/code/game/objects/items/puzzle_pieces.dm b/code/game/objects/items/puzzle_pieces.dm index 03bf0a2a16b..c4cbc852418 100644 --- a/code/game/objects/items/puzzle_pieces.dm +++ b/code/game/objects/items/puzzle_pieces.dm @@ -143,5 +143,4 @@ AM.set_anchored(TRUE) flick("laserbox_burn", AM) trigger() - sleep(15) - qdel(AM) + QDEL_IN(AM, 15) diff --git a/code/game/objects/items/stunbaton.dm b/code/game/objects/items/stunbaton.dm index 198db746213..86d4d9d176d 100644 --- a/code/game/objects/items/stunbaton.dm +++ b/code/game/objects/items/stunbaton.dm @@ -333,9 +333,7 @@ if(ishuman(hit_atom) && !caught && prob(throw_stun_chance))//if they are a carbon and they didn't catch it baton_effect(hit_atom) if(thrownby && !caught) - sleep(1) - if(!QDELETED(src)) - throw_at(thrownby, throw_range+2, throw_speed, null, TRUE) + addtimer(CALLBACK(src, /atom/movable.proc/throw_at, thrownby, throw_range+2, throw_speed, null, TRUE), 1) else return ..() diff --git a/code/game/objects/items/toys.dm b/code/game/objects/items/toys.dm index ca52940c79b..f108d20e46d 100644 --- a/code/game/objects/items/toys.dm +++ b/code/game/objects/items/toys.dm @@ -1082,8 +1082,9 @@ playsound(src, 'sound/effects/explosionfar.ogg', 50, FALSE) for(var/mob/M in urange(10, src)) // Checks range if(!M.stat && !isAI(M)) // Checks to make sure whoever's getting shaken is alive/not the AI - sleep(8) // Short delay to match up with the explosion sound - shake_camera(M, 2, 1) // Shakes player camera 2 squares for 1 second. + // Short delay to match up with the explosion sound + // Shakes player camera 2 squares for 1 second. + addtimer(CALLBACK(GLOBAL_PROC, .proc/shake_camera, M, 2, 1), 0.8 SECONDS) else to_chat(user, "Nothing happens.") @@ -1471,8 +1472,7 @@ if(cooldown <= world.time) cooldown = (world.time + 300) user.visible_message("[user] adjusts the dial on [src].") - sleep(5) - playsound(src, 'sound/items/radiostatic.ogg', 50, FALSE) + addtimer(CALLBACK(GLOBAL_PROC, .proc/playsound, src, 'sound/items/radiostatic.ogg', 50, FALSE), 0.5 SECONDS) else to_chat(user, "The dial on [src] jams up") return @@ -1487,5 +1487,4 @@ /obj/item/toy/braintoy/attack_self(mob/user) if(cooldown <= world.time) cooldown = (world.time + 10) - sleep(5) - playsound(src, 'sound/effects/blobattack.ogg', 50, FALSE) + addtimer(CALLBACK(GLOBAL_PROC, .proc/playsound, src, 'sound/effects/blobattack.ogg', 50, FALSE), 0.5 SECONDS) diff --git a/code/modules/antagonists/changeling/changeling.dm b/code/modules/antagonists/changeling/changeling.dm index 0801c30a09f..34e62e15ccd 100644 --- a/code/modules/antagonists/changeling/changeling.dm +++ b/code/modules/antagonists/changeling/changeling.dm @@ -149,7 +149,7 @@ ///Handles stinging without verbs. /datum/antagonist/changeling/proc/stingAtom(mob/living/carbon/ling, atom/A) - SIGNAL_HANDLER + SIGNAL_HANDLER_DOES_SLEEP if(!chosen_sting || A == ling || !istype(ling) || ling.stat) return diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index e5e052fe995..7e662fb0c27 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -422,7 +422,7 @@ switch(rand(1,100)+modifier) //91-100=Nothing special happens if(-INFINITY to 0) //attack yourself - I.attack(src,src) + INVOKE_ASYNC(I, /obj/item.proc/attack, src, src) if(1 to 30) //throw it at yourself I.throw_impact(src) if(31 to 60) //Throw object in facing direction diff --git a/code/modules/mob/living/carbon/death.dm b/code/modules/mob/living/carbon/death.dm index 0e69053951e..a03e7203f36 100644 --- a/code/modules/mob/living/carbon/death.dm +++ b/code/modules/mob/living/carbon/death.dm @@ -6,7 +6,7 @@ losebreath = 0 if(!gibbed) - emote("deathgasp") + INVOKE_ASYNC(src, .proc/emote, "deathgasp") end_metabolization() . = ..() diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 587532df275..47705422a96 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -622,7 +622,7 @@ var/obj/effect/proc_holder/spell/spell = S spell.updateButtonIcon() if(excess_healing) - emote("gasp") + INVOKE_ASYNC(src, .proc/emote, "gasp") log_combat(src, src, "revived") /mob/living/proc/remove_CC(should_update_mobility = TRUE) diff --git a/code/modules/mob/living/simple_animal/bot/SuperBeepsky.dm b/code/modules/mob/living/simple_animal/bot/SuperBeepsky.dm index 4fb39e54783..c471d988413 100644 --- a/code/modules/mob/living/simple_animal/bot/SuperBeepsky.dm +++ b/code/modules/mob/living/simple_animal/bot/SuperBeepsky.dm @@ -33,7 +33,7 @@ /mob/living/simple_animal/bot/secbot/grievous/Initialize() . = ..() - weapon.attack_self(src) + INVOKE_ASYNC(weapon, /obj/item.proc/attack_self, src) /mob/living/simple_animal/bot/secbot/grievous/Destroy() QDEL_NULL(weapon) diff --git a/code/modules/mob/living/simple_animal/eldritch_demons.dm b/code/modules/mob/living/simple_animal/eldritch_demons.dm index 418c5afa4d1..c1b8e99a825 100644 --- a/code/modules/mob/living/simple_animal/eldritch_demons.dm +++ b/code/modules/mob/living/simple_animal/eldritch_demons.dm @@ -98,7 +98,7 @@ action.Remove(mob_linked) qdel(action) to_chat(mob_linked, "Your mind shatters as the [src]'s Mansus Link leaves your mind.") - mob_linked.emote("Scream") + INVOKE_ASYNC(mob_linked, /mob.proc/emote, "scream") //micro stun mob_linked.AdjustParalyzed(0.5 SECONDS) linked_mobs -= mob_linked diff --git a/code/modules/mob/living/simple_animal/friendly/dog.dm b/code/modules/mob/living/simple_animal/friendly/dog.dm index 2c5d91d6f98..585c6d2e759 100644 --- a/code/modules/mob/living/simple_animal/friendly/dog.dm +++ b/code/modules/mob/living/simple_animal/friendly/dog.dm @@ -343,7 +343,7 @@ /mob/living/simple_animal/pet/dog/corgi/proc/place_on_head(obj/item/item_to_add, mob/user) if(istype(item_to_add, /obj/item/grenade/c4)) // last thing he ever wears, I guess - item_to_add.afterattack(src,user,1) + INVOKE_ASYNC(item_to_add, /obj/item.proc/afterattack, src, user, 1) return if(inventory_head) diff --git a/code/modules/mob/living/simple_animal/hostile/mecha_pilot.dm b/code/modules/mob/living/simple_animal/hostile/mecha_pilot.dm index f737c7eed4a..e24962c8af5 100644 --- a/code/modules/mob/living/simple_animal/hostile/mecha_pilot.dm +++ b/code/modules/mob/living/simple_animal/hostile/mecha_pilot.dm @@ -65,7 +65,7 @@ if(spawn_mecha_type) var/obj/vehicle/sealed/mecha/M = new spawn_mecha_type (get_turf(src)) if(istype(M)) - enter_mecha(M) + INVOKE_ASYNC(src, .proc/enter_mecha, M) /mob/living/simple_animal/hostile/syndicate/mecha_pilot/proc/enter_mecha(obj/vehicle/sealed/mecha/M) diff --git a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm index c786c4fbdef..22cdeee5096 100644 --- a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm +++ b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm @@ -3,6 +3,9 @@ var/modifier = 0 /datum/chemical_reaction/reagent_explosion/on_reaction(datum/reagents/holder, created_volume) + explode(holder, created_volume) + +/datum/chemical_reaction/reagent_explosion/proc/explode(datum/reagents/holder, created_volume) var/power = modifier + round(created_volume/strengthdiv, 1) if(power > 0) var/turf/T = get_turf(holder.my_atom) @@ -23,7 +26,6 @@ e.start() holder.clear_reagents() - /datum/chemical_reaction/reagent_explosion/nitroglycerin results = list(/datum/reagent/nitroglycerin = 2) required_reagents = list(/datum/reagent/glycerol = 1, /datum/reagent/toxin/acid/nitracid = 1, /datum/reagent/toxin/acid = 1) @@ -146,15 +148,16 @@ R.stun(20) R.reveal(100) R.adjustHealth(50) - sleep(20) - for(var/mob/living/carbon/C in get_hearers_in_view(round(created_volume/48,1),get_turf(holder.my_atom))) - if(iscultist(C)) - to_chat(C, "The divine explosion sears you!") - C.Paralyze(40) - C.adjust_fire_stacks(5) - C.IgniteMob() + addtimer(CALLBACK(src, .proc/divine_explosion, round(created_volume/48,1),get_turf(holder.my_atom)), 2 SECONDS) ..() +/datum/chemical_reaction/reagent_explosion/potassium_explosion/holyboom/proc/divine_explosion(size, turf/T) + for(var/mob/living/carbon/C in get_hearers_in_view(size,T)) + if(iscultist(C)) + to_chat(C, "The divine explosion sears you!") + C.Paralyze(40) + C.adjust_fire_stacks(5) + C.IgniteMob() /datum/chemical_reaction/gunpowder results = list(/datum/reagent/gunpowder = 3) @@ -168,8 +171,7 @@ mix_message = "Sparks start flying around the gunpowder!" /datum/chemical_reaction/reagent_explosion/gunpowder_explosion/on_reaction(datum/reagents/holder, created_volume) - sleep(rand(50,100)) - ..() + addtimer(CALLBACK(src, .proc/explode, holder, created_volume), rand(5,10) SECONDS) /datum/chemical_reaction/thermite results = list(/datum/reagent/thermite = 3) @@ -452,19 +454,22 @@ var/T1 = created_volume * 20 //100 units : Zap 3 times, with powers 2000/5000/12000. Tesla revolvers have a power of 10000 for comparison. var/T2 = created_volume * 50 var/T3 = created_volume * 120 - sleep(5) + var/added_delay = 0.5 SECONDS if(created_volume >= 75) - tesla_zap(holder.my_atom, 7, T1, zap_flags) - playsound(holder.my_atom, 'sound/machines/defib_zap.ogg', 50, TRUE) - sleep(15) + addtimer(CALLBACK(src, .proc/zappy_zappy, holder, T1), added_delay) + added_delay += 1.5 SECONDS if(created_volume >= 40) - tesla_zap(holder.my_atom, 7, T2, zap_flags) - playsound(holder.my_atom, 'sound/machines/defib_zap.ogg', 50, TRUE) - sleep(15) + addtimer(CALLBACK(src, .proc/zappy_zappy, holder, T2), added_delay) + added_delay += 1.5 SECONDS if(created_volume >= 10) //10 units minimum for lightning, 40 units for secondary blast, 75 units for tertiary blast. - tesla_zap(holder.my_atom, 7, T3, zap_flags) - playsound(holder.my_atom, 'sound/machines/defib_zap.ogg', 50, TRUE) - ..() + addtimer(CALLBACK(src, .proc/zappy_zappy, holder, T3), added_delay) + addtimer(CALLBACK(src, .proc/explode, holder, created_volume), added_delay) + +/datum/chemical_reaction/reagent_explosion/teslium_lightning/proc/zappy_zappy(datum/reagents/holder, power) + if(QDELETED(holder.my_atom)) + return + tesla_zap(holder.my_atom, 7, power, zap_flags) + playsound(holder.my_atom, 'sound/machines/defib_zap.ogg', 50, TRUE) /datum/chemical_reaction/reagent_explosion/teslium_lightning/heat required_temp = 474 diff --git a/code/modules/reagents/chemistry/recipes/slime_extracts.dm b/code/modules/reagents/chemistry/recipes/slime_extracts.dm index 56772b8986b..0deeb391c29 100644 --- a/code/modules/reagents/chemistry/recipes/slime_extracts.dm +++ b/code/modules/reagents/chemistry/recipes/slime_extracts.dm @@ -3,6 +3,9 @@ var/deletes_extract = TRUE /datum/chemical_reaction/slime/on_reaction(datum/reagents/holder) + use_slime_core(holder) + +/datum/chemical_reaction/slime/proc/use_slime_core(datum/reagents/holder) SSblackbox.record_feedback("tally", "slime_cores_used", 1, "type") if(deletes_extract) delete_extract(holder) @@ -484,7 +487,9 @@ required_other = TRUE /datum/chemical_reaction/slime/slimestop/on_reaction(datum/reagents/holder) - sleep(50) + addtimer(CALLBACK(src, .proc/slime_stop, holder), 5 SECONDS) + +/datum/chemical_reaction/slime/slimestop/proc/slime_stop(datum/reagents/holder) var/obj/item/slime_extract/sepia/extract = holder.my_atom var/turf/T = get_turf(holder.my_atom) new /obj/effect/timestop(T, null, null, null) @@ -493,8 +498,7 @@ var/mob/lastheld = get_mob_by_key(holder.my_atom.fingerprintslast) if(lastheld && !lastheld.equip_to_slot_if_possible(extract, ITEM_SLOT_HANDS, disable_warning = TRUE)) extract.forceMove(get_turf(lastheld)) - - ..() + use_slime_core(holder) /datum/chemical_reaction/slime/slimecamera required_reagents = list(/datum/reagent/water = 1) diff --git a/code/modules/surgery/bodyparts/_bodyparts.dm b/code/modules/surgery/bodyparts/_bodyparts.dm index ed651686e68..e73b07adc77 100644 --- a/code/modules/surgery/bodyparts/_bodyparts.dm +++ b/code/modules/surgery/bodyparts/_bodyparts.dm @@ -573,7 +573,7 @@ if(total_damage >= max_damage * disable_threshold) //Easy limb disable disables the limb at 40% health instead of 0% if(!last_maxed) if(owner.stat < UNCONSCIOUS) - owner.emote("scream") + INVOKE_ASYNC(owner, /mob.proc/emote, "scream") last_maxed = TRUE set_disabled(TRUE) return diff --git a/code/modules/surgery/bodyparts/dismemberment.dm b/code/modules/surgery/bodyparts/dismemberment.dm index 5e09c7b3d98..020509e861e 100644 --- a/code/modules/surgery/bodyparts/dismemberment.dm +++ b/code/modules/surgery/bodyparts/dismemberment.dm @@ -17,7 +17,7 @@ affecting.receive_damage(clamp(brute_dam/2 * affecting.body_damage_coeff, 15, 50), clamp(burn_dam/2 * affecting.body_damage_coeff, 0, 50), wound_bonus=CANT_WOUND) //Damage the chest based on limb's existing damage if(!silent) C.visible_message("[C]'s [name] is violently dismembered!") - C.emote("scream") + INVOKE_ASYNC(C, /mob.proc/emote, "scream") playsound(get_turf(C), 'sound/effects/dismember.ogg', 80, TRUE) SEND_SIGNAL(C, COMSIG_ADD_MOOD_EVENT, "dismembered", /datum/mood_event/dismembered) drop_limb() diff --git a/code/modules/vehicles/mecha/_mecha.dm b/code/modules/vehicles/mecha/_mecha.dm index 400dde4a51f..85f0b63aa61 100644 --- a/code/modules/vehicles/mecha/_mecha.dm +++ b/code/modules/vehicles/mecha/_mecha.dm @@ -551,13 +551,13 @@ if(HAS_TRAIT(L, TRAIT_PACIFISM) && selected.harmful) to_chat(L, "You don't want to harm other living beings!") return - selected.action(user, target, params) + INVOKE_ASYNC(selected, /obj/item/mecha_parts/mecha_equipment.proc/action, user, target, params) return if((selected.range & MECHA_MELEE) && Adjacent(target)) if(isliving(target) && selected.harmful && HAS_TRAIT(L, TRAIT_PACIFISM)) to_chat(L, "You don't want to harm other living beings!") return - selected.action(user, target, params) + INVOKE_ASYNC(selected, /obj/item/mecha_parts/mecha_equipment.proc/action, user, target, params) return if(TIMER_COOLDOWN_CHECK(src, COOLDOWN_MECHA_MELEE_ATTACK) || !istype(target, /atom) || !Adjacent(target)) return diff --git a/code/modules/vehicles/mecha/combat/durand.dm b/code/modules/vehicles/mecha/combat/durand.dm index 5a9583f3ea3..f99d8a59531 100644 --- a/code/modules/vehicles/mecha/combat/durand.dm +++ b/code/modules/vehicles/mecha/combat/durand.dm @@ -54,7 +54,7 @@ if(defense_mode) var/datum/action/action = LAZYACCESSASSOC(occupant_actions, M, /datum/action/vehicle/sealed/mecha/mech_defense_mode) if(action) - action.Trigger(FALSE) + INVOKE_ASYNC(action, /datum/action.proc/Trigger, FALSE) return ..() ///Relays the signal from the action button to the shield, and creates a new shield if the old one is MIA.