stoneharry

Untitled

Jun 4th, 2012
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 24.47 KB | None | 0 0
  1. /*
  2.  * ArcScripts for ArcEmu MMORPG Server
  3.  * Copyright (C) 2009 ArcEmu Team <http://www.arcemu.org/>
  4.  *
  5.  * This program is free software: you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation, either version 3 of the License, or
  8.  * any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. #include "StdAfx.h"
  20. #include "Setup.h"
  21. #include "../Common/Base.h"
  22.  
  23. static Coords RoomPoints[]=
  24. {
  25.     { 1646.411499f, -280.270538f, 417.321686f },
  26.     { 1654.442139f, -296.619995f, 417.321686f },
  27.     { 1649.935181f, -312.869995f, 417.321991f },
  28.     { 1635.889160f, -323.114960f, 417.321991f },
  29.     { 1626.588257f, -334.422952f, 417.321991f },
  30.     { 1609.273315f, -325.008759f, 417.321991f },
  31.     { 1613.084351f, -311.113373f, 417.321991f },
  32.     { 1608.645264f, -300.140015f, 417.321991f },
  33.     { 1611.737549f, -287.944885f, 417.321991f },
  34.     { 1622.536509f, -289.462799f, 417.321991f },
  35.     { 1634.319824f, -276.142670f, 417.321991f },
  36.     { 1642.059082f, -288.031097f, 417.321991f },
  37.     { 1654.436279f, -286.942200f, 417.321991f }
  38. };
  39.  
  40. static Coords BlackHoleSpawns[]=
  41. {
  42.     { 1640.192749f, -313.252136f, 417.321686f, 2.244802f },
  43.     { 1621.535767f, -311.449310f, 417.321686f, 0.723486f },
  44.     { 1625.286743f, -291.989807f, 417.321686f, 5.373048f },
  45.     { 1643.084351f, -301.061035f, 417.321686f, 3.614546f }
  46. };
  47.  
  48. static Coords BronzebeardWaypoint[]=
  49. {
  50.     { 1632.451904f, -173.976532f, 427.262726f, 4.693232f, 0 },
  51.     { 1631.937988f, -221.072922f, 418.409332f, 4.693232f, 0 }
  52. };
  53.  
  54. static Coords LivingConstellationWP[]=
  55. {
  56.     { 1618.260010f, -303.169342f, 420.658508f, 6.241804f },
  57.     { 1631.825928f, -319.399384f, 421.392365f, 1.560456f },
  58.     { 1642.386353f, -305.013702f, 421.466583f, 3.218021f }
  59. };
  60.  
  61. static Coords LivingConstellationSpawn[]=
  62. {
  63.     { 1678.458862f, -306.932587f, 438.095001f, 3.126851f },
  64.     { 1588.860718f, -312.406250f, 536.889526f, 6.256645f },
  65.     { 1633.562012f, -355.855469f, 434.713654f, 1.860765f }
  66. };
  67.  
  68. static Coords AlgalonEndEvent[]=
  69. {
  70.     { 1632.140381f, -302.678314f, 417.321106f, 1.604511f },
  71.     { 1632.315308f, -307.865356f, 417.321106f, 1.604511f }
  72. };
  73.  
  74. enum ALGALON_DEFINES
  75. {
  76.     // Game Objects
  77.     Doodad_UL_SigilDoor_01                      = 194767,
  78.     Doodad_UL_UniverseGlobe_01                  = 194148,
  79.     Doodad_UL_UniverseFloor_01                  = 194715,
  80.     Doodad_UL_UniverseFloor_02                  = 194716,
  81.     Doodad_UL_TrapDoor_03                       = 194253,
  82.     Doodad_UL_SigilDoor_03                      = 194910,
  83.     UL_GIFT_OF_THE_OBSERVER                     = 194821,
  84.     // Creatures
  85.     CN_ALGALON                                  = 32871,
  86.     CN_BRANN                                    = 33235,  // used at intro scene
  87.     CN_AZEROTH                                  = 34246,
  88.     CN_COLLAPSING_STAR                          = 32955,
  89.     CN_BLACK_HOLE                               = 32953,
  90.     CN_LIVING_CONSTELLATION                     = 33052,
  91.     CN_DARK_MATTER                              = 33089,
  92.     CN_UNLEASEHED_DARK_MATTER                   = 34097,
  93.     // Algalon Spells
  94.     ALGALON_QUANTUM_STRIKE_10                   = 64395,
  95.     ALGALON_QUANTUM_STRIKE_25                   = 64592,
  96.     ALGALON_BIG_BANG_10                         = 64443,
  97.     ALGALON_BIG_BANG_25                         = 64584,
  98.     ALGALON_BERSEK                              = 47008,
  99.     ALGALON_PHASE_PUNCH                         = 64412,
  100.     ALGALON_ASCEND_TO_HEAVENS                   = 64487,
  101.     // Stars spells
  102.     STAR_EXPLODE                                = 64122, // used on stars death
  103.     STAR_SUMMON_BLACK_HOLE                      = 62189,
  104.     // phase related spells
  105.     BLACK_HOLE_DAMAGE_AURA                      = 62169,
  106.     BLACK_HOLE_PHASE_AURA                       = 64417,
  107.     BLACK_HOLE_VISUAL_VOID_ZONE                 = 64017,
  108.     // Living Constellation spells
  109.     ARCANE_BARRAGE                              = 64599,
  110.     // thanks to Compboy for this 2 ids, start event spells
  111.     ALGALON_CHANNEL                             = 64996,
  112.     ALGALON_ARRIVAL                             = 64997,
  113.     // achievement killcredit spell
  114.     ALGALON_KILLCREDIT                          = 65184,
  115.     // Algalon Sound ids
  116.     UR_ALGALON_SUMMON01                         = 15405,      //UR_Algalon_Summon01.wav
  117.     UR_ALGALON_SUMMON02                         = 15406,      //UR_Algalon_Summon02.wav
  118.     UR_ALGALON_SUMMON03                         = 15407,     //UR_Algalon_Summon03.wav
  119.     UR_ALGALON_AGGRO01                          = 15386,      //UR_Algalon_Aggro01.wav
  120.     UR_ALGALON_ADDS01                           = 15392,      //UR_Algalon_Adds01.wav
  121.     UR_ALGALON_BHOLE01                          = 15391,      //UR_Algalon_BHole01.wav
  122.     UR_ALGALON_SPECIAL01                        = 15396,      //UR_Algalon_Special01.wav
  123.     UR_ALGALON_SPACE01                          = 15390,      //UR_Algalon_Space01.wav
  124.     UR_ALGALON_BERSERK01                        = 15394,      //UR_Algalon_Berzerk01.wav
  125.     // Branns sound ids
  126.     UR_BRANN_ALGALONSUMMONED01                  = 15824,      //UR_Brann_AlgalonSummoned01.wav
  127.     UR_BRANN_ALGALONSUMMONED02                  = 15825,      //UR_Brann_AlgalonSummoned02.wav
  128.     // timer macros
  129.     TIMER_STAR_01                               = 15000,
  130.     TIMER_STAR_02                               = 40000,
  131.     TIMER_START_DELAY                           = 12000,
  132.     TIMER_BIG_BANG                              = 90000,
  133.     TIMER_BIG_BANG_CAST                         = 8000,
  134.     TIMER_ENRAGE                                = 360000,
  135.     TIMER_SUMMON_DARK_MATTER                    = 30000,
  136.     TIMER_LIVING_CONSTELLATION_JOIN             = 38000,
  137. };
  138.  
  139. typedef std::vector<Creature*> EncounterArray;
  140.  
  141. class AlgalonAI : public MoonScriptBossAI
  142. {
  143. public:
  144.     MOONSCRIPT_FACTORY_FUNCTION(AlgalonAI, MoonScriptBossAI);
  145.     AlgalonAI(Creature* pCreature) : MoonScriptBossAI(pCreature)
  146.     {
  147.         AddPhaseSpell( 2, AddSpell( ALGALON_QUANTUM_STRIKE_10, Target_Current, 50, 0, 6 ) );
  148.         AddPhaseSpell( 2, AddSpell( ALGALON_PHASE_PUNCH, Target_Current, 99, 0, 12 ) );
  149.         AddPhaseSpell( 3, AddSpell( ALGALON_QUANTUM_STRIKE_10, Target_Current, 50, 0, 6 ) );
  150.         AddPhaseSpell( 3, AddSpell( ALGALON_PHASE_PUNCH, Target_Current, 99, 0, 12 ) );
  151.         mEnrage = AddSpell( ALGALON_BERSEK, Target_Self, 0, 0, 0 ); // 6 minutes enrage
  152.  
  153.         AddEmote( Event_OnCombatStart, "Your actions are illogical. All possible results for this encounter have been calculated. The pantheon will receive the observer's message regardless outcome.", Text_Yell, UR_ALGALON_AGGRO01 );
  154.    
  155.         SetCanEnterCombat( false );
  156.         SetFlyMode( true );
  157.  
  158.         mIntro = true;
  159.         mFirstEncounter = true;
  160.         mEndScene = false;
  161.         mScene = 0;
  162.         mTimer = 0;
  163.         pAzeroth = NULL;
  164.        
  165.         _bigBang = false;
  166.         mEnrageTimer = INVALIDATE_TIMER;
  167.         mAddTimer = INVALIDATE_TIMER;
  168.         mTimeoutTimer = INVALIDATE_TIMER;
  169.         mBigBangTimer = INVALIDATE_TIMER;
  170.  
  171.         RegisterAIUpdateEvent( 1000 );
  172.     };
  173.  
  174.     void OnCombatStart(Unit* pTarget)
  175.     {
  176.         // additional spell timers
  177.         mAddTimer = AddTimer( TIMER_STAR_01 + TIMER_START_DELAY ); // star timer
  178.         mBigBangTimer = AddTimer( TIMER_BIG_BANG + TIMER_START_DELAY ); //90 seconds + 12 seconds
  179.         mEnrageTimer = AddTimer( TIMER_ENRAGE ); // 6 minutes
  180.         _bigBang = false;
  181.  
  182.         // add timers and stop him from doing anything
  183.         mTimeoutTimer = AddTimer( TIMER_START_DELAY );
  184.         DelayNextAttack( TIMER_START_DELAY );
  185.         _unit->SetUInt64Value( UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_9 );
  186.        
  187.         SetAllowMelee( false );
  188.         SetAllowSpell( false );
  189.         SetAllowTargeting( false );
  190.         SetCanMove( false );
  191.         TriggerCooldownOnAllSpells();
  192.    
  193.         ParentClass::OnCombatStart( pTarget );
  194.     };
  195.  
  196.    
  197.  
  198.     void AIUpdate()
  199.     {
  200.         if( mIntro )
  201.         {
  202.             ++mTimer;
  203.             switch( mTimer )
  204.             {
  205.             case 1:
  206.             case 5:
  207.             case 9:
  208.             case 12:
  209.             case 19:
  210.             case 29:
  211.             case 34:
  212.                 IntroScene();
  213.             break;
  214.             }; 
  215.         }
  216.  
  217.        
  218.  
  219.         if( GetHealthPercent() <= 3 && GetPhase() == 3 )
  220.         {
  221.             // lets set him out of combat
  222.             mEndScene = true;
  223.             SetCanEnterCombat(false);
  224.             _unit->GetAIInterface()->HandleEvent( EVENT_LEAVECOMBAT, _unit, 0 );
  225.            
  226.             AddWaypoint(CreateWaypoint( 1, 0, Flag_Run, AlgalonEndEvent[1] ));
  227.             ForceWaypointMove( 1 );
  228.         };
  229.  
  230.         if( GetHealthPercent() <= 20 && GetPhase() == 2 )
  231.             PhaseThree();
  232.  
  233.         if( IsTimerFinished( mEnrageTimer ) )
  234.         {
  235.             CastSpellNowNoScheduling( mEnrage );
  236.             Emote( "You are... out of time.", Text_Yell, UR_ALGALON_BERSERK01 );
  237.             RemoveTimer( mEnrageTimer );
  238.         };
  239.  
  240.         if( IsTimerFinished( mTimeoutTimer ) )
  241.             StartHandler();
  242.  
  243.         if( IsTimerFinished( mAddTimer ) )
  244.             SummonStars();
  245.        
  246.         if( IsTimerFinished( mBigBangTimer ) )
  247.             BigBang();
  248.  
  249.         ParentClass::AIUpdate();
  250.     };
  251.  
  252.     void OnCombatStop(Unit* pTarget)
  253.     {
  254.         DespawnAllEncounterCreatures();
  255.  
  256.         if( pPlanet != NULL && pPlanet->GetState() == 0)
  257.             pPlanet->SetState(1);
  258.  
  259.         if( pFloor1 != NULL && pFloor1->GetState() == 1)
  260.             pFloor1->SetState(0);
  261.        
  262.         if( pFloor2 != NULL && pFloor2->GetState() == 0)
  263.             pFloor2->SetState(1);
  264.  
  265.         if( pTrapDoor != NULL && pTrapDoor->GetState() == 0 )
  266.             pTrapDoor->SetState(1);
  267.  
  268.         if( pLimitDoor != NULL && pFloor2->GetState() == 1 )       
  269.             pLimitDoor->SetState(0);
  270.  
  271.         ParentClass::OnCombatStop( pTarget );
  272.  
  273.         if( !mEndScene )
  274.         {
  275.             /* to prevent possible bugs */
  276.             mFirstEncounter = false;
  277.             RemoveAIUpdateEvent();
  278.             _unit->SetUInt64Value( UNIT_FIELD_FLAGS, 0 );
  279.         }
  280.     };
  281.  
  282.     void OnReachWP(uint32 iWaypointId, bool bForwards )
  283.     {
  284.         if ( iWaypointId == 1 )
  285.         {
  286.             /*for( set<Player*>::iterator PlayerIter = _unit->GetInRangePlayerSetBegin(); PlayerIter != _unit->GetInRangePlayerSetEnd(); ++PlayerIter )
  287.             {
  288.                 (*PlayerIter)->CastSpell( (*PlayerIter), ALGALON_KILLCREDIT, true );
  289.             }*/
  290.             _unit->GetMapMgr()->GetInterface()->SpawnGameObject( UL_GIFT_OF_THE_OBSERVER, AlgalonEndEvent[0].mX, AlgalonEndEvent[0].mY, AlgalonEndEvent[0].mZ, AlgalonEndEvent[0].mO, false, 0, 0, 1 );
  291.             //RegisterAIUpdate( 1000 );
  292.             //_unit->CombatStatus.TryToClearAttackTargets();
  293.         };
  294.     };
  295.  
  296.     void IntroScene()
  297.     {
  298.         if( mScene != 7 )
  299.         {
  300.             switch( mScene )
  301.             {
  302.             case 0:
  303.                 _unit->CastSpell( _unit, ALGALON_ARRIVAL, true );
  304.                 break;
  305.             case 1:
  306.                 Emote( "Translocation complete. Commencing planetary analysis of Azeroth.", Text_Say, UR_ALGALON_SUMMON01 );
  307.                 break;
  308.             case 2:
  309.                 _unit->Emote( EMOTE_ONESHOT_SPELLCAST_OMNI );
  310.                 SpawnCreature( CN_AZEROTH, 1631.762817f, -293.814301f, 417.321106f, 1.573153f );
  311.                 break;
  312.             case 3:
  313.                 Emote( "Stand back mortals. I am not here to fight you.", Text_Say, UR_ALGALON_SUMMON02 );
  314.                 SetFlyMode( false );
  315.                 pAzeroth = static_cast<Creature*>( ForceCreatureFind(CN_AZEROTH, 1631.762817f, -293.814301f, 417.321106f ) );
  316.                 if( pAzeroth != NULL )
  317.                     SetTargetToChannel( pAzeroth, ALGALON_CHANNEL );
  318.                 break;
  319.             case 4:
  320.                 Emote( "It is in the universe's best interest to re-originate this planet, should my analysis find systemic corruption. Do not interfere.", Text_Say, UR_ALGALON_SUMMON03 );
  321.                 break;
  322.             case 5:
  323.                 SetTargetToChannel( NULL, 0 );
  324.                 pAzeroth->Despawn(0, 0);
  325.                 break;
  326.             case 6:
  327.                 SetCanEnterCombat( true );
  328.                 mIntro = false;
  329.                 RemoveAIUpdateEvent();
  330.                 break;
  331.             }
  332.             ++mScene;
  333.         }
  334.     };
  335.  
  336.     void StartHandler()
  337.     {
  338.         if( mFirstEncounter )
  339.         {
  340.             Emote( "See your world through my eyes: A universe so vast as to be immeasurable - incomprehensible even to your greatest minds.", Text_Yell, UR_ALGALON_SPACE01 );
  341.             mFirstEncounter = false;
  342.         };
  343.  
  344.         _unit->SetUInt64Value( UNIT_FIELD_FLAGS, 0 );
  345.  
  346.         SetAllowMelee( true );
  347.         SetAllowSpell( true );
  348.         SetAllowTargeting( true );
  349.         SetCanMove( true );
  350.         TriggerCooldownOnAllSpells();
  351.  
  352.         pPlanet = GetNearestGameObject( Doodad_UL_UniverseGlobe_01 );
  353.         if( pPlanet != NULL && pPlanet->GetState() == 1 )
  354.             pPlanet->SetState( 0 );
  355.  
  356.         pFloor1 = GetNearestGameObject( Doodad_UL_UniverseFloor_01 );
  357.         if( pFloor1 != NULL && pFloor1->GetState() == 0 )
  358.             pFloor1->SetState( 1 );
  359.  
  360.         pFloor2 = GetNearestGameObject( Doodad_UL_UniverseFloor_02 );
  361.         if( pFloor2 != NULL && pFloor2->GetState() == 1 )
  362.             pFloor2->SetState( 0 );
  363.  
  364.         pTrapDoor = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords( 1632.324585f, -246.840393f, 417.323151f, Doodad_UL_TrapDoor_03 );
  365.         if( pTrapDoor != NULL && pFloor2->GetState() == 1 )    
  366.             pTrapDoor->SetState( 0 );
  367.  
  368.         pLimitDoor = _unit->GetMapMgr()->GetInterface()->GetGameObjectNearestCoords( 1632.324585f, -246.840393f, 417.323151f, Doodad_UL_SigilDoor_03 );
  369.         if( pLimitDoor != NULL && pFloor2->GetState() == 0 )       
  370.             pLimitDoor->SetState( 1 );
  371.  
  372.         for( int i=0; i < 3; i++ )
  373.         {
  374.             SpawnCreature( CN_LIVING_CONSTELLATION, LivingConstellationSpawn[i].mX, LivingConstellationSpawn[i].mY, LivingConstellationSpawn[i].mZ, LivingConstellationSpawn[i].mO, 1 );
  375.         };
  376.        
  377.         SetPhase( 2 );
  378.         RemoveTimer( mTimeoutTimer );
  379.     };
  380.  
  381.     void SummonStars()
  382.     {
  383.         _unit->SendChatMessage(CHAT_MSG_RAID_BOSS_EMOTE, LANG_UNIVERSAL, "Algalon the Observer begins to Summon Collapsing Stars!" );
  384.         Emote( "The stars come to my aid.", Text_Yell, UR_ALGALON_ADDS01 );
  385.  
  386.         uint32 mRandom = 0;
  387.         for( int i = 0; i < 4; i++ )
  388.         {
  389.             mRandom = RandomUInt( 11 );
  390.             SpawnCreature( CN_COLLAPSING_STAR, RoomPoints[mRandom].mX, RoomPoints[mRandom].mY, RoomPoints[mRandom].mZ, 0, true, 1 );
  391.         };         
  392.         ResetTimer( mAddTimer, TIMER_STAR_02 );
  393.     };
  394.  
  395.     void BigBang()
  396.     {
  397.         if( !_bigBang )
  398.         {
  399.             _unit->CastSpell( _unit, dbcSpell.LookupEntryForced(ALGALON_BIG_BANG_10), false );
  400.             _unit->SendChatMessage(CHAT_MSG_RAID_BOSS_EMOTE, LANG_UNIVERSAL, "Algalon the Observer begins to cast Big Bang!" );
  401.             Emote( "Witness the fury of cosmos!", Text_Yell, UR_ALGALON_SPECIAL01 );
  402.             _bigBang = true;
  403.             ResetTimer( mBigBangTimer, TIMER_BIG_BANG_CAST ); //8 seconds cast time
  404.         }
  405.         else
  406.         {
  407.             bool mPhasedPlayer = false;
  408.  
  409.             for( set<Player*>::iterator PlayerIter = _unit->GetInRangePlayerSetBegin(); PlayerIter != _unit->GetInRangePlayerSetEnd(); ++PlayerIter )
  410.             {
  411.                 if( (*PlayerIter)->GetPhase() == 1 )
  412.                     mPhasedPlayer = true;
  413.                 else
  414.                     (*PlayerIter)->RemoveAura( BLACK_HOLE_PHASE_AURA );
  415.             }
  416.  
  417.             if( mPhasedPlayer == false )
  418.             _unit->CastSpell( _unit, ALGALON_ASCEND_TO_HEAVENS, false ); // wipe raid
  419.             _bigBang = false;
  420.             ResetTimer( mBigBangTimer, TIMER_BIG_BANG );
  421.         };
  422.     };
  423.  
  424.     void PhaseThree()
  425.     {
  426.         DespawnAllEncounterCreatures();
  427.         for( int i = 0; i < 4; ++i )
  428.         {
  429.             SpawnCreature( CN_BLACK_HOLE, BlackHoleSpawns[i].mX,  BlackHoleSpawns[i].mY,  BlackHoleSpawns[i].mZ,  BlackHoleSpawns[i].mO, false );
  430.         };
  431.         Emote("Beware!", Text_Yell, UR_ALGALON_BHOLE01);
  432.         RemoveTimer( mAddTimer );
  433.         RemoveTimer( mBigBangTimer );
  434.         SetPhase( 3 );
  435.     };
  436.  
  437.     void AddEncounterCreature( Creature* pCreature )
  438.     {
  439.         mEncounterArray.push_back( pCreature );
  440.     };
  441.  
  442.     void DespawnAllEncounterCreatures()
  443.     {
  444.         for( vector<Creature*>::iterator CreatureIter = mEncounterArray.begin(); CreatureIter != mEncounterArray.end(); ++CreatureIter )
  445.         {
  446.             if( (*CreatureIter) != NULL )
  447.                 (*CreatureIter)->Despawn( 0, 0);
  448.         };
  449.         mEncounterArray.clear();
  450.     };
  451.  
  452.     void Destroy()
  453.     {
  454.         delete this;
  455.     };
  456.  
  457.     // Vars:
  458.     // Game Objects
  459.     GameObject*     pPlanet;
  460.     GameObject*     pFloor1;
  461.     GameObject*     pFloor2;
  462.     GameObject*     pTrapDoor;
  463.     GameObject*     pLimitDoor;
  464.  
  465.     // Spell Desc
  466.     SpellDesc*      mEnrage;
  467.  
  468.     // Creature pointer
  469.     Creature*       pAzeroth;
  470.  
  471.     // boolean
  472.     bool            mIntro;
  473.     bool            mFirstEncounter;
  474.     bool            mEndScene;
  475.     bool            _bigBang;
  476.  
  477.     // counters
  478.     uint32          mScene;
  479.     uint32          mTimer;
  480.  
  481.     // timers
  482.     int32           mEnrageTimer;
  483.     int32           mAddTimer;
  484.     int32           mTimeoutTimer;
  485.     int32           mBigBangTimer;
  486.  
  487. private:
  488.     EncounterArray  mEncounterArray;
  489. };
  490.  
  491. class AlgalonDoorGO : public GameObjectAIScript
  492. {
  493. public:
  494.     AlgalonDoorGO(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
  495.     static GameObjectAIScript *Create(GameObject* GO) { return new AlgalonDoorGO(GO); }
  496.  
  497.     void OnActivate(Player* pPlayer)
  498.     {
  499.         RegisterAIUpdateEvent( 45000 );
  500.         _gameobject->GetMapMgr()->GetInterface()->SpawnCreature( CN_BRANN, BronzebeardWaypoint[0].mX, BronzebeardWaypoint[0].mY, BronzebeardWaypoint[0].mZ, BronzebeardWaypoint[0].mO, true, true, NULL, NULL, 1);
  501.     };
  502.    
  503.     void AIUpdate()
  504.     {
  505.         _gameobject->GetMapMgr()->GetInterface()->SpawnCreature( CN_ALGALON, 1631.954712f, -303.857910f, 417.321167f, 1.482785f, true, true, NULL, NULL, 1);
  506.         _gameobject->Despawn( 1000, 0 );
  507.     };
  508.  
  509.     void Destroy()
  510.     {
  511.         delete this;
  512.     };
  513. };
  514.  
  515. class AzerothAI : public CreatureAIScript
  516. {
  517. public:
  518.     ADD_CREATURE_FACTORY_FUNCTION(AzerothAI);
  519.     AzerothAI(Creature* pCreature) : CreatureAIScript(pCreature) {};
  520.  
  521.     void OnLoad()
  522.     {
  523.         _unit->SetUInt64Value( UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE );
  524.         _unit->GetAIInterface()->SetAllowedToEnterCombat( false );
  525.     };
  526.  
  527.     void Destroy()
  528.     {
  529.         delete this;
  530.     };
  531. };
  532.  
  533. class CollapsingStarAI : public MoonScriptCreatureAI
  534. {
  535.     MOONSCRIPT_FACTORY_FUNCTION(CollapsingStarAI, MoonScriptCreatureAI);
  536.     CollapsingStarAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature){}
  537.  
  538.     void OnLoad()
  539.     {
  540.         RegisterAIUpdateEvent( 1000 );
  541.         _unit->GetAIInterface()->SetAllowedToEnterCombat( false );
  542.         SetAllowTargeting( false );
  543.         uint32 mRandom = RandomUInt(  11 );
  544.         MoveTo(RoomPoints[mRandom].mX, RoomPoints[mRandom].mY, RoomPoints[mRandom].mZ, false);
  545.         mMoveCounter = 0;
  546.  
  547.         AlgalonAI* mAlgalon = NULL;
  548.         Creature* pAlgalon = static_cast<Creature*>(ForceCreatureFind( CN_ALGALON, 1632.250000f, -307.548004f, 416.264008f));
  549.         if ( pAlgalon != NULL && pAlgalon->GetScript() != NULL )
  550.         {
  551.                 mAlgalon = (AlgalonAI*)(pAlgalon->GetScript());
  552.                 mAlgalon->AddEncounterCreature( _unit );
  553.         }
  554.         pAlgalon = NULL;
  555.         mAlgalon = NULL;
  556.     };
  557.  
  558.     void AIUpdate()
  559.     {
  560.         ++mMoveCounter;
  561.         uint32 mHealth = _unit->GetUInt32Value(UNIT_FIELD_HEALTH);
  562.         _unit->SetUInt32Value( UNIT_FIELD_HEALTH, mHealth - ( mHealth / 100 ) ); // loose 1 pct every sec
  563.         if(mMoveCounter == 5)
  564.         {
  565.             uint32 mRandom = RandomUInt( 11 );
  566.             MoveTo(RoomPoints[mRandom].mX, RoomPoints[mRandom].mY, RoomPoints[mRandom].mZ, false);
  567.             mMoveCounter = 0;
  568.         };
  569.  
  570.         ParentClass::AIUpdate();
  571.     };
  572.  
  573.     void OnDied(Unit* pUnit)
  574.     {
  575.         _unit->CastSpell(_unit, STAR_EXPLODE, true );
  576.         _unit->CastSpell(_unit, STAR_SUMMON_BLACK_HOLE, true );
  577.  
  578.         CancelAllSpells();
  579.         CancelAllTimers();
  580.         RemoveAllAuras();
  581.  
  582.         Despawn( 1000, 0 );
  583.     };
  584.  
  585.     void Destroy()
  586.     {
  587.         delete this;
  588.     };
  589.  
  590. private:
  591.     uint32  mMoveCounter;
  592. };
  593.  
  594. class BlackHoleAI : public MoonScriptCreatureAI
  595. {
  596.     MOONSCRIPT_FACTORY_FUNCTION(BlackHoleAI, MoonScriptCreatureAI);
  597.     BlackHoleAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature){}
  598.    
  599.     void OnLoad()
  600.     {
  601.         _unit->SetUInt64Value( UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE );
  602.         _unit->GetAIInterface()->SetAllowedToEnterCombat( false );
  603.         mVoidZone = false;
  604.  
  605.         Creature* pAlgalon = static_cast<Creature*>(ForceCreatureFind( CN_ALGALON, 1632.250000f, -307.548004f, 416.264008f));
  606.         AlgalonAI* mAlgalon = NULL;
  607.         if ( pAlgalon != NULL && pAlgalon->GetScript() != NULL )
  608.         {
  609.                 mAlgalon = (AlgalonAI*)(pAlgalon->GetScript());
  610.                 mAlgalon->AddEncounterCreature( _unit );
  611.                 if( mAlgalon->GetPhase() == 3 )
  612.                     mPhaseTwo = true;
  613.         }
  614.         pAlgalon = NULL;
  615.         mAlgalon = NULL;
  616.  
  617.         RegisterAIUpdateEvent( 100 );
  618.     };
  619.  
  620.     void AIUpdate()
  621.     {
  622.         Unit* pPlayer = GetNearestPlayer();
  623.         if( pPlayer != NULL && pPlayer->isAlive() == true && pPlayer->GetDistance2dSq(static_cast<Object*>(_unit)) <= 3.5f )
  624.         {
  625.             if( !pPlayer->HasAura( BLACK_HOLE_PHASE_AURA ) )
  626.             {
  627.                 _unit->CastSpell( pPlayer, BLACK_HOLE_DAMAGE_AURA, true);
  628.                 pPlayer->CastSpell( pPlayer, BLACK_HOLE_PHASE_AURA, true);
  629.             }
  630.         };
  631.        
  632.         Creature* pLivingConstellation = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(_unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ(), CN_LIVING_CONSTELLATION);
  633.         if( pLivingConstellation != NULL && pLivingConstellation->GetDistance2dSq(static_cast<Object*>(_unit)) <= 3.5f )
  634.         {
  635.             pLivingConstellation->Despawn( 0, 0 );
  636.             Despawn();
  637.         };
  638.  
  639.         if( mPhaseTwo )
  640.             mSummonTimer = AddTimer( TIMER_SUMMON_DARK_MATTER );
  641.        
  642.         if( IsTimerFinished( mSummonTimer ) )
  643.         {
  644.             SpawnCreature( CN_UNLEASEHED_DARK_MATTER );
  645.             ResetTimer( mSummonTimer, TIMER_SUMMON_DARK_MATTER );
  646.         }
  647.  
  648.         if( !mVoidZone )
  649.             ApplyAura( BLACK_HOLE_VISUAL_VOID_ZONE );
  650.     };
  651.  
  652.     void Destroy()
  653.     {
  654.         delete this;
  655.     };
  656.  
  657. private:
  658.     bool        mVoidZone;
  659.     bool        mPhaseTwo;
  660.  
  661.     int32       mSummonTimer;
  662. };
  663.  
  664. class LivingConstellationAI : public MoonScriptBossAI
  665. {
  666.     MOONSCRIPT_FACTORY_FUNCTION(LivingConstellationAI, MoonScriptBossAI);
  667.     LivingConstellationAI(Creature* pCreature) : MoonScriptBossAI(pCreature)
  668.     {
  669.         AddPhaseSpell( 2, AddSpell( ARCANE_BARRAGE, Target_RandomPlayer, 100, 2, 5, 0, 60 ) );
  670.  
  671.         SetFlyMode( true );
  672.         SetCanEnterCombat( false );
  673.         SetAllowMelee( false );
  674.         SetAllowSpell( false );
  675.         SetAllowTargeting( false);
  676.         SetCanMove( false );
  677.     };
  678.  
  679.     void OnLoad()
  680.     {
  681.         Creature* pAlgalon = static_cast<Creature*>(ForceCreatureFind( CN_ALGALON, 1632.250000f, -307.548004f, 416.264008f));
  682.         AlgalonAI* mAlgalon = NULL;
  683.         if ( pAlgalon != NULL && pAlgalon->GetScript() != NULL )
  684.         {
  685.                 mAlgalon = (AlgalonAI*)(pAlgalon->GetScript());
  686.                 mAlgalon->AddEncounterCreature( _unit );
  687.         }
  688.         pAlgalon = NULL;
  689.         mAlgalon = NULL;
  690.  
  691.         SetPhase( 1 );
  692.         mJoinTimer = AddTimer( TIMER_LIVING_CONSTELLATION_JOIN );
  693.         RegisterAIUpdateEvent( 1000 );
  694.     };
  695.  
  696.     void AIUpdate()
  697.     {
  698.         if( GetPhase() == 1 )
  699.         {
  700.             if( IsTimerFinished( mJoinTimer ) )
  701.             {
  702.                 SpawnCreature( CN_LIVING_CONSTELLATION );
  703.                 RemoveTimer( mJoinTimer );
  704.  
  705.                 SetCanEnterCombat( true );
  706.                 SetAllowSpell( true );
  707.                 SetAllowTargeting( true );
  708.                 SetCanMove( true );
  709.                 SetPhase( 2 );
  710.                
  711.                 uint32 mRandom = RandomUInt( 2 );
  712.                 AddWaypoint( CreateWaypoint( 1, 0, Flag_Fly, LivingConstellationWP[mRandom] ) );
  713.                 ForceWaypointMove( 1 );    
  714.             }
  715.         };
  716.  
  717.         ParentClass::AIUpdate();
  718.     };
  719.  
  720.     void OnDied(Unit* pKiller)
  721.     {
  722.         Despawn( 1000, 0 );
  723.     };
  724.  
  725.     void OnReachWP(uint32 iWaypoinyId, bool bForwards)
  726.     {
  727.         if( !IsInCombat() )
  728.             AggroNearestPlayer(1);
  729.     };
  730.  
  731.     void Destroy()
  732.     {
  733.         delete this;
  734.     };
  735.  
  736.     int32       mJoinTimer;
  737. };
  738.  
  739. class BrannBronzebeardAI : public MoonScriptCreatureAI
  740. {
  741.     MOONSCRIPT_FACTORY_FUNCTION(BrannBronzebeardAI, MoonScriptCreatureAI);
  742.     BrannBronzebeardAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature){}
  743.    
  744.     void OnLoad()
  745.     {
  746.         mScene = 0;
  747.         RegisterAIUpdateEvent( 8000 );
  748.     };
  749.  
  750.     void OnReachWP(uint32 iWaypointId, bool bForwards)
  751.     {
  752.         if(iWaypointId == 1)
  753.         {
  754.             Emote( "We did it lads! We got here before Algalon's arrival! Maybe we can rig the systems to interfere with his analysis.", Text_Yell, UR_BRANN_ALGALONSUMMONED01);
  755.             _unit->Emote(EMOTE_ONESHOT_TALK);
  756.             RegisterAIUpdateEvent(8000);
  757.         }
  758.     };
  759.  
  760.     void AIUpdate()
  761.     {
  762.         if(mScene == 0)
  763.         {
  764.             for( int i=0; i < 2; i++ )
  765.             {
  766.                 AddWaypoint(CreateWaypoint( i, 0, Flag_Walk, BronzebeardWaypoint[i]));
  767.             }
  768.             ++mScene;
  769.             ForceWaypointMove(1);
  770.             RemoveAIUpdateEvent();
  771.         }
  772.         else if( mScene == 1)
  773.         {
  774.             Emote( "I'll head back to the Archivum and see if I can jam his signal. I might be able to buy us some time while you take care of him.", Text_Yell, UR_BRANN_ALGALONSUMMONED02);
  775.             _unit->Emote(EMOTE_ONESHOT_TALK);
  776.             RemoveAIUpdateEvent();
  777.             Despawn();
  778.         }
  779.     };
  780.  
  781.     void Destroy()
  782.     {
  783.         delete this;
  784.     };
  785.  
  786. private:
  787.     int32 mScene;
  788. };
  789.  
  790. class UnleashedDarkMatterAI : public MoonScriptCreatureAI
  791. {
  792.     MOONSCRIPT_FACTORY_FUNCTION(UnleashedDarkMatterAI, MoonScriptCreatureAI);
  793.     UnleashedDarkMatterAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature){}
  794.  
  795.     void OnLoad()
  796.     {
  797.         Creature* pAlgalon = static_cast<Creature*>(ForceCreatureFind( CN_ALGALON, 1632.250000f, -307.548004f, 416.264008f));
  798.         AlgalonAI* mAlgalon = NULL;
  799.         if ( pAlgalon != NULL && pAlgalon->GetScript() != NULL )
  800.         {
  801.                 mAlgalon = (AlgalonAI*)(pAlgalon->GetScript());
  802.                 mAlgalon->AddEncounterCreature( _unit );
  803.         }
  804.         pAlgalon = NULL;
  805.         mAlgalon = NULL;
  806.     };
  807. };
  808.  
  809. class PhasePunchAI  : public SpellScript
  810. {
  811. public:
  812.     ADD_SPELL_FACTORY_FUNCTION(PhasePunchAI);
  813.     PhasePunchAI(Spell* spellinstance) : SpellScript(spellinstance) {};
  814.  
  815.     void OnCast()
  816.     {
  817.         if( _spell->GetUnitTarget() && _spell->GetUnitTarget()->IsPlayer())
  818.         {
  819.             Player* pVictim = static_cast<Player*>(_spell->GetUnitTarget());
  820.             if ( pVictim->GetAuraStackCount( ALGALON_PHASE_PUNCH ) == 5 )
  821.             {
  822.                     pVictim->RemoveAllAuraById( ALGALON_PHASE_PUNCH );
  823.                     Aura* pAura = new Aura( dbcSpell.LookupEntryForced(BLACK_HOLE_PHASE_AURA), 10000, pVictim, pVictim, true);
  824.                     if( pAura != NULL )
  825.                         pVictim->AddAura(pAura, NULL);
  826.             };
  827.         }
  828.     };
  829. };
  830.  
  831. void SetupAlgalon(ScriptMgr * mgr)
  832. {
  833.     mgr->register_creature_script( CN_ALGALON, &AlgalonAI::Create);
  834.     mgr->register_creature_script( CN_AZEROTH, &AzerothAI::Create);
  835.     mgr->register_creature_script( CN_COLLAPSING_STAR, &CollapsingStarAI::Create);
  836.     mgr->register_creature_script( CN_BLACK_HOLE, &BlackHoleAI::Create);
  837.     mgr->register_creature_script( CN_BRANN, &BrannBronzebeardAI::Create);
  838.     mgr->register_creature_script( CN_LIVING_CONSTELLATION, &LivingConstellationAI::Create);
  839.     mgr->register_creature_script( CN_UNLEASEHED_DARK_MATTER, &UnleashedDarkMatterAI::Create );
  840.  
  841.     mgr->register_gameobject_script( Doodad_UL_SigilDoor_01, &AlgalonDoorGO::Create);
  842.  
  843.     //mgr->register_spell_script( ALGALON_PHASE_PUNCH, &PhasePunchAI::Create);
  844. };
Advertisement
Add Comment
Please, Sign In to add comment