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

This commit is contained in:
Shauren
2022-04-24 13:58:18 +02:00
parent e1abd8256b
commit 1c62b0b90f
23 changed files with 52 additions and 32 deletions

View File

@@ -21,6 +21,7 @@
#include "CreatureAI.h"
#include "CreatureAIImpl.h"
#include "DatabaseEnv.h"
#include "GameEventSender.h"
#include "GameObject.h"
#include "Group.h"
#include "InstancePackets.h"
@@ -129,6 +130,23 @@ ObjectGuid InstanceScript::GetGuidData(uint32 type) const
return GetObjectGuid(type);
}
void InstanceScript::TriggerGameEvent(uint32 gameEventId, WorldObject* source /*= nullptr*/, WorldObject* target /*= nullptr*/)
{
if (source)
{
ZoneScript::TriggerGameEvent(gameEventId, source, target);
return;
}
ProcessEvent(target, gameEventId, source);
instance->DoOnPlayers([gameEventId](Player* player)
{
GameEvents::TriggerForPlayer(gameEventId, player);
});
GameEvents::TriggerForMap(gameEventId, instance);
}
Creature* InstanceScript::GetCreature(uint32 type)
{
return instance->GetCreature(GetObjectGuid(type));
@@ -622,15 +640,6 @@ void InstanceScript::DoUpdateCriteria(CriteriaType type, uint32 miscValue1 /*= 0
});
}
// Start timed achievement for all players in instance
void InstanceScript::DoStartCriteriaTimer(CriteriaStartEvent startEvent, uint32 entry)
{
instance->DoOnPlayers([startEvent, entry](Player* player)
{
player->StartCriteriaTimer(startEvent, entry);
});
}
void InstanceScript::DoRemoveAurasDueToSpellOnPlayers(uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/)
{
instance->DoOnPlayers([this, spell, includePets, includeControlled](Player* player)