Guest User

Untitled

a guest
Jul 17th, 2013
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 132.00 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify it
  5.  * under the terms of the GNU General Public License as published by the
  6.  * Free Software Foundation; either version 2 of the License, or (at your
  7.  * option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful, but WITHOUT
  10.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11.  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12.  * more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License along
  15.  * with this program. If not, see <http://www.gnu.org/licenses/>.
  16.  */
  17.  
  18. #include "ScriptPCH.h"
  19. #include "ulduar.h"
  20.  
  21. /*
  22. LandofLegends - Entwicklungsnotizen:
  23.  
  24. Allgemein:
  25. Loot
  26.  
  27. Script ist zu 97% fertig.
  28.  
  29. Phase 1 ist komplett
  30. Phase 2 ist fast fertig
  31.   Allgemein:
  32.     Die kleinen Geschichten (visual spells finden)
  33.   YoggSauron:
  34. Phase 3 fertig
  35. */
  36.  
  37. enum Sara_Yells
  38. {
  39.     SAY_SARA_PREFIGHT_1                         = -1603310,
  40.     SAY_SARA_PREFIGHT_2                         = -1603311,
  41.     SAY_SARA_AGGRO_1                            = -1603312,
  42.     SAY_SARA_AGGRO_2                            = -1603313,
  43.     SAY_SARA_AGGRO_3                            = -1603314,
  44.     SAY_SARA_SLAY_1                             = -1603315,
  45.     SAY_SARA_SLAY_2                             = -1603316,
  46.     WHISP_SARA_INSANITY                         = -1603317,
  47.     SAY_SARA_PHASE2_1                           = -1603318,
  48.     SAY_SARA_PHASE2_2                           = -1603319,
  49. };
  50.  
  51. enum KeepersHelpSays
  52. {
  53.     SAY_FREYA_HELP                              = -1603189,
  54.     SAY_MIMIRON_HELP                            = -1603259,
  55.     SAY_THORIM_HELP                             = -1603287,
  56.     SAY_HODIR_HELP                              = -1603217,
  57. };
  58.  
  59. enum YoggSaron_Yells
  60. {
  61.     SAY_PHASE2_1                                = -1603330,
  62.     SAY_PHASE2_2                                = -1603331,
  63.     SAY_PHASE2_3                                = -1603332,
  64.     SAY_PHASE2_4                                = -1603333,
  65.     SAY_PHASE2_5                                = -1603334,
  66.     SAY_PHASE3                                  = -1603335,
  67.     SAY_VISION                                  = -1603336,
  68.     SAY_LUNCATIC_GLAZE                          = -1603337,
  69.     SAY_DEAFENING_ROAR                          = -1603338,
  70.     WHISP_INSANITY_1                            = -1603339,
  71.     WHISP_INSANITY_2                            = -1603340,
  72.     SAY_DEATH                                   = -1603341,
  73. };
  74.  
  75. enum Vision_Says
  76. {
  77.     // King Llane
  78.     SAY_GARONA_1_VISION_1                       = -1603342,
  79.     SAY_GARONA_2_VISION_1                       = -1603343,
  80.     SAY_GARONA_3_VISION_1                       = -1603344,
  81.     SAY_YOGGSARON_4_VISION_1                    = -1603345,
  82.     SAY_YOGGSARON_5_VISION_1                    = -1603346,
  83.     SAY_LLANE_6_VISION_1                        = -1603347,
  84.     SAY_GARONA_7_VISION_1                       = -1603348,
  85.     SAY_YOGGSARON_8_VISION_1                    = -1603349,
  86.     // Lichking
  87.     SAY_LICHKING_1_VISION_2                     = -1603350,
  88.     SAY_CHAMP_2_VISION_2                        = -1603351,
  89.     SAY_CHAMP_3_VISION_2                        = -1603352,
  90.     SAY_LICHKING_4_VISION_2                     = -1603353,
  91.     SAY_YOGGSARON_5_VISION_2                    = -1603354,
  92.     SAY_YOGGSARON_6_VISION_2                    = -1603355,
  93.     // Dragon Soul
  94.     SAY_NELTHARION_1_VISION_3                   = -1603356,
  95.     SAY_YSERA_2_VISION_3                        = -1603357,
  96.     SAY_NELTHARION_3_VISION_3                   = -1603358,
  97.     SAY_MALYGOS_4_VISION_3                      = -1603359,
  98.     SAY_YOGGSARON_5_VISION_3                    = -1603360
  99. };
  100.  
  101. enum Events
  102. {
  103.     ACHIEV_TIMED_START_EVENT                    = 21001, // Dont Need this
  104. };
  105.  
  106. enum Achievments
  107. {
  108.     // Sara
  109.     ACHIEVMENT_KISS_AND_MAKE_UP_10              = 3009,
  110.     ACHIEVMENT_KISS_AND_MAKE_UP_25              = 3011,
  111.     ACHIEVMENT_DRIVE_ME_CRAZY_10                = 3008,
  112.     ACHIEVMENT_DRIVE_ME_CRAZY_25                = 3010,
  113.     ACHIEVMENT_HE_S_NOT_GETTING_ANY_OLDER_10    = 3012,
  114.     ACHIEVMENT_HE_S_NOT_GETTING_ANY_OLDER_25    = 3013,
  115.  
  116.     // Heroic Mode
  117.     ACHIEVMENT_THREE_LIGHTS_IN_THE_DARKNESS_10  = 3157,
  118.     ACHIEVMENT_TWO_LIGHTS_IN_THE_DARKNESS_10    = 3141,
  119.     ACHIEVMENT_ONE_LIGHTS_IN_THE_DARKNESS_10    = 3158,
  120.     ACHIEVMENT_ALONE_IN_THE_DARKNESS_10         = 3159,
  121.     ACHIEVMENT_THREE_LIGHTS_IN_THE_DARKNESS_25  = 3161,
  122.     ACHIEVMENT_TWO_LIGHTS_IN_THE_DARKNESS_25    = 3162,
  123.     ACHIEVMENT_ONE_LIGHTS_IN_THE_DARKNESS_25    = 3163,
  124.     ACHIEVMENT_ALONE_IN_THE_DARKNESS_25         = 3164,
  125.  
  126.     // Realm First - 0 Keeper - 25
  127.     ACHIEVMENT_REALM_FIRST_DEATHS_DEMISE        = 3117,
  128. };
  129.  
  130. enum Entrys
  131. {
  132.     NPC_HELP_KEEPER_FREYA                       = 33241,
  133.     NPC_HELP_KEEPER_MIMIRON                     = 33244,
  134.     NPC_HELP_KEEPER_THORIM                      = 33242,
  135.     NPC_HELP_KEEPER_HODIR                       = 33213,
  136.     // All Phases
  137.     ENTRY_KEEPER_FREYA                          = 33410,
  138.     ENTRY_KEEPER_HODIR                          = 33411,
  139.     ENTRY_KEEPER_MIMIRON                        = 33412,
  140.     ENTRY_KEEPER_THORIM                         = 33413,
  141.     ENTRY_SANITY_WELL                           = 33991,
  142.     // Phase 1
  143.     ENTRY_SARA                                  = 33134,
  144.     ENTRY_OMINOUS_CLOUD                         = 33292,
  145.     ENTRY_GUARDIAN_OF_YOGG_SARON                = 33136,
  146.     // Phase 2
  147.     ENTRY_YOGG_SARON                            = 33288,
  148.     ENTRY_BRAIN_OF_YOGG_SARON                   = 33890,
  149.     ENTRY_DEATH_RAY                             = 33881,
  150.     ENTRY_DEATH_ORB                             = 33882,
  151.     //  Tentakles
  152.     ENTRY_CRUSHER_TENTACLE                      = 33966,
  153.     ENTRY_CORRUPTOR_TENTACLE                    = 33985,
  154.     ENTRY_CONSTRICTOR_TENTACLE                  = 33983,
  155.     //  Brain
  156.     //  All Vision
  157.     ENTRY_BRAIN_PORTAL                          = 34072,
  158.     ENTRY_INFULENCE_TENTACLE                    = 33943,
  159.     ENTRY_LAUGHING_SKULL                        = 33990,
  160.     //  Vision Dragon Soul
  161.     ENTRY_RUBY_CONSORT                          = 33716, // 2 on Roomexit (l & r)
  162.     ENTRY_OBSIDIAN_CONSORT                      = 33720, // 2 on End of the Room (l & r)
  163.     ENTRY_EMERAL_CONSORT                        = 33719, // 2 on North West of the room
  164.     ENTRY_AZURE_CONSORT                         = 33717, // 2 on North East of the room
  165.     ENTRY_NELTHARION_VISION                     = 33523,
  166.     ENTRY_YSERA_VISION                          = 33495,
  167.     ENTRY_MALYGOS_VISION                        = 33535,
  168.     //  Vision Llane
  169.     ENTRY_SUIT_OF_ARMOR                         = 33433, // around the Room
  170.     ENTRY_GARONA_VISION                         = 33436,
  171.     ENTRY_KING_LLANE                            = 33437,
  172.     //  Vision Lich King
  173.     ENTRY_DEATHSWORN_ZEALOT                     = 33567, // 3 Groups of 3 ... left middle right
  174.     ENTRY_LICHKING_VISION                       = 33441,
  175.     ENTRY_IMMOLATED_CHAMPION_VISION             = 33442,
  176.     ENTRY_TURNED_CHAMPION_VISION                = 33962,
  177.     // Phase 3
  178.     ENTRY_IMMORTAL_GUARDIAN                     = 33988,
  179.  
  180.     OBJECT_THE_DRAGON_SOUL                      = 194462,
  181.     OBJECT_FLEE_TO_SURFACE                      = 194625,
  182. };
  183.  
  184. //enum ModelIds
  185. //{
  186. //    SARA_NORMAL                                 = 29117,
  187. //    SARA_TRANSFORM                              = 29182,
  188. //    YOGGSARON_NORMAL                            = 28817,
  189. //    YOGGSARON_TRANSFORM                         = 28945
  190. //};
  191.  
  192. enum MindlessSpell
  193. {
  194.     BRAIN_LINK = 0,
  195.     MALADY_OF_MIND = 1,
  196.     DEATH_RAY = 2
  197. };
  198.  
  199. enum EncounterConstants
  200. {
  201.     CONSTANT_MAX_NOVA_HITS = 8,
  202.     CONSTANT_MAX_LLIANE_TENTACLE_SPAWNS = 8,
  203.     CONSTANT_MAX_LICHKING_TENTACLE_SPAWNS = 9,
  204.     CONSTANT_MAX_DRAGONSOUL_TENTACLE_SPAWNS = 8
  205. };
  206.  
  207. enum Actions
  208. {
  209.     ACTION_NOVA_HIT = 0,
  210.     ACTION_ACTIVATE_CLOUDS = 1,
  211.     ACTION_DEACTIVATE_CLOUDS = 2,
  212.     ACTION_PORTAL_TO_MADNESS_STORMWIND = 3,
  213.     ACTION_PORTAL_TO_MADNESS_DRAGON = 4,
  214.     ACTION_PORTAL_TO_MADNESS_LICHKING = 5,
  215.     ACTION_BRAIN_UNDER_30_PERCENT = 6,
  216.     ACTION_YOGGSARON_KILLED = 7,
  217.     ACTION_DEATH_RAY_MOVE = 8,
  218.     ACTION_USED_MINDCONTROL = 9,
  219.     ACTION_MODIFY_SANITY = 10,
  220. };
  221.  
  222. enum Spells
  223. {
  224.     SPELL_IN_THE_MAWS_OF_THE_OLD_GOD            = 64184,
  225.     //All Phases
  226.     // Keeper Freya
  227.     SPELL_RESILIENCE_OF_NATURE                  = 62670,
  228.     SPELL_SANITY_WELL                           = 64170, // Send Script Effect ... Scripted in Keeper Script (Summon)
  229.     SPELL_SANITY_WELL_OPTIC                     = 63288, // Optical Effect ... Green Light
  230.     SPELL_SANITY_WELL_DEBUFF                    = 64169, // Damage Debuff if you stand in the well
  231.     // Keeper Thorim
  232.     SPELL_FURY_OF_THE_STORM                     = 62702,
  233.     SPELL_TITANIC_STORM                         = 64171, // Triggers 64172
  234.     SPELL_TITANIC_STORM_DUMMY                   = 64172, // Dummy Spell ... kills weakend guardians
  235.     // Keeper Mimiron
  236.     SPELL_SPEED_OF_INVENTION                    = 62671,
  237.     SPELL_DESTABILIZATION_MATRIX                = 65210, // No AoE ... Target every Tentakle or Guardian Random
  238.     // Keeper Hodir
  239.     SPELL_FORTITUDE_OF_FROST                    = 62650,
  240.     SPELL_HODIRS_PROTECTIVE_GAZE                = 64174,
  241.     SPELL_FLASH_FREEZE                          = 64175,
  242.     SPELL_FLASH_FREEZE_COOLDOWN                 = 64176,
  243.     // Sanity
  244.     SPELL_SANITY                                = 63050,
  245.     SPELL_INSANE                                = 63120, // MindControl
  246.     SPELL_INSANE_2                              = 64464, // Let all player looks like FacelessOnes
  247.     //Phase 1:
  248.     SPELL_SUMMON_GUARDIAN                       = 63031,
  249.     SPELL_OMINOUS_CLOUD                         = 60977,
  250.     SPELL_OMINOUS_CLOUD_TRIGGER                 = 60978,
  251.     SPELL_OMINOUS_CLOUD_DAMAGE                  = 60984,
  252.     SPELL_OMINOUS_CLOUD_EFFECT                  = 63084,
  253.     //  Sara
  254.     SPELL_SARAS_FERVOR                          = 63138, // On Player
  255.     SPELL_SARAS_BLESSING                        = 63134, // On Player
  256.     SPELL_SARAS_ANGER                           = 63147, // On "Enemy"
  257.     //  Guardians of Yogg-Saron
  258.     SPELL_DOMINATE_MIND                         = 63042, // Removed by blizz, Needs Sanity Scripting
  259.     SPELL_DARK_VOLLEY                           = 63038, // Needs Sanity Scripting
  260.     SPELL_SHADOW_NOVA                           = 65209, // On Death
  261.     //Phase 2:
  262.     SPELL_SARA_TRANSFORMATION                   = 65157,
  263.     //  Sara - She spams Psychosis without pause on random raid members unless she casts something else. The other three abilities each have a 30 second cooldown, and are used randomly when available.
  264.     SPELL_PSYCHOSIS                             = 65301, // Needs Sanity Scripting
  265.     SPELL_BRAIN_LINK                            = 63802, // Only Apply Aura
  266.     SPELL_BRAIN_LINK_DAMAGE                     = 63803, // Needs Sanity Scripting
  267.     SPELL_BRAIN_LINK_DUMMY                      = 63804, // Dummy Effekt
  268.     SPELL_MALADY_OF_MIND                        = 63830, // Needs Sanity Scripting, Trigger 63881 on remove
  269.     SPELL_DEATH_RAY_SUMMON                      = 63891, // Summond 1 33882 (controll deathray)
  270.     SPELL_DEATH_RAY_DAMAGE_VISUAL               = 63886, // Damage visual Effekt of 33881 (triggered with periodic)
  271.     SPELL_DEATH_RAY_PERIODIC                    = 63883, // Trigger 63884
  272.     SPELL_DEATH_RAY_ORIGIN_VISUAL               = 63893, // Visual Effekt of 33882
  273.     SPELL_DEATH_RAY_WARNING_VISUAL              = 63882,
  274.     SPELL_SARA_SHADOWY_BARRIER                  = 64775,
  275.     // Tentacle
  276.     SPELL_ERUPT                                 = 64144,
  277.     SPELL_TENTACLE_VOID_ZONE                    = 64017,
  278.     //  Crusher Tentacle
  279.     SPELL_DIMISH_POWER                          = 64145, // Aura around Caster
  280.     SPELL_FOCUS_ANGER                           = 57688, // Trigger 57689
  281.     SPELL_CRUSH                                 = 64146,
  282.     //  Corruptor Tentacle
  283.     SPELL_DRAINING_POISON                       = 64152,
  284.     SPELL_BLACK_PLAGUE                          = 64153, // Trigger 64155
  285.     SPELL_APATHY                                = 64156,
  286.     SPELL_CURSE_OF_DOOM                         = 64157,
  287.     //  Constrictor Tentacles
  288.     SPELL_LUNGE                                 = 64123, // Need Vehicle
  289.     SPELL_SQUEEZE_10                            = 64125, // Until killed
  290.     SPELL_SQUEEZE_25                            = 64126,
  291.     //  Influence Tentacle
  292.     SPELL_GRIM_REPRISAL                         = 63305, // Dummy aura
  293.     SPELL_GRIM_REPRISAL_DAMAGE                  = 64039, // Damage 1
  294.     //  Yogg-Saron
  295.     SPELL_EXTINGUISH_ALL_LIFE                   = 64166, // After 15 Minutes
  296.     SPELL_SHADOWY_BARRIER                       = 63894,
  297.     SPELL_SUMMON_CRUSHER_TENTACLE               = 64139,
  298.     SPELL_SUMMON_CURRUPTOR_TENTACLE             = 64143,
  299.     SPELL_SUMMON_CONSTRICTOR_TENTACLES          = 64133,
  300.     //  Brain of Yogg-Sauron
  301.     SPELL_INDUCE_MADNESS                        = 64059,
  302.     SPELL_SHATTERED_ILLUSIONS                   = 64173,
  303.     SPELL_BRAIN_HURT_VISUAL                     = 64361,
  304.     //  Mind Portal
  305.     SPELL_TELEPORT                              = 64027, // Not Used
  306.     SPELL_ILLUSION_ROOM                         = 63988, // Must be removed if not in Room
  307.     //  Lauthing Skull
  308.     SPELL_LS_LUNATIC_GAZE                       = 64167,
  309.     SPELL_LS_LUNATIC_GAZE_EFFECT                = 64168,
  310.     //Phase 3:
  311.     SPELL_YOGG_SARON_TRANSFORMATION             = 63895,
  312.     //  Yogg-Saron
  313.     SPELL_DEAFENING_ROAR                        = 64189, // Cast only on 25plr Mode and only with 0-3 Keepers active
  314.     SPELL_SUMMON_IMMORTAL_GUARDIAN              = 64158,
  315.  
  316.     SPELL_SHADOW_BEACON                         = 64465, // Casted on Immortal Guardian - trigger 64466
  317.     SPELL_EMPOWERING_SHADOWS_SCRP_1             = 64466, // Script Effekt ... as index 64467
  318.     SPELL_EMPOWERING_SHADOWS_SCRP_2             = 64467, // I dont need this
  319.     SPELL_EMPOWERING_SHADOWS_HEAL_10            = 64468, // 10plr Heal
  320.     SPELL_EMPOWERING_SHADOWS_HEAL_25            = 64486, // 20plr Heal
  321.  
  322.     SPELL_LUNATIC_GAZE                          = 64163, // Triggers 4 Times 64164
  323.     SPELL_LUNATIC_GAZE_EFFECT                   = 64164, // Needs Sanity Scripting
  324.  
  325.     //  Immortal Guardian - under 1% no damage
  326.     SPELL_DRAIN_LIFE_10                         = 64159,
  327.     SPELL_DRAIN_LIFE_25                         = 64160,
  328.  
  329.     SPELL_WEAKENED                              = 64162, // Dummy on low health for Titan Storm and Shadow Beacon
  330.     SPELL_EMPOWERED                             = 65294, // stacks 9 times ... on 100% hp it have 9 stacks .. but with <10% it havent any
  331. };
  332.  
  333. enum BossPhase
  334. {
  335.     PHASE_NONE = 0,
  336.     PHASE_SARA = 1,
  337.     PHASE_BRAIN = 2,
  338.     PHASE_YOGG = 3
  339. };
  340.  
  341. enum TentacleType
  342. {
  343.     CRUSHER_TENTACLE        = 0,
  344.     CORRUPTOR_TENTACLE      = 1,
  345.     CONSTRICTOR_TENTACLE    = 2
  346. };
  347.  
  348. enum BrainEventPhase
  349. {
  350.     PORTAL_PHASE_KING_LLIANE = 0,
  351.     PORTAL_PHASE_DRAGON_SOUL = 1,
  352.     PORTAL_PHASE_LICH_KING   = 2,
  353.     PORTAL_PHASE_BRAIN_NONE = 3
  354. };
  355.  
  356. const Position InnerBrainLocation[3] =
  357. {
  358.     {1944.87f,  37.22f, 239.7f, (0.66f*M_PI)}, //King Lliane
  359.     {2045.97f, -25.45f, 239.8f, 0           }, //Dragon Soul
  360.     {1953.41f, -73.73f, 240.0f, (1.33f*M_PI)}  //Lich King
  361. };
  362.  
  363. const Position BrainPortalLocation[10] =
  364. {
  365.     {1970.48f,   -9.75f, 325.5f, 0},
  366.     {1992.76f,  -10.21f, 325.5f, 0},
  367.     {1995.53f,  -39.78f, 325.5f, 0},
  368.     {1969.25f,  -42.00f, 325.5f, 0},
  369.     {1960.62f,  -32.00f, 325.5f, 0},
  370.     {1981.98f,  -5.69f,  325.5f, 0},
  371.     {1982.78f,  -45.73f, 325.5f, 0},
  372.     {2000.66f,  -29.68f, 325.5f, 0},
  373.     {1999.88f,  -19.61f, 325.5f, 0},
  374.     {1961.37f,  -19.54f, 325.5f, 0}
  375. };
  376.  
  377. const Position KingLlaneTentacleLocation[CONSTANT_MAX_LLIANE_TENTACLE_SPAWNS] =
  378. {
  379.     {1949.82f,   50.77f, 239.70f, (0.8f*M_PI)},
  380.     {1955.24f,   72.08f, 239.70f, (1.04f*M_PI)},
  381.     {1944.51f,   90.88f, 239.70f, (1.3f*M_PI)},
  382.     {1923.46f,   96.71f, 239.70f, (1.53f*M_PI)},
  383.     {1904.14f,   85.99f, 239.70f, (1.78f*M_PI)},
  384.     {1898.78f,   64.62f, 239.70f, (0.05f*M_PI)},
  385.     {1909.74f,   45.15f, 239.70f, (0.31f*M_PI)},
  386.     {1931.01f,   39.85f, 239.70f, (0.55f*M_PI)},
  387. };
  388.  
  389. const Position DragonSoulTentacleLocation[CONSTANT_MAX_DRAGONSOUL_TENTACLE_SPAWNS] =
  390. {
  391.     // ENTRY_RUBY_CONSORT
  392.     {2061.44f,  -11.83f, 239.80f, 0},
  393.     {2059.87f,  -37.77f, 239.80f, 0},
  394.     // ENTRY_AZURE_CONSORT
  395.     {2105.42f,  -71.81f, 239.80f, (0.51f*M_PI)},
  396.     {2131.29f,  -60.90f, 239.80f, (0.68f*M_PI)},
  397.     // ENTRY_OBSIDIAN_CONSORT
  398.     {2147.62f,  -42.06f, 239.80f, M_PI},
  399.     {2147.62f,   -6.91f, 239.80f, M_PI},
  400.     //ENTRY_EMERAL_CONSORT
  401.     {2125.64f,   17.08f, 239.80f, (1.35f*M_PI)},
  402.     {2109.06f,   22.69f, 239.80f, (1.42f*M_PI)}
  403. };
  404.  
  405. const Position LichKingTentacleLocation[CONSTANT_MAX_LICHKING_TENTACLE_SPAWNS] =
  406. {
  407.     {1944.20f,  -136.72f, 240.00f, (1.35f*M_PI)},
  408.     {1950.06f,  -139.36f, 240.00f, (1.35f*M_PI)},
  409.     {1948.23f,  -129.44f, 240.00f, (1.35f*M_PI)},
  410.  
  411.     {1920.34f,  -136.38f, 240.00f, (1.35f*M_PI)},
  412.     {1914.44f,  -132.35f, 240.00f, (1.35f*M_PI)},
  413.     {1919.69f,  -129.47f, 240.00f, (1.35f*M_PI)},
  414.  
  415.     {1909.49f,  -111.84f, 240.00f, (1.35f*M_PI)},
  416.     {1902.02f,  -107.69f, 240.00f, (1.35f*M_PI)},
  417.     {1910.28f,  -102.96f, 240.00f, (1.35f*M_PI)}
  418. };
  419.  
  420. const Position BrainLocation = {1980.01f, -25.36f, 260.00f, M_PI};
  421. const Position SaraLocation = {1980.28f, -25.58f, 325.00f, M_PI};
  422.  
  423. const Position InnerBrainTeleportLocation[3] =
  424. {
  425.     {2001.40f, -59.66f, 245.07f, 0},
  426.     {1941.61f, -25.88f, 244.98f, 0},
  427.     {2001.18f,  9.409f, 245.24f, 0}
  428. };
  429.  
  430. const Position KeeperSpawnLocation[4] =
  431. {
  432.     {1939.15f,  42.47f, 338.46f, 1.7f*M_PI}, // Mimiron
  433.     {2037.09f,  25.43f, 338.46f, 1.3f*M_PI}, // Freya
  434.     {2036.88f, -73.66f, 338.46f, 0.7f*M_PI}, // Thorim
  435.     {1939.94f, -90.49f, 338.46f, 0.3f*M_PI} // Hodir
  436. };
  437.  
  438. const Position FreyaSanityWellLocation[5] =
  439. {
  440.     {1901.21f, -48.69f, 332.00f, 0},
  441.     {1901.90f,  -2.78f, 332.30f, 0},
  442.     {1993.58f,  45.56f, 332.00f, 0},
  443.     {1985.87f, -91.10f, 330.20f, 0},
  444.     {2040.12f, -39.16f, 329.00f, 0},
  445. };
  446.  
  447. const Position KingLlaneSkullLocation[3] =
  448. {
  449.     {1929.41f,  45.27f, 239.70f, 0},
  450.     {1902.31f,  72.53f, 239.70f, 0},
  451.     {1925.10f,  91.52f, 239.70f, 0}
  452. };
  453.  
  454. const Position LichkingSkullLocation[3] =
  455. {
  456.     {1955.12f, -111.96f,  240.00f, 0},
  457.     {1919.55f, -131.94f,  240.00f, 0},
  458.     {1921.03f,  -93.46f,  240.00f, 0}
  459. };
  460.  
  461. const Position DragonSoulSkullLocation[4] =
  462. {
  463.     {2115.89f,   4.63f,  239.80f, 0},
  464.     {2080.65f,  37.47f,  244.3f, 0},
  465.     {2170.20f, -33.31f,  244.3f, 0},
  466.     {2090.49f, -57.40f,  239.8f, 0}
  467. };
  468.  
  469. const Position EventNpcLocation[9] =
  470. {
  471.     { 1928.23f, 66.81f, 242.40f, 5.207f }, // King Llane
  472.     { 1929.78f, 63.60f, 242.40f, 2.124f }, // Garona - kneeling
  473.     { 2103.87f, -13.13f, 242.65f, 4.692f }, // Ysera
  474.     { 2118.68f, -25.56f, 242.65f, M_PI}, // Neltharion
  475.     { 2095.87f, -34.47f, 242.65f, 0.836f }, // Malygos
  476.     { 2104.61f, -25.36f, 242.65f, 0.0f }, // The Dragon Soul
  477.     { 1903.41f, -160.21f, 239.99f, 1.114f }, // Immolated Champion
  478.     { 1909.31f, -155.88f, 239.99f, 4.222f }, // Turned Champion
  479.     { 1907.02f, -153.92f, 239.99f, 4.187f }, // The Lich King
  480.  
  481. };
  482.  
  483. struct EventNPC
  484. {
  485.     uint32 entry;
  486.     uint64 guid;
  487. };
  488.  
  489. struct EventSpeech
  490. {
  491.     uint32 npc_entry;
  492.     int32 speech_entry;
  493.     uint32 next_speech;
  494.     bool isSpeaking;
  495. };
  496.  
  497. const uint32  EventNpcEntrys[9] =
  498. {
  499.     ENTRY_KING_LLANE,
  500.     ENTRY_GARONA_VISION,
  501.     ENTRY_YSERA_VISION,
  502.     ENTRY_NELTHARION_VISION,
  503.     ENTRY_MALYGOS_VISION,
  504.     OBJECT_THE_DRAGON_SOUL,
  505.     ENTRY_IMMOLATED_CHAMPION_VISION,
  506.     ENTRY_TURNED_CHAMPION_VISION,
  507.     ENTRY_LICHKING_VISION,
  508. };
  509.  
  510. const EventSpeech EventNpcSpeaching[19] =
  511. {
  512.     {ENTRY_GARONA_VISION,SAY_GARONA_1_VISION_1,3000,true},
  513.     {ENTRY_GARONA_VISION,SAY_GARONA_2_VISION_1,5000,true},
  514.     {ENTRY_GARONA_VISION,SAY_GARONA_3_VISION_1,5000,true},
  515.     {ENTRY_YOGG_SARON,SAY_YOGGSARON_4_VISION_1,3000,true},
  516.     {ENTRY_YOGG_SARON,SAY_YOGGSARON_5_VISION_1,3000,true},
  517.     {ENTRY_KING_LLANE,SAY_LLANE_6_VISION_1,5000,true},
  518.     {ENTRY_GARONA_VISION,SAY_GARONA_7_VISION_1,5000,true},
  519.     {ENTRY_YOGG_SARON,SAY_YOGGSARON_8_VISION_1,5000,false},
  520.  
  521.     {ENTRY_LICHKING_VISION,SAY_LICHKING_1_VISION_2,5000,true},/*8*/
  522.     {ENTRY_IMMOLATED_CHAMPION_VISION,SAY_CHAMP_2_VISION_2,5000,true},
  523.     {ENTRY_IMMOLATED_CHAMPION_VISION,SAY_CHAMP_3_VISION_2,5000,true},
  524.     {ENTRY_LICHKING_VISION,SAY_LICHKING_4_VISION_2,5000,true},
  525.     {ENTRY_YOGG_SARON,SAY_YOGGSARON_5_VISION_2,5000,true},
  526.     {ENTRY_YOGG_SARON,SAY_YOGGSARON_6_VISION_2,5000,false},
  527.  
  528.     {ENTRY_NELTHARION_VISION,SAY_NELTHARION_1_VISION_3,5000,true},/*14*/
  529.     {ENTRY_YSERA_VISION,SAY_YSERA_2_VISION_3,5000,true},
  530.     {ENTRY_NELTHARION_VISION,SAY_NELTHARION_3_VISION_3,5000,true},
  531.     {ENTRY_MALYGOS_VISION,SAY_MALYGOS_4_VISION_3,5000,true},
  532.     {ENTRY_YOGG_SARON,SAY_YOGGSARON_5_VISION_3,5000,false},
  533. };
  534.  
  535. bool IsPlayerInBrainRoom(const Player* pPlayer)
  536. {
  537.     return pPlayer->GetPositionZ() < 300;
  538. }
  539.  
  540. class boss_sara : public CreatureScript
  541. {
  542. public:
  543.     boss_sara() : CreatureScript("boss_sara") { }
  544.  
  545.     CreatureAI* GetAI(Creature* pCreature) const
  546.     {
  547.         return new boss_saraAI (pCreature);
  548.     }
  549.  
  550.     struct boss_saraAI : public ScriptedAI
  551.     {
  552.         boss_saraAI(Creature *c) : ScriptedAI(c), Summons(me)
  553.         {
  554.             m_pInstance = c->GetInstanceScript();
  555.             me->SetFlying(true);
  556.             SetImmuneToPushPullEffects(true);
  557.         }
  558.  
  559.         InstanceScript* m_pInstance;
  560.         SummonList Summons;
  561.  
  562.         BossPhase m_Phase;
  563.         uint32 uiAmountKeeperActive;
  564.  
  565.         uint64 guidYogg;
  566.         uint64 guidYoggBrain;
  567.         std::list<uint64> guidEventTentacles;
  568.         std::list<uint64> guidEventSkulls;
  569.         std::list<EventNPC> listEventNPCs;
  570.  
  571.         bool bUsedMindcontroll;
  572.  
  573.         // Phase 1
  574.         uint32 uiSarasHelp_Timer;
  575.  
  576.         uint32 uiGuardianSummon_Timer;
  577.         uint32 uilastGuardianSummon_Timer;
  578.         uint32 uiRandomYell_Timer;
  579.  
  580.         uint32 NovaHitCounter;
  581.         // Phase 2
  582.         Actions lastBrainAction;
  583.         bool IsSpeaking;
  584.         uint32 SpeakingPhase;
  585.         uint32 uiSpeaking_Timer;
  586.  
  587.         uint32 uiPsychosis_Timer;
  588.         uint32 uiMindSpell_Timer;
  589.         uint32 uiTentacle_Timer;
  590.         uint32 uiTentacle1_Timer;
  591.  
  592.         uint32 uiEnrage_Timer;
  593.         uint32 uiMadness_Timer;
  594.  
  595.         uint32 uiBrainEvents_Count;
  596.         BrainEventPhase currentBrainEventPhase;
  597.  
  598.         bool IsEventSpeaking;
  599.         uint32 EventSpeakingPhase;
  600.  
  601.         // Phase 3
  602.         uint32 uiDeafeningRoar_Timer;
  603.         uint32 uiShadowBeacon_Timer;
  604.         uint32 uiLunaticGaze_Timer;
  605.  
  606.         void CloudHandling(bool remove)
  607.         {
  608.             std::list<Creature*> CloudList;
  609.             me->GetCreatureListWithEntryInGrid(CloudList,ENTRY_OMINOUS_CLOUD,100.0f);
  610.             if(!CloudList.empty())
  611.             {
  612.                 for(std::list<Creature*>::iterator itr = CloudList.begin(); itr != CloudList.end(); itr++)
  613.                 {
  614.                     if(remove) (*itr)->AI()->DoAction(ACTION_DEACTIVATE_CLOUDS);
  615.                     else (*itr)->AI()->DoAction(ACTION_ACTIVATE_CLOUDS);
  616.                 }
  617.             }
  618.         }
  619.  
  620.         void Reset()
  621.         {
  622.             Summons.DespawnAll();
  623.             guidEventTentacles = std::list<uint64>();
  624.             guidEventSkulls = std::list<uint64>();
  625.             listEventNPCs = std::list<EventNPC>();
  626.  
  627.             me->InterruptNonMeleeSpells(false);
  628.             // Zurueck an Home ... muss nicht sein ist aber besser so
  629.             Position pos = me->GetHomePosition();
  630.             me->NearTeleportTo(pos.m_positionX,pos.m_positionY,pos.m_positionZ,pos.m_orientation);
  631.             me->RemoveAurasDueToSpell(SPELL_SHATTERED_ILLUSIONS);
  632.             me->RemoveAurasDueToSpell(SPELL_SARA_SHADOWY_BARRIER);
  633.  
  634.             // Remove Random MoveMaster
  635.             me->GetMotionMaster()->Clear(false);
  636.             me->GetMotionMaster()->MoveIdle();
  637.  
  638.             // Reset Display
  639.             me->setFaction(35);
  640.             me->SetVisible(true);
  641.             //me->SetDisplayId(me->GetNativeDisplayId());
  642.             me->RemoveAurasDueToSpell(SPELL_SARA_TRANSFORMATION);
  643.             // Reset Health
  644.             me->SetHealth(me->GetMaxHealth());
  645.             // Remove Not Attackable Flags
  646.             //me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  647.             //me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  648.  
  649.             // Reset Phase
  650.             m_Phase = PHASE_NONE;
  651.             // Respawn Clouds
  652.             CloudHandling(false);
  653.             SetSanityAura(true);
  654.             // Reset HitCounter Phase 1
  655.             NovaHitCounter = CONSTANT_MAX_NOVA_HITS;
  656.             currentBrainEventPhase = PORTAL_PHASE_BRAIN_NONE;
  657.  
  658.             // Spawn Yoggy if not spawned
  659.             Creature* yogg = me->GetCreature(*me,guidYogg);
  660.             if(yogg) yogg->DespawnOrUnsummon();
  661.             if(yogg = DoSummon(ENTRY_YOGG_SARON,SaraLocation,0,TEMPSUMMON_MANUAL_DESPAWN))
  662.                 yogg->SetLootMode(LOOT_MODE_DEFAULT);
  663.  
  664.             Creature* yoggbrain = me->GetCreature(*me,guidYoggBrain);
  665.             if(yoggbrain) yoggbrain->DespawnOrUnsummon();
  666.             DoSummon(ENTRY_BRAIN_OF_YOGG_SARON,BrainLocation,0,TEMPSUMMON_MANUAL_DESPAWN);
  667.  
  668.             if(m_pInstance)
  669.                 m_pInstance->SetBossState(TYPE_YOGGSARON,NOT_STARTED);
  670.  
  671.             uiRandomYell_Timer = urand(10000,20000);
  672.  
  673.             bUsedMindcontroll = false;
  674.             uiAmountKeeperActive = -1;
  675.         }
  676.  
  677.         void JustDied(Unit *killer)
  678.         {
  679.             if(m_pInstance)
  680.                 m_pInstance->SetBossState(TYPE_YOGGSARON,DONE);
  681.  
  682.             SetSanityAura(true);
  683.             Summons.DespawnAll();
  684.         }
  685.  
  686.         void DoSpawnKeeperForSupport() // Despawn on Sara Reset
  687.         {
  688.             if(m_pInstance)
  689.             {
  690.                 uint32 supportFlag = m_pInstance->GetData(DATA_KEEPER_SUPPORT_YOGG);
  691.  
  692.                 if((supportFlag & MIMIRON_SUPPORT) == MIMIRON_SUPPORT)
  693.                     DoSummon(ENTRY_KEEPER_MIMIRON,KeeperSpawnLocation[0],0,TEMPSUMMON_MANUAL_DESPAWN);
  694.                 if((supportFlag & FREYA_SUPPORT) == FREYA_SUPPORT)
  695.                     DoSummon(ENTRY_KEEPER_FREYA,KeeperSpawnLocation[1],0,TEMPSUMMON_MANUAL_DESPAWN);
  696.                 if((supportFlag & THORIM_SUPPORT) == THORIM_SUPPORT)
  697.                     DoSummon(ENTRY_KEEPER_THORIM,KeeperSpawnLocation[2],0,TEMPSUMMON_MANUAL_DESPAWN);
  698.                 if((supportFlag & HODIR_SUPPORT) == HODIR_SUPPORT)
  699.                     DoSummon(ENTRY_KEEPER_HODIR,KeeperSpawnLocation[3],0,TEMPSUMMON_MANUAL_DESPAWN);
  700.             }
  701.         }
  702.  
  703.         void EnterCombat(Unit* /*who*/)
  704.         {
  705.             uiSarasHelp_Timer = urand(5000,6000);
  706.             uiGuardianSummon_Timer = 10000;
  707.             uilastGuardianSummon_Timer = 35000;
  708.  
  709.             uiPsychosis_Timer = urand(5000,5000);
  710.             uiMindSpell_Timer = urand(30000,30000);
  711.             uiTentacle_Timer = urand(3000,5000);
  712.             uiTentacle1_Timer = 1000;
  713.             uiMadness_Timer = 60000;
  714.  
  715.             uiDeafeningRoar_Timer = urand(30000,60000);
  716.             uiShadowBeacon_Timer = 30000;
  717.             uiLunaticGaze_Timer = 12000;
  718.  
  719.             uiEnrage_Timer = 900000;
  720.  
  721.             if(Creature* yogg = me->GetCreature(*me,guidYogg))
  722.                 DoZoneInCombat(yogg);
  723.  
  724.             if(m_pInstance)
  725.                 m_pInstance->SetBossState(TYPE_YOGGSARON,IN_PROGRESS);
  726.  
  727.             lastBrainAction = Actions(0);
  728.         }
  729.  
  730.         void ReceiveEmote(Player* pPlayer, uint32 emote)
  731.         {
  732.             if(m_Phase >= PHASE_BRAIN)
  733.             {
  734.                 if(emote == TEXT_EMOTE_KISS)
  735.                 {
  736.                     if(pPlayer->HasAchieved(RAID_MODE(ACHIEVMENT_KISS_AND_MAKE_UP_10,ACHIEVMENT_KISS_AND_MAKE_UP_25)))
  737.                         return;
  738.  
  739.                     if (me->IsWithinLOS(pPlayer->GetPositionX(),pPlayer->GetPositionY(),pPlayer->GetPositionZ()) && me->IsWithinDistInMap(pPlayer,30.0f))
  740.                     {
  741.                         if(AchievementEntry const *achievKissAndMakeUp = GetAchievementStore()->LookupEntry(RAID_MODE(ACHIEVMENT_KISS_AND_MAKE_UP_10,ACHIEVMENT_KISS_AND_MAKE_UP_25)))
  742.                             pPlayer->CompletedAchievement(achievKissAndMakeUp);
  743.                     }
  744.                 }
  745.             }
  746.         }
  747.  
  748.         void DamageTaken(Unit* dealer, uint32 &damage)
  749.         {
  750.             if(dealer->GetEntry() == ENTRY_GUARDIAN_OF_YOGG_SARON)
  751.             {
  752.                 damage = 0;
  753.                 return;
  754.             }
  755.  
  756.             if(damage > me->GetHealth())
  757.                 damage = me->GetHealth()-1;
  758.         }
  759.  
  760.         uint32 CountKeepersActive()
  761.         {
  762.             uint32 count = 0;
  763.             if(m_pInstance)
  764.             {
  765.                 uint32 supportFlag = m_pInstance->GetData(DATA_KEEPER_SUPPORT_YOGG);
  766.  
  767.                 if(supportFlag & MIMIRON_SUPPORT)
  768.                     count++;
  769.                 if(supportFlag & FREYA_SUPPORT)
  770.                     count++;
  771.                 if(supportFlag & THORIM_SUPPORT)
  772.                     count++;
  773.                 if(supportFlag & HODIR_SUPPORT)
  774.                     count++;
  775.             }
  776.             return count;
  777.         }
  778.  
  779.         void ModifySanity(Player* target, int8 amount)
  780.         {
  781.             if(target && target->isAlive())
  782.             {
  783.                 int32 newamount;
  784.                 if(Aura* aur = target->GetAura(SPELL_SANITY, GetGUID()))
  785.                 {
  786.                     newamount = aur->GetStackAmount();
  787.                     if(newamount > 0)
  788.                         newamount += amount;
  789.  
  790.                     if(newamount > 100)
  791.                         newamount = 100;
  792.  
  793.                     if(newamount <= 0)
  794.                         target->RemoveAurasDueToSpell(SPELL_SANITY);
  795.                     else
  796.                         aur->SetStackAmount(newamount);
  797.                 }
  798.             }
  799.         }
  800.  
  801.         void SpellHitTarget(Unit* target, const SpellEntry* spell)
  802.         {
  803.             if(target && target->ToPlayer())
  804.             {
  805.                 switch(spell->Id)
  806.                 {
  807.                 case SPELL_PSYCHOSIS:
  808.                     ModifySanity(target->ToPlayer(),-12);
  809.                     break;
  810.                 case SPELL_BRAIN_LINK_DAMAGE:
  811.                     ModifySanity(target->ToPlayer(),-2);
  812.                     break;
  813.                 case SPELL_MALADY_OF_MIND:
  814.                     ModifySanity(target->ToPlayer(),-3);
  815.                     break;
  816.                 }
  817.             }
  818.         }
  819.  
  820.         void MovementInform(uint32 type, uint32 i)
  821.         {
  822.             if (type != POINT_MOTION_TYPE)
  823.                 return;
  824.  
  825.             if(i == 1)
  826.             {
  827.                 me->GetMotionMaster()->Clear(false);
  828.                 me->GetMotionMaster()->MoveIdle();
  829.             }
  830.         }
  831.  
  832.         void DoAction(const int32 action)
  833.         {
  834.             switch(action)
  835.             {
  836.             case ACTION_NOVA_HIT:
  837.                 if(m_Phase != PHASE_SARA)
  838.                     return;
  839.                 --NovaHitCounter;
  840.                 if(NovaHitCounter <= 0)
  841.                     SetPhase(PHASE_BRAIN);
  842.                 else me->ModifyHealth(-25000);
  843.                 break;
  844.             case ACTION_BRAIN_UNDER_30_PERCENT:
  845.                 SetPhase(PHASE_YOGG);
  846.                 break;
  847.             case ACTION_YOGGSARON_KILLED:
  848.                 if(Creature* yogg = me->GetCreature(*me,guidYogg))
  849.                     yogg->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
  850.  
  851.                 if(uiEnrage_Timer >= 480000)
  852.                     m_pInstance->DoCompleteAchievement(RAID_MODE(ACHIEVMENT_HE_S_NOT_GETTING_ANY_OLDER_10,ACHIEVMENT_HE_S_NOT_GETTING_ANY_OLDER_25));
  853.                 if(!bUsedMindcontroll)
  854.                     m_pInstance->DoCompleteAchievement(RAID_MODE(ACHIEVMENT_DRIVE_ME_CRAZY_10,ACHIEVMENT_DRIVE_ME_CRAZY_25));
  855.                 if(GetDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL && uiAmountKeeperActive == 0)
  856.                     m_pInstance->DoCompleteAchievement(ACHIEVMENT_REALM_FIRST_DEATHS_DEMISE);
  857.                 switch(uiAmountKeeperActive)
  858.                 {
  859.                 case 0:
  860.                     m_pInstance->DoCompleteAchievement(RAID_MODE(ACHIEVMENT_ALONE_IN_THE_DARKNESS_10,ACHIEVMENT_ALONE_IN_THE_DARKNESS_25));
  861.                 case 1:
  862.                     m_pInstance->DoCompleteAchievement(RAID_MODE(ACHIEVMENT_ONE_LIGHTS_IN_THE_DARKNESS_10,ACHIEVMENT_ONE_LIGHTS_IN_THE_DARKNESS_25));
  863.                 case 2:
  864.                     m_pInstance->DoCompleteAchievement(RAID_MODE(ACHIEVMENT_TWO_LIGHTS_IN_THE_DARKNESS_10,ACHIEVMENT_TWO_LIGHTS_IN_THE_DARKNESS_25));
  865.                 case 3:
  866.                     m_pInstance->DoCompleteAchievement(RAID_MODE(ACHIEVMENT_THREE_LIGHTS_IN_THE_DARKNESS_10,ACHIEVMENT_THREE_LIGHTS_IN_THE_DARKNESS_25));
  867.                     break;
  868.                 default: break;
  869.                 }
  870.                 me->Kill(me);
  871.                 break;
  872.             case ACTION_USED_MINDCONTROL:
  873.                 bUsedMindcontroll = true;
  874.                 break;
  875.             }
  876.         }
  877.  
  878.         uint32 GetData(uint32 data)
  879.         {
  880.             switch(data)
  881.             {
  882.             case DATA_PORTAL_PHASE:
  883.                 return currentBrainEventPhase;
  884.             }
  885.             return 0;
  886.         }
  887.  
  888.         void SetPhase(BossPhase newPhase)
  889.         {
  890.             if(m_Phase == newPhase)
  891.                 return;
  892.  
  893.             switch(newPhase)
  894.             {
  895.             case PHASE_SARA:
  896.                 DoScriptText(SAY_SARA_AGGRO_1,me);
  897.                 DoSpawnKeeperForSupport();
  898.                 SetSanityAura();
  899.                 uiAmountKeeperActive = CountKeepersActive();
  900.                 if(Creature* yogg = me->GetCreature(*me,guidYogg))
  901.                 {
  902.                     yogg->SetLootMode(LOOT_MODE_DEFAULT);
  903.                     if(uiAmountKeeperActive <= 1)
  904.                         yogg->AddLootMode(LOOT_MODE_HARD_MODE_1);
  905.                     if(uiAmountKeeperActive == 0)
  906.                         yogg->AddLootMode(LOOT_MODE_HARD_MODE_2);
  907.                 }
  908.  
  909.                 break;
  910.             case PHASE_BRAIN:
  911.                 me->SetHealth(me->GetMaxHealth());
  912.                 IsSpeaking = true;
  913.                 SpeakingPhase = 0;
  914.                 uiSpeaking_Timer = 1000;
  915.                 IsEventSpeaking = false;
  916.                 EventSpeakingPhase = 0;
  917.                 //me->SetDisplayId(SARA_TRANSFORM);
  918.                 CloudHandling(true);
  919.                 uiRandomYell_Timer = 35000;
  920.                 uiBrainEvents_Count = 0;
  921.                 break;
  922.             case PHASE_YOGG:
  923.                 me->SetVisible(false);
  924.                 if(Creature* yogg = me->GetCreature(*me,guidYogg))
  925.                 {
  926.                     yogg->LowerPlayerDamageReq(uint32(yogg->GetMaxHealth()*0.3f));
  927.                     yogg->SetHealth(yogg->CountPctFromMaxHealth(30));
  928.                     yogg->RemoveAurasDueToSpell(SPELL_SHADOWY_BARRIER);
  929.                     yogg->RemoveAurasDueToSpell(SPELL_SHATTERED_ILLUSIONS);
  930.                     DoScriptText(SAY_PHASE3,yogg);
  931.                     me->AddAura(SPELL_YOGG_SARON_TRANSFORMATION,yogg);
  932.                 }
  933.  
  934.                 // Not blizzlike
  935.                 //if(me->GetMap() && me->GetMap()->IsDungeon())
  936.                 //{
  937.                 //    Map::PlayerList const& players = me->GetMap()->GetPlayers();
  938.                 //    if (!players.isEmpty())
  939.                 //        for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  940.                 //            if (Player* plr = itr->getSource())
  941.                 //                if(plr->isAlive() && IsPlayerInBrainRoom(plr))
  942.                 //                {
  943.                 //                    plr->NearTeleportTo(SaraLocation.GetPositionX(),SaraLocation.GetPositionY(),SaraLocation.GetPositionZ(),M_PI,false);
  944.                 //                    plr->JumpTo(30.0f,5.0f,true);
  945.                 //                }
  946.                 //}
  947.  
  948.                 for(std::list<uint64>::iterator itr = Summons.begin(); itr != Summons.end(); ++itr)
  949.                 {
  950.                     if(Creature* temp = Creature::GetCreature(*me,*itr))
  951.                     {
  952.                         switch(temp->GetEntry())
  953.                         {
  954.                         case ENTRY_CONSTRICTOR_TENTACLE:
  955.                         case ENTRY_CORRUPTOR_TENTACLE:
  956.                         case ENTRY_CRUSHER_TENTACLE:
  957.                                 temp->RemoveAurasDueToSpell(SPELL_SHATTERED_ILLUSIONS);
  958.                             break;
  959.                         }
  960.                     }
  961.                 }
  962.  
  963.                 Summons.DespawnEntry(ENTRY_BRAIN_PORTAL);
  964.  
  965.                 if(Creature* yoggbrain = me->GetCreature(*me,guidYoggBrain))
  966.                     yoggbrain->InterruptNonMeleeSpells(false);
  967.  
  968.                 uiGuardianSummon_Timer = 20000;
  969.                 uilastGuardianSummon_Timer = 35000;
  970.                 break;
  971.             }
  972.  
  973.             m_Phase = newPhase;
  974.         }
  975.  
  976.         void SaraRandomYell()
  977.         {
  978.             switch(m_Phase)
  979.             {
  980.             case PHASE_NONE: DoScriptText(RAND(SAY_SARA_PREFIGHT_1,SAY_SARA_PREFIGHT_2),me); break;
  981.             case PHASE_SARA: DoScriptText(RAND(SAY_SARA_AGGRO_2,SAY_SARA_AGGRO_3),me); break;
  982.             case PHASE_BRAIN: DoScriptText(RAND(SAY_SARA_PHASE2_1,SAY_SARA_PHASE2_2,SAY_SARA_AGGRO_3),me); break;
  983.             }
  984.         }
  985.  
  986.         void MoveInLineOfSight(Unit* target)
  987.         {
  988.             if(m_Phase == PHASE_NONE)
  989.             {
  990.                 if(target && me->GetDistance2d(target) <= 100 && target->ToPlayer() && !target->ToPlayer()->isGameMaster() && me->IsWithinLOSInMap(target))
  991.                 {
  992.                     if(m_pInstance && m_pInstance->GetBossState(TYPE_VEZAX) == DONE)
  993.                     {
  994.                         SetPhase(PHASE_SARA);
  995.                         EnterCombat(target);
  996.                     }
  997.                 }
  998.             }
  999.         }
  1000.  
  1001.         void JustSummoned(Creature* pSummoned)
  1002.         {
  1003.             switch(pSummoned->GetEntry())
  1004.             {
  1005.             case ENTRY_GUARDIAN_OF_YOGG_SARON:
  1006.                 pSummoned->setFaction(14);
  1007.                 pSummoned->AI()->AttackStart(SelectPlayerTargetInRange(100.0f));
  1008.                 break;
  1009.             case ENTRY_YOGG_SARON:
  1010.                 guidYogg = pSummoned->GetGUID();
  1011.                 pSummoned->SetReactState(REACT_PASSIVE);
  1012.                 pSummoned->setFaction(14);
  1013.                 //pSummoned->SetVisible(false);
  1014.                 pSummoned->SetStandState(UNIT_STAND_STATE_SUBMERGED);
  1015.                 pSummoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  1016.                 pSummoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1017.                 pSummoned->SetFloatValue(UNIT_FIELD_COMBATREACH, 20.0f);
  1018.                 pSummoned->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 20.0f);
  1019.                 return; // Do Not Save Yoggy in Summons because he shouldnt despawnt on Encount Finished
  1020.             case ENTRY_BRAIN_OF_YOGG_SARON:
  1021.                 guidYoggBrain = pSummoned->GetGUID();
  1022.                 pSummoned->setActive(true);
  1023.                 pSummoned->SetFloatValue(UNIT_FIELD_COMBATREACH, 25.0f);
  1024.                 pSummoned->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 25.0f);
  1025.                 pSummoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1026.                 break;
  1027.             case ENTRY_RUBY_CONSORT:
  1028.             case ENTRY_OBSIDIAN_CONSORT:
  1029.             case ENTRY_AZURE_CONSORT:
  1030.             case ENTRY_EMERAL_CONSORT:
  1031.             case ENTRY_DEATHSWORN_ZEALOT:
  1032.             case ENTRY_SUIT_OF_ARMOR:
  1033.                 pSummoned->SetReactState(REACT_DEFENSIVE);
  1034.                 pSummoned->setFaction(15);
  1035.                 break;
  1036.             case ENTRY_KEEPER_FREYA:
  1037.             case ENTRY_KEEPER_HODIR:
  1038.             case ENTRY_KEEPER_MIMIRON:
  1039.             case ENTRY_KEEPER_THORIM:
  1040.                 pSummoned->setActive(true);
  1041.                 break;
  1042.             case ENTRY_LAUGHING_SKULL:
  1043.                 pSummoned->setFaction(14);
  1044.                 pSummoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  1045.                 pSummoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1046.                 break;
  1047.             }
  1048.  
  1049.             Summons.Summon(pSummoned);
  1050.         }
  1051.  
  1052.         bool IsEncounterInProgress()
  1053.         {
  1054.             if(me->GetMap() && me->GetMap()->IsDungeon())
  1055.             {
  1056.                 Map::PlayerList const& players = me->GetMap()->GetPlayers();
  1057.                 if (!players.isEmpty())
  1058.                     for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  1059.                         if (Player* plr = itr->getSource())
  1060.                             if(plr->isAlive() && !plr->isGameMaster() && !plr->HasAura(SPELL_INSANE))
  1061.                                 return true;
  1062.             }
  1063.             return false;
  1064.         }
  1065.  
  1066.         void SetSanityAura(bool remove = false)
  1067.         {
  1068.             if(me->GetMap() && me->GetMap()->IsDungeon())
  1069.             {
  1070.                 Map::PlayerList const& players = me->GetMap()->GetPlayers();
  1071.                 if (!players.isEmpty())
  1072.                     for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  1073.                         if (Player* plr = itr->getSource())
  1074.                             if(plr->isAlive())
  1075.                             {
  1076.                                 if(!remove)
  1077.                                 {
  1078.                                     me->AddAura(SPELL_SANITY,plr);
  1079.                                     me->SetAuraStack(SPELL_SANITY,plr,100);
  1080.                                 }else
  1081.                                 {
  1082.                                     plr->RemoveAurasDueToSpell(SPELL_SANITY);
  1083.                                 }
  1084.                             }
  1085.             }
  1086.         }
  1087.  
  1088.         Player* SelectPlayerTargetInRange(float range)
  1089.         {
  1090.             Player *target = NULL;
  1091.             Trinity::AnyPlayerInObjectRangeCheck u_check(me, range);
  1092.             Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, target, u_check);
  1093.             me->VisitNearbyObject(range, searcher);
  1094.             return target;
  1095.         }
  1096.  
  1097.         Creature* GetRandomEntryTarget(uint32 entry, float range = 100.0f)
  1098.         {
  1099.             std::list<Creature*> TargetList;
  1100.             me->GetCreatureListWithEntryInGrid(TargetList,entry, range);
  1101.             if(TargetList.empty())
  1102.                 return NULL;
  1103.  
  1104.             std::list<Creature*>::iterator itr = TargetList.begin();
  1105.             advance(itr, urand(0, TargetList.size()-1));
  1106.             return (*itr);
  1107.         }
  1108.  
  1109.         // For Gardian Summon
  1110.         Creature* GetRandomCloudTarget(float range = 100.0f)
  1111.         {
  1112.             return GetRandomEntryTarget(ENTRY_OMINOUS_CLOUD);
  1113.         }
  1114.  
  1115.         // For Immortal Guardian Heal
  1116.         Creature* GetRandomGuardianTarget(float range = 100.0f)
  1117.         {
  1118.             return GetRandomEntryTarget(ENTRY_IMMORTAL_GUARDIAN);
  1119.         }
  1120.  
  1121.         bool AllSpawnsDeadOrDespawned(std::list<uint64> GuidListe)
  1122.         {
  1123.             for(std::list<uint64>::iterator itr = GuidListe.begin(); itr != GuidListe.end(); ++itr)
  1124.             {
  1125.                 Creature* temp = me->GetCreature(*me,*itr);
  1126.                 if(temp && temp->isAlive())
  1127.                     return false;
  1128.             }
  1129.  
  1130.             return true;
  1131.         }
  1132.  
  1133.         void DoKillAndDespawnGUIDs(std::list<uint64> GuidListe)
  1134.         {
  1135.             for(std::list<uint64>::iterator itr = GuidListe.begin(); itr != GuidListe.end(); ++itr)
  1136.             {
  1137.                 Creature* temp = me->GetCreature(*me,*itr);
  1138.                 if(temp && temp->isAlive())
  1139.                 {
  1140.                     temp->DealDamage(temp,temp->GetHealth());
  1141.                     temp->RemoveCorpse();
  1142.                 }
  1143.             }
  1144.         }
  1145.  
  1146.         void SummonMadnessEventNPCs()
  1147.         {
  1148.             listEventNPCs.clear();
  1149.             uint32 npcIndex = 0;
  1150.             uint32 npcAmount = 0;
  1151.  
  1152.             switch(currentBrainEventPhase)
  1153.             {
  1154.             case PORTAL_PHASE_KING_LLIANE:
  1155.                 npcIndex = 0;
  1156.                 npcAmount = 2;
  1157.                 break;
  1158.             case PORTAL_PHASE_DRAGON_SOUL:
  1159.                 npcIndex = 2;
  1160.                 npcAmount = 4;
  1161.                 break;
  1162.             case PORTAL_PHASE_LICH_KING:
  1163.                 npcIndex = 6;
  1164.                 npcAmount = 3;
  1165.                 break;
  1166.             }
  1167.  
  1168.             Creature* temp;
  1169.  
  1170.             for(uint8 i = 0; i < npcAmount; i++)
  1171.             {
  1172.                 if(EventNpcEntrys[npcIndex+i] == OBJECT_THE_DRAGON_SOUL)
  1173.                 {
  1174.                     if(GameObject* obj = me->SummonGameObject(EventNpcEntrys[npcIndex+i],EventNpcLocation[npcIndex+i].GetPositionX(),EventNpcLocation[npcIndex+i].GetPositionY(),EventNpcLocation[npcIndex+i].GetPositionZ(),0,0,0,0,0,40000))
  1175.                     {
  1176.                         obj->setActive(true);
  1177.                         EventNPC *info = new EventNPC();
  1178.                         info->entry = obj->GetEntry();
  1179.                         info->guid = obj->GetGUID();
  1180.  
  1181.                         listEventNPCs.push_back(*info);
  1182.                     }
  1183.                 }
  1184.                 else
  1185.                 {
  1186.                     if(temp = DoSummon(EventNpcEntrys[npcIndex+i],EventNpcLocation[npcIndex+i],40000,TEMPSUMMON_TIMED_DESPAWN))
  1187.                     {
  1188.                         temp->setActive(true);
  1189.                         EventNPC *info = new EventNPC();
  1190.                         info->entry = temp->GetEntry();
  1191.                         info->guid = temp->GetGUID();
  1192.                         switch(info->entry)
  1193.                         {
  1194.                         case ENTRY_GARONA_VISION:
  1195.                             temp->SetStandState(UNIT_STAND_STATE_KNEEL);
  1196.                             break;
  1197.                         }
  1198.                         listEventNPCs.push_back(*info);
  1199.                     }
  1200.                 }
  1201.             }
  1202.         }
  1203.  
  1204.         uint64 GetEventNPCGuid(uint32 entry)
  1205.         {
  1206.             for(std::list<EventNPC>::iterator itr = listEventNPCs.begin(); itr != listEventNPCs.end(); ++itr)
  1207.             {
  1208.                 if(itr->entry == entry)
  1209.                     return itr->guid;
  1210.             }
  1211.             return 0;
  1212.         }
  1213.  
  1214.         void DoMadness()
  1215.         {
  1216.             if(m_pInstance)
  1217.             {
  1218.                 m_pInstance->HandleGameObject(m_pInstance->GetData64(TYPE_BRAIN_DOOR_1),false);
  1219.                 m_pInstance->HandleGameObject(m_pInstance->GetData64(TYPE_BRAIN_DOOR_2),false);
  1220.                 m_pInstance->HandleGameObject(m_pInstance->GetData64(TYPE_BRAIN_DOOR_3),false);
  1221.             }
  1222.  
  1223.             Actions tempAction;
  1224.             switch(lastBrainAction)
  1225.             {
  1226.             case ACTION_PORTAL_TO_MADNESS_STORMWIND:
  1227.                 tempAction = ACTION_PORTAL_TO_MADNESS_DRAGON;
  1228.                 break;
  1229.             case ACTION_PORTAL_TO_MADNESS_DRAGON:
  1230.                 tempAction = ACTION_PORTAL_TO_MADNESS_LICHKING;
  1231.                 break;
  1232.             case ACTION_PORTAL_TO_MADNESS_LICHKING:
  1233.                 tempAction = ACTION_PORTAL_TO_MADNESS_STORMWIND;
  1234.                 break;
  1235.             default:
  1236.                 tempAction = RAND(ACTION_PORTAL_TO_MADNESS_STORMWIND,ACTION_PORTAL_TO_MADNESS_DRAGON,ACTION_PORTAL_TO_MADNESS_LICHKING);
  1237.                 break;
  1238.             }
  1239.             lastBrainAction = tempAction;
  1240.  
  1241.             // Spawn Portal
  1242.             int max = RAID_MODE(4,10);
  1243.             for(int i = 0; i < max; ++i)
  1244.             {
  1245.                 if(Creature* portal = DoSummon(ENTRY_BRAIN_PORTAL,BrainPortalLocation[i],40000,TEMPSUMMON_TIMED_DESPAWN))
  1246.                     portal->AI()->DoAction(tempAction);
  1247.             }
  1248.  
  1249.             // Spawn Event Tentacle
  1250.             switch(tempAction)
  1251.             {
  1252.             case ACTION_PORTAL_TO_MADNESS_DRAGON:
  1253.                 currentBrainEventPhase = PORTAL_PHASE_DRAGON_SOUL;
  1254.                 guidEventTentacles.clear();
  1255.                 guidEventSkulls.clear();
  1256.                 uint32 entry;
  1257.                 for(int i = 0; i < CONSTANT_MAX_DRAGONSOUL_TENTACLE_SPAWNS; ++i)
  1258.                 {
  1259.                     switch(i)
  1260.                     {
  1261.                     case 0:
  1262.                     case 1: entry = ENTRY_RUBY_CONSORT; break;
  1263.                     case 2:
  1264.                     case 3: entry = ENTRY_AZURE_CONSORT; break;
  1265.                     case 4:
  1266.                     case 5: entry = ENTRY_OBSIDIAN_CONSORT; break;
  1267.                     case 6:
  1268.                     case 7: entry = ENTRY_EMERAL_CONSORT; break;
  1269.                     }
  1270.                     if(Creature* summon = DoSummon(entry,DragonSoulTentacleLocation[i],60000,TEMPSUMMON_TIMED_DESPAWN))
  1271.                         guidEventTentacles.push_back(summon->GetGUID());
  1272.                 }
  1273.                 for(int i = 0; i < 4; ++i)
  1274.                 {
  1275.                     if(Creature* summon = DoSummon(ENTRY_LAUGHING_SKULL,DragonSoulSkullLocation[i],60000,TEMPSUMMON_TIMED_DESPAWN))
  1276.                         guidEventSkulls.push_back(summon->GetGUID());
  1277.                 }
  1278.                 break;
  1279.             case ACTION_PORTAL_TO_MADNESS_LICHKING:
  1280.                 currentBrainEventPhase = PORTAL_PHASE_LICH_KING;
  1281.                 guidEventTentacles.clear();
  1282.                 guidEventSkulls.clear();
  1283.                 for(int i = 0; i < CONSTANT_MAX_LICHKING_TENTACLE_SPAWNS; ++i)
  1284.                 {
  1285.                     if(Creature* summon = DoSummon(ENTRY_DEATHSWORN_ZEALOT,LichKingTentacleLocation[i],60000,TEMPSUMMON_TIMED_DESPAWN))
  1286.                         guidEventTentacles.push_back(summon->GetGUID());
  1287.                 }
  1288.                 for(int i = 0; i < 3; ++i)
  1289.                 {
  1290.                     if(Creature* summon = DoSummon(ENTRY_LAUGHING_SKULL,LichkingSkullLocation[i],60000,TEMPSUMMON_TIMED_DESPAWN))
  1291.                         guidEventSkulls.push_back(summon->GetGUID());
  1292.                 }
  1293.                 break;
  1294.             case ACTION_PORTAL_TO_MADNESS_STORMWIND:
  1295.                 currentBrainEventPhase = PORTAL_PHASE_KING_LLIANE;
  1296.                 guidEventTentacles.clear();
  1297.                 guidEventSkulls.clear();
  1298.                 for(int i = 0; i < CONSTANT_MAX_LLIANE_TENTACLE_SPAWNS; ++i)
  1299.                 {
  1300.                     if(Creature* summon = DoSummon(ENTRY_SUIT_OF_ARMOR,KingLlaneTentacleLocation[i],60000,TEMPSUMMON_TIMED_DESPAWN))
  1301.                         guidEventTentacles.push_back(summon->GetGUID());
  1302.                 }
  1303.                 for(int i = 0; i < 3; ++i)
  1304.                 {
  1305.                     if(Creature* summon = DoSummon(ENTRY_LAUGHING_SKULL,KingLlaneSkullLocation[i],60000,TEMPSUMMON_TIMED_DESPAWN))
  1306.                         guidEventSkulls.push_back(summon->GetGUID());
  1307.                 }
  1308.                 break;
  1309.             }
  1310.  
  1311.             if(Creature* yoggbrain = me->GetCreature(*me,guidYoggBrain))
  1312.             {
  1313.                 yoggbrain->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1314.                 yoggbrain->CastSpell(yoggbrain,SPELL_INDUCE_MADNESS,false);
  1315.             }
  1316.  
  1317.             SummonMadnessEventNPCs();
  1318.             IsEventSpeaking = true;
  1319.             EventSpeakingPhase = 0;
  1320.             uiSpeaking_Timer = 5000;
  1321.  
  1322.             uiBrainEvents_Count++;
  1323.         }
  1324.  
  1325.         uint32 DoEventSpeaking(BrainEventPhase phase, uint32 part)
  1326.         {
  1327.             uint64 npcguid = 0;
  1328.             uint32 speachindex = 0;
  1329.             switch(phase)
  1330.             {
  1331.             case PORTAL_PHASE_KING_LLIANE:
  1332.                 speachindex = 0;
  1333.                 break;
  1334.             case PORTAL_PHASE_LICH_KING:
  1335.                 speachindex = 8;
  1336.                 break;
  1337.             case PORTAL_PHASE_DRAGON_SOUL:
  1338.                 speachindex = 14;
  1339.             }
  1340.  
  1341.             if(phase+speachindex > 18)
  1342.                 return 5000;
  1343.  
  1344.             if(EventNpcSpeaching[speachindex+part].npc_entry != ENTRY_YOGG_SARON)
  1345.                 npcguid = GetEventNPCGuid(EventNpcSpeaching[speachindex+part].npc_entry);
  1346.             else
  1347.                 npcguid = guidYogg;
  1348.  
  1349.             if(Creature* speaker = Creature::GetCreature(*me,npcguid))
  1350.                 DoScriptText(EventNpcSpeaching[speachindex+part].speech_entry,speaker);
  1351.             IsEventSpeaking = EventNpcSpeaching[speachindex+part].isSpeaking;
  1352.             return EventNpcSpeaching[speachindex+part].next_speech;
  1353.         }
  1354.  
  1355.         void UpdateAI(const uint32 diff)
  1356.         {
  1357.             if(m_pInstance && m_pInstance->GetBossState(TYPE_VEZAX) == DONE)
  1358.                 if(uiRandomYell_Timer <= diff)
  1359.                 {
  1360.                     SaraRandomYell();
  1361.                     uiRandomYell_Timer = urand(40000,60000);
  1362.                 }else uiRandomYell_Timer -= diff;
  1363.  
  1364.             switch(m_Phase)
  1365.             {
  1366.                 case PHASE_SARA:
  1367.                     if(uiGuardianSummon_Timer <= diff)
  1368.                     {
  1369.                         if(Creature* target = GetRandomCloudTarget(500.0f))
  1370.                             target->CastSpell(target,SPELL_SUMMON_GUARDIAN,true);
  1371.  
  1372.                         uilastGuardianSummon_Timer = uilastGuardianSummon_Timer-5000 <= 10000 ? 10000 : uilastGuardianSummon_Timer - 5000;
  1373.                         uiGuardianSummon_Timer = uilastGuardianSummon_Timer;
  1374.                     }else uiGuardianSummon_Timer -= diff;
  1375.  
  1376.                     if(uiSarasHelp_Timer <= diff)
  1377.                     {
  1378.                         switch(urand(0,2))
  1379.                         {
  1380.                         case 0:
  1381.                             if(Player* target = SelectPlayerTargetInRange(500.0f))
  1382.                                 if(!IsPlayerInBrainRoom(target))
  1383.                                 DoCast(target,SPELL_SARAS_FERVOR,false);
  1384.                             break;
  1385.                         case 1:
  1386.                             if(Player* target = SelectPlayerTargetInRange(500.0f))
  1387.                                 if(!IsPlayerInBrainRoom(target))
  1388.                                     DoCast(target,SPELL_SARAS_BLESSING,false);
  1389.                         case 2:
  1390.                             if(Unit* target = GetRandomEntryTarget(ENTRY_GUARDIAN_OF_YOGG_SARON,500.0f))
  1391.                                 DoCast(target, SPELL_SARAS_ANGER, false);
  1392.                             break;
  1393.                         default: break;
  1394.                         }
  1395.                         uiSarasHelp_Timer = urand(5000,6000);
  1396.                     }else uiSarasHelp_Timer -= diff;
  1397.  
  1398.                     break;
  1399.                 case PHASE_BRAIN:
  1400.                     if(IsSpeaking)
  1401.                     {
  1402.                         if(uiSpeaking_Timer <= diff)
  1403.                         {
  1404.                             switch(SpeakingPhase)
  1405.                             {
  1406.                             case 0:
  1407.                                 //if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1408.                                 //    yogg->SetVisible(true);
  1409.  
  1410.                                 DoScriptText(SAY_PHASE2_1,me);
  1411.                                 uiSpeaking_Timer = 5000;
  1412.                                 break;
  1413.                             case 1:
  1414.                                 DoScriptText(SAY_PHASE2_2,me);
  1415.                                 uiSpeaking_Timer = 5000;
  1416.                                 break;
  1417.                             case 2:
  1418.                                 DoScriptText(SAY_PHASE2_3,me);
  1419.                                 uiSpeaking_Timer = 4000;
  1420.                                 break;
  1421.                             case 3:
  1422.                                 DoScriptText(SAY_PHASE2_4,me);
  1423.                                 uiSpeaking_Timer = 4000;
  1424.                                 break;
  1425.                             case 4:
  1426.                                 //me->SetDisplayId(SARA_TRANSFORM);
  1427.                                 me->AddAura(SPELL_SARA_TRANSFORMATION,me);
  1428.                                 DoCast(me,SPELL_SARA_SHADOWY_BARRIER,false);
  1429.                                 me->GetMotionMaster()->MovePoint(1,me->GetPositionX(),me->GetPositionY(),me->GetPositionZ()+20);
  1430.                                 if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1431.                                 {
  1432.                                     //yogg->SetDisplayId(YOGGSARON_NORMAL);
  1433.                                     yogg->CastSpell(yogg,SPELL_SHADOWY_BARRIER,false);
  1434.                                     yogg->SetStandState(UNIT_STAND_STATE_STAND);
  1435.                                     yogg->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  1436.                                     yogg->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1437.                                     DoScriptText(SAY_PHASE2_5,yogg);
  1438.  
  1439.                                     yogg->CastSpell(yogg,SPELL_SUMMON_CURRUPTOR_TENTACLE,true);
  1440.                                 }
  1441.                                 me->setFaction(14);
  1442.                                 //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  1443.                                 //me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1444.                                 uiSpeaking_Timer = 5000;
  1445.                                 IsSpeaking = false;
  1446.                                 break;
  1447.                             }
  1448.                             SpeakingPhase++;
  1449.                         }else uiSpeaking_Timer -= diff;
  1450.                     }else
  1451.                     {
  1452.                         if(IsEventSpeaking)
  1453.                         {
  1454.                             if(uiSpeaking_Timer <= diff)
  1455.                             {
  1456.                                 uiSpeaking_Timer = DoEventSpeaking(currentBrainEventPhase,EventSpeakingPhase);
  1457.                                 EventSpeakingPhase++;
  1458.                             }else uiSpeaking_Timer -= diff;
  1459.                         }
  1460.  
  1461.                         if(!me->HasAura(SPELL_SHATTERED_ILLUSIONS))
  1462.                         {
  1463.                             if(uiPsychosis_Timer <= diff)
  1464.                             {
  1465.                                 if(Player* target = SelectPlayerTargetInRange(500.0f))
  1466.                                     if(!IsPlayerInBrainRoom(target))
  1467.                                         DoCast(target,SPELL_PSYCHOSIS,false);
  1468.                                 uiPsychosis_Timer = urand(5000,5000);
  1469.                             }else uiPsychosis_Timer -= diff;
  1470.  
  1471.                             if(uiMindSpell_Timer <= diff)
  1472.                             {
  1473.                                 if(!me->IsNonMeleeSpellCasted(false))
  1474.                                 {
  1475.                                     switch(urand(0,2))
  1476.                                     {
  1477.                                     case 0:
  1478.                                         DoCast(SPELL_MALADY_OF_MIND);
  1479.                                         break;
  1480.                                     case 1:
  1481.                                         DoCast(SPELL_BRAIN_LINK);
  1482.                                         break;
  1483.                                     case 2:
  1484.                                         DoCast(SPELL_DEATH_RAY_SUMMON);
  1485.                                         break;
  1486.                                     }
  1487.                                     uiMindSpell_Timer = 30000;
  1488.                                 }
  1489.                             }else uiMindSpell_Timer -= diff;
  1490.  
  1491.                             if(uiTentacle_Timer <= diff)
  1492.                             {
  1493.                                 if(urand(0,1) == 0)
  1494.                                 {
  1495.                                     if(Player* target = SelectPlayerTargetInRange(500.0f))
  1496.                                         if(!IsPlayerInBrainRoom(target))
  1497.                                             target->CastSpell(target,SPELL_SUMMON_CONSTRICTOR_TENTACLES,true);
  1498.                                 }else
  1499.                                 {
  1500.                                     if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1501.                                         yogg->CastSpell(yogg,SPELL_SUMMON_CURRUPTOR_TENTACLE,true);
  1502.                                 }
  1503.                                 uiTentacle_Timer =  uiBrainEvents_Count < 4 ? urand(5000,10000) : urand(2000,5000);
  1504.                             }else uiTentacle_Timer -= diff;
  1505.  
  1506.                             if(uiTentacle1_Timer <= diff)
  1507.                             {
  1508.                                 if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1509.                                     yogg->CastSpell(yogg,SPELL_SUMMON_CRUSHER_TENTACLE,true);
  1510.                                 uiTentacle1_Timer = uiBrainEvents_Count < 4 ? urand(30000,40000) : urand(10000,15000);
  1511.                             }else uiTentacle1_Timer -= diff;
  1512.  
  1513.  
  1514.                         }else
  1515.                         {
  1516.                             if(Creature* yoggbrain = me->GetCreature(*me,guidYoggBrain))
  1517.                                 if(!yoggbrain->IsNonMeleeSpellCasted(false))
  1518.                                 {
  1519.                                     if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1520.                                         yogg->RemoveAurasDueToSpell(SPELL_SHATTERED_ILLUSIONS);
  1521.                                     me->RemoveAurasDueToSpell(SPELL_SHATTERED_ILLUSIONS);
  1522.  
  1523.                                     for(std::list<uint64>::iterator itr = Summons.begin(); itr != Summons.end(); ++itr)
  1524.                                     {
  1525.                                         if(Creature* temp = Creature::GetCreature(*me,*itr))
  1526.                                         {
  1527.                                             switch(temp->GetEntry())
  1528.                                             {
  1529.                                             case ENTRY_CONSTRICTOR_TENTACLE:
  1530.                                             case ENTRY_CORRUPTOR_TENTACLE:
  1531.                                             case ENTRY_CRUSHER_TENTACLE:
  1532.                                                     temp->RemoveAurasDueToSpell(SPELL_SHATTERED_ILLUSIONS);
  1533.                                                 break;
  1534.                                             }
  1535.                                         }
  1536.                                     }
  1537.                                 }
  1538.                         }
  1539.  
  1540.                         if(uiMadness_Timer <= diff)
  1541.                         {
  1542.                             if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1543.                             {
  1544.                                 DoScriptText(SAY_VISION,yogg);
  1545.                                 DoMadness();
  1546.                             }
  1547.  
  1548.                             //Say YoggSaron to Open Portals
  1549.                             uiMadness_Timer = 80000;
  1550.                         }else uiMadness_Timer -= diff;
  1551.  
  1552.                         if(!me->HasAura(SPELL_SHATTERED_ILLUSIONS))
  1553.                         {
  1554.                             if(currentBrainEventPhase != PORTAL_PHASE_BRAIN_NONE)
  1555.                             {
  1556.                                 if(AllSpawnsDeadOrDespawned(guidEventTentacles))
  1557.                                 {
  1558.                                     switch(currentBrainEventPhase)
  1559.                                     {
  1560.                                     case PORTAL_PHASE_DRAGON_SOUL: if(m_pInstance) m_pInstance->HandleGameObject(m_pInstance->GetData64(TYPE_BRAIN_DOOR_1),true); break;
  1561.                                     case PORTAL_PHASE_LICH_KING: if(m_pInstance) m_pInstance->HandleGameObject(m_pInstance->GetData64(TYPE_BRAIN_DOOR_2),true); break;
  1562.                                     case PORTAL_PHASE_KING_LLIANE: if(m_pInstance) m_pInstance->HandleGameObject(m_pInstance->GetData64(TYPE_BRAIN_DOOR_3),true); break;
  1563.                                     }
  1564.                                     currentBrainEventPhase = PORTAL_PHASE_BRAIN_NONE;
  1565.                                     IsEventSpeaking = false;
  1566.                                     if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1567.                                         me->AddAura(SPELL_SHATTERED_ILLUSIONS,yogg);
  1568.                                     me->AddAura(SPELL_SHATTERED_ILLUSIONS,me);
  1569.  
  1570.                                     if(Creature* yoggbrain = me->GetCreature(*me,guidYoggBrain))
  1571.                                         yoggbrain->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1572.  
  1573.                                     for(std::list<uint64>::iterator itr = Summons.begin(); itr != Summons.end(); ++itr)
  1574.                                     {
  1575.                                         if(Creature* temp = Creature::GetCreature(*me,*itr))
  1576.                                         {
  1577.                                             switch(temp->GetEntry())
  1578.                                             {
  1579.                                             case ENTRY_CONSTRICTOR_TENTACLE:
  1580.                                             case ENTRY_CORRUPTOR_TENTACLE:
  1581.                                             case ENTRY_CRUSHER_TENTACLE:
  1582.                                                     me->AddAura(SPELL_SHATTERED_ILLUSIONS,temp);
  1583.                                                 break;
  1584.                                             }
  1585.                                         }
  1586.                                     }
  1587.                                     DoKillAndDespawnGUIDs(guidEventSkulls);
  1588.                                 }
  1589.                             }
  1590.                         }
  1591.                     }
  1592.                     break;
  1593.                 case PHASE_YOGG:
  1594.                     if(uiGuardianSummon_Timer <= diff)
  1595.                     {
  1596.                         if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1597.                             yogg->CastSpell(yogg,SPELL_SUMMON_IMMORTAL_GUARDIAN,true);
  1598.  
  1599.                         uilastGuardianSummon_Timer = uilastGuardianSummon_Timer-5000 <= 10000 ? 10000 : uilastGuardianSummon_Timer - 5000;
  1600.                         uiGuardianSummon_Timer = uilastGuardianSummon_Timer;
  1601.                     }else uiGuardianSummon_Timer -= diff;
  1602.  
  1603.                     if(uiLunaticGaze_Timer <= diff)
  1604.                     {
  1605.                         if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1606.                         {
  1607.                             if(!yogg->IsNonMeleeSpellCasted(false))
  1608.                             {
  1609.                                 DoScriptText(SAY_LUNCATIC_GLAZE,yogg,0);
  1610.                                 yogg->CastSpell(yogg,SPELL_LUNATIC_GAZE,false);
  1611.                                 uiLunaticGaze_Timer = 12000;
  1612.                             }
  1613.                         }
  1614.                     }else uiLunaticGaze_Timer -= diff;
  1615.  
  1616.                     if(GetDifficulty() == RAID_DIFFICULTY_25MAN_NORMAL && uiAmountKeeperActive < 4)
  1617.                         if(uiDeafeningRoar_Timer <= diff)
  1618.                         {
  1619.                             if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1620.                             {
  1621.                                 if(!yogg->IsNonMeleeSpellCasted(false))
  1622.                                 {
  1623.                                     DoScriptText(SAY_DEAFENING_ROAR,yogg,0);
  1624.                                     yogg->CastSpell(yogg,SPELL_DEAFENING_ROAR,false);
  1625.                                     uiDeafeningRoar_Timer = 60000;
  1626.                                 }
  1627.                             }
  1628.                         }else uiDeafeningRoar_Timer -= diff;
  1629.  
  1630.                     if(uiShadowBeacon_Timer <= diff)
  1631.                     {
  1632.                         if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1633.                         {
  1634.                             if(!yogg->IsNonMeleeSpellCasted(false))
  1635.                             {
  1636.                                 yogg->CastSpell(yogg,SPELL_SHADOW_BEACON,false);
  1637.                                 uiShadowBeacon_Timer = 30000;
  1638.                             }
  1639.                         }
  1640.                     }else uiShadowBeacon_Timer -= diff;
  1641.  
  1642.                     break;
  1643.             }
  1644.  
  1645.             if(m_Phase != PHASE_NONE)
  1646.             {
  1647.                 if(uiEnrage_Timer <= diff)
  1648.                 {
  1649.                     if(Creature* yogg = me->GetCreature(*me,guidYogg))
  1650.                     {
  1651.                         yogg->InterruptNonMeleeSpells(false);
  1652.                         yogg->CastSpell(yogg,SPELL_EXTINGUISH_ALL_LIFE,false);
  1653.                     }
  1654.                     uiEnrage_Timer = 5000;
  1655.                 }else uiEnrage_Timer -= diff;
  1656.             }
  1657.  
  1658.             if(m_Phase != PHASE_NONE && !IsEncounterInProgress())
  1659.                 EnterEvadeMode();
  1660.  
  1661.             // temporary
  1662.             if (m_Phase == PHASE_NONE && me->isInCombat())
  1663.                 EnterEvadeMode();
  1664.         }
  1665.     };
  1666. };
  1667.  
  1668. class npc_ominous_cloud : public CreatureScript
  1669. {
  1670. public:
  1671.     npc_ominous_cloud() : CreatureScript("npc_ominous_cloud") { }
  1672.  
  1673.     CreatureAI* GetAI(Creature* pCreature) const
  1674.     {
  1675.         return new npc_ominous_cloudAI (pCreature);
  1676.     }
  1677.  
  1678.     struct npc_ominous_cloudAI : public ScriptedAI
  1679.     {
  1680.         npc_ominous_cloudAI(Creature *c) : ScriptedAI(c)
  1681.         {
  1682.             SetImmuneToPushPullEffects(true);
  1683.             m_pInstance = c->GetInstanceScript();
  1684.         }
  1685.  
  1686.         InstanceScript* m_pInstance;
  1687.  
  1688.         void MoveInLineOfSight(Unit* target)
  1689.         {
  1690.             if(m_pInstance && m_pInstance->GetBossState(TYPE_YOGGSARON) == IN_PROGRESS)
  1691.                 if(target && me->GetDistance2d(target) <= 5 && target->ToPlayer() && !target->ToPlayer()->isGameMaster() && !target->HasAura(SPELL_FLASH_FREEZE))
  1692.                     TriggerGuardianSpawn();
  1693.         }
  1694.  
  1695.         void AttackStart(Unit* /*attacker*/) {}
  1696.  
  1697.         void DoAction(const int32 action)
  1698.         {
  1699.             switch(action)
  1700.             {
  1701.             case ACTION_DEACTIVATE_CLOUDS:
  1702.                 me->RemoveAurasDueToSpell(SPELL_SUMMON_GUARDIAN);
  1703.                 me->RemoveAurasDueToSpell(SPELL_OMINOUS_CLOUD_EFFECT);
  1704.                 me->SetReactState(REACT_PASSIVE);
  1705.                 break;
  1706.             case ACTION_ACTIVATE_CLOUDS:
  1707.                 Reset();
  1708.                 me->SetReactState(REACT_AGGRESSIVE);
  1709.                 break;
  1710.             }
  1711.         }
  1712.  
  1713.         void TriggerGuardianSpawn()
  1714.         {
  1715.             if(!me->HasAura(SPELL_SUMMON_GUARDIAN))
  1716.                 DoCast(me,SPELL_SUMMON_GUARDIAN,true);
  1717.         }
  1718.  
  1719.         void Reset()
  1720.         {
  1721.             DoCast(me,SPELL_OMINOUS_CLOUD_EFFECT,true);
  1722.             me->RemoveAurasDueToSpell(SPELL_SUMMON_GUARDIAN);
  1723.             me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  1724.             me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  1725.             //me->SetReactState(REACT_PASSIVE); //Prevent MoveInLineOfSight
  1726.  
  1727.             me->GetMotionMaster()->MoveRandom(25.0f);
  1728.         }
  1729.  
  1730.         void UpdateAI(const uint32 diff) {}
  1731.     };
  1732. };
  1733.  
  1734. class npc_guardian_of_yogg_saron : public CreatureScript
  1735. {
  1736. public:
  1737.     npc_guardian_of_yogg_saron() : CreatureScript("npc_guardian_of_yogg_saron") { }
  1738.  
  1739.     CreatureAI* GetAI(Creature* pCreature) const
  1740.     {
  1741.         return new npc_guardian_of_yogg_saronAI (pCreature);
  1742.     }
  1743.  
  1744.     struct npc_guardian_of_yogg_saronAI : public ScriptedAI
  1745.     {
  1746.         npc_guardian_of_yogg_saronAI(Creature *c) : ScriptedAI(c)
  1747.         {
  1748.             m_pInstance = c->GetInstanceScript();
  1749.             me->setFaction(14);
  1750.  
  1751.             //SpellEntry *TempSpell;
  1752.             //TempSpell = GET_SPELL(SPELL_SHADOW_NOVA);
  1753.             //if (TempSpell)
  1754.             //    TempSpell->Effect[1] = 0;
  1755.         }
  1756.  
  1757.         InstanceScript* m_pInstance;
  1758.         uint32 uiDarkVolley_Timer;
  1759.  
  1760.         void SpellHitTarget(Unit* target, const SpellEntry* spell)
  1761.         {
  1762.             if(target && target->ToPlayer())
  1763.             {
  1764.                 switch(spell->Id)
  1765.                 {
  1766.                 case SPELL_DARK_VOLLEY:
  1767.                     if(Creature* cSara = me->GetCreature(*me,m_pInstance->GetData64(TYPE_SARA)))
  1768.                         CAST_AI(boss_sara::boss_saraAI,cSara->AI())->ModifySanity(target->ToPlayer(),-2);
  1769.                     break;
  1770.                 }
  1771.             }
  1772.         }
  1773.  
  1774.         Unit* SelectPlayerTargetInRange(float range)
  1775.         {
  1776.             Player *target = NULL;
  1777.             Trinity::AnyPlayerInObjectRangeCheck u_check(me, range);
  1778.             Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, target, u_check);
  1779.             me->VisitNearbyObject(range, searcher);
  1780.             return target;
  1781.         }
  1782.  
  1783.         void JustDied(Unit* /*killer*/)
  1784.         {
  1785.             DoCast(me,SPELL_SHADOW_NOVA,true);
  1786.             if(m_pInstance)
  1787.             {
  1788.                 if(Creature* cSara = me->GetCreature(*me,m_pInstance->GetData64(TYPE_SARA)))
  1789.                         cSara->AI()->DoAction(ACTION_NOVA_HIT);
  1790.             }
  1791.  
  1792.             me->DespawnOrUnsummon(5000);
  1793.         }
  1794.  
  1795.         void Reset()
  1796.         {
  1797.             uiDarkVolley_Timer = urand(20000,30000);
  1798.             if(Unit* target = SelectPlayerTargetInRange(100.0f))
  1799.                 me->AI()->AttackStart(target);
  1800.         }
  1801.  
  1802.         void UpdateAI(const uint32 diff)
  1803.         {
  1804.             if(m_pInstance && m_pInstance->GetBossState(TYPE_YOGGSARON) != IN_PROGRESS)
  1805.             {
  1806.                 me->DealDamage(me,me->GetMaxHealth());
  1807.                 me->RemoveCorpse();
  1808.             }
  1809.  
  1810.             if (!UpdateVictim())
  1811.                 return;
  1812.  
  1813.             if(uiDarkVolley_Timer <= diff)
  1814.             {
  1815.                 DoCast(SPELL_DARK_VOLLEY);
  1816.                 uiDarkVolley_Timer = urand(20000,30000);
  1817.             }else uiDarkVolley_Timer -= diff;
  1818.  
  1819.             DoMeleeAttackIfReady();
  1820.         }
  1821.     };
  1822. };
  1823.  
  1824. class npc_yogg_saron_tentacle : public CreatureScript
  1825. {
  1826. public:
  1827.     npc_yogg_saron_tentacle() : CreatureScript("npc_yogg_saron_tentacle") { }
  1828.  
  1829.     CreatureAI* GetAI(Creature* pCreature) const
  1830.     {
  1831.         return new npc_yogg_saron_tentacleAI (pCreature);
  1832.     }
  1833.  
  1834.     struct npc_yogg_saron_tentacleAI : public Scripted_NoMovementAI
  1835.     {
  1836.         npc_yogg_saron_tentacleAI(Creature *c) : Scripted_NoMovementAI(c)
  1837.         {
  1838.             m_pInstance = c->GetInstanceScript();
  1839.             SetTentacleType(c->GetEntry());
  1840.             once = false;
  1841.             me->setFaction(14);
  1842.             me->SetFlying(true);
  1843.             if(m_pInstance)
  1844.             {
  1845.                 if(Creature* sara = Creature::GetCreature(*me,m_pInstance->GetData64(TYPE_SARA)))
  1846.                     sara->AI()->JustSummoned(me);
  1847.             }
  1848.         }
  1849.  
  1850.         InstanceScript* m_pInstance;
  1851.         TentacleType t_Type;
  1852.         bool once;
  1853.         uint32 uiTentacleSpell_Timer;
  1854.  
  1855.         void SetTentacleType(uint32 entry)
  1856.         {
  1857.             switch(entry)
  1858.             {
  1859.             case ENTRY_CRUSHER_TENTACLE : t_Type = CRUSHER_TENTACLE; break;
  1860.             case ENTRY_CORRUPTOR_TENTACLE : t_Type = CORRUPTOR_TENTACLE; break;
  1861.             case ENTRY_CONSTRICTOR_TENTACLE : t_Type = CONSTRICTOR_TENTACLE; break;
  1862.             default: t_Type = CORRUPTOR_TENTACLE; break;
  1863.             }
  1864.         }
  1865.  
  1866.         void MoveInLineOfSight(Unit* target)
  1867.         {
  1868.             if(target && me->GetDistance2d(target) <= me->GetMeleeReach() && target->ToPlayer() && !target->ToPlayer()->isGameMaster())
  1869.                 AttackStartNoMove(target);
  1870.         }
  1871.  
  1872.         void AttackStart(Unit* /*target*/) {}
  1873.  
  1874.         Unit* SelectPlayerTargetInRange(float range)
  1875.         {
  1876.             Player *target = NULL;
  1877.             Trinity::AnyPlayerInObjectRangeCheck u_check(me, range, true);
  1878.             Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, target, u_check);
  1879.             me->VisitNearbyObject(range, searcher);
  1880.             return target;
  1881.         }
  1882.  
  1883.         void JustDied(Unit* /*killer*/)
  1884.         {
  1885.             me->RemoveAurasDueToSpell(SPELL_TENTACLE_VOID_ZONE);
  1886.  
  1887.             me->DespawnOrUnsummon(5000);
  1888.         }
  1889.  
  1890.         void PassengerBoarded(Unit* who, int8 /*seatId*/, bool apply)
  1891.         {
  1892.             if (apply)
  1893.                 who->CastSpell(who, RAID_MODE(SPELL_SQUEEZE_10, SPELL_SQUEEZE_25), true, NULL, NULL, me->GetGUID());
  1894.             else
  1895.                 who->RemoveAurasDueToSpell(RAID_MODE(SPELL_SQUEEZE_10, SPELL_SQUEEZE_25));
  1896.         }
  1897.  
  1898.         void Reset()
  1899.         {
  1900.             if(Unit* target = SelectPlayerTargetInRange(500.0f))
  1901.                 AttackStartNoMove(target);
  1902.  
  1903.             DoCast(me,SPELL_TENTACLE_VOID_ZONE,true);
  1904.         }
  1905.  
  1906.         void EnterCombat(Unit* /*who*/)
  1907.         {
  1908.             DoZoneInCombat();
  1909.  
  1910.             uiTentacleSpell_Timer = urand(5000,10000);
  1911.             switch(t_Type)
  1912.             {
  1913.             case CRUSHER_TENTACLE:
  1914.                 DoCast(me,SPELL_CRUSH,true);
  1915.                 DoCast(SPELL_FOCUS_ANGER);
  1916.                 break;
  1917.             case CONSTRICTOR_TENTACLE:
  1918.                 uiTentacleSpell_Timer = urand(20000,30000);
  1919.                 break;
  1920.             }
  1921.         }
  1922.  
  1923.         void UpdateAI(const uint32 diff)
  1924.         {
  1925.             if(m_pInstance && m_pInstance->GetBossState(TYPE_YOGGSARON) != IN_PROGRESS)
  1926.             {
  1927.                 me->DealDamage(me,me->GetMaxHealth());
  1928.                 me->RemoveCorpse();
  1929.             }
  1930.  
  1931.             if(!once)
  1932.             {
  1933.                 DoCast(SPELL_ERUPT);
  1934.                 once = true;
  1935.             }
  1936.  
  1937.             if (!UpdateVictim())
  1938.                 return;
  1939.  
  1940.             if(uiTentacleSpell_Timer <= diff)
  1941.             {
  1942.                 switch(t_Type)
  1943.                 {
  1944.                 case CRUSHER_TENTACLE:
  1945.                     if(!me->HasAura(SPELL_DIMISH_POWER))
  1946.                         DoCast(SPELL_DIMISH_POWER);
  1947.                     break;
  1948.                 case CORRUPTOR_TENTACLE:
  1949.                     if(Unit* target = SelectPlayerTargetInRange(500.0f))
  1950.                         DoCast(target,RAND(SPELL_DRAINING_POISON,SPELL_BLACK_PLAGUE,SPELL_APATHY,SPELL_CURSE_OF_DOOM),false);
  1951.                     break;
  1952.                 case CONSTRICTOR_TENTACLE:
  1953.                     if (Unit* target =  me->FindNearestPlayer(50.0f, true))
  1954.                         target->CastSpell(me, SPELL_LUNGE, true);
  1955.                     break;
  1956.                 }
  1957.                 uiTentacleSpell_Timer = urand(5000,7000);
  1958.             }else uiTentacleSpell_Timer -= diff;
  1959.  
  1960.             if(t_Type == CRUSHER_TENTACLE)
  1961.                 DoMeleeAttackIfReady();
  1962.         }
  1963.     };
  1964. };
  1965.  
  1966. class npc_descend_into_madness : public CreatureScript
  1967. {
  1968. public:
  1969.     npc_descend_into_madness() : CreatureScript("npc_descend_into_madness") { }
  1970.  
  1971.     bool OnGossipHello(Player* pPlayer,Creature* pCreature)
  1972.     {
  1973.         pPlayer->PlayerTalkClass->ClearMenus();
  1974.  
  1975.         bool AcceptTeleport = false;
  1976.         Position posTeleportPosition;
  1977.         //pPlayer->NearTeleportTo();
  1978.         BrainEventPhase pTemp = PORTAL_PHASE_BRAIN_NONE;
  1979.         if(pCreature && pCreature->AI())
  1980.             pTemp = CAST_AI(npc_descend_into_madnessAI,pCreature->AI())->bPhase;
  1981.  
  1982.         switch(pTemp)
  1983.         {
  1984.         case PORTAL_PHASE_KING_LLIANE:
  1985.         case PORTAL_PHASE_DRAGON_SOUL:
  1986.         case PORTAL_PHASE_LICH_KING:
  1987.             AcceptTeleport = true;
  1988.             posTeleportPosition = InnerBrainLocation[pTemp];
  1989.             break;
  1990.         default: AcceptTeleport = false; break;
  1991.         }
  1992.  
  1993.         if(AcceptTeleport)
  1994.         {
  1995.             if(pPlayer)
  1996.             {
  1997.                 pPlayer->RemoveAurasDueToSpell(SPELL_BRAIN_LINK);
  1998.                 pCreature->AddAura(SPELL_ILLUSION_ROOM,pPlayer);
  1999.                 pPlayer->NearTeleportTo(posTeleportPosition.m_positionX,posTeleportPosition.m_positionY,posTeleportPosition.m_positionZ,posTeleportPosition.m_orientation,true);
  2000.                 //pPlayer->CastSpell(pPlayer,SPELL_TELEPORT,true);
  2001.                 CAST_AI(npc_descend_into_madnessAI,pCreature->AI())->bPhase = PORTAL_PHASE_BRAIN_NONE;
  2002.                 AcceptTeleport = false;
  2003.                 pPlayer->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2,SPELL_ILLUSION_ROOM);
  2004.                 pCreature->DespawnOrUnsummon(500);
  2005.             }
  2006.  
  2007.         }
  2008.  
  2009.         return true;
  2010.     };
  2011.  
  2012.     CreatureAI* GetAI(Creature* pCreature) const
  2013.     {
  2014.         return new npc_descend_into_madnessAI (pCreature);
  2015.     }
  2016.  
  2017.     struct npc_descend_into_madnessAI : public Scripted_NoMovementAI
  2018.     {
  2019.         npc_descend_into_madnessAI(Creature *c) : Scripted_NoMovementAI(c)
  2020.         {
  2021.         }
  2022.  
  2023.         BrainEventPhase bPhase;
  2024.  
  2025.         void DoAction(const int32 action)
  2026.         {
  2027.             me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
  2028.             switch(action)
  2029.             {
  2030.                 case ACTION_PORTAL_TO_MADNESS_STORMWIND:
  2031.                     bPhase = PORTAL_PHASE_KING_LLIANE;
  2032.                     break;
  2033.                 case ACTION_PORTAL_TO_MADNESS_DRAGON:
  2034.                     bPhase = PORTAL_PHASE_DRAGON_SOUL;
  2035.                     break;
  2036.                 case ACTION_PORTAL_TO_MADNESS_LICHKING:
  2037.                     bPhase = PORTAL_PHASE_LICH_KING;
  2038.                     break;
  2039.             }
  2040.         }
  2041.  
  2042.         void Reset()
  2043.         {
  2044.             bPhase = PORTAL_PHASE_BRAIN_NONE;
  2045.         }
  2046.  
  2047.         void UpdateAI(uint32 const /*diff*/) {}
  2048.     };
  2049. };
  2050.  
  2051.  
  2052. class npc_brain_of_yogg_saron : public CreatureScript
  2053. {
  2054. public:
  2055.     npc_brain_of_yogg_saron() : CreatureScript("npc_brain_of_yogg_saron") { }
  2056.  
  2057.     CreatureAI* GetAI(Creature* pCreature) const
  2058.     {
  2059.         return new npc_brain_of_yogg_saronAI (pCreature);
  2060.     }
  2061.  
  2062.     struct npc_brain_of_yogg_saronAI : public Scripted_NoMovementAI
  2063.     {
  2064.         npc_brain_of_yogg_saronAI(Creature *c) : Scripted_NoMovementAI(c)
  2065.         {
  2066.             m_pInstance = c->GetInstanceScript();
  2067.             me->SetReactState(REACT_PASSIVE);
  2068.             me->setFaction(14);
  2069.             me->SetFlying(true);
  2070.         }
  2071.  
  2072.         void DamageTaken(Unit* /*dealer*/, uint32 &damage)
  2073.         {
  2074.             if(damage > me->GetHealth())
  2075.                 damage = me->GetHealth()-1;
  2076.         }
  2077.  
  2078.         void SpellHitTarget(Unit *target, const SpellInfo *spell)
  2079.         {
  2080.             if(!target->ToPlayer())
  2081.                 return;
  2082.  
  2083.             if(spell->Id == SPELL_INDUCE_MADNESS)
  2084.             {
  2085.                 if(IsPlayerInBrainRoom(target->ToPlayer()))
  2086.                     target->RemoveAurasDueToSpell(SPELL_SANITY);
  2087.             }
  2088.         }
  2089.  
  2090.         InstanceScript* m_pInstance;
  2091.  
  2092.         void UpdateAI(uint32 const /*diff*/)
  2093.         {
  2094.             if(HealthBelowPct(31))
  2095.             {
  2096.                 if(Creature* cSara = me->GetCreature(*me,m_pInstance->GetData64(TYPE_SARA)))
  2097.                         cSara->AI()->DoAction(ACTION_BRAIN_UNDER_30_PERCENT);
  2098.  
  2099.                 if(!me->HasAura(SPELL_BRAIN_HURT_VISUAL))
  2100.                     DoCast(me,SPELL_BRAIN_HURT_VISUAL,true);
  2101.                 me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  2102.                 me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
  2103.             }
  2104.         }
  2105.     };
  2106. };
  2107.  
  2108. class boss_yogg_saron : public CreatureScript
  2109. {
  2110. public:
  2111.     boss_yogg_saron() : CreatureScript("boss_yogg_saron") { }
  2112.  
  2113.     CreatureAI* GetAI(Creature* pCreature) const
  2114.     {
  2115.         return new boss_yogg_saronAI (pCreature);
  2116.     }
  2117.  
  2118.     struct boss_yogg_saronAI : public Scripted_NoMovementAI
  2119.     {
  2120.         boss_yogg_saronAI(Creature *c) : Scripted_NoMovementAI(c)
  2121.         {
  2122.             m_pInstance = c->GetInstanceScript();
  2123.             me->SetReactState(REACT_PASSIVE);
  2124.             me->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING | MOVEMENTFLAG_SWIMMING);
  2125.         }
  2126.  
  2127.         InstanceScript* m_pInstance;
  2128.         uint32 uiSanityCheck_Timer;
  2129.         bool bUsedMindControll;
  2130.  
  2131.         void Reset()
  2132.         {
  2133.             uiSanityCheck_Timer = 1000;
  2134.             bUsedMindControll = false;
  2135.         }
  2136.  
  2137.         void JustDied(Unit* killer)
  2138.         {
  2139.             if(Creature* cSara = me->GetCreature(*me,m_pInstance->GetData64(TYPE_SARA)))
  2140.                 cSara->AI()->DoAction(ACTION_YOGGSARON_KILLED);
  2141.  
  2142.             DoScriptText(SAY_DEATH,me);
  2143.         }
  2144.  
  2145.         void SpellHitTarget(Unit* target, const SpellInfo* spell)
  2146.         {
  2147.             if(!m_pInstance) return;
  2148.  
  2149.             if(target && target->ToPlayer())
  2150.             {
  2151.                 switch(spell->Id)
  2152.                 {
  2153.                 case SPELL_LUNATIC_GAZE_EFFECT:
  2154.                     if(Creature* cSara = me->GetCreature(*me,m_pInstance->GetData64(TYPE_SARA)))
  2155.                         CAST_AI(boss_sara::boss_saraAI,cSara->AI())->ModifySanity(target->ToPlayer(),-4);
  2156.                     break;
  2157.                 }
  2158.             }
  2159.         }
  2160.  
  2161.         void SpellHit(Unit* /*caster*/, SpellInfo const* spell)
  2162.         {
  2163.             if (spell->Id == SPELL_IN_THE_MAWS_OF_THE_OLD_GOD)
  2164.                 me->AddLootMode(LOOT_MODE_HARD_MODE_4);
  2165.         }
  2166.  
  2167.         void UpdateAI(const uint32 diff)
  2168.         {
  2169.             if(m_pInstance && m_pInstance->GetBossState(TYPE_YOGGSARON) != IN_PROGRESS)
  2170.                 return;
  2171.  
  2172.             if(uiSanityCheck_Timer <= diff)
  2173.             {
  2174.                 if(me->GetMap() && me->GetMap()->IsDungeon())
  2175.                 {
  2176.                     Map::PlayerList const& players = me->GetMap()->GetPlayers();
  2177.                     if (!players.isEmpty())
  2178.                         for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  2179.                             if (Player* plr = itr->getSource())
  2180.                                 if(plr->isAlive() && !plr->isGameMaster())
  2181.                                     if(!plr->HasAura(SPELL_SANITY) && !plr->HasAura(SPELL_INSANE))
  2182.                                     {
  2183.                                         // Dont make GMs Insane
  2184.                                         if(plr->GetSession()->GetSecurity() > SEC_PLAYER)
  2185.                                             continue;
  2186.  
  2187.                                         // Say Sara we used Mindcontrol - for Archievment ... we need only one mindecontrolled Player to cancel Achievment
  2188.                                         if(!bUsedMindControll)
  2189.                                         {
  2190.                                             if(Creature* cSara = me->GetCreature(*me,m_pInstance->GetData64(TYPE_SARA)))
  2191.                                                 cSara->AI()->DoAction(ACTION_USED_MINDCONTROL);
  2192.                                             bUsedMindControll = true;
  2193.                                         }
  2194.  
  2195.                                         // Do Not Cast because its AoE and need better targeting scripting
  2196.                                         //DoCast(plr,SPELL_INSANE,true);
  2197.                                         //DoCast(plr,SPELL_INSANE_2,true);
  2198.                                         if(IsPlayerInBrainRoom(plr))
  2199.                                         {
  2200.                                             plr->RemoveAurasDueToSpell(SPELL_ILLUSION_ROOM);
  2201.                                             plr->NearTeleportTo(SaraLocation.GetPositionX(),SaraLocation.GetPositionY(),SaraLocation.GetPositionZ(),M_PI,false);
  2202.                                         }
  2203.  
  2204.                                         me->AddAura(SPELL_INSANE,plr);
  2205.                                         me->AddAura(SPELL_INSANE_2,plr);
  2206.                                         DoScriptText(RAND(WHISP_INSANITY_1,WHISP_INSANITY_2),me,plr);
  2207.                                     }
  2208.                 }
  2209.  
  2210.                 uiSanityCheck_Timer = 1000;
  2211.             }else uiSanityCheck_Timer -= diff;
  2212.         }
  2213.     };
  2214. };
  2215.  
  2216. class npc_influence_tentacle : public CreatureScript
  2217. {
  2218. public:
  2219.     npc_influence_tentacle() : CreatureScript("npc_influence_tentacle") { }
  2220.  
  2221.     CreatureAI* GetAI(Creature* pCreature) const
  2222.     {
  2223.         return new npc_influence_tentacleAI (pCreature);
  2224.     }
  2225.  
  2226.     struct npc_influence_tentacleAI : public Scripted_NoMovementAI
  2227.     {
  2228.         npc_influence_tentacleAI(Creature *c) : Scripted_NoMovementAI(c)
  2229.         {
  2230.             me->SetReactState(REACT_DEFENSIVE);
  2231.         }
  2232.  
  2233.         void JustDied(Unit* /*killer*/)
  2234.         {
  2235.             me->RemoveAurasDueToSpell(SPELL_TENTACLE_VOID_ZONE);
  2236.         }
  2237.  
  2238.         void Reset()
  2239.         {
  2240.         }
  2241.  
  2242.         void DamageTaken(Unit* attacker, uint32 &damage)
  2243.         {
  2244.             if(attacker->ToPlayer())
  2245.                 me->CastCustomSpell(SPELL_GRIM_REPRISAL_DAMAGE, SPELLVALUE_BASE_POINT0, int32(damage *0.60), attacker,true);
  2246.         }
  2247.  
  2248.         void EnterCombat(Unit* /*attacker*/)
  2249.         {
  2250.             if(me->GetEntry() != ENTRY_INFULENCE_TENTACLE)
  2251.             {
  2252.                 me->UpdateEntry(ENTRY_INFULENCE_TENTACLE);
  2253.                 me->setFaction(14);
  2254.                 me->setRegeneratingHealth(false);
  2255.                 DoCast(SPELL_GRIM_REPRISAL);
  2256.  
  2257.                 DoCast(me,SPELL_TENTACLE_VOID_ZONE,true);
  2258.             }
  2259.         }
  2260.     };
  2261. };
  2262.  
  2263. class npc_immortal_guardian : public CreatureScript
  2264. {
  2265. public:
  2266.     npc_immortal_guardian() : CreatureScript("npc_immortal_guardian") { }
  2267.  
  2268.     CreatureAI* GetAI(Creature* pCreature) const
  2269.     {
  2270.         return new npc_immortal_guardianAI (pCreature);
  2271.     }
  2272.  
  2273.     struct npc_immortal_guardianAI : public ScriptedAI
  2274.     {
  2275.         npc_immortal_guardianAI(Creature *c) : ScriptedAI(c)
  2276.         {
  2277.             m_pInstance = c->GetInstanceScript();
  2278.             me->setFaction(14);
  2279.             SetImmuneToPushPullEffects(true);
  2280.         }
  2281.  
  2282.         InstanceScript* m_pInstance;
  2283.  
  2284.         uint32 uiDrainLife_Timer;
  2285.  
  2286.         Unit* SelectPlayerTargetInRange(float range)
  2287.         {
  2288.             Player *target = NULL;
  2289.             Trinity::AnyPlayerInObjectRangeCheck u_check(me, range, true);
  2290.             Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(me, target, u_check);
  2291.             me->VisitNearbyObject(range, searcher);
  2292.             return target;
  2293.         }
  2294.  
  2295.         void Reset()
  2296.         {
  2297.             if(Unit* target = SelectPlayerTargetInRange(100.0f))
  2298.                 me->AI()->AttackStart(target);
  2299.  
  2300.             uiDrainLife_Timer = 10000;
  2301.         }
  2302.  
  2303.         void JustDied(Unit* /*killer*/)
  2304.         {
  2305.             me->DespawnOrUnsummon(5000);
  2306.         }
  2307.  
  2308.         void SpellHit(Unit* /*caster*/, SpellInfo const* spell)
  2309.         {
  2310.             if(spell->Id == 64172) // Titanic Storm
  2311.             {
  2312.                 if(me->HasAura(SPELL_WEAKENED))
  2313.                     me->DealDamage(me,me->GetHealth());
  2314.             }
  2315.         }
  2316.  
  2317.         void DamageTaken(Unit* dealer, uint32 &damage)
  2318.         {
  2319.             if(dealer->GetGUID() == me->GetGUID())
  2320.                 return;
  2321.  
  2322.             if(me->GetHealth() < damage)
  2323.                 damage = me->GetHealth()-1;
  2324.         }
  2325.  
  2326.         void UpdateAI(const uint32 diff)
  2327.         {
  2328.             if(m_pInstance && m_pInstance->GetBossState(TYPE_YOGGSARON) != IN_PROGRESS)
  2329.             {
  2330.                 me->DealDamage(me,me->GetMaxHealth());
  2331.                 me->RemoveCorpse();
  2332.             }
  2333.  
  2334.             {
  2335.                 int8 stacks = int8(uint32(me->GetHealthPct()) / 10);
  2336.                 if(stacks > 9) stacks = 9;
  2337.  
  2338.                 if(stacks > 0)
  2339.                 {
  2340.                     me->RemoveAurasDueToSpell(SPELL_WEAKENED);
  2341.                     if(!me->HasAura(SPELL_EMPOWERED))
  2342.                         me->AddAura(SPELL_EMPOWERED,me);
  2343.                     me->SetAuraStack(SPELL_EMPOWERED,me,stacks);
  2344.                 }else
  2345.                 {
  2346.                     me->RemoveAurasDueToSpell(SPELL_EMPOWERED);
  2347.                     if(!me->HasAura(SPELL_WEAKENED))
  2348.                         me->AddAura(SPELL_WEAKENED,me);
  2349.                 }
  2350.             }
  2351.  
  2352.             if(m_pInstance->GetBossState(TYPE_YOGGSARON) != IN_PROGRESS)
  2353.                 return;
  2354.  
  2355.             if (!UpdateVictim())
  2356.                 return;
  2357.  
  2358.             if(uiDrainLife_Timer < diff)
  2359.             {
  2360.                 DoCast(me->getVictim(),RAID_MODE(SPELL_DRAIN_LIFE_10,SPELL_DRAIN_LIFE_25));
  2361.                 uiDrainLife_Timer = 35000;
  2362.             }else uiDrainLife_Timer -= diff;
  2363.  
  2364.             DoMeleeAttackIfReady();
  2365.         }
  2366.     };
  2367. };
  2368.  
  2369. class AllSaronitCreaturesInRange
  2370. {
  2371.     public:
  2372.         AllSaronitCreaturesInRange(const WorldObject* pObject, float fMaxRange) : m_pObject(pObject), m_fRange(fMaxRange) {}
  2373.         bool operator() (Unit* pUnit)
  2374.         {
  2375.             if (IsSaronitEntry(pUnit->GetEntry()) && m_pObject->IsWithinDist(pUnit,m_fRange,false) && pUnit->isAlive())
  2376.                 return true;
  2377.  
  2378.             return false;
  2379.         }
  2380.  
  2381.     private:
  2382.         const WorldObject* m_pObject;
  2383.         float m_fRange;
  2384.  
  2385.         bool IsSaronitEntry(uint32 entry)
  2386.         {
  2387.             switch(entry)
  2388.             {
  2389.             case ENTRY_GUARDIAN_OF_YOGG_SARON:
  2390.             case ENTRY_CONSTRICTOR_TENTACLE:
  2391.             case ENTRY_CORRUPTOR_TENTACLE:
  2392.             case ENTRY_CRUSHER_TENTACLE:
  2393.             case ENTRY_IMMORTAL_GUARDIAN:
  2394.                 return true;
  2395.             }
  2396.             return false;
  2397.         }
  2398. };
  2399.  
  2400. class npc_support_keeper : public CreatureScript
  2401. {
  2402. public:
  2403.     npc_support_keeper() : CreatureScript("npc_support_keeper") { }
  2404.  
  2405.     CreatureAI* GetAI(Creature* pCreature) const
  2406.     {
  2407.         return new npc_support_keeperAI (pCreature);
  2408.     }
  2409.  
  2410.     struct npc_support_keeperAI : public Scripted_NoMovementAI
  2411.     {
  2412.         npc_support_keeperAI(Creature *c) : Scripted_NoMovementAI(c) , Summons(me)
  2413.         {
  2414.             m_pInstance = c->GetInstanceScript();
  2415.         }
  2416.  
  2417.         SummonList Summons;
  2418.         InstanceScript* m_pInstance;
  2419.  
  2420.         uint32 uiSecondarySpell_Timer;
  2421.  
  2422.         bool summoning;
  2423.         bool summoned;
  2424.  
  2425.         void AttackStart(Unit *attacker) {}
  2426.  
  2427.         void Reset()
  2428.         {
  2429.             uint32 auraspell = 0;
  2430.             switch(me->GetEntry())
  2431.             {
  2432.             case ENTRY_KEEPER_HODIR:
  2433.                 auraspell = SPELL_FORTITUDE_OF_FROST;
  2434.                 break;
  2435.             case ENTRY_KEEPER_FREYA:
  2436.                 auraspell = SPELL_RESILIENCE_OF_NATURE;
  2437.                 break;
  2438.             case ENTRY_KEEPER_THORIM:
  2439.                 auraspell = SPELL_FURY_OF_THE_STORM;
  2440.                 break;
  2441.             case ENTRY_KEEPER_MIMIRON:
  2442.                 auraspell = SPELL_SPEED_OF_INVENTION;
  2443.                 break;
  2444.             }
  2445.             DoCast(auraspell);
  2446.  
  2447.             summoning = false;
  2448.             summoned = false;
  2449.  
  2450.             uiSecondarySpell_Timer = 10000;
  2451.         }
  2452.  
  2453.         void JustSummoned(Creature* pSummoned)
  2454.         {
  2455.             Summons.Summon(pSummoned);
  2456.         }
  2457.  
  2458.         void DoSummonSanityWells()
  2459.         {
  2460.             for(uint8 i = 0; i < 5 ; i++)
  2461.                 DoSummon(ENTRY_SANITY_WELL,FreyaSanityWellLocation[i],0,TEMPSUMMON_MANUAL_DESPAWN);
  2462.         }
  2463.  
  2464.         void GetAliveSaronitCreatureListInGrid(std::list<Creature*>& lList, float fMaxSearchRange)
  2465.         {
  2466.             CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
  2467.             Cell cell(pair);
  2468.             cell.SetNoCreate();
  2469.  
  2470.             AllSaronitCreaturesInRange check(me, fMaxSearchRange);
  2471.             Trinity::CreatureListSearcher<AllSaronitCreaturesInRange> searcher(me, lList, check);
  2472.             TypeContainerVisitor<Trinity::CreatureListSearcher<AllSaronitCreaturesInRange>, GridTypeMapContainer> visitor(searcher);
  2473.  
  2474.             cell.Visit(pair, visitor, *(me->GetMap()), *me, SIZE_OF_GRIDS);
  2475.         }
  2476.  
  2477.         void UpdateAI(const uint32 diff)
  2478.         {
  2479.             if(uiSecondarySpell_Timer <= diff)
  2480.             {
  2481.                 switch(me->GetEntry())
  2482.                 {
  2483.                 case ENTRY_KEEPER_THORIM:
  2484.                     if(!me->HasAura(SPELL_TITANIC_STORM))
  2485.                         DoCast(SPELL_TITANIC_STORM);
  2486.  
  2487.                     uiSecondarySpell_Timer = 10000;
  2488.                     return;
  2489.                 case ENTRY_KEEPER_FREYA:
  2490.                     if(!summoned)
  2491.                     {
  2492.                         if(!summoning)
  2493.                         {
  2494.                             DoCast(SPELL_SANITY_WELL);
  2495.                             uiSecondarySpell_Timer = 3000;
  2496.                             summoning = true;
  2497.                         }else
  2498.                         {
  2499.                             DoSummonSanityWells();
  2500.                             summoned = true;
  2501.                         }
  2502.                     }
  2503.                     return;
  2504.                 case ENTRY_KEEPER_MIMIRON:
  2505.                     {
  2506.                         std::list<Creature*> creatureList;
  2507.                         GetAliveSaronitCreatureListInGrid(creatureList,5000);
  2508.                         if(!creatureList.empty())
  2509.                         {
  2510.                             std::list<Creature*>::iterator itr = creatureList.begin();
  2511.                             advance(itr, urand(0, creatureList.size()-1));
  2512.                             DoCast((*itr),SPELL_DESTABILIZATION_MATRIX,false);
  2513.                         }
  2514.                     }
  2515.                     uiSecondarySpell_Timer = 30000;
  2516.                     return;
  2517.                 case ENTRY_KEEPER_HODIR:
  2518.                     {
  2519.                         if(!me->HasAura(SPELL_HODIRS_PROTECTIVE_GAZE))
  2520.                             DoCast(me,SPELL_HODIRS_PROTECTIVE_GAZE,false);
  2521.                         uiSecondarySpell_Timer = 25000;
  2522.                     }
  2523.                 }
  2524.                 uiSecondarySpell_Timer = 10000;
  2525.             }else
  2526.             {
  2527.                 if(me->GetEntry() == ENTRY_KEEPER_HODIR)
  2528.                 {
  2529.                     if(!me->HasAura(SPELL_HODIRS_PROTECTIVE_GAZE))
  2530.                         uiSecondarySpell_Timer -= diff;
  2531.                 }else uiSecondarySpell_Timer -= diff;
  2532.             }
  2533.         }
  2534.     };
  2535. };
  2536.  
  2537. class npc_sanity_well : public CreatureScript
  2538. {
  2539. public:
  2540.     npc_sanity_well() : CreatureScript("npc_sanity_well") { }
  2541.  
  2542.     CreatureAI* GetAI(Creature* pCreature) const
  2543.     {
  2544.         return new npc_sanity_wellAI (pCreature);
  2545.     }
  2546.  
  2547.     struct npc_sanity_wellAI : public Scripted_NoMovementAI
  2548.     {
  2549.         npc_sanity_wellAI(Creature *c) : Scripted_NoMovementAI(c)
  2550.         {
  2551.             m_pInstance = c->GetInstanceScript();
  2552.         }
  2553.  
  2554.         InstanceScript* m_pInstance;
  2555.  
  2556.         uint32 uiSanityTick_Timer;
  2557.  
  2558.         void Reset()
  2559.         {
  2560.             DoCast(SPELL_SANITY_WELL_OPTIC);
  2561.             uiSanityTick_Timer = 2000;
  2562.         }
  2563.  
  2564.         void AttackStart(Unit* /*who*/) {}
  2565.  
  2566.         void MoveInLineOfSight(Unit *mover)
  2567.         {
  2568.             if(mover && mover->ToPlayer() )
  2569.                 if(me->IsWithinDist2d(mover,6))
  2570.                 {
  2571.                     if(!mover->HasAura(SPELL_SANITY_WELL_DEBUFF))
  2572.                         me->AddAura(SPELL_SANITY_WELL_DEBUFF,mover);
  2573.                 }else
  2574.                 {
  2575.                     if(mover->HasAura(SPELL_SANITY_WELL_DEBUFF))
  2576.                         mover->RemoveAurasDueToSpell(SPELL_SANITY_WELL_DEBUFF);
  2577.                 }
  2578.         }
  2579.  
  2580.         void UpdateAI(const uint32 diff)
  2581.         {
  2582.             if(m_pInstance && m_pInstance->GetBossState(TYPE_YOGGSARON) != IN_PROGRESS)
  2583.             {
  2584.                 me->DealDamage(me,me->GetMaxHealth());
  2585.                 me->RemoveCorpse();
  2586.             }
  2587.  
  2588.             if(uiSanityTick_Timer <= diff)
  2589.             {
  2590.                 std::list<Player*> plrList = me->GetNearestPlayersList(10);
  2591.                 for (std::list<Player*>::const_iterator itr = plrList.begin(); itr != plrList.end(); ++itr)
  2592.                 {
  2593.                     if((*itr))
  2594.                     {
  2595.                         if((*itr)->HasAura(SPELL_SANITY_WELL_DEBUFF))
  2596.                         {
  2597.                             if(Creature* sara = Creature::GetCreature((*me),m_pInstance->GetData64(TYPE_SARA)))
  2598.                                 CAST_AI(boss_sara::boss_saraAI,sara->AI())->ModifySanity((*itr),10);
  2599.                         }
  2600.                     }
  2601.                 }
  2602.                 uiSanityTick_Timer = 2000;
  2603.             }else uiSanityTick_Timer -= diff;
  2604.         }
  2605.     };
  2606. };
  2607.  
  2608. class npc_laughting_skull : public CreatureScript
  2609. {
  2610. public:
  2611.     npc_laughting_skull() : CreatureScript("npc_laughting_skull") { }
  2612.  
  2613.     CreatureAI* GetAI(Creature* pCreature) const
  2614.     {
  2615.         return new npc_laughting_skullAI (pCreature);
  2616.     }
  2617.  
  2618.     struct npc_laughting_skullAI : public Scripted_NoMovementAI
  2619.     {
  2620.         npc_laughting_skullAI(Creature *c) : Scripted_NoMovementAI(c)
  2621.         {
  2622.             m_pInstance = c->GetInstanceScript();
  2623.         }
  2624.  
  2625.         InstanceScript* m_pInstance;
  2626.  
  2627.         void Reset()
  2628.         {
  2629.             DoCast(SPELL_LS_LUNATIC_GAZE);
  2630.         }
  2631.  
  2632.         void SpellHitTarget(Unit* target, const SpellInfo* spell)
  2633.         {
  2634.             if(!m_pInstance) return;
  2635.  
  2636.             if(target && target->ToPlayer())
  2637.             {
  2638.                 switch(spell->Id)
  2639.                 {
  2640.                 case SPELL_LS_LUNATIC_GAZE_EFFECT:
  2641.                     if(Creature* cSara = me->GetCreature(*me,m_pInstance->GetData64(TYPE_SARA)))
  2642.                         CAST_AI(boss_sara::boss_saraAI,cSara->AI())->ModifySanity(target->ToPlayer(),-2);
  2643.                     break;
  2644.                 }
  2645.             }
  2646.         }
  2647.  
  2648.         void AttackStart(Unit* /*who*/) {}
  2649.  
  2650.         void UpdateAI(uint32 const /*diff*/)
  2651.         {
  2652.         }
  2653.     };
  2654. };
  2655.  
  2656. class npc_death_orb : public CreatureScript
  2657. {
  2658. public:
  2659.     npc_death_orb() : CreatureScript("npc_death_orb") { }
  2660.  
  2661.     CreatureAI* GetAI(Creature* pCreature) const
  2662.     {
  2663.         return new npc_death_orbAI (pCreature);
  2664.     }
  2665.  
  2666.     struct npc_death_orbAI : public Scripted_NoMovementAI
  2667.     {
  2668.         npc_death_orbAI(Creature *c) : Scripted_NoMovementAI(c) , Summons(me)
  2669.         {
  2670.             m_pInstance = c->GetInstanceScript();
  2671.             me->SetReactState(REACT_PASSIVE);
  2672.             me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
  2673.         }
  2674.  
  2675.         SummonList Summons;
  2676.         InstanceScript* m_pInstance;
  2677.         bool prepaired;
  2678.         uint32 uiReathRayEffekt_Timer;
  2679.  
  2680.         void Reset()
  2681.         {
  2682.             me->SetFlying(true);
  2683.             me->setFaction(14);
  2684.             prepaired = false;
  2685.             Summons.DespawnAll();
  2686.             SummonDeathRays();
  2687.             uiReathRayEffekt_Timer = 5000;
  2688.             DoCast(me,SPELL_DEATH_RAY_ORIGIN_VISUAL,true);
  2689.         }
  2690.  
  2691.         void SummonDeathRays()
  2692.         {
  2693.             for(uint8 i = 0; i < 4; i++)
  2694.             {
  2695.                 Position pos;
  2696.                 me->GetNearPoint2D(pos.m_positionX,pos.m_positionY,float(rand_norm()*10 + 30),float(2*M_PI*rand_norm()));
  2697.                 pos.m_positionZ = me->GetPositionZ();
  2698.                 pos.m_positionZ = me->GetMap()->GetHeight(pos.GetPositionX(),pos.GetPositionY(),pos.GetPositionZ(),true,500.0f);
  2699.  
  2700.                 DoSummon(ENTRY_DEATH_RAY,pos,20000,TEMPSUMMON_TIMED_DESPAWN);
  2701.             }
  2702.         }
  2703.  
  2704.         void JustSummoned(Creature* pSummoned)
  2705.         {
  2706.             switch(pSummoned->GetEntry())
  2707.             {
  2708.             case ENTRY_DEATH_RAY:
  2709.                 pSummoned->setFaction(14);
  2710.                 pSummoned->CastSpell(pSummoned,SPELL_DEATH_RAY_WARNING_VISUAL,true,0,0,me->GetGUID());
  2711.                 pSummoned->SetReactState(REACT_PASSIVE);
  2712.                 pSummoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
  2713.                 break;
  2714.             }
  2715.  
  2716.             Summons.Summon(pSummoned);
  2717.         }
  2718.  
  2719.         void AttackStart(Unit* /*who*/) {}
  2720.  
  2721.         void UpdateAI(const uint32 diff)
  2722.         {
  2723.             if(uiReathRayEffekt_Timer <= diff)
  2724.             {
  2725.                 for(std::list<uint64>::iterator itr = Summons.begin(); itr != Summons.end(); ++itr)
  2726.                 {
  2727.                     if(Creature* temp = me->GetCreature(*me,*itr))
  2728.                     {
  2729.                         temp->CastSpell(temp,SPELL_DEATH_RAY_PERIODIC,true);
  2730.                         temp->CastSpell(temp,SPELL_DEATH_RAY_DAMAGE_VISUAL,true,0,0,me->GetGUID());
  2731.  
  2732.                         temp->AI()->DoAction(ACTION_DEATH_RAY_MOVE);
  2733.                     }
  2734.                 }
  2735.                 uiReathRayEffekt_Timer = 30000;
  2736.             }else uiReathRayEffekt_Timer -= diff;
  2737.         }
  2738.     };
  2739. };
  2740.  
  2741. class npc_death_ray : public CreatureScript
  2742. {
  2743. public:
  2744.     npc_death_ray() : CreatureScript("npc_death_ray") { }
  2745.  
  2746.     CreatureAI* GetAI(Creature* pCreature) const
  2747.     {
  2748.         return new npc_death_rayAI (pCreature);
  2749.     }
  2750.  
  2751.     struct npc_death_rayAI : public ScriptedAI
  2752.     {
  2753.         npc_death_rayAI(Creature *c) : ScriptedAI(c)
  2754.         {
  2755.         }
  2756.  
  2757.         bool moving;
  2758.  
  2759.         void Reset()
  2760.         {
  2761.             moving = true;
  2762.         }
  2763.  
  2764.         void DoAction(const int32 action)
  2765.         {
  2766.             if(action == ACTION_DEATH_RAY_MOVE)
  2767.                 moving = false;
  2768.         }
  2769.  
  2770.         void DoRandomMove()
  2771.         {
  2772.             Position pos;
  2773.             me->GetNearPoint2D(pos.m_positionX,pos.m_positionY,10,float(2*M_PI*rand_norm()));
  2774.             pos.m_positionZ = me->GetPositionZ();
  2775.             pos.m_positionZ = me->GetMap()->GetHeight(pos.GetPositionX(),pos.GetPositionY(),pos.GetPositionZ(),true,50.0f);
  2776.             me->SetUnitMovementFlags(MOVEMENTFLAG_WALKING);
  2777.             me->GetMotionMaster()->MovePoint(1,pos);
  2778.         }
  2779.  
  2780.         void MovementInform(uint32 type, uint32 id)
  2781.         {
  2782.             if (type != POINT_MOTION_TYPE)
  2783.                 return;
  2784.  
  2785.             if(id != 1)
  2786.                 return;
  2787.  
  2788.             moving = false;
  2789.         }
  2790.  
  2791.         void AttackStart(Unit* /*who*/) {}
  2792.  
  2793.         void UpdateAI(uint32 const /*diff*/)
  2794.         {
  2795.             if(!moving)
  2796.             {
  2797.                 DoRandomMove();
  2798.                 moving = true;
  2799.             }
  2800.         }
  2801.     };
  2802. };
  2803.  
  2804. class go_flee_to_surface : public GameObjectScript
  2805. {
  2806. public:
  2807.     go_flee_to_surface() : GameObjectScript("go_flee_to_surface") { }
  2808.  
  2809.     bool OnGossipHello(Player *pPlayer, GameObject * /*pGO*/)
  2810.     {
  2811.         pPlayer->RemoveAurasDueToSpell(SPELL_ILLUSION_ROOM);
  2812.         pPlayer->NearTeleportTo(SaraLocation.GetPositionX(),SaraLocation.GetPositionY(),SaraLocation.GetPositionZ(),M_PI,false);
  2813.         pPlayer->JumpTo(40.0f,15.0f,true);
  2814.         return false;
  2815.     }
  2816. };
  2817.  
  2818. class spell_keeper_support_aura_targeting : public SpellScriptLoader
  2819. {
  2820.     public:
  2821.         spell_keeper_support_aura_targeting() : SpellScriptLoader("spell_keeper_support_aura_targeting") { }
  2822.  
  2823.     class spell_keeper_support_aura_targeting_AuraScript : public AuraScript
  2824.     {
  2825.         PrepareAuraScript(spell_keeper_support_aura_targeting_AuraScript)
  2826.         void HandleEffectApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
  2827.         {
  2828.             std::list<Unit*> targetList;
  2829.             aurEff->GetTargetList(targetList);
  2830.  
  2831.             for(std::list<Unit*>::iterator iter = targetList.begin(); iter != targetList.end(); ++iter)
  2832.                 if(!(*iter)->ToPlayer() && (*iter)->GetGUID() != GetCasterGUID() )
  2833.                     (*iter)->RemoveAurasDueToSpell(GetSpellInfo()->Id);
  2834.         }
  2835.  
  2836.         void Register()
  2837.         {
  2838.             OnEffectApply += AuraEffectApplyFn(spell_keeper_support_aura_targeting_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, AURA_EFFECT_HANDLE_REAL);
  2839.         }
  2840.     };
  2841.  
  2842.     AuraScript *GetAuraScript() const
  2843.     {
  2844.         return new spell_keeper_support_aura_targeting_AuraScript();
  2845.     }
  2846. };
  2847.  
  2848. class DontLooksDirectlyInGazeCheck
  2849. {
  2850.     public:
  2851.         DontLooksDirectlyInGazeCheck(Unit* caster) : _caster(caster) { }
  2852.  
  2853.         bool operator() (Unit* unit)
  2854.         {
  2855.             Position pos;
  2856.             _caster->GetPosition(&pos);
  2857.             return !unit->HasInArc(static_cast<float>(M_PI), &pos);
  2858.         }
  2859.  
  2860.     private:
  2861.         Unit* _caster;
  2862. };
  2863.  
  2864. class spell_lunatic_gaze_targeting : public SpellScriptLoader
  2865. {
  2866.     public:
  2867.         spell_lunatic_gaze_targeting() : SpellScriptLoader("spell_lunatic_gaze_targeting") { }
  2868.  
  2869.         class spell_lunatic_gaze_targeting_SpellScript : public SpellScript
  2870.         {
  2871.             PrepareSpellScript(spell_lunatic_gaze_targeting_SpellScript)
  2872.  
  2873.             void FilterTargets(std::list<Unit*>& unitList)
  2874.             {
  2875.                 unitList.remove_if(DontLooksDirectlyInGazeCheck(GetCaster()));
  2876.             }
  2877.  
  2878.             void Register()
  2879.             {
  2880.                 OnUnitTargetSelect += SpellUnitTargetFn(spell_lunatic_gaze_targeting_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
  2881.                 OnUnitTargetSelect += SpellUnitTargetFn(spell_lunatic_gaze_targeting_SpellScript::FilterTargets, EFFECT_1, TARGET_UNIT_SRC_AREA_ENEMY);
  2882.             }
  2883.         };
  2884.  
  2885.         // function which creates SpellScript
  2886.         SpellScript *GetSpellScript() const
  2887.         {
  2888.             return new spell_lunatic_gaze_targeting_SpellScript();
  2889.         }
  2890. };
  2891.  
  2892. class spell_brain_link_periodic_dummy : public SpellScriptLoader
  2893. {
  2894.     public:
  2895.         spell_brain_link_periodic_dummy() : SpellScriptLoader("spell_brain_link_periodic_dummy") { }
  2896.  
  2897.     class spell_brain_link_periodic_dummy_AuraScript : public AuraScript
  2898.     {
  2899.         PrepareAuraScript(spell_brain_link_periodic_dummy_AuraScript)
  2900.  
  2901.         void HandlePeriodicDummy(AuraEffect const* aurEff)
  2902.         {
  2903.             PreventDefaultAction();
  2904.             if (Unit* trigger = GetTarget())
  2905.             {
  2906.                 if (trigger->GetTypeId() == TYPEID_PLAYER)
  2907.                 {
  2908.                     if(!trigger->GetMap()->IsDungeon())
  2909.                         return;
  2910.  
  2911.                     Map::PlayerList const &players = trigger->GetMap()->GetPlayers();
  2912.                     for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
  2913.                         if (Player* player = itr->getSource())
  2914.                             if(player->HasAura(SPELL_BRAIN_LINK) && player->GetGUID() != trigger->GetGUID() )
  2915.                             {
  2916.                                 trigger->CastSpell(player, SPELL_BRAIN_LINK_DUMMY, true);
  2917.                                 if(Unit* caster = GetCaster())
  2918.                                 if (!player->IsWithinDist(trigger, float(aurEff->GetAmount())))
  2919.                                 {
  2920.                                     caster->CastSpell(trigger, SPELL_BRAIN_LINK_DAMAGE, true);
  2921.                                     if(InstanceScript* pInstance = caster->GetInstanceScript())
  2922.                                         if(caster->ToCreature() && caster->GetGUID() == pInstance->GetData64(TYPE_SARA))
  2923.                                             CAST_AI(boss_sara::boss_saraAI,caster->ToCreature()->AI())->ModifySanity(player,-2);
  2924.                                 }
  2925.                             }
  2926.                 }
  2927.             }
  2928.         }
  2929.  
  2930.         void Register()
  2931.         {
  2932.             OnEffectPeriodic += AuraEffectPeriodicFn(spell_brain_link_periodic_dummy_AuraScript::HandlePeriodicDummy, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
  2933.         }
  2934.     };
  2935.  
  2936.     AuraScript *GetAuraScript() const
  2937.     {
  2938.         return new spell_brain_link_periodic_dummy_AuraScript();
  2939.     }
  2940. };
  2941.  
  2942. class NotIsWeakenedImmortalCheck
  2943. {
  2944.     public:
  2945.         NotIsWeakenedImmortalCheck() { }
  2946.  
  2947.         bool operator() (Unit* unit)
  2948.         {
  2949.             return !(unit->HasAura(SPELL_WEAKENED));
  2950.         }
  2951. };
  2952.  
  2953. class spell_titanic_storm_targeting : public SpellScriptLoader
  2954. {
  2955.     public:
  2956.         spell_titanic_storm_targeting() : SpellScriptLoader("spell_titanic_storm_targeting") { }
  2957.  
  2958.         class spell_titanic_storm_targeting_SpellScript : public SpellScript
  2959.         {
  2960.             PrepareSpellScript(spell_titanic_storm_targeting_SpellScript)
  2961.  
  2962.             void FilterTargets(std::list<Unit*>& unitList)
  2963.             {
  2964.                 unitList.remove_if(NotIsWeakenedImmortalCheck());
  2965.             }
  2966.  
  2967.             void Register()
  2968.             {
  2969.                 OnUnitTargetSelect += SpellUnitTargetFn(spell_titanic_storm_targeting_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY);
  2970.             }
  2971.         };
  2972.  
  2973.         // function which creates SpellScript
  2974.         SpellScript *GetSpellScript() const
  2975.         {
  2976.             return new spell_titanic_storm_targeting_SpellScript();
  2977.         }
  2978. };
  2979.  
  2980. class spell_insane_death_effekt : public SpellScriptLoader
  2981. {
  2982.     public:
  2983.         spell_insane_death_effekt() : SpellScriptLoader("spell_insane_death_effekt") { }
  2984.  
  2985.         class spell_insane_death_effekt_AuraScript : public AuraScript
  2986.         {
  2987.             PrepareAuraScript(spell_insane_death_effekt_AuraScript)
  2988.  
  2989.             void HandleEffectRemove(AuraEffect const * /*aurEff*/, AuraEffectHandleModes /*mode*/)
  2990.             {
  2991.                 if(Unit * target = GetTarget())
  2992.                     if(target->ToPlayer() && target->isAlive())
  2993.                         target->DealDamage(target,target->GetHealth());
  2994.             }
  2995.  
  2996.             // function registering
  2997.             void Register()
  2998.             {
  2999.                 OnEffectRemove += AuraEffectRemoveFn(spell_insane_death_effekt_AuraScript::HandleEffectRemove, EFFECT_0, SPELL_AURA_AOE_CHARM, AURA_EFFECT_HANDLE_REAL);
  3000.             }
  3001.         };
  3002.  
  3003.         AuraScript *GetAuraScript() const
  3004.         {
  3005.             return new spell_insane_death_effekt_AuraScript();
  3006.         }
  3007. };
  3008.  
  3009. class spell_summon_tentacle_position : public SpellScriptLoader
  3010. {
  3011.     public:
  3012.         spell_summon_tentacle_position() : SpellScriptLoader("spell_summon_tentacle_position") { }
  3013.  
  3014.         class spell_summon_tentacle_position_SpellScript : public SpellScript
  3015.         {
  3016.             PrepareSpellScript(spell_summon_tentacle_position_SpellScript);
  3017.  
  3018.             void ChangeSummonPos(SpellEffIndex /*effIndex*/)
  3019.             {
  3020.                 WorldLocation summonPos = *GetTargetDest();
  3021.                 if (Unit* caster = GetCaster())
  3022.                     summonPos.m_positionZ = caster->GetMap()->GetHeight(summonPos.GetPositionX(), summonPos.GetPositionY(), summonPos.GetPositionZ());
  3023.  
  3024.                 SetTargetDest(summonPos);
  3025.             }
  3026.  
  3027.             void Register()
  3028.             {
  3029.                 OnEffectHit += SpellEffectFn(spell_summon_tentacle_position_SpellScript::ChangeSummonPos, EFFECT_0, SPELL_EFFECT_SUMMON);
  3030.             }
  3031.         };
  3032.  
  3033.         SpellScript* GetSpellScript() const
  3034.         {
  3035.             return new spell_summon_tentacle_position_SpellScript();
  3036.         }
  3037. };
  3038.  
  3039. class spell_empowering_shadows : public SpellScriptLoader
  3040. {
  3041.     public:
  3042.         spell_empowering_shadows() : SpellScriptLoader("spell_empowering_shadows") { }
  3043.  
  3044.         class spell_empowering_shadows_SpellScript : public SpellScript
  3045.         {
  3046.             PrepareSpellScript(spell_empowering_shadows_SpellScript)
  3047.  
  3048.             void HandleScript(SpellEffIndex /*effIndex*/)
  3049.             {
  3050.                 if (Unit * target = GetHitUnit())
  3051.                 {
  3052.                     uint32 spell = 0;
  3053.                     switch(target->GetMap()->GetDifficulty())
  3054.                     {
  3055.                     case RAID_DIFFICULTY_10MAN_NORMAL:
  3056.                         spell = SPELL_EMPOWERING_SHADOWS_HEAL_10;
  3057.                         break;
  3058.                     case RAID_DIFFICULTY_25MAN_NORMAL:
  3059.                         spell = SPELL_EMPOWERING_SHADOWS_HEAL_25;
  3060.                         break;
  3061.                     }
  3062.                     if(spell)
  3063.                         GetCaster()->CastSpell(target, spell, true);
  3064.                 }
  3065.             }
  3066.  
  3067.             void Register()
  3068.             {
  3069.                 OnEffectHitTarget += SpellEffectFn(spell_empowering_shadows_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
  3070.             }
  3071.         };
  3072.  
  3073.         // function which creates SpellScript
  3074.         SpellScript *GetSpellScript() const
  3075.         {
  3076.             return new spell_empowering_shadows_SpellScript();
  3077.         }
  3078. };
  3079.  
  3080. // Hodir's Protective Gaze
  3081. class spell_hodir_protective_gaze : public SpellScriptLoader
  3082. {
  3083. public:
  3084.     spell_hodir_protective_gaze() : SpellScriptLoader("spell_hodir_protective_gaze") { }
  3085.  
  3086.     class spell_hodir_protective_gaze_AuraScript : public AuraScript
  3087.     {
  3088.         PrepareAuraScript(spell_hodir_protective_gaze_AuraScript);
  3089.  
  3090.         bool Validate(SpellInfo const * /*spellEntry*/)
  3091.         {
  3092.             return sSpellMgr->GetSpellInfo(SPELL_FLASH_FREEZE_COOLDOWN);
  3093.         }
  3094.  
  3095.         //bool Load()
  3096.         //{
  3097.         //    return GetOwner()->ToPlayer();
  3098.         //}
  3099.  
  3100.         void HandleEffectApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
  3101.         {
  3102.             std::list<Unit*> targetList;
  3103.             aurEff->GetTargetList(targetList);
  3104.  
  3105.             for(std::list<Unit*>::iterator iter = targetList.begin(); iter != targetList.end(); ++iter)
  3106.                 if(!(*iter)->ToPlayer() && (*iter)->GetGUID() != GetCasterGUID() )
  3107.                     (*iter)->RemoveAurasDueToSpell(GetSpellInfo()->Id);
  3108.         }
  3109.  
  3110.         void CalculateAmount(AuraEffect const * /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
  3111.         {
  3112.             // Set absorbtion amount to unlimited
  3113.             amount = -1;
  3114.         }
  3115.  
  3116.         void Absorb(AuraEffect * /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
  3117.         {
  3118.             Unit * target = GetTarget();
  3119.             if (dmgInfo.GetDamage() < target->GetHealth())
  3120.                 return;
  3121.  
  3122.             target->CastSpell(target, SPELL_FLASH_FREEZE, true);
  3123.  
  3124.             // absorb hp till 1 hp
  3125.             absorbAmount = dmgInfo.GetDamage() - target->GetHealth() + 1;
  3126.  
  3127.             // Remove Aura from Hodir
  3128.             if(GetCaster() && GetCaster()->ToCreature())
  3129.                 GetCaster()->ToCreature()->RemoveAurasDueToSpell(SPELL_HODIRS_PROTECTIVE_GAZE);
  3130.         }
  3131.  
  3132.         void Register()
  3133.         {
  3134.             DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hodir_protective_gaze_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
  3135.             OnEffectAbsorb += AuraEffectAbsorbFn(spell_hodir_protective_gaze_AuraScript::Absorb, EFFECT_0);
  3136.             OnEffectApply += AuraEffectApplyFn(spell_hodir_protective_gaze_AuraScript::HandleEffectApply, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB, AURA_EFFECT_HANDLE_REAL);
  3137.         }
  3138.     };
  3139.  
  3140.     AuraScript *GetAuraScript() const
  3141.     {
  3142.         return new spell_hodir_protective_gaze_AuraScript();
  3143.     }
  3144. };
  3145.  
  3146. #define GOSSIP_KEEPER_HELP                  "Lend us your aid, keeper. Together we shall defeat Yogg-Saron."
  3147.  
  3148. class npc_keeper_help : public CreatureScript
  3149. {
  3150. public:
  3151.     npc_keeper_help() : CreatureScript("npc_keeper_help") { }
  3152.  
  3153.     bool OnGossipHello(Player* player, Creature* _Creature)
  3154.     {
  3155.         if(InstanceScript* m_pInstance = _Creature->GetInstanceScript())
  3156.         {
  3157.             uint32 supportFlag = m_pInstance->GetData(DATA_KEEPER_SUPPORT_YOGG);
  3158.             switch(_Creature->GetEntry())
  3159.             {
  3160.             case NPC_HELP_KEEPER_FREYA:
  3161.                 if((supportFlag & FREYA_SUPPORT) == FREYA_SUPPORT)
  3162.                     return false;
  3163.                 break;
  3164.             case NPC_HELP_KEEPER_MIMIRON:
  3165.                 if((supportFlag & MIMIRON_SUPPORT) == MIMIRON_SUPPORT)
  3166.                     return false;
  3167.                 break;
  3168.             case NPC_HELP_KEEPER_THORIM:
  3169.                 if((supportFlag & THORIM_SUPPORT) == THORIM_SUPPORT)
  3170.                     return false;
  3171.                 break;
  3172.             case NPC_HELP_KEEPER_HODIR:
  3173.                 if((supportFlag & HODIR_SUPPORT) == HODIR_SUPPORT)
  3174.                     return false;
  3175.                 break;
  3176.             }
  3177.  
  3178.             player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_KEEPER_HELP, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
  3179.             player->SEND_GOSSIP_MENU(player->GetGossipTextId(_Creature), _Creature->GetGUID());
  3180.         }
  3181.         return true;
  3182.     }
  3183.  
  3184.     bool OnGossipSelect(Player* player, Creature* _Creature, uint32 sender, uint32 action)
  3185.     {
  3186.         player->CLOSE_GOSSIP_MENU();
  3187.  
  3188.         InstanceScript* instance = _Creature->GetInstanceScript();
  3189.  
  3190.         if(!instance) return false;
  3191.  
  3192.         if( action == GOSSIP_ACTION_INFO_DEF + 1)
  3193.         {
  3194.             switch(_Creature->GetEntry())
  3195.             {
  3196.             case NPC_HELP_KEEPER_FREYA:
  3197.                 DoScriptText(SAY_FREYA_HELP,_Creature,player);
  3198.                 instance->SetData(DATA_ADD_HELP_FLAG,FREYA_SUPPORT);
  3199.                 break;
  3200.             case NPC_HELP_KEEPER_MIMIRON:
  3201.                 DoScriptText(SAY_MIMIRON_HELP,_Creature,player);
  3202.                 instance->SetData(DATA_ADD_HELP_FLAG,MIMIRON_SUPPORT);
  3203.                 break;
  3204.             case NPC_HELP_KEEPER_THORIM:
  3205.                 DoScriptText(SAY_THORIM_HELP,_Creature,player);
  3206.                 instance->SetData(DATA_ADD_HELP_FLAG,THORIM_SUPPORT);
  3207.                 break;
  3208.             case NPC_HELP_KEEPER_HODIR:
  3209.                 DoScriptText(SAY_HODIR_HELP,_Creature,player);
  3210.                 instance->SetData(DATA_ADD_HELP_FLAG,HODIR_SUPPORT);
  3211.                 break;
  3212.             }
  3213.         }
  3214.  
  3215.         return true;
  3216.     }
  3217.  
  3218.     CreatureAI* GetAI(Creature* pCreature) const
  3219.     {
  3220.         return new npc_keeper_helpAI (pCreature);
  3221.     }
  3222.  
  3223.     struct npc_keeper_helpAI : public Scripted_NoMovementAI
  3224.     {
  3225.         npc_keeper_helpAI(Creature *c) : Scripted_NoMovementAI(c)
  3226.         {
  3227.             m_pInstance = c->GetInstanceScript();
  3228.             me->setFaction(35);
  3229.         }
  3230.  
  3231.         InstanceScript* m_pInstance;
  3232.  
  3233.         void AttackStart(Unit *who) {}
  3234.  
  3235.         void UpdateAI(const uint32 diff)
  3236.         {
  3237.             if(m_pInstance)
  3238.             {
  3239.                 if(m_pInstance->GetBossState(TYPE_YOGGSARON) == IN_PROGRESS)
  3240.                 {
  3241.                     me->SetVisible(false);
  3242.                     return;
  3243.                 }
  3244.  
  3245.                 switch(me->GetEntry())
  3246.                 {
  3247.                 case NPC_HELP_KEEPER_FREYA:
  3248.                     me->SetVisible(m_pInstance->GetBossState(TYPE_FREYA) == DONE);
  3249.                     break;
  3250.                 case NPC_HELP_KEEPER_MIMIRON:
  3251.                     me->SetVisible(m_pInstance->GetBossState(TYPE_MIMIRON) == DONE);
  3252.                     break;
  3253.                 case NPC_HELP_KEEPER_THORIM:
  3254.                     me->SetVisible(m_pInstance->GetBossState(TYPE_THORIM) == DONE);
  3255.                     break;
  3256.                 case NPC_HELP_KEEPER_HODIR:
  3257.                     me->SetVisible(m_pInstance->GetBossState(TYPE_HODIR) == DONE);
  3258.                     break;
  3259.                 }
  3260.             }
  3261.         }
  3262.     };
  3263. };
  3264.  
  3265. class item_unbound_fragments_of_valanyr : public ItemScript
  3266. {
  3267. public:
  3268.     item_unbound_fragments_of_valanyr() : ItemScript("item_unbound_fragments_of_valanyr") { }
  3269.  
  3270.     bool OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& /*targets*/)
  3271.     {
  3272.         if(Creature* yogg = pPlayer->FindNearestCreature(ENTRY_YOGG_SARON,20))
  3273.         {
  3274.             if(yogg->FindCurrentSpellBySpellId(SPELL_DEAFENING_ROAR))
  3275.                 return false;
  3276.         }
  3277.  
  3278.         pPlayer->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW,pItem,NULL);
  3279.         return true;
  3280.     }
  3281. };
  3282.  
  3283. /*
  3284. UPDATE creature_template SET scriptname = 'boss_sara' WHERE entry = 33134;
  3285. UPDATE script_texts SET npc_entry = 33134 WHERE npc_entry = 33288 AND entry IN (-1603330,-1603331,-1603332,-1603333);
  3286. UPDATE script_texts SET content_default = "Help me! Please get them off me!" WHERE npc_entry = 33134 AND entry = -1603310;
  3287. UPDATE script_texts SET content_default = "What do you want from me? Leave me alone!" WHERE npc_entry = 33134 AND entry = -1603311;
  3288. UPDATE `creature_template` SET `InhabitType`=4 WHERE `entry` = 33134;
  3289. UPDATE creature_template SET scriptname = 'npc_ominous_cloud' WHERE entry = 33292;
  3290. UPDATE creature_template SET scriptname = 'npc_guardian_of_yogg_saron' WHERE entry = 33136;
  3291. UPDATE creature_template SET scriptname = 'npc_yogg_saron_tentacle' WHERE entry in (33966,33985,33983);
  3292. UPDATE creature_template SET scriptname = 'npc_descend_into_madness' WHERE entry = 34072;
  3293. UPDATE creature_template SET scriptname = 'npc_brain_of_yogg_saron' WHERE entry = 33890;
  3294. UPDATE creature_template SET scriptname = 'boss_yogg_saron' WHERE entry = 33288;
  3295. UPDATE creature_template SET scriptname = 'npc_influence_tentacle' WHERE entry in (33716,33720,33719,33717,33433,33567);
  3296. UPDATE creature_template SET scriptname = 'npc_immortal_guardian' WHERE entry = 33988;
  3297. UPDATE creature_template SET scriptname = 'npc_support_keeper' WHERE entry in (33410,33411,33412,33413);
  3298. UPDATE creature_template SET scriptname = 'npc_sanity_well' WHERE entry = 33991;
  3299. UPDATE creature_template SET modelid1 = 11686, modelid2 = 11686 WHERE entry = 33991;
  3300. UPDATE creature_template SET scriptname = 'npc_death_orb' WHERE entry = 33882;
  3301. UPDATE creature_template SET modelid1 = 16946, modelid2 = 16946 WHERE entry = 33882;
  3302. UPDATE creature_template SET scriptname = 'npc_death_ray' WHERE entry = 33881;
  3303. UPDATE creature_template SET modelid1 = 17612, modelid2 = 17612 WHERE entry = 33881;
  3304. UPDATE creature_template SET minlevel = 80, maxlevel = 80, scriptname = 'npc_laughting_skull' WHERE entry = 33990;
  3305. UPDATE creature_template SET modelid1 = 15880, modelid2 = 15880 WHERE entry = 33990;
  3306. UPDATE creature_template SET scriptname = 'npc_keeper_help' WHERE entry IN(33241,33244,33242,33213);
  3307. UPDATE `creature_template` SET `minlevel`=80  , `maxlevel`=80 WHERE `entry` = 33943;
  3308.  
  3309. UPDATE gameobject_template SET scriptname = 'go_flee_to_surface' WHERE entry = 194625;
  3310. UPDATE item_template SET scriptname = 'item_unbound_fragments_of_valanyr' WHERE entry = 45896;
  3311.  
  3312. UPDATE creature_template SET RegenHealth = 0 WHERE entry IN (33134,34332,33890,33954);
  3313.  
  3314. -- Secound Damage Effekt of ShadowNova only on other Guardians or Sara
  3315. DELETE FROM conditions WHERE SourceEntry = 65209;
  3316. INSERT INTO conditions
  3317. (SourceTypeOrReferenceId,SourceGroup,SourceEntry,ElseGroup,
  3318.  ConditionTypeOrReference,ConditionValue1,ConditionValue2,ConditionValue3,
  3319.  ErrorTextId,ScriptName,COMMENT)
  3320. VALUES
  3321. (13,0,65209,0,18,1,33136,0,0,'','Effekt only for Guardian of YoggSaron'),
  3322. (13,0,65209,0,18,1,33134,0,0,'','Effekt only for Sara');
  3323.  
  3324. DELETE FROM gameobject WHERE id = 194625;
  3325. INSERT INTO gameobject
  3326. (guid, id, map, spawnMask, phaseMask, position_x, position_y, position_z, orientation, rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state)
  3327. VALUES
  3328. (603001, 194625, 603, 3, 1, 2001.40, -59.66, 245.07, 0, 0, 0, 0, 0, 60, 100, 1),
  3329. (603002, 194625, 603, 3, 1, 1941.61, -25.88, 244.98, 0, 0, 0, 0, 0, 60, 100, 1),
  3330. (603003, 194625, 603, 3, 1, 2001.18,  9.409, 245.24, 0, 0, 0, 0, 0, 60, 100, 1);
  3331.  
  3332. -- Auren shouldnt hit other friendly NPCs
  3333. DELETE FROM spell_script_names WHERE spell_id IN (62670,62671,62702,62650);
  3334. INSERT INTO spell_script_names (spell_id,Scriptname)
  3335. VALUES
  3336. (62670,'spell_keeper_support_aura_targeting'),
  3337. (62671,'spell_keeper_support_aura_targeting'),
  3338. (62702,'spell_keeper_support_aura_targeting'),
  3339. (62650,'spell_keeper_support_aura_targeting');
  3340.  
  3341. -- Script for Target Faces Caster
  3342. DELETE FROM spell_script_names WHERE spell_id IN (64164,64168);
  3343. INSERT INTO spell_script_names (spell_id,Scriptname)
  3344. VALUES
  3345. (64164,'spell_lunatic_gaze_targeting'),
  3346. (64168,'spell_lunatic_gaze_targeting');
  3347.  
  3348. -- Trigger Effekt on Near Player with Brain Link
  3349. DELETE FROM spell_script_names WHERE spell_id IN (63802);
  3350. INSERT INTO spell_script_names (spell_id,Scriptname)
  3351. VALUES
  3352. (63802,'spell_brain_link_periodic_dummy');
  3353.  
  3354. -- Needed for Titanic Storm
  3355. -- Script for Target have Weakened Aura
  3356. DELETE FROM spell_script_names WHERE spell_id IN (64172);
  3357. INSERT INTO spell_script_names (spell_id,Scriptname)
  3358. VALUES
  3359. (64172,'spell_titanic_storm_targeting');
  3360.  
  3361. -- Condition because NPCs need this else no hit
  3362. DELETE FROM conditions WHERE SourceEntry in (64172,64465);
  3363. INSERT INTO conditions
  3364. (SourceTypeOrReferenceId,SourceGroup,SourceEntry,ElseGroup,
  3365.  ConditionTypeOrReference,ConditionValue1,ConditionValue2,ConditionValue3,
  3366.  ErrorTextId,ScriptName,COMMENT)
  3367. VALUES
  3368. (13,0,64172,0,18,1,33988,0,0,'','Effekt only for Immortal Guardians'),
  3369. (13,0,64465,0,18,1,33988,0,0,'','Effekt only for Immortal Guardians');
  3370.  
  3371. -- Hodir Secound Aura Script
  3372. DELETE FROM spell_script_names WHERE spell_id IN (64174);
  3373. INSERT INTO spell_script_names (spell_id,Scriptname)
  3374. VALUES
  3375. (64174,'spell_hodir_protective_gaze');
  3376.  
  3377. -- Insane Death trigger on Remove
  3378. DELETE FROM spell_script_names WHERE spell_id IN (63120);
  3379. INSERT INTO spell_script_names (spell_id,Scriptname)
  3380. VALUES
  3381. (63120,'spell_insane_death_effekt');
  3382.  
  3383. -- Deathray Effekt on Death Orb
  3384. DELETE FROM conditions WHERE SourceEntry IN (63882,63886);
  3385. INSERT INTO conditions
  3386. (SourceTypeOrReferenceId,SourceGroup,SourceEntry,ElseGroup,
  3387.  ConditionTypeOrReference,ConditionValue1,ConditionValue2,ConditionValue3,
  3388.  ErrorTextId,ScriptName,COMMENT)
  3389. VALUES
  3390. (13,0,63882,0,18,1,33882,0,0,'','Effekt on Death Orb'),
  3391. (13,0,63886,0,18,1,33882,0,0,'','Effekt on Death Orb');
  3392.  
  3393. -- Correct Summon Position of Tentacle
  3394. DELETE FROM spell_script_names WHERE spell_id IN (64139,64143,64133);
  3395. INSERT INTO spell_script_names (spell_id,Scriptname)
  3396. VALUES
  3397. (64139,'spell_summon_tentacle_position'),
  3398. (64143,'spell_summon_tentacle_position'),
  3399. (64133,'spell_summon_tentacle_position');
  3400.  
  3401. -- Heal Trigger for Empowering Shadows
  3402. DELETE FROM spell_script_names WHERE spell_id IN (64466);
  3403. INSERT INTO spell_script_names (spell_id,Scriptname)
  3404. VALUES
  3405. (64466,'spell_empowering_shadows');
  3406.  
  3407. -- Create Val'anyr on Yogg-Saron
  3408. DELETE FROM conditions WHERE SourceEntry IN (64184);
  3409. INSERT INTO conditions
  3410. (SourceTypeOrReferenceId,SourceGroup,SourceEntry,ElseGroup,
  3411.  ConditionTypeOrReference,ConditionValue1,ConditionValue2,ConditionValue3,
  3412.  ErrorTextId,ScriptName,COMMENT)
  3413. VALUES
  3414. (13,0,64184,0,18,1,33288,0,0,'','Effekt on YoggSaron');
  3415.  
  3416. -- Missing Says Vision
  3417. DELETE FROM script_texts WHERE entry BETWEEN -1603360 AND -1603342;
  3418. INSERT INTO script_texts (`npc_entry`,`entry`,`content_default`,`sound`,`type`,`language`,`emote`,`comment`)
  3419. VALUES
  3420. (33436,-1603342,'Bad news sire.',15538,0,0,0,'Garona KingLlaneVision_Say1'),
  3421. (33436,-1603343,'The clans are united under Blackhand in this assault. They will stand together until Stormwind has fallen.',15539,0,0,0,'Garona KingLlaneVision_Say2'),
  3422. (33436,-1603344,'Gul\'dan is bringing up his warlocks by nightfall. Until then, the Blackrock clan will be trying to take the Eastern Wall.',15540,0,0,0,'Garona KingLlaneVision_Say3'),
  3423. (33288,-1603345,'A thousand deaths... or one murder.',15762,0,0,0,'YoggSaron KingLlaneVision_Say1'),
  3424. (33288,-1603346,'',15763,0,0,0,'YoggSaron KingLlianeVision_Say2'),
  3425. (33437,-1603347,'We will hold until the reinforcements come. As long as men with stout hearts are manning the walls and throne Stormwind will hold.',15585,0,0,0,'KingLlane KingLlaneVision_Say'),
  3426. (33436,-1603348,'The orc leaders agree with your assessment.',15541,0,0,0,'Garona KingLlaneVision_Say4'),
  3427. (33288,-1603349,'Your petty quarrels only make me stronger!',15764,0,0,0,'YoggSaron KingLlaneVision_Say3'),
  3428.  
  3429. (33441,-1603350,'Your resilience is admirable.',15598,0,0,0,'TheLichKing LichKingVision_Say1'),
  3430. (33442,-1603351,'Arrrrrrgh!',15470,1,0,0,'ImmolatedChampion LichKingVision_Say1'),
  3431. (33442,-1603352,'I\'m not afraid of you!',15471,0,0,0,'ImmolatedChampion LichKingVision_Say2'),
  3432. (33441,-1603353,'I will break you as I broke him.',15599,0,0,0,'TheLichKing LichKingVision_Say2'),
  3433. (33288,-1603354,'Yrr n\'lyeth... shuul anagg!',15766,0,0,0,'YoggSaron LichKingVision_Say1'),
  3434. (33288,-1603355,'He will learn... no king rules forever, only death is eternal!',15767,0,0,0,'YoggSaron LichKingVision_Say2'),
  3435.  
  3436. (33523,-1603356,'It is done... All have been given that which must be given. I now seal the Dragon Soul forever...',15631,0,0,0,'Neltharion DragonSoulVision_Say1'),
  3437. (33495,-1603357,'That terrible glow... should that be?',15702,0,0,0,'Ysera DragonSoulVision_Say'),
  3438. (33523,-1603358,'For it to be as it must, yes.',15632,0,0,0,'Neltharion DragonSoulVision_Say2'),
  3439. (33535,-1603359,'It is a weapon like no other. It must be like no other.',15610,0,0,0,'Malygos DragonSoulVision_Say'),
  3440. (33288,-1603360,'His brood learned their lesson before too long, you shall soon learn yours!',15765,0,0,0,'YoggSaron DragonSoulVision_Say1');
  3441. */
  3442.  
  3443. void AddSC_boss_yoggsaron()
  3444. {
  3445.     new boss_sara();
  3446.     new npc_ominous_cloud();
  3447.     new npc_guardian_of_yogg_saron();
  3448.     new npc_yogg_saron_tentacle();
  3449.     new npc_descend_into_madness();
  3450.     new npc_influence_tentacle();
  3451.     new npc_brain_of_yogg_saron();
  3452.     new boss_yogg_saron();
  3453.     new npc_immortal_guardian();
  3454.     new npc_support_keeper();
  3455.     new npc_sanity_well();
  3456.     new npc_laughting_skull();
  3457.     new npc_death_orb();
  3458.     new npc_death_ray();
  3459.     new npc_keeper_help();
  3460.     new go_flee_to_surface();
  3461.     new item_unbound_fragments_of_valanyr();
  3462.  
  3463.     new spell_keeper_support_aura_targeting();
  3464.     new spell_lunatic_gaze_targeting();
  3465.     new spell_brain_link_periodic_dummy();
  3466.     new spell_titanic_storm_targeting();
  3467.     new spell_insane_death_effekt();
  3468.     new spell_summon_tentacle_position();
  3469.     new spell_empowering_shadows();
  3470.     new spell_hodir_protective_gaze();
  3471. }
Advertisement
Add Comment
Please, Sign In to add comment