From a01b48aa48eca657c81ed62dfbabf04bcfff4d40 Mon Sep 17 00:00:00 2001 From: Jack Edge Date: Sun, 5 Jun 2016 19:47:17 +0100 Subject: [PATCH] Removes spawn() from some things Yay, refactoring. --- .../gamemodes/changeling/powers/tiny_prick.dm | 27 ++++++---- .../gamemodes/clock_cult/clock_structures.dm | 31 ++++++----- code/game/machinery/doors/door.dm | 14 ++--- code/game/machinery/recycler.dm | 9 ++-- .../chemistry/recipes/slime_extracts.dm | 12 ++--- code/modules/spells/spell_types/lichdom.dm | 46 ++++++++-------- code/modules/spells/spell_types/wizard.dm | 7 +-- code/modules/surgery/organs/augments_chest.dm | 53 ++++++++++--------- .../surgery/organs/augments_internal.dm | 8 +-- code/modules/surgery/organs/organ_internal.dm | 15 +++--- code/modules/telesci/gps.dm | 12 +++-- code/modules/zombie/items.dm | 12 +++-- 12 files changed, 134 insertions(+), 112 deletions(-) diff --git a/code/game/gamemodes/changeling/powers/tiny_prick.dm b/code/game/gamemodes/changeling/powers/tiny_prick.dm index 3307b18cebe..5deadd09cbf 100644 --- a/code/game/gamemodes/changeling/powers/tiny_prick.dm +++ b/code/game/gamemodes/changeling/powers/tiny_prick.dm @@ -149,16 +149,21 @@ target.visible_message("A grotesque blade forms around [target.name]\'s arm!", "Your arm twists and mutates, transforming into a horrific monstrosity!", "You hear organic matter ripping and tearing!") playsound(target, 'sound/effects/blobattack.ogg', 30, 1) - spawn(600) - playsound(target, 'sound/effects/blobattack.ogg', 30, 1) - target.visible_message("With a sickening crunch, [target] reforms their [blade.name] into an arm!", "[blade] reforms back to normal.", "With a sickening crunch, \ + [target] reforms their [blade.name] into an arm!", + "[blade] reforms back to normal.", + "The writhing tendrils return to the gemstone, which begins to glow with power.") - flick("[initial(icon_state)]_recharged", src) - icon_state = initial(icon_state) - recharging = FALSE + addtimer(src, "recharge", 3000) // 5 minutes return 1 +/obj/structure/clockwork/interdiction_lens/proc/recharge() + if(!src) + return 0 + visible_message("The writhing tendrils return \ + to the gemstone, which begins to glow with power.") + flick("[initial(icon_state)]_recharged", src) + icon_state = initial(icon_state) + recharging = FALSE + /obj/structure/clockwork/mending_motor //Mending motor: A prism that consumes replicant alloy to repair nearby mechanical servants at a quick rate. name = "mending motor" desc = "A dark onyx prism, held in midair by spiraling tendrils of stone." @@ -594,9 +597,11 @@ clockwork_desc = "A gateway in reality. It can both send and receive objects." else clockwork_desc = "A gateway in reality. It can only [sender ? "send" : "receive"] objects." - spawn(lifetime) - if(src) - qdel(src) + addtimer(src, "selfdel", lifetime) + +/obj/effect/clockwork/spatial_gateway/proc/selfdel() + if(src) + qdel(src) //set up a gateway with another gateway /obj/effect/clockwork/spatial_gateway/proc/setup_gateway(obj/effect/clockwork/spatial_gateway/gatewayB, set_duration, uses, two_way) @@ -690,8 +695,10 @@ ..() playsound(src, 'sound/magic/clockwork/invoke_general.ogg', 50, 0) animate(src, alpha = 0, time = 10) - spawn(10) - qdel(src) + addtimer(src, "selfdel", 10) + +/obj/effect/clockwerk/general_marker/proc/selfdel() + qdel(src) /obj/effect/clockwork/general_marker/nezbere name = "Nezbere, the Brass Eidolon" diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 015c78b195a..3c34aaa3e05 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -175,16 +175,11 @@ obj/machinery/door/proc/try_to_crowbar(obj/item/I, mob/user) if(BURN) if(sound_effect) playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) - else - return - /obj/machinery/door/blob_act(obj/effect/blob/B) if(prob(40)) qdel(src) - return - /obj/machinery/door/emp_act(severity) if(prob(20/severity) && (istype(src,/obj/machinery/door/airlock) || istype(src,/obj/machinery/door/window)) ) @@ -193,10 +188,11 @@ obj/machinery/door/proc/try_to_crowbar(obj/item/I, mob/user) if(secondsElectrified == 0) secondsElectrified = -1 shockedby += "\[[time_stamp()]\]EM Pulse" - spawn(300) - secondsElectrified = 0 + addtimer(src, "unelectrify", 300) ..() +/obj/machinery/door/proc/unelectrify() + secondsElectrified = 0 /obj/machinery/door/ex_act(severity, target) if(severity == 3) @@ -212,8 +208,6 @@ obj/machinery/door/proc/try_to_crowbar(obj/item/I, mob/user) icon_state = "door1" else icon_state = "door0" - return - /obj/machinery/door/proc/do_animate(animation) switch(animation) @@ -340,4 +334,4 @@ obj/machinery/door/proc/try_to_crowbar(obj/item/I, mob/user) return /obj/machinery/door/proc/unlock() - return \ No newline at end of file + return diff --git a/code/game/machinery/recycler.dm b/code/game/machinery/recycler.dm index f98ac6d0605..44954f90af3 100644 --- a/code/game/machinery/recycler.dm +++ b/code/game/machinery/recycler.dm @@ -148,11 +148,12 @@ var/const/SAFETY_COOLDOWN = 100 safety_mode = TRUE update_icon() L.loc = src.loc + addtimer(src, "reboot", SAFETY_COOLDOWN) - spawn(SAFETY_COOLDOWN) - playsound(src.loc, 'sound/machines/ping.ogg', 50, 0) - safety_mode = FALSE - update_icon() +/obj/machinery/recycler/proc/reboot() + playsound(src.loc, 'sound/machines/ping.ogg', 50, 0) + safety_mode = FALSE + update_icon() /obj/machinery/recycler/proc/crush_living(mob/living/L) diff --git a/code/modules/reagents/chemistry/recipes/slime_extracts.dm b/code/modules/reagents/chemistry/recipes/slime_extracts.dm index eceb9be7e61..6022bad0b6c 100644 --- a/code/modules/reagents/chemistry/recipes/slime_extracts.dm +++ b/code/modules/reagents/chemistry/recipes/slime_extracts.dm @@ -102,8 +102,8 @@ feedback_add_details("slime_cores_used","[type]") var/turf/T = get_turf(holder.my_atom) T.visible_message("The slime extract begins to vibrate violently !") - spawn(50) - chemical_mob_spawn(holder, 5, "Gold Slime") + addtimer(src, "chemical_mob_spawn", 50, unique=FALSE, + holder, 5, "Gold Slime") /datum/chemical_reaction/slimecritlesser name = "Slime Crit Lesser" @@ -118,8 +118,8 @@ feedback_add_details("slime_cores_used","[type]") var/turf/T = get_turf(holder.my_atom) T.visible_message("The slime extract begins to vibrate violently !") - spawn(50) - chemical_mob_spawn(holder, 3, "Lesser Gold Slime", "neutral") + addtimer(src, "chemical_mob_spawn", 50, unique=FALSE, + holder, 3, "Lesser Gold Slime", "neutral") /datum/chemical_reaction/slimecritfriendly name = "Slime Crit Friendly" @@ -134,8 +134,8 @@ feedback_add_details("slime_cores_used","[type]") var/turf/T = get_turf(holder.my_atom) T.visible_message("The slime extract begins to vibrate adorably !") - spawn(50) - chemical_mob_spawn(holder, 1, "Friendly Gold Slime", "neutral") + addtimer(src, "chemical_mob_spawn", 50, unique=FALSE, + holder, 1, "Friendly Gold Slime", "neutral") //Silver /datum/chemical_reaction/slimebork diff --git a/code/modules/spells/spell_types/lichdom.dm b/code/modules/spells/spell_types/lichdom.dm index f6a119c428a..511f446bf4f 100644 --- a/code/modules/spells/spell_types/lichdom.dm +++ b/code/modules/spells/spell_types/lichdom.dm @@ -106,32 +106,32 @@ for(var/obj/item in hand_items) if(ABSTRACT in item.flags || NODROP in item.flags) continue - marked_item = item + marked_item = item M << "You begin to focus your very being into the [item.name]..." break if(!marked_item) M << "You must hold an item you wish to make your phylactery..." return - spawn(50) - if(marked_item.loc != M) //I changed my mind I don't want to put my soul in a cheeseburger! - M << "Your soul snaps back to your body as you drop the [marked_item.name]!" - marked_item = null - return - name = "RISE!" - desc = "Rise from the dead! You will reform at the location of your phylactery and your old body will crumble away." - charge_max = 1800 //3 minute cooldown, if you rise in sight of someone and killed again, you're probably screwed. - charge_counter = 1800 - stat_allowed = 1 - marked_item.name = "Ensouled [marked_item.name]" - marked_item.desc = "A terrible aura surrounds this item, its very existence is offensive to life itself..." - marked_item.color = "#003300" - M << "With a hideous feeling of emptiness you watch in horrified fascination as skin sloughs off bone! Blood boils, nerves disintegrate, eyes boil in their sockets! As your organs crumble to dust in your fleshless chest you come to terms with your choice. You're a lich!" - M.set_species(/datum/species/skeleton) - current_body = M.mind.current - if(ishuman(M)) - var/mob/living/carbon/human/H = M - H.unEquip(H.wear_suit) - H.unEquip(H.head) - H.equip_to_slot_or_del(new /obj/item/clothing/suit/wizrobe/black(H), slot_wear_suit) - H.equip_to_slot_or_del(new /obj/item/clothing/head/wizard/black(H), slot_head) + if(!do_after(M, 50, needhand=FALSE, target=marked_item)) + M << "Your soul snaps back to your body as you stop ensouling [marked_item.name]!" + marked_item = null + return + + name = "RISE!" + desc = "Rise from the dead! You will reform at the location of your phylactery and your old body will crumble away." + charge_max = 1800 //3 minute cooldown, if you rise in sight of someone and killed again, you're probably screwed. + charge_counter = 1800 + stat_allowed = 1 + marked_item.name = "Ensouled [marked_item.name]" + marked_item.desc = "A terrible aura surrounds this item, its very existence is offensive to life itself..." + marked_item.color = "#003300" + M << "With a hideous feeling of emptiness you watch in horrified fascination as skin sloughs off bone! Blood boils, nerves disintegrate, eyes boil in their sockets! As your organs crumble to dust in your fleshless chest you come to terms with your choice. You're a lich!" + M.set_species(/datum/species/skeleton) + current_body = M.mind.current + if(ishuman(M)) + var/mob/living/carbon/human/H = M + H.unEquip(H.wear_suit) + H.unEquip(H.head) + H.equip_to_slot_or_del(new /obj/item/clothing/suit/wizrobe/black(H), slot_wear_suit) + H.equip_to_slot_or_del(new /obj/item/clothing/head/wizard/black(H), slot_head) diff --git a/code/modules/spells/spell_types/wizard.dm b/code/modules/spells/spell_types/wizard.dm index 4976b6a4718..89eb9a6d1ef 100644 --- a/code/modules/spells/spell_types/wizard.dm +++ b/code/modules/spells/spell_types/wizard.dm @@ -319,9 +319,7 @@ AM.overlays += targeteffect throwtarget = get_edge_target_turf(user, get_dir(user, get_step_away(AM, user))) distfromcaster = get_dist(user, AM) - spawn(10) - AM.overlays -= targeteffect - qdel(targeteffect) + addtimer(src, "remove_sparkles", AM, targeteffect) if(distfromcaster == 0) if(istype(AM, /mob/living)) var/mob/living/M = AM @@ -335,6 +333,9 @@ M << "You're thrown back by [user]!" AM.throw_at_fast(throwtarget, ((Clamp((maxthrow - (Clamp(distfromcaster - 2, 0, distfromcaster))), 3, maxthrow))), 1,user)//So stuff gets tossed around at the same time. +/obj/effect/proc_holder/spell/aoe_turf/repulse/proc/remove_sparkles(atom/movable/AM, obj/effect/overlay/targeteffect) + AM.overlays -= targeteffect + qdel(targeteffect) /obj/effect/proc_holder/spell/aoe_turf/repulse/xeno //i fixed conflicts only to find out that this is in the WIZARD file instead of the xeno file?! name = "Tail Sweep" diff --git a/code/modules/surgery/organs/augments_chest.dm b/code/modules/surgery/organs/augments_chest.dm index c2d7fc0efa0..2e1d1677973 100644 --- a/code/modules/surgery/organs/augments_chest.dm +++ b/code/modules/surgery/organs/augments_chest.dm @@ -21,11 +21,11 @@ return if(owner.nutrition <= hunger_threshold) - synthesizing = 1 + synthesizing = TRUE owner << "You feel less hungry..." owner.nutrition += 50 - spawn(50) - synthesizing = 0 + sleep(50) + synthesizing = FALSE /obj/item/organ/cyberimp/chest/nutriment/emp_act(severity) if(!owner) @@ -57,22 +57,10 @@ /obj/item/organ/cyberimp/chest/reviver/on_life() if(reviving) if(owner.stat == UNCONSCIOUS) - spawn(30) - if(prob(90) && owner.getOxyLoss()) - owner.adjustOxyLoss(-3) - revive_cost += 5 - if(prob(75) && owner.getBruteLoss()) - owner.adjustBruteLoss(-1) - revive_cost += 20 - if(prob(75) && owner.getFireLoss()) - owner.adjustFireLoss(-1) - revive_cost += 20 - if(prob(40) && owner.getToxLoss()) - owner.adjustToxLoss(-1) - revive_cost += 50 + addtimer(src, "heal", 30) else cooldown = revive_cost + world.time - reviving = 0 + reviving = FALSE return if(cooldown > world.time) @@ -83,7 +71,21 @@ return revive_cost = 0 - reviving = 1 + reviving = TRUE + +/obj/item/organ/cyberimp/chest/reviver/proc/heal() + if(prob(90) && owner.getOxyLoss()) + owner.adjustOxyLoss(-3) + revive_cost += 5 + if(prob(75) && owner.getBruteLoss()) + owner.adjustBruteLoss(-1) + revive_cost += 20 + if(prob(75) && owner.getFireLoss()) + owner.adjustFireLoss(-1) + revive_cost += 20 + if(prob(40) && owner.getToxLoss()) + owner.adjustToxLoss(-1) + revive_cost += 50 /obj/item/organ/cyberimp/chest/reviver/emp_act(severity) if(!owner) @@ -97,13 +99,16 @@ if(istype(owner, /mob/living/carbon/human)) var/mob/living/carbon/human/H = owner if(H.stat != DEAD && prob(50 / severity)) - H.heart_attack = 1 - spawn(600 / severity) - H.heart_attack = 0 - if(H.stat == CONSCIOUS) - H << "You feel your heart beating again!" - + H.heart_attack = TRUE + addtimer(src, "undo_heart_attack", 600 / severity) +/obj/item/organ/cyberimp/chest/reviver/proc/undo_heart_attack() + var/mob/living/carbon/human/H = owner + if(!istype(H)) + return + H.heart_attack = FALSE + if(H.stat == CONSCIOUS) + H << "You feel your heart beating again!" /obj/item/organ/cyberimp/chest/thrusters diff --git a/code/modules/surgery/organs/augments_internal.dm b/code/modules/surgery/organs/augments_internal.dm index 683a2a176a4..2f73fe7ed02 100644 --- a/code/modules/surgery/organs/augments_internal.dm +++ b/code/modules/surgery/organs/augments_internal.dm @@ -140,9 +140,11 @@ /obj/item/organ/cyberimp/brain/anti_stun/emp_act(severity) if(crit_fail) return - crit_fail = 1 - spawn(90 / severity) - crit_fail = 0 + crit_fail = TRUE + addtimer(src, "reboot", 90 / severity) + +/obj/item/organ/cyberimp/brain/anti_stun/proc/reboot() + crit_fail = FALSE //[[[[MOUTH]]]] diff --git a/code/modules/surgery/organs/organ_internal.dm b/code/modules/surgery/organs/organ_internal.dm index b051541a2c7..1e4a8a0f3a0 100644 --- a/code/modules/surgery/organs/organ_internal.dm +++ b/code/modules/surgery/organs/organ_internal.dm @@ -125,18 +125,19 @@ if(!special) H.heart_attack = 1 - spawn(120) - if(!owner) - Stop() + addtimer(src, "stop_if_unowned", 120) + +/obj/item/organ/heart/proc/stop_if_unowned() + if(!owner) + Stop() /obj/item/organ/heart/attack_self(mob/user) ..() if(!beating) + visible_message("[user] squeezes [src] to \ + make it beat again!") Restart() - spawn(80) - if(!owner) - Stop() - + addtimer(src, "stop_if_unowned", 80) /obj/item/organ/heart/Insert(mob/living/carbon/M, special = 0) ..() diff --git a/code/modules/telesci/gps.dm b/code/modules/telesci/gps.dm index 3df5a057277..f882b4444c7 100644 --- a/code/modules/telesci/gps.dm +++ b/code/modules/telesci/gps.dm @@ -23,13 +23,15 @@ var/list/GPS_list = list() return ..() /obj/item/device/gps/emp_act(severity) - emped = 1 + emped = TRUE overlays -= "working" overlays += "emp" - spawn(300) - emped = 0 - overlays -= "emp" - overlays += "working" + addtimer(src, "reboot", 300) + +/obj/item/device/gps/proc/reboot() + emped = FALSE + overlays -= "emp" + overlays += "working" /obj/item/device/gps/AltClick(mob/user) if(!user.canUseTopic(src, be_close=TRUE)) diff --git a/code/modules/zombie/items.dm b/code/modules/zombie/items.dm index 5e2455a18e9..df643003d35 100644 --- a/code/modules/zombie/items.dm +++ b/code/modules/zombie/items.dm @@ -74,11 +74,7 @@ A.audible_message("You hear a loud metallic \ grinding sound.") - spawn(20) - if(removing_airlock) - playsound(src.loc, 'sound/hallucinations/growl3.ogg', 50, 1) - user.audible_message("[user] growls as \ - their claws dig into the metal frame...") + addtimer(src, "growl", 20, unique=FALSE, user) if(do_after(user, delay=160, needhand=FALSE, target=A, progress=TRUE)) playsound(src.loc, 'sound/hallucinations/far_noise.ogg', 50, 1) @@ -93,6 +89,12 @@ qdel(A) removing_airlock = FALSE +/obj/item/zombie_hand/proc/growl(mob/user) + if(removing_airlock) + playsound(src.loc, 'sound/hallucinations/growl3.ogg', 50, 1) + user.audible_message("[user] growls as \ + their claws dig into the metal frame...") + /obj/item/zombie_hand/suicide_act(mob/living/carbon/user) // Suiciding as a zombie brings someone else in to play it user.visible_message("[user] is lying down.")