diff --git a/code/datums/components/crafting/crafting.dm b/code/datums/components/crafting/crafting.dm index 10eee99eddf..999971ea7cf 100644 --- a/code/datums/components/crafting/crafting.dm +++ b/code/datums/components/crafting/crafting.dm @@ -322,10 +322,10 @@ qdel(DL) /datum/component/personal_crafting/proc/component_ui_interact(atom/movable/screen/craft/image, location, control, params, user) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER if(user == parent) - ui_interact(user) + INVOKE_ASYNC(src, .proc/ui_interact, user) /datum/component/personal_crafting/ui_state(mob/user) return GLOB.not_incapacitated_turf_state diff --git a/code/datums/components/embedded.dm b/code/datums/components/embedded.dm index b84c43d4de2..396a5836129 100644 --- a/code/datums/components/embedded.dm +++ b/code/datums/components/embedded.dm @@ -207,7 +207,7 @@ /// This proc handles the final step and actual removal of an embedded/stuck item from a carbon, whether or not it was actually removed safely. /// Pass TRUE for to_hands if we want it to go to the victim's hands when they pull it out /datum/component/embedded/proc/safeRemove(to_hands) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER var/mob/living/carbon/victim = parent limb.embedded_objects -= weapon @@ -216,7 +216,7 @@ if(!weapon.unembedded()) // if it hasn't deleted itself due to drop del UnregisterSignal(weapon, list(COMSIG_MOVABLE_MOVED, COMSIG_PARENT_QDELETING)) if(to_hands) - victim.put_in_hands(weapon) + INVOKE_ASYNC(victim, /mob.proc/put_in_hands, weapon) else weapon.forceMove(get_turf(victim)) diff --git a/code/datums/components/gps.dm b/code/datums/components/gps.dm index 7408b78c721..433d967bf8e 100644 --- a/code/datums/components/gps.dm +++ b/code/datums/components/gps.dm @@ -36,10 +36,10 @@ GLOBAL_LIST_EMPTY(GPS_list) ///Called on COMSIG_ITEM_ATTACK_SELF /datum/component/gps/item/proc/interact(datum/source, mob/user) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER if(user) - ui_interact(user) + INVOKE_ASYNC(src, .proc/ui_interact, user) ///Called on COMSIG_PARENT_EXAMINE /datum/component/gps/item/proc/on_examine(datum/source, mob/user, list/examine_list) diff --git a/code/datums/components/gunpoint.dm b/code/datums/components/gunpoint.dm index 5661a5b668c..9ae6f8dceb0 100644 --- a/code/datums/components/gunpoint.dm +++ b/code/datums/components/gunpoint.dm @@ -166,7 +166,7 @@ ///If the shooter is hit by an attack, they have a 50% chance to flinch and fire. If it hit the arm holding the trigger, it's an 80% chance to fire instead /datum/component/gunpoint/proc/flinch(attacker, damage, damagetype, def_zone) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER var/mob/living/shooter = parent if(attacker == shooter) @@ -184,7 +184,7 @@ if(prob(flinch_chance)) shooter.visible_message("[shooter] flinches!", \ "You flinch!") - trigger_reaction() + INVOKE_ASYNC(src, .proc/trigger_reaction) #undef GUNPOINT_SHOOTER_STRAY_RANGE #undef GUNPOINT_DELAY_STAGE_2 diff --git a/code/datums/components/mirv.dm b/code/datums/components/mirv.dm index ef0790ef673..140e1134764 100644 --- a/code/datums/components/mirv.dm +++ b/code/datums/components/mirv.dm @@ -22,9 +22,9 @@ UnregisterSignal(parent, list(COMSIG_PROJECTILE_ON_HIT)) /datum/component/mirv/proc/projectile_hit(atom/fired_from, atom/movable/firer, atom/target, Angle) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER - do_shrapnel(firer, target) + INVOKE_ASYNC(src, .proc/do_shrapnel, firer, target) /datum/component/mirv/proc/do_shrapnel(mob/firer, atom/target) if(radius < 1) diff --git a/code/datums/components/punchcooldown.dm b/code/datums/components/punchcooldown.dm index 55a6bbcea67..dd5ab2fe6c4 100644 --- a/code/datums/components/punchcooldown.dm +++ b/code/datums/components/punchcooldown.dm @@ -22,8 +22,10 @@ ///Called on COMSIG_ITEM_ATTACK_SELF. Allows you to change the warcry. /datum/component/wearertargeting/punchcooldown/proc/changewarcry(datum/source, mob/user) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER + INVOKE_ASYNC(src, .proc/do_changewarcry, user) +/datum/component/wearertargeting/punchcooldown/proc/do_changewarcry(mob/user) var/input = stripped_input(user,"What do you want your battlecry to be? Max length of 6 characters.", ,"", 7) if(!QDELETED(src) && !QDELETED(user) && !user.Adjacent(parent)) return diff --git a/code/datums/components/religious_tool.dm b/code/datums/components/religious_tool.dm index 4e0f6818262..f42d11f19a0 100644 --- a/code/datums/components/religious_tool.dm +++ b/code/datums/components/religious_tool.dm @@ -51,60 +51,22 @@ * Since all of these involve attackby, we require mega proc. Handles Invocation, Sacrificing, And Selection of Sects. */ /datum/component/religious_tool/proc/AttemptActions(datum/source, obj/item/the_item, mob/living/user) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER /**********Sect Selection**********/ if(!SetGlobalToLocal()) if(!(operation_flags & RELIGION_TOOL_SECTSELECT)) return - . = COMPONENT_NO_AFTERATTACK //At this point you're intentionally trying to select a sect. - if(user.mind.holy_role != HOLY_ROLE_HIGHPRIEST) - to_chat(user, "You are not the high priest, and therefore cannot select a religious sect.") - return - var/list/available_options = generate_available_sects(user) - if(!available_options) - return + //At this point you're intentionally trying to select a sect. + INVOKE_ASYNC(src, .proc/select_sect, user) + return COMPONENT_NO_AFTERATTACK - var/sect_select = input(user,"Select a sect (You CANNOT revert this decision!)","Select a Sect",null) in available_options - if(!sect_select || !user.canUseTopic(parent, BE_CLOSE, FALSE, NO_TK)) - to_chat(user,"You cannot select a sect at this time.") - return - var/type_selected = available_options[sect_select] - GLOB.religious_sect = new type_selected() - for(var/i in GLOB.player_list) - if(!isliving(i)) - continue - var/mob/living/am_i_holy_living = i - if(!am_i_holy_living.mind?.holy_role) - continue - GLOB.religious_sect.on_conversion(am_i_holy_living) - easy_access_sect = GLOB.religious_sect - after_sect_select_cb.Invoke() - return /**********Rite Invocation**********/ else if(istype(the_item, catalyst_type)) if(!(operation_flags & RELIGION_TOOL_INVOKE)) return - . = force_catalyst_afterattack ? null : COMPONENT_NO_AFTERATTACK - if(!easy_access_sect.rites_list) - to_chat(user, "Your sect doesn't have any rites to perform!") - return - if(performing_rite) - to_chat(user, "There is a rite currently being performed here already!") - return - var/rite_select = input(user,"Select a rite to perform!","Select a rite",null) in easy_access_sect.rites_list - if(!rite_select || !user.canUseTopic(parent, BE_CLOSE, FALSE, NO_TK)) - to_chat(user,"You cannot perform the rite at this time.") - return - var/selection2type = easy_access_sect.rites_list[rite_select] - performing_rite = new selection2type(parent) - if(!performing_rite.perform_rite(user, parent)) - QDEL_NULL(performing_rite) - else - performing_rite.invoke_effect(user, parent) - easy_access_sect.adjust_favor(-performing_rite.favor_cost) - QDEL_NULL(performing_rite) - return + INVOKE_ASYNC(src, .proc/perform_rite, user) + return (force_catalyst_afterattack ? NONE : COMPONENT_NO_AFTERATTACK) /**********Sacrificing**********/ else if(operation_flags & RELIGION_TOOL_SACRIFICE) @@ -113,6 +75,51 @@ easy_access_sect.on_sacrifice(the_item,user) return COMPONENT_NO_AFTERATTACK +/// Select the sect, called async from [/datum/component/religious_tool/proc/AttemptActions] +/datum/component/religious_tool/proc/select_sect(mob/living/user) + if(user.mind.holy_role != HOLY_ROLE_HIGHPRIEST) + to_chat(user, "You are not the high priest, and therefore cannot select a religious sect.") + return + var/list/available_options = generate_available_sects(user) + if(!available_options) + return + + var/sect_select = input(user,"Select a sect (You CANNOT revert this decision!)","Select a Sect",null) in available_options + if(!sect_select || !user.canUseTopic(parent, BE_CLOSE, FALSE, NO_TK)) + to_chat(user,"You cannot select a sect at this time.") + return + var/type_selected = available_options[sect_select] + GLOB.religious_sect = new type_selected() + for(var/i in GLOB.player_list) + if(!isliving(i)) + continue + var/mob/living/am_i_holy_living = i + if(!am_i_holy_living.mind?.holy_role) + continue + GLOB.religious_sect.on_conversion(am_i_holy_living) + easy_access_sect = GLOB.religious_sect + after_sect_select_cb.Invoke() + +/// Perform the rite, called async from [/datum/component/religious_tool/proc/AttemptActions] +/datum/component/religious_tool/proc/perform_rite(mob/living/user) + if(!easy_access_sect.rites_list) + to_chat(user, "Your sect doesn't have any rites to perform!") + return + if(performing_rite) + to_chat(user, "There is a rite currently being performed here already!") + return + var/rite_select = input(user,"Select a rite to perform!","Select a rite",null) in easy_access_sect.rites_list + if(!rite_select || !user.canUseTopic(parent, BE_CLOSE, FALSE, NO_TK)) + to_chat(user,"You cannot perform the rite at this time.") + return + var/selection2type = easy_access_sect.rites_list[rite_select] + performing_rite = new selection2type(parent) + if(!performing_rite.perform_rite(user, parent)) + QDEL_NULL(performing_rite) + else + performing_rite.invoke_effect(user, parent) + easy_access_sect.adjust_favor(-performing_rite.favor_cost) + QDEL_NULL(performing_rite) /** * Generates a list of available sects to the user. Intended to support custom-availability sects. Because these are not instanced, we cannot put the availability on said sect beyond variables. diff --git a/code/datums/components/spooky.dm b/code/datums/components/spooky.dm index 27d62668892..dfd06b1833c 100644 --- a/code/datums/components/spooky.dm +++ b/code/datums/components/spooky.dm @@ -5,7 +5,7 @@ RegisterSignal(parent, COMSIG_ITEM_ATTACK, .proc/spectral_attack) /datum/component/spooky/proc/spectral_attack(datum/source, mob/living/carbon/C, mob/user) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER if(ishuman(user)) //this weapon wasn't meant for mortals. var/mob/living/carbon/human/U = user @@ -15,7 +15,7 @@ U.stuttering = 20 if(U.getStaminaLoss() > 95) to_chat(U, "Your ears weren't meant for this spectral sound.") - spectral_change(U) + INVOKE_ASYNC(src, .proc/spectral_change, U) return if(ishuman(C)) @@ -30,7 +30,7 @@ if((!istype(H.dna.species, /datum/species/skeleton)) && (!istype(H.dna.species, /datum/species/golem)) && (!istype(H.dna.species, /datum/species/android)) && (!istype(H.dna.species, /datum/species/jelly))) C.adjustStaminaLoss(25) //boneless humanoids don't lose the will to live to_chat(C, "DOOT") - spectral_change(H) + INVOKE_ASYNC(src, .proc/spectral_change, H) else //the sound will spook monkeys. C.Jitter(15) diff --git a/code/datums/components/storage/storage.dm b/code/datums/components/storage/storage.dm index f4619b5e31e..32059f41dde 100644 --- a/code/datums/components/storage/storage.dm +++ b/code/datums/components/storage/storage.dm @@ -183,13 +183,13 @@ hide_from(L) /datum/component/storage/proc/attack_self(datum/source, mob/M) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER if(locked) to_chat(M, "[parent] seems to be locked!") return FALSE if((M.get_active_held_item() == parent) && allow_quick_empty) - quick_empty(M) + INVOKE_ASYNC(src, .proc/quick_empty, M) /datum/component/storage/proc/preattack_intercept(datum/source, obj/O, mob/M, params) SIGNAL_HANDLER_DOES_SLEEP @@ -552,7 +552,7 @@ to_chat(user, "[source] can hold: [can_hold_description]") /datum/component/storage/proc/mousedrop_onto(datum/source, atom/over_object, mob/M) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER set waitfor = FALSE . = COMPONENT_NO_MOUSEDROP @@ -572,7 +572,7 @@ playsound(A, "rustle", 50, TRUE, -5) //SKYRAT EDIT ADDITION - AESTHETICS A.do_jiggle() //SKYRAT EDIT ADDITION - AESTHETICS if(!istype(over_object, /atom/movable/screen)) - dump_content_at(over_object, M) + INVOKE_ASYNC(src, .proc/dump_content_at, over_object, M) return if(A.loc != M) return @@ -774,7 +774,7 @@ /datum/component/storage/proc/on_attack_hand(datum/source, mob/user) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER var/atom/A = parent if(!attack_hand_interact) @@ -792,12 +792,12 @@ var/mob/living/carbon/human/H = user if(H.l_store == A && !H.get_active_held_item()) //Prevents opening if it's in a pocket. . = COMPONENT_CANCEL_ATTACK_CHAIN - H.put_in_hands(A) + INVOKE_ASYNC(H, /mob.proc/put_in_hands, A) H.l_store = null return if(H.r_store == A && !H.get_active_held_item()) . = COMPONENT_CANCEL_ATTACK_CHAIN - H.put_in_hands(A) + INVOKE_ASYNC(H, /mob.proc/put_in_hands, A) H.r_store = null return diff --git a/code/datums/components/surgery_initiator.dm b/code/datums/components/surgery_initiator.dm index 4155e6959c0..faad2baa706 100644 --- a/code/datums/components/surgery_initiator.dm +++ b/code/datums/components/surgery_initiator.dm @@ -31,16 +31,17 @@ * */ /datum/component/surgery_initiator/proc/initiate_surgery_moment(datum/source, atom/target, mob/user) - SIGNAL_HANDLER_DOES_SLEEP - + SIGNAL_HANDLER if(!isliving(target)) return + INVOKE_ASYNC(src, .proc/do_initiate_surgery_moment, source, target, user) + return COMPONENT_CANCEL_ATTACK_CHAIN + +/datum/component/surgery_initiator/proc/do_initiate_surgery_moment(datum/source, atom/target, mob/user) var/mob/living/livingtarget = target var/mob/living/carbon/carbontarget var/obj/item/bodypart/affecting var/selected_zone = user.zone_selected - . = COMPONENT_CANCEL_ATTACK_CHAIN - if(iscarbon(livingtarget)) carbontarget = livingtarget affecting = carbontarget.get_bodypart(check_zone(selected_zone)) diff --git a/code/datums/components/uplink.dm b/code/datums/components/uplink.dm index fb9685492be..b7ce377cfac 100644 --- a/code/datums/components/uplink.dm +++ b/code/datums/components/uplink.dm @@ -114,13 +114,13 @@ return /datum/component/uplink/proc/interact(datum/source, mob/user) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER if(locked) return active = TRUE if(user) - ui_interact(user) + INVOKE_ASYNC(src, .proc/ui_interact, user) // an unlocked uplink blocks also opening the PDA or headset menu return COMPONENT_CANCEL_ATTACK_CHAIN @@ -233,7 +233,7 @@ // Implant signal responses /datum/component/uplink/proc/implant_activation() - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER var/obj/item/implant/implant = parent locked = FALSE @@ -260,7 +260,7 @@ // PDA signal responses /datum/component/uplink/proc/new_ringtone(datum/source, mob/living/user, new_ring_text) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER var/obj/item/pda/master = parent if(trim(lowertext(new_ring_text)) != trim(lowertext(unlock_code))) @@ -283,7 +283,7 @@ // Radio signal responses /datum/component/uplink/proc/new_frequency(datum/source, list/arguments) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER var/obj/item/radio/master = parent var/frequency = arguments[1] @@ -298,7 +298,7 @@ // Pen signal responses /datum/component/uplink/proc/pen_rotation(datum/source, degrees, mob/living/carbon/user) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER var/obj/item/pen/master = parent previous_attempts += degrees diff --git a/code/datums/mutations/hulk.dm b/code/datums/mutations/hulk.dm index 7b75a34d2f4..b48b7908cc0 100644 --- a/code/datums/mutations/hulk.dm +++ b/code/datums/mutations/hulk.dm @@ -27,7 +27,7 @@ RegisterSignal(owner, COMSIG_MOB_SAY, .proc/handle_speech) /datum/mutation/human/hulk/proc/on_attack_hand(mob/living/carbon/human/source, atom/target, proximity) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER if(!proximity) return @@ -36,13 +36,15 @@ if(target.attack_hulk(owner)) if(world.time > (last_scream + scream_delay)) last_scream = world.time - source.say(pick(";RAAAAAAAARGH!", ";HNNNNNNNNNGGGGGGH!", ";GWAAAAAAAARRRHHH!", "NNNNNNNNGGGGGGGGHH!", ";AAAAAAARRRGH!" ), forced="hulk") + INVOKE_ASYNC(src, .proc/scream_attack, source) log_combat(source, target, "punched", "hulk powers") source.do_attack_animation(target, ATTACK_EFFECT_SMASH) source.changeNext_move(CLICK_CD_MELEE) return COMPONENT_CANCEL_ATTACK_CHAIN +/datum/mutation/human/hulk/proc/scream_attack(mob/living/carbon/human/source) + source.say(pick(";RAAAAAAAARGH!", ";HNNNNNNNNNGGGGGGH!", ";GWAAAAAAAARRRHHH!", "NNNNNNNNGGGGGGGGHH!", ";AAAAAAARRRGH!" ), forced="hulk") /** *Checks damage of a hulk's arm and applies bone wounds as necessary. diff --git a/code/datums/mutations/sight.dm b/code/datums/mutations/sight.dm index 21563aef9b2..c97b1211faf 100644 --- a/code/datums/mutations/sight.dm +++ b/code/datums/mutations/sight.dm @@ -99,7 +99,7 @@ ///Triggers on COMSIG_MOB_ATTACK_RANGED. Does the projectile shooting. /datum/mutation/human/laser_eyes/proc/on_ranged_attack(mob/living/carbon/human/source, atom/target, mouseparams) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER if(source.a_intent != INTENT_HARM) return @@ -110,7 +110,7 @@ LE.firer = source LE.def_zone = ran_zone(source.zone_selected) LE.preparePixelProjectile(target, source, mouseparams) - LE.fire() + INVOKE_ASYNC(LE, /obj/projectile.proc/fire) playsound(source, 'sound/weapons/taser2.ogg', 75, TRUE) ///Projectile type used by laser eyes diff --git a/code/datums/status_effects/gas.dm b/code/datums/status_effects/gas.dm index eb706ce513b..e272b2b7bca 100644 --- a/code/datums/status_effects/gas.dm +++ b/code/datums/status_effects/gas.dm @@ -28,8 +28,10 @@ qdel(src) /datum/status_effect/freon/proc/owner_resist() - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER + INVOKE_ASYNC(src, .proc/do_resist) +/datum/status_effect/freon/proc/do_resist() to_chat(owner, "You start breaking out of the ice cube...") if(do_mob(owner, owner, 40)) if(!QDELETED(src)) diff --git a/code/game/objects/effects/proximity.dm b/code/game/objects/effects/proximity.dm index 01e8d516695..5c477501f45 100644 --- a/code/game/objects/effects/proximity.dm +++ b/code/game/objects/effects/proximity.dm @@ -36,7 +36,7 @@ return ..() /datum/proximity_monitor/proc/HandleMove() - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER var/atom/_host = host var/atom/new_host_loc = _host.loc diff --git a/code/modules/assembly/infrared.dm b/code/modules/assembly/infrared.dm index 0ac801a785d..457b7fd98d7 100644 --- a/code/modules/assembly/infrared.dm +++ b/code/modules/assembly/infrared.dm @@ -167,7 +167,7 @@ listeningTo = newloc /obj/item/assembly/infra/proc/check_exit(datum/source, atom/movable/offender) - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER if(QDELETED(src)) return @@ -177,7 +177,7 @@ var/obj/item/I = offender if (I.item_flags & ABSTRACT) return - return refreshBeam() + INVOKE_ASYNC(src, .proc/refreshBeam) /obj/item/assembly/infra/setDir() . = ..() diff --git a/code/modules/fields/fields.dm b/code/modules/fields/fields.dm index 52449bad79e..cb8d3e8dcf6 100644 --- a/code/modules/fields/fields.dm +++ b/code/modules/fields/fields.dm @@ -154,7 +154,7 @@ var/atom/_host = host var/atom/new_host_loc = _host.loc if(last_host_loc != new_host_loc) - recalculate_field() + INVOKE_ASYNC(src, .proc/recalculate_field) /datum/proximity_monitor/advanced/proc/post_setup_field() @@ -319,7 +319,7 @@ listeningTo = null /obj/item/multitool/field_debug/proc/on_mob_move() - SIGNAL_HANDLER_DOES_SLEEP + SIGNAL_HANDLER check_turf(get_turf(src))