-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instance: Implement partially generalized example for triggering even…
…ts based on locations player enter Basically idea is serverside areatriggers
- Loading branch information
1 parent
62636be
commit c91fa41
Showing
4 changed files
with
39 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,18 +32,33 @@ instance_shattered_halls::instance_shattered_halls(Map* pMap) : ScriptedInstance | |
m_team(0), | ||
m_executionStage(0), | ||
m_prisonersLeft(3), | ||
m_legionnaireIntroTimer(1000), | ||
m_gauntletStopped(false) | ||
{ | ||
Initialize(); | ||
} | ||
|
||
enum SHHActions | ||
{ | ||
SHH_TRIGGER_LEGIONNAIRE, | ||
SHH_ACTION_MAX, | ||
}; | ||
|
||
void instance_shattered_halls::Initialize() | ||
{ | ||
memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); | ||
GauntletReset(); | ||
instance->GetVariableManager().SetVariable(WORLD_STATE_LEGIONNAIRE_002, 0); | ||
instance->GetVariableManager().SetVariable(WORLD_STATE_LEGIONNAIRE_003, 0); | ||
|
||
// Event got triggered on wotlk classic when player moved at | ||
// Position: X: 69.95503 Y: 124.538864 Z: -13.209421 O: 1.5825446 | ||
auto posCheck = [](Unit const* unit) -> bool { return unit->GetPositionY() > 124.5f; }; | ||
auto successEvent = [&]() | ||
{ | ||
// Trigger Legionnaire group 04 and 05 | ||
instance->GetVariableManager().SetVariable(WORLD_STATE_LEGIONNAIRE_003, 1); | ||
}; | ||
AddInstanceEvent(SHH_TRIGGER_LEGIONNAIRE, posCheck, successEvent); | ||
} | ||
|
||
void instance_shattered_halls::OnPlayerEnter(Player* pPlayer) | ||
|
@@ -388,25 +403,7 @@ void instance_shattered_halls::DoBeginArcherAttack(bool leftOrRight) | |
|
||
void instance_shattered_halls::Update(uint32 diff) | ||
{ | ||
if (m_legionnaireIntroTimer) | ||
{ | ||
if (m_legionnaireIntroTimer <= diff) | ||
{ | ||
m_legionnaireIntroTimer = 1000; | ||
for (const auto& data : instance->GetPlayers()) | ||
{ | ||
// Event got triggered on wotlk classic when player moved at | ||
// Position: X: 69.95503 Y: 124.538864 Z: -13.209421 O: 1.5825446 | ||
if (data.getSource()->GetPositionY() > 124.5f) | ||
{ | ||
m_legionnaireIntroTimer = 0; | ||
// Trigger Legionnaire group 04 and 05 | ||
instance->GetVariableManager().SetVariable(WORLD_STATE_LEGIONNAIRE_003, 1); | ||
} | ||
} | ||
} | ||
else m_legionnaireIntroTimer -= diff; | ||
} | ||
UpdateTimers(diff); | ||
|
||
if (m_auiEncounter[TYPE_GAUNTLET] == IN_PROGRESS) | ||
{ | ||
|
@@ -551,6 +548,21 @@ void instance_shattered_halls::Update(uint32 diff) | |
m_executionTimer -= diff; | ||
} | ||
|
||
void instance_shattered_halls::AddInstanceEvent(uint32 id, std::function<bool(Unit const*)> check, std::function<void()> successEvent) | ||
{ | ||
AddCustomAction(id, false, [instance = this->instance, check = check, successEvent = successEvent]() | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
killerwife
Author
Contributor
|
||
{ | ||
for (const auto& data : instance->GetPlayers()) | ||
{ | ||
if (check(data.getSource())) | ||
{ | ||
successEvent(); | ||
return; | ||
} | ||
} | ||
}); | ||
} | ||
|
||
void instance_shattered_halls::FailGauntlet() | ||
{ | ||
// If success despawn all, else respawn permanents | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Is this called on every update and never disabled?