/
do_wear.c
2387 lines (2233 loc) · 59.8 KB
/
do_wear.c
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
/* SCCS Id: @(#)do_wear.c 3.4 2003/11/14 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#ifndef OVLB
STATIC_DCL long takeoff_mask, taking_off;
#else /* OVLB */
STATIC_OVL NEARDATA long takeoff_mask = 0L;
static NEARDATA long taking_off = 0L;
static NEARDATA int todelay;
static boolean cancelled_don = FALSE;
static NEARDATA const char see_yourself[] = "see yourself";
static NEARDATA const char unknown_type[] = "Unknown type of %s (%d)";
static NEARDATA const char c_armor[] = "armor",
c_suit[] = "suit",
#ifdef TOURIST
c_shirt[] = "shirt",
#endif
c_cloak[] = "cloak",
c_gloves[] = "gloves",
c_boots[] = "boots",
c_helmet[] = "helmet",
c_shield[] = "shield",
c_weapon[] = "weapon",
c_sword[] = "sword",
c_axe[] = "axe",
c_that_[] = "that";
static NEARDATA const long takeoff_order[] = { WORN_BLINDF, W_WEP,
WORN_SHIELD, WORN_GLOVES, LEFT_RING, RIGHT_RING, WORN_CLOAK,
WORN_HELMET, WORN_AMUL, WORN_ARMOR,
#ifdef TOURIST
WORN_SHIRT,
#endif
WORN_BOOTS, W_SWAPWEP, W_QUIVER, 0L };
STATIC_DCL void FDECL(on_msg, (struct obj *));
STATIC_DCL void FDECL(Ring_off_or_gone, (struct obj *, BOOLEAN_P));
STATIC_PTR int FDECL(select_off, (struct obj *));
STATIC_DCL struct obj *NDECL(do_takeoff);
STATIC_PTR int NDECL(take_off);
STATIC_DCL int FDECL(menu_remarm, (int));
STATIC_DCL void FDECL(already_wearing, (const char*));
STATIC_DCL void FDECL(already_wearing2, (const char*, const char*));
void
off_msg(otmp)
register struct obj *otmp;
{
if(flags.verbose)
You("were wearing %s.", doname(otmp));
}
/* for items that involve no delay */
STATIC_OVL void
on_msg(otmp)
register struct obj *otmp;
{
if (flags.verbose) {
char how[BUFSZ];
how[0] = '\0';
if (otmp->otyp == TOWEL)
Sprintf(how, " around your %s", body_part(HEAD));
You("are now wearing %s%s.",
obj_is_pname(otmp) ? the(xname(otmp)) : an(xname(otmp)),
how);
}
}
/*
* The Type_on() functions should be called *after* setworn().
* The Type_off() functions call setworn() themselves.
*/
int
Boots_on()
{
long oldprop =
u.uprops[objects[uarmf->otyp].oc_oprop].extrinsic & ~WORN_BOOTS;
switch(uarmf->otyp) {
case LOW_BOOTS:
case IRON_SHOES:
case HIGH_BOOTS:
case JUMPING_BOOTS:
case KICKING_BOOTS:
break;
case WATER_WALKING_BOOTS:
if (u.uinwater) spoteffects(TRUE);
break;
case SPEED_BOOTS:
/* Speed boots are still better than intrinsic speed, */
/* though not better than potion speed */
if (!oldprop && !(HFast & TIMEOUT)) {
makeknown(uarmf->otyp);
You_feel("yourself speed up%s.",
(oldprop || HFast) ? " a bit more" : "");
}
break;
case ELVEN_BOOTS:
if (!oldprop && !HStealth && !BStealth) {
makeknown(uarmf->otyp);
You("walk very quietly.");
}
break;
case FUMBLE_BOOTS:
if (!oldprop && !(HFumbling & ~TIMEOUT))
incr_itimeout(&HFumbling, rnd(20));
break;
case LEVITATION_BOOTS:
if (!oldprop && !HLevitation) {
flags.botl = 1;
makeknown(uarmf->otyp);
float_up();
spoteffects(FALSE);
}
break;
default: impossible(unknown_type, c_boots, uarmf->otyp);
}
return 0;
}
int
Boots_off()
{
int otyp = uarmf->otyp;
long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_BOOTS;
takeoff_mask &= ~W_ARMF;
/* For levitation, float_down() returns if Levitation, so we
* must do a setworn() _before_ the levitation case.
*/
setworn((struct obj *)0, W_ARMF);
switch (otyp) {
case SPEED_BOOTS:
if (!Very_fast && !cancelled_don) {
makeknown(otyp);
You_feel("yourself slow down%s.",
Fast ? " a bit" : "");
}
break;
case WATER_WALKING_BOOTS:
if (is_pool(u.ux,u.uy) && !Levitation && !Flying &&
!is_clinger(youmonst.data) && !cancelled_don) {
makeknown(otyp);
/* make boots known in case you survive the drowning */
spoteffects(TRUE);
}
break;
case ELVEN_BOOTS:
if (!oldprop && !HStealth && !BStealth && !cancelled_don) {
makeknown(otyp);
You("sure are noisy.");
}
break;
case FUMBLE_BOOTS:
if (!oldprop && !(HFumbling & ~TIMEOUT))
HFumbling = EFumbling = 0;
break;
case LEVITATION_BOOTS:
if (!oldprop && !HLevitation && !cancelled_don) {
flags.botl = 1;
(void) float_down(0L, 0L);
makeknown(otyp);
}
break;
case LOW_BOOTS:
case IRON_SHOES:
case HIGH_BOOTS:
case JUMPING_BOOTS:
case KICKING_BOOTS:
break;
default: impossible(unknown_type, c_boots, otyp);
}
cancelled_don = FALSE;
return 0;
}
int
Cloak_on()
{
long oldprop =
u.uprops[objects[uarmc->otyp].oc_oprop].extrinsic & ~WORN_CLOAK;
switch(uarmc->otyp) {
case ELVEN_CLOAK:
case CLOAK_OF_PROTECTION:
case CLOAK_OF_DISPLACEMENT:
makeknown(uarmc->otyp);
break;
case ORCISH_CLOAK:
case DWARVISH_CLOAK:
case CLOAK_OF_MAGIC_RESISTANCE:
case ROBE:
case LEATHER_CLOAK:
/* KMH, balance patch -- removed
case CLOAK_OF_DRAIN_RESISTANCE: */
break;
/* KMH, balance patch -- lab coat gives poison _and_ acid resistance */
case LAB_COAT:
EAcid_resistance |= WORN_CLOAK;
break;
case MUMMY_WRAPPING:
/* Note: it's already being worn, so we have to cheat here. */
if ((HInvis || EInvis || pm_invisible(youmonst.data)) && !Blind) {
newsym(u.ux,u.uy);
You("can %s!",
See_invisible ? "no longer see through yourself"
: see_yourself);
}
break;
case CLOAK_OF_INVISIBILITY:
/* since cloak of invisibility was worn, we know mummy wrapping
wasn't, so no need to check `oldprop' against blocked */
if (!oldprop && !HInvis && !Blind) {
makeknown(uarmc->otyp);
newsym(u.ux,u.uy);
pline("Suddenly you can%s yourself.",
See_invisible ? " see through" : "not see");
}
break;
case POISONOUS_CLOAK:
if (Poison_resistance)
pline("This cloak feels a little itchy.");
else {
makeknown(uarmc->otyp);
poisoned("cloak",A_STR,"poisonous cloak",3);
}
break;
case OILSKIN_CLOAK:
pline("%s very tightly.", Tobjnam(uarmc, "fit"));
break;
/* Alchemy smock gives poison _and_ acid resistance */
#if 0
case ALCHEMY_SMOCK:
EAcid_resistance |= WORN_CLOAK;
break;
#endif
default: impossible(unknown_type, c_cloak, uarmc->otyp);
}
return 0;
}
int
Cloak_off()
{
int otyp = uarmc->otyp;
long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_CLOAK;
takeoff_mask &= ~W_ARMC;
/* For mummy wrapping, taking it off first resets `Invisible'. */
setworn((struct obj *)0, W_ARMC);
switch (otyp) {
case ELVEN_CLOAK:
case ORCISH_CLOAK:
case DWARVISH_CLOAK:
case CLOAK_OF_PROTECTION:
case CLOAK_OF_MAGIC_RESISTANCE:
case CLOAK_OF_DISPLACEMENT:
case POISONOUS_CLOAK:
case OILSKIN_CLOAK:
case ROBE:
case LEATHER_CLOAK:
/* KMH, balance patch -- removed
case CLOAK_OF_DRAIN_RESISTANCE: */
break;
/* KMH, balance patch -- lab coat gives poison _and_ acid resistance */
case LAB_COAT:
EAcid_resistance &= ~WORN_CLOAK;
break;
case MUMMY_WRAPPING:
if (Invis && !Blind) {
newsym(u.ux,u.uy);
You("can %s.",
See_invisible ? "see through yourself"
: "no longer see yourself");
}
break;
case CLOAK_OF_INVISIBILITY:
if (!oldprop && !HInvis && !Blind) {
makeknown(CLOAK_OF_INVISIBILITY);
newsym(u.ux,u.uy);
pline("Suddenly you can %s.",
See_invisible ? "no longer see through yourself"
: see_yourself);
}
break;
#if 0
/* Alchemy smock gives poison _and_ acid resistance */
case ALCHEMY_SMOCK:
EAcid_resistance &= ~WORN_CLOAK;
break;
#endif
default: impossible(unknown_type, c_cloak, otyp);
}
return 0;
}
int
Helmet_on()
{
switch(uarmh->otyp) {
case FEDORA:
set_moreluck();
flags.botl = 1;
break;
case HELMET:
case DENTED_POT:
case ELVEN_LEATHER_HELM:
case DWARVISH_IRON_HELM:
case ORCISH_HELM:
/* KMH, balance patch -- removed
case FIRE_HELMET: */
case HELM_OF_TELEPATHY:
break;
case HELM_OF_BRILLIANCE:
adj_abon(uarmh, uarmh->spe);
break;
case CORNUTHAUM:
/* people think marked wizards know what they're talking
* about, but it takes trained arrogance to pull it off,
* and the actual enchantment of the hat is irrelevant.
*/
ABON(A_CHA) += (Role_if(PM_WIZARD) ? 1 : -1);
flags.botl = 1;
makeknown(uarmh->otyp);
break;
case HELM_OF_OPPOSITE_ALIGNMENT:
if (u.ualign.type == A_NEUTRAL)
u.ualign.type = rn2(2) ? A_CHAOTIC : A_LAWFUL;
else u.ualign.type = -(u.ualign.type);
u.ublessed = 0; /* lose your god's protection */
/* makeknown(uarmh->otyp); -- moved below, after xname() */
/*FALLTHRU*/
case DUNCE_CAP:
if (!uarmh->cursed) {
if (Blind)
pline("%s for a moment.", Tobjnam(uarmh, "vibrate"));
else
pline("%s %s for a moment.",
Tobjnam(uarmh, "glow"), hcolor(NH_BLACK));
curse(uarmh);
}
flags.botl = 1; /* reveal new alignment or INT & WIS */
if (Hallucination) {
pline("My brain hurts!"); /* Monty Python's Flying Circus */
} else if (uarmh->otyp == DUNCE_CAP) {
You_feel("%s.", /* track INT change; ignore WIS */
ACURR(A_INT) <= (ABASE(A_INT) + ABON(A_INT) + ATEMP(A_INT)) ?
"like sitting in a corner" : "giddy");
} else {
Your("mind oscillates briefly.");
makeknown(HELM_OF_OPPOSITE_ALIGNMENT);
}
break;
default: impossible(unknown_type, c_helmet, uarmh->otyp);
}
return 0;
}
int
Helmet_off()
{
takeoff_mask &= ~W_ARMH;
switch(uarmh->otyp) {
case FEDORA:
setworn((struct obj *)0, W_ARMH);
set_moreluck();
flags.botl = 1;
return 0;
case HELMET:
case DENTED_POT:
case ELVEN_LEATHER_HELM:
case DWARVISH_IRON_HELM:
case ORCISH_HELM:
/* KMH, balance patch -- removed
case FIRE_HELMET: */
break;
case DUNCE_CAP:
flags.botl = 1;
break;
case CORNUTHAUM:
if (!cancelled_don) {
ABON(A_CHA) += (Role_if(PM_WIZARD) ? -1 : 1);
flags.botl = 1;
}
break;
case HELM_OF_TELEPATHY:
/* need to update ability before calling see_monsters() */
setworn((struct obj *)0, W_ARMH);
see_monsters();
return 0;
case HELM_OF_BRILLIANCE:
if (!cancelled_don) adj_abon(uarmh, -uarmh->spe);
break;
case HELM_OF_OPPOSITE_ALIGNMENT:
u.ualign.type = u.ualignbase[A_CURRENT];
u.ublessed = 0; /* lose the other god's protection */
flags.botl = 1;
break;
default: impossible(unknown_type, c_helmet, uarmh->otyp);
}
setworn((struct obj *)0, W_ARMH);
cancelled_don = FALSE;
return 0;
}
int
Gloves_on()
{
long oldprop =
u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES;
switch(uarmg->otyp) {
case LEATHER_GLOVES:
break;
case GAUNTLETS_OF_SWIMMING:
if (u.uinwater) {
pline("Hey! You can swim!");
spoteffects(TRUE);
}
break;
case GAUNTLETS_OF_FUMBLING:
if (!oldprop && !(HFumbling & ~TIMEOUT))
incr_itimeout(&HFumbling, rnd(20));
break;
case GAUNTLETS_OF_POWER:
makeknown(uarmg->otyp);
flags.botl = 1; /* taken care of in attrib.c */
break;
case GAUNTLETS_OF_DEXTERITY:
adj_abon(uarmg, uarmg->spe);
break;
default: impossible(unknown_type, c_gloves, uarmg->otyp);
}
return 0;
}
int
Gloves_off()
{
long oldprop =
u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES;
takeoff_mask &= ~W_ARMG;
switch(uarmg->otyp) {
case LEATHER_GLOVES:
break;
case GAUNTLETS_OF_SWIMMING:
if (u.uinwater) {
You("begin to thrash about!");
spoteffects(TRUE);
}
break;
case GAUNTLETS_OF_FUMBLING:
if (!oldprop && !(HFumbling & ~TIMEOUT))
HFumbling = EFumbling = 0;
break;
case GAUNTLETS_OF_POWER:
makeknown(uarmg->otyp);
flags.botl = 1; /* taken care of in attrib.c */
break;
case GAUNTLETS_OF_DEXTERITY:
if (!cancelled_don) adj_abon(uarmg, -uarmg->spe);
break;
default: impossible(unknown_type, c_gloves, uarmg->otyp);
}
setworn((struct obj *)0, W_ARMG);
cancelled_don = FALSE;
(void) encumber_msg(); /* immediate feedback for GoP */
/* Prevent wielding cockatrice when not wearing gloves */
if (uwep && uwep->otyp == CORPSE &&
touch_petrifies(&mons[uwep->corpsenm])) {
char kbuf[BUFSZ];
You("wield the %s in your bare %s.",
corpse_xname(uwep, TRUE), makeplural(body_part(HAND)));
Strcpy(kbuf, an(killer_cxname(uwep, TRUE)));
instapetrify(kbuf);
uwepgone(); /* life-saved still doesn't allow touching cockatrice */
}
/* KMH -- ...or your secondary weapon when you're wielding it */
if (u.twoweap && uswapwep && uswapwep->otyp == CORPSE &&
touch_petrifies(&mons[uswapwep->corpsenm])) {
char kbuf[BUFSZ];
You("wield the %s in your bare %s.",
corpse_xname(uswapwep, TRUE), body_part(HAND));
Strcpy(kbuf, an(killer_cxname(uswapwep, TRUE)));
instapetrify(kbuf);
uswapwepgone(); /* lifesaved still doesn't allow touching cockatrice */
}
return 0;
}
int
Shield_on()
{
/*
switch (uarms->otyp) {
case SMALL_SHIELD:
case ELVEN_SHIELD:
case URUK_HAI_SHIELD:
case ORCISH_SHIELD:
case DWARVISH_ROUNDSHIELD:
case LARGE_SHIELD:
case SHIELD_OF_REFLECTION:
break;
default: impossible(unknown_type, c_shield, uarms->otyp);
}
*/
return 0;
}
int
Shield_off()
{
takeoff_mask &= ~W_ARMS;
/*
switch (uarms->otyp) {
case SMALL_SHIELD:
case ELVEN_SHIELD:
case URUK_HAI_SHIELD:
case ORCISH_SHIELD:
case DWARVISH_ROUNDSHIELD:
case LARGE_SHIELD:
case SHIELD_OF_REFLECTION:
break;
default: impossible(unknown_type, c_shield, uarms->otyp);
}
*/
setworn((struct obj *)0, W_ARMS);
return 0;
}
#ifdef TOURIST
int
Shirt_on()
{
/*
switch (uarmu->otyp) {
case HAWAIIAN_SHIRT:
case T_SHIRT:
break;
default: impossible(unknown_type, c_shirt, uarmu->otyp);
}
*/
return 0;
}
int
Shirt_off()
{
takeoff_mask &= ~W_ARMU;
/*
switch (uarmu->otyp) {
case HAWAIIAN_SHIRT:
case T_SHIRT:
break;
default: impossible(unknown_type, c_shirt, uarmu->otyp);
}
*/
setworn((struct obj *)0, W_ARMU);
return 0;
}
#endif /*TOURIST*/
/* This must be done in worn.c, because one of the possible intrinsics conferred
* is fire resistance, and we have to immediately set HFire_resistance in worn.c
* since worn.c will check it before returning.
*/
int
Armor_on()
{
/* KMH -- certain armor is obvious when worn */
switch (uarm->otyp) {
case ROBE_OF_PROTECTION:
case ROBE_OF_WEAKNESS:
makeknown(uarm->otyp);
break;
}
return 0;
}
int
Armor_off()
{
takeoff_mask &= ~W_ARM;
setworn((struct obj *)0, W_ARM);
cancelled_don = FALSE;
return 0;
}
/* The gone functions differ from the off functions in that if you die from
* taking it off and have life saving, you still die.
*/
int
Armor_gone()
{
takeoff_mask &= ~W_ARM;
setnotworn(uarm);
cancelled_don = FALSE;
return 0;
}
void
Amulet_on()
{
switch(uamul->otyp) {
case AMULET_OF_ESP:
#if 0 /* OBSOLETE */
if(uamul->oartifact == ART_MEDALLION_OF_SHIFTERS) rescham();
#endif
case AMULET_OF_LIFE_SAVING:
case AMULET_VERSUS_POISON:
case AMULET_OF_DRAIN_RESISTANCE:
case AMULET_OF_REFLECTION:
case AMULET_OF_MAGICAL_BREATHING:
/* KMH, balance patch -- removed
case AMULET_OF_REGENERATION:
case AMULET_OF_CONFLICT:*/
case FAKE_AMULET_OF_YENDOR:
break;
case AMULET_OF_UNCHANGING:
if (Slimed) {
Slimed = 0;
flags.botl = 1;
}
break;
case AMULET_OF_CHANGE:
{
int orig_sex = poly_gender();
if (Unchanging) break;
change_sex();
/* Don't use same message as polymorph */
if (orig_sex != poly_gender()) {
makeknown(AMULET_OF_CHANGE);
You("are suddenly very %s!", flags.female ? "feminine"
: "masculine");
flags.botl = 1;
} else
/* already polymorphed into single-gender monster; only
changed the character's base sex */
You("don't feel like yourself.");
pline_The("amulet disintegrates!");
if (orig_sex == poly_gender() && uamul->dknown &&
!objects[AMULET_OF_CHANGE].oc_name_known &&
!objects[AMULET_OF_CHANGE].oc_uname)
docall(uamul);
useup(uamul);
break;
}
/* KMH, balance patch -- removed
case AMULET_OF_POLYMORPH:
makeknown(AMULET_OF_POLYMORPH);
You("feel rather strange.");
polyself();
flags.botl = 1;
pline("The amulet disintegrates!");
useup(uamul);
break;*/
case AMULET_OF_STRANGULATION:
makeknown(AMULET_OF_STRANGULATION);
pline("It constricts your throat!");
Strangled = 6;
break;
case AMULET_OF_RESTFUL_SLEEP:
if(uamul->blessed) {
char buf[BUFSZ];
int sleeptime;
makeknown(AMULET_OF_RESTFUL_SLEEP);
do {
getlin("How many moves do you wish to sleep for? [1-500]", buf);
sleeptime = (!*buf || *buf=='\033') ? 0 : atoi(buf);
} while (sleeptime < 1 || sleeptime > 500);
if (sleeptime > 0) {
You("sit down and fall asleep.");
nomul(-sleeptime);
u.usleep = 1;
nomovemsg = "You wake up from your refreshing nap.";
HSleeping = rnd(100);
}
} else HSleeping = rnd(100);
break;
case AMULET_OF_YENDOR:
break;
/* KMH, balance patch -- added */
case AMULET_VERSUS_STONE:
uunstone();
break;
case AMULET_OF_FLYING:
if (!(EFlying & ~W_AMUL) && !is_flyer(youmonst.data)) {
You_feel("like flying!");
if (!Levitation)
float_up();
makeknown(AMULET_OF_FLYING);
}
break;
}
}
void
Amulet_off()
{
takeoff_mask &= ~W_AMUL;
switch(uamul->otyp) {
case AMULET_OF_ESP:
/* need to update ability before calling see_monsters() */
#if 0 /* OBSOLETE */
if(uamul->oartifact == ART_MEDALLION_OF_SHIFTERS) restartcham();
#endif
setworn((struct obj *)0, W_AMUL);
see_monsters();
return;
case AMULET_OF_LIFE_SAVING:
case AMULET_VERSUS_POISON:
case AMULET_OF_DRAIN_RESISTANCE:
/* KMH, balance patch -- removed
case AMULET_OF_REGENERATION:
case AMULET_OF_CONFLICT:*/
/* KMH, balance patch -- added */
case AMULET_VERSUS_STONE:
case AMULET_OF_REFLECTION:
case AMULET_OF_CHANGE:
case AMULET_OF_UNCHANGING:
case FAKE_AMULET_OF_YENDOR:
break;
case AMULET_OF_MAGICAL_BREATHING:
if (Underwater) {
/* HMagical_breathing must be set off
before calling drown() */
setworn((struct obj *)0, W_AMUL);
if (!breathless(youmonst.data) && !amphibious(youmonst.data)
&& !Swimming) {
You("suddenly inhale an unhealthy amount of water!");
(void) drown();
}
return;
}
break;
case AMULET_OF_STRANGULATION:
if (Strangled) {
You("can breathe more easily!");
Strangled = 0;
}
break;
case AMULET_OF_RESTFUL_SLEEP:
setworn((struct obj *)0, W_AMUL);
if (!ESleeping)
HSleeping = 0;
return;
/* KMH, balance patch -- added */
case AMULET_OF_FLYING:
setworn((struct obj *)0, W_AMUL);
(void) float_down(0L, 0L);
return;
case AMULET_OF_YENDOR:
break;
}
setworn((struct obj *)0, W_AMUL);
return;
}
void
Ring_on(obj)
register struct obj *obj;
{
long oldprop = u.uprops[objects[obj->otyp].oc_oprop].extrinsic;
int old_attrib, which;
if (obj == uwep) setuwep((struct obj *) 0, TRUE);
if (obj == uswapwep) setuswapwep((struct obj *) 0, TRUE);
if (obj == uquiver) setuqwep((struct obj *) 0);
/* only mask out W_RING when we don't have both
left and right rings of the same type */
if ((oldprop & W_RING) != W_RING) oldprop &= ~W_RING;
switch(obj->otyp){
case RIN_TELEPORTATION:
case RIN_REGENERATION:
case RIN_SEARCHING:
case RIN_STEALTH:
case RIN_HUNGER:
case RIN_AGGRAVATE_MONSTER:
case RIN_POISON_RESISTANCE:
case RIN_FIRE_RESISTANCE:
case RIN_COLD_RESISTANCE:
case RIN_SHOCK_RESISTANCE:
case RIN_CONFLICT:
case RIN_TELEPORT_CONTROL:
case RIN_POLYMORPH:
case RIN_POLYMORPH_CONTROL:
/* KMH, balance patch -- now an amulet
case RIN_DRAIN_RESISTANCE: */
/* KMH -- added */
case RIN_MOOD:
case RIN_FREE_ACTION:
case RIN_SLOW_DIGESTION:
case RIN_SUSTAIN_ABILITY:
case MEAT_RING:
break;
case RIN_SLEEPING:
HSleeping = rnd(100);
break;
#if 0
case RIN_INDIGESTION:
incr_itimeout(&HIndigestion, rnd(20));
break;
#endif
case RIN_WARNING:
see_monsters();
break;
case RIN_SEE_INVISIBLE:
/* can now see invisible monsters */
set_mimic_blocking(); /* do special mimic handling */
see_monsters();
#ifdef INVISIBLE_OBJECTS
see_objects();
#endif
if (Invis && !oldprop && !HSee_invisible &&
!perceives(youmonst.data) && !Blind) {
newsym(u.ux,u.uy);
pline("Suddenly you are transparent, but there!");
makeknown(RIN_SEE_INVISIBLE);
}
break;
case RIN_INVISIBILITY:
if (!oldprop && !HInvis && !BInvis && !Blind) {
makeknown(RIN_INVISIBILITY);
newsym(u.ux,u.uy);
self_invis_message();
}
break;
case RIN_LEVITATION:
if (!oldprop && !HLevitation) {
flags.botl = 1;
float_up();
makeknown(RIN_LEVITATION);
spoteffects(FALSE); /* for sinks */
}
break;
case RIN_GAIN_STRENGTH:
which = A_STR;
goto adjust_attrib;
case RIN_GAIN_CONSTITUTION:
which = A_CON;
goto adjust_attrib;
case RIN_ADORNMENT:
which = A_CHA;
adjust_attrib:
old_attrib = ACURR(which);
ABON(which) += obj->spe;
if (ACURR(which) != old_attrib ||
(objects[obj->otyp].oc_name_known &&
old_attrib != 25 && old_attrib != 3)) {
flags.botl = 1;
makeknown(obj->otyp);
obj->known = 1;
update_inventory();
}
break;
case RIN_GAIN_INTELLIGENCE:
ABON(A_INT) += obj->spe;
flags.botl = 1;
if (obj->spe || objects[RIN_GAIN_INTELLIGENCE].oc_name_known) {
makeknown(RIN_GAIN_INTELLIGENCE);
obj->known = TRUE;
}
break;
case RIN_GAIN_WISDOM:
ABON(A_WIS) += obj->spe;
flags.botl = 1;
if (obj->spe || objects[RIN_GAIN_WISDOM].oc_name_known) {
makeknown(RIN_GAIN_WISDOM);
obj->known = TRUE;
}
break;
case RIN_GAIN_DEXTERITY:
ABON(A_DEX) += obj->spe;
flags.botl = 1;
if (obj->spe || objects[RIN_GAIN_DEXTERITY].oc_name_known) {
makeknown(RIN_GAIN_DEXTERITY);
obj->known = TRUE;
}
break;
case RIN_INCREASE_ACCURACY: /* KMH */
u.uhitinc += obj->spe;
break;
case RIN_INCREASE_DAMAGE:
u.udaminc += obj->spe;
break;
case RIN_PROTECTION_FROM_SHAPE_CHAN:
rescham();
break;
case RIN_PROTECTION:
if (obj->spe || objects[RIN_PROTECTION].oc_name_known) {
flags.botl = 1;
makeknown(RIN_PROTECTION);
obj->known = 1;
update_inventory();
}
break;
}
}
STATIC_OVL void
Ring_off_or_gone(obj,gone)
register struct obj *obj;
boolean gone;
{
long mask = (obj->owornmask & W_RING);
int old_attrib, which;
takeoff_mask &= ~mask;
if(!(u.uprops[objects[obj->otyp].oc_oprop].extrinsic & mask))
impossible("Strange... I didn't know you had that ring.");
if(gone) setnotworn(obj);
else setworn((struct obj *)0, obj->owornmask);
switch(obj->otyp) {
case RIN_TELEPORTATION:
case RIN_REGENERATION:
case RIN_SEARCHING:
case RIN_STEALTH:
case RIN_HUNGER:
case RIN_AGGRAVATE_MONSTER:
case RIN_POISON_RESISTANCE:
case RIN_FIRE_RESISTANCE:
case RIN_COLD_RESISTANCE:
case RIN_SHOCK_RESISTANCE:
case RIN_CONFLICT:
case RIN_TELEPORT_CONTROL:
case RIN_POLYMORPH:
case RIN_POLYMORPH_CONTROL:
/* KMH, balance patch -- now an amulet
case RIN_DRAIN_RESISTANCE: */
/* KMH, balance patch -- added */
case RIN_MOOD:
case RIN_FREE_ACTION:
case RIN_SLOW_DIGESTION:
case RIN_SUSTAIN_ABILITY:
case MEAT_RING:
break;
case RIN_SLEEPING:
if (!ESleeping)
HSleeping = 0;
break;
#if 0
case RIN_INDIGESTION:
if (!EIndigestion)
HIndigestion = 0;
break;
#endif
case RIN_WARNING:
see_monsters();
break;
case RIN_SEE_INVISIBLE:
/* Make invisible monsters go away */
if (!See_invisible) {
set_mimic_blocking(); /* do special mimic handling */
see_monsters();
#ifdef INVISIBLE_OBJECTS
see_objects();
#endif
}
if (Invisible && !Blind) {
newsym(u.ux,u.uy);
pline("Suddenly you cannot see yourself.");
makeknown(RIN_SEE_INVISIBLE);
}
break;
case RIN_INVISIBILITY:
if (!Invis && !BInvis && !Blind) {
newsym(u.ux,u.uy);
Your("body seems to unfade%s.",
See_invisible ? " completely" : "..");
makeknown(RIN_INVISIBILITY);
}
break;
case RIN_LEVITATION: