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:
@@ -418,8 +418,8 @@ namespace Framework.Constants
|
||||
ShowConfirmationPrompt = 394,
|
||||
AreaTrigger = 395, // NYI
|
||||
TriggerSpellOnPowerAmount = 396,
|
||||
Unk397 = 397,
|
||||
Unk398 = 398,
|
||||
BattleGroundPlayerPositionFactional = 397,
|
||||
BattleGroundPlayerPosition = 398,
|
||||
ModTimeRate = 399,
|
||||
ModSkill2 = 400,
|
||||
Unk401 = 401,
|
||||
|
||||
@@ -188,13 +188,21 @@ namespace Game.BattleGrounds
|
||||
m_LastPlayerPositionBroadcast = 0;
|
||||
|
||||
BattlegroundPlayerPositions playerPositions = new BattlegroundPlayerPositions();
|
||||
GetPlayerPositionData(playerPositions.FlagCarriers);
|
||||
for (var i =0; i < _playerPositions.Count; ++i)
|
||||
{
|
||||
var playerPosition = _playerPositions[i];
|
||||
// Update position data if we found player.
|
||||
Player player = Global.ObjAccessor.GetPlayer(GetBgMap(), playerPosition.Guid);
|
||||
if (player != null)
|
||||
playerPosition.Pos = player.GetPosition();
|
||||
|
||||
playerPositions.FlagCarriers.Add(playerPosition);
|
||||
}
|
||||
|
||||
SendPacketToAll(playerPositions);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void GetPlayerPositionData(List<BattlegroundPlayerPosition> positions) { }
|
||||
|
||||
void _ProcessOfflineQueue()
|
||||
{
|
||||
// remove offline players from bg after 5 Time.Minutes
|
||||
@@ -943,6 +951,8 @@ namespace Game.BattleGrounds
|
||||
PlayerScores.Clear();
|
||||
|
||||
ResetBGSubclass();
|
||||
|
||||
_playerPositions.Clear();
|
||||
}
|
||||
|
||||
public void StartBattleground()
|
||||
@@ -1586,6 +1596,16 @@ namespace Game.BattleGrounds
|
||||
BroadcastWorker(localizer);
|
||||
}
|
||||
|
||||
public void AddPlayerPosition(BattlegroundPlayerPosition position)
|
||||
{
|
||||
_playerPositions.Add(position);
|
||||
}
|
||||
|
||||
public void RemovePlayerPosition(ObjectGuid guid)
|
||||
{
|
||||
_playerPositions.RemoveAll(playerPosition => playerPosition.Guid == guid);
|
||||
}
|
||||
|
||||
void EndNow()
|
||||
{
|
||||
RemoveFromBGFreeSlotQueue();
|
||||
@@ -2078,6 +2098,8 @@ namespace Game.BattleGrounds
|
||||
|
||||
BattlegroundTemplate _battlegroundTemplate;
|
||||
PvpDifficultyRecord _pvpDifficultyEntry;
|
||||
|
||||
List<BattlegroundPlayerPosition> _playerPositions = new List<BattlegroundPlayerPosition>();
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -107,21 +107,6 @@ namespace Game.BattleGrounds.Zones
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetPlayerPositionData(List<BattlegroundPlayerPosition> positions)
|
||||
{
|
||||
Player player = Global.ObjAccessor.GetPlayer(GetBgMap(), m_FlagKeeper);
|
||||
if (player)
|
||||
{
|
||||
BattlegroundPlayerPosition position = new BattlegroundPlayerPosition();
|
||||
position.Guid = player.GetGUID();
|
||||
position.Pos.X = player.GetPositionX();
|
||||
position.Pos.Y = player.GetPositionY();
|
||||
position.IconID = player.GetTeam() == Team.Alliance ? BattlegroundConst.PlayerPositionIconAllianceFlag : BattlegroundConst.PlayerPositionIconHordeFlag;
|
||||
position.ArenaSlot = BattlegroundConst.PlayerPositionArenaSlotNone;
|
||||
positions.Add(position);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StartingEventCloseDoors()
|
||||
{
|
||||
SpawnBGObject(EotSObjectTypes.DoorA, BattlegroundConst.RespawnImmediately);
|
||||
|
||||
@@ -165,33 +165,6 @@ namespace Game.BattleGrounds.Zones
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetPlayerPositionData(List<BattlegroundPlayerPosition> positions)
|
||||
{
|
||||
Player player = Global.ObjAccessor.GetPlayer(GetBgMap(), m_FlagKeepers[TeamId.Alliance]);
|
||||
if (player)
|
||||
{
|
||||
BattlegroundPlayerPosition position = new BattlegroundPlayerPosition();
|
||||
position.Guid = player.GetGUID();
|
||||
position.Pos.X = player.GetPositionX();
|
||||
position.Pos.Y = player.GetPositionY();
|
||||
position.IconID = BattlegroundConst.PlayerPositionIconAllianceFlag;
|
||||
position.ArenaSlot = BattlegroundConst.PlayerPositionArenaSlotNone;
|
||||
positions.Add(position);
|
||||
}
|
||||
|
||||
player = Global.ObjAccessor.GetPlayer(GetBgMap(), m_FlagKeepers[TeamId.Horde]);
|
||||
if (player)
|
||||
{
|
||||
BattlegroundPlayerPosition position = new BattlegroundPlayerPosition();
|
||||
position.Guid = player.GetGUID();
|
||||
position.Pos.X = player.GetPositionX();
|
||||
position.Pos.Y = player.GetPositionY();
|
||||
position.IconID = BattlegroundConst.PlayerPositionIconHordeFlag;
|
||||
position.ArenaSlot = BattlegroundConst.PlayerPositionArenaSlotNone;
|
||||
positions.Add(position);
|
||||
}
|
||||
}
|
||||
|
||||
public override void StartingEventCloseDoors()
|
||||
{
|
||||
for (int i = WSGObjectTypes.DoorA1; i <= WSGObjectTypes.DoorH4; ++i)
|
||||
|
||||
@@ -341,6 +341,11 @@ namespace Game.Entities
|
||||
{
|
||||
return $"X: {posX} Y: {posY} Z: {posZ} O: {Orientation}";
|
||||
}
|
||||
|
||||
public static implicit operator Vector2(Position position)
|
||||
{
|
||||
return new(position.posX, position.posY);
|
||||
}
|
||||
}
|
||||
|
||||
public class WorldLocation : Position
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user