Пример #1
0
        public void RequestTeleportList(L2Npc npc, L2Player player, int groupId, int itemId)
        {
            if (!_teleports.Npcs.ContainsKey(npc.Template.NpcId))
            {
                player.ShowHtmPlain("no teleports available for you", npc);
                player.SendActionFailed();
                return;
            }

            ABTeleportGroup group = _teleports.Npcs[npc.Template.NpcId].Groups[groupId];
            StringBuilder   sb    = new StringBuilder("&$556;<br><br>");

            foreach (ABTeleportEntry e in group.Teles.Values)
            {
                string cost = string.Empty;
                int    id   = itemId != -1 ? itemId : e.ItemId;
                if (player.Level >= 40)
                {
                    cost = $" - {e.Cost} &#{id};";
                }

                sb.Append($"<a action=\"bypass -h teleport_next?ask={groupId}&reply={e.Id}\" msg=\"811;{e.Name}\">{e.Name}{cost}</a><br1>");
            }

            player.TeleportPayId = itemId;
            player.ShowHtmPlain(sb.ToString(), npc);
        }
Пример #2
0
        private void Reload()
        {
            XElement xml = XElement.Parse(File.ReadAllText(@"scripts\nd_teleports.xml"));
            XElement ex  = xml.Element("list");

            if (ex != null)
            {
                foreach (XElement m in ex.Elements())
                {
                    if (m.Name != "npc")
                    {
                        continue;
                    }

                    ABTeleportNpc npc = new ABTeleportNpc
                    {
                        Id = int.Parse(m.Attribute("id").Value)
                    };

                    foreach (XElement x in m.Elements())
                    {
                        if (x.Name != "group")
                        {
                            continue;
                        }

                        ABTeleportGroup ab = new ABTeleportGroup
                        {
                            Id = int.Parse(x.Attribute("id").Value)
                        };

                        foreach (XElement e in x.Elements())
                        {
                            if (e.Name != "e")
                            {
                                continue;
                            }

                            ABTeleportEntry ae = new ABTeleportEntry
                            {
                                Name = e.Attribute("name").Value,
                                X    = int.Parse(e.Attribute("x").Value),
                                Y    = int.Parse(e.Attribute("y").Value),
                                Z    = int.Parse(e.Attribute("z").Value),
                                Id   = ab.Teles.Count
                            };

                            if (e.Attribute("cost") != null)
                            {
                                ae.Cost = int.Parse(e.Attribute("cost").Value);
                            }
                            if (e.Attribute("itemId") != null)
                            {
                                ae.ItemId = int.Parse(e.Attribute("itemId").Value);
                            }

                            ab.Teles.Add(ae.Id, ae);
                        }

                        npc.Groups.Add(ab.Id, ab);
                    }

                    if (Npcs.ContainsKey(npc.Id))
                    {
                        Log.Error($"NpcData(Teleporter) dublicate npc str {npc.Id}");
                    }
                    else
                    {
                        Npcs.Add(npc.Id, npc);
                    }
                }
            }

            Log.Info($"NpcData(Teleporter): loaded {Npcs.Count} npcs.");
        }