Skip to content

Commit

Permalink
Added WaveInProgress var.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnchyDev committed Oct 17, 2023
1 parent 50db07a commit c7bc932
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/scripts/ToSArenaMasterScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ToSArenaMasterScript : public CreatureScript
return true;
}

if (!iScript->IsEncounterInProgress() && waveCleared && hasMoreWaves)
if (iScript->IsEncounterInProgress() && waveCleared && hasMoreWaves)
{
AddGossipItemFor(player, GOSSIP_ICON_CHAT, Acore::StringFormatFmt("Yes, I would like to proceed to the next wave. ({})", currentWave + 1), GOSSIP_SENDER_MAIN, TOS_GOSSIP_ENCOUNTER_NEXT_WAVE);
AddGossipItemFor(player, GOSSIP_ICON_CHAT, "I would like to stop here.", GOSSIP_SENDER_MAIN, TOS_GOSSIP_ENCOUNTER_RESET);
Expand Down
21 changes: 17 additions & 4 deletions src/scripts/ToSInstanceScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class instance_trial_of_strength : public InstanceMapScript
EventMap events;

bool encounterInProgress;
bool waveInProgress;

uint32 currentWave;
uint32 totalWaves;
Expand Down Expand Up @@ -44,7 +45,7 @@ class instance_trial_of_strength : public InstanceMapScript

bool IsSubWaveCleared() const
{
return encounterInProgress && GetRemainingAlive() == 0;
return waveInProgress && GetRemainingAlive() == 0;
}

bool IsWaveCleared() const
Expand All @@ -57,6 +58,11 @@ class instance_trial_of_strength : public InstanceMapScript
return currentWave < totalWaves ? true : false;
}

bool IsWaveInProgress() const
{
return waveInProgress;
}

void SpawnNextWave(ToSWaveTemplate* waveTemplate = nullptr)
{
if (!waveTemplate)
Expand Down Expand Up @@ -165,14 +171,19 @@ class instance_trial_of_strength : public InstanceMapScript
return;
}

if (IsEncounterInProgress() && !arenaMasterLeft)
if (!IsEncounterInProgress())
{
return;
}

if (IsWaveInProgress() && !arenaMasterLeft)
{
RelocateArenaMaster(false);
arenaMasterLeft = true;
return;
}

if (IsWaveCleared() && arenaMasterLeft)
if (!IsWaveInProgress() && arenaMasterLeft)
{
RelocateArenaMaster(true);
arenaMasterLeft = false;
Expand Down Expand Up @@ -260,6 +271,7 @@ class instance_trial_of_strength : public InstanceMapScript
void SetupEncounter()
{
encounterInProgress = true;
waveInProgress = true;
waveCleared = false;

auto waveTemplate = GetWaveTemplateForWave(currentWave);
Expand Down Expand Up @@ -307,7 +319,7 @@ class instance_trial_of_strength : public InstanceMapScript
TryRewardPlayers();
CleanupCreatures();

encounterInProgress = false;
waveInProgress = false;
waveCleared = true;

if (currentWave == totalWaves)
Expand Down Expand Up @@ -485,6 +497,7 @@ class instance_trial_of_strength : public InstanceMapScript
void ResetEncounter()
{
encounterInProgress = false;
waveInProgress = false;

currentWave = 1;
totalWaves = 0;
Expand Down

0 comments on commit c7bc932

Please sign in to comment.