void EnterCombat(Unit* u)
            {
                if (!pInstance)
                    return;

                me->CastSpell(me, SPELL_GATHERING_DOUBT, false);
                events.ScheduleEvent(EVENT_GATHERING_DOUBT, 1000);
                
                events.ScheduleEvent(EVENT_SIPHON_ESSENCE, 8000);
                switch (_class)
                {
                    case CLASS_DPS:
                        events.ScheduleEvent(EVENT_SPELL_FURY, 5000);
                        events.ScheduleEvent(EVENT_BLADE_SONG, 13000);
                        events.ScheduleEvent(EVENT_GLIMPSE_OF_MADNESS, 8000);
                        break;
                    case CLASS_HEAL:
                        events.ScheduleEvent(EVENT_SPELL_PHANTOM_STRIKE, 20000);
                        events.ScheduleEvent(EVENT_STUN, 7000);
                        break;
                    case CLASS_TANK:
                        events.ScheduleEvent(EVENT_SPELL_ARMOR_BUFF, 10000);
                        events.ScheduleEvent(EVENT_SANCTUARY, 10000);
                        events.ScheduleEvent(EVENT_STUN, 7000);
                        break;
                }

                Creature* sha = me->GetMap()->GetCreature(pInstance->GetObjectGuid(pInstance->GetData64(CREATURE_SHA_OF_DOUBT)));
                if(sha && sha->GetAI())
                    sha->GetAI()->DoAction(ACTION_FIGMENT_POP);
            }
            void JustDied(Unit* killer)
            {
                if (!pInstance)
                    return;

                me->CastSpell(me, SPELL_DROWNED_STATE, false);
                me->RemoveAura(SPELL_GATHERING_DOUBT);
                me->DespawnOrUnsummon(5000);
                Creature* sha = me->GetMap()->GetCreature(pInstance->GetObjectGuid(pInstance->GetData64(CREATURE_SHA_OF_DOUBT)));
                if(sha && sha->GetAI())
                    sha->GetAI()->DoAction(ACTION_FIGMENT_DIED);
            }
            void Reset()
            {
                if (!pInstance)
                    return;

                me->CastSpell(me, SPELL_GROW, false);

                Player* owner = NULL;

                if (TempSummon* tempMe = me->ToTempSummon())
                    if (Unit* summoner = tempMe->GetSummoner())
                        owner = summoner->ToPlayer();

                if (!owner)
                    return;

                me->SetDisplayId(owner->GetDisplayId()); // A check au cas où ça crasherait
                
                uint8 role = lfg::PLAYER_ROLE_DAMAGE;

                if(owner && owner->GetGroup())
                   // role = owner->GetGroup()->GetMemberRole(GetGUID(owner->GetGUID()));
                    role = owner->GetGroup()->GetLfgRoles(owner->GetGUID());

                if (role & lfg::PLAYER_ROLE_DAMAGE)
                    _class = CLASS_DPS;
                else if (role & lfg::PLAYER_ROLE_HEALER)
                    _class = CLASS_HEAL;
                else if (role & lfg::PLAYER_ROLE_TANK)
                    _class = CLASS_TANK;

                owner->CastSpell(me, SPELL_FIGMENT_OF_DOUBT_2, true);

                Creature* sha = me->GetMap()->GetCreature(pInstance->GetObjectGuid(pInstance->GetData64(CREATURE_SHA_OF_DOUBT)));
                if(sha && sha->GetAI())
                    sha->GetAI()->DoAction(ACTION_FIGMENT_POP);
            }
            void UpdateAI(uint32 diff)
            {
                if (!pInstance)
                    return;

                if (!UpdateVictim())
                    return;

                events.Update(diff);

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_GATHERING_DOUBT:
                        {
                            if (me->GetAuraCount(SPELL_GATHERING_DOUBT_2) == 30)
                            {
                                me->CastSpell(me, SPELL_RELEASE_DOUBT, false);
                                me->RemoveAura(SPELL_GATHERING_DOUBT);
                                me->DealDamage(me, me->GetMaxHealth());

                                me->DespawnOrUnsummon(5000);

                                uint64 guid_sha_of_doubt = pInstance->GetData64(CREATURE_SHA_OF_DOUBT);
                                if (guid_sha_of_doubt != 0)
                                {
                                    Creature* creature = me->GetMap()->GetCreature(pInstance->GetObjectGuid(guid_sha_of_doubt));
                                    if (!creature)
                                        return;

                                    const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(SPELL_RELEASE_DOUBT);
                                    if (!spellInfo)
                                        return;

                                    creature->CastSpell(creature, SPELL_CHI_WAVE, true);
                                    me->HealBySpell(creature, spellInfo, uint32(float(creature->GetMaxHealth())* 0.1f));
                                }
                            }
                            else
                                events.ScheduleEvent(EVENT_GATHERING_DOUBT, 1000);
                            break;
                        }
                        case EVENT_SPELL_PHANTOM_STRIKE:
                        {
                            me->CastSpell(me->GetVictim(), 9806, false);
                            events.ScheduleEvent(EVENT_SPELL_PHANTOM_STRIKE, 20000);
                            break;
                        }
                        case EVENT_SPELL_ARMOR_BUFF:
                        {
                            me->CastSpell(me, 34199, false);
                            events.ScheduleEvent(EVENT_SPELL_ARMOR_BUFF, 10000);
                            break;
                        }
                        case EVENT_SPELL_FURY:
                        {
                            me->CastSpell(me, 15494, false);
                            events.ScheduleEvent(EVENT_SPELL_FURY, 5000);
                            break;
                        }
                        case EVENT_SANCTUARY:
                        {
                            me->CastSpell(me, 69207, false);
                            events.ScheduleEvent(EVENT_SANCTUARY, 10000);
                            break;
                        }
                        case EVENT_SIPHON_ESSENCE:
                        {
                            me->CastSpell(me, 40291, false);
                            events.ScheduleEvent(EVENT_SIPHON_ESSENCE, 8000);
                            break;
                        }
                        case EVENT_STUN:
                        {
                            me->CastSpell(me->GetVictim(), 23454, false);
                            events.ScheduleEvent(EVENT_STUN, 7000);
                            break;
                        }
                        case EVENT_BLADE_SONG:
                        {
                            me->CastSpell(me, 38282, false);
                            events.ScheduleEvent(EVENT_BLADE_SONG, 13000);
                            break;
                        }
                        case EVENT_UNTAMED_FURY:
                        {
                            me->CastSpell(me, 23719, false);
                            events.ScheduleEvent(EVENT_UNTAMED_FURY, 9000);
                            break;
                        }
                        case EVENT_GLIMPSE_OF_MADNESS:
                        {
                            me->CastSpell(me->GetVictim(), 26108, false);
                            events.ScheduleEvent(EVENT_GLIMPSE_OF_MADNESS, 8000);
                            break;
                        }
                    }
                }

                DoMeleeAttackIfReady();
            }