Advertisement
Guest User

full script pandaria start

a guest
Apr 8th, 2020
626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 186.77 KB | None | 0 0
  1. #include "ScriptedEscortAI.h"
  2. #include "CreatureTextMgr.h"
  3. #include "MapManager.h"
  4. #include "ScriptMgr.h"
  5. #include "Packets/WorldStatePackets.h"
  6. #include <AI\ScriptedAI\ScriptedGossip.h>
  7.  
  8. enum panda_npc
  9. {
  10.     NPC_ANNOUNCER_1                                = 60183,
  11.     NPC_ANNOUNCER_2                                = 60244,
  12.     NPC_ANNOUNCER_3                                = 54943,
  13.     NPC_ANNOUNCER_4                                = 54568,
  14.     NPC_ANNOUNCER_5_TRAVEL                         = 57712,
  15.     NPC_ANNOUNCER_6                                = 55694,
  16.     NPC_ANNOUNCER_7                                = 55672,
  17.     NPC_ANNOUNCER_8                                = 60889,
  18.     NPC_AMBERLEAF_SCAMP                            = 54130, //Amberleaf Scamp
  19.     NPC_MIN_DIMWIND_OUTRO                          = 56503, //Min Dimwind
  20.     NPC_MASTER_LI_FAI                              = 54856,
  21.     NPC_EAST_CHILDREN_CAI                          = 60250,
  22.     NPC_EAST_CHILDREN_DEN                          = 60249,
  23.     NPC_AYSA_WATTER_OUTRO_EVENT                    = 54975,
  24.     NPC_XO_TREVELER                                = 54958,
  25. };
  26.  
  27. enum panda_quests
  28. {
  29.     QUEST_THE_DISCIPLE_CHALLENGE                   = 29409, //29409 The Disciple's Challenge
  30.     QUEST_MISSING_DRIVER                           = 29419,
  31.     QUEST_AYSA_OF_TUSHUI                           = 29410, // Aysa of the Tushui
  32.     QUEST_PARCHEMIN_VOLANT                         = 29421,
  33.     QUEST_PASSION_OF_SHEN                          = 29423, //The Passion of Shen-zin Su
  34.     QUEST_NEW_FRIEND                               = 29679,
  35.     QUEST_SINGING_POOLS                            = 29521, // The Singing Pools
  36.     QUEST_SOURCE_OF_OUR_LIVELIHOOD                 = 29680, // The Source of Our Livelihood
  37.     QUEST_NOT_IN_FACE                              = 29774,
  38.     QUEST_SPIRIT_AND_BODY                          = 29775, //The Spirit and Body of Shen-zin Su
  39.     QUEST_MORNING_BREEZE_BILLAGE                   = 29776, // Morning Breeze Village
  40.     QUEST_BALANCED_PERSPECTIVE                     = 29784, // Balanced Perspective
  41.     QUST_DAFENG_SPIRIT_OF_AIR                      = 29785, // Dafeng, the Spirit of Air
  42.     QIEST_BATTLE_FOR_SKIES                         = 29786, // Battle for the Skies
  43.     QUEST_PASSING_WISDOM                           = 29790,
  44.     QUEST_SUF_SHUN_ZI                              = 29791,
  45.     QUEST_BIDDEN_TO_GREATNESS                      = 29792, // Bidden to Greatness
  46.     QUEST_NONE_LEFT_BEHINED                        = 29794, //None Left Behind
  47.     QUEST_ACIENT_EVIL                              = 29798,
  48.     QUEST_RISKING_IT_ALL                           = 30767, //Risking It All
  49.     QUEST_HEALING_SHEN                             = 29799,
  50.     QUSRT_NEW_FATE                                 = 31450, //A New Fate
  51. };
  52.  
  53. enum spell_panda
  54. {
  55.     SPELL_SUMMON_CHILDREN                          = 116190,
  56.     SPELL_CSA_AT_TIMER                             = 116219, //CSA Area Trigger Dummy Timer Aura A
  57.     SPELL_SUMMON_SPIRIT_OF_WATTER                  = 103538,
  58.     SPELL_CREDIT_NOT_IN_FACE                       = 104017, // Quest credit Not In the Face!
  59.     SPELL_SUMMON_WIND_TELEPORTER                   = 104396,
  60.     SUMMON_MANDORI_DOOR                            = 115426, // Summon Mandori Door
  61.     SUMMON_PEI_WU_DOOR                             = 115435, // Summon Pei-Wu Door
  62.     SUMMON_GO_TRIGER_CHECKER                       = 115343,
  63. };
  64.  
  65. class npc_panda_announcer : public CreatureScript
  66. {
  67.     public:
  68.         npc_panda_announcer() : CreatureScript("npc_panda_announcer") { }
  69.  
  70.     CreatureAI* GetAI(Creature* creature) const
  71.     {
  72.         return new npc_panda_announcerAI(creature);
  73.     }
  74.    
  75.     struct npc_panda_announcerAI : public ScriptedAI
  76.     {
  77.         npc_panda_announcerAI(Creature* creature) : ScriptedAI(creature)
  78.         {
  79.  
  80.         }
  81.  
  82.         void Reset()
  83.         {
  84.             text = TEXT_GENERIC_0;
  85.             targetGUID.Clear();
  86.         }
  87.  
  88.         enum events
  89.         {
  90.             EVENT_1            = 1,
  91.             EVENT_2_ANNOUNCER6 = 2,
  92.             EVENT_CLEAR        = 3,
  93.         };
  94.  
  95.         uint32 text;
  96.         ObjectGuid targetGUID;
  97.         GuidSet m_player_for_event;
  98.         EventMap events;
  99.         void MoveInLineOfSight(Unit* who)
  100.         {
  101.             if (who->GetTypeId() != TYPEID_PLAYER || who->IsOnVehicle())
  102.                 return;
  103.  
  104.             GuidSet::iterator itr = m_player_for_event.find(who->GetGUID());
  105.             if (itr != m_player_for_event.end())
  106.                 return;
  107.  
  108.             if (!me->IsWithinDistInMap(who, 60.0f))
  109.                 return;
  110.  
  111.             uint32 eTimer = 4000;
  112.  
  113.             switch(me->GetEntry())
  114.             {
  115.                 case NPC_ANNOUNCER_1:
  116.                     if (who->ToPlayer()->GetQuestStatus(QUEST_THE_DISCIPLE_CHALLENGE) != QUEST_STATUS_INCOMPLETE)
  117.                         return;
  118.                     break;
  119.                 case NPC_ANNOUNCER_2:
  120.                 case NPC_ANNOUNCER_3:
  121.                     if (who->ToPlayer()->GetQuestStatus(QUEST_AYSA_OF_TUSHUI) == QUEST_STATUS_REWARDED)
  122.                         return;
  123.                     break;
  124.                 case NPC_ANNOUNCER_5_TRAVEL:
  125.                     if (me->GetAreaId() == 5826 && who->ToPlayer()->GetQuestStatus(QUEST_NEW_FRIEND) != QUEST_STATUS_REWARDED) // Bassins chantants
  126.                         return;
  127.                     if (me->GetAreaId() == 5881) // Ferme Dai-Lo
  128.                     {
  129.                         if (who->ToPlayer()->GetQuestStatus(QUEST_NOT_IN_FACE) != QUEST_STATUS_REWARDED)
  130.                             return;
  131.                         text = TEXT_GENERIC_1;
  132.                     }
  133.                     if (me->GetAreaId() == 5833) // Epave du Chercheciel
  134.                     {
  135.                         if (who->ToPlayer()->GetQuestStatus(QUEST_NOT_IN_FACE) != QUEST_STATUS_REWARDED)
  136.                             return;
  137.                         text = TEXT_GENERIC_1;
  138.                     }
  139.                     break;
  140.                 case NPC_ANNOUNCER_6:
  141.                     if (!me->IsWithinDistInMap(who, 35.0f))
  142.                         return;
  143.                     break;
  144.                 case NPC_ANNOUNCER_8:
  145.                     eTimer = 13000;
  146.                     break;
  147.                 default:
  148.                     break;
  149.             }
  150.  
  151.             m_player_for_event.insert(who->GetGUID());
  152.             events.RescheduleEvent(EVENT_1, eTimer);
  153.             events.RescheduleEvent(EVENT_CLEAR, 300000);
  154.             targetGUID = who->GetGUID();
  155.         }
  156.  
  157.         void UpdateAI(uint32 diff)
  158.         {
  159.             events.Update(diff);
  160.  
  161.             if (uint32 eventId = events.ExecuteEvent())
  162.             {
  163.                 switch (eventId)
  164.                 {
  165.                     case EVENT_1:
  166.                         sCreatureTextMgr->SendChat(me, text, targetGUID);
  167.                         if (me->GetEntry() == NPC_ANNOUNCER_6)
  168.                             events.RescheduleEvent(EVENT_2_ANNOUNCER6, 5000);
  169.                         break;
  170.                     case EVENT_2_ANNOUNCER6:
  171.                         me->DespawnOrUnsummon(5000);
  172. //                        me->GetMotionMaster()->MovePoint(1, 919.6441f, 3631.506f, 251.9946f);
  173.                         me->GetMotionMaster()->MovePoint(1, 902.8281f, 3667.672f, 268.9162f);
  174.                         break;
  175.                     case EVENT_CLEAR:
  176.                         m_player_for_event.clear();
  177.                         break;
  178.                 }
  179.             }
  180.         }
  181.     };
  182. };
  183.  
  184. class mob_tushui_trainee : public CreatureScript
  185. {
  186.     public:
  187.         mob_tushui_trainee() : CreatureScript("mob_tushui_trainee") { }
  188.  
  189.         CreatureAI* GetAI(Creature* creature) const
  190.         {
  191.             return new mob_tushui_trainee_AI(creature);
  192.         }
  193.  
  194.         struct mob_tushui_trainee_AI : public ScriptedAI
  195.         {
  196.             mob_tushui_trainee_AI(Creature* creature) : ScriptedAI(creature) {}
  197.  
  198.             enum data
  199.             {
  200.                 EVENT_1     = 1,
  201.                 EVENT_2     = 2,
  202.                 SPELL       = 109080,
  203.             };
  204.  
  205.             EventMap events;
  206.  
  207.             void Reset()
  208.             {
  209.                 events.Reset();
  210.                 me->SetReactState(REACT_DEFENSIVE);
  211.                 me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
  212.                 events.RescheduleEvent(EVENT_2, 5000);
  213.             }
  214.  
  215.             void EnterCombat(Unit* unit)
  216.             {
  217.                 events.RescheduleEvent(EVENT_1, 5000);
  218.                 events.CancelEvent(EVENT_2);
  219.             }
  220.  
  221.             void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType dmgType)
  222.             {
  223.                 if (attacker && me->HealthBelowPctDamaged(5, damage))
  224.                 {
  225.                     if(attacker->GetTypeId() == TYPEID_PLAYER)
  226.                         attacker->ToPlayer()->KilledMonsterCredit(54586, ObjectGuid::Empty);
  227.                     //me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
  228.                     sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, attacker->GetGUID());
  229.                     me->CombatStop();
  230.                     me->SetFullHealth();
  231.                     me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
  232.                     me->DespawnOrUnsummon(4000);
  233.                     damage = 0;
  234.                 }
  235.             }
  236.  
  237.             void UpdateAI(uint32 diff)
  238.             {
  239.                 UpdateVictim();
  240.  
  241.                 events.Update(diff);
  242.  
  243.                 if (uint32 eventId = events.ExecuteEvent())
  244.                 {
  245.                     switch(eventId)
  246.                     {
  247.                         case EVENT_1:
  248.                             if (me->getVictim())
  249.                                 me->CastSpell(me->getVictim(), SPELL, true);
  250.                             events.RescheduleEvent(EVENT_1, 5000);
  251.                             break;
  252.                         case EVENT_2:
  253.                             me->HandleEmoteCommand(EMOTE_ONESHOT_MONKOFFENSE_ATTACKUNARMEDOFF);
  254.                             events.RescheduleEvent(EVENT_2, 5000);
  255.                             break;
  256.                     }
  257.                 }
  258.                 DoMeleeAttackIfReady();
  259.             }
  260.         };
  261. };
  262.  
  263. // Should be done by summon npc 59591
  264. class mob_master_shang_xi : public CreatureScript
  265. {
  266.     public:
  267.         mob_master_shang_xi() : CreatureScript("mob_master_shang_xi") { }
  268.  
  269.         bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
  270.         {
  271.             if (quest->GetQuestId() == 29408) // La lecon du parchemin brulant
  272.             {
  273.                 creature->AddAura(114610, creature);
  274.                 creature->RemoveFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
  275.                 creature->SetFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  276.             }
  277.  
  278.             return true;
  279.         }
  280.  
  281.         CreatureAI* GetAI(Creature* creature) const
  282.         {
  283.             return new mob_master_shang_xi_AI(creature);
  284.         }
  285.  
  286.         struct mob_master_shang_xi_AI : public ScriptedAI
  287.         {
  288.             mob_master_shang_xi_AI(Creature* creature) : ScriptedAI(creature)
  289.             {
  290.                 checkPlayersTime = 2000;
  291.             }
  292.  
  293.             uint32 checkPlayersTime;
  294.  
  295.             void SpellHit(Unit* caster, const SpellInfo* pSpell)
  296.             {
  297.                 if (pSpell->Id == 114746) // Attraper la flamme
  298.                 {
  299.                     if (caster->GetTypeId() == TYPEID_PLAYER)
  300.                     {
  301.                         if (caster->ToPlayer()->GetQuestStatus(29408) == QUEST_STATUS_INCOMPLETE)
  302.                         {
  303.                             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  304.                             me->CastSpell(caster, 114611, true);
  305.                             me->RemoveAurasDueToSpell(114610);
  306.                             me->SetFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
  307.                             me->RemoveFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  308.                         }
  309.                     }
  310.                 }
  311.             }
  312.  
  313.             void UpdateAI(uint32 diff)
  314.             {
  315.                 if (checkPlayersTime <= diff)
  316.                 {
  317.                     std::list<Player*> playerList;
  318.                     GetPlayerListInGrid(playerList, me, 5.0f);
  319.  
  320.                     bool playerWithQuestNear = false;
  321.  
  322.                     for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
  323.                     {
  324.                         if ((*itr)->GetQuestStatus(29408) == QUEST_STATUS_INCOMPLETE && !(*itr)->HasItemCount(80212))
  325.                                 playerWithQuestNear = true;
  326.                     }
  327.  
  328.                     if (playerWithQuestNear && !me->HasAura(114610))
  329.                     {
  330.                         me->AddAura(114610, me);
  331.                         me->RemoveFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
  332.                         me->SetFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  333.                     }
  334.                     else if (!playerWithQuestNear && me->HasAura(114610))
  335.                     {
  336.                         me->RemoveAurasDueToSpell(114610);
  337.                         me->SetFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
  338.                         me->RemoveFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  339.                     }
  340.  
  341.                     checkPlayersTime = 2000;
  342.                 }
  343.                 else
  344.                     checkPlayersTime -= diff;
  345.             }
  346.         };
  347. };
  348.  
  349. // cast 88811 for check something
  350. class boss_jaomin_ro : public CreatureScript
  351. {
  352. public:
  353.     boss_jaomin_ro() : CreatureScript("boss_jaomin_ro") { }
  354.    
  355.     CreatureAI* GetAI(Creature* creature) const
  356.     {
  357.         return new boss_jaomin_roAI(creature);
  358.     }
  359.    
  360.     struct boss_jaomin_roAI : public ScriptedAI
  361.     {
  362.         boss_jaomin_roAI(Creature* creature) : ScriptedAI(creature) {}
  363.  
  364.         enum eEvents
  365.         {
  366.             EVENT_JAOMIN_JUMP   = 1,
  367.             EVENT_HIT_CIRCLE    = 2,
  368.             EVENT_FALCON        = 3,
  369.             EVENT_RESET         = 4,
  370.         };
  371.  
  372.         EventMap events;
  373.         bool isInFalcon;
  374.         bool fightEnd;
  375.  
  376.         void EnterCombat(Unit* unit)
  377.         {
  378.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  379.             events.RescheduleEvent(EVENT_JAOMIN_JUMP, 1000);
  380.             events.RescheduleEvent(EVENT_HIT_CIRCLE, 2000);
  381.         }
  382.  
  383.         void Reset()
  384.         {
  385.             events.Reset();
  386.             me->SetReactState(REACT_DEFENSIVE);
  387.             me->SetDisplayId(39755);
  388.             me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NOT_ATTACKABLE_1);
  389.             isInFalcon = false;
  390.             fightEnd = false;
  391.         }
  392.  
  393.         void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType dmgType)
  394.         {
  395.             if (me->HealthBelowPctDamaged(30, damage) && !isInFalcon)
  396.             {
  397.                 isInFalcon = true;
  398.                 me->SetDisplayId(39796); //faucon
  399.                 events.RescheduleEvent(EVENT_FALCON, 1000);
  400.                 events.CancelEvent(EVENT_JAOMIN_JUMP);
  401.                 events.CancelEvent(EVENT_HIT_CIRCLE);
  402.             }
  403.  
  404.             if (me->HealthBelowPctDamaged(5, damage) && !fightEnd)
  405.             {
  406.                 sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1);
  407.  
  408.                 std::list<Player*> playerList;
  409.                 GetPlayerListInGrid(playerList, me, 10.0f);
  410.                 for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
  411.                     (*itr)->KilledMonsterCredit(me->GetEntry(), ObjectGuid::Empty);
  412.  
  413.                 fightEnd = true;
  414.                 me->StopAttack();
  415.                 me->SetFullHealth();
  416.                 me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_NOT_ATTACKABLE_1);
  417.                 attacker->AttackStop();
  418.                 me->SetDisplayId(39755);
  419.                 me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
  420.                 events.Reset();
  421.                 events.RescheduleEvent(EVENT_RESET, 9000);
  422.                 DoCast(me, 108959, true);
  423.                 damage = 0;
  424.             }
  425.  
  426.             if (damage >= me->GetHealth())
  427.                 damage = 0;
  428.         }
  429.        
  430.         void UpdateAI(uint32 diff)
  431.         {
  432.             if (!UpdateVictim())
  433.                 return;
  434.  
  435.             events.Update(diff);
  436.  
  437.             if (me->HasUnitState(UNIT_STATE_CASTING))
  438.                 return;
  439.  
  440.             if (CheckHomeDistToEvade(diff, 30.0f))
  441.                 return;
  442.  
  443.             if (uint32 eventId = events.ExecuteEvent())
  444.             {
  445.                 switch(eventId)
  446.                 {
  447.                     case EVENT_JAOMIN_JUMP:
  448.                         DoCastVictim(108938);
  449.                         events.RescheduleEvent(EVENT_JAOMIN_JUMP, 30000);
  450.                         break;
  451.                     case EVENT_HIT_CIRCLE:
  452.                         DoCastVictim(119301);
  453.                         events.RescheduleEvent(EVENT_HIT_CIRCLE, 8000);
  454.                         break;
  455.                     case EVENT_FALCON:
  456.                         DoCast(108935);
  457.                         events.RescheduleEvent(EVENT_FALCON, 6000);
  458.                         break;
  459.                     case EVENT_RESET:
  460.                         me->NearTeleportTo(me->GetHomePosition());
  461.                         EnterEvadeMode();
  462.                         break;
  463.                 }
  464.             }
  465.             DoMeleeAttackIfReady();
  466.         }
  467.     };
  468. };
  469.  
  470. class mob_attacker_dimwind : public CreatureScript
  471. {
  472. public:
  473.     mob_attacker_dimwind() : CreatureScript("mob_attacker_dimwind") { }
  474.     CreatureAI* GetAI(Creature* creature) const
  475.     {
  476.         return new mob_attacker_dimwindAI(creature);
  477.     }
  478.    
  479.     struct mob_attacker_dimwindAI : public ScriptedAI
  480.     {
  481.         mob_attacker_dimwindAI(Creature* creature) : ScriptedAI(creature) {}
  482.        
  483.         void DamageTaken(Unit* pDoneBy, uint32 &uiDamage, DamageEffectType dmgType)
  484.         {
  485.             if(me->GetHealthPct() < 90 && pDoneBy && pDoneBy->ToCreature() && pDoneBy->ToCreature()->GetEntry() == 54785)
  486.                 uiDamage = 0;
  487.         }
  488.  
  489.         void JustDied(Unit* killer)
  490.         {
  491.             if (killer->GetTypeId() != TYPEID_PLAYER || !me->ToTempSummon())
  492.                 return;
  493.  
  494.             if (Creature* owner = me->GetMap()->GetCreature(me->ToTempSummon()->GetSummonerGUID()))
  495.                 owner->AI()->SetGUID(killer->GetGUID(), 0);
  496.         }
  497.     };
  498. };
  499.  
  500. class mob_min_dimwind : public CreatureScript
  501. {
  502. public:
  503.     mob_min_dimwind() : CreatureScript("mob_min_dimwind") { }
  504.    
  505.     CreatureAI* GetAI(Creature* creature) const
  506.     {
  507.         return new mob_min_dimwindAI(creature);
  508.     }
  509.    
  510.     struct mob_min_dimwindAI : public ScriptedAI
  511.     {
  512.         EventMap events;
  513.         GuidSet guidMob;
  514.         ObjectGuid plrGUID;
  515.         GuidSet m_player_for_event;
  516.         bool mt;
  517.  
  518.         mob_min_dimwindAI(Creature* creature) : ScriptedAI(creature)
  519.         {
  520.             mt = false;
  521.         }
  522.  
  523.         void Reset()
  524.         {
  525.             me->setActive(true);
  526.             me->HandleEmoteCommand(EMOTE_STATE_READY2H);
  527.         }
  528.  
  529.         void MoveInLineOfSight(Unit* who)
  530.         {
  531.             if (who->GetTypeId() != TYPEID_PLAYER || who->ToPlayer()->GetQuestStatus(QUEST_MISSING_DRIVER) != QUEST_STATUS_INCOMPLETE)
  532.                 return;
  533.            
  534.             GuidSet::iterator itr = m_player_for_event.find(who->GetGUID());
  535.             if (itr != m_player_for_event.end())
  536.                 return;
  537.  
  538.             m_player_for_event.insert(who->GetGUID());
  539.             if (!mt)
  540.             {
  541.                 mt = true;
  542.                 InitMobs(who);
  543.             }
  544.         }
  545.  
  546.         void DamageTaken(Unit* pDoneBy, uint32 &uiDamage, DamageEffectType dmgType)
  547.         {
  548.             if(me->GetHealthPct() < 25 && pDoneBy && pDoneBy->ToCreature() && pDoneBy->ToCreature()->GetEntry() == NPC_AMBERLEAF_SCAMP)
  549.                 uiDamage = 0;
  550.         }
  551.        
  552.         void SetGUID(ObjectGuid const& guid, int32 id = 0) // deleted , int32 /*id*/ = 0)
  553.         {
  554.             plrGUID = guid;
  555.         }
  556.  
  557.         void SummonedCreatureDespawn(Creature* summon)
  558.         {
  559.             guidMob.erase(summon->GetGUID());
  560.             if (guidMob.empty())
  561.             {
  562.                 mt = false;
  563.                 me->HandleEmoteCommand(EMOTE_STATE_STAND);
  564.                 if (Player* target = sObjectAccessor->FindPlayer(plrGUID))
  565.                 {
  566.                     target->KilledMonsterCredit(54855, ObjectGuid::Empty);
  567.                     // by spell 106205
  568.                     if(TempSummon* mind = target->SummonCreature(NPC_MIN_DIMWIND_OUTRO, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1000))
  569.                     {
  570.                         mind->AI()->SetGUID(plrGUID, 0);
  571.                         mind->setFaction(35);
  572.                     }
  573.                 }
  574.                 me->DespawnOrUnsummon(1000);
  575.             }
  576.         }
  577.        
  578.         void InitMobs(Unit* who)
  579.         {
  580.             me->HandleEmoteCommand(EMOTE_STATE_READY2H);
  581.             for(GuidSet::iterator itr = guidMob.begin(); itr != guidMob.end(); ++itr)
  582.                 if (Creature* c = me->GetMap()->GetCreature(*itr))
  583.                     c->DespawnOrUnsummon(1000);
  584.             guidMob.clear();
  585.  
  586.             for(int i = 0; i < 4; i++)
  587.             {
  588.                 if(TempSummon* temp = me->SummonCreature(NPC_AMBERLEAF_SCAMP, me->GetPositionX()-3+rand()%6, me->GetPositionY() + 4 + rand()%4, me->GetPositionZ()+2, 3.3f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1000))
  589.                 {
  590.                     guidMob.insert(temp->GetGUID());
  591.                    
  592.                     if (i == 0)
  593.                         sCreatureTextMgr->SendChat(temp->ToCreature(), TEXT_GENERIC_0, who->GetGUID());
  594.  
  595.                     temp->SetFacingToObject(me);
  596.                     temp->HandleEmoteCommand(EMOTE_STATE_READY2H);
  597.                     temp->Attack(me, true);
  598.                     //temp->getThreatManager().addThreat(me, 250.0f);
  599.                 }
  600.             }
  601.         }
  602.     };
  603. };
  604.  
  605. class npc_min_dimwind_outro : public CreatureScript
  606. {
  607. public:
  608.     npc_min_dimwind_outro() : CreatureScript("npc_min_dimwind_outro") {}
  609.  
  610.     CreatureAI* GetAI(Creature* creature) const
  611.     {
  612.         return new npc_min_dimwind_outroAI (creature);
  613.     }
  614.  
  615.     struct npc_min_dimwind_outroAI : public npc_escortAI
  616.     {
  617.         npc_min_dimwind_outroAI(Creature* creature) : npc_escortAI(creature) {}
  618.  
  619.         EventMap events;
  620.         ObjectGuid playerGUID;
  621.  
  622.         enum eEvents
  623.         {
  624.             EVENT_1    = 1,
  625.             EVENT_2    = 2,
  626.         };
  627.  
  628.         void Reset()
  629.         {
  630.             playerGUID.Clear();
  631.         }
  632.  
  633.         void SetGUID(ObjectGuid const& guid, int32 id)
  634.         {
  635.             playerGUID = guid;
  636.             events.RescheduleEvent(EVENT_1, 1000);
  637.         }
  638.  
  639.         void WaypointReached(uint32 pointId)
  640.         {            
  641.             switch(pointId)
  642.             {
  643.                 case 3:
  644.                 case 4:
  645.                     sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2, playerGUID);
  646.                     break;
  647.                 case 12:
  648.                     sCreatureTextMgr->SendChat(me, TEXT_GENERIC_3, playerGUID);
  649.                     me->DespawnOrUnsummon(30000);
  650.                     break;
  651.                 default:
  652.                     break;
  653.             }
  654.         }
  655.  
  656.         void UpdateAI(uint32 diff)
  657.         {
  658.             npc_escortAI::UpdateAI(diff);
  659.             events.Update(diff);
  660.  
  661.             if (uint32 eventId = events.ExecuteEvent())
  662.             {
  663.                 switch (eventId)
  664.                 {
  665.                     // emotes only when in vehicle.
  666.                     case EVENT_1:
  667.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, playerGUID);
  668.                         events.RescheduleEvent(EVENT_2, 1000);
  669.                         break;
  670.                     case EVENT_2:
  671.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1, playerGUID);
  672.                         Start(true, true);
  673.                         break;
  674.                     default:
  675.                         break;
  676.                 }
  677.             }
  678.         }
  679.     };
  680. };
  681.  
  682. class mob_aysa_lake_escort : public CreatureScript
  683. {
  684. public:
  685.     mob_aysa_lake_escort() : CreatureScript("mob_aysa_lake_escort") { }
  686.  
  687.     struct mob_aysa_lake_escortAI : public npc_escortAI
  688.     {        
  689.         mob_aysa_lake_escortAI(Creature* creature) : npc_escortAI(creature)
  690.         {}
  691.  
  692.         uint32 IntroTimer;
  693.  
  694.         void Reset()
  695.         {
  696.             IntroTimer = 2500;
  697.         }
  698.  
  699.         void MovementInform(uint32 uiType, uint32 uiId)
  700.         {
  701.             npc_escortAI::MovementInform(uiType, uiId);
  702.  
  703.             if (uiType != POINT_MOTION_TYPE && uiType != EFFECT_MOTION_TYPE)
  704.                 return;
  705.  
  706.             switch (uiId)
  707.             {
  708.                 case 10:
  709.                     me->GetMotionMaster()->MoveJump(1227.11f, 3489.73f, 100.37f, 10, 20, 11);
  710.                     break;
  711.                 case 11:
  712.                     me->GetMotionMaster()->MoveJump(1236.68f, 3456.68f, 102.58f, 10, 20, 12);
  713.                     break;
  714.                 case 12:
  715.                     Start(false, true);
  716.                     break;
  717.                 default:
  718.                     break;
  719.             }
  720.         }
  721.  
  722.         void IsSummonedBy(Unit* summoner)
  723.         {
  724.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  725.             me->AddPlayerInPersonnalVisibilityList(summoner->GetGUID());
  726.         }
  727.  
  728.         void WaypointReached(uint32 waypointId)
  729.         {
  730.             if (waypointId == 4)
  731.                 me->DespawnOrUnsummon(500);
  732.         }
  733.  
  734.         void UpdateAI(uint32 diff)
  735.         {
  736.             if (IntroTimer)
  737.             {
  738.                 if (IntroTimer <= diff)
  739.                 {
  740.                     IntroTimer = 0;
  741.                     me->GetMotionMaster()->MoveJump(1216.78f, 3499.44f, 91.15f, 10, 20, 10);
  742.                 }
  743.                 else
  744.                     IntroTimer -= diff;
  745.             }
  746.  
  747.             npc_escortAI::UpdateAI(diff);
  748.         }
  749.     };
  750.    
  751.     CreatureAI* GetAI(Creature* creature) const
  752.     {
  753.         return new mob_aysa_lake_escortAI(creature);
  754.     }
  755.    
  756. };
  757.  
  758. class mob_aysa : public CreatureScript
  759. {
  760. public:
  761.     mob_aysa() : CreatureScript("mob_aysa") { }
  762.    
  763.     CreatureAI* GetAI(Creature* creature) const
  764.     {
  765.         return new mob_aysaAI(creature);
  766.     }
  767.    
  768.     struct mob_aysaAI : public ScriptedAI
  769.     {
  770.         EventMap events;
  771.         std::list<Player*> playersInvolved;
  772.         ObjectGuid lifeiGUID;
  773.         bool inCombat;
  774.         uint32 timer;
  775.        
  776.         mob_aysaAI(Creature* creature) : ScriptedAI(creature)
  777.         {
  778.             events.RescheduleEvent(1, 600); //Begin script
  779.             inCombat = false;
  780.             timer = 0;
  781.             lifeiGUID.Clear();
  782.             me->SetReactState(REACT_DEFENSIVE);
  783.             me->setFaction(2263);
  784.         }
  785.  
  786.         enum eEvents
  787.         {
  788.             EVENT_START         = 1,
  789.             EVENT_SPAWN_MOBS    = 2,
  790.             EVENT_PROGRESS      = 3,
  791.             EVENT_END           = 4,
  792.         };
  793.  
  794.         enum eText
  795.         {
  796.             TEXT_TUSHI_0          = 0,
  797.             TEXT_TUSHI_1          = 1,
  798.             TEXT_TUSHI_2          = 2,
  799.             TEXT_TUSHI_3          = 3,
  800.             TEXT_TUSHI_4          = 4,
  801.             TEXT_TUSHI_5          = 5,
  802.             TEXT_TUSHI_6          = 6,
  803.         };
  804.        
  805.         void DamageTaken(Unit* pDoneBy, uint32 &uiDamage, DamageEffectType dmgType)
  806.         {
  807.             if(me->HealthBelowPctDamaged(5, uiDamage))
  808.             {
  809.                 if (Creature* lifei = me->GetMap()->GetCreature(lifeiGUID))
  810.                 {
  811.                     lifei->DespawnOrUnsummon(0);
  812.                     lifeiGUID.Clear();
  813.                     timer = 0;
  814.                 }
  815.                
  816.                 uiDamage = 0;
  817.                 me->SetFullHealth();
  818.                 me->SetReactState(REACT_DEFENSIVE);
  819.                
  820.                 std::list<Creature*> unitlist;
  821.                 GetCreatureListWithEntryInGrid(unitlist, me, 59637, 50.0f);
  822.                 for (std::list<Creature*>::const_iterator itr = unitlist.begin(); itr != unitlist.end(); ++itr)
  823.                     me->Kill(*itr);
  824.                    
  825.                 events.RescheduleEvent(EVENT_START, 20000);
  826.                 events.CancelEvent(EVENT_SPAWN_MOBS);
  827.                 events.CancelEvent(EVENT_PROGRESS);
  828.                 events.CancelEvent(EVENT_END);
  829.             }
  830.         }
  831.        
  832.         void updatePlayerList()
  833.         {
  834.             playersInvolved.clear();
  835.            
  836.             std::list<Player*> PlayerList;
  837.             GetPlayerListInGrid(PlayerList, me, 20.0f);
  838.  
  839.             for (std::list<Player*>::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
  840.             {
  841.                 Player* player = *itr;
  842.                 if(player->GetQuestStatus(29414) == QUEST_STATUS_INCOMPLETE)
  843.                     playersInvolved.push_back(player);
  844.             }
  845.         }
  846.        
  847.         uint32 getLang(uint32 timer) const
  848.         {
  849.             switch(timer)
  850.             {
  851.                 case 30: return TEXT_TUSHI_2;
  852.                 case 42: return TEXT_TUSHI_0;
  853.                 case 54: return TEXT_TUSHI_1;
  854.                 case 66: return TEXT_TUSHI_3;
  855.                 case 78: return TEXT_TUSHI_5;
  856.                 case 85: return TEXT_TUSHI_6;
  857.                 default: return 0;
  858.             }
  859.             return 0;
  860.         }
  861.         void UpdateAI(uint32 diff)
  862.         {
  863.             events.Update(diff);
  864.             if (uint32 eventId = events.ExecuteEvent())
  865.             {
  866.                 switch(eventId)
  867.                 {
  868.                     case EVENT_START: //Begin script if playersInvolved is not empty
  869.                     {
  870.                         updatePlayerList();
  871.                         if(playersInvolved.empty())
  872.                             events.RescheduleEvent(1, 600);
  873.                         else
  874.                         {
  875.                             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  876.                             me->SetReactState(REACT_PASSIVE);
  877.                             timer = 0;
  878.                             events.RescheduleEvent(EVENT_SPAWN_MOBS, 5000); //spawn mobs
  879.                             events.RescheduleEvent(EVENT_PROGRESS, 1000); //update time
  880.                             events.RescheduleEvent(EVENT_END, 90000); //end quest
  881.                         }
  882.                         break;
  883.                     }
  884.                     case EVENT_SPAWN_MOBS: //Spawn 3 mobs
  885.                     {
  886.                         updatePlayerList();
  887.                         for(int i = 0; i < std::max((int)playersInvolved.size()*3,3); i++)
  888.                         {
  889.                             if(TempSummon* temp = me->SummonCreature(59637, 1144.55f, 3435.65f, 104.97f, 3.3f,TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000))
  890.                             {
  891.                                 if (temp->AI())
  892.                                     temp->AI()->AttackStart(me);
  893.  
  894.                                 temp->AddThreat(me, 250.0f);
  895.                                 temp->GetMotionMaster()->Clear();
  896.                                 temp->GetMotionMaster()->MoveChase(me);
  897.                             }
  898.                         }
  899.                         events.RescheduleEvent(EVENT_SPAWN_MOBS, 20000); //spawn mobs
  900.                         break;
  901.                     }
  902.                     case EVENT_PROGRESS: //update energy
  903.                     {
  904.                         timer++;
  905.                         if(timer == 25 && !lifeiGUID)
  906.                         {
  907.                             if (Creature *lifei = me->SummonCreature(NPC_MASTER_LI_FAI, 1130.162231f, 3435.905518f, 105.496597f, 0.0f, TEMPSUMMON_MANUAL_DESPAWN))
  908.                             {
  909.                                 sCreatureTextMgr->SendChat(lifei, TEXT_TUSHI_4);
  910.                                 lifeiGUID = lifei->GetGUID();
  911.                             }
  912.                         }
  913.                        
  914.                         if (uint32 lang = getLang(timer))
  915.                         {
  916.                             if (Creature* lifei = me->GetMap()->GetCreature(lifeiGUID))
  917.                             {
  918.                                 sCreatureTextMgr->SendChat(lifei, lang);
  919.                                 if(timer == 85)
  920.                                 {
  921.                                     lifei->DespawnOrUnsummon(0);
  922.                                     lifeiGUID.Clear();
  923.                                 }
  924.                             }
  925.                         }
  926.                        
  927.                         updatePlayerList();
  928.                         for (std::list<Player*>::const_iterator itr = playersInvolved.begin(); itr != playersInvolved.end(); ++itr)
  929.                         {
  930.                             Player* player = *itr;
  931.                             if(!player->HasAura(116421))
  932.                                 player->CastSpell(player, 116421);
  933.  
  934.                             player->ModifyPower(POWER_ALTERNATE, timer/25);
  935.                             player->SetMaxPower(POWER_ALTERNATE, 90);
  936.                         }
  937.  
  938.                         events.RescheduleEvent(EVENT_PROGRESS, 1000);
  939.                         break;
  940.                     }
  941.                     case EVENT_END: //script end
  942.                     {
  943.                         if (Creature* lifei = me->GetMap()->GetCreature(lifeiGUID))
  944.                         {
  945.                             lifei->DespawnOrUnsummon(0);
  946.                             lifeiGUID.Clear();
  947.                             timer = 0;
  948.                         }
  949.                         events.RescheduleEvent(EVENT_START, 10000);
  950.                         events.CancelEvent(EVENT_SPAWN_MOBS);
  951.                         events.CancelEvent(EVENT_PROGRESS);
  952.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1);
  953.                         updatePlayerList();
  954.                         me->SetReactState(REACT_DEFENSIVE);
  955.                         for (std::list<Player*>::const_iterator itr = playersInvolved.begin(); itr != playersInvolved.end(); ++itr)
  956.                         {
  957.                             Player* player = *itr;
  958.                             player->KilledMonsterCredit(NPC_MASTER_LI_FAI, ObjectGuid::Empty);
  959.                             player->RemoveAura(116421);
  960.                         }
  961.                         break;
  962.                     }
  963.                 }
  964.             }
  965.         }
  966.     };
  967. };
  968.  
  969. class boss_living_air : public CreatureScript
  970. {
  971. public:
  972.     boss_living_air() : CreatureScript("boss_living_air") { }
  973.    
  974.     CreatureAI* GetAI(Creature* creature) const
  975.     {
  976.         return new boss_living_airAI(creature);
  977.     }
  978.    
  979.     struct boss_living_airAI : public ScriptedAI
  980.     {
  981.         boss_living_airAI(Creature* creature) : ScriptedAI(creature)
  982.         {
  983.             me->SetReactState(REACT_AGGRESSIVE);
  984.         }
  985.        
  986.         EventMap events;
  987.        
  988.         void EnterCombat(Unit* unit)
  989.         {
  990.             events.RescheduleEvent(1, 3000);
  991.             events.RescheduleEvent(2, 5000);
  992.         }
  993.        
  994.         void UpdateAI(uint32 diff)
  995.         {
  996.             if (!UpdateVictim())
  997.                 return;
  998.            
  999.             events.Update(diff);
  1000.            
  1001.             if (uint32 eventId = events.ExecuteEvent())
  1002.             {
  1003.                 switch(eventId)
  1004.                 {
  1005.                     case 1:
  1006.                         me->CastSpell(me->getVictim(), 108693);
  1007.                         break;
  1008.                     case 2:
  1009.                         me->CastSpell(me->getVictim(), 73212);
  1010.                         events.RescheduleEvent(2, 5000);
  1011.                         break;
  1012.                 }
  1013.             }
  1014.            
  1015.             DoMeleeAttackIfReady();
  1016.         }
  1017.     };
  1018. };
  1019.  
  1020. class boss_li_fei : public CreatureScript
  1021. {
  1022. public:
  1023.     boss_li_fei() : CreatureScript("boss_li_fei") {}
  1024.  
  1025.     bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
  1026.     {
  1027.         if (quest->GetQuestId() == QUEST_PARCHEMIN_VOLANT) // La lecon du parchemin brulant
  1028.         {
  1029.             // used by spell 102445
  1030.             if (Creature* tempSummon = creature->SummonCreature(54734, creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000, player->GetGUID()))
  1031.             {
  1032.                 //player->CastSpell(player, 108149);  //visib
  1033.                 //player->CastSpell(player, 108150);  //invis
  1034.                
  1035.                 tempSummon->AddPlayerInPersonnalVisibilityList(player->GetGUID());
  1036.                 tempSummon->AI()->AttackStart(player);
  1037.                 tempSummon->AI()->SetGUID(player->GetGUID());
  1038.             }
  1039.         }
  1040.  
  1041.         return true;
  1042.     }
  1043. };
  1044.  
  1045. class boss_li_fei_fight : public CreatureScript
  1046. {
  1047. public:
  1048.     boss_li_fei_fight() : CreatureScript("boss_li_fei_fight") { }
  1049.    
  1050.     CreatureAI* GetAI(Creature* creature) const
  1051.     {
  1052.         return new boss_li_fei_fightAI(creature);
  1053.     }
  1054.    
  1055.     struct boss_li_fei_fightAI : public ScriptedAI
  1056.     {
  1057.         EventMap events;
  1058.         std::list<Player*> playersInvolved;
  1059.         ObjectGuid playerGuid;
  1060.  
  1061.         boss_li_fei_fightAI(Creature* creature) : ScriptedAI(creature)
  1062.         {}
  1063.  
  1064.         enum eEvents
  1065.         {
  1066.             EVENT_CHECK_PLAYER      = 1,
  1067.             EVENT_FEET_OF_FURY      = 2,
  1068.             EVENT_SHADOW_KICK       = 3,
  1069.             EVENT_SHADOW_KICK_STUN  = 4,
  1070.         };
  1071.  
  1072.         void Reset()
  1073.         {
  1074.             // This particular entry is also spawned on an other event
  1075.             if (me->GetAreaId() != 5849) // Cavern areaid
  1076.                 return;
  1077.  
  1078.             playerGuid.Clear();
  1079.             me->SetReactState(REACT_AGGRESSIVE);
  1080.             me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_IMMUNE_TO_PC);
  1081.             me->setFaction(16);
  1082.             events.RescheduleEvent(EVENT_CHECK_PLAYER, 2500);
  1083.             events.RescheduleEvent(EVENT_FEET_OF_FURY, 5000);
  1084.             events.RescheduleEvent(EVENT_SHADOW_KICK,  1000);
  1085.         }
  1086.  
  1087.         void SetGUID(ObjectGuid const& guid, int32 /*type*/) override
  1088.         {
  1089.             playerGuid = guid;
  1090.         }
  1091.        
  1092.         void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType dmgType)
  1093.         {
  1094.             if (me->HealthBelowPctDamaged(10, damage))
  1095.             {
  1096.                 damage = 0;
  1097.                 me->setFaction(35);
  1098.                 me->CombatStop();
  1099.                 me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
  1100.                 me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
  1101.  
  1102.                 if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  1103.                 {
  1104.                     player->KilledMonsterCredit(54734, ObjectGuid::Empty);
  1105.                     player->RemoveAurasDueToSpell(108150);
  1106.                 }
  1107.                 if (Creature* owner = me->GetMap()->GetCreature(me->ToTempSummon()->GetSummonerGUID()))
  1108.                     sCreatureTextMgr->SendChat(owner, TEXT_GENERIC_0, attacker->GetGUID());
  1109.             }
  1110.         }
  1111.  
  1112.         void KilledUnit(Unit* victim)
  1113.         {
  1114.             if (victim->GetTypeId() == TYPEID_PLAYER)
  1115.             {
  1116.                 victim->ToPlayer()->SetQuestStatus(QUEST_PARCHEMIN_VOLANT, QUEST_STATUS_FAILED);
  1117.  
  1118.                 if (victim->GetGUID() == playerGuid)
  1119.                     me->DespawnOrUnsummon(3000);
  1120.             }
  1121.         }
  1122.        
  1123.         void UpdateAI(uint32 diff)
  1124.         {
  1125.             events.Update(diff);
  1126.            
  1127.             if (uint32 eventId = events.ExecuteEvent())
  1128.             {
  1129.                 switch(eventId)
  1130.                 {
  1131.                     case EVENT_CHECK_PLAYER:
  1132.                     {
  1133.                         bool checkPassed = true;
  1134.                         Player* player = ObjectAccessor::FindPlayer(playerGuid);
  1135.  
  1136.                         if (!player || !player->isAlive())
  1137.                         {
  1138.                             me->DespawnOrUnsummon(1000);
  1139.                             playerGuid.Clear();
  1140.                             break;
  1141.                         }
  1142.  
  1143.                         if (player->GetQuestStatus(QUEST_PARCHEMIN_VOLANT) != QUEST_STATUS_INCOMPLETE)
  1144.                         {
  1145.                             me->DespawnOrUnsummon(1000);
  1146.                             playerGuid.Clear();
  1147.                             break;
  1148.                         }
  1149.  
  1150.                         events.RescheduleEvent(EVENT_CHECK_PLAYER, 2500);
  1151.                         break;
  1152.                     }
  1153.                     case EVENT_FEET_OF_FURY:
  1154.                         if(me->getVictim())
  1155.                             me->CastSpell(me->getVictim(), 108958);
  1156.  
  1157.                         events.RescheduleEvent(EVENT_FEET_OF_FURY, 5000);
  1158.                         break;
  1159.                     case EVENT_SHADOW_KICK:
  1160.                         if(me->getVictim())
  1161.                             me->CastSpell(me->getVictim(), 108936);
  1162.  
  1163.                         events.RescheduleEvent(EVENT_SHADOW_KICK_STUN, 2500);
  1164.                         events.RescheduleEvent(EVENT_SHADOW_KICK, 30000);
  1165.                         break;
  1166.                     case 4:
  1167.                         if(me->getVictim())
  1168.                             me->CastSpell(me->getVictim(), 108944);
  1169.                         break;
  1170.                 }
  1171.             }
  1172.            
  1173.             DoMeleeAttackIfReady();
  1174.         }
  1175.     };
  1176. };
  1177.  
  1178. class AreaTrigger_at_temple_entrance : public AreaTriggerScript
  1179. {
  1180.     public:
  1181.         AreaTrigger_at_temple_entrance() : AreaTriggerScript("AreaTrigger_at_temple_entrance")
  1182.         {}
  1183.  
  1184.         bool OnTrigger(Player* player, AreaTriggerEntry const* trigger, bool enter)
  1185.         {
  1186.             if (player->GetQuestStatus(QUEST_PASSION_OF_SHEN) == QUEST_STATUS_INCOMPLETE)
  1187.             {
  1188.                 player->KilledMonsterCredit(61128, ObjectGuid::Empty);
  1189.  
  1190.                 std::list<Creature*> huoList;
  1191.                 GetCreatureListWithEntryInGrid(huoList, player, 54958, 20.0f);
  1192.  
  1193.                 for (std::list<Creature*>::const_iterator itr = huoList.begin(); itr != huoList.end(); ++itr)
  1194.                 {
  1195.                     Creature* huo = *itr;
  1196.                     if (huo->ToTempSummon())
  1197.                     {
  1198.                         if (huo->ToTempSummon()->GetOwnerGUID() == player->GetGUID())
  1199.                         {
  1200.                             huo->GetMotionMaster()->Clear();
  1201.                             huo->GetMotionMaster()->MovePoint(1, 950.0f, 3601.0f, 203.0f);
  1202.                             huo->DespawnOrUnsummon(5000);
  1203.                         }
  1204.                     }
  1205.                 }
  1206.             }
  1207.  
  1208.             return true;
  1209.         }
  1210. };
  1211.  
  1212. /*
  1213. ========================================
  1214. ========= E A S T  P A R T =============
  1215. ========================================
  1216. */
  1217.  
  1218. class at_going_to_east : public AreaTriggerScript
  1219. {
  1220.     public:
  1221.         at_going_to_east() : AreaTriggerScript("at_going_to_east")
  1222.         {}
  1223.  
  1224.         bool OnTrigger(Player* player, AreaTriggerEntry const* trigger, bool enter)
  1225.         {
  1226.             if (player->HasAura(SPELL_CSA_AT_TIMER) || player->ToPlayer()->GetQuestStatus(QUEST_SINGING_POOLS) != QUEST_STATUS_COMPLETE)
  1227.                 return true;
  1228.  
  1229.             player->CastSpell(player, SPELL_CSA_AT_TIMER, true);
  1230.             //player->CastSpell(player, SPELL_SUMMON_CHILDREN, true);
  1231.            
  1232.             if (Creature *cai = player->SummonCreature(NPC_EAST_CHILDREN_CAI, 934.0156f, 3513.154f, 188.1347f, 0.0f, TEMPSUMMON_MANUAL_DESPAWN))
  1233.             {
  1234.                 cai->AI()->SetGUID(player->GetGUID(), 0);
  1235.                 cai->GetMotionMaster()->MoveFollow(player, 2.0f, M_PI / 4);
  1236.             }
  1237.             if (Creature *cai = player->SummonCreature(NPC_EAST_CHILDREN_DEN, 949.37f, 3510.0f, 187.7983f, 0.0f, TEMPSUMMON_MANUAL_DESPAWN))
  1238.             {
  1239.                 cai->AI()->SetGUID(player->GetGUID(), 0);
  1240.                 cai->GetMotionMaster()->MoveFollow(player, 2.0f, M_PI / 2);
  1241.             }
  1242.             return true;
  1243.         }
  1244. };
  1245.  
  1246. class npc_childrens_going_to_east : public CreatureScript
  1247. {
  1248. public:
  1249.     npc_childrens_going_to_east() : CreatureScript("npc_childrens_going_to_east") { }
  1250.    
  1251.     CreatureAI* GetAI(Creature* creature) const
  1252.     {
  1253.         return new npc_childrens_going_to_eastAI(creature);
  1254.     }
  1255.    
  1256.     struct npc_childrens_going_to_eastAI : public ScriptedAI
  1257.     {
  1258.         npc_childrens_going_to_eastAI(Creature* creature) : ScriptedAI(creature)
  1259.         {
  1260.         }
  1261.  
  1262.         enum eEvents
  1263.         {
  1264.             EVENT_1   = 1,
  1265.             EVENT_2   = 2,
  1266.             EVENT_3   = 3,
  1267.             EVENT_DESPOWN   = 4,
  1268.         };
  1269.        
  1270.         EventMap events;
  1271.         ObjectGuid plrGUID;
  1272.  
  1273.         void SetGUID(ObjectGuid const& guid, int32 /*id*/ = 0)
  1274.         {
  1275.             plrGUID = guid;
  1276.         }
  1277.  
  1278.         void Reset()
  1279.         {
  1280.             plrGUID.Clear();
  1281.             events.RescheduleEvent(EVENT_DESPOWN, 60000);
  1282.  
  1283.             if (me->GetEntry() == NPC_EAST_CHILDREN_CAI)
  1284.             {
  1285.                 events.RescheduleEvent(EVENT_1, 1000);
  1286.                 events.RescheduleEvent(EVENT_2, 25000);
  1287.                 events.RescheduleEvent(EVENT_3, 50000);
  1288.             }else
  1289.             {
  1290.                 events.RescheduleEvent(EVENT_1, 15000);
  1291.                 events.RescheduleEvent(EVENT_2, 40000);
  1292.             }
  1293.         }
  1294.        
  1295.         void UpdateAI(uint32 diff)
  1296.         {
  1297.  
  1298.             events.Update(diff);
  1299.  
  1300.             if (uint32 eventId = events.ExecuteEvent())
  1301.             {
  1302.                 switch (eventId)
  1303.                 {
  1304.                     case EVENT_1:
  1305.                     case EVENT_2:
  1306.                     case EVENT_3:
  1307.                         sCreatureTextMgr->SendChat(me, eventId - 1, plrGUID);
  1308.                         break;
  1309.                     case EVENT_DESPOWN:
  1310.                         sCreatureTextMgr->SendChat(me, me->GetEntry() == NPC_EAST_CHILDREN_CAI ? TEXT_GENERIC_3 : TEXT_GENERIC_2, plrGUID);
  1311.                         me->DespawnOrUnsummon(5000);
  1312.                         break;
  1313.                     default:
  1314.                         break;
  1315.                 }
  1316.             }
  1317.         }
  1318.     };
  1319. };
  1320.  
  1321. class checkArea : public BasicEvent
  1322. {
  1323.     Player* player;
  1324.     uint32 spellId;
  1325. public:
  1326.     explicit checkArea(Player * me, uint32 sp) : player(me), spellId(sp) {}
  1327.  
  1328.     virtual bool Execute(uint64 , uint32)
  1329.     {
  1330.         LiquidData liquidStatus;
  1331.         ZLiquidStatus status = player->GetMap()->getLiquidStatus(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus);
  1332.         if (!player->IsOnVehicle() && status == LIQUID_MAP_IN_WATER)
  1333.             player->AddAura(spellId, player);
  1334.         return true;
  1335.     }
  1336. };
  1337.  
  1338. class AreaTrigger_at_bassin_curse : public AreaTriggerScript
  1339. {
  1340.     public:
  1341.         AreaTrigger_at_bassin_curse() : AreaTriggerScript("AreaTrigger_at_bassin_curse")
  1342.         {}
  1343.  
  1344.         enum eTriggers
  1345.         {
  1346.             AREA_CRANE              = 6991,
  1347.             AREA_SKUNK              = 6988,
  1348.             AREA_FROG2              = 6986,
  1349.             AREA_FROG               = 6987,
  1350.             AREA_FROG_EXIT          = 6986,
  1351.             AREA_TURTLE             = 7012,
  1352.             AREA_CROCODILE          = 6990
  1353.         };
  1354.  
  1355.         enum eSpells
  1356.         {
  1357.             SPELL_FROG              = 102938,
  1358.             SPELL_SKUNK             = 102939,
  1359.             SPELL_TURTLE            = 102940,
  1360.             SPELL_CRANE             = 102941,
  1361.             SPELL_CROCODILE         = 102942,
  1362.         };
  1363.  
  1364.         void AddOrRemoveSpell(Player* player, uint32 spellId, bool enter)
  1365.         {
  1366.             RemoveAllSpellsExcept(player, spellId);
  1367.  
  1368.             if (!player->HasAura(spellId))
  1369.             {
  1370.                 player->m_Events.AddEvent(new checkArea(player, spellId), player->m_Events.CalculateTime(1000));
  1371.             }
  1372.             else if (!enter)
  1373.                 player->RemoveAurasDueToSpell(spellId);
  1374.         }
  1375.  
  1376.         void RemoveAllSpellsExcept(Player* player, uint32 spellId)
  1377.         {
  1378.             uint32 spellTable[5] = {SPELL_FROG, SPELL_SKUNK, SPELL_TURTLE, SPELL_CRANE, SPELL_CROCODILE};
  1379.  
  1380.             for (uint8 i = 0; i < 5; ++i)
  1381.                 if (spellId != spellTable[i])
  1382.                     player->RemoveAurasDueToSpell(spellTable[i]);
  1383.         }
  1384.  
  1385.         bool OnTrigger(Player* player, AreaTriggerEntry const* trigger, bool enter)
  1386.         {
  1387.             //if (player->IsOnVehicle())
  1388.             //    return true;
  1389.  
  1390.             switch(trigger->ID)
  1391.             {
  1392.                 case AREA_CRANE:     AddOrRemoveSpell(player, SPELL_CRANE, enter);     break;
  1393.                 case AREA_SKUNK:     AddOrRemoveSpell(player, SPELL_SKUNK, enter);     break;
  1394.                 case AREA_FROG: case AREA_FROG_EXIT: AddOrRemoveSpell(player, SPELL_FROG, enter);      break;
  1395.                 //case AREA_FROG_EXIT: RemoveAllSpellsExcept(player, 0);          break;
  1396.                 case AREA_TURTLE:    AddOrRemoveSpell(player, SPELL_TURTLE, enter);    break;
  1397.                 case AREA_CROCODILE: AddOrRemoveSpell(player, SPELL_CROCODILE, enter); break;
  1398.             }
  1399.  
  1400.             return true;
  1401.         }
  1402. };
  1403.  
  1404. // Npc's : 54993 - 55083 - 57431
  1405. class vehicle_balance_pole : public VehicleScript
  1406. {
  1407.     public:
  1408.         vehicle_balance_pole() : VehicleScript("vehicle_balance_pole") {}
  1409.  
  1410.         void OnAddPassenger(Vehicle* veh, Unit* passenger, int8 /*seatId*/)
  1411.         {
  1412.             if (passenger->HasAura(102938))
  1413.                 passenger->ExitVehicle();
  1414.         }
  1415.  
  1416.         void OnRemovePassenger(Vehicle* veh, Unit* passenger)
  1417.         {
  1418.             Player* p = passenger->ToPlayer();
  1419.             if (!p || !p->GetLastAreaTrigger())
  1420.                 return;
  1421.  
  1422.             sScriptMgr->OnAreaTrigger(p, p->GetLastAreaTrigger(), true);
  1423.             //passenger->AddAura(102938, passenger);
  1424.         }
  1425. };
  1426.  
  1427. /*
  1428. blizz create random pole... one model set invisible. this enable all visible.
  1429. UPDATE `creature_template` SET `modelid2` = '0' WHERE `entry` in (54993, 55083, 57431);
  1430. UPDATE `creature_template` SET `modelid1` = '38347', `modelid2` = '0' WHERE `entry` = 57626;
  1431. */
  1432. class mob_tushui_monk : public CreatureScript
  1433. {
  1434. public:
  1435.     mob_tushui_monk() : CreatureScript("mob_tushui_monk") { }
  1436.  
  1437.     CreatureAI* GetAI(Creature* creature) const
  1438.     {
  1439.         return new mob_tushui_monkAI(creature);
  1440.     }
  1441.  
  1442.     struct mob_tushui_monkAI : public ScriptedAI
  1443.     {
  1444.         mob_tushui_monkAI(Creature* creature) : ScriptedAI(creature)
  1445.         {
  1446.             me->setFaction(2357);
  1447.         }
  1448.  
  1449.         enum data
  1450.         {
  1451.             NPC_VEH         =   54993,
  1452.         };
  1453.  
  1454.         ObjectGuid vehGUID;
  1455.         EventMap events;
  1456.  
  1457.         void Reset()
  1458.         {
  1459.             events.RescheduleEvent(1, 1000);
  1460.             vehGUID.Clear();
  1461.         }
  1462.  
  1463.         void JustDied(Unit* /*killer*/)
  1464.         {
  1465.             me->ExitVehicle();
  1466.             me->DespawnOrUnsummon(1000);
  1467.             if (Creature *v = me->GetMap()->GetCreature(vehGUID))
  1468.                 v->DespawnOrUnsummon(100);
  1469.         }
  1470.  
  1471.         void UpdateAI(uint32 diff)
  1472.         {
  1473.             //UpdateVictim();
  1474.  
  1475.             events.Update(diff);
  1476.  
  1477.             while (events.ExecuteEvent())
  1478.             {
  1479.                 if (me->GetVehicle())
  1480.                     return;
  1481.  
  1482.                 me->StopMoving();
  1483.  
  1484.                 if (Creature * c = me->GetMap()->SummonCreature(NPC_VEH, *me, NULL, 0, NULL, ObjectGuid::Empty, 0, 1749))
  1485.                 {
  1486.                     c->SetDisplayId(39004);
  1487.                     me->EnterVehicle(c);
  1488.                     vehGUID = c->GetGUID();
  1489.                 }else
  1490.                     events.RescheduleEvent(1, 1000);
  1491.             }
  1492.             DoMeleeAttackIfReady();
  1493.         }
  1494.     };
  1495. };
  1496.  
  1497. class mob_jojo_ironbrow_1 : public CreatureScript
  1498. {
  1499. public:
  1500.     mob_jojo_ironbrow_1() : CreatureScript("mob_jojo_ironbrow_1") {}
  1501.  
  1502.     CreatureAI* GetAI(Creature* creature) const
  1503.     {
  1504.         return new mob_jojo_ironbrow_1_AI (creature);
  1505.     }
  1506.  
  1507.     struct mob_jojo_ironbrow_1_AI : public ScriptedAI
  1508.     {
  1509.         mob_jojo_ironbrow_1_AI(Creature* creature) : ScriptedAI(creature) {}
  1510.  
  1511.         enum eEvents
  1512.         {
  1513.             EVENT_1    = 1,
  1514.             EVENT_2    = 2,
  1515.             EVENT_3    = 3,
  1516.             EVENT_4    = 4,
  1517.         };
  1518.  
  1519.         enum eSpell
  1520.         {
  1521.             NPC_TARGET          = 57636,
  1522.             SUPER_DUPER_KULAK   = 129272,
  1523.         };
  1524.  
  1525.         EventMap events;
  1526.  
  1527.         void Reset()
  1528.         {
  1529.             me->SetWalk(true);
  1530.             events.RescheduleEvent(EVENT_1, 1000);
  1531.         }
  1532.  
  1533.         void MovementInform(uint32 moveType, uint32 pointId)
  1534.         {
  1535.             if (pointId == EVENT_4)
  1536.                 me->DespawnOrUnsummon(1000);
  1537.             else
  1538.                 sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  1539.         }
  1540.  
  1541.         void UpdateAI(uint32 diff)
  1542.         {
  1543.             events.Update(diff);
  1544.  
  1545.             if (uint32 eventId = events.ExecuteEvent())
  1546.             {
  1547.                 switch (eventId)
  1548.                 {
  1549.                     // emotes only when in vehicle.
  1550.                     case EVENT_1:
  1551.                         me->GetMotionMaster()->MovePoint(EVENT_1, 1039.0f, 3284.0f, 126.6f);
  1552.                         events.RescheduleEvent(EVENT_2, 10000);
  1553.                         break;
  1554.                     case EVENT_2:
  1555.                         if (Creature* target = me->FindNearestCreature(NPC_TARGET, 50.0f, true))
  1556.                             me->CastSpell(target, SUPER_DUPER_KULAK, true);
  1557.                         events.RescheduleEvent(EVENT_3, 3000);
  1558.                         break;
  1559.                     case EVENT_3:
  1560.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1);
  1561.                         events.RescheduleEvent(EVENT_4, 10000);
  1562.                         break;
  1563.                     case EVENT_4:
  1564.                         me->GetMotionMaster()->MovePoint(EVENT_4, 1027.379f, 3287.417f, 126.2935f);
  1565.                         break;
  1566.                     default:
  1567.                         break;
  1568.                 }
  1569.             }
  1570.         }
  1571.     };
  1572. };
  1573.  
  1574. // Rock Jump - 103069 / 103070 / 103077
  1575. class spell_rock_jump: public SpellScriptLoader
  1576. {
  1577.     public:
  1578.         spell_rock_jump() : SpellScriptLoader("spell_rock_jump") { }
  1579.  
  1580.         class spell_rock_jump_SpellScript : public SpellScript
  1581.         {
  1582.             PrepareSpellScript(spell_rock_jump_SpellScript);
  1583.  
  1584.             void HandleScriptEffect(SpellEffIndex effIndex)
  1585.             {
  1586.                 if (Unit* caster = GetCaster())
  1587.                 {
  1588.                     if (caster->GetPositionZ() < 90.0f)
  1589.                         caster->GetMotionMaster()->MoveJump(1045.36f, 2848.47f, 91.38f, 10.0f, 10.0f);
  1590.                     else if (caster->GetPositionZ() < 92.0f)
  1591.                         caster->GetMotionMaster()->MoveJump(1054.42f, 2842.65f, 92.96f, 10.0f, 10.0f);
  1592.                     else if (caster->GetPositionZ() < 94.0f)
  1593.                         caster->GetMotionMaster()->MoveJump(1063.66f, 2843.49f, 95.50f, 10.0f, 10.0f);
  1594.                     else
  1595.                     {
  1596.                         caster->GetMotionMaster()->MoveJump(1078.42f, 2845.07f, 95.16f, 10.0f, 10.0f);
  1597.  
  1598.                         if (caster->ToPlayer())
  1599.                             caster->ToPlayer()->KilledMonsterCredit(57476);
  1600.                     }
  1601.                 }
  1602.             }
  1603.  
  1604.             void Register()
  1605.             {
  1606.                 OnEffectLaunch += SpellEffectFn(spell_rock_jump_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_JUMP_DEST);
  1607.             }
  1608.         };
  1609.  
  1610.         SpellScript* GetSpellScript() const
  1611.         {
  1612.             return new spell_rock_jump_SpellScript();
  1613.         }
  1614. };
  1615.  
  1616. Position rocksPos[4] =
  1617. {
  1618.     {1102.05f, 2882.11f, 94.32f, 0.11f},
  1619.     {1120.01f, 2883.20f, 96.44f, 4.17f},
  1620.     {1128.09f, 2859.44f, 97.64f, 2.51f},
  1621.     {1111.52f, 2849.84f, 94.84f, 1.94f}
  1622. };
  1623.  
  1624. class mob_shu_water_spirit : public CreatureScript
  1625. {
  1626. public:
  1627.     mob_shu_water_spirit() : CreatureScript("mob_shu_water_spirit") { }
  1628.  
  1629.     CreatureAI* GetAI(Creature* creature) const
  1630.     {
  1631.         return new mob_shu_water_spiritAI(creature);
  1632.     }
  1633.  
  1634.     struct mob_shu_water_spiritAI : public ScriptedAI
  1635.     {
  1636.         mob_shu_water_spiritAI(Creature* creature) : ScriptedAI(creature)
  1637.         {}
  1638.  
  1639.         EventMap _events;
  1640.         uint8 actualPlace;
  1641.  
  1642.         ObjectGuid waterSpoutGUID;
  1643.  
  1644.         enum eShuSpells
  1645.         {
  1646.             SPELL_WATER_SPOUT_SUMMON    = 116810,
  1647.             SPELL_WATER_SPOUT_WARNING   = 116695,
  1648.             SPELL_WATER_SPOUT_EJECT     = 116696,
  1649.             SPELL_WATER_SPOUT_VISUAL    = 117057,
  1650.         };
  1651.  
  1652.         enum eEvents
  1653.         {
  1654.             EVENT_CHANGE_PLACE          = 1,
  1655.             EVENT_SUMMON_WATER_SPOUT    = 2,
  1656.             EVENT_WATER_SPOUT_VISUAL    = 3,
  1657.             EVENT_WATER_SPOUT_EJECT     = 4,
  1658.             EVENT_WATER_SPOUT_DESPAWN   = 5,
  1659.         };
  1660.  
  1661.         void Reset()
  1662.         {
  1663.             _events.Reset();
  1664.             actualPlace = 0;
  1665.             waterSpoutGUID.Clear();
  1666.  
  1667.             _events.RescheduleEvent(EVENT_CHANGE_PLACE, 5000);
  1668.         }
  1669.  
  1670.         void MovementInform(uint32 typeId, uint32 pointId) override
  1671.         {
  1672.             if (typeId != EFFECT_MOTION_TYPE)
  1673.                 return;
  1674.  
  1675.             if (pointId == 1)
  1676.             {
  1677.                 me->RemoveAurasDueToSpell(SPELL_WATER_SPOUT_WARNING);
  1678.                 if (Player* player = me->SelectNearestPlayerNotGM(50.0f))
  1679.                 {
  1680.                     me->SetOrientation(me->GetAngle(player));
  1681.                     me->SetFacingToObject(player);
  1682.                     _events.RescheduleEvent(EVENT_SUMMON_WATER_SPOUT, 2000);
  1683.                 }
  1684.                 else
  1685.                     _events.RescheduleEvent(EVENT_CHANGE_PLACE, 5000);
  1686.             }
  1687.         }
  1688.  
  1689.         Creature* getWaterSpout()
  1690.         {
  1691.             return me->GetMap()->GetCreature(waterSpoutGUID);
  1692.         }
  1693.  
  1694.         void UpdateAI(uint32 diff)
  1695.         {
  1696.             _events.Update(diff);
  1697.  
  1698.             switch (_events.ExecuteEvent())
  1699.             {
  1700.                 case EVENT_CHANGE_PLACE:
  1701.                 {
  1702.                     uint8 newPlace = 0;
  1703.  
  1704.                     do { newPlace = urand(0, 3); } while (newPlace == actualPlace);
  1705.  
  1706.                     me->GetMotionMaster()->MoveJump(rocksPos[newPlace].GetPositionX(), rocksPos[newPlace].GetPositionY(), rocksPos[newPlace].GetPositionZ(), 10.0f, 10.0f, 1);
  1707.                     me->AddAura(SPELL_WATER_SPOUT_WARNING, me); // Just visual
  1708.                     actualPlace = newPlace;
  1709.                     break;
  1710.                 }
  1711.                 case EVENT_SUMMON_WATER_SPOUT:
  1712.                 {
  1713.                     float x = 0.0f, y = 0.0f;
  1714.                     GetPositionWithDistInOrientation(me, 5.0f, me->GetOrientation() + frand(-M_PI, M_PI), x, y);
  1715.                     waterSpoutGUID.Clear();
  1716.  
  1717.                     if (Creature* waterSpout = me->SummonCreature(60488, x, y, 92.189629f))
  1718.                         waterSpoutGUID = waterSpout->GetGUID();
  1719.  
  1720.                     _events.RescheduleEvent(EVENT_WATER_SPOUT_VISUAL, 500);
  1721.                     _events.RescheduleEvent(EVENT_WATER_SPOUT_EJECT, 7500);
  1722.                     break;
  1723.                 }
  1724.                 case EVENT_WATER_SPOUT_VISUAL:
  1725.                 {
  1726.                     if (Creature* waterSpout = getWaterSpout())
  1727.                         waterSpout->CastSpell(waterSpout, SPELL_WATER_SPOUT_WARNING, true);
  1728.                     break;
  1729.                 }
  1730.                 case EVENT_WATER_SPOUT_EJECT:
  1731.                 {
  1732.                     if (Creature* waterSpout = getWaterSpout())
  1733.                     {
  1734.                         std::list<Player*> playerList;
  1735.                         GetPlayerListInGrid(playerList, waterSpout, 1.0f);
  1736.  
  1737.                         for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
  1738.                             (*itr)->CastSpell((*itr), SPELL_WATER_SPOUT_EJECT, true);
  1739.  
  1740.                         waterSpout->CastSpell(waterSpout, SPELL_WATER_SPOUT_VISUAL, true);
  1741.                     }
  1742.                     _events.RescheduleEvent(EVENT_WATER_SPOUT_DESPAWN, 3000);
  1743.                     break;
  1744.                 }
  1745.                 case EVENT_WATER_SPOUT_DESPAWN:
  1746.                 {
  1747.                     if (Creature* waterSpout = getWaterSpout())
  1748.                         waterSpout->DespawnOrUnsummon();
  1749.  
  1750.                     waterSpoutGUID.Clear();
  1751.  
  1752.                     _events.RescheduleEvent(EVENT_CHANGE_PLACE, 2000);
  1753.                     break;
  1754.                 }
  1755.             }
  1756.         }
  1757.     };
  1758. };
  1759.  
  1760. // Summon Spirit of Water - 103538
  1761. class spell_summon_spirit_of_watter: public SpellScriptLoader
  1762. {
  1763.     public:
  1764.         spell_summon_spirit_of_watter() : SpellScriptLoader("spell_summon_spirit_of_watter") { }
  1765.  
  1766.         class spell_summon_spirit_of_watter_AuraScript : public AuraScript
  1767.         {
  1768.             PrepareAuraScript(spell_summon_spirit_of_watter_AuraScript);
  1769.            
  1770.             void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  1771.             {
  1772.                 Unit* target = GetTarget();
  1773.  
  1774.                 if (!target)
  1775.                     return;
  1776.  
  1777.                 std::list<Creature*> shuList;
  1778.                 GetCreatureListWithEntryInGrid(shuList, target, NPC_AYSA_WATTER_OUTRO_EVENT, 20.0f);
  1779.                 for (std::list<Creature*>::const_iterator itr = shuList.begin(); itr != shuList.end(); ++itr)
  1780.                 {
  1781.                     (*itr)->AI()->SetGUID(target->GetGUID(), 0);
  1782.                 }
  1783.             }
  1784.  
  1785.             void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  1786.             {
  1787.                 Unit* target = GetTarget();
  1788.  
  1789.                 if (!target)
  1790.                     return;
  1791.  
  1792.             }
  1793.  
  1794.             void Register()
  1795.             {
  1796.                 OnEffectApply  += AuraEffectApplyFn (spell_summon_spirit_of_watter_AuraScript::OnApply,  EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
  1797.                 OnEffectRemove += AuraEffectRemoveFn(spell_summon_spirit_of_watter_AuraScript::OnRemove, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
  1798.             }
  1799.         };
  1800.  
  1801.         AuraScript* GetAuraScript() const
  1802.         {
  1803.             return new spell_summon_spirit_of_watter_AuraScript();
  1804.         }
  1805. };
  1806.  
  1807. class mob_aysa_cloudsinger_watter_outro : public CreatureScript
  1808. {
  1809. public:
  1810.     mob_aysa_cloudsinger_watter_outro() : CreatureScript("mob_aysa_cloudsinger_watter_outro") { }
  1811.  
  1812.     CreatureAI* GetAI(Creature* creature) const
  1813.     {
  1814.         return new mob_aysa_cloudsinger_watter_outroAI(creature);
  1815.     }
  1816.  
  1817.     struct mob_aysa_cloudsinger_watter_outroAI : public ScriptedAI
  1818.     {
  1819.         mob_aysa_cloudsinger_watter_outroAI(Creature* creature) : ScriptedAI(creature)
  1820.         {}
  1821.  
  1822.         EventMap _events;
  1823.         ObjectGuid plrGUID;
  1824.         enum eEvents
  1825.         {
  1826.             EVENT_1          = 1,
  1827.             EVENT_2          = 2,
  1828.  
  1829.         };
  1830.  
  1831.         void Reset()
  1832.         {
  1833.             plrGUID.Clear();
  1834.             _events.Reset();
  1835.         }
  1836.  
  1837.         void SetGUID(ObjectGuid const& guid, int32 /*id*/ = 0)
  1838.         {
  1839.             plrGUID = guid;
  1840.             _events.RescheduleEvent(EVENT_1, 1000);
  1841.             _events.RescheduleEvent(EVENT_2, 10000);
  1842.         }
  1843.  
  1844.         void UpdateAI(uint32 diff)
  1845.         {
  1846.             _events.Update(diff);
  1847.  
  1848.             while (uint32 eventId = _events.ExecuteEvent())
  1849.                 sCreatureTextMgr->SendChat(me, eventId - 1, plrGUID);
  1850.         }
  1851.     };
  1852. };
  1853.  
  1854. // Grab Carriage - 115904
  1855. class spell_grab_carriage: public SpellScriptLoader
  1856. {
  1857.     public:
  1858.         spell_grab_carriage() : SpellScriptLoader("spell_grab_carriage") { }
  1859.  
  1860.         enum misc
  1861.         {
  1862.             _credit = 57710,    //Q: 29680
  1863.             _credit2 = 59497,   //Q: 59497
  1864.             _credit3 = 57741,   //Q: 29800
  1865.         };
  1866.  
  1867.         class spell_grab_carriage_SpellScript : public SpellScript
  1868.         {
  1869.             PrepareSpellScript(spell_grab_carriage_SpellScript);
  1870.  
  1871.             void HandleScriptEffect(SpellEffIndex effIndex)
  1872.             {
  1873.                 Unit* caster = GetCaster();
  1874.  
  1875.                 if (!caster)
  1876.                     return;
  1877.  
  1878.                 Creature* carriage = NULL;
  1879.                 Creature* yak      = NULL;
  1880.                
  1881.                 if (caster->GetAreaId() == 5826) // Bassins chantants
  1882.                 {
  1883.                     carriage = caster->SummonCreature(57208, 979.06f, 2863.87f, 87.88f, 4.7822f, TEMPSUMMON_MANUAL_DESPAWN, 0, caster->GetGUID());
  1884.                     yak      = caster->SummonCreature(57207, 979.37f, 2860.29f, 88.22f, 4.4759f, TEMPSUMMON_MANUAL_DESPAWN, 0, caster->GetGUID());
  1885.                     if (Player* p = caster->ToPlayer())
  1886.                         p->TalkedToCreature(_credit, ObjectGuid::Empty);
  1887.                 }
  1888.                 else if (caster->GetAreaId() == 5881) // Ferme Dai-Lo
  1889.                 {
  1890.                     carriage = caster->SummonCreature(57208, 588.70f, 3165.63f, 88.86f, 4.4156f, TEMPSUMMON_MANUAL_DESPAWN, 0, caster->GetGUID());
  1891.                     yak      = caster->SummonCreature(59499, 587.61f, 3161.91f, 89.31f, 4.3633f, TEMPSUMMON_MANUAL_DESPAWN, 0, caster->GetGUID());
  1892.                     if (Player* p = caster->ToPlayer())
  1893.                         p->TalkedToCreature(_credit2, ObjectGuid::Empty);
  1894.                 }
  1895.                 else if (caster->GetAreaId() == 5833) // Epave du Chercheciel
  1896.                 {
  1897.                     carriage = caster->SummonCreature(57208, 264.37f, 3867.60f, 73.56f, 0.9948f, TEMPSUMMON_MANUAL_DESPAWN, 0, caster->GetGUID());
  1898.                     // spell 108932
  1899.                     yak      = caster->SummonCreature(57742, 268.38f, 3872.36f, 74.50f, 0.8245f, TEMPSUMMON_MANUAL_DESPAWN, 0, caster->GetGUID());
  1900.                     if (Player* p = caster->ToPlayer())
  1901.                         p->TalkedToCreature(_credit3, ObjectGuid::Empty);
  1902.                 }
  1903.  
  1904.                 if (!carriage || !yak)
  1905.                     return;
  1906.  
  1907.                 yak->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_IMMUNE_TO_PC);
  1908.                 carriage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_IMMUNE_TO_PC);
  1909.                 yak->SetReactState(REACT_PASSIVE);
  1910.                 carriage->SetReactState(REACT_PASSIVE);
  1911.  
  1912.                 //sLog->outU(">>>>> speed %f|%u ---- | %f", yak->GetSpeed(MOVE_RUN), yak->IsWalking(), carriage->GetSpeed(MOVE_RUN));
  1913.                 //carriage->SetSpeed(MOVE_WALK, 5.0f, true);
  1914.                 //carriage->SetSpeed(MOVE_RUN, 1.5f, true);
  1915.                 //yak->SetSpeed(MOVE_WALK, yak->GetSpeed(MOVE_WALK), false);
  1916.  
  1917.                 //carriage->CastSpell(yak, 108627, true);   //visual
  1918.                 //carriage->GetMotionMaster()->MoveFollow(yak, 0.0f, M_PI);
  1919.                 yak->AI()->SetGUID(carriage->GetGUID(), 0); // enable following
  1920.                 caster->EnterVehicle(carriage, 0);
  1921.                 caster->RemoveAllMinionsByFilter(55213);
  1922.             }
  1923.  
  1924.             void Register()
  1925.             {
  1926.                 OnEffectLaunch += SpellEffectFn(spell_grab_carriage_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
  1927.             }
  1928.         };
  1929.  
  1930.         SpellScript* GetSpellScript() const
  1931.         {
  1932.             return new spell_grab_carriage_SpellScript();
  1933.         }
  1934. };
  1935.  
  1936. // Npc's : 57208
  1937. class vehicle_carriage : public VehicleScript
  1938. {
  1939.     public:
  1940.         vehicle_carriage() : VehicleScript("vehicle_carriage") {}
  1941.         void OnRemovePassenger(Vehicle* veh, Unit* passenger)
  1942.         {
  1943.             if(Unit* u = veh->GetBase())
  1944.                 if (Creature * c = u->ToCreature())
  1945.                     c->DespawnOrUnsummon(1000);
  1946.         }
  1947. };
  1948.  
  1949. class npc_nourished_yak : public CreatureScript
  1950. {
  1951. public:
  1952.     npc_nourished_yak() : CreatureScript("npc_nourished_yak") { }
  1953.  
  1954.     struct npc_nourished_yakAI : public npc_escortAI
  1955.     {        
  1956.         npc_nourished_yakAI(Creature* creature) : npc_escortAI(creature)
  1957.         {}
  1958.  
  1959.         uint32 IntroTimer;
  1960.  
  1961.         void Reset()
  1962.         {
  1963.             if (me->isSummon())
  1964.             {
  1965.                 IntroTimer = 2500;
  1966.             }
  1967.             else
  1968.                 IntroTimer = 0;
  1969.         }
  1970.  
  1971.         void SetGUID(ObjectGuid const& guid, int32 /*id*/ = 0)
  1972.         {
  1973.             SetFollowerGUID(guid);
  1974.         }
  1975.  
  1976.         void WaypointReached(uint32 waypointId)
  1977.         {
  1978.  
  1979.         }
  1980.  
  1981.         void UpdateAI(uint32 diff)
  1982.         {
  1983.             if (IntroTimer)
  1984.             {
  1985.                 if (IntroTimer <= diff)
  1986.                 {
  1987.                     Start(false, true);
  1988.                     IntroTimer = 0;
  1989.                 }
  1990.                 else
  1991.                     IntroTimer -= diff;
  1992.             }
  1993.  
  1994.             npc_escortAI::UpdateAI(diff);
  1995.         }
  1996.     };
  1997.    
  1998.     CreatureAI* GetAI(Creature* creature) const
  1999.     {
  2000.         return new npc_nourished_yakAI(creature);
  2001.     }
  2002.    
  2003. };
  2004.  
  2005. class mob_jojo_ironbrow_2 : public CreatureScript
  2006. {
  2007. public:
  2008.     mob_jojo_ironbrow_2() : CreatureScript("mob_jojo_ironbrow_2") {}
  2009.  
  2010.     CreatureAI* GetAI(Creature* creature) const
  2011.     {
  2012.         return new mob_jojo_ironbrow_2_AI (creature);
  2013.     }
  2014.  
  2015.     struct mob_jojo_ironbrow_2_AI : public ScriptedAI
  2016.     {
  2017.         mob_jojo_ironbrow_2_AI(Creature* creature) : ScriptedAI(creature) {}
  2018.  
  2019.         enum eEvents
  2020.         {
  2021.             EVENT_1    = 1,
  2022.             EVENT_2    = 2,
  2023.             EVENT_3    = 3,
  2024.             EVENT_4    = 4,
  2025.         };
  2026.  
  2027.         enum eSpell
  2028.         {
  2029.             NPC_TARGET          = 57667,
  2030.             SUPER_DUPER_KULAK   = 129293,
  2031.         };
  2032.  
  2033.         EventMap events;
  2034.  
  2035.         void Reset()
  2036.         {
  2037.             events.RescheduleEvent(EVENT_1, 1000);
  2038.             me->SetWalk(true);
  2039.         }
  2040.  
  2041.         void MovementInform(uint32 moveType, uint32 pointId)
  2042.         {
  2043.             if (pointId == EVENT_4)
  2044.                 me->DespawnOrUnsummon(1000);
  2045.             else
  2046.                 sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  2047.         }
  2048.  
  2049.         void UpdateAI(uint32 diff)
  2050.         {
  2051.             events.Update(diff);
  2052.  
  2053.             if (uint32 eventId = events.ExecuteEvent())
  2054.             {
  2055.                 switch (eventId)
  2056.                 {
  2057.                     // emotes only when in vehicle.
  2058.                     case EVENT_1:
  2059.                         me->GetMotionMaster()->MovePoint(EVENT_1, 599.215f, 3132.27f, 89.06574f);
  2060.                         events.RescheduleEvent(EVENT_2, 10000);
  2061.                         break;
  2062.                     case EVENT_2:
  2063.                         if (Creature* target = me->FindNearestCreature(NPC_TARGET, 50.0f, true))
  2064.                             me->CastSpell(target, SUPER_DUPER_KULAK, true);
  2065.                         events.RescheduleEvent(EVENT_3, 3000);
  2066.                         break;
  2067.                     case EVENT_3:
  2068.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1);
  2069.                         events.RescheduleEvent(EVENT_4, 10000);
  2070.                         break;
  2071.                     case EVENT_4:
  2072.                         me->GetMotionMaster()->MovePoint(EVENT_4, 568.2413f, 3155.377f, 84.04771f);
  2073.                         break;
  2074.                     default:
  2075.                         break;
  2076.                 }
  2077.             }
  2078.         }
  2079.     };
  2080. };
  2081.  
  2082. class npc_water_spirit_dailo : public CreatureScript
  2083. {
  2084. public:
  2085.     npc_water_spirit_dailo() : CreatureScript("npc_water_spirit_dailo") { }
  2086.  
  2087.     enum Credit
  2088.     {
  2089.         CREDIT_1    = 55548,
  2090.         CREDIT_2    = 55547,
  2091.     };
  2092.     bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
  2093.     {
  2094.         player->PlayerTalkClass->ClearMenus();
  2095.         if (action == 1)
  2096.         {
  2097.             player->CLOSE_GOSSIP_MENU();
  2098.             if (player->GetQuestStatus(QUEST_NOT_IN_FACE) == QUEST_STATUS_INCOMPLETE)
  2099.             {
  2100.                 player->KilledMonsterCredit(CREDIT_1);
  2101.                 creature->AI()->SetGUID(player->GetGUID());
  2102.             }
  2103.         }
  2104.  
  2105.         return true;
  2106.     }
  2107.  
  2108.     struct npc_water_spirit_dailoAI : public ScriptedAI
  2109.     {
  2110.         npc_water_spirit_dailoAI(Creature* creature) : ScriptedAI(creature)
  2111.         {}
  2112.  
  2113.         ObjectGuid playerGuid;
  2114.         uint16 eventTimer;
  2115.         uint8  eventProgress;
  2116.  
  2117.         void Reset()
  2118.         {
  2119.             eventTimer = 0;
  2120.             eventProgress = 0;
  2121.             playerGuid.Clear();
  2122.         }
  2123.  
  2124.         void SetGUID(ObjectGuid const& guid, int32 /*type*/)
  2125.         {
  2126.             playerGuid = guid;
  2127.             eventTimer = 2500;
  2128.         }
  2129.  
  2130.         void MovementInform(uint32 typeId, uint32 pointId)
  2131.         {
  2132.             if (typeId != POINT_MOTION_TYPE)
  2133.                 return;
  2134.  
  2135.             switch (pointId)
  2136.             {
  2137.                 case 1:
  2138.                     eventTimer = 250;
  2139.                     ++eventProgress;
  2140.                     break;
  2141.                 case 2:
  2142.                     eventTimer = 250;
  2143.                     ++eventProgress;
  2144.                     break;
  2145.                 case 3:
  2146.                     if (Creature* wugou = GetClosestCreatureWithEntry(me, 60916, 20.0f))
  2147.                         me->SetFacingToObject(wugou);
  2148.                     me->SetUInt32Value(UNIT_FIELD_EMOTE_STATE, EMOTE_STATE_READY_UNARMED);
  2149.                     eventTimer = 2000;
  2150.                     ++eventProgress;
  2151.                     break;
  2152.                 default:
  2153.                     break;
  2154.             }
  2155.         }
  2156.  
  2157.         void UpdateAI(uint32 diff)
  2158.         {
  2159.             if (eventTimer)
  2160.             {
  2161.                 if (eventTimer <= diff)
  2162.                 {
  2163.                     switch (eventProgress)
  2164.                     {
  2165.                         case 0:
  2166.                             me->GetMotionMaster()->MovePoint(1, 650.30f, 3127.16f, 89.62f);
  2167.                             eventTimer = 0;
  2168.                             break;
  2169.                         case 1:
  2170.                             me->GetMotionMaster()->MovePoint(2, 625.25f, 3127.88f, 87.95f);
  2171.                             eventTimer = 0;
  2172.                             break;
  2173.                         case 2:
  2174.                             me->GetMotionMaster()->MovePoint(3, 624.44f, 3142.94f, 87.75f);
  2175.                             eventTimer = 0;
  2176.                             break;
  2177.                         case 3:
  2178.                             if (Creature* wugou = GetClosestCreatureWithEntry(me, 60916, 20.0f))
  2179.                                 wugou->CastSpell(wugou, 118027, false);
  2180.                             me->SetUInt32Value(UNIT_FIELD_EMOTE_STATE, EMOTE_ONESHOT_NONE);
  2181.                             eventTimer = 3000;
  2182.                             ++eventProgress;
  2183.                             break;
  2184.                         case 4:
  2185.                             eventTimer = 0;
  2186.                             if (Player* owner = ObjectAccessor::FindPlayer(playerGuid))
  2187.                             {
  2188.                                 owner->KilledMonsterCredit(CREDIT_2);  //hack it already done in credit spell, but for cust it need already finished quest.
  2189.                                 owner->CastSpell(owner, SPELL_CREDIT_NOT_IN_FACE, false);
  2190.                                 me->GetMotionMaster()->MoveTargetedHome();
  2191.                                 //me->DespawnOrUnsummon(100);
  2192.                             }
  2193.                             break;
  2194.                         default:
  2195.                             break;
  2196.                     }
  2197.                 }
  2198.                 else
  2199.                     eventTimer -= diff;
  2200.             }
  2201.         }
  2202.     };
  2203.  
  2204.     CreatureAI* GetAI(Creature* creature) const
  2205.     {
  2206.         return new npc_water_spirit_dailoAI(creature);
  2207.     }
  2208. };
  2209.  
  2210. class AreaTrigger_at_middle_temple_from_east : public AreaTriggerScript
  2211. {
  2212.     public:
  2213.         AreaTrigger_at_middle_temple_from_east() : AreaTriggerScript("AreaTrigger_at_middle_temple_from_east")
  2214.         {}
  2215.  
  2216.         bool OnTrigger(Player* player, AreaTriggerEntry const* trigger, bool enter)
  2217.         {
  2218.             player->RemoveAllMinionsByFilter(60916);
  2219.             player->RemoveAllMinionsByFilter(55558);
  2220.             return true;
  2221.         }
  2222. };
  2223.  
  2224. /*
  2225. ========================================
  2226. ========= W E S T  P A R T =============
  2227. ========================================
  2228. */
  2229.  
  2230. class mob_master_shang_xi_temple : public CreatureScript
  2231. {
  2232.     public:
  2233.         mob_master_shang_xi_temple() : CreatureScript("mob_master_shang_xi_temple") { }
  2234.  
  2235.     CreatureAI* GetAI(Creature* creature) const
  2236.     {
  2237.         return new mob_master_shang_xi_templeAI(creature);
  2238.     }
  2239.  
  2240.     struct mob_master_shang_xi_templeAI : public ScriptedAI
  2241.     {
  2242.         mob_master_shang_xi_templeAI(Creature* creature) : ScriptedAI(creature)
  2243.         {}
  2244.  
  2245.         ObjectGuid playerGuid;
  2246.         GuidSet m_player_for_event;
  2247.         EventMap events;
  2248.  
  2249.         enum events
  2250.         {
  2251.             EVENT_XO1    = 1,
  2252.             EVENT_CLEAN  = 2,
  2253.         };
  2254.  
  2255.         void MoveInLineOfSight(Unit* who)
  2256.         {
  2257.             if (who->GetTypeId() != TYPEID_PLAYER)
  2258.                 return;
  2259.  
  2260.             GuidSet::iterator itr = m_player_for_event.find(who->GetGUID());
  2261.             if (itr != m_player_for_event.end())
  2262.                 return;
  2263.  
  2264.             if (who->ToPlayer()->GetQuestStatus(QUEST_PASSION_OF_SHEN) == QUEST_STATUS_COMPLETE)
  2265.                 events.RescheduleEvent(EVENT_XO1, 1000);
  2266.  
  2267.             events.RescheduleEvent(EVENT_CLEAN, 60000);
  2268.             m_player_for_event.insert(who->GetGUID());
  2269.         }
  2270.  
  2271.         void Reset()
  2272.         {
  2273.             playerGuid.Clear();
  2274.         }
  2275.  
  2276.         void UpdateAI(uint32 diff)
  2277.         {
  2278.             events.Update(diff);
  2279.  
  2280.             if (uint32 eventId = events.ExecuteEvent())
  2281.             {
  2282.                 switch (eventId)
  2283.                 {
  2284.                     case EVENT_CLEAN:
  2285.                         events.Reset();
  2286.                         break;
  2287.                     case EVENT_XO1:
  2288.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  2289.                         break;
  2290.                 }
  2291.             }
  2292.         }
  2293.     };
  2294.  
  2295.     bool OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 /*opt*/)
  2296.     {
  2297.         switch(quest->GetQuestId())
  2298.         {
  2299.             case QUEST_SPIRIT_AND_BODY:
  2300.                 sCreatureTextMgr->SendChat(creature, TEXT_GENERIC_7);
  2301.                 player->RemoveAurasDueToSpell(SPELL_CREDIT_NOT_IN_FACE);
  2302.                 player->RemoveAllMinionsByFilter(118036, 1);
  2303.                 player->RemoveAllMinionsByFilter(SPELL_CREDIT_NOT_IN_FACE, 1);
  2304.                 break;
  2305.         }
  2306.         return true;
  2307.     }
  2308.  
  2309.     bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
  2310.     {
  2311.         switch(quest->GetQuestId())
  2312.         {
  2313.             case QUEST_SINGING_POOLS:
  2314.                 sCreatureTextMgr->SendChat(creature, TEXT_GENERIC_1);
  2315.                 break;
  2316.             case QUEST_MORNING_BREEZE_BILLAGE:
  2317.             {
  2318.                 if (quest->GetQuestId() == QUEST_MORNING_BREEZE_BILLAGE) // Brise du matin
  2319.                 {
  2320.                     player->CastSpell(player, SPELL_SUMMON_WIND_TELEPORTER, true);
  2321.                 }
  2322.                 break;
  2323.             }
  2324.         }
  2325.         return true;
  2326.     }
  2327.  
  2328.     bool OnGossipSelect(Player* player, Creature* /*creature*/, uint32 /*sender*/, uint32 action)
  2329.     {
  2330.         if (action == 1)
  2331.         {
  2332.             player->CastSpell(player, SPELL_SUMMON_WIND_TELEPORTER, true);
  2333.             //player->NearTeleportTo(926.58f, 3605.33f, 251.63f, 3.114f);
  2334.         }
  2335.  
  2336.         player->PlayerTalkClass->SendCloseGossip();
  2337.         return true;
  2338.     }
  2339. };
  2340.  
  2341. class npc_wind_vehicle : public CreatureScript
  2342. {
  2343. public:
  2344.     npc_wind_vehicle() : CreatureScript("npc_wind_vehicle") { }
  2345.  
  2346.     struct npc_wind_vehicleAI : public npc_escortAI
  2347.     {        
  2348.         npc_wind_vehicleAI(Creature* creature) : npc_escortAI(creature)
  2349.         {}
  2350.  
  2351.         void Reset()
  2352.         {
  2353.         }
  2354.        
  2355.         void OnCharmed(bool /*apply*/)
  2356.         {
  2357.         }
  2358.  
  2359.         void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply)
  2360.         {
  2361.             if (apply)
  2362.                 Start(false, true);
  2363.  
  2364.             //if (!apply || who->GetTypeId() != TYPEID_PLAYER)
  2365.             //    return;
  2366.  
  2367.             // PlayerOn = true;
  2368.             // Start(false, true, who->GetGUID());
  2369.         }
  2370.  
  2371.         void WaypointReached(uint32 waypointId)
  2372.         {
  2373.             if (waypointId == 16)
  2374.             {
  2375.                 if (me->GetVehicleKit())
  2376.                     me->GetVehicleKit()->RemoveAllPassengers();
  2377.  
  2378.                 me->DespawnOrUnsummon();
  2379.             }
  2380.         }
  2381.  
  2382.         void UpdateAI(uint32 diff)
  2383.         {
  2384.             npc_escortAI::UpdateAI(diff);
  2385.         }
  2386.     };
  2387.    
  2388.     CreatureAI* GetAI(Creature* creature) const
  2389.     {
  2390.         return new npc_wind_vehicleAI(creature);
  2391.     }
  2392. };
  2393.  
  2394. class npc_panda_history_leason : public CreatureScript
  2395. {
  2396.     public:
  2397.         npc_panda_history_leason() : CreatureScript("npc_panda_history_leason") { }
  2398.  
  2399.     CreatureAI* GetAI(Creature* creature) const
  2400.     {
  2401.         return new npc_panda_history_leasonAI(creature);
  2402.     }
  2403.    
  2404.     struct npc_panda_history_leasonAI : public ScriptedAI
  2405.     {
  2406.         npc_panda_history_leasonAI(Creature* creature) : ScriptedAI(creature)
  2407.         {
  2408.  
  2409.         }
  2410.  
  2411.         void Reset()
  2412.         {
  2413.             text = TEXT_GENERIC_0;
  2414.             events.RescheduleEvent(EVENT_1, 10000);
  2415.         }
  2416.  
  2417.         enum datalocal
  2418.         {
  2419.             EVENT_1            = 1,
  2420.             MAX_TEXT           = 15,
  2421.  
  2422.         };
  2423.  
  2424.         uint32 text;
  2425.         EventMap events;
  2426.  
  2427.         void UpdateAI(uint32 diff)
  2428.         {
  2429.             events.Update(diff);
  2430.  
  2431.             if (uint32 eventId = events.ExecuteEvent())
  2432.             {
  2433.                 events.RescheduleEvent(EVENT_1, 10000);
  2434.                 sCreatureTextMgr->SendChat(me, text);
  2435.                 ++text;
  2436.                 if (text >= MAX_TEXT)
  2437.                     text = TEXT_GENERIC_0;
  2438.             }
  2439.         }
  2440.     };
  2441. };
  2442.  
  2443. class mob_jojo_ironbrow_3 : public CreatureScript
  2444. {
  2445. public:
  2446.     mob_jojo_ironbrow_3() : CreatureScript("mob_jojo_ironbrow_3") {}
  2447.  
  2448.     CreatureAI* GetAI(Creature* creature) const
  2449.     {
  2450.         return new mob_jojo_ironbrow_3_AI (creature);
  2451.     }
  2452.  
  2453.     struct mob_jojo_ironbrow_3_AI : public ScriptedAI
  2454.     {
  2455.         mob_jojo_ironbrow_3_AI(Creature* creature) : ScriptedAI(creature) {}
  2456.  
  2457.         enum eEvents
  2458.         {
  2459.             EVENT_1    = 1,
  2460.             EVENT_2    = 2,
  2461.             EVENT_3    = 3,
  2462.             EVENT_4    = 4,
  2463.         };
  2464.  
  2465.         enum eSpell
  2466.         {
  2467.             NPC_TARGET          = 57668,
  2468.             SUPER_DUPER_KULAK   = 129294,
  2469.         };
  2470.  
  2471.         EventMap events;
  2472.  
  2473.         void Reset()
  2474.         {
  2475.             events.RescheduleEvent(EVENT_1, 1000);
  2476.             me->SetWalk(true);
  2477.         }
  2478.  
  2479.         void MovementInform(uint32 moveType, uint32 pointId)
  2480.         {
  2481.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  2482.         }
  2483.  
  2484.         void UpdateAI(uint32 diff)
  2485.         {
  2486.             events.Update(diff);
  2487.  
  2488.             if (uint32 eventId = events.ExecuteEvent())
  2489.             {
  2490.                 switch (eventId)
  2491.                 {
  2492.                     // emotes only when in vehicle.
  2493.                     case EVENT_1:
  2494.                         me->GetMotionMaster()->MovePoint(EVENT_1, 1077.31f, 4179.94f, 205.7737f);
  2495.                         events.RescheduleEvent(EVENT_2, 10000);
  2496.                         break;
  2497.                     case EVENT_2:
  2498.                         if (Creature* target = me->FindNearestCreature(NPC_TARGET, 50.0f, true))
  2499.                             me->CastSpell(target, SUPER_DUPER_KULAK, true);
  2500.                         events.RescheduleEvent(EVENT_3, 3000);
  2501.                         break;
  2502.                     case EVENT_3:
  2503.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1);
  2504.                         events.RescheduleEvent(EVENT_4, 10000);
  2505.                         break;
  2506.                     case EVENT_4:
  2507.                         me->DespawnOrUnsummon(10000);
  2508.                         break;
  2509.                     default:
  2510.                         break;
  2511.                 }
  2512.             }
  2513.         }
  2514.     };
  2515. };
  2516.  
  2517. class mob_huojin_monk : public CreatureScript
  2518. {
  2519. public:
  2520.     mob_huojin_monk() : CreatureScript("mob_huojin_monk") {}
  2521.  
  2522.     CreatureAI* GetAI(Creature* creature) const
  2523.     {
  2524.         return new mob_huojin_monk_AI (creature);
  2525.     }
  2526.  
  2527.     bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
  2528.     {
  2529.         if (quest->GetQuestId() == QUEST_BALANCED_PERSPECTIVE)
  2530.         {
  2531.             sCreatureTextMgr->SendChat(creature, TEXT_GENERIC_2);
  2532.             creature->GetMotionMaster()->MovePoint(1, 1149.78f, 4550.93f, 223.17f);
  2533.             creature->DespawnOrUnsummon(10000);
  2534.         }
  2535.         return true;
  2536.     }
  2537.  
  2538.     struct mob_huojin_monk_AI : public ScriptedAI
  2539.     {
  2540.         mob_huojin_monk_AI(Creature* creature) : ScriptedAI(creature) {}
  2541.        
  2542.         enum eEvents
  2543.         {
  2544.             EVENT_KICK              = 1,
  2545.             EVENT_FIST_FURY         = 2,
  2546.             EVENT_JAP               = 3,
  2547.             EVENT_SPINING_KICK      = 4,
  2548.             EVENT_CHECK_ZONE        = 5,
  2549.         };
  2550.  
  2551.         enum eSpell
  2552.         {
  2553.             SPELL_ROLL          = 117312,
  2554.             SPELL_KICK          = 128631,
  2555.             SPELL_FIST_FURY     = 128635,
  2556.             SPELL_JAP           = 128630,
  2557.             SPELL_SPINING_KICK  = 128632,
  2558.             SPELL_SUM_HILING_SP = 128643, // use 128641
  2559.             AREA                = 5831,
  2560.         };
  2561.  
  2562.         EventMap events;
  2563.  
  2564.         void Reset()
  2565.         {
  2566.             events.Reset();
  2567.             events.RescheduleEvent(EVENT_KICK, 5000);
  2568.             events.RescheduleEvent(EVENT_FIST_FURY, 7000);
  2569.             events.RescheduleEvent(EVENT_JAP, 12000);
  2570.             events.RescheduleEvent(EVENT_SPINING_KICK, 15000);
  2571.         }
  2572.  
  2573.         void OnCharmed(bool /*apply*/)
  2574.         {
  2575.         }
  2576.  
  2577.         void KilledUnit(Unit* /*victim*/)
  2578.         {
  2579.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1);
  2580.         }
  2581.  
  2582.         void IsSummonedBy(Unit* summoner)
  2583.         {
  2584.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  2585.             me->AddPlayerInPersonnalVisibilityList(summoner->GetGUID());
  2586.         }
  2587.  
  2588.         void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType dmgType)
  2589.         {
  2590.             damage = 1;
  2591.         }
  2592.  
  2593.         void EnterCombat(Unit* victim)
  2594.         {
  2595.             if (me->GetDistance(victim) > 10)
  2596.                 me->CastSpell(victim, SPELL_ROLL, true);
  2597.         }
  2598.  
  2599.         void UpdateAI(uint32 diff)
  2600.         {
  2601.             if (!UpdateVictim())
  2602.                 return;
  2603.  
  2604.             if (me->HasUnitState(UNIT_STATE_CASTING))
  2605.                 return;
  2606.  
  2607.             events.Update(diff);
  2608.  
  2609.             if (uint32 eventId = events.ExecuteEvent())
  2610.             {
  2611.                 switch (eventId)
  2612.                 {
  2613.                     // emotes only when in vehicle.
  2614.                     case EVENT_KICK:
  2615.                         me->CastSpell(me->getVictim(), SPELL_KICK, true);
  2616.                         events.RescheduleEvent(EVENT_KICK, 5000);
  2617.                         break;
  2618.                     case EVENT_FIST_FURY:
  2619.                         me->CastSpell(me->getVictim(), SPELL_FIST_FURY, true);
  2620.                         events.RescheduleEvent(EVENT_FIST_FURY, 5000);
  2621.                         break;
  2622.                     case EVENT_JAP:
  2623.                         me->CastSpell(me->getVictim(), SPELL_JAP, true);
  2624.                         events.RescheduleEvent(EVENT_JAP, 5000);
  2625.                         break;
  2626.                     case EVENT_SPINING_KICK:
  2627.                         me->CastSpell(me->getVictim(), SPELL_SPINING_KICK, true);
  2628.                         events.RescheduleEvent(EVENT_SPINING_KICK, 16000);
  2629.                         break;
  2630.                     default:
  2631.                         break;
  2632.                 }
  2633.             }
  2634.             DoMeleeAttackIfReady();
  2635.         }
  2636.     };
  2637. };
  2638. // Summon Ji Yuan 105306
  2639. class spell_summon_ji_yung: public SpellScriptLoader
  2640. {
  2641.     public:
  2642.         spell_summon_ji_yung() : SpellScriptLoader("spell_summon_ji_yung") { }
  2643.  
  2644.         class spell_summon_ji_yung_AuraScript : public AuraScript
  2645.         {
  2646.             PrepareAuraScript(spell_summon_ji_yung_AuraScript);
  2647.            
  2648.             void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
  2649.             {
  2650.                 Unit* target = GetTarget();
  2651.  
  2652.                 if (!target)
  2653.                     return;
  2654.  
  2655.                 target->RemoveAllMinionsByFilter(65558);
  2656.             }
  2657.  
  2658.             void Register()
  2659.             {
  2660.                 OnEffectRemove += AuraEffectRemoveFn(spell_summon_ji_yung_AuraScript::OnRemove, EFFECT_3, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
  2661.             }
  2662.         };
  2663.  
  2664.         AuraScript* GetAuraScript() const
  2665.         {
  2666.             return new spell_summon_ji_yung_AuraScript();
  2667.         }
  2668. };
  2669.  
  2670. class mob_jojo_ironbrow_4 : public CreatureScript
  2671. {
  2672. public:
  2673.     mob_jojo_ironbrow_4() : CreatureScript("mob_jojo_ironbrow_4") {}
  2674.  
  2675.     CreatureAI* GetAI(Creature* creature) const
  2676.     {
  2677.         return new mob_jojo_ironbrow_4_AI (creature);
  2678.     }
  2679.  
  2680.     struct mob_jojo_ironbrow_4_AI : public ScriptedAI
  2681.     {
  2682.         mob_jojo_ironbrow_4_AI(Creature* creature) : ScriptedAI(creature) {}
  2683.  
  2684.         enum eEvents
  2685.         {
  2686.             EVENT_1    = 1,
  2687.             EVENT_2    = 2,
  2688.             EVENT_3    = 3,
  2689.             EVENT_4    = 4,
  2690.             EVENT_5    = 5,
  2691.         };
  2692.  
  2693.         enum eSpell
  2694.         {
  2695.             SUPER_DUPER_KULAK   = 129297,
  2696.         };
  2697.  
  2698.         EventMap events;
  2699.  
  2700.         void Reset()
  2701.         {
  2702.             events.RescheduleEvent(EVENT_1, 1000);
  2703.             me->SetWalk(true);
  2704.         }
  2705.  
  2706.         void MovementInform(uint32 moveType, uint32 pointId)
  2707.         {
  2708.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  2709.         }
  2710.  
  2711.         void UpdateAI(uint32 diff)
  2712.         {
  2713.             events.Update(diff);
  2714.  
  2715.             if (uint32 eventId = events.ExecuteEvent())
  2716.             {
  2717.                 switch (eventId)
  2718.                 {
  2719.                     // emotes only when in vehicle.
  2720.                     case EVENT_1:
  2721.                         me->GetMotionMaster()->MovePoint(EVENT_1, 1077.31f, 4179.94f, 205.7737f);
  2722.                         events.RescheduleEvent(EVENT_2, 5000);
  2723.                         break;
  2724.                     case EVENT_2:
  2725.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1);
  2726.                         events.RescheduleEvent(EVENT_3, 10000);
  2727.                         break;
  2728.                     case EVENT_3:
  2729.                         me->CastSpell(me, SUPER_DUPER_KULAK, true);
  2730.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2);
  2731.                         me->PlayOneShotAnimKit(1078);
  2732.                         events.RescheduleEvent(EVENT_4, 6000);
  2733.                         break;
  2734.                     case EVENT_4:
  2735.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_3);
  2736.                         me->SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_SLEEP);
  2737.                         me->PlayOneShotAnimKit(0);
  2738.                         events.RescheduleEvent(EVENT_5, 15000);
  2739.                         break;
  2740.                     case EVENT_5:
  2741.                         me->DespawnOrUnsummon(30000);
  2742.                         break;
  2743.                     default:
  2744.                         break;
  2745.                 }
  2746.             }
  2747.         }
  2748.     };
  2749. };
  2750.  
  2751. class AreaTrigger_at_wind_temple_entrance : public AreaTriggerScript
  2752. {
  2753.     public:
  2754.         AreaTrigger_at_wind_temple_entrance() : AreaTriggerScript("AreaTrigger_at_wind_temple_entrance")
  2755.         {}
  2756.  
  2757.         enum spell
  2758.         {
  2759.             SUMMON_SPELL    = 104571,
  2760.         };
  2761.  
  2762.         bool OnTrigger(Player* player, AreaTriggerEntry const* trigger, bool enter)
  2763.         {
  2764.             if (player->GetQuestStatus(QUST_DAFENG_SPIRIT_OF_AIR) == QUEST_STATUS_INCOMPLETE && !player->HasAura(SUMMON_SPELL))
  2765.             {
  2766.                 player->CastSpell(player, SUMMON_SPELL, true);
  2767.                 //if (Creature* aysa = player->SummonCreature(55744, 665.60f, 4220.66f, 201.93f, 1.93f, TEMPSUMMON_MANUAL_DESPAWN, 0, player->GetGUID()))
  2768.                 //    aysa->AI()->SetGUID(player->GetGUID());
  2769.             }
  2770.  
  2771.             return true;
  2772.         }
  2773. };
  2774.  
  2775. class mob_aysa_wind_temple_escort : public CreatureScript
  2776. {
  2777.     public:
  2778.         mob_aysa_wind_temple_escort() : CreatureScript("mob_aysa_wind_temple_escort") { }
  2779.  
  2780.     struct mob_aysa_wind_temple_escortAI : public npc_escortAI
  2781.     {        
  2782.         mob_aysa_wind_temple_escortAI(Creature* creature) : npc_escortAI(creature)
  2783.         {}
  2784.        
  2785.         ObjectGuid playerGuid;
  2786.         EventMap events;
  2787.  
  2788.         enum events
  2789.         {
  2790.             EVENT_1                 = 1,
  2791.             EVENT_2                 = 2,
  2792.             EVENT_JECK_DEAD         = 3,
  2793.         };
  2794.  
  2795.         void Reset()
  2796.         {
  2797.             me->SetReactState(REACT_PASSIVE);
  2798.         }
  2799.  
  2800.         void SetGUID(ObjectGuid const& guid, int32)
  2801.         {
  2802.             playerGuid = guid;
  2803.         }
  2804.  
  2805.         void IsSummonedBy(Unit* summoner)
  2806.         {
  2807.             me->AddPlayerInPersonnalVisibilityList(summoner->GetGUID());
  2808.             playerGuid = summoner->GetGUID();
  2809.             events.RescheduleEvent(EVENT_1, 1000);
  2810.         }
  2811.  
  2812.         void DoAction(int32 const /*param*/)
  2813.         {
  2814.             SetEscortPaused(false);
  2815.         }
  2816.  
  2817.         void WaypointReached(uint32 waypointId)
  2818.         {
  2819.             switch (waypointId)
  2820.             {
  2821.                 case 2:
  2822.                     sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1, playerGuid);
  2823.                     SetEscortPaused(true);
  2824.                     me->SetFacingTo(2.38f);
  2825.                     break;
  2826.                 case 7:
  2827.                     sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2, playerGuid);
  2828.                     SetEscortPaused(true);
  2829.                     // cast 104612 on owner
  2830.                     break;
  2831.                 case 11:
  2832.                     //if (Player* player = ObjectAccessor::GetPlayer(*me, playerGuid))
  2833.                     //    player->KilledMonsterCredit(55666);
  2834.                     me->DespawnOrUnsummon(5000);
  2835.                     break;
  2836.                 default:
  2837.                     break;
  2838.             }
  2839.         }
  2840.  
  2841.         void UpdateAI(uint32 diff)
  2842.         {
  2843.             npc_escortAI::UpdateAI(diff);
  2844.             events.Update(diff);
  2845.  
  2846.             if (uint32 eventId = events.ExecuteEvent())
  2847.             {
  2848.                 switch (eventId)
  2849.                 {
  2850.                     case EVENT_1:
  2851.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, playerGuid);
  2852.                         events.RescheduleEvent(EVENT_2, 5000);
  2853.                         break;
  2854.                     case EVENT_2:
  2855.                         Start(false, true);
  2856.                         break;
  2857.                 }
  2858.             }
  2859.         }
  2860.     };
  2861.    
  2862.     CreatureAI* GetAI(Creature* creature) const
  2863.     {
  2864.         return new mob_aysa_wind_temple_escortAI(creature);
  2865.     }
  2866. };
  2867.  
  2868. class mob_frightened_wind : public CreatureScript
  2869. {
  2870. public:
  2871.     mob_frightened_wind() : CreatureScript("mob_frightened_wind") { }
  2872.  
  2873.     CreatureAI* GetAI(Creature* creature) const
  2874.     {
  2875.         return new mob_frightened_windAI(creature);
  2876.     }
  2877.  
  2878.     struct mob_frightened_windAI : public ScriptedAI
  2879.     {
  2880.         mob_frightened_windAI(Creature* creature) : ScriptedAI(creature)
  2881.         {}
  2882.  
  2883.         uint32 tornadeTimer;
  2884.         ObjectGuid goWinder;
  2885.         enum Spells
  2886.         {
  2887.             SPELL_TORNADE    = 104333,
  2888.             SPELL_OFFTIME    = 105678,
  2889.             GO_WIND          = 209685,
  2890.         };
  2891.  
  2892.         void Reset()
  2893.         {
  2894.             me->SetReactState(REACT_PASSIVE);
  2895.             tornadeTimer = 8 * IN_MILLISECONDS;
  2896.             if (GameObject* wind =  me->FindNearestGameObject(GO_WIND, 15.0f))
  2897.                 goWinder = wind->GetGUID();
  2898.         }
  2899.  
  2900.         void UpdateAI(uint32 diff)
  2901.         {
  2902.             if (tornadeTimer <= diff)
  2903.             {
  2904.                 me->ToggleAura(SPELL_TORNADE, me);
  2905.  
  2906.                 bool enable = false;
  2907.                 if (!me->HasAura(SPELL_TORNADE))
  2908.                 {
  2909.                     me->RemoveAurasDueToSpell(SPELL_OFFTIME);
  2910.                     enable = true;
  2911.                 }else
  2912.                 {
  2913.                     me->CastSpell(me, SPELL_OFFTIME, true);
  2914.                     if (Creature* aysa = me->FindNearestCreature(55744, 200.0f, true))
  2915.                         aysa->AI()->DoAction(1);
  2916.                 }
  2917.  
  2918.                 if (GameObject* g = me->GetMap()->GetGameObject(goWinder))
  2919.                 {
  2920.                     //g->SetGoState(enable ? GO_STATE_ACTIVE : GO_STATE_READY);
  2921.                     g->EnableOrDisableGo(!enable);
  2922.                 }
  2923.                 tornadeTimer = 8 * IN_MILLISECONDS;
  2924.             }
  2925.             else
  2926.                 tornadeTimer -= diff;
  2927.         }
  2928.     };
  2929. };
  2930.  
  2931. enum Enums
  2932. {
  2933.     NPC_ROCKET_LAUNCHER = 64507,
  2934.     NPC_AISA_SHAO       = 64506,
  2935.     SPELL_ROCKET_LAUNCH = 104855,
  2936.            
  2937.     EVENT_NEXT_MOVEMENT = 1,
  2938.     EVENT_STUNNED       = 2,
  2939.     EVENT_LIGHTNING     = 3,
  2940.  
  2941.     SPELL_SERPENT_SWEEP = 125990,
  2942.     SPELL_STUNNED       = 125992,
  2943.     SPELL_LIGHTNING     = 126006,
  2944. };
  2945.  
  2946. Position ZhaoPos[] =
  2947. {
  2948.     {719.36f, 4164.60f, 216.06f}, // Center
  2949.     {745.91f, 4154.35f, 223.48f},
  2950.     {717.04f, 4141.16f, 219.83f},
  2951.     {689.62f, 4153.16f, 217.63f},
  2952.     {684.53f, 4173.24f, 216.98f},
  2953.     {704.77f, 4190.16f, 218.24f},
  2954.     {736.90f, 4183.85f, 221.41f}
  2955. };
  2956.  
  2957. class boss_zhao_ren : public CreatureScript
  2958. {
  2959. public:
  2960.     boss_zhao_ren() : CreatureScript("boss_zhao_ren") { }
  2961.  
  2962.     CreatureAI* GetAI(Creature* creature) const
  2963.     {
  2964.         return new boss_zhao_renAI(creature);
  2965.     }
  2966.  
  2967.     struct boss_zhao_renAI : public ScriptedAI
  2968.     {
  2969.         boss_zhao_renAI(Creature* creature) : ScriptedAI(creature)
  2970.         {}
  2971.  
  2972.         EventMap _events;
  2973.         bool eventStarted;
  2974.         bool falling;
  2975.         uint8 hitCount;
  2976.         uint8 currentPos;
  2977.  
  2978.         void Reset()
  2979.         {
  2980.             _events.Reset();
  2981.             me->SetReactState(REACT_PASSIVE);
  2982.  
  2983.             falling = false;
  2984.             eventStarted = false;
  2985.             hitCount = 0;
  2986.             currentPos = 0;
  2987.  
  2988.             me->SetFullHealth();
  2989.             me->RemoveAurasDueToSpell(SPELL_STUNNED);
  2990.  
  2991.             me->GetMotionMaster()->Clear();
  2992.             me->GetMotionMaster()->MovePoint(0, ZhaoPos[0].GetPositionX(), ZhaoPos[0].GetPositionY(), ZhaoPos[0].GetPositionZ());
  2993.         }
  2994.  
  2995.         void SpellHit(Unit* caster, const SpellInfo* spell)
  2996.         {
  2997.             if (spell->Id == SPELL_ROCKET_LAUNCH)
  2998.             {
  2999.                 if (++hitCount >= 5)
  3000.                 {
  3001.                     falling = true;
  3002.                     me->GetMotionMaster()->Clear();
  3003.                     me->GetMotionMaster()->MoveFall();
  3004.                     _events.RescheduleEvent(EVENT_STUNNED, 12000);
  3005.                     hitCount = 0;
  3006.                 }else if (hitCount == 1)
  3007.                 {
  3008.                     if (Creature* aysa = me->FindNearestCreature(NPC_AISA_SHAO, 100.0f, true))
  3009.                         sCreatureTextMgr->SendChat(aysa, TEXT_GENERIC_0);
  3010.                 }
  3011.             }
  3012.         }
  3013.        
  3014.         bool checkPlayers()
  3015.         {
  3016.             std::list<Player*> playerList;
  3017.             GetPlayerListInGrid(playerList, me, 80.0f);
  3018.  
  3019.             for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
  3020.             {
  3021.                 Player* player = *itr;
  3022.                 if (player->GetQuestStatus(QIEST_BATTLE_FOR_SKIES) == QUEST_STATUS_INCOMPLETE)
  3023.                     if (player->isAlive())
  3024.                         return true;
  3025.             }
  3026.  
  3027.             return false;
  3028.         }
  3029.  
  3030.         void GoToNextPos()
  3031.         {
  3032.             if (++currentPos > 6)
  3033.                 currentPos = 1;
  3034.  
  3035.             me->GetMotionMaster()->MovePoint(currentPos, ZhaoPos[currentPos].GetPositionX(), ZhaoPos[currentPos].GetPositionY(), ZhaoPos[currentPos].GetPositionZ());
  3036.         }
  3037.  
  3038.         Player* GetRandomPlayer()
  3039.         {
  3040.             std::list<Player*> playerList;
  3041.             GetPlayerListInGrid(playerList, me, 50.0f);
  3042.  
  3043.             if (playerList.empty())
  3044.                 return NULL;
  3045.  
  3046.             Trinity::Containers::RandomResizeList(playerList, 1);
  3047.  
  3048.             return *playerList.begin();
  3049.         }
  3050.  
  3051.         void MovementInform(uint32 type, uint32 id)
  3052.         {
  3053.             if (falling)
  3054.             {
  3055.                 me->CastSpell(me, SPELL_STUNNED, true);
  3056.                 falling = false;
  3057.                 if (Creature* aysa = me->FindNearestCreature(NPC_AISA_SHAO, 100.0f, true))
  3058.                 {
  3059.                     sCreatureTextMgr->SendChat(aysa, TEXT_GENERIC_1);
  3060.                     aysa->AI()->AttackStart(me);
  3061.                 }
  3062.             }
  3063.  
  3064.             if (type != POINT_MOTION_TYPE)
  3065.                 return;
  3066.  
  3067.             if (!id)
  3068.                 return;
  3069.  
  3070.             _events.RescheduleEvent(EVENT_NEXT_MOVEMENT, 200);
  3071.         }
  3072.  
  3073.         void JustDied(Unit* attacker)
  3074.         {
  3075.             std::list<Player*> playerList;
  3076.             GetPlayerListInGrid(playerList, me, 50.0f);
  3077.  
  3078.             for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
  3079.             {
  3080.                 Player* player = *itr;
  3081.                 if (player->GetQuestStatus(QIEST_BATTLE_FOR_SKIES) == QUEST_STATUS_INCOMPLETE)
  3082.                     if (player->isAlive())
  3083.                         player->KilledMonsterCredit(me->GetEntry());
  3084.             }
  3085.         }
  3086.  
  3087.         void UpdateAI(uint32 diff)
  3088.         {
  3089.             if (checkPlayers())
  3090.             {
  3091.                 if (!eventStarted)  // Event not started, player found
  3092.                 {
  3093.                     _events.RescheduleEvent(EVENT_NEXT_MOVEMENT, 1000);
  3094.                     _events.RescheduleEvent(EVENT_LIGHTNING, 5000);
  3095.                     eventStarted = true;
  3096.                 }
  3097.             }
  3098.             else
  3099.             {
  3100.                 if (eventStarted)  // Event started, no player found
  3101.                     Reset();
  3102.  
  3103.                 return;
  3104.             }
  3105.  
  3106.             _events.Update(diff);
  3107.  
  3108.             switch (_events.ExecuteEvent())
  3109.             {
  3110.                 case EVENT_NEXT_MOVEMENT:
  3111.                 {
  3112.                     if (me->HasAura(SPELL_STUNNED))
  3113.                         _events.RescheduleEvent(EVENT_NEXT_MOVEMENT, 2000);
  3114.  
  3115.                     GoToNextPos();
  3116.                     break;
  3117.                 }
  3118.                 case EVENT_STUNNED:
  3119.                 {
  3120.                     me->RemoveAurasDueToSpell(SPELL_STUNNED);
  3121.                     me->CastSpell(me, SPELL_SERPENT_SWEEP, false);
  3122.                     _events.RescheduleEvent(EVENT_NEXT_MOVEMENT, 3000);
  3123.                     break;
  3124.                 }
  3125.                 case EVENT_LIGHTNING:
  3126.                 {
  3127.                     if (Player* player = GetRandomPlayer())
  3128.                         me->CastSpell(player, SPELL_LIGHTNING, false);
  3129.  
  3130.                     _events.RescheduleEvent(EVENT_LIGHTNING, 5000);
  3131.                     break;
  3132.                 }
  3133.             }
  3134.         }
  3135.     };
  3136. };
  3137.  
  3138. class npc_rocket_launcher : public CreatureScript
  3139. {
  3140. public:
  3141.     npc_rocket_launcher() : CreatureScript("npc_rocket_launcher") { }
  3142.  
  3143.     CreatureAI* GetAI(Creature* creature) const
  3144.     {
  3145.         return new npc_rocket_launcherAI (creature);
  3146.     }
  3147.  
  3148.     struct npc_rocket_launcherAI : public ScriptedAI
  3149.     {
  3150.         npc_rocket_launcherAI(Creature* creature) : ScriptedAI(creature) {}
  3151.  
  3152.         uint32 cooldown;
  3153.  
  3154.         void Reset()
  3155.         {
  3156.             cooldown = 0;
  3157.             me->SetFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  3158.         }
  3159.  
  3160.         void OnSpellClick(Unit* Clicker)
  3161.         {
  3162.             if (cooldown)
  3163.                 return;
  3164.             if (Creature* zhao = GetClosestCreatureWithEntry(me, 55786, 50.0f))
  3165.                 Clicker->CastSpell(zhao, SPELL_ROCKET_LAUNCH, false);
  3166.  
  3167.             cooldown = 5000;
  3168.             me->RemoveFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  3169.         }
  3170.  
  3171.         void EnterCombat(Unit* /*who*/)
  3172.         {
  3173.             return;
  3174.         }
  3175.  
  3176.         void UpdateAI(uint32 diff)
  3177.         {
  3178.             if (cooldown)
  3179.             {
  3180.                 if (cooldown <= diff)
  3181.                 {
  3182.                     me->SetFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  3183.                     cooldown = 0;
  3184.                 }
  3185.                 else
  3186.                     cooldown -= diff;
  3187.             }
  3188.         }
  3189.     };
  3190. };
  3191.  
  3192. class mob_master_shang_xi_after_zhao_escort : public CreatureScript
  3193. {
  3194.     public:
  3195.         mob_master_shang_xi_after_zhao_escort() : CreatureScript("mob_master_shang_xi_after_zhao_escort") { }
  3196.  
  3197.     struct mob_master_shang_xi_after_zhao_escortAI : public npc_escortAI
  3198.     {        
  3199.         mob_master_shang_xi_after_zhao_escortAI(Creature* creature) : npc_escortAI(creature)
  3200.         {}
  3201.        
  3202.         uint32 IntroTimer;
  3203.  
  3204.         ObjectGuid playerGuid;
  3205.  
  3206.         void Reset()
  3207.         {
  3208.             IntroTimer = 250;
  3209.             me->SetReactState(REACT_PASSIVE);
  3210.             me->SetWalk(false);
  3211.             //Start(false, true);
  3212.         }
  3213.  
  3214.         void IsSummonedBy(Unit* summoner)
  3215.         {
  3216.             me->AddPlayerInPersonnalVisibilityList(summoner->GetGUID());
  3217.             playerGuid = summoner->GetGUID();
  3218.             Start(false, true);
  3219.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  3220.         }
  3221.  
  3222.         void WaypointReached(uint32 waypointId)
  3223.         {
  3224.             switch (waypointId)
  3225.             {
  3226.                 case 7:
  3227.                     me->SetWalk(true);
  3228.                     sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1);
  3229.                     break;
  3230.                 case 8:
  3231.                     if (GameObject* gate =  me->FindNearestGameObject(209922, 200.0f))
  3232.                         gate->EnableOrDisableGo(false);
  3233.                     me->SummonCreature(56274, 845.89f, 4372.62f, 223.98f, 4.78f, TEMPSUMMON_CORPSE_DESPAWN, 0, playerGuid);
  3234.                     sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2);
  3235.                     break;
  3236.                 case 9:
  3237.                     sCreatureTextMgr->SendChat(me, TEXT_GENERIC_3);
  3238.                     break;
  3239.                 case 11:
  3240.                     me->SetFacingTo(0.0f);
  3241.                     SetEscortPaused(true);
  3242.                     break;
  3243.                 case 12:
  3244.                     me->SetFacingTo(4.537860f);
  3245.                     me->DespawnOrUnsummon(1000);
  3246.                     break;
  3247.                 default:
  3248.                     break;
  3249.             }
  3250.         }
  3251.  
  3252.         void SummonedCreatureDespawn(Creature* summon)
  3253.         {
  3254.             if (summon->GetEntry() == 56274)
  3255.             {
  3256.                 if (auto owner = me->GetAnyOwner())
  3257.                 {
  3258.                     if (auto plr = owner->ToPlayer())
  3259.                         plr->KilledMonsterCredit(56274);
  3260.                 }
  3261.                 sCreatureTextMgr->SendChat(me, TEXT_GENERIC_4);
  3262.                 if (GameObject* gate =  me->FindNearestGameObject(209922, 200.0f))
  3263.                     gate->EnableOrDisableGo(true);
  3264.                 me->SetWalk(false);
  3265.                 SetEscortPaused(false);
  3266.             }
  3267.         }
  3268.     };
  3269.    
  3270.     CreatureAI* GetAI(Creature* creature) const
  3271.     {
  3272.         return new mob_master_shang_xi_after_zhao_escortAI(creature);
  3273.     }
  3274. };
  3275.  
  3276. class mob_master_shang_xi_thousand_staff : public CreatureScript
  3277. {
  3278.     public:
  3279.         mob_master_shang_xi_thousand_staff() : CreatureScript("mob_master_shang_xi_thousand_staff") { }
  3280.  
  3281.     struct mob_master_shang_xi_thousand_staffAI : public ScriptedAI
  3282.     {        
  3283.         mob_master_shang_xi_thousand_staffAI(Creature* creature) : ScriptedAI(creature)
  3284.         {}
  3285.  
  3286.         EventMap _events;
  3287.         ObjectGuid playerGuid;
  3288.         enum events
  3289.         {
  3290.             EVENT_DESPAWN   = 1,
  3291.             EVENT_1         = 2,
  3292.             EVENT_2         = 3,
  3293.             EVENT_3         = 4,
  3294.             EVENT_4         = 5,
  3295.             EVENT_5         = 6,
  3296.         };
  3297.  
  3298.         void Reset()
  3299.         {
  3300.             me->SetReactState(REACT_PASSIVE);
  3301.             me->SetWalk(true);
  3302.             playerGuid.Clear();
  3303.         }
  3304.  
  3305.         void IsSummonedBy(Unit* summoner)
  3306.         {
  3307.             me->AddPlayerInPersonnalVisibilityList(summoner->GetGUID());
  3308.             playerGuid = summoner->GetGUID();
  3309.            
  3310.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  3311.             _events.RescheduleEvent(EVENT_1, 12000);
  3312.         }
  3313.  
  3314.          void MovementInform(uint32 moveType, uint32 waypointId)
  3315.         {
  3316.             switch (waypointId)
  3317.             {
  3318.                 case 2:
  3319.                     _events.RescheduleEvent(EVENT_3, 12000);
  3320.                     break;
  3321.                 default:
  3322.                     break;
  3323.             }
  3324.             if (Player* p = ObjectAccessor::GetPlayer(*me, playerGuid))
  3325.                 me->SetFacingToObject(p);
  3326.         }
  3327.  
  3328.         void UpdateAI(uint32 diff)
  3329.         {
  3330.             _events.Update(diff);
  3331.  
  3332.             while (uint32 eventId = _events.ExecuteEvent())
  3333.             {
  3334.                 switch(eventId)
  3335.                 {
  3336.                     case EVENT_1:
  3337.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1);
  3338.                         me->GetMotionMaster()->MovePoint(1, 871.0573f, 4460.548f, 241.4504f);
  3339.                         _events.RescheduleEvent(EVENT_2, 14000);
  3340.                         break;
  3341.                     case EVENT_2:
  3342.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2);
  3343.                         me->GetMotionMaster()->MovePoint(2, 868.007f, 4464.838f, 241.6647f);
  3344.                         break;
  3345.                     case EVENT_3:
  3346.                         me->GetMotionMaster()->MovePoint(3, 874.205f, 4464.75f, 241.3819f);
  3347.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_3);
  3348.                         _events.RescheduleEvent(EVENT_4, 15000);
  3349.                         break;
  3350.                     case EVENT_4:
  3351.                          me->RemoveAurasDueToSpell(126160);
  3352.                          me->CastSpell(me, 128850, true);       //summon stuff
  3353.                          sCreatureTextMgr->SendChat(me, TEXT_GENERIC_4);
  3354.                          _events.RescheduleEvent(EVENT_5, 15000);
  3355.                         break;
  3356.                     case EVENT_5:
  3357.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_5);
  3358.                         me->SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_KNEEL);
  3359.                         me->CastSpell(me, 128851, true);
  3360.                         me->CastSpell(me, 109336, true);
  3361.                         me->CastSpell(me, 106625, true);
  3362.                         _events.RescheduleEvent(EVENT_DESPAWN, 10000);
  3363.                         break;
  3364.                     case EVENT_DESPAWN:
  3365.                     {
  3366.                         me->DespawnOrUnsummon();
  3367.                         if (Player* owner = ObjectAccessor::GetPlayer(*me, playerGuid))
  3368.                         {
  3369.                             owner->CastSpell(owner, 106625, true);
  3370.                             //owner->KilledMonsterCredit(56688);
  3371.                         }
  3372.                         break;
  3373.                     }
  3374.                 }
  3375.             }
  3376.         }
  3377.     };
  3378.    
  3379.     CreatureAI* GetAI(Creature* creature) const
  3380.     {
  3381.         return new mob_master_shang_xi_thousand_staffAI(creature);
  3382.     }
  3383. };
  3384.  
  3385. class mob_aisa_pre_balon_event : public CreatureScript
  3386. {
  3387.     public:
  3388.         mob_aisa_pre_balon_event() : CreatureScript("mob_aisa_pre_balon_event") { }
  3389.  
  3390.     bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
  3391.     {
  3392.         if (quest->GetQuestId() == QUEST_SUF_SHUN_ZI)
  3393.             sCreatureTextMgr->SendChat(creature, TEXT_GENERIC_1, player->GetGUID());
  3394.  
  3395.         return true;
  3396.     }
  3397.  
  3398.     struct mob_aisa_pre_balon_eventAI : public ScriptedAI
  3399.     {        
  3400.         mob_aisa_pre_balon_eventAI(Creature* creature) : ScriptedAI(creature)
  3401.         {}
  3402.  
  3403.         bool justSpeaking;
  3404.         EventMap _events;
  3405.         GuidSet m_player_for_event;
  3406.  
  3407.         enum events
  3408.         {
  3409.             EVENT_1    = 1,
  3410.             EVENT_2    = 2,
  3411.             EVENT_3    = 3,
  3412.  
  3413.             NPC_FRIEND  = 56663,
  3414.         };
  3415.  
  3416.         void Reset()
  3417.         {
  3418.             justSpeaking = false;
  3419.         }
  3420.  
  3421.         void MoveInLineOfSight(Unit* who)
  3422.         {
  3423.             if (justSpeaking || who->GetTypeId() != TYPEID_PLAYER || who->IsOnVehicle())
  3424.                 return;
  3425.  
  3426.             GuidSet::iterator itr = m_player_for_event.find(who->GetGUID());
  3427.             if (itr != m_player_for_event.end())
  3428.                 return;
  3429.  
  3430.             if (who->ToPlayer()->GetQuestStatus(QUEST_PASSING_WISDOM) != QUEST_STATUS_COMPLETE)
  3431.                 return;
  3432.  
  3433.             m_player_for_event.insert(who->GetGUID());
  3434.             justSpeaking = true;
  3435.             _events.RescheduleEvent(EVENT_1, 10000);
  3436.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, who->GetGUID());
  3437.         }
  3438.  
  3439.         void UpdateAI(uint32 diff)
  3440.         {
  3441.             _events.Update(diff);
  3442.  
  3443.             while (uint32 eventId = _events.ExecuteEvent())
  3444.             {
  3445.                 switch(eventId)
  3446.                 {
  3447.                     case EVENT_1:
  3448.                     {
  3449.                         _events.RescheduleEvent(EVENT_2, 8000);
  3450.                         if (Creature* f = me->FindNearestCreature(NPC_FRIEND, 100.0f, true))
  3451.                         {
  3452.                             sCreatureTextMgr->SendChat(f, TEXT_GENERIC_0);
  3453.                             f->SetFacingToObject(me);
  3454.                         }
  3455.                         break;
  3456.                     }
  3457.                     case EVENT_2:
  3458.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2);
  3459.                         justSpeaking = false;
  3460.                         break;
  3461.                 }
  3462.             }
  3463.         }
  3464.     };
  3465.  
  3466.     CreatureAI* GetAI(Creature* creature) const
  3467.     {
  3468.         return new mob_aisa_pre_balon_eventAI(creature);
  3469.     }
  3470. };
  3471.  
  3472. class mop_air_balloon : public VehicleScript
  3473. {
  3474.     public:
  3475.         mop_air_balloon() : VehicleScript("mop_air_balloon") { }
  3476.  
  3477.     struct mop_air_balloonAI : public npc_escortAI
  3478.     {        
  3479.         mop_air_balloonAI(Creature* creature) : npc_escortAI(creature)
  3480.         {}
  3481.        
  3482.         ObjectGuid playerGuid;
  3483.         ObjectGuid aisaGUID;
  3484.         ObjectGuid firepawGUID;
  3485.         ObjectGuid shenZiGUID;
  3486.         ObjectGuid headGUID;
  3487.         EventMap events;
  3488.  
  3489.         void Reset()
  3490.         {
  3491.             me->SetWalk(false);
  3492.             //me->SetSpeed(MOVE_FLIGHT, 8.0f, false);
  3493.  
  3494.             playerGuid.Clear();
  3495.             aisaGUID.Clear();
  3496.             firepawGUID.Clear();
  3497.             shenZiGUID.Clear();
  3498.             headGUID.Clear();
  3499.             me->setActive(true);
  3500.             me->SetReactState(REACT_PASSIVE);
  3501.             me->m_invisibilityDetect.AddFlag(INVISIBILITY_UNK5);
  3502.             me->m_invisibilityDetect.AddValue(INVISIBILITY_UNK5, 999);
  3503.         }
  3504.  
  3505.         enum localdata
  3506.         {
  3507.             NPC_AISA                          = 56661,
  3508.             NPC_FIREPAW                       = 56660,
  3509.             NPC_SHEN_ZI_SU                    = 56676,
  3510.             NPC_TURTLE_HEAD                   = 57769,
  3511.  
  3512.             SPELL_HEAD_ANIM_RISE              = 114888,
  3513.             SPELL_HEAD_ANIM_1                 = 114898,
  3514.             SPELL_HEAD_ANIM_2                 = 118571,
  3515.             SPELL_HEAD_ANIM_3                 = 118572,
  3516.             SPELL_VOICE_ANIM                  = 106759,
  3517.  
  3518.             SPELL_AISA_ENTER_SEAT_2           = 63313, //106617
  3519.  
  3520.             SPELL_CREDIT_1                    = 105895,
  3521.             SPELL_CREDIT_2                    = 105010,
  3522.             SPELL_EJECT_PASSANGER             = 60603,
  3523.             SPELL_PARASHUT                    = 45472,
  3524.  
  3525.             EVENT_1                           = 1, // 17:24:47.000
  3526.  
  3527.             EVENT_AISA_TALK_0                 = 2,  //17:24:51.000
  3528.             EVENT_AISA_TALK_1                 = 3,  //17:25:07.000
  3529.             EVENT_AISA_TALK_2                 = 4,  //17:25:18.000
  3530.             EVENT_AISA_TALK_3                 = 5,  //17:25:31.000
  3531.             EVENT_AISA_TALK_4                 = 6,  //17:25:38.000
  3532.             EVENT_AISA_TALK_5                 = 7,  //17:26:40.000
  3533.             EVENT_AISA_TALK_6                 = 8,  //17:27:02.000
  3534.             EVENT_AISA_TALK_7                 = 9,  //17:27:29.000
  3535.             EVENT_AISA_TALK_8                 = 10, //17:27:50.000
  3536.             EVENT_AISA_TALK_9                 = 11, //17:28:04.000
  3537.             EVENT_AISA_TALK_10                = 12, //17:28:10.000
  3538.  
  3539.             EVENT_FIREPAW_TALK_0              = 13, //17:24:47.000
  3540.             EVENT_FIREPAW_TALK_1              = 14, //17:24:57.000
  3541.             EVENT_FIREPAW_TALK_2              = 15, //17:25:13.000
  3542.             EVENT_FIREPAW_TALK_3              = 16, //17:27:16.000
  3543.             EVENT_FIREPAW_TALK_4              = 17, //17:27:22.000
  3544.             EVENT_FIREPAW_TALK_5              = 18, //17:27:43.000
  3545.             EVENT_FIREPAW_TALK_6              = 19, //17:27:57.000
  3546.  
  3547.             EVENT_SHEN_ZI_SU_TALK_0           = 20, //17:25:44.000
  3548.             EVENT_SHEN_ZI_SU_TALK_1           = 21, //17:25:58.000
  3549.             EVENT_SHEN_ZI_SU_TALK_2           = 22, //17:26:12.000
  3550.             EVENT_SHEN_ZI_SU_TALK_3           = 23, //17:26:25.000
  3551.             EVENT_SHEN_ZI_SU_TALK_4           = 24, //17:26:47.000
  3552.             EVENT_SHEN_ZI_SU_TALK_5           = 25, //17:27:09.000
  3553.         };
  3554.  
  3555.         void InitTalking(Player* player)
  3556.         {
  3557.             me->GetMap()->LoadGrid(865.222f, 4986.84f); //voice
  3558.             me->GetMap()->LoadGrid(868.356f, 4631.19f); //head
  3559.             if (WorldObject* head = me->GetMap()->GetActiveObjectWithEntry(NPC_TURTLE_HEAD))
  3560.             {
  3561.                 head->m_invisibilityDetect.AddFlag(INVISIBILITY_UNK5);
  3562.                 head->m_invisibilityDetect.AddValue(INVISIBILITY_UNK5, 999);
  3563.                 player->AddToExtraLook(head->GetGUID());
  3564.                 headGUID = head->GetGUID();
  3565.             }
  3566.             else
  3567.             {
  3568.                 me->MonsterSay("SCRIPT::mop_air_balloon not find turtle heat entry 57769", LANG_UNIVERSAL, playerGuid);
  3569.                 player->ExitVehicle();
  3570.                 return;
  3571.             }
  3572.  
  3573.             if (WorldObject* shen = me->GetMap()->GetActiveObjectWithEntry(NPC_SHEN_ZI_SU))
  3574.                 shenZiGUID = shen->GetGUID();
  3575.             else
  3576.             {
  3577.                 me->MonsterSay("SCRIPT::mop_air_balloon not find shen zi su entry 56676", LANG_UNIVERSAL, playerGuid);
  3578.                 player->ExitVehicle();
  3579.                 return;
  3580.             }
  3581.  
  3582.             uint32 t = 3000;
  3583.             events.RescheduleEvent(EVENT_FIREPAW_TALK_0, t += 1000);       //17:24:47.000
  3584.             events.RescheduleEvent(EVENT_AISA_TALK_0, t += 4000);          //17:24:51.000
  3585.             events.RescheduleEvent(EVENT_FIREPAW_TALK_1, t += 6000);       //17:24:57.000
  3586.             events.RescheduleEvent(EVENT_AISA_TALK_1, t += 10000);         //17:25:07.000
  3587.             events.RescheduleEvent(EVENT_FIREPAW_TALK_2, t += 6000);       //17:25:13.000
  3588.             events.RescheduleEvent(EVENT_AISA_TALK_2, t += 5000);          //17:25:18.000
  3589.             events.RescheduleEvent(EVENT_AISA_TALK_3, t += 14000);         //17:25:31.000
  3590.             events.RescheduleEvent(EVENT_AISA_TALK_4, t += 6000);          //17:25:38.000
  3591.             events.RescheduleEvent(EVENT_SHEN_ZI_SU_TALK_0, t += 6000);    //17:25:44.000
  3592.             events.RescheduleEvent(EVENT_SHEN_ZI_SU_TALK_1, t += 14000);   //17:25:58.000
  3593.             events.RescheduleEvent(EVENT_SHEN_ZI_SU_TALK_2, t += 14000);   //17:26:12.000
  3594.             events.RescheduleEvent(EVENT_SHEN_ZI_SU_TALK_3, t += 13000);   //17:26:25.000
  3595.             events.RescheduleEvent(EVENT_AISA_TALK_5, t += 15000);         //17:26:40.000
  3596.             events.RescheduleEvent(EVENT_SHEN_ZI_SU_TALK_4, t +=7000);     //17:26:47.000
  3597.             events.RescheduleEvent(EVENT_AISA_TALK_6, t += 15000);         //17:27:02.000
  3598.             events.RescheduleEvent(EVENT_SHEN_ZI_SU_TALK_5, t +=7000);     //17:27:09.000
  3599.             events.RescheduleEvent(EVENT_FIREPAW_TALK_3, t += 7000);       //17:27:16.000
  3600.             events.RescheduleEvent(EVENT_FIREPAW_TALK_4, t += 6000);       //17:27:22.000
  3601.             events.RescheduleEvent(EVENT_AISA_TALK_7, t += 7000);          //17:27:29.000
  3602.             events.RescheduleEvent(EVENT_FIREPAW_TALK_5, t += 14000);      //17:27:43.000
  3603.             events.RescheduleEvent(EVENT_AISA_TALK_8, t += 7000);          //17:27:50.000
  3604.             events.RescheduleEvent(EVENT_FIREPAW_TALK_6, t += 7000);       //17:27:57.000
  3605.             events.RescheduleEvent(EVENT_AISA_TALK_9, t += 7000);          //17:28:04.000
  3606.             events.RescheduleEvent(EVENT_AISA_TALK_10, t += 7000);         //17:28:10.000
  3607.         };
  3608.  
  3609.         void TalkShenZiSU(uint32 text)
  3610.         {
  3611.             Creature *shen = me->GetMap()->GetCreature(shenZiGUID);
  3612.  
  3613.             if (!shen)
  3614.                 return;
  3615.  
  3616.             if (Player* plr = sObjectAccessor->FindPlayer(playerGuid))
  3617.             {
  3618.                 Creature *head = me->GetMap()->GetCreature(headGUID);
  3619.                 if (!head)
  3620.                     return;
  3621.  
  3622.                 switch(text)
  3623.                 {
  3624.                     //cast 114888                                   //17:25:31.000
  3625.                     case TEXT_GENERIC_0:                            //17:25:44.000
  3626.                         plr->CastSpell(shen, SPELL_HEAD_ANIM_1, false);    
  3627.                         break;
  3628.                     case TEXT_GENERIC_1:                            //17:25:58.000
  3629.                         plr->CastSpell(shen, SPELL_VOICE_ANIM, false);
  3630.                         break;
  3631.                     case TEXT_GENERIC_2:                            //17:26:11.000
  3632.                     case TEXT_GENERIC_3:                            //17:26:25.000
  3633.                     case TEXT_GENERIC_5:                            //17:27:08.000
  3634.                         plr->CastSpell(shen, SPELL_HEAD_ANIM_2, false);
  3635.                         break;
  3636.                     case TEXT_GENERIC_4:                            //17:26:47.000
  3637.                         plr->CastSpell(shen, SPELL_HEAD_ANIM_3, false);
  3638.                         break;
  3639.                 }
  3640.                 if (text == TEXT_GENERIC_5) // restore emote
  3641.                 {
  3642.                     head->SetUInt32Value(UNIT_FIELD_EMOTE_STATE, ANIM_FLY_LAND);   //hack
  3643.                     plr->RemoveFromExtraLook(head->GetGUID());
  3644.                 }
  3645.             }
  3646.             sCreatureTextMgr->SendChat(shen, text, playerGuid, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_AREA);
  3647.         }
  3648.  
  3649.         void PassengerBoarded(Unit* passenger, int8 seatId, bool apply)
  3650.         {
  3651.             if (!apply)
  3652.             {
  3653.                 if (passenger->GetTypeId() == TYPEID_PLAYER)
  3654.                 {
  3655.                     me->DespawnOrUnsummon(1000);
  3656.                     me->CastSpell(passenger, SPELL_PARASHUT, true);
  3657.                 }
  3658.                 else
  3659.                     passenger->ToCreature()->DespawnOrUnsummon(1000);
  3660.                 return;
  3661.             }
  3662.  
  3663.             if (seatId == 0)
  3664.             {
  3665.                 if (Player* player = passenger->ToPlayer())
  3666.                 {
  3667.                     playerGuid = player->GetGUID();
  3668.                     me->CastSpell(player, SPELL_CREDIT_1, true);
  3669.                     InitTalking(player);
  3670.                 }
  3671.             }
  3672.  
  3673.             if (passenger->GetTypeId() != TYPEID_PLAYER)
  3674.             {
  3675.                 passenger->m_invisibilityDetect.AddFlag(INVISIBILITY_UNK5);
  3676.                 passenger->m_invisibilityDetect.AddValue(INVISIBILITY_UNK5, 999);
  3677.                 switch(passenger->GetEntry())
  3678.                 {
  3679.                     case NPC_AISA: aisaGUID = passenger->GetGUID(); break;
  3680.                     case NPC_FIREPAW: firepawGUID = passenger->GetGUID(); break;
  3681.                     default:
  3682.                         break;
  3683.                 }
  3684.             }
  3685.         }
  3686.  
  3687.         void IsSummonedBy(Unit* summoner)
  3688.         {
  3689.             me->AddPlayerInPersonnalVisibilityList(summoner->GetGUID());
  3690.             playerGuid = summoner->GetGUID();
  3691.             summoner->EnterVehicle(me, 0);
  3692.             events.RescheduleEvent(EVENT_1, 1000);
  3693.         }
  3694.  
  3695.         void WaypointReached(uint32 waypointId)
  3696.         {
  3697.             switch (waypointId)
  3698.             {
  3699.                 case 8:
  3700.                     me->SetSpeed(MOVE_FLIGHT, 3.0f, false);
  3701.                     break;
  3702.                 case 15:
  3703.                 {
  3704.                     if (Player* plr = sObjectAccessor->FindPlayer(playerGuid))
  3705.                         me->CastSpell(plr, SPELL_CREDIT_2, true);
  3706.                     break;
  3707.                 }
  3708.                 default:
  3709.                     break;
  3710.             }
  3711.         }
  3712.  
  3713.         void UpdateAI(uint32 diff)
  3714.         {
  3715.             events.Update(diff);
  3716.             npc_escortAI::UpdateAI(diff);
  3717.  
  3718.             if (uint32 eventId = events.ExecuteEvent())
  3719.             {
  3720.                 switch(eventId)
  3721.                 {
  3722.                     case EVENT_1:
  3723.                     {
  3724.                         if (Creature* f = me->FindNearestCreature(NPC_AISA, 100.0f, true))
  3725.                             f->CastSpell(me, SPELL_AISA_ENTER_SEAT_2, true);
  3726.                         Start(false, true);
  3727.                         break;
  3728.                     }
  3729.                     case EVENT_AISA_TALK_3:
  3730.                         if (Creature *head = me->GetMap()->GetCreature(headGUID))
  3731.                             if (Player* plr = sObjectAccessor->FindPlayer(playerGuid))
  3732.                             {
  3733.                                 plr->CastSpell(plr, SPELL_HEAD_ANIM_RISE, false);    //17:25:31.000
  3734.                                 head->SetUInt32Value(UNIT_FIELD_EMOTE_STATE, 0);   //hack
  3735.                             }
  3736.                     case EVENT_AISA_TALK_0:
  3737.                     case EVENT_AISA_TALK_1:
  3738.                     case EVENT_AISA_TALK_2:
  3739.                     case EVENT_AISA_TALK_4:
  3740.                     case EVENT_AISA_TALK_5:
  3741.                     case EVENT_AISA_TALK_6:
  3742.                     case EVENT_AISA_TALK_7:
  3743.                     case EVENT_AISA_TALK_8:
  3744.                     case EVENT_AISA_TALK_9:
  3745.                     case EVENT_AISA_TALK_10:
  3746.                     {
  3747.                         if (Creature *aisa = me->GetMap()->GetCreature(aisaGUID))
  3748.                             sCreatureTextMgr->SendChat(aisa, eventId - 2, playerGuid);
  3749.                         break;
  3750.                     }
  3751.                    
  3752.                     case EVENT_FIREPAW_TALK_0:
  3753.                     case EVENT_FIREPAW_TALK_1:
  3754.                     case EVENT_FIREPAW_TALK_2:
  3755.                     case EVENT_FIREPAW_TALK_3:
  3756.                     case EVENT_FIREPAW_TALK_4:
  3757.                     case EVENT_FIREPAW_TALK_5:
  3758.                     case EVENT_FIREPAW_TALK_6:
  3759.                     {
  3760.                         if (Creature *paw = me->GetMap()->GetCreature(firepawGUID))
  3761.                             sCreatureTextMgr->SendChat(paw, eventId - 13, playerGuid);
  3762.                         break;
  3763.                     }
  3764.                     case EVENT_SHEN_ZI_SU_TALK_0:   // 114898
  3765.                     case EVENT_SHEN_ZI_SU_TALK_1:   //cast 106759
  3766.                     case EVENT_SHEN_ZI_SU_TALK_2:   //cast 118571
  3767.                     case EVENT_SHEN_ZI_SU_TALK_3:   //118571
  3768.                     case EVENT_SHEN_ZI_SU_TALK_4:   //118572
  3769.                     case EVENT_SHEN_ZI_SU_TALK_5:   //118571
  3770.                         TalkShenZiSU(eventId - 20);
  3771.                         break;
  3772.                 }
  3773.             }
  3774.         }
  3775.     };
  3776.    
  3777.     CreatureAI* GetAI(Creature* creature) const
  3778.     {
  3779.         return new mop_air_balloonAI(creature);
  3780.     }
  3781. };
  3782.  
  3783. /*
  3784. ========================================
  3785. ========= S O U T H  P A R T ===========
  3786. ========================================
  3787. */
  3788.  
  3789. class mob_mandori_triger : public CreatureScript
  3790. {
  3791. public:
  3792.     mob_mandori_triger() : CreatureScript("mob_mandori_triger") { }
  3793.    
  3794.     CreatureAI* GetAI(Creature* creature) const
  3795.     {
  3796.         return new mob_mandori_trigerAI(creature);
  3797.     }
  3798.    
  3799.     struct mob_mandori_trigerAI : public ScriptedAI
  3800.     {
  3801.  
  3802.         enum spells
  3803.         {
  3804.             SUMMON_AYSA                 = 115332, // Summon Aysa
  3805.             SUMMON_JI                   = 115335, // Summon Ji
  3806.             SUMMON_JOJO                 = 115337, // Summon Jojo
  3807.         };
  3808.  
  3809.         mob_mandori_trigerAI(Creature* creature) : ScriptedAI(creature)
  3810.         {
  3811.         }
  3812.  
  3813.         void Reset()
  3814.         {
  3815.         }
  3816.  
  3817.         void MoveInLineOfSight(Unit* who)
  3818.         {
  3819.             Player *player = who->ToPlayer();
  3820.             if (!player)
  3821.                 return;
  3822.  
  3823.            if (player->GetPositionX() < 710.0f || !me->IsWithinDistInMap(who, 50.0f))
  3824.                return;
  3825.  
  3826.            if (player->GetQuestStatus(QUEST_BIDDEN_TO_GREATNESS) != QUEST_STATUS_INCOMPLETE)
  3827.                return;
  3828.  
  3829.            if (player->HasAura(SUMMON_MANDORI_DOOR) || player->HasAura(SUMMON_PEI_WU_DOOR))
  3830.                return;
  3831.  
  3832.             //summon doors
  3833.             player->CastSpell(player, SUMMON_MANDORI_DOOR, false);
  3834.             player->CastSpell(player, SUMMON_PEI_WU_DOOR, false);
  3835.  
  3836.             //summon escort
  3837.             player->CastSpell(player, SUMMON_AYSA, true);
  3838.             player->CastSpell(player, SUMMON_JI, true);
  3839.             player->CastSpell(player, SUMMON_JOJO, true);
  3840.             return;
  3841.         }
  3842.     };
  3843. };
  3844.  
  3845. class mob_mandori_escort : public CreatureScript
  3846. {
  3847.     public:
  3848.         mob_mandori_escort() : CreatureScript("mob_mandori_escort") { }
  3849.  
  3850.     struct mob_mandori_escortAI : public npc_escortAI
  3851.     {        
  3852.         mob_mandori_escortAI(Creature* creature) : npc_escortAI(creature)
  3853.         {}
  3854.  
  3855.         enum escortEntry
  3856.         {
  3857.             NPC_AYSA                = 59986,
  3858.             NPC_JI                  = 59988,
  3859.             NPC_JOJO                = 59989,
  3860.             NPC_KORGA_STRONGMANE    = 60042, //Korga Strongmane
  3861.             NPC_WEI_PALERAGE        = 55943, //Wei Palerage <Hermit of the Forbidden Forest>
  3862.  
  3863.             SPELL_CREDIT_1          = 115442,
  3864.             SPELL_CREDIT_2          = 115443,
  3865.  
  3866.             SPELL_VIS_28            = 115449,
  3867.  
  3868.             EVENT_AISA_0            = 1,    //17:29:44.000 talk + credit
  3869.             EVENT_AISA_1            = 2,    //17:29:48.000 start move
  3870.             EVENT_AISA_2            = 3,    //17:30:12.000 stop move + emote stop
  3871.             EVENT_AISA_3            = 4,    //17:30:15.000 talk
  3872.             EVENT_AISA_4            = 5,
  3873.             EVENT_AISA_5            = 6,
  3874.             EVENT_AISA_6            = 7,
  3875.             EVENT_AISA_7            = 8,
  3876.  
  3877.             EVENT_JI_0              = 9,
  3878.             EVENT_JI_1              = 10,
  3879.             EVENT_JI_2              = 11,
  3880.             EVENT_JI_3              = 12,
  3881.             EVENT_JI_4              = 13,
  3882.             EVENT_JI_5              = 14,
  3883.             EVENT_JI_6              = 15,
  3884.             EVENT_JI_7              = 16,
  3885.             EVENT_JI_8              = 17,
  3886.  
  3887.             EVENT_JOJO_0            = 18,
  3888.             EVENT_JOJO_1            = 19,
  3889.             EVENT_JOJO_2            = 20,
  3890.             EVENT_JOJO_3            = 21,
  3891.             EVENT_JOJO_4            = 22,
  3892.             EVENT_JOJO_5            = 23,
  3893.  
  3894.             EVENT_KORGA_0           = 24,
  3895.             EVENT_KORGA_1           = 25,
  3896.             EVENT_KORGA_2           = 26,
  3897.             EVENT_WEI_PALERAGE      = 27,
  3898.         };
  3899.        
  3900.         EventMap events;
  3901.         ObjectGuid playerGuid;
  3902.        
  3903.         ObjectGuid mandoriDoorGuid;
  3904.         ObjectGuid peiwuDoorGuid;
  3905.  
  3906.         void Reset()
  3907.         {
  3908.             playerGuid.Clear();
  3909.             mandoriDoorGuid.Clear();
  3910.             peiwuDoorGuid.Clear();
  3911.  
  3912.             me->SetReactState(REACT_PASSIVE);
  3913.         }
  3914.  
  3915.         bool Is(uint32 npc_entry) const
  3916.         {
  3917.             return me->GetEntry() == npc_entry;
  3918.         }
  3919.  
  3920.         void IsSummonedBy(Unit* summoner)
  3921.         {
  3922.             Player *player = summoner->ToPlayer();
  3923.             if (!player)
  3924.             {
  3925.                 me->MonsterSay("SCRIPT::mob_mandori_escort summoner is not player", LANG_UNIVERSAL, ObjectGuid::Empty);
  3926.                 return;
  3927.             }
  3928.  
  3929.             playerGuid = summoner->GetGUID();
  3930.             me->AddPlayerInPersonnalVisibilityList(summoner->GetGUID());
  3931.  
  3932.             if (GameObject* mandoriDoor = summoner->GetGameObject(SUMMON_MANDORI_DOOR))
  3933.                 mandoriDoorGuid = mandoriDoor->GetGUID();
  3934.             else
  3935.             {
  3936.                 me->MonsterSay("SCRIPT::mob_mandori_escort no go summoned by SUMMON_MANDORI_DOOR 115426", LANG_UNIVERSAL, playerGuid);
  3937.                 return;
  3938.             }
  3939.  
  3940.             if (GameObject* mandoriDoor = summoner->GetGameObject(SUMMON_PEI_WU_DOOR))
  3941.                 peiwuDoorGuid = mandoriDoor->GetGUID();
  3942.             else
  3943.             {
  3944.                 me->MonsterSay("SCRIPT::mob_mandori_escort no go summoned by SUMMON_PEI_WU_DOOR 115435", LANG_UNIVERSAL, playerGuid);
  3945.                 return;
  3946.             }
  3947.  
  3948.             uint32 t = 4000;                                         //17:29:43.000
  3949.             if (Is(NPC_AYSA))
  3950.             {
  3951.                 events.RescheduleEvent(EVENT_AISA_0, t += 1000);       //17:29:44.000 talk + credit
  3952.                 events.RescheduleEvent(EVENT_AISA_1, t += 1000);       //17:29:48.000
  3953.             }else// if (Is(NPC_JI) || Is(NPC_JOJO))
  3954.             {
  3955.                 if (Is(NPC_JI))
  3956.                     events.RescheduleEvent(EVENT_JI_0, t += 2000);     //17:29:48.000
  3957.                 if (Is(NPC_JOJO))
  3958.                     events.RescheduleEvent(EVENT_JOJO_0, t += 2000);   //17:29:48.000
  3959.             }
  3960.         }
  3961.  
  3962.         void WaypointReached(uint32 waypointId)
  3963.         {
  3964.             uint32 t = 0;
  3965.             switch (waypointId)
  3966.             {
  3967.                 //cast 9  - 17:30:05.000 cast 115346 trigger dummy.
  3968.                 case 12:
  3969.                     SetEscortPaused(true);
  3970.  
  3971.                     if (Is(NPC_AYSA))
  3972.                     {
  3973.                         t = 1000;                                            //
  3974.                         events.RescheduleEvent(EVENT_AISA_2, t += 2000);       //17:30:12.000 stop move + emote stop
  3975.                         events.RescheduleEvent(EVENT_AISA_3, t += 3000);       //17:30:15.000 talk
  3976.                         events.RescheduleEvent(EVENT_AISA_4, t += 2000);       //17:30:17.000 talk
  3977.                         events.RescheduleEvent(EVENT_AISA_5, t += 16000);      //17:30:33.000 move continue
  3978.                     }else if (Is(NPC_JI))
  3979.                     {
  3980.                         t = 1000;                                           //17:30:10.000
  3981.                         events.RescheduleEvent(EVENT_JI_1, t += 9000);        //17:30:19.000 talk
  3982.                         events.RescheduleEvent(EVENT_JI_2, t += 3000);        //17:30:22.000 move + emote
  3983.                         events.RescheduleEvent(EVENT_JI_3, t += 2000);        //17:30:24.000
  3984.                         events.RescheduleEvent(EVENT_JI_4, t += 4000);        //17:30:28.000
  3985.                         events.RescheduleEvent(EVENT_JI_5, t += 5000);        //17:30:33.000
  3986.                         events.RescheduleEvent(EVENT_JI_6, t += 5000);        //17:30:38.000
  3987.                     }else if (Is(NPC_JOJO))
  3988.                     {
  3989.                         t = 0;                                              //17:30:10.000
  3990.                         events.RescheduleEvent(EVENT_JOJO_1, t += 1000);      //17:30:10.000
  3991.                         events.RescheduleEvent(EVENT_JOJO_2, t += 22000);     //17:30:32.000
  3992.                         events.RescheduleEvent(EVENT_JOJO_3, t += 2000);      //17:30:34.000
  3993.                         events.RescheduleEvent(EVENT_JOJO_4, t += 1000);      //17:30:35.000
  3994.                     }
  3995.                     break;
  3996.                 case 20:
  3997.                     if (Is(NPC_AYSA))
  3998.                     {
  3999.                         SetEscortPaused(true);
  4000.                         t = 1000;                                            //17:30:59.000
  4001.                         events.RescheduleEvent(EVENT_AISA_6, t += 27000);      //17:31:27.000
  4002.                         events.RescheduleEvent(EVENT_AISA_7, t += 7000);       //17:31:35.000
  4003.                     }else if (Is(NPC_JOJO))
  4004.                     {
  4005.                         SetEscortPaused(true);
  4006.                         events.RescheduleEvent(EVENT_JOJO_5, 37000);           //17:31:37.000
  4007.                     }
  4008.                     break;
  4009.                 case 23:
  4010.                     if (Is(NPC_JI))
  4011.                     {
  4012.                         SetEscortPaused(true);
  4013.                         t = 1000;                                           //17:30:59.000
  4014.                         events.RescheduleEvent(EVENT_KORGA_0, t +=2000);      //17:31:02.000
  4015.                         events.RescheduleEvent(EVENT_WEI_PALERAGE, t +=4000); //17:31:06.000
  4016.                         events.RescheduleEvent(EVENT_KORGA_1, t +=9000);      //17:31:15.000
  4017.                         events.RescheduleEvent(EVENT_JI_7, t += 22000);       //17:31:37.000
  4018.                         events.RescheduleEvent(EVENT_KORGA_2, t +=7000);      //17:31:44.000
  4019.                         events.RescheduleEvent(EVENT_JI_8, t += 9000);        //17:31:53.000 + 17:33:58.000  despawn
  4020.                     }
  4021.                     break;
  4022.                 default:
  4023.                     break;
  4024.             }
  4025.         }
  4026.  
  4027.         void LastWaypointReached()
  4028.         {          
  4029.             if (Is(NPC_AYSA))
  4030.             {
  4031.                 if (GameObject* mandoriDoor = me->GetMap()->GetGameObject(mandoriDoorGuid))
  4032.                     mandoriDoor->Delete();
  4033.                 if (GameObject* peiwuDoor = me->GetMap()->GetGameObject(peiwuDoorGuid))
  4034.                     peiwuDoor->Delete();
  4035.             }
  4036.         }
  4037.  
  4038.         void UpdateAI(uint32 diff)
  4039.         {
  4040.             events.Update(diff);
  4041.             npc_escortAI::UpdateAI(diff);
  4042.  
  4043.             if (uint32 eventId = events.ExecuteEvent())
  4044.             {
  4045.                 switch(eventId)
  4046.                 {
  4047.                     case EVENT_AISA_0:
  4048.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, playerGuid);
  4049.                         break;
  4050.                     case EVENT_AISA_1:
  4051.                         if (GameObject* mandoriDoor = me->GetMap()->GetGameObject(mandoriDoorGuid))
  4052.                             mandoriDoor->SetGoState(GO_STATE_ACTIVE);
  4053.  
  4054.                         if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  4055.                         {
  4056.                             me->CastSpell(player, SPELL_CREDIT_1, true);
  4057.                             player->RemoveAurasDueToSpell(SPELL_VIS_28);
  4058.                         }
  4059.                         Start(false, true);
  4060.                         break;
  4061.                     case EVENT_AISA_2:
  4062.                         me->HandleEmoteCommand(432);
  4063.                         break;
  4064.                     case EVENT_AISA_3:
  4065.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1, playerGuid);
  4066.                         break;
  4067.                     case EVENT_AISA_4:
  4068.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2, playerGuid);
  4069.                         break;
  4070.                     case EVENT_AISA_7:
  4071.                     case EVENT_AISA_5:
  4072.                     case EVENT_JOJO_5:
  4073.                         SetEscortPaused(false);
  4074.                         break;
  4075.                     case EVENT_AISA_6:
  4076.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_3, playerGuid);
  4077.                         break;
  4078.                     case EVENT_JI_0:
  4079.                     case EVENT_JOJO_0:
  4080.                         Start(false, true);
  4081.                         break;
  4082.                     case EVENT_JI_1:
  4083.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, playerGuid);
  4084.                         break;
  4085.                     case EVENT_JI_2:
  4086.                         me->GetMotionMaster()->MovePoint(100, 569.153f, 3582.24f, 94.95621f);
  4087.                         me->SetUInt32Value(UNIT_FIELD_EMOTE_STATE, EMOTE_STATE_STEALTH_STAND);
  4088.                         break;
  4089.                     case EVENT_JI_3:
  4090.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1, playerGuid);
  4091.                         break;
  4092.                     case EVENT_JI_4:
  4093.                         me->SendPlaySpellVisualKit(15801, 0);
  4094.                         break;
  4095.                     case EVENT_JI_5:
  4096.                         me->SetUInt32Value(UNIT_FIELD_EMOTE_STATE, 0);
  4097.                         SetEscortPaused(false);
  4098.                         break;
  4099.                     case EVENT_JI_6:
  4100.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2, playerGuid);
  4101.                         break;
  4102.                     case EVENT_JI_7:
  4103.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_3, playerGuid);
  4104.                         break;
  4105.                     case EVENT_JI_8:
  4106.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_4, playerGuid);
  4107.                         me->DespawnOrUnsummon(120000);
  4108.                         break;
  4109.                     case EVENT_JOJO_1:
  4110.                         me->SetUInt32Value(UNIT_FIELD_EMOTE_STATE, EMOTE_STATE_READY_BOW);
  4111.                         break;
  4112.                     case EVENT_JOJO_2:
  4113.                         me->HandleEmoteCommand(15);
  4114.                         me->PlayDistanceSound(32037);
  4115.                         break;
  4116.                     case EVENT_JOJO_3:
  4117.                         if (GameObject* peiwuDoor = me->GetMap()->GetGameObject(peiwuDoorGuid))
  4118.                             peiwuDoor->SetGoState(GO_STATE_ACTIVE);
  4119.                         if (Player* player = ObjectAccessor::GetPlayer(*me, playerGuid))
  4120.                             me->CastSpell(player, SPELL_CREDIT_2, true);
  4121.                         me->GetMotionMaster()->MoveCharge(567.99f, 3583.41f, 94.74f);
  4122.                         break;
  4123.                     case EVENT_JOJO_4:
  4124.                         SetEscortPaused(false);
  4125.                         me->SendPlaySpellVisualKit(28180, 0);
  4126.                         break;
  4127.                     case EVENT_WEI_PALERAGE:
  4128.                         if (Creature* wei = me->FindNearestCreature(NPC_WEI_PALERAGE, 50.0f, true))
  4129.                             sCreatureTextMgr->SendChat(wei, TEXT_GENERIC_0, playerGuid);
  4130.                         break;
  4131.                     case EVENT_KORGA_0:
  4132.                         if (Creature* korga = me->FindNearestCreature(NPC_KORGA_STRONGMANE, 50.0f, true))
  4133.                             sCreatureTextMgr->SendChat(korga, TEXT_GENERIC_0, playerGuid);
  4134.                         break;
  4135.                     case EVENT_KORGA_1:
  4136.                         if (Creature* korga = me->FindNearestCreature(NPC_KORGA_STRONGMANE, 50.0f, true))
  4137.                             sCreatureTextMgr->SendChat(korga, TEXT_GENERIC_1, playerGuid);
  4138.                         break;
  4139.                     case EVENT_KORGA_2:
  4140.                         if (Creature* korga = me->FindNearestCreature(NPC_KORGA_STRONGMANE, 50.0f, true))
  4141.                             sCreatureTextMgr->SendChat(korga, TEXT_GENERIC_2, playerGuid);
  4142.                         break;
  4143.                 }
  4144.             }
  4145.         }
  4146.     };
  4147.    
  4148.     CreatureAI* GetAI(Creature* creature) const
  4149.     {
  4150.         return new mob_mandori_escortAI(creature);
  4151.     }
  4152. };
  4153.  
  4154. // Ji Yuan
  4155. class npc_ji_yuan : public CreatureScript
  4156. {
  4157.     public:
  4158.         npc_ji_yuan() : CreatureScript("npc_ji_yuan") { }
  4159.  
  4160.     struct npc_ji_yuanAI : public ScriptedAI
  4161.     {        
  4162.         npc_ji_yuanAI(Creature* creature) : ScriptedAI(creature)
  4163.         {}
  4164.  
  4165.         void Reset()
  4166.         {
  4167.             me->SetReactState(REACT_PASSIVE);
  4168.         }
  4169.  
  4170.         void IsSummonedBy(Unit* summoner)
  4171.         {
  4172.             me->AddPlayerInPersonnalVisibilityList(summoner->GetGUID());
  4173.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, summoner->GetGUID());
  4174.             me->GetMotionMaster()->MovePoint(1, 495.061f, 4007.92f, 78.3662f);
  4175.         }
  4176.  
  4177.         void MovementInform(uint32 moveType, uint32 waypointId)
  4178.         {
  4179.             me->DespawnOrUnsummon(5000);
  4180.         }
  4181.     };
  4182.     CreatureAI* GetAI(Creature* creature) const
  4183.     {
  4184.         return new npc_ji_yuanAI(creature);
  4185.     }
  4186. };
  4187.  
  4188. //56476 Injured Sailor Rescue Controller
  4189. class npc_injured_sailor_rescue_controller : public CreatureScript
  4190. {
  4191. public:
  4192.     npc_injured_sailor_rescue_controller() : CreatureScript("npc_injured_sailor_rescue_controller") { }
  4193.    
  4194.     CreatureAI* GetAI(Creature* creature) const
  4195.     {
  4196.         return new npc_injured_sailor_rescue_controllerAI(creature);
  4197.     }
  4198.    
  4199.     struct npc_injured_sailor_rescue_controllerAI : public ScriptedAI
  4200.     {
  4201.  
  4202.         enum spells
  4203.         {
  4204.             SPELL_CANCEL_INJURED_SAILOR             = 117987,   //Cancel Injured Sailor Rescue Aura
  4205.             NPC_SAILOR                              = 56236,
  4206.             NPC_QUEST_CREDIT                        = 55999,
  4207.         };
  4208.  
  4209.         npc_injured_sailor_rescue_controllerAI(Creature* creature) : ScriptedAI(creature)
  4210.         {
  4211.         }
  4212.  
  4213.         void Reset()
  4214.         {
  4215.         }
  4216.  
  4217.         void MoveInLineOfSight(Unit* who)
  4218.         {
  4219.            if (!me->IsWithinDistInMap(who, 10.0f))
  4220.                return;
  4221.  
  4222.            Vehicle* veh = who->GetVehicle();
  4223.            if (who->GetEntry() != NPC_SAILOR || !veh)
  4224.                return;
  4225.  
  4226.            Player* player = veh->GetBase()->ToPlayer();
  4227.            if (!player || player->GetQuestStatus(QUEST_NONE_LEFT_BEHINED) != QUEST_STATUS_INCOMPLETE)
  4228.                return;
  4229.  
  4230.             player->KilledMonsterCredit(NPC_QUEST_CREDIT);
  4231.  
  4232.             player->CastSpell(player, SPELL_CANCEL_INJURED_SAILOR, true);
  4233.             sCreatureTextMgr->SendChat(who->ToCreature(), TEXT_GENERIC_0, player->GetGUID());
  4234.             who->ToCreature()->DespawnOrUnsummon(5000);
  4235.             return;
  4236.         }
  4237.     };
  4238.  
  4239. };
  4240.  
  4241. class npc_hurted_soldier : public CreatureScript
  4242. {
  4243. public:
  4244.     npc_hurted_soldier() : CreatureScript("npc_hurted_soldier") { }
  4245.  
  4246.     CreatureAI* GetAI(Creature* creature) const
  4247.     {
  4248.         return new npc_hurted_soldierAI (creature);
  4249.     }
  4250.  
  4251.     struct npc_hurted_soldierAI : public ScriptedAI
  4252.     {
  4253.         npc_hurted_soldierAI(Creature* creature) : ScriptedAI(creature) {}
  4254.  
  4255.         uint32 checkSavedTimer;
  4256.         bool HasBeenSaved;
  4257.  
  4258.         void Reset()
  4259.         {
  4260.             checkSavedTimer = 2500;
  4261.             HasBeenSaved = false;
  4262.         }
  4263.  
  4264.         void OnSpellClick(Unit* Clicker)
  4265.         {
  4266.             HasBeenSaved = true;
  4267.         }
  4268.  
  4269.         void UpdateAI(uint32 diff)
  4270.         {
  4271.             if (checkSavedTimer)
  4272.             {
  4273.                 if (checkSavedTimer <= diff)
  4274.                 {
  4275.                     if (HasBeenSaved && !me->GetVehicle())
  4276.                     {
  4277.                         me->DespawnOrUnsummon(5000);
  4278.                         checkSavedTimer = 0;
  4279.                     }
  4280.                     else
  4281.                         checkSavedTimer = 2500;
  4282.                 }
  4283.                 else
  4284.                     checkSavedTimer -= diff;
  4285.             }
  4286.         }
  4287.     };
  4288. };
  4289.  
  4290. class boss_vordraka : public CreatureScript
  4291. {
  4292. public:
  4293.     boss_vordraka() : CreatureScript("boss_vordraka") { }
  4294.  
  4295.     CreatureAI* GetAI(Creature* creature) const
  4296.     {
  4297.         return new boss_vordrakaAI(creature);
  4298.     }
  4299.  
  4300.     struct boss_vordrakaAI : public ScriptedAI
  4301.     {
  4302.         boss_vordrakaAI(Creature* creature) : ScriptedAI(creature)
  4303.         {}
  4304.  
  4305.         EventMap _events;
  4306.  
  4307.         enum eEnums
  4308.         {
  4309.             QUEST_ANCIEN_MAL        = 29798,
  4310.  
  4311.             EVENT_DEEP_ATTACK       = 1,
  4312.             EVENT_DEEP_SEA_RUPTURE  = 2,
  4313.  
  4314.             SPELL_DEEP_ATTACK       = 117287,
  4315.             SPELL_DEEP_SEA_RUPTURE  = 117456,
  4316.         };
  4317.  
  4318.         void Reset()
  4319.         {
  4320.             _events.RescheduleEvent(EVENT_DEEP_ATTACK, 10000);
  4321.             _events.RescheduleEvent(EVENT_DEEP_SEA_RUPTURE, 15000);
  4322.         }
  4323.  
  4324.         void JustDied(Unit* attacker)
  4325.         {
  4326.             std::list<Player*> playerList;
  4327.             GetPlayerListInGrid(playerList, me, 50.0f);
  4328.  
  4329.             for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
  4330.             {
  4331.                 Player* player = *itr;
  4332.                 if (player->GetQuestStatus(QUEST_ANCIEN_MAL) == QUEST_STATUS_INCOMPLETE)
  4333.                     if (player->isAlive())
  4334.                         player->KilledMonsterCredit(me->GetEntry());
  4335.             }
  4336.         }
  4337.  
  4338.         void UpdateAI(uint32 diff)
  4339.         {
  4340.             if (!UpdateVictim())
  4341.                 return;
  4342.  
  4343.             _events.Update(diff);
  4344.  
  4345.             if (me->HasUnitState(UNIT_STATE_CASTING))
  4346.                 return;
  4347.  
  4348.             switch (_events.ExecuteEvent())
  4349.             {
  4350.                 case EVENT_DEEP_ATTACK:
  4351.                 {
  4352.                     if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 25.0f, true))
  4353.                         me->CastSpell(target, SPELL_DEEP_ATTACK, false);
  4354.                     _events.RescheduleEvent(EVENT_DEEP_ATTACK, 15000);
  4355.                     break;
  4356.                 }
  4357.                 case EVENT_DEEP_SEA_RUPTURE:
  4358.                 {
  4359.                     if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 25.0f, true))
  4360.                         me->CastSpell(target, SPELL_DEEP_SEA_RUPTURE, false);
  4361.                     _events.RescheduleEvent(EVENT_DEEP_SEA_RUPTURE, 15000);
  4362.                     break;
  4363.                 }
  4364.             }
  4365.         }
  4366.     };
  4367. };
  4368.  
  4369. //Aysa Cloudsinger <Master of Tushui>
  4370. class npc_aysa_cloudsinger : public CreatureScript
  4371. {
  4372. public:
  4373.     npc_aysa_cloudsinger() : CreatureScript("npc_aysa_cloudsinger") {}
  4374.  
  4375.     CreatureAI* GetAI(Creature* creature) const
  4376.     {
  4377.         return new npc_aysa_cloudsinger_AI (creature);
  4378.     }
  4379.  
  4380.     enum eSpell
  4381.     {
  4382.         SPELL_ROLL          = 117312,
  4383.         SPELL_FIST_FURY     = 117275,
  4384.         SPELL_SUMMON_AISA   = 117497,
  4385.         SPELL_SUMMON_JI     = 117597,
  4386.         NPC_NIGHMIRE        = 56009,
  4387.     };
  4388.  
  4389.     bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
  4390.     {
  4391.         if (quest->GetQuestId() == QUEST_RISKING_IT_ALL)
  4392.             player->CastSpell(player, SPELL_SUMMON_AISA, true);
  4393.         return true;
  4394.     }
  4395.  
  4396.     struct npc_aysa_cloudsinger_AI : public ScriptedAI
  4397.     {
  4398.         npc_aysa_cloudsinger_AI(Creature* creature) : ScriptedAI(creature)
  4399.         {
  4400.             bossGUID.Clear();
  4401.             me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_KNOCK_BACK, true);
  4402.         }
  4403.        
  4404.         enum eEvents
  4405.         {
  4406.             EVENT_FIST_FURY         = 1,
  4407.             EVENT_1                 = 2,
  4408.             EVENT_2                 = 3,
  4409.             EVENT_3                 = 4,
  4410.         };
  4411.  
  4412.         EventMap events;
  4413.         ObjectGuid bossGUID;
  4414.         GuidSet m_player_for_event;
  4415.         uint16 checkPOSTimer;
  4416.  
  4417.         void Reset()
  4418.         {
  4419.             events.Reset();
  4420.             events.RescheduleEvent(EVENT_FIST_FURY, 7000);
  4421.             checkPOSTimer = 2000;
  4422.         }
  4423.  
  4424.         void MoveInLineOfSight(Unit* who)
  4425.         {
  4426.             ScriptedAI::MoveInLineOfSight(who);
  4427.  
  4428.             if (who->GetTypeId() != TYPEID_PLAYER)
  4429.                 return;
  4430.  
  4431.             if (!me->IsWithinDistInMap(who, 60.0f))
  4432.                 return;
  4433.  
  4434.             GuidSet::iterator itr = m_player_for_event.find(who->GetGUID());
  4435.             if (itr != m_player_for_event.end())
  4436.                 return;
  4437.  
  4438.             if (who->ToPlayer()->GetQuestStatus(QUEST_ACIENT_EVIL) != QUEST_STATUS_INCOMPLETE)
  4439.                 return;
  4440.  
  4441.             m_player_for_event.insert(who->GetGUID());
  4442.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, who->GetGUID());
  4443.             if (Creature* boss = me->FindNearestCreature(NPC_NIGHMIRE, 100.0f, true))
  4444.             {
  4445.                 bossGUID = boss->GetGUID();
  4446.                 if (!boss->isAlive())
  4447.                     boss->Respawn(true);
  4448.                 AttackStart(boss);
  4449.  
  4450.                 events.RescheduleEvent(EVENT_1, 10000);
  4451.                 events.RescheduleEvent(EVENT_2, 15000);
  4452.                 events.RescheduleEvent(EVENT_3, 35000);
  4453.             }
  4454.         }
  4455.  
  4456.         void EnterEvadeMode()
  4457.         {
  4458.             ScriptedAI::EnterEvadeMode();
  4459.  
  4460.             if (bossGUID)
  4461.             {
  4462.                 sCreatureTextMgr->SendChat(me, TEXT_GENERIC_4);
  4463.                 bossGUID.Clear();
  4464.             }
  4465.  
  4466.             DoTeleportTo(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY(), me->GetHomePosition().GetPositionZ());
  4467.         }
  4468.  
  4469.         void KilledUnit(Unit* /*victim*/)
  4470.         {
  4471.             sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1);
  4472.         }
  4473.  
  4474.         void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType dmgType)
  4475.         {
  4476.             if (damage >= me->GetHealth())
  4477.                 damage = 0;
  4478.             else
  4479.                 damage = 1;
  4480.         }
  4481.  
  4482.         void EnterCombat(Unit* victim)
  4483.         {
  4484.             if (me->GetDistance(victim) > 10)
  4485.                 me->CastSpell(victim, SPELL_ROLL, true);
  4486.         }
  4487.  
  4488.         void UpdateAI(uint32 diff)
  4489.         {
  4490.             UpdateVictim();
  4491.  
  4492.             if (checkPOSTimer)
  4493.             {
  4494.                 if (checkPOSTimer <= diff)
  4495.                 {
  4496.                     checkPOSTimer = 2000;
  4497.                     if ((me->GetDistance(me->GetHomePosition()) > 20.0f) || me->GetPositionZ() < 70.0f || me->GetPositionZ() > 80.0f)
  4498.                         DoTeleportTo(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY(), me->GetHomePosition().GetPositionZ());
  4499.                 }
  4500.                 else
  4501.                     checkPOSTimer -= diff;
  4502.             }
  4503.  
  4504.             if (me->HasUnitState(UNIT_STATE_CASTING))
  4505.                 return;
  4506.  
  4507.             events.Update(diff);
  4508.  
  4509.             if (uint32 eventId = events.ExecuteEvent())
  4510.             {
  4511.                 switch (eventId)
  4512.                 {
  4513.                     case EVENT_1:
  4514.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1);
  4515.                         break;
  4516.                     case EVENT_2:
  4517.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2);
  4518.                         break;
  4519.                     case EVENT_3:
  4520.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_3);
  4521.                         break;
  4522.                     case EVENT_FIST_FURY:
  4523.                         DoCastVictim(SPELL_FIST_FURY, true);
  4524.                         events.RescheduleEvent(EVENT_FIST_FURY, 5000);
  4525.                         break;
  4526.                     default:
  4527.                         break;
  4528.                 }
  4529.             }
  4530.             DoMeleeAttackIfReady();
  4531.         }
  4532.     };
  4533. };
  4534.  
  4535. class mob_aysa_gunship_crash_escort : public CreatureScript
  4536. {
  4537. public:
  4538.     mob_aysa_gunship_crash_escort() : CreatureScript("mob_aysa_gunship_crash_escort") { }
  4539.  
  4540.     struct mob_aysa_gunship_crash_escortAI : public npc_escortAI
  4541.     {        
  4542.         mob_aysa_gunship_crash_escortAI(Creature* creature) : npc_escortAI(creature)
  4543.         {}
  4544.  
  4545.         EventMap events;
  4546.         ObjectGuid playerGuid;
  4547.         ObjectGuid jiGuid;
  4548.  
  4549.         enum escortEntry
  4550.         {
  4551.             EVENT_AISA_0        = 1,
  4552.             EVENT_AISA_1        = 2,
  4553.             EVENT_AISA_2        = 3,
  4554.             EVENT_AISA_3        = 4,
  4555.             EVENT_AISA_4        = 5,
  4556.             EVENT_AISA_5        = 6,
  4557.             EVENT_AISA_6        = 7,
  4558.             EVENT_AISA_7        = 8,
  4559.             EVENT_AISA_8        = 9,
  4560.  
  4561.             EVENT_JI_0          = 10,
  4562.             EVENT_JI_1          = 11,
  4563.             EVENT_JI_2          = 12,
  4564.             EVENT_JI_3          = 13,
  4565.             EVENT_JI_4          = 14,
  4566.  
  4567.             SPELL_FINISH        = 106037,
  4568.         };
  4569.  
  4570.         void Reset()
  4571.         {
  4572.             playerGuid.Clear();
  4573.             jiGuid.Clear();
  4574.         }
  4575.  
  4576.         void IsSummonedBy(Unit* summoner)
  4577.         {
  4578.             Player *player = summoner->ToPlayer();
  4579.             if (!player)
  4580.             {
  4581.                 me->MonsterSay("SCRIPT::mob_aysa_gunship_crash_escort summoner is not player", LANG_UNIVERSAL, ObjectGuid::Empty);
  4582.                 return;
  4583.             }
  4584.  
  4585.             playerGuid = summoner->GetGUID();
  4586.             me->AddPlayerInPersonnalVisibilityList(summoner->GetGUID());
  4587.  
  4588.             // summoned by spell 117600
  4589.             if (Creature* ji = me->SummonCreature(60741, 230.31f, 4006.67f, 87.27f, 3.38f, TEMPSUMMON_MANUAL_DESPAWN, 0, playerGuid))
  4590.                 jiGuid = ji->GetGUID();
  4591.  
  4592.             uint32 t = 0;                                        //17:54:19.000
  4593.             events.RescheduleEvent(EVENT_AISA_0, t += 2000);       //17:54:21.000
  4594.             events.RescheduleEvent(EVENT_AISA_1, t += 3000);       //17:54:24.000
  4595.         }
  4596.  
  4597.         void WaypointReached(uint32 waypointId)
  4598.         {
  4599.             if (waypointId == 8)
  4600.             {
  4601.                 SetEscortPaused(true);
  4602.                 uint32 t = 0;                                        //
  4603.                 events.RescheduleEvent(EVENT_AISA_2, t += 2000);       //17:54:41.000
  4604.                 events.RescheduleEvent(EVENT_JI_0, t += 4000);         //17:54:45.000
  4605.                 events.RescheduleEvent(EVENT_AISA_3, t += 9000);       //17:54:54.000
  4606.                 events.RescheduleEvent(EVENT_JI_1, t += 4000);         //17:54:58.000
  4607.                 events.RescheduleEvent(EVENT_AISA_4, t += 10000);      //17:55:08.000
  4608.                 events.RescheduleEvent(EVENT_JI_2, t += 4000);         //17:55:12.000
  4609.                 events.RescheduleEvent(EVENT_AISA_5, t += 6000);       //17:55:18.000
  4610.                 events.RescheduleEvent(EVENT_AISA_6, t += 6000);       //17:55:24.000
  4611.                 events.RescheduleEvent(EVENT_JI_3, t += 5000);         //17:55:29.000
  4612.                 events.RescheduleEvent(EVENT_AISA_7, t += 4000);       //17:55:33.000
  4613.                 events.RescheduleEvent(EVENT_AISA_8, t += 500);        //17:55:33.000
  4614.             }
  4615.         }
  4616.  
  4617.         void LastWaypointReached()
  4618.         {  
  4619.             if (Creature* ji = getJi())
  4620.                 ji->DespawnOrUnsummon();
  4621.         }
  4622.  
  4623.         Creature* getJi()
  4624.         {
  4625.             return me->GetMap()->GetCreature(jiGuid);
  4626.         }
  4627.  
  4628.         void UpdateAI(uint32 diff)
  4629.         {
  4630.             events.Update(diff);
  4631.             npc_escortAI::UpdateAI(diff);
  4632.  
  4633.             if (uint32 eventId = events.ExecuteEvent())
  4634.             {
  4635.                 switch(eventId)
  4636.                 {
  4637.                     case EVENT_AISA_0:
  4638.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, playerGuid);
  4639.                         break;
  4640.                     case EVENT_AISA_1:
  4641.                         Start(false, true);
  4642.                         break;
  4643.                     case EVENT_AISA_2:
  4644.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1, playerGuid);
  4645.                         break;
  4646.                     case EVENT_AISA_3:
  4647.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2, playerGuid);
  4648.                         break;
  4649.                     case EVENT_AISA_4:
  4650.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_3, playerGuid);
  4651.                         break;
  4652.                     case EVENT_AISA_5:
  4653.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_4, playerGuid);
  4654.                         break;
  4655.                     case EVENT_AISA_6:
  4656.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_5, playerGuid);
  4657.                         break;
  4658.                     case EVENT_AISA_7:
  4659.                         SetEscortPaused(false);
  4660.                         if (Player* player = ObjectAccessor::GetPlayer(*me, playerGuid))
  4661.                         {
  4662.                             player->KilledMonsterCredit(60727);
  4663.                             player->SendMovieStart(117);
  4664.                         }
  4665.                         break;
  4666.                     case EVENT_AISA_8:
  4667.                         if (Player* player = ObjectAccessor::GetPlayer(*me, playerGuid))
  4668.                             player->NearTeleportTo(249.38f, 3939.55f, 65.61f, 1.501471f);
  4669.                         break;
  4670.                     case EVENT_JI_0:
  4671.                         if (Creature* ji = getJi())
  4672.                         {
  4673.                             ji->SetFacingToObject(me);
  4674.                             sCreatureTextMgr->SendChat(ji, TEXT_GENERIC_0, playerGuid);
  4675.                         }
  4676.                         break;
  4677.                     case EVENT_JI_1:
  4678.                         if (Creature* ji = getJi())
  4679.                             sCreatureTextMgr->SendChat(ji, TEXT_GENERIC_1, playerGuid);
  4680.                         break;
  4681.                     case EVENT_JI_2:
  4682.                         if (Creature* ji = getJi())
  4683.                             sCreatureTextMgr->SendChat(ji, TEXT_GENERIC_2, playerGuid);
  4684.                         break;
  4685.                     case EVENT_JI_3:
  4686.                         if (Creature* ji = getJi())
  4687.                             ji->GetMotionMaster()->MovePoint(0, 230.4045f, 3975.614f, 87.7406f);
  4688.                         break;
  4689.                 }
  4690.             }
  4691.         }
  4692.     };
  4693.    
  4694.     CreatureAI* GetAI(Creature* creature) const
  4695.     {
  4696.         return new mob_aysa_gunship_crash_escortAI(creature);
  4697.     }
  4698.    
  4699. };
  4700.  
  4701. #define MAX_ENNEMIES_POS   2
  4702. #define MAX_HEALER_COUNT   12
  4703. #define UPDATE_POWER_TIMER 3000
  4704.  
  4705. Position ennemiesPositions[MAX_ENNEMIES_POS] =
  4706. {
  4707.     {215.0f, 3951.0f, 71.4f},
  4708.     {290.0f, 3939.0f, 86.7f}
  4709. };
  4710.  
  4711.  
  4712. enum eEnums
  4713. {          
  4714.     NPC_HEALER_A            = 60878,
  4715.     NPC_HEALER_H            = 60896,
  4716.     NPC_ENNEMY              = 60858,
  4717.     NPC_ENEMY_2             = 60780,
  4718.  
  4719.     NPC_SHEN_HEAL_CREDIT    = 56011,
  4720.  
  4721.     EVENT_CHECK_PLAYERS     = 1,
  4722.     EVENT_UPDATE_POWER      = 2,
  4723.     EVENT_SUMMON_ENNEMY     = 3,
  4724.     EVENT_SUMMON_HEALER     = 4,
  4725.     EVENT_SEND_PHASE        = 5,
  4726.  
  4727.     SPELL_SHEN_HEALING      = 117783,
  4728.     SPELL_HEALER_A          = 117784,
  4729.     SPELL_HEALER_H          = 117932,
  4730.  
  4731.     SPELL_SCEAN_HEAL        = 117790,
  4732. };
  4733.  
  4734. class npc_ji_end_event : public CreatureScript
  4735. {
  4736. public:
  4737.     npc_ji_end_event() : CreatureScript("npc_ji_end_event") { }
  4738.  
  4739.     CreatureAI* GetAI(Creature* creature) const
  4740.     {
  4741.         return new npc_ji_end_eventAI(creature);
  4742.     }
  4743.  
  4744.     bool OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt)
  4745.     {
  4746.         switch(quest->GetQuestId())
  4747.         {
  4748.             case QUEST_HEALING_SHEN:
  4749.                 player->CastSpell(player, SPELL_SCEAN_HEAL, true);
  4750.                 break;
  4751.         }
  4752.         return true;
  4753.     }
  4754.  
  4755.     struct npc_ji_end_eventAI : public ScriptedAI
  4756.     {
  4757.         npc_ji_end_eventAI(Creature* creature) : ScriptedAI(creature), _summons(creature)
  4758.         {}
  4759.  
  4760.         EventMap   _events;
  4761.         SummonList _summons;
  4762.  
  4763.         bool       inProgress;
  4764.         uint8      healerCount;
  4765.         uint8      ennemiesCount;
  4766.         uint16     actualPower;
  4767.  
  4768.         GuidSet m_player_for_event;
  4769.  
  4770.         void Reset()
  4771.         {
  4772.             _summons.DespawnAll();
  4773.  
  4774.             healerCount   = 0;
  4775.             ennemiesCount = 0;
  4776.             actualPower   = 0;
  4777.  
  4778.             inProgress = false;
  4779.  
  4780.             _events.Reset();
  4781.             _events.RescheduleEvent(EVENT_CHECK_PLAYERS, 5000);
  4782.         }
  4783.  
  4784.  
  4785.         void MoveInLineOfSight(Unit* who)
  4786.         {
  4787.             Player* player = who->ToPlayer();
  4788.             if (!player)
  4789.                 return;
  4790.  
  4791.             if (player->GetQuestStatus(QUEST_HEALING_SHEN) != QUEST_STATUS_INCOMPLETE)
  4792.                 return;
  4793.  
  4794.             GuidSet::iterator itr = m_player_for_event.find(who->GetGUID());
  4795.             if (itr != m_player_for_event.end())
  4796.                 return;
  4797.  
  4798.             m_player_for_event.insert(who->GetGUID());
  4799.             SendState(player, 1);
  4800.         }
  4801.  
  4802.         void SendState(Player* player, int32 value)
  4803.         {
  4804.             WorldPackets::WorldState::InitWorldStates packet;
  4805.             packet.AreaID = 5833;
  4806.             packet.MapID = 860;
  4807.             packet.SubareaID = 5736;
  4808.             packet.Worldstates.emplace_back(WorldStates::WS_ENABLE, value);
  4809.             packet.Worldstates.emplace_back(WorldStates::WS_HEALER_COUNT, healerCount);
  4810.             player->SendDirectMessage(packet.Write());            
  4811.         }
  4812.  
  4813.         void UpdateState()
  4814.         {
  4815.             for (GuidSet::iterator itr = m_player_for_event.begin(); itr != m_player_for_event.end(); ++itr)
  4816.                 if (Player* player = sObjectAccessor->FindPlayer(*itr))
  4817.                     player->SendUpdateWorldState(WorldStates::WS_HEALER_COUNT, healerCount);
  4818.         }
  4819.  
  4820.         bool CheckPlayers()
  4821.         {
  4822.             for (GuidSet::iterator itr = m_player_for_event.begin(); itr != m_player_for_event.end(); ++itr)
  4823.                 if (Player* player = sObjectAccessor->FindPlayer(*itr))
  4824.                     if (player->isAlive())
  4825.                         return true;
  4826.  
  4827.             return false;
  4828.         }
  4829.  
  4830.         void UpdatePower()
  4831.         {
  4832.             actualPower = (actualPower + healerCount <= 700) ? actualPower + healerCount: 700;
  4833.             for (GuidSet::iterator itr = m_player_for_event.begin(); itr != m_player_for_event.end(); ++itr)
  4834.                 if (Player* player = sObjectAccessor->FindPlayer(*itr))
  4835.                 {
  4836.                     if (player->isAlive())
  4837.                     {
  4838.                         if (actualPower < 700) // IN_PROGRESS
  4839.                         {
  4840.                             if (!player->HasAura(SPELL_SHEN_HEALING))
  4841.                                 player->CastSpell(player, SPELL_SHEN_HEALING, true);
  4842.  
  4843.                             player->SetPower(POWER_ALTERNATE, actualPower);
  4844.                         }
  4845.                         else
  4846.                         {
  4847.                             if (player->HasAura(SPELL_SHEN_HEALING))
  4848.                                 player->RemoveAurasDueToSpell(SPELL_SHEN_HEALING);
  4849.  
  4850.                             player->KilledMonsterCredit(NPC_SHEN_HEAL_CREDIT);
  4851.                             SendState(player, 0);
  4852.                             continue;
  4853.                         }
  4854.                     }
  4855.                    
  4856.                 }
  4857.  
  4858.             if (actualPower >= 700)
  4859.             {
  4860.                 m_player_for_event.clear();
  4861.                 Reset();
  4862.             }
  4863.         }
  4864.  
  4865.         void SummonEnnemy()
  4866.         {
  4867.             for(uint32 i = 0; i < 1; ++i)
  4868.                 me->SummonCreature(RAND(NPC_ENEMY_2, NPC_ENNEMY), ennemiesPositions[i], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 20000);
  4869.         }
  4870.  
  4871.         void SummonHealer()
  4872.         {
  4873.             Map* map = sMapMgr->CreateMap(975, NULL);
  4874.             if (!map)
  4875.                 return;
  4876.  
  4877.             float posX = frand(228.0f, 270.0f);
  4878.             float posY = frand(3949.0f, 3962.0f);
  4879.  
  4880.             me->SummonCreature(RAND(NPC_HEALER_A, NPC_HEALER_H), posX, posY, map->GetHeight(me->GetPhases(), posX, posY, 100.0f), 1.37f, TEMPSUMMON_CORPSE_DESPAWN);
  4881.         }
  4882.  
  4883.         void JustSummoned(Creature* summon)
  4884.         {
  4885.             _summons.Summon(summon);
  4886.  
  4887.             switch (summon->GetEntry())
  4888.             {
  4889.                 case NPC_HEALER_A:
  4890.                 case NPC_HEALER_H:
  4891.                      _events.RescheduleEvent(EVENT_SEND_PHASE, 1000);
  4892.                     ++healerCount;
  4893.                     break;
  4894.                 case NPC_ENNEMY:
  4895.                 case NPC_ENEMY_2:
  4896.                     AttackHealers(summon);
  4897.                     ++ennemiesCount;
  4898.                     break;
  4899.             }
  4900.         }
  4901.  
  4902.         void AttackHealers(Creature* summon)
  4903.         {
  4904.             uint32 hAttack = urand(0, healerCount - 1);
  4905.             uint32 i = 0;
  4906.             for(SummonList::iterator itr = _summons.begin(); itr != _summons.end(); ++itr)
  4907.             {
  4908.                 if ((*itr).GetEntry() == NPC_HEALER_A || (*itr).GetEntry() == NPC_HEALER_H)
  4909.                 {
  4910.                     if (Creature* healer = me->GetMap()->GetCreature(*itr))
  4911.                     {
  4912.                         if (i == hAttack)
  4913.                         {
  4914.                             summon->JumpTo(healer, 20.0f);
  4915.                             summon->AI()->AttackStart(healer);
  4916.                         }
  4917.  
  4918.                         summon->AddThreat(healer, 1000.0f);
  4919.                         ++i;
  4920.                     }
  4921.                 }
  4922.             }
  4923.         }
  4924.  
  4925.         void SummonedCreatureDespawn(Creature* summon)
  4926.         {
  4927.             _summons.Despawn(summon);
  4928.  
  4929.             switch (summon->GetEntry())
  4930.             {
  4931.                 case NPC_HEALER_A:
  4932.                 case NPC_HEALER_H:
  4933.                     _events.RescheduleEvent(EVENT_SEND_PHASE, 1000);
  4934.                     --healerCount;
  4935.                     break;
  4936.                 case NPC_ENNEMY:
  4937.                 case NPC_ENEMY_2:
  4938.                     --ennemiesCount;
  4939.                     break;
  4940.             }
  4941.         }
  4942.  
  4943.         void UpdateAI(uint32 diff)
  4944.         {
  4945.             _events.Update(diff);
  4946.  
  4947.             switch (_events.ExecuteEvent())
  4948.             {
  4949.                 case EVENT_CHECK_PLAYERS:
  4950.                 {
  4951.                     bool playerNearWithQuest = CheckPlayers();
  4952.  
  4953.                     if (inProgress && !playerNearWithQuest)
  4954.                     {
  4955.                         inProgress = false;
  4956.                         Reset();
  4957.                     }
  4958.                     else if (!inProgress && playerNearWithQuest)
  4959.                     {
  4960.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0);
  4961.                         inProgress = true;
  4962.                         _events.RescheduleEvent(EVENT_UPDATE_POWER,  UPDATE_POWER_TIMER);
  4963.                         _events.RescheduleEvent(EVENT_SUMMON_ENNEMY, 6000);
  4964.                         _events.RescheduleEvent(EVENT_SUMMON_HEALER, 5000);
  4965.                     }
  4966.                     _events.RescheduleEvent(EVENT_CHECK_PLAYERS, 5000);
  4967.                     break;
  4968.                 }
  4969.                 case EVENT_UPDATE_POWER:
  4970.                     UpdatePower();
  4971.                     _events.RescheduleEvent(EVENT_UPDATE_POWER, UPDATE_POWER_TIMER);
  4972.                     break;
  4973.                 case EVENT_SUMMON_ENNEMY:
  4974.                     if (healerCount > 0 && ennemiesCount < 5 && ennemiesCount < healerCount*2)
  4975.                         SummonEnnemy();
  4976.                     _events.RescheduleEvent(EVENT_SUMMON_ENNEMY, 7000);
  4977.                     break;
  4978.                 case EVENT_SUMMON_HEALER:
  4979.                     if (healerCount < MAX_HEALER_COUNT)
  4980.                         SummonHealer();
  4981.  
  4982.                     _events.RescheduleEvent(EVENT_SUMMON_HEALER, 12500);
  4983.                     break;
  4984.                 case EVENT_SEND_PHASE:
  4985.                     UpdateState();
  4986.                     break;
  4987.             }
  4988.         }
  4989.     };
  4990. };
  4991.  
  4992. class npc_shen_healer : public CreatureScript
  4993. {
  4994.     public:
  4995.         npc_shen_healer() : CreatureScript("npc_shen_healer") { }
  4996.  
  4997.         struct npc_shen_healerAI : public ScriptedAI
  4998.         {        
  4999.             npc_shen_healerAI(Creature* creature) : ScriptedAI(creature)
  5000.             {}
  5001.  
  5002.             void Reset()
  5003.             {
  5004.                 me->SetReactState(REACT_PASSIVE);
  5005.                 me->CastSpell(me, me->GetEntry() == NPC_HEALER_A ? SPELL_HEALER_A: SPELL_HEALER_H, true);
  5006.             }
  5007.  
  5008.             void EnterCombat(Unit*)
  5009.             {
  5010.                 return;
  5011.             }
  5012.         };
  5013.    
  5014.         CreatureAI* GetAI(Creature* creature) const
  5015.         {
  5016.             return new npc_shen_healerAI(creature);
  5017.         }
  5018. };
  5019.  
  5020. class npc_shang_xi_choose_faction : public CreatureScript
  5021. {
  5022.     public:
  5023.         npc_shang_xi_choose_faction() : CreatureScript("npc_shang_xi_choose_faction") { }
  5024.  
  5025.     bool OnGossipSelect(Player* player, Creature* /*creature*/, uint32 /*sender*/, uint32 action)
  5026.     {
  5027.         if (action == 1)
  5028.         {
  5029.             if (player->GetQuestStatus(QUSRT_NEW_FATE) == QUEST_STATUS_REWARDED ||
  5030.                 player->GetQuestStatus(QUSRT_NEW_FATE) == QUEST_STATUS_INCOMPLETE || sWorld->getBoolConfig(CONFIG_FUN_OPTION_ENABLED))
  5031.                 player->ShowNeutralPlayerFactionSelectUI();
  5032.         }
  5033.         else if (action == 2)
  5034.             player->TeleportTo(0, -8866.55f, 671.93f, 97.90f, 5.31f);
  5035.         else if (action == 3)
  5036.             player->TeleportTo(1, 1577.30f, -4453.64f, 15.68f, 1.84f);
  5037.  
  5038.         player->PlayerTalkClass->SendCloseGossip();
  5039.         return true;
  5040.     }
  5041.  
  5042.     bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
  5043.     {
  5044.         if (quest->GetQuestId() == QUSRT_NEW_FATE)
  5045.             creature->AI()->SetGUID(player->GetGUID(), 0);
  5046.  
  5047.         return true;
  5048.     }
  5049.  
  5050.     CreatureAI* GetAI(Creature* creature) const
  5051.     {
  5052.         return new npc_shang_xi_choose_factionAI(creature);
  5053.     }
  5054.  
  5055.     struct npc_shang_xi_choose_factionAI : public ScriptedAI
  5056.     {        
  5057.         npc_shang_xi_choose_factionAI(Creature* creature) : ScriptedAI(creature)
  5058.         {}
  5059.  
  5060.         EventMap events;
  5061.         ObjectGuid playerGuid;
  5062.         enum ev
  5063.         {
  5064.             EVENT_0        = 1,
  5065.             EVENT_1        = 2,
  5066.             EVENT_2        = 3,
  5067.             EVENT_3        = 4,
  5068.             EVENT_4        = 5,
  5069.             EVENT_5        = 6,
  5070.         };
  5071.  
  5072.         void SetGUID(ObjectGuid const& guid, int32 id)
  5073.         {
  5074.             playerGuid = guid;
  5075.             uint32 t = 0;
  5076.             events.RescheduleEvent(EVENT_0, t += 1000);     //18:08:37.000
  5077.             events.RescheduleEvent(EVENT_1, t += 9000);     //18:08:46.000
  5078.             events.RescheduleEvent(EVENT_2, t += 11000);    //18:08:57.000
  5079.             events.RescheduleEvent(EVENT_3, t += 7000);     //18:09:04.000
  5080.             events.RescheduleEvent(EVENT_4, t += 8000);     //18:09:12.000
  5081.             events.RescheduleEvent(EVENT_5, t += 10000);    //18:09:22.000
  5082.         }
  5083.  
  5084.         void Reset()
  5085.         {
  5086.             playerGuid.Clear();
  5087.             events.Reset();
  5088.         }
  5089.  
  5090.         void UpdateAI(uint32 diff)
  5091.         {
  5092.             events.Update(diff);
  5093.  
  5094.             if (uint32 eventId = events.ExecuteEvent())
  5095.             {
  5096.                 switch (eventId)
  5097.                 {
  5098.                     case EVENT_0:
  5099.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, playerGuid);
  5100.                         break;
  5101.                     case EVENT_1:
  5102.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1, playerGuid);
  5103.                         break;
  5104.                     case EVENT_2:
  5105.                         if (Creature* aysa = me->FindNearestCreature(57721, 100.0f, true))
  5106.                             sCreatureTextMgr->SendChat(aysa, TEXT_GENERIC_0, playerGuid);
  5107.                         break;
  5108.                     case EVENT_3:
  5109.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2, playerGuid);
  5110.                         break;
  5111.                     case EVENT_4:
  5112.                         if (Creature* czi = me->FindNearestCreature(57720, 100.0f, true))
  5113.                             sCreatureTextMgr->SendChat(czi, TEXT_GENERIC_0, playerGuid);
  5114.                         break;
  5115.                     case EVENT_5:
  5116.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_3, playerGuid);
  5117.                         break;
  5118.                 }
  5119.             }
  5120.         }
  5121.     };
  5122. };
  5123.  
  5124. // by spell 120753
  5125. class mob_garosh_hord_way : public CreatureScript
  5126. {
  5127. public:
  5128.     mob_garosh_hord_way() : CreatureScript("mob_garosh_hord_way") { }
  5129.  
  5130.     struct mob_garosh_hord_wayAI : public npc_escortAI
  5131.     {        
  5132.         mob_garosh_hord_wayAI(Creature* creature) : npc_escortAI(creature)
  5133.         {}
  5134.  
  5135.         EventMap events;
  5136.         ObjectGuid playerGuid;
  5137.         ObjectGuid CziGUID;
  5138.  
  5139.         enum dataType
  5140.         {
  5141.             NPC_CZI        = 62081,
  5142.             NPC_CREDIT     = 62089,
  5143.  
  5144.             EVENT_0        = 1,
  5145.             EVENT_1        = 2,
  5146.             EVENT_2        = 3,
  5147.             EVENT_3        = 4,
  5148.             EVENT_4        = 5,
  5149.             EVENT_5        = 6,
  5150.             EVENT_6        = 7,
  5151.             EVENT_7        = 8,
  5152.             EVENT_8        = 9,
  5153.             EVENT_9,
  5154.             EVENT_10,
  5155.             EVENT_11,
  5156.             EVENT_12,
  5157.             EVENT_13,
  5158.             EVENT_14,
  5159.             EVENT_15,
  5160.             EVENT_16,
  5161.             EVENT_17,
  5162.             EVENT_18,
  5163.             EVENT_19,
  5164.             EVENT_20,
  5165.  
  5166.             EVENT_CZI_0_1,
  5167.             EVENT_CZI_0,
  5168.             EVENT_CZI_1,
  5169.  
  5170.         };
  5171.  
  5172.         void Reset()
  5173.         {
  5174.             me->SetWalk(true);
  5175.             playerGuid.Clear();
  5176.             CziGUID.Clear();
  5177.         }
  5178.  
  5179.         void IsSummonedBy(Unit* summoner)
  5180.         {
  5181.             Player *player = summoner->ToPlayer();
  5182.             if (!player)
  5183.             {
  5184.                 me->MonsterSay("SCRIPT::mob_garosh_hord_way summoner is not player", LANG_UNIVERSAL, ObjectGuid::Empty);
  5185.                 return;
  5186.             }
  5187.  
  5188.             playerGuid = summoner->GetGUID();
  5189.             me->AddPlayerInPersonnalVisibilityList(summoner->GetGUID());
  5190.  
  5191.             uint32 t = 0;                                        //
  5192.             events.RescheduleEvent(EVENT_0, t += 2000);            //18:12:24.000 start + talk
  5193.             events.RescheduleEvent(EVENT_1, t += 5000);            //18:12:29.000
  5194.             events.RescheduleEvent(EVENT_2, t += 8000);            //18:12:37.000
  5195.             events.RescheduleEvent(EVENT_3, t += 6000);            //18:12:43.000
  5196.             events.RescheduleEvent(EVENT_4, t += 5000);            //18:12:48.000
  5197.             events.RescheduleEvent(EVENT_5, t += 5000);            //18:12:54.000
  5198.             events.RescheduleEvent(EVENT_6, t += 1000);            //18:12:55.000
  5199.             events.RescheduleEvent(EVENT_7, t += 2000);            //18:12:57.000
  5200.             events.RescheduleEvent(EVENT_8, t += 9000);            //18:13:06.000
  5201.             events.RescheduleEvent(EVENT_CZI_0, t += 3000);        //18:13:09.000 Message: Š, 㯦弮
  5202.             events.RescheduleEvent(EVENT_9, t += 3000);            //18:13:12.000
  5203.             events.RescheduleEvent(EVENT_10, t += 3000);           //18:13:15.000
  5204.             events.RescheduleEvent(EVENT_11, t += 8000);           //18:13:23.000
  5205.             events.RescheduleEvent(EVENT_12, t += 6000);           //18:13:29.000
  5206.             events.RescheduleEvent(EVENT_13, t += 5000);           //18:13:34.000
  5207.             events.RescheduleEvent(EVENT_14, t += 13000);          //18:13:47.000
  5208.             events.RescheduleEvent(EVENT_15, t += 5000);           //18:13:52.000
  5209.             events.RescheduleEvent(EVENT_16, t += 11000);          //18:14:03.000
  5210.             events.RescheduleEvent(EVENT_CZI_1, t += 3000);        //18:14:06.000 Message: Š... Š, 믭渭.
  5211.             events.RescheduleEvent(EVENT_17, t += 4000);           //18:14:10.000
  5212.             events.RescheduleEvent(EVENT_18, t += 1000);           //18:14:11.000
  5213.             events.RescheduleEvent(EVENT_19, t += 2000);           //18:14:13.000
  5214.             //events.RescheduleEvent(EVENT_20, t += 20000);           //18:14:33.000
  5215.         }
  5216.  
  5217.         void WaypointReached(uint32 waypointId)
  5218.         {
  5219.             switch(waypointId)
  5220.             {
  5221.                 case 3:
  5222.                 case 6:
  5223.                 case 7:
  5224.                 case 12:
  5225.                 case 13:
  5226.                 case 16:
  5227.                 if (Player* target = sObjectAccessor->FindPlayer(playerGuid))
  5228.                     me->SetFacingToObject(target);
  5229.                     SetEscortPaused(true);
  5230.                     break;
  5231.                 case 26:
  5232.                     events.RescheduleEvent(EVENT_20, 1000);           //18:14:33.000
  5233.                     SetEscortPaused(true);
  5234.                     break;
  5235.             }
  5236.         }
  5237.  
  5238.         void initSummon()
  5239.         {
  5240.             if (Player* target = sObjectAccessor->FindPlayer(playerGuid))
  5241.                 if (Creature* czi = me->FindNearestCreature(NPC_CZI, 200.0f, true))
  5242.                 {
  5243.                     czi->GetMotionMaster()->MoveFollow(target, 2.0f, M_PI / 4);
  5244.                     CziGUID = czi->GetGUID();
  5245.                 }
  5246.         }
  5247.  
  5248.         void UpdateAI(uint32 diff)
  5249.         {
  5250.             events.Update(diff);
  5251.             npc_escortAI::UpdateAI(diff);
  5252.  
  5253.             if (uint32 eventId = events.ExecuteEvent())
  5254.             {
  5255.                 switch(eventId)
  5256.                 {
  5257.                     case EVENT_0:
  5258.                         Start(false, false);
  5259.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_0, playerGuid);
  5260.                         initSummon();
  5261.                         break;
  5262.                     case EVENT_1:
  5263.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_1, playerGuid);
  5264.                         break;
  5265.                     case EVENT_2:
  5266.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_2, playerGuid);
  5267.                         break;
  5268.                     case EVENT_3:
  5269.                         SetEscortPaused(false);
  5270.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_3, playerGuid);
  5271.                         break;
  5272.                     case EVENT_4:
  5273.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_4, playerGuid);
  5274.                         break;
  5275.                     case EVENT_5:
  5276.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_5, playerGuid);
  5277.                         break;
  5278.                     case EVENT_6:
  5279.                         SetEscortPaused(false);
  5280.                         break;
  5281.                     case EVENT_7:
  5282.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_6, playerGuid);
  5283.                         break;
  5284.                     case EVENT_8:
  5285.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_7, playerGuid);
  5286.                         if (Creature* zu = me->GetMap()->GetCreature(CziGUID))
  5287.                             me->SetFacingToObject(zu);
  5288.                         break;
  5289.                     case EVENT_9:
  5290.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_8, playerGuid);
  5291.                         break;
  5292.                     case EVENT_10:
  5293.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_9, playerGuid);
  5294.                         SetEscortPaused(false);
  5295.                         break;
  5296.                     case EVENT_11:
  5297.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_10, playerGuid);
  5298.                         break;
  5299.                     case EVENT_12:
  5300.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_11, playerGuid);
  5301.                         break;
  5302.                     case EVENT_13:
  5303.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_12, playerGuid);
  5304.                         SetEscortPaused(false);
  5305.                         break;
  5306.                     case EVENT_14:
  5307.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_13, playerGuid);
  5308.                         SetEscortPaused(false);
  5309.                         break;
  5310.                     case EVENT_15:
  5311.                         me->HandleEmoteCommand(397);
  5312.                         break;
  5313.                     case EVENT_16:
  5314.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_14, playerGuid);
  5315.                         if (Creature* zu = me->GetMap()->GetCreature(CziGUID))
  5316.                             me->SetFacingToObject(zu);
  5317.                         break;
  5318.                     case EVENT_17:
  5319.                         break;
  5320.                     case EVENT_18:
  5321.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_15, playerGuid);
  5322.                         break;
  5323.                     case EVENT_19:
  5324.                         sCreatureTextMgr->SendChat(me, TEXT_GENERIC_16, playerGuid);
  5325.                         SetEscortPaused(false);
  5326.                         if (Player* plr = sObjectAccessor->FindPlayer(playerGuid))
  5327.                             plr->KilledMonsterCredit(NPC_CREDIT, ObjectGuid::Empty);
  5328.                         break;
  5329.                     case EVENT_20:
  5330.                         me->SetUInt32Value(UNIT_FIELD_MOUNT_DISPLAY_ID, 17719);
  5331.                         me->SetSpeed(MOVE_RUN, 8.0f, false);
  5332.                         me->SetUInt32Value(UNIT_FIELD_EMOTE_STATE, 0x3000000);
  5333.                         me->DespawnOrUnsummon(10000);
  5334.                         if (Creature* zu = me->GetMap()->GetCreature(CziGUID))
  5335.                             zu->DespawnOrUnsummon(10000);
  5336.                         break;
  5337.                     case EVENT_CZI_0:
  5338.                         if (Creature* zu = me->GetMap()->GetCreature(CziGUID))
  5339.                             sCreatureTextMgr->SendChat(zu, TEXT_GENERIC_3, playerGuid);
  5340.                         break;
  5341.                     case EVENT_CZI_1:
  5342.                         if (Creature* zu = me->GetMap()->GetCreature(CziGUID))
  5343.                             sCreatureTextMgr->SendChat(zu, TEXT_GENERIC_4, playerGuid);
  5344.                         break;
  5345.                 }
  5346.             }
  5347.         }
  5348.     };
  5349.    
  5350.     CreatureAI* GetAI(Creature* creature) const
  5351.     {
  5352.         return new mob_garosh_hord_wayAI(creature);
  5353.     }
  5354.    
  5355. };
  5356. void AddSC_WanderingIsland()
  5357. {
  5358.     new mob_tushui_trainee();
  5359.     new mob_master_shang_xi();
  5360.     new boss_jaomin_ro();
  5361.     new npc_panda_announcer();
  5362.     new mob_attacker_dimwind();
  5363.     new mob_min_dimwind();
  5364.     new npc_min_dimwind_outro();
  5365.     new mob_aysa_lake_escort();
  5366.     new mob_aysa();
  5367.     new boss_living_air();
  5368.     new boss_li_fei();
  5369.     new boss_li_fei_fight();
  5370.     new AreaTrigger_at_temple_entrance();
  5371.     // east
  5372.     new at_going_to_east();
  5373.     new npc_childrens_going_to_east();
  5374.     new AreaTrigger_at_bassin_curse();
  5375.     new vehicle_balance_pole();
  5376.     new mob_tushui_monk();
  5377.     new mob_jojo_ironbrow_1();
  5378.     new spell_rock_jump();
  5379.     new mob_shu_water_spirit();
  5380.     new spell_summon_spirit_of_watter();
  5381.     new mob_aysa_cloudsinger_watter_outro();
  5382.     new spell_grab_carriage();
  5383.     new vehicle_carriage();
  5384.     new npc_nourished_yak();
  5385.     new mob_jojo_ironbrow_2();
  5386.     new npc_water_spirit_dailo();
  5387.     new AreaTrigger_at_middle_temple_from_east();
  5388.     // west
  5389.     new mob_master_shang_xi_temple();
  5390.     new npc_wind_vehicle();
  5391.     new npc_panda_history_leason();
  5392.     new mob_jojo_ironbrow_3();
  5393.     new mob_huojin_monk();
  5394.     new spell_summon_ji_yung();
  5395.     new mob_jojo_ironbrow_4();
  5396.     new AreaTrigger_at_wind_temple_entrance();
  5397.     new mob_aysa_wind_temple_escort();
  5398.     new mob_frightened_wind();
  5399.     new boss_zhao_ren();
  5400.     new npc_rocket_launcher();
  5401.     new mob_master_shang_xi_after_zhao_escort();
  5402.     new mob_master_shang_xi_thousand_staff();
  5403.     new mob_aisa_pre_balon_event();
  5404.     new mop_air_balloon();
  5405.     // south
  5406.     new mob_mandori_triger();
  5407.     new mob_mandori_escort();
  5408.     new npc_ji_yuan();
  5409.     new npc_injured_sailor_rescue_controller();
  5410.     new npc_hurted_soldier();
  5411.     new boss_vordraka();
  5412.     new npc_aysa_cloudsinger();
  5413.     new mob_aysa_gunship_crash_escort();
  5414.     new npc_ji_end_event();
  5415.     new npc_shen_healer();
  5416.     new npc_shang_xi_choose_faction();
  5417.     new mob_garosh_hord_way();
  5418. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement