Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Jan 14, 2025
1 parent cc0179a commit d795d20
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ EndScriptData */
#include "AI/ScriptDevAI/include/sc_common.h"
#include "ruins_of_ahnqiraj.h"

instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj(Map* pMap) : ScriptedInstance(pMap),
instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj(Map* map) : ScriptedInstance(map),
m_uiArmyDelayTimer(0),
m_uiCurrentArmyWave(0)
m_currentArmyWave(0)
{
Initialize();
}
Expand All @@ -36,21 +36,21 @@ void instance_ruins_of_ahnqiraj::Initialize()
memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
}

void instance_ruins_of_ahnqiraj::OnPlayerEnter(Player* /*pPlayer*/)
void instance_ruins_of_ahnqiraj::OnPlayerEnter(Player* /*player*/)
{
// Spawn andorov if necessary
if (m_auiEncounter[TYPE_KURINNAXX] == DONE)
if (GetData(TYPE_KURINNAXX) == DONE)
DoSpawnAndorovIfCan();
}

void instance_ruins_of_ahnqiraj::OnCreatureCreate(Creature* pCreature)
void instance_ruins_of_ahnqiraj::OnCreatureCreate(Creature* creature)
{
switch (pCreature->GetEntry())
switch (creature->GetEntry())
{
case NPC_OSSIRIAN_TRIGGER:
{
GuidVector& vector = m_npcEntryGuidCollection[pCreature->GetEntry()];
vector.push_back(pCreature->GetObjectGuid());
GuidVector& vector = m_npcEntryGuidCollection[creature->GetEntry()];
vector.push_back(creature->GetObjectGuid());
std::sort(vector.begin(), vector.end(), [&](ObjectGuid const& a, ObjectGuid const& b) -> bool
{
return a.GetCounter() < b.GetCounter();
Expand All @@ -68,10 +68,10 @@ void instance_ruins_of_ahnqiraj::OnCreatureCreate(Creature* pCreature)
case NPC_CAPTAIN_DRENN:
case NPC_CAPTAIN_TUUBID:
case NPC_CAPTAIN_QEEZ:
m_npcEntryGuidStore[pCreature->GetEntry()] = pCreature->GetObjectGuid();
m_npcEntryGuidStore[creature->GetEntry()] = creature->GetObjectGuid();
break;
case NPC_KALDOREI_ELITE:
m_lKaldoreiGuidList.push_back(pCreature->GetObjectGuid());
m_lKaldoreiGuidList.push_back(creature->GetObjectGuid());
break;
}
}
Expand All @@ -82,9 +82,9 @@ void instance_ruins_of_ahnqiraj::OnObjectCreate(GameObject* go)
m_goEntryGuidCollection[go->GetEntry()].push_back(go->GetObjectGuid());
}

void instance_ruins_of_ahnqiraj::OnCreatureEnterCombat(Creature* pCreature)
void instance_ruins_of_ahnqiraj::OnCreatureEnterCombat(Creature* creature)
{
switch (pCreature->GetEntry())
switch (creature->GetEntry())
{
case NPC_KURINNAXX: SetData(TYPE_KURINNAXX, IN_PROGRESS); break;
case NPC_MOAM: SetData(TYPE_MOAM, IN_PROGRESS); break;
Expand All @@ -94,9 +94,9 @@ void instance_ruins_of_ahnqiraj::OnCreatureEnterCombat(Creature* pCreature)
}
}

void instance_ruins_of_ahnqiraj::OnCreatureEvade(Creature* pCreature)
void instance_ruins_of_ahnqiraj::OnCreatureEvade(Creature* creature)
{
switch (pCreature->GetEntry())
switch (creature->GetEntry())
{
case NPC_KURINNAXX: SetData(TYPE_KURINNAXX, FAIL); break;
case NPC_MOAM: SetData(TYPE_MOAM, FAIL); break;
Expand All @@ -105,7 +105,7 @@ void instance_ruins_of_ahnqiraj::OnCreatureEvade(Creature* pCreature)
case NPC_OSSIRIAN: SetData(TYPE_OSSIRIAN, FAIL); break;
case NPC_RAJAXX:
// Rajaxx yells on evade
// DoScriptText(SAY_DEAGGRO, pCreature); - unconfirmed
// DoScriptText(SAY_DEAGGRO, creature); - unconfirmed
// no break;
case NPC_COLONEL_ZERRAN:
case NPC_MAJOR_PAKKON:
Expand All @@ -119,9 +119,9 @@ void instance_ruins_of_ahnqiraj::OnCreatureEvade(Creature* pCreature)
}
}

void instance_ruins_of_ahnqiraj::OnCreatureDeath(Creature* pCreature)
void instance_ruins_of_ahnqiraj::OnCreatureDeath(Creature* creature)
{
switch (pCreature->GetEntry())
switch (creature->GetEntry())
{
case NPC_KURINNAXX: SetData(TYPE_KURINNAXX, DONE); break;
case NPC_RAJAXX: SetData(TYPE_RAJAXX, DONE); break;
Expand All @@ -144,13 +144,13 @@ void instance_ruins_of_ahnqiraj::OnCreatureDeath(Creature* pCreature)
return;

// Check if the dead creature belongs to the current wave
if (m_sArmyWavesGuids[m_uiCurrentArmyWave - 1].find(pCreature->GetObjectGuid()) != m_sArmyWavesGuids[m_uiCurrentArmyWave - 1].end())
if (m_sArmyWavesGuids[m_currentArmyWave - 1].find(creature->GetObjectGuid()) != m_sArmyWavesGuids[m_currentArmyWave - 1].end())
{
m_sArmyWavesGuids[m_uiCurrentArmyWave - 1].erase(pCreature->GetObjectGuid());
m_sArmyWavesGuids[m_currentArmyWave - 1].erase(creature->GetObjectGuid());

// If all the soldiers from the current wave are dead, then send the next one
if (m_sArmyWavesGuids[m_uiCurrentArmyWave - 1].empty())
DoSendNextArmyWave();
if (m_sArmyWavesGuids[m_currentArmyWave - 1].empty())
m_uiArmyDelayTimer = 1;
}
break;
}
Expand All @@ -176,25 +176,30 @@ void instance_ruins_of_ahnqiraj::OnCreatureRespawn(Creature* creature)
}
}

void instance_ruins_of_ahnqiraj::SetData(uint32 uiType, uint32 uiData)
void instance_ruins_of_ahnqiraj::OnCreatureGroupDespawn(CreatureGroup* group, Creature* creature)
{

}

void instance_ruins_of_ahnqiraj::SetData(uint32 type, uint32 data)
{
switch (uiType)
switch (type)
{
case TYPE_KURINNAXX:
if (uiData == DONE)
if (data == DONE)
{
DoSpawnAndorovIfCan();
// Yell after kurinnaxx
if (Creature* ossirian = GetSingleCreatureFromStorage(NPC_OSSIRIAN))
DoScriptText(SAY_OSSIRIAN_INTRO, ossirian); // targets kurinnaxx in sniff
}
m_auiEncounter[uiType] = uiData;
m_auiEncounter[type] = data;
break;
case TYPE_RAJAXX:
m_auiEncounter[uiType] = uiData;
if (uiData == IN_PROGRESS)
m_auiEncounter[type] = data;
if (data == IN_PROGRESS)
DoSortArmyWaves();
if (uiData == DONE)
if (data == DONE)
{
if (Creature* andorov = GetSingleCreatureFromStorage(NPC_GENERAL_ANDOROV))
if (andorov->IsAlive())
Expand All @@ -205,7 +210,7 @@ void instance_ruins_of_ahnqiraj::SetData(uint32 uiType, uint32 uiData)
case TYPE_BURU:
case TYPE_AYAMISS:
case TYPE_OSSIRIAN:
if (uiType == FAIL)
if (type == FAIL)
{
GuidVector crystals;
GetGameObjectGuidVectorFromStorage(GO_OSSIRIAN_CRYSTAL, crystals);
Expand All @@ -219,11 +224,11 @@ void instance_ruins_of_ahnqiraj::SetData(uint32 uiType, uint32 uiData)
}
m_goEntryGuidCollection[GO_OSSIRIAN_CRYSTAL].resize(1); // keeps first
}
m_auiEncounter[uiType] = uiData;
m_auiEncounter[type] = data;
break;
}

if (uiData == DONE)
if (data == DONE)
{
OUT_SAVE_INST_DATA;

Expand All @@ -238,10 +243,10 @@ void instance_ruins_of_ahnqiraj::SetData(uint32 uiType, uint32 uiData)
}
}

uint32 instance_ruins_of_ahnqiraj::GetData(uint32 uiType) const
uint32 instance_ruins_of_ahnqiraj::GetData(uint32 type) const
{
if (uiType < MAX_ENCOUNTER)
return m_auiEncounter[uiType];
if (type < MAX_ENCOUNTER)
return m_auiEncounter[type];

return 0;
}
Expand All @@ -251,12 +256,12 @@ void instance_ruins_of_ahnqiraj::DoSpawnAndorovIfCan()
if (GetSingleCreatureFromStorage(NPC_GENERAL_ANDOROV))
return;

Player* pPlayer = GetPlayerInMap();
if (!pPlayer)
Player* player = GetPlayerInMap();
if (!player)
return;

for (const auto& aAndorovSpawnLoc : aAndorovSpawnLocs)
pPlayer->SummonCreature(aAndorovSpawnLoc.m_uiEntry, aAndorovSpawnLoc.m_fX, aAndorovSpawnLoc.m_fY, aAndorovSpawnLoc.m_fZ, aAndorovSpawnLoc.m_fO, TEMPSPAWN_DEAD_DESPAWN, 0);
player->SummonCreature(aAndorovSpawnLoc.m_uiEntry, aAndorovSpawnLoc.m_fX, aAndorovSpawnLoc.m_fY, aAndorovSpawnLoc.m_fZ, aAndorovSpawnLoc.m_fO, TEMPSPAWN_DEAD_DESPAWN, 0);
}

void instance_ruins_of_ahnqiraj::Load(const char* chrIn)
Expand All @@ -283,19 +288,19 @@ void instance_ruins_of_ahnqiraj::Load(const char* chrIn)
OUT_LOAD_INST_DATA_COMPLETE;
}

void instance_ruins_of_ahnqiraj::Update(uint32 uiDiff)
void instance_ruins_of_ahnqiraj::Update(uint32 diff)
{
if (GetData(TYPE_RAJAXX) == IN_PROGRESS)
{
if (m_uiArmyDelayTimer)
{
if (m_uiArmyDelayTimer <= uiDiff)
if (m_uiArmyDelayTimer <= diff)
{
DoSendNextArmyWave();
m_uiArmyDelayTimer = 2 * MINUTE * IN_MILLISECONDS;
m_uiArmyDelayTimer = 3 * MINUTE * IN_MILLISECONDS;
}
else
m_uiArmyDelayTimer -= uiDiff;
m_uiArmyDelayTimer -= diff;
}
}
}
Expand All @@ -312,24 +317,28 @@ void instance_ruins_of_ahnqiraj::DoSortArmyWaves()
m_sArmyWavesGuids[i].clear();
lCreatureList.clear();

if (Creature* pTemp = GetSingleCreatureFromStorage(aArmySortingParameters[i].m_uiEntry))
if (Creature* leader = GetSingleCreatureFromStorage(aArmySortingParameters[i].m_uiEntry))
{
GetCreatureListWithEntryInGrid(lCreatureList, pTemp, NPC_QIRAJI_WARRIOR, aArmySortingParameters[i].m_fSearchDist);
GetCreatureListWithEntryInGrid(lCreatureList, pTemp, NPC_SWARMGUARD_NEEDLER, aArmySortingParameters[i].m_fSearchDist);
CreatureGroup* group = leader->GetCreatureGroup();
if (!group) // code expects leader to have group
{
sLog.outError("AQ40: Leader of group entry %u does not have spawn group assigned.", aArmySortingParameters[i].m_uiEntry);
continue;
}

for (CreatureList::const_iterator itr = lCreatureList.begin(); itr != lCreatureList.end(); ++itr)
{
if ((*itr)->IsAlive())
m_sArmyWavesGuids[i].insert((*itr)->GetObjectGuid());
}

if (pTemp->IsAlive())
m_sArmyWavesGuids[i].insert(pTemp->GetObjectGuid());
if (leader->IsAlive())
m_sArmyWavesGuids[i].insert(leader->GetObjectGuid());
}
}

// send the first wave
m_uiCurrentArmyWave = 0;
m_currentArmyWave = 0;
DoSendNextArmyWave();
}

Expand All @@ -340,64 +349,54 @@ void instance_ruins_of_ahnqiraj::DoSendNextArmyWave()
return;

// The last wave is General Rajaxx itself
if (m_uiCurrentArmyWave == MAX_ARMY_WAVES)
if (m_currentArmyWave == MAX_ARMY_WAVES)
{
if (Creature* pRajaxx = GetSingleCreatureFromStorage(NPC_RAJAXX))
if (Creature* rajaxx = GetSingleCreatureFromStorage(NPC_RAJAXX))
{
DoScriptText(SAY_INTRO, pRajaxx);
pRajaxx->SetInCombatWithZone();
pRajaxx->AI()->AttackClosestEnemy();
DoScriptText(SAY_INTRO, rajaxx);
rajaxx->SetInCombatWithZone();
rajaxx->AI()->AttackClosestEnemy();
}
m_uiArmyDelayTimer = 0;
}
else
{
// Increase the wave id if some are already dead
while (m_uiCurrentArmyWave < MAX_ARMY_WAVES && m_sArmyWavesGuids[m_uiCurrentArmyWave].empty())
++m_uiCurrentArmyWave;

if (m_uiCurrentArmyWave == MAX_ARMY_WAVES)
if (m_currentArmyWave == MAX_ARMY_WAVES)
{
script_error_log("Instance Ruins of Ahn'Qiraj: ERROR Something unexpected happened. Please report to SD2 team.");
return;
}

float fX, fY, fZ;
for (auto itr : m_sArmyWavesGuids[m_uiCurrentArmyWave])
auto waveInfo = aArmySortingParameters[m_currentArmyWave];
auto waveMobs = instance->GetCreatures(waveInfo.m_stringId);
if (!waveMobs->empty())
{
if (Creature* pTemp = instance->GetCreature(itr))
if (Creature* leader = dynamic_cast<Creature*>((*waveMobs)[0]->GetFormationSlot()->GetMaster()))
{
if (!pTemp->IsAlive())
continue;

pTemp->SetWalk(false);
pTemp->GetRandomPoint(aAndorovMoveLocs[4].m_fX, aAndorovMoveLocs[4].m_fY, aAndorovMoveLocs[4].m_fZ, 10.0f, fX, fY, fZ);
pTemp->GetMotionMaster()->MovePoint(0, fX, fY, fZ);
leader->SetWalk(false);
auto fSlot = leader->GetFormationSlot();
fSlot->GetFormationData()->SetMovementInfo(WAYPOINT_MOTION_TYPE, waveInfo.m_waypointPath);
leader->GetMotionMaster()->MoveWaypoint(0);
}
}

// Yell on each wave (except the first 2)
if (aArmySortingParameters[m_uiCurrentArmyWave].m_uiYellEntry)
if (aArmySortingParameters[m_currentArmyWave].m_uiYellEntry)
{
if (Creature* pRajaxx = GetSingleCreatureFromStorage(NPC_RAJAXX))
DoScriptText(aArmySortingParameters[m_uiCurrentArmyWave].m_uiYellEntry, pRajaxx);
DoScriptText(aArmySortingParameters[m_currentArmyWave].m_uiYellEntry, pRajaxx);
}
// on wowwiki it states that there were 3 min between the waves, but this was reduced in later patches
m_uiArmyDelayTimer = 2 * MINUTE * IN_MILLISECONDS;
m_uiArmyDelayTimer = 3 * MINUTE * IN_MILLISECONDS;
}

++m_uiCurrentArmyWave;
}

InstanceData* GetInstanceData_instance_ruins_of_ahnqiraj(Map* pMap)
{
return new instance_ruins_of_ahnqiraj(pMap);
++m_currentArmyWave;
}

void AddSC_instance_ruins_of_ahnqiraj()
{
Script* pNewScript = new Script;
pNewScript->Name = "instance_ruins_of_ahnqiraj";
pNewScript->GetInstanceData = &GetInstanceData_instance_ruins_of_ahnqiraj;
pNewScript->GetInstanceData = &GetNewInstanceScript<instance_ruins_of_ahnqiraj>;
pNewScript->RegisterSelf();
}
Loading

0 comments on commit d795d20

Please sign in to comment.