]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.apply.c
1 /* $NetBSD: hack.apply.c,v 1.5 1997/10/19 16:57:32 christos Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.apply.c,v 1.5 1997/10/19 16:57:32 christos Exp $");
15 #include "def.mkroom.h"
17 static void use_camera
__P((struct obj
*));
18 static int in_ice_box
__P((struct obj
*));
19 static int ck_ice_box
__P((struct obj
*));
20 static int out_ice_box
__P((struct obj
*));
21 static void use_ice_box
__P((struct obj
*));
22 static struct monst
*bchit
__P((int, int , int , int));
23 static void use_whistle
__P((struct obj
*));
24 static void use_magic_whistle
__P((struct obj
*));
25 static int dig
__P((void));
26 static int use_pick_axe
__P((struct obj
*));
34 obj
= getobj("(", "use or apply");
39 case EXPENSIVE_CAMERA
:
46 res
= use_pick_axe(obj
);
50 if (pl_character
[0] == 'W' || u
.ulevel
> 9) {
51 use_magic_whistle(obj
);
54 /* fall into next case */
61 pline("You have no can to open.");
64 pline("You cannot open a tin without eating its contents.");
65 pline("In order to eat, use the 'e' command.");
67 pline("Opening the tin will be much easier if you wield the can-opener.");
71 pline("Sorry, I don't know how to use that.");
86 if (!getdir(1)) { /* ask: in what direction? */
87 flags
.move
= multi
= 0;
91 pline("You take a picture of %s's stomach.", monnam(u
.ustuck
));
95 pline("You take a picture of the %s.",
96 (u
.dz
> 0) ? "floor" : "ceiling");
99 if ((mtmp
= bchit(u
.dx
, u
.dy
, COLNO
, '!')) != NULL
) {
102 pline("The flash awakens %s.", monnam(mtmp
)); /* a3 */
103 } else if (mtmp
->data
->mlet
!= 'y')
104 if (mtmp
->mcansee
|| mtmp
->mblinded
) {
105 int tmp
= dist(mtmp
->mx
, mtmp
->my
);
107 if (cansee(mtmp
->mx
, mtmp
->my
))
108 pline("%s is blinded by the flash!", Monnam(mtmp
));
110 if (tmp
< 9 && !mtmp
->isshk
&& rn2(4)) {
113 mtmp
->mfleetim
= rnd(100);
116 mtmp
->mcansee
= mtmp
->mblinded
= 0;
118 tmp2
= mtmp
->mblinded
;
119 tmp2
+= rnd(1 + 50 / tmp
);
122 mtmp
->mblinded
= tmp2
;
130 struct obj
*current_ice_box
;/* a local variable of use_ice_box, to be
131 * used by its local procedures in/ck_ice_box */
136 if (obj
== current_ice_box
||
137 (Punished
&& (obj
== uball
|| obj
== uchain
))) {
138 pline("You must be kidding.");
141 if (obj
->owornmask
& (W_ARMOR
| W_RING
)) {
142 pline("You cannot refrigerate something you are wearing.");
145 if (obj
->owt
+ current_ice_box
->owt
> 70) {
146 pline("It won't fit.");
147 return (1); /* be careful! */
151 pline("Your weapon is welded to your hand!");
154 setuwep((struct obj
*) 0);
156 current_ice_box
->owt
+= obj
->owt
;
158 obj
->o_cnt_id
= current_ice_box
->o_id
;
161 obj
->age
= moves
- obj
->age
; /* actual age */
169 return (obj
->o_cnt_id
== current_ice_box
->o_id
);
180 for (otmp
= fcobj
; otmp
->nobj
!= obj
; otmp
= otmp
->nobj
)
182 panic("out_ice_box");
183 otmp
->nobj
= obj
->nobj
;
185 current_ice_box
->owt
-= obj
->owt
;
186 obj
->age
= moves
- obj
->age
; /* simulated point of time */
197 current_ice_box
= obj
; /* for use by in/out_ice_box */
198 for (otmp
= fcobj
; otmp
; otmp
= otmp
->nobj
)
199 if (otmp
->o_cnt_id
== obj
->o_id
)
202 pline("Your ice-box is empty.");
204 pline("Do you want to take something out of the ice-box? [yn] ");
205 if (readchar() == 'y')
206 if (askchain(fcobj
, (char *) 0, 0, out_ice_box
, ck_ice_box
, 0))
208 pline("That was all. Do you wish to put something in? [yn] ");
209 if (readchar() != 'y')
212 /* call getobj: 0: allow cnt; #: allow all types; %: expect food */
213 otmp
= getobj("0#%", "put in");
214 if (!otmp
|| !in_ice_box(otmp
))
215 flags
.move
= multi
= 0;
218 static struct monst
*
219 bchit(ddx
, ddy
, range
, sym
)
223 struct monst
*mtmp
= (struct monst
*) 0;
224 int bchx
= u
.ux
, bchy
= u
.uy
;
227 Tmp_at(-1, sym
);/* open call */
231 if ((mtmp
= m_at(bchx
, bchy
)) != NULL
)
233 if (!ZAP_POS(levl
[bchx
][bchy
].typ
)) {
251 struct monst
*mtmp
= fmon
;
252 pline("You produce a high whistling sound.");
254 if (dist(mtmp
->mx
, mtmp
->my
) < u
.ulevel
* 20) {
258 EDOG(mtmp
)->whistletime
= moves
;
266 use_magic_whistle(obj
)
269 struct monst
*mtmp
= fmon
;
270 pline("You produce a strange whistling sound.");
278 static int dig_effort
; /* effort expended on current pos */
279 static uchar dig_level
;
280 static coord dig_pos
;
281 static boolean dig_down
;
287 int dpx
= dig_pos
.x
, dpy
= dig_pos
.y
;
289 /* perhaps a nymph stole his pick-axe while he was busy digging */
290 /* or perhaps he teleported away */
291 if (u
.uswallow
|| !uwep
|| uwep
->otyp
!= PICK_AXE
||
292 dig_level
!= dlevel
||
293 ((dig_down
&& (dpx
!= u
.ux
|| dpy
!= u
.uy
)) ||
294 (!dig_down
&& dist(dpx
, dpy
) > 2)))
297 dig_effort
+= 10 + abon() + uwep
->spe
+ rn2(5);
300 pline("The floor here seems too hard to dig in.");
303 if (dig_effort
> 250) {
305 return (0); /* done with digging */
307 if (dig_effort
> 50) {
308 struct trap
*ttmp
= t_at(dpx
, dpy
);
311 ttmp
= maketrap(dpx
, dpy
, PIT
);
313 pline("You have dug a pit.");
315 u
.utraptype
= TT_PIT
;
319 } else if (dig_effort
> 100) {
323 lev
= &levl
[dpx
][dpy
];
324 if ((obj
= sobj_at(ENORMOUS_ROCK
, dpx
, dpy
)) != NULL
) {
326 digtxt
= "The rock falls apart.";
327 } else if (!lev
->typ
|| lev
->typ
== SCORR
) {
329 digtxt
= "You succeeded in cutting away some rock.";
330 } else if (lev
->typ
== HWALL
|| lev
->typ
== VWALL
331 || lev
->typ
== SDOOR
) {
332 lev
->typ
= xdnstair
? DOOR
: ROOM
;
333 digtxt
= "You just made an opening in the wall.";
335 digtxt
= "Now what exactly was it that you were digging in?";
338 pline(digtxt
); /* after mnewsym & prl */
341 if (IS_WALL(levl
[dpx
][dpy
].typ
)) {
342 int rno
= inroom(dpx
, dpy
);
344 if (rno
>= 0 && rooms
[rno
].rtype
>= 8) {
345 pline("This wall seems too hard to dig into.");
349 pline("You hit the rock with all your might.");
354 /* When will hole be finished? Very rough indication used by shopkeeper. */
358 return ((occupation
== dig
) ? (250 - dig_effort
) / 20 : -1);
364 struct trap
*ttmp
= t_at(u
.ux
, u
.uy
);
367 pline("The floor here seems too hard to dig in.");
370 ttmp
->ttyp
= TRAPDOOR
;
372 ttmp
= maketrap(u
.ux
, u
.uy
, TRAPDOOR
);
374 pline("You've made a hole in the floor.");
378 pline("You fall through ...");
379 if (u
.utraptype
== TT_PIT
) {
383 goto_level(dlevel
+ 1, FALSE
);
393 char *dsp
= dirsyms
, *sdp
= sdir
;
399 if (uwep
&& uwep
->cursed
) {
400 /* Andreas Bormann - ihnp4!decvax!mcvax!unido!ab */
401 pline("Since your weapon is welded to your hand,");
402 pline("you cannot use that pick-axe.");
405 pline("You now wield %s.", doname(obj
));
410 (void) movecmd(*sdp
); /* sets u.dx and u.dy and u.dz */
413 if (u
.dz
> 0 || (u
.dz
== 0 && isok(rx
, ry
) &&
414 (IS_ROCK(levl
[rx
][ry
].typ
)
415 || sobj_at(ENORMOUS_ROCK
, rx
, ry
))))
420 pline("In what direction do you want to dig? [%s] ", dirsyms
);
421 if (!getdir(0)) /* no txt */
423 if (u
.uswallow
&& attack(u
.ustuck
)) /* return(1) */
426 pline("You cannot reach the ceiling.");
427 else if (u
.dz
== 0) {
432 if ((mtmp
= m_at(rx
, ry
)) && attack(mtmp
))
439 if (lev
->typ
== DOOR
)
440 pline("Your %s against the door.",
441 aobjnam(obj
, "clang"));
442 else if (!IS_ROCK(lev
->typ
)
443 && !sobj_at(ENORMOUS_ROCK
, rx
, ry
)) {
444 /* ACCESSIBLE or POOL */
445 pline("You swing your %s through thin air.",
446 aobjnam(obj
, (char *) 0));
448 if (dig_pos
.x
!= rx
|| dig_pos
.y
!= ry
449 || dig_level
!= dlevel
|| dig_down
) {
455 pline("You start digging.");
457 pline("You continue digging.");
461 } else if (Levitation
) {
462 pline("You cannot reach the floor.");
464 if (dig_pos
.x
!= u
.ux
|| dig_pos
.y
!= u
.uy
465 || dig_level
!= dlevel
|| !dig_down
) {
471 pline("You start digging in the floor.");
475 pline("You continue digging in the floor.");