All pastes #762980 Raw Edit

Unnamed

public cpp v1 · immutable
·published 2007-11-06 01:26 UTC
rendered paste body
struct MANGOS_DLL_DECL mob_hellfire_channelerAI : public ScriptedAI{    mob_hellfire_channelerAI(Creature *c) : ScriptedAI(c) {EnterEvadeMode();}    uint32 ShadowBoltVolley_Timer;    uint32 DarkMending_Timer;    uint32 Fear_Timer;    uint32 Infernal_Timer;    std::list<uint64> FriendlyList;    bool InfernalSpawned;    void EnterEvadeMode()    {        ShadowBoltVolley_Timer = 10000;        DarkMending_Timer = 30000;        Fear_Timer = 20000;        Infernal_Timer = 30000;        InfernalSpawned = false;        FriendlyList.clear();        m_creature->RemoveAllAuras();        m_creature->DeleteThreatList();        m_creature->CombatStop();        DoGoHome();        // Must be scripted - don't know how.....        //DoCast(m_creature,SPELL_HELLFIRE_CHANNELING);        //DoCast(m_creature,SPELL_HELLFIRE_CAST_VISUAL);    }    bool ListContains(std::list<uint64> &plist, uint64 element)    {        if (plist.empty())            return false;        std::list<uint64>::iterator i;        for (i = plist.begin(); i!=plist.end(); ++i)        {            if ((*i) == element)                return true;        }        return false;    }    void AttackStart(Unit *who)    {        if (!who) return;        if (who->isTargetableForAttack() && who!= m_creature)        {            DoStartMeleeAttack(who);        }    }    void MoveInLineOfSight(Unit *who)    {        if (!who) return;        if (!m_creature->IsHostileTo(who) && !ListContains(FriendlyList, who->GetGUID()))            FriendlyList.push_back(who->GetGUID());        if (m_creature->getVictim())            return;        if (who->isTargetableForAttack() && who->isInAccessablePlaceFor(m_creature) && m_creature->IsHostileTo(who))        {            float attackRadius = m_creature->GetAttackDistance(who);            if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->GetDistanceZ(who) <= CREATURE_Z_ATTACK_RANGE && m_creature->IsWithinLOSInMap(who))            {                if(who->HasStealthAura()) who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);                DoStartMeleeAttack(who);            }        }    }    void UpdateAI(const uint32 diff)    {        //Return since we have no target        if (!m_creature->SelectHostilTarget() || !m_creature->getVictim() )            return;        //Shadow bolt volley        if (ShadowBoltVolley_Timer < diff)        {            DoCast(m_creature->getVictim(),SPELL_SHADOW_BOLT_VOLLEY);            ShadowBoltVolley_Timer = 10000 + (rand()%10000);        }else ShadowBoltVolley_Timer -= diff;        //Dark Mending        if (DarkMending_Timer < diff)        {            if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 50)            {                //If no friends then heal self                if (FriendlyList.empty())                    DoCast(m_creature, SPELL_DARK_MENDING);                //Cast Dark Mending on the target with the lowest                //amount of HP within 30 yards (cast range)                uint32 LowestHP = 0;                Unit* pLowestHPTarget = NULL;                Unit* pTemp = NULL;                std::list<uint64>::iterator i;                for (i = FriendlyList.begin(); i!=FriendlyList.end(); ++i)                {                    pTemp = Unit::GetUnit((*m_creature),(*i));                    if (pTemp && pTemp->isAlive() && pTemp->GetHealth() < LowestHP && m_creature->GetDistance2dSq(pTemp) < 900)                    {                        LowestHP = pTemp->GetHealth();                        pLowestHPTarget = pTemp;                    }                }                //Cast on ourselves if we are lower then lowest hp friendly unit                if (pLowestHPTarget && LowestHP < m_creature->GetHealth())                    DoCast(pLowestHPTarget, SPELL_DARK_MENDING);                else DoCast(m_creature, SPELL_DARK_MENDING);            }            DarkMending_Timer = 10000 + (rand() % 10000);        }else DarkMending_Timer -= diff;        //Fear        if (Fear_Timer < diff)        {            Unit* target = NULL;            target = SelectUnit(SELECT_TARGET_RANDOM, 1);            if (target)                DoCast(target,SPELL_FEAR);            Fear_Timer = 25000 + (rand()%15000);        }else Fear_Timer -= diff;        //Infernal spawning        if (!InfernalSpawned && Infernal_Timer < diff)        {            Unit* target = NULL;            target = SelectUnit(SELECT_TARGET_RANDOM, 0);            if (target)                DoCast(target, SPELL_BURNING_ABYSSAL);            /*Creature* Infernal = m_creature->SummonCreature(CREATURE_INFERNAL, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 60000);            if (Infernal)            {                Infernal->setFaction(m_creature->getFaction());                Unit* target = NULL;                target = SelectUnit(SELECT_TARGET_RANDOM, 0);                if (target)                    Infernal->AI()->AttackStart(target);            }*/            InfernalSpawned = true;        }else Infernal_Timer -= diff;        DoMeleeAttackIfReady();    }};