Some updates
This commit is contained in:
+18
-8
@@ -5,7 +5,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is the proc you use whenever you want to have pathfinding more complex than "try stepping towards the thing"
|
||||
* This is the proc you use whenever you want to have pathfinding more complex than "try stepping towards the thing".
|
||||
* If no path was found, returns an empty list, which is important for bots like medibots who expect an empty list rather than nothing.
|
||||
*
|
||||
* Arguments:
|
||||
* * caller: The movable atom that's trying to find the path
|
||||
@@ -15,8 +16,9 @@
|
||||
* * id: An ID card representing what access we have and what doors we can open. Its location relative to the pathing atom is irrelevant
|
||||
* * simulated_only: Whether we consider turfs without atmos simulation (AKA do we want to ignore space)
|
||||
* * 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_path_to(caller, end, max_distance = 30, mintargetdist, id=null, simulated_only = TRUE, turf/exclude)
|
||||
/proc/get_path_to(caller, end, max_distance = 30, mintargetdist, id=null, simulated_only = TRUE, turf/exclude, skip_first=TRUE)
|
||||
if(!caller || !get_turf(end))
|
||||
return
|
||||
|
||||
@@ -33,12 +35,14 @@
|
||||
SSpathfinder.mobs.found(l)
|
||||
if(!path)
|
||||
path = list()
|
||||
if(length(path) > 0 && skip_first)
|
||||
path.Cut(1,2)
|
||||
return path
|
||||
|
||||
/**
|
||||
* A helper macro to see if it's possible to step from the first turf into the second one, minding things like door access and directional windows.
|
||||
* Note that this can only be used inside the [datum/pathfind][pathfind datum] since it uses variables from said datum
|
||||
* If you really want to optimize things, optimize this, cuz this gets called a lot
|
||||
* Note that this can only be used inside the [datum/pathfind][pathfind datum] since it uses variables from said datum.
|
||||
* If you really want to optimize things, optimize this, cuz this gets called a lot.
|
||||
*/
|
||||
#define CAN_STEP(cur_turf, next) (next && !next.density && cur_turf.Adjacent(next) && !(simulated_only && SSpathfinder.space_type_cache[next.type]) && !cur_turf.LinkBlockedWithAccess(next,caller, id) && (next != avoid))
|
||||
/// Another helper macro for JPS, for telling when a node has forced neighbors that need expanding
|
||||
@@ -128,16 +132,21 @@
|
||||
src.simulated_only = simulated_only
|
||||
src.avoid = avoid
|
||||
|
||||
/// The proc you use to run the search, returns FALSE if it's invalid, an empty list if no path could be found, or a valid path to the target
|
||||
/**
|
||||
* search() is the proc you call to kick off and handle the actual pathfinding, and kills the pathfind datum instance when it's done.
|
||||
*
|
||||
* If a valid path was found, it's returned as a list. If invalid or cross-z-level params are entered, or if there's no valid path found, we
|
||||
* return null, which [/proc/get_path_to] translates to an empty list (notable for simple bots, who need empty lists)
|
||||
*/
|
||||
/datum/pathfind/proc/search()
|
||||
start = get_turf(caller)
|
||||
if(!start || !end)
|
||||
stack_trace("Invalid A* start or destination")
|
||||
return FALSE
|
||||
return
|
||||
if(start.z != end.z || start == end ) //no pathfinding between z levels
|
||||
return FALSE
|
||||
return
|
||||
if(max_distance && (max_distance < get_dist(start, end))) //if start turf is farther than max_distance from end turf, no need to do anything
|
||||
return FALSE
|
||||
return
|
||||
|
||||
//initialization
|
||||
var/datum/jps_node/current_processed_node = new (start, -1, 0, end)
|
||||
@@ -165,6 +174,7 @@
|
||||
if(path)
|
||||
for(var/i = 1 to round(0.5 * length(path)))
|
||||
path.Swap(i, length(path) - i + 1)
|
||||
|
||||
sources = null
|
||||
qdel(open)
|
||||
return path
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
return
|
||||
if(!isturf(user.loc))
|
||||
return
|
||||
if(!get_path_to(user, target, max_distance = changeling.sting_range, simulated_only = FALSE))
|
||||
return
|
||||
if(!length(get_path_to(user, target, max_distance = changeling.sting_range, simulated_only = FALSE)))
|
||||
return // no path within the sting's range is found. what a weird place to use the pathfinding system
|
||||
return 1
|
||||
|
||||
/obj/effect/proc_holder/changeling/sting/sting_feedback(mob/user, mob/target)
|
||||
|
||||
Reference in New Issue
Block a user