Files
Bubberstation/code/datums/ai/movement/ai_movement_basic_avoidance.dm
MrMelbert 72491a5e41 Fix monkeys ignoring grabs while restrained/in crit (#88041)
## About The Pull Request

Fixes #84338

When handcuffed or crit, you are unable to resist even a passive grab,
you are truly helpless

Yet monkeys ignore this

They ignore this because the code handling above is on the client:
`/client/proc/Process_Grab()`

The ideal fix for this is to move it off the client, but that carries a
bunch of order of operations shenanigans so I'll leave that for a more
in depth refactor of this kinda stuff

In the meanwhile we can simply tell AI controllers not to move if
grabbed and incapacitated (barring stasis)

## Changelog

🆑 Melbert
fix: Monkeys no longer ignore basic rules such as "you can't escape a
passive grab if you're cuffed or in crit"
/🆑
2024-11-21 18:18:47 +01:00

25 lines
1.2 KiB
Plaintext

///Uses Byond's basic obstacle avoidance movement
/datum/ai_movement/basic_avoidance
max_pathing_attempts = 10
/// Movement flags to pass to the loop
var/move_flags = NONE
/datum/ai_movement/basic_avoidance/start_moving_towards(datum/ai_controller/controller, atom/current_movement_target, min_distance)
. = ..()
var/atom/movable/moving = controller.pawn
var/min_dist = controller.blackboard[BB_CURRENT_MIN_MOVE_DISTANCE]
var/delay = controller.movement_delay
var/datum/move_loop/loop = GLOB.move_manager.move_to(moving, current_movement_target, min_dist, delay, flags = move_flags, subsystem = SSai_movement, extra_info = controller)
RegisterSignal(loop, COMSIG_MOVELOOP_PREPROCESS_CHECK, PROC_REF(pre_move))
RegisterSignal(loop, COMSIG_MOVELOOP_POSTPROCESS, PROC_REF(post_move))
/datum/ai_movement/basic_avoidance/allowed_to_move(datum/move_loop/has_target/dist_bound/source)
var/turf/target_turf = get_step_towards(source.moving, source.target)
if(!target_turf?.can_cross_safely(source.moving))
return FALSE
return ..()
/// Move immediately and don't update our facing
/datum/ai_movement/basic_avoidance/backstep
move_flags = MOVEMENT_LOOP_START_FAST | MOVEMENT_LOOP_NO_DIR_UPDATE