Source:NetHack 3.4.0/wield.c

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

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

1.   /*	SCCS Id: @(#)wield.c	3.4	2001/12/23	*/ 2.   /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3.    /* NetHack may be freely redistributed. See license for details. */ 4.     5.    #include "hack.h"  6. 7.   /* KMH -- Differences between the three weapon slots. 8.    *  9.     * The main weapon (uwep): 10.   * 1.  Is filled by the (w)ield command. 11.   * 2.  Can be filled with any type of item. 12.   * 3.  May be carried in one or both hands. 13.   * 4.  Is used as the melee weapon and as the launcher for 14.   *     ammunition. 15.   * 5.  Only conveys intrinsics when it is a weapon, weapon-tool, 16.   *     or artifact. 17.   * 6.  Certain cursed items will weld to the hand and cannot be  18. *    unwielded or dropped. See erodeable_wep and will_weld 19.   *     below for the list of which items apply. 20.   *  21.    * The secondary weapon (uswapwep): 22.   * 1.  Is filled by the e(x)change command, which swaps this slot 23.   *     with the main weapon. If the "pushweapon" option is set, 24.   *     the (w)ield command will also store the old weapon in the 25.   *     secondary slot. 26.   * 2.  Can be field with anything that will fit in the main weapon 27.   *     slot; that is, any type of item. 28.   * 3.  Is usually NOT considered to be carried in the hands. 29.   *     That would force too many checks among the main weapon, 30.   *     second weapon, shield, gloves, and rings; and it would 31.   *     further be complicated by bimanual weapons. A special 32.   *     exception is made for two-weapon combat. 33.   * 4.  Is used as the second weapon for two-weapon combat, and as  34. *    a convenience to swap with the main weapon. 35.   * 5.  Never conveys intrinsics. 36.   * 6.  Cursed items never weld (see #3 for reasons), but they also 37.   *     prevent two-weapon combat. 38.   *  39.    * The quiver (uquiver): 40.   * 1.  Is filled by the (Q)uiver command. 41.   * 2.  Can be filled with any type of item. 42.   * 3.  Is considered to be carried in a special part of the pack. 43.   * 4.  Is used as the item to throw with the (f)ire command. 44.   *     This is a convenience over the normal (t)hrow command. 45.   * 5.  Never conveys intrinsics. 46.   * 6.  Cursed items never weld; their effect is handled by the normal 47.   *     throwing code. 48.   *  49.    * No item may be in more than one of these slots. 50.   */  51.    52.    53.   STATIC_DCL int FDECL(ready_weapon, (struct obj *)); 54.   55.   /* elven weapons vibrate warningly when enchanted beyond a limit */ 56.  #define is_elven_weapon(optr)	((optr)->otyp == ELVEN_ARROW\  57.   				|| (optr)->otyp == ELVEN_SPEAR\  58.   				|| (optr)->otyp == ELVEN_DAGGER\  59.   				|| (optr)->otyp == ELVEN_SHORT_SWORD\  60.   				|| (optr)->otyp == ELVEN_BROADSWORD\  61.   				|| (optr)->otyp == ELVEN_BOW) 62.   63.   /* used by will_weld */ 64.  /* probably should be renamed */ 65.  #define erodeable_wep(optr)	((optr)->oclass == WEAPON_CLASS \  66.   				|| is_weptool(optr) \  67.   				|| (optr)->otyp == HEAVY_IRON_BALL \  68.   				|| (optr)->otyp == IRON_CHAIN) 69.   70.   /* used by welded, and also while wielding */ 71.  #define will_weld(optr)		((optr)->cursed \  72.   				&& (erodeable_wep(optr) \ 73.  				   || (optr)->otyp == TIN_OPENER)) 74.   75.    76.   /*** Functions that place a given item in a slot ***/ 77.  /* Proper usage includes: 78.   * 1.  Initializing the slot during character generation or a  79. *    restore. 80.   * 2.  Setting the slot due to a player's actions. 81.   * 3.  If one of the objects in the slot are split off, these 82.   *     functions can be used to put the remainder back in the slot. 83.   * 4.  Putting an item that was thrown and returned back into the slot. 84.   * 5.  Emptying the slot, by passing a null object. NEVER pass 85.   *     zeroobj! 86.   *  87.    * If the item is being moved from another slot, it is the caller's  88. * responsibility to handle that. It's also the caller's responsibility 89.   * to print the appropriate messages. 90.   */  91.   void 92.  setuwep(obj) 93.  register struct obj *obj; 94.  {  95.   	struct obj *olduwep = uwep; 96.   97.   	if (obj == uwep) return; /* necessary to not set unweapon */ 98.  	/* This message isn't printed in the caller because it happens 99.  	 * *whenever* Sunsword is unwielded, from whatever cause. 100. 	 */  101.  	setworn(obj, W_WEP); 102. 	if (uwep == obj && artifact_light(olduwep) && olduwep->lamplit) { 103. 	    end_burn(olduwep, FALSE); 104. 	    if (!Blind) pline("%s glowing.", Tobjnam(olduwep, "stop")); 105. 	}  106.  	/* Note: Explicitly wielding a pick-axe will not give a "bashing" 107. 	 * message. Wielding one via 'a'pplying it will. 108. 	 * 3.2.2:  Wielding arbitrary objects will give bashing message too. 109. 	 */  110.  	if (obj) { 111. 		unweapon = (obj->oclass == WEAPON_CLASS) ? 112. 				is_launcher(obj) || is_ammo(obj) || 113. 				is_missile(obj) || (is_pole(obj)  114.  #ifdef STEED  115.  				&& !u.usteed  116.  #endif  117.  				) : !is_weptool(obj); 118. 	} else 119. 		unweapon = TRUE;	/* for "bare hands" message */ 120. 	update_inventory; 121. }  122.   123.  STATIC_OVL int 124. ready_weapon(wep) 125. struct obj *wep; 126. {  127.  	/* Separated function so swapping works easily */ 128. 	int res = 0; 129.  130.  	if (!wep) { 131. 	    /* No weapon */ 132. 	    if (uwep) { 133. 		You("are empty %s.", body_part(HANDED)); 134. 		setuwep((struct obj *) 0); 135. 		res++; 136. 	    } else 137. 		You("are already empty %s.", body_part(HANDED)); 138. 	} else if (!uarmg && !Stone_resistance && wep->otyp == CORPSE  139.  				&& touch_petrifies(&mons[wep->corpsenm])) { 140. 	    /* Prevent wielding cockatrice when not wearing gloves --KAA */ 141. 	    char kbuf[BUFSZ]; 142.  143.  	    You("wield the %s corpse in your bare %s.",  144.  		mons[wep->corpsenm].mname, makeplural(body_part(HAND))); 145. 	    Sprintf(kbuf, "%s corpse", an(mons[wep->corpsenm].mname)); 146. 	    instapetrify(kbuf); 147. 	} else if (uarms && bimanual(wep)) 148. 	    You("cannot wield a two-handed %s while wearing a shield.",  149.  		is_sword(wep) ? "sword" :  150.  		    wep->otyp == BATTLE_AXE ? "axe" : "weapon"); 151. 	else if (wep->oartifact && !touch_artifact(wep, &youmonst)) { 152. 	    res++;	/* takes a turn even though it doesn't get wielded */ 153. 	} else { 154. 	    /* Weapon WILL be wielded after this point */ 155. 	    res++; 156. 	    if (will_weld(wep)) { 157. 		const char *tmp = xname(wep), *thestr = "The "; 158. 		if (strncmp(tmp, thestr, 4) && !strncmp(The(tmp),thestr,4)) 159. 		    tmp = thestr; 160. 		else tmp = ""; 161. 		pline("%s%s %s to your %s!", tmp, aobjnam(wep, "weld"),  162.  			(wep->quan == 1L) ? "itself" : "themselves", /* a3 */  163.  			bimanual(wep) ?  164.  				(const char *)makeplural(body_part(HAND))  165.  				: body_part(HAND)); 166. 		wep->bknown = TRUE; 167. 	    } else { 168. 		/* The message must be printed before setuwep (since  169.  		 * you might die and be revived from changing weapons), 170. 		 * and the message must be before the death message and 171. 		 * Lifesaved rewielding. Yet we want the message to 172. * say "weapon in hand", thus this kludge. 173. 		 */  174.  		long dummy = wep->owornmask; 175. 		wep->owornmask |= W_WEP; 176. 		prinv((char *)0, wep, 0L); 177. 		wep->owornmask = dummy; 178. 	    }  179.  	    setuwep(wep); 180.  181.  	    /* KMH -- Talking artifacts are finally implemented */ 182. 	    arti_speak(wep); 183.  184.  	    if (artifact_light(wep) && !wep->lamplit) { 185. 		begin_burn(wep, FALSE); 186. 		if (!Blind) 187. 		    pline("%s to glow brilliantly!", Tobjnam(wep, "begin")); 188. 	    }  189.   190.  #if 0 191. 	    /* we'll get back to this someday, but it's not balanced yet */ 192. 	    if (Race_if(PM_ELF) && !wep->oartifact &&  193.  			    objects[wep->otyp].oc_material == IRON) { 194. 		/* Elves are averse to wielding cold iron */ 195. 		You("have an uneasy feeling about wielding cold iron."); 196. 		change_luck(-1); 197. 	    }  198.  #endif 199.  200.  	    if (wep->unpaid) { 201. 		struct monst *this_shkp; 202.  203.  		if ((this_shkp = shop_keeper(inside_shop(u.ux, u.uy))) !=  204.  		    (struct monst *)0) { 205. 		    pline("%s says \"You be careful with my %s!\"",  206.  			  shkname(this_shkp),  207.  			  xname(wep)); 208. 		}  209.  	    }  210.  	}  211.  	return(res); 212. }  213.   214.  void 215. setuqwep(obj) 216. register struct obj *obj; 217. {  218.  	setworn(obj, W_QUIVER); 219. 	update_inventory; 220. }  221.   222.  void 223. setuswapwep(obj) 224. register struct obj *obj; 225. {  226.  	setworn(obj, W_SWAPWEP); 227. 	update_inventory; 228. }  229.   230.   231.  /*** Commands to change particular slot(s) ***/ 232.  233.  static NEARDATA const char wield_objs[] = 234. 	{ ALL_CLASSES, ALLOW_NONE, WEAPON_CLASS, TOOL_CLASS, 0 }; 235. static NEARDATA const char ready_objs[] = 236. 	{ ALL_CLASSES, ALLOW_NONE, WEAPON_CLASS, 0 }; 237. static NEARDATA const char bullets[] =	/* (note: different from dothrow.c) */ 238. 	{ ALL_CLASSES, ALLOW_NONE, GEM_CLASS, WEAPON_CLASS, 0 }; 239.  240.  int 241. dowield 242. {  243.  	register struct obj *wep, *oldwep; 244. 	int result; 245.  246.  	/* May we attempt this? */ 247.  	multi = 0; 248. 	if (cantwield(youmonst.data)) { 249. 		pline("Don't be ridiculous!"); 250. 		return(0); 251. 	}  252.   253.  	/* Prompt for a new weapon */ 254. 	if (!(wep = getobj(wield_objs, "wield"))) 255. 		/* Cancelled */ 256. 		return (0); 257. 	else if (wep == uwep) { 258. 	    You("are already wielding that!"); 259. 	    if (is_weptool(wep)) unweapon = FALSE;	/* [see setuwep] */ 260. 		return (0); 261. 	} else if (welded(uwep)) { 262. 		weldmsg(uwep); 263. 		return (0); 264. 	}  265.   266.  	/* Handle no object, or object in other slot */ 267. 	if (wep == &zeroobj) 268. 		wep = (struct obj *) 0; 269. 	else if (wep == uswapwep) 270. 		return (doswapweapon); 271. 	else if (wep == uquiver) 272. 		setuqwep((struct obj *) 0); 273. 	else if (wep->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL 274. #ifdef STEED 275. 			| W_SADDLE 276. #endif 277. 			)) {  278.  		You("cannot wield that!"); 279. 		return (0); 280. 	}  281.   282.  	/* Set your new primary weapon */ 283. 	oldwep = uwep; 284. 	result = ready_weapon(wep); 285. 	if (flags.pushweapon && oldwep && uwep != oldwep) 286. 		setuswapwep(oldwep); 287. 	untwoweapon; 288.  289.  	return (result); 290. }  291.   292.  int 293. doswapweapon 294. {  295.  	register struct obj *oldwep, *oldswap; 296. 	int result = 0; 297.  298.   299.  	/* May we attempt this? */ 300.  	multi = 0; 301. 	if (cantwield(youmonst.data)) { 302. 		pline("Don't be ridiculous!"); 303. 		return(0); 304. 	}  305.  	if (welded(uwep)) { 306. 		weldmsg(uwep); 307. 		return (0); 308. 	}  309.   310.  	/* Unwield your current secondary weapon */ 311. 	oldwep = uwep; 312. 	oldswap = uswapwep; 313. 	setuswapwep((struct obj *) 0); 314.  315.  	/* Set your new primary weapon */ 316. 	result = ready_weapon(oldswap); 317.  318.  	/* Set your new secondary weapon */ 319. 	if (uwep == oldwep) 320. 		/* Wield failed for some reason */ 321. 		setuswapwep(oldswap); 322. 	else { 323. 		setuswapwep(oldwep); 324. 		if (uswapwep) 325. 			prinv((char *)0, uswapwep, 0L); 326. 		else 327. 			You("have no secondary weapon readied."); 328. 	}  329.   330.  	if (u.twoweap && !can_twoweapon) 331. 		untwoweapon; 332.  333.  	return (result); 334. }  335.   336.  int 337. dowieldquiver 338. {  339.  	register struct obj *newquiver; 340.  341.   342.  	/* Since the quiver isn't in your hands, don't check cantwield, */ 343. 	/* will_weld, touch_petrifies, etc. */ 344. 	multi = 0; 345.  346.  	/* Because 'Q' used to be quit... */ 347.  	if (!flags.suppress_alert || flags.suppress_alert < FEATURE_NOTICE_VER(3,3,0)) 348. 		pline("Note: Please use #quit if you wish to exit the game."); 349.  350.  	/* Prompt for a new quiver */ 351. 	if (!(newquiver = getobj(uslinging ? bullets : ready_objs, "ready"))) 352. 		/* Cancelled */ 353. 		return (0); 354.  355.  	/* Handle no object, or object in other slot */ 356. 	/* Any type is okay, since we give no intrinsics anyways */ 357. 	if (newquiver == &zeroobj) { 358. 		/* Explicitly nothing */ 359. 		if (uquiver) { 360. 			You("now have no ammunition readied."); 361. 			setuqwep(newquiver = (struct obj *) 0); 362. 		} else { 363. 			You("already have no ammunition readied!"); 364. 			return(0); 365. 		}  366.  	} else if (newquiver == uquiver) { 367. 		pline("That ammunition is already readied!"); 368. 		return(0); 369. 	} else if (newquiver == uwep) { 370. 		/* Prevent accidentally readying the main weapon */ 371. 		pline("%s already being used as a weapon!",  372.  		      !is_plural(uwep) ? "That is" : "They are"); 373. 		return(0); 374. 	} else if (newquiver->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL 375. #ifdef STEED 376. 			| W_SADDLE 377. #endif 378. 			)) {  379.  		You("cannot ready that!"); 380. 		return (0); 381. 	} else { 382. 		long dummy; 383.  384.   385.  		/* Check if it's the secondary weapon */ 386. 		if (newquiver == uswapwep) { 387. 			setuswapwep((struct obj *) 0); 388. 			untwoweapon; 389. 		}  390.   391.  		/* Okay to put in quiver; print it */ 392. 		dummy = newquiver->owornmask; 393. 		newquiver->owornmask |= W_QUIVER; 394. 		prinv((char *)0, newquiver, 0L); 395. 		newquiver->owornmask = dummy; 396. 	}  397.   398.  	/* Finally, place it in the quiver */ 399. 	setuqwep(newquiver); 400. 	/* Take no time since this is a convenience slot */ 401. 	return (0); 402. }  403.   404.  int 405. can_twoweapon 406. {  407.  	struct obj *otmp; 408.  409.  #define NOT_WEAPON(obj) (!is_weptool(obj) && obj->oclass != WEAPON_CLASS) 410. 	if (!could_twoweap(youmonst.data)) 411. 		You_cant("use two weapons in your current form."); 412. 	else if (!uwep || !uswapwep) 413. 		Your("%s%s%s empty.", uwep ? "left " : uswapwep ? "right " : "",  414.  			body_part(HAND), (!uwep && !uswapwep) ? "s are" : " is"); 415. 	else if (NOT_WEAPON(uwep) || NOT_WEAPON(uswapwep)) { 416. 		otmp = NOT_WEAPON(uwep) ? uwep : uswapwep; 417. 		pline("%s %s.", Yname2(otmp),  418.  		    is_plural(otmp) ? "aren't weapons" : "isn't a weapon"); 419. 	} else if (bimanual(uwep) || bimanual(uswapwep)) { 420. 		otmp = bimanual(uwep) ? uwep : uswapwep; 421. 		pline("%s isn't one-handed.", Yname2(otmp)); 422. 	} else if (uarms) 423. 		You_cant("use two weapons while wearing a shield."); 424. 	else if (uswapwep->oartifact) 425. 		pline("%s %s being held second to another weapon!",  426.  			Yname2(uswapwep), otense(uswapwep, "resist")); 427. 	else if (!uarmg && !Stone_resistance && (uswapwep->otyp == CORPSE && 428. 		    touch_petrifies(&mons[uswapwep->corpsenm]))) { 429. 		char kbuf[BUFSZ]; 430.  431.  		You("wield the %s corpse with your bare %s.",  432.  		    mons[uswapwep->corpsenm].mname, body_part(HAND)); 433. 		Sprintf(kbuf, "%s corpse", an(mons[uswapwep->corpsenm].mname)); 434. 		instapetrify(kbuf); 435. 	} else if (Glib || uswapwep->cursed) { 436. 		char str[BUFSZ]; 437. 		struct obj *obj = uswapwep; 438.  439.  		/* Avoid trashing makeplural's static buffer */ 440. 		Strcpy(str, makeplural(body_part(HAND))); 441. 		Your("%s from your %s!",  aobjnam(obj, "slip"), str); 442. 		if (!Glib) 443. 			obj->bknown = TRUE; 444. 		dropx(obj); 445. 	} else 446. 		return (TRUE); 447. 	return (FALSE); 448. }  449.   450.  int 451. dotwoweapon 452. {  453.  	/* You can always toggle it off */ 454. 	if (u.twoweap) { 455. 		You("switch to your primary weapon."); 456. 		u.twoweap = 0; 457. 		update_inventory; 458. 		return (0); 459. 	}  460.   461.  	/* May we use two weapons? */ 462.  	if (can_twoweapon) { 463. 		/* Success! */ 464.  		You("begin two-weapon combat."); 465. 		u.twoweap = 1; 466. 		update_inventory; 467. 		return (rnd(20) > ACURR(A_DEX)); 468. 	}  469.  	return (0); 470. }  471.   472.  /*** Functions to empty a given slot ***/ 473. /* These should be used only when the item can't be put back in  474. * the slot by life saving. Proper usage includes: 475.  * 1.  The item has been eaten, stolen, burned away, or rotted away. 476.  * 2.  Making an item disappear for a bones pile. 477.  */  478.  void 479. uwepgone 480. {  481.  	if (uwep) { 482. 		if (artifact_light(uwep) && uwep->lamplit) { 483. 		    end_burn(uwep, FALSE); 484. 		    if (!Blind) pline("%s glowing.", Tobjnam(uwep, "stop")); 485. 		}  486.  		setworn((struct obj *)0, W_WEP); 487. 		unweapon = TRUE; 488. 		update_inventory; 489. 	}  490.  }  491.   492.  void 493. uswapwepgone 494. {  495.  	if (uswapwep) { 496. 		setworn((struct obj *)0, W_SWAPWEP); 497. 		update_inventory; 498. 	}  499.  }  500.   501.  void 502. uqwepgone 503. {  504.  	if (uquiver) { 505. 		setworn((struct obj *)0, W_QUIVER); 506. 		update_inventory; 507. 	}  508.  }  509.   510.  void 511. untwoweapon 512. {  513.  	if (u.twoweap) { 514. 		You("can no longer use two weapons at once."); 515. 		u.twoweap = FALSE; 516. 		update_inventory; 517. 	}  518.  	return; 519. }  520.   521.  /* Maybe rust object, or corrode it if acid damage is called for */ 522. void 523. erode_obj(target, acid_dmg, fade_scrolls) 524. struct obj *target;		/* object (e.g. weapon or armor) to erode */ 525. boolean acid_dmg; 526. boolean fade_scrolls; 527. {  528.  	int erosion; 529. 	struct monst *victim; 530. 	boolean vismon; 531. 	boolean visobj; 532.  533.  	if (!target) 534. 	    return; 535. 	victim = carried(target) ? &youmonst : 536. 	    mcarried(target) ? target->ocarry : (struct monst *)0; 537. 	vismon = victim && (victim != &youmonst) && canseemon(victim); 538. 	visobj = !victim && cansee(bhitpos.x, bhitpos.y); /* assume thrown */ 539.  540.  	erosion = acid_dmg ? target->oeroded2 : target->oeroded; 541.  542.  	if (target->greased) { 543. 	    grease_protect(target,(char *)0,victim); 544. 	} else if (target->oclass == SCROLL_CLASS) { 545. 	    if(fade_scrolls && target->otyp != SCR_BLANK_PAPER  546.  #ifdef MAIL  547.  	    && target->otyp != SCR_MAIL  548.  #endif  549.  					) 550. 	    {  551.  		if (!Blind) { 552. 		    if (victim == &youmonst) 553. 			Your("%s.", aobjnam(target, "fade")); 554. 		    else if (vismon) 555. 			pline("%s's %s.", Monnam(victim),  556.  			      aobjnam(target, "fade")); 557. 		    else if (visobj) 558. 			pline_The("%s.", aobjnam(target, "fade")); 559. 		}  560.  		target->otyp = SCR_BLANK_PAPER; 561. 		target->spe = 0; 562. 	    }  563.  	} else if (target->oerodeproof ||  564.  		(acid_dmg ? !is_corrodeable(target) : !is_rustprone(target))) { 565. 	    if (flags.verbose || !(target->oerodeproof && target->rknown)) { 566. 		if (victim == &youmonst) 567. 		    Your("%s not affected.", aobjnam(target, "are")); 568. 		else if (vismon) 569. 		    pline("%s's %s not affected.", Monnam(victim),  570.  			aobjnam(target, "are")); 571. 		/* no message if not carried */ 572. 	    }  573.  	    if (target->oerodeproof) target->rknown = TRUE; 574. 	} else if (erosion < MAX_ERODE) { 575. 	    if (victim == &youmonst) 576. 		Your("%s%s!", aobjnam(target, acid_dmg ? "corrode" : "rust"), 577.  		    erosion+1 == MAX_ERODE ? " completely" :  578.  		    erosion ? " further" : ""); 579. 	    else if (vismon) 580. 		pline("%s's %s%s!", Monnam(victim),  581.  		    aobjnam(target, acid_dmg ? "corrode" : "rust"), 582.  		    erosion+1 == MAX_ERODE ? " completely" :  583.  		    erosion ? " further" : ""); 584. 	    else if (visobj) 585. 		pline_The("%s%s!",  586.  		    aobjnam(target, acid_dmg ? "corrode" : "rust"), 587.  		    erosion+1 == MAX_ERODE ? " completely" :  588.  		    erosion ? " further" : ""); 589. 	    if (acid_dmg) 590. 		target->oeroded2++; 591. 	    else 592. 		target->oeroded++; 593. 	} else { 594. 	    if (flags.verbose) { 595. 		if (victim == &youmonst) 596. 		    Your("%s completely %s.",  597.  			aobjnam(target, Blind ? "feel" : "look"), 598.  			acid_dmg ? "corroded" : "rusty"); 599. 		else if (vismon) 600. 		    pline("%s's %s completely %s.", Monnam(victim),  601.  			aobjnam(target, "look"),  602.  			acid_dmg ? "corroded" : "rusty"); 603. 		else if (visobj) 604. 		    pline_The("%s completely %s.",  605.  			aobjnam(target, "look"),  606.  			acid_dmg ? "corroded" : "rusty"); 607. 	    }  608.  	}  609.  }  610.   611.  int 612. chwepon(otmp, amount) 613. register struct obj *otmp; 614. register int amount; 615. {  616.  	register const char *color = hcolor((amount < 0) ? Black : blue); 617. 	register const char *xtime; 618.  619.  	if(!uwep || (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))) { 620. 		char buf[BUFSZ]; 621.  622.  		Sprintf(buf, "Your %s %s.", makeplural(body_part(HAND)),  623.  			(amount >= 0) ? "twitch" : "itch"); 624. 		strange_feeling(otmp, buf); 625. 		exercise(A_DEX, (boolean) (amount >= 0)); 626. 		return(0); 627. 	}  628.   629.  	if(uwep->otyp == WORM_TOOTH && amount >= 0) { 630. 		uwep->otyp = CRYSKNIFE; 631. 		uwep->oerodeproof = 0; 632. 		Your("weapon seems sharper now."); 633. 		uwep->cursed = 0; 634. 		return(1); 635. 	}  636.   637.  	if(uwep->otyp == CRYSKNIFE && amount < 0) { 638. 		uwep->otyp = WORM_TOOTH; 639. 		uwep->oerodeproof = 0; 640. 		Your("weapon seems duller now."); 641. 		return(1); 642. 	}  643.   644.  	if (amount < 0 && uwep->oartifact && restrict_name(uwep, ONAME(uwep))) { 645. 	    if (!Blind) 646. 		Your("%s %s.", aobjnam(uwep, "faintly glow"), color); 647. 	    return(1); 648. 	}  649.  	/* there is a (soft) upper and lower limit to uwep->spe */ 650. 	if(((uwep->spe > 5 && amount >= 0) || (uwep->spe < -5 && amount < 0))  651.  								&& rn2(3)) { 652. 	    if (!Blind) 653. 	    Your("%s %s for a while and then %s.",  654.  		 aobjnam(uwep, "violently glow"), color,  655.  		 otense(uwep, "evaporate")); 656. 	    else 657. 		Your("%s.", aobjnam(uwep, "evaporate")); 658.  659.  	    while(uwep)		/* let all of them disappear */ 660. 				/* note: uwep->quan = 1 is nogood if unpaid */ 661. 		useup(uwep); 662. 	    return(1); 663. 	}  664.  	if (!Blind) { 665. 	    xtime = (amount*amount == 1) ? "moment" : "while"; 666. 	    Your("%s %s for a %s.",  667.  		 aobjnam(uwep, amount == 0 ? "violently glow" : "glow"), 668.  		 color, xtime); 669. 	}  670.  	uwep->spe += amount; 671. 	if(amount > 0) uwep->cursed = 0; 672.  673.  	/*  674.  	 * Enchantment, which normally improves a weapon, has an  675. * addition adverse reaction on Magicbane whose effects are 676. 	 * spe dependent. Give an obscure clue here. 677. 	 */  678.  	if (uwep->oartifact == ART_MAGICBANE && uwep->spe >= 0) { 679. 		Your("right %s %sches!",  680.  			body_part(HAND),  681.  			(((amount > 1) && (uwep->spe > 1)) ? "flin" : "it")); 682. 	}  683.   684.  	/* an elven magic clue, cookie@keebler */ 685. 	if ((uwep->spe > 5)  686.  		&& (is_elven_weapon(uwep) || uwep->oartifact || !rn2(7))) 687. 	    Your("%s unexpectedly.",  688.  		aobjnam(uwep, "suddenly vibrate")); 689.  690.  	return(1); 691. }  692.   693.  int 694. welded(obj) 695. register struct obj *obj; 696. {  697.  	if (obj && obj == uwep && will_weld(obj)) { 698. 		obj->bknown = TRUE; 699. 		return 1; 700. 	}  701.  	return 0; 702. }  703.   704.  void 705. weldmsg(obj) 706. register struct obj *obj; 707. {  708.  	long savewornmask; 709.  710.  	savewornmask = obj->owornmask; 711. 	Your("%s %s welded to your %s!",  712.  		xname(obj), otense(obj, "are"),  713.  		bimanual(obj) ? (const char *)makeplural(body_part(HAND))  714.  				: body_part(HAND)); 715. 	obj->owornmask = savewornmask; 716. }  717.   718.  /*wield.c*/