Advertisement
Guest User

Halls of Reflection

a guest
Nov 4th, 2012
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 160.31 KB | None | 0 0
  1. diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
  2. index 39b5dce..bdda79f 100755
  3. --- a/src/server/game/Scripting/ScriptLoader.cpp
  4. +++ b/src/server/game/Scripting/ScriptLoader.cpp
  5. @@ -485,6 +485,7 @@ void AddSC_instance_halls_of_reflection();   // Halls of Reflection
  6.  void AddSC_halls_of_reflection();
  7.  void AddSC_boss_falric();
  8.  void AddSC_boss_marwyn();
  9. +void AddSC_boss_lich_king_hr();
  10.  void AddSC_boss_lord_marrowgar();       // Icecrown Citadel
  11.  void AddSC_boss_lady_deathwhisper();
  12.  void AddSC_boss_deathbringer_saurfang();
  13. @@ -1208,6 +1209,7 @@ void AddNorthrendScripts()
  14.      AddSC_halls_of_reflection();
  15.      AddSC_boss_falric();
  16.      AddSC_boss_marwyn();
  17. +   AddSC_boss_lich_king_hr();
  18.      AddSC_boss_lord_marrowgar();        // Icecrown Citadel
  19.      AddSC_boss_lady_deathwhisper();
  20.      AddSC_boss_deathbringer_saurfang();
  21. diff --git a/src/server/scripts/Northrend/CMakeLists.txt b/src/server/scripts/Northrend/CMakeLists.txt
  22. index 22d0f37..c2977d5 100644
  23. --- a/src/server/scripts/Northrend/CMakeLists.txt
  24. +++ b/src/server/scripts/Northrend/CMakeLists.txt
  25. @@ -54,6 +54,7 @@ set(scripts_STAT_SRCS
  26.    Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp
  27.    Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.h
  28.    Northrend/FrozenHalls/HallsOfReflection/boss_falric.cpp
  29. +  Northrend/FrozenHalls/HallsOfReflection/boss_the_lich_king_hor.cpp
  30.    Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp
  31.    Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp
  32.    Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp
  33. diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_falric.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_falric.cpp
  34. index 4df13d3..67a69ee 100644
  35. --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_falric.cpp
  36. +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_falric.cpp
  37. @@ -1,49 +1,50 @@
  38.  /*
  39. - * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
  40. + * Copyright (C) 2008 - 2012 Trinity <http://www.trinitycore.org/>
  41. + * Copyright (C) 2008 - 2012 Facecore <https://github.com/SignFinder/FaceCore/>
  42.   *
  43. - * This program is free software; you can redistribute it and/or modify it
  44. - * under the terms of the GNU General Public License as published by the
  45. - * Free Software Foundation; either version 2 of the License, or (at your
  46. - * option) any later version.
  47. + * This program is free software; you can redistribute it and/or modify
  48. + * it under the terms of the GNU General Public License as published by
  49. + * the Free Software Foundation; either version 2 of the License, or
  50. + * (at your option) any later version.
  51.   *
  52. - * This program is distributed in the hope that it will be useful, but WITHOUT
  53. - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  54. - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  55. - * more details.
  56. + * This program is distributed in the hope that it will be useful,
  57. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  58. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  59. + * GNU General Public License for more details.
  60.   *
  61. - * You should have received a copy of the GNU General Public License along
  62. - * with this program. If not, see <http://www.gnu.org/licenses/>.
  63. + * You should have received a copy of the GNU General Public License
  64. + * along with this program; if not, write to the Free Software
  65. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  66.   */
  67.  
  68. + /* ScriptData
  69. + SDName: boss_falric
  70. + SD%Complete: 0%
  71. + SDComment: new script for tc implementation.
  72. + SDCategory: Halls of Reflection
  73. + EndScriptData */
  74. +
  75.  #include "ScriptMgr.h"
  76.  #include "ScriptedCreature.h"
  77.  #include "halls_of_reflection.h"
  78.  
  79. -enum Yells
  80. +enum
  81.  {
  82. -    SAY_AGGRO                                     = -1668050,
  83. -    SAY_SLAY_1                                    = -1668051,
  84. -    SAY_SLAY_2                                    = -1668052,
  85. -    SAY_DEATH                                     = -1668053,
  86. -    SAY_IMPENDING_DESPAIR                         = -1668054,
  87. -    SAY_DEFILING_HORROR                           = -1668055,
  88. -};
  89. +    SAY_FALRIC_AGGRO                        = -1668050,
  90. +    SAY_FALRIC_DEATH                        = -1668053,
  91. +    SAY_FALRIC_SLAY01                       = -1668051,
  92. +    SAY_FALRIC_SLAY02                       = -1668052,
  93. +    SAY_FALRIC_SP01                         = -1668054,
  94. +    SAY_FALRIC_SP02                         = -1668055,
  95.  
  96. -enum Spells
  97. -{
  98. -    SPELL_QUIVERING_STRIKE                        = 72422,
  99. -    SPELL_IMPENDING_DESPAIR                       = 72426,
  100. -    SPELL_DEFILING_HORROR                         = 72435,
  101. -    SPELL_HOPELESSNESS                            = 72395,
  102. -    H_SPELL_HOPELESSNESS                          = 72390, // TODO: not in dbc. Add in DB.
  103. -};
  104. +    SPELL_HOPELESSNESS                      = 72395,
  105. +    SPELL_IMPENDING_DESPAIR                 = 72426,
  106. +    SPELL_DEFILING_HORROR_N                 = 72435,
  107. +    SPELL_DEFILING_HORROR_H                 = 72452,
  108. +    SPELL_QUIVERING_STRIKE_N                = 72422,
  109. +    SPELL_QUIVERING_STRIKE_H                = 72453,
  110.  
  111. -enum Events
  112. -{
  113. -    EVENT_NONE,
  114. -    EVENT_QUIVERING_STRIKE,
  115. -    EVENT_IMPENDING_DESPAIR,
  116. -    EVENT_DEFILING_HORROR,
  117. +    SPELL_BERSERK                           = 47008
  118.  };
  119.  
  120.  class boss_falric : public CreatureScript
  121. @@ -51,94 +52,216 @@ class boss_falric : public CreatureScript
  122.  public:
  123.      boss_falric() : CreatureScript("boss_falric") { }
  124.  
  125. -    CreatureAI* GetAI(Creature* creature) const
  126. +    struct boss_falricAI : public ScriptedAI
  127.      {
  128. -        return new boss_falricAI(creature);
  129. -    }
  130. +        boss_falricAI(Creature *pCreature) : ScriptedAI(pCreature)
  131. +       {
  132. +            m_pInstance = (InstanceScript*)pCreature->GetInstanceScript();
  133. +            Regular = pCreature->GetMap()->IsRegularDifficulty();
  134. +            Reset();
  135. +       }
  136.  
  137. -    struct boss_falricAI : public boss_horAI
  138. -    {
  139. -        boss_falricAI(Creature* creature) : boss_horAI(creature) {}
  140. +       InstanceScript* m_pInstance;
  141. +       bool Regular;
  142. +       bool m_bIsCall;
  143. +       //FUNCTIONS
  144. +       uint32 m_uiBerserkTimer;
  145. +       uint32 m_uiGrowlTimer;
  146. +       uint32 m_uiHorrorTimer;
  147. +       uint32 m_uiStrikeTimer;
  148. +       uint32 m_uiSummonTimer;
  149. +       uint32 m_uiLocNo;
  150. +       uint64 m_uiSummonGUID[16];
  151. +       uint32 m_uiCheckSummon;
  152.  
  153. -        uint8 uiHopelessnessCount;
  154. +       uint8 SummonCount;
  155. +
  156. +       uint64 pSummon;
  157.  
  158.          void Reset()
  159.          {
  160. -            boss_horAI::Reset();
  161. +          m_uiBerserkTimer = 180000;
  162. +          SummonCount = 0;
  163. +          m_bIsCall = false;
  164. +          m_uiGrowlTimer = 20000;
  165. +          m_uiHorrorTimer = urand(14000,20000);
  166. +          m_uiStrikeTimer = 2000;
  167. +          m_uiSummonTimer = 11000;
  168. +          me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  169. +          me->SetVisible(false);
  170. +        }
  171.  
  172. -            uiHopelessnessCount = 0;
  173. +        void EnterCombat(Unit* victim)
  174. +        {
  175. +          //me->RemoveFlag(MOVEFLAG_WALK, NULL);
  176. +          DoScriptText(SAY_FALRIC_AGGRO, me);
  177. +          DoCast(me, SPELL_HOPELESSNESS);
  178. +        }
  179.  
  180. -            if (instance)
  181. -                instance->SetData(DATA_FALRIC_EVENT, NOT_STARTED);
  182. +        void KilledUnit(Unit* victim)
  183. +        {
  184. +            switch(urand(0,1))
  185. +            {
  186. +                case 0: DoScriptText(SAY_FALRIC_SLAY01, me); break;
  187. +                case 1: DoScriptText(SAY_FALRIC_SLAY02, me); break;
  188. +            }
  189.          }
  190.  
  191. -        void EnterCombat(Unit* /*who*/)
  192. +        void JustDied(Unit* pKiller)
  193.          {
  194. -            DoScriptText(SAY_AGGRO, me);
  195. -            if (instance)
  196. -                instance->SetData(DATA_FALRIC_EVENT, IN_PROGRESS);
  197. +          if(!m_pInstance) return;
  198. +             m_pInstance->SetData(TYPE_MARWYN, SPECIAL);
  199. +          DoScriptText(SAY_FALRIC_DEATH, me);
  200. +        }
  201. +
  202. +        void AttackStart(Unit* who)
  203. +        {
  204. +            if(!m_pInstance) return;
  205. +
  206. +               if(m_pInstance->GetData(TYPE_FALRIC) != IN_PROGRESS)
  207. +                 return;
  208.  
  209. -            events.ScheduleEvent(EVENT_QUIVERING_STRIKE, 23000);
  210. -            events.ScheduleEvent(EVENT_IMPENDING_DESPAIR, 9000);
  211. -            events.ScheduleEvent(EVENT_DEFILING_HORROR, urand(25000, 45000)); // TODO adjust timer.
  212. +             ScriptedAI::AttackStart(who);
  213.          }
  214.  
  215. -        void JustDied(Unit* /*killer*/)
  216. +        void Summon()
  217.          {
  218. -            DoScriptText(SAY_DEATH, me);
  219. +             m_uiLocNo = 0;
  220.  
  221. -            if (instance)
  222. -                instance->SetData(DATA_FALRIC_EVENT, DONE);
  223. +             for(uint8 i = 0; i < 14; i++)
  224. +             {
  225. +                switch(urand(0,3))
  226. +                {
  227. +                   case 0:
  228. +                       switch(urand(1, 3))
  229. +                       {
  230. +                         case 1: pSummon = NPC_DARK_1; break;
  231. +                         case 2: pSummon = NPC_DARK_3; break;
  232. +                         case 3: pSummon = NPC_DARK_6; break;
  233. +                       }
  234. +                       break;
  235. +                   case 1:
  236. +                       switch(urand(1, 3))
  237. +                       {
  238. +                         case 1: pSummon = NPC_DARK_2; break;
  239. +                         case 2: pSummon = NPC_DARK_3; break;
  240. +                         case 3: pSummon = NPC_DARK_4; break;
  241. +                       }
  242. +                       break;
  243. +                   case 2:
  244. +                       switch(urand(1, 3))
  245. +                       {
  246. +                         case 1: pSummon = NPC_DARK_2; break;
  247. +                         case 2: pSummon = NPC_DARK_5; break;
  248. +                         case 3: pSummon = NPC_DARK_6; break;
  249. +                       }
  250. +                       break;
  251. +                   case 3:
  252. +                       switch(urand(1, 3))
  253. +                       {
  254. +                         case 1: pSummon = NPC_DARK_1; break;
  255. +                         case 2: pSummon = NPC_DARK_5; break;
  256. +                         case 3: pSummon = NPC_DARK_4; break;
  257. +                       }
  258. +                       break;
  259. +                 }
  260. +
  261. +                 m_uiCheckSummon = 0;
  262. +
  263. +                 if(Creature* Summon = me->SummonCreature(pSummon, SpawnLoc[m_uiLocNo].x, SpawnLoc[m_uiLocNo].y, SpawnLoc[m_uiLocNo].z, SpawnLoc[m_uiLocNo].o, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000))
  264. +                 {
  265. +                    m_uiSummonGUID[i] = Summon->GetGUID();
  266. +                    Summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  267. +                    Summon->setFaction(974);
  268. +                    Summon->SetReactState(REACT_PASSIVE);
  269. +                 }
  270. +                 m_uiLocNo++;
  271. +             }
  272.          }
  273.  
  274. -        void KilledUnit(Unit* /*victim*/)
  275. +        void CallFallSoldier()
  276.          {
  277. -            DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), me);
  278. +             for(uint8 i = 0; i < 4; i++)
  279. +             {
  280. +                if(Creature* Summon = m_pInstance->instance->GetCreature(m_uiSummonGUID[m_uiCheckSummon]))
  281. +                {
  282. +                   Summon->setFaction(14);
  283. +                   Summon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  284. +                   Summon->SetReactState(REACT_AGGRESSIVE);
  285. +                   Summon->SetInCombatWithZone();
  286. +                }
  287. +                m_uiCheckSummon++;
  288. +             }
  289.          }
  290.  
  291. -        void UpdateAI(const uint32 diff)
  292. +        void UpdateAI(const uint32 uiDiff)
  293.          {
  294. -            // Return since we have no target
  295. -            if (!UpdateVictim())
  296. -                return;
  297. +            if(!m_pInstance) return;
  298.  
  299. -            events.Update(diff);
  300. +            if (m_pInstance->GetData(TYPE_FALRIC) == SPECIAL)
  301. +            {
  302. +                if(!m_bIsCall)
  303. +                {
  304. +                   m_bIsCall = true;
  305. +                   Summon();
  306. +                }
  307.  
  308. -            if (me->HasUnitState(UNIT_STATE_CASTING))
  309. +                if (m_uiSummonTimer < uiDiff)
  310. +                {
  311. +                        ++SummonCount;
  312. +                        if(SummonCount > 4)
  313. +                        {
  314. +                            m_pInstance->SetData(TYPE_FALRIC, IN_PROGRESS);
  315. +                            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  316. +                            me->SetInCombatWithZone();
  317. +                        }
  318. +                        else CallFallSoldier();
  319. +                        m_uiSummonTimer = 60000;
  320. +                } else m_uiSummonTimer -= uiDiff;
  321. +            }
  322. +
  323. +            if (!UpdateVictim())
  324.                  return;
  325.  
  326. -            switch (events.ExecuteEvent())
  327. +            if(m_uiStrikeTimer < uiDiff)
  328.              {
  329. -                case EVENT_QUIVERING_STRIKE:
  330. -                    DoCast(SPELL_QUIVERING_STRIKE);
  331. -                    events.ScheduleEvent(EVENT_QUIVERING_STRIKE, 10000);
  332. -                    break;
  333. -                case EVENT_IMPENDING_DESPAIR:
  334. -                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  335. -                    {
  336. -                        DoScriptText(SAY_IMPENDING_DESPAIR, me);
  337. -                        DoCast(target, SPELL_IMPENDING_DESPAIR);
  338. -                    }
  339. -                    events.ScheduleEvent(EVENT_IMPENDING_DESPAIR, 13000);
  340. -                    break;
  341. -                case EVENT_DEFILING_HORROR:
  342. -                    DoCast(SPELL_DEFILING_HORROR);
  343. -                    events.ScheduleEvent(EVENT_DEFILING_HORROR, urand(25000, 45000)); // TODO adjust timer.
  344. -                    break;
  345. +                DoCast(me->getVictim(), Regular ? SPELL_QUIVERING_STRIKE_N : SPELL_QUIVERING_STRIKE_H);
  346. +                m_uiStrikeTimer = (urand(7000, 14000));
  347.              }
  348. +            else m_uiStrikeTimer -= uiDiff;
  349.  
  350. -            if ((uiHopelessnessCount < 1 && HealthBelowPct(66))
  351. -                || (uiHopelessnessCount < 2 && HealthBelowPct(33))
  352. -                || (uiHopelessnessCount < 3 && HealthBelowPct(10)))
  353. +            if(m_uiHorrorTimer < uiDiff)
  354.              {
  355. -                uiHopelessnessCount++;
  356. -                DoCast(DUNGEON_MODE(SPELL_HOPELESSNESS, H_SPELL_HOPELESSNESS));
  357. +                DoScriptText(SAY_FALRIC_SP01, me);
  358. +                if(Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  359. +                   DoCast(pTarget, SPELL_IMPENDING_DESPAIR);
  360. +                m_uiHorrorTimer = (urand(15000, 25000));
  361.              }
  362. +            else m_uiHorrorTimer -= uiDiff;
  363.  
  364. -            DoMeleeAttackIfReady();
  365. +            if(m_uiGrowlTimer < uiDiff)
  366. +            {
  367. +                DoScriptText(SAY_FALRIC_SP02, me);
  368. +                DoCast(me->getVictim(), Regular ? SPELL_DEFILING_HORROR_N : SPELL_DEFILING_HORROR_H);
  369. +                m_uiGrowlTimer = (urand(25000, 30000));
  370. +            }
  371. +            else m_uiGrowlTimer -= uiDiff;
  372. +
  373. +            if (m_uiBerserkTimer < uiDiff)
  374. +            {
  375. +                DoCast(me, SPELL_BERSERK);
  376. +                m_uiBerserkTimer = 180000;
  377. +            } else  m_uiBerserkTimer -= uiDiff;
  378. +
  379. +            DoMeleeAttackIfReady();  
  380. +
  381. +            return;
  382.          }
  383.      };
  384. -
  385. +    CreatureAI* GetAI(Creature* pCreature) const
  386. +    {
  387. +        return new boss_falricAI(pCreature);
  388. +    }
  389.  };
  390.  
  391.  void AddSC_boss_falric()
  392. diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp
  393. index 8334a19..56af661 100644
  394. --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp
  395. +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp
  396. @@ -1,49 +1,52 @@
  397.  /*
  398. - * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
  399. + * Copyright (C) 2008 - 2012 Trinity <http://www.trinitycore.org/>
  400. + * Copyright (C) 2008 - 2012 Facecore <https://github.com/SignFinder/FaceCore/>
  401.   *
  402. - * This program is free software; you can redistribute it and/or modify it
  403. - * under the terms of the GNU General Public License as published by the
  404. - * Free Software Foundation; either version 2 of the License, or (at your
  405. - * option) any later version.
  406. + * This program is free software; you can redistribute it and/or modify
  407. + * it under the terms of the GNU General Public License as published by
  408. + * the Free Software Foundation; either version 2 of the License, or
  409. + * (at your option) any later version.
  410.   *
  411. - * This program is distributed in the hope that it will be useful, but WITHOUT
  412. - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  413. - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  414. - * more details.
  415. + * This program is distributed in the hope that it will be useful,
  416. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  417. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  418. + * GNU General Public License for more details.
  419.   *
  420. - * You should have received a copy of the GNU General Public License along
  421. - * with this program. If not, see <http://www.gnu.org/licenses/>.
  422. + * You should have received a copy of the GNU General Public License
  423. + * along with this program; if not, write to the Free Software
  424. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  425.   */
  426.  
  427. + /* ScriptData
  428. + SDName: boss_Marwyn
  429. + SD%Complete: 0%
  430. + SDComment: new script for tc implementation.
  431. + SDCategory: Halls of Reflection
  432. + EndScriptData */
  433. +
  434.  #include "ScriptMgr.h"
  435.  #include "ScriptedCreature.h"
  436.  #include "halls_of_reflection.h"
  437.  
  438. -enum Yells
  439. +enum
  440.  {
  441. -    SAY_AGGRO                                     = -1668060,
  442. -    SAY_SLAY_1                                    = -1668061,
  443. -    SAY_SLAY_2                                    = -1668062,
  444. -    SAY_DEATH                                     = -1668063,
  445. -    SAY_CORRUPTED_FLESH_1                         = -1668064,
  446. -    SAY_CORRUPTED_FLESH_2                         = -1668065,
  447. -};
  448. +    SAY_MARWYN_INTRO                        = -1594506,
  449. +    SAY_MARWYN_AGGRO                        = -1668060,
  450. +    SAY_MARWYN_DEATH                        = -1668063,
  451. +    SAY_MARWYN_SLAY01                       = -1668061,
  452. +    SAY_MARWYN_SLAY02                       = -1668062,
  453. +    SAY_MARWYN_SP01                         = -1668064,
  454. +    SAY_MARWYN_SP02                         = -1668065,
  455.  
  456. -enum Spells
  457. -{
  458. -    SPELL_OBLITERATE                              = 72360,
  459. -    SPELL_WELL_OF_CORRUPTION                      = 72362,
  460. -    SPELL_CORRUPTED_FLESH                         = 72363,
  461. -    SPELL_SHARED_SUFFERING                        = 72368,
  462. -};
  463. +    SPELL_OBLITERATE_N                      = 72360,
  464. +    SPELL_OBLITERATE_H                      = 72434,
  465. +    SPELL_SHARED_SUFFERING_N                = 72368,
  466. +    SPELL_SHARED_SUFFERING_H                = 72369,
  467. +    SPELL_WELL_OF_CORRUPTION                = 72362,
  468. +    SPELL_CORRUPTED_FLESH_N                 = 72363,
  469. +    SPELL_CORRUPTED_FLESH_H                 = 72436,
  470.  
  471. -enum Events
  472. -{
  473. -    EVENT_NONE,
  474. -    EVENT_OBLITERATE,
  475. -    EVENT_WELL_OF_CORRUPTION,
  476. -    EVENT_CORRUPTED_FLESH,
  477. -    EVENT_SHARED_SUFFERING,
  478. +    SPELL_BERSERK                           = 47008,
  479.  };
  480.  
  481.  class boss_marwyn : public CreatureScript
  482. @@ -51,84 +54,238 @@ class boss_marwyn : public CreatureScript
  483.  public:
  484.      boss_marwyn() : CreatureScript("boss_marwyn") { }
  485.  
  486. -    CreatureAI* GetAI(Creature* creature) const
  487. +    struct boss_marwynAI : public ScriptedAI
  488.      {
  489. -        return new boss_marwynAI(creature);
  490. -    }
  491. +       boss_marwynAI(Creature *pCreature) : ScriptedAI(pCreature)
  492. +       {
  493. +            m_pInstance = (InstanceScript*)pCreature->GetInstanceScript();
  494. +            Regular = pCreature->GetMap()->IsRegularDifficulty();
  495. +            Reset();
  496. +       }
  497.  
  498. -    struct boss_marwynAI : public boss_horAI
  499. -    {
  500. -        boss_marwynAI(Creature* creature) : boss_horAI(creature) {}
  501. +       InstanceScript* m_pInstance;
  502. +       bool Regular;
  503. +       bool m_bIsCall;
  504. +
  505. +       //FUNCTIONS
  506. +       uint32 m_uiBerserkTimer;
  507. +       uint32 m_uiSharedSufferingTimer;
  508. +       uint32 m_uiWellTimer;
  509. +       uint32 m_uiTouchTimer;
  510. +       uint32 m_uiFleshTimer;
  511. +       uint32 m_uiObliterateTimer;
  512. +       uint32 m_uiSummonTimer;
  513. +
  514. +       uint32 m_uiLocNo;
  515. +       uint64 m_uiSummonGUID[16];
  516. +       uint32 m_uiCheckSummon;
  517. +
  518. +       uint8 SummonCount;
  519. +
  520. +       uint64 pSummon;
  521.  
  522. -        void Reset()
  523. +       void Reset()
  524. +       {
  525. +          m_uiBerserkTimer = 180000;
  526. +          m_uiSharedSufferingTimer = 4000;
  527. +          m_uiWellTimer = 12000;
  528. +          m_uiTouchTimer = 8000;
  529. +          m_uiFleshTimer = 21000;
  530. +          m_uiObliterateTimer = 5000;
  531. +          SummonCount = 0;
  532. +          m_bIsCall = false;
  533. +          m_uiSummonTimer = 15000;
  534. +          me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  535. +          me->SetVisible(false);
  536. +        }
  537. +
  538. +        void Summon()
  539.          {
  540. -            boss_horAI::Reset();
  541. +             m_uiLocNo = 14;
  542. +
  543. +             for(uint8 i = 0; i < 14; i++)
  544. +             {
  545. +                switch(urand(0,3))
  546. +                {
  547. +                   case 0:
  548. +                       switch(urand(1, 3))
  549. +                       {
  550. +                         case 1: pSummon = NPC_DARK_1; break;
  551. +                         case 2: pSummon = NPC_DARK_3; break;
  552. +                         case 3: pSummon = NPC_DARK_6; break;
  553. +                       }
  554. +                       break;
  555. +                   case 1:
  556. +                       switch(urand(1, 3))
  557. +                       {
  558. +                         case 1: pSummon = NPC_DARK_2; break;
  559. +                         case 2: pSummon = NPC_DARK_3; break;
  560. +                         case 3: pSummon = NPC_DARK_4; break;
  561. +                       }
  562. +                       break;
  563. +                   case 2:
  564. +                       switch(urand(1, 3))
  565. +                       {
  566. +                         case 1: pSummon = NPC_DARK_2; break;
  567. +                         case 2: pSummon = NPC_DARK_5; break;
  568. +                         case 3: pSummon = NPC_DARK_6; break;
  569. +                       }
  570. +                       break;
  571. +                   case 3:
  572. +                       switch(urand(1, 3))
  573. +                       {
  574. +                         case 1: pSummon = NPC_DARK_1; break;
  575. +                         case 2: pSummon = NPC_DARK_5; break;
  576. +                         case 3: pSummon = NPC_DARK_4; break;
  577. +                       }
  578. +                       break;
  579. +                 }
  580.  
  581. -            if (instance)
  582. -                instance->SetData(DATA_MARWYN_EVENT, NOT_STARTED);
  583. +                 m_uiCheckSummon = 0;
  584. +
  585. +                 if(Creature* Summon = me->SummonCreature(pSummon, SpawnLoc[m_uiLocNo].x, SpawnLoc[m_uiLocNo].y, SpawnLoc[m_uiLocNo].z, SpawnLoc[m_uiLocNo].o, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000))
  586. +                 {
  587. +                    m_uiSummonGUID[i] = Summon->GetGUID();
  588. +                    Summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  589. +                    Summon->SetReactState(REACT_PASSIVE);
  590. +                    Summon->setFaction(974);
  591. +                 }
  592. +                 m_uiLocNo++;
  593. +             }
  594.          }
  595.  
  596. -        void EnterCombat(Unit* /*who*/)
  597. +        void CallFallSoldier()
  598.          {
  599. -            DoScriptText(SAY_AGGRO, me);
  600. -            if (instance)
  601. -                instance->SetData(DATA_MARWYN_EVENT, IN_PROGRESS);
  602. -
  603. -            events.ScheduleEvent(EVENT_OBLITERATE, 30000);          // TODO Check timer
  604. -            events.ScheduleEvent(EVENT_WELL_OF_CORRUPTION, 13000);
  605. -            events.ScheduleEvent(EVENT_CORRUPTED_FLESH, 20000);
  606. -            events.ScheduleEvent(EVENT_SHARED_SUFFERING, 20000);    // TODO Check timer
  607. +             for(uint8 i = 0; i < 4; i++)
  608. +             {
  609. +                if(Creature* Summon = m_pInstance->instance->GetCreature(m_uiSummonGUID[m_uiCheckSummon]))
  610. +                {
  611. +                   Summon->setFaction(14);
  612. +                   Summon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  613. +                   Summon->SetReactState(REACT_AGGRESSIVE);
  614. +                   Summon->SetInCombatWithZone();
  615. +                }
  616. +                m_uiCheckSummon++;
  617. +             }
  618.          }
  619.  
  620. -        void JustDied(Unit* /*killer*/)
  621. +        void JustDied(Unit* pKiller)
  622.          {
  623. -            DoScriptText(SAY_DEATH, me);
  624. +          if(m_pInstance)
  625. +          {
  626. +             m_pInstance->SetData(TYPE_MARWYN, DONE);
  627. +             m_pInstance->SetData(TYPE_PHASE, 3);
  628. +          }
  629.  
  630. -            if (instance)
  631. -                instance->SetData(DATA_MARWYN_EVENT, DONE);
  632. +          DoScriptText(SAY_MARWYN_DEATH, me);
  633.          }
  634.  
  635. -        void KilledUnit(Unit* /*victim*/)
  636. +        void KilledUnit(Unit* victim)
  637.          {
  638. -            DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2), me);
  639. +            switch(urand(0,1))
  640. +            {
  641. +                case 0: DoScriptText(SAY_MARWYN_SLAY01, me); break;
  642. +                case 1: DoScriptText(SAY_MARWYN_SLAY02, me); break;
  643. +            }
  644.          }
  645.  
  646. -        void UpdateAI(const uint32 diff)
  647. +        void EnterCombat(Unit* victim)
  648.          {
  649. -            // Return since we have no target
  650. -            if (!UpdateVictim())
  651. -                return;
  652. +            if (!m_pInstance) return;
  653. +          //me->RemoveFlag(MOVEFLAG_WALK, MOVEMENTFLAG_WALK_MODE);
  654. +          DoScriptText(SAY_MARWYN_AGGRO, me);
  655. +        }
  656.  
  657. -            events.Update(diff);
  658. +        void AttackStart(Unit* who)
  659. +        {
  660. +            if (!m_pInstance) return;
  661.  
  662. -            if (me->HasUnitState(UNIT_STATE_CASTING))
  663. -                return;
  664. +               if (m_pInstance->GetData(TYPE_MARWYN) != IN_PROGRESS)
  665. +                 return;
  666. +
  667. +             ScriptedAI::AttackStart(who);
  668. +        }
  669.  
  670. -            switch (events.ExecuteEvent())
  671. +       void UpdateAI(const uint32 uiDiff)
  672. +        {
  673. +            if(!m_pInstance) return;
  674. +
  675. +            if (m_pInstance->GetData(TYPE_FALRIC) == SPECIAL)
  676. +            {
  677. +                if(!m_bIsCall)
  678. +                {
  679. +                   m_bIsCall = true;
  680. +                   Summon();
  681. +                }
  682. +            }
  683. +
  684. +            if(m_pInstance->GetData(TYPE_MARWYN) == SPECIAL)
  685.              {
  686. -                case EVENT_OBLITERATE:
  687. -                    DoCast(SPELL_OBLITERATE);
  688. -                    events.ScheduleEvent(EVENT_OBLITERATE, 30000);
  689. -                    break;
  690. -                case EVENT_WELL_OF_CORRUPTION:
  691. -                    DoCast(SPELL_WELL_OF_CORRUPTION);
  692. -                    events.ScheduleEvent(EVENT_WELL_OF_CORRUPTION, 13000);
  693. -                    break;
  694. -                case EVENT_CORRUPTED_FLESH:
  695. -                    DoScriptText(RAND(SAY_CORRUPTED_FLESH_1, SAY_CORRUPTED_FLESH_2), me);
  696. -                    DoCast(SPELL_CORRUPTED_FLESH);
  697. -                    events.ScheduleEvent(EVENT_CORRUPTED_FLESH, 20000);
  698. -                    break;
  699. -                case EVENT_SHARED_SUFFERING:
  700. -                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  701. -                        DoCast(target, SPELL_SHARED_SUFFERING);
  702. -                    events.ScheduleEvent(EVENT_SHARED_SUFFERING, 20000);
  703. -                    break;
  704. +               if(m_uiSummonTimer < uiDiff)
  705. +               {
  706. +                       ++SummonCount;
  707. +                       if(SummonCount == 1)
  708. +                          DoScriptText(SAY_MARWYN_INTRO, me);
  709. +
  710. +                       if(SummonCount > 4)
  711. +                       {
  712. +                            m_pInstance->SetData(TYPE_MARWYN, IN_PROGRESS);
  713. +                            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  714. +                            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  715. +                            me->SetInCombatWithZone();
  716. +                       }
  717. +                       else CallFallSoldier();
  718. +                       m_uiSummonTimer = 60000;
  719. +               } else m_uiSummonTimer -= uiDiff;
  720.              }
  721.  
  722. +            if(!UpdateVictim())
  723. +                return;
  724. +
  725. +            if(m_uiObliterateTimer < uiDiff)
  726. +            {
  727. +                DoCast(me->getVictim(), Regular ? SPELL_OBLITERATE_N : SPELL_OBLITERATE_H);
  728. +                m_uiObliterateTimer = urand(8000, 12000);
  729. +            } else m_uiObliterateTimer -= uiDiff;
  730. +
  731. +            if (m_uiWellTimer < uiDiff)
  732. +            {
  733. +                DoScriptText(SAY_MARWYN_SP02, me);
  734. +                if(Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  735. +                   DoCast(pTarget, SPELL_WELL_OF_CORRUPTION);
  736. +                m_uiWellTimer= urand(25000, 30000);
  737. +            } else m_uiWellTimer -= uiDiff;
  738. +
  739. +            if (m_uiSharedSufferingTimer < uiDiff)
  740. +            {
  741. +                if(Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  742. +                   DoCast(pTarget, Regular ? SPELL_SHARED_SUFFERING_N : SPELL_SHARED_SUFFERING_H);
  743. +                m_uiSharedSufferingTimer = urand(15000, 20000);
  744. +            } else m_uiSharedSufferingTimer -= uiDiff;
  745. +
  746. +            if (m_uiFleshTimer < uiDiff)
  747. +            {
  748. +                DoScriptText(SAY_MARWYN_SP01, me);
  749. +                if(Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  750. +                    DoCast(pTarget, Regular ? SPELL_CORRUPTED_FLESH_N : SPELL_CORRUPTED_FLESH_H);
  751. +                m_uiFleshTimer = urand(10000, 16000);
  752. +            } else m_uiFleshTimer -= uiDiff;
  753. +
  754. +            if(m_uiBerserkTimer < uiDiff)
  755. +            {
  756. +                DoCast(me, SPELL_BERSERK);
  757. +                m_uiBerserkTimer = 180000;
  758. +            } else  m_uiBerserkTimer -= uiDiff;
  759. +
  760.              DoMeleeAttackIfReady();
  761. +
  762. +            return;
  763.          }
  764.      };
  765. +    CreatureAI* GetAI(Creature* pCreature) const
  766. +    {
  767. +        return new boss_marwynAI(pCreature);
  768. +    }
  769.  
  770.  };
  771.  
  772. diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp
  773. index 26ec9e5..04861f7 100644
  774. --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp
  775. +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.cpp
  776. @@ -1,555 +1,1401 @@
  777.  /*
  778. - * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
  779. + * Copyright (C) 2008 - 2012 Trinity <http://www.trinitycore.org/>
  780. + * Copyright (C) 2008 - 2012 Facecore <https://github.com/SignFinder/FaceCore/>
  781.   *
  782. - * This program is free software; you can redistribute it and/or modify it
  783. - * under the terms of the GNU General Public License as published by the
  784. - * Free Software Foundation; either version 2 of the License, or (at your
  785. - * option) any later version.
  786. - *
  787. - * This program is distributed in the hope that it will be useful, but WITHOUT
  788. - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  789. - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  790. - * more details.
  791. - *
  792. - * You should have received a copy of the GNU General Public License along
  793. - * with this program. If not, see <http://www.gnu.org/licenses/>.
  794. - */
  795. -
  796. +* This program is free software; you can redistribute it and/or modify
  797. +* it under the terms of the GNU General Public License as published by
  798. +* the Free Software Foundation; either version 2 of the License, or
  799. +* (at your option) any later version.
  800. +*
  801. +* This program is distributed in the hope that it will be useful,
  802. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  803. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  804. +* GNU General Public License for more details.
  805. +*
  806. +* You should have received a copy of the GNU General Public License
  807. +* along with this program; if not, write to the Free Software
  808. +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  809. +*/
  810. +
  811. +#include "ScriptedEscortAI.h"
  812.  #include "ScriptMgr.h"
  813.  #include "ScriptedCreature.h"
  814.  #include "ScriptedGossip.h"
  815.  #include "halls_of_reflection.h"
  816.  
  817. -enum Yells
  818. +enum
  819.  {
  820. -    SAY_JAINA_INTRO_1                             = -1668001,
  821. -    SAY_JAINA_INTRO_2                             = -1668002,
  822. -    SAY_JAINA_INTRO_3                             = -1668003,
  823. -    SAY_JAINA_INTRO_4                             = -1668004,
  824. -    SAY_UTHER_INTRO_A2_1                          = -1668005,
  825. -    SAY_JAINA_INTRO_5                             = -1668006,
  826. -    SAY_UTHER_INTRO_A2_2                          = -1668007,
  827. -    SAY_JAINA_INTRO_6                             = -1668008,
  828. -    SAY_UTHER_INTRO_A2_3                          = -1668009,
  829. -    SAY_JAINA_INTRO_7                             = -1668010,
  830. -    SAY_UTHER_INTRO_A2_4                          = -1668011,
  831. -    SAY_JAINA_INTRO_8                             = -1668012,
  832. -    SAY_UTHER_INTRO_A2_5                          = -1668013,
  833. -    SAY_JAINA_INTRO_9                             = -1668014,
  834. -    SAY_UTHER_INTRO_A2_6                          = -1668015,
  835. -    SAY_UTHER_INTRO_A2_7                          = -1668016,
  836. -    SAY_JAINA_INTRO_10                            = -1668017,
  837. -    SAY_UTHER_INTRO_A2_8                          = -1668018,
  838. -    SAY_JAINA_INTRO_11                            = -1668019,
  839. -    SAY_UTHER_INTRO_A2_9                          = -1668020,
  840. -
  841. -    SAY_SYLVANAS_INTRO_1                          = -1668021,
  842. -    SAY_SYLVANAS_INTRO_2                          = -1668022,
  843. -    SAY_SYLVANAS_INTRO_3                          = -1668023,
  844. -    SAY_UTHER_INTRO_H2_1                          = -1668024,
  845. -    SAY_SYLVANAS_INTRO_4                          = -1668025,
  846. -    SAY_UTHER_INTRO_H2_2                          = -1668026,
  847. -    SAY_SYLVANAS_INTRO_5                          = -1668027,
  848. -    SAY_UTHER_INTRO_H2_3                          = -1668028,
  849. -    SAY_SYLVANAS_INTRO_6                          = -1668029,
  850. -    SAY_UTHER_INTRO_H2_4                          = -1668030,
  851. -    SAY_SYLVANAS_INTRO_7                          = -1668031,
  852. -    SAY_UTHER_INTRO_H2_5                          = -1668032,
  853. -    SAY_UTHER_INTRO_H2_6                          = -1668033,
  854. -    SAY_SYLVANAS_INTRO_8                          = -1668034,
  855. -    SAY_UTHER_INTRO_H2_7                          = -1668035,
  856. -
  857. -    SAY_LK_INTRO_1                                = -1668036,
  858. -    SAY_LK_INTRO_2                                = -1668037,
  859. -    SAY_LK_INTRO_3                                = -1668038,
  860. -    SAY_FALRIC_INTRO_1                            = -1668039,
  861. -    SAY_MARWYN_INTRO_1                            = -1668040,
  862. -    SAY_FALRIC_INTRO_2                            = -1668041,
  863. -
  864. -    SAY_JAINA_INTRO_END                           = -1668042,
  865. -    SAY_SYLVANAS_INTRO_END                        = -1668043,
  866. +   //Intro
  867. +   SAY_JAINA_INTRO_01                 = -1668001,
  868. +   SAY_JAINA_INTRO_02                 = -1668002,
  869. +   SAY_JAINA_INTRO_03                 = -1668003,
  870. +   SAY_JAINA_INTRO_04                 = -1668004,
  871. +
  872. +   SAY_SYLVANA_INTRO_01               = -1668021,
  873. +   SAY_SYLVANA_INTRO_02               = -1668022,
  874. +   SAY_SYLVANA_INTRO_03               = -1668023,
  875. +
  876. +   //Dialog with Uter
  877. +   SAY_UTHER_A_01                     = -1668005,
  878. +   SAY_JAINA_02                       = -1668006,
  879. +   SAY_UTHER_A_03                     = -1668007,
  880. +   SAY_JAINA_04                       = -1668008,
  881. +   SAY_UTHER_A_05                     = -1668009,
  882. +   SAY_JAINA_06                       = -1668010,
  883. +   SAY_UTHER_A_07                     = -1668011,
  884. +   SAY_JAINA_08                       = -1668012,
  885. +   SAY_UTHER_A_09                     = -1668013,
  886. +   SAY_JAINA_10                       = -1668014,
  887. +   SAY_UTHER_A_11                     = -1668015,
  888. +   SAY_JAINA_12                       = -1668017,
  889. +   SAY_UTHER_A_13                     = -1668016,
  890. +   SAY_UTHER_A_14                     = -1668018,
  891. +   SAY_JAINA_15                       = -1668019,
  892. +
  893. +   SAY_UTHER_H_01                     = -1668024,
  894. +   SAY_SYLVANA_02                     = -1668025,
  895. +   SAY_UTHER_H_03                     = -1668026,
  896. +   SAY_SYLVANA_04                     = -1668027,
  897. +   SAY_UTHER_H_05                     = -1668028,
  898. +   SAY_SYLVANA_06                     = -1668029,
  899. +   SAY_UTHER_H_07                     = -1668030,
  900. +   SAY_SYLVANA_08                     = -1668031,
  901. +   SAY_UTHER_H_09                     = -1668032,
  902. +   SAY_UTHER_H_11                     = -1668033,
  903. +   SAY_SYLVANA_12                     = -1668034,
  904. +
  905. +   //Lich King dialog
  906. +   SAY_UTHER_A_16                     = -1668020,
  907. +   SAY_JAINA_20                       = -1668042,
  908. +
  909. +
  910. +   SAY_UTHER_H_16                     = -1668035,
  911. +   SAY_SYLVANA_20                     = -1668043,
  912. +
  913. +   SAY_LICH_KING_17                   = -1668036,
  914. +   SAY_LICH_KING_18                   = -1668037,
  915. +   SAY_LICH_KING_19                   = -1668038,
  916. +   SAY_LICH_KING_A_21                 = -1594473,
  917. +   SAY_LICH_KING_H_21                 = -1594474,
  918. +
  919. +   SAY_FALRIC_INTRO                   = -1668039,
  920. +   SAY_MARWYN_INTRO                   = -1668040,
  921. +   SAY_FALRIC_INTRO2                  = -1668041,
  922. +
  923. +   /*INTRO - Pre Escape*/
  924. +   SAY_LICH_KING_AGGRO_A              = -1594477,
  925. +   SAY_LICH_KING_AGGRO_H              = -1594478,
  926. +   SAY_JAINA_AGGRO                    = -1594479,
  927. +   SAY_SYLVANA_AGGRO                  = -1594480,
  928. +
  929. +   /*ESCAPE*/
  930. +   SAY_JAINA_WALL_01                  = -1594487,
  931. +   SAY_SYLVANA_WALL_01                = -1594488,
  932. +   SAY_JAINA_WALL_02                  = -1594489,
  933. +   SAY_SYLVANA_WALL_02                = -1594490,
  934. +   SAY_LICH_KING_WALL_02              = -1594491,
  935. +   SAY_LICH_KING_WALL_03              = -1594492,
  936. +   SAY_LICH_KING_WALL_04              = -1594493,
  937. +   SAY_JAINA_WALL_03                  = -1594494,
  938. +   SAY_JAINA_WALL_04                  = -1594495,
  939. +   SAY_SYLVANA_WALL_03                = -1594496,
  940. +   SAY_SYLVANA_WALL_04                = -1594497,
  941. +   SAY_JAINA_ESCAPE_01                = -1594498,
  942. +   SAY_JAINA_ESCAPE_02                = -1594499,
  943. +   SAY_SYLVANA_ESCAPE_01              = -1594500,
  944. +   SAY_SYLVANA_ESCAPE_02              = -1594501,
  945. +   SAY_JAINA_TRAP                     = -1594502,
  946. +   SAY_SYLVANA_TRAP                   = -1594503,
  947. +   SAY_MATHEAS_JAINA                  = -1594505,
  948. +   SAY_LICH_KING_END_01               = -1594506,
  949. +   SAY_LICH_KING_END_02               = -1594507,
  950. +   SAY_LICH_KING_END_03               = -1594508,
  951. +
  952. +   /*SPELLS AND VISUAL EFFECTS*/
  953. +   SPELL_TAKE_FROSTMOURNE             = 72729,
  954. +   SPELL_FROSTMOURNE_DESPAWN          = 72726,
  955. +   SPELL_FROSTMOURNE_SOUNDS           = 70667,
  956. +   SPELL_CAST_VISUAL                  = 65633,  //Jaina And Sylavana cast this when summon uther.
  957. +   SPELL_BOSS_SPAWN_AURA              = 72712,  //Falric and Marwyn
  958. +   SPELL_UTHER_DESPAWN                = 70693,
  959. +   SPELL_WINTER                       = 69780,
  960. +   SPELL_FURY_OF_FROSTMOURNE          = 70063,
  961. +   SPELL_SOUL_REAPER                  = 73797,
  962. +   SPELL_RAISE_DEAD                   = 69818,
  963. +   SPELL_ICE_PRISON                   = 71321,
  964. +   SPELL_ICE_PRISON_VISUAL            = 69708,
  965. +   SPELL_DARK_ARROW                   = 70194,
  966. +   SPELL_ICE_BARRIER                  = 69787,
  967. +   SPELL_DESTROY_ICE_WALL_01          = 69784, //Jaina
  968. +   SPELL_DESTROY_ICE_WALL_02          = 70224,
  969. +   SPELL_DESTROY_ICE_WALL_03          = 70225, //Sylvana
  970. +   SPELL_SUMMON_ICE_WALL              = 69784,
  971. +   SPELL_SYLVANA_JUMP                 = 68339,
  972. +   SPELL_SYLVANA_STEP                 = 69087,
  973. +   SPELL_SILENCE                      = 69413,
  974. +   SPELL_LICH_KING_CAST               = 57561,
  975. +   SPELL_FROSTMOURNE_VISUAL           = 73220,
  976. +   SPELL_SHIELD_DISRUPTION            = 58291,
  977. +
  978. +   FACTION                            = 2076,
  979.  };
  980.  
  981. -enum Events
  982. +class npc_jaina_and_sylvana_HRintro : public CreatureScript
  983.  {
  984. -    EVENT_NONE,
  985. -
  986. -    EVENT_START_INTRO,
  987. -    EVENT_SKIP_INTRO,
  988. -
  989. -    EVENT_INTRO_A2_1,
  990. -    EVENT_INTRO_A2_2,
  991. -    EVENT_INTRO_A2_3,
  992. -    EVENT_INTRO_A2_4,
  993. -    EVENT_INTRO_A2_5,
  994. -    EVENT_INTRO_A2_6,
  995. -    EVENT_INTRO_A2_7,
  996. -    EVENT_INTRO_A2_8,
  997. -    EVENT_INTRO_A2_9,
  998. -    EVENT_INTRO_A2_10,
  999. -    EVENT_INTRO_A2_11,
  1000. -    EVENT_INTRO_A2_12,
  1001. -    EVENT_INTRO_A2_13,
  1002. -    EVENT_INTRO_A2_14,
  1003. -    EVENT_INTRO_A2_15,
  1004. -    EVENT_INTRO_A2_16,
  1005. -    EVENT_INTRO_A2_17,
  1006. -    EVENT_INTRO_A2_18,
  1007. -    EVENT_INTRO_A2_19,
  1008. -
  1009. -    EVENT_INTRO_H2_1,
  1010. -    EVENT_INTRO_H2_2,
  1011. -    EVENT_INTRO_H2_3,
  1012. -    EVENT_INTRO_H2_4,
  1013. -    EVENT_INTRO_H2_5,
  1014. -    EVENT_INTRO_H2_6,
  1015. -    EVENT_INTRO_H2_7,
  1016. -    EVENT_INTRO_H2_8,
  1017. -    EVENT_INTRO_H2_9,
  1018. -    EVENT_INTRO_H2_10,
  1019. -    EVENT_INTRO_H2_11,
  1020. -    EVENT_INTRO_H2_12,
  1021. -    EVENT_INTRO_H2_13,
  1022. -    EVENT_INTRO_H2_14,
  1023. -    EVENT_INTRO_H2_15,
  1024. -
  1025. -    EVENT_INTRO_LK_1,
  1026. -    EVENT_INTRO_LK_2,
  1027. -    EVENT_INTRO_LK_3,
  1028. -    EVENT_INTRO_LK_4,
  1029. -    EVENT_INTRO_LK_5,
  1030. -    EVENT_INTRO_LK_6,
  1031. -    EVENT_INTRO_LK_7,
  1032. -    EVENT_INTRO_LK_8,
  1033. -    EVENT_INTRO_LK_9,
  1034. -
  1035. -    EVENT_INTRO_END,
  1036. -};
  1037. +public:
  1038. +    npc_jaina_and_sylvana_HRintro() : CreatureScript("npc_jaina_and_sylvana_HRintro") { }
  1039.  
  1040. -enum eEnum
  1041. -{
  1042. -    ACTION_START_INTRO,
  1043. -    ACTION_SKIP_INTRO,
  1044. +    bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
  1045. +    {
  1046. +        InstanceScript* m_pInstance = (InstanceScript*)pCreature->GetInstanceScript();
  1047.  
  1048. -    QUEST_DELIVRANCE_FROM_THE_PIT_A2              = 24710,
  1049. -    QUEST_DELIVRANCE_FROM_THE_PIT_H2              = 24712,
  1050. -    QUEST_WRATH_OF_THE_LICH_KING_A2               = 24500,
  1051. -    QUEST_WRATH_OF_THE_LICH_KING_H2               = 24802,
  1052. -};
  1053. +        if (!m_pInstance)
  1054. +            return false;
  1055.  
  1056. -const Position HallsofReflectionLocs[]=
  1057. -{
  1058. -    {5283.234863f, 1990.946777f, 707.695679f, 0.929097f},   // 2 Loralen Follows
  1059. -    {5408.031250f, 2102.918213f, 707.695251f, 0.792756f},   // 9 Sylvanas Follows
  1060. -    {5401.866699f, 2110.837402f, 707.695251f, 0.800610f},   // 10 Loralen follows
  1061. -};
  1062. +        switch (uiAction)
  1063. +        {
  1064. +            case GOSSIP_ACTION_INFO_DEF+1:
  1065. +                pPlayer->CLOSE_GOSSIP_MENU();
  1066. +                m_pInstance->SetData(TYPE_EVENT, 1);
  1067. +                break;
  1068. +        }
  1069.  
  1070. -const Position SpawnPos              = {5262.540527f, 1949.693726f, 707.695007f, 0.808736f}; // Jaina/Sylvanas Beginning Position
  1071. -const Position MoveThronePos         = {5306.952148f, 1998.499023f, 709.341431f, 1.277278f}; // Jaina/Sylvanas walks to throne
  1072. -const Position UtherSpawnPos         = {5308.310059f, 2003.857178f, 709.341431f, 4.650315f};
  1073. -const Position LichKingSpawnPos      = {5362.917480f, 2062.307129f, 707.695374f, 3.945812f};
  1074. -const Position LichKingMoveThronePos = {5312.080566f, 2009.172119f, 709.341431f, 3.973301f}; // Lich King walks to throne
  1075. -const Position LichKingMoveAwayPos   = {5400.069824f, 2102.7131689f, 707.69525f, 0.843803f}; // Lich King walks away
  1076. +        if(pPlayer->GetTeam() == ALLIANCE)
  1077. +            m_pInstance->SetData(DATA_LIDER, 1);
  1078. +        else
  1079. +            m_pInstance->SetData(DATA_LIDER, 2);
  1080.  
  1081. -class npc_jaina_or_sylvanas_hor : public CreatureScript
  1082. -{
  1083. -private:
  1084. -    bool m_isSylvana;
  1085. +        m_pInstance->SetData64(DATA_ESCAPE_LIDER,pCreature->GetGUID());
  1086.  
  1087. -public:
  1088. -    npc_jaina_or_sylvanas_hor(bool isSylvana, const char* name) : CreatureScript(name), m_isSylvana(isSylvana) { }
  1089. +        return true;
  1090. +    }
  1091.  
  1092. -    bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
  1093. +    bool OnGossipHello(Player* pPlayer, Creature* pCreature)
  1094.      {
  1095. -        player->PlayerTalkClass->ClearMenus();
  1096. -        switch (action)
  1097. +        InstanceScript* m_pInstance = (InstanceScript*)pCreature->GetInstanceScript();
  1098. +
  1099. +        if(pCreature->isQuestGiver())
  1100. +            pPlayer->PrepareQuestMenu( pCreature->GetGUID());
  1101. +
  1102. +        switch(pCreature->GetEntry())
  1103.          {
  1104. -            case GOSSIP_ACTION_INFO_DEF+1:
  1105. -                player->CLOSE_GOSSIP_MENU();
  1106. -                if (creature->AI())
  1107. -                    creature->AI()->DoAction(ACTION_START_INTRO);
  1108. -                creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
  1109. +            case NPC_JAINA:
  1110. +                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "???? ??????, ?? ?????? ? ????????? ??????!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  1111.                  break;
  1112. -            case GOSSIP_ACTION_INFO_DEF+2:
  1113. -                player->CLOSE_GOSSIP_MENU();
  1114. -                if (creature->AI())
  1115. -                    creature->AI()->DoAction(ACTION_SKIP_INTRO);
  1116. -                creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
  1117. +            case NPC_SYLVANA:
  1118. +                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "???? ????????, ?? ?????? ? ????????? ??????!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  1119.                  break;
  1120.          }
  1121.  
  1122. +        pPlayer->PlayerTalkClass->SendGossipMenu(907,pCreature->GetGUID());
  1123.          return true;
  1124.      }
  1125.  
  1126. -    bool OnGossipHello(Player* player, Creature* creature)
  1127. +    struct npc_jaina_and_sylvana_HRintroAI : public ScriptedAI
  1128.      {
  1129. -        if (creature->isQuestGiver())
  1130. -            player->PrepareQuestMenu(creature->GetGUID());
  1131. +        npc_jaina_and_sylvana_HRintroAI(Creature *pCreature) : ScriptedAI(pCreature)
  1132. +        {
  1133. +            m_pInstance = (InstanceScript*)pCreature->GetInstanceScript();
  1134. +            Reset();
  1135. +        }
  1136.  
  1137. -        QuestStatus status = player->GetQuestStatus(m_isSylvana ? QUEST_DELIVRANCE_FROM_THE_PIT_H2 : QUEST_DELIVRANCE_FROM_THE_PIT_A2);
  1138. -        if (status == QUEST_STATUS_COMPLETE || status == QUEST_STATUS_REWARDED)
  1139. -            player->ADD_GOSSIP_ITEM( 0, "Can you remove the sword?", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  1140. +        InstanceScript* m_pInstance;
  1141.  
  1142. -        // once last quest is completed, she offers this shortcut of the starting event
  1143. -        status = player->GetQuestStatus(m_isSylvana ? QUEST_WRATH_OF_THE_LICH_KING_H2 : QUEST_WRATH_OF_THE_LICH_KING_A2);
  1144. -        if (status == QUEST_STATUS_COMPLETE || status == QUEST_STATUS_REWARDED)
  1145. -            player->ADD_GOSSIP_ITEM( 0, "Dark Lady, I think I hear Arthas coming. Whatever you're going to do, do it quickly.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
  1146. +        uint32 StepTimer;
  1147. +        uint32 Step;
  1148. +        uint64 m_uiFrostmourneGUID;
  1149. +        uint64 m_uiMainGateGUID;
  1150. +        uint64 m_uiFalricGUID;
  1151. +        uint64 m_uiMarwynGUID;
  1152. +        Creature* pUther;
  1153. +        Creature* pLichKing;
  1154. +        bool Small;
  1155.  
  1156. -        player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
  1157. -        return true;
  1158. -    }
  1159. +        void Reset()
  1160. +        {
  1161. +            me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
  1162. +            me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
  1163. +            Small = false;
  1164. +        }
  1165. +
  1166. +        void StartEvent()
  1167. +        {
  1168. +            if(!m_pInstance)
  1169. +                return
  1170. +            sLog->outDebug(LOG_FILTER_TSCR, "EventMGR: creature %u received signal %u ",me->GetEntry(),m_pInstance->GetData(TYPE_EVENT));
  1171. +            m_pInstance->SetData(TYPE_PHASE, 1);
  1172. +            m_pInstance->SetData(TYPE_EVENT, 0);
  1173. +            Step = 1;
  1174. +            StepTimer = 100;
  1175. +        }
  1176. +
  1177. +        void JumpNextStep(uint32 Time)
  1178. +        {
  1179. +            StepTimer = Time;
  1180. +            Step++;
  1181. +        }
  1182.  
  1183. -    CreatureAI* GetAI(Creature* creature) const
  1184. +        void Event()
  1185. +        {
  1186. +            switch(Step)
  1187. +            {
  1188. +                case 1:
  1189. +                    me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
  1190. +                    me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
  1191. +                    JumpNextStep(2000);
  1192. +                    break;
  1193. +                case 2:
  1194. +                    if(me->GetEntry() == NPC_JAINA)
  1195. +                    {
  1196. +                        DoScriptText(SAY_JAINA_INTRO_01, me);
  1197. +                        JumpNextStep(5000);
  1198. +                    }
  1199. +                    if(me->GetEntry() == NPC_SYLVANA)
  1200. +                    {
  1201. +                        DoScriptText(SAY_SYLVANA_INTRO_01, me);
  1202. +                        JumpNextStep(8000);
  1203. +                    }
  1204. +                    break;
  1205. +                case 3:
  1206. +                    if(me->GetEntry() == NPC_JAINA)
  1207. +                    {
  1208. +                        DoScriptText(SAY_JAINA_INTRO_02, me);
  1209. +                        JumpNextStep(5000);
  1210. +                    }
  1211. +                    if(me->GetEntry() == NPC_SYLVANA)
  1212. +                        JumpNextStep(500);
  1213. +                    break;
  1214. +                case 4:
  1215. +                    me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
  1216. +                    me->GetMotionMaster()->MovePoint(0, 5307.031f, 1997.920f, 709.341f);
  1217. +                    JumpNextStep(10000);
  1218. +                    break;
  1219. +                case 5:
  1220. +                    if(Creature* pTarget = me->SummonCreature(NPC_ALTAR_TARGET,5309.374f,2006.788f,711.615f,1.37f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,360000))
  1221. +                    {
  1222. +                        me->SetUInt64Value(UNIT_FIELD_TARGET, pTarget->GetGUID());
  1223. +                        pTarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
  1224. +                    }
  1225. +                    JumpNextStep(1000);
  1226. +                    break;
  1227. +                case 6:
  1228. +                    if(me->GetEntry() == NPC_JAINA)
  1229. +                    {
  1230. +                        DoScriptText(SAY_JAINA_INTRO_03, me);
  1231. +                        JumpNextStep(5000);
  1232. +                    }
  1233. +                    if(me->GetEntry() == NPC_SYLVANA)
  1234. +                    {
  1235. +                        DoScriptText(SAY_SYLVANA_INTRO_03, me);
  1236. +                        //DoScriptText(SAY_SYLVANA_INTRO_02, me);
  1237. +                        JumpNextStep(6000);
  1238. +                    }
  1239. +                    break;
  1240. +                case 7:
  1241. +                    DoCast(me, SPELL_CAST_VISUAL);
  1242. +                    if(me->GetEntry() == NPC_JAINA)
  1243. +                        DoScriptText(SAY_JAINA_INTRO_04, me);
  1244. +                    if(me->GetEntry() == NPC_SYLVANA)
  1245. +                        DoScriptText(SAY_SYLVANA_INTRO_03, me);
  1246. +                    JumpNextStep(3000);
  1247. +                    break;
  1248. +                case 8:
  1249. +                    DoCast(me, SPELL_FROSTMOURNE_SOUNDS);
  1250. +                    m_uiFrostmourneGUID = m_pInstance->GetData64(GO_FROSTMOURNE);
  1251. +                    if(GameObject* pFrostmourne = m_pInstance->instance->GetGameObject(m_uiFrostmourneGUID))
  1252. +                    {
  1253. +                        pFrostmourne->SetGoState(GO_STATE_ACTIVE);
  1254. +                    }
  1255. +                    if(me->GetEntry() == NPC_JAINA)
  1256. +                        JumpNextStep(12000);
  1257. +                    if(me->GetEntry() == NPC_SYLVANA)
  1258. +                        JumpNextStep(8000);
  1259. +                    break;
  1260. +                case 9:
  1261. +                    if(Creature* Uther = me->SummonCreature(NPC_UTHER,5308.228f,2003.641f,709.341f,4.17f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,360000))
  1262. +                    {
  1263. +                        pUther = Uther;
  1264. +                        Uther->SetUInt64Value(UNIT_FIELD_TARGET, me->GetGUID());
  1265. +                        me->SetUInt64Value(UNIT_FIELD_TARGET, Uther->GetGUID());
  1266. +                        if(me->GetEntry() == NPC_JAINA)
  1267. +                        {
  1268. +                            DoScriptText(SAY_UTHER_A_01, Uther);
  1269. +                            JumpNextStep(3000);
  1270. +                        }
  1271. +                        if(me->GetEntry() == NPC_SYLVANA)
  1272. +                        {
  1273. +                            DoScriptText(SAY_UTHER_H_01, Uther);
  1274. +                            JumpNextStep(10000);
  1275. +                        }
  1276. +                    }
  1277. +                    break;
  1278. +                case 10:
  1279. +                    if(me->GetEntry() == NPC_JAINA)
  1280. +                    {
  1281. +                        DoScriptText(SAY_JAINA_02, me);
  1282. +                        JumpNextStep(5000);
  1283. +                    }
  1284. +                    if(me->GetEntry() == NPC_SYLVANA)
  1285. +                    {
  1286. +                        DoScriptText(SAY_SYLVANA_02, me);
  1287. +                        JumpNextStep(3000);
  1288. +                    }
  1289. +                    break;
  1290. +                case 11:
  1291. +                    if(me->GetEntry() == NPC_JAINA && pUther)
  1292. +                    {
  1293. +                        DoScriptText(SAY_UTHER_A_03, pUther);
  1294. +                        JumpNextStep(7000);
  1295. +                    }
  1296. +                    if(me->GetEntry() == NPC_SYLVANA && pUther)
  1297. +                    {
  1298. +                        DoScriptText(SAY_UTHER_H_03, pUther);
  1299. +                        JumpNextStep(6000);
  1300. +                    }
  1301. +                    if(Small)
  1302. +                        Step = 24;
  1303. +                    break;
  1304. +                case 12:
  1305. +                    if(me->GetEntry() == NPC_JAINA)
  1306. +                    {
  1307. +                        DoScriptText(SAY_JAINA_04, me);
  1308. +                        JumpNextStep(2000);
  1309. +                    }
  1310. +                    if(me->GetEntry() == NPC_SYLVANA)
  1311. +                    {
  1312. +                        DoScriptText(SAY_SYLVANA_04, me);
  1313. +                        JumpNextStep(5000);
  1314. +                    }
  1315. +                    break;
  1316. +                case 13:
  1317. +                    if(me->GetEntry() == NPC_JAINA && pUther)
  1318. +                    {
  1319. +                        DoScriptText(SAY_UTHER_A_05, pUther);
  1320. +                        JumpNextStep(10000);
  1321. +                    }
  1322. +                    if(me->GetEntry() == NPC_SYLVANA && pUther)
  1323. +                    {
  1324. +                        DoScriptText(SAY_UTHER_H_05, pUther);
  1325. +                        JumpNextStep(19000);
  1326. +                    }
  1327. +                    break;
  1328. +                case 14:
  1329. +                    if(me->GetEntry() == NPC_JAINA)
  1330. +                    {
  1331. +                        DoScriptText(SAY_JAINA_06, me);
  1332. +                        JumpNextStep(6000);
  1333. +                    }
  1334. +                    if(me->GetEntry() == NPC_SYLVANA)
  1335. +                    {
  1336. +                        DoScriptText(SAY_SYLVANA_06, me);
  1337. +                        JumpNextStep(2000);
  1338. +                    }
  1339. +                    break;
  1340. +                case 15:
  1341. +                    if(me->GetEntry() == NPC_JAINA && pUther)
  1342. +                    {
  1343. +                        DoScriptText(SAY_UTHER_A_07, pUther);
  1344. +                        JumpNextStep(12000);
  1345. +                    }
  1346. +                    if(me->GetEntry() == NPC_SYLVANA && pUther)
  1347. +                    {
  1348. +                        DoScriptText(SAY_UTHER_H_07, pUther);
  1349. +                        JumpNextStep(20000);
  1350. +                    }
  1351. +                    break;
  1352. +                case 16:
  1353. +                    if(me->GetEntry() == NPC_JAINA)
  1354. +                    {
  1355. +                        DoScriptText(SAY_JAINA_08, me);
  1356. +                        JumpNextStep(6000);
  1357. +                    }
  1358. +                    if(me->GetEntry() == NPC_SYLVANA)
  1359. +                    {
  1360. +                        DoScriptText(SAY_SYLVANA_08, me);
  1361. +                        JumpNextStep(3000);
  1362. +                    }
  1363. +                    break;
  1364. +                case 17:
  1365. +                    if(me->GetEntry() == NPC_JAINA && pUther)
  1366. +                    {
  1367. +                        DoScriptText(SAY_UTHER_A_09, pUther);
  1368. +                        JumpNextStep(12000);
  1369. +                    }
  1370. +                    if(me->GetEntry() == NPC_SYLVANA && pUther)
  1371. +                    {
  1372. +                        DoScriptText(SAY_UTHER_H_09, pUther);
  1373. +                        JumpNextStep(11000);
  1374. +                    }
  1375. +                    break;
  1376. +                case 18:
  1377. +                    if(me->GetEntry() == NPC_JAINA)
  1378. +                    {
  1379. +                        DoScriptText(SAY_JAINA_10, me);
  1380. +                        JumpNextStep(11000);
  1381. +                    }
  1382. +                    if(me->GetEntry() == NPC_SYLVANA)
  1383. +                    {
  1384. +                        JumpNextStep(100);
  1385. +                    }
  1386. +                    break;
  1387. +                case 19:
  1388. +                    if(me->GetEntry() == NPC_JAINA && pUther)
  1389. +                    {
  1390. +                        DoScriptText(SAY_UTHER_A_11, pUther);
  1391. +                        JumpNextStep(24000);
  1392. +                    }
  1393. +                    if(me->GetEntry() == NPC_SYLVANA && pUther)
  1394. +                    {
  1395. +                        DoScriptText(SAY_UTHER_H_11, pUther);
  1396. +                        JumpNextStep(9000);
  1397. +                    }
  1398. +                    break;
  1399. +                case 20:
  1400. +                    if(me->GetEntry() == NPC_JAINA)
  1401. +                    {
  1402. +                        DoScriptText(SAY_JAINA_12, me);
  1403. +                        JumpNextStep(2000);
  1404. +                    }
  1405. +                    if(me->GetEntry() == NPC_SYLVANA)
  1406. +                    {
  1407. +                        DoScriptText(SAY_SYLVANA_12, me);
  1408. +                        JumpNextStep(2100);
  1409. +                    }
  1410. +                    break;
  1411. +                case 21:
  1412. +                    if(me->GetEntry() == NPC_JAINA && pUther)
  1413. +                    {
  1414. +                        DoScriptText(SAY_UTHER_A_13, pUther);
  1415. +                        JumpNextStep(5000);
  1416. +                    }
  1417. +                    if(me->GetEntry() == NPC_SYLVANA)
  1418. +                    {
  1419. +                        JumpNextStep(100);
  1420. +                    }
  1421. +                    break;
  1422. +                case 22:
  1423. +                    if(me->GetEntry() == NPC_JAINA && pUther)
  1424. +                    {
  1425. +                        DoScriptText(SAY_UTHER_A_14, pUther);
  1426. +                        JumpNextStep(12000);
  1427. +                    }
  1428. +                    if(me->GetEntry() == NPC_SYLVANA)
  1429. +                    {
  1430. +                        JumpNextStep(100);
  1431. +                    }
  1432. +                    break;
  1433. +                case 23:
  1434. +                    if(me->GetEntry() == NPC_JAINA)
  1435. +                    {
  1436. +                        DoScriptText(SAY_JAINA_15, me);
  1437. +                        JumpNextStep(2000);
  1438. +                    }
  1439. +                    if(me->GetEntry() == NPC_SYLVANA)
  1440. +                    {
  1441. +                        JumpNextStep(100);
  1442. +                    }
  1443. +                    break;
  1444. +                case 24:
  1445. +                    if(me->GetEntry() == NPC_JAINA && pUther)
  1446. +                        DoScriptText(SAY_UTHER_A_16, pUther);
  1447. +                    if(me->GetEntry() == NPC_SYLVANA && pUther)
  1448. +                        DoScriptText(SAY_UTHER_H_16, pUther);
  1449. +                    m_uiMainGateGUID = m_pInstance->GetData64(GO_IMPENETRABLE_DOOR);
  1450. +                    if(GameObject* pGate = m_pInstance->instance->GetGameObject(m_uiMainGateGUID))
  1451. +                    {
  1452. +                        pGate->SetGoState(GO_STATE_ACTIVE);
  1453. +                    }
  1454. +                    if(Creature* LichKing = me->SummonCreature(NPC_LICH_KING,5362.469f,2062.342f,707.695f,3.97f,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,360000))
  1455. +                    {
  1456. +                        pLichKing = LichKing;
  1457. +                        LichKing->setActive(true);
  1458. +                    }
  1459. +                    JumpNextStep(1000);
  1460. +                    break;
  1461. +                case 25:
  1462. +                    if(pUther)
  1463. +                        pUther->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_COWER);
  1464. +                    if(pLichKing)
  1465. +                    {
  1466. +                        pLichKing->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1467. +                        pLichKing->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
  1468. +                        pLichKing->GetMotionMaster()->MovePoint(0, 5314.881f, 2012.496f, 709.341f);
  1469. +                    }
  1470. +                    JumpNextStep(3000);
  1471. +                    break;
  1472. +                case 26:
  1473. +                    if(GameObject* pGate = m_pInstance->instance->GetGameObject(m_uiMainGateGUID))
  1474. +                        pGate->SetGoState(GO_STATE_READY);
  1475. +                    JumpNextStep(7000);
  1476. +                    break;
  1477. +                case 27:
  1478. +                    if(pUther)
  1479. +                        pUther->CastSpell(pUther, SPELL_UTHER_DESPAWN, false);
  1480. +                    JumpNextStep(500);
  1481. +                    break;
  1482. +                case 28:
  1483. +                    if(pLichKing)
  1484. +                        DoScriptText(SAY_LICH_KING_17, pLichKing);
  1485. +                    JumpNextStep(10000);
  1486. +                    break;
  1487. +                case 29:
  1488. +                    if(pLichKing)
  1489. +                        DoScriptText(SAY_LICH_KING_18, pLichKing);
  1490. +                    JumpNextStep(5000);
  1491. +                    break;
  1492. +                case 30:
  1493. +                    if(pLichKing)
  1494. +                        pLichKing->CastSpell(pLichKing, SPELL_TAKE_FROSTMOURNE, false);
  1495. +                    if(GameObject* pFrostmourne = m_pInstance->instance->GetGameObject(m_uiFrostmourneGUID))
  1496. +                        pFrostmourne->SetGoState(GO_STATE_READY);
  1497. +                    JumpNextStep(1500);
  1498. +                    break;
  1499. +                case 31:
  1500. +                    if(GameObject* pFrostmourne = m_pInstance->instance->GetGameObject(m_uiFrostmourneGUID))
  1501. +                        pFrostmourne->SetPhaseMask(0, true);
  1502. +                    if(pLichKing)
  1503. +                        pLichKing->CastSpell(pLichKing, SPELL_FROSTMOURNE_VISUAL, false);
  1504. +                    me->RemoveAurasDueToSpell(SPELL_FROSTMOURNE_SOUNDS);
  1505. +                    JumpNextStep(5000);
  1506. +                    break;
  1507. +                case 32:
  1508. +                    if(pLichKing)
  1509. +                        DoScriptText(SAY_LICH_KING_19, pLichKing);
  1510. +                    JumpNextStep(9000);
  1511. +                    break;
  1512. +                case 33:
  1513. +                    m_uiFalricGUID = m_pInstance->GetData64(NPC_FALRIC);
  1514. +                    m_uiMarwynGUID = m_pInstance->GetData64(NPC_MARWYN);
  1515. +                    if(Creature* Falric = m_pInstance->instance->GetCreature(m_uiFalricGUID))
  1516. +                    {
  1517. +                        Falric->RemoveAllAuras();
  1518. +                        Falric->SetVisible(true);
  1519. +                        Falric->CastSpell(Falric, SPELL_BOSS_SPAWN_AURA, false);
  1520. +                        Falric->GetMotionMaster()->MovePoint(0, 5283.309f, 2031.173f, 709.319f);
  1521. +                    }
  1522. +                    if(Creature* Marwyn = m_pInstance->instance->GetCreature(m_uiMarwynGUID))
  1523. +                    {
  1524. +                        Marwyn->RemoveAllAuras();
  1525. +                        Marwyn->SetVisible(true);
  1526. +                        Marwyn->CastSpell(Marwyn, SPELL_BOSS_SPAWN_AURA, false);
  1527. +                        Marwyn->GetMotionMaster()->MovePoint(0, 5335.585f, 1981.439f, 709.319f);
  1528. +                    }
  1529. +                    if(pLichKing)
  1530. +                        pLichKing->GetMotionMaster()->MovePoint(0, 5402.286f, 2104.496f, 707.695f);
  1531. +                    JumpNextStep(600);
  1532. +                    break;
  1533. +                case 34:
  1534. +                    if(Creature* Falric = ((Creature*)Unit::GetUnit(*me, m_uiFalricGUID)))
  1535. +                        DoScriptText(SAY_FALRIC_INTRO, Falric);
  1536. +                    if(Creature* Marwyn = ((Creature*)Unit::GetUnit(*me, m_uiMarwynGUID)))
  1537. +                        DoScriptText(SAY_MARWYN_INTRO, Marwyn);
  1538. +                    JumpNextStep(3000);
  1539. +                    break;
  1540. +                case 35:
  1541. +                    if(GameObject* pGate = m_pInstance->instance->GetGameObject(m_uiMainGateGUID))
  1542. +                        pGate->SetGoState(GO_STATE_ACTIVE);
  1543. +                    if(Creature* Falric = ((Creature*)Unit::GetUnit(*me, m_uiFalricGUID)))
  1544. +                        DoScriptText(SAY_FALRIC_INTRO2, Falric);
  1545. +                    m_pInstance->SetData(TYPE_FALRIC, SPECIAL);
  1546. +                    JumpNextStep(4000);
  1547. +                    break;
  1548. +                case 36:
  1549. +                    if(me->GetEntry() == NPC_JAINA)
  1550. +                        DoScriptText(SAY_JAINA_20, me);
  1551. +                    if(me->GetEntry() == NPC_SYLVANA)
  1552. +                        DoScriptText(SAY_SYLVANA_20, me);
  1553. +                    me->GetMotionMaster()->MovePoint(0, 5443.880f, 2147.095f, 707.695f);
  1554. +                    JumpNextStep(4000);
  1555. +                    break;
  1556. +                case 37:
  1557. +                    if(pLichKing)
  1558. +                    {
  1559. +                        pLichKing->GetMotionMaster()->MovementExpired(false);
  1560. +                        pLichKing->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
  1561. +                        pLichKing->GetMotionMaster()->MovePoint(0, 5443.880f, 2147.095f, 707.695f);
  1562. +                    }
  1563. +                    if(me->GetEntry() == NPC_JAINA && pLichKing)
  1564. +                        DoScriptText(SAY_LICH_KING_A_21, pLichKing);
  1565. +                    if(me->GetEntry() == NPC_SYLVANA && pLichKing)
  1566. +                        DoScriptText(SAY_LICH_KING_H_21, pLichKing);
  1567. +                    JumpNextStep(8000);
  1568. +                    break;
  1569. +                case 38:
  1570. +                    if(GameObject* pGate = m_pInstance->instance->GetGameObject(m_uiMainGateGUID))
  1571. +                        pGate->SetGoState(GO_STATE_READY);
  1572. +                    JumpNextStep(5000);
  1573. +                    break;
  1574. +                case 39:
  1575. +                    me->SetVisible(false);
  1576. +                    if(pLichKing)
  1577. +                        pLichKing->SetVisible(false);
  1578. +                    m_pInstance->SetData(TYPE_PHASE, 2);
  1579. +                    JumpNextStep(1000);
  1580. +                    break;
  1581. +            }
  1582. +        }
  1583. +
  1584. +        void UpdateAI(const uint32 diff)
  1585. +        {
  1586. +            if(!m_pInstance)
  1587. +                return;
  1588. +
  1589. +            if(m_pInstance->GetData(TYPE_EVENT) == 1
  1590. +                &&  m_pInstance->GetData64(DATA_ESCAPE_LIDER) == me->GetGUID())
  1591. +                StartEvent();
  1592. +
  1593. +            if(m_pInstance->GetData(TYPE_EVENT) == 2
  1594. +                &&  m_pInstance->GetData64(DATA_ESCAPE_LIDER) == me->GetGUID())
  1595. +            {
  1596. +                Small = true;
  1597. +                StartEvent();
  1598. +            }
  1599. +
  1600. +            if(StepTimer < diff && m_pInstance->GetData(TYPE_PHASE) == 1)
  1601. +                Event();
  1602. +            else StepTimer -= diff;
  1603. +
  1604. +            return;
  1605. +        }
  1606. +    };
  1607. +
  1608. +    CreatureAI* GetAI(Creature* pCreature) const
  1609.      {
  1610. -        return new npc_jaina_or_sylvanas_horAI(creature);
  1611. +        return new npc_jaina_and_sylvana_HRintroAI(pCreature);
  1612.      }
  1613.  
  1614. -    // AI of Part1: handle the intro till start of gauntlet event.
  1615. -    struct npc_jaina_or_sylvanas_horAI : public ScriptedAI
  1616. +};
  1617. +
  1618. +class npc_jaina_and_sylvana_HRextro : public CreatureScript
  1619. +{
  1620. +public:
  1621. +    npc_jaina_and_sylvana_HRextro() : CreatureScript("npc_jaina_and_sylvana_HRextro") { }
  1622. +
  1623. +    bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
  1624.      {
  1625. -        npc_jaina_or_sylvanas_horAI(Creature* creature) : ScriptedAI(creature)
  1626. +        InstanceScript* m_pInstance = (InstanceScript*)pCreature->GetInstanceScript();
  1627. +        switch (uiAction)
  1628.          {
  1629. -            instance = me->GetInstanceScript();
  1630. +            case GOSSIP_ACTION_INFO_DEF+1:
  1631. +                pPlayer->CLOSE_GOSSIP_MENU();
  1632. +                ((npc_jaina_and_sylvana_HRextroAI*)pCreature->AI())->Start(false,true);
  1633. +                pCreature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
  1634. +                pCreature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
  1635. +                pCreature->SetUInt64Value(UNIT_FIELD_TARGET, 0);
  1636. +                pCreature->setActive(true);
  1637. +
  1638. +                if(m_pInstance)
  1639. +                {
  1640. +                    m_pInstance->SetData64(DATA_ESCAPE_LIDER, pCreature->GetGUID());
  1641. +                    m_pInstance->SetData(TYPE_LICH_KING, IN_PROGRESS);
  1642. +                    m_pInstance->SetData(TYPE_PHASE, 5);
  1643. +                }
  1644. +                return true;
  1645. +            default:
  1646. +                return false;
  1647.          }
  1648. +    }
  1649.  
  1650. -        InstanceScript* instance;
  1651. -        uint64 uiUther;
  1652. -        uint64 uiLichKing;
  1653. +    bool OnGossipHello(Player* pPlayer, Creature* pCreature)
  1654. +    {
  1655. +        InstanceScript*   m_pInstance = (InstanceScript*)pCreature->GetInstanceScript();
  1656.  
  1657. -        EventMap events;
  1658. +        if(!m_pInstance)
  1659. +            return false;
  1660.  
  1661. -        void Reset()
  1662. -        {
  1663. -            events.Reset();
  1664. +        if(m_pInstance->GetData(TYPE_LICH_KING) == DONE)
  1665. +            return false;
  1666.  
  1667. -            uiUther = 0;
  1668. -            uiLichKing = 0;
  1669. +        if(pCreature->isQuestGiver())
  1670. +           pPlayer->PrepareQuestMenu( pCreature->GetGUID());
  1671.  
  1672. -            me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
  1673. -            me->SetStandState(UNIT_STAND_STATE_STAND);
  1674. -            me->SetVisible(true);
  1675. +        pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "????????!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  1676. +
  1677. +        pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
  1678. +
  1679. +        return true;
  1680. +    }
  1681. +
  1682. +    struct npc_jaina_and_sylvana_HRextroAI : public npc_escortAI
  1683. +    {
  1684. +        npc_jaina_and_sylvana_HRextroAI(Creature *pCreature) : npc_escortAI(pCreature)
  1685. +        {
  1686. +            m_pInstance = (InstanceScript*)pCreature->GetInstanceScript();
  1687. +            Reset();
  1688.          }
  1689.  
  1690. -        void DoAction(const int32 actionId)
  1691. +        InstanceScript* m_pInstance;
  1692. +
  1693. +        uint32 CastTimer;
  1694. +        uint32 StepTimer;
  1695. +        uint32 Step;
  1696. +        int32 HoldTimer;
  1697. +        uint32 Count;
  1698. +        bool Fight;
  1699. +        bool Event;
  1700. +        bool PreFight;
  1701. +        bool WallCast;
  1702. +        uint64 m_uiLichKingGUID;
  1703. +        uint64 m_uiLiderGUID;
  1704. +        uint64 m_uiIceWallGUID;
  1705. +        uint64 m_uipWallTargetGUID;
  1706. +        Creature* pLichKing;
  1707. +        uint32 m_chestID;
  1708. +
  1709. +        void Reset()
  1710.          {
  1711. -            switch (actionId)
  1712. +            if(!m_pInstance)
  1713. +                return;
  1714. +
  1715. +            if(m_pInstance->GetData(TYPE_LICH_KING) == IN_PROGRESS)
  1716. +                return;
  1717. +
  1718. +            Step = 0;
  1719. +            StepTimer = 500;
  1720. +            Fight = true;
  1721. +            me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
  1722. +            me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
  1723. +            m_uipWallTargetGUID = 0;
  1724. +
  1725. +            if(me->GetEntry() == NPC_JAINA_OUTRO)
  1726.              {
  1727. -                case ACTION_START_INTRO:
  1728. -                    events.ScheduleEvent(EVENT_START_INTRO, 0);
  1729. -                    break;
  1730. -                case ACTION_SKIP_INTRO:
  1731. -                    events.ScheduleEvent(EVENT_SKIP_INTRO, 0);
  1732. -                    break;
  1733. +                me->CastSpell(me, SPELL_ICE_BARRIER, false);
  1734. +                me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_READY2HL);
  1735.              }
  1736. +            if(m_pInstance->GetData(TYPE_LICH_KING) == DONE)
  1737. +                me->SetVisible(false);
  1738. +
  1739.          }
  1740.  
  1741. -        void UpdateAI(const uint32 diff)
  1742. +        void AttackStart(Unit* who)
  1743.          {
  1744. -            events.Update(diff);
  1745. -            switch (events.ExecuteEvent())
  1746. +            if(!who)
  1747. +                return;
  1748. +
  1749. +            if(me->GetEntry() != NPC_SYLVANA_OUTRO)
  1750. +                return;
  1751. +
  1752. +            if(m_pInstance->GetData(TYPE_LICH_KING) == IN_PROGRESS || Fight != true)
  1753. +                return;
  1754. +
  1755. +            npc_escortAI::AttackStart(who);
  1756. +
  1757. +        }
  1758. +
  1759. +        void JustDied(Unit* pKiller)
  1760. +        {
  1761. +            if(!m_pInstance)
  1762. +                return;
  1763. +            m_pInstance->SetData(TYPE_LICH_KING, FAIL);
  1764. +        }
  1765. +
  1766. +        void WaypointReached(uint32 i)
  1767. +        {
  1768. +            switch(i)
  1769.              {
  1770. -                case EVENT_START_INTRO:
  1771. -                    me->GetMotionMaster()->MovePoint(0, MoveThronePos);
  1772. -                    // Begining of intro is differents between fActions as the speech sequence and timers are differents.
  1773. -                    if (instance->GetData(DATA_TEAM_IN_INSTANCE) == ALLIANCE)
  1774. -                        events.ScheduleEvent(EVENT_INTRO_A2_1, 0);
  1775. -                    else
  1776. -                        events.ScheduleEvent(EVENT_INTRO_H2_1, 0);
  1777. +                case 3:
  1778. +                    m_pInstance->SetData(TYPE_ICE_WALL_01, IN_PROGRESS);
  1779. +                    if(GameObject* pGate = m_pInstance->instance->GetGameObject(m_pInstance->GetData64(GO_ICE_WALL_1)))
  1780. +                    {
  1781. +                        pGate->SetGoState(GO_STATE_READY);
  1782. +                        m_uiIceWallGUID = pGate->GetGUID();
  1783. +                    }
  1784.                      break;
  1785. -
  1786. -            // A2 Intro Events
  1787. -                case EVENT_INTRO_A2_1:
  1788. -                    DoScriptText(SAY_JAINA_INTRO_3, me);
  1789. -                    events.ScheduleEvent(EVENT_INTRO_A2_2, 5000);
  1790. +                case 4:
  1791. +                    if(me->GetEntry() == NPC_JAINA_OUTRO)
  1792. +                        DoScriptText(SAY_JAINA_WALL_01, me);
  1793. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  1794. +                        DoScriptText(SAY_SYLVANA_WALL_01, me);
  1795. +                    CastTimer = 1000;
  1796. +                    HoldTimer = 30000;
  1797. +                    SetEscortPaused(true);
  1798. +                    if (Creature *pWallTarget = me->SummonCreature(NPC_ICE_WALL,me->GetPositionX(),me->GetPositionY(),me->GetPositionZ(),me->GetOrientation(),TEMPSUMMON_MANUAL_DESPAWN,720000))
  1799. +                    {
  1800. +                        m_uipWallTargetGUID = pWallTarget->GetGUID();
  1801. +                        pWallTarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
  1802. +                        if(me->GetEntry() == NPC_JAINA_OUTRO)
  1803. +                            me->CastSpell(pWallTarget, SPELL_DESTROY_ICE_WALL_01, false);
  1804. +                    }
  1805. +                    WallCast = true;
  1806.                      break;
  1807. -                case EVENT_INTRO_A2_2:
  1808. -                    DoScriptText(SAY_JAINA_INTRO_4, me);
  1809. -                    events.ScheduleEvent(EVENT_INTRO_A2_3, 10000);
  1810. +                case 6:
  1811. +                    m_pInstance->SetData(TYPE_ICE_WALL_02, IN_PROGRESS);
  1812. +                    if (Creature* pWallTarget = m_pInstance->instance->GetCreature(m_uipWallTargetGUID))
  1813. +                    {
  1814. +                        if(pWallTarget->isAlive())
  1815. +                        {
  1816. +                            pWallTarget->DespawnOrUnsummon();
  1817. +                            m_uipWallTargetGUID = 0;
  1818. +                        }
  1819. +                    }
  1820. +                    break;
  1821. +                case 8:
  1822. +                    if(me->GetEntry() == NPC_JAINA_OUTRO)
  1823. +                        DoScriptText(SAY_JAINA_WALL_02, me);
  1824. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  1825. +                        DoScriptText(SAY_SYLVANA_WALL_02, me);
  1826. +                    CastTimer = 1000;
  1827. +                    HoldTimer = 30000;
  1828. +                    SetEscortPaused(true);
  1829. +                    if (Creature *pWallTarget = me->SummonCreature(NPC_ICE_WALL,me->GetPositionX(),me->GetPositionY(),me->GetPositionZ(),me->GetOrientation(),TEMPSUMMON_MANUAL_DESPAWN,720000))
  1830. +                    {
  1831. +                        m_uipWallTargetGUID = pWallTarget->GetGUID();
  1832. +                        pWallTarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
  1833. +                        if(me->GetEntry() == NPC_JAINA_OUTRO)
  1834. +                            me->CastSpell(pWallTarget, SPELL_DESTROY_ICE_WALL_01, false);
  1835. +                    }
  1836. +                    WallCast = true;
  1837. +                    break;
  1838. +                case 9:
  1839. +                    if(me->GetEntry() == NPC_JAINA_OUTRO)
  1840. +                        DoScriptText(SAY_JAINA_ESCAPE_01, me);
  1841. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  1842. +                        DoScriptText(SAY_SYLVANA_ESCAPE_01, me);
  1843.                      break;
  1844. -                case EVENT_INTRO_A2_3:
  1845. -                    // TODO: she's doing some kind of spell casting emote
  1846. -                    instance->HandleGameObject(instance->GetData64(DATA_FROSTMOURNE), true);
  1847. -                    events.ScheduleEvent(EVENT_INTRO_A2_4, 10000);
  1848. +                case 11:
  1849. +                    m_pInstance->SetData(TYPE_ICE_WALL_03, IN_PROGRESS);
  1850. +                    if (Creature* pWallTarget = m_pInstance->instance->GetCreature(m_uipWallTargetGUID))
  1851. +                    {
  1852. +                        if(pWallTarget->isAlive())
  1853. +                        {
  1854. +                            pWallTarget->DespawnOrUnsummon();
  1855. +                            m_uipWallTargetGUID = 0;
  1856. +                        }
  1857. +                    }
  1858.                      break;
  1859. -                case EVENT_INTRO_A2_4:
  1860. -                    // spawn UTHER during speach 2
  1861. -                    if (Creature* pUther = me->SummonCreature(NPC_UTHER, UtherSpawnPos, TEMPSUMMON_MANUAL_DESPAWN))
  1862. +                case 12:
  1863. +                    if(me->GetEntry() == NPC_JAINA_OUTRO)
  1864. +                        DoScriptText(SAY_JAINA_WALL_03, me);
  1865. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  1866. +                        DoScriptText(SAY_SYLVANA_WALL_03, me);
  1867. +                    CastTimer = 1000;
  1868. +                    HoldTimer = 30000;
  1869. +                    SetEscortPaused(true);
  1870. +                    if (Creature *pWallTarget = me->SummonCreature(NPC_ICE_WALL,me->GetPositionX(),me->GetPositionY(),me->GetPositionZ(),me->GetOrientation(),TEMPSUMMON_MANUAL_DESPAWN,720000))
  1871.                      {
  1872. -                        pUther->GetMotionMaster()->MoveIdle();
  1873. -                        pUther->SetReactState(REACT_PASSIVE); // be sure he will not aggro arthas
  1874. -                        uiUther = pUther->GetGUID();
  1875. +                        m_uipWallTargetGUID = pWallTarget->GetGUID();
  1876. +                        pWallTarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
  1877. +                        if(me->GetEntry() == NPC_JAINA_OUTRO)
  1878. +                            me->CastSpell(pWallTarget, SPELL_DESTROY_ICE_WALL_01, false);
  1879.                      }
  1880. -                    events.ScheduleEvent(EVENT_INTRO_A2_5, 2000);
  1881. -                    break;
  1882. -                case EVENT_INTRO_A2_5:
  1883. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  1884. -                        DoScriptText(SAY_UTHER_INTRO_A2_1, pUther);
  1885. -                    events.ScheduleEvent(EVENT_INTRO_A2_6, 3000);
  1886. -                    break;
  1887. -                case EVENT_INTRO_A2_6:
  1888. -                    DoScriptText(SAY_JAINA_INTRO_5, me);
  1889. -                    events.ScheduleEvent(EVENT_INTRO_A2_7, 6000);
  1890. -                    break;
  1891. -                case EVENT_INTRO_A2_7:
  1892. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  1893. -                        DoScriptText(SAY_UTHER_INTRO_A2_2, pUther);
  1894. -                    events.ScheduleEvent(EVENT_INTRO_A2_8, 6500);
  1895. -                    break;
  1896. -                case EVENT_INTRO_A2_8:
  1897. -                    DoScriptText(SAY_JAINA_INTRO_6, me);
  1898. -                    events.ScheduleEvent(EVENT_INTRO_A2_9, 2000);
  1899. -                    break;
  1900. -                case EVENT_INTRO_A2_9:
  1901. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  1902. -                        DoScriptText(SAY_UTHER_INTRO_A2_3, pUther);
  1903. -                    events.ScheduleEvent(EVENT_INTRO_A2_10, 9000);
  1904. -                    break;
  1905. -                case EVENT_INTRO_A2_10:
  1906. -                    DoScriptText(SAY_JAINA_INTRO_7, me);
  1907. -                    events.ScheduleEvent(EVENT_INTRO_A2_11, 5000);
  1908. -                    break;
  1909. -                case EVENT_INTRO_A2_11:
  1910. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  1911. -                        DoScriptText(SAY_UTHER_INTRO_A2_4, pUther);
  1912. -                    events.ScheduleEvent(EVENT_INTRO_A2_12, 11000);
  1913. -                    break;
  1914. -                case EVENT_INTRO_A2_12:
  1915. -                    DoScriptText(SAY_JAINA_INTRO_8, me);
  1916. -                    events.ScheduleEvent(EVENT_INTRO_A2_13, 4000);
  1917. -                    break;
  1918. -                case EVENT_INTRO_A2_13:
  1919. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  1920. -                        DoScriptText(SAY_UTHER_INTRO_A2_5, pUther);
  1921. -                    events.ScheduleEvent(EVENT_INTRO_A2_14, 12500);
  1922. -                    break;
  1923. -                case EVENT_INTRO_A2_14:
  1924. -                    DoScriptText(SAY_JAINA_INTRO_9, me);
  1925. -                    events.ScheduleEvent(EVENT_INTRO_A2_15, 10000);
  1926. -                    break;
  1927. -                case EVENT_INTRO_A2_15:
  1928. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  1929. -                        DoScriptText(SAY_UTHER_INTRO_A2_6, pUther);
  1930. -                    events.ScheduleEvent(EVENT_INTRO_A2_16, 22000);
  1931. -                    break;
  1932. -                case EVENT_INTRO_A2_16:
  1933. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  1934. -                        DoScriptText(SAY_UTHER_INTRO_A2_7, pUther);
  1935. -                    events.ScheduleEvent(EVENT_INTRO_A2_17, 4000);
  1936. -                    break;
  1937. -                case EVENT_INTRO_A2_17:
  1938. -                    DoScriptText(SAY_JAINA_INTRO_10, me);
  1939. -                    events.ScheduleEvent(EVENT_INTRO_A2_18, 2000);
  1940. -                    break;
  1941. -                case EVENT_INTRO_A2_18:
  1942. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  1943. +                    WallCast = true;
  1944. +                    break;
  1945. +                case 13:
  1946. +                    if(me->GetEntry() == NPC_JAINA_OUTRO)
  1947. +                        DoScriptText(SAY_JAINA_ESCAPE_02, me);
  1948. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  1949. +                        DoScriptText(SAY_SYLVANA_ESCAPE_02, me);
  1950. +                    break;
  1951. +                case 15:
  1952. +                    m_pInstance->SetData(TYPE_ICE_WALL_04, IN_PROGRESS);
  1953. +                    if (Creature* pWallTarget = m_pInstance->instance->GetCreature(m_uipWallTargetGUID))
  1954.                      {
  1955. -                        pUther->HandleEmoteCommand(EMOTE_ONESHOT_NO);
  1956. -                        DoScriptText(SAY_UTHER_INTRO_A2_8, pUther);
  1957. +                        if(pWallTarget->isAlive())
  1958. +                        {
  1959. +                            pWallTarget->DespawnOrUnsummon();
  1960. +                            m_uipWallTargetGUID = 0;
  1961. +                        }
  1962.                      }
  1963. -                    events.ScheduleEvent(EVENT_INTRO_A2_19, 11000);
  1964.                      break;
  1965. -                case EVENT_INTRO_A2_19:
  1966. -                    DoScriptText(SAY_JAINA_INTRO_11, me);
  1967. -                    events.ScheduleEvent(EVENT_INTRO_LK_1, 2000);
  1968. +                case 16:
  1969. +                    if(me->GetEntry() == NPC_JAINA_OUTRO)
  1970. +                        DoScriptText(SAY_JAINA_WALL_04, me);
  1971. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  1972. +                        DoScriptText(SAY_SYLVANA_WALL_04, me);
  1973. +                    CastTimer = 1000;
  1974. +                    HoldTimer = 30000;
  1975. +                    SetEscortPaused(true);
  1976. +                    if (Creature *pWallTarget = me->SummonCreature(NPC_ICE_WALL,me->GetPositionX(),me->GetPositionY(),me->GetPositionZ(),me->GetOrientation(),TEMPSUMMON_MANUAL_DESPAWN,720000))
  1977. +                    {
  1978. +                        m_uipWallTargetGUID = pWallTarget->GetGUID();
  1979. +                        pWallTarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
  1980. +                        if(me->GetEntry() == NPC_JAINA_OUTRO)
  1981. +                            me->CastSpell(pWallTarget, SPELL_DESTROY_ICE_WALL_01, false);
  1982. +                    }
  1983. +                    WallCast = true;
  1984.                      break;
  1985. -
  1986. -            // H2 Intro Events
  1987. -                case EVENT_INTRO_H2_1:
  1988. -                    DoScriptText(SAY_SYLVANAS_INTRO_1, me);
  1989. -                    events.ScheduleEvent(EVENT_INTRO_H2_2, 8000);
  1990. +                case 19:
  1991. +                    if(me->GetEntry() == NPC_JAINA_OUTRO)
  1992. +                        DoScriptText(SAY_JAINA_TRAP, me);
  1993. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  1994. +                        DoScriptText(SAY_SYLVANA_TRAP, me);
  1995.                      break;
  1996. -                case EVENT_INTRO_H2_2:
  1997. -                    DoScriptText(SAY_SYLVANAS_INTRO_2, me);
  1998. -                    events.ScheduleEvent(EVENT_INTRO_H2_3, 6000);
  1999. +                case 20:
  2000. +                    if (Creature* pWallTarget = m_pInstance->instance->GetCreature(m_uipWallTargetGUID))
  2001. +                    {
  2002. +                        if(pWallTarget->isAlive())
  2003. +                        {
  2004. +                            pWallTarget->DespawnOrUnsummon();
  2005. +                            m_uipWallTargetGUID = 0;
  2006. +                        }
  2007. +                    }
  2008. +                    SetEscortPaused(true);
  2009. +                    if(me->GetEntry() == NPC_JAINA_OUTRO)
  2010. +                        me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_READY2HL);
  2011. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  2012. +                        me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_READY1H);
  2013.                      break;
  2014. -                case EVENT_INTRO_H2_3:
  2015. -                    DoScriptText(SAY_SYLVANAS_INTRO_3, me);
  2016. -                    // TODO: she's doing some kind of spell casting emote
  2017. -                    events.ScheduleEvent(EVENT_INTRO_H2_4, 6000);
  2018. +            }
  2019. +        }
  2020. +
  2021. +        void MoveInLineOfSight(Unit* who)
  2022. +        {
  2023. +            if(!who || !m_pInstance)
  2024. +                return;
  2025. +
  2026. +            if(who->GetTypeId() != TYPEID_PLAYER)
  2027. +                return;
  2028. +
  2029. +            Player* pPlayer = (Player *)who;
  2030. +
  2031. +            if(pPlayer->GetTeam() == ALLIANCE && me->GetEntry() == NPC_SYLVANA_OUTRO)
  2032. +                return;
  2033. +
  2034. +            if(pPlayer->GetTeam() == HORDE && me->GetEntry() == NPC_JAINA_OUTRO)
  2035. +                return;
  2036. +
  2037. +            if(me->IsWithinDistInMap(who, 50.0f)
  2038. +                && m_pInstance->GetData(TYPE_FROST_GENERAL) == DONE
  2039. +                && m_pInstance->GetData(TYPE_PHASE) == 3)
  2040. +            {
  2041. +                pPlayer = (Player *)who;
  2042. +                Event = true;
  2043. +                me->setFaction(FACTION);
  2044. +                m_pInstance->SetData(TYPE_PHASE, 4);
  2045. +            }
  2046. +        }
  2047. +
  2048. +        void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
  2049. +        {
  2050. +            if(!m_pInstance)
  2051. +                return;
  2052. +
  2053. +            if(m_pInstance->GetData(TYPE_LICH_KING) != IN_PROGRESS)
  2054. +            {
  2055. +                uiDamage = 0;
  2056. +                return;
  2057. +            }
  2058. +
  2059. +            if(m_pInstance->GetData(TYPE_LICH_KING) == IN_PROGRESS && WallCast == true)
  2060. +            {
  2061. +                HoldTimer = HoldTimer + 100;
  2062. +                return;
  2063. +            }
  2064. +        }
  2065. +
  2066. +        void JumpNextStep(uint32 Time)
  2067. +        {
  2068. +            StepTimer = Time;
  2069. +            Step++;
  2070. +        }
  2071. +
  2072. +        void Intro()
  2073. +        {
  2074. +            switch(Step)
  2075. +            {
  2076. +                case 0:
  2077. +                    me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
  2078. +                    m_uiLichKingGUID = m_pInstance->GetData64(BOSS_LICH_KING);
  2079. +                    pLichKing = m_pInstance->instance->GetCreature(m_uiLichKingGUID);
  2080. +                    JumpNextStep(100);
  2081.                      break;
  2082. -                case EVENT_INTRO_H2_4:
  2083. -                    // spawn UTHER during speach 2
  2084. -                    if (Creature* pUther = me->SummonCreature(NPC_UTHER, UtherSpawnPos, TEMPSUMMON_MANUAL_DESPAWN))
  2085. +                case 1:
  2086. +                    if(pLichKing)
  2087.                      {
  2088. -                        pUther->GetMotionMaster()->MoveIdle();
  2089. -                        pUther->SetReactState(REACT_PASSIVE); // be sure he will not aggro arthas
  2090. -                        uiUther = pUther->GetGUID();
  2091. +                        pLichKing->SetPhaseMask(65535, true);
  2092. +                        if(me->GetEntry() == NPC_JAINA_OUTRO)
  2093. +                            DoScriptText(SAY_LICH_KING_AGGRO_A, pLichKing);
  2094. +                        if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  2095. +                            DoScriptText(SAY_LICH_KING_AGGRO_H, pLichKing);
  2096. +                        pLichKing->AI()->AttackStart(me);
  2097. +                        me->AI()->AttackStart(pLichKing);
  2098.                      }
  2099. -                    events.ScheduleEvent(EVENT_INTRO_H2_5, 2000);
  2100. -                    break;
  2101. -                case EVENT_INTRO_H2_5:
  2102. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  2103. -                        DoScriptText(SAY_UTHER_INTRO_H2_1, pUther);
  2104. -                    events.ScheduleEvent(EVENT_INTRO_H2_6, 11000);
  2105. -                    break;
  2106. -                case EVENT_INTRO_H2_6:
  2107. -                    DoScriptText(SAY_SYLVANAS_INTRO_4, me);
  2108. -                    events.ScheduleEvent(EVENT_INTRO_H2_7, 3000);
  2109. -                    break;
  2110. -                case EVENT_INTRO_H2_7:
  2111. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  2112. -                        DoScriptText(SAY_UTHER_INTRO_H2_2, pUther);
  2113. -                    events.ScheduleEvent(EVENT_INTRO_H2_8, 6000);
  2114. -                    break;
  2115. -                case EVENT_INTRO_H2_8:
  2116. -                    DoScriptText(SAY_SYLVANAS_INTRO_5, me);
  2117. -                    events.ScheduleEvent(EVENT_INTRO_H2_9, 5000);
  2118. -                    break;
  2119. -                case EVENT_INTRO_H2_9:
  2120. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  2121. -                        DoScriptText(SAY_UTHER_INTRO_H2_3, pUther);
  2122. -                    events.ScheduleEvent(EVENT_INTRO_H2_10, 19000);
  2123. -                    break;
  2124. -                case EVENT_INTRO_H2_10:
  2125. -                    DoScriptText(SAY_SYLVANAS_INTRO_6, me);
  2126. -                    events.ScheduleEvent(EVENT_INTRO_H2_11, 1500);
  2127. -                    break;
  2128. -                case EVENT_INTRO_H2_11:
  2129. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  2130. -                        DoScriptText(SAY_UTHER_INTRO_H2_4, pUther);
  2131. -                    events.ScheduleEvent(EVENT_INTRO_H2_12, 19500);
  2132. -                    break;
  2133. -                case EVENT_INTRO_H2_12:
  2134. -                    DoScriptText(SAY_SYLVANAS_INTRO_7, me);
  2135. -                    events.ScheduleEvent(EVENT_INTRO_H2_13, 2000);
  2136. -                    break;
  2137. -                case EVENT_INTRO_H2_13:
  2138. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  2139. +                    JumpNextStep(3000);
  2140. +                    break;
  2141. +                case 2:
  2142. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  2143.                      {
  2144. -                        pUther->HandleEmoteCommand(EMOTE_ONESHOT_NO);
  2145. -                        DoScriptText(SAY_UTHER_INTRO_H2_5, pUther);
  2146. +                        Fight = false;
  2147. +                        if(pLichKing)
  2148. +                            me->GetMotionMaster()->MovePoint(0, (me->GetPositionX()-5)+rand()%10, (me->GetPositionY()-5)+rand()%10, me->GetPositionZ());
  2149. +                        JumpNextStep(3000);
  2150.                      }
  2151. -                    events.ScheduleEvent(EVENT_INTRO_H2_14, 12000);
  2152. +                    else
  2153. +                        JumpNextStep(100);
  2154.                      break;
  2155. -                case EVENT_INTRO_H2_14:
  2156. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  2157. -                        DoScriptText(SAY_UTHER_INTRO_H2_6, pUther);
  2158. -                    events.ScheduleEvent(EVENT_INTRO_H2_15, 8000);
  2159. +                case 3:
  2160. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  2161. +                        Fight = true;
  2162. +                    JumpNextStep(100);
  2163.                      break;
  2164. -                case EVENT_INTRO_H2_15:
  2165. -                    DoScriptText(SAY_SYLVANAS_INTRO_8, me);
  2166. -                    events.ScheduleEvent(EVENT_INTRO_LK_1, 2000);
  2167. +                case 4:
  2168. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  2169. +                    {
  2170. +                        if(pLichKing)
  2171. +                            me->CastSpell(pLichKing, SPELL_SYLVANA_STEP, false);
  2172. +                        JumpNextStep(3000);
  2173. +                    }
  2174. +                    else
  2175. +                        JumpNextStep(100);
  2176.                      break;
  2177. -
  2178. -            // Remaining Intro Events common for both faction
  2179. -                case EVENT_INTRO_LK_1:
  2180. -                    // Spawn LK in front of door, and make him move to the sword.
  2181. -                    if (Creature* pLichKing = me->SummonCreature(NPC_LICH_KING_EVENT, LichKingSpawnPos, TEMPSUMMON_MANUAL_DESPAWN))
  2182. +                case 5:
  2183. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  2184.                      {
  2185. -                        pLichKing->GetMotionMaster()->MovePoint(0, LichKingMoveThronePos);
  2186. -                        pLichKing->SetReactState(REACT_PASSIVE);
  2187. -                        uiLichKing = pLichKing->GetGUID();
  2188. +                        Fight = false;
  2189. +                        if(pLichKing)
  2190. +                            me->GetMotionMaster()->MovePoint(0, (me->GetPositionX()-5)+rand()%10, (me->GetPositionY()-5)+rand()%10, me->GetPositionZ());
  2191. +                        JumpNextStep(3000);
  2192.                      }
  2193. +                    else
  2194. +                        JumpNextStep(12000);
  2195. +                    break;
  2196. +                case 6:
  2197. +                    Fight = true;
  2198. +
  2199. +                    if(pLichKing)
  2200. +                   {
  2201. +                        me->CastSpell(pLichKing, me->GetEntry() == NPC_JAINA_OUTRO ? SPELL_ICE_PRISON_VISUAL : SPELL_DARK_ARROW,true);
  2202. +                       pLichKing->AttackStop();
  2203. +                   }
  2204. +                    JumpNextStep(2500);
  2205. +                    break;
  2206. +                case 7:
  2207. +                    if(pLichKing && !pLichKing->HasAura(SPELL_ICE_PRISON))
  2208. +                        pLichKing->CastSpell(pLichKing,me->GetEntry() == NPC_JAINA_OUTRO ? SPELL_ICE_PRISON : SPELL_DARK_ARROW,true);
  2209. +
  2210. +                    me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STAND);
  2211. +                    me->AttackStop();
  2212.  
  2213. -                    if (Creature* pUther = me->GetCreature(*me, uiUther))
  2214. +                    if(me->GetEntry() == NPC_JAINA_OUTRO)
  2215.                      {
  2216. -                        if (instance->GetData(DATA_TEAM_IN_INSTANCE) == ALLIANCE)
  2217. -                            DoScriptText(SAY_UTHER_INTRO_A2_9, pUther);
  2218. -                        else
  2219. -                            DoScriptText(SAY_UTHER_INTRO_H2_7, pUther);
  2220. +                        me->RemoveAurasDueToSpell(SPELL_ICE_BARRIER);
  2221. +                        DoScriptText(SAY_JAINA_AGGRO, me);
  2222.                      }
  2223.  
  2224. -                    events.ScheduleEvent(EVENT_INTRO_LK_2, 11000);
  2225. +                    if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  2226. +                        DoScriptText(SAY_SYLVANA_AGGRO, me);
  2227. +
  2228. +                    JumpNextStep(3000);
  2229. +                    break;
  2230. +                case 8:
  2231. +                    me->GetMotionMaster()->MovePoint(0, 5577.187f, 2236.003f, 733.012f);
  2232. +                    if(pLichKing)
  2233. +                        me->SetUInt64Value(UNIT_FIELD_TARGET, pLichKing->GetGUID());
  2234. +                    JumpNextStep(10000);
  2235.                      break;
  2236. +                case 9:
  2237. +                    me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
  2238. +                    Count = 1;
  2239. +                    JumpNextStep(100);
  2240. +                    break;
  2241. +            }
  2242. +        }
  2243.  
  2244. -                case EVENT_INTRO_LK_2:
  2245. -                     if (Creature* pLichKing = me->GetCreature(*me, uiLichKing))
  2246. -                         DoScriptText(SAY_LK_INTRO_1, pLichKing);
  2247. -                     events.ScheduleEvent(EVENT_INTRO_LK_3, 2000);
  2248. -                     break;
  2249. +        void Outro()
  2250. +        {
  2251. +            switch(Step)
  2252. +            {
  2253. +                case 10:
  2254. +                    me->CastSpell(me, SPELL_SHIELD_DISRUPTION,false);
  2255. +                    me->RemoveAurasDueToSpell(SPELL_SILENCE);
  2256. +                    JumpNextStep(6000);
  2257. +                    break;
  2258. +                case 11:
  2259. +                    if(GameObject* pCave = m_pInstance->instance->GetGameObject(m_pInstance->GetData64(GO_CAVE)))
  2260. +                        pCave->SetGoState(GO_STATE_READY);
  2261. +                    me->CastSpell(me, SPELL_SHIELD_DISRUPTION,false);
  2262. +                    me->GetMotionMaster()->MovePoint(0, 5258.911328f,1652.112f,784.295166f);
  2263. +                    JumpNextStep(10000);
  2264. +                    break;
  2265. +                case 12:
  2266. +                    m_pInstance->SetData(TYPE_LICH_KING, DONE);
  2267. +                    JumpNextStep(10000);
  2268. +                    break;
  2269. +                case 13:
  2270. +                    JumpNextStep(20000);
  2271. +                    break;
  2272. +                case 14:
  2273. +                    me->GetMotionMaster()->MovePoint(0, 5240.66f, 1646.93f, 784.302f);
  2274. +                    JumpNextStep(5000);
  2275. +                    break;
  2276. +                case 15:
  2277. +                    me->SetOrientation(0.68f);
  2278. +                    me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
  2279. +                    me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
  2280. +                    QuestCompleate();
  2281. +                    JumpNextStep(5000);
  2282. +                    break;
  2283. +            }
  2284. +        }
  2285.  
  2286. -                case EVENT_INTRO_LK_3:
  2287. -                     // The Lich King banishes Uther to the abyss.
  2288. -                     if (Creature* pUther = me->GetCreature(*me, uiUther))
  2289. -                     {
  2290. -                         pUther->DisappearAndDie();
  2291. -                         uiUther = 0;
  2292. -                     }
  2293. +        void QuestCompleate()
  2294. +        {
  2295. +            if(m_pInstance)
  2296. +            {
  2297. +                Map::PlayerList const &PlayerList = m_pInstance->instance->GetPlayers();
  2298. +                for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
  2299. +                {
  2300. +                    i->getSource()->KilledMonsterCredit(36955, 0);
  2301. +                    i->getSource()->KilledMonsterCredit(37554, 0);
  2302. +                }
  2303. +            }
  2304. +        }
  2305.  
  2306. -                     // He steps forward and removes the runeblade from the heap of skulls.
  2307. +        void UpdateEscortAI(const uint32 diff)
  2308. +        {
  2309. +            if(!m_pInstance || !Event)
  2310. +                return;
  2311.  
  2312. -                     events.ScheduleEvent(EVENT_INTRO_LK_4, 4000);
  2313. -                     break;
  2314. +            DoMeleeAttackIfReady();
  2315.  
  2316. -                case EVENT_INTRO_LK_4:
  2317. -                      if (Creature* pLichKing = me->GetCreature(*me, uiLichKing))
  2318. -                          DoScriptText(SAY_LK_INTRO_2, pLichKing);
  2319. -                    events.ScheduleEvent(EVENT_INTRO_LK_5, 10000);
  2320. -                    break;
  2321. +            if(m_pInstance->GetData(TYPE_PHASE) == 4)
  2322. +            {
  2323. +                if(StepTimer < diff)
  2324. +                    Intro();
  2325. +                else
  2326. +                    StepTimer -= diff;
  2327. +            }
  2328.  
  2329. -                case EVENT_INTRO_LK_5:
  2330. -                    // summon Falric and Marwyn. then go back to the door
  2331. -                    if (Creature* pFalric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
  2332. -                        pFalric->SetVisible(true);
  2333. -                    if (Creature* pMarwyn = me->GetCreature(*me, instance->GetData64(DATA_MARWYN)))
  2334. -                        pMarwyn->SetVisible(true);
  2335. +            if(m_pInstance->GetData(TYPE_LICH_KING) == SPECIAL
  2336. +                && m_pInstance->GetData(TYPE_PHASE) != 6)       //End Cinematic
  2337. +            {
  2338. +                m_pInstance->SetData(TYPE_PHASE, 6);
  2339. +                Step = 10;
  2340. +            }
  2341.  
  2342. -                    if (Creature* pLichKing = me->GetCreature(*me, uiLichKing))
  2343. -                    {
  2344. -                        pLichKing->GetMotionMaster()->MovePoint(0, LichKingSpawnPos);
  2345. -                        DoScriptText(SAY_LK_INTRO_3, pLichKing);
  2346. -                    }
  2347. +            if (m_pInstance->GetData(TYPE_PHASE) == 6)
  2348. +            {
  2349. +                if(StepTimer < diff)
  2350. +                    Outro();
  2351. +                else
  2352. +                    StepTimer -= diff;
  2353. +                return;
  2354. +            }
  2355.  
  2356. -                    events.ScheduleEvent(EVENT_INTRO_LK_6, 8000);
  2357. -                    break;
  2358. +            if(WallCast == true && CastTimer < diff)
  2359. +            {
  2360. +                if(me->GetEntry() == NPC_SYLVANA_OUTRO)
  2361. +                {
  2362. +                   if (Creature* pWallTarget = m_pInstance->instance->GetCreature(m_uipWallTargetGUID))
  2363. +                        me->CastSpell(pWallTarget, SPELL_DESTROY_ICE_WALL_03, false);
  2364. +                    CastTimer = 1000;
  2365. +                }
  2366. +            }
  2367. +            else
  2368. +                CastTimer -= diff;
  2369.  
  2370. -                case EVENT_INTRO_LK_6:
  2371. -                    if (Creature* pFalric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
  2372. -                        DoScriptText(SAY_FALRIC_INTRO_1, pFalric);
  2373. +            if (WallCast == true && HoldTimer < 10000 && ( m_pInstance->GetData(DATA_SUMMONS) == 0 || !me->isInCombat()))
  2374. +            {
  2375. +                WallCast = false;
  2376. +                me->InterruptNonMeleeSpells(false);
  2377. +                SetEscortPaused(false);
  2378. +                if(GameObject* pGate = m_pInstance->instance->GetGameObject(m_uiIceWallGUID))
  2379. +                    pGate->SetGoState(GO_STATE_ACTIVE);
  2380. +                ++Count;
  2381. +                switch(Count)
  2382. +                {
  2383. +                    case 2:
  2384. +                        if(GameObject* pGate = m_pInstance->instance->GetGameObject(m_pInstance->GetData64(GO_ICE_WALL_2)))
  2385. +                        {
  2386. +                            pGate->SetGoState(GO_STATE_READY);
  2387. +                            if(pLichKing && pLichKing->isAlive())
  2388. +                                DoScriptText(SAY_LICH_KING_WALL_02, pLichKing);
  2389. +                            m_uiIceWallGUID = pGate->GetGUID();
  2390. +                        }
  2391. +                        break;
  2392. +                    case 3:
  2393. +                        if(GameObject* pGate = m_pInstance->instance->GetGameObject(m_pInstance->GetData64(GO_ICE_WALL_3)))
  2394. +                        {
  2395. +                            pGate->SetGoState(GO_STATE_READY);
  2396. +                            if(pLichKing && pLichKing->isAlive())
  2397. +                                DoScriptText(SAY_LICH_KING_WALL_03, pLichKing);
  2398. +                            m_uiIceWallGUID = pGate->GetGUID();
  2399. +                        }
  2400. +                        break;
  2401. +                    case 4:
  2402. +                        if(GameObject* pGate = m_pInstance->instance->GetGameObject(m_pInstance->GetData64(GO_ICE_WALL_4)))
  2403. +                        {
  2404. +                            pGate->SetGoState(GO_STATE_READY);
  2405. +                            if(pLichKing && pLichKing->isAlive())
  2406. +                                DoScriptText(SAY_LICH_KING_WALL_04, pLichKing);
  2407. +                            m_uiIceWallGUID = pGate->GetGUID();
  2408. +                        }
  2409. +                        break;
  2410. +                    case 5:
  2411. +                        if(pLichKing && pLichKing->isAlive())
  2412. +                        {
  2413. +                            pLichKing->RemoveAurasDueToSpell(SPELL_WINTER);
  2414. +                            pLichKing->SetSpeed(MOVE_WALK, 2.5f, true);
  2415. +                            Step = 0;
  2416. +                        }
  2417. +                        break;
  2418. +                }
  2419. +            }
  2420. +            else
  2421. +            {
  2422. +                HoldTimer -= diff;
  2423. +                if (HoldTimer <= 0)
  2424. +                    HoldTimer = 0;
  2425. +            }
  2426.  
  2427. -                    events.ScheduleEvent(EVENT_INTRO_LK_7, 2000);
  2428. -                    break;
  2429. +            return;
  2430. +        }
  2431. +    };
  2432.  
  2433. -                case EVENT_INTRO_LK_7:
  2434. -                    if (Creature* pMarwyn = me->GetCreature(*me, instance->GetData64(DATA_MARWYN)))
  2435. -                        DoScriptText(SAY_MARWYN_INTRO_1, pMarwyn);
  2436. +    CreatureAI* GetAI(Creature* pCreature) const
  2437. +    {
  2438. +        return new npc_jaina_and_sylvana_HRextroAI(pCreature);
  2439. +    }
  2440. +};
  2441.  
  2442. -                    events.ScheduleEvent(EVENT_INTRO_LK_8, 2000);
  2443. -                    break;
  2444. +class npc_lich_king_hr : public CreatureScript
  2445. +{
  2446. +public:
  2447. +    npc_lich_king_hr() : CreatureScript("npc_lich_king_hr") { }
  2448.  
  2449. -                case EVENT_INTRO_LK_8:
  2450. -                    if (Creature* pFalric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
  2451. -                        DoScriptText(SAY_FALRIC_INTRO_2, pFalric);
  2452. +    struct npc_lich_king_hrAI : public ScriptedAI
  2453. +    {
  2454. +        npc_lich_king_hrAI(Creature *pCreature) : ScriptedAI(pCreature)
  2455. +        {
  2456. +            Reset();
  2457. +        }
  2458.  
  2459. -                    events.ScheduleEvent(EVENT_INTRO_LK_9, 5000);
  2460. -                    break;
  2461. +        void Reset()
  2462. +        {
  2463. +        }
  2464.  
  2465. -                case EVENT_INTRO_LK_9:
  2466. -                    if (instance->GetData(DATA_TEAM_IN_INSTANCE) == ALLIANCE)
  2467. -                        DoScriptText(SAY_JAINA_INTRO_END, me);
  2468. -                    else
  2469. -                        DoScriptText(SAY_SYLVANAS_INTRO_END, me);
  2470. +        void JustDied(Unit* pKiller)
  2471. +        {
  2472. +        }
  2473.  
  2474. -                    me->GetMotionMaster()->MovePoint(0, LichKingSpawnPos);
  2475. -                    // TODO: Loralen/Koreln shall run also
  2476. -                    events.ScheduleEvent(EVENT_INTRO_END, 10000);
  2477. -                    break;
  2478. +        void AttackStart(Unit* who)
  2479. +        {
  2480. +            return;
  2481. +        }
  2482.  
  2483. -                case EVENT_INTRO_END:
  2484. -                    if (instance)
  2485. -                        instance->SetData(DATA_WAVE_COUNT, SPECIAL);   // start first wave
  2486. +        void UpdateAI(const uint32 diff)
  2487. +        {
  2488. +        }
  2489. +    };
  2490.  
  2491. -                    // Loralen or Koreln disappearAndDie()
  2492. -                    me->DisappearAndDie();
  2493. -                    break;
  2494. +    CreatureAI* GetAI(Creature* pCreature) const
  2495. +    {
  2496. +        return new npc_lich_king_hrAI(pCreature);
  2497. +    }
  2498. +};
  2499.  
  2500. -                case EVENT_SKIP_INTRO:
  2501. -                    // TODO: implement
  2502. +enum GENERAL_EVENT
  2503. +{
  2504. +    SAY_AGGRO                    = -1594519,
  2505. +    SAY_DEATH                    = -1594520,
  2506.  
  2507. -                    if (Creature* pFalric = me->GetCreature(*me, instance->GetData64(DATA_FALRIC)))
  2508. -                        pFalric->SetVisible(true);
  2509. -                    if (Creature* pMarwyn = me->GetCreature(*me, instance->GetData64(DATA_MARWYN)))
  2510. -                        pMarwyn->SetVisible(true);
  2511. +    SPELL_SHIELD_THROWN          = 69222,
  2512. +    SPELL_SPIKE                  = 59446   // this is not right spell!
  2513. +};
  2514.  
  2515. -                    me->GetMotionMaster()->MovePoint(0, LichKingSpawnPos);
  2516. -                    // TODO: Loralen/Koreln shall run also
  2517. +class npc_frostworn_general : public CreatureScript
  2518. +{
  2519. +public:
  2520. +    npc_frostworn_general() : CreatureScript("npc_frostworn_general") { }
  2521.  
  2522. -                    events.ScheduleEvent(EVENT_INTRO_END, 15000);
  2523. -                    break;
  2524. +    struct npc_frostworn_generalAI : public ScriptedAI
  2525. +    {
  2526. +        npc_frostworn_generalAI(Creature *pCreature) : ScriptedAI(pCreature)
  2527. +        {
  2528. +            m_pInstance = (InstanceScript*)pCreature->GetInstanceScript();
  2529. +            Reset();
  2530. +        }
  2531. +
  2532. +        InstanceScript* m_pInstance;
  2533. +
  2534. +        uint32 m_uiShieldTimer;
  2535. +        uint32 m_uiSpikeTimer;
  2536. +
  2537. +        void Reset()
  2538. +        {
  2539. +            if (!m_pInstance)
  2540. +                return;
  2541. +            m_uiShieldTimer = 5000;
  2542. +            m_uiSpikeTimer = 14000;
  2543. +            m_pInstance->SetData(TYPE_FROST_GENERAL, NOT_STARTED);
  2544. +            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  2545. +        }
  2546. +
  2547. +        void JustDied(Unit* pKiller)
  2548. +        {
  2549. +            if (!m_pInstance)
  2550. +                return;
  2551. +            DoScriptText(SAY_DEATH, me);
  2552. +            m_pInstance->SetData(TYPE_FROST_GENERAL, DONE);
  2553. +            
  2554. +            me->SummonCreature(BOSS_LICH_KING, 5564.25f, 2274.69f, 733.01f, 3.93f, TEMPSUMMON_DEAD_DESPAWN);
  2555. +            
  2556. +            if(m_pInstance->GetData(DATA_TEAM_IN_INSTANCE)==ALLIANCE)
  2557. +                me->SummonCreature(NPC_JAINA_OUTRO, 5556.27f, 2266.28f, 733.01f, 0.8f, TEMPSUMMON_DEAD_DESPAWN);
  2558. +            else
  2559. +                me->SummonCreature(NPC_SYLVANA_OUTRO, 5556.27f, 2266.28f, 733.01f, 0.8f, TEMPSUMMON_DEAD_DESPAWN);
  2560. +        }
  2561. +
  2562. +        void MoveInLineOfSight(Unit* pWho)
  2563. +        {
  2564. +            if (!m_pInstance)
  2565. +                return;
  2566. +
  2567. +            if (me->getVictim())
  2568. +                return;
  2569. +
  2570. +            if (pWho->GetTypeId() != TYPEID_PLAYER
  2571. +                || m_pInstance->GetData(TYPE_MARWYN) != DONE
  2572. +                || !me->IsWithinDistInMap(pWho, 20.0f)
  2573. +                ) return;
  2574. +
  2575. +            if (Player* pPlayer = (Player*)pWho)
  2576. +                if (pPlayer->isGameMaster())
  2577. +                    return;
  2578. +
  2579. +            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  2580. +
  2581. +            AttackStart(pWho);
  2582. +        }
  2583. +
  2584. +        void EnterCombat(Unit* victim)
  2585. +        {
  2586. +            if (!m_pInstance)
  2587. +                return;
  2588. +            DoScriptText(SAY_AGGRO, me);
  2589. +            m_pInstance->SetData(TYPE_FROST_GENERAL, IN_PROGRESS);
  2590. +        }
  2591. +
  2592. +        void UpdateAI(const uint32 uiDiff)
  2593. +        {
  2594. +            if(!UpdateVictim())
  2595. +                return;
  2596. +
  2597. +            if(m_uiShieldTimer < uiDiff)
  2598. +            {
  2599. +                if(Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0))
  2600. +                   DoCast(pTarget,SPELL_SHIELD_THROWN);
  2601. +                m_uiShieldTimer = urand(8000, 12000);
  2602.              }
  2603. +            else
  2604. +                m_uiShieldTimer -= uiDiff;
  2605. +
  2606. +            if (m_uiSpikeTimer < uiDiff)
  2607. +            {
  2608. +                if(Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0))
  2609. +                    DoCast(pTarget, SPELL_SPIKE);
  2610. +                m_uiSpikeTimer = urand(15000, 20000);
  2611. +            }
  2612. +            else
  2613. +                m_uiSpikeTimer -= uiDiff;
  2614. +
  2615. +            DoMeleeAttackIfReady();
  2616.          }
  2617.      };
  2618. -
  2619. +    CreatureAI* GetAI(Creature* pCreature) const
  2620. +    {
  2621. +        return new npc_frostworn_generalAI(pCreature);
  2622. +    }
  2623.  };
  2624.  
  2625.  enum TrashSpells
  2626. @@ -628,14 +1474,14 @@ class npc_ghostly_priest : public CreatureScript
  2627.  public:
  2628.      npc_ghostly_priest() : CreatureScript("npc_ghostly_priest") { }
  2629.  
  2630. -    CreatureAI* GetAI(Creature* creature) const
  2631. +    CreatureAI* GetAI(Creature* pCreature) const
  2632.      {
  2633. -        return new npc_ghostly_priestAI(creature);
  2634. +        return new npc_ghostly_priestAI(pCreature);
  2635.      }
  2636.  
  2637.      struct npc_ghostly_priestAI: public ScriptedAI
  2638.      {
  2639. -        npc_ghostly_priestAI(Creature* creature) : ScriptedAI(creature)
  2640. +        npc_ghostly_priestAI(Creature *c) : ScriptedAI(c)
  2641.          {
  2642.          }
  2643.  
  2644. @@ -666,28 +1512,28 @@ public:
  2645.  
  2646.              while (uint32 eventId = events.ExecuteEvent())
  2647.              {
  2648. -                switch (eventId)
  2649. +                switch(eventId)
  2650.                  {
  2651.                      case EVENT_SHADOW_WORD_PAIN:
  2652. -                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  2653. -                            DoCast(target, SPELL_SHADOW_WORD_PAIN);
  2654. +                        if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  2655. +                            DoCast(pTarget, SPELL_SHADOW_WORD_PAIN);
  2656.                          events.ScheduleEvent(EVENT_SHADOW_WORD_PAIN, 8000);
  2657.                          return;
  2658.                      case EVENT_CIRCLE_OF_DESTRUCTION:
  2659. -                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  2660. -                            DoCast(target, SPELL_CIRCLE_OF_DESTRUCTION);
  2661. +                        if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  2662. +                            DoCast(pTarget, SPELL_CIRCLE_OF_DESTRUCTION);
  2663.                          events.ScheduleEvent(EVENT_CIRCLE_OF_DESTRUCTION, 12000);
  2664.                          return;
  2665.                      case EVENT_COWER_IN_FEAR:
  2666. -                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  2667. -                            DoCast(target, SPELL_COWER_IN_FEAR);
  2668. +                        if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  2669. +                            DoCast(pTarget, SPELL_COWER_IN_FEAR);
  2670.                          events.ScheduleEvent(EVENT_COWER_IN_FEAR, 10000);
  2671.                          return;
  2672.                      case EVENT_DARK_MENDING:
  2673.                          // find an ally with missing HP
  2674. -                        if (Unit* target = DoSelectLowestHpFriendly(40, DUNGEON_MODE(30000, 50000)))
  2675. +                        if (Unit *pTarget = DoSelectLowestHpFriendly(40, DUNGEON_MODE(30000, 50000)))
  2676.                          {
  2677. -                            DoCast(target, SPELL_DARK_MENDING);
  2678. +                            DoCast(pTarget, SPELL_DARK_MENDING);
  2679.                              events.ScheduleEvent(EVENT_DARK_MENDING, 20000);
  2680.                          }
  2681.                          else
  2682. @@ -710,14 +1556,14 @@ class npc_phantom_mage : public CreatureScript
  2683.  public:
  2684.      npc_phantom_mage() : CreatureScript("npc_phantom_mage") { }
  2685.  
  2686. -    CreatureAI* GetAI(Creature* creature) const
  2687. +    CreatureAI* GetAI(Creature* pCreature) const
  2688.      {
  2689. -        return new npc_phantom_mageAI(creature);
  2690. +        return new npc_phantom_mageAI(pCreature);
  2691.      }
  2692.  
  2693.      struct npc_phantom_mageAI: public ScriptedAI
  2694.      {
  2695. -        npc_phantom_mageAI(Creature* creature) : ScriptedAI(creature)
  2696. +        npc_phantom_mageAI(Creature *c) : ScriptedAI(c)
  2697.          {
  2698.          }
  2699.  
  2700. @@ -749,11 +1595,11 @@ public:
  2701.  
  2702.              while (uint32 eventId = events.ExecuteEvent())
  2703.              {
  2704. -                switch (eventId)
  2705. +                switch(eventId)
  2706.                  {
  2707.                      case EVENT_FIREBALL:
  2708. -                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  2709. -                            DoCast(target, SPELL_FIREBALL);
  2710. +                        if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  2711. +                            DoCast(pTarget, SPELL_FIREBALL);
  2712.                          events.ScheduleEvent(EVENT_FIREBALL, 15000);
  2713.                          return;
  2714.                      case EVENT_FLAMESTRIKE:
  2715. @@ -761,13 +1607,13 @@ public:
  2716.                          events.ScheduleEvent(EVENT_FLAMESTRIKE, 15000);
  2717.                          return;
  2718.                      case EVENT_FROSTBOLT:
  2719. -                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  2720. -                            DoCast(target, SPELL_FROSTBOLT);
  2721. +                        if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  2722. +                            DoCast(pTarget, SPELL_FROSTBOLT);
  2723.                          events.ScheduleEvent(EVENT_FROSTBOLT, 15000);
  2724.                          return;
  2725.                      case EVENT_CHAINS_OF_ICE:
  2726. -                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  2727. -                            DoCast(target, SPELL_CHAINS_OF_ICE);
  2728. +                        if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  2729. +                            DoCast(pTarget, SPELL_CHAINS_OF_ICE);
  2730.                          events.ScheduleEvent(EVENT_CHAINS_OF_ICE, 15000);
  2731.                          return;
  2732.                      case EVENT_HALLUCINATION:
  2733. @@ -787,9 +1633,9 @@ class npc_phantom_hallucination : public CreatureScript
  2734.  public:
  2735.      npc_phantom_hallucination() : CreatureScript("npc_phantom_hallucination") { }
  2736.  
  2737. -    CreatureAI* GetAI(Creature* creature) const
  2738. +    CreatureAI* GetAI(Creature* pCreature) const
  2739.      {
  2740. -        return new npc_phantom_hallucinationAI(creature);
  2741. +        return new npc_phantom_hallucinationAI(pCreature);
  2742.      }
  2743.  
  2744.      struct npc_phantom_hallucinationAI : public npc_phantom_mage::npc_phantom_mageAI
  2745. @@ -811,14 +1657,14 @@ class npc_shadowy_mercenary : public CreatureScript
  2746.  public:
  2747.      npc_shadowy_mercenary() : CreatureScript("npc_shadowy_mercenary") { }
  2748.  
  2749. -    CreatureAI* GetAI(Creature* creature) const
  2750. +    CreatureAI* GetAI(Creature* pCreature) const
  2751.      {
  2752. -        return new npc_shadowy_mercenaryAI(creature);
  2753. +        return new npc_shadowy_mercenaryAI(pCreature);
  2754.      }
  2755.  
  2756.      struct npc_shadowy_mercenaryAI: public ScriptedAI
  2757.      {
  2758. -        npc_shadowy_mercenaryAI(Creature* creature) : ScriptedAI(creature)
  2759. +        npc_shadowy_mercenaryAI(Creature *c) : ScriptedAI(c)
  2760.          {
  2761.          }
  2762.  
  2763. @@ -849,7 +1695,7 @@ public:
  2764.  
  2765.              while (uint32 eventId = events.ExecuteEvent())
  2766.              {
  2767. -                switch (eventId)
  2768. +                switch(eventId)
  2769.                  {
  2770.                      case EVENT_SHADOW_STEP:
  2771.                          DoCast(SPELL_SHADOW_STEP);
  2772. @@ -860,8 +1706,8 @@ public:
  2773.                          events.ScheduleEvent(EVENT_DEADLY_POISON, 10000);
  2774.                          return;
  2775.                      case EVENT_ENVENOMED_DAGGER_THROW:
  2776. -                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  2777. -                            DoCast(target, SPELL_ENVENOMED_DAGGER_THROW);
  2778. +                        if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  2779. +                            DoCast(pTarget, SPELL_ENVENOMED_DAGGER_THROW);
  2780.                          events.ScheduleEvent(EVENT_ENVENOMED_DAGGER_THROW, 10000);
  2781.                          return;
  2782.                      case EVENT_KIDNEY_SHOT:
  2783. @@ -882,14 +1728,14 @@ class npc_spectral_footman : public CreatureScript
  2784.  public:
  2785.      npc_spectral_footman() : CreatureScript("npc_spectral_footman") { }
  2786.  
  2787. -    CreatureAI* GetAI(Creature* creature) const
  2788. +    CreatureAI* GetAI(Creature* pCreature) const
  2789.      {
  2790. -        return new npc_spectral_footmanAI(creature);
  2791. +        return new npc_spectral_footmanAI(pCreature);
  2792.      }
  2793.  
  2794.      struct npc_spectral_footmanAI: public ScriptedAI
  2795.      {
  2796. -        npc_spectral_footmanAI(Creature* creature) : ScriptedAI(creature)
  2797. +        npc_spectral_footmanAI(Creature *c) : ScriptedAI(c)
  2798.          {
  2799.          }
  2800.  
  2801. @@ -919,7 +1765,7 @@ public:
  2802.  
  2803.              while (uint32 eventId = events.ExecuteEvent())
  2804.              {
  2805. -                switch (eventId)
  2806. +                switch(eventId)
  2807.                  {
  2808.                      case EVENT_SPECTRAL_STRIKE:
  2809.                          DoCast(me->getVictim(), SPELL_SPECTRAL_STRIKE);
  2810. @@ -947,14 +1793,14 @@ class npc_tortured_rifleman : public CreatureScript
  2811.  public:
  2812.      npc_tortured_rifleman() : CreatureScript("npc_tortured_rifleman") { }
  2813.  
  2814. -    CreatureAI* GetAI(Creature* creature) const
  2815. +    CreatureAI* GetAI(Creature* pCreature) const
  2816.      {
  2817. -        return new npc_tortured_riflemanAI(creature);
  2818. +        return new npc_tortured_riflemanAI(pCreature);
  2819.      }
  2820.  
  2821.      struct npc_tortured_riflemanAI  : public ScriptedAI
  2822.      {
  2823. -        npc_tortured_riflemanAI(Creature* creature) : ScriptedAI(creature)
  2824. +        npc_tortured_riflemanAI(Creature *c) : ScriptedAI(c)
  2825.          {
  2826.          }
  2827.  
  2828. @@ -985,16 +1831,16 @@ public:
  2829.  
  2830.              while (uint32 eventId = events.ExecuteEvent())
  2831.              {
  2832. -                switch (eventId)
  2833. +                switch(eventId)
  2834.                  {
  2835.                      case EVENT_SHOOT:
  2836. -                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  2837. -                            DoCast(target, SPELL_SHOOT);
  2838. +                        if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  2839. +                            DoCast(pTarget, SPELL_SHOOT);
  2840.                          events.ScheduleEvent(EVENT_SHOOT, 2000);
  2841.                          return;
  2842.                      case EVENT_CURSED_ARROW:
  2843. -                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  2844. -                            DoCast(target, SPELL_CURSED_ARROW);
  2845. +                        if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  2846. +                            DoCast(pTarget, SPELL_CURSED_ARROW);
  2847.                          events.ScheduleEvent(EVENT_CURSED_ARROW, 10000);
  2848.                          return;
  2849.                      case EVENT_FROST_TRAP:
  2850. @@ -1002,8 +1848,8 @@ public:
  2851.                          events.ScheduleEvent(EVENT_FROST_TRAP, 30000);
  2852.                          return;
  2853.                      case EVENT_ICE_SHOT:
  2854. -                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
  2855. -                            DoCast(target, SPELL_ICE_SHOT);
  2856. +                        if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM))
  2857. +                            DoCast(pTarget, SPELL_ICE_SHOT);
  2858.                          events.ScheduleEvent(EVENT_ICE_SHOT, 15000);
  2859.                          return;
  2860.                  }
  2861. @@ -1017,8 +1863,10 @@ public:
  2862.  
  2863.  void AddSC_halls_of_reflection()
  2864.  {
  2865. -    new npc_jaina_or_sylvanas_hor(true, "npc_sylvanas_hor_part1");
  2866. -    new npc_jaina_or_sylvanas_hor(false, "npc_jaina_hor_part1");
  2867. +    new npc_jaina_and_sylvana_HRintro();
  2868. +    new npc_jaina_and_sylvana_HRextro();
  2869. +    new npc_lich_king_hr();
  2870. +    new npc_frostworn_general();
  2871.      new npc_ghostly_priest();
  2872.      new npc_phantom_mage();
  2873.      new npc_phantom_hallucination();
  2874. diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.h b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.h
  2875. index 1557fd1..4bd27b6 100644
  2876. --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.h
  2877. +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/halls_of_reflection.h
  2878. @@ -1,18 +1,20 @@
  2879.  /*
  2880. - * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
  2881. + * Copyright (C) 2008 - 2012 Trinity <http://www.trinitycore.org/>
  2882. + * Copyright (C) 2008 - 2012 Facecore <https://github.com/SignFinder/FaceCore/>
  2883.   *
  2884. - * This program is free software; you can redistribute it and/or modify it
  2885. - * under the terms of the GNU General Public License as published by the
  2886. - * Free Software Foundation; either version 2 of the License, or (at your
  2887. - * option) any later version.
  2888. + * This program is free software; you can redistribute it and/or modify
  2889. + * it under the terms of the GNU General Public License as published by
  2890. + * the Free Software Foundation; either version 2 of the License, or
  2891. + * (at your option) any later version.
  2892.   *
  2893. - * This program is distributed in the hope that it will be useful, but WITHOUT
  2894. - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  2895. - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  2896. - * more details.
  2897. + * This program is distributed in the hope that it will be useful,
  2898. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2899. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2900. + * GNU General Public License for more details.
  2901.   *
  2902. - * You should have received a copy of the GNU General Public License along
  2903. - * with this program. If not, see <http://www.gnu.org/licenses/>.
  2904. + * You should have received a copy of the GNU General Public License
  2905. + * along with this program; if not, write to the Free Software
  2906. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  2907.   */
  2908.  
  2909.  #ifndef DEF_HALLS_OF_REFLECTION_H
  2910. @@ -20,138 +22,118 @@
  2911.  
  2912.  enum Data
  2913.  {
  2914. -    DATA_FALRIC_EVENT,
  2915. -    DATA_MARWYN_EVENT,
  2916. -    DATA_LICHKING_EVENT,
  2917. -    DATA_WAVE_COUNT,
  2918. -    DATA_TEAM_IN_INSTANCE,
  2919. +    TYPE_PHASE              = 0,
  2920. +    TYPE_EVENT              = 1,
  2921. +    TYPE_FALRIC             = 2,
  2922. +    TYPE_MARWYN             = 3,
  2923. +    TYPE_FROST_GENERAL      = 4,
  2924. +    TYPE_LICH_KING          = 5,
  2925. +    TYPE_ICE_WALL_01        = 6,
  2926. +    TYPE_ICE_WALL_02        = 7,
  2927. +    TYPE_ICE_WALL_03        = 8,
  2928. +    TYPE_ICE_WALL_04        = 9,
  2929. +    TYPE_HALLS              = 10,
  2930. +    MAX_ENCOUNTERS,
  2931. +
  2932. +    DATA_ESCAPE_LIDER       = 101,
  2933. +    DATA_LIDER              = 102,
  2934. +    DATA_SUMMONS            = 103,
  2935. +    DATA_TEAM_IN_INSTANCE   = 104,
  2936. +
  2937. +    /*UNITS*/
  2938. +    NPC_DARK_1                   = 38177, //Shadowy Mercenary
  2939. +    NPC_DARK_2                   = 38176, //Tortured Rifleman
  2940. +    NPC_DARK_3                   = 38173, //Spectral Footman
  2941. +    NPC_DARK_4                   = 38172, //Phantom Mage
  2942. +    NPC_DARK_5                   = 38567, //Phantom Hallucination
  2943. +    NPC_DARK_6                   = 38175, //Ghostly Priest
  2944. +    NPC_JAINA                    = 37221,
  2945. +    NPC_SYLVANA                  = 37223,
  2946. +    NPC_JAINA_OUTRO              = 36955,
  2947. +    NPC_SYLVANA_OUTRO            = 37554,
  2948. +    NPC_ALTAR_TARGET             = 37704,
  2949. +    NPC_UTHER                    = 37225,
  2950. +    NPC_LICH_KING                = 36954,
  2951. +    BOSS_LICH_KING               = 37226,
  2952. +    NPC_ICE_WALL                 = 37014,
  2953. +    NPC_FALRIC                   = 38112,
  2954. +    NPC_MARWYN                   = 38113,
  2955. +    NPC_GHOSTLY_ROGUE            = 38177,
  2956. +    NPC_GHOSTLY_PRIEST           = 38175,
  2957. +    NPC_GHOSTLY_MAGE             = 38172,
  2958. +    NPC_GHOSTLY_FOOTMAN          = 38173,
  2959. +    NPC_GHOSTLY_RIFLEMAN         = 38176,
  2960. +    NPC_GLUK                     = 38567,
  2961. +
  2962. +    NPC_RAGING_GNOUL             = 36940,
  2963. +    NPC_RISEN_WITCH_DOCTOR       = 36941,
  2964. +    NPC_ABON                     = 37069,
  2965. +
  2966. +    NPC_FROST_GENERAL            = 36723,
  2967. +
  2968. +    GO_ICECROWN_DOOR             = 201976, //72802
  2969. +    GO_ICECROWN_DOOR_2           = 197342,
  2970. +    GO_ICECROWN_DOOR_3           = 197343,
  2971. +    GO_IMPENETRABLE_DOOR         = 197341, //72801
  2972. +    GO_FROSTMOURNE_ALTAR         = 202236, //3551
  2973. +    GO_FROSTMOURNE               = 202302, //364
  2974. +
  2975. +    GO_ICE_WALL_1                = 201385,
  2976. +    GO_ICE_WALL_2                = 201885,
  2977. +    GO_ICE_WALL_3                = 202396,
  2978. +    GO_ICE_WALL_4                = 500001,
  2979. +    GO_CAVE                      = 201596,
  2980. +    GO_PORTAL                    = 202079,
  2981. +
  2982. +    GO_CAPTAIN_CHEST_1           = 202212, //3145
  2983. +    GO_CAPTAIN_CHEST_2           = 201710, //30357
  2984. +    GO_CAPTAIN_CHEST_3           = 202337, //3246
  2985. +    GO_CAPTAIN_CHEST_4           = 202336, //3333
  2986.  };
  2987.  
  2988. -enum Data64
  2989. +struct Locations
  2990.  {
  2991. -    DATA_FALRIC,
  2992. -    DATA_MARWYN,
  2993. -    DATA_LICHKING,
  2994. -    DATA_FROSTMOURNE,
  2995. +    float x, y, z, o;
  2996. +    uint32 id;
  2997.  };
  2998.  
  2999. -enum Creatures
  3000. +static Locations SpawnLoc[]=
  3001.  {
  3002. -    NPC_FALRIC                                    = 38112,
  3003. -    NPC_MARWYN                                    = 38113,
  3004. -    NPC_LICH_KING_EVENT                           = 37226,
  3005. -    NPC_LICH_KING_BOSS                            = 36954,
  3006. -
  3007. -    NPC_UTHER                                     = 37225,
  3008. -    NPC_JAINA_PART1                               = 37221,
  3009. -    NPC_JAINA_PART2                               = 36955,
  3010. -    NPC_SYLVANAS_PART1                            = 37223,
  3011. -    NPC_SYLVANAS_PART2                            = 37554,
  3012. -
  3013. -    NPC_WAVE_MERCENARY                            = 38177,
  3014. -    NPC_WAVE_FOOTMAN                              = 38173,
  3015. -    NPC_WAVE_RIFLEMAN                             = 38176,
  3016. -    NPC_WAVE_PRIEST                               = 38175,
  3017. -    NPC_WAVE_MAGE                                 = 38172,
  3018. -};
  3019. -
  3020. -enum GameObjects
  3021. -{
  3022. -    GO_FROSTMOURNE                                = 202302,
  3023. -    GO_FROSTMOURNE_ALTAR                          = 202236,
  3024. -    GO_FRONT_DOOR                                 = 201976,
  3025. -    GO_ARTHAS_DOOR                                = 197341,
  3026. -};
  3027. -
  3028. -enum HorWorldStates
  3029. -{
  3030. -    WORLD_STATE_HOR                               = 4884,
  3031. -    WORLD_STATE_HOR_WAVE_COUNT                    = 4882,
  3032. -};
  3033. -
  3034. -// Common actions from Instance Script to Boss Script
  3035. -enum Actions
  3036. -{
  3037. -    ACTION_ENTER_COMBAT,
  3038. -};
  3039. -
  3040. -// Base class for FALRIC and MARWYN
  3041. -// handled the summonList and the notification events to/from the InstanceScript
  3042. -struct boss_horAI : ScriptedAI
  3043. -{
  3044. -    boss_horAI(Creature* creature) : ScriptedAI(creature), summons(creature)
  3045. -    {
  3046. -        instance = me->GetInstanceScript();
  3047. -    }
  3048. -
  3049. -    InstanceScript* instance;
  3050. -    EventMap events;
  3051. -    SummonList summons;
  3052. -
  3053. -    void Reset()
  3054. -    {
  3055. -        events.Reset();
  3056. -        me->SetVisible(false);
  3057. -        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
  3058. -        me->SetReactState(REACT_PASSIVE);
  3059. -    }
  3060. -
  3061. -    void DamageTaken(Unit* /*who*/, uint32 &uiDamage)
  3062. -    {
  3063. -        if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
  3064. -            uiDamage = 0;
  3065. -    }
  3066. -
  3067. -    void DoAction(const int32 actionID)
  3068. -    {
  3069. -        switch (actionID)
  3070. -        {
  3071. -            case ACTION_ENTER_COMBAT:  // called by InstanceScript when boss shall enter in combat.
  3072. -                // Just in case. Should have been done by InstanceScript
  3073. -                me->SetVisible(true);
  3074. -
  3075. -                // Reset flags
  3076. -                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
  3077. -                me->SetReactState(REACT_AGGRESSIVE);
  3078. -
  3079. -                if (Unit* unit = me->SelectNearestTarget())
  3080. -                    AttackStart(unit);
  3081. -
  3082. -                DoZoneInCombat();
  3083. -                break;
  3084. -        }
  3085. -    }
  3086. -
  3087. -    void JustSummoned(Creature* summoned)
  3088. -    {
  3089. -        summons.Summon(summoned);
  3090. -
  3091. -        if (Unit* target = summoned->SelectNearestTarget())
  3092. -        {
  3093. -            if (summoned->AI())
  3094. -                summoned->AI()->AttackStart(target);
  3095. -            else
  3096. -            {
  3097. -                summoned->GetMotionMaster()->MoveChase(target);
  3098. -                summoned->Attack(target, true);
  3099. -            }
  3100. -        }
  3101. -
  3102. -        if (summoned->AI())
  3103. -            summoned->AI()->DoZoneInCombat();
  3104. -    }
  3105. -
  3106. -    void SummonedCreatureDespawn(Creature* summoned)
  3107. -    {
  3108. -        summons.Despawn(summoned);
  3109. -        if (summons.empty())
  3110. -        {
  3111. -            if (summoned->isAlive())
  3112. -                instance->SetData(DATA_WAVE_COUNT, NOT_STARTED);
  3113. -            else
  3114. -                instance->SetData(DATA_WAVE_COUNT, SPECIAL);
  3115. -        }
  3116. -    }
  3117. +    //Wing 01
  3118. +    {5277.409f, 1993.161f, 707.694f, 0.05f}, //27
  3119. +    {5301.876f, 2041.699f, 707.694f, 4.71f}, //1
  3120. +    {5339.830f, 2020.887f, 707.694f, 3.14f}, //13
  3121. +    {5311.041f, 2042.935f, 707.694f, 4.71f}, //3
  3122. +    {5314.750f, 2039.969f, 707.694f, 4.71f}, //4
  3123. +    {5342.823f, 2003.801f, 707.694f, 3.14f}, //10
  3124. +    {5311.579f, 1972.823f, 707.694f, 1.62f}, //16
  3125. +
  3126. +    //Wing 02
  3127. +    {5272.491f, 2005.673f, 707.694f, 0.05f}, //23
  3128. +    {5302.669f, 1973.050f, 707.694f, 1.62f}, //18
  3129. +    {5346.187f, 2008.058f, 707.694f, 3.14f}, //9
  3130. +    {5319.752f, 2041.321f, 707.694f, 4.71f}, //5
  3131. +    {5344.882f, 1998.714f, 707.694f, 3.14f}, //11
  3132. +    {5340.552f, 1994.735f, 707.694f, 3.14f}, //12
  3133. +    {5306.441f, 2040.358f, 707.694f, 4.71f}, //2
  3134. +
  3135. +    //Wing 03
  3136. +    {5273.297f, 2014.009f, 707.694f, 0.05f}, //25
  3137. +    {5316.062f, 1970.777f, 707.694f, 1.62f}, //15
  3138. +    {5322.498f, 2037.415f, 707.694f, 4.71f}, //6
  3139. +    {5307.087f, 1970.065f, 707.694f, 1.62f}, //17
  3140. +    {5342.460f, 2012.391f, 707.694f, 3.14f}, //8
  3141. +    {5297.601f, 1971.420f, 707.694f, 1.62f}, //19
  3142. +    {5295.668f, 1975.853f, 707.694f, 1.62f}, //20
  3143. +
  3144. +    //Wing 04
  3145. +    {5273.661f, 1996.767f, 707.694f, 0.05f}, //21
  3146. +    {5275.228f, 2001.275f, 707.694f, 0.05f}, //22
  3147. +    {5344.153f, 2017.753f, 707.694f, 3.14f}, //7
  3148. +    {5275.310f, 2009.686f, 707.694f, 0.05f}, //24
  3149. +    {5319.835f, 1975.177f, 707.694f, 1.62f}, //14
  3150. +    {5277.445f, 2017.197f, 707.694f, 0.05f}, //26
  3151. +    {5298.198f, 2037.762f, 707.694f, 4.71f}  //0
  3152.  };
  3153.  
  3154.  #endif
  3155. diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp
  3156. index e360489..62b1975 100644
  3157. --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp
  3158. +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/instance_halls_of_reflection.cpp
  3159. @@ -1,429 +1,384 @@
  3160.  /*
  3161. - * Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
  3162. + * Copyright (C) 2008 - 2012 Trinity <http://www.trinitycore.org/>
  3163. + * Copyright (C) 2008 - 2012 Facecore <https://github.com/SignFinder/FaceCore/>
  3164.   *
  3165. - * This program is free software; you can redistribute it and/or modify it
  3166. - * under the terms of the GNU General Public License as published by the
  3167. - * Free Software Foundation; either version 2 of the License, or (at your
  3168. - * option) any later version.
  3169. + * This program is free software; you can redistribute it and/or modify
  3170. + * it under the terms of the GNU General Public License as published by
  3171. + * the Free Software Foundation; either version 2 of the License, or
  3172. + * (at your option) any later version.
  3173.   *
  3174. - * This program is distributed in the hope that it will be useful, but WITHOUT
  3175. - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  3176. - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  3177. - * more details.
  3178. + * This program is distributed in the hope that it will be useful,
  3179. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3180. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3181. + * GNU General Public License for more details.
  3182.   *
  3183. - * You should have received a copy of the GNU General Public License along
  3184. - * with this program. If not, see <http://www.gnu.org/licenses/>.
  3185. + * You should have received a copy of the GNU General Public License
  3186. + * along with this program; if not, write to the Free Software
  3187. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  3188.   */
  3189.  
  3190. +/* ScriptData
  3191. +SDName: instance_halls_of_reflection
  3192. +SD%Complete: 70%
  3193. +SDComment:
  3194. +SDErrors:
  3195. +SDCategory: instance script
  3196. +SDAuthor: /dev/rsa, modified by MaxXx2021 aka Mioka
  3197. +EndScriptData */
  3198. +
  3199.  #include "ScriptMgr.h"
  3200.  #include "ScriptedCreature.h"
  3201.  #include "InstanceScript.h"
  3202.  #include "halls_of_reflection.h"
  3203. -
  3204. -#define MAX_ENCOUNTER 3
  3205. -
  3206. -/* Halls of Reflection encounters:
  3207. -0- Falric
  3208. -1- Marwyn
  3209. -2- The Lich King
  3210. -*/
  3211. -
  3212. -enum eEnum
  3213. -{
  3214. -    ENCOUNTER_WAVE_MERCENARY                      = 6,
  3215. -    ENCOUNTER_WAVE_FOOTMAN                        = 10,
  3216. -    ENCOUNTER_WAVE_RIFLEMAN                       = 6,
  3217. -    ENCOUNTER_WAVE_PRIEST                         = 6,
  3218. -    ENCOUNTER_WAVE_MAGE                           = 6,
  3219. -};
  3220. -
  3221. -enum Events
  3222. -{
  3223. -    EVENT_NONE,
  3224. -    EVENT_NEXT_WAVE,
  3225. -    EVENT_START_LICH_KING,
  3226. -};
  3227. -
  3228. -static Position PriestSpawnPos[ENCOUNTER_WAVE_PRIEST] =
  3229. -{
  3230. -    {5277.74f, 2016.88f, 707.778f, 5.96903f},
  3231. -    {5295.88f, 2040.34f, 707.778f, 5.07891f},
  3232. -    {5320.37f, 1980.13f, 707.778f, 2.00713f},
  3233. -    {5280.51f, 1997.84f, 707.778f, 0.296706f},
  3234. -    {5302.45f, 2042.22f, 707.778f, 4.90438f},
  3235. -    {5306.57f, 1977.47f, 707.778f, 1.50098f},
  3236. -};
  3237. -
  3238. -static Position MageSpawnPos[ENCOUNTER_WAVE_MAGE] =
  3239. -{
  3240. -    {5312.75f, 2037.12f, 707.778f, 4.59022f},
  3241. -    {5309.58f, 2042.67f, 707.778f, 4.69494f},
  3242. -    {5275.08f, 2008.72f, 707.778f, 6.21337f},
  3243. -    {5279.65f, 2004.66f, 707.778f, 0.069813f},
  3244. -    {5275.48f, 2001.14f, 707.778f, 0.174533f},
  3245. -    {5316.7f, 2041.55f, 707.778f, 4.50295f},
  3246. -};
  3247. -
  3248. -static Position MercenarySpawnPos[ENCOUNTER_WAVE_MERCENARY] =
  3249. -{
  3250. -    {5302.25f, 1972.41f, 707.778f, 1.37881f},
  3251. -    {5311.03f, 1972.23f, 707.778f, 1.64061f},
  3252. -    {5277.36f, 1993.23f, 707.778f, 0.401426f},
  3253. -    {5318.7f, 2036.11f, 707.778f, 4.2237f},
  3254. -    {5335.72f, 1996.86f, 707.778f, 2.74017f},
  3255. -    {5299.43f, 1979.01f, 707.778f, 1.23918f},
  3256. -};
  3257. -
  3258. -static Position FootmenSpawnPos[ENCOUNTER_WAVE_FOOTMAN] =
  3259. -{
  3260. -    {5306.06f, 2037, 707.778f, 4.81711f},
  3261. -    {5344.15f, 2007.17f, 707.778f, 3.15905f},
  3262. -    {5337.83f, 2010.06f, 707.778f, 3.22886f},
  3263. -    {5343.29f, 1999.38f, 707.778f, 2.9147f},
  3264. -    {5340.84f, 1992.46f, 707.778f, 2.75762f},
  3265. -    {5325.07f, 1977.6f, 707.778f, 2.07694f},
  3266. -    {5336.6f, 2017.28f, 707.778f, 3.47321f},
  3267. -    {5313.82f, 1978.15f, 707.778f, 1.74533f},
  3268. -    {5280.63f, 2012.16f, 707.778f, 6.05629f},
  3269. -    {5322.96f, 2040.29f, 707.778f, 4.34587f},
  3270. -};
  3271. -
  3272. -static Position RiflemanSpawnPos[ENCOUNTER_WAVE_RIFLEMAN] =
  3273. -{
  3274. -    {5343.47f, 2015.95f, 707.778f, 3.49066f},
  3275. -    {5337.86f, 2003.4f, 707.778f, 2.98451f},
  3276. -    {5319.16f, 1974, 707.778f, 1.91986f},
  3277. -    {5299.25f, 2036, 707.778f, 5.02655f},
  3278. -    {5295.64f, 1973.76f, 707.778f, 1.18682f},
  3279. -    {5282.9f, 2019.6f, 707.778f, 5.88176f},
  3280. -};
  3281. +#include "World.h"
  3282.  
  3283.  class instance_halls_of_reflection : public InstanceMapScript
  3284.  {
  3285.  public:
  3286.      instance_halls_of_reflection() : InstanceMapScript("instance_halls_of_reflection", 668) { }
  3287.  
  3288. -    InstanceScript* GetInstanceScript(InstanceMap* map) const
  3289. -    {
  3290. -        return new instance_halls_of_reflection_InstanceMapScript(map);
  3291. -    }
  3292. -
  3293.      struct instance_halls_of_reflection_InstanceMapScript : public InstanceScript
  3294.      {
  3295. -        instance_halls_of_reflection_InstanceMapScript(Map* map) : InstanceScript(map) {};
  3296. -
  3297. -        uint64 uiFalric;
  3298. -        uint64 uiMarwyn;
  3299. -        uint64 uiLichKingEvent;
  3300. -        uint64 uiJainaPart1;
  3301. -        uint64 uiSylvanasPart1;
  3302. +        instance_halls_of_reflection_InstanceMapScript(Map* pMap) : InstanceScript(pMap)
  3303. +        {
  3304. +            Difficulty = pMap->GetDifficulty();
  3305. +            Initialize();
  3306. +        }
  3307.  
  3308. -        uint64 uiFrostmourne;
  3309. -        uint64 uiFrostmourneAltar;
  3310. -        uint64 uiArthasDoor;
  3311. -        uint64 uiFrontDoor;
  3312. +        uint32 m_auiEncounter[MAX_ENCOUNTERS+1];
  3313. +        uint32 m_auiLider;
  3314. +        std::string strSaveData;
  3315. +
  3316. +        uint8 Difficulty;
  3317. +        uint8 m_uiSummons;
  3318. +
  3319. +        uint64 m_uiFalricGUID;
  3320. +        uint64 m_uiMarwynGUID;  
  3321. +        uint64 m_uiLichKingGUID;
  3322. +        uint64 m_uiLiderGUID;
  3323. +
  3324. +        uint64 m_uiMainGateGUID;
  3325. +        uint64 m_uiExitGateGUID;
  3326. +        uint64 m_uiDoor2GUID;
  3327. +        uint64 m_uiDoor3GUID;
  3328. +
  3329. +        uint64 m_uiFrostGeneralGUID;
  3330. +        uint64 m_uiCaptainsChestHordeGUID;
  3331. +        uint64 m_uiCaptainsChestAllianceGUID;
  3332. +        uint64 m_uiFrostmourneGUID;
  3333. +        uint64 m_uiFrostmourneAltarGUID;
  3334. +        uint64 m_uiPortalGUID;
  3335. +        uint64 m_uiIceWall1GUID;
  3336. +        uint64 m_uiIceWall2GUID;
  3337. +        uint64 m_uiIceWall3GUID;
  3338. +        uint64 m_uiIceWall4GUID;
  3339. +        uint64 m_uiGoCaveGUID;
  3340. +        uint32 m_uiTeamInInstance;
  3341.  
  3342. -        uint32 uiEncounter[MAX_ENCOUNTER];
  3343. -        uint32 uiTeamInInstance;
  3344. -        uint32 uiWaveCount;
  3345. -        bool bIntroDone;
  3346. +        void Initialize()
  3347. +        {
  3348. +            for (uint8 i = 0; i < MAX_ENCOUNTERS; ++i)
  3349. +                m_auiEncounter[i] = NOT_STARTED;
  3350. +            m_uiMainGateGUID = 0;
  3351. +            m_uiFrostmourneGUID = 0;
  3352. +            m_uiFalricGUID = 0;
  3353. +            m_uiLiderGUID = 0;
  3354. +            m_uiLichKingGUID = 0;
  3355. +            m_uiExitGateGUID = 0;
  3356. +            m_uiSummons = 0;
  3357. +            m_uiIceWall1GUID = 0;
  3358. +            m_uiIceWall2GUID = 0;
  3359. +            m_uiIceWall3GUID = 0;
  3360. +            m_uiIceWall4GUID = 0;
  3361. +            m_uiGoCaveGUID = 0;
  3362. +            m_uiTeamInInstance = 0;
  3363. +        }
  3364.  
  3365. -        EventMap events;
  3366. +        void OpenDoor(uint64 guid)
  3367. +        {
  3368. +            if(!guid) return;
  3369. +            GameObject* go = instance->GetGameObject(guid);
  3370. +            if(go) go->SetGoState(GO_STATE_ACTIVE);
  3371. +        }
  3372.  
  3373. -        void Initialize()
  3374. +        void CloseDoor(uint64 guid)
  3375.          {
  3376. -            events.Reset();
  3377. -
  3378. -            uiFalric = 0;
  3379. -            uiMarwyn = 0;
  3380. -            uiLichKingEvent = 0;
  3381. -            uiJainaPart1 = 0;
  3382. -            uiSylvanasPart1 = 0;
  3383. -
  3384. -            uiFrostmourne = 0;
  3385. -            uiFrostmourneAltar = 0;
  3386. -            uiArthasDoor = 0;
  3387. -            uiFrontDoor = 0;
  3388. -            uiTeamInInstance = 0;
  3389. -            uiWaveCount = 0;
  3390. -            bIntroDone = false;
  3391. -
  3392. -            for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
  3393. -                uiEncounter[i] = NOT_STARTED;
  3394. +            if(!guid) return;
  3395. +            GameObject* go = instance->GetGameObject(guid);
  3396. +            if(go) go->SetGoState(GO_STATE_READY);
  3397.          }
  3398.  
  3399.          void OnCreatureCreate(Creature* creature)
  3400.          {
  3401.              Map::PlayerList const &players = instance->GetPlayers();
  3402.              if (!players.isEmpty())
  3403. -                if (Player* player = players.begin()->getSource())
  3404. -                    uiTeamInInstance = player->GetTeam();
  3405. +                if (Player* pPlayer = players.begin()->getSource())
  3406. +                    m_uiTeamInInstance = pPlayer->GetTeam();
  3407.  
  3408. -            switch (creature->GetEntry())
  3409. +            switch(creature->GetEntry())
  3410.              {
  3411. -                case NPC_FALRIC:
  3412. -                    uiFalric = creature->GetGUID();
  3413. -                    break;
  3414. -                case NPC_MARWYN:
  3415. -                    uiMarwyn = creature->GetGUID();
  3416. -                    break;
  3417. -                case NPC_LICH_KING_EVENT:
  3418. -                    uiLichKingEvent = creature->GetGUID();
  3419. -                    break;
  3420. -                case NPC_JAINA_PART1:
  3421. -                    uiJainaPart1 = creature->GetGUID();
  3422. -                    break;
  3423. -                case NPC_SYLVANAS_PART1:
  3424. -                    uiSylvanasPart1 = creature->GetGUID();
  3425. -                    break;
  3426. +                case NPC_FALRIC:
  3427. +                       m_uiFalricGUID = creature->GetGUID();
  3428. +                       break;
  3429. +                case NPC_MARWYN:
  3430. +                       m_uiMarwynGUID = creature->GetGUID();  
  3431. +                       break;
  3432. +                case BOSS_LICH_KING:
  3433. +                       m_uiLichKingGUID = creature->GetGUID();
  3434. +                       break;
  3435. +                case NPC_FROST_GENERAL:
  3436. +                       m_uiFrostGeneralGUID = creature->GetGUID();
  3437. +                       break;
  3438.              }
  3439.          }
  3440.  
  3441. +        void OnPlayerEnter(Player *pPlayer)
  3442. +        {
  3443. +
  3444. +        enum PhaseControl
  3445. +        {
  3446. +            HORDE_CONTROL_PHASE_SHIFT_1    = 55773,
  3447. +            HORDE_CONTROL_PHASE_SHIFT_2    = 60028,
  3448. +            ALLIANCE_CONTROL_PHASE_SHIFT_1 = 55774,
  3449. +            ALLIANCE_CONTROL_PHASE_SHIFT_2 = 60027,
  3450. +        };
  3451. +        
  3452. +         if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP)) return;
  3453. +
  3454. +            switch (pPlayer->GetTeam())
  3455. +            {
  3456. +                case ALLIANCE:
  3457. +                      if (pPlayer && pPlayer->IsInWorld() && pPlayer->HasAura(HORDE_CONTROL_PHASE_SHIFT_1))
  3458. +                          pPlayer->RemoveAurasDueToSpell(HORDE_CONTROL_PHASE_SHIFT_1);
  3459. +                      pPlayer->CastSpell(pPlayer, HORDE_CONTROL_PHASE_SHIFT_2, false);
  3460. +                      break;
  3461. +                case HORDE:
  3462. +                      if (pPlayer && pPlayer->IsInWorld() && pPlayer->HasAura(ALLIANCE_CONTROL_PHASE_SHIFT_1))
  3463. +                          pPlayer->RemoveAurasDueToSpell(ALLIANCE_CONTROL_PHASE_SHIFT_1);
  3464. +                      pPlayer->CastSpell(pPlayer, ALLIANCE_CONTROL_PHASE_SHIFT_2, false);
  3465. +                      break;
  3466. +            };
  3467. +
  3468. +        };
  3469. +
  3470.          void OnGameObjectCreate(GameObject* go)
  3471.          {
  3472. -            // TODO: init state depending on encounters
  3473. -            switch (go->GetEntry())
  3474. +            switch(go->GetEntry())
  3475.              {
  3476. -                case GO_FROSTMOURNE:
  3477. -                    uiFrostmourne = go->GetGUID();
  3478. -                    go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND);
  3479. -                    HandleGameObject(0, false, go);
  3480. +                case GO_IMPENETRABLE_DOOR: m_uiMainGateGUID = go->GetGUID(); break;
  3481. +                case GO_FROSTMOURNE: m_uiFrostmourneGUID = go->GetGUID(); break;
  3482. +                case GO_ICECROWN_DOOR:     m_uiExitGateGUID = go->GetGUID(); break;
  3483. +                case GO_ICECROWN_DOOR_2:   m_uiDoor2GUID = go->GetGUID(); break;
  3484. +                case GO_ICECROWN_DOOR_3:   m_uiDoor3GUID = go->GetGUID(); break;
  3485. +                case GO_PORTAL:            m_uiPortalGUID = go->GetGUID(); break;
  3486. +                case GO_CAPTAIN_CHEST_1:
  3487. +                                      if (Difficulty == RAID_DIFFICULTY_10MAN_NORMAL)
  3488. +                                      m_uiCaptainsChestHordeGUID = go->GetGUID();
  3489. +                                      break;
  3490. +                case GO_CAPTAIN_CHEST_3:
  3491. +                                      if (Difficulty == RAID_DIFFICULTY_25MAN_NORMAL)
  3492. +                                      m_uiCaptainsChestHordeGUID = go->GetGUID();
  3493. +                                      break;
  3494. +                case GO_CAPTAIN_CHEST_2:
  3495. +                                      if (Difficulty == RAID_DIFFICULTY_10MAN_NORMAL)
  3496. +                                      m_uiCaptainsChestAllianceGUID = go->GetGUID();
  3497. +                                      break;
  3498. +                case GO_CAPTAIN_CHEST_4:
  3499. +                                      if (Difficulty == RAID_DIFFICULTY_25MAN_NORMAL)
  3500. +                                      m_uiCaptainsChestAllianceGUID = go->GetGUID();
  3501. +                                      break;
  3502. +                case GO_ICE_WALL_1:
  3503. +                    m_uiIceWall1GUID = go->GetGUID();
  3504. +                    go->SetGoState(GO_STATE_READY);
  3505.                      break;
  3506. -                case GO_FROSTMOURNE_ALTAR:
  3507. -                    uiFrostmourneAltar = go->GetGUID();
  3508. -                    go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND);
  3509. -                    HandleGameObject(0, true, go);
  3510. +                case GO_ICE_WALL_2:
  3511. +                    m_uiIceWall2GUID = go->GetGUID();
  3512. +                    go->SetGoState(GO_STATE_READY);
  3513.                      break;
  3514. -                case GO_FRONT_DOOR:
  3515. -                    uiFrontDoor = go->GetGUID();
  3516. -                    go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND);
  3517. -                    HandleGameObject(0, true, go);
  3518. +                case GO_ICE_WALL_3:
  3519. +                    m_uiIceWall3GUID = go->GetGUID();
  3520. +                    go->SetGoState(GO_STATE_READY);
  3521.                      break;
  3522. -                case GO_ARTHAS_DOOR:
  3523. -                    uiArthasDoor = go->GetGUID();
  3524. -                    go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND);
  3525. -
  3526. -                    if (uiEncounter[1] == DONE)
  3527. -                        HandleGameObject(0, true, go);
  3528. -                    else
  3529. -                        HandleGameObject(0, false, go);
  3530. +                case GO_ICE_WALL_4:
  3531. +                    m_uiIceWall4GUID = go->GetGUID();
  3532. +                    go->SetGoState(GO_STATE_READY);
  3533. +                    break;
  3534. +                case GO_CAVE:
  3535. +                    m_uiGoCaveGUID = go->GetGUID();
  3536. +                    go->SetGoState(GO_STATE_ACTIVE);
  3537.                      break;
  3538.              }
  3539.          }
  3540.  
  3541. -        void SetData(uint32 type, uint32 data)
  3542. +        void SetData(uint32 uiType, uint32 uiData)
  3543.          {
  3544. -            if (type == DATA_WAVE_COUNT && data == SPECIAL)
  3545. -            {
  3546. -                bIntroDone = true;
  3547. -                events.ScheduleEvent(EVENT_NEXT_WAVE, 10000);
  3548. -                return;
  3549. -            }
  3550. -
  3551. -            if (uiWaveCount && data == NOT_STARTED)
  3552. -                DoWipe();
  3553. -
  3554. -            switch (type)
  3555. +            switch(uiType)
  3556.              {
  3557. -                case DATA_FALRIC_EVENT:
  3558. -                    uiEncounter[0] = data;
  3559. -                    if (data == DONE)
  3560. -                        events.ScheduleEvent(EVENT_NEXT_WAVE, 60000);
  3561. +                case TYPE_PHASE:                m_auiEncounter[uiType] = uiData; break;
  3562. +                case TYPE_EVENT:                m_auiEncounter[uiType] = uiData;
  3563. +                                                uiData = NOT_STARTED;
  3564. +                    break;
  3565. +                case TYPE_FALRIC:               m_auiEncounter[uiType] = uiData;
  3566. +                    if(uiData == SPECIAL)
  3567. +                                                    CloseDoor(m_uiExitGateGUID);
  3568. +                    break;
  3569. +                case TYPE_MARWYN:               m_auiEncounter[uiType] = uiData;
  3570. +                    if(uiData == DONE)
  3571. +                    {
  3572. +                                                   OpenDoor(m_uiMainGateGUID);
  3573. +                                                   OpenDoor(m_uiExitGateGUID);
  3574. +                    }
  3575. +                    break;
  3576. +                case TYPE_FROST_GENERAL:        m_auiEncounter[uiType] = uiData;
  3577. +                                                if(uiData == DONE)
  3578. +                                                   OpenDoor(m_uiDoor2GUID);
  3579. +                    break;
  3580. +                case TYPE_LICH_KING:            m_auiEncounter[uiType] = uiData;
  3581. +                                                if(uiData == IN_PROGRESS)
  3582. +                                                   OpenDoor(m_uiDoor3GUID);
  3583. +                                                if(uiData == DONE)
  3584. +                                                {
  3585. +                                                if (m_auiLider == 1)
  3586. +                                                {
  3587. +                                                if (GameObject* pChest = instance->GetGameObject(m_uiCaptainsChestAllianceGUID))
  3588. +                                                    if (pChest && !pChest->isSpawned()) {
  3589. +                                                        pChest->SetRespawnTime(DAY);
  3590. +                                                    };
  3591. +                                                } else
  3592. +                                                if (GameObject* pChest = instance->GetGameObject(m_uiCaptainsChestHordeGUID))
  3593. +                                                    if (pChest && !pChest->isSpawned()) {
  3594. +                                                        pChest->SetRespawnTime(DAY);
  3595. +                                                    };
  3596. +                                                if (GameObject* pPortal = instance->GetGameObject(m_uiPortalGUID))
  3597. +                                                    if (pPortal && !pPortal->isSpawned()) {
  3598. +                                                        pPortal->SetRespawnTime(DAY);
  3599. +                                                    };
  3600. +                                                }
  3601.                      break;
  3602. -                case DATA_MARWYN_EVENT:
  3603. -                    uiEncounter[1] = data;
  3604. -                    if (data == DONE)
  3605. -                        HandleGameObject(uiArthasDoor, true);
  3606. +                case TYPE_ICE_WALL_01:          m_auiEncounter[uiType] = uiData; break;
  3607. +                case TYPE_ICE_WALL_02:          m_auiEncounter[uiType] = uiData; break;
  3608. +                case TYPE_ICE_WALL_03:          m_auiEncounter[uiType] = uiData; break;
  3609. +                case TYPE_ICE_WALL_04:          m_auiEncounter[uiType] = uiData; break;
  3610. +                case TYPE_HALLS:                m_auiEncounter[uiType] = uiData; break;
  3611. +                case DATA_LIDER:                m_auiLider = uiData;
  3612. +                                                uiData = NOT_STARTED;
  3613.                      break;
  3614. -                case DATA_LICHKING_EVENT:
  3615. -                    uiEncounter[2] = data;
  3616. +                case DATA_SUMMONS:              if (uiData == 3) m_uiSummons = 0;
  3617. +                                                else if (uiData == 1) ++m_uiSummons;
  3618. +                                                else if (uiData == 0) --m_uiSummons;
  3619. +                                                uiData = NOT_STARTED;
  3620.                      break;
  3621.              }
  3622.  
  3623. -            if (data == DONE)
  3624. +            if (uiData == DONE)
  3625. +            {
  3626. +                OUT_SAVE_INST_DATA;
  3627. +
  3628. +                std::ostringstream saveStream;
  3629. +
  3630. +                for(uint8 i = 0; i < MAX_ENCOUNTERS; ++i)
  3631. +                    saveStream << m_auiEncounter[i] << " ";
  3632. +
  3633. +                strSaveData = saveStream.str();
  3634. +
  3635.                  SaveToDB();
  3636. +                OUT_SAVE_INST_DATA_COMPLETE;
  3637. +            }
  3638. +        }
  3639. +
  3640. +        const char* Save()
  3641. +        {
  3642. +            return strSaveData.c_str();
  3643.          }
  3644.  
  3645. -        uint32 GetData(uint32 type)
  3646. +        uint32 GetData(uint32 uiType)
  3647.          {
  3648. -            switch (type)
  3649. +            switch(uiType)
  3650.              {
  3651. -                case DATA_FALRIC_EVENT:         return uiEncounter[0];
  3652. -                case DATA_MARWYN_EVENT:         return uiEncounter[1];
  3653. -                case DATA_LICHKING_EVENT:       return uiEncounter[2];
  3654. -                case DATA_WAVE_COUNT:           return uiWaveCount;
  3655. -                case DATA_TEAM_IN_INSTANCE:     return uiTeamInInstance;
  3656. +                case TYPE_PHASE:                return m_auiEncounter[uiType];
  3657. +                case TYPE_EVENT:                return m_auiEncounter[uiType];
  3658. +                case TYPE_FALRIC:               return m_auiEncounter[uiType];
  3659. +                case TYPE_MARWYN:               return m_auiEncounter[uiType];
  3660. +                case TYPE_LICH_KING:            return m_auiEncounter[uiType];
  3661. +                case TYPE_FROST_GENERAL:        return m_auiEncounter[uiType];
  3662. +                case TYPE_ICE_WALL_01:          return m_auiEncounter[uiType];
  3663. +                case TYPE_ICE_WALL_02:          return m_auiEncounter[uiType];
  3664. +                case TYPE_ICE_WALL_03:          return m_auiEncounter[uiType];
  3665. +                case TYPE_ICE_WALL_04:          return m_auiEncounter[uiType];
  3666. +                case TYPE_HALLS:                return m_auiEncounter[uiType];
  3667. +                case DATA_LIDER:                return m_auiLider;
  3668. +                case DATA_SUMMONS:              return m_uiSummons;
  3669. +                case DATA_TEAM_IN_INSTANCE:     return m_uiTeamInInstance;
  3670. +                default:                        return 0;
  3671.              }
  3672. -
  3673.              return 0;
  3674.          }
  3675.  
  3676. -        uint64 GetData64(uint32 identifier)
  3677. +        void SetData64(uint32 uiData, uint64 uiGuid)
  3678.          {
  3679. -            switch (identifier)
  3680. +            switch(uiData)
  3681.              {
  3682. -                case DATA_FALRIC:               return uiFalric;
  3683. -                case DATA_MARWYN:               return uiMarwyn;
  3684. -                case DATA_LICHKING:             return uiLichKingEvent;
  3685. -                case DATA_FROSTMOURNE:          return uiFrostmourne;
  3686. +                case DATA_ESCAPE_LIDER:
  3687. +                       m_uiLiderGUID = uiGuid;
  3688. +                       break;
  3689.              }
  3690. -
  3691. -            return 0;
  3692.          }
  3693.  
  3694. -        std::string GetSaveData()
  3695. +        uint64 GetData64(uint32 uiData)
  3696.          {
  3697. -            OUT_SAVE_INST_DATA;
  3698. -
  3699. -            std::ostringstream saveStream;
  3700. -            saveStream << "H R 1 " << uiEncounter[0] << ' ' << uiEncounter[1] << ' ' << uiEncounter[2];
  3701. -
  3702. -            OUT_SAVE_INST_DATA_COMPLETE;
  3703. -            return saveStream.str();
  3704. +            switch(uiData)
  3705. +            {
  3706. +                case GO_IMPENETRABLE_DOOR: return m_uiMainGateGUID;
  3707. +                case GO_FROSTMOURNE:       return m_uiFrostmourneGUID;
  3708. +                case NPC_FALRIC:           return m_uiFalricGUID;
  3709. +                case NPC_MARWYN:           return m_uiMarwynGUID;
  3710. +                case BOSS_LICH_KING:       return m_uiLichKingGUID;
  3711. +                case DATA_ESCAPE_LIDER:    return m_uiLiderGUID;
  3712. +                case NPC_FROST_GENERAL:    return m_uiFrostGeneralGUID;
  3713. +                case GO_ICECROWN_DOOR:     return m_uiExitGateGUID;
  3714. +                case GO_ICECROWN_DOOR_2:   return m_uiDoor2GUID;
  3715. +                case GO_ICECROWN_DOOR_3:   return m_uiDoor3GUID;
  3716. +                case GO_ICE_WALL_1:        return m_uiIceWall1GUID;
  3717. +                case GO_ICE_WALL_2:        return m_uiIceWall2GUID;
  3718. +                case GO_ICE_WALL_3:        return m_uiIceWall3GUID;
  3719. +                case GO_ICE_WALL_4:        return m_uiIceWall4GUID;
  3720. +                case GO_CAVE:              return m_uiGoCaveGUID;
  3721. +            }
  3722. +            return 0;
  3723.          }
  3724.  
  3725. -        void Load(const char* in)
  3726. +        void Load(const char* chrIn)
  3727.          {
  3728. -            if (!in)
  3729. +            if (!chrIn)
  3730.              {
  3731.                  OUT_LOAD_INST_DATA_FAIL;
  3732.                  return;
  3733.              }
  3734.  
  3735. -            OUT_LOAD_INST_DATA(in);
  3736. -
  3737. -            char dataHead1, dataHead2;
  3738. -            uint16 version;
  3739. -            uint16 data0, data1, data2;
  3740. +            OUT_LOAD_INST_DATA(chrIn);
  3741.  
  3742. -            std::istringstream loadStream(in);
  3743. -            loadStream >> dataHead1 >> dataHead2 >> version >> data0 >> data1 >> data2;
  3744. +            std::istringstream loadStream(chrIn);
  3745.  
  3746. -            if (dataHead1 == 'H' && dataHead2 == 'R')
  3747. +            for(uint8 i = 0; i < MAX_ENCOUNTERS; ++i)
  3748.              {
  3749. -                uiEncounter[0] = data0;
  3750. -                uiEncounter[1] = data1;
  3751. -                uiEncounter[2] = data2;
  3752. -
  3753. -                for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
  3754. -                    if (uiEncounter[i] == IN_PROGRESS)
  3755. -                        uiEncounter[i] = NOT_STARTED;
  3756. -
  3757. -            } else OUT_LOAD_INST_DATA_FAIL;
  3758. -
  3759. -            if (uiEncounter[0] == DONE || uiEncounter[1] == DONE)
  3760. -                bIntroDone = true;
  3761. +                loadStream >> m_auiEncounter[i];
  3762.  
  3763. -            OUT_LOAD_INST_DATA_COMPLETE;
  3764. -        }
  3765. -
  3766. -        void AddWave()
  3767. -        {
  3768. -            DoUpdateWorldState(WORLD_STATE_HOR, 1);
  3769. -            DoUpdateWorldState(WORLD_STATE_HOR_WAVE_COUNT, uiWaveCount);
  3770. -
  3771. -            switch (uiWaveCount)
  3772. -            {
  3773. -                case 1:
  3774. -                case 2:
  3775. -                case 3:
  3776. -                case 4:
  3777. -                    if (Creature* pFalric = instance->GetCreature(uiFalric))
  3778. -                        SpawnWave(pFalric);
  3779. -                    break;
  3780. -                case 5:
  3781. -                    if (GetData(DATA_FALRIC_EVENT) == DONE)
  3782. -                        events.ScheduleEvent(EVENT_NEXT_WAVE, 10000);
  3783. -                    else if (Creature* pFalric = instance->GetCreature(uiFalric))
  3784. -                        if (pFalric->AI())
  3785. -                            pFalric->AI()->DoAction(ACTION_ENTER_COMBAT);
  3786. -                    break;
  3787. -                case 6:
  3788. -                case 7:
  3789. -                case 8:
  3790. -                case 9:
  3791. -                    if (Creature* pMarwyn  = instance->GetCreature(uiMarwyn))
  3792. -                        SpawnWave(pMarwyn);
  3793. -                    break;
  3794. -                case 10:
  3795. -                    if (GetData(DATA_MARWYN_EVENT) != DONE) // wave should not have been started if DONE. Check anyway to avoid bug exploit!
  3796. -                        if (Creature* pMarwyn = instance->GetCreature(uiMarwyn))
  3797. -                            if (pMarwyn->AI())
  3798. -                                pMarwyn->AI()->DoAction(ACTION_ENTER_COMBAT);
  3799. -                    break;
  3800. +                if (m_auiEncounter[i] == IN_PROGRESS)
  3801. +                    m_auiEncounter[i] = NOT_STARTED;
  3802.              }
  3803. -        }
  3804. -
  3805. -        // Wipe has been detected. Perform cleanup and reset.
  3806. -        void DoWipe()
  3807. -        {
  3808. -            uiWaveCount = 0;
  3809. -            events.Reset();
  3810. -            DoUpdateWorldState(WORLD_STATE_HOR, 1);
  3811. -            DoUpdateWorldState(WORLD_STATE_HOR_WAVE_COUNT, uiWaveCount);
  3812. -            HandleGameObject(uiFrontDoor, true);
  3813. -
  3814. -            // TODO
  3815. -            // in case of wipe, the event is normally restarted by jumping into the center of the room.
  3816. -            // As I can't find a trigger area there, just respawn Jaina/Sylvanas so the event may be restarted.
  3817. -            if (Creature* pJaina = instance->GetCreature(uiJainaPart1))
  3818. -                pJaina->Respawn();
  3819. -            if (Creature* pSylvanas = instance->GetCreature(uiSylvanasPart1))
  3820. -                pSylvanas->Respawn();
  3821. -
  3822. -            if (Creature* pFalric = instance->GetCreature(uiFalric))
  3823. -                pFalric->SetVisible(false);
  3824. -            if (Creature* pMarwyn = instance->GetCreature(uiMarwyn))
  3825. -                pMarwyn->SetVisible(false);
  3826. -        }
  3827. -
  3828. -        // spawn a wave on behalf of the summoner.
  3829. -        void SpawnWave(Creature* summoner)
  3830. -        {
  3831. -            uint32 index;
  3832. -
  3833. -            summoner->SetVisible(true);
  3834. -
  3835. -            // TODO: do composition at random. # of spawn also depends on uiWaveCount
  3836. -            // As of now, it is just one of each.
  3837. -            index = urand(0, ENCOUNTER_WAVE_MERCENARY-1);
  3838. -            summoner->SummonCreature(NPC_WAVE_MERCENARY, MercenarySpawnPos[index], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
  3839. -
  3840. -            index = urand(0, ENCOUNTER_WAVE_FOOTMAN-1);
  3841. -            summoner->SummonCreature(NPC_WAVE_FOOTMAN, FootmenSpawnPos[index], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
  3842. -
  3843. -            index = urand(0, ENCOUNTER_WAVE_RIFLEMAN-1);
  3844. -            summoner->SummonCreature(NPC_WAVE_RIFLEMAN, RiflemanSpawnPos[index], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
  3845. -
  3846. -            index = urand(0, ENCOUNTER_WAVE_PRIEST-1);
  3847. -            summoner->SummonCreature(NPC_WAVE_PRIEST, PriestSpawnPos[index], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
  3848.  
  3849. -            index = urand(0, ENCOUNTER_WAVE_MAGE-1);
  3850. -            summoner->SummonCreature(NPC_WAVE_MAGE, MageSpawnPos[index], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
  3851. +            OUT_LOAD_INST_DATA_COMPLETE;
  3852.          }
  3853.  
  3854. -        void Update(uint32 diff)
  3855. -        {
  3856. -            if (!instance->HavePlayers())
  3857. -                return;
  3858. -
  3859. -            events.Update(diff);
  3860. -
  3861. -            switch (events.ExecuteEvent())
  3862. -            {
  3863. -                case EVENT_NEXT_WAVE:
  3864. -                    uiWaveCount++;
  3865. -                    AddWave();
  3866. -                    break;
  3867. -                case EVENT_START_LICH_KING:
  3868. -                    // TODO
  3869. -                    break;
  3870. -            }
  3871. -        }
  3872.      };
  3873.  
  3874. +    InstanceScript* GetInstanceScript (InstanceMap* pMap) const
  3875. +    {
  3876. +        return new instance_halls_of_reflection_InstanceMapScript(pMap);
  3877. +    }
  3878.  };
  3879.  
  3880. +
  3881.  void AddSC_instance_halls_of_reflection()
  3882.  {
  3883.      new instance_halls_of_reflection();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement