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
🆑
fix: basic ranged mobs will now chase victims
/🆑
This commit is contained in:
Ben10Omintrix
2023-09-02 18:23:45 +01:00
committed by GitHub
parent 69f51c6c65
commit 14df914591
@@ -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)