root/Trunk/src/InstanceScripts/Instance_Nexus.cpp @ 1151

Revision 1151, 23.2 kB (checked in by azolex, 7 months ago)

* MODIFIED: 3.3.2 Anomalus( Nexus ) change, charge rift only once

Line 
1/*
2 * ArcScripts for ArcEmu MMORPG Server
3 * Copyright (C) 2009 ArcEmu Team <http://www.arcemu.org/>
4 * Copyright (C) 2008-2009 Sun++ Team <http://www.sunscripting.com/>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20/* Instance: Nexus
21 * Dev Comment: Last boss needs to be finished
22 */
23
24#include "StdAfx.h"
25#include "Setup.h"
26#include "../Common/Base.h"
27#include "../Common/Instance_Base.h"
28
29#define ANOMALUS_CS             188527
30#define TELESTRA_CS             188526
31#define ORMOROK_CS              188528                 
32#define CN_KERISTRASZA  26723
33#define CN_ANOMALUS             26763
34#define CN_TELESTRA     26731
35#define CN_ORMOROK              26794
36
37#define GO_FLAG_UNCLICKABLE 0x00000010
38
39enum NexusEncounterList
40{
41    NEXUS_ANOMALUS      = 0,
42    NEXUS_TELESTRA      = 1,
43    NEXUS_ORMOROK       = 2,
44    NEXUS_KERISTRASZA   = 3,
45
46    NEXUS_END           = 4
47};
48
49////////////////////////////////////////////////////////////////////////////////////////////
50///////////////////////////////// Anomalus ////////////////////////////////////////////////
51//////////////////////////////////////////////////////////////////////////////////////////
52#define CN_CHAOTIC_RIFT                 26918
53#define CN_CRAZED_MANA_WRAITH   26746
54
55#define SPARK                                   47751
56#define SPARK_HC                                57062
57#define CHAOTIC_ENERGY_BURST    47688
58#define CHAOTIC_RIFT_AURA               47687
59#define SUMMON_MANA_WRAITH              47692
60
61class AnomalusAI : public MoonScriptBossAI
62{
63public:
64        MOONSCRIPT_FACTORY_FUNCTION(AnomalusAI, MoonScriptBossAI);
65        AnomalusAI(Creature* pCreature) : MoonScriptBossAI(pCreature)
66    {
67        mInstance = GetInstanceScript(); 
68
69                if( IsHeroic() )
70                        AddSpell(SPARK_HC, Target_RandomPlayer, 80, 0, 3);
71                else
72                        AddSpell(SPARK, Target_RandomPlayer, 80, 0, 3);
73
74                AddEmote( Event_OnDied, "Of course.", Text_Yell, 13187 );
75        AddEmote( Event_OnCombatStart, "Chaos beckons.", Text_Yell, 13186);
76
77        mSummon = 0;
78    };
79   
80    void OnCombatStart(Unit* mTarget)
81    {
82                mSummon = 0;
83                mRift = false;
84        mSummonTimer = AddTimer( IsHeroic() ? 14000 : 18000 ); // check heroic
85
86                ParentClass::OnCombatStart(mTarget);
87       
88        if( mInstance )
89            mInstance->SetInstanceData( Data_EncounterState, NEXUS_ANOMALUS, State_InProgress );
90    };
91
92    void AIUpdate()
93    {
94                if((GetHealthPercent() <= 50 && mSummon == 0))
95                        mSummon += 1;
96               
97                if(mSummon == 1) 
98                        ChargeRift();
99
100        if( IsTimerFinished( mSummonTimer ) && mRift == false )
101        {
102            SummonRift( false );
103            ResetTimer( mSummonTimer, IsHeroic() ? 14000 : 18000 );
104        };
105
106                if( mRift == true && ( pChaoticRift == NULL || !pChaoticRift->isAlive() ))
107                {
108                        RemoveAura(47748);
109                        mRift = false;
110                };
111
112                ParentClass::AIUpdate();
113    };
114
115    void SummonRift( bool bToCharge )
116    {
117        if( !bToCharge )
118            Emote("Reality... unwoven.", Text_Yell, 13188);
119
120        Announce( "Anomalus opens a Chaotic Rift!" );
121        SpawnCreature( CN_CHAOTIC_RIFT, _unit->GetPositionX() + 13.5f, _unit->GetPositionY(), _unit->GetPositionZ(), _unit->GetOrientation(), false );
122    };
123
124        void ChargeRift()
125        {
126        SummonRift( true );
127
128        Announce( "Anomalus shields himself and diverts his power to the rifts!" );
129        Emote( "Indestructible.", Text_Yell, 13189 );
130        ApplyAura( 47748 ); // me immune
131                SetCanMove( false );
132
133                mRift = true;
134                mSummon += 1;
135        };
136
137        void OnDied(Unit* pKiller)
138        {
139                if( mInstance )
140            mInstance->SetInstanceData( Data_EncounterState, NEXUS_ANOMALUS, State_Finished);
141       
142                ParentClass::OnDied(pKiller);
143        };
144
145    void OnCombatStop(Unit* pTarget)
146    {
147        if( mInstance )
148            mInstance->SetInstanceData( Data_EncounterState, NEXUS_ANOMALUS, State_Performed );
149
150        ParentClass::OnCombatStop(pTarget);
151    };
152
153        void Destroy()
154    {
155                delete this;
156    };
157
158private:
159    int32           mSummonTimer;
160        uint8               mSummon;
161        bool                    mRift;
162        Creature*       pChaoticRift;
163    MoonInstanceScript* mInstance;
164};
165
166class ChaoticRiftAI : public MoonScriptBossAI
167{
168public:
169        MOONSCRIPT_FACTORY_FUNCTION(ChaoticRiftAI, MoonScriptBossAI);
170        ChaoticRiftAI(Creature* pCreature) : MoonScriptBossAI(pCreature)
171        {
172        _unit->GetAIInterface()->SetAllowedToEnterCombat( false );
173                AddSpell( SUMMON_MANA_WRAITH, Target_Self, 30, 0, dbcSpell.LookupEntryForced(SUMMON_MANA_WRAITH)->RecoveryTime );
174                AddSpell( CHAOTIC_ENERGY_BURST, Target_RandomPlayer, 30, 0, dbcSpell.LookupEntryForced(CHAOTIC_ENERGY_BURST)->RecoveryTime );
175        };
176
177        void OnLoad()
178        {
179                ApplyAura( CHAOTIC_RIFT_AURA );
180                Despawn( 40000, 0 );
181                ParentClass::OnLoad();
182        };
183
184    void OnDied(Unit*  mKiller)
185    {
186                Despawn( 2000, 0 );
187                ParentClass::OnDied(mKiller);
188    };
189
190        void OnCombatStop(Unit* pTarget)
191        {
192                Despawn( 2000, 0 );
193                ParentClass::OnCombatStop(pTarget);
194        };
195
196        void Destroy()
197    {
198                delete this;
199    };
200};
201
202class CraziedManaWrathAI : public MoonScriptBossAI
203{
204public:
205        MOONSCRIPT_FACTORY_FUNCTION(CraziedManaWrathAI, MoonScriptBossAI);
206        CraziedManaWrathAI(Creature* pCreature) : MoonScriptBossAI(pCreature){};
207
208        void OnCombatStop(Unit* pTarget)
209        {
210                Despawn();
211                ParentClass::OnCombatStop(pTarget);
212        };
213
214        void OnDied(Unit*  mKiller)
215    {
216                Despawn();
217                ParentClass::OnDied(mKiller);
218        };
219
220        void Destroy()
221    {
222                delete this;
223    };
224};
225
226
227////////////////////////////////////////////////////////////////////////////////////////////
228/////////////////////////////// Grand Magus Telestra //////////////////////////////////////
229//////////////////////////////////////////////////////////////////////////////////////////
230
231struct Spawns
232{
233        float x;
234        float y;
235        float z;
236        float o;
237};
238
239static Spawns FormSpawns[] =     
240{ 
241    { 494.726990f, 89.128799f, -15.941300f, 6.021390f }, 
242    { 495.006012f, 89.328102f, -16.124609f, 0.027486f }, 
243    { 504.798431f, 102.248375f, -16.124609f, 4.629921f } 
244}; 
245
246#define CN_TELESTRA_FROST 26930
247#define CN_TELESTRA_FIRE 26928
248#define CN_TELESTRA_ARCANE 26929
249
250#define GRAVITY_WELL 47756
251
252// Normal mode spells
253#define ICE_NOVA 47772
254#define FIREBOMB 47773
255
256// Heroic mode spells
257#define ICE_NOVA_HC 56935
258#define FIREBOMB_HC 56934
259
260// Arcane spells
261#define CRITTER 47731
262#define TIME_STOP 47736
263
264// Fire
265#define FIRE_BLAST 47721
266#define FIRE_BLAST_HC 56939
267#define SCORCH 47723
268#define SCORCH_HC 56938
269
270// Frost
271#define BLIZZARD 47727
272#define BLIZZARD_HC 56936
273#define ICE_BARB 47729
274#define ICE_BARB_HC 56937
275
276class TelestraBossAI : public MoonScriptBossAI
277{
278public:
279        MOONSCRIPT_FACTORY_FUNCTION(TelestraBossAI, MoonScriptBossAI);
280        TelestraBossAI(Creature* pCreature) : MoonScriptBossAI(pCreature)
281        {
282        mInstance = GetInstanceScript();
283
284        mHeroic = IsHeroic();
285                if( mHeroic )
286                {
287                        AddSpell(ICE_NOVA_HC, Target_Self, 25, 2.0, 15);
288                        AddSpell(FIREBOMB_HC, Target_RandomPlayer, 35, 1.5, 5);
289                        AddSpell(GRAVITY_WELL, Target_Self, 15, 0.5, 20);
290                }
291                else
292                {
293                        AddSpell(ICE_NOVA, Target_Self, 25, 2.0, 15);
294                        AddSpell(FIREBOMB, Target_RandomPlayer, 35, 1.5, 5);
295                        AddSpell(GRAVITY_WELL, Target_Self, 15, 0.5, 20);
296                };
297
298                SetAIUpdateFreq(1000);
299       
300        mAddCount = 0;
301        mPhaseRepeat = 2;
302
303                AddEmote(Event_OnCombatStart, "You know what they say about curiosity. ", Text_Yell, 13319);
304                AddEmote(Event_OnDied, "Damn the... luck.", Text_Yell, 13320);
305                AddEmote(Event_OnTargetDied, "Death becomes you!", Text_Yell, 13324);
306        };
307
308        void AIUpdate()
309        {
310                if( GetPhase() == 1 && GetHealthPercent() <= ( mPhaseRepeat * 25 ) )
311                {
312                        switch ( rand()%2 )     
313                        {
314                                case 0:
315                                        Emote( "I'll give you more than you can handle.", Text_Yell, 13321 );
316                                        break;
317                                case 1:
318                                        Emote( "There's plenty of me to go around.", Text_Yell, 13322 );
319                                        break;
320                        }
321                        SetPhase(2);
322                        SetCanMove(false);
323                SetAllowRanged(false);
324                SetAllowSpell(false);
325            SetAllowTargeting(false);
326                        ApplyAura(60191);
327
328            for( int i = 0; i < 3; ++i )
329            {
330                mAddArray[i] = _unit->GetMapMgr()->GetInterface()->SpawnCreature( CN_TELESTRA_FIRE + i, FormSpawns[i].x, FormSpawns[i].y, FormSpawns[i].z, FormSpawns[i].o, true, true, NULL, NULL );
331                if( mAddArray[i] != NULL )
332                    ++mAddCount;
333            }
334
335                };
336
337                if( GetPhase() == 2 )
338                {
339                        for( int i = 0; i < 3; ++i )
340            {
341                if( mAddArray[i] != NULL )
342                {
343                    mAddArray[i]->Despawn( 1000, 0 );
344                    mAddArray[i] = NULL;
345                    --mAddCount;
346                }
347            }
348
349            if( mAddCount != 0 )
350                return;
351
352                        Emote("Now to finish the job!", Text_Yell, 13323);
353                        RemoveAura(60191);
354                        SetCanMove(true);
355            mPhaseRepeat = 1;
356            SetPhase( mHeroic  ? 1 : 3 ); //3 disables p2
357                };
358
359                ParentClass::AIUpdate();
360        };
361
362    void OnCombatStart(Unit* pTarget)
363    {
364        if( mInstance )
365            mInstance->SetInstanceData( Data_EncounterState, NEXUS_TELESTRA, State_InProgress );
366
367        ParentClass::OnCombatStart(pTarget);
368    };
369
370    void OnCombatStop(Unit* pTarget)
371    {
372        for( int i = 0; i < 3; ++i )
373        {
374            if( mAddArray[i] != NULL )
375            {
376                mAddArray[i]->Despawn( 1000, 0 );
377                mAddArray[i] = NULL;
378            }
379        }
380
381        ParentClass::OnCombatStop(pTarget);
382
383        if( mInstance )
384            mInstance->SetInstanceData( Data_EncounterState, NEXUS_TELESTRA, State_Performed );
385    };
386
387        void OnDied(Unit* pKiller)
388        {
389        for( int i = 0; i < 3; ++i )
390        {
391            if( mAddArray[i] != NULL )
392            {
393                mAddArray[i]->Despawn( 1000, 0 );
394                mAddArray[i] = NULL;
395            }
396        }
397
398                if( mInstance )
399            mInstance->SetInstanceData( Data_EncounterState, NEXUS_TELESTRA, State_Finished );
400
401                ParentClass::OnDied(pKiller);
402        };
403
404        void Destroy()
405    {
406                delete this;
407    };
408
409private:
410    Creature*   mAddArray[3];
411    bool        mHeroic;
412    int32       mPhaseRepeat;
413    int32       mAddCount;
414    MoonInstanceScript* mInstance;
415};
416
417class TelestraFireAI : public MoonScriptBossAI
418{
419public:
420        MOONSCRIPT_FACTORY_FUNCTION(TelestraFireAI, MoonScriptBossAI);
421        TelestraFireAI(Creature* pCreature) : MoonScriptBossAI(pCreature)
422        {
423                if( IsHeroic() )
424                {
425                        AddSpell(FIRE_BLAST_HC, Target_RandomPlayer, 30, 0, 14);
426                        AddSpell(SCORCH_HC, Target_Current, 100, 1, 3);
427                }
428                else
429                {
430                        AddSpell(FIRE_BLAST, Target_RandomPlayer, 30, 0, 14);
431                        AddSpell(SCORCH, Target_Current, 100, 1, 3);
432                };
433        };
434
435        void OnLoad()
436        {
437                AggroNearestUnit();
438                ParentClass::OnLoad();
439        };
440
441        void Destroy()
442    {
443                delete this;
444    };
445};
446
447class TelestraFrostAI : public MoonScriptBossAI
448{
449public:
450        MOONSCRIPT_FACTORY_FUNCTION(TelestraFrostAI, MoonScriptBossAI);
451        TelestraFrostAI(Creature* pCreature) : MoonScriptBossAI(pCreature)
452        {
453                if( IsHeroic() )
454                {
455                        AddSpell(BLIZZARD_HC, Target_RandomPlayerDestination, 20, 0, 20);
456                        AddSpell(ICE_BARB_HC, Target_RandomPlayer, 25, 0.5, 6);
457                }
458                else
459                {
460                        AddSpell(BLIZZARD, Target_RandomPlayerDestination, 20, 0, 20);
461                        AddSpell(ICE_BARB, Target_RandomPlayer, 25, 0.5, 6);
462                };
463        };
464
465        void OnLoad()
466        {
467                AggroNearestUnit();
468                ParentClass::OnLoad();
469        };
470
471        void Destroy()
472    {
473                delete this;
474    };
475};
476
477class TelestraArcaneAI : public MoonScriptBossAI
478{
479public:
480        MOONSCRIPT_FACTORY_FUNCTION(TelestraArcaneAI, MoonScriptBossAI);
481        TelestraArcaneAI(Creature* pCreature) : MoonScriptBossAI(pCreature)
482        {
483                AddSpell(TIME_STOP, Target_Self, 30, 1.5, 30);
484                AddSpell(CRITTER, Target_RandomPlayer, 25, 0, 20);
485        };
486
487        void OnLoad()
488        {
489                AggroNearestUnit();
490                ParentClass::OnLoad();
491        };
492
493        void Destroy()
494    {
495                delete this;
496    };
497};
498
499////////////////////////////////////////////////////////////////////////////////////////////
500/////////////////////////////// Ormorok the Tree-Shaper ///////////////////////////////////
501//////////////////////////////////////////////////////////////////////////////////////////
502
503// creatures
504#define CN_CRYSTAL_SPIKE                        27099
505
506// spells
507#define SPELL_REFLECTION                        47981
508#define FRENZY                                          48017
509
510// normal mode spells
511#define TRAMPLE                                         48016
512#define CRYSTAL_SPIKES                          47958
513
514// heroic mode spells
515#define TRAMPLE_H                                       57066
516#define CRYSTAL_SPIKES_H                        57082
517
518// Crystal Spike spells
519#define SPELL_CRYSTAL_SPIKE_VISUAL      50442
520#define SPELL_CRYSTAL_SPIKE                     47944
521#define SPELL_CRYSTAL_SPIKE_H           57067
522
523bool CrystalSpikes(uint32 i, Spell *pSpell)
524{
525        if (pSpell == NULL || pSpell->u_caster == NULL)
526                return true;
527
528        Unit* pCaster = pSpell->u_caster;
529
530        for( int i = 1; i < 6; ++i )
531        {
532                pCaster->GetMapMgr()->GetInterface()->SpawnCreature( CN_CRYSTAL_SPIKE, pCaster->GetPositionX() + ( 3 * i ) + rand()%3 , pCaster->GetPositionY() + ( 3 * i ) + rand()%3 , pCaster->GetPositionZ(), pCaster->GetOrientation(), true, false, NULL, NULL );
533        };
534       
535        for( int i = 1; i < 6; ++i )
536        {
537                pCaster->GetMapMgr()->GetInterface()->SpawnCreature( CN_CRYSTAL_SPIKE, pCaster->GetPositionX() - ( 3 * i ) - rand()%3 , pCaster->GetPositionY() + ( 3 * i ) + rand()%3 , pCaster->GetPositionZ(), pCaster->GetOrientation(), true, false, NULL, NULL );
538        };
539       
540        for( int i = 1; i < 6; ++i )
541        {
542                pCaster->GetMapMgr()->GetInterface()->SpawnCreature( CN_CRYSTAL_SPIKE, pCaster->GetPositionX() + ( 3 * i ) + rand()%3 , pCaster->GetPositionY() - ( 3 * i ) - rand()%3 , pCaster->GetPositionZ(), pCaster->GetOrientation(), true, false, NULL, NULL );
543        };
544       
545        for( int i = 1; i < 6; ++i )
546        {
547                pCaster->GetMapMgr()->GetInterface()->SpawnCreature( CN_CRYSTAL_SPIKE, pCaster->GetPositionX() - ( 3 * i ) - rand()%3 , pCaster->GetPositionY() - ( 3 * i ) - rand()%3 , pCaster->GetPositionZ(), pCaster->GetOrientation(), true, false, NULL, NULL );
548        };
549
550        return true;
551}
552
553class OrmorokAI : public MoonScriptBossAI
554{
555    MOONSCRIPT_FACTORY_FUNCTION(OrmorokAI, MoonScriptBossAI);
556        OrmorokAI(Creature* pCreature) : MoonScriptBossAI(pCreature)
557        {
558        mInstance = GetInstanceScript();
559
560                if ( IsHeroic() )
561                        AddSpell(TRAMPLE_H, Target_Current, 30, 0, 9 );
562                else
563                        AddSpell(TRAMPLE, Target_Current, 30, 0, 9 );
564
565                AddSpell( SPELL_REFLECTION, Target_Self, 35, 2.0f, 15 );
566                mCrystalSpikes = AddSpell( CRYSTAL_SPIKES, Target_Self, 25, 0, 12 );
567                mCrystalSpikes->AddEmote( "Bleed!", Text_Yell, 13332 );
568
569                AddEmote( Event_OnCombatStart, "Noo!", Text_Yell, 13328 );
570                AddEmote( Event_OnDied, "Aaggh!", Text_Yell, 13330 );
571
572                mEnraged = false;
573        };
574
575        void OnCombatStart(Unit* pTarget)
576        {
577                mEnraged = false;
578                ParentClass::OnCombatStart(pTarget);
579        };
580
581        void AIUpdate()
582        {
583                if( GetHealthPercent() <= 25 && mEnraged == false )
584                {
585                        ApplyAura( FRENZY );
586                        Announce( "Ormorok the Tree-Shaper goes into a frenzy!" );
587                        mEnraged = true;
588                };
589
590                ParentClass::AIUpdate();
591        };
592
593        void OnDied(Unit* pKiller)
594        {
595                if( mInstance )
596            mInstance->SetInstanceData( Data_EncounterState, NEXUS_ORMOROK, State_Finished );
597
598                ParentClass::OnDied(pKiller);
599        };
600
601        void Destroy()
602        {
603                delete this;
604        };
605
606private:
607        SpellDesc*      mCrystalSpikes;
608        bool            mEnraged;
609    MoonInstanceScript* mInstance;
610};
611
612class CrystalSpikeAI : public MoonScriptBossAI
613{
614    MOONSCRIPT_FACTORY_FUNCTION(CrystalSpikeAI, MoonScriptBossAI);
615        CrystalSpikeAI(Creature* pCreature) : MoonScriptBossAI(pCreature){};
616
617        void OnLoad()
618        {
619                SetCanEnterCombat( false );
620                SetCanMove( false );
621                _unit->SetUInt64Value( UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE );
622
623                Despawn( 4500, 0 );
624                RegisterAIUpdateEvent( 500 );
625                m_part = 0;
626
627                ParentClass::OnLoad();
628        };
629
630        void AIUpdate()
631        {
632                m_part += 1;
633
634                if( m_part == 1 )
635                {
636                        _unit->CastSpell( _unit, SPELL_CRYSTAL_SPIKE_VISUAL, true );
637                }
638                else if( m_part == 5 )
639                {
640                        if ( IsHeroic() )
641                        {
642                                _unit->CastSpell( _unit, dbcSpell.LookupEntry(SPELL_CRYSTAL_SPIKE_H), true );
643                        }
644                        else
645                        {
646                                _unit->CastSpell( _unit, dbcSpell.LookupEntry(SPELL_CRYSTAL_SPIKE), true );
647                        };
648                };
649        };
650
651        void Destroy()
652        {
653                delete this;
654        };
655
656private:
657        int             m_part;
658};
659
660////////////////////////////////////////////////////////////////////////////////////////////
661//////////////////////////////////// Keristrasza //////////////////////////////////////////
662//////////////////////////////////////////////////////////////////////////////////////////
663// unfinished
664#define TAIL_SWEEP                                      50155
665#define INTENSE_COLD                            48094
666#define CRYSTAL_CHAINS                          50997
667#define CRYSTALLIZE                                     48179
668#define ENRAGE                                          8599
669
670// normal mode
671#define CRYSTALFIRE_BREATH                      48096
672//heroic
673#define CRYSTALFIRE_BREATH_HC           57091
674
675class KeristraszaAI : public MoonScriptBossAI
676{
677    MOONSCRIPT_FACTORY_FUNCTION(KeristraszaAI, MoonScriptBossAI);
678        KeristraszaAI(Creature* pCreature) : MoonScriptBossAI(pCreature)
679        {
680                if ( IsHeroic() )
681                        AddSpell( CRYSTALFIRE_BREATH_HC, Target_Self, 30, 1, 14 );
682                else
683                        AddSpell( CRYSTALFIRE_BREATH, Target_Self, 30, 1, 14 );
684
685                AddSpell( CRYSTAL_CHAINS, Target_RandomPlayer, 30, 0, 12);
686                AddSpell( TAIL_SWEEP, Target_Self, 40, 0, 8 );
687
688                mCrystalize = AddSpell( CRYSTALLIZE, Target_Self, 25, 0, 22 );
689                mCrystalize->AddEmote( "Stay. Enjoy your final moments.", Text_Yell, 13451 );
690
691                AddEmote(Event_OnCombatStart, "Preserve? Why? There's no truth in it. No no no... only in the taking! I see that now!", Text_Yell, 13450);
692                AddEmote(Event_OnTargetDied, "Now we've come to the truth!", Text_Yell, 13453);
693                AddEmote(Event_OnDied, "Dragonqueen... Life-Binder... preserve... me.", Text_Yell, 13454);
694
695                mEnraged = false;
696                SetCanEnterCombat(false);
697        };
698
699        void OnLoad()
700        {
701                ApplyAura( 47543 ); // frozen prison
702                ParentClass::OnLoad();
703        };
704
705        void AIUpdate()
706        {
707                if( mEnraged == false && GetHealthPercent() <= 25 )
708                {
709                        ApplyAura( ENRAGE );
710                        mEnraged = true;
711                };
712        };
713
714        void Release()
715        {
716            SetCanEnterCombat( true );
717            RemoveAura( 47543 );
718            ApplyAura( INTENSE_COLD );
719        };
720
721private:
722        bool            mEnraged;
723        SpellDesc*      mCrystalize;
724};
725
726// Nexus Instance script
727#define MAP_NEXUS 576
728
729class NexusScript : public MoonInstanceScript
730{
731public:
732    uint32 mAnomalusGUID;
733    uint32 mTelestraGUID;
734    uint32 mOrmorokGUID;
735    uint32 mKeristraszaGUID;
736
737    uint8 mCSCount;
738
739    uint32 m_uiEncounters[NEXUS_END];
740
741    MOONSCRIPT_INSTANCE_FACTORY_FUNCTION( NexusScript, MoonInstanceScript );
742        NexusScript( MapMgr* pMapMgr ) : MoonInstanceScript( pMapMgr )
743        {
744        mAnomalusGUID = 0;
745        mTelestraGUID = 0;
746        mOrmorokGUID = 0;
747        mKeristraszaGUID = 0;
748
749        mCSCount = 0;
750
751        for( uint32 i = 0; i < NEXUS_END; ++i )
752             m_uiEncounters[i] = State_NotStarted;
753    };
754
755    void SetInstanceData( uint32 pType, uint32 pIndex, uint32 pData )
756        {
757                if( pType != Data_EncounterState )
758                        return;
759       
760                if( pIndex >= NEXUS_END )
761            return;
762
763        m_uiEncounters[pIndex] = pData;
764
765        if( pData == State_Finished )
766        {
767            GameObject* pSphere = NULL;
768
769            switch( pIndex )
770            {
771            case NEXUS_ANOMALUS:
772                pSphere = GetGameObjectBySqlId( ANOMALUS_CS );
773                break;
774            case NEXUS_TELESTRA:
775                pSphere = GetGameObjectBySqlId( TELESTRA_CS );
776                break;
777            case NEXUS_ORMOROK:
778                pSphere = GetGameObjectBySqlId( ORMOROK_CS );
779                break;
780            default: 
781                return;
782            };
783
784            if( pSphere != NULL )
785                pSphere->RemoveFlag( GAMEOBJECT_FLAGS, GO_FLAG_UNCLICKABLE);
786        };
787    };
788
789    uint32 GetInstanceData( uint32 pType, uint32 pIndex )
790        {
791            return m_uiEncounters[pIndex];
792        };
793
794    void OnCreaturePushToWorld( Creature* pCreature )
795        {
796                switch( pCreature->GetEntry() )
797                {
798        case CN_KERISTRASZA: 
799            mKeristraszaGUID = pCreature->GetLowGUID();
800            break;
801        case CN_ANOMALUS:
802            mAnomalusGUID = pCreature->GetLowGUID();
803            break;
804        case CN_TELESTRA:
805            mTelestraGUID = pCreature->GetLowGUID();
806            break;
807        case CN_ORMOROK:
808            mOrmorokGUID = pCreature->GetLowGUID();
809            break;
810        }
811    };
812
813    void OnGameObjectPushToWorld( GameObject* pGameObject )
814        {
815                switch( pGameObject->GetEntry() )
816                {
817                case ANOMALUS_CS: 
818                    pGameObject->SetFlag( GAMEOBJECT_FLAGS,GO_FLAG_UNCLICKABLE ); 
819            break;
820        case TELESTRA_CS: 
821                pGameObject->SetFlag( GAMEOBJECT_FLAGS,GO_FLAG_UNCLICKABLE ); 
822            break;
823        case ORMOROK_CS: 
824                    pGameObject->SetFlag( GAMEOBJECT_FLAGS,GO_FLAG_UNCLICKABLE ); 
825            break;
826        };
827    };
828
829    void OnGameObjectActivate( GameObject* pGameObject, Player* pPlayer )
830        {
831                switch( pGameObject->GetEntry() )
832                {
833        case ANOMALUS_CS: 
834                    pGameObject->SetFlag( GAMEOBJECT_FLAGS, GO_FLAG_UNCLICKABLE );
835            ++mCSCount;
836            break;
837        case TELESTRA_CS: 
838                pGameObject->SetFlag( GAMEOBJECT_FLAGS, GO_FLAG_UNCLICKABLE ); 
839            ++mCSCount;
840            break;
841        case ORMOROK_CS:
842            pGameObject->SetFlag( GAMEOBJECT_FLAGS, GO_FLAG_UNCLICKABLE );
843            ++mCSCount;
844            break;
845        default:
846            return;
847        }
848
849        if( mCSCount == 3 ) // release last boss
850        {
851            Creature* pKeristrasza = GetCreatureByGuid( mKeristraszaGUID );
852            if( pKeristrasza == NULL )
853                return;
854
855            KeristraszaAI* pKeristraszaAI = static_cast< KeristraszaAI* >( pKeristrasza->GetScript() );
856            if( pKeristraszaAI == NULL )
857                return;
858
859            pKeristraszaAI->Release();
860        };
861    };
862};
863
864void SetupNexus(ScriptMgr * mgr)
865{
866        // Anomalus Encounter
867    mgr->register_creature_script(CN_ANOMALUS, &AnomalusAI::Create);
868        mgr->register_creature_script(CN_CHAOTIC_RIFT, &ChaoticRiftAI::Create);
869        mgr->register_creature_script(CN_CRAZED_MANA_WRAITH, &CraziedManaWrathAI::Create);
870
871        // Grand Magus Telestra Encounter
872        mgr->register_creature_script(CN_TELESTRA, &TelestraBossAI::Create);
873        mgr->register_creature_script(CN_TELESTRA_ARCANE, &TelestraArcaneAI::Create);
874        mgr->register_creature_script(CN_TELESTRA_FROST, &TelestraFrostAI::Create);
875        mgr->register_creature_script(CN_TELESTRA_FIRE, &TelestraFireAI::Create);
876
877        // Ormorok the Tree-Shaper Encounter
878        mgr->register_creature_script(CN_ORMOROK, &OrmorokAI::Create); 
879        mgr->register_creature_script(CN_CRYSTAL_SPIKE, &CrystalSpikeAI::Create);
880        mgr->register_dummy_spell(CRYSTAL_SPIKES, &CrystalSpikes);
881        mgr->register_dummy_spell(CRYSTAL_SPIKES_H, &CrystalSpikes);
882
883        // Keristrasza Encounter
884        mgr->register_creature_script(CN_KERISTRASZA, &KeristraszaAI::Create); 
885
886    mgr->register_instance_script( MAP_NEXUS, &NexusScript::Create );
887}
Note: See TracBrowser for help on using the browser.