Exemple #1
0
        static bool HandleModifyPhaseCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            uint phaseId      = args.NextUInt32();
            uint visibleMapId = args.NextUInt32();

            if (phaseId != 0 && !CliDB.PhaseStorage.ContainsKey(phaseId))
            {
                handler.SendSysMessage(CypherStrings.PhaseNotfound);
                return(false);
            }

            Unit target = handler.GetSelectedUnit();

            if (visibleMapId != 0)
            {
                MapRecord visibleMap = CliDB.MapStorage.LookupByKey(visibleMapId);
                if (visibleMap == null || visibleMap.ParentMapID != target.GetMapId())
                {
                    handler.SendSysMessage(CypherStrings.PhaseNotfound);
                    return(false);
                }

                if (!target.GetPhaseShift().HasVisibleMapId(visibleMapId))
                {
                    PhasingHandler.AddVisibleMapId(target, visibleMapId);
                }
                else
                {
                    PhasingHandler.RemoveVisibleMapId(target, visibleMapId);
                }
            }

            if (phaseId != 0)
            {
                if (!target.GetPhaseShift().HasPhase(phaseId))
                {
                    PhasingHandler.AddPhase(target, phaseId, true);
                }
                else
                {
                    PhasingHandler.RemovePhase(target, phaseId, true);
                }
            }

            return(true);
        }
        public override void SpellHitTarget(Unit target, SpellInfo spell)
        {
            if (spell.Id == SpellIds.Insanity)
            {
                // Not good target or too many players
                if (target.GetTypeId() != TypeId.Player || insanityHandled > 4)
                {
                    return;
                }
                // First target - start channel visual and set self as unnattackable
                if (insanityHandled == 0)
                {
                    // Channel visual
                    DoCast(me, SpellIds.InsanityVisual, true);
                    // Unattackable
                    me.AddUnitFlag(UnitFlags.NotSelectable);
                    me.SetControlled(true, UnitState.Stunned);
                }

                // phase the player
                target.CastSpell(target, SpellIds.InsanityTarget + insanityHandled, true);

                SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.InsanityTarget + insanityHandled, GetDifficulty());
                if (spellInfo == null)
                {
                    return;
                }

                // summon twisted party members for this target
                var players = me.GetMap().GetPlayers();
                foreach (var player in players)
                {
                    if (!player || !player.IsAlive())
                    {
                        continue;
                    }
                    // Summon clone
                    Unit summon = me.SummonCreature(AKCreatureIds.TwistedVisage, me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), me.GetOrientation(), TempSummonType.CorpseDespawn, 0);
                    if (summon)
                    {
                        // clone
                        player.CastSpell(summon, SpellIds.ClonePlayer, true);
                        // phase the summon
                        PhasingHandler.AddPhase(summon, (uint)spellInfo.GetEffect(0).MiscValueB, true);
                    }
                }
                ++insanityHandled;
            }
        }
        public override void Reset()
        {
            Initialize();

            instance.SetBossState(DataTypes.HeraldVolazj, EncounterState.NotStarted);
            instance.DoStopCriteriaTimer(CriteriaTimedTypes.Event, Misc.AchievQuickDemiseStartEvent);

            // Visible for all players in insanity
            for (uint i = 173; i <= 177; ++i)
            {
                PhasingHandler.AddPhase(me, i, false);
            }
            PhasingHandler.AddPhase(me, 169, true);

            ResetPlayersPhase();

            // Cleanup
            Summons.DespawnAll();
            me.RemoveUnitFlag(UnitFlags.NotSelectable);
            me.SetControlled(false, UnitState.Stunned);
        }