Skip to content

Commit

Permalink
Merge pull request #4790 from MistakeNot4892/fixes/slipping
Browse files Browse the repository at this point in the history
Unifying space slipping, magboots and slipping checks
  • Loading branch information
out-of-phaze authored Jan 30, 2025
2 parents a295725 + 21e9345 commit a85e5dd
Show file tree
Hide file tree
Showing 62 changed files with 427 additions and 437 deletions.
1 change: 1 addition & 0 deletions code/__defines/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ The latter will result in a linter warning and will not work correctly.
#define ITEM_FLAG_PADDED BITFLAG(13) // When set on gloves, will act like pulling punches in unarmed combat.
#define ITEM_FLAG_CAN_TAPE BITFLAG(14) // Whether the item can be taped onto something using tape
#define ITEM_FLAG_IS_WEAPON BITFLAG(15) // Item is considered a weapon. Currently only used for force-based worth calculation.
#define ITEM_FLAG_MAGNETISED BITFLAG(16) // When worn on feet and standing on an appropriate spot, will prevent slipping.

// Flags for pass_flags (/atom/var/pass_flags)
#define PASS_FLAG_TABLE BITFLAG(0)
Expand Down
7 changes: 6 additions & 1 deletion code/__defines/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,9 @@
#define CRAYON_DRAW_RUNE "rune"
#define CRAYON_DRAW_GRAFFITI "graffiti"
#define CRAYON_DRAW_LETTER "letter"
#define CRAYON_DRAW_ARROW "arrow"
#define CRAYON_DRAW_ARROW "arrow"

// Enum for results of is_space_movement_permitted()
#define SPACE_MOVE_SUPPORTED (-1)
#define SPACE_MOVE_FORBIDDEN 0
#define SPACE_MOVE_PERMITTED 1
4 changes: 2 additions & 2 deletions code/_helpers/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
var/user_loc = user.loc

var/drifting = 0
if(!user.Process_Spacemove(0) && user.inertia_dir)
if(user.is_space_movement_permitted() == SPACE_MOVE_FORBIDDEN && user.inertia_dir)
drifting = 1

var/target_loc = target.loc
Expand Down Expand Up @@ -101,7 +101,7 @@
var/atom/original_loc = user.loc

var/drifting = 0
if(!user.Process_Spacemove(0) && user.inertia_dir)
if(user.is_space_movement_permitted() == SPACE_MOVE_FORBIDDEN && user.inertia_dir)
drifting = 1

var/holding = user.get_active_held_item()
Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystems/spacedrift.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ SUBSYSTEM_DEF(spacedrift)
return
continue

if (!AM.loc || AM.loc != AM.inertia_last_loc || AM.Process_Spacemove(0))
if (!AM.loc || AM.loc != AM.inertia_last_loc || AM.is_space_movement_permitted() != SPACE_MOVE_FORBIDDEN)
AM.inertia_dir = 0

AM.inertia_ignore = null

if (!AM.inertia_dir)
Expand Down
15 changes: 11 additions & 4 deletions code/datums/movement/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,28 @@
return (MOVEMENT_PROCEED|MOVEMENT_HANDLED)

/datum/movement_handler/mob/space
var/allow_move
var/last_space_move_result

// Notes on space movement chain:
// - owning mob calls MayMove() via normal movement handler chain
// - MayMove() sets last_space_move_result based on is_space_movement_permitted() (checks for footing, magboots, etc)
// - last_space_move_result is checked in DoMove() and passed to try_space_move() as a param, which returns TRUE/FALSE
// - if the original move result was forbidden, or try_space_move() fails, the handler prevents movement.
// - Otherwise it goes ahead and lets the mob move.

// Space movement
/datum/movement_handler/mob/space/DoMove(direction, mob/mover, is_external)
if(mob.has_gravity() || (IS_NOT_SELF(mover) && is_external))
return
if(!allow_move || !mob.space_do_move(allow_move, direction))
if(last_space_move_result == SPACE_MOVE_FORBIDDEN || !mob.try_space_move(last_space_move_result, direction))
return MOVEMENT_HANDLED

/datum/movement_handler/mob/space/MayMove(mob/mover, is_external)
if(IS_NOT_SELF(mover) && is_external)
return MOVEMENT_PROCEED
if(!mob.has_gravity())
allow_move = mob.Process_Spacemove(1)
if(!allow_move)
last_space_move_result = mob.is_space_movement_permitted(allow_movement = TRUE)
if(last_space_move_result == SPACE_MOVE_FORBIDDEN)
return MOVEMENT_STOP
return MOVEMENT_PROCEED

Expand Down
7 changes: 5 additions & 2 deletions code/datums/movement/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
// Use power while moving.
/datum/movement_handler/robot/use_power/DoMove(direction, mob/mover, is_external)
var/datum/robot_component/actuator/A = robot.get_component("actuator")
if(!robot.cell_use_power(A.active_usage * robot.power_efficiency))
if(!is_external && !robot.cell_use_power(A.active_usage * robot.power_efficiency))
return MOVEMENT_HANDLED
return MOVEMENT_PROCEED

/datum/movement_handler/robot/use_power/MayMove(mob/mover, is_external)
return (!robot.lockcharge && robot.is_component_functioning("actuator")) ? MOVEMENT_PROCEED : MOVEMENT_STOP
if(is_external || (!robot.incapacitated() && !robot.lockcharge && robot.is_component_functioning("actuator")))
return MOVEMENT_PROCEED
return MOVEMENT_STOP
2 changes: 1 addition & 1 deletion code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ var/global/list/mob/living/forced_ambiance_list = new
if(isspaceturf(get_turf(mob))) // Can't fall onto nothing.
return

if(mob.Check_Shoegrip())
if(!mob.can_slip(magboots_only = TRUE))
return

if(ishuman(mob))
Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1010,4 +1010,4 @@
return ATOM_IS_OPEN_CONTAINER(src) && reagents?.total_volume && user.check_has_mouth()

/atom/proc/immune_to_floor_hazards()
return !simulated
return !simulated || !has_gravity()
27 changes: 10 additions & 17 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

//call this proc to start space drifting
/atom/movable/proc/space_drift(direction)//move this down
if(!loc || direction & (UP|DOWN) || Process_Spacemove(0))
if(!loc || direction & (UP|DOWN) || is_space_movement_permitted() != SPACE_MOVE_FORBIDDEN)
inertia_dir = 0
inertia_ignore = null
return 0
Expand All @@ -59,29 +59,22 @@
return 1

//return 0 to space drift, 1 to stop, -1 for mobs to handle space slips
/atom/movable/proc/Process_Spacemove(var/allow_movement)
/atom/movable/proc/is_space_movement_permitted(allow_movement = FALSE)
if(!simulated)
return 1

return SPACE_MOVE_PERMITTED
if(has_gravity())
return 1

return SPACE_MOVE_PERMITTED
if(length(grabbed_by))
return 1

return SPACE_MOVE_PERMITTED
if(throwing)
return 1

return SPACE_MOVE_PERMITTED
if(anchored)
return 1

return SPACE_MOVE_PERMITTED
if(!isturf(loc))
return 1

return SPACE_MOVE_PERMITTED
if(locate(/obj/structure/lattice) in range(1, get_turf(src))) //Not realistic but makes pushing things in space easier
return -1

return 0
return SPACE_MOVE_SUPPORTED
return SPACE_MOVE_FORBIDDEN

/atom/movable/attack_hand(mob/user)
// Unbuckle anything buckled to us.
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/extinguisher.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
return
if(user.buckled && isobj(user.buckled))
addtimer(CALLBACK(src, PROC_REF(propel_object), user.buckled, user, get_dir(A, user)), 0)
else if(!user.check_space_footing())
else if(user.can_slip(magboots_only = TRUE))
var/old_dir = user.dir
step(user, get_dir(A, user))
user.set_dir(old_dir)
Expand Down
10 changes: 6 additions & 4 deletions code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,15 @@
L.Add(t)
return L

/turf/proc/contains_dense_objects()
/turf/proc/contains_dense_objects(list/exceptions)
if(density)
return 1
return TRUE
for(var/atom/A in src)
if(exceptions && (exceptions == A || (islist(exceptions) && (A in exceptions))))
continue
if(A.density && !(A.atom_flags & ATOM_FLAG_CHECKS_BORDER))
return 1
return 0
return TRUE
return FALSE

/turf/proc/remove_cleanables()
for(var/obj/effect/decal/cleanable/cleanable in src)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@

/turf/unsimulated/get_lumcount(var/minlum = 0, var/maxlum = 1)
return 0.8

// For the purposes of spacemove/spacedrift.
/turf/unsimulated/is_floor()
return !density
/turf/unsimulated/is_wall()
return !is_floor()
3 changes: 0 additions & 3 deletions code/game/turfs/unsimulated/floor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
/turf/unsimulated/floor/rescue_base
icon_state = "asteroidfloor"

/turf/unsimulated/floor/shuttle_ceiling
icon_state = "reinforced"

/turf/unsimulated/floor/snow
name = "snow"
icon = 'icons/turf/flooring/snow.dmi'
Expand Down
11 changes: 2 additions & 9 deletions code/modules/ZAS/Airflow.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Contains helper procs for airflow, called by /connection_group.
return FALSE

/mob/living/human/handle_airflow_stun()
if(!slip_chance())
if(!get_eva_slip_prob())
to_chat(src, SPAN_NOTICE("Air suddenly rushes past you!"))
return FALSE
. = ..()
Expand Down Expand Up @@ -91,14 +91,7 @@ Contains helper procs for airflow, called by /connection_group.
return 1

/mob/AirflowCanMove(n)
if(status_flags & GODMODE)
return 0
if(buckled)
return 0
var/obj/item/shoes = get_equipped_item(slot_shoes_str)
if(istype(shoes) && (shoes.item_flags & ITEM_FLAG_NOSLIP))
return 0
return 1
return can_slip(magboots_only = TRUE)

/atom/movable/Bump(atom/A)
if(airflow_speed > 0 && airflow_dest)
Expand Down
5 changes: 3 additions & 2 deletions code/modules/clothing/shoes/magboots.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//Note that despite the use of the NOSLIP flag, magboots are still hardcoded to prevent spaceslipping in Check_Shoegrip().
/obj/item/clothing/shoes/magboots
name = "magboots"
desc = "Magnetic boots, often used during extravehicular activity to ensure the user remains safely attached to the vehicle. They're large enough to be worn over other footwear."
Expand Down Expand Up @@ -31,12 +30,14 @@
/obj/item/clothing/shoes/magboots/attack_self(mob/user)
if(magpulse)
item_flags &= ~ITEM_FLAG_NOSLIP
item_flags &= ~ITEM_FLAG_MAGNETISED
magpulse = 0
set_slowdown()
set_base_attack_force(3)
to_chat(user, "You disable the mag-pulse traction system.")
else
item_flags |= ITEM_FLAG_NOSLIP
item_flags |= ITEM_FLAG_MAGNETISED
magpulse = 1
set_slowdown()
set_base_attack_force(5)
Expand Down Expand Up @@ -115,6 +116,6 @@
/obj/item/clothing/shoes/magboots/examine(mob/user)
. = ..()
var/state = "disabled"
if(item_flags & ITEM_FLAG_NOSLIP)
if(item_flags & ITEM_FLAG_MAGNETISED)
state = "enabled"
to_chat(user, "Its mag-pulse traction system appears to be [state].")
2 changes: 1 addition & 1 deletion code/modules/clothing/spacesuits/rig/suits/light.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
icon = 'icons/clothing/rigs/chests/chest_hacker.dmi'
/obj/item/clothing/shoes/lightrig/hacker
siemens_coefficient = 0.2
item_flags = ITEM_FLAG_NOSLIP //All the other rigs have magboots anyways, hopefully gives the hacker suit something more going for it.
item_flags = ITEM_FLAG_NOSLIP | ITEM_FLAG_MAGNETISED //All the other rigs have magboots anyways, hopefully gives the hacker suit something more going for it.
icon = 'icons/clothing/rigs/boots/boots_hacker.dmi'
/obj/item/clothing/gloves/lightrig/hacker
siemens_coefficient = 0
Expand Down
2 changes: 1 addition & 1 deletion code/modules/economy/worth_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
additional_value += (25 * total_coverage)

if(item_flags)
for(var/flag in list(ITEM_FLAG_PADDED, ITEM_FLAG_NOSLIP, ITEM_FLAG_BLOCK_GAS_SMOKE_EFFECT, ITEM_FLAG_SILENT, ITEM_FLAG_NOCUFFS))
for(var/flag in list(ITEM_FLAG_PADDED, ITEM_FLAG_NOSLIP, ITEM_FLAG_MAGNETISED, ITEM_FLAG_BLOCK_GAS_SMOKE_EFFECT, ITEM_FLAG_SILENT, ITEM_FLAG_NOCUFFS))
if(item_flags & flag)
additional_value += 15

Expand Down
5 changes: 2 additions & 3 deletions code/modules/hydroponics/grown.dm
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,10 @@
return

var/mob/living/M = AM
if(M.buckled || MOVING_DELIBERATELY(M))
if(MOVING_DELIBERATELY(M))
return

var/obj/item/shoes = M.get_equipped_item(slot_shoes_str)
if(shoes && shoes.item_flags & ITEM_FLAG_NOSLIP)
if(!M.can_slip() || M.immune_to_floor_hazards())
return

to_chat(M, SPAN_DANGER("You slipped on \the [src]!"))
Expand Down
3 changes: 1 addition & 2 deletions code/modules/hydroponics/spreading/spreading_response.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@
if(H.species.species_flags & SPECIES_FLAG_NO_TANGLE)
return

var/obj/item/clothing/shoes/magboots/magboots = H.get_equipped_item(slot_shoes_str)
if(victim.loc != loc && istype(magboots) && (magboots.item_flags & ITEM_FLAG_NOSLIP) || H.species.check_no_slip(H))
if(victim.loc != loc && victim.can_slip())
visible_message("<span class='danger'>Tendrils lash to drag \the [victim] but \the [src] can't pull them across the ground!</span>")
return

Expand Down
15 changes: 6 additions & 9 deletions code/modules/mechs/equipment/utility.dm
Original file line number Diff line number Diff line change
Expand Up @@ -603,17 +603,14 @@
QDEL_NULL(ion_trail)
return ..()

/obj/item/mech_equipment/ionjets/proc/allowSpaceMove()
if (!active)
/obj/item/mech_equipment/ionjets/proc/provides_thrust()
if(!active)
return FALSE

var/obj/item/cell/C = owner.get_cell()
if (istype(C))
if (C.checked_use(movement_power * CELLRATE))
var/obj/item/cell/cell = owner?.get_cell()
if(istype(cell))
if(cell.checked_use(movement_power * CELLRATE))
return TRUE
else
deactivate()

deactivate()
return FALSE

/obj/item/mech_equipment/ionjets/attack_self(mob/user)
Expand Down
Loading

0 comments on commit a85e5dd

Please sign in to comment.