Skip to content

Commit

Permalink
Arena master should teleport away during an encounter.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnchyDev committed Oct 16, 2023
1 parent 61ff61a commit 5d07771
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/TrialOfStrength.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

enum ToSConstants {
TOS_MAP_ID = 44,
TOS_NPC_HANDLER = 441250,
TOS_NPC_ARENA_MASTER = 441250,

TOS_DATA_ENCOUNTER_START = 1,
TOS_DATA_ENCOUNTER_CURRENT_WAVE = 2,
Expand All @@ -27,6 +27,7 @@ enum ToSConstants {
TOS_DATA_ENCOUNTER_CURRENT_SUBWAVE = 11,
TOS_DATA_ENCOUNTER_TOTAL_SUBWAVE = 12,
TOS_DATA_ENCOUNTER_TRIAL_COMPLETED = 13,
TOS_DATA_ENCOUNTER_CHECK_ARENA_MASTER_RELOCATE = 14,
};

struct ToSWaveTemplate {
Expand Down
68 changes: 68 additions & 0 deletions src/scripts/ToSInstanceScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,27 @@ class instance_trial_of_strength : public InstanceMapScript

std::vector<Creature*> waveCreatures;

Creature* arenaMaster;
bool arenaMasterLeft;

trial_of_strength_InstanceScript(Map* map) : InstanceScript(map)
{
arenaMaster = nullptr;
arenaMasterLeft = false;

ResetEncounter();
}

void OnCreatureCreate(Creature* creature) override
{
if (creature &&
creature->GetEntry() == TOS_NPC_ARENA_MASTER)
{
arenaMaster = creature;
events.ScheduleEvent(TOS_DATA_ENCOUNTER_CHECK_ARENA_MASTER_RELOCATE, 3s);
}
}

bool IsSubWaveCleared() const
{
return encounterInProgress && GetRemainingAlive() == 0;
Expand Down Expand Up @@ -136,6 +152,51 @@ class instance_trial_of_strength : public InstanceMapScript
events.RescheduleEvent(TOS_DATA_ENCOUNTER_CHECK_FAILURE, 3s);
}
break;
case TOS_DATA_ENCOUNTER_CHECK_ARENA_MASTER_RELOCATE:
CheckArenaMasterRelocate();
events.RescheduleEvent(TOS_DATA_ENCOUNTER_CHECK_ARENA_MASTER_RELOCATE, 3s);
break;
}
}

void CheckArenaMasterRelocate()
{
if (!arenaMaster)
{
return;
}

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

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

void RelocateArenaMaster(bool returning)
{
if (!arenaMaster || !arenaMaster->IsInWorld())
{
return;
}

arenaMaster->CastSpell(arenaMaster, 64446);

if (returning)
{
arenaMaster->NearTeleportTo(244.114, -99.9485, 23.7741, 3.16135);
}
else
{
arenaMaster->NearTeleportTo(211.368, -91.809, 18.677, 4.730);
}
}

Expand Down Expand Up @@ -435,8 +496,15 @@ class instance_trial_of_strength : public InstanceMapScript
trialCompleted = false;

events.Reset();
events.ScheduleEvent(TOS_DATA_ENCOUNTER_CHECK_ARENA_MASTER_RELOCATE, 3s);

CleanupCreatures();

if (arenaMasterLeft)
{
RelocateArenaMaster(true);
arenaMasterLeft = false;
}
}
};

Expand Down

0 comments on commit 5d07771

Please sign in to comment.