-
Notifications
You must be signed in to change notification settings - Fork 1
/
items.h
614 lines (474 loc) · 16.5 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
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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
// Dodajac new_one wlasciwosc do itemu pamietaj o dodaniu jej do Load/Save
#ifndef ITEMS_H
#define ITEMS_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>
using namespace std;
#include "tiles.h"
#include "types.h"
#include "map.h"
#include "loadsave.h"
#define DAMAGE_NONE 0
#define DAMAGE_DEATH -1
class MONSTER;
class INTELLIGENT;
class RANGED_WEAPON;
class HAND_WEAPON;
class GRENADE;
class AMMO;
class TRASH;
class PILL;
class BASE_ARMOR;
class ARMOR;
class CORPSE;
class COUNTABLE;
class ROBOT_SHELL;
class ROBOT_LEG;
class PROCESSOR;
class REPAIR_KIT;
class PROGRAMMATOR;
class BATTERY;
typedef list<void *> ptr_list;
void bad_virtual_call(string method);
class ITEM : public TILE {
private:
bool is_dead; // when death() for this item was called
public:
int category; // category of item - for probability of setting on the level
MONSTER *owner; // who go nosi lub NULL
ITEM *in_robot_shell;
int purpose;
bool on_ground; // if lays on ground
int DMG; // Hand 2 hand combat
int HIT; // Hand 2 hand combat
int DEF; // Hand 2 hand combat
int energy_activated; // -1 cannot, 0 - when on, 1 - when off
PROPERTIES properties; // Armor Piercing / Explosive etc.
int hit_points;
int max_hit_points;
int required_strength;
int weight;
int price;
int skill_to_use; // which skill to concern when using
string activities;
string sound_used;
int inventory_letter; // used only by player
ITEM();
~ITEM();
virtual bool ChangePosition(int x, int y);
// ----------------------------------------
/// dopasowane do konkretnych rodzajow
virtual int used_by_on(MONSTER *who, MONSTER *on_who, int skill);
virtual int uses_energy(bool by_activation=true); // return: 0 - nothing changed, 1 - turned self off
virtual int turn_energy_on() { bad_virtual_call("Item: turn_energy_on"); return 0; };
virtual int turn_energy_off() { bad_virtual_call("Item: turn_energy_off"); return 0; };
// for granade
virtual int activate() { bad_virtual_call("Item: activate"); return 0; };
// for pills - should be changed to used_by_on?
virtual int use_on(MONSTER *who) { bad_virtual_call("Item: use_on"); return 0; };
// for ammo ('l')
virtual int load_ammo(AMMO *ammo) { bad_virtual_call("Item: load_ammo"); return 0;};
virtual bool unload_ammo(INTELLIGENT *czyj_backpack) { bad_virtual_call("Item: unload_ammo"); return 0;};
/// dla countable ('i')
virtual void add_and_destroy_object (ITEM *object) { bad_virtual_call("Item: add_and_destroy_object"); };
// ----------------------------------------
// ogolne
virtual bool compare_activities_with (ITEM *object);
virtual void print_item_with_letter(int x,int y,string additional_text);
virtual int evaluate_item() { return 0;}; // check the item value, base on "price" mostly
virtual int evaluate_item_for_h2h_combat();
virtual int evaluate_item_for_ranged_combat() { return 0; };
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual int calculate_weight();
virtual int damage_it(int value);
virtual int fix_damage(int value);
virtual bool fix_with_item(ITEM *parts, MONSTER *who_fixes);
virtual void every_turn(); // cos, co sie wykonuje co ture z tym objectem
virtual void death(); // Call this method - at the end of turn is removes object from memory
virtual string show_name();
virtual string article_a();
virtual string article_the();
bool is_monster_around();
// fulfill activities
bool property_get();
bool property_drop();
bool property_buildrobot();
bool property_throw();
bool property_wield();
bool property_use();
bool property_controller();
bool property_load_ammo();
bool property_unload_ammo();
bool property_put_on();
bool property_to_load();
bool property_join(); // f.e. with pills or ammo
bool property_activate(); // f.e. grenades
bool property_ready();
bool property_mend();
bool property_program();
// informacje o przedmiocie
HAND_WEAPON * IsHandWeapon();
RANGED_WEAPON * IsShootingWeapon();
GRENADE * IsGrenade();
PILL * IsPill();
AMMO * IsAmmo();
BASE_ARMOR * IsArmor();
CORPSE * IsCorpse();
TRASH * IsGarbage();
REPAIR_KIT * IsRepairSet();
COUNTABLE * IsCountable();
ROBOT_SHELL * IsRobotShell();
ROBOT_LEG * IsRobotLeg();
PROCESSOR *IsRobotCPU();
PROGRAMMATOR *IsProgrammator();
BATTERY *IsBattery();
bool IsLoaded(); // is loaded with ammo
bool IsDead();
// duplicate on creation
virtual ITEM * duplicate() { bad_virtual_call("Item: duplicate"); return 0; };
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class TRASH : public ITEM {
public:
TRASH();
virtual void every_turn() {}; // cos, co sie wykonuje co ture z tym objectem - tu nic
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class REPAIR_KIT : public ITEM {
public:
REPAIR_KIT();
int regeneration_time;
int regeneration_progress;
bool can_be_used();
bool fix(ITEM *item, MONSTER *who_fixes);
virtual void every_turn(); // cos, co sie wykonuje co ture z tym objectem - tu nic
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class PROGRAMMATOR : public ITEM {
public:
PROGRAMMATOR();
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class BATTERY : public ITEM {
public:
BATTERY();
int max_capacity;
int capacity;
int regeneration_speed; // regeneruje maks. do swojej pojemnosci, ale u posiadacza
virtual void every_turn(); // cos, co sie wykonuje co ture z tym objectem - tu nic
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual int evaluate_item() { return max_capacity + (regeneration_speed!=0)*100;};
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class COUNTABLE : public ITEM { // it the item can be in packages (ammo, pills)
public:
COUNTABLE();
int quantity;
virtual void add_and_destroy_object (ITEM *object);
virtual int damage_it(int value);
virtual int fix_damage(int value);
virtual string show_name();
virtual int calculate_weight();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class PILL : public COUNTABLE {
public:
int PWR;
PILL();
virtual void every_turn();
virtual int evaluate_item();
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual bool compare_activities_with (ITEM *object);
virtual int use_on(MONSTER *who);
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class CORPSE : public ITEM {
public:
string of_what;
int rotting_state;
CORPSE();
virtual void every_turn(); // cos, co sie wykonuje co ture z tym objectem
virtual int evaluate_item();
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class AMMO : public COUNTABLE {
public:
AMMO();
~AMMO();
int PWR; // power of missile
int ACC; // accuracy
AMMO_TYPE ammo_type; // f.e. 8mm
RANGED_WEAPON *in_weapon;
virtual int evaluate_item();
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual string show_name();
virtual bool compare_activities_with (ITEM *object);
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class RANGED_WEAPON : public ITEM {
public:
RANGED_WEAPON();
AMMO_TYPE ammo_type; // must be the same in ammo and weapon
int PWR; // additional power for ammo
int ACC; // accuracy for weapon
int energy_PWR; // additional power with energy on
int energy_ACC; // additional accuracy with energy on
int magazine_capacity;
int category_of_magazine; // category from which is randomized ammo on item creation. Not saved.
FIRE_TYPE fire_type;
FIRE_TYPE available_fire_types;
AMMO ammo;
// Sounds are not saved, are taken from definitions
string sound_file_single;
string sound_file_double;
string sound_file_triple;
string sound_file_burst;
string sound_reload;
string sound_gun_empty;
void incrase_fire_mode();
void decrase_fire_mode();
virtual int turn_energy_on();
virtual int turn_energy_off();
virtual int activate();
virtual int damage_it(int value);
virtual int calculate_weight();
virtual int load_ammo(AMMO *ammo);
virtual bool unload_ammo(INTELLIGENT *backpack_owner);
virtual int evaluate_item();
virtual int evaluate_item_for_ranged_combat();
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual void print_item_with_letter(int x,int y,string additional_text);
bool fire_missile(int x1, int y1, int x2, int y2,MONSTER * enemy, int distance);
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class BASE_ARMOR : public ITEM {
public:
int ARM; // how much it blocks
// modifiers
int MOD_STR; //
int MOD_DEX; //
int MOD_SPD; //
// additional modifiers for energy on
int energy_ARM;
int energy_MOD_STR;
int energy_MOD_DEX;
int energy_MOD_SPD;
PROPERTIES energy_properties;
PROPERTIES energy_real_properties;
virtual int turn_energy_on();
virtual int turn_energy_off();
virtual int activate();
BASE_ARMOR();
int evaluate_item();
virtual void death(); // Call this method - at the end of turn is removes object from memory
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey) {};
virtual string show_name();
virtual ITEM * duplicate() ;
virtual bool fix_with_item(ITEM *parts, MONSTER *who_fixes);
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class NO_ARMOR : public BASE_ARMOR { // all OBRAZENIA ZADAWANE SA TEJ ZBROI czyli skorze
public:
NO_ARMOR();
virtual int damage_it(int value);
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class ARMOR : public BASE_ARMOR {
public:
ARMOR();
virtual void every_turn(); // cos, co sie wykonuje co ture z tym objectem
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual ITEM * duplicate() ;
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class HAND_WEAPON : public ITEM {
public:
int energy_DMG;
int energy_HIT;
int energy_DEF;
PROPERTIES energy_properties;
PROPERTIES energy_real_properties;
HAND_WEAPON();
virtual int turn_energy_on();
virtual int turn_energy_off();
virtual int activate();
virtual string show_name();
virtual void death(); // Call this method - at the end of turn is removes object from memory
// void used_by_on(MONSTER *who, MONSTER *on_who);
virtual int evaluate_item();
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
typedef HAND_WEAPON WEAPON_UNARMED;
class GRENADE : public ITEM {
private:
int counter; // odlicza do 0, gdy 0 to wybuch. -1 nieactive
bool works_now;
int calculate_explosion(int *data);
public:
bool active;
int PWR;
int RNG;
int DLY; // value poczatkowa dla countera
string sound_explosion;
GRENADE();
virtual string show_name();
virtual int evaluate_item();
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual void every_turn(); // cos, co sie wykonuje co ture z tym objectem
virtual int activate();
virtual int damage_it(int value);
int explode();
int fire_explosion();
int stun_explosion();
int emp_explosion();
int produce_gas();
int create_shield();
int remove_shield();
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class GAS : public TILE {
public:
GAS();
bool is_dead; // gdy zostalo wywalane death() dla tego gazu
int density; // density 0 - 100 invisible 101-200 visible 201+ blocks fov
PROPERTIES properties;
virtual bool ChangePosition(int x, int y);
virtual void act_on_monster();
virtual void display();
virtual void death(); // usuwa ten gaz z map
virtual void every_turn(); // gaz sie rozprzestrzenia, dziala na monsters itd.
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class FIRE : public GAS {
public:
FIRE();
virtual void act_on_monster();
virtual void act_on_items();
virtual void display();
virtual void death(); // usuwa ten ogien z map
virtual void every_turn(); // ogien sie rozprzestrzenia, dziala na monsters itd.
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class CONTROLLER : public ITEM {
public:
int PWR;
CONTROLLER();
void display() {};
virtual void every_turn();
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class ROBOT_LEG : public ITEM {
public:
int move_power;
ROBOT_LEG();
// virtual void death(); // Call this method - at the end of turn is removes object from memory
virtual void every_turn() {};
virtual int evaluate_item() { return 0; };
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual ITEM * duplicate();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class PROCESSOR : public ITEM {
public:
string program;
int frequency;
int quality;
int group_affiliation;
ROBOT_SHELL *where_placed;
PROCESSOR();
// virtual void death(); // Call this method - at the end of turn is removes object from memory
virtual void every_turn() {};
virtual int evaluate_item() { return 0; };
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual ITEM * duplicate();
virtual string show_name();
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
class ROBOT_SHELL : public ITEM {
public:
int max_number_move_slots;
int max_number_action_slots;
int ARM; // how much it blocks
ptr_list move_slots;
ptr_list action_slots;
PROCESSOR *cpu;
string last_robot_name;
ROBOT_SHELL();
virtual void death(); // Call this method - at the end of turn is removes object from memory
virtual int evaluate_item() { return 0; };
virtual void print_attributes_vertical(int x,int y, int *changex, int *changey);
virtual int calculate_weight();
virtual ITEM * duplicate();
virtual bool install_CPU(ITEM *item);
virtual bool install_in_action_slot(ITEM *item);
virtual bool install_in_move_slot(ITEM *item);
virtual bool separate_item(ITEM *item);
virtual bool uninstall_CPU();
virtual bool uninstall_from_action_slot(ITEM *item);
virtual bool uninstall_from_move_slot(ITEM *item);
/// INHERITED FROM ToSave
virtual unsigned long SaveObject();
virtual bool LoadObject();
};
#endif