-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
player-equip.cc
1390 lines (1161 loc) · 40.5 KB
/
player-equip.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 "player-equip.h"
#include <cmath>
#include "act-iter.h"
#include "areas.h"
#include "artefact.h"
#include "art-enum.h"
#include "delay.h"
#include "english.h" // conjugate_verb
#include "evoke.h"
#include "food.h"
#include "god-abil.h"
#include "god-item.h"
#include "god-passive.h"
#include "hints.h"
#include "item-name.h"
#include "item-prop.h"
#include "items.h"
#include "item-use.h"
#include "libutil.h"
#include "macro.h" // command_to_string
#include "message.h"
#include "mutation.h"
#include "nearby-danger.h"
#include "notes.h"
#include "options.h"
#include "player-stats.h"
#include "religion.h"
#include "shopping.h"
#include "spl-miscast.h"
#include "spl-summoning.h"
#include "spl-wpnench.h"
#include "xom.h"
static void _mark_unseen_monsters();
/**
* Recalculate the player's max hp and set the current hp based on the %change
* of max hp. This has resulted from our having equipped an artefact that
* changes max hp.
*/
static void _calc_hp_artefact()
{
recalc_and_scale_hp();
if (you.hp_max <= 0) // Borgnjor's abusers...
ouch(0, KILLED_BY_DRAINING);
}
// Fill an empty equipment slot.
void equip_item(equipment_type slot, int item_slot, bool msg)
{
ASSERT_RANGE(slot, EQ_FIRST_EQUIP, NUM_EQUIP);
ASSERT(you.equip[slot] == -1);
ASSERT(!you.melded[slot]);
you.equip[slot] = item_slot;
equip_effect(slot, item_slot, false, msg);
ash_check_bondage();
if (you.equip[slot] != -1 && you.inv[you.equip[slot]].cursed())
auto_id_inventory();
}
// Clear an equipment slot (possibly melded).
bool unequip_item(equipment_type slot, bool msg)
{
ASSERT_RANGE(slot, EQ_FIRST_EQUIP, NUM_EQUIP);
ASSERT(!you.melded[slot] || you.equip[slot] != -1);
const int item_slot = you.equip[slot];
if (item_slot == -1)
return false;
else
{
you.equip[slot] = -1;
if (!you.melded[slot])
unequip_effect(slot, item_slot, false, msg);
else
you.melded.set(slot, false);
ash_check_bondage();
return true;
}
}
// Meld a slot (if equipped).
// Does not handle unequip effects, since melding should be simultaneous (so
// you should call all unequip effects after all melding is done)
bool meld_slot(equipment_type slot, bool msg)
{
ASSERT_RANGE(slot, EQ_FIRST_EQUIP, NUM_EQUIP);
ASSERT(!you.melded[slot] || you.equip[slot] != -1);
if (you.equip[slot] != -1 && !you.melded[slot])
{
you.melded.set(slot);
return true;
}
return false;
}
// Does not handle equip effects, since unmelding should be simultaneous (so
// you should call all equip effects after all unmelding is done)
bool unmeld_slot(equipment_type slot, bool msg)
{
ASSERT_RANGE(slot, EQ_FIRST_EQUIP, NUM_EQUIP);
ASSERT(!you.melded[slot] || you.equip[slot] != -1);
if (you.equip[slot] != -1 && you.melded[slot])
{
you.melded.set(slot, false);
return true;
}
return false;
}
static void _equip_weapon_effect(item_def& item, bool showMsgs, bool unmeld);
static void _unequip_weapon_effect(item_def& item, bool showMsgs, bool meld);
static void _equip_armour_effect(item_def& arm, bool unmeld,
equipment_type slot);
static void _unequip_armour_effect(item_def& item, bool meld,
equipment_type slot);
static void _equip_jewellery_effect(item_def &item, bool unmeld,
equipment_type slot);
static void _unequip_jewellery_effect(item_def &item, bool mesg, bool meld,
equipment_type slot);
static void _equip_use_warning(const item_def& item);
static void _assert_valid_slot(equipment_type eq, equipment_type slot)
{
#ifdef ASSERTS
if (eq == slot)
return;
ASSERT(eq == EQ_RINGS); // all other slots are unique
equipment_type r1 = EQ_LEFT_RING, r2 = EQ_RIGHT_RING;
if (you.species == SP_OCTOPODE)
r1 = EQ_RING_ONE, r2 = EQ_RING_EIGHT;
if (slot >= r1 && slot <= r2)
return;
if (const item_def* amu = you.slot_item(EQ_AMULET, true))
if (is_unrandom_artefact(*amu, UNRAND_FINGER_AMULET) && slot == EQ_RING_AMULET)
return;
die("ring on invalid slot %d", slot);
#endif
}
void equip_effect(equipment_type slot, int item_slot, bool unmeld, bool msg)
{
item_def& item = you.inv[item_slot];
equipment_type eq = get_item_slot(item);
if (slot == EQ_WEAPON && eq != EQ_WEAPON)
return;
_assert_valid_slot(eq, slot);
if (msg)
_equip_use_warning(item);
if (slot == EQ_WEAPON)
_equip_weapon_effect(item, msg, unmeld);
else if (slot >= EQ_CLOAK && slot <= EQ_BODY_ARMOUR)
_equip_armour_effect(item, unmeld, slot);
else if (slot >= EQ_FIRST_JEWELLERY && slot <= EQ_LAST_JEWELLERY)
_equip_jewellery_effect(item, unmeld, slot);
}
void unequip_effect(equipment_type slot, int item_slot, bool meld, bool msg)
{
item_def& item = you.inv[item_slot];
equipment_type eq = get_item_slot(item);
if (slot == EQ_WEAPON && eq != EQ_WEAPON)
return;
_assert_valid_slot(eq, slot);
if (slot == EQ_WEAPON)
_unequip_weapon_effect(item, msg, meld);
else if (slot >= EQ_CLOAK && slot <= EQ_BODY_ARMOUR)
_unequip_armour_effect(item, meld, slot);
else if (slot >= EQ_FIRST_JEWELLERY && slot <= EQ_LAST_JEWELLERY)
_unequip_jewellery_effect(item, msg, meld, slot);
}
///////////////////////////////////////////////////////////
// Actual equip and unequip effect implementation below
//
static void _equip_artefact_effect(item_def &item, bool *show_msgs, bool unmeld,
equipment_type slot)
{
#define unknown_proprt(prop) (proprt[(prop)] && !known[(prop)])
ASSERT(is_artefact(item));
// Call unrandart equip function first, so that it can modify the
// artefact's properties before they're applied.
if (is_unrandom_artefact(item))
{
const unrandart_entry *entry = get_unrand_entry(item.unrand_idx);
if (entry->equip_func)
entry->equip_func(&item, show_msgs, unmeld);
if (entry->world_reacts_func)
you.unrand_reacts.set(slot);
}
const bool alreadyknown = item_type_known(item);
const bool dangerous = player_in_a_dangerous_place();
const bool msg = !show_msgs || *show_msgs;
artefact_properties_t proprt;
artefact_known_props_t known;
artefact_properties(item, proprt, known);
if (proprt[ARTP_AC] || proprt[ARTP_SHIELDING])
you.redraw_armour_class = true;
if (proprt[ARTP_EVASION])
you.redraw_evasion = true;
if (proprt[ARTP_SEE_INVISIBLE])
autotoggle_autopickup(false);
if (proprt[ARTP_MAGICAL_POWER] && !known[ARTP_MAGICAL_POWER] && msg)
{
canned_msg(proprt[ARTP_MAGICAL_POWER] > 0 ? MSG_MANA_INCREASE
: MSG_MANA_DECREASE);
}
// Modify ability scores.
notify_stat_change(STAT_STR, proprt[ARTP_STRENGTH],
!(msg && unknown_proprt(ARTP_STRENGTH)));
notify_stat_change(STAT_INT, proprt[ARTP_INTELLIGENCE],
!(msg && unknown_proprt(ARTP_INTELLIGENCE)));
notify_stat_change(STAT_DEX, proprt[ARTP_DEXTERITY],
!(msg && unknown_proprt(ARTP_DEXTERITY)));
if (unknown_proprt(ARTP_CONTAM) && msg)
mpr("You feel a build-up of mutagenic energy.");
if (!unmeld && !item.cursed() && proprt[ARTP_CURSE])
do_curse_item(item, !msg);
if (!alreadyknown && dangerous)
{
// Xom loves it when you use an unknown random artefact and
// there is a dangerous monster nearby...
xom_is_stimulated(100);
}
if (proprt[ARTP_HP])
_calc_hp_artefact();
// Let's try this here instead of up there.
if (proprt[ARTP_MAGICAL_POWER])
calc_mp();
if (!fully_identified(item))
{
set_ident_type(item, true);
set_ident_flags(item, ISFLAG_IDENT_MASK);
}
#undef unknown_proprt
}
static void _unequip_artefact_effect(item_def &item,
bool *show_msgs, bool meld,
equipment_type slot)
{
ASSERT(is_artefact(item));
artefact_properties_t proprt;
artefact_known_props_t known;
artefact_properties(item, proprt, known);
const bool msg = !show_msgs || *show_msgs;
if (proprt[ARTP_AC] || proprt[ARTP_SHIELDING])
you.redraw_armour_class = true;
if (proprt[ARTP_EVASION])
you.redraw_evasion = true;
if (proprt[ARTP_HP])
_calc_hp_artefact();
if (proprt[ARTP_MAGICAL_POWER] && !known[ARTP_MAGICAL_POWER] && msg)
{
canned_msg(proprt[ARTP_MAGICAL_POWER] > 0 ? MSG_MANA_DECREASE
: MSG_MANA_INCREASE);
}
notify_stat_change(STAT_STR, -proprt[ARTP_STRENGTH], true);
notify_stat_change(STAT_INT, -proprt[ARTP_INTELLIGENCE], true);
notify_stat_change(STAT_DEX, -proprt[ARTP_DEXTERITY], true);
if (proprt[ARTP_FLY] != 0 && you.cancellable_flight()
&& !you.evokable_flight())
{
you.duration[DUR_FLIGHT] = 0;
land_player();
}
if (proprt[ARTP_INVISIBLE] != 0
&& you.duration[DUR_INVIS] > 1
&& !you.attribute[ATTR_INVIS_UNCANCELLABLE]
&& !you.evokable_invis())
{
you.duration[DUR_INVIS] = 1;
}
if (proprt[ARTP_MAGICAL_POWER])
calc_mp();
if (proprt[ARTP_CONTAM] && !meld)
{
mpr("Mutagenic energies flood into your body!");
contaminate_player(7000, true);
}
if (proprt[ARTP_DRAIN] && !meld)
drain_player(150, true, true);
if (proprt[ARTP_SEE_INVISIBLE])
_mark_unseen_monsters();
if (is_unrandom_artefact(item))
{
const unrandart_entry *entry = get_unrand_entry(item.unrand_idx);
if (entry->unequip_func)
entry->unequip_func(&item, show_msgs);
if (entry->world_reacts_func)
you.unrand_reacts.set(slot, false);
}
// this must be last!
if (proprt[ARTP_FRAGILE] && !meld)
{
mprf("%s crumbles to dust!", item.name(DESC_THE).c_str());
dec_inv_item_quantity(item.link, 1);
}
}
static void _equip_use_warning(const item_def& item)
{
if (is_holy_item(item) && you_worship(GOD_YREDELEMNUL))
mpr("You really shouldn't be using a holy item like this.");
else if (is_corpse_violating_item(item) && you_worship(GOD_FEDHAS))
mpr("You really shouldn't be using a corpse-violating item like this.");
else if (is_evil_item(item) && is_good_god(you.religion))
mpr("You really shouldn't be using an evil item like this.");
else if (is_unclean_item(item) && you_worship(GOD_ZIN))
mpr("You really shouldn't be using an unclean item like this.");
else if (is_chaotic_item(item) && you_worship(GOD_ZIN))
mpr("You really shouldn't be using a chaotic item like this.");
else if (is_hasty_item(item) && you_worship(GOD_CHEIBRIADOS))
mpr("You really shouldn't be using a hasty item like this.");
else if (is_fiery_item(item) && you_worship(GOD_DITHMENOS))
mpr("You really shouldn't be using a fiery item like this.");
else if (is_channeling_item(item) && you_worship(GOD_PAKELLAS))
mpr("You really shouldn't be trying to channel magic like this.");
}
static void _wield_cursed(item_def& item, bool known_cursed, bool unmeld)
{
if (!item.cursed() || unmeld)
return;
mprf("It sticks to your %s!", you.hand_name(false).c_str());
int amusement = 16;
if (!known_cursed)
{
amusement *= 2;
if (origin_as_god_gift(item) == GOD_XOM)
amusement *= 2;
}
const int wpn_skill = item_attack_skill(item.base_type, item.sub_type);
if (wpn_skill != SK_FIGHTING && you.skills[wpn_skill] == 0)
amusement *= 2;
xom_is_stimulated(amusement);
}
// Provide a function for handling initial wielding of 'special'
// weapons, or those whose function is annoying to reproduce in
// other places *cough* auto-butchering *cough*. {gdl}
static void _equip_weapon_effect(item_def& item, bool showMsgs, bool unmeld)
{
int special = 0;
const bool artefact = is_artefact(item);
const bool known_cursed = item_known_cursed(item);
// And here we finally get to the special effects of wielding. {dlb}
switch (item.base_type)
{
case OBJ_STAVES:
{
set_ident_flags(item, ISFLAG_IDENT_MASK);
set_ident_type(OBJ_STAVES, item.sub_type, true);
if (item.sub_type == STAFF_POWER)
{
canned_msg(MSG_MANA_INCREASE);
calc_mp();
}
_wield_cursed(item, known_cursed, unmeld);
break;
}
case OBJ_WEAPONS:
{
// Note that if the unrand equip prints a message, it will
// generally set showMsgs to false.
if (artefact)
_equip_artefact_effect(item, &showMsgs, unmeld, EQ_WEAPON);
const bool was_known = item_type_known(item);
bool known_recurser = false;
set_ident_flags(item, ISFLAG_IDENT_MASK);
special = item.brand;
if (artefact)
{
special = artefact_property(item, ARTP_BRAND);
if (!was_known && !(item.flags & ISFLAG_NOTED_ID))
{
item.flags |= ISFLAG_NOTED_ID;
// Make a note of it.
take_note(Note(NOTE_ID_ITEM, 0, 0, item.name(DESC_A),
origin_desc(item)));
}
else
known_recurser = artefact_known_property(item, ARTP_CURSE);
}
if (special != SPWPN_NORMAL)
{
// message first
if (showMsgs)
{
const string item_name = item.name(DESC_YOUR);
switch (special)
{
case SPWPN_FLAMING:
mprf("%s bursts into flame!", item_name.c_str());
break;
case SPWPN_FREEZING:
mprf("%s %s", item_name.c_str(),
is_range_weapon(item) ?
"is covered in frost." :
"glows with a cold blue light!");
break;
case SPWPN_HOLY_WRATH:
mprf("%s softly glows with a divine radiance!",
item_name.c_str());
break;
case SPWPN_ELECTROCUTION:
if (!silenced(you.pos()))
{
mprf(MSGCH_SOUND,
"You hear the crackle of electricity.");
}
else
mpr("You see sparks fly.");
break;
case SPWPN_VENOM:
mprf("%s begins to drip with poison!", item_name.c_str());
break;
case SPWPN_PROTECTION:
mprf("%s hums with potential!", item_name.c_str());
break;
case SPWPN_DRAINING:
mpr("You sense an unholy aura.");
break;
case SPWPN_SPEED:
mpr(you.hands_act("tingle", "!"));
break;
case SPWPN_VAMPIRISM:
if (you.species == SP_VAMPIRE)
mpr("You feel a bloodthirsty glee!");
else if (you.undead_state() == US_ALIVE && !you_foodless())
mpr("You feel a dreadful hunger.");
else
mpr("You feel an empty sense of dread.");
break;
case SPWPN_PAIN:
{
const string your_arm = you.arm_name(false);
if (you.skill(SK_NECROMANCY) == 0)
mpr("You have a feeling of ineptitude.");
else if (you.skill(SK_NECROMANCY) <= 6)
{
mprf("Pain shudders through your %s!",
your_arm.c_str());
}
else
{
mprf("A searing pain shoots up your %s!",
your_arm.c_str());
}
break;
}
case SPWPN_CHAOS:
mprf("%s is briefly surrounded by a scintillating aura of "
"random colours.", item_name.c_str());
break;
case SPWPN_PENETRATION:
{
// FIXME: make hands_act take a pre-verb adverb so we can
// use it here.
bool plural = true;
string hand = you.hand_name(true, &plural);
mprf("Your %s briefly %s through it before you manage "
"to get a firm grip on it.",
hand.c_str(), conjugate_verb("pass", plural).c_str());
break;
}
case SPWPN_REAPING:
mprf("%s is briefly surrounded by shifting shadows.",
item_name.c_str());
break;
case SPWPN_ANTIMAGIC:
// Even if your maxmp is 0.
mpr("You feel magic leave you.");
break;
case SPWPN_DISTORTION:
mpr("Space warps around you for a moment!");
break;
case SPWPN_ACID:
mprf("%s begins to ooze corrosive slime!", item_name.c_str());
break;
default:
break;
}
}
// effect second
switch (special)
{
case SPWPN_VAMPIRISM:
if (you.species != SP_VAMPIRE
&& you.undead_state() == US_ALIVE
&& !you_foodless()
&& !unmeld)
{
make_hungry(4500, false, false);
}
break;
case SPWPN_DISTORTION:
if (!was_known)
{
// Xom loves it when you ID a distortion weapon this way,
// and even more so if he gifted the weapon himself.
if (origin_as_god_gift(item) == GOD_XOM)
xom_is_stimulated(200);
else
xom_is_stimulated(100);
}
break;
case SPWPN_ANTIMAGIC:
calc_mp();
break;
default:
break;
}
}
_wield_cursed(item, known_cursed || known_recurser, unmeld);
break;
}
default:
break;
}
}
static void _unequip_weapon_effect(item_def& real_item, bool showMsgs,
bool meld)
{
you.wield_change = true;
you.m_quiver.on_weapon_changed();
// Fragile artefacts may be destroyed, so make a copy
item_def item = real_item;
// Call this first, so that the unrandart func can set showMsgs to
// false if it does its own message handling.
if (is_artefact(item))
_unequip_artefact_effect(real_item, &showMsgs, meld, EQ_WEAPON);
if (item.base_type == OBJ_WEAPONS)
{
const int brand = get_weapon_brand(item);
if (brand != SPWPN_NORMAL)
{
const string msg = item.name(DESC_YOUR);
switch (brand)
{
case SPWPN_FLAMING:
if (showMsgs)
mprf("%s stops flaming.", msg.c_str());
break;
case SPWPN_FREEZING:
case SPWPN_HOLY_WRATH:
if (showMsgs)
mprf("%s stops glowing.", msg.c_str());
break;
case SPWPN_ELECTROCUTION:
if (showMsgs)
mprf("%s stops crackling.", msg.c_str());
break;
case SPWPN_VENOM:
if (showMsgs)
mprf("%s stops dripping with poison.", msg.c_str());
break;
case SPWPN_PROTECTION:
if (showMsgs)
mprf("%s goes still.", msg.c_str());
if (you.duration[DUR_SPWPN_PROTECTION])
{
you.duration[DUR_SPWPN_PROTECTION] = 0;
you.redraw_armour_class = true;
}
break;
case SPWPN_VAMPIRISM:
if (showMsgs)
{
if (you.species == SP_VAMPIRE)
mpr("You feel your glee subside.");
else
mpr("You feel the dreadful sensation subside.");
}
break;
case SPWPN_DISTORTION:
// Removing the translocations skill reduction of effect,
// it might seem sensible, but this brand is supposed
// to be dangerous because it does large bonus damage,
// as well as free teleport other side effects, and
// even with the miscast effects you can rely on the
// occasional spatial bonus to mow down some opponents.
// It's far too powerful without a real risk, especially
// if it's to be allowed as a player spell. -- bwr
// int effect = 9 -
// random2avg(you.skills[SK_TRANSLOCATIONS] * 2, 2);
if (!meld)
{
if (have_passive(passive_t::safe_distortion))
{
simple_god_message(" absorbs the residual spatial "
"distortion as you unwield your "
"weapon.");
break;
}
// Makes no sense to discourage unwielding a temporarily
// branded weapon since you can wait it out. This also
// fixes problems with unwield prompts (mantis #793).
MiscastEffect(&you, nullptr, WIELD_MISCAST,
SPTYP_TRANSLOCATION, 9, 90,
"a distortion unwield");
}
break;
case SPWPN_ANTIMAGIC:
calc_mp();
mpr("You feel magic returning to you.");
break;
// NOTE: When more are added here, *must* duplicate unwielding
// effect in brand weapon scroll effect in read_scroll.
case SPWPN_ACID:
mprf("%s stops oozing corrosive slime.", msg.c_str());
break;
}
if (you.duration[DUR_EXCRUCIATING_WOUNDS])
{
ASSERT(real_item.defined());
end_weapon_brand(real_item, true);
}
}
}
else if (item.is_type(OBJ_STAVES, STAFF_POWER))
{
calc_mp();
canned_msg(MSG_MANA_DECREASE);
}
// Unwielding dismisses an active spectral weapon
monster *spectral_weapon = find_spectral_weapon(&you);
if (spectral_weapon)
{
mprf("Your spectral weapon disappears as %s.",
meld ? "your weapon melds" : "you unwield");
end_spectral_weapon(spectral_weapon, false, true);
}
}
static void _spirit_shield_message(bool unmeld)
{
if (!unmeld && you.spirit_shield() < 2)
{
dec_mp(you.magic_points);
mpr("You feel your power drawn to a protective spirit.");
if (you.species == SP_DEEP_DWARF
&& !(have_passive(passive_t::no_mp_regen)
|| player_under_penance(GOD_PAKELLAS)))
{
mpr("Now linked to your health, your magic stops regenerating.");
}
}
else if (!unmeld && player_mutation_level(MUT_MANA_SHIELD))
mpr("You feel the presence of a powerless spirit.");
else // unmeld or already spirit-shielded
mpr("You feel spirits watching over you.");
}
static void _equip_armour_effect(item_def& arm, bool unmeld,
equipment_type slot)
{
const bool known_cursed = item_known_cursed(arm);
int ego = get_armour_ego_type(arm);
if (ego != SPARM_NORMAL)
{
switch (ego)
{
case SPARM_RUNNING:
if (!you.fishtail)
mpr("You feel quick.");
break;
case SPARM_FIRE_RESISTANCE:
mpr("You feel resistant to fire.");
break;
case SPARM_COLD_RESISTANCE:
mpr("You feel resistant to cold.");
break;
case SPARM_POISON_RESISTANCE:
if (player_res_poison(false, false, false) < 3)
mpr("You feel resistant to poison.");
break;
case SPARM_SEE_INVISIBLE:
mpr("You feel perceptive.");
autotoggle_autopickup(false);
break;
case SPARM_INVISIBILITY:
if (!you.duration[DUR_INVIS])
mpr("You become transparent for a moment.");
break;
case SPARM_STRENGTH:
notify_stat_change(STAT_STR, 3, false);
break;
case SPARM_DEXTERITY:
notify_stat_change(STAT_DEX, 3, false);
break;
case SPARM_INTELLIGENCE:
notify_stat_change(STAT_INT, 3, false);
break;
case SPARM_PONDEROUSNESS:
mpr("You feel rather ponderous.");
break;
case SPARM_FLYING:
// If you weren't flying when you took off the boots, don't restart.
if (you.attribute[ATTR_LAST_FLIGHT_STATUS]
|| player_mutation_level(MUT_NO_ARTIFICE))
{
if (you.airborne())
{
you.attribute[ATTR_PERM_FLIGHT] = 1;
mpr("You feel rather light.");
}
else
{
you.attribute[ATTR_PERM_FLIGHT] = 1;
float_player();
}
}
if (!unmeld && !player_mutation_level(MUT_NO_ARTIFICE))
{
if (player_mutation_level(MUT_NO_ARTIFICE))
mpr("Take it off to stop flying.");
else
{
mprf("(use the <w>%s</w>bility menu to %s flying)",
command_to_string(CMD_USE_ABILITY).c_str(),
you.attribute[ATTR_LAST_FLIGHT_STATUS]
? "stop or start" : "start or stop");
}
}
break;
case SPARM_MAGIC_RESISTANCE:
mpr("You feel resistant to hostile enchantments.");
break;
case SPARM_PROTECTION:
mpr("You feel protected.");
break;
case SPARM_STEALTH:
if (!player_mutation_level(MUT_NO_STEALTH))
mpr("You feel stealthy.");
break;
case SPARM_RESISTANCE:
mpr("You feel resistant to extremes of temperature.");
break;
case SPARM_POSITIVE_ENERGY:
mpr("You feel more protected from negative energy.");
break;
case SPARM_ARCHMAGI:
if (!you.skill(SK_SPELLCASTING))
mpr("You feel strangely lacking in power.");
else
mpr("You feel powerful.");
break;
case SPARM_SPIRIT_SHIELD:
_spirit_shield_message(unmeld);
break;
case SPARM_ARCHERY:
mpr("You feel that your aim is more steady.");
break;
}
}
if (is_artefact(arm))
{
bool show_msgs = true;
_equip_artefact_effect(arm, &show_msgs, unmeld, slot);
}
if (arm.cursed() && !unmeld)
{
mpr("Oops, that feels deathly cold.");
learned_something_new(HINT_YOU_CURSED);
if (!known_cursed)
{
int amusement = 64;
if (origin_as_god_gift(arm) == GOD_XOM)
amusement *= 2;
xom_is_stimulated(amusement);
}
}
you.redraw_armour_class = true;
you.redraw_evasion = true;
}
/**
* The player lost a source of permafly. End their flight if there was
* no other source, evoking a ring of flight "for free" if possible.
*/
void lose_permafly_source()
{
const bool had_perm_flight = you.attribute[ATTR_PERM_FLIGHT];
if (had_perm_flight
&& !you.wearing_ego(EQ_ALL_ARMOUR, SPARM_FLYING)
&& !you.racial_permanent_flight())
{
you.attribute[ATTR_PERM_FLIGHT] = 0;
if (you.evokable_flight())
{
fly_player(
player_adjust_evoc_power(you.skill(SK_EVOCATIONS, 2) + 30),
true);
}
}
// since a permflight item can keep tempflight evocations going
// we should check tempflight here too
if (you.cancellable_flight() && !you.evokable_flight())
you.duration[DUR_FLIGHT] = 0;
if (had_perm_flight)
land_player(); // land_player() has a check for airborne()
}
static void _unequip_armour_effect(item_def& item, bool meld,
equipment_type slot)
{
you.redraw_armour_class = true;
you.redraw_evasion = true;
switch (get_armour_ego_type(item))
{
case SPARM_RUNNING:
if (!you.fishtail)
mpr("You feel rather sluggish.");
break;
case SPARM_FIRE_RESISTANCE:
mpr("You feel less resistant to fire.");
break;
case SPARM_COLD_RESISTANCE:
mpr("You feel less resistant to cold.");
break;
case SPARM_POISON_RESISTANCE:
if (player_res_poison() <= 0)
mpr("You no longer feel resistant to poison.");
break;
case SPARM_SEE_INVISIBLE:
if (!you.can_see_invisible())
{
mpr("You feel less perceptive.");
_mark_unseen_monsters();
}
break;
case SPARM_INVISIBILITY:
if (you.duration[DUR_INVIS]
&& !you.attribute[ATTR_INVIS_UNCANCELLABLE]
&& !you.evokable_invis())
{
you.duration[DUR_INVIS] = 1;
}
break;
case SPARM_STRENGTH:
notify_stat_change(STAT_STR, -3, false);
break;
case SPARM_DEXTERITY:
notify_stat_change(STAT_DEX, -3, false);
break;
case SPARM_INTELLIGENCE:
notify_stat_change(STAT_INT, -3, false);
break;
case SPARM_PONDEROUSNESS:
mpr("That put a bit of spring back into your step.");
break;
case SPARM_FLYING:
// Save current flight status so we can restore it on reequip
you.attribute[ATTR_LAST_FLIGHT_STATUS] =
you.attribute[ATTR_PERM_FLIGHT];