Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PORT] 'Mobs will not path into dangerous turfs.' from TG (PR#79428) #588

Merged
merged 2 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions code/_globalvars/lists/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ GLOBAL_LIST_EMPTY(deadmins) //all ckeys who have used the de-admin verb.
GLOBAL_LIST_EMPTY(directory) //all ckeys with associated client
GLOBAL_LIST_EMPTY(stealthminID) //reference list with IDs that store ckeys, for stealthmins

GLOBAL_LIST_INIT(dangerous_turfs, typecacheof(list(
/turf/open/lava,
/turf/open/chasm,
/turf/open/space,
/turf/open/openspace)))


//Since it didn't really belong in any other category, I'm putting this here
//This is for procs to replace all the goddamn 'in world's that are chilling around the code

Expand Down
6 changes: 4 additions & 2 deletions code/datums/ai/idle_behaviors/idle_random_walk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@

if(DT_PROB(walk_chance, delta_time) && (living_pawn.mobility_flags & MOBILITY_MOVE) && isturf(living_pawn.loc) && !living_pawn.pulledby)
var/move_dir = pick(GLOB.alldirs)
living_pawn.Move(get_step(living_pawn, move_dir), move_dir)

var/turf/destination_turf = get_step(living_pawn, move_dir)
if(!destination_turf?.can_cross_safely(living_pawn))
return
living_pawn.Move(destination_turf, move_dir)
4 changes: 2 additions & 2 deletions code/datums/ai/movement/ai_movement_basic_avoidance.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
. = ..()
var/turf/target_turf = get_step_towards(source.moving, source.target)

if(is_type_in_typecache(target_turf, GLOB.dangerous_turfs))
. = FALSE
if(!target_turf?.can_cross_safely(source.moving))
. = MOVELOOP_SKIP_STEP
return .
4 changes: 2 additions & 2 deletions code/datums/ai/movement/ai_movement_dumb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
. = ..()
var/turf/target_turf = get_step_towards(source.moving, source.target)

if(is_type_in_typecache(target_turf, GLOB.dangerous_turfs))
. = FALSE
if(!target_turf?.can_cross_safely(source.moving))
. = MOVELOOP_SKIP_STEP
return .
3 changes: 3 additions & 0 deletions code/game/turfs/open/chasm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
else if(istype(C, /obj/item/stack/tile/iron))
build_with_floor_tiles(C, user)

/turf/open/chasm/can_cross_safely(atom/movable/crossing)
return HAS_TRAIT(crossing, TRAIT_MOVE_FLYING)

// Chasms for Lavaland, with planetary atmos and lava glow
/turf/open/chasm/lavaland
initial_gas = PLANETARY_ATMOS
Expand Down
3 changes: 3 additions & 0 deletions code/game/turfs/open/lava.dm
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@
burn_living.adjust_fire_stacks(lava_firestacks * delta_time)
burn_living.ignite_mob()

/turf/open/lava/can_cross_safely(atom/movable/crossing)
return HAS_TRAIT(crossing, immunity_trait) || HAS_TRAIT(crossing, TRAIT_MOVE_FLYING)

/turf/open/lava/smooth
name = "lava"
baseturfs = /turf/open/lava/smooth
Expand Down
3 changes: 3 additions & 0 deletions code/game/turfs/open/openspace.dm
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ GLOBAL_DATUM_INIT(openspace_backdrop_one_for_all, /atom/movable/openspace_backdr
return TRUE
return FALSE

/turf/open/openspace/can_cross_safely(atom/movable/crossing)
return HAS_TRAIT(crossing, TRAIT_MOVE_FLYING)

/turf/open/openspace/icemoon
name = "ice chasm"
baseturfs = /turf/open/openspace/icemoon
Expand Down
3 changes: 3 additions & 0 deletions code/game/turfs/open/space/space.dm
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@
destination_y = dest_y
destination_z = dest_z

/turf/open/space/can_cross_safely(atom/movable/crossing)
return HAS_TRAIT(crossing, TRAIT_SPACEWALK)

/turf/open/space/openspace
icon = 'icons/turf/floors.dmi'
icon_state = "invisible"
Expand Down
5 changes: 4 additions & 1 deletion code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ GLOBAL_LIST_EMPTY(station_turfs)

var/lighting_uses_jen = FALSE


///Which directions does this turf block the vision of, taking into account both the turf's opacity and the movable opacity_sources.
var/directional_opacity = NONE
///Lazylist of movable atoms providing opacity sources.
Expand Down Expand Up @@ -710,3 +709,7 @@ GLOBAL_LIST_EMPTY(station_turfs)

/turf/proc/TakeTemperature(temp)
temperature += temp

/// Returns whether it is safe for an atom to move across this turf
/turf/proc/can_cross_safely(atom/movable/crossing)
return TRUE
Loading