From cd8e2175088aff6df8098b7754c6db33340aa6e2 Mon Sep 17 00:00:00 2001 From: Fira Date: Sun, 5 Nov 2023 17:47:40 +0000 Subject: [PATCH] move stop pulling logic --- code/modules/mob/mob.dm | 28 ++++++++++++++++++++++++++++ code/modules/mob/mob_verbs.dm | 25 +------------------------ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 02a686320b04..3cf985ca62b6 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -513,6 +513,34 @@ return do_pull(AM, lunge, no_msg) +/mob/proc/stop_pulling() + if(!pulling) + return + + REMOVE_TRAIT(pulling, TRAIT_FLOORED, CHOKEHOLD_TRAIT) + var/mob/M = pulling + pulling.pulledby = null + pulling = null + + grab_level = 0 + if(client) + client.recalculate_move_delay() + // When you stop pulling a mob after you move a tile with it your next movement will still include + // the grab delay so we have to fix it here (we love code) + client.next_movement = world.time + client.move_delay + if(hud_used && hud_used.pull_icon) + hud_used.pull_icon.icon_state = "pull0" + if(istype(r_hand, /obj/item/grab)) + temp_drop_inv_item(r_hand) + else if(istype(l_hand, /obj/item/grab)) + temp_drop_inv_item(l_hand) + if(istype(M)) + if(M.client) + //resist_grab uses long movement cooldown durations to prevent message spam + //so we must undo it here so the victim can move right away + M.client.next_movement = world.time + M.update_transform(TRUE) + /mob/living/vv_get_header() . = ..() var/refid = REF(src) diff --git a/code/modules/mob/mob_verbs.dm b/code/modules/mob/mob_verbs.dm index 67d45092a4d8..74333b3e5d42 100644 --- a/code/modules/mob/mob_verbs.dm +++ b/code/modules/mob/mob_verbs.dm @@ -221,27 +221,4 @@ set name = "Stop Pulling" set category = "IC" - if(pulling) - REMOVE_TRAIT(pulling, TRAIT_FLOORED, CHOKEHOLD_TRAIT) - var/mob/M = pulling - pulling.pulledby = null - pulling = null - - grab_level = 0 - if(client) - client.recalculate_move_delay() - // When you stop pulling a mob after you move a tile with it your next movement will still include - // the grab delay so we have to fix it here (we love code) - client.next_movement = world.time + client.move_delay - if(hud_used && hud_used.pull_icon) - hud_used.pull_icon.icon_state = "pull0" - if(istype(r_hand, /obj/item/grab)) - temp_drop_inv_item(r_hand) - else if(istype(l_hand, /obj/item/grab)) - temp_drop_inv_item(l_hand) - if(istype(M)) - if(M.client) - //resist_grab uses long movement cooldown durations to prevent message spam - //so we must undo it here so the victim can move right away - M.client.next_movement = world.time - M.update_transform(TRUE) + stop_pulling()