Core/Battlefields: Refactor Battlefield creation to be linked to host map creation instead of having globally accessible objects
Port From (https://github.com/TrinityCore/TrinityCore/commit/073a036d84365dae60a70064eb67e68f0447bd72)
This commit is contained in:
@@ -36,7 +36,7 @@ namespace Game.BattleFields
|
|||||||
|
|
||||||
public class BattleField : ZoneScript
|
public class BattleField : ZoneScript
|
||||||
{
|
{
|
||||||
public BattleField()
|
public BattleField(Map map)
|
||||||
{
|
{
|
||||||
m_IsEnabled = true;
|
m_IsEnabled = true;
|
||||||
m_DefenderTeam = TeamId.Neutral;
|
m_DefenderTeam = TeamId.Neutral;
|
||||||
@@ -47,6 +47,9 @@ namespace Game.BattleFields
|
|||||||
|
|
||||||
m_LastResurectTimer = 30 * Time.InMilliseconds;
|
m_LastResurectTimer = 30 * Time.InMilliseconds;
|
||||||
|
|
||||||
|
m_Map = map;
|
||||||
|
m_MapId = map.GetId();
|
||||||
|
|
||||||
for (byte i = 0; i < 2; ++i)
|
for (byte i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
m_players[i] = new List<ObjectGuid>();
|
m_players[i] = new List<ObjectGuid>();
|
||||||
|
|||||||
@@ -19,11 +19,16 @@ using Framework.Database;
|
|||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using Game.Maps;
|
using Game.Maps;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Game.BattleFields
|
namespace Game.BattleFields
|
||||||
{
|
{
|
||||||
public class BattleFieldManager : Singleton<BattleFieldManager>
|
public class BattleFieldManager : Singleton<BattleFieldManager>
|
||||||
{
|
{
|
||||||
|
static uint[] BattlefieldIdToMapId = { 0, 571, 732 };
|
||||||
|
static uint[] BattlefieldIdToZoneId = { 0, 4197, 5095 }; // imitate World_PVP_Area.db2
|
||||||
|
static uint[] BattlefieldIdToScriptId = { 0, 0, 0 };
|
||||||
|
|
||||||
BattleFieldManager() { }
|
BattleFieldManager() { }
|
||||||
|
|
||||||
public void InitBattlefield()
|
public void InitBattlefield()
|
||||||
@@ -43,20 +48,7 @@ namespace Game.BattleFields
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint scriptId = Global.ObjectMgr.GetScriptId(result.Read<string>(1));
|
BattlefieldIdToScriptId[(int)typeId] = Global.ObjectMgr.GetScriptId(result.Read<string>(1));
|
||||||
|
|
||||||
var bf = Global.ScriptMgr.CreateBattlefield(scriptId);
|
|
||||||
if (bf == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!bf.SetupBattlefield())
|
|
||||||
{
|
|
||||||
Log.outInfo(LogFilter.Battlefield, $"Setting up battlefield with TypeId {typeId} failed.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
_battlefieldSet.Add(bf);
|
|
||||||
Log.outInfo(LogFilter.Battlefield, $"Setting up battlefield with TypeId {typeId} succeeded.");
|
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
} while (result.NextRow());
|
} while (result.NextRow());
|
||||||
@@ -65,14 +57,44 @@ namespace Game.BattleFields
|
|||||||
Log.outInfo(LogFilter.ServerLoading, $"Loaded {count} battlefields in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
Log.outInfo(LogFilter.ServerLoading, $"Loaded {count} battlefields in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CreateBattlefieldsForMap(Map map)
|
||||||
|
{
|
||||||
|
for (uint i = 0; i < (int)BattleFieldTypes.Max; ++i)
|
||||||
|
{
|
||||||
|
if (BattlefieldIdToScriptId[i] == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (BattlefieldIdToMapId[i] != map.GetId())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
BattleField bf = Global.ScriptMgr.CreateBattlefield(BattlefieldIdToScriptId[i], map);
|
||||||
|
if (bf == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!bf.SetupBattlefield())
|
||||||
|
{
|
||||||
|
Log.outInfo(LogFilter.Battlefield, $"Setting up battlefield with TypeId {(BattleFieldTypes)i} on map {map.GetId()} instance id {map.GetInstanceId()} failed.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
_battlefieldsByMap.Add(map, bf);
|
||||||
|
Log.outInfo(LogFilter.Battlefield, $"Setting up battlefield with TypeId {(BattleFieldTypes)i} on map {map.GetId()} instance id {map.GetInstanceId()} succeeded.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DestroyBattlefieldsForMap(Map map)
|
||||||
|
{
|
||||||
|
_battlefieldsByMap.Remove(map);
|
||||||
|
}
|
||||||
|
|
||||||
public void AddZone(uint zoneId, BattleField bf)
|
public void AddZone(uint zoneId, BattleField bf)
|
||||||
{
|
{
|
||||||
_battlefieldMap[zoneId] = bf;
|
_battlefieldsByZone[(bf.GetMap(), zoneId)] = bf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandlePlayerEnterZone(Player player, uint zoneId)
|
public void HandlePlayerEnterZone(Player player, uint zoneId)
|
||||||
{
|
{
|
||||||
var bf = _battlefieldMap.LookupByKey(zoneId);
|
var bf = _battlefieldsByZone.LookupByKey((player.GetMap(), zoneId));
|
||||||
if (bf == null)
|
if (bf == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -85,7 +107,7 @@ namespace Game.BattleFields
|
|||||||
|
|
||||||
public void HandlePlayerLeaveZone(Player player, uint zoneId)
|
public void HandlePlayerLeaveZone(Player player, uint zoneId)
|
||||||
{
|
{
|
||||||
var bf = _battlefieldMap.LookupByKey(zoneId);
|
var bf = _battlefieldsByZone.LookupByKey((player.GetMap(), zoneId));
|
||||||
if (bf == null)
|
if (bf == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -97,9 +119,14 @@ namespace Game.BattleFields
|
|||||||
Log.outDebug(LogFilter.Battlefield, "Player {0} left battlefield id {1}", player.GetGUID().ToString(), bf.GetTypeId());
|
Log.outDebug(LogFilter.Battlefield, "Player {0} left battlefield id {1}", player.GetGUID().ToString(), bf.GetTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BattleField GetBattlefieldToZoneId(uint zoneId)
|
public bool IsWorldPvpArea(uint zoneId)
|
||||||
{
|
{
|
||||||
var bf = _battlefieldMap.LookupByKey(zoneId);
|
return BattlefieldIdToZoneId.Contains(zoneId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BattleField GetBattlefieldToZoneId(Map map, uint zoneId)
|
||||||
|
{
|
||||||
|
var bf = _battlefieldsByZone.LookupByKey((map, zoneId));
|
||||||
if (bf == null)
|
if (bf == null)
|
||||||
{
|
{
|
||||||
// no handle for this zone, return
|
// no handle for this zone, return
|
||||||
@@ -112,30 +139,12 @@ namespace Game.BattleFields
|
|||||||
return bf;
|
return bf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BattleField GetBattlefieldByBattleId(uint battleId)
|
public BattleField GetBattlefieldByBattleId(Map map, uint battleId)
|
||||||
{
|
{
|
||||||
foreach (var bf in _battlefieldSet)
|
var battlefields = _battlefieldsByMap.LookupByKey(map);
|
||||||
{
|
foreach (var battlefield in battlefields)
|
||||||
if (bf.GetBattleId() == battleId)
|
if (battlefield.GetBattleId() == battleId)
|
||||||
return bf;
|
return battlefield;
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BattleField GetBattlefieldByQueueId(ulong queueId)
|
|
||||||
{
|
|
||||||
foreach (var bf in _battlefieldSet)
|
|
||||||
if (bf.GetQueueId() == queueId)
|
|
||||||
return bf;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZoneScript GetZoneScript(uint zoneId)
|
|
||||||
{
|
|
||||||
var bf = _battlefieldMap.LookupByKey(zoneId);
|
|
||||||
if (bf != null)
|
|
||||||
return bf;
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -145,19 +154,20 @@ namespace Game.BattleFields
|
|||||||
_updateTimer += diff;
|
_updateTimer += diff;
|
||||||
if (_updateTimer > 1000)
|
if (_updateTimer > 1000)
|
||||||
{
|
{
|
||||||
foreach (var bf in _battlefieldSet)
|
foreach (var (map, battlefield) in _battlefieldsByMap)
|
||||||
if (bf.IsEnabled())
|
if (battlefield.IsEnabled())
|
||||||
bf.Update(_updateTimer);
|
battlefield.Update(_updateTimer);
|
||||||
|
|
||||||
_updateTimer = 0;
|
_updateTimer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// contains all initiated battlefield events
|
// contains all initiated battlefield events
|
||||||
// used when initing / cleaning up
|
// used when initing / cleaning up
|
||||||
List<BattleField> _battlefieldSet = new();
|
MultiMap<Map, BattleField> _battlefieldsByMap = new();
|
||||||
// maps the zone ids to an battlefield event
|
// maps the zone ids to an battlefield event
|
||||||
// used in player event handling
|
// used in player event handling
|
||||||
Dictionary<uint, BattleField> _battlefieldMap = new();
|
Dictionary<(Map map, uint zoneId), BattleField> _battlefieldsByZone = new();
|
||||||
// update interval
|
// update interval
|
||||||
uint _updateTimer;
|
uint _updateTimer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Game.Chat
|
|||||||
[Command("enable", RBACPermissions.CommandBfEnable)]
|
[Command("enable", RBACPermissions.CommandBfEnable)]
|
||||||
static bool HandleBattlefieldEnable(CommandHandler handler, uint battleId)
|
static bool HandleBattlefieldEnable(CommandHandler handler, uint battleId)
|
||||||
{
|
{
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(battleId);
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(handler.GetPlayer().GetMap(), battleId);
|
||||||
if (bf == null)
|
if (bf == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ namespace Game.Chat
|
|||||||
[Command("start", RBACPermissions.CommandBfStart)]
|
[Command("start", RBACPermissions.CommandBfStart)]
|
||||||
static bool HandleBattlefieldStart(CommandHandler handler, uint battleId)
|
static bool HandleBattlefieldStart(CommandHandler handler, uint battleId)
|
||||||
{
|
{
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(battleId);
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(handler.GetPlayer().GetMap(), battleId);
|
||||||
if (bf == null)
|
if (bf == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ namespace Game.Chat
|
|||||||
[Command("stop", RBACPermissions.CommandBfStop)]
|
[Command("stop", RBACPermissions.CommandBfStop)]
|
||||||
static bool HandleBattlefieldEnd(CommandHandler handler, uint battleId)
|
static bool HandleBattlefieldEnd(CommandHandler handler, uint battleId)
|
||||||
{
|
{
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(battleId);
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(handler.GetPlayer().GetMap(), battleId);
|
||||||
if (bf == null)
|
if (bf == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ namespace Game.Chat
|
|||||||
[Command("switch", RBACPermissions.CommandBfSwitch)]
|
[Command("switch", RBACPermissions.CommandBfSwitch)]
|
||||||
static bool HandleBattlefieldSwitch(CommandHandler handler, uint battleId)
|
static bool HandleBattlefieldSwitch(CommandHandler handler, uint battleId)
|
||||||
{
|
{
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(battleId);
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(handler.GetPlayer().GetMap(), battleId);
|
||||||
if (bf == null)
|
if (bf == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ namespace Game.Chat
|
|||||||
[Command("timer", RBACPermissions.CommandBfTimer)]
|
[Command("timer", RBACPermissions.CommandBfTimer)]
|
||||||
static bool HandleBattlefieldTimer(CommandHandler handler, uint battleId, uint time)
|
static bool HandleBattlefieldTimer(CommandHandler handler, uint battleId, uint time)
|
||||||
{
|
{
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(battleId);
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldByBattleId(handler.GetPlayer().GetMap(), battleId);
|
||||||
if (bf == null)
|
if (bf == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -691,7 +691,7 @@ namespace Game.Chat
|
|||||||
nearestLoc = bg.GetClosestGraveYard(player);
|
nearestLoc = bg.GetClosestGraveYard(player);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetZoneId());
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetMap(), player.GetZoneId());
|
||||||
if (bf != null)
|
if (bf != null)
|
||||||
nearestLoc = bf.GetClosestGraveYard(player);
|
nearestLoc = bf.GetClosestGraveYard(player);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1434,7 +1434,7 @@ namespace Game.Entities
|
|||||||
return (ZoneScript)instanceMap.GetInstanceScript();
|
return (ZoneScript)instanceMap.GetInstanceScript();
|
||||||
else if (!map.IsBattlegroundOrArena())
|
else if (!map.IsBattlegroundOrArena())
|
||||||
{
|
{
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(GetZoneId());
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(map, GetZoneId());
|
||||||
if (bf != null)
|
if (bf != null)
|
||||||
return bf;
|
return bf;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ namespace Game.Entities
|
|||||||
if (area.HasFlag(AreaFlags.Arena))
|
if (area.HasFlag(AreaFlags.Arena))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (Global.BattleFieldMgr.GetBattlefieldToZoneId(area.Id) != null)
|
if (Global.BattleFieldMgr.IsWorldPvpArea(area.Id))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
area = CliDB.AreaTableStorage.LookupByKey(area.ParentAreaID);
|
area = CliDB.AreaTableStorage.LookupByKey(area.ParentAreaID);
|
||||||
|
|||||||
@@ -4018,7 +4018,7 @@ namespace Game.Entities
|
|||||||
ClosestGrave = bg.GetClosestGraveYard(this);
|
ClosestGrave = bg.GetClosestGraveYard(this);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(GetZoneId());
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(GetMap(), GetZoneId());
|
||||||
if (bf != null)
|
if (bf != null)
|
||||||
ClosestGrave = bf.GetClosestGraveYard(this);
|
ClosestGrave = bf.GetClosestGraveYard(this);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -967,7 +967,7 @@ namespace Game.Entities
|
|||||||
if (pvp != null)
|
if (pvp != null)
|
||||||
pvp.HandleKill(player, victim);
|
pvp.HandleKill(player, victim);
|
||||||
|
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetZoneId());
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetMap(), player.GetZoneId());
|
||||||
if (bf != null)
|
if (bf != null)
|
||||||
bf.HandleKill(player, victim);
|
bf.HandleKill(player, victim);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -643,7 +643,7 @@ namespace Game
|
|||||||
if (bg != null)
|
if (bg != null)
|
||||||
Global.BattlegroundMgr.SendAreaSpiritHealerQuery(GetPlayer(), bg, areaSpiritHealerQuery.HealerGuid);
|
Global.BattlegroundMgr.SendAreaSpiritHealerQuery(GetPlayer(), bg, areaSpiritHealerQuery.HealerGuid);
|
||||||
|
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(GetPlayer().GetZoneId());
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(GetPlayer().GetMap(), GetPlayer().GetZoneId());
|
||||||
if (bf != null)
|
if (bf != null)
|
||||||
bf.SendAreaSpiritHealerQuery(GetPlayer(), areaSpiritHealerQuery.HealerGuid);
|
bf.SendAreaSpiritHealerQuery(GetPlayer(), areaSpiritHealerQuery.HealerGuid);
|
||||||
}
|
}
|
||||||
@@ -662,7 +662,7 @@ namespace Game
|
|||||||
if (bg)
|
if (bg)
|
||||||
bg.AddPlayerToResurrectQueue(areaSpiritHealerQueue.HealerGuid, GetPlayer().GetGUID());
|
bg.AddPlayerToResurrectQueue(areaSpiritHealerQueue.HealerGuid, GetPlayer().GetGUID());
|
||||||
|
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(GetPlayer().GetZoneId());
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(GetPlayer().GetMap(), GetPlayer().GetZoneId());
|
||||||
if (bf != null)
|
if (bf != null)
|
||||||
bf.AddPlayerToResurrectQueue(areaSpiritHealerQueue.HealerGuid, GetPlayer().GetGUID());
|
bf.AddPlayerToResurrectQueue(areaSpiritHealerQueue.HealerGuid, GetPlayer().GetGUID());
|
||||||
}
|
}
|
||||||
@@ -673,7 +673,7 @@ namespace Game
|
|||||||
if (GetPlayer().IsInFlight())
|
if (GetPlayer().IsInFlight())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(GetPlayer().GetZoneId());
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(GetPlayer().GetMap(), GetPlayer().GetZoneId());
|
||||||
if (bf != null)
|
if (bf != null)
|
||||||
{
|
{
|
||||||
bf.PlayerAskToLeave(_player);
|
bf.PlayerAskToLeave(_player);
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ namespace Game.Maps
|
|||||||
_worldStateValues = Global.WorldStateMgr.GetInitialWorldStatesForMap(this);
|
_worldStateValues = Global.WorldStateMgr.GetInitialWorldStatesForMap(this);
|
||||||
|
|
||||||
Global.OutdoorPvPMgr.CreateOutdoorPvPForMap(this);
|
Global.OutdoorPvPMgr.CreateOutdoorPvPForMap(this);
|
||||||
|
Global.BattleFieldMgr.CreateBattlefieldsForMap(this);
|
||||||
|
|
||||||
Global.ScriptMgr.OnCreateMap(this);
|
Global.ScriptMgr.OnCreateMap(this);
|
||||||
}
|
}
|
||||||
@@ -114,6 +115,7 @@ namespace Game.Maps
|
|||||||
Global.MapMgr.DecreaseScheduledScriptCount((uint)m_scriptSchedule.Count);
|
Global.MapMgr.DecreaseScheduledScriptCount((uint)m_scriptSchedule.Count);
|
||||||
|
|
||||||
Global.OutdoorPvPMgr.DestroyOutdoorPvPForMap(this);
|
Global.OutdoorPvPMgr.DestroyOutdoorPvPForMap(this);
|
||||||
|
Global.BattleFieldMgr.DestroyBattlefieldsForMap(this);
|
||||||
|
|
||||||
if (m_parentMap == this)
|
if (m_parentMap == this)
|
||||||
m_childTerrainMaps = null;
|
m_childTerrainMaps = null;
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ namespace Game.Scripting
|
|||||||
|
|
||||||
public override bool IsDatabaseBound() { return true; }
|
public override bool IsDatabaseBound() { return true; }
|
||||||
|
|
||||||
public virtual BattleField GetBattlefield() { return null; }
|
public virtual BattleField GetBattlefield(Map map) { return null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BattlegroundScript : ScriptObject
|
public class BattlegroundScript : ScriptObject
|
||||||
|
|||||||
@@ -715,9 +715,9 @@ namespace Game.Scripting
|
|||||||
}
|
}
|
||||||
|
|
||||||
//BattlefieldScript
|
//BattlefieldScript
|
||||||
public BattleField CreateBattlefield(uint scriptId)
|
public BattleField CreateBattlefield(uint scriptId, Map map)
|
||||||
{
|
{
|
||||||
return RunScriptRet<BattlefieldScript, BattleField>(p => p.GetBattlefield(), scriptId, null);
|
return RunScriptRet<BattlefieldScript, BattleField>(p => p.GetBattlefield(map), scriptId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
//BattlegroundScript
|
//BattlegroundScript
|
||||||
|
|||||||
@@ -4275,7 +4275,7 @@ namespace Game.Spells
|
|||||||
Battleground bg = target.ToPlayer().GetBattleground();
|
Battleground bg = target.ToPlayer().GetBattleground();
|
||||||
if (bg)
|
if (bg)
|
||||||
bg.RemovePlayerFromResurrectQueue(target.GetGUID());
|
bg.RemovePlayerFromResurrectQueue(target.GetGUID());
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(target.GetZoneId());
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(target.GetMap(), target.GetZoneId());
|
||||||
if (bf != null)
|
if (bf != null)
|
||||||
bf.RemovePlayerFromResurrectQueue(target.GetGUID());
|
bf.RemovePlayerFromResurrectQueue(target.GetGUID());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5731,7 +5731,7 @@ namespace Game.Spells
|
|||||||
// allow always ghost flight spells
|
// allow always ghost flight spells
|
||||||
if (m_originalCaster != null && m_originalCaster.IsTypeId(TypeId.Player) && m_originalCaster.IsAlive())
|
if (m_originalCaster != null && m_originalCaster.IsTypeId(TypeId.Player) && m_originalCaster.IsAlive())
|
||||||
{
|
{
|
||||||
BattleField Bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(m_originalCaster.GetZoneId());
|
BattleField Bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(m_originalCaster.GetMap(), m_originalCaster.GetZoneId());
|
||||||
var area = CliDB.AreaTableStorage.LookupByKey(m_originalCaster.GetAreaId());
|
var area = CliDB.AreaTableStorage.LookupByKey(m_originalCaster.GetAreaId());
|
||||||
if (area != null)
|
if (area != null)
|
||||||
if (area.HasFlag(AreaFlags.NoFlyZone) || (Bf != null && !Bf.CanFlyIn()))
|
if (area.HasFlag(AreaFlags.NoFlyZone) || (Bf != null && !Bf.CanFlyIn()))
|
||||||
|
|||||||
@@ -4922,7 +4922,7 @@ namespace Game.Entities
|
|||||||
if (!player)
|
if (!player)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BattleField Bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetZoneId());
|
BattleField Bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetMap(), player.GetZoneId());
|
||||||
if (Bf == null || Bf.CanFlyIn() || (!player.HasAuraType(AuraType.ModIncreaseMountedFlightSpeed) && !player.HasAuraType(AuraType.Fly)))
|
if (Bf == null || Bf.CanFlyIn() || (!player.HasAuraType(AuraType.ModIncreaseMountedFlightSpeed) && !player.HasAuraType(AuraType.Fly)))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
@@ -4933,7 +4933,7 @@ namespace Game.Entities
|
|||||||
if (!player)
|
if (!player)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetZoneId());
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetMap(), player.GetZoneId());
|
||||||
|
|
||||||
if (bf == null || bf.GetTypeId() != (int)BattleFieldTypes.WinterGrasp)
|
if (bf == null || bf.GetTypeId() != (int)BattleFieldTypes.WinterGrasp)
|
||||||
return false;
|
return false;
|
||||||
@@ -4953,7 +4953,7 @@ namespace Game.Entities
|
|||||||
if (!player)
|
if (!player)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BattleField battlefieldWG = Global.BattleFieldMgr.GetBattlefieldByBattleId(1);
|
BattleField battlefieldWG = Global.BattleFieldMgr.GetBattlefieldByBattleId(player.GetMap(), 1);
|
||||||
if (battlefieldWG != null)
|
if (battlefieldWG != null)
|
||||||
return battlefieldWG.IsEnabled() && (player.GetTeamId() == battlefieldWG.GetDefenderTeam()) && !battlefieldWG.IsWarTime();
|
return battlefieldWG.IsEnabled() && (player.GetTeamId() == battlefieldWG.GetDefenderTeam()) && !battlefieldWG.IsWarTime();
|
||||||
break;
|
break;
|
||||||
@@ -4963,7 +4963,7 @@ namespace Game.Entities
|
|||||||
if (!player)
|
if (!player)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetZoneId());
|
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetMap(), player.GetZoneId());
|
||||||
if (bf != null)
|
if (bf != null)
|
||||||
return bf.IsWarTime();
|
return bf.IsWarTime();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -16,25 +16,25 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using Framework.Constants;
|
using Framework.Constants;
|
||||||
|
using Game.AI;
|
||||||
using Game.DataStorage;
|
using Game.DataStorage;
|
||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using Game.Networking.Packets;
|
using Game.Maps;
|
||||||
|
using Game.Scripting;
|
||||||
using Game.Spells;
|
using Game.Spells;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Game.Scripting;
|
|
||||||
using Game.AI;
|
|
||||||
|
|
||||||
namespace Game.BattleFields
|
namespace Game.BattleFields
|
||||||
{
|
{
|
||||||
class BattlefieldWG : BattleField
|
class BattlefieldWG : BattleField
|
||||||
{
|
{
|
||||||
|
public BattlefieldWG(Map map) : base(map) { }
|
||||||
|
|
||||||
public override bool SetupBattlefield()
|
public override bool SetupBattlefield()
|
||||||
{
|
{
|
||||||
m_TypeId = (uint)BattleFieldTypes.WinterGrasp; // See enum BattlefieldTypes
|
m_TypeId = (uint)BattleFieldTypes.WinterGrasp; // See enum BattlefieldTypes
|
||||||
m_BattleId = BattlefieldIds.WG;
|
m_BattleId = BattlefieldIds.WG;
|
||||||
m_ZoneId = (uint)AreaId.Wintergrasp;
|
m_ZoneId = (uint)AreaId.Wintergrasp;
|
||||||
m_MapId = WGConst.MapId;
|
|
||||||
m_Map = Global.MapMgr.CreateBaseMap(m_MapId);
|
|
||||||
|
|
||||||
InitStalker(WGNpcs.Stalker, WGConst.WintergraspStalkerPos);
|
InitStalker(WGNpcs.Stalker, WGConst.WintergraspStalkerPos);
|
||||||
|
|
||||||
@@ -1149,6 +1149,26 @@ namespace Game.BattleFields
|
|||||||
}
|
}
|
||||||
|
|
||||||
_state = (WGGameObjectState)Global.WorldStateMgr.GetValue((int)_worldState, _wg.GetMap());
|
_state = (WGGameObjectState)Global.WorldStateMgr.GetValue((int)_worldState, _wg.GetMap());
|
||||||
|
if (_state == WGGameObjectState.None)
|
||||||
|
{
|
||||||
|
// set to default state based on type
|
||||||
|
switch (_teamControl)
|
||||||
|
{
|
||||||
|
case TeamId.Alliance:
|
||||||
|
_state = WGGameObjectState.AllianceIntact;
|
||||||
|
break;
|
||||||
|
case TeamId.Horde:
|
||||||
|
_state = WGGameObjectState.HordeIntact;
|
||||||
|
break;
|
||||||
|
case TeamId.Neutral:
|
||||||
|
_state = WGGameObjectState.NeutralIntact;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Global.WorldStateMgr.SetValueAndSaveInDb((int)_worldState, (int)_state, false, _wg.GetMap());
|
||||||
|
}
|
||||||
|
|
||||||
switch (_state)
|
switch (_state)
|
||||||
{
|
{
|
||||||
case WGGameObjectState.NeutralIntact:
|
case WGGameObjectState.NeutralIntact:
|
||||||
@@ -1556,9 +1576,9 @@ namespace Game.BattleFields
|
|||||||
{
|
{
|
||||||
public Battlefield_wintergrasp() : base("battlefield_wg") { }
|
public Battlefield_wintergrasp() : base("battlefield_wg") { }
|
||||||
|
|
||||||
public override BattleField GetBattlefield()
|
public override BattleField GetBattlefield(Map map)
|
||||||
{
|
{
|
||||||
return new BattlefieldWG();
|
return new BattlefieldWG(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1572,7 +1592,7 @@ namespace Game.BattleFields
|
|||||||
if (!killer || !killer.IsPlayer())
|
if (!killer || !killer.IsPlayer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BattlefieldWG wintergrasp = (BattlefieldWG)Global.BattleFieldMgr.GetBattlefieldByBattleId(BattlefieldIds.WG);
|
BattlefieldWG wintergrasp = (BattlefieldWG)Global.BattleFieldMgr.GetBattlefieldByBattleId(killer.GetMap(), BattlefieldIds.WG);
|
||||||
if (wintergrasp == null)
|
if (wintergrasp == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user