-
Notifications
You must be signed in to change notification settings - Fork 37
/
items.h
501 lines (418 loc) · 12.1 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
// START A3HEADER
//
// This source file is part of the Atlantis PBM game program.
// Copyright (C) 1995-1999 Geoff Dunbar
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program, in the file license.txt. If not, write
// to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// See the Atlantis Project web page for details:
// http://www.prankster.com/project
//
// END A3HEADER
#ifndef ITEMS_CLASS
#define ITEMS_CLASS
class Item;
class ItemType;
#include "gamedefs.h"
#include "alist.h"
#include "astring.h"
#include <vector>
#include <string>
enum {
ATTACK_COMBAT,
ATTACK_ENERGY,
ATTACK_SPIRIT,
ATTACK_WEATHER,
ATTACK_RIDING,
ATTACK_RANGED,
NUM_ATTACK_TYPES // non resistable attack
};
enum {
IT_NORMAL = 0x0001,
IT_ADVANCED = 0x0002,
IT_TRADE = 0x0004,
IT_MAN = 0x0008,
IT_MONSTER = 0x0010,
IT_MAGIC = 0x0020,
IT_WEAPON = 0x0040,
IT_ARMOR = 0x0080,
IT_MOUNT = 0x0100,
IT_BATTLE = 0x0200,
IT_SPECIAL = 0x0400,
IT_TOOL = 0x0800,
IT_FOOD = 0x1000,
IT_ILLUSION = 0x2000,
IT_UNDEAD = 0x4000,
IT_DEMON = 0x8000,
IT_LEADER = 0x10000,
IT_MONEY = 0x20000,
IT_ANIMAL = 0x40000,
IT_SHIP = 0x80000,
IT_MAGEONLY = 0x100000,
IT_ALWAYS_SPOIL = 0x200000,
IT_NEVER_SPOIL = 0x400000
};
struct Materials
{
int item;
int amt;
};
struct ShowItem {
int item;
bool full;
std::string display_name();
std::string display_tag();
};
class ItemType
{
public:
std::string name;
std::string names;
char const *abr;
enum {
CANTGIVE = 0x1,
DISABLED = 0x2,
NOMARKET = 0x4,
// This item requires ANY of its inputs, not ALL
// of them
ORINPUTS = 0x8,
// A number of items are produced equal to the
// producer's skill, based on a fixed number of
// inputs
SKILLOUT = 0x10,
// This item cannot be transported.
NOTRANSPORT = 0x20,
// Produced monsters
MANPRODUCE = 0x40,
SKILLOUT_HALF = 0x80,
NOSTEALTH = 0x100, // this item makes the unit non-stealthy
MAINTENANCE = 0x200, // this item has a maintenance cost (it uses the items base cost)
SEEK_ALTAR = 0x400, // this item wants to move towards the nearest O_RITUAL_ALTAR (NO7 specific)
NO_SHAFT = 0x800, // the unit carrying this item transit a shaft
};
int flags;
char const *pSkill; // production skill
int pLevel; // production skill level
int pMonths; // Man months required for production
int pOut; // How many of the item we get
Materials pInput[4];
char const *mSkill; // magical production skill
int mLevel; // magical production skill level
int mOut; // How many of the item are conjured
Materials mInput[4];
int weight;
int type;
int baseprice;
int combat;
int walk;
int ride;
int fly;
int swim;
int speed;
int hitchItem;
int hitchwalk;
// LLS
int mult_item;
int mult_val;
int max_inventory; // if non-zero, amount allowed in inventory.
enum {
// LOSE_LINKED only works with ESC_LEV_*
LOSE_LINKED = 0x01, // All items of same type will be lost.
// The rest of these are mutually exclusive
HAS_SKILL = 0x02, // Check skill, if exists at level, no loss
ESC_LEV_LINEAR = 0x04, // bottom of formula based on level
ESC_LEV_SQUARE = 0x08, // bottom of formula based on level squared
ESC_LEV_CUBE = 0x10, // bottom of formula based on level cubed
ESC_LEV_QUAD = 0x20, // bottom of formula based on level ^ 4
LOSS_CHANCE = 0x40, // flat chance of escape.
// escape chances increase quadratically with number of monsters
ESC_NUM_SQUARE = 0x80,
};
int escape;
char const *esc_skill;
int esc_val; // level for has_skill, constant for all others
char const *grantSkill;
char const *fromSkills[4];
int minGrant, maxGrant;
};
extern ItemType *ItemDefs;
enum Ethnicity {
NONE,
VIKING,
BARBARIAN,
MAN,
ESKIMO,
NOMAD,
TRIBESMAN,
HIGHELF,
ELF,
DWARF,
ORC,
LIZARDMAN,
DROW,
TITAN,
HERO
};
class ManType
{
public:
char const *abbr;
int terrain;
int speciallevel;
int defaultlevel;
char const *skills[6];
Ethnicity ethnicity;
int CanProduce(int);
int CanUse(int);
};
extern ManType *ManDefs;
class MonType
{
public:
int attackLevel;
int defense[NUM_ATTACK_TYPES];
int numAttacks;
int hits;
int regen;
int tactics;
int stealth;
int obs;
char const *special;
int specialLevel;
int silver;
int spoiltype;
int hostile; /* Percent */
int number;
char const *name;
char const *abbr;
int hitDamage;
// Terrain types which monster like to be in.
// When the list is left empty, it will mean all terrains are possible.
std::vector<int> preferredTerrain;
// Terrain types into which monster will never try to enter.
std::vector<int> forbiddenTerrain;
/*
The general algorithm of the monster movement:
There are three categories of terrain: 1) what monster likes, 2) what monster is neutral, and 3) what monster dislikes.
Monster will freely move through the terrain he likes, and there will be a standard chance to move into the terrain he likes.
The monster will never enter the terrain he dislikes and will have a 2x lower chance to enter neutral terrain.
The monster can enter into the region of neutral terrain only if that particular region has at least one neighbor of the terrain
he likes.
This forbids monsters from going deeper into the unusual terrain but leaves regions on borders affected by "uncommon" monsters.
*/
const int getAggression();
};
extern MonType *MonDefs;
enum {
SLASHING, // e.g. sword attack (This is default)
PIERCING, // e.g. spear or arrow attack
CRUSHING, // e.g. mace attack
CLEAVING, // e.g. axe attack
ARMORPIERCING, // e.g. crossbow double bow
MAGIC_ENERGY, // e.g. fire, dragon breath
MAGIC_SPIRIT, // e.g. black wind
MAGIC_WEATHER, // e.g. tornado
NUM_WEAPON_CLASSES
};
#define MAX_WEAPON_BM_TARGETS 4
// Describes bonus/mauls against another weapon
class WeaponBonusMalus {
public:
char const *weaponAbbr; // weapon abbreviation
int attackModifer; // how much increase/decrase attack versus this weapon
int defenseModifer; // how much increase/decrase defense versus this weapon
};
class WeaponType
{
public:
char const *abbr;
enum {
NEEDSKILL = 0x1, // No bonus or use unless skilled
ALWAYSREADY = 0x2, // Ignore the 50% chance to attack
NODEFENSE = 0x4, // No combat defense against this weapon
NOFOOT = 0x8, // Weapon cannot be used on foot (e.g. lance)
NOMOUNT = 0x10, // Weapon cannot be used mounted (e.g. pike)
SHORT = 0x20, // Short melee weapon (e.g. shortsword, hatchet)
LONG = 0x40, // Long melee weapon (e.g. lance, pike)
RANGED = 0x80, // Missile weapon
NOATTACKERSKILL = 0x100, // Attacker gets no combat/skill defense.
RIDINGBONUS = 0x200, // Unit gets riding bonus on att and def.
RIDINGBONUSDEFENSE = 0x400, // Unit gets riding bonus on def only.
};
int flags;
char const *baseSkill;
char const *orSkill;
int weapClass; // SLASHING, PIERCING, CRUSHING, CLEAVING, ARMORPIERCING, MAGIC_ENERGY, MAGIC_SPIRIT, MAGIC_WEATHER
int attackType; // ATTACK_COMBAT, ATTACK_ENERGY, ATTACK_SPIRIT, ATTACK_WEATHER, ATTACK_RIDING, ATTACK_RANGED, NUM_ATTACK_TYPES (non resistable attack)
//
// For numAttacks:
// - A positive number is the number of attacks per round.
// - A negative number is the number of rounds per attack.
// - NUM_ATTACKS_HALF_SKILL indicates that the weapon gives as many
// attacks as the skill of the user divided by 2, rounded up.
// - NUM_ATTACKS_HALF_SKILL+1 indicates that the weapon gives an extra
// attack above that, etc.
// - NUM_ATTACKS_SKILL indicates the the weapon gives as many attacks
// as the skill of the user.
// - NUM_ATTACKS_SKILL+1 indicates the the weapon gives as many
// attacks as the skill of the user + 1, etc.
//
enum {
NUM_ATTACKS_HALF_SKILL = 50,
NUM_ATTACKS_SKILL = 100,
};
int numAttacks;
int attackBonus;
int defenseBonus;
int mountBonus;
//
// For hitDamage:
// - A positive number is the number of damage per attack.
// - A negative number is the number of rounds per attack.
// - NUM_DAMAGE_HALF_SKILL indicates that the weapon gives as many
// damage as the skill of the user divided by 2, rounded up.
// - NUM_DAMAGE_HALF_SKILL+1 indicates that the weapon gives an extra
// damage above that, etc.
// - NUM_DAMAGE_SKILL indicates the the weapon gives as many damage
// as the skill of the user.
// - NUM_DAMAGE_SKILL+1 indicates the the weapon gives as many
// damage as the skill of the user + 1, etc.
//
enum {
NUM_DAMAGE_HALF_SKILL = 500,
NUM_DAMAGE_SKILL = 1000,
};
int hitDamage;
WeaponBonusMalus bonusMalus[MAX_WEAPON_BM_TARGETS];
};
extern WeaponType *WeaponDefs;
class ArmorType
{
public:
char const *abbr;
enum {
USEINASSASSINATE = 0x1,
};
int flags;
//
// Against attacks, the chance of the armor protecting the wearer
// is: <type>Chance / from
//
int from;
int saves[NUM_WEAPON_CLASSES];
};
extern ArmorType *ArmorDefs;
class MountType
{
public:
char const *abbr;
//
// This is the skill needed to use this mount.
//
char const *skill;
//
// This is the minimum bonus (and minimal skill level) for this mount.
//
int minBonus;
//
// This is the maximum bonus this mount will grant.
//
int maxBonus;
//
// This is the max bonus a mount will grant if it can normally fly
// but the region doesn't allow flying mounts
int maxHamperedBonus;
// If the mount has a special effect it generates when ridden in
// combat
char const *mountSpecial;
int specialLev;
};
extern MountType *MountDefs;
class BattleItemType
{
public:
char const *abbr;
enum {
MAGEONLY = 0x1,
SPECIAL = 0x2,
SHIELD = 0x4,
EXCLUSIVE = 0x8,
};
int flags;
char const *special;
int skillLevel;
int hitDamage;
};
extern BattleItemType *BattleItemDefs;
extern int ParseGiveableItem(AString *);
extern int ParseAllItems(AString *);
extern int ParseEnabledItem(AString *);
extern int ParseTransportableItem(AString *);
extern int LookupItem(AString *);
extern BattleItemType *FindBattleItem(char const *abbr);
extern ItemType *FindItem(char const *abbr);
extern int FindItemIndex(char const *abbr);
extern ArmorType *FindArmor(char const *abbr);
extern WeaponType *FindWeapon(char const *abbr);
extern MountType *FindMount(char const *abbr);
extern MonType *FindMonster(char const *abbr, int illusion);
extern ManType *FindRace(char const *abbr);
extern int FindRaceItemIndex(int raceIndex);
extern AString AttType(int atype);
enum {
FULLNUM = 0x01,
ALWAYSPLURAL = 0x02
};
extern std::string ItemString(int type, int num, int flags = 0);
extern AString *ItemDescription(int item, int full);
extern int IsSoldier(int);
class Item
{
public:
Item();
~Item();
void Readin(std::istream& f);
void Writeout(std::ostream& f);
AString Report(int);
int type;
int num;
int selling;
int checked; // flag whether item has been reported, counted etc.
};
class ItemList
{
std::vector<Item> items;
public:
using iterator = typename std::vector<Item>::iterator;
void Readin(std::istream& f);
void Writeout(std::ostream& f);
std::string Report(int obs, int seeillusions, int nofirstcomma);
std::string BattleReport();
std::string ReportByType(int, int, int, int);
int Weight();
int GetNum(int);
void SetNum(int, int); /* type, number */
int CanSell(int);
void Selling(int, int); /* type, number */
void UncheckAll(); // re-set checked flag for all
iterator begin() { return items.begin(); }
iterator end() { return items.end(); }
iterator erase(iterator i) { return items.erase(i); }
inline size_t size() { return items.size(); }
inline void clear() { items.clear(); }
};
extern AString ShowSpecial(char const *special, int level, int expandLevel, int fromItem);
#endif