Beispiel #1
0
    void UpdateAI(const uint32 diff)
    {
        if(!UpdateVictim() )
            return;

        boss_moroes_guestAI::UpdateAI(diff);

        if(MindFlay_Timer < diff)
        {
            DoCast(m_creature->getVictim(),SPELL_MINDFLY);
            MindFlay_Timer = 12000;                         //3sec channeled
        }else MindFlay_Timer -= diff;

        if(ManaBurn_Timer < diff)
        {
            Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0);
            if(target && (target->getPowerType() == POWER_MANA))
                DoCast(target,SPELL_MANABURN);
            ManaBurn_Timer = 5000;                          //3 sec cast
        }else ManaBurn_Timer -= diff;

        if(ShadowWordPain_Timer < diff)
        {
            Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0);
            if(target)
            {
                DoCast(target,SPELL_SWPAIN);
                ShadowWordPain_Timer = 7000;
            }
        }else ShadowWordPain_Timer -= diff;
    }
 Unit* GetHatedManaUser()
 {
     ThreatContainer::StorageType::const_iterator i;
     for (i = me->getThreatManager().getThreatList().begin(); i != me->getThreatManager().getThreatList().end(); ++i)
     {
         Unit* pUnit = Unit::GetUnit((*me), (*i)->getUnitGuid());
         if (pUnit->getPowerType() == POWER_MANA)
             return pUnit;
     }
     return NULL;
 }
 Unit* GetHatedManaUser()
 {
     std::list<HostileReference*>::iterator i;
     for (i = me->getThreatManager().getThreatList().begin();i != me->getThreatManager().getThreatList().end(); ++i)
     {
         Unit* pUnit = Unit::GetUnit((*me), (*i)->getUnitGuid());
         if (pUnit->getPowerType() == POWER_MANA)
             return pUnit;
     }
     return NULL;
 }
 Unit* SelectEnemyCaster(bool casting)
 {
     ThreatList const& tList = m_creature->getThreatManager().getThreatList();
     ThreatList::const_iterator iter;
     for(iter = tList.begin(); iter!=tList.end(); ++iter)
     {
         Unit *target;
         if(target = Unit::GetUnit((*m_creature),(*iter)->getUnitGuid()))
             if(target->getPowerType() == POWER_MANA)
                 return target;
     }
     return NULL;
 }
Beispiel #5
0
    void UpdateAI(const uint32 diff)
    {
        //Return since we have no target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if(CleaveTimer < diff)
        {
            if(m_creature->getVictim())
                DoCast(m_creature->getVictim(), SPELL_CLEAVE);
            CleaveTimer = 6000+rand()%15000;
        }else CleaveTimer -= diff;

        if(WarStompTimer < diff)
        {
            DoCast(m_creature, SPELL_WARSTOMP);
            WarStompTimer = 60000;
        }else WarStompTimer -= diff;

        if(m_creature->HasAura(SPELL_MARK))
            m_creature->RemoveAurasDueToSpell(SPELL_MARK);

        if(MarkBlastTimer < diff)
        {
            std::list<HostileReference *> t_list = m_creature->getThreatManager().getThreatList();
            for(std::list<HostileReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
            {
                Unit *target = m_creature->GetMap()->GetUnit((*itr)->getUnitGuid());

                if (target && target->GetTypeId() == TYPEID_PLAYER && target->getPowerType() == POWER_MANA)
                    if(target->HasAura(SPELL_MARK))
                        if((target->GetPower(POWER_MANA)*100) / target->GetMaxPower(POWER_MANA) <= 1)
                            target->CastSpell(target, SPELL_MARK2, true);
            }
            MarkBlastTimer = 1000;
        }MarkBlastTimer -= diff;

        if(MarkTimer < diff)
        {
            CastMark();
            MarkTimer = BaseMarkTimer - MarkCount * 10000;
            if(MarkCount < 6)
                ++MarkCount;
            else
                MarkTimer = 5000;

        }else MarkTimer -= diff;

        DoMeleeAttackIfReady();
    }
Beispiel #6
0
 void CastMark()
 {
     SpellEntry *spellInfo = (SpellEntry *)GetSpellStore()->LookupEntry(SPELL_MARK);
     if (spellInfo)
     {
         std::list<HostileReference *> t_list = m_creature->getThreatManager().getThreatList();
         for(std::list<HostileReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
         {
             Unit *target = m_creature->GetMap()->GetUnit((*itr)->getUnitGuid());
             if (target && target->GetTypeId() == TYPEID_PLAYER && target->getPowerType() == POWER_MANA)
             {
                 for(uint32 i=0; i < MAX_EFFECT_INDEX; ++i)
                 {
                     uint8 eff = spellInfo->Effect[SpellEffectIndex(i)];
                     if (eff >= TOTAL_SPELL_EFFECTS)
                         continue;
                     /*target->AddAura(new KazrogalMark(spellInfo, SpellEffectIndex(i), NULL, target, target));*/
                 }    
             }
         }
     }
 }
    void UpdateAI(const uint32 uiDiff)
    {
        // Speach
        if (mbIsDoingSpeach)
        {
            if (m_uiSpeachTimer < uiDiff)
            {
                switch (m_uiSpeachNum)
                {
                    case 0:
                        // 16 seconds till next line
                        DoScriptText(SAY_LINE_2, m_creature);
                        m_uiSpeachTimer = 16000;
                        ++m_uiSpeachNum;
                        break;
                    case 1:
                        // This one is actually 16 seconds but we only go to 10 seconds because he starts attacking after he says "I must fight this!"
                        DoScriptText(SAY_LINE_3, m_creature);
                        m_uiSpeachTimer = 10000;
                        ++m_uiSpeachNum;
                        break;
                    case 2:
                        m_creature->setFaction(103);
                        m_creature->SetHealth(int(m_creature->GetMaxHealth()*.3));

                        if (m_uiPlayerGUID)
                        {
                            if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_uiPlayerGUID))
                                AttackStart(pPlayer);

                            DoCastSpellIfCan(m_creature, SPELL_ESSENCE_OF_THE_RED);
                        }
                        m_uiSpeachTimer = 0;
                        mbIsDoingSpeach = false;
                        break;
                }
            }
            else
                m_uiSpeachTimer -= uiDiff;
        }

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

        // Yell if hp lower than 15%
        if (m_creature->GetHealthPercent() < 15.0f && !m_bHasYelled)
        {
            DoScriptText(SAY_HALFLIFE, m_creature);
            m_bHasYelled = true;
        }

        // Cleave Timer
        if (m_uiCleaveTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_CLEAVE) == CAST_OK)
                m_uiCleaveTimer = 15000;
        }
        else
            m_uiCleaveTimer -= uiDiff;

        // Flame Breath Timer
        if (m_uiFlameBreathTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_FLAME_BREATH) == CAST_OK)
                m_uiFlameBreathTimer = urand(4000, 8000);
        }
        else
            m_uiFlameBreathTimer -= uiDiff;

        // Burning Adrenaline Caster Timer
        if (m_uiBurningAdrenalineCasterTimer < uiDiff)
        {
            Unit* pTarget = NULL;

            // TODO Target Selection must be improved!
            int i = 0 ;
            while (i < 3)                                   // max 3 tries to get a random target with power_mana
            {
                ++i;
                pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1);
                if (pTarget)
                    if (pTarget->getPowerType() == POWER_MANA)
                        i=3;
            }
            if (pTarget)                                    // cast on self (see below)
                pTarget->CastSpell(pTarget, SPELL_BURNING_ADRENALINE, true);

            m_uiBurningAdrenalineCasterTimer = 15000;
        }
        else
            m_uiBurningAdrenalineCasterTimer -= uiDiff;

        // Burning Adrenaline Tank Timer
        if (m_uiBurningAdrenalineTankTimer < uiDiff)
        {
            // have the victim cast the spell on himself otherwise the third effect aura will be applied
            // to Vael instead of the player
            m_creature->getVictim()->CastSpell(m_creature->getVictim(), SPELL_BURNING_ADRENALINE, true);

            m_uiBurningAdrenalineTankTimer = 45000;
        }
        else
            m_uiBurningAdrenalineTankTimer -= uiDiff;

        // Fire Nova Timer
        if (m_uiFireNovaTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_FIRE_NOVA) == CAST_OK)
                m_uiFireNovaTimer = 5000;
        }
        else
            m_uiFireNovaTimer -= uiDiff;

        // Tail Sweep Timer
        if (m_uiTailSweepTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_TAIL_SWEEP) == CAST_OK)
                m_uiTailSweepTimer = 20000;
        }
        else
            m_uiTailSweepTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }
Beispiel #8
0
    void UpdateAI(const uint32 diff)
    {
        if (IsEvent)
        {
            //Must update npc_escortAI
            npc_escortAI::UpdateAI(diff);
            if (!pGo)
            {
                pGo = true;
                if (pInstance)
                {
                    AddWaypoint(0, 5492.91,    -2404.61,    1462.63);
                    AddWaypoint(1, 5531.76,    -2460.87,    1469.55);
                    AddWaypoint(2, 5554.58,    -2514.66,    1476.12);
                    AddWaypoint(3, 5554.16,    -2567.23,    1479.90);
                    AddWaypoint(4, 5540.67,    -2625.99,    1480.89);
                    AddWaypoint(5, 5508.16,    -2659.2,    1480.15);
                    AddWaypoint(6, 5489.62,    -2704.05,    1482.18);
                    AddWaypoint(7, 5457.04,    -2726.26,    1485.10);
                    Start(false, true);
                    SetDespawnAtEnd(false);
                }
            }
        }

        //Return since we have no target
        if (!UpdateVictim())
            return;

        if (CleaveTimer < diff)
        {
            DoCast(m_creature, SPELL_CLEAVE);
            CleaveTimer = 6000+rand()%15000;
        }else CleaveTimer -= diff;

        if (WarStompTimer < diff)
        {
            DoCast(m_creature, SPELL_WARSTOMP);
            WarStompTimer = 60000;
        }else WarStompTimer -= diff;

        if (m_creature->HasAura(SPELL_MARK))
            m_creature->RemoveAurasDueToSpell(SPELL_MARK);
        if (MarkTimer < diff)
        {
            //cast dummy, useful for bos addons
            m_creature->CastCustomSpell(m_creature, SPELL_MARK, NULL, NULL, NULL, false, NULL, NULL, m_creature->GetGUID());

            std::list<HostilReference *> t_list = m_creature->getThreatManager().getThreatList();
            for(std::list<HostilReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
            {
                Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                if (target && target->GetTypeId() == TYPEID_PLAYER && target->getPowerType() == POWER_MANA)
                {
                    target->CastSpell(target, SPELL_MARK,true);//only cast on mana users
                }
            }
            MarkTimerBase -= 5000;
            if (MarkTimerBase < 5500)
                MarkTimerBase = 5500;
            MarkTimer = MarkTimerBase;
            switch(rand()%3)
            {
                case 0:
                    DoPlaySoundToSet(m_creature, SOUND_MARK1);
                    m_creature->MonsterYell(SAY_MARK1, LANG_UNIVERSAL, NULL);
                    break;
                case 1:
                    DoPlaySoundToSet(m_creature, SOUND_MARK2);
                    m_creature->MonsterYell(SAY_MARK2, LANG_UNIVERSAL, NULL);
                    break;
            }
        }else MarkTimer -= diff;

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

        if (!m_pInstance || m_pInstance->GetData(TYPE_KELTHUZAD) != IN_PROGRESS)
            return;

        if (m_uiPhase == PHASE_INTRO)
        {
            if (m_uiIntroPackCount < 7)
            {
                if (m_uiSummonIntroTimer < uiDiff)
                {
                    if (!m_uiIntroPackCount)
                        DoScriptText(SAY_SUMMON_MINIONS, m_creature);

                    SummonIntroCreatures(m_uiIntroPackCount);
                    ++m_uiIntroPackCount;
                    m_uiSummonIntroTimer = 2000;
                }
                else
                    m_uiSummonIntroTimer -= uiDiff;
            }
            else
            {
                if (m_uiPhase1Timer < uiDiff)
                {
                    m_uiPhase = PHASE_NORMAL;
                    DespawnIntroCreatures();
                    m_creature->InterruptNonMeleeSpells(false);
                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    SetCombatMovement(true);
                    m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());

                    DoScriptText(EMOTE_PHASE2, m_creature);

                    switch(urand(0, 2))
                    {
                        case 0: DoScriptText(SAY_AGGRO1, m_creature); break;
                        case 1: DoScriptText(SAY_AGGRO2, m_creature); break;
                        case 2: DoScriptText(SAY_AGGRO3, m_creature); break;
                    };
                }
                else
                    m_uiPhase1Timer -= uiDiff;

                if (m_uiSoldierCount < MAX_SOLDIER_COUNT)
                {
                    if (m_uiSoldierTimer < uiDiff)
                    {
                        SummonMob(NPC_SOLDIER_FROZEN);
                        ++m_uiSoldierCount;
                        m_uiSoldierTimer = 3000;
                    }
                    else
                        m_uiSoldierTimer -= uiDiff;
                }

                if (m_uiAbominationCount < MAX_ABOMINATION_COUNT)
                {
                    if (m_uiAbominationTimer < uiDiff)
                    {
                        SummonMob(NPC_UNSTOPPABLE_ABOM);
                        ++m_uiAbominationCount;
                        m_uiAbominationTimer = 25000;
                    }
                    else
                        m_uiAbominationTimer -= uiDiff;
                }

                if (m_uiBansheeCount < MAX_BANSHEE_COUNT)
                {
                    if (m_uiBansheeTimer < uiDiff)
                    {
                        SummonMob(NPC_SOUL_WEAVER);
                        ++m_uiBansheeCount;
                        m_uiBansheeTimer = 25000;
                    }
                    else
                        m_uiBansheeTimer -= uiDiff;
                }
            }
        }
        else // normal or guardian phase
        {
            if (m_uiFrostBoltTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), m_bIsRegularMode ? SPELL_FROST_BOLT : SPELL_FROST_BOLT_H) == CAST_OK)
                    m_uiFrostBoltTimer = urand(1000, 60000);
            }
            else
                m_uiFrostBoltTimer -= uiDiff;

            if (m_uiFrostBoltNovaTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), m_bIsRegularMode ? SPELL_FROST_BOLT_NOVA : SPELL_FROST_BOLT_NOVA_H) == CAST_OK)
                    m_uiFrostBoltNovaTimer = 15000;
            }
            else
                m_uiFrostBoltNovaTimer -= uiDiff;

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

                if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER && pTarget->getPowerType() == POWER_MANA)
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_DETONATE_MANA) == CAST_OK)
                    {
                        if (urand(0, 1))
                            DoScriptText(SAY_SPECIAL1_MANA_DET, m_creature);

                        m_uiManaDetonationTimer = 20000;
                    }
                }
            }
            else
                m_uiManaDetonationTimer -= uiDiff;

            if (m_uiShadowFissureTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_SHADOW_FISSURE) == CAST_OK)
                    {
                        if (urand(0, 1))
                            DoScriptText(SAY_SPECIAL3_MANA_DET, m_creature);

                        m_uiShadowFissureTimer = 25000;
                    }
                }
            }
            else
                m_uiShadowFissureTimer -= uiDiff;

            if (m_uiFrostBlastTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_FROST_BLAST) == CAST_OK)
                {
                    if (urand(0, 1))
                        DoScriptText(SAY_FROST_BLAST, m_creature);

                    m_uiFrostBlastTimer = urand(30000, 60000);
                }
            }
            else
                m_uiFrostBlastTimer -= uiDiff;

            if (!m_bIsRegularMode)
            {
                if (m_uiChainsTimer < uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_CHAINS_OF_KELTHUZAD) == CAST_OK)
                    {
                        DoScriptText(urand(0, 1) ? SAY_CHAIN1 : SAY_CHAIN2, m_creature);

                        m_uiChainsTimer = urand(30000, 60000);
                    }
                }
                else
                    m_uiChainsTimer -= uiDiff;
            }

            if (m_uiPhase == PHASE_NORMAL)
            {
                if (m_creature->GetHealthPercent() < 45.0f)
                {
                    m_uiPhase = PHASE_GUARDIANS;
                    DoScriptText(SAY_REQUEST_AID, m_creature);
                }
            }
            else if (m_uiPhase == PHASE_GUARDIANS && m_uiGuardiansCount < m_uiGuardiansCountMax)
            {
                if (m_uiGuardiansTimer < uiDiff)
                {
                    // Summon a Guardian of Icecrown in a random alcove
                    SummonMob(NPC_GUARDIAN);
                    m_uiGuardiansTimer = 5000;
                }
                else
                    m_uiGuardiansTimer -= uiDiff;

                if (m_uiLichKingAnswerTimer && m_pInstance)
                {
                    if (m_uiLichKingAnswerTimer <= uiDiff)
                    {
                        if (Creature* pLichKing = m_pInstance->GetSingleCreatureFromStorage(NPC_THE_LICHKING))
                            DoScriptText(SAY_ANSWER_REQUEST, pLichKing);
                        m_uiLichKingAnswerTimer = 0;
                    }
                    else
                        m_uiLichKingAnswerTimer -= uiDiff;
                }
            }

            DoMeleeAttackIfReady();
        }
    }
Beispiel #10
0
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
{
    DEBUG_LOG("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
    uint64 Guid;
    recv_data >> Guid;

    Player *player = sObjectMgr.GetPlayer(Guid);
    if(!player)
    {
        WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2);
        data << uint8(0);                                   // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
        data.appendPackGUID(Guid);
        data << uint32(GROUP_UPDATE_FLAG_STATUS);
        data << uint16(MEMBER_STATUS_OFFLINE);
        SendPacket(&data);
        return;
    }

    Unit *pet = player->GetCharmOrPet();

    WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
    data << uint8(0);                                       // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
    data << player->GetPackGUID();

    uint32 mask1 = 0x00040BFF;                              // common mask, real flags used 0x000040BFF
    if(pet)
        mask1 = 0xFFFFFFFF;                                 // for hunters and other classes with pets

    Powers powerType = player->getPowerType();
    data << uint32(mask1);                                  // group update mask
    data << uint16(MEMBER_STATUS_ONLINE);                   // member's online status
    data << uint32(player->GetHealth());                    // GROUP_UPDATE_FLAG_CUR_HP
    data << uint32(player->GetMaxHealth());                 // GROUP_UPDATE_FLAG_MAX_HP
    data << uint8(powerType);                               // GROUP_UPDATE_FLAG_POWER_TYPE
    data << uint16(player->GetPower(powerType));            // GROUP_UPDATE_FLAG_CUR_POWER
    data << uint16(player->GetMaxPower(powerType));         // GROUP_UPDATE_FLAG_MAX_POWER
    data << uint16(player->getLevel());                     // GROUP_UPDATE_FLAG_LEVEL
    data << uint16(player->GetZoneId());                    // GROUP_UPDATE_FLAG_ZONE
    data << uint16(player->GetPositionX());                 // GROUP_UPDATE_FLAG_POSITION
    data << uint16(player->GetPositionY());                 // GROUP_UPDATE_FLAG_POSITION

    uint64 auramask = 0;
    size_t maskPos = data.wpos();
    data << uint64(auramask);                               // placeholder
    for(uint8 i = 0; i < MAX_AURAS; ++i)
    {
        if(uint32 aura = player->GetVisibleAura(i))
        {
            auramask |= (uint64(1) << i);
            data << uint32(aura);
            data << uint8(1);
        }
    }
    data.put<uint64>(maskPos, auramask);                    // GROUP_UPDATE_FLAG_AURAS

    if(pet)
    {
        Powers petpowertype = pet->getPowerType();
        data << pet->GetObjectGuid();                       // GROUP_UPDATE_FLAG_PET_GUID
        data << pet->GetName();                             // GROUP_UPDATE_FLAG_PET_NAME
        data << uint16(pet->GetDisplayId());                // GROUP_UPDATE_FLAG_PET_MODEL_ID
        data << uint32(pet->GetHealth());                   // GROUP_UPDATE_FLAG_PET_CUR_HP
        data << uint32(pet->GetMaxHealth());                // GROUP_UPDATE_FLAG_PET_MAX_HP
        data << uint8(petpowertype);                        // GROUP_UPDATE_FLAG_PET_POWER_TYPE
        data << uint16(pet->GetPower(petpowertype));        // GROUP_UPDATE_FLAG_PET_CUR_POWER
        data << uint16(pet->GetMaxPower(petpowertype));     // GROUP_UPDATE_FLAG_PET_MAX_POWER

        uint64 petauramask = 0;
        size_t petMaskPos = data.wpos();
        data << uint64(petauramask);                        // placeholder
        for(uint8 i = 0; i < MAX_AURAS; ++i)
        {
            if(uint32 petaura = pet->GetVisibleAura(i))
            {
                petauramask |= (uint64(1) << i);
                data << uint32(petaura);
                data << uint8(1);
            }
        }
        data.put<uint64>(petMaskPos, petauramask);          // GROUP_UPDATE_FLAG_PET_AURAS
        data << (uint32) player->m_movementInfo.GetTransportDBCSeat();
    }
    else
    {
        data << uint8(0);                                   // GROUP_UPDATE_FLAG_PET_NAME
        data << uint64(0);                                  // GROUP_UPDATE_FLAG_PET_AURAS
    }

    SendPacket(&data);
}
Beispiel #11
0
            void UpdateAI(const uint32 diff)
            {
                if(!UpdateVictim())
                    return;

                if(me->getVictim() && me->isAlive())
                {
                    if(PoisonVolley_Timer <= diff)
                    {
                        DoCast(me->getVictim(), SPELL_POISONVOLLEY);
                        PoisonVolley_Timer = 10000 + rand()%10000;
                    } else PoisonVolley_Timer -= diff;

                    if(!PhaseTwo && Aspect_Timer <= diff)
                    {
                        DoCast(me->getVictim(), SPELL_ASPECT_OF_MARLI);
                        Aspect_Timer = 13000 + rand()%5000;
                    } else Aspect_Timer -= diff;

                    if(!Spawned && SpawnStartSpiders_Timer <= diff)
                    {
                        DoScriptText(SAY_SPIDER_SPAWN, me);

                        Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
                        if(!target)
                            return;

                        Creature* Spider = NULL;

                        Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Spider)
                            Spider->AI()->AttackStart(target);
                        Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Spider)
                            Spider->AI()->AttackStart(target);
                        Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Spider)
                            Spider->AI()->AttackStart(target);
                        Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Spider)
                            Spider->AI()->AttackStart(target);

                        Spawned = true;
                    } else SpawnStartSpiders_Timer -= diff;

                    if(SpawnSpider_Timer <= diff)
                    {
                        Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
                        if(!target)
                            return;

                        Creature* Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Spider)
                            Spider->AI()->AttackStart(target);
                        SpawnSpider_Timer = 12000 + rand()%5000;
                    } else SpawnSpider_Timer -= diff;

                    if(!PhaseTwo && Transform_Timer <= diff)
                    {
                        DoScriptText(SAY_TRANSFORM, me);
                        DoCast(me, SPELL_SPIDER_FORM);
                        const CreatureTemplate *cinfo = me->GetCreatureInfo();
                        me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35)));
                        me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35)));
                        me->UpdateDamagePhysical(BASE_ATTACK);
                        DoCast(me->getVictim(), SPELL_ENVOLWINGWEB);

                        if(DoGetThreat(me->getVictim()))
                            DoModifyThreatPercent(me->getVictim(), -100);

                        PhaseTwo = true;
                        Transform_Timer = urand(35000, 60000);
                    } else Transform_Timer -= diff;

                    if(PhaseTwo)
                    {
                        if(Charge_Timer <= diff)
                        {
                            Unit* target = NULL;
                            int i = 0;
                            while(i < 3)                           // max 3 tries to get a random target with power_mana
                            {
                                ++i;
                                target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);  // not aggro leader
                                if(target && target->getPowerType() == POWER_MANA)
                                        i = 3;
                            }
                            if(target)
                            {
                                DoCast(target, SPELL_CHARGE);
                                //me->GetMap()->CreatureRelocation(me, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0);
                                //me->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true, 1);
                                AttackStart(target);
                            }

                            Charge_Timer = 8000;
                        } else Charge_Timer -= diff;

                        if(TransformBack_Timer <= diff)
                        {
                            me->SetDisplayId(15220);
                            const CreatureTemplate *cinfo = me->GetCreatureInfo();
                            me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 1)));
                            me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 1)));
                            me->UpdateDamagePhysical(BASE_ATTACK);

                            PhaseTwo = false;
                            TransformBack_Timer = urand(25000, 40000);
                        } else TransformBack_Timer -= diff;

                    }

                    DoMeleeAttackIfReady();
                }
            }
    void UpdateAI(const uint32 uiDiff)
    {
        //Return since we have no target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
        {
            //check if the event is started
            if (m_pInstance && m_pInstance->GetData(TYPE_KARATHRESS_EVENT) == IN_PROGRESS)
            {
                if (Unit* pTarget = Unit::GetUnit((*m_creature), m_pInstance->GetData64(DATA_KARATHRESS_STARTER)))
                {
                    AttackStart(pTarget);
                    GetAdvisors();
                }
            }
            return;
        }

        //someone evaded!
        if (m_pInstance && m_pInstance->GetData(TYPE_KARATHRESS_EVENT) == NOT_STARTED)
        {
            EnterEvadeMode();
            return;
        }

        //m_uiCataclysmicBolt_Timer
		//Spell musi byc rzucany na target z mana i nie na tanka, chyba ze w threat znajduje sie tylko 1 osoba wtedy na nia
		//Jesli ktos ma lepszy pomysl na rozwiazanie tego problemu zapraszam do zmiany tej kiszkowatej implementacji :S
        if (m_uiCataclysmicBolt_Timer < uiDiff)
        {
			Unit* pTarget;
			uint8 k = 1; //8bitow - max 25ppl

			std::list<HostileReference*>& m_threatlist = m_creature->getThreatManager().getThreatList();
			std::list<HostileReference*>::iterator i = m_threatlist.begin();
			
			for (i = m_threatlist.begin(); i!= m_threatlist.end();++i)
			{
				error_log("Debug:Fathom Lord Karrathes - petla Cataclysmic Bolt"); // Do usuniecia jesli wszytsko bedzie dzialalo poprawnie

				pTarget = SelectUnit(SELECT_TARGET_RANDOM, k);// zaczyna od 2 osoby w threat (k=1) - czyli nigdy nie bedzie to tank, chyba ze bedzie solo
				if (!pTarget) //proba solowania (niezaleznie czy ma mane czy nie zwraca aktualny target jako poprawny target)
				{
                pTarget = m_creature->getVictim();
					break;
				}

				if(pTarget && pTarget->getPowerType() == POWER_MANA)
					break;

				++k; //inkrementacja pozycji w threat
			}

            m_creature->CastSpell(pTarget, SPELL_CATACLYSMIC_BOLT, false);
            m_uiCataclysmicBolt_Timer = 10000;
        }else m_uiCataclysmicBolt_Timer -= uiDiff;

        //hp under 75%
        if (!m_bBlessingOfTides_MobsChecked && ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth())  <= 75))
        {
            for(uint8 i = 0; i < MAX_ADVISORS; ++i)
            {
                if (Unit* pAdvisor = Unit::GetUnit(*m_creature, m_auiAdvisorsGUID[i]))
                {
                    //stack max three times (one for each alive)
                    if (pAdvisor->isAlive())
                    {
                        m_creature->InterruptNonMeleeSpells(false);
                        m_creature->CastSpell(m_creature, SPELL_BLESSING_OF_THE_TIDES, true);
                    }
                }
            }

            //yell if we now have the aura
            if (m_creature->HasAura(SPELL_BLESSING_OF_THE_TIDES))
                DoScriptText(SAY_GAIN_BLESSING, m_creature);

            m_bBlessingOfTides_MobsChecked = true;
        }

        //m_uiEnrage_Timer
        if (m_uiEnrage_Timer < uiDiff)
        {
            DoCast(m_creature, SPELL_ENRAGE);
            m_uiEnrage_Timer = 90000;
        }else m_uiEnrage_Timer -= uiDiff;

        DoMeleeAttackIfReady();
    }
Beispiel #13
0
    void UpdateAI(const uint32 diff)
    {
        //Speach
        if (DoingSpeach)
        {
            if (SpeachTimer < diff)
            {
                switch (SpeachNum)
                {
                    case 0:
                        //16 seconds till next line
                        DoScriptText(SAY_LINE2, m_creature);
                        SpeachTimer = 16000;
                        ++SpeachNum;
                        break;
                    case 1:
                        //This one is actually 16 seconds but we only go to 10 seconds because he starts attacking after he says "I must fight this!"
                        DoScriptText(SAY_LINE3, m_creature);
                        SpeachTimer = 10000;
                        ++SpeachNum;
                        break;
                    case 2:
                        m_creature->setFaction(103);
                        m_creature->SetHealth(int(m_creature->GetMaxHealth()*.3));

                        if (PlayerGUID)
                        {
                            if (Player* pPlayer = m_creature->GetMap()->GetPlayer(PlayerGUID))
                                AttackStart(pPlayer);

                            DoCastSpellIfCan(m_creature, SPELL_ESSENCEOFTHERED);
                        }
                        SpeachTimer = 0;
                        DoingSpeach = false;
                        break;
                }
            }else SpeachTimer -= diff;
        }

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

        // Yell if hp lower than 15%
        if (m_creature->GetHealthPercent() < 15.0f && !HasYelled)
        {
            DoScriptText(SAY_HALFLIFE, m_creature);
            HasYelled = true;
        }

        //Cleave_Timer
        if (Cleave_Timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_CLEAVE);
            Cleave_Timer = 15000;
        }else Cleave_Timer -= diff;

        //FlameBreath_Timer
        if (FlameBreath_Timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_FLAMEBREATH);
            FlameBreath_Timer = urand(4000, 8000);
        }else FlameBreath_Timer -= diff;

        //BurningAdrenalineCaster_Timer
        if (BurningAdrenalineCaster_Timer < diff)
        {
            Unit* target = NULL;

            int i = 0 ;
            while (i < 3)                                   // max 3 tries to get a random target with power_mana
            {
                ++i;
                target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,1);//not aggro leader
                if (target)
                    if (target->getPowerType() == POWER_MANA)
                        i=3;
            }
            if (target)                                     // cast on self (see below)
                target->CastSpell(target, SPELL_BURNINGADRENALINE, true);

            BurningAdrenalineCaster_Timer = 15000;
        }else BurningAdrenalineCaster_Timer -= diff;

        //BurningAdrenalineTank_Timer
        if (BurningAdrenalineTank_Timer < diff)
        {
            // have the victim cast the spell on himself otherwise the third effect aura will be applied
            // to Vael instead of the player
            m_creature->getVictim()->CastSpell(m_creature->getVictim(), SPELL_BURNINGADRENALINE, true);

            BurningAdrenalineTank_Timer = 45000;
        }else BurningAdrenalineTank_Timer -= diff;

        //FireNova_Timer
        if (FireNova_Timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_FIRENOVA);
            FireNova_Timer = 5000;
        }else FireNova_Timer -= diff;

        //TailSwipe_Timer
        if (TailSwipe_Timer < diff)
        {
            //Only cast if we are behind
            /*if (!m_creature->HasInArc(M_PI, m_creature->getVictim()))
            {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_TAILSWIPE);
            }*/

            TailSwipe_Timer = 20000;
        }else TailSwipe_Timer -= diff;

        DoMeleeAttackIfReady();
    }
    void UpdateAI(const uint32 diff)
    {
        if (IsNihil)
        {
            if (NihilSpeech_Phase)
            {
                if (NihilSpeech_Timer <= diff)
                {
                    switch(NihilSpeech_Phase)
                    {
                        case 1:
                            DoScriptText(SAY_NIHIL_1, me);
                            ++NihilSpeech_Phase;
                            break;
                        case 2:
                            DoScriptText(SAY_NIHIL_2, me);
                            ++NihilSpeech_Phase;
                            break;
                        case 3:
                            DoScriptText(SAY_NIHIL_3, me);
                            ++NihilSpeech_Phase;
                            break;
                        case 4:
                            DoScriptText(SAY_NIHIL_4, me);
                            ++NihilSpeech_Phase;
                            break;
                        case 5:
                            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                                            // + MOVEFLAG_LEVITATING
                            me->AddUnitMovementFlag(MOVEFLAG_ONTRANSPORT);
                            //then take off to random location. creature is initially summoned, so don't bother do anything else.
                            me->GetMotionMaster()->MovePoint(0, me->GetPositionX()+100, me->GetPositionY(), me->GetPositionZ()+100);
                            NihilSpeech_Phase = 0;
                            break;
                    }
                    NihilSpeech_Timer = 5000;
                } else NihilSpeech_Timer -=diff;
            }
            return;                                         //anything below here is not interesting for Nihil, so skip it
        }

        if (!UpdateVictim())
            return;

        if (IntangiblePresence_Timer <= diff)
        {
            DoCast(me->getVictim(),SPELL_INTANGIBLE_PRESENCE);
            IntangiblePresence_Timer = 15000+rand()%15000;
        } else IntangiblePresence_Timer -= diff;

        if (ManaBurn_Timer <= diff)
        {
            Unit *pTarget = me->getVictim();
            if (pTarget && pTarget->getPowerType() == POWER_MANA)
                DoCast(pTarget,SPELL_MANA_BURN);
            ManaBurn_Timer = 8000+rand()%8000;
        } else ManaBurn_Timer -= diff;

        if (ArcaneBlast_Timer <= diff)
        {
            DoCast(me->getVictim(),SPELL_ARCANE_BLAST);
            ArcaneBlast_Timer = 2500+rand()%5000;
        } else ArcaneBlast_Timer -= diff;

        DoMeleeAttackIfReady();
    }
        void UpdateAI(uint32 diff)
        {
            events.Update(diff);

            // Speech
            if (!UpdateVictim())
            {
                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_SPEECH_1:
                            Talk(SAY_LINE1);
                            me->SetStandState(UNIT_STAND_STATE_STAND);
                            me->HandleEmoteCommand(EMOTE_ONESHOT_TALK);
                            events.ScheduleEvent(EVENT_SPEECH_2, 12000);
                            break;
                        case EVENT_SPEECH_2:
                            Talk(SAY_LINE2);
                            me->HandleEmoteCommand(EMOTE_ONESHOT_TALK);
                            events.ScheduleEvent(EVENT_SPEECH_3, 12000);
                            break;
                        case EVENT_SPEECH_3:
                            Talk(SAY_LINE3);
                            me->HandleEmoteCommand(EMOTE_ONESHOT_TALK);
                            events.ScheduleEvent(EVENT_SPEECH_4, 16000);
                            break;
                        case EVENT_SPEECH_4:
                            me->setFaction(103);
                            if (PlayerGUID && ObjectAccessor::GetUnit(*me, PlayerGUID))
                                AttackStart(ObjectAccessor::GetUnit(*me, PlayerGUID));;
                            break;
                    }
                }
                return;
            }

            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                    case EVENT_CLEAVE:
                        events.ScheduleEvent(EVENT_CLEAVE, 15000);
                        DoCastVictim(SPELL_CLEAVE);
                        break;
                    case EVENT_FLAMEBREATH:
                        DoCastVictim(SPELL_FLAMEBREATH);
                        events.ScheduleEvent(EVENT_FLAMEBREATH, urand(8000, 14000));
                        break;
                    case EVENT_FIRENOVA:
                        DoCastVictim(SPELL_FIRENOVA);
                        events.ScheduleEvent(EVENT_FIRENOVA, 15000);
                        break;
                    case EVENT_TAILSWIPE:
                        //Only cast if we are behind
                        /*if (!me->HasInArc(M_PI, me->GetVictim()))
                        {
                        DoCast(me->GetVictim(), SPELL_TAILSWIPE);
                        }*/
                        events.ScheduleEvent(EVENT_TAILSWIPE, 15000);
                        break;
                    case EVENT_BURNINGADRENALINE_CASTER:
                        {
                            Unit* target = NULL;

                            uint8 i = 0;
                            while (i < 3)   // max 3 tries to get a random target with power_mana
                            {
                                ++i;
                                target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); // not aggro leader
                                if (target && target->getPowerType() == POWER_MANA)
                                    i = 3;
                            }
                            if (target)                                     // cast on self (see below)
                                target->CastSpell(target, SPELL_BURNINGADRENALINE, true);
                        }
                        events.ScheduleEvent(EVENT_BURNINGADRENALINE_CASTER, 15000);
                        break;
                    case EVENT_BURNINGADRENALINE_TANK:
                        // have the victim cast the spell on himself otherwise the third effect aura will be applied to Vael instead of the player
                        me->GetVictim()->CastSpell(me->GetVictim(), SPELL_BURNINGADRENALINE, true);
                        events.ScheduleEvent(EVENT_BURNINGADRENALINE_TANK, 45000);
                        break;
                }
            }

            // Yell if hp lower than 15%
            if (HealthBelowPct(15) && !HasYelled)
            {
                Talk(SAY_HALFLIFE);
                HasYelled = true;
            }

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

        // Supreme mode - Causes Kazzak to cast his Shadowbolt every second.
        if (m_uiSupremeTimer < uiDiff && !m_bSupremeMode)
            m_bSupremeMode = true;
        else if (!m_bSupremeMode)
            m_uiSupremeTimer -= uiDiff;

        // Shadowbolt Volley
        if (m_uiShadowVolleyTimer < uiDiff)
        {
            DoCastSpellIfCan(m_creature->getVictim(), SPELL_SHADOW_VOLLEY);
            if (m_bSupremeMode)
                m_uiShadowVolleyTimer = 1000;
            else
                m_uiShadowVolleyTimer = urand(4000,20000);
        }
        else
            m_uiShadowVolleyTimer -= uiDiff;

        // Cleave
        if (m_uiCleaveTimer < uiDiff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_CLEAVE);
            m_uiCleaveTimer = urand(8000,12000);
        }
        else
            m_uiCleaveTimer -= uiDiff;

        // Thunder Clap
        if (m_uiThunderClapTimer < uiDiff)
        {
            DoCastSpellIfCan(m_creature->getVictim(), SPELL_THUNDERCLAP);
            m_uiThunderClapTimer = urand(10000,14000);
        }
        else
            m_uiThunderClapTimer -= uiDiff;

        // Void Bolt
        if (m_uiVoidBoltTimer < uiDiff)
        {
            DoCastSpellIfCan(m_creature->getVictim(), SPELL_VOIDBOLT);
            m_uiVoidBoltTimer = urand(15000,28000);
        }
        else
            m_uiVoidBoltTimer -= uiDiff;

        // Mark of Kazzak
        if (m_uiMarkOfKazzakTimer < uiDiff)
        {
            Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);
            if (pTarget && pTarget->getPowerType() == POWER_MANA && pTarget->GetPower(POWER_MANA) > 1000)
            {
                DoCastSpellIfCan(pTarget, SPELL_MARK_OF_KAZZAK);
                m_uiMarkOfKazzakTimer = 20000;
            }
        }
        else
            m_uiMarkOfKazzakTimer -= uiDiff;

        // Mark of Kazzak - Explode the target when does not have more mana
        ThreatList const& tMarkList = m_creature->getThreatManager().getThreatList();
        for (ThreatList::const_iterator iter = tMarkList.begin(); iter != tMarkList.end(); ++iter)
        {
            Unit* pMarked = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid());
            if (pMarked && pMarked->HasAura(SPELL_MARK_OF_KAZZAK, EFFECT_INDEX_0) && pMarked->GetPower(POWER_MANA) < 250)
            {
                pMarked->RemoveAurasDueToSpell(SPELL_MARK_OF_KAZZAK);
                pMarked->CastSpell(pMarked, SPELL_MARK_OF_KAZZAK_EXP, false);
                break;
            }
        }

        // Twisted Reflection
        if (m_uiTwistedReflectionTimer < uiDiff)
        {
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                DoCastSpellIfCan(pTarget, SPELL_TWISTEDREFLECTION);

            m_uiTwistedReflectionTimer = 15000;
        }
        else
            m_uiTwistedReflectionTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }
Beispiel #17
0
            void UpdateAI(uint32 const diff)
            {
                if (!UpdateVictim())
                    return;

                events.Update(diff);

                if (me->HasUnitState(UNIT_STATE_CASTING))
                    return;

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_SPAWN_START_SPIDERS:

                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            {
                                Talk(SAY_SPIDER_SPAWN);
                                Creature* Spider = NULL;
                                Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Spider)
                                    Spider->AI()->AttackStart(target);
                                Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Spider)
                                    Spider->AI()->AttackStart(target);
                                Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Spider)
                                    Spider->AI()->AttackStart(target);
                                Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Spider)
                                    Spider->AI()->AttackStart(target);
                            }
                            events.ScheduleEvent(EVENT_ASPECT_OF_MARLI, 12000, 0, PHASE_TWO);
                            events.ScheduleEvent(EVENT_TRANSFORM, 45000, 0, PHASE_TWO);
                            events.ScheduleEvent(EVENT_POISON_VOLLEY, 15000);
                            events.ScheduleEvent(EVENT_SPAWN_SPIDER, 30000);
                            events.ScheduleEvent(EVENT_TRANSFORM, 45000, 0, PHASE_TWO);
                            events.SetPhase(PHASE_TWO);
                            break;
                        case EVENT_POISON_VOLLEY:
                            DoCastVictim(SPELL_POISON_VOLLEY, true);
                            events.ScheduleEvent(EVENT_POISON_VOLLEY, urand(10000, 20000));
                            break;
                        case EVENT_ASPECT_OF_MARLI:
                            DoCastVictim(SPELL_ASPECT_OF_MARLI, true);
                            events.ScheduleEvent(EVENT_ASPECT_OF_MARLI, urand(13000, 18000), 0, PHASE_TWO);
                            break;
                        case EVENT_SPAWN_SPIDER:
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            {
                                Creature* Spider = me->SummonCreature(15041, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                                if (Spider)
                                    Spider->AI()->AttackStart(target);
                            }
                            events.ScheduleEvent(EVENT_SPAWN_SPIDER, urand(12000, 17000));
                            break;
                        case EVENT_TRANSFORM:
                            {
                                Talk(SAY_TRANSFORM);
                                DoCast(me, SPELL_SPIDER_FORM);
                                const CreatureTemplate* cinfo = me->GetCreatureTemplate();
                                me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35)));
                                me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35)));
                                me->UpdateDamagePhysical(BASE_ATTACK);
                                DoCast(me->getVictim(), SPELL_ENVOLWINGWEB);
                                if (DoGetThreat(me->getVictim()))
                                    DoModifyThreatPercent(me->getVictim(), -100);
                                events.ScheduleEvent(EVENT_CHARGE_PLAYER, 1500, 0, PHASE_THREE);
                                events.ScheduleEvent(EVENT_TRANSFORM_BACK, 25000, 0, PHASE_THREE);
                                events.SetPhase(PHASE_THREE);
                                break;
                            }
                        case EVENT_CHARGE_PLAYER:
                            {
                                Unit* target = NULL;
                                int i = 0;
                                while (i < 3) // max 3 tries to get a random target with power_mana
                                {
                                    ++i;
                                    Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);  // not aggro leader
                                    if (target && target->getPowerType() == POWER_MANA)
                                        i = 3;
                                }
                                if (target)
                                {
                                    DoCast(target, SPELL_CHARGE);
                                    //me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0);
                                    //me->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true, 1);
                                    AttackStart(target);
                                }
                                events.ScheduleEvent(EVENT_CHARGE_PLAYER, 8000, 0, PHASE_THREE);
                                break;
                            }
                        case EVENT_TRANSFORM_BACK:
                            {
                                me->SetDisplayId(MODEL_MARLI);
                                const CreatureTemplate* cinfo = me->GetCreatureTemplate();
                                me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 1)));
                                me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 1)));
                                me->UpdateDamagePhysical(BASE_ATTACK);
                                events.ScheduleEvent(EVENT_ASPECT_OF_MARLI, 12000, 0, PHASE_TWO);
                                events.ScheduleEvent(EVENT_TRANSFORM, 45000, 0, PHASE_TWO);
                                events.ScheduleEvent(EVENT_POISON_VOLLEY, 15000);
                                events.ScheduleEvent(EVENT_SPAWN_SPIDER, 30000);
                                events.ScheduleEvent(EVENT_TRANSFORM, urand(35000, 60000), 0, PHASE_TWO);
                                events.SetPhase(PHASE_TWO);
                                break;
                            }
                        default:
                            break;
                    }
                }

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

        if (!m_pInstance || m_pInstance->GetData(TYPE_KELTHUZAD) != IN_PROGRESS)
            return;

        if (m_uiPhase == PHASE_INTRO)
        {
            if (m_uiIntroPackCount < 7)
            {
                if (m_uiSummonIntroTimer < uiDiff)
                {
                    if (!m_uiIntroPackCount)
                        DoScriptText(SAY_SUMMON_MINIONS, m_creature);

                    SummonIntroCreatures(m_uiIntroPackCount);
                    ++m_uiIntroPackCount;
                    m_uiSummonIntroTimer = 2000;
                }
                else
                    m_uiSummonIntroTimer -= uiDiff;
            }
            else
            {
                if (m_uiPhase1Timer < uiDiff)
                {
                    m_uiPhase = PHASE_NORMAL;
                    DespawnIntroCreatures();

                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    SetCombatMovement(true);
                    m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());

                    DoScriptText(EMOTE_PHASE2, m_creature);

                    switch(urand(0, 2))
                    {
                        case 0: DoScriptText(SAY_AGGRO1, m_creature); break;
                        case 1: DoScriptText(SAY_AGGRO2, m_creature); break;
                        case 2: DoScriptText(SAY_AGGRO3, m_creature); break;
                    };
                }
                else
                    m_uiPhase1Timer -= uiDiff;

                if (m_uiSoldierCount < MAX_SOLDIER_COUNT)
                {
                    if (m_uiSoldierTimer < uiDiff)
                    {
                        SummonMob(NPC_SOLDIER_FROZEN);
                        ++m_uiSoldierCount;
                        m_uiSoldierTimer = 3000;
                    }
                    else
                        m_uiSoldierTimer -= uiDiff;
                }

                if (m_uiAbominationCount < MAX_ABOMINATION_COUNT)
                {
                    if (m_uiAbominationTimer < uiDiff)
                    {
                        SummonMob(NPC_UNSTOPPABLE_ABOM);
                        ++m_uiAbominationCount;
                        m_uiAbominationTimer = 25000;
                    }
                    else
                        m_uiAbominationTimer -= uiDiff;
                }

                if (m_uiBansheeCount < MAX_BANSHEE_COUNT)
                {
                    if (m_uiBansheeTimer < uiDiff)
                    {
                        SummonMob(NPC_SOUL_WEAVER);
                        ++m_uiBansheeCount;
                        m_uiBansheeTimer = 25000;
                    }
                    else
                        m_uiBansheeTimer -= uiDiff;
                }
            }
        }
        else // normal or guardian phase
        {
            if (m_uiFrostBoltTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), m_bIsRegularMode ? SPELL_FROST_BOLT : SPELL_FROST_BOLT_H) == CAST_OK)
                    m_uiFrostBoltTimer = urand(1000, 60000);
            }
            else
                m_uiFrostBoltTimer -= uiDiff;

            if (m_uiFrostBoltNovaTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), m_bIsRegularMode ? SPELL_FROST_BOLT_NOVA : SPELL_FROST_BOLT_NOVA_H) == CAST_OK)
                    m_uiFrostBoltNovaTimer = 15000;
            }
            else
                m_uiFrostBoltNovaTimer -= uiDiff;
               
            if (m_uiManaDetonationTimer < uiDiff)
            {
                Unit* pTarget;
                uint8 counter = 0;
                do
                {
                    counter++;
                    if (counter >= 25)
                    {
                        break;
                        pTarget = NULL;
                    }
                    else
                        pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);
                }
                while(pTarget->getPowerType() != POWER_MANA);

                if (pTarget)
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_MANA_DETONATION) == CAST_OK)
                    {
                        if (urand(0, 1))
                            DoScriptText(SAY_SPECIAL1_MANA_DET, m_creature);

                        m_uiManaDetonationTargetGUID = pTarget->GetGUID();
                        m_uiManaDetonationMana = m_bIsRegularMode ? urand(2500,4000) : urand(3500,5500);
                        uint32 newMana = pTarget->GetPower(POWER_MANA) - m_uiManaDetonationMana; 
                        uint32 mana = newMana < 0 ? 0 : newMana;
                        m_uiManaDetonationMana *= 1+(urand(2,m_bIsRegularMode?5:9)/10.f); // random increase damage output, not blizzlike
                        pTarget->SetPower(POWER_MANA, mana);
                        
                        m_uiManaDetonationTimer = 20000;
                        m_uiManaDetonationEndTimer = 5000;
                        m_bManaDetonationActive = true;
                    }
                }
            }
            else
                m_uiManaDetonationTimer -= uiDiff;

            if (m_bManaDetonationActive)
                if (m_uiManaDetonationEndTimer < uiDiff)
                {
                    if (Player* pTarget = m_creature->GetMap()->GetPlayer(m_uiManaDetonationTargetGUID))
                    {
                        Map *map = m_creature->GetMap();
                        Map::PlayerList const &PlayerList = map->GetPlayers();
                        if (!PlayerList.isEmpty())
                            for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
                            {
                                if(i->getSource()->isDead() || i->getSource() == pTarget || i->getSource()->isGameMaster()) // no dmg on dead, self and GMs
                                    continue;
                                if (pTarget->GetDistance2d(i->getSource()) < 15.f)
                                    i->getSource()->DealDamage(i->getSource(), m_uiManaDetonationMana, NULL, SPELL_DIRECT_DAMAGE, SPELL_SCHOOL_MASK_ARCANE, NULL, true);
                            }
                    }
                    m_bManaDetonationActive = false;
                }
                else
                    m_uiManaDetonationEndTimer -= uiDiff;

            
            if (m_uiShadowFissureTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                    if(DoCastSpellIfCan(pTarget, SPELL_SHADOW_FISSURE) == CAST_OK)
                    {
                        m_fFissureX = pTarget->GetPositionX();
                        m_fFissureY = pTarget->GetPositionY();

                        if (urand(0, 1))
                            DoScriptText(SAY_SPECIAL3_MANA_DET, m_creature);

                        m_uiShadowFissureTimer = 25000;
                        m_uiShadowFissureActiveTimer = 5000;
                        m_bShadowFissureActive = true;
                    }
            }
            else
                m_uiShadowFissureTimer -= uiDiff;

            if(m_bShadowFissureActive)
                if(m_uiShadowFissureActiveTimer < uiDiff)
                {   
                    // hack for shadow fissure damage, shadow fissure spell does not give damage to players
                    Map::PlayerList const& pPlayers = m_creature->GetMap()->GetPlayers();
                    if (!pPlayers.isEmpty())
                        for (Map::PlayerList::const_iterator itr = pPlayers.begin(); itr != pPlayers.end(); ++itr)
                            if(itr->getSource() && !itr->getSource()->isGameMaster() && (itr->getSource()->GetDistance2d(m_fFissureX,m_fFissureY) < 4.0f))
                                m_creature->DealDamage(itr->getSource(),itr->getSource()->GetHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                    m_bShadowFissureActive = false;
                }
                else 
                    m_uiShadowFissureActiveTimer -= uiDiff;

            if (m_uiFrostBlastTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0), SPELL_FROST_BLAST) == CAST_OK)
                {
                    if (urand(0, 1))
                        DoScriptText(SAY_FROST_BLAST, m_creature);

                    m_uiFrostBlastTimer = urand(30000, 60000);
                }
            }
            else
                m_uiFrostBlastTimer -= uiDiff;
                
            if (!m_bIsRegularMode)
            {
                if (m_uiChainsTimer < uiDiff)
                {
                    m_lChainsTargets.clear();
                    if (SpellEntry* TempSpell = (SpellEntry*)GetSpellStore()->LookupEntry(SPELL_CHAINS_OF_KELTHUZAD_TARGET))
                    {
                        TempSpell->EffectApplyAuraName[0]=SPELL_AURA_MOD_CHARM;
                        uint8 uiChainsTargetsCount = 0;
                        for (uint8 i=0; i<25; ++i)
                        {
                            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                            {
                                if (pTarget->GetTypeId() == TYPEID_PLAYER && !pTarget->HasAura(SPELL_CHAINS_OF_KELTHUZAD_TARGET, EFFECT_INDEX_0))
                                {
                                    m_creature->InterruptNonMeleeSpells(false);
                                    m_creature->CastCustomSpell(pTarget, TempSpell, NULL, NULL, NULL, true);
                                    ((Player*)pTarget)->SetClientControl(pTarget, 0);
                                    m_lChainsTargets.insert(pTarget->GetGUID());
                                    pTarget->setFaction(14);
                                    ++uiChainsTargetsCount;
                                }
                                if (uiChainsTargetsCount>=3)
                                    break;
                            }
                        }
                        m_uiChainsEndTimer = 20000;
                        m_uiChainsTargetsCastTimer = 3500;
                        DoResetThreat();
                    }
                
                    //DoCastSpellIfCan(pTarget, SPELL_CHAINS_OF_KELTHUZAD);
                    DoScriptText(urand(0, 1) ? SAY_CHAIN1 : SAY_CHAIN2, m_creature);
                    m_uiChainsTimer = urand(60000, 90000);
                }
                else
                    m_uiChainsTimer -= uiDiff;

                if (!m_lChainsTargets.empty())
                {
                    if (m_uiChainsTargetsCastTimer < uiDiff)
                    {
                        for (std::set<uint64>::iterator itr = m_lChainsTargets.begin(); itr != m_lChainsTargets.end(); ++itr)
                            if (Unit* pUnit = m_creature->GetMap()->GetUnit(*itr))
                            {
                                if (pUnit->isDead())
                                    continue;
                            
                                if (pUnit->getClass() == CLASS_PRIEST || pUnit->getClass() == CLASS_SHAMAN ||  pUnit->getClass() == CLASS_MAGE ||
                                    pUnit->getClass() == CLASS_WARLOCK) // healer classes heal kelthuzad
                                {
                                    int32 amount = urand(11000,19000);
                                    pUnit->CastCustomSpell(m_creature, 36983, &amount, NULL, NULL, false);
                                }
                                else // other classes melee players
                                    if (Unit* pVictim = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                                    {
                                        pUnit->GetMotionMaster()->MoveChase(pVictim);
                                        pUnit->Attack(pVictim,true);
                                    }
                            }
                        m_uiChainsTargetsCastTimer = 4500;
                    }
                    else
                        m_uiChainsTargetsCastTimer -= uiDiff;

                    if (m_uiChainsEndTimer < uiDiff)
                    {
                        for(std::set<uint64>::iterator itr = m_lChainsTargets.begin(); itr != m_lChainsTargets.end(); ++itr)
                            if (Player* pPlayer = m_creature->GetMap()->GetPlayer(*itr))
                            {
                                pPlayer->setFactionForRace(pPlayer->getRace());
                                pPlayer->SetClientControl(pPlayer, 1);
                            }
                        m_lChainsTargets.clear();
                    }
                    else
                        m_uiChainsEndTimer -= uiDiff;
                }
            }

            if (m_uiPhase == PHASE_NORMAL)
            {
                if (m_creature->GetHealthPercent() < 45.0f)
                {
                    m_uiPhase = PHASE_GUARDIANS;
                    DoScriptText(SAY_REQUEST_AID, m_creature);

                    // here Lich King should respond to Kel'Thuzad but I don't know which creature to make talk
                    // so for now just make Kel'Thuzad says it.
                    DoScriptText(SAY_ANSWER_REQUEST, m_creature);
                }
            }
            else if (m_uiPhase == PHASE_GUARDIANS && m_uiGuardiansCount < m_uiGuardiansCountMax)
            {
                if (m_uiGuardiansTimer < uiDiff)
                {
                    // Summon a Guardian of Icecrown in a random alcove
                    SummonMob(NPC_GUARDIAN);
                    m_uiGuardiansTimer = 5000;
                }
                else
                    m_uiGuardiansTimer -= uiDiff;
            }

            DoMeleeAttackIfReady();
        }
    }
Beispiel #19
0
            void UpdateAI(uint32 diff) override
            {
                if (!UpdateVictim())
                    return;

                events.Update(diff);

                if (me->HasUnitState(UNIT_STATE_CASTING))
                    return;

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_SPAWN_START_SPIDERS:
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            {
                                Talk(SAY_SPIDER_SPAWN);
                                for (uint8 i = 0; i < 4; ++i)
                                    if (Creature* spider = me->SummonCreature(NPC_SPIDER, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000))
                                        spider->AI()->AttackStart(target);
                            }
                            events.ScheduleEvent(EVENT_ASPECT_OF_MARLI, 12000, 0, PHASE_TWO);
                            events.ScheduleEvent(EVENT_TRANSFORM, 45000, 0, PHASE_TWO);
                            events.ScheduleEvent(EVENT_POISON_VOLLEY, 15000);
                            events.ScheduleEvent(EVENT_SPAWN_SPIDER, 30000);
                            events.ScheduleEvent(EVENT_TRANSFORM, 45000, 0, PHASE_TWO);
                            events.SetPhase(PHASE_TWO);
                            break;
                        case EVENT_POISON_VOLLEY:
                            DoCastVictim(SPELL_POISON_VOLLEY, true);
                            events.ScheduleEvent(EVENT_POISON_VOLLEY, urand(10000, 20000));
                            break;
                        case EVENT_ASPECT_OF_MARLI:
                            DoCastVictim(SPELL_ASPECT_OF_MARLI, true);
                            events.ScheduleEvent(EVENT_ASPECT_OF_MARLI, urand(13000, 18000), 0, PHASE_TWO);
                            break;
                        case EVENT_SPAWN_SPIDER:
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                                if (Creature* spider = me->SummonCreature(NPC_SPIDER, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000))
                                    spider->AI()->AttackStart(target);
                            events.ScheduleEvent(EVENT_SPAWN_SPIDER, urand(12000, 17000));
                            break;
                        case EVENT_TRANSFORM:
                        {
                            Talk(SAY_TRANSFORM);
                            DoCast(me, SPELL_SPIDER_FORM); // SPELL_AURA_TRANSFORM
                            /*
                            CreatureTemplate const* cinfo = me->GetCreatureTemplate();
                            me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35)));
                            me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35)));
                            me->UpdateDamagePhysical(BASE_ATTACK);
                            */
                            me->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, 35.0f, true); // hack
                            DoCastVictim(SPELL_ENVOLWINGWEB);
                            if (DoGetThreat(me->GetVictim()))
                                DoModifyThreatPercent(me->GetVictim(), -100);
                            events.ScheduleEvent(EVENT_CHARGE_PLAYER, 1500, 0, PHASE_THREE);
                            events.ScheduleEvent(EVENT_TRANSFORM_BACK, 25000, 0, PHASE_THREE);
                            events.SetPhase(PHASE_THREE);
                            break;
                        }
                        case EVENT_CHARGE_PLAYER:
                        {
                            Unit* target = NULL;
                            int i = 0;
                            while (i++ < 3) // max 3 tries to get a random target with power_mana
                            {
                                target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);  // not aggro leader
                                if (target && target->getPowerType() == POWER_MANA)
                                    break;
                            }
                            if (target)
                            {
                                DoCast(target, SPELL_CHARGE);
                                AttackStart(target);
                            }
                            events.ScheduleEvent(EVENT_CHARGE_PLAYER, 8000, 0, PHASE_THREE);
                            break;
                        }
                        case EVENT_TRANSFORM_BACK:
                        {
                            me->RemoveAura(SPELL_SPIDER_FORM);
                            /*
                            CreatureTemplate const* cinfo = me->GetCreatureTemplate();
                            me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 1)));
                            me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 1)));
                            me->UpdateDamagePhysical(BASE_ATTACK);
                            */
                            me->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, 35.0f, false); // hack
                            events.ScheduleEvent(EVENT_ASPECT_OF_MARLI, 12000, 0, PHASE_TWO);
                            events.ScheduleEvent(EVENT_TRANSFORM, 45000, 0, PHASE_TWO);
                            events.ScheduleEvent(EVENT_POISON_VOLLEY, 15000);
                            events.ScheduleEvent(EVENT_SPAWN_SPIDER, 30000);
                            events.ScheduleEvent(EVENT_TRANSFORM, urand(35000, 60000), 0, PHASE_TWO);
                            events.SetPhase(PHASE_TWO);
                            break;
                        }
                        default:
                            break;
                    }
                }

                DoMeleeAttackIfReady();
            }
Beispiel #20
0
void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacket *data)
{
    uint32 mask = player->GetGroupUpdateFlag();

    if (mask & GROUP_UPDATE_FLAG_POWER_TYPE)                // if update power type, update current/max power also
        mask |= (GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER);

    if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE)            // same for pets
        mask |= (GROUP_UPDATE_FLAG_PET_CUR_POWER | GROUP_UPDATE_FLAG_PET_MAX_POWER);

    uint32 byteCount = 0;
    for (int i = 1; i < GROUP_UPDATE_FLAGS_COUNT; ++i)
        if (mask & (1 << i))
            byteCount += GroupUpdateLength[i];

    data->Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount);
    *data << player->GetPackGUID();
    *data << uint32(mask);

    if (mask & GROUP_UPDATE_FLAG_STATUS)
    {
        if (player)
        {
            if (player->IsPvP())
                *data << uint16(MEMBER_STATUS_ONLINE | MEMBER_STATUS_PVP);
            else
                *data << uint16(MEMBER_STATUS_ONLINE);
        }
        else
            *data << uint16(MEMBER_STATUS_OFFLINE);
    }

    if (mask & GROUP_UPDATE_FLAG_CUR_HP)
        *data << uint32(player->GetHealth());

    if (mask & GROUP_UPDATE_FLAG_MAX_HP)
        *data << uint32(player->GetMaxHealth());

    Powers powerType = player->getPowerType();
    if (mask & GROUP_UPDATE_FLAG_POWER_TYPE)
        *data << uint8(powerType);

    if (mask & GROUP_UPDATE_FLAG_CUR_POWER)
        *data << uint16(player->GetPower(powerType));

    if (mask & GROUP_UPDATE_FLAG_MAX_POWER)
        *data << uint16(player->GetMaxPower(powerType));

    if (mask & GROUP_UPDATE_FLAG_LEVEL)
        *data << uint16(player->getLevel());

    if (mask & GROUP_UPDATE_FLAG_ZONE)
        *data << uint16(player->GetZoneId());

    if (mask & GROUP_UPDATE_FLAG_POSITION)
        *data << uint16(player->GetPositionX()) << uint16(player->GetPositionY());

    if (mask & GROUP_UPDATE_FLAG_AURAS)
    {
        const uint64& auramask = player->GetAuraUpdateMask();
        *data << uint64(auramask);
        for(uint32 i = 0; i < MAX_AURAS; ++i)
        {
            if(auramask & (uint64(1) << i))
            {
                *data << uint32(player->GetVisibleAura(i));
                *data << uint8(1);
            }
        }
    }

    Unit *pet = player->GetCharmOrPet();
    if (mask & GROUP_UPDATE_FLAG_PET_GUID)
        *data << (pet ? pet->GetObjectGuid() : ObjectGuid());

    if (mask & GROUP_UPDATE_FLAG_PET_NAME)
    {
        if(pet)
            *data << pet->GetName();
        else
            *data << uint8(0);
    }

    if (mask & GROUP_UPDATE_FLAG_PET_MODEL_ID)
    {
        if(pet)
            *data << uint16(pet->GetDisplayId());
        else
            *data << uint16(0);
    }

    if (mask & GROUP_UPDATE_FLAG_PET_CUR_HP)
    {
        if(pet)
            *data << uint32(pet->GetHealth());
        else
            *data << uint32(0);
    }

    if (mask & GROUP_UPDATE_FLAG_PET_MAX_HP)
    {
        if(pet)
            *data << uint32(pet->GetMaxHealth());
        else
            *data << uint32(0);
    }

    if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE)
    {
        if(pet)
            *data << uint8(pet->getPowerType());
        else
            *data << uint8(0);
    }

    if (mask & GROUP_UPDATE_FLAG_PET_CUR_POWER)
    {
        if(pet)
            *data << uint16(pet->GetPower(pet->getPowerType()));
        else
            *data << uint16(0);
    }

    if (mask & GROUP_UPDATE_FLAG_PET_MAX_POWER)
    {
        if(pet)
            *data << uint16(pet->GetMaxPower(pet->getPowerType()));
        else
            *data << uint16(0);
    }

    if (mask & GROUP_UPDATE_FLAG_PET_AURAS)
    {
        if(pet)
        {
            const uint64& auramask = pet->GetAuraUpdateMask();
            *data << uint64(auramask);
            for(uint32 i = 0; i < MAX_AURAS; ++i)
            {
                if(auramask & (uint64(1) << i))
                {
                    *data << uint32(pet->GetVisibleAura(i));
                    *data << uint8(1);
                }
            }
        }
        else
            *data << uint64(0);
    }

    if (mask & GROUP_UPDATE_FLAG_VEHICLE_SEAT)
    {
        *data << (uint32) player->m_movementInfo.GetTransportDBCSeat();
    }
}
Beispiel #21
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (m_uiIntroTimer)
        {
            if (m_uiIntroTimer <= uiDiff)
            {
                switch (m_uiIntroPhase)
                {
                    case 0:
                        m_creature->SummonCreature(NPC_LORD_NEFARIAN, aNefariusSpawnLoc[0], aNefariusSpawnLoc[1], aNefariusSpawnLoc[2], aNefariusSpawnLoc[3], TEMPSUMMON_TIMED_DESPAWN, 25000);
                        m_uiIntroTimer = 1000;
                        break;
                    case 1:
                        if (Creature* pNefarius = m_creature->GetMap()->GetCreature(m_nefariusGuid))
                        {
                            pNefarius->CastSpell(m_creature, SPELL_NEFARIUS_CORRUPTION, true);
                            DoScriptText(SAY_NEFARIUS_CORRUPT_1, pNefarius);
                        }
                        m_uiIntroTimer = 16000;
                        break;
                    case 2:
                        if (Creature* pNefarius = m_creature->GetMap()->GetCreature(m_nefariusGuid))
                            DoScriptText(SAY_NEFARIUS_CORRUPT_2, pNefarius);

                        // Set npc flags now
                        m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                        m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
                        m_uiIntroTimer = 0;
                        break;
                }
                ++m_uiIntroPhase;
            }
            else
                m_uiIntroTimer -= uiDiff;
        }

        // Speech
        if (m_uiSpeechTimer)
        {
            if (m_uiSpeechTimer <= uiDiff)
            {
                switch (m_uiSpeechNum)
                {
                    case 0:
                        // 16 seconds till next line
                        DoScriptText(SAY_LINE_2, m_creature);
                        m_uiSpeechTimer = 16000;
                        ++m_uiSpeechNum;
                        break;
                    case 1:
                        // This one is actually 16 seconds but we only go to 10 seconds because he starts attacking after he says "I must fight this!"
                        DoScriptText(SAY_LINE_3, m_creature);
                        m_uiSpeechTimer = 10000;
                        ++m_uiSpeechNum;
                        break;
                    case 2:
                        m_creature->setFaction(FACTION_HOSTILE);

                        if (m_playerGuid)
                        {
                            if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_playerGuid))
                                AttackStart(pPlayer);
                        }
                        m_uiSpeechTimer = 0;
                        break;
                }
            }
            else
                m_uiSpeechTimer -= uiDiff;
        }

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

        // Yell if hp lower than 15%
        if (m_creature->GetHealthPercent() < 15.0f && !m_bHasYelled)
        {
            DoScriptText(SAY_HALFLIFE, m_creature);
            m_bHasYelled = true;
        }

        // Cleave Timer
        if (m_uiCleaveTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_CLEAVE) == CAST_OK)
                m_uiCleaveTimer = 15000;
        }
        else
            m_uiCleaveTimer -= uiDiff;

        // Flame Breath Timer
        if (m_uiFlameBreathTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_FLAME_BREATH) == CAST_OK)
                m_uiFlameBreathTimer = urand(4000, 8000);
        }
        else
            m_uiFlameBreathTimer -= uiDiff;

        // Burning Adrenaline Caster Timer
        if (m_uiBurningAdrenalineCasterTimer < uiDiff)
        {
            std::vector<Unit*> vManaPlayers;

            // Scan for mana targets in threat list
            ThreatList const& tList = m_creature->getThreatManager().getThreatList();
            vManaPlayers.reserve(tList.size());
            for (ThreatList::const_iterator iter = tList.begin();iter != tList.end(); ++iter)
            {
                Unit* pTempTarget = m_creature->GetMap()->GetUnit((*iter)->getUnitGuid());

                if (pTempTarget && pTempTarget->getPowerType() == POWER_MANA && pTempTarget->GetTypeId() == TYPEID_PLAYER)
                    vManaPlayers.push_back(pTempTarget);
            }

            if (vManaPlayers.empty())
                return;

            Unit* pTarget = vManaPlayers[urand(0, vManaPlayers.size() - 1)];
            pTarget->CastSpell(pTarget, SPELL_BURNING_ADRENALINE, true, NULL, NULL, m_creature->GetObjectGuid());

            m_uiBurningAdrenalineCasterTimer = 15000;
        }
        else
            m_uiBurningAdrenalineCasterTimer -= uiDiff;

        // Burning Adrenaline Tank Timer
        if (m_uiBurningAdrenalineTankTimer < uiDiff)
        {
            // have the victim cast the spell on himself otherwise the third effect aura will be applied
            // to Vael instead of the player
            m_creature->getVictim()->CastSpell(m_creature->getVictim(), SPELL_BURNING_ADRENALINE, true, NULL, NULL, m_creature->GetObjectGuid());

            m_uiBurningAdrenalineTankTimer = 45000;
        }
        else
            m_uiBurningAdrenalineTankTimer -= uiDiff;

        // Fire Nova Timer
        if (m_uiFireNovaTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_FIRE_NOVA) == CAST_OK)
                m_uiFireNovaTimer = 5000;
        }
        else
            m_uiFireNovaTimer -= uiDiff;

        // Tail Sweep Timer
        if (m_uiTailSweepTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_TAIL_SWEEP) == CAST_OK)
                m_uiTailSweepTimer = 20000;
        }
        else
            m_uiTailSweepTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }
        void UpdateAI(const uint32 diff)
        {
            if (IsNihil)
            {
                if (NihilSpeech_Timer <= diff)
                {
                    switch(NihilSpeech_Phase)
                    {
                        case 0:
                            DoScriptText(SAY_NIHIL_1, me);
                            ++NihilSpeech_Phase;
                            break;
                        case 1:
                            DoScriptText(SAY_NIHIL_2, me);
                            ++NihilSpeech_Phase;
                            break;
                        case 2:
                            DoScriptText(SAY_NIHIL_3, me);
                            ++NihilSpeech_Phase;
                            break;
                        case 3:
                            DoScriptText(SAY_NIHIL_4, me);
                            ++NihilSpeech_Phase;
                            break;
                        case 4:
                            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            //take off to location above
                            me->GetMotionMaster()->MovePoint(0, me->GetPositionX()+50.0f, me->GetPositionY(), me->GetPositionZ()+50.0f);
                            ++NihilSpeech_Phase;
                            break;
                    }
                    NihilSpeech_Timer = 5000;
                } else NihilSpeech_Timer -=diff;

                //anything below here is not interesting for Nihil, so skip it
                return;
            }

            if (!UpdateVictim())
                return;

            if (IntangiblePresence_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_INTANGIBLE_PRESENCE);
                IntangiblePresence_Timer = 15000+rand()%15000;
            } else IntangiblePresence_Timer -= diff;

            if (ManaBurn_Timer <= diff)
            {
                Unit *pTarget = me->getVictim();
                if (pTarget && pTarget->getPowerType() == POWER_MANA)
                    DoCast(pTarget, SPELL_MANA_BURN);
                ManaBurn_Timer = 8000+rand()%8000;
            } else ManaBurn_Timer -= diff;

            if (ArcaneBlast_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_ARCANE_BLAST);
                ArcaneBlast_Timer = 2500+rand()%5000;
            } else ArcaneBlast_Timer -= diff;

            DoMeleeAttackIfReady();
        }
Beispiel #23
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostilTarget())
            return;

        if( m_creature->getVictim() && m_creature->isAlive())
        {
            if (PoisonVolley_Timer < diff)
            {
                DoCast(m_creature->getVictim(),SPELL_POISONVOLLEY);
                PoisonVolley_Timer = 10000 + rand()%10000;
            }else PoisonVolley_Timer -= diff;

            if (!PhaseTwo && Aspect_Timer < diff)
            {
                DoCast(m_creature->getVictim(),SPELL_ASPECT_OF_MARLI);
                Aspect_Timer = 13000 + rand()%5000;
            }else Aspect_Timer -= diff;

            if (!Spawned && SpawnStartSpiders_Timer < diff)
            {
                Unit* target = NULL;
                target = SelectUnit(SELECT_TARGET_RANDOM,0);

                Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if(target && Spider ) { Spider ->AI()->AttackStart(target); }
                Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if(target && Spider ) { Spider ->AI()->AttackStart(target); }
                Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if(target && Spider ) { Spider ->AI()->AttackStart(target); }
                Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if(target && Spider ) { Spider ->AI()->AttackStart(target); }

                Spawned = true;
            }else SpawnStartSpiders_Timer -= diff;

            if (SpawnSpider_Timer < diff)
            {
                Unit* target = NULL;
                target = SelectUnit(SELECT_TARGET_RANDOM,0);

                Spider = m_creature->SummonCreature(15041,target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(),0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if(target && Spider ) { Spider ->AI()->AttackStart(target); }

                SpawnSpider_Timer = 12000 + rand()%5000;
            }else SpawnSpider_Timer -= diff;

            if(!PhaseTwo && Transform_Timer < diff)
            {
                DoCast(m_creature,SPELL_SPIDER_FORM);
                const CreatureInfo *cinfo = m_creature->GetCreatureInfo();
                m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 35)));
                m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 35)));
                m_creature->UpdateDamagePhysical(BASE_ATTACK);
                DoCast(m_creature->getVictim(),SPELL_ENVOLWINGWEB);

                if(m_creature->getThreatManager().getThreat(m_creature->getVictim()))
                    m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-100);

                PhaseTwo = true;
                Transform_Timer = 35000 + rand()%25000;
            }else Transform_Timer -= diff;

            if (PhaseTwo)
            {
                if (Charge_Timer < diff)
                {
                    Unit* target = NULL;
                    int i = 0 ;
                    while (i < 3)                           // max 3 tries to get a random target with power_mana
                    {
                        ++i;                                //not aggro leader
                        target = SelectUnit(SELECT_TARGET_RANDOM,1);
                        if (target)
                            if (target->getPowerType() == POWER_MANA)
                                i=3;
                    }
                    if (target)
                    {
                        DoCast(target, SPELL_CHARGE);
                        //m_creature->Relocate(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0);
                        //m_creature->SendMonsterMove(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, true,1);
                        AttackStart(target);
                    }

                    Charge_Timer = 8000;
                }else Charge_Timer -= diff;

                if (TransformBack_Timer < diff)
                {
                    m_creature->SetUInt32Value(UNIT_FIELD_DISPLAYID,15220);
                    const CreatureInfo *cinfo = m_creature->GetCreatureInfo();
                    m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 1)));
                    m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 1)));
                    m_creature->UpdateDamagePhysical(BASE_ATTACK);

                    PhaseTwo = false;
                    TransformBack_Timer = 25000 + rand()%15000;
                }else TransformBack_Timer -= diff;

            }

            DoMeleeAttackIfReady();
        }
    }
Beispiel #24
0
		void UnchainedMagic()
		{
			Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0);
			if (pTarget && !pTarget->HasAura(SPELL_UNCHAINED_MAGIC) && !me->IsWithinDistInMap(pTarget, 5) && pTarget->getPowerType() == POWER_MANA)
			{
				DoCast(pTarget, SPELL_UNCHAINED_MAGIC);
				DoScriptText(SAY_UNCHAINED_MAGIC, me);
			}
		}
            void UpdateAI(uint32 uiDiff)
            {
                if (me->HasUnitState(UNIT_STATE_CASTING))
                    return;

                if (!UpdateVictim())
                    return;

                if (m_uiSporeTimer <= uiDiff)
                {
                    if(Unit* victim = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me)))
                        DoCast(victim, SPELL_SPORE);
                    m_uiSporeTimer = urand(20000, 25000);
                }
                else
                    m_uiSporeTimer -= uiDiff;

                if (m_uiWitherTimer <= uiDiff)
                {
                    if(Unit* victim = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        DoCast(victim, SPELL_WITHER);
                    m_uiWitherTimer = urand(14000, 18000);
                }
                else
                    m_uiWitherTimer -= uiDiff;

                if (m_uiLife_Drain_Timer <= uiDiff)
                {
                    Unit *pTarget = NULL;

                    uint8 i = 0;
                    while (i < 5)                                   // max 5 tries to get a random target with power_mana
                    {
                    ++i;
                    pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); 
                    if (pTarget && pTarget->getPowerType() == POWER_MANA)
                    {
                        i = 5;

                        me->SetPower(POWER_ENERGY, me->GetPower(POWER_ENERGY) + 10); // cast spell on target with mana.
                        DoCast(pTarget, SPELL_CONSUME_ENERGY_MANA_N);
                    }
                }

                    m_uiLife_Drain_Timer = 15000;

                } else m_uiLife_Drain_Timer -= uiDiff;

                if (m_uiLife_Drain2_Timer <= uiDiff)
                {
                    Unit *pTarget = NULL;

                    uint8 i = 0;
                    while (i < 5)                                   // max 5 tries to get a random target with power_energy
                    {
                    ++i;
                    pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); 
                    if (pTarget && pTarget->getPowerType() == POWER_ENERGY)
                    {
                            i = 5;

                        me->SetPower(POWER_ENERGY, me->GetPower(POWER_ENERGY) + 10); // cast spell on target with mana.
                        DoCast(pTarget, SPELL_CONSUME_ENERGY_ENER_N);
                    }
                    }

                    m_uiLife_Drain2_Timer = 15000;
                } else m_uiLife_Drain2_Timer -= uiDiff;

                if (m_uiLife_Drain3_Timer <= uiDiff)
                {
                    Unit *pTarget = NULL;

                    uint8 i = 0;
                    while (i < 5)                                   // max 5 tries to get a random target with power_runic
                    {
                    ++i;
                    pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); 
                    if (pTarget && pTarget->getPowerType() == POWER_RUNIC_POWER)
                    {
                            i = 5;

                        DoCast(pTarget, SPELL_CONSUME_ENERGY_RUNE_N);
                        me->SetPower(POWER_ENERGY, me->GetPower(POWER_ENERGY) + 20);
                    }
                    }

                    m_uiLife_Drain3_Timer = 15000;
                } else m_uiLife_Drain3_Timer -= uiDiff;

                if (m_uiLife_Drain4_Timer <= uiDiff)
                {
                    Unit *pTarget = NULL;

                    uint8 i = 0;
                    while (i < 5)                                   // max 5 tries to get a random target with power_rage
                    {
                    ++i;
                    pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);                    
                    if (pTarget && pTarget->getPowerType() == POWER_RAGE)
                    {
                            i = 5;

                        DoCast(pTarget, SPELL_CONSUME_ENERGY_RAGE_N);
                        me->SetPower(POWER_ENERGY, me->GetPower(POWER_ENERGY) + 10);
                    }
                    }

                    m_uiLife_Drain4_Timer = 15000;
                } else m_uiLife_Drain4_Timer -= uiDiff;

                if (m_uiLife_Drain5_Timer <= uiDiff)
                {
                    Unit *pTarget = NULL;

                    uint8 i = 0;
                    while (i < 5)                                   // max 5 tries to get a random target with power_focus
                    {
                    ++i;
                    pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); 
                    if (pTarget && pTarget->getPowerType() == POWER_FOCUS)
                    {
                            i = 5;

                        DoCast(pTarget, SPELL_CONSUME_ENERGY_FOCU_N);
                        me->SetPower(POWER_ENERGY, me->GetPower(POWER_ENERGY) + 20);
                    }
                    }

                    m_uiLife_Drain5_Timer = 15000;
                } else m_uiLife_Drain5_Timer -= uiDiff;

                if (m_uiSeedlingTimer <= uiDiff)
                {
                    me->MonsterTextEmote(SAY_ANNOUNCE, NULL, true);
                     
                    if(urand(1, 2) == 1)
                    {
                        seedling[i] = me->SummonCreature(40716, me->GetPositionX()+15+i*3, me->GetPositionY()+urand(10, 20), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 300000);
                        DoZoneInCombat(seedling[i]);
                    }
                    else
                    {
                        seedling[i] = me->SummonCreature(40716, me->GetPositionX()-15-i*3, me->GetPositionY()+urand(10, 20), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 300000);
                        DoZoneInCombat(seedling[i]);
                    }
                    if(!i) 
                        m_uiEnergizingGrowthTimer = 3000;
                    i++;
                    m_uiSeedlingTimer = IsHeroic() ? urand(12000, 17000) : urand(17000, 23000);
                    m_uiRampantTimer += 5000;
                }
                else
                    m_uiSeedlingTimer -= uiDiff;

                if (me->GetPower(POWER_ENERGY) == 100)
                {
                    if(me->HasUnitState(UNIT_STATE_CASTING))
                        me->CastStop();
                    DoCast(me, IsHeroic() ? SPELL_RAMPANT_GROWTH_H : SPELL_RAMPANT_GROWTH);
                    m_uiBoomTimer = 2000;
                    m_uiRampantTimer = 30000;
                    Talk(SAY_RAMPANT);
                }
                else
                    m_uiRampantTimer -= uiDiff;
                if (m_uiBoomTimer > 0 && m_uiBoomTimer <= uiDiff)
                {
                    uint8 k = 0;
                    for(uint8 j=0; j<10; j++)
                        if(seedling[j] && k != i)
                        {
                            k++;
                            blossom[j] = me->SummonCreature(40620, seedling[j]->GetPositionX(), seedling[j]->GetPositionY(), seedling[j]->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 300000);
                            DoZoneInCombat(blossom[j]);
                            seedling[j]->setDeathState(JUST_DIED);
                        }
                    for(uint8 p=0; p<10; p++)
                    {
                        seedling[p] = NULL;
                        blossom[p] = NULL;
                    }
                    i = 0;
                    m_uiBoomTimer = 0;
                }
                else
                    m_uiBoomTimer -= uiDiff;

                if (i > 0 && m_uiEnergizingGrowthTimer <= uiDiff)
                {
                    if(IsHeroic())
                    {
                    DoCast(me, SPELL_ENERGIZING_GROWTH_TICK);
                    me->AddAura(SPELL_ENERGIZE_ENRAGE, me);
                    }
                    else if (!IsHeroic())
                    me->AddAura(SPELL_ENERGIZE_ENRAGE, me);
                    
                    m_uiEnergizingGrowthTimer = 4000 - i*1000;
                    me->SetPower(POWER_ENERGY, me->GetPower(POWER_ENERGY) + 10);
                }
                else
                    m_uiEnergizingGrowthTimer -= uiDiff;

                DoMeleeAttackIfReady();
            }
        void UpdateAI(const uint32 diff)
        {
            //Speech
            if (DoingSpeech)
            {
                if (SpeechTimer <= diff)
                {
                    switch (SpeechNum)
                    {
                        case 0:
                            //16 seconds till next line
                            Talk(SAY_LINE2);
                            SpeechTimer = 16000;
                            ++SpeechNum;
                            break;
                        case 1:
                            //This one is actually 16 seconds but we only go to 10 seconds because he starts attacking after he says "I must fight this!"
                            Talk(SAY_LINE3);
                            SpeechTimer = 10000;
                            ++SpeechNum;
                            break;
                        case 2:
                            me->setFaction(103);
                            if (PlayerGUID && Unit::GetUnit(*me, PlayerGUID))
                            {
                                AttackStart(Unit::GetUnit(*me, PlayerGUID));
                                DoCast(me, SPELL_ESSENCEOFTHERED);
                            }
                            SpeechTimer = 0;
                            DoingSpeech = false;
                            break;
                    }
                } else SpeechTimer -= diff;
            }

            //Return since we have no target
            if (!UpdateVictim())
                return;

            // Yell if hp lower than 15%
            if (HealthBelowPct(15) && !HasYelled)
            {
                Talk(SAY_HALFLIFE);
                HasYelled = true;
            }

            //Cleave_Timer
            if (Cleave_Timer <= diff)
            {
                DoCastVictim(SPELL_CLEAVE);
                Cleave_Timer = 15000;
            } else Cleave_Timer -= diff;

            //FlameBreath_Timer
            if (FlameBreath_Timer <= diff)
            {
                DoCastVictim(SPELL_FLAMEBREATH);
                FlameBreath_Timer = urand(4000, 8000);
            } else FlameBreath_Timer -= diff;

            //BurningAdrenalineCaster_Timer
            if (BurningAdrenalineCaster_Timer <= diff)
            {
                Unit* target = NULL;

                uint8 i = 0;
                while (i < 3)   // max 3 tries to get a random target with power_mana
                {
                    ++i;
                    target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); //not aggro leader
                    if (target && target->getPowerType() == POWER_MANA)
                            i = 3;
                }
                if (target)                                     // cast on self (see below)
                    target->CastSpell(target, SPELL_BURNINGADRENALINE, 1);

                BurningAdrenalineCaster_Timer = 15000;
            } else BurningAdrenalineCaster_Timer -= diff;

            //BurningAdrenalineTank_Timer
            if (BurningAdrenalineTank_Timer <= diff)
            {
                // have the victim cast the spell on himself otherwise the third effect aura will be applied
                // to Vael instead of the player
                me->GetVictim()->CastSpell(me->GetVictim(), SPELL_BURNINGADRENALINE, 1);

                BurningAdrenalineTank_Timer = 45000;
            } else BurningAdrenalineTank_Timer -= diff;

            //FireNova_Timer
            if (FireNova_Timer <= diff)
            {
                DoCastVictim(SPELL_FIRENOVA);
                FireNova_Timer = 5000;
            } else FireNova_Timer -= diff;

            //TailSwipe_Timer
            if (TailSwipe_Timer <= diff)
            {
                //Only cast if we are behind
                /*if (!me->HasInArc(M_PI, me->GetVictim()))
                {
                DoCastVictim(SPELL_TAILSWIPE);
                }*/

                TailSwipe_Timer = 20000;
            } else TailSwipe_Timer -= diff;

            DoMeleeAttackIfReady();
        }
Beispiel #27
0
/*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
{
    DEBUG_LOG("WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
    ObjectGuid guid;
    recv_data >> guid;

    Player * player = HashMapHolder<Player>::Find(guid);
    if(!player)
    {
        WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2);
        data << uint8(0);                                   // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
        data << guid.WriteAsPacked();
        data << uint32(GROUP_UPDATE_FLAG_STATUS);
        data << uint16(MEMBER_STATUS_OFFLINE);
        SendPacket(&data);
        return;
    }

    Unit *pet = player->GetCharmOrPet();

    WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
    data << uint8(0);                                       // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
    data << player->GetPackGUID();

    uint32 mask1 = 0x00040BFF;                              // common mask, real flags used 0x000040BFF
    if(pet)
        mask1 = 0xFFFFFFFF;                                 // for hunters and other classes with pets

    Powers powerType = player->getPowerType();
    data << uint32(mask1);                                  // group update mask
    data << uint16(MEMBER_STATUS_ONLINE);                   // member's online status
    data << uint32(player->GetHealth());                    // GROUP_UPDATE_FLAG_CUR_HP
    data << uint32(player->GetMaxHealth());                 // GROUP_UPDATE_FLAG_MAX_HP
    data << uint8(powerType);                               // GROUP_UPDATE_FLAG_POWER_TYPE
    data << uint16(player->GetPower(powerType));            // GROUP_UPDATE_FLAG_CUR_POWER
    data << uint16(player->GetMaxPower(powerType));         // GROUP_UPDATE_FLAG_MAX_POWER
    data << uint16(player->getLevel());                     // GROUP_UPDATE_FLAG_LEVEL

    //verify player coordinates and zoneid to send to teammates
    uint16 iZoneId = 0;
    uint16 iCoordX = 0;
    uint16 iCoordY = 0;

    if (player->IsInWorld())
    {
        iZoneId = player->GetZoneId();
        iCoordX = player->GetPositionX();
        iCoordY = player->GetPositionY();
    }
    else if (player->IsBeingTeleported())               // Player is in teleportation
    {
        WorldLocation& loc = player->GetTeleportDest(); // So take teleportation destination
        iZoneId = sTerrainMgr.GetZoneId(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z);
        iCoordX = loc.coord_x;
        iCoordY = loc.coord_y;
    }
    else
    {
        //unknown player status.
    }

    data << uint16(iZoneId);                              // GROUP_UPDATE_FLAG_ZONE
    data << uint16(iCoordX);                              // GROUP_UPDATE_FLAG_POSITION
    data << uint16(iCoordY);                              // GROUP_UPDATE_FLAG_POSITION

    uint64 auramask = 0;
    size_t maskPos = data.wpos();
    data << uint64(auramask);                               // placeholder
    for(uint8 i = 0; i < MAX_AURAS; ++i)
    {
        if(uint32 aura = player->GetVisibleAura(i))
        {
            auramask |= (uint64(1) << i);
            data << uint32(aura);
            data << uint8(1);
        }
    }
    data.put<uint64>(maskPos, auramask);                    // GROUP_UPDATE_FLAG_AURAS

    if(pet)
    {
        Powers petpowertype = pet->getPowerType();
        data << pet->GetObjectGuid();                       // GROUP_UPDATE_FLAG_PET_GUID
        data << pet->GetName();                             // GROUP_UPDATE_FLAG_PET_NAME
        data << uint16(pet->GetDisplayId());                // GROUP_UPDATE_FLAG_PET_MODEL_ID
        data << uint32(pet->GetHealth());                   // GROUP_UPDATE_FLAG_PET_CUR_HP
        data << uint32(pet->GetMaxHealth());                // GROUP_UPDATE_FLAG_PET_MAX_HP
        data << uint8(petpowertype);                        // GROUP_UPDATE_FLAG_PET_POWER_TYPE
        data << uint16(pet->GetPower(petpowertype));        // GROUP_UPDATE_FLAG_PET_CUR_POWER
        data << uint16(pet->GetMaxPower(petpowertype));     // GROUP_UPDATE_FLAG_PET_MAX_POWER

        uint64 petauramask = 0;
        size_t petMaskPos = data.wpos();
        data << uint64(petauramask);                        // placeholder
        for(uint8 i = 0; i < MAX_AURAS; ++i)
        {
            if(uint32 petaura = pet->GetVisibleAura(i))
            {
                petauramask |= (uint64(1) << i);
                data << uint32(petaura);
                data << uint8(1);
            }
        }
        data.put<uint64>(petMaskPos, petauramask);          // GROUP_UPDATE_FLAG_PET_AURAS
        data << (uint32) player->m_movementInfo.GetTransportDBCSeat();
    }
    else
    {
        data << uint8(0);                                   // GROUP_UPDATE_FLAG_PET_NAME
        data << uint64(0);                                  // GROUP_UPDATE_FLAG_PET_AURAS
    }

    SendPacket(&data);
}