-
Notifications
You must be signed in to change notification settings - Fork 1
/
monster.h
584 lines (456 loc) · 16.7 KB
/
monster.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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
#ifndef MONSTER_H
#define MONSTER_H
#pragma warning (disable: 4786)
#pragma warning (disable: 4788)
// disable warning (compare bool with int)
#pragma warning (disable: 4805)
#pragma warning (disable: 4503)
#include <list>
#include <set>
using namespace std;
#include "tiles.h"
#include "actions.h"
#include "items.h"
#include "game.h"
#include "attrib.h"
typedef list<void *> ptr_list;
typedef set <string> set_of_known_names;
// w global.cpp
void bad_virtual_call(string method);
// value dla samoleczenia - po osiagnieciu tej wartosci HP wzrasta o 1
#define REACHED_TREATMENT 1000
#define GROUP_HERO 0
#define GROUP_ENEMIES 1
#define GROUP_NEUTRAL 2
#define GROUP_CRAZY 3
class ANIMAL;
class INTELLIGENT;
class ROBOT;
class HERO;
class ENEMY;
class SEARCHLIGHT;
class MADDOCTOR;
class WORM;
#define SPECIAL_PROPERTY_NONE 0
#define SPECIAL_PROPERTY_SPLITTER 1
#define MUTATION_POSITIVE 1
#define MUTATION_NEGATIVE 0
#define MUTATION_NEUTRAL 2
class MONSTER : public TILE {
protected:
void cell_in_current_direction(int &x, int &y);
void direction_to_near_cell(int x, int y); // tylko pole sasiadujace z potworem
int self_treatment; // incrases every turn by metabolism value, when 1000, HP++
virtual void self_treatment_every_turn();
virtual void status_management_every_turn();
public:
virtual bool ChangePosition(int x, int y);
bool is_dead; // is dead
int weight;
int last_pX, last_pY; // position in last turn
int category;
int special_properties;
ATTRIBUTE fov_radius;
int size;
ATTRIBUTE hit_points;
ATTRIBUTE energy_points;
ATTRIBUTE strength;
ATTRIBUTE dexterity;
ATTRIBUTE endurance;
ATTRIBUTE intelligence;
ATTRIBUTE speed;
ATTRIBUTE metabolism;
string sound_dying;
string sound_pain;
int group_affiliation; // 0 - player 1 - enemies 2 - neutral 3 - crazy - attack everything (SENTRY GUN)
int direction; // direction of movement
WEAPON_UNARMED unarmed;
NO_ARMOR no_armor;
ITEM *weapon;
BASE_ARMOR *armor;
TIME next_action_time; // w ktore turze nastapi ruch tego potwora
bool seen_now;
TIME seen_last_time_in_turn;
unsigned long experience_for_kill;
MONSTER * enemy; // selected enemy
ptr_list seen_enemies;
ptr_list seen_friends;
int skill[NUMBER_OF_SKILLS]; // value for skills
int resist[NUMBER_OF_RESISTS]; // value for resists
int state[NUMBER_OF_STATES]; // value for states
bool IsBlinded() { return state[STATE_BLIND]>0; };
bool IsStunned() { return state[STATE_STUN]>0; };
bool IsConfused(){ return state[STATE_CONFUSE]>0; };
bool IsBurning() { return state[STATE_TEMPERATURE]>0; };
bool IsFreezed() { return state[STATE_TEMPERATURE]<0; };
bool IsRadiated() { return state[STATE_RADIOACTIVE]>0; };
bool IsSlowed() { return state[STATE_SPEED]<0; };
bool IsHasted() { return state[STATE_SPEED]>0; };
bool IsPoisoned(){ return state[STATE_CHEM_POISON]>0; };
ANIMAL * IsAnimal();
INTELLIGENT * IsIntelligent();
ROBOT *IsRobot();
HERO * IsPlayer();
ENEMY * IsHostile();
SEARCHLIGHT * IsSearchlight();
MADDOCTOR * IsMadDoctor();
WORM * IsWorm();
virtual void ShowDescription();
MONSTER();
~MONSTER();
virtual void set_attributes_on_self();
virtual int move();
void wait( TIME );
virtual void attack(MONSTER *a_enemy);
bool is_unarmed(); // gdy ma jakas weapon
bool in_armor(); // gdy nosi jakis armor
virtual bool have_low_hp() { return (hit_points.GetValue() <= hit_points.max/2); };
virtual bool have_critically_low_hp() { return (hit_points.GetValue() <= hit_points.max/4); };
virtual bool is_intelligent() { return false; };
bool is_enemy(MONSTER *m);
bool is_friendly(MONSTER *m);
virtual int cause_damage(int damage); // return (0 - no damage, 1 - damage done or -1 death)
virtual int use_energy(int energy);
virtual int add_energy(int energy);
bool heal(int damage);
virtual int hit_by_item(int hit_power, ITEM *item);
virtual int hit_by_explosion(int hit_power);
virtual int hit_changes_status(int kind, int power);
virtual bool attack_in_direction();
virtual bool look_around();
virtual int calculate_weight() { return weight; };
virtual int mutate(int type);
virtual void monster_sees_enemy(MONSTER *enemy) {};
virtual bool evade_missile(MONSTER *thrower);
virtual int get_h2h_attack_value();
virtual int get_h2h_defense_value();
virtual void enemy_died();
virtual bool death();
virtual ACTION get_action() { bad_virtual_call("Monster: get_action"); return ACTION_NOTHING; };
virtual TIME do_action( ACTION ) { bad_virtual_call("Monster: do_action"); return 0; };
virtual void select_closest_enemy() { bad_virtual_call("Monster: select_closest_enemy");};
virtual MONSTER * duplicate() { bad_virtual_call("Monster: duplicate"); return NULL; };
virtual void every_turn();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
enum BEHAVIOUR {
BEHAVIOUR_CALM,
BEHAVIOUR_H2H_COMBAT,
BEHAVIOUR_RANGED_COMBAT,
BEHAVIOUR_RUN_AWAY,
BEHAVIOUR_SEARCH_FOR_ENEMY,
BEHAVIOUR_TURN_TO_FIGHT
};
class ENEMY : public MONSTER {
public:
ACTION chosen_action; // do decyzji inteligentnego...
int actual_behaviour;
bool turned_to_fight;
int camping; // Licznik postoju w jednym miejscu dla potwora. Gdy > 5 to idzie w losowa strone.
int last_x_of_enemy; // Ostatnie place, gdzie player byl widziany
int last_y_of_enemy; // Ostatnie place, gdzie player byl widziany
int last_direction_of_enemy;
bool is_at_enemy_position;
TIME enemy_last_seen_in_turn;
ENEMY();
virtual void enemy_died();
int set_direction_to_cell_by_shortest_path(int cell_x, int cell_y, bool opening);
virtual int how_danger_is_cell(int x,int y) { return 0;}; // aby potrafil omijac (w direction na pole) takie pola
virtual void monster_sees_enemy(MONSTER *enemy);
virtual bool go_around_cell(int x,int y,bool opening);
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
#define AI_NOT_LIMITED 0x00000000
#define AI_DONT_USE_GRENADES 0x00000001
#define AI_DONT_USE_HEALING 0x00000002
#define AI_DONT_USE_BOOSTERS 0x00000004
#define AI_DONT_USE_RANGED_WEAPONS 0x00000008
#define AI_DONT_MOVE 0x00000010
#define AI_DONT_COOPERATE_WITH_FRIENDS 0x00000020
#define AI_DONT_RUN_AWAY 0x00000040
#define AI_DONT_PICK_UP_ITEMS 0x00000080
#define AI_DONT_USE_OTHER_WEAPONS 0x00000100
#define AI_DONT_USE_OTHER_ARMORS 0x00000200
typedef unsigned long AI_CONTROL;
void calculate_hit_place(int who_x, int who_y, int &target_x, int &target_y, double angle_miss);
class INTELLIGENT : public ENEMY {
private:
int misses_in_shooting; // to choose lower distance
int run_away_to_x, run_away_to_y;
public:
AI_CONTROL AI_restrictions;
TIME turns_of_searching_for_enemy;
TIME turns_of_calm;
ptr_list backpack;
ptr_list seen_items;
ITEM *ready_weapon; // ready item
int max_items_in_backpack;
int items_in_backpack;
int get_backpack_weight(); // zwraca wage
int get_monster_capacity();
virtual bool look_around();
virtual bool defend_self_from_danger_on_map();
virtual bool is_intelligent() { return true; };
virtual int how_danger_is_cell(int x,int y); // aby potrafil omijac takie pola
virtual int cause_damage(int damage);
virtual int use_item(ITEM *); // np. pill
virtual int set_weapon(ITEM *);
virtual int set_armor(ITEM *);
virtual int remove_armor();
virtual int take_out_from_backpack(ITEM *);
virtual int drop_item(ITEM *, bool see_possible);
virtual int pick_up_item(ITEM *, bool see_possible);
virtual int shoot_into(int x, int y); // strzela z broni uzywanej w pole
virtual int reload_weapon();
virtual int can_pick_up(ITEM *item);
virtual bool open_in_direction();
virtual bool close_in_direction();
virtual bool isStrained();
virtual bool isBurdened();
virtual int calculate_weight() { return weight + get_backpack_weight(); };
// with shooting
virtual bool evade_missile(MONSTER *thrower);
virtual bool throw_item_to (int x,int y,ITEM *item);
// AI
virtual bool throw_item_to();
virtual bool load_weapon();
virtual bool unload_weapon();
virtual bool fire_at_enemy();
virtual bool use_healing_item();
virtual bool use_remove_poison_item();
virtual bool throw_active_grenade();
virtual bool tell_others_about_enemy();
virtual bool use_booster_item();
virtual bool change_weapon_to_better_one();
virtual bool change_armor_to_better_one();
virtual bool activate_grenade_when_enemy_is_far();
virtual int activate_weapon_and_armor_when_energy_available();
virtual int carried_number_of_missiles_for_weapon(RANGED_WEAPON *ranged_weapon);
virtual bool choose_place_to_throw_grenade(int &x,int &y);
virtual int go_to_direction_of_enemy();
virtual bool find_best_weapons(ITEM *&best_for_h2h, int &best_evaluation_h2h, ITEM *&best_for_ranged, int &best_evaluation_ranged);
virtual int pick_valuable_items();
virtual ITEM * go_to_valuable_item();
virtual bool choose_run_away_direction();
virtual bool use_defensive_techniques_running_away();
virtual int turn_robot_on(ITEM *to_turn_on);
virtual bool choose_ready_weapon(ITEM *item);
virtual bool set_ready_weapon();
virtual void start_to_run_away();
INTELLIGENT();
virtual bool death();
virtual ACTION get_action();
virtual TIME do_action( ACTION );
virtual MONSTER * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
#define SKILL_MULTIPLIER 35
// way of showing the inventory
enum EInvShowType {
INV_SHOW_SIMPLE,
INV_SHOW_MATCH_AMMO,
INV_SHOW_HIGHLIGHT_CORPSES,
INV_SHOW_MATCH_ITEM_TO_REPAIR,
INV_SHOW_REPAIR_KIT,
INV_SHOW_HIGHLIGHT_REAPIR_KITS,
INV_SHOW_IMPROVE_ARMOR
};
enum ERepeatAction {
REPEAT_ACTION_NONE,
REPEAT_ACTION_REST,
REPEAT_ACTION_INVENTORY,
REPEAT_ACTION_TRAVEL,
REPEAT_ACTION_EXPLORE
};
class HERO : public INTELLIGENT {
private:
ITEM *choose_item_to_pick_up();
int turns_of_rest;
int exp_level;
unsigned long experience;
unsigned long level_at_experience;
unsigned long free_skill_pointes;
int experience_in_skill[NUMBER_OF_SKILLS]; // experience w tym % w skillu
void train_skill(int skill, int value);
bool set_direction_to_closest_unexplored(); // returns distance
void got_level_up();
int show_actions_of_item(ITEM *);
int get_action_for_item(ITEM *);
int shoot_into(int x, int y); // strzela z broni uzywanej w pole
MONSTER * choose_target(int *x, int *y, string text);
virtual void select_closest_enemy();
bool choose_travel_destination();
bool print_visible_monsters_and_items();
void show_attributes();
int show_inventory();
bool use_stairs(bool direction);
void show_player_info();
void show_info();
void look_with_cursor();
bool set_move_direction(void); // ustala zmienna direction gracza na chosen_one
ERepeatAction action_to_repeat;
bool inventory_repeat_break;
public:
ptr_list monsters_following_player_to_other_level;
set_of_known_names known_items;
void add_known_item(string real);
void add_known_category_of_items(string category_to_add);
bool is_item_known(string real);
string ID_of_level; // on which player is
string ID_of_last_level; // from which player came
int stairs_number_used; // with changing level
unsigned long adaptation_points;
int travel_dest_x, travel_dest_y; // not saved
ITEM *last_activated;
HERO();
ACTION get_action();
TIME do_action( ACTION );
void create_list_of_monsters_following_player();
virtual int pick_up_item(ITEM *, bool see_possible);
void show_laying_items();
void show_backpack(ITEM *passed_item, EInvShowType print_type);
void show_robot_build_screen(ROBOT_SHELL *shell, int show_letters); // if -1 then check is robot on;
int build_robot_change_field_number(ROBOT_SHELL *shell, int field_number);
bool build_robot_fix(ROBOT_SHELL *shell);
bool build_robot_find_available_parts(ptr_list &available_items);
ITEM *choose_item_from_backpack(int character);
ITEM *choose_item_from_list(ptr_list &available_items, string header);
void give_experience(unsigned long value);
void skill_used(int skill);
void stop_repeating();
void repeat_action(ERepeatAction to_repeat);
int is_repeating_action() { return action_to_repeat; };
virtual bool look_around();
virtual int build_robot(ITEM *item);
virtual int reprogram (PROGRAMMATOR *item);
virtual int set_weapon(ITEM *);
virtual int drop_item(ITEM *, bool visible_dropping);
virtual bool throw_item_to (int x,int y,ITEM *item);
virtual void display(); // nowa method
virtual bool death();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class ANIMAL : public ENEMY {
public:
ANIMAL();
ACTION get_action();
TIME do_action( ACTION );
virtual bool look_around();
virtual bool evade_missile(MONSTER *thrower);
virtual MONSTER * duplicate();
virtual int how_danger_is_cell(int x,int y); // aby potrafil omijac takie pola
virtual int cause_damage(int damage);
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class WORM : public ENEMY {
private:
void reverse_worm();
public:
WORM *prev; // segments
WORM *next;
int length_left;
string segment_name;
string tail_name;
WORM();
ACTION get_action();
TIME do_action( ACTION );
virtual int move();
virtual bool look_around();
virtual MONSTER * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class ROBOT : public ENEMY {
private:
int last_x_of_creator;
int last_y_of_creator;
bool sees_creator;
char get_CPU_instruction();
bool can_weapon_shoot();
bool load_ammo_to_weapon();
bool fire_grenades();
public:
ROBOT_SHELL *shell;
unsigned long Creator_ID;
ROBOT();
ACTION get_action();
TIME do_action( ACTION );
virtual bool death();
void turn_robot_off();
bool tries_to_turn_off(MONSTER *temp);
int get_robot_speed();
virtual int calculate_weight() { return shell->calculate_weight(); };
virtual void display(); // robot to specjalny type potworka, zmienia wyglad zaleznie od pancerza
virtual void ShowDescription();
virtual bool look_around();
virtual bool evade_missile(MONSTER *thrower) { return false; };
virtual MONSTER * duplicate();
virtual int get_h2h_attack_value();
virtual int get_h2h_defense_value();
virtual void attack(MONSTER *enemy);
virtual bool attack_with_ranged_weapon();
virtual bool shoot_into(int x, int y);
virtual int cause_damage(int damage); // zwraca (0 - bez obrazen, 1 - byly lub -1 gdy death)
bool heal(int damage);
virtual int hit_by_item(int hit_power, ITEM *item);
virtual int hit_by_explosion(int hit_power);
virtual int hit_changes_status(int kind, int power);
virtual bool attack_in_direction();
virtual bool have_low_hp() { return (shell->hit_points <= shell->max_hit_points/2); };
virtual bool have_critically_low_hp() { return (shell->hit_points <= shell->max_hit_points/4); };
virtual int how_danger_is_cell(int x,int y) { return 0; }; // aby potrafil omijac takie pola
virtual void self_treatment_every_turn();
virtual void status_management_every_turn();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class SEARCHLIGHT : public ENEMY {
public:
int destination_x,destination_y;
SEARCHLIGHT();
virtual bool death();
ACTION get_action();
TIME do_action( ACTION );
virtual bool look_around();
virtual bool evade_missile(MONSTER *thrower) { return false; };
virtual MONSTER * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
#define MADDOCTOR_TEXTS 25
class MADDOCTOR : public INTELLIGENT {
private:
string histext[MADDOCTOR_TEXTS];
int yelling_chance;
public:
HAND_WEAPON tail;
MADDOCTOR();
ACTION get_action();
TIME do_action( ACTION );
virtual bool look_around();
virtual MONSTER * duplicate();
virtual int how_danger_is_cell(int x,int y); // aby potrafil omijac takie pola
virtual bool death();
// special akcje
int throw_enemy_at_the_wall();
int spit_poison();
int fire_needle();
int yell();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
#endif