]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.trap.c
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
6 static char rcsid
[] = "$Id: hack.trap.c,v 1.2 1993/08/02 17:19:32 mycroft Exp $";
11 extern struct monst
*makemon();
13 char vowels
[] = "aeiou";
20 " teleportation trap",
31 register struct trap
*ttmp
;
44 dotrap(trap
) register struct trap
*trap
; {
45 register int ttype
= trap
->ttyp
;
48 if(trap
->tseen
&& !rn2(5) && ttype
!= PIT
)
49 pline("You escape a%s.", traps
[ttype
]);
54 pline("A cloud of gas puts you to sleep!");
59 pline("You float over a bear trap.");
63 u
.utraptype
= TT_BEARTRAP
;
64 pline("A bear trap closes on your foot!");
68 if(makemon(PM_PIERCER
,u
.ux
,u
.uy
)) {
69 pline("A piercer suddenly drops from the ceiling!");
71 pline("Its blow glances off your helmet.");
73 (void) thitu(3,d(4,6),"falling piercer");
77 pline("An arrow shoots out at you!");
78 if(!thitu(8,rnd(6),"arrow")){
79 mksobj_at(ARROW
, u
.ux
, u
.uy
);
85 pline("A trap door in the ceiling opens and a rock falls on your head!");
86 if(uarmh
) pline("Fortunately, you are wearing a helmet!");
87 losehp(uarmh
? 2 : d(2,10),"falling rock");
88 mksobj_at(ROCK
, u
.ux
, u
.uy
);
91 if(Invisible
) newsym(u
.ux
, u
.uy
);
93 register int newlevel
= dlevel
+ 1;
94 while(!rn2(4) && newlevel
< 29)
96 pline("A trap door opens up under you!");
97 if(Levitation
|| u
.ustuck
) {
98 pline("For some reason you don't fall in.");
102 goto_level(newlevel
, FALSE
);
106 pline("A little dart shoots out at you!");
107 if(thitu(7,rnd(3),"little dart")) {
109 poisoned("dart","poison dart");
111 mksobj_at(DART
, u
.ux
, u
.uy
);
127 pline("A pit opens up under you!");
128 pline("You don't fall in!");
131 pline("You fall into a pit!");
133 u
.utraptype
= TT_PIT
;
134 losehp(rnd(6),"fall into a pit");
135 selftouch("Falling, you");
138 impossible("You hit a trap of type %u", trap
->ttyp
);
143 mintrap(mtmp
) register struct monst
*mtmp
; {
144 register struct trap
*trap
= t_at(mtmp
->mx
, mtmp
->my
);
145 register int wasintrap
= mtmp
->mtrapped
;
148 mtmp
->mtrapped
= 0; /* perhaps teleported? */
149 } else if(wasintrap
) {
150 if(!rn2(40)) mtmp
->mtrapped
= 0;
152 register int tt
= trap
->ttyp
;
153 int in_sight
= cansee(mtmp
->mx
,mtmp
->my
);
154 extern char mlarge
[];
156 if(mtmp
->mtrapseen
& (1 << tt
)) {
157 /* he has been in such a trap - perhaps he escapes */
158 if(rn2(4)) return(0);
160 mtmp
->mtrapseen
|= (1 << tt
);
163 if(index(mlarge
, mtmp
->data
->mlet
)) {
165 pline("%s is caught in a bear trap!",
168 if(mtmp
->data
->mlet
== 'o')
169 pline("You hear the roaring of an angry bear!");
174 /* there should be a mtmp/data -> floating */
175 if(!index("EywBfk'& ", mtmp
->data
->mlet
)) { /* ab */
178 pline("%s falls in a pit!", Monnam(mtmp
));
182 if(!mtmp
->msleep
&& !mtmp
->mfroz
) {
185 pline("%s suddenly falls asleep!",
191 if(in_sight
&& !cansee(mtmp
->mx
,mtmp
->my
))
192 pline("%s suddenly disappears!",
197 pline("%s is hit by an arrow!",
204 pline("%s is hit by a dart!",
208 /* not mondied here !! */
214 pline("A trap door in the ceiling opens and a rock hits %s!", monnam(mtmp
));
217 if(mtmp
->data
->mlet
!= 'w'){
220 pline("Suddenly, %s disappears out of sight.", monnam(mtmp
));
221 return(2); /* no longer on this level */
227 impossible("Some monster encountered a strange trap.");
230 return(mtmp
->mtrapped
);
233 selftouch(arg
) char *arg
; {
234 if(uwep
&& uwep
->otyp
== DEAD_COCKATRICE
){
235 pline("%s touch the dead cockatrice.", arg
);
236 pline("You turn to stone.");
237 killer
= objects
[uwep
->otyp
].oc_name
;
244 if(u
.utraptype
== TT_PIT
) {
246 pline("You float up, out of the pit!");
248 pline("You float up, only your leg is still stuck.");
251 pline("You start to float in the air!");
255 register struct trap
*trap
;
256 pline("You float gently to the ground.");
257 if(trap
= t_at(u
.ux
,u
.uy
))
262 if(!xdnstair
|| u
.ustuck
) break;
263 /* fall into next case */
271 #include "def.mkroom.h"
272 register struct mkroom
*croom
;
273 for(croom
= &rooms
[0]; croom
->hx
>= 0; croom
++)
274 if(croom
->rtype
== VAULT
) {
277 x
= rn2(2) ? croom
->lx
: croom
->hx
;
278 y
= rn2(2) ? croom
->ly
: croom
->hy
;
288 extern coord
getpos();
290 register int nux
,nuy
;
292 if(Teleport_control
) {
293 pline("To what position do you want to be teleported?");
294 cc
= getpos(1, "the desired position"); /* 1: force valid */
295 /* possible extensions: introduce a small error if
296 magic power is low; allow transfer to solid rock */
297 if(teleok(cc
.x
, cc
.y
)){
306 } while(!teleok(nux
, nuy
));
311 register int nux
,nuy
;
313 if(Punished
) unplacebc();
320 if(Punished
) placebc(1);
322 u
.uswldtim
= u
.uswallow
= 0;
326 if(levl
[nux
][nuy
].typ
== POOL
&& !Levitation
)
330 if(!Blind
) read_engr_at(u
.ux
,u
.uy
);
333 teleok(x
,y
) register int x
,y
; { /* might throw him into a POOL */
334 return( isok(x
,y
) && !IS_ROCK(levl
[x
][y
].typ
) && !m_at(x
,y
) &&
335 !sobj_at(ENORMOUS_ROCK
,x
,y
) && !t_at(x
,y
)
337 /* Note: gold is permitted (because of vaults) */
341 extern char pl_character
[];
347 (!Teleportation
|| u
.ulevel
< 6 ||
348 (pl_character
[0] != 'W' && u
.ulevel
< 10))) {
349 pline("You are not able to teleport at will.");
352 if(u
.uhunger
<= 100 || u
.ustr
< 6) {
353 pline("You miss the strength for a teleport spell.");
361 placebc(attach
) int attach
; {
362 if(!uchain
|| !uball
){
363 impossible("Where are your chain and ball??");
366 uball
->ox
= uchain
->ox
= u
.ux
;
367 uball
->oy
= uchain
->oy
= u
.uy
;
388 register int newlevel
;
389 if(Teleport_control
) {
393 pline("To what level do you want to teleport? [type a number] ");
395 } while(!digit(buf
[0]) && (buf
[0] != '-' || !digit(buf
[1])));
396 newlevel
= atoi(buf
);
398 newlevel
= 5 + rn2(20); /* 5 - 24 */
399 if(dlevel
== newlevel
)
400 if(!xdnstair
) newlevel
--; else newlevel
++;
403 if(newlevel
> MAXLEVEL
) newlevel
= MAXLEVEL
;
404 pline("You arrive at the center of the earth ...");
405 pline("Unfortunately it is here that hell is located.");
406 if(Fire_resistance
) {
407 pline("But the fire doesn't seem to harm you.");
409 pline("You burn to a crisp.");
410 dlevel
= maxdlevel
= newlevel
;
411 killer
= "visit to the hell";
417 pline("You are now high above the clouds ...");
419 pline("You float gently down to earth.");
422 pline("Unfortunately, you don't know how to fly.");
423 pline("You fall down a few thousand feet and break your neck.");
429 goto_level(newlevel
, FALSE
); /* calls done("escaped") if newlevel==0 */
434 pline("You fall into a pool!");
435 pline("You can't swim!");
436 if(rn2(3) < u
.uluck
+2) {
437 /* most scrolls become unreadable */
438 register struct obj
*obj
;
440 for(obj
= invent
; obj
; obj
= obj
->nobj
)
441 if(obj
->olet
== SCROLL_SYM
&& rn2(12) > u
.uluck
)
442 obj
->otyp
= SCR_BLANK_PAPER
;
443 /* we should perhaps merge these scrolls ? */
445 pline("You attempt a teleport spell."); /* utcsri!carroll */
447 if(levl
[u
.ux
][u
.uy
].typ
!= POOL
) return;
449 pline("You drown ...");
450 killer
= "pool of water";