Example #1
0
        void UpdateAI(const uint32 diff)
        {
            if (SayTimer <= diff)
            {
                if (Event)
                    SayTimer = NextStep(++Step);
            } else SayTimer -= diff;

            if (Attack)
            {
                Player* pPlayer = Unit::GetPlayer(*me, PlayerGUID);
                me->setFaction(14);
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                if (pPlayer)
                {
                Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20);
                if (Creepjack)
                {
                    Creepjack->Attack(pPlayer, true);
                    Creepjack->setFaction(14);
                    Creepjack->GetMotionMaster()->MoveChase(pPlayer);
                    Creepjack->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }
                Unit* Malone = me->FindNearestCreature(NPC_MALONE, 20);
                if (Malone)
                {
                    Malone->Attack(pPlayer, true);
                    Malone->setFaction(14);
                    Malone->GetMotionMaster()->MoveChase(pPlayer);
                    Malone->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }
                    DoStartMovement(pPlayer);
                    AttackStart(pPlayer);
                }
                Attack = false;
            }

            if (HealthBelowPct(5) && !Done)
            {
                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                me->RemoveAllAuras();

                Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20);
                if (Creepjack)
                {
                    CAST_CRE(Creepjack)->AI()->EnterEvadeMode();
                    Creepjack->setFaction(1194);
                    Creepjack->GetMotionMaster()->MoveTargetedHome();
                    Creepjack->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }
                Unit* Malone = me->FindNearestCreature(NPC_MALONE, 20);
                if (Malone)
                {
                    CAST_CRE(Malone)->AI()->EnterEvadeMode();
                    Malone->setFaction(1194);
                    Malone->GetMotionMaster()->MoveTargetedHome();
                    Malone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }
                me->setFaction(1194);
                Done = true;
                DoScriptText(SAY_GIVEUP, me, NULL);
                me->DeleteThreatList();
                me->CombatStop();
                me->GetMotionMaster()->MoveTargetedHome();
                Player* pPlayer = Unit::GetPlayer(*me, PlayerGUID);
                if (pPlayer)
                    CAST_PLR(pPlayer)->GroupEventHappens(QUEST_WBI, me);
            }
            DoMeleeAttackIfReady();
        }
Example #2
0
            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                    //Check_Timer for the death of LorKhan and Zath.
                    if (!WasDead && Check_Timer <= diff)
                    {
                        if (instance)
                        {
                            if (instance->GetData(DATA_LORKHAN) == SPECIAL)
                            {
                                //Resurrect LorKhan
                                if (Unit* LorKhan = Unit::GetUnit((*me), instance->GetData64(DATA_LORKHAN)))
                                {
                                    LorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                                    LorKhan->setFaction(14);
                                    LorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                    LorKhan->SetFullHealth();

                                    instance->SetData(DATA_LORKHAN, DONE);
                                }
                            }

                            if (instance->GetData(DATA_ZATH) == SPECIAL)
                            {
                                //Resurrect Zath
                                Unit* zath = Unit::GetUnit((*me), instance->GetData64(DATA_ZATH));
                                if (zath)
                                {
                                    zath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                                    zath->setFaction(14);
                                    zath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                    zath->SetFullHealth();

                                    instance->SetData(DATA_ZATH, DONE);
                                }
                            }
                        }

                        Check_Timer = 5000;
                    } else Check_Timer -= diff;

                    if (!PhaseTwo && MortalCleave_Timer <= diff)
                    {
                        DoCast(me->getVictim(), SPELL_MORTALCLEAVE);
                        MortalCleave_Timer = 15000 + rand()%5000;
                    } else MortalCleave_Timer -= diff;

                    if (!PhaseTwo && Silence_Timer <= diff)
                    {
                        DoCast(me->getVictim(), SPELL_SILENCE);
                        Silence_Timer = 20000 + rand()%5000;
                    } else Silence_Timer -= diff;

                    if (!PhaseTwo && !WasDead && !HealthAbovePct(5))
                    {
                        me->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE_PERCENT);
                        me->RemoveAurasByType(SPELL_AURA_PERIODIC_DAMAGE);
                        me->RemoveAurasByType(SPELL_AURA_PERIODIC_LEECH);
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        me->SetStandState(UNIT_STAND_STATE_SLEEP);
                        me->AttackStop();

                        if (instance)
                            instance->SetData(DATA_THEKAL, SPECIAL);

                        WasDead=true;
                    }

                    //Thekal will transform to Tiger if he died and was not resurrected after 10 seconds.
                    if (!PhaseTwo && WasDead)
                    {
                        if (Resurrect_Timer <= diff)
                        {
                            DoCast(me, SPELL_TIGER_FORM);
                            me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.00f);
                            me->SetStandState(UNIT_STAND_STATE_STAND);
                            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            me->SetFullHealth();
                            const CreatureTemplate *cinfo = me->GetCreatureInfo();
                            me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 40)));
                            me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 40)));
                            me->UpdateDamagePhysical(BASE_ATTACK);
                            DoResetThreat();
                            PhaseTwo = true;
                        } else Resurrect_Timer -= diff;
                    }

                    if (me->IsFullHealth() && WasDead)
                    {
                        WasDead = false;
                    }

                    if (PhaseTwo)
                    {
                        if (Charge_Timer <= diff)
                        {
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            {
                                DoCast(target, SPELL_CHARGE);
                                DoResetThreat();
                                AttackStart(target);
                            }

                            Charge_Timer = 15000 + rand()%7000;
                        } else Charge_Timer -= diff;

                        if (Frenzy_Timer <= diff)
                        {
                            DoCast(me, SPELL_FRENZY);
                            Frenzy_Timer = 30000;
                        } else Frenzy_Timer -= diff;

                        if (ForcePunch_Timer <= diff)
                        {
                            DoCast(me->getVictim(), SPELL_SILENCE);
                            ForcePunch_Timer = 16000 + rand()%5000;
                        } else ForcePunch_Timer -= diff;

                        if (SummonTigers_Timer <= diff)
                        {
                            DoCast(me->getVictim(), SPELL_SUMMONTIGERS);
                            SummonTigers_Timer = 10000 + rand()%4000;
                        } else SummonTigers_Timer -= diff;

                        if (HealthBelowPct(11) && !Enraged)
                        {
                            DoCast(me, SPELL_ENRAGE);
                            Enraged = true;
                        }
                    }

                    DoMeleeAttackIfReady();
            }
void boss_attumen::boss_attumenAI::UpdateAI(const uint32 diff)
{
    if (ResetTimer)
    {
        if (ResetTimer <= diff)
        {
            ResetTimer = 0;
            Unit *pMidnight = Unit::GetUnit(*me, Midnight);
            if (pMidnight)
            {
                pMidnight->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                pMidnight->SetVisible(true);
            }
            Midnight = 0;
            me->SetVisible(false);
            me->Kill(me);
        }
    } else ResetTimer -= diff;

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

    if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE))
        return;

    if (CleaveTimer <= diff)
    {
        DoCast(me->getVictim(), SPELL_SHADOWCLEAVE);
        CleaveTimer = urand(10000,15000);
    } else CleaveTimer -= diff;

    if (CurseTimer <= diff)
    {
        DoCast(me->getVictim(), SPELL_INTANGIBLE_PRESENCE);
        CurseTimer = 30000;
    } else CurseTimer -= diff;

    if (RandomYellTimer <= diff)
    {
        DoScriptText(RAND(SAY_RANDOM1,SAY_RANDOM2), me);
        RandomYellTimer = urand(30000,60000);
    } else RandomYellTimer -= diff;

    if (me->GetUInt32Value(UNIT_FIELD_DISPLAYID) == MOUNTED_DISPLAYID)
    {
        if (ChargeTimer <= diff)
        {
            Unit *pTarget = NULL;
            std::list<HostileReference *> t_list = me->getThreatManager().getThreatList();
            std::vector<Unit *> target_list;
            for (std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
            {
                pTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                if (pTarget && !pTarget->IsWithinDist(me, ATTACK_DISTANCE, false))
                    target_list.push_back(pTarget);
                pTarget = NULL;
            }
            if (target_list.size())
                pTarget = *(target_list.begin()+rand()%target_list.size());

            DoCast(pTarget, SPELL_BERSERKER_CHARGE);
            ChargeTimer = 20000;
        } else ChargeTimer -= diff;
    }
    else
    {
        if (HealthBelowPct(25))
        {
            Creature *pMidnight = Unit::GetCreature(*me, Midnight);
            if (pMidnight && pMidnight->GetTypeId() == TYPEID_UNIT)
            {
                CAST_AI(boss_midnight::boss_midnightAI, (pMidnight->AI()))->Mount(me);
                me->SetHealth(pMidnight->GetHealth());
                DoResetThreat();
            }
        }
    }

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

                if (StormCount)
                {
                    Unit* target = Unit::GetUnit(*me, CloudGUID);
                    if (!target || !target->isAlive())
                    {
                        EnterEvadeMode();
                        return;
                    }
                    else if (Unit* Cyclone = Unit::GetUnit(*me, CycloneGUID))
                        Cyclone->CastSpell(target, 25160, true); // keep casting or...

                    if (StormSequenceTimer <= diff)
                        HandleStormSequence(target);
                    else
                        StormSequenceTimer -= diff;

                    return;
                }

                if (Enrage_Timer <= diff)
                {
                    me->MonsterYell(SAY_ONENRAGE, LANG_UNIVERSAL, 0);
                    DoPlaySoundToSet(me, SOUND_ONENRAGE);
                    DoCast(me, SPELL_BERSERK, true);
                    Enrage_Timer = 600000;
                } else Enrage_Timer -= diff;

                if (StaticDisruption_Timer <= diff)
                {
                    Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1);
                    if (!target) target = me->getVictim();
                    TargetGUID = target->GetGUID();
                    DoCast(target, SPELL_STATIC_DISRUPTION, false);
                    me->SetInFront(me->getVictim());
                    StaticDisruption_Timer = (10+rand()%8)*1000; // < 20s

                    /*if (float dist = me->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f) dist = 5.0f;
                    SDisruptAOEVisual_Timer = 1000 + floor(dist / 30 * 1000.0f);*/
                } else StaticDisruption_Timer -= diff;

                if (GustOfWind_Timer <= diff)
                {
                    Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1);
                    if (!target) target = me->getVictim();
                    DoCast(target, SPELL_GUST_OF_WIND);
                    GustOfWind_Timer = (20+rand()%10)*1000; //20 to 30 seconds(bosskillers)
                } else GustOfWind_Timer -= diff;

                if (CallLighting_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_CALL_LIGHTNING);
                    CallLighting_Timer = (12 + rand()%5)*1000; //totaly random timer. can't find any info on this
                } else CallLighting_Timer -= diff;

                if (!isRaining && ElectricalStorm_Timer < uint32(8000 + rand() % 5000))
                {
                    SetWeather(WEATHER_STATE_HEAVY_RAIN, 0.9999f);
                    isRaining = true;
                }

                if (ElectricalStorm_Timer <= diff) {
                    Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true);
                    if (!target)
                    {
                        EnterEvadeMode();
                        return;
                    }
                    target->CastSpell(target, 44007, true);//cloud visual
                    DoCast(target, SPELL_ELECTRICAL_STORM, false);//storm cyclon + visual
                    float x, y, z;
                    target->GetPosition(x, y, z);
                    if (target)
                    {
                        target->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING);
                        target->SendMonsterMove(x, y, me->GetPositionZ()+15, 0);
                    }
                    Unit* Cloud = me->SummonTrigger(x, y, me->GetPositionZ()+16, 0, 15000);
                    if (Cloud)
                    {
                        CloudGUID = Cloud->GetGUID();
                        Cloud->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING);
                        Cloud->StopMoving();
                        Cloud->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
                        Cloud->setFaction(35);
                        Cloud->SetMaxHealth(9999999);
                        Cloud->SetHealth(9999999);
                        Cloud->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    }
                    ElectricalStorm_Timer = 60000; //60 seconds(bosskillers)
                    StormCount = 1;
                    StormSequenceTimer = 0;
                } else ElectricalStorm_Timer -= diff;

                if (SummonEagles_Timer <= diff)
                {
                    me->MonsterYell(SAY_ONSUMMON, LANG_UNIVERSAL, 0);
                    DoPlaySoundToSet(me, SOUND_ONSUMMON);

                    float x, y, z;
                    me->GetPosition(x, y, z);

                    for (uint8 i = 0; i < 8; ++i)
                    {
                        Unit* bird = Unit::GetUnit(*me, BirdGUIDs[i]);
                        if (!bird) //they despawned on die
                        {
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            {
                                x = target->GetPositionX() + irand(-10, 10);
                                y = target->GetPositionY() + irand(-10, 10);
                                z = target->GetPositionZ() + urand(16, 20);
                                if (z > 95)
                                    z = 95.0f - urand(0, 5);
                            }
                            Creature* creature = me->SummonCreature(MOB_SOARING_EAGLE, x, y, z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                            if (creature)
                            {
                                creature->AddThreat(me->getVictim(), 1.0f);
                                creature->AI()->AttackStart(me->getVictim());
                                BirdGUIDs[i] = creature->GetGUID();
                            }
                        }
                    }
                    SummonEagles_Timer = 999999;
                } else SummonEagles_Timer -= diff;

                DoMeleeAttackIfReady();
            }
Example #5
0
/// Remove control and such modifiers to a passenger if they were added
void VehicleInfo::RemoveSeatMods(Unit* passenger, uint32 seatFlags)
{
    Unit* pVehicle = (Unit*)m_owner;

    if (seatFlags & SEAT_FLAG_NOT_SELECTABLE)
        passenger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);

    // ToDo: reset passenger model id for SEAT_FLAG_HIDE_PASSENGER?

    if (passenger->GetTypeId() == TYPEID_PLAYER)
    {
        Player* pPlayer = (Player*)passenger;

        // group update
        if (pPlayer->GetGroup())
            pPlayer->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_VEHICLE_SEAT);

        if (seatFlags & SEAT_FLAG_CAN_CONTROL)
        {
            pPlayer->SetCharm(nullptr);
            pVehicle->SetCharmer(nullptr);

            pPlayer->UpdateClientControl(pVehicle, false);
            pPlayer->SetMover(nullptr);

            pVehicle->StopMoving(true);
            pVehicle->GetMotionMaster()->Clear();

            pVehicle->clearUnitState(UNIT_STAT_POSSESSED);
            pVehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);

            pVehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);

            // must be called after movement control unapplying
            pPlayer->GetCamera().ResetView();

            if (pVehicle->GetTypeId() == TYPEID_UNIT)
            {
                // reset vehicle faction
                ((Creature*)pVehicle)->ClearTemporaryFaction();

                // Reset react state
                if (!(GetVehicleEntry()->m_flags & VEHICLE_FLAG_PASSIVE))
                    pVehicle->AI()->SetReactState(REACT_AGGRESSIVE);
            }
        }

        if (seatFlags & SEAT_FLAG_CAN_CAST)
            pPlayer->RemovePetActionBar();
    }
    else if (passenger->GetTypeId() == TYPEID_UNIT)
    {
        if (seatFlags & SEAT_FLAG_CAN_CONTROL)
        {
            passenger->SetCharm(nullptr);
            pVehicle->SetCharmer(nullptr);
        }

        // Reinitialize movement
        if (((Creature*)passenger)->AI())
            ((Creature*)passenger)->AI()->SetCombatMovement(true, true);
        if (!passenger->getVictim())
            passenger->GetMotionMaster()->Initialize();
    }
}
Example #6
0
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

            //Check_Timer for the death of LorKhan and Zath.
            if(!WasDead && Check_Timer < diff)
            {
                if(pInstance)
                {
                    if(pInstance->GetData(DATA_LORKHANISDEAD))
                    {
                        //Resurrect LorKhan
                        Unit *pLorKhan = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_LORKHAN));
                        if(pLorKhan)
                        {
                            pLorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                            pLorKhan->setFaction(14);
                            pLorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            pLorKhan->SetHealth(int(pLorKhan->GetMaxHealth()*1.0));
                        }
                    }

                    if(pInstance->GetData(DATA_ZATHISDEAD))
                    {
                        //Resurrect Zath
                        Unit *pZath = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ZATH));
                        if(pZath)
                        {
                            pZath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                            pZath->setFaction(14);
                            pZath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            pZath->SetHealth(int(pZath->GetMaxHealth()*1.0));
                        }
                    }
                }

                Check_Timer = 5000;
            }else Check_Timer -= diff;

            if (!PhaseTwo && MortalCleave_Timer < diff)
            {
                DoCast(m_creature->getVictim(),SPELL_MORTALCLEAVE);
                MortalCleave_Timer = 15000 + rand()%5000;
            }else MortalCleave_Timer -= diff;

            if (!PhaseTwo && Silence_Timer < diff)
            {
                DoCast(m_creature->getVictim(),SPELL_SILENCE);
                Silence_Timer = 20000 + rand()%5000;
            }else Silence_Timer -= diff;

            if (!PhaseTwo && !WasDead && m_creature->GetHealth() <= m_creature->GetMaxHealth() * 0.05)
            {
                m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 3);
                m_creature->AttackStop();

                if(pInstance)
                    pInstance->SetData(DATA_THEKALFAKE_DEATH, 0);

                WasDead=true;
            }

            //Thekal will transform to Tiger if he died and was not resurrected after 10 seconds.
            if(!PhaseTwo && WasDead)
            {
                if (Resurrect_Timer < diff)
                {
                    DoCast(m_creature,SPELL_TIGER_FORM);
                    m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.00f);
                    m_creature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    m_creature->SetHealth(int(m_creature->GetMaxHealth()*1.0));
                    const CreatureInfo *cinfo = m_creature->GetCreatureInfo();
                    m_creature->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 40)));
                    m_creature->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 40)));
                    m_creature->UpdateDamagePhysical(BASE_ATTACK);
                    DoResetThreat();
                    PhaseTwo = true;
                }else Resurrect_Timer -= diff;
            }

            if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() == 100) && WasDead)
            {
                WasDead = false;
            }

            if (PhaseTwo)
            {
                if (Charge_Timer < diff)
                {
                    if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM,0))
                    {
                        DoCast(target,SPELL_CHARGE);
                        DoResetThreat();
                        AttackStart(target);
                    }

                    Charge_Timer = 15000 + rand()%7000;
                }else Charge_Timer -= diff;

                if (Frenzy_Timer < diff)
                {
                    DoCast(m_creature,SPELL_FRENZY);
                    Frenzy_Timer = 30000;
                }else Frenzy_Timer -= diff;

                if (ForcePunch_Timer < diff)
                {
                    DoCast(m_creature->getVictim(),SPELL_SILENCE);
                    ForcePunch_Timer = 16000 + rand()%5000;
                }else ForcePunch_Timer -= diff;

                if (SummonTigers_Timer < diff)
                {
                    DoCast(m_creature->getVictim(),SPELL_SUMMONTIGERS);
                    SummonTigers_Timer = 10000 + rand()%4000;
                }else SummonTigers_Timer -= diff;

                if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 11) && !Enraged)
                {
                    DoCast(m_creature, SPELL_ENRAGE);
                    Enraged = true;
                }
            }

            DoMeleeAttackIfReady();
    }