Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptedCreature.h"
- #include "siege_of_orgrimmar.h"
- enum eSpells
- {
- /* Immerseus */
- SPELL_SWIRL = 143309,
- SPELL_CORROSIVE_BLAST = 143436,
- SPELL_SEEPING_SHA = 143281, // Areatrigger 1016 (143286)
- SPELL_SPLIT = 143020,
- SPELL_REFORM = 143469,
- SPELL_BERSERK = 64238,
- SPELL_ZERO_POWER = 72242,
- /* Puddles */
- SPELL_ERUPTING_SHA = 143498,
- SPELL_ERUPTING_WATER = 145377,
- SPELL_SHA_RESIDUE = 143459,
- SPELL_PURIFIED = 143523,
- SPELL_PURIFIED_RESIDUE = 143524,
- SPELL_CONGEALING_VISUAL = 143538,
- SPELL_CONGEALING = 143540,
- };
- enum eEvents
- {
- /* Immerseus */
- EVENT_BERSERK = 1,
- EVENT_SPLIT = 2,
- EVENT_CORROSIVE_BLAST = 3,
- EVENT_PHASE_SWIRL = 4,
- EVENT_SWIRL = 5,
- EVENT_SWIRL_ORIENTATION = 6,
- };
- enum ePhases
- {
- PHASE_NULL,
- PHASE_COMBAT,
- PHASE_SPLIT,
- PHASE_SWIRL,
- };
- #define ERUPTING_SHA_DIST 20.0f
- static Creature *GetImmerseus(WorldObject *pSource)
- {
- return ObjectAccessor::GetCreature(*pSource, pSource->GetInstanceScript()->GetData64(BOSS_IMMERSEUS));
- }
- class boss_immerseus : public CreatureScript
- {
- public:
- boss_immerseus() : CreatureScript("boss_immerseus") { }
- CreatureAI* GetAI(Creature* creature) const
- {
- if (!creature->GetVehicleKit())
- {
- TC_LOG_ERROR(LOG_FILTER_TSCR, "boss_immerseus_AI: creature should be a vehicle.");
- return NULL;
- }
- return GetSiegeOfOrgrimmarAI<boss_immerseus_AI>(creature);
- }
- struct boss_immerseus_AI : public BossAI
- {
- boss_immerseus_AI(Creature* creature) :
- BossAI(creature, DATA_IMMERSEUS) { }
- void Reset() override
- {
- _Reset();
- events.Reset();
- summons.DespawnAll();
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- me->setPowerType(POWER_ENERGY);
- me->SetMaxPower(POWER_ENERGY, me->GetCreatePowers(POWER_ENERGY));
- DoCast(me, SPELL_ZERO_POWER);
- me->SetPower(POWER_ENERGY, 100);
- me->RemoveAurasDueToSpell(SPELL_BERSERK);
- events.SetPhase(PHASE_NULL);
- DoCast(SPELL_SEEPING_SHA);
- instance->SetData(DATA_IMMERSEUS, NOT_STARTED);
- }
- void JustDied(Unit* /*killer*/) override
- {
- instance->SetData(DATA_IMMERSEUS, DONE);
- summons.DespawnAll();
- }
- void DamageTaken(Unit* /*killer*/, uint32 &damage) override
- {
- if (damage >= me->GetHealth())
- {
- damage = 0;
- events.SetPhase(PHASE_SPLIT);
- events.ScheduleEvent(EVENT_SPLIT, 0, 0, PHASE_SPLIT);
- }
- }
- void JustSummoned(Creature* summon) override
- {
- summons.Summon(summon);
- }
- void SummonedCreatureDespawn(Creature* summon) override
- {
- summons.Despawn(summon);
- }
- void EnterCombat(Unit* /*who*/) override
- {
- _EnterCombat();
- events.SetPhase(PHASE_COMBAT);
- events.ScheduleEvent(EVENT_BERSERK, 10 * MINUTE * IN_MILLISECONDS, 0, PHASE_COMBAT);
- events.ScheduleEvent(EVENT_CORROSIVE_BLAST, 10 * IN_MILLISECONDS, 0, PHASE_COMBAT);
- events.ScheduleEvent(EVENT_SWIRL, 19 * IN_MILLISECONDS, 0, PHASE_COMBAT);
- instance->SetData(DATA_IMMERSEUS, IN_PROGRESS);
- }
- void UpdateAI(uint32 diff) override
- {
- if (!UpdateVictim())
- return;
- if (me->HasUnitState(UNIT_STATE_CASTING) && !events.IsInPhase(PHASE_SWIRL))
- return;
- events.Update(diff);
- if (events.IsInPhase(PHASE_COMBAT) && me->GetPower(POWER_ENERGY) <= 0)
- me->Kill(me);
- switch (events.ExecuteEvent())
- {
- case EVENT_BERSERK:
- DoCast(SPELL_BERSERK);
- events.CancelEvent(EVENT_BERSERK);
- break;
- case EVENT_SPLIT:
- DoCast(SPELL_SPLIT);
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- events.CancelEvent(EVENT_SPLIT);
- break;
- case EVENT_CORROSIVE_BLAST:
- DoCastVictim(SPELL_CORROSIVE_BLAST);
- events.ScheduleEvent(EVENT_CORROSIVE_BLAST, 23 * IN_MILLISECONDS, 0, PHASE_COMBAT);
- break;
- case EVENT_PHASE_SWIRL:
- events.SetPhase(PHASE_SWIRL);
- events.ScheduleEvent(EVENT_SWIRL, 0, 0, PHASE_SWIRL);
- events.CancelEvent(EVENT_PHASE_SWIRL);
- break;
- case EVENT_SWIRL:
- DoCast(SPELL_SWIRL);
- events.ScheduleEvent(EVENT_SWIRL_ORIENTATION, 0, 0, PHASE_SWIRL);
- events.ScheduleEvent(EVENT_SWIRL, 20 * IN_MILLISECONDS, 0, PHASE_COMBAT);
- break;
- case EVENT_SWIRL_ORIENTATION:
- {
- uint32 duration = 0;
- float pitch = float(M_PI * 2 * (1 / 3) / 10 * IN_MILLISECONDS);
- while (duration < 10 * IN_MILLISECONDS)
- {
- float newOrientation = pitch + me->GetOrientation();
- if (newOrientation > M_PI * 2)
- newOrientation -= M_PI * 2;
- me->SetOrientation(newOrientation);
- me->SendMovementUpdate();
- duration++;
- }
- events.SetPhase(PHASE_COMBAT);
- events.CancelEvent(EVENT_SWIRL_ORIENTATION);
- break;
- }
- default:
- break;
- }
- DoMeleeAttackIfReady();
- }
- };
- };
- // #71603# Sha Puddle
- class npc_sha_puddle : public CreatureScript
- {
- public:
- npc_sha_puddle() : CreatureScript("npc_sha_puddle") { }
- struct npc_sha_puddleAI : public ScriptedAI
- {
- npc_sha_puddleAI(Creature* creature) : ScriptedAI(creature)
- {
- instance = creature->GetInstanceScript();
- }
- InstanceScript* instance;
- void Reset() override
- {
- me->SetReactState(REACT_PASSIVE);
- if (instance)
- if (Creature* immerseus = GetImmerseus(me))
- me->GetMotionMaster()->MovePoint(0, immerseus->GetPositionX(), immerseus->GetPositionY(), immerseus->GetPositionZ());
- }
- void JustDied(Unit* /*killer*/) override
- {
- if (instance)
- if (Creature* immerseus = GetImmerseus(me))
- immerseus->ModifyPower(POWER_ENERGY, -1);
- DoCast(SPELL_SHA_RESIDUE);
- me->DespawnOrUnsummon(4 * IN_MILLISECONDS);
- }
- void EnterCombat(Unit* who) override { }
- void UpdateAI(uint32 diff) override
- {
- if (instance)
- if (Creature* immerseus = GetImmerseus(me))
- if (me->GetExactDist2d(immerseus) <= 25.0f)
- {
- DoCast(SPELL_ERUPTING_SHA);
- me->DespawnOrUnsummon();
- }
- }
- };
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new npc_sha_puddleAI(creature);
- }
- };
- // #71604# Contaminated Puddle
- class npc_contaminated_puddle : public CreatureScript
- {
- public:
- npc_contaminated_puddle() : CreatureScript("npc_contaminated_puddle") { }
- struct npc_contaminated_puddleAI : public ScriptedAI
- {
- npc_contaminated_puddleAI(Creature* creature) : ScriptedAI(creature)
- {
- instance = creature->GetInstanceScript();
- }
- InstanceScript* instance;
- bool fullHealth;
- void Reset() override
- {
- fullHealth = false;
- me->SetReactState(REACT_PASSIVE);
- me->SetHealth(int32(me->GetMaxHealth() * .1f));
- if (instance)
- if (Creature* immerseus = GetImmerseus(me))
- me->GetMotionMaster()->MovePoint(0, immerseus->GetPositionX(), immerseus->GetPositionY(), immerseus->GetPositionZ());
- }
- void HealReceived(Unit* /*healer*/, uint32& heal) override
- {
- if (!me->HasAura(SPELL_CONGEALING_VISUAL))
- {
- DoCast(SPELL_CONGEALING_VISUAL);
- DoCast(SPELL_CONGEALING);
- }
- if (!fullHealth && heal >= me->GetMaxHealth() - me->GetHealth())
- {
- me->RemoveAurasDueToSpell(SPELL_CONGEALING);
- DoCast(SPELL_PURIFIED);
- DoCast(SPELL_PURIFIED_RESIDUE);
- if (instance)
- if (Creature* immerseus = GetImmerseus(me))
- immerseus->ModifyPower(POWER_ENERGY, -1);
- fullHealth = true;
- }
- }
- void JustDied(Unit* /*killer*/) override { }
- void EnterCombat(Unit* who) override { }
- void UpdateAI(uint32 diff) override
- {
- if (int32 healthPerStack = me->GetHealth() / me->GetMaxHealth() * 10)
- if (Aura* congealing = me->GetAura(SPELL_CONGEALING))
- if (healthPerStack > 1)
- congealing->SetStackAmount(healthPerStack);
- if (instance)
- if (Creature* immerseus = GetImmerseus(me))
- if (me->GetExactDist2d(immerseus) <= 25.0f)
- {
- if (!me->HasAura(SPELL_PURIFIED))
- DoCast(SPELL_ERUPTING_WATER);
- me->DespawnOrUnsummon();
- }
- }
- };
- CreatureAI* GetAI(Creature* creature) const override
- {
- return new npc_contaminated_puddleAI(creature);
- }
- };
- void AddSC_immerseus()
- {
- sScriptMgr->AddScript(new boss_immerseus());
- sScriptMgr->AddScript(new npc_sha_puddle());
- sScriptMgr->AddScript(new npc_contaminated_puddle());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement