/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* hack.trap.c - version 1.0.3 */
extern struct monst
*makemon();
register struct trap
*ttmp
;
dotrap(trap
) register struct trap
*trap
; {
register int ttype
= trap
->ttyp
;
if(trap
->tseen
&& !rn2(5) && ttype
!= PIT
)
pline("You escape a%s.", traps
[ttype
]);
pline("A cloud of gas puts you to sleep!");
pline("You float over a bear trap.");
u
.utraptype
= TT_BEARTRAP
;
pline("A bear trap closes on your foot!");
if(makemon(PM_PIERCER
,u
.ux
,u
.uy
)) {
pline("A piercer suddenly drops from the ceiling!");
pline("Its blow glances off your helmet.");
(void) thitu(3,d(4,6),"falling piercer");
pline("An arrow shoots out at you!");
if(!thitu(8,rnd(6),"arrow")){
mksobj_at(ARROW
, u
.ux
, u
.uy
);
pline("A trap door in the ceiling opens and a rock falls on your head!");
if(uarmh
) pline("Fortunately, you are wearing a helmet!");
losehp(uarmh
? 2 : d(2,10),"falling rock");
mksobj_at(ROCK
, u
.ux
, u
.uy
);
if(Invisible
) newsym(u
.ux
, u
.uy
);
register int newlevel
= dlevel
+ 1;
while(!rn2(4) && newlevel
< 29)
pline("A trap door opens up under you!");
if(Levitation
|| u
.ustuck
) {
pline("For some reason you don't fall in.");
goto_level(newlevel
, FALSE
);
pline("A little dart shoots out at you!");
if(thitu(7,rnd(3),"little dart")) {
poisoned("dart","poison dart");
mksobj_at(DART
, u
.ux
, u
.uy
);
pline("A pit opens up under you!");
pline("You don't fall in!");
pline("You fall into a pit!");
losehp(rnd(6),"fall into a pit");
selftouch("Falling, you");
impossible("You hit a trap of type %u", trap
->ttyp
);
mintrap(mtmp
) register struct monst
*mtmp
; {
register struct trap
*trap
= t_at(mtmp
->mx
, mtmp
->my
);
register int wasintrap
= mtmp
->mtrapped
;
mtmp
->mtrapped
= 0; /* perhaps teleported? */
if(!rn2(40)) mtmp
->mtrapped
= 0;
register int tt
= trap
->ttyp
;
int in_sight
= cansee(mtmp
->mx
,mtmp
->my
);
if(mtmp
->mtrapseen
& (1 << tt
)) {
/* he has been in such a trap - perhaps he escapes */
mtmp
->mtrapseen
|= (1 << tt
);
if(index(mlarge
, mtmp
->data
->mlet
)) {
pline("%s is caught in a bear trap!",
if(mtmp
->data
->mlet
== 'o')
pline("You hear the roaring of an angry bear!");
/* there should be a mtmp/data -> floating */
if(!index("EywBfk'& ", mtmp
->data
->mlet
)) { /* ab */
pline("%s falls in a pit!", Monnam(mtmp
));
if(!mtmp
->msleep
&& !mtmp
->mfroz
) {
pline("%s suddenly falls asleep!",
if(in_sight
&& !cansee(mtmp
->mx
,mtmp
->my
))
pline("%s suddenly disappears!",
pline("%s is hit by an arrow!",
pline("%s is hit by a dart!",
/* not mondied here !! */
pline("A trap door in the ceiling opens and a rock hits %s!", monnam(mtmp
));
if(mtmp
->data
->mlet
!= 'w'){
pline("Suddenly, %s disappears out of sight.", monnam(mtmp
));
return(2); /* no longer on this level */
impossible("Some monster encountered a strange trap.");
selftouch(arg
) char *arg
; {
if(uwep
&& uwep
->otyp
== DEAD_COCKATRICE
){
pline("%s touch the dead cockatrice.", arg
);
pline("You turn to stone.");
killer
= objects
[uwep
->otyp
].oc_name
;
if(u
.utraptype
== TT_PIT
) {
pline("You float up, out of the pit!");
pline("You float up, only your leg is still stuck.");
pline("You start to float in the air!");
register struct trap
*trap
;
pline("You float gently to the ground.");
if(trap
= t_at(u
.ux
,u
.uy
))
if(!xdnstair
|| u
.ustuck
) break;
/* fall into next case */
register struct mkroom
*croom
;
for(croom
= &rooms
[0]; croom
->hx
>= 0; croom
++)
if(croom
->rtype
== VAULT
) {
x
= rn2(2) ? croom
->lx
: croom
->hx
;
y
= rn2(2) ? croom
->ly
: croom
->hy
;
pline("To what position do you want to be teleported?");
cc
= getpos(1, "the desired position"); /* 1: force valid */
/* possible extensions: introduce a small error if
magic power is low; allow transfer to solid rock */
} while(!teleok(nux
, nuy
));
if(Punished
) unplacebc();
u
.uswldtim
= u
.uswallow
= 0;
if(levl
[nux
][nuy
].typ
== POOL
&& !Levitation
)
if(!Blind
) read_engr_at(u
.ux
,u
.uy
);
teleok(x
,y
) register int x
,y
; { /* might throw him into a POOL */
return( isok(x
,y
) && !IS_ROCK(levl
[x
][y
].typ
) && !m_at(x
,y
) &&
!sobj_at(ENORMOUS_ROCK
,x
,y
) && !t_at(x
,y
)
/* Note: gold is permitted (because of vaults) */
extern char pl_character
[];
(!Teleportation
|| u
.ulevel
< 6 ||
(pl_character
[0] != 'W' && u
.ulevel
< 10))) {
pline("You are not able to teleport at will.");
if(u
.uhunger
<= 100 || u
.ustr
< 6) {
pline("You miss the strength for a teleport spell.");
placebc(attach
) int attach
; {
impossible("Where are your chain and ball??");
uball
->ox
= uchain
->ox
= u
.ux
;
uball
->oy
= uchain
->oy
= u
.uy
;
pline("To what level do you want to teleport? [type a number] ");
} while(!digit(buf
[0]) && (buf
[0] != '-' || !digit(buf
[1])));
newlevel
= 5 + rn2(20); /* 5 - 24 */
if(!xdnstair
) newlevel
--; else newlevel
++;
if(newlevel
> MAXLEVEL
) newlevel
= MAXLEVEL
;
pline("You arrive at the center of the earth ...");
pline("Unfortunately it is here that hell is located.");
pline("But the fire doesn't seem to harm you.");
pline("You burn to a crisp.");
dlevel
= maxdlevel
= newlevel
;
killer
= "visit to the hell";
pline("You are now high above the clouds ...");
pline("You float gently down to earth.");
pline("Unfortunately, you don't know how to fly.");
pline("You fall down a few thousand feet and break your neck.");
goto_level(newlevel
, FALSE
); /* calls done("escaped") if newlevel==0 */
pline("You fall into a pool!");
pline("You can't swim!");
/* most scrolls become unreadable */
register struct obj
*obj
;
for(obj
= invent
; obj
; obj
= obj
->nobj
)
if(obj
->olet
== SCROLL_SYM
&& rn2(12) > u
.uluck
)
obj
->otyp
= SCR_BLANK_PAPER
;
/* we should perhaps merge these scrolls ? */
pline("You attempt a teleport spell."); /* utcsri!carroll */
if(levl
[u
.ux
][u
.uy
].typ
!= POOL
) return;
killer
= "pool of water";