From 56d67f9964865ea6a8803f29e5d3e877bc2dfde0 Mon Sep 17 00:00:00 2001 From: Gemt Date: Tue, 28 Mar 2017 21:32:42 +0200 Subject: [PATCH] complete rewrite of cthun stomach logic. Using triggers for porting, and moved the logic to aq instance script. --- sql/AQ/CThun.sql | 3 +- .../temple_of_ahnqiraj/boss_cthun.cpp | 242 +----------------- .../instance_temple_of_ahnqiraj.cpp | 126 +++++---- .../temple_of_ahnqiraj/temple_of_ahnqiraj.h | 67 ++--- 4 files changed, 127 insertions(+), 311 deletions(-) diff --git a/sql/AQ/CThun.sql b/sql/AQ/CThun.sql index 2270f8546..0a74f22c4 100644 --- a/sql/AQ/CThun.sql +++ b/sql/AQ/CThun.sql @@ -67,4 +67,5 @@ INSERT INTO `mangos`.`scripted_areatrigger` (`entry`, `ScriptName`) VALUES ('403 INSERT INTO `mangos`.`scripted_areatrigger` (`entry`, `ScriptName`) VALUES ('4034', 'at_temple_ahnqiraj'); INSERT INTO `mangos`.`scripted_areatrigger` (`entry`, `ScriptName`) VALUES ('4036', 'at_temple_ahnqiraj'); --- UPDATE `mangos`.`creature_template` SET `ScriptName`='at_temple_ahnqiraj' WHERE `entry`='15800'; +-- flags update on trigger unit used to knock players out of cthuns body after being ported. Flags copied from viscidus trigger. +UPDATE `mangos`.`creature_template` SET `unit_flags`='33587968', `ScriptName`='boss cthun knockback trigger' WHERE `entry`='15800'; diff --git a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_cthun.cpp b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_cthun.cpp index dd4d3aa19..152614e23 100644 --- a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_cthun.cpp +++ b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_cthun.cpp @@ -73,11 +73,6 @@ enum eSpells { SPELL_TRANSFORM = 26232, // Initiates the p1->p2 transform SPELL_CTHUN_VULNERABLE = 26235, // Adds the red color. Does not actually him vulnerable, need to remove carapace for that. SPELL_MOUTH_TENTACLE = 26332, // Spawns the tentacle that "eats" you to stomach and mounts the player on it. - SPELL_PORT_OUT_STOMACH = 26648, // Not yet used, was killing c'thun too. Maybe that's intended => a respawn? - - - - }; uint32 CANNOT_CAST_SPELL_MASK = CANNOT_CAST_SPELL_MASK = (UNIT_FLAG_SILENCED | UNIT_FLAG_PACIFIED | UNIT_FLAG_STUNNED @@ -107,16 +102,6 @@ static const float eyeTentaclePositions[8][3] = { -8556.115234f, 1965.667725f, 100.598129f } }; -enum CThunPhase -{ - PHASE_EYE_NORMAL = 0, - PHASE_EYE_DARK_GLARE = 1, - PHASE_TRANSITION = 2, - PHASE_CTHUN_INVULNERABLE = 3, - PHASE_CTHUN_WEAKENED = 4, - PHASE_CTHUN_DONE = 5, -}; - using SpellTarSelectFunction = std::function; class SpellTimer { @@ -231,34 +216,12 @@ private: using CThunStomachList = std::vector>; -bool PlayerInStomach(Unit *unit, const CThunStomachList& stomachList) -{ - //return unit->GetPositionZ() < -30.0f; - if (!unit->GetPositionZ() < -30.0f) return false; - if (unit->GetDistance(puntPosition[0], puntPosition[1], puntPosition[2]) > 95.0f) return false; - - return true; - - auto it = std::find_if(stomachList.begin(), stomachList.end(), - [unit](const std::pair& e) { - if (unit->GetObjectGuid() == e.first) { - return true; - } - return false; - - return e.first == unit->GetObjectGuid(); - }); - - return it != stomachList.end(); -} - Player* SelectRandomAliveNotStomach(instance_temple_of_ahnqiraj* instance) { if (!instance) return nullptr; std::list temp; std::list::iterator j; const Map::PlayerList& PlayerList = instance->GetMap()->GetPlayers(); - const CThunStomachList& stomachList = instance->GetPlayersInStomach(); if (!PlayerList.isEmpty()) { @@ -266,7 +229,7 @@ Player* SelectRandomAliveNotStomach(instance_temple_of_ahnqiraj* instance) { if (Player* player = itr->getSource()) { - if (!player->isDead() && !player->isGameMaster() && !PlayerInStomach(player, stomachList)) { + if (!player->isDead() && !player->isGameMaster() && !instance->PlayerInStomach(player)) { temp.push_back(player); } } @@ -556,9 +519,6 @@ struct cthunAI : public ScriptedAI EyeDeathAnimTimer = 4000; // It's really 5 seconds, but 4 sec in CthunEmergeTimer takes over the logic CthunEmergeTimer = 8000; - stomachPuntTimer = StomachTimers::PUNT_CAST_TIME; - puntCreatureGuid = 0; - ResetartUnvulnerablePhase(); // Reset visibility @@ -587,7 +547,6 @@ struct cthunAI : public ScriptedAI if (m_pInstance) { - m_pInstance->GetPlayersInStomach().clear(); m_pInstance->SetData(TYPE_CTHUN_PHASE, 0); m_pInstance->SetData(TYPE_CTHUN, NOT_STARTED); @@ -659,7 +618,6 @@ struct cthunAI : public ScriptedAI m_creature->SetTargetGuid(0); VerifyAnyPlayerAliveOutside(); - UpdatePlayersInStomach(diff); switch (m_pInstance->GetData(TYPE_CTHUN_PHASE)) { case PHASE_TRANSITION: { @@ -751,14 +709,7 @@ struct cthunAI : public ScriptedAI void VerifyAnyPlayerAliveOutside() { if (!SelectRandomAliveNotStomach(m_pInstance)) { - for (auto iter = m_pInstance->GetPlayersInStomach().begin(); iter != m_pInstance->GetPlayersInStomach().end(); iter++) { - if (Player* p = m_creature->GetMap()->GetPlayer(iter->first)) { - if (p->isAlive()) { - p->KillPlayer(); - //m_creature->CastSpell(p, SPELL_PORT_OUT_STOMACH, true); - } - } - } + m_pInstance->KillPlayersInStomach(); } } @@ -844,174 +795,6 @@ struct cthunAI : public ScriptedAI //player->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID); } - void UpdatePlayersInStomach(uint32 diff) - { - if (m_pInstance->GetData(TYPE_CTHUN_PHASE) == PHASE_CTHUN_DONE) { - while (m_pInstance->GetPlayersInStomach().size() > 0) { - Player* player = m_creature->GetMap()->GetPlayer(m_pInstance->GetPlayersInStomach().at(0).first); - if (player) { - PortPlayerOutOfStomach(player); - } - m_pInstance->GetPlayersInStomach().erase(m_pInstance->GetPlayersInStomach().begin()); - } - return; - } - - for (auto it = m_pInstance->GetPlayersInStomach().begin(); it != m_pInstance->GetPlayersInStomach().end();) { - Player* player = m_creature->GetMap()->GetPlayer(it->first); - // player has left the instance or something and is presumably no longer in stomach - if (!player) { - sLog.outBasic("Player no longer in instance. Removed from stomach list"); - it = m_pInstance->GetPlayersInStomach().erase(it); - continue; - }else if (player->isDead()) { - sLog.outBasic("Player in stomach dead. Removing from list"); - //player->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID); - it = m_pInstance->GetPlayersInStomach().erase(it); - continue; - } - - StomachTimers& timers = it->second; - - if (timers.playerHasLeftStomach) { - if (timers.removeFromListIn < diff) { - it = m_pInstance->GetPlayersInStomach().erase(it); - } - else { - timers.removeFromListIn -= diff; - ++it; - } - continue; - } - // Update acid debuff - if (timers.acidDebuff < diff) { - //m_creature->CastSpell(player, SPELL_DIGESTIVE_ACID, true); - timers.acidDebuff += StomachTimers::ACID_REFRESH_RATE; - } - else { - timers.acidDebuff -= diff; - } - -#ifdef USE_INDIVIDUAL_PUNT_TIMER - // update punt timer while player is in the punt area. Otherwise reset timer. - if (player->GetDistance(puntPosition[0], puntPosition[1], puntPosition[2]) < 5.0f) { - if (stomachPuntTimer == StomachTimers::PUNT_CAST_TIME) { - stomachPuntTimer -= diff; - } - - if (stomachPuntTimer < diff) { - - } - else { - stomachPuntTimer -= diff; - } - - - if (timers.puntCastTime < diff) { - // Punt the player if he has been in the area aproximately PUNT_CAST_TIME ms - sLog.outBasic("Player in stomach getting punted"); - player->CastSpell(player, SPELL_PUNT_UPWARD, true); - player->RemoveAurasDueToSpell(SPELL_PUNT_UPWARD); - timers.puntCastTime = StomachTimers::PUNT_CAST_TIME; - } - else { - timers.puntCastTime -= diff; - } - - // Player just arrived at punt area. Start cast visual - if (timers.puntCastTime == (timers.PUNT_CAST_TIME - diff)) { - if (Creature *pCreature = m_creature->SummonCreature(PUNT_CREATURE, - puntPosition[0], puntPosition[1], puntPosition[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN, 4450)) - { - sLog.outBasic("Player in stomach arrived at punt area. Starting punt countdown"); - pCreature->CastSpell(pCreature, 26092, false); - } - } - } - else { - if (timers.puntCastTime != StomachTimers::PUNT_CAST_TIME) { - sLog.outBasic("Player in stomach left punt area. Resetting punt countdown"); - } - timers.puntCastTime = StomachTimers::PUNT_CAST_TIME; - } -#endif - // check if we should throw the player out of stomach - if (player->GetPositionZ() > -40.0f && player->HasMovementFlag(MOVEFLAG_JUMPING)) { - - PortPlayerOutOfStomach(player); - if (StomachTimers::REMOVE_FROM_STOMACH_LIST_DELAY == 0) { - //Remove player from stomach list - it = m_pInstance->GetPlayersInStomach().erase(it); - } - else { - it->second.playerHasLeftStomach = true; - sLog.outBasic("Player ported out of stomach"); - ++it; - } - continue; - } - - ++it; - } -#ifndef USE_INDIVIDUAL_PUNT_TIMER - //Punt creature despawn timer (4450 vs cast time of 3sec) should be enough to avoid - //player that has just been punted to retrigger punting - Creature* testPuntCreature = m_pInstance->GetMap()->GetCreature(puntCreatureGuid); - if (!testPuntCreature){ - puntCreatureGuid = 0; - } - - if (!puntCreatureGuid) { - for (auto it = m_pInstance->GetPlayersInStomach().begin(); it != m_pInstance->GetPlayersInStomach().end();) { - Player* player = m_creature->GetMap()->GetPlayer(it->first); - // this should not be needed afaik as it's already done in loop above. But just in case. - if (!player) { - ++it; - continue; - } - //starting a punt timer - if (player->GetDistance(puntPosition[0], puntPosition[1], puntPosition[2]) < 7.0f) { - if (Creature *pCreature = m_creature->SummonCreature(PUNT_CREATURE, - puntPosition[0], puntPosition[1], puntPosition[2], 0.0f, TEMPSUMMON_TIMED_DESPAWN, 4450)) - { - puntCreatureGuid = pCreature->GetObjectGuid(); - sLog.outBasic("Player in stomach arrived at punt area. Starting punt countdown"); - pCreature->CastSpell(pCreature, 26092, false); - pCreature->SendSpellGo(pCreature, 26093); //only visual quake - stomachPuntTimer = StomachTimers::PUNT_CAST_TIME; - } - break; - } - - ++it; - } - } - else if(stomachPuntTimer < diff){ - for (auto it = m_pInstance->GetPlayersInStomach().begin(); it != m_pInstance->GetPlayersInStomach().end();) { - Player* player = m_creature->GetMap()->GetPlayer(it->first); - // this should not be needed afaik as it's already done in loop above. But just in case. - if (!player) { - ++it; - continue; - } - if (Creature* puntCreature = m_pInstance->GetMap()->GetCreature(puntCreatureGuid)) { - if (player->GetDistance(puntCreature) < 7.0f) { - //player->CastSpell(player, SPELL_PUNT_UPWARD, true); - //player->RemoveAurasDueToSpell(SPELL_PUNT_UPWARD); - } - } - ++it; - } - // just setting it high so no continous punting happens until punt creature despawns - // and timer is re-initialized - stomachPuntTimer = std::numeric_limits::max(); - } - else { - stomachPuntTimer -= diff; - } -#endif - } - void JustDied(Unit* pKiller) { if (m_pInstance) @@ -1044,7 +827,7 @@ struct eye_of_cthunAI : public ScriptedAI m_pInstance = dynamic_cast(pCreature->GetInstanceData()); if (!m_pInstance) sLog.outError("SD0: No Instance eye_of_cthunAI"); - + Reset(); } @@ -1378,11 +1161,9 @@ struct eye_tentacleAI : public ScriptedAI } else { - Unit* currentCastTarget = m_creature->GetMap()->GetPlayer(currentMFTarget); - if (currentCastTarget) { - // Stop casting on current target if it's been ported to stomach - const CThunStomachList& lst = m_pInstance->GetPlayersInStomach(); - if (PlayerInStomach(currentCastTarget, lst)) { + // Stop casting on current target if it's been ported to stomach + if (Unit* currentCastTarget = m_creature->GetMap()->GetPlayer(currentMFTarget)) { + if (m_pInstance->PlayerInStomach(currentCastTarget)) { m_creature->InterruptSpell(CurrentSpellTypes::CURRENT_CHANNELED_SPELL); } } @@ -1630,12 +1411,11 @@ struct giant_eye_tentacleAI : public ScriptedAI else { BeamTimer -= diff; if (m_creature->GetCurrentSpell(CurrentSpellTypes::CURRENT_GENERIC_SPELL)) { - Unit* currentCastTarget = m_creature->GetMap()->GetPlayer(beamTargetGuid); - if (currentCastTarget) { - // Stop casting on current target if it's been ported to stomach - // and immediately start casting on a new target - const CThunStomachList& lst = m_pInstance->GetPlayersInStomach(); - if (PlayerInStomach(currentCastTarget, lst)) { + + // Stop casting on current target if it's been ported to stomach + // and immediately start casting on a new target + if (Unit* currentCastTarget = m_creature->GetMap()->GetPlayer(beamTargetGuid)) { + if (m_pInstance->PlayerInStomach(currentCastTarget)) { m_creature->InterruptNonMeleeSpells(false); BeamTimer = 0; } diff --git a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp index 8c9748651..1951aecd8 100644 --- a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp +++ b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp @@ -88,17 +88,6 @@ void instance_temple_of_ahnqiraj::DoHandleTempleAreaTrigger(uint32 uiTriggerId) } } -instance_temple_of_ahnqiraj::CThunStomachList& instance_temple_of_ahnqiraj::GetPlayersInStomach() -{ - return playersInStomach; -} - -void instance_temple_of_ahnqiraj::AddPlayerToStomach(Unit * p) -{ - p->CastSpell(p, SPELL_DIGESTIVE_ACID, true); - playersInStomach.push_back(std::make_pair(p->GetGUID(), StomachTimers())); -} - void instance_temple_of_ahnqiraj::OnObjectCreate(GameObject* pGo) { switch (pGo->GetEntry()) @@ -313,6 +302,49 @@ void instance_temple_of_ahnqiraj::Load(const char* chrIn) OUT_LOAD_INST_DATA_COMPLETE; } +void instance_temple_of_ahnqiraj::AddPlayerToStomach(Unit * p) +{ + p->CastSpell(p, SPELL_DIGESTIVE_ACID, true); + playersInStomach.push_back(std::make_pair(p->GetGUID(), StomachTimers())); +} + +instance_temple_of_ahnqiraj::CThunStomachList::iterator instance_temple_of_ahnqiraj::PlayerInStomachIter(Unit * unit) +{ + if (!unit) return playersInStomach.end(); + + return std::find_if(playersInStomach.begin(), playersInStomach.end(), + [unit](const std::pair& e) { + if (unit->GetObjectGuid() == e.first) { + return true; + } + return false; + + return e.first == unit->GetObjectGuid(); + }); +} + +void instance_temple_of_ahnqiraj::RemovePlayerFromStomach(Unit * unit) +{ + if (!unit) return; + + if (unit->HasAura(SPELL_DIGESTIVE_ACID)) { + unit->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID); + } + auto it = PlayerInStomachIter(unit); + if (it != playersInStomach.end()) { + playersInStomach.erase(it); + } +} + +bool instance_temple_of_ahnqiraj::PlayerInStomach(Unit * unit) +{ + //if (!unit->GetPositionZ() > -30.0f) return false; + //if (p->GetDistance(puntPosition[0], puntPosition[1], puntPosition[2]) > 95.0f) return false; + if (!unit) return false; + + return PlayerInStomachIter(unit) != playersInStomach.end(); +} + void instance_temple_of_ahnqiraj::HandleStomachTriggers(Player * pPlayer, const AreaTriggerEntry * pAt) { if (!pPlayer) return; @@ -320,53 +352,59 @@ void instance_temple_of_ahnqiraj::HandleStomachTriggers(Player * pPlayer, const return; if (pAt->id == AREATRIGGER_STOMACH_GROUND) { - sLog.outBasic("AREATRIGGER_STOMACH_GROUND"); - //pCreature->SendSpellGo(pCreature, 26093); if (!puntCreatureGuid) { - if (Creature* pc = GetMap()->SummonCreature(15922, pAt->x, pAt->y, pAt->z, 0, + if (Creature* pc = GetMap()->SummonCreature(PUNT_CREATURE, pAt->x, pAt->y, pAt->z, 0, TEMPSUMMON_TIMED_DESPAWN, 4000)) { - pc->setFaction(14); - //pc->SetVisibility(VISIBILITY_OFF); puntCreatureGuid = pc->GetGUID(); quakeTimer = 1000; puntCountdown = StomachTimers::PUNT_CAST_TIME; - + // Since this is the wrong spell, and it deals damage, we send the visual only, instead of casting it. pc->SendSpellGo(pc, SPELL_QUAKE); } - } } else if (pAt->id == AREATRIGGER_STOMACH_AIR) { - sLog.outBasic("AREATRIGGER_STOMACH_AIR"); const AreaTriggerEntry* portOutTrigger = sAreaTriggerStore.LookupEntry(AREATRIGGER_CTHUN_KNOCKBACK); + if (portOutTrigger) { - pPlayer->NearTeleportTo(portOutTrigger->x, portOutTrigger->y, portOutTrigger->z, pPlayer->GetOrientation()); + float x = portOutTrigger->x + cos((frand(0.0f,360.0f)) * (3.14f / 180.0f)) * 0.1f; + float y = portOutTrigger->y + sin((frand(0.0f, 360.0f)) * (3.14f / 180.0f)) * 0.1f; + pPlayer->NearTeleportTo(x, y, portOutTrigger->z, pPlayer->GetOrientation()); } else { - pPlayer->NearTeleportTo(-8577.27, 1987, 100.4f, pPlayer->GetOrientation()); + float x = -8578.0f + cos((frand(0.0f, 360.0f)) * (3.14f / 180.0f)) * 0.1f; + float y = 1986.8f + sin((frand(0.0f, 360.0f)) * (3.14f / 180.0f)) * 0.1f; + pPlayer->NearTeleportTo(x, y, 100.4f, pPlayer->GetOrientation()); + sLog.outError("instance_temple_of_ahnqiraj::HandleStomachTriggers attempted to lookup area trigger %d, but it was not found.", + AREATRIGGER_CTHUN_KNOCKBACK); } - - //Cast knockback on them - ///player->CastSpell(player, SPELL_EXIT_STOMACH_KNOCKBACK, true); - - //Remove the acid debuff - pPlayer->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID); } else if (pAt->id == AREATRIGGER_CTHUN_KNOCKBACK) { - if (Creature* kbCreature = GetMap()->SummonCreature(PUNT_CREATURE, pAt->x, pAt->y, pAt->z, 0, TEMPSUMMON_TIMED_DESPAWN, 1000)) { - kbCreature->setFaction(14); - kbCreature->CastSpell(kbCreature, SPELL_EXIT_STOMACH_KNOCKBACK, true); - kbCreature->ForcedDespawn(); + RemovePlayerFromStomach(pPlayer); + + // "Disable" the knockback if c'thun is killed + if (GetData(TYPE_CTHUN_PHASE) != PHASE_CTHUN_DONE) { + if (Creature* kbCreature = GetMap()->SummonCreature(EXIT_KNOCKBACK_CREATURE, pAt->x, pAt->y, pAt->z, 0, TEMPSUMMON_TIMED_DESPAWN, 1000)) { + kbCreature->CastSpell(kbCreature, SPELL_EXIT_STOMACH_KNOCKBACK, false); + } } } } -bool instance_temple_of_ahnqiraj::PlayerInStomach(Unit* p) +void instance_temple_of_ahnqiraj::KillPlayersInStomach() { - if (!p->GetPositionZ() > -30.0f) return false; - if (p->GetDistance(puntPosition[0], puntPosition[1], puntPosition[2]) > 95.0f) return false; - + for (auto iter = playersInStomach.begin(); iter != playersInStomach.end();) { + if (Player* p = GetMap()->GetPlayer(iter->first)) { + if (p->isAlive()) { + if (p->HasAura(SPELL_DIGESTIVE_ACID)) { + p->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID); + } + p->CastSpell(p, SPELL_PORT_OUT_STOMACH, true); + iter = playersInStomach.erase(iter); + } + } + } } void instance_temple_of_ahnqiraj::UpdateStomachOfCthun(uint32 diff) @@ -383,11 +421,8 @@ void instance_temple_of_ahnqiraj::UpdateStomachOfCthun(uint32 diff) } //Checking if it's time to punt if (puntCountdown < diff) { - const AreaTriggerEntry * pat = sAreaTriggerStore.LookupEntry(AREATRIGGER_STOMACH_GROUND); - //pc->CastSpell(pat->x, pat->y, pat->z, SPELL_PUNT_UPWARD, true); pc->CastSpell(pc, SPELL_PUNT_UPWARD, true); puntCountdown = std::numeric_limits::max(); - //pc->ForcedDespawn(); puntCreatureGuid = 0; } else { @@ -399,7 +434,9 @@ void instance_temple_of_ahnqiraj::UpdateStomachOfCthun(uint32 diff) } // Update the players in the stomach - for (auto it = playersInStomach.begin(); it != playersInStomach.end(); it++) { + if (playersInStomach.empty()) return; + + for (auto it = playersInStomach.begin(); it != playersInStomach.end();) { Player* player = GetMap()->GetPlayer(it->first); //Player has left instance or something and we remove him from the list. if (!player) { @@ -416,16 +453,7 @@ void instance_temple_of_ahnqiraj::UpdateStomachOfCthun(uint32 diff) timers.acidDebuff -= diff; } - if (const AreaTriggerEntry* ate = sAreaTriggerStore.LookupEntry(AREATRIGGER_STOMACH_GROUND)) { - - } - - // Checking if player should be removed from playersInStomach - if (!PlayerInStomach(player)) { - player->RemoveAurasDueToSpell(SPELL_DIGESTIVE_ACID); - it = playersInStomach.erase(it); - continue; - } + ++it; } } diff --git a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/temple_of_ahnqiraj.h b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/temple_of_ahnqiraj.h index 5b0374dfa..c402a7829 100644 --- a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/temple_of_ahnqiraj.h +++ b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/temple_of_ahnqiraj.h @@ -115,22 +115,21 @@ enum // Used for C'thun only, but needed by multiple mobs so putting in instance struct StomachTimers { uint32 acidDebuff; - uint32 puntCastTime; - uint32 removeFromListIn; - bool playerHasLeftStomach; StomachTimers() : - acidDebuff(StomachTimers::ACID_REFRESH_RATE), - puntCastTime(StomachTimers::PUNT_CAST_TIME), - removeFromListIn(REMOVE_FROM_STOMACH_LIST_DELAY), - playerHasLeftStomach(false) + acidDebuff(StomachTimers::ACID_REFRESH_RATE) {} + static const uint32 PUNT_CAST_TIME = 3000; + static const uint32 ACID_REFRESH_RATE = 5000; +}; - static const int32 ACID_REFRESH_RATE = 5000; - static const int32 PUNT_CAST_TIME = 3000; - // Player is removed from players in stomach list after a delay of this - // length after the teleport has found place. - // If set to 0, the player is instantly removed from the list. - static const uint32 REMOVE_FROM_STOMACH_LIST_DELAY = 3000; +enum CThunPhase +{ + PHASE_EYE_NORMAL = 0, + PHASE_EYE_DARK_GLARE = 1, + PHASE_TRANSITION = 2, + PHASE_CTHUN_INVULNERABLE = 3, + PHASE_CTHUN_WEAKENED = 4, + PHASE_CTHUN_DONE = 5, }; static const float puntPosition[3] = @@ -161,13 +160,6 @@ public: void Update(uint32 uiDiff); - void DoHandleTempleAreaTrigger(uint32 uiTriggerId); - void HandleStomachTriggers(Player* pPlayer, const AreaTriggerEntry* pAt); - - using CThunStomachList = std::vector>; - CThunStomachList& GetPlayersInStomach(); - void AddPlayerToStomach(Unit* p); - private: uint32 m_auiEncounter[MAX_ENCOUNTER]; std::string m_strInstData; @@ -182,21 +174,36 @@ private: DialogueHelper m_dialogueHelper; - enum eStomachSpells { - SPELL_EXIT_STOMACH_KNOCKBACK = 26230, //knocks well back, but must be cast probably an invisible trigger, if not by cthun outside - SPELL_PUNT_UPWARD = 26224, //knocks up like craaayy everyone in range, maybe too big radius - SPELL_DIGESTIVE_ACID = 26476, // Must be stacked and removed manually. - PUNT_CREATURE = 15922, //invisible viscidus trigger, used in stomach - SPELL_QUAKE = 26093, //used for its visual only with SendSpellGo. It deals damage if cast normally - }; - void UpdateStomachOfCthun(uint32 diff); + // The following functions, variables etc, are used to handle the C'thun stomach. + // One might argue if they should be in boss_cthun.cpp instead, but it makes it a whole + // lot easier to handle this logic if it's handled by the instance script. +public: + void DoHandleTempleAreaTrigger(uint32 uiTriggerId); + void HandleStomachTriggers(Player* pPlayer, const AreaTriggerEntry* pAt); + void AddPlayerToStomach(Unit* p); bool PlayerInStomach(Unit* p); + void KillPlayersInStomach(); + +private: + enum eStomachSpells { + SPELL_PUNT_UPWARD = 26224, //knocks up like craaayy everyone in range, maybe too big radius. Only works if thing is targeting player? + SPELL_EXIT_STOMACH_KNOCKBACK = 26230, //knocks well back, but must be cast probably an invisible trigger, if not by cthun outside + + SPELL_DIGESTIVE_ACID = 26476, // Must be stacked and removed manually. + EXIT_KNOCKBACK_CREATURE = 15800, // Exit trigger creature used for stomach and cthun knockups/knockbacks + PUNT_CREATURE = 15922, // Trigger for cthuns belly knockup spell + SPELL_QUAKE = 26093, //used for its visual only with SendSpellGo. It deals damage if cast normally + SPELL_PORT_OUT_STOMACH = 26648, // Not yet used, was killing c'thun too. Maybe that's intended => a respawn? + }; + using CThunStomachList = std::vector>; + void UpdateStomachOfCthun(uint32 diff); + void RemovePlayerFromStomach(Unit* unit); + CThunStomachList::iterator PlayerInStomachIter(Unit* unit); + ObjectGuid puntCreatureGuid; uint32 quakeTimer; uint32 puntCountdown; - AreaTriggerEntry puntTrigger; - // Used for C'thun only, but needed by multiple mobs so putting in instance std::vector> playersInStomach; };