1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.trap.c - version 1.0.3 */
7 extern struct monst *makemon();
9 char vowels[] = "aeiou";
16 " teleportation trap",
40 dotrap(trap) struct trap *trap; {
41 int ttype = trap->ttyp;
44 if(trap->tseen && !rn2(5) && ttype != PIT)
45 pline("You escape a%s.", traps[ttype]);
50 pline("A cloud of gas puts you to sleep!");
55 pline("You float over a bear trap.");
59 u.utraptype = TT_BEARTRAP;
60 pline("A bear trap closes on your foot!");
64 if(makemon(PM_PIERCER,u.ux,u.uy)) {
65 pline("A piercer suddenly drops from the ceiling!");
67 pline("Its blow glances off your helmet.");
69 (void) thitu(3,d(4,6),"falling piercer");
73 pline("An arrow shoots out at you!");
74 if(!thitu(8,rnd(6),"arrow")){
75 mksobj_at(ARROW, u.ux, u.uy);
81 pline("A trap door in the ceiling opens and a rock falls on your head!");
82 if(uarmh) pline("Fortunately, you are wearing a helmet!");
83 losehp(uarmh ? 2 : d(2,10),"falling rock");
84 mksobj_at(ROCK, u.ux, u.uy);
87 if(Invisible) newsym(u.ux, u.uy);
89 int newlevel = dlevel + 1;
90 while(!rn2(4) && newlevel < 29)
92 pline("A trap door opens up under you!");
93 if(Levitation || u.ustuck) {
94 pline("For some reason you don't fall in.");
98 goto_level(newlevel, FALSE);
102 pline("A little dart shoots out at you!");
103 if(thitu(7,rnd(3),"little dart")) {
105 poisoned("dart","poison dart");
107 mksobj_at(DART, u.ux, u.uy);
123 pline("A pit opens up under you!");
124 pline("You don't fall in!");
127 pline("You fall into a pit!");
129 u.utraptype = TT_PIT;
130 losehp(rnd(6),"fall into a pit");
131 selftouch("Falling, you");
134 impossible("You hit a trap of type %u", trap->ttyp);
139 mintrap(mtmp) struct monst *mtmp; {
140 struct trap *trap = t_at(mtmp->mx, mtmp->my);
141 int wasintrap = mtmp->mtrapped;
144 mtmp->mtrapped = 0; /* perhaps teleported? */
145 } else if(wasintrap) {
146 if(!rn2(40)) mtmp->mtrapped = 0;
149 int in_sight = cansee(mtmp->mx,mtmp->my);
150 extern char mlarge[];
152 if(mtmp->mtrapseen & (1 << tt)) {
153 /* he has been in such a trap - perhaps he escapes */
154 if(rn2(4)) return(0);
156 mtmp->mtrapseen |= (1 << tt);
159 if(index(mlarge, mtmp->data->mlet)) {
161 pline("%s is caught in a bear trap!",
164 if(mtmp->data->mlet == 'o')
165 pline("You hear the roaring of an angry bear!");
170 /* there should be a mtmp/data -> floating */
171 if(!index("EywBfk'& ", mtmp->data->mlet)) { /* ab */
174 pline("%s falls in a pit!", Monnam(mtmp));
178 if(!mtmp->msleep && !mtmp->mfroz) {
181 pline("%s suddenly falls asleep!",
187 if(in_sight && !cansee(mtmp->mx,mtmp->my))
188 pline("%s suddenly disappears!",
193 pline("%s is hit by an arrow!",
200 pline("%s is hit by a dart!",
204 /* not mondied here !! */
210 pline("A trap door in the ceiling opens and a rock hits %s!", monnam(mtmp));
213 if(mtmp->data->mlet != 'w'){
216 pline("Suddenly, %s disappears out of sight.", monnam(mtmp));
217 return(2); /* no longer on this level */
223 impossible("Some monster encountered a strange trap.");
226 return(mtmp->mtrapped);
229 selftouch(arg) char *arg; {
230 if(uwep && uwep->otyp == DEAD_COCKATRICE){
231 pline("%s touch the dead cockatrice.", arg);
232 pline("You turn to stone.");
233 killer = objects[uwep->otyp].oc_name;
240 if(u.utraptype == TT_PIT) {
242 pline("You float up, out of the pit!");
244 pline("You float up, only your leg is still stuck.");
247 pline("You start to float in the air!");
252 pline("You float gently to the ground.");
253 if(trap = t_at(u.ux,u.uy))
258 if(!xdnstair || u.ustuck) break;
259 /* fall into next case */
267 #include "def.mkroom.h"
268 struct mkroom *croom;
269 for(croom = &rooms[0]; croom->hx >= 0; croom++)
270 if(croom->rtype == VAULT) {
273 x = rn2(2) ? croom->lx : croom->hx;
274 y = rn2(2) ? croom->ly : croom->hy;
284 extern coord getpos();
288 if(Teleport_control) {
289 pline("To what position do you want to be teleported?");
290 cc = getpos(1, "the desired position"); /* 1: force valid */
291 /* possible extensions: introduce a small error if
292 magic power is low; allow transfer to solid rock */
293 if(teleok(cc.x, cc.y)){
302 } while(!teleok(nux, nuy));
309 if(Punished) unplacebc();
316 if(Punished) placebc(1);
318 u.uswldtim = u.uswallow = 0;
322 if(levl[nux][nuy].typ == POOL && !Levitation)
326 if(!Blind) read_engr_at(u.ux,u.uy);
329 teleok(x,y) int x,y; { /* might throw him into a POOL */
330 return( isok(x,y) && !IS_ROCK(levl[x][y].typ) && !m_at(x,y) &&
331 !sobj_at(ENORMOUS_ROCK,x,y) && !t_at(x,y)
333 /* Note: gold is permitted (because of vaults) */
337 extern char pl_character[];
343 (!Teleportation || u.ulevel < 6 ||
344 (pl_character[0] != 'W' && u.ulevel < 10))) {
345 pline("You are not able to teleport at will.");
348 if(u.uhunger <= 100 || u.ustr < 6) {
349 pline("You miss the strength for a teleport spell.");
357 placebc(attach) int attach; {
358 if(!uchain || !uball){
359 impossible("Where are your chain and ball??");
362 uball->ox = uchain->ox = u.ux;
363 uball->oy = uchain->oy = u.uy;
385 if(Teleport_control) {
389 pline("To what level do you want to teleport? [type a number] ");
391 } while(!digit(buf[0]) && (buf[0] != '-' || !digit(buf[1])));
392 newlevel = atoi(buf);
394 newlevel = 5 + rn2(20); /* 5 - 24 */
395 if(dlevel == newlevel) {
396 if(!xdnstair) newlevel--; else newlevel++;
400 if(newlevel > MAXLEVEL) newlevel = MAXLEVEL;
401 pline("You arrive at the center of the earth ...");
402 pline("Unfortunately it is here that hell is located.");
403 if(Fire_resistance) {
404 pline("But the fire doesn't seem to harm you.");
406 pline("You burn to a crisp.");
407 dlevel = maxdlevel = newlevel;
408 killer = "visit to the hell";
414 pline("You are now high above the clouds ...");
416 pline("You float gently down to earth.");
419 pline("Unfortunately, you don't know how to fly.");
420 pline("You fall down a few thousand feet and break your neck.");
426 goto_level(newlevel, FALSE); /* calls done("escaped") if newlevel==0 */
431 pline("You fall into a pool!");
432 pline("You can't swim!");
433 if(rn2(3) < u.uluck+2) {
434 /* most scrolls become unreadable */
437 for(obj = invent; obj; obj = obj->nobj)
438 if(obj->olet == SCROLL_SYM && rn2(12) > u.uluck)
439 obj->otyp = SCR_BLANK_PAPER;
440 /* we should perhaps merge these scrolls ? */
442 pline("You attempt a teleport spell."); /* utcsri!carroll */
444 if(levl[u.ux][u.uy].typ != POOL) return;
446 pline("You drown ...");
447 killer = "pool of water";