Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ScriptMgr.h"
- #include "ScriptedCreature.h"
- #include "SpellScripts.h"
- #include "SpellAuraEffects.h"
- enum Spells
- {
- SPELL_ARCANE_MISSILES = 33031,
- SPELL_WRATH_OF_THE_ASTROMANCER = 42783,
- SPELL_WRATH_OF_THE_ASTROMANCER_DOT = 42784,
- SPELL_BLINDING_LIGHT = 33009,
- SPELL_DRAIN_MANA = 25671,
- SPELL_SPOTLIGHT = 25824,
- NPC_SPOTLIGHT = 18928,
- };
- const float CENTER_X = 297.673f;
- const float CENTER_Y = 11.665f;
- const float CENTER_Z = 25.386f;
- const float CENTER_O = 2.991229f;
- const float SMALL_PORTAL_RADIUS = 10.0f;
- const float LARGE_PORTAL_RADIUS = 20.0f;
- const float PORTAL_Z = 24.986f;
- class Astro_Boss : public CreatureScript
- {
- public:
- Astro_Boss() : CreatureScript("Astro_Boss") { }
- struct Astro_BossAI : public ScriptedAI
- {
- Astro_BossAI(Creature* creature) : ScriptedAI
- (creature), Summons(me) {}
- SummonList Summons;
- uint8 Phase;
- uint32 arcanemissiletimer;
- uint32 m_uiWrathOfTheAstromancer_Timer;
- uint32 BlindingLight_Timer;
- uint32 Phase1_Timer;
- uint32 Phase2_Timer;
- uint32 Phase3_Timer;
- uint32 AppearDelay_Timer;
- uint32 Wrath_Timer;
- uint32 Drain_Mana;
- float defaultsize;
- float Portals[3][3];
- bool AppearDelay;
- bool BlindingLight;
- void Reset()
- {
- arcanemissiletimer = 2000;
- m_uiWrathOfTheAstromancer_Timer = 15000;
- BlindingLight_Timer = 41000;
- Phase1_Timer = 50000;
- Phase2_Timer = 10000;
- Phase3_Timer = 15000;
- AppearDelay_Timer = 2000;
- Drain_Mana = 31000;
- BlindingLight = false;
- AppearDelay = false;
- Wrath_Timer = 20000+rand()%5000;//twice in phase one
- Phase = 1;
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- me->SetVisible(true);
- Summons.DespawnAll();
- }
- void EnterCombat(Unit* /*who*/)
- {
- DoZoneInCombat();
- }
- void SummonMinion(uint32 entry, float x, float y, float z)
- {
- Creature* Summoned = me->SummonCreature(entry, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
- if(Summoned)
- {
- if(Unit* target = SelectTarger(SELECT_TARGET_RANDOM, 0))
- Summoned->AI()->AttackStart(target);
- Summons.Summon(Summoned);
- }
- }
- float Portal_X(float radius)
- {
- if(urand(0, 1))
- radius = -radius;
- return radius * (float)(rand()%100)/100.0f + CENTER_X;
- }
- float Portal_Y(float x, float radius)
- {
- float z = RAND(1.0f, -1.0f);
- return (z*sqrt(radius*radius - (x - CENTER_X)*(X - CENTER_X)) + (CENTER_Y);
- }
- void UpdateAI(uint32 diff)
- {
- if(!UpdateVictim())
- return;
- if(AppearDelay)
- {
- me->StopMoving();
- me->AttackStop();
- if(AppearDelay_Timer <= diff)
- {
- AppearDelay = false;
- if(Phase == 2)
- {
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- me->SetVisible(false);
- }
- AppearDelay_Timer = 2000;
- }
- else
- AppearDelay_Timer -= diff;
- }
- if(Phase == 1)
- {
- if(Drain_Mana <= diff)
- {
- std::list<Unit*> targetList;
- const std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList();
- for (std::list<HostileReference*>::const_iterator
- itr = threatlist.begin(); itr != threatlist.end(); ++itr)
- if(((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && (*itr)->getTarget->getPowerType() == POWER_MANA)
- targetList.push_back((*itr)->getTarget());
- }
- Trinity::Containers::RandomResizeList(targetList, 5);
- for(std::list<Unit*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
- DoCast(*itr, SPELL_DRAIN_MANA);
- Drain_Mana = 11000;
- }
- else
- Drain_Mana -= diff;
- if(Wrath_Timer <= diff)
- {
- me->InterruptNonMeleeSpells(false);
- if(Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true))
- DoCast(target, SPELL_WRATH_OF_THE_ASTROMANCER, true);
- Wrath_Timer = 20000+rand()%5000;
- }
- else
- Wrath_Timer -= diff;
- if(arcanemissiletimer <= diff)
- {
- if(BlindingLight)
- {
- DoCastVictim(SPELL_BLINDING_LIGHT);
- BlindingLight = false;
- }
- else
- {
- if(Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
- {
- if(!me->HasInArc(2.5f, target))
- target = me->GetVictim();
- DoCast(target, SPELL_ARCANE_MISSILES);
- }
- }
- arcanemissiletimer = 3000;
- }
- else
- arcanemissiletimer -= diff;
- if(m_uiWrathOfTheAstromancer_Timer <= diff)
- {
- me->InterruptNonMeleeSpells(false);
- if(Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
- {
- if(target->GetTypeId() == TYPEID_PLAYER)
- {
- DoCast(target, SPELL_WRATH_OF_THE_ASTROMANCER);
- m_uiWrathOfTheAstromancer_Timer = 25000;
- }
- else
- m_uiWrathOfTheAstromancer_Timer = 1000;
- }
- }
- else
- m_uiWrathOfTheAstromancer_Timer -= diff;
- if(Phase1_Timer <= diff)
- {
- Phase = 2;
- Phase1_Timer = 50000;
- me->GetMotionMaster()->Clear();
- me->SetPosition(CENTER_X, CENTER_Y, CENTER_Z, CENTER_O_;
- for(uint8 i=0; i <= 2; ++i)
- {
- if(!i)
- {
- Portals[i][0] = Portal_X(SMALL_PORTAL_RADIUS);
- Portals[i][1] = Portal_Y(Portals[i][0], SMALL_PORTAL_RADIUS);
- Portals[i][2] = PORTAL_Z;
- }
- }
- if((abs(Portals[2][0] - Portals[1][0]) < 7) && (abs(Portals[2][1] - Portals[1][1]) < 7))
- {
- for i=1;
- if(abs(CENTER_X + 26.0f - Portals[2][0]) < 7)
- i = -1;
- Portals[2][0] = Portals[2][0]+7*i;
- Portals[2][1] = Portal_Y(Portals[2][0], LARGE_PORTAL_RADIUS);
- }
- for (int i = 0; i <= 2; ++i)
- {
- if (Creature* Summoned = me->SummonCreature(NPC_SPOTLIGHT, Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O,
- TEMPSUMMON_TIMED_DESPAWN, Phase2_Timer+Phase3_Timer+AppearDelay_Timer+1700))
- {
- Summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- Summoned->CastSpell(Summoned, SPELL_SPOTLIGHT, false)
- }
- }
- AppearDelay = true;
- }
- else
- Phase1_Timer -= diff;
- }
- else
- if(Phase == 2)
- {
- me->AttackStop();
- me->StopMoving();
- if(Phase2_Timer <= diff)
- {
- Phase = 3;
- for(int i=0; i <= 2; ++i)
- for(int j=1; j <= 4; j++)
- SummonMinion(15527, Portals[i][0], Portals[i][1], Portals[i][2]);
- Phase2_Timer = 10000;
- }
- else
- Phase2_Timer -= diff;
- }
- if(Phase == 3)
- {
- me->AttackStop();
- me->StopMoving();
- if(Phase3_Timer <= diff)
- {
- Phase = 1;
- int i = rand()%3;
- me->GetMotionMaster()->Clear();
- me->SetPosition(Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O);
- for(int j=0; j <= 2; j++)
- if(j != i)
- SummonMinion(15527, Portals[j][0], Portals[j][1], Portals[j][2]);
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
- me->SetVisible(true);
- AppearDelay = true;
- Phase3_Timer = 15000;
- }
- else
- Phase3_Timer -= diff;
- }
- DoMeleeAttackIfReady();
- }
- };
- class Mana_Fiend : public CreatureScript
- {
- public:
- Mana_Fiend() : CreatureScript("Mana_Fiend") {}
- struct Mana_FiendAI(Creature* creature) : ScriptedAI(creature) {}
- uint32 silenceTimer;
- void Reset()
- {
- silenceTimer = 15000;
- }
- void JustDied(Unit* /*killer*/)
- {
- DoCastAOE(25672);
- }
- void UpdateAI(uint32 diff)
- {
- if(!UpdateVictim())
- return;
- if(silenceTimer <= diff)
- {
- DoCastVictim(15122);
- silenceTimer = 12000;
- }
- else
- silenceTimer -= diff;
- DoMeleeAttackIfReady();
- }
- };
- CreatureAI* GetAI(Creature* creature) const
- {
- return new Mana_FiendAI(creature);
- }
- };
- void AddSC_Astro_Boss()
- {
- new Astro_Boxx();
- new Mana_Fiend();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement