示例#1
0
        static bool UnAura(StringArguments args, CommandHandler handler)
        {
            Unit target = handler.GetSelectedUnit();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.SelectCharOrCreature);

                return(false);
            }

            string argstr = args.NextString();

            if (argstr == "all")
            {
                target.RemoveAllAuras();
                return(true);
            }

            // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
            uint spellId = handler.ExtractSpellIdFromLink(args);

            if (spellId == 0)
            {
                return(false);
            }

            target.RemoveAurasDueToSpell(spellId);

            return(true);
        }
示例#2
0
        static bool HandleModifyMorphCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            uint display_id = args.NextUInt32();

            Unit target = handler.GetSelectedUnit();

            if (!target)
            {
                target = handler.GetSession().GetPlayer();
            }

            // check online security
            else if (target.IsTypeId(TypeId.Player) && handler.HasLowerSecurity(target.ToPlayer(), ObjectGuid.Empty))
            {
                return(false);
            }

            target.SetDisplayId(display_id);

            return(true);
        }
示例#3
0
        static bool HandleAuraCommand(StringArguments args, CommandHandler handler)
        {
            Unit target = handler.GetSelectedUnit();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.SelectCharOrCreature);

                return(false);
            }

            // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
            uint spellId = handler.ExtractSpellIdFromLink(args);

            SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, target.GetMap().GetDifficultyID());

            if (spellInfo != null)
            {
                ObjectGuid     castId     = ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, target.GetMapId(), spellId, target.GetMap().GenerateLowGuid(HighGuid.Cast));
                AuraCreateInfo createInfo = new(castId, spellInfo, target.GetMap().GetDifficultyID(), SpellConst.MaxEffectMask, target);
                createInfo.SetCaster(target);

                Aura.TryRefreshStackOrCreate(createInfo);
            }

            return(true);
        }
示例#4
0
        static bool HandleCastSelfCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            Unit target = handler.GetSelectedUnit();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.SelectCharOrCreature);
                return(false);
            }

            // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
            uint spellId = handler.ExtractSpellIdFromLink(args);

            if (spellId == 0)
            {
                return(false);
            }

            if (!CheckSpellExistsAndIsValid(handler, spellId))
            {
                return(false);
            }

            target.CastSpell(target, spellId, false);

            return(true);
        }
示例#5
0
        static bool HandleCastCommand(CommandHandler handler, SpellInfo spell, string triggeredStr)
        {
            Unit target = handler.GetSelectedUnit();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.SelectCharOrCreature);
                return(false);
            }

            if (!CheckSpellExistsAndIsValid(handler, spell))
            {
                return(false);
            }

            TriggerCastFlags triggerFlags = TriggerCastFlags.None;

            if (!triggeredStr.IsEmpty())
            {
                if ("triggered".Contains(triggeredStr)) // check if "triggered" starts with *triggeredStr (e.g. "trig", "trigger", etc.)
                {
                    triggerFlags = TriggerCastFlags.FullDebugMask;
                }
                else
                {
                    return(false);
                }
            }

            handler.GetSession().GetPlayer().CastSpell(target, spell.Id, new CastSpellExtraArgs(triggerFlags));
            return(true);
        }
示例#6
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);
        }
示例#7
0
        static bool HandleCooldownCommand(StringArguments args, CommandHandler handler)
        {
            Unit target = handler.GetSelectedUnit();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.PlayerNotFound);
                return(false);
            }

            Player owner = target.GetCharmerOrOwnerPlayerOrPlayerItself();

            if (!owner)
            {
                owner  = handler.GetSession().GetPlayer();
                target = owner;
            }

            string nameLink = handler.GetNameLink(owner);

            if (args.Empty())
            {
                target.GetSpellHistory().ResetAllCooldowns();
                target.GetSpellHistory().ResetAllCharges();
                handler.SendSysMessage(CypherStrings.RemoveallCooldown, nameLink);
            }
            else
            {
                // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
                uint spellIid = handler.ExtractSpellIdFromLink(args);
                if (spellIid == 0)
                {
                    return(false);
                }

                SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellIid, target.GetMap().GetDifficultyID());
                if (spellInfo == null)
                {
                    handler.SendSysMessage(CypherStrings.UnknownSpell, owner == handler.GetSession().GetPlayer() ? handler.GetCypherString(CypherStrings.You) : nameLink);
                    return(false);
                }

                target.GetSpellHistory().ResetCooldown(spellIid, true);
                target.GetSpellHistory().ResetCharges(spellInfo.ChargeCategoryId);
                handler.SendSysMessage(CypherStrings.RemoveallCooldown, spellIid, owner == handler.GetSession().GetPlayer() ? handler.GetCypherString(CypherStrings.You) : nameLink);
            }
            return(true);
        }
示例#8
0
        static bool HandleCastDestCommand(StringArguments args, CommandHandler handler)
        {
            Unit caster = handler.GetSelectedUnit();

            if (!caster)
            {
                handler.SendSysMessage(CypherStrings.SelectCharOrCreature);
                return(false);
            }

            // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
            uint spellId = handler.ExtractSpellIdFromLink(args);

            if (spellId == 0)
            {
                return(false);
            }

            if (CheckSpellExistsAndIsValid(handler, spellId))
            {
                return(false);
            }

            float x = args.NextSingle();
            float y = args.NextSingle();
            float z = args.NextSingle();

            if (x == 0f || y == 0f || z == 0f)
            {
                return(false);
            }

            string triggeredStr = args.NextString();

            if (!string.IsNullOrEmpty(triggeredStr))
            {
                if (triggeredStr != "triggered")
                {
                    return(false);
                }
            }

            bool triggered = (triggeredStr != null);

            caster.CastSpell(x, y, z, spellId, triggered);

            return(true);
        }
示例#9
0
        static bool HandleDeMorphCommand(StringArguments args, CommandHandler handler)
        {
            Unit target = handler.GetSelectedUnit();

            if (!target)
            {
                target = handler.GetSession().GetPlayer();
            }

            // check online security
            else if (target.IsTypeId(TypeId.Player) && handler.HasLowerSecurity(target.ToPlayer(), ObjectGuid.Empty))
            {
                return(false);
            }

            target.DeMorph();

            return(true);
        }
示例#10
0
        static bool HandleCastCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            Unit target = handler.GetSelectedUnit();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.SelectCharOrCreature);
                return(false);
            }

            // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
            uint spellId = handler.ExtractSpellIdFromLink(args);

            if (spellId == 0)
            {
                return(false);
            }

            if (!CheckSpellExistsAndIsValid(handler, spellId))
            {
                return(false);
            }

            string triggeredStr = args.NextString();

            if (!string.IsNullOrEmpty(triggeredStr))
            {
                if (triggeredStr != "triggered")
                {
                    return(false);
                }
            }

            handler.GetSession().GetPlayer().CastSpell(target, spellId, !triggeredStr.IsEmpty());
            return(true);
        }
示例#11
0
        static bool HandleModifyScaleCommand(StringArguments args, CommandHandler handler)
        {
            float Scale;
            Unit  target = handler.GetSelectedUnit();

            if (CheckModifySpeed(args, handler, target, out Scale, 0.1f, 10.0f, false))
            {
                NotifyModification(handler, target, CypherStrings.YouChangeSize, CypherStrings.YoursSizeChanged, Scale);
                Creature creatureTarget = target.ToCreature();
                if (creatureTarget)
                {
                    creatureTarget.SetDisplayId(creatureTarget.GetDisplayId(), Scale);
                }
                else
                {
                    target.SetObjectScale(Scale);
                }
                return(true);
            }
            return(false);
        }
示例#12
0
        static Pet GetSelectedPlayerPetOrOwn(CommandHandler handler)
        {
            Unit target = handler.GetSelectedUnit();

            if (target)
            {
                if (target.IsTypeId(TypeId.Player))
                {
                    return(target.ToPlayer().GetPet());
                }
                if (target.IsPet())
                {
                    return(target.ToPet());
                }
                return(null);
            }

            Player player = handler.GetSession().GetPlayer();

            return(player ? player.GetPet() : null);
        }
示例#13
0
        static bool PathCommand(StringArguments args, CommandHandler handler)
        {
            if (Global.MMapMgr.GetNavMesh(handler.GetPlayer().GetMapId()) == null)
            {
                handler.SendSysMessage("NavMesh not loaded for current map.");
                return(true);
            }

            handler.SendSysMessage("mmap path:");

            // units
            Player player = handler.GetPlayer();
            Unit   target = handler.GetSelectedUnit();

            if (player == null || target == null)
            {
                handler.SendSysMessage("Invalid target/source selection.");
                return(true);
            }

            string para = args.NextString();

            bool useStraightPath = false;

            if (para.Equals("true"))
            {
                useStraightPath = true;
            }

            bool useStraightLine = false;

            if (para.Equals("line"))
            {
                useStraightLine = true;
            }

            // unit locations
            float x, y, z;

            player.GetPosition(out x, out y, out z);

            // path
            PathGenerator path = new PathGenerator(target);

            path.SetUseStraightPath(useStraightPath);
            bool result = path.CalculatePath(x, y, z, false, useStraightLine);

            var pointPath = path.GetPath();

            handler.SendSysMessage("{0}'s path to {1}:", target.GetName(), player.GetName());
            handler.SendSysMessage("Building: {0}", useStraightPath ? "StraightPath" : useStraightLine ? "Raycast" : "SmoothPath");
            handler.SendSysMessage("Result: {0} - Length: {1} - Type: {2}", (result ? "true" : "false"), pointPath.Length, path.GetPathType());

            var start     = path.GetStartPosition();
            var end       = path.GetEndPosition();
            var actualEnd = path.GetActualEndPosition();

            handler.SendSysMessage("StartPosition     ({0:F3}, {1:F3}, {2:F3})", start.X, start.Y, start.Z);
            handler.SendSysMessage("EndPosition       ({0:F3}, {1:F3}, {2:F3})", end.X, end.Y, end.Z);
            handler.SendSysMessage("ActualEndPosition ({0:F3}, {1:F3}, {2:F3})", actualEnd.X, actualEnd.Y, actualEnd.Z);

            if (!player.IsGameMaster())
            {
                handler.SendSysMessage("Enable GM mode to see the path points.");
            }

            for (uint i = 0; i < pointPath.Length; ++i)
            {
                player.SummonCreature(1, pointPath[i].X, pointPath[i].Y, pointPath[i].Z, 0, TempSummonType.TimedDespawn, 9000);
            }

            return(true);
        }