From f5cbd8c35e1119941d4436fa0ecf1a42587eefa9 Mon Sep 17 00:00:00 2001 From: Aronai Sieyes Date: Thu, 30 Apr 2020 15:43:58 -0400 Subject: [PATCH] Stop adjusting cooldown directly --- code/modules/admin/verbs/smite.dm | 10 ++----- code/modules/ai/interfaces.dm | 43 ++++++++++++++----------------- code/modules/mob/mob.dm | 4 +-- 3 files changed, 24 insertions(+), 33 deletions(-) diff --git a/code/modules/admin/verbs/smite.dm b/code/modules/admin/verbs/smite.dm index e8183e3665..1fd5120f55 100644 --- a/code/modules/admin/verbs/smite.dm +++ b/code/modules/admin/verbs/smite.dm @@ -56,18 +56,12 @@ return BSACooldown = 1 - spawn(50) - BSACooldown = 0 + VARSET_IN(global, BSACooldown, FALSE, 5 SECONDS) to_chat(target,"You've been hit by bluespace artillery!") log_and_message_admins("[key_name(target)] has been hit by Bluespace Artillery fired by [key_name(user ? user : usr)]") - var/obj/effect/stop/S - S = new /obj/effect/stop - S.victim = target - S.loc = target.loc - spawn(20) - qdel(S) + target.setMoveCooldown(2 SECONDS) var/turf/simulated/floor/T = get_turf(target) if(istype(T)) diff --git a/code/modules/ai/interfaces.dm b/code/modules/ai/interfaces.dm index 787e1b4e28..2755875df0 100644 --- a/code/modules/ai/interfaces.dm +++ b/code/modules/ai/interfaces.dm @@ -74,30 +74,27 @@ // Respects move cooldowns as if it had a client. // Also tries to avoid being superdumb with moving into certain tiles (unless that's desired). /mob/living/proc/IMove(turf/newloc, safety = TRUE) - if(check_move_cooldown()) -// if(!newdir) -// newdir = get_dir(get_turf(src), newloc) + if(!checkMoveCooldown()) + return MOVEMENT_ON_COOLDOWN - // Check to make sure moving to newloc won't actually kill us. e.g. we're a slime and trying to walk onto water. - if(istype(newloc)) - if(safety && !newloc.is_safe_to_enter(src)) - return MOVEMENT_FAILED - - // Move()ing to another tile successfully returns 32 because BYOND. Would rather deal with TRUE/FALSE-esque terms. - // Note that moving to the same tile will be 'successful'. - var/turf/old_T = get_turf(src) - - // An adjacency check to avoid mobs phasing diagonally past windows. - // This might be better in general movement code but I'm too scared to add it, and most things don't move diagonally anyways. - if(!old_T.Adjacent(newloc)) + // Check to make sure moving to newloc won't actually kill us. e.g. we're a slime and trying to walk onto water. + if(istype(newloc)) + if(safety && !newloc.is_safe_to_enter(src)) return MOVEMENT_FAILED - . = SelfMove(newloc) ? MOVEMENT_SUCCESSFUL : MOVEMENT_FAILED - if(. == MOVEMENT_SUCCESSFUL) - set_dir(get_dir(old_T, newloc)) - // Apply movement delay. - // Player movement has more factors but its all in the client and fixing that would be its own project. - setMoveCooldown(movement_delay()) - return + // Move()ing to another tile successfully returns 32 because BYOND. Would rather deal with TRUE/FALSE-esque terms. + // Note that moving to the same tile will be 'successful'. + var/turf/old_T = get_turf(src) - . = MOVEMENT_ON_COOLDOWN // To avoid superfast mobs that aren't meant to be superfast. Is actually -1. + // An adjacency check to avoid mobs phasing diagonally past windows. + // This might be better in general movement code but I'm too scared to add it, and most things don't move diagonally anyways. + if(!old_T.Adjacent(newloc)) + return MOVEMENT_FAILED + + . = SelfMove(newloc) ? MOVEMENT_SUCCESSFUL : MOVEMENT_FAILED + if(. == MOVEMENT_SUCCESSFUL) + set_dir(get_dir(old_T, newloc)) + // Apply movement delay. + // Player movement has more factors but its all in the client and fixing that would be its own project. + setMoveCooldown(movement_delay()) + return \ No newline at end of file diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 52b87e011d..095dd63e74 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -745,12 +745,12 @@ /mob/proc/facedir(var/ndir) - if(!canface() || (client && (client.moving || (world.time < move_delay)))) + if(!canface() || (client && (client.moving || !checkMoveCooldown()))) return 0 set_dir(ndir) if(buckled && buckled.buckle_movable) buckled.set_dir(ndir) - move_delay += movement_delay() + setMoveCooldown(movement_delay()) return 1