Source:NetHack 1.4f/trap.c

From NetHackWiki
Revision as of 01:44, 4 March 2008 by Kernigh bot (talk | contribs) (NetHack 1.4f/trap.c moved to Source:NetHack 1.4f/trap.c: Robot: moved page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Below is the full text to trap.c from the source code of NetHack 1.4f. To link to a particular line, write [[NetHack 1.4f/trap.c#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

Screenshots and source code from Hack are used under the CWI license.

1.    /*	SCCS Id: @(#)trap.c	1.4	87/08/08
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* trap.c - version 1.0.3 */
4.    
5.    #include	<stdio.h>
6.    #include	"hack.h"
7.    
8.    extern struct monst *makemon();
9.    #ifdef KAA
10.   extern char *Xmonnam();
11.   extern char *nomovemsg;
12.   #endif
13.   
14.   char vowels[] = "aeiou";
15.   
16.   char *traps[] = {
17.   	"",
18.   	" bear trap",
19.   	"n arrow trap",
20.   	" dart trap",
21.   	" trapdoor",
22.   	" teleportation trap",
23.   	" pit",
24.   	" sleeping gas trap",
25.   	" piercer",
26.   	" mimic"
27.   #ifdef NEWTRAPS
28.   	," magic trap"
29.   	," squeaky board"
30.   #endif
31.   #ifdef SPIDERS
32.   	," web"
33.   #endif
34.   #ifdef NEWCLASS
35.   	," spiked pit",
36.   	" level teleporter"
37.   #endif
38.   #ifdef SPELLS
39.   	," anti-magic field" 
40.   #endif
41.   #ifdef KAA
42.   	," rust trap"
43.   #endif
44.   };
45.   
46.   struct trap *
47.   maketrap(x,y,typ)
48.   register x,y,typ;
49.   {
50.   	register struct trap *ttmp;
51.   
52.   	ttmp = newtrap();
53.   	ttmp->ttyp = typ;
54.   	ttmp->tseen = 0;
55.   	ttmp->once = 0;
56.   	ttmp->tx = x;
57.   	ttmp->ty = y;
58.   	ttmp->ntrap = ftrap;
59.   	ftrap = ttmp;
60.   	return(ttmp);
61.   }
62.   
63.   dotrap(trap) register struct trap *trap; {
64.   	register int ttype = trap->ttyp;
65.   	register struct monst *mtmp;
66.   
67.   	nomul(0);
68.   	if(trap->tseen && !rn2(5) && !(ttype == PIT
69.   #ifdef NEWCLASS
70.   	   || ttype == SPIKED_PIT
71.   #endif
72.   #ifdef SPELLS
73.   	   || ttype == ANTI_MAGIC
74.   #endif
75.   		))
76.   		pline("You escape a%s.", traps[ttype]);
77.   	else {
78.   		trap->tseen = 1;
79.   		switch(ttype) {
80.   		case SLP_GAS_TRAP:
81.   			pline("A cloud of gas puts you to sleep!");
82.   			nomul(-rnd(25));
83.   			break;
84.   		case BEAR_TRAP:
85.   			if(Levitation) {
86.   				pline("You float over a bear trap.");
87.   				break;
88.   			}
89.   			u.utrap = 4 + rn2(4);
90.   			u.utraptype = TT_BEARTRAP;
91.   			pline("A bear trap closes on your foot!");
92.   			if(u.usym=='o') pline("You howl in anger!");
93.   			break;
94.   		case PIERC:
95.   			deltrap(trap);
96.   			if(mtmp=makemon(PM_PIERCER,u.ux,u.uy)) {
97.   			  pline("%s suddenly drops from the ceiling!", Xmonnam(mtmp));
98.   			  if(uarmh)
99.   				pline("Its blow glances off your helmet.");
100.  			  else
101.  				(void) thitu(3,d(4,6),"falling piercer");
102.  			}
103.  			break;
104.  		case ARROW_TRAP:
105.  			pline("An arrow shoots out at you!");
106.  			if(!thitu(8,rnd(6),"arrow")){
107.  				mksobj_at(ARROW, u.ux, u.uy);
108.  				fobj->quan = 1;
109.  			}
110.  			break;
111.  		case TRAPDOOR:
112.  			if(!xdnstair) {
113.  pline("A trap door in the ceiling opens and a rock falls on your head!");
114.  if(uarmh) pline("Fortunately, you are wearing a helmet!");
115.  			    losehp(uarmh ? 2 : d(2,10),"falling rock");
116.  			    mksobj_at(ROCK, u.ux, u.uy);
117.  			    fobj->quan = 1;
118.  			    stackobj(fobj);
119.  			    if(Invisible) newsym(u.ux, u.uy);
120.  			} else {
121.  			    register int newlevel = dlevel + 1;
122.  				while(!rn2(4) && newlevel < 29)
123.  					newlevel++;
124.  				pline("A trap door opens up under you!");
125.  				if(Levitation || u.ustuck) {
126.  				pline("For some reason you don't fall in.");
127.  					break;
128.  				}
129.  				fflush(stdout);
130.  				goto_level(newlevel, FALSE);
131.  			}
132.  			break;
133.  		case DART_TRAP:
134.  			pline("A little dart shoots out at you!");
135.  			if(thitu(7,rnd(3),"little dart")) {
136.  			    if(!rn2(6))
137.  				poisoned("dart","poison dart");
138.  			} else {
139.  				mksobj_at(DART, u.ux, u.uy);
140.  				fobj->quan = 1;
141.  			}
142.  			break;
143.  		case TELEP_TRAP:
144.  			if(trap->once) {
145.  				deltrap(trap);
146.  				newsym(u.ux,u.uy);
147.  				vtele();
148.  			} else {
149.  				newsym(u.ux,u.uy);
150.  				tele();
151.  			}
152.  			break;
153.  #ifdef KAA
154.  		case RUST_TRAP:
155.  			switch (rn2(5)) {
156.  			case 0:
157.  				pline("A gush of water hits you on the head!");
158.  				if (uarmh) {
159.  					if (uarmh->rustfree)
160.  						pline("Your helmet is not affected!");
161.  					else {
162.  						pline("Your helmet rusts!");
163.  						uarmh->spe--;
164.  					}
165.  				}
166.  				break;
167.  			case 1:
168.  				pline("A gush of water hits your left arm!");
169.  				if (uarms) {
170.  					pline("Your shield is not affected!");
171.  					break;
172.  				}
173.  				if (uwep && uwep->otyp == TWO_HANDED_SWORD) goto two_hand;
174.  				/* Two goto statements in a row--aaarrrgggh! */
175.  		glovecheck: if(uarmg) pline("Your gloves are not affected!");
176.  				break;
177.  			case 2:
178.  				pline("A gush of water hits your right arm!");
179.  		two_hand: corrode_weapon();
180.  				goto glovecheck;
181.  			default:
182.  				pline("A gush of water hits you!");
183.  				if (uarm)
184.  					if (uarm->rustfree ||
185.  						uarm->otyp >= STUDDED_LEATHER_ARMOR) 
186.  						pline("Your %s not affected!",
187.  						aobjnam(uarm,"are"));
188.  					else {
189.  						pline("Your %s!",aobjnam(uarm,"corrode"));
190.  						uarm->spe--;
191.  					}
192.  			}
193.  			break;
194.  #endif
195.  		case PIT:
196.  			if (Levitation || index("EyBfk'&",u.usym)) {
197.  				pline("A pit opens up under you!");
198.  				pline("You don't fall in!");
199.  				break;
200.  			}
201.  			pline("You fall into a pit!");
202.  			u.utrap = rn1(6,2);
203.  			u.utraptype = TT_PIT;
204.  			losehp(rnd(6),"fall into a pit");
205.  			selftouch("Falling, you");
206.  			break;
207.  #ifdef NEWCLASS
208.  		case SPIKED_PIT:
209.  			if (Levitation || index("EyBfk'&",u.usym)) {
210.  				pline("A pit opens up under you!");
211.  				pline("You don't fall in!");
212.  				pline("There are spikes in that pit!!!");
213.  				break;
214.  			}
215.  			pline("You fall into a pit!");
216.  			pline("You land on a set of sharp iron spikes!");
217.  			u.utrap = rn1(6,2);
218.  			u.utraptype = TT_PIT;
219.  			losehp(rnd(10),"fall onto iron spikes");
220.  			if(!rn2(6)) poisoned("spikes","poison spikes");
221.  			selftouch("Falling, you");
222.  			break;
223.  		case LEVEL_TELEP:
224.  			if (!Blind)	pline("You are momentarily blinded by a flash of light");
225.  			else		pline("You are momentarily disoriented.");
226.  			deltrap(trap);
227.  			newsym(u.ux,u.uy);
228.  			level_tele();
229.  			break;
230.  #endif
231.  #ifdef SPELLS
232.  		case ANTI_MAGIC:
233.  			pline("You feel your magical energy drain away!");
234.  			u.uen -= (rnd(u.ulevel) + 1);
235.  			if(u.uen < 0)  {
236.  				u.uenmax += u.uen;
237.  				if(u.uenmax < 0) u.uenmax = 0;
238.  				u.uen = 0;
239.  			}
240.  			flags.botl = 1;
241.  			break;
242.  #endif
243.  #ifdef NEWTRAPS
244.  		case MGTRP:
245.  			/* A magic trap. */
246.  			domagictrap();
247.  			break;
248.  		case SQBRD: {
249.  #include      "edog.h"
250.  			register struct monst *mtmp = fmon;
251.  			/* Stepped on a squeaky board. */
252.  			pline("A board underfoot gives off a loud squeak!");
253.  			/* Wake up nearby monsters. */
254.  		       while(mtmp) {
255.  			 if(dist(mtmp->mx,mtmp->my) < u.ulevel*20) {
256.  			       if(mtmp->msleep)
257.  				       mtmp->msleep = 0;
258.  			       if(mtmp->mtame)
259.  				       EDOG(mtmp)->whistletime = moves;
260.  			 }
261.  			 mtmp = mtmp->nmon;
262.  		       }
263.  		}
264.  			break;
265.  #endif
266.  #ifdef SPIDERS
267.  	       case WEB:
268.  
269.  		       /* Our luckless adventurer has stepped into a web. */
270.  
271.  		       pline("You've stumbled into a spider web!");
272.  		       u.utraptype = TT_WEB;
273.  
274.  		       /* Time stuck in the web depends on your strength. */
275.  
276.  		       if (u.ustr == 3) u.utrap = rn1(6,6);
277.  		       else if (u.ustr < 6) u.utrap = rn1(6,4);
278.  		       else if (u.ustr < 9) u.utrap = rn1(4,4);
279.  		       else if (u.ustr < 12) u.utrap = rn1(4,2);
280.  		       else if (u.ustr < 15) u.utrap = rn1(2,2);
281.  		       else if (u.ustr < 18) u.utrap = rnd(2);
282.  		       else if (u.ustr < 69) u.utrap = 1;
283.  		       else {
284.  			       u.utrap = 0;
285.  			       pline("You tear through the web!");
286.  			       deltrap(trap);
287.  			    }
288.  		       break;
289.  #endif
290.  		default:
291.  			impossible("You hit a trap of type %u", trap->ttyp);
292.  		}
293.  	}
294.  }
295.  
296.  mintrap(mtmp) register struct monst *mtmp; {
297.  	register struct trap *trap = t_at(mtmp->mx, mtmp->my);
298.  	register int wasintrap = mtmp->mtrapped;
299.  
300.  	if(!trap) {
301.  		mtmp->mtrapped = 0;	/* perhaps teleported? */
302.  	} else if(wasintrap) {
303.  		if(!rn2(40)) mtmp->mtrapped = 0;
304.  	} else {
305.  	    register int tt = trap->ttyp;
306.  #ifdef DGK
307.  	/* A bug fix for dumb messages by ab@unido.
308.  	 */
309.  	    int in_sight = cansee(mtmp->mx,mtmp->my)
310.  			   && (!mtmp->minvis || See_invisible);
311.  #else
312.  	    int in_sight = cansee(mtmp->mx,mtmp->my);
313.  #endif
314.  	    extern char mlarge[];
315.  
316.  	    if(mtmp->mtrapseen & (1 << tt)) {
317.  		/* he has been in such a trap - perhaps he escapes */
318.  		if(rn2(4)) return(0);
319.  	    }
320.  	    mtmp->mtrapseen |= (1 << tt);
321.  	    switch (tt) {
322.  		case BEAR_TRAP:
323.  			if(index(mlarge, mtmp->data->mlet)) {
324.  				if(in_sight)
325.  				  pline("%s is caught in a bear trap!",
326.  					Monnam(mtmp));
327.  				else
328.  				  if(mtmp->data->mlet == 'o')
329.  			    pline("You hear the roaring of an angry bear!");
330.  				mtmp->mtrapped = 1;
331.  			}
332.  			break;
333.  #ifdef KAA
334.  		case RUST_TRAP:
335.  			if(in_sight)
336.  				pline("A gush of water hits %s!",monnam(mtmp));
337.  			break;
338.  #endif
339.  		case PIT:
340.  #ifdef NEWCLASS
341.  		case SPIKED_PIT:
342.  #endif
343.  			/* there should be a mtmp/data -> floating */
344.  			if(!index("EywBIfk'& ", mtmp->data->mlet)) { /* ab */
345.  				mtmp->mtrapped = 1;
346.  				if(in_sight)
347.  				  pline("%s falls into a pit!", Monnam(mtmp));
348.  			}
349.  			break;
350.  		case SLP_GAS_TRAP:
351.  			if(!mtmp->msleep && !mtmp->mfroz) {
352.  				mtmp->msleep = 1;
353.  				if(in_sight)
354.  				  pline("%s suddenly falls asleep!",
355.  					Monnam(mtmp));
356.  			}
357.  			break;
358.  		case TELEP_TRAP:
359.  #ifdef NEWCLASS
360.  		case LEVEL_TELEP:
361.  #endif
362.  			rloc(mtmp);
363.  			if(in_sight && !cansee(mtmp->mx,mtmp->my))
364.  				pline("%s suddenly disappears!",
365.  					Monnam(mtmp));
366.  			break;
367.  		case ARROW_TRAP:
368.  			if(in_sight)
369.  				pline("%s is hit by an arrow!",	Monnam(mtmp));
370.  			mtmp->mhp -= 3;
371.  			break;
372.  		case DART_TRAP:
373.  			if(in_sight)
374.  				pline("%s is hit by a dart!", Monnam(mtmp));
375.  			mtmp->mhp -= 2;
376.  			/* not mondied here !! */
377.  			break;
378.  		case TRAPDOOR:
379.  			if(!xdnstair) {
380.  				mtmp->mhp -= 10;
381.  				if(in_sight)
382.  pline("A trap door in the ceiling opens and a rock hits %s!", monnam(mtmp));
383.  				break;
384.  			}
385.  			if(!index("EywBIfk", mtmp->data->mlet)){
386.  				fall_down(mtmp);
387.  				if(in_sight)
388.  		pline("Suddenly, %s disappears out of sight.", monnam(mtmp));
389.  				return(2);	/* no longer on this level */
390.  			}
391.  			break;
392.  		case PIERC:
393.  			break;
394.  #ifdef NEWTRAPS
395.  		case MGTRP:
396.  			/* A magic trap.  Monsters immune. */
397.  			break;
398.  		case SQBRD: {
399.  			register struct monst *ztmp = fmon;
400.  			
401.  			if(index("EyBIfk", mtmp->data->mlet)) break;
402.  			/* Stepped on a squeaky board. */
403.  			if (in_sight)
404.  			   pline("%s steps on a squeaky board.", Monnam(mtmp));
405.  			else
406.  			   pline("You hear a distant squeak.");
407.  			/* Wake up nearby monsters. */
408.  		       while(ztmp) {
409.  			 if(dist2(mtmp->mx,mtmp->my,ztmp->mx,ztmp->my) < 40)
410.  			       if(ztmp->msleep) ztmp->msleep = 0;
411.  			 ztmp = ztmp->nmon;
412.  		       }
413.  			break;
414.  		}
415.  #endif
416.  #ifdef SPIDERS
417.  	       case WEB:
418.  		       /* Monster in a web. */
419.  			/* in_sight check and confused bear by Eric Backus */
420.  		       if(mtmp->data->mlet != 's') {
421.  			 if(in_sight)
422.  				pline("%s is caught in a web!", Monnam(mtmp));
423.  			  else
424.  			    if(mtmp->data->mlet == 'o')
425.  			      pline("You hear the roaring of a confused bear!");
426.  			 mtmp->mtrapped = 1;
427.  		       }
428.  		      break;
429.  #endif
430.  #ifdef SPELLS
431.  		case ANTI_MAGIC:	break;
432.  #endif
433.  		default:
434.  			impossible("Some monster encountered a strange trap of type %d.",tt);
435.  	    }
436.  	}
437.  	return(mtmp->mtrapped);
438.  }
439.  
440.  selftouch(arg) char *arg; {
441.  	if(uwep && uwep->otyp == DEAD_COCKATRICE){
442.  		pline("%s touch the dead cockatrice.", arg);
443.  		pline("You turn to stone.");
444.  		pline("You die...");
445.  		killer = objects[uwep->otyp].oc_name;
446.  		done("died");
447.  	}
448.  }
449.  
450.  float_up(){
451.  	if(u.utrap) {
452.  		if(u.utraptype == TT_PIT) {
453.  			u.utrap = 0;
454.  			pline("You float up, out of the pit!");
455.  		} else {
456.  			pline("You float up, only your leg is still stuck.");
457.  		}
458.  	} else
459.  		if (Hallucination)
460.  			pline("Oh wow!  You're floating in the air!");
461.  		else
462.  			pline("You start to float in the air!");
463.  }
464.  
465.  float_down(){
466.  	register struct rm *tmpr;
467.  	register struct trap *trap;
468.  	
469.  	/* check for falling into pool - added by GAN 10/20/86 */
470.  	if(IS_POOL(levl[u.ux][u.uy].typ) && !Levitation)
471.  		drown();
472.  
473.  	pline("You float gently to the ground.");
474.  	if(trap = t_at(u.ux,u.uy))
475.  		switch(trap->ttyp) {
476.  		case PIERC:
477.  			break;
478.  		case TRAPDOOR:
479.  			if(!xdnstair || u.ustuck) break;
480.  			/* fall into next case */
481.  		default:
482.  			dotrap(trap);
483.  	}
484.  	pickup(1);
485.  }
486.  
487.  #include "mkroom.h"
488.  
489.  vtele() {
490.  	register struct mkroom *croom;
491.  
492.  	for(croom = &rooms[0]; croom->hx >= 0; croom++)
493.  	    if(croom->rtype == VAULT) {
494.  		register x,y;
495.  
496.  		x = rn2(2) ? croom->lx : croom->hx;
497.  		y = rn2(2) ? croom->ly : croom->hy;
498.  		if(teleok(x,y)) {
499.  		    teleds(x,y);
500.  		    return;
501.  		}
502.  	    }
503.  	tele();
504.  }
505.  
506.  tele() {
507.  	coord cc;
508.  	register int nux,nuy;
509.  
510.  	if(Teleport_control) {
511.  #ifdef KAA
512.  	    if (multi < 0 && (!nomovemsg ||
513.  			      !strncmp(nomovemsg,"You awake", 9) ||
514.  			      !strncmp(nomovemsg,"You regain con", 15) ||
515.  			      !strncmp(nomovemsg,"You are consci", 15)))
516.   
517.  		pline("Being unconscious, you cannot control your teleport.");
518.  	    else {
519.  #endif
520.  	
521.  		    pline("To what position do you want to be teleported?");
522.  		    getpos(&cc, 1, "the desired position"); /* 1: force valid */
523.  		    /* possible extensions: introduce a small error if
524.  		       magic power is low; allow transfer to solid rock */
525.  		    if(teleok(cc.x, cc.y)){
526.  			teleds(cc.x, cc.y);
527.  			return;
528.  		    }
529.  		    pline("Sorry ...");
530.  #ifdef KAA
531.  		}
532.  #endif
533.  	}
534.  	do {
535.  		nux = rnd(COLNO-1);
536.  		nuy = rn2(ROWNO);
537.  	} while(!teleok(nux, nuy));
538.  	teleds(nux, nuy);
539.  }
540.  
541.  teleds(nux, nuy)
542.  register int nux,nuy;
543.  {
544.  	if(Punished) unplacebc();
545.  	unsee();
546.  	u.utrap = 0;
547.  	u.ustuck = 0;
548.  	u.ux = nux;
549.  	u.uy = nuy;
550.  	setsee();
551.  	if(Punished) placebc(1);
552.  	if(u.uswallow){
553.  		u.uswldtim = u.uswallow = 0;
554.  		docrt();
555.  	}
556.  	nomul(0);
557.  	if(IS_POOL(levl[nux][nuy].typ) && !Levitation)
558.  		drown();
559.  	(void) inshop();
560.  	pickup(1);
561.  	read_engr_at(u.ux,u.uy);
562.  }
563.  
564.  teleok(x,y) register int x,y; {	/* might throw him into a POOL
565.  				 * removed by GAN 10/20/86
566.  				 */
567.  #ifdef STUPID
568.  	boolean	tmp1, tmp2, tmp3;
569.  	tmp1 = isok(x,y) && !IS_ROCK(levl[x][y].typ) && !m_at(x,y);
570.  	tmp2 = !sobj_at(ENORMOUS_ROCK,x,y) && !t_at(x,y);
571.  	tmp3 = !(IS_POOL(levl[x][y].typ) && !Levitation);
572.  	return(tmp1 && tmp2 && tmp3);
573.  #else
574.  	return( isok(x,y) && !IS_ROCK(levl[x][y].typ) && !m_at(x,y) &&
575.  		!sobj_at(ENORMOUS_ROCK,x,y) && !t_at(x,y) &&
576.  		!(IS_POOL(levl[x][y].typ) && !Levitation)
577.  	);
578.  #endif
579.  	/* Note: gold is permitted (because of vaults) */
580.  }
581.  
582.  dotele() {
583.  	extern char pl_character[];
584.  
585.  	if((!index("LNt",u.usym)) &&
586.  #ifdef WIZARD
587.  	   !wizard &&
588.  #endif
589.  		      (!Teleportation || u.ulevel < 6 ||
590.  			(pl_character[0] != 'W' && u.ulevel < 10))) {
591.  		pline("You are not able to teleport at will.");
592.  		return(0);
593.  	}
594.  	if(u.uhunger <= 100 || u.ustr < 6) {
595.  		pline("You miss the strength for a teleport spell.");
596.  #ifdef WIZARD
597.  		if(!wizard)
598.  #endif
599.  		return(1);
600.  	}
601.  	tele();
602.  	morehungry(100);
603.  	return(1);
604.  }
605.  
606.  placebc(attach) int attach; {
607.  	if(!uchain || !uball){
608.  		impossible("Where are your chain and ball??");
609.  		return;
610.  	}
611.  	uball->ox = uchain->ox = u.ux;
612.  	uball->oy = uchain->oy = u.uy;
613.  	if(attach){
614.  		uchain->nobj = fobj;
615.  		fobj = uchain;
616.  		if(!carried(uball)){
617.  			uball->nobj = fobj;
618.  			fobj = uball;
619.  		}
620.  	}
621.  }
622.  
623.  unplacebc(){
624.  	if(!carried(uball)){
625.  		freeobj(uball);
626.  		unpobj(uball);
627.  	}
628.  	freeobj(uchain);
629.  	unpobj(uchain);
630.  }
631.  
632.  level_tele() {
633.  register int newlevel;
634.  	if(Teleport_control) {
635.  	    char buf[BUFSZ];
636.  
637.  	    do {
638.  	      pline("To what level do you want to teleport? [type a number] ");
639.  	      getlin(buf);
640.  	    } while(!digit(buf[0]) && (buf[0] != '-' || !digit(buf[1])));
641.  	    newlevel = atoi(buf);
642.  	} else {
643.  #ifdef DGKMOD
644.  	    newlevel = rn2(5) ? rnz(dlevel + 3) : 30;
645.  #else
646.  	    newlevel = rnz(dlevel + 3);	/* 5 - 24 */
647.  #endif
648.  	    if(dlevel == newlevel)
649.  		if(!xdnstair) newlevel--; else newlevel++;
650.  	}
651.  	if(newlevel >= 30) {
652.  	    if(newlevel > MAXLEVEL) newlevel = MAXLEVEL;
653.  	    pline("You arrive at the center of the earth ...");
654.  	    pline("Unfortunately it is here that hell is located.");
655.  #ifdef DGK
656.  	    fflush(stdout);
657.  #endif
658.  	    if(Fire_resistance) {
659.  		pline("But the fire doesn't seem to harm you.");
660.  	    } else {
661.  		pline("You burn to a crisp.");
662.  		pline("You die...");
663.  		dlevel = maxdlevel = newlevel;
664.  		killer = "visit to hell";
665.  		done("burned");
666.  	    }
667.  	}
668.  	if(newlevel < 0) {
669.  		if(newlevel <= -10) {
670.  			pline("You arrive in heaven.");
671.  			pline("\"You are here a bit early, but we'll let you in.\"");
672.  			killer = "visit to heaven";
673.  			done("died");
674.  		}
675.  	    newlevel = 0;
676.  	    pline("You are now high above the clouds ...");
677.  	    if(Levitation) {
678.  		pline("You float gently down to earth.");
679.  		done("escaped");
680.  	    }
681.  	    pline("Unfortunately, you don't know how to fly.");
682.  	    pline("You fall down a few thousand feet and break your neck.");
683.  	    pline("You die...");
684.  	    dlevel = 0;
685.  	    killer = "fall";
686.  	    done("died");
687.  	}
688.  
689.  	goto_level(newlevel, FALSE); /* calls done("escaped") if newlevel==0 */
690.  }
691.  
692.  #ifdef NEWTRAPS
693.  
694.  domagictrap()
695.  {
696.  	register int fate = rnd(20);
697.  
698.  	/* What happened to the poor sucker? */
699.  
700.  	if (fate < 10) {
701.  
702.  	  /* Most of the time, it creates some monsters. */
703.  	  register int cnt = rnd(4);
704.  
705.  	  /* below checks for blindness added by GAN 10/30/86 */
706.  	  if (!Blind)  {
707.  		pline("You are momentarily blinded by a flash of light!");
708.  		Blind += rn1(5,10);
709.  		seeoff(0);
710.  	  }  else
711.  		pline("You hear a deafening roar!");
712.  	  while(cnt--)
713.  	   (void) makemon((struct permonst *) 0, u.ux, u.uy);
714.  	}
715.  	else
716.  	  switch (fate) {
717.  
718.  	     case 10:
719.  	     case 11:
720.  		      /* sometimes nothing happens */
721.  			break;
722.  	     case 12:
723.  		      /* a flash of fire */
724.  		      {
725.  			register int num;
726.  			
727.  			/* changed to be in conformance with
728.  			 * SCR_FIRE by GAN 11/02/86
729.  			 */
730.  			
731.  			pline("A tower of flame bursts from the floor!");
732.  			if(Fire_resistance)
733.  				pline("You are uninjured.");
734.  			else {
735.  				num = rnd(6);
736.  				u.uhpmax -= num;
737.  				losehp(num,"a burst of flame");
738.  				break;
739.  			}
740.  		      }
741.  
742.  	     /* odd feelings */
743.  	     case 13:   pline("A shiver runs up and down your spine!");
744.  			break;
745.  	     case 14:   pline("You hear distant howling.");
746.  			break;
747.  	     case 15:   pline("You suddenly yearn for your distant homeland.");
748.  			break;
749.  	     case 16:   pline("Your pack shakes violently!");
750.  			break;
751.  
752.  	     /* very occasionally something nice happens. */
753.  
754.  	     case 19:
755.  		    /* tame nearby monsters */
756.  		   {   register int i,j;
757.  		       register boolean confused = (Confusion != 0);
758.  		       register int bd = confused ? 5 : 1;
759.  		       register struct monst *mtmp;
760.  
761.  		       /* below pline added by GAN 10/30/86 */
762.  		       pline("You feel charismatic.");
763.  		       for(i = -bd; i <= bd; i++) for(j = -bd; j <= bd; j++)
764.  		       if(mtmp = m_at(u.ux+i, u.uy+j))
765.  			       (void) tamedog(mtmp, (struct obj *) 0);
766.  		       break;
767.  		   }
768.  
769.  	     case 20:
770.  		    /* uncurse stuff */
771.  		   {  register struct obj *obj;
772.  		      register boolean confused = (Confusion != 0);
773.  
774.  			/* below plines added by GAN 10/30/86 */
775.  			if (confused)
776.  			    if (Hallucination)
777.  				pline("You feel the power of the Force against you!");
778.  			    else
779.  				pline("You feel like you need some help.");
780.  			else
781.  			    if (Hallucination)
782.  				pline("You feel in touch with the Universal Oneness.");
783.  			    else
784.  				pline("You feel like someone is helping you.");
785.  		       for(obj = invent; obj ; obj = obj->nobj)
786.  			       if(obj->owornmask)
787.  				       obj->cursed = confused;
788.  		       if(Punished && !confused) {
789.  			       Punished = 0;
790.  			       freeobj(uchain);
791.  			       unpobj(uchain);
792.  			       free((char *) uchain);
793.  			       uball->spe = 0;
794.  			       uball->owornmask &= ~W_BALL;
795.  			       uchain = uball = (struct obj *) 0;
796.  		       }
797.  		       break;
798.  		   }
799.  	     default: break;
800.  	  }
801.  }
802.  
803.  #endif /* NEWTRAPS /**/
804.  
805.  
806.  drown()
807.  {
808.  	pline("You fall into a pool!");
809.  	pline("You can't swim!");
810.  	if(
811.  #ifdef WIZARD
812.  	wizard ||
813.  #endif
814.  	rn2(3) < u.uluck+2) {
815.  		/* most scrolls become unreadable */
816.  		register struct obj *obj;
817.  
818.  		for(obj = invent; obj; obj = obj->nobj)
819.  			if(obj->olet == SCROLL_SYM && rn2(12) > u.uluck)
820.  				obj->otyp = SCR_BLANK_PAPER;
821.  		/* we should perhaps merge these scrolls ? */
822.  
823.  		pline("You attempt a teleport spell.");	/* utcsri!carroll */
824.  		(void) dotele();
825.  		if(!IS_POOL(levl[u.ux][u.uy].typ)) return;
826.  	}
827.  	pline("You drown.");
828.  	pline("You die...");
829.  	killer = "pool of water";
830.  	done("drowned");
831.  }