-
Notifications
You must be signed in to change notification settings - Fork 4
/
move.c
1451 lines (1342 loc) · 32.7 KB
/
move.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
/*
move.c - Hero movement commands
Last Modified: Dec 29, 1990
UltraRogue
Copyright (C) 1984, 1985, 1986, 1987, 1990 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"
#include "stepok.h"
#include "death.h"
/*
* Used to hold the new hero position
*/
coord nh;
/*
* do_run: Start the hero running
*/
do_run(ch)
char ch;
{
running = TRUE;
after = FALSE;
runch = ch;
if (doorstop && !on(player, ISBLIND)) {
door_stop = TRUE;
firstmove = TRUE;
}
}
/*
* corr_move: Check to see that a move is legal. If so, return correct
* character. If not, if player came from a legal place, then try to turn
* him.
*/
corr_move(dy, dx)
int dy, dx;
{
char ch;
short legal = 0; /* Number of legal alternatives */
int y, x; /* Holds legal new position */
int *ny, *nx; /* Point to which direction to change */
/* New position */
nh.y = hero.y + dy;
nh.x = hero.x + dx;
/* A bad diagonal move is illegal */
if (!diag_ok(&hero, &nh, &player))
return;
/* If it is a legal move, just return */
if (nh.x >= 0 && nh.x < COLS && nh.y > 0 && nh.y < LINES - 2) {
ch = winat(nh.y, nh.x);
switch (ch) {
case ' ':
case '|':
case '-':
break;
default:
return;
}
}
/* Check the legal alternatives */
if (dy == 0) {
ny = &dy;
nx = &dx;
}
else {
ny = &dx;
nx = &dy;
}
for (*nx = 0, *ny = -1; *ny < 2; *ny += 2) {
/* New position */
nh.y = hero.y + dy;
nh.x = hero.x + dx;
if (nh.x < 0 || nh.x > COLS - 1 || nh.y < 1 || nh.y > LINES - 3)
continue;
ch = winat(nh.y, nh.x);
switch (ch) {
case ' ':
case '|':
case '-':
break;
default:
legal++;
y = dy;
x = dx;
}
}
/* If we have 2 legal moves, make no change */
if (legal != 1)
return;
/* Make the change */
if (y == 0) { /* Move horizontally */
if (x == 1)
runch = 'l';
else
runch = 'h';
}
else { /* Move vertically */
if (y == 1)
runch = 'j';
else
runch = 'k';
}
return;
}
/*
* do_move: Check to see that a move is legal. If it is handle the
* consequences (fighting, picking up, etc.)
*/
do_move(dy, dx)
int dy, dx;
{
char ch;
coord old_hero;
char hch;
firstmove = FALSE;
if (player.t_no_move) {
player.t_no_move--;
msg("You are still stuck in the bear trap.");
return;
}
/*
* Do a confused move (maybe)
*/
if ((rnd(100) < 80 && on(player, ISHUH)) ||
(is_wearing(R_DELUSION) && rnd(100) < 25) ||
on(player, STUMBLER) && rnd(40) == 0)
nh = *rndmove(&player);
else {
nh.y = hero.y + dy;
nh.x = hero.x + dx;
}
/*
* Check if he tried to move off the screen or make an illegal
* diagonal move, and stop him if he did.
*/
if (nh.x < 0 || nh.x > COLS - 1 || nh.y < 1 || nh.y >= LINES - 2
|| !diag_ok(&hero, &nh, &player)) {
after = fighting = running = FALSE;
return;
}
if (running && ce(hero, nh))
after = running = FALSE;
ch = winat(nh.y, nh.x);
/* Take care of hero trying to move close to something frightening */
if (on(player, ISFLEE)) {
if (rnd(10) < 1) {
turn_off(player, ISFLEE);
msg("You regain your composure.");
}
else if (DISTANCE(nh.y, nh.x, player.t_dest.y,
player.t_dest.x) <
DISTANCE(hero.y, hero.x, player.t_dest.y, player.t_dest.x))
return;
}
/* Take care of hero being held */
if (on(player, ISHELD) && !isalpha(ch)) {
if (rnd(pstats.s_str) > 14) {
msg("You break free of the hold.");
if (--hold_count == 0)
turn_off(player, ISHELD);
}
else {
msg("You are being held.");
return;
}
}
if (on(player, ISDISGUISE) && rnd(11 * pstats.s_dext) == 0) {
extinguish(undisguise);
undisguise();
}
/* assume he's not in a wall */
if (!isalpha(ch))
turn_off(player, ISINWALL);
hch = mvinch(hero.y, hero.x); /* Where hero was */
old_hero = hero; /* Save hero's old position */
switch (ch) {
case ' ':
case '|':
case '-':
case SECRETDOOR:
if (off(player, CANINWALL)) {
after = running = FALSE;
return;
}
else if (running) {
after = running = FALSE;
return;
}
turn_on(player, ISINWALL);
break;
case TRAPDOOR:
case TELTRAP:
case BEARTRAP:
case SLEEPTRAP:
case ARROWTRAP:
case DARTTRAP:
case POOL:
case MAZETRAP:
case FIRETRAP:
case POISONTRAP:
case LAIR:
case RUSTTRAP:
ch = be_trapped(&player, &nh);
if (!is_wearing(R_LEVITATION) && off(player, CANFLY) &&
(old_hero.x != hero.x || old_hero.y != hero.y
|| pool_teleport)) {
pool_teleport = FALSE;
return;
}
break;
case GOLD:
case POTION:
case SCROLL:
case FOOD:
case WEAPON:
case ARMOR:
case RING:
case ARTIFACT:
case STICK:
running = FALSE;
take = ch;
break;
default:
break;
}
if (ch == FIRETRAP)
light(&hero);
hero = nh; /* Move the hero */
if (roomin(&hero) == NULL && (hch == '-' || hch == '|' ||
hch == DOOR || hch == SECRETDOOR)) {
/* Leaving a room -- darken it */
struct room *rp = roomin(&old_hero);
bool is_lit = FALSE;
if (!(rp->r_flags & ISDARK))
is_lit = TRUE;
rp->r_flags |= ISDARK; /* Fake darkness */
light(&old_hero);
if (is_lit)
rp->r_flags &= ~ISDARK; /* Restore light state */
}
else if (ch == DOOR || ch == SECRETDOOR || ch == '|' || ch == '-') {
/* Entering a room */
running = FALSE;
if (hch != '|' && hch != '-')
light(&hero); /* knows whether the hero can see
* things in */
}
else if (ch == STAIRS)
running = FALSE;
else if (ch == POST) {
running = FALSE;
new_level(POSTLEV);
return;
}
else if (isalpha(ch)) {
struct linked_list *mp;
struct thing *tp;
int t;
running = FALSE;
mp = find_mons(hero.y, hero.x);
if (mp == NULL)
return;
tp = THINGPTR(mp);
if (good_monster(*tp)) { /* Exchange places with your
* buddy */
mvwaddch(cw, old_hero.y, old_hero.x, ch);
mvwaddch(mw, old_hero.y, old_hero.x, ch);
mvwaddch(mw, hero.y, hero.x, ' ');
mvwaddch(cw, hero.y, hero.x, tp->t_oldch);
(*tp).t_pos.x = old_hero.x; /* Update monster
* position variables */
(*tp).t_pos.y = old_hero.y;
(*tp).t_oldpos.x = old_hero.x;
(*tp).t_oldpos.y = old_hero.y;
t = (*tp).t_oldch;
(*tp).t_oldch = player.t_oldch;
player.t_oldch = t;
turn_on(*tp, ISRUN);
mvwaddch(cw, hero.y, hero.x, PLAYER);
wrefresh(cw);
return;
}
else {
hero = old_hero; /* Restore hero -- we'll
* fight instead of move */
fight(&nh, cur_weapon, NOTHROWN);
return;
}
}
else
fighting = FALSE;
ch = winat(old_hero.y, old_hero.x);
wmove(cw, old_hero.y, old_hero.x);
waddch(cw, ch);
wmove(cw, hero.y, hero.x);
waddch(cw, PLAYER);
}
/*
* Called to illuminate a room. If it is dark, remove anything that might
* move.
*/
light(cp)
coord *cp;
{
struct room *rp;
int j, k, x, y;
char ch, rch;
struct linked_list *item;
int jlow, jhigh, klow, khigh; /* Boundaries of lit area */
if ((rp = roomin(cp)) != NULL && !on(player, ISBLIND)) {
/*
* is he wearing ring of illumination and in same room?
*/
if ((is_wearing(R_LIGHT) || on(player, ISELECTRIC)) &&
cp == &hero)
rp->r_flags &= ~ISDARK;
/* If we are in a maze, don't look at the whole room (level) */
if (levtype == MAZELEV) {
jlow = max(0, hero.y - 2 - rp->r_pos.y);
jhigh = min(rp->r_max.y, hero.y + 2 - rp->r_pos.y + 1);
klow = max(0, hero.x - 2 - rp->r_pos.x);
khigh = min(rp->r_max.x, hero.x + 2 - rp->r_pos.x + 1);
}
else {
jlow = klow = 0;
jhigh = rp->r_max.y;
khigh = rp->r_max.x;
}
for (j = 0; j < rp->r_max.y; j++) {
for (k = 0; k < rp->r_max.x; k++) {
/*
* Is this in the give area -- needed for
* maze
*/
if ((j < jlow || j >= jhigh) &&
(k < klow || k >= khigh))
continue;
y = rp->r_pos.y + j;
x = rp->r_pos.x + k;
ch = show(y, x);
wmove(cw, y, x);
/*
* Figure out how to display a secret door
*/
if (ch == SECRETDOOR) {
if (j == 0 || j == rp->r_max.y - 1)
ch = '-';
else
ch = '|';
}
/*
* For monsters, if they were previously not
* seen and now can be seen, or vice-versa,
* make sure that will happen.
*/
if (isalpha(ch)) {
struct thing *tp;
item = wake_monster(y, x);
if (item == NULL)
continue;
tp = THINGPTR(item);
/*
* Previously not seen -- now can see
* it
*/
if (tp->t_oldch == ' ' &&
cansee(tp->t_pos.y,
tp->t_pos.x))
tp->t_oldch = mvinch(y, x);
/*
* Previously seen -- now can't see
* it
*/
else if (off(player, ISBLIND) &&
tp->t_oldch != ' ' &&
!cansee(tp->t_pos.y,
tp->t_pos.x))
tp->t_oldch = ' ';
}
/*
* If the room is a dark room, we might want
* to remove monsters and the like from it
* (since they might move). A dark room or
* not in line-of-sight in a maze.
*/
if (((rp->r_flags & ISDARK) &&
!(rp->r_flags & HASFIRE)) ||
(levtype == MAZELEV &&
!maze_view(y, x))) {
rch = mvwinch(cw, y, x);
switch (rch) {
when DOOR:
case STAIRS:
case TRAPDOOR:
case TELTRAP:
case BEARTRAP:
case SLEEPTRAP:
case ARROWTRAP:
case DARTTRAP:
case POOL:
case MAZETRAP:
case FIRETRAP:
case POISONTRAP:
case LAIR:
case RUSTTRAP:
case POST:
case '|':
case '-':
case ' ':
ch = rch;
when FLOOR:
ch = (on(player,
ISBLIND) ?
FLOOR : ' ');
otherwise:
ch = ' ';
}
}
mvwaddch(cw, y, x, ch);
}
}
}
}
/*
* blue_light: magically light up a room (or level or make it dark)
*/
bool
blue_light(flags)
int flags;
{
struct room *rp;
bool blessed = (flags & ISBLESSED);
bool cursed = (flags & ISCURSED);
bool ret_val = FALSE;/* Whether or not affect is known */
rp = roomin(&hero); /* What room is hero in? */
/* Darken the room if the magic is cursed */
if (cursed) {
if ((rp == NULL) || (rp->r_flags & ISDARK))
nothing_message(flags);
else {
if (!(rp->r_flags & HASFIRE))
msg("The room suddenly goes dark.");
else
nothing_message(flags);
rp->r_flags |= ISDARK;
ret_val = TRUE;
}
}
else {
ret_val = TRUE;
if (rp && (rp->r_flags & ISDARK) && !(rp->r_flags & HASFIRE)) {
addmsg("The room is lit");
if (!terse)
addmsg(" by a %s blue light",
blessed ? "bright" : "shimmering");
addmsg(".");
endmsg();
}
else if (winat(hero.y, hero.x) == PASSAGE)
msg("The corridor glows %sand then fades.",
blessed ? "brightly " : "");
else {
ret_val = FALSE;
nothing_message(flags);
}
if (blessed) {
short i; /* Index through rooms */
for (i = 0; i < MAXROOMS; i++)
rooms[i].r_flags &= ~ISDARK;
}
else if (rp)
rp->r_flags &= ~ISDARK;
}
/*
* Light the room and put the player back up
*/
light(&hero);
mvwaddch(cw, hero.y, hero.x, PLAYER);
return (ret_val);
}
/*
* show: returns what a certain thing will display as to the un-initiated
*/
show(y, x)
int y, x;
{
char ch = winat(y, x);
struct linked_list *it;
struct thing *tp;
if (isatrap(ch)) {
struct trap *trp = trap_at(y, x);
return (trp->tr_flags & ISFOUND) ? ch : trp->tr_show;
}
else if (isalpha(ch)) {
if ((it = find_mons(y, x)) == NULL) {
debug("Can't find monster in move.");
return ' ';
}
tp = THINGPTR(it);
if (on(*tp, ISDISGUISE))
ch = tp->t_disguise; /* As a mimic */
else if (on(*tp, ISINVIS) || (on(*tp, ISSHADOW) &&
rnd(100) < 90) || on(*tp, CANSURPRISE)) {
if (off(player, CANSEE) || on(*tp, CANSURPRISE))
ch = mvwinch(stdscr, y, x); /* Invisible */
}
else if (on(*tp, CANINWALL)) {
char tch;
tch = mvwinch(stdscr, y, x);
if (tch == WALL || tch == '-' || tch == '|')
ch = winch(stdscr); /* As Xorn */
}
}
return ch;
}
/*
* be_trapped: The guy stepped on a trap.... Make him pay.
*/
be_trapped(th, tc)
struct thing *th;
coord *tc;
{
struct trap *tp;
char ch, *mname;
bool is_player = (th == &player), can_see = cansee(tc->y, tc->x);
struct linked_list *mitem;
tp = trap_at(tc->y, tc->x);
ch = tp->tr_type;
if (!is_player) {
mitem = find_mons(th->t_pos.y, th->t_pos.x);
mname = monsters[th->t_index].m_name;
/* Flying monsters do not set off traps */
if (!mitem || (on(*th, CANFLY) &&
(ch == BEARTRAP || ch == MAZETRAP || ch == TRAPDOOR
|| ch == ARROWTRAP || ch == DARTTRAP))) {
debug("%s avoided trap.", mname);
return (ch);
}
}
else {
short thief_bonus = -50;
count = running = FALSE;
mvwaddch(cw, tp->tr_pos.y, tp->tr_pos.x, tp->tr_type);
if (no_command)
return (ch);
if (player.t_ctype == C_THIEF || player.t_ctype == C_NINJA)
thief_bonus = 10;
if (((is_wearing(R_LEVITATION) || on(player, CANFLY)) &&
(ch != FIRETRAP ||
(ch == FIRETRAP && !(tp->tr_flags & ISFOUND))))
|| (moving && (tp->tr_flags & ISFOUND) && rnd(100) <
thief_bonus + 2 * pstats.s_dext + 5 * pstats.s_lvl) &&
(ch == BEARTRAP || ch == MAZETRAP || ch == TRAPDOOR
|| ch == ARROWTRAP || ch == DARTTRAP)) {
msg(tr_name(ch));
tp->tr_flags |= ISFOUND;
return (ch);
}
if (moving)
msg("Your attempt fails.");
}
tp->tr_flags |= ISFOUND;
switch (ch) {
when TRAPDOOR:
if (is_player) {
level++;
new_level(NORMLEV);
addmsg("You fell into a trap");
if (player.t_ctype != C_THIEF
&& player.t_ctype != C_ASSASIN
&& player.t_ctype != C_NINJA
&& rnd(pstats.s_dext) < 4) {
addmsg(" and were damaged by the fall");
if ((pstats.s_hpt -= roll(1, 6)) <= 0) {
addmsg("! The fall killed you.");
endmsg();
death(D_FALL);
return (ch);
}
}
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.");
}
else {
if (can_see)
msg("The %s fell into a trap!", mname);
check_residue(th);
remove_monster(&th->t_pos, mitem);
}
when BEARTRAP:
if (is_stealth(th)) {
if (is_player)
msg("You pass a bear trap.");
else if (can_see)
msg("The %s passes a bear trap.",
mname);
}
else {
th->t_no_move += BEARTIME;
if (is_player)
msg("You are caught in a bear trap.");
else if (can_see)
msg("The %s is caught in a bear trap.",
mname);
}
when SLEEPTRAP:
if (is_player) {
msg("A strange white mist envelops you.");
if (!is_wearing(R_ALERT)) {
if (!is_wearing(R_BREATHE) &&
off(player, HASOXYGEN)) {
msg("You fall asleep.");
no_command += SLEEPTIME;
}
}
}
else {
if (can_see)
msg("A strange white mist envelops the %s.", mname);
if (on(*th, ISUNDEAD)) {
if (can_see)
msg("The mist doesn't seem to affect the %s.", mname);
}
if (on(*th, ISUNDEAD) || on(*th, HASOXYGEN)) {
if (can_see)
msg("The mist doesn't seem to affect the %s.", mname);
}
else {
th->t_no_move += SLEEPTIME;
}
}
when ARROWTRAP:
if (swing(th->t_ctype, th->t_stats.s_lvl - 1,
th->t_stats.s_arm, 1)) {
if (is_player) {
msg("Oh no! An arrow shot you.");
if ((pstats.s_hpt -= roll(1, 6)) <= 0) {
msg("The arrow killed you.");
death(D_ARROW);
return ch;
}
}
else {
if (can_see)
msg("An arrow shot the %s.", mname);
if (on(*th, NOSHARP)) {
if (can_see)
msg("The arrow has no effect!");
}
else {
if ((th->t_stats.s_hpt -= roll(1, 6)) <= 0) {
if (can_see)
msg("The arrow killed the %s.", mname);
killed(NULL, mitem,
NOMESSAGE,
NOPOINTS);
}
}
}
}
else {
struct linked_list *item;
struct object *arrow;
if (is_player)
msg("An arrow shoots past you.");
else if (can_see)
msg("An arrow shoots by the %s.",
mname);
item = new_item(sizeof *arrow);
arrow = OBJPTR(item);
arrow->o_type = WEAPON;
arrow->o_which = ARROW;
arrow->o_hplus = rnd(3) - 1;
arrow->o_dplus = rnd(3) - 1;
init_weapon(arrow, ARROW);
arrow->o_count = 1;
arrow->o_pos = *tc;
arrow->o_mark[0] = '\0';
fall(&player, item, FALSE);
}
when TELTRAP:
if (is_player) {
teleport();
if (off(player, ISCLEAR)) {
msg("Wait, what's going on here. Huh? What? Who?");
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.");
}
else {
int rm;
/* Erase the monster from the old position */
if (isalpha(mvwinch(cw, th->t_pos.y,
th->t_pos.x)))
mvwaddch(cw, th->t_pos.y, th->t_pos.x,
th->t_oldch);
mvwaddch(mw, th->t_pos.y, th->t_pos.x, ' ');
/* Get a new position */
do {
rm = rnd_room();
rnd_pos(&rooms[rm], &th->t_pos);
} until(winat(th->t_pos.y, th->t_pos.x)
== FLOOR);
/* Put it there */
mvwaddch(mw, th->t_pos.y, th->t_pos.x,
th->t_type);
th->t_oldch = mvwinch(cw, th->t_pos.y,
th->t_pos.x);
if (can_see)
msg("The %s seems to have disappeared!", mname);
}
when DARTTRAP:
if (swing(th->t_ctype, th->t_stats.s_lvl + 1,
th->t_stats.s_arm, 1)) {
if (is_player) {
msg("A small dart just hit you in the shoulder.");
if ((pstats.s_hpt -= roll(1, 4)) <= 0) {
msg("The dart killed you.");
death(D_DART);
return (ch);
}
/* Now the poison */
if (player.t_ctype != C_PALADIN
&& !(player.t_ctype == C_NINJA &&
pstats.s_lvl > 12)
&& !save(VS_POISON)) {
/*
* 75% chance it will do point
* damage - else strength
*/
if (rnd(100) < 75) {
pstats.s_hpt /= 2;
if (pstats.s_hpt == 0) {
death(D_POISON);
return (ch);
}
}
else if (!is_wearing(R_SUSABILITY))
chg_str(-1, FALSE, FALSE);
}
}
else {
int orig_hp = th->t_stats.s_hpt;
if (can_see)
msg("A small dart just hit the %s.", mname);
/*
* Poison has no effect on poisonous or
* undead monsters
*/
if (off(*th, CANPOISON) &&
off(*th, ISUNDEAD) &&
!save_throw(VS_POISON, th))
th->t_stats.s_hpt /= 2;
/* Now the dart damage */
if (off(*th, NOSHARP))
th->t_stats.s_hpt -= roll(1, 4);
if (orig_hp == th->t_stats.s_hpt)
if (can_see)
msg("The dart has not effect!");
else if (th->t_stats.s_hpt < 0) {
if (can_see)
msg("The dart killed the %s.", mname);
killed(NULL, mitem, NOMESSAGE, NOPOINTS);
}
}
}
else {
if (is_player)
msg("A small dart whizzes by your ear and vanishes.");
else if (can_see)
msg("A small dart whizzes by the %s and vanishes.",
mname);
}
when POOL:{
int i;
i = rnd(100);
if (is_player) {
if (on(player, ISELECTRIC)) {
msg("Oh no!!! The water shorts you out");
extinguish(unelectrify);
turn_off(player, ISELECTRIC);
if (!is_wearing(R_ELECTRESIST)) {
if ((pstats.s_hpt -= roll(1, 10)) <= 0) {
addmsg("! The shock killed you.");
endmsg();
death(D_DROWN);
return (ch);
}
}
}
if ((tp->tr_flags & ISGONE)) {
if (i < 30) {
teleport(); /* teleport away */
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);
}
else
msg("You feel dizzy for a moment, but it quickly passes.");
pool_teleport = TRUE;
}
else if ((i < 45) && level > 2) {
level -= rnd(2) + 1;
new_level(NORMLEV);
pool_teleport = TRUE;
msg("You here a faint groan from below.");
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);
}
else
msg("You feel dizzy for a moment, but it quickly passes.");
}
else if (i < 70) {
level += rnd(4) + 1;
new_level(NORMLEV);
pool_teleport = TRUE;
msg("You find yourself in strange surroundings.");
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);
}
else
msg("You feel dizzy for a moment, but it quickly passes.");
}
else if (i > 95) {
if (is_wearing(R_BREATHE) || on(player, HASOXYGEN))
msg("You splash in the pool unharmed.");
else {
msg("Oh no!!! You drown in the pool!!! --More--");
wait_for(' ');
death(D_DROWN);
return (ch);
}
}
}
}
else {
if (can_see)
msg("The %s fell into the pool!", mname);
if (i < 30) {
if (off(*th, HASOXYGEN)) {
if (can_see)
msg("The %s has drowned!", mname);
killed(NULL, mitem, NOMESSAGE, NOPOINTS);
}
}
}
}
when MAZETRAP:
if (is_player) {
level++;
new_level(MAZELEV);
addmsg("You are surrounded by twisty passages");
if (rnd(4) < 1) {
addmsg(" and were damaged by the fall");
if ((pstats.s_hpt -= roll(1, 6)) <= 0) {
addmsg("! The fall killed you.");
endmsg();
death(D_FALL);
return (ch);
}
}
addmsg("!");
endmsg();
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);
}
}
else
msg("You feel dizzy for a moment, but it quickly passes.");