void UpdateAI(uint32 diff) override
        {
            events.Update(diff);
            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                case EVENT_CHECK_MOBS:
                {
                    if (VerifyMobs()) //plus de mobs, win!
                    {
                        me->HandleEmoteCommand(EMOTE_STATE_STAND);
                        me->MonsterYell("Thank you!", LANG_UNIVERSAL, 0);

                        std::list<Player*> PlayerList;
                        GetPlayerListInGrid(PlayerList, me, 20.0f);
                        for (auto player: PlayerList)
                            player->KilledMonsterCredit(54855, 0);

                        events.ScheduleEvent(EVENT_RESET, 30000);
                    }
                    else
                        events.ScheduleEvent(EVENT_CHECK_MOBS, 1000);

                    break;
                }
                case EVENT_RESET:
                {
                    ResetMobs();
                }
                }
            }
        }
            void Reset()
            {
                me->setPowerType(POWER_RAGE);
                me->SetPower(POWER_RAGE, 0);

                me->SetFloatValue(UNIT_FIELD_COMBAT_REACH, 5.0f);

                summons.DespawnAll();

                phase1 = true;
                range = false;
                _dominateMindCount = 2;
                _cloudCount = 3;
                _targetCount = 0;
                _maxTargetCount = 5;
                timer = 0;

                Talk(TALK_RESET);

                events.Reset();
                events.ScheduleEvent(EVENT_GROWING_ANGER_WARNING, 19000);
                events.ScheduleEvent(EVENT_SPAWN, 5000);
                events.ScheduleEvent(EVENT_UNLEASHED_WRATH, 52000);
                events.ScheduleEvent(EVENT_BERSERK, 900000);
                events.ScheduleEvent(EVENT_UPDATE_RAGE, 1000);

                targetedDominationPlayerGuids.clear();

                std::list<Player*> playerList;
                GetPlayerListInGrid(playerList, me, 100.0f);

                for (auto itr : playerList)
                    itr->RemoveAura(SPELL_DOMINATE_MIND);
            }
        void DamageTaken(Unit* attacker, uint32& damage)
        {
            if (me->HealthBelowPctDamaged(30, damage) && !isInFalcon)
            {
                isInFalcon = true;
                me->SetDisplayId(39796); //falcon
                events.ScheduleEvent(EVENT_FALCON, 1000);
                events.CancelEvent(EVENT_JAOMIN_JUMP);
                events.CancelEvent(EVENT_HIT_CIRCLE);
            }

            if (me->HealthBelowPctDamaged(5, damage))
            {
                me->SetDisplayId(39755);

                std::list<Player*> playerList;
                GetPlayerListInGrid(playerList, me, 15.0f);
                for (auto player: playerList)
                    player->KilledMonsterCredit(me->GetEntry(), 0);

                me->CombatStop();
                me->setFaction(35);
                me->SetFullHealth();
                me->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
                events.Reset();
                events.ScheduleEvent(EVENT_RESET, 5000);
                damage = 0;
            }

            if (damage > me->GetHealth())
                damage = 0;
        }
        void UpdatePower()
        {
            actualPower = (actualPower + healerCount <= 700) ? actualPower + healerCount: 700;

            std::list<Player*> playerList;
            GetPlayerListInGrid(playerList, me, 100.0f);

            for (auto player : playerList)
            {
                if (player->GetQuestStatus(QUEST_HEALING_SHEN) == QUEST_STATUS_INCOMPLETE)
                {
                    if (player->isAlive())
                    {
                        if (actualPower < 700) // IN_PROGRESS
                        {
                            if (!player->HasAura(SPELL_SHEN_HEALING))
                                player->CastSpell(player, SPELL_SHEN_HEALING, true);

                            player->SetPower(POWER_ALTERNATE_POWER, actualPower);
                        }
                        else
                        {
                            if (player->HasAura(SPELL_SHEN_HEALING))
                                player->RemoveAurasDueToSpell(SPELL_SHEN_HEALING);

                            player->KilledMonsterCredit(NPC_SHEN_HEAL_CREDIT);
                        }
                    }
                }
            }

            if (actualPower >= 700)
                Reset();
        }
        void UpdateAI(const uint32 diff)
        {
            events.Update(diff);

            if (events.ExecuteEvent() == EVENT_CHECK)
            {
                std::list<Creature*> munitionList;
                me->GetCreatureListWithEntryInGrid(munitionList, NPC_STABLE_MUNITION, 2.0f);
                if (!munitionList.empty())
                {
                    for(auto munition : munitionList)
                    {
                        if (munition->HasAura(SPELL_MUNITION_STABLE))
                        {
                            munition->RemoveAurasDueToSpell(SPELL_MUNITION_STABLE);
                            munition->CastSpell(munition, SPELL_MUNITION_EXPLOSION, true);
                            munition->DespawnOrUnsummon(2 * IN_MILLISECONDS);
                        }
                    }
                }

                std::list<Player*> playerList;
                GetPlayerListInGrid(playerList, me, 2.0f);
                if (!playerList.empty())
                {
                    for(auto player : playerList)
                        me->CastSpell(player, SPELL_MANTID_EXPLOSION, false);
                }

                events.ScheduleEvent(EVENT_CHECK, 0.5 * IN_MILLISECONDS);
            }
        }
Beispiel #6
0
            void CheckBetweenPlayerAndDmg()
            {
                std::list<Player*> PlayerList,PlayersInBetween;
                Player * DrainLifeTarget = NULL;
                GetPlayerListInGrid(PlayerList, me, 100.0f);

                for (auto itr : PlayerList)
                    if (itr->HasAura(SPELL_DRAIN_LIFE_STUN))
                        DrainLifeTarget = itr;

                if (DrainLifeTarget != NULL)
                {
                    for (auto itr : PlayerList)
                        if (itr->IsInBetween(me, DrainLifeTarget, 5.0f) && itr->GetGUID() != DrainLifeTarget->GetGUID())
                            PlayersInBetween.push_back(itr);

                    Player * NearstPlayer = DrainLifeTarget;
                    if (NearstPlayer)
                    {
                        for (auto itr : PlayersInBetween)
                            if (itr->GetDistance(me) < NearstPlayer->GetDistance(me))
                                NearstPlayer = itr;

                        DoCast(NearstPlayer,SPELL_DRAIN_LIFE_DAMAGE, true);
                    }
                }
            }
Beispiel #7
0
            void EndBeamPhase()
            {
                // RemoveBeamAuras
                std::list<Player*> PlayerList;
                GetPlayerListInGrid(PlayerList, me, 200.0f);

                for (auto itr : PlayerList)
                {
                    itr->RemoveAurasDueToSpell(SPELL_BLUE_BEAM);
                    itr->RemoveAurasDueToSpell(SPELL_RED_BEAM);
                }

                // Despawn creatures from phase
                DespawnCreature(RED_EYE);
                DespawnCreature(BLUE_EYE);
                DespawnCreature(YELLOW_EYE);
                DespawnCreature(YELLOW_EYE_MOVER);
                DespawnCreature(BLUE_FOG);
                
                std::list<Creature*> hungryList;
                GetCreatureListWithEntryInGrid(hungryList, me, HUNGRY_EYE, 80.0f); 
                for (auto eye : hungryList)
                    eye->GetAI()->DoAction(ACTION_EYE_DRAIN_LIFE); // find hungry eye to start drain life

                events.ScheduleEvent(EVENT_MAZE_TIME, 75000);
            }
        void UpdateAI(uint32 diff) override
        {
            if (checkPlayersTime <= diff)
            {
                std::list<Player*> playerList;
                GetPlayerListInGrid(playerList, me, 5.0f);

                bool playerWithQuestNear = false;

                for (auto player: playerList)
                    if (player->GetQuestStatus(29408) == QUEST_STATUS_INCOMPLETE)
                        if (!player->HasItemCount(80212))// Flamme du maitre
                            playerWithQuestNear = true;

                if (playerWithQuestNear && !me->HasAura(114610))
                {
                    me->AddAura(114610, me);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
                }
                else if (!playerWithQuestNear && me->HasAura(114610))
                {
                    me->RemoveAurasDueToSpell(114610);
                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
                }

                checkPlayersTime = 2000;
            }
            else
                checkPlayersTime -= diff;
        }
            void JustDied(Unit* attacker)
            {
                std::list<Player*> playerList;
                GetPlayerListInGrid(playerList, me, 6.0f);

                uint8 count = 0;
                for (auto player: playerList)
                {
                    if (player->HasAura(SPELL_VOODOO_DOLL_VISUAL) || player->HasAura(SPELL_FRAIL_SOUL))
                        continue;

                    if (++count > 3)
                        break;

                    if (Creature* clone = me->SummonCreature(56405, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation()))
                    {
                        if (player->GetHealthPct() >= 10.0f)
                            player->SetHealth(player->GetMaxHealth() / 10);

                        player->CastSpell(player, SPELL_CLONE_VISUAL, true);
                        player->CastSpell(player, SPELL_CROSSED_OVER, true);

                        player->CastSpell(clone,  SPELL_CLONE, true);

                        clone->CastSpell(clone, SPELL_LIFE_FRAGILE_THREAD, true);
                        clone->GetMotionMaster()->MoveTakeoff(1, clone->GetPositionX(), clone->GetPositionY(), clone->GetPositionZ() + 10.0f);

                        player->AddAura(SPELL_LIFE_FRAGILE_THREAD, player);
                    }
                }
            }
Beispiel #10
0
 void CheckPlayersInWater()
 {
     std::list<Player*> PlayerList;
     GetPlayerListInGrid(PlayerList, me, 100.0f);
     for (auto player : PlayerList)
         if (player->IsInWater())
             player->Kill(player);
 }
Beispiel #11
0
 void TryKillPlayerInFront()
 {
     // In maze time phase all players in front of durumu beam instant killed
     std::list<Player*> PlayerList;
     GetPlayerListInGrid(PlayerList, me, 80.0f);
     for (auto player : PlayerList)
         if (me->isInFront(player, M_PI/6))
             me->Kill(player);
 }
        void JustDied(Unit* attacker)
        {
            std::list<Player*> playerList;
            GetPlayerListInGrid(playerList, me, 50.0f);

            for (auto player : playerList)
                if (player->GetQuestStatus(29786) == QUEST_STATUS_INCOMPLETE)
                    if (player->isAlive())
                        player->KilledMonsterCredit(me->GetEntry());
        }
        void updatePlayerList()
        {
            playersInvolved.clear();

            std::list<Player*> PlayerList;
            GetPlayerListInGrid(PlayerList, me, 20.0f);

            for (auto player: PlayerList)
                if (player->GetQuestStatus(29414) == QUEST_STATUS_INCOMPLETE)
                    playersInvolved.push_back(player);
        }
Beispiel #14
0
uint64 SelecGUIDtRandomPlayerInRage(Creature*me,float range,bool lingering_gaze = false)
{
    std::list<Player*> PlayerList;
    GetPlayerListInGrid(PlayerList, me, range);
    if (lingering_gaze)
        PlayerList.remove_if(JadeCore::UnitAuraCheck(true, SPELL_LINGERING_GAZE_MARKER));
    if (!PlayerList.empty())
    if (Player *target = JadeCore::Containers::SelectRandomContainerElement(PlayerList))
            return target->GetGUID();

    return 0;
}
        Player* GetRandomPlayer()
        {
            std::list<Player*> playerList;
            GetPlayerListInGrid(playerList, me, 50.0f);

            if (playerList.empty())
                return NULL;

            JadeCore::Containers::RandomResizeList(playerList, 1);

            return *playerList.begin();
        }
        bool checkPlayers()
        {
            std::list<Player*> playerList;
            GetPlayerListInGrid(playerList, me, 80.0f);

            for (auto player : playerList)
                if (player->GetQuestStatus(29786) == QUEST_STATUS_INCOMPLETE)
                    if (player->isAlive())
                        return true;

            return false;
        }
        void UpdateAI(const uint32 diff)
        {
            std::list<Player*> playerList;
            GetPlayerListInGrid(playerList, me, 15.0f);

            for (auto player: playerList)
            {
                if (me->GetPositionX() == 974.718994f && me->GetPositionY() == 2863.25)
                    DoAction(ACTION_TALK_1);
                else if (player->GetQuestStatus(29775) == QUEST_STATUS_COMPLETE)
                    DoAction(ACTION_TALK_2);
            }
        }
        void UpdateAI(const uint32 diff)
        {
            std::list<Player*> playerList;
            GetPlayerListInGrid(playerList, me, 7.0f);
            for (auto player: playerList)
            {
                if (player->GetQuestStatus(29423) == QUEST_STATUS_COMPLETE)
                {
                    DoAction(ACTION_TALK);
                }
            }

            DoMeleeAttackIfReady();
        }
Beispiel #19
0
        void UpdateAI(const uint32 diff)
        {
            if (checkNearPlayerTimer)
            {
                if (checkNearPlayerTimer <= diff)
                {
                    std::list<Player*> playerList;
                    GetPlayerListInGrid(playerList, me, 5.0f);

                    for (auto player: playerList)
                        me->CastSpell(player, SPELL_FIST_CHARGE, true);

                    checkNearPlayerTimer = 500;
                }
                else
                    checkNearPlayerTimer -= diff;
            }
        }
Beispiel #20
0
            uint64 SelectBeamTargetGuid()
            {
                if (me->GetEntry() == YELLOW_EYE)
                {
                    std::list<Creature*> beamTarList;
                    GetCreatureListWithEntryInGrid(beamTarList, me, YELLOW_EYE_MOVER, 80.0f);
                    for (auto Beam : beamTarList)
                        return Beam->GetGUID();
                }
                else // red or blue beam
                {
                    std::list<Player*> PlayerList;
                    GetPlayerListInGrid(PlayerList, me, 80.0f);

                    for (auto itr : PlayerList)
                        if (itr->HasAura(me->GetEntry() == RED_EYE ?  SPELL_RED_BEAM : SPELL_BLUE_BEAM))
                            return itr->GetGUID();
                }
                return 0;
            }
        void JustDied(Unit* unit)
        {
            me->RemoveAura(SPELL_INTENSITY);
            if (instance)
            {
                instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me);
                instance->SetData(DATA_TRIAL, DONE);

                if (instance->GetData(DATA_LOREWALKER) != DONE)
                    me->SetLootRecipient(NULL);
                else
                {
                    std::list<Player*> playerList;
                    GetPlayerListInGrid(playerList, me, 150.0f);
                    if (!playerList.empty())
                    {
                        for(auto player : playerList)
                            player->ModifyCurrency(395, player->GetMap()->IsHeroic() ? 100 * CURRENCY_PRECISION : 70 * CURRENCY_PRECISION);
                    }
                }
            }
        }
Beispiel #22
0
            void HandleTriggerSpell(constAuraEffectPtr aurEff)
            {
                PreventDefaultAction();

                Unit* caster = GetCaster();

                if (!caster)
                    return;

                std::list<Player*> playerList;
                GetPlayerListInGrid(playerList, caster, 200.0f);

                for (auto target: playerList)
                {
                    if (target->HasAura(SPELL_TOTALY_PETRIFIED))
                        continue;

                    uint32 triggeredSpell = GetSpellInfo()->Effects[0].TriggerSpell;

                    if (!target->HasAura(triggeredSpell))
                        caster->AddAura(triggeredSpell, target);

                    if (AuraPtr triggeredAura = target->GetAura(triggeredSpell))
                    {
                        uint8 stackCount = triggeredAura->GetStackAmount();

                        uint8 newStackCount = (stackCount + 5 > 100) ? 100 : (stackCount + 5);
                        triggeredAura->SetStackAmount(newStackCount);
                        triggeredAura->RefreshDuration();
                        triggeredAura->RecalculateAmountOfEffects();

                        target->SetPower(POWER_ALTERNATE_POWER, newStackCount);

                        if (newStackCount >= 100)
                            caster->AddAura(SPELL_TOTALY_PETRIFIED, target);
                    }
                }
            }
        void UpdateAI(uint32 diff)
        {
            if (checkTimer <= diff)
            {
                checkTimer = 500;
                if (Creature* munition = GetClosestCreatureWithEntry(me, NPC_STABLE_MUNITION, 2.0f, true))
                {
                    if (munition->HasAura(SPELL_MUNITION_STABLE))
                    {
                        munition->RemoveAurasDueToSpell(SPELL_MUNITION_STABLE);
                        munition->CastSpell(munition, SPELL_MUNITION_EXPLOSION, true);
                        munition->DespawnOrUnsummon(2000);
                    }
                }

                std::list<Player*> playerList;
                GetPlayerListInGrid(playerList, me, 2.0f);

                for (auto player : playerList)
                    me->CastSpell(player, SPELL_MUNITION_EXPLOSION_DAMAGE, true);
            }
            else checkTimer -= diff;
        }
Beispiel #24
0
            void SummonBeamsEye()
            {
                if (Creature * eyeDontMover = me->SummonCreature(YELLOW_EYE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ())) // Yellow eye
                    if (Creature * tarMover = me->SummonCreature(YELLOW_EYE_MOVER, YellowEyePositions[0])) // Eyebeam target(mover)
                        eyeDontMover->CastSpell(tarMover, SPELL_YELLOW_BEAM, true);
                
                // We must use one list for two beams coz not get problem with one player for two beams
                std::list<Player*> PlayerList;
                GetPlayerListInGrid(PlayerList, me, 100.0f);

                if (!PlayerList.empty())
                    if (Creature * eyeDontMover = me->SummonCreature(RED_EYE,me->GetPositionX(), me->GetPositionY(),me->GetPositionZ()))
                        if (Player *target = JadeCore::Containers::SelectRandomContainerElement(PlayerList))
                        {
                            eyeDontMover->CastSpell(target, SPELL_RED_BEAM, true);
                            PlayerList.remove(target);
                        }
                        
                if (!PlayerList.empty()) // Check again coz we change player list before
                    if (Creature * eyeDontMover = me->SummonCreature(BLUE_EYE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()))
                        if (Player *target = JadeCore::Containers::SelectRandomContainerElement(PlayerList))
                            eyeDontMover->CastSpell(target, SPELL_BLUE_BEAM, true);
            }
Beispiel #25
0
        void UpdateAI(uint32 diff) override
        {
            if (!UpdateVictim())
                return;
            
            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            events.Update(diff);
            
            if (events.IsInPhase(PHASE_COMBAT) && me->GetPower(POWER_ENERGY) == me->GetMaxPower(POWER_ENERGY))
            {
                events.ScheduleEvent(EVENT_FURIOUS_STONE_BREATH, IN_MILLISECONDS, 0, PHASE_FURIOUS_STONE_BREATH);
                events.SetPhase(PHASE_FURIOUS_STONE_BREATH);
            }

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                    case EVENT_SNAPPING_BITE:
                        DoCastVictim(SPELL_SNAPPING_BITE);
                        events.ScheduleEvent(EVENT_SNAPPING_BITE, 8*IN_MILLISECONDS, 0, PHASE_COMBAT);
                        break;

                    case EVENT_CALL_OF_TORTOS:
                        DoCast(SPELL_CALL_OF_TORTOS);
                        events.ScheduleEvent(EVENT_CALL_OF_TORTOS, MINUTE*IN_MILLISECONDS, 0, PHASE_COMBAT);
                        break;

                    case EVENT_QUAKE_STOMP:
                        DoCast(SPELL_QUAKE_STOMP);
                        events.ScheduleEvent(EVENT_QUAKE_STOMP, 47*IN_MILLISECONDS, 0, PHASE_COMBAT);
                        break;

                    case EVENT_SUMMON_BATS:
                        events.ScheduleEvent(EVENT_SUMMON_BATS, 45*IN_MILLISECONDS, 0, PHASE_COMBAT);
                        break;

                    case EVENT_BERSERK:
                        DoCast(SPELL_BERSERK);
                        events.CancelEvent(EVENT_BERSERK);
                        break;

                    case EVENT_GROWING_FURY_RANGE:
                    {
                        std::list<Player*> playerList;
                        GetPlayerListInGrid(playerList, me, me->GetMeleeReach());

                        if (playerList.empty())
                        {
                            DoCast(SPELL_GROWING_FURY);
                            events.ScheduleEvent(EVENT_GROWING_FURY_RANGE, IN_MILLISECONDS, 0, PHASE_COMBAT);
                        }
                        else
                            events.ScheduleEvent(EVENT_GROWING_FURY_RANGE, 5*IN_MILLISECONDS, 0, PHASE_COMBAT);

                        break;
                    }

                    case EVENT_FURIOUS_STONE_BREATH:
                        DoCast(SPELL_FURIOUS_STONE_BREATH);
                        events.SetPhase(PHASE_COMBAT);

                        events.CancelEvent(EVENT_FURIOUS_STONE_BREATH);
                        break;

                    default:
                        break;
                }
            }

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

            switch (_events.ExecuteEvent())
            {
                case EVENT_CHANGE_PLACE:
                {
                    uint8 newPlace = 0;

                    do
                    {
                        newPlace = urand(0, 3);
                    }
                    while (newPlace == actualPlace);

                    me->GetMotionMaster()->MoveJump(rocksPos[newPlace].GetPositionX(), rocksPos[newPlace].GetPositionY(), rocksPos[newPlace].GetPositionZ(), 10.0f, 10.0f, 1);
                    me->AddAura(SPELL_WATER_SPOUT_WARNING, me); // Just visual
                    actualPlace = newPlace;
                    break;
                }
                case EVENT_SUMMON_WATER_SPOUT:
                {
                    float x = 0.0f, y = 0.0f;
                    GetPositionWithDistInOrientation(me, 5.0f, me->GetOrientation() + frand(-M_PI, M_PI), x, y);
                    waterSpoutGUID = 0;

                    if (Creature* waterSpout = me->SummonCreature(60488, x, y, 92.189629f))
                        waterSpoutGUID = waterSpout->GetGUID();

                    _events.ScheduleEvent(EVENT_WATER_SPOUT_VISUAL, 500);
                    _events.ScheduleEvent(EVENT_WATER_SPOUT_EJECT, 7500);
                    break;
                }
                case EVENT_WATER_SPOUT_VISUAL:
                {
                    if (Creature* waterSpout = getWaterSpout())
                        waterSpout->CastSpell(waterSpout, SPELL_WATER_SPOUT_WARNING, true);
                    break;
                }
                case EVENT_WATER_SPOUT_EJECT:
                {
                    if (Creature* waterSpout = getWaterSpout())
                    {
                        std::list<Player*> playerList;
                        GetPlayerListInGrid(playerList, waterSpout, 1.0f);

                        for (auto player: playerList)
                            player->CastSpell(player, SPELL_WATER_SPOUT_EJECT, true);

                        waterSpout->CastSpell(waterSpout, SPELL_WATER_SPOUT_VISUAL, true);
                    }
                    _events.ScheduleEvent(EVENT_WATER_SPOUT_DESPAWN, 3000);
                    break;
                }
                case EVENT_WATER_SPOUT_DESPAWN:
                {
                    if (Creature* waterSpout = getWaterSpout())
                        waterSpout->DespawnOrUnsummon();

                    waterSpoutGUID = 0;

                    _events.ScheduleEvent(EVENT_CHANGE_PLACE, 2000);
                    break;
                }
            }
        }
Beispiel #27
0
            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                {
                    if (!me->isMoving() && !me->HasAura(SPELL_ANIM_SIT))
                        me->CastSpell(me, SPELL_ANIM_SIT, true);

                    return;
                }

                events.Update(diff);

                switch(events.ExecuteEvent())
                {
                    case EVENT_CHECK_NEAR_GUARDIANS:
                    {
                        bool hasNearGardian = CheckNearGuardians();

                        if (!isInTrueForm && hasNearGardian)
                        {
                            me->RemoveAurasDueToSpell(SPELL_SOLID_STONE);
                            me->CastSpell(me, spellTrueFormId, true);
                            isInTrueForm = true;
                        }
                        else if (isInTrueForm && !hasNearGardian)
                        {
                            me->CastSpell(me, SPELL_SOLID_STONE, true);
                            me->RemoveAurasDueToSpell(spellTrueFormId);
                            isInTrueForm = false;
                        }

                        events.ScheduleEvent(EVENT_CHECK_NEAR_GUARDIANS, 2000);
                        break;
                    }
                    case EVENT_CHECK_ENERGY:
                    {
                        if (me->GetPower(POWER_ENERGY) >= me->GetMaxPower(POWER_ENERGY))
                        {
                            me->MonsterTextEmote(sSpellMgr->GetSpellInfo(spellOverloadId)->SpellName, 0, true);
                            me->CastSpell(me, spellOverloadId, false);
                            me->RemoveAurasDueToSpell(spellPetrificationId);
                            if (pInstance)
                                pInstance->DoRemoveAurasDueToSpellOnPlayers(spellPetrificationBarId);
                        }
                        else if (me->GetPower(POWER_ENERGY) >= 85 && !warnedForOverload)
                        {
                            char buf[128];
                            const char *name = me->GetName();
                            sprintf(buf, "%s is about to Overload !", name);
                            me->MonsterTextEmote(buf, 0, true);
                            warnedForOverload = true;
                        }

                        events.ScheduleEvent(EVENT_CHECK_ENERGY, 1000);
                        break;
                    }
                    case EVENT_REND_FLESH:
                    {
                        if (Unit* victim = SelectTarget(SELECT_TARGET_TOPAGGRO))
                            me->CastSpell(victim, SPELL_REND_FLESH, false);

                        events.ScheduleEvent(EVENT_REND_FLESH, urand(20000, 25000));
                        break;
                    }
                    case EVENT_MAIN_ATTACK:
                    {
                        if (isInTrueForm)
                        {
                            switch (me->GetEntry())
                            {
                                case NPC_JADE:
                                {
                                    me->CastSpell(me, SPELL_JADE_SHARDS, false);
                                    events.ScheduleEvent(EVENT_MAIN_ATTACK, 8000);
                                    break;
                                }
                                case NPC_COBALT:
                                case NPC_AMETHYST:
                                {
                                    if (Unit* victim = SelectTarget(SELECT_TARGET_RANDOM))
                                        me->CastSpell(victim, spellMainAttack, false);

                                    events.ScheduleEvent(EVENT_MAIN_ATTACK, 10000);
                                    break;
                                }
                                case NPC_JASPER:
                                {
                                    for (uint8 i = 0; i < 2; ++i)
                                    {
                                        std::list<Player*> playerList;
                                        std::list<Player*> tempPlayerList;
                                        GetPlayerListInGrid(playerList, me, 100.0f);

                                        uint64 victimGuid = 0;
                                        if (me->getVictim())
                                            victimGuid = me->getVictim()->GetGUID();

                                        for (auto player: playerList)
                                            if (player->isAlive() && !player->HasAura(SPELL_JASPER_CHAINS) && !player->HasAura(SPELL_TOTALY_PETRIFIED) && player->GetGUID() != victimGuid)
                                                tempPlayerList.push_back(player);

                                        if (tempPlayerList.size() < 2)
                                            break;

                                        JadeCore::Containers::RandomResizeList(tempPlayerList, 2);
                                    
                                        Player* firstPlayer  = *tempPlayerList.begin();
                                        Player* SecondPlayer = *(++(tempPlayerList.begin()));

                                        if (!firstPlayer || !SecondPlayer)
                                            break;

                                        if (AuraPtr aura = me->AddAura(SPELL_JASPER_CHAINS, firstPlayer))
                                            aura->SetScriptGuid(0, SecondPlayer->GetGUID());

                                        if (AuraPtr aura = me->AddAura(SPELL_JASPER_CHAINS, SecondPlayer))
                                            aura->SetScriptGuid(0, firstPlayer->GetGUID());
                                    }

                                    events.ScheduleEvent(EVENT_MAIN_ATTACK, 10000);
                                    break;
                                }
                            }
                        }

                        break;
                    }
                    case EVENT_ENRAGE:
                        me->CastSpell(me, SPELL_BERSERK, true);
                        break;
                    default:
                        break;
                }

                DoMeleeAttackIfReady();
            }