]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.trap.c
1 /* $NetBSD: hack.trap.c,v 1.6 2001/03/25 20:44:03 jsm Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.trap.c,v 1.6 2001/03/25 20:44:03 jsm Exp $");
15 #include "def.mkroom.h"
17 const char vowels
[] = "aeiou";
19 const char *const traps
[] = {
24 " teleportation trap",
52 int ttype
= trap
->ttyp
;
55 if (trap
->tseen
&& !rn2(5) && ttype
!= PIT
)
56 pline("You escape a%s.", traps
[ttype
]);
61 pline("A cloud of gas puts you to sleep!");
66 pline("You float over a bear trap.");
70 u
.utraptype
= TT_BEARTRAP
;
71 pline("A bear trap closes on your foot!");
75 if (makemon(PM_PIERCER
, u
.ux
, u
.uy
)) {
76 pline("A piercer suddenly drops from the ceiling!");
78 pline("Its blow glances off your helmet.");
80 (void) thitu(3, d(4, 6), "falling piercer");
84 pline("An arrow shoots out at you!");
85 if (!thitu(8, rnd(6), "arrow")) {
86 mksobj_at(ARROW
, u
.ux
, u
.uy
);
92 pline("A trap door in the ceiling opens and a rock falls on your head!");
94 pline("Fortunately, you are wearing a helmet!");
95 losehp(uarmh
? 2 : d(2, 10), "falling rock");
96 mksobj_at(ROCK
, u
.ux
, u
.uy
);
102 int newlevel
= dlevel
+ 1;
103 while (!rn2(4) && newlevel
< 29)
105 pline("A trap door opens up under you!");
106 if (Levitation
|| u
.ustuck
) {
107 pline("For some reason you don't fall in.");
110 goto_level(newlevel
, FALSE
);
114 pline("A little dart shoots out at you!");
115 if (thitu(7, rnd(3), "little dart")) {
117 poisoned("dart", "poison dart");
119 mksobj_at(DART
, u
.ux
, u
.uy
);
135 pline("A pit opens up under you!");
136 pline("You don't fall in!");
139 pline("You fall into a pit!");
141 u
.utraptype
= TT_PIT
;
142 losehp(rnd(6), "fall into a pit");
143 selftouch("Falling, you");
146 impossible("You hit a trap of type %u", trap
->ttyp
);
155 struct trap
*trap
= t_at(mtmp
->mx
, mtmp
->my
);
156 int wasintrap
= mtmp
->mtrapped
;
159 mtmp
->mtrapped
= 0; /* perhaps teleported? */
160 } else if (wasintrap
) {
165 int in_sight
= cansee(mtmp
->mx
, mtmp
->my
);
167 if (mtmp
->mtrapseen
& (1 << tt
)) {
168 /* he has been in such a trap - perhaps he escapes */
172 mtmp
->mtrapseen
|= (1 << tt
);
175 if (strchr(mlarge
, mtmp
->data
->mlet
)) {
177 pline("%s is caught in a bear trap!",
179 else if (mtmp
->data
->mlet
== 'o')
180 pline("You hear the roaring of an angry bear!");
185 /* there should be a mtmp/data -> floating */
186 if (!strchr("EywBfk'& ", mtmp
->data
->mlet
)) { /* ab */
189 pline("%s falls in a pit!", Monnam(mtmp
));
193 if (!mtmp
->msleep
&& !mtmp
->mfroz
) {
196 pline("%s suddenly falls asleep!",
202 if (in_sight
&& !cansee(mtmp
->mx
, mtmp
->my
))
203 pline("%s suddenly disappears!",
208 pline("%s is hit by an arrow!",
215 pline("%s is hit by a dart!",
219 /* not mondied here !! */
225 pline("A trap door in the ceiling opens and a rock hits %s!", monnam(mtmp
));
228 if (mtmp
->data
->mlet
!= 'w') {
231 pline("Suddenly, %s disappears out of sight.", monnam(mtmp
));
232 return (2); /* no longer on this level */
238 impossible("Some monster encountered a strange trap.");
241 return (mtmp
->mtrapped
);
248 if (uwep
&& uwep
->otyp
== DEAD_COCKATRICE
) {
249 pline("%s touch the dead cockatrice.", arg
);
250 pline("You turn to stone.");
251 killer
= objects
[uwep
->otyp
].oc_name
;
260 if (u
.utraptype
== TT_PIT
) {
262 pline("You float up, out of the pit!");
264 pline("You float up, only your leg is still stuck.");
267 pline("You start to float in the air!");
274 pline("You float gently to the ground.");
275 if ((trap
= t_at(u
.ux
, u
.uy
)) != NULL
)
276 switch (trap
->ttyp
) {
280 if (!xdnstair
|| u
.ustuck
)
282 /* fall into next case */
292 struct mkroom
*croom
;
293 for (croom
= &rooms
[0]; croom
->hx
>= 0; croom
++)
294 if (croom
->rtype
== VAULT
) {
297 x
= rn2(2) ? croom
->lx
: croom
->hx
;
298 y
= rn2(2) ? croom
->ly
: croom
->hy
;
313 if (Teleport_control
) {
314 pline("To what position do you want to be teleported?");
315 cc
= getpos(1, "the desired position"); /* 1: force valid */
317 * possible extensions: introduce a small error if magic
318 * power is low; allow transfer to solid rock
320 if (teleok(cc
.x
, cc
.y
)) {
327 nux
= rnd(COLNO
- 1);
329 } while (!teleok(nux
, nuy
));
348 u
.uswldtim
= u
.uswallow
= 0;
352 if (levl
[nux
][nuy
].typ
== POOL
&& !Levitation
)
357 read_engr_at(u
.ux
, u
.uy
);
363 { /* might throw him into a POOL */
364 return (isok(x
, y
) && !IS_ROCK(levl
[x
][y
].typ
) && !m_at(x
, y
) &&
365 !sobj_at(ENORMOUS_ROCK
, x
, y
) && !t_at(x
, y
)
367 /* Note: gold is permitted (because of vaults) */
377 (!Teleportation
|| u
.ulevel
< 6 ||
378 (pl_character
[0] != 'W' && u
.ulevel
< 10))) {
379 pline("You are not able to teleport at will.");
382 if (u
.uhunger
<= 100 || u
.ustr
< 6) {
383 pline("You miss the strength for a teleport spell.");
395 if (!uchain
|| !uball
) {
396 impossible("Where are your chain and ball??");
399 uball
->ox
= uchain
->ox
= u
.ux
;
400 uball
->oy
= uchain
->oy
= u
.uy
;
404 if (!carried(uball
)) {
414 if (!carried(uball
)) {
426 if (Teleport_control
) {
430 pline("To what level do you want to teleport? [type a number] ");
432 } while (!digit(buf
[0]) && (buf
[0] != '-' || !digit(buf
[1])));
433 newlevel
= atoi(buf
);
435 newlevel
= 5 + rn2(20); /* 5 - 24 */
436 if (dlevel
== newlevel
) {
443 if (newlevel
>= 30) {
444 if (newlevel
> MAXLEVEL
)
446 pline("You arrive at the center of the earth ...");
447 pline("Unfortunately it is here that hell is located.");
448 if (Fire_resistance
) {
449 pline("But the fire doesn't seem to harm you.");
451 pline("You burn to a crisp.");
452 dlevel
= maxdlevel
= newlevel
;
453 killer
= "visit to the hell";
459 pline("You are now high above the clouds ...");
461 pline("You float gently down to earth.");
464 pline("Unfortunately, you don't know how to fly.");
465 pline("You fall down a few thousand feet and break your neck.");
470 goto_level(newlevel
, FALSE
); /* calls done("escaped") if
477 pline("You fall into a pool!");
478 pline("You can't swim!");
479 if (rn2(3) < u
.uluck
+ 2) {
480 /* most scrolls become unreadable */
483 for (obj
= invent
; obj
; obj
= obj
->nobj
)
484 if (obj
->olet
== SCROLL_SYM
&& rn2(12) > u
.uluck
)
485 obj
->otyp
= SCR_BLANK_PAPER
;
486 /* we should perhaps merge these scrolls ? */
488 pline("You attempt a teleport spell."); /* utcsri!carroll */
490 if (levl
[u
.ux
][u
.uy
].typ
!= POOL
)
493 pline("You drown ...");
494 killer
= "pool of water";