示例#1
0
 void doTriggerUnoculated()
 {
      for(uint8 i = 0; i < MAX_SPORE_TARGETS; ++i)
          if (spored[i])
             if (!hasAura(SPELL_SPORE_AURA_1,spored[i]))
             {
                doCast(SPELL_INOCULATE,spored[i]);
                spored[i] = NULL;
             }
 }
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_pInstance)
            return;

        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (hasAura(SPELL_INVOCATION_OF_BLOOD_V))
        {
            if (!invocated)
            {
                DoScriptText(-1631307,m_creature);
                m_creature->SetHealth(m_health);
                invocated = true;
            }
            if (timedQuery(SPELL_INVOCATION_OF_BLOOD_V, uiDiff))
            {
                if (doCast(urand(0,1) ? SPELL_INVOCATION_OF_BLOOD_K : SPELL_INVOCATION_OF_BLOOD_T) == CAST_OK)
                {
                    doRemove(SPELL_INVOCATION_OF_BLOOD_V);
                    invocated = false;
                    m_health = m_creature->GetHealth();
                    m_creature->SetHealth(1);
                }
            }
            timedCast(SPELL_KINETIC_BOMB, uiDiff);
            timedCast(SPELL_SHOCK_VORTEX_2, uiDiff);
        }
        else
        {

            timedCast(SPELL_KINETIC_BOMB, uiDiff);
            timedCast(SPELL_SHOCK_VORTEX, uiDiff);
        }

        if (timedQuery(SPELL_BERSERK, uiDiff))
        {
             doCast(SPELL_BERSERK);
             DoScriptText(-1631305,m_creature);
         };

        DoMeleeAttackIfReady();
    }
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        switch(getStage())
        {
            case 0: 
                    if (timedQuery(SPELL_BONE_STRIKE, diff))
                        if (Unit* pTarget = doSelectRandomPlayer(SPELL_BONE_STRIKE_IMPALE, false, 60.0f))
                            if (doCast(SPELL_BONE_STRIKE, pTarget) == CAST_OK)
                            {
                                doSummonSpike(pTarget);
                                switch (urand(0,1)) {
                                                   case 0:
                                                   DoScriptText(-1631003,m_creature,pTarget);
                                                   break;
                                                   case 1:
                                                   DoScriptText(-1631004,m_creature,pTarget);
                                                   break;
                                                   case 2:
                                                   DoScriptText(-1631005,m_creature,pTarget);
                                                   break;
                                                   };

                            };

                    if (timedQuery(SPELL_BONE_STORM, diff)) setStage(1);

                    if (timedQuery(SPELL_CALL_COLD_FLAME, diff))
                    {
                        if (urand(0,1)) doCast(SPELL_CALL_COLD_FLAME);
                            else  doCast(SPELL_CALL_COLD_FLAME_1);

                        if (m_creature->GetHealthPercent() <= 30.0f)
                        {
                            if (urand(0,1)) doCast(SPELL_CALL_COLD_FLAME);
                                else  doCast(SPELL_CALL_COLD_FLAME_1);
                        }
                    }

                    timedCast(SPELL_SABER_LASH, diff);

                    DoMeleeAttackIfReady();

                    break;
            case 1:
                    m_creature->InterruptNonMeleeSpells(true);
                    doCast(SPELL_BONE_STORM);
                    setStage(2);
                    DoScriptText(-1631002,m_creature);
                    DoResetThreat();
                    m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE);
                    m_creature->SetSpeedRate(MOVE_RUN, 3);
                    m_creature->SetSpeedRate(MOVE_WALK, 3);
                    break;
            case 2:
                    if (!m_creature->IsNonMeleeSpellCasted(false)) setStage(3);
                    break;
            case 3:
                    if (isHeroic())
                        if (timedQuery(SPELL_BONE_STRIKE, diff, true))
                            if (Unit* pTarget = doSelectRandomPlayer(SPELL_BONE_STRIKE_IMPALE, false, 60.0f))
                                doSummonSpike(pTarget);

                    if (timedQuery(SPELL_CALL_COLD_FLAME, diff, true)
                        && m_creature->IsWithinDistInMap(m_creature->getVictim(),2.0f))
                    {
                        pInstance->SetData(DATA_DIRECTION, (uint32)(1000*2.0f*M_PI_F*((float)urand(1,16)/16.0f)));
//                        if (urand(0,1)) doCast(SPELL_CALL_COLD_FLAME);
//                            else  doCast(SPELL_CALL_COLD_FLAME_1);
                        float fPosX, fPosY, fPosZ;
                        m_creature->GetPosition(fPosX, fPosY, fPosZ);
                        doSummon(NPC_COLD_FLAME, fPosX, fPosY, fPosZ);
                        DoResetThreat();
                        if (Unit* pTarget = doSelectRandomPlayerAtRange(60.0f))
                            AttackStart(pTarget);
                    }
                    if (!hasAura(SPELL_BONE_STORM_STRIKE, m_creature) && !hasAura(SPELL_BONE_STORM, m_creature)) setStage(4);
                    break;
            case 4:
                    pInstance->SetData(DATA_DIRECTION, 0);
                    m_creature->SetSpeedRate(MOVE_RUN, 1);
                    m_creature->SetSpeedRate(MOVE_WALK, 1);
//                    m_creature->AddSplineFlag(SPLINEFLAG_WALKMODE);
                    setStage(0);
                    break;
            default:
                    break;
            }

        if (timedQuery(SPELL_BERSERK, diff))
            {
                doCast(SPELL_BERSERK);
                DoScriptText(-1631008,m_creature);
            }


    }
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        switch(getStage())
        {
            case 0: // Bone Slice and single Coldflames phase
            {
                if (timedQuery(SPELL_BONE_SPIKE, diff))
                {
                    if (Unit* pTarget = doSelectRandomPlayer(SPELL_BONE_SPIKE_IMPALE, false, 60.0f, isHeroic()))
                    {
                        doCast(pTarget, SPELL_BONE_SPIKE);
                        DoSummonSpike(pTarget);
                        DoScriptText(-1631003 - urand(0,2), m_creature, pTarget);
                    }
                }

                if (timedQuery(SPELL_BONE_STORM, diff))
                    setStage(1);

                if (timedQuery(SPELL_CALL_COLD_FLAME, diff))
                    doCast(SPELL_CALL_COLD_FLAME);

                if (m_uiSliceTimer <= 1000)
                {
                    if (m_uiSliceTimer <= diff)
                    {
                        doCast(SPELL_BONE_SLICE, m_creature->getVictim());
                        m_uiSliceTimer = 1000;
                    }
                    else
                        m_uiSliceTimer -= diff;
                }
                else
                    m_uiSliceTimer -= diff;

                DoMeleeAttackIfReady();
                break;
            }
            case 1: // Bone Storm initialization phase
            {
                m_creature->InterruptNonMeleeSpells(true);
                doCast(SPELL_BONE_STORM);
                DoScriptText(-1631002,m_creature);
                SetCombatMovement(false);
                m_creature->GetMotionMaster()->Clear();
                m_creature->SetSpeedRate(MOVE_RUN, 3);
                // initial X Coldflames are in Marrowgar's place
                m_creature->GetPosition(targetPosX, targetPosY, targetPosZ);
                setStage(2);
                break;
            }
            case 2: // Bone Storm waiting to end casting the spell
            {
                if (!m_creature->IsNonMeleeSpellCasted(false))
                    setStage(3);
                break;
            }
            case 3: // Whirling in Bone Storm and casting Cold Flames
            {
                if (isHeroic())
                {
                    if (timedQuery(SPELL_BONE_SPIKE, diff))
                    {
                        if (Unit* pTarget = doSelectRandomPlayer(SPELL_BONE_SPIKE_IMPALE, false, 60.0f, isHeroic()))
                        {
                            doCast(pTarget, SPELL_BONE_SPIKE);
                            DoSummonSpike(pTarget);
                            DoScriptText(-1631003 - urand(0,2), m_creature, pTarget);
                        }
                    }
                }

                if (m_creature->GetDistance2d(targetPosX, targetPosY) < 5.0f)
                {
                    if (!m_bIsColdFlameXCast)
                    {
                        
                        float myPosX, myPosY, myPosZ;

                        m_creature->GetPosition(myPosX, myPosY, myPosZ);

                        m_pInstance->SetData(DATA_DIRECTION, (uint32)(1000*2.0f*M_PI_F*((float)urand(1,16)/16.0f)));
                        doCast(SPELL_CALL_COLD_FLAME);
                        doSummon(NPC_COLD_FLAME, myPosX, myPosY, myPosZ);

                        if (++m_uiColdFlameCounter >= 4 + isHeroic())
                        {
                            doRemove(SPELL_BONE_STORM_STRIKE);
                            doRemove(SPELL_BONE_STORM);
                        }
                        m_bIsColdFlameXCast = true;
                    }

                    if (m_uiBoneStormChargeTimer <= diff)
                    {
                        if (Unit* pTarget = doSelectRandomPlayerAtRange(60.0f))
                        {
                            pTarget->GetPosition(targetPosX, targetPosY, targetPosZ);
                            m_creature->GetMotionMaster()->MovePoint(0, targetPosX, targetPosY, targetPosZ);
                            m_bIsColdFlameXCast = false;
                            m_uiBoneStormChargeTimer = 3000;
                        }
                    }
                    else
                        m_uiBoneStormChargeTimer -= diff;
                }

                if (!hasAura(SPELL_BONE_STORM_STRIKE, m_creature) && !hasAura(SPELL_BONE_STORM, m_creature))
                    setStage(4);

                break;
            }
            case 4:
            {
                m_pInstance->SetData(DATA_DIRECTION, 0);
                m_creature->SetSpeedRate(MOVE_RUN, 1);
                m_uiColdFlameCounter = 0;
                SetCombatMovement(true);
                m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                m_uiSliceTimer = 10000;
                setStage(0);
                break;
            }
            default:
                break;
        }

        if (timedQuery(SPELL_BERSERK, diff))
        {
            doCast(SPELL_BERSERK);
            DoScriptText(-1631008, m_creature);
        }
    }