Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoonij authored Dec 23, 2024
1 parent 35c53e3 commit 793b2ce
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 49 deletions.
26 changes: 13 additions & 13 deletions code/__HELPERS/paths/path.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* It will yield until a path is returned, using magic
*
* Arguments:
* * caller: The movable atom that's trying to find the path
* * requester: The movable atom that's trying to find the path
* * end: What we're trying to path to. It doesn't matter if this is a turf or some other atom, we're gonna just path to the turf it's on anyway
* * max_distance: The maximum number of steps we can take in a given path to search (default: 30, 0 = infinite)
* * mintargetdistance: Minimum distance to the target before path returns, could be used to get near a target, but not right to it - for an AI mob with a gun, for example.
Expand All @@ -14,16 +14,16 @@
* * skip_first: Whether or not to delete the first item in the path. This would be done because the first item is the starting tile, which can break movement for some creatures.
* * diagonal_handling: defines how we handle diagonal moves. see __DEFINES/path.dm
*/
/proc/get_path_to(atom/movable/caller, atom/end, max_distance = 30, mintargetdist, access=list(), simulated_only = TRUE, turf/exclude, skip_first = TRUE, diagonal_handling = DIAGONAL_REMOVE_CLUNKY)
/proc/get_path_to(atom/movable/requester, atom/end, max_distance = 30, mintargetdist, access=list(), simulated_only = TRUE, turf/exclude, skip_first = TRUE, diagonal_handling = DIAGONAL_REMOVE_CLUNKY)
var/list/hand_around = list()
// We're guarenteed that list will be the first list in pathfinding_finished's argset because of how callback handles the arguments list
var/datum/callback/await = list(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(pathfinding_finished), hand_around))
if(!SSpathfinder.pathfind(caller, end, max_distance, mintargetdist, access, simulated_only, exclude, skip_first, diagonal_handling, await))
if(!SSpathfinder.pathfind(requester, end, max_distance, mintargetdist, access, simulated_only, exclude, skip_first, diagonal_handling, await))
return list()

UNTIL(length(hand_around))
var/list/return_val = hand_around[1]
if(!islist(return_val) || (QDELETED(caller) || QDELETED(end))) // It's trash, just hand back empty to make it easy
if(!islist(return_val) || (QDELETED(requester) || QDELETED(end))) // It's trash, just hand back empty to make it easy
return list()
return return_val

Expand All @@ -38,7 +38,7 @@
* It will yield until a path is returned, using magic
*
* Arguments:
* * caller: The movable atom that's trying to find the path
* * requester: The movable atom that's trying to find the path
* * end: What we're trying to path to. It doesn't matter if this is a turf or some other atom, we're gonna just path to the turf it's on anyway
* * max_distance: The maximum number of steps we can take in a given path to search (default: 30, 0 = infinite)
* * mintargetdistance: Minimum distance to the target before path returns, could be used to get near a target, but not right to it - for an AI mob with a gun, for example.
Expand All @@ -48,30 +48,30 @@
* * exclude: If we want to avoid a specific turf, like if we're a mulebot who already got blocked by some turf
* * skip_first: Whether or not to delete the first item in the path. This would be done because the first item is the starting tile, which can break movement for some creatures.
*/
/proc/get_swarm_path_to(atom/movable/caller, atom/end, max_distance = 30, mintargetdist, age = MAP_REUSE_INSTANT, access = list(), simulated_only = TRUE, turf/exclude, skip_first = TRUE)
/proc/get_swarm_path_to(atom/movable/requester, atom/end, max_distance = 30, mintargetdist, age = MAP_REUSE_INSTANT, access = list(), simulated_only = TRUE, turf/exclude, skip_first = TRUE)
var/list/hand_around = list()
// We're guarenteed that list will be the first list in pathfinding_finished's argset because of how callback handles the arguments list
var/datum/callback/await = list(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(pathfinding_finished), hand_around))
if(!SSpathfinder.swarmed_pathfind(caller, end, max_distance, mintargetdist, age, access, simulated_only, exclude, skip_first, await))
if(!SSpathfinder.swarmed_pathfind(requester, end, max_distance, mintargetdist, age, access, simulated_only, exclude, skip_first, await))
return list()

UNTIL(length(hand_around))
var/list/return_val = hand_around[1]
if(!islist(return_val) || (QDELETED(caller) || QDELETED(end))) // It's trash, just hand back empty to make it easy
if(!islist(return_val) || (QDELETED(requester) || QDELETED(end))) // It's trash, just hand back empty to make it easy
return list()
return return_val


/proc/get_sssp(atom/movable/caller, max_distance = 30, access = list(), simulated_only = TRUE, turf/exclude)
/proc/get_sssp(atom/movable/requester, max_distance = 30, access = list(), simulated_only = TRUE, turf/exclude)
var/list/hand_around = list()
// We're guarenteed that list will be the first list in pathfinding_finished's argset because of how callback handles the arguments list
var/datum/callback/await = list(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(pathfinding_finished), hand_around))
if(!SSpathfinder.build_map(caller, get_turf(caller), max_distance, access, simulated_only, exclude, await))
if(!SSpathfinder.build_map(requester, get_turf(requester), max_distance, access, simulated_only, exclude, await))
return null

UNTIL(length(hand_around))
var/datum/path_map/return_val = hand_around[1]
if(!istype(return_val, /datum/path_map) || (QDELETED(caller))) // It's trash, just hand back null to make it easy
if(!istype(return_val, /datum/path_map) || (QDELETED(requester))) // It's trash, just hand back null to make it easy
return null
return return_val

Expand Down Expand Up @@ -215,7 +215,7 @@


/**
* For seeing if we can actually move between 2 given turfs while accounting for our access and the caller's pass_flags
* For seeing if we can actually move between 2 given turfs while accounting for our access and the requester's pass_flags
*
* Assumes destinantion turf is non-dense - check and shortcircuit in code invoking this proc to avoid overhead.
* Makes some other assumptions, such as assuming that unless declared, non dense objects will not block movement.
Expand Down Expand Up @@ -323,7 +323,7 @@
/// Pass information for the object we are pulling, if any
var/datum/can_pass_info/pulling_info = null

/// Weakref to the caller used to generate this info
/// Weakref to the requester used to generate this info
/// Should not use this almost ever, it's for context and to allow for proc chains that
/// Require a movable
var/datum/weakref/caller_ref = null
Expand Down
4 changes: 2 additions & 2 deletions code/__HELPERS/paths/sssp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@
var/working_index


/datum/pathfind/sssp/proc/setup(atom/movable/caller, list/access, turf/center, max_distance, simulated_only, turf/avoid, list/datum/callback/on_finish)
src.pass_info = new(caller, access)
/datum/pathfind/sssp/proc/setup(atom/movable/requester, list/access, turf/center, max_distance, simulated_only, turf/avoid, list/datum/callback/on_finish)
src.pass_info = new(requester, access)
src.start = center
src.max_distance = max_distance
src.simulated_only = simulated_only
Expand Down
22 changes: 11 additions & 11 deletions code/controllers/subsystem/pathfinder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ SUBSYSTEM_DEF(pathfinder)


/// Initiates a pathfind. Returns true if we're good, FALSE if something's failed
/datum/controller/subsystem/pathfinder/proc/pathfind(atom/movable/caller, atom/end, max_distance = 30, mintargetdist, access = list(), simulated_only = TRUE, turf/exclude, skip_first = TRUE, diagonal_handling = DIAGONAL_REMOVE_CLUNKY, list/datum/callback/on_finish)
/datum/controller/subsystem/pathfinder/proc/pathfind(atom/movable/requester, atom/end, max_distance = 30, mintargetdist, access = list(), simulated_only = TRUE, turf/exclude, skip_first = TRUE, diagonal_handling = DIAGONAL_REMOVE_CLUNKY, list/datum/callback/on_finish)
var/datum/pathfind/jps/path = new()
path.setup(caller, access, max_distance, simulated_only, exclude, on_finish, end, mintargetdist, skip_first, diagonal_handling)
path.setup(requester, access, max_distance, simulated_only, exclude, on_finish, end, mintargetdist, skip_first, diagonal_handling)
if(path.start())
active_pathing += path
return TRUE
Expand All @@ -75,21 +75,21 @@ SUBSYSTEM_DEF(pathfinder)

/// Initiates a swarmed pathfind. Returns TRUE if we're good, FALSE if something's failed
/// If a valid pathmap exists for the TARGET turf we'll use that, otherwise we have to build a new one
/datum/controller/subsystem/pathfinder/proc/swarmed_pathfind(atom/movable/caller, atom/end, max_distance = 30, mintargetdist = 0, age = MAP_REUSE_INSTANT, access = list(), simulated_only = TRUE, turf/exclude, skip_first = TRUE, list/datum/callback/on_finish)
/datum/controller/subsystem/pathfinder/proc/swarmed_pathfind(atom/movable/requester, atom/end, max_distance = 30, mintargetdist = 0, age = MAP_REUSE_INSTANT, access = list(), simulated_only = TRUE, turf/exclude, skip_first = TRUE, list/datum/callback/on_finish)
var/turf/target = get_turf(end)
var/datum/can_pass_info/pass_info = new(caller, access)
var/datum/can_pass_info/pass_info = new(requester, access)
// If there's a map we can use already, use it
var/datum/path_map/valid_map = get_valid_map(pass_info, target, simulated_only, exclude, age, include_building = TRUE)
if(valid_map && valid_map.expand(max_distance))
path_map_passalong(on_finish, get_turf(caller), mintargetdist, skip_first, valid_map)
path_map_passalong(on_finish, get_turf(requester), mintargetdist, skip_first, valid_map)
return TRUE

// Otherwise we're gonna make a new one, and turn it into a path for the callbacks passed into us
var/list/datum/callback/pass_in = list()
pass_in += CALLBACK(GLOBAL_PROC, /proc/path_map_passalong, on_finish, get_turf(caller), mintargetdist, skip_first)
pass_in += CALLBACK(GLOBAL_PROC, /proc/path_map_passalong, on_finish, get_turf(requester), mintargetdist, skip_first)
// And to allow subsequent calls to reuse the same map, we'll put a placeholder in the cache, and fill it up when the pathing finishes
var/datum/path_map/empty = new()
empty.pass_info = new(caller, access)
empty.pass_info = new(requester, access)
empty.start = target
empty.pass_space = simulated_only
empty.avoid = exclude
Expand Down Expand Up @@ -141,9 +141,9 @@ SUBSYSTEM_DEF(pathfinder)


/// Initiates a SSSP run. Returns true if we're good, FALSE if something's failed
/datum/controller/subsystem/pathfinder/proc/build_map(atom/movable/caller, turf/source, max_distance = 30, access = list(), simulated_only = TRUE, turf/exclude, list/datum/callback/on_finish)
/datum/controller/subsystem/pathfinder/proc/build_map(atom/movable/requester, turf/source, max_distance = 30, access = list(), simulated_only = TRUE, turf/exclude, list/datum/callback/on_finish)
var/datum/pathfind/sssp/path = new()
path.setup(caller, access, source, max_distance, simulated_only, exclude, on_finish)
path.setup(requester, access, source, max_distance, simulated_only, exclude, on_finish)
if(path.start())
active_pathing += path
return TRUE
Expand Down Expand Up @@ -171,7 +171,7 @@ SUBSYSTEM_DEF(pathfinder)
/// Optionally takes a max age to accept (defaults to 0 seconds) and a minimum acceptable range
/// If include_building is true and we can only find a building path, we'll use that instead. tho we will wait for it to finish first
/datum/controller/subsystem/pathfinder/proc/get_valid_map(datum/can_pass_info/pass_info, turf/target, simulated_only = TRUE, turf/exclude, age = MAP_REUSE_INSTANT, min_range = -INFINITY, include_building = FALSE)
// Walk all the maps that match our caller's turf OR our target's
// Walk all the maps that match our requester's turf OR our target's
// Then hold onto em. If their cache time is short we can reuse/expand them, if not we'll have to make a new one
var/oldest_time = world.time - age
/// Backup return value used if no finished pathmaps are found
Expand Down Expand Up @@ -201,7 +201,7 @@ SUBSYSTEM_DEF(pathfinder)
/// Takes a set of pathfind info, returns all valid pathmaps that would work
/// Takes an optional minimum range arg
/datum/controller/subsystem/pathfinder/proc/get_valid_maps(datum/can_pass_info/pass_info, turf/target, simulated_only = TRUE, turf/exclude, age = MAP_REUSE_INSTANT, min_range = -INFINITY, include_building = FALSE)
// Walk all the maps that match our caller's turf OR our target's
// Walk all the maps that match our requester's turf OR our target's
// Then hold onto em. If their cache time is short we can reuse/expand them, if not we'll have to make a new one
var/list/valid_maps = list()
var/oldest_time = world.time - age
Expand Down
8 changes: 4 additions & 4 deletions code/datums/holocall.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

var/call_start_time

//creates a holocall made by `caller` from `calling_pad` to `callees`
/datum/holocall/New(mob/living/caller, obj/machinery/hologram/holopad/calling_pad, list/callees)
//creates a holocall made by `requester` from `calling_pad` to `callees`
/datum/holocall/New(mob/living/requester, obj/machinery/hologram/holopad/calling_pad, list/callees)
call_start_time = world.time
user = caller
user = requester
calling_pad.outgoing_call = src
calling_holopad = calling_pad
dialed_holopads = list()
Expand All @@ -34,7 +34,7 @@
dialed_holopads += H
var/area/area = get_area(H)
LAZYADD(H.holo_calls, src)
H.atom_say("[area] голопад звонит: входящий вызов от [caller]!")
H.atom_say("[area] голопад звонит: входящий вызов от [requester]!")

if(!dialed_holopads.len)
calling_holopad.atom_say("Сбой соединения.")
Expand Down
4 changes: 2 additions & 2 deletions code/game/gamemodes/malfunction/Malf_Modules.dm
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
enable_text = "<span class='notice'>You tap into the station's powernet. Click on a machine to detonate it, or use the ability again to cancel.</span>"
disable_text = "<span class='notice'>You release your hold on the powernet.</span>"

/obj/effect/proc_holder/ranged_ai/overload_machine/InterceptClickOn(mob/living/caller, params, obj/machinery/target)
/obj/effect/proc_holder/ranged_ai/overload_machine/InterceptClickOn(mob/living/requester, params, obj/machinery/target)
if(..())
return
if(ranged_ability_user.incapacitated())
Expand Down Expand Up @@ -542,7 +542,7 @@
enable_text = "<span class='notice'>You tap into the station's powernet. Click on a machine to animate it, or use the ability again to cancel.</span>"
disable_text = "<span class='notice'>You release your hold on the powernet.</span>"

/obj/effect/proc_holder/ranged_ai/override_machine/InterceptClickOn(mob/living/caller, params, obj/machinery/target)
/obj/effect/proc_holder/ranged_ai/override_machine/InterceptClickOn(mob/living/requester, params, obj/machinery/target)
if(..())
return
if(ranged_ability_user.incapacitated())
Expand Down
6 changes: 3 additions & 3 deletions code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -712,16 +712,16 @@
* Returns adjacent turfs to this turf that are reachable, in all cardinal directions
*
* Arguments:
* * caller: The movable, if one exists, being used for mobility checks to see what tiles it can reach
* * requester: The movable, if one exists, being used for mobility checks to see what tiles it can reach
* * access: A list that decides if we can gain access to doors that would otherwise block a turf
* * simulated_only: Do we only worry about turfs with simulated atmos, most notably things that aren't space?
* * no_id: When true, doors with public access will count as impassible
*/
/turf/proc/reachableAdjacentTurfs(atom/movable/caller, list/access, simulated_only, no_id = FALSE)
/turf/proc/reachableAdjacentTurfs(atom/movable/requester, list/access, simulated_only, no_id = FALSE)
var/static/space_type_cache = typecacheof(/turf/space)
. = list()

var/datum/can_pass_info/pass_info = new(caller, access, no_id)
var/datum/can_pass_info/pass_info = new(requester, access, no_id)
for(var/iter_dir in GLOB.cardinal)
var/turf/turf_to_check = get_step(src, iter_dir)
if(!turf_to_check || (simulated_only && space_type_cache[turf_to_check.type]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
* Returns whether the extraction process can be started.
*
* Arguments:
* * caller - The person trying to call the extraction.
* * requester - The person trying to call the extraction.
*/
/datum/objective/contract/proc/can_start_extraction_process(mob/living/carbon/human/caller)
return get_area(caller) == extraction_zone && get_area(target.current) == extraction_zone
/datum/objective/contract/proc/can_start_extraction_process(mob/living/carbon/human/requester)
return get_area(requester) == extraction_zone && get_area(target.current) == extraction_zone
8 changes: 4 additions & 4 deletions code/modules/mob/living/simple_animal/bot/bot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,8 @@ Pass the desired type path itself, declaring a temporary var beforehand is not r
access_card.access = prev_access


/mob/living/simple_animal/bot/proc/call_bot(caller, turf/waypoint, message = TRUE)
if(isAI(caller) && calling_ai && calling_ai != src) //Prevents an override if another AI is controlling this bot.
/mob/living/simple_animal/bot/proc/call_bot(requester, turf/waypoint, message = TRUE)
if(isAI(requester) && calling_ai && calling_ai != src) //Prevents an override if another AI is controlling this bot.
return FALSE

bot_reset() //Reset a bot before setting it to call mode.
Expand All @@ -694,7 +694,7 @@ Pass the desired type path itself, declaring a temporary var beforehand is not r
all_access.access = get_all_accesses()

set_path(get_path_to(src, waypoint, max_distance = 200, access = all_access.GetAccess()))
calling_ai = caller //Link the AI to the bot!
calling_ai = requester //Link the AI to the bot!
ai_waypoint = waypoint

if(path && length(path)) //Ensures that a valid path is calculated!
Expand All @@ -704,7 +704,7 @@ Pass the desired type path itself, declaring a temporary var beforehand is not r
access_card.access = all_access.GetAccess() //Give the bot all-access while under the AI's command.
if(client)
reset_access_timer_id = addtimer(CALLBACK(src, PROC_REF(bot_reset)), 60 SECONDS, TIMER_UNIQUE|TIMER_OVERRIDE|TIMER_STOPPABLE) //if the bot is player controlled, they get the extra access for a limited time
to_chat(src, span_notice("[span_big("Приоритетный маршрут установлен [calling_ai] <b>[caller]</b>. Проследуйте в локацию <b>[end_area.name]</b>.")]<br>[path.len-1]</br> метров до точки назначения. Вам выдан неограниченный доступ к шлюзам на следующие 60 секунд."))
to_chat(src, span_notice("[span_big("Приоритетный маршрут установлен [calling_ai] <b>[requester]</b>. Проследуйте в локацию <b>[end_area.name]</b>.")]<br>[path.len-1]</br> метров до точки назначения. Вам выдан неограниченный доступ к шлюзам на следующие 60 секунд."))
if(message)
to_chat(calling_ai, span_notice("[bicon(src)] [capitalize(declent_ru(NOMINATIVE))] вызван в локацию [end_area.name]. [length(path)-1] метров до точки назначения."))
pathset = TRUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,17 @@
if(!istype(get_area(src), /area/shuttle)) //I'll be funny and make non teleported enrage mobs not lose enrage. Harder to pull off, and also funny when it happens accidently. Or if one gets on the escape shuttle.
unrage()

/mob/living/simple_animal/hostile/megafauna/onShuttleMove(turf/oldT, turf/T1, rotation, mob/caller)
/mob/living/simple_animal/hostile/megafauna/onShuttleMove(turf/oldT, turf/T1, rotation, mob/requester)
var/turf/oldloc = loc
. = ..()

if(!.)
return

var/turf/newloc = loc
mob_attack_logs += "[time_stamp()] Moved via shuttle from [COORD(oldloc)] to [COORD(newloc)] caller: [caller ? "[caller]" : "unknown" ]"
message_admins("Megafauna[stat == DEAD ? "(DEAD)" : null] [src] ([ADMIN_FLW(src,"FLW")]) moved via shuttle from [ADMIN_COORDJMP(oldloc)] to [ADMIN_COORDJMP(newloc)][caller ? " called by [ADMIN_LOOKUPFLW(caller)]" : ""]")

mob_attack_logs += "[time_stamp()] Moved via shuttle from [COORD(oldloc)] to [COORD(newloc)] requester: [requester ? "[requester]" : "unknown" ]"
message_admins("Megafauna[stat == DEAD ? "(DEAD)" : null] [src] ([ADMIN_FLW(src,"FLW")]) moved via shuttle from [ADMIN_COORDJMP(oldloc)] to [ADMIN_COORDJMP(newloc)][requester ? " called by [ADMIN_LOOKUPFLW(requester)]" : ""]")

/mob/living/simple_animal/hostile/megafauna/proc/devour(mob/living/L)
if(!L)
Expand Down
Loading

0 comments on commit 793b2ce

Please sign in to comment.