Beispiel #1
0
        public static void LoadShops()
        {
            using (var sr = new StreamReader("RAW\\Shop.dat"))
            {
                var items = new HashSet <int>();;
                while (!sr.EndOfStream)
                {
                    items.Clear();
                    var line = "";

                    while (line != null && !line.Contains("ID="))
                    {
                        line = sr.ReadLine();
                    }

                    var id = 0;
                    if (line != null)
                    {
                        id = int.Parse(line.Split('=')[1]);
                    }

                    while (line != null && !line.Contains("ItemAmount="))
                    {
                        line = sr.ReadLine();
                    }

                    byte amount = 0;
                    if (line != null)
                    {
                        amount = byte.Parse(line.Split('=')[1]);
                    }

                    for (var I = 0; I < amount; I++)
                    {
                        var line1 = sr.ReadLine();
                        if (line1 == null)
                        {
                            continue;
                        }
                        if (line1.Contains("Name="))
                        {
                            break;
                        }
                        items.Add(int.Parse(line1.Split('=')[1]));
                    }
                    YiObj npc;

                    if (Collections.Npcs.TryGetValue(id, out npc))
                    {
                        foreach (var itemId in items)
                        {
                            var item = Item.Factory.Create(itemId);
                            item.UniqueId = item.ItemId;
                            npc.Inventory.AddBypass(item);
                        }
                        BoothSystem.Create(npc);
                    }
                }
            }
        }
Beispiel #2
0
 private static void BuyBoothItem(Player player, ref MsgItem packet)
 {
     if (BoothSystem.Buy(player, packet.Param, packet.UnqiueId))
     {
         player.Send(packet);
     }
 }
Beispiel #3
0
        private async void UI_Load(object sender, EventArgs e)
        {
            Text = @"Yi Server - IP: " + YiCore.ServerIp;
            //await DbConverter.Convert();
            //await Db.SaveAsJsonAsync(SaveType.All);
            //await Database.Converters.MonsterDb.Load();
            //await Database.Converters.MagicTypeConverter.Load();
            //await Database.Converters.LevelExpConverter.Load();
            //Db.Serialize("Skills", Collections.Skills);
            //Db.Serialize("LevelExps", Collections.LevelExps);
            //Db.Serialize("BaseMonsters", Collections.BaseMonsters);
            //Db.Serialize("Monsters", Collections.Monsters);
            await Db.Load();

            BoothSystem.SetUpBooths();
            ScriptWatcher.Start();
            WeatherSystem.Start();
            //DayNightSystem.Start();

            //if (arg.Length > 0)
            //{
            //    Output.WriteLine("Running as 2nd Instance!");
            //    Servers.Start(5816);
            //}
            //else
            //{
            //    Output.WriteLine("Running as 1st Instance!");
            Servers.Start(9958);
            //    Process.Start("yi.exe", "secondInstance");
            //}

            PerformanceMonitor.Start();
        }
Beispiel #4
0
 private static void OpenShop(Player player, MsgAction packet)
 {
     player.BoothId   = 10000000 + player.UniqueId;
     player.Direction = (Direction)packet.Direction;
     BoothSystem.Create(player);
     packet.Param = player.BoothId;
     player.Send(packet);
 }
Beispiel #5
0
        public static async Task <bool> Load()
        {
            try
            {
                UniqueIdGenerator.Load();
                LoadItems();
                SquigglyDb.LoadMaps();
                SquigglyDb.LoadMobs();
                SquigglyDb.LoadSpawns();
                SquigglyDb.LoadNpcs();
                SquigglyDb.LoadLevelExp();
                SquigglyDb.LoadPortals();
                SquigglyDb.LoadItemBonus();
                SquigglyDb.Spawn();

                await Task.WhenAll(LoadStatpoints(), LoadSkills(), LoadAccounts(),
                                   LoadFloorItems(), LoadStoragePool(), LoadBoothPool());


                StorageSystem.SetUpStorageSpaces();
                BoothSystem.SetUpBooths();
                FloorItemSystem.SetUpFloorItemSystem();

                Output.WriteLine("|------------ Player Data ------------");
                Output.WriteLine("|");
                Output.WriteLine("|---> Accounts:     " + SelectorSystem.Players.Count);
                Output.WriteLine("|---> Storages:     " + StorageSystem.StoragePool.Count);
                Output.WriteLine("|---> Booths:       " + BoothSystem.BoothPool.Count);
                Output.WriteLine("|");
                Output.WriteLine("|------------ Common Data ------------");
                Output.WriteLine("|");
                Output.WriteLine("|---> Bots:         " + GameWorld.CountBots());
                Output.WriteLine("|---> Monsters:     " + GameWorld.CountMonsters());
                Output.WriteLine("|---> Npcs:         " + GameWorld.CountNpcs());
                Output.WriteLine("|---> DynamicNpcs:  " + GameWorld.CountDynNpcs());
                Output.WriteLine("|---> Maps:         " + GameWorld.Maps.Count);
                Output.WriteLine("|---> FloorItems:   " + FloorItemSystem.FloorItems.Count);
                Output.WriteLine("|---> Items:        " + Collections.Items.Count);
                Output.WriteLine("|---> ItemBonus:    " + Collections.ItemBonus.Count);
                Output.WriteLine("|---> LevelExp:     " + Collections.LevelExps.Count);
                Output.WriteLine("|---> StatPoints:   " + Collections.Statpoints.Count);
                Output.WriteLine("|---> Skills:       " + Collections.Skills.Count);
                Output.WriteLine("|---> Portals:      " + Collections.Portals.Count);
                Output.WriteLine("|---> Mob Drops:    " + MobDropSystem.Drops.Count);
                await SetUpScriptingEngine();

                Output.WriteLine("|-------------------------------------");
                Output.WriteLine("");
                GCSettings.LatencyMode = GCLatencyMode.SustainedLowLatency;
                YiCore.CompactLoh();
                return(true);
            }
            catch (Exception ex)
            {
                Output.WriteLine(ex);
                return(false);
            }
        }
Beispiel #6
0
 private static void AddItemToShop(Player player, ref MsgItem packet)
 {
     if (player.Inventory.TryGetItem(packet.UnqiueId, out var item))
     {
         BoothSystem.Add(player, packet.UnqiueId, packet.Param);
         ScreenSystem.Send(player, packet, true);
     }
     else
     {
         Message.SendTo(player, "Invalid Item", MsgTextType.Action);
     }
 }
Beispiel #7
0
        public static void Handle(Player player, byte[] buffer)
        {
            try
            {
                fixed(byte *p = buffer)
                {
                    var packet = *(MsgItem *)p;

                    BufferPool.RecycleBuffer(buffer);

                    switch (packet.Type)
                    {
                    case MsgItemType.BuyItemAddItem:
                        BuyItem(player, ref packet);
                        break;

                    case MsgItemType.SellItem:
                        SellItem(player, ref packet);
                        break;

                    case MsgItemType.RemoveInventory:
                        DropItem(player, ref packet);
                        break;

                    case MsgItemType.EquipItem:
                        EquipItem(player, ref packet);
                        break;

                    case MsgItemType.SetEquipPosition:
                        break;

                    case MsgItemType.UnEquipItem:
                        UnEquipItem(player, ref packet);
                        break;

                    case MsgItemType.ShowWarehouseMoney:
                        StorageSystem.ShowStock(player);
                        break;

                    case MsgItemType.DepositWarehouseMoney:
                        StorageSystem.PutInMoney(player, packet.Param);
                        break;

                    case MsgItemType.WithdrawWarehouseMoney:
                        StorageSystem.TakeOutMoney(player, packet.Param);
                        break;

                    case MsgItemType.DropGold:
                        DropGold(player, ref packet);
                        break;

                    case MsgItemType.RepairItem:
                        RepairItem(player, ref packet);
                        break;

                    case MsgItemType.UpgradeDragonball:
                        UpgradeDragonball(player, ref packet);
                        break;

                    case MsgItemType.UpgradeMeteor:
                        UpgradeMeteor(player, ref packet);
                        break;

                    case MsgItemType.ShowVendingList:
                        BoothSystem.Show(player, packet.UnqiueId);
                        break;

                    case MsgItemType.AddVendingItem:
                        AddItemToShop(player, ref packet);
                        break;

                    case MsgItemType.RemoveVendingItem:
                        RemoveItemFromShop(player, ref packet);
                        break;

                    case MsgItemType.BuyVendingItem:
                        BuyBoothItem(player, ref packet);
                        break;

                    case MsgItemType.Ping:
                        Ping(player, ref packet);
                        break;

                    case MsgItemType.Enchant:
                        UpgradeItemEnchant(player, ref packet);
                        break;

                    case MsgItemType.BoothAddCp:
                        player.GetMessage("Server", player.Name.TrimEnd('\0'), "This server doesn't use conquer points as currency.", MsgTextType.Action);
                        break;

                    default:
                        Output.WriteLine(((byte[])packet).HexDump());
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Output.WriteLine(e);
            }
        }
Beispiel #8
0
 private static void AddItemToShop(Player player, ref MsgItem packet)
 {
     BoothSystem.Add(player, packet.UnqiueId, packet.Param);
     ScreenSystem.Send(player, packet, true);
 }
Beispiel #9
0
 private static void RemoveItemFromShop(Player player, ref MsgItem packet)
 {
     BoothSystem.Remove(player, packet.UnqiueId);
     ScreenSystem.Send(player, packet, true);
 }