Beispiel #1
0
        private bool CommandMobInfo(InputData i)
        {
            if (!i.Arguments.Success || i.Arguments.Groups[1].Length == 0)
            {
                World.Instance.SendMessage("@wSyntax: mobdb mobinfo <ID> [option] [value]", i.ClientMask);
                World.Instance.SendMessage("", i.ClientMask);
                World.Instance.SendMessage("@wAvailable options for mob:", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "addflag") + " @w- Add a flag to mob.",
                                           i.ClientMask);
                World.Instance.SendMessage(
                    "@W" + string.Format("{0,-15}", "removeflag") + " @w- Remove a flag from mob.", i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "name1") + " @w- Change (short)name of mob.",
                                           i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "name2") + " @w- Change second (short)name of mob.",
                                           i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "name3") + " @w- Change third (short)name of mob. (This goes all the way up to 999).",
                                           i.ClientMask);
                World.Instance.SendMessage(
                    "@W" + string.Format("{0,-15}", "areas") +
                    " @w- Set allowed areas for mob. Separate with space, enter all to allow all areas.", i.ClientMask);
                World.Instance.SendMessage(
                    "@W" + string.Format("{0,-15}", "color") + " @w- Change default color of mob name. Enter default as value to set default color from config.", i.ClientMask);
                World.Instance.SendMessage(
                    "@W" + string.Format("{0,-15}", "keywords") + " @w- Change keywords for mob.", i.ClientMask);
                World.Instance.SendMessage(
                    "@W" + string.Format("{0,-15}", "longname") + " @w- Change longname (roomname) of mob.",
                    i.ClientMask);
                World.Instance.SendMessage("@W" + string.Format("{0,-15}", "level") + " @w- Change level of mob.",
                                           i.ClientMask);
                World.Instance.SendMessage("@wEnter '@Wclear@w' as a shortname to remove that name from mob.", i.ClientMask);
                return(true);
            }

            uint mobId;

            if (!uint.TryParse(i.Arguments.Groups[1].Value, out mobId))
            {
                World.Instance.SendMessage("@wInvalid mob ID given (@R" + i.Arguments.Groups[1].Value + "@w).",
                                           i.ClientMask);
                return(true);
            }

            Mob r = GetMob(mobId);

            if (r == null)
            {
                World.Instance.SendMessage("@wNo such mob in database (@R" + mobId + "@w).", i.ClientMask);
                return(true);
            }

            if (i.Arguments.Groups[2].Length != 0)
            {
                string key, val;
                string str = i.Arguments.Groups[2].Value.Trim();
                if (str.Contains(' '))
                {
                    key = str.Substring(0, str.IndexOf(' ')).ToLower();
                    val = str.Substring(key.Length).Trim();

                    switch (key)
                    {
                    case "addflag":
                        r.AddFlag(val);
                        break;

                    case "removeflag":
                        r.RemoveFlag(val);
                        break;

                    case "name":
                        if (r.Name.Length == 0)
                        {
                            r.Name = new[] { val }
                        }
                        ;
                        else
                        {
                            r.Name[0] = val;
                        }
                        break;

                    case "level":
                    {
                        int lvl;
                        if (int.TryParse(val, out lvl))
                        {
                            r.Level = lvl;
                        }
                    } break;

                    case "areas":
                    {
                        string[] spl = val.ToLower().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        if (spl.Length > 0)
                        {
                            r.Areas = spl;
                        }
                    } break;

                    case "keywords":
                    {
                        if (val.Length > 0)
                        {
                            r.Keyword = val;
                        }
                    } break;

                    case "longname":
                    {
                        if (val == "clear")
                        {
                            r.Longname = "";
                        }
                        else
                        {
                            r.Longname = val;
                        }
                    } break;

                    case "color":
                    {
                        if (val == "clear" || val == "default" || val == "none")
                        {
                            r.DefaultColor = null;
                        }
                        else if (val.Length > 0)
                        {
                            r.DefaultColor = val;
                        }
                    } break;
                    }

                    if (key.StartsWith("name") && key.Length > 4)
                    {
                        key = key.Substring(4);
                        int nth;
                        if (int.TryParse(key, out nth) && nth >= 1)
                        {
                            nth--;
                            List <string> Names = r.Name.ToList();
                            if (nth >= r.Name.Length)
                            {
                                if (val != "clear")
                                {
                                    Names.Add(val);
                                }
                            }
                            else if (val != "clear")
                            {
                                Names[nth] = val;
                            }
                            else
                            {
                                Names.RemoveAt(nth);
                            }

                            r.Name = Names.ToArray();
                        }
                    }
                }
            }

            World.Instance.SendMessage("@w+----------------------------------------------------------------------+",
                                       i.ClientMask);
            World.Instance.SendMessage("@w| @WEntry       @w: @Y" + string.Format("{0,-55}", r.Entry) + "@w|",
                                       i.ClientMask);
            int k = 0;

            foreach (string z in r.Name)
            {
                ++k;
                string tag = "Name (" + k + ")";
                World.Instance.SendMessage(
                    "@w| @W" + string.Format("{0,-11}", tag) + " @w: @G" +
                    string.Format("{0,-55}", !string.IsNullOrEmpty(z) ? z : "Unknown") + "@w|", i.ClientMask);
            }
            string area = "";

            if (r.Areas != null)
            {
                foreach (string y in r.Areas)
                {
                    if (area.Length > 0)
                    {
                        area += " ";
                    }
                    area += y;
                }
            }
            World.Instance.SendMessage("@w| @WArea        @w: @M" + string.Format("{0,-55}", area) + "@w|", i.ClientMask);
            {
                StringBuilder strFlags = new StringBuilder();
                if (r.Flags != null)
                {
                    foreach (string x in r.Flags)
                    {
                        if (strFlags.Length > 0)
                        {
                            strFlags.Append(", ");
                        }
                        strFlags.Append(x);
                    }
                }

                string[] spl = Utility.WrapColored(strFlags.ToString(), 54, 0);
                for (int j = 0; j < spl.Length; j++)
                {
                    if (j == 0)
                    {
                        World.Instance.SendMessage("@w| @WFlags       @w: " + string.Format("{0,-55}", spl[j]) + "@w|",
                                                   i.ClientMask);
                    }
                    else
                    {
                        World.Instance.SendMessage("@w|             : " + string.Format("{0,-55}", spl[j]) + "@w|",
                                                   i.ClientMask);
                    }
                }
            }

            World.Instance.SendMessage("@w| @WLongname    @w: " + Utility.FormatColoredString(r.Longname, -55) + "@w|",
                                       i.ClientMask);
            World.Instance.SendMessage("@w| @WKeywords    @w: " + string.Format("{0,-55}", r.Keyword) + "@w|",
                                       i.ClientMask);
            World.Instance.SendMessage("@w| @WLevel       @w: @Y" + string.Format("{0,-55}", r.Level) + "@w|",
                                       i.ClientMask);

            string defColor = Config.GetString("Mob.DefaultColor", "@y");

            if (string.IsNullOrEmpty(r.DefaultColor))
            {
                defColor += "Default";
            }
            else
            {
                defColor = r.DefaultColor + r.DefaultColor.Replace("@", "@@");
            }
            World.Instance.SendMessage("@w| @WColor       @w: " + Utility.FormatColoredString(defColor, -55) + "@w|",
                                       i.ClientMask);

            World.Instance.SendMessage("@w+----------------------------------------------------------------------+",
                                       i.ClientMask);
            return(true);
        }
Beispiel #2
0
        private bool CommandWhere(InputData i)
        {
            if (!i.Arguments.Success)
            {
                World.Instance.SendMessage("@wSyntax: mobdb where <mob ID>", i.ClientMask);
                World.Instance.SendMessage("@wShows up to @W20 @wbest locations for a mob.", i.ClientMask);
                World.Instance.SendMessage("", i.ClientMask);
                World.Instance.SendMessage("        @wmobdb where <mob partial name>", i.ClientMask);
                World.Instance.SendMessage("@wShows up to @W5 @wbest locations for all mobs that match this name in current area.", i.ClientMask);
                return(true);
            }

            uint mobId;

            if (uint.TryParse(i.Arguments.Groups[1].Value, out mobId))
            {
                Mob m = GetMob(mobId);
                if (m == null)
                {
                    World.Instance.SendMessage("@wNo such mob in database (@R" + mobId + "@w).", i.ClientMask);
                    return(true);
                }

                if (!ShowLocations(m, 20, i.ClientMask, false))
                {
                    World.Instance.SendMessage("@wDon't know where '@G" + m.Names + "@w' [@Y" + m.Entry + "@w] is.", i.ClientMask);
                }
            }
            else
            {
                string n      = i.Arguments.Groups[1].Value.ToLower();
                bool   showed = false;
                foreach (KeyValuePair <uint, Mob> x in IMobs)
                {
                    if (!x.Value.Areas.Contains("all") && !x.Value.Areas.Contains(RoomInfoArea))
                    {
                        continue;
                    }

                    bool f = false;
                    foreach (string z in x.Value.Name)
                    {
                        if (!z.ToLower().Contains(n))
                        {
                            continue;
                        }

                        f = true;
                        break;
                    }

                    if (!f)
                    {
                        continue;
                    }

                    showed = ShowLocations(x.Value, 5, i.ClientMask, showed);
                }

                if (!showed)
                {
                    World.Instance.SendMessage("@wFound no mob locations with that name.", i.ClientMask);
                }
            }

            return(true);
        }