private static void CreateElement(WorldClient client, int elementId, ushort skillId, string actionType, string value1, string value2)
        {
            SkillRecord skill       = SkillRecord.Skills.Find(rec => rec.Id == skillId);
            ushort      elementType = skill.InteractiveId;

            InteractiveElementsUtils.CreateInteractiveElement(new NewElementData(client.Character.Map.Id, elementId, elementType, actionType, skillId, value1, value2), client);

            client.Character.Reply($"Element <i>{actionType}</i> Successfully added with skill <i>{skill.Name}</i>.");
        }
        public static void AddMineWay(WorldClient client, string[] args)
        {
            if (args.Length < 2)
            {
                if (args.Length != 1)
                {
                    client.Character.ReplyError("Invalid command.");
                }

                client.Character.Reply("Add a mine way.");
                client.Character.Reply("» .elements|el mineway|mw $ElementId");
                client.Character.Reply(" - <b>$ElementId</b> ⇒ The element id (see .elements).");

                return;
            }

            int    elementId   = int.Parse(args[1]); // [0] = command name
            int    spawnCellId = client.Character.CellId;
            int    elementType = 282;
            ushort skillId     = 339;

            int currentMapId = client.Character.Map.Id;

            int exitsCount   = LinkItem.Exits.Count;
            int entriesCount = LinkItem.Entries.Count;


            if (exitsCount != 0 && entriesCount <= 1)
            {
                client.Character.ReplyError($"Cannot perform action, Entries and Exits lists must be empty. Entries: {entriesCount}, Exits: {exitsCount}");
                return;
            }

            if (exitsCount == 0 && entriesCount == 0)
            {
                LinkItem.InitEntry(currentMapId, elementId, elementType, skillId, spawnCellId);
                client.Character.Reply("Added mineway. Register another to link them.");
            }
            else
            {
                LinkItem entryItem = LinkItem.Entries.First();

                // On the map <mapid>, the element <elementid> which is a <elementtype>, will "Teleport" you if you Use (=114) it, to the map <mapid> on the cell <cellid>
                NewElementData entryData = new NewElementData(entryItem.MapId, entryItem.ElementId, entryItem.ElementType, "Teleport", entryItem.SkillId, currentMapId.ToString(), spawnCellId.ToString());
                // On the map <mapid>, the element <elementid> which is a <elementtype>, will "Teleport" you if you walk on it (as it's a exit =339), to the map <mapid> on the cell <cellid>
                NewElementData exitData = new NewElementData(currentMapId, elementId, elementType, "Teleport", skillId, entryItem.MapId.ToString(), entryItem.SpawnCellId.ToString());

                InteractiveElementsUtils.CreateInteractiveElement(entryData, client);
                InteractiveElementsUtils.CreateInteractiveElement(exitData, client);

                LinkItem.Entries.Clear();
                client.Character.Reply($"Successfully linked maps {entryItem.MapId} and {currentMapId}.");
            }
        }
Esempio n. 3
0
        public static void Run(string value, WorldClient client)
        {
            if (value == null)
            {
                client.Character.Reply("Link two maps using a previously created entry and exit. Related cmds: .addentry, .addexit");
                client.Character.Reply("» .link auto ⇒ Works if there's exactly one entry and one exit.");
                client.Character.Reply("» .link $EntryElementId $ExitElementId");
                client.Character.Reply(" - <b>$EntryElementId</b> ⇒ The ElementId of the entry.");
                client.Character.Reply(" - <b>$ExitElementId</b> ⇒ The ElementId of the exit.");

                return;
            }

            LinkItem entryItem;
            LinkItem exitItem;

            var split = value.Trim().Split(' ');

            if (split.Length >= 1 && split[0].ToLower().Equals("auto"))
            {
                if (LinkItem.Entries.Count == 1 && LinkItem.Exits.Count == 1 ||
                    LinkItem.Entries.Count > 0 && LinkItem.Exits.Count > 0 && split.Length > 1 && split[1].ToLower().Equals("-f"))
                {
                    entryItem = LinkItem.Entries.First();
                    exitItem  = LinkItem.Exits.First();
                }
                else
                {
                    client.Character.ReplyError($"Can't create auto link. Entries: {LinkItem.Entries.Count}, Exits: {LinkItem.Exits.Count}.");
                    return;
                }
            }
            else
            {
                if (split.Length != 2)
                {
                    client.Character.ReplyError("Invalid command.");
                    return;
                }

                int entryId = int.Parse(split[0]);
                int exitId  = int.Parse(split[1]);

                if (!LinkItem.Entries.Exists(e => e.ElementId == entryId))
                {
                    client.Character.ReplyError($"Error: Entry with ElementId={entryId} does not exist. Maybe you haven't created it yet? Check cmd .addentry.");

                    return;
                }

                if (!LinkItem.Exits.Exists(e => e.ElementId == exitId))
                {
                    client.Character.ReplyError($"Error: Exit with ElementId={exitId} does not exist. Maybe you haven't created it yet? Check cmd .addentry.");

                    return;
                }


                entryItem = LinkItem.Entries.Find(e => e.ElementId == entryId);
                exitItem  = LinkItem.Exits.Find(e => e.ElementId == exitId);
            }

            // On the map <mapid>, the element <elementid> which is a <elementtype>, will "Teleport" you if you Use (=114) it, to the map <mapid> on the cell <cellid>
            var entryElementData = new NewElementData(entryItem.MapId, entryItem.ElementId, entryItem.ElementType, "Teleport", entryItem.SkillId, exitItem.MapId.ToString(), exitItem.SpawnCellId.ToString());
            // On the map <mapid>, the element <elementid> which is a <elementtype>, will "Teleport" you if you walk on it (as it's a exit =339), to the map <mapid> on the cell <cellid>
            var exitElementData = new NewElementData(exitItem.MapId, exitItem.ElementId, exitItem.ElementType, "Teleport", exitItem.SkillId, entryItem.MapId.ToString(), entryItem.SpawnCellId.ToString());

            InteractiveElementsUtils.CreateInteractiveElement(entryElementData, client);
            InteractiveElementsUtils.CreateInteractiveElement(exitElementData, client);


            client.Character.Reply($"Successfully linked maps {entryItem.MapId} and {exitItem.MapId}.");

            LinkItem.Entries.Remove(entryItem);
            LinkItem.Exits.Remove(exitItem);
        }