mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 05:50:18 +00:00
fix group logic
This commit is contained in:
parent
e0f89e1e47
commit
d2fe1b1cfb
1 changed files with 29 additions and 13 deletions
|
@ -87,11 +87,11 @@ namespace SanAndreasUnity.Behaviours
|
|||
{
|
||||
Ped attackerPed = dmgInfo.GetAttackerPed();
|
||||
|
||||
if (attackerPed != null)
|
||||
_enemyPeds.AddIfNotPresent(attackerPed);
|
||||
|
||||
if (this.Action == PedAIAction.Following)
|
||||
{
|
||||
if (null == attackerPed)
|
||||
return;
|
||||
|
||||
if (attackerPed == this.TargetPed)
|
||||
{
|
||||
// our leader attacked us
|
||||
|
@ -100,9 +100,18 @@ namespace SanAndreasUnity.Behaviours
|
|||
return;
|
||||
}
|
||||
|
||||
if (!this.IsMemberOfOurGroup(attackerPed))
|
||||
{
|
||||
_enemyPeds.AddIfNotPresent(attackerPed);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (attackerPed != null)
|
||||
_enemyPeds.AddIfNotPresent(attackerPed);
|
||||
|
||||
if (this.Action == PedAIAction.Idle || this.Action == PedAIAction.WalkingAround)
|
||||
{
|
||||
var hitPed = this.MyPed;
|
||||
|
@ -131,15 +140,8 @@ namespace SanAndreasUnity.Behaviours
|
|||
|
||||
if (this.Action == PedAIAction.Following)
|
||||
{
|
||||
bool isAttackerPartOfOurGroup = true;
|
||||
var attackerPedAi = attackerPed.GetComponent<PedAI>();
|
||||
if (null == attackerPedAi || attackerPedAi.Action != PedAIAction.Following || attackerPedAi.TargetPed != this.TargetPed)
|
||||
isAttackerPartOfOurGroup = false;
|
||||
|
||||
if (isAttackerPartOfOurGroup)
|
||||
{
|
||||
if (this.IsMemberOfOurGroup(attackerPed))
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.TargetPed == otherPed)
|
||||
{
|
||||
|
@ -149,8 +151,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
return;
|
||||
}
|
||||
|
||||
var otherPedAi = otherPed.GetComponent<PedAI>();
|
||||
if (otherPedAi != null && otherPedAi.Action == PedAIAction.Following && otherPedAi.TargetPed == this.TargetPed)
|
||||
if (this.IsMemberOfOurGroup(otherPed))
|
||||
{
|
||||
// attacked ped is member of our group
|
||||
// his enemy will be also our enemy
|
||||
|
@ -163,6 +164,21 @@ namespace SanAndreasUnity.Behaviours
|
|||
|
||||
}
|
||||
|
||||
bool IsMemberOfOurGroup(Ped ped)
|
||||
{
|
||||
if (this.Action != PedAIAction.Following || this.TargetPed == null) // we are not part of any group
|
||||
return false;
|
||||
|
||||
if (this.TargetPed == ped) // our leader
|
||||
return true;
|
||||
|
||||
var pedAI = ped.GetComponent<PedAI>();
|
||||
if (pedAI != null && pedAI.Action == PedAIAction.Following && pedAI.TargetPed == this.TargetPed)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
this.MyPed.ResetInput();
|
||||
|
|
Loading…
Reference in a new issue