-
Notifications
You must be signed in to change notification settings - Fork 4
/
misc.c
1108 lines (992 loc) · 22.4 KB
/
misc.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
/*
misc.c - all sorts of miscellaneous routines
Last Modified: Jan 5, 1991
UltraRogue
Copyright (C) 1984, 1985, 1986, 1987, 1990, 1991 Herb Chong
All rights reserved.
Based on "Advanced Rogue"
Copyright (C) 1983, 1984 Michael Morgan, Ken Dalka and AT&T
All rights reserved.
Based on "Super-Rogue"
Copyright (C) 1982, 1983 Robert D. Kindelberger
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.
*/
#include <ctype.h>
#include "rogue.h"
/*
* tr_name: print the name of a trap
*/
static char ret_string[40];
char *
tr_name(ch)
char ch;
{
char *s, *prefix;
ret_string[0] = '\0';
switch (ch) {
when TRAPDOOR:
s = "trapdoor.";
when BEARTRAP:
s = "beartrap.";
when SLEEPTRAP:
s = "sleeping gas trap.";
when ARROWTRAP:
s = "arrow trap.";
when TELTRAP:
s = "teleport trap.";
when DARTTRAP:
s = "dart trap.";
when POOL:
s = "shimmering pool.";
when MAZETRAP:
s = "maze entrance.";
when FIRETRAP:
s = "fire trap.";
when POISONTRAP:
s = "poison pool trap.";
when LAIR:
s = "monster lair.";
when RUSTTRAP:
s = "rust trap.";
otherwise:
;
}
prefix = (terse ? "A " : "You found a ");
strcpy(ret_string, prefix);
strcat(ret_string, s);
return (ret_string);
}
/*
* Look: A quick glance all around the player
*/
look(wakeup)
bool wakeup;
{
int x, y;
char ch, och;
int oldx, oldy;
bool inpass, horiz, vert, do_light = FALSE, do_blank = FALSE;
int passcount = 0;
struct room *rp;
int ey, ex;
/* Are we moving vertically or horizontally? */
if (runch == 'h' || runch == 'l')
horiz = TRUE;
else
horiz = FALSE;
if (runch == 'j' || runch == 'k')
vert = TRUE;
else
vert = FALSE;
getyx(cw, oldy, oldx); /* Save current position */
/*
* Blank out the floor around our last position and check for moving
* out of a corridor in a maze.
*/
if (oldrp != NULL && (oldrp->r_flags & ISDARK) &&
!(oldrp->r_flags & HASFIRE) && off(player, ISBLIND))
do_blank = TRUE;
for (x = player.t_oldpos.x - 1; x <= player.t_oldpos.x + 1; x++)
for (y = player.t_oldpos.y - 1; y <= player.t_oldpos.y + 1;
y++) {
ch = show(y, x);
if (do_blank && (y != hero.y || x != hero.x) &&
ch == FLOOR)
mvwaddch(cw, y, x, ' ');
/* Moving out of a corridor? */
if (levtype == MAZELEV &&
(ch != '|' && ch != '-') && /* Not a wall */
((vert && x != player.t_oldpos.x &&
y == player.t_oldpos.y) ||
(horiz && y != player.t_oldpos.y &&
x == player.t_oldpos.x)))
do_light = TRUE; /* Just came to a turn */
}
inpass = ((rp = roomin(&hero)) == NULL); /* Are we in a passage? */
/* Are we coming out of a wall into a corridor in a maze? */
och = show(player.t_oldpos.y, player.t_oldpos.x);
ch = show(hero.y, hero.x);
if (levtype == MAZELEV && (och == '|' || och == '-' ||
och == SECRETDOOR) &&
(ch != '|' && ch != '-' && ch != SECRETDOOR))
do_light = off(player, ISBLIND); /* Light it up if not
* blind */
/* Look around the player */
ey = hero.y + 1;
ex = hero.x + 1;
for (x = hero.x - 1; x <= ex; x++)
if (x >= 0 && x < COLS)
for (y = hero.y - 1; y <= ey; y++) {
if (y <= 0 || y >= LINES - 2)
continue;
if (isalpha(mvwinch(mw, y, x))) {
struct linked_list *it;
struct thing *tp;
if (wakeup)
it = wake_monster(y, x);
else
it = find_mons(y, x);
if (it == NULL)
continue;
tp = THINGPTR(it);
tp->t_oldch = mvinch(y, x);
if (isatrap(tp->t_oldch)) {
struct trap *trp =
trap_at(y, x);
tp->t_oldch = (trp->tr_flags &
ISFOUND) ? tp->t_oldch
: trp->tr_show;
}
if (tp->t_oldch == FLOOR &&
(rp->r_flags & ISDARK)
&& !(rp->r_flags & HASFIRE) &&
off(player, ISBLIND))
tp->t_oldch = ' ';
}
/*
* Secret doors show as walls
*/
if ((ch = show(y, x)) == SECRETDOOR)
ch = secretdoor(y, x);
/*
* Don't show room walls if he is in a
* passage and check for maze turns
*/
if (off(player, ISBLIND)) {
if (y == hero.y && x == hero.x
|| (inpass && (ch == '-' ||
ch == '|')))
continue;
/* Are we at a crossroads in a maze? */
if (levtype == MAZELEV &&
(ch != '|' && ch != '-') &&
/* Not a wall */
((vert && x != hero.x &&
y == hero.y) ||
(horiz && y != hero.y &&
x == hero.x)))
do_light = TRUE;
/* Just came to a turn */
}
else if (y != hero.y || x != hero.x)
continue;
wmove(cw, y, x);
waddch(cw, ch);
if (door_stop && !firstmove && running) {
switch (runch) {
when 'h':
if (x == ex)
continue;
when 'j':
if (y == hero.y - 1)
continue;
when 'k':
if (y == ey)
continue;
when 'l':
if (x == hero.x - 1)
continue;
when 'y':
if ((x + y) -
(hero.x +
hero.y) >= 1)
continue;
when 'u':
if ((y - x) -
(hero.y -
hero.x) >= 1)
continue;
when 'n':
if ((x + y) -
(hero.x +
hero.y) <= -1)
continue;
when 'b':
if ((y - x) -
(hero.y -
hero.x) <= -1)
continue;
}
switch (ch) {
case DOOR:
if (x == hero.x ||
y == hero.y)
running = FALSE;
break;
case PASSAGE:
if (x == hero.x ||
y == hero.y)
passcount++;
break;
case FLOOR:
/*
* Stop by new passages in a
* maze (floor next to us)
*/
if ((levtype ==
MAZELEV) &&
((horiz &&
x == hero.x &&
y != hero.y) ||
(vert &&
y == hero.y &&
x != hero.x)))
running = FALSE;
case '|':
case '-':
case ' ':
break;
default:
running = FALSE;
break;
}
}
}
if (door_stop && !firstmove && passcount > 1)
running = FALSE;
/*
* Do we have to light up the area (just stepped into a new
* corridor)?
*/
if (do_light && wakeup && /* wakeup will be true on a normal
* move */
!(rp->r_flags & ISDARK) && /* We have some light */
!ce(hero, player.t_oldpos)) /* Don't do anything if we didn't
* move */
light(&hero);
mvwaddch(cw, hero.y, hero.x, PLAYER);
wmove(cw, oldy, oldx);
if (wakeup) {
player.t_oldpos = hero; /* Don't change if we didn't move */
oldrp = rp;
}
}
/*
* secret_door: Figure out what a secret door looks like.
*/
static coord cp;
secretdoor(y, x)
int y, x;
{
struct room *rp;
cp.y = y;
cp.x = x;
if ((rp = roomin(&cp)) != NULL) {
if (y == rp->r_pos.y || y == rp->r_pos.y + rp->r_max.y - 1)
return ('-');
else
return ('|');
}
return ('p');
}
/*
* find_obj: find the unclaimed object at y, x
*/
static struct linked_list *next_ll;
struct linked_list *
find_obj(y, x, start)
int y;
int x, start;
{
struct linked_list *obj, *sobj;
struct object *op;
if (start)
sobj = lvl_obj;
else
sobj = next_ll;
for (obj = sobj; obj != NULL; obj = next(obj)) {
op = OBJPTR(obj);
if (op && op->o_pos.y == y && op->o_pos.x == x) {
next_ll = next(obj);
if (!next_ll)
next_ll = lvl_obj;
return obj;
}
}
next_ll = lvl_obj;
return NULL;
}
/*
* eat: He wants to eat something, so let him try
*/
eat()
{
struct object *obj;
int amount;
object *get_object();
if ((obj = get_object(pack, "eat", FOOD, NULL)) == NULL)
return;
if (--obj->o_count == 0)
discard_pack(obj);
switch (obj->o_which) {
when FD_RATION:
amount = HUNGERTIME + rnd(400) - 200;
if (rnd(100) > 70) {
msg("Yuk, this food tastes awful.");
pstats.s_exp++;
check_level();
}
else
msg("Yum, that tasted good.");
when FD_FRUIT:
amount = 200 + rnd(HUNGERTIME);
msg("My, that was a yummy %s.", fruit);
when FD_CRAM:
amount = rnd(HUNGERTIME / 2) + 600;
msg("The cram tastes dry in your mouth.");
when FD_CAKES:
amount = (HUNGERTIME / 3) + rnd(600);
msg("Yum, the honey cakes tasted good.");
when FD_LEMBA:
amount = (HUNGERTIME / 2) + rnd(900);
quaff(&player, P_HEALING, ISNORMAL);
when FD_MIRUVOR:
amount = (HUNGERTIME / 3) + rnd(500);
quaff(&player, P_HEALING, ISNORMAL);
quaff(&player, P_RESTORE, ISNORMAL);
otherwise:
msg("What a strange thing to eat!");
amount = HUNGERTIME;
}
food_left += amount;
if (obj->o_flags & ISBLESSED) {
food_left += 2 * amount;
msg("You have a tingling feeling in your mouth.");
}
else if (food_left > STOMACHSIZE) {
food_left = STOMACHSIZE;
msg("You feel satiated and too full to move.");
no_command = HOLDTIME;
}
hungry_state = F_OK;
updpack();
if (obj == cur_weapon)
cur_weapon = NULL;
}
/*
* Used to modify the player's strength it keeps track of the highest it has
* been, just in case
*/
chg_str(amt, both, lost)
int amt;
bool both, lost;
{
int ring_str; /* ring strengths */
struct stats *ptr; /* for speed */
ptr = &pstats;
ring_str = ring_value(R_ADDSTR) + (on(player, POWERSTR) ? 10 : 0) +
(on(player, SUPERHERO) ? 10 : 0);
ptr->s_str -= ring_str;
ptr->s_str += amt;
if (ptr->s_str < 3) {
ptr->s_str = 3;
lost = FALSE;
}
else if (ptr->s_str > 25)
ptr->s_str = 25;
if (both)
max_stats.s_str = ptr->s_str;
if (lost)
lost_str -= amt;
ptr->s_str += ring_str;
if (ptr->s_str < 0)
ptr->s_str = 0;
updpack();
}
/*
* Used to modify the player's dexterity it keeps track of the highest it has
* been, just in case
*/
chg_dext(amt, both, lost)
int amt;
bool both, lost;
{
int ring_dext; /* ring strengths */
struct stats *ptr; /* for speed */
ptr = &pstats;
ring_dext = ring_value(R_ADDHIT) + (on(player, POWERDEXT) ? 10 : 0) +
(on(player, SUPERHERO) ? 5 : 0);
ptr->s_dext -= ring_dext;
ptr->s_dext += amt;
if (ptr->s_dext < 3) {
ptr->s_dext = 3;
lost = FALSE;
}
else if (ptr->s_dext > 25)
ptr->s_dext = 25;
if (both)
max_stats.s_dext = ptr->s_dext;
if (lost)
lost_dext -= amt;
ptr->s_dext += ring_dext;
if (ptr->s_dext < 0)
ptr->s_dext = 0;
}
/*
* add_haste: add a haste to the player
*/
add_haste(blessed)
bool blessed;
{
short hasttime;
if (blessed)
hasttime = 10;
else
hasttime = 6;
if (on(player, ISSLOW)) { /* Is person slow? */
extinguish(noslow);
noslow();
if (blessed)
hasttime = 4;
else
return;
}
if (on(player, ISHASTE)) {
msg("You faint from exhaustion.");
no_command += rnd(hasttime);
lengthen(nohaste, rnd(hasttime) + (roll(1, 4) * hasttime));
}
else {
turn_on(player, ISHASTE);
fuse(nohaste, 0, roll(hasttime, hasttime), AFTER);
}
}
/*
* aggravate: aggravate all the monsters on this level
*/
aggravate()
{
struct linked_list *mi;
struct thing *tp;
for (mi = mlist; mi != NULL; mi = next(mi)) {
tp = THINGPTR(mi);
runto(&tp->t_pos, &hero);
turn_off(*tp, ISFRIENDLY);
}
}
/*
* for printfs: if string starts with a vowel, return "n" for an "an"
*/
char *
vowelstr(str)
char *str;
{
switch (*str) {
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
return "n";
default:
return "";
}
}
/*
* see if the object is one of the currently used items
*/
is_current(obj)
struct object *obj;
{
if (obj == NULL)
return FALSE;
if (obj == cur_armor || obj == cur_weapon ||
obj == cur_ring[LEFT_1] || obj == cur_ring[LEFT_2] ||
obj == cur_ring[LEFT_3] || obj == cur_ring[LEFT_4] ||
obj == cur_ring[LEFT_5] ||
obj == cur_ring[RIGHT_1] || obj == cur_ring[RIGHT_2] ||
obj == cur_ring[RIGHT_3] || obj == cur_ring[RIGHT_4] ||
obj == cur_ring[RIGHT_5]) {
msg(terse ? "In use." : "That's already in use.");
return TRUE;
}
return FALSE;
}
/*
* set up the direction co_ordinate for use in varios "prefix" commands
*/
get_dir()
{
char *prompt;
bool gotit;
if (terse)
prompt = "Direction? ";
else {
prompt = "Which direction? ";
msg(prompt);
}
do {
gotit = TRUE;
switch (readchar()) {
when 'h': case 'H':
delta.y = 0;
delta.x = -1;
when 'j': case 'J':
delta.y = 1;
delta.x = 0;
when 'k': case 'K':
delta.y = -1;
delta.x = 0;
when 'l': case 'L':
delta.y = 0;
delta.x = 1;
when 'y': case 'Y':
delta.y = -1;
delta.x = -1;
when 'u': case 'U':
delta.y = -1;
delta.x = 1;
when 'b': case 'B':
delta.y = 1;
delta.x = -1;
when 'n': case 'N':
delta.y = 1;
delta.x = 1;
when ESCAPE:
return FALSE;
otherwise:
mpos = 0;
msg(prompt);
gotit = FALSE;
}
} until(gotit);
if (on(player, ISHUH) && rnd(100) > 80)
do {
delta.y = rnd(3) - 1;
delta.x = rnd(3) - 1;
} while (delta.y == 0 && delta.x == 0);
mpos = 0;
return TRUE;
}
/*
* is_wearing: is the hero wearing a particular ring
*/
bool
is_wearing(type)
int type;
{
#define ISRING(h, r) (cur_ring[h] != NULL && cur_ring[h]->o_which == r)
return (ISRING(LEFT_1, type) || ISRING(LEFT_2, type) ||
ISRING(LEFT_3, type) || ISRING(LEFT_4, type) ||
ISRING(LEFT_5, type) ||
ISRING(RIGHT_1, type) || ISRING(RIGHT_2, type) ||
ISRING(RIGHT_3, type) || ISRING(RIGHT_4, type) ||
ISRING(RIGHT_5, type));
}
/*
* Maze_view: Returns true if the player can see the specified location
* within the confines of a maze (within one column or row)
*/
bool
maze_view(y, x)
int y, x;
{
int start, goal, delta, ycheck, xcheck, absy, absx;
bool row;
/* Get the absolute value of y and x differences */
absy = hero.y - y;
absx = hero.x - x;
if (absy < 0)
absy = -absy;
if (absx < 0)
absx = -absx;
/* Must be within one row or column */
if (absy > 1 && absx > 1)
return (FALSE);
if (absy <= 1) { /* Go along row */
start = hero.x;
goal = x;
row = TRUE;
ycheck = hero.y;
}
else { /* Go along column */
start = hero.y;
goal = y;
row = FALSE;
xcheck = hero.x;
}
if (start <= goal)
delta = 1;
else
delta = -1;
while (start != goal) {
if (row)
xcheck = start;
else
ycheck = start;
switch (winat(ycheck, xcheck)) {
case '|':
case '-':
case WALL:
case DOOR:
case SECRETDOOR:
return (FALSE);
default:
break;
}
start += delta;
}
return (TRUE);
}
/*
* listen: listen for monsters less than 5 units away
*/
listen()
{
struct linked_list *item;
struct thing *tp;
int thief_bonus = -50;
int mcount = 0;
if (player.t_ctype == C_THIEF)
thief_bonus = 10;
for (item = mlist; item != NULL; item = next(item)) {
tp = THINGPTR(item);
if (DISTANCE(hero.y, hero.x, tp->t_pos.y, tp->t_pos.x) < 81
&& rnd(70) < (thief_bonus + 4 * pstats.s_dext +
6 * pstats.s_lvl)) {
msg("You hear a%s %s nearby.",
vowelstr(monsters[tp->t_index].m_name),
monsters[tp->t_index].m_name);
mcount++;
}
}
if (mcount == 0)
msg("You hear nothing.");
}
/*
* nothing_message - print out "Nothing <adverb> happens."
*/
static char *nothings[] = {
"",
"unusual ",
"seems to ",
"at all ",
"really ",
"noticeable ",
"different ",
"strange ",
"wierd ",
"bizzare ",
"wonky ",
""
};
nothing_message(flags)
int flags;
{
int adverb = rnd(sizeof(nothings) / sizeof(char *));
bool blessed = flags & ISBLESSED;
bool cursed = flags & ISCURSED;
msg("Nothing %s%shappens.", (blessed ? "good " :
(cursed ? "bad " : "")), nothings[adverb]);
}
/*
* feel_message - print out "You feel <description>."
*/
feel_message()
{
char *charp;
switch (rnd(25)) {
when 1:
charp = "bad";
when 2:
charp = "hurt";
when 3:
charp = "sick";
when 4:
charp = "faint";
when 5:
charp = "yucky";
when 6:
charp = "wonky";
when 7:
charp = "wierd";
when 8:
charp = "queasy";
when 9:
charp = "wounded";
when 11:
charp = "unusual";
when 12:
charp = "no pain";
when 13:
charp = "strange";
when 14:
charp = "noticable";
when 15:
charp = "bizzare";
when 16:
charp = "distressed";
when 17:
charp = "different";
when 18:
charp = "a touch of ague";
when 19:
charp = "a migrane coming on";
when 20:
charp = "Excedrin headache #666";
when 21:
charp = "a disturbance in the force";
when 22:
charp = "like someone dropped a house on you";
when 23:
charp = "as if every nerve in your body is on fire";
when 24:
charp = "like thousands of red-hot army ants are crawling under your skin";
otherwise:
charp = "ill";
}
msg("You feel %s.", charp);
}
/*
* const_bonus - Hit point adjustment for changing levels
*/
const_bonus()
{
int ret_val = -2;
if (pstats.s_const > 12)
ret_val = pstats.s_const - 12;
else if (pstats.s_const > 6)
ret_val = 0;
else if (pstats.s_const > 3)
ret_val = -1;
return (ret_val);
}
/*
* int_wis_bonus - Spell point adjustment for changing levels
*/
int_wis_bonus()
{
int ret_val = -2;
int casters_stat;
switch (player.t_ctype) {
when C_PALADIN:
case C_CLERIC:
casters_stat = pstats.s_wisdom;
when C_RANGER:
case C_DRUID:
casters_stat = pstats.s_wisdom;
when C_MAGICIAN:
casters_stat = pstats.s_intel;
when C_ILLUSION:
casters_stat = pstats.s_intel;
otherwise:
if (is_wearing(R_WIZARD))
casters_stat = pstats.s_intel;
else if (is_wearing(R_PIETY))
casters_stat = pstats.s_wisdom;
else
casters_stat = (rnd(2) ? pstats.s_wisdom :
pstats.s_intel);
}
if (casters_stat > 12)
ret_val = casters_stat - 12;
else if (casters_stat > 6)
ret_val = 0;
else if (casters_stat > 3)
ret_val = -1;
return (ret_val);
}
electrificate()
{
int affect_dist = 4 + player.t_stats.s_lvl / 4;
struct linked_list *item, *nitem;
for (item = mlist; item != NULL; item = nitem) {
struct thing *tp = THINGPTR(item);
char *mname = monsters[tp->t_index].m_name;
nitem = next(item);
if (DISTANCE(tp->t_pos.y, tp->t_pos.x, hero.y, hero.x) <
affect_dist) {
int damage = roll(2, player.t_stats.s_lvl);
debug("Charge does %d (%d)", damage,
tp->t_stats.s_hpt - damage);
if (on(*tp, NOBOLT))
continue;
if ((tp->t_stats.s_hpt -= damage) <= 0) {
msg("The %s is killed by an electric shock.",
mname);
killed(&player, item, NOMESSAGE, POINTS);
continue;
}
if (rnd(tp->t_stats.s_intel / 5) == 0) {
turn_on(*tp, ISFLEE);
msg("The %s is shocked by electricity.", mname);
}
else
msg("The %s is zapped by your electricity.",
mname);
summon_help(tp, NOFORCE);
turn_off(*tp, ISFRIENDLY);
turn_off(*tp, ISCHARMED);
turn_on(*tp, ISRUN);
turn_off(*tp, ISDISGUISE);
runto(&tp->t_pos, &hero);
fighting = after = running = FALSE;
}
}
}
/*
* feed_me - Print out interesting messages about food consumption
*/
static char *f_hungry[] = {
"want a cookie",
"feel like a snack",
"feel like some fruit",
"start having the munchies",
"are starting to get hungry"
};
static char *f_weak[] = {
"are really hungry",
"could eat a horse",
"want some food - now",
"are starting to feel weak",
"feel a gnawing in your stomach",
"are even willing to eat up cram",
"feel lightheaded from not eating"
};
static char *f_faint[] = {
"get dizzy from not eating",
"are starving for nutrients",
"feel too weak from lack of food",
"see a mirage of an incredible banquet",
"have incredible cramps in your stomach"
};
static char *f_plop[] = {
"faint",
"pass out",
"keel over",
"black out"
};
feed_me(hungry_state)
{
char *charp, *charp2;
switch (hungry_state) {
when F_OK:
default:
debug("feed_me(%d) called.", hungry_state);
when F_HUNGRY:
charp = f_hungry[rnd(sizeof(f_hungry) /
sizeof(char *))];
when F_WEAK:
charp = f_weak[rnd(sizeof(f_weak) / sizeof(char *))];
when F_FAINT:
charp = f_faint[rnd(sizeof(f_faint) / sizeof(char *))];
charp2 = f_plop[rnd(sizeof(f_plop) / sizeof(char *))];
}
msg("You %s.", charp);
if (hungry_state == F_FAINT)
msg("You %s.", charp2);
}
/*
* get_monster_number - prompt player for a monster on list returns 0 if none
* selected
*/
get_monster_number(message)
char *message;
{
int i;
int pres_monst = 1;
int ret_val = -1;
char buf[2 * LINELEN];