From 11996065512e5c6205fc8e1756cc71f65df65bc2 Mon Sep 17 00:00:00 2001 From: Cgbd Date: Fri, 17 Mar 2017 13:29:19 +0100 Subject: [PATCH] Rewrite Viscidus script, poison cloud should be improved --- sql/AQ/Viscidus.sql | 15 + .../temple_of_ahnqiraj/boss_viscidus.cpp | 419 ++++++++++++------ 2 files changed, 291 insertions(+), 143 deletions(-) create mode 100644 sql/AQ/Viscidus.sql diff --git a/sql/AQ/Viscidus.sql b/sql/AQ/Viscidus.sql new file mode 100644 index 000000000..6c3a938ac --- /dev/null +++ b/sql/AQ/Viscidus.sql @@ -0,0 +1,15 @@ +-- cmangos unit flags Viscidus trigger TOD : search flags name +UPDATE creature_template SET unit_flags = unit_flags | 33587968 WHERE entry = 15922; + +-- Viscidus trigger aren't targettable and can't fight players +UPDATE creature_template SET unit_flags = unit_flags | (33554432 + 512), AIName = "NullAI" WHERE entry = 15922; + +-- Viscidus texts from cmangos +DELETE FROM script_texts WHERE entry BETWEEN -1531046 AND -1531041; +INSERT INTO script_texts (entry, content_default, content_loc1, content_loc2, content_loc3, content_loc4, content_loc5, content_loc6, content_loc7, content_loc8, sound, type, language, emote, comment) VALUES +(-1531046, "%s explodes!", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2, 0, 0, "viscidus EMOTE_EXPLODE"), +(-1531045, "%s looks ready to shatter!", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2, 0, 0, "viscidus EMOTE_SHATTER"), +(-1531044, "%s begins to crack!", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2, 0, 0, "viscidus EMOTE_CRACK"), +(-1531043, "%s is frozen solid!", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2, 0, 0, "viscidus EMOTE_FROZEN"), +(-1531042, "%s is freezing up!", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2, 0, 0, "viscidus EMOTE_FREEZE"), +(-1531041, "%s begins to slow!", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 2, 0, 0, "viscidus EMOTE_SLOW"); diff --git a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_viscidus.cpp b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_viscidus.cpp index c0e2bae9b..1038657ad 100644 --- a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_viscidus.cpp +++ b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_viscidus.cpp @@ -19,21 +19,28 @@ /* ScriptData SDName: Boss_Viscidus -SD%Complete: 0 -SDComment: place holder +SD%Complete: 90 +SDComment: ToDo: Use aura proc to handle freeze event instead of direct function SDCategory: Temple of Ahn'Qiraj EndScriptData */ #include "scriptPCH.h" +#include "temple_of_ahnqiraj.h" enum { + // emotes + EMOTE_SLOW = -1531041, + EMOTE_FREEZE = -1531042, + EMOTE_FROZEN = -1531043, + EMOTE_CRACK = -1531044, + EMOTE_SHATTER = -1531045, + EMOTE_EXPLODE = -1531046, + // Timer spells SPELL_POISON_SHOCK = 25993, SPELL_POISONBOLT_VOLLEY = 25991, - SPELL_TOXIN = 26575, // Triggers toxin cloud - SPELL_TOXIN_CLOUD = 25989, - SPELL_TOXIN_SUMMON = 26577, + SPELL_TOXIN = 26575, // Triggers toxin cloud - 25989 // Debuffs gained by the boss on frost damage SPELL_VISCIDUS_SLOWED = 26034, @@ -42,196 +49,309 @@ enum // When frost damage exceeds a certain limit, then boss explodes SPELL_REJOIN_VISCIDUS = 25896, - SPELL_VISCIDUS_EXPLODE = 25938, // Casts a lot of spells in the same time: 25865 to 25884; All spells have target coords - SPELL_VISCIDUS_SUICIDE = 26003, + SPELL_VISCIDUS_EXPLODE = 25938, + SPELL_VISCIDUS_SUICIDE = 26003, // cast when boss explodes and is below 5% Hp - should trigger 26002 + SPELL_DESPAWN_GLOBS = 26608, + SPELL_MEMBRANE_VISCIDUS = 25994, // damage reduction spell + SPELL_VISCIDUS_WEAKNESS = 25926, // aura which procs at damage - should trigger the slow spells SPELL_VISCIDUS_SHRINKS = 25893, + SPELL_VISCIDUS_SHRINKS_HP = 27934, + SPELL_VISCIDUS_GROWS = 25897, + SPELL_SUMMON_GLOBS = 25885, // summons npc 15667 using spells from 25865 to 25884; All spells have target coords + SPELL_VISCIDUS_TELEPORT = 25904, // teleport to room center + SPELL_SUMMONT_TRIGGER = 26564, // summons 15992 - NPC_GLOB_OF_VISCIDUS = 15667 + NPC_GLOB_OF_VISCIDUS = 15667, + NPC_VISCIDUS_TRIGGER = 15922, // handles aura 26575 + + MAX_VISCIDUS_GLOBS = 20, // there are 20 summoned globs; each glob = 5% hp + + // hitcounts + HITCOUNT_SLOW = 100, + HITCOUNT_SLOW_MORE = 150, + HITCOUNT_FREEZE = 200, + HITCOUNT_CRACK = 50, + HITCOUNT_SHATTER = 100, + HITCOUNT_EXPLODE = 150, + + // phases + PHASE_NORMAL = 1, + PHASE_FROZEN = 2, + PHASE_EXPLODED = 3, }; +static const uint32 auiGlobSummonSpells[MAX_VISCIDUS_GLOBS] = { 25865, 25866, 25867, 25868, 25869, 25870, 25871, 25872, 25873, 25874, 25875, 25876, 25877, 25878, 25879, 25880, 25881, 25882, 25883, 25884 }; + struct boss_viscidusAI : public ScriptedAI { boss_viscidusAI(Creature* pCreature) : ScriptedAI(pCreature) { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); Reset(); } - uint32 SalveToxiqueTimer; - uint32 HorionEmpoisonneTimer; - uint32 FlaqueTimer; - uint32 InvisibleTimer; + ScriptedInstance* m_pInstance; - int Vie; - int Froid; - bool Gele; - bool Visible; + uint8 m_uiPhase; + + uint32 m_uiHitCount; + uint32 m_uiToxinTimer; + uint32 m_uiExplodeDelayTimer; + uint32 m_uiPoisonShockTimer; + uint32 m_uiPoisonBoltVolleyTimer; + + GuidList m_lGlobesGuidList; void Reset() { - SalveToxiqueTimer = 8000; - HorionEmpoisonneTimer = 1000; - FlaqueTimer = 20000; - InvisibleTimer = 0; - Vie = 20; - Froid = 0; - Gele = false; - Visible = true; + m_uiPhase = PHASE_NORMAL; + m_uiHitCount = 0; + + m_uiExplodeDelayTimer = 0; + m_uiToxinTimer = 30000; + m_uiPoisonShockTimer = urand(7000, 12000); + m_uiPoisonBoltVolleyTimer = urand(10000, 15000); + + DoCastSpellIfCan(m_creature, SPELL_MEMBRANE_VISCIDUS, CAST_TRIGGERED); + DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_WEAKNESS, CAST_TRIGGERED); + + SetCombatMovement(true); + m_creature->SetVisibility(VISIBILITY_ON); + m_creature->SetStandState(UNIT_STAND_STATE_STAND); } - void DamageTaken(Unit *done_by, uint32 &damage) + void Aggro(Unit* /*pWho*/) { - if (damage >= m_creature->GetHealth() && Vie > 0) - damage = 0; + DoCastSpellIfCan(m_creature, SPELL_TOXIN); - if (Gele == true && done_by->GetDistance(m_creature) < 5.0f) + if (m_pInstance) + m_pInstance->SetData(TYPE_VISCIDUS, IN_PROGRESS); + } + + void JustReachedHome() + { + if (m_pInstance) + m_pInstance->SetData(TYPE_VISCIDUS, FAIL); + + DoCastSpellIfCan(m_creature, SPELL_DESPAWN_GLOBS, CAST_TRIGGERED); + } + + void JustDied(Unit* /*pKiller*/) + { + if (m_pInstance) + m_pInstance->SetData(TYPE_VISCIDUS, DONE); + } + + void JustSummoned(Creature* pSummoned) + { + if (pSummoned->GetEntry() == NPC_GLOB_OF_VISCIDUS) { - Froid++; - if (Froid == 50) - SpawnGele(); + float fX, fY, fZ; + m_creature->GetRespawnCoord(fX, fY, fZ); + pSummoned->GetMotionMaster()->MovePoint(1, fX, fY, fZ); + m_lGlobesGuidList.push_back(pSummoned->GetObjectGuid()); + } + else if (pSummoned->GetEntry() == NPC_VISCIDUS_TRIGGER) + pSummoned->AddAura(SPELL_TOXIN); + } + + void SummonedCreatureJustDied(Creature* pSummoned) + { + if (pSummoned->GetEntry() == NPC_GLOB_OF_VISCIDUS) + { + // shrink - modify scale + DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_SHRINKS, CAST_TRIGGERED); + + if (DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_SHRINKS_HP, CAST_TRIGGERED) == CAST_OK) + m_creature->SetHealth(m_creature->GetHealth() - (m_creature->GetMaxHealth() * 0.05f)); + + m_lGlobesGuidList.remove(pSummoned->GetObjectGuid()); + + // suicide if required + if (m_creature->GetHealthPercent() < 5.0f) + { + m_creature->SetVisibility(VISIBILITY_ON); + + if (DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_SUICIDE, CAST_TRIGGERED) == CAST_OK) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, nullptr, false); + } + else if (m_lGlobesGuidList.empty()) + { + m_creature->SetVisibility(VISIBILITY_ON); + m_creature->SetStandState(UNIT_STAND_STATE_STAND); + m_uiPhase = PHASE_NORMAL; + + SetCombatMovement(true); + DoStartMovement(m_creature->getVictim()); + } } } - void SummonedCreatureJustDied(Creature* unit) + void SummonedMovementInform(Creature* pSummoned, uint32 uiType, uint32 uiPointId) { - Vie--; - m_creature->CastSpell(m_creature, SPELL_VISCIDUS_SHRINKS, true); - CheckGele(); - } - - void JustSummoned(Creature* unit) - { - //unit->SetInCombatWithZone(); - unit->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ()); - } - - void SummonedMovementInform(Creature* summoned, uint32 motion_type, uint32 point_id) - { - summoned->ForcedDespawn(); - m_creature->SetHealth(m_creature->GetHealth() + m_creature->GetMaxHealth() / 20); - CheckGele(); - } - - void CheckGele() - { - if (m_creature->FindNearestCreature(NPC_GLOB_OF_VISCIDUS, 150.0f)) + if (pSummoned->GetEntry() != NPC_GLOB_OF_VISCIDUS || uiType != POINT_MOTION_TYPE || !uiPointId) return; - Froid = 0; - Gele = false; - Visible = true; - m_creature->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_MAGIC, false); - } + DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_GROWS, CAST_TRIGGERED); - void SpellHit(Unit* pCaster, const SpellEntry* pSpell) - { - if (pSpell->School == SPELL_SCHOOL_FROST && Gele == false) + m_lGlobesGuidList.remove(pSummoned->GetObjectGuid()); + pSummoned->CastSpell(m_creature, SPELL_REJOIN_VISCIDUS, true); + pSummoned->ForcedDespawn(1000); + + if (m_lGlobesGuidList.empty()) { - Froid++; - if (Froid >= 200) - { - if (DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_FREEZE, CAST_AURA_NOT_PRESENT) == CAST_OK) - { - m_creature->RemoveAurasDueToSpell(SPELL_VISCIDUS_SLOWED_MORE); - Gele = true; - Froid = 0; - m_creature->ApplySpellImmune(0, IMMUNITY_DAMAGE, SPELL_SCHOOL_MASK_MAGIC, true); - } - } - else if (Froid >= 140) - { - if (DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_SLOWED_MORE, CAST_AURA_NOT_PRESENT) == CAST_OK) - m_creature->RemoveAurasDueToSpell(SPELL_VISCIDUS_SLOWED); - } - else if (Froid >= 70) - DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_SLOWED, CAST_AURA_NOT_PRESENT); + m_creature->SetVisibility(VISIBILITY_ON); + m_creature->SetStandState(UNIT_STAND_STATE_STAND); + m_uiPhase = PHASE_NORMAL; + + SetCombatMovement(true); + DoStartMovement(m_creature->getVictim()); } } - void SpawnGele() + void DamageTaken(Unit* pDealer, uint32& uiDamage, DamageEffectType /*damagetype*/) { - m_creature->CastSpell(m_creature, SPELL_VISCIDUS_EXPLODE, true); - float x = 0.0f; - float y = 0.0f; - float z = 0.0f; - float o = 0.0f; - m_creature->GetRespawnCoord(x, y, z); - for (int i = 0; i < Vie; i++) + if (m_uiPhase != PHASE_FROZEN) + return; + + ++m_uiHitCount; + + // only count melee attacks + if (pDealer->hasUnitState(UNIT_STAT_MELEE_ATTACKING) && m_uiHitCount >= HITCOUNT_EXPLODE) { - float ang = M_PI_F * 2 * i / 20; - float X = x + 70 * cos(ang); - float Y = y + 70 * sin(ang); - float Z = z + 5.0f; - m_creature->CastSpell(X, Y, Z, 25865 + i, true); + if (m_creature->GetHealthPercent() <= 5.0f) + { + if (DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_SUICIDE, CAST_TRIGGERED) == CAST_OK) + m_creature->DealDamage(m_creature, m_creature->GetHealth(), nullptr, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, nullptr, false); + } + else if (DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_EXPLODE, CAST_TRIGGERED | CAST_INTERRUPT_PREVIOUS) == CAST_OK) + { + DoScriptText(EMOTE_EXPLODE, m_creature); + m_uiPhase = PHASE_EXPLODED; + m_uiHitCount = 0; + m_lGlobesGuidList.clear(); + uint32 uiGlobeCount = m_creature->GetHealthPercent() / 5.0f; + + DoCastSpellIfCan(m_creature, SPELL_SUMMON_GLOBS, CAST_TRIGGERED); + + for (uint8 i = 0; i < uiGlobeCount; ++i) + DoCastSpellIfCan(m_creature, auiGlobSummonSpells[i], CAST_TRIGGERED); + + m_creature->RemoveAurasDueToSpell(SPELL_VISCIDUS_FREEZE); + m_uiExplodeDelayTimer = 2000; + + SetCombatMovement(false); + m_creature->GetMotionMaster()->MoveIdle(); + m_creature->SetStandState(UNIT_STAND_STATE_DEAD); + } } - InvisibleTimer = 5000; - Froid = 0; - Gele = false; + else if (m_uiHitCount == HITCOUNT_SHATTER) + DoScriptText(EMOTE_SHATTER, m_creature); + else if (m_uiHitCount == HITCOUNT_CRACK) + DoScriptText(EMOTE_CRACK, m_creature); } - void KilledUnit(Unit* pVictim) + void SpellHit(Unit* /*pCaster*/, const SpellEntry* pSpell) { + if (m_uiPhase != PHASE_NORMAL) + return; + + // only count frost damage + if (GetSchoolMask(pSpell->School) == SPELL_SCHOOL_MASK_FROST) + { + ++m_uiHitCount; + + if (m_uiHitCount >= HITCOUNT_FREEZE) + { + m_uiPhase = PHASE_FROZEN; + m_uiHitCount = 0; + + if (m_uiHitCount == HITCOUNT_FREEZE) + { + DoScriptText(EMOTE_FROZEN, m_creature); + m_creature->RemoveAurasDueToSpell(SPELL_VISCIDUS_SLOWED_MORE); + } + DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_FREEZE, CAST_TRIGGERED); + } + else if (m_uiHitCount >= HITCOUNT_SLOW_MORE) + { + if (m_uiHitCount == HITCOUNT_SLOW_MORE) + { + DoScriptText(EMOTE_FREEZE, m_creature); + m_creature->RemoveAurasDueToSpell(SPELL_VISCIDUS_SLOWED); + } + DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_SLOWED_MORE, CAST_TRIGGERED); + } + else if (m_uiHitCount >= HITCOUNT_SLOW) + { + if (m_uiHitCount == HITCOUNT_SLOW) + { + DoScriptText(EMOTE_SLOW, m_creature); + } + DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_SLOWED, CAST_TRIGGERED); + } + } } - void JustDied(Unit* pKiller) + void ResetFrozenPhase() { - } + if (m_uiPhase == PHASE_EXPLODED) + return; - bool IsVisibleFor(Unit const* pOther, bool &isVisible) const - { - isVisible = Visible; - return true; + // reset phase if not already exploded + m_uiPhase = PHASE_NORMAL; + m_uiHitCount = 0; } void UpdateAI(const uint32 uiDiff) { - if (InvisibleTimer > 0) - { - if (InvisibleTimer <= uiDiff) - { - float x = 0.0f; - float y = 0.0f; - float z = 0.0f; - float o = 0.0f; - m_creature->GetRespawnCoord(x, y, z); - m_creature->Relocate(x, y, z, o); - m_creature->SetHealth(1); - Visible = false; - InvisibleTimer = 0; - } - else InvisibleTimer -= uiDiff; - return; - } - - if (Visible == false || Gele == true) - return; - if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; - if (SalveToxiqueTimer < uiDiff) + if (m_uiExplodeDelayTimer) { - if (DoCastSpellIfCan(m_creature, SPELL_POISONBOLT_VOLLEY) == CAST_OK) - SalveToxiqueTimer = 11000; - } - else SalveToxiqueTimer -= uiDiff; + if (m_uiExplodeDelayTimer <= uiDiff) + { + // Make invisible + m_creature->SetVisibility(VISIBILITY_OFF); - if (HorionEmpoisonneTimer < uiDiff) + DoCastSpellIfCan(m_creature, SPELL_VISCIDUS_TELEPORT, CAST_TRIGGERED); + m_uiExplodeDelayTimer = 0; + } + else + m_uiExplodeDelayTimer -= uiDiff; + } + + if (m_uiPhase != PHASE_NORMAL) + return; + + if (m_uiPoisonShockTimer < uiDiff) { if (DoCastSpellIfCan(m_creature, SPELL_POISON_SHOCK) == CAST_OK) - HorionEmpoisonneTimer = 7000; + m_uiPoisonShockTimer = urand(7000, 12000); } - else HorionEmpoisonneTimer -= uiDiff; + else + m_uiPoisonShockTimer -= uiDiff; - if (FlaqueTimer < uiDiff) + if (m_uiPoisonBoltVolleyTimer < uiDiff) + { + if (DoCastSpellIfCan(m_creature, SPELL_POISONBOLT_VOLLEY) == CAST_OK) + m_uiPoisonBoltVolleyTimer = urand(10000, 15000); + } + else + m_uiPoisonBoltVolleyTimer -= uiDiff; + + if (m_uiToxinTimer < uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { - if (DoCastSpellIfCan(pTarget, SPELL_TOXIN_SUMMON) == CAST_OK) - FlaqueTimer = 9000; + m_creature->SummonCreature(NPC_VISCIDUS_TRIGGER, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), pTarget->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 180000); + m_uiToxinTimer = 30000; } } - else FlaqueTimer -= uiDiff; + else + m_uiToxinTimer -= uiDiff; DoMeleeAttackIfReady(); } @@ -242,18 +362,30 @@ CreatureAI* GetAI_boss_viscidus(Creature* pCreature) return new boss_viscidusAI(pCreature); } +bool EffectAuraDummy_spell_aura_dummy_viscidus_freeze(const Aura* pAura, bool bApply) +{ + // On Aura removal inform the boss + if (pAura->GetId() == SPELL_VISCIDUS_FREEZE && pAura->GetEffIndex() == EFFECT_INDEX_1 && !bApply) + { + if (Creature* pTarget = (Creature*)pAura->GetTarget()) + { + if (boss_viscidusAI* pViscidusAI = dynamic_cast(pTarget->AI())) + pViscidusAI->ResetFrozenPhase(); + } + } + return true; +} + +// TODO Remove this 'script' when combat can be proper prevented from core-side struct boss_glob_of_viscidusAI : public ScriptedAI { - boss_glob_of_viscidusAI(Creature* pCreature) : ScriptedAI(pCreature) - { - } + boss_glob_of_viscidusAI(Creature* pCreature) : ScriptedAI(pCreature) { } - void AttackStart(Unit *) {} - void AttackedBy(Unit *) {} + void Reset() { } - void Reset() - { - } + void AttackStart(Unit* /*pWho*/) { } + void MoveInLineOfSight(Unit* /*pWho*/) { } + void UpdateAI(const uint32 /*uiDiff*/) { } }; CreatureAI* GetAI_boss_glob_of_viscidus(Creature* pCreature) @@ -268,6 +400,7 @@ void AddSC_boss_viscidus() pNewScript = new Script; pNewScript->Name = "boss_viscidus"; pNewScript->GetAI = &GetAI_boss_viscidus; + pNewScript->pEffectAuraDummy = &EffectAuraDummy_spell_aura_dummy_viscidus_freeze; pNewScript->RegisterSelf(); pNewScript = new Script;