-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathentities.h
316 lines (264 loc) · 9.15 KB
/
entities.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#ifndef ENTITIES_HEADER
#define ENTITIES_HEADER
#include <vector>
#include <list>
#include <memory>
class map;
class map_object;
class creature_base;
class light;
class bullet;
class particle;
class item;
const float grid_size = 128.0f; //how many pixels is each grid square
//#define maximum_lights 100//how many simultaneous lights available
//#define maximum_bullets 100//how many simultaneous bullets available
//#define maximum_particles 100//how many simultaneous particles available
//#define maximum_items 1000//number of items that the map can have
//#define maximum_objects_on_grid 10
#define maximum_bars 100
#define MAXIMUM_WEAPON_EFFECTS 30
const float minimum_distance_from_edge = 0.4f;//how far must items be from map edges
//bullets
class bullet
{
protected:
public:
bool dead;
bool dead_on_next;//the bullet will disappear on the next frame
float x,y;//position now
float x2,y2;//position was
float x3,y3;//in between was and now
float x4,y4;//position in beginning
float time;//time left until disappears, -1=infinite
float angle;
float move_x,move_y;
float shooter_move_x,shooter_move_y;
int type;
float distance;//distance to player
int side;//0=player, 1=aliens
int from_creature;//which creature shot this
bullet();//constructor
~bullet() = default;//destructor
};
//map
class map
{
protected:
struct grid_point{
int terrain_type;//terrain type
//int total_objects;//how many objects are on this grid
std::vector <int> objects;//list the objects that are here
std::vector <int> items;//list the items that are here
int total_creatures;//how many objects are on this grid
float light_rgb[3];//light, r g b
int creatures[20];//list the creatures that are here
int current_frame;
float frame_time;
};
// struct row{
// grid_point *grid;
// };
protected:
map(int sizex, int sizey, int climate); // base constructor (initializes some fields and map grid)
public:
map(int sizex,int sizey, float amount_multiplier, int climate, std::vector <int> terrain_types,
std::vector <bool> no_random_terrain_types, std::vector <bool> do_not_place_on_map_edges,
std::vector <bool> terrain_is_hazardous, std::vector <int> prop_amounts,
std::vector <int> prop_objects, std::vector <int> alien_types, std::vector <int> alien_amounts,
std::vector <int> alien_sides,int items_amount); // main constructor
/** constructor for loading a saved game (reserves internal vectors with the given amounts) */
map(int sizex,int sizey, size_t creature_amount, size_t object_amount, size_t item_amount, int climate);
~map() = default;
int sizex,sizey;//map size
protected:
std::unique_ptr<grid_point[]> grid;//map tiles
public:
std::vector <map_object> object;//map objects
std::vector <creature_base> creature;//creatures
std::vector <light> lights;//lighting effects
std::list <bullet> bullets;//bullets
std::vector <item> items;
int climate_number;//what climate type this map has
int area_type;
float wind_speed;
float wind_direction;
float wind_direction_target;
float rain_timer;
int near_areas[4];//which map is to left,right,up and down
bool been_here_already;//if the player has been here at least once
int map_texture,map_texture_2;
float time0;
float time1;
float time2;
void generate_map(float amount_multiplier, const std::vector<int>& terrain_types, const std::vector<bool>& no_random_terrain_types,
const std::vector<bool>& do_not_place_on_map_edges, const std::vector<bool>& terrain_is_hazardous, const std::vector<int>& prop_amounts,
const std::vector<int>& prop_objects, const std::vector<int>& alien_types, const std::vector<int>& alien_amounts, const std::vector<int>& alien_sides);//generates the map
void check_creatures(void);//checks on which squares the creatures are on
int create_light(float x, float y, int type, float size, float r, float g, float b, float a, float time);//sets in a light
void initialize_items(void);//initializes the map
void initialize_objects(void);//initializes the map
/// obtain reference to grid point at the given grid coordinates
map::grid_point& at(int x, int y);
/// obtain reference to grid point at the given grid coordinates (const version)
const map::grid_point& at(int x, int y) const;
/// obtain reference to grid point at the given real coordinates
map::grid_point& at_real(float x, float y);
/// obtain reference to grid point at the given real coordinates (const version)
const map::grid_point& at_real(float x, float y) const;
};
//objects that are on the map, trees, buildings
class map_object
{
protected:
public:
float x,y;
double rotation;
float size;
bool dead;//active or not
bool visible;//visible or not
int type;//which general object type it is
float light_level[3];//light r,g and b
int current_animation_frame;
float animation_frame_time;
//swaying
float sway_power;
float sway_phase;
map_object();//constructor
~map_object();//destructor
};
//creatures that walk around, including player
class creature_base
{
protected:
public:
float x,y,x2,y2;
float vx,vy;//for pushing
float rotation;//torso rotation
float rotation_head;
float rotation_legs;
float size;
//bool may_change_area;
bool dead;//active or not
int type;//which general creature type it is
float fire_timer;//if this is below zero, player can fire
//float health;
int side;//which side this is
float light[3];//light level of this creature
int animation[3];//animation frame of head, torso and feet
float animation_timer[3];//animation timer for head, torso and feet
float distance;//distance to player
int life_time;//dead when reaches target
int spawn_time;//spawn a creature when reaches target
bool show_energy;//if the energy meter is to be draw near the creature
int eat_counter;
bool killed;
int carry_light;
float carry_light_size;
int carry_light_type;
int light_attached_to;
int last_bullet_hit_from_creature_number;//who shot the last bullet that hit this creature
//bool fired_weapon_in_last_frame;
int dialog;
float dialog_timer;
int carried_creature;
float vanish_timer;//time to remain hidden
float enemy_angle;
bool force_AI;
int last_weapon_to_hit;
float last_weapon_to_hit_time;
//stealth
int wall_between_creature_and_player;
float angle_to_player;
float alpha;
//AI
int AI_order;//0=normal, 1=stay put
//int status;//0=not seen player, 1=seen player, 2=attacking, 3=moving into attack position, 4=killed, 5=evading player
//float time_in_flashlight;//how long it's been exposed to the flashligh at one time
//bool last_frame_in_flashlight;
int touched_enemy;//if it has touched an enemy, should fire on the next opportunity
//int target;
float move_to_x,move_to_y;
//target_data closest_friend;
//target_data closest_enemy;
int tactic[2];
float behavior_parameter0[10];
float behavior_parameter1[10];
float anger_level;//0..1
struct bar_base{
bool active;
//int number;
float value;
float minimum,maximum;
};
bar_base bars[maximum_bars];
struct weapon_effect{
int weapon_type;
int effect_type;
float time;
float parameter0;
float parameter1;
};
weapon_effect weapon_effects[MAXIMUM_WEAPON_EFFECTS];
int weapon_effects_amount;
float script_timer[30];
float left,right,up,down;//movement commands
bool fire;//shoot command
float backward_forward_speed,turn_speed;//movement
//bool sneak;//move slower
void die(void);
creature_base();//constructor
~creature_base();//destructor
};
//light effects, flashlight, explosions
class light
{
protected:
public:
float x,y;//precise location to draw picture
float x2,y2;//precise location to illumination
float size;
//float angle;
float rotation;
bool dead;//active or not
int type;//which general light type it is
float transparency;//how intense the light is
float r,g,b;//colors
//bool visible;//if the light picture should be drawn
float time;//time left, -1=infinite
float pulse;//pulse
float pulse_phase;//phase
light();//constructor
~light();//destructor
};
//particle
class particle
{
protected:
public:
float x,y;//precise location to draw picture
float move_x,move_y;//where to move
float time,time_start;//time left until disappears
//bool dead;//active or not
//int type;//which type it is
float rotate;
//int layer;
};
//item
class item: public map_object
{
protected:
public:
int base_type;//0=plot item, 1=pickable item
int item_type;//which type of base_type it is
bool event_used;//if the event has already been used once
int amount;
float interval_timer;
float create_time;
//float parameter0;
//float parameter1;
//float energy_for_battery;//battery charger energy
float sound_timer;
item();
};
#endif