diff --git a/code/__DEFINES/cooldowns.dm b/code/__DEFINES/cooldowns.dm index 63c1f2fd713..3335ac50fc4 100644 --- a/code/__DEFINES/cooldowns.dm +++ b/code/__DEFINES/cooldowns.dm @@ -74,14 +74,18 @@ #define TIMER_COOLDOWN_START(cd_source, cd_index, cd_time) LAZYSET(cd_source.cooldowns, cd_index, addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(end_cooldown), cd_source, cd_index), cd_time)) -#define TIMER_COOLDOWN_CHECK(cd_source, cd_index) LAZYACCESS(cd_source.cooldowns, cd_index) +/// Checks if a timer based cooldown is NOT finished. +#define TIMER_COOLDOWN_RUNNING(cd_source, cd_index) LAZYACCESS(cd_source.cooldowns, cd_index) + +/// Checks if a timer based cooldown is finished. +#define TIMER_COOLDOWN_FINISHED(cd_source, cd_index) (!TIMER_COOLDOWN_RUNNING(cd_source, cd_index)) #define TIMER_COOLDOWN_END(cd_source, cd_index) LAZYREMOVE(cd_source.cooldowns, cd_index) /* * Stoppable timer cooldowns. * Use indexes the same as the regular tiemr cooldowns. - * They make use of the TIMER_COOLDOWN_CHECK() and TIMER_COOLDOWN_END() macros the same, just not the TIMER_COOLDOWN_START() one. + * They make use of the TIMER_COOLDOWN_RUNNING() and TIMER_COOLDOWN_END() macros the same, just not the TIMER_COOLDOWN_START() one. * A bit more expensive than the regular timers, but can be reset before they end and the time left can be checked. */ @@ -89,7 +93,7 @@ #define S_TIMER_COOLDOWN_RESET(cd_source, cd_index) reset_cooldown(cd_source, cd_index) -#define S_TIMER_COOLDOWN_TIMELEFT(cd_source, cd_index) (timeleft(TIMER_COOLDOWN_CHECK(cd_source, cd_index))) +#define S_TIMER_COOLDOWN_TIMELEFT(cd_source, cd_index) (timeleft(TIMER_COOLDOWN_RUNNING(cd_source, cd_index))) /* diff --git a/code/datums/components/bumpattack.dm b/code/datums/components/bumpattack.dm index ec8cd272a44..a305b43c25b 100644 --- a/code/datums/components/bumpattack.dm +++ b/code/datums/components/bumpattack.dm @@ -64,7 +64,7 @@ var/obj/item/our_weapon = proxy_weapon || parent if(!istype(our_weapon)) CRASH("[our_weapon] somehow failed istype") - if(!TIMER_COOLDOWN_CHECK(src, COOLDOWN_BUMP_ATTACK)) + if(TIMER_COOLDOWN_FINISHED(src, COOLDOWN_BUMP_ATTACK)) TIMER_COOLDOWN_START(src, COOLDOWN_BUMP_ATTACK, attack_cooldown) INVOKE_ASYNC(target, TYPE_PROC_REF(/atom, attackby), our_weapon, bumper) bumper.visible_message(span_danger("[bumper] charges into [target], attacking with [our_weapon]!"), span_danger("You charge into [target], attacking with [our_weapon]!"), vision_distance = COMBAT_MESSAGE_RANGE) diff --git a/code/datums/emotes.dm b/code/datums/emotes.dm index 3ee251dfbab..88db5948d53 100644 --- a/code/datums/emotes.dm +++ b/code/datums/emotes.dm @@ -110,7 +110,7 @@ // SKYRAT EDIT END var/tmp_sound = get_sound(user) - if(tmp_sound && should_play_sound(user, intentional) && !TIMER_COOLDOWN_CHECK(user, type)) + if(tmp_sound && should_play_sound(user, intentional) && TIMER_COOLDOWN_FINISHED(user, type)) TIMER_COOLDOWN_START(user, type, audio_cooldown) //SKYRAT EDIT CHANGE BEGIN //playsound(user, tmp_sound, 50, vary) - SKYRAT EDIT - ORIGINAL diff --git a/code/game/objects/items/robot/robot_upgrades.dm b/code/game/objects/items/robot/robot_upgrades.dm index 92dd162a9b0..37c95a418db 100644 --- a/code/game/objects/items/robot/robot_upgrades.dm +++ b/code/game/objects/items/robot/robot_upgrades.dm @@ -375,7 +375,7 @@ cyborg.cell.use(5) next_repair = world.time + repair_cooldown * 10 // Multiply by 10 since world.time is in deciseconds - if(!TIMER_COOLDOWN_CHECK(src, COOLDOWN_BORG_SELF_REPAIR)) + if(TIMER_COOLDOWN_FINISHED(src, COOLDOWN_BORG_SELF_REPAIR)) TIMER_COOLDOWN_START(src, COOLDOWN_BORG_SELF_REPAIR, 200 SECONDS) var/msgmode = "standby" if(cyborg.health < 0) diff --git a/code/game/turfs/closed/minerals.dm b/code/game/turfs/closed/minerals.dm index 012d331f12a..47b08da3662 100644 --- a/code/game/turfs/closed/minerals.dm +++ b/code/game/turfs/closed/minerals.dm @@ -100,7 +100,7 @@ if (!isturf(T)) return - if(TIMER_COOLDOWN_CHECK(src, REF(user))) //prevents mining turfs in progress + if(TIMER_COOLDOWN_RUNNING(src, REF(user))) //prevents mining turfs in progress return TIMER_COOLDOWN_START(src, REF(user), tool_mine_speed) @@ -121,7 +121,7 @@ var/turf/user_turf = user.loc if (!isturf(user_turf)) return - if(TIMER_COOLDOWN_CHECK(src, REF(user))) //prevents mining turfs in progress + if(TIMER_COOLDOWN_RUNNING(src, REF(user))) //prevents mining turfs in progress return var/mining_speed = mining_arms ? tool_mine_speed : hand_mine_speed TIMER_COOLDOWN_START(src, REF(user), mining_speed) diff --git a/code/modules/assembly/signaler.dm b/code/modules/assembly/signaler.dm index d38d20790e1..3823706358f 100644 --- a/code/modules/assembly/signaler.dm +++ b/code/modules/assembly/signaler.dm @@ -96,7 +96,7 @@ switch(action) if("signal") if(cooldown_length > 0) - if(TIMER_COOLDOWN_CHECK(src, COOLDOWN_SIGNALLER_SEND)) + if(TIMER_COOLDOWN_RUNNING(src, COOLDOWN_SIGNALLER_SEND)) balloon_alert(ui.user, "recharging!") return TIMER_COOLDOWN_START(src, COOLDOWN_SIGNALLER_SEND, cooldown_length) @@ -135,7 +135,7 @@ return if(!ishuman(user)) return - if(TIMER_COOLDOWN_CHECK(src, COOLDOWN_SIGNALLER_SEND)) + if(TIMER_COOLDOWN_RUNNING(src, COOLDOWN_SIGNALLER_SEND)) balloon_alert(user, "still recharging...") return TIMER_COOLDOWN_START(src, COOLDOWN_SIGNALLER_SEND, 1 SECONDS) diff --git a/code/modules/cargo/expressconsole.dm b/code/modules/cargo/expressconsole.dm index a449c841495..149aaf6af86 100644 --- a/code/modules/cargo/expressconsole.dm +++ b/code/modules/cargo/expressconsole.dm @@ -149,7 +149,7 @@ if("add")//Generate Supply Order first - if(TIMER_COOLDOWN_CHECK(src, COOLDOWN_EXPRESSPOD_CONSOLE)) + if(TIMER_COOLDOWN_RUNNING(src, COOLDOWN_EXPRESSPOD_CONSOLE)) say("Railgun recalibrating. Stand by.") return var/id = params["id"] diff --git a/code/modules/mob/living/emote.dm b/code/modules/mob/living/emote.dm index be71ef5c350..a434f894082 100644 --- a/code/modules/mob/living/emote.dm +++ b/code/modules/mob/living/emote.dm @@ -575,7 +575,7 @@ if(!isliving(user)) return - if(!TIMER_COOLDOWN_CHECK(user, COOLDOWN_YAWN_PROPAGATION)) + if(TIMER_COOLDOWN_FINISHED(user, COOLDOWN_YAWN_PROPAGATION)) TIMER_COOLDOWN_START(user, COOLDOWN_YAWN_PROPAGATION, cooldown * 3) var/mob/living/carbon/carbon_user = user @@ -585,7 +585,7 @@ var/propagation_distance = user.client ? 5 : 2 // mindless mobs are less able to spread yawns for(var/mob/living/iter_living in view(user, propagation_distance)) - if(IS_DEAD_OR_INCAP(iter_living) || TIMER_COOLDOWN_CHECK(iter_living, COOLDOWN_YAWN_PROPAGATION)) + if(IS_DEAD_OR_INCAP(iter_living) || TIMER_COOLDOWN_RUNNING(iter_living, COOLDOWN_YAWN_PROPAGATION)) continue var/dist_between = get_dist(user, iter_living) @@ -604,7 +604,7 @@ /// This yawn has been triggered by someone else yawning specifically, likely after a delay. Check again if they don't have the yawned recently trait /datum/emote/living/yawn/proc/propagate_yawn(mob/user) - if(!istype(user) || TIMER_COOLDOWN_CHECK(user, COOLDOWN_YAWN_PROPAGATION)) + if(!istype(user) || TIMER_COOLDOWN_RUNNING(user, COOLDOWN_YAWN_PROPAGATION)) return user.emote("yawn") diff --git a/code/modules/vehicles/cars/clowncar.dm b/code/modules/vehicles/cars/clowncar.dm index 1fd230bb47a..6b019cac270 100644 --- a/code/modules/vehicles/cars/clowncar.dm +++ b/code/modules/vehicles/cars/clowncar.dm @@ -198,7 +198,7 @@ * * Fart and make everyone nearby laugh */ /obj/vehicle/sealed/car/clowncar/proc/roll_the_dice(mob/user) - if(TIMER_COOLDOWN_CHECK(src, COOLDOWN_CLOWNCAR_RANDOMNESS)) + if(TIMER_COOLDOWN_RUNNING(src, COOLDOWN_CLOWNCAR_RANDOMNESS)) to_chat(user, span_notice("The button panel is currently recharging.")) return TIMER_COOLDOWN_START(src, COOLDOWN_CLOWNCAR_RANDOMNESS, dice_cooldown_time) diff --git a/code/modules/vehicles/mecha/_mecha.dm b/code/modules/vehicles/mecha/_mecha.dm index 573e09f347d..f586a9656e8 100644 --- a/code/modules/vehicles/mecha/_mecha.dm +++ b/code/modules/vehicles/mecha/_mecha.dm @@ -682,7 +682,7 @@ if(!(livinguser in return_controllers_with_flag(VEHICLE_CONTROL_MELEE))) to_chat(livinguser, span_warning("You're in the wrong seat to interact with your hands.")) return - var/on_cooldown = TIMER_COOLDOWN_CHECK(src, COOLDOWN_MECHA_MELEE_ATTACK) + var/on_cooldown = TIMER_COOLDOWN_RUNNING(src, COOLDOWN_MECHA_MELEE_ATTACK) var/adjacent = Adjacent(target) if(SEND_SIGNAL(src, COMSIG_MECHA_MELEE_CLICK, livinguser, target, on_cooldown, adjacent) & COMPONENT_CANCEL_MELEE_CLICK) return @@ -749,7 +749,7 @@ balloon_alert(user, "cabin can't be sealed!") log_message("Tried to seal cabin. This mech can't be airtight.", LOG_MECHA) return - if(TIMER_COOLDOWN_CHECK(src, COOLDOWN_MECHA_CABIN_SEAL)) + if(TIMER_COOLDOWN_RUNNING(src, COOLDOWN_MECHA_CABIN_SEAL)) balloon_alert(user, "on cooldown!") return TIMER_COOLDOWN_START(src, COOLDOWN_MECHA_CABIN_SEAL, 1 SECONDS) diff --git a/code/modules/vehicles/mecha/combat/marauder.dm b/code/modules/vehicles/mecha/combat/marauder.dm index 79b09568994..2fe8da4bdc7 100644 --- a/code/modules/vehicles/mecha/combat/marauder.dm +++ b/code/modules/vehicles/mecha/combat/marauder.dm @@ -61,7 +61,7 @@ /datum/action/vehicle/sealed/mecha/mech_smoke/Trigger(trigger_flags) if(!owner || !chassis || !(owner in chassis.occupants)) return - if(!TIMER_COOLDOWN_CHECK(src, COOLDOWN_MECHA_SMOKE) && chassis.smoke_charges>0) + if(TIMER_COOLDOWN_FINISHED(src, COOLDOWN_MECHA_SMOKE) && chassis.smoke_charges>0) chassis.smoke_system.start() chassis.smoke_charges-- TIMER_COOLDOWN_START(src, COOLDOWN_MECHA_SMOKE, chassis.smoke_cooldown) diff --git a/code/modules/vehicles/mecha/combat/savannah_ivanov.dm b/code/modules/vehicles/mecha/combat/savannah_ivanov.dm index e3926aa7d35..1851e6b39b1 100644 --- a/code/modules/vehicles/mecha/combat/savannah_ivanov.dm +++ b/code/modules/vehicles/mecha/combat/savannah_ivanov.dm @@ -86,7 +86,7 @@ if(chassis.phasing) to_chat(owner, span_warning("You're already airborne!")) return - if(TIMER_COOLDOWN_CHECK(chassis, COOLDOWN_MECHA_SKYFALL)) + if(TIMER_COOLDOWN_RUNNING(chassis, COOLDOWN_MECHA_SKYFALL)) var/timeleft = S_TIMER_COOLDOWN_TIMELEFT(chassis, COOLDOWN_MECHA_SKYFALL) to_chat(owner, span_warning("You need to wait [DisplayTimeText(timeleft, 1)] before attempting to Skyfall.")) return @@ -254,7 +254,7 @@ /datum/action/vehicle/sealed/mecha/ivanov_strike/Trigger(trigger_flags) if(!owner || !chassis || !(owner in chassis.occupants)) return - if(TIMER_COOLDOWN_CHECK(chassis, COOLDOWN_MECHA_MISSILE_STRIKE)) + if(TIMER_COOLDOWN_RUNNING(chassis, COOLDOWN_MECHA_MISSILE_STRIKE)) var/timeleft = S_TIMER_COOLDOWN_TIMELEFT(chassis, COOLDOWN_MECHA_MISSILE_STRIKE) to_chat(owner, span_warning("You need to wait [DisplayTimeText(timeleft, 1)] before firing another Ivanov Strike.")) return diff --git a/code/modules/vehicles/mecha/equipment/mecha_equipment.dm b/code/modules/vehicles/mecha/equipment/mecha_equipment.dm index f9ee84ba4b8..aea1a21c082 100644 --- a/code/modules/vehicles/mecha/equipment/mecha_equipment.dm +++ b/code/modules/vehicles/mecha/equipment/mecha_equipment.dm @@ -107,7 +107,7 @@ if(get_integrity() <= 1) to_chat(chassis.occupants, span_warning("Error -- Equipment critically damaged.")) return FALSE - if(TIMER_COOLDOWN_CHECK(chassis, COOLDOWN_MECHA_EQUIPMENT(type))) + if(TIMER_COOLDOWN_RUNNING(chassis, COOLDOWN_MECHA_EQUIPMENT(type))) return FALSE return TRUE diff --git a/code/modules/vehicles/mecha/mecha_movement.dm b/code/modules/vehicles/mecha/mecha_movement.dm index d6c8feed4b3..e8c43ae48f9 100644 --- a/code/modules/vehicles/mecha/mecha_movement.dm +++ b/code/modules/vehicles/mecha/mecha_movement.dm @@ -70,14 +70,14 @@ return loc_atom.relaymove(src, direction) var/obj/machinery/portable_atmospherics/canister/internal_tank = get_internal_tank() if(internal_tank?.connected_port) - if(!TIMER_COOLDOWN_CHECK(src, COOLDOWN_MECHA_MESSAGE)) + if(TIMER_COOLDOWN_FINISHED(src, COOLDOWN_MECHA_MESSAGE)) to_chat(occupants, "[icon2html(src, occupants)][span_warning("Unable to move while connected to the air system port!")]") TIMER_COOLDOWN_START(src, COOLDOWN_MECHA_MESSAGE, 2 SECONDS) return FALSE if(!Process_Spacemove(direction)) return FALSE if(zoom_mode) - if(!TIMER_COOLDOWN_CHECK(src, COOLDOWN_MECHA_MESSAGE)) + if(TIMER_COOLDOWN_FINISHED(src, COOLDOWN_MECHA_MESSAGE)) to_chat(occupants, "[icon2html(src, occupants)][span_warning("Unable to move while in zoom mode!")]") TIMER_COOLDOWN_START(src, COOLDOWN_MECHA_MESSAGE, 2 SECONDS) return FALSE @@ -89,17 +89,17 @@ if(isnull(servo)) missing_parts += "micro-servo" if(length(missing_parts)) - if(!TIMER_COOLDOWN_CHECK(src, COOLDOWN_MECHA_MESSAGE)) + if(TIMER_COOLDOWN_FINISHED(src, COOLDOWN_MECHA_MESSAGE)) to_chat(occupants, "[icon2html(src, occupants)][span_warning("Missing [english_list(missing_parts)].")]") TIMER_COOLDOWN_START(src, COOLDOWN_MECHA_MESSAGE, 2 SECONDS) return FALSE if(!use_power(step_energy_drain)) - if(!TIMER_COOLDOWN_CHECK(src, COOLDOWN_MECHA_MESSAGE)) + if(TIMER_COOLDOWN_FINISHED(src, COOLDOWN_MECHA_MESSAGE)) to_chat(occupants, "[icon2html(src, occupants)][span_warning("Insufficient power to move!")]") TIMER_COOLDOWN_START(src, COOLDOWN_MECHA_MESSAGE, 2 SECONDS) return FALSE if(lavaland_only && is_mining_level(z)) - if(!TIMER_COOLDOWN_CHECK(src, COOLDOWN_MECHA_MESSAGE)) + if(TIMER_COOLDOWN_FINISHED(src, COOLDOWN_MECHA_MESSAGE)) to_chat(occupants, "[icon2html(src, occupants)][span_warning("Invalid Environment.")]") TIMER_COOLDOWN_START(src, COOLDOWN_MECHA_MESSAGE, 2 SECONDS) return FALSE diff --git a/code/modules/vehicles/vehicle_actions.dm b/code/modules/vehicles/vehicle_actions.dm index 1fbf394d270..5afcd58c0c0 100644 --- a/code/modules/vehicles/vehicle_actions.dm +++ b/code/modules/vehicles/vehicle_actions.dm @@ -232,7 +232,7 @@ var/hornsound = 'sound/items/carhorn.ogg' /datum/action/vehicle/sealed/horn/Trigger(trigger_flags) - if(TIMER_COOLDOWN_CHECK(src, COOLDOWN_CAR_HONK)) + if(TIMER_COOLDOWN_RUNNING(src, COOLDOWN_CAR_HONK)) return TIMER_COOLDOWN_START(src, COOLDOWN_CAR_HONK, 2 SECONDS) vehicle_entered_target.visible_message(span_danger("[vehicle_entered_target] loudly honks!")) @@ -316,7 +316,7 @@ var/bell_cooldown /datum/action/vehicle/ridden/wheelchair/bell/Trigger(trigger_flags) - if(TIMER_COOLDOWN_CHECK(src, bell_cooldown)) + if(TIMER_COOLDOWN_RUNNING(src, bell_cooldown)) return TIMER_COOLDOWN_START(src, bell_cooldown, 0.5 SECONDS) playsound(vehicle_ridden_target, 'sound/machines/microwave/microwave-end.ogg', 70) diff --git a/code/modules/wiremod/components/action/pathfind.dm b/code/modules/wiremod/components/action/pathfind.dm index 9820d9b81e0..0de6d346db1 100644 --- a/code/modules/wiremod/components/action/pathfind.dm +++ b/code/modules/wiremod/components/action/pathfind.dm @@ -77,7 +77,7 @@ return // If we're going to the same place and the cooldown hasn't subsided, we're probably on the same path as before - if (destination == old_dest && TIMER_COOLDOWN_CHECK(parent, COOLDOWN_CIRCUIT_PATHFIND_SAME)) + if (destination == old_dest && TIMER_COOLDOWN_RUNNING(parent, COOLDOWN_CIRCUIT_PATHFIND_SAME)) // Check if the current turf is the same as the current turf we're supposed to be in. If so, then we set the next step as the next turf on the list if(current_turf == next_turf) @@ -92,7 +92,7 @@ else // Either we're not going to the same place or the cooldown is over. Either way, we need a new path - if(destination != old_dest && TIMER_COOLDOWN_CHECK(parent, COOLDOWN_CIRCUIT_PATHFIND_DIF)) + if(destination != old_dest && TIMER_COOLDOWN_RUNNING(parent, COOLDOWN_CIRCUIT_PATHFIND_DIF)) failed.set_output(COMPONENT_SIGNAL) reason_failed.set_output("Cooldown still active!") return diff --git a/code/modules/wiremod/components/action/radio.dm b/code/modules/wiremod/components/action/radio.dm index 74b2c54c1b8..3940059453e 100644 --- a/code/modules/wiremod/components/action/radio.dm +++ b/code/modules/wiremod/components/action/radio.dm @@ -74,7 +74,7 @@ INVOKE_ASYNC(src, PROC_REF(handle_radio_input), port) /obj/item/circuit_component/radio/proc/handle_radio_input(datum/port/input/port) - if(!TIMER_COOLDOWN_CHECK(parent, COOLDOWN_SIGNALLER_SEND)) + if(TIMER_COOLDOWN_RUNNING(parent, COOLDOWN_SIGNALLER_SEND)) return var/frequency = freq.value diff --git a/code/modules/wiremod/components/action/soundemitter.dm b/code/modules/wiremod/components/action/soundemitter.dm index 6ee9b273fae..44b9cbae8ab 100644 --- a/code/modules/wiremod/components/action/soundemitter.dm +++ b/code/modules/wiremod/components/action/soundemitter.dm @@ -87,7 +87,7 @@ if(!parent.shell) return - if(TIMER_COOLDOWN_CHECK(parent.shell, COOLDOWN_CIRCUIT_SOUNDEMITTER)) + if(TIMER_COOLDOWN_RUNNING(parent.shell, COOLDOWN_CIRCUIT_SOUNDEMITTER)) return var/sound_to_play = options_map[sound_file.value] diff --git a/code/modules/wiremod/components/action/speech.dm b/code/modules/wiremod/components/action/speech.dm index 809c473c14a..4bf735cf82b 100644 --- a/code/modules/wiremod/components/action/speech.dm +++ b/code/modules/wiremod/components/action/speech.dm @@ -26,7 +26,7 @@ if(!parent.shell) return - if(TIMER_COOLDOWN_CHECK(parent.shell, COOLDOWN_CIRCUIT_SPEECH)) + if(TIMER_COOLDOWN_RUNNING(parent.shell, COOLDOWN_CIRCUIT_SPEECH)) return if(message.value) diff --git a/code/modules/wiremod/components/bci/hud/target_intercept.dm b/code/modules/wiremod/components/bci/hud/target_intercept.dm index 8352b0aead9..bfdaec13122 100644 --- a/code/modules/wiremod/components/bci/hud/target_intercept.dm +++ b/code/modules/wiremod/components/bci/hud/target_intercept.dm @@ -42,7 +42,7 @@ if(!owner || !istype(owner) || !owner.client) return - if(TIMER_COOLDOWN_CHECK(parent.shell, COOLDOWN_CIRCUIT_TARGET_INTERCEPT)) + if(TIMER_COOLDOWN_RUNNING(parent.shell, COOLDOWN_CIRCUIT_TARGET_INTERCEPT)) return to_chat(owner, "Left-click to trigger target interceptor!") diff --git a/code/modules/wiremod/components/sensors/view_sensor.dm b/code/modules/wiremod/components/sensors/view_sensor.dm index f65853986e3..1725044c035 100644 --- a/code/modules/wiremod/components/sensors/view_sensor.dm +++ b/code/modules/wiremod/components/sensors/view_sensor.dm @@ -37,7 +37,7 @@ if(!parent.shell) return - if(TIMER_COOLDOWN_CHECK(parent.shell, COOLDOWN_CIRCUIT_VIEW_SENSOR)) + if(TIMER_COOLDOWN_RUNNING(parent.shell, COOLDOWN_CIRCUIT_VIEW_SENSOR)) result.set_output(null) cooldown.set_output(COMPONENT_SIGNAL) return