Core/Auras: Implement SPELL_AURA_BATTLEGROUND_PLAYER_POSITION_FACTIONAL (397) & SPELL_AURA_BATTLEGROUND_PLAYER_POSITION (398)

Port From (https://github.com/TrinityCore/TrinityCore/commit/e9357dc7f29fc15a72a3dc25b647d577dc979db8)
This commit is contained in:
hondacrx
2021-02-13 20:41:50 -05:00
parent b9a94c1235
commit 307f07eeb9
6 changed files with 71 additions and 47 deletions
+39
View File
@@ -6172,6 +6172,45 @@ namespace Game.Spells
target.UpdateHostileAreaState(CliDB.AreaTableStorage.LookupByKey(target.GetZoneId()));
target.UpdatePvPState();
}
[AuraEffectHandler(AuraType.BattleGroundPlayerPositionFactional)]
[AuraEffectHandler(AuraType.BattleGroundPlayerPosition)]
void HandleBattlegroundPlayerPosition(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
{
if (!mode.HasAnyFlag(AuraEffectHandleModes.Real))
return;
Player target = aurApp.GetTarget().ToPlayer();
if (target == null)
return;
BattlegroundMap battlegroundMap = target.GetMap().ToBattlegroundMap();
if (battlegroundMap == null)
return;
Battleground bg = battlegroundMap.GetBG();
if (bg == null)
return;
if (apply)
{
BattlegroundPlayerPosition playerPosition = new BattlegroundPlayerPosition();
playerPosition.Guid = target.GetGUID();
playerPosition.ArenaSlot = (sbyte)GetMiscValue();
playerPosition.Pos = target.GetPosition();
if (GetAuraType() == AuraType.BattleGroundPlayerPositionFactional)
playerPosition.IconID = target.GetTeam() == Team.Alliance ? BattlegroundConst.PlayerPositionIconHordeFlag : BattlegroundConst.PlayerPositionIconAllianceFlag;
else if (GetAuraType() == AuraType.BattleGroundPlayerPosition)
playerPosition.IconID = target.GetTeam() == Team.Alliance ? BattlegroundConst.PlayerPositionIconAllianceFlag : BattlegroundConst.PlayerPositionIconHordeFlag;
else
Log.outWarn(LogFilter.Spells, $"Unknown aura effect {GetAuraType()} handled by HandleBattlegroundPlayerPosition.");
bg.AddPlayerPosition(playerPosition);
}
else
bg.RemovePlayerPosition(target.GetGUID());
}
#endregion
}