diff --git a/code/defines/obj.dm b/code/defines/obj.dm
index 187b69e021..7308083ae6 100644
--- a/code/defines/obj.dm
+++ b/code/defines/obj.dm
@@ -59,22 +59,11 @@
var/damage = 0.0
var/range = 10.0
-
-/obj/effect/list_container
- name = "list container"
-
-/obj/effect/list_container/mobl
- name = "mobl"
- var/master = null
-
- var/list/container = list( )
-
/obj/effect/projection
name = "Projection"
desc = "This looks like a projection of something."
anchored = 1.0
-
/obj/effect/shut_controller
name = "shut controller"
var/moving = null
@@ -114,12 +103,5 @@
user.drop_item()
src.throw_at(target, throw_range, throw_speed, user)
-/obj/effect/stop
- var/victim = null
- icon_state = "empty"
- name = "Geas"
- desc = "You can't resist."
- // name = ""
-
/obj/effect/spawner
name = "object spawner"
diff --git a/code/modules/mob/living/inventory.dm b/code/modules/mob/living/inventory.dm
index 22db034374..24f36f8ac7 100644
--- a/code/modules/mob/living/inventory.dm
+++ b/code/modules/mob/living/inventory.dm
@@ -127,39 +127,27 @@
onclose(user, "mob[name]")
return
-/mob/living/ret_grab(obj/effect/list_container/mobl/L as obj, flag)
- if ((!( istype(l_hand, /obj/item/weapon/grab) ) && !( istype(r_hand, /obj/item/weapon/grab) )))
- if (!( L ))
- return null
- else
- return L.container
- else
- if (!( L ))
- L = new /obj/effect/list_container/mobl( null )
- L.container += src
- L.master = src
- if (istype(l_hand, /obj/item/weapon/grab))
- var/obj/item/weapon/grab/G = l_hand
- if (!( L.container.Find(G.affecting) ))
- L.container += G.affecting
- if (G.affecting)
- G.affecting.ret_grab(L, 1)
- if (istype(r_hand, /obj/item/weapon/grab))
- var/obj/item/weapon/grab/G = r_hand
- if (!( L.container.Find(G.affecting) ))
- L.container += G.affecting
- if (G.affecting)
- G.affecting.ret_grab(L, 1)
- if (!( flag ))
- if (L.master == src)
- var/list/temp = list( )
- temp += L.container
- //L = null
- qdel(L)
- return temp
- else
- return L.container
- return
+/mob/living/ret_grab(var/list/L, var/mobchain_limit = 5)
+ // We're the first!
+ if(!L)
+ L = list()
+
+ // Lefty grab!
+ if (istype(l_hand, /obj/item/weapon/grab))
+ var/obj/item/weapon/grab/G = l_hand
+ L |= G.affecting
+ if(mobchain_limit-- > 0)
+ G.affecting?.ret_grab(L, mobchain_limit) // Recurse! They can update the list. It's the same instance as ours.
+
+ // Righty grab!
+ if (istype(r_hand, /obj/item/weapon/grab))
+ var/obj/item/weapon/grab/G = r_hand
+ L |= G.affecting
+ if(mobchain_limit-- > 0)
+ G.affecting?.ret_grab(L, mobchain_limit) // Same as lefty!
+
+ // On all but the one not called by us, this will just be ignored. Oh well!
+ return L
/mob/living/mode()
set name = "Activate Held Object"
diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm
index d2fe2ecbd9..1100bd0385 100644
--- a/code/modules/mob/mob_movement.dm
+++ b/code/modules/mob/mob_movement.dm
@@ -1,8 +1,8 @@
/mob/proc/setMoveCooldown(var/timeout)
- move_delay = max(world.time + timeout, move_delay)
+ next_move = max(world.time + timeout, next_move)
-/mob/proc/check_move_cooldown()
- if(world.time < src.move_delay)
+/mob/proc/checkMoveCooldown()
+ if(world.time < next_move)
return FALSE // Need to wait more.
return TRUE
@@ -108,206 +108,224 @@
mob.control_object.forceMove(get_step(mob.control_object,direct))
return
-
+// NB: This is called for 'self movement', not for being pulled or things like that, which COULD be the case for /mob/Move
+// But to be honest, A LOT OF THIS CODE should be in /mob/Move
/client/Move(n, direct)
- //if(!mob) // Clients cannot have a null mob, as enforced by byond
- // return // Moved here to avoid nullrefs below
+ // Prevents a double-datum lookup each time this is referenced
+ // May seem dumb, but it's faster to look up a var on my_mob than dereferencing mob on client, then dereferencing the var on that mob
+ // Having it in a var here means it's more available to look up things on. It won't speed up that second dereference, though.
+ var/mob/my_mob = mob
- if(mob.control_object) Move_object(direct)
+ // Nothing to do in nullspace
+ if(!my_mob.loc)
+ return
- if(mob.incorporeal_move && isobserver(mob))
+ // Used many times below, faster reference.
+ var/atom/loc = my_mob.loc
+
+ // We're controlling an object which is SOMEHOW DIFFERENT FROM AN EYE??
+ if(my_mob.control_object)
+ Move_object(direct)
+
+ // Ghosty mob movement
+ if(my_mob.incorporeal_move && isobserver(my_mob))
Process_Incorpmove(direct)
return
- if(moving) return 0
+ // We're in the middle of another move we've already decided to do
+ if(moving)
+ return 0
- if(!mob.check_move_cooldown())
+ // We're still cooling down from the last move
+ if(!my_mob.checkMoveCooldown())
return
- if(locate(/obj/effect/stop/, mob.loc))
- for(var/obj/effect/stop/S in mob.loc)
- if(S.victim == mob)
- return
-
- if(mob.stat==DEAD && isliving(mob) && !mob.forbid_seeing_deadchat)
- mob.ghostize()
+ // If dead and we try to move in our mob, it leaves our body
+ if(my_mob.stat == DEAD && isliving(my_mob) && !my_mob.forbid_seeing_deadchat)
+ my_mob.ghostize()
return
- // handle possible Eye movement
- if(mob.eyeobj)
- return mob.EyeMove(n,direct)
+ // If we have an eyeobj, it moves instead
+ if(my_mob.eyeobj)
+ return my_mob.EyeMove(n,direct)
- if(mob.transforming) return//This is sota the goto stop mobs from moving var
+ // This is sota the goto stop mobs from moving var (for some reason)
+ if(my_mob.transforming)
+ return
- if(isliving(mob))
- var/mob/living/L = mob
+ if(isliving(my_mob))
+ var/mob/living/L = my_mob
if(L.incorporeal_move)//Move though walls
Process_Incorpmove(direct)
return
- if(mob.client)
- if(mob.client.view != world.view) // If mob moves while zoomed in with device, unzoom them.
- for(var/obj/item/item in mob.contents)
- if(item.zoom)
- item.zoom()
- break
- /*
- if(locate(/obj/item/weapon/gun/energy/sniperrifle, mob.contents)) // If mob moves while zoomed in with sniper rifle, unzoom them.
- var/obj/item/weapon/gun/energy/sniperrifle/s = locate() in mob
- if(s.zoom)
- s.zoom()
- if(locate(/obj/item/device/binoculars, mob.contents)) // If mob moves while zoomed in with binoculars, unzoom them.
- var/obj/item/device/binoculars/b = locate() in mob
- if(b.zoom)
- b.zoom()
- */
+ /* TODO observer unzoom
+ if(view != world.view) // If mob moves while zoomed in with device, unzoom them.
+ for(var/obj/item/item in mob.contents)
+ if(item.zoom)
+ item.zoom()
+ break
+ */
- if(Process_Grab()) return
-
- if(!mob.canmove)
+ if(Process_Grab())
return
- //Relaymove could handle it
- if(mob.machine)
- var/result = mob.machine.relaymove(mob, direct)
+ // Can't move
+ if(!my_mob.canmove)
+ return
+
+ // Relaymove could handle it
+ if(my_mob.machine)
+ var/result = my_mob.machine.relaymove(my_mob, direct)
if(result)
return result
- if(!mob.lastarea)
- mob.lastarea = get_area(mob.loc)
-
- if((istype(mob.loc, /turf/space)) || (mob.lastarea.has_gravity == 0))
- if(!mob.Process_Spacemove(0)) return 0
-
- if(isobj(mob.loc) || ismob(mob.loc))//Inside an object, tell it we moved
- var/atom/O = mob.loc
- return O.relaymove(mob, direct)
-
- if(isturf(mob.loc))
-
- if(mob.restrained())//Why being pulled while cuffed prevents you from moving
- for(var/mob/M in range(mob, 1))
- if(M.pulling == mob)
- if(!M.restrained() && M.stat == 0 && M.canmove && mob.Adjacent(M))
- to_chat(src, "You're restrained! You can't move!")
- return 0
- else
- M.stop_pulling()
-
- if(mob.pinned.len)
- to_chat(src, "You're pinned to a wall by [mob.pinned[1]]!")
+ // Can't control ourselves when drifting
+ if(isspace(loc) || my_mob.lastarea?.has_gravity == 0)
+ if(!my_mob.Process_Spacemove(0))
return 0
- mob.move_delay = world.time//set move delay
+ // Inside an object, tell it we moved
+ if(isobj(loc) || ismob(loc))
+ return loc.relaymove(my_mob, direct)
- switch(mob.m_intent)
- if("run")
- if(mob.drowsyness > 0)
- mob.move_delay += 6
- mob.move_delay += config.run_speed
- if("walk")
- mob.move_delay += config.walk_speed
- mob.move_delay += mob.movement_delay(n, direct)
+ // Can't move unless you're in the world somewhere
+ if(!isturf(loc))
+ return
- if(istype(mob.buckled, /obj/vehicle) || istype(mob.buckled, /mob)) //VOREStation Edit: taur riding. I think.
- //manually set move_delay for vehicles so we don't inherit any mob movement penalties
- //specific vehicle move delays are set in code\modules\vehicles\vehicle.dm
- mob.move_delay = world.time
- //drunk driving
- if(mob.confused && prob(20)) //vehicles tend to keep moving in the same direction
- direct = turn(direct, pick(90, -90))
- if(istype(mob.buckled, /mob)) //VOREStation Edit to prevent mob riding speed exploit.
- var/mob/M = mob.buckled
- if(M.move_delay > mob.move_delay - 10)
- return
- return mob.buckled.relaymove(mob,direct)
-
- if(mob.pulledby || mob.buckled) // Wheelchair driving!
- if(istype(mob.loc, /turf/space))
- return // No wheelchair driving in space
- if(istype(mob.pulledby, /obj/structure/bed/chair/wheelchair))
- return mob.pulledby.relaymove(mob, direct)
- else if(istype(mob.buckled, /obj/structure/bed/chair/wheelchair))
- if(ishuman(mob))
- var/mob/living/carbon/human/driver = mob
- var/obj/item/organ/external/l_hand = driver.get_organ("l_hand")
- var/obj/item/organ/external/r_hand = driver.get_organ("r_hand")
- if((!l_hand || l_hand.is_stump()) && (!r_hand || r_hand.is_stump()))
- return // No hands to drive your chair? Tough luck!
- //drunk wheelchair driving
- else if(mob.confused)
- switch(mob.m_intent)
- if("run")
- if(prob(50)) direct = turn(direct, pick(90, -90))
- if("walk")
- if(prob(25)) direct = turn(direct, pick(90, -90))
- mob.move_delay += 2
- return mob.buckled.relaymove(mob,direct)
-
- //We are now going to move
- moving = 1
- //Something with pulling things
- if(locate(/obj/item/weapon/grab, mob))
- mob.move_delay = max(mob.move_delay, world.time + 7)
- var/list/L = mob.ret_grab()
- if(istype(L, /list))
- if(L.len == 2)
- L -= mob
- var/mob/M = L[1]
- if(M)
- if ((get_dist(mob, M) <= 1 || M.loc == mob.loc))
- var/turf/T = mob.loc
- . = ..()
- if (isturf(M.loc))
- var/diag = get_dir(mob, M)
- if ((diag - 1) & diag)
- else
- diag = null
- if ((get_dist(mob, M) > 1 || diag))
- step(M, get_dir(M.loc, T))
+ // Why being pulled while cuffed prevents you from moving
+ if(my_mob.restrained())
+ for(var/mob/M in range(my_mob, 1))
+ if(M.pulling == my_mob)
+ if(!M.restrained() && M.stat == 0 && M.canmove && my_mob.Adjacent(M))
+ to_chat(src, "You're restrained! You can't move!")
+ return 0
else
- for(var/mob/M in L)
- M.other_mobs = 1
- if(mob != M)
- M.animate_movement = 3
- for(var/mob/M in L)
- spawn( 0 )
- step(M, direct)
- return
- spawn( 1 )
- M.other_mobs = null
- M.animate_movement = 2
- return
+ M.stop_pulling()
- else
- if(mob.confused)
- switch(mob.m_intent)
+ if(my_mob.pinned.len)
+ to_chat(src, "You're pinned to a wall by [my_mob.pinned[1]]!")
+ return 0
+
+ if(istype(my_mob.buckled, /obj/vehicle) || ismob(my_mob.buckled))
+ //manually set move_delay for vehicles so we don't inherit any mob movement penalties
+ //specific vehicle move delays are set in code\modules\vehicles\vehicle.dm
+ my_mob.next_move = world.time
+ //drunk driving
+ if(my_mob.confused && prob(20)) //vehicles tend to keep moving in the same direction
+ direct = turn(direct, pick(90, -90))
+ if(ismob(my_mob.buckled))
+ var/mob/M = my_mob.buckled
+ if(M.next_move > my_mob.next_move) // Don't let piggyback riders move their mob IN ADDITION TO the mob moving
+ return
+ return my_mob.buckled.relaymove(my_mob,direct)
+
+ if(my_mob.pulledby || my_mob.buckled) // Wheelchair driving!
+ if(isspace(loc))
+ return // No wheelchair driving in space
+ if(istype(my_mob.pulledby, /obj/structure/bed/chair/wheelchair))
+ return my_mob.pulledby.relaymove(my_mob, direct)
+ else if(istype(my_mob.buckled, /obj/structure/bed/chair/wheelchair))
+ if(ishuman(my_mob))
+ var/mob/living/carbon/human/driver = my_mob
+ var/obj/item/organ/external/l_hand = driver.get_organ("l_hand")
+ var/obj/item/organ/external/r_hand = driver.get_organ("r_hand")
+ if((!l_hand || l_hand.is_stump()) && (!r_hand || r_hand.is_stump()))
+ return // No hands to drive your chair? Tough luck!
+ //drunk wheelchair driving
+ else if(my_mob.confused)
+ switch(my_mob.m_intent)
if("run")
- if(prob(75))
+ if(prob(50))
direct = turn(direct, pick(90, -90))
- n = get_step(mob, direct)
if("walk")
if(prob(25))
direct = turn(direct, pick(90, -90))
- n = get_step(mob, direct)
- . = mob.SelfMove(n, direct)
+ my_mob.setMoveCooldown(2)
+ return my_mob.buckled.relaymove(my_mob,direct)
- for (var/obj/item/weapon/grab/G in mob)
- if (G.state == GRAB_NECK)
- mob.set_dir(reverse_dir[direct])
- G.adjust_position()
- for (var/obj/item/weapon/grab/G in mob.grabbed_by)
- G.adjust_position()
+ // We are now going to move
+ moving = 1
+ var/total_delay = 0
+ var/pre_move_loc = loc
- moving = 0
+ // Start tally'ing when we can next move
+ // Grabs slow you down
+ if(locate(/obj/item/weapon/grab) in my_mob)
+ total_delay += 7
+
+ // Movespeed delay based on movement mode
+ switch(my_mob.m_intent)
+ if("run")
+ if(my_mob.drowsyness > 0)
+ total_delay += 6
+ total_delay += config.run_speed
+ if("walk")
+ total_delay += config.walk_speed
+
+ // A billion other things can slow you down, ask the mob
+ total_delay += my_mob.movement_delay(n, direct)
- return .
+ // Confused direction randomization
+ if(my_mob.confused)
+ switch(my_mob.m_intent)
+ if("run")
+ if(prob(75))
+ direct = turn(direct, pick(90, -90))
+ n = get_step(my_mob, direct)
+ if("walk")
+ if(prob(25))
+ direct = turn(direct, pick(90, -90))
+ n = get_step(my_mob, direct)
+
+ total_delay = TICKS2DS(-round(-(DS2TICKS(total_delay)))) //Rounded to the next tick in equivalent ds
+ var/glide_size = WORLD_ICON_SIZE/DS2TICKS(total_delay) //Down to whatever decimal
+ my_mob.setMoveCooldown(max(total_delay, 1))
+ . = my_mob.SelfMove(n, direct, glide_size)
- return
+ // If we have a grab
+ var/list/grablist = my_mob.ret_grab()
+ if(grablist.len)
+ grablist -= my_mob // Just in case we're in a circular grab chain
+
+ // It's just us and another person
+ if(grablist.len == 1)
+ var/mob/M = grablist[1]
+ if(!my_mob.Adjacent(M)) //Oh no, we moved away
+ M.glide_size = glide_size
+ step(M, get_dir(M, pre_move_loc)) //Have them step towards where we were
+
+ // It's a grab chain
+ else
+ for(var/mob/M in grablist)
+ my_mob.other_mobs = 1
+ M.other_mobs = 1 //Has something to do with people being able or unable to pass a chain of mobs
+ M.animate_movement = 3
+
+ //Ugly!
+ spawn(0) //Step
+ M.glide_size = glide_size
+ step(M, direct)
+ spawn(1) //Unstep
+ M.other_mobs = null
+ M.animate_movement = 2
+ spawn(1) //Unset
+ my_mob.other_mobs = null
-/mob/proc/SelfMove(turf/n, direct)
+ // Update all the grabs!
+ for (var/obj/item/weapon/grab/G in my_mob)
+ if (G.state == GRAB_NECK)
+ mob.set_dir(reverse_dir[direct])
+ G.adjust_position()
+ for (var/obj/item/weapon/grab/G in my_mob.grabbed_by)
+ G.adjust_position()
+
+ // We're not in the middle of a move anymore
+ moving = 0
+
+/mob/proc/SelfMove(turf/n, direct, glide_size = 8)
+ src.glide_size = glide_size
return Move(n, direct)
-
///Process_Incorpmove
///Called by client/Move()
///Allows mobs to run though walls