Source:NetHack 1.3d/trap.c

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

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

1.   /*	SCCS Id: @(#)trap.c	1.3	87/07/14 2.   /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3.    /* trap.c - version 1.0.3 */ 4.    5.    #include	  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->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. 	extern coord getpos; 508. 	coord cc; 509. 	register int nux,nuy; 510.  511.  	if(Teleport_control) { 512. #ifdef KAA 513. 	    if (multi < 0 && (!nomovemsg || 514. 			      !strncmp(nomovemsg,"You awake", 9) || 515. 			      !strncmp(nomovemsg,"You regain con", 15) || 516. 			      !strncmp(nomovemsg,"You are consci", 15))) 517.   518.  		pline("Being unconscious, you cannot control your teleport."); 519. 	    else { 520. #endif 521. 	  522.  		    pline("To what position do you want to be teleported?"); 523. 		    cc = getpos(1, "the desired position"); /* 1: force valid */ 524. 		    /* possible extensions: introduce a small error if  525. magic power is low; allow transfer to solid rock */ 526. 		    if(teleok(cc.x, cc.y)){ 527. 			teleds(cc.x, cc.y); 528. 			return; 529. 		    }  530.  		    pline("Sorry ..."); 531. #ifdef KAA 532. 		}  533.  #endif 534. 	}  535.  	do { 536. 		nux = rnd(COLNO-1); 537. 		nuy = rn2(ROWNO); 538. 	} while(!teleok(nux, nuy)); 539. 	teleds(nux, nuy); 540. }  541.   542.  teleds(nux, nuy) 543. register int nux,nuy; 544. {  545.  	if(Punished) unplacebc; 546. 	unsee; 547. 	u.utrap = 0; 548. 	u.ustuck = 0; 549. 	u.ux = nux; 550. 	u.uy = nuy; 551. 	setsee; 552. 	if(Punished) placebc(1); 553. 	if(u.uswallow){ 554. 		u.uswldtim = u.uswallow = 0; 555. 		docrt; 556. 	}  557.  	nomul(0); 558. 	if(IS_POOL(levl[nux][nuy].typ) && !Levitation) 559. 		drown; 560. 	(void) inshop; 561. 	pickup(1); 562. 	if(!Blind) read_engr_at(u.ux,u.uy); 563. }  564.   565.  teleok(x,y) register int x,y; {	/* might throw him into a POOL 566. 				 * removed by GAN 10/20/86 567. 				 */  568.  #ifdef STUPID 569. 	boolean	tmp1, tmp2, tmp3; 570. 	tmp1 = isok(x,y) && !IS_ROCK(levl[x][y].typ) && !m_at(x,y); 571. 	tmp2 = !sobj_at(ENORMOUS_ROCK,x,y) && !t_at(x,y); 572. 	tmp3 = !(IS_POOL(levl[x][y].typ) && !Levitation); 573. 	return(tmp1 && tmp2 && tmp3); 574. #else 575. 	return( isok(x,y) && !IS_ROCK(levl[x][y].typ) && !m_at(x,y) &&  576.  		!sobj_at(ENORMOUS_ROCK,x,y) && !t_at(x,y) &&  577.  		!(IS_POOL(levl[x][y].typ) && !Levitation)  578.  	); 579. #endif 580. 	/* Note: gold is permitted (because of vaults) */ 581. }  582.   583.  dotele { 584. 	extern char pl_character[]; 585.  586.  	if((!index("LNt",u.usym)) &&  587.  #ifdef WIZARD  588.  	   !wizard &&  589.  #endif  590.  		      (!Teleportation || u.ulevel < 6 || 591. 			(pl_character[0] != 'W' && u.ulevel < 10))) { 592. 		pline("You are not able to teleport at will."); 593. 		return(0); 594. 	}  595.  	if(u.uhunger <= 100 || u.ustr < 6) { 596. 		pline("You miss the strength for a teleport spell."); 597. #ifdef WIZARD 598. 		if(!wizard) 599. #endif 600. 		return(1); 601. 	}  602.  	tele; 603. 	morehungry(100); 604. 	return(1); 605. }  606.   607.  placebc(attach) int attach; { 608. 	if(!uchain || !uball){ 609. 		impossible("Where are your chain and ball??"); 610. 		return; 611. 	}  612.  	uball->ox = uchain->ox = u.ux; 613. 	uball->oy = uchain->oy = u.uy; 614. 	if(attach){ 615. 		uchain->nobj = fobj; 616. 		fobj = uchain; 617. 		if(!carried(uball)){ 618. 			uball->nobj = fobj; 619. 			fobj = uball; 620. 		}  621.  	}  622.  }  623.   624.  unplacebc{ 625. 	if(!carried(uball)){ 626. 		freeobj(uball); 627. 		unpobj(uball); 628. 	}  629.  	freeobj(uchain); 630. 	unpobj(uchain); 631. }  632.   633.  level_tele { 634. register int newlevel; 635. 	if(Teleport_control) { 636. 	    char buf[BUFSZ]; 637.  638.  	    do { 639. 	      pline("To what level do you want to teleport? [type a number] "); 640. 	      getlin(buf); 641. 	    } while(!digit(buf[0]) && (buf[0] != '-' || !digit(buf[1]))); 642. 	    newlevel = atoi(buf); 643. 	} else { 644. #ifdef DGKMOD 645. 	    newlevel  = rn2(5) ? 5 + rn2(20) : 30; 646. #else 647. 	    newlevel  = 5 + rn2(20);	/* 5 - 24 */ 648. #endif 649. 	    if(dlevel == newlevel) 650. 		if(!xdnstair) newlevel--; else newlevel++; 651. 	}  652.  	if(newlevel >= 30) { 653. 	    if(newlevel > MAXLEVEL) newlevel = MAXLEVEL; 654. 	    pline("You arrive at the center of the earth ..."); 655. 	    pline("Unfortunately it is here that hell is located."); 656. #ifdef DGK 657. 	    fflush(stdout); 658. #endif 659. 	    if(Fire_resistance) { 660. 		pline("But the fire doesn't seem to harm you."); 661. 	    } else { 662. 		pline("You burn to a crisp."); 663. 		pline("You die..."); 664. 		dlevel = maxdlevel = newlevel; 665. 		killer = "visit to hell"; 666. 		done("burned"); 667. 	    }  668.  	}  669.  	if(newlevel < 0) { 670. 		if(newlevel <= -10) { 671. 			pline("You arrive in heaven."); 672. 			pline("\"You are here a bit early, but we'll let you in.\""); 673. 			killer = "visit to heaven"; 674. 			done("died"); 675. 		}  676.  	    newlevel = 0; 677. 	    pline("You are now high above the clouds ..."); 678. 	    if(Levitation) { 679. 		pline("You float gently down to earth."); 680. 		done("escaped"); 681. 	    }  682.  	    pline("Unfortunately, you don't know how to fly."); 683. 	    pline("You fall down a few thousand feet and break your neck."); 684. 	    pline("You die..."); 685. 	    dlevel = 0; 686. 	    killer = "fall"; 687. 	    done("died"); 688. 	}  689.   690.  	goto_level(newlevel, FALSE); /* calls done("escaped") if newlevel==0 */ 691. }  692.   693.  #ifdef NEWTRAPS 694.  695.  domagictrap 696. {  697.  	register int fate = rnd(20); 698.  699.  	/* What happened to the poor sucker? */ 700.   701.  	if (fate < 10) { 702.  703.  	  /* Most of the time, it creates some monsters. */ 704.  	  register int cnt = rnd(4); 705.  706.  	  /* below checks for blindness added by GAN 10/30/86 */ 707. 	  if (!Blind)  { 708. 		pline("You are momentarily blinded by a flash of light!"); 709. 		Blind += rn1(5,10); 710. 		seeoff(0); 711. 	  }  else 712. 		pline("You hear a deafening roar!"); 713. 	  while(cnt--) 714. 	   (void) makemon((struct permonst *) 0, u.ux, u.uy); 715. 	}  716.  	else 717. 	  switch (fate) { 718.  719.  	     case 10: 720. 	     case 11: 721. 		      /* sometimes nothing happens */ 722. 			break; 723. 	     case 12: 724. 		      /* a flash of fire */ 725. 		      {  726.  			register int num; 727. 			  728.  			/* changed to be in conformance with 729. 			 * SCR_FIRE by GAN 11/02/86 730. 			 */  731.  			  732.  			pline("A tower of flame bursts from the floor!"); 733. 			if(Fire_resistance) 734. 				pline("You are uninjured."); 735. 			else { 736. 				num = rnd(6); 737. 				u.uhpmax -= num; 738. 				losehp(num,"a burst of flame"); 739. 				break; 740. 			}  741.  		      }  742.   743.  	     /* odd feelings */ 744. 	     case 13:   pline("A shiver runs up and down your spine!"); 745. 			break; 746. 	     case 14:   pline("You hear distant howling."); 747. 			break; 748. 	     case 15:   pline("You suddenly yearn for your distant homeland."); 749. 			break; 750. 	     case 16:   pline("Your pack shakes violently!"); 751. 			break; 752.  753.  	     /* very occasionally something nice happens. */ 754.   755.  	     case 19: 756. 		    /* tame nearby monsters */ 757. 		   {   register int i,j; 758. 		       register boolean confused = (Confusion != 0); 759. 		       register int bd = confused ? 5 : 1; 760.  		       register struct monst *mtmp; 761.  762.  		       /* below pline added by GAN 10/30/86 */ 763. 		       pline("You feel charismatic."); 764. 		       for(i = -bd; i <= bd; i++) for(j = -bd; j <= bd; j++) 765. 		       if(mtmp = m_at(u.ux+i, u.uy+j)) 766. 			       (void) tamedog(mtmp, (struct obj *) 0); 767. 		       break; 768. 		   }  769.   770.  	     case 20: 771. 		    /* uncurse stuff */ 772. 		   {  register struct obj *obj; 773. 		      register boolean confused = (Confusion != 0); 774.  775.  			/* below plines added by GAN 10/30/86 */ 776. 			if (confused) 777. 			    if (Hallucination) 778. 				pline("You feel the power of the Force against you!"); 779. 			    else 780. 				pline("You feel like you need some help."); 781. 			else 782. 			    if (Hallucination) 783. 				pline("You feel in touch with the Universal Oneness."); 784. 			    else 785. 				pline("You feel like someone is helping you."); 786. 		       for(obj = invent; obj ; obj = obj->nobj) 787. 			       if(obj->owornmask) 788. 				       obj->cursed = confused; 789. 		       if(Punished && !confused) { 790. 			       Punished = 0; 791. 			       freeobj(uchain); 792. 			       unpobj(uchain); 793. 			       free((char *) uchain); 794. 			       uball->spe = 0; 795. 			       uball->owornmask &= ~W_BALL; 796. 			       uchain = uball = (struct obj *) 0; 797. 		       }  798.  		       break; 799. 		   }  800.  	     default: break; 801. 	  }  802.  }  803.   804.  #endif /* NEWTRAPS /**/ 805.  806.   807.  drown 808. {  809.  	pline("You fall into a pool!"); 810. 	pline("You can't swim!"); 811. 	if(  812.  #ifdef WIZARD  813.  	wizard ||  814.  #endif  815.  	rn2(3) < u.uluck+2) { 816. 		/* most scrolls become unreadable */ 817. 		register struct obj *obj; 818.  819.  		for(obj = invent; obj; obj = obj->nobj) 820. 			if(obj->olet == SCROLL_SYM && rn2(12) > u.uluck) 821. 				obj->otyp = SCR_BLANK_PAPER; 822. 		/* we should perhaps merge these scrolls ? */ 823.   824.  		pline("You attempt a teleport spell.");	/* utcsri!carroll */ 825. 		(void) dotele; 826. 		if(!IS_POOL(levl[u.ux][u.uy].typ)) return; 827. 	}  828.  	pline("You drown."); 829. 	pline("You die..."); 830. 	killer = "pool of water"; 831. 	done("drowned"); 832. }