Roguelike
 All Classes Namespaces Functions Variables Typedefs Friends Pages
enemy.h
1 
22 #ifndef ENEMY_H
23 #define ENEMY_H
24 #include <character.h>
25 #include <defs.h>
26 #include <constants.h>
27 #include <string>
28 #include <vector>
29 #include <helper.h>
30 #include <constants.h>
31 #include <math_helper.h>
32 #include <bresenham.h>
33 
34 using namespace enemies;
35 
42 struct ATile
43 {
47  int parent;
48 
53 
58  int f;
59 
63  int g;
64 
69  int h;
70 
75  {
76  f = -1;
77  g = -1;
78  h = -1;
79  }
80 
84  ATile(int _parent, IntPoint _coords)
85  {
86  parent = _parent;
87  coords = _coords;
88  f = 0;
89  g = 0;
90  h = 0;
91  }
92 };
93 
100 class Enemy : public Character
101 {
102  typedef std::vector<std::vector<Tile*> > TilePointerMatrix;
103  protected:
110  int id;
111 
115  int sight;
116 
122 
127  int view;
128 
129 
135  bool spooked;
136 
145 
150 
155  std::string name;
156 
165  std::vector<Equipment*> generate_equipment(std::vector<EquipType> equipment_list);
166 
176  Weapon* generate_weapon(std::vector<WeaponType>);
177 
188  void move(int x_change, int y_change);
189 
201  IntPoint get_next_step(IntPoint goal, TilePointerMatrix& surroundings, IntPoint cur_coords);
202 
212  int is_in(IntPoint point, std::vector<ATile> list);
213 
238  std::vector<IntPoint> a_star(IntPoint start, IntPoint goal, TilePointerMatrix &surroundings);
239 
249  int manhattan(IntPoint, IntPoint);
250 
258  int get_smallest_f(std::vector<ATile>& list);
259 
271  IntPoint get_sur_coords(IntPoint sur_chunk, IntPoint sur_coords, IntPoint _chunk, IntPoint _coords);
272 
282  Character* find_best_target(int target_id, int selectability, std::vector<Character*> enemy_list);
283 
292  Character* passive_best_target(int target_id, int selectability, std::vector<Character*> enemy_list);
293 
294 
304  IntPoint get_spooked(IntPoint abs_coords, IntPoint target_abs);
305 
314  bool in_sight_range(IntPoint _coords, IntPoint _chunk);
315 
326  bool in_sight(IntPoint _coords, IntPoint _chunk);
327 
333  void turn(IntPoint coords);
334 
339  IntPoint get_fov();
340  public:
344  Enemy();
345 
350  Enemy(int _x, int _y, int _chunk_x , int _chunk_y, int _depth, EnemyType enemy);
351 
367  void run_ai(TilePointerMatrix &surroundings, IntPoint sur_chunk, IntPoint sur_coords, std::vector<Character*> char_list, long delta_ms);
368 
372  bool validate_target();
373 
374 
386  void aggressive_ai(TilePointerMatrix&, IntPoint sur_chunk, IntPoint sur_coords, std::vector<Character*> char_list, long delta_ms);
387 
402  void passive_ai(TilePointerMatrix &surroundings, IntPoint sur_chunk, IntPoint sur_coords, std::vector<Character*> char_list, long delta_ms);
403 
408  int get_sight();
409 
415  int get_id();
416 
427  void dump_matrix(TilePointerMatrix& map, IntPoint tl, IntPoint br);
428 
433  std::vector<IntPoint> sight_tiles();
434 };
435 
436 
437 #endif
int view
Definition: enemy.h:127
Definition: character.h:42
int h
Definition: enemy.h:69
Definition: enemy.h:100
ATile()
Definition: enemy.h:74
Definition: defs.h:565
IntPoint coords
Definition: enemy.h:52
int time_spooked
Definition: enemy.h:149
int id
Definition: enemy.h:110
IntPoint direction_spooked
Definition: enemy.h:144
int f
Definition: enemy.h:58
int g
Definition: enemy.h:63
Definition: int_point.h:26
int sight
Definition: enemy.h:115
int direction
Definition: enemy.h:121
Definition: enemy.h:42
Definition: item.h:257
std::string name
Definition: enemy.h:155
ATile(int _parent, IntPoint _coords)
Definition: enemy.h:84
Definition: defs.cpp:173
int parent
Definition: enemy.h:47
bool spooked
Definition: enemy.h:135