All pastes #715771 Raw Edit

Lady Vashj by Palmik v0.2

public cpp v1 · immutable
#715771 ·published 2007-09-26 13:38 UTC
rendered paste body
/**|||||||||||||||||||||||||*||                     ||*||  UNDER DEVELOPMENT  ||*||                     ||*|||||||||||||||||||||||||*/#include "../../../sc_defines.h"//Spells#define SPELL_SHOCK_BLAST            38509#define SPELL_STATIC_CHARGE          38280            // 38281#define SPELL_ENTANGLE               38316#define SPELL_SHOOT                  38372#define SPELL_MULTYSHOT              38310#define SPELL_FORKED_LIGHTING        38145#define SPELL_DMG_INCREASE           0//NPCs#define NPC_SPORE_BAT                22140#define NPC_STRIDER                  22056#define NPC_NAGA                     0#define NPC_ENCHANTED_ELEMENTAL      21958#define NPC_TAINTED_ELEMENTAL        22009//Yells#define SAY_AGGRO1                   "I'll split you from stem to stern!"#define SAY_AGGRO2                   "Victory to Lord Illidan!"#define SAY_AGGRO3                   "I spit on you, surface filth!"#define SAY_AGGRO4                   "Death to the outsiders!"#define SAY_PHASE1                   "I did not wish to lower myself by engaging your kind, but you leave me little choice!"#define SAY_PHASE2                   "The time is now! Leave none standing!"#define SAY_PHASE3                   "You may want to take cover."#define SAY_SHOOT1                   "Straight to the heart!"#define SAY_SHOOT2                   "Seek your mark!"#define SAY_KILLEDUNIT1              "Your time ends now!"#define SAY_KILLEDUNIT2              "You have failed!"#define SAY_JUSTDIED                 "Lord Illidan, I... I am... sorry."//Sounds#define SOUND_AGGRO1                 11532#define SOUND_AGGRO2                 11533#define SOUND_AGGRO3                 11534#define SOUND_AGGRO4                 11535#define SOUND_PHASE1                 11538#define SOUND_PHASE2                 11539#define SOUND_PHASE3                 11540#define SOUND_SHOOT1                 11536#define SOUND_SHOOT2                 11537#define SOUND_KILLEDUNIT1            11541#define SOUND_KILLEDUNIT2            11542#define SOUND_KILLEDUNIT3            11543#define SOUND_JUSTDIED               11544//Enchanted Elemental move location (because it is in the middle of the "ring" i can use one loc.)#define ELE_X        30#define ELE_Y        -923,4#define ELE_Z        43 struct MANGOS_DLL_DECL boss_lady_vashjAI : public ScriptedAI{    boss_lady_vashjAI(Creature *c) : ScriptedAI(c) {EnterEvadeMode();}     bool InCombat;    bool Tainted_Elemental;    int Phase;    float ElementPos[7][2];    ElementPos[0][3] = {8.3, -835.3, 21.9, 5}    ElementPos[1][3] = {53.4, -835.3, 21.9, 4.5}    ElementPos[2][3] = {96, -861.9, 21.8, 4}    ElementPos[3][3] = {96, 986.4, 21.4, 2.5}    ElementPos[4][3] = {54.4, -1010.6, 22, 1.8}    ElementPos[5][3] = {9.8, -1012, 21.7, 1.4}    ElementPos[6][3] = {-35, -987.6, 21.5, 0.8}    ElementPos[7][3] = {-58.9, -901.6, 21.5, 6}    uint32 StaticCharge_Timer;    uint32 ForkedLighting_Timer;    uint32 ShockBlast_Timer;    uint32 Strider_Timer;    uint32 Naga_Timer;    uint32 EnchantedElemental_Timer;    uint32 TaintedElemental_Timer;     void EnterEvadeMode()    {        InCombat = false;        Phase = 1;                StaticCharge_Timer = 10000;        ForkedLighting_Timer = 4000;        ShockBlast_Timer = 1+rand()%60000;        Strider_Timer = 60000;        Naga_Timer = 45000;        EnchantedElemental_Timer = 5000;        TaintedElemental_Timer = 50000;         m_creature->RemoveAllAuras();        m_creature->DeleteThreatList();        m_creature->CombatStop();        DoGoHome();        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_DISARM, true);        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, true);        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_INTERRUPTED, true);        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_DAZED, true);        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_FEAR, true);        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_SILENCE, true);        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_CHARM, true);        m_creature->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_ROOT, true);    }     void AttackStart(Unit *who)    {        if (!who)            return;         if (who->isTargetableForAttack() && who!= m_creature)        {            //Begin melee attack if we are within range            if (!m_creature->IsWithinDistInMap(who, ATTACK_DISTANCE))            DoStartMeleeAttack(who);             InCombat = true;        }    }     void MoveInLineOfSight(Unit *who)    {        if (!who || m_creature->getVictim())            return;         if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who))        {            float attackRadius = m_creature->GetAttackDistance(who);            if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who))            {                if(who->HasStealthAura())                    who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);                 //Begin melee attack if we are within range                if (!m_creature->IsWithinDistInMap(who, ATTACK_DISTANCE))                DoStartMeleeAttack(who);                if (!m_creature->IsWithinDistInMap(who, ATTACK_DISTANCE))                {                    IsSelfRooted = true;                }                 InCombat = true;                if (who->GetTypeId() == TYPEID_PLAYER)                {                    switch (rand()%4)                    {                        case 0:                            DoYell(SAY_AGGRO1,LANG_UNIVERSAL,NULL);                            DoPlaySoundToSet(m_creature,SOUND_AGGRO1);                        break;                        case 1:                            DoYell(SAY_AGGRO2,LANG_UNIVERSAL,NULL);                            DoPlaySoundToSet(m_creature,SOUND_AGGRO2);                        break;                        case 2:                            DoYell(SAY_AGGRO3,LANG_UNIVERSAL,NULL);                            DoPlaySoundToSet(m_creature,SOUND_AGGRO3);                        break;                                                case 3:                            DoYell(SAY_AGGRO4,LANG_UNIVERSAL,NULL);                            DoPlaySoundToSet(m_creature,SOUND_AGGRO4);                        break;                    }                }            }        }    }    void KilledUnit(Unit *victim)    {        switch(rand()%1)        {            case 0:                DoYell(SAY_KILLEDUNIT1,LANG_UNIVERSAL,NULL);                DoPlaySoundToSet(m_creature,SOUND_KILLEDUNIT1);            break;            case 1:                DoYell(SAY_KILLEDUNIT2,LANG_UNIVERSAL,NULL);                DoPlaySoundToSet(m_creature,SOUND_KILLEDUNIT2);            break;        }    }    void JustDied(Unit* Killer)    {        DoYell(SAY_JUSTDIED,LANG_UNIVERSAL,NULL);        DoPlaySoundToSet(m_creature,SOUND_JUSTDIED);    }     void UpdateAI(const uint32 diff)        {            //Return since we have no target        if (!m_creature->SelectHostilTarget())            return;            //Check if we have a current target        if( m_creature->getVictim() && m_creature->isAlive())                 //If we are within range melee the target            if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))                {                    //Make sure our attack is ready and we aren't currently casting                if(m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))                {                    if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 100) && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 70))                    {                        Phase = 1;                    }                    else if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 70) && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 50))                    {                        Phase = 2;                    }                    else                    {                        Phase = 3;                    }                    switch(Phase)                    {                        //Have to discover more info                        case 1:                        {                            DoYell(SAY_PHASE1,LANG_UNIVERSAL,NULL);                            DoPlaySoundToSet(m_creature,SOUND_PHASE1);                            if (StaticCharge_Timer < diff)                            {                                Unit* target = NULL;                                target = SelectUnit(SELECT_TARGET_RANDOM,0);                                if(target)                                {                                    DoCast(target,SPELL_STATIC_CHARGE);                                    StaticCharge_Timer = 10000;                                }                                else                                {                                        DoCast(m_creature->getVictim(),SPELL_STATIC_CHARGE);                                    StaticCharge_Timer = 10000;                                }                            }                            else StaticCharge_Timer -= diff;                            //Shock blast with random CD                            if (ShockBlast_Timer < diff)                            {                                   Unit* target = NULL;                                Unit* target = SelectUnit(SELECT_TARGET_TOP_AGGRO,0);                                DoCast(target,SPELL_SHOCK_BLAST);                                Unit* target = NULL;                                Unit* target = SelectUnit(SELECT_TARGET_TOP_AGGRO,1);                                m_creature->TauntApply(target);                                ShockBlast_Timer = 1+rand()%60000;                            }                            else ShockBlast_Timer -= diff;                        }                                            case 1:                        {                            //Reseting Timers                            ForkedLighting_Timer = 4000;                            Strider_Timer = 60000;                            Naga_Timer = 45000;                            EnchantedElemental_Timer = 5000;                            TaintedElemental_Timer = 50000;                            DoYell(SAY_PHASE2,LANG_UNIVERSAL,NULL);                            DoPlaySoundToSet(m_creature,SOUND_PHASE2);                            if (ForkedLighting_Timer < diff)                            {                                Unit* target = NULL;                                target = SelectUnit(SELECT_TARGET_RANDOM,0);                                if(target)                                {                                    DoCast(target,SPELL_FORKED_LIGHTING);                                    ForkedLighting_Timer = 4000;                                }                                else                                {                                        DoCast(m_creature->getVictim(),SPELL_FORKED_LIGHTING);                                    ForkedLighting_Timer = 4000;                                }                            }                            else ForkedLighting_Timer -= diff;                            if (Strider_Timer < diff)                            {                                /*How many?*/                                Creature *Strider;                                Strider = m_creature->SummonCreature(NPC_STRIDER,0,0,0,0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                /*have to discover loc*/                                Strider_Timer = 60000;                            }                            else Strider_Timer -= diff;                            if (Naga_Timer < diff)                            {                                /*How many?*/                                Creature *Naga;                                Naga = m_creature->SummonCreature(NPC_NAGA,0,0,0,0,TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                /*have to discover loc*/                                Naga_Timer = 45000;                            }                            else Naga_Timer -= diff;                            if (EnchantedElemental_Timer < diff)                            {                                Creature *Ench_Elemental;                                Ench_Elemental = m_creature->SummonCreature(NPC_ENCHANTED_ELEMENTAL,ElementPos[0][0],ElementPos[0][1],ElementPos[0][2],ElementPos[0][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                Ench_Elemental = m_creature->SummonCreature(NPC_ENCHANTED_ELEMENTAL,ElementPos[1][0],ElementPos[1][1],ElementPos[1][2],ElementPos[1][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                Ench_Elemental = m_creature->SummonCreature(NPC_ENCHANTED_ELEMENTAL,ElementPos[2][0],ElementPos[2][1],ElementPos[2][2],ElementPos[2][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                Ench_Elemental = m_creature->SummonCreature(NPC_ENCHANTED_ELEMENTAL,ElementPos[3][0],ElementPos[3][1],ElementPos[3][2],ElementPos[3][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                Ench_Elemental = m_creature->SummonCreature(NPC_ENCHANTED_ELEMENTAL,ElementPos[4][0],ElementPos[4][1],ElementPos[4][2],ElementPos[4][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                Ench_Elemental = m_creature->SummonCreature(NPC_ENCHANTED_ELEMENTAL,ElementPos[5][0],ElementPos[5][1],ElementPos[5][2],ElementPos[5][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                Ench_Elemental = m_creature->SummonCreature(NPC_ENCHANTED_ELEMENTAL,ElementPos[6][0],ElementPos[6][1],ElementPos[6][2],ElementPos[6][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                Ench_Elemental = m_creature->SummonCreature(NPC_ENCHANTED_ELEMENTAL,ElementPos[7][0],ElementPos[7][1],ElementPos[7][2],ElementPos[7][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                                                EnchantedElemental_Timer = 50000;                                if ((Ench_Elemental->GetPositionX() == ELE_X) && (Ench_Elemental->GetPositionY() == ELE_Y) && (Ench_Elemental->GetPositionZ() == ELE_Z))                                {                                    0; /*dmg increase*/                                }                            }                            else EnchantedElemental_Timer -= diff;                            if ((TaintedElemental_Timer < diff) && (!Tainted_Elemental))                            {                                Tainted_Elemental = true;                                Creature *Tain_Elemental;                                switch (rand()%8)                                {                                case 0:                                        Tain_Elemental = m_creature->SummonCreature(NPC_TAINTED_ELEMENTAL,ElementPos[0][0],ElementPos[0][1],ElementPos[0][2],ElementPos[0][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                break;                                case 1:                                        Tain_Elemental = m_creature->SummonCreature(NPC_TAINTED_ELEMENTAL,ElementPos[1][0],ElementPos[1][1],ElementPos[1][2],ElementPos[1][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                break;                                case 2:                                        Tain_Elemental = m_creature->SummonCreature(NPC_TAINTED_ELEMENTAL,ElementPos[2][0],ElementPos[2][1],ElementPos[2][2],ElementPos[2][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                break;                                case 3:                                        Tain_Elemental = m_creature->SummonCreature(NPC_TAINTED_ELEMENTAL,ElementPos[3][0],ElementPos[3][1],ElementPos[3][2],ElementPos[3][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                break;                                case 4:                                        Tain_Elemental = m_creature->SummonCreature(NPC_TAINTED_ELEMENTAL,ElementPos[4][0],ElementPos[4][1],ElementPos[4][2],ElementPos[4][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                break;                                case 5:                                        Tain_Elemental = m_creature->SummonCreature(NPC_TAINTED_ELEMENTAL,ElementPos[5][0],ElementPos[5][1],ElementPos[5][2],ElementPos[5][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                break;                                case 6:                                        Tain_Elemental = m_creature->SummonCreature(NPC_TAINTED_ELEMENTAL,ElementPos[6][0],ElementPos[6][1],ElementPos[6][2],ElementPos[6][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                break;                                case 7:                                        Tain_Elemental = m_creature->SummonCreature(NPC_TAINTED_ELEMENTAL,ElementPos[7][0],ElementPos[7][1],ElementPos[7][2],ElementPos[7][3],TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN,900000);                                break;                                }                                //Tainted Elemental is spawned after 50sec. after the previous elemental is death                                if ((Tain_Elemental->GetHealth() <= 0))                                {                                    Tainted_Elemental = false;                                    TaintedElemental_Timer = 50000;                                                            }                                                            }                                                    }                        case 3:                        {                            DoYell(SAY_PHASE3,LANG_UNIVERSAL,NULL);                            DoPlaySoundToSet(m_creature,SOUND_PHASE3);                        }                }            }             DoMeleeAttackIfReady();     }}; CreatureAI* GetAI_boss_lady_vashj(Creature *_Creature){    return new boss_lady_vashjAI (_Creature);} /**==========================================* ENCHANTED ELEMENTAL*==========================================*//*TODO:*They do not attack in melee, they only go straight to Lady Vashj. So How can I do to ignore attacks? :)*/#include "../../sc_defines.h"#define ELE_X        30#define ELE_Y        -923,4#define ELE_Z        43 struct MANGOS_DLL_DECL npc_enchanted_elementalAI : public ScriptedAI{    npc_enchanted_elementalAI(Creature *c) : ScriptedAI(c) {EnterEvadeMode();}     bool InCombat;     void EnterEvadeMode()    {        InCombat = false;         m_creature->RemoveAllAuras();        m_creature->DeleteThreatList();        m_creature->CombatStop();        DoGoHome();        m_creature->SendMoveToPacket(ELE_X,ELE_Y,ELE_Z,false);    }     void AttackStart(Unit *who)    {        if (!who)            return;         if (who->isTargetableForAttack() && who!= m_creature)        {            //Begin melee attack if we are within range            if (!m_creature->IsWithinDistInMap(who, ATTACK_DISTANCE))            DoStartMeleeAttack(who);             InCombat = true;        }    }     void MoveInLineOfSight(Unit *who)    {        if (!who || m_creature->getVictim())            return;         if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who))        {            float attackRadius = m_creature->GetAttackDistance(who);            if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who))            {                if(who->HasStealthAura())                    who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);                 //Begin melee attack if we are within range                if (!m_creature->IsWithinDistInMap(who, ATTACK_DISTANCE))                DoStartMeleeAttack(who);                 InCombat = true;            }        }    }     void UpdateAI(const uint32 diff)        {            //Return since we have no target        if (!m_creature->SelectHostilTarget())            return;            //Check if we have a current target        if( m_creature->getVictim() && m_creature->isAlive())                 //If we are within range melee the target            if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))                {                    //Make sure our attack is ready and we aren't currently casting                if( m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))                {                }            }             DoMeleeAttackIfReady();     }}; CreatureAI* GetAI_npc_enchanted_elemental(Creature *_Creature){    return new npc_enchanted_elementalAI (_Creature);}/**==========================================* TAINTED ELEMENTAL*==========================================*//*TODO:*Right IDs and Timers*/#include "../sc_defines.h"#include "../creature/simple_ai.h"#define SPELL_POISON_BOLT       38459CreatureAI* GetAI_npc_tainted_elemental(Creature *_Creature){    SimpleAI* ai = new SimpleAI (_Creature);    //Poison Bolt    ai->Spell[0].Enabled = true;    ai->Spell[0].Spell_Id = SPELL_POISON_BOLT;    ai->Spell[0].Cooldown = 5000;    ai->Spell[0].First_Cast = 5000;    ai->Spell[0].Cast_Target_Type = CAST_HOSTILE_TARGET;    return ai;}//Scripts...void AddSC_boss_lady_vashj(){    Script *newscript;    newscript = new Script;    newscript->Name="boss_lady_vashj";    newscript->GetAI = GetAI_boss_lady_vashj;    m_scripts[nrscripts++] = newscript;    newscript = new Script;    newscript->Name="npc_enchanted_elemental";    newscript->GetAI = GetAI_npc_enchanted_elemental;    m_scripts[nrscripts++] = newscript;    newscript = new Script;    newscript->Name="npc_tainted_elemental";    newscript->GetAI = GetAI_npc_tainted_elemental;    m_scripts[nrscripts++] = newscript;}