Skip to content

Commit

Permalink
Add OnStop to AttackPlayer effect
Browse files Browse the repository at this point in the history
  • Loading branch information
ryand56 committed Sep 10, 2022
1 parent 348b93d commit 57042e3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ChaosVDotNet/Effects/db/Ped/AttackPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ namespace ChaosVDotNet.Effects.db
{
internal class AttackPlayer : Effect
{
private readonly List<Ped> Peds = new List<Ped>();
private RelationshipGroup group;

public AttackPlayer() : base("All Peds Attack Player", EffectType.Ped, true, false)
{
OnStart += _OnStart;
OnTick += _OnTick;
OnStop += _OnStop;
}

private void _OnStart(object sender, EventArgs e)
Expand Down Expand Up @@ -50,8 +52,28 @@ private void _OnTick(object sender, EventArgs e)
Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, ped, 2, true);

ped.Task.FightAgainst(playerPed);
Peds.Add(ped);
}
}
}

private void _OnStop(object sender, EventArgs e)
{
foreach (Ped ped in Peds)
{
if (ped.Exists())
{
ped.RelationshipGroup = null;

Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, ped, 5, false);
Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, ped, 46, false);
Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, ped, 2, false);

ped.Task.ClearAllImmediately();
}
}

Peds.Clear();
}
}
}

0 comments on commit 57042e3

Please sign in to comment.