mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-13 09:05:11 +01:00
Merge pull request #15686 from Menshin/bot_patrol_fixes
Bots patrol/summons tweaks and fixes
This commit is contained in:
@@ -408,7 +408,7 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
return 0
|
||||
var/step_count = move_speed ? move_speed : base_speed //If a value is passed into move_speed, use that instead of the default speed var.
|
||||
|
||||
if(step_count >= 1 && tries < 4)
|
||||
if(step_count >= 1 && tries < BOT_STEP_MAX_RETRIES)
|
||||
for(var/step_number = 0, step_number < step_count,step_number++)
|
||||
spawn(BOT_STEP_DELAY*step_number)
|
||||
bot_step(dest)
|
||||
@@ -424,6 +424,7 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
step_towards(src, path[1])
|
||||
if(get_turf(src) == path[1]) //Successful move
|
||||
path -= path[1]
|
||||
tries = 0
|
||||
else
|
||||
tries++
|
||||
return 0
|
||||
@@ -503,7 +504,7 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
|
||||
/mob/living/simple_animal/bot/proc/start_patrol()
|
||||
|
||||
if(tries >= 4) //Bot is trapped, so stop trying to patrol.
|
||||
if(tries >= BOT_STEP_MAX_RETRIES) //Bot is trapped, so stop trying to patrol.
|
||||
auto_patrol = 0
|
||||
tries = 0
|
||||
speak("Unable to start patrol.")
|
||||
@@ -548,33 +549,16 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
|
||||
|
||||
var/moved = bot_move(patrol_target)//step_towards(src, next) // attempt to move
|
||||
if(moved) // successful move
|
||||
blockcount = 0
|
||||
|
||||
else // failed to move
|
||||
blockcount++
|
||||
|
||||
if(blockcount > 5) // attempt 5 times before recomputing
|
||||
// find new path excluding blocked turf
|
||||
|
||||
spawn(2)
|
||||
calc_path(next)
|
||||
if(path.len == 0)
|
||||
find_patrol_target() //Start looking for the next nearest beacon
|
||||
tries++
|
||||
else
|
||||
blockcount = 0
|
||||
tries = 0
|
||||
|
||||
return
|
||||
|
||||
return
|
||||
if(!moved) //Couldn't proceed the next step of the path BOT_STEP_MAX_RETRIES times
|
||||
spawn(2)
|
||||
calc_path()
|
||||
if(path.len == 0)
|
||||
find_patrol_target()
|
||||
tries = 0
|
||||
|
||||
else // no path, so calculate new one
|
||||
mode = BOT_START_PATROL
|
||||
|
||||
return
|
||||
|
||||
// finds the nearest beacon to self
|
||||
/mob/living/simple_animal/bot/proc/find_patrol_target()
|
||||
nearest_beacon = null
|
||||
@@ -590,7 +574,7 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
|
||||
/mob/living/simple_animal/bot/proc/get_next_patrol_target()
|
||||
// search the beacon list for the next target in the list.
|
||||
for(var/obj/machinery/navbeacon/NB in navbeacons)
|
||||
for(var/obj/machinery/navbeacon/NB in navbeacons["[z]"])
|
||||
if(NB.location == next_destination) //Does the Beacon location text match the destination?
|
||||
destination = new_destination //We now know the name of where we want to go.
|
||||
patrol_target = NB.loc //Get its location and set it as the target.
|
||||
@@ -598,7 +582,7 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
return 1
|
||||
|
||||
/mob/living/simple_animal/bot/proc/find_nearest_beacon()
|
||||
for(var/obj/machinery/navbeacon/NB in navbeacons)
|
||||
for(var/obj/machinery/navbeacon/NB in navbeacons["[z]"])
|
||||
var/dist = get_dist(src, NB)
|
||||
if(nearest_beacon) //Loop though the beacon net to find the true closest beacon.
|
||||
//Ignore the beacon if were are located on it.
|
||||
@@ -665,10 +649,8 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
else
|
||||
src << "<span class='warning'>Unidentified control sequence recieved:[command]</span>"
|
||||
|
||||
/mob/living/simple_animal/bot/proc/bot_summon()
|
||||
// summoned to PDA
|
||||
/mob/living/simple_animal/bot/proc/bot_summon() // summoned to PDA
|
||||
summon_step()
|
||||
return
|
||||
|
||||
// calculates a path to the current destination
|
||||
// given an optional turf to avoid
|
||||
@@ -680,7 +662,7 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
check_bot_access()
|
||||
spawn()
|
||||
path = get_path_to(src, summon_target, /turf/proc/Distance_cardinal, 0, 150, id=access_card, exclude=avoid)
|
||||
if(!path.len || tries >= 5) //Cannot reach target. Give up and announce the issue.
|
||||
if(!path.len) //Cannot reach target. Give up and announce the issue.
|
||||
speak("Summon command failed, destination unreachable.",radio_channel)
|
||||
bot_reset()
|
||||
|
||||
@@ -700,27 +682,14 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
return
|
||||
|
||||
var/moved = bot_move(summon_target, 3) // Move attempt
|
||||
if(moved)
|
||||
blockcount = 0
|
||||
|
||||
else // failed to move
|
||||
blockcount++
|
||||
|
||||
if(blockcount > 5) // attempt 5 times before recomputing
|
||||
// find new path excluding blocked turf
|
||||
spawn(2)
|
||||
calc_summon_path(next)
|
||||
tries++
|
||||
return
|
||||
|
||||
return
|
||||
if(!moved)
|
||||
spawn(2)
|
||||
calc_summon_path()
|
||||
tries = 0
|
||||
|
||||
else // no path, so calculate new one
|
||||
calc_summon_path()
|
||||
|
||||
return
|
||||
|
||||
|
||||
/mob/living/simple_animal/bot/Bump(M as mob|obj) //Leave no door unopened!
|
||||
. = ..()
|
||||
if((istype(M, /obj/machinery/door/airlock) || istype(M, /obj/machinery/door/window)) && (!isnull(access_card)))
|
||||
|
||||
Reference in New Issue
Block a user