-
Notifications
You must be signed in to change notification settings - Fork 1
/
artifact.c
1758 lines (1661 loc) · 40.2 KB
/
artifact.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
/*
artifact.c - This file contains functions for dealing with artifacts
UltraRogue
Copyright (C) 1985 Herb Chong
All rights reserved.
Based on "Advanced Rogue"
Copyright (C) 1982, 1984, 1985 Michael Morgan, Ken Dalka and AT&T
All rights reserved.
See the file LICENSE.TXT for full copyright and licensing information.
*/
#include <string.h>
#include <stdlib.h>
#include "curses.h"
#include <ctype.h>
#include "rogue.h"
#define SIZE(array) (sizeof (array) / sizeof (*(array)))
int inbag;
char bag_letters[] = "zyxwvutsrqponmlkjihgfedcba";
char *bag_index = bag_letters + SIZE(bag_letters) - 1;
char *bag_end = bag_letters + SIZE(bag_letters) - 1;
/*
* apply an artifact
*/
void
apply(void)
{
register struct linked_list *item;
register struct object *obj;
register int which;
int chance;
if ((item = get_item("apply", ARTIFACT)) == NULL)
return;
obj = (struct object *) ldata(item);
which = obj->o_which;
if (!(obj->art_stats.ar_flags & ISACTIVE)) {
chance = rnd(100);
if (wizard) {
msg("What roll? ");
if(get_str(prbuf,msgw) == NORM) {
chance = atoi(prbuf);
if(chance < 0 || chance > 99) {
msg("Invalid selection.");
chance = rnd(100);
}
}
}
debug("Rolled %d.", chance);
if (chance < 65)
do_minor(obj);
else if (chance < 80)
do_major();
else
obj->art_stats.ar_flags |= ISACTIVE;
}
if (obj->art_stats.ar_flags & ISACTIVE) {
switch (which) {
when TR_PURSE:
do_bag(obj);
when TR_PHIAL:
do_phial();
when TR_AMULET:
do_amulet();
when TR_PALANTIR:
do_palantir();
when TR_CROWN:
do_crown();
when TR_SCEPTRE:
do_sceptre();
when TR_SILMARIL:
do_silmaril();
when TR_WAND:
do_wand();
otherwise:
msg("Nothing happens.");
return;
}
}
if (rnd(pstats.s_lvl) < 8)
do_minor(obj);
turn_on(player, POWEREAT);
}
/*
* was the hero carrying a particular artifact
*/
int
possessed(int artifact)
{
if ((picked_artifact >> artifact) & 1)
return TRUE;
else
return FALSE;
}
/*
* is the hero carrying a particular artifact
*/
int
is_carrying(int artifact)
{
if ((has_artifact >> artifact) & 1)
return TRUE;
else
return FALSE;
}
/*
* is it time to make a new artifact?
*/
int
make_artifact(void)
{
int i;
mpos = 0;
debug("Artifact possession and picked flags : %x %x.",
has_artifact, picked_artifact);
for(i = 0; i < MAXARTIFACT; i++) {
if (!possessed(i) && arts[i].ar_level <= level)
return TRUE;
}
return FALSE;
}
/*
* make a specified artifact
*/
void
new_artifact(int which, struct object *cur)
{
if (which >= MAXARTIFACT) {
debug("Bad artifact %d. Random one created.", which);
which = rnd(MAXARTIFACT);
}
if (which < 0) {
for(which = 0; which < MAXARTIFACT; which++)
if (!possessed(which) && arts[which].ar_level <= level)
break;
}
debug("Artifact number: %d.", which);
cur->o_hplus = cur->o_dplus = 0;
strcpy(cur->o_damage, "0d0");
strcpy(cur->o_hurldmg, "0d0");
cur->o_ac = 11;
cur->o_mark[0] = '\0';
cur->o_type = ARTIFACT;
cur->o_which = which;
cur->o_weight = arts[which].ar_weight;
cur->o_flags = 0;
cur->o_group = 0;
cur->o_count = 1;
cur->art_stats.ar_flags = 0;
cur->art_stats.ar_rings = 0;
cur->art_stats.ar_potions = 0;
cur->art_stats.ar_scrolls = 0;
cur->art_stats.ar_wands = 0;
cur->art_stats.t_art = NULL;
return;
}
/*
* do_minor: side effects and minor malevolent effects of artifacts
*/
void
do_minor(struct object *tr)
{
register int which;
which = rnd(110);
if (wizard) {
msg("Which minor effect? (%d)", which);
if(get_str(prbuf,msgw) == NORM) {
which = atoi(prbuf);
if(which < 0 || which > 109) {
msg("Invalid selection.");
which = rnd(110);
}
}
}
debug("Rolled %d.", which);
switch(which) {
when 0:
if (off(player, ISBLIND))
msg("You develop some acne on your face.");
when 1:
if (on(player, CANSCENT)) {
msg("A sudden whiff of BO causes you to faint.");
no_command = STONETIME;
}
else if (off(player, ISUNSMELL))
msg("You begin to smell funny.");
when 2:
if(off(player, ISBLIND))
msg("A wart grows on the end of your nose.");
when 3:
if (off(player, ISDEAF))
msg("Your hear strange noises in the distance.");
when 4:
if (off(player, ISDEAF))
msg("You hear shuffling in the distance.");
when 5:
if (off(player, ISDEAF))
msg("You hear clanking in the distance.");
when 6:
if (off(player, ISDEAF))
msg("You hear water dripping onto the floor.");
when 7:
if (off(player, ISDEAF))
msg("The dungeon goes strangely silent.");
when 8:
msg("You suddenly feel very warm.");
when 9:
msg("You feel very hot.");
when 10:
msg("A blast of heat hits you.");
when 11: {
register struct room *rp;
static coord fpos;
if (off(player, ISBLIND))
msg("A pillar of flame leaps up beside you.");
else
msg("You feel something very hot nearby.");
rp = roomin(&hero);
if (ntraps + 1 < MAXTRAPS + MAXTRAPS&&
fallpos(&hero, &fpos, TRUE)) {
mvaddch(fpos.y, fpos.x, FIRETRAP);
traps[ntraps].tr_type = FIRETRAP;
traps[ntraps].tr_flags = ISFOUND;
traps[ntraps].tr_show = FIRETRAP;
traps[ntraps].tr_pos.y = fpos.y;
traps[ntraps++].tr_pos.x = fpos.x;
if (rp != NULL) {
rp->r_flags &= ~ISDARK;
light(&hero);
mvwaddch(cw, hero.y, hero.x, PLAYER) ;
}
}
}
when 12:
msg("You feel a blast of hot air.");
when 13:
msg("You feel very cold.");
when 14:
msg("You break out in a cold sweat.");
when 15:
if (off(player, ISBLIND) && cur_armor == NULL)
msg("You are covered with frost.");
else if(off(player, ISBLIND))
msg("Your armor is covered with frost.");
else if (cur_armor == NULL)
msg("Your body feels very cold and you begin to shiver.");
else
msg("Your armor feels very cold. You hear cracking ice.");
when 16:
msg("A cold wind whistles through the dungeon.");
when 17: {
register int change;
change = 18 - pstats.s_str;
chg_str(change, TRUE, FALSE);
chg_dext(-change, TRUE, FALSE);
if (change > 0)
msg("You feel stronger and clumsier now.");
else if (change < 0)
msg("You feel weaker and more dextrous now.");
else
msg("Nothing happens.");
}
when 18:
msg("You begin to itch all over.");
when 19:
msg("You begin to feel hot and itchy.");
when 20:
msg("You feel a burning itch.");
chg_dext(-1, FALSE, TRUE);
if (off(player, HASITCH)) {
turn_on(player, HASITCH);
fuse(un_itch, 0, roll(4,6), AFTER);
}
else
lengthen(un_itch, roll(4,6));
when 21:
if (off(player, ISBLIND))
msg("Your skin begins to flake and peel.");
else
msg("You feel an urge to scratch an itch.");
when 22:
if (off(player, ISBLIND))
msg("Your hair begins to turn grey.");
when 23:
if (off(player, ISBLIND))
msg("Your hair begins to turn white.");
when 24:
if (off(player, ISBLIND))
msg("Some of your hair instantly turns white.");
when 25:
if (off(player, ISBLIND))
msg("You are covered with long white hair.");
when 26:
if (off(player, ISBLIND))
msg("You are covered with long red hair.");
when 27:
msg("You grow a beard.");
when 28:
msg("Your hair falls out.");
when 29:
msg("You feel a burning down below.");
when 30:
msg("Your toes fall off.");
when 31:
msg("You grow some extra toes.");
when 32:
msg("You grow some extra fingers.");
when 33:
msg("You grow an extra thumb.");
when 34:
msg("Your nose falls off.");
when 35:
msg("Your nose gets bigger.");
when 36:
msg("Your nose shrinks.");
when 37:
msg("An eye grows on your forehead.");
when 38:
if(off(player, ISBLIND))
msg("You see beady eyes watching from a distance.");
when 39:
msg("The dungeon rumbles for a moment.");
when 40:
if (off(player, ISBLIND))
msg("A flower grows on the floor next to you.");
when 41:
msg("You are stunned by a psionic blast.");
if (on(player, ISHUH))
lengthen(unconfuse, rnd(40)+(HUHDURATION*3));
else {
fuse(unconfuse, 0, rnd(40)+(HUHDURATION*3), AFTER);
turn_on(player, ISHUH);
}
when 42:
msg("You are confused by thousands of voices in your head.");
if (on(player, ISHUH))
lengthen(unconfuse, rnd(10)+(HUHDURATION*2));
else {
fuse(unconfuse, 0, rnd(10)+(HUHDURATION*2), AFTER);
turn_on(player, ISHUH);
}
when 43:
if (off(player, ISDEAF))
msg("You hear voices in the distance.");
when 44:
msg("You feel a strange pull.");
teleport();
if (off(player, ISCLEAR)) {
if (on(player, ISHUH))
lengthen(unconfuse, rnd(8)+HUHDURATION);
else {
fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER);
turn_on(player, ISHUH);
}
}
when 45:
msg("You feel less healthy now.");
pstats.s_const = max(pstats.s_const - 1, 3);
max_stats.s_const = max(max_stats.s_const - 1, 3);
when 46:
msg("You feel weaker now.");
chg_str(-1, TRUE, FALSE);
when 47:
msg("You feel less wise now.");
pstats.s_wisdom = max(pstats.s_wisdom - 1, 3);
max_stats.s_wisdom = max(max_stats.s_wisdom - 1, 3);
when 48:
msg("You feel less dextrous now.");
chg_dext(-1, TRUE, FALSE);
when 49:
msg("You feel less intelligent now.");
pstats.s_intel = max(pstats.s_intel - 1, 3);
max_stats.s_intel = max(max_stats.s_intel - 1, 3);
when 50:
msg("A trap door opens underneath your feet.");
mpos = 0;
level++;
new_level(NORMLEV);
if (rnd(4) < 2) {
addmsg("You are damaged by the fall");
if ((pstats.s_hpt -= roll(1,6)) <= 0) {
addmsg("! The fall killed you.");
endmsg();
death(D_FALL);
return;
}
}
addmsg("!");
endmsg();
if (off(player, ISCLEAR) && rnd(4) < 3)
{
if (on(player, ISHUH))
lengthen(unconfuse, rnd(8)+HUHDURATION);
else
fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER);
turn_on(player, ISHUH);
}
else msg("You feel dizzy for a moment, but it quickly passes.");
when 51:
msg("A maze entrance opens underneath your feet.");
mpos = 0;
level++;
new_level(MAZELEV);
if (rnd(4) < 2) {
addmsg("You are damaged by the fall");
if ((pstats.s_hpt -= roll(1,6)) <= 0) {
addmsg("! The fall killed you.");
endmsg();
death(D_FALL);
return;
}
}
addmsg("!");
endmsg();
if (off(player, ISCLEAR) && rnd(4) < 3)
{
if (on(player, ISHUH))
lengthen(unconfuse, rnd(8)+HUHDURATION);
else
fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER);
turn_on(player, ISHUH);
}
else msg("You feel dizzy for a moment, but it quickly passes.");
when 52:
if (off(player, ISDEAF))
msg("You hear a wailing sound in the distance.");
aggravate();
when 53:
if (off(player, ISDEAF))
msg("You hear a high pitched whining sound.");
aggravate();
when 54:
msg("You can't move.");
no_command = 3 * HOLDTIME;
when 55:
if (off(player, ISDEAF))
msg("You hear a buzzing sound.");
aggravate();
when 56:
msg("Your limbs stiffen.");
no_command = 3 * STONETIME;
when 57:
msg("You feel a rock in your shoe hurting your foot.");
turn_on(player, STUMBLER);
when 58:
msg("You get a hollow feeling in your stomach.");
food_left -= 500;
when 59:
msg("Your purse feels lighter.");
purse = max(purse - 50 - rnd(purse/2), 0);
when 60:
msg("A pixie appears and grabs gold from your purse.");
purse = max(purse - 50 - rnd(50), 0);
when 61:
msg("You feel a tingling sensation all over.");
pstats.s_hpt -= rnd(pstats.s_hpt/3);
when 62:
msg("You feel a pull downwards.");
when 63:
msg("You feel a strange pull downwards.");
when 64:
msg("You feel a peculiar pull downwards.");
when 65:
msg("You have astrange urge to go down.");
when 66:
msg("You feel a pull upwards.");
when 67:
msg("You feel a strange pull upwards.");
when 68:
msg("You have a strange feeling for a moment.");
when 69:
msg("You float in the air for a moment.");
when 70:
msg("You feel very heavy for a moment.");
when 71:
msg("You feel a strange sense of loss.");
when 72:
msg("You feel the earth spinning underneath your feet.");
when 73:
msg("You feel in touch with a Universal Oneness.");
when 74:
if (off(player, ISDEAF))
msg("You hear voices in the distance.");
when 75:
msg("A strange feeling of power comes over you.");
when 76:
msg("You feel a strange sense of unease.");
when 77:
msg("You feel Lady Luck is looking the other way.");
luck++;
when 78:
msg("You feel your pack vibrate for a moment.");
when 79:
msg("You feel someone is watching you.");
when 80:
msg("You feel your hair standing on end.");
when 81:
msg("Wait! The walls are moving!");
new_level(NORMLEV);
when 82:
msg("Wait! Walls are appearing out of nowhere!");
new_level(MAZELEV);
when 83:
blue_light(FALSE, TRUE);
when 84:
msg("Your mind goes blank for a moment.");
wclear(cw);
light(&hero);
status(TRUE);
when 85:
if (on(player, ISDEAF)) {
msg("You feel your ears burn for a moment.");
lengthen(hear, 2*PHASEDURATION);
}
else {
msg("You are suddenly surrounded by silence.");
turn_on(player, ISDEAF);
fuse(hear, 0, 2*PHASEDURATION, AFTER);
}
when 86: {
register struct linked_list *item;
register struct object *obj;
for (item = pack; item != NULL; item = next(item)) {
obj = OBJPTR(item);
if (obj->o_type != ARTIFACT && rnd(8) == 0) {
obj->o_flags |= ISCURSED;
obj->o_flags &= ~ISBLESSED;
}
}
if (off(player, ISUNSMELL))
msg("You smell a faint trace of burning sulfur.");
}
when 87:
msg("You have contracted a parasitic infestation.");
infest_dam++;
turn_on(player, HASINFEST);
when 88: {
static coord fear;
msg("You suddenly feel a chill run up and down your spine.");
turn_on(player, ISFLEE);
fallpos(&hero, &fear, TRUE);
player.t_dest = &fear;
}
when 89:
if (cur_weapon != NULL)
msg("You feel your %s get very hot.",
inv_name(cur_weapon, TRUE));
when 90:
if (cur_weapon != NULL)
msg("Your %s glows white for an instant.",
inv_name(cur_weapon, TRUE));
when 91:
if (cur_armor != NULL)
msg("Your %s gets very hot.", inv_name(cur_armor, TRUE));
when 92:
if (cur_weapon != NULL)
msg("Your %s suddenly feels very cold.",
inv_name(cur_weapon, TRUE));
when 93:
if (cur_armor != NULL)
msg("Your armor is covered by an oily film.");
when 94:
read_scroll(S_CREATE, FALSE);
when 95:
lower_level(D_POTION);
when 96: {
register int x, y;
for (x = -1; x <= 1; x++) {
for (y = -1; y <= 1; y++) {
if (x == 0 && y == 0)
continue;
delta.x = x;
delta.y = y;
do_zap(TRUE, WS_POLYMORPH, FALSE);
}
}
}
when 97: {
register int x, y;
for (x = -1; x <= 1; x++) {
for (y = -1; y <= 1; y++) {
if (x == 0 && y == 0)
continue;
delta.x = x;
delta.y = y;
do_zap(TRUE, WS_INVIS, FALSE);
}
}
}
otherwise:
tr->art_stats.ar_flags &= ~ISACTIVE;
msg("You hear a click coming from %s.", inv_name(tr, TRUE));
}
}
/*
* do_major: major malevolent effects
*/
void
do_major(void)
{
register int which;
which = rnd(12);
if (wizard) {
msg("Which major effect? (%d)", which);
if(get_str(prbuf,msgw) == NORM) {
which = atoi(prbuf);
if(which < 0 || which > 11) {
msg("Invalid selection.");
which = rnd(12);
}
}
}
debug("Rolled %d.", which);
switch (which) {
when 0:
level = level * 3 + 10 + rnd(10);
new_level(NORMLEV);
mpos = 0;
msg("You are banished to the lower regions.");
when 1:
if (on(player, ISBLIND)) {
msg("The cloak of darkness deepens.");
extinguish(sight);
fuse(sight, 0, 4*SEEDURATION, AFTER);
}
else {
msg("A cloak of darkness falls around you.");
fuse(sight, 0, 2*SEEDURATION, AFTER);
}
turn_on(player, ISBLIND);
turn_on(player, PERMBLIND);
look(FALSE);
when 2:
new_level(THRONE);
when 3:
msg("You feel very warm all over.");
turn_on(player, SUPEREAT);
when 4:
msg("You feel yourself moving %sslower.",
on(player, ISSLOW) ? "even " : "");
if (on(player, ISSLOW))
lengthen(noslow, 20 + rnd(20));
else {
turn_on(player, ISSLOW);
player.t_turn = TRUE;
fuse(noslow, 0, 20 + rnd(20), AFTER);
}
when 5: {
register int num, i;
num = roll(1,4);
for (i = 1; i < num; i++)
lower_level(D_POTION);
}
when 6:
if (rnd(2))
add_intelligence(TRUE);
if (rnd(2))
chg_dext(-1, TRUE, FALSE);
if (rnd(2))
chg_str(-1, TRUE, FALSE);
if (rnd(2))
add_wisdom(TRUE);
if (rnd(2))
add_const(TRUE);
when 7: {
static coord fires;
register struct room *rp;
if (ntraps + 1 >= MAXTRAPS) {
msg("You feel a puff of hot air.");
return;
}
for (; ntraps < MAXTRAPS + MAXTRAPS; ntraps++) {
if (!fallpos(&hero, &fires, TRUE))
break;
mvaddch(fires.y, fires.x, FIRETRAP);
traps[ntraps].tr_type = FIRETRAP;
traps[ntraps].tr_flags |= ISFOUND;
traps[ntraps].tr_show = FIRETRAP;
traps[ntraps].tr_pos.x = fires.x;
traps[ntraps].tr_pos.y = fires.y;
if ((rp = roomin(&hero)) != NULL)
rp->r_flags &= ~ISDARK;
}
}
when 8: {
register struct linked_list *item;
register struct object *obj = NULL;
if (cur_weapon == NULL) {
msg("You feel your hands tingle a moment.");
return;
}
for (item = pack; item != NULL; item = next(item))
if ((obj = OBJPTR(item)) == cur_weapon)
break;
if (obj->o_flags & ISMETAL)
msg("Your %s melts and disappears.", inv_name(obj, TRUE));
else
msg("Your %s crumbles in your hands.",
inv_name(obj, TRUE));
obj->o_flags &= ~ISCURSED;
dropcheck(obj);
detach(pack, item);
freeletter(item);
inpack--;
discard(item);
}
when 9: {
register struct linked_list *item;
register struct object *obj = NULL;
if (cur_armor == NULL) {
msg("Your body tingles a moment.");
return;
}
for (item = pack; item != NULL; item = next(item))
if ((obj = OBJPTR(item)) == cur_armor)
break;
msg("Your %s crumbles into small black powdery dust.",
inv_name(obj, TRUE));
obj->o_flags &= ~ISCURSED;
dropcheck(obj);
detach(pack, item);
freeletter(item);
inpack--;
discard(item);
}
otherwise:
if (cur_weapon == NULL) {
msg("Your hand glows yellow for an instant.");
return;
}
msg("Your %s glows bright red for a moment.",
weaps[cur_weapon->o_which].w_name);
if (cur_weapon->o_hplus > 0)
cur_weapon->o_hplus = -rnd(3);
else
cur_weapon->o_hplus -= rnd(3);
if (cur_weapon->o_dplus > 0)
cur_weapon->o_dplus = -rnd(3);
else
cur_weapon->o_dplus -= rnd(3);
cur_weapon->o_flags |= ISCURSED;
cur_weapon->o_flags |= ISLOST;
cur_weapon->o_flags &= ~ISOWNED;
cur_weapon->o_flags &= ~CANRETURN;
cur_weapon->o_flags &= ~ISPOISON;
cur_weapon->o_flags &= ~ISZAPPED;
cur_weapon->o_flags &= ~ISKNOW;
cur_weapon->o_flags &= ~ISPROT;
cur_weapon->o_flags &= ~ISSILVER;
cur_weapon->o_flags &= ~CANBURN;
cur_weapon->o_flags &= ~ISHOLY;
cur_weapon->o_ac = 0;
}
}
/*
* do_phial: handle powers of the Phial of Galadriel
*/
void
do_phial(void)
{
register int which;
/* Prompt for action */
msg("How do you wish to apply the Phial of Galadriel? (* for list): ");
which = ((readchar(msgw) & 0177) - 'a');
if (which == ESCAPE - 'a') {
after = FALSE;
return;
}
if (which < 0 || which > 1) {
msg("");
clearok(cw, TRUE);
touchwin(cw);
wclear(hw);
touchwin(hw);
mvwaddstr(hw, 2, 0, "[a] light");
mvwaddstr(hw, 3, 0, "[b] monster confusion");
wmove(hw, 0, 0);
wprintw(hw, "Which power do you wish to use?");
draw(hw);
which = ((readchar(hw) & 0177) - 'a');
while (which < 0 || which > 1) {
if (which == ESCAPE - 'a') {
after = FALSE;
return;
}
msg("");
wmove(hw, 0, 0);
wclrtoeol(hw);
waddstr(hw, "Please enter one of the listed powers. ");
draw(hw);
which = ((readchar(hw) & 0177) - 'a');
}
mvwaddstr(hw, 0, 0, "Your attempt is successful.--More--");
wclrtoeol(hw);
draw(hw);
wait_for(hw, ' ');
}
else
msg("Your attempt is successsful.");
switch (which) {
when 0: read_scroll(S_LIGHT, TRUE);
when 1:
if (get_dir())
do_zap(TRUE, WS_CONFMON, FALSE);
otherwise:
msg("What a strange thing to do!!");
}
}
/*
* do_palantir: handle powers of the Palantir of Might
*/
void
do_palantir(void)
{
register int which, limit;
/* Prompt for action */
msg("How do you wish to apply the Palantir of Might? (* for list): ");
limit = 3;
if (is_carrying(TR_SCEPTRE))
limit += 1;
if (is_carrying(TR_CROWN))
limit += 1;
which = ((readchar(msgw) & 0177) - 'a');
if (which == ESCAPE - 'a') {
after = FALSE;
return;
}
if (which < 0 || which > limit) {
msg("");
clearok(cw, TRUE);
touchwin(cw);
wclear(hw);
touchwin(hw);
mvwaddstr(hw, 2, 0, "[a] monster detection");
mvwaddstr(hw, 3, 0, "[b] gold detection");
mvwaddstr(hw, 4, 0, "[c] magic detection");
mvwaddstr(hw, 5, 0, "[d] food detection");
if (limit >= 4)
mvwaddstr(hw, 6, 0, "[e] teleportation");
if (limit >= 5)
mvwaddstr(hw, 7, 0, "[f] clear thought");
wmove(hw, 0, 0);
wprintw(hw, "Which power do you wish to use?");
draw(hw);
which = ((readchar(hw) & 0177) - 'a');
while (which < 0 || which > limit) {
if (which == ESCAPE - 'a') {
after = FALSE;
return;
}
msg("");
wmove(hw, 0, 0);
wclrtoeol(hw);
waddstr(hw, "Please enter one of the listed powers. ");
draw(hw);
which = ((readchar(hw) & 0177) - 'a');
}
mvwaddstr(hw, 0, 0, "Your attempt is successful.--More--");
wclrtoeol(hw);
draw(hw);
wait_for(hw, ' ');
}
else
msg("Your attempt is successful.");
switch (which) {
when 0: quaff(P_MFIND, FALSE);
when 1: read_scroll(S_GFIND, FALSE);
when 2: quaff(P_TFIND, FALSE);
when 3: read_scroll(S_FOODFIND, FALSE);
when 4: read_scroll(S_TELEP, FALSE);
when 5: quaff(P_CLEAR, FALSE);
otherwise:
msg("What a strange thing to do!!");
}
}
/*
* do_silmaril: handle powers of the Silamril of Ea
*/
void
do_silmaril(void)
{
register int which;
/* Prompt for action */
msg("How do you wish to apply the Silamril of Ea? (* for list): ");
which = ((readchar(msgw) & 0177) - 'a');
if (which == ESCAPE - 'a') {
after = FALSE;
return;
}
if (which < 0 || which > 2) {
msg("");
clearok(cw, TRUE);
touchwin(cw);
wclear(hw);
touchwin(hw);
mvwaddstr(hw, 2, 0, "[a] magic mapping");
mvwaddstr(hw, 3, 0, "[b] petrification");
mvwaddstr(hw, 4, 0, "[c] stairwell downwards");
wmove(hw, 0, 0);
wprintw(hw, "Which power do you wish to use?");
draw(hw);
which = ((readchar(hw) & 0177) - 'a');
while (which < 0 || which > 2) {
if (which == ESCAPE - 'a') {
after = FALSE;
return;
}
msg("");
wmove(hw, 0, 0);
wclrtoeol(hw);
waddstr(hw, "Please enter one of the listed powers. ");
draw(hw);
which = ((readchar(hw) & 0177) - 'a');
}
mvwaddstr(hw, 0, 0, "Your attempt is successful.--More--");
wclrtoeol(hw);
draw(hw);
wait_for(hw, ' ');
}
else
msg("Your attempt is successful.");
switch (which) {
when 0: read_scroll(S_MAP, FALSE);
when 1: read_scroll(S_PETRIFY, FALSE);
when 2:
msg("A stairwell opens beneath your feet and you go down.");
level++;
new_level(NORMLEV);
otherwise:
msg("What a strange thing to do!!");
}
}
/*
* do_amulet: handle powers of the Amulet of Yendor
*/
void
do_amulet(void)
{
register int which, limit;
/* Prompt for action */
msg("How do you wish to apply the Amulet of Yendor? (* for list): ");
limit = 0;
if (is_carrying(TR_PURSE))
limit += 1;
which = ((readchar(msgw) & 0177) - 'a');
if (which == ESCAPE - 'a') {
after = FALSE;
return;
}
if (which < 0 || which > limit) {
msg("");
clearok(cw, TRUE);
touchwin(cw);
wclear(hw);
touchwin(hw);
mvwaddstr(hw, 2, 0, "[a] level evaluation");