Core/Battlegrounds: Replace manual criteria timer starts in battlegrounds with new GameEvents api
Port From (https://github.com/TrinityCore/TrinityCore/commit/111fc6ac6fd703bb645046e7a477a986d8519a64)
This commit is contained in:
@@ -1846,13 +1846,14 @@ namespace Game.BattleGrounds
|
|||||||
return Global.ObjectMgr.GetClosestGraveYard(player, GetPlayerTeam(player.GetGUID()), player);
|
return Global.ObjectMgr.GetClosestGraveYard(player, GetPlayerTeam(player.GetGUID()), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartCriteriaTimer(CriteriaStartEvent startEvent, uint entry)
|
public void TriggerGameEvent(uint gameEventId)
|
||||||
{
|
{
|
||||||
|
GameEvents.TriggerForMap(gameEventId, GetBgMap());
|
||||||
foreach (var guid in GetPlayers().Keys)
|
foreach (var guid in GetPlayers().Keys)
|
||||||
{
|
{
|
||||||
Player player = Global.ObjAccessor.FindPlayer(guid);
|
Player player = Global.ObjAccessor.FindPlayer(guid);
|
||||||
if (player)
|
if (player)
|
||||||
player.StartCriteriaTimer(startEvent, entry);
|
GameEvents.TriggerForPlayer(gameEventId, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ namespace Game.BattleGrounds.Zones
|
|||||||
DoorOpen(ABObjectTypes.GateH);
|
DoorOpen(ABObjectTypes.GateH);
|
||||||
|
|
||||||
// Achievement: Let's Get This Done
|
// Achievement: Let's Get This Done
|
||||||
StartCriteriaTimer(CriteriaStartEvent.SendEvent, EventStartBattle);
|
TriggerGameEvent(EventStartBattle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddPlayer(Player player)
|
public override void AddPlayer(Player player)
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ namespace Game.BattleGrounds.Zones
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Achievement: Flurry
|
// Achievement: Flurry
|
||||||
StartCriteriaTimer(CriteriaStartEvent.SendEvent, EotSMisc.EventStartBattle);
|
TriggerGameEvent(EotSMisc.EventStartBattle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddPoints(Team Team, uint Points)
|
void AddPoints(Team Team, uint Points)
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ namespace Game.BattleGrounds.Zones
|
|||||||
ToggleTimer();
|
ToggleTimer();
|
||||||
DemolisherStartState(false);
|
DemolisherStartState(false);
|
||||||
Status = SAStatus.RoundOne;
|
Status = SAStatus.RoundOne;
|
||||||
StartCriteriaTimer(CriteriaStartEvent.SendEvent, (Attackers == TeamId.Alliance) ? 23748 : 21702u);
|
TriggerGameEvent(Attackers == TeamId.Alliance ? 23748 : 21702u);
|
||||||
}
|
}
|
||||||
if (TotalTime >= SATimers.BoatStart)
|
if (TotalTime >= SATimers.BoatStart)
|
||||||
StartShips();
|
StartShips();
|
||||||
@@ -366,7 +366,7 @@ namespace Game.BattleGrounds.Zones
|
|||||||
ToggleTimer();
|
ToggleTimer();
|
||||||
DemolisherStartState(false);
|
DemolisherStartState(false);
|
||||||
Status = SAStatus.RoundTwo;
|
Status = SAStatus.RoundTwo;
|
||||||
StartCriteriaTimer(CriteriaStartEvent.SendEvent, (Attackers == TeamId.Alliance) ? 23748 : 21702u);
|
TriggerGameEvent(Attackers == TeamId.Alliance ? 23748 : 21702u);
|
||||||
// status was set to STATUS_WAIT_JOIN manually for Preparation, set it back now
|
// status was set to STATUS_WAIT_JOIN manually for Preparation, set it back now
|
||||||
SetStatus(BattlegroundStatus.InProgress);
|
SetStatus(BattlegroundStatus.InProgress);
|
||||||
foreach (var pair in GetPlayers())
|
foreach (var pair in GetPlayers())
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ namespace Game.BattleGrounds.Zones
|
|||||||
SpawnBGObject(WSGObjectTypes.DoorH4, BattlegroundConst.RespawnOneDay);
|
SpawnBGObject(WSGObjectTypes.DoorH4, BattlegroundConst.RespawnOneDay);
|
||||||
|
|
||||||
// players joining later are not eligibles
|
// players joining later are not eligibles
|
||||||
StartCriteriaTimer(CriteriaStartEvent.SendEvent, 8563);
|
TriggerGameEvent( 8563);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddPlayer(Player player)
|
public override void AddPlayer(Player player)
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ namespace Game
|
|||||||
zoneScript.ProcessEvent(target, gameEventId, source);
|
zoneScript.ProcessEvent(target, gameEventId, source);
|
||||||
|
|
||||||
Map map = refForMapAndZoneScript.GetMap();
|
Map map = refForMapAndZoneScript.GetMap();
|
||||||
if (target)
|
GameObject goTarget = target?.ToGameObject();
|
||||||
{
|
|
||||||
GameObject goTarget = target.ToGameObject();
|
|
||||||
if (goTarget != null)
|
if (goTarget != null)
|
||||||
{
|
{
|
||||||
GameObjectAI goAI = goTarget.GetAI();
|
GameObjectAI goAI = goTarget.GetAI();
|
||||||
@@ -48,13 +46,26 @@ namespace Game
|
|||||||
goAI.EventInform(gameEventId);
|
goAI.EventInform(gameEventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player sourcePlayer = source?.ToPlayer();
|
||||||
|
if (sourcePlayer != null)
|
||||||
|
TriggerForPlayer(gameEventId, sourcePlayer);
|
||||||
|
|
||||||
|
TriggerForMap(gameEventId, map, source, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void TriggerForPlayer(uint gameEventId, Player source)
|
||||||
|
{
|
||||||
|
Map map = source.GetMap();
|
||||||
|
if (map.Instanceable())
|
||||||
|
source.StartCriteriaTimer(CriteriaStartEvent.SendEvent, gameEventId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void TriggerForMap(uint gameEventId, Map map, WorldObject source = null, WorldObject target = null)
|
||||||
|
{
|
||||||
BattlegroundMap bgMap = map.ToBattlegroundMap();
|
BattlegroundMap bgMap = map.ToBattlegroundMap();
|
||||||
if (bgMap != null)
|
if (bgMap != null)
|
||||||
bgMap.GetBG().ProcessEvent(target, gameEventId, source);
|
bgMap.GetBG().ProcessEvent(target, gameEventId, source);
|
||||||
}
|
|
||||||
|
|
||||||
map.ScriptsStart(ScriptsType.Event, gameEventId, source, target);
|
map.ScriptsStart(ScriptsType.Event, gameEventId, source, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user