Skip to content

Commit

Permalink
TGS Test Merge (#6703)
Browse files Browse the repository at this point in the history
  • Loading branch information
blubelle authored and blubelle committed Sep 3, 2024
2 parents e9c4a04 + 4090d04 commit a03b6b1
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 81 deletions.
3 changes: 2 additions & 1 deletion citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1033,9 +1033,9 @@
#include "code\game\atoms\movement.dm"
#include "code\game\atoms\say.dm"
#include "code\game\atoms\vv.dm"
#include "code\game\atoms\movable\movable-movement.dm"
#include "code\game\atoms\movable\movable-throw.dm"
#include "code\game\atoms\movable\movable.dm"
#include "code\game\atoms\movable\movement.dm"
#include "code\game\atoms\movable\pulling.dm"
#include "code\game\atoms\movable\vv.dm"
#include "code\game\atoms\movable\special\overlay.dm"
Expand Down Expand Up @@ -2202,6 +2202,7 @@
#include "code\modules\admin\view_variables\topic_list.dm"
#include "code\modules\admin\view_variables\view_variables.dm"
#include "code\modules\ai\ai_pathing.dm"
#include "code\modules\ai\ai_tracking.dm"
#include "code\modules\ai\holders\ai_holder-movement.dm"
#include "code\modules\ai\holders\ai_holder-pathfinding.dm"
#include "code\modules\ai\holders\ai_holder-scheduling.dm"
Expand Down
20 changes: 16 additions & 4 deletions code/__HELPERS/lists/string.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
/**
* Returns a list in plain english as a string.
*
* * input - (optional) list or null; if null, we use empty_text
* @params
* * input - the list to interpolate into strings
* * nothing_text - the text to emit if the list is empty
* * and_text - the text to emit on the last element instead of a comma
* * comma_text - the glue between elements
* * final_comma_text - the glue between the last two elements; usually empty for use with 'and_text'
* * limit - limit the entries processed. if the limit was reached, the last two elements will not use the usual glue text.
* * limit_text - text to append at the end if we were limited. defaults to "..."
*/
/proc/english_list(list/input, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "" )
/proc/english_list(list/input, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "", limit, limit_text = "...")
var/total = length(input)
var/limited = FALSE
if(!isnull(limit))
if(total > limit)
total = limit
limited = TRUE
if (!total)
return "[nothing_text]"
else if (total == 1)
Expand All @@ -15,13 +27,13 @@
var/output = ""
var/index = 1
while (index < total)
if (index == total - 1)
if ((index == (total - 1)) && !limited)
comma_text = final_comma_text

output += "[input[index]][comma_text]"
index++

return "[output][and_text][input[index]]"
return "[output][limited ? "" : and_text][input[index]][limited? limit_text : ""]"

/**
* Removes a string from a list.
Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystem/air.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ SUBSYSTEM_DEF(air)
var/timer
if(!resumed)
if(LAZYLEN(currentrun) != 0)
stack_trace("Currentrun not empty before processing cycle when it should be. [english_list(currentrun)]")
stack_trace("Currentrun not empty before processing cycle when it should be. [english_list(currentrun, limit = 5)]")
currentrun = list()
if(current_step != null)
stack_trace("current_step before processing cycle was [current_step] instead of null")
Expand All @@ -152,7 +152,7 @@ SUBSYSTEM_DEF(air)

// Okay, we're done! Woo! Got thru a whole SSair cycle!
if(LAZYLEN(currentrun) != 0)
stack_trace("Currentrun not empty after processing cycle when it should be. [english_list(currentrun.Copy(1, min(currentrun.len, 5)))]")
stack_trace("Currentrun not empty after processing cycle when it should be. [english_list(currentrun, limit = 5)]")
currentrun = null
if(current_step != SSAIR_DONE)
stack_trace("current_step after processing cycle was [current_step] instead of [SSAIR_DONE]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,77 +208,96 @@
if(glide_size_override)
set_glide_size(glide_size_override, FALSE)

if(loc != newloc)
if (!(direct & (direct - 1))) //Cardinal move
. = ..()
else //Diagonal move, split it into cardinal moves
moving_diagonally = FIRST_DIAG_STEP
var/first_step_dir
// The `&& moving_diagonally` checks are so that a force_move taking
// place due to a Crossed, Bumped, etc. call will interrupt
// the second half of the diagonal movement, or the second attempt
// at a first half if step() fails because we hit something.
if (direct & NORTH)
if (direct & EAST)
if (step(src, NORTH) && moving_diagonally)
first_step_dir = NORTH
moving_diagonally = SECOND_DIAG_STEP
. = step(src, EAST)
else if (moving_diagonally && step(src, EAST))
first_step_dir = EAST
moving_diagonally = SECOND_DIAG_STEP
. = step(src, NORTH)
else if (direct & WEST)
if (step(src, NORTH) && moving_diagonally)
first_step_dir = NORTH
moving_diagonally = SECOND_DIAG_STEP
. = step(src, WEST)
else if (moving_diagonally && step(src, WEST))
first_step_dir = WEST
moving_diagonally = SECOND_DIAG_STEP
. = step(src, NORTH)
else if (direct & SOUTH)
if (direct & EAST)
if (step(src, SOUTH) && moving_diagonally)
first_step_dir = SOUTH
moving_diagonally = SECOND_DIAG_STEP
. = step(src, EAST)
else if (moving_diagonally && step(src, EAST))
first_step_dir = EAST
moving_diagonally = SECOND_DIAG_STEP
. = step(src, SOUTH)
else if (direct & WEST)
if (step(src, SOUTH) && moving_diagonally)
first_step_dir = SOUTH
moving_diagonally = SECOND_DIAG_STEP
. = step(src, WEST)
else if (moving_diagonally && step(src, WEST))
first_step_dir = WEST
moving_diagonally = SECOND_DIAG_STEP
. = step(src, SOUTH)
if(moving_diagonally == SECOND_DIAG_STEP)
if(!.)
setDir(first_step_dir)
else if (!inertia_moving)
inertia_next_move = world.time + inertia_move_delay
newtonian_move(direct)
moving_diagonally = NOT_IN_DIAG_STEP
--in_move
return
else // trying to move to the same place
var/time_since_last_move = world.time - last_move
last_move = world.time

// trying to move to the same place
if(loc == newloc)
if(direct)
last_move_dir = direct
setDir(direct)
--in_move
return TRUE // not moving is technically success
ai_tracking?.track_movement(time_since_last_move, NONE)
// not moving is technically success
return TRUE

//Cardinal move
if (!(direct & (direct - 1)))
. = ..()
//Diagonal move, split it into cardinal moves
else
moving_diagonally = FIRST_DIAG_STEP
var/first_step_dir
// The `&& moving_diagonally` checks are so that a force_move taking
// place due to a Crossed, Bumped, etc. call will interrupt
// the second half of the diagonal movement, or the second attempt
// at a first half if step() fails because we hit something.
if (direct & NORTH)
if (direct & EAST)
if (step(src, NORTH) && moving_diagonally)
first_step_dir = NORTH
moving_diagonally = SECOND_DIAG_STEP
. = step(src, EAST)
else if (moving_diagonally && step(src, EAST))
first_step_dir = EAST
moving_diagonally = SECOND_DIAG_STEP
. = step(src, NORTH)
else if (direct & WEST)
if (step(src, NORTH) && moving_diagonally)
first_step_dir = NORTH
moving_diagonally = SECOND_DIAG_STEP
. = step(src, WEST)
else if (moving_diagonally && step(src, WEST))
first_step_dir = WEST
moving_diagonally = SECOND_DIAG_STEP
. = step(src, NORTH)
else if (direct & SOUTH)
if (direct & EAST)
if (step(src, SOUTH) && moving_diagonally)
first_step_dir = SOUTH
moving_diagonally = SECOND_DIAG_STEP
. = step(src, EAST)
else if (moving_diagonally && step(src, EAST))
first_step_dir = EAST
moving_diagonally = SECOND_DIAG_STEP
. = step(src, SOUTH)
else if (direct & WEST)
if (step(src, SOUTH) && moving_diagonally)
first_step_dir = SOUTH
moving_diagonally = SECOND_DIAG_STEP
. = step(src, WEST)
else if (moving_diagonally && step(src, WEST))
first_step_dir = WEST
moving_diagonally = SECOND_DIAG_STEP
. = step(src, SOUTH)
if(moving_diagonally == SECOND_DIAG_STEP)
if(!.)
setDir(first_step_dir)
else if (!inertia_moving)
inertia_next_move = world.time + inertia_move_delay
newtonian_move(direct)
moving_diagonally = NOT_IN_DIAG_STEP
--in_move
// track movement if we're no longer in a move; this way this fires only once for diag steps
if(ai_tracking && !in_move)
ai_tracking.track_movement(time_since_last_move, . ? direct : (moving_diagonally == SECOND_DIAG_STEP ? first_step_dir : NONE))
return

if(!loc || (loc == oldloc && oldloc != newloc))
last_move_dir = NONE
--in_move
return
// track movement if we're no longer in a move; this way this fires only once for diag steps
if(ai_tracking && !in_move)
ai_tracking.track_movement(time_since_last_move, NONE)
return FALSE

if(. && has_buckled_mobs() && !handle_buckled_mob_movement(loc, direct, glide_size_override)) //movement failed due to buckled mob(s)
//movement failed due to buckled mob(s)
if(. && has_buckled_mobs() && !handle_buckled_mob_movement(loc, direct, glide_size_override))
last_move_dir = NONE
--in_move
// track movement if we're no longer in a move; this way this fires only once for diag steps
if(ai_tracking && !in_move)
ai_tracking.track_movement(time_since_last_move, NONE)
return FALSE

if(.)
Expand Down Expand Up @@ -311,6 +330,10 @@

--in_move

// track movement if we're no longer in a move; this way this fires only once for diag steps
if(ai_tracking && !in_move)
ai_tracking.track_movement(time_since_last_move, direct)

// legacy
move_speed = world.time - l_move_time
l_move_time = world.time
Expand Down Expand Up @@ -579,6 +602,9 @@
/atom/movable/proc/doMove(atom/destination)
. = FALSE

// completely reset ai tracking
ai_tracking?.reset_movement()

++in_move

var/atom/oldloc = loc
Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms/movable/movable-throw.dm
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
// user momentum
var/user_speed = L.movement_delay()
// 1 decisecond of margin
if(L.last_move_dir && (L.last_move_time >= (world.time - user_speed + 1)))
if(L.last_move_dir && (L.last_self_move >= (world.time - user_speed + 1)))
user_speed = max(user_speed, world.tick_lag)
// convert to tiles per **decisecond**
user_speed = 1/user_speed
Expand Down
13 changes: 13 additions & 0 deletions code/game/atoms/movable/movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
//* AI Holders
/// AI holder bound to us
var/datum/ai_holder/ai_holder
/// AI tracking datum. Handled by procs in [code/modules/ai/ai_tracking.dm].
var/datum/ai_tracking/ai_tracking

//? Intrinsics
/// movable flags - see [code/__DEFINES/_flags/atoms.dm]
Expand All @@ -36,28 +38,39 @@
/// Set this to TRUE if we are not a [TILE_MOVER]!
var/pixel_movement = FALSE
/// Whatever we're pulling.
///
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/atom/movable/pulling
/// Who's currently pulling us
///
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/atom/movable/pulledby
/// If false makes [CanPass][/atom/proc/CanPass] call [CanPassThrough][/atom/movable/proc/CanPassThrough] on this type instead of using default behaviour
///
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/generic_canpass = TRUE
/// Pass flags.
var/pass_flags = NONE
/// movement calls we're in
///
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/in_move = 0
/// a direction, or null
///
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/moving_diagonally = NOT_IN_DIAG_STEP
/// attempt to resume grab after moving instead of before. This is what atom/movable is pulling us during move-from-pulling.
///
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/atom/movable/moving_from_pull
/// Direction of our last move.
///
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/last_move_dir = NONE
/// world.time of our last move
///
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/last_move
/// Our default glide_size. Null to use global default.
var/default_glide_size
/// Movement types, see [code/__DEFINES/flags/movement.dm]
Expand Down
2 changes: 1 addition & 1 deletion code/modules/ai/ai_pathing.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 silicons *//
//* Copyright (c) 2024 Citadel Station Developers *//

/**
* Pathfinding results.
Expand Down
Loading

0 comments on commit a03b6b1

Please sign in to comment.