Properly stop attacking after player leaves ffa area (like Gurubashi Arena)

Port From (https://github.com/TrinityCore/TrinityCore/commit/4380fe2751869e7a011d51ee9449e8723b00067f)
This commit is contained in:
hondacrx
2019-08-30 18:05:45 -04:00
parent 7f03373c93
commit 8797760d8a
2 changed files with 23 additions and 0 deletions
@@ -110,9 +110,14 @@ namespace Game.Entities
m_areaUpdateId = newArea;
AreaTableRecord area = CliDB.AreaTableStorage.LookupByKey(newArea);
bool oldFFAPvPArea = pvpInfo.IsInFFAPvPArea;
pvpInfo.IsInFFAPvPArea = area != null && area.Flags[0].HasAnyFlag(AreaFlags.Arena);
UpdatePvPState(true);
// check if we were in ffa arena and we left
if (oldFFAPvPArea && !pvpInfo.IsInFFAPvPArea)
ValidateAttackersAndOwnTarget();
PhasingHandler.OnAreaChange(this);
UpdateAreaDependentAuras(newArea);
+18
View File
@@ -225,6 +225,24 @@ namespace Game.Entities
}
}
public void ValidateAttackersAndOwnTarget()
{
// iterate attackers
List<Unit> toRemove = new List<Unit>();
foreach (Unit attacker in getAttackers())
if (!attacker.IsValidAttackTarget(this))
toRemove.Add(attacker);
foreach (Unit attacker in toRemove)
attacker.AttackStop();
// remove our own victim
Unit victim = GetVictim();
if (victim != null)
if (!IsValidAttackTarget(victim))
AttackStop();
}
public void CombatStop(bool includingCast = false)
{
if (includingCast && IsNonMeleeSpellCast(false))