/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* hack.apply.c - version 1.0.3 */
static struct monst
*bchit();
extern struct obj
*addinv();
extern struct trap
*maketrap();
extern int (*occupation
)();
extern char pl_character
[];
static void use_camera(), use_ice_box(), use_whistle(), use_magic_whistle();
static int use_pick_axe();
register struct obj
*obj
;
obj
= getobj("(", "use or apply");
if(pl_character
[0] == 'W' || u
.ulevel
> 9) {
/* fall into next case */
pline("You have no can to open.");
pline("You cannot open a tin without eating its contents.");
pline("In order to eat, use the 'e' command.");
pline("Opening the tin will be much easier if you wield the can-opener.");
pline("Sorry, I don't know how to use that.");
use_camera(obj
) /* register */ struct obj
*obj
; {
register struct monst
*mtmp
;
if(!getdir(1)){ /* ask: in what direction? */
pline("You take a picture of %s's stomach.", monnam(u
.ustuck
));
pline("You take a picture of the %s.",
(u
.dz
> 0) ? "floor" : "ceiling");
if(mtmp
= bchit(u
.dx
, u
.dy
, COLNO
, '!')) {
pline("The flash awakens %s.", monnam(mtmp
)); /* a3 */
if(mtmp
->data
->mlet
!= 'y')
if(mtmp
->mcansee
|| mtmp
->mblinded
){
register int tmp
= dist(mtmp
->mx
,mtmp
->my
);
if(cansee(mtmp
->mx
,mtmp
->my
))
pline("%s is blinded by the flash!", Monnam(mtmp
));
if(tmp
< 9 && !mtmp
->isshk
&& rn2(4)) {
if(rn2(4)) mtmp
->mfleetim
= rnd(100);
if(tmp
< 3) mtmp
->mcansee
= mtmp
->mblinded
= 0;
if(tmp2
> 127) tmp2
= 127;
struct obj
*current_ice_box
; /* a local variable of use_ice_box, to be
used by its local procedures in/ck_ice_box */
in_ice_box(obj
) register struct obj
*obj
; {
if(obj
== current_ice_box
||
(Punished
&& (obj
== uball
|| obj
== uchain
))){
pline("You must be kidding.");
if(obj
->owornmask
& (W_ARMOR
| W_RING
)) {
pline("You cannot refrigerate something you are wearing.");
if(obj
->owt
+ current_ice_box
->owt
> 70) {
return(1); /* be careful! */
pline("Your weapon is welded to your hand!");
setuwep((struct obj
*) 0);
current_ice_box
->owt
+= obj
->owt
;
obj
->o_cnt_id
= current_ice_box
->o_id
;
obj
->age
= moves
- obj
->age
; /* actual age */
ck_ice_box(obj
) register struct obj
*obj
; {
return(obj
->o_cnt_id
== current_ice_box
->o_id
);
out_ice_box(obj
) register struct obj
*obj
; {
register struct obj
*otmp
;
if(obj
== fcobj
) fcobj
= fcobj
->nobj
;
for(otmp
= fcobj
; otmp
->nobj
!= obj
; otmp
= otmp
->nobj
)
if(!otmp
->nobj
) panic("out_ice_box");
current_ice_box
->owt
-= obj
->owt
;
obj
->age
= moves
- obj
->age
; /* simulated point of time */
use_ice_box(obj
) register struct obj
*obj
; {
register struct obj
*otmp
;
current_ice_box
= obj
; /* for use by in/out_ice_box */
for(otmp
= fcobj
; otmp
; otmp
= otmp
->nobj
)
if(otmp
->o_cnt_id
== obj
->o_id
)
if(!cnt
) pline("Your ice-box is empty.");
pline("Do you want to take something out of the ice-box? [yn] ");
if(askchain(fcobj
, (char *) 0, 0, out_ice_box
, ck_ice_box
, 0))
pline("That was all. Do you wish to put something in? [yn] ");
if(readchar() != 'y') return;
/* call getobj: 0: allow cnt; #: allow all types; %: expect food */
otmp
= getobj("0#%", "put in");
if(!otmp
|| !in_ice_box(otmp
))
bchit(ddx
,ddy
,range
,sym
) register int ddx
,ddy
,range
; char sym
; {
register struct monst
*mtmp
= (struct monst
*) 0;
register int bchx
= u
.ux
, bchy
= u
.uy
;
if(sym
) Tmp_at(-1, sym
); /* open call */
if(mtmp
= m_at(bchx
,bchy
))
if(!ZAP_POS(levl
[bchx
][bchy
].typ
)) {
if(sym
) Tmp_at(bchx
, bchy
);
use_whistle(obj
) struct obj
*obj
; {
register struct monst
*mtmp
= fmon
;
pline("You produce a high whistling sound.");
if(dist(mtmp
->mx
,mtmp
->my
) < u
.ulevel
*20) {
EDOG(mtmp
)->whistletime
= moves
;
use_magic_whistle(obj
) struct obj
*obj
; {
register struct monst
*mtmp
= fmon
;
pline("You produce a strange whistling sound.");
if(mtmp
->mtame
) mnexto(mtmp
);
static int dig_effort
; /* effort expended on current pos */
register dpx
= dig_pos
.x
, dpy
= dig_pos
.y
;
/* perhaps a nymph stole his pick-axe while he was busy digging */
/* or perhaps he teleported away */
if(u
.uswallow
|| !uwep
|| uwep
->otyp
!= PICK_AXE
||
((dig_down
&& (dpx
!= u
.ux
|| dpy
!= u
.uy
)) ||
(!dig_down
&& dist(dpx
,dpy
) > 2)))
dig_effort
+= 10 + abon() + uwep
->spe
+ rn2(5);
pline("The floor here seems too hard to dig in.");
return(0); /* done with digging */
register struct trap
*ttmp
= t_at(dpx
,dpy
);
ttmp
= maketrap(dpx
,dpy
,PIT
);
pline("You have dug a pit.");
register struct obj
*obj
;
if(obj
= sobj_at(ENORMOUS_ROCK
, dpx
, dpy
)) {
digtxt
= "The rock falls apart.";
} else if(!lev
->typ
|| lev
->typ
== SCORR
) {
digtxt
= "You succeeded in cutting away some rock.";
} else if(lev
->typ
== HWALL
|| lev
->typ
== VWALL
lev
->typ
= xdnstair
? DOOR
: ROOM
;
digtxt
= "You just made an opening in the wall.";
digtxt
= "Now what exactly was it that you were digging in?";
pline(digtxt
); /* after mnewsym & prl */
if(IS_WALL(levl
[dpx
][dpy
].typ
)) {
register int rno
= inroom(dpx
,dpy
);
if(rno
>= 0 && rooms
[rno
].rtype
>= 8) {
pline("This wall seems too hard to dig into.");
pline("You hit the rock with all your might.");
/* When will hole be finished? Very rough indication used by shopkeeper. */
return( (occupation
== dig
) ? (250 - dig_effort
)/20 : -1);
register struct trap
*ttmp
= t_at(u
.ux
, u
.uy
);
pline("The floor here seems too hard to dig in.");
ttmp
= maketrap(u
.ux
, u
.uy
, TRAPDOOR
);
pline("You've made a hole in the floor.");
pline("You fall through ...");
if(u
.utraptype
== TT_PIT
) {
goto_level(dlevel
+1, FALSE
);
register char *dsp
= dirsyms
, *sdp
= sdir
;
register struct monst
*mtmp
;
register int rx
, ry
, res
= 0;
if(uwep
&& uwep
->cursed
) {
/* Andreas Bormann - ihnp4!decvax!mcvax!unido!ab */
pline("Since your weapon is welded to your hand,");
pline("you cannot use that pick-axe.");
pline("You now wield %s.", doname(obj
));
(void) movecmd(*sdp
); /* sets u.dx and u.dy and u.dz */
if(u
.dz
> 0 || (u
.dz
== 0 && isok(rx
, ry
) &&
(IS_ROCK(levl
[rx
][ry
].typ
)
|| sobj_at(ENORMOUS_ROCK
, rx
, ry
))))
pline("In what direction do you want to dig? [%s] ", dirsyms
);
if(!getdir(0)) /* no txt */
if(u
.uswallow
&& attack(u
.ustuck
)) /* return(1) */;
pline("You cannot reach the ceiling.");
if((mtmp
= m_at(rx
, ry
)) && attack(mtmp
))
pline("Your %s against the door.",
else if(!IS_ROCK(lev
->typ
)
&& !sobj_at(ENORMOUS_ROCK
, rx
, ry
)) {
pline("You swing your %s through thin air.",
aobjnam(obj
, (char *) 0));
if(dig_pos
.x
!= rx
|| dig_pos
.y
!= ry
|| dig_level
!= dlevel
|| dig_down
) {
pline("You start digging.");
pline("You continue digging.");
pline("You cannot reach the floor.");
if(dig_pos
.x
!= u
.ux
|| dig_pos
.y
!= u
.uy
|| dig_level
!= dlevel
|| !dig_down
) {
pline("You start digging in the floor.");
pline("You continue digging in the floor.");