Ejemplo n.º 1
0
    void UpdateAI(const uint32 uiDiff)
    {
        // Splitted
        if (m_creature->GetVisibility() == VISIBILITY_OFF)
        {
            if (!m_creature->getVictim())
            {
                Reset();
                return;
            }

            if (m_uiSplit_Timer < uiDiff)
            {
                m_uiSplit_Timer = 2500;

                // Return sparks to where Ionar splitted
                if (m_bIsSplitPhase)
                {
                    CallBackSparks();
                    m_bIsSplitPhase = false;
                }
                // Lightning effect and restore Ionar
                else if (m_uiSparkAtHomeCount == MAX_SPARKS)
                {
                    m_creature->SetVisibility(VISIBILITY_ON);
                    m_creature->CastSpell(m_creature, SPELL_SPARK_DESPAWN, false);

                    DespawnSpark();

                    m_uiSparkAtHomeCount = 0;
                    m_uiSplit_Timer = 25000;
                    m_bIsSplitPhase = true;

                    if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE)
                    {
                        if (m_creature->getVictim())
                            m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                    }
                }
            }
            else
                m_uiSplit_Timer -= uiDiff;

            return;
        }

        //Return since we have no target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_uiStaticOverload_Timer < uiDiff)
        {
            if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                DoCast(pTarget, m_bIsRegularMode ? SPELL_STATIC_OVERLOAD_N : SPELL_STATIC_OVERLOAD_H);

            m_uiStaticOverload_Timer = urand(5000, 6000);
        }
        else
            m_uiStaticOverload_Timer -= uiDiff;

        if (m_uiBallLightning_Timer < uiDiff)
        {
            DoCast(m_creature->getVictim(), m_bIsRegularMode ? SPELL_BALL_LIGHTNING_N : SPELL_BALL_LIGHTNING_H);
            m_uiBallLightning_Timer = urand(10000, 11000);
        }
        else
            m_uiBallLightning_Timer -= uiDiff;

        // Health check
        if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < (100-(20*m_uiHealthAmountModifier)))
        {
            ++m_uiHealthAmountModifier;

            DoScriptText(urand(0, 1) ? SAY_SPLIT_1 : SAY_SPLIT_2, m_creature);

            if (m_creature->IsNonMeleeSpellCasted(false))
                m_creature->InterruptNonMeleeSpells(false);

            DoCast(m_creature, SPELL_DISPERSE);
        }

        DoMeleeAttackIfReady();
    }
Ejemplo n.º 2
0
        void UpdateAI(uint32 uiDiff)
        {
            //Return since we have no target
            if (!UpdateVictim())
                return;

            // Splitted
            if (!me->IsVisible())
            {
                if (uiSplitTimer <= uiDiff)
                {
                    uiSplitTimer = 2500;

                    // Return sparks to where Ionar splitted
                    if (bIsSplitPhase)
                    {
                        CallBackSparks();
                        bIsSplitPhase = false;
                    }
                    // Lightning effect and restore Ionar
                    else if (lSparkList.empty())
                    {
                        me->SetVisible(true);
                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_DISABLE_MOVE);

                        DoCast(me, SPELL_SPARK_DESPAWN, false);

                        uiSplitTimer = 25*IN_MILLISECONDS;
                        bIsSplitPhase = true;

                        if (me->getVictim())
                            me->GetMotionMaster()->MoveChase(me->getVictim());
                    }
                }
                else
                    uiSplitTimer -= uiDiff;

                return;
            }

            if (uiStaticOverloadTimer <= uiDiff)
            {
                if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                    DoCast(target, SPELL_STATIC_OVERLOAD);

                uiStaticOverloadTimer = urand(5*IN_MILLISECONDS, 6*IN_MILLISECONDS);
            }
            else
                uiStaticOverloadTimer -= uiDiff;

            if (uiBallLightningTimer <= uiDiff)
            {
                DoCast(me->getVictim(), SPELL_BALL_LIGHTNING);
                uiBallLightningTimer = urand(10*IN_MILLISECONDS, 11*IN_MILLISECONDS);
            }
            else
                uiBallLightningTimer -= uiDiff;

            // Health check
            if (!bHasDispersed && HealthBelowPct(uiDisperseHealth))
            {
                bHasDispersed = true;

                Talk(SAY_SPLIT);

                if (me->IsNonMeleeSpellCasted(false))
                    me->InterruptNonMeleeSpells(false);

                DoCast(me, SPELL_DISPERSE, false);
            }

            DoMeleeAttackIfReady();
        }
Ejemplo n.º 3
0
    void UpdateAI(const uint32 uiDiff) override
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        // Splitted
        if (m_creature->GetVisibility() == VISIBILITY_OFF)
        {
            if (m_uiSplitTimer < uiDiff)
            {
                m_uiSplitTimer = 2500;

                // Return sparks to where Ionar splitted
                if (m_bIsSplitPhase)
                {
                    CallBackSparks();
                    m_bIsSplitPhase = false;
                }
                // Lightning effect and restore Ionar
                else if (m_uiSparkAtHomeCount == MAX_SPARKS)
                {
                    m_creature->SetVisibility(VISIBILITY_ON);
                    DoCastSpellIfCan(m_creature, SPELL_SPARK_DESPAWN);

                    m_uiSparkAtHomeCount = 0;
                    m_uiSplitTimer = 25000;
                    m_bIsSplitPhase = true;
                    m_bIsDesperseCasting = false;

                    if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE)
                    {
                        if (m_creature->getVictim())
                            m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                    }
                }
            }
            else
                m_uiSplitTimer -= uiDiff;

            return;
        }

        if (m_uiStaticOverloadTimer < uiDiff)
        {
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
            {
                if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_STATIC_OVERLOAD_N : SPELL_STATIC_OVERLOAD_H) == CAST_OK)
                    m_uiStaticOverloadTimer = urand(5000, 6000);
            }
        }
        else
            m_uiStaticOverloadTimer -= uiDiff;

        if (m_uiBallLightningTimer < uiDiff)
        {
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
            {
                if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_BALL_LIGHTNING_N : SPELL_BALL_LIGHTNING_H) == CAST_OK)
                    m_uiBallLightningTimer = urand(10000, 11000);
            }
        }
        else
            m_uiBallLightningTimer -= uiDiff;

        // Health check
        if (m_creature->GetHealthPercent() < float(100 - 20 * m_uiHealthAmountModifier))
        {
            ++m_uiHealthAmountModifier;

            if (!m_bIsDesperseCasting && DoCastSpellIfCan(m_creature, SPELL_DISPERSE, CAST_INTERRUPT_PREVIOUS) == CAST_OK)
            {
                DoScriptText(urand(0, 1) ? SAY_SPLIT_1 : SAY_SPLIT_2, m_creature);
                m_bIsDesperseCasting = true;
            }
        }

        DoMeleeAttackIfReady();
    }
Ejemplo n.º 4
0
    void UpdateAI(const uint32 uiDiff)
    {
        // Splitted
        if (m_creature->GetVisibility() == VISIBILITY_OFF)
        {
            if (!m_creature->isInCombat())
            {
                Reset();
                return;
            }

            if (m_uiSplit_Timer < uiDiff)
            {
                m_uiSplit_Timer = 2500;

                // Return sparks to where Ionar splitted
                if (m_bIsSplitPhase)
                {
                    CallBackSparks();
                    m_bIsSplitPhase = false;
                }
                // Lightning effect and restore Ionar
                else 
                {
                    m_creature->SetVisibility(VISIBILITY_ON);
                    m_creature->CastSpell(m_creature, SPELL_SPARK_DESPAWN, false);

                    DespawnSpark();

                    m_uiSparkAtHomeCount = 0;
                    m_uiSplit_Timer = 25000;
                    m_bIsSplitPhase = true;

                    if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE)
                    {
                        if (m_creature->getVictim())
                            m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                    }
                }
            }
            else
                m_uiSplit_Timer -= uiDiff;

            return;
        }

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

        if (m_uiStaticOverload_Timer < uiDiff)
        {
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_STATIC_OVERLOAD_N : SPELL_STATIC_OVERLOAD_H);

            m_uiStaticOverload_Timer = urand(5000, 6000);
        }
        else
            m_uiStaticOverload_Timer -= uiDiff;

        if (m_uiBallLightning_Timer < uiDiff)
        {
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                m_creature->CastSpell(pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), m_bIsRegularMode ? SPELL_BALL_LIGHTNING_N : SPELL_BALL_LIGHTNING_H, false, NULL, NULL, m_creature->GetObjectGuid());
            m_uiBallLightning_Timer = urand(10000, 11000);
        }
        else
            m_uiBallLightning_Timer -= uiDiff;

        // Health check
        if (m_creature->GetHealthPercent() < float(100 - 20*m_uiHealthAmountModifier))
        {
            ++m_uiHealthAmountModifier;

            DoScriptText(urand(0, 1) ? SAY_SPLIT_1 : SAY_SPLIT_2, m_creature);

            if (m_creature->IsNonMeleeSpellCasted(false))
                m_creature->InterruptNonMeleeSpells(false);

            DoCastSpellIfCan(m_creature, SPELL_DISPERSE);
        }

        DoMeleeAttackIfReady();
    }
Ejemplo n.º 5
0
        void UpdateAI(const uint32 uiDiff)
        {
            //Return since we have no target
            if (!UpdateVictim())
                return;

            // Splitted
            if (!me->IsVisible())
            {
                if (uiSplitTimer <= uiDiff)
                {
                    uiSplitTimer = 2500;

                    // Return sparks to where Ionar splitted
                    if (bIsSplitPhase)
                    {
                        CallBackSparks();
                        bIsSplitPhase = false;
                    }
                    // Lightning effect and restore Ionar
                    else if (lSparkList.empty())
                    {
                        me->SetVisible(true);
                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_DISABLE_MOVE);

                        DoCast(me, SPELL_SPARK_DESPAWN, false);

                        uiSplitTimer = 25*IN_MILLISECONDS;
                        bIsSplitPhase = true;

                        if (me->getVictim())
                            me->GetMotionMaster()->MoveChase(me->getVictim());
                    }
                }
                else
                    uiSplitTimer -= uiDiff;

                return;
            }

            if (uiStaticOverloadTimer <= uiDiff)
            {
                if (!me->IsNonMeleeSpellCasted(false))
                {
                    if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        DoCast(pTarget, DUNGEON_MODE(SPELL_STATIC_OVERLOAD,H_SPELL_STATIC_OVERLOAD));

                    uiStaticOverloadTimer = 11*IN_MILLISECONDS;
                }
            }
            else
                uiStaticOverloadTimer -= uiDiff;

            if (uiBallLightningTimer <= uiDiff)
            {
                if (!me->IsNonMeleeSpellCasted(false))
                {
                    if (Unit* pTemp = SelectTarget(SELECT_TARGET_RANDOM,1,100,true))
                        DoCast(pTemp, DUNGEON_MODE(SPELL_BALL_LIGHTNING,H_SPELL_BALL_LIGHTNING));
                    else 
                        DoCast(me->getVictim(), DUNGEON_MODE(SPELL_BALL_LIGHTNING,H_SPELL_BALL_LIGHTNING));

                    uiBallLightningTimer = 10*IN_MILLISECONDS;
                }
            }
            else
                uiBallLightningTimer -= uiDiff;

            // Health check
            if (me->HealthBelowPct(100 - 20 * uiHealthAmountModifier))
            {
                ++uiHealthAmountModifier;

                DoScriptText(RAND(SAY_SPLIT_1, SAY_SPLIT_2), me);

                if (me->IsNonMeleeSpellCasted(false))
                    me->InterruptNonMeleeSpells(false);

                me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false);
                DoCast(me, SPELL_DISPERSE, false);
            }

            DoMeleeAttackIfReady();
        }