From 06a879da7e54ee665dce154ab8924b00b0bc1420 Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Sat, 18 Jun 2022 09:42:01 -0300 Subject: [PATCH] =?UTF-8?q?fix(Scripts/TempleofAhnQiraj):=20improve=20C'th?= =?UTF-8?q?un's=20script=20a=20bit=20and=20repl=E2=80=A6=20(#12067)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(Scripts/TempleofAhnQiraj): improve C'thun's script a bit and replace eye tentacle spawns with sniffed values --- .../rev_1655410251292385300.sql | 56 +++ .../Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp | 353 ++++++++---------- .../instance_temple_of_ahnqiraj.cpp | 1 + .../TempleOfAhnQiraj/temple_of_ahnqiraj.h | 6 +- 4 files changed, 207 insertions(+), 209 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1655410251292385300.sql diff --git a/data/sql/updates/pending_db_world/rev_1655410251292385300.sql b/data/sql/updates/pending_db_world/rev_1655410251292385300.sql new file mode 100644 index 000000000..84f4249d6 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1655410251292385300.sql @@ -0,0 +1,56 @@ +DELETE FROM `creature_summon_groups` WHERE `summonerId` = 15589; +INSERT INTO `creature_summon_groups` (`summonerId`, `summonerType`, `groupId`, `entry`, `position_x`, `position_y`, `position_z`, `orientation`, `summonType`, `summonTime`) VALUES +-- Group 1 +(15589, 0, 0, 15726, -8603.775391, 1974.709351, 100.220718, 0.0, 2, 300000), +(15589, 0, 0, 15726, -8605.348633, 1994.268188, 100.221367, 0.0, 2, 300000), +(15589, 0, 0, 15726, -8589.451172, 2012.543823, 100.220688, 0.0, 2, 300000), +(15589, 0, 0, 15726, -8563.065430, 2010.912842, 100.220688, 0.0, 2, 300000), +(15589, 0, 0, 15726, -8550.451172, 1992.396851, 100.171875, 0.0, 2, 300000), +(15589, 0, 0, 15726, -8554.344727, 1972.097046, 100.221184, 0.0, 2, 300000), +(15589, 0, 0, 15726, -8565.425781, 1961.392578, 100.220581, 0.0, 2, 300000), +(15589, 0, 0, 15726, -8588.680664, 1957.962646, 100.498169, 0.0, 2, 300000), +-- Group 2 +(15589, 0, 1, 15726, -8604.788086, 1977.721191, 100.220673, 0.0, 2, 300000), +(15589, 0, 1, 15726, -8604.773438, 1997.835571, 100.220657, 0.0, 2, 300000), +(15589, 0, 1, 15726, -8586.697266, 2014.359497, 100.221024, 0.0, 2, 300000), +(15589, 0, 1, 15726, -8560.730469, 2009.243042, 100.312027, 0.0, 2, 300000), +(15589, 0, 1, 15726, -8549.125977, 1989.693115, 100.218964, 0.0, 2, 300000), +(15589, 0, 1, 15726, -8555.000977, 1969.066040, 100.220825, 0.0, 2, 300000), +(15589, 0, 1, 15726, -8567.546875, 1959.600464, 100.340576, 0.0, 2, 300000), +(15589, 0, 1, 15726, -8591.760742, 1960.183838, 100.220749, 0.0, 2, 300000), +-- Group 3 +(15589, 0, 2, 15726, -8584.177734, 2015.206665, 100.220627, 0.0, 2, 300000), +(15589, 0, 2, 15726, -8558.459961, 2007.343140, 100.500259, 0.0, 2, 300000), +(15589, 0, 2, 15726, -8548.819336, 1987.051270, 100.219139, 0.0, 2, 300000), +(15589, 0, 2, 15726, -8557.414063, 1967.254272, 100.220711, 0.0, 2, 300000), +(15589, 0, 2, 15726, -8570.909180, 1958.947632, 100.220642, 0.0, 2, 300000), +(15589, 0, 2, 15726, -8594.705078, 1962.332764, 100.220726, 0.0, 2, 300000), +(15589, 0, 2, 15726, -8605.216797, 1981.862793, 100.220512, 0.0, 2, 300000), +(15589, 0, 2, 15726, -8602.661133, 2000.301636, 100.300171, 0.0, 2, 300000), +-- Group 4 +(15589, 0, 3, 15726, -8574.696289, 1958.381958, 100.220482, 0.0, 2, 300000), +(15589, 0, 3, 15726, -8597.281250, 1964.753052, 100.220665, 0.0, 2, 300000), +(15589, 0, 3, 15726, -8605.613281, 1984.794800, 100.220833, 0.0, 2, 300000), +(15589, 0, 3, 15726, -8601.550781, 2002.827759, 100.411690, 0.0, 2, 300000), +(15589, 0, 3, 15726, -8580.916016, 2015.309814, 100.220802, 0.0, 2, 300000), +(15589, 0, 3, 15726, -8556.536133, 2004.968018, 100.220840, 0.0, 2, 300000), +(15589, 0, 3, 15726, -8549.049805, 1984.366577, 100.220390, 0.0, 2, 300000), +(15589, 0, 3, 15726, -8559.099609, 1965.337646, 100.220795, 0.0, 2, 300000), +-- Group 5 +(15589, 0, 4, 15726, -8606.484375, 1987.263062, 100.220650, 0.0, 2, 300000), +(15589, 0, 4, 15726, -8598.741211, 2005.753418, 100.220520, 0.0, 2, 300000), +(15589, 0, 4, 15726, -8577.381836, 2015.370239, 100.220665, 0.0, 2, 300000), +(15589, 0, 4, 15726, -8554.274414, 2001.834106, 100.167274, 0.0, 2, 300000), +(15589, 0, 4, 15726, -8550.043945, 1980.844604, 100.218864, 0.0, 2, 300000), +(15589, 0, 4, 15726, -8560.641602, 1963.641602, 100.218864, 0.0, 2, 300000), +(15589, 0, 4, 15726, -8578.719727, 1957.526001, 100.403954, 0.0, 2, 300000), +(15589, 0, 4, 15726, -8599.988281, 1968.158936, 100.220963, 0.0, 2, 300000), +-- Group 6 +(15589, 0, 5, 15726, -8562.926758, 1962.273071, 100.220818, 0.0, 2, 300000), +(15589, 0, 5, 15726, -8583.307617, 1956.971558, 100.498611, 0.0, 2, 300000), +(15589, 0, 5, 15726, -8601.906250, 1970.630859, 100.263298, 0.0, 2, 300000), +(15589, 0, 5, 15726, -8606.078125, 1990.227051, 100.220634, 0.0, 2, 300000), +(15589, 0, 5, 15726, -8595.287109, 2009.543457, 100.220711, 0.0, 2, 300000), +(15589, 0, 5, 15726, -8573.629883, 2014.623413, 100.220512, 0.0, 2, 300000), +(15589, 0, 5, 15726, -8552.320313, 1998.953735, 100.130707, 0.0, 2, 300000), +(15589, 0, 5, 15726, -8550.862305, 1978.124878, 100.219307, 0.0, 2, 300000); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index 8001bfd63..cffb86012 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -91,6 +91,14 @@ enum Spells enum Actions { ACTION_FLESH_TENTACLE_KILLED = 1, + + ACTION_SPAWN_EYE_TENTACLES = 1, +}; + +enum Misc +{ + MAX_TENTACLE_GROUPS = 5, + GROUP_BEAM_PHASE = 1 }; enum Yells @@ -146,45 +154,22 @@ public: struct eye_of_cthunAI : public ScriptedAI { - eye_of_cthunAI(Creature* creature) : ScriptedAI(creature) + eye_of_cthunAI(Creature* creature) : ScriptedAI(creature), _summons(creature) { instance = creature->GetInstanceScript(); SetCombatMovement(false); } - InstanceScript* instance; - - //Global variables - uint32 PhaseTimer; - - //Eye beam phase - uint32 BeamTimer; - uint32 EyeTentacleTimer; - uint32 ClawTentacleTimer; - - //Dark Glare phase - uint32 DarkGlareTick; - uint32 DarkGlareTickTimer; - float DarkGlareAngle; - bool ClockWise; - void Reset() override { - //Phase information - PhaseTimer = 50000; //First dark glare in 50 seconds - - //Eye beam phase 50 seconds - BeamTimer = 3000; - EyeTentacleTimer = 45000; //Always spawns 5 seconds before Dark Beam - ClawTentacleTimer = 12500; //4 per Eye beam phase (unsure if they spawn during Dark beam) - //Dark Beam phase 35 seconds (each tick = 1 second, 35 ticks) DarkGlareTick = 0; - DarkGlareTickTimer = 1000; DarkGlareAngle = 0; ClockWise = false; + _eyeTentacleCounter = 0; + //Reset flags me->RemoveAurasDueToSpell(SPELL_RED_COLORATION); me->RemoveAurasDueToSpell(SPELL_FREEZE_ANIM); @@ -198,20 +183,128 @@ public: Creature* pPortal = me->FindNearestCreature(NPC_CTHUN_PORTAL, 10); if (pPortal) pPortal->SetReactState(REACT_PASSIVE); + + _summons.DespawnAll(); + _scheduler.CancelAll(); } void EnterCombat(Unit* /*who*/) override { DoZoneInCombat(); + ScheduleTasks(); instance->SetData(DATA_CTHUN_PHASE, PHASE_EYE_GREEN_BEAM); } - void SpawnEyeTentacle(float x, float y) + void DoAction(int32 action) override { - if (Creature* Spawned = DoSpawnCreature(NPC_EYE_TENTACLE, x, y, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 500)) - if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0)) - if (Spawned->AI()) - Spawned->AI()->AttackStart(target); + if (action == ACTION_SPAWN_EYE_TENTACLES) + { + me->SummonCreatureGroup(_eyeTentacleCounter); + _eyeTentacleCounter++; + + if (_eyeTentacleCounter >= MAX_TENTACLE_GROUPS) + { + _eyeTentacleCounter = 0; + } + } + } + + void ScheduleTasks() + { + _scheduler.Schedule(3s, [this](TaskContext task) + { + DoCastRandomTarget(SPELL_GREEN_BEAM); + task.SetGroup(GROUP_BEAM_PHASE); + task.Repeat(); + }).Schedule(12s, [this](TaskContext task) + { + if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true)) + { + if (Creature* tentacle = me->SummonCreature(NPC_CLAW_TENTACLE, *target, TEMPSUMMON_CORPSE_DESPAWN, 1000)) + { + tentacle->AI()->AttackStart(target); + } + } + + task.SetGroup(GROUP_BEAM_PHASE); + task.Repeat(); + }).Schedule(45s, [this](TaskContext task) + { + DoAction(ACTION_SPAWN_EYE_TENTACLES); + task.SetGroup(GROUP_BEAM_PHASE); + task.Repeat(); + }).Schedule(50s, [this](TaskContext /*task*/) + { + _scheduler.CancelGroup(GROUP_BEAM_PHASE); + + me->StopMoving(); + me->SetReactState(REACT_PASSIVE); + me->InterruptNonMeleeSpells(false); + me->SetTarget(ObjectGuid::Empty); + + _scheduler.Schedule(1s, [this](TaskContext /*task*/) + { + //Select random target for dark beam to start on + if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true)) + { + //Face our target + DarkGlareAngle = me->GetAngle(target); + DarkGlareTick = 0; + ClockWise = RAND(true, false); + + me->SetTarget(target->GetGUID()); + + //Add red coloration to C'thun + DoCast(me, SPELL_RED_COLORATION, true); + + //Freeze animation + DoCast(me, SPELL_FREEZE_ANIM, true); + + me->StopMoving(); + me->SetFacingToObject(target); + me->SetOrientation(DarkGlareAngle); + } + + _scheduler.Schedule(3s, [this](TaskContext tasker) + { + me->SetTarget(ObjectGuid::Empty); + me->StopMoving(); + + if (ClockWise) + { + me->SetFacingTo(DarkGlareAngle + DarkGlareTick * float(M_PI) / 35); + me->SetOrientation(DarkGlareAngle + DarkGlareTick * float(M_PI) / 35); + + } + else + { + me->SetFacingTo(DarkGlareAngle - DarkGlareTick * float(M_PI) / 35); + me->SetOrientation(DarkGlareAngle - DarkGlareTick * float(M_PI) / 35); + } + + DoCastSelf(SPELL_DARK_GLARE); + ++DarkGlareTick; + + if (tasker.GetRepeatCounter() >= 35) + { + _scheduler.CancelAll(); + me->SetReactState(REACT_AGGRESSIVE); + me->RemoveAurasDueToSpell(SPELL_RED_COLORATION); + me->RemoveAurasDueToSpell(SPELL_FREEZE_ANIM); + me->InterruptNonMeleeSpells(false); + ScheduleTasks(); + } + else + tasker.Repeat(1s); + }); + }); + }); + } + + void JustSummoned(Creature* summon) override + { + _summons.Summon(summon); + summon->SetInCombatWithZone(); } void UpdateAI(uint32 diff) override @@ -220,162 +313,8 @@ public: if (!UpdateVictim()) return; - uint32 currentPhase = instance->GetData(DATA_CTHUN_PHASE); - if (currentPhase == PHASE_EYE_GREEN_BEAM || currentPhase == PHASE_EYE_RED_BEAM) + switch (instance->GetData(DATA_CTHUN_PHASE)) { - // EyeTentacleTimer - if (EyeTentacleTimer <= diff) - { - //Spawn the 8 Eye Tentacles in the corret spots - SpawnEyeTentacle(0, 20); //south - SpawnEyeTentacle(10, 10); //south west - SpawnEyeTentacle(20, 0); //west - SpawnEyeTentacle(10, -10); //north west - - SpawnEyeTentacle(0, -20); //north - SpawnEyeTentacle(-10, -10); //north east - SpawnEyeTentacle(-20, 0); // east - SpawnEyeTentacle(-10, 10); // south east - - EyeTentacleTimer = 45000; - } - else EyeTentacleTimer -= diff; - } - - switch (currentPhase) - { - case PHASE_EYE_GREEN_BEAM: - //BeamTimer - if (BeamTimer <= diff) - { - //SPELL_GREEN_BEAM - if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0)) - { - me->InterruptNonMeleeSpells(false); - DoCast(target, SPELL_GREEN_BEAM); - - //Correctly update our target - me->SetTarget(target->GetGUID()); - } - - //Beam every 3 seconds - BeamTimer = 3000; - } - else BeamTimer -= diff; - - //ClawTentacleTimer - if (ClawTentacleTimer <= diff) - { - if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0)) - { - //Spawn claw tentacle on the random target - Creature* spawned = me->SummonCreature(NPC_CLAW_TENTACLE, *target, TEMPSUMMON_CORPSE_DESPAWN, 500); - - if (spawned && spawned->AI()) - { - spawned->AI()->AttackStart(target); - } - } - - //One claw tentacle every 12.5 seconds - ClawTentacleTimer = 12500; - } - else ClawTentacleTimer -= diff; - - //PhaseTimer - if (PhaseTimer <= diff) - { - //Switch to Dark Beam - instance->SetData(DATA_CTHUN_PHASE, PHASE_EYE_RED_BEAM); - - me->InterruptNonMeleeSpells(false); - me->SetReactState(REACT_PASSIVE); - - //Remove any target - me->SetTarget(); - - //Select random target for dark beam to start on - if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0)) - { - //Face our target - DarkGlareAngle = me->GetAngle(target); - DarkGlareTickTimer = 4000; - DarkGlareTick = 0; - ClockWise = RAND(true, false); - } - - //Add red coloration to C'thun - DoCast(me, SPELL_RED_COLORATION, true); - - //Freeze animation - DoCast(me, SPELL_FREEZE_ANIM); - me->StopMoving(); - me->SetFacingTo(DarkGlareAngle); - me->SetOrientation(DarkGlareAngle); - - //Darkbeam for 35 seconds - PhaseTimer = 35000; - } - else PhaseTimer -= diff; - - break; - - case PHASE_EYE_RED_BEAM: - if (DarkGlareTick < 35) - { - if (DarkGlareTickTimer <= diff) - { - me->StopMoving(); - - //Set angle and cast - if (ClockWise) - { - me->SetFacingTo(DarkGlareAngle + DarkGlareTick * M_PI / 35); - me->SetOrientation(DarkGlareAngle + DarkGlareTick * M_PI / 35); - } - else - { - me->SetFacingTo(DarkGlareAngle - DarkGlareTick * M_PI / 35); - me->SetOrientation(DarkGlareAngle - DarkGlareTick * M_PI / 35); - } - - //Actual dark glare cast, maybe something missing here? - DoCast(me, SPELL_DARK_GLARE, false); - - //Increase tick - ++DarkGlareTick; - - //1 second per tick - DarkGlareTickTimer = 1000; - } - else DarkGlareTickTimer -= diff; - } - - //PhaseTimer - if (PhaseTimer <= diff) - { - //Switch to Eye Beam - instance->SetData(DATA_CTHUN_PHASE, PHASE_EYE_GREEN_BEAM); - - BeamTimer = 3000; - ClawTentacleTimer = 12500; //4 per Eye beam phase (unsure if they spawn during Dark beam) - - me->InterruptNonMeleeSpells(false); - - //Remove Red coloration from c'thun - me->RemoveAurasDueToSpell(SPELL_RED_COLORATION); - me->RemoveAurasDueToSpell(SPELL_FREEZE_ANIM); - - //set it back to aggressive - me->SetReactState(REACT_AGGRESSIVE); - - //Eye Beam for 50 seconds - PhaseTimer = 50000; - } - else PhaseTimer -= diff; - - break; - //Transition phase case PHASE_CTHUN_TRANSITION: //Remove any target @@ -386,13 +325,16 @@ public: //Dead phase case PHASE_CTHUN_DONE: - Creature* pPortal = me->FindNearestCreature(NPC_CTHUN_PORTAL, 10); - if (pPortal) + if (Creature* pPortal = me->FindNearestCreature(NPC_CTHUN_PORTAL, 10)) + { pPortal->DespawnOrUnsummon(); + } me->DespawnOrUnsummon(); break; } + + _scheduler.Update(diff); } void DamageTaken(Unit*, uint32& damage, DamageEffectType, SpellSchoolMask) override @@ -437,6 +379,18 @@ public: return; } } + + private: + InstanceScript* instance; + + //Dark Glare phase + uint32 DarkGlareTick; + float DarkGlareAngle; + bool ClockWise; + + uint32 _eyeTentacleCounter; + TaskScheduler _scheduler; + SummonList _summons; }; }; @@ -522,15 +476,6 @@ public: DoZoneInCombat(); } - void SpawnEyeTentacle(float x, float y) - { - Creature* Spawned; - Spawned = DoSpawnCreature(NPC_EYE_TENTACLE, x, y, 0, 0, TEMPSUMMON_CORPSE_DESPAWN, 500); - if (Spawned && Spawned->AI()) - if (Unit* target = SelectRandomNotStomach()) - Spawned->AI()->AttackStart(target); - } - Unit* SelectRandomNotStomach() { if (Stomach_Map.empty()) @@ -607,16 +552,10 @@ public: // EyeTentacleTimer if (EyeTentacleTimer <= diff) { - //Spawn the 8 Eye Tentacles in the corret spots - SpawnEyeTentacle(0, 20); //south - SpawnEyeTentacle(10, 10); //south west - SpawnEyeTentacle(20, 0); //west - SpawnEyeTentacle(10, -10); //north west - - SpawnEyeTentacle(0, -20); //north - SpawnEyeTentacle(-10, -10); //north east - SpawnEyeTentacle(-20, 0); // east - SpawnEyeTentacle(-10, 10); // south east + if (Creature* eye = instance->GetCreature(DATA_EYE_OF_CTHUN)) + { + eye->AI()->DoAction(ACTION_SPAWN_EYE_TENTACLES); + } EyeTentacleTimer = 30000; // every 30sec in phase 2 } diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp index d05e3687d..3056a305f 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/instance_temple_of_ahnqiraj.cpp @@ -30,6 +30,7 @@ EndScriptData */ ObjectData const creatureData[] = { { NPC_SARTURA, DATA_SARTURA }, + { NPC_EYE_OF_CTHUN, DATA_EYE_OF_CTHUN } }; class instance_temple_of_ahnqiraj : public InstanceMapScript diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/temple_of_ahnqiraj.h b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/temple_of_ahnqiraj.h index a41d38da0..d32f6dbd9 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/temple_of_ahnqiraj.h +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/temple_of_ahnqiraj.h @@ -38,12 +38,14 @@ enum DataTypes DATA_BUG_TRIO_DEATH = 14, DATA_CTHUN_PHASE = 20, DATA_VISCIDUS = 21, - DATA_SARTURA = 22 + DATA_SARTURA = 22, + + DATA_EYE_OF_CTHUN = 23 }; enum Creatures { - BOSS_EYE_OF_CTHUN = 15589, + NPC_EYE_OF_CTHUN = 15589, NPC_CTHUN_PORTAL = 15896, NPC_CLAW_TENTACLE = 15725, NPC_EYE_TENTACLE = 15726,