From 63f9657d9b28d0363294cb22f34eff0b63e4be7f Mon Sep 17 00:00:00 2001 From: CitadelStationBot Date: Sun, 4 Jun 2017 11:06:47 -0500 Subject: [PATCH] Refactors a cooldown var to not require a spawn or sleep (#1381) --- code/game/gamemodes/malfunction/Malf_Modules.dm | 12 ++++-------- code/modules/mob/living/silicon/ai/ai.dm | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/code/game/gamemodes/malfunction/Malf_Modules.dm b/code/game/gamemodes/malfunction/Malf_Modules.dm index 4f09f2e362..199c07cf86 100644 --- a/code/game/gamemodes/malfunction/Malf_Modules.dm +++ b/code/game/gamemodes/malfunction/Malf_Modules.dm @@ -194,7 +194,7 @@ set desc = "Detonate all RCDs on the station, while sparing onboard cyborg RCDs." set waitfor = FALSE - if(!canUseTopic() || malf_cooldown) + if(!canUseTopic() || malf_cooldown > world.time) return for(var/I in GLOB.rcd_list) @@ -203,9 +203,7 @@ RCD.detonate_pulse() to_chat(src, "RCD detonation pulse emitted.") - malf_cooldown = TRUE - sleep(100) - malf_cooldown = FALSE + malf_cooldown = world.time + 100 /datum/AI_Module/large/mecha_domination module_name = "Viral Mech Domination" @@ -446,7 +444,7 @@ set name = "Reactivate Cameranet" set category = "Malfunction" - if(!canUseTopic() || malf_cooldown) + if(!canUseTopic() || malf_cooldown > world.time) return var/fixedcams = 0 //Tells the AI how many cams it fixed. Stats are fun. @@ -469,9 +467,7 @@ break to_chat(src, "Diagnostic complete! Operations completed: [fixedcams].") - malf_cooldown = 1 - spawn(30) //Lag protection - malf_cooldown = 0 + malf_cooldown = world.time + 30 /datum/AI_Module/large/upgrade_cameras module_name = "Upgrade Camera Network" diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index f4cfb363fd..2655820e2f 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -53,7 +53,7 @@ var/control_disabled = 0 // Set to 1 to stop AI from interacting via Click() var/malfhacking = 0 // More or less a copy of the above var, so that malf AIs can hack and still get new cyborgs -- NeoFite - var/malf_cooldown = 0 //Cooldown var for malf modules + var/malf_cooldown = 0 //Cooldown var for malf modules, stores a worldtime + cooldown var/obj/machinery/power/apc/malfhack = null var/explosive = 0 //does the AI explode when it dies?