Example #1
0
        void DoAction(const int32 actionId)
        {
            if (actionId == ACTION_OUTRO)
            {
                Creature* tyrannusPtr = ObjectAccessor::GetCreature(*me, _instanceScript->GetData64(DATA_TYRANNUS_EVENT));
                if (tyrannusPtr)
                    tyrannusPtr->NearTeleportTo(outroPos[1].GetPositionX(), outroPos[1].GetPositionY(), outroPos[1].GetPositionZ(), outroPos[1].GetOrientation());
                else
                    tyrannusPtr = me->SummonCreature(NPC_TYRANNUS_EVENTS, outroPos[1], TEMPSUMMON_MANUAL_DESPAWN);

                tyrannusPtr->SetCanFly(true);
                me->GetMotionMaster()->MovePoint(POINT_KRICK_INTRO, outroPos[0].GetPositionX(), outroPos[0].GetPositionY(), outroPos[0].GetPositionZ());
                tyrannusPtr->SetFacingToObject(me);
            }
        }
        void UpdateAI(uint32 const Diff)
        {
            if (!UpdateVictim())
                return;

            // Transformation on 66% and 33% of health
            if ((me->GetHealthPct() < 66.0f && !TransformationCounter && me->GetHealthPct() > 33.0f) || (me->GetHealthPct() < 33.0f && TransformationCounter))
            {
                TransformationCounter = !TransformationCounter;

                std::list<Creature*> shadowsList;
                GetCreatureListWithEntryInGrid(shadowsList, me, NPC_SHADOW_OF_OBSIDIUS, 60.0f);
                if (shadowsList.empty())
                    return;

                std::list<Creature*>::iterator current = shadowsList.begin();
                std::advance(current, urand(0, shadowsList.size() - 1));
                Creature * toTransform = *current;

                Position Pos;
                toTransform->GetPosition(&Pos);

                toTransform->NearTeleportTo(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
                me->NearTeleportTo(Pos.GetPositionX(), Pos.GetPositionY(), Pos.GetPositionZ(), Pos.GetOrientation());

                // Needed to prevent continual visual movement on the stun
                toTransform->GetMotionMaster()->MoveIdle();
                me->GetMotionMaster()->MoveIdle();

                me->CastSpell(toTransform, SPELL_TRANSFORMATION_1, true);
                me->CastSpell(toTransform, SPELL_TRANSFORMATION_3, true);
                me->CastSpell(toTransform, SPELL_TRANSFORMATION_2, true);

                // Return to chase movement
                me->GetMotionMaster()->MoveChase(me->GetVictim());
                toTransform->GetMotionMaster()->MoveChase(me->GetVictim());

                Talk(SAY_TRANSFORM);
            }

            if (StoneBlowTimer <= Diff)
            {
                if (me->IsNonMeleeSpellCasted(false))
                    return;

                DoCastVictim(SPELL_STONE_BLOW);

                StoneBlowTimer = urand(20000, 25000);
            }
            else
                StoneBlowTimer -= Diff;

            if (TwilightCorruptionTimer <= Diff)
            {
                if (me->IsNonMeleeSpellCasted(false))
                    return;

                if (Unit * pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 60.0f, true))
                    me->CastSpell(pTarget, SPELL_TWILIGHT_CORRUPTION, false);

                TwilightCorruptionTimer = urand(20000, 25000);
            }
            else
                TwilightCorruptionTimer -= Diff;

            if (IsHeroic())
            {
                if (ThunderclapTimer <= Diff)
                {
                    if (me->IsNonMeleeSpellCasted(false))
                        return;

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

                    ThunderclapTimer = urand(20000, 25000);
                }
                else
                    ThunderclapTimer -= Diff;
            }

            DoMeleeAttackIfReady();
        }