コード例 #1
0
        public DropTables(NecServer server)
        {
            _server    = server;
            dropTables = new List <DropTable>();
            DropTable     beetle = new DropTable(40101);
            DropTableItem item1  = new DropTableItem();

            item1.ItemId   = 1;
            item1.Rarity   = 1;
            item1.MinItems = 1;
            item1.Maxitems = 5;
            DropTableItem item2 = new DropTableItem();

            item2.ItemId   = 50100101;
            item2.Rarity   = 2;
            item2.MinItems = 1;
            item2.Maxitems = 3;
            DropTableItem item3 = new DropTableItem();

            item3.ItemId   = 10200101;
            item3.Rarity   = 3;
            item3.MinItems = 1;
            item3.Maxitems = 1;

            beetle.AddItem(item1);
            beetle.AddItem(item2);
            beetle.AddItem(item3);
            dropTables.Add(beetle);
        }
コード例 #2
0
        public DropItem GetLoot(int monsterId)
        {
            monsterId = 40101; //   All monsters are beetles for now!!
            int       roll        = LootRoll();
            DropTable monsterDrop = dropTables.Find(x => x.MonsterId == monsterId);
            DropItem  dropItem    = null;

            if (monsterDrop != null)
            {
                List <DropTableItem> ItemDrop = monsterDrop.FindAll(roll);
                if (ItemDrop.Count == 1)
                {
                    Logger.Debug($"ItemId [ItemDrop ItemId {ItemDrop[0].ItemId}]");
                    if (!_server.SettingRepository.Items.TryGetValue(ItemDrop[0].ItemId, out ItemSetting itemSetting))
                    {
                        Logger.Error($"Could not retrieve ItemSettings for ItemId [{ItemDrop[0].ItemId}]");
                        return(null);
                    }

                    Logger.Debug($"ItemId [ItemDrop ItemId {ItemDrop[0].ItemId}]");
                    if (itemSetting.Id == 10200101)
                    {
                        itemSetting.IconType = 2;
                    }
                    else if (itemSetting.Id == 80000101)
                    {
                        itemSetting.IconType = 55;
                    }

                    Item item = _server.Instances64
                                .CreateInstance <Item>(); //  Need to get fully populated Item repository
                    item.AddItemSetting(itemSetting);
                    int numItems = GetNumberItems(ItemDrop[0].MinItems, ItemDrop[0].Maxitems + 1);
                    dropItem = new DropItem(numItems, item);
                }
            }
            else
            {
                if (!_server.SettingRepository.Items.TryGetValue(50100301, out ItemSetting itemSetting))
                {
                    Logger.Error($"Could not retrieve ItemSettings for default Item Camp");
                    return(null);
                }

                Item item = new Item(); //  Need to get fully populated Item repository
                item.IconType = 45;
                item.ItemType = 1;
                dropItem      = new DropItem(1, item);
            }

            return(dropItem);
        }