-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
ability.cc
3712 lines (3240 loc) · 114 KB
/
ability.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 Functions related to special abilities.
**/
#include "AppHdr.h"
#include "ability.h"
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <sstream>
#include "abyss.h"
#include "acquire.h"
#include "areas.h"
#include "art-enum.h"
#include "branch.h"
#include "butcher.h"
#include "chardump.h"
#include "cleansing-flame-source-type.h"
#include "cloud.h"
#include "coordit.h"
#include "database.h"
#include "decks.h"
#include "delay.h"
#include "describe.h"
#include "directn.h"
#include "dungeon.h"
#include "evoke.h"
#include "exercise.h"
#include "fight.h"
#include "food.h"
#include "god-abil.h"
#include "god-companions.h"
#include "god-conduct.h"
#include "god-prayer.h"
#include "god-wrath.h"
#include "hints.h"
#include "invent.h"
#include "item-prop.h"
#include "items.h"
#include "item-status-flag-type.h"
#include "item-use.h"
#include "level-state-type.h"
#include "libutil.h"
#include "macro.h"
#include "maps.h"
#include "menu.h"
#include "message.h"
#include "mon-place.h"
#include "mutation.h"
#include "notes.h"
#include "options.h"
#include "output.h"
#include "player-stats.h"
#include "potion.h"
#include "prompt.h"
#include "religion.h"
#include "skills.h"
#include "spl-cast.h"
#include "spl-clouds.h"
#include "spl-damage.h"
#include "spl-goditem.h"
#include "spl-miscast.h"
#include "spl-other.h"
#include "spl-selfench.h"
#include "spl-summoning.h"
#include "spl-transloc.h"
#include "stairs.h"
#include "state.h"
#include "stepdown.h"
#include "stringutil.h"
#include "target.h"
#include "terrain.h"
#include "tilepick.h"
#include "transform.h"
#include "traps.h"
#include "uncancel.h"
#include "unicode.h"
#include "view.h"
#ifdef USE_TILE
# include "tiledef-icons.h"
#endif
enum class abflag
{
none = 0x00000000,
breath = 0x00000001, // ability uses DUR_BREATH_WEAPON
delay = 0x00000002, // ability has its own delay
pain = 0x00000004, // ability must hurt player (ie torment)
piety = 0x00000008, // ability has its own piety cost
exhaustion = 0x00000010, // fails if you.exhausted
instant = 0x00000020, // doesn't take time to use
//0x00000040,
//0x00000080,
conf_ok = 0x00000100, // can use even if confused
rations = 0x00000200, // ability requires 2 rations per target
rations_or_piety = 0x00000400, // ability requires 2 rations or piety
variable_mp = 0x00000800, // costs a variable amount of MP
//0x00001000,
//0x00002000,
//0x00004000,
//0x00008000,
//0x00010000,
//0x00020000,
remove_curse_scroll = 0x00040000, // Uses ?rc
skill_drain = 0x00080000, // drains skill levels
gold = 0x00100000, // costs gold
sacrifice = 0x00200000, // sacrifice (Ru)
hostile = 0x00400000, // failure summons a hostile (Makhleb)
starve_ok = 0x00800000, // can use even if starving
};
DEF_BITFIELD(ability_flags, abflag);
struct generic_cost
{
int base, add, rolls;
generic_cost(int num)
: base(num), add(num == 0 ? 0 : (num + 1) / 2 + 1), rolls(1)
{
}
generic_cost(int num, int _add, int _rolls = 1)
: base(num), add(_add), rolls(_rolls)
{
}
static generic_cost fixed(int fixed)
{
return generic_cost(fixed, 0, 1);
}
static generic_cost range(int low, int high, int _rolls = 1)
{
return generic_cost(low, high - low + 1, _rolls);
}
int cost() const PURE;
operator bool () const { return base > 0 || add > 0; }
};
struct scaling_cost
{
int value;
scaling_cost(int permille) : value(permille) {}
static scaling_cost fixed(int fixed)
{
return scaling_cost(-fixed);
}
int cost(int max) const;
operator bool () const { return value != 0; }
};
/// What affects the failure chance of the ability?
enum class fail_basis
{
xl,
evo,
invo,
};
/**
* What skill is used to determine the player's god's invocations' failure
* chance?
*
* XXX: deduplicate this with the similar code for divine titles, etc
* (skills.cc:skill_title_by_rank)
*
* IMPORTANT NOTE: functions that depend on this will be wrong if you aren't
* currently worshipping a god that grants the given ability (e.g. in ?/A)!
*
* @return The appropriate skill type; e.g. SK_INVOCATIONS.
*/
skill_type invo_skill(god_type god)
{
switch (god)
{
case GOD_KIKUBAAQUDGHA:
return SK_NECROMANCY;
#if TAG_MAJOR_VERSION == 34
case GOD_PAKELLAS:
return SK_EVOCATIONS;
#endif
case GOD_ASHENZARI:
case GOD_JIYVA:
case GOD_GOZAG:
case GOD_RU:
case GOD_TROG:
case GOD_WU_JIAN:
return SK_NONE; // ugh
default:
return SK_INVOCATIONS;
}
}
/// How to determine the odds of the ability failing?
struct failure_info
{
/// what determines the variable portion of failure: e.g. xl, evo, invo
fail_basis basis;
/// base failure chance
int base_chance;
/// multiplier to skill/xl; subtracted from base fail chance
int variable_fail_mult;
/// denominator to piety; subtracted from base fail chance if invo
int piety_fail_denom;
/**
* What's the chance of the ability failing if the player tries to use it
* right now?
*
* See spl-cast.cc:_get_true_fail_rate() for details on what this 'chance'
* actually means.
*
* @return A failure chance; may be outside the 0-100 range.
*/
int chance() const
{
switch (basis)
{
case fail_basis::xl:
return base_chance - you.experience_level * variable_fail_mult;
case fail_basis::evo:
return base_chance - you.skill(SK_EVOCATIONS, variable_fail_mult);
case fail_basis::invo:
{
const int sk_mod = invo_skill() == SK_NONE ? 0 :
you.skill(invo_skill(), variable_fail_mult);
const int piety_mod
= piety_fail_denom ? you.piety / piety_fail_denom : 0;
return base_chance - sk_mod - piety_mod;
}
default:
die("unknown failure basis %d!", (int)basis);
}
}
/// What skill governs the use of this ability, if any?
skill_type skill() const
{
switch (basis)
{
case fail_basis::evo:
return SK_EVOCATIONS;
case fail_basis::invo:
return invo_skill();
case fail_basis::xl:
default:
return SK_NONE;
}
}
};
// Structure for representing an ability:
struct ability_def
{
ability_type ability;
const char * name;
unsigned int mp_cost; // magic cost of ability
scaling_cost hp_cost; // hit point cost of ability
unsigned int food_cost; // + rand2avg(food_cost, 2)
generic_cost piety_cost; // + random2((piety_cost + 1) / 2 + 1)
failure_info failure; // calculator for failure odds
ability_flags flags; // used for additional cost notices
};
static int _lookup_ability_slot(ability_type abil);
static spret_type _do_ability(const ability_def& abil, bool fail);
static void _pay_ability_costs(const ability_def& abil);
static int _scale_piety_cost(ability_type abil, int original_cost);
// The description screen was way out of date with the actual costs.
// This table puts all the information in one place... -- bwr
//
// The four numerical fields are: MP, HP, food, and piety.
// Note: food_cost = val + random2avg(val, 2)
// piety_cost = val + random2((val + 1) / 2 + 1);
// hp cost is in per-mil of maxhp (i.e. 20 = 2% of hp, rounded up)
static const ability_def Ability_List[] =
{
// NON_ABILITY should always come first
{ ABIL_NON_ABILITY, "No ability", 0, 0, 0, 0, {}, abflag::none },
{ ABIL_SPIT_POISON, "Spit Poison",
0, 0, 40, 0, {fail_basis::xl, 20, 1}, abflag::breath },
{ ABIL_BLINK, "Blink", 0, 50, 50, 0, {fail_basis::xl, -1}, abflag::none },
// ^ failure special-cased
{ ABIL_BREATHE_FIRE, "Breathe Fire",
0, 0, 125, 0, {fail_basis::xl, 30, 1}, abflag::breath },
{ ABIL_BREATHE_FROST, "Breathe Frost",
0, 0, 125, 0, {fail_basis::xl, 30, 1}, abflag::breath },
{ ABIL_BREATHE_POISON, "Breathe Poison Gas",
0, 0, 125, 0, {fail_basis::xl, 30, 1}, abflag::breath },
{ ABIL_BREATHE_MEPHITIC, "Breathe Noxious Fumes",
0, 0, 125, 0, {fail_basis::xl, 30, 1}, abflag::breath },
{ ABIL_BREATHE_LIGHTNING, "Breathe Lightning",
0, 0, 125, 0, {fail_basis::xl, 30, 1}, abflag::breath },
{ ABIL_BREATHE_POWER, "Breathe Dispelling Energy",
0, 0, 125, 0, {fail_basis::xl, 30, 1}, abflag::breath },
{ ABIL_BREATHE_STEAM, "Breathe Steam",
0, 0, 75, 0, {fail_basis::xl, 20, 1}, abflag::breath },
{ ABIL_TRAN_BAT, "Bat Form",
2, 0, 0, 0, {fail_basis::xl, 45, 2}, abflag::starve_ok },
{ ABIL_BREATHE_ACID, "Breathe Acid",
0, 0, 125, 0, {fail_basis::xl, 30, 1}, abflag::breath },
{ ABIL_FLY, "Fly", 3, 0, 100, 0, {fail_basis::xl, 42, 3}, abflag::none },
{ ABIL_STOP_FLYING, "Stop Flying", 0, 0, 0, 0, {}, abflag::starve_ok },
{ ABIL_DAMNATION, "Hurl Damnation",
0, 150, 200, 0, {fail_basis::xl, 50, 1}, abflag::none },
{ ABIL_CANCEL_PPROJ, "Cancel Portal Projectile",
0, 0, 0, 0, {}, abflag::instant | abflag::starve_ok },
{ ABIL_DIG, "Dig", 0, 0, 0, 0, {}, abflag::instant | abflag::starve_ok },
{ ABIL_SHAFT_SELF, "Shaft Self", 0, 0, 250, 0, {}, abflag::delay },
{ ABIL_HOP, "Hop", 0, 0, 0, 0, {}, abflag::none },
// EVOKE abilities use Evocations and come from items.
// Teleportation and Blink can also come from mutations
// so we have to distinguish them (see above). The off items
// below are labeled EVOKE because they only work now if the
// player has an item with the evocable power (not just because
// you used a wand, potion, or miscast effect). I didn't see
// any reason to label them as "Evoke" in the text, they don't
// use or train Evocations (the others do). -- bwr
{ ABIL_EVOKE_BLINK, "Evoke Blink",
1, 0, 50, 0, {fail_basis::evo, 40, 2}, abflag::none },
{ ABIL_HEAL_WOUNDS, "Heal Wounds",
0, 0, 0, 0, {fail_basis::xl, 45, 2}, abflag::none },
{ ABIL_EVOKE_BERSERK, "Evoke Berserk Rage",
0, 0, 600, 0, {fail_basis::evo, 50, 2}, abflag::none },
{ ABIL_EVOKE_TURN_INVISIBLE, "Evoke Invisibility",
2, 0, 250, 0, {fail_basis::evo, 60, 2}, abflag::none },
#if TAG_MAJOR_VERSION == 34
{ ABIL_EVOKE_TURN_VISIBLE, "Turn Visible",
0, 0, 0, 0, {}, abflag::starve_ok },
#endif
{ ABIL_EVOKE_FLIGHT, "Evoke Flight",
1, 0, 100, 0, {fail_basis::evo, 40, 2}, abflag::none },
{ ABIL_EVOKE_FOG, "Evoke Fog",
2, 0, 250, 0, {fail_basis::evo, 50, 2}, abflag::none },
{ ABIL_EVOKE_RATSKIN, "Evoke Ratskin",
3, 0, 200, 0, {fail_basis::evo, 50, 2}, abflag::none },
{ ABIL_END_TRANSFORMATION, "End Transformation",
0, 0, 0, 0, {}, abflag::starve_ok },
// INVOCATIONS:
// Zin
{ ABIL_ZIN_RECITE, "Recite",
0, 0, 0, 0, {fail_basis::invo, 30, 6, 20}, abflag::none },
{ ABIL_ZIN_VITALISATION, "Vitalisation",
2, 0, 0, 1, {fail_basis::invo, 40, 5, 20}, abflag::none },
{ ABIL_ZIN_IMPRISON, "Imprison",
5, 0, 0, 4, {fail_basis::invo, 60, 5, 20}, abflag::none },
{ ABIL_ZIN_SANCTUARY, "Sanctuary",
7, 0, 0, 15, {fail_basis::invo, 80, 4, 25}, abflag::none },
{ ABIL_ZIN_DONATE_GOLD, "Donate Gold",
0, 0, 0, 0, {fail_basis::invo}, abflag::none },
// The Shining One
{ ABIL_TSO_DIVINE_SHIELD, "Divine Shield",
3, 0, 50, 2, {fail_basis::invo, 40, 5, 20}, abflag::none },
{ ABIL_TSO_CLEANSING_FLAME, "Cleansing Flame",
5, 0, 100, 2, {fail_basis::invo, 70, 4, 25}, abflag::none },
{ ABIL_TSO_SUMMON_DIVINE_WARRIOR, "Summon Divine Warrior",
8, 0, 150, 5, {fail_basis::invo, 80, 4, 25}, abflag::none },
{ ABIL_TSO_BLESS_WEAPON, "Brand Weapon With Holy Wrath", 0, 0, 0, 0,
{fail_basis::invo}, abflag::none },
// Kikubaaqudgha
{ ABIL_KIKU_RECEIVE_CORPSES, "Receive Corpses",
3, 0, 200, 2, {fail_basis::invo, 40, 5, 20}, abflag::none },
{ ABIL_KIKU_TORMENT, "Torment",
4, 0, 0, 8, {fail_basis::invo, 60, 5, 20}, abflag::none },
{ ABIL_KIKU_GIFT_NECRONOMICON, "Receive Necronomicon", 0, 0, 0, 0,
{fail_basis::invo}, abflag::none },
{ ABIL_KIKU_BLESS_WEAPON, "Brand Weapon With Pain", 0, 0, 0, 0,
{fail_basis::invo}, abflag::pain },
// Yredelemnul
{ ABIL_YRED_INJURY_MIRROR, "Injury Mirror",
0, 0, 0, 0, {fail_basis::invo, 40, 4, 20}, abflag::piety },
{ ABIL_YRED_ANIMATE_REMAINS, "Animate Remains",
2, 0, 200, 0, {fail_basis::invo, 40, 4, 20}, abflag::none },
{ ABIL_YRED_RECALL_UNDEAD_SLAVES, "Recall Undead Slaves",
2, 0, 0, 0, {fail_basis::invo, 50, 4, 20}, abflag::none },
{ ABIL_YRED_ANIMATE_DEAD, "Animate Dead",
2, 0, 200, 0, {fail_basis::invo, 40, 4, 20}, abflag::none },
{ ABIL_YRED_DRAIN_LIFE, "Drain Life",
6, 0, 200, 2, {fail_basis::invo, 60, 4, 25}, abflag::none },
{ ABIL_YRED_ENSLAVE_SOUL, "Enslave Soul",
8, 0, 500, 4, {fail_basis::invo, 80, 4, 25}, abflag::none },
// Okawaru
{ ABIL_OKAWARU_HEROISM, "Heroism",
2, 0, 0, 1, {fail_basis::invo, 30, 6, 20}, abflag::none },
{ ABIL_OKAWARU_FINESSE, "Finesse",
5, 0, 0, 3, {fail_basis::invo, 60, 4, 25}, abflag::none },
// Makhleb
{ ABIL_MAKHLEB_MINOR_DESTRUCTION, "Minor Destruction",
0, scaling_cost::fixed(1), 0, 0, {fail_basis::invo, 40, 5, 20}, abflag::none },
{ ABIL_MAKHLEB_LESSER_SERVANT_OF_MAKHLEB, "Lesser Servant of Makhleb",
0, scaling_cost::fixed(4), 0, 2, {fail_basis::invo, 40, 5, 20}, abflag::hostile },
{ ABIL_MAKHLEB_MAJOR_DESTRUCTION, "Major Destruction",
0, scaling_cost::fixed(6), 0, generic_cost::range(0, 1),
{fail_basis::invo, 60, 4, 25}, abflag::none },
{ ABIL_MAKHLEB_GREATER_SERVANT_OF_MAKHLEB, "Greater Servant of Makhleb",
0, scaling_cost::fixed(10), 0, 5,
{fail_basis::invo, 90, 2, 5}, abflag::hostile },
// Sif Muna
{ ABIL_SIF_MUNA_DIVINE_ENERGY, "Divine Energy",
0, 0, 0, 0, {fail_basis::invo}, abflag::instant | abflag::starve_ok },
{ ABIL_SIF_MUNA_STOP_DIVINE_ENERGY, "Stop Divine Energy",
0, 0, 0, 0, {fail_basis::invo}, abflag::instant | abflag::starve_ok },
{ ABIL_SIF_MUNA_FORGET_SPELL, "Forget Spell",
0, 0, 0, 8, {fail_basis::invo}, abflag::none },
{ ABIL_SIF_MUNA_CHANNEL_ENERGY, "Channel Magic",
0, 0, 200, 2, {fail_basis::invo, 60, 4, 25}, abflag::none },
// Trog
{ ABIL_TROG_BERSERK, "Berserk",
0, 0, 600, 0, {fail_basis::invo}, abflag::none },
{ ABIL_TROG_REGEN_MR, "Trog's Hand",
0, 0, 200, 2, {fail_basis::invo, piety_breakpoint(2), 0, 1}, abflag::none },
{ ABIL_TROG_BROTHERS_IN_ARMS, "Brothers in Arms",
0, 0, 250, generic_cost::range(5, 6),
{fail_basis::invo, piety_breakpoint(5), 0, 1}, abflag::none },
// Elyvilon
{ ABIL_ELYVILON_LIFESAVING, "Divine Protection",
0, 0, 0, 0, {fail_basis::invo}, abflag::piety },
{ ABIL_ELYVILON_LESSER_HEALING, "Lesser Healing", 1, 0, 100,
generic_cost::range(0, 1), {fail_basis::invo, 30, 6, 20}, abflag::none },
{ ABIL_ELYVILON_HEAL_OTHER, "Heal Other",
2, 0, 250, 2, {fail_basis::invo, 40, 5, 20}, abflag::none },
{ ABIL_ELYVILON_PURIFICATION, "Purification",
3, 0, 300, 3, {fail_basis::invo, 20, 5, 20}, abflag::conf_ok },
{ ABIL_ELYVILON_GREATER_HEALING, "Greater Healing",
2, 0, 250, 3, {fail_basis::invo, 40, 5, 20}, abflag::none },
{ ABIL_ELYVILON_DIVINE_VIGOUR, "Divine Vigour",
0, 0, 600, 6, {fail_basis::invo, 80, 4, 25}, abflag::none },
// Lugonu
{ ABIL_LUGONU_ABYSS_EXIT, "Depart the Abyss",
1, 0, 0, 10, {fail_basis::invo, 30, 6, 20}, abflag::none },
{ ABIL_LUGONU_BEND_SPACE, "Bend Space",
1, scaling_cost::fixed(2), 0, 0, {fail_basis::invo, 40, 5, 20}, abflag::none },
{ ABIL_LUGONU_BANISH, "Banish", 4, 0, 200, generic_cost::range(3, 4),
{fail_basis::invo, 85, 7, 20}, abflag::none },
{ ABIL_LUGONU_CORRUPT, "Corrupt", 7, scaling_cost::fixed(5), 500, 10,
{fail_basis::invo, 70, 4, 25}, abflag::none },
{ ABIL_LUGONU_ABYSS_ENTER, "Enter the Abyss", 10, 0, 500, 28,
{fail_basis::invo, 80, 4, 25}, abflag::pain },
{ ABIL_LUGONU_BLESS_WEAPON, "Brand Weapon With Distortion", 0, 0, 0, 0,
{fail_basis::invo}, abflag::none },
// Nemelex
{ ABIL_NEMELEX_TRIPLE_DRAW, "Triple Draw",
2, 0, 0, 2, {fail_basis::invo, 60, 5, 20}, abflag::none },
{ ABIL_NEMELEX_DEAL_FOUR, "Deal Four",
8, 0, 0, 8, {fail_basis::invo, -1}, abflag::none }, // failure special-cased
{ ABIL_NEMELEX_STACK_FIVE, "Stack Five",
5, 0, 0, 10, {fail_basis::invo, 80, 4, 25}, abflag::none },
// Beogh
{ ABIL_BEOGH_SMITING, "Smiting",
3, 0, 0, generic_cost::fixed(3), {fail_basis::invo, 40, 5, 20}, abflag::none },
{ ABIL_BEOGH_RECALL_ORCISH_FOLLOWERS, "Recall Orcish Followers",
2, 0, 0, 0, {fail_basis::invo, 30, 6, 20}, abflag::none },
{ ABIL_BEOGH_GIFT_ITEM, "Give Item to Named Follower",
0, 0, 0, 0, {fail_basis::invo}, abflag::none },
{ ABIL_BEOGH_RESURRECTION, "Resurrection",
0, 0, 0, 28, {fail_basis::invo}, abflag::none },
// Jiyva
{ ABIL_JIYVA_CALL_JELLY, "Request Jelly",
2, 0, 0, 1, {fail_basis::invo}, abflag::none },
{ ABIL_JIYVA_SLIMIFY, "Slimify",
4, 0, 0, 8, {fail_basis::invo, 90, 0, 2}, abflag::none },
{ ABIL_JIYVA_CURE_BAD_MUTATION, "Cure Bad Mutation",
0, 0, 0, 15, {fail_basis::invo}, abflag::none },
// Fedhas
{ ABIL_FEDHAS_FUNGAL_BLOOM, "Fungal Bloom",
0, 0, 0, 0, {fail_basis::invo}, abflag::none },
{ ABIL_FEDHAS_SUNLIGHT, "Sunlight",
2, 0, 50, 0, {fail_basis::invo, 30, 6, 20}, abflag::none },
{ ABIL_FEDHAS_EVOLUTION, "Evolution",
2, 0, 0, 0, {fail_basis::invo, 30, 6, 20}, abflag::rations_or_piety },
{ ABIL_FEDHAS_PLANT_RING, "Growth",
2, 0, 0, 0, {fail_basis::invo, 40, 5, 20}, abflag::rations },
{ ABIL_FEDHAS_SPAWN_SPORES, "Reproduction",
4, 0, 100, 1, {fail_basis::invo, 60, 4, 25}, abflag::none },
{ ABIL_FEDHAS_RAIN, "Rain",
4, 0, 150, 4, {fail_basis::invo, 70, 4, 25}, abflag::none },
// Cheibriados
{ ABIL_CHEIBRIADOS_TIME_BEND, "Bend Time",
3, 0, 50, 1, {fail_basis::invo, 40, 4, 20}, abflag::none },
{ ABIL_CHEIBRIADOS_DISTORTION, "Temporal Distortion",
4, 0, 200, 3, {fail_basis::invo, 60, 5, 20}, abflag::instant },
{ ABIL_CHEIBRIADOS_SLOUCH, "Slouch",
5, 0, 100, 8, {fail_basis::invo, 60, 4, 25}, abflag::none },
{ ABIL_CHEIBRIADOS_TIME_STEP, "Step From Time",
10, 0, 200, 10, {fail_basis::invo, 80, 4, 25}, abflag::none },
// Ashenzari
{ ABIL_ASHENZARI_CURSE, "Curse Item",
0, 0, 0, 0, {fail_basis::invo}, abflag::remove_curse_scroll },
{ ABIL_ASHENZARI_SCRYING, "Scrying",
4, 0, 0, 2, {fail_basis::invo}, abflag::instant },
{ ABIL_ASHENZARI_TRANSFER_KNOWLEDGE, "Transfer Knowledge",
0, 0, 0, 10, {fail_basis::invo}, abflag::none },
{ ABIL_ASHENZARI_END_TRANSFER, "End Transfer Knowledge",
0, 0, 0, 0, {fail_basis::invo}, abflag::starve_ok },
// Dithmenos
{ ABIL_DITHMENOS_SHADOW_STEP, "Shadow Step",
4, 80, 0, 5, {fail_basis::invo, 30, 6, 20}, abflag::none },
{ ABIL_DITHMENOS_SHADOW_FORM, "Shadow Form",
9, 0, 0, 12, {fail_basis::invo, 80, 4, 25}, abflag::skill_drain },
// Ru
{ ABIL_RU_DRAW_OUT_POWER, "Draw Out Power", 0, 0, 0, 0,
{fail_basis::invo}, abflag::exhaustion|abflag::skill_drain|abflag::conf_ok },
{ ABIL_RU_POWER_LEAP, "Power Leap",
5, 0, 0, 0, {fail_basis::invo}, abflag::exhaustion },
{ ABIL_RU_APOCALYPSE, "Apocalypse",
8, 0, 0, 0, {fail_basis::invo}, abflag::exhaustion|abflag::skill_drain },
{ ABIL_RU_SACRIFICE_PURITY, "Sacrifice Purity",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_WORDS, "Sacrifice Words",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_DRINK, "Sacrifice Drink",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_ESSENCE, "Sacrifice Essence",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_HEALTH, "Sacrifice Health",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_STEALTH, "Sacrifice Stealth",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_ARTIFICE, "Sacrifice Artifice",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_LOVE, "Sacrifice Love",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_COURAGE, "Sacrifice Courage",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_ARCANA, "Sacrifice Arcana",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_NIMBLENESS, "Sacrifice Nimbleness",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_DURABILITY, "Sacrifice Durability",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_HAND, "Sacrifice a Hand",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_EXPERIENCE, "Sacrifice Experience",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_SKILL, "Sacrifice Skill",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_EYE, "Sacrifice an Eye",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_SACRIFICE_RESISTANCE, "Sacrifice Resistance",
0, 0, 0, 0, {fail_basis::invo}, abflag::sacrifice },
{ ABIL_RU_REJECT_SACRIFICES, "Reject Sacrifices",
0, 0, 0, 0, {fail_basis::invo}, abflag::none },
// Gozag
{ ABIL_GOZAG_POTION_PETITION, "Potion Petition",
0, 0, 0, 0, {fail_basis::invo}, abflag::gold },
{ ABIL_GOZAG_CALL_MERCHANT, "Call Merchant",
0, 0, 0, 0, {fail_basis::invo}, abflag::gold|abflag::starve_ok },
{ ABIL_GOZAG_BRIBE_BRANCH, "Bribe Branch",
0, 0, 0, 0, {fail_basis::invo}, abflag::gold },
// Qazlal
{ ABIL_QAZLAL_UPHEAVAL, "Upheaval",
4, 0, 0, 3, {fail_basis::invo, 40, 5, 20}, abflag::none },
{ ABIL_QAZLAL_ELEMENTAL_FORCE, "Elemental Force",
6, 0, 0, 6, {fail_basis::invo, 60, 5, 20}, abflag::none },
{ ABIL_QAZLAL_DISASTER_AREA, "Disaster Area",
7, 0, 0, 10, {fail_basis::invo, 70, 4, 25}, abflag::none },
#if TAG_MAJOR_VERSION == 34
// Pakellas
{ ABIL_PAKELLAS_DEVICE_SURGE, "Device Surge",
0, 0, 0, generic_cost::fixed(1),
{fail_basis::invo, 40, 5, 20}, abflag::variable_mp | abflag::instant },
#endif
// Uskayaw
{ ABIL_USKAYAW_STOMP, "Stomp",
3, 0, 100, generic_cost::fixed(20), {fail_basis::invo}, abflag::none },
{ ABIL_USKAYAW_LINE_PASS, "Line Pass",
4, 0, 200, generic_cost::fixed(20), {fail_basis::invo}, abflag::none},
{ ABIL_USKAYAW_GRAND_FINALE, "Grand Finale",
8, 0, 500, generic_cost::fixed(0),
{fail_basis::invo, 120 + piety_breakpoint(4), 5, 1}, abflag::none},
// Hepliaklqana
{ ABIL_HEPLIAKLQANA_RECALL, "Recall Ancestor",
2, 0, 0, 0, {fail_basis::invo}, abflag::none },
{ ABIL_HEPLIAKLQANA_TRANSFERENCE, "Transference",
2, 0, 0, 3, {fail_basis::invo, 40, 5, 20},
abflag::none },
{ ABIL_HEPLIAKLQANA_IDEALISE, "Idealise",
4, 0, 0, 4, {fail_basis::invo, 60, 4, 25},
abflag::none },
{ ABIL_HEPLIAKLQANA_TYPE_KNIGHT, "Ancestor Life: Knight",
0, 0, 0, 0, {fail_basis::invo}, abflag::starve_ok },
{ ABIL_HEPLIAKLQANA_TYPE_BATTLEMAGE, "Ancestor Life: Battlemage",
0, 0, 0, 0, {fail_basis::invo}, abflag::starve_ok },
{ ABIL_HEPLIAKLQANA_TYPE_HEXER, "Ancestor Life: Hexer",
0, 0, 0, 0, {fail_basis::invo}, abflag::starve_ok },
{ ABIL_HEPLIAKLQANA_IDENTITY, "Ancestor Identity",
0, 0, 0, 0, {fail_basis::invo}, abflag::instant | abflag::starve_ok },
// Wu Jian
{ ABIL_WU_JIAN_SERPENTS_LASH, "Serpent's Lash",
0, 0, 0, 2, {fail_basis::invo}, abflag::exhaustion | abflag::instant },
{ ABIL_WU_JIAN_HEAVENLY_STORM, "Heavenly Storm",
0, 0, 0, 20, {fail_basis::invo, piety_breakpoint(5), 0, 1}, abflag::none },
// Lunge and Whirlwind abilities aren't menu abilities but currently need
// to exist for action counting, hence need enums/entries.
{ ABIL_WU_JIAN_LUNGE, "Lunge", 0, 0, 0, 0, {}, abflag::none },
{ ABIL_WU_JIAN_WHIRLWIND, "Whirlwind", 0, 0, 0, 0, {}, abflag::none },
{ ABIL_WU_JIAN_WALLJUMP, "Wall Jump", 0, 0, 0, 0, {}, abflag::starve_ok },
{ ABIL_STOP_RECALL, "Stop Recall", 0, 0, 0, 0, {fail_basis::invo}, abflag::starve_ok },
{ ABIL_RENOUNCE_RELIGION, "Renounce Religion",
0, 0, 0, 0, {fail_basis::invo}, abflag::starve_ok },
{ ABIL_CONVERT_TO_BEOGH, "Convert to Beogh",
0, 0, 0, 0, {fail_basis::invo}, abflag::starve_ok },
};
static const ability_def& get_ability_def(ability_type abil)
{
for (const ability_def &ab_def : Ability_List)
if (ab_def.ability == abil)
return ab_def;
return Ability_List[0];
}
unsigned int ability_mp_cost(ability_type abil)
{
return get_ability_def(abil).mp_cost;
}
/**
* Is there a valid ability with a name matching that given?
*
* @param key The name in question. (Not case sensitive.)
* @return true if such an ability exists; false if not.
*/
bool string_matches_ability_name(const string& key)
{
return ability_by_name(key) != ABIL_NON_ABILITY;
}
/**
* Find an ability whose name matches the given key.
*
* @param name The name in question. (Not case sensitive.)
* @return The enum of the relevant ability, if there was one; else
* ABIL_NON_ABILITY.
*/
ability_type ability_by_name(const string &key)
{
for (const auto &abil : Ability_List)
{
if (abil.ability == ABIL_NON_ABILITY)
continue;
const string name = lowercase_string(ability_name(abil.ability));
if (name == lowercase_string(key))
return abil.ability;
}
return ABIL_NON_ABILITY;
}
string print_abilities()
{
string text = "\n<w>a:</w> ";
const vector<talent> talents = your_talents(false);
if (talents.empty())
text += "no special abilities";
else
{
for (unsigned int i = 0; i < talents.size(); ++i)
{
if (i)
text += ", ";
text += ability_name(talents[i].which);
}
}
return text;
}
int get_gold_cost(ability_type ability)
{
switch (ability)
{
case ABIL_GOZAG_CALL_MERCHANT:
return gozag_price_for_shop(true);
case ABIL_GOZAG_POTION_PETITION:
return gozag_potion_price();
case ABIL_GOZAG_BRIBE_BRANCH:
return GOZAG_BRIBE_AMOUNT;
default:
return 0;
}
}
const string make_cost_description(ability_type ability)
{
const ability_def& abil = get_ability_def(ability);
string ret;
if (abil.mp_cost)
ret += make_stringf(", %d MP", abil.mp_cost);
if (abil.flags & abflag::variable_mp)
ret += ", MP";
if (ability == ABIL_HEAL_WOUNDS)
ret += ", Permanent MP";
if (abil.hp_cost)
ret += make_stringf(", %d HP", abil.hp_cost.cost(you.hp_max));
if (abil.food_cost && !you_foodless()
&& (you.undead_state() != US_SEMI_UNDEAD
|| you.hunger_state > HS_STARVING))
{
ret += ", Hunger"; // randomised and exact amount hidden from player
}
if (abil.piety_cost || abil.flags & abflag::piety)
ret += ", Piety"; // randomised and exact amount hidden from player
if (abil.flags & abflag::breath)
ret += ", Breath";
if (abil.flags & abflag::delay)
ret += ", Delay";
if (abil.flags & abflag::pain)
ret += ", Pain";
if (abil.flags & abflag::exhaustion)
ret += ", Exhaustion";
if (abil.flags & abflag::instant)
ret += ", Instant"; // not really a cost, more of a bonus - bwr
if (abil.flags & abflag::rations)
ret += ", 2 Rations per target";
if (abil.flags & abflag::rations_or_piety)
ret += ", Piety or 2 Rations";
if (abil.flags & abflag::skill_drain)
ret += ", Skill drain";
if (abil.flags & abflag::remove_curse_scroll)
ret += ", Scroll of remove curse";
if (abil.flags & abflag::gold)
{
const int amount = get_gold_cost(ability);
if (amount)
ret += make_stringf(", %d Gold", amount);
else if (ability == ABIL_GOZAG_POTION_PETITION)
ret += ", Free";
else
ret += ", Gold";
}
if (abil.flags & abflag::sacrifice)
{
ret += ", ";
const string prefix = "Sacrifice ";
ret += string(ability_name(ability)).substr(prefix.size());
ret += ru_sac_text(ability);
}
// If we haven't output anything so far, then the effect has no cost
if (ret.empty())
return "None";
ret.erase(0, 2);
return ret;
}
static string _get_piety_amount_str(int value)
{
return value > 15 ? "extremely large" :
value > 10 ? "large" :
value > 5 ? "moderate" :
"small";
}
static const string _detailed_cost_description(ability_type ability)
{
const ability_def& abil = get_ability_def(ability);
ostringstream ret;
bool have_cost = false;
ret << "This ability costs: ";
if (abil.mp_cost > 0)
{
have_cost = true;
ret << "\nMP : ";
ret << abil.mp_cost;
}
if (abil.hp_cost)
{
have_cost = true;
ret << "\nHP : ";
ret << abil.hp_cost.cost(you.hp_max);
}
if (abil.food_cost && !you_foodless()
&& (you.undead_state() != US_SEMI_UNDEAD
|| you.hunger_state > HS_STARVING))
{
have_cost = true;
ret << "\nHunger : ";
ret << hunger_cost_string(abil.food_cost + abil.food_cost / 2);
}
if (abil.piety_cost || abil.flags & abflag::piety)
{
have_cost = true;
ret << "\nPiety : ";
if (abil.flags & abflag::piety)
ret << "variable";
else
{
int avgcost = abil.piety_cost.base + abil.piety_cost.add / 2;
ret << _get_piety_amount_str(avgcost);
}
}
if (abil.flags & abflag::gold)
{
have_cost = true;
ret << "\nGold : ";
int gold_amount = get_gold_cost(ability);
if (gold_amount)
ret << gold_amount;
else if (ability == ABIL_GOZAG_POTION_PETITION)
ret << "free";
else
ret << "variable";
}
if (abil.flags & abflag::rations_or_piety)
ret << "\nPiety, or 2 rations";
if (abil.flags & abflag::rations)
ret << "\nRations: 2 per target";
if (abil.flags & abflag::remove_curse_scroll)
{
have_cost = true;
ret << "\nOne scroll of remove curse";
}
if (!have_cost)
ret << "nothing.";
if (abil.flags & abflag::breath)
ret << "\nYou must catch your breath between uses of this ability.";
if (abil.flags & abflag::delay)
ret << "\nIt takes some time before being effective.";
if (abil.flags & abflag::pain)
ret << "\nUsing this ability will hurt you.";
if (abil.flags & abflag::exhaustion)
ret << "\nIt causes exhaustion, and cannot be used when exhausted.";
if (abil.flags & abflag::instant)
ret << "\nIt is instantaneous.";
if (abil.flags & abflag::conf_ok)
ret << "\nYou can use it even if confused.";
if (abil.flags & abflag::skill_drain)
ret << "\nIt will temporarily drain your skills when used.";
if (abil.ability == ABIL_HEAL_WOUNDS)
{
ret << "\nIt has a chance of reducing your maximum magic capacity "
"when used.";
}
return ret.str();
}
ability_type fixup_ability(ability_type ability)
{
switch (ability)
{
case ABIL_YRED_ANIMATE_REMAINS:
// suppress animate remains once animate dead is unlocked (ugh)
if (in_good_standing(GOD_YREDELEMNUL, 2))
return ABIL_NON_ABILITY;
return ability;
case ABIL_YRED_RECALL_UNDEAD_SLAVES:
case ABIL_BEOGH_RECALL_ORCISH_FOLLOWERS:
if (!you.recall_list.empty())
return ABIL_STOP_RECALL;
return ability;
case ABIL_EVOKE_BERSERK:
case ABIL_TROG_BERSERK:
if (you.is_lifeless_undead(false)
|| you.species == SP_FORMICID)
{
return ABIL_NON_ABILITY;
}
return ability;
case ABIL_BLINK:
case ABIL_EVOKE_BLINK:
if (you.species == SP_FORMICID)
return ABIL_NON_ABILITY;
else
return ability;
case ABIL_LUGONU_ABYSS_EXIT:
case ABIL_LUGONU_ABYSS_ENTER:
if (brdepth[BRANCH_ABYSS] == -1)
return ABIL_NON_ABILITY;
else
return ability;
case ABIL_TSO_BLESS_WEAPON:
case ABIL_KIKU_BLESS_WEAPON:
case ABIL_LUGONU_BLESS_WEAPON:
if (you.species == SP_FELID)
return ABIL_NON_ABILITY;
else
return ability;
case ABIL_ELYVILON_HEAL_OTHER:
case ABIL_TSO_SUMMON_DIVINE_WARRIOR:
case ABIL_MAKHLEB_LESSER_SERVANT_OF_MAKHLEB:
case ABIL_MAKHLEB_GREATER_SERVANT_OF_MAKHLEB:
case ABIL_TROG_BROTHERS_IN_ARMS:
case ABIL_GOZAG_BRIBE_BRANCH:
case ABIL_QAZLAL_ELEMENTAL_FORCE:
if (you.get_mutation_level(MUT_NO_LOVE))
return ABIL_NON_ABILITY;
else
return ability;
case ABIL_SIF_MUNA_DIVINE_ENERGY:
if (you.attribute[ATTR_DIVINE_ENERGY])
return ABIL_SIF_MUNA_STOP_DIVINE_ENERGY;
return ability;
case ABIL_ASHENZARI_TRANSFER_KNOWLEDGE:
if (you.species == SP_GNOLL)
return ABIL_NON_ABILITY;
else
return ability;
default:
return ability;
}
}