Page 1 of 1

Items & Slots

Posted: Sun Oct 05, 2008 1:06 pm
by John Adams
LE,
Can you (or anyone who's played with this) give us a quick refresher course on how "slots" work? I am trying to build starting_items for testing, and when I put your Bottomless Bag of Envy in slot 0, most of the time it does not show up on the character. The only way I get it to appear is to /summonitem 1 and then I can see it. When comparing the before/after slot configs, my starting_items slot setup is exactly what is expected, yet the item only shows visible in my inventory if I summon it in-game.
I have been able to get food/water to show up on a new character, but most of the time if I set it to slot 1 and 2 (since slot 0 should be the bag?), the food and water show up INSIDE the bag, at slot 1 and 2 of the bag. Noticing again after summon and placing in my inventory, there is something weird about the field character_items.bag_slot = 255 for items appearing in my normal 0-5 inventory slots. Seems the only way to get something to show up OUTSIDE a bag is to make it's bag_slot = the max + 1 slots inside the bag.
Horribly confusing. Can you give me a simplified description of how these should work?
TIA,
-J
Code says:

Code: Select all

#define NUM_INV_SLOTS 6
#define INV_SLOT1 0
#define INV_SLOT2 50
#define INV_SLOT3 100
#define INV_SLOT4 150
#define INV_SLOT5 200
#define INV_SLOT6 250
I have been assuming that in order to get something to appear in slot 2 of my 6-slot inventory, it's slot needs to be set to 50. otherwise, it'll show up inside some bag slot in slot1 - which if this is not a bag, puts it into some mysterious void from which there is no return. But this does not jive with /summonitem item placement. ~confused~

Posted: Sun Oct 05, 2008 1:41 pm
by John Adams
As usual, I post a request for help and suddenly "get it". Though I still would like clarification of the why things work this way, here's what I have discovered and been able to make work...
In my starting_items table, I set bag_slot = 255 for every item (this I do not understand). Then all the other slot assignments work as expected. Slot 0 is a bag, slot 1 is food, slot 2 is water, slot 3 is some random item. Now I have 4 of my 6 inventory slots full and nothing is >inside< the bag itself.
Furthermore, not sure where `count` comes into this, as the bag and random item `count` = 0 seems to work. But if I wanted a stack of food and water, I assume setting `count` = 20 would do the trick.
This is where some confusion still sets in... if I wanted to put that food and water inside the bag, I set the bag_id to 5 (5? why 5?), set the water's bag_slot = 0, but the food's bag_slot = 255 still (boggle). The `slot` settings make sense, being 0 and 1 respectively. But I do not get bag_id = 5 nor the reason behind bag_slot 0 and 255 for 2 items belonging in the same bag.
Answers I seek:
- Why does bag_slot = 255 make things appear in slots1-slot6?
- Why when I move items to a bag in slot1 does the bag_id = 5?
- Why when 2 items are in slot 0 and 1 of bag_id 5, is bag_slot 0 and 255 for the 2 items?
- Most importantly, why is it when I setup my starting_items exactly as the slot/bag configs in character_items, it simply does not work the same if items are starting inside a bag? :)
Thanks

Posted: Sun Oct 05, 2008 5:53 pm
by LethalEncounter
John Adams wrote: Answers I seek:
-(1) Why does bag_slot = 255 make things appear in slots1-slot6?
-(2) Why when I move items to a bag in slot1 does the bag_id = 5?
-(3) Why when 2 items are in slot 0 and 1 of bag_id 5, is bag_slot 0 and 255 for the 2 items?
-(4) Most importantly, why is it when I setup my starting_items exactly as the slot/bag configs in character_items, it simply does not work the same if items are starting inside a bag? :)
It has been a while since I have messed with these, but this is how I remember it. I'll answer your questions below, but let me explain the purposes of each field first.
id - the unique id for an item, used by the client in game for various stuff
type - kinda obvious (NOT-EQUIPPED, or EQUIPPED)
char_id - character id
bag_slot - A field that will be removed when I redesign items. Until then use a 255 in this field if it is an inventory item, otherwise the inventory slot the bag is in.
slot - The slot the item is in, if bag_id is > 0 then it is inside the bag.
item_id - item id
creator - Created by name
condition - item condition
attuned - 1 if it is attuned
bag_id - if this field is greater than 0, then it points to the bag's unique id (id field of the bag). In your case the 5 in this field means that the id field for your bag is 5.
count - item count, limited usage right now
max_sell_value - max sell value, limited usage right now
1. If bag slot is equal to 255, then it is an inventory item and is not in a bag. It is a little redundant since the 0 for bag_id also means that it is an inventory item, but both fields are necessary as explained above.
2. It doesnt matter what slot the bag is in, the bag_id field is the same as the id field for the bag entry. So in your case, the id of the bag entry in the table is 5.
3. It shouldn't be, bag slot 255 is currently reversed for inventory usage.
4. Gremlins? I'm not sure why, but I'll fix it when I rework items.