From 14df9145914dc0b807cc100cba3761cbfcbde288 Mon Sep 17 00:00:00 2001 From: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Date: Sat, 2 Sep 2023 20:23:45 +0300 Subject: [PATCH] fix basic ranged mobs not chasing the victims (#78073) ## About The Pull Request if the victim is outside the shooting distance the mob will go through an endless cycle of finding the target and deleting the target instead of chasing them ## Why It's Good For The Game fix basic ranged mobs not chasing the targets ## Changelog :cl: fix: basic ranged mobs will now chase victims /:cl: --- .../ai/basic_mobs/basic_ai_behaviors/basic_attacking.dm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/datums/ai/basic_mobs/basic_ai_behaviors/basic_attacking.dm b/code/datums/ai/basic_mobs/basic_ai_behaviors/basic_attacking.dm index fee9160e5c0..a289c4e5c70 100644 --- a/code/datums/ai/basic_mobs/basic_ai_behaviors/basic_attacking.dm +++ b/code/datums/ai/basic_mobs/basic_ai_behaviors/basic_attacking.dm @@ -52,6 +52,8 @@ var/shots = 1 /// The interval between individual shots in a burst var/burst_interval = 0.2 SECONDS + /// range we will try chasing the target before giving up + var/chase_range = 9 /datum/ai_behavior/basic_ranged_attack/setup(datum/ai_controller/controller, target_key, targetting_datum_key, hiding_location_key) . = ..() @@ -61,13 +63,12 @@ set_movement_target(controller, target) /datum/ai_behavior/basic_ranged_attack/perform(seconds_per_tick, datum/ai_controller/controller, target_key, targetting_datum_key, hiding_location_key) - . = ..() var/mob/living/basic/basic_mob = controller.pawn //targetting datum will kill the action if not real anymore var/atom/target = controller.blackboard[target_key] var/datum/targetting_datum/targetting_datum = controller.blackboard[targetting_datum_key] - if(!targetting_datum.can_attack(basic_mob, target)) + if(!targetting_datum.can_attack(basic_mob, target, chase_range)) finish_action(controller, FALSE, target_key) return @@ -75,7 +76,6 @@ var/atom/final_target = hiding_target ? hiding_target : target if(!can_see(basic_mob, final_target, required_distance)) - finish_action(controller, FALSE, target_key) return controller.set_blackboard_key(hiding_location_key, hiding_target) @@ -89,6 +89,8 @@ else basic_mob.RangedAttack(final_target) + return ..() //only start the cooldown when the shot is shot + /datum/ai_behavior/basic_ranged_attack/finish_action(datum/ai_controller/controller, succeeded, target_key, targetting_datum_key, hiding_location_key) . = ..() if(!succeeded)