-
Notifications
You must be signed in to change notification settings - Fork 0
/
items.h
171 lines (142 loc) · 3.91 KB
/
items.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include <stdbool.h>
#include <curses.h>
#include "bodies.h"
#ifndef ITEMS_H
#define ITEMS_H
typedef struct itemlist_t itemlist_t;
typedef struct item_map_t item_map_t;
#define ITEM_UNKNOWN 0
#define ITEM_UP_STAIR 1
#define ITEM_DOWN_STAIR 2
#define ITEM_IRON_SWORD 3
#define ITEM_MAX 3
//Damage Types
#define DMG_BLUNT 0
#define DMG_SLASHING 1
#define DMG_PIERCING 2
#define DMG_FIRE 3
#define DMG_COLD 4
#define DMG_INFECTION 5
#define DMG_CRUSHING 6
#define DMG_EXPLOSIVE 7
#define DMG_PSYCHIC 8
#define DMG_MAX 8
#define BUC_UNCURSED 0
#define BUC_CURSED 1
#define BUC_BLESSED 2
//These are callbacks that will be inside of each item
struct item_use_t; struct item_consume_t; struct item_zap_t;
typedef void (*itemUseCallback)(struct item_use_t* data);
typedef void (*itemConsumeCallback)(struct item_consume_t* data);
typedef void (*itemZapCallback)(struct item_zap_t* data);
typedef struct item_t{
int id;
int str_bonus;int per_bonus;int end_bonus;int cha_bonus;
int int_bonus;int agl_bonus;int luc_bonus;int hth_bonus;
int display;
char *name;
char *exam_text;
char *dmg_verb;
int gold_value;
int size;//how much space it takes up on an item stack, in a bag
int material;
int weight;
int health;
int damage;
int damage_type;
int weapon_type;
int wearable;
bool is_static;
bool is_two_handed;
bool stopme;
bool immovable;
bool edible;
int extrinsic;
int curse_lvl;
int water_breathing_lvl;//0=normal,1=shallow,2=deep
struct map_t* go_to_map;
struct body_part_t *corpse;
itemUseCallback use;
itemConsumeCallback consume;
itemZapCallback zap;
}item_t;
#include "creature.h"
//This gives the callbacks information about how to use an item
typedef struct item_use_t{
int type;
item_t* caller;
item_t* item;
struct creature_t* creature;
}item_use_t;
//This gives the callbacks information about how to consume an item
typedef struct item_consume_t{
int type;
struct creature_t* creature;
}item_consume_t;
//This gives the callbacks information about how to zap an item
typedef struct item_zap_t{
int type;
struct creature_list_t* creatures;
}item_zap_t;
#include "item_callbacks.h"
//Material Types
#define MAT_UNKNOWN 0
#define MAT_CLOTH 1
#define MAT_GOLD 2
#define MAT_LEATHER 3
#define MAT_WOOD 4
#define MAT_BONE 5
#define MAT_SILVER 6
#define MAT_STONE 7
#define MAT_BRONZE 8
#define MAT_IRON 9
#define MAT_STEEL 10
#define MAT_ADAMANTINE 11
#define MAT_MITHRIL 12
//WEARABLE TYPES LIST
#define WEAR_UNKNOWN 0
#define WEAR_RESIST 1
#define WEAR_HEAD 2
#define WEAR_CHEST 3
#define WEAR_ARM 4
#define WEAR_HAND 5
#define WEAR_LEG 6
#define WEAR_FOOT 7
#define WEAR_FINGER 8
#define WEAR_EYES 9
#define WEAR_NECK 10
#define WEAR_SHOULDER 11
#define WEAR_MAX 11
item_t item_data[ITEM_MAX+1];
//Simple item list
struct itemlist_t{
item_t *item;
struct itemlist_t *next;
};
/* This represents a stack of items on a given coordinate on the floor. Next and
* Prev help cycle through the list of item stacks.
*/
struct item_map_t{
struct item_map_t* next;
itemlist_t* first;
int x; int y;
int size;//This is the current size of the item stack
};
#include "map.h"
void item_data_init();
void item_map_init(struct item_map_t* items, int w, int h);
void item_map_add(item_map_t *items, item_t *item);
bool add_item(struct map_t* map, int x, int y, struct item_t* i, bool reveal);
item_t* remove_item(item_map_t* map, int x, int y, int index);
int count_items(struct map_t* map,int x,int y);
void destroy_item(item_t* item);
int item_weight(item_t *item);
char *get_dmg_verb(item_t *weapon);
char *item_name(item_t *item);
int get_item_sym(struct map_t* map,int x,int y, int index);
int get_top_item_sym(struct map_t* map,int x,int y);
int get_top_item_sym_from_stack(struct item_map_t* items);
item_t *item_create_from_data(int index);
int items_display(struct map_t* map,int x,int y);
bool item_set_name(item_t *item, char *name);
#endif