mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-16 21:08:28 +00:00
dont start chasing if there is no weapon or no ammo
This commit is contained in:
parent
e6fa8866a5
commit
ade4bf6100
3 changed files with 22 additions and 2 deletions
|
@ -182,5 +182,11 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
|
|||
|
||||
return WeaponSlot.Hand;
|
||||
}
|
||||
|
||||
public bool CanStartChasing()
|
||||
{
|
||||
int slot = this.GetBestWeaponSlot();
|
||||
return slot != WeaponSlot.Hand;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,7 +29,12 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
|
|||
hitPed.PedDef.DefaultType.IsGangMember()))
|
||||
{
|
||||
if (attackerPed != null)
|
||||
_pedAI.StartChasing();
|
||||
{
|
||||
if (_pedAI.StateContainer.GetStateOrThrow<ChaseState>().CanStartChasing())
|
||||
_pedAI.StartChasing();
|
||||
else
|
||||
_pedAI.StartEscaping();
|
||||
}
|
||||
}
|
||||
else
|
||||
_pedAI.StartEscaping();
|
||||
|
|
|
@ -9,6 +9,15 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
|
|||
private readonly PathMovementData _pathMovementData = new PathMovementData();
|
||||
public PathMovementData PathMovementData => _pathMovementData;
|
||||
|
||||
private ChaseState _chaseState;
|
||||
|
||||
|
||||
protected internal override void OnAwake(PedAI pedAI)
|
||||
{
|
||||
base.OnAwake(pedAI);
|
||||
|
||||
_chaseState = _pedAI.StateContainer.GetStateOrThrow<ChaseState>();
|
||||
}
|
||||
|
||||
public override void OnBecameActive()
|
||||
{
|
||||
|
@ -37,7 +46,7 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
|
|||
|
||||
// check if we gained some enemies
|
||||
_enemyPeds.RemoveDeadObjectsIfNotEmpty();
|
||||
if (_enemyPeds.Count > 0)
|
||||
if (_enemyPeds.Count > 0 && _chaseState.CanStartChasing())
|
||||
{
|
||||
_pedAI.StartChasing();
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue