Esempio n. 1
0
        public static void LoadTitleRegistry()
        {
            DataStoreResult result = TitleRegistry.Import();

            CMOptions.ToConsole("Result: {0}", result.ToString());

            switch (result)
            {
            case DataStoreResult.Null:
            case DataStoreResult.Busy:
            case DataStoreResult.Error:
            {
                if (TitleRegistry.HasErrors)
                {
                    CMOptions.ToConsole("Titles database has errors...");

                    TitleRegistry.Errors.ForEach(CMOptions.ToConsole);
                }
            }
            break;

            case DataStoreResult.OK:
                CMOptions.ToConsole("Titles count: {0:#,0}", TitleRegistry.Count);
                break;
            }
        }
Esempio n. 2
0
        public static Title CreateTitle(
            string maleValue, string femaleValue, TitleRarity rarity, TitleDisplay display, out string result)
        {
            if (String.IsNullOrWhiteSpace(maleValue))
            {
                result = "The male title can not be whitespace.";
                return(null);
            }

            if (String.IsNullOrWhiteSpace(femaleValue))
            {
                femaleValue = maleValue;
                //result = "The female title can not be whitespace.";
                //return null;
            }

            //Allow female and male titles to be the same to specify gender neutral titles

            /*if (maleValue == femaleValue)
             * {
             *      result = "The male and female titles must differ.";
             *      return null;
             * }*/

            if (TitleRegistry.Any(x => x.Value.MaleTitle == maleValue))
            {
                result = "The male title '" + maleValue + "' already exists in the registry.";
                return(null);
            }

            if (TitleRegistry.Any(x => x.Value.FemaleTitle == femaleValue))
            {
                result = "The female title '" + femaleValue + "' already exists in the registry.";
                return(null);
            }

            var title = new Title(maleValue, femaleValue, rarity, display);

            TitleRegistry.Add(title.UID, title);

            foreach (TitleProfile p in
                     Profiles.Values.AsParallel()
                     .Where(p => p != null && p.Owner != null && p.Owner.AccessLevel >= AccessLevel.GameMaster))
            {
                p.Add(title);
            }

            result = "The title '" + title + "' was successfully added to the registry.";
            return(title);
        }
Esempio n. 3
0
        public static Title ReadTitle(GenericReader reader)
        {
            if (!reader.ReadBool())
            {
                return(null);
            }

            var uid = new TitleObjectSerial(reader);

            Title title;

            if (TitleRegistry.TryGetValue(uid, out title))
            {
                return(title);
            }

            return(null);
        }
Esempio n. 4
0
        public static bool PurgeTitle(Title title, out string result)
        {
            if (title == null)
            {
                result = "Title can not be null.";
                return(false);
            }

            foreach (TitleProfile p in Profiles.Values)
            {
                p.Remove(title);
            }

            if (!TitleRegistry.Remove(title.UID))
            {
                result = "The title '" + title + "' did not exist in the registry.";
                return(false);
            }

            result = "The title '" + title + "' has been successfully deleted.";

            return(true);
        }
Esempio n. 5
0
        private static void CMInvoke()
        {
            CommandUtility.Register(
                "AddCustomTitle",
                AccessLevel.Administrator,
                e =>
            {
                if (!(e.Mobile is PlayerMobile))
                {
                    return;
                }

                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                if (e.Arguments.Length < 2)
                {
                    e.Mobile.SendMessage(0x22, "Format: <maleTitle> <femaleTitle> [rarity]");
                    return;
                }

                string maleValue   = e.Arguments[0];
                string femaleValue = e.Arguments[1];

                var rarity = TitleRarity.Common;

                if (e.Arguments.Length > 2 && !Enum.TryParse(e.Arguments[2], true, out rarity))
                {
                    e.Mobile.SendMessage(0x22, "Format: <maleTitle> <femaleTitle> [rarity]");
                    return;
                }

                var display = TitleDisplay.BeforeName;

                if (e.Arguments.Length > 3 && !Enum.TryParse(e.Arguments[3], true, out display))
                {
                    e.Mobile.SendMessage(0x22, "Format: <maleTitle> <femaleTitle> [rarity] [display]");
                    return;
                }

                string result;

                Title title = CreateTitle(maleValue, femaleValue, rarity, display, out result);

                e.Mobile.SendMessage(title == null ? 0x22 : 0x33, result);
            });

            CommandUtility.Register(
                "AddCustomTitleHue",
                AccessLevel.Administrator,
                e =>
            {
                if (!(e.Mobile is PlayerMobile))
                {
                    return;
                }

                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                if (e.Arguments.Length == 0)
                {
                    e.Mobile.SendMessage(0x22, "Format: <hue> [rarity]");
                    return;
                }

                int value;

                if (!Int32.TryParse(e.Arguments[0], out value))
                {
                    e.Mobile.SendMessage(0x22, "Format: <hue> [rarity]");
                    return;
                }

                var rarity = TitleRarity.Common;

                if (e.Arguments.Length > 1 && !Enum.TryParse(e.Arguments[1], true, out rarity))
                {
                    e.Mobile.SendMessage(0x22, "Format: <hue> [rarity]");
                    return;
                }

                string result;

                TitleHue hue = CreateHue(value, rarity, out result);

                e.Mobile.SendMessage(hue == null ? 0x22 : 0x33, result);
            });

            CommandUtility.Register(
                "WipeCustomTitles",
                AccessLevel.Administrator,
                e =>
            {
                if (!(e.Mobile is PlayerMobile))
                {
                    return;
                }

                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                new ConfirmDialogGump((PlayerMobile)e.Mobile)
                {
                    Title = "Confirm Action: Wipe",
                    Html  =
                        "This action will wipe all titles, title hues and title profiles.\nThis action can not be reversed!\n\nClick OK to confirm.",
                    AcceptHandler = b =>
                    {
                        Profiles.Values.ForEach(p => VitaNexCore.TryCatch(p.Clear));
                        Profiles.Clear();
                        e.Mobile.SendMessage("All title profiles have been cleared.");

                        HueRegistry.Values.ForEach(h => VitaNexCore.TryCatch(h.Clear));
                        HueRegistry.Clear();
                        e.Mobile.SendMessage("All title hues have been cleared.");

                        TitleRegistry.Values.ForEach(t => VitaNexCore.TryCatch(t.Clear));
                        TitleRegistry.Clear();
                        e.Mobile.SendMessage("All titles have been cleared.");
                    }
                }.Send();
            });

            CommandUtility.Register(
                "GrantCustomTitles",
                AccessLevel.Administrator,
                e =>
            {
                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                GrantTitlesTarget(e.Mobile as PlayerMobile);
            });

            CommandUtility.Register(
                "RevokeCustomTitles",
                AccessLevel.Administrator,
                e =>
            {
                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                RevokeTitlesTarget(e.Mobile as PlayerMobile);
            });

            CommandUtility.Register(
                "pg",
                AccessLevel.Player,
                e =>
            {
                if (e.Mobile is PlayerMobile && e.Mobile.Map != Map.ZombieLand)
                {
                    var player = e.Mobile as PlayerMobile;
                    if (player.RawName == "Savo-" || player.RawName == "Savo" || player.RawName == "Tsavo" ||
                        player.RawName == "a evil savo" || player.RawName == "a pirate savo" || player.RawName == "Tsavo-")
                    {
                        player.Frozen = true;
                        if (!player.Mounted)
                        {
                            player.Animate(239, 7, 1, true, false, 0);
                        }
                        player.PublicOverheadMessage(MessageType.Spell, player.SpeechHue, true, "Kal Ort Por", false);
                        Timer.DelayCall(TimeSpan.FromSeconds(0.75 + (0.25 * 3)), () =>
                        {
                            player.Frozen = false;
                            player.Hidden = true;
                            BaseCreature.TeleportPets(player, new Point3D(2977, 2893, -4), Map.Felucca, false);
                            player.MoveToWorld(new Point3D(2977, 2893, -4), Map.Felucca);
                        });
                    }
                }
            });

            CommandUtility.Register(
                "he",
                AccessLevel.Player,
                e =>
            {
                if (e.Mobile is PlayerMobile && e.Mobile.Map != Map.ZombieLand)
                {
                    var player = e.Mobile as PlayerMobile;
                    if (player.RawName == "Savo-" || player.RawName == "Savo" || player.RawName == "Tsavo" ||
                        player.RawName == "a evil savo" || player.RawName == "a pirate savo" || player.RawName == "Tsavo-")
                    {
                        player.Frozen = true;
                        if (!player.Mounted)
                        {
                            player.Animate(239, 7, 1, true, false, 0);
                        }
                        player.PublicOverheadMessage(MessageType.Spell, player.SpeechHue, true, "Kal Ort Por", false);
                        Timer.DelayCall(TimeSpan.FromSeconds(0.75 + (0.25 * 3)), () =>
                        {
                            player.Frozen = false;
                            player.Hidden = true;
                            BaseCreature.TeleportPets(player, new Point3D(2318, 3755, 0), Map.Felucca, false);
                            player.MoveToWorld(new Point3D(2318, 3755, 0), Map.Felucca);
                        });
                    }
                }
            });

            CommandUtility.Register(
                "CustomTitles",
                AccessLevel.Player,
                e =>
            {
                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                SendTitlesGump(e.Mobile as PlayerMobile);
            });

            CommandUtility.Register(
                "ConvertMetaDragons",
                AccessLevel.Developer,
                e =>
            {
                foreach (Mobile mob in World.Mobiles.Values.Where(x => x is EvolutionDragon).ToArray())
                {
                    var dragon = mob as EvolutionDragon;
                    if (dragon != null)
                    {
                        var newmeta           = new MetaDragon();
                        newmeta.Location      = dragon.Location;
                        newmeta.Map           = dragon.Map;
                        newmeta.Loyalty       = 100;
                        newmeta.ControlMaster = dragon.ControlMaster;
                        newmeta.Controlled    = true;
                        newmeta.ControlTarget = null;
                        newmeta.ControlOrder  = OrderType.Come;
                        newmeta.IsBonded      = true;
                        newmeta.Hue           = dragon.Hue;
                        newmeta.RawStr        = dragon.RawStr;
                        newmeta.RawDex        = dragon.RawDex;
                        newmeta.RawInt        = dragon.RawInt;
                        newmeta.Name          = dragon.Name;

                        newmeta.Stage           = dragon.Stage;
                        newmeta.MaxStage        = 7;
                        newmeta.EvolutionPoints = dragon.EvolutionPoints;

                        newmeta.Metaskills = new Dictionary <MetaSkillType, BaseMetaSkill>();

                        dragon.Delete();
                    }
                }
            });

            CommandUtility.Register(
                "GetAllItems",
                AccessLevel.Developer,
                e =>
            {
                var itemsdict = new Dictionary <int, int>();
                foreach (Item item in World.Items.Values.Where(x => x.Movable || x.IsLockedDown).ToArray())
                {
                    if (itemsdict.ContainsKey(item.ItemID))
                    {
                        itemsdict[item.ItemID]++;
                    }
                    else
                    {
                        itemsdict.Add(item.ItemID, 1);
                    }
                }

                foreach (KeyValuePair <int, int> kvp in itemsdict.OrderBy(i => i.Value))
                {
                    var sb = new StringBuilder();

                    sb.Append("ItemID: " + kvp.Key + "---------------Count: " + kvp.Value + "\n");
                    LoggingCustom.Log("ItemsLog/" + IOUtility.GetSafeFileName("Itemslog") + ".log", sb.ToString());
                }
            });

            CommandUtility.RegisterAlias("CustomTitles", "Titles");

            CommandUtility.Register("FlameSpiral", AccessLevel.GameMaster, e => BeginTarget(e.Mobile));
            CommandUtility.Register("FlashEffect", AccessLevel.GameMaster, e => DoFlash(e.Mobile));
            CommandUtility.Register("UpgradeAccounts", AccessLevel.Developer, e => UpgradeAccounts());
            CommandUtility.Register("LockedDownFix", AccessLevel.Developer, e => LockedDownFix());
        }