diff --git a/code/game/machinery/buttons.dm b/code/game/machinery/buttons.dm index f610a58fe49..dee501d0b02 100644 --- a/code/game/machinery/buttons.dm +++ b/code/game/machinery/buttons.dm @@ -147,7 +147,7 @@ if((stat & (NOPOWER|BROKEN))) return - if(device && device.cooldown) + if(device && device.next_activate > world.time) return if(!allowed(user)) diff --git a/code/modules/assembly/assembly.dm b/code/modules/assembly/assembly.dm index dd53ccbdfd2..5302153594b 100644 --- a/code/modules/assembly/assembly.dm +++ b/code/modules/assembly/assembly.dm @@ -14,7 +14,6 @@ var/secured = 1 var/list/attached_overlays = null var/obj/item/device/assembly_holder/holder = null - var/cooldown = 0//To prevent spam var/wire_type = WIRE_RECEIVE | WIRE_PULSE var/attachable = 0 // can this be attached to wires var/datum/wires/connected = null @@ -25,6 +24,8 @@ var/const/WIRE_RADIO_RECEIVE = 8 //Allows Pulsed(1) to call Activate() var/const/WIRE_RADIO_PULSE = 16 //Allows Pulse(1) to send a radio message + var/next_activate = 0 //When we're next allowed to activate - for spam control + /obj/item/device/assembly/proc/on_attach() /obj/item/device/assembly/proc/on_detach() @@ -43,16 +44,6 @@ return 1 -//Called via spawn(10) to have it count down the cooldown var -/obj/item/device/assembly/proc/process_cooldown() - cooldown-- - if(cooldown <= 0) - return 0 - spawn(10) - process_cooldown() - return 1 - - //Called when another assembly acts on this one, var/radio will determine where it came from for wire calcs /obj/item/device/assembly/proc/pulsed(radio = 0) if(wire_type & WIRE_RECEIVE) @@ -78,12 +69,10 @@ // What the device does when turned on /obj/item/device/assembly/proc/activate() - if(!secured || (cooldown > 0)) - return 0 - cooldown = 2 - spawn(10) - process_cooldown() - return 1 + if(qdeleted(src) || !secured || (next_activate > world.time)) + return FALSE + next_activate = world.time + 30 + return TRUE /obj/item/device/assembly/proc/toggle_secure() diff --git a/code/modules/assembly/doorcontrol.dm b/code/modules/assembly/doorcontrol.dm index 28fbe833f13..e5b591e4c43 100644 --- a/code/modules/assembly/doorcontrol.dm +++ b/code/modules/assembly/doorcontrol.dm @@ -6,6 +6,7 @@ attachable = 1 var/id = null var/can_change_id = 0 + var/cooldown = 0//Door cooldowns /obj/item/device/assembly/control/examine(mob/user) ..() @@ -152,4 +153,4 @@ C.cremate(usr) sleep(50) - cooldown = 0 \ No newline at end of file + cooldown = 0 diff --git a/code/modules/assembly/infrared.dm b/code/modules/assembly/infrared.dm index 9b76ccbc2e4..9ce556ff2aa 100644 --- a/code/modules/assembly/infrared.dm +++ b/code/modules/assembly/infrared.dm @@ -92,17 +92,15 @@ /obj/item/device/assembly/infra/holder_movement() if(!holder) return 0 -// setDir(holder.dir) qdel(first) return 1 /obj/item/device/assembly/infra/proc/trigger_beam() - if((!secured)||(!on)||(cooldown > 0)) - return 0 + if(!secured || !on || next_activate > world.time) + return FALSE pulse(0) audible_message("\icon[src] *beep* *beep*", null, 3) - cooldown = 2 - addtimer(src, "process_cooldown", 10) + next_activate = world.time + 30 /obj/item/device/assembly/infra/interact(mob/user)//TODO: change this this to the wire control panel if(is_secured(user)) diff --git a/code/modules/assembly/proximity.dm b/code/modules/assembly/proximity.dm index 8690a82d115..85699689361 100644 --- a/code/modules/assembly/proximity.dm +++ b/code/modules/assembly/proximity.dm @@ -59,12 +59,11 @@ /obj/item/device/assembly/prox_sensor/sense() - if((!secured)||(cooldown > 0)) + if(!secured || next_activate > world.time) return 0 pulse(0) audible_message("\icon[src] *beep* *beep*", null, 3) - cooldown = 2 - addtimer(src, "process_cooldown", 10) + next_activate = world.time + 30 /obj/item/device/assembly/prox_sensor/process() diff --git a/code/modules/assembly/signaler.dm b/code/modules/assembly/signaler.dm index db8cd41f582..5bceadfd906 100644 --- a/code/modules/assembly/signaler.dm +++ b/code/modules/assembly/signaler.dm @@ -25,14 +25,10 @@ return ..() /obj/item/device/assembly/signaler/activate() - if(cooldown > 0) - return 0 - cooldown = 2 - spawn(10) - process_cooldown() - + if(!..())//cooldown processing + return FALSE signal() - return 1 + return TRUE /obj/item/device/assembly/signaler/update_icon() if(holder) @@ -188,4 +184,4 @@ Code: A.anomalyNeutralize() /obj/item/device/assembly/signaler/anomaly/attack_self() - return \ No newline at end of file + return diff --git a/code/modules/assembly/timer.dm b/code/modules/assembly/timer.dm index 80735e86467..12f8f464dc5 100644 --- a/code/modules/assembly/timer.dm +++ b/code/modules/assembly/timer.dm @@ -42,15 +42,12 @@ /obj/item/device/assembly/timer/proc/timer_end() - if((!secured)||(cooldown > 0)) - return 0 + if(!secured || next_activate > world.time) + return FALSE pulse(0) audible_message("\icon[src] *beep* *beep*", null, 3) - cooldown = 2 - spawn(10) - process_cooldown() - if(loop) - timing = 1 + if(loop) + timing = 1 update_icon()