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

        if (m_uiEnrageTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_TWINS_ENRAGE) == CAST_OK)
            {
                DoScriptText(SAY_SACROLASH_BERSERK, m_creature);
                m_uiEnrageTimer = 6 * MINUTE * IN_MILLISECONDS;
            }
        }
        else
            m_uiEnrageTimer -= uiDiff;

        if (m_uiShadowBladesTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_SHADOW_BLADES) == CAST_OK)
                m_uiShadowBladesTimer = urand(13000, 15000);
        }
        else
            m_uiShadowBladesTimer -= uiDiff;

        if (m_uiShadowNovaTimer < uiDiff)
        {
            Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 2);
            if (!pTarget)
                pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);

            // If sister is dead cast conflagration instead of shadownova
            bool bSwitchSpell = m_creature->HasAura(SPELL_EMPOWER);
            if (DoCastSpellIfCan(pTarget, bSwitchSpell ? SPELL_CONFLAGRATION : SPELL_SHADOW_NOVA) == CAST_OK)
            {
                if (!bSwitchSpell)
                    DoScriptText(SAY_SACROLASH_SHADOW_NOVA, m_creature);

                m_uiShadowNovaTimer = urand(30000, 35000);
            }
        }
        else
            m_uiShadowNovaTimer -= uiDiff;

        if (m_uiConfoundingBlowTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_CONFOUNDING_BLOW) == CAST_OK)
            {
                // Reset threat
                if (m_creature->getThreatManager().getThreat(m_creature->getVictim()))
                    m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(), -100);

                m_uiConfoundingBlowTimer = urand(25000, 30000);
            }
        }
        else
            m_uiConfoundingBlowTimer -= uiDiff;

        if (m_uiSummonShadowImage < uiDiff)
        {
            // Summon 3 shadow images at the boss position
            for (uint8 i = 0; i < 3; ++i)
                m_creature->SummonCreature(NPC_SHADOW_IMAGE, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 3000);

            m_uiSummonShadowImage = urand(10000, 12000);
        }
        else
            m_uiSummonShadowImage -= uiDiff;

        // Overwrite the melee attack in order to apply the dark strike
        if (m_creature->CanReachWithMeleeAttack(m_creature->getVictim()))
        {
            // Make sure our attack is ready and we aren't currently casting
            if (m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_DARK_STRIKE);

                m_creature->AttackerStateUpdate(m_creature->getVictim());
                m_creature->resetAttackTimer();
            }
        }
    }
 void Aggro(Unit* pWho)
 {
     // spell reflection
     DoCastSpellIfCan(m_creature, m_uiSpell3);
 }
Beispiel #3
0
    void UpdateAI(const uint32 uiDiff) override
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_uiPhase == PHASE_GROUND)
        {
            // Teleport to platform
            if (m_uiPhaseTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_TELEPORT) == CAST_OK)
                {
                    DoScriptText(EMOTE_TELEPORT, m_creature);
                    m_creature->GetMotionMaster()->MoveIdle();

                    m_uiPhase = PHASE_PLATFORM;
                    ResetPhase();
                    return;
                }
            }
            else
                m_uiPhaseTimer -= uiDiff;

            // Fever
            if (m_uiFeverTimer < uiDiff)
            {
                DoCastSpellIfCan(m_creature, SPELL_DECREPIT_FEVER);
                m_uiFeverTimer = 21000;
            }
            else
                m_uiFeverTimer -= uiDiff;

            // Disruption
            if (m_uiDisruptionTimer < uiDiff)
            {
                DoCastSpellIfCan(m_creature, SPELL_DISRUPTION);
                m_uiDisruptionTimer = 10000;
            }
            else
                m_uiDisruptionTimer -= uiDiff;

            if (m_uiTeleportTimer < uiDiff)
            {
                float fX, fY, fZ;
                // Teleport players in the tunnel
                for (uint8 i = 0; i < MAX_PLAYERS_TELEPORT; i++)
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, uint32(0), SELECT_FLAG_PLAYER))
                    {
                        m_creature->GetRandomPoint(aTunnelLoc[0], aTunnelLoc[1], aTunnelLoc[2], 5.0f, fX, fY, fZ);
                        pTarget->NearTeleportTo(fX, fY, fZ, aTunnelLoc[3]);
                    }
                }

                m_uiTeleportTimer = 70000;
            }
            else
                m_uiTeleportTimer -= uiDiff;

        }
        else                                                // Platform Phase
        {
            if (m_uiPhaseTimer <= uiDiff)                   // Return to fight
            {
                m_creature->InterruptNonMeleeSpells(true);
                DoScriptText(EMOTE_RETURN, m_creature);
                m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());

                m_uiPhase = PHASE_GROUND;
                ResetPhase();
                return;
            }
            else
                m_uiPhaseTimer -= uiDiff;

            if (m_uiStartChannelingTimer)
            {
                if (m_uiStartChannelingTimer <= uiDiff)
                {
                    DoScriptText(SAY_CHANNELING, m_creature);
                    DoCastSpellIfCan(m_creature, SPELL_PLAGUE_CLOUD);

                    // ToDo: fill the tunnel with poison - required further research
                    m_uiStartChannelingTimer = 0;           // no more
                }
                else
                    m_uiStartChannelingTimer -= uiDiff;
            }
        }

        // Taunt
        if (m_uiTauntTimer < uiDiff)
        {
            switch (urand(0, 3))
            {
                case 0: DoScriptText(SAY_TAUNT1, m_creature); break;
                case 1: DoScriptText(SAY_TAUNT2, m_creature); break;
                case 2: DoScriptText(SAY_TAUNT3, m_creature); break;
                case 3: DoScriptText(SAY_TAUNT4, m_creature); break;
            }
            m_uiTauntTimer = urand(20000, 70000);
        }
        else
            m_uiTauntTimer -= uiDiff;

        DoMeleeAttackIfReady();

        // Handling of the erruptions, this is not related to melee attack or spell-casting
        if (!m_pInstance)
            return;

        // Eruption
        if (m_uiEruptionTimer < uiDiff)
        {
            for (uint8 uiArea = 0; uiArea < MAX_HEIGAN_TRAP_AREAS; ++uiArea)
            {
                // Actually this is correct :P
                if (uiArea == (m_uiPhaseEruption % 6) || uiArea == 6 - (m_uiPhaseEruption % 6))
                    continue;

                m_pInstance->DoTriggerHeiganTraps(m_creature, uiArea);
            }

            m_uiEruptionTimer = m_uiPhase == PHASE_GROUND ? 10000 : 3000;
            ++m_uiPhaseEruption;
        }
        else
            m_uiEruptionTimer -= uiDiff;
    }
    void UpdateAI(const uint32 uiDiff)
    {
        // Handling of his combat-end speech and Ragnaros summoning
        if (m_uiSpeech)
        {
            if (m_uiSpeechTimer < uiDiff)
            {
                switch (m_uiSpeech)
                {
                    // Majordomo retreat event
                    case 1:
                        DoScriptText(SAY_DEFEAT_1, m_creature);
                        m_uiSpeechTimer = 7500;
                        ++m_uiSpeech;
                        break;
                    case 2:
                        DoScriptText(SAY_DEFEAT_2, m_creature);
                        m_uiSpeechTimer = 8000;
                        ++m_uiSpeech;
                        break;
                    case 3:
                        DoScriptText(SAY_DEFEAT_3, m_creature);
                        m_uiSpeechTimer = 21500;
                        ++m_uiSpeech;
                        break;
                    case 4:
                        DoCastSpellIfCan(m_creature, SPELL_TELEPORT_SELF);
                        // TODO - when should they be unsummoned?
                        // TODO - also unclear how this should be handled, as of range issues
                        m_uiSpeechTimer = 900;
                        ++m_uiSpeech;
                        break;
                    case 5:
                        // Majordomo is away now, remove his adds
                        UnsummonMajordomoAdds();
                        m_uiSpeech = 0;
                        break;

                    // Ragnaros Summon Event
                    case 10:
                        DoScriptText(SAY_SUMMON_1, m_creature);
                        ++m_uiSpeech;
                        m_uiSpeechTimer = 1000;
                        break;
                    case 11:
                        DoCastSpellIfCan(m_creature, SPELL_SUMMON_RAGNAROS);
                        // TODO - Move along, this expects to be handled with mmaps
                        m_creature->GetMotionMaster()->MovePoint(1, 831.079590f, -816.023193f, -229.023270f);
                        ++m_uiSpeech;
                        m_uiSpeechTimer = 7000;
                        break;
                    case 12:
                        // Reset orientation
                        if (GameObject* pLavaSteam = m_pInstance->GetSingleGameObjectFromStorage(GO_LAVA_STEAM))
                            m_creature->SetFacingToObject(pLavaSteam);
                        m_uiSpeechTimer = 4500;
                        ++m_uiSpeech;
                        break;
                    case 13:
                        DoScriptText(SAY_SUMMON_MAJ, m_creature);
                        ++m_uiSpeech;
                        m_uiSpeechTimer = 8000;
                        break;
                    case 14:
                        // Summon Ragnaros
                        if (m_pInstance)
                            if (GameObject* pGo = m_pInstance->GetSingleGameObjectFromStorage(GO_LAVA_STEAM))
                                m_creature->SummonCreature(NPC_RAGNAROS, pGo->GetPositionX(), pGo->GetPositionY(), pGo->GetPositionZ(), fmod(m_creature->GetOrientation() + M_PI, 2*M_PI), TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN, 2*HOUR*IN_MILLISECONDS);
                        ++m_uiSpeech;
                        m_uiSpeechTimer = 8700;
                        break;
                    case 15:
                        if (Creature* pRagnaros = m_creature->GetMap()->GetCreature(m_ragnarosGuid))
                            DoScriptText(SAY_ARRIVAL1_RAG, pRagnaros);
                        ++m_uiSpeech;
                        m_uiSpeechTimer = 11700;
                        break;
                    case 16:
                        DoScriptText(SAY_ARRIVAL2_MAJ, m_creature);
                        ++m_uiSpeech;
                        m_uiSpeechTimer = 8700;
                        break;
                    case 17:
                        if (Creature* pRagnaros = m_creature->GetMap()->GetCreature(m_ragnarosGuid))
                            DoScriptText(SAY_ARRIVAL3_RAG, pRagnaros);
                        ++m_uiSpeech;
                        m_uiSpeechTimer = 16500;
                        break;
                    case 18:
                        if (Creature* pRagnaros = m_creature->GetMap()->GetCreature(m_ragnarosGuid))
                            pRagnaros->CastSpell(m_creature, SPELL_ELEMENTAL_FIRE, false);
                        // Rest of summoning speech is handled by Ragnaros, as Majordomo will be dead
                        m_uiSpeech = 0;
                        break;
                }
            }
            else
                m_uiSpeechTimer -= uiDiff;
        }

        // When encounter finished, no need to do anything anymore (important for moving home after victory)
        if (m_bHasEncounterFinished)
            return;

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

        // Cast Ageis to heal self
        if (m_uiAegisTimer <= uiDiff)
            m_uiAegisTimer = 0;
        else
            m_uiAegisTimer -= uiDiff;

        if (m_creature->GetHealthPercent() < 90.0f && !m_uiAegisTimer)
        {
            DoCastSpellIfCan(m_creature, SPELL_AEGIS);
            m_uiAegisTimer = 10000;
        }

        // Magic Reflection Timer
        if (m_uiMagicReflectionTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_MAGIC_REFLECTION) == CAST_OK)
                m_uiMagicReflectionTimer = 30000;
        }
        else
            m_uiMagicReflectionTimer -= uiDiff;

        // Damage Reflection Timer
        if (m_uiDamageReflectionTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_DAMAGE_REFLECTION) == CAST_OK)
                m_uiDamageReflectionTimer = 30000;
        }
        else
            m_uiDamageReflectionTimer -= uiDiff;

        // Teleports the target to the heated rock in the center of the area
        if (m_uiTeleportTimer < uiDiff)
        {
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1))
            {
                if (DoCastSpellIfCan(pTarget, SPELL_TELEPORT) == CAST_OK)
                    m_uiTeleportTimer = 20000;
            }
        }
        else
            m_uiTeleportTimer -= uiDiff;

        // Blastwave Timer
        if (m_uiBlastwaveTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_BLASTWAVE) == CAST_OK)
                m_uiBlastwaveTimer = 10000;
        }
        else
            m_uiBlastwaveTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }
 void Aggro(Unit* pWho)
 {
     m_creature->SetInCombatWithZone();
     DoCastSpellIfCan(m_creature->getVictim(), AURA_OF_ANGER, CAST_TRIGGERED);
 }
Beispiel #6
0
 void Aggro(Unit* pWho)
 {
     DoScriptText(SAY_AGGRO, m_creature);
     DoCastSpellIfCan(m_creature, SPELL_RUSHINGCHARGE);
 }
    void UpdateAI(const uint32 uiDiff) override
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
        {
            return;
        }

        // START NOT TRANSFORMED
        if (!m_bTransformed)
        {
            // MindBlast
            if (m_uiMindBlast_Timer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_MINDBLAST);
                m_uiMindBlast_Timer = urand(15000, 20000);
            }
            else { m_uiMindBlast_Timer -= uiDiff; }

            // CrusadersHammer
            if (m_uiCrusadersHammer_Timer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_CRUSADERSHAMMER);
                m_uiCrusadersHammer_Timer = 12000;
            }
            else { m_uiCrusadersHammer_Timer -= uiDiff; }

            // CrusaderStrike
            if (m_uiCrusaderStrike_Timer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_CRUSADERSTRIKE);
                m_uiCrusaderStrike_Timer = 15000;
            }
            else { m_uiCrusaderStrike_Timer -= uiDiff; }

            // HolyStrike
            if (m_uiHolyStrike_Timer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_HOLYSTRIKE);
                m_uiHolyStrike_Timer = 15000;
            }
            else { m_uiHolyStrike_Timer -= uiDiff; }

            // BalnazzarTransform
            if (m_creature->GetHealthPercent() < 40.0f)
            {
                // restore hp, mana and stun
                if (DoCastSpellIfCan(m_creature, SPELL_BALNAZZARTRANSFORM) == CAST_OK)
                {
                    m_creature->UpdateEntry(NPC_BALNAZZAR);
                    DoScriptText(SAY_TRANSFORM, m_creature);
                    m_bTransformed = true;
                }
            }
        }
        else
        {
            // MindBlast
            if (m_uiMindBlast_Timer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_MINDBLAST);
                m_uiMindBlast_Timer = urand(15000, 20000);
            }
            else { m_uiMindBlast_Timer -= uiDiff; }

            // ShadowShock
            if (m_uiShadowShock_Timer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_SHADOWSHOCK);
                m_uiShadowShock_Timer = 11000;
            }
            else { m_uiShadowShock_Timer -= uiDiff; }

            // PsychicScream
            if (m_uiPsychicScream_Timer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    DoCastSpellIfCan(pTarget, SPELL_PSYCHICSCREAM);
                }

                m_uiPsychicScream_Timer = 20000;
            }
            else { m_uiPsychicScream_Timer -= uiDiff; }

            // DeepSleep
            if (m_uiDeepSleep_Timer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    DoCastSpellIfCan(pTarget, SPELL_SLEEP);
                }

                m_uiDeepSleep_Timer = 15000;
            }
            else { m_uiDeepSleep_Timer -= uiDiff; }

            // MindControl
            if (m_uiMindControl_Timer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_MINDCONTROL);
                m_uiMindControl_Timer = 15000;
            }
            else { m_uiMindControl_Timer -= uiDiff; }
        }

        DoMeleeAttackIfReady();
    }
Beispiel #8
0
    void UpdateAI(const uint32 uiDiff)
    {
        //Return since we have no target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_bIsAura)
        {
            // workaround for PULSING_SHOCKWAVE
            if (m_uiPulsingShockwave_Timer < uiDiff)
            {
                Map *map = m_creature->GetMap();
                if (map->IsDungeon())
                {
                    Map::PlayerList const &PlayerList = map->GetPlayers();

                    if (PlayerList.isEmpty())
                        return;

                    for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                        if (i->getSource()->isAlive() && i->getSource()->isTargetableForAttack())
                        {
                            int32 dmg;
                            float m_fDist = m_creature->GetDistance(i->getSource());

                            if (m_fDist <= 1.0f) // Less than 1 yard
                                dmg = (m_bIsRegularMode ? 800 : 850); // need to correct damage

                            m_creature->CastCustomSpell(i->getSource(), (m_bIsRegularMode ? 52942 : 59837), &dmg, 0, 0, false);
                        }
                }
                m_uiPulsingShockwave_Timer = 2000;
            }else m_uiPulsingShockwave_Timer -= uiDiff;
        }
        else
        {
            if (m_uiResumePulsingShockwave_Timer < uiDiff)
            {
                //breaks at movement, can we assume when it's time, this spell is casted and also must stop movement?
                //m_creature->CastSpell(m_creature, SPELL_PULSING_SHOCKWAVE_AURA, true);

                  //DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_PULSING_SHOCKWAVE_N : SPELL_PULSING_SHOCKWAVE_H); // need core support
                m_bIsAura = true;
                m_uiResumePulsingShockwave_Timer = 0;
            }
            else
                m_uiResumePulsingShockwave_Timer -= uiDiff;
        }

        if (m_uiArcLightning_Timer < uiDiff)
        {
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                DoCastSpellIfCan(pTarget, SPELL_ARC_LIGHTNING);

            m_uiArcLightning_Timer = urand(15000, 16000);
        }
        else
            m_uiArcLightning_Timer -= uiDiff;

        if (m_uiLightningNova_Timer < uiDiff)
        {
            switch(urand(0, 2))
            {
                case 0: DoScriptText(SAY_NOVA_1, m_creature);break;
                case 1: DoScriptText(SAY_NOVA_2, m_creature);break;
                case 2: DoScriptText(SAY_NOVA_3, m_creature);break;
            }

            DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_LIGHTNING_NOVA_N : SPELL_LIGHTNING_NOVA_H);

            m_bIsAura = false;
            m_uiResumePulsingShockwave_Timer = (m_bIsRegularMode ? 5000 : 4000); // Pause Pulsing Shockwave aura
            m_uiLightningNova_Timer = urand(20000, 21000);
        }
        else
            m_uiLightningNova_Timer -= uiDiff;

        // Health check
        if (m_creature->GetHealthPercent() < float(100 - 25*m_uiHealthAmountModifier))
        {
            switch(m_uiHealthAmountModifier)
            {
                case 1: DoScriptText(SAY_75HEALTH, m_creature); break;
                case 2: DoScriptText(SAY_50HEALTH, m_creature); break;
                case 3: DoScriptText(SAY_25HEALTH, m_creature); break;
            }

            ++m_uiHealthAmountModifier;
        }

        DoMeleeAttackIfReady();
    }
Beispiel #9
0
    void UpdateAI(const uint32 uiDiff) override
    {
        // Return since we have no pTarget
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (!m_bSubmerged)
        {
            // Summon sandworm base
            if (m_uiSummonBaseTimer)
            {
                if (m_uiSummonBaseTimer <= uiDiff)
                {
                    // Note: server side spells should be cast directly
                    m_creature->CastSpell(m_creature, SPELL_SUMMON_BASE, true);
                    m_uiSummonBaseTimer = 0;
                }
                else
                    m_uiSummonBaseTimer -= uiDiff;
            }

            // Sweep
            if (m_uiSweepTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_SWEEP) == CAST_OK)
                    m_uiSweepTimer = 20000;
            }
            else
                m_uiSweepTimer -= uiDiff;

            // Sand Blast
            if (m_uiSandBlastTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_SANDBLAST) == CAST_OK)
                    m_uiSandBlastTimer = 22000;
            }
            else
                m_uiSandBlastTimer -= uiDiff;

            if (!m_bEnraged)
            {
                // Enrage at 20% HP
                if (m_creature->GetHealthPercent() < 20.0f)
                {
                    if (DoCastSpellIfCan(m_creature, SPELL_BERSERK) == CAST_OK)
                    {
                        m_bEnraged = true;
                        return;
                    }
                }

                // Submerge
                if (m_uiSubmergeTimer < uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature, SPELL_SUBMERGE_VISUAL) == CAST_OK)
                    {
                        DoCastSpellIfCan(m_creature, SPELL_SUMMON_OURO_MOUNDS, CAST_TRIGGERED);
                        DoCastSpellIfCan(m_creature, SPELL_SUMMON_TRIGGER, CAST_TRIGGERED);

                        m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);

                        m_bSubmerged      = true;
                        m_uiSubmergeTimer = 30000;
                    }
                }
                else
                    m_uiSubmergeTimer -= uiDiff;
            }
            else
            {
                // Summon 1 mound every 10 secs when enraged
                if (m_uiSummonMoundTimer < uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature, SPELL_SUMMON_OURO_MOUND) == CAST_OK)
                        m_uiSummonMoundTimer = 10000;
                }
                else
                    m_uiSummonMoundTimer -= uiDiff;
            }

            // If we are within range melee the target
            if (m_creature->CanReachWithMeleeAttack(m_creature->getVictim()))
                DoMeleeAttackIfReady();
            // Spam Boulder spell when enraged and not tanked
            else if (m_bEnraged)
            {
                if (!m_creature->IsNonMeleeSpellCasted(false))
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                        DoCastSpellIfCan(pTarget, SPELL_BOULDER);
                }
            }
        }
        else
        {
            // Resume combat
            if (m_uiSubmergeTimer < uiDiff)
            {
                // Teleport to the trigger in order to get a new location
                if (Creature* pTrigger = m_creature->GetMap()->GetCreature(m_ouroTriggerGuid))
                    m_creature->NearTeleportTo(pTrigger->GetPositionX(), pTrigger->GetPositionY(), pTrigger->GetPositionZ(), 0);

                if (DoCastSpellIfCan(m_creature, SPELL_BIRTH) == CAST_OK)
                {
                    m_creature->RemoveAurasDueToSpell(SPELL_SUBMERGE_VISUAL);
                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);

                    m_bSubmerged        = false;
                    m_uiSummonBaseTimer = 2000;
                    m_uiSubmergeTimer   = 90000;
                }
            }
            else
                m_uiSubmergeTimer -= uiDiff;
        }
    }
Beispiel #10
0
    void UpdateAI(const uint32 uiDiff) override
    {
        if (!SelectHostileTarget())
            return;

        switch (m_Phase)
        {
            case PHASE_TRANSITION:

                if (m_uiPhaseTimer < uiDiff)
                {
                    // Note: we need to set the display id before casting the transform spell, in order to get the proper animation
                    m_creature->SetDisplayId(DISPLAY_ID_CTHUN_BODY);

                    // Transform and start C'thun phase
                    if (DoCastSpellIfCan(m_creature, SPELL_TRANSFORM) == CAST_OK)
                    {
                        m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        DoSpawnFleshTentacles();

                        m_Phase        = PHASE_CTHUN;
                        m_uiPhaseTimer = 0;
                    }
                }
                else
                    m_uiPhaseTimer -= uiDiff;

                break;
            case PHASE_CTHUN:

                if (m_uiMouthTentacleTimer < uiDiff)
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, uint32(0), SELECT_FLAG_IN_LOS))
                    {
                        // Cast the spell using the target as source
                        pTarget->InterruptNonMeleeSpells(false);
                        pTarget->CastSpell(pTarget, SPELL_MOUTH_TENTACLE, TRIGGERED_OLD_TRIGGERED, nullptr, nullptr, m_creature->GetObjectGuid());
                        m_stomachEnterTargetGuid = pTarget->GetObjectGuid();

                        m_uiStomachEnterTimer  = 3800;
                        m_uiMouthTentacleTimer = urand(13000, 15000);
                    }
                }
                else
                    m_uiMouthTentacleTimer -= uiDiff;

                // Teleport the target to the stomach after a few seconds
                if (m_uiStomachEnterTimer)
                {
                    if (m_uiStomachEnterTimer <= uiDiff)
                    {
                        // Check for valid player
                        if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_stomachEnterTargetGuid))
                        {
                            pPlayer->CastSpell(pPlayer, SPELL_DIGESTIVE_ACID_TELEPORT, TRIGGERED_OLD_TRIGGERED);
                            m_lPlayersInStomachList.push_back(pPlayer->GetObjectGuid());
                        }

                        m_stomachEnterTargetGuid.Clear();
                        m_uiStomachEnterTimer = 0;
                    }
                    else
                        m_uiStomachEnterTimer -= uiDiff;
                }

                break;
            case PHASE_CTHUN_WEAKENED:

                // Handle Flesh Tentacles respawn when the vulnerability spell expires
                if (m_uiPhaseTimer < uiDiff)
                {
                    DoSpawnFleshTentacles();

                    m_uiPhaseTimer = 0;
                    m_Phase        = PHASE_CTHUN;
                }
                else
                    m_uiPhaseTimer -= uiDiff;

                break;
            default:
                break;
        }

        if (m_uiGiantClawTentacleTimer < uiDiff)
        {
            // Summon 1 Giant Claw Tentacle every 60 seconds
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, uint32(0), SELECT_FLAG_IN_LOS))
                m_creature->SummonCreature(NPC_GIANT_CLAW_TENTACLE, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_DEAD_DESPAWN, 0);

            m_uiGiantClawTentacleTimer = 60000;
        }
        else
            m_uiGiantClawTentacleTimer -= uiDiff;

        if (m_uiGiantEyeTentacleTimer < uiDiff)
        {
            // Summon 1 Giant Eye Tentacle every 60 seconds
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, uint32(0), SELECT_FLAG_IN_LOS))
                m_creature->SummonCreature(NPC_GIANT_EYE_TENTACLE, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_DEAD_DESPAWN, 0);

            m_uiGiantEyeTentacleTimer = 60000;
        }
        else
            m_uiGiantEyeTentacleTimer -= uiDiff;

        if (m_uiEyeTentacleTimer < uiDiff)
        {
            DoDespawnEyeTentacles();

            // Spawn 8 Eye Tentacles every 30 seconds
            float fX, fY, fZ;
            for (uint8 i = 0; i < MAX_EYE_TENTACLES; ++i)
            {
                m_creature->GetNearPoint(m_creature, fX, fY, fZ, 0, 30.0f, M_PI_F / 4 * i);
                m_creature->SummonCreature(NPC_EYE_TENTACLE, fX, fY, fZ, 0, TEMPSUMMON_DEAD_DESPAWN, 0);
            }

            m_uiEyeTentacleTimer = 30000;
        }
        else
            m_uiEyeTentacleTimer -= uiDiff;

        // Note: this should be applied by the teleport spell
        if (m_uiDigestiveAcidTimer < uiDiff)
        {
            // Iterate the Stomach players list and apply the Digesti acid debuff on them every 4 sec
            for (GuidList::const_iterator itr = m_lPlayersInStomachList.begin(); itr != m_lPlayersInStomachList.end(); ++itr)
            {
                if (Player* pPlayer = m_creature->GetMap()->GetPlayer(*itr))
                    pPlayer->CastSpell(pPlayer, SPELL_DIGESTIVE_ACID, TRIGGERED_OLD_TRIGGERED, nullptr, nullptr, m_creature->GetObjectGuid());
            }
            m_uiDigestiveAcidTimer = 4000;
        }
        else
            m_uiDigestiveAcidTimer -= uiDiff;
    }
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        // Pounding
        if (Pounding_Timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_POUNDING);
            DoScriptText(urand(0, 1) ? 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 *target = NULL;
            std::vector<Unit *> target_list;

            ThreatList const& tList = m_creature->getThreatManager().getThreatList();
            for (ThreatList::const_iterator itr = tList.begin();itr != tList.end(); ++itr)
            {
                target = m_creature->GetMap()->GetUnit((*itr)->getUnitGuid());

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

                //18 yard radius minimum
                if (target->IsWithinDist(m_creature, 18.0f, false))
                    continue;

                target_list.push_back(target);
            }

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

            if (target)
                DoCastSpellIfCan(target, SPELL_ARCANE_ORB_MISSILE);

            ArcaneOrb_Timer = 3000;
        }else ArcaneOrb_Timer -= diff;

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

            KnockAway_Timer = 30000;
        }else KnockAway_Timer -= diff;

        //Berserk
        if (Berserk_Timer < diff)
        {
            if (m_creature->IsNonMeleeSpellCasted(false))
                m_creature->InterruptNonMeleeSpells(false);

            DoCastSpellIfCan(m_creature,SPELL_BERSERK);
            Berserk_Timer = 600000;
        }else Berserk_Timer -= diff;

        DoMeleeAttackIfReady();

        EnterEvadeIfOutOfCombatArea(diff);
    }
Beispiel #12
0
    void UpdateAI(const uint32 uiDiff) override
    {
        if (!SelectHostileTarget())
            return;

        switch (m_Phase)
        {
            case PHASE_EYE_NORMAL:

                if (m_uiBeamTimer < uiDiff)
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                    {
                        if (DoCastSpellIfCan(pTarget, SPELL_EYE_BEAM) == CAST_OK)
                        {
                            m_creature->SetTargetGuid(pTarget->GetObjectGuid());
                            m_uiBeamTimer = 3000;
                        }
                    }
                }
                else
                    m_uiBeamTimer -= uiDiff;

                if (m_uiDarkGlareTimer < uiDiff)
                {
                    // Cast the rotation spell
                    if (DoCastSpellIfCan(m_creature, SPELL_ROTATE_TRIGGER) == CAST_OK)
                    {
                        // Remove the target focus but allow the boss to face the current victim
                        m_creature->SetTargetGuid(ObjectGuid());
                        m_creature->SetFacingToObject(m_creature->getVictim());

                        // Switch to Dark Glare phase
                        m_uiDarkGlareTimer    = 45000;
                        m_Phase               = PHASE_EYE_DARK_GLARE;
                    }
                }
                else
                    m_uiDarkGlareTimer -= uiDiff;

                break;
            case PHASE_EYE_DARK_GLARE:

                if (m_uiDarkGlareEndTimer < uiDiff)
                {
                    // Remove rotation auras
                    m_creature->RemoveAurasDueToSpell(SPELL_ROTATE_360_LEFT);
                    m_creature->RemoveAurasDueToSpell(SPELL_ROTATE_360_RIGHT);

                    // Switch to Eye Beam
                    m_uiDarkGlareEndTimer = 40000;
                    m_uiBeamTimer         = 1000;
                    m_Phase               = PHASE_EYE_NORMAL;
                }
                else
                    m_uiDarkGlareEndTimer -= uiDiff;

                break;
            default:
                break;
        }

        if (m_uiClawTentacleTimer < uiDiff)
        {
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
            {
                // Spawn claw tentacle on the random target on both phases
                m_creature->SummonCreature(NPC_CLAW_TENTACLE, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_DEAD_DESPAWN, 0);
                m_uiClawTentacleTimer = urand(7000, 13000);
            }
        }
        else
            m_uiClawTentacleTimer -= uiDiff;

        if (m_uiEyeTentacleTimer <= uiDiff)
        {
            // Despawn the eye tentacles if necessary
            DoDespawnEyeTentacles();

            // Spawn 8 Eye Tentacles
            float fX, fY, fZ;
            for (uint8 i = 0; i < MAX_EYE_TENTACLES; ++i)
            {
                m_creature->GetNearPoint(m_creature, fX, fY, fZ, 0, 30.0f, M_PI_F / 4 * i);
                m_creature->SummonCreature(NPC_EYE_TENTACLE, fX, fY, fZ, 0, TEMPSUMMON_DEAD_DESPAWN, 0);
            }

            m_uiEyeTentacleTimer = 45000;
        }
        else
            m_uiEyeTentacleTimer -= uiDiff;
    }
Beispiel #13
0
    void UpdateAI(const uint32 uiDiff)
    {
        // Return since we have no pTarget
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (!m_bSubmerged)
        {
            // Sweep
            if (m_uiSweepTimer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_SWEEP);
                m_uiSweepTimer = urand(15000, 30000);
            }
            else
                m_uiSweepTimer -= uiDiff;

            // Sand Blast
            if (m_uiSandBlastTimer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_SANDBLAST);
                m_uiSandBlastTimer = urand(20000, 35000);
            }
            else
                m_uiSandBlastTimer -= uiDiff;

            if (!m_bEnraged)
            {
                if (m_creature->GetHealthPercent() < 20.0f)
                {
                    DoCastSpellIfCan(m_creature, SPELL_BERSERK);
                    m_bEnraged = true;
                    return;
                }

                // Submerge
                if (m_uiSubmergeTimer < uiDiff)
                {
                    //Cast
                    m_creature->HandleEmote(EMOTE_ONESHOT_SUBMERGE);
                    m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    m_creature->setFaction(35);
                    DoCastSpellIfCan(m_creature, SPELL_DIRTMOUND_PASSIVE);

                    m_bSubmerged = true;
                    m_uiBackTimer = urand(30000, 45000);
                }
                else
                    m_uiSubmergeTimer -= uiDiff;
            }

            DoMeleeAttackIfReady();
        }
        else
        {
            // Change Target
            if (m_uiChangeTargetTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    m_creature->MonsterMoveWithSpeed(pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 28.f);
                }

                m_uiChangeTargetTimer = urand(10000, 20000);
            }
            else
                m_uiChangeTargetTimer -= uiDiff;

            // Back
            if (m_uiBackTimer < uiDiff)
            {
                m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                m_creature->setFaction(14);

                DoCastSpellIfCan(m_creature->getVictim(), SPELL_GROUND_RUPTURE);

                m_bSubmerged = false;
                m_uiSubmergeTimer = urand(60000, 120000);
            }
            else
                m_uiBackTimer -= uiDiff;
        }
    }
Beispiel #14
0
 void Aggro(Unit* pWho)
 {
     DoCastSpellIfCan(m_creature, SPELL_BIRTH);
 }
Beispiel #15
0
    void UpdateAI(const uint32 diff)
    {
        //Return since we have no target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        //SonicBoom_Timer
        if (SonicBoom_Timer < diff)
        {
            if (CanSonicBoom)
            {
                DoCastSpellIfCan(m_creature, SPELL_SONIC_BOOM_CAST, CAST_TRIGGERED);
                SonicBoomEffect();

                CanSonicBoom = false;
                SonicBoom_Timer = 30000;
            }
            else
            {
                DoScriptText(EMOTE_SONIC_BOOM, m_creature);
                DoCastSpellIfCan(m_creature,SPELL_SONIC_BOOM_PRE);
                CanSonicBoom = true;
                SonicBoom_Timer = 5000;
            }
        }else SonicBoom_Timer -= diff;

        //MurmursTouch_Timer
        if (MurmursTouch_Timer < diff)
        {
            /*Unit* target = NULL;
            target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);
            if (target)
                DoCastSpellIfCan(target, SPELL_MURMURS_TOUCH);*/
            DoCastSpellIfCan(m_creature, SPELL_MURMURS_TOUCH);
            MurmursTouch_Timer = urand(25000, 35000);
        }else MurmursTouch_Timer -= diff;

        //Resonance_Timer
        if (!CanSonicBoom && !m_creature->CanReachWithMeleeAttack(m_creature->getVictim()))
        {
            if (Resonance_Timer < diff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_RESONANCE);
                Resonance_Timer = m_bIsRegularMode ? 5000 : 3000;
            }else Resonance_Timer -= diff;
        }

        if (!m_bIsRegularMode)
        {
            if (SonicShock_Timer < diff)
            {
                if (Unit *target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                    DoCastSpellIfCan(target, SPELL_SONIC_SHOCK);
                SonicShock_Timer = urand(8000, 12000);
            }else SonicShock_Timer -= diff;

            if (ThunderingStorm_Timer < diff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_THUNDERING_STORM);
                ThunderingStorm_Timer = 12000;
            }else ThunderingStorm_Timer -= diff;
        }

        //MagneticPull_Timer
        if (MagneticPull_Timer < diff)
        {
            if (!CanShockWave)
            {
                if (Unit* temp = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                {
                    if (temp->GetTypeId() == TYPEID_PLAYER)
                    {
                        DoCastSpellIfCan(temp, SPELL_MAGNETIC_PULL);
                        m_uiPlayerTargetGUID = temp->GetGUID();
                        CanShockWave = true;
                    }
                    MagneticPull_Timer = 2500;
                }
            }
            else
            {
                if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_uiPlayerTargetGUID))
                    pPlayer->CastSpell(pPlayer, SPELL_SHOCKWAVE, true);

                MagneticPull_Timer = urand(15000, 30000);
                CanShockWave = false;
                m_uiPlayerTargetGUID = 0;
            }
        }else MagneticPull_Timer -= diff;

        //no meele if preparing for sonic boom
        if (!CanSonicBoom)
            DoMeleeAttackIfReady();
    }
Beispiel #16
0
    void Reset() override
    {
        m_bHasSummoned = false;

        DoCastSpellIfCan(m_creature, SPELL_DIRTMOUND_PASSIVE);
    }
    void UpdateAI(const uint32 uiDiff)
    {
        if(m_uiBirthState == 1)
            if(m_uiBirthTimer < uiDiff)
            {
                m_creature->SetVisibility(VISIBILITY_ON);
                m_creature->setFaction(21);
                m_uiBirthState = 2;
            }
            else
                m_uiBirthTimer -= uiDiff;

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

        if (m_uiBeserkTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_BESERK) == CAST_OK)
            {
                m_uiBeserkTimer = 300000;
                DoScriptText(EMOTE_ENRAGE, m_creature);
            }
        }
        else
            m_uiBeserkTimer -= uiDiff;

        if (m_uiPhase == 1)
        {
            if (m_uiLifeDrainTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_LIFE_DRAIN : H_SPELL_LIFE_DRAIN) == CAST_OK)
                        m_uiLifeDrainTimer = 24000;
                }
            }
            else
                m_uiLifeDrainTimer -= uiDiff;

            if (m_uiBlizzardTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_BLIZZARD : H_SPELL_BLIZZARD) == CAST_OK)
                        m_uiBlizzardTimer = urand(17,20)*IN_MILLISECONDS;
                }
            }
            else
                m_uiBlizzardTimer -= uiDiff;

            if (m_uiCleaveTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_CLEAVE) == CAST_OK)
                    m_uiCleaveTimer = urand(7000, 10000);
            }
            else
                m_uiCleaveTimer -= uiDiff;

            if (m_uiTailSweepTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_TAIL_SWEEP : H_SPELL_TAIL_SWEEP) == CAST_OK)
                    m_uiTailSweepTimer = urand(10000, 15000);
            }
            else
                m_uiTailSweepTimer -= uiDiff;

            if (m_creature->GetHealthPercent() > 10.0f)
            {
                if (m_uiFlyTimer < uiDiff)
                {
                    m_uiPhase = 2;
                    m_creature->InterruptNonMeleeSpells(false);
                    m_creature->HandleEmote(EMOTE_ONESHOT_LIFTOFF);
                    m_creature->GetMotionMaster()->Clear(false);
                    m_creature->GetMotionMaster()->MoveIdle();
                    DoCastSpellIfCan(m_creature,11010);
                    m_creature->SetHover(true);
                    DoCastSpellIfCan(m_creature,18430);
                    m_uiIceboltTimer = 4000;
                    m_uiIceboltCount = 0;
                    m_bLandoff = false;
                    DoScriptText(EMOTE_FLY, m_creature);
                }
                else
                    m_uiFlyTimer -= uiDiff;
            }

            DoMeleeAttackIfReady();
        }
        else // Phase 2
        {
            if (m_uiIceboltCount < m_uiIceboltCountMax)
            {
                if (m_uiIceboltTimer < uiDiff)
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                    {
                        if(DoCastSpellIfCan(pTarget,SPELL_ICEBOLT) == CAST_OK)
                        {  
                            targetGUIDs.push_back(pTarget->GetGUID());
                            ++m_uiIceboltCount;

                            if (m_uiIceboltCount == m_uiIceboltCountMax)
                            {
                                DoScriptText(EMOTE_BREATH, m_creature);
                                m_uiFrostBreathTimer = 8700;
                                if(pFrostBreathTarget)
                                {
                                    pFrostBreathTarget->NearTeleportTo(m_creature->GetPositionX(),m_creature->GetPositionY(),pFrostBreathTarget->GetPositionZ(),0);
                                    m_creature->CastSpell(pFrostBreathTarget,SPELL_FROST_BREATH_VISUAL,true);
                                }
                            }

                            m_uiIceboltTimer = 4000;
                        }
                    }
                }
                else
                    m_uiIceboltTimer -= uiDiff;
            }
            else
            {
                if (m_bLandoff)
                {
                    if (m_uiLandTimer < uiDiff)
                    {
                        m_uiPhase = 1;
                        m_creature->HandleEmote(EMOTE_ONESHOT_LAND);
                        m_creature->SetHover(false);
                        m_creature->GetMotionMaster()->Clear(false);
                        m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                        m_uiFlyTimer = 45000;
                        DoScriptText(EMOTE_GROUND, m_creature);
                    }
                    else
                        m_uiLandTimer -= uiDiff;
                }
                else
                {
                    if (m_uiFrostBreathTimer < uiDiff)
                    {
                        if(!pFrostBreathTarget)
                            return;

                        Map *map = m_creature->GetMap();
                        if (!map->IsDungeon())
                            return;

                        Map::PlayerList const &PlayerList = map->GetPlayers();

                        //check for each player
                        for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                            //check for both iceblocks
                            for(std::vector<uint64>::iterator itr = targetGUIDs.begin(); itr!= targetGUIDs.end(); ++itr)
                                //check if player near iceblock
                            {
                                if(Player* pPlayer = m_creature->GetMap()->GetPlayer(*itr))
                                    if(i->getSource()->GetDistance2d(pPlayer) <= 6.0f)
                                    {
                                        //check if iceblock is closer to breathtarget then player
                                        if(pFrostBreathTarget->GetDistanceOrder(pPlayer,i->getSource(),false))
                                        {
                                            i->getSource()->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true);
                                            immunePlayerGUIDs.push_back(i->getSource()->GetGUID());
                                            break;
                                        }  
                                    }
                            }

                        if (DoCastSpellIfCan(m_creature, SPELL_FROST_BREATH) == CAST_OK)
                        {
                            //remove frost immunity
                            for(std::vector<uint64>::iterator itr = immunePlayerGUIDs.begin(); itr!= immunePlayerGUIDs.end(); ++itr)
                            {
                                if(Player* pPlayer = m_creature->GetMap()->GetPlayer(*itr))
                                pPlayer->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false);
                            }
                            m_uiLandTimer = 4000;
                            m_bLandoff = true;
                            immunePlayerGUIDs.clear();
                            targetGUIDs.clear();
                        }
                    }
                    else
                        m_uiFrostBreathTimer -= uiDiff;
                }
            }
                
        }
    }
    void UpdateAI(const uint32 uiDiff) override
    {
        // Animation for opening the Reliquary
        if (m_uiAnimationTimer)
        {
            if (m_uiAnimationTimer <= uiDiff)
            {
                m_creature->HandleEmote(EMOTE_ONESHOT_SUBMERGE);
                m_uiAnimationTimer = 0;
            }
            else
                m_uiAnimationTimer -= uiDiff;
        }

        // Animation for reset Reliquary
        if (m_uiAnimResetTimer)
        {
            if (m_uiAnimResetTimer <= uiDiff)
            {
                // Reset animation
                m_creature->HandleEmote(EMOTE_STATE_NONE);
                m_uiAnimResetTimer = 0;
            }
            else
                m_uiAnimResetTimer -= uiDiff;
        }

        // Summon the Essence on timer
        if (m_uiSummonEssenceTimer)
        {
            if (m_uiSummonEssenceTimer <= uiDiff)
            {
                uint32 uiSpellId = 0;
                switch (m_uiPhase)
                {
                    case PHASE_1_SUFFERING: uiSpellId = SPELL_SUMMON_ESSENCE_SUFFERING; break;
                    case PHASE_2_DESIRE:    uiSpellId = SPELL_SUMMON_ESSENCE_DESIRE;    break;
                    case PHASE_3_ANGER:     uiSpellId = SPELL_SUMMON_ESSENCE_ANGER;     break;
                }

                if (DoCastSpellIfCan(m_creature, uiSpellId) == CAST_OK)
                {
                    m_creature->HandleEmote(EMOTE_STATE_SUBMERGED);
                    m_uiSummonEssenceTimer = 0;
                }
            }
            else
                m_uiSummonEssenceTimer -= uiDiff;
        }

        // Summon Enslaved souls between the essence
        switch (m_uiPhase)
        {
            case PHASE_2_DESIRE:
            case PHASE_3_ANGER:

                if (m_uiSoulSummonedCount < MAX_ENSLAVED_SOULS)
                {
                    if (m_uiSummonSoulTimer < uiDiff)
                    {
                        if (DoCastSpellIfCan(m_creature, SPELL_SUMMON_ENSLAVED_SOUL) == CAST_OK)
                        {
                            ++m_uiSoulSummonedCount;
                            m_uiSummonSoulTimer = 500;
                        }
                    }
                    else
                        m_uiSummonSoulTimer -= uiDiff;
                }

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

        if (m_uiCleaveTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_SHADOWCLEAVE) == CAST_OK)
                m_uiCleaveTimer = urand(10000, 16000);
        }
        else
            m_uiCleaveTimer -= uiDiff;

        if (m_uiCurseTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_INTANGIBLE_PRESENCE) == CAST_OK)
                m_uiCurseTimer = 30000;
        }
        else
            m_uiCurseTimer -= uiDiff;

        if (m_uiRandomYellTimer < uiDiff)
        {
            DoScriptText(urand(0, 1) ? SAY_RANDOM1 : SAY_RANDOM2, m_creature);
            m_uiRandomYellTimer = urand(30000, 60000);
        }
        else
            m_uiRandomYellTimer -= uiDiff;

        if (m_uiKnockDown < uiDiff)
        {
            // Cast knockdown when mounted, otherwise uppercut
            if (DoCastSpellIfCan(m_creature->getVictim(), m_creature->GetEntry() == NPC_ATTUMEN_MOUNTED ? SPELL_KNOCKDOWN : SPELL_UPPERCUT) == CAST_OK)
                m_uiKnockDown = urand(6000, 9000);
        }
        else
            m_uiKnockDown -= uiDiff;

        // If creature is mounted then cast charge
        if (m_creature->GetEntry() == NPC_ATTUMEN_MOUNTED)
        {
            if (m_uiChargeTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, SPELL_BERSERKER_CHARGE, SELECT_FLAG_NOT_IN_MELEE_RANGE | SELECT_FLAG_IN_LOS))
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_BERSERKER_CHARGE) == CAST_OK)
                        m_uiChargeTimer = 20000;
                }
                else
                    m_uiChargeTimer = 2000;
            }
            else
                m_uiChargeTimer -= uiDiff;
        }
        // Else, mount if below 25%
        else if (!m_bHasSummonRider && m_creature->GetHealthPercent() < 25.0f)
        {
            if (Creature* pMidnight = m_pInstance->GetSingleCreatureFromStorage(NPC_MIDNIGHT))
            {
                pMidnight->CastSpell(m_creature, SPELL_MOUNT, TRIGGERED_OLD_TRIGGERED);
                m_bHasSummonRider = true;
            }
        }

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

        if (!m_bIsEnraged && m_creature->GetHealthPercent() < 25.0f)
        {
            if (!m_creature->IsNonMeleeSpellCasted(false))
            {
                m_bIsEnraged = true;
                DoScriptText(SAY_ENRAGE, m_creature);
                DoCastSpellIfCan(m_creature, SPELL_ENRAGE);
            }
        }

        if (uiCrystalChainTimer < uiDiff)
        {
            if (!m_creature->IsNonMeleeSpellCasted(false))
            {
                if (m_bIsRegularMode)
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1))
                    {
                        if (Player* pPlayer = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself())
                            DoCastSpellIfCan(pPlayer, SPELL_CRYSTAL_CHAINS);

                        uiCrystalChainTimer = 30000;
                    }
                }
                else
                {
                    if (Unit* pSource = m_creature->getVictim())
                    {
                        uiCrystalChainTimer = 15000;

                        Player* pPlayer = pSource->GetCharmerOrOwnerPlayerOrPlayerItself();

                        if (!pPlayer)
                            return;

                        if (Group* pGroup = pPlayer->GetGroup())
                        {
                            for(GroupReference* pRef = pGroup->GetFirstMember(); pRef != NULL; pRef = pRef->next())
                            {
                                if (Player* pMember = pRef->getSource())
                                {
                                    if (pMember->isAlive() && pMember->IsWithinDistInMap(m_creature, 50.0f))
                                        m_creature->CastSpell(pMember, SPELL_CRYSTAL_CHAINS, true);
                                }
                            }
                        }
                        else
                            m_creature->CastSpell(pPlayer, SPELL_CRYSTAL_CHAINS, false);
                    }
                }
            }
        }
        else
            uiCrystalChainTimer -= uiDiff;

        if (uiTailSweepTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_TAIL_SWEEP) == CAST_OK)
                uiTailSweepTimer = urand(2500, 7500);
        }
        else
            uiCrystalChainTimer -= uiDiff;

        if (uiCrystalfireBreathTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_CRYSTALFIRE_BREATH : SPELL_CRYSTALFIRE_BREATH_H) == CAST_OK)
                uiCrystalfireBreathTimer = urand(15000, 20000);
        }
        else
            uiCrystalfireBreathTimer -= uiDiff;

        if (!m_bIsRegularMode)
        {
            if (uiCrystallizeTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_CRYSTALLIZE) == CAST_OK)
                {
                    uiCrystallizeTimer = urand(15000, 25000);
                    DoScriptText(SAY_CRYSTAL_NOVA, m_creature);
                }
            }
            else
                uiCrystallizeTimer -= uiDiff;
        }

        DoMeleeAttackIfReady();
    }
Beispiel #21
0
    void UpdateAI(const uint32 uiDiff) override
    {
        if (m_uiEventTimer < uiDiff)
        {
            Player* pPlayer = m_creature->GetMap()->GetPlayer(m_playerGuid);

            if (!pPlayer)
            {
                // Reset Event
                if (GameObject* pGo = m_creature->GetMap()->GetGameObject(m_consoleGuid))
                    pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);

                m_creature->ForcedDespawn();
                return;
            }

            switch (m_uiPhase)
            {
                case 1:
                    DoScriptText(EMOTE_START, m_creature, pPlayer);
                    m_uiEventTimer = 60000;
                    m_bWave = true;
                    ++m_uiPhase;
                    break;
                case 2:
                    DoScriptText(EMOTE_60, m_creature, pPlayer);
                    m_uiEventTimer = 30000;
                    ++m_uiPhase;
                    break;
                case 3:
                    DoScriptText(EMOTE_30, m_creature, pPlayer);
                    m_uiEventTimer = 20000;
                    DoFinalSpawnForCreature(m_creature);
                    ++m_uiPhase;
                    break;
                case 4:
                    DoScriptText(EMOTE_10, m_creature, pPlayer);
                    m_uiEventTimer = 10000;
                    m_bWave = false;
                    ++m_uiPhase;
                    break;
                case 5:
                    DoScriptText(EMOTE_COMPLETE, m_creature, pPlayer);
                    pPlayer->KilledMonsterCredit(m_creature->GetEntry(), m_creature->GetObjectGuid());
                    DoCastSpellIfCan(m_creature, SPELL_DISABLE_VISUAL);

                    if (GameObject* pGo = m_creature->GetMap()->GetGameObject(m_consoleGuid))
                        pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);

                    ++m_uiPhase;
                    break;
            }
        }
        else
            m_uiEventTimer -= uiDiff;

        if (m_bWave)
        {
            if (m_uiWaveTimer < uiDiff)
            {
                DoWaveSpawnForCreature(m_creature);
            }
            else
                m_uiWaveTimer -= uiDiff;
        }
    }
    void UpdateAI(const uint32 uiDiff)
    {
        DialogueUpdate(uiDiff);

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

        // Don't use spells during the epilogue
        if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
            return;

        if (m_bIsFirstPhase)
        {
            // *Heroic mode only:
            if (!m_bIsRegularMode)
            {
                if (m_uiShockBarrierTimer < uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature, SPELL_SHOCK_BARRIER) == CAST_OK)
                    {
                        m_uiPyroblastTimer = 1000;
                        m_uiShockBarrierTimer = 60000;
                    }
                }
                else
                    m_uiShockBarrierTimer -= uiDiff;

                if (m_uiPyroblastTimer)
                {
                    if (m_uiPyroblastTimer <= uiDiff)
                    {
                        if (DoCastSpellIfCan(m_creature, SPELL_PYROBLAST) == CAST_OK)
                            m_uiPyroblastTimer = 0;
                    }
                    else
                        m_uiPyroblastTimer -= uiDiff;
                }
            }

            if (m_uiFireballTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    if (DoCastSpellIfCan(pTarget, m_bIsRegularMode ? SPELL_FIREBALL : SPELL_FIREBALL_H) == CAST_OK)
                        m_uiFireballTimer = urand(2000, 4000);
                }
            }
            else
                m_uiFireballTimer -= uiDiff;

            if (m_uiPhoenixTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_PHOENIX) == CAST_OK)
                {
                    DoScriptText(SAY_PHOENIX, m_creature);
                    m_uiPhoenixTimer = 45000;
                }
            }
            else
                m_uiPhoenixTimer -= uiDiff;

            if (m_uiFlameStrikeTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_FLAME_STRIKE) == CAST_OK)
                    {
                        DoScriptText(SAY_FLAMESTRIKE, m_creature);
                        m_uiFlameStrikeTimer = urand(15000, 25000);
                    }
                }
            }
            else
                m_uiFlameStrikeTimer -= uiDiff;

            // Below 50%
            if (m_creature->GetHealthPercent() < 50.0f)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_TELEPORT_CENTER, CAST_INTERRUPT_PREVIOUS) == CAST_OK)
                {
                    SetCombatMovement(false);
                    m_creature->GetMotionMaster()->Clear();
                    m_creature->GetMotionMaster()->MoveIdle();

                    m_bIsFirstPhase = false;
                }
            }

            DoMeleeAttackIfReady();
        }
        else
        {
            if (m_uiGravityLapseTimer < uiDiff)
            {
                switch (m_uiGravityLapseStage)
                {
                    case 0:
                        // Cast Gravity Lapse on Players
                        if (DoCastSpellIfCan(m_creature, SPELL_GRAVITY_LAPSE) == CAST_OK)
                        {
                            if (m_bFirstGravityLapse)
                            {
                                DoScriptText(SAY_GRAVITY_LAPSE, m_creature);
                                m_bFirstGravityLapse = false;
                            }
                            else
                                DoScriptText(SAY_RECAST_GRAVITY, m_creature);

                            m_uiGravityLapseTimer = 2000;
                            m_uiGravityIndex = 0;
                            ++m_uiGravityLapseStage;
                        }
                        break;
                    case 1:
                        // Summon spheres and apply the Gravity Lapse visual - upon visual expire, the gravity lapse is removed
                        if (DoCastSpellIfCan(m_creature, SPELL_GRAVITY_LAPSE_VISUAL) == CAST_OK)
                        {
                            for (uint8 i = 0; i < MAX_ARCANE_SPHERES; ++i)
                                DoCastSpellIfCan(m_creature, SPELL_ARCANE_SPHERE_SUMMON, CAST_TRIGGERED);

                            m_uiGravityLapseTimer = 30000;
                            ++m_uiGravityLapseStage;
                        }
                        break;
                    case 2:
                        // Cast Power Feedback and stay stunned for 10 secs - also break the statues if they are not broken
                        if (DoCastSpellIfCan(m_creature, SPELL_POWER_FEEDBACK) == CAST_OK)
                        {
                            DoScriptText(SAY_TIRED, m_creature);
                            RemoveGravityLapse();
                            m_uiGravityLapseTimer = 10000;
                            m_uiGravityLapseStage = 0;
                        }
                        break;
                }
            }
            else
                m_uiGravityLapseTimer -= uiDiff;
        }
    }
 void Aggro(Unit* pWho)
 {
     m_creature->SetInCombatWithZone();
     DoCastSpellIfCan(pWho, AURA_OF_SUFFERING, CAST_TRIGGERED);
     DoCastSpellIfCan(m_creature, ESSENCE_OF_SUFFERING_PASSIVE, CAST_TRIGGERED);
 }
Beispiel #24
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (m_pInstance->GetData(TYPE_ICHORON) == SPECIAL && !MovementStarted)
           StartMovement(0);

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

        if (!m_bIsFrenzy)
        {
            if (m_uiBuubleChecker_Timer < uiDiff)
            {
                if (!m_bIsExploded)
                {
                    if (!m_creature->HasAura(SPELL_PROTECTIVE_BUBBLE, EFFECT_INDEX_0))
                    {
                        DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_WATER_BLAST_H : SPELL_WATER_BLAST);
                        //DoCastSpellIfCan(m_creature, SPELL_DRAINED);
                        m_bIsExploded = true;
                        m_uiShowup_Counter = 0;
                        DoCastSpellIfCan(m_creature, SPELL_PROTECTIVE_BUBBLE);
                        m_creature->AttackStop();
                        for(uint8 i = 0; i < 10; i++)
                        {
                            int tmp = urand(0, 5);
                            m_creature->SummonCreature(NPC_ICHOR_GLOBULE, PortalLoc[tmp].x, PortalLoc[tmp].y, PortalLoc[tmp].z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                        }
                    }
                    m_uiBuubleChecker_Timer = 3000;
                }
                else
                {
                    bool bIsWaterElementsAlive = false;
                    ++m_uiShowup_Counter;
                    if (!m_lWaterElementsGUIDList.empty())
                    {
                        for(std::list<uint64>::iterator itr = m_lWaterElementsGUIDList.begin(); itr != m_lWaterElementsGUIDList.end(); ++itr)
                            if (Creature* pTemp = (Creature*)Unit::GetUnit(*m_creature, *itr))
                                if (pTemp->isAlive())
                                    bIsWaterElementsAlive = true;
                    }
                    if (!bIsWaterElementsAlive || m_uiShowup_Counter > 20)
                    {
                        m_bIsExploded = false;
                        m_uiShowup_Counter = 0;
                        m_creature->SetInCombatWithZone();
                        m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                    }
                    m_uiBuubleChecker_Timer = 1000;
                }
            }
            else m_uiBuubleChecker_Timer -= uiDiff;
        }

        if (!m_bIsExploded)
        {
            if (m_uiWaterBoltVolley_Timer < uiDiff)
            {
                DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_WATER_BOLT_VOLLEY_H : SPELL_WATER_BOLT_VOLLEY);
                m_uiWaterBoltVolley_Timer = urand(10000, 15000);
            }
            else m_uiWaterBoltVolley_Timer -= uiDiff;

            if (!m_bIsFrenzy && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25)
            {
                DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_FRENZY_H : SPELL_FRENZY);
                m_bIsFrenzy = true;
            }
        }
        DoMeleeAttackIfReady();
    }
Beispiel #25
0
    void UpdateAI(const uint32 diff)
    {
        //Check if we have a target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        //No instance
        if (!m_pInstance)
            return;

        switch (m_pInstance->GetData(TYPE_CTHUN_PHASE))
        {
            case 0:
            {
                //BeamTimer
                if (BeamTimer < diff)
                {
                    //SPELL_GREEN_BEAM
                    Unit* target = NULL;
                    target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);
                    if (target)
                    {
                        m_creature->InterruptNonMeleeSpells(false);
                        DoCastSpellIfCan(target,SPELL_GREEN_BEAM);

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

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

                //ClawTentacleTimer
                if (ClawTentacleTimer < diff)
                {
                    Unit* target = NULL;
                    target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);
                    if (target)
                    {
                        Creature* Spawned = NULL;

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

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

                    //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
                    m_pInstance->SetData(TYPE_CTHUN_PHASE, 1);

                    m_creature->InterruptNonMeleeSpells(false);

                    //Select random target for dark beam to start on
                    Unit* target = NULL;
                    target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);

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

                        //Face our target
                        DarkGlareAngle = m_creature->GetAngle(target);
                        DarkGlareTickTimer = 1000;
                        DarkGlareTick = 0;
                        ClockWise = urand(0, 1);
                    }

                    //Add red coloration to C'thun
                    DoCastSpellIfCan(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(NULL, SPELL_DARK_GLARE, false);

                    //Increase tick
                    ++DarkGlareTick;

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

                //PhaseTimer
                if (PhaseTimer < diff)
                {
                    //Switch to Eye Beam
                    m_pInstance->SetData(TYPE_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->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false);
            }
        }
    }
    void UpdateAI(const uint32 uiDiff) override
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        // Bat phase
        if (m_bIsPhaseOne)
        {
            // Phase Switch at 50%
            if (m_creature->GetHealthPercent() < 50.0f)
            {
                m_creature->RemoveAurasDueToSpell(SPELL_BAT_FORM);
                m_creature->SetLevitate(false);
                DoResetThreat();
                m_bIsPhaseOne = false;
                return;
            }

            if (m_uiChargeTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_CHARGE) == CAST_OK)
                        m_uiChargeTimer = urand(15000, 30000);
                }
            }
            else
                m_uiChargeTimer -= uiDiff;

            if (m_uiSwoopTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_SWOOP) == CAST_OK)
                    m_uiSwoopTimer = urand(4000, 9000);
            }
            else
                m_uiSwoopTimer -= uiDiff;

            if (m_uiSonicBurstTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_SONIC_BURST) == CAST_OK)
                    m_uiSonicBurstTimer = urand(8000, 13000);
            }
            else
                m_uiSonicBurstTimer -= uiDiff;

            if (m_uiSpawnBatsTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_SUMMON_FRENZIED_BATS) == CAST_OK)
                {
                    DoScriptText(SAY_SHRIEK, m_creature);
                    m_uiSpawnBatsTimer = 60000;
                }
            }
            else
                m_uiSpawnBatsTimer -= uiDiff;
        }
        // Troll phase
        else
        {
            if (m_uiShadowWordPainTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_SHADOW_WORD_PAIN) == CAST_OK)
                        m_uiShadowWordPainTimer = urand(12000, 18000);
                }
            }
            else
                m_uiShadowWordPainTimer -= uiDiff;

            if (m_uiMindFlayTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_MIND_FLAY) == CAST_OK)
                    m_uiMindFlayTimer = 16000;
            }
            else
                m_uiMindFlayTimer -= uiDiff;

            if (m_uiChainMindFlayTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_BLOOD_LEECH) == CAST_OK)
                    m_uiChainMindFlayTimer = urand(15000, 30000);
            }
            else
                m_uiChainMindFlayTimer -= uiDiff;

            if (m_uiGreaterHealTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_GREATERHEAL, CAST_INTERRUPT_PREVIOUS) == CAST_OK)
                {
                    DoScriptText(SAY_HEAL, m_creature);
                    m_uiGreaterHealTimer = urand(25000, 35000);
                }
            }
            else
                m_uiGreaterHealTimer -= uiDiff;

            if (m_uiFlyingBatsTimer)
            {
                if (m_uiFlyingBatsTimer <= uiDiff)
                {
                    // Note: the bat riders summoning and movement may need additional research
                    for (uint8 i = 0; i < 3; ++i)
                    {
                        if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                            m_creature->SummonCreature(NPC_BAT_RIDER, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ() + 15.0f, 0, TEMPSUMMON_DEAD_DESPAWN, 0);
                    }
                    DoScriptText(SAY_RAIN_FIRE, m_creature);

                    m_uiFlyingBatsTimer = 0;
                }
                else
                    m_uiFlyingBatsTimer -= uiDiff;
            }
        }

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

        // always decrease BerserkTimer
        if (m_uiBerserkTimer)
        {
            if (m_uiBerserkTimer <= uiDiff)
            {
                // Also interrupt evocation
                m_creature->RemoveAurasDueToSpell(SPELL_EVOCATION);

                if (DoCastSpellIfCan(m_creature, SPELL_BERSERK, CAST_INTERRUPT_PREVIOUS) == CAST_OK)
                {
                    // ScriptText needs confirmation
                    DoScriptText(SAY_ENRAGE, m_creature);

                    // don't know if he's supposed to do summon/evocate after hard enrage (probably not)
                    m_uiBerserkTimer = 0;
                }
            }
            else
                m_uiBerserkTimer -= uiDiff;
        }

        // not supposed to do anything while evocate
        if (m_creature->HasAura(SPELL_EVOCATION))
            return;

        if (!m_bIsEnraged)
        {
            if (m_uiFlareTimer < uiDiff)
            {
                m_uiFlareTimer = 10000;

                // summon Astral Flare
                float fX, fY, fZ;
                m_creature->GetRandomPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 10.0f, fX, fY, fZ);
                m_creature->SummonCreature(NPC_ASTRAL_FLARE, fX, fY, fZ, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);

                // reduce mana by 10% of maximum
                if (int32 iMana = m_creature->GetMaxPower(POWER_MANA))
                {
                    m_creature->ModifyPower(POWER_MANA, -(iMana/10));

                    //if this get's us below 10%, then we evocate (the 10th should be summoned now
                    if (m_creature->GetPower(POWER_MANA)*10 < m_creature->GetMaxPower(POWER_MANA))
                    {
                        if (DoCastSpellIfCan(m_creature, SPELL_EVOCATION, CAST_INTERRUPT_PREVIOUS) == CAST_OK)
                        {
                            DoScriptText(SAY_EVOCATE, m_creature);
                            //this small delay should make first flare appear fast after evocate, and also prevent possible spawn flood
                            m_uiFlareTimer = 1000;
                        }
                        return;
                    }
                    else
                    {
                        switch(urand(0, 3))
                        {
                            case 0: DoScriptText(SAY_SUMMON1, m_creature); break;
                            case 1: DoScriptText(SAY_SUMMON2, m_creature); break;
                        }
                    }
                }
            }
            else
                m_uiFlareTimer -= uiDiff;

            if (m_creature->GetHealthPercent() < 15.0f)
            {
                // Also stop evocation
                m_creature->RemoveAurasDueToSpell(SPELL_EVOCATION);

                if (DoCastSpellIfCan(m_creature, SPELL_ARCANE_INFUSION, CAST_INTERRUPT_PREVIOUS) == CAST_OK)
                {
                    DoScriptText(SAY_ENRAGE, m_creature);
                    m_bIsEnraged = true;
                }
            }
        }

        if (m_uiHatefulBoltTimer < uiDiff)
        {
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 1))
            {
                if (DoCastSpellIfCan(pTarget, SPELL_HATEFUL_BOLT) == CAST_OK)
                    m_uiHatefulBoltTimer = m_bIsEnraged ? 7000 : 15000;
            }
        }
        else
            m_uiHatefulBoltTimer -= uiDiff;

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

        if (TreeForm_Timer < diff)
        {
            DoScriptText(urand(0, 1) ? SAY_TREE_1 : SAY_TREE_2, m_creature);

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

            m_creature->RemoveAllAuras();

            DoCastSpellIfCan(m_creature, SPELL_SUMMON_FRAYER, CAST_TRIGGERED);
            DoCastSpellIfCan(m_creature, SPELL_TRANQUILITY,   CAST_TRIGGERED);
            DoCastSpellIfCan(m_creature, SPELL_TREE_FORM,     CAST_TRIGGERED);

            m_creature->GetMotionMaster()->MoveIdle();
            MoveFree = false;

            TreeForm_Timer = 75000;
        }else TreeForm_Timer -= diff;

        if (!MoveFree)
        {
            if (MoveCheck_Timer < diff)
            {
                for(GUIDList::iterator itr = Adds_List.begin(); itr != Adds_List.end(); ++itr)
                {
                    if (Creature* pTemp = m_creature->GetMap()->GetCreature(*itr))
                    {
                        if (!pTemp->isAlive())
                        {
                            Adds_List.erase(itr);
                            ++DeadAddsCount;
                            break;
                        }
                    }
                }

                if (DeadAddsCount < 3 && TreeForm_Timer-30000 < diff)
                    DeadAddsCount = 3;

                if (DeadAddsCount >= 3)
                {
                    Adds_List.clear();
                    DeadAddsCount = 0;

                    m_creature->InterruptNonMeleeSpells(true);
                    m_creature->RemoveAllAuras();
                    m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                    MoveFree = true;
                }
                MoveCheck_Timer = 500;
            }
            else MoveCheck_Timer -= diff;

            return;
        }

        /*if (m_creature->HasAura(SPELL_TREE_FORM, EFFECT_INDEX_0) || m_creature->HasAura(SPELL_TRANQUILITY, EFFECT_INDEX_0))
            return;*/

        //one random seedling every 5 secs, but not in tree form
        if (SummonSeedling_Timer < diff)
        {
            DoSummonSeedling();
            SummonSeedling_Timer = 6000;
        }else SummonSeedling_Timer -= diff;

        DoMeleeAttackIfReady();
    }
    void UpdateAI(const uint32 uiDiff) override
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
        {
            if (m_uiMovementTimer)
            {
                if (m_uiMovementTimer <= uiDiff)
                {
                    if (m_pInstance)
                    {
                        if (m_pInstance->GetData(TYPE_VAZRUDEN) == IN_PROGRESS)
                            DoMoveToAir();
                        else
                            DoMoveToCenter();
                    }
                    m_uiMovementTimer = 0;
                }
                else
                    m_uiMovementTimer -= uiDiff;
            }

            if (m_vazrudenGuid && m_uiFireballTimer)
            {
                if (m_uiFireballTimer <= uiDiff)
                {
                    if (Creature* pVazruden = m_creature->GetMap()->GetCreature(m_vazrudenGuid))
                    {
                        if (Unit* pEnemy = pVazruden->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                        {
                            if (DoCastSpellIfCan(pEnemy, m_bIsRegularMode ? SPELL_FIREBALL : SPELL_FIREBALL_H, 0, pVazruden->GetObjectGuid()) == CAST_OK)
                                m_uiFireballTimer = urand(2100, 7300);
                        }
                    }
                }
                else
                    m_uiFireballTimer -= uiDiff;

                if (m_uiFireballBTimer < uiDiff)
                {
                    if (Creature* pVazruden = m_creature->GetMap()->GetCreature(m_vazrudenGuid))
                    {
                        if (Unit* pEnemy = pVazruden->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                        {
                            if (DoCastSpellIfCan(pEnemy, m_bIsRegularMode ? SPELL_FIREBALL_B : SPELL_FIREBALL_B_H, 0, pVazruden->GetObjectGuid()) == CAST_OK)
                                m_uiFireballBTimer = 15700;
                        }
                    }
                }
                else
                    m_uiFireballBTimer -= uiDiff;
            }

            if (m_creature->GetHealthPercent() < 20.0f)
                DoMoveToCombat();

            return;
        }

        // In Combat
        if (m_uiFireballTimer < uiDiff)
        {
            if (Unit* pEnemy = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
            {
                if (DoCastSpellIfCan(pEnemy, m_bIsRegularMode ? SPELL_FIREBALL_LAND : SPELL_FIREBALL_LAND_H) == CAST_OK)
                    m_uiFireballTimer = urand(7300, 13200);
            }
        }
        else
            m_uiFireballTimer -= uiDiff;

        if (m_uiConeOfFireTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature->getVictim(), m_bIsRegularMode ? SPELL_CONE_OF_FIRE : SPELL_CONE_OF_FIRE_H) == CAST_OK)
                m_uiConeOfFireTimer = urand(7300, 13200);
        }
        else
            m_uiConeOfFireTimer -= uiDiff;

        if (!m_bIsRegularMode)
        {
            if (m_uiBellowingRoarTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_BELLOW_ROAR_H) == CAST_OK)
                    m_uiBellowingRoarTimer = urand(8000, 12000); // TODO Guesswork, 8s cooldown
            }
            else
                m_uiBellowingRoarTimer -= uiDiff;
        }

        DoMeleeAttackIfReady();
    }
Beispiel #30
0
    void UpdateAI(const uint32 diff)
    {
        if (!Init)
        {
            if (EventProgress_Timer < diff)
            {
                if (Phase < 8)
                {
                    switch(Phase)
                    {
                        case 1:
                            DoScriptText(SAY_INTRO_1, m_creature);
                            EventProgress_Timer = 18000;
                            break;
                        case 2:
                            DoScriptText(SAY_INTRO_2, m_creature);
                            EventProgress_Timer = 18000;
                            break;
                        case 3:
                            DoScriptText(SAY_WATER, m_creature);
                            DoCastSpellIfCan(m_creature,SPELL_CONJURE_WATER);
                            EventProgress_Timer = 7000;
                            break;
                        case 4:
                            DoScriptText(SAY_BUFFS, m_creature);
                            DoCastSpellIfCan(m_creature,SPELL_ICE_ARMOR);
                            EventProgress_Timer = 7000;
                            break;
                        case 5:
                            DoScriptText(SAY_DRINK, m_creature);
                            DoCastSpellIfCan(m_creature,SPELL_ARCANE_INTELLECT);
                            EventProgress_Timer = 7000;
                            break;
                        case 6:
                            DoScriptText(SAY_READY, m_creature);
                            EventProgress_Timer = 6000;
                            break;
                        case 7:
                            if (m_pInstance)
                                m_pInstance->SetData(TYPE_WARDEN_2,DONE);
                            Init = true;
                            break;
                    }
                    ++Phase;
                }
            } else EventProgress_Timer -= diff;
        }

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

        if (!LowHp && m_creature->GetHealthPercent() < 20.0f)
        {
            DoScriptText(SAY_LOWHP, m_creature);
            LowHp = true;
        }

        if (Pyroblast_Timer < diff)
        {
            if (m_creature->IsNonMeleeSpellCasted(false))
                return;

            DoScriptText(SAY_PYRO, m_creature);

            DoCastSpellIfCan(m_creature->getVictim(),SPELL_PYROBLAST);
            Pyroblast_Timer = 40000;
        }else Pyroblast_Timer -=diff;

        if (Fireball_Timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_FIREBALL);
            Fireball_Timer = 4000;
        }else Fireball_Timer -=diff;

        DoMeleeAttackIfReady();
    }