void UpdateAI(const uint32 diff)
        {
            if (Intro && !Done)
            {
                if (AggroTimer <= diff)
                {
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    DoScriptText(SAY_AGGRO, me);
                    me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE);
                    Done = true;
                    if (AggroTargetGUID)
                    {
                        Unit* pUnit = Unit::GetUnit((*me), AggroTargetGUID);
                        if (pUnit)
                            AttackStart(pUnit);

                        DoZoneInCombat();
                    }
                    else
                    {
                        EnterEvadeMode();
                        return;
                    }
                } else AggroTimer -= diff;
            }

            if (!UpdateVictim() || !Done)
                return;

            if (SummonShadowsTimer <= diff)
            {
                //MindControlGhost();

                for (uint8 i = 0; i < 2; ++i)
                {
                    Creature* Shadow = NULL;
                    float X = CalculateRandomLocation(me->GetPositionX(), 10);
                    Shadow = me->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 0);
                    if (Shadow)
                    {
                        Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1);
                        if (!pTarget)
                            pTarget = me->getVictim();

                        if (pTarget)
                            Shadow->AI()->AttackStart(pTarget);
                    }
                }
                SummonShadowsTimer = 60000;
            } else SummonShadowsTimer -= diff;

            if (SummonDoomBlossomTimer <= diff)
            {
                if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0))
                {
                    float X = CalculateRandomLocation(pTarget->GetPositionX(), 20);
                    float Y = CalculateRandomLocation(pTarget->GetPositionY(), 20);
                    float Z = pTarget->GetPositionZ();
                    Z = me->GetMap()->GetHeight(X, Y, Z);
                    Creature* DoomBlossom = me->SummonCreature(CREATURE_DOOM_BLOSSOM, X, Y, Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 20000);
                    if (DoomBlossom)
                    {
                        DoomBlossom->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        DoomBlossom->setFaction(me->getFaction());
                        DoomBlossom->AddThreat(pTarget, 1.0f);
                        CAST_AI(mob_doom_blossom::mob_doom_blossomAI, DoomBlossom->AI())->SetTeronGUID(me->GetGUID());
                        pTarget->CombatStart(DoomBlossom);
                        SetThreatList(DoomBlossom);
                        SummonDoomBlossomTimer = 35000;
                    }
                }
            } else SummonDoomBlossomTimer -= diff;

            if (IncinerateTimer <= diff)
            {
                Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1);
                if (!pTarget)
                    pTarget = me->getVictim();

                if (pTarget)
                {
                    DoScriptText(RAND(SAY_SPECIAL1, SAY_SPECIAL2), me);
                    DoCast(pTarget, SPELL_INCINERATE);
                    IncinerateTimer = 20000 + rand()%31 * 1000;
                }
            } else IncinerateTimer -= diff;

            if (CrushingShadowsTimer <= diff)
            {
                Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0);
                if (pTarget && pTarget->isAlive())
                    DoCast(pTarget, SPELL_CRUSHING_SHADOWS);
                CrushingShadowsTimer = 10000 + rand()%16 * 1000;
            } else CrushingShadowsTimer -= diff;

            /*** NOTE FOR FUTURE DEV: UNCOMMENT BELOW ONLY IF MIND CONTROL IS FULLY IMPLEMENTED **/
            /*if (ShadowOfDeathTimer <= diff)
            {
                Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);

                if (!pTarget)
                   pTarget = me->getVictim();

                if (pTarget && pTarget->isAlive() && pTarget->GetTypeId() == TYPEID_PLAYER)
                {
                    DoCast(pTarget, SPELL_SHADOW_OF_DEATH);
                    GhostGUID = pTarget->GetGUID();
                    ShadowOfDeathTimer = 30000;
                    SummonShadowsTimer = 53000; // Make it VERY close but slightly less so that we can check if the aura is still on the player
                }
            } else ShadowOfDeathTimer -= diff;*/

            if (RandomYellTimer <= diff)
            {
                DoScriptText(RAND(SAY_SPELL1, SAY_SPELL2), me);
                RandomYellTimer = 50000 + rand()%51 * 1000;
            } else RandomYellTimer -= diff;

            if (!me->HasAura(SPELL_BERSERK))
            {
                if (EnrageTimer <= diff)
            {
                DoCast(me, SPELL_BERSERK);
                DoScriptText(SAY_ENRAGE, me);
            } else EnrageTimer -= diff;
            }

            DoMeleeAttackIfReady();
        }
    bool OnUse(Player* player, Item* /*item*/, SpellCastTargets const& targets) override
    {
        InstanceScript* instance = player->GetInstanceScript();
        if (!instance)
        {
            player->GetSession()->SendNotification(TEXT_NOT_INITIALIZED);
            return true;
        }

        Creature* vashj = ObjectAccessor::GetCreature((*player), instance->GetGuidData(DATA_LADYVASHJ));
        if (vashj && (ENSURE_AI(boss_lady_vashj::boss_lady_vashjAI, vashj->AI())->Phase == 2))
        {
            if (GameObject* gObj = targets.GetGOTarget())
            {
                uint32 identifier;
                uint8 channelIdentifier;
                switch (gObj->GetEntry())
                {
                    case 185052:
                        identifier = DATA_SHIELDGENERATOR1;
                        channelIdentifier = 0;
                        break;
                    case 185053:
                        identifier = DATA_SHIELDGENERATOR2;
                        channelIdentifier = 1;
                        break;
                    case 185051:
                        identifier = DATA_SHIELDGENERATOR3;
                        channelIdentifier = 2;
                        break;
                    case 185054:
                        identifier = DATA_SHIELDGENERATOR4;
                        channelIdentifier = 3;
                        break;
                    default:
                        return true;
                }

                if (instance->GetData(identifier))
                {
                    player->GetSession()->SendNotification(TEXT_ALREADY_DEACTIVATED);
                    return true;
                }

                // get and remove channel
                if (Unit* channel = ObjectAccessor::GetCreature(*vashj, ENSURE_AI(boss_lady_vashj::boss_lady_vashjAI, vashj->AI())->ShieldGeneratorChannel[channelIdentifier]))
                    channel->setDeathState(JUST_DIED); // call Unsummon()

                instance->SetData(identifier, 1);

                // remove this item
                player->DestroyItemCount(31088, 1, true);
                return true;
            }
            else if (targets.GetUnitTarget()->GetTypeId() == TYPEID_UNIT)
                return false;
            else if (targets.GetUnitTarget()->GetTypeId() == TYPEID_PLAYER)
            {
                player->DestroyItemCount(31088, 1, true);
                player->CastSpell(targets.GetUnitTarget(), 38134, true);
                return true;
            }
        }
        return true;
    }
Exemple #3
0
        void UpdateAI(const uint32 diff)
        {
            //Return since we have no target
            if (!UpdateVictim())
                return;

            switch (Phase)
            {
                case 0:
                {
                    // *Heroic mode only:
                    if (IsHeroic())
                    {
                        if (PyroblastTimer <= diff)
                        {
                            me->InterruptSpell(CURRENT_CHANNELED_SPELL);
                            me->InterruptSpell(CURRENT_GENERIC_SPELL);
                            DoCast(me, SPELL_SHOCK_BARRIER, true);
                            DoCast(me->getVictim(), SPELL_PYROBLAST);
                            PyroblastTimer = 60000;
                        }
                        else PyroblastTimer -= diff;
                    }

                    if (FireballTimer <= diff)
                    {
                        DoCast(me->getVictim(), SPELL_FIREBALL_NORMAL);
                        FireballTimer = urand(2000, 6000);
                    }
                    else FireballTimer -= diff;

                    if (PhoenixTimer <= diff)
                    {
                        Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1);

                        uint8 random = urand(1, 2);
                        float x = KaelLocations[random][0];
                        float y = KaelLocations[random][1];

                        Creature* Phoenix = me->SummonCreature(CREATURE_PHOENIX, x, y, LOCATION_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
                        if (Phoenix)
                        {
                            Phoenix->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE);
                            SetThreatList(Phoenix);
                            Phoenix->AI()->AttackStart(target);
                        }

                        DoScriptText(SAY_PHOENIX, me);

                        PhoenixTimer = 60000;
                    }
                    else PhoenixTimer -= diff;

                    if (FlameStrikeTimer <= diff)
                    {
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                        {
                            me->InterruptSpell(CURRENT_CHANNELED_SPELL);
                            me->InterruptSpell(CURRENT_GENERIC_SPELL);
                            DoCast(target, SPELL_FLAMESTRIKE3, true);
                            DoScriptText(SAY_FLAMESTRIKE, me);
                        }
                        FlameStrikeTimer = urand(15000, 25000);
                    }
                    else FlameStrikeTimer -= diff;

                    // Below 50%
                    if (HealthBelowPct(50))
                    {
                        me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true);
                        me->StopMoving();
                        me->GetMotionMaster()->Clear();
                        me->GetMotionMaster()->MoveIdle();
                        GravityLapseTimer = 0;
                        GravityLapsePhase = 0;
                        Phase = 1;
                    }

                    DoMeleeAttackIfReady();
                }
                break;

                case 1:
                {
                    if (GravityLapseTimer <= diff)
                    {
                        switch (GravityLapsePhase)
                        {
                            case 0:
                                if (FirstGravityLapse)          // Different yells at 50%, and at every following Gravity Lapse
                                {
                                    DoScriptText(SAY_GRAVITY_LAPSE, me);
                                    FirstGravityLapse = false;

                                    if (instance)
                                    {
                                        instance->HandleGameObject(instance->GetData64(DATA_KAEL_STATUE_LEFT), true);
                                        instance->HandleGameObject(instance->GetData64(DATA_KAEL_STATUE_RIGHT), true);
                                    }
                                }
                                else
                                {
                                    DoScriptText(SAY_RECAST_GRAVITY, me);
                                }

                                DoCast(me, SPELL_GRAVITY_LAPSE_INITIAL);
                                GravityLapseTimer = 2000 + diff;// Don't interrupt the visual spell
                                GravityLapsePhase = 1;
                                break;
                            case 1:
                                TeleportPlayersToSelf();
                                GravityLapseTimer = 1000;
                                GravityLapsePhase = 2;
                                break;
                            case 2:
                                CastGravityLapseKnockUp();
                                GravityLapseTimer = 1000;
                                GravityLapsePhase = 3;
                                break;
                            case 3:
                                CastGravityLapseFly();
                                GravityLapseTimer = 30000;
                                GravityLapsePhase = 4;

                                for (uint8 i = 0; i < 3; ++i)
                                {
                                    Unit* target = NULL;
                                    target = SelectTarget(SELECT_TARGET_RANDOM, 0);

                                    Creature* Orb = DoSpawnCreature(CREATURE_ARCANE_SPHERE, 5, 5, 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
                                    if (Orb && target)
                                    {
                                        Orb->SetSpeed(MOVE_RUN, 0.5f);
                                        Orb->AddThreat(target, 1000000.0f);
                                        Orb->AI()->AttackStart(target);
                                    }
                                }

                                DoCast(me, SPELL_GRAVITY_LAPSE_CHANNEL);
                                break;
                            case 4:
                                me->InterruptNonMeleeSpells(false);
                                DoScriptText(SAY_TIRED, me);
                                DoCast(me, SPELL_POWER_FEEDBACK);
                                RemoveGravityLapse();
                                GravityLapseTimer = 10000;
                                GravityLapsePhase = 0;
                                break;
                        }
                    }
                    else GravityLapseTimer -= diff;
                }
                break;
            }
        }
            void UpdateAI(const uint32 diff)
            {
                if (Delay_Timer <= diff)
                {
                    Delay_Timer = 3500;

                    Creature* pLeftHead  = Creature::GetCreature(*me, LeftHeadGUID);
                    Creature* pRightHead = Creature::GetCreature(*me, RightHeadGUID);

                    if (!pLeftHead || !pRightHead)
                        return;

                    if (AggroYell)
                    {
                        pRightHead->AI()->Talk(GoCombatDelay[iaggro].id);
                        AggroYell = false;
                    }

                    if (ThreatYell2)
                    {
                        Creature* source = (pLeftHead->GetEntry() == ThreatDelay2[ithreat].creature ? pLeftHead : pRightHead);

                        source->AI()->Talk(ThreatDelay2[ithreat].id);
                        ThreatYell2 = false;
                    }

                    if (ThreatYell)
                    {
                        Creature* source = (pLeftHead->GetEntry() == ThreatDelay1[ithreat].creature ? pLeftHead : pRightHead);

                        source->AI()->Talk(ThreatDelay1[ithreat].id);
                        ThreatYell = false;
                        ThreatYell2 = true;
                    }

                    if (KillingYell)
                    {
                        Creature* source = (pLeftHead->GetEntry() == KillingDelay[ikilling].creature ? pLeftHead : pRightHead);

                        source->AI()->Talk(KillingDelay[ikilling].id);
                        KillingYell = false;
                    }
                } else Delay_Timer -= diff;

                if (!UpdateVictim())
                    return;

                if (BlastCount && BlastWave_Timer <= diff)
                {
                    DoCast(me, SPELL_BLAST_WAVE);
                    BlastWave_Timer = 5000;
                    ++BlastCount;

                    if (BlastCount == 3)
                        BlastCount = 0;
                }
                else
                    BlastWave_Timer -= diff;

                if (BurningMaul_Timer <= diff)
                {
                    Talk(EMOTE_ENRAGE);
                    DoCast(me, SPELL_BURNING_MAUL);
                    BurningMaul_Timer = 40000;
                    BlastWave_Timer = 16000;
                    BlastCount = 1;
                }
                else
                    BurningMaul_Timer -= diff;

                if (ResetThreat_Timer <= diff)
                {
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                    {
                        DoYellForThreat();
                        DoResetThreat();
                        me->AddThreat(target, 0.0f);
                    }
                    ResetThreat_Timer = 25000+rand()%15000;
                }
                else
                    ResetThreat_Timer -= diff;

                if (Fear_Timer <= diff)
                {
                    DoCast(me, SPELL_FEAR);
                    Fear_Timer = 15000+rand()%20000;
                }
                else
                    Fear_Timer -= diff;

                if (ThunderClap_Timer <= diff)
                {
                    DoCast(me, SPELL_THUNDERCLAP);
                    ThunderClap_Timer = 15000+rand()%15000;
                }
                else
                    ThunderClap_Timer -= diff;

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

            //ArcaneMissiles_Timer
            if (ArcaneMissiles_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_ARCANEMISSILES);
                ArcaneMissiles_Timer = 8000;
            } else ArcaneMissiles_Timer -= diff;

            //ShadowShield_Timer
            if (ShadowShield_Timer <= diff)
            {
                DoCast(me, SPELL_SHADOWSHIELD);
                ShadowShield_Timer = 14000 + rand()%14000;
            } else ShadowShield_Timer -= diff;

            //Curse_Timer
            if (Curse_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_CURSE);
                Curse_Timer = 15000 + rand()%12000;
            } else Curse_Timer -= diff;

            //Teleporting Random Target to one of the six pre boss rooms and spawn 3-4 skeletons near the gamer.
            //We will only telport if gandling has more than 3% of hp so teleported gamers can always loot.
            if (HealthAbovePct(3))
            {
                if (Teleport_Timer <= diff)
                {
                    Unit* target = NULL;
                    target = SelectTarget(SELECT_TARGET_RANDOM, 0);
                    if (target && target->GetTypeId() == TYPEID_PLAYER)
                    {
                        if (DoGetThreat(target))
                            DoModifyThreatPercent(target, -100);

                        Creature* Summoned = NULL;
                        switch (rand()%6)
                        {
                            case 0:
                                DoTeleportPlayer(target, 250.0696f, 0.3921f, 84.8408f, 3.149f);
                                Summoned = me->SummonCreature(16119, 254.2325f, 0.3417f, 84.8407f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 257.7133f, 4.0226f, 84.8407f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 258.6702f, -2.60656f, 84.8407f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                break;
                            case 1:
                                DoTeleportPlayer(target, 181.4220f, -91.9481f, 84.8410f, 1.608f);
                                Summoned = me->SummonCreature(16119, 184.0519f, -73.5649f, 84.8407f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 179.5951f, -73.7045f, 84.8407f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 180.6452f, -78.2143f, 84.8407f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 283.2274f, -78.1518f, 84.8407f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                break;
                            case 2:
                                DoTeleportPlayer(target, 95.1547f, -1.8173f, 85.2289f, 0.043f);
                                Summoned = me->SummonCreature(16119, 100.9404f, -1.8016f, 85.2289f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 101.3729f, 0.4882f, 85.2289f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 101.4596f, -4.4740f, 85.2289f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                break;
                            case 3:
                                DoTeleportPlayer(target, 250.0696f, 0.3921f, 72.6722f, 3.149f);
                                Summoned = me->SummonCreature(16119, 240.34481f, 0.7368f, 72.6722f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 240.3633f, -2.9520f, 72.6722f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 240.6702f, 3.34949f, 72.6722f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                break;
                            case 4:
                                DoTeleportPlayer(target, 181.4220f, -91.9481f, 70.7734f, 1.608f);
                                Summoned = me->SummonCreature(16119, 184.0519f, -73.5649f, 70.7734f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 179.5951f, -73.7045f, 70.7734f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 180.6452f, -78.2143f, 70.7734f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 283.2274f, -78.1518f, 70.7734f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                break;
                            case 5:
                                DoTeleportPlayer(target, 106.1541f, -1.8994f, 75.3663f, 0.043f);
                                Summoned = me->SummonCreature(16119, 115.3945f, -1.5555f, 75.3663f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 257.7133f, 1.8066f, 75.3663f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                Summoned = me->SummonCreature(16119, 258.6702f, -5.1001f, 75.3663f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                                if (Summoned)
                                    Summoned->AI()->AttackStart(target);
                                break;
                        }
                    }
                    Teleport_Timer = 20000 + rand()%15000;
                } else Teleport_Timer -= diff;
            }

            DoMeleeAttackIfReady();
        }
Exemple #6
0
    void UpdateAI(const uint32 diff)
    {
        //Sounds OOC, Kiljaeden Orders
        if(!m_creature->getVictim())
        {
            if(m_uiKJOrdersTimer < diff)
            {
                switch (rand()%5)
                {
                    case 0: DoPlaySoundToSet(m_creature, SAY_KJ_OFFCOMBAT1); break;
                    case 1: DoPlaySoundToSet(m_creature, SAY_KJ_OFFCOMBAT2); break;
                    case 2: DoPlaySoundToSet(m_creature, SAY_KJ_OFFCOMBAT3); break;
                    case 3: DoPlaySoundToSet(m_creature, SAY_KJ_OFFCOMBAT4); break;
                    case 4: DoPlaySoundToSet(m_creature, SAY_KJ_OFFCOMBAT5); break;
                }
                m_uiKJOrdersTimer = 60000;
            }else m_uiKJOrdersTimer -= diff;
        }

        //Rebirth After Phase1
        if(pInstance && pInstance->GetData(DATA_DECIVER) == SPECIAL)
        {
            m_creature->setFaction(14);
            m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            pInstance->SetData(DATA_KILJAEDEN_EVENT, IN_PROGRESS);
            pInstance->SetData(DATA_DECIVER, NOT_STARTED); 
        }

        if(!m_creature->SelectHostileTarget() || !m_creature->getVictim())
               return;

        //FireBloom Damage WorkArround
        if(m_uiFireBloomCheck < diff)
        {
            if(m_uiFireBloomCount < 10)
                for(uint8 i=0; i<5; ++i)
                {
                    if(Unit* FireTarget = Unit::GetUnit(*m_creature, m_uiFireBloomTarget[i]))
                        if(FireTarget->isAlive())
                            FireTarget->CastSpell(FireTarget, SPELL_FIREBLOOM_EFF, true);
                }
            ++m_uiFireBloomCount;
            m_uiFireBloomCheck = 2000;
        }else m_uiFireBloomCheck -= diff;

        if((m_uiOrbTimer < diff) && !m_bBoolOrb)
        {
            switch (rand()%4)
                {
                    case 0: DoPlaySoundToSet(m_creature, SAY_KALEC_ORB_READY1); break;
                    case 1: DoPlaySoundToSet(m_creature, SAY_KALEC_ORB_READY2); break;
                    case 2: DoPlaySoundToSet(m_creature, SAY_KALEC_ORB_READY3); break;
                    case 3: DoPlaySoundToSet(m_creature, SAY_KALEC_ORB_READY4); break;
                }
            uint8 m_uiMaxDragons = 1;
            if(m_bPhase5)
                m_uiMaxDragons = 4;
            for(uint8 i=0; i<m_uiMaxDragons; ++i)
            {
                Creature* Dragon = m_creature->SummonCreature(ID_DRAGON, m_creature->GetPositionX()+urand(20,35), m_creature->GetPositionY()+urand(20,35), m_creature->GetPositionZ()+1, 0, TEMPSUMMON_CORPSE_DESPAWN, 20000);
                m_uiDragonGUID[i] = Dragon->GetGUID();
            }
            m_bBoolOrb = true;
        }else m_uiOrbTimer -= diff;

        //Shield of Blue m_uiDragonGUID[i]
        for(uint8 i=0; i<4; ++i)
        {
            if(Unit* Dragon = Unit::GetUnit((*m_creature), m_uiDragonGUID[i]))
                if(Dragon && Dragon->HasAura(SPELL_SHIELD_OF_BLUE))
                {
                    m_uiCancelShieldTimer = 6000;
                    std::list<HostileReference *> t_list = m_creature->getThreatManager().getThreatList();
                    for(std::list<HostileReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                    {
                        Unit *TargetedPlayer = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());  
                        if (TargetedPlayer && TargetedPlayer->GetTypeId() == TYPEID_PLAYER && TargetedPlayer->IsWithinDistInMap(Dragon, 15) && !TargetedPlayer->HasAura(AURA_BLUESHIELD))
                            TargetedPlayer->CastSpell(TargetedPlayer,AURA_BLUESHIELD,true);
                    }
                }
        }

        if(m_uiCancelShieldTimer < 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 *ShieldedPlayer1 = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                if (ShieldedPlayer1 && ShieldedPlayer1->GetTypeId() == TYPEID_PLAYER && ShieldedPlayer1->HasAura(AURA_BLUESHIELD))
                {
                    ShieldedPlayer1->RemoveAurasDueToSpell(AURA_BLUESHIELD);
                } 
            }
            m_uiCancelShieldTimer = 300000;
        }else m_uiCancelShieldTimer -= diff;

        //Kalecgos and Anvena Event
        if((m_uiKalecgosAnvenaTimer < diff) && m_bIsAnvena)
        {
            switch(m_uiKalecgosAnvenaCount)
            {
                case 0:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_AWAKEN); m_uiKalecgosAnvenaTimer = 5000; break;
                case 1:
                DoPlaySoundToSet(m_creature, SAY_ANVEENA_IMPRISONED); m_uiKalecgosAnvenaTimer = 3000; break;
                case 2:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_LETGO); m_uiKalecgosAnvenaTimer = 6000; break;
                case 5:
                DoPlaySoundToSet(m_creature, SAY_ANVEENA_LOST); m_uiKalecgosAnvenaTimer = 4000; break;
                case 4:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_FOCUS); m_uiKalecgosAnvenaTimer = 8000; break;
                case 3:
                DoPlaySoundToSet(m_creature, SAY_ANVEENA_KALEC); m_uiKalecgosAnvenaTimer = 5000; break;
                case 6:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_FATE); m_uiKalecgosAnvenaTimer = 5000; break;
                case 7:
                DoPlaySoundToSet(m_creature, SAY_ANVEENA_GOODBYE); 
                m_creature->CastSpell(m_creature, SPELL_SACRIFICE_OF_ANVEENA, false);
                if(Unit* Anveena = Unit::GetUnit((*m_creature), m_uiAnveenaGUID))
                    if(Anveena && Anveena->isAlive())
                        Anveena->SetVisibility(VISIBILITY_OFF);
                m_uiKalecgosAnvenaTimer = 5000;
                break;
                case 9:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_GOODBYE); ; m_bIsAnvena = false; break;
                case 8:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_ENCOURAGE); m_uiKalecgosAnvenaTimer = 14000; break;         
            }
            ++m_uiKalecgosAnvenaCount;
        }m_uiKalecgosAnvenaTimer -= diff;

        //Kalecgos Event
        if((m_uiKalecgosTimer < diff) && !m_bIsKalecgosSpawned)
        {
            DoPlaySoundToSet(m_creature, SAY_KALECGOS_JOIN);
            float x, y, z;
            m_creature->GetClosePoint(x, y, z, m_creature->GetObjectBoundingRadius(), 15.0f, urand(0, 6));
            if(Creature* cKalecgos = m_creature->SummonCreature(ID_KALECGOS, x, y, z, 0.686f, TEMPSUMMON_TIMED_DESPAWN, 600000))
            {
                m_uiKalecgosGUID = cKalecgos->GetGUID();
                cKalecgos->setFaction(35);
                cKalecgos->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            //Kalecgos need to start shhooting arcane bolt into Kiljaeden
            //Dragon->AI()->AttackStart(m_creature);
            }
            m_bIsKalecgosSpawned = true;
        }m_uiKalecgosTimer -= diff;

        //Shield Orb At Start each phases
        if(m_uiShieldOrbTimer < diff && !m_bPhase5)
        {
            uint8 l=1;
            if(m_bPhase3)
                l=2;
            if(m_bPhase4)
                l=3;
            for(uint8 k=0; k<l; ++k)
            {
                Creature* ShieldOrb = m_creature->SummonCreature(ID_SHIELDORB, m_creature->GetPositionX()+urand(1,15), m_creature->GetPositionY()+urand(1,15), m_creature->GetPositionZ()+10, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if(ShieldOrb)
                    ShieldOrb->AI()->AttackStart(m_creature->getVictim()); 
            }
            m_uiShieldOrbTimer = 50000; 
        }else m_uiShieldOrbTimer -= diff;

        //Sinister Reflects Attack
        if(m_uiSinnisterCastTimer < diff)
        {
            uint8 m_uiSinisterCount = 0;
            if(m_bPhase3)
                m_uiSinisterCount = 4;
            if(m_bPhase4)
                m_uiSinisterCount = 8;
            if(m_bPhase5)
                m_uiSinisterCount = 12;
            for(uint8 i=0; i<m_uiSinisterCount; ++i)
                if(Unit* Sinister = Unit::GetUnit((*m_creature), m_uiSinisterGUID[i][0]))
                    if(Sinister->isAlive())
                        if(Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                            Sinister->CastSpell(target, m_uiSinisterGUID[i][1], true);

            m_uiSinnisterCastTimer = urand(8000,16000);
        }else m_uiSinnisterCastTimer -= diff;

        //Phase4
        if((m_uiAramageddonTimer < diff) && m_bPhase4)
        {
            uint8 h=3;
            if(m_bPhase5)
                h=5;
            if(!m_bPhase5 && m_bDarknessOfSoulsCasting)
                h=0;
            
            for(uint8 i=0; i<h; ++i)
                if(Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                    m_creature->SummonCreature(ID_ARMAGEDON, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 15000);

            m_uiAramageddonTimer = urand(20000,30000);
        }else m_uiAramageddonTimer -= diff;

        //ShadowSpike Explosions
        if((m_uiShadowSpikeEndsTimer < diff) && m_bShadowSpikeEnds && m_bPhase3)
        {
            if(Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
            {
                if(Creature* cShadowSpike = m_creature->SummonCreature(ID_SHADOWSPIKE, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 6000))
                {
                    cShadowSpike->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    cShadowSpike->setFaction(14);
                }
                //target->CastSpell(target, SPELL_SHADOWSPIKE_EXP, false);
            }
            ++m_uiSpikesCount;
            if(m_uiSpikesCount > 9)
                m_bShadowSpikeEnds = false;
            m_uiShadowSpikeEndsTimer = 3000;
        }else m_uiShadowSpikeEndsTimer -= diff;

        if(m_bShadowSpikeEnds)
            return;

        if(m_uiDarknessExplosionTimer < diff && m_bDarknessOfSoulsCasting)
        {
            //m_creature->CastSpell(m_creature->getVictim(), SPELL_DARKNESS_EXPLOSION, true);
            m_bDarknessOfSoulsCasting = false;
            m_uiDarknessExplosionTimer = 600000;
            m_uiDarknessOfSoulsTimer = 60000;
            m_uiFireBloomTimer = 25000;
            if(m_bPhase5)
                m_uiDarknessOfSoulsTimer = 35000;
        }else m_uiDarknessExplosionTimer -= diff;

        if(m_bDarknessOfSoulsCasting)
            return;

        if(m_uiDarknessOfSoulsTimer < diff && m_bPhase3)
        {
            switch (rand()%3)
                {
                    case 0: DoPlaySoundToSet(m_creature, SAY_KJ_DARKNESS1); break;
                    case 1: DoPlaySoundToSet(m_creature, SAY_KJ_DARKNESS2); break;
                    case 2: DoPlaySoundToSet(m_creature, SAY_KJ_DARKNESS3); break;
                }
            m_creature->CastSpell(m_creature, SPELL_DARKNESS_OF_SOULS, false);
            m_bDarknessOfSoulsCasting = true;
            m_uiDarknessExplosionTimer = 8000;
        }else m_uiDarknessOfSoulsTimer -= diff;

        //Phases
        if ((m_creature->GetHealthPercent() <= 85) && !m_bPhase3)
        {      
            DoPlaySoundToSet(m_creature, SAY_KJ_PHASE3);
            if (Unit* pVictim = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                if (pVictim && (pVictim->GetTypeId() == TYPEID_PLAYER))
                    Sinister(((Player*)pVictim),0,4);

            //Start Timerow  Dochodzacych w 3 Fazie
            m_uiFlameDartTimer         = 20000;
            m_uiSinnisterCastTimer     = 10000;
            m_uiShadowSpikeTimer       = 30000;
            m_uiFlameDartTimer         = 40000;
            m_uiDarknessOfSoulsTimer   = 60000;
            m_bShadowSpikeEnds         = false;
            m_bDarknessOfSoulsCasting  = false;
            m_bPhase3 = true;
            //DragonsTimer
            m_uiOrbTimer = 35000;
            m_bBoolOrb = false;
        }

        if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 55) && !m_bPhase4)
        {
            DoPlaySoundToSet(m_creature, SAY_KJ_PHASE4);
            if(Unit* pVictim = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                if (pVictim && (pVictim->GetTypeId() == TYPEID_PLAYER))
                    Sinister(((Player*)pVictim),4,8);

            //Start Timerow  Dochodzacych w 4 Fazie
            m_uiFlameDartTimer         = 20000;
            m_uiAramageddonTimer       = 2000;  //100% ok
            m_bPhase4 = true;
            m_uiDarknessOfSoulsTimer   = 60000;
            //DragonsTimer
            m_uiOrbTimer = 35000;
            m_bBoolOrb = false;
        }

        if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 25) && !m_bPhase5)
        {
            DoPlaySoundToSet(m_creature, SAY_KJ_PHASE5);
            if(Unit* pVictim = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                if (pVictim && (pVictim->GetTypeId() == TYPEID_PLAYER))
                    Sinister(((Player*)pVictim),8,12);
            //Start Timerow  Dochodzacych w 5 Fazie
            m_uiAramageddonTimer = urand(20000,30000);
            m_uiFlameDartTimer = 20000;
            m_uiShadowSpikeTimer = 1000;
            m_uiDarknessOfSoulsTimer   = 60000;
            m_bPhase5 = true;
            //DragonsTimer
            m_uiOrbTimer = 35000;
            m_bBoolOrb = false;
            //Kalecgos and Anvena Event
            m_uiKalecgosAnvenaTimer = 20000;
            m_bIsAnvena = true;
            m_uiKalecgosAnvenaCount = 0;

            if(Creature* cAnveena = m_creature->SummonCreature(ID_ANVEENA, m_creature->GetPositionX()+urand(20,30), m_creature->GetPositionY()+urand(20,30), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 120000))
            {
                m_uiAnveenaGUID = cAnveena->GetGUID();
                cAnveena->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                cAnveena->setFaction(35);
            }
        }

        //Phase3
        if(m_bPhase3)
        {
            if(m_uiShadowSpikeTimer < diff)
            {
                //DoCast(m_creature->getVictim(), SPELL_SHADOWSPIKE);
                m_bShadowSpikeEnds         = true;
                m_uiShadowSpikeEndsTimer    = 500;
                m_uiSpikesCount             = 0;
                m_uiShadowSpikeTimer        = urand(65000,95000);
            }else m_uiShadowSpikeTimer -= diff;

            if(m_uiFlameDartTimer < diff)
            {
                DoCast(m_creature->getVictim(), SPELL_FLAMEDARTS);
                m_uiFlameDartTimer = urand(41000,63000);
            }else m_uiFlameDartTimer -= diff;
        }

        //Phase2
        if(m_uiLegionLightingTimer < diff)
        {
            DoCast(m_creature->getVictim(), SPELL_LEGION_LIGHTING);
            m_uiLegionLightingTimer = urand(18000,26000);
        }else m_uiLegionLightingTimer -= diff;

        if(m_uiFireBloomTimer < diff)
        {
            for(uint8 i=0; i<5; ++i)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                    m_uiFireBloomTarget[i] = pTarget->GetGUID();
                m_uiFireBloomCount = 0;
                //DoCast(target, SPELL_FIREBLOOM, true);
            }
            m_uiFireBloomTimer = urand(34000,56000);
        }else m_uiFireBloomTimer -= diff;

        if(m_uiSoulFlyTimer < diff)
        {
            DoCast(m_creature->getVictim(), SPELL_SOULFLY);
            m_uiSoulFlyTimer = 7000;
        }else m_uiSoulFlyTimer -= diff;

        DoMeleeAttackIfReady();
    }
Exemple #7
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (m_uiAnimalCounter)
        {
            if(m_uiAnimalCheck_Timer < uiDiff)
            {
            	Creature* pTemp = NULL;

                if (m_uiAnimalCounter == 1)
                	pTemp = (Creature*)Unit::GetUnit(*m_creature, m_pInstance->GetData64(DATA_MOB_FRENZIED_WORGEN));
                if (m_uiAnimalCounter == 2)
                	pTemp = (Creature*)Unit::GetUnit(*m_creature, m_pInstance->GetData64(DATA_MOB_RAVENOUS_FURBOLG));
                if (m_uiAnimalCounter == 3)
                	pTemp = (Creature*)Unit::GetUnit(*m_creature, m_pInstance->GetData64(DATA_MOB_MASSIVE_JORMUNGAR));
                if (m_uiAnimalCounter == 4)
                	pTemp = (Creature*)Unit::GetUnit(*m_creature, m_pInstance->GetData64(DATA_MOB_FEROCIOUS_RHINO));

                if (pTemp)
                {
                    if (!pTemp->isAlive())
                        m_uiAnimalCounter++;
                    if (pTemp->isAlive() && !pTemp->getVictim())
                    {
                        if (pTemp->HasAura(SPELL_FREEZE_ANIM, 0))
                            pTemp->RemoveAurasDueToSpell(SPELL_FREEZE_ANIM);
                        pTemp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        pTemp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                        ((Unit*)pTemp)->SetStandState(UNIT_STAND_STATE_STAND);
                        pTemp->SetInCombatWithZone();
                        pTemp->AI()->AttackStart(pPlayer);
                    }
                }

                if (m_uiAnimalCounter == 5)
                {
                    if (m_creature->HasAura(SPELL_FREEZE_ANIM, 0))
                        m_creature->RemoveAurasDueToSpell(SPELL_FREEZE_ANIM);
                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    ((Unit*)m_creature)->SetStandState(UNIT_STAND_STATE_STAND);
                    m_uiAnimalCheck_Timer = 10000000;
                    AttackStart(pPlayer);
                }
                else
                {
                    m_uiAnimalCheck_Timer = 1000;
                    return;
                }
            }else m_uiAnimalCheck_Timer -= uiDiff;
        }

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

        // Withering Roar
        if(m_uiWitheringRoar_Timer < uiDiff)
        {
            DoCast(m_creature, m_bIsHeroic ? SPELL_WITHERING_ROAR_H : SPELL_WITHERING_ROAR_N);
            m_uiWitheringRoar_Timer = 8000 + rand()%4000;
        }else m_uiWitheringRoar_Timer -= uiDiff;

        // Impale
        if(m_uiImpale_Timer < uiDiff)
        {
            DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), m_bIsHeroic ? SPELL_IMPALE_H : SPELL_IMPALE_N);
            m_uiImpale_Timer = 8000 + rand()%4000;
        }else m_uiImpale_Timer -= uiDiff;

        // Arcing Smash
        if(m_uiArcingSmash_Timer < uiDiff)
        {
            DoCast(m_creature, SPELL_ARCING_SMASH);
            m_uiArcingSmash_Timer = 13000 + rand()%4000;
        }else m_uiArcingSmash_Timer -= uiDiff;

        DoMeleeAttackIfReady();
    }
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            //Only do this if we haven't spawned nef yet
            if (SpawnedAdds < 42)
            {
                //ShadowBoltTimer
                if (ShadowBoltTimer <= diff)
                {
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                        DoCast(target, SPELL_SHADOWBOLT);

                    ShadowBoltTimer = urand(3000, 10000);
                } else ShadowBoltTimer -= diff;

                //FearTimer
                if (FearTimer <= diff)
                {
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                        DoCast(target, SPELL_FEAR);

                    FearTimer = 10000 + (rand()%10000);
                } else FearTimer -= diff;

                //Add spawning mechanism
                if (AddSpawnTimer <= diff)
                {
                    //Spawn 2 random types of creatures at the 2 locations
                    uint32 CreatureID;
                    Creature* Spawned = NULL;
                    Unit* target = NULL;

                    //1 in 3 chance it will be a chromatic
                    if (urand(0, 2) == 0)
                        CreatureID = CREATURE_CHROMATIC_DRAKANOID;
                    else
                        CreatureID = DrakType1;

                    ++SpawnedAdds;

                    //Spawn Creature and force it to start attacking a random target
                    Spawned = me->SummonCreature(CreatureID, ADD_X1, ADD_Y1, ADD_Z1, 5.000f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                    if (target && Spawned)
                    {
                        Spawned->AI()->AttackStart(target);
                        Spawned->setFaction(103);
                    }

                    //1 in 3 chance it will be a chromatic
                    if (urand(0, 2) == 0)
                        CreatureID = CREATURE_CHROMATIC_DRAKANOID;
                    else
                        CreatureID = DrakType2;

                    ++SpawnedAdds;

                    Spawned = me->SummonCreature(CreatureID, ADD_X2, ADD_Y2, ADD_Z2, 5.000f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                    if (target && Spawned)
                    {
                        Spawned->AI()->AttackStart(target);
                        Spawned->setFaction(103);
                    }

                    //Begin phase 2 by spawning Nefarian and what not
                    if (SpawnedAdds >= 42)
                    {
                        //Teleport Victor Nefarius way out of the map
                        //sMapMgr->GetMap(me->GetMapId(), me)->CreatureRelocation(me, 0, 0, -5000, 0);

                        //Interrupt any spell casting
                        me->InterruptNonMeleeSpells(false);

                        //Root self
                        DoCast(me, 33356);

                        //Make super invis
                        DoCast(me, 8149);

                        //Teleport self to a hiding spot (this causes errors in the Trillium log but no real issues)
                        DoTeleportTo(HIDE_X, HIDE_Y, HIDE_Z);
                        me->AddUnitState(UNIT_STAT_FLEEING);

                        //Spawn nef and have him attack a random target
                        Creature* Nefarian = me->SummonCreature(CREATURE_NEFARIAN, NEF_X, NEF_Y, NEF_Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
                        target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                        if (target && Nefarian)
                        {
                            Nefarian->AI()->AttackStart(target);
                            Nefarian->setFaction(103);
                            NefarianGUID = Nefarian->GetGUID();
                        }
                        else sLog->outError("TSCR: Blackwing Lair: Unable to spawn nefarian properly.");
                    }

                    AddSpawnTimer = 4000;
                } else AddSpawnTimer -= diff;
            }
            else if (NefarianGUID)
            {
                if (NefCheckTime <= diff)
                {
                    Unit* Nefarian = Unit::GetCreature((*me), NefarianGUID);

                    //If nef is dead then we die to so the players get out of combat
                    //and cannot repeat the event
                    if (!Nefarian || !Nefarian->isAlive())
                    {
                        NefarianGUID = 0;
                        me->DespawnOrUnsummon();
                    }

                    NefCheckTime = 2000;
                } else NefCheckTime -= diff;
            }
        }
Exemple #9
0
 void HandleFlightSequence()
 {
     switch(FlightCount)
     {
     case 0:
         m_creature->AttackStop();
         m_creature->GetMotionMaster()->Clear(false);
         m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
         m_creature->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING + MOVEMENTFLAG_ONTRANSPORT);
         m_creature->StopMoving();
         DoYell(YELL_TAKEOFF, LANG_UNIVERSAL, NULL);
         DoPlaySoundToSet(m_creature, SOUND_TAKEOFF);
         Timer[EVENT_FLIGHT_SEQUENCE] = 2000;
         break;
     case 1:
         m_creature->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX()+1, m_creature->GetPositionY(), m_creature->GetPositionZ()+10);
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 2:
         if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
         {
             Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
             if(Vapor)
             {
                 Vapor->AI()->AttackStart(target);
                 m_creature->InterruptNonMeleeSpells(false);
                 m_creature->CastSpell(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug
                 Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true);
             }
         }else EnterEvadeMode();
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;
     case 3:
         DespawnSummons(MOB_VAPOR_TRAIL);
         //m_creature->CastSpell(m_creature, SPELL_VAPOR_SELECT); need core support
         if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
         {
             //target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support
             Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
             if(Vapor)
             {
                 Vapor->AI()->AttackStart(target);
                 m_creature->InterruptNonMeleeSpells(false);
                 m_creature->CastSpell(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug
                 Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true);
             }
         }else EnterEvadeMode();
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;
     case 4:
         DespawnSummons(MOB_VAPOR_TRAIL);
         Timer[EVENT_FLIGHT_SEQUENCE] = 1;
         break;
     case 5:
         if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
         {
             BreathX = target->GetPositionX();
             BreathY = target->GetPositionY();
             float x, y, z;
             target->GetContactPoint(m_creature, x, y, z, 70);
             m_creature->GetMotionMaster()->MovePoint(0, x, y, z+10);
         }else EnterEvadeMode();
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 6:
         m_creature->SetOrientation(m_creature->GetAngle(BreathX, BreathY));
         m_creature->StopMoving();
         DoTextEmote("takes a deep breath.", NULL);
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;
     case 7:
         m_creature->CastSpell(m_creature, SPELL_FOG_BREATH, true);
         {
             float x, y, z;
             m_creature->GetPosition(x, y, z);
             x = 2 * BreathX - x;
             y = 2 * BreathY - y;
             m_creature->GetMotionMaster()->MovePoint(0, x, y, z);
         }
         Timer[EVENT_SUMMON_FOG] = 1;
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 8:
         m_creature->RemoveAurasDueToSpell(SPELL_FOG_BREATH);
         BreathCount++;
         Timer[EVENT_SUMMON_FOG] = 0;
         Timer[EVENT_FLIGHT_SEQUENCE] = 1;
         if(BreathCount < 3) FlightCount = 4;
         break;
     case 9:
         if(Unit* target = SelectUnit(SELECT_TARGET_TOPAGGRO, 0))
         {
             float x, y, z;
             target->GetContactPoint(m_creature, x, y, z);
             m_creature->GetMotionMaster()->MovePoint(0, x, y, z);
         }else EnterEvadeMode();
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 10:
         m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING + MOVEMENTFLAG_ONTRANSPORT);
         m_creature->StopMoving();
         m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
         EnterPhase(PHASE_GROUND);
         m_creature->AI()->AttackStart(SelectUnit(SELECT_TARGET_TOPAGGRO, 0));
         break;
     default:
         break;
     }
     FlightCount++;
 }
Exemple #10
0
 void HandleFlightSequence()
 {
     switch(FlightCount)
     {
     case 0:
         //m_creature->AttackStop();
         error_log("prevent fly phase");
         m_creature->GetMotionMaster()->Clear(false);
         m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
         m_creature->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING);
         m_creature->StopMoving();
         DoScriptText(YELL_TAKEOFF, m_creature);
         Timer[EVENT_FLIGHT_SEQUENCE] = 2000;
         break;
     case 1:
         error_log("Move to Fly point");
         m_creature->GetMotionMaster()->MovePoint(0, m_creature->GetPositionX()+1, m_creature->GetPositionY(), m_creature->GetPositionZ()+10);
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 2:{
         error_log("Summon Vapor case 2");
         Unit *pTarget;
         pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
         if (!pTarget) pTarget = Unit::GetUnit(*m_creature, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);
         if (pTarget)
         {
             Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, pTarget->GetPositionX()-5+rand()%10, pTarget->GetPositionY()-5+rand()%10, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
             if (Vapor)
             {
                 Vapor->AI()->AttackStart(pTarget);
                 m_creature->InterruptNonMeleeSpells(false);
                 m_creature->CastSpell(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug
                 Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true);
             }
         }
         else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;}
     case 3: {
         DespawnSummons(MOB_VAPOR_TRAIL);
         error_log("Summon Vapor case3");
         //m_creature->CastSpell(m_creature, SPELL_VAPOR_SELECT); need core support
         Unit *pTarget;
         pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
         if (!pTarget) pTarget = Unit::GetUnit(*m_creature, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);
         if (pTarget)
         {
             //pTarget->CastSpell(pTarget, SPELL_VAPOR_SUMMON, true); need core support
             Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, pTarget->GetPositionX()-5+rand()%10, pTarget->GetPositionY()-5+rand()%10, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
             if (Vapor)
             {
                 Vapor->AI()->AttackStart(pTarget);
                 m_creature->InterruptNonMeleeSpells(false);
                 m_creature->CastSpell(Vapor, SPELL_VAPOR_CHANNEL, false); // core bug
                 Vapor->CastSpell(Vapor, SPELL_VAPOR_TRIGGER, true);
             }
         }
         else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;}
     case 4:
         DespawnSummons(MOB_VAPOR_TRAIL);
         Timer[EVENT_FLIGHT_SEQUENCE] = 1;
         break;
     case 5:{
         Unit *pTarget;
         pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 150, true);
         if (!pTarget) pTarget = Unit::GetUnit(*m_creature, pInstance ? pInstance->GetData64(DATA_PLAYER_GUID) : 0);
         if (pTarget)
         {
             BreathX = pTarget->GetPositionX();
             BreathY = pTarget->GetPositionY();
             float x, y, z;
             pTarget->GetContactPoint(m_creature, x, y, z, 70);
             m_creature->GetMotionMaster()->MovePoint(0, x, y, z+10);
         }else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;}
     case 6:
         m_creature->SetOrientation(m_creature->GetAngle(BreathX, BreathY));
         m_creature->StopMoving();
         //DoTextEmote("takes a deep breath.", NULL);
         Timer[EVENT_FLIGHT_SEQUENCE] = 10000;
         break;
     case 7:
         m_creature->CastSpell(m_creature, SPELL_FOG_BREATH, true);
         {
             float x, y, z;
             m_creature->GetPosition(x, y, z);
             x = 2 * BreathX - x;
             y = 2 * BreathY - y;
             m_creature->GetMotionMaster()->MovePoint(0, x, y, z);
         }
         Timer[EVENT_SUMMON_FOG] = 1;
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 8:
         m_creature->RemoveAurasDueToSpell(SPELL_FOG_BREATH);
         ++BreathCount;
         Timer[EVENT_SUMMON_FOG] = 0;
         Timer[EVENT_FLIGHT_SEQUENCE] = 1;
         if (BreathCount < 3) FlightCount = 4;
         break;
     case 9:
         if (Unit *pTarget = SelectUnit(SELECT_TARGET_TOPAGGRO, 0))
         {
             float x, y, z;
             pTarget->GetContactPoint(m_creature, x, y, z);
             m_creature->GetMotionMaster()->MovePoint(0, x, y, z);
         }
         else
         {
             EnterEvadeMode();
             return;
         }
         Timer[EVENT_FLIGHT_SEQUENCE] = 0;
         break;
     case 10:
         m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
         m_creature->StopMoving();
         m_creature->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
         EnterPhase(PHASE_GROUND);
         m_creature->AI()->AttackStart(SelectUnit(SELECT_TARGET_TOPAGGRO, 0));
         break;
     default:
         break;
     }
     ++FlightCount;
 }
/*
Tribute Event
*/
void instance_dire_maul::GordokTributeEvent(uint32 diff)
{
	if(1<2)return;
	Creature* pChoRush = instance->GetCreature(m_uiChoRushGUID);
	Creature* pMizzle = instance->GetCreature(m_uiMizzleGUID);
	Creature* pTrigger = instance->GetCreature(m_uiTributeTriggerGUID);

	Map* pMap;
	pMap = pChoRush->GetMap();

	Map::PlayerList const &PlayerList = pMap->GetPlayers();

	if ((GetData(TYPE_KING_GORDOK) == DONE) && pMap->GetCreature(m_uiChoRushGUID)->isAlive() && !pChoRushHome)
	{
		pChoRush->SetFlag(UNIT_NPC_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PASSIVE);
		pChoRush->setFaction(35);
		pChoRush->DeleteThreatList();
		pChoRush->CombatStop();
		pChoRush->SetCanAttackPlayer(false);
		pChoRush->AI()->EnterEvadeMode();

		pChoRushHome = true;
		GossipStepGordok = 1;
		Text_Timer_Event = 1000;
	}
	else if ((TYPE_KING_GORDOK == DONE) && pMap->GetCreature(m_uiChoRushGUID)->isDead())
	{
		for(Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
		{
			Player* pPlayer = itr->getSource();
			if (pPlayer->IsWithinDistInMap(pTrigger, 30.0f))
					pTrigger->CastSpell(pPlayer, SPELL_KING_OF_GORDOK, false);
		}
	}

	if(pChoRushHome)
	{
		if (Text_Timer_Event<diff)
		{
			switch (GossipStepGordok)
			{
				case 1:
				DoScriptText(ChoRush_SAY_1, pChoRush);
				pChoRush->HandleEmote(EMOTE_STATE_TALK);
				pChoRush->SummonCreature(NPC_MIZZLE_THE_CRAFTY, 817.666f, 478.371f, 37.3182f, 3.07057f, TEMPSUMMON_TIMED_DESPAWN, 9000000);
				Text_Timer_Event = 5000;
				break;

				case 2:
				pChoRush->HandleEmote(EMOTE_STATE_SIT);
				DoScriptText(Mizzle_SAY_1, pMizzle);
				pMizzle->HandleEmote(EMOTE_STATE_TALK);
				Text_Timer_Event = 5000;
				break;

				case 3:
				DoScriptText(Mizzle_SAY_2, pMizzle);
				pMizzle->HandleEmote(EMOTE_STATE_TALK);
				Text_Timer_Event = 8000;
				break;

				case 4:
				for(Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
				{
					Player* pPlayer = itr->getSource();
					if (pPlayer->IsWithinDistInMap(pMizzle, 50.0f))
							pMizzle->CastSpell(pPlayer, SPELL_KING_OF_GORDOK, false);
				}
				if (pMap->GetCreature(m_uiMoldarGUID)->isAlive() && pMap->GetCreature(m_uiMizzleGUID)->isAlive() && pMap->GetCreature(m_uiFengusGUID)->isAlive())
				{
					pMizzle->SummonObject(pMap, GO_GORDOK_TRIBUTE, 809.899719f, 482.306366f, 37.318359f, 0.212846f);
					pMizzle->HandleEmote(EMOTE_ONESHOT_APPLAUD);
				}
				pChoRushHome = false;
				break;
			}
		}
		else Text_Timer_Event -= diff;
	}
}
Exemple #12
0
    void 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->SetVisibility(VISIBILITY_ON);
                }
                Midnight = 0;
                me->SetVisibility(VISIBILITY_OFF);
                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) && pTarget->GetTypeId() == TYPEID_PLAYER)
                        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 ((me->GetHealth()*100)/me->GetMaxHealth() < 25)
            {
                Creature *pMidnight = Unit::GetCreature(*me, Midnight);
                if (pMidnight && pMidnight->GetTypeId() == TYPEID_UNIT)
                {
                    CAST_AI(boss_midnightAI, (pMidnight->AI()))->Mount(me);
                    me->SetHealth(pMidnight->GetHealth());
                }
            }
        }

        DoMeleeAttackIfReady();
    }
   	void SummonAttacker(uint32 entry, float x, float y, float z)
	{
		Creature* Summoned = m_creature->SummonCreature(entry, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 20000);
        if (Summoned && EventStarter)
            ((CreatureAI*)Summoned->AI())->AttackStart(EventStarter);
    }
Exemple #14
0
    void UpdateAI(const uint32 diff)
    {
        //Check if we have a target
        if (!UpdateVictim())
            return;

        //No instance
        if (!pInst)
            return;

        switch (pInst->GetData(DATA_CTHUN_PHASE))
        {
            case 0:
            {
                //BeamTimer
                if (BeamTimer <= diff)
                {
                    //SPELL_GREEN_BEAM
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM,0);
                    if (pTarget)
                    {
                        m_creature->InterruptNonMeleeSpells(false);
                        DoCast(pTarget,SPELL_GREEN_BEAM);

                        //Correctly update our target
                        m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pTarget->GetGUID());
                    }

                    //Beam every 3 seconds
                    BeamTimer = 3000;
                } else BeamTimer -= diff;

                //ClawTentacleTimer
                if (ClawTentacleTimer <= diff)
                {
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM,0);
                    if (pTarget)
                    {
                        Creature* Spawned = NULL;

                        //Spawn claw tentacle on the random target
                        Spawned = me->SummonCreature(MOB_CLAW_TENTACLE,pTarget->GetPositionX(),pTarget->GetPositionY(),pTarget->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500);

                        if (Spawned)
                            Spawned->AI()->AttackStart(pTarget);
                    }

                    //One claw tentacle every 12.5 seconds
                    ClawTentacleTimer = 12500;
                } else ClawTentacleTimer -= diff;

                //EyeTentacleTimer
                if (EyeTentacleTimer <= diff)
                {
                    //Spawn the 8 Eye Tentacles in the corret spots
                    SpawnEyeTentacle(0, 20);                //south
                    SpawnEyeTentacle(10, 10);               //south west
                    SpawnEyeTentacle(20, 0);                //west
                    SpawnEyeTentacle(10, -10);              //north west

                    SpawnEyeTentacle(0, -20);               //north
                    SpawnEyeTentacle(-10, -10);             //north east
                    SpawnEyeTentacle(-20, 0);               // east
                    SpawnEyeTentacle(-10, 10);              // south east

                    //No point actually putting a timer here since
                    //These shouldn't trigger agian until after phase shifts
                    EyeTentacleTimer = 45000;
                } else EyeTentacleTimer -= diff;

                //PhaseTimer
                if (PhaseTimer <= diff)
                {
                    //Switch to Dark Beam
                    pInst->SetData(DATA_CTHUN_PHASE, 1);

                    m_creature->InterruptNonMeleeSpells(false);

                    //Select random target for dark beam to start on
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM,0);

                    if (pTarget)
                    {
                        //Correctly update our target
                        m_creature->SetUInt64Value(UNIT_FIELD_TARGET, pTarget->GetGUID());

                        //Face our target
                        DarkGlareAngle = m_creature->GetAngle(pTarget);
                        DarkGlareTickTimer = 1000;
                        DarkGlareTick = 0;
                        ClockWise = rand()%2;
                    }

                    //Add red coloration to C'thun
                    DoCast(m_creature,SPELL_RED_COLORATION);

                    //Freeze animation

                    //Darkbeam for 35 seconds
                    PhaseTimer = 35000;
                } else PhaseTimer -= diff;

            }
            break;
            case 1:
            {
                //EyeTentacleTimer
                if (DarkGlareTick < 35)
                    if (DarkGlareTickTimer <= diff)
                    {
                        //Remove any target
                        m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0);

                        //Set angle and cast
                        if (ClockWise)
                            m_creature->SetOrientation(DarkGlareAngle + ((float)DarkGlareTick*PI/35));
                        else
                            m_creature->SetOrientation(DarkGlareAngle - ((float)DarkGlareTick*PI/35));

                        m_creature->StopMoving();

                        //Actual dark glare cast, maybe something missing here?
                        m_creature->CastSpell(m_creature, SPELL_DARK_GLARE, false);

                        //Increase tick
                        ++DarkGlareTick;

                        //1 second per tick
                        DarkGlareTickTimer = 1000;
                    } else DarkGlareTickTimer -= diff;

                //PhaseTimer
                if (PhaseTimer <= diff)
                {
                    //Switch to Eye Beam
                    pInst->SetData(DATA_CTHUN_PHASE, 0);

                    BeamTimer = 3000;
                    EyeTentacleTimer = 45000;               //Always spawns 5 seconds before Dark Beam
                    ClawTentacleTimer = 12500;              //4 per Eye beam phase (unsure if they spawn durring Dark beam)

                    m_creature->InterruptNonMeleeSpells(false);

                    //Remove Red coloration from c'thun
                    m_creature->RemoveAurasDueToSpell(SPELL_RED_COLORATION);

                    //Freeze animation
                    m_creature->SetUInt32Value(UNIT_FIELD_FLAGS, 0);

                    //Eye Beam for 50 seconds
                    PhaseTimer = 50000;
                } else PhaseTimer -= diff;
            }
            break;

            //Transition phase
            case 2:
            {
                //Remove any target
                m_creature->SetUInt64Value(UNIT_FIELD_TARGET, 0);
                m_creature->SetHealth(0);
            }

            //Dead phase
            case 5:
            {
                m_creature->Kill(m_creature);
            }
        }
    }
	void UpdateAI(const uint32 diff)
	{
		if (!UpdateVictim())
			return;

		if (SummonKilrekTimer <= diff && SummonedKilrek == false)
		{
			Creature* Kilrek = me->SummonCreature(CREATURE_KILREK, -11237.955078, -1693.597412, 179.237823, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 15000);
			if (Kilrek)
			{
				Kilrek->SetReactState(REACT_AGGRESSIVE);
				Kilrek->AddThreat(me->GetVictim(), 1.0f);
				Kilrek->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 1));
				SummonedKilrek = true;
			}			
		}
		else SummonKilrekTimer -= diff;

		if (ReSummonKilrek_Timer <= diff && SummonedKilrek == true && ReSummonedKilrek == false)
		{
			if (me->HasAura(SPELL_BROKEN_PACT, 0))
				me->RemoveAurasDueToSpell(SPELL_BROKEN_PACT);

			Creature* Kilrek = me->SummonCreature(CREATURE_KILREK, -11237.955078, -1693.597412, 179.237823, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 15000);
			if (Kilrek)				
			{
				Kilrek->SetReactState(REACT_AGGRESSIVE);
				Kilrek->AddThreat(me->GetVictim(), 1.0f);
				Kilrek->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 1));
				ReSummonedKilrek = true;
			}
		}
		else ReSummonKilrek_Timer -= diff;


		if (SacrificeTimer <= diff)
		{
			Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);  // target tank as well patch pre 2.1.0
			if (pTarget && pTarget->IsAlive())
			{
				DoCast(pTarget, SPELL_SACRIFICE, true);
				me->SummonCreature(17248, -11233.81f, -1698.38f, 179.236f, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30500);

				if (Creature* Chains = me->FindNearestCreature(CREATURE_DEMONCHAINS, 5000))
				{
					CAST_AI(mob_demon_chainAI, Chains->AI())->SacrificeGUID = pTarget->GetGUID();
					Chains->CastSpell(Chains, SPELL_DEMON_CHAINS, true);
					DoScriptText(RAND(SAY_SACRIFICE1, SAY_SACRIFICE2), me);
					SacrificeTimer = 30000;
				}
			}
		}
		else SacrificeTimer -= diff;

		if (ShadowboltTimer <= diff)
		{
			DoCast(SelectUnit(SELECT_TARGET_TOPAGGRO, 0), SPELL_SHADOW_BOLT);
			ShadowboltTimer = 10000;
		}
		else ShadowboltTimer -= diff;

		if (SummonTimer <= diff)
		{
			if (!SummonedPortals)
			{
				for (uint8 i = 0; i < 2; ++i)
				{
					Creature* Portal = me->SummonCreature(CREATURE_PORTAL, PortalLocations[i][0], PortalLocations[i][1], PORTAL_Z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
					if (Portal)
						PortalGUID[i] = Portal->GetGUID();
				}

				SummonedPortals = true;
			}

			uint32 random = rand() % 2;
			Creature* Imp = me->SummonCreature(CREATURE_FIENDISHIMP, PortalLocations[random][0], PortalLocations[random][1], PORTAL_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 15000);
			if (Imp)
			{
				Imp->AddThreat(me->GetVictim(), 1.0f);
				Imp->AI()->AttackStart(SelectUnit(SELECT_TARGET_RANDOM, 0));
			}
			SummonTimer = urand(1500, 5000);
		}
		else SummonTimer -= diff;

		if (!Berserk)
		{
			if (BerserkTimer <= diff)
			{
				DoCast(me, SPELL_BERSERK);
				Berserk = true;
			}
			else BerserkTimer -= diff;
		}

		DoMeleeAttackIfReady();
	}
Exemple #16
0
        bool DoEncounterAction(Unit *who, bool attack, bool reset, bool checkAllDead)
        {
            if (!instance)
                return false;

            Creature *Thane = CAST_CRE(Unit::GetUnit(*me, instance->GetData64(DATA_THANE)));
            Creature *Lady = CAST_CRE(Unit::GetUnit(*me, instance->GetData64(DATA_LADY)));
            Creature *Baron = CAST_CRE(Unit::GetUnit(*me, instance->GetData64(DATA_BARON)));
            Creature *Sir = CAST_CRE(Unit::GetUnit(*me, instance->GetData64(DATA_SIR)));

            if (Thane && Lady && Baron && Sir)
            {
                if (attack && who)
                {
                    CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Thane->AI())->encounterActionAttack = true;
                    CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Lady->AI())->encounterActionAttack = true;
                    CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Baron->AI())->encounterActionAttack = true;
                    CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Sir->AI())->encounterActionAttack = true;

                    CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Thane->AI())->AttackStart(who);
                    CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Lady->AI())->AttackStart(who);
                    CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Baron->AI())->AttackStart(who);
                    CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Sir->AI())->AttackStart(who);
                }

                if (reset)
                {
                    if (instance->GetBossState(BOSS_HORSEMEN) != NOT_STARTED)
                    {
                        if (!Thane->isAlive())
                            Thane->Respawn();

                        if (!Lady->isAlive())
                            Lady->Respawn();

                        if (!Baron->isAlive())
                            Baron->Respawn();

                        if (!Sir->isAlive())
                            Sir->Respawn();

                        CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Thane->AI())->encounterActionReset = true;
                        CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Lady->AI())->encounterActionReset = true;
                        CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Baron->AI())->encounterActionReset = true;
                        CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Sir->AI())->encounterActionReset = true;

                        CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Thane->AI())->EnterEvadeMode();
                        CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Lady->AI())->EnterEvadeMode();
                        CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Baron->AI())->EnterEvadeMode();
                        CAST_AI(boss_four_horsemen::boss_four_horsemenAI, Sir->AI())->EnterEvadeMode();
                    }
                }

                if (checkAllDead)
                    return !Thane->isAlive() && !Lady->isAlive() && !Baron->isAlive() && !Sir->isAlive();
            }
            return false;
        }
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        if (pInstance && !pInstance->GetData(TYPE_MOROES))
        {
            EnterEvadeMode();
            return;
        }

        if (!Enrage && me->GetHealth()*100 / me->GetMaxHealth() < 30)
        {
            DoCast(me, SPELL_FRENZY);
            Enrage = true;
        }

        if (CheckAdds_Timer <= diff)
        {
            for (uint8 i = 0; i < 4; ++i)
            {
                Creature* Temp = NULL;
                if (AddGUID[i])
                {
                    Temp = Unit::GetCreature((*me),AddGUID[i]);
                    if (Temp && Temp->isAlive())
                        if (!Temp->getVictim())
                            Temp->AI()->AttackStart(me->getVictim());
                }
            }
            CheckAdds_Timer = 5000;
        } else CheckAdds_Timer -= diff;

        if (!Enrage)
        {
            //Cast Vanish, then Garrote random victim
            if (Vanish_Timer <= diff)
            {
                DoCast(me, SPELL_VANISH);
                InVanish = true;
                Vanish_Timer = 35000;
                Wait_Timer = 12000;
                return;
            } else Vanish_Timer -= diff;

            //Blind highest aggro, and attack second highest
            if (Gouge_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_GOUGE);
                Gouge_Timer = 40000;
            } else Gouge_Timer -= diff;

            if (Blind_Timer <= diff)
            {
                Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 25, true);
                if (pTarget && me->IsWithinMeleeRange(pTarget))
                    DoCast(pTarget, SPELL_BLIND);

                Blind_Timer = 40000;
            } else Blind_Timer -= diff;
        }

        if (InVanish)
        {
            if (Wait_Timer <= diff)
            {
                DoScriptText(RAND(SAY_SPECIAL_1,SAY_SPECIAL_2), me);

                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                    pTarget->CastSpell(pTarget, SPELL_GARROTE,true);

                InVanish = false;
            } else Wait_Timer -= diff;
        }

        if (!InVanish)
            DoMeleeAttackIfReady();
    }
Exemple #18
0
    void UpdateAI(const uint32 diff)
    {
        //Return since we have no target
        if (!UpdateVictim())
            return;

        //MortalWound_Timer
        if (MortalWound_Timer < diff)
        {
            DoCast(m_creature->getVictim(),SPELL_MORTAL_WOUND);
            MortalWound_Timer = 10000 + rand()%10000;
        } else MortalWound_Timer -= diff;

        //Summon 1-3 Spawns of Fankriss at random time.
        if (SpawnSpawns_Timer < diff)
        {
            switch(rand()%3)
            {
            case 0:
                SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0));
                break;
            case 1:
                SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0));
                SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0));
                break;
            case 2:
                SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0));
                SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0));
                SummonSpawn(SelectUnit(SELECT_TARGET_RANDOM,0));
                break;
            }
            SpawnSpawns_Timer = 30000 + rand()%30000;
        } else SpawnSpawns_Timer -= diff;

        // Teleporting Random Target to one of the three tunnels and spawn 4 hatchlings near the gamer.
        //We will only telport if fankriss has more than 3% of hp so teleported gamers can always loot.
        if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() > 3 )
        {
            if(SpawnHatchlings_Timer< diff)
            {
                Unit* target = NULL;
                target = SelectUnit(SELECT_TARGET_RANDOM,0);
                if (target && target->GetTypeId() == TYPEID_PLAYER)
                {
                    DoCast(target, SPELL_ROOT);

                    if(DoGetThreat(target))
                        DoModifyThreatPercent(target, -100);

                    switch(rand()%3)
                    {
                    case 0:
                        DoTeleportPlayer(target, -8106.0142,1289.2900,-74.419533,5.112);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        break;
                    case 1:
                        DoTeleportPlayer(target, -7990.135354,1155.1907,-78.849319,2.608);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        break;
                    case 2:
                        DoTeleportPlayer(target,-8159.7753,1127.9064,-76.868660,0.675);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()-3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-3, target->GetPositionY()+3, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()-5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        Hatchling = m_creature->SummonCreature(15962, target->GetPositionX()-5, target->GetPositionY()+5, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if(Hatchling)
                            ((CreatureAI*)Hatchling->AI())->AttackStart(target);
                        break;
                    }
                }
                SpawnHatchlings_Timer = 45000 + rand()%15000;
            } else SpawnHatchlings_Timer -= diff;
        }

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

                //BrainWashTotem_Timer
                if (BrainWashTotem_Timer <= diff)
                {
                    DoCast(me, SPELL_BRAINWASHTOTEM);
                    BrainWashTotem_Timer = 18000 + rand()%8000;
                } else BrainWashTotem_Timer -= diff;

                //HealingWard_Timer
                if (HealingWard_Timer <= diff)
                {
                    //DoCast(me, SPELL_POWERFULLHEALINGWARD);
                    me->SummonCreature(14987, me->GetPositionX()+3, me->GetPositionY()-2, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000);
                    HealingWard_Timer = 14000 + rand()%6000;
                } else HealingWard_Timer -= diff;

                //Hex_Timer
                if (Hex_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_HEX);

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

                    Hex_Timer = 12000 + rand()%8000;
                } else Hex_Timer -= diff;

                //Casting the delusion curse with a shade. So shade will attack the same target with the curse.
                if (Delusions_Timer <= diff)
                {
                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                    {
                        DoCast(pTarget, SPELL_DELUSIONSOFJINDO);

                        Creature *Shade = me->SummonCreature(14986, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Shade)
                            Shade->AI()->AttackStart(pTarget);
                    }

                    Delusions_Timer = 4000 + rand()%8000;
                } else Delusions_Timer -= diff;

                //Teleporting a random gamer and spawning 9 skeletons that will attack this gamer
                if (Teleport_Timer <= diff)
                {
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                    if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
                    {
                        DoTeleportPlayer(pTarget, -11583.7783f, -1249.4278f, 77.5471f, 4.745f);

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

                        Creature *Skeletons;
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX()+2, pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX()-2, pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX()+4, pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX()-4, pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX(), pTarget->GetPositionY()+2, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX(), pTarget->GetPositionY()-2, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX(), pTarget->GetPositionY()+4, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX(), pTarget->GetPositionY()-4, pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                        Skeletons = me->SummonCreature(14826, pTarget->GetPositionX()+3, pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                        if (Skeletons)
                            Skeletons->AI()->AttackStart(pTarget);
                    }

                    Teleport_Timer = 15000 + rand()%8000;
                } else Teleport_Timer -= diff;

                DoMeleeAttackIfReady();
            }
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        if (EnfeebleResetTimer && EnfeebleResetTimer <= diff) // Let's not forget to reset that
        {
            EnfeebleResetHealth();
            EnfeebleResetTimer = 0;
        } else EnfeebleResetTimer -= diff;

        if (me->hasUnitState(UNIT_STAT_STUNNED))      // While shifting to phase 2 malchezaar stuns himself
            return;

        if (me->GetUInt64Value(UNIT_FIELD_TARGET) != me->getVictim()->GetGUID())
            me->SetUInt64Value(UNIT_FIELD_TARGET, me->getVictim()->GetGUID());

        if (phase == 1)
        {
            if ((me->GetHealth()*100) / me->GetMaxHealth() < 60)
            {
                me->InterruptNonMeleeSpells(false);

                phase = 2;

                //animation
                DoCast(me, SPELL_EQUIP_AXES);

                //text
                DoScriptText(SAY_AXE_TOSS1, me);

                //passive thrash aura
                DoCast(me, SPELL_THRASH_AURA, true);

                //models
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, AXE_EQUIP_MODEL);
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, AXE_EQUIP_INFO);

                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, AXE_EQUIP_MODEL);
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, AXE_EQUIP_INFO);

                //damage
                const CreatureTemplate *cinfo = me->GetCreatureTemplate();
                me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, 2*cinfo->mindmg);
                me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, 2*cinfo->maxdmg);
                me->UpdateDamagePhysical(BASE_ATTACK);

                me->SetBaseWeaponDamage(OFF_ATTACK, MINDAMAGE, cinfo->mindmg);
                me->SetBaseWeaponDamage(OFF_ATTACK, MAXDAMAGE, cinfo->maxdmg);
                //Sigh, updating only works on main attack, do it manually ....
                me->SetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, cinfo->mindmg);
                me->SetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, cinfo->maxdmg);

                me->SetAttackTime(OFF_ATTACK, (me->GetAttackTime(BASE_ATTACK)*150)/100);
            }
        }
        else if (phase == 2)
        {
            if ((me->GetHealth()*100) / me->GetMaxHealth() < 30)
            {
                InfernalTimer = 15000;

                phase = 3;

                ClearWeapons();

                //remove thrash
                me->RemoveAurasDueToSpell(SPELL_THRASH_AURA);

                DoScriptText(SAY_AXE_TOSS2, me);

                Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                for (uint8 i = 0; i < 2; ++i)
                {
                    Creature *axe = me->SummonCreature(MALCHEZARS_AXE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
                    if (axe)
                    {
                        axe->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, AXE_EQUIP_MODEL);
                        axe->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, AXE_EQUIP_INFO);

                        axe->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        axe->setFaction(me->getFaction());
                        axes[i] = axe->GetGUID();
                        if (pTarget)
                        {
                            axe->AI()->AttackStart(pTarget);
                            //axe->getThreatManager().tauntApply(pTarget); //Taunt Apply and fade out does not work properly
                                                            // So we'll use a hack to add a lot of threat to our target
                            axe->AddThreat(pTarget, 10000000.0f);
                        }
                    }
                }

                if (ShadowNovaTimer > 35000)
                    ShadowNovaTimer = EnfeebleTimer + 5000;

                return;
            }

            if (SunderArmorTimer <= diff)
            {
                DoCast(me->getVictim(), SPELL_SUNDER_ARMOR);
                SunderArmorTimer = urand(10000, 18000);
            } else SunderArmorTimer -= diff;

            if (Cleave_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_CLEAVE);
                Cleave_Timer = urand(6000, 12000);
            } else Cleave_Timer -= diff;
        }
        else
        {
            if (AxesTargetSwitchTimer <= diff)
            {
                AxesTargetSwitchTimer = urand(7500, 20000);

                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                {
                    for (uint8 i = 0; i < 2; ++i)
                    {
                        if (Unit *axe = Unit::GetUnit(*me, axes[i]))
                        {
                            if (axe->getVictim())
                                DoModifyThreatPercent(axe->getVictim(), -100);
                            if (pTarget)
                                axe->AddThreat(pTarget, 1000000.0f);
                            //axe->getThreatManager().tauntFadeOut(axe->getVictim());
                            //axe->getThreatManager().tauntApply(pTarget);
                        }
                    }
                }
            } else AxesTargetSwitchTimer -= diff;

            if (AmplifyDamageTimer <= diff)
            {
                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                    DoCast(pTarget, SPELL_AMPLIFY_DAMAGE);
                AmplifyDamageTimer = urand(20000, 30000);
            } else AmplifyDamageTimer -= diff;
        }

        //Time for global and double timers
        if (InfernalTimer <= diff)
        {
            SummonInfernal(diff);
            InfernalTimer = phase == 3 ? 14500 : 44500;    // 15 secs in phase 3, 45 otherwise
        } else InfernalTimer -= diff;

        if (ShadowNovaTimer <= diff)
        {
            DoCast(me->getVictim(), SPELL_SHADOWNOVA);
            ShadowNovaTimer = phase == 3 ? 31000 : uint32(-1);
        } else ShadowNovaTimer -= diff;

        if (phase != 2)
        {
            if (SWPainTimer <= diff)
            {
                Unit *pTarget = NULL;
                if (phase == 1)
                    pTarget = me->getVictim();        // the tank
                else                                          // anyone but the tank
                    pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);

                if (pTarget)
                    DoCast(pTarget, SPELL_SW_PAIN);

                SWPainTimer = 20000;
            } else SWPainTimer -= diff;
        }

        if (phase != 3)
        {
            if (EnfeebleTimer <= diff)
            {
                EnfeebleHealthEffect();
                EnfeebleTimer = 30000;
                ShadowNovaTimer = 5000;
                EnfeebleResetTimer = 9000;
            } else EnfeebleTimer -= diff;
        }

        if (phase == 2)
            DoMeleeAttacksIfReady();
        else
            DoMeleeAttackIfReady();
    }
            void EnterCombat(Unit* /*who*/)
            {
                if (instance)
                {
                    if (instance->GetData64(DATA_NETHEKURSE))
                    {
                        Creature* pKurse = Unit::GetCreature(*me, instance->GetData64(DATA_NETHEKURSE));
                        if (pKurse && me->IsWithinDist(pKurse, 45.0f))
                        {
                            CAST_AI(boss_grand_warlock_nethekurse::boss_grand_warlock_nethekurseAI, pKurse->AI())->DoYellForPeonAggro();

                            if (instance->GetData(TYPE_NETHEKURSE) == IN_PROGRESS)
                                return;
                            else
                                instance->SetData(TYPE_NETHEKURSE, IN_PROGRESS);
                        }
                    }
                }
            }
Exemple #22
0
    bool OnQuestAccept(Player* player, Creature* creature, const Quest* quest) override
    {
        if (quest->GetQuestId() == QUEST_MISSING_DIPLO_PT11)
        {
            Creature* pSlim = creature->FindNearestCreature(NPC_TAPOKE_SLIM_JAHN, 25.0f);

            if (!pSlim)
                return false;

            if (!pSlim->HasStealthAura())
                pSlim->CastSpell(pSlim, SPELL_STEALTH, true);

            if (npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI* pEscortAI = CAST_AI(npc_tapoke_slim_jahn::npc_tapoke_slim_jahnAI, pSlim->AI()))
                pEscortAI->Start(false, false, player->GetGUID(), quest);
        }
        return false;
    }
            void UpdateAI(const uint32 diff)
            {
                //Return since we have no target
                if (!UpdateVictim())
                    return;

                if (Summon_Timer <= diff)
                {
                    for (uint8 i = 0; i < 3; ++i)
                    {
                        Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
                        Creature* Wraith = me->SummonCreature(21062, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 25000);
                        if (target && Wraith)
                            Wraith->AI()->AttackStart(target);
                    }
                    DoScriptText(SAY_SUMMON, me);
                    Summon_Timer = urand(30000, 45000);
                }
                else
                    Summon_Timer -= diff;

                if (ManaTap_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_MANA_TAP);
                    ManaTap_Timer = urand(14000, 22000);
                }
                else
                    ManaTap_Timer -= diff;

                if (ArcaneTorrent_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_ARCANE_TORRENT);
                    ArcaneTorrent_Timer = urand(12000, 18000);
                }
                else
                    ArcaneTorrent_Timer -= diff;

                if (Domination_Timer <= diff)
                {
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
                    {
                        DoScriptText(RAND(SAY_DOMINATION_1, SAY_DOMINATION_2), me);
                        DoCast(target, SPELL_DOMINATION);
                    }
                    Domination_Timer = urand(25000, 30000);
                }
                else
                    Domination_Timer -= diff;

                //Only casting if Heroic Mode is used
                if (IsHeroic())
                {
                    if (ArcaneExplosion_Timer <= diff)
                    {
                        DoCast(me->getVictim(), H_SPELL_ARCANE_EXPLOSION);
                        ArcaneExplosion_Timer = urand(10000, 14000);
                    }
                    else
                        ArcaneExplosion_Timer -= diff;
                }

                if (!Enraged && HealthBelowPct(21))
                {
                    DoCast(me, SPELL_FRENZY);
                    DoScriptText(SAY_ENRAGE, me);
                    Enraged = true;

                }

                DoMeleeAttackIfReady();
            }
template <> void TargetedMovementGenerator<Creature>::MovementInform(Creature &unit)
{
    // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle
    unit.AI()->MovementInform(TARGETED_MOTION_TYPE, i_target.getTarget()->GetGUIDLow());
}
        void UpdateAI(uint32 diff) override
        {
            if (!CanAttack && Intro)
            {
                if (AggroTimer <= diff)
                {
                    CanAttack = true;
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    AggroTimer=19000;
                }
                else
                {
                    AggroTimer -= diff;
                    return;
                }
            }
            // to prevent abuses during phase 2
            if (Phase == 2 && !me->GetVictim() && me->IsInCombat())
            {
                EnterEvadeMode();
                return;
            }
            // Return since we have no target
            if (!UpdateVictim())
                return;

            if (Phase == 1 || Phase == 3)
            {
                // ShockBlastTimer
                if (ShockBlastTimer <= diff)
                {
                    // Shock Burst
                    // Randomly used in Phases 1 and 3 on Vashj's target, it's a Shock spell doing 8325-9675 nature damage and stunning the target for 5 seconds, during which she will not attack her target but switch to the next person on the aggro list.
                    DoCastVictim(SPELL_SHOCK_BLAST);

                    ShockBlastTimer = 1000 + rand32() % 14000;       // random cooldown
                } else ShockBlastTimer -= diff;

                // StaticChargeTimer
                if (StaticChargeTimer <= diff)
                {
                    // Static Charge
                    // Used on random people (only 1 person at any given time) in Phases 1 and 3, it's a debuff doing 2775 to 3225 Nature damage to the target and everybody in about 5 yards around it, every 1 seconds for 30 seconds. It can be removed by Cloak of Shadows, Iceblock, Divine Shield, etc, but not by Cleanse or Dispel Magic.
                    Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 200, true);
                    if (target && !target->HasAura(SPELL_STATIC_CHARGE_TRIGGER))
                        DoCast(target, SPELL_STATIC_CHARGE_TRIGGER); // cast Static Charge every 2 seconds for 20 seconds

                    StaticChargeTimer = 10000 + rand32() % 20000;
                } else StaticChargeTimer -= diff;

                // EntangleTimer
                if (EntangleTimer <= diff)
                {
                    if (!Entangle)
                    {
                        // Entangle
                        // Used in Phases 1 and 3, it casts Entangling Roots on everybody in a 15 yard radius of Vashj, immobilzing them for 10 seconds and dealing 500 damage every 2 seconds. It's not a magic effect so it cannot be dispelled, but is removed by various buffs such as Cloak of Shadows or Blessing of Freedom.
                        DoCastVictim(SPELL_ENTANGLE);
                        Entangle = true;
                        EntangleTimer = 10000;
                    }
                    else
                    {
                        CastShootOrMultishot();
                        Entangle = false;
                        EntangleTimer = 20000 + rand32() % 5000;
                    }
                } else EntangleTimer -= diff;

                // Phase 1
                if (Phase == 1)
                {
                    // Start phase 2
                    if (HealthBelowPct(70))
                    {
                        // Phase 2 begins when Vashj hits 70%. She will run to the middle of her platform and surround herself in a shield making her invulerable.
                        Phase = 2;

                        me->GetMotionMaster()->Clear();
                        DoTeleportTo(MIDDLE_X, MIDDLE_Y, MIDDLE_Z);

                        for (uint8 i = 0; i < 4; ++i)
                            if (Creature* creature = me->SummonCreature(SHIED_GENERATOR_CHANNEL, ShieldGeneratorChannelPos[i][0],  ShieldGeneratorChannelPos[i][1],  ShieldGeneratorChannelPos[i][2],  ShieldGeneratorChannelPos[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0))
                                ShieldGeneratorChannel[i] = creature->GetGUID();

                        Talk(SAY_PHASE2);
                    }
                }
                // Phase 3
                else
                {
                    // SummonSporebatTimer
                    if (SummonSporebatTimer <= diff)
                    {
                        if (Creature* sporebat = me->SummonCreature(TOXIC_SPOREBAT, SPOREBAT_X, SPOREBAT_Y, SPOREBAT_Z, SPOREBAT_O, TEMPSUMMON_CORPSE_DESPAWN, 0))
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                                sporebat->AI()->AttackStart(target);

                        // summon sporebats faster and faster
                        if (SummonSporebatStaticTimer > 1000)
                            SummonSporebatStaticTimer -= 1000;

                        SummonSporebatTimer = SummonSporebatStaticTimer;

                        if (SummonSporebatTimer < 5000)
                            SummonSporebatTimer = 5000;

                    } else SummonSporebatTimer -= diff;
                }

                // Melee attack
                DoMeleeAttackIfReady();

                // CheckTimer - used to check if somebody is in melee range
                if (CheckTimer <= diff)
                {
                    bool inMeleeRange = false;
                    for (auto* ref : me->GetThreatManager().GetUnsortedThreatList())
                    {
                        Unit* target = ref->GetVictim();
                        if (target->IsWithinMeleeRange(me)) // if in melee range
                        {
                            inMeleeRange = true;
                            break;
                        }
                    }

                    // if nobody is in melee range
                    if (!inMeleeRange)
                        CastShootOrMultishot();

                    CheckTimer = 5000;
                } else CheckTimer -= diff;
            }
            // Phase 2
            else
            {
                // ForkedLightningTimer
                if (ForkedLightningTimer <= diff)
                {
                    // Forked Lightning
                    // Used constantly in Phase 2, it shoots out completely randomly targeted bolts of lightning which hit everybody in a roughtly 60 degree cone in front of Vashj for 2313-2687 nature damage.
                    Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0);

                    if (!target)
                        target = me->GetVictim();

                    DoCast(target, SPELL_FORKED_LIGHTNING);

                    ForkedLightningTimer = 2000 + rand32() % 6000;
                } else ForkedLightningTimer -= diff;

                // EnchantedElementalTimer
                if (EnchantedElementalTimer <= diff)
                {
                    me->SummonCreature(ENCHANTED_ELEMENTAL, ElementPos[EnchantedElementalPos][0], ElementPos[EnchantedElementalPos][1], ElementPos[EnchantedElementalPos][2], ElementPos[EnchantedElementalPos][3], TEMPSUMMON_CORPSE_DESPAWN, 0);

                    if (EnchantedElementalPos == 7)
                        EnchantedElementalPos = 0;
                    else
                        ++EnchantedElementalPos;

                    EnchantedElementalTimer = 10000 + rand32() % 5000;
                } else EnchantedElementalTimer -= diff;

                // TaintedElementalTimer
                if (TaintedElementalTimer <= diff)
                {
                    uint32 pos = rand32() % 8;
                    me->SummonCreature(TAINTED_ELEMENTAL, ElementPos[pos][0], ElementPos[pos][1], ElementPos[pos][2], ElementPos[pos][3], TEMPSUMMON_DEAD_DESPAWN, 0);

                    TaintedElementalTimer = 120000;
                } else TaintedElementalTimer -= diff;

                // CoilfangEliteTimer
                if (CoilfangEliteTimer <= diff)
                {
                    uint32 pos = rand32() % 3;
                    Creature* coilfangElite = me->SummonCreature(COILFANG_ELITE, CoilfangElitePos[pos][0], CoilfangElitePos[pos][1], CoilfangElitePos[pos][2], CoilfangElitePos[pos][3], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    if (coilfangElite)
                    {
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            coilfangElite->AI()->AttackStart(target);
                        else if (me->GetVictim())
                            coilfangElite->AI()->AttackStart(me->GetVictim());
                    }
                    CoilfangEliteTimer = 45000 + rand32() % 5000;
                } else CoilfangEliteTimer -= diff;

                // CoilfangStriderTimer
                if (CoilfangStriderTimer <= diff)
                {
                    uint32 pos = rand32() % 3;
                    if (Creature* CoilfangStrider = me->SummonCreature(COILFANG_STRIDER, CoilfangStriderPos[pos][0], CoilfangStriderPos[pos][1], CoilfangStriderPos[pos][2], CoilfangStriderPos[pos][3], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000))
                    {
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            CoilfangStrider->AI()->AttackStart(target);
                        else if (me->GetVictim())
                            CoilfangStrider->AI()->AttackStart(me->GetVictim());
                    }
                    CoilfangStriderTimer = 60000 + rand32() % 10000;
                } else CoilfangStriderTimer -= diff;

                // CheckTimer
                if (CheckTimer <= diff)
                {
                    // Start Phase 3
                    if (instance->GetData(DATA_CANSTARTPHASE3))
                    {
                        // set life 50%
                        me->SetHealth(me->CountPctFromMaxHealth(50));

                        me->RemoveAurasDueToSpell(SPELL_MAGIC_BARRIER);

                        Talk(SAY_PHASE3);

                        Phase = 3;

                        // return to the tank
                        me->GetMotionMaster()->MoveChase(me->GetVictim());
                    }
                    CheckTimer = 1000;
                } else CheckTimer -= diff;
            }
        }
Exemple #26
0
 void SetData(uint32 type, uint32 data)
 {
     switch(type)
     {
     case DATA_MAGTHERIDON_EVENT:
         m_auiEncounter[0] = data;
         if (data == NOT_STARTED)
             RespawnTimer = 10000;
         if (data != IN_PROGRESS)
            HandleGameObject(DoorGUID, true);
         break;
     case DATA_CHANNELER_EVENT:
         switch(data)
         {
         case NOT_STARTED: // Reset all channelers once one is reset.
             if (m_auiEncounter[1] != NOT_STARTED)
             {
                 m_auiEncounter[1] = NOT_STARTED;
                 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                 {
                     if (Creature *Channeler = instance->GetCreature(*i))
                     {
                         if (Channeler->isAlive())
                             Channeler->AI()->EnterEvadeMode();
                         else
                             Channeler->Respawn();
                     }
                 }
                 CageTimer = 0;
                 HandleGameObject(DoorGUID, true);
             }break;
         case IN_PROGRESS: // Event start.
             if (m_auiEncounter[1] != IN_PROGRESS)
             {
                 m_auiEncounter[1] = IN_PROGRESS;
                 // Let all five channelers aggro.
                 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                 {
                     Creature *Channeler = instance->GetCreature(*i);
                     if (Channeler && Channeler->isAlive())
                         Channeler->AI()->AttackStart(Channeler->SelectNearestTarget(999));
                 }
                 // Release Magtheridon after two minutes.
                 Creature *Magtheridon = instance->GetCreature(MagtheridonGUID);
                 if (Magtheridon && Magtheridon->isAlive())
                 {
                     Magtheridon->MonsterTextEmote(EMOTE_BONDS_WEAKEN, 0);
                     CageTimer = 120000;
                 }
                 HandleGameObject(DoorGUID, false);
             }break;
         case DONE: // Add buff and check if all channelers are dead.
             for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
             {
                 Creature *Channeler = instance->GetCreature(*i);
                 if (Channeler && Channeler->isAlive())
                 {
                     //Channeler->CastSpell(Channeler, SPELL_SOUL_TRANSFER, true);
                     data = IN_PROGRESS;
                     break;
                 }
             }break;
         }
         m_auiEncounter[1] = data;
         break;
     case DATA_COLLAPSE:
         // true - collapse / false - reset
         for(std::set<uint64>::iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i)
             DoUseDoorOrButton(*i);
         break;
     default:
         break;
     }
 }
Exemple #27
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        //BrainWashTotem_Timer
        if (BrainWashTotem_Timer < diff)
        {
            DoCastSpellIfCan(m_creature, SPELL_BRAINWASHTOTEM);
            BrainWashTotem_Timer = urand(18000, 26000);
        }else BrainWashTotem_Timer -= diff;

        //HealingWard_Timer
        if (HealingWard_Timer < diff)
        {
            //DoCastSpellIfCan(m_creature, SPELL_POWERFULLHEALINGWARD);
            m_creature->SummonCreature(14987, m_creature->GetPositionX()+3, m_creature->GetPositionY()-2, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,30000);
            HealingWard_Timer = urand(14000, 20000);
        }else HealingWard_Timer -= diff;

        //Hex_Timer
        if (Hex_Timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(), SPELL_HEX);

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

            Hex_Timer = urand(12000, 20000);
        }else Hex_Timer -= diff;

        //Casting the delusion curse with a shade. So shade will attack the same target with the curse.
        if (Delusions_Timer < diff)
        {
            if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
            {
                DoCastSpellIfCan(target, SPELL_DELUSIONSOFJINDO);

                Creature *Shade = m_creature->SummonCreature(14986, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Shade)
                    Shade->AI()->AttackStart(target);
            }

            Delusions_Timer = urand(4000, 12000);
        }else Delusions_Timer -= diff;

        //Teleporting a random gamer and spawning 9 skeletons that will attack this gamer
        if (Teleport_Timer < diff)
        {
            Unit* target = NULL;
            target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);
            if (target && target->GetTypeId() == TYPEID_PLAYER)
            {
                DoTeleportPlayer(target, -11583.7783f, -1249.4278f, 77.5471f, 4.745f);

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

                Creature *Skeletons;
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+2, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()-2, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+4, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()-4, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()+2, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()-2, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()+4, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX(), target->GetPositionY()-4, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
                Skeletons = m_creature->SummonCreature(14826, target->GetPositionX()+3, target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (Skeletons)
                    Skeletons->AI()->AttackStart(target);
            }

            Teleport_Timer = urand(15000, 23000);
        }else Teleport_Timer -= diff;

        DoMeleeAttackIfReady();
    }
    void UpdateAI(const uint32 diff)
    {
        if (!SisterDeath)
        {
            if (pInstance)
            {
                Unit* Temp = NULL;
                Temp = Unit::GetUnit((*m_creature),pInstance->GetData64(DATA_ALYTHESS));
                if (Temp && Temp->isDead())
                {
                    DoScriptText(YELL_SISTER_ALYTHESS_DEAD, m_creature);
                    DoCast(m_creature, SPELL_EMPOWER);
                    m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
                    SisterDeath = true;
                }
            }
        }

        if (!UpdateVictim())
            return;

        if (SisterDeath)
        {
            if (ConflagrationTimer <= diff)
            {
                if (!m_creature->IsNonMeleeSpellCasted(false))
                {
                    m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                    if (pTarget)
                        DoCast(pTarget, SPELL_CONFLAGRATION);
                    ConflagrationTimer = 30000+(rand()%5000);
                }
            } else ConflagrationTimer -= diff;
        }
        else
        {
            if (ShadownovaTimer <= diff)
            {
                if (!m_creature->IsNonMeleeSpellCasted(false))
                {
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                    if (pTarget)
                        DoCast(pTarget, SPELL_SHADOW_NOVA);

                    if (!SisterDeath)
                    {
                        if (pTarget)
                            DoScriptText(EMOTE_SHADOW_NOVA, m_creature, pTarget);
                        DoScriptText(YELL_SHADOW_NOVA, m_creature);
                    }
                    ShadownovaTimer = 30000+(rand()%5000);
                }
            } else ShadownovaTimer -=diff;
        }

        if (ConfoundingblowTimer <= diff)
        {
            if (!m_creature->IsNonMeleeSpellCasted(false))
            {
                Unit *pTarget = NULL;
                pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                if (pTarget)
                    DoCast(pTarget, SPELL_CONFOUNDING_BLOW);
                ConfoundingblowTimer = 20000 + (rand()%5000);
            }
        } else ConfoundingblowTimer -=diff;

        if (ShadowimageTimer <= diff)
        {
            Unit *pTarget = NULL;
            Creature* temp = NULL;
            for (uint8 i = 0; i<3; ++i)
            {
                pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                temp = DoSpawnCreature(MOB_SHADOW_IMAGE,0,0,0,0,TEMPSUMMON_CORPSE_DESPAWN,10000);
                if (temp && pTarget)
                {
                    temp->AddThreat(pTarget,1000000);//don't change target(healers)
                    temp->AI()->AttackStart(pTarget);
                }
            }
            ShadowimageTimer = 20000;
        } else ShadowimageTimer -=diff;

        if (ShadowbladesTimer <= diff)
        {
            if (!m_creature->IsNonMeleeSpellCasted(false))
            {
                DoCast(m_creature, SPELL_SHADOW_BLADES);
                ShadowbladesTimer = 10000;
            }
        } else ShadowbladesTimer -=diff;

        if (EnrageTimer < diff && !Enraged)
        {
            m_creature->InterruptSpell(CURRENT_GENERIC_SPELL);
            DoScriptText(YELL_ENRAGE, m_creature);
            DoCast(m_creature, SPELL_ENRAGE);
            Enraged = true;
        } else EnrageTimer -= diff;

        if (m_creature->isAttackReady() && !m_creature->IsNonMeleeSpellCasted(false))
        {
            //If we are within range melee the target
            if (m_creature->IsWithinMeleeRange(m_creature->getVictim()))
            {
                HandleTouchedSpells(m_creature->getVictim(), SPELL_DARK_TOUCHED);
                m_creature->AttackerStateUpdate(m_creature->getVictim());
                m_creature->resetAttackTimer();
            }
        }
    }
void WaypointMovementGenerator<Creature>::MovementInform(Creature &creature)
{
    if (creature.AI())
        creature.AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode);
}
Exemple #30
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_creature->GetHealthPercent() > 50.0f)
        {
            if (Charge_Timer < diff)
            {
                if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                    DoCastSpellIfCan(target,SPELL_CHARGE);

                Charge_Timer = urand(15000, 30000);
            }else Charge_Timer -= diff;

            if (SonicBurst_Timer < diff)
            {
                DoCastSpellIfCan(m_creature->getVictim(),SPELL_SONICBURST);
                SonicBurst_Timer = urand(8000, 13000);
            }else SonicBurst_Timer -= diff;

            if (Screech_Timer < diff)
            {
                DoCastSpellIfCan(m_creature->getVictim(),SPELL_SCREECH);
                Screech_Timer = urand(18000, 26000);
            }else Screech_Timer -= diff;

            if (SpawnBats_Timer < diff)
            {
                Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);

                Creature* Bat = NULL;
                Bat = m_creature->SummonCreature(11368, -12291.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                Bat = m_creature->SummonCreature(11368, -12289.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                Bat = m_creature->SummonCreature(11368, -12293.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                Bat = m_creature->SummonCreature(11368, -12291.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                Bat = m_creature->SummonCreature(11368, -12289.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                Bat = m_creature->SummonCreature(11368, -12293.6220f, -1380.2640f, 144.8304f, 5.483f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if (target && Bat) Bat ->AI()->AttackStart(target);

                SpawnBats_Timer = 60000;
            }else SpawnBats_Timer -= diff;
        }
        else
        {
            if (PhaseTwo)
            {
                if (PhaseTwo && ShadowWordPain_Timer < diff)
                {
                    if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                    {
                        DoCastSpellIfCan(target, SPELL_SHADOW_WORD_PAIN);
                        ShadowWordPain_Timer = urand(12000, 18000);
                    }
                }ShadowWordPain_Timer -=diff;

                if (MindFlay_Timer < diff)
                {
                    DoCastSpellIfCan(m_creature->getVictim(), SPELL_MIND_FLAY);
                    MindFlay_Timer = 16000;
                }MindFlay_Timer -=diff;

                if (ChainMindFlay_Timer < diff)
                {
                    m_creature->InterruptNonMeleeSpells(false);
                    DoCastSpellIfCan(m_creature->getVictim(), SPELL_CHAIN_MIND_FLAY);
                    ChainMindFlay_Timer = urand(15000, 30000);
                }ChainMindFlay_Timer -=diff;

                if (GreaterHeal_Timer < diff)
                {
                    m_creature->InterruptNonMeleeSpells(false);
                    DoCastSpellIfCan(m_creature,SPELL_GREATERHEAL);
                    GreaterHeal_Timer = urand(25000, 35000);
                }GreaterHeal_Timer -=diff;

                if (SpawnFlyingBats_Timer < diff)
                {
                    Unit *target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);

                    Creature* FlyingBat = m_creature->SummonCreature(14965, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ()+15, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                    if (FlyingBat)
                    {
                        if (target)
                            FlyingBat->AI()->AttackStart(target);
                    }

                    SpawnFlyingBats_Timer = urand(10000, 15000);
                } else SpawnFlyingBats_Timer -=diff;
            }
            else
            {
                m_creature->SetDisplayId(15219);
                DoResetThreat();
                PhaseTwo = true;
            }
        }

        DoMeleeAttackIfReady();
    }