Alchemy
Loading...
Searching...
No Matches

inventory.c

Go to the documentation of this file.
1/// @file
2/// Items and inventories: equipping, adding, removing, breaking and counting.
3/// Part of game.c, the game object, compiled only through it.
4
5#include "../game_internal.h"
6
7/// Returns item `item`'s definition; an inventory entry may be passed, its
8/// equipped and quantity bits are ignored. Every bank that shows or uses an
9/// item calls it, through GAME.S as Item_GetDirectFar.
11 return gItem_DefinitionTable + (item & ITEM_ID_MASK);
12}
13
14/// Returns whether the character can equip `item`: bit classId of the item's
15/// equipMask. Units past the eight characters cannot. Inventory_Equip checks
16/// it first.
18 struct BattleUnit *unit = UnitGet(owner);
19 struct ItemDefinition *itemDefinition = Item_GetDirect(item);
20 s32 equipMask = itemDefinition->equipMask;
21
22 if (unit->classId >= 8) {
23 return 0;
24 }
25 return (equipMask >> unit->classId) & 1;
26}
27
28/// Returns 1 for an item that is not a weapon or armor, and for those whether
29/// the character can equip it. The shop's buy screen calls it to grey out the
30/// members who could not use an item.
32 if (Item_GetEquipmentGroup(item) == 0) {
33 return 1;
34 }
35 return Item_CanOwnerEquipDirect(unit, item);
36}
37
38/// Returns what kind of thing an item is: 1 a weapon, 2 armor (armor,
39/// shields, helms, boots and shirts), 0 anything else, rings included. Called
40/// by the shops to choose the comparison they show.
42 s32 group;
43 struct ItemDefinition *item;
44
45 item = Item_GetDirect(itemId);
46 group = 0;
47 if (item->type == ITEM_TYPE_WEAPON)
48 group = 1;
49 else if (item->type == ITEM_TYPE_ARMOR)
50 group = 2;
51 else if (item->type == ITEM_TYPE_SHIELD)
52 group = 2;
53 else if (item->type == ITEM_TYPE_HELM)
54 group = 2;
55 else if (item->type == ITEM_TYPE_BOOTS)
56 group = 2;
57 else if (item->type == ITEM_TYPE_SHIRT)
58 group = 2;
59 return group;
60}
61
62/// Returns how many of the item in `slot` the unit carries (0 for an empty
63/// slot). The entry stores one less than the count. Reached through GAME.S as
64/// Shop_GetSelectionState; nothing in this image calls it by name.
66 s32 itemId;
67
68 owner = UnitGet(owner)->inventory[slot];
69 itemId = ITEM_ID_MASK;
70 itemId &= owner;
71 owner = (u32)owner >> INVENTORY_QUANTITY_SHIFT;
72 owner++;
73 if (itemId == 0) {
74 owner = 0;
75 }
76 return owner;
77}
78
79/// Counts filled inventory slots up to the first empty slot; the inventory is
80/// kept closed up, so this is how many items the unit carries. Called by the
81/// shops before they add an item and to lay out their item grids.
83 struct BattleUnit *unit = UnitGet(owner);
84 s32 count = 0;
85
86 if (unit->inventory[count] != 0) {
87 do {
88 count++;
89 if (count > 14)
90 break;
91 } while (unit->inventory[count] != 0);
92 }
93 return count;
94}
95
96/// Returns 1 when the selected character or any party member has a free
97/// inventory slot. Called by the scenes that give an item (the Vault's Water
98/// of Life and the bones) and the debug item menus.
100 s16 owners[10];
101 s32 ownerCount;
102 s32 ownerIndex;
103 s16 *ownerCursor;
104
106 return 1;
107 ownerCount = Party_ListActiveOwners(owners);
108 ownerCursor = owners;
109 ownerIndex = 0;
110 if (ownerIndex < ownerCount) {
111 do {
112 if (Inventory_Count(*ownerCursor++) != INVENTORY_SLOTS)
113 return 1;
114 ownerIndex++;
115 } while (ownerIndex < ownerCount);
116 }
117 return 0;
118}
119
120/// Returns the free inventory slots of the whole party. Called by the Tolbi
121/// spring game and the lucky wheels to cap what the player can win.
123 s16 owners[10];
124 s32 ownerCount = Party_ListActiveOwners(owners);
125 s32 freeSlots = 0;
126 s16 *ownerCursor = owners;
127
128 if (freeSlots < ownerCount) {
129 s32 remainingOwners = ownerCount;
130
131 do {
132 freeSlots = freeSlots - Inventory_Count(*ownerCursor++) + INVENTORY_SLOTS;
133 remainingOwners--;
134 } while (remainingOwners != 0);
135 }
136 return freeSlots;
137}
138
139/// Gives a unit one item, joining its first matching stack (up to 30) or
140/// taking the first free slot. A full matching stack fails immediately, even
141/// if another slot is free. Writes the inventory slot; returns it, or -1 when
142/// there was no room. Called by the shops, the new game set-up, the debug
143/// presets and PartyInventory_Add.
144s32 Inventory_AddItem(s32 owner, s32 itemId) {
145 struct BattleUnit *unit = UnitGet(owner);
146 struct ItemDefinition *item = Item_GetDirect(itemId);
147 s32 slot;
148
149 if ((item->flags & ITEM_STACKABLE) != 0) {
150 slot = 0;
151 if (((unit->inventory[slot] ^ itemId) & ITEM_ID_MASK) != 0) {
152 do {
153 slot++;
154 if (slot >= INVENTORY_SLOTS)
155 break;
156 } while (((unit->inventory[slot] ^ itemId) & ITEM_ID_MASK) != 0);
157 }
158 if (slot != INVENTORY_SLOTS) {
159 s32 entry = unit->inventory[slot];
160 u32 count = ((u32)entry >> INVENTORY_QUANTITY_SHIFT) + 1;
161
162 if (count > 29)
163 return -1;
164 {
166
167 value &= entry;
168 value |= count << INVENTORY_QUANTITY_SHIFT;
169 unit->inventory[slot] = value;
170 }
171 return slot;
172 }
173 }
174
175 slot = 0;
176 do {
177 if (unit->inventory[slot] == 0) {
178 unit->inventory[slot] = itemId;
179 return slot;
180 }
181 slot++;
182 } while (slot < INVENTORY_SLOTS);
183 return -1;
184}
185
186/// Gives the item to the first party member with room. Returns who took it,
187/// or -1. Called for a battle's spoils, a chest or search in the field, and
188/// the scenes that give items.
190 s16 owners[10];
191 s32 ownerCount;
192 s32 ownerIndex;
193 s16 *ownerCursor;
194
195 ownerCount = Party_ListActiveOwners(owners);
196 ownerCursor = owners;
197 ownerIndex = 0;
198 if (ownerIndex < ownerCount) {
199 do {
200 s16 ownerId = *ownerCursor++;
201
202 if (Inventory_AddItem(ownerId, itemId) >= 0)
203 return ownerId;
204 ownerIndex++;
205 } while (ownerIndex < ownerCount);
206 }
207 return -1;
208}
209
210/// Returns the first slot holding `itemId` (any quantity, equipped or not),
211/// or -1. Called by the shops and the scenes that check for an item.
212s32 Inventory_Find(s32 owner, s32 itemId) {
213 struct BattleUnit *inv = UnitGet(owner);
214 s32 slot = 0;
215 u16 *entry = inv->inventory;
216
217 do {
218 if (((*entry++) & ITEM_ID_MASK) == itemId) {
219 return slot;
220 }
221 slot++;
222 } while (slot < INVENTORY_SLOTS);
223 return -1;
224}
225
226/// Returns who carries `itemId`, asking the selected character first, or -1.
227/// Called by the scenes that need a key item, such as the Mercury Lighthouse's
228/// Hermes' Water and Kolima's Tret.
230 s16 owners[10];
231 s32 ownerCount;
232 s32 ownerIndex;
233 s16 *ownerCursor;
234 s16 owner;
235
236 if (Inventory_Find(gGameState.selectedActor, itemId) != -1)
238 ownerCount = Party_ListActiveOwners(owners);
239 ownerCursor = owners;
240 ownerIndex = 0;
241 if (ownerIndex < ownerCount) {
242 do {
243 owner = *ownerCursor++;
244 if (Inventory_Find(owner, itemId) != -1)
245 return owner;
246 ownerIndex++;
247 } while (ownerIndex < ownerCount);
248 }
249 return -1;
250}
251
252/// Equips the item in `slot`, clearing the equipped bit of the item of the
253/// same type it replaces. Psynergy items may coexist. Recomputes the unit's
254/// Psynergy and stats. Returns 0, -1 when the unit cannot equip it, or -2
255/// when the item it would replace is cursed on. Called by the item menu, the
256/// shop's equip prompt, the new game set-up and the debug presets.
258 struct BattleUnit *unit = UnitGet(owner);
259 u32 inventoryEntry = unit->inventory[slot];
260 struct ItemDefinition *item;
261 u8 type;
262 s32 equippedSlot;
263
264 if (Item_CanOwnerEquipDirect(owner, inventoryEntry) == 0)
265 return -1;
266 if (inventoryEntry & INVENTORY_EQUIPPED)
267 return 0;
268
269 item = Item_GetDirect(inventoryEntry);
270 type = item->type;
271 if (type != ITEM_TYPE_PSYNERGY) {
272 for (equippedSlot = 0; equippedSlot < INVENTORY_SLOTS; equippedSlot++) {
273 if ((unit->inventory[equippedSlot] & INVENTORY_EQUIPPED) == 0)
274 continue;
275 if (Item_GetDirect(unit->inventory[equippedSlot])->type == type)
276 break;
277 }
278
279 if (equippedSlot != INVENTORY_SLOTS) {
280 item = Item_GetDirect(unit->inventory[equippedSlot]);
281 if (item->flags & ITEM_CANNOT_UNEQUIP)
282 return -2;
283 unit->inventory[equippedSlot] &= (u16)~INVENTORY_EQUIPPED;
284 }
285 }
286
287 unit->inventory[slot] |= INVENTORY_EQUIPPED;
289 UnitCalc(owner);
290 return 0;
291}
292
293/// Returns the slot of the equipped item of `type`, or -1. Called by the
294/// shops to compare what is worn and to repair it, and by the battle sprites
295/// to draw the member's weapon.
297 struct BattleUnit *base = UnitGet(owner);
298 s32 index;
299 struct ItemDefinition *item;
300
301 for (index = 0; index < INVENTORY_SLOTS; index++) {
302 if (base->inventory[index] & INVENTORY_EQUIPPED) {
303 item = Item_GetDirect(base->inventory[index]);
304 if (item->type == type)
305 break;
306 }
307 }
308 if (index == INVENTORY_SLOTS)
309 index = -1;
310 return index;
311}
312
313/// Returns the definition of the unit's equipped item of `type`, or NULL.
314/// Nothing calls it by name.
316 s32 type) {
317 s32 slot;
318 struct ItemDefinition *item;
319
320 for (slot = 0; slot < INVENTORY_SLOTS; slot++) {
321 if (unit->inventory[slot] & INVENTORY_EQUIPPED) {
322 item = Item_GetDirect(unit->inventory[slot]);
323 if (item->type == type) {
324 return item;
325 }
326 }
327 }
328 return 0;
329}
330
331/// Returns the id of the unit's equipped item of `type`, or 0. Called by
332/// BattleObjMake to draw a member's weapon, and by the battle plan.
334 s32 slot;
335
336 for (slot = 0; slot < INVENTORY_SLOTS; slot++) {
337 if (unit->inventory[slot] & INVENTORY_EQUIPPED) {
338 struct ItemDefinition *item = Item_GetDirect(unit->inventory[slot]);
339
340 if (item->type == type) {
341 return unit->inventory[slot] & ITEM_ID_MASK;
342 }
343 }
344 }
345 return 0;
346}
347
348/// Takes one item out of `slot`: a stack shrinks by one (returns 1), a last
349/// item empties the slot and the inventory closes up (returns 2). Returns -1
350/// for an empty slot. The unit's stats are recomputed either way. Called by
351/// using an item in the field or in battle, by the shops and by
352/// Inventory_Discard.
354 struct BattleUnit *unit = UnitGet(owner);
355 u16 item = unit->inventory[slot];
356 s32 result = -1;
357
358 if (item != 0) {
359 if (item & INVENTORY_QUANTITY_MASK) {
360 unit->inventory[slot] = item - INVENTORY_QUANTITY_STEP;
361 result = 1;
362 } else {
363 unit->inventory[slot] = 0;
364 Inventory_CompactSlots(unit->inventory);
365 result = 2;
366 }
367 }
368 UnitCalc(owner);
369 return result;
370}
371
372/// Removes one item as Inventory_Remove does, and puts a rare item back into
373/// circulation (its counter goes up by one) for the shops to sell. Called
374/// by selling an item and by the scenes that take an item away.
376 s32 item = UnitGet(owner)->inventory[slot];
377 s32 removalResult = Inventory_Remove(owner, slot);
378
379 if (removalResult != -1) {
380 Item_AdjustCounter(item, 1);
382 }
383 return removalResult;
384}
385
386/// Returns whether the item in `slot` may be dropped: 0 yes, -1 the slot is
387/// empty, -4 the item is indispensable, -3 it is equipped and cursed on.
388/// Called by the shop's item picker before it lets an item go.
390 struct BattleUnit *unit = UnitGet(owner);
391 s32 itemId = unit->inventory[slot] & ITEM_ID_MASK;
392 struct ItemDefinition *item = Item_GetDirect(itemId);
393
394 if (itemId == 0) {
395 return -1;
396 }
397 if ((item->flags & ITEM_INDISPENSABLE) != 0) {
398 return -4;
399 }
400 if ((unit->inventory[slot] & INVENTORY_EQUIPPED) != 0 &&
401 (item->flags & ITEM_CANNOT_UNEQUIP) != 0) {
402 return -3;
403 }
404 return 0;
405}
406
407/// Removes one `itemId` from whoever carries it first; always returns 0.
408/// Called by the scenes that use up a key item, the slot machine's Game
409/// Tickets and the field shortcut that uses an item.
411 s32 owner = PartyInventory_FindOwner(itemId);
412
413 if (owner == -1)
414 return 0;
415 Inventory_Remove(owner, Inventory_Find(owner, itemId));
416 return 0;
417}
418
419/// Discards one `itemId` from whoever carries it first, as Inventory_Discard
420/// does; always returns 0. Called by the scenes that take an item back, such
421/// as the Vault dog's bone and the Black Orb.
423 s32 owner = PartyInventory_FindOwner(itemId);
424
425 if (owner == -1)
426 return 0;
427 Inventory_Discard(owner, Inventory_Find(owner, itemId));
428 return 0;
429}
430
431/// Marks the item in `slot` broken; returns -1 for an empty slot. Called when
432/// a used item breaks, in battle or from the item menu.
434 struct BattleUnit *inv = UnitGet(owner);
435 if (inv->inventory[slot] == 0) {
436 return -1;
437 }
438 inv->inventory[slot] |= INVENTORY_BROKEN;
439 return 0;
440}
441
442/// Clears the broken mark of the item in `slot`; returns -1 for an empty
443/// slot. Called by the shop's repair.
445 struct BattleUnit *inv = UnitGet(owner);
446 if (inv->inventory[slot] == 0) {
447 return -1;
448 }
449 inv->inventory[slot] &= ~INVENTORY_BROKEN;
450 return 0;
451}
452
453/// Returns how the action an item performs when used picks its targets. Only
454/// GAME.S's bare veneer reaches it; nothing calls it by name.
456 return BattleAction_GetDirect(Item_GetDirect(itemId)->actionId)->targetMode;
457}
458
459/// Adds `delta` to rare item counter `index`, kept between 0 and 99, and
460/// returns the new count (0 for an index past 127).
462 s32 counter_slot = index;
463 u8 *data = gItemCounters;
464
465 index = 0;
466 if (counter_slot <= 127) {
467 s32 value = data[counter_slot];
468
469 value += delta;
470
471 if (value < 0) {
472 value = 0;
473 } else if (value > 99) {
474 value = 99;
475 index = 99;
476 } else {
477 index = value;
478 }
479 data[counter_slot] = value;
480 }
481 return index;
482}
483
484/// Adds `delta` to the counter of a rare item; ordinary items have none.
485/// Returns the new count, or 0. The counters are how many of each rare item
486/// the shops may sell: buying one takes one, discarding or selling puts one
487/// back.
489 s32 itemIdMask = ITEM_ID_MASK;
490 u8 counter;
491 s32 result = 0;
492
493 counter = gItem_ArtifactSlotTable[itemId & itemIdMask];
494 if (counter != 0) {
495 result = ItemCounter_Adjust(counter - 1, delta);
496 }
497 return result;
498}
499
500/// Counts matching nonstackable items, or the quantity in the first matching
501/// stack. Called by PartyInventory_CountItem and by the events that give an
502/// item, to keep stacks under their limit.
504 struct BattleUnit *unit = UnitGet(owner);
505 s32 count = 0;
506 s32 itemIdOnly = itemId & ITEM_ID_MASK;
507 s32 slot = 0;
508
509 do {
510 if ((unit->inventory[slot] & ITEM_ID_MASK) == itemIdOnly) {
511 struct ItemDefinition *item = Item_GetDirect(itemIdOnly);
512
513 if (item->flags & ITEM_STACKABLE) {
514 count = (unit->inventory[slot] >> INVENTORY_QUANTITY_SHIFT) + 1;
515 break;
516 }
517 count++;
518 }
519 slot++;
520 } while (slot < INVENTORY_SLOTS);
521 return count;
522}
523
524/// Counts `itemId` across the party. Called by the slot machine (Game
525/// Tickets) and the Tolbi spring game.
527 u16 owners[16];
528 s32 itemCount = 0;
529 s32 ownerCount = Party_ListActiveOwners(owners);
530
531 if (itemCount < ownerCount) {
532 u16 *ownerCursor = owners;
533 s32 remainingOwners = ownerCount;
534
535 do {
536 itemCount += Inventory_CountItem(*ownerCursor++, itemId);
537 remainingOwners--;
538 } while (remainingOwners != 0);
539 }
540 return itemCount;
541}
void Event_ClearInvalidPackedValuesFar(void)
u8 gItem_ArtifactSlotTable[]
struct ItemDefinition gItem_DefinitionTable[]
u8 gItemCounters[128]
What every part of the game object shares: its includes and the inventory helper two parts use.
struct GameState gGameState
u8 Item_GetTargetMode(s32 itemId)
Returns how the action an item performs when used picks its targets.
Definition inventory.c:455
s32 PartyInventory_Discard(s32 itemId)
Discards one itemId from whoever carries it first, as Inventory_Discard does; always returns 0.
Definition inventory.c:422
s32 PartyInventory_HasSpace(void)
Returns 1 when the selected character or any party member has a free inventory slot.
Definition inventory.c:99
struct ItemDefinition * Inventory_GetEquippedDefinition(struct BattleUnit *unit, s32 type)
Returns the definition of the unit's equipped item of type, or NULL.
Definition inventory.c:315
s32 Inventory_FindEquipped(s32 owner, s32 type)
Returns the slot of the equipped item of type, or -1.
Definition inventory.c:296
s32 Inventory_CheckDiscard(s32 owner, s32 slot)
Returns whether the item in slot may be dropped: 0 yes, -1 the slot is empty, -4 the item is indispen...
Definition inventory.c:389
s32 Inventory_GetEquippedItem(struct BattleUnit *unit, s32 type)
Returns the id of the unit's equipped item of type, or 0.
Definition inventory.c:333
s32 Inventory_GetQuantity(s32 owner, s32 slot)
Returns how many of the item in slot the unit carries (0 for an empty slot).
Definition inventory.c:65
s32 Inventory_AddItem(s32 owner, s32 itemId)
Gives a unit one item, joining its first matching stack (up to 30) or taking the first free slot.
Definition inventory.c:144
s32 Item_IsCompatibleWithOwner(s32 unit, s32 item)
Returns 1 for an item that is not a weapon or armor, and for those whether the character can equip it...
Definition inventory.c:31
s32 Inventory_Count(s32 owner)
Counts filled inventory slots up to the first empty slot; the inventory is kept closed up,...
Definition inventory.c:82
s32 Inventory_Equip(s32 owner, s32 slot)
Equips the item in slot, clearing the equipped bit of the item of the same type it replaces.
Definition inventory.c:257
struct ItemDefinition * Item_GetDirect(s32 item)
Returns item item's definition; an inventory entry may be passed, its equipped and quantity bits are ...
Definition inventory.c:10
s32 ItemCounter_Adjust(s32 index, s32 delta)
Adds delta to rare item counter index, kept between 0 and 99, and returns the new count (0 for an ind...
Definition inventory.c:461
s32 PartyInventory_CountItem(s32 itemId)
Counts itemId across the party.
Definition inventory.c:526
s32 Inventory_Repair(s32 owner, s32 slot)
Clears the broken mark of the item in slot; returns -1 for an empty slot.
Definition inventory.c:444
s32 Inventory_Discard(s32 owner, s32 slot)
Removes one item as Inventory_Remove does, and puts a rare item back into circulation (its counter go...
Definition inventory.c:375
s32 Inventory_Find(s32 owner, s32 itemId)
Returns the first slot holding itemId (any quantity, equipped or not), or -1.
Definition inventory.c:212
s32 Inventory_CountItem(s32 owner, s32 itemId)
Counts matching nonstackable items, or the quantity in the first matching stack.
Definition inventory.c:503
s32 PartyInventory_CountFreeSlots(void)
Returns the free inventory slots of the whole party.
Definition inventory.c:122
s32 Inventory_Remove(s32 owner, s32 slot)
Takes one item out of slot: a stack shrinks by one (returns 1), a last item empties the slot and the ...
Definition inventory.c:353
s32 PartyInventory_FindOwner(s32 itemId)
Returns who carries itemId, asking the selected character first, or -1.
Definition inventory.c:229
s32 Item_GetEquipmentGroup(s32 itemId)
Returns what kind of thing an item is: 1 a weapon, 2 armor (armor, shields, helms,...
Definition inventory.c:41
s32 PartyInventory_Add(s32 itemId)
Gives the item to the first party member with room.
Definition inventory.c:189
s32 Item_AdjustCounter(s32 itemId, s32 delta)
Adds delta to the counter of a rare item; ordinary items have none.
Definition inventory.c:488
s32 Inventory_Break(s32 owner, s32 slot)
Marks the item in slot broken; returns -1 for an empty slot.
Definition inventory.c:433
s32 Item_CanOwnerEquipDirect(s32 owner, s32 item)
Returns whether the character can equip item: bit classId of the item's equipMask.
Definition inventory.c:17
s32 PartyInventory_Remove(s32 itemId)
Removes one itemId from whoever carries it first; always returns 0.
Definition inventory.c:410
@ ITEM_TYPE_ARMOR
armor, clothes and robes
Definition item.h:47
@ ITEM_TYPE_HELM
helms, caps, crowns and circlets
Definition item.h:49
@ ITEM_TYPE_SHIELD
shields, gloves and armlets
Definition item.h:48
@ ITEM_TYPE_PSYNERGY
The items that teach Psynergy while held: Orb of Force to Catch Beads.
Definition item.h:52
@ ITEM_TYPE_WEAPON
swords, axes, maces, rods and staffs
Definition item.h:46
@ ITEM_TYPE_SHIRT
Mythril Shirt, Silk Shirt, Running Shirt.
Definition item.h:54
@ ITEM_TYPE_BOOTS
Hyper Boots to Turtle Boots.
Definition item.h:50
@ INVENTORY_QUANTITY_STEP
Definition item.h:21
@ INVENTORY_EQUIPPED
Definition item.h:17
@ INVENTORY_SLOTS
Definition item.h:23
@ INVENTORY_QUANTITY_MASK
Definition item.h:22
@ INVENTORY_ENTRY_MASK
Definition item.h:19
@ ITEM_ID_MASK
Definition item.h:16
@ INVENTORY_QUANTITY_SHIFT
Definition item.h:20
@ INVENTORY_BROKEN
Definition item.h:18
@ ITEM_CANNOT_UNEQUIP
Definition item.h:28
@ ITEM_STACKABLE
Definition item.h:31
@ ITEM_INDISPENSABLE
Definition item.h:30
s32 Unit_RefreshPsynergy(s32 owner)
Rebuilds a character's Psynergy list: drops the actions its class and items gave, closes up the list,...
Definition levels.c:68
struct BattleAct * BattleAction_GetDirect(s32 actionId)
Returns the definition of action actionId (its low 14 bits); an id past the table gives the first.
Definition levels.c:10
s32 Party_ListActiveOwners(s16 *owners)
Writes the party members to owners, ending with 0xff, and returns how many there are.
Definition party.c:173
u8 targetMode
TARGET_MODE_NONE, _FOES, _ALLIES or _SELF.
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u8 classId
Who the unit is: a character's id (ISAAC to JENNA, below 8) or an enemy's id (BattleUnitSet).
u16 inventory[15]
Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*...
s32 selectedActor
the leader: its unit and its actor
Definition game_state.h:59
An item's definition: its price, type, who can equip it, its bonuses and unleash, its effects and the...
Definition item.h:104
u8 type
enum ItemType; 0 for an item that is not equipment
Definition item.h:106
u8 flags
enum ItemFlags
Definition item.h:107
u16 equipMask
one bit per character that can equip it, bit 0 Isaac
Definition item.h:108
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
void UnitCalc(s32 owner)
Recomputes a unit's stats from its base stats, equipment, set Djinn, class and battle stat levels,...
Definition units.c:149
struct BattleUnit * UnitGet(u32 owner)
Returns the unit record of owner: 0 to 7 are the playable characters in the game state,...
Definition units.c:73