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

        // Impale
        if (m_uiImpaleTimer < uiDiff)
        {
            //Cast Impale on a random target
            //Do NOT cast it when we are afflicted by locust swarm
            if (!m_creature->HasAura(SPELL_LOCUSTSWARM) || !m_creature->HasAura(SPELL_LOCUSTSWARM_H))
            {
                if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                    DoCast(target, m_bIsRegularMode ? SPELL_IMPALE : SPELL_IMPALE_H);
            }

            m_uiImpaleTimer = 15000;
        }
        else
            m_uiImpaleTimer -= uiDiff;

        // Locust Swarm
        if (m_uiLocustSwarmTimer < uiDiff)
        {
            DoCast(m_creature, m_bIsRegularMode?SPELL_LOCUSTSWARM_H:SPELL_LOCUSTSWARM);
            m_uiLocustSwarmTimer = 90000;
            m_uiSummonTimer = 15000;
        }
        else
            m_uiLocustSwarmTimer -= uiDiff;

        if (m_uiSummonTimer < uiDiff)
        {
            SummonGuard();
            m_uiSummonTimer = 240000;
        }else m_uiSummonTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }
Beispiel #2
0
    void MoveInLineOfSight(Unit* pWho) override
    {
        if (!m_pSpawnAssoc)
            return;

        if (pWho->isTargetableForAttack() && m_creature->IsHostileTo(pWho))
        {
            Player* pPlayerTarget = pWho->GetTypeId() == TYPEID_PLAYER ? (Player*)pWho : nullptr;

            // airforce guards only spawn for players
            if (!pPlayerTarget)
                return;

            Creature* pLastSpawnedGuard = m_spawnedGuid ? GetSummonedGuard() : nullptr;

            // prevent calling GetCreature at next MoveInLineOfSight call - speedup
            if (!pLastSpawnedGuard)
                m_spawnedGuid.Clear();

            switch (m_pSpawnAssoc->m_SpawnType)
            {
            case SPAWNTYPE_ALARMBOT:
            {
                if (!pWho->IsWithinDistInMap(m_creature, RANGE_GUARDS_MARK))
                    return;

                Aura* pMarkAura = pWho->GetAura(SPELL_GUARDS_MARK, EFFECT_INDEX_0);
                if (pMarkAura)
                {
                    // the target wasn't able to move out of our range within 25 seconds
                    if (!pLastSpawnedGuard)
                    {
                        pLastSpawnedGuard = SummonGuard();

                        if (!pLastSpawnedGuard)
                            return;
                    }

                    if (pMarkAura->GetAuraDuration() < AURA_DURATION_TIME_LEFT)
                    {
                        if (!pLastSpawnedGuard->getVictim())
                            pLastSpawnedGuard->AI()->AttackStart(pWho);
                    }
                }
                else
                {
                    if (!pLastSpawnedGuard)
                        pLastSpawnedGuard = SummonGuard();

                    if (!pLastSpawnedGuard)
                        return;

                    pLastSpawnedGuard->CastSpell(pWho, SPELL_GUARDS_MARK, true);
                }
                break;
            }
            case SPAWNTYPE_TRIPWIRE_ROOFTOP:
            {
                if (!pWho->IsWithinDistInMap(m_creature, RANGE_TRIPWIRE))
                    return;

                if (!pLastSpawnedGuard)
                    pLastSpawnedGuard = SummonGuard();

                if (!pLastSpawnedGuard)
                    return;

                // ROOFTOP only triggers if the player is on the ground
                if (!pPlayerTarget->IsFlying())
                {
                    if (!pLastSpawnedGuard->getVictim())
                        pLastSpawnedGuard->AI()->AttackStart(pWho);
                }
                break;
            }
            }
        }
    }