]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.do.c
1 /* $NetBSD: hack.do.c,v 1.4 1997/10/19 16:57:41 christos Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.do.c,v 1.4 1997/10/19 16:57:41 christos Exp $");
12 /* Contains code for 'd', 'D' (drop), '>', '<' (up, down) and 't' (throw) */
21 static int drop
__P((struct obj
*));
26 return (drop(getobj("0$#", "drop")));
35 if (obj
->olet
== '$') { /* pseudo object */
36 long amount
= OGOLD(obj
);
39 pline("You didn't drop any gold pieces.");
41 mkgold(amount
, u
.ux
, u
.uy
);
42 pline("You dropped %ld gold piece%s.",
43 amount
, plur(amount
));
50 if (obj
->owornmask
& (W_ARMOR
| W_RING
)) {
51 pline("You cannot drop something you are wearing.");
56 pline("Your weapon is welded to your hand!");
59 setuwep((struct obj
*) 0);
61 pline("You dropped %s.", doname(obj
));
66 /* Called in several places - should not produce texts */
79 if (obj
->otyp
== CRYSKNIFE
)
80 obj
->otyp
= WORM_TOOTH
;
91 /* drop several things */
95 return (ggetobj("drop", drop
, 0));
101 if (u
.ux
!= xdnstair
|| u
.uy
!= ydnstair
) {
102 pline("You can't go down here.");
106 pline("You are being held, and cannot go down.");
110 pline("You're floating high above the stairs.");
113 goto_level(dlevel
+ 1, TRUE
);
120 if (u
.ux
!= xupstair
|| u
.uy
!= yupstair
) {
121 pline("You can't go up here.");
125 pline("You are being held, and cannot go up.");
128 if (!Levitation
&& inv_weight() + 5 > 0) {
129 pline("Your load is too heavy to climb the stairs.");
132 goto_level(dlevel
- 1, TRUE
);
137 goto_level(newlevel
, at_stairs
)
142 boolean up
= (newlevel
< dlevel
);
145 done("escaped");/* in fact < 0 is impossible */
146 if (newlevel
> MAXLEVEL
)
147 newlevel
= MAXLEVEL
; /* strange ... */
148 if (newlevel
== dlevel
)
149 return; /* this can happen */
152 fd
= creat(lock
, FMASK
);
155 * This is not quite impossible: e.g., we may have
156 * exceeded our quota. If that is the case then we
157 * cannot leave this level, and cannot save either.
158 * Another possibility is that the directory was not
161 pline("A mysterious force prevents you from going %s.",
167 u
.utrap
= 0; /* needed in level_tele */
168 u
.ustuck
= 0; /* idem */
171 if (u
.uswallow
) /* idem */
172 u
.uswldtim
= u
.uswallow
= 0;
174 u
.ux
= FAR
; /* hack */
175 (void) inshop(); /* probably was a trapdoor */
181 if (maxdlevel
< dlevel
)
185 if (!level_exists
[dlevel
])
188 if ((fd
= open(lock
, 0)) < 0) {
189 pline("Cannot open %s .", lock
);
190 pline("Probably someone removed it.");
193 getlev(fd
, hackpid
, dlevel
);
201 if (!u
.ux
) { /* entering a maze from below? */
202 u
.ux
= xupstair
; /* this will confuse the
206 if (Punished
&& !Levitation
) {
207 pline("With great effort you climb the stairs.");
213 if (inv_weight() + 5 > 0 || Punished
) {
214 pline("You fall down the stairs."); /* %% */
215 losehp(rnd(3), "fall");
217 if (uwep
!= uball
&& rn2(3)) {
218 pline("... and are hit by the iron ball.");
219 losehp(rnd(20), "iron ball");
223 selftouch("Falling, you");
227 struct monst
*mtmp
= m_at(u
.ux
, u
.uy
);
231 } else { /* trapdoor or level_tele */
233 u
.ux
= rnd(COLNO
- 1);
235 } while (levl
[u
.ux
][u
.uy
].typ
!= ROOM
||
238 if (uwep
!= uball
&& !up
/* %% */ && rn2(5)) {
239 pline("The iron ball falls on your head.");
240 losehp(rnd(25), "iron ball");
244 selftouch("Falling, you");
252 if ((mtmp
= m_at(u
.ux
, u
.uy
)) != NULL
)
253 mnexto(mtmp
); /* riv05!a3 */
257 seeobjs(); /* make old cadavers disappear - riv05!a3 */
260 read_engr_at(u
.ux
, u
.uy
);
266 return (1); /* Do nothing, but let other things happen */
272 nomovemsg
= "You finished your prayer.";
284 obj
= getobj("#)", "throw"); /* it is also possible to throw food */
285 /* (or jewels, or iron balls ... ) */
286 if (!obj
|| !getdir(1)) /* ask "in what direction?" */
288 if (obj
->owornmask
& (W_ARMOR
| W_RING
)) {
289 pline("You can't throw something you are wearing.");
296 pline("Your weapon is welded to your hand.");
300 setuwep(splitobj(obj
, 1));
302 setuwep((struct obj
*) 0);
303 } else if (obj
->quan
> 1)
304 (void) splitobj(obj
, 1);
312 pline("%s hits the ceiling, then falls back on top of your head.",
313 Doname(obj
)); /* note: obj->quan == 1 */
314 if (obj
->olet
== POTION_SYM
)
315 potionhit(&youmonst
, obj
);
318 pline("Fortunately, you are wearing a helmet!");
319 losehp(uarmh
? 1 : rnd((int) (obj
->owt
)), "falling object");
323 pline("%s hits the floor.", Doname(obj
));
324 if (obj
->otyp
== EXPENSIVE_CAMERA
) {
325 pline("It is shattered in a thousand pieces!");
326 obfree(obj
, Null(obj
));
327 } else if (obj
->otyp
== EGG
) {
328 pline("\"Splash!\"");
329 obfree(obj
, Null(obj
));
330 } else if (obj
->olet
== POTION_SYM
) {
331 pline("The flask breaks, and you smell a peculiar odor ...");
333 obfree(obj
, Null(obj
));
339 } else if (obj
->otyp
== BOOMERANG
) {
340 mon
= boomhit(u
.dx
, u
.dy
);
341 if (mon
== &youmonst
) { /* the thing was caught */
346 if (obj
->otyp
== PICK_AXE
&& shkcatch(obj
))
349 mon
= bhit(u
.dx
, u
.dy
, (obj
->otyp
== ICE_BOX
) ? 1 :
350 (!Punished
|| obj
!= uball
) ? 8 : !u
.ustuck
? 5 : 1,
352 (void (*) __P((struct monst
*, struct obj
*))) 0,
353 (int (*) __P((struct obj
*, struct obj
*))) 0, obj
);
356 /* awake monster if sleeping */
359 if (obj
->olet
== WEAPON_SYM
) {
360 tmp
= -1 + u
.ulevel
+ mon
->data
->ac
+ abon();
361 if (obj
->otyp
< ROCK
) {
363 uwep
->otyp
!= obj
->otyp
+ (BOW
- ARROW
))
368 } else if (obj
->otyp
== BOOMERANG
)
371 if (u
.uswallow
|| tmp
>= rnd(20)) {
372 if (hmon(mon
, obj
, 1) == TRUE
) {
373 /* mon still alive */
375 cutworm(mon
, bhitpos
.x
, bhitpos
.y
, obj
->otyp
);
379 /* weapons thrown disappear sometimes */
380 if (obj
->otyp
< BOOMERANG
&& rn2(3)) {
381 /* check bill; free */
382 obfree(obj
, (struct obj
*) 0);
386 miss(objects
[obj
->otyp
].oc_name
, mon
);
387 } else if (obj
->otyp
== HEAVY_IRON_BALL
) {
388 tmp
= -1 + u
.ulevel
+ mon
->data
->ac
+ abon();
389 if (!Punished
|| obj
!= uball
)
393 if (u
.uswallow
|| tmp
>= rnd(20)) {
394 if (hmon(mon
, obj
, 1) == FALSE
)
395 mon
= 0; /* he died */
397 miss("iron ball", mon
);
398 } else if (obj
->olet
== POTION_SYM
&& u
.ulevel
> rn2(15)) {
402 if (cansee(bhitpos
.x
, bhitpos
.y
))
403 pline("You miss %s.", monnam(mon
));
405 pline("You miss it.");
406 if (obj
->olet
== FOOD_SYM
&& mon
->data
->mlet
== 'd')
407 if (tamedog(mon
, obj
))
409 if (obj
->olet
== GEM_SYM
&& mon
->data
->mlet
== 'u' &&
411 if (obj
->dknown
&& objects
[obj
->otyp
].oc_name_known
) {
412 if (objects
[obj
->otyp
].g_val
> 0) {
416 pline("%s is not interested in your junk.",
419 } else { /* value unknown to @ */
422 if (u
.uluck
> LUCKMAX
) /* dan@ut-ngp */
424 pline("%s graciously accepts your gift.",
433 /* the code following might become part of dropy() */
434 if (obj
->otyp
== CRYSKNIFE
)
435 obj
->otyp
= WORM_TOOTH
;
440 /* prevent him from throwing articles to the exit and escaping */
441 /* subfrombill(obj); */
443 if (Punished
&& obj
== uball
&&
444 (bhitpos
.x
!= u
.ux
|| bhitpos
.y
!= u
.uy
)) {
448 if (u
.utraptype
== TT_PIT
)
449 pline("The ball pulls you out of the pit!");
452 rn2(3) ? LEFT_SIDE
: RIGHT_SIDE
;
453 pline("The ball pulls you out of the bear trap.");
454 pline("Your %s leg is severely damaged.",
455 (side
== LEFT_SIDE
) ? "left" : "right");
456 set_wounded_legs(side
, 500 + rn2(1000));
457 losehp(2, "thrown ball");
464 u
.ux
= uchain
->ox
= bhitpos
.x
- u
.dx
;
465 u
.uy
= uchain
->oy
= bhitpos
.y
- u
.dy
;
469 if (cansee(bhitpos
.x
, bhitpos
.y
))
470 prl(bhitpos
.x
, bhitpos
.y
);
474 /* split obj so that it gets size num */
475 /* remainder is put in the object structure delivered by this call */
483 *otmp
= *obj
; /* copies whole structure */
484 otmp
->o_id
= flags
.ident
++;
487 obj
->owt
= weight(obj
);
489 otmp
->owt
= weight(otmp
); /* -= obj->owt ? */
492 splitbill(obj
, otmp
);
497 more_experienced(exp
, rexp
)
501 u
.urexp
+= 4 * exp
+ rexp
;
504 if (u
.urexp
>= ((pl_character
[0] == 'W') ? 1000 : 2000))
509 set_wounded_legs(side
, timex
)
513 if (!Wounded_legs
|| (Wounded_legs
& TIMEOUT
))
514 Wounded_legs
|= side
+ timex
;
516 Wounded_legs
|= side
;
523 if ((Wounded_legs
& BOTH_SIDES
) == BOTH_SIDES
)
524 pline("Your legs feel somewhat better.");
526 pline("Your leg feels somewhat better.");