items.h
Raw
1#ifndef ITEMS_H
2#define ITEMS_H
3
4#include <game.h>
5
6#define DAGGER_OF_DARKNESS *game_at(&g, (struct point){8,3}) = (struct object)\
7 {\
8 .type = ITEM,\
9 .symbol = 'T',\
10 .u.i = {"Dagger of Darkness", EQUIP, {{0, 2, 0}}}\
11 };
12
13#define HP_POTION (struct item)\
14 {\
15 .o.type = ITEM,\
16 .o.symbol = 'p',\
17 .name = "HP Potion", .type = USE, .u = {.u.restorehp = 10}\
18 };
19
20static inline void spawn_item(struct game *g)
21{
22 while(true)
23 {
24 struct point p = {randrange(0, g->ys), randrange(0, g->xs)};
25 if(in_bounds(g, p) && game_at(g, p)->u->ground.type == NOOBJ) {
26 game_at(g, p)->u->it = HP_POTION;
27 break;
28 }
29 }
30}
31
32#endif //ITEMS_H
33