예제 #1
0
 private static void Main(string[] args)
 {
     if (args.Length <= 0)
     {
         Console.WriteLine("usage: Json2wmapConv.exe jsonfile");
         return;
     }
     try
     {
         XmlData data = new XmlData();
         FileInfo fi = new FileInfo(args[0]);
         if (fi.Exists)
             terrain.Json2Wmap.Convert(data, args[0], args[0].Replace(".jm", ".wmap"));
         else
         {
             Console.WriteLine("input file not found: " + fi.FullName);
             Console.ReadLine();
             return;
         }
         Console.WriteLine("done");
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception : " + e);
         Console.ReadLine();
     }
 }
예제 #2
0
        public static GiftCode GenerateRandom(XmlData data, int minGold=0, int maxGold=10000, int minFame=0, int maxFame=10000, int minCharSlots=0, int maxCharSlots=4, int minVaultChests=0, int maxVaultChests=4, int maxItemStack=10, int minItemStack=1, int maxItemTypes=10, int minItemTypes=1)
        {
            var rand = new Random();
            var ret = new GiftCode();

            var types = rand.Next(minItemTypes, maxItemTypes);
            var c = rand.Next(minItemStack, maxItemStack);

            for (var i = 0; i < types; i++)
            {
                var t = data.Items.ElementAt(rand.Next(0, data.Items.Count)).Key;
                for (var j = 0; j < c; j++)
                    ret.Gifts.Add(t);
                c = rand.Next(minItemStack, maxItemStack);
            }
            ret.CharSlots = rand.Next(minCharSlots, maxCharSlots);
            ret.VaultChests = rand.Next(minVaultChests, maxVaultChests);
            ret.Gold = rand.Next(minGold, maxGold);
            ret.Fame = rand.Next(minFame, maxFame);
            return ret;
        }
        public static void InitMerchatLists(XmlData data)
        {
            log.Info("Loading merchant lists...");
            List<int> accessoryDyeList = new List<int>();
            List<int> clothingDyeList = new List<int>();
            List<int> accessoryClothList = new List<int>();
            List<int> clothingClothList = new List<int>();

            foreach (KeyValuePair<ushort, Item> item in data.Items.Where(_ => noShopCloths.All(i => i != _.Value.ObjectId)))
            {
                if (item.Value.Texture1 != 0 && item.Value.ObjectId.Contains("Clothing") && item.Value.Class == "Dye")
                {
                    prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(51, CurrencyType.Fame));
                    clothingDyeList.Add(item.Value.ObjectType);
                }

                if (item.Value.Texture2 != 0 && item.Value.ObjectId.Contains("Accessory") && item.Value.Class == "Dye")
                {
                    prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(51, CurrencyType.Fame));
                    accessoryDyeList.Add(item.Value.ObjectType);
                }

                if (item.Value.Texture1 != 0 && item.Value.ObjectId.Contains("Cloth") &&
                    item.Value.ObjectId.Contains("Large"))
                {
                    prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(160, CurrencyType.Fame));
                    clothingClothList.Add(item.Value.ObjectType);
                }

                if (item.Value.Texture2 != 0 && item.Value.ObjectId.Contains("Cloth") &&
                    item.Value.ObjectId.Contains("Small"))
                {
                    prices.Add(item.Value.ObjectType, new Tuple<int, CurrencyType>(160, CurrencyType.Fame));
                    accessoryClothList.Add(item.Value.ObjectType);
                }
            }

            ClothingDyeList = clothingDyeList.ToArray();
            ClothingClothList = clothingClothList.ToArray();
            AccessoryClothList = accessoryClothList.ToArray();
            AccessoryDyeList = accessoryDyeList.ToArray();
            log.Info("Merchat lists added.");
        }
예제 #4
0
 public Wmap(XmlData data)
 {
     this.data = data;
 }
예제 #5
0
 public static void Convert(XmlData data, string from, string to)
 {
     byte[] buffer = Convert(data, File.ReadAllText(from));
     File.WriteAllBytes(to, buffer);
 }
예제 #6
0
        public static byte[] Convert(XmlData data, string json)
        {
            var obj = JsonConvert.DeserializeObject<json_dat>(json);
            var dat = ZlibStream.UncompressBuffer(obj.data);

            Dictionary<short, TerrainTile> tileDict = new Dictionary<short, TerrainTile>();
            for (int i = 0; i < obj.dict.Length; i++)
            {
                var o = obj.dict[i];
                tileDict[(short)i] = new TerrainTile()
                {
                    TileId = o.ground == null ? (ushort)0xff : data.IdToTileType[o.ground],
                    TileObj = o.objs == null ? null : o.objs[0].id,
                    Name = o.objs == null ? "" : o.objs[0].name ?? "",
                    Terrain = TerrainType.None,
                    Region = o.regions == null ? TileRegion.None : (TileRegion)Enum.Parse(typeof(TileRegion), o.regions[0].id.Replace(' ', '_'))
                };
            }

            var tiles = new TerrainTile[obj.width, obj.height];
            ushort objType;
            //creates a new case insensitive dictionary based on the XmlDatas
            Dictionary<string, ushort> icdatas = new Dictionary<string, ushort>(
                data.IdToObjectType,
                StringComparer.OrdinalIgnoreCase);
            using (NReader rdr = new NReader(new MemoryStream(dat)))
                for (int y = 0; y < obj.height; y++)
                {
                    for (int x = 0; x < obj.width; x++)
                    {
                        tiles[x, y] = tileDict[rdr.ReadInt16()];
                        if (tiles[x, y].TileId.ToString().Length == 2)
                        {
                            File.AppendAllText("Tiles.txt", tiles[x, y].TileId.ToString() + "  ");
                        }
                        else if (String.IsNullOrEmpty(tiles[x, y].TileId.ToString()))
                        {
                            File.AppendAllText("Tiles.txt", "   ");
                        }
                        else
                        {
                            File.AppendAllText("Tiles.txt", tiles[x, y].TileId.ToString() + " ");
                        }
                        if (tiles[x, y].TileObj == null)
                        {
                            File.AppendAllText("Objects.txt", "     ");
                        }
                        else
                        {
                            if (!icdatas.TryGetValue(tiles[x, y].TileObj, out objType) ||
                                !data.ObjectDescs.ContainsKey(objType))
                            {
                            }
                            if (objType.ToString().Length == 3)
                                File.AppendAllText("Objects.txt", objType.ToString() + "  ");
                            else
                                File.AppendAllText("Objects.txt", objType.ToString() + " ");
                        }
                    }
                    File.AppendAllText("Objects.txt", Environment.NewLine);
                    File.AppendAllText("Tiles.txt", Environment.NewLine);
                }
            return WorldMapExporter.Export(tiles);
        }
예제 #7
0
 internal AutoAssign(XmlData dat)
     : base("autoId")
 {
     this.dat = dat;
     nextSignedId = GetValue<int>("nextSigned", "50000"); //0xC350
     nextFullId = GetValue<int>("nextFull", "58000"); //0xE290
 }