LI2 Roguelite
item.h
Go to the documentation of this file.
1 #ifndef _ITEM_H_
2 #define _ITEM_H_
3 
4 typedef struct map Map;
5 
28 typedef struct item {
29  char *name;
30  char symbol;
31  int type; // 0: body weapon, 1: projectile weapon, 2: armor, 3: potion, 4: gold
32  int value;
33  unsigned int x;
34  unsigned int y;
35  int damage;
36  int defense;
37  int hp;
38  int count;
39  int range;
40  int color;
41 } Item;
42 
43 #define MAX_ITEMS 100 // TODO use this
44 #define MAX_ITEM_NAME 20 // TODO use this
45 
46 // Item types
47 #define WEAPON 0
48 #define PROJECTILE 1
49 #define ARMOR 2
50 #define POTION 3
51 #define GOLD 4
52 
53 // Speficic item macros
54 // Rock
55 #define ROCK_VALUE 1
56 #define ROCK_DAMAGE_MIN 5
57 #define ROCK_DAMAGE_MAX 7
58 #define ROCK_SYMBOL ':'
59 #define ROCK_TYPE PROJECTILE
60 #define ROCK_RANGE 7 // cells
61 #define ROCK_COLOR COLOR_CYAN
62 
63 // Smoke bomb
64 #define SMOKE_BOMB_VALUE 30
65 #define SMOKE_BOMB_DAMAGE_MIN 10
66 #define SMOKE_BOMB_DAMAGE_MAX 20
67 #define SMOKE_BOMB_SYMBOL '*'
68 #define SMOKE_BOMB_TYPE PROJECTILE
69 #define SMOKE_BOMB_RANGE 5 // cells
70 #define SMOKE_BOMB_COLOR COLOR_WHITE
71 #define SMOKE_BOMB_EFFECT 1
72 #define SMOKE_BOMB_DURATION 5 // turns
73 
74 // Fire bomb
75 #define FIRE_BOMB_VALUE 50
76 #define FIRE_BOMB_DAMAGE_MIN 15
77 #define FIRE_BOMB_DAMAGE_MAX 25
78 #define FIRE_BOMB_SYMBOL '*'
79 #define FIRE_BOMB_TYPE PROJECTILE
80 #define FIRE_BOMB_RANGE 6 // cells
81 #define FIRE_BOMB_COLOR COLOR_RED
82 #define FIRE_BOMB_EFFECT 2
83 #define FIRE_BOMB_EFFECT_DAMAGE 7 // hp
84 #define FIRE_BOMB_DURATION 5 // turns
85 
86 // Ice bomb
87 #define ICE_BOMB_VALUE 70
88 #define ICE_BOMB_DAMAGE_MIN 20
89 #define ICE_BOMB_DAMAGE_MAX 30
90 #define ICE_BOMB_SYMBOL '*'
91 #define ICE_BOMB_TYPE PROJECTILE
92 #define ICE_BOMB_RANGE 7 // cells
93 #define ICE_BOMB_COLOR COLOR_CYAN
94 #define ICE_BOMB_EFFECT 3
95 #define ICE_BOMB_DURATION 7 // turns
96 
97 // Iron sword
98 #define IRON_SWORD_VALUE 20
99 #define IRON_SWORD_DAMAGE_MIN 10
100 #define IRON_SWORD_DAMAGE_MAX 20
101 #define IRON_SWORD_SYMBOL 'l'
102 #define IRON_SWORD_TYPE WEAPON
103 #define IRON_SWORD_COLOR COLOR_WHITE
104 
105 // Gold sword
106 #define GOLD_SWORD_VALUE 40
107 #define GOLD_SWORD_DAMAGE_MIN 20
108 #define GOLD_SWORD_DAMAGE_MAX 30
109 #define GOLD_SWORD_SYMBOL 'l'
110 #define GOLD_SWORD_TYPE WEAPON
111 #define GOLD_SWORD_COLOR COLOR_YELLOW
112 
113 // Diamond sword
114 #define DIAMOND_SWORD_VALUE 60
115 #define DIAMOND_SWORD_DAMAGE_MIN 30
116 #define DIAMOND_SWORD_DAMAGE_MAX 40
117 #define DIAMOND_SWORD_SYMBOL 'l'
118 #define DIAMOND_SWORD_TYPE WEAPON
119 #define DIAMOND_SWORD_COLOR COLOR_CYAN
120 
121 // Leather armor
122 #define LEATHER_ARMOR_VALUE 20
123 #define LEATHER_ARMOR_DEFENSE 20
124 #define LEATHER_ARMOR_SYMBOL 'T'
125 #define LEATHER_ARMOR_TYPE ARMOR
126 #define LEATHER_ARMOR_COLOR COLOR_WHITE
127 
128 // Chainmail armor
129 #define CHAINMAIL_ARMOR_VALUE 40
130 #define CHAINMAIL_ARMOR_DEFENSE 40
131 #define CHAINMAIL_ARMOR_SYMBOL 'T'
132 #define CHAINMAIL_ARMOR_TYPE ARMOR
133 #define CHAINMAIL_ARMOR_COLOR COLOR_GREEN
134 
135 // Plate armor
136 #define PLATE_ARMOR_VALUE 60
137 #define PLATE_ARMOR_DEFENSE 60
138 #define PLATE_ARMOR_SYMBOL 'T'
139 #define PLATE_ARMOR_TYPE ARMOR
140 #define PLATE_ARMOR_COLOR COLOR_MAGENTA
141 
142 // Potion of healing
143 #define POTION_OF_HEALING_SYMBOL '!'
144 #define POTION_OF_HEALING_TYPE POTION
145 #define POTION_OF_HEALING_VALUE 20
146 #define POTION_OF_HEALING_HP 50
147 #define POTION_OF_HEALING_COLOR COLOR_MAGENTA
148 
149 // Sensory potion
150 #define SENSORY_POTION_SYMBOL '!'
151 #define SENSORY_POTION_TYPE POTION
152 #define SENSORY_POTION_VALUE 50
153 #define SENSORY_POTION_VISION_RANGE 10 // + cells
154 #define SENSORY_POTION_VISION_WIDTH 2 // + adjacent cells
155 #define SENSORY_POTION_EARING_RANGE 20 // + cells
156 #define SENSORY_POTION_EARING_PROB 60 // = (60%)
157 #define SENSORY_POTION_TURNS 60 // turns
158 #define SENSORY_POTION_RANGE 10 // cells
159 #define SENSORY_POTION_COLOR COLOR_BLUE
160 
161 // Potion of invincibility
162 #define POTION_OF_INVINCIBILITY_SYMBOL '!'
163 #define POTION_OF_INVINCIBILITY_TYPE POTION
164 #define POTION_OF_INVINCIBILITY_VALUE 100
165 #define POTION_OF_INVINCIBILITY_TURNS 40 // turns
166 #define POTION_OF_INVINCIBILITY_DEFENSE 100 // MAX_DEFENSE
167 #define POTION_OF_INVINCIBILITY_COLOR COLOR_GREEN
168 
169 // Pot of gold
170 #define POT_OF_GOLD_SYMBOL 'O'
171 #define POT_OF_GOLD_TYPE GOLD
172 #define POT_OF_GOLD_VALUE_MIN 1 // * 10
173 #define POT_OF_GOLD_VALUE_MAX 10 // * 10
174 #define POT_OF_GOLD_COLOR COLOR_YELLOW
175 
176 Item** generateItems(int n);
177 void drawAllItems(Item **items, int n);
178 void drawVisibleItems(Map *map, Item **items, int n);
179 Item* getItem(Item **items, int nr_items, unsigned int x, unsigned int y);
180 int insertItem(Item **items, int nr_items, Item *item);
181 void freeItem(void *i);
182 
183 #endif
Item * getItem(Item **items, int nr_items, unsigned int x, unsigned int y)
Get item at (x, y) in the map, also removes it from the array.
Definition: item.c:323
Item ** generateItems(int n)
Generate n random items.
Definition: item.c:265
struct item Item
Item structure represents an item in the game.
void drawAllItems(Item **items, int n)
Draw all items in the Map.
Definition: item.c:293
void freeItem(void *i)
Free an item.
Definition: item.c:368
void drawVisibleItems(Map *map, Item **items, int n)
Draw all visible items in the Map.
Definition: item.c:307
int insertItem(Item **items, int nr_items, Item *item)
insert item into the items array (inventory)
Definition: item.c:343
Item structure represents an item in the game.
Definition: item.h:28
int damage
Definition: item.h:35
int range
Definition: item.h:39
int hp
Definition: item.h:37
int defense
Definition: item.h:36
int value
Definition: item.h:32
int count
Definition: item.h:38
int type
Definition: item.h:31
int color
Definition: item.h:40
unsigned int y
Definition: item.h:34
char symbol
Definition: item.h:30
char * name
Definition: item.h:29
unsigned int x
Definition: item.h:33
Structure that represents a map in the game.
Definition: map.h:26