Core/Battlegrounds: Use fields from DB2/battleground_template data in the Battleground Class
Port From (https://github.com/TrinityCore/TrinityCore/commit/d7623adf0e6b8c5cdc1e468b89172ed7db63fe92)
This commit is contained in:
@@ -27,7 +27,7 @@ namespace Game.Arenas
|
||||
{
|
||||
public class Arena : Battleground
|
||||
{
|
||||
public Arena()
|
||||
public Arena(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate)
|
||||
{
|
||||
StartDelayTimes[BattlegroundConst.EventIdFirst] = BattlegroundStartTimeIntervals.Delay1m;
|
||||
StartDelayTimes[BattlegroundConst.EventIdSecond] = BattlegroundStartTimeIntervals.Delay30s;
|
||||
|
||||
@@ -18,11 +18,14 @@
|
||||
using Framework.Constants;
|
||||
using Game.Entities;
|
||||
using Game.Network.Packets;
|
||||
using Game.BattleGrounds;
|
||||
|
||||
namespace Game.Arenas
|
||||
{
|
||||
public class BladesEdgeArena : Arena
|
||||
{
|
||||
public BladesEdgeArena(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
|
||||
public override void StartingEventCloseDoors()
|
||||
{
|
||||
for (int i = BladeEdgeObjectTypes.Door1; i <= BladeEdgeObjectTypes.Door4; ++i)
|
||||
|
||||
@@ -19,12 +19,13 @@ using Framework.Constants;
|
||||
using Framework.Dynamic;
|
||||
using Game.Entities;
|
||||
using Game.Network.Packets;
|
||||
using Game.BattleGrounds;
|
||||
|
||||
namespace Game.Arenas
|
||||
{
|
||||
class DalaranSewersArena : Arena
|
||||
{
|
||||
public DalaranSewersArena()
|
||||
public DalaranSewersArena(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate)
|
||||
{
|
||||
_events = new EventMap();
|
||||
}
|
||||
|
||||
@@ -18,11 +18,14 @@
|
||||
using Framework.Constants;
|
||||
using Game.Entities;
|
||||
using Game.Network.Packets;
|
||||
using Game.BattleGrounds;
|
||||
|
||||
namespace Game.Arenas
|
||||
{
|
||||
public class NagrandArena : Arena
|
||||
{
|
||||
public NagrandArena(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
|
||||
public override void StartingEventCloseDoors()
|
||||
{
|
||||
for (int i = NagrandArenaObjectTypes.Door1; i <= NagrandArenaObjectTypes.Door4; ++i)
|
||||
|
||||
@@ -19,12 +19,13 @@ using Framework.Constants;
|
||||
using Framework.Dynamic;
|
||||
using Game.Entities;
|
||||
using Game.Network.Packets;
|
||||
using Game.BattleGrounds;
|
||||
|
||||
namespace Game.Arenas
|
||||
{
|
||||
class RingofValorArena : Arena
|
||||
{
|
||||
public RingofValorArena()
|
||||
public RingofValorArena(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate)
|
||||
{
|
||||
_events = new EventMap();
|
||||
}
|
||||
|
||||
@@ -18,11 +18,14 @@
|
||||
using Framework.Constants;
|
||||
using Game.Entities;
|
||||
using Game.Network.Packets;
|
||||
using Game.BattleGrounds;
|
||||
|
||||
namespace Game.Arenas
|
||||
{
|
||||
class RuinsofLordaeronArena : Arena
|
||||
{
|
||||
public RuinsofLordaeronArena(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { }
|
||||
|
||||
public override bool SetupBattleground()
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
@@ -35,14 +35,12 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
public class Battleground : IDisposable
|
||||
{
|
||||
public Battleground()
|
||||
public Battleground(BattlegroundTemplate battlegroundTemplate)
|
||||
{
|
||||
m_TypeID = BattlegroundTypeId.None;
|
||||
_battlegroundTemplate = battlegroundTemplate;
|
||||
m_RandomTypeID = BattlegroundTypeId.None;
|
||||
m_Status = BattlegroundStatus.None;
|
||||
m_BracketId = BattlegroundBracketId.First;
|
||||
_winnerTeamId = BattlegroundTeamId.Neutral;
|
||||
m_Name = "";
|
||||
|
||||
m_HonorMode = BGHonorMode.Normal;
|
||||
|
||||
@@ -171,11 +169,11 @@ namespace Game.BattleGrounds
|
||||
continue;
|
||||
|
||||
Position pos = player.GetPosition();
|
||||
Position startPos = GetTeamStartPosition(GetTeamIndexByTeamId(player.GetBGTeam()));
|
||||
if (pos.GetExactDistSq(startPos) > maxDist)
|
||||
WorldSafeLocsEntry startPos = GetTeamStartPosition(GetTeamIndexByTeamId(player.GetBGTeam()));
|
||||
if (pos.GetExactDistSq(startPos.Loc) > maxDist)
|
||||
{
|
||||
Log.outDebug(LogFilter.Battleground, "Battleground: Sending {0} back to start location (map: {1}) (possible exploit)", player.GetName(), GetMapId());
|
||||
player.TeleportTo(GetMapId(), startPos.GetPositionX(), startPos.GetPositionY(), startPos.GetPositionZ(), startPos.GetOrientation());
|
||||
Log.outDebug(LogFilter.Battleground, $"Battleground: Sending {player.GetName()} back to start location (map: {GetMapId()}) (possible exploit)");
|
||||
player.TeleportTo(startPos.Loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,7 +362,7 @@ namespace Game.BattleGrounds
|
||||
|
||||
if (!FindBgMap())
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, "Battleground._ProcessJoin: map (map id: {0}, instance id: {1}) is not created!", m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground._ProcessJoin: map (map id: {GetMapId()}, instance id: {m_InstanceID}) is not created!");
|
||||
EndNow();
|
||||
return;
|
||||
}
|
||||
@@ -418,7 +416,7 @@ namespace Game.BattleGrounds
|
||||
if (player)
|
||||
{
|
||||
// BG Status packet
|
||||
BattlegroundQueueTypeId bgQueueTypeId = Global.BattlegroundMgr.BGQueueTypeId(m_TypeID, GetArenaType());
|
||||
BattlegroundQueueTypeId bgQueueTypeId = Global.BattlegroundMgr.BGQueueTypeId(GetTypeID(), GetArenaType());
|
||||
uint queueSlot = player.GetBattlegroundQueueIndex(bgQueueTypeId);
|
||||
|
||||
BattlefieldStatusActive battlefieldStatus;
|
||||
@@ -493,7 +491,7 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
player = Global.ObjAccessor.FindPlayer(guid);
|
||||
if (!player)
|
||||
Log.outError(LogFilter.Battleground, "Battleground.{0}: player ({1}) not found for BG (map: {1}, instance id: {2})!", context, guid.ToString(), m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.{context}: player ({guid}) not found for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
}
|
||||
return player;
|
||||
}
|
||||
@@ -523,12 +521,17 @@ namespace Game.BattleGrounds
|
||||
return m_Map;
|
||||
}
|
||||
|
||||
public void SetTeamStartPosition(int teamIndex, Position pos)
|
||||
public WorldSafeLocsEntry GetTeamStartPosition(int teamId)
|
||||
{
|
||||
Cypher.Assert(teamIndex < TeamId.Neutral);
|
||||
StartPosition[teamIndex] = pos;
|
||||
Cypher.Assert(teamId < TeamId.Neutral);
|
||||
return _battlegroundTemplate.StartLocation[teamId];
|
||||
}
|
||||
|
||||
float GetStartMaxDist()
|
||||
{
|
||||
return _battlegroundTemplate.MaxStartDistSq;
|
||||
}
|
||||
|
||||
void SendPacketToAll(ServerPacket packet)
|
||||
{
|
||||
foreach (var pair in m_Players)
|
||||
@@ -806,6 +809,11 @@ namespace Game.BattleGrounds
|
||||
}
|
||||
}
|
||||
|
||||
uint GetScriptId()
|
||||
{
|
||||
return _battlegroundTemplate.ScriptId;
|
||||
}
|
||||
|
||||
public uint GetBonusHonorFromKill(uint kills)
|
||||
{
|
||||
//variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill)
|
||||
@@ -937,8 +945,7 @@ namespace Game.BattleGrounds
|
||||
m_Events = 0;
|
||||
|
||||
if (m_InvitedAlliance > 0 || m_InvitedHorde > 0)
|
||||
Log.outError(LogFilter.Battleground, "Battleground.Reset: one of the counters is not 0 (Team.Alliance: {0}, Team.Horde: {1}) for BG (map: {2}, instance id: {3})!",
|
||||
m_InvitedAlliance, m_InvitedHorde, m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.Reset: one of the counters is not 0 (Team.Alliance: {m_InvitedAlliance}, Team.Horde: {m_InvitedHorde}) for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
|
||||
m_InvitedAlliance = 0;
|
||||
m_InvitedHorde = 0;
|
||||
@@ -1000,7 +1007,7 @@ namespace Game.BattleGrounds
|
||||
SendPacketToTeam(team, playerJoined, player);
|
||||
|
||||
// BG Status packet
|
||||
BattlegroundQueueTypeId bgQueueTypeId = Global.BattlegroundMgr.BGQueueTypeId(m_TypeID, GetArenaType());
|
||||
BattlegroundQueueTypeId bgQueueTypeId = Global.BattlegroundMgr.BGQueueTypeId(GetTypeID(), GetArenaType());
|
||||
uint queueSlot = player.GetBattlegroundQueueIndex(bgQueueTypeId);
|
||||
|
||||
BattlefieldStatusActive battlefieldStatus;
|
||||
@@ -1125,7 +1132,7 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
if (!m_InBGFreeSlotQueue && IsBattleground())
|
||||
{
|
||||
Global.BattlegroundMgr.AddToBGFreeSlotQueue(m_TypeID, this);
|
||||
Global.BattlegroundMgr.AddToBGFreeSlotQueue(GetTypeID(), this);
|
||||
m_InBGFreeSlotQueue = true;
|
||||
}
|
||||
}
|
||||
@@ -1135,7 +1142,7 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
if (m_InBGFreeSlotQueue)
|
||||
{
|
||||
Global.BattlegroundMgr.RemoveFromBGFreeSlotQueue(m_TypeID, m_InstanceID);
|
||||
Global.BattlegroundMgr.RemoveFromBGFreeSlotQueue(GetTypeID(), m_InstanceID);
|
||||
m_InBGFreeSlotQueue = false;
|
||||
}
|
||||
}
|
||||
@@ -1206,6 +1213,16 @@ namespace Game.BattleGrounds
|
||||
return 0;
|
||||
}
|
||||
|
||||
public bool IsArena()
|
||||
{
|
||||
return _battlegroundTemplate.IsArena();
|
||||
}
|
||||
|
||||
public bool IsBattleground()
|
||||
{
|
||||
return !IsArena();
|
||||
}
|
||||
|
||||
public bool HasFreeSlots()
|
||||
{
|
||||
return GetPlayersSize() < GetMaxPlayers();
|
||||
@@ -1313,8 +1330,8 @@ namespace Game.BattleGrounds
|
||||
// Temporally add safety check for bad spawns and send log (object rotations need to be rechecked in sniff)
|
||||
if (rotation0 == 0 && rotation1 == 0 && rotation2 == 0 && rotation3 == 0)
|
||||
{
|
||||
Log.outDebug(LogFilter.Battleground, "Battleground.AddObject: gameoobject [entry: {0}, object type: {1}] for BG (map: {2}) has zeroed rotation fields, " +
|
||||
"orientation used temporally, but please fix the spawn", entry, type, m_MapId);
|
||||
Log.outDebug(LogFilter.Battleground, $"Battleground.AddObject: gameoobject [entry: {entry}, object type: {type}] for BG (map: {GetMapId()}) has zeroed rotation fields, " +
|
||||
"orientation used temporally, but please fix the spawn");
|
||||
|
||||
rotation = Quaternion.fromEulerAnglesZYX(o, 0.0f, 0.0f);
|
||||
}
|
||||
@@ -1325,7 +1342,7 @@ namespace Game.BattleGrounds
|
||||
GameObject go = GameObject.CreateGameObject(entry, GetBgMap(), new Position(x, y, z, o), rotation, 255, goState);
|
||||
if (!go)
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, "Battleground.AddObject: cannot create gameobject (entry: {0}) for BG (map: {1}, instance id: {2})!", entry, m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.AddObject: cannot create gameobject (entry: {entry}) for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1357,8 +1374,7 @@ namespace Game.BattleGrounds
|
||||
}
|
||||
}
|
||||
else
|
||||
Log.outError(LogFilter.Battleground, "Battleground.DoorClose: door gameobject (type: {0}, {1}) not found for BG (map: {2}, instance id: {3})!",
|
||||
type, BgObjects[type].ToString(), m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.DoorClose: door gameobject (type: {type}, {BgObjects[type]}) not found for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
}
|
||||
|
||||
public void DoorOpen(int type)
|
||||
@@ -1370,8 +1386,7 @@ namespace Game.BattleGrounds
|
||||
obj.SetGoState(GameObjectState.Active);
|
||||
}
|
||||
else
|
||||
Log.outError(LogFilter.Battleground, "Battleground.DoorOpen: door gameobject (type: {0}, {1}) not found for BG (map: {2}, instance id: {3})!",
|
||||
type, BgObjects[type].ToString(), m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.DoorOpen: door gameobject (type: {type}, {BgObjects[type]}) not found for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
}
|
||||
|
||||
public GameObject GetBGObject(int type)
|
||||
@@ -1381,7 +1396,7 @@ namespace Game.BattleGrounds
|
||||
|
||||
GameObject obj = GetBgMap().GetGameObject(BgObjects[type]);
|
||||
if (!obj)
|
||||
Log.outError(LogFilter.Battleground, "Battleground.GetBGObject: gameobject (type: {0}, {1}) not found for BG (map: {2}, instance id: {3})!", type, BgObjects[type].ToString(), m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.GetBGObject: gameobject (type: {type}, {BgObjects[type]}) not found for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
|
||||
return obj;
|
||||
}
|
||||
@@ -1393,11 +1408,16 @@ namespace Game.BattleGrounds
|
||||
|
||||
Creature creature = GetBgMap().GetCreature(BgCreatures[type]);
|
||||
if (!creature)
|
||||
Log.outError(LogFilter.Battleground, "Battleground.GetBGCreature: creature (type: {0}, {1}) not found for BG (map: {2}, instance id: {3})!", type, BgCreatures[type].ToString(), m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.GetBGCreature: creature (type: {type}, {BgCreatures[type]}) not found for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
|
||||
return creature;
|
||||
}
|
||||
|
||||
public uint GetMapId()
|
||||
{
|
||||
return _battlegroundTemplate.BattlemasterEntry.MapId[0];
|
||||
}
|
||||
|
||||
public void SpawnBGObject(int type, uint respawntime)
|
||||
{
|
||||
Map map = FindBgMap();
|
||||
@@ -1428,7 +1448,7 @@ namespace Game.BattleGrounds
|
||||
|
||||
if (Global.ObjectMgr.GetCreatureTemplate(entry) == null)
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.AddCreature: creature template (entry: {entry}) does not exist for BG (map: {m_MapId}, instance id: {m_InstanceID})!");
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.AddCreature: creature template (entry: {entry}) does not exist for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1450,8 +1470,7 @@ namespace Game.BattleGrounds
|
||||
Creature creature = Creature.CreateCreature(entry, map, pos);
|
||||
if (!creature)
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, "Battleground.AddCreature: cannot create creature (entry: {0}) for BG (map: {1}, instance id: {2})!",
|
||||
entry, m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.AddCreature: cannot create creature (entry: {entry}) for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1486,8 +1505,7 @@ namespace Game.BattleGrounds
|
||||
return true;
|
||||
}
|
||||
|
||||
Log.outError(LogFilter.Battleground, "Battleground.DelCreature: creature (type: {0}, {1}) not found for BG (map: {2}, instance id: {3})!",
|
||||
type, BgCreatures[type].ToString(), m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.DelCreature: creature (type: {type}, {BgCreatures[type]}) not found for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
BgCreatures[type].Clear();
|
||||
return false;
|
||||
}
|
||||
@@ -1505,7 +1523,7 @@ namespace Game.BattleGrounds
|
||||
BgObjects[type].Clear();
|
||||
return true;
|
||||
}
|
||||
Log.outError(LogFilter.Battleground, "Battleground.DelObject: gameobject (type: {0}, {1}) not found for BG (map: {2}, instance id: {3})!", type, BgObjects[type].ToString(), m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.DelObject: gameobject (type: {type}, {BgObjects[type]}) not found for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
BgObjects[type].Clear();
|
||||
return false;
|
||||
}
|
||||
@@ -1528,8 +1546,7 @@ namespace Game.BattleGrounds
|
||||
//creature.CastSpell(creature, SPELL_SPIRIT_HEAL_CHANNEL, true);
|
||||
return true;
|
||||
}
|
||||
Log.outError(LogFilter.Battleground, "Battleground.AddSpiritGuide: cannot create spirit guide (type: {0}, entry: {1}) for BG (map: {2}, instance id: {3})!",
|
||||
type, entry, m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.AddSpiritGuide: cannot create spirit guide (type: {type}, entry: {entry}) for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
EndNow();
|
||||
return false;
|
||||
}
|
||||
@@ -1581,8 +1598,7 @@ namespace Game.BattleGrounds
|
||||
index--;
|
||||
if (index < 0)
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, "Battleground.HandleTriggerBuff: cannot find buff gameobject ({0}, entry: {1}, type: {2}) in internal data for BG (map: {3}, instance id: {4})!",
|
||||
goGuid.ToString(), obj.GetEntry(), obj.GetGoType(), m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.HandleTriggerBuff: cannot find buff gameobject ({goGuid}, entry: {obj.GetEntry()}, type: {obj.GetGoType()}) in internal data for BG (map: {GetMapId()}, instance id: {m_InstanceID})!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1714,8 +1730,7 @@ namespace Game.BattleGrounds
|
||||
for (int i = 0; i < BgObjects.Length; ++i)
|
||||
if (BgObjects[i] == guid)
|
||||
return i;
|
||||
Log.outError(LogFilter.Battleground, "Battleground.GetObjectType: player used gameobject ({0}) which is not in internal data for BG (map: {1}, instance id: {2}), cheating?",
|
||||
guid.ToString(), m_MapId, m_InstanceID);
|
||||
Log.outError(LogFilter.Battleground, $"Battleground.GetObjectType: player used gameobject ({guid}) which is not in internal data for BG (map: {GetMapId()}, instance id: {m_InstanceID}), cheating?");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1746,8 +1761,7 @@ namespace Game.BattleGrounds
|
||||
|
||||
public void SetBracket(PvpDifficultyRecord bracketEntry)
|
||||
{
|
||||
m_BracketId = bracketEntry.GetBracketId();
|
||||
SetLevelRange(bracketEntry.MinLevel, bracketEntry.MaxLevel);
|
||||
_pvpDifficultyEntry = bracketEntry;
|
||||
}
|
||||
|
||||
void RewardXPAtKill(Player killer, Player victim)
|
||||
@@ -1782,11 +1796,82 @@ namespace Game.BattleGrounds
|
||||
return true;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return _battlegroundTemplate.BattlemasterEntry.Name[Global.WorldMgr.GetDefaultDbcLocale()];
|
||||
}
|
||||
|
||||
public ulong GetQueueId()
|
||||
{
|
||||
return (ulong)_battlegroundTemplate.Id | 0x1F10000000000000ul;
|
||||
}
|
||||
|
||||
public BattlegroundTypeId GetTypeID(bool getRandom = false)
|
||||
{
|
||||
return getRandom ? m_RandomTypeID : _battlegroundTemplate.Id;
|
||||
}
|
||||
|
||||
public BattlegroundBracketId GetBracketId()
|
||||
{
|
||||
return _pvpDifficultyEntry.GetBracketId();
|
||||
}
|
||||
|
||||
byte GetUniqueBracketId()
|
||||
{
|
||||
return (byte)((GetMinLevel() / 5) - 1); // 10 - 1, 15 - 2, 20 - 3, etc.
|
||||
}
|
||||
|
||||
uint GetMaxPlayers()
|
||||
{
|
||||
return GetMaxPlayersPerTeam() * 2;
|
||||
}
|
||||
|
||||
uint GetMinPlayers()
|
||||
{
|
||||
return GetMinPlayersPerTeam() * 2;
|
||||
}
|
||||
|
||||
public uint GetMinLevel()
|
||||
{
|
||||
if (_pvpDifficultyEntry != null)
|
||||
return _pvpDifficultyEntry.MinLevel;
|
||||
|
||||
return _battlegroundTemplate.GetMinLevel();
|
||||
}
|
||||
|
||||
public uint GetMaxLevel()
|
||||
{
|
||||
if (_pvpDifficultyEntry != null)
|
||||
return _pvpDifficultyEntry.MaxLevel;
|
||||
|
||||
return _battlegroundTemplate.GetMaxLevel();
|
||||
}
|
||||
|
||||
public uint GetMaxPlayersPerTeam()
|
||||
{
|
||||
if (IsArena())
|
||||
{
|
||||
switch (GetArenaType())
|
||||
{
|
||||
case ArenaTypes.Team2v2:
|
||||
return 2;
|
||||
case ArenaTypes.Team3v3:
|
||||
return 3;
|
||||
case ArenaTypes.Team5v5: // removed
|
||||
return 5;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return _battlegroundTemplate.GetMaxPlayersPerTeam();
|
||||
}
|
||||
|
||||
public uint GetMinPlayersPerTeam()
|
||||
{
|
||||
return _battlegroundTemplate.GetMinPlayersPerTeam();
|
||||
}
|
||||
|
||||
public virtual void StartingEventCloseDoors() { }
|
||||
public virtual void StartingEventOpenDoors() { }
|
||||
public virtual void ResetBGSubclass() { } // must be implemented in BG subclass
|
||||
@@ -1794,34 +1879,18 @@ namespace Game.BattleGrounds
|
||||
public virtual void DestroyGate(Player player, GameObject go) { }
|
||||
public virtual bool IsAllNodesControlledByTeam(Team team) { return false; }
|
||||
|
||||
public string GetName() { return m_Name; }
|
||||
public ulong GetQueueId() { return m_queueId; }
|
||||
public BattlegroundTypeId GetTypeID(bool GetRandom = false) { return GetRandom ? m_RandomTypeID : m_TypeID; }
|
||||
public BattlegroundBracketId GetBracketId() { return m_BracketId; }
|
||||
public uint GetInstanceID() { return m_InstanceID; }
|
||||
public BattlegroundStatus GetStatus() { return m_Status; }
|
||||
public uint GetClientInstanceID() { return m_ClientInstanceID; }
|
||||
public uint GetElapsedTime() { return m_StartTime; }
|
||||
public uint GetRemainingTime() { return (uint)m_EndTime; }
|
||||
public uint GetLastResurrectTime() { return m_LastResurrectTime; }
|
||||
uint GetMaxPlayers() { return m_MaxPlayers; }
|
||||
uint GetMinPlayers() { return m_MinPlayers; }
|
||||
|
||||
public uint GetMinLevel() { return m_LevelMin; }
|
||||
public uint GetMaxLevel() { return m_LevelMax; }
|
||||
|
||||
public uint GetMaxPlayersPerTeam() { return m_MaxPlayersPerTeam; }
|
||||
public uint GetMinPlayersPerTeam() { return m_MinPlayersPerTeam; }
|
||||
|
||||
int GetStartDelayTime() { return m_StartDelayTime; }
|
||||
public ArenaTypes GetArenaType() { return m_ArenaType; }
|
||||
BattlegroundTeamId GetWinner() { return _winnerTeamId; }
|
||||
uint GetScriptId() { return ScriptId; }
|
||||
public bool IsRandom() { return m_IsRandom; }
|
||||
|
||||
public void SetQueueId(ulong queueId) { m_queueId = queueId; }
|
||||
public void SetName(string Name) { m_Name = Name; }
|
||||
public void SetTypeID(BattlegroundTypeId TypeID) { m_TypeID = TypeID; }
|
||||
public void SetRandomTypeID(BattlegroundTypeId TypeID) { m_RandomTypeID = TypeID; }
|
||||
//here we can count minlevel and maxlevel for players
|
||||
public void SetInstanceID(uint InstanceID) { m_InstanceID = InstanceID; }
|
||||
@@ -1830,21 +1899,13 @@ namespace Game.BattleGrounds
|
||||
public void SetElapsedTime(uint Time) { m_StartTime = Time; }
|
||||
public void SetRemainingTime(uint Time) { m_EndTime = (int)Time; }
|
||||
public void SetLastResurrectTime(uint Time) { m_LastResurrectTime = Time; }
|
||||
public void SetMaxPlayers(uint MaxPlayers) { m_MaxPlayers = MaxPlayers; }
|
||||
public void SetMinPlayers(uint MinPlayers) { m_MinPlayers = MinPlayers; }
|
||||
public void SetLevelRange(uint min, uint max) { m_LevelMin = min; m_LevelMax = max; }
|
||||
public void SetRated(bool state) { m_IsRated = state; }
|
||||
public void SetArenaType(ArenaTypes type) { m_ArenaType = type; }
|
||||
public void SetArenaorBGType(bool _isArena) { m_IsArena = _isArena; }
|
||||
public void SetWinner(BattlegroundTeamId winnerTeamId) { _winnerTeamId = winnerTeamId; }
|
||||
public void SetScriptId(uint scriptId) { ScriptId = scriptId; }
|
||||
|
||||
void ModifyStartDelayTime(int diff) { m_StartDelayTime -= diff; }
|
||||
void SetStartDelayTime(BattlegroundStartTimeIntervals Time) { m_StartDelayTime = (int)Time; }
|
||||
|
||||
public void SetMaxPlayersPerTeam(uint MaxPlayers) { m_MaxPlayersPerTeam = MaxPlayers; }
|
||||
public void SetMinPlayersPerTeam(uint MinPlayers) { m_MinPlayersPerTeam = MinPlayers; }
|
||||
|
||||
public void DecreaseInvitedCount(Team team)
|
||||
{
|
||||
if (team == Team.Alliance)
|
||||
@@ -1863,8 +1924,6 @@ namespace Game.BattleGrounds
|
||||
public void SetRandom(bool isRandom) { m_IsRandom = isRandom; }
|
||||
uint GetInvitedCount(Team team) { return (team == Team.Alliance) ? m_InvitedAlliance : m_InvitedHorde; }
|
||||
|
||||
public bool IsArena() { return m_IsArena; }
|
||||
public bool IsBattleground() { return !m_IsArena; }
|
||||
public bool IsRated() { return m_IsRated; }
|
||||
|
||||
public Dictionary<ObjectGuid, BattlegroundPlayer> GetPlayers() { return m_Players; }
|
||||
@@ -1872,21 +1931,9 @@ namespace Game.BattleGrounds
|
||||
uint GetPlayerScoresSize() { return (uint)PlayerScores.Count; }
|
||||
uint GetReviveQueueSize() { return (uint)m_ReviveQueue.Count; }
|
||||
|
||||
public void SetMapId(uint MapID) { m_MapId = MapID; }
|
||||
public uint GetMapId() { return m_MapId; }
|
||||
|
||||
public void SetBgMap(BattlegroundMap map) { m_Map = map; }
|
||||
BattlegroundMap FindBgMap() { return m_Map; }
|
||||
|
||||
public Position GetTeamStartPosition(int teamIndex)
|
||||
{
|
||||
Cypher.Assert(teamIndex < TeamId.Neutral);
|
||||
return StartPosition[teamIndex];
|
||||
}
|
||||
|
||||
public void SetStartMaxDist(float startMaxDist) { m_StartMaxDist = startMaxDist; }
|
||||
float GetStartMaxDist() { return m_StartMaxDist; }
|
||||
|
||||
public virtual void FillInitialWorldStates(InitWorldStates data) { }
|
||||
|
||||
Group GetBgRaid(Team team) { return m_BgRaids[GetTeamIndexByTeamId(team)]; }
|
||||
@@ -1927,7 +1974,7 @@ namespace Game.BattleGrounds
|
||||
public bool ToBeDeleted() { return m_SetDeleteThis; }
|
||||
void SetDeleteThis() { m_SetDeleteThis = true; }
|
||||
|
||||
bool CanAwardArenaPoints() { return m_LevelMin >= 71; }
|
||||
bool CanAwardArenaPoints() { return GetMinLevel() >= 71; }
|
||||
|
||||
public virtual ObjectGuid GetFlagPickerGUID(int teamIndex = -1) { return ObjectGuid.Empty; }
|
||||
public virtual void SetDroppedFlagGUID(ObjectGuid guid, int teamIndex = -1) { }
|
||||
@@ -1981,7 +2028,6 @@ namespace Game.BattleGrounds
|
||||
public uint[] Buff_Entries = { BattlegroundConst.SpeedBuff, BattlegroundConst.RegenBuff, BattlegroundConst.BerserkerBuff };
|
||||
|
||||
// Battleground
|
||||
BattlegroundTypeId m_TypeID;
|
||||
BattlegroundTypeId m_RandomTypeID;
|
||||
uint m_InstanceID; // Battleground Instance's GUID!
|
||||
BattlegroundStatus m_Status;
|
||||
@@ -1992,18 +2038,14 @@ namespace Game.BattleGrounds
|
||||
uint m_ValidStartPositionTimer;
|
||||
int m_EndTime; // it is set to 120000 when bg is ending and it decreases itself
|
||||
uint m_LastResurrectTime;
|
||||
BattlegroundBracketId m_BracketId;
|
||||
ArenaTypes m_ArenaType; // 2=2v2, 3=3v3, 5=5v5
|
||||
bool m_InBGFreeSlotQueue; // used to make sure that BG is only once inserted into the BattlegroundMgr.BGFreeSlotQueue[bgTypeId] deque
|
||||
bool m_SetDeleteThis; // used for safe deletion of the bg after end / all players leave
|
||||
bool m_IsArena;
|
||||
BattlegroundTeamId _winnerTeamId;
|
||||
int m_StartDelayTime;
|
||||
bool m_IsRated; // is this battle rated?
|
||||
bool m_PrematureCountDown;
|
||||
uint m_PrematureCountDownTimer;
|
||||
string m_Name;
|
||||
ulong m_queueId;
|
||||
uint m_LastPlayerPositionBroadcast;
|
||||
|
||||
// Player lists
|
||||
@@ -2028,20 +2070,12 @@ namespace Game.BattleGrounds
|
||||
int[] m_ArenaTeamRatingChanges = new int[SharedConst.BGTeamsCount];
|
||||
uint[] m_ArenaTeamMMR = new uint[SharedConst.BGTeamsCount];
|
||||
|
||||
// Limits
|
||||
uint m_LevelMin;
|
||||
uint m_LevelMax;
|
||||
uint m_MaxPlayersPerTeam;
|
||||
uint m_MaxPlayers;
|
||||
uint m_MinPlayersPerTeam;
|
||||
uint m_MinPlayers;
|
||||
|
||||
// Start location
|
||||
uint m_MapId;
|
||||
BattlegroundMap m_Map;
|
||||
Position[] StartPosition = new Position[SharedConst.BGTeamsCount];
|
||||
float m_StartMaxDist;
|
||||
uint ScriptId;
|
||||
|
||||
BattlegroundTemplate _battlegroundTemplate;
|
||||
PvpDifficultyRecord _pvpDifficultyEntry;
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -275,32 +275,9 @@ namespace Game.BattleGrounds
|
||||
bg.Reset(); // reset the new bg (set status to status_wait_queue from status_none)
|
||||
bg.SetStatus(BattlegroundStatus.WaitJoin); // start the joining of the bg
|
||||
bg.SetArenaType(arenaType);
|
||||
bg.SetTypeID(originalBgTypeId);
|
||||
bg.SetRandomTypeID(bgTypeId);
|
||||
bg.SetRated(isRated);
|
||||
bg.SetRandom(isRandom);
|
||||
bg.SetQueueId((ulong)bgTypeId | 0x1F10000000000000);
|
||||
|
||||
// Set up correct min/max player counts for scoreboards
|
||||
if (bg.IsArena())
|
||||
{
|
||||
uint maxPlayersPerTeam = 0;
|
||||
switch (arenaType)
|
||||
{
|
||||
case ArenaTypes.Team2v2:
|
||||
maxPlayersPerTeam = 2;
|
||||
break;
|
||||
case ArenaTypes.Team3v3:
|
||||
maxPlayersPerTeam = 3;
|
||||
break;
|
||||
case ArenaTypes.Team5v5:
|
||||
maxPlayersPerTeam = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
bg.SetMaxPlayersPerTeam(maxPlayersPerTeam);
|
||||
bg.SetMaxPlayers(maxPlayersPerTeam * 2);
|
||||
}
|
||||
|
||||
return bg;
|
||||
}
|
||||
@@ -315,73 +292,59 @@ namespace Game.BattleGrounds
|
||||
switch (bgTemplate.Id)
|
||||
{
|
||||
//case BattlegroundTypeId.AV:
|
||||
// bg = new BattlegroundAV();
|
||||
//break;
|
||||
// bg = new BattlegroundAV(bgTemplate);
|
||||
//break;
|
||||
case BattlegroundTypeId.WS:
|
||||
bg = new BgWarsongGluch();
|
||||
bg = new BgWarsongGluch(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.AB:
|
||||
bg = new BgArathiBasin();
|
||||
bg = new BgArathiBasin(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.NA:
|
||||
bg = new NagrandArena();
|
||||
bg = new NagrandArena(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.BE:
|
||||
bg = new BladesEdgeArena();
|
||||
bg = new BladesEdgeArena(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.EY:
|
||||
bg = new BgEyeofStorm();
|
||||
bg = new BgEyeofStorm(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.RL:
|
||||
bg = new RuinsofLordaeronArena();
|
||||
bg = new RuinsofLordaeronArena(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.SA:
|
||||
bg = new BgStrandOfAncients();
|
||||
bg = new BgStrandOfAncients(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.DS:
|
||||
bg = new DalaranSewersArena();
|
||||
bg = new DalaranSewersArena(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.RV:
|
||||
bg = new RingofValorArena();
|
||||
bg = new RingofValorArena(bgTemplate);
|
||||
break;
|
||||
//case BattlegroundTypeId.IC:
|
||||
//bg = new BattlegroundIC();
|
||||
//break;
|
||||
//bg = new BattlegroundIC(bgTemplate);
|
||||
//break;
|
||||
case BattlegroundTypeId.AA:
|
||||
bg = new Battleground();
|
||||
bg = new Battleground(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.RB:
|
||||
bg = new Battleground();
|
||||
bg = new Battleground(bgTemplate);
|
||||
bg.SetRandom(true);
|
||||
break;
|
||||
/*
|
||||
case BattlegroundTypeId.TP:
|
||||
bg = new BattlegroundTP();
|
||||
bg = new BattlegroundTP(bgTemplate);
|
||||
break;
|
||||
case BattlegroundTypeId.BFG:
|
||||
bg = new BattlegroundBFG();
|
||||
bg = new BattlegroundBFG(bgTemplate);
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
bg.SetTypeID(bgTemplate.Id);
|
||||
}
|
||||
|
||||
bg.SetMapId((uint)bgTemplate.BattlemasterEntry.MapId[0]);
|
||||
bg.SetName(bgTemplate.BattlemasterEntry.Name[Global.WorldMgr.GetDefaultDbcLocale()]);
|
||||
bg.SetInstanceID(0);
|
||||
bg.SetArenaorBGType(bgTemplate.IsArena());
|
||||
bg.SetMinPlayersPerTeam(bgTemplate.MinPlayersPerTeam);
|
||||
bg.SetMaxPlayersPerTeam(bgTemplate.MaxPlayersPerTeam);
|
||||
bg.SetMinPlayers(bgTemplate.MinPlayersPerTeam * 2);
|
||||
bg.SetMaxPlayers(bgTemplate.MaxPlayersPerTeam * 2);
|
||||
bg.SetTeamStartPosition(TeamId.Alliance, bgTemplate.StartLocation[TeamId.Alliance]);
|
||||
bg.SetTeamStartPosition(TeamId.Horde, bgTemplate.StartLocation[TeamId.Horde]);
|
||||
bg.SetStartMaxDist(bgTemplate.StartMaxDist);
|
||||
bg.SetLevelRange(bgTemplate.MinLevel, bgTemplate.MaxLevel);
|
||||
bg.SetScriptId(bgTemplate.scriptId);
|
||||
bg.SetQueueId((ulong)bgTemplate.Id | 0x1F10000000000000);
|
||||
|
||||
if (!bgDataStore.ContainsKey(bg.GetTypeID()))
|
||||
bgDataStore[bg.GetTypeID()] = new BattlegroundData();
|
||||
@@ -395,11 +358,8 @@ namespace Game.BattleGrounds
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
|
||||
_BattlegroundMapTemplates.Clear();
|
||||
_BattlegroundTemplates.Clear();
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
SQLResult result = DB.World.Query("SELECT ID, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, AllianceStartLoc, HordeStartLoc, StartMaxDist, Weight, ScriptName FROM battleground_template");
|
||||
// 0 1 2 3 4 5
|
||||
SQLResult result = DB.World.Query("SELECT ID, AllianceStartLoc, HordeStartLoc, StartMaxDist, Weight, ScriptName FROM battleground_template");
|
||||
if (result.IsEmpty())
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, "Loaded 0 Battlegrounds. DB table `Battleground_template` is empty.");
|
||||
@@ -423,65 +383,50 @@ namespace Game.BattleGrounds
|
||||
|
||||
BattlegroundTemplate bgTemplate = new BattlegroundTemplate();
|
||||
bgTemplate.Id = bgTypeId;
|
||||
bgTemplate.MinPlayersPerTeam = result.Read<ushort>(1);
|
||||
bgTemplate.MaxPlayersPerTeam = result.Read<ushort>(2);
|
||||
bgTemplate.MinLevel = result.Read<byte>(3);
|
||||
bgTemplate.MaxLevel = result.Read<byte>(4);
|
||||
float dist = result.Read<float>(7);
|
||||
bgTemplate.StartMaxDist = dist * dist;
|
||||
bgTemplate.Weight = result.Read<byte>(8);
|
||||
float dist = result.Read<float>(3);
|
||||
bgTemplate.MaxStartDistSq = dist * dist;
|
||||
bgTemplate.Weight = result.Read<byte>(4);
|
||||
|
||||
bgTemplate.scriptId = Global.ObjectMgr.GetScriptId(result.Read<string>(9));
|
||||
bgTemplate.ScriptId = Global.ObjectMgr.GetScriptId(result.Read<string>(5));
|
||||
bgTemplate.BattlemasterEntry = bl;
|
||||
|
||||
if (bgTemplate.MaxPlayersPerTeam == 0 || bgTemplate.MinPlayersPerTeam > bgTemplate.MaxPlayersPerTeam)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Table `Battleground_template` for Id {0} has bad values for MinPlayersPerTeam ({1}) and MaxPlayersPerTeam({2})",
|
||||
bgTemplate.Id, bgTemplate.MinPlayersPerTeam, bgTemplate.MaxPlayersPerTeam);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bgTemplate.MinLevel == 0 || bgTemplate.MaxLevel == 0 || bgTemplate.MinLevel > bgTemplate.MaxLevel)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Table `Battleground_template` for Id {0} has bad values for LevelMin ({1}) and LevelMax({2})",
|
||||
bgTemplate.Id, bgTemplate.MinLevel, bgTemplate.MaxLevel);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bgTemplate.Id != BattlegroundTypeId.AA && bgTemplate.Id != BattlegroundTypeId.RB)
|
||||
{
|
||||
uint startId = result.Read<uint>(5);
|
||||
uint startId = result.Read<uint>(1);
|
||||
WorldSafeLocsEntry start = Global.ObjectMgr.GetWorldSafeLoc(startId);
|
||||
if (start != null)
|
||||
{
|
||||
bgTemplate.StartLocation[TeamId.Alliance] = start.Loc;
|
||||
}
|
||||
bgTemplate.StartLocation[TeamId.Alliance] = start;
|
||||
else if (bgTemplate.StartLocation[TeamId.Alliance] != null) // reload case
|
||||
Log.outError(LogFilter.Sql, $"Table `battleground_template` for id {bgTemplate.Id} contains a non-existing WorldSafeLocs.dbc id {startId} in field `AllianceStartLoc`. Ignoring.");
|
||||
else
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Table `Battleground_template` for Id {0} has a non-existed WorldSafeLocs.dbc id {1} in field `AllianceStartLoc`. BG not created.", bgTemplate.Id, startId);
|
||||
Log.outError(LogFilter.Sql, $"Table `Battleground_template` for Id {bgTemplate.Id} has a non-existed WorldSafeLocs.dbc id {startId} in field `AllianceStartLoc`. BG not created.");
|
||||
continue;
|
||||
}
|
||||
|
||||
startId = result.Read<uint>(6);
|
||||
startId = result.Read<uint>(2);
|
||||
start = Global.ObjectMgr.GetWorldSafeLoc(startId);
|
||||
if (start != null)
|
||||
{
|
||||
bgTemplate.StartLocation[TeamId.Horde] = start.Loc;
|
||||
}
|
||||
bgTemplate.StartLocation[TeamId.Horde] = start;
|
||||
else if (bgTemplate.StartLocation[TeamId.Horde] != null) // reload case
|
||||
Log.outError(LogFilter.Sql, $"Table `battleground_template` for id {bgTemplate.Id} contains a non-existing WorldSafeLocs.dbc id {startId} in field `HordeStartLoc`. Ignoring.");
|
||||
else
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Table `Battleground_template` for Id {0} has a non-existed WorldSafeLocs.dbc id {1} in field `HordeStartLoc`. BG not created.", bgTemplate.Id, startId);
|
||||
Log.outError(LogFilter.Sql, $"Table `Battleground_template` for Id {bgTemplate.Id} has a non-existed WorldSafeLocs.dbc id {startId} in field `HordeStartLoc`. BG not created.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CreateBattleground(bgTemplate))
|
||||
{
|
||||
Log.outError(LogFilter.Battleground, $"Could not create battleground template class ({bgTemplate.Id})!");
|
||||
continue;
|
||||
}
|
||||
|
||||
_BattlegroundTemplates[bgTypeId] = bgTemplate;
|
||||
_battlegroundTemplates[bgTypeId] = bgTemplate;
|
||||
|
||||
if (bgTemplate.BattlemasterEntry.MapId[1] == -1) // in this case we have only one mapId
|
||||
_BattlegroundMapTemplates[(uint)bgTemplate.BattlemasterEntry.MapId[0]] = _BattlegroundTemplates[bgTypeId];
|
||||
_battlegroundMapTemplates[(uint)bgTemplate.BattlemasterEntry.MapId[0]] = _battlegroundTemplates[bgTypeId];
|
||||
|
||||
++count;
|
||||
}
|
||||
@@ -499,8 +444,8 @@ namespace Game.BattleGrounds
|
||||
BattlefieldList battlefieldList = new BattlefieldList();
|
||||
battlefieldList.BattlemasterGuid = guid;
|
||||
battlefieldList.BattlemasterListID = (int)bgTypeId;
|
||||
battlefieldList.MinLevel = (byte)bgTemplate.MinLevel;
|
||||
battlefieldList.MaxLevel = (byte)bgTemplate.MaxLevel;
|
||||
battlefieldList.MinLevel = bgTemplate.GetMinLevel();
|
||||
battlefieldList.MaxLevel = bgTemplate.GetMaxLevel();
|
||||
battlefieldList.PvpAnywhere = guid.IsEmpty();
|
||||
battlefieldList.HasRandomWinToday = player.GetRandomWinner();
|
||||
player.SendPacket(battlefieldList);
|
||||
@@ -514,12 +459,12 @@ namespace Game.BattleGrounds
|
||||
uint mapid = bg.GetMapId();
|
||||
Team team = player.GetBGTeam();
|
||||
|
||||
Position pos = bg.GetTeamStartPosition(Battleground.GetTeamIndexByTeamId(team));
|
||||
Log.outDebug(LogFilter.Battleground, "BattlegroundMgr.SendToBattleground: Sending {0} to map {1}, {2} (bgType {3})", player.GetName(), mapid, pos.ToString(), bgTypeId);
|
||||
player.TeleportTo(mapid, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation());
|
||||
WorldSafeLocsEntry pos = bg.GetTeamStartPosition(Battleground.GetTeamIndexByTeamId(team));
|
||||
Log.outDebug(LogFilter.Battleground, $"BattlegroundMgr.SendToBattleground: Sending {player.GetName()} to map {mapid}, {pos.Loc} (bgType {bgTypeId})");
|
||||
player.TeleportTo(pos.Loc);
|
||||
}
|
||||
else
|
||||
Log.outError(LogFilter.Battleground, "BattlegroundMgr.SendToBattleground: Instance {0} (bgType {1}) not found while trying to teleport player {2}", instanceId, bgTypeId, player.GetName());
|
||||
Log.outError(LogFilter.Battleground, $"BattlegroundMgr.SendToBattleground: Instance {instanceId} (bgType {bgTypeId}) not found while trying to teleport player {player.GetName()}");
|
||||
}
|
||||
|
||||
public void SendAreaSpiritHealerQuery(Player player, Battleground bg, ObjectGuid guid)
|
||||
@@ -867,19 +812,19 @@ namespace Game.BattleGrounds
|
||||
|
||||
BattlegroundTemplate GetBattlegroundTemplateByTypeId(BattlegroundTypeId id)
|
||||
{
|
||||
return _BattlegroundTemplates.LookupByKey(id);
|
||||
return _battlegroundTemplates.LookupByKey(id);
|
||||
}
|
||||
|
||||
BattlegroundTemplate GetBattlegroundTemplateByMapId(uint mapId)
|
||||
{
|
||||
return _BattlegroundMapTemplates.LookupByKey(mapId);
|
||||
return _battlegroundMapTemplates.LookupByKey(mapId);
|
||||
}
|
||||
|
||||
Dictionary<BattlegroundTypeId, BattlegroundData> bgDataStore = new Dictionary<BattlegroundTypeId, BattlegroundData>();
|
||||
BattlegroundQueue[] m_BattlegroundQueues = new BattlegroundQueue[(int)BattlegroundQueueTypeId.Max];
|
||||
Dictionary<uint, BattlegroundTypeId> mBattleMastersMap = new Dictionary<uint, BattlegroundTypeId>();
|
||||
Dictionary<BattlegroundTypeId, BattlegroundTemplate> _BattlegroundTemplates = new Dictionary<BattlegroundTypeId, BattlegroundTemplate>();
|
||||
Dictionary<uint, BattlegroundTemplate> _BattlegroundMapTemplates = new Dictionary<uint, BattlegroundTemplate>();
|
||||
Dictionary<BattlegroundTypeId, BattlegroundTemplate> _battlegroundTemplates = new Dictionary<BattlegroundTypeId, BattlegroundTemplate>();
|
||||
Dictionary<uint, BattlegroundTemplate> _battlegroundMapTemplates = new Dictionary<uint, BattlegroundTemplate>();
|
||||
List<ulong> m_QueueUpdateScheduler = new List<ulong>();
|
||||
uint m_NextRatedArenaUpdate;
|
||||
uint m_UpdateTimer;
|
||||
@@ -901,19 +846,35 @@ namespace Game.BattleGrounds
|
||||
public Battleground Template;
|
||||
}
|
||||
|
||||
class BattlegroundTemplate
|
||||
public class BattlegroundTemplate
|
||||
{
|
||||
public BattlegroundTypeId Id;
|
||||
public uint MinPlayersPerTeam;
|
||||
public uint MaxPlayersPerTeam;
|
||||
public uint MinLevel;
|
||||
public uint MaxLevel;
|
||||
public Position[] StartLocation = new Position[SharedConst.BGTeamsCount];
|
||||
public float StartMaxDist;
|
||||
public WorldSafeLocsEntry[] StartLocation = new WorldSafeLocsEntry[SharedConst.BGTeamsCount];
|
||||
public float MaxStartDistSq;
|
||||
public byte Weight;
|
||||
public uint scriptId;
|
||||
public uint ScriptId;
|
||||
public BattlemasterListRecord BattlemasterEntry;
|
||||
|
||||
public bool IsArena() { return BattlemasterEntry.InstanceType == (uint)MapTypes.Arena; }
|
||||
|
||||
public ushort GetMinPlayersPerTeam()
|
||||
{
|
||||
return BattlemasterEntry.MinPlayers;
|
||||
}
|
||||
|
||||
public ushort GetMaxPlayersPerTeam()
|
||||
{
|
||||
return BattlemasterEntry.MaxPlayers;
|
||||
}
|
||||
|
||||
public byte GetMinLevel()
|
||||
{
|
||||
return BattlemasterEntry.MinLevel;
|
||||
}
|
||||
|
||||
public byte GetMaxLevel()
|
||||
{
|
||||
return BattlemasterEntry.MaxLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class BgArathiBasin : Battleground
|
||||
{
|
||||
public BgArathiBasin()
|
||||
public BgArathiBasin(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate)
|
||||
{
|
||||
m_IsInformedNearVictory = false;
|
||||
m_BuffChange = true;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class BgEyeofStorm : Battleground
|
||||
{
|
||||
public BgEyeofStorm()
|
||||
public BgEyeofStorm(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate)
|
||||
{
|
||||
m_BuffChange = true;
|
||||
BgObjects = new ObjectGuid[ABObjectTypes.Max];
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
public class BgStrandOfAncients : Battleground
|
||||
{
|
||||
public BgStrandOfAncients()
|
||||
public BgStrandOfAncients(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate)
|
||||
{
|
||||
StartMessageIds[BattlegroundConst.EventIdFourth] = 0;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Game.BattleGrounds.Zones
|
||||
{
|
||||
class BgWarsongGluch : Battleground
|
||||
{
|
||||
public BgWarsongGluch()
|
||||
public BgWarsongGluch(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate)
|
||||
{
|
||||
BgObjects = new ObjectGuid[WSGObjectTypes.Max];
|
||||
BgCreatures = new ObjectGuid[WSGCreatureTypes.Max];
|
||||
|
||||
@@ -104,6 +104,20 @@ namespace Game.DataStorage
|
||||
foreach (AzeriteUnlockMappingRecord azeriteUnlockMapping in CliDB.AzeriteUnlockMappingStorage.Values)
|
||||
azeriteUnlockMappings.Add(azeriteUnlockMapping.AzeriteUnlockMappingSetID, azeriteUnlockMapping);
|
||||
|
||||
foreach (BattlemasterListRecord battlemaster in CliDB.BattlemasterListStorage.Values)
|
||||
{
|
||||
if (battlemaster.MaxLevel < battlemaster.MinLevel)
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, $"Battlemaster ({battlemaster.Id}) contains bad values for MinLevel ({battlemaster.MinLevel}) and MaxLevel ({battlemaster.MaxLevel}). Swapping values.");
|
||||
MathFunctions.Swap(ref battlemaster.MaxLevel, ref battlemaster.MinLevel);
|
||||
}
|
||||
if (battlemaster.MaxPlayers < battlemaster.MinPlayers)
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, $"Battlemaster ({battlemaster.Id}) contains bad values for MinPlayers ({battlemaster.MinPlayers}) and MaxPlayers ({battlemaster.MaxPlayers}). Swapping values.");
|
||||
MathFunctions.Swap(ref battlemaster.MaxPlayers, ref battlemaster.MinPlayers);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (CharacterFacialHairStylesRecord characterFacialStyle in CliDB.CharacterFacialHairStylesStorage.Values)
|
||||
_characterFacialHairStyles.Add(Tuple.Create(characterFacialStyle.RaceID, characterFacialStyle.SexID, (uint)characterFacialStyle.VariationID));
|
||||
|
||||
|
||||
@@ -90,18 +90,18 @@ namespace Game.DataStorage
|
||||
public string ShortDescription;
|
||||
public string LongDescription;
|
||||
public sbyte InstanceType;
|
||||
public sbyte MinLevel;
|
||||
public sbyte MaxLevel;
|
||||
public byte MinLevel;
|
||||
public byte MaxLevel;
|
||||
public sbyte RatedPlayers;
|
||||
public sbyte MinPlayers;
|
||||
public sbyte MaxPlayers;
|
||||
public byte MinPlayers;
|
||||
public byte MaxPlayers;
|
||||
public sbyte GroupsAllowed;
|
||||
public sbyte MaxGroupSize;
|
||||
public ushort HolidayWorldState;
|
||||
public BattlemasterListFlags Flags;
|
||||
public int IconFileDataID;
|
||||
public short RequiredPlayerConditionID;
|
||||
public short[] MapId = new short[16];
|
||||
public ushort[] MapId = new ushort[16];
|
||||
}
|
||||
|
||||
public sealed class BroadcastTextRecord
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE `battleground_template`
|
||||
DROP COLUMN `MinPlayersPerTeam`,
|
||||
DROP COLUMN `MaxPlayersPerTeam`,
|
||||
DROP COLUMN `MinLvl`,
|
||||
DROP COLUMN `MaxLvl`;
|
||||
Reference in New Issue
Block a user