Scripts/Instances: Replace manual criteria timer starts in instances with new GameEvents api

Port From (https://github.com/TrinityCore/TrinityCore/commit/1c62b0b90f879e5df6c6785c12e9a5bddd65cb48)
This commit is contained in:
hondacrx
2022-05-31 19:57:24 -04:00
parent 4b0b5df152
commit 8bbd650d0b
2 changed files with 24 additions and 6 deletions
+16 -6
View File
@@ -320,6 +320,22 @@ namespace Game.Maps
minionInfo.bossInfo.minion.Remove(minion.GetGUID());
}
// Triggers a GameEvent
// * If source is null then event is triggered for each player in the instance as "source"
public override void TriggerGameEvent(uint gameEventId, WorldObject source = null, WorldObject target = null)
{
if (source != null)
{
base.TriggerGameEvent(gameEventId, source, target);
return;
}
ProcessEvent(target, gameEventId, source);
instance.DoOnPlayers(player => GameEvents.TriggerForPlayer(gameEventId, player));
GameEvents.TriggerForMap(gameEventId, instance);
}
public Creature GetCreature(uint type)
{
return instance.GetCreature(GetObjectGuid(type));
@@ -600,12 +616,6 @@ namespace Game.Maps
instance.DoOnPlayers(player => player.UpdateCriteria(type, miscValue1, miscValue2, 0, unit));
}
// Start timed achievement for all players in instance
public void DoStartCriteriaTimer(CriteriaStartEvent startEvent, uint entry)
{
instance.DoOnPlayers(player => player.StartCriteriaTimer(startEvent, entry));
}
// Remove Auras due to Spell on all players in instance
public void DoRemoveAurasDueToSpellOnPlayers(uint spell, bool includePets = false, bool includeControlled = false)
{
+8
View File
@@ -22,6 +22,14 @@ namespace Game.Maps
{
public class ZoneScript
{
public virtual void TriggerGameEvent(uint gameEventId, WorldObject source = null, WorldObject target = null)
{
if (source != null)
GameEvents.Trigger(gameEventId, source, target);
else
ProcessEvent(null, gameEventId, null);
}
public virtual uint GetCreatureEntry(ulong guidlow, CreatureData data) { return data.Id; }
public virtual uint GetGameObjectEntry(ulong spawnId, uint entry) { return entry; }