/
art-func.h
1821 lines (1525 loc) · 55.9 KB
/
art-func.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
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 non-standard unrandarts uses.
**/
#pragma once
/*
* util/art-data.pl scans through this file to grab the functions
* non-standard unrandarts use and put them into the unranddata structs
* in art-data.h, so the function names must have the form of
* _UNRAND_ENUM_func_name() in order to be recognised.
*/
#ifdef ART_FUNC_H
#error "art-func.h included twice!"
#endif
#ifdef ART_DATA_H
#error "art-func.h must be included before art-data.h"
#endif
#define ART_FUNC_H
#include "act-iter.h" // For autumn katana
#include "areas.h" // For silenced() and invalidate_agrid()
#include "attack.h" // For attack_strength_punctuation()
#include "beam.h" // For Lajatang of Order's silver damage
#include "bloodspatter.h" // For Leech
#include "cloud.h" // For robe of clouds' thunder and salamander's flame
#include "coordit.h" // For distance_iterator()
#include "death-curse.h" // For the Scythe of Curses
#include "english.h" // For apostrophise
#include "exercise.h" // For practise_evoking
#include "fight.h"
#include "fineff.h" // For the Storm Queen's Shield
#include "god-conduct.h" // did_god_conduct
#include "mgen-data.h" // For Sceptre of Asmodeus
#include "melee-attack.h" // For autumn katana
#include "message.h"
#include "monster.h"
#include "mon-death.h" // For demon axe's SAME_ATTITUDE
#include "mon-place.h" // For Sceptre of Asmodeus
#include "nearby-danger.h" // For Zhor
#include "output.h"
#include "player.h"
#include "player-reacts.h" // For the consecrated labrys
#include "player-stats.h"
#include "showsymb.h" // For Cigotuvi's Embrace
#include "spl-cast.h" // For evokes
#include "spl-damage.h" // For the Singing Sword.
#include "spl-goditem.h" // For Sceptre of Torment tormenting
#include "spl-miscast.h" // For Spellbinder and plutonium sword miscasts
#include "spl-monench.h" // For Zhor's aura
#include "spl-summoning.h" // For Zonguldrok animating dead
#include "tag-version.h"
#include "terrain.h" // For storm bow
#include "unwind.h" // For autumn katana
#include "view.h" // For arc blade's discharge effect
// prop recording whether the singing sword has said hello yet
#define SS_WELCOME_KEY "ss_welcome"
// similarly, for the majin-bo
#define MB_WELCOME_KEY "mb_welcome"
/*******************
* Helper functions.
*******************/
static void _equip_mpr(bool* show_msgs, const char* msg,
msg_channel_type chan = MSGCH_PLAIN)
{
bool do_show = true;
if (show_msgs == nullptr)
show_msgs = &do_show;
if (*show_msgs)
mprf(chan, "%s", msg);
// Caller shouldn't give any more messages.
*show_msgs = false;
}
/*******************
* Unrand functions.
*******************/
////////////////////////////////////////////////////
static void _CEREBOV_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* defender, bool mondied, int dam)
{
if (dam)
{
if (defender->is_player()
&& defender->res_fire() <= 3
&& !you.duration[DUR_FIRE_VULN])
{
mpr("The sword of Cerebov burns away your fire resistance.");
you.increase_duration(DUR_FIRE_VULN, 3 + random2(dam), 50);
}
if (defender->is_monster()
&& !mondied
&& !defender->as_monster()->has_ench(ENCH_FIRE_VULN))
{
if (you.can_see(*attacker))
{
mprf("The sword of Cerebov burns away %s fire resistance.",
defender->name(DESC_ITS).c_str());
}
defender->as_monster()->add_ench(
mon_enchant(ENCH_FIRE_VULN, 1, attacker,
(3 + random2(dam)) * BASELINE_DELAY));
}
}
}
////////////////////////////////////////////////////
static void _CONDEMNATION_equip(item_def */*item*/, bool *show_msgs, bool unmeld)
{
if (!unmeld && you.species == SP_BARACHI)
_equip_mpr(show_msgs, "You feel a strange sense of familiarity.");
}
static void _CONDEMNATION_unequip(item_def */*item*/, bool *show_msgs)
{
if (you.species == SP_BARACHI)
_equip_mpr(show_msgs, "You feel oddly sad, like being parted from an old friend.");
}
static void _CONDEMNATION_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* defender, bool mondied, int dam)
{
if (!dam || mondied || defender->is_player())
return;
monster *mons = defender->as_monster();
if (mons_intel(*mons) <= I_BRAINLESS)
return;
const int dur = random_range(40, 80);
const bool was_guilty = mons->has_ench(ENCH_ANGUISH);
if (mons->add_ench(mon_enchant(ENCH_ANGUISH, 0, attacker, dur)) && !was_guilty)
simple_monster_message(*mons, " is haunted by guilt!");
}
////////////////////////////////////////////////////
static void _CURSES_equip(item_def */*item*/, bool *show_msgs, bool unmeld)
{
_equip_mpr(show_msgs, "A shiver runs down your spine.");
if (!unmeld)
death_curse(you, nullptr, "the scythe of Curses", 0);
}
static void _CURSES_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* defender, bool mondied, int dam)
{
if (attacker->is_player())
did_god_conduct(DID_EVIL, 3);
if (!mondied && defender->holiness() & (MH_NATURAL | MH_PLANT))
death_curse(*defender, attacker, "the scythe of Curses", min(dam, 27));
}
////////////////////////////////////////////////////
static void _FINISHER_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* defender, bool mondied, int dam)
{
// Can't kill a monster that's already dead.
// Can't kill a monster if we don't do damage.
// Don't insta-kill the player
if (mondied || dam == 0 || defender->is_player())
return;
// Chance to insta-kill based on HD. From 1/4 for small HD popcorn down to
// 1/10 for an Orb of Fire (compare to the 3/20 chance for banish or
// instant teleport on distortion).
if (x_chance_in_y(50 - defender->get_hit_dice(), 200))
{
monster* mons = defender->as_monster();
mons->flags |= MF_EXPLODE_KILL;
mons->hurt(attacker, INSTANT_DEATH);
}
}
////////////////////////////////////////////////////
static void _THROATCUTTER_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* defender, bool mondied, int /*dam*/)
{
// Can't kill a monster that's already dead.
// Don't insta-kill the player
if (mondied || defender->is_player())
return;
// Chance to insta-kill based on HP.
// (Effectively extra AC-ignoring damage, sort of.)
if (defender->stat_hp() <= 20 && one_chance_in(3))
{
monster* mons = defender->as_monster();
if (you.can_see(*attacker))
{
const bool plural = attacker->is_monster();
switch (get_mon_shape(mons_genus(mons->type)))
{
case MON_SHAPE_PLANT:
case MON_SHAPE_ORB:
case MON_SHAPE_BLOB:
case MON_SHAPE_MISC:
mprf("%s put%s %s out of %s misery!",
attacker->name(DESC_THE).c_str(),
plural ? "s" : "",
mons->name(DESC_THE).c_str(),
mons->pronoun(PRONOUN_POSSESSIVE).c_str());
break;
default: // yes, even fungi have heads :)
mprf("%s behead%s %s%s!",
attacker->name(DESC_THE).c_str(),
plural ? "s" : "",
mons->name(DESC_THE).c_str(),
mons->heads() > 1 ? " thoroughly" : "");
}
}
if (mons->num_heads > 1)
mons->num_heads = 1; // mass chop those hydra heads
mons->hurt(attacker, INSTANT_DEATH);
}
}
////////////////////////////////////////////////////
// XXX: Staff giving a boost to poison spells is hardcoded in
// player_spec_poison()
static void _OLGREB_equip(item_def */*item*/, bool *show_msgs, bool /*unmeld*/)
{
if (you.can_smell())
_equip_mpr(show_msgs, "You smell chlorine.");
else
_equip_mpr(show_msgs, "The staff glows a sickly green.");
}
static void _OLGREB_unequip(item_def */*item*/, bool *show_msgs)
{
if (you.can_smell())
_equip_mpr(show_msgs, "The smell of chlorine vanishes.");
else
_equip_mpr(show_msgs, "The staff's sickly green glow vanishes.");
}
// Based on melee_attack::staff_damage(), but using only evocations skill.
static int _calc_olgreb_damage(actor* attacker, actor* defender)
{
int base_dam = 0;
if (x_chance_in_y(attacker->skill(SK_EVOCATIONS, 100), 1000))
base_dam = random2(attacker->skill(SK_EVOCATIONS, 150) / 80);
return resist_adjust_damage(defender, BEAM_POISON_ARROW, base_dam);
}
static void _OLGREB_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* defender, bool mondied,
int /*dam*/)
{
const int bonus_dam = _calc_olgreb_damage(attacker, defender);
if (!mondied && bonus_dam)
{
mprf("%s %s %s%s",
attacker->name(DESC_THE).c_str(),
attacker->conj_verb("envenom").c_str(),
defender->name(DESC_THE).c_str(),
attack_strength_punctuation(bonus_dam).c_str());
defender->hurt(attacker, bonus_dam);
if (defender->alive())
defender->poison(attacker, 2, true);
}
}
////////////////////////////////////////////////////
static void _POWER_equip(item_def * /* item */, bool *show_msgs,
bool /*unmeld*/)
{
_equip_mpr(show_msgs, "You sense an aura of extreme power.");
}
static void _POWER_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* defender, bool mondied, int /*dam*/)
{
if (!mondied && x_chance_in_y(min(attacker->stat_hp() / 10, 27), 27))
{
bolt beam;
beam.thrower = attacker->is_player() ? KILL_YOU : KILL_MON;
beam.source = attacker->pos();
beam.source_id = attacker->mid;
beam.attitude = attacker->temp_attitude();
beam.range = 4;
beam.target = defender->pos();
zappy(ZAP_SWORD_BEAM, 100, false, beam);
beam.fire();
}
}
////////////////////////////////////////////////////
static void _HOLY_AXE_world_reacts(item_def *item)
{
const int horror_level = current_horror_level();
// Caps at the obsidian axe's base enchant.
const int plus = min(horror_level * 3 + 4, 16);
if (item->plus == plus)
return;
item->plus = plus;
you.wield_change = true;
}
////////////////////////////////////////////////////
static void _SINGING_SWORD_equip(item_def *item, bool *show_msgs, bool /*unmeld*/)
{
bool def_show = true;
if (show_msgs == nullptr)
show_msgs = &def_show;
if (!*show_msgs)
return;
if (!item->props.exists(SS_WELCOME_KEY))
{
mprf(MSGCH_TALK, "The sword says, \"Hi! I'm the Singing Sword!\"");
item->props[SS_WELCOME_KEY].get_bool() = true;
}
else
mprf(MSGCH_TALK, "The Singing Sword hums in delight!");
*show_msgs = false;
}
static void _SINGING_SWORD_unequip(item_def *item, bool *show_msgs)
{
set_artefact_name(*item, "Singing Sword");
_equip_mpr(show_msgs, "The Singing Sword sighs.", MSGCH_TALK);
}
static void _SINGING_SWORD_world_reacts(item_def *item)
{
int tension = get_tension(GOD_NO_GOD);
int tier = max(1, min(4, 1 + tension / 20));
bool silent = silenced(you.pos());
string old_name = get_artefact_name(*item);
string new_name;
if (silent)
new_name = "Sulking Sword";
else if (tier < 4)
new_name = "Singing Sword";
else
new_name = "Screaming Sword";
if (old_name != new_name)
{
set_artefact_name(*item, new_name);
you.wield_change = true;
}
}
static void _SINGING_SWORD_melee_effects(item_def* weapon, actor* attacker,
actor* /* defender */,
bool /*mondied*/, int /*dam*/)
{
int tier;
if (attacker->is_player())
tier = max(1, min(4, 1 + get_tension(GOD_NO_GOD) / 20));
// Don't base the sword on player state when the player isn't wielding it.
else
tier = 1;
if (silenced(attacker->pos()))
tier = 0;
dprf(DIAG_COMBAT, "Singing sword tension: %d, tier: %d",
attacker->is_player() ? get_tension(GOD_NO_GOD) : -1, tier);
// Not as spammy at low tension. Max chance reached at tier 3, allowing
// tier 0 to have a high chance so that the sword is likely to express its
// unhappiness with being silenced.
if (!x_chance_in_y(6, (tier == 1) ? 24: (tier == 2) ? 16: 12))
return;
const char *tenname[] = {"silenced", "no_tension", "low_tension",
"high_tension", "SCREAM"};
const string key = tenname[tier];
string msg = getSpeakString("singing sword " + key);
const int loudness[] = {0, 0, 20, 30, 40};
item_noise(*weapon, *attacker, msg, loudness[tier]);
if (tier < 1)
return; // Can't cast when silenced.
const int spellpower = 100 + 13 * (tier - 1) + (tier == 4 ? 36 : 0);
fire_los_attack_spell(SPELL_SONIC_WAVE, spellpower, attacker);
}
////////////////////////////////////////////////////
static void _PRUNE_equip(item_def */*item*/, bool *show_msgs, bool /*unmeld*/)
{
if (you.undead_state() == US_ALIVE)
_equip_mpr(show_msgs, "You struggle to resist the curse of the Prune...");
else
_equip_mpr(show_msgs, "The curse of the Prune has no hold on the dead.");
}
static void _PRUNE_unequip(item_def */*item*/, bool *show_msgs)
{
if (you.undead_state() == US_ALIVE)
_equip_mpr(show_msgs, "The curse of the Prune lifts from you.");
}
////////////////////////////////////////////////////
static void _LIGHTNING_SCALES_equip(item_def */*item*/, bool *show_msgs, bool /*unmeld*/)
{
_equip_mpr(show_msgs, "You feel lightning quick.");
}
static void _LIGHTNING_SCALES_unequip(item_def */*item*/, bool *show_msgs)
{
_equip_mpr(show_msgs, "You feel rather sluggish.");
}
////////////////////////////////////////////////////
static void _TORMENT_equip(item_def */*item*/, bool *show_msgs, bool /*unmeld*/)
{
_equip_mpr(show_msgs, "A terrible, searing pain shoots up your arm!");
}
static void _TORMENT_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* /*defender*/, bool /*mondied*/,
int /*dam*/)
{
if (one_chance_in(5))
torment(attacker, TORMENT_SCEPTRE, attacker->pos());
}
/////////////////////////////////////////////////////
static void _TROG_equip(item_def */*item*/, bool *show_msgs, bool /*unmeld*/)
{
_equip_mpr(show_msgs, "You feel the exhaustion of battles past.");
player_end_berserk();
}
static void _TROG_unequip(item_def */*item*/, bool *show_msgs)
{
_equip_mpr(show_msgs, "You feel less violent.");
}
///////////////////////////////////////////////////
// XXX: Always getting maximal vampiric drain is hardcoded in
// attack::apply_damage_brand()
static void _VAMPIRES_TOOTH_equip(item_def */*item*/, bool *show_msgs, bool /*unmeld*/)
{
if (!you.has_mutation(MUT_VAMPIRISM))
_equip_mpr(show_msgs, "You feel strangely empty.");
else if (you.vampire_alive)
{
_equip_mpr(show_msgs,
"You feel a strange hunger, and smell blood in the air...");
}
// else let player-equip.cc handle message
}
///////////////////////////////////////////////////
static void _VARIABILITY_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* /*defender*/, bool mondied,
int /*dam*/)
{
if (!mondied && one_chance_in(5))
{
const int pow = 75 + random2avg(75, 2);
if (you.can_see(*attacker))
mpr("The mace of Variability scintillates.");
cast_chain_spell(SPELL_CHAIN_OF_CHAOS, pow, attacker);
}
}
///////////////////////////////////////////////////
static void _ZONGULDROK_equip(item_def */*item*/, bool *show_msgs,
bool /*unmeld*/)
{
_equip_mpr(show_msgs, "You sense an extremely unholy aura.");
}
static void _ZONGULDROK_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* /*defender*/, bool /*mondied*/,
int /*dam*/)
{
if (attacker->is_player())
did_god_conduct(DID_EVIL, 3);
}
///////////////////////////////////////////////////
static void _GONG_melee_effects(item_def* /*item*/, actor* wearer,
actor* /*attacker*/, bool /*dummy*/,
int /*dam*/)
{
if (silenced(wearer->pos()))
return;
string msg = getSpeakString("shield of the gong");
if (msg.empty())
msg = "You hear a strange loud sound.";
mprf(MSGCH_SOUND, "%s", msg.c_str());
noisy(40, wearer->pos());
}
///////////////////////////////////////////////////
static void _STORM_QUEEN_melee_effects(item_def* /*item*/, actor* wearer,
actor* attacker, bool /*dummy*/,
int /*dam*/)
{
// Discharge does 3d(4 + pow*3/2) damage, so each point of power does
// an average of another 9/4 points of retaliation damage (~2).
// Let's try 3d7 damage at 1/3 chance. This is broadly comparable to
// elec brand - same average damage per trigger, higher trigger chance,
// but checks (half) AC - and triggers on block instead of attack :)
if (!attacker || !one_chance_in(3)) return;
shock_discharge_fineff::schedule(wearer, *attacker,
wearer->pos(), 3,
"shield");
}
///////////////////////////////////////////////////
static void _DEMON_AXE_melee_effects(item_def* /*item*/, actor* attacker,
actor* /*defender*/, bool /*mondied*/,
int /*dam*/)
{
if (one_chance_in(10))
{
if (monster* mons = attacker->as_monster())
{
create_monster(
mgen_data(summon_any_demon(RANDOM_DEMON_COMMON),
SAME_ATTITUDE(mons), mons->pos(), mons->foe)
.set_summoned(mons, 6, SPELL_SUMMON_DEMON));
}
else if (!you.allies_forbidden())
cast_summon_demon(50 + random2(100));
}
}
static monster* _find_nearest_possible_beholder()
{
for (distance_iterator di(you.pos(), true, true, LOS_RADIUS); di; ++di)
{
monster *mon = monster_at(*di);
if (mon && you.can_see(*mon)
&& you.possible_beholder(mon)
&& mons_is_threatening(*mon))
{
return mon;
}
}
return nullptr;
}
static void _DEMON_AXE_world_reacts(item_def */*item*/)
{
monster* mon = _find_nearest_possible_beholder();
if (!mon)
return;
monster& closest = *mon;
if (!you.beheld_by(closest))
{
mprf("Visions of slaying %s flood into your mind.",
closest.name(DESC_THE).c_str());
// The monsters (if any) currently mesmerising the player do not include
// this monster. To avoid trapping the player, all other beholders
// are removed.
you.clear_beholders();
}
if (you.confused())
{
mpr("Your confusion fades away as the thirst for blood takes over your mind.");
you.duration[DUR_CONF] = 0;
}
you.add_beholder(closest, true);
}
static void _DEMON_AXE_unequip(item_def */*item*/, bool */*show_msgs*/)
{
if (you.beheld())
{
// This shouldn't clear sirens and merfolk avatars, but we lack the
// information why they behold us -- usually, it's due to the axe.
// Since unwielding it costs scrolls of rem curse, we might say getting
// the demon away is enough of a shock to get you back to senses.
you.clear_beholders();
mpr("Your thirst for blood fades away.");
}
}
///////////////////////////////////////////////////
static void _WYRMBANE_equip(item_def */*item*/, bool *show_msgs, bool /*unmeld*/)
{
_equip_mpr(show_msgs,
species::is_draconian(you.species)
|| you.form == transformation::dragon
? "You feel an uncomfortable desire to slay dragons."
: "You feel an overwhelming desire to slay dragons!");
}
static void _WYRMBANE_melee_effects(item_def* weapon, actor* attacker,
actor* defender, bool mondied, int dam)
{
if (!defender || !defender->is_dragonkind())
return;
// Since the target will become a DEAD MONSTER if it dies due to the extra
// damage to dragons, we need to grab this information now.
const int hd = defender->dragon_level();
string name = defender->name(DESC_THE);
if (!mondied)
{
int bonus_dam = 1 + random2(3 * dam / 2);
mprf("%s %s%s",
defender->name(DESC_THE).c_str(),
defender->conj_verb("convulse").c_str(),
attack_strength_punctuation(bonus_dam).c_str());
defender->hurt(attacker, bonus_dam);
// Allow the lance to charge when killing dragonform felid players.
mondied = defender->is_player() ? defender->as_player()->pending_revival
: !defender->alive();
}
if (!mondied || !hd)
return;
// The cap can be reached by:
// * iron dragon, golden dragon, pearl dragon (18)
// * Xtahua (19)
// * bone dragon, Serpent of Hell (20)
// * Tiamat (22)
// * pghosts (up to 27)
dprf("Killed a drac with hd %d.", hd);
if (weapon->plus < hd)
{
weapon->plus++;
// Including you, if you were a dragonform felid with lives left.
if (weapon->plus == 18)
{
mprf("<white>The lance glows brightly as it skewers %s. You feel "
"that it has reached its full power.</white>",
name.c_str());
}
else
{
mprf("<green>The lance glows as it skewers %s.</green>",
name.c_str());
}
you.wield_change = true;
}
}
///////////////////////////////////////////////////
static void _UNDEADHUNTER_melee_effects(item_def* /*item*/, actor* attacker,
actor* defender, bool mondied, int dam)
{
if (defender->holiness() & MH_UNDEAD && !one_chance_in(3)
&& !mondied && dam)
{
int bonus_dam = random2avg((1 + (dam * 3)), 3);
mprf("%s %s blasted by disruptive energy%s",
defender->name(DESC_THE).c_str(),
defender->conj_verb("be").c_str(),
attack_strength_punctuation(bonus_dam).c_str());
defender->hurt(attacker, bonus_dam);
}
}
///////////////////////////////////////////////////
static void _EOS_equip(item_def */*item*/, bool */*show_msgs*/, bool /*unmeld*/)
{
invalidate_agrid(true);
}
static void _EOS_unequip(item_def */*item*/, bool */*show_msgs*/)
{
invalidate_agrid(true);
}
///////////////////////////////////////////////////
static void _SHADOWS_equip(item_def */*item*/, bool */*show_msgs*/, bool /*unmeld*/)
{
invalidate_agrid(true);
}
static void _SHADOWS_unequip(item_def */*item*/, bool */*show_msgs*/)
{
invalidate_agrid(true);
}
///////////////////////////////////////////////////
static void _DEVASTATOR_equip(item_def */*item*/, bool *show_msgs,
bool /*unmeld*/)
{
_equip_mpr(show_msgs, "Time to lay down the shillelagh law.");
}
static void _DEVASTATOR_melee_effects(item_def* /*item*/, actor* attacker,
actor* defender, bool /*mondied*/,
int dam)
{
if (dam)
shillelagh(attacker, defender->pos(), dam);
}
///////////////////////////////////////////////////
static void _DRAGONSKIN_equip(item_def */*item*/, bool *show_msgs, bool /*unmeld*/)
{
_equip_mpr(show_msgs, "You feel oddly protected from the elements.");
}
static void _DRAGONSKIN_unequip(item_def */*item*/, bool *show_msgs)
{
_equip_mpr(show_msgs, "You no longer feel protected from the elements.");
}
///////////////////////////////////////////////////
static void _BLACK_KNIGHT_HORSE_world_reacts(item_def */*item*/)
{
if (x_chance_in_y(you.time_taken, 10 * BASELINE_DELAY))
did_god_conduct(DID_EVIL, 1);
}
///////////////////////////////////////////////////
static void _NIGHT_equip(item_def */*item*/, bool *show_msgs, bool /*unmeld*/)
{
update_vision_range();
_equip_mpr(show_msgs, "The light fades from your surroundings.");
}
static void _NIGHT_unequip(item_def */*item*/, bool *show_msgs)
{
update_vision_range();
_equip_mpr(show_msgs, "The light returns to your surroundings.");
}
///////////////////////////////////////////////////
static void _PLUTONIUM_SWORD_melee_effects(item_def* /*weapon*/,
actor* attacker, actor* defender,
bool mondied, int dam)
{
if (!mondied && one_chance_in(5) && defender->can_mutate())
{
mpr("Mutagenic energy flows through the plutonium sword!");
if (attacker->is_player())
did_god_conduct(DID_CHAOS, 3);
if (one_chance_in(10))
defender->polymorph(0); // Low duration if applied to the player.
else
{
miscast_effect(*defender, attacker, {miscast_source::melee},
spschool::transmutation, 5, random2(dam),
"the plutonium sword");
}
}
}
///////////////////////////////////////////////////
static void _SNAKEBITE_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* defender, bool mondied, int /*dam*/)
{
if (!mondied && x_chance_in_y(2, 5))
{
curare_actor(attacker, defender, 2, "curare",
attacker->name(DESC_PLAIN));
}
}
///////////////////////////////////////////////////
static void _WOE_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* defender, bool mondied, int /*dam*/)
{
const char *verb = "bugger", *adv = "";
switch (random2(8))
{
case 0: verb = "cleave", adv = " in twain"; break;
case 1: verb = "pulverise", adv = " into a thin bloody mist"; break;
case 2: verb = "hew", adv = " savagely"; break;
case 3: verb = "fatally mangle", adv = ""; break;
case 4: verb = "dissect", adv = " like a pig carcass"; break;
case 5: verb = "chop", adv = " into pieces"; break;
case 6: verb = "butcher", adv = " messily"; break;
case 7: verb = "slaughter", adv = " joyfully"; break;
}
if (you.see_cell(attacker->pos()) || you.see_cell(defender->pos()))
{
mprf("%s %s %s%s.", attacker->name(DESC_THE).c_str(),
attacker->conj_verb(verb).c_str(),
(attacker == defender ? defender->pronoun(PRONOUN_REFLEXIVE)
: defender->name(DESC_THE)).c_str(),
adv);
}
if (!mondied)
defender->hurt(attacker, defender->stat_hp());
if (defender->as_monster()->can_bleed())
{
blood_spray(defender->pos(), defender->as_monster()->type,
random_range(5, 10));
}
defender->as_monster()->flags |= MF_EXPLODE_KILL;
}
///////////////////////////////////////////////////
static setup_missile_type _DAMNATION_launch(item_def* /*item*/, bolt* beam,
string* ammo_name, bool* /*returning*/)
{
ASSERT(beam->item
&& beam->item->base_type == OBJ_MISSILES
&& !is_artefact(*(beam->item)));
beam->item->props[DAMNATION_BOLT_KEY].get_bool() = true;
beam->name = "damnation bolt";
*ammo_name = "a damnation bolt";
beam->colour = LIGHTRED;
beam->glyph = DCHAR_FIRED_ZAP;
bolt *expl = new bolt(*beam);
expl->flavour = BEAM_DAMNATION;
expl->is_explosion = true;
expl->damage = dice_def(2, 14);
expl->name = "damnation";
beam->special_explosion = expl;
return SM_FINISHED;
}
///////////////////////////////////////////////////
/**
* Calculate the bonus damage that the Elemental Staff does with an attack of
* the given flavour.
*
* @param flavour The elemental flavour of attack; may be BEAM_NONE for earth
* (physical) attacks.
* @param defender The victim of the attack. (Not const because checking res
* may end up IDing items on monsters... )
* @return The amount of damage that the defender will receive.
*/
static int _calc_elemental_staff_damage(beam_type flavour,
actor* defender)
{
const int base_bonus_dam = 10 + random2(15);
if (flavour == BEAM_NONE) // earth
return defender->apply_ac(base_bonus_dam);
return resist_adjust_damage(defender, flavour, base_bonus_dam);
}
static void _ELEMENTAL_STAFF_melee_effects(item_def*, actor* attacker,
actor* defender, bool mondied,
int)
{
const int evoc = attacker->skill(SK_EVOCATIONS, 27);
if (mondied || !(x_chance_in_y(evoc, 27*27) || x_chance_in_y(evoc, 27*27)))
return;
const char *verb = nullptr;
beam_type flavour = BEAM_NONE;
switch (random2(4))
{
case 0:
verb = "burn";
flavour = BEAM_FIRE;
break;
case 1:
verb = "freeze";
flavour = BEAM_COLD;
break;
case 2:
verb = "electrocute";
flavour = BEAM_ELECTRICITY;
break;
default:
dprf("Bad damage type for elemental staff; defaulting to earth");
// fallthrough to earth
case 3:
verb = "crush";
break;
}
const int bonus_dam = _calc_elemental_staff_damage(flavour, defender);
if (bonus_dam <= 0)
return;
mprf("%s %s %s%s",
attacker->name(DESC_THE).c_str(),
attacker->conj_verb(verb).c_str(),
(attacker == defender ? defender->pronoun(PRONOUN_REFLEXIVE)
: defender->name(DESC_THE)).c_str(),
attack_strength_punctuation(bonus_dam).c_str());
defender->hurt(attacker, bonus_dam, flavour);
if (defender->alive() && flavour != BEAM_NONE)
defender->expose_to_element(flavour, 2);
}
///////////////////////////////////////////////////
static void _ARC_BLADE_equip(item_def */*item*/, bool *show_msgs, bool /*unmeld*/)
{
_equip_mpr(show_msgs, "The arc blade crackles to life.");
}
static void _ARC_BLADE_unequip(item_def */*item*/, bool *show_msgs)
{
_equip_mpr(show_msgs, "The arc blade stops crackling.");
}
static void _ARC_BLADE_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* /*defender*/, bool /*mondied*/,
int /*dam*/)
{
if (one_chance_in(3))
{
const int pow = 100 + random2avg(100, 2);
if (you.can_see(*attacker))
mpr("The arc blade crackles.");
else
mpr("You hear the crackle of electricity.");
cast_discharge(pow, *attacker, false, false);
}
}
///////////////////////////////////////////////////
static void _SPELLBINDER_melee_effects(item_def* /*weapon*/, actor* attacker,
actor* defender, bool mondied,
int dam)
{
// Only cause miscasts if the target has magic to disrupt.
if (defender->antimagic_susceptible()
&& !mondied)
{
miscast_effect(*defender, attacker, {miscast_source::melee},
spschool::random, random_range(1, 9), dam,
"the demon whip \"Spellbinder\"");
}
}
///////////////////////////////////////////////////