/
god-passive.cc
1714 lines (1483 loc) · 51.1 KB
/
god-passive.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
#include "AppHdr.h"
#include "god-passive.h"
#include <algorithm>
#include <cmath>
#include "act-iter.h"
#include "areas.h"
#include "artefact.h"
#include "art-enum.h"
#include "branch.h"
#include "chardump.h"
#include "cloud.h"
#include "coordit.h"
#include "directn.h"
#include "env.h"
#include "fight.h"
#include "files.h"
#include "fprop.h"
#include "god-abil.h"
#include "god-prayer.h"
#include "invent.h" // in_inventory
#include "item-name.h"
#include "item-prop.h"
#include "item-status-flag-type.h"
#include "items.h"
#include "libutil.h"
#include "los.h"
#include "map-knowledge.h"
#include "melee-attack.h"
#include "message.h"
#include "mon-cast.h"
#include "mon-place.h"
#include "mon-util.h"
#include "output.h"
#include "player.h"
#include "religion.h"
#include "shout.h"
#include "skills.h"
#include "spl-clouds.h"
#include "state.h"
#include "stringutil.h"
#include "tag-version.h"
#include "terrain.h"
#include "throw.h"
#include "unwind.h"
// TODO: template out the differences between this and god_power.
// TODO: use the display method rather than dummy powers in god_powers.
// TODO: finish using these for implementing passive abilities.
struct god_passive
{
// 1-6 means it unlocks at that many stars of piety;
// 0 means it is always present when in good standing with the god;
// -1 means it is present even under penance;
int rank;
passive_t pasv;
/** Message to be given on gain of this passive.
*
* If the string begins with an uppercase letter, it is treated as
* a complete sentence. Otherwise, if it contains the substring " NOW ",
* the string "You " is prepended. Otherwise, the string "You NOW " is
* prepended to the message, with the " NOW " then being replaced.
*
* The substring "GOD" is replaced with the name of the god.
* The substring " NOW " is replaced with " now " for messages about
* gaining the ability, or " " for messages about having the ability.
*
* Examples:
* "have super powers"
* => "You have super powers", "You now have super powers."
* "are NOW powerful"
* => "You are powerful", "You are now powerful."
* "Your power is NOW great"
* => "Your power is great", "Your power is now great"
* "GOD NOW makes you powerful"
* => "Moloch makes you powerful", "Moloch now makes you powerful"
* "GOD grants you a boon"
* => "Moloch grants you a boon" (in all situations)
*
* FIXME: This member is currently unused.
*
* @see god_passive::loss.
*/
const char* gain;
/** Message to be given on loss of this passive.
*
* If empty, use the gain message. This makes sense only if the message
* contains " NOW ", either explicitly or implicitly through not
* beginning with a capital letter.
*
* The substring "GOD" is replaced with the name of the god.
* The substring " NOW " is replaced with " no longer ".
*
* Examples:
* "have super powers"
* => "You no longer have super powers"
* "are NOW powerful"
* => "You are no longer powerful"
* "Your power is NOW great"
* => "Your power is no longer great"
* "GOD NOW makes you powerful"
* => "Moloch no longer makes you powerful"
* "GOD grants you a boon"
* => "Moloch grants you a boon" (probably incorrect)
*
* FIXME: This member is currently unused.
*
* @see god_passive::gain.
*/
const char* loss;
god_passive(int rank_, passive_t pasv_, const char* gain_,
const char* loss_ = "")
: rank{rank_}, pasv{pasv_}, gain{gain_}, loss{*loss_ ? loss_ : gain_}
{ }
god_passive(int rank_, const char* gain_, const char* loss_ = "")
: god_passive(rank_, passive_t::none, gain_, loss_)
{ }
void display(bool gaining, const char* fmt) const
{
const char * const str = gaining ? gain : loss;
if (isupper(str[0]))
god_speaks(you.religion, str);
else
god_speaks(you.religion, make_stringf(fmt, str).c_str());
}
};
static const vector<god_passive> god_passives[] =
{
// no god
{ },
// Zin
{
{ -1, passive_t::protect_from_harm,
"GOD sometimes watches over you",
"GOD no longer watches over you"
},
{ -1, passive_t::resist_mutation,
"GOD can shield you from mutations",
"GOD NOW shields you from mutations"
},
{ -1, passive_t::resist_polymorph,
"GOD can protect you from unnatural transformations",
"GOD NOW protects you from unnatural transformations",
},
{ -1, passive_t::resist_hell_effects,
"GOD can protect you from effects of Hell",
"GOD NOW protects you from effects of Hell"
},
{ -1, passive_t::warn_shapeshifter,
"GOD will NOW warn you about shapeshifters"
},
{
6, passive_t::cleanse_mut_potions,
"GOD cleanses your potions of mutation",
"GOD no longer cleanses your potions of mutation",
}
},
// TSO
{
{ -1, passive_t::protect_from_harm,
"GOD sometimes watches over you",
"GOD no longer watches over you"
},
{ -1, passive_t::abjuration_protection_hd,
"GOD NOW protects your summons from abjuration" },
{ -1, passive_t::bless_followers_vs_evil,
"GOD NOW blesses your followers when they kill evil beings" },
{ -1, passive_t::restore_hp_mp_vs_evil,
"gain health and magic from killing evil beings" },
{ -1, passive_t::no_stabbing,
"are NOW prevented from stabbing unaware creatures" },
{ 0, passive_t::halo, "are NOW surrounded by divine halo" },
},
// Kikubaaqudgha
{
{ 2, passive_t::miscast_protection_necromancy,
"GOD NOW protects you from necromancy miscasts"
" and mummy death curses"
},
{ 4, passive_t::resist_torment,
"GOD NOW protects you from torment" },
},
// Yredelemnul
{
{ -1, passive_t::reaping, "can NOW harvest souls to fight along side you" },
{ -1, passive_t::nightvision, "can NOW see well in the dark" },
{ -1, passive_t::r_spectral_mist, "are NOW immune to spectral mist" },
},
// Xom
{ },
// Vehumet
{
{ -1, passive_t::mp_on_kill,
"have a chance to gain magical power from killing" },
{ 3, passive_t::spells_success,
"are NOW less likely to miscast destructive spells" },
{ 4, passive_t::spells_range,
"can NOW cast destructive spells farther" },
},
// Okawaru
{
{ -1, passive_t::no_allies,
"are NOW prevented from gaining allies" },
},
// Makhleb
{
{ -1, passive_t::restore_hp, "gain health from killing" },
},
// Sif Muna
{ },
// Trog
{
{ -1, passive_t::abjuration_protection,
"GOD NOW protects your allies from abjuration"
},
{ 0, passive_t::extend_berserk,
"GOD NOW extends your berserk rage on killing"
},
},
// Nemelex
{
// None
},
// Elyvilon
{
{ -1, passive_t::lifesaving,
"GOD carefully watches over you",
"GOD no longer watches over you"
},
{ -1, passive_t::protect_ally,
"GOD can protect the life of your allies",
"GOD NOW protects the life of your allies"
},
},
// Lugonu
{
{ -1, passive_t::safe_distortion,
"are NOW protected from distortion unwield effects" },
{ -1, passive_t::wrath_banishment,
"GOD will NOW banish foes whenever another god meddles" },
{ -1, passive_t::map_rot_res_abyss,
"remember the shape of the Abyss better" },
{ 5, passive_t::attract_abyssal_rune,
"GOD will NOW help you find the Abyssal rune" },
},
// Beogh
{
{ -1, passive_t::share_exp, "share experience with your followers" },
{ 3, passive_t::convert_orcs, "inspire orcs to join your side" },
{ 3, passive_t::bless_followers,
"GOD will bless your followers",
"GOD will no longer bless your followers"
},
{ 5, passive_t::water_walk, "walk on water" },
},
// Jiyva
{
{ -1, passive_t::neutral_slimes,
"Slimes and eye monsters are NOW neutral towards you" },
{ -1, passive_t::jellies_army,
"GOD NOW summons slimes to protect you" },
{ -1, passive_t::jelly_eating,
"GOD NOW allows slimes to devour items" },
{ 0, passive_t::slime_wall_immune,
"are NOW immune to slime covered walls" },
{ 1, passive_t::jelly_regen,
"GOD NOW accelerates your HP and MP regeneration" },
{ 2, passive_t::resist_corrosion,
"GOD NOW protects you from corrosion" },
{ 5, passive_t::spawn_slimes_on_hit,
"spawn slimes when struck by massive blows" },
{ 6, passive_t::unlock_slime_vaults,
"GOD NOW grants you access to the hidden treasures"
" of the Slime Pits"
},
},
// Fedhas
{
{ -1, passive_t::pass_through_plants,
"can NOW walk through plants" },
{ -1, passive_t::shoot_through_plants,
"can NOW safely fire through allied plants" },
{ 0, passive_t::friendly_plants,
"Allied plants are NOW friendly towards you" },
},
// Cheibriados
{
{ -1, passive_t::no_haste,
"are NOW protected from inadvertent hurry" },
{ -1, passive_t::slowed, "move less quickly" },
{ 0, passive_t::slow_orb_run,
"GOD will NOW aid your escape with the Orb of Zot",
},
{ 0, passive_t::stat_boost,
"GOD NOW supports your attributes"
},
{ 0, passive_t::slow_abyss,
"GOD will NOW slow the Abyss"
},
// TODO: this one should work regardless of penance, maybe?
{ 0, passive_t::slow_zot,
"GOD will NOW slow Zot's hunt for you"
},
{ 0, passive_t::slow_poison, "process poison slowly" },
},
// Ashenzari
{
{ -1, passive_t::want_curses, "prefer cursed items" },
{ 0, passive_t::detect_portals, "sense portals" },
{ 0, passive_t::auto_map, "have improved mapping abilities" },
{ 0, passive_t::detect_montier, "sense threats" },
{ 0, passive_t::detect_items, "sense items" },
{ 0, passive_t::bondage_skill_boost,
"get a skill boost from cursed items" },
{ 1, passive_t::identify_items, "sense the properties of items" },
{ 2, passive_t::sinv, "are NOW clear of vision" },
{ 3, passive_t::clarity, "are NOW clear of mind" },
{ 4, passive_t::avoid_traps, "avoid traps" },
},
// Dithmenos
{
{ 1, passive_t::nightvision, "can NOW see well in the dark" },
{ 1, passive_t::umbra, "are NOW surrounded by an umbra" },
// TODO: this one should work regardless of penance.
{ 3, passive_t::hit_smoke, "emit smoke when hit" },
{ 4, passive_t::shadow_attacks,
"Your attacks are NOW mimicked by a shadow" },
{ 4, passive_t::shadow_spells,
"Your attack spells are NOW mimicked by a shadow" },
},
// Gozag
{
{ -1, passive_t::detect_gold, "detect gold" },
{ 0, passive_t::goldify_corpses,
"GOD NOW turns all corpses to gold" },
{ 0, passive_t::gold_aura, "have a gold aura" },
},
// Qazlal
{
{ 0, passive_t::cloud_immunity, "and your divine allies are ADV immune to clouds" },
{ 1, passive_t::storm_shield,
"generate elemental clouds to protect yourself" },
{ 4, passive_t::upgraded_storm_shield,
"Your chances to be struck by projectiles are NOW reduced" },
{ 5, passive_t::elemental_adaptation,
"Elemental attacks NOW leave you somewhat more resistant"
" to them"
}
},
// Ru
{
{ 1, passive_t::aura_of_power,
"Your enemies will sometimes fail their attack or even hit themselves",
"Your enemies will NOW fail their attack or hit themselves"
},
{ 2, passive_t::upgraded_aura_of_power,
"Enemies that inflict damage upon you will sometimes receive"
" a detrimental status effect",
"Enemies that inflict damage upon you will NOW receive"
" a detrimental status effect"
},
},
#if TAG_MAJOR_VERSION == 34
// Pakellas
{ },
#endif
// Uskayaw
{ },
// Hepliaklqana
{
{ 1, passive_t::frail,
"GOD NOW siphons a part of your essence into your ancestor" },
{ 5, passive_t::transfer_drain,
"drain nearby creatures when transferring your ancestor" },
},
// Wu Jian
{
{ 0, passive_t::wu_jian_lunge, "perform damaging attacks by moving towards foes." },
{ 1, passive_t::wu_jian_whirlwind, "lightly attack monsters by moving around them." },
{ 2, passive_t::wu_jian_wall_jump, "perform airborne attacks in an area by jumping off a solid obstacle." },
},
// Ignis
{
{ 0, passive_t::resist_fire, "resist fire." },
}, // TODO
};
COMPILE_CHECK(ARRAYSZ(god_passives) == NUM_GODS);
static bool _god_gives_passive_if(god_type god, passive_t passive,
function<bool(const god_passive&)> condition)
{
const auto &pasvec = god_passives[god];
return any_of(begin(pasvec), end(pasvec),
[&] (const god_passive &p) -> bool
{ return p.pasv == passive && condition(p); });
}
bool god_gives_passive(god_type god, passive_t passive)
{
return _god_gives_passive_if(god, passive,
[] (god_passive /*p*/) { return true; });
}
bool have_passive(passive_t passive)
{
return _god_gives_passive_if(you.religion, passive,
[] (god_passive p)
{
return piety_rank() >= p.rank
&& (!player_under_penance()
|| p.rank < 0);
});
}
bool will_have_passive(passive_t passive)
{
return _god_gives_passive_if(you.religion, passive,
[] (god_passive/*p*/) { return true; });
}
// Returns a large number (10) if we will never get this passive.
int rank_for_passive(passive_t passive)
{
const auto &pasvec = god_passives[you.religion];
const auto found = find_if(begin(pasvec), end(pasvec),
[passive] (const god_passive &p) -> bool
{
return p.pasv == passive;
});
return found == end(pasvec) ? 10 : found->rank;
}
int chei_stat_boost(int piety)
{
if (!have_passive(passive_t::stat_boost))
return 0;
if (piety < piety_breakpoint(0)) // Since you've already begun to slow down.
return 1;
if (piety >= piety_breakpoint(5))
return 15;
return (piety - 10) / 10;
}
// Eat from one random off-level item stack.
void jiyva_eat_offlevel_items()
{
// For wizard mode 'J' command
if (!have_passive(passive_t::jelly_eating))
return;
if (crawl_state.game_is_sprint())
return;
while (true)
{
if (one_chance_in(200))
break;
const int branch = random2(NUM_BRANCHES);
// Choose level based on main dungeon depth so that levels of
// short branches aren't picked more often.
ASSERT(brdepth[branch] <= MAX_BRANCH_DEPTH);
const int level = random2(MAX_BRANCH_DEPTH) + 1;
const level_id lid(static_cast<branch_type>(branch), level);
if (lid == level_id::current() || !you.level_visited(lid))
continue;
dprf("Checking %s", lid.describe().c_str());
level_excursion le;
le.go_to(lid);
while (true)
{
if (one_chance_in(200))
break;
const coord_def p = random_in_bounds();
if (env.igrid(p) == NON_ITEM || testbits(env.pgrid(p), FPROP_NO_JIYVA))
continue;
for (stack_iterator si(p); si; ++si)
{
if (!item_is_jelly_edible(*si) || one_chance_in(4))
continue;
if (one_chance_in(4))
break;
dprf("Eating %s on %s",
si->name(DESC_PLAIN).c_str(), lid.describe().c_str());
mpr("You hear a distant slurping noise.");
item_was_destroyed(*si);
destroy_item(si.index());
}
return;
}
}
}
static bool _two_handed()
{
const item_def* wpn = you.slot_item(EQ_WEAPON, true);
if (!wpn)
return false;
hands_reqd_type wep_type = you.hands_reqd(*wpn, true);
return wep_type == HANDS_TWO;
}
static void _curse_boost_skills(const item_def &item)
{
if (!item.props.exists(CURSE_KNOWLEDGE_KEY))
return;
for (auto& curse : item.props[CURSE_KNOWLEDGE_KEY].get_vector())
{
for (skill_type sk : curse_skills(curse))
{
if (you.skill_boost.count(sk))
you.skill_boost[sk]++;
else
you.skill_boost[sk] = 1;
}
}
}
// Checks bondage and sets ash piety
void ash_check_bondage()
{
if (!will_have_passive(passive_t::bondage_skill_boost))
return;
#if TAG_MAJOR_VERSION == 34
// Save compatibility for the new ash tag minor forgot to do this
initialize_ashenzari_props();
#endif
int num_cursed = 0, num_slots = 0;
you.skill_boost.clear();
for (int j = EQ_FIRST_EQUIP; j < NUM_EQUIP; j++)
{
const equipment_type i = static_cast<equipment_type>(j);
// handles missing hand, octopode ring slots, finger necklace, species
// armour restrictions, etc. Finger necklace slot counts.
if (!you_can_wear(i))
continue;
// transformed away slots are still considered to be possibly bound
num_slots++;
if (you.equip[i] != -1)
{
const item_def& item = you.inv[you.equip[i]];
if (item.cursed() && (i != EQ_WEAPON || is_weapon(item)))
{
if (i == EQ_WEAPON && _two_handed())
num_cursed += 2;
else
{
num_cursed++;
if (i == EQ_BODY_ARMOUR
&& is_unrandom_artefact(item, UNRAND_LEAR))
{
num_cursed += 3;
}
}
if (!item_is_melded(item))
_curse_boost_skills(item);
}
}
}
set_piety(ASHENZARI_BASE_PIETY
+ (num_cursed * ASHENZARI_PIETY_SCALE) / num_slots);
calc_hp(true);
calc_mp(true);
}
// XXX: If this is called on an item in inventory, then auto_assign_item_slot
// needs to be called subsequently. However, moving an item in inventory
// invalidates its reference, which is a different behavior than for floor
// items, so we don't do it in this function.
bool god_id_item(item_def& item, bool silent)
{
iflags_t old_ided = item.flags & ISFLAG_IDENT_MASK;
if (have_passive(passive_t::identify_items))
{
// Don't identify runes or the orb, since this has no gameplay purpose
// and might mess up other things.
if (item.base_type == OBJ_RUNES || item_is_orb(item))
return false;
if ((item.base_type == OBJ_JEWELLERY || item.base_type == OBJ_STAVES)
&& item_needs_autopickup(item))
{
item.props[NEEDS_AUTOPICKUP_KEY] = true;
}
set_ident_type(item, true);
set_ident_flags(item, ISFLAG_IDENT_MASK);
}
iflags_t ided = item.flags & ISFLAG_IDENT_MASK;
if (ided & ~old_ided)
{
if (item.props.exists(NEEDS_AUTOPICKUP_KEY) && is_useless_item(item))
item.props.erase(NEEDS_AUTOPICKUP_KEY);
if (&item == you.weapon())
you.wield_change = true;
if (!silent)
mprf_nocap("%s", item.name(DESC_INVENTORY_EQUIP).c_str());
seen_item(item);
return true;
}
// nothing new
return false;
}
static bool is_ash_portal(dungeon_feature_type feat)
{
if (feat_is_portal_entrance(feat))
return true;
switch (feat)
{
case DNGN_ENTER_HELL:
case DNGN_EXIT_DIS:
case DNGN_EXIT_GEHENNA:
case DNGN_EXIT_COCYTUS:
case DNGN_EXIT_TARTARUS:
case DNGN_ENTER_ABYSS: // for completeness
case DNGN_EXIT_THROUGH_ABYSS:
case DNGN_EXIT_ABYSS:
case DNGN_ENTER_PANDEMONIUM:
case DNGN_EXIT_PANDEMONIUM:
// DNGN_TRANSIT_PANDEMONIUM is too mundane
return true;
default:
return false;
}
}
// Yay for rectangle_iterator and radius_iterator not sharing a base type
static bool _check_portal(coord_def where)
{
const dungeon_feature_type feat = env.grid(where);
if (feat != env.map_knowledge(where).feat() && is_ash_portal(feat))
{
env.map_knowledge(where).set_feature(feat);
set_terrain_mapped(where);
if (!testbits(env.pgrid(where), FPROP_SEEN_OR_NOEXP))
{
env.pgrid(where) |= FPROP_SEEN_OR_NOEXP;
if (!you.see_cell(where))
return true;
}
}
return false;
}
int ash_detect_portals(bool all)
{
if (!have_passive(passive_t::detect_portals))
return 0;
int portals_found = 0;
const int map_radius = LOS_DEFAULT_RANGE + 1;
if (all)
{
for (rectangle_iterator ri(0); ri; ++ri)
{
if (_check_portal(*ri))
portals_found++;
}
}
else
{
for (radius_iterator ri(you.pos(), map_radius, C_SQUARE); ri; ++ri)
{
if (_check_portal(*ri))
portals_found++;
}
}
you.seen_portals += portals_found;
return portals_found;
}
monster_type ash_monster_tier(const monster *mon)
{
return monster_type(MONS_SENSED_TRIVIAL + monster_info(mon).threat);
}
/**
* Does the player have an ash skill boost for a particular skill?
*/
bool ash_has_skill_boost(skill_type sk)
{
return have_passive(passive_t::bondage_skill_boost)
&& you.skill_boost.count(sk) && you.skill_boost.find(sk)->second;
}
/**
* Calculate the ash skill point boost for skill sk.
*
* @param scaled_skill the skill level to calculate it for, scaled by 10.
*
* @return the skill point bonus to use.
*/
unsigned int ash_skill_point_boost(skill_type sk, int scaled_skill)
{
unsigned int skill_points = 0;
const int scale = 10;
const int skill_boost = scale * (you.skill_boost[sk] * 4 + 3) / 3;
skill_points += skill_boost * (piety_rank() + 1) * max(scaled_skill, 1)
* species_apt_factor(sk) / scale;
return skill_points;
}
int ash_skill_boost(skill_type sk, int scale)
{
// It gives a bonus to skill points. The formula is:
// ( curses * 4 / 3 + 1 ) * (piety_rank + 1) * skill_level
unsigned int skill_points = you.skill_points[sk]
+ get_crosstrain_points(sk)
+ ash_skill_point_boost(sk, you.skill(sk, 10, true));
int level = you.skills[sk];
while (level < MAX_SKILL_LEVEL && skill_points >= skill_exp_needed(level + 1, sk))
++level;
level = level * scale + get_skill_progress(sk, level, skill_points, scale);
return min(level, MAX_SKILL_LEVEL * scale);
}
void gozag_detect_level_gold(bool count)
{
ASSERT(you.on_current_level);
vector<item_def *> gold_piles;
vector<coord_def> gold_places;
int gold = 0;
for (rectangle_iterator ri(0); ri; ++ri)
{
for (stack_iterator j(*ri); j; ++j)
{
if (j->base_type == OBJ_GOLD && !(j->flags & ISFLAG_UNOBTAINABLE))
{
gold += j->quantity;
gold_piles.push_back(&(*j));
gold_places.push_back(*ri);
}
}
}
if (!player_in_branch(BRANCH_ABYSS) && count)
you.attribute[ATTR_GOLD_GENERATED] += gold;
if (have_passive(passive_t::detect_gold))
{
for (unsigned int i = 0; i < gold_places.size(); i++)
{
int dummy = gold_piles[i]->index();
coord_def &pos = gold_places[i];
unlink_item(dummy);
move_item_to_grid(&dummy, pos, true);
if ((!env.map_knowledge(pos).item()
|| env.map_knowledge(pos).item()->base_type != OBJ_GOLD
&& you.visible_igrd(pos) != NON_ITEM))
{
env.map_knowledge(pos).set_item(
get_item_known_info(*gold_piles[i]),
!!env.map_knowledge(pos).item());
env.map_knowledge(pos).flags |= MAP_DETECTED_ITEM;
#ifdef USE_TILE
// force an update for gold generated during Abyss shifts
tiles.update_minimap(pos);
#endif
}
}
}
}
int qazlal_sh_boost(int piety)
{
if (!have_passive(passive_t::storm_shield))
return 0;
return min(piety, piety_breakpoint(5)) / 10;
}
// Not actually passive, but placing it here so that it can be easily compared
// with Qazlal's boost.
int tso_sh_boost()
{
if (!you.duration[DUR_DIVINE_SHIELD])
return 0;
return you.attribute[ATTR_DIVINE_SHIELD];
}
void qazlal_storm_clouds()
{
if (!have_passive(passive_t::storm_shield))
return;
// You are a *storm*. You are pretty loud!
noisy(min((int)you.piety, piety_breakpoint(5)) / 10, you.pos());
const int radius = you.piety >= piety_breakpoint(3) ? 2 : 1;
vector<coord_def> candidates;
for (radius_iterator ri(you.pos(), radius, C_SQUARE, LOS_SOLID, true);
ri; ++ri)
{
int count = 0;
if (cell_is_solid(*ri) || cloud_at(*ri))
continue;
// Don't create clouds over firewood
const monster * mon = monster_at(*ri);
if (mon != nullptr && mons_is_firewood(*mon))
continue;
// No clouds in corridors.
for (adjacent_iterator ai(*ri); ai; ++ai)
if (!cell_is_solid(*ai))
count++;
if (count >= 5)
candidates.push_back(*ri);
}
const int count =
div_rand_round(min((int)you.piety, piety_breakpoint(5))
* candidates.size() * you.time_taken,
piety_breakpoint(5) * 7 * BASELINE_DELAY);
if (count < 0)
return;
shuffle_array(candidates);
int placed = 0;
for (unsigned int i = 0; placed < count && i < candidates.size(); i++)
{
bool water = false;
for (adjacent_iterator ai(candidates[i]); ai; ++ai)
{
if (feat_is_watery(env.grid(*ai)))
water = true;
}
// No flame clouds over water to avoid steam generation.
cloud_type ctype;
do
{
ctype = random_choose(CLOUD_FIRE, CLOUD_COLD, CLOUD_STORM,
CLOUD_DUST);
} while (water && ctype == CLOUD_FIRE);
place_cloud(ctype, candidates[i], random_range(3, 5), &you);
placed++;
}
}
/**
* Handle Qazlal's elemental adaptation.
* This should be called (exactly once) for physical, fire, cold, and electrical damage.
* Right now, it is called only from expose_player_to_element. This may merit refactoring.
*
* @param flavour the beam type.
* @param strength The adaptations will trigger strength in (11 - piety_rank()) times. In practice, this is mostly called with a value of 2.
*/
void qazlal_element_adapt(beam_type flavour, int strength)
{
if (strength <= 0
|| !have_passive(passive_t::elemental_adaptation)
|| !x_chance_in_y(strength, 11 - piety_rank()))
{
return;
}
beam_type what = BEAM_NONE;
duration_type dur = NUM_DURATIONS;
string descript = "";
switch (flavour)
{
case BEAM_FIRE:
case BEAM_LAVA:
case BEAM_STICKY_FLAME:
case BEAM_STEAM:
what = BEAM_FIRE;
dur = DUR_QAZLAL_FIRE_RES;
descript = "fire";
break;
case BEAM_COLD:
case BEAM_ICE:
what = BEAM_COLD;
dur = DUR_QAZLAL_COLD_RES;
descript = "cold";
break;
case BEAM_ELECTRICITY:
case BEAM_THUNDER:
what = BEAM_ELECTRICITY;
dur = DUR_QAZLAL_ELEC_RES;
descript = "electricity";
break;
case BEAM_MMISSILE: // for LCS, iron shot
case BEAM_MISSILE:
case BEAM_FRAG:
what = BEAM_MISSILE;
dur = DUR_QAZLAL_AC;
descript = "physical attacks";
break;
default:
return;
}
if (what != BEAM_FIRE && you.duration[DUR_QAZLAL_FIRE_RES])
{
mprf(MSGCH_DURATION, "Your resistance to fire fades away.");
you.duration[DUR_QAZLAL_FIRE_RES] = 0;
}
if (what != BEAM_COLD && you.duration[DUR_QAZLAL_COLD_RES])
{
mprf(MSGCH_DURATION, "Your resistance to cold fades away.");
you.duration[DUR_QAZLAL_COLD_RES] = 0;
}
if (what != BEAM_ELECTRICITY && you.duration[DUR_QAZLAL_ELEC_RES])
{
mprf(MSGCH_DURATION, "Your resistance to electricity fades away.");
you.duration[DUR_QAZLAL_ELEC_RES] = 0;
}
if (what != BEAM_MISSILE && you.duration[DUR_QAZLAL_AC])
{
mprf(MSGCH_DURATION, "Your resistance to physical damage fades away.");
you.duration[DUR_QAZLAL_AC] = 0;
you.redraw_armour_class = true;
}
mprf(MSGCH_GOD, "You feel %sprotected from %s.",
you.duration[dur] > 0 ? "more " : "", descript.c_str());
// was scaled by 10 * strength. But the strength parameter is used so inconsistently that
// it seems like a constant would be better, based on the typical value of 2.
you.increase_duration(dur, 20, 80);
if (what == BEAM_MISSILE)
you.redraw_armour_class = true;
}
/**