void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        // Pounding
        if (Pounding_Timer <= diff)
        {
            DoCast(m_creature->getVictim(), SPELL_POUNDING);

            DoScriptText(RAND(SAY_POUNDING1,SAY_POUNDING2), m_creature);
             Pounding_Timer = 15000;                         //cast time(3000) + cooldown time(12000)
        } else Pounding_Timer -= diff;

        // Arcane Orb
        if (ArcaneOrb_Timer <= diff)
        {
            Unit *pTarget = NULL;
            std::list<HostilReference *> t_list = m_creature->getThreatManager().getThreatList();
            std::vector<Unit *> target_list;
            for (std::list<HostilReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
            {
                pTarget = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                if (!pTarget)
                    continue;

                // exclude pets & totems
                if (pTarget->GetTypeId() != TYPEID_PLAYER)
                    continue;

                //18 yard radius minimum
                if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER && pTarget->isAlive() && !pTarget->IsWithinDist(m_creature, 18, false))
                    target_list.push_back(pTarget);
                pTarget = NULL;
            }

            if (target_list.size())
                pTarget = *(target_list.begin()+rand()%target_list.size());
            else
                pTarget = m_creature->getVictim();

            if (pTarget)
                m_creature->CastSpell(pTarget->GetPositionX(),pTarget->GetPositionY(),pTarget->GetPositionZ(), SPELL_ARCANE_ORB, false, NULL, NULL, NULL, pTarget);

            ArcaneOrb_Timer = 3000;
        } else ArcaneOrb_Timer -= diff;

        // Single Target knock back, reduces aggro
        if (KnockAway_Timer <= diff)
        {
            DoCast(m_creature->getVictim(), SPELL_KNOCK_AWAY);

            //Drop 25% aggro
            if (DoGetThreat(m_creature->getVictim()))
                DoModifyThreatPercent(m_creature->getVictim(),-25);

            KnockAway_Timer = 30000;
        } else KnockAway_Timer -= diff;

        //Berserk
        if (Berserk_Timer < diff && !Enraged)
        {
            DoCast(m_creature, SPELL_BERSERK);
            Enraged = true;
        } else Berserk_Timer -= diff;

        DoMeleeAttackIfReady();

        EnterEvadeIfOutOfCombatArea(diff);
    }
Beispiel #2
0
		void MeteorStrike()
		{
			Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0);
			if (pTarget)
				me->SummonCreature(NPC_METEOR_STRIKE, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 999999);
		}
Beispiel #3
0
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        if (event_inProgress)
        {
            if (SpawnResTimer)
                if (SpawnResTimer <= diff)
                {
                    DoCast(m_creature, SPELL_SUMMON_BANSHEE); // Summons direktly on caster position
                    //DoCast(m_creature, SPELL_SCOURG_RESURRECTION_EFFEKTSPAWN); // Dont needet ?
                    SpawnResTimer = 0;
                } else SpawnResTimer -= diff;

            return;
        }

        // This is used for a spell queue ... the spells should not castet if one spell is already casting
        if (wait_Timer)
            if (wait_Timer <= diff)
            {
                wait_Timer = 0;
            } else wait_Timer -= diff;

        if (Cleave_Timer <= diff)
        {
            if (!wait_Timer)
            {
                if (undead)
                    DoCast(m_creature->getVictim(), DUNGEON_MODE(SPELL_WOE_STRIKE, H_SPELL_WOE_STRIKE));
                else
                    DoCast(m_creature->getVictim(), SPELL_CLEAVE);
                Cleave_Timer = rand()%5000 + 2000;

                wait_Timer = 1000;
            }
        } else Cleave_Timer -= diff;

        if (Smash_Timer <= diff)
        {
            if (!wait_Timer)
            {
                if (undead)
                    DoCast(m_creature->getVictim(), SPELL_DARK_SMASH);
                else
                    DoCast(m_creature->getVictim(), DUNGEON_MODE(SPELL_SMASH, H_SPELL_SMASH));
                Smash_Timer = 10000;

                wait_Timer = 5000;
            }
        } else Smash_Timer -= diff;

        if (!undead)
        {
            if (Enrage_Timer <= diff)
            {
                DoCast(m_creature, DUNGEON_MODE(SPELL_ENRAGE, H_SPELL_ENRAGE));
                Enrage_Timer = 10000;
            } else Enrage_Timer -= diff;
        } else // In Undead form used to summon weapon
        {
            if (Enrage_Timer <= diff)
            {
                if (!wait_Timer)
                {
                    // Spawn target for Axe
                    Unit *pTarget = SelectUnit(SELECT_TARGET_TOPAGGRO, 1);
                    if (pTarget)
                    {
                        Creature* temp = m_creature->SummonCreature(ENTRY_THROW_TARGET,pTarget->GetPositionX(),pTarget->GetPositionY(),pTarget->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN,2000);

                        DoCast(m_creature, SPELL_SHADOW_AXE_SUMMON);
                    }
                    Enrage_Timer = 30000;
                }
            } else Enrage_Timer -= diff;
        }

        if (Roar_Timer <= diff)
        {
            if (!wait_Timer)
            {
                if (undead)
                    DoCast(m_creature, DUNGEON_MODE(SPELL_DREADFUL_ROAR, H_SPELL_DREADFUL_ROAR));
                else
                    DoCast(m_creature, DUNGEON_MODE(SPELL_STAGGERING_ROAR, H_SPELL_STAGGERING_ROAR));
                Roar_Timer = 10000;

                wait_Timer = 5000;
            }
        } else Roar_Timer -= diff;

        DoMeleeAttackIfReady();
    }
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            if (me->getVictim() && me->isAlive())
            {
                if (PoisonVolley_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_POISONVOLLEY);
                    PoisonVolley_Timer = urand(10000, 20000);
                } else PoisonVolley_Timer -= diff;

                if (!PhaseTwo && Aspect_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_ASPECT_OF_MARLI);
                    Aspect_Timer = urand(13000, 18000);
                } else Aspect_Timer -= diff;

                if (!Spawned && SpawnStartSpiders_Timer <= diff)
                {
                    Talk(SAY_SPIDER_SPAWN);

                    Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
                    if (!target)
                        return;

                    Creature* Spider = NULL;

                    Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                    if (Spider)
                        Spider->AI()->AttackStart(target);
                    Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                    if (Spider)
                        Spider->AI()->AttackStart(target);
                    Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                    if (Spider)
                        Spider->AI()->AttackStart(target);
                    Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                    if (Spider)
                        Spider->AI()->AttackStart(target);

                    Spawned = true;
                } else SpawnStartSpiders_Timer -= diff;

                if (SpawnSpider_Timer <= diff)
                {
                    Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
                    if (!target)
                        return;

                    Creature* Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                    if (Spider)
                        Spider->AI()->AttackStart(target);
                    SpawnSpider_Timer = urand(12000, 17000);
                } else SpawnSpider_Timer -= diff;

                if (!PhaseTwo && Transform_Timer <= diff)
                {
                    Talk(SAY_TRANSFORM);
                    DoCast(me, SPELL_SPIDER_FORM);
                    const CreatureTemplate* cinfo = me->GetCreatureTemplate();
                    me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35)));
                    me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35)));
                    me->UpdateDamagePhysical(BASE_ATTACK);
                    DoCast(me->getVictim(), SPELL_ENVOLWINGWEB);

                    if (DoGetThreat(me->getVictim()))
                        DoModifyThreatPercent(me->getVictim(), -100);

                    PhaseTwo = true;
                    Transform_Timer = urand(35000, 60000);
                } else Transform_Timer -= diff;

                if (PhaseTwo)
                {
                    if (Charge_Timer <= diff)
                    {
                        Unit* target = NULL;
                        int i = 0;
                        while (i < 3)                           // max 3 tries to get a random target with power_mana
                        {
                            ++i;
                            target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);  // not aggro leader
                            if (target && target->getPowerType() == POWER_MANA)
                                i = 3;
                        }
                        if (target)
                        {
                            DoCast(target, SPELL_CHARGE);
                            //me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0);
                            //me->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true, 1);
                            AttackStart(target);
                        }

                        Charge_Timer = 8000;
                    } else Charge_Timer -= diff;

                    if (TransformBack_Timer <= diff)
                    {
                        me->SetDisplayId(15220);
                        const CreatureTemplate* cinfo = me->GetCreatureTemplate();
                        me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 1)));
                        me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 1)));
                        me->UpdateDamagePhysical(BASE_ATTACK);

                        PhaseTwo = false;
                        TransformBack_Timer = urand(25000, 40000);
                    } else TransformBack_Timer -= diff;

                }

                DoMeleeAttackIfReady();
            }
        }
Beispiel #5
0
        void UpdateAI(const uint32 diff)
        {
            switch(Phase)
            {
                case FLYING:
                    if (!UpdateVictim())
                        return;

                    if (me->GetPositionX() >= 515)
                    {
                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
                        if (!m_bSaidEmote)
                        {
                            DoScriptText(EMOTE_RANGE, me);
                            m_bSaidEmote = true;
                        }
                    }
                    else
                    {
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
                        m_bSaidEmote = false;
                    }

                    if (m_uiMountTimer && m_uiMountTimer <= diff)
                    {
                        me->Mount(DATA_MOUNT);
                        me->SetFlying(true);
                        m_uiMountTimer = 0;
                    } else m_uiMountTimer -= diff;

                    if (m_uiSummonTimer <= diff)
                    {
                        SpawnMobs();
                        m_uiSummonTimer = 25000;
                    } else m_uiSummonTimer -= diff;

                    if (BreathSide != NONE)
                        if (m_uiSpawnTriggerTimer <= diff)
                        {
                            me->SummonCreature(CREATURE_TRIGGER,Location[m_LocCount]);
                            m_uiSpawnTriggerTimer = 125;
                            m_LocCount++;
                            if (m_LocCount > m_End)
                                BreathSide = NONE;
                        } else m_uiSpawnTriggerTimer -= diff;

                    if (m_uiMovementTimer <= diff)
                    {
                        switch(m_uiWaypointId)
                        {
                            case 0:
                                me->GetMotionMaster()->MovePoint(0, Location[1].GetPositionX(), Location[1].GetPositionY(), Location[1].GetPositionZ());
                                m_uiMovementTimer = 5000;
                                break;
                            case 1:
                                me->GetMotionMaster()->MovePoint(0, Location[2].GetPositionX(), Location[2].GetPositionY(), Location[2].GetPositionZ());
                                m_uiMovementTimer = 2000;
                                break;
                            case 2:
                                me->GetMotionMaster()->MovePoint(0, Location[3].GetPositionX(), Location[3].GetPositionY(), Location[3].GetPositionZ());
                                m_uiMovementTimer = 15000;
                                break;
                            case 3:
                                switch (urand(0,1))
                                {
                                    case 0:
                                        BreathSide = LEFT;
                                        m_Start = 8;
                                        m_End = 37;
                                        m_LocNr = 69;
                                        break;
                                    case 1:
                                        BreathSide = RIGHT;
                                        m_Start = 38;
                                        m_End = 68;
                                        m_LocNr = 70;
                                        break;
                                }
                                me->GetMotionMaster()->MovePoint(0, Location[m_LocNr].GetPositionX(), Location[m_LocNr].GetPositionY(), Location[m_LocNr].GetPositionZ());
                                DoScriptText(RAND(SAY_DRAKE_BREATH_1, SAY_DRAKE_BREATH_2, SAY_DRAKE_BREATH_3), me);
                                //DoScriptText(EMOTE_BREATH, me);
                                m_uiMovementTimer = 2500;
                                m_uiSpawnTriggerTimer = 3000;
                                m_LocCount = m_Start;
                                break;
                            case 4:
                                me->GetMotionMaster()->MovePoint(0, Location[71].GetPositionX(), Location[71].GetPositionY(), Location[71].GetPositionZ());
                                m_uiMovementTimer = 2000;
                                //SpawnTrigger();

                                // if there are harpoon hits at this point, disable achievement
                                if (m_uiSpellHitCount)
                                    m_bAchiev = false;
                                break;
                            case 5:
                                me->GetMotionMaster()->MovePoint(0, Location[72].GetPositionX(), Location[72].GetPositionY(), Location[72].GetPositionZ());
                                m_uiMovementTimer = 15000;
                                break;
                            case 6:
                                me->GetMotionMaster()->MovePoint(0, Location[3].GetPositionX(), Location[3].GetPositionY(), Location[3].GetPositionZ());
                                m_uiWaypointId = 2;
                                m_uiMovementTimer = 15000;
                                break;
                        }
                        m_uiWaypointId++;
                    } else m_uiMovementTimer -= diff;
                    break;
                case SKADI:
                    //Return since we have no target
                    if (!UpdateVictim())
                        return;

                    if (!me->HasAura(DUNGEON_MODE(SPELL_WHIRLWIND, H_SPELL_WHIRLWIND)))
                    {
                        if (m_isWhirling)
                        {
                            m_isWhirling = false;
                            me->GetMotionMaster()->Clear();
                            me->GetMotionMaster()->MoveChase(me->getVictim());
                            m_uiWhirlwindTimer = 13000;
                        }

                    if (m_uiCrushTimer <= diff)
                    {
                            if(!me->IsNonMeleeSpellCasted(false))
                            {
                            DoCastVictim(DUNGEON_MODE(SPELL_CRUSH, H_SPELL_CRUSH));
                            m_uiCrushTimer = urand(8000, 12000);
                            }
                    } else m_uiCrushTimer -= diff;

                    if (m_uiPoisonedSpearTimer <= diff)
                    {
                            if(!me->IsNonMeleeSpellCasted(false))
                            {
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
                                DoCast(target, DUNGEON_MODE(SPELL_POISONED_SPEAR, H_SPELL_POISONED_SPEAR));
                            m_uiPoisonedSpearTimer = urand(10000, 12000);
                            }
                    } else m_uiPoisonedSpearTimer -= diff;
                    }

                    if (!m_isWhirling)
                    {
                    if (m_uiWhirlwindTimer <= diff)
                    {
                        if(!me->IsNonMeleeSpellCasted(false))
                        {
                                if (Unit *newTarget = SelectTarget(SELECT_TARGET_RANDOM, 1))
                                    m_uiWhirlGUID = newTarget->GetGUID();

                                DoCast(DUNGEON_MODE(SPELL_WHIRLWIND, H_SPELL_WHIRLWIND));
                                m_isWhirling = true;
                        }
                    } else m_uiWhirlwindTimer -= diff;
                    }

                    if (m_isWhirling)  //somewhat hacky to get skadi move during whirlwind
                    {
                        if (m_uiWhirlwindTimer <= diff)
                        {
                            Unit *whirlTarget = Unit::GetUnit(*me, m_uiWhirlGUID);
                            if (whirlTarget && whirlTarget->isAlive())
                            {
                                me->GetMotionMaster()->Clear();
                                me->GetMotionMaster()->MovePoint(0,whirlTarget->GetPositionX(),whirlTarget->GetPositionY(),whirlTarget->GetPositionZ());
                            }
                            else if (Unit *newTarget = SelectTarget(SELECT_TARGET_RANDOM, 1)) //whirl target died
                            {
                                me->GetMotionMaster()->Clear();
                                m_uiWhirlGUID = newTarget->GetGUID();
                                me->GetMotionMaster()->MovePoint(0,newTarget->GetPositionX(),newTarget->GetPositionY(),newTarget->GetPositionZ());
                            }
                            else                                                            //only 1 target left
                            {
                                me->GetMotionMaster()->Clear();
                                me->GetMotionMaster()->MoveChase(me->getVictim());
                            }

                            m_uiWhirlwindTimer = 500;
                        } else m_uiWhirlwindTimer -= diff;
                    }

                    DoMeleeAttackIfReady();
                    break;
            }
        }
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            if(pulse_Timer < diff)
            {
                DoAttackerAreaInCombat(me->getVictim(),50);
                pulse_Timer = 10000;
            }else pulse_Timer -= diff;

            if(TidalShieldTimer < diff)
            {
                if(TryDoCast(me, SPELL_TIDAL_SHIELD, true))
                {
                    ResetTimer(45000);
                    TidalShieldTimer = 60000;
                }
            }else TidalShieldTimer -= diff;

            if(!me->HasAura(SPELL_BERSERK,0))
            {
                if(EnrageTimer < diff)
                {
                    DoScriptText(SAY_ENRAGE2, me);
                    DoCast(me, SPELL_BERSERK, true);
                }else EnrageTimer -= diff;
            }

            if(SpecialYellTimer < diff)
            {
                switch(rand()%2)
                {
                case 0: DoScriptText(SAY_SPECIAL1, me); break;
                case 1: DoScriptText(SAY_SPECIAL2, me); break;
                }
                SpecialYellTimer = 25000 + (rand()%76)*1000;
            }else SpecialYellTimer -= diff;

            if(ImpalingSpineTimer < diff)
            {
                if(!me->IsNonMeleeSpellCasted(false))
                {
                    Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 80,true);
                    if(!target) target = me->getVictim();
                    if(target)
                    {
                        DoCast(target, SPELL_IMPALING_SPINE);
                        SpineTargetGUID = target->GetGUID();
                        //must let target summon, otherwise you cannot click the spine
                        target->SummonGameObject(GOBJECT_SPINE, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), me->GetOrientation(), 0, 0, 0, 0, 0);

                        switch(rand()%2)
                        {
                        case 0: DoScriptText(SAY_NEEDLE1, me); break;
                        case 1: DoScriptText(SAY_NEEDLE2, me); break;
                        }
                        ImpalingSpineTimer = 21000;
                    }
                }
            }else ImpalingSpineTimer -= diff;

            if(NeedleSpineTimer < diff)
            {
                if(TryDoCast(me, SPELL_NEEDLE_SPINE, true))
                {
                    //std::list<Unit*> target;
                    //SelectTargetList(target, 3, SELECT_TARGET_RANDOM, 100, true);
                    //for(std::list<Unit*>::iterator i = target.begin(); i != target.end(); ++i)
                    //    me->CastSpell(*i, 39835, true);
                    NeedleSpineTimer = 3000;
                }
            }else NeedleSpineTimer -= diff;


            DoMeleeAttackIfReady();
        }
Beispiel #7
0
            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                //Invisible_Timer
                if (Invisible_Timer <= diff)
                {
                    me->InterruptSpell(CURRENT_GENERIC_SPELL);

                    SetEquipmentSlots(false, EQUIP_UNEQUIP, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE);
                    me->SetDisplayId(11686);

                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    Invisible = true;

                    Invisible_Timer = 15000 + rand()%15000;
                } else Invisible_Timer -= diff;

                if (Invisible)
                {
                    if (Ambush_Timer <= diff)
                    {
                        Unit *pTarget = NULL;
                        pTarget = SelectTarget(SELECT_TARGET_RANDOM,0);
                        if (pTarget)
                        {
                            DoTeleportTo(pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ());
                            DoCast(pTarget, SPELL_AMBUSH);
                        }

                        Ambushed = true;
                        Ambush_Timer = 3000;
                    } else Ambush_Timer -= diff;
                }

                if (Ambushed)
                {
                    if (Visible_Timer <= diff)
                    {
                        me->InterruptSpell(CURRENT_GENERIC_SPELL);

                        me->SetDisplayId(15268);
                        SetEquipmentSlots(false, EQUIP_ID_MAIN_HAND, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE);

                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        Invisible = false;

                        Visible_Timer = 4000;
                    } else Visible_Timer -= diff;
                }

                //Resetting some aggro so he attacks other gamers
                if (!Invisible)
                {
                    if (Aggro_Timer <= diff)
                    {
                        Unit *pTarget = NULL;
                        pTarget = SelectTarget(SELECT_TARGET_RANDOM,1);

                        if (DoGetThreat(me->getVictim()))
                            DoModifyThreatPercent(me->getVictim(),-50);

                        if (pTarget)
                            AttackStart(pTarget);

                        Aggro_Timer = 7000 + rand()%13000;
                    } else Aggro_Timer -= diff;
                }

                if (!Invisible)
                {
                    if (ThousandBlades_Timer <= diff)
                    {
                        DoCast(me->getVictim(), SPELL_THOUSANDBLADES);
                        ThousandBlades_Timer = 7000 + rand()%5000;
                    } else ThousandBlades_Timer -= diff;
                }

                DoMeleeAttackIfReady();
            }
Beispiel #8
0
    void UpdateAI(const uint32 diff)
    {
        //Check if we have a target
        if (!UpdateVictim())
            return;

        //No instance
        if (!pInst)
            return;

        switch (pInst->GetData(DATA_CTHUN_PHASE))
        {
            case 0:
            {
                //BeamTimer
                if (BeamTimer <= diff)
                {
                    //SPELL_GREEN_BEAM
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM,0);
                    if (pTarget)
                    {
                        m_creature->InterruptNonMeleeSpells(false);
                        DoCast(pTarget,SPELL_GREEN_BEAM);

                        //Correctly update our target
                        m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pTarget->GetGUID());
                    }

                    //Beam every 3 seconds
                    BeamTimer = 3000;
                } else BeamTimer -= diff;

                //ClawTentacleTimer
                if (ClawTentacleTimer <= diff)
                {
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM,0);
                    if (pTarget)
                    {
                        Creature* Spawned = NULL;

                        //Spawn claw tentacle on the random target
                        Spawned = me->SummonCreature(MOB_CLAW_TENTACLE,pTarget->GetPositionX(),pTarget->GetPositionY(),pTarget->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500);

                        if (Spawned)
                            Spawned->AI()->AttackStart(pTarget);
                    }

                    //One claw tentacle every 12.5 seconds
                    ClawTentacleTimer = 12500;
                } else ClawTentacleTimer -= diff;

                //EyeTentacleTimer
                if (EyeTentacleTimer <= diff)
                {
                    //Spawn the 8 Eye Tentacles in the corret spots
                    SpawnEyeTentacle(0, 20);                //south
                    SpawnEyeTentacle(10, 10);               //south west
                    SpawnEyeTentacle(20, 0);                //west
                    SpawnEyeTentacle(10, -10);              //north west

                    SpawnEyeTentacle(0, -20);               //north
                    SpawnEyeTentacle(-10, -10);             //north east
                    SpawnEyeTentacle(-20, 0);               // east
                    SpawnEyeTentacle(-10, 10);              // south east

                    //No point actually putting a timer here since
                    //These shouldn't trigger agian until after phase shifts
                    EyeTentacleTimer = 45000;
                } else EyeTentacleTimer -= diff;

                //PhaseTimer
                if (PhaseTimer <= diff)
                {
                    //Switch to Dark Beam
                    pInst->SetData(DATA_CTHUN_PHASE, 1);

                    m_creature->InterruptNonMeleeSpells(false);

                    //Select random target for dark beam to start on
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM,0);

                    if (pTarget)
                    {
                        //Correctly update our target
                        m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pTarget->GetGUID());

                        //Face our target
                        DarkGlareAngle = m_creature->GetAngle(pTarget);
                        DarkGlareTickTimer = 1000;
                        DarkGlareTick = 0;
                        ClockWise = rand()%2;
                    }

                    //Add red coloration to C'thun
                    DoCast(m_creature,SPELL_RED_COLORATION);

                    //Freeze animation

                    //Darkbeam for 35 seconds
                    PhaseTimer = 35000;
                } else PhaseTimer -= diff;

            }
            break;
            case 1:
            {
                //EyeTentacleTimer
                if (DarkGlareTick < 35)
                    if (DarkGlareTickTimer <= diff)
                    {
                        //Remove any target
                        m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0);

                        //Set angle and cast
                        if (ClockWise)
                            m_creature->SetOrientation(DarkGlareAngle + ((float)DarkGlareTick*PI/35));
                        else
                            m_creature->SetOrientation(DarkGlareAngle - ((float)DarkGlareTick*PI/35));

                        m_creature->StopMoving();

                        //Actual dark glare cast, maybe something missing here?
                        m_creature->CastSpell(m_creature, SPELL_DARK_GLARE, false);

                        //Increase tick
                        ++DarkGlareTick;

                        //1 second per tick
                        DarkGlareTickTimer = 1000;
                    } else DarkGlareTickTimer -= diff;

                //PhaseTimer
                if (PhaseTimer <= diff)
                {
                    //Switch to Eye Beam
                    pInst->SetData(DATA_CTHUN_PHASE, 0);

                    BeamTimer = 3000;
                    EyeTentacleTimer = 45000;               //Always spawns 5 seconds before Dark Beam
                    ClawTentacleTimer = 12500;              //4 per Eye beam phase (unsure if they spawn durring Dark beam)

                    m_creature->InterruptNonMeleeSpells(false);

                    //Remove Red coloration from c'thun
                    m_creature->RemoveAurasDueToSpell(SPELL_RED_COLORATION);

                    //Freeze animation
                    m_creature->SetUInt32Value(UNIT_FIELD_FLAGS, 0);

                    //Eye Beam for 50 seconds
                    PhaseTimer = 50000;
                } else PhaseTimer -= diff;
            }
            break;

            //Transition phase
            case 2:
            {
                //Remove any target
                m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0);
                m_creature->SetHealth(0);
            }

            //Dead phase
            case 5:
            {
                m_creature->Kill(m_creature);
            }
        }
    }
        void UpdateAI(const uint32 diff)
        {
            if (!pInstance || !UpdateVictim())
                return;

            if (IsHeroic() && me->HealthBelowPct(30) && !bShadowBreath)
            {
                bShadowBreath = true;
                if (Creature* pNefarius = me->FindNearestCreature(NPC_LORD_VICTOR_NEFARIUS_HEROIC, 200.0f))
                    pNefarius->AI()->DoAction(ACTION_SHADOW_BREATH);
            }

            events.Update(diff);

            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                /*case EVENT_HEAD_START:
                    SetGrounded(true, 0);
                    if (Creature* pMagmawhead = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_MAGMAW_HEAD)))
                        pMagmawhead->AI()->DoAction(ACTION_HEAD_START);
                    events.ScheduleEvent(EVENT_HEAD_END, 20000);
                    break;
                case EVENT_HEAD_END:
                    if (Creature* pMagmawhead = ObjectAccessor::GetCreature(*me, pInstance->GetData64(DATA_MAGMAW_HEAD)))
                        pMagmawhead->AI()->DoAction(ACTION_HEAD_END);
                    SetGrounded(false, 0);
                    events.ScheduleEvent(EVENT_MELEE_CHECK, 6000);
                    events.ScheduleEvent(EVENT_LAVA_SPEW, urand(3000, 7000));
                    events.ScheduleEvent(EVENT_PILLAR_OF_FLAME, urand(10000, 15000));
                    events.ScheduleEvent(EVENT_MAGMA_SPLIT, urand(15000, 20000));
                    break;*/
                case EVENT_BERSERK:
                    DoCast(me, SPELL_BERSERK);
                    break;
                case EVENT_MELEE_CHECK:
                    if (!me->IsWithinMeleeRange(me->getVictim()))
                        DoCast(me, SPELL_MAGMA_SPLIT_2);
                    events.ScheduleEvent(EVENT_MELEE_CHECK, 1000);
                    break;
                case EVENT_MAGMA_SPLIT:
                    me->CastCustomSpell(SPELL_MAGMA_SPLIT_1, SPELLVALUE_MAX_TARGETS, RAID_MODE(3, 8, 3, 8), 0, false); 
                    events.ScheduleEvent(EVENT_MAGMA_SPLIT, urand(15000, 20000));
                    break;
                case EVENT_LAVA_SPEW:
                    DoCast (me, SPELL_LAVA_SPEW);
                    events.ScheduleEvent(EVENT_LAVA_SPEW, 22000);
                    break;
                case EVENT_PILLAR_OF_FLAME:
                    Unit* target;
                    target = SelectTarget(SELECT_TARGET_RANDOM, 1, -20.0f, true);
                    if (!target)
                        target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true);
                    if (!target)
                        break;
                    me->SummonCreature(NPC_PILLAR_OF_FLAME,
                        target->GetPositionX(),
                        target->GetPositionY(),
                        target->GetPositionZ(),
                        0.0f, TEMPSUMMON_TIMED_DESPAWN, 8000);
                    events.ScheduleEvent(EVENT_PILLAR_OF_FLAME, urand(35000, 45000));
                    break;
                case EVENT_MANGLE:
                    DoCast(me->getVictim(), SPELL_MANGLE);
                    //events.CancelEvent(EVENT_MELEE_CHECK);
                    //events.CancelEvent(EVENT_LAVA_SPEW);
                    //events.CancelEvent(EVENT_PILLAR_OF_FLAME);
                    //events.CancelEvent(EVENT_MAGMA_SPLIT);
                    events.ScheduleEvent(EVENT_MANGLE, 95000);
                    //events.ScheduleEvent(EVENT_HEAD_START, 12000);
                    break;
                }
            }
            if (me->getVictim())
                if (!me->getVictim()->HasAura(SPELL_MANGLE) && !bGrounded)
                    DoMeleeAttackIfReady();
        }
Beispiel #10
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_creature->GetHealthPercent() > 50.0f)
        {
            if (Charge_Timer < diff)
            {
                if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                    DoCastSpellIfCan(target,SPELL_CHARGE);

                Charge_Timer = urand(15000, 30000);
            }else Charge_Timer -= diff;

            if (SonicBurst_Timer < diff)
            {
                DoCastSpellIfCan(m_creature->getVictim(),SPELL_SONICBURST);
                SonicBurst_Timer = urand(8000, 13000);
            }else SonicBurst_Timer -= diff;

            if (Screech_Timer < diff)
            {
                DoCastSpellIfCan(m_creature->getVictim(),SPELL_SCREECH);
                Screech_Timer = urand(18000, 26000);
            }else Screech_Timer -= diff;

            if (SpawnBats_Timer < diff)
            {
                Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);

                Creature* Bat = NULL;
                Bat = m_creature->SummonCreature(11368, -12291.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                Bat = m_creature->SummonCreature(11368, -12289.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                Bat = m_creature->SummonCreature(11368, -12293.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                Bat = m_creature->SummonCreature(11368, -12291.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                Bat = m_creature->SummonCreature(11368, -12289.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                Bat = m_creature->SummonCreature(11368, -12293.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                SpawnBats_Timer = 60000;
            }else SpawnBats_Timer -= diff;
        }
        else
        {
            if (PhaseTwo)
            {
                if (PhaseTwo && ShadowWordPain_Timer < diff)
                {
                    if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                    {
                        DoCastSpellIfCan(target, SPELL_SHADOW_WORD_PAIN);
                        ShadowWordPain_Timer = urand(12000, 18000);
                    }
                }ShadowWordPain_Timer -=diff;

                if (MindFlay_Timer < diff)
                {
                    DoCastSpellIfCan(m_creature->getVictim(), SPELL_MIND_FLAY);
                    MindFlay_Timer = 16000;
                }MindFlay_Timer -=diff;

                if (ChainMindFlay_Timer < diff)
                {
                    m_creature->InterruptNonMeleeSpells(false);
                    DoCastSpellIfCan(m_creature->getVictim(), SPELL_CHAIN_MIND_FLAY);
                    ChainMindFlay_Timer = urand(15000, 30000);
                }ChainMindFlay_Timer -=diff;

                if (GreaterHeal_Timer < diff)
                {
                    m_creature->InterruptNonMeleeSpells(false);
                    DoCastSpellIfCan(m_creature,SPELL_GREATERHEAL);
                    GreaterHeal_Timer = urand(25000, 35000);
                }GreaterHeal_Timer -=diff;

                if (SpawnFlyingBats_Timer < diff)
                {
                    Unit *target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);

                    Creature* FlyingBat = m_creature->SummonCreature(14965, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()+15, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                    if (FlyingBat)
                    {
                        if (target)
                            FlyingBat->AI()->AttackStart(target);
                    }

                    SpawnFlyingBats_Timer = urand(10000, 15000);
                } else SpawnFlyingBats_Timer -=diff;
            }
            else
            {
                m_creature->SetDisplayId(15219);
                DoResetThreat();
                PhaseTwo = true;
            }
        }

        DoMeleeAttackIfReady();
    }
        void UpdateAI(uint32 diff)
        {
            events.Update(diff);

            if (Creature* warlord = me->FindNearestCreature(NPC_WARLORD, 1000.0f, true))
            {
                if (warlord->FindNearestCreature(me->GetEntry(), 2.0f, true) && !boss)
                {
                    boss = true;
                    uint32 stack = me->GetAura(AURA_DIFFUSION)->GetStackAmount();

                    if (stack >= 1)
                        warlord->CastSpell(warlord, AURA_DIFFUSION, true);
                    if (stack >= 2 && warlord->HasAura(AURA_DIFFUSION))
                        warlord->GetAura(AURA_DIFFUSION)->SetStackAmount(stack);

                    me->DespawnOrUnsummon(1000);
                }
            }

            if (Creature* cmaw = me->FindNearestCreature(55544, 100.0f, true))
            {
                if (cmaw->GetDistance(me) >= 40.0f && !maw)
                {
                    maw = true;
                    DoCast(SPELL_BLACK_BLOOD_ERUPTION);

                    me->NearTeleportTo(-1762.994f, -1951.96f, -226.269f, 0.0f, true);
                }
            }

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                case SPHERE_START:
                    me->SetSpeed(MOVE_RUN, 0.6f);
                    me->GetMotionMaster()->MoveRandom(20.0f);
                    events.ScheduleEvent(SPHERE_TARGET, urand(5000, 15000));
                    break;

                case SPHERE_TARGET:
                    player = true;
                    break;

                case SPHERE_UPDATE:
                    if (player)
                    {
                        Unit* victim = SelectTarget(SELECT_TARGET_RANDOM);
                        me->GetMotionMaster()->MovePoint(0, victim->GetPositionX(), victim->GetPositionY(), victim->GetPositionZ());
                        me->SetSpeed(MOVE_RUN, 5.0f);
                        if (victim->FindNearestCreature(me->GetEntry(), 10.0f, true))
                        {
                            DoCast(SPELL_SPREYED_SPHERE);

                            events.ScheduleEvent(SPHERE_START, 2000);
                            player = false;
                        }
                    }
                    events.ScheduleEvent(SPHERE_UPDATE, 2000);
                    break;
                }
            }
        }
Beispiel #12
0
            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                if (me->getVictim() && me->isAlive())
                {
                    if (!CombatStart)
                    {
                        //At combat Start Mandokir is mounted so we must unmount it first
                        me->Unmount();

                        //And summon his raptor
                        me->SummonCreature(14988, me->getVictim()->GetPositionX(), me->getVictim()->GetPositionY(), me->getVictim()->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 35000);
                        CombatStart = true;
                    }

                    if (Watch_Timer <= diff)                         //Every 20 Sec Mandokir will check this
                    {
                        if (WatchTarget)                             //If someone is watched and If the Position of the watched target is different from the one stored, or are attacking, mandokir will charge him
                        {
                            Unit* pUnit = Unit::GetUnit(*me, WatchTarget);

                            if (pUnit && (
                                targetX != pUnit->GetPositionX() ||
                                targetY != pUnit->GetPositionY() ||
                                targetZ != pUnit->GetPositionZ() ||
                                pUnit->isInCombat()))
                            {
                                if (me->IsWithinMeleeRange(pUnit))
                                {
                                    DoCast(pUnit, 24316);
                                }
                                else
                                {
                                    DoCast(pUnit, SPELL_CHARGE);
                                    //me->SendMonsterMove(pUnit->GetPositionX(), pUnit->GetPositionY(), pUnit->GetPositionZ(), 0, true, 1);
                                    AttackStart(pUnit);
                                }
                            }
                        }
                        someWatched = false;
                        Watch_Timer = 20000;
                    } else Watch_Timer -= diff;

                    if ((Watch_Timer < 8000) && !someWatched)       //8 sec(cast time + expire time) before the check for the watch effect mandokir will cast watch debuff on a random target
                    {
                        if (Unit* p = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        {
                            DoScriptText(SAY_WATCH, me, p);
                            DoCast(p, SPELL_WATCH);
                            WatchTarget = p->GetGUID();
                            someWatched = true;
                            endWatch = true;
                        }
                    }

                    if ((Watch_Timer < 1000) && endWatch)           //1 sec before the debuf expire, store the target position
                    {
                        Unit* pUnit = Unit::GetUnit(*me, WatchTarget);
                        if (pUnit)
                        {
                            targetX = pUnit->GetPositionX();
                            targetY = pUnit->GetPositionY();
                            targetZ = pUnit->GetPositionZ();
                        }
                        endWatch = false;
                    }

                    if (!someWatched)
                    {
                        //Cleave
                        if (Cleave_Timer <= diff)
                        {
                            DoCast(me->getVictim(), SPELL_CLEAVE);
                            Cleave_Timer = 7000;
                        } else Cleave_Timer -= diff;

                        //Whirlwind
                        if (Whirlwind_Timer <= diff)
                        {
                            DoCast(me, SPELL_WHIRLWIND);
                            Whirlwind_Timer = 18000;
                        } else Whirlwind_Timer -= diff;

                        //If more then 3 targets in melee range mandokir will cast fear
                        if (Fear_Timer <= diff)
                        {
                            TargetInRange = 0;

                            std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin();
                            for (; i != me->getThreatManager().getThreatList().end(); ++i)
                            {
                                Unit* pUnit = Unit::GetUnit(*me, (*i)->getUnitGuid());
                                if (pUnit && me->IsWithinMeleeRange(pUnit))
                                    ++TargetInRange;
                            }

                            if (TargetInRange > 3)
                                DoCast(me->getVictim(), SPELL_FEAR);

                            Fear_Timer = 4000;
                        } else Fear_Timer -=diff;

                        //Mortal Strike if target below 50% hp
                        if (me->getVictim() && me->getVictim()->HealthBelowPct(50))
                        {
                            if (MortalStrike_Timer <= diff)
                            {
                                DoCast(me->getVictim(), SPELL_MORTAL_STRIKE);
                                MortalStrike_Timer = 15000;
                            } else MortalStrike_Timer -= diff;
                        }
                    }
                    //Checking if Ohgan is dead. If yes Mandokir will enrage.
                    if (Check_Timer <= diff)
                    {
                        if (m_pInstance)
                        {
                            if (m_pInstance->GetData(DATA_OHGAN) == DONE)
                            {
                                if (!RaptorDead)
                                {
                                    DoCast(me, SPELL_ENRAGE);
                                    RaptorDead = true;
                                }
                            }
                        }

                        Check_Timer = 1000;
                    } else Check_Timer -= diff;

                    DoMeleeAttackIfReady();
                }
            }
    void UpdateAI(const uint32 diff)
    {
        //Return since we have no target
        if (me->HasAura(AURA_BANISH, 0) || !UpdateVictim())
        {
            if (BanishTimer <= diff)
            {
                CheckBanish();//no need to check every update tick
                BanishTimer = 1000;
            } else BanishTimer -= diff;
            return;
        }
        if (me->HasAura(SPELL_WHIRLWIND, 0))
        {
            if (Whirlwind_Timer <= diff)
            {
                Unit* newTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                if (newTarget)
                {
                    DoResetThreat();
                    me->GetMotionMaster()->Clear();
                    me->GetMotionMaster()->MovePoint(0,newTarget->GetPositionX(),newTarget->GetPositionY(),newTarget->GetPositionZ());
                }
                Whirlwind_Timer = 2000;
            } else Whirlwind_Timer -= diff;
        }
        // reseting after changing forms and after ending whirlwind
        if (NeedThreatReset && !me->HasAura(SPELL_WHIRLWIND, 0))
        {
            // when changing forms seting timers (or when ending whirlwind - to avoid adding new variable i use Whirlwind_Timer to countdown 2s while whirlwinding)
            if (DemonForm)
                InnerDemons_Timer = 30000;
            else
                Whirlwind_Timer =  15000;

            NeedThreatReset = false;
            DoResetThreat();
            me->GetMotionMaster()->Clear();
            me->GetMotionMaster()->MoveChase(me->getVictim());
        }

        //Enrage_Timer (10 min)
        if (Berserk_Timer <= diff && !EnrageUsed)
        {
            me->InterruptNonMeleeSpells(false);
            DoCast(me, SPELL_BERSERK);
            EnrageUsed = true;
        } else Berserk_Timer -= diff;

        if (!DemonForm)
        {
            //Whirldind Timer
            if (!me->HasAura(SPELL_WHIRLWIND, 0))
            {
                if (Whirlwind_Timer <= diff)
                {
                    DoCast(me, SPELL_WHIRLWIND);
                    // while whirlwinding this variable is used to countdown target's change
                    Whirlwind_Timer = 2000;
                    NeedThreatReset = true;
                } else Whirlwind_Timer -= diff;
            }
            //Switch_Timer

            if (!IsFinalForm)
            {
                if (SwitchToDemon_Timer <= diff)
                {
                    //switch to demon form
                    me->RemoveAurasDueToSpell(SPELL_WHIRLWIND,0);
                    me->SetDisplayId(MODEL_DEMON);
                    DoScriptText(SAY_SWITCH_TO_DEMON, me);
                    me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY  , 0);
                    me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, 0);
                    DemonForm = true;
                    NeedThreatReset = true;
                    SwitchToDemon_Timer = 45000;
                } else SwitchToDemon_Timer -= diff;
                
                DoMeleeAttackIfReady();
           }
        }
        else
        {
            //ChaosBlast_Timer
            if (!me->getVictim())
                return;
            if (me->GetDistance(me->getVictim()) < 30)
                me->StopMoving();
            if (ChaosBlast_Timer <= diff)
            {
                // will cast only when in range of spell
                if (me->GetDistance(me->getVictim()) < 30)
                {
                    //DoCast(me->getVictim(), SPELL_CHAOS_BLAST, true);
                    int damage = 100;
                    me->CastCustomSpell(me->getVictim(), SPELL_CHAOS_BLAST, &damage, NULL, NULL, false, NULL, NULL, me->GetGUID());
                }
                ChaosBlast_Timer = 3000;
            } else ChaosBlast_Timer -= diff;
            //Summon Inner Demon
            if (InnerDemons_Timer <= diff)
            {
                std::list<HostileReference *>& ThreatList = me->getThreatManager().getThreatList();
                std::vector<Unit* > TargetList;
                for (std::list<HostileReference *>::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr)
                {
                    Unit* tempTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                    if (tempTarget && tempTarget->GetTypeId() == TYPEID_PLAYER && tempTarget->GetGUID() != me->getVictim()->GetGUID() && TargetList.size()<5)
                        TargetList.push_back(tempTarget);
                }
                SpellEntry *spell = (SpellEntry *)GetSpellStore()->LookupEntry(SPELL_INSIDIOUS_WHISPER);
                for (std::vector<Unit* >::const_iterator itr = TargetList.begin(); itr != TargetList.end(); ++itr)
                {
                    if ((*itr) && (*itr)->isAlive())
                    {
                        Creature* demon = me->SummonCreature(INNER_DEMON_ID, (*itr)->GetPositionX()+10, (*itr)->GetPositionY()+10, (*itr)->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                        if (demon)
                        {
                            demon->AI()->AttackStart((*itr));
                            CAST_AI(mob_inner_demonAI, demon->AI())->victimGUID = (*itr)->GetGUID();

                            for (int i=0; i<3; i++)
                            {
                                if (!spell->Effect[i])
                                    continue;
                                (*itr)->AddAura(new InsidiousAura(spell, i, NULL, (*itr), (*itr)));
                            }

                            if (InnerDemon_Count > 4)
                                InnerDemon_Count = 0;

                            //Safe storing of creatures
                            InnderDemon[InnerDemon_Count] = demon->GetGUID();

                            //Update demon count
                            ++InnerDemon_Count;
                        }
                    }
                }
                DoScriptText(SAY_INNER_DEMONS, me);

                InnerDemons_Timer = 999999;
            } else InnerDemons_Timer -= diff;

            //Switch_Timer
            if (SwitchToHuman_Timer <= diff)
            {
                //switch to nightelf form
                me->SetDisplayId(MODEL_NIGHTELF);
                me->LoadEquipment(me->GetEquipmentId());

                CastConsumingMadness();
                DespawnDemon();

                DemonForm = false;
                NeedThreatReset = true;

                SwitchToHuman_Timer = 60000;
            } else SwitchToHuman_Timer -= diff;
        }

        if (!IsFinalForm && (me->GetHealth()*100 / me->GetMaxHealth()) < 15)
        {
            //at this point he divides himself in two parts
            CastConsumingMadness();
            DespawnDemon();
            Creature* Copy = NULL;
            Copy = DoSpawnCreature(DEMON_FORM, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 6000);
            if (Copy)
             {
                 Demon = Copy->GetGUID();
                if (me->getVictim())
                    Copy->AI()->AttackStart(me->getVictim());
            }
            //set nightelf final form
            IsFinalForm = true;
            DemonForm = false;

            DoScriptText(SAY_FINAL_FORM, me);
            me->SetDisplayId(MODEL_NIGHTELF);
            me->LoadEquipment(me->GetEquipmentId());
        }
    }
Beispiel #14
0
        void UpdateAI(const uint32 diff)
        {
            //Check if we have a target
            if (!UpdateVictim())
                return;

            //EvadeTimer
            if (!me->IsWithinMeleeRange(me->getVictim()))
            {
                if (EvadeTimer <= diff)
                {
                    if (Unit* p = Unit::GetUnit(*me, Portal))
                        p->Kill(p);

                    //Dissapear and reappear at new position
                    me->SetVisibility(VISIBILITY_OFF);

                    Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                    if (!pTarget)
                    {
                        me->Kill(me);
                        return;
                    }

                    if (!pTarget->HasAura(SPELL_DIGESTIVE_ACID))
                    {
                        me->GetMap()->CreatureRelocation(me, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0);
                        if (Creature* pPortal = me->SummonCreature(MOB_GIANT_PORTAL, *me, TEMPSUMMON_CORPSE_DESPAWN))
                        {
                            pPortal->SetReactState(REACT_PASSIVE);
                            Portal = pPortal->GetGUID();
                        }

                        GroundRuptureTimer = 500;
                        HamstringTimer = 2000;
                        ThrashTimer = 5000;
                        EvadeTimer = 5000;
                        AttackStart(pTarget);
                    }
                    me->SetVisibility(VISIBILITY_ON);
                } else EvadeTimer -= diff;
            }

            //GroundRuptureTimer
            if (GroundRuptureTimer <= diff)
            {
                DoCast(me->getVictim(), SPELL_GROUND_RUPTURE);
                GroundRuptureTimer = 30000;
            } else GroundRuptureTimer -= diff;

            //ThrashTimer
            if (ThrashTimer <= diff)
            {
                DoCast(me->getVictim(), SPELL_THRASH);
                ThrashTimer = 10000;
            } else ThrashTimer -= diff;

            //HamstringTimer
            if (HamstringTimer <= diff)
            {
                DoCast(me->getVictim(), SPELL_HAMSTRING);
                HamstringTimer = 10000;
            } else HamstringTimer -= diff;

            DoMeleeAttackIfReady();
        }
Beispiel #15
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->getVictim() && !m_creature->SelectHostilTarget())
            return;

        if (PoisonVolley_Timer < diff)
        {
            DoCast(m_creature->getVictim(),SPELL_POISONVOLLEY);
            PoisonVolley_Timer = 10000 + rand()%10000;
        }else PoisonVolley_Timer -= diff;

        if (!PhaseTwo && Aspect_Timer < diff)
        {
            DoCast(m_creature->getVictim(),SPELL_ASPECT_OF_MARLI);
            Aspect_Timer = 13000 + rand()%5000;
        }else Aspect_Timer -= diff;

        if (!Spawned && SpawnStartSpiders_Timer < diff)
        {
            DoScriptText(SAY_SPIDER_SPAWN, m_creature);

            Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0);

            Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
            if (target && Spider) Spider ->AI()->AttackStart(target);

            Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
            if (target && Spider) Spider ->AI()->AttackStart(target);

            Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
            if (target && Spider) Spider ->AI()->AttackStart(target);

            Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
            if (target && Spider) Spider ->AI()->AttackStart(target);

            Spawned = true;
        }else SpawnStartSpiders_Timer -= diff;

        if (SpawnSpider_Timer < diff)
        {
            Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0);

            Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
            if (target && Spider)
                Spider ->AI()->AttackStart(target);

            SpawnSpider_Timer = 12000 + rand()%5000;
        }else SpawnSpider_Timer -= diff;

        if (!PhaseTwo && Transform_Timer < diff)
        {
            DoScriptText(SAY_TRANSFORM, m_creature);

            DoCast(m_creature,SPELL_SPIDER_FORM);
            const CreatureInfo *cinfo = m_creature->GetCreatureInfo();
            m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35)));
            m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35)));
            m_creature->UpdateDamagePhysical(BASE_ATTACK);
            DoCast(m_creature->getVictim(),SPELL_ENVOLWINGWEB);

            if (m_creature->getThreatManager().getThreat(m_creature->getVictim()))
                m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100);

            PhaseTwo = true;
            Transform_Timer = 35000 + rand()%25000;
        }else Transform_Timer -= diff;

        if (PhaseTwo)
        {
            if (Charge_Timer < diff)
            {
                Unit* target = NULL;
                int i = 0 ;
                while (i < 3)                               // max 3 tries to get a random target with power_mana
                {
                    ++i;                                    //not aggro leader
                    target = SelectUnit(SELECT_TARGET_RANDOM,1);
                    if (target)
                        if (target->getPowerType() == POWER_MANA)
                            i=3;
                }

                if (target)
                    DoCast(target, SPELL_CHARGE);

                Charge_Timer = 8000;
            }else Charge_Timer -= diff;

            if (TransformBack_Timer < diff)
            {
                m_creature->SetDisplayId(15220);
                const CreatureInfo *cinfo = m_creature->GetCreatureInfo();
                m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 1)));
                m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 1)));
                m_creature->UpdateDamagePhysical(BASE_ATTACK);

                PhaseTwo = false;
                TransformBack_Timer = 25000 + rand()%15000;
            }else TransformBack_Timer -= diff;
        }

        DoMeleeAttackIfReady();
    }
Beispiel #16
0
        void UpdateAI(uint32 diff)
        {
            if (!UpdateVictim() || me->HasUnitState(UNIT_STATE_CASTING))
                return;

            if (ShouldSummonAdds)
            {
                // Despawns the Stalker
                DespawnCreatures(NPC_SHADOW_GALE_STALKER);
                RemoveShadowGaleDebuffFromPlayers();

                me->SetReactState(REACT_AGGRESSIVE);
                me->GetMotionMaster()->Clear();
                me->GetMotionMaster()->MoveChase(me->getVictim());

                if ((rand()%2))
                    me->MonsterYell(SAY_SUMMON, LANG_UNIVERSAL, NULL);

                //Adds a visual portal effect to the Stalker
                FacelessPortalStalker->GetAI()->DoCast(FacelessPortalStalker, SPELL_TWILIGHT_PORTAL_VISUAL, true);
                events.ScheduleEvent(EVENT_REMOVE_TWILIGHT_PORTAL, 7000);

                //Summons Faceless over the Spell
                FacelessPortalStalker->GetAI()->DoCast(FacelessPortalStalker, SPELL_SPAWN_FACELESS, true);

                ShouldSummonAdds = false;

                // DBM says that the Spell has 40s CD
                events.ScheduleEvent(EVENT_SHADOW_GALE, urand(40000, 44000));
            }

            events.Update(diff);

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                case EVENT_ENFEEBLING_BLOW:
                    DoCastVictim(SPELL_ENFEEBLING_BLOW);
                    events.ScheduleEvent(EVENT_ENFEEBLING_BLOW, urand(19000, 24000));
                    break;

                case EVENT_SHADOW_GALE:
                    ShadowGaleTrigger = me->SummonCreature(NPC_SHADOW_GALE_STALKER, -739.665f/*+(urand(0, 20)-10)*/, -827.024f/*+(urand(0, 20)-10)*/, 232.412f, 3.1f, TEMPSUMMON_CORPSE_DESPAWN);
                    me->SetReactState(REACT_PASSIVE);
                    me->GetMotionMaster()->MovePoint(POINT_ERUDAX_IS_AT_STALKER, ShadowGaleTrigger->GetPositionX(), ShadowGaleTrigger->GetPositionY(), ShadowGaleTrigger->GetPositionZ());
//                    Talk(SAY_GALE);
                    break;

                case EVENT_REMOVE_TWILIGHT_PORTAL:
                    //Removes Portal effect from Stalker
                    FacelessPortalStalker->RemoveAllAuras();
                    break;

                case EVENT_BINDING_SHADOWS:

                    if (Unit* tempTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 500.0f, true))
                        DoCast(tempTarget, SPELL_BINDING_SHADOWS);

                    events.ScheduleEvent(EVENT_BINDING_SHADOWS, urand(12000, 17000));
                    break;

                default:
                    break;
                }
            }

            DoMeleeAttackIfReady();
        }
        void UpdateAI(uint32 diff)
        {
            if (!UpdateVictim() || me->HasUnitState(UNIT_STATE_CASTING))
                return;

            if (!phase)
                return;

            if (m_uiPowerTimer <= diff)
            {
               instance->NormaliseAltPower();
            }
            else m_uiPowerTimer -= diff;

            events.Update(diff);

            if (phase == PHASE_GROUND) // Ground phase
            {
                ThreatContainer::StorageType const &threatlist = me->getThreatManager().getThreatList();

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_AGGRO_NEF:
                            if (Creature* nefarianHelperheroic = me->FindNearestCreature(NPC_NEFARIAN_HELPER_HEROIC, 150.0f, true))
                            nefarianHelperheroic->AI()->Talk(28);
                            return;

                        case EVENT_SONAR_PULSE:
                            DoCast(me, SPELL_SONAR_PULSE);
                            me->SummonCreature(NPC_SONAR_PULSES, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 1.5f, TEMPSUMMON_TIMED_DESPAWN, 30000);
                            me->SummonCreature(NPC_SONAR_PULSES, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 3.0f, TEMPSUMMON_TIMED_DESPAWN, 30000);
                            me->SummonCreature(NPC_SONAR_PULSES, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 4.5f, TEMPSUMMON_TIMED_DESPAWN, 30000);
                            me->SummonCreature(NPC_SONAR_PULSES, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 6.0f, TEMPSUMMON_TIMED_DESPAWN, 30000);   
                            events.ScheduleEvent(EVENT_SONAR_PULSE, 50000);
                            break;

                        case EVENT_MODULATION:
                            DoCast(me, SPELL_MODULATION);
                            for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
                                if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid()))
                                    unit->SetPower(POWER_ALTERNATE_POWER, unit->GetPower(POWER_ALTERNATE_POWER) + 7);

                            events.ScheduleEvent(EVENT_MODULATION, 20000);
                            break;

                        case EVENT_SONIC_BREATH:
                             if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
                            {
                                target->AddAura(SPELL_TRACKING, target);
                                DoCast(target, SPELL_SONIC_BREATH);
                            }
                            events.ScheduleEvent(EVENT_REMOVE_TRACKING, 8500);                            
                            events.ScheduleEvent(EVENT_SONIC_BREATH, 40000);
                            break;

                        case EVENT_REMOVE_TRACKING:
                            if(instance)
                                instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TRACKING);
                            return;

                        case EVENT_SEARING_FLAMES:
                            Talk(SAY_SEARING);
                            DoCast(me, SPELL_SEARING_FLAMES);                       
                            events.ScheduleEvent(EVENT_SEARING_FLAMES, 50000);
                            break;

                        case EVENT_LIFTOFF:
                            Talk(SAY_AIR_PHASE);
                            me->HandleEmote(EMOTE_ONESHOT_LIFTOFF);
                            me->SetDisableGravity(true);
                            events.ScheduleEvent(EVENT_FLIGHT, 1500);
                            events.ScheduleEvent(EVENT_AIR, 2000);
                            return;
                            
                        case EVENT_FLIGHT:
                            me->SetReactState(REACT_PASSIVE);
                            me->AttackStop();
                            me->GetMotionMaster()->MovePoint(1, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() + 20.0f);
                            return;

                        case EVENT_AIR:
                            EnterPhaseAir();
                            return;

                        case EVENT_FIEND:
                            me->SummonCreature(NPC_OBNOXIOUS_FIEND, 93.767f, -224.105f, 74.911f, 6.26f, TEMPSUMMON_CORPSE_DESPAWN, 3000);
                            if (Creature* nefarianHelperheroic = me->FindNearestCreature(NPC_NEFARIAN_HELPER_HEROIC, 150.0f, true))
                                nefarianHelperheroic->AI()->Talk(27);                                
                            events.ScheduleEvent(EVENT_FIEND, 38500);
                            break;
                    }
                }

                DoMeleeAttackIfReady();
            }
            else if (phase == PHASE_FLIGHT) // Air phase
            {
                std::list<Unit*> targets;
                ThreatContainer::StorageType const &m_threatlist = me->getThreatManager().getThreatList();

                // if has vertigo, remove all roaring flame npc's wait 8 sec then get player who rang gong.
                if (me->HasAura(SPELL_VERTIGO))
                    events.ScheduleEvent(EVENT_ROARING_FLAME_SUMMON, 8000, PHASE_FLIGHT);

                if (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_ROARING_FLAME_SUMMON:
                            for (ThreatContainer::StorageType::const_iterator i = m_threatlist.begin(); i != m_threatlist.end(); ++i)
                            {
                                Unit* unit = Unit::GetUnit(*me, (*i)->getUnitGuid());
                                if (unit && unit->HasAura(SPELL_NOISY)) // You rang? :)
                                {
                                    me->SummonCreature(NPC_ROARING_FLAME_TARGET, unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
                                }
                                else
                                {                                
                                     if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
                                        me->SummonCreature(NPC_ROARING_FLAME_TARGET, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
                                }
                            }        
                            events.ScheduleEvent(EVENT_ROARING_FLAME, 500);
                            return;

                        case EVENT_ROARING_FLAME:
                            if (Unit* roaring = me->FindNearestCreature(NPC_ROARING_FLAME_TARGET, 100.0f))
                                DoCast(roaring, SPELL_ROARING_FLAME_BREATH_DUMMY);
                            return;

                        case EVENT_SONAR_BOMB:
                            SelectTargetList(targets, RAID_MODE(3, 6), SELECT_TARGET_RANDOM, 100.0f, true);
                            if (!targets.empty())
                                for (std::list<Unit*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
                                    DoCast(*itr, SPELL_SONAR_BOMB);                     
                            events.ScheduleEvent(EVENT_SONAR_BOMB, 18000);
                            break;

                        case EVENT_LAND:
                            me->HandleEmote(EMOTE_ONESHOT_LAND);
                            me->SetDisableGravity(false);
                            events.ScheduleEvent(EVENT_RETURN, 1000);
                            events.ScheduleEvent(EVENT_GROUND, 1500);
                            return;

                        case EVENT_RETURN:
                            me->SetReactState(REACT_PASSIVE);
                            me->AttackStop();
                            me->GetMotionMaster()->MovePoint(1, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ() - 20.0f);
                            return;
                            
                        case EVENT_GROUND:
                            EnterPhaseGround();
                            return;
                    }
                }
            }            
        }
Beispiel #18
0
 void HandleFlightSequence()
 {
     switch(FlightCount)
     {
     case 0:
         //m_creature->AttackStop();
         error_log("prevent fly phase");
         m_creature->GetMotionMaster()->Clear(false);
         m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
         m_creature->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING);
         m_creature->StopMoving();
         DoScriptText(YELL_TAKEOFF, m_creature);
         Timer[EVENT_FLIGHT_SEQUENCE] = 2000;
         break;
     case 1:
         error_log("Move to Fly point");
         m_creature->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX()+1, m_creature->GetPositionY(), m_creature->GetPositionZ()+10);
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 2:{
         error_log("Summon Vapor case 2");
         Unit *pTarget;
         pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
         if (!pTarget) pTarget = Unit::GetUnit(*m_creature, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);
         if (pTarget)
         {
             Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, pTarget->GetPositionX()-5+rand()%10, pTarget->GetPositionY()-5+rand()%10, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
             if (Vapor)
             {
                 Vapor->AI()->AttackStart(pTarget);
                 m_creature->InterruptNonMeleeSpells(false);
                 m_creature->CastSpell(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug
                 Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true);
             }
         }
         else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;}
     case 3: {
         DespawnSummons(MOB_VAPOR_TRAIL);
         error_log("Summon Vapor case3");
         //m_creature->CastSpell(m_creature, SPELL_VAPOR_SELECT); need core support
         Unit *pTarget;
         pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
         if (!pTarget) pTarget = Unit::GetUnit(*m_creature, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);
         if (pTarget)
         {
             //pTarget->CastSpell(pTarget, SPELL_VAPOR_SUMMON, true); need core support
             Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, pTarget->GetPositionX()-5+rand()%10, pTarget->GetPositionY()-5+rand()%10, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
             if (Vapor)
             {
                 Vapor->AI()->AttackStart(pTarget);
                 m_creature->InterruptNonMeleeSpells(false);
                 m_creature->CastSpell(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug
                 Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true);
             }
         }
         else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;}
     case 4:
         DespawnSummons(MOB_VAPOR_TRAIL);
         Timer[EVENT_FLIGHT_SEQUENCE] = 1;
         break;
     case 5:{
         Unit *pTarget;
         pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
         if (!pTarget) pTarget = Unit::GetUnit(*m_creature, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);
         if (pTarget)
         {
             BreathX = pTarget->GetPositionX();
             BreathY = pTarget->GetPositionY();
             float x, y, z;
             pTarget->GetContactPoint(m_creature, x, y, z, 70);
             m_creature->GetMotionMaster()->MovePoint(0, x, y, z+10);
         }else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;}
     case 6:
         m_creature->SetOrientation(m_creature->GetAngle(BreathX, BreathY));
         m_creature->StopMoving();
         //DoTextEmote("takes a deep breath.", NULL);
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;
     case 7:
         m_creature->CastSpell(m_creature, SPELL_FOG_BREATH, true);
         {
             float x, y, z;
             m_creature->GetPosition(x, y, z);
             x = 2 * BreathX - x;
             y = 2 * BreathY - y;
             m_creature->GetMotionMaster()->MovePoint(0, x, y, z);
         }
         Timer[EVENT_SUMMON_FOG] = 1;
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 8:
         m_creature->RemoveAurasDueToSpell(SPELL_FOG_BREATH);
         ++BreathCount;
         Timer[EVENT_SUMMON_FOG] = 0;
         Timer[EVENT_FLIGHT_SEQUENCE] = 1;
         if (BreathCount < 3) FlightCount = 4;
         break;
     case 9:
         if (Unit *pTarget = SelectUnit(SELECT_TARGET_TOPAGGRO, 0))
         {
             float x, y, z;
             pTarget->GetContactPoint(m_creature, x, y, z);
             m_creature->GetMotionMaster()->MovePoint(0, x, y, z);
         }
         else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 10:
         m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
         m_creature->StopMoving();
         m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
         EnterPhase(PHASE_GROUND);
         m_creature->AI()->AttackStart(SelectUnit(SELECT_TARGET_TOPAGGRO, 0));
         break;
     default:
         break;
     }
     ++FlightCount;
 }
Beispiel #19
0
        void UpdateAI(const uint32 diff)
        {
            //Return since we have no target
            if (!UpdateVictim())
                return;

            //MortalWound_Timer
            if (MortalWound_Timer <= diff)
            {
                DoCastVictim(SPELL_MORTAL_WOUND);
                MortalWound_Timer = urand(10000, 20000);
            } else MortalWound_Timer -= diff;

            //Summon 1-3 Spawns of Fankriss at random time.
            if (SpawnSpawns_Timer <= diff)
            {
                switch (urand(0, 2))
                {
                    case 0:
                        SummonSpawn(SelectTarget(SELECT_TARGET_RANDOM, 0));
                        break;
                    case 1:
                        SummonSpawn(SelectTarget(SELECT_TARGET_RANDOM, 0));
                        SummonSpawn(SelectTarget(SELECT_TARGET_RANDOM, 0));
                        break;
                    case 2:
                        SummonSpawn(SelectTarget(SELECT_TARGET_RANDOM, 0));
                        SummonSpawn(SelectTarget(SELECT_TARGET_RANDOM, 0));
                        SummonSpawn(SelectTarget(SELECT_TARGET_RANDOM, 0));
                        break;
                }
                SpawnSpawns_Timer = urand(30000, 60000);
            } else SpawnSpawns_Timer -= diff;

            // Teleporting Random Target to one of the three tunnels and spawn 4 hatchlings near the gamer.
            //We will only telport if fankriss has more than 3% of hp so teleported gamers can always loot.
            if (HealthAbovePct(3))
            {
                if (SpawnHatchlings_Timer <= diff)
                {
                    Unit* target = NULL;
                    target = SelectTarget(SELECT_TARGET_RANDOM, 0);
                    if (target && target->GetTypeId() == TYPEID_PLAYER)
                    {
                        DoCast(target, SPELL_ROOT);

                        if (DoGetThreat(target))
                            DoModifyThreatPercent(target, -100);

                        switch (urand(0, 2))
                        {
                            case 0:
                                DoTeleportPlayer(target, -8106.0142f, 1289.2900f, -74.419533f, 5.112f);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                break;
                            case 1:
                                DoTeleportPlayer(target, -7990.135354f, 1155.1907f, -78.849319f, 2.608f);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                break;
                            case 2:
                                DoTeleportPlayer(target, -8159.7753f, 1127.9064f, -76.868660f, 0.675f);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                Hatchling = me->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Hatchling)
                                    Hatchling->AI()->AttackStart(target);
                                break;
                        }
                    }
                    SpawnHatchlings_Timer = urand(45000, 60000);
                } else SpawnHatchlings_Timer -= diff;
            }

            DoMeleeAttackIfReady();
        }
Beispiel #20
0
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        //Invisible_Timer
        if (Invisible_Timer <= diff)
        {
            me->InterruptSpell(CURRENT_GENERIC_SPELL);
            me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 0);
            me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO , 218171138);
            me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO  + 1, 3);
            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
            me->SetUInt32Value(UNIT_FIELD_DISPLAYID,11686);
            Invisible = true;

            Invisible_Timer = 15000 + rand()%15000;
        } else Invisible_Timer -= diff;

        if (Invisible)
        {
            if (Ambush_Timer <= diff)
            {
                Unit *pTarget = NULL;
                pTarget = SelectUnit(SELECT_TARGET_RANDOM,0);
                if (pTarget)
                {
                    DoTeleportTo(pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ());
                    DoCast(pTarget,SPELL_AMBUSH);
                }

                Ambushed = true;
                Ambush_Timer = 3000;
            } else Ambush_Timer -= diff;
        }

        if (Ambushed)
        {
            if (Visible_Timer <= diff)
            {
                me->InterruptSpell(CURRENT_GENERIC_SPELL);
                me->SetUInt32Value(UNIT_FIELD_DISPLAYID,15268);
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 31818);
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO , 218171138);
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO  + 1, 3);
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                Invisible = false;

                Visible_Timer = 4000;
            } else Visible_Timer -= diff;
        }

        //Resetting some aggro so he attacks other gamers
        if (!Invisible)
            if (Aggro_Timer <= diff)
        {
            Unit *pTarget = NULL;
            pTarget = SelectUnit(SELECT_TARGET_RANDOM,1);

            if (DoGetThreat(me->getVictim()))
                DoModifyThreatPercent(me->getVictim(),-50);

            if (pTarget)
                AttackStart(pTarget);

            Aggro_Timer = 7000 + rand()%13000;
        } else Aggro_Timer -= diff;

        if (!Invisible)
            if (ThousandBlades_Timer <= diff)
        {
            DoCast(me->getVictim(), SPELL_THOUSANDBLADES);
            ThousandBlades_Timer = 7000 + rand()%5000;
        } else ThousandBlades_Timer -= diff;

        DoMeleeAttackIfReady();
    }
bool
FleeingMovementGenerator<T>::_setMoveData(T &owner)
{
    float cur_dist_xyz = owner.GetDistance(i_caster_x, i_caster_y, i_caster_z);

    if(i_to_distance_from_caster > 0.0f)
    {
        if((i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz < i_to_distance_from_caster)   ||
                                                            // if we reach lower distance
           (i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz > i_last_distance_from_caster) ||
                                                            // if we can't be close
           (i_last_distance_from_caster < i_to_distance_from_caster && cur_dist_xyz > i_to_distance_from_caster)   ||
                                                            // if we reach bigger distance
           (cur_dist_xyz > MAX_QUIET_DISTANCE) ||           // if we are too far
           (i_last_distance_from_caster > MIN_QUIET_DISTANCE && cur_dist_xyz < MIN_QUIET_DISTANCE) )
                                                            // if we leave 'quiet zone'
        {
            // we are very far or too close, stopping
            i_to_distance_from_caster = 0.0f;
            i_nextCheckTime.Reset( urand(500,1000) );
            return false;
        }
        else
        {
            // now we are running, continue
            i_last_distance_from_caster = cur_dist_xyz;
            return true;
        }
    }

    float cur_dist;
    float angle_to_caster;

    Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID);

    if(fright)
    {
        cur_dist = fright->GetDistance(&owner);
        if(cur_dist < cur_dist_xyz)
        {
            i_caster_x = fright->GetPositionX();
            i_caster_y = fright->GetPositionY();
            i_caster_z = fright->GetPositionZ();
            angle_to_caster = fright->GetAngle(&owner);
        }
        else
        {
            cur_dist = cur_dist_xyz;
            angle_to_caster = owner.GetAngle(i_caster_x, i_caster_y) + M_PI_F;
        }
    }
    else
    {
        cur_dist = cur_dist_xyz;
        angle_to_caster = owner.GetAngle(i_caster_x, i_caster_y) + M_PI_F;
    }

    // if we too close may use 'path-finding' else just stop
    i_only_forward = cur_dist >= MIN_QUIET_DISTANCE/3;

    //get angle and 'distance from caster' to run
    float angle;

    if(i_cur_angle == 0.0f && i_last_distance_from_caster == 0.0f) //just started, first time
    {
        angle = rand_norm_f()*(1.0f - cur_dist/MIN_QUIET_DISTANCE) * M_PI_F/3 + rand_norm_f()*M_PI_F*2/3;
        i_to_distance_from_caster = MIN_QUIET_DISTANCE;
        i_only_forward = true;
    }
    else if(cur_dist < MIN_QUIET_DISTANCE)
    {
        angle = M_PI_F/6 + rand_norm_f()*M_PI_F*2/3;
        i_to_distance_from_caster = cur_dist*2/3 + rand_norm_f()*(MIN_QUIET_DISTANCE - cur_dist*2/3);
    }
    else if(cur_dist > MAX_QUIET_DISTANCE)
    {
        angle = rand_norm_f()*M_PI_F/3 + M_PI_F*2/3;
        i_to_distance_from_caster = MIN_QUIET_DISTANCE + 2.5f + rand_norm_f()*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE - 2.5f);
    }
    else
    {
        angle = rand_norm_f()*M_PI_F;
        i_to_distance_from_caster = MIN_QUIET_DISTANCE + 2.5f + rand_norm_f()*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE - 2.5f);
    }

    int8 sign = rand_norm_f() > 0.5f ? 1 : -1;
    i_cur_angle = sign*angle + angle_to_caster;

    // current distance
    i_last_distance_from_caster = cur_dist;

    return true;
}
Beispiel #22
0
            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                //BrainWashTotem_Timer
                if (BrainWashTotem_Timer <= diff)
                {
                    DoCast(me, SPELL_BRAINWASHTOTEM);
                    BrainWashTotem_Timer = 18000 + rand()%8000;
                } else BrainWashTotem_Timer -= diff;

                //HealingWard_Timer
                if (HealingWard_Timer <= diff)
                {
                    //DoCast(me, SPELL_POWERFULLHEALINGWARD);
                    me->SummonCreature(14987, me->GetPositionX()+3, me->GetPositionY()-2, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000);
                    HealingWard_Timer = 14000 + rand()%6000;
                } else HealingWard_Timer -= diff;

                //Hex_Timer
                if (Hex_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_HEX);

                    if (DoGetThreat(me->getVictim()))
                        DoModifyThreatPercent(me->getVictim(), -80);

                    Hex_Timer = 12000 + rand()%8000;
                } else Hex_Timer -= diff;

                //Casting the delusion curse with a shade. So shade will attack the same target with the curse.
                if (Delusions_Timer <= diff)
                {
                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                    {
                        DoCast(pTarget, SPELL_DELUSIONSOFJINDO);

                        Creature *Shade = me->SummonCreature(14986, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Shade)
                            Shade->AI()->AttackStart(pTarget);
                    }

                    Delusions_Timer = 4000 + rand()%8000;
                } else Delusions_Timer -= diff;

                //Teleporting a random gamer and spawning 9 skeletons that will attack this gamer
                if (Teleport_Timer <= diff)
                {
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                    if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
                    {
                        DoTeleportPlayer(pTarget, -11583.7783f, -1249.4278f, 77.5471f, 4.745f);

                        if (DoGetThreat(me->getVictim()))
                            DoModifyThreatPercent(pTarget, -100);

                        Creature *Skeletons;
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX()+2, pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX()-2, pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX()+4, pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX()-4, pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX(), pTarget->GetPositionY()+2, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX(), pTarget->GetPositionY()-2, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX(), pTarget->GetPositionY()+4, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX(), pTarget->GetPositionY()-4, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX()+3, pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                    }

                    Teleport_Timer = 15000 + rand()%8000;
                } else Teleport_Timer -= diff;

                DoMeleeAttackIfReady();
            }
        void UpdateAI(uint32 const diff)
        {
            //Inhibitmagic_Timer
            if (Inhibitmagic_Timer <= diff)
            {
                float dist;
                Map* pMap = me->GetMap();
                Map::PlayerList const &PlayerList = pMap->GetPlayers();
                for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                    if (Player* i_pl = i->getSource())
                        if (i_pl->isAlive() && (dist = i_pl->IsWithinDist(me, 45)))
                        {
                            i_pl->RemoveAurasDueToSpell(SPELL_INHIBITMAGIC);
                            me->AddAura(SPELL_INHIBITMAGIC, i_pl);
                            if (dist < 35)
                                me->AddAura(SPELL_INHIBITMAGIC, i_pl);
                            if (dist < 25)
                                me->AddAura(SPELL_INHIBITMAGIC, i_pl);
                            if (dist < 15)
                                me->AddAura(SPELL_INHIBITMAGIC, i_pl);
                        }
                Inhibitmagic_Timer = 3000+(rand()%1000);
            } else Inhibitmagic_Timer -= diff;

            //Return since we have no target
            if (!UpdateVictim())
                return;

            //Attractmagic_Timer
            if (Attractmagic_Timer <= diff)
            {
                DoCast(me, SPELL_ATTRACTMAGIC);
                Attractmagic_Timer = 30000;
                Carnivorousbite_Timer = 1500;
            } else Attractmagic_Timer -= diff;

            //Carnivorousbite_Timer
            if (Carnivorousbite_Timer <= diff)
            {
                DoCast(me, SPELL_CARNIVOROUSBITE);
                Carnivorousbite_Timer = 10000;
            } else Carnivorousbite_Timer -= diff;

            //FocusFire_Timer
            if (FocusFire_Timer <= diff)
            {
                // Summon Focus Fire & Emote
                Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1);
                if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER && pTarget->isAlive())
                {
                    FocusedTargetGUID = pTarget->GetGUID();
                    me->SummonCreature(ENTRY_FOCUS_FIRE, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 5500);

                    // TODO: Find better way to handle emote
                    // Emote
                    std::string *emote = new std::string(EMOTE_FOCUSES_ON);
                    emote->append(pTarget->GetName());
                    emote->append("!");
                    const char* text = emote->c_str();
                    me->MonsterTextEmote(text, 0, true);
                    delete emote;
                }
                FocusFire_Timer = 15000+(rand()%5000);
            } else FocusFire_Timer -= diff;

            DoMeleeAttackIfReady();
        }
Beispiel #24
0
bool DeathGrip(uint32 i, Spell* s)
{
    Unit* unitTarget = s->GetUnitTarget();

    if(!s->u_caster || !s->u_caster->isAlive() || !unitTarget || !unitTarget->isAlive())
        return false;

    // rooted units can't be death gripped
    if(unitTarget->isRooted())
        return false;

    if(unitTarget->IsPlayer())
    {
        Player* playerTarget = static_cast< Player* >(unitTarget);

        if(playerTarget->m_CurrentTransporter) // Blizzard screwed this up, so we won't.
            return false;

        s->SpellEffectPlayerPull(i);

        return false;

    }
    else
    {
        float posX, posY, posZ;
        float deltaX, deltaY;

        if(s->u_caster->GetPositionX() == 0.0f || s->u_caster->GetPositionY() == 0.0f)
            return false;

        deltaX = s->u_caster->GetPositionX() - unitTarget->GetPositionX();
        deltaY = s->u_caster->GetPositionY() - unitTarget->GetPositionY();

        if(deltaX == 0.0f || deltaY == 0.0f)
            return false;

        float d = sqrt(deltaX * deltaX + deltaY * deltaY) - s->u_caster->GetBoundingRadius() - unitTarget->GetBoundingRadius();

        float alpha = atanf(deltaY / deltaX);

        if(deltaX < 0)
            alpha += M_PI_FLOAT;

        posX = d * cosf(alpha) + unitTarget->GetPositionX();
        posY = d * sinf(alpha) + unitTarget->GetPositionY();
        posZ = s->u_caster->GetPositionZ();

        uint32 time = uint32((unitTarget->CalcDistance(s->m_caster) / ((unitTarget->m_runSpeed * 3.5) * 0.001f)) + 0.5);

        WorldPacket data(SMSG_MONSTER_MOVE, 60);
        data << unitTarget->GetNewGUID();
        data << uint8(0); //VLack: the usual change in SMSG_MONSTER_MOVE packets, initial idea from Mangos
        data << unitTarget->GetPositionX();
        data << unitTarget->GetPositionY();
        data << unitTarget->GetPositionZ();
        data << getMSTime();
        data << uint8(0x00);
        data << uint32(0x00001000);
        data << time;
        data << uint32(1);
        data << posX << posY << posZ;

        if(unitTarget->IsCreature())
            unitTarget->GetAIInterface()->StopMovement(2000);

        unitTarget->SendMessageToSet(&data, true);
        unitTarget->SetPosition(posX, posY, posZ, alpha, true);
        unitTarget->addStateFlag(UF_ATTACKING);
        unitTarget->smsg_AttackStart(unitTarget);
        unitTarget->setAttackTimer(time, false);
        unitTarget->setAttackTimer(time, true);
        unitTarget->GetAIInterface()->taunt(s->u_caster, true);
    }

    return true;
}
Beispiel #25
0
        void HandleFlightSequence()
        {
            switch (uiFlightCount)
            {
            case 0:
                //me->AttackStop();
                me->GetMotionMaster()->Clear(false);
                me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
                me->StopMoving();
                DoScriptText(YELL_TAKEOFF, me);
                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 2000);
                break;
            case 1:
                me->GetMotionMaster()->MovePoint(0, me->GetPositionX()+1, me->GetPositionY(), me->GetPositionZ()+10);
                break;
            case 2:
            {
                Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
                if (!target)
                    target = Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);

                if (!target)
                {
                    EnterEvadeMode();
                    return;
                }

                Creature* Vapor = me->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
                if (Vapor)
                {
                    Vapor->AI()->AttackStart(target);
                    me->InterruptNonMeleeSpells(false);
                    DoCast(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug
                    Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true);
                }

                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000);
                break;
            }
            case 3:
            {
                DespawnSummons(MOB_VAPOR_TRAIL);
                //DoCast(me, SPELL_VAPOR_SELECT); need core support

                Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
                if (!target)
                    target = Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);

                if (!target)
                {
                    EnterEvadeMode();
                    return;
                }

                //pTarget->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support
                Creature* pVapor = me->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
                if (pVapor)
                {
                    if (pVapor->AI())
                        pVapor->AI()->AttackStart(target);
                    me->InterruptNonMeleeSpells(false);
                    DoCast(pVapor, SPELL_VAPOR_CHANNEL, false); // core bug
                    pVapor->CastSpell(pVapor, SPELL_VAPOR_TRIGGER, true);
                }

                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000);
                break;
            }
            case 4:
                DespawnSummons(MOB_VAPOR_TRAIL);
                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1);
                break;
            case 5:
            {
                Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
                if (!target)
                    target = Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);

                if (!target)
                {
                    EnterEvadeMode();
                    return;
                }

                breathX = target->GetPositionX();
                breathY = target->GetPositionY();
                float x, y, z;
                target->GetContactPoint(me, x, y, z, 70);
                me->GetMotionMaster()->MovePoint(0, x, y, z+10);
                break;
            }
            case 6:
                me->SetOrientation(me->GetAngle(breathX, breathY));
                me->StopMoving();
                //DoTextEmote("takes a deep breath.", NULL);
                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 10000);
                break;
            case 7:
            {
                DoCast(me, SPELL_FOG_BREATH, true);
                float x, y, z;
                me->GetPosition(x, y, z);
                x = 2 * breathX - x;
                y = 2 * breathY - y;
                me->GetMotionMaster()->MovePoint(0, x, y, z);
                events.ScheduleEvent(EVENT_SUMMON_FOG, 1);
                break;
            }
            case 8:
                me->CastStop(SPELL_FOG_BREATH);
                me->RemoveAurasDueToSpell(SPELL_FOG_BREATH);
                ++uiBreathCount;
                events.ScheduleEvent(EVENT_FLIGHT_SEQUENCE, 1);
                if (uiBreathCount < 3)
                    uiFlightCount = 4;
                break;
            case 9:
                if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO))
                    DoStartMovement(target);
                else
                {
                    EnterEvadeMode();
                    return;
                }
                break;
            case 10:
                me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
                me->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
                EnterPhase(PHASE_GROUND);
                AttackStart(SelectTarget(SELECT_TARGET_TOPAGGRO));
                break;
            }
            ++uiFlightCount;
        }
Beispiel #26
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        //BrainWashTotem_Timer
        if (BrainWashTotem_Timer < diff)
        {
            DoCastSpellIfCan(m_creature, SPELL_BRAINWASHTOTEM);
            BrainWashTotem_Timer = urand(18000, 26000);
        }else BrainWashTotem_Timer -= diff;

        //HealingWard_Timer
        if (HealingWard_Timer < diff)
        {
            //DoCastSpellIfCan(m_creature, SPELL_POWERFULLHEALINGWARD);
            m_creature->SummonCreature(14987, m_creature->GetPositionX()+3, m_creature->GetPositionY()-2, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,30000);
            HealingWard_Timer = urand(14000, 20000);
        }else HealingWard_Timer -= diff;

        //Hex_Timer
        if (Hex_Timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(), SPELL_HEX);

            if (m_creature->getThreatManager().getThreat(m_creature->getVictim()))
                m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-80);

            Hex_Timer = urand(12000, 20000);
        }else Hex_Timer -= diff;

        //Casting the delusion curse with a shade. So shade will attack the same target with the curse.
        if (Delusions_Timer < diff)
        {
            if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
            {
                DoCastSpellIfCan(target, SPELL_DELUSIONSOFJINDO);

                Creature *Shade = m_creature->SummonCreature(14986, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Shade)
                    Shade->AI()->AttackStart(target);
            }

            Delusions_Timer = urand(4000, 12000);
        }else Delusions_Timer -= diff;

        //Teleporting a random gamer and spawning 9 skeletons that will attack this gamer
        if (Teleport_Timer < diff)
        {
            Unit* target = NULL;
            target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);
            if (target && target->GetTypeId() == TYPEID_PLAYER)
            {
                DoTeleportPlayer(target, -11583.7783f, -1249.4278f, 77.5471f, 4.745f);

                if (m_creature->getThreatManager().getThreat(m_creature->getVictim()))
                    m_creature->getThreatManager().modifyThreatPercent(target,-100);

                Creature *Skeletons;
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+2, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()-2, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+4, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()-4, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()+2, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()-2, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()+4, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()-4, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+3, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
            }

            Teleport_Timer = urand(15000, 23000);
        }else Teleport_Timer -= diff;

        DoMeleeAttackIfReady();
    }
Beispiel #27
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostilTarget() || !m_creature->getVictim())
            return;

        //Invisible_Timer
        if (Invisible_Timer < diff)
        {
            m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);

            m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+0, 0);
            m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,11686);

            m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
            Invisible = true;

            Invisible_Timer = 15000 + rand()%15000;
        }else Invisible_Timer -= diff;

        if (Invisible)
        {
            if (Ambush_Timer < diff)
            {
                Unit* target = NULL;
                target = SelectUnit(SELECT_TARGET_RANDOM,0);
                if (target)
                {
                    m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0);
                    m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1);
                    DoCast(target,SPELL_AMBUSH);
                }

                Ambushed = true;
                Ambush_Timer = 3000;
            }else Ambush_Timer -= diff;
        }

        if (Ambushed)
        {
            if (Visible_Timer < diff)
            {
                m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);

                m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID, 15268);
                m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+0, ITEM_ID_MAIN_HAND);

                m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                Invisible = false;

                Visible_Timer = 4000;
            }else Visible_Timer -= diff;
        }

        //Resetting some aggro so he attacks other gamers
        if(!Invisible)
            if (Aggro_Timer < diff)
        {
            Unit* target = NULL;
            target = SelectUnit(SELECT_TARGET_RANDOM,1);

            if(m_creature->getThreatManager().getThreat(m_creature->getVictim()))
                m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-50);

            if (target)
                AttackStart(target);

            Aggro_Timer = 7000 + rand()%13000;
        }else Aggro_Timer -= diff;

        if (!Invisible)
            if(ThousandBlades_Timer < diff)
        {
            DoCast(m_creature->getVictim(), SPELL_THOUSANDBLADES);
            ThousandBlades_Timer = 7000 + rand()%5000;
        }else ThousandBlades_Timer -= diff;

        DoMeleeAttackIfReady();
    }
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        // Pounding
        if (Pounding_Timer <= diff)
        {
            DoCast(me->getVictim(),SPELL_POUNDING);

            switch (rand()%2)
            {
            case 0: DoScriptText(SAY_POUNDING1, me); break;
            case 1: DoScriptText(SAY_POUNDING2, me); break;
            }
             Pounding_Timer = 15000;                         //cast time(3000) + cooldown time(12000)
        } else Pounding_Timer -= diff;

        // Arcane Orb
        if (ArcaneOrb_Timer <= diff)
        {
            if (me->IsNonMeleeSpellCasted(false))
            {
                ArcaneOrb_Timer = 3000;
                return;
            }
            Unit* pTarget = NULL;
            std::list<HostileReference *> t_list = me->getThreatManager().getThreatList();
            std::vector<Unit* > target_list;
            for (std::list<HostileReference *>::iterator itr = t_list.begin(); itr != t_list.end(); ++itr)
            {
                pTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                                                            //18 yard radius minimum
                if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER && pTarget->isAlive() && pTarget->GetDistance2d(me) >= 18)
                    target_list.push_back(pTarget);
                pTarget = NULL;
            }
            if (target_list.size())
                pTarget = *(target_list.begin()+rand()%target_list.size());

            if (pTarget)
                me->CastSpell(pTarget->GetPositionX(),pTarget->GetPositionY(),pTarget->GetPositionZ(), SPELL_ARCANE_ORB, false);

            ArcaneOrb_Timer = 3000;
        } else ArcaneOrb_Timer -= diff;

        // Single Target knock back, reduces aggro
        if (KnockAway_Timer <= diff)
        {
            DoCast(me->getVictim(),SPELL_KNOCK_AWAY);

            //Drop 25% aggro
            if (DoGetThreat(me->getVictim()))
                DoModifyThreatPercent(me->getVictim(), -25);

            KnockAway_Timer = 30000;
        } else KnockAway_Timer -= diff;

        //Berserk
        if (Berserk_Timer <= diff && !Enraged)
        {
            DoCast(me,SPELL_BERSERK);
            Enraged = true;
        } else Berserk_Timer -= diff;

        DoMeleeAttackIfReady();
    }
Beispiel #29
0
    void UpdateAI(const uint32 uiDiff)
    {
        // Check if we have a target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        // EvadeTimer
        if (m_creature->CanReachWithMeleeAttack(m_creature->getVictim()))
        {
            if (m_uiEvadeTimer < uiDiff)
            {
                if (Creature* pCreature = m_creature->GetMap()->GetCreature(m_portalGuid))
                    pCreature->DealDamage(pCreature, pCreature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false);

                // Dissapear and reappear at new position
                m_creature->SetVisibility(VISIBILITY_OFF);

                Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);

                if (!target)
                {
                    m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false);
                    return;
                }

                if (!target->HasAura(SPELL_DIGESTIVE_ACID, EFFECT_INDEX_0))
                {
                    m_creature->GetMap()->CreatureRelocation(m_creature, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0);

                    if (Unit* pPortal = m_creature->SummonCreature(MOB_GIANT_PORTAL, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 0))
                        m_portalGuid = pPortal->GetObjectGuid();

                    m_uiGroundRuptureTimer = 500;
                    m_uiHamstringTimer = 2000;
                    m_uiThrashTimer = 5000;
                    m_uiEvadeTimer = 5000;
                    AttackStart(target);
                }

                m_creature->SetVisibility(VISIBILITY_ON);

            }
            else
                m_uiEvadeTimer -= uiDiff;
        }

        // GroundRuptureTimer
        if (m_uiGroundRuptureTimer < uiDiff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_GROUND_RUPTURE);
            m_uiGroundRuptureTimer = 30000;
        }
        else
            m_uiGroundRuptureTimer -= uiDiff;

        // ThrashTimer
        if (m_uiThrashTimer < uiDiff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_THRASH);
            m_uiThrashTimer = 10000;
        }
        else
            m_uiThrashTimer -= uiDiff;

        // HamstringTimer
        if (m_uiHamstringTimer < uiDiff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_HAMSTRING);
            m_uiHamstringTimer = 10000;
        }
        else
            m_uiHamstringTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }
        void UpdateAI(uint32 const diff)
        {
            if (!UpdateVictim())
                return;

            switch (m_uiStage)
            {
                case 0:
                    if (m_uiFerociousButtTimer <= diff)
                    {
                        DoCastVictim(SPELL_FEROCIOUS_BUTT);
                        m_uiFerociousButtTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
                    } else m_uiFerociousButtTimer -= diff;

                    if (m_uiArticBreathTimer <= diff)
                    {
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            DoCast(target, SPELL_ARCTIC_BREATH);
                        m_uiArticBreathTimer = urand(25*IN_MILLISECONDS, 40*IN_MILLISECONDS);
                    } else m_uiArticBreathTimer -= diff;

                    if (m_uiWhirlTimer <= diff)
                    {
                        DoCastAOE(SPELL_WHIRL);
                        m_uiWhirlTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
                    } else m_uiWhirlTimer -= diff;

                    if (m_uiMassiveCrashTimer <= diff)
                    {
                        me->GetMotionMaster()->MoveJump(ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY(), ToCCommonLoc[1].GetPositionZ(), 10.0f, 20.0f); // 1: Middle of the room
                        m_uiStage = 7; //Invalid (Do nothing more than move)
                        m_uiMassiveCrashTimer = 30*IN_MILLISECONDS;
                    } else m_uiMassiveCrashTimer -= diff;

                    DoMeleeAttackIfReady();
                    break;
                case 1:
                    DoCastAOE(SPELL_MASSIVE_CRASH);
                    m_uiStage = 2;
                    break;
                case 2:
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0, true))
                    {
                        m_uiTrampleTargetGUID = target->GetGUID();
                        me->SetTarget(m_uiTrampleTargetGUID);
                        DoScriptText(SAY_TRAMPLE_STARE, me, target);
                        m_bTrampleCasted = false;
                        SetCombatMovement(false);
                        me->GetMotionMaster()->MoveIdle();
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                        m_uiTrampleTimer = 4*IN_MILLISECONDS;
                        m_uiStage = 3;
                    } else m_uiStage = 6;
                    break;
                case 3:
                    if (m_uiTrampleTimer <= diff)
                    {
                        if (Unit* target = Unit::GetPlayer(*me, m_uiTrampleTargetGUID))
                        {
                            m_bTrampleCasted = false;
                            m_bMovementStarted = true;
                            m_fTrampleTargetX = target->GetPositionX();
                            m_fTrampleTargetY = target->GetPositionY();
                            m_fTrampleTargetZ = target->GetPositionZ();
                            me->GetMotionMaster()->MoveJump(2*me->GetPositionX()-m_fTrampleTargetX,
                                2*me->GetPositionY()-m_fTrampleTargetY,
                                me->GetPositionZ(),
                                10.0f, 20.0f); // 2: Hop Backwards
                            m_uiStage = 7; //Invalid (Do nothing more than move)
                        } else m_uiStage = 6;
                    } else m_uiTrampleTimer -= diff;
                    break;
                case 4:
                    DoScriptText(SAY_TRAMPLE_START, me);
                    me->GetMotionMaster()->MoveCharge(m_fTrampleTargetX, m_fTrampleTargetY, m_fTrampleTargetZ+2, 42, 1);
                    me->SetTarget(0);
                    m_uiStage = 5;
                    break;
                case 5:
                    if (m_bMovementFinish)
                    {
                        if (m_uiTrampleTimer <= diff) DoCastAOE(SPELL_TRAMPLE);
                        m_bMovementFinish = false;
                        m_uiStage = 6;
                        return;
                    }
                    if (m_uiTrampleTimer <= diff)
                    {
                        Map::PlayerList const &lPlayers = me->GetMap()->GetPlayers();
                        for (Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr)
                        {
                            if (Unit* player = itr->getSource())
                                if (player->isAlive() && player->IsWithinDistInMap(me, 6.0f))
                                {
                                    DoCastAOE(SPELL_TRAMPLE);
                                    m_uiTrampleTimer = IN_MILLISECONDS;
                                    break;
                                }
                        }
                    } else m_uiTrampleTimer -= diff;
                    break;
                case 6:
                    if (!m_bTrampleCasted)
                    {
                        DoCast(me, SPELL_STAGGERED_DAZE);
                        DoScriptText(SAY_TRAMPLE_FAIL, me);
                    }
                    m_bMovementStarted = false;
                    me->GetMotionMaster()->MovementExpired();
                    me->GetMotionMaster()->MoveChase(me->getVictim());
                    SetCombatMovement(true);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    m_uiStage = 0;
                    break;
            }
        }