Source:NetHack 3.3.0/apply.c

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

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

1.   /*	SCCS Id: @(#)apply.c	3.3	1999/10/10	*/ 2.   /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3.    /* NetHack may be freely redistributed. See license for details. */ 4.     5.    #include "hack.h"  6.    #include "edog.h"  7. 8.   #ifdef OVLB 9.    10.   static const char tools[] = { TOOL_CLASS, WEAPON_CLASS, WAND_CLASS, 0 }; 11.  static const char tools_too[] = { ALL_CLASSES, TOOL_CLASS, POTION_CLASS, 12.  					  WEAPON_CLASS, WAND_CLASS, 0 }; 13.   14.   #ifdef TOURIST 15.  STATIC_DCL int FDECL(use_camera, (struct obj *)); 16.  #endif 17.  STATIC_DCL int FDECL(use_towel, (struct obj *)); 18.  STATIC_DCL boolean FDECL(its_dead, (int,int,int *)); 19.  STATIC_DCL int FDECL(use_stethoscope, (struct obj *)); 20.  STATIC_DCL void FDECL(use_whistle, (struct obj *)); 21.  STATIC_DCL void FDECL(use_magic_whistle, (struct obj *)); 22.  STATIC_DCL void FDECL(use_leash, (struct obj *)); 23.  STATIC_DCL int FDECL(use_mirror, (struct obj *)); 24.  STATIC_DCL void FDECL(use_bell, (struct obj *)); 25.  STATIC_DCL void FDECL(use_candelabrum, (struct obj *)); 26.  STATIC_DCL void FDECL(use_candle, (struct obj *)); 27.  STATIC_DCL void FDECL(use_lamp, (struct obj *)); 28.  STATIC_DCL void FDECL(light_cocktail, (struct obj *)); 29.  STATIC_DCL void FDECL(use_tinning_kit, (struct obj *)); 30.  STATIC_DCL void FDECL(use_figurine, (struct obj *)); 31.  STATIC_DCL void FDECL(use_grease, (struct obj *)); 32.  STATIC_DCL void FDECL(use_trap, (struct obj *)); 33.  STATIC_PTR int NDECL(set_trap);		/* occupation callback */ 34.  STATIC_DCL int FDECL(use_whip, (struct obj *)); 35.  STATIC_DCL int FDECL(use_pole, (struct obj *)); 36.  STATIC_DCL int FDECL(use_grapple, (struct obj *)); 37.  STATIC_DCL int FDECL(do_break_wand, (struct obj *)); 38.  STATIC_DCL boolean FDECL(figurine_location_checks,  39.   				(struct obj *, coord *, BOOLEAN_P)); 40.   41.   #ifdef	AMIGA 42.  void FDECL( amii_speaker, ( struct obj *, char *, int ) ); 43.  #endif 44.   45.   static char no_elbow_room[] = "don't have enough elbow-room to maneuver."; 46.   47.   #ifdef TOURIST 48.  STATIC_OVL int 49.  use_camera(obj) 50.  	struct obj *obj; 51.  {  52.   	register struct monst *mtmp; 53.   54.   	if(Underwater) { 55.  		pline("Using your camera underwater would void the warranty."); 56.  		return(0); 57.  	}  58.   	if(!getdir((char *)0)) return(0); 59.   60.   	if (obj->spe <= 0) { 61.  		pline(nothing_happens); 62.  		return (1); 63.  	}  64.   	obj->spe--; 65.  	if (obj->cursed && !rn2(2)) { 66.  		(void) zapyourself(obj, TRUE); 67.  	} else if (u.uswallow) { 68.  		You("take a picture of %s %s.", s_suffix(mon_nam(u.ustuck)),  69.   		    is_animal(u.ustuck->data) ? "stomach" : "interior"); 70.  	} else if (u.dz) { 71.  		You("take a picture of the %s.",  72.   			(u.dz > 0) ? surface(u.ux,u.uy) : ceiling(u.ux,u.uy)); 73.  	} else if (!u.dx && !u.dy) { 74.  		(void) zapyourself(obj, TRUE); 75.  	} else if ((mtmp = bhit(u.dx, u.dy, COLNO, FLASHED_LIGHT,  76.   				(int FDECL((*),(MONST_P,OBJ_P)))0,  77.   				(int FDECL((*),(OBJ_P,OBJ_P)))0,  78.   				obj)) != 0) { 79.  		obj->ox = u.ux,  obj->oy = u.uy; 80.  		(void) flash_hits_mon(mtmp, obj); 81.  	}  82.   	return 1; 83.  }  84.   #endif 85.   86.   STATIC_OVL int 87.  use_towel(obj) 88.  	struct obj *obj; 89.  {  90.   	if(!freehand) { 91.  		You("have no free %s!", body_part(HAND)); 92.  		return 0; 93.  	} else if (obj->owornmask) { 94.  		You("cannot use it while you're wearing it!"); 95.  		return 0; 96.  	} else if (obj->cursed) { 97.  		long old; 98.  		switch (rn2(3)) { 99.  		case 2: 100. 		    old = Glib; 101. 		    Glib += rn1(10, 3); 102. 		    Your("%s %s!", makeplural(body_part(HAND)),  103.  			(old ? "are filthier than ever" : "get slimy")); 104. 		    return 1; 105. 		case 1: 106. 		    if (!ublindf) { 107. 			old = u.ucreamed; 108. 			u.ucreamed += rn1(10, 3); 109. 			pline("Yecch! Your %s %s gunk on it!", body_part(FACE),  110.  			      (old ? "has more" : "now has")); 111. 			make_blinded(Blinded + (long)u.ucreamed - old, TRUE); 112. 		    } else { 113. 			const char *what = (ublindf->otyp == LENSES) ? 114. 					    "lenses" : "blindfold"; 115. 			if (ublindf->cursed) { 116. 			    You("push your %s %s.", what,  117.  				rn2(2) ? "cock-eyed" : "crooked"); 118. 			} else { 119. 			    struct obj *saved_ublindf = ublindf; 120. 			    You("push your %s off.", what); 121. 			    Blindf_off(ublindf); 122. 			    dropx(saved_ublindf); 123. 			}  124.  		    }  125.  		    return 1; 126. 		case 0: 127. 		    break; 128. 		}  129.  	}  130.   131.  	if (Glib) { 132. 		Glib = 0; 133. 		You("wipe off your %s.", makeplural(body_part(HAND))); 134. 		return 1; 135. 	} else if(u.ucreamed) { 136. 		Blinded -= u.ucreamed; 137. 		u.ucreamed = 0; 138.  139.  		if (!Blinded) { 140. 			pline("You've got the glop off."); 141. 			Blinded = 1; 142. 			make_blinded(0L,TRUE); 143. 		} else { 144. 			Your("%s feels clean now.", body_part(FACE)); 145. 		}  146.  		return 1; 147. 	}  148.   149.  	Your("%s and %s are already clean.",  150.  		body_part(FACE), makeplural(body_part(HAND))); 151.  152.  	return 0; 153. }  154.   155.  /* maybe give a stethoscope message based on floor objects */ 156. STATIC_OVL boolean 157. its_dead(rx, ry, resp) 158. int rx, ry, *resp; 159. {  160.  	struct obj *otmp; 161. 	struct trap *ttmp; 162.  163.  	/* additional stethoscope messages from jyoung@apanix.apana.org.au */ 164. 	if (Hallucination && sobj_at(CORPSE, rx, ry)) { 165. 	    /* (a corpse doesn't retain the monster's sex,  166.  	       so we're forced to use generic pronoun here) */ 167. 	    You_hear("a voice say, \"It's dead, Jim.\""); 168. 	    *resp = 1; 169. 	    return TRUE; 170. 	} else if (Role_if(PM_HEALER) && ((otmp = sobj_at(CORPSE, rx, ry)) != 0 || 171. 				    (otmp = sobj_at(STATUE, rx, ry)) != 0)) { 172. 	    /* possibly should check uppermost {corpse,statue} in the pile 173. 	       if both types are present, but it's not worth the effort */ 174. 	    if (vobj_at(rx, ry)->otyp == STATUE) otmp = vobj_at(rx, ry); 175. 	    if (otmp->otyp == CORPSE) { 176. 		You("determine that %s unfortunate being is dead.",  177.  		    (rx == u.ux && ry == u.uy) ? "this" : "that"); 178. 	    } else { 179. 		ttmp = t_at(rx, ry); 180. 		pline("%s appears to be in %s health for a statue.",  181.  		      The(mons[otmp->corpsenm].mname),  182.  		      (ttmp && ttmp->ttyp == STATUE_TRAP) ?  183.  			"extraordinary" : "excellent"); 184. 	    }  185.  	    return TRUE; 186. 	}  187.  	return FALSE; 188. }  189.   190.  static char hollow_str[] = "a hollow sound.  This must be a secret %s!"; 191.  192.  /* Strictly speaking it makes no sense for usage of a stethoscope to  193. not take any time; however, unless it did, the stethoscope would be 194. almost useless. As a compromise, one use per turn is free, another 195.    uses up the turn; this makes curse status have a tangible effect. */ 196.  STATIC_OVL int 197. use_stethoscope(obj) 198. 	register struct obj *obj; 199. {  200.  	static long last_used = 0; 201. 	struct monst *mtmp; 202. 	struct rm *lev; 203. 	int rx, ry, res; 204.  205.  	if (nohands(youmonst.data)) {	/* should also check for no ears and/or deaf */ 206. 		You("have no hands!");	/* not `body_part(HAND)' */ 207. 		return 0; 208. 	} else if (!freehand) { 209. 		You("have no free %s.", body_part(HAND)); 210. 		return 0; 211. 	}  212.  	if (!getdir((char *)0)) return 0; 213.  214.  	res = (moves + monstermoves == last_used); 215. 	last_used = moves + monstermoves; 216.  217.  	if (u.uswallow && (u.dx || u.dy || u.dz)) { 218. 		mstatusline(u.ustuck); 219. 		return res; 220. #ifdef STEED 221. 	} else if (u.usteed && u.dz > 0) { 222. 		mstatusline(u.usteed); 223. 		return res; 224. #endif 225. 	} else if (u.dz) { 226. 		if (Underwater) 227. 		    You_hear("faint splashing."); 228. 		else if (u.dz < 0 || !can_reach_floor) 229. 		    You_cant("reach the %s.",  230.  			(u.dz > 0) ? surface(u.ux,u.uy) : ceiling(u.ux,u.uy)); 231. 		else if (its_dead(u.ux, u.uy, &res)) 232. 		    ;	/* message already given */ 233. 		else if (Is_stronghold(&u.uz)) 234. 		    You_hear("the crackling of hellfire."); 235. 		else 236. 		    pline_The("%s seems healthy enough.", surface(u.ux,u.uy)); 237. 		return res; 238. 	} else if (obj->cursed && !rn2(2)) { 239. 		You_hear("your heart beat."); 240. 		return res; 241. 	}  242.  	if (Stunned || (Confusion && !rn2(5))) confdir; 243. 	if (!u.dx && !u.dy) { 244. 		ustatusline; 245. 		return res; 246. 	}  247.  	rx = u.ux + u.dx; ry = u.uy + u.dy; 248. 	if (!isok(rx,ry)) { 249. 		You_hear("a faint typing noise."); 250. 		return 0; 251. 	}  252.  	if ((mtmp = m_at(rx,ry)) != 0) { 253. 		mstatusline(mtmp); 254. 		if (mtmp->mundetected) { 255. 			mtmp->mundetected = 0; 256. 			if (cansee(rx,ry)) newsym(mtmp->my,mtmp->my); 257. 		}  258.  		if (!canspotmon(mtmp)) 259. 			map_invisible(rx,ry); 260. 		return res; 261. 	}  262.  	if (glyph_is_invisible(levl[rx][ry].glyph)) { 263. 		unmap_object(rx, ry); 264. 		newsym(rx, ry); 265. 		pline_The("invisible monster must have moved."); 266. 	}  267.   268.  	lev = &levl[rx][ry]; 269. 	switch(lev->typ) { 270. 	case SDOOR: 271. 		You_hear(hollow_str, "door"); 272. 		cvt_sdoor_to_door(lev);		/* ->typ = DOOR */ 273. 		if (Blind) feel_location(rx,ry); 274. 		else newsym(rx,ry); 275. 		return res; 276. 	case SCORR: 277. 		You_hear(hollow_str, "passage"); 278. 		lev->typ = CORR; 279. 		if (Blind) feel_location(rx,ry); 280. 		else newsym(rx,ry); 281. 		return res; 282. 	}  283.   284.  	if (!its_dead(rx, ry, &res)) 285. 	    You("hear nothing special.");	/* not You_hear  */ 286. 	return res; 287. }  288.   289.  static char whistle_str[] = "produce a %s whistling sound."; 290.  291.  STATIC_OVL void 292. use_whistle(obj) 293. struct obj *obj; 294. {  295.  	You(whistle_str, obj->cursed ? "shrill" : "high"); 296. 	wake_nearby; 297. }  298.   299.  STATIC_OVL void 300. use_magic_whistle(obj) 301. struct obj *obj; 302. {  303.  	register struct monst *mtmp, *nextmon; 304.  305.  	if(obj->cursed && !rn2(2)) { 306. 		You("produce a high-pitched humming noise."); 307. 		wake_nearby; 308. 	} else { 309. 		int pet_cnt = 0; 310. 		You(whistle_str, Hallucination ? "normal" : "strange"); 311. 		for(mtmp = fmon; mtmp; mtmp = nextmon) { 312. 		    nextmon = mtmp->nmon; /* trap might kill mon */ 313. 		    if (mtmp->mtame) { 314. 			if (mtmp->mtrapped) { 315. 			    /* no longer in previous trap (affects mintrap) */ 316. 			    mtmp->mtrapped = 0; 317. 			    fill_pit(mtmp->mx, mtmp->my); 318. 			}  319.  			mnexto(mtmp); 320. 			if (canspotmon(mtmp)) ++pet_cnt; 321. 			if (mintrap(mtmp) == 2) change_luck(-1); 322. 		    }  323.  		}  324.  		if (pet_cnt > 0) makeknown(MAGIC_WHISTLE); 325. 	}  326.  }  327.   328.  boolean 329. um_dist(x,y,n) 330. register xchar x, y, n;  331. { 332.  	return((boolean)(abs(u.ux - x) > n  || abs(u.uy - y) > n)); 333. }  334.   335.  int 336. number_leashed 337. {  338.  	register int i = 0; 339. 	register struct obj *obj; 340.  341.  	for(obj = invent; obj; obj = obj->nobj) 342. 		if(obj->otyp == LEASH && obj->leashmon != 0) i++; 343. 	return(i); 344. }  345.   346.  void 347. o_unleash(otmp)		/* otmp is about to be destroyed or stolen */ 348. register struct obj *otmp; 349. {  350.  	register struct monst *mtmp; 351.  352.  	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) 353. 		if(mtmp->m_id == (unsigned)otmp->leashmon) 354. 			mtmp->mleashed = 0; 355. 	otmp->leashmon = 0; 356. }  357.   358.  void 359. m_unleash(mtmp)		/* mtmp is about to die, or become untame */ 360. register struct monst *mtmp; 361. {  362.  	register struct obj *otmp; 363.  364.  	for(otmp = invent; otmp; otmp = otmp->nobj) 365. 		if(otmp->otyp == LEASH &&  366.  				otmp->leashmon == (int)mtmp->m_id) 367. 			otmp->leashmon = 0; 368. 	mtmp->mleashed = 0; 369. }  370.   371.  void 372. unleash_all		/* player is about to die (for bones) */ 373. {  374.  	register struct obj *otmp; 375. 	register struct monst *mtmp; 376.  377.  	for(otmp = invent; otmp; otmp = otmp->nobj) 378. 		if(otmp->otyp == LEASH) otmp->leashmon = 0; 379. 	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) 380. 		if(mtmp->mtame) mtmp->mleashed = 0; 381. }  382.   383.  #define MAXLEASHED	2 384.  385.  /* ARGSUSED */ 386. STATIC_OVL void 387. use_leash(obj) 388. struct obj *obj; 389. {  390.  	register int x, y;  391. register struct monst *mtmp; 392. 	int spotmon; 393.  394.  	if(!obj->leashmon && number_leashed >= MAXLEASHED) { 395. 		You("cannot leash any more pets."); 396. 		return; 397. 	}  398.   399.  	if(!getdir((char *)0)) return; 400.  401.  	x = u.ux + u.dx; 402. 	y = u.uy + u.dy; 403.  404.  	if((x == u.ux) && (y == u.uy)) { 405. 		pline("Leash yourself?  Very funny..."); 406. 		return; 407. 	}  408.   409.  	if(!(mtmp = m_at(x, y))) { 410. 		pline("There is no creature there."); 411. 		return; 412. 	}  413.   414.  	spotmon = canspotmon(mtmp); 415.  416.  	if(!mtmp->mtame) { 417. 	    if(!spotmon) 418. 		pline("There is no creature there."); 419. 	    else 420. 		pline("%s %s leashed!", Monnam(mtmp), (!obj->leashmon) ?  421.  				"cannot be" : "is not"); 422. 	    return; 423. 	}  424.  	if(!obj->leashmon) { 425. 		if(mtmp->mleashed) { 426. 			pline("This %s is already leashed.",  427.  			      spotmon ? l_monnam(mtmp) : "monster"); 428. 			return; 429. 		}  430.  		You("slip the leash around %s%s.",  431.  		    spotmon ? "your " : "", l_monnam(mtmp)); 432. 		mtmp->mleashed = 1; 433. 		obj->leashmon = (int)mtmp->m_id; 434. 		mtmp->msleeping = 0; 435. 		return; 436. 	}  437.  	if(obj->leashmon != (int)mtmp->m_id) { 438. 		pline("This leash is not attached to that creature."); 439. 		return; 440. 	} else { 441. 		if(obj->cursed) { 442. 			pline_The("leash would not come off!"); 443. 			obj->bknown = TRUE; 444. 			return; 445. 		}  446.  		mtmp->mleashed = 0; 447. 		obj->leashmon = 0; 448. 		You("remove the leash from %s%s.",  449.  		    spotmon ? "your " : "", l_monnam(mtmp)); 450. 	}  451.  	return; 452. }  453.   454.  struct obj * 455. get_mleash(mtmp)	/* assuming mtmp->mleashed has been checked */ 456. register struct monst *mtmp; 457. {  458.  	register struct obj *otmp; 459.  460.  	otmp = invent; 461. 	while(otmp) { 462. 		if(otmp->otyp == LEASH && otmp->leashmon == (int)mtmp->m_id) 463. 			return(otmp); 464. 		otmp = otmp->nobj; 465. 	}  466.  	return((struct obj *)0); 467. }  468.   469.  #endif /* OVLB */ 470. #ifdef OVL1 471.  472.  boolean 473. next_to_u 474. {  475.  	register struct monst *mtmp; 476. 	register struct obj *otmp; 477.  478.  	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) 479. 		if(mtmp->mleashed) { 480. 			if (distu(mtmp->mx,mtmp->my) > 2) mnexto(mtmp); 481. 			if (distu(mtmp->mx,mtmp->my) > 2) { 482. 			    for(otmp = invent; otmp; otmp = otmp->nobj) 483. 				if(otmp->otyp == LEASH &&  484.  					otmp->leashmon == (int)mtmp->m_id) { 485. 				    if(otmp->cursed) return(FALSE); 486. 				    You_feel("%s leash go slack.",  487.  					(number_leashed > 1) ? "a" : "the"); 488. 				    mtmp->mleashed = 0; 489. 				    otmp->leashmon = 0; 490. 				}  491.  			}  492.  		}  493.  	return(TRUE); 494. }  495.   496.  #endif /* OVL1 */ 497. #ifdef OVL0 498.  499.  void 500. check_leash(x, y)  501. register xchar x, y; 502. { 503.  	register struct obj *otmp; 504. 	register struct monst *mtmp = fmon; 505.  506.  	for(otmp = invent; otmp; otmp = otmp->nobj) 507. 	    if(otmp->otyp == LEASH && otmp->leashmon != 0) { 508. 		while(mtmp) { 509. 		    if((int)mtmp->m_id == otmp->leashmon &&  510.  			    (dist2(u.ux,u.uy,mtmp->mx,mtmp->my) > 511. 				dist2(x,y,mtmp->mx,mtmp->my))  512.  			) { 513. 			if(otmp->cursed && !breathless(mtmp->data)) { 514. 			    if(um_dist(mtmp->mx, mtmp->my, 5)) { 515. 				pline("%s chokes to death!",Monnam(mtmp)); 516. 				mondied(mtmp); 517. 			    } else 518. 				if(um_dist(mtmp->mx, mtmp->my, 3)) 519. 					pline("%s chokes on the leash!",  520.  						Monnam(mtmp)); 521. 			} else { 522. 			    if(um_dist(mtmp->mx, mtmp->my, 5)) { 523. 				pline("%s leash snaps loose!",  524.  					s_suffix(Monnam(mtmp))); 525. 				m_unleash(mtmp); 526. 			    } else { 527. 				if(um_dist(mtmp->mx, mtmp->my, 3)) { 528. 				    You("pull on the leash."); 529. 				    if (mtmp->data->msound != MS_SILENT) 530. 					switch(rn2(3)) { 531. 					    case 0:  growl(mtmp);	break; 532. 					    case 1:  yelp(mtmp);	break; 533. 					    default: whimper(mtmp); break; 534. 					}  535.  				}  536.  			    }  537.  			}  538.  		    }  539.  		    mtmp = mtmp->nmon; 540. 		}  541.  	    }  542.  }  543.   544.  #endif /* OVL0 */ 545. #ifdef OVLB 546.  547.  boolean 548. wield_tool(obj) 549. struct obj *obj; 550. {  551.  	if(welded(uwep)) { 552. 		/* Andreas Bormann - ihnp4!decvax!mcvax!unido!ab */ 553. 		if(flags.verbose) { 554. 			pline("Since your weapon is welded to your %s,",  555.  				bimanual(uwep) ?  556.  				(const char *)makeplural(body_part(HAND))  557.  				: body_part(HAND)); 558. 			pline("you cannot wield that %s.", xname(obj)); 559. 		}  560.  		return(FALSE); 561. 	}  562.  	if (cantwield(youmonst.data)) { 563. 		You_cant("hold it strongly enough."); 564. 		return(FALSE); 565. 	}  566.  	/* Check shield */ 567. 	if (uarms && bimanual(obj)) { 568. 		You("cannot wield a two-handed tool while wearing a shield."); 569. 		return(FALSE); 570. 	}  571.  	if(uquiver == obj) setuqwep((struct obj *)0); 572. 	if(uswapwep == obj) { 573. 	    (void) doswapweapon; 574. 	    /* If doswapweapon failed... */ 575.  	    if(uswapwep == obj) return (FALSE); 576. 	} else { 577. 	    You("now wield %s.", doname(obj)); 578. 	    setuwep(obj); 579. 	}  580.  	if (uwep != obj) return(FALSE); /* rewielded old object after dying */ 581. 	if (!can_twoweapon) 582. 		untwoweapon; 583. 	if (obj->oclass != WEAPON_CLASS) 584. 		unweapon = TRUE; 585. 	return(TRUE); 586. }  587.   588.  #define WEAK	3	/* from eat.c */ 589.  590.  static char look_str[] = "look %s."; 591.  592.  STATIC_OVL int 593. use_mirror(obj) 594. struct obj *obj; 595. {  596.  	register struct monst *mtmp; 597. 	register char mlet; 598. 	boolean vis; 599.  600.  	if(!getdir((char *)0)) return 0; 601. 	if(obj->cursed && !rn2(2)) { 602. 		if (!Blind) 603. 			pline_The("mirror fogs up and doesn't reflect!"); 604. 		return 1; 605. 	}  606.  	if(!u.dx && !u.dy && !u.dz) { 607. 		if(!Blind && !Invisible) { 608. 		    if (u.umonnum == PM_FLOATING_EYE) { 609. 			if (!Free_action) { 610. 			pline(Hallucination ?  611.  			      "Yow!  The mirror stares back!" :  612.  			      "Yikes!  You've frozen yourself!"); 613. 			nomul(-rnd((MAXULEV+6) - u.ulevel)); 614. 			} else pline("You stiffen momentarily under your gaze."); 615. 		    } else if (youmonst.data->mlet == S_VAMPIRE) 616. 			You("don't have a reflection."); 617. 		    else if (u.umonnum == PM_UMBER_HULK) { 618. 			pline("Huh?  That doesn't look like you!"); 619. 			make_confused(HConfusion + d(3,4),FALSE); 620. 		    } else if (Hallucination) 621. 			You(look_str, hcolor((char *)0)); 622. 		    else if (Sick) 623. 			You(look_str, "peaked"); 624. 		    else if (u.uhs >= WEAK) 625. 			You(look_str, "undernourished"); 626. 		    else You("look as %s as ever.",  627.  				ACURR(A_CHA) > 14 ?  628.  				(poly_gender==1 ? "beautiful" : "handsome") : 629.  				"ugly"); 630. 		} else { 631. 			You_cant("see your %s %s.",  632.  				ACURR(A_CHA) > 14 ?  633.  				(poly_gender==1 ? "beautiful" : "handsome") : 634.  				"ugly",  635.  				body_part(FACE)); 636. 		}  637.  		return 1; 638. 	}  639.  	if(u.uswallow) { 640. 		if (!Blind) You("reflect %s %s.", s_suffix(mon_nam(u.ustuck)),  641.  		    is_animal(u.ustuck->data)? "stomach" : "interior"); 642. 		return 1; 643. 	}  644.  	if(Underwater) { 645. 		You(Hallucination ?  646.  		    "give the fish a chance to fix their makeup." :  647.  		    "reflect the murky water."); 648. 		return 1; 649. 	}  650.  	if(u.dz) { 651. 		if (!Blind) 652. 		    You("reflect the %s.",  653.  			(u.dz > 0) ? surface(u.ux,u.uy) : ceiling(u.ux,u.uy)); 654. 		return 1; 655. 	}  656.  	mtmp = bhit(u.dx, u.dy, COLNO, INVIS_BEAM,  657.  		    (int FDECL((*),(MONST_P,OBJ_P)))0,  658.  		    (int FDECL((*),(OBJ_P,OBJ_P)))0,  659.  		    obj); 660. 	if (!mtmp || !haseyes(mtmp->data)) 661. 		return 1; 662.  663.  	vis = canseemon(mtmp); 664. 	mlet = mtmp->data->mlet; 665. 	if (mtmp->msleeping) { 666. 		if (vis) 667. 		    pline ("%s is too tired to look at your mirror.",  668.  			    Monnam(mtmp)); 669. 	} else if (!mtmp->mcansee) { 670. 	    if (vis) 671. 		pline("%s can't see anything right now.", Monnam(mtmp)); 672. 	/* some monsters do special things */ 673. 	} else if (mlet == S_VAMPIRE || mlet == S_GHOST) { 674. 	    if (vis) 675. 		pline ("%s doesn't have a reflection.", Monnam(mtmp)); 676. 	} else if(!mtmp->mcan && mtmp->data == &mons[PM_MEDUSA]) { 677. 		if (mon_reflects(mtmp, "The gaze is reflected away by %s %s!")) 678. 			return 1; 679. 		if (vis) 680. 			pline("%s is turned to stone!", Monnam(mtmp)); 681. 		stoned = TRUE; 682. 		killed(mtmp); 683. 	} else if(!mtmp->mcan && !mtmp->minvis &&  684.  					mtmp->data == &mons[PM_FLOATING_EYE]) { 685. 		int tmp = d((int)mtmp->m_lev, (int)mtmp->data->mattk[0].damd); 686. 		if (!rn2(4)) tmp = 120; 687. 	/* Note: floating eyes cannot use their abilities while invisible, 688. 	 * but Medusa and umber hulks can. 689. 	 */  690.  		if (vis) 691. 			pline("%s is frozen by its reflection.", Monnam(mtmp)); 692. 		else You_hear("%s stop moving.",something); 693. 		mtmp->mcanmove = 0; 694. 		if ( (int) mtmp->mfrozen + tmp > 127) 695. 			mtmp->mfrozen = 127; 696. 		else mtmp->mfrozen += tmp; 697. 	} else if(!mtmp->mcan && mtmp->data == &mons[PM_UMBER_HULK]) { 698. 		if (vis) 699. 			pline ("%s confuses itself!", Monnam(mtmp)); 700. 		mtmp->mconf = 1; 701. 	} else if(!mtmp->mcan && !mtmp->minvis && (mlet == S_NYMPH 702. 				     || mtmp->data==&mons[PM_SUCCUBUS])) { 703. 		if (vis) { 704. 		    pline ("%s admires herself in your mirror.", Monnam(mtmp)); 705. 		    pline ("She takes it!"); 706. 		} else pline ("It steals your mirror!"); 707. 		setnotworn(obj); /* in case mirror was wielded */ 708. 		freeinv(obj); 709. 		mpickobj(mtmp,obj); 710. 		rloc(mtmp); 711. 	} else if (!is_unicorn(mtmp->data) && !humanoid(mtmp->data) &&  712.  			(!mtmp->minvis || perceives(mtmp->data)) && rn2(5)) { 713. 		if (vis) 714. 			pline ("%s is frightened by its reflection.",  715.  				Monnam(mtmp)); 716. 		mtmp->mflee = 1; 717. 		mtmp->mfleetim += d(2,4); 718. 	} else if (!Blind) { 719. 		if (mtmp->minvis && !See_invisible) 720. 		    ;  721.  		else if ((mtmp->minvis && !perceives(mtmp->data))  722.  			 || !haseyes(mtmp->data)) 723. 		    pline("%s doesn't seem to notice its reflection.",  724.  			Monnam(mtmp)); 725. 		else 726. 		    pline("%s ignores %s reflection.",  727.  			  Monnam(mtmp), his[pronoun_gender(mtmp)]); 728. 	}  729.  	return 1; 730. }  731.   732.  STATIC_OVL void 733. use_bell(obj) 734. register struct obj *obj; 735. {  736.  	struct monst *mtmp; 737. 	boolean wakem = FALSE, learno = FALSE, 738. 		ordinary = (obj->otyp != BELL_OF_OPENING || !obj->spe), 739. 		invoking = (obj->otyp == BELL_OF_OPENING &&  740.  			 invocation_pos(u.ux, u.uy) && !On_stairs(u.ux, u.uy)); 741.  742.  	You("ring %s.", the(xname(obj))); 743.  744.  	if (Underwater || (u.uswallow && ordinary)) { 745. #ifdef	AMIGA 746. 	    amii_speaker( obj, "AhDhGqEqDhEhAqDqFhGw", AMII_MUFFLED_VOLUME ); 747. #endif 748. 	    pline("But the sound is muffled."); 749.  750.  	} else if (invoking && ordinary) { 751. 	    /* needs to be recharged... */ 752.  	    pline("But it makes no sound."); 753. 	    learno = TRUE;	/* help player figure out why */ 754.  755.  	} else if (ordinary) { 756. #ifdef	AMIGA 757. 	    amii_speaker( obj, "ahdhgqeqdhehaqdqfhgw", AMII_MUFFLED_VOLUME ); 758. #endif 759. 	    if (obj->cursed && !rn2(4) &&  760.  		    /* note: once any of them are gone, we stop all of them */  761.  		    !(mvitals[PM_WOOD_NYMPH].mvflags & G_GONE) &&  762.  		    !(mvitals[PM_WATER_NYMPH].mvflags & G_GONE) &&  763.  		    !(mvitals[PM_MOUNTAIN_NYMPH].mvflags & G_GONE) &&  764.  		    (mtmp = makemon(mkclass(S_NYMPH, 0),  765.  					u.ux, u.uy, NO_MINVENT)) != 0) { 766. 		You("summon %s!", a_monnam(mtmp)); 767. 		if (!obj_resists(obj, 93, 100)) { 768. 		    pline("%s has shattered!", The(xname(obj))); 769. 		    useup(obj); 770. 		} else switch (rn2(3)) { 771. 			default: 772. 				break; 773. 			case 1: mon_adjust_speed(mtmp, 2); 774. 				break; 775. 			case 2: /* no explanation; it just happens... */ 776.  				nomovemsg = ""; 777. 				nomul(-rnd(2)); 778. 				break; 779. 		}  780.  	    }  781.  	    wakem = TRUE; 782.  783.  	} else { 784. 	    /* charged Bell of Opening */ 785. 	    check_unpaid(obj); 786. 	    obj->spe--; 787.  788.  	    if (u.uswallow) { 789. 		if (!obj->cursed) 790. 		    (void) openit; 791. 		else 792. 		    pline(nothing_happens); 793.  794.  	    } else if (obj->cursed) { 795. 		coord mm; 796.  797.  		mm.x = u.ux; 798. 		mm.y = u.uy; 799. 		mkundead(&mm, FALSE, NO_MINVENT); 800. 		wakem = TRUE; 801.  802.  	    } else  if (invoking) { 803. 		pline("%s issues an unsettling shrill sound...",  804.  		      The(xname(obj))); 805. #ifdef	AMIGA 806. 		amii_speaker( obj, "aefeaefeaefeaefeaefe", AMII_LOUDER_VOLUME ); 807. #endif 808. 		obj->age = moves; 809. 		learno = TRUE; 810. 		wakem = TRUE; 811.  812.  	    } else if (obj->blessed) { 813. #ifdef	AMIGA 814. 		amii_speaker( obj, "ahahahDhEhCw", AMII_SOFT_VOLUME ); 815. #endif 816. 		switch (openit) { 817. 		  case 0:  pline(nothing_happens); break; 818. 		  case 1:  pline("%s opens...", Something); 819. 			   learno = TRUE; break; 820. 		  default: pline("Things open around you..."); 821. 			   learno = TRUE; break; 822. 		}  823.   824.  	    } else {  /* uncursed */ 825. #ifdef	AMIGA 826. 		amii_speaker( obj, "AeFeaeFeAefegw", AMII_OKAY_VOLUME ); 827. #endif 828. 		if (findit != 0) learno = TRUE; 829. 		else pline(nothing_happens); 830. 	    }  831.   832.  	}	/* charged BofO */ 833.  834.  	if (learno) { 835. 	    makeknown(BELL_OF_OPENING); 836. 	    obj->known = 1; 837. 	}  838.  	if (wakem) wake_nearby; 839. }  840.   841.  STATIC_OVL void 842. use_candelabrum(obj) 843. register struct obj *obj; 844. {  845.  	if(Underwater) { 846. 		You("cannot make fire under water."); 847. 		return; 848. 	}  849.  	if(obj->lamplit) { 850. 		You("snuff the candle%s.", obj->spe > 1 ? "s" : ""); 851. 		end_burn(obj, TRUE); 852. 		return; 853. 	}  854.  	if(obj->spe <= 0) { 855. 		pline("This %s has no candles.", xname(obj)); 856. 		return; 857. 	}  858.  	if(u.uswallow || obj->cursed) { 859. 		pline_The("candle%s flicker%s for a moment, then die%s.",  860.  			obj->spe > 1 ? "s" : "",  861.  			obj->spe > 1 ? "" : "s",  862.  			obj->spe > 1 ? "" : "s"); 863. 		return; 864. 	}  865.  	if(obj->spe < 7) { 866. 		pline("There %s only %d candle%s in %s.",  867.  		       obj->spe == 1 ? "is" : "are",  868.  		       obj->spe,  869.  		       obj->spe > 1 ? "s" : "",  870.  		       the(xname(obj))); 871. 		if (!Blind) 872. 		    pline("%s lit.  %s shines dimly.",  873.  		       obj->spe == 1 ? "It is" : "They are", The(xname(obj))); 874. 	} else { 875. 		pline("%s's candles burn%s", The(xname(obj)),  876.  			(Blind ? "." : " brightly!")); 877. 	}  878.  	if (!invocation_pos(u.ux, u.uy)) { 879. 		pline_The("candle%s being rapidly consumed!",  880.  			(obj->spe > 1 ? "s are" : " is")); 881. 		obj->age /= 2; 882. 	} else { 883. 		if(obj->spe == 7) { 884. 		    if (Blind) 885. 		      pline("%s radiates a strange warmth!", The(xname(obj))); 886. 		    else 887. 		      pline("%s glows with a strange light!", The(xname(obj))); 888. 		}  889.  		obj->known = 1; 890. 	}  891.  	begin_burn(obj, FALSE); 892. }  893.   894.  STATIC_OVL void 895. use_candle(obj) 896. register struct obj *obj; 897. {  898.  	register struct obj *otmp; 899. 	char qbuf[QBUFSZ]; 900.  901.  	if(u.uswallow) { 902. 		You(no_elbow_room); 903. 		return; 904. 	}  905.  	if(Underwater) { 906. 		pline("Sorry, fire and water don't mix."); 907. 		return; 908. 	}  909.   910.  	otmp = carrying(CANDELABRUM_OF_INVOCATION); 911. 	if(!otmp || otmp->spe == 7) { 912. 		use_lamp(obj); 913. 		return; 914. 	}  915.   916.  	Sprintf(qbuf, "Attach %s", the(xname(obj))); 917. 	Sprintf(eos(qbuf), " to %s?", the(xname(otmp))); 918. 	if(yn(qbuf) == 'n') { 919. 		if (!obj->lamplit) 920. 		    You("try to light %s...", the(xname(obj))); 921. 		use_lamp(obj); 922. 		return; 923. 	} else { 924. 		if ((long)otmp->spe + obj->quan > 7L) 925. 		    (void)splitobj(obj, 7L - (long)otmp->spe); 926. 		You("attach %ld%s candle%s to %s.",  927.  		    obj->quan, !otmp->spe ? "" : " more",  928.  		    plur(obj->quan), the(xname(otmp))); 929. 		if (!otmp->spe || otmp->age > obj->age) 930. 		    otmp->age = obj->age; 931. 		otmp->spe += (int)obj->quan; 932. 		if (otmp->lamplit && !obj->lamplit) 933. 		    pline_The("new candle%s magically ignite%s!",  934.  			      plur(obj->quan),  935.  			      (obj->quan > 1L) ? "" : "s"); 936. 		else if (!otmp->lamplit && obj->lamplit) 937. 		    pline("%s out.", (obj->quan > 1L) ? "They go" : "It goes"); 938. 		if (obj->unpaid) 939. 		    verbalize("You %s %s, you bought %s!",  940.  			      otmp->lamplit ? "burn" : "use",  941.  			      (obj->quan > 1L) ? "them" : "it",  942.  			      (obj->quan > 1L) ? "them" : "it"); 943. 		if (obj->quan < 7L && otmp->spe == 7) 944. 		    pline("%s now has seven%s candles attached.",  945.  			  The(xname(otmp)), otmp->lamplit ? " lit" : ""); 946. 		/* candelabrum's light range might increase */ 947. 		if (otmp->lamplit) obj_merge_light_sources(otmp, otmp); 948. 		/* candles are no longer a separate light source */ 949. 		if (obj->lamplit) end_burn(obj, TRUE); 950. 		/* candles are now gone */ 951. 		useupall(obj); 952. 	}  953.  }  954.   955.  boolean 956. snuff_candle(otmp)  /* call in drop, throw, and put in box, etc. */ 957. register struct obj *otmp; 958. {  959.  	register boolean candle = Is_candle(otmp); 960.  961.  	if ((candle || otmp->otyp == CANDELABRUM_OF_INVOCATION) &&  962.  		otmp->lamplit) { 963. 	    char buf[BUFSZ]; 964. 	    xchar x, y;  965. register boolean many = candle ? otmp->quan > 1L : otmp->spe > 1; 966.  967.  	    (void) get_obj_location(otmp, &x, &y, 0); 968. 	    if (otmp->where == OBJ_MINVENT ? cansee(x,y) : !Blind) 969. 		pline("%s %scandle%s flame%s extinguished.",  970.  		      Shk_Your(buf, otmp),  971.  		      (candle ? "" : "candelabrum's "), 972.  		      (many ? "s'" : "'s"), (many ? "s are" : " is")); 973. 	   end_burn(otmp, TRUE); 974. 	   return(TRUE); 975. 	}  976.  	return(FALSE); 977. }  978.   979.  /* called when lit lamp is hit by water or put into a container or  980. you've been swallowed by a monster; obj might be in transit while 981.    being thrown or dropped so don't assume that its location is valid */ 982. boolean 983. snuff_lit(obj) 984. struct obj *obj; 985. {  986.  	xchar x, y;  987. 988. 	if (obj->lamplit) { 989. 	    if (obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP ||  990.  		    obj->otyp == BRASS_LANTERN || obj->otyp == POT_OIL) { 991. 		(void) get_obj_location(obj, &x, &y, 0); 992. 		if (obj->where == OBJ_MINVENT ? cansee(x,y) : !Blind) 993. 		    pline("%s goes out!", Yname2(obj)); 994. 		end_burn(obj, TRUE); 995. 		return TRUE; 996. 	    }  997.  	    if (snuff_candle(obj)) return TRUE; 998. 	}  999.  	return FALSE; 1000. } 1001.  1002. STATIC_OVL void 1003. use_lamp(obj) 1004. struct obj *obj; 1005. { 1006. 	char buf[BUFSZ]; 1007. 1008. 	if(Underwater) { 1009. 		pline("This is not a diving lamp."); 1010. 		return; 1011. 	} 1012. 	if(obj->lamplit) { 1013. 		if(obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP || 1014. 				obj->otyp == BRASS_LANTERN) 1015. 		   pline("%s lamp is now off.", Shk_Your(buf, obj)); 1016. 		else 1017. 		   You("snuff out %s.", yname(obj)); 1018. 		end_burn(obj, TRUE); 1019. 		return; 1020. 	} 1021. 	/* magic lamps with an spe == 0 (wished for) cannot be lit */ 1022. 	if ((!Is_candle(obj) && obj->age == 0) 1023. 			|| (obj->otyp == MAGIC_LAMP && obj->spe == 0)) { 1024. 		if (obj->otyp == BRASS_LANTERN) 1025. 			Your("lamp has run out of power."); 1026. 		else pline("This %s has no oil.", xname(obj)); 1027. 		return; 1028. 	} 1029. 	if (obj->cursed && !rn2(2)) { 1030. 		pline("%s flicker%s for a moment, then die%s.", 1031. 		       The(xname(obj)),  1032. 		       obj->quan > 1L ? "" : "s",  1033. 		       obj->quan > 1L ? "" : "s"); 1034. 	} else { 1035. 		if(obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP || 1036. 				obj->otyp == BRASS_LANTERN) { 1037. 		   check_unpaid(obj); 1038. 		   pline("%s lamp is now on.", Shk_Your(buf, obj)); 1039. 		} else {	/* candle(s) */ 1040. 		   pline("%s flame%s burn%s%s",  1041. 			s_suffix(Yname2(obj)),  1042. 			plur(obj->quan),  1043. 			obj->quan > 1L ? "" : "s",  1044. 			Blind ? "." : " brightly!"); 1045. 		   if (obj->unpaid &&  1046. 			  obj->age == 20L * (long)objects[obj->otyp].oc_cost) { 1047. 			const char *ithem = obj->quan > 1L ? "them" : "it"; 1048. 			verbalize("You burn %s, you bought %s!", ithem, ithem); 1049. 			bill_dummy_object(obj); 1050. 		   }  1051. 		}  1052. 		begin_burn(obj, FALSE); 1053. 	} 1054. }  1055.  1056. STATIC_OVL void 1057. light_cocktail(obj) 1058. 	struct obj *obj;	/* obj is a potion of oil */ 1059. { 1060. 	char buf[BUFSZ]; 1061. 1062. 	if (u.uswallow) { 1063. 	   You(no_elbow_room); 1064. 	   return; 1065. 	} 1066.  1067. 	if (obj->lamplit) { 1068. 	   You("snuff the lit potion."); 1069. 	   end_burn(obj, TRUE); 1070. 	   /*  1071. 	     * Free & add to re-merge potion. This will average the 1072. 	    * age of the potions. Not exactly the best solution, 1073. 	    * but its easy. 1074. 	    */  1075. 	    freeinv(obj); 1076. 	   (void) addinv(obj); 1077. 	   return; 1078. 	} else if (Underwater) { 1079. 	   pline("There is not enough oxygen to sustain a fire."); 1080. 	   return; 1081. 	} 1082.  1083. 	You("light %s potion.  It gives off a dim light.", shk_your(buf, obj)); 1084. 	if (obj->unpaid) { 1085. 	   check_unpaid(obj);		/* surcharge for use of unpaid item */ 1086. 	   bill_dummy_object(obj);	/* treat it as having been used up    */ 1087. 	   obj->no_charge = 1;		/* you're now obligated to pay for it */ 1088. 	   obj->unpaid = 0; 1089. 	} 1090. 	makeknown(obj->otyp); 1091. 1092. 	if (obj->quan > 1L) { 1093. 	   (void) splitobj(obj, 1L); 1094. 	   begin_burn(obj, FALSE);	/* burn before free to get position */ 1095. 	   obj_extract_self(obj);	/* free from inv */ 1096. 1097. 	    /* shouldn't merge */ 1098. 	   obj = hold_another_object(obj, "You drop %s!",  1099. 				      doname(obj), (const char *)0); 1100. 	} else 1101. 	   begin_burn(obj, FALSE); 1102. } 1103.  1104. static NEARDATA const char cuddly[] = { TOOL_CLASS, 0 }; 1105. 1106. int 1107. dorub 1108. { 1109. 	struct obj *obj = getobj(cuddly, "rub"); 1110. 1111. 	if(!obj || (obj != uwep && !wield_tool(obj))) return 0; 1112. 1113. 	/* now uwep is obj */ 1114. 	if (uwep->otyp == MAGIC_LAMP) { 1115. 	   if (uwep->spe > 0 && !rn2(3)) { 1116. 		check_unpaid_usage(uwep, TRUE);		/* unusual item use */ 1117. 		djinni_from_bottle(uwep); 1118. 		makeknown(MAGIC_LAMP); 1119. 		uwep->otyp = OIL_LAMP; 1120. 		uwep->spe = 0; /* for safety */ 1121. 		uwep->age = rn1(500,1000); 1122. 		if (uwep->lamplit) begin_burn(uwep, TRUE); 1123. 	   } else if (rn2(2) && !Blind) 1124. 		You("see a puff of smoke."); 1125. 	   else pline(nothing_happens); 1126. 	} else if (obj->otyp == BRASS_LANTERN) { 1127. 	   /* message from Adventure */ 1128. 	   pline("Rubbing the electric lamp is not particularly rewarding."); 1129. 	   pline("Anyway, nothing exciting happens."); 1130. 	} else pline(nothing_happens); 1131. 	return 1; 1132. } 1133.  1134. int 1135. dojump 1136. { 1137. 	/* Physical jump */ 1138. 	return jump(0); 1139. } 1140.  1141. int 1142. jump(magic) 1143. int magic; /* 0=Physical, otherwise skill level */ 1144. { 1145. 	coord cc; 1146. 	struct monst *mtmp; 1147. 1148. 	if (!magic && (nolimbs(youmonst.data) || slithy(youmonst.data))) { 1149. 		/* normally (nolimbs || slithy) implies !Jumping, 1150. 		  but that isn't necessarily the case for knights */ 1151. 		You_cant("jump; you have no legs!"); 1152. 		return 0; 1153. 	} else if (!magic && !Jumping) { 1154. 		You_cant("jump very far."); 1155. 		return 0; 1156. 	} else if (u.uswallow) { 1157. 		if (magic) { 1158. 			You("bounce around a little."); 1159. 			return 1; 1160. 		} 1161. 		pline("You've got to be kidding!"); 1162. 		return 0; 1163. 	} else if (u.uinwater) { 1164. 		if (magic) { 1165. 			You("swish around a little."); 1166. 			return 1; 1167. 		} 1168. 		pline("This calls for swimming, not jumping!"); 1169. 		return 0; 1170. 	} else if (u.ustuck) { 1171. 		if (magic) { 1172. 			You("writhe a little in the grasp of %s!", mon_nam(u.ustuck)); 1173. 			return 1; 1174. 		} 1175. 		You("cannot escape from %s!", mon_nam(u.ustuck)); 1176. 		return 0; 1177. 	} else if (Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) { 1178. 		if (magic) { 1179. 			You("flail around a little."); 1180. 			return 1; 1181. 		} 1182. 		You("don't have enough traction to jump."); 1183. 		return 0; 1184. 	} else if (!magic && near_capacity > UNENCUMBERED) { 1185. 		You("are carrying too much to jump!"); 1186. 		return 0; 1187. 	} else if (!magic && (u.uhunger <= 100 || ACURR(A_STR) < 6)) { 1188. 		You("lack the strength to jump!"); 1189. 		return 0; 1190. 	} else if (Wounded_legs) { 1191. 		/* note: dojump has similar code */ 1192. 		long wl = (Wounded_legs & BOTH_SIDES); 1193. 		const char *bp = body_part(LEG); 1194. 1195. 		if (wl == BOTH_SIDES) bp = makeplural(bp); 1196. #ifdef STEED 1197. 		if (u.usteed) 1198. 	 	   pline("%s is in no shape for jumping.", Monnam(u.usteed)); 1199. 		else 1200. #endif 1201. 		Your("%s%s %s in no shape for jumping.", 1202. 		     (wl == LEFT_SIDE) ? "left " :  1203. 			(wl == RIGHT_SIDE) ? "right " : "",  1204. 		     bp, (wl == BOTH_SIDES) ? "are" : "is"); 1205. 		return 0; 1206. 	} 1207. #ifdef STEED 1208. 	else if (u.usteed && u.utrap) { 1209. 		pline("%s is stuck in a trap.", Monnam(u.usteed)); 1210. 		return (0); 1211. 	} 1212. #endif 1213. 1214. 	pline("Where do you want to jump?"); 1215. 	cc.x = u.ux; 1216. 	cc.y = u.uy; 1217. 	if (getpos(&cc, TRUE, "the desired position") < 0) 1218. 		return 0;	/* user pressed ESC */ 1219. 	if (!magic && !(HJumping & ~INTRINSIC) && !EJumping && 1220. 			distu(cc.x, cc.y) != 5) { 1221. 		pline("Illegal move!"); 1222. 		return 0; 1223. 	} else if (distu(cc.x, cc.y) > (magic ? 6+magic*3 : 9)) { 1224. 		pline("Too far!"); 1225. 		return 0; 1226. 	} else if (!cansee(cc.x, cc.y)) { 1227. 		You("cannot see where to land!"); 1228. 		return 0; 1229. 	} else if ((mtmp = m_at(cc.x, cc.y)) != 0) { 1230. 		You("cannot trample %s!", mon_nam(mtmp)); 1231. 		return 0; 1232. 	} else if (!isok(cc.x, cc.y) || 1233. 		   ((IS_ROCK(levl[cc.x][cc.y].typ) ||  1234. 		     sobj_at(BOULDER, cc.x, cc.y) || closed_door(cc.x, cc.y)) 1235. 		   && !(Passes_walls && may_passwall(cc.x, cc.y)))) { 1236. 			You("cannot jump there!"); 1237. 			return 0; 1238. 	} else { 1239. 	   if(u.utrap) 1240. 		switch(u.utraptype) { 1241. 		case TT_BEARTRAP: { 1242. 		   register long side = rn2(3) ? LEFT_SIDE : RIGHT_SIDE; 1243. 		   You("rip yourself free of the bear trap!  Ouch!"); 1244. 		   losehp(rnd(10), "jumping out of a bear trap", KILLED_BY); 1245. 		   set_wounded_legs(side, rn1(1000,500)); 1246. 		   break; 1247. 		 }  1248. 		case TT_PIT: 1249. 		   You("leap from the pit!"); 1250. 		   break; 1251. 		case TT_WEB: 1252. 		   You("tear the web apart as you pull yourself free!"); 1253. 		   deltrap(t_at(u.ux,u.uy)); 1254. 		   break; 1255. 		case TT_LAVA: 1256. 		   You("pull yourself above the lava!"); 1257. 		   u.utrap = 0; 1258. 		   return 1; 1259. 		case TT_INFLOOR: 1260. 		   You("strain your %s, but you're still stuck in the floor.",  1261. 			makeplural(body_part(LEG))); 1262. 		   set_wounded_legs(LEFT_SIDE, rn1(10, 11)); 1263. 		   set_wounded_legs(RIGHT_SIDE, rn1(10, 11)); 1264. 		   return 1; 1265. 		} 1266.  1267. 		/* A little Sokoban guilt... */ 1268. 		if (In_sokoban(&u.uz)) 1269. 		   change_luck(-1); 1270. 1271. 	    teleds(cc.x, cc.y); 1272. 	   nomul(-1); 1273. 	   nomovemsg = ""; 1274. 	   morehungry(rnd(25)); 1275. 	   return 1; 1276. 	} 1277. }  1278.  1279. boolean 1280. tinnable(corpse) 1281. struct obj *corpse; 1282. { 1283. 	if (corpse->oeaten) return 0; 1284. 	if (!mons[corpse->corpsenm].cnutrit) return 0; 1285. 	return 1; 1286. } 1287.  1288. STATIC_OVL void 1289. use_tinning_kit(obj) 1290. register struct obj *obj; 1291. { 1292. 	register struct obj *corpse, *can; 1293. 1294. 	/* This takes only 1 move. If this is to be changed to take many 1295. 	 * moves, we've got to deal with decaying corpses... 1296. */ 1297. 	if (obj->spe <= 0) { 1298. 		You("seem to be out of tins."); 1299. 		return; 1300. 	} 1301. 	if (!(corpse = floorfood("tin", 2))) return; 1302. 	if (corpse->oeaten) { 1303. 		You("cannot tin %s which is partly eaten.",something); 1304. 		return; 1305. 	} 1306. 	if (touch_petrifies(&mons[corpse->corpsenm])  1307. 		&& !Stone_resistance && !uarmg) { 1308. 	   char kbuf[BUFSZ]; 1309. 1310. 	    if (poly_when_stoned(youmonst.data)) 1311. 		You("tin %s without wearing gloves.", 1312. 			an(mons[corpse->corpsenm].mname)); 1313. 	   else { 1314. 		pline("Tinning %s without wearing gloves is a fatal mistake...", 1315. 			an(mons[corpse->corpsenm].mname)); 1316. 		Sprintf(kbuf, "trying to tin %s without gloves", 1317. 			an(mons[corpse->corpsenm].mname)); 1318. 	   }  1319. 	    instapetrify(kbuf); 1320. 	} 1321. 	if (is_rider(&mons[corpse->corpsenm])) { 1322. 		(void) revive_corpse(corpse); 1323. 		verbalize("Yes... But War does not preserve its enemies..."); 1324. 		return; 1325. 	} 1326. 	if (mons[corpse->corpsenm].cnutrit == 0) { 1327. 		pline("That's too insubstantial to tin."); 1328. 		return; 1329. 	} 1330. 	obj->spe--; 1331. 	if ((can = mksobj(TIN, FALSE, FALSE)) != 0) { 1332. 	   static const char you_buy_it[] = "You tin it, you bought it!"; 1333. 1334. 	    can->corpsenm = corpse->corpsenm; 1335. 	   can->cursed = obj->cursed; 1336. 	   can->blessed = obj->blessed; 1337. 	   can->owt = weight(can); 1338. 	   can->known = 1; 1339. 	   can->spe = -1;  /* Mark tinned tins. No spinach allowed... */ 1340. 	    if (carried(corpse)) { 1341. 		if (corpse->unpaid) 1342. 		   verbalize(you_buy_it); 1343. 		useup(corpse); 1344. 	   } else { 1345. 		if (costly_spot(corpse->ox, corpse->oy) && !corpse->no_charge) 1346. 		   verbalize(you_buy_it); 1347. 		useupf(corpse, 1L); 1348. 	   }  1349. 	    can = hold_another_object(can, "You make, but cannot pick up, %s.",  1350. 				      doname(can), (const char *)0); 1351. 	} else impossible("Tinning failed."); 1352. } 1353.  1354. void 1355. use_unicorn_horn(obj) 1356. struct obj *obj; 1357. { 1358. #define PROP_COUNT 6		/* number of properties we're dealing with */ 1359. #define ATTR_COUNT (A_MAX*3)	/* number of attribute points we might fix */ 1360. 	int idx, val, val_limit, 1361. 	   trouble_count, unfixable_trbl, did_prop, did_attr; 1362. 	int trouble_list[PROP_COUNT + ATTR_COUNT]; 1363. 1364. 	if (obj && obj->cursed) { 1365. 	   long lcount = (long) rnd(100); 1366. 1367. 	    switch (rn2(6)) { 1368. 	   case 0: make_sick(Sick ? Sick/3L + 1L : (long)rn1(ACURR(A_CON),20),  1369. 			xname(obj), TRUE, SICK_NONVOMITABLE); 1370. 		   break; 1371. 	   case 1: make_blinded(Blinded + lcount, TRUE); 1372. 		   break; 1373. 	   case 2: if (!Confusion) 1374. 			You("suddenly feel %s.", 1375. 			    Hallucination ? "trippy" : "confused"); 1376. 		   make_confused(HConfusion + lcount, TRUE); 1377. 		   break; 1378. 	   case 3: make_stunned(HStun + lcount, TRUE); 1379. 		   break; 1380. 	   case 4: (void) adjattrib(rn2(A_MAX), -1, FALSE); 1381. 		   break; 1382. 	   case 5: make_hallucinated(HHallucination + lcount, TRUE, 0L); 1383. 		   break; 1384. 	   }  1385. 	    return; 1386. 	} 1387.  1388. /*  1389.  * Entries in the trouble list use a very simple encoding scheme. 1390. */  1391. #define prop2trbl(X)	((X) + A_MAX) 1392. #define attr2trbl(Y)	(Y) 1393. #define prop_trouble(X) trouble_list[trouble_count++] = prop2trbl(X) 1394. #define attr_trouble(Y) trouble_list[trouble_count++] = attr2trbl(Y) 1395. 1396. 	trouble_count = unfixable_trbl = did_prop = did_attr = 0; 1397. 1398. 	/* collect property troubles */ 1399. 	if (Sick) prop_trouble(SICK); 1400. 	if (Blinded > (long)(u.ucreamed + 1)) prop_trouble(BLINDED); 1401. 	if (HHallucination) prop_trouble(HALLUC); 1402. 	if (Vomiting) prop_trouble(VOMITING); 1403. 	if (HConfusion) prop_trouble(CONFUSION); 1404. 	if (HStun) prop_trouble(STUNNED); 1405. 	/* keep track of unfixed trouble, for message adjustment below 1406. 	  (can't "feel great" with these problems present) */ 1407. 	if (Stoned) unfixable_trbl++; 1408. 	if (Strangled) unfixable_trbl++; 1409. 	if (Wounded_legs) unfixable_trbl++; 1410. 1411. 	/* collect attribute troubles */ 1412. 	for (idx = 0; idx < A_MAX; idx++) { 1413. 	   val_limit = AMAX(idx); 1414. 	   /* don't recover strength lost from hunger */ 1415. 	   if (idx == A_STR && u.uhs >= WEAK) val_limit--; 1416. 	   /* don't recover more than 3 points worth of any attribute */ 1417. 	   if (val_limit > ABASE(idx) + 3) val_limit = ABASE(idx) + 3; 1418. 1419. 	    for (val = ABASE(idx); val < val_limit; val++) 1420. 		attr_trouble(idx); 1421. 	   /* keep track of unfixed trouble, for message adjustment below */ 1422. 	   unfixable_trbl += (AMAX(idx) - val_limit); 1423. 	} 1424.  1425. 	if (trouble_count == 0) { 1426. 	   pline(nothing_happens); 1427. 	   return; 1428. 	} else if (trouble_count > 1) {		/* shuffle */ 1429. 	   int i, j, k;  1430. 1431. 	   for (i = trouble_count - 1; i > 0; i--) 1432. 		if ((j = rn2(i + 1)) != i) { 1433. 		   k = trouble_list[j]; 1434. 		   trouble_list[j] = trouble_list[i]; 1435. 		   trouble_list[i] = k;  1436. } 1437. 	}  1438.  1439. 	/*  1440. 	 *		Chances for number of troubles to be fixed 1441. 	 *		 0	1     2      3      4	    5	   6	  7  1442. 	 *   blessed:  22.7%  22.7%  19.5%  15.4%  10.7%   5.7%   2.6%	 0.8% 1443. 	 * uncursed:  35.4%  35.4%  22.9%   6.3%    0	    0	   0	  0 1444. 	 */ 1445. 	val_limit = rn2( d(2, (obj && obj->blessed) ? 4 : 2) ); 1446. 	if (val_limit > trouble_count) val_limit = trouble_count; 1447. 1448. 	/* fix [some of] the troubles */ 1449. 	for (val = 0; val < val_limit; val++) { 1450. 	   idx = trouble_list[val]; 1451. 1452. 	    switch (idx) { 1453. 	   case prop2trbl(SICK): 1454. 		make_sick(0L, (char *) 0, TRUE, SICK_ALL); 1455. 		did_prop++; 1456. 		break; 1457. 	   case prop2trbl(BLINDED): 1458. 		make_blinded(u.ucreamed ? (long)(u.ucreamed+1) : 0L, TRUE); 1459. 		did_prop++; 1460. 		break; 1461. 	   case prop2trbl(HALLUC): 1462. 		make_hallucinated(0L, TRUE, 0L); 1463. 		did_prop++; 1464. 		break; 1465. 	   case prop2trbl(VOMITING): 1466. 		make_vomiting(0L, TRUE); 1467. 		did_prop++; 1468. 		break; 1469. 	   case prop2trbl(CONFUSION): 1470. 		make_confused(0L, TRUE); 1471. 		did_prop++; 1472. 		break; 1473. 	   case prop2trbl(STUNNED): 1474. 		make_stunned(0L, TRUE); 1475. 		did_prop++; 1476. 		break; 1477. 	   default: 1478. 		if (idx >= 0 && idx < A_MAX) { 1479. 		   ABASE(idx) += 1; 1480. 		   did_attr++; 1481. 		} else 1482. 		   panic("use_unicorn_horn: bad trouble? (%d)", idx); 1483. 		break; 1484. 	   }  1485. 	}  1486.  1487. 	if (did_attr) 1488. 	   pline("This makes you feel %s!",  1489. 		  (did_prop + did_attr) == (trouble_count + unfixable_trbl) ?  1490. 		  "great" : "better"); 1491. 	else if (!did_prop) 1492. 	   pline("Nothing seems to happen."); 1493. 1494. 	flags.botl = (did_attr || did_prop); 1495. #undef PROP_COUNT 1496. #undef ATTR_COUNT 1497. #undef prop2trbl 1498. #undef attr2trbl 1499. #undef prop_trouble 1500. #undef attr_trouble 1501. } 1502.  1503. /*  1504.  * Timer callback routine: turn figurine into monster 1505. */  1506. void 1507. fig_transform(arg, timeout) 1508. genericptr_t arg; 1509. long timeout; 1510. { 1511. 	struct obj *figurine = (struct obj *)arg; 1512. 	struct monst *mtmp; 1513. 	coord cc; 1514. 	boolean cansee_spot, silent, okay_spot; 1515. 	boolean redraw = FALSE; 1516. 	char monnambuf[BUFSZ], carriedby[BUFSZ]; 1517. 1518. 	if (!figurine) { 1519. #ifdef DEBUG 1520. 	   pline("null figurine in fig_transform"); 1521. #endif 1522. 	   return; 1523. 	} 1524. 	silent = (timeout != monstermoves); /* happened while away */ 1525. 	okay_spot = get_obj_location(figurine, &cc.x, &cc.y, 0); 1526. 	if (figurine->where == OBJ_INVENT || 1527. 	    figurine->where == OBJ_MINVENT) 1528. 	       okay_spot = enexto(&cc, cc.x, cc.y,  1529. 				   &mons[figurine->corpsenm]); 1530. 	if (!okay_spot || 1531. 	    !figurine_location_checks(figurine,&cc, TRUE)) { 1532. 	   	/* reset the timer to try again later */ 1533. 		(void) start_timer((long)rnd(5000), TIMER_OBJECT, 1534. 				FIG_TRANSFORM, (genericptr_t)figurine); 1535. 		return; 1536. 	} 1537. 	  1538. 	cansee_spot = cansee(cc.x, cc.y); 1539. 	mtmp = make_familiar(figurine, cc.x, cc.y, TRUE); 1540. 	if (mtmp) { 1541. 	   Sprintf(monnambuf, "%s",a_monnam(mtmp)); 1542. 	   switch (figurine->where) { 1543. 		case OBJ_INVENT: 1544. 		   if (Blind) 1545. 			You_feel("%s %s from your pack!", something, 1546. 			    locomotion(mtmp->data,"drop")); 1547. 		   else 1548. 			You("see %s %s out of your pack!", 1549. 			    monnambuf,  1550. 			    locomotion(mtmp->data,"drop")); 1551. 		   break; 1552. 1553. 		case OBJ_FLOOR: 1554. 		   if (cansee_spot && !silent) { 1555. 			You("suddenly see a figurine transform into %s!", 1556. 				monnambuf); 1557. 			redraw = TRUE;	/* update figurine's map location */ 1558. 		   }  1559. 		    break; 1560. 1561. 		case OBJ_MINVENT: 1562. 		   if (cansee_spot && !silent) { 1563. 		   	struct monst *mon; 1564. 		   	mon = figurine->ocarry; 1565. 			/* figurine carring monster might be invisible */ 1566. 			if (canseemon(figurine->ocarry)) { 1567. 			   Sprintf(carriedby, "%s pack",  1568. 				     s_suffix(a_monnam(mon))); 1569. 			} 1570. 			else if (is_pool(mon->mx, mon->my)) 1571. 			   Strcpy(carriedby, "empty water"); 1572. 			else 1573. 			   Strcpy(carriedby, "thin air"); 1574. 			You("see %s %s out of %s!", monnambuf, 1575. 			    locomotion(mtmp->data, "drop"), carriedby); 1576. 		   }  1577. 		    break; 1578. #if 0 1579. 		case OBJ_MIGRATING: 1580. 		   break; 1581. #endif 1582. 1583. 		default: 1584. 		   impossible("figurine came to life where? (%d)",  1585. 				(int)figurine->where); 1586. 		break; 1587. 	   }  1588. 	}  1589. 	/* free figurine now */ 1590. 	obj_extract_self(figurine); 1591. 	obfree(figurine, (struct obj *)0); 1592. 	if (redraw) newsym(cc.x, cc.y); 1593. } 1594.  1595. STATIC_OVL boolean 1596. figurine_location_checks(obj, cc, quietly) 1597. struct obj *obj; 1598. coord *cc; 1599. boolean quietly; 1600. { 1601. 	xchar x,y; 1602. 	 1603. 	x = cc->x; y = cc->y; 1604. 	if (!isok(x,y)) { 1605. 		if (!quietly) 1606. 			You("cannot put the figurine there."); 1607. 		return FALSE; 1608. 	} 1609. 	if (IS_ROCK(levl[x][y].typ) &&  1610. 	    !(passes_walls(&mons[obj->corpsenm]) && may_passwall(x,y))) { 1611. 		if (!quietly) 1612. 			You("cannot place a figurine in solid rock!"); 1613. 		return FALSE; 1614. 	} 1615. 	if (sobj_at(BOULDER,x,y) && !passes_walls(&mons[obj->corpsenm])  1616. 			&& !throws_rocks(&mons[obj->corpsenm])) { 1617. 		if (!quietly) 1618. 			You("cannot fit the figurine on the boulder."); 1619. 		return FALSE; 1620. 	} 1621. 	return TRUE; 1622. } 1623.  1624. STATIC_OVL void 1625. use_figurine(obj) 1626. register struct obj *obj; 1627. { 1628. 	xchar x, y;  1629. coord cc; 1630. 	 1631. 	if(!getdir((char *)0)) { 1632. 		flags.move = multi = 0; 1633. 		return; 1634. 	} 1635. 	x = u.ux + u.dx; y = u.uy + u.dy; 1636. 	cc.x = x; cc.y = y; 1637. /* Passing FALSE arg here will result in messages displayed */ 1638. 	if (!figurine_location_checks(obj, &cc, FALSE)) return; 1639. 	You("%s and it transforms.", 1640. 	    (u.dx||u.dy) ? "set the figurine beside you" :  1641. 	    (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) ?  1642. 		"release the figurine" :  1643. 	    (u.dz < 0 ? 1644. 		"toss the figurine into the air" : 1645. 		"set the figurine on the ground")); 1646. 	(void) make_familiar(obj, u.ux+u.dx, u.uy+u.dy, FALSE); 1647. 	(void) stop_timer(FIG_TRANSFORM, (genericptr_t)obj); 1648. 	useup(obj); 1649. } 1650.  1651. static NEARDATA const char lubricables[] = { ALL_CLASSES, ALLOW_NONE, 0 }; 1652. static NEARDATA const char need_to_remove_outer_armor[] = 1653. 			"need to remove your %s to grease your %s."; 1654. 1655. STATIC_OVL void 1656. use_grease(obj) 1657. struct obj *obj; 1658. { 1659. 	struct obj *otmp; 1660. 	char buf[BUFSZ]; 1661. 1662. 	if (Glib) { 1663. 	   dropx(obj); 1664. 	   pline("%s slips from your %s.", The(xname(obj)),  1665. 		  makeplural(body_part(FINGER))); 1666. 	   return; 1667. 	} 1668.  1669. 	if (obj->spe > 0) { 1670. 		if ((obj->cursed || Fumbling) && !rn2(2)) { 1671. 			check_unpaid(obj); 1672. 			obj->spe--; 1673. 			dropx(obj); 1674. 			pline("%s slips from your %s.", The(xname(obj)), 1675. 			      makeplural(body_part(FINGER))); 1676. 			return; 1677. 		} 1678. 		otmp = getobj(lubricables, "grease"); 1679. 		if (!otmp) return; 1680. 		if ((otmp->owornmask & WORN_ARMOR) && uarmc) { 1681. 			Strcpy(buf, xname(uarmc)); 1682. 			You(need_to_remove_outer_armor, buf, xname(otmp)); 1683. 			return; 1684. 		} 1685. #ifdef TOURIST 1686. 		if ((otmp->owornmask & WORN_SHIRT) && (uarmc || uarm)) { 1687. 			Strcpy(buf, uarmc ? xname(uarmc) : ""); 1688. 			if (uarmc && uarm) Strcat(buf, " and "); 1689. 			Strcat(buf, uarm ? xname(uarm) : ""); 1690. 			You(need_to_remove_outer_armor, buf, xname(otmp)); 1691. 			return; 1692. 		} 1693. #endif 1694. 		check_unpaid(obj); 1695. 		obj->spe--; 1696. 		if (otmp != &zeroobj) { 1697. 			You("cover %s with a thick layer of grease.", 1698. 			    yname(otmp)); 1699. 			otmp->greased = 1; 1700. 			if (obj->cursed && !nohands(youmonst.data)) { 1701. 			   incr_itimeout(&Glib, rnd(15)); 1702. 			   pline("Some of the grease gets all over your %s.",  1703. 				makeplural(body_part(HAND))); 1704. 			} 1705. 		} else { 1706. 			Glib += rnd(15); 1707. 			You("coat your %s with grease.", 1708. 			    makeplural(body_part(FINGER))); 1709. 		} 1710. 	} else { 1711. 		pline("%s %s empty.", The(xname(obj)), 1712. 			obj->known ? "is" : "seems to be"); 1713. 	} 1714. }  1715.  1716. static struct trapinfo { 1717. 	struct obj *tobj; 1718. 	xchar tx, ty; 1719. 	int time_needed; 1720. } trapinfo; 1721. 1722. void 1723. reset_trapset 1724. { 1725. 	trapinfo.tobj = 0; 1726. } 1727.  1728. /* Place a landmine/bear trap. Helge Hafting */ 1729. STATIC_OVL void 1730. use_trap(otmp) 1731. struct obj *otmp; 1732. { 1733. 	int ttyp, tmp; 1734. 	const char *what = (char *)0; 1735. 	char buf[BUFSZ]; 1736. 	const char *occutext = "setting the trap"; 1737. 1738. 	if (nohands(youmonst.data)) 1739. 	   what = "without hands"; 1740. 	else if (Stunned) 1741. 	   what = "while stunned"; 1742. 	else if (u.uswallow) 1743. 	   what = is_animal(u.ustuck->data) ? "while swallowed" : 1744. 			"while engulfed"; 1745. 	else if (Underwater) 1746. 	   what = "underwater"; 1747. 	else if (Levitation) 1748. 	   what = "while levitating"; 1749. 	else if (is_pool(u.ux, u.uy)) 1750. 	   what = "in water"; 1751. 	else if (is_lava(u.ux, u.uy)) 1752. 	   what = "in lava"; 1753. 	else if (On_stairs(u.ux, u.uy)) 1754. 	   what = (u.ux == xdnladder || u.ux == xupladder) ? 1755. 			"on the ladder" : "on the stairs"; 1756. 	else if (IS_FURNITURE(levl[u.ux][u.uy].typ) || 1757. 		IS_ROCK(levl[u.ux][u.uy].typ) ||  1758. 		closed_door(u.ux, u.uy) || t_at(u.ux, u.uy)) 1759. 	   what = "here"; 1760. 	if (what) { 1761. 	   You_cant("set a trap %s!",what); 1762. 	   reset_trapset; 1763. 	   return; 1764. 	} 1765. 	ttyp = (otmp->otyp == LAND_MINE) ? LANDMINE : BEAR_TRAP; 1766. 	if (otmp == trapinfo.tobj && 1767. 		u.ux == trapinfo.tx && u.uy == trapinfo.ty) { 1768. 	   You("resume setting %s %s.",  1769. 		shk_your(buf, otmp),  1770. 		defsyms[trap_to_defsym(what_trap(ttyp))].explanation); 1771. 	   set_occupation(set_trap, occutext, 0); 1772. 	   return; 1773. 	} 1774. 	trapinfo.tobj = otmp; 1775. 	trapinfo.tx = u.ux, trapinfo.ty = u.uy; 1776. 	tmp = ACURR(A_DEX); 1777. 	trapinfo.time_needed = (tmp > 17) ? 2 : (tmp > 12) ? 3 : 1778. 				(tmp > 7) ? 4 : 5; 1779. 	if (Blind) trapinfo.time_needed *= 2; 1780. 	tmp = ACURR(A_STR); 1781. 	if (ttyp == BEAR_TRAP && tmp < 18) 1782. 	   trapinfo.time_needed += (tmp > 12) ? 1 : (tmp > 7) ? 2 : 4; 1783. 	/*[fumbling and/or confusion and/or cursed object check(s) 1784. 	  should be incorporated here instead of in set_trap]*/ 1785. 1786. 	You("begin setting %s %s.",  1787. 	    shk_your(buf, otmp),  1788. 	    defsyms[trap_to_defsym(what_trap(ttyp))].explanation); 1789. 	set_occupation(set_trap, occutext, 0); 1790. 	return; 1791. } 1792.  1793. STATIC_PTR 1794. int 1795. set_trap 1796. { 1797. 	struct obj *otmp = trapinfo.tobj; 1798. 	struct trap *ttmp; 1799. 	int ttyp; 1800. 1801. 	if (!otmp || otmp->where != OBJ_INVENT ||  1802. 		u.ux != trapinfo.tx || u.uy != trapinfo.ty) { 1803. 	   /* ?? */  1804. 	    reset_trapset; 1805. 	   return 0; 1806. 	} 1807.  1808. 	if (--trapinfo.time_needed > 0) return 1;	/* still busy */ 1809. 1810. 	ttyp = (otmp->otyp == LAND_MINE) ? LANDMINE : BEAR_TRAP; 1811. 	ttmp = maketrap(u.ux, u.uy, ttyp); 1812. 	if (ttmp) { 1813. 	   ttmp->tseen = 1; 1814. 	   ttmp->madeby_u = 1; 1815. 	   newsym(u.ux, u.uy); /* if our hero happens to be invisible */ 1816. 	   if (*in_rooms(u.ux,u.uy,SHOPBASE)) { 1817. 		add_damage(u.ux, u.uy, 0L);		/* schedule removal */ 1818. 	   }  1819. 	    You("finish arming %s.",  1820. 		the(defsyms[trap_to_defsym(what_trap(ttyp))].explanation)); 1821. 	   if ((otmp->cursed || Fumbling) && (rnl(10) > 5)) dotrap(ttmp); 1822. 	} else { 1823. 	   /* this shouldn't happen */ 1824. 	   Your("trap setting attempt fails."); 1825. 	} 1826. 	useup(otmp); 1827. 	reset_trapset; 1828. 	return 0; 1829. } 1830.  1831. STATIC_OVL int 1832. use_whip(obj) 1833. struct obj *obj; 1834. { 1835. 	char buf[BUFSZ]; 1836. 	struct monst *mtmp; 1837. 	register int rx, ry; 1838. 	int res = 0; 1839. 	int proficient = 0; 1840. 	const char *msg_slipsfree = "The bullwhip slips free."; 1841. 	const char *msg_snap = "Snap!"; 1842. 	struct obj *otmp; 1843. 1844. 	if (obj != uwep) { 1845. 	   if (!wield_tool(obj)) return(0); 1846. 	   else res = 1; 1847. 	   /* prevent bashing msg */ 1848. 	   unweapon = FALSE; 1849. 	} 1850. 	if(!getdir((char *)0)) return(res); 1851. 	if (Stunned || (Confusion && !rn2(5))) confdir; 1852. 	rx = u.ux + u.dx; 1853. 	ry = u.uy + u.dy; 1854. 	mtmp = m_at(rx, ry); 1855. 1856. 	/* fake some proficiency checks */ 1857. 	proficient = 0; 1858. 	if (Role_if(PM_ARCHEOLOGIST)) ++proficient; 1859. 	if (ACURR(A_DEX) < 6) proficient--; 1860. 	else if (ACURR(A_DEX) >= 14) proficient += (ACURR(A_DEX) - 14); 1861. 	if (Fumbling) --proficient; 1862. 	if (proficient > 3) proficient = 3; 1863. 	if (proficient < 0) proficient = 0; 1864. 1865. 	if (u.uswallow && attack(u.ustuck)) 1866. 		pline("There is not enough room to flick your bullwhip."); 1867. 	else if (Underwater) 1868. 		pline("There is too much resistance to flick your bullwhip."); 1869. 	else if (u.dz < 0) 1870. 		You("flick a bug off of the %s.",ceiling(u.ux,u.uy)); 1871. 	else if((!u.dx && !u.dy) || (u.dz > 0)) { 1872. 		int dam; 1873. 1874. #ifdef STEED 1875. 		/* Sometimes you hit your steed by mistake */ 1876. 		if (u.usteed && !rn2(3)) { 1877. 			You("whip %s!", mon_nam(u.usteed)); 1878. 			kick_steed; 1879. 			return (1); 1880. 		} 1881. #endif 1882. 		if (Levitation 1883. #ifdef STEED  1884. 			|| u.usteed  1885. #endif  1886. 		   ) { 1887. 			/* Have a shot at snaring something on the floor */ 1888. 			otmp = level.objects[u.ux][u.uy]; 1889. 			if (otmp && proficient) { 1890. 				You("wrap your bullwhip around %s on the %s.", 1891. 					an(singular(otmp,xname)),  1892. 					surface(u.ux, u.uy)); 1893. 				if (!rnl(6)) 1894. 					if (pickup_object(otmp, 1L, TRUE) > 0) 1895. 						return 1; 1896. 				pline(msg_slipsfree); 1897. 				return 1; 1898. 			} 1899. 		}  1900. 		dam = rnd(2) + dbon + obj->spe; 1901. 		if (dam <= 0) dam = 1; 1902. 		You("hit your %s with your bullwhip.", body_part(FOOT)); 1903. 		/* self_pronoun won't work twice in a sentence */ 1904. 		Strcpy(buf, self_pronoun("killed %sself with %%s bullwhip", 1905. 			"him")); 1906. 		losehp(dam, self_pronoun(buf, "his"), NO_KILLER_PREFIX); 1907. 		flags.botl=1; 1908. 		return(1); 1909. 	} else if ((Fumbling || Glib) && !rn2(5)) { 1910. 		pline_The("bullwhip slips out of your %s.", 1911. 			body_part(HAND)); 1912. 		dropx(obj); 1913. 		setuwep((struct obj *)0); 1914. 	} 1915. 	/*  1916. 	 *     Assumptions: 1917. 	 * 1918. 	 *		if you're in a pit 1919. 	 *			- you are attempting to get out of the pit 1920. 	 *			- or, if you are applying it towards a small 1921. 	 *			 monster then it is assumed that you are 1922. 	 *			 trying to hit it. 1923. 	 *		else if the monster is wielding a weapon 1924. 	 *			- you are attempting to disarm a monster 1925. 	 *		else 1926. 	 *			- you are attempting to hit the monster 1927. 	 * 1928. 	 *		if you're confused (and thus off the mark) 1929. 	 *			- you only end up hitting. 1930. 	 * 1931. 	 */  1932. 	else if(u.utrap && u.utraptype == TT_PIT) { 1933. 		const char *wrapped_what = (char *)0; 1934. 1935. 		if (mtmp) { 1936. 			if (bigmonst(mtmp->data)) { 1937. 				Strcpy(buf, mon_nam(mtmp)); 1938. 				wrapped_what = buf; 1939. 			} else if (proficient) { 1940. 				if (attack(mtmp)) return(1); 1941. 				else pline(msg_snap); 1942. 			} 1943. 		}  1944. 		if (!wrapped_what) { 1945. 			if (IS_FURNITURE(levl[rx][ry].typ)) 1946. 				wrapped_what = something; 1947. 			else if (sobj_at(BOULDER, rx, ry)) 1948. 				wrapped_what = "a boulder"; 1949. 		} 1950. 		if (wrapped_what) { 1951. 			coord cc; 1952. 1953. 			cc.x = rx; cc.y = ry; 1954. 			You("wrap your bullwhip around %s.", wrapped_what); 1955. 			if (proficient && rn2(proficient + 2)) { 1956. 				if (!mtmp || enexto(&cc, rx, ry, youmonst.data)) { 1957. 					You("yank yourself out of the pit!"); 1958. 					teleds(cc.x, cc.y); 1959. 					u.utrap = 0; 1960. 					vision_full_recalc = 1; 1961. 				} 1962. 			} else 1963. 				pline(msg_slipsfree); 1964. 			if (mtmp) wakeup(mtmp); 1965. 		} else pline(msg_snap); 1966. 	} else if (mtmp) { 1967. 		if (!canspotmon(mtmp) && 1968. 				    !glyph_is_invisible(levl[rx][ry].glyph)) { 1969. 			pline("A monster is there that you couldn't see."); 1970. 			map_invisible(rx, ry); 1971. 		} 1972. 		otmp = MON_WEP(mtmp);	/* can be null */ 1973. 		if (otmp) { 1974. 			char onambuf[BUFSZ]; 1975. 			const char *mon_hand; 1976. 			boolean gotit = proficient && (!Fumbling || !rn2(10)); 1977. 1978. 			Strcpy(onambuf, xname(otmp)); 1979. 			if (gotit) { 1980. 			   mon_hand = mbodypart(mtmp, HAND); 1981. 			   if (bimanual(otmp)) 1982. 				mon_hand = makeplural(mon_hand); 1983. 			} else 1984. 			   mon_hand = 0;	/* lint suppression */ 1985. 1986. 			You("wrap your bullwhip around %s %s.",  1987. 				s_suffix(mon_nam(mtmp)), onambuf); 1988. 			if (gotit && otmp->cursed) { 1989. 			   pline("%s welded to %s %s%c",  1990. 				  (otmp->quan == 1L) ? "It is" : "They are",  1991. 				  his[pronoun_gender(mtmp)], mon_hand,  1992. 				  !otmp->bknown ? '!' : '.'); 1993. 			   otmp->bknown = 1; 1994. 			   gotit = FALSE;	/* can't pull it free */ 1995. 			} 1996. 			if (gotit) { 1997. 			   obj_extract_self(otmp); 1998. 			   possibly_unwield(mtmp); 1999. 			   otmp->owornmask &= ~W_WEP; 2000. 			   switch(rn2(proficient + 1)) { 2001. 				case 2: 2002. 				   /* to floor near you */ 2003. 				   You("yank %s %s to the %s!",  2004. 					s_suffix(mon_nam(mtmp)),  2005. 					onambuf,  2006. 					surface(u.ux, u.uy)); 2007. 				   if (otmp->otyp == CRYSKNIFE &&  2008. 				    	(!otmp->oerodeproof || !rn2(10))) { 2009. 				   	otmp->otyp = WORM_TOOTH; 2010. 				   	otmp->oerodeproof = 0; 2011. 				   }  2012. 				    place_object(otmp,u.ux, u.uy); 2013. 				   break; 2014. 				case 3: 2015. 				   /* right into your inventory */ 2016. 				   if (rn2(25)) { 2017. 					You("snatch %s %s!", 2018. 						s_suffix(mon_nam(mtmp)),  2019. 						onambuf); 2020. 					otmp = hold_another_object(otmp, 2021. 						"You drop %s!", doname(otmp),  2022. 						(const char *)0); 2023. 				   /* proficient with whip, but maybe not 2024. 				      so proficient at catching weapons */ 2025. 				   }  2026. #if 0 2027. 				   else { 2028. 					int hitu, hitvalu; 2029. 2030. 					hitvalu = 8 + otmp->spe; 2031. 					hitu = thitu(hitvalu, 2032. 						dmgval(otmp, &youmonst),  2033. 						otmp, onambuf); 2034. 					if (hitu) { 2035. 				You("The %s hits you as you try to snatch it!", 2036. 						the(onambuf)); 2037. 					} 2038. 					place_object(otmp, u.ux, u.uy); 2039. 				   }  2040. #endif /* 0 */ 2041. 				   break; 2042. 				default: 2043. 				   /* to floor beneath mon */ 2044. 				   You("yank %s from %s %s!",  2045. 					the(onambuf),  2046. 					s_suffix(mon_nam(mtmp)),  2047. 					mon_hand); 2048. 				   if (otmp->otyp == CRYSKNIFE &&  2049. 				    	(!otmp->oerodeproof || !rn2(10))) { 2050. 				   	otmp->otyp = WORM_TOOTH; 2051. 				   	otmp->oerodeproof = 0; 2052. 				   }  2053. 				    place_object(otmp, mtmp->mx, mtmp->my); 2054. 				   break; 2055. 			   }  2056. 			} else { 2057. 				pline(msg_slipsfree); 2058. 			} 2059. 			wakeup(mtmp); 2060. 		} else { 2061. 			You("flick your bullwhip towards %s.", mon_nam(mtmp)); 2062. 			if (proficient) { 2063. 				if (attack(mtmp)) return(1); 2064. 				else pline(msg_snap); 2065. 			} 2066. 		}  2067. 	} else if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) { 2068. 		/* it must be air -- water checked above */ 2069. 		You("snap your whip through thin air."); 2070. 	} else 2071. 		pline(msg_snap); 2072. 	return(1); 2073. } 2074.  2075.  2076. static const char 2077. 	*not_enough_room = "There's not enough room here to use that.", 2078. 	*where_to_hit = "Where do you want to hit?", 2079. 	*cant_see_spot = "won't hit anything if you can't see that spot."; 2080. 2081. /* Distance attacks by pole-weapons */ 2082. STATIC_OVL int 2083. use_pole (obj) 2084. 	struct obj *obj; 2085. { 2086. 	int res = 0, typ, max_range = 4, min_range = 4; 2087. 	coord cc; 2088. 	struct monst *mtmp; 2089. 2090.  2091. 	/* Are you allowed to use the pole? */ 2092. 	if (u.uswallow) { 2093. 	   pline(not_enough_room); 2094. 	   return (0); 2095. 	} 2096. 	if (obj != uwep) { 2097. 	   if (!wield_tool(obj)) return(0); 2098. 	   else res = 1; 2099. 	} 2100.  2101. 	/* Prompt for a location */ 2102. 	pline(where_to_hit); 2103. 	cc.x = u.ux; 2104. 	cc.y = u.uy; 2105. 	if (getpos(&cc, TRUE, "the spot to hit") < 0) 2106. 	   return 0;	/* user pressed ESC */ 2107. 2108. 	/* Calculate range */ 2109. 	typ = weapon_type(obj); 2110. 	if (typ == P_NONE || P_SKILL(typ) <= P_BASIC) max_range = 4; 2111. 	else if (P_SKILL(typ) == P_SKILLED) max_range = 5; 2112. 	else max_range = 8; 2113. 	if (distu(cc.x, cc.y) > max_range) { 2114. 	   pline("Too far!"); 2115. 	   return (res); 2116. 	} else if (distu(cc.x, cc.y) < min_range) { 2117. 	   pline("Too close!"); 2118. 	   return (res); 2119. 	} else if (!cansee(cc.x, cc.y)) { 2120. 	   You(cant_see_spot); 2121. 	   return (res); 2122. 	} 2123.  2124. 	/* Attack the monster there */ 2125. 	if ((mtmp = m_at(cc.x, cc.y)) != (struct monst *)0) 2126. 	   (void) thitmonst(mtmp, obj); 2127. 	else 2128. 	   /* Now you know that nothing is there... */ 2129. 	    pline(nothing_happens); 2130. 	return (1); 2131. } 2132.  2133.  2134. STATIC_OVL int 2135. use_grapple (obj) 2136. 	struct obj *obj; 2137. { 2138. 	int res = 0, typ, max_range = 4; 2139. 	coord cc; 2140. 	struct monst *mtmp; 2141. 	struct obj *otmp; 2142. 2143.  2144. 	/* Are you allowed to use the hook? */ 2145. 	if (u.uswallow) { 2146. 	   pline(not_enough_room); 2147. 	   return (0); 2148. 	} 2149. 	if (obj != uwep) { 2150. 	   if (!wield_tool(obj)) return(0); 2151. 	   else res = 1; 2152. 	} 2153.  2154. 	/* Prompt for a location */ 2155. 	pline(where_to_hit); 2156. 	cc.x = u.ux; 2157. 	cc.y = u.uy; 2158. 	if (getpos(&cc, TRUE, "the spot to hit") < 0) 2159. 	   return 0;	/* user pressed ESC */ 2160. 2161. 	/* Calculate range */ 2162. 	typ = weapon_type(obj); 2163. 	if (typ == P_NONE || P_SKILL(typ) <= P_BASIC) max_range = 4; 2164. 	else if (P_SKILL(typ) == P_SKILLED) max_range = 5; 2165. 	else max_range = 8; 2166. 	if (distu(cc.x, cc.y) > max_range) { 2167. 		pline("Too far!"); 2168. 		return (res); 2169. 	} else if (!cansee(cc.x, cc.y)) { 2170. 		You(cant_see_spot); 2171. 		return (res); 2172. 	} 2173.  2174. 	/* What did you hit? */ 2175. 	switch (rn2(5)) 2176. 	{ 2177. 	case 0:	/* Trap */ 2178. 	   /* FIXME -- untrap needs to deal with non-adjacent traps */ 2179. 	   break; 2180. 	case 1:	/* Object */ 2181. 	   if ((otmp = level.objects[cc.x][cc.y]) !=  2182. 	    		(struct obj *)0) { 2183. 	   	You("snag an object from the %s!", surface(cc.x, cc.y)); 2184. 	   	(void) pickup_object(otmp, 1L, FALSE); 2185. 	   	/* If pickup fails, leave it alone */ 2186. 	   	newsym(cc.x, cc.y); 2187. 	   	return (1); 2188. 	   }  2189. 	    break; 2190. 	case 2:	/* Monster */ 2191. 	   if ((mtmp = m_at(cc.x, cc.y)) == (struct monst *)0) break; 2192. 	   if (verysmall(mtmp->data) && !rn2(4) &&  2193. 	    		enexto(&cc, u.ux, u.uy, (struct permonst *)0)) { 2194. 	   	You("pull in %s!", mon_nam(mtmp)); 2195. 	   	mtmp->mundetected = 0; 2196. 	   	rloc_to(mtmp, cc.x, cc.y); 2197. 	   	return (1); 2198. 	   } else if ((!bigmonst(mtmp->data) && !strongmonst(mtmp->data)) ||  2199. 		       rn2(4)) { 2200. 	   	(void) thitmonst(mtmp, obj); 2201. 	   	return (1); 2202. 	   }  2203. 	    /* FALL THROUGH */ 2204. 	case 3:	/* Surface */ 2205. 	   You("are yanked toward the %s!",  2206. 	    		surface(cc.x, cc.y)); 2207. 	   hurtle(sgn(cc.x-u.ux), sgn(cc.y-u.uy), 1, FALSE); 2208. 	   return (1); 2209. 	default:	/* Yourself (oops!) */ 2210. 	   if (P_SKILL(typ) <= P_BASIC) { 2211. 	   	You("hook yourself!"); 2212. 	   	losehp(rn1(10,10), "a grappling hook", KILLED_BY); 2213. 	   	return (1); 2214. 	   }  2215. 	    break; 2216. 	} 2217. 	pline(nothing_happens); 2218. 	return (1); 2219. } 2220.  2221.  2222. #define BY_OBJECT	((struct monst *)0) 2223. 2224. /* return 1 if the wand is broken, hence some time elapsed */ 2225. STATIC_OVL int 2226. do_break_wand(obj) 2227.    struct obj *obj; 2228. { 2229.     static const char nothing_else_happens[] = "But nothing else happens..."; 2230.    register int i, x, y;  2231. register struct monst *mon; 2232.    int dmg, damage; 2233.    boolean affects_objects; 2234.    char confirm[QBUFSZ], the_wand[BUFSZ]; 2235. 2236.     Strcpy(the_wand, yname(obj)); 2237.    Sprintf(confirm, "Are you really sure you want to break %s?", the_wand); 2238.    if (yn(confirm) == 'n' ) return 0; 2239. 2240.     if (nohands(youmonst.data)) { 2241. 	You_cant("break %s without hands!", the_wand); 2242. 	return 0; 2243.    } else if (ACURR(A_STR) < 10) { 2244. 	You("don't have the strength to break %s!", the_wand); 2245. 	return 0; 2246.    }  2247.     pline("Raising %s high above your %s, you break it in two!",  2248. 	  the_wand, body_part(HEAD)); 2249. 2250.     current_wand = obj;		/* destroy_item might reset this */ 2251.    freeinv(obj);		/* hide it from destroy_item instead... */ 2252.  2253.     if (obj->spe <= 0) { 2254. 	pline(nothing_else_happens); 2255. 	goto discard_broken_wand; 2256.    }  2257.     obj->ox = u.ux; 2258.    obj->oy = u.uy; 2259.    dmg = obj->spe * 4; 2260.    affects_objects = FALSE; 2261. 2262.     switch (obj->otyp) { 2263.    case WAN_WISHING: 2264.    case WAN_NOTHING: 2265.    case WAN_LOCKING: 2266.    case WAN_PROBING: 2267.    case WAN_ENLIGHTENMENT: 2268.    case WAN_OPENING: 2269.    case WAN_SECRET_DOOR_DETECTION: 2270. 	pline(nothing_else_happens); 2271. 	goto discard_broken_wand; 2272.    case WAN_DEATH: 2273.    case WAN_LIGHTNING: 2274. 	dmg *= 2; 2275.    case WAN_FIRE: 2276.    case WAN_COLD: 2277. 	dmg *= 2; 2278.    case WAN_MAGIC_MISSILE: 2279. 	explode(u.ux, u.uy, (obj->otyp - WAN_MAGIC_MISSILE), dmg, WAND_CLASS); 2280. 	makeknown(obj->otyp);	/* explode described the effect */ 2281. 	goto discard_broken_wand; 2282.    case WAN_STRIKING: 2283. 	/* we want this before the explosion instead of at the very end */ 2284. 	pline("A wall of force smashes down around you!"); 2285. 	dmg = d(1 + obj->spe,6);	/* normally 2d12 */ 2286.    case WAN_CANCELLATION: 2287.    case WAN_POLYMORPH: 2288.    case WAN_TELEPORTATION: 2289.    case WAN_UNDEAD_TURNING: 2290. 	affects_objects = TRUE; 2291. 	break; 2292.    default: 2293. 	break; 2294.    }  2295.  2296.     /* magical explosion and its visual effect occur before specific effects */ 2297.    explode(obj->ox, obj->oy, 0, rnd(dmg), WAND_CLASS); 2298. 2299.     /* this makes it hit us last, so that we can see the action first */ 2300.    for (i = 0; i <= 8; i++) { 2301. 	bhitpos.x = x = obj->ox + xdir[i]; 2302. 	bhitpos.y = y = obj->oy + ydir[i]; 2303. 	if (!isok(x,y)) continue; 2304. 2305. 	if (obj->otyp == WAN_DIGGING) { 2306. 	   if(dig_check(BY_OBJECT, FALSE, x, y)) 2307. 		digactualhole(x, y, BY_OBJECT, 2308. 			      (rn2(obj->spe) < 3 || !Can_dig_down(&u.uz)) ?  2309. 			       PIT : HOLE); 2310. 	   continue; 2311. 	} else if(obj->otyp == WAN_CREATE_MONSTER) { 2312. 	   (void) makemon((struct permonst *)0, x, y, NO_MM_FLAGS); 2313. 	   continue; 2314. 	} else { 2315. 	   if (x == u.ux && y == u.uy) { 2316. 		damage = zapyourself(obj, FALSE); 2317. 		if (damage) 2318. 		   losehp(damage,  2319. 			   self_pronoun("killed %sself by breaking a wand", 2320. 					"him"), 2321. 			   NO_KILLER_PREFIX); 2322. 		if (flags.botl) bot;		/* blindness */ 2323. 	   } else if ((mon = m_at(x, y)) != 0) { 2324. 		(void) bhitm(mon, obj); 2325. 	    /* if (flags.botl) bot; */ 2326. 	   }  2327. 	    if (affects_objects && level.objects[x][y]) { 2328. 		(void) bhitpile(obj, bhito, x, y); 2329. 		if (flags.botl) bot;		/* potion effects */ 2330. 	   }  2331. 	}  2332.     }  2333.  2334.     if (obj->otyp == WAN_LIGHT) 2335. 	litroom(TRUE, obj);	/* only needs to be done once */ 2336. 2337.  discard_broken_wand: 2338.    obj = current_wand;		/* [see dozap and destroy_item] */ 2339.    current_wand = 0; 2340.    if (obj) { 2341. 	/* extra charge for _use_ prior to destruction */ 2342. 	check_unpaid(obj); 2343. 	delobj(obj); 2344.    }  2345.     nomul(0); 2346.    return 1; 2347. } 2348.  2349. int 2350. doapply 2351. { 2352. 	register struct obj *obj; 2353. 	register int res = 1; 2354. 2355. 	if(check_capacity((char *)0)) return (0); 2356. 	obj = getobj(carrying(POT_OIL) ? tools_too : tools, "use or apply"); 2357. 	if(!obj) return 0; 2358. 2359. 	if (obj->oclass == WAND_CLASS) 2360. 	   return do_break_wand(obj); 2361. 2362. 	switch(obj->otyp){ 2363. 	case BLINDFOLD: 2364. 	case LENSES: 2365. 		if (obj == ublindf) { 2366. 		   if (!cursed(obj)) Blindf_off(obj); 2367. 		} else if (!ublindf) 2368. 		   Blindf_on(obj); 2369. 		else You("are already %s.", 2370. 			ublindf->otyp == TOWEL ?     "covered by a towel" :  2371. 			ublindf->otyp == BLINDFOLD ? "wearing a blindfold" :  2372. 						     "wearing lenses"); 2373. 		break; 2374. 	case BULLWHIP: 2375. 		res = use_whip(obj); 2376. 		break; 2377. 	case GRAPPLING_HOOK: 2378. 		res = use_grapple(obj); 2379. 		break; 2380. 	case LARGE_BOX: 2381. 	case CHEST: 2382. 	case ICE_BOX: 2383. 	case SACK: 2384. 	case BAG_OF_HOLDING: 2385. 	case OILSKIN_SACK: 2386. 		res = use_container(obj, 1); 2387. 		break; 2388. 	case BAG_OF_TRICKS: 2389. 		if(obj->spe > 0) { 2390. 			register int cnt = 1; 2391. 2392. 			check_unpaid(obj); 2393. 			obj->spe--; 2394. 			if(!rn2(23)) cnt += rn2(7) + 1; 2395. 			while(cnt--) 2396. 			  (void) makemon((struct permonst *) 0,  2397. 						u.ux, u.uy, NO_MM_FLAGS); 2398. 			makeknown(BAG_OF_TRICKS); 2399. 		} else 2400. 			pline(nothing_happens); 2401. 		break; 2402. 	case CAN_OF_GREASE: 2403. 		use_grease(obj); 2404. 		break; 2405. 	case LOCK_PICK: 2406. #ifdef TOURIST 2407. 	case CREDIT_CARD: 2408. #endif 2409. 	case SKELETON_KEY: 2410. 		(void) pick_lock(obj); 2411. 		break; 2412. 	case PICK_AXE: 2413. 	case DWARVISH_MATTOCK: 2414. 		res = use_pick_axe(obj); 2415. 		break; 2416. 	case TINNING_KIT: 2417. 		use_tinning_kit(obj); 2418. 		break; 2419. 	case LEASH: 2420. 		use_leash(obj); 2421. 		break; 2422. #ifdef STEED 2423. 	case SADDLE: 2424. 		res = use_saddle(obj); 2425. 		break; 2426. #endif 2427. 	case MAGIC_WHISTLE: 2428. 		use_magic_whistle(obj); 2429. 		break; 2430. 	case TIN_WHISTLE: 2431. 		use_whistle(obj); 2432. 		break; 2433. 	case STETHOSCOPE: 2434. 		res = use_stethoscope(obj); 2435. 		break; 2436. 	case MIRROR: 2437. 		res = use_mirror(obj); 2438. 		break; 2439. 	case BELL: 2440. 	case BELL_OF_OPENING: 2441. 		use_bell(obj); 2442. 		break; 2443. 	case CANDELABRUM_OF_INVOCATION: 2444. 		use_candelabrum(obj); 2445. 		break; 2446. 	case WAX_CANDLE: 2447. 	case TALLOW_CANDLE: 2448. 		use_candle(obj); 2449. 		break; 2450. 	case OIL_LAMP: 2451. 	case MAGIC_LAMP: 2452. 	case BRASS_LANTERN: 2453. 		use_lamp(obj); 2454. 		break; 2455. 	case POT_OIL: 2456. 		light_cocktail(obj); 2457. 		break; 2458. #ifdef TOURIST 2459. 	case EXPENSIVE_CAMERA: 2460. 		res = use_camera(obj); 2461. 		break; 2462. #endif 2463. 	case TOWEL: 2464. 		res = use_towel(obj); 2465. 		break; 2466. 	case CRYSTAL_BALL: 2467. 		use_crystal_ball(obj); 2468. 		break; 2469. 	case MAGIC_MARKER: 2470. 		res = dowrite(obj); 2471. 		break; 2472. 	case TIN_OPENER: 2473. 		if(!carrying(TIN)) { 2474. 			You("have no tin to open."); 2475. 			goto xit; 2476. 		} 2477. 		You("cannot open a tin without eating or discarding its contents."); 2478. 		if(flags.verbose) 2479. 			pline("In order to eat, use the 'e' command."); 2480. 		if(obj != uwep) 2481.    pline("Opening the tin will be much easier if you wield the tin opener."); 2482. 		goto xit; 2483. 2484. 	case FIGURINE: 2485. 		use_figurine(obj); 2486. 		break; 2487. 	case UNICORN_HORN: 2488. 		use_unicorn_horn(obj); 2489. 		break; 2490. 	case WOODEN_FLUTE: 2491. 	case MAGIC_FLUTE: 2492. 	case TOOLED_HORN: 2493. 	case FROST_HORN: 2494. 	case FIRE_HORN: 2495. 	case WOODEN_HARP: 2496. 	case MAGIC_HARP: 2497. 	case BUGLE: 2498. 	case LEATHER_DRUM: 2499. 	case DRUM_OF_EARTHQUAKE: 2500. 		res = do_play_instrument(obj); 2501. 		break; 2502. 	case HORN_OF_PLENTY:	/* not a musical instrument */ 2503. 		if (obj->spe > 0) { 2504. 		   struct obj *otmp; 2505. 		   const char *what; 2506. 2507. 		    check_unpaid(obj); 2508. 		   obj->spe--; 2509. 		   if (!rn2(13)) { 2510. 			otmp = mkobj(POTION_CLASS, FALSE); 2511. 			if (objects[otmp->otyp].oc_magic) do { 2512. 			   otmp->otyp = rnd_class(POT_BOOZE, POT_WATER); 2513. 			} while (otmp->otyp == POT_SICKNESS); 2514. 			what = "A potion"; 2515. 		   } else { 2516. 			otmp = mkobj(FOOD_CLASS, FALSE); 2517. 			if (otmp->otyp == FOOD_RATION && !rn2(7)) 2518. 			   otmp->otyp = LUMP_OF_ROYAL_JELLY; 2519. 			what = "Some food"; 2520. 		   }  2521. 		    pline("%s spills out.", what); 2522. 		   otmp->blessed = obj->blessed; 2523. 		   otmp->cursed = obj->cursed; 2524. 		   otmp->owt = weight(otmp); 2525. 		   otmp = hold_another_object(otmp,  2526. 					(u.uswallow || Is_airlevel(&u.uz) || 2527. 					 u.uinwater || Is_waterlevel(&u.uz)) ? 2528. 					       "Oops!  %s away from you!" :  2529. 					       "Oops!  %s to the floor!",  2530. 					       The(aobjnam(otmp, "slip")),  2531. 					       (const char *)0); 2532. 		   makeknown(HORN_OF_PLENTY); 2533. 		} else 2534. 		   pline(nothing_happens); 2535. 		break; 2536. 	case LAND_MINE: 2537. 	case BEARTRAP: 2538. 		use_trap(obj); 2539. 		break; 2540. 	default: 2541. 		/* Pole-weapons can strike at a distance */ 2542. 		if (is_pole(obj)) { 2543. 			res = use_pole(obj); 2544. 			break; 2545. 		} else if (is_pick(obj) /* || is_axe(obj) */) { 2546. 			res = use_pick_axe(obj); 2547. 			break; 2548. 		} 2549. 		pline("Sorry, I don't know how to use that."); 2550. 	xit: 2551. 		nomul(0); 2552. 		return 0; 2553. 	} 2554. 	nomul(0); 2555. 	return res; 2556. } 2557.  2558. #endif /* OVLB */ 2559. 2560. /*apply.c*/