Changeset 239

Show
Ignore:
Timestamp:
11/19/08 13:49:43 (17 years ago)
Author:
yumileroy
Message:

[svn] *Update Kalecgos script.
*Correctly select aura triggered spell target.
*Fix some scripts, should be pGOHello = &
*Fix a bug that some channel spells cannot be interrupted.
*Fix a bug that not-selectable creature cannot be hit by target_entry spells.
*If eventAI cannot find heroic flag and normal flag, enable event as default rather than disable it.

Original author: megamage
Date: 2008-11-15 15:09:22-06:00

Location:
trunk
Files:
1 added
11 modified

Legend:

Unmodified
Added
Removed
  • trunk/sql/updates/146_world.sql

    r178 r239  
    1717VALUES 
    1818   (-30410, 44032, 0, 'Manticron Cube Mind Exhaustion'); 
    19  
    20 INSERT INTO spell_linked_spell 
    21    (`spell_trigger`, `spell_effect`, `type`, `comment`) 
    22 VALUES 
    23    (-45934, 7, 0, 'Dark Fiend Suicide'); 
    2419 
    2520INSERT INTO spell_linked_spell 
  • trunk/sql/updates/147_world.sql

    r223 r239  
    1 DELETE FROM spell_linked_spell WHERE `spell_trigger` IN (46648, 46019, 46021, -46021, 46020); 
    2 INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (46648, 44866, 1, 'Spectral Blast'); 
    3 INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (46019, 46021, 1, 'Teleport: Spectral Realm'); 
    4 INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (46021, 44852, 1, 'Spectral Realm Aura'); 
    5 INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (-46021, 46020, 0, 'Teleport: Normal Realm'); 
    6 INSERT INTO spell_linked_spell (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES (46020, 44867, 1, 'Spectral Exhaustion'); 
    7  
    8 DELETE FROM spell_target_position WHERE `id` IN (46019, 46020); 
    9 INSERT INTO spell_target_position () VALUES (46019, 580, 1704.34, 928.17, -74.558, 0); 
    10 INSERT INTO spell_target_position () VALUES (46020, 580, 1704.34, 928.17, 53.079, 0); 
    11  
    121-- Magtheridon Earthquake 
    132DELETE FROM spell_script_target WHERE `entry` IN (30657); 
  • trunk/src/bindings/scripts/scripts/creature/mob_event_ai.cpp

    r229 r239  
    13711371 
    13721372                if (EAI_ErrorLevel > 1) 
    1373                     error_db_log("SD2: Creature %u Event %u. Creature are in instance but neither EFLAG_NORMAL or EFLAG_HEROIC are set. Event Disabled.", _Creature->GetEntry(), (*i).event_id); 
     1373                { 
     1374                    error_db_log("SD2: Creature %u Event %u. Creature are in instance but neither EFLAG_NORMAL or EFLAG_HEROIC are set.", _Creature->GetEntry(), (*i).event_id); 
     1375                    EventList.push_back(EventHolder(*i)); 
     1376                } 
    13741377 
    13751378                continue; 
  • trunk/src/bindings/scripts/scripts/go/go_scripts.cpp

    r90 r239  
    195195    newscript = new Script; 
    196196    newscript->Name="go_tablet_of_madness"; 
    197     newscript->pGOHello =           GOHello_go_tablet_of_madness; 
     197    newscript->pGOHello =           &GOHello_go_tablet_of_madness; 
    198198    m_scripts[nrscripts++] = newscript; 
    199199 
    200200    newscript = new Script; 
    201201    newscript->Name="go_tablet_of_the_seven"; 
    202     newscript->pGOHello =           GOHello_go_tablet_of_the_seven; 
     202    newscript->pGOHello =           &GOHello_go_tablet_of_the_seven; 
    203203    m_scripts[nrscripts++] = newscript; 
    204204 
    205205    newscript = new Script; 
    206206    newscript->Name="go_teleporter"; 
    207     newscript->pGOHello =           GOHello_go_teleporter; 
    208     m_scripts[nrscripts++] = newscript; 
    209 } 
     207    newscript->pGOHello =           &GOHello_go_teleporter; 
     208    m_scripts[nrscripts++] = newscript; 
     209} 
  • trunk/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp

    r203 r239  
    22792279    newscript = new Script; 
    22802280    newscript->Name="mob_cage_trap_trigger"; 
    2281     newscript->GetAI = GetAI_cage_trap_trigger; 
     2281    newscript->GetAI = &GetAI_cage_trap_trigger; 
    22822282    m_scripts[nrscripts++] = newscript; 
    22832283 
  • trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp

    r125 r239  
    194194    newscript = new Script; 
    195195    newscript->Name="go_barrel_old_hillsbrad"; 
    196     newscript->pGOHello = GOHello_go_barrel_old_hillsbrad; 
     196    newscript->pGOHello = &GOHello_go_barrel_old_hillsbrad; 
    197197    m_scripts[nrscripts++] = newscript; 
    198198 
  • trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp

    r90 r239  
    1 /* Copyright ? 2006,2007 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> 
    2  * This program is free software; you can redistribute it and/or modify 
    3  * it under the terms of the GNU General Public License as published by 
    4  * the Free Software Foundation; either version 2 of the License, or 
    5  * (at your option) any later version. 
    6  * 
    7  * This program is distributed in the hope that it will be useful, 
    8  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    10  * GNU General Public License for more details. 
    11  * 
    12  * You should have received a copy of the GNU General Public License 
    13  * along with this program; if not, write to the Free Software 
    14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    15  */ 
     1/* Copyright ?2006,2007 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> 
     2* This program is free software; you can redistribute it and/or modify 
     3* it under the terms of the GNU General Public License as published by 
     4* the Free Software Foundation; either version 2 of the License, or 
     5* (at your option) any later version. 
     6* 
     7* This program is distributed in the hope that it will be useful, 
     8* but WITHOUT ANY WARRANTY; without even the implied warranty of 
     9* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     10* GNU General Public License for more details. 
     11* 
     12* You should have received a copy of the GNU General Public License 
     13* along with this program; if not, write to the Free Software 
     14* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     15*/ 
    1616 
    1717/* ScriptData 
     
    1919SD%Complete: 0 
    2020SDComment: VERIFY SCRIPT 
    21 SDCategory: Sunwell Plateau 
    2221EndScriptData */ 
    2322 
    2423#include "precompiled.h" 
    25 #include "WorldPacket.h" 
    2624#include "def_sunwell_plateau.h" 
    2725 
    28 #define SAY_KALECGOS_AGGRO         "Aggh! No longer will I be a slave to Malygos! Challenge me and you will be destroyed!" 
    29 #define SOUND_KALECGOS_AGGRO       12422 
    30 #define SAY_KALECGOS_SPELL1        "I will purge you!" 
    31 #define SOUND_KALECGOS_SPELL1      12423 
    32 #define SAY_KALECGOS_SPELL2        "Your pain has only begun!" 
    33 #define SOUND_KALECGOS_SPELL2      12424 
    34 #define SAY_KALECGOS_SLAY1         "In the name of Kil'jaeden!" 
    35 #define SOUND_KALECGOS_SLAY1       12425 
    36 #define SAY_KALECGOS_SLAY2         "You were warned!" 
    37 #define SOUND_KALECGOS_SLAY2       12426 
    38 #define SAY_KALECGOS_ENRAGE        "My awakening is complete! You shall all perish!" 
    39 #define SOUND_KALECGOS_ENRAGE      12427 
    40  
    41 #define SAY_SATH_AGGRO             "There will be no reprieve. My work here is nearly finished." 
    42 #define SOUND_SATH_AGGRO           12451 
    43 #define SAY_SATH_DEATH             "I'm... never on... the losing... side..." 
    44 #define SOUND_SATH_DEATH           12452 
    45 #define SAY_SATH_SPELL1            "Your misery is my delight!" 
    46 #define SOUND_SATH_SPELL1          12453 
    47 #define SAY_SATH_SPELL2            "I will watch you bleed!" 
    48 #define SOUND_SATH_SPELL2          12454 
    49 #define SAY_SATH_SLAY1             "Pitious mortal!" 
    50 #define SOUND_SATH_SLAY1           12455 
    51 #define SAY_SATH_SLAY2             "Haven't you heard? I always win!" 
    52 #define SOUND_SATH_SLAY2           12456 
    53 #define SAY_SATH_ENRAGE            "I have toyed with you long enough!" 
    54 #define SOUND_SATH_ENRAGE          12457 
    55  
    56 #define SAY_KALEC_AGGRO            "I need... your help... Cannot... resist him... much longer..." 
    57 #define SOUND_KALEC_AGGRO          12428 
    58 #define SAY_KALEC_NEAR_DEATH       "Aaahhh! Help me, before I lose my mind!" 
    59 #define SOUND_KALEC_NEAR_DEATH     12429 
    60                                                             //??? 
    61 #define SAY_KALEC_NEAR_DEATH2      "Hurry! There is not much of me left!" 
    62 #define SOUND_KALEC_NEAR_DEATH2    12430 
    63 #define SAY_KALEC_PLRWIN           "I am forever in your debt. Once we have triumphed over Kil'jaeden, this entire world will be in your debt as well." 
    64 #define SOUND_KALEC_PLRWIN         12431 
    65  
    66 #define SPELL_SPECTRAL_EXHAUSTION           44867 
    67 #define SPELL_TELEPORT_SPECTRAL_REALM       46019 
    68 #define SPELL_SPECTRAL_REALM                46021 
    69  
    70 #define NOTIFY_SPECTRALLY_EXHAUSTED     "Your body is too exhausted to travel to the Spectral Realm." 
    71 #define ERROR_INST_DATA                 "SD2: Instance Data not set properly for Sunwell Plateau. Kalecgos Encounter will be buggy." 
    72 #define ERROR_INST_DATA_PLR             "SD2 ERROR: Instance Data not set properly for Sunwell Plateau. Please report this to your administrator." 
    73 #define ERROR_UNABLE_TO_TELEPORT        "SD2: Unable to select target for Spectral Blast. Threatlist has too few players." 
    74 #define ERROR_MISSING_TELEPORT_GUID     "SD2: [Kalecgos] Invalid TeleportTargetGUID. Unable to teleport player." 
    75 #define ERROR_KALECGOS_NOT_FOUND        "SD2: Unable to create pointer to Kalecgos from Sathrovarr." 
    76  
    77 #define KALECGOS_ARENA_X        1704.34 
    78 #define KALECGOS_ARENA_Y        928.17 
    79 #define KALECGOS_ARENA_Z        53.08 
    80  
    81 /*** Kalecgos ****/ 
    82 #define SPELL_SPECTRAL_BLAST            44866 
     26#define KALECGOS_SAY_AGGRO             "No longer will I be a slave to Malygos! Challenge me and you will be destroyed!" 
     27#define KALECGOS_SOUND_AGGRO           12422 
     28#define KALECGOS_SAY_SPELL_1           "I will purge you!" 
     29#define KALECGOS_SOUND_SPELL_1         12423 
     30#define KALECGOS_SAY_SPELL_2           "Your pain has only begun!" 
     31#define KALECGOS_SOUND_SPELL_2         12424 
     32#define KALECGOS_SAY_KILL_1            "In the name of Kil'jaeden!" 
     33#define KALECGOS_SOUND_KILL_1          12425 
     34#define KALECGOS_SAY_KILL_2            "You were warned!" 
     35#define KALECGOS_SOUND_KILL_2          12426 
     36#define KALECGOS_SAY_FLY_AWAY          "My awakening is complete! You shall all perish!" 
     37#define KALECGOS_SOUND_FLY_AWAY        12427 
     38#define KALECGOS_SAY_WIN               "I am forever in your debt. Once we have triumphed over Kil'jaeden, this entire world will be in your debt as well." 
     39#define KALECGOS_SOUND_WIN             12431 
     40 
     41#define SATH_SAY_AGGRO           "Gyahaha... There will be no reprieve. My work here is nearly finished." 
     42#define SATH_SOUND_AGGRO         12451 
     43#define SATH_SAY_DIE             "I'm... never on... the losing... side..." 
     44#define SATH_SOUND_DIE           12452 
     45#define SATH_SAY_SPELL_1         "Your misery is my delight!" 
     46#define SATH_SOUND_SPELL_1       12453 
     47#define SATH_SAY_SPELL_2         "I will watch you bleed!" 
     48#define SATH_SOUND_SPELL_2       12454 
     49#define SATH_SAY_KILL_1          "Pitious mortal!" 
     50#define SATH_SOUND_KILL_1        12455 
     51#define SATH_SAY_KILL_2          "Haven't you heard? I always win!" 
     52#define SATH_SOUND_KILL_2        12456 
     53#define SATH_SAY_ENRAGE          "I have toyed with you long enough!" 
     54#define SATH_SOUND_ENRAGE        12457 
     55 
     56#define KALEC_SAY_AGGRO         "I need... your help... Cannot... resist him... much longer..." 
     57#define KALEC_SOUND_AGGRO       12428 
     58#define KALEC_SAY_LOSING1       "Aaahhh! Help me, before I lose my mind!" 
     59#define KALEC_SOUND_LOSING1     12429 
     60#define KALEC_SAY_LOSING2       "Hurry! There is not much of me left!" //??? 
     61#define KALEC_SOUND_LOSING2     12430 
     62 
     63#define GO_FAILED               "You are unable to use this currently." 
     64 
     65#define FLY_X       1679 
     66#define FLY_Y       900 
     67#define FLY_Z       82 
     68 
     69#define CENTER_X    1705 
     70#define CENTER_Y    930 
     71#define RADIUS      30 
     72 
     73#define AURA_SUNWELL_RADIANCE           45769 
     74#define AURA_SPECTRAL_EXHAUSTION        44867 
     75#define AURA_SPECTRAL_REALM             46021 
     76#define AURA_SPECTRAL_INVISIBILITY      44801 
     77#define AURA_DEMONIC_VISUAL             44800 
     78 
     79#define SPELL_SPECTRAL_BLAST            44869 
     80#define SPELL_TELEPORT_SPECTRAL         46019 
    8381#define SPELL_ARCANE_BUFFET             45018 
    8482#define SPELL_FROST_BREATH              44799 
     83#define SPELL_TAIL_LASH                 45122 
     84 
     85#define SPELL_BANISH                    44836 
     86#define SPELL_TRANSFORM_KALEC           44670 
     87#define SPELL_ENRAGE                    44807 
     88 
     89#define SPELL_CORRUPTION_STRIKE         45029 
     90#define SPELL_AGONY_CURSE               45032 
     91#define SPELL_SHADOW_BOLT               45031 
     92 
    8593#define SPELL_HEROIC_STRIKE             45026 
    8694#define SPELL_REVITALIZE                45027 
    87 #define SPELL_TAIL_LASH                 45122 
    88 #define SPELL_TRANSFORM_KALEC           45027 
    89 #define SPELL_CRAZED_RAGE               44806 
     95 
     96#define MOB_KALECGOS    24850 
     97#define MOB_KALEC       24891 
     98#define MOB_SATHROVARR  24892 
     99 
     100#define DRAGON_REALM_Z  53.079 
     101#define DEMON_REALM_Z   -74.558 
     102 
    90103uint32 WildMagic[]= { 44978, 45001, 45002, 45004, 45006, 45010 }; 
    91104 
    92 /*** Sathrovarr ***/ 
    93 #define SPELL_CORRUPTING_STRIKE         45029 
    94 #define SPELL_CURSE_OF_BOUNDLESS_AGONY  45032 
    95 #define SPELL_SHADOW_BOLT_VOLLEY        45031 
    96  
    97 /*** Misc ***/ 
    98 #define SPELL_BANISH                    44836 
    99  
    100 void TeleportToInnerVeil(Player* plr) 
    101 { 
    102     if(plr->HasAura(SPELL_SPECTRAL_EXHAUSTION, 0)) 
    103     { 
    104         plr->GetSession()->SendNotification(NOTIFY_SPECTRALLY_EXHAUSTED); 
    105         return; 
    106     } 
    107  
    108     ScriptedInstance* pInstance = ((ScriptedInstance*)plr->GetInstanceData()); 
    109     if(!pInstance) 
    110     { 
    111         error_log(ERROR_INST_DATA); 
    112         plr->GetSession()->SendNotification(ERROR_INST_DATA_PLR); 
    113         return; 
    114     } 
    115  
    116     pInstance->SetData64(DATA_PLAYER_SPECTRAL_REALM, plr->GetGUID()); 
    117     // Remove the player from Kalecgos' Threat List 
    118     Creature* Kalecgos = ((Creature*)Unit::GetUnit(*plr, pInstance->GetData64(DATA_KALECGOS_DRAGON))); 
    119     if(Kalecgos) 
    120     { 
    121         HostilReference* ref = Kalecgos->getThreatManager().getOnlineContainer().getReferenceByTarget(plr); 
    122         if(ref) 
    123             ref->removeReference(); 
    124     } 
    125  
    126     // Add the player to Sathrovarr's Threat List 
    127     Creature* Sathrovarr = ((Creature*)Unit::GetUnit(*plr, pInstance->GetData64(DATA_SATHROVARR))); 
    128     if(Sathrovarr) 
    129         Sathrovarr->AddThreat(plr, 1.0f); 
    130  
    131     // Make them able to see Sathrovarr (he's invisible for some reason). Also, when this buff wears off, they get teleported back to Normal Realm (this is handled by Instance Script) 
    132     plr->CastSpell(plr, SPELL_SPECTRAL_REALM, true); 
    133     plr->CastSpell(plr, SPELL_TELEPORT_SPECTRAL_REALM, true); 
    134 } 
    135  
    136 bool GOHello_GO_Spectral_Portal(Player* plr, GameObject* go) 
    137 { 
    138     TeleportToInnerVeil(plr); 
    139  
    140     return true; 
    141 } 
    142105 
    143106struct TRINITY_DLL_DECL boss_kalecgosAI : public ScriptedAI 
    144107{ 
    145     boss_kalecgosAI(Creature* c) : ScriptedAI(c) 
     108    boss_kalecgosAI(Creature *c) : ScriptedAI(c)  
    146109    { 
    147110        pInstance = ((ScriptedInstance*)c->GetInstanceData()); 
     111        SathGUID = 0; 
     112        DoorGUID = 0; 
    148113        Reset(); 
    149114    } 
    150115 
    151     ScriptedInstance* pInstance; 
    152  
    153     uint64 TeleportTargetGUID; 
     116    ScriptedInstance *pInstance; 
    154117 
    155118    uint32 ArcaneBuffetTimer; 
     
    157120    uint32 WildMagicTimer; 
    158121    uint32 SpectralBlastTimer; 
    159     uint32 SpectralTeleportTimer; 
    160     uint32 ForceFieldTimer; 
    161     uint32 ExitTimer; 
    162  
    163     bool LockedArena; 
    164     bool Uncorrupted; 
    165     bool Banished; 
    166     bool Checked; 
    167     bool Enraged; 
     122    uint32 TailLashTimer; 
     123    uint32 CheckTimer; 
     124    uint32 TalkTimer; 
     125    uint32 TalkSequence; 
     126 
     127    bool isFriendly; 
     128    bool isEnraged; 
     129    bool isBanished; 
     130 
     131    uint64 SathGUID; 
     132    uint64 DoorGUID; 
    168133 
    169134    void Reset() 
    170135    { 
    171         TeleportTargetGUID = 0; 
    172  
    173         // TODO: Fix timers 
    174         ArcaneBuffetTimer       = 8000; 
    175         FrostBreathTimer        = 24000; 
    176         WildMagicTimer          = 18000; 
    177         SpectralBlastTimer      = 30000; 
    178         SpectralTeleportTimer   = SpectralBlastTimer + 2000; 
    179  
    180         ForceFieldTimer = 20000; 
    181         ExitTimer = 0; 
    182  
    183         LockedArena = false; 
    184         Uncorrupted = false; 
    185         Banished    = false; 
    186         Checked     = false; 
    187         Enraged     = false; 
    188  
    189         // Reset Sathrovarr too 
    190136        if(pInstance) 
    191             if(Creature* Sath = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SATHROVARR)))) 
    192                 Sath->AI()->EnterEvadeMode(); 
     137        { 
     138            uint64 SathGUID = pInstance->GetData64(DATA_SATHROVARR); 
     139            uint64 DoorGUID = pInstance->GetData64(DATA_GO_FORCEFIELD); 
     140        } 
     141 
     142        Unit *Sath = Unit::GetUnit(*m_creature,SathGUID); 
     143        if(Sath) ((Creature*)Sath)->AI()->EnterEvadeMode(); 
     144 
     145        GameObject *Door = GameObject::GetGameObject(*m_creature, DoorGUID); 
     146        if(Door) Door->SetLootState(GO_JUST_DEACTIVATED); 
     147 
     148        m_creature->setFaction(14); 
     149        m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); 
     150        m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); 
     151        m_creature->SetVisibility(VISIBILITY_ON); 
     152        m_creature->SetStandState(PLAYER_STATE_SLEEP); 
     153 
     154        ArcaneBuffetTimer = 8000; 
     155        FrostBreathTimer = 15000; 
     156        WildMagicTimer = 10000; 
     157        TailLashTimer = 25000; 
     158        SpectralBlastTimer = 20000+(rand()%5000); 
     159        CheckTimer = SpectralBlastTimer+20000; //after spectral blast 
     160 
     161        TalkTimer = 0; 
     162        TalkSequence = 0; 
     163        isFriendly = false; 
     164        isEnraged = false; 
     165        isBanished = false; 
     166        //m_creature->CastSpell(m_creature, AURA_SUNWELL_RADIANCE, true); 
     167    } 
     168 
     169    void DamageTaken(Unit *done_by, uint32 &damage) 
     170    { 
     171        if(damage >= m_creature->GetHealth() && done_by != m_creature) 
     172            damage = 0; 
    193173    } 
    194174 
    195175    void Aggro(Unit* who) 
    196176    { 
    197         DoYell(SAY_KALECGOS_AGGRO, LANG_UNIVERSAL, NULL); 
    198         DoPlaySoundToSet(m_creature, SOUND_KALECGOS_AGGRO); 
    199  
     177        m_creature->SetStandState(PLAYER_STATE_NONE); 
     178        DoYell(KALECGOS_SAY_AGGRO, LANG_UNIVERSAL,NULL); 
     179        DoPlaySoundToSet(m_creature, KALECGOS_SOUND_AGGRO); 
     180        GameObject *Door = GameObject::GetGameObject(*m_creature, DoorGUID); 
     181        if(Door) Door->SetLootState(GO_ACTIVATED); 
     182        DoZoneInCombat(); 
     183    } 
     184 
     185    void KilledUnit(Unit *victim) 
     186    { 
     187        switch(rand()%2) 
     188        { 
     189        case 0: 
     190            DoYell(KALECGOS_SAY_KILL_1,LANG_UNIVERSAL,NULL); 
     191            DoPlaySoundToSet(m_creature,KALECGOS_SOUND_KILL_1); 
     192            break; 
     193        case 1: 
     194            DoYell(KALECGOS_SAY_KILL_2,LANG_UNIVERSAL,NULL); 
     195            DoPlaySoundToSet(m_creature,KALECGOS_SOUND_KILL_2); 
     196            break; 
     197        } 
     198    } 
     199 
     200    void MovementInform(uint32 type,uint32 id) 
     201    { 
     202        m_creature->SetVisibility(VISIBILITY_OFF); 
     203        if(isFriendly) 
     204            m_creature->setDeathState(JUST_DIED); 
     205        else 
     206        { 
     207            m_creature->GetMotionMaster()->MoveTargetedHome(); 
     208            TalkTimer = 30000; 
     209        } 
     210    } 
     211 
     212    void GoodEnding() 
     213    { 
     214        switch(TalkSequence) 
     215        { 
     216        case 1: 
     217            m_creature->setFaction(35); 
     218            DoCast(m_creature, SPELL_TRANSFORM_KALEC); 
     219            TalkTimer = 1000; 
     220            break; 
     221        case 2: 
     222            DoSay(KALECGOS_SAY_WIN, LANG_UNIVERSAL,NULL); 
     223            DoPlaySoundToSet(m_creature, KALECGOS_SOUND_WIN); 
     224            TalkTimer = 10000; 
     225            break; 
     226        case 3: 
     227            m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); 
     228            m_creature->GetMotionMaster()->Clear(); 
     229            m_creature->GetMotionMaster()->MovePoint(0,FLY_X,FLY_Y,FLY_Z); 
     230            TalkTimer = 600000; 
     231            break; 
     232        default: 
     233            break; 
     234        } 
     235    } 
     236 
     237    void BadEnding() 
     238    { 
     239        switch(TalkSequence) 
     240        { 
     241        case 1: 
     242            DoYell(KALECGOS_SAY_FLY_AWAY,LANG_UNIVERSAL,NULL); 
     243            DoPlaySoundToSet(m_creature,KALECGOS_SOUND_FLY_AWAY); 
     244            TalkTimer = 3000; 
     245            break; 
     246        case 2: 
     247            m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); 
     248            m_creature->GetMotionMaster()->Clear(); 
     249            m_creature->GetMotionMaster()->MovePoint(0,FLY_X,FLY_Y,FLY_Z); 
     250            TalkTimer = 600000; 
     251            break; 
     252        case 3: 
     253            EnterEvadeMode(); 
     254            break; 
     255        default: 
     256            break; 
     257        } 
     258    } 
     259 
     260    void UpdateAI(const uint32 diff); 
     261}; 
     262 
     263struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI 
     264{ 
     265    boss_sathrovarrAI(Creature *c) : ScriptedAI(c)  
     266    { 
     267        pInstance = ((ScriptedInstance*)c->GetInstanceData()); 
     268        KalecGUID = 0; 
     269        KalecgosGUID = 0; 
     270        Reset(); 
     271    } 
     272 
     273    ScriptedInstance *pInstance; 
     274 
     275    uint32 CorruptionStrikeTimer; 
     276    uint32 AgonyCurseTimer; 
     277    uint32 ShadowBoltTimer; 
     278    uint32 CheckTimer; 
     279 
     280    uint64 KalecGUID; 
     281    uint64 KalecgosGUID; 
     282 
     283    bool isEnraged; 
     284    bool isBanished; 
     285 
     286    void Reset() 
     287    { 
    200288        if(pInstance) 
    201             pInstance->SetData(DATA_KALECGOS_EVENT, IN_PROGRESS); 
    202     } 
    203  
    204     void DamageTaken(Unit* done_by, uint32 &damage) 
    205     { 
    206         if(damage > m_creature->GetHealth() && done_by != m_creature) 
    207         { 
    208             if(!Uncorrupted) 
     289            KalecgosGUID = pInstance->GetData64(DATA_KALECGOS_DRAGON); 
     290 
     291        if(KalecGUID) 
     292        { 
     293            if(Unit* Kalec = Unit::GetUnit(*m_creature, KalecGUID)) 
     294                Kalec->setDeathState(JUST_DIED); 
     295            KalecGUID = 0; 
     296        } 
     297 
     298        ShadowBoltTimer = 7000 + rand()%3 * 1000; 
     299        AgonyCurseTimer = 20000; 
     300        CorruptionStrikeTimer = 13000; 
     301        CheckTimer = 1000; 
     302        isEnraged = false; 
     303        isBanished = false; 
     304        //m_creature->CastSpell(m_creature, AURA_SPECTRAL_INVISIBILITY, true); 
     305        //m_creature->CastSpell(m_creature, AURA_SUNWELL_RADIANCE, true); 
     306        //m_creature->CastSpell(m_creature, AURA_DEMONIC_VISUAL, true); 
     307    } 
     308 
     309    void Aggro(Unit* who) 
     310    { 
     311        Creature *Kalec = m_creature->SummonCreature(MOB_KALEC, m_creature->GetPositionX() + 10, m_creature->GetPositionY() + 5, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); 
     312        if(Kalec) 
     313        { 
     314            KalecGUID = Kalec->GetGUID(); 
     315            m_creature->CombatStart(Kalec); 
     316            m_creature->AddThreat(Kalec, 100.0f); 
     317        } 
     318        DoYell(SATH_SAY_AGGRO, LANG_UNIVERSAL, NULL); 
     319        DoPlaySoundToSet(m_creature, SATH_SOUND_AGGRO); 
     320    } 
     321 
     322    void DamageTaken(Unit *done_by, uint32 &damage) 
     323    { 
     324        if(damage >= m_creature->GetHealth() && done_by != m_creature) 
     325            damage = 0; 
     326    } 
     327 
     328    void KilledUnit(Unit *target) 
     329    { 
     330        if(target->GetGUID() == KalecGUID) 
     331        { 
     332            TeleportAllPlayersBack(); 
     333            if(Unit *Kalecgos = Unit::GetUnit(*m_creature, KalecgosGUID)) 
    209334            { 
    210                 damage = 0; 
    211                 Banished = true; 
    212                 DoCast(m_creature, SPELL_BANISH, true); 
    213                 m_creature->GetMotionMaster()->MoveIdle(); 
     335                ((boss_kalecgosAI*)((Creature*)Kalecgos)->AI())->TalkTimer = 1; 
     336                ((boss_kalecgosAI*)((Creature*)Kalecgos)->AI())->isFriendly = false; 
    214337            } 
    215             else 
     338            EnterEvadeMode(); 
     339            return; 
     340        } 
     341        switch(rand()%2) 
     342        { 
     343        case 0: 
     344            DoYell(SATH_SAY_KILL_1,LANG_UNIVERSAL,NULL); 
     345            DoPlaySoundToSet(m_creature,SATH_SOUND_KILL_1); 
     346            break; 
     347        case 1: 
     348            DoYell(SATH_SAY_KILL_2,LANG_UNIVERSAL,NULL); 
     349            DoPlaySoundToSet(m_creature,SATH_SOUND_KILL_2); 
     350            break; 
     351        } 
     352    } 
     353 
     354    void JustDied(Unit *victim) 
     355    { 
     356        DoYell(SATH_SAY_DIE, LANG_UNIVERSAL, NULL); 
     357        DoPlaySoundToSet(m_creature, SATH_SOUND_DIE); 
     358        m_creature->Relocate(m_creature->GetPositionX(), m_creature->GetPositionY(), DRAGON_REALM_Z, m_creature->GetOrientation()); 
     359        TeleportAllPlayersBack(); 
     360        if(Unit *Kalecgos = Unit::GetUnit(*m_creature, KalecgosGUID)) 
     361        { 
     362            ((boss_kalecgosAI*)((Creature*)Kalecgos)->AI())->TalkTimer = 1; 
     363            ((boss_kalecgosAI*)((Creature*)Kalecgos)->AI())->isFriendly = true; 
     364        } 
     365    } 
     366 
     367    void TeleportAllPlayersBack() 
     368    { 
     369        Map *map = m_creature->GetMap(); 
     370        if(!map->IsDungeon()) return; 
     371        InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
     372        InstanceMap::PlayerList::const_iterator i; 
     373        for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     374        { 
     375            if((*i)->HasAura(AURA_SPECTRAL_REALM,0)) 
     376                (*i)->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM); 
     377        } 
     378    } 
     379 
     380    void Enrage(); // demon and dragon should enrage at the same time 
     381 
     382    void UpdateAI(const uint32 diff) 
     383    { 
     384        if (!m_creature->SelectHostilTarget() && !m_creature->getVictim()) 
     385            return;      
     386 
     387        if(CheckTimer < diff) 
     388        { 
     389            if(!isEnraged && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 10) 
     390                Enrage(); 
     391 
     392            if(!isBanished && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 1) 
    216393            { 
    217                 damage = 0; 
    218                 BeginOutro(); 
     394                if(Unit *Kalecgos = Unit::GetUnit(*m_creature, KalecgosGUID)) 
     395                { 
     396                    if(((boss_kalecgosAI*)((Creature*)Kalecgos)->AI())->isBanished) 
     397                    { 
     398                        m_creature->setDeathState(JUST_DIED); 
     399                        return; 
     400                    } 
     401                    else 
     402                    { 
     403                        m_creature->CastSpell(m_creature, SPELL_BANISH, true); 
     404                        isBanished = true; 
     405                    } 
     406                } 
     407                else 
     408                { 
     409                    DoTextEmote("is unable to find Kalecgos", NULL); 
     410                    EnterEvadeMode(); 
     411                } 
    219412            } 
    220         } 
    221     } 
    222  
    223     void KilledUnit(Unit* victim) 
    224     { 
    225         switch(rand()%2) 
    226         { 
     413            CheckTimer = 1000; 
     414        }else CheckTimer -= diff; 
     415 
     416        if(ShadowBoltTimer < diff) 
     417        { 
     418            DoCast(m_creature, SPELL_SHADOW_BOLT); 
     419            ShadowBoltTimer = 7000+(rand()%3000); 
     420        }else ShadowBoltTimer -= diff; 
     421 
     422        if(AgonyCurseTimer < diff) 
     423        { 
     424            Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0); 
     425            if(!target) target = m_creature->getVictim(); 
     426            DoCast(target, SPELL_AGONY_CURSE); 
     427            AgonyCurseTimer = 20000; 
     428        }else AgonyCurseTimer -= diff; 
     429 
     430        if(CorruptionStrikeTimer < diff) 
     431        { 
     432            DoCast(m_creature->getVictim(), SPELL_CORRUPTION_STRIKE); 
     433            CorruptionStrikeTimer = 13000; 
     434        }else CorruptionStrikeTimer -= diff; 
     435 
     436        DoMeleeAttackIfReady();  
     437    } 
     438}; 
     439 
     440struct TRINITY_DLL_DECL boss_kalecAI : public ScriptedAI 
     441{ 
     442    ScriptedInstance *pInstance; 
     443 
     444    uint32 RevitalizeTimer; 
     445    uint32 HeroicStrikeTimer; 
     446    uint32 YellTimer; 
     447    uint32 YellSequence; 
     448 
     449    uint64 SathGUID; 
     450 
     451    bool isEnraged; // if demon is enraged 
     452 
     453    boss_kalecAI(Creature *c) : ScriptedAI(c) 
     454    { 
     455        pInstance = ((ScriptedInstance*)c->GetInstanceData()); 
     456        Reset(); 
     457    } 
     458 
     459    void Reset() 
     460    {            
     461        if(pInstance) 
     462            SathGUID = pInstance->GetData64(DATA_SATHROVARR); 
     463 
     464        RevitalizeTimer = 5000; 
     465        HeroicStrikeTimer = 3000; 
     466        YellTimer = 5000; 
     467        YellSequence = 0; 
     468 
     469        isEnraged = false; 
     470 
     471        //m_creature->CastSpell(m_creature, AURA_SPECTRAL_INVISIBILITY, true); 
     472        //m_creature->CastSpell(m_creature, AURA_SUNWELL_RADIANCE, true); 
     473    } 
     474 
     475    void Aggro(Unit* who) {} 
     476 
     477    void DamageTaken(Unit *done_by, uint32 &damage) 
     478    { 
     479        if(done_by->GetGUID() != SathGUID) 
     480            damage = 0; 
     481        else if(isEnraged) 
     482            damage *= 3; 
     483    } 
     484 
     485    void UpdateAI(const uint32 diff) 
     486    { 
     487        if(!m_creature->getVictim()) // only victim is Sath 
     488        { 
     489            EnterEvadeMode(); 
     490            return; 
     491        } 
     492 
     493        if(YellTimer < diff) 
     494        { 
     495            switch(YellSequence) 
     496            { 
    227497            case 0: 
    228                 DoYell(SAY_KALECGOS_SLAY1,LANG_UNIVERSAL,NULL); 
    229                 DoPlaySoundToSet(m_creature,SOUND_KALECGOS_SLAY1); 
     498                DoYell(KALEC_SAY_AGGRO, LANG_UNIVERSAL, NULL); 
     499                DoPlaySoundToSet(m_creature, KALEC_SOUND_AGGRO); 
     500                YellSequence++; 
    230501                break; 
    231502            case 1: 
    232                 DoYell(SAY_KALECGOS_SLAY2,LANG_UNIVERSAL,NULL); 
    233                 DoPlaySoundToSet(m_creature,SOUND_KALECGOS_SLAY2); 
     503                if((m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 50) 
     504                { 
     505                    DoYell(KALEC_SAY_LOSING1, LANG_UNIVERSAL, NULL); 
     506                    DoPlaySoundToSet(m_creature, KALEC_SOUND_LOSING1); 
     507                    YellSequence++; 
     508                } 
    234509                break; 
    235         } 
    236     } 
    237  
    238     void BeginOutro() 
    239     { 
    240         debug_log("SD2: KALEC: Beginning Outro"); 
    241  
    242         if(!pInstance) 
    243         { 
    244             error_log(ERROR_INST_DATA); 
     510            case 2: 
     511                if((m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 10) 
     512                { 
     513                    DoYell(KALEC_SAY_LOSING2, LANG_UNIVERSAL, NULL); 
     514                    DoPlaySoundToSet(m_creature, KALEC_SOUND_LOSING2); 
     515                    YellSequence++; 
     516                } 
     517                break; 
     518            default: 
     519                break; 
     520            } 
     521            YellTimer = 5000; 
     522        } 
     523 
     524        if(RevitalizeTimer < diff) 
     525        { 
     526            DoCast(m_creature, SPELL_REVITALIZE); 
     527            RevitalizeTimer = 5000; 
     528        }else RevitalizeTimer -= diff; 
     529 
     530        if(HeroicStrikeTimer < diff) 
     531        { 
     532            DoCast(m_creature->getVictim(), SPELL_HEROIC_STRIKE); 
     533            HeroicStrikeTimer = 2000; 
     534        }else HeroicStrikeTimer -= diff; 
     535 
     536        DoMeleeAttackIfReady(); 
     537    } 
     538}; 
     539 
     540void boss_kalecgosAI::UpdateAI(const uint32 diff) 
     541{ 
     542    if(TalkTimer) 
     543    { 
     544        if(!TalkSequence) 
     545        { 
     546            m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); 
     547            m_creature->InterruptNonMeleeSpells(true); 
     548            m_creature->RemoveAllAuras(); 
     549            m_creature->DeleteThreatList(); 
     550            m_creature->CombatStop(); 
     551            GameObject *Door = GameObject::GetGameObject(*m_creature, DoorGUID); 
     552            if(Door) Door->SetLootState(GO_JUST_DEACTIVATED); 
     553            TalkSequence++; 
     554        } 
     555        if(TalkTimer <= diff) 
     556        { 
     557            if(isFriendly) 
     558                GoodEnding(); 
     559            else 
     560                BadEnding(); 
     561            TalkSequence++; 
     562        }else TalkTimer -= diff; 
     563    } 
     564    else 
     565    { 
     566        if (!m_creature->SelectHostilTarget() && !m_creature->getVictim()) 
    245567            return; 
    246         } 
    247  
    248         Unit* Sathrovarr = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SATHROVARR)); 
    249         if(Sathrovarr) 
    250         { 
    251             Sathrovarr->DealDamage(Sathrovarr, Sathrovarr->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); 
    252  
    253             Sathrovarr->Relocate(KALECGOS_ARENA_X, KALECGOS_ARENA_Y, KALECGOS_ARENA_Z); 
    254             Sathrovarr->SendMonsterMove(KALECGOS_ARENA_X, KALECGOS_ARENA_Y, KALECGOS_ARENA_Z, 0, 0, 0); 
    255         } 
    256  
    257         Creature* Kalec = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KALECGOS_HUMAN))); 
    258         if(Kalec) 
    259         { 
    260             Kalec->DeleteThreatList(); 
    261             Kalec->SetVisibility(VISIBILITY_OFF); 
    262         } 
    263  
    264         m_creature->GetMotionMaster()->MoveIdle(); 
    265         m_creature->setFaction(35); 
    266     } 
    267  
    268     void MovementInform(uint32 type, uint32 id) 
    269     { 
    270         if(type != POINT_MOTION_TYPE) 
    271             return; 
    272  
    273         if(id) 
    274         { 
    275             if(pInstance) 
     568 
     569        if(CheckTimer < diff) 
     570        { 
     571            if(!isEnraged && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 10) 
    276572            { 
    277                 GameObject* ForceField = GameObject::GetGameObject(*m_creature, pInstance->GetData64(DATA_GO_FORCEFIELD)); 
    278                 if(ForceField) 
    279                     ForceField->SetGoState(1); 
    280  
    281                 pInstance->SetData(DATA_KALECGOS_EVENT, DONE); 
     573                if(Unit *Sath = Unit::GetUnit(*m_creature, SathGUID)) 
     574                    ((boss_sathrovarrAI*)((Creature*)Sath)->AI())->Enrage(); 
    282575            } 
    283             else error_log(ERROR_INST_DATA); 
    284  
    285             m_creature->SetVisibility(VISIBILITY_OFF); 
    286             m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); 
    287         } 
    288     } 
    289  
    290     void UpdateAI(const uint32 diff) 
    291     { 
    292         if(!m_creature->getVictim() || !m_creature->SelectHostilTarget() || Banished) 
    293             return; 
    294  
    295         if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !Enraged) 
    296         { 
    297             Unit* Sathrovarr = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SATHROVARR)); 
    298             if(Sathrovarr) 
    299                 Sathrovarr->CastSpell(Sathrovarr, SPELL_CRAZED_RAGE, true); 
    300             DoCast(m_creature, SPELL_CRAZED_RAGE, true); 
    301             Enraged = true; 
    302         } 
    303  
    304         if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 1) && !Checked) 
    305         { 
    306             Checked = true; 
    307  
    308             if(!Uncorrupted) 
     576 
     577            if(!isBanished && (m_creature->GetHealth()*100)/m_creature->GetMaxHealth() < 1) 
    309578            { 
    310                 Banished = true; 
    311                 DoCast(m_creature, SPELL_BANISH, true); 
    312                 m_creature->GetMotionMaster()->MoveIdle(); 
     579                if(Unit *Sath = Unit::GetUnit(*m_creature, SathGUID)) 
     580                { 
     581                    if(((boss_sathrovarrAI*)((Creature*)Sath)->AI())->isBanished) 
     582                        Sath->setDeathState(JUST_DIED); 
     583                    else 
     584                    { 
     585                        m_creature->CastSpell(m_creature, SPELL_BANISH, true); 
     586                        isBanished = true; 
     587                    } 
     588                } 
     589                else  
     590                { 
     591                    DoTextEmote("is unable to find Sath", NULL); 
     592                    EnterEvadeMode(); 
     593                } 
    313594            } 
    314             else 
    315                 BeginOutro(); 
    316         } 
    317  
    318         if(ExitTimer) 
    319             if(ExitTimer <= diff) 
    320         { 
    321             debug_log("SD2: KALEC: Exiting the arena"); 
    322             DoYell(SAY_KALEC_PLRWIN, LANG_UNIVERSAL, NULL); 
    323             DoPlaySoundToSet(m_creature, SOUND_KALEC_PLRWIN); 
    324             m_creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT + MOVEMENTFLAG_LEVITATING); 
    325             float x, y, z; 
    326             float iniX, iniY, iniZ; 
    327             m_creature->GetPosition(iniX, iniY, iniZ); 
    328             m_creature->GetRandomPoint(iniX, iniY, iniZ, 30, x, y, z); 
    329             z = 70; 
    330             m_creature->GetMotionMaster()->MovePoint(1, x, y, z); 
    331         }else ExitTimer -= diff; 
    332  
    333         if(!LockedArena) 
    334             if(ForceFieldTimer < diff) 
    335         { 
    336             if(pInstance) 
    337             { 
    338                 GameObject* ForceField = GameObject::GetGameObject((*m_creature), pInstance->GetData64(DATA_GO_FORCEFIELD)); 
    339                 if(ForceField) 
    340                     ForceField->SetUInt32Value(GAMEOBJECT_STATE, 0); 
    341  
    342                 LockedArena = true; 
    343             }else error_log(ERROR_INST_DATA); 
    344         }else ForceFieldTimer -= diff; 
     595            CheckTimer = 1000; //every 1 sec we check this 
     596        }else CheckTimer -= diff; 
    345597 
    346598        if(ArcaneBuffetTimer < diff) 
    347599        { 
    348             if(rand()%3 == 0) 
    349             { 
    350                 DoYell(SAY_KALECGOS_SPELL1, LANG_UNIVERSAL, NULL); 
    351                 DoPlaySoundToSet(m_creature, SOUND_KALECGOS_SPELL1); 
    352             } 
    353600            DoCast(m_creature->getVictim(), SPELL_ARCANE_BUFFET); 
    354             ArcaneBuffetTimer = 20000; 
     601            ArcaneBuffetTimer = 8000; 
    355602        }else ArcaneBuffetTimer -= diff; 
    356603 
    357604        if(FrostBreathTimer < diff) 
    358605        { 
    359             if(rand()%2 == 0) 
    360             { 
    361                 DoYell(SAY_KALECGOS_SPELL2, LANG_UNIVERSAL, NULL); 
    362                 DoPlaySoundToSet(m_creature, SOUND_KALECGOS_SPELL2); 
    363             } 
    364606            DoCast(m_creature->getVictim(), SPELL_FROST_BREATH); 
    365             FrostBreathTimer = 25000; 
     607            FrostBreathTimer = 15000; 
    366608        }else FrostBreathTimer -= diff; 
    367609 
     610        if(TailLashTimer < diff) 
     611        { 
     612            DoCast(m_creature->getVictim(), SPELL_TAIL_LASH); 
     613            TailLashTimer = 15000; 
     614        }else TailLashTimer -= diff; 
     615 
    368616        if(WildMagicTimer < diff) 
    369617        { 
    370             DoCast(m_creature->getVictim(), WildMagic[rand()%6]); 
    371             WildMagicTimer = 19000; 
     618            DoCast(m_creature, WildMagic[rand()%6]); 
     619            WildMagicTimer = 20000; 
    372620        }else WildMagicTimer -= diff; 
    373621 
    374622        if(SpectralBlastTimer < diff) 
    375623        { 
    376             if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1)) 
    377             { 
    378                 TeleportTargetGUID = target->GetGUID(); 
    379                 m_creature->SetUInt64Value(UNIT_FIELD_TARGET, TeleportTargetGUID); 
    380                 SpectralBlastTimer = 30000; 
    381                 SpectralTeleportTimer = 2000; 
    382             } 
     624            m_creature->CastSpell(m_creature, SPELL_SPECTRAL_BLAST, true); 
     625            SpectralBlastTimer = 20000+(rand()%5000); 
    383626        }else SpectralBlastTimer -= diff; 
    384627 
    385         if(SpectralTeleportTimer < diff) 
    386         { 
    387             if(TeleportTargetGUID) 
    388             { 
    389                 Unit* pUnit = Unit::GetUnit((*m_creature), TeleportTargetGUID); 
    390                 if(pUnit) 
    391                 { 
    392                     pUnit->CastSpell(pUnit, SPELL_SPECTRAL_BLAST, true); 
    393                     TeleportToInnerVeil((Player*)pUnit); 
    394                 } 
    395                 else error_log(ERROR_MISSING_TELEPORT_GUID); 
    396             } 
    397             else error_log(ERROR_MISSING_TELEPORT_GUID); 
    398  
    399             m_creature->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->getVictim()->GetGUID()); 
    400             TeleportTargetGUID = 0; 
    401             SpectralTeleportTimer = SpectralBlastTimer + 2000; 
    402  
    403         }else SpectralTeleportTimer -= diff; 
    404  
    405         if(!Banished) DoMeleeAttackIfReady(); 
    406     } 
    407 }; 
    408  
    409 struct TRINITY_DLL_DECL boss_sathrovarrAI : public ScriptedAI 
    410 { 
    411     boss_sathrovarrAI(Creature* c) : ScriptedAI(c) 
    412     { 
    413         pInstance = ((ScriptedInstance*)c->GetInstanceData()); 
    414         Reset(); 
    415     } 
    416  
    417     ScriptedInstance* pInstance; 
    418  
    419     uint32 CorruptingStrikeTimer; 
    420     uint32 CurseOfBoundlessAgonyTimer; 
    421     uint32 ShadowBoltVolleyTimer; 
    422     bool Banished; 
    423     bool Enraged; 
    424  
    425     void Reset() 
    426     { 
    427         // FIXME: Timers 
    428         CorruptingStrikeTimer = 5000; 
    429         CurseOfBoundlessAgonyTimer = 15000; 
    430         ShadowBoltVolleyTimer = 10000; 
    431  
    432         Banished = false; 
    433         Enraged  = false; 
    434  
    435         DoCast(m_creature, SPELL_SPECTRAL_REALM, true); 
    436     } 
    437  
    438     void Aggro(Unit* who) 
    439     { 
    440         DoYell(SAY_SATH_AGGRO, LANG_UNIVERSAL, NULL); 
    441         DoPlaySoundToSet(m_creature, SOUND_SATH_AGGRO); 
    442  
    443         Creature* Kalec = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KALECGOS_HUMAN))); 
    444         if(Kalec) 
    445         { 
    446             m_creature->AddThreat(Kalec, 10000000.0f); 
    447             Kalec->AddThreat(m_creature, 10000000.0f); 
    448         } 
    449     } 
    450  
    451     void DamageTaken(Unit* done_by, uint32 &damage) 
    452     { 
    453         if(damage > m_creature->GetHealth()) 
    454         { 
    455             damage = 0; 
    456             DoCast(m_creature, SPELL_BANISH, true); 
    457             Banished = true; 
    458  
    459             DoYell(SAY_SATH_DEATH, LANG_UNIVERSAL, NULL); 
    460             DoPlaySoundToSet(m_creature, SOUND_SATH_DEATH); 
    461  
    462             if(!pInstance) 
    463             { 
    464                 error_log(ERROR_INST_DATA); 
    465                 return; 
    466             } 
    467  
    468             pInstance->SetData(DATA_SET_SPECTRAL_CHECK, 5000); 
    469  
    470             Creature* Kalecgos = ((Creature*)Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_KALECGOS_DRAGON))); 
    471             if(Kalecgos) 
    472             { 
    473                 ((boss_kalecgosAI*)Kalecgos->AI())->Checked = false; 
    474                 ((boss_kalecgosAI*)Kalecgos->AI())->Uncorrupted = true; 
    475             } 
    476             else error_log(ERROR_KALECGOS_NOT_FOUND); 
    477         } 
    478     } 
    479  
    480     void KilledUnit(Unit* victim) 
    481     { 
    482         switch(rand()%2) 
    483         { 
    484             case 0: 
    485                 DoYell(SAY_SATH_SLAY1,LANG_UNIVERSAL,NULL); 
    486                 DoPlaySoundToSet(m_creature,SOUND_SATH_SLAY1); 
    487                 break; 
    488             case 1: 
    489                 DoYell(SAY_SATH_SLAY2,LANG_UNIVERSAL,NULL); 
    490                 DoPlaySoundToSet(m_creature,SOUND_SATH_SLAY2); 
    491                 break; 
    492         } 
    493     } 
    494  
    495     void UpdateAI(const uint32 diff) 
    496     { 
    497         if(!m_creature->getVictim() || !m_creature->SelectHostilTarget() || Banished) 
    498             return; 
    499  
    500         if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !Enraged) 
    501         { 
    502             Unit* Kalecgos = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_KALECGOS_DRAGON)); 
    503             if(Kalecgos) 
    504                 Kalecgos->CastSpell(Kalecgos, SPELL_CRAZED_RAGE, true); 
    505             DoCast(m_creature, SPELL_CRAZED_RAGE, true); 
    506             Enraged = true; 
    507         } 
    508  
    509         if(CorruptingStrikeTimer < diff) 
    510         { 
    511             if(rand()%2 == 0) 
    512             { 
    513                 DoYell(SAY_SATH_SPELL2, LANG_UNIVERSAL, NULL); 
    514                 DoPlaySoundToSet(m_creature, SOUND_SATH_SPELL2); 
    515             } 
    516             DoCast(m_creature->getVictim(), SPELL_CORRUPTING_STRIKE); 
    517             CorruptingStrikeTimer = 13000; 
    518         }else CorruptingStrikeTimer -= diff; 
    519  
    520         if(CurseOfBoundlessAgonyTimer < diff) 
    521         { 
    522             DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_CURSE_OF_BOUNDLESS_AGONY); 
    523             CurseOfBoundlessAgonyTimer = 35000; 
    524             DoCast(m_creature, SPELL_SPECTRAL_REALM, true); 
    525         }else CurseOfBoundlessAgonyTimer -= diff; 
    526  
    527         if(ShadowBoltVolleyTimer < diff) 
    528         { 
    529             if(rand()%2 == 0) 
    530             { 
    531                 DoYell(SAY_SATH_SPELL1, LANG_UNIVERSAL, NULL); 
    532                 DoPlaySoundToSet(m_creature, SOUND_SATH_SPELL1); 
    533             } 
    534             DoCast(m_creature->getVictim(), SPELL_SHADOW_BOLT_VOLLEY); 
    535             ShadowBoltVolleyTimer = 15000; 
    536         }else ShadowBoltVolleyTimer -= diff; 
    537  
    538628        DoMeleeAttackIfReady(); 
    539629    } 
    540 }; 
    541  
    542 struct TRINITY_DLL_DECL boss_kalecAI : public ScriptedAI 
    543 { 
    544     boss_kalecAI(Creature* c) : ScriptedAI(c) 
    545     { 
    546         pInstance = ((ScriptedInstance*)c->GetInstanceData()); 
    547         Reset(); 
    548     } 
    549  
    550     ScriptedInstance *pInstance; 
    551  
    552     uint32 RevitalizeTimer; 
    553     uint32 HeroicStrikeTimer; 
    554  
    555     bool HasYelled10Percent; 
    556     bool HasYelled20Percent; 
    557  
    558     void Reset() 
    559     { 
    560         //TODO: Times! 
    561         RevitalizeTimer = 30000; 
    562         HeroicStrikeTimer = 8000; 
    563  
    564         HasYelled10Percent = false; 
    565         HasYelled20Percent = false; 
    566  
    567         DoCast(m_creature, SPELL_SPECTRAL_REALM, true); 
    568     } 
    569  
    570     void Aggro(Unit* who) 
    571     { 
    572         DoYell(SAY_KALEC_AGGRO, LANG_UNIVERSAL, NULL); 
    573         DoPlaySoundToSet(m_creature, SOUND_KALEC_AGGRO); 
    574     } 
    575  
    576     void JustDied(Unit* killer) 
    577     { 
    578         // Whatever happens when Kalec (Half-elf) dies 
    579     } 
    580  
    581     void UpdateAI(const uint32 diff) 
    582     { 
    583         if(!m_creature->getVictim() || !m_creature->SelectHostilTarget()) 
    584             return; 
    585  
    586         if(RevitalizeTimer < diff) 
    587         { 
    588             if(pInstance) 
    589             { 
    590                 Unit* pUnit = Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_RANDOM_SPECTRAL_PLAYER)); 
    591                 if(pUnit) 
    592                     DoCast(pUnit, SPELL_REVITALIZE); 
    593                 RevitalizeTimer = 30000; 
    594             } 
    595         }else RevitalizeTimer -= diff; 
    596  
    597         if(HeroicStrikeTimer < diff) 
    598         { 
    599             DoCast(m_creature->getVictim(), SPELL_HEROIC_STRIKE); 
    600             HeroicStrikeTimer = 30000; 
    601         }else HeroicStrikeTimer -= diff; 
    602  
    603         if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 20) && !HasYelled20Percent) 
    604         { 
    605             DoYell(SAY_KALEC_NEAR_DEATH, LANG_UNIVERSAL, NULL); 
    606             DoPlaySoundToSet(m_creature, SOUND_KALEC_NEAR_DEATH); 
    607             HasYelled20Percent = true; 
    608         } 
    609  
    610         if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 10) && !HasYelled10Percent) 
    611         { 
    612             DoYell(SAY_KALEC_NEAR_DEATH2, LANG_UNIVERSAL, NULL); 
    613             DoPlaySoundToSet(m_creature, SOUND_KALEC_NEAR_DEATH2); 
    614             HasYelled10Percent = true; 
    615         } 
    616     } 
    617 }; 
    618  
    619 CreatureAI* GetAI_boss_kalecgos(Creature* c) 
    620 { 
    621     return new boss_kalecgosAI(c); 
    622630} 
    623631 
    624 CreatureAI* GetAI_boss_sathrovarr(Creature* c) 
    625 { 
    626     return new boss_sathrovarrAI(c); 
     632void boss_sathrovarrAI::Enrage() 
     633{ 
     634    Unit *Kalecgos = Unit::GetUnit(*m_creature, KalecgosGUID); 
     635    Unit *Kalec = Unit::GetUnit(*m_creature, KalecGUID); 
     636    if(!Kalecgos) 
     637    { 
     638        error_log("SD2 ERROR: unable to find Kalecgos"); 
     639        return; 
     640    } 
     641    if(!Kalec) 
     642    { 
     643        error_log("SD2 ERROR: unable to find Kalec"); 
     644        return; 
     645    } 
     646    DoYell(SATH_SAY_ENRAGE,LANG_UNIVERSAL,NULL); 
     647    m_creature->CastSpell(m_creature, SPELL_ENRAGE, true); 
     648    Kalecgos->CastSpell(Kalecgos, SPELL_ENRAGE, true); 
     649    isEnraged = true; 
     650    ((boss_kalecgosAI*)((Creature*)Kalecgos)->AI())->isEnraged = true; 
     651    ((boss_kalecAI*)((Creature*)Kalec)->AI())->isEnraged = true; 
    627652} 
    628653 
    629 CreatureAI* GetAI_boss_kalec(Creature* c) 
    630 { 
    631     return new boss_kalecAI(c); 
     654bool GOkalocegos_teleporter(Player *player, GameObject* _GO) 
     655{ 
     656    if(player->HasAura(AURA_SPECTRAL_EXHAUSTION, 0)) 
     657        player->GetSession()->SendNotification(GO_FAILED); 
     658    else 
     659        player->CastSpell(player, SPELL_TELEPORT_SPECTRAL, true); 
     660    return true; 
    632661} 
    633662 
     663CreatureAI* GetAI_boss_kalecgos(Creature *_Creature) 
     664{ 
     665    return new boss_kalecgosAI (_Creature); 
     666} 
     667 
     668CreatureAI* GetAI_boss_Sathrovarr(Creature *_Creature) 
     669{ 
     670    return new boss_sathrovarrAI (_Creature); 
     671} 
     672 
     673CreatureAI* GetAI_boss_kalec(Creature *_Creature) 
     674{ 
     675    return new boss_kalecAI (_Creature); 
     676} 
     677 
    634678void AddSC_boss_kalecgos() 
    635679{ 
    636     Script* newscript; 
    637  
     680    Script *newscript; 
    638681    newscript = new Script; 
     682    newscript->Name="boss_kalecgos"; 
    639683    newscript->GetAI = GetAI_boss_kalecgos; 
    640     newscript->Name = "boss_kalecgos"; 
    641684    m_scripts[nrscripts++] = newscript; 
    642685 
    643686    newscript = new Script; 
    644     newscript->GetAI = GetAI_boss_sathrovarr; 
    645     newscript->Name = "boss_sathrovarr"; 
     687    newscript->Name="boss_sathrovarr"; 
     688    newscript->GetAI = GetAI_boss_Sathrovarr; 
    646689    m_scripts[nrscripts++] = newscript; 
    647690 
    648691    newscript = new Script; 
     692    newscript->Name="boss_kalec"; 
    649693    newscript->GetAI = GetAI_boss_kalec; 
    650     newscript->Name = "boss_kalec"; 
    651694    m_scripts[nrscripts++] = newscript; 
    652695 
    653696    newscript = new Script; 
    654     newscript->pGOHello = GOHello_GO_Spectral_Portal; 
    655     newscript->Name = "go_spectral_portal"; 
     697    newscript->Name="kalocegos_teleporter"; 
     698    newscript->pGOHello = &GOkalocegos_teleporter; 
    656699    m_scripts[nrscripts++] = newscript; 
    657700} 
  • trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/def_sunwell_plateau.h

    r90 r239  
    3737 
    3838/*** Misc ***/ 
    39 #define DATA_PLAYER_SPECTRAL_REALM  24 
    40 #define DATA_SET_SPECTRAL_CHECK     25 
    41 #define DATA_RANDOM_SPECTRAL_PLAYER 26 
    42 #define DATA_INST_EJECT_PLAYERS     27 
    4339#endif 
  • trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp

    r90 r239  
    1414 
    1515#define ENCOUNTERS 6 
    16  
    17 #define SPELL_SPECTRAL_REALM        46021 
    18 #define SPELL_TELEPORT_NORMAL_REALM 46020 
    19 #define SPELL_SPECTRAL_EXHAUSTION   44867 
    2016 
    2117/* Sunwell Plateau: 
     
    159155            case DATA_KILJAEDEN_CONTROLLER: return KilJaedenController; break; 
    160156            case DATA_ANVEENA:              return Anveena;             break; 
     157        } 
    161158 
    162             case DATA_RANDOM_SPECTRAL_PLAYER: 
    163                 return *(SpectralRealmList.begin() + rand()%SpectralRealmList.size()); 
    164                 break; 
    165         } 
    166159        return 0; 
    167160    } 
     
    177170            case DATA_MURU_EVENT:          Encounters[4] = data; break; 
    178171            case DATA_KILJAEDEN_EVENT:     Encounters[5] = data; break; 
    179  
    180             case DATA_SET_SPECTRAL_CHECK:  SpectralRealmTimer = data; break; 
    181             case DATA_INST_EJECT_PLAYERS:  EjectPlayers(); break; 
    182172        } 
    183173    } 
     
    185175    void SetData64(uint32 id, uint64 guid) 
    186176    { 
    187         switch(id) 
    188         { 
    189             case DATA_PLAYER_SPECTRAL_REALM: 
    190                 SpectralRealmList.push_back(guid); 
    191                 break; 
    192         } 
    193     } 
    194  
    195     // Dirty Hack as we can't use Unit::GetUnit in instance scripts due to lack of a WorldObject. 
    196     Player* DirtyHackToGetPlayerFromSpectralList(uint64 guid) 
    197     { 
    198         Player* first = ((InstanceMap*)instance)->GetPlayers().front(); 
    199         if(!first) 
    200             return NULL; 
    201  
    202         Player* plr = ((Player*)Unit::GetUnit(*first, guid)); 
    203         if(plr) 
    204             return plr; 
    205  
    206         return NULL; 
    207     } 
    208  
    209     void EjectPlayer(Player* plr) 
    210     { 
    211         debug_log("SD2: INST: Ejecting Player %s from Spectral Realm", plr->GetName()); 
    212         // Remove player from Sathrovarr's threat list 
    213         Creature* Sath = ((Creature*)Unit::GetUnit(*plr, Sathrovarr)); 
    214         if(Sath && Sath->isAlive()) 
    215         { 
    216             HostilReference* ref = Sath->getThreatManager().getOnlineContainer().getReferenceByTarget(plr); 
    217             if(ref) 
    218             { 
    219                 ref->removeReference(); 
    220                 debug_log("SD2: INST: Deleting %s from Sathrovarr's threatlist", plr->GetName()); 
    221             } 
    222         } 
    223  
    224         // Put player back in Kalecgos(Dragon)'s threat list 
    225         Creature* Kalecgos = ((Creature*)Unit::GetUnit(*plr, Kalecgos_Dragon)); 
    226         if(Kalecgos && Kalecgos->isAlive()) 
    227         { 
    228             debug_log("SD2: INST: Putting %s in Kalecgos' threatlist", plr->GetName()); 
    229             Kalecgos->AddThreat(plr, 1.0f); 
    230         } 
    231  
    232         plr->CastSpell(plr, SPELL_TELEPORT_NORMAL_REALM, true); 
    233         plr->CastSpell(plr, SPELL_SPECTRAL_EXHAUSTION, true); 
    234     } 
    235  
    236     void EjectPlayers() 
    237     { 
    238         for(uint8 i = 0; i < SpectralRealmList.size(); ++i) 
    239         { 
    240             Player* plr = DirtyHackToGetPlayerFromSpectralList(SpectralRealmList[i]); 
    241             if(plr && !plr->HasAura(SPELL_SPECTRAL_REALM, 0)) 
    242             { 
    243                 EjectPlayer(plr); 
    244                 SpectralRealmList.erase(SpectralRealmList.begin() + i); 
    245             } 
    246         } 
    247  
    248         SpectralRealmList.clear(); 
    249177    } 
    250178 
    251179    void Update(uint32 diff) 
    252180    { 
    253         // Only check for Spectral Realm if Kalecgos Encounter is running 
    254         if(Encounters[0] == IN_PROGRESS) 
    255             if(SpectralRealmTimer < diff) 
    256         { 
    257             EjectPlayers(); 
    258             SpectralRealmTimer = 5000; 
    259         }else SpectralRealmTimer -= diff; 
    260181    } 
    261182}; 
  • trunk/src/game/Spell.cpp

    r236 r239  
    49294929        // unselectable targets skipped in all cases except TARGET_SCRIPT targeting 
    49304930        // in case TARGET_SCRIPT target selected by server always and can't be cheated 
    4931         if( target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) && 
     4931        /*if( target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) && 
    49324932            m_spellInfo->EffectImplicitTargetA[eff] != TARGET_SCRIPT && 
    49334933            m_spellInfo->EffectImplicitTargetB[eff] != TARGET_SCRIPT ) 
    4934             return false; 
     4934            return false;*/ 
    49354935    } 
    49364936 
  • trunk/src/game/Unit.cpp

    r236 r239  
    498498    // interrupt channeled spell 
    499499    if(Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) 
    500         if(spell->getState() == SPELL_STATE_CASTING && (spell->m_spellInfo->AuraInterruptFlags & flag)) 
     500        if(spell->getState() == SPELL_STATE_CASTING && (spell->m_spellInfo->ChannelInterruptFlags & flag)) 
    501501            InterruptNonMeleeSpells(false); 
    502502} 
     
    512512    if(Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) 
    513513        if(spell->getState() == SPELL_STATE_CASTING) 
    514             m_interruptMask |= spell->m_spellInfo->AuraInterruptFlags; 
     514            m_interruptMask |= spell->m_spellInfo->ChannelInterruptFlags; 
    515515} 
    516516