if ped has no weapon or no ammo, stop attacking and go to leader

This commit is contained in:
in0finite 2021-10-16 22:16:50 +02:00
parent 51545ef571
commit dad217f9b2

View file

@ -46,6 +46,16 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
if (null == this.LeaderPed)
return;
_chaseState.ChooseBestWeapon();
if (null == _ped.CurrentWeapon)
{
// we have no weapon to attack with, or no ammo
// remove current target and go to leader
_currentlyEngagedPed = null;
return;
}
// try to find new target, or remove the current one if needed
if (this.IsFarAwayFromLeader())
{
@ -117,13 +127,6 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
if (this.MyPed.IsInVehicle || this.LeaderPed.IsInVehicle)
this.UpdateFollowing_MovementPart();
// this we do every frame: if we are close enough to leader and have no target, find one.
// this is done so that we quickly choose another target after previous one was killed.
if (!this.IsFarAwayFromLeader() && null == _currentlyEngagedPed)
{
_currentlyEngagedPed = this.GetNextPedToAttack();
}
// update attacking or following
if (_currentlyEngagedPed != null)