Alchemy
Loading...
Searching...
No Matches

item.h

Go to the documentation of this file.
1#ifndef ALCHEMY_ITEM_H
2#define ALCHEMY_ITEM_H
3
4/// @file
5/// Items: their definitions, types, flags and effects.
6
7#include "static_assert.h"
8#include "edition.h"
9#include "farcall.h"
10
11struct BattleUnit;
12
13/// An inventory entry's parts, and a unit's slot count.
14/// bits: 15..11 quantity | 10 broken | 9 equipped | 8..0 item id
16 ITEM_ID_MASK = 0x1ff,
24};
25
29 ITEM_RARE = 4, ///< selects the shop's rare item offers
32};
33
34/// What using an item costs (struct ItemDefinition's useType).
35#define ITEM_USE_CONSUMED 1 ///< one is used up
36#define ITEM_USE_MAY_BREAK 2 ///< breaks one time in eight
37/// Not used up: equipped, it teaches its actionId as Psynergy.
38#define ITEM_USE_TEACHES 3
39#define ITEM_USE_EMPTIES 4 ///< Hermes' Water leaves an Empty Bottle
40
41/// An item's type (struct ItemDefinition's type, items.tsv's type column).
42/// A unit equips one item of each type, except Psynergy items.
45 0, ///< not equipment: Herb, Game Ticket, the keys, unused rows
46 ITEM_TYPE_WEAPON = 1, ///< swords, axes, maces, rods and staffs
47 ITEM_TYPE_ARMOR = 2, ///< armor, clothes and robes
48 ITEM_TYPE_SHIELD = 3, ///< shields, gloves and armlets
49 ITEM_TYPE_HELM = 4, ///< helms, caps, crowns and circlets
50 ITEM_TYPE_BOOTS = 5, ///< Hyper Boots to Turtle Boots
51 /// The items that teach Psynergy while held: Orb of Force to Catch Beads.
53 ITEM_TYPE_RING = 8, ///< Adept Ring to Cleric's Ring
54 ITEM_TYPE_SHIRT = 9 ///< Mythril Shirt, Silk Shirt, Running Shirt
55};
56
73 /// Element power and resistance, in the element order Venus, Mercury, Mars,
74 /// Jupiter
83 ITEM_EFFECT_ADD_UNLEASH_CHANCE, ///< percent added to the weapon's unleash
84 ITEM_EFFECT_24, ///< summed by UnitCalc; TBS never reads it
85 ITEM_EFFECT_25, ///< sets restraint bit 3, which lifts bit 0
86 ITEM_EFFECT_ADD_TURNS, ///< more actions each round
87 ITEM_EFFECT_LURE ///< sets FLAG_LURE_CAP while worn: encounters come faster
88};
89
90/// One effect of an item while equipped: its kind (enum ItemEffectKind) and
91/// amount.
92struct ItemEffect {
93 u8 kind; ///< enum ItemEffectKind; 0 for none
94 s8 amount; ///< what the kind adds or scales by
95 u8 reserved02[2]; ///< not named by TBS code
96};
97
98STATIC_ASSERT(sizeof(struct ItemEffect) == 0x04);
99STATIC_ASSERT(offsetof(struct ItemEffect, kind) == 0x00);
100STATIC_ASSERT(offsetof(struct ItemEffect, amount) == 0x01);
101
102/// An item's definition: its price, type, who can equip it, its bonuses and
103/// unleash, its effects and the action it is used for.
105 s16 price; ///< coins
106 u8 type; ///< enum ItemType; 0 for an item that is not equipment
107 u8 flags; ///< enum ItemFlags
108 u16 equipMask; ///< one bit per character that can equip it, bit 0 Isaac
109 u16 icon; ///< indexes gUiIcon_ItemIconPointers
110 s16 primaryBonus; ///< Attack added while equipped
111 s8 secondaryBonus; ///< Defense added while equipped
112 u8 unleashChance; ///< in steps of 5 percent
113 u8 useType; ///< what using it costs (ITEM_USE_), or 0 for nothing
114 u8 reserved0d; ///< not named by TBS code
115 u16 unleashAction; ///< the action a weapon unleashes, or 0
116
117 u8 reserved10[4]; ///< not named by TBS code
118 s32 element; ///< a weapon's attack element; 4 for none
119 struct ItemEffect effects[4]; ///< what it does while equipped
120 u16 actionId; ///< the ability used, or taught as Psynergy
121 u8 reserved2a[2]; ///< not named by TBS code
122};
123
124STATIC_ASSERT(sizeof(struct ItemDefinition) == 0x2c);
125STATIC_ASSERT(offsetof(struct ItemDefinition, price) == 0x00);
126STATIC_ASSERT(offsetof(struct ItemDefinition, type) == 0x02);
127STATIC_ASSERT(offsetof(struct ItemDefinition, flags) == 0x03);
128STATIC_ASSERT(offsetof(struct ItemDefinition, equipMask) == 0x04);
129STATIC_ASSERT(offsetof(struct ItemDefinition, icon) == 0x06);
130STATIC_ASSERT(offsetof(struct ItemDefinition, primaryBonus) == 0x08);
131STATIC_ASSERT(offsetof(struct ItemDefinition, secondaryBonus) == 0x0a);
132STATIC_ASSERT(offsetof(struct ItemDefinition, unleashChance) == 0x0b);
133STATIC_ASSERT(offsetof(struct ItemDefinition, useType) == 0x0c);
134STATIC_ASSERT(offsetof(struct ItemDefinition, unleashAction) == 0x0e);
135STATIC_ASSERT(offsetof(struct ItemDefinition, element) == 0x14);
136STATIC_ASSERT(offsetof(struct ItemDefinition, effects) == 0x18);
137STATIC_ASSERT(offsetof(struct ItemDefinition, actionId) == 0x28);
138
140
141#endif
The edition's language, for C to compare (LANGUAGE == LANGUAGE_GERMAN).
Public interfaces to the engine's code banks.
ItemType
An item's type (struct ItemDefinition's type, items.tsv's type column).
Definition item.h:43
@ 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_NONE
not equipment: Herb, Game Ticket, the keys, unused rows
Definition item.h:44
@ 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_RING
Adept Ring to Cleric's Ring.
Definition item.h:53
@ 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
struct ItemDefinition * Item_Get(s32 item)
ItemEffectKind
Definition item.h:57
@ ITEM_EFFECT_ADD_MARS_RESIST
Definition item.h:81
@ ITEM_EFFECT_24
summed by UnitCalc; TBS never reads it
Definition item.h:84
@ ITEM_EFFECT_SCALE_HP_REGEN
Definition item.h:66
@ ITEM_EFFECT_ADD_JUPITER_POWER
Definition item.h:78
@ ITEM_EFFECT_SCALE_DEFENSE
Definition item.h:70
@ ITEM_EFFECT_SCALE_AGILITY
Definition item.h:71
@ ITEM_EFFECT_ADD_LUCK
Definition item.h:64
@ ITEM_EFFECT_ADD_VENUS_RESIST
Definition item.h:79
@ ITEM_EFFECT_ADD_HP
Definition item.h:59
@ ITEM_EFFECT_SCALE_HP
Definition item.h:65
@ ITEM_EFFECT_SCALE_LUCK
Definition item.h:72
@ ITEM_EFFECT_SCALE_ATTACK
Definition item.h:69
@ ITEM_EFFECT_LURE
sets FLAG_LURE_CAP while worn: encounters come faster
Definition item.h:87
@ ITEM_EFFECT_ADD_AGILITY
Definition item.h:63
@ ITEM_EFFECT_ADD_HP_REGEN
Definition item.h:60
@ ITEM_EFFECT_ADD_JUPITER_RESIST
Definition item.h:82
@ ITEM_EFFECT_ADD_PP_REGEN
Definition item.h:62
@ ITEM_EFFECT_SCALE_PP_REGEN
Definition item.h:68
@ ITEM_EFFECT_25
sets restraint bit 3, which lifts bit 0
Definition item.h:85
@ ITEM_EFFECT_ADD_VENUS_POWER
Element power and resistance, in the element order Venus, Mercury, Mars, Jupiter.
Definition item.h:75
@ ITEM_EFFECT_ADD_PP
Definition item.h:61
@ ITEM_EFFECT_ADD_MERCURY_POWER
Definition item.h:76
@ ITEM_EFFECT_SCALE_PP
Definition item.h:67
@ ITEM_EFFECT_NONE
Definition item.h:58
@ ITEM_EFFECT_ADD_TURNS
more actions each round
Definition item.h:86
@ ITEM_EFFECT_ADD_UNLEASH_CHANCE
percent added to the weapon's unleash
Definition item.h:83
@ ITEM_EFFECT_ADD_MARS_POWER
Definition item.h:77
@ ITEM_EFFECT_ADD_MERCURY_RESIST
Definition item.h:80
InventoryEncoding
An inventory entry's parts, and a unit's slot count.
Definition item.h:15
@ 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
ItemFlags
Definition item.h:26
@ ITEM_CANNOT_UNEQUIP
Definition item.h:28
@ ITEM_STACKABLE
Definition item.h:31
@ ITEM_CURSED
Definition item.h:27
@ ITEM_RARE
selects the shop's rare item offers
Definition item.h:29
@ ITEM_INDISPENSABLE
Definition item.h:30
STATIC_ASSERT, a compile-time check that emits nothing.
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
An item's definition: its price, type, who can equip it, its bonuses and unleash, its effects and the...
Definition item.h:104
u8 useType
what using it costs (ITEM_USE_), or 0 for nothing
Definition item.h:113
s8 secondaryBonus
Defense added while equipped.
Definition item.h:111
u8 type
enum ItemType; 0 for an item that is not equipment
Definition item.h:106
u8 reserved0d
not named by TBS code
Definition item.h:114
s32 element
a weapon's attack element; 4 for none
Definition item.h:118
s16 primaryBonus
Attack added while equipped.
Definition item.h:110
s16 price
coins
Definition item.h:105
u16 unleashAction
the action a weapon unleashes, or 0
Definition item.h:115
u16 actionId
the ability used, or taught as Psynergy
Definition item.h:120
struct ItemEffect effects[4]
what it does while equipped
Definition item.h:119
u8 unleashChance
in steps of 5 percent
Definition item.h:112
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
u16 icon
indexes gUiIcon_ItemIconPointers
Definition item.h:109
u8 reserved2a[2]
not named by TBS code
Definition item.h:121
u8 reserved10[4]
not named by TBS code
Definition item.h:117
One effect of an item while equipped: its kind (enum ItemEffectKind) and amount.
Definition item.h:92
u8 reserved02[2]
not named by TBS code
Definition item.h:95
u8 kind
enum ItemEffectKind; 0 for none
Definition item.h:93
s8 amount
what the kind adds or scales by
Definition item.h:94
signed int s32
Definition types.h:14
signed char s8
Definition types.h:10
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11