/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* hack.do.c - version 1.0.3 */
/* Contains code for 'd', 'D' (drop), '>', '<' (up, down) and 't' (throw) */
extern struct obj
*splitobj(), *addinv();
extern boolean level_exists
[];
extern struct monst youmonst
;
return(drop(getobj("0$#", "drop")));
drop(obj
) register struct obj
*obj
; {
if(obj
->olet
== '$') { /* pseudo object */
register long amount
= OGOLD(obj
);
pline("You didn't drop any gold pieces.");
mkgold(amount
, u
.ux
, u
.uy
);
pline("You dropped %ld gold piece%s.",
if(Invisible
) newsym(u
.ux
, u
.uy
);
if(obj
->owornmask
& (W_ARMOR
| W_RING
)){
pline("You cannot drop something you are wearing.");
pline("Your weapon is welded to your hand!");
setuwep((struct obj
*) 0);
pline("You dropped %s.", doname(obj
));
/* Called in several places - should not produce texts */
register struct obj
*obj
;
register struct obj
*obj
;
if(obj
->otyp
== CRYSKNIFE
)
if(Invisible
) newsym(u
.ux
,u
.uy
);
/* drop several things */
return(ggetobj("drop", drop
, 0));
if(u
.ux
!= xdnstair
|| u
.uy
!= ydnstair
) {
pline("You can't go down here.");
pline("You are being held, and cannot go down.");
pline("You're floating high above the stairs.");
goto_level(dlevel
+1, TRUE
);
if(u
.ux
!= xupstair
|| u
.uy
!= yupstair
) {
pline("You can't go up here.");
pline("You are being held, and cannot go up.");
if(!Levitation
&& inv_weight() + 5 > 0) {
pline("Your load is too heavy to climb the stairs.");
goto_level(dlevel
-1, TRUE
);
goto_level(newlevel
, at_stairs
)
register boolean at_stairs
;
register boolean up
= (newlevel
< dlevel
);
if(newlevel
<= 0) done("escaped"); /* in fact < 0 is impossible */
if(newlevel
> MAXLEVEL
) newlevel
= MAXLEVEL
; /* strange ... */
if(newlevel
== dlevel
) return; /* this can happen */
* This is not quite impossible: e.g., we may have
* exceeded our quota. If that is the case then we
* cannot leave this level, and cannot save either.
* Another possibility is that the directory was not
pline("A mysterious force prevents you from going %s.",
if(Punished
) unplacebc();
u
.utrap
= 0; /* needed in level_tele */
if(u
.uswallow
) /* idem */
u
.uswldtim
= u
.uswallow
= 0;
(void) inshop(); /* probably was a trapdoor */
if(!level_exists
[dlevel
])
if((fd
= open(lock
,0)) < 0) {
pline("Cannot open %s .", lock
);
pline("Probably someone removed it.");
getlev(fd
, hackpid
, dlevel
);
if(!u
.ux
) { /* entering a maze from below? */
u
.ux
= xupstair
; /* this will confuse the player! */
if(Punished
&& !Levitation
){
pline("With great effort you climb the stairs.");
if(inv_weight() + 5 > 0 || Punished
){
pline("You fall down the stairs."); /* %% */
if(uwep
!= uball
&& rn2(3)){
pline("... and are hit by the iron ball.");
losehp(rnd(20), "iron ball");
selftouch("Falling, you");
{ register struct monst
*mtmp
= m_at(u
.ux
, u
.uy
);
} else { /* trapdoor or level_tele */
} while(levl
[u
.ux
][u
.uy
].typ
!= ROOM
||
if(uwep
!= uball
&& !up
/* %% */ && rn2(5)){
pline("The iron ball falls on your head.");
losehp(rnd(25), "iron ball");
selftouch("Falling, you");
{ register struct monst
*mtmp
;
if(mtmp
= m_at(u
.ux
, u
.uy
)) mnexto(mtmp
); /* riv05!a3 */
seeobjs(); /* make old cadavers disappear - riv05!a3 */
return(1); /* Do nothing, but let other things happen */
nomovemsg
= "You finished your prayer.";
struct monst
*bhit(), *boomhit();
register struct obj
*obj
;
register struct monst
*mon
;
obj
= getobj("#)", "throw"); /* it is also possible to throw food */
/* (or jewels, or iron balls ... ) */
if(!obj
|| !getdir(1)) /* ask "in what direction?" */
if(obj
->owornmask
& (W_ARMOR
| W_RING
)){
pline("You can't throw something you are wearing.");
pline("Your weapon is welded to your hand.");
setuwep(splitobj(obj
, 1));
setuwep((struct obj
*) 0);
pline("%s hits the ceiling, then falls back on top of your head.",
Doname(obj
)); /* note: obj->quan == 1 */
if(obj
->olet
== POTION_SYM
)
potionhit(&youmonst
, obj
);
if(uarmh
) pline("Fortunately, you are wearing a helmet!");
losehp(uarmh
? 1 : rnd((int)(obj
->owt
)), "falling object");
pline("%s hits the floor.", Doname(obj
));
if(obj
->otyp
== EXPENSIVE_CAMERA
) {
pline("It is shattered in a thousand pieces!");
} else if(obj
->otyp
== EGG
) {
} else if(obj
->olet
== POTION_SYM
) {
pline("The flask breaks, and you smell a peculiar odor ...");
} else if(obj
->otyp
== BOOMERANG
) {
mon
= boomhit(u
.dx
, u
.dy
);
if(mon
== &youmonst
) { /* the thing was caught */
if(obj
->otyp
== PICK_AXE
&& shkcatch(obj
))
mon
= bhit(u
.dx
, u
.dy
, (obj
->otyp
== ICE_BOX
) ? 1 :
(!Punished
|| obj
!= uball
) ? 8 : !u
.ustuck
? 5 : 1,
(int (*)()) 0, (int (*)()) 0, obj
);
/* awake monster if sleeping */
if(obj
->olet
== WEAPON_SYM
) {
tmp
= -1+u
.ulevel
+mon
->data
->ac
+abon();
uwep
->otyp
!= obj
->otyp
+(BOW
-ARROW
))
if(obj
->otyp
== BOOMERANG
) tmp
+= 4;
if(u
.uswallow
|| tmp
>= rnd(20)) {
if(hmon(mon
,obj
,1) == TRUE
){
cutworm(mon
,bhitpos
.x
,bhitpos
.y
,obj
->otyp
);
/* weapons thrown disappear sometimes */
if(obj
->otyp
< BOOMERANG
&& rn2(3)) {
obfree(obj
, (struct obj
*) 0);
} else miss(objects
[obj
->otyp
].oc_name
, mon
);
} else if(obj
->otyp
== HEAVY_IRON_BALL
) {
tmp
= -1+u
.ulevel
+mon
->data
->ac
+abon();
if(!Punished
|| obj
!= uball
) tmp
+= 2;
if(u
.uswallow
|| tmp
>= rnd(20)) {
if(hmon(mon
,obj
,1) == FALSE
)
} else miss("iron ball", mon
);
} else if(obj
->olet
== POTION_SYM
&& u
.ulevel
> rn2(15)) {
if(cansee(bhitpos
.x
,bhitpos
.y
))
pline("You miss %s.",monnam(mon
));
else pline("You miss it.");
if(obj
->olet
== FOOD_SYM
&& mon
->data
->mlet
== 'd')
if(tamedog(mon
,obj
)) return(1);
if(obj
->olet
== GEM_SYM
&& mon
->data
->mlet
== 'u' &&
if(obj
->dknown
&& objects
[obj
->otyp
].oc_name_known
){
if(objects
[obj
->otyp
].g_val
> 0){
pline("%s is not interested in your junk.",
} else { /* value unknown to @ */
if(u
.uluck
> LUCKMAX
) /* dan@ut-ngp */
pline("%s graciously accepts your gift.",
/* the code following might become part of dropy() */
if(obj
->otyp
== CRYSKNIFE
)
/* prevent him from throwing articles to the exit and escaping */
if(Punished
&& obj
== uball
&&
(bhitpos
.x
!= u
.ux
|| bhitpos
.y
!= u
.uy
)){
if(u
.utraptype
== TT_PIT
)
pline("The ball pulls you out of the pit!");
rn2(3) ? LEFT_SIDE
: RIGHT_SIDE
;
pline("The ball pulls you out of the bear trap.");
pline("Your %s leg is severely damaged.",
(side
== LEFT_SIDE
) ? "left" : "right");
set_wounded_legs(side
, 500+rn2(1000));
losehp(2, "thrown ball");
u
.ux
= uchain
->ox
= bhitpos
.x
- u
.dx
;
u
.uy
= uchain
->oy
= bhitpos
.y
- u
.dy
;
if(cansee(bhitpos
.x
, bhitpos
.y
)) prl(bhitpos
.x
,bhitpos
.y
);
/* split obj so that it gets size num */
/* remainder is put in the object structure delivered by this call */
splitobj(obj
, num
) register struct obj
*obj
; register int num
; {
register struct obj
*otmp
;
*otmp
= *obj
; /* copies whole structure */
otmp
->o_id
= flags
.ident
++;
otmp
->owt
= weight(otmp
); /* -= obj->owt ? */
if(obj
->unpaid
) splitbill(obj
,otmp
);
more_experienced(exp
,rexp
)
extern char pl_character
[];
if(u
.urexp
>= ((pl_character
[0] == 'W') ? 1000 : 2000))
set_wounded_legs(side
, timex
)
if(!Wounded_legs
|| (Wounded_legs
& TIMEOUT
))
Wounded_legs
|= side
+ timex
;
if((Wounded_legs
& BOTH_SIDES
) == BOTH_SIDES
)
pline("Your legs feel somewhat better.");
pline("Your leg feels somewhat better.");