/
apply.c
4452 lines (4124 loc) · 118 KB
/
apply.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: @(#)apply.c 3.4 2003/11/18 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "edog.h"
#ifdef OVLB
static const char tools[] = { TOOL_CLASS, WEAPON_CLASS, WAND_CLASS, 0 };
static const char all_count[] = { ALLOW_COUNT, ALL_CLASSES, 0 };
static const char tools_too[] = { COIN_CLASS, ALL_CLASSES, TOOL_CLASS, POTION_CLASS,
WEAPON_CLASS, WAND_CLASS, GEM_CLASS,
#ifdef NEPHI_PHOTOGRAPHY
SPBOOK_CLASS,
#endif
0 };
static const char tinnables[] = { ALLOW_FLOOROBJ, FOOD_CLASS, 0 };
#ifdef TOURIST
#ifndef NEPHI_PHOTOGRAPHY
STATIC_DCL int FDECL(use_camera, (struct obj *));
#endif /* NEPHI_PHOTOGRAPHY */
#endif
STATIC_DCL int FDECL(use_towel, (struct obj *));
STATIC_DCL boolean FDECL(its_dead, (int,int,int *));
STATIC_DCL int FDECL(use_stethoscope, (struct obj *));
STATIC_DCL void FDECL(use_whistle, (struct obj *));
STATIC_DCL void FDECL(use_magic_whistle, (struct obj *));
STATIC_DCL void FDECL(use_leash, (struct obj *));
STATIC_DCL int FDECL(use_mirror, (struct obj *));
STATIC_DCL void FDECL(use_bell, (struct obj **));
STATIC_DCL void FDECL(use_candelabrum, (struct obj *));
STATIC_DCL void FDECL(use_candle, (struct obj **));
STATIC_DCL void FDECL(use_lamp, (struct obj *));
STATIC_DCL int FDECL(use_torch, (struct obj *));
STATIC_DCL void FDECL(light_cocktail, (struct obj *));
STATIC_DCL void FDECL(use_tinning_kit, (struct obj *));
STATIC_DCL void FDECL(use_figurine, (struct obj **));
STATIC_DCL void FDECL(use_grease, (struct obj *));
STATIC_DCL void FDECL(use_trap, (struct obj *));
STATIC_DCL void FDECL(use_stone, (struct obj *));
STATIC_DCL void FDECL(apply_flint, (struct obj *));
STATIC_PTR int NDECL(set_trap); /* occupation callback */
STATIC_DCL int FDECL(use_whip, (struct obj *));
STATIC_DCL int FDECL(use_longwhip, (struct obj *));
STATIC_DCL int FDECL(use_pole, (struct obj *));
STATIC_DCL int FDECL(use_cream_pie, (struct obj *));
STATIC_DCL int FDECL(use_grapple, (struct obj *));
STATIC_DCL int FDECL(do_break_wand, (struct obj *));
STATIC_DCL int FDECL(do_flip_coin, (struct obj*));
STATIC_DCL boolean FDECL(figurine_location_checks,
(struct obj *, coord *, BOOLEAN_P));
STATIC_DCL boolean NDECL(uhave_graystone);
STATIC_DCL void FDECL(add_class, (char *, CHAR_P));
#ifdef AMIGA
void FDECL( amii_speaker, ( struct obj *, char *, int ) );
#endif
const char no_elbow_room[] = "don't have enough elbow-room to maneuver.";
#ifdef TOURIST
#ifdef NEPHI_PHOTOGRAPHY
int
use_camera(obj,brightflash)
struct obj *obj;
boolean brightflash;
#else
STATIC_OVL int
use_camera(obj)
struct obj *obj;
#endif
{
#ifndef NEPHI_PHOTOGRAPHY
register struct monst *mtmp;
#endif
if(Underwater) {
pline("Using your camera underwater would void the warranty.");
return(0);
}
if(!getdir((char *)0)) return(0);
if (obj->spe <= 0) {
pline(nothing_happens);
return (1);
}
#ifdef NEPHI_PHOTOGRAPHY
obj_stop_timers(obj);
take_picture2(obj,u.dx,u.dy,u.dz,brightflash,FALSE);
return (1);
#else
consume_obj_charge(obj, TRUE);
if (obj->cursed && !rn2(2)) {
(void) zapyourself(obj, TRUE);
} else if (u.uswallow) {
You("take a picture of %s %s.", s_suffix(mon_nam(u.ustuck)),
mbodypart(u.ustuck, STOMACH));
} else if (u.dz) {
You("take a picture of the %s.",
(u.dz > 0) ? surface(u.ux,u.uy) : ceiling(u.ux,u.uy));
} else if (!u.dx && !u.dy) {
(void) zapyourself(obj, TRUE);
} else if ((mtmp = bhit(u.dx,u.dy,COLNO,FLASHED_LIGHT,
(int FDECL((*),(MONST_P,OBJ_P)))0,
(int FDECL((*),(OBJ_P,OBJ_P)))0,
&obj)) != 0) {
obj->ox = u.ux, obj->oy = u.uy;
(void) flash_hits_mon(mtmp, obj);
}
return 1;
#endif /* NEPHI_PHOTOGRAPHY */
}
#endif /* TOURIST */
STATIC_OVL int
use_towel(obj)
struct obj *obj;
{
if(!freehand()) {
You("have no free %s!", body_part(HAND));
return 0;
} else if (obj->owornmask) {
You("cannot use it while you're wearing it!");
return 0;
} else if (obj->cursed) {
long old;
switch (rn2(3)) {
case 2:
old = Glib;
incr_itimeout(&Glib, rn1(10, 3));
Your("%s %s!", makeplural(body_part(HAND)),
(old ? "are filthier than ever" : "get slimy"));
return 1;
case 1:
if (!ublindf) {
old = u.ucreamed;
u.ucreamed += rn1(10, 3);
pline("Yecch! Your %s %s gunk on it!", body_part(FACE),
(old ? "has more" : "now has"));
make_blinded(Blinded + (long)u.ucreamed - old, TRUE);
} else {
const char *what = (ublindf->otyp == LENSES) ?
"lenses" : "blindfold";
if (ublindf->cursed) {
You("push your %s %s.", what,
rn2(2) ? "cock-eyed" : "crooked");
} else {
struct obj *saved_ublindf = ublindf;
You("push your %s off.", what);
Blindf_off(ublindf);
dropx(saved_ublindf);
}
}
return 1;
case 0:
break;
}
}
if (Glib) {
Glib = 0;
You("wipe off your %s.", makeplural(body_part(HAND)));
return 1;
} else if(u.ucreamed) {
Blinded -= u.ucreamed;
u.ucreamed = 0;
if (!Blinded) {
pline("You've got the glop off.");
Blinded = 1;
make_blinded(0L,TRUE);
} else {
Your("%s feels clean now.", body_part(FACE));
}
return 1;
}
Your("%s and %s are already clean.",
body_part(FACE), makeplural(body_part(HAND)));
return 0;
}
/* maybe give a stethoscope message based on floor objects */
STATIC_OVL boolean
its_dead(rx, ry, resp)
int rx, ry, *resp;
{
struct obj *otmp;
struct trap *ttmp;
if (!can_reach_floor()) return FALSE;
/* additional stethoscope messages from jyoung@apanix.apana.org.au */
if (Hallucination && sobj_at(CORPSE, rx, ry)) {
/* (a corpse doesn't retain the monster's sex,
so we're forced to use generic pronoun here) */
You_hear("a voice say, \"It's dead, Jim.\"");
*resp = 1;
return TRUE;
} else if (Role_if(PM_HEALER) && ((otmp = sobj_at(CORPSE, rx, ry)) != 0 ||
(otmp = sobj_at(STATUE, rx, ry)) != 0)) {
/* possibly should check uppermost {corpse,statue} in the pile
if both types are present, but it's not worth the effort */
if (vobj_at(rx, ry)->otyp == STATUE) otmp = vobj_at(rx, ry);
if (otmp->otyp == CORPSE) {
You("determine that %s unfortunate being is dead.",
(rx == u.ux && ry == u.uy) ? "this" : "that");
} else {
ttmp = t_at(rx, ry);
pline("%s appears to be in %s health for a statue.",
The(mons[otmp->corpsenm].mname),
(ttmp && ttmp->ttyp == STATUE_TRAP) ?
"extraordinary" : "excellent");
}
return TRUE;
}
/* listening to eggs is a little fishy, but so is stethoscopes detecting alignment
* The overcomplex wording is because all the monster-naming functions operate
* on actual instances of the monsters, and we're dealing with just an index
* so we can avoid things like "a owlbear", etc. */
if (otmp = sobj_at(EGG,rx,ry)) {
if (Hallucination) {
pline("You listen to the egg and guess... %s?",rndmonnam());
} else {
if (stale_egg(otmp) || otmp->corpsenm == NON_PM) {
pline("The egg doesn't make much noise at all.");
} else {
pline("You listen to the egg and guess... %s?",mons[otmp->corpsenm].mname);
}
}
return TRUE;
}
return FALSE;
}
static const char hollow_str[] = "a hollow sound. This must be a secret %s!";
/* Strictly speaking it makes no sense for usage of a stethoscope to
not take any time; however, unless it did, the stethoscope would be
almost useless. As a compromise, one use per turn is free, another
uses up the turn; this makes curse status have a tangible effect. */
STATIC_OVL int
use_stethoscope(obj)
register struct obj *obj;
{
static long last_used_move = -1;
static short last_used_movement = 0;
struct monst *mtmp;
struct rm *lev;
int rx, ry, res;
boolean interference = (u.uswallow && is_whirly(u.ustuck->data) &&
!rn2(Role_if(PM_HEALER) ? 10 : 3));
if (nohands(youmonst.data)) { /* should also check for no ears and/or deaf */
You("have no hands!"); /* not `body_part(HAND)' */
return 0;
} else if (!freehand()) {
You("have no free %s.", body_part(HAND));
return 0;
}
if (!getdir((char *)0)) return 0;
res = (moves == last_used_move) &&
(youmonst.movement == last_used_movement);
last_used_move = moves;
last_used_movement = youmonst.movement;
#ifdef STEED
if (u.usteed && u.dz > 0) {
if (interference) {
pline("%s interferes.", Monnam(u.ustuck));
mstatusline(u.ustuck);
} else
if (obj->blessed)
mstatuslinebl(u.usteed); /* make blessed one better than uncursed --Amy */
else
mstatusline(u.usteed);
return res;
} else
#endif
if (u.uswallow && (u.dx || u.dy || u.dz)) {
mstatusline(u.ustuck);
return res;
} else if (u.uswallow && interference) {
pline("%s interferes.", Monnam(u.ustuck));
mstatusline(u.ustuck);
return res;
} else if (u.dz) {
if (Underwater)
You_hear("faint splashing.");
else if (u.dz < 0 || !can_reach_floor())
You_cant("reach the %s.",
(u.dz > 0) ? surface(u.ux,u.uy) : ceiling(u.ux,u.uy));
else if (its_dead(u.ux, u.uy, &res))
; /* message already given */
else if (Is_stronghold(&u.uz))
You_hear("the crackling of hellfire.");
else
pline_The("%s seems healthy enough.", surface(u.ux,u.uy));
return res;
} else if (obj->cursed && !rn2(2)) {
You_hear("your heart beat.");
return res;
}
if (Stunned || (Confusion && !rn2(5))) confdir();
if (!u.dx && !u.dy) {
ustatusline();
return res;
}
rx = u.ux + u.dx; ry = u.uy + u.dy;
if (!isok(rx,ry)) {
You_hear(Hallucination ? "two robots and a human heckling you."
: "a faint typing noise.");
return 0;
}
if ((mtmp = m_at(rx,ry)) != 0) {
mstatusline(mtmp);
if (mtmp->mundetected) {
mtmp->mundetected = 0;
if (cansee(rx,ry)) newsym(mtmp->mx,mtmp->my);
}
if (!canspotmon(mtmp))
map_invisible(rx,ry);
return res;
}
if (memory_is_invisible(rx, ry)) {
unmap_object(rx, ry);
newsym(rx, ry);
pline_The("invisible monster must have moved.");
}
lev = &levl[rx][ry];
switch(lev->typ) {
case SDOOR:
You_hear(hollow_str, "door");
cvt_sdoor_to_door(lev); /* ->typ = DOOR */
if (Blind) feel_location(rx,ry);
else newsym(rx,ry);
return res;
case SCORR:
You_hear(hollow_str, "passage");
lev->typ = CORR;
unblock_point(rx,ry);
if (Blind) feel_location(rx,ry);
else newsym(rx,ry);
return res;
}
if (!its_dead(rx, ry, &res))
You("hear nothing special."); /* not You_hear() */
return res;
}
static const char whistle_str[] = "produce a %s whistling sound.";
STATIC_OVL void
use_whistle(obj)
struct obj *obj;
{
You(whistle_str, obj->cursed ? "shrill" : "high");
wake_nearby();
}
STATIC_OVL void
use_magic_whistle(obj)
struct obj *obj;
{
register struct monst *mtmp, *nextmon;
if(obj->cursed && !rn2(2)) {
You("produce a high-pitched humming noise.");
wake_nearby();
} else {
int pet_cnt = 0;
You(whistle_str, Hallucination ? "normal" : "strange");
for(mtmp = fmon; mtmp; mtmp = nextmon) {
nextmon = mtmp->nmon; /* trap might kill mon */
if (DEADMONSTER(mtmp)) continue;
if (mtmp->mtame) {
if (mtmp->mtrapped) {
/* no longer in previous trap (affects mintrap) */
mtmp->mtrapped = 0;
fill_pit(mtmp->mx, mtmp->my);
}
mnexto(mtmp);
if (canspotmon(mtmp)) ++pet_cnt;
if (mintrap(mtmp) == 2) change_luck(-1);
}
}
if (pet_cnt > 0) makeknown(obj->otyp);
}
}
boolean
um_dist(x,y,n)
register xchar x, y, n;
{
return((boolean)(abs(u.ux - x) > n || abs(u.uy - y) > n));
}
int
number_leashed()
{
register int i = 0;
register struct obj *obj;
for(obj = invent; obj; obj = obj->nobj)
if(obj->otyp == LEASH && obj->leashmon != 0) i++;
return(i);
}
void
o_unleash(otmp) /* otmp is about to be destroyed or stolen */
register struct obj *otmp;
{
register struct monst *mtmp;
for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
if(mtmp->m_id == (unsigned)otmp->leashmon)
mtmp->mleashed = 0;
otmp->leashmon = 0;
}
void
m_unleash(mtmp, feedback) /* mtmp is about to die, or become untame */
register struct monst *mtmp;
boolean feedback;
{
register struct obj *otmp;
if (feedback) {
if (canseemon(mtmp))
pline("%s pulls free of %s leash!", Monnam(mtmp), mhis(mtmp));
else
Your("leash falls slack.");
}
for(otmp = invent; otmp; otmp = otmp->nobj)
if(otmp->otyp == LEASH &&
otmp->leashmon == (int)mtmp->m_id)
otmp->leashmon = 0;
mtmp->mleashed = 0;
}
void
unleash_all() /* player is about to die (for bones) */
{
register struct obj *otmp;
register struct monst *mtmp;
for(otmp = invent; otmp; otmp = otmp->nobj)
if(otmp->otyp == LEASH) otmp->leashmon = 0;
for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
mtmp->mleashed = 0;
}
#define MAXLEASHED 2
/* ARGSUSED */
STATIC_OVL void
use_leash(obj)
struct obj *obj;
{
coord cc;
register struct monst *mtmp;
int spotmon;
if(!obj->leashmon && number_leashed() >= MAXLEASHED) {
You("cannot leash any more pets.");
return;
}
if(!get_adjacent_loc((char *)0, (char *)0, u.ux, u.uy, &cc)) return;
if((cc.x == u.ux) && (cc.y == u.uy)) {
#ifdef STEED
if (u.usteed && u.dz > 0) {
mtmp = u.usteed;
spotmon = 1;
goto got_target;
}
#endif
pline("Leash yourself? Very funny...");
return;
}
if(!(mtmp = m_at(cc.x, cc.y))) {
There("is no creature there.");
return;
}
spotmon = canspotmon(mtmp);
#ifdef STEED
got_target:
#endif
/* KMH, balance patch -- This doesn't work properly.
* Pets need extra memory for their edog structure.
* Normally, this is handled by tamedog(), but that
* rejects all demons. Our other alternative would
* be to duplicate tamedog()'s functionality here.
* Yuck. So I've merged it into the nymph code below.
if (((mtmp->data == &mons[PM_SUCCUBUS]) || (mtmp->data == &mons[PM_INCUBUS]))
&& (!mtmp->mtame) && (spotmon) && (!mtmp->mleashed)) {
pline("%s smiles seductively at the sight of this prop!", Monnam(mtmp));
mtmp->mtame = 10;
mtmp->mpeaceful = 1;
set_malign(mtmp);
}*/
if ((mtmp->data->mlet == S_NYMPH || mtmp->data == &mons[PM_SUCCUBUS]
|| mtmp->data == &mons[PM_INCUBUS])
&& (spotmon) && (!mtmp->mleashed)) {
pline("%s looks shocked! \"I'm not that way!\"", Monnam(mtmp));
mtmp->mtame = 0;
mtmp->mpeaceful = 0;
mtmp->msleeping = 0;
}
if(!mtmp->mtame) {
if(!spotmon)
There("is no creature there.");
else
pline("%s %s leashed!", Monnam(mtmp), (!obj->leashmon) ?
"cannot be" : "is not");
return;
}
if(!obj->leashmon) {
if(mtmp->mleashed) {
pline("This %s is already leashed.",
spotmon ? l_monnam(mtmp) : "monster");
return;
}
You("slip the leash around %s%s.",
spotmon ? "your " : "", l_monnam(mtmp));
mtmp->mleashed = 1;
obj->leashmon = (int)mtmp->m_id;
mtmp->msleeping = 0;
return;
}
if(obj->leashmon != (int)mtmp->m_id) {
pline("This leash is not attached to that creature.");
return;
} else {
if(obj->cursed) {
pline_The("leash would not come off!");
obj->bknown = TRUE;
return;
}
mtmp->mleashed = 0;
obj->leashmon = 0;
You("remove the leash from %s%s.",
spotmon ? "your " : "", l_monnam(mtmp));
/* KMH, balance patch -- this is okay */
if ((mtmp->data == &mons[PM_SUCCUBUS]) ||
(mtmp->data == &mons[PM_INCUBUS]))
{
pline("%s is infuriated!", Monnam(mtmp));
mtmp->mtame = 0;
mtmp->mpeaceful = 0;
}
}
return;
}
struct obj *
get_mleash(mtmp) /* assuming mtmp->mleashed has been checked */
register struct monst *mtmp;
{
register struct obj *otmp;
otmp = invent;
while(otmp) {
if(otmp->otyp == LEASH && otmp->leashmon == (int)mtmp->m_id)
return(otmp);
otmp = otmp->nobj;
}
return((struct obj *)0);
}
#endif /* OVLB */
#ifdef OVL1
boolean
next_to_u()
{
register struct monst *mtmp;
register struct obj *otmp;
for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (DEADMONSTER(mtmp)) continue;
if(mtmp->mleashed) {
if (distu(mtmp->mx,mtmp->my) > 2) mnexto(mtmp);
if (distu(mtmp->mx,mtmp->my) > 2) {
for(otmp = invent; otmp; otmp = otmp->nobj)
if(otmp->otyp == LEASH &&
otmp->leashmon == (int)mtmp->m_id) {
if(otmp->cursed) return(FALSE);
You_feel("%s leash go slack.",
(number_leashed() > 1) ? "a" : "the");
mtmp->mleashed = 0;
otmp->leashmon = 0;
}
}
}
}
#ifdef STEED
/* no pack mules for the Amulet */
if (u.usteed && mon_has_amulet(u.usteed)) return FALSE;
#endif
return(TRUE);
}
#endif /* OVL1 */
#ifdef OVL0
void
check_leash(x, y)
register xchar x, y;
{
register struct obj *otmp;
register struct monst *mtmp;
for (otmp = invent; otmp; otmp = otmp->nobj) {
if (otmp->otyp != LEASH || otmp->leashmon == 0) continue;
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (DEADMONSTER(mtmp)) continue;
if ((int)mtmp->m_id == otmp->leashmon) break;
}
if (!mtmp) {
impossible("leash in use isn't attached to anything?");
otmp->leashmon = 0;
continue;
}
if (dist2(u.ux,u.uy,mtmp->mx,mtmp->my) >
dist2(x,y,mtmp->mx,mtmp->my)) {
if (!um_dist(mtmp->mx, mtmp->my, 3)) {
; /* still close enough */
} else if (otmp->cursed && !breathless(mtmp->data)) {
if (um_dist(mtmp->mx, mtmp->my, 5) ||
(mtmp->mhp -= rnd(2)) <= 0) {
long save_pacifism = u.uconduct.killer;
Your("leash chokes %s to death!", mon_nam(mtmp));
/* hero might not have intended to kill pet, but
that's the result of his actions; gain experience,
lose pacifism, take alignment and luck hit, make
corpse less likely to remain tame after revival */
xkilled(mtmp, 0); /* no "you kill it" message */
/* life-saving doesn't ordinarily reset this */
if (mtmp->mhp > 0) u.uconduct.killer = save_pacifism;
} else {
pline("%s chokes on the leash!", Monnam(mtmp));
/* tameness eventually drops to 1 here (never 0) */
if (mtmp->mtame && rn2(mtmp->mtame)) mtmp->mtame--;
}
} else {
if (um_dist(mtmp->mx, mtmp->my, 5)) {
pline("%s leash snaps loose!", s_suffix(Monnam(mtmp)));
m_unleash(mtmp, FALSE);
} else {
You("pull on the leash.");
if (mtmp->data->msound != MS_SILENT)
switch (rn2(3)) {
case 0: growl(mtmp); break;
case 1: yelp(mtmp); break;
default: whimper(mtmp); break;
}
}
}
}
}
}
#endif /* OVL0 */
#ifdef OVLB
#define WEAK 3 /* from eat.c */
static const char look_str[] = "look %s.";
STATIC_OVL int
use_mirror(obj)
struct obj *obj;
{
register struct monst *mtmp;
register char mlet;
#ifdef INVISIBLE_OBJECTS
boolean vis = !Blind && (!obj->oinvis || See_invisible);
#else
boolean vis = !Blind;
#endif
if(!getdir((char *)0)) return 0;
if(obj->cursed && !rn2(2)) {
if (vis)
pline_The("mirror fogs up and doesn't reflect!");
return 1;
}
if(!u.dx && !u.dy && !u.dz) {
if(vis && !Invisible) {
if (u.umonnum == PM_FLOATING_EYE) {
if (!Free_action) {
pline(Hallucination ?
"Yow! The mirror stares back!" :
"Yikes! You've frozen yourself!");
nomul(-rnd((MAXULEV+6) - u.ulevel), "gazing into a mirror");
nomovemsg = 0;
} else You("stiffen momentarily under your gaze.");
} else if (is_vampire(youmonst.data))
You("don't have a reflection.");
else if (u.umonnum == PM_UMBER_HULK) {
pline("Huh? That doesn't look like you!");
make_confused(HConfusion + d(3,4),FALSE);
} else if (Hallucination)
You(look_str, hcolor((char *)0));
else if (Sick)
You(look_str, "peaked");
else if (u.uhs >= WEAK)
You(look_str, "undernourished");
else You("look as %s as ever.",
ACURR(A_CHA) > 14 ?
(poly_gender()==1 ? "beautiful" : "handsome") :
"ugly");
} else {
You_cant("see your %s %s.",
ACURR(A_CHA) > 14 ?
(poly_gender()==1 ? "beautiful" : "handsome") :
"ugly",
body_part(FACE));
}
return 1;
}
if(u.uswallow) {
if (vis) You("reflect %s %s.", s_suffix(mon_nam(u.ustuck)),
mbodypart(u.ustuck, STOMACH));
return 1;
}
if(Underwater) {
#ifdef INVISIBLE_OBJECTS
if (!obj->oinvis)
#endif
You(Hallucination ?
"give the fish a chance to fix their makeup." :
"reflect the murky water.");
return 1;
}
if(u.dz) {
if (vis)
You("reflect the %s.",
(u.dz > 0) ? surface(u.ux,u.uy) : ceiling(u.ux,u.uy));
return 1;
}
mtmp = bhit(u.dx, u.dy, COLNO, INVIS_BEAM,
(int FDECL((*),(MONST_P,OBJ_P)))0,
(int FDECL((*),(OBJ_P,OBJ_P)))0,
&obj);
if (!mtmp || !haseyes(mtmp->data))
return 1;
vis = canseemon(mtmp);
mlet = mtmp->data->mlet;
if (mtmp->msleeping) {
if (vis)
pline ("%s is too tired to look at your mirror.",
Monnam(mtmp));
} else if (!mtmp->mcansee) {
if (vis)
pline("%s can't see anything right now.", Monnam(mtmp));
#ifdef INVISIBLE_OBJECTS
} else if (obj->oinvis && !perceives(mtmp->data)) {
if (vis)
pline("%s can't see your mirror.", Monnam(mtmp));
#endif
/* some monsters do special things */
} else if (is_vampire(mtmp->data) || mlet == S_GHOST) {
if (vis)
pline ("%s doesn't have a reflection.", Monnam(mtmp));
} else if(!mtmp->mcan && !mtmp->minvis &&
mtmp->data == &mons[PM_MEDUSA]) {
if (mon_reflects(mtmp, "The gaze is reflected away by %s %s!"))
return 1;
if (vis)
pline("%s is turned to stone!", Monnam(mtmp));
stoned = TRUE;
killed(mtmp);
} else if(!mtmp->mcan && !mtmp->minvis &&
mtmp->data == &mons[PM_FLOATING_EYE]) {
int tmp = d((int)mtmp->m_lev, (int)mtmp->data->mattk[0].damd);
if (!rn2(4)) tmp = 120;
if (vis)
pline("%s is frozen by its reflection.", Monnam(mtmp));
else You_hear("%s stop moving.",something);
mtmp->mcanmove = 0;
if ( (int) mtmp->mfrozen + tmp > 127)
mtmp->mfrozen = 127;
else mtmp->mfrozen += tmp;
} else if(!mtmp->mcan && !mtmp->minvis &&
mtmp->data == &mons[PM_UMBER_HULK]) {
if (vis)
pline ("%s confuses itself!", Monnam(mtmp));
mtmp->mconf = 1;
} else if(!mtmp->mcan && !mtmp->minvis && (mlet == S_NYMPH
|| mtmp->data==&mons[PM_SUCCUBUS])) {
if (vis) {
pline ("%s admires herself in your mirror.", Monnam(mtmp));
pline ("She takes it!");
} else pline ("It steals your mirror!");
setnotworn(obj); /* in case mirror was wielded */
freeinv(obj);
(void) mpickobj(mtmp,obj);
if (!tele_restrict(mtmp)) (void) rloc(mtmp, FALSE);
} else if (!is_unicorn(mtmp->data) && !humanoid(mtmp->data) &&
(!mtmp->minvis || perceives(mtmp->data)) && rn2(5)) {
if (vis)
pline("%s is frightened by its reflection.", Monnam(mtmp));
monflee(mtmp, d(2,4), FALSE, FALSE);
} else if (!Blind) {
if (mtmp->minvis && !See_invisible)
;
else if ((mtmp->minvis && !perceives(mtmp->data))
|| !haseyes(mtmp->data))
pline("%s doesn't seem to notice its reflection.",
Monnam(mtmp));
else
pline("%s ignores %s reflection.",
Monnam(mtmp), mhis(mtmp));
}
return 1;
}
STATIC_OVL void
use_bell(optr)
struct obj **optr;
{
register struct obj *obj = *optr;
struct monst *mtmp;
boolean wakem = FALSE, learno = FALSE,
ordinary = (obj->otyp != BELL_OF_OPENING || !obj->spe),
invoking = (obj->otyp == BELL_OF_OPENING &&
invocation_pos(u.ux, u.uy) && !On_stairs(u.ux, u.uy));
You("ring %s.", the(xname(obj)));
if (Underwater || (u.uswallow && ordinary)) {
#ifdef AMIGA
amii_speaker( obj, "AhDhGqEqDhEhAqDqFhGw", AMII_MUFFLED_VOLUME );
#endif
pline("But the sound is muffled.");
} else if (invoking && ordinary) {
/* needs to be recharged... */
pline("But it makes no sound.");
learno = TRUE; /* help player figure out why */
} else if (ordinary) {
#ifdef AMIGA
amii_speaker( obj, "ahdhgqeqdhehaqdqfhgw", AMII_MUFFLED_VOLUME );
#endif
if (obj->cursed && !rn2(4) &&
/* note: once any of them are gone, we stop all of them */
!(mvitals[PM_WOOD_NYMPH].mvflags & G_GONE) &&
!(mvitals[PM_WATER_NYMPH].mvflags & G_GONE) &&
!(mvitals[PM_MOUNTAIN_NYMPH].mvflags & G_GONE) &&
(mtmp = makemon(mkclass(S_NYMPH, 0),
u.ux, u.uy, NO_MINVENT)) != 0) {
You("summon %s!", a_monnam(mtmp));
if (!obj_resists(obj, 93, 100)) {
pline("%s shattered!", Tobjnam(obj, "have"));
useup(obj);
*optr = 0;
} else switch (rn2(3)) {
default:
break;
case 1:
mon_adjust_speed(mtmp, 2, (struct obj *)0);
break;
case 2: /* no explanation; it just happens... */
nomovemsg = "";
nomul(-rnd(2), 0);
break;
}
}
wakem = TRUE;
} else {
/* charged Bell of Opening */
consume_obj_charge(obj, TRUE);
if (u.uswallow) {
if (!obj->cursed)
(void) openit();
else
pline(nothing_happens);
} else if (obj->cursed) {
coord mm;
mm.x = u.ux;
mm.y = u.uy;
mkundead(&mm, FALSE, NO_MINVENT);
wakem = TRUE;
} else if (invoking) {
pline("%s an unsettling shrill sound...",
Tobjnam(obj, "issue"));
#ifdef AMIGA
amii_speaker( obj, "aefeaefeaefeaefeaefe", AMII_LOUDER_VOLUME );
#endif
obj->age = moves;
learno = TRUE;
wakem = TRUE;
} else if (obj->blessed) {
int res = 0;
#ifdef AMIGA
amii_speaker( obj, "ahahahDhEhCw", AMII_SOFT_VOLUME );
#endif
if (uchain) {
unpunish();
res = 1;
}
res += openit();
switch (res) {
case 0: pline(nothing_happens); break;
case 1: pline("%s opens...", Something);
learno = TRUE; break;
default: pline("Things open around you...");
learno = TRUE; break;
}
} else { /* uncursed */
#ifdef AMIGA
amii_speaker( obj, "AeFeaeFeAefegw", AMII_OKAY_VOLUME );
#endif
if (findit() != 0) learno = TRUE;
else pline(nothing_happens);
}
} /* charged BofO */
if (learno) {
makeknown(BELL_OF_OPENING);
obj->known = 1;
}
if (wakem) wake_nearby();
}
STATIC_OVL void
use_candelabrum(obj)
register struct obj *obj;
{
const char *s = (obj->spe != 1) ? "candles" : "candle";
if(Underwater) {
You("cannot make fire under water.");
return;
}
if(obj->lamplit) {
You("snuff the %s.", s);
end_burn(obj, TRUE);
return;
}
if(obj->spe <= 0) {
pline("This %s has no %s.", xname(obj), s);
return;
}
if(u.uswallow || obj->cursed) {
if (!Blind)
pline_The("%s %s for a moment, then %s.",
s, vtense(s, "flicker"), vtense(s, "die"));
return;
}
if(obj->spe < 7) {
There("%s only %d %s in %s.",
vtense(s, "are"), obj->spe, s, the(xname(obj)));
if (!Blind)
pline("%s lit. %s dimly.",
obj->spe == 1 ? "It is" : "They are",
Tobjnam(obj, "shine"));
} else {
pline("%s's %s burn%s", The(xname(obj)), s,
(Blind ? "." : " brightly!"));
}
if (!invocation_pos(u.ux, u.uy)) {
pline_The("%s %s being rapidly consumed!", s, vtense(s, "are"));
/* this used to be obj->age /= 2, rounding down; an age of
* 1 would yield 0, confusing begin_burn() and producing an
* unlightable, unrefillable candelabrum; round up instead */
obj->age = (obj->age + 1L) / 2L;
/* to make absolutely sure the game doesn't become unwinnable as
* a consequence of a broken candelabrum */
if (obj->age == 0) {
impossible("Candelabrum with candles but no fuel?");