forked from Whales/Cataclysm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem_type.h
210 lines (168 loc) · 6.05 KB
/
item_type.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#ifndef _ITEM_TYPE_H_
#define _ITEM_TYPE_H_
#include "glyph.h"
#include "enum.h"
#include "dice.h"
#include "tool.h"
#include "status_effect.h"
#include <string>
#include <istream>
#include <vector>
/* After adding an Item_class, be sure to edit Item_type.cpp and add the class
* to the function item_class_name().
*/
enum Item_class
{
ITEM_CLASS_MISC = 0,
ITEM_CLASS_CLOTHING,
ITEM_CLASS_AMMO,
ITEM_CLASS_LAUNCHER,
ITEM_CLASS_FOOD,
ITEM_CLASS_TOOL,
ITEM_CLASS_CONTAINER,
ITEM_CLASS_MAX
};
Item_class lookup_item_class(std::string name);
std::string item_class_name_plural(Item_class iclass);
std::string item_class_name(Item_class iclass, bool plural = false);
Item_flag lookup_item_flag(std::string name);
std::string item_flag_name(Item_flag flag);
class Item_type
{
public:
Item_type();
virtual ~Item_type();
int uid;
std::string name;
std::string display_name;
std::string description;
int weight; // In 1/10ths of a pound / 0.045 kg (sorry)
int volume; // 1 volume = a ping pong ball
glyph sym;
int damage[DAMAGE_MAX];
int to_hit;
int attack_speed;
Dice thrown_variance;// Angle our thrown attack is off by, in 1/10ths of
// a degree; defaults to 5d20!
int thrown_dmg_percent; // Percent of normal damage done when thrown
int thrown_speed; // AP cost of throwing; if 0, it's calculated
void assign_uid(int id);
std::string get_data_name();
std::string get_name();
virtual bool load_data(std::istream &data);
virtual bool handle_data(std::string ident, std::istream &data);
virtual Item_class get_class() { return ITEM_CLASS_MISC; }
virtual Item_action default_action() { return IACT_NULL; }
virtual std::string get_property_description() { return ""; }
virtual int time_to_reload() { return 0; }
virtual int time_to_fire() { return 0; }
virtual int default_charges() { return 0; }
virtual bool always_combines() { return false; }
virtual bool combine_by_charges() { return false; }
bool has_flag(Item_flag flag);
private:
std::vector<bool> flags;
};
class Item_type_clothing : public Item_type
{
public:
Item_type_clothing();
~Item_type_clothing(){}
virtual Item_class get_class() { return ITEM_CLASS_CLOTHING; }
virtual Item_action default_action() { return IACT_WEAR; }
virtual std::string get_property_description();
virtual bool handle_data(std::string ident, std::istream &data);
int carry_capacity;
int armor_bash;
int armor_cut;
int armor_pierce;
int encumbrance;
bool covers[BODY_PART_MAX];
};
class Item_type_ammo : public Item_type
{
public:
Item_type_ammo();
~Item_type_ammo(){}
virtual Item_class get_class() { return ITEM_CLASS_AMMO; }
virtual bool handle_data(std::string ident, std::istream &data);
virtual int default_charges() { return count; }
virtual std::string get_property_description();
virtual bool always_combines() { return true; }
virtual bool combine_by_charges() { return true; }
std::string ammo_type; // Ammo type - links this to a launcher
int damage; // Base damage
int armor_pierce; // Armor ignored
int range;
Dice accuracy; // Low is good! In 1/10ths of a degree
int count; // How many to a box
};
class Item_type_launcher : public Item_type
{
public:
Item_type_launcher();
~Item_type_launcher(){}
virtual Item_class get_class() { return ITEM_CLASS_LAUNCHER; }
virtual bool handle_data(std::string ident, std::istream &data);
virtual std::string get_property_description();
virtual int time_to_reload() { return reload_ap; }
virtual int time_to_fire() { return fire_ap; }
// TODO: Add in gun class / skill used / however we do that
std::string ammo_type; // Ammo type - links this to a launcher
int damage; // Damage bonus
Dice accuracy; // Low is good! In 1/10ths of a degree
int recoil; // Recoil added
int durability; // HP basically
int capacity; // Shots per reload
int reload_ap; // action_points per reload
int fire_ap; // action_points per shot fired
std::vector<int> modes; // Each element is a number of shots
};
class Item_type_food : public Item_type
{
public:
Item_type_food();
~Item_type_food(){};
virtual Item_class get_class() { return ITEM_CLASS_FOOD; }
virtual Item_action default_action() { return IACT_EAT; }
virtual std::string get_property_description();
virtual int default_charges() { return charges; }
virtual bool handle_data(std::string ident, std::istream &data);
int food;
int water;
Status_effect effect; // Special effect inflicted; see status_effect.h
int charges; // So that you can partially consume a food item
std::string container; // Name of another item type!
std::string verb; // Verb for consuming this. "You ____ your <name>"
};
class Item_type_tool : public Item_type
{
public:
Item_type_tool();
~Item_type_tool(){};
virtual Item_class get_class() { return ITEM_CLASS_TOOL; }
virtual Item_action default_action() { return IACT_APPLY; }
virtual std::string get_property_description();
virtual bool handle_data(std::string ident, std::istream &data);
bool uses_charges(); // true if max_charges > 0 && charges_per_use > 0
Tool_action applied_action; // Action when applied
Tool_action powered_action; // Action every turn, while powered
Tool_action countdown_action; // Action when countdown finishes
int default_charges; // Charges it starts with
int max_charges; // Max charges. If 0, doesn't use charges.
int countdown_timer; // How many turns after applying before countdown_action
std::string fuel; // Ammo name - matches this with an ammo type for fuel
std::string powered_text; // Text for when it's powered; e.g. "on", "active"
};
class Item_type_container : public Item_type
{
public:
Item_type_container();
~Item_type_container(){}
virtual Item_class get_class() { return ITEM_CLASS_CONTAINER; }
virtual Item_action default_action() { return IACT_EMPTY; }
virtual std::string get_property_description();
virtual bool handle_data(std::string ident, std::istream &data);
int capacity; // Volume capacity, that is
};
#endif