/
itemprop.cc
3090 lines (2649 loc) · 90.8 KB
/
itemprop.cc
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
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @file
* @brief Misc functions.
**/
#include "AppHdr.h"
#include "itemprop.h"
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "artefact.h"
#include "art-enum.h"
#include "decks.h"
#include "describe.h"
#include "godpassive.h"
#include "invent.h"
#include "items.h"
#include "item_use.h"
#include "libutil.h" // map_find
#include "message.h"
#include "misc.h"
#include "notes.h"
#include "options.h"
#include "random.h"
#include "religion.h"
#include "shopping.h"
#include "skills.h"
#include "stringutil.h"
#include "terrain.h"
#include "xom.h"
static iflags_t _full_ident_mask(const item_def& item);
// XXX: Name strings in most of the following are currently unused!
struct armour_def
{
/// The armour_type enum of this armour type.
armour_type id;
/// The name of the armour. (E.g. "robe".)
const char *name;
/// The base AC value provided by the armour, before skill & enchant.
int ac;
/// The base EV penalty of the armour; used for EV, stealth, spell %, &c.
int ev;
/// The slot the armour is equipped into; e.g. EQ_BOOTS.
equipment_type slot;
/// The smallest size creature the armour will fit.
size_type fit_min;
/// The largest size creature the armour will fit.
size_type fit_max;
/// Whether this armour is mundane or inherently 'special', for acq.
bool mundane; // (special armour doesn't need egos etc)
/// The resists, vulns, &c that this armour type gives when worn.
armflags_t flags;
/// Used in body armour 'acquirement' code; higher = generated more.
int acquire_weight;
};
// Note: the Little-Giant range is used to make armours which are very
// flexible and adjustable and can be worn by any player character...
// providing they also pass the shape test, of course.
static int Armour_index[NUM_ARMOURS];
static const armour_def Armour_prop[] =
{
{ ARM_ANIMAL_SKIN, "animal skin", 2, 0,
EQ_BODY_ARMOUR, SIZE_LITTLE, SIZE_GIANT, true, ARMF_NO_FLAGS, 333 },
{ ARM_ROBE, "robe", 2, 0,
EQ_BODY_ARMOUR, SIZE_LITTLE, SIZE_BIG, true, ARMF_NO_FLAGS, 1000 },
{ ARM_LEATHER_ARMOUR, "leather armour", 3, -40,
EQ_BODY_ARMOUR, SIZE_SMALL, SIZE_MEDIUM, true },
{ ARM_RING_MAIL, "ring mail", 5, -70,
EQ_BODY_ARMOUR, SIZE_SMALL, SIZE_MEDIUM, true, ARMF_NO_FLAGS, 1000 },
{ ARM_SCALE_MAIL, "scale mail", 6, -100,
EQ_BODY_ARMOUR, SIZE_SMALL, SIZE_MEDIUM, true, ARMF_NO_FLAGS, 1000 },
{ ARM_CHAIN_MAIL, "chain mail", 8, -150,
EQ_BODY_ARMOUR, SIZE_SMALL, SIZE_MEDIUM, true, ARMF_NO_FLAGS, 1000 },
{ ARM_PLATE_ARMOUR, "plate armour", 10, -180,
EQ_BODY_ARMOUR, SIZE_SMALL, SIZE_MEDIUM, true, ARMF_NO_FLAGS, 1000 },
{ ARM_CRYSTAL_PLATE_ARMOUR, "crystal plate armour", 14, -230,
EQ_BODY_ARMOUR, SIZE_SMALL, SIZE_MEDIUM, false, ARMF_NO_FLAGS, 500 },
#define HIDE_ARMOUR(aenum, aname, aac, aevp, henum, hname, res, weight) \
{ henum, hname, (aac)/2, aevp, \
EQ_BODY_ARMOUR, SIZE_LITTLE, SIZE_GIANT, false, res, 0 }, \
{ aenum, aname, aac, aevp, \
EQ_BODY_ARMOUR, SIZE_LITTLE, SIZE_GIANT, false, res, weight }
#define DRAGON_ARMOUR(id, name, ac, evp, res) \
HIDE_ARMOUR(ARM_ ## id ## _DRAGON_ARMOUR, name " dragon armour", ac, evp, \
ARM_ ## id ## _DRAGON_HIDE, name " dragon hide", res, 25)
HIDE_ARMOUR(
ARM_TROLL_LEATHER_ARMOUR, "troll leather armour", 4, -40,
ARM_TROLL_HIDE, "troll hide",
ARMF_REGENERATION, 50
),
DRAGON_ARMOUR(STEAM, "steam", 5, 0,
ARMF_RES_STEAM),
DRAGON_ARMOUR(MOTTLED, "mottled", 6, -50,
ARMF_RES_STICKY_FLAME),
DRAGON_ARMOUR(QUICKSILVER, "quicksilver", 9, -70,
ARMF_RES_MAGIC),
DRAGON_ARMOUR(SWAMP, "swamp", 7, -70,
ARMF_RES_POISON),
DRAGON_ARMOUR(FIRE, "fire", 8, -110,
ard(ARMF_RES_FIRE, 2) | ARMF_VUL_COLD),
DRAGON_ARMOUR(ICE, "ice", 9, -110,
ard(ARMF_RES_COLD, 2) | ARMF_VUL_FIRE),
DRAGON_ARMOUR(PEARL, "pearl", 10, -110,
ARMF_RES_NEG),
DRAGON_ARMOUR(STORM, "storm", 10, -150,
ARMF_RES_ELEC),
DRAGON_ARMOUR(SHADOW, "shadow", 10, -150,
ard(ARMF_STEALTH, 4)),
DRAGON_ARMOUR(GOLD, "gold", 12, -230,
ARMF_RES_FIRE | ARMF_RES_COLD | ARMF_RES_POISON),
#undef DRAGON_HIDE
#undef HIDE_ARMOUR
{ ARM_CLOAK, "cloak", 1, 0,
EQ_CLOAK, SIZE_LITTLE, SIZE_BIG, true },
{ ARM_GLOVES, "gloves", 1, 0,
EQ_GLOVES, SIZE_SMALL, SIZE_MEDIUM, true },
{ ARM_HELMET, "helmet", 1, 0,
EQ_HELMET, SIZE_SMALL, SIZE_MEDIUM, true },
#if TAG_MAJOR_VERSION == 34
{ ARM_CAP, "cap", 0, 0,
EQ_HELMET, SIZE_LITTLE, SIZE_LARGE, true },
#endif
{ ARM_HAT, "hat", 0, 0,
EQ_HELMET, SIZE_TINY, SIZE_LARGE, true },
// Note that barding size is compared against torso so it currently
// needs to fit medium, but that doesn't matter as much as race
// and shapeshift status.
{ ARM_BOOTS, "boots", 1, 0,
EQ_BOOTS, SIZE_SMALL, SIZE_MEDIUM, true },
// Changed max. barding size to large to allow for the appropriate
// monster types (monsters don't differentiate between torso and general).
{ ARM_CENTAUR_BARDING, "centaur barding", 4, -60,
EQ_BOOTS, SIZE_MEDIUM, SIZE_LARGE, true },
{ ARM_NAGA_BARDING, "naga barding", 4, -60,
EQ_BOOTS, SIZE_MEDIUM, SIZE_LARGE, true },
// Note: shields use ac-value as sh-value, EV pen is used as the basis
// to calculate adjusted shield penalty.
{ ARM_BUCKLER, "buckler", 3, -8,
EQ_SHIELD, SIZE_LITTLE, SIZE_MEDIUM, true },
{ ARM_SHIELD, "shield", 8, -30,
EQ_SHIELD, SIZE_SMALL, SIZE_BIG, true },
{ ARM_LARGE_SHIELD, "large shield", 13, -50,
EQ_SHIELD, SIZE_MEDIUM, SIZE_GIANT, true },
};
typedef pair<brand_type, int> brand_weight_tuple;
/// The standard properties for a given weapon type. (E.g. falchions)
struct weapon_def
{
/// The weapon_type enum for this weapon type.
int id;
/// The name of this weapon type. (E.g. "club".)
const char *name;
/// The base damage of the weapon. (Later multiplied by skill, etc)
int dam;
/// The base to-hit bonus of the weapon.
int hit;
/// The number of aut it takes to swing the weapon with 0 skill.
int speed;
/// The weapon skill corresponding to this weapon's use.
skill_type skill;
/// The size of the smallest creature that can wield the weapon.
size_type min_2h_size;
/// The smallest creature that can wield the weapon one-handed.
size_type min_1h_size;
/// The ammo fired by the weapon; MI_NONE for non-launchers.
missile_type ammo;
/// A union of vorpal_damage_type flags (slash, crush, etc)
int dam_type;
/// Used in *some* item generation code; higher = generated more often.
int commonness;
/// Used in *some* item 'acquirement' code; higher = generated more.
int acquire_weight;
/// Used in non-artefact ego item generation. If empty, default to NORMAL.
vector<brand_weight_tuple> brand_weights;
};
/// brand weights for non-dagger shortblades (short sword & rapier)
static const vector<brand_weight_tuple> SBL_BRANDS = {
{ SPWPN_NORMAL, 33 },
{ SPWPN_VENOM, 17 },
{ SPWPN_SPEED, 10 },
{ SPWPN_DRAINING, 9 },
{ SPWPN_PROTECTION, 6 },
{ SPWPN_ELECTROCUTION, 6 },
{ SPWPN_HOLY_WRATH, 5 },
{ SPWPN_VAMPIRISM, 4 },
{ SPWPN_FLAMING, 4 },
{ SPWPN_FREEZING, 4 },
{ SPWPN_DISTORTION, 1 },
{ SPWPN_ANTIMAGIC, 1 },
};
/// brand weights for most m&f weapons
static const vector<brand_weight_tuple> M_AND_F_BRANDS = {
{ SPWPN_PROTECTION, 30 },
{ SPWPN_NORMAL, 28 },
{ SPWPN_HOLY_WRATH, 15 },
{ SPWPN_VORPAL, 14 },
{ SPWPN_DRAINING, 10 },
{ SPWPN_VENOM, 5 },
{ SPWPN_DISTORTION, 1 },
{ SPWPN_ANTIMAGIC, 1 },
{ SPWPN_PAIN, 1 },
};
/// brand weights for demon weapons (whip, blade, trident)
static const vector<brand_weight_tuple> DEMON_BRANDS = {
{ SPWPN_NORMAL, 27 },
{ SPWPN_VENOM, 19 },
{ SPWPN_ELECTROCUTION, 16 },
{ SPWPN_DRAINING, 10 },
{ SPWPN_FLAMING, 7 },
{ SPWPN_FREEZING, 7 },
{ SPWPN_VAMPIRISM, 7 },
{ SPWPN_PAIN, 4 },
{ SPWPN_ANTIMAGIC, 3 },
};
/// brand weights for long blades.
static const vector<brand_weight_tuple> LBL_BRANDS = {
{ SPWPN_HOLY_WRATH, 23 },
{ SPWPN_NORMAL, 19 },
{ SPWPN_VORPAL, 15 },
{ SPWPN_ELECTROCUTION, 10 },
{ SPWPN_PROTECTION, 8 },
{ SPWPN_FREEZING, 5 },
{ SPWPN_FLAMING, 5 },
{ SPWPN_DRAINING, 5 },
{ SPWPN_VAMPIRISM, 4 },
{ SPWPN_VENOM, 2 },
{ SPWPN_DISTORTION, 2 },
{ SPWPN_PAIN, 1 },
{ SPWPN_ANTIMAGIC, 1 },
};
/// brand weights for axes.
static const vector<brand_weight_tuple> AXE_BRANDS = {
{ SPWPN_NORMAL, 31 },
{ SPWPN_VORPAL, 16 },
{ SPWPN_ELECTROCUTION, 11 },
{ SPWPN_FLAMING, 10 },
{ SPWPN_FREEZING, 10 },
{ SPWPN_VENOM, 8 },
{ SPWPN_VAMPIRISM, 5 },
{ SPWPN_DRAINING, 3 },
{ SPWPN_DISTORTION, 2 },
{ SPWPN_ANTIMAGIC, 2 },
{ SPWPN_PAIN, 1 },
{ SPWPN_HOLY_WRATH, 1 },
};
/// brand weights for most polearms.
static const vector<brand_weight_tuple> POLEARM_BRANDS = {
{ SPWPN_NORMAL, 36 },
{ SPWPN_VENOM, 17 },
{ SPWPN_PROTECTION, 12 },
{ SPWPN_VORPAL, 9 },
{ SPWPN_FLAMING, 7 },
{ SPWPN_FREEZING, 7 },
{ SPWPN_VAMPIRISM, 5 },
{ SPWPN_DISTORTION, 2 },
{ SPWPN_PAIN, 2 },
{ SPWPN_ANTIMAGIC, 2 },
{ SPWPN_HOLY_WRATH, 1 },
};
/// brand weights for most ranged weapons.
static const vector<brand_weight_tuple> RANGED_BRANDS = {
{ SPWPN_NORMAL, 50 },
{ SPWPN_FLAMING, 24 },
{ SPWPN_FREEZING, 12 },
{ SPWPN_EVASION, 8 },
{ SPWPN_VORPAL, 6 },
};
/// brand weights for holy (TSO-blessed) weapons.
static const vector<brand_weight_tuple> HOLY_BRANDS = {
{ SPWPN_HOLY_WRATH, 100 },
};
static int Weapon_index[NUM_WEAPONS];
static const weapon_def Weapon_prop[] =
{
// Maces & Flails
{ WPN_CLUB, "club", 5, 3, 13,
SK_MACES_FLAILS, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_CRUSHING, 10, 0, {} },
{ WPN_ROD, "rod", 5, 3, 13,
SK_MACES_FLAILS, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_CRUSHING, 0, 0, {} },
{ WPN_WHIP, "whip", 6, 2, 11,
SK_MACES_FLAILS, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_SLASHING, 4, 0, {
{ SPWPN_NORMAL, 34 },
{ SPWPN_VENOM, 16 },
{ SPWPN_ELECTROCUTION, 16 },
{ SPWPN_DRAINING, 7 },
{ SPWPN_FREEZING, 6 },
{ SPWPN_FLAMING, 6 },
{ SPWPN_VAMPIRISM, 5 },
{ SPWPN_PAIN, 4 },
{ SPWPN_HOLY_WRATH, 3 },
{ SPWPN_DISTORTION, 2 },
{ SPWPN_ANTIMAGIC, 1 },
}},
#if TAG_MAJOR_VERSION == 34
{ WPN_HAMMER, "hammer", 7, 3, 13,
SK_MACES_FLAILS, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_CRUSHING, 0, 0, M_AND_F_BRANDS },
#endif
{ WPN_MACE, "mace", 8, 3, 14,
SK_MACES_FLAILS, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_CRUSHING, 9, 10, M_AND_F_BRANDS },
{ WPN_FLAIL, "flail", 10, 0, 14,
SK_MACES_FLAILS, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_CRUSHING, 8, 10, M_AND_F_BRANDS },
{ WPN_MORNINGSTAR, "morningstar", 13, -2, 15,
SK_MACES_FLAILS, SIZE_LITTLE, SIZE_SMALL, MI_NONE,
DAMV_CRUSHING | DAM_PIERCE, 7, 10, {
{ SPWPN_PROTECTION, 30 },
{ SPWPN_NORMAL, 15 },
{ SPWPN_HOLY_WRATH, 15 },
{ SPWPN_DRAINING, 10 },
{ SPWPN_VORPAL, 9 },
{ SPWPN_VENOM, 5 },
{ SPWPN_FLAMING, 4 },
{ SPWPN_FREEZING, 4 },
{ SPWPN_DISTORTION, 2 },
{ SPWPN_ANTIMAGIC, 2 },
{ SPWPN_PAIN, 2 },
{ SPWPN_VAMPIRISM, 2 },
}},
{ WPN_DEMON_WHIP, "demon whip", 11, 1, 11,
SK_MACES_FLAILS, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_SLASHING, 0, 2, DEMON_BRANDS },
{ WPN_SACRED_SCOURGE, "sacred scourge", 12, 0, 11,
SK_MACES_FLAILS, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_SLASHING, 0, 0, HOLY_BRANDS },
{ WPN_DIRE_FLAIL, "dire flail", 13, -3, 13,
SK_MACES_FLAILS, SIZE_MEDIUM, SIZE_BIG, MI_NONE,
DAMV_CRUSHING | DAM_PIERCE, 2, 10, M_AND_F_BRANDS },
{ WPN_EVENINGSTAR, "eveningstar", 15, -1, 15,
SK_MACES_FLAILS, SIZE_LITTLE, SIZE_SMALL, MI_NONE,
DAMV_CRUSHING | DAM_PIERCE, 0, 2, {
{ SPWPN_PROTECTION, 30 },
{ SPWPN_DRAINING, 19 },
{ SPWPN_HOLY_WRATH, 15 },
{ SPWPN_NORMAL, 8 },
{ SPWPN_VORPAL, 6 },
{ SPWPN_VENOM, 6 },
{ SPWPN_FLAMING, 6 },
{ SPWPN_FREEZING, 6 },
{ SPWPN_DISTORTION, 2 },
{ SPWPN_ANTIMAGIC, 2 },
{ SPWPN_PAIN, 2 },
{ SPWPN_VAMPIRISM, 2 },
}},
{ WPN_GREAT_MACE, "great mace", 17, -4, 17,
SK_MACES_FLAILS, SIZE_MEDIUM, SIZE_BIG, MI_NONE,
DAMV_CRUSHING, 3, 10, M_AND_F_BRANDS },
{ WPN_GIANT_CLUB, "giant club", 20, -6, 16,
SK_MACES_FLAILS, SIZE_LARGE, NUM_SIZE_LEVELS, MI_NONE,
DAMV_CRUSHING, 1, 10, {} },
{ WPN_GIANT_SPIKED_CLUB, "giant spiked club", 22, -7, 19,
SK_MACES_FLAILS, SIZE_LARGE, NUM_SIZE_LEVELS, MI_NONE,
DAMV_CRUSHING | DAM_PIERCE, 1, 10, {} },
// Short Blades
{ WPN_DAGGER, "dagger", 4, 6, 10,
SK_SHORT_BLADES, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_PIERCING, 10, 10, {
{ SPWPN_VENOM, 28 },
{ SPWPN_NORMAL, 20 },
{ SPWPN_SPEED, 10 },
{ SPWPN_DRAINING, 9 },
{ SPWPN_PROTECTION, 6 },
{ SPWPN_ELECTROCUTION, 6 },
{ SPWPN_HOLY_WRATH, 5 },
{ SPWPN_VAMPIRISM, 4 },
{ SPWPN_FLAMING, 4 },
{ SPWPN_FREEZING, 4 },
{ SPWPN_PAIN, 2 },
{ SPWPN_DISTORTION, 1 },
{ SPWPN_ANTIMAGIC, 1 },
}},
{ WPN_QUICK_BLADE, "quick blade", 5, 6, 7,
SK_SHORT_BLADES, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_PIERCING, 0, 2, {} },
{ WPN_SHORT_SWORD, "short sword", 6, 4, 11,
SK_SHORT_BLADES, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_PIERCING, 8, 10, SBL_BRANDS },
{ WPN_RAPIER, "rapier", 7, 4, 12,
SK_SHORT_BLADES, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_PIERCING, 8, 10, SBL_BRANDS },
{ WPN_CUTLASS, "cutlass", 7, 4, 12,
SK_SHORT_BLADES, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_SLICING | DAM_PIERCE, 0, 0, {}},
// Long Blades
{ WPN_FALCHION, "falchion", 8, 2, 13,
SK_LONG_BLADES, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_SLICING, 7, 10, LBL_BRANDS }, // DAMV_CHOPPING...?
{ WPN_LONG_SWORD, "long sword", 10, 1, 14,
SK_LONG_BLADES, SIZE_LITTLE, SIZE_SMALL, MI_NONE,
DAMV_SLICING, 7, 10, LBL_BRANDS },
{ WPN_SCIMITAR, "scimitar", 12, -2, 14,
SK_LONG_BLADES, SIZE_LITTLE, SIZE_SMALL, MI_NONE,
DAMV_SLICING, 6, 10, LBL_BRANDS },
{ WPN_DEMON_BLADE, "demon blade", 13, -1, 13,
SK_LONG_BLADES, SIZE_LITTLE, SIZE_SMALL, MI_NONE,
DAMV_SLICING, 0, 2, DEMON_BRANDS },
{ WPN_EUDEMON_BLADE, "eudemon blade", 14, -2, 12,
SK_LONG_BLADES, SIZE_LITTLE, SIZE_SMALL, MI_NONE,
DAMV_SLICING, 0, 0, HOLY_BRANDS },
{ WPN_DOUBLE_SWORD, "double sword", 15, -1, 15,
SK_LONG_BLADES, SIZE_LITTLE, SIZE_MEDIUM, MI_NONE,
DAMV_SLICING, 0, 2, LBL_BRANDS },
{ WPN_GREAT_SWORD, "great sword", 16, -3, 16,
SK_LONG_BLADES, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_SLICING, 6, 10, LBL_BRANDS },
{ WPN_TRIPLE_SWORD, "triple sword", 19, -4, 19,
SK_LONG_BLADES, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_SLICING, 0, 2, LBL_BRANDS },
#if TAG_MAJOR_VERSION == 34
{ WPN_BLESSED_FALCHION, "old falchion", 8, 2, 13,
SK_LONG_BLADES, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_SLICING, 0, 0, {} },
{ WPN_BLESSED_LONG_SWORD, "old long sword", 10, 1, 14,
SK_LONG_BLADES, SIZE_LITTLE, SIZE_SMALL, MI_NONE,
DAMV_SLICING, 0, 0, {} },
{ WPN_BLESSED_SCIMITAR, "old scimitar", 12, -2, 14,
SK_LONG_BLADES, SIZE_LITTLE, SIZE_SMALL, MI_NONE,
DAMV_SLICING, 0, 0, {} },
{ WPN_BLESSED_DOUBLE_SWORD, "old double sword", 15, -1, 15,
SK_LONG_BLADES, SIZE_LITTLE, SIZE_MEDIUM, MI_NONE,
DAMV_SLICING, 0, 0, {} },
{ WPN_BLESSED_GREAT_SWORD, "old great sword", 16, -3, 16,
SK_LONG_BLADES, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_SLICING, 0, 0, {} },
{ WPN_BLESSED_TRIPLE_SWORD, "old triple sword",19, -4, 19,
SK_LONG_BLADES, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_SLICING, 0, 0, {} },
#endif
// Axes
{ WPN_HAND_AXE, "hand axe", 7, 3, 13,
SK_AXES, SIZE_LITTLE, SIZE_LITTLE, MI_NONE,
DAMV_CHOPPING, 9, 10, AXE_BRANDS },
{ WPN_WAR_AXE, "war axe", 11, 0, 15,
SK_AXES, SIZE_LITTLE, SIZE_SMALL, MI_NONE,
DAMV_CHOPPING, 7, 10, AXE_BRANDS },
{ WPN_BROAD_AXE, "broad axe", 13, -2, 16,
SK_AXES, SIZE_LITTLE, SIZE_MEDIUM, MI_NONE,
DAMV_CHOPPING, 4, 10, AXE_BRANDS },
{ WPN_BATTLEAXE, "battleaxe", 15, -4, 17,
SK_AXES, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_CHOPPING, 6, 10, AXE_BRANDS },
{ WPN_EXECUTIONERS_AXE, "executioner's axe", 18, -6, 20,
SK_AXES, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_CHOPPING, 0, 2, AXE_BRANDS },
// Polearms
{ WPN_SPEAR, "spear", 6, 4, 11,
SK_POLEARMS, SIZE_LITTLE, SIZE_SMALL, MI_NONE,
DAMV_PIERCING, 8, 10, {
{ SPWPN_NORMAL, 46 },
{ SPWPN_VENOM, 17 },
{ SPWPN_VORPAL, 12 },
{ SPWPN_FLAMING, 7 },
{ SPWPN_FREEZING, 7 },
{ SPWPN_VAMPIRISM, 5 },
{ SPWPN_DISTORTION, 2 },
{ SPWPN_PAIN, 2 },
{ SPWPN_ANTIMAGIC, 2 },
}},
{ WPN_TRIDENT, "trident", 9, 1, 13,
SK_POLEARMS, SIZE_LITTLE, SIZE_MEDIUM, MI_NONE,
DAMV_PIERCING, 6, 10, POLEARM_BRANDS },
{ WPN_HALBERD, "halberd", 13, -3, 15,
SK_POLEARMS, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_CHOPPING | DAM_PIERCE, 5, 10, POLEARM_BRANDS },
{ WPN_SCYTHE, "scythe", 14, -4, 20,
SK_POLEARMS, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_SLICING, 2, 0, POLEARM_BRANDS },
{ WPN_DEMON_TRIDENT, "demon trident", 12, 1, 13,
SK_POLEARMS, SIZE_LITTLE, SIZE_MEDIUM, MI_NONE,
DAMV_PIERCING, 0, 2, DEMON_BRANDS },
{ WPN_TRISHULA, "trishula", 13, 0, 13,
SK_POLEARMS, SIZE_LITTLE, SIZE_MEDIUM, MI_NONE,
DAMV_PIERCING, 0, 0, HOLY_BRANDS },
{ WPN_GLAIVE, "glaive", 15, -3, 17,
SK_POLEARMS, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_CHOPPING, 5, 10, POLEARM_BRANDS },
{ WPN_BARDICHE, "bardiche", 18, -6, 20,
SK_POLEARMS, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_CHOPPING, 1, 2, POLEARM_BRANDS },
// Staves
// WPN_STAFF is for weapon stats for magical staves only.
{ WPN_STAFF, "staff", 5, 5, 12,
SK_STAVES, SIZE_LITTLE, SIZE_MEDIUM, MI_NONE,
DAMV_CRUSHING, 0, 0, {} },
{ WPN_QUARTERSTAFF, "quarterstaff", 10, 3, 13,
SK_STAVES, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_CRUSHING, 8, 10, {
{ SPWPN_NORMAL, 50 },
{ SPWPN_PROTECTION, 18 },
{ SPWPN_DRAINING, 8 },
{ SPWPN_VORPAL, 8 },
{ SPWPN_SPEED, 8 },
{ SPWPN_DISTORTION, 2 },
{ SPWPN_PAIN, 2 },
{ SPWPN_HOLY_WRATH, 2 },
{ SPWPN_ANTIMAGIC, 2 },
}},
{ WPN_LAJATANG, "lajatang", 16,-3, 14,
SK_STAVES, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_NONE,
DAMV_SLICING, 2, 2, {
{ SPWPN_NORMAL, 34 },
{ SPWPN_SPEED, 12 },
{ SPWPN_ELECTROCUTION, 12 },
{ SPWPN_VAMPIRISM, 12 },
{ SPWPN_PROTECTION, 9 },
{ SPWPN_VENOM, 7 },
{ SPWPN_PAIN, 7 },
{ SPWPN_ANTIMAGIC, 4 },
{ SPWPN_DISTORTION, 3 },
}},
// Range weapons
{ WPN_BLOWGUN, "blowgun", 0, 2, 10,
SK_THROWING, SIZE_LITTLE, SIZE_LITTLE, MI_NEEDLE,
DAMV_NON_MELEE, 5, 0, {
{ SPWPN_EVASION, 3 },
{ SPWPN_NORMAL, 97 },
}},
{ WPN_HUNTING_SLING, "hunting sling", 5, 2, 12,
SK_SLINGS, SIZE_LITTLE, SIZE_LITTLE, MI_STONE,
DAMV_NON_MELEE, 8, 10, RANGED_BRANDS },
{ WPN_GREATSLING, "greatsling", 8, -1, 14,
SK_SLINGS, SIZE_LITTLE, SIZE_SMALL, MI_STONE,
DAMV_NON_MELEE, 2, 2, RANGED_BRANDS },
{ WPN_HAND_CROSSBOW, "hand crossbow", 12, 5, 15,
SK_CROSSBOWS, SIZE_LITTLE, SIZE_LITTLE, MI_BOLT,
DAMV_NON_MELEE, 7, 10, RANGED_BRANDS },
{ WPN_ARBALEST, "arbalest", 18, 2, 19,
SK_CROSSBOWS, SIZE_LITTLE, NUM_SIZE_LEVELS, MI_BOLT,
DAMV_NON_MELEE, 5, 10, RANGED_BRANDS },
{ WPN_TRIPLE_CROSSBOW, "triple crossbow", 22, 0, 23,
SK_CROSSBOWS, SIZE_SMALL, NUM_SIZE_LEVELS, MI_BOLT,
DAMV_NON_MELEE, 0, 2, RANGED_BRANDS },
{ WPN_SHORTBOW, "shortbow", 9, 2, 13,
SK_BOWS, SIZE_LITTLE, NUM_SIZE_LEVELS, MI_ARROW,
DAMV_NON_MELEE, 8, 10, RANGED_BRANDS },
{ WPN_LONGBOW, "longbow", 15, 0, 17,
SK_BOWS, SIZE_MEDIUM, NUM_SIZE_LEVELS, MI_ARROW,
DAMV_NON_MELEE, 2, 10, RANGED_BRANDS },
};
struct missile_def
{
int id;
const char *name;
int dam;
int mulch_rate;
bool throwable;
};
static int Missile_index[NUM_MISSILES];
static const missile_def Missile_prop[] =
{
#if TAG_MAJOR_VERSION == 34
{ MI_DART, "dart", 2, 1, true },
#endif
{ MI_NEEDLE, "needle", 0, 12, false },
{ MI_STONE, "stone", 2, 8, true },
{ MI_ARROW, "arrow", 0, 8, false },
{ MI_BOLT, "bolt", 0, 8, false },
{ MI_LARGE_ROCK, "large rock", 20, 25, true },
{ MI_SLING_BULLET, "sling bullet", 4, 8, false },
{ MI_JAVELIN, "javelin", 10, 20, true },
{ MI_THROWING_NET, "throwing net", 0, 0, true },
{ MI_TOMAHAWK, "tomahawk", 6, 20, true },
};
struct food_def
{
int id;
const char *name;
int value;
int carn_mod;
int herb_mod;
int turns;
};
static int Food_index[NUM_FOODS];
static const food_def Food_prop[] =
{
{ FOOD_MEAT_RATION, "meat ration", 5000, 500, -1500, 3 },
{ FOOD_CHUNK, "chunk", 1000, 100, -500, 3 },
{ FOOD_BEEF_JERKY, "beef jerky", 1500, 200, -200, 1 },
{ FOOD_BREAD_RATION, "bread ration", 4400, -1000, 500, 3 },
{ FOOD_FRUIT, "fruit", 850, -100, 50, 1 },
{ FOOD_ROYAL_JELLY, "royal jelly", 2000, 0, 0, 3 },
{ FOOD_PIZZA, "pizza", 1500, 0, 0, 1 },
#if TAG_MAJOR_VERSION == 34
{ FOOD_UNUSED, "buggy", 0, 0, 0, 1 },
{ FOOD_AMBROSIA, "buggy", 0, 0, 0, 1 },
{ FOOD_ORANGE, "buggy", 1000, -300, 300, 1 },
{ FOOD_BANANA, "buggy", 1000, -300, 300, 1 },
{ FOOD_LEMON, "buggy", 1000, -300, 300, 1 },
{ FOOD_PEAR, "buggy", 700, -200, 200, 1 },
{ FOOD_APPLE, "buggy", 700, -200, 200, 1 },
{ FOOD_APRICOT, "buggy", 700, -200, 200, 1 },
{ FOOD_CHOKO, "buggy", 600, -200, 200, 1 },
{ FOOD_RAMBUTAN, "buggy", 600, -200, 200, 1 },
{ FOOD_LYCHEE, "buggy", 600, -200, 200, 1 },
{ FOOD_STRAWBERRY, "buggy", 200, -50, 50, 1 },
{ FOOD_GRAPE, "buggy", 100, -20, 20, 1 },
{ FOOD_SULTANA, "buggy", 70, -20, 20, 1 },
{ FOOD_CHEESE, "buggy", 1200, 0, 0, 1 },
{ FOOD_SAUSAGE, "buggy", 1200, 150, -400, 1 },
#endif
};
// Must call this functions early on so that the above tables can
// be accessed correctly.
void init_properties()
{
// The compiler would complain about too many initializers but not
// about too few, so we check this ourselves.
COMPILE_CHECK(NUM_ARMOURS == ARRAYSZ(Armour_prop));
COMPILE_CHECK(NUM_WEAPONS == ARRAYSZ(Weapon_prop));
COMPILE_CHECK(NUM_MISSILES == ARRAYSZ(Missile_prop));
COMPILE_CHECK(NUM_FOODS == ARRAYSZ(Food_prop));
for (int i = 0; i < NUM_ARMOURS; i++)
Armour_index[ Armour_prop[i].id ] = i;
for (int i = 0; i < NUM_WEAPONS; i++)
Weapon_index[ Weapon_prop[i].id ] = i;
for (int i = 0; i < NUM_MISSILES; i++)
Missile_index[ Missile_prop[i].id ] = i;
for (int i = 0; i < NUM_FOODS; i++)
Food_index[ Food_prop[i].id ] = i;
}
const set<pair<object_class_type, int> > removed_items =
{
#if TAG_MAJOR_VERSION == 34
{ OBJ_JEWELLERY, AMU_CONTROLLED_FLIGHT },
{ OBJ_JEWELLERY, AMU_CONSERVATION },
{ OBJ_JEWELLERY, RING_REGENERATION },
{ OBJ_JEWELLERY, RING_TELEPORT_CONTROL },
{ OBJ_STAVES, STAFF_ENCHANTMENT },
{ OBJ_STAVES, STAFF_CHANNELING },
{ OBJ_POTIONS, POT_GAIN_STRENGTH },
{ OBJ_POTIONS, POT_GAIN_DEXTERITY },
{ OBJ_POTIONS, POT_GAIN_INTELLIGENCE },
{ OBJ_POTIONS, POT_WATER },
{ OBJ_POTIONS, POT_STRONG_POISON },
{ OBJ_POTIONS, POT_BLOOD_COAGULATED },
{ OBJ_POTIONS, POT_PORRIDGE },
{ OBJ_POTIONS, POT_SLOWING },
{ OBJ_POTIONS, POT_DECAY },
{ OBJ_POTIONS, POT_RESTORE_ABILITIES },
{ OBJ_BOOKS, BOOK_WIZARDRY },
{ OBJ_BOOKS, BOOK_CONTROL },
{ OBJ_BOOKS, BOOK_BUGGY_DESTRUCTION },
{ OBJ_RODS, ROD_VENOM },
{ OBJ_RODS, ROD_WARDING },
{ OBJ_SCROLLS, SCR_ENCHANT_WEAPON_II },
{ OBJ_SCROLLS, SCR_ENCHANT_WEAPON_III },
#endif
// Outside the #if because we probably won't remove these.
{ OBJ_RUNES, RUNE_ELF },
{ OBJ_RUNES, RUNE_FOREST },
{ OBJ_JEWELLERY, AMU_NOTHING }, // These should only spawn as uniques
};
bool item_type_removed(object_class_type base, int subtype)
{
return removed_items.count({ base, subtype }) != 0;
}
// Some convenient functions to hide the bit operations and create
// an interface layer between the code and the data in case this
// gets changed again. - bwr
//
// Item cursed status functions:
//
bool item_known_cursed(const item_def &item)
{
return _full_ident_mask(item) & ISFLAG_KNOW_CURSE
&& item_ident(item, ISFLAG_KNOW_CURSE) && item.cursed();
}
// Curses a random player inventory item.
bool curse_an_item(bool ignore_holy_wrath)
{
// allowing these would enable mummy scumming
if (you_worship(GOD_ASHENZARI))
{
mprf(MSGCH_GOD, "The curse is absorbed by %s.",
god_name(GOD_ASHENZARI).c_str());
return false;
}
int count = 0;
item_def *found = nullptr;
for (auto &item : you.inv)
{
if (!item.defined())
continue;
if (is_weapon(item)
|| item.base_type == OBJ_ARMOUR
|| item.base_type == OBJ_JEWELLERY)
{
if (item.cursed())
continue;
if (ignore_holy_wrath && item.base_type == OBJ_WEAPONS
&& get_weapon_brand(item) == SPWPN_HOLY_WRATH)
{
continue;
}
// Item is valid for cursing, so we'll give it a chance.
count++;
if (one_chance_in(count))
found = &item;
}
}
// Any item to curse?
if (!found)
return false;
do_curse_item(*found, false);
return true;
}
void auto_id_inventory()
{
for (auto &item : you.inv)
if (item.defined())
god_id_item(item, false);
}
void do_curse_item(item_def &item, bool quiet)
{
// Already cursed?
if (item.flags & ISFLAG_CURSED)
return;
if (!is_weapon(item) && item.base_type != OBJ_ARMOUR
&& item.base_type != OBJ_JEWELLERY)
{
return;
}
// Holy wrath weapons cannot be cursed.
if (item.base_type == OBJ_WEAPONS
&& get_weapon_brand(item) == SPWPN_HOLY_WRATH)
{
if (!quiet)
{
const bool was_known = is_artefact(item)
? artefact_known_property(item, ARTP_BRAND)
: item_ident(item, ISFLAG_KNOW_TYPE);
mprf("Your %s glows black briefly, but repels the curse.",
item.name(DESC_PLAIN).c_str());
if (is_artefact(item))
artefact_learn_prop(item, ARTP_BRAND);
else
set_ident_flags(item, ISFLAG_KNOW_TYPE);
if (!was_known)
mprf_nocap("%s", item.name(DESC_INVENTORY_EQUIP).c_str());
}
return;
}
if (!quiet)
{
mprf("Your %s glows black for a moment.",
item.name(DESC_PLAIN).c_str());
// If we get the message, we know the item is cursed now.
item.flags |= ISFLAG_KNOW_CURSE;
}
item.flags |= ISFLAG_CURSED;
// Xom is amused by the player's items being cursed, especially if
// they're worn/equipped.
if (in_inventory(item))
{
int amusement = 50;
if (item_is_equipped(item))
{
amusement *= 2;
if (you.equip[EQ_WEAPON] == item.link)
{
// Redraw the weapon.
you.wield_change = true;
}
ash_check_bondage();
auto_id_inventory();
}
xom_is_stimulated(amusement);
}
}
void do_uncurse_item(item_def &item, bool inscribe, bool no_ash,
bool check_bondage)
{
if (!item.cursed())
{
if (in_inventory(item))
item.flags |= ISFLAG_KNOW_CURSE;
return;
}
if (no_ash && you_worship(GOD_ASHENZARI))
{
simple_god_message(" preserves the curse.");
return;
}
if (in_inventory(item))
{
if (you.equip[EQ_WEAPON] == item.link)
{
// Redraw the weapon.
you.wield_change = true;
}
item.flags |= ISFLAG_KNOW_CURSE;
}
item.flags &= (~ISFLAG_CURSED);
if (check_bondage)
ash_check_bondage();
}
/**
* Make a net stationary (because it currently traps a victim).
*
* @param item The net item.
*/
void set_net_stationary(item_def &item)
{
if (item.is_type(OBJ_MISSILES, MI_THROWING_NET))
item.net_placed = true;
}
/**
* Is the item stationary (unmovable)?
*
* Currently only carrion and nets with a trapped victim are stationary.
* @param item The item.
* @return True iff the item is stationary.
*/
bool item_is_stationary(const item_def &item)
{
return item.base_type == OBJ_CORPSES || item_is_stationary_net(item);
}
/**
* Is the item a stationary net?
*
* @param item The item.
* @return True iff the item is a stationary net.
*/
bool item_is_stationary_net(const item_def &item)
{
return item.is_type(OBJ_MISSILES, MI_THROWING_NET) && item.net_placed;
}
/**
* Get the actor held in a stationary net.
*
* @param net A stationary net item.
* @return A pointer to the actor in the net, guaranteed to be non-null.
*/
actor *net_holdee(const item_def &net)
{
ASSERT(item_is_stationary_net(net));
// Stationary nets should not be in inventory etc.
ASSERT_IN_BOUNDS(net.pos);
actor * const a = actor_at(net.pos);
ASSERTM(a, "No actor in stationary net at (%d,%d)", net.pos.x, net.pos.y);
return a;
}
static bool _is_affordable(const item_def &item)
{
// Temp items never count.
if (item.flags & ISFLAG_SUMMONED)
return false;
// Already in our grubby mitts.
if (in_inventory(item))
return true;
// Disregard shop stuff above your reach.
if (is_shop_item(item))
return (int)item_value(item) <= you.gold;
// Explicitly marked by a vault.
if (item.flags & ISFLAG_UNOBTAINABLE)
return false;
// On the ground or a monster has it. Violence is the answer.
return true;
}
//
// Item identification status:
//
bool item_ident(const item_def &item, iflags_t flags)
{
return (item.flags & flags) == flags;
}
void set_ident_flags(item_def &item, iflags_t flags)
{
preserve_quiver_slots p;
if ((item.flags & flags) != flags)
{
item.flags |= flags;
request_autoinscribe();
if (in_inventory(item))
{
shopping_list.cull_identical_items(item);
item_skills(item, you.start_train);
}
}
if (fully_identified(item))
{
if (notes_are_active() && !(item.flags & ISFLAG_NOTED_ID)
&& !get_ident_type(item)
&& is_interesting_item(item))
{
// Make a note of it.
take_note(Note(NOTE_ID_ITEM, 0, 0, item.name(DESC_A),
origin_desc(item)));
// Sometimes (e.g. shops) you can ID an item before you get it;
// don't note twice in those cases.
item.flags |= (ISFLAG_NOTED_ID | ISFLAG_NOTED_GET);
}
}