Пример #1
0
        public Portal Unlock(string dungeonName)
        {
            PortalDesc desc = Manager.GameData.Portals[0x0700];
            //desc.DungeonName = dungeonName;
            var portal = new Portal(Manager, desc.ObjectType, desc.TimeoutTime * 1000);

            portal.Move(X, Y);
            portal.Usable = true;
            Owner.EnterWorld(portal);
            Owner.LeaveWorld(this);
            return(portal);
        }
Пример #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" || 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);
        }
    }
Пример #3
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 = (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++;
                }
            }
        }
Пример #4
0
        void Handle(Client client, Player player, USEPORTAL packet)
        {
            if (player?.Owner == null)
            {
                return;
            }

            Portal portal = player.Owner.GetEntity(packet.ObjectId) as Portal;

            if (portal == null)
            {
                return;
            }

            if (!portal.Usable)
            {
                player.SendError("{\"key\":\"server.realm_full\"}");
                return;
            }

            World world = portal.WorldInstance;

            if (world == null)
            {
                bool setWorldInstance = true;

                PortalDesc desc = portal.ObjectDesc;

                if (desc == null)
                {
                    client.SendMessage(new FAILURE
                    {
                        ErrorId          = 0,
                        ErrorDescription = "Portal not found!"
                    });
                }
                else
                {
                    switch (portal.ObjectType)
                    {
                    case 0x0720:
                        world            = player.Manager.PlayerVault(client);
                        setWorldInstance = false;
                        break;

                    case 0x0704:
                    case 0x0703:     //portal of cowardice
                    case 0x0d40:
                    case 0x070d:
                    case 0x070e:
                    {
                        if (player.Manager.LastWorld.ContainsKey(player.AccountId))
                        {
                            World w = player.Manager.LastWorld[player.AccountId];

                            if (w != null && player.Manager.Worlds.ContainsKey(w.Id))
                            {
                                world = w;
                            }
                            else
                            {
                                world = player.Manager.GetWorld(World.NEXUS_ID);
                            }
                        }
                        else
                        {
                            world = player.Manager.GetWorld(World.NEXUS_ID);
                        }
                        setWorldInstance = false;
                    }
                    break;

                    case 0x0750:
                        world = player.Manager.GetWorld(World.MARKET);
                        break;

                    case 0x071d:
                        world = player.Manager.GetWorld(World.NEXUS_ID);
                        break;

                    case 0x0712:
                        world = player.Manager.GetWorld(World.NEXUS_ID);
                        break;

                    case 0x1756:
                        world = player.Manager.GetWorld(World.DAILY_QUEST_ID);
                        break;

                    case 0x072f:
                        if (player.Guild != null)
                        {
                            //client.Player.SendInfo(
                            //    "Sorry, you are unable to enter the GuildHall because of a possible memory leak, check back later");
                            player.SendInfo("Thanks.");
                        }
                        break;

                    default:
                    {
                        Type worldType =
                            Type.GetType("gameserver.realm.world." + desc.DungeonName.Replace(" ", string.Empty).Replace("'", string.Empty));
                        if (worldType != null)
                        {
                            try
                            {
                                world = client.Manager.AddWorld((World)Activator.CreateInstance(worldType,
                                                                                                System.Reflection.BindingFlags.CreateInstance, null, null,
                                                                                                CultureInfo.InvariantCulture, null));
                            }
                            catch
                            {
                                player.SendError($"Dungeon instance \"{desc.DungeonName}\" isn't declared yet and under maintenance until further notice.");
                            }
                        }
                        else
                        {
                            player.SendHelp($"Dungeon instance \"{desc.DungeonName}\" isn't declared yet and under maintenance until further notice.");
                        }
                    }
                    break;
                    }
                }
                if (setWorldInstance)
                {
                    portal.WorldInstance = world;
                }
            }

            if (world != null)
            {
                if (world.IsFull)
                {
                    player.SendError("{\"key\":\"server.dungeon_full\"}");
                    return;
                }

                if (player.Manager.LastWorld.ContainsKey(player.AccountId))
                {
                    World dummy;
                    player.Manager.LastWorld.TryRemove(player.AccountId, out dummy);
                }
                if (player.Owner is Nexus || player.Owner is GameWorld)
                {
                    player.Manager.LastWorld.TryAdd(player.AccountId, player.Owner);
                }

                client?.Reconnect(new RECONNECT
                {
                    Host   = "",
                    Port   = Settings.GAMESERVER.PORT,
                    GameId = world.Id,
                    Name   = world.Name,
                    Key    = world.PortalKey,
                });
            }
        }
Пример #5
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);
            }
        }
Пример #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();
        }
    }
 private Portal(RealmManager manager, PortalDesc desc, int? life)
     : base(manager, desc.ObjectType, life, false, true, false)
 {
     ObjectDesc = desc;
     Name = desc.DisplayId;
 }
Пример #8
0
 private Portal(RealmManager manager, PortalDesc desc, int?life)
     : base(manager, desc.ObjectType, life, false, true, false)
 {
     ObjectDesc = desc;
     Name       = desc.DisplayId;
 }
Пример #9
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);
            }
        }
Пример #10
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 = (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++;
                }
            }
        }
Пример #11
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":
                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++;
            }
        }
    }
Пример #12
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++;
            }
        }
    }
Пример #13
0
        private void MysteryPortal()
        {
            string[] dungeons = new[]
            {
                "Pirate Cave Portal",
                "Forest Maze Portal",
                "Spider Den Portal",
                "Snake Pit Portal",
                "Glowing Portal",
                "Forbidden Jungle Portal",
                "Candyland Portal",
                "Haunted Cemetery Portal",
                "Undead Lair Portal",
                "Davy Jones' Locker Portal",
                "Manor of the Immortals Portal",
                "Abyss of Demons Portal",
                "Lair of Draconis Portal",
                "Mad Lab Portal",
                "Ocean Trench Portal",
                "Tomb of the Ancients Portal",
                "Beachzone Portal",
                "The Shatters",
                "Deadwater Docks",
                "Woodland Labyrinth",
                "The Crawling Depths",
                "Treasure Cave Portal",
                "Battle Nexus Portal",
                "Belladonna's Garden Portal",
                "Lair of Shaitan Portal"
            };

            PortalDesc[] descs      = Manager.GameData.Portals.Where(_ => dungeons.Contains <string>(_.Value.ObjectId)).Select(_ => _.Value).ToArray();
            PortalDesc   portalDesc = descs[Random.Next(0, descs.Count())];
            Entity       por        = Entity.Resolve(Manager, portalDesc.ObjectId);

            por?.Move(this.X, this.Y);
            Owner?.EnterWorld(por);

            Client?.SendMessage(new NOTIFICATION
            {
                Color = new ARGB(0x00FF00),
                Text  =
                    "{\"key\":\"blank\",\"tokens\":{\"data\":\"Opened by " +
                    Client.Account.Name + "\"}}",
                ObjectId = Client.Player.Id
            });

            Owner?.BroadcastPacket(new TEXT
            {
                BubbleTime = 0,
                Stars      = -1,
                Name       = "",
                Text       = portalDesc.ObjectId + " opened by " + Name,
                NameColor  = 0x123456,
                TextColor  = 0x123456
            }, null);

            Owner?.Timers.Add(new WorldTimer(portalDesc.TimeoutTime * 1000, (w, t) => //default portal close time * 1000
            {
                try
                {
                    w?.LeaveWorld(por);
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Couldn't despawn portal.\n{0}", ex);
                }
            }));
        }
Пример #14
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")
            {
                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());
        }
    }
Пример #15
0
 private Portal(PortalDesc desc, int?life)
     : base(desc.ObjectType, life, false, true, false)
 {
     ObjectDesc = desc;
     Name       = desc.DisplayId;
 }
Пример #16
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;

            UsedIds.Add(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 = (short)Utils.FromString(elem.Attribute("type").Value);
            string id   = elem.Attribute("id").Value;

            UsedIds.Add(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")
            {
                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);
        }
    }
Пример #17
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*/
                }
            }
        }
    }
Пример #18
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)
                {
                    continue;
                }
                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((short)type, elem);
                    break;

                case "Portal":
                case "GuildHallPortal":
                    try
                    {
                        portals[type] = new PortalDesc(type, elem);
                    }
                    catch
                    {
                        log.Error("Error for portal: " + type + " id: " + id);
                    }
                    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;
                }
            }
        }
Пример #19
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);
                }
            }
        }
Пример #20
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++;
            }
        }
    }
Пример #21
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++;
        }
    }