-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscrolls.c
841 lines (787 loc) · 20.4 KB
/
scrolls.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
/*
* scrolls.c - Functions for dealing with scrolls
*
* Advanced Rogue
* Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T
* All rights reserved.
*
* Based on "Rogue: Exploring the Dungeons of Doom"
* Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
* All rights reserved.
*
* See the file LICENSE.TXT for full copyright and licensing information.
*/
/*
* Read a scroll and let it happen
*
*/
#include "curses.h"
#include <ctype.h>
#include "rogue.h"
/*
* let the hero get rid of some type of monster (but not a UNIQUE!)
*/
genocide()
{
register struct linked_list *ip;
register struct thing *mp;
register struct linked_list *nip;
register int num_monst = NUMMONST-NUMUNIQUE-1, /* cannot genocide uniques */
pres_monst=1,
num_lines=2*(lines-3);
register int which_monst;
which_monst = makemonster(FALSE, "Genocide", "wipe out");
if (which_monst <= 0) {
msg("");
return;
}
/* Remove this monster from the present level */
for (ip = mlist; ip; ip = nip) {
mp = THINGPTR(ip);
nip = next(ip);
if (mp->t_index == which_monst) {
killed(ip, FALSE, FALSE, TRUE);
}
}
/* Remove from available monsters */
monsters[which_monst].m_normal = FALSE;
monsters[which_monst].m_wander = FALSE;
mpos = 0;
msg("You have wiped out the %s.", monsters[which_monst].m_name);
}
read_scroll(which, flag, is_scroll)
register int which;
int flag;
bool is_scroll;
{
register struct object *obj, *nobj;
register struct linked_list *item, *nitem;
register int i,j;
register char ch, nch;
bool cursed, blessed;
blessed = FALSE;
cursed = FALSE;
item = NULL;
if (which < 0) {
if (on(player, ISBLIND)) {
msg("You can't see to read anything");
return;
}
if (on(player, ISINWALL)) {
msg("You can't see the scroll while inside rock!");
return;
}
/* This is a scroll or book. */
if (player.t_action != C_READ) {
int units;
item = get_item(pack, "read", READABLE, FALSE, FALSE);
/*
* Make certain that it is somethings that we want to read
*/
if (item == NULL)
return;
/* How long does it take to read? */
units = usage_time(item);
if (units < 0) return;
player.t_using = item; /* Remember what it is */
player.t_no_move = units * movement(&player);
if ((OBJPTR(item))->o_type == SCROLL) player.t_action = C_READ;
else player.t_action = C_USE;
return;
}
/* We have waited our time, let's quaff the potion */
item = player.t_using;
player.t_using = NULL;
player.t_action = A_NIL;
obj = OBJPTR(item);
/* remove it from the pack */
inpack--;
detach(pack, item);
msg("As you read the scroll, it vanishes.");
cursed = (obj->o_flags & ISCURSED) != 0;
blessed = (obj->o_flags & ISBLESSED) != 0;
which = obj->o_which;
}
else {
cursed = flag & ISCURSED;
blessed = flag & ISBLESSED;
}
switch (which) {
case S_CONFUSE:
/*
* Scroll of monster confusion. Give him that power.
*/
msg("Your hands begin to glow red");
turn_on(player, CANHUH);
when S_CURING:
/*
* A cure disease spell
*/
if (on(player, HASINFEST) ||
on(player, HASDISEASE)||
on(player, DOROT)) {
if (on(player, HASDISEASE)) {
extinguish(cure_disease);
cure_disease();
}
if (on(player, HASINFEST)) {
msg(terse ? "You feel yourself improving."
: "You begin to feel yourself improving again.");
turn_off(player, HASINFEST);
infest_dam = 0;
}
if (on(player, DOROT)) {
msg("You feel your skin returning to normal.");
turn_off(player, DOROT);
}
}
else {
msg(nothing);
break;
}
if (is_scroll) s_know[S_CURING] = TRUE;
when S_LIGHT:
if (blue_light(blessed, cursed) && is_scroll)
s_know[S_LIGHT] = TRUE;
when S_HOLD:
if (cursed) {
/*
* This scroll aggravates all the monsters on the current
* level and sets them running towards the hero
*/
aggravate(TRUE, TRUE);
msg("You hear a high pitched humming noise.");
}
else if (blessed) { /* Hold all monsters on level */
if (mlist == NULL) msg(nothing);
else {
register struct linked_list *mon;
register struct thing *th;
for (mon = mlist; mon != NULL; mon = next(mon)) {
th = THINGPTR(mon);
turn_off(*th, ISRUN);
turn_on(*th, ISHELD);
}
msg("A sudden peace comes over the dungeon.");
}
}
else {
/*
* Hold monster scroll. Stop all monsters within two spaces
* from chasing after the hero.
*/
register int x,y;
register struct linked_list *mon;
bool gotone=FALSE;
for (x = hero.x-2; x <= hero.x+2; x++) {
for (y = hero.y-2; y <= hero.y+2; y++) {
if (y < 1 || x < 0 || y > lines - 3 || x > cols - 1)
continue;
if (isalpha(mvwinch(mw, y, x))) {
if ((mon = find_mons(y, x)) != NULL) {
register struct thing *th;
gotone = TRUE;
th = THINGPTR(mon);
turn_off(*th, ISRUN);
turn_on(*th, ISHELD);
}
}
}
}
if (gotone) msg("A sudden peace surrounds you.");
else msg(nothing);
}
when S_SLEEP:
/*
* if cursed, you fall asleep
*/
if (is_scroll) s_know[S_SLEEP] = TRUE;
if (cursed) {
if (ISWEARING(R_ALERT))
msg("You feel drowsy for a moment.");
else {
msg("You fall asleep.");
player.t_no_move += movement(&player)*(4 + rnd(SLEEPTIME));
player.t_action = A_FREEZE;
}
}
else {
/*
* sleep monster scroll.
* puts all monsters within 2 spaces asleep
*/
register int x,y;
register struct linked_list *mon;
bool gotone=FALSE;
for (x = hero.x-2; x <= hero.x+2; x++) {
for (y = hero.y-2; y <= hero.y+2; y++) {
if (y < 1 || x < 0 || y > lines - 3 || x > cols - 1)
continue;
if (isalpha(mvwinch(mw, y, x))) {
if ((mon = find_mons(y, x)) != NULL) {
register struct thing *th;
th = THINGPTR(mon);
if (on(*th, ISUNDEAD))
continue;
th->t_no_move += movement(th)*(SLEEPTIME+4);
th->t_action = A_FREEZE;
gotone = TRUE;
}
}
}
}
if (gotone)
msg("The monster(s) around you seem to have fallen asleep");
else
msg(nothing);
}
when S_CREATE:
/*
* Create a monster
* First look in a circle around him, next try his room
* otherwise give up
*/
creat_mons(&player, (short) 0, TRUE);
light(&hero);
when S_IDENT:
/*
* if its blessed then identify everything in the pack
*/
if (blessed) {
msg("You feel more Knowledgeable!");
idenpack();
}
else {
/*
* Identify, let the rogue figure something out
*/
if (is_scroll && s_know[S_IDENT] != TRUE) {
msg("This scroll is an identify scroll");
}
whatis(NULL);
}
if (is_scroll) s_know[S_IDENT] = TRUE;
when S_MAP:
/*
* Scroll of magic mapping.
*/
if (is_scroll && s_know[S_MAP] != TRUE) {
msg("Oh, now this scroll has a map on it.");
s_know[S_MAP] = TRUE;
}
overwrite(stdscr, hw);
/*
* Take all the things we want to keep hidden out of the window
*/
for (i = 1; i < lines-2; i++)
for (j = 0; j < cols; j++)
{
switch (nch = ch = CCHAR( mvwinch(hw, i, j) ))
{
case SECRETDOOR:
nch = secretdoor (i, j);
break;
case '-':
case '|':
case DOOR:
case PASSAGE:
case ' ':
case STAIRS:
if (mvwinch(mw, i, j) != ' ')
{
register struct thing *it;
it = THINGPTR(find_mons(i, j));
if (it && it->t_oldch == ' ')
it->t_oldch = nch;
}
break;
default:
nch = ' ';
}
if (nch != ch)
waddch(hw, nch);
}
/*
* Copy in what he has discovered
*/
overlay(cw, hw);
/*
* And set up for display
*/
overwrite(hw, cw);
when S_GFIND:
/*
* Scroll of gold detection
*/
{
int gtotal = 0;
wclear(hw);
for (nitem = lvl_obj; nitem != NULL; nitem = next(nitem)) {
nobj = OBJPTR(nitem);
if (nobj->o_type == GOLD) {
gtotal += nobj->o_count;
mvwaddch(hw, nobj->o_pos.y, nobj->o_pos.x, GOLD);
}
}
for (nitem = mlist; nitem != NULL; nitem = next(nitem)) {
register struct linked_list *gitem;
register struct thing *th;
th = THINGPTR(nitem);
if (on(*th, NODETECT)) continue;
for(gitem = th->t_pack; gitem != NULL; gitem = next(gitem)){
nobj = OBJPTR(gitem);
if (nobj->o_type == GOLD) {
gtotal += nobj->o_count;
mvwaddch(hw, th->t_pos.y, th->t_pos.x, GOLD);
}
}
}
if (gtotal) {
if (is_scroll) s_know[S_GFIND] = TRUE;
msg("You begin to feel greedy and you sense gold.");
waddstr(msgw, morestr);
clearok(msgw, FALSE);
draw(msgw);
overlay(hw, cw);
draw(cw);
wait_for(' ');
msg("");
break;
}
}
msg("You begin to feel a pull downward");
when S_TELEP:
/*
* Scroll of teleportation:
* Make him disappear and reappear
*/
if (cursed) {
int old_max = cur_max;
turns = (vlevel * 3) * LEVEL;
level = nfloors;
new_level(NORMLEV);
status(TRUE);
mpos = 0;
msg("You are banished to the lower regions.");
if (old_max == cur_max) /* if he's been here, make it harder */
aggravate(TRUE, TRUE);
}
else if (blessed) {
int old_level,
much = rnd(4) - 4;
old_level = level;
if (much != 0) {
level += much;
if (level < 1)
level = 1;
mpos = 0;
cur_max = level;
turns += much*LEVEL;
if (turns < 0)
turns = 0;
new_level(NORMLEV); /* change levels */
if (level == old_level)
status(TRUE);
msg("You are whisked away to another region.");
}
}
else {
teleport();
}
if (is_scroll) s_know[S_TELEP] = TRUE;
when S_SCARE:
/*
* A monster will refuse to step on a scare monster scroll
* if it is dropped. Thus reading it is a mistake and produces
* laughter at the poor rogue's boo boo.
*/
msg("You hear maniacal laughter in the distance.");
when S_REMOVE:
if (cursed) { /* curse all player's possessions */
for (nitem = pack; nitem != NULL; nitem = next(nitem)) {
nobj = OBJPTR(nitem);
if (nobj->o_flags & ISBLESSED)
nobj->o_flags &= ~ISBLESSED;
else
nobj->o_flags |= ISCURSED;
}
msg("The smell of fire and brimstone fills the air.");
}
else if (blessed) {
for (nitem = pack; nitem != NULL; nitem = next(nitem)) {
nobj = OBJPTR(nitem);
nobj->o_flags &= ~ISCURSED;
}
msg("Your pack glistens brightly");
}
else {
nitem = get_item(pack, "remove the curse on",ALL,FALSE,FALSE);
if (nitem != NULL) {
nobj = OBJPTR(nitem);
nobj->o_flags &= ~ISCURSED;
msg("Removed the curse from %s",inv_name(nobj,TRUE));
}
}
if (is_scroll) s_know[S_REMOVE] = TRUE;
when S_PETRIFY:
switch (mvinch(hero.y, hero.x)) {
case TRAPDOOR:
case DARTTRAP:
case TELTRAP:
case ARROWTRAP:
case SLEEPTRAP:
case BEARTRAP:
{
register int i;
/* Find the right trap */
for (i=0; i<ntraps && !ce(traps[i].tr_pos, hero); i++);
ntraps--;
if (!ce(traps[i].tr_pos, hero))
msg("What a strange trap!");
else {
while (i < ntraps) {
traps[i] = traps[i + 1];
i++;
}
}
}
goto pet_message;
case DOOR:
case SECRETDOOR:
case FLOOR:
case PASSAGE:
pet_message: msg("The dungeon begins to rumble and shake!");
addch(WALL);
/* If the player is phased, unphase him */
if (on(player, CANINWALL)) {
extinguish(unphase);
turn_off(player, CANINWALL);
msg("Your dizzy feeling leaves you.");
}
/* Mark the player as in a wall */
turn_on(player, ISINWALL);
break;
default:
msg(nothing);
}
when S_GENOCIDE:
msg("You have been granted the boon of genocide!--More--");
wait_for(' ');
msg("");
genocide();
if (is_scroll) s_know[S_GENOCIDE] = TRUE;
when S_PROTECT: {
struct linked_list *ll;
struct object *lb;
bool did_it = FALSE;
msg("You are granted the power of protection.");
if ((ll=get_item(pack,"protect",PROTECTABLE,FALSE,FALSE)) != NULL) {
lb = OBJPTR(ll);
mpos = 0;
if (cursed) {
switch(lb->o_type) { /* ruin it completely */
case RING: if (lb->o_ac > 0) {
if (is_current(lb)) {
switch (lb->o_which) {
case R_ADDWISDOM:
pstats.s_wisdom -= lb->o_ac;
when R_ADDINTEL:
pstats.s_intel -= lb->o_ac;
when R_ADDSTR:
pstats.s_str -= lb->o_ac;
when R_ADDHIT:
pstats.s_dext -= lb->o_ac;
}
}
did_it = TRUE;
lb->o_ac = 0;
}
when ARMOR: if (lb->o_ac > 10) {
did_it = TRUE;
lb->o_ac = 10;
}
when STICK: if (lb->o_charges > 0) {
did_it = TRUE;
lb->o_charges = 0;
}
when WEAPON:if (lb->o_hplus > 0) {
did_it = TRUE;
lb->o_hplus = 0;
}
if (lb->o_dplus > 0) {
did_it = TRUE;
lb->o_dplus = 0;
}
}
if (lb->o_flags & ISPROT) {
did_it = TRUE;
lb->o_flags &= ~ISPROT;
}
if (lb->o_flags & ISBLESSED) {
did_it = TRUE;
lb->o_flags &= ~ISBLESSED;
}
if (did_it)
msg("Your %s glows red for a moment",inv_name(lb,TRUE));
else {
msg(nothing);
break;
}
}
else {
lb->o_flags |= ISPROT;
msg("Protected %s.",inv_name(lb,TRUE));
}
}
if (is_scroll) s_know[S_PROTECT] = TRUE;
}
when S_MAKEIT:
msg("You have been endowed with the power of creation.");
if (is_scroll) s_know[S_MAKEIT] = TRUE;
create_obj(TRUE, 0, 0);
when S_ALLENCH: {
struct linked_list *ll;
struct object *lb;
int howmuch, flags;
if (is_scroll && s_know[S_ALLENCH] == FALSE) {
msg("You are granted the power of enchantment.");
msg("You may enchant anything(weapon,ring,armor,scroll,potion)");
}
if ((ll = get_item(pack, "enchant", ALL, FALSE, FALSE)) != NULL) {
lb = OBJPTR(ll);
lb->o_flags &= ~ISCURSED;
if (blessed) {
howmuch = 2;
flags = ISBLESSED;
}
else if (cursed) {
howmuch = -1;
flags = ISCURSED;
}
else {
howmuch = 1;
flags = ISBLESSED;
}
switch(lb->o_type) {
case RING:
if (lb->o_ac + howmuch > MAXENCHANT) {
msg("The enchantment doesn't seem to work!");
break;
}
lb->o_ac += howmuch;
if (lb==cur_ring[LEFT_1] || lb==cur_ring[LEFT_2] ||
lb==cur_ring[LEFT_3] || lb==cur_ring[LEFT_4] ||
lb==cur_ring[RIGHT_1] || lb==cur_ring[RIGHT_2] ||
lb==cur_ring[RIGHT_3] || lb==cur_ring[RIGHT_4]) {
switch (lb->o_which) {
case R_ADDWISDOM: pstats.s_wisdom += howmuch;
when R_ADDINTEL: pstats.s_intel += howmuch;
when R_ADDSTR: pstats.s_str += howmuch;
when R_ADDHIT: pstats.s_dext += howmuch;
}
}
msg("Enchanted %s.",inv_name(lb,TRUE));
when ARMOR:
if ((armors[lb->o_which].a_class - lb->o_ac) +
howmuch > MAXENCHANT) {
msg("The enchantment doesn't seem to work!");
break;
}
else
lb->o_ac -= howmuch;
msg("Enchanted %s.",inv_name(lb,TRUE));
when STICK:
lb->o_charges += (howmuch * 10) + rnd(5);
if (lb->o_charges < 0)
lb->o_charges = 0;
if (EQUAL(ws_type[lb->o_which], "staff")) {
if (lb->o_charges > 100)
lb->o_charges = 100;
}
else {
if (lb->o_charges > 50)
lb->o_charges = 50;
}
msg("Enchanted %s.",inv_name(lb,TRUE));
when WEAPON:
if(lb->o_hplus+lb->o_dplus+howmuch > MAXENCHANT * 2){
msg("The enchantment doesn't seem to work!");
break;
}
if (rnd(100) < 50)
lb->o_hplus += howmuch;
else
lb->o_dplus += howmuch;
msg("Enchanted %s.",inv_name(lb,TRUE));
when MM:
switch (lb->o_which) {
case MM_BRACERS:
if (lb->o_ac + howmuch > MAXENCHANT) {
msg("The enchantment doesn't seem to work!");
break;
}
else lb->o_ac += howmuch;
msg("Enchanted %s.",inv_name(lb,TRUE));
when MM_PROTECT:
if (lb->o_ac + howmuch > MAXENCHANT/2) {
msg("The enchantment doesn't seem to work!");
break;
}
else lb->o_ac += howmuch;
msg("Enchanted %s.",inv_name(lb,TRUE));
}
lb->o_flags |= flags;
when POTION:
case SCROLL:
default:
lb->o_flags |= flags;
msg("Enchanted %s.",inv_name(lb,TRUE));
}
}
if (is_scroll) s_know[S_ALLENCH] = TRUE;
if (!is_scroll) {
pstats.s_const--;
max_stats.s_const--;
if (pstats.s_const <= 0)
death(D_CONSTITUTION);
msg("You feel less healthy now");
}
}
when S_FINDTRAPS:
for (i=0; i<ntraps; i++) {
if (!(traps[i].tr_flags & ISFOUND)) {
traps[i].tr_flags |= ISFOUND;
if (cansee(traps[i].tr_pos.y, traps[i].tr_pos.x))
mvwaddch(cw,traps[i].tr_pos.y,traps[i].tr_pos.x,
traps[i].tr_type);
}
}
if (ntraps > 0) {
msg("You sense the presence of traps");
if (is_scroll) s_know[S_FINDTRAPS] = TRUE;
}
else
msg(nothing);
when S_RUNES:
{
register struct linked_list *sitem;
msg("The scroll explodes in a ball of fire!");
if (on(player, NOFIRE)) {
msg("The fire does not seem to affect you");
break;
}
explode(&player);
if (pstats.s_hpt <= 0)
death(D_SCROLL);
for (sitem = pack; sitem != NULL; sitem = nitem) {
nitem = next(sitem); /* in case we delete it */
nobj = OBJPTR(sitem);
/*
* check for loss of all scrolls and give them
* a save versus fire
*/
if (nobj->o_type == SCROLL && roll(1,20) < 19) {
msg("%s burns up!", inv_name(nobj, TRUE));
inpack--;
detach(pack, sitem);
o_discard(sitem);
}
}
}
when S_CHARM:
{
bool spots[9];
int x, y, spot, count, numcharmed, something, bonus;
struct linked_list *item;
register struct thing *tp;
/* Initialize the places where we look around us */
for (i=0; i<9; i++) spots[i] = FALSE;
count = 0; /* No spots tried yet */
numcharmed = 0; /* Nobody charmed yet */
something = 0; /* Nothing has been seen yet */
bonus = 0; /* no bonus yet */
/* Now look around us randomly for a charmee */
while (count < 9) {
do {
spot = rnd(9);
} while (spots[spot] == TRUE);
/* We found a place */
count++;
spots[spot] = TRUE;
y = hero.y - 1 + (spot / 3);
x = hero.x - 1 + (spot % 3);
/* Be sure to stay on the board! */
if (x < 0 || x >= cols || (y < 1) || (y >= lines - 2))
continue;
/* Is there a monster here? */
if (!isalpha(mvwinch(mw, y, x))) continue;
/* What kind is it? */
item = find_mons(y, x);
if (item == NULL) continue;
tp = THINGPTR(item);
if (on(*tp,ISCHARMED) || on(*tp,ISUNIQUE) || on(*tp,ISUNDEAD))
continue;
/* Will the monster be charmed? */
if (blessed) bonus -= 3;
bonus -= (pstats.s_charisma - 13) / 3;
if ((player.t_ctype==C_PALADIN || player.t_ctype==C_RANGER) &&
off(*tp, ISMEAN))
bonus -= 3;
if (save(VS_MAGIC, tp, bonus)) continue;
/* We got him! */
numcharmed++;
/* Let the player know (maybe) */
if ((off(*tp, ISINVIS) || on(player, CANSEE)) &&
(off(*tp, ISSHADOW) || on(player, CANSEE)) &&
cansee(y, x)) {
if (on(*tp, CANSURPRISE)) {
turn_off(*tp, CANSURPRISE);
msg("Woah!");
}
msg("The eyes of %s glaze over!",
prname(monster_name(tp), FALSE));
something++;
}
/* Charm him and turn off any side effects */
turn_on(*tp, ISCHARMED);
runto(tp, &hero);
tp->t_action = A_NIL;
/* If monster was suffocating us, stop it */
if (on(*tp, DIDSUFFOCATE)) {
turn_off(*tp, DIDSUFFOCATE);
extinguish(suffocate);
}
/* If monster held us, stop it */
if (on(*tp, DIDHOLD) && (--hold_count == 0))
turn_off(player, ISHELD);
turn_off(*tp, DIDHOLD);
/* If frightened of this monster, stop */
if (on(player, ISFLEE) &&
player.t_dest == &tp->t_pos) turn_off(player, ISFLEE);
if ((blessed && numcharmed >= 2) || numcharmed > 0) break;
}
if (something == 0) msg(nothing);
}
otherwise:
msg("What a puzzling scroll!");
return;
}
look(TRUE, FALSE); /* put the result of the scroll on the screen */
status(FALSE);
if (is_scroll && item && s_know[which] && s_guess[which])
{
free(s_guess[which]);
s_guess[which] = NULL;
}
else if (is_scroll &&
!s_know[which] &&
item &&
askme &&
(obj->o_flags & ISKNOW) == 0 &&
(obj->o_flags & ISPOST) == 0 &&
s_guess[which] == NULL) {
nameitem(item, FALSE);
}
if (item != NULL) o_discard(item);
updpack(TRUE, &player);
}