Example #1
0
void boss_mr_smiteAI::UpdateAI(const uint32 uiDiff)
{
	// Equipment phase (Somehow hacky I think, since this is determined by his target...)
    if (!m_creature->SelectHostileTarget() ||
		!m_creature->getVictim())
    {
		// decrease the cooldown in between equipment change phases
        if (m_uiEquipTimer)
        {
            if (m_uiEquipTimer > uiDiff)
            {
                m_uiEquipTimer -= uiDiff;
                return;		// STOP here since the timer has not yet expired
            }
            else
                m_uiEquipTimer = 0;
        }

		// Choose which phase needs to be updated
        switch (m_uiPhase)
        {
            case PHASE_EQUIP_START:
                PhaseEquipStart();
                break;

            case PHASE_EQUIP_PROCESS:
                PhaseEquipProcess();
                break;

            case PHASE_EQUIP_END:
                PhaseEquipEnd();
                break;
        }

        return;
    }

    // Normal combat phases
    switch (m_uiPhase)
    {
    case PHASE_1:
		{
			// On 66% life or below, go on to equipment phase (Double Axe)
			if (m_creature->GetHealthPercent() < 66.0f)
			{
				// This will stun all players around!
				if (DoCastSpellIfCan(m_creature, SPELL_SMITE_STOMP) == CAST_OK)
				{
					// Show Mr. Smite texts (This code allows skipping the double axe if Mr. Smite's health 
					// sinks too quickly - was it like that in classic?)
					DoScriptText(m_creature->GetHealthPercent() < 33.0f ? SAY_PHASE_3 : SAY_PHASE_2, m_creature);
					
					// Go on with equip phase (2.5 Seconds duration)
					m_uiPhase = PHASE_EQUIP_START;
					m_uiEquipTimer = 2500;

					// We need to clear victim and stop combat
					m_creature->AttackStop(true);
					m_creature->RemoveAurasDueToSpell(SPELL_NIBLE_REFLEXES);
				}

				return;
			}
			break;
		}

    case PHASE_2:
		{
			// On 33% life or below, go on to equipment phase again!
			
			if (m_creature->GetHealthPercent() < 33.0f)
			{
				// This will stun all players around!
				if (DoCastSpellIfCan(m_creature, SPELL_SMITE_STOMP) == CAST_OK)
				{
					// Let him yell his text
					DoScriptText(SAY_PHASE_3, m_creature);
					
					// Go on with equip phase (2.5 Seconds duration)
					m_uiPhase = PHASE_EQUIP_START;
					m_uiEquipTimer = 2500;

					// We need to clear victim and stop combat
					m_creature->AttackStop(true);
					m_creature->RemoveAurasDueToSpell(SPELL_THRASH);
				}

				return;
			}
			break;
		}

	case PHASE_3:
		{
			// Use "Slam" every 11 Seconds
			if (m_uiSlamTimer < uiDiff)
			{
				if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_SMITE_SLAM) == CAST_OK)
					m_uiSlamTimer = SPELL_SMITE_SLAM_COOLDOWN;
			}
			else
			{
				m_uiSlamTimer -= uiDiff;
			}

			break;
		}
    }

	// Do melee attack on cooldown (Not reached during equipment phases)
    DoMeleeAttackIfReady();
}
    void UpdateAI(const uint32 uiDiff) override
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
        {
            if (m_uiEquipTimer)
            {
                // decrease the cooldown in between equipment change phases
                if (m_uiEquipTimer > uiDiff)
                {
                    m_uiEquipTimer -= uiDiff;
                    return;
                }
                else
                    m_uiEquipTimer = 0;
            }

            switch (m_uiPhase)
            {
                case PHASE_EQUIP_START:
                    PhaseEquipStart();
                    break;
                case PHASE_EQUIP_PROCESS:
                    PhaseEquipProcess();
                    break;
                case PHASE_EQUIP_END:
                    PhaseEquipEnd();
                    break;
            }

            return;
        }

        // the normal combat phases
        switch (m_uiPhase)
        {
            case PHASE_1:
            {
                if (m_creature->GetHealthPercent() < 66.0f)
                {
                    if (DoCastSpellIfCan(m_creature, SPELL_SMITE_STOMP) == CAST_OK)
                    {
                        DoScriptText(m_creature->GetHealthPercent() < 33.0f ? SAY_PHASE_3 : SAY_PHASE_2, m_creature);
                        m_uiPhase = PHASE_EQUIP_START;
                        m_uiEquipTimer = 2500;

                        // will clear getVictim (m_attacking)
                        m_creature->AttackStop(true);
                        m_creature->RemoveAurasDueToSpell(SPELL_NIBLE_REFLEXES);
                    }
                    return;
                }
                break;
            }
            case PHASE_2:
            {
                if (m_creature->GetHealthPercent() < 33.0f)
                {
                    if (DoCastSpellIfCan(m_creature, SPELL_SMITE_STOMP) == CAST_OK)
                    {
                        DoScriptText(SAY_PHASE_3, m_creature);
                        m_uiPhase = PHASE_EQUIP_START;
                        m_uiEquipTimer = 2500;

                        // will clear getVictim (m_attacking)
                        m_creature->AttackStop(true);
                        m_creature->RemoveAurasDueToSpell(SPELL_THRASH);
                    }
                    return;
                }
                break;
            }
            case PHASE_3:
            {
                if (m_uiSlamTimer < uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_SMITE_SLAM) == CAST_OK)
                        m_uiSlamTimer = 11000;
                }
                else
                    m_uiSlamTimer -= uiDiff;

                break;
            }
        }

        DoMeleeAttackIfReady();
    }