Refactor move/click code

This commit is contained in:
Aronai Sieyes
2020-05-15 10:49:27 -04:00
parent 6571a10ad4
commit a8f3a0a7a0
40 changed files with 520 additions and 582 deletions

View File

@@ -35,10 +35,10 @@
/mob/living/carbon/Moved(atom/old_loc, direction, forced = FALSE)
. = ..()
if(src.nutrition && src.stat != DEAD)
adjust_nutrition(-DEFAULT_HUNGER_FACTOR / 10)
if(src.m_intent == "run")
if(src.nutrition && src.stat != 2)
adjust_nutrition(-DEFAULT_HUNGER_FACTOR / 10)
if(src.m_intent == "run")
adjust_nutrition(-DEFAULT_HUNGER_FACTOR / 10)
if((FAT in src.mutations) && src.m_intent == "run" && src.bodytemperature <= 360)
src.bodytemperature += 2
@@ -400,3 +400,4 @@
if(does_not_breathe)
return FALSE
return ..()

View File

@@ -1374,7 +1374,7 @@
set desc = "Pop a joint back into place. Extremely painful."
set src in view(1)
if(!isliving(usr) || !usr.canClick())
if(!isliving(usr) || !usr.checkClickCooldown())
return
usr.setClickCooldown(20)
@@ -1612,3 +1612,32 @@
msg += get_display_species()
return msg
/mob/living/carbon/human/pull_damage()
if(((health - halloss) <= config.health_threshold_softcrit))
for(var/name in organs_by_name)
var/obj/item/organ/external/e = organs_by_name[name]
if(!e)
continue
if((e.status & ORGAN_BROKEN && (!e.splinted || (e.splinted in e.contents && prob(30))) || e.status & ORGAN_BLEEDING) && (getBruteLoss() + getFireLoss() >= 100))
return 1
else
return ..()
// Drag damage is handled in a parent
/mob/living/carbon/human/dragged(var/mob/living/dragger, var/oldloc)
if(prob(getBruteLoss() * 200 / maxHealth))
var/bloodtrail = 1
if(species?.flags & NO_BLOOD)
bloodtrail = 0
else
var/blood_volume = round((vessel.get_reagent_amount("blood")/species.blood_volume)*100)
if(blood_volume < BLOOD_VOLUME_SURVIVE)
bloodtrail = 0 //Most of it's gone already, just leave it be
else
vessel.remove_reagent("blood", 1)
if(bloodtrail)
if(istype(loc, /turf/simulated))
var/turf/T = loc
T.add_blood(src)
. = ..()

View File

@@ -2,10 +2,10 @@
/mob/living/carbon/human/movement_delay(oldloc, direct)
var/tally = 0
. = ..()
if(species.slowdown)
tally = species.slowdown
. = species.slowdown
if (istype(loc, /turf/space)) return -1 // It's hard to be slowed down in space by... anything
@@ -19,54 +19,54 @@
if(!isnull(M.haste) && M.haste == TRUE)
return HUMAN_LOWEST_SLOWDOWN // Returning -1 will actually result in a slowdown for Teshari.
if(!isnull(M.slowdown))
tally += M.slowdown
. += M.slowdown
var/health_deficiency = (getMaxHealth() - health)
if(health_deficiency >= 40) tally += (health_deficiency / 25)
if(health_deficiency >= 40) . += (health_deficiency / 25)
if(can_feel_pain())
if(halloss >= 10) tally += (halloss / 10) //halloss shouldn't slow you down if you can't even feel it
if(halloss >= 10) . += (halloss / 10) //halloss shouldn't slow you down if you can't even feel it
var/hungry = (MAX_NUTRITION - nutrition) / 5
if (hungry >= 70) tally += hungry/50
if (hungry >= 70) . += hungry/50
if(istype(buckled, /obj/structure/bed/chair/wheelchair))
for(var/organ_name in list(BP_L_HAND, BP_R_HAND, BP_L_ARM, BP_R_ARM))
var/obj/item/organ/external/E = get_organ(organ_name)
if(!E || E.is_stump())
tally += 4
. += 4
else if(E.splinted && E.splinted.loc != E)
tally += 0.5
. += 0.5
else if(E.status & ORGAN_BROKEN)
tally += 1.5
. += 1.5
else
for(var/organ_name in list(BP_L_LEG, BP_R_LEG, BP_L_FOOT, BP_R_FOOT))
var/obj/item/organ/external/E = get_organ(organ_name)
if(!E || E.is_stump())
tally += 4
. += 4
else if(E.splinted && E.splinted.loc != E)
tally += 0.5
. += 0.5
else if(E.status & ORGAN_BROKEN)
tally += 1.5
. += 1.5
if(shock_stage >= 10) tally += 3
if(shock_stage >= 10) . += 3
if(aiming && aiming.aiming_at) tally += 5 // Iron sights make you slower, it's a well-known fact.
if(aiming && aiming.aiming_at) . += 5 // Iron sights make you slower, it's a well-known fact.
if(FAT in src.mutations)
tally += 1.5
. += 1.5
if (bodytemperature < species.cold_level_1)
tally += (species.cold_level_1 - bodytemperature) / 10 * 1.75
. += (species.cold_level_1 - bodytemperature) / 10 * 1.75
tally += max(2 * stance_damage, 0) //damaged/missing feet or legs is slow
. += max(2 * stance_damage, 0) //damaged/missing feet or legs is slow
if(mRun in mutations)
tally = 0
. = 0
// Turf related slowdown
var/turf/T = get_turf(src)
tally += calculate_turf_slowdown(T, direct)
. += calculate_turf_slowdown(T, direct)
// Item related slowdown.
var/item_tally = calculate_item_encumbrance()
@@ -83,19 +83,19 @@
item_tally *= species.item_slowdown_mod
tally += item_tally
. += item_tally
if(CE_SLOWDOWN in chem_effects)
if (tally >= 0 )
tally = (tally + tally/4) //Add a quarter of penalties on top.
tally += chem_effects[CE_SLOWDOWN]
if (. >= 0 )
. *= 1.25 //Add a quarter of penalties on top.
. += chem_effects[CE_SLOWDOWN]
if(CE_SPEEDBOOST in chem_effects)
if (tally >= 0) // cut any penalties in half
tally = tally/2
tally -= chem_effects[CE_SPEEDBOOST] // give 'em a buff on top.
if (. >= 0) // cut any penalties in half
. *= 0.5
. -= chem_effects[CE_SPEEDBOOST] // give 'em a buff on top.
return max(HUMAN_LOWEST_SLOWDOWN, tally+config.human_delay) // Minimum return should be the same as force_max_speed
. = max(HUMAN_LOWEST_SLOWDOWN, . + config.human_delay) // Minimum return should be the same as force_max_speed
// This calculates the amount of slowdown to receive from items worn. This does NOT include species modifiers.
// It is in a seperate place to avoid an infinite loop situation with dragging mobs dragging each other.
@@ -204,6 +204,8 @@
// Handle footstep sounds
/mob/living/carbon/human/handle_footstep(var/turf/T)
if(!istype(T))
return
if(is_incorporeal())
return
if(!config.footstep_volume || !T.footstep_sounds || !T.footstep_sounds.len)

View File

@@ -127,49 +127,37 @@
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"
set category = "Object"
set src = usr
if(world.time <= next_click) // This isn't really a 'click' but it'll work for our purposes.
if(!checkClickCooldown())
return
next_click = world.time + 1
setClickCooldown(1)
if(istype(loc,/obj/mecha)) return

View File

@@ -735,116 +735,65 @@ default behaviour is:
return
/mob/living/Move(a, b, flag)
if (buckled && buckled.loc != a) //not updating position
if(istype(buckled, /mob)) //If you're buckled to a mob, a la slime things, keep on rolling.
return buckled.Move(a, b)
else //Otherwise, no running around for you.
// Almost all of this handles pulling movables behind us
/mob/living/Move(atom/newloc, direct, movetime)
if(buckled && buckled.loc != newloc) //not updating position
if(!buckled.anchored && buckled.buckle_movable)
return buckled.Move(newloc, direct)
else
return 0
if (restrained())
var/atom/movable/pullee = pulling
// Prior to our move it's already too far away
if(pullee && get_dist(src, pullee) > 1)
stop_pulling()
// Shenanigans! Pullee closed into locker for eg.
if(pullee && !isturf(pullee.loc) && pullee.loc != loc)
stop_pulling()
// Can't pull with no hands
if(restrained())
stop_pulling()
// Will move our mob (probably)
. = ..() // Moved() called at this point if successful
var/t7 = 1
if (restrained())
for(var/mob/living/M in range(src, 1))
if ((M.pulling == src && M.stat == 0 && !( M.restrained() )))
t7 = null
if ((t7 && (pulling && ((get_dist(src, pulling) <= 1 || pulling.loc == loc) && (client && client.moving)))))
var/turf/T = loc
. = ..()
if(pulledby && moving_diagonally != FIRST_DIAG_STEP && get_dist(src, pulledby) > 1) //seperated from our puller and not in the middle of a diagonal move
pulledby.stop_pulling()
if (pulling && pulling.loc)
if(!( isturf(pulling.loc) ))
stop_pulling()
return
if(s_active && !(s_active in contents) && get_turf(s_active) != get_turf(src)) //check !( s_active in contents ) first so we hopefully don't have to call get_turf() so much.
s_active.close(src)
/////
if(pulling && pulling.anchored)
/mob/living/proc/dragged(var/mob/living/dragger, var/oldloc)
var/area/A = get_area(src)
if(lying && !buckled && pull_damage() && A.has_gravity && (prob(getBruteLoss() * 200 / maxHealth)))
adjustBruteLoss(2)
visible_message("<span class='danger'>\The [src]'s [isSynthetic() ? "state" : "wounds"] worsen terribly from being dragged!</span>")
/mob/living/Moved(var/atom/oldloc, direct, forced, movetime)
. = ..()
handle_footstep(loc)
if(pulling) // we were pulling a thing and didn't lose it during our move.
if(pulling.anchored || !isturf(pulling.loc))
stop_pulling()
return
if (!restrained())
var/diag = get_dir(src, pulling)
if ((diag - 1) & diag)
else
diag = null
if ((get_dist(src, pulling) > 1 || diag))
if (isliving(pulling))
var/mob/living/M = pulling
var/atom/movable/t = M.pulling
M.stop_pulling()
var/pull_dir = get_dir(src, pulling)
if(get_dist(src, pulling) > 1 || (moving_diagonally != SECOND_DIAG_STEP && ((pull_dir - 1) & pull_dir))) // puller and pullee more than one tile away or in diagonal position
// If it is too far away or across z-levels from old location, stop pulling.
if(get_dist(pulling.loc, oldloc) > 1 || pulling.loc.z != oldloc?.z)
stop_pulling()
return
if(!istype(M.loc, /turf/space))
var/area/A = get_area(M)
if(A.has_gravity)
//this is the gay blood on floor shit -- Added back -- Skie
if (M.lying && (prob(M.getBruteLoss() / 6)))
var/bloodtrail = 1 //Checks if it's possible to even spill blood
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(H.species.flags & NO_BLOOD)
bloodtrail = 0
else
var/blood_volume = round((H.vessel.get_reagent_amount("blood")/H.species.blood_volume)*100)
if(blood_volume < BLOOD_VOLUME_SURVIVE)
bloodtrail = 0 //Most of it's gone already, just leave it be
else
H.vessel.remove_reagent("blood", 1)
if(bloodtrail)
var/turf/location = M.loc
if(istype(location, /turf/simulated))
location.add_blood(M)
//pull damage with injured people
if(prob(25))
M.adjustBruteLoss(1)
visible_message("<span class='danger'>\The [M]'s [M.isSynthetic() ? "state worsens": "wounds open more"] from being dragged!</span>")
if(M.pull_damage())
if(prob(25))
M.adjustBruteLoss(2)
visible_message("<span class='danger'>\The [M]'s [M.isSynthetic() ? "state" : "wounds"] worsen terribly from being dragged!</span>")
var/turf/location = M.loc
if (istype(location, /turf/simulated))
var/bloodtrail = 1 //Checks if it's possible to even spill blood
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(H.species.flags & NO_BLOOD)
bloodtrail = 0
else
var/blood_volume = round((H.vessel.get_reagent_amount("blood")/H.species.blood_volume)*100)
if(blood_volume < BLOOD_VOLUME_SURVIVE)
bloodtrail = 0 //Most of it's gone already, just leave it be
else
H.vessel.remove_reagent("blood", 1)
if(bloodtrail)
if(istype(location, /turf/simulated))
location.add_blood(M)
// living might take damage from drags
if(isliving(pulling))
var/mob/living/M = pulling
M.dragged(src, oldloc)
if(get_dist(pulling.loc, T) > 1 || pulling.loc.z != T.z)
M.stop_pulling()
else
step(pulling, get_dir(pulling.loc, T))
if(t)
M.start_pulling(t)
else
if (pulling)
if (istype(pulling, /obj/structure/window))
var/obj/structure/window/W = pulling
if(W.is_fulltile())
for(var/obj/structure/window/win in get_step(pulling,get_dir(pulling.loc, T)))
stop_pulling()
pulling.Move(oldloc, 0, movetime) // the pullee tries to reach our previous position
if(pulling && get_dist(src, pulling) > 1) // the pullee couldn't keep up
stop_pulling()
if(get_dist(pulling.loc, T) > 1 || pulling.loc.z != T.z) // This is needed or else pulled objects can't get pushed away.
stop_pulling()
else
step(pulling, get_dir(pulling.loc, T))
else
stop_pulling()
. = ..()
if (s_active && !( s_active in contents ) && get_turf(s_active) != get_turf(src)) //check !( s_active in contents ) first so we hopefully don't have to call get_turf() so much.
s_active.close(src)
/mob/living/proc/handle_footstep(turf/T)
return FALSE
@@ -853,7 +802,7 @@ default behaviour is:
set name = "Resist"
set category = "IC"
if(!incapacitated(INCAPACITATION_KNOCKOUT) && canClick())
if(!incapacitated(INCAPACITATION_KNOCKOUT) && checkClickCooldown())
setClickCooldown(20)
resist_grab()
if(!weakened)
@@ -1239,9 +1188,7 @@ default behaviour is:
//actually throw it!
src.visible_message("<span class='warning'>[src] has thrown [item].</span>")
if(!src.lastarea)
src.lastarea = get_area(src.loc)
if((istype(src.loc, /turf/space)) || (src.lastarea.has_gravity == 0))
if((isspace(src.loc)) || (src.lastarea?.has_gravity == 0))
src.inertia_dir = get_dir(target, src)
step(src, inertia_dir)

View File

@@ -8,7 +8,10 @@
return !P.can_hit_target(src, P.permutated, src == P.original, TRUE)
return (!mover.density || !density || lying)
/mob/living/SelfMove(turf/n, direct)
/mob/CanZASPass(turf/T, is_zone)
return ATMOS_PASS_YES
/mob/living/SelfMove(turf/n, direct, movetime)
// If on walk intent, don't willingly step into hazardous tiles.
// Unless the walker is confused.
if(m_intent == "walk" && confused <= 0)

View File

@@ -909,10 +909,10 @@
set category = "IC"
set src = usr
if(world.time <= next_click) // Hard check, before anything else, to avoid crashing
if(!checkClickCooldown())
return
next_click = world.time + 1
setClickCooldown(1)
var/obj/item/W = get_active_hand()
if (W)

View File

@@ -15,17 +15,17 @@
//No longer needed, but I'll leave it here incase we plan to re-use it.
/mob/living/silicon/robot/movement_delay()
var/tally = 0 //Incase I need to add stuff other than "speed" later
. = ..()
tally = speed
. += speed
if(module_active && istype(module_active,/obj/item/borg/combat/mobility))
tally-=3
. -= 3
return tally+config.robot_delay
. += config.robot_delay
// NEW: Use power while moving.
/mob/living/silicon/robot/SelfMove(turf/n, direct)
/mob/living/silicon/robot/SelfMove(turf/n, direct, movetime)
if (!is_component_functioning("actuator"))
return 0

View File

@@ -194,7 +194,7 @@
. = ..()
to_chat(src,"<b>You are \the [src].</b> [player_msg]")
/mob/living/simple_mob/SelfMove(turf/n, direct)
/mob/living/simple_mob/SelfMove(turf/n, direct, movetime)
var/turf/old_turf = get_turf(src)
var/old_dir = dir
. = ..()
@@ -212,9 +212,9 @@
return ..()
*/
/mob/living/simple_mob/movement_delay()
var/tally = 0 //Incase I need to add stuff other than "speed" later
. = ..()
tally = movement_cooldown
. += movement_cooldown
if(force_max_speed)
return -3
@@ -223,25 +223,25 @@
if(!isnull(M.haste) && M.haste == TRUE)
return -3
if(!isnull(M.slowdown))
tally += M.slowdown
. += M.slowdown
// Turf related slowdown
var/turf/T = get_turf(src)
if(T && T.movement_cost && !hovering) // Flying mobs ignore turf-based slowdown. Aquatic mobs ignore water slowdown, and can gain bonus speed in it.
if(istype(T,/turf/simulated/floor/water) && aquatic_movement)
tally -= aquatic_movement - 1
. -= aquatic_movement - 1
else
tally += T.movement_cost
. += T.movement_cost
if(purge)//Purged creatures will move more slowly. The more time before their purge stops, the slower they'll move.
if(tally <= 0)
tally = 1
tally *= purge
if(. <= 0)
. = 1
. *= purge
if(m_intent == "walk")
tally *= 1.5
. *= 1.5
return tally+config.animal_delay
. += config.animal_delay
/mob/living/simple_mob/Stat()

View File

@@ -45,6 +45,7 @@
dead_mob_list += src
else
living_mob_list += src
lastarea = get_area(src)
update_transform() // Some mobs may start bigger or smaller than normal.
return ..()
@@ -139,7 +140,18 @@
return 0
/mob/proc/movement_delay(oldloc, direct)
return 0
. = 0
if(locate(/obj/item/weapon/grab) in src)
. += 7
// Movespeed delay based on movement mode
switch(m_intent)
if("run")
if(drowsyness > 0)
. += 6
. += config.run_speed
if("walk")
. += config.walk_speed
/mob/proc/Life()
// if(organStructure)
@@ -507,15 +519,6 @@
/mob/proc/pull_damage()
if(ishuman(src))
var/mob/living/carbon/human/H = src
if(H.health - H.halloss <= config.health_threshold_softcrit)
for(var/name in H.organs_by_name)
var/obj/item/organ/external/e = H.organs_by_name[name]
if(e && H.lying)
if((e.status & ORGAN_BROKEN && (!e.splinted || (e.splinted && e.splinted in e.contents && prob(30))) || e.status & ORGAN_BLEEDING) && (H.getBruteLoss() + H.getFireLoss() >= 100))
return 1
break
return 0
/mob/MouseDrop(mob/M as mob)
@@ -737,12 +740,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
@@ -905,7 +908,7 @@ mob/proc/yank_out_object()
set desc = "Remove an embedded item at the cost of bleeding and pain."
set src in view(1)
if(!isliving(usr) || !usr.canClick())
if(!isliving(usr) || !usr.checkClickCooldown())
return
usr.setClickCooldown(20)

View File

@@ -7,8 +7,7 @@
var/datum/mind/mind
var/stat = 0 //Whether a mob is alive or dead. TODO: Move this to living - Nodrak
var/move_delay = null // For movement speed delays.
var/next_move = null // For click delay, despite the misleading name.
var/next_move = null // world.time when mob is next allowed to self-move.
//Not in use yet
var/obj/effect/organstructure/organStructure = null

View File

@@ -231,8 +231,6 @@
return
if(state == GRAB_UPGRADING)
return
if(!assailant.canClick())
return
if(world.time < (last_action + UPGRADE_COOLDOWN))
return
if(!assailant.canmove || assailant.lying)

View File

@@ -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,201 +108,201 @@
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, "<font color='blue'>You're restrained! You can't move!</font>")
return 0
else
M.stop_pulling()
if(mob.pinned.len)
to_chat(src, "<font color='blue'>You're pinned to a wall by [mob.pinned[1]]!</font>")
// 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))
//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))
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, "<font color='blue'>You're restrained! You can't move!</font>")
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, "<font color='blue'>You're pinned to a wall by [my_mob.pinned[1]]!</font>")
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))
my_mob.setMoveCooldown(3)
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(3)
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 = my_mob.movement_delay(n, direct)
var/pre_move_loc = loc
moving = 0
// 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 = DS2NEARESTTICK(total_delay) //Rounded to the next tick in equivalent ds
my_mob.setMoveCooldown(total_delay)
. = my_mob.SelfMove(n, direct, total_delay)
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.Move(pre_move_loc, get_dir(M, pre_move_loc), total_delay) //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
//Ugly!
spawn(0) //Step
M.Move(pre_move_loc, get_dir(M, pre_move_loc), total_delay)
spawn(1) //Unstep
M.other_mobs = null
spawn(1) //Unset
my_mob.other_mobs = null
return
/mob/proc/SelfMove(turf/n, direct)
return Move(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, movetime)
return Move(n, direct, movetime)
///Process_Incorpmove
///Called by client/Move()

View File

@@ -497,8 +497,6 @@
if(!new_character)
new_character = new(T)
new_character.lastarea = get_area(T)
if(ticker.random_players)
new_character.gender = pick(MALE, FEMALE)
client.prefs.real_name = random_name(new_character.gender)