mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 22:19:30 +01:00
Basic mulebots. last basic bot refactor (#95899)
my watch has ended <img width="401" height="256" alt="ffffff" src="https://github.com/user-attachments/assets/a539203c-020b-4ad8-b034-f69ec0eafa78" /> ## Changelog 🆑 Profakos (originally pulled from their branch, did massive chunk of this), Ben10omintrix refactor: mulebots have been refactored. please report any bugs /🆑
This commit is contained in:
@@ -461,6 +461,94 @@
|
||||
if(length(movement_path))
|
||||
movement_path.Cut(1,2)
|
||||
else
|
||||
return handle_move_attempt_failure()
|
||||
|
||||
|
||||
/datum/move_loop/has_target/jps/proc/handle_move_attempt_failure()
|
||||
EVLOG_TEXT(moving, EVLOG_CATEGORY_MOVELOOPS, "Path recalculating due to obstruction")
|
||||
INVOKE_ASYNC(src, PROC_REF(recalculate_path))
|
||||
return MOVELOOP_FAILURE
|
||||
|
||||
/datum/move_loop/has_target/jps/frustrations
|
||||
///maximum amount of frustrations before we recalculate path
|
||||
var/maximum_frustrations
|
||||
///what is our current frustration?
|
||||
var/current_frustrations = 0
|
||||
///how long before we're able to increment frustration?
|
||||
var/frustration_delay
|
||||
///have we drawn our initial path?
|
||||
var/initial_path_drawn = FALSE
|
||||
///cooldown between frustration increments
|
||||
COOLDOWN_DECLARE(frustration_cooldown)
|
||||
|
||||
|
||||
/datum/move_manager/proc/frustrations_move(moving,
|
||||
chasing,
|
||||
delay,
|
||||
timeout,
|
||||
repath_delay,
|
||||
max_path_length,
|
||||
minimum_distance,
|
||||
list/access,
|
||||
simulated_only,
|
||||
turf/avoid,
|
||||
skip_first,
|
||||
subsystem,
|
||||
diagonal_handling,
|
||||
priority,
|
||||
flags,
|
||||
datum/extra_info,
|
||||
initial_path)
|
||||
return add_to_loop(moving,
|
||||
subsystem,
|
||||
/datum/move_loop/has_target/jps/frustrations,
|
||||
priority,
|
||||
flags,
|
||||
extra_info,
|
||||
delay,
|
||||
timeout,
|
||||
chasing,
|
||||
repath_delay,
|
||||
max_path_length,
|
||||
minimum_distance,
|
||||
access,
|
||||
simulated_only,
|
||||
avoid,
|
||||
skip_first,
|
||||
diagonal_handling,
|
||||
initial_path)
|
||||
|
||||
/datum/move_loop/has_target/jps/frustrations/setup(delay, timeout, atom/chasing, maximum_frustrations = 10, frustration_delay = 2 SECONDS)
|
||||
. = ..()
|
||||
if(!.)
|
||||
return
|
||||
src.maximum_frustrations = maximum_frustrations
|
||||
src.frustration_delay = frustration_delay
|
||||
|
||||
/datum/move_loop/has_target/jps/frustrations/recalculate_path()
|
||||
if(initial_path_drawn && current_frustrations < maximum_frustrations)
|
||||
return
|
||||
return ..()
|
||||
|
||||
/datum/move_loop/has_target/jps/frustrations/loop_stopped()
|
||||
. = ..()
|
||||
|
||||
/datum/move_loop/has_target/jps/frustrations/on_finish_pathing(list/path)
|
||||
. = ..()
|
||||
if(movement_path)
|
||||
initial_path_drawn = TRUE
|
||||
|
||||
/datum/move_loop/has_target/jps/frustrations/handle_move_attempt_failure()
|
||||
if(!initial_path_drawn)
|
||||
INVOKE_ASYNC(src, PROC_REF(recalculate_path))
|
||||
return MOVELOOP_FAILURE
|
||||
if(!COOLDOWN_FINISHED(src, frustration_cooldown))
|
||||
return NONE
|
||||
COOLDOWN_START(src, frustration_cooldown, frustration_delay)
|
||||
current_frustrations++
|
||||
SEND_SIGNAL(src, COMSIG_MOVELOOP_JPS_FRUSTRATION_INCREMENTED, current_frustrations)
|
||||
if(current_frustrations >= maximum_frustrations)
|
||||
current_frustrations = 0
|
||||
EVLOG_TEXT(moving, EVLOG_CATEGORY_MOVELOOPS, "Path recalculating due to obstruction")
|
||||
INVOKE_ASYNC(src, PROC_REF(recalculate_path))
|
||||
return MOVELOOP_FAILURE
|
||||
|
||||
Reference in New Issue
Block a user