コード例 #1
0
        private void reload()
        {
            XElement xml = XElement.Parse(File.ReadAllText(@"scripts\nd_teleports.xml"));
            XElement ex  = xml.Element("list");

            foreach (var m in ex.Elements())
            {
                if (m.Name == "npc")
                {
                    ab_teleport_npc npc = new ab_teleport_npc();
                    npc.id = int.Parse(m.Attribute("id").Value);

                    foreach (var x in m.Elements())
                    {
                        if (x.Name == "group")
                        {
                            ab_teleport_group ab = new ab_teleport_group();
                            ab.id = int.Parse(x.Attribute("id").Value);

                            foreach (var e in x.Elements())
                            {
                                if (e.Name == "e")
                                {
                                    ab_teleport_entry ae = new ab_teleport_entry();
                                    ae.name = e.Attribute("name").Value;
                                    ae.x    = int.Parse(e.Attribute("x").Value);
                                    ae.y    = int.Parse(e.Attribute("y").Value);
                                    ae.z    = int.Parse(e.Attribute("z").Value);
                                    ae.id   = ab._teles.Count;

                                    if (e.Attribute("cost") != null)
                                    {
                                        ae.cost = long.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))
                    {
                        CLogger.error("NpcData(Teleporter) dublicate npc str " + npc.id);
                    }
                    else
                    {
                        npcs.Add(npc.id, npc);
                    }
                }
            }

            CLogger.info("NpcData(Teleporter): loaded " + npcs.Count + " npcs.");
        }
コード例 #2
0
ファイル: NpcData.cs プロジェクト: gitter-badger/L2dotNET
        public void RequestTeleport(L2Citizen npc, L2Player player, int type, int entryId)
        {
            ab_teleport_group group = null;

            try
            {
                group = Teleports.npcs[npc.Template.NpcId].groups[type];
            }
            catch
            {
                CLogger.error("ND:RequestTeleport cant find teleport group " + type);
                player.sendActionFailed();
                return;
            }

            ab_teleport_entry e = group._teles[entryId];

            if (!player.hasItem(e.itemId, e.cost))
            {
                switch (e.itemId)
                {
                case 57:
                    player.sendSystemMessage(279);     //You do not have enough adena.
                    break;

                case 6651:
                    player.ShowHtm("fornonoblessitem.htm", npc);
                    break;

                default:
                    player.sendSystemMessage(701);     //You do not have enough required items.
                    break;
                }

                player.sendActionFailed();
                return;
            }

            switch (e.itemId)
            {
            case 57:
                player.reduceAdena(e.cost, true, true);
                break;

            default:
                player.Inventory.destroyItem(e.itemId, e.cost, true, true);
                break;
            }

            player.teleport(e.x, e.y, e.z);
        }