Merge pull request #15536 from SandPoot/JPS
Implements JPS (Jump Point Search) Pathfinding
This commit is contained in:
@@ -75,11 +75,10 @@
|
||||
/obj/structure/blob/CanAtmosPass(turf/T)
|
||||
return !atmosblock
|
||||
|
||||
/obj/structure/blob/CanAStarPass(ID, dir, caller)
|
||||
. = 0
|
||||
if(ismovable(caller))
|
||||
var/atom/movable/mover = caller
|
||||
. = . || (mover.pass_flags & PASSBLOB)
|
||||
/obj/structure/blob/CanAStarPass(obj/item/card/id/ID, to_dir, atom/movable/caller)
|
||||
. = FALSE
|
||||
if(istype(caller))
|
||||
. = . || (caller.pass_flags & PASSBLOB)
|
||||
|
||||
/obj/structure/blob/update_icon() //Updates color based on overmind color if we have an overmind.
|
||||
if(overmind)
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
return
|
||||
if(!isturf(user.loc))
|
||||
return
|
||||
if(!AStar(user, target.loc, /turf/proc/Distance, changeling.sting_range, simulated_only = 0))
|
||||
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)
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
return
|
||||
idc.access = assembly.access_card.access
|
||||
var/turf/a_loc = get_turf(assembly)
|
||||
var/list/P = cir_get_path_to(assembly, locate(get_pin_data(IC_INPUT, 1),get_pin_data(IC_INPUT, 2),a_loc.z), /turf/proc/Distance_cardinal, 0, 200, id=idc, exclude=get_turf(get_pin_data_as_type(IC_INPUT,3, /atom)), simulated_only = 0)
|
||||
var/list/P = get_path_to(assembly, locate(get_pin_data(IC_INPUT, 1),get_pin_data(IC_INPUT, 2),a_loc.z), 200, id=idc, exclude=get_turf(get_pin_data_as_type(IC_INPUT,3, /atom)), simulated_only = 0)
|
||||
|
||||
if(!P)
|
||||
activate_pin(3)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
return 0
|
||||
|
||||
if(myPath.len <= 0)
|
||||
myPath = get_path_to(src, get_turf(target), /turf/proc/Distance, MAX_RANGE_FIND + 1, 250,1)
|
||||
myPath = get_path_to(src, target, 250, 1)
|
||||
|
||||
if(myPath)
|
||||
if(myPath.len > 0)
|
||||
|
||||
@@ -551,7 +551,7 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
var/datum/job/captain/All = new/datum/job/captain
|
||||
all_access.access = All.get_access()
|
||||
|
||||
set_path(get_path_to(src, waypoint, /turf/proc/Distance_cardinal, 0, 200, id=all_access))
|
||||
set_path(get_path_to(src, waypoint, 200, id=all_access))
|
||||
calling_ai = caller //Link the AI to the bot!
|
||||
ai_waypoint = waypoint
|
||||
|
||||
@@ -730,6 +730,7 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
access_card.access = user_access + prev_access //Adds the user's access, if any.
|
||||
mode = BOT_SUMMON
|
||||
speak("Responding.", radio_channel)
|
||||
|
||||
calc_summon_path()
|
||||
|
||||
if("ejectpai")
|
||||
@@ -765,12 +766,12 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
// given an optional turf to avoid
|
||||
/mob/living/simple_animal/bot/proc/calc_path(turf/avoid)
|
||||
check_bot_access()
|
||||
set_path(get_path_to(src, patrol_target, /turf/proc/Distance_cardinal, 0, 120, id=access_card, exclude=avoid))
|
||||
set_path(get_path_to(src, patrol_target, 120, id=access_card, exclude=avoid))
|
||||
|
||||
/mob/living/simple_animal/bot/proc/calc_summon_path(turf/avoid)
|
||||
check_bot_access()
|
||||
spawn()
|
||||
set_path(get_path_to(src, summon_target, /turf/proc/Distance_cardinal, 0, 150, id=access_card, exclude=avoid))
|
||||
set_path(get_path_to(src, summon_target, 150, id=access_card, exclude=avoid))
|
||||
if(!path.len) //Cannot reach target. Give up and announce the issue.
|
||||
speak("Summon command failed, destination unreachable.",radio_channel)
|
||||
bot_reset()
|
||||
|
||||
@@ -302,7 +302,7 @@
|
||||
|
||||
if(!path || path.len == 0) //No path, need a new one
|
||||
//Try to produce a path to the target, and ignore airlocks to which it has access.
|
||||
path = get_path_to(src, target.loc, /turf/proc/Distance_cardinal, 0, 30, id=access_card)
|
||||
path = get_path_to(src, target, 30, id=access_card)
|
||||
if(!bot_move(target))
|
||||
add_to_ignore(target)
|
||||
target = null
|
||||
|
||||
@@ -223,7 +223,7 @@
|
||||
|
||||
if(target_fire && (get_dist(src, target_fire) > 2))
|
||||
|
||||
path = get_path_to(src, get_turf(target_fire), /turf/proc/Distance_cardinal, 0, 30, 1, id=access_card)
|
||||
path = get_path_to(src, target_fire, 30, 1, id=access_card)
|
||||
mode = BOT_MOVING
|
||||
if(!path.len)
|
||||
soft_reset()
|
||||
|
||||
@@ -263,9 +263,9 @@
|
||||
if(path.len == 0)
|
||||
if(!isturf(target))
|
||||
var/turf/TL = get_turf(target)
|
||||
path = get_path_to(src, TL, /turf/proc/Distance_cardinal, 0, 30, id=access_card,simulated_only = 0)
|
||||
path = get_path_to(src, TL, 30, id=access_card,simulated_only = 0)
|
||||
else
|
||||
path = get_path_to(src, target, /turf/proc/Distance_cardinal, 0, 30, id=access_card,simulated_only = 0)
|
||||
path = get_path_to(src, target, 30, id=access_card,simulated_only = 0)
|
||||
|
||||
if(!bot_move(target))
|
||||
add_to_ignore(target)
|
||||
|
||||
@@ -492,10 +492,10 @@
|
||||
return
|
||||
|
||||
if(patient && path.len == 0 && (get_dist(src,patient) > 1))
|
||||
path = get_path_to(src, get_turf(patient), /turf/proc/Distance_cardinal, 0, 30,id=access_card)
|
||||
path = get_path_to(src, patient, 30, id=access_card)
|
||||
mode = BOT_MOVING
|
||||
if(!path.len) //try to get closer if you can't reach the patient directly
|
||||
path = get_path_to(src, get_turf(patient), /turf/proc/Distance_cardinal, 0, 30,1,id=access_card)
|
||||
path = get_path_to(src, patient, 30, 1, id=access_card)
|
||||
if(!path.len) //Do not chase a patient we cannot reach.
|
||||
soft_reset()
|
||||
|
||||
|
||||
@@ -530,7 +530,7 @@
|
||||
// calculates a path to the current destination
|
||||
// given an optional turf to avoid
|
||||
/mob/living/simple_animal/bot/mulebot/calc_path(turf/avoid = null)
|
||||
path = get_path_to(src, target, /turf/proc/Distance_cardinal, 0, 250, id=access_card, exclude=avoid)
|
||||
path = get_path_to(src, target, 250, id=access_card, exclude=avoid)
|
||||
|
||||
// sets the current destination
|
||||
// signals all beacons matching the delivery code
|
||||
|
||||
@@ -655,7 +655,7 @@ GLOBAL_LIST_INIT(strippable_parrot_items, create_strippable_list(list(
|
||||
item = I
|
||||
break
|
||||
if(item)
|
||||
if(!AStar(src, get_turf(item), /turf/proc/Distance_cardinal))
|
||||
if(!get_path_to(src, item))
|
||||
item = null
|
||||
continue
|
||||
return item
|
||||
|
||||
Reference in New Issue
Block a user