From dfdeed74342fb6bae32bd71be97c21026a6b6466 Mon Sep 17 00:00:00 2001 From: Giacomand Date: Sun, 5 Jan 2014 17:44:46 +0000 Subject: [PATCH] Made the follow verb less buggy. Removed duplicated code. --- code/_onclick/observer.dm | 21 ----------- code/modules/mob/dead/observer/observer.dm | 43 ++++++++++++---------- 2 files changed, 23 insertions(+), 41 deletions(-) diff --git a/code/_onclick/observer.dm b/code/_onclick/observer.dm index c326d83df4..869b10c3a1 100644 --- a/code/_onclick/observer.dm +++ b/code/_onclick/observer.dm @@ -37,27 +37,6 @@ // Not all of them require checking, see below A.attack_ghost(src) -// This is the ghost's follow verb with an argument -/mob/dead/observer/proc/ManualFollow(var/atom/target) - following = target - if(target) - src << "\blue Now following [target]" - spawn(0) - var/turf/pos = get_turf(src) - while(loc == pos && target && following == target) - - var/turf/T = get_turf(target) - if(!T) - break - if(following != target) - break - if(!client) - break - loc = T - pos = loc - sleep(15) - following = null - // Oh by the way this didn't work with old click code which is why clicking shit didn't spam you /atom/proc/attack_ghost(mob/dead/observer/user as mob) if(user.client && user.client.inquisitive_ghost) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 2b5b5d75b7..ad75be05ad 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -369,27 +369,30 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp set name = "Follow" // "Haunt" set desc = "Follow and haunt a mob." - if(istype(usr, /mob/dead/observer)) - var/list/mobs = getmobs() - var/input = input("Please, select a mob!", "Haunt", null, null) as null|anything in mobs - var/mob/target = mobs[input] - if(target && target != usr) - following = target - spawn(0) - var/turf/pos = get_turf(src) - while(src.loc == pos) + var/list/mobs = getmobs() + var/input = input("Please, select a mob!", "Haunt", null, null) as null|anything in mobs + var/mob/target = mobs[input] + ManualFollow(target) - var/turf/T = get_turf(target) - if(!T) - break - if(following != target) - break - if(!client) - break - src.loc = T - pos = src.loc - sleep(15) - following = null +// This is the ghost's follow verb with an argument +/mob/dead/observer/proc/ManualFollow(var/atom/movable/target) + if(target && target != src) + if(following && following == target) + return + following = target + src << "\blue Now following [target]" + spawn(0) + var/turf/pos = get_turf(src) + while(loc == pos && target && following == target && client) + var/turf/T = get_turf(target) + if(!T) + break + // To stop the ghost flickering. + if(loc != T) + loc = T + pos = loc + sleep(15) + following = null /mob/dead/observer/verb/jumptomob() //Moves the ghost instead of just changing the ghosts's eye -Nodrak