-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
ability.cc
4034 lines (3534 loc) · 125 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 "branch.h"
#include "butcher.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 "food.h"
#include "godabil.h"
#include "godconduct.h"
#include "godprayer.h"
#include "hints.h"
#include "items.h"
#include "item_use.h"
#include "libutil.h"
#include "macro.h"
#include "maps.h"
#include "menu.h"
#include "message.h"
#include "misc.h"
#include "mon-place.h"
#include "mutation.h"
#include "notes.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 "stringutil.h"
#include "target.h"
#include "terrain.h"
#include "tilepick.h"
#include "transform.h"
#include "traps.h"
#include "uncancel.h"
#include "unicode.h"
#include "zotdef.h"
enum ability_flag_type
{
ABFLAG_NONE = 0x00000000,
ABFLAG_BREATH = 0x00000001, // ability uses DUR_BREATH_WEAPON
ABFLAG_DELAY = 0x00000002, // ability has its own delay
ABFLAG_PAIN = 0x00000004, // ability must hurt player (ie torment)
ABFLAG_PIETY = 0x00000008, // ability has its own piety cost
ABFLAG_EXHAUSTION = 0x00000010, // fails if you.exhausted
ABFLAG_INSTANT = 0x00000020, // doesn't take time to use
ABFLAG_PERMANENT_HP = 0x00000040, // costs permanent HPs
ABFLAG_PERMANENT_MP = 0x00000080, // costs permanent MPs
ABFLAG_CONF_OK = 0x00000100, // can use even if confused
ABFLAG_FRUIT = 0x00000200, // ability requires fruit
ABFLAG_VARIABLE_FRUIT = 0x00000400, // ability requires fruit or piety
//0x00000800,
//0x00001000,
ABFLAG_NECRO_MISCAST_MINOR = 0x00002000, // severity 2 necro miscast
//0x00004000,
//0x00008000,
ABFLAG_LEVEL_DRAIN = 0x00010000, // drains 2 levels
ABFLAG_STAT_DRAIN = 0x00020000, // stat drain
ABFLAG_ZOTDEF = 0x00040000, // ZotDef ability, w/ appropriate hotkey
ABFLAG_SKILL_DRAIN = 0x00080000, // drains skill levels
ABFLAG_GOLD = 0x00100000, // costs gold
ABFLAG_SACRIFICE = 0x00200000, // sacrifice (Ru)
};
static int _find_ability_slot(const ability_def& abil);
static spret_type _do_ability(const ability_def& abil, bool fail);
static void _pay_ability_costs(const ability_def& abil, int zpcost);
static int _scale_piety_cost(ability_type abil, int original_cost);
static string _zd_mons_description_for_ability(const ability_def &abil);
static monster_type _monster_for_ability(const ability_def& abil);
/**
* This all needs to be split into data/util/show files
* and the struct mechanism here needs to be rewritten (again)
* along with the display routine to piece the strings
* together dynamically ... I'm getting to it now {dlb}
*
* This array corresponds with ::god_gain_power_messages and
* ::god_lose_power_messages, which have the same shape.
*
* It makes more sense to think of them as an array
* of structs than two arrays that share common index
* values -- well, doesn't it? {dlb}
*
* @note Declaring this const messes up externs later, so don't do it!
*/
ability_type god_abilities[NUM_GODS][MAX_GOD_ABILITIES] =
{
// no god
{ ABIL_NON_ABILITY, ABIL_NON_ABILITY, ABIL_NON_ABILITY, ABIL_NON_ABILITY,
ABIL_NON_ABILITY },
// Zin
{ ABIL_ZIN_RECITE, ABIL_ZIN_VITALISATION, ABIL_ZIN_IMPRISON,
ABIL_NON_ABILITY, ABIL_ZIN_SANCTUARY },
// TSO
{ ABIL_NON_ABILITY, ABIL_TSO_DIVINE_SHIELD, ABIL_NON_ABILITY,
ABIL_TSO_CLEANSING_FLAME, ABIL_TSO_SUMMON_DIVINE_WARRIOR },
// Kikubaaqudgha
{ ABIL_KIKU_RECEIVE_CORPSES, ABIL_NON_ABILITY, ABIL_NON_ABILITY,
ABIL_NON_ABILITY, ABIL_KIKU_TORMENT },
// Yredelemnul
{ ABIL_YRED_ANIMATE_REMAINS_OR_DEAD, ABIL_YRED_RECALL_UNDEAD_SLAVES,
ABIL_NON_ABILITY, ABIL_YRED_DRAIN_LIFE, ABIL_YRED_ENSLAVE_SOUL },
// Xom
{ ABIL_NON_ABILITY, ABIL_NON_ABILITY, ABIL_NON_ABILITY, ABIL_NON_ABILITY,
ABIL_NON_ABILITY },
// Vehumet
{ ABIL_NON_ABILITY, ABIL_NON_ABILITY, ABIL_NON_ABILITY, ABIL_NON_ABILITY,
ABIL_NON_ABILITY },
// Okawaru
{ ABIL_OKAWARU_HEROISM, ABIL_NON_ABILITY, ABIL_NON_ABILITY,
ABIL_NON_ABILITY, ABIL_OKAWARU_FINESSE },
// Makhleb
{ ABIL_NON_ABILITY, ABIL_MAKHLEB_MINOR_DESTRUCTION,
ABIL_MAKHLEB_LESSER_SERVANT_OF_MAKHLEB, ABIL_MAKHLEB_MAJOR_DESTRUCTION,
ABIL_MAKHLEB_GREATER_SERVANT_OF_MAKHLEB },
// Sif Muna
{ ABIL_SIF_MUNA_CHANNEL_ENERGY, ABIL_SIF_MUNA_FORGET_SPELL,
ABIL_NON_ABILITY, ABIL_NON_ABILITY, ABIL_NON_ABILITY },
// Trog
{ ABIL_TROG_BERSERK, ABIL_TROG_REGEN_MR, ABIL_NON_ABILITY,
ABIL_TROG_BROTHERS_IN_ARMS, ABIL_NON_ABILITY },
// Nemelex
{ ABIL_NON_ABILITY, ABIL_NON_ABILITY, ABIL_NEMELEX_TRIPLE_DRAW,
ABIL_NEMELEX_DEAL_FOUR, ABIL_NEMELEX_STACK_FIVE },
// Elyvilon
{ ABIL_ELYVILON_LESSER_HEALING, ABIL_ELYVILON_HEAL_OTHER,
ABIL_ELYVILON_PURIFICATION, ABIL_ELYVILON_GREATER_HEALING,
ABIL_ELYVILON_DIVINE_VIGOUR },
// Lugonu
{ ABIL_LUGONU_ABYSS_EXIT, ABIL_LUGONU_BEND_SPACE, ABIL_LUGONU_BANISH,
ABIL_LUGONU_CORRUPT, ABIL_LUGONU_ABYSS_ENTER },
// Beogh
{ ABIL_NON_ABILITY, ABIL_BEOGH_SMITING, ABIL_NON_ABILITY,
ABIL_BEOGH_RECALL_ORCISH_FOLLOWERS, ABIL_BEOGH_GIFT_ITEM },
// Jiyva
{ ABIL_JIYVA_CALL_JELLY, ABIL_JIYVA_JELLY_PARALYSE, ABIL_NON_ABILITY,
ABIL_JIYVA_SLIMIFY, ABIL_JIYVA_CURE_BAD_MUTATION },
// Fedhas
{ ABIL_FEDHAS_EVOLUTION, ABIL_FEDHAS_SUNLIGHT, ABIL_FEDHAS_PLANT_RING,
ABIL_FEDHAS_SPAWN_SPORES, ABIL_FEDHAS_RAIN},
// Cheibriados
{ ABIL_NON_ABILITY, ABIL_NON_ABILITY, ABIL_CHEIBRIADOS_DISTORTION,
ABIL_CHEIBRIADOS_SLOUCH, ABIL_CHEIBRIADOS_TIME_STEP },
// Ashenzari
{ ABIL_NON_ABILITY, ABIL_NON_ABILITY, ABIL_NON_ABILITY,
ABIL_ASHENZARI_SCRYING, ABIL_ASHENZARI_TRANSFER_KNOWLEDGE },
// Dithmenos
{ ABIL_NON_ABILITY, ABIL_DITHMENOS_SHADOW_STEP, ABIL_NON_ABILITY,
ABIL_NON_ABILITY, ABIL_DITHMENOS_SHADOW_FORM },
// Gozag
{ ABIL_GOZAG_POTION_PETITION, ABIL_GOZAG_CALL_MERCHANT,
ABIL_GOZAG_BRIBE_BRANCH, ABIL_NON_ABILITY, ABIL_NON_ABILITY },
// Qazlal
{ ABIL_NON_ABILITY, ABIL_QAZLAL_UPHEAVAL, ABIL_QAZLAL_ELEMENTAL_FORCE,
ABIL_NON_ABILITY, ABIL_QAZLAL_DISASTER_AREA },
// Ru
{ ABIL_NON_ABILITY, ABIL_NON_ABILITY, ABIL_RU_DRAW_OUT_POWER,
ABIL_RU_POWER_LEAP, ABIL_RU_APOCALYPSE }
};
// The description screen was way out of date with the actual costs.
// This table puts all the information in one place... -- bwr
//
// The five numerical fields are: MP, HP, food, piety and ZP.
// 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, 0, ABFLAG_NONE},
{ ABIL_SPIT_POISON, "Spit Poison", 0, 0, 40, 0, 0, ABFLAG_BREATH},
{ ABIL_BLINK, "Blink", 0, 50, 50, 0, 0, ABFLAG_NONE},
{ ABIL_BREATHE_FIRE, "Breathe Fire", 0, 0, 125, 0, 0, ABFLAG_BREATH},
{ ABIL_BREATHE_FROST, "Breathe Frost", 0, 0, 125, 0, 0, ABFLAG_BREATH},
{ ABIL_BREATHE_POISON, "Breathe Poison Gas",
0, 0, 125, 0, 0, ABFLAG_BREATH},
{ ABIL_BREATHE_MEPHITIC, "Breathe Noxious Fumes",
0, 0, 125, 0, 0, ABFLAG_BREATH},
{ ABIL_BREATHE_LIGHTNING, "Breathe Lightning",
0, 0, 125, 0, 0, ABFLAG_BREATH},
{ ABIL_BREATHE_POWER, "Breathe Dispelling Energy", 0, 0, 125, 0, 0, ABFLAG_BREATH},
{ ABIL_BREATHE_STICKY_FLAME, "Breathe Sticky Flame",
0, 0, 125, 0, 0, ABFLAG_BREATH},
{ ABIL_BREATHE_STEAM, "Breathe Steam", 0, 0, 75, 0, 0, ABFLAG_BREATH},
{ ABIL_TRAN_BAT, "Bat Form", 2, 0, 0, 0, 0, ABFLAG_NONE},
{ ABIL_SPIT_ACID, "Spit Acid", 0, 0, 125, 0, 0, ABFLAG_BREATH},
{ ABIL_FLY, "Fly", 3, 0, 100, 0, 0, ABFLAG_NONE},
{ ABIL_STOP_FLYING, "Stop Flying", 0, 0, 0, 0, 0, ABFLAG_NONE},
{ ABIL_HELLFIRE, "Hellfire", 0, 150, 200, 0, 0, ABFLAG_NONE},
{ ABIL_DELAYED_FIREBALL, "Release Delayed Fireball",
0, 0, 0, 0, 0, ABFLAG_INSTANT},
{ ABIL_STOP_SINGING, "Stop Singing",
0, 0, 0, 0, 0, ABFLAG_NONE},
{ ABIL_MUMMY_RESTORATION, "Self-Restoration",
1, 0, 0, 0, 0, ABFLAG_PERMANENT_MP},
{ ABIL_DIG, "Dig", 0, 0, 0, 0, 0, ABFLAG_INSTANT},
{ ABIL_SHAFT_SELF, "Shaft Self", 0, 0, 250, 0, 0, ABFLAG_DELAY},
// 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_TELEPORTATION, "Evoke Teleportation",
3, 0, 200, 0, 0, ABFLAG_NONE},
{ ABIL_EVOKE_BLINK, "Evoke Blink", 1, 0, 50, 0, 0, ABFLAG_NONE},
{ ABIL_RECHARGING, "Device Recharging", 1, 0, 0, 0, 0, ABFLAG_PERMANENT_MP},
{ ABIL_EVOKE_BERSERK, "Evoke Berserk Rage", 0, 0, 0, 0, 0, ABFLAG_NONE},
{ ABIL_EVOKE_TURN_INVISIBLE, "Evoke Invisibility",
2, 0, 250, 0, 0, ABFLAG_NONE},
{ ABIL_EVOKE_TURN_VISIBLE, "Turn Visible", 0, 0, 0, 0, 0, ABFLAG_NONE},
{ ABIL_EVOKE_FLIGHT, "Evoke Flight", 1, 0, 100, 0, 0, ABFLAG_NONE},
{ ABIL_EVOKE_FOG, "Evoke Fog", 2, 0, 250, 0, 0, ABFLAG_NONE},
{ ABIL_EVOKE_TELEPORT_CONTROL, "Evoke Teleport Control", 4, 0, 200, 0, 0, ABFLAG_NONE},
{ ABIL_EVOKE_TWISTER, "Evoke Twister", 10, 0, 200, 0, 0, ABFLAG_NONE},
{ ABIL_END_TRANSFORMATION, "End Transformation", 0, 0, 0, 0, 0, ABFLAG_NONE},
// INVOCATIONS:
// Zin
{ ABIL_ZIN_RECITE, "Recite", 0, 0, 0, 0, 0, ABFLAG_BREATH},
{ ABIL_ZIN_VITALISATION, "Vitalisation", 0, 0, 0, 1, 0, ABFLAG_NONE},
{ ABIL_ZIN_IMPRISON, "Imprison", 5, 0, 125, 4, 0, ABFLAG_NONE},
{ ABIL_ZIN_SANCTUARY, "Sanctuary", 7, 0, 150, 15, 0, ABFLAG_NONE},
{ ABIL_ZIN_CURE_ALL_MUTATIONS, "Cure All Mutations",
0, 0, 0, 0, 0, ABFLAG_NONE},
// The Shining One
{ ABIL_TSO_DIVINE_SHIELD, "Divine Shield", 3, 0, 50, 2, 0, ABFLAG_NONE},
{ ABIL_TSO_CLEANSING_FLAME, "Cleansing Flame",
5, 0, 100, 2, 0, ABFLAG_NONE},
{ ABIL_TSO_SUMMON_DIVINE_WARRIOR, "Summon Divine Warrior",
8, 0, 150, 6, 0, ABFLAG_NONE},
// Kikubaaqudgha
{ ABIL_KIKU_RECEIVE_CORPSES, "Receive Corpses",
3, 0, 50, 2, 0, ABFLAG_NONE},
{ ABIL_KIKU_TORMENT, "Torment", 4, 0, 0, 8, 0, ABFLAG_NONE},
// Yredelemnul
{ ABIL_YRED_INJURY_MIRROR, "Injury Mirror", 0, 0, 0, 0, 0, ABFLAG_PIETY},
{ ABIL_YRED_ANIMATE_REMAINS, "Animate Remains",
2, 0, 50, 0, 0, ABFLAG_NONE},
{ ABIL_YRED_RECALL_UNDEAD_SLAVES, "Recall Undead Slaves",
2, 0, 50, 0, 0, ABFLAG_NONE},
{ ABIL_YRED_ANIMATE_DEAD, "Animate Dead", 2, 0, 50, 0, 0, ABFLAG_NONE},
{ ABIL_YRED_DRAIN_LIFE, "Drain Life", 6, 0, 200, 2, 0, ABFLAG_NONE},
{ ABIL_YRED_ENSLAVE_SOUL, "Enslave Soul", 8, 0, 150, 4, 0, ABFLAG_NONE},
// Placeholder for Animate Remains or Animate Dead.
{ ABIL_YRED_ANIMATE_REMAINS_OR_DEAD, "Animate Remains or Dead",
2, 0, 100, 0, 0, ABFLAG_NONE},
// Okawaru
{ ABIL_OKAWARU_HEROISM, "Heroism", 2, 0, 50, 2, 0, ABFLAG_NONE},
{ ABIL_OKAWARU_FINESSE, "Finesse", 5, 0, 100, 4, 0, ABFLAG_NONE},
// Makhleb
{ ABIL_MAKHLEB_MINOR_DESTRUCTION, "Minor Destruction",
0, scaling_cost::fixed(1), 20, 0, 0, ABFLAG_NONE},
{ ABIL_MAKHLEB_LESSER_SERVANT_OF_MAKHLEB, "Lesser Servant of Makhleb",
0, scaling_cost::fixed(4), 50, 2, 0, ABFLAG_NONE},
{ ABIL_MAKHLEB_MAJOR_DESTRUCTION, "Major Destruction",
0, scaling_cost::fixed(6), 100, generic_cost::range(0, 1), 0, ABFLAG_NONE},
{ ABIL_MAKHLEB_GREATER_SERVANT_OF_MAKHLEB, "Greater Servant of Makhleb",
0, scaling_cost::fixed(10), 100, 5, 0, ABFLAG_NONE},
// Sif Muna
{ ABIL_SIF_MUNA_CHANNEL_ENERGY, "Channel Energy",
0, 0, 100, 0, 0, ABFLAG_NONE},
{ ABIL_SIF_MUNA_FORGET_SPELL, "Forget Spell", 5, 0, 0, 8, 0, ABFLAG_NONE},
// Trog
{ ABIL_TROG_BURN_SPELLBOOKS, "Burn Spellbooks",
0, 0, 10, 0, 0, ABFLAG_NONE},
{ ABIL_TROG_BERSERK, "Berserk", 0, 0, 200, 0, 0, ABFLAG_NONE},
{ ABIL_TROG_REGEN_MR, "Trog's Hand",
0, 0, 50, generic_cost::range(2, 3), 0, ABFLAG_NONE},
{ ABIL_TROG_BROTHERS_IN_ARMS, "Brothers in Arms",
0, 0, 100, generic_cost::range(5, 6), 0, ABFLAG_NONE},
// Elyvilon
{ ABIL_ELYVILON_LIFESAVING, "Divine Protection",
0, 0, 0, 0, 0, ABFLAG_NONE},
{ ABIL_ELYVILON_LESSER_HEALING, "Lesser Healing",
1, 0, 100, generic_cost::range(0, 1), 0, ABFLAG_CONF_OK},
{ ABIL_ELYVILON_HEAL_OTHER, "Heal Other",
2, 0, 250, 2, 0, ABFLAG_NONE},
{ ABIL_ELYVILON_PURIFICATION, "Purification", 3, 0, 300, 3, 0,
ABFLAG_CONF_OK},
{ ABIL_ELYVILON_GREATER_HEALING, "Greater Healing",
2, 0, 250, 3, 0, ABFLAG_CONF_OK},
{ ABIL_ELYVILON_DIVINE_VIGOUR, "Divine Vigour", 0, 0, 600, 6, 0,
ABFLAG_CONF_OK},
// Lugonu
{ ABIL_LUGONU_ABYSS_EXIT, "Depart the Abyss",
1, 0, 150, 10, 0, ABFLAG_NONE},
{ ABIL_LUGONU_BEND_SPACE, "Bend Space", 1, 0, 50, 0, 0, ABFLAG_PAIN},
{ ABIL_LUGONU_BANISH, "Banish",
4, 0, 200, generic_cost::range(3, 4), 0, ABFLAG_NONE},
{ ABIL_LUGONU_CORRUPT, "Corrupt",
7, scaling_cost::fixed(5), 500, generic_cost::range(10, 14), 0, ABFLAG_NONE},
{ ABIL_LUGONU_ABYSS_ENTER, "Enter the Abyss",
9, 0, 500, generic_cost::fixed(35), 0, ABFLAG_PAIN},
// Nemelex
{ ABIL_NEMELEX_TRIPLE_DRAW, "Triple Draw", 2, 0, 100, 2, 0, ABFLAG_NONE},
{ ABIL_NEMELEX_DEAL_FOUR, "Deal Four", 8, 0, 200, 8, 0, ABFLAG_NONE},
{ ABIL_NEMELEX_STACK_FIVE, "Stack Five", 5, 0, 250, 10, 0, ABFLAG_NONE},
// Beogh
{ ABIL_BEOGH_SMITING, "Smiting",
3, 0, 80, generic_cost::fixed(3), 0, ABFLAG_NONE},
{ ABIL_BEOGH_RECALL_ORCISH_FOLLOWERS, "Recall Orcish Followers",
2, 0, 50, 0, 0, ABFLAG_NONE},
{ ABIL_BEOGH_GIFT_ITEM, "Give Item to Named Follower",
0, 0, 0, 0, 0, ABFLAG_NONE},
// Jiyva
{ ABIL_JIYVA_CALL_JELLY, "Request Jelly", 2, 0, 20, 1, 0, ABFLAG_NONE},
{ ABIL_JIYVA_JELLY_PARALYSE, "Jelly Paralyse", 0, 0, 0, 0, 0, ABFLAG_PIETY},
{ ABIL_JIYVA_SLIMIFY, "Slimify", 4, 0, 100, 8, 0, ABFLAG_NONE},
{ ABIL_JIYVA_CURE_BAD_MUTATION, "Cure Bad Mutation",
8, 0, 200, 15, 0, ABFLAG_NONE},
// Fedhas
{ ABIL_FEDHAS_EVOLUTION, "Evolution", 2, 0, 0, 0, 0, ABFLAG_VARIABLE_FRUIT},
{ ABIL_FEDHAS_SUNLIGHT, "Sunlight", 2, 0, 50, 0, 0, ABFLAG_NONE},
{ ABIL_FEDHAS_PLANT_RING, "Growth", 2, 0, 0, 0, 0, ABFLAG_FRUIT},
{ ABIL_FEDHAS_SPAWN_SPORES, "Reproduction", 4, 0, 100, 1, 0, ABFLAG_NONE},
{ ABIL_FEDHAS_RAIN, "Rain", 4, 0, 150, 4, 0, ABFLAG_NONE},
// Cheibriados
{ ABIL_CHEIBRIADOS_TIME_BEND, "Bend Time", 3, 0, 50, 1, 0, ABFLAG_NONE},
{ ABIL_CHEIBRIADOS_DISTORTION, "Temporal Distortion",
4, 0, 200, 3, 0, ABFLAG_INSTANT},
{ ABIL_CHEIBRIADOS_SLOUCH, "Slouch", 5, 0, 100, 8, 0, ABFLAG_NONE},
{ ABIL_CHEIBRIADOS_TIME_STEP, "Step From Time",
10, 0, 200, 10, 0, ABFLAG_NONE},
// Ashenzari
{ ABIL_ASHENZARI_SCRYING, "Scrying",
4, 0, 50, generic_cost::range(2, 3), 0, ABFLAG_INSTANT},
{ ABIL_ASHENZARI_TRANSFER_KNOWLEDGE, "Transfer Knowledge",
0, 0, 0, 20, 0, ABFLAG_NONE},
{ ABIL_ASHENZARI_END_TRANSFER, "End Transfer Knowledge",
0, 0, 0, 0, 0, ABFLAG_NONE},
// Dithmenos
{ ABIL_DITHMENOS_SHADOW_STEP, "Shadow Step",
4, 0, 0, 4, 0, ABFLAG_NONE },
{ ABIL_DITHMENOS_SHADOW_FORM, "Shadow Form",
9, 0, 0, 10, 0, ABFLAG_SKILL_DRAIN },
// Ru
{ ABIL_RU_DRAW_OUT_POWER, "Draw Out Power",
0, 0, 0, 0, 0, ABFLAG_EXHAUSTION|ABFLAG_SKILL_DRAIN|ABFLAG_CONF_OK },
{ ABIL_RU_POWER_LEAP, "Power Leap",
5, 0, 0, 0, 0, ABFLAG_EXHAUSTION },
{ ABIL_RU_APOCALYPSE, "Apocalypse",
8, 0, 0, 0, 0, ABFLAG_EXHAUSTION|ABFLAG_SKILL_DRAIN },
{ ABIL_RU_SACRIFICE_PURITY, "Sacrifice Purity",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_WORDS, "Sacrifice Words",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_DRINK, "Sacrifice Drink",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_ESSENCE, "Sacrifice Essence",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_HEALTH, "Sacrifice Health",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_STEALTH, "Sacrifice Stealth",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_ARTIFICE, "Sacrifice Artifice",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_LOVE, "Sacrifice Love",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_COURAGE, "Sacrifice Courage",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_ARCANA, "Sacrifice Arcana",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_NIMBLENESS, "Sacrifice Nimbleness",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_DURABILITY, "Sacrifice Durability",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_HAND, "Sacrifice a Hand",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_EXPERIENCE, "Sacrifice Experience",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_SACRIFICE_SKILL, "Sacrifice Skill",
0, 0, 0, 0, 0, ABFLAG_SACRIFICE },
{ ABIL_RU_REJECT_SACRIFICES, "Reject Sacrifices",
0, 0, 0, 0, 0, ABFLAG_NONE },
// Gozag
{ ABIL_GOZAG_POTION_PETITION, "Potion Petition",
0, 0, 0, 0, 0, ABFLAG_GOLD },
{ ABIL_GOZAG_CALL_MERCHANT, "Call Merchant",
0, 0, 0, 0, 0, ABFLAG_GOLD },
{ ABIL_GOZAG_BRIBE_BRANCH, "Bribe Branch",
0, 0, 0, 0, 0, ABFLAG_GOLD },
// Qazlal
{ ABIL_QAZLAL_UPHEAVAL, "Upheaval", 4, 0, 0, 3, 0, ABFLAG_NONE },
{ ABIL_QAZLAL_ELEMENTAL_FORCE, "Elemental Force",
6, 0, 0, 6, 0, ABFLAG_NONE },
{ ABIL_QAZLAL_DISASTER_AREA, "Disaster Area", 7, 0, 0,
generic_cost::range(10, 14), 0, ABFLAG_NONE },
{ ABIL_STOP_RECALL, "Stop Recall", 0, 0, 0, 0, 0, ABFLAG_NONE},
// zot defence abilities
{ ABIL_MAKE_FUNGUS, "Make mushroom circle", 0, 0, 0, 0, 10, ABFLAG_ZOTDEF},
{ ABIL_MAKE_PLANT, "Make plant", 0, 0, 0, 0, 2, ABFLAG_ZOTDEF},
{ ABIL_MAKE_OKLOB_SAPLING, "Make oklob sapling", 0, 0, 0, 0, 60, ABFLAG_ZOTDEF},
{ ABIL_MAKE_BURNING_BUSH, "Make burning bush", 0, 0, 0, 0, 200, ABFLAG_ZOTDEF},
{ ABIL_MAKE_OKLOB_PLANT, "Make oklob plant", 0, 0, 0, 0, 250, ABFLAG_ZOTDEF},
{ ABIL_MAKE_ICE_STATUE, "Make ice statue", 0, 0, 0, 0, 2000, ABFLAG_ZOTDEF},
{ ABIL_MAKE_OCS, "Make crystal statue", 0, 0, 0, 0, 2000, ABFLAG_ZOTDEF},
{ ABIL_MAKE_OBSIDIAN_STATUE, "Make obsidian statue", 0, 0, 0, 0, 3000, ABFLAG_ZOTDEF},
{ ABIL_MAKE_CURSE_SKULL, "Make curse skull",
0, 0, 600, 0, 10000, ABFLAG_ZOTDEF|ABFLAG_NECRO_MISCAST_MINOR},
{ ABIL_MAKE_TELEPORT, "Zot-teleport", 0, 0, 0, 0, 2, ABFLAG_ZOTDEF},
{ ABIL_MAKE_ARROW_TRAP, "Make arrow trap", 0, 0, 0, 0, 30, ABFLAG_ZOTDEF},
{ ABIL_MAKE_BOLT_TRAP, "Make bolt trap", 0, 0, 0, 0, 300, ABFLAG_ZOTDEF},
{ ABIL_MAKE_SPEAR_TRAP, "Make spear trap", 0, 0, 0, 0, 50, ABFLAG_ZOTDEF},
{ ABIL_MAKE_NEEDLE_TRAP, "Make needle trap", 0, 0, 0, 0, 30, ABFLAG_ZOTDEF},
{ ABIL_MAKE_NET_TRAP, "Make net trap", 0, 0, 0, 0, 2, ABFLAG_ZOTDEF},
{ ABIL_MAKE_ALARM_TRAP, "Make alarm trap", 0, 0, 0, 0, 2, ABFLAG_ZOTDEF},
{ ABIL_MAKE_BLADE_TRAP, "Make blade trap", 0, 0, 0, 0, 3000, ABFLAG_ZOTDEF},
{ ABIL_MAKE_OKLOB_CIRCLE, "Make oklob circle", 0, 0, 0, 0, 1000, ABFLAG_ZOTDEF},
{ ABIL_MAKE_ACQUIRE_GOLD, "Acquire gold",
0, 0, 0, 0, 0, ABFLAG_ZOTDEF|ABFLAG_LEVEL_DRAIN},
{ ABIL_MAKE_ACQUIREMENT, "Acquirement",
0, 0, 0, 0, 0, ABFLAG_ZOTDEF|ABFLAG_LEVEL_DRAIN},
{ ABIL_MAKE_WATER, "Make water", 0, 0, 0, 0, 10, ABFLAG_ZOTDEF},
{ ABIL_MAKE_LIGHTNING_SPIRE, "Make lightning spire", 0, 0, 0, 0, 100, ABFLAG_ZOTDEF},
{ ABIL_MAKE_BAZAAR, "Make bazaar",
0, 30, 0, 0, 100, ABFLAG_ZOTDEF|ABFLAG_PERMANENT_HP},
{ ABIL_MAKE_ALTAR, "Make altar", 0, 0, 0, 0, 50, ABFLAG_ZOTDEF},
{ ABIL_MAKE_GRENADES, "Make grenades", 0, 0, 0, 0, 2, ABFLAG_ZOTDEF},
{ ABIL_REMOVE_CURSE, "Remove Curse",
0, 0, 0, 0, 0, ABFLAG_ZOTDEF|ABFLAG_STAT_DRAIN},
{ ABIL_RENOUNCE_RELIGION, "Renounce Religion", 0, 0, 0, 0, 0, ABFLAG_NONE},
{ ABIL_CONVERT_TO_BEOGH, "Convert to Beogh", 0, 0, 0, 0, 0, ABFLAG_NONE},
};
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];
}
/**
* 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;
// don't display zot abilties outside zotdef
if ((abil.flags & ABFLAG_ZOTDEF) && !crawl_state.game_is_zotdef())
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;
}
static monster_type _monster_for_ability(const ability_def& abil)
{
monster_type mtyp = MONS_PROGRAM_BUG;
switch (abil.ability)
{
case ABIL_MAKE_PLANT: mtyp = MONS_PLANT; break;
case ABIL_MAKE_FUNGUS: mtyp = MONS_FUNGUS; break;
case ABIL_MAKE_OKLOB_SAPLING: mtyp = MONS_OKLOB_SAPLING; break;
case ABIL_MAKE_OKLOB_CIRCLE:
case ABIL_MAKE_OKLOB_PLANT: mtyp = MONS_OKLOB_PLANT; break;
case ABIL_MAKE_BURNING_BUSH: mtyp = MONS_BURNING_BUSH; break;
case ABIL_MAKE_LIGHTNING_SPIRE: mtyp = MONS_LIGHTNING_SPIRE; break;
case ABIL_MAKE_ICE_STATUE: mtyp = MONS_ICE_STATUE; break;
case ABIL_MAKE_OCS: mtyp = MONS_ORANGE_STATUE; break;
case ABIL_MAKE_OBSIDIAN_STATUE: mtyp = MONS_OBSIDIAN_STATUE; break;
case ABIL_MAKE_CURSE_SKULL: mtyp = MONS_CURSE_SKULL; break;
default:
mprf("DEBUG: NO RELEVANT MONSTER FOR %d", abil.ability);
break;
}
return mtyp;
}
static string _zd_mons_description_for_ability(const ability_def &abil)
{
switch (abil.ability)
{
case ABIL_MAKE_PLANT:
return "Tendrils and shoots erupt from the earth and gnarl into the form of a plant.";
case ABIL_MAKE_OKLOB_SAPLING:
return "A rhizome shoots up through the ground and merges with vitriolic spirits in the atmosphere.";
case ABIL_MAKE_OKLOB_PLANT:
return "A rhizome shoots up through the ground and merges with vitriolic spirits in the atmosphere.";
case ABIL_MAKE_BURNING_BUSH:
return "Blackened shoots writhe from the ground and burst into flame!";
case ABIL_MAKE_ICE_STATUE:
return "Water vapor collects and crystallises into an icy humanoid shape.";
case ABIL_MAKE_OCS:
return "Quartz juts from the ground and forms a humanoid shape. You smell citrus.";
case ABIL_MAKE_OBSIDIAN_STATUE:
return "Molten obsidian falls from the ceiling and solidifies into a vaguely humanoid shape.";
case ABIL_MAKE_CURSE_SKULL:
return "You sculpt a terrible being from the primitive principle of evil.";
case ABIL_MAKE_LIGHTNING_SPIRE:
return "You mount a charged rod inside a coil.";
default:
return "";
}
}
static int _count_relevant_monsters(const ability_def& abil)
{
monster_type mtyp = _monster_for_ability(abil);
if (mtyp == MONS_PROGRAM_BUG)
return 0;
return count_monsters(mtyp, true); // Friendly ones only
}
static trap_type _trap_for_ability(const ability_def& abil)
{
switch (abil.ability)
{
case ABIL_MAKE_ARROW_TRAP: return TRAP_ARROW;
case ABIL_MAKE_BOLT_TRAP: return TRAP_BOLT;
case ABIL_MAKE_SPEAR_TRAP: return TRAP_SPEAR;
case ABIL_MAKE_NEEDLE_TRAP: return TRAP_NEEDLE;
case ABIL_MAKE_NET_TRAP: return TRAP_NET;
case ABIL_MAKE_ALARM_TRAP: return TRAP_ALARM;
case ABIL_MAKE_BLADE_TRAP: return TRAP_BLADE;
default: return TRAP_UNASSIGNED;
}
}
// Scale the zp cost by the number of friendly monsters
// of that type. Each successive critter costs 20% more
// than the last one, after the first two.
static int _zp_cost(const ability_def& abil)
{
int cost = abil.zp_cost;
int scale10 = 0; // number of times to scale up by 10%
int scale20 = 0; // number of times to scale up by 20%
int num;
switch (abil.ability)
{
default:
return abil.zp_cost;
// Monster type 1: reasonably generous
case ABIL_MAKE_PLANT:
case ABIL_MAKE_FUNGUS:
case ABIL_MAKE_OKLOB_SAPLING:
case ABIL_MAKE_OKLOB_PLANT:
case ABIL_MAKE_OKLOB_CIRCLE:
case ABIL_MAKE_BURNING_BUSH:
case ABIL_MAKE_LIGHTNING_SPIRE:
num = _count_relevant_monsters(abil);
// special case for oklob circles
if (abil.ability == ABIL_MAKE_OKLOB_CIRCLE)
num /= 3;
// ... and for harmless stuff
else if (abil.ability == ABIL_MAKE_PLANT
|| abil.ability == ABIL_MAKE_FUNGUS)
{
num /= 5;
}
num -= 2; // first two are base cost
num = max(num, 0);
scale10 = min(num, 10); // next 10 at 10% increment
scale20 = num - scale10; // after that at 20% increment
break;
// Monster type 2: less generous
case ABIL_MAKE_ICE_STATUE:
case ABIL_MAKE_OCS:
num = _count_relevant_monsters(abil);
num -= 2; // first two are base cost
scale20 = max(num, 0); // after first two, 20% increment
break;
// Monster type 3: least generous
case ABIL_MAKE_OBSIDIAN_STATUE:
case ABIL_MAKE_CURSE_SKULL:
scale20 = _count_relevant_monsters(abil); // scale immediately
break;
// Simple Traps
case ABIL_MAKE_ARROW_TRAP:
case ABIL_MAKE_BOLT_TRAP:
case ABIL_MAKE_SPEAR_TRAP:
case ABIL_MAKE_NEEDLE_TRAP:
case ABIL_MAKE_NET_TRAP:
case ABIL_MAKE_ALARM_TRAP:
num = count_traps(_trap_for_ability(abil));
scale10 = max(num-5, 0); // First 5 at base cost
break;
case ABIL_MAKE_BLADE_TRAP:
scale10 = count_traps(TRAP_BLADE); // Max of 18-ish at base cost 3000
break;
}
float c = cost; // stave off round-off errors
for (; scale10 > 0; scale10--)
c = c * 1.1; // +10%
for (; scale20 > 0; scale20--)
c = c * 1.2; // +20%
return c;
}
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 %sMP", abil.mp_cost,
abil.flags & ABFLAG_PERMANENT_MP ? "Permanent " : "");
}
if (abil.hp_cost)
{
ret += make_stringf(", %d %sHP", abil.hp_cost.cost(you.hp_max),
abil.flags & ABFLAG_PERMANENT_HP ? "Permanent " : "");
}
if (abil.zp_cost)
ret += make_stringf(", %d ZP", (int)_zp_cost(abil));
if (abil.food_cost && !you_foodless(true)
&& (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_FRUIT)
ret += ", Fruit";
if (abil.flags & ABFLAG_VARIABLE_FRUIT)
ret += ", Fruit or Piety";
if (abil.flags & ABFLAG_LEVEL_DRAIN)
ret += ", Level drain";
if (abil.flags & ABFLAG_STAT_DRAIN)
ret += ", Stat drain";
if (abil.flags & ABFLAG_SKILL_DRAIN)
ret += ", Skill drain";
if (abil.flags & ABFLAG_GOLD)
{
const int amount = get_gold_cost(ability);
if (amount)
ret += make_stringf(", %d Gold", amount);
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;
vector<string> values;
string str;
bool have_cost = false;
ret << "This ability costs: ";
if (abil.mp_cost > 0)
{
have_cost = true;
if (abil.flags & ABFLAG_PERMANENT_MP)
ret << "\nMax MP : ";
else
ret << "\nMP : ";
ret << abil.mp_cost;
}
if (abil.hp_cost)
{
have_cost = true;
if (abil.flags & ABFLAG_PERMANENT_HP)
ret << "\nMax HP : ";
else
ret << "\nHP : ";
ret << abil.hp_cost.cost(you.hp_max);
}
if (abil.zp_cost)
{
have_cost = true;
ret << "\nZP : ";
ret << abil.zp_cost;
}
if (abil.food_cost && !you_foodless(true)
&& (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
ret << "variable";
}
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 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_LEVEL_DRAIN)
ret << "\nIt will lower your experience level by one when used.";
if (abil.flags & ABFLAG_STAT_DRAIN)
ret << "\nIt will temporarily drain your strength, intelligence or dexterity when used.";
if (abil.flags & ABFLAG_SKILL_DRAIN)
ret << "\nIt will temporarily drain your skills when used.";
return ret.str();
}
static ability_type _fixup_ability(ability_type ability)
{
switch (ability)
{
case ABIL_YRED_ANIMATE_REMAINS_OR_DEAD:
// Placeholder for Animate Remains or Animate Dead.
if (yred_can_animate_dead())
return ABIL_YRED_ANIMATE_DEAD;
else
return ABIL_YRED_ANIMATE_REMAINS;
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:
switch (you.species)
{
#if TAG_MAJOR_VERSION == 34
case SP_DJINNI:
#endif
case SP_GHOUL:
case SP_MUMMY:
case SP_FORMICID:
return ABIL_NON_ABILITY;
default:
return ability;
}
case ABIL_OKAWARU_FINESSE:
case ABIL_BLINK:
case ABIL_EVOKE_BLINK:
if (you.species == SP_FORMICID)
return ABIL_NON_ABILITY;
else
return ability;
default:
return ability;
}
}
talent get_talent(ability_type ability, bool check_confused)
{
ASSERT(ability != ABIL_NON_ABILITY);
talent result;
// Placeholder handling, part 1: The ability we have might be a
// placeholder, so convert it into its corresponding ability before
// doing anything else, so that we'll handle its flags properly.
result.which = _fixup_ability(ability);
const ability_def &abil = get_ability_def(result.which);
int failure = 0;
bool invoc = false;
if (check_confused)
{
if (you.confused() && !testbits(abil.flags, ABFLAG_CONF_OK))
{
// Initialize these so compilers don't complain.
result.is_invocation = 0;
result.is_zotdef = 0;
result.hotkey = 0;
result.fail = 0;
result.which = ABIL_NON_ABILITY;
return result;
}
}
// Look through the table to see if there's a preference, else find