void TimedFleeingMovementGenerator::Finalize(Unit &owner)
{
    owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
    owner.clearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_ROAMING);
    if (Unit* victim = owner.getVictim())
    {
        if (owner.isAlive())
        {
            owner.AttackStop();
            ((Creature*)&owner)->AI()->AttackStart(victim);
        }
    }
}
Example #2
0
 void MovementInform(uint32 type, uint32 id)
 {
     if (type == POINT_MOTION_TYPE && id == 1)
     {
         Unit* CrystalChosen = Unit::GetUnit(*me, CrystalGUID);
         if (CrystalChosen && CrystalChosen->isAlive())
         {
             // Make the crystal attackable
             // We also remove NON_ATTACKABLE in case the database has it set.
             CrystalChosen->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE);
             CrystalChosen->CastSpell(me, SPELL_MANA_RAGE, true);
             IsDraining = true;
         }
         else
         {
             // Make an error message in case something weird happened here
             sLog->outError("TSCR: Selin Fireheart unable to drain crystal as the crystal is either dead or despawned");
             DrainingCrystal = false;
         }
     }
 }
Example #3
0
        void UpdateAI(const uint32 diff)
        {
            if(!UpdateVictim())
                return;

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

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

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

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

                Check_Timer = 5000;
            } else Check_Timer -= diff;

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

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

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

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

                WasDead=true;
            }

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

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

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

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

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

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

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

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

            DoMeleeAttackIfReady();

        }