From a4a49b203f11059a1b4e6180795751b5ea73f496 Mon Sep 17 00:00:00 2001 From: Cameron Lennox Date: Tue, 4 Mar 2025 09:41:53 -0500 Subject: [PATCH] Gets rid of another 400 sleep in init problems (#17265) * Shadekin phase_in moved to timers * Capture crystal to timers * async * PROC_REF --- .../objects/items/weapons/capture_crystal.dm | 10 +--- .../species/shadekin/shadekin_abilities.dm | 51 +++++++++-------- .../subtypes/vore/shadekin/ability_procs.dm | 57 ++++++++++--------- 3 files changed, 60 insertions(+), 58 deletions(-) diff --git a/code/game/objects/items/weapons/capture_crystal.dm b/code/game/objects/items/weapons/capture_crystal.dm index 71def1ca5bc..bb847dc6af3 100644 --- a/code/game/objects/items/weapons/capture_crystal.dm +++ b/code/game/objects/items/weapons/capture_crystal.dm @@ -494,18 +494,14 @@ playsound(src, 'sound/effects/capture-crystal-negative.ogg', 75, 1, -1) else if(!active) //The ball isn't set up, let's try to set it up. if(isliving(target)) //We're hitting a mob, let's try to capture it. - sleep(10) - activate(thrower, target) + addtimer(CALLBACK(src, PROC_REF(activate), thrower, target), 10, TIMER_DELETE_ME) return - sleep(10) - activate(thrower, src) + addtimer(CALLBACK(src, PROC_REF(activate), thrower, src), 10, TIMER_DELETE_ME) else if(!bound_mob) //We hit something else, and we don't have a mob, so we can't really do anything! to_chat(thrower, span_notice("\The [src] clicks unpleasantly...")) playsound(src, 'sound/effects/capture-crystal-negative.ogg', 75, 1, -1) else if(bound_mob in contents) //We have our mob! Let's try to let it out. - sleep(10) - unleash(thrower, src) - update_icon() + addtimer(CALLBACK(src, PROC_REF(unleash), thrower, src), 10, TIMER_DELETE_ME) else //Our mob isn't here, we can't do anything. to_chat(thrower, span_notice("\The [src] clicks unpleasantly...")) playsound(src, 'sound/effects/capture-crystal-negative.ogg', 75, 1, -1) diff --git a/code/modules/mob/living/carbon/human/species/shadekin/shadekin_abilities.dm b/code/modules/mob/living/carbon/human/species/shadekin/shadekin_abilities.dm index c64479ce647..9b399d8b344 100644 --- a/code/modules/mob/living/carbon/human/species/shadekin/shadekin_abilities.dm +++ b/code/modules/mob/living/carbon/human/species/shadekin/shadekin_abilities.dm @@ -133,35 +133,38 @@ phaseanim.adjust_scale(src.size_multiplier, src.size_multiplier) phaseanim.dir = dir alpha = 0 - custom_emote(1,"phases in!") - sleep(5) //The duration of the TP animation - canmove = original_canmove - alpha = initial(alpha) - remove_modifiers_of_type(/datum/modifier/shadekin_phase_vision) + INVOKE_ASYNC(src, PROC_REF(custom_emote),1,"phases in!") - //Potential phase-in vore - if(can_be_drop_pred) //Toggleable in vore panel - var/list/potentials = living_mobs(0) - if(potentials.len) - var/mob/living/target = pick(potentials) - if(istype(target) && target.devourable && target.can_be_drop_prey && vore_selected) - target.forceMove(vore_selected) - to_chat(target,span_vwarning("\The [src] phases in around you, [vore_selected.vore_verb]ing you into their [vore_selected.name]!")) + addtimer(CALLBACK(src, PROC_REF(shadekin_complete_phase_in), original_canmove), 5, TIMER_DELETE_ME) - ability_flags &= ~AB_PHASE_SHIFTING - //Affect nearby lights - var/destroy_lights = 0 +/mob/living/carbon/human/proc/shadekin_complete_phase_in(var/original_canmove) + canmove = original_canmove + alpha = initial(alpha) + remove_modifiers_of_type(/datum/modifier/shadekin_phase_vision) - for(var/obj/machinery/light/L in machines) - if(L.z != z || get_dist(src,L) > 10) - continue + //Potential phase-in vore + if(can_be_drop_pred) //Toggleable in vore panel + var/list/potentials = living_mobs(0) + if(potentials.len) + var/mob/living/target = pick(potentials) + if(istype(target) && target.devourable && target.can_be_drop_prey && vore_selected) + target.forceMove(vore_selected) + to_chat(target,span_vwarning("\The [src] phases in around you, [vore_selected.vore_verb]ing you into their [vore_selected.name]!")) - if(prob(destroy_lights)) - spawn(rand(5,25)) - L.broken() - else - L.flicker(10) + ability_flags &= ~AB_PHASE_SHIFTING + + //Affect nearby lights + var/destroy_lights = 0 + + for(var/obj/machinery/light/L in machines) + if(L.z != z || get_dist(src,L) > 10) + continue + + if(prob(destroy_lights)) + addtimer(CALLBACK(L, TYPE_PROC_REF(/obj/machinery/light, broken)), rand(5,25), TIMER_DELETE_ME) + else + L.flicker(10) /mob/living/carbon/human/proc/phase_out(var/turf/T) if(!(ability_flags & AB_PHASE_SHIFTED)) diff --git a/code/modules/mob/living/simple_mob/subtypes/vore/shadekin/ability_procs.dm b/code/modules/mob/living/simple_mob/subtypes/vore/shadekin/ability_procs.dm index e1834d3943b..f4607093e6e 100644 --- a/code/modules/mob/living/simple_mob/subtypes/vore/shadekin/ability_procs.dm +++ b/code/modules/mob/living/simple_mob/subtypes/vore/shadekin/ability_procs.dm @@ -56,38 +56,41 @@ //Cosmetics mostly flick("tp_in",src) - custom_emote(1,"phases in!") - sleep(5) //The duration of the TP animation - canmove = original_canmove + INVOKE_ASYNC(src, PROC_REF(custom_emote),1,"phases in!") - //Potential phase-in vore - if(can_be_drop_pred) //Toggleable in vore panel - var/list/potentials = living_mobs(0) - if(potentials.len) - var/mob/living/target = pick(potentials) - if(istype(target) && target.devourable && target.can_be_drop_prey && vore_selected) - target.forceMove(vore_selected) - to_chat(target,span_vwarning("\The [src] phases in around you, [vore_selected.vore_verb]ing you into their [vore_selected.name]!")) + addtimer(CALLBACK(src, PROC_REF(shadekin_complete_phase_in), original_canmove), 5, TIMER_DELETE_ME) - // Do this after the potential vore, so we get the belly - update_icon() - //Affect nearby lights - var/destroy_lights = 0 - if(eye_state == RED_EYES) - destroy_lights = 80 - if(eye_state == PURPLE_EYES) - destroy_lights = 25 +/mob/living/simple_mob/shadekin/proc/shadekin_complete_phase_in(var/original_canmove) + canmove = original_canmove - for(var/obj/machinery/light/L in machines) - if(L.z != z || get_dist(src,L) > 10) - continue + //Potential phase-in vore + if(can_be_drop_pred) //Toggleable in vore panel + var/list/potentials = living_mobs(0) + if(potentials.len) + var/mob/living/target = pick(potentials) + if(istype(target) && target.devourable && target.can_be_drop_prey && vore_selected) + target.forceMove(vore_selected) + to_chat(target,span_vwarning("\The [src] phases in around you, [vore_selected.vore_verb]ing you into their [vore_selected.name]!")) - if(prob(destroy_lights)) - spawn(rand(5,25)) - L.broken() - else - L.flicker(10) + // Do this after the potential vore, so we get the belly + update_icon() + + //Affect nearby lights + var/destroy_lights = 0 + if(eye_state == RED_EYES) + destroy_lights = 80 + if(eye_state == PURPLE_EYES) + destroy_lights = 25 + + for(var/obj/machinery/light/L in machines) + if(L.z != z || get_dist(src,L) > 10) + continue + + if(prob(destroy_lights)) + addtimer(CALLBACK(L, TYPE_PROC_REF(/obj/machinery/light, broken)), rand(5,25), TIMER_DELETE_ME) + else + L.flicker(10) /mob/living/simple_mob/shadekin/proc/phase_out(var/turf/T) if(!(ability_flags & AB_PHASE_SHIFTED))