示例#1
0
    static void ProcessXml(Stream stream)
    {
        XElement root = XElement.Load(stream);
        foreach (var elem in root.Elements("Ground"))
        {
            short type = (short)Utils.FromString(elem.Attribute("type").Value);
            string id = elem.Attribute("id").Value;

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            TileDescs[type] = new TileDesc(elem);
        }
        foreach (var elem in root.Elements("Object"))
        {
            if (elem.Element("Class") == null) continue;
            string cls = elem.Element("Class").Value;
            short type = (short)Utils.FromString(elem.Attribute("type").Value);
            string id = elem.Attribute("id").Value;

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            if (cls == "Equipment")
                ItemDescs[type] = new Item(elem);
            else if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                cls == "ConnectedWall" || cls == "CaveWall")
                ObjectDescs[type] = new ObjectDesc(elem);
        }
    }
示例#2
0
    static void ProcessXml(Stream stream)
    {
        XElement root = XElement.Load(stream);
        foreach (var elem in root.Elements("Ground"))
        {
            short type = (short)Utils.FromString(elem.Attribute("type").Value);
            string id = elem.Attribute("id").Value;

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            TileDescs[type] = new TileDesc(elem);
        }
        foreach (var elem in root.Elements("Object"))
        {
            if (elem.Element("Class") == null) continue;
            string cls = elem.Element("Class").Value;
            short type = (short)Utils.FromString(elem.Attribute("type").Value);
            string id = elem.Attribute("id").Value;

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            if (cls == "Equipment")
                ItemDescs[type] = new Item(elem);
            else if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                cls == "ConnectedWall" || cls == "CaveWall")
                ObjectDescs[type] = new ObjectDesc(elem);
            else if (cls == "Portal")
            {
                try
                {
                    PortalDescs[type] = new PortalDesc(elem);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error for portal: " + type + " id: " + id);
                        /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
        *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                }
            }
        }
    }
示例#3
0
        private static void ProcessXml(Stream stream)
        {
            XElement root = XElement.Load(stream);
            foreach (XElement elem in root.Elements("Ground"))
            {
                var type = (short) Utils.FromString(elem.Attribute("type").Value);
                string id = elem.Attribute("id").Value;

                TypeToId[type] = id;
                TypeToIdGround[type] = id;
                IdToType[id] = type;
                TypeToElement[type] = elem;

                TileDescs[type] = new TileDesc(elem);
            }
            foreach (XElement elem in root.Elements("Object"))
            {
                if (elem.Element("Class") == null) continue;
                string cls = elem.Element("Class").Value;
                var type = (short) Utils.FromString(elem.Attribute("type").Value);
                string id = elem.Attribute("id").Value;

                TypeToId[type] = id;
                IdToType[id] = type;
                TypeToElement[type] = elem;

                if (cls == "Equipment" || cls == "Dye" || cls == "Pet")
                {
                    ItemDescs[type] = new Item(elem);
                    if (elem.Element("Shop") != null)
                    {
                        XElement shop = elem.Element("Shop");
                        ItemShops[type] = shop.Element("Name").Value;
                        ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                    }
                }
                if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                    cls == "ConnectedWall" || cls == "CaveWall" || cls == "Portal")
                    ObjectDescs[type] = new ObjectDesc(elem);
                if (cls == "Portal")
                {
                    try
                    {
                        PortalDescs[type] = new PortalDesc(elem);
                    }
                    catch
                    {
                        Console.WriteLine(@"Error for portal: " + type + @" id: " + id);
                        /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?* 
*  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                    }
                }

                if (elem.Element("RemoteTexture") != null)
                {
                    XElement rtElem = elem.Element("RemoteTexture");
                    if (rtElem.Element("Id") != null)
                    {
                        string rtId = rtElem.Element("Id").Value;
                        if (!RemoteTextures.ContainsKey(rtId))
                            if (rtId.StartsWith("draw:"))
                                RemoteTextures.Add(rtId,
                                    new WebClient().DownloadData("http://realmofthemadgod.appspot.com/picture/get?id=" +
                                                                 new String(rtId.Skip(5).ToArray())));
                            else if (rtId.StartsWith("tdraw:"))
                                RemoteTextures.Add(rtId,
                                    new WebClient().DownloadData("http://rotmgtesting.appspot.com/picture/get?id=" +
                                                                 new String(rtId.Skip(5).ToArray())));
                            else if (rtId.StartsWith("file:"))
                                RemoteTextures.Add(rtId,
                                    File.ReadAllBytes("texture/" + new String(rtId.Skip(5).ToArray()) + ".png"));
                    }
                }

                XElement key = elem.Element("Key");
                if (key != null)
                {
                    Keys.Add(type);
                    KeyPrices[type] = Utils.FromString(key.Value);
                }
            }
            foreach (XElement elem in root.Elements("Dungeon"))
            {
                string name = elem.Attribute("name").Value;
                var portalid = (short) Utils.FromString(elem.Attribute("type").Value);

                IdToDungeon[portalid] = name;
                DungeonDescs[name] = new DungeonDesc(elem);
            }
        }
        public void AddObjects(XElement root)
        {
            foreach (XElement elem in root.XPathSelectElements("//Object"))
            {
                if (elem.Element("Class") == null) continue;
                string cls = elem.Element("Class").Value;
                string id = elem.Attribute("id").Value;

                ushort type;
                XAttribute typeAttr = elem.Attribute("type");
                if (typeAttr == null)
                    type = (ushort)assign.Assign(id, elem);
                else
                    type = (ushort)Utils.FromString(typeAttr.Value);

                if (cls == "PetBehavior" || cls == "PetAbility") continue;

                if (type2id_obj.ContainsKey(type))
                    log.WarnFormat("'{0}' and '{1}' has the same ID of 0x{2:x4}!", id, type2id_obj[type], type);
                if (id2type_obj.ContainsKey(id))
                    log.WarnFormat("0x{0:x4} and 0x{1:x4} has the same name of {2}!", type, id2type_obj[id], id);

                type2id_obj[type] = id;
                id2type_obj[id] = type;
                type2elem_obj[type] = elem;

                switch (cls)
                {
                    case "Equipment":
                    case "Dye":
                        items[type] = new Item(type, elem);
                        break;
                    case "Portal":
                    case "GuildHallPortal":
                        try
                        {
                            portals[type] = new PortalDesc(type, elem);
                        }
                        catch
                        {
                            Console.WriteLine("Error for portal: " + type + " id: " + id);
                            /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
            *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                        }
                        break;
                    case "Pet":
                        type2pet[type] = new PetStruct(type, elem);
                        break;
                    case "PetSkin":
                        id2pet_skin[id] = new PetSkin(type, elem);
                        break;
                    case "PetBehavior":
                    case "PetAbility":
                        break;
                    default:
                        objDescs[type] = new ObjectDesc(type, elem);
                        break;
                }

                XAttribute extAttr = elem.Attribute("ext");
                bool ext;
                if (extAttr != null && bool.TryParse(extAttr.Value, out ext) && ext)
                {
                    if (elem.Attribute("type") == null)
                        elem.Add(new XAttribute("type", type));
                    addition.Add(elem);
                    updateCount++;
                }
            }
        }
示例#5
0
    public void AddObjects(XElement root)
    {
        foreach (XElement elem in root.XPathSelectElements("//Object"))
        {
            if (elem.Element("Class") == null) continue;
            string cls = elem.Element("Class").Value;
            string id = elem.Attribute("id").Value;

            ushort type;
            XAttribute typeAttr = elem.Attribute("type");
            if (typeAttr == null)
                type = assign.Assign(id, elem);
            else
                type = (ushort) Utils.FromString(typeAttr.Value);

            if (type2id_obj.ContainsKey(type))
                log.WarnFormat("'{0}' and '{1}' has the same ID of 0x{2:x4}!", id, type2id_obj[type], type);
            if (id2type_obj.ContainsKey(id))
                log.WarnFormat("0x{0:x4} and 0x{1:x4} has the same name of {2}!", type, id2type_obj[id], id);

            type2id_obj[type] = id;
            id2type_obj[id] = type;
            type2elem_obj[type] = elem;

            switch (cls)
            {
                case "Pet":
                case "Dye":
                case "Equipment":
                    items[type] = new Item(type, elem);
                    if (elem.Element("Shop") != null)
                    {
                        XElement shop = elem.Element("Shop");
                        ItemShops[type] = shop.Element("Name").Value;
                        ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                    }
                    foreach(var eff in items[type].ActivateEffects)
                        if (eff.Effect == ActivateEffects.UnlockSkin)
                            skin2item[(ushort)eff.SkinType] = items[type];
                    break;
                case "Skin":
                    skins[type] = new SkinDesc(type, elem);
                    break;
                case "Portal":
                    portals[type] = new PortalDesc(type, elem);
                    objDescs[type] = new ObjectDesc(type, elem);
                    break;
                default:
                    objDescs[type] = new ObjectDesc(type, elem);
                    break;
            }

            XAttribute extAttr = elem.Attribute("ext");
            bool ext;
            if (extAttr != null && bool.TryParse(extAttr.Value, out ext) && ext)
            {
                if (elem.Attribute("type") == null)
                    elem.Add(new XAttribute("type", type));
                addition.Add(elem);
                updateCount++;
            }
        }
    }
示例#6
0
    public static string ProcessModXml(Stream stream, string dir)
    {
        XElement root = XElement.Load(stream);
        foreach (var elem in root.Elements("Ground"))
        {
            short type = 0x3000;
            string id = elem.Attribute("id").Value;

            if (!ItemIds.ContainsKey(id))
                for (var i = 0x3001; i < 0xffff; i++)
                    if (!UsedIds.Contains((short)i))
                    {
                        ItemIds.Add(id, (short)i);
                        UsedIds.Add((short)i);
                    }
            type = ItemIds[id];

            elem.SetAttributeValue("type", type);

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            TileDescs[type] = new TileDesc(elem);
        }
        foreach (var elem in root.Elements("Object"))
        {
            if (elem.Element("Class") == null) continue;
            string cls = elem.Element("Class").Value;
            short type = 0x4000;
            string id = elem.Attribute("id").Value;

            if (!ItemIds.ContainsKey(id))
                for (var i = 0x4001; i < 0xffff; i++)
                    if (!UsedIds.Contains((short)i))
                    {
                        ItemIds.Add(id, (short)i);
                        UsedIds.Add((short)i);
                        break;
                    }
            type = ItemIds[id];

            Console.Out.WriteLine("(" + new DirectoryInfo(dir).Name + ") Adding mod object: " + id + " (" + type.ToString() + ")");
            if (File.Exists(dir + ds + id + ".png"))
            {
                Console.Out.WriteLine("(" + new DirectoryInfo(dir).Name + ") Adding mod texture: " + id);

                if (elem.Element("RemoteTexture") != null)
                    elem.Element("RemoteTexture").Remove();
                if (elem.Element("Texture") != null)
                    elem.Element("Texture").Remove();

                XElement texElem = new XElement("RemoteTexture",
                    new XElement("Instance",
                        new XText("production")
                    ),
                    new XElement("Id",
                        new XText("mod:" + id)
                    )
                );

                elem.Add(texElem);

                try
                {
                    ModTextures.Add(id, File.ReadAllBytes(dir + ds + id + ".png"));
                }
                catch { Console.Out.WriteLine("(" + new DirectoryInfo(dir).Name + ") Error adding texture: " + id); }
            }

            elem.SetAttributeValue("type", type);

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            if (cls == "Equipment" || cls == "Dye" || cls == "Pet")
            {
                ItemDescs[type] = new Item(elem);
                if (elem.Element("Shop") != null)
                {
                    XElement shop = elem.Element("Shop");
                    ItemShops[type] = shop.Element("Name").Value;
                    ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                }
            }
            if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                cls == "ConnectedWall" || cls == "CaveWall" || cls == "Portal" ||
                cls == "NPC")
                ObjectDescs[type] = new ObjectDesc(elem);
            if (cls == "Portal")
            {
                try
                {
                    PortalDescs[type] = new PortalDesc(elem);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error for portal: " + type + " id: " + id);
                    /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
        *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                }
            }

            XElement key = elem.Element("Key");
            if (key != null)
            {
                Keys.Add(type);
                KeyPrices[type] = Utils.FromString(key.Value);
            }
        }
        foreach (var elem in root.Elements("Dungeon"))
        {
            string name = elem.Attribute("name").Value;
            short portalid = (short)Utils.FromString(elem.Attribute("type").Value);

            IdToDungeon[portalid] = name;
            DungeonDescs[name] = new DungeonDesc(elem);
        }
        using (StringWriter sw = new StringWriter())
        {
            root.Save(sw);
            return sw.ToString();
        }
    }
示例#7
0
        void HandleGround(RealmTime time)
        {
            if (time.tickTimes - l > 500)
            {
                if (HasConditionEffect(ConditionEffects.Paused) ||
                    HasConditionEffect(ConditionEffects.Invincible))
                {
                    return;
                }

                try
                {
                    WmapTile   tile     = Owner.Map[(int)X, (int)Y];
                    ObjectDesc objDesc  = tile.ObjType == 0 ? null : XmlDatas.ObjectDescs[tile.ObjType];
                    TileDesc   tileDesc = XmlDatas.TileDescs[tile.TileId];
                    if (tileDesc.Damaging && (objDesc == null || !objDesc.ProtectFromGroundDamage))
                    {
                        int dmg = Random.Next(tileDesc.MinDamage, tileDesc.MaxDamage);
                        dmg = (int)statsMgr.GetDefenseDamage(dmg, true);
                        if (HP <= 0)
                        {
                            psr.Reconnect(new ReconnectPacket()
                            {
                                Host   = "",
                                Port   = 2050,
                                GameId = World.NEXUS_ID,
                                Name   = "Nexus",
                                Key    = Empty <byte> .Array,
                            });
                        }
                        HP -= dmg;
                        UpdateCount++;
                        l = time.tickTimes;
                    }
                }
                catch { }
            }
            if (time.tickTimes - b > 60)
            {
                try
                {
                    if (Owner.Name == "Ocean Trench")
                    {
                        bool fObject = false;
                        foreach (var i in Owner.StaticObjects)
                        {
                            if (i.Value.ObjectType == 0x0731)
                            {
                                if (Math.Floor(X) == Math.Floor(i.Value.X) && Math.Floor(Y) == Math.Floor(i.Value.Y))
                                {
                                    fObject = true;
                                }
                            }
                        }

                        //BEST COLLISION FORMULA EVER

                        if (fObject)
                        {
                            OxygenRegen = true;
                        }
                        else
                        {
                            OxygenRegen = false;
                        }

                        if (!OxygenRegen)
                        {
                            if (OxygenBar == 0)
                            {
                                HP -= 5;
                            }
                            else
                            {
                                OxygenBar -= 1;
                            }

                            if (HP <= 0)
                            {
                                psr.Reconnect(new ReconnectPacket()
                                {
                                    Host   = "",
                                    Port   = 2050,
                                    GameId = World.NEXUS_ID,
                                    Name   = "Nexus",
                                    Key    = Empty <byte> .Array,
                                });
                            }
                            return;
                            //UpdateCount++; //Comment out
                        }
                        else
                        {
                            if (OxygenBar < 100)
                            {
                                OxygenBar += 15;
                            }
                            if (OxygenBar > 100)
                            {
                                OxygenBar = 100;
                            }

                            UpdateCount++;
                        }
                    }

                    b = time.tickTimes;
                }
                catch { }
            }
        }
示例#8
0
    static void ProcessXml(Stream stream)
    {
        XElement root = XElement.Load(stream);
        foreach (var elem in root.Elements("Ground"))
        {
            short type = (short)Utils.FromString(elem.Attribute("type").Value);
            string id = elem.Attribute("id").Value;

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            TileDescs[type] = new TileDesc(elem);
        }
        foreach (var elem in root.Elements("Object"))
        {
            if (elem.Element("Class") == null) continue;
            string cls = elem.Element("Class").Value;
            short type = (short)Utils.FromString(elem.Attribute("type").Value);
            string id = elem.Attribute("id").Value;

            TypeToId[type] = id;
            IdToType[id] = type;
            TypeToElement[type] = elem;

            if (cls == "Equipment" || cls == "Dye" || cls == "Pet")
            {
                ItemDescs[type] = new Item(elem);
                if (elem.Element("Shop") != null)
                {
                    XElement shop = elem.Element("Shop");
                    ItemShops[type] = shop.Element("Name").Value;
                    ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                }
            }
            if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                cls == "ConnectedWall" || cls == "CaveWall" || cls == "Portal")
                ObjectDescs[type] = new ObjectDesc(elem);
            if (cls == "Portal")
            {
                try
                {
                    PortalDescs[type] = new PortalDesc(elem);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error for portal: " + type + " id: " + id);
                    /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
        *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                }
            }

            XElement key = elem.Element("Key");
            if (key != null)
            {
                Keys.Add(type);
                KeyPrices[type] = Utils.FromString(key.Value);
            }
        }
        foreach (var elem in root.Elements("Dungeon"))
        {
            string name = elem.Attribute("name").Value;
            short portalid = (short)Utils.FromString(elem.Attribute("type").Value);

            IdToDungeon[portalid] = name;
            DungeonDescs[name] = new DungeonDesc(elem);
        }
    }
示例#9
0
        public void Death(string killer, ObjectDesc desc = null)
        {
            if (dying)
            {
                return;
            }
            dying = true;
            switch (Owner.Name)
            {
            case "Arena":
            {
                Client.SendMessage(new ARENA_DEATH
                    {
                        RestartPrice = 100
                    });
                HP = (int)ObjectDesc.MaxHP;
                ApplyConditionEffect(new ConditionEffect
                    {
                        Effect     = ConditionEffectIndex.Paused,
                        DurationMS = -1
                    });
                return;
            }
            }
            if (Client.State == ProtocolState.Disconnected || resurrecting)
            {
                return;
            }
            if (CheckResurrection())
            {
                return;
            }

            if (Client.Character.Dead)
            {
                GameServer.Manager.TryDisconnect(Client, DisconnectReason.CHARACTER_IS_DEAD);
                return;
            }
            GenerateGravestone();
            if (desc != null)
            {
                if (desc.DisplayId != null)
                {
                    killer = desc.DisplayId;
                }
                else
                {
                    killer = desc.ObjectId;
                }
            }
            switch (killer)
            {
            case "":
            case "Unknown":
                break;

            default:
                Owner.BroadcastMessage(new TEXT
                {
                    BubbleTime = 0,
                    Stars      = -1,
                    Name       = "",
                    Text       = "{\"key\":\"server.death\",\"tokens\":{\"player\":\"" + Name + "\",\"level\":\"" + Level + "\",\"enemy\":\"" + killer + "\"}}",
                    NameColor  = 0x123456,
                    TextColor  = 0x123456
                }, null);
                break;
            }

            try
            {
                Client.Character.Dead = true;

                SaveToCharacter();

                GameServer.Manager.Database.SaveCharacter(Client.Account, Client.Character, true);
                GameServer.Manager.Database.Death(GameServer.Manager.GameData, Client.Account, Client.Character, FameCounter.Stats, killer);

                if (Owner.Id != -6)
                {
                    DEATH _death = new DEATH
                    {
                        AccountId  = AccountId,
                        CharId     = Client.Character.CharId,
                        Killer     = killer,
                        zombieId   = -1,
                        zombieType = -1
                    };

                    Client.SendMessage(_death);

                    Owner.Timers.Add(new WorldTimer(1000, (w, t) => GameServer.Manager.TryDisconnect(Client, DisconnectReason.CHARACTER_IS_DEAD)));

                    Owner.LeaveWorld(this);
                }
                else
                {
                    GameServer.Manager.TryDisconnect(Client, DisconnectReason.CHARACTER_IS_DEAD_ERROR);
                }
            }
            catch (Exception) { }
        }
示例#10
0
        public void Death(string killer, ObjectDesc desc = null)
        {
            if (dying)
            {
                return;
            }
            dying = true;
            switch (Owner.Name)
            {
            case "Arena":
            {
                Client.SendPacket(new ArenaDeathPacket
                    {
                        RestartPrice = 100
                    });
                HP = Client.Character.MaxHitPoints;
                ApplyConditionEffect(new ConditionEffect
                    {
                        Effect     = ConditionEffectIndex.Invulnerable,
                        DurationMS = -1
                    });
                return;
            }

            case "Nexus":
                foreach (var i in Manager.Worlds.Values)
                {
                    foreach (var e in i.Players.Values)
                    {
                        e.SendInfo(Name + " cannot be killed in nexus!");
                    }
                }
                return;
            }

            if (Client.Stage == ProtocalStage.Disconnected || resurrecting)
            {
                return;
            }
            if (CheckResurrection())
            {
                return;
            }

            if (Client.Character.Dead)
            {
                Client.Disconnect();
                return;
            }
            GenerateGravestone();
            AnnounceDeath(killer);

            if (desc != null)
            {
                killer = desc.DisplayId;
            }

            try
            {
                Manager.Database.DoActionAsync(db =>
                {
                    Client.Character.Dead = true;
                    SaveToCharacter();
                    db.SaveCharacter(Client.Account, Client.Character);
                    db.Death(Manager.GameData, Client.Account, Client.Character, killer);
                });
                if (Owner.Id != -6)
                {
                    Client.SendPacket(new DeathPacket
                    {
                        AccountId = AccountId,
                        CharId    = Client.Character.CharacterId,
                        Killer    = killer,
                        obf0      = -1,
                        obf1      = -1,
                    });
                    Owner.Timers.Add(new WorldTimer(1000, (w, t) => Client.Disconnect()));
                    Owner.LeaveWorld(this);
                }
                else
                {
                    Client.Disconnect();
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
        }
示例#11
0
文件: Player.cs 项目: maximan20/CJ
        public void Death(string killer, ObjectDesc desc = null)
        {
            if (dying)
            {
                return;
            }
            dying = true;
            switch (Owner.Name)
            {
            case "Arena":
            {
                Client.SendPacket(new ArenaDeathPacket
                    {
                        RestartPrice = 100
                    });
                HP = Client.Character.MaxHitPoints;
                ApplyConditionEffect(new ConditionEffect
                    {
                        Effect     = ConditionEffectIndex.Invulnerable,
                        DurationMS = -1
                    });
                return;
            }
            }

            if (Client.Stage == ProtocalStage.Disconnected || resurrecting)
            {
                return;
            }
            if (CheckResurrection())
            {
                return;
            }

            if (Client.Character.Dead)
            {
                Client.Disconnect();
                return;
            }
            GenerateGravestone();
            if (desc != null)
            {
                killer = desc.DisplayId;
            }
            switch (killer)
            {
            case "":
            case "Unknown":
                break;

            default:
                Owner.BroadcastPacket(new TextPacket
                {
                    BubbleTime = 0,
                    Stars      = -1,
                    Name       = "",
                    Text       = "{\"key\":\"server.death\",\"tokens\":{\"player\":\"" + Name + "\",\"level\":\"" + Level + "\",\"enemy\":\"" + killer + "\"}}"
                }, null);
                break;
            }

            try
            {
                Manager.Database.DoActionAsync(db =>
                {
                    Client.Character.Dead = true;
                    SaveToCharacter();
                    db.SaveCharacter(Client.Account, Client.Character);
                    db.Death(Manager.GameData, Client.Account, Client.Character, killer);
                });
                if (Owner.Id != -6)
                {
                    Client.SendPacket(new DeathPacket
                    {
                        AccountId = AccountId,
                        CharId    = Client.Character.CharacterId,
                        Killer    = killer,
                        obf0      = -1,
                        obf1      = -1,
                    });
                    Owner.Timers.Add(new WorldTimer(1000, (w, t) => Client.Disconnect()));
                    Owner.LeaveWorld(this);
                }
                else
                {
                    Client.Disconnect();
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
        }
示例#12
0
        private static void ProcessXml(Stream stream)
        {
            XElement root = XElement.Load(stream);

            foreach (XElement elem in root.Elements("Ground"))
            {
                var    type = (short)Utils.FromString(elem.Attribute("type").Value);
                string id   = elem.Attribute("id").Value;

                TypeToId[type]       = id;
                TypeToIdGround[type] = id;
                IdToType[id]         = type;
                TypeToElement[type]  = elem;

                TileDescs[type] = new TileDesc(elem);
            }
            foreach (XElement elem in root.Elements("Object"))
            {
                if (elem.Element("Class") == null)
                {
                    continue;
                }
                string cls  = elem.Element("Class").Value;
                var    type = (short)Utils.FromString(elem.Attribute("type").Value);
                string id   = elem.Attribute("id").Value;

                TypeToId[type]      = id;
                IdToType[id]        = type;
                TypeToElement[type] = elem;

                if (cls == "Equipment" || cls == "Dye" || cls == "Pet")
                {
                    ItemDescs[type] = new Item(elem);
                    if (elem.Element("Shop") != null)
                    {
                        XElement shop = elem.Element("Shop");
                        ItemShops[type]  = shop.Element("Name").Value;
                        ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                    }
                }
                if (cls == "Character" || cls == "GameObject" || cls == "Wall" ||
                    cls == "ConnectedWall" || cls == "CaveWall" || cls == "Portal")
                {
                    ObjectDescs[type] = new ObjectDesc(elem);
                }
                if (cls == "Portal")
                {
                    try
                    {
                        PortalDescs[type] = new PortalDesc(elem);
                    }
                    catch
                    {
                        Console.WriteLine(@"Error for portal: " + type + @" id: " + id);

                        /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
                         *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                    }
                }

                if (elem.Element("RemoteTexture") != null)
                {
                    XElement rtElem = elem.Element("RemoteTexture");
                    if (rtElem.Element("Id") != null)
                    {
                        string rtId = rtElem.Element("Id").Value;
                        if (!RemoteTextures.ContainsKey(rtId))
                        {
                            if (rtId.StartsWith("draw:"))
                            {
                                RemoteTextures.Add(rtId,
                                                   new WebClient().DownloadData("http://realmofthemadgod.appspot.com/picture/get?id=" +
                                                                                new String(rtId.Skip(5).ToArray())));
                            }
                            else if (rtId.StartsWith("tdraw:"))
                            {
                                RemoteTextures.Add(rtId,
                                                   new WebClient().DownloadData("http://rotmgtesting.appspot.com/picture/get?id=" +
                                                                                new String(rtId.Skip(6).ToArray())));
                            }
                            else if (rtId.StartsWith("file:"))
                            {
                                RemoteTextures.Add(rtId,
                                                   File.ReadAllBytes("texture/" + new String(rtId.Skip(5).ToArray()) + ".png"));
                            }
                        }
                    }
                }


                XElement key = elem.Element("Key");
                if (key != null)
                {
                    Keys.Add(type);
                    KeyPrices[type] = Utils.FromString(key.Value);
                }
            }
            foreach (XElement elem in root.Elements("Dungeon"))
            {
                string name     = elem.Attribute("name").Value;
                var    portalid = (short)Utils.FromString(elem.Attribute("type").Value);

                IdToDungeon[portalid] = name;
                DungeonDescs[name]    = new DungeonDesc(elem);
            }
        }
示例#13
0
        public void Death(string killer, ObjectDesc desc = null)
        {
            if (CheckBrokenAmulet(MathsUtils.GenerateProb(100)))
            {
                return;
            }
            if (CheckNotBrokenAmulet())
            {
                return;
            }
            if (_dying)
            {
                return;
            }
            _dying = true;
            var killPlayer = true;

            switch (Owner.Name)
            {
            case "Arena":
            {
                Client.SendPacket(new ArenaDeathPacket
                    {
                        RestartPrice = 100
                    });
                HP = Client.Character.MaxHitPoints;
                ApplyConditionEffect(new ConditionEffect
                    {
                        Effect     = ConditionEffectIndex.Invulnerable,
                        DurationMS = -1
                    });
                return;
            }
            }


            if (Client.Stage == ProtocalStage.Disconnected || _resurrecting)
            {
                return;
            }
            if (CheckResurrection())
            {
                return;
            }

            if (Client.Character.Dead)
            {
                Client.Disconnect();
                return;
            }

            GenerateGravestone();

            if (desc != null)
            {
                killer = desc.DisplayId;
            }
            switch (killer)
            {
            case "":
            case "Unknown":
                killPlayer = false;
                break;

            default:
                announceDeath(killer, desc);
                break;
            }

            if (killPlayer)
            {
                try
                {
                    Manager.Database.DoActionAsync(db =>
                    {
                        Client.Character.Dead = true;
                        SaveToCharacter();
                        db.SaveCharacter(Client.Account, Client.Character);
                        db.Death(Manager.GameData, Client.Account, Client.Character, killer);
                    });
                    if (Owner.Id != World.TEST_ID)
                    {
                        Client.SendPacket(new DeathPacket
                        {
                            AccountId = AccountId,
                            CharId    = Client.Character.CharacterId,
                            Killer    = killer,
                            Obf0      = -1,
                            Obf1      = -1
                        });
                        Owner.Timers.Add(new WorldTimer(1000, (w, t) => Client.Disconnect()));
                        Owner.LeaveWorld(this);
                    }
                    else
                    {
                        Client.Disconnect();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
            else
            {
                Client.Disconnect();
            }
        }
示例#14
0
    public void AddObjects(XElement root)
    {
        foreach (XElement elem in root.XPathSelectElements("//Object"))
        {
            if (elem.Element("Class") == null)
            {
                continue;
            }
            string cls = elem.Element("Class").Value;
            string id  = elem.Attribute("id").Value;

            ushort     type;
            XAttribute typeAttr = elem.Attribute("type");
            if (typeAttr == null)
            {
                type = assign.Assign(id, elem);
            }
            else
            {
                type = (ushort)Utils.FromString(typeAttr.Value);
            }

            if (type2id_obj.ContainsKey(type))
            {
                log.WarnFormat("'{0}' and '{1}' has the same ID of 0x{2:x4}!", id, type2id_obj[type], type);
            }
            if (id2type_obj.ContainsKey(id))
            {
                log.WarnFormat("0x{0:x4} and 0x{1:x4} has the same name of {2}!", type, id2type_obj[id], id);
            }

            type2id_obj[type]   = id;
            id2type_obj[id]     = type;
            type2elem_obj[type] = elem;

            switch (cls)
            {
            case "Pet":
            case "Dye":
            case "Equipment":
                items[type] = new Item(type, elem);
                if (elem.Element("Shop") != null)
                {
                    XElement shop = elem.Element("Shop");
                    ItemShops[type]  = shop.Element("Name").Value;
                    ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                }
                foreach (var eff in items[type].ActivateEffects)
                {
                    if (eff.Effect == ActivateEffects.UnlockSkin)
                    {
                        skin2item[(ushort)eff.SkinType] = items[type];
                    }
                }
                break;

            case "Skin":
                skins[type] = new SkinDesc(type, elem);
                break;

            case "Portal":
            case "GuildHallPortal":
                try
                {
                    portals[type] = new PortalDesc(type, elem);
                }
                catch
                {
                    Console.WriteLine("Error for portal: " + type + " id: " + id);

                    /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
                     *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                }
                break;

            default:
                objDescs[type] = new ObjectDesc(type, elem);
                break;
            }

            XAttribute extAttr = elem.Attribute("ext");
            bool       ext;
            if (extAttr != null && bool.TryParse(extAttr.Value, out ext) && ext)
            {
                if (elem.Attribute("type") == null)
                {
                    elem.Add(new XAttribute("type", type));
                }
                addition.Add(elem);
                updateCount++;
            }
        }
    }
示例#15
0
        public void Death(string killer, ObjectDesc desc = null)
        {
            if (client.Stage == ProtocalStage.Disconnected || resurrecting)
            {
                return;
            }
            switch (Owner.Name)
            {
            case "Editor":
                return;

            case "Nexus":
                HP = Stats[0] + Stats[0];
                MP = Stats[1] + Stats[1];
                client.Disconnect();
                return;
            }
            if (client.Stage == ProtocalStage.Disconnected || resurrecting)
            {
                return;
            }
            if (CheckResurrection())
            {
                return;
            }
            //if (client.Character.Dead)
            //{
            //    client.Disconnect();
            //    return;
            //}

            GenerateGravestone();
            if (desc != null)
            {
                killer = desc.DisplayId;
            }
            switch (killer)
            {
            case "":
            case "Unknown":
                break;

            default:
                Owner.BroadcastPacket(new TextPacket
                {
                    BubbleTime = 0,
                    Stars      = -1,
                    Name       = "",
                    Text       = ""
                }, null);
                break;
            }
            if (killer != "" && killer != "Unknown" && killer != "???")
            {
                Owner.BroadcastPacket(new TextPacket
                {
                    BubbleTime = 0,
                    Stars      = -1,
                    Name       = "",
                    Text       = string.Format("{0} died at level {1}, killed by {2}", Name, Level, killer)
                }, null);
            }

            try
            {
                Manager.Data.AddDatabaseOperation(db =>
                {
                    client.Player.Experience -= (int)(Math.Round(client.Player.Experience * 0.2));
                    client.Character.Deaths++;

                    client.Player.CalculateFame();
                    db.SaveCharacter(client.Account, client.Character);

                    for (var i = 0; i < Level; i++)
                    {
                        if (GetLevelExp(client.Player.Level) > client.Player.Experience)
                        {
                            client.Character.Level--;
                            client.Player.Level--;
                        }
                    }
                    HP = Stats[0] + Stats[0];
                    MP = Stats[1] + Stats[1];
                    client.Player.CalculateFame();
                    client.Player.UpdateCount++;
                    SaveToCharacter();
                }).ContinueWith(task =>
                                client.Reconnect(new ReconnectPacket
                {
                    Host   = "",
                    Port   = 2050,
                    GameId = World.NEXUS_ID,
                    Name   = "Nexus",
                    Key    = Empty <byte> .Array,
                }));
            }
            catch (Exception e)
            {
                log.Error(e);
            }
        }
        public void AddObjects(XElement root)
        {
            foreach (XElement e in root.XPathSelectElements("//Object"))
            {
                if (e.Element("Class") == null)
                {
                    continue;
                }
                string cls = e.Element("Class").Value;
                string id  = e.Attribute("id").Value;

                if (IsEgg(e))
                {
                    LoEObjectAmount++;
                    EggAmount++;
                }

                if (IsEnemy(e))
                {
                    LoEObjectAmount++;
                    EnemyAmount++;
                }

                if (IsProjectile(e))
                {
                    LoEObjectAmount++;
                    ProjectileAmount++;
                }

                if (IsEquipment(e))
                {
                    LoEObjectAmount++;
                    EquipmentAmount++;
                }

                if (IsPet(e))
                {
                    LoEObjectAmount++;
                    PetAmount++;
                }

                if (IsSkin(e))
                {
                    LoEObjectAmount++;
                    SkinAmount++;
                }

                ushort     type;
                XAttribute typeAttr = e.Attribute("type");
                if (typeAttr == null)
                {
                    type = (ushort)assign.Assign(id, e);
                }
                else
                {
                    type = (ushort)Utils.FromString(typeAttr.Value);
                }

                if (cls == "PetBehavior" || cls == "PetAbility")
                {
                    continue;
                }

                if (type2id_obj.ContainsKey(type))
                {
                    Log.Warn($"'{id}' and '{type2id_obj[type]}' has the same ID of 0x{type:x4}!");
                }
                if (id2type_obj.ContainsKey(id))
                {
                    Log.Warn($"0x{type:x4} and 0x{id2type_obj[id]:x4} has the same name of {id}!");
                }

                type2id_obj[type]   = id;
                id2type_obj[id]     = type;
                type2elem_obj[type] = e;

                switch (cls)
                {
                case "Equipment":
                case "Dye":
                    items[type] = new Item(type, e);
                    break;

                case "Portal":
                case "GuildHallPortal":
                    try
                    {
                        portals[type] = new PortalDesc(type, e);
                    }
                    catch
                    {
                        Console.WriteLine("Error for portal: " + type + " id: " + id);

                        /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
                         *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                    }
                    break;

                case "Pet":
                    type2pet[type] = new PetStruct(type, e);
                    break;

                case "PetSkin":
                    id2pet_skin[id] = new PetSkin(type, e);
                    break;

                case "PetBehavior":
                case "PetAbility":
                    break;

                default:
                    objDescs[type] = new ObjectDesc(type, e);
                    break;
                }

                XAttribute extAttr = e.Attribute("ext");
                if (extAttr != null && bool.TryParse(extAttr.Value, out bool ext) && ext)
                {
                    if (e.Attribute("type") == null)
                    {
                        e.Add(new XAttribute("type", type));
                    }
                    addition.Add(e);
                    updateCount++;
                }
            }
        }
示例#17
0
        private static void AddObject(XElement root)
        {
            foreach (var elem in root.XPathSelectElements("//Object"))
            {
                if (elem.Element("Class") == null) continue;
                var cls = elem.Element("Class").Value;
                var id = elem.Attribute("id").Value;
                var type = (short)Utils.FromString(elem.Attribute("type").Value);

                ObjectTypeToId[type] = id;
                IdToObjectType[id] = type;
                TypeToElement[type] = elem;

                switch (cls)
                {
                    case "Equipment":
                    case "Dye":
                    case "Pet":
                        Items[type] = new Item(elem);
                        if (elem.Element("Shop") != null)
                        {
                            var shop = elem.Element("Shop");
                            ItemShops[type] = shop.Element("Name").Value;
                            ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                        }
                        break;
                    case "Portal":
                        try
                        {
                            Portals[type] = new PortalDesc(elem);
                        }
                        catch (Exception ex)
                        {
                            Logger.Error($"Error for portal: {type} id: {id}");
                            Logger.Error(ex);
                            /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
*  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                        }
                        break;
                    default:
                        ObjectDescs[type] = new ObjectDesc(elem);
                        break;
                }

                if (elem.Element("RemoteTexture") != null)
                {
                    var rtElem = elem.Element("RemoteTexture");
                    if (rtElem.Element("Id") != null)
                    {
                        var rtId = rtElem.Element("Id").Value;
                        if (!RemoteTextures.ContainsKey(rtId))
                            if (rtId.StartsWith("draw:"))
                                RemoteTextures.Add(rtId,
                                    new WebClient().DownloadData("http://realmofthemadgod.appspot.com/picture/get?id=" +
                                                                 new String(rtId.Skip(5).ToArray())));
                            else if (rtId.StartsWith("tdraw:"))
                                RemoteTextures.Add(rtId,
                                    new WebClient().DownloadData("http://rotmgtesting.appspot.com/picture/get?id=" +
                                                                 new String(rtId.Skip(6).ToArray())));
                            else if (rtId.StartsWith("file:"))
                                RemoteTextures.Add(rtId,
                                    File.ReadAllBytes("texture/" + new String(rtId.Skip(5).ToArray()) + ".png"));
                    }
                }

                var key = elem.Element("Key");
                if (key != null)
                {
                    Keys.Add(type);
                    KeyPrices[type] = Utils.FromString(key.Value);
                }
            }
        }
示例#18
0
        public void OnEnemyKilled(Enemy enemy, Player killer)
        {
            if (enemy.ObjectDesc != null && enemy.ObjectDesc.Quest)
            {
                TauntData?dat = null;
                foreach (var i in criticalEnemies)
                {
                    if ((enemy.ObjectDesc.DisplayId ?? enemy.ObjectDesc.ObjectId) == i.Item1)
                    {
                        dat = i.Item2;
                        break;
                    }
                }
                if (dat == null)
                {
                    return;
                }

                if (dat.Value.killed != null)
                {
                    string[] arr = dat.Value.killed;
                    string   msg = arr[rand.Next(0, arr.Length)];
                    while (killer == null && msg.Contains("{PLAYER}"))
                    {
                        msg = arr[rand.Next(0, arr.Length)];
                    }
                    msg = msg.Replace("{PLAYER}", killer.Name);
                    BroadcastMsg(msg);
                }

                if (rand.NextDouble() < 0.25)
                {
                    Tuple <string, ISetPiece> evt = events[rand.Next(0, events.Count)];
                    if (
                        world.Manager.GameData.ObjectDescs[world.Manager.GameData.IdToObjectType[evt.Item1]].PerRealmMax ==
                        1)
                    {
                        events.Remove(evt);
                    }
                    SpawnEvent(evt.Item1, evt.Item2);

                    dat = null;
                    foreach (var i in criticalEnemies)
                    {
                        if (evt.Item1 == i.Item1)
                        {
                            dat = i.Item2;
                            break;
                        }
                    }
                    if (dat == null)
                    {
                        return;
                    }

                    if (dat.Value.spawn != null)
                    {
                        string[] arr = dat.Value.spawn;
                        string   msg = arr[rand.Next(0, arr.Length)];
                        BroadcastMsg(msg);
                    }
                }
                else
                {
                    bool enemyFound = false;
                    foreach (var i in world.Enemies)
                    {
                        if (i.Value == enemy)
                        {
                            continue;
                        }
                        ObjectDesc desc = i.Value.ObjectDesc;
                        if (desc == null)
                        {
                            continue;
                        }
                        bool isCritical = false;
                        foreach (var e in criticalEnemies)
                        {
                            if ((desc.DisplayId ?? desc.ObjectId) == e.Item1)
                            {
                                isCritical = true;
                                break;
                            }
                        }
                        if (!isCritical)
                        {
                            continue;
                        }
                        enemyFound = true;
                    }
                    if (!enemyFound)
                    {
                        BroadcastMsg("UHHH BUH BUH BUH UH BUH BUH BUH UH BUH BUH");
                        BroadcastMsg("I WILL SUFFER NO MORE OF YOUR IMPUDENCE!");
                        BroadcastMsg("I HAVE CLOSED THIS REALM! YOU WILL NOT LIVE TO SEE THE LIGHT OF DAY!");
                        this.closed = true;
                        world.Timers.Add(new WorldTimer(120000, (w, t) =>
                        {
                            BroadcastMsg("MY MINIONS HAVE FAILED ME!");
                            BroadcastMsg("BUT NOW YOU SHALL FEEL MY WRATH");
                            BroadcastMsg("COME MEET ME AT THE WALLS OF MY CASTLE");
                            w.BroadcastPacket(new ShowEffectPacket()
                            {
                                Color      = new ARGB(0xFF00FF00),
                                EffectType = EffectType.Earthquake,
                            }, null);
                            w.Timers.Add(new WorldTimer(15000, (s, g) =>
                            {
                                World chamber = s.Manager.AddWorld(new OryxChamber());
                                foreach (var i in s.Players)
                                {
                                    i.Value.Client.Reconnect(new ReconnectPacket()
                                    {
                                        Host   = "",
                                        Port   = 2050,
                                        GameId = chamber.Id,
                                        Name   = "Oryx's Chamber",
                                        Key    = Empty <byte> .Array
                                    });
                                }
                                var manager = world.Manager;
                                manager.RemoveWorld(world);
                                manager.AddWorld(world.Id, GameWorld.AutoName(1, true));
                            }));
                        }));
                        world.Manager.Monitor.WorldClosed(world);
                    }
                }
            }
        }
示例#19
0
        private int Spawn(ObjectDesc desc, WmapTerrain terrain, int w, int h)
        {
            Entity entity;
            int ret = 0;
            var pt = new IntPoint();
            if (desc.Spawn != null)
            {
                var num = (int) GetNormal(rand, desc.Spawn.Mean, desc.Spawn.StdDev);
                if (num > desc.Spawn.Max) num = desc.Spawn.Max;
                else if (num < desc.Spawn.Min) num = desc.Spawn.Min;

                do
                {
                    pt.X = rand.Next(0, w);
                    pt.Y = rand.Next(0, h);
                } while (world.Map[pt.X, pt.Y].Terrain != terrain ||
                         !world.IsPassable(pt.X, pt.Y) ||
                         world.AnyPlayerNearby(pt.X, pt.Y));

                for (int k = 0; k < num; k++)
                {
                    entity = Entity.Resolve(world.Manager, desc.ObjectType);
                    entity.Move(
                        pt.X + (float) (rand.NextDouble()*2 - 1)*5,
                        pt.Y + (float) (rand.NextDouble()*2 - 1)*5);
                    (entity as Enemy).Terrain = terrain;
                    world.EnterWorld(entity);
                    ret++;
                }
            }
            else
            {
                do
                {
                    pt.X = rand.Next(0, w);
                    pt.Y = rand.Next(0, h);
                } while (world.Map[pt.X, pt.Y].Terrain != terrain ||
                         !world.IsPassable(pt.X, pt.Y) ||
                         world.AnyPlayerNearby(pt.X, pt.Y));

                entity = Entity.Resolve(world.Manager, desc.ObjectType);
                entity.Move(pt.X, pt.Y);
                (entity as Enemy).Terrain = terrain;
                world.EnterWorld(entity);
                ret++;
            }
            return ret;
        }
示例#20
0
    public void AddObjects(XElement root)
    {
        foreach (var elem in root.XPathSelectElements("//Object"))
        {
            if (elem.Element("Class") == null)
            {
                continue;
            }
            var cls = elem.Element("Class").Value;
            var id  = elem.Attribute("id").Value;

            ushort type;
            var    typeAttr = elem.Attribute("type");
            if (typeAttr == null)
            {
                type = assign.Assign(id, elem);
            }
            else
            {
                type = (ushort)Utils.FromString(typeAttr.Value);
            }

            if (type2id_obj.ContainsKey(type))
            {
                log.Warn($"'{id}' and '{type2id_obj[type]}' has the same ID of 0x{type:x4}!");
            }
            if (id2type_obj.ContainsKey(id))
            {
                log.Warn($"0x{type:x4} and 0x{id2type_obj[id]:x4} has the same name of {id}!");
            }

            type2id_obj[type]   = id;
            id2type_obj[id]     = type;
            type2elem_obj[type] = elem;

            switch (cls)
            {
            case "Equipment":
            case "Dye":
                items[type] = new Item(type, elem);
                break;

            case "Portal":
                try
                {
                    portals[type] = new PortalDesc(type, elem);
                }
                catch
                {
                    log.Error($"Error for portal: {type} id: {id}");
                    Console.WriteLine("Error for portal: " + type + " id: " + id);

                    /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
                     *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                }
                break;

            default:
                objDescs[type] = new ObjectDesc(type, elem);
                break;
            }

            var  extAttr = elem.Attribute("ext");
            bool ext;
            if (extAttr == null || !bool.TryParse(extAttr.Value, out ext) || !ext)
            {
                continue;
            }
            if (elem.Attribute("type") == null)
            {
                elem.Add(new XAttribute("type", type));
            }
            addition.Add(elem);
            updateCount++;
        }
    }