Source:NetHack 3.4.3/src/apply.c

From NetHackWiki
(Redirected from Source:Ref/doapply)
Jump to: navigation, search

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

Top of file

  1. /*	SCCS Id: @(#)apply.c	3.4	2003/11/18	*/
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1. #include "hack.h"
  2. #include "edog.h"
  3.  
  4. #ifdef OVLB
  5.  
  6. static const char tools[] = { TOOL_CLASS, WEAPON_CLASS, WAND_CLASS, 0 };
  7. static const char tools_too[] = { ALL_CLASSES, TOOL_CLASS, POTION_CLASS,
  8. 				  WEAPON_CLASS, WAND_CLASS, GEM_CLASS, 0 };
  9.  
  10. #ifdef TOURIST
  11. STATIC_DCL int FDECL(use_camera, (struct obj *));
  12. #endif
  13. STATIC_DCL int FDECL(use_towel, (struct obj *));
  14. STATIC_DCL boolean FDECL(its_dead, (int,int,int *));
  15. STATIC_DCL int FDECL(use_stethoscope, (struct obj *));
  16. STATIC_DCL void FDECL(use_whistle, (struct obj *));
  17. STATIC_DCL void FDECL(use_magic_whistle, (struct obj *));
  18. STATIC_DCL void FDECL(use_leash, (struct obj *));
  19. STATIC_DCL int FDECL(use_mirror, (struct obj *));
  20. STATIC_DCL void FDECL(use_bell, (struct obj **));
  21. STATIC_DCL void FDECL(use_candelabrum, (struct obj *));
  22. STATIC_DCL void FDECL(use_candle, (struct obj **));
  23. STATIC_DCL void FDECL(use_lamp, (struct obj *));
  24. STATIC_DCL void FDECL(light_cocktail, (struct obj *));
  25. STATIC_DCL void FDECL(use_tinning_kit, (struct obj *));
  26. STATIC_DCL void FDECL(use_figurine, (struct obj **));
  27. STATIC_DCL void FDECL(use_grease, (struct obj *));
  28. STATIC_DCL void FDECL(use_trap, (struct obj *));
  29. STATIC_DCL void FDECL(use_stone, (struct obj *));
  30. STATIC_PTR int NDECL(set_trap);		/* occupation callback */
  31. STATIC_DCL int FDECL(use_whip, (struct obj *));
  32. STATIC_DCL int FDECL(use_pole, (struct obj *));
  33. STATIC_DCL int FDECL(use_cream_pie, (struct obj *));
  34. STATIC_DCL int FDECL(use_grapple, (struct obj *));
  35. STATIC_DCL int FDECL(do_break_wand, (struct obj *));
  36. STATIC_DCL boolean FDECL(figurine_location_checks,
  37. 				(struct obj *, coord *, BOOLEAN_P));
  38. STATIC_DCL boolean NDECL(uhave_graystone);
  39. STATIC_DCL void FDECL(add_class, (char *, CHAR_P));
  40.  
  41. #ifdef	AMIGA
  42. void FDECL( amii_speaker, ( struct obj *, char *, int ) );
  43. #endif

use_camera

  1. static const char no_elbow_room[] = "don't have enough elbow-room to maneuver.";
  2.  
  3. #ifdef TOURIST
  4. STATIC_OVL int
  5. use_camera(obj)
  6. 	struct obj *obj;
  7. {
  8. 	register struct monst *mtmp;
  9.  
  10. 	if(Underwater) {
  11. 		pline("Using your camera underwater would void the warranty.");
  12. 		return(0);
  13. 	}
  14. 	if(!getdir((char *)0)) return(0);
  15.  
  16. 	if (obj->spe <= 0) {
  17. 		pline(nothing_happens);
  18. 		return (1);
  19. 	}
  20. 	consume_obj_charge(obj, TRUE);
  21.  
  22. 	if (obj->cursed && !rn2(2)) {
  23. 		(void) zapyourself(obj, TRUE);
  24. 	} else if (u.uswallow) {
  25. 		You("take a picture of %s %s.", s_suffix(mon_nam(u.ustuck)),
  26. 		    mbodypart(u.ustuck, STOMACH));
  27. 	} else if (u.dz) {
  28. 		You("take a picture of the %s.",
  29. 			(u.dz > 0) ? surface(u.ux,u.uy) : ceiling(u.ux,u.uy));
  30. 	} else if (!u.dx && !u.dy) {
  31. 		(void) zapyourself(obj, TRUE);
  32. 	} else if ((mtmp = bhit(u.dx, u.dy, COLNO, FLASHED_LIGHT,
  33. 				(int FDECL((*),(MONST_P,OBJ_P)))0,
  34. 				(int FDECL((*),(OBJ_P,OBJ_P)))0,
  35. 				obj)) != 0) {
  36. 		obj->ox = u.ux,  obj->oy = u.uy;
  37. 		(void) flash_hits_mon(mtmp, obj);
  38. 	}
  39. 	return 1;
  40. }
  41. #endif

use_towel

  1. STATIC_OVL int
  2. use_towel(obj)
  3. 	struct obj *obj;
  4. {
  5. 	if(!freehand()) {
  6. 		You("have no free %s!", body_part(HAND));
  7. 		return 0;
  8. 	} else if (obj->owornmask) {
  9. 		You("cannot use it while you're wearing it!");
  10. 		return 0;
  11. 	} else if (obj->cursed) {
  12. 		long old;
  13. 		switch (rn2(3)) {
  14. 		case 2:
  15. 		    old = Glib;
  16. 		    Glib += rn1(10, 3);
  17. 		    Your("%s %s!", makeplural(body_part(HAND)),
  18. 			(old ? "are filthier than ever" : "get slimy"));
  19. 		    return 1;
  20. 		case 1:
  21. 		    if (!ublindf) {
  22. 			old = u.ucreamed;
  23. 			u.ucreamed += rn1(10, 3);
  24. 			pline("Yecch! Your %s %s gunk on it!", body_part(FACE),
  25. 			      (old ? "has more" : "now has"));
  26. 			make_blinded(Blinded + (long)u.ucreamed - old, TRUE);
  27. 		    } else {
  28. 			const char *what = (ublindf->otyp == LENSES) ?
  29. 					    "lenses" : "blindfold";
  30. 			if (ublindf->cursed) {
  31. 			    You("push your %s %s.", what,
  32. 				rn2(2) ? "cock-eyed" : "crooked");
  33. 			} else {
  34. 			    struct obj *saved_ublindf = ublindf;
  35. 			    You("push your %s off.", what);
  36. 			    Blindf_off(ublindf);
  37. 			    dropx(saved_ublindf);
  38. 			}
  39. 		    }
  40. 		    return 1;
  41. 		case 0:
  42. 		    break;
  43. 		}
  44. 	}
  45.  
  46. 	if (Glib) {
  47. 		Glib = 0;
  48. 		You("wipe off your %s.", makeplural(body_part(HAND)));
  49. 		return 1;
  50. 	} else if(u.ucreamed) {
  51. 		Blinded -= u.ucreamed;
  52. 		u.ucreamed = 0;
  53.  
  54. 		if (!Blinded) {
  55. 			pline("You've got the glop off.");
  56. 			Blinded = 1;
  57. 			make_blinded(0L,TRUE);
  58. 		} else {
  59. 			Your("%s feels clean now.", body_part(FACE));
  60. 		}
  61. 		return 1;
  62. 	}
  63.  
  64. 	Your("%s and %s are already clean.",
  65. 		body_part(FACE), makeplural(body_part(HAND)));
  66.  
  67. 	return 0;
  68. }

its_dead

  1. /* maybe give a stethoscope message based on floor objects */
  2. STATIC_OVL boolean
  3. its_dead(rx, ry, resp)
  4. int rx, ry, *resp;
  5. {
  6. 	struct obj *otmp;
  7. 	struct trap *ttmp;
  8.  
  9. 	if (!can_reach_floor()) return FALSE;
  10.  
  11. 	/* additional stethoscope messages from jyoung@apanix.apana.org.au */
  12. 	if (Hallucination && sobj_at(CORPSE, rx, ry)) {
  13. 	    /* (a corpse doesn't retain the monster's sex,
  14. 	       so we're forced to use generic pronoun here) */
  15. 	    You_hear("a voice say, \"It's dead, Jim.\"");
  16. 	    *resp = 1;
  17. 	    return TRUE;
  18. 	} else if (Role_if(PM_HEALER) && ((otmp = sobj_at(CORPSE, rx, ry)) != 0 ||
  19. 				    (otmp = sobj_at(STATUE, rx, ry)) != 0)) {
  20. 	    /* possibly should check uppermost {corpse,statue} in the pile
  21. 	       if both types are present, but it's not worth the effort */
  22. 	    if (vobj_at(rx, ry)->otyp == STATUE) otmp = vobj_at(rx, ry);
  23. 	    if (otmp->otyp == CORPSE) {
  24. 		You("determine that %s unfortunate being is dead.",
  25. 		    (rx == u.ux && ry == u.uy) ? "this" : "that");
  26. 	    } else {
  27. 		ttmp = t_at(rx, ry);
  28. 		pline("%s appears to be in %s health for a statue.",
  29. 		      The(mons[otmp->corpsenm].mname),
  30. 		      (ttmp && ttmp->ttyp == STATUE_TRAP) ?
  31. 			"extraordinary" : "excellent");
  32. 	    }
  33. 	    return TRUE;
  34. 	}
  35. 	return FALSE;
  36. }

use_stethoscope

  1. static const char hollow_str[] = "a hollow sound.  This must be a secret %s!";
  2.  
  3. /* Strictly speaking it makes no sense for usage of a stethoscope to
  4. not take any time; however, unless it did, the stethoscope would be
  5. almost useless.  As a compromise, one use per turn is free, another
  6. uses up the turn; this makes curse status have a tangible effect. */
  7. STATIC_OVL int
  8. use_stethoscope(obj)
  9. 	register struct obj *obj;
  10. {
  11. 	static long last_used_move = -1;
  12. 	static short last_used_movement = 0;
  13. 	struct monst *mtmp;
  14. 	struct rm *lev;
  15. 	int rx, ry, res;
  16. 	boolean interference = (u.uswallow && is_whirly(u.ustuck->data) &&
  17. 				!rn2(Role_if(PM_HEALER) ? 10 : 3));
  18.  
  19. 	if (nohands(youmonst.data)) {	/* should also check for no ears and/or deaf */
  20. 		You("have no hands!");	/* not `body_part(HAND)' */
  21. 		return 0;
  22. 	} else if (!freehand()) {
  23. 		You("have no free %s.", body_part(HAND));
  24. 		return 0;
  25. 	}
  26. 	if (!getdir((char *)0)) return 0;
  27.  
  28. 	res = (moves == last_used_move) &&
  29. 	      (youmonst.movement == last_used_movement);
  30. 	last_used_move = moves;
  31. 	last_used_movement = youmonst.movement;
  32.  
  33. #ifdef STEED
  34. 	if (u.usteed && u.dz > 0) {
  35. 		if (interference) {
  36. 			pline("%s interferes.", Monnam(u.ustuck));
  37. 			mstatusline(u.ustuck);
  38. 		} else
  39. 			mstatusline(u.usteed);
  40. 		return res;
  41. 	} else
  42. #endif
  43. 	if (u.uswallow && (u.dx || u.dy || u.dz)) {
  44. 		mstatusline(u.ustuck);
  45. 		return res;
  46. 	} else if (u.uswallow && interference) {
  47. 		pline("%s interferes.", Monnam(u.ustuck));
  48. 		mstatusline(u.ustuck);
  49. 		return res;
  50. 	} else if (u.dz) {
  51. 		if (Underwater)
  52. 		    You_hear("faint splashing.");
  53. 		else if (u.dz < 0 || !can_reach_floor())
  54. 		    You_cant("reach the %s.",
  55. 			(u.dz > 0) ? surface(u.ux,u.uy) : ceiling(u.ux,u.uy));
  56. 		else if (its_dead(u.ux, u.uy, &res))
  57. 		    ;	/* message already given */
  58. 		else if (Is_stronghold(&u.uz))
  59. 		    You_hear("the crackling of hellfire.");
  60. 		else
  61. 		    pline_The("%s seems healthy enough.", surface(u.ux,u.uy));
  62. 		return res;
  63. 	} else if (obj->cursed && !rn2(2)) {
  64. 		You_hear("your heart beat.");
  65. 		return res;
  66. 	}
  67. 	if (Stunned || (Confusion && !rn2(5))) confdir();
  68. 	if (!u.dx && !u.dy) {
  69. 		ustatusline();
  70. 		return res;
  71. 	}
  72. 	rx = u.ux + u.dx; ry = u.uy + u.dy;
  73. 	if (!isok(rx,ry)) {
  74. 		You_hear("a faint typing noise.");
  75. 		return 0;
  76. 	}
  77. 	if ((mtmp = m_at(rx,ry)) != 0) {
  78. 		mstatusline(mtmp);
  79. 		if (mtmp->mundetected) {
  80. 			mtmp->mundetected = 0;
  81. 			if (cansee(rx,ry)) newsym(mtmp->mx,mtmp->my);
  82. 		}
  83. 		if (!canspotmon(mtmp))
  84. 			map_invisible(rx,ry);
  85. 		return res;
  86. 	}
  87. 	if (glyph_is_invisible(levl[rx][ry].glyph)) {
  88. 		unmap_object(rx, ry);
  89. 		newsym(rx, ry);
  90. 		pline_The("invisible monster must have moved.");
  91. 	}
  92. 	lev = &levl[rx][ry];
  93. 	switch(lev->typ) {
  94. 	case SDOOR:
  95. 		You_hear(hollow_str, "door");
  96. 		cvt_sdoor_to_door(lev);		/* ->typ = DOOR */
  97. 		if (Blind) feel_location(rx,ry);
  98. 		else newsym(rx,ry);
  99. 		return res;
  100. 	case SCORR:
  101. 		You_hear(hollow_str, "passage");
  102. 		lev->typ = CORR;
  103. 		unblock_point(rx,ry);
  104. 		if (Blind) feel_location(rx,ry);
  105. 		else newsym(rx,ry);
  106. 		return res;
  107. 	}
  108.  
  109. 	if (!its_dead(rx, ry, &res))
  110. 	    You("hear nothing special.");	/* not You_hear()  */
  111. 	return res;
  112. }

use_whistle

  1. static const char whistle_str[] = "produce a %s whistling sound.";
  2.  
  3. STATIC_OVL void
  4. use_whistle(obj)
  5. struct obj *obj;
  6. {
  7. 	You(whistle_str, obj->cursed ? "shrill" : "high");
  8. 	wake_nearby();
  9. }

use_magic_whistle

  1. STATIC_OVL void
  2. use_magic_whistle(obj)
  3. struct obj *obj;
  4. {
  5. 	register struct monst *mtmp, *nextmon;
  6.  
  7. 	if(obj->cursed && !rn2(2)) {
  8. 		You("produce a high-pitched humming noise.");
  9. 		wake_nearby();
  10. 	} else {
  11. 		int pet_cnt = 0;
  12. 		You(whistle_str, Hallucination ? "normal" : "strange");
  13. 		for(mtmp = fmon; mtmp; mtmp = nextmon) {
  14. 		    nextmon = mtmp->nmon; /* trap might kill mon */
  15. 		    if (DEADMONSTER(mtmp)) continue;
  16. 		    if (mtmp->mtame) {
  17. 			if (mtmp->mtrapped) {
  18. 			    /* no longer in previous trap (affects mintrap) */
  19. 			    mtmp->mtrapped = 0;
  20. 			    fill_pit(mtmp->mx, mtmp->my);
  21. 			}
  22. 			mnexto(mtmp);
  23. 			if (canspotmon(mtmp)) ++pet_cnt;
  24. 			if (mintrap(mtmp) == 2) change_luck(-1);
  25. 		    }
  26. 		}
  27. 		if (pet_cnt > 0) makeknown(obj->otyp);
  28. 	}
  29. }

um_dist

  1. boolean
  2. um_dist(x,y,n)
  3. register xchar x, y, n;
  4. {
  5. 	return((boolean)(abs(u.ux - x) > n  || abs(u.uy - y) > n));
  6. }

number_leashed

  1. int
  2. number_leashed()
  3. {
  4. 	register int i = 0;
  5. 	register struct obj *obj;
  6.  
  7. 	for(obj = invent; obj; obj = obj->nobj)
  8. 		if(obj->otyp == LEASH && obj->leashmon != 0) i++;
  9. 	return(i);
  10. }

o_unleash

  1. void
  2. o_unleash(otmp)		/* otmp is about to be destroyed or stolen */
  3. register struct obj *otmp;
  4. {
  5. 	register struct monst *mtmp;
  6.  
  7. 	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  8. 		if(mtmp->m_id == (unsigned)otmp->leashmon)
  9. 			mtmp->mleashed = 0;
  10. 	otmp->leashmon = 0;
  11. }

m_unleash

  1. void
  2. m_unleash(mtmp, feedback)	/* mtmp is about to die, or become untame */
  3. register struct monst *mtmp;
  4. boolean feedback;
  5. {
  6. 	register struct obj *otmp;
  7.  
  8. 	if (feedback) {
  9. 	    if (canseemon(mtmp))
  10. 		pline("%s pulls free of %s leash!", Monnam(mtmp), mhis(mtmp));
  11. 	    else
  12. 		Your("leash falls slack.");
  13. 	}
  14. 	for(otmp = invent; otmp; otmp = otmp->nobj)
  15. 		if(otmp->otyp == LEASH &&
  16. 				otmp->leashmon == (int)mtmp->m_id)
  17. 			otmp->leashmon = 0;
  18. 	mtmp->mleashed = 0;
  19. }

unleash_all

  1. void
  2. unleash_all()		/* player is about to die (for bones) */
  3. {
  4. 	register struct obj *otmp;
  5. 	register struct monst *mtmp;
  6.  
  7. 	for(otmp = invent; otmp; otmp = otmp->nobj)
  8. 		if(otmp->otyp == LEASH) otmp->leashmon = 0;
  9. 	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  10. 		mtmp->mleashed = 0;
  11. }

use_leash

  1. #define MAXLEASHED	2
  2.  
  3. /* ARGSUSED */
  4. STATIC_OVL void
  5. use_leash(obj)
  6. struct obj *obj;
  7. {
  8. 	coord cc;
  9. 	register struct monst *mtmp;
  10. 	int spotmon;
  11.  
  12. 	if(!obj->leashmon && number_leashed() >= MAXLEASHED) {
  13. 		You("cannot leash any more pets.");
  14. 		return;
  15. 	}
  16.  
  17. 	if(!get_adjacent_loc((char *)0, (char *)0, u.ux, u.uy, &cc)) return;
  18.  
  19. 	if((cc.x == u.ux) && (cc.y == u.uy)) {
  20. #ifdef STEED
  21. 		if (u.usteed && u.dz > 0) {
  22. 		    mtmp = u.usteed;
  23. 		    spotmon = 1;
  24. 		    goto got_target;
  25. 		}
  26. #endif
  27. 		pline("Leash yourself?  Very funny...");
  28. 		return;
  29. 	}
  30.  
  31. 	if(!(mtmp = m_at(cc.x, cc.y))) {
  32. 		There("is no creature there.");
  33. 		return;
  34. 	}
  35.  
  36. 	spotmon = canspotmon(mtmp);
  37. #ifdef STEED
  38. got_target:
  39. #endif
  40.  
  41. 	if(!mtmp->mtame) {
  42. 	    if(!spotmon)
  43. 		There("is no creature there.");
  44. 	    else
  45. 		pline("%s %s leashed!", Monnam(mtmp), (!obj->leashmon) ?
  46. 				"cannot be" : "is not");
  47. 	    return;
  48. 	}
  49. 	if(!obj->leashmon) {
  50. 		if(mtmp->mleashed) {
  51. 			pline("This %s is already leashed.",
  52. 			      spotmon ? l_monnam(mtmp) : "monster");
  53. 			return;
  54. 		}
  55. 		You("slip the leash around %s%s.",
  56. 		    spotmon ? "your " : "", l_monnam(mtmp));
  57. 		mtmp->mleashed = 1;
  58. 		obj->leashmon = (int)mtmp->m_id;
  59. 		mtmp->msleeping = 0;
  60. 		return;
  61. 	}
  62. 	if(obj->leashmon != (int)mtmp->m_id) {
  63. 		pline("This leash is not attached to that creature.");
  64. 		return;
  65. 	} else {
  66. 		if(obj->cursed) {
  67. 			pline_The("leash would not come off!");
  68. 			obj->bknown = TRUE;
  69. 			return;
  70. 		}
  71. 		mtmp->mleashed = 0;
  72. 		obj->leashmon = 0;
  73. 		You("remove the leash from %s%s.",
  74. 		    spotmon ? "your " : "", l_monnam(mtmp));
  75. 	}
  76. 	return;
  77. }

get_mleash

  1. struct obj *
  2. get_mleash(mtmp)	/* assuming mtmp->mleashed has been checked */
  3. register struct monst *mtmp;
  4. {
  5. 	register struct obj *otmp;
  6.  
  7. 	otmp = invent;
  8. 	while(otmp) {
  9. 		if(otmp->otyp == LEASH && otmp->leashmon == (int)mtmp->m_id)
  10. 			return(otmp);
  11. 		otmp = otmp->nobj;
  12. 	}
  13. 	return((struct obj *)0);
  14. }
  15.  
  16. #endif /* OVLB */

next_to_u

  1. #ifdef OVL1
  2.  
  3. boolean
  4. next_to_u()
  5. {
  6. 	register struct monst *mtmp;
  7. 	register struct obj *otmp;
  8.  
  9. 	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
  10. 		if (DEADMONSTER(mtmp)) continue;
  11. 		if(mtmp->mleashed) {
  12. 			if (distu(mtmp->mx,mtmp->my) > 2) mnexto(mtmp);
  13. 			if (distu(mtmp->mx,mtmp->my) > 2) {
  14. 			    for(otmp = invent; otmp; otmp = otmp->nobj)
  15. 				if(otmp->otyp == LEASH &&
  16. 					otmp->leashmon == (int)mtmp->m_id) {
  17. 				    if(otmp->cursed) return(FALSE);
  18. 				    You_feel("%s leash go slack.",
  19. 					(number_leashed() > 1) ? "a" : "the");
  20. 				    mtmp->mleashed = 0;
  21. 				    otmp->leashmon = 0;
  22. 				}
  23. 			}
  24. 		}
  25. 	}
  26. #ifdef STEED
  27. 	/* no pack mules for the Amulet */
  28. 	if (u.usteed && mon_has_amulet(u.usteed)) return FALSE;
  29. #endif
  30. 	return(TRUE);
  31. }
  32.  
  33. #endif /* OVL1 */

check_leash

  1. #ifdef OVL0
  2.  
  3. void
  4. check_leash(x, y)
  5. register xchar x, y;
  6. {
  7. 	register struct obj *otmp;
  8. 	register struct monst *mtmp;
  9.  
  10. 	for (otmp = invent; otmp; otmp = otmp->nobj) {
  11. 	    if (otmp->otyp != LEASH || otmp->leashmon == 0) continue;
  12. 	    for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
  13. 		if (DEADMONSTER(mtmp)) continue;
  14. 		if ((int)mtmp->m_id == otmp->leashmon) break; 
  15. 	    }
  16. 	    if (!mtmp) {
  17. 		impossible("leash in use isn't attached to anything?");
  18. 		otmp->leashmon = 0;
  19. 		continue;
  20. 	    }
  21. 	    if (dist2(u.ux,u.uy,mtmp->mx,mtmp->my) >
  22. 		    dist2(x,y,mtmp->mx,mtmp->my)) {
  23. 		if (!um_dist(mtmp->mx, mtmp->my, 3)) {
  24. 		    ;	/* still close enough */
  25. 		} else if (otmp->cursed && !breathless(mtmp->data)) {
  26. 		    if (um_dist(mtmp->mx, mtmp->my, 5) ||
  27. 			    (mtmp->mhp -= rnd(2)) <= 0) {
  28. 			long save_pacifism = u.uconduct.killer;
  29.  
  30. 			Your("leash chokes %s to death!", mon_nam(mtmp));
  31. 			/* hero might not have intended to kill pet, but
  32. 			   that's the result of his actions; gain experience,
  33. 			   lose pacifism, take alignment and luck hit, make
  34. 			   corpse less likely to remain tame after revival */
  35. 			xkilled(mtmp, 0);	/* no "you kill it" message */
  36. 			/* life-saving doesn't ordinarily reset this */
  37. 			if (mtmp->mhp > 0) u.uconduct.killer = save_pacifism;
  38. 		    } else {
  39. 			pline("%s chokes on the leash!", Monnam(mtmp));
  40. 			/* tameness eventually drops to 1 here (never 0) */
  41. 			if (mtmp->mtame && rn2(mtmp->mtame)) mtmp->mtame--;
  42. 		    }
  43. 		} else {
  44. 		    if (um_dist(mtmp->mx, mtmp->my, 5)) {
  45. 			pline("%s leash snaps loose!", s_suffix(Monnam(mtmp)));
  46. 			m_unleash(mtmp, FALSE);
  47. 		    } else {
  48. 			You("pull on the leash.");
  49. 			if (mtmp->data->msound != MS_SILENT)
  50. 			    switch (rn2(3)) {
  51. 			    case 0:  growl(mtmp);   break;
  52. 			    case 1:  yelp(mtmp);    break;
  53. 			    default: whimper(mtmp); break;
  54. 			    }
  55. 		    }
  56. 		}
  57. 	    }
  58. 	}
  59. }
  60.  
  61. #endif /* OVL0 */

use_mirror

  1. #ifdef OVLB
  2.  
  3. #define WEAK	3	/* from eat.c */
  4.  
  5. static const char look_str[] = "look %s.";
  6.  
  7. STATIC_OVL int
  8. use_mirror(obj)
  9. struct obj *obj;
  10. {
  11. 	register struct monst *mtmp;
  12. 	register char mlet;
  13. 	boolean vis;
  14.  
  15. 	if(!getdir((char *)0)) return 0;
  16. 	if(obj->cursed && !rn2(2)) {
  17. 		if (!Blind)
  18. 			pline_The("mirror fogs up and doesn't reflect!");
  19. 		return 1;
  20. 	}
  21. 	if(!u.dx && !u.dy && !u.dz) {
  22. 		if(!Blind && !Invisible) {
  23. 		    if (u.umonnum == PM_FLOATING_EYE) {
  24. 			if (!Free_action) {
  25. 			pline(Hallucination ?
  26. 			      "Yow!  The mirror stares back!" :
  27. 			      "Yikes!  You've frozen yourself!");
  28. 			nomul(-rnd((MAXULEV+6) - u.ulevel));
  29. 			} else You("stiffen momentarily under your gaze.");
  30. 		    } else if (youmonst.data->mlet == S_VAMPIRE)
  31. 			You("don't have a reflection.");
  32. 		    else if (u.umonnum == PM_UMBER_HULK) {
  33. 			pline("Huh?  That doesn't look like you!");
  34. 			make_confused(HConfusion + d(3,4),FALSE);
  35. 		    } else if (Hallucination)
  36. 			You(look_str, hcolor((char *)0));
  37. 		    else if (Sick)
  38. 			You(look_str, "peaked");
  39. 		    else if (u.uhs >= WEAK)
  40. 			You(look_str, "undernourished");
  41. 		    else You("look as %s as ever.",
  42. 				ACURR(A_CHA) > 14 ?
  43. 				(poly_gender()==1 ? "beautiful" : "handsome") :
  44. 				"ugly");
  45. 		} else {
  46. 			You_cant("see your %s %s.",
  47. 				ACURR(A_CHA) > 14 ?
  48. 				(poly_gender()==1 ? "beautiful" : "handsome") :
  49. 				"ugly",
  50. 				body_part(FACE));
  51. 		}
  52. 		return 1;
  53. 	}
  54. 	if(u.uswallow) {
  55. 		if (!Blind) You("reflect %s %s.", s_suffix(mon_nam(u.ustuck)),
  56. 		    mbodypart(u.ustuck, STOMACH));
  57. 		return 1;
  58. 	}
  59. 	if(Underwater) {
  60. 		You(Hallucination ?
  61. 		    "give the fish a chance to fix their makeup." :
  62. 		    "reflect the murky water.");
  63. 		return 1;
  64. 	}
  65. 	if(u.dz) {
  66. 		if (!Blind)
  67. 		    You("reflect the %s.",
  68. 			(u.dz > 0) ? surface(u.ux,u.uy) : ceiling(u.ux,u.uy));
  69. 		return 1;
  70. 	}
  71. 	mtmp = bhit(u.dx, u.dy, COLNO, INVIS_BEAM,
  72. 		    (int FDECL((*),(MONST_P,OBJ_P)))0,
  73. 		    (int FDECL((*),(OBJ_P,OBJ_P)))0,
  74. 		    obj);
  75. 	if (!mtmp || !haseyes(mtmp->data))
  76. 		return 1;
  77.  
  78. 	vis = canseemon(mtmp);
  79. 	mlet = mtmp->data->mlet;
  80. 	if (mtmp->msleeping) {
  81. 		if (vis)
  82. 		    pline ("%s is too tired to look at your mirror.",
  83. 			    Monnam(mtmp));
  84. 	} else if (!mtmp->mcansee) {
  85. 	    if (vis)
  86. 		pline("%s can't see anything right now.", Monnam(mtmp));
  87. 	/* some monsters do special things */
  88. 	} else if (mlet == S_VAMPIRE || mlet == S_GHOST) {
  89. 	    if (vis)
  90. 		pline ("%s doesn't have a reflection.", Monnam(mtmp));
  91. 	} else if(!mtmp->mcan && !mtmp->minvis &&
  92. 					mtmp->data == &mons[PM_MEDUSA]) {
  93. 		if (mon_reflects(mtmp, "The gaze is reflected away by %s %s!"))
  94. 			return 1;
  95. 		if (vis)
  96. 			pline("%s is turned to stone!", Monnam(mtmp));
  97. 		stoned = TRUE;
  98. 		killed(mtmp);
  99. 	} else if(!mtmp->mcan && !mtmp->minvis &&
  100. 					mtmp->data == &mons[PM_FLOATING_EYE]) {
  101. 		int tmp = d((int)mtmp->m_lev, (int)mtmp->data->mattk[0].damd);
  102. 		if (!rn2(4)) tmp = 120;
  103. 		if (vis)
  104. 			pline("%s is frozen by its reflection.", Monnam(mtmp));
  105. 		else You_hear("%s stop moving.",something);
  106. 		mtmp->mcanmove = 0;
  107. 		if ( (int) mtmp->mfrozen + tmp > 127)
  108. 			mtmp->mfrozen = 127;
  109. 		else mtmp->mfrozen += tmp;
  110. 	} else if(!mtmp->mcan && !mtmp->minvis &&
  111. 					mtmp->data == &mons[PM_UMBER_HULK]) {
  112. 		if (vis)
  113. 			pline ("%s confuses itself!", Monnam(mtmp));
  114. 		mtmp->mconf = 1;
  115. 	} else if(!mtmp->mcan && !mtmp->minvis && (mlet == S_NYMPH
  116. 				     || mtmp->data==&mons[PM_SUCCUBUS])) {
  117. 		if (vis) {
  118. 		    pline ("%s admires herself in your mirror.", Monnam(mtmp));
  119. 		    pline ("She takes it!");
  120. 		} else pline ("It steals your mirror!");
  121. 		setnotworn(obj); /* in case mirror was wielded */
  122. 		freeinv(obj);
  123. 		(void) mpickobj(mtmp,obj);
  124. 		if (!tele_restrict(mtmp)) (void) rloc(mtmp, FALSE);
  125. 	} else if (!is_unicorn(mtmp->data) && !humanoid(mtmp->data) &&
  126. 			(!mtmp->minvis || perceives(mtmp->data)) && rn2(5)) {
  127. 		if (vis)
  128. 		    pline("%s is frightened by its reflection.", Monnam(mtmp));
  129. 		monflee(mtmp, d(2,4), FALSE, FALSE);
  130. 	} else if (!Blind) {
  131. 		if (mtmp->minvis && !See_invisible)
  132. 		    ;
  133. 		else if ((mtmp->minvis && !perceives(mtmp->data))
  134. 			 || !haseyes(mtmp->data))
  135. 		    pline("%s doesn't seem to notice its reflection.",
  136. 			Monnam(mtmp));
  137. 		else
  138. 		    pline("%s ignores %s reflection.",
  139. 			  Monnam(mtmp), mhis(mtmp));
  140. 	}
  141. 	return 1;
  142. }

use_bell

  1. STATIC_OVL void
  2. use_bell(optr)
  3. struct obj **optr;
  4. {
  5. 	register struct obj *obj = *optr;
  6. 	struct monst *mtmp;
  7. 	boolean wakem = FALSE, learno = FALSE,
  8. 		ordinary = (obj->otyp != BELL_OF_OPENING || !obj->spe),
  9. 		invoking = (obj->otyp == BELL_OF_OPENING &&
  10. 			 invocation_pos(u.ux, u.uy) && !On_stairs(u.ux, u.uy));
  11.  
  12. 	You("ring %s.", the(xname(obj)));
  13.  
  14. 	if (Underwater || (u.uswallow && ordinary)) {
  15. #ifdef	AMIGA
  16. 	    amii_speaker( obj, "AhDhGqEqDhEhAqDqFhGw", AMII_MUFFLED_VOLUME );
  17. #endif
  18. 	    pline("But the sound is muffled.");
  19.  
  20. 	} else if (invoking && ordinary) {
  21. 	    /* needs to be recharged... */
  22. 	    pline("But it makes no sound.");
  23. 	    learno = TRUE;	/* help player figure out why */
  24.  
  25. 	} else if (ordinary) {
  26. #ifdef	AMIGA
  27. 	    amii_speaker( obj, "ahdhgqeqdhehaqdqfhgw", AMII_MUFFLED_VOLUME );
  28. #endif
  29. 	    if (obj->cursed && !rn2(4) &&
  30. 		    /* note: once any of them are gone, we stop all of them */
  31. 		    !(mvitals[PM_WOOD_NYMPH].mvflags & G_GONE) &&
  32. 		    !(mvitals[PM_WATER_NYMPH].mvflags & G_GONE) &&
  33. 		    !(mvitals[PM_MOUNTAIN_NYMPH].mvflags & G_GONE) &&
  34. 		    (mtmp = makemon(mkclass(S_NYMPH, 0),
  35. 					u.ux, u.uy, NO_MINVENT)) != 0) {
  36. 		You("summon %s!", a_monnam(mtmp));
  37. 		if (!obj_resists(obj, 93, 100)) {
  38. 		    pline("%s shattered!", Tobjnam(obj, "have"));
  39. 		    useup(obj);
  40. 		    *optr = 0;
  41. 		} else switch (rn2(3)) {
  42. 			default:
  43. 				break;
  44. 			case 1:
  45. 				mon_adjust_speed(mtmp, 2, (struct obj *)0);
  46. 				break;
  47. 			case 2: /* no explanation; it just happens... */
  48. 				nomovemsg = "";
  49. 				nomul(-rnd(2));
  50. 				break;
  51. 		}
  52. 	    }
  53. 	    wakem = TRUE;
  54.  
  55. 	} else {
  56. 	    /* charged Bell of Opening */
  57. 	    consume_obj_charge(obj, TRUE);
  58.  
  59. 	    if (u.uswallow) {
  60. 		if (!obj->cursed)
  61. 		    (void) openit();
  62. 		else
  63. 		    pline(nothing_happens);
  64.  
  65. 	    } else if (obj->cursed) {
  66. 		coord mm;
  67.  
  68. 		mm.x = u.ux;
  69. 		mm.y = u.uy;
  70. 		mkundead(&mm, FALSE, NO_MINVENT);
  71. 		wakem = TRUE;
  72.  
  73. 	    } else  if (invoking) {
  74. 		pline("%s an unsettling shrill sound...",
  75. 		      Tobjnam(obj, "issue"));
  76. #ifdef	AMIGA
  77. 		amii_speaker( obj, "aefeaefeaefeaefeaefe", AMII_LOUDER_VOLUME );
  78. #endif
  79. 		obj->age = moves;
  80. 		learno = TRUE;
  81. 		wakem = TRUE;
  82.  
  83. 	    } else if (obj->blessed) {
  84. 		int res = 0;
  85.  
  86. #ifdef	AMIGA
  87. 		amii_speaker( obj, "ahahahDhEhCw", AMII_SOFT_VOLUME );
  88. #endif
  89. 		if (uchain) {
  90. 		    unpunish();
  91. 		    res = 1;
  92. 		}
  93. 		res += openit();
  94. 		switch (res) {
  95. 		  case 0:  pline(nothing_happens); break;
  96. 		  case 1:  pline("%s opens...", Something);
  97. 			   learno = TRUE; break;
  98. 		  default: pline("Things open around you...");
  99. 			   learno = TRUE; break;
  100. 		}
  101.  
  102. 	    } else {  /* uncursed */
  103. #ifdef	AMIGA
  104. 		amii_speaker( obj, "AeFeaeFeAefegw", AMII_OKAY_VOLUME );
  105. #endif
  106. 		if (findit() != 0) learno = TRUE;
  107. 		else pline(nothing_happens);
  108. 	    }
  109.  
  110. 	}	/* charged BofO */
  111.  
  112. 	if (learno) {
  113. 	    makeknown(BELL_OF_OPENING);
  114. 	    obj->known = 1;
  115. 	}
  116. 	if (wakem) wake_nearby();
  117. }

use_candelabrum

  1. STATIC_OVL void
  2. use_candelabrum(obj)
  3. register struct obj *obj;
  4. {
  5. 	const char *s = (obj->spe != 1) ? "candles" : "candle";
  6.  
  7. 	if(Underwater) {
  8. 		You("cannot make fire under water.");
  9. 		return;
  10. 	}
  11. 	if(obj->lamplit) {
  12. 		You("snuff the %s.", s);
  13. 		end_burn(obj, TRUE);
  14. 		return;
  15. 	}
  16. 	if(obj->spe <= 0) {
  17. 		pline("This %s has no %s.", xname(obj), s);
  18. 		return;
  19. 	}
  20. 	if(u.uswallow || obj->cursed) {
  21. 		if (!Blind)
  22. 		    pline_The("%s %s for a moment, then %s.",
  23. 			      s, vtense(s, "flicker"), vtense(s, "die"));
  24. 		return;
  25. 	}
  26. 	if(obj->spe < 7) {
  27. 		There("%s only %d %s in %s.",
  28. 		      vtense(s, "are"), obj->spe, s, the(xname(obj)));
  29. 		if (!Blind)
  30. 		    pline("%s lit.  %s dimly.",
  31. 			  obj->spe == 1 ? "It is" : "They are",
  32. 			  Tobjnam(obj, "shine"));
  33. 	} else {
  34. 		pline("%s's %s burn%s", The(xname(obj)), s,
  35. 			(Blind ? "." : " brightly!"));
  36. 	}
  37. 	if (!invocation_pos(u.ux, u.uy)) {
  38. 		pline_The("%s %s being rapidly consumed!", s, vtense(s, "are"));
  39. 		obj->age /= 2;
  40. 	} else {
  41. 		if(obj->spe == 7) {
  42. 		    if (Blind)
  43. 		      pline("%s a strange warmth!", Tobjnam(obj, "radiate"));
  44. 		    else
  45. 		      pline("%s with a strange light!", Tobjnam(obj, "glow"));
  46. 		}
  47. 		obj->known = 1;
  48. 	}
  49. 	begin_burn(obj, FALSE);
  50. }

use_candle

  1. STATIC_OVL void
  2. use_candle(optr)
  3. struct obj **optr;
  4. {
  5. 	register struct obj *obj = *optr;
  6. 	register struct obj *otmp;
  7. 	const char *s = (obj->quan != 1) ? "candles" : "candle";
  8. 	char qbuf[QBUFSZ];
  9.  
  10. 	if(u.uswallow) {
  11. 		You(no_elbow_room);
  12. 		return;
  13. 	}
  14. 	if(Underwater) {
  15. 		pline("Sorry, fire and water don't mix.");
  16. 		return;
  17. 	}
  18.  
  19. 	otmp = carrying(CANDELABRUM_OF_INVOCATION);
  20. 	if(!otmp || otmp->spe == 7) {
  21. 		use_lamp(obj);
  22. 		return;
  23. 	}
  24.  
  25. 	Sprintf(qbuf, "Attach %s", the(xname(obj)));
  26. 	Sprintf(eos(qbuf), " to %s?",
  27. 		safe_qbuf(qbuf, sizeof(" to ?"), the(xname(otmp)),
  28. 			the(simple_typename(otmp->otyp)), "it"));
  29. 	if(yn(qbuf) == 'n') {
  30. 		if (!obj->lamplit)
  31. 		    You("try to light %s...", the(xname(obj)));
  32. 		use_lamp(obj);
  33. 		return;
  34. 	} else {
  35. 		if ((long)otmp->spe + obj->quan > 7L)
  36. 		    obj = splitobj(obj, 7L - (long)otmp->spe);
  37. 		else *optr = 0;
  38. 		You("attach %ld%s %s to %s.",
  39. 		    obj->quan, !otmp->spe ? "" : " more",
  40. 		    s, the(xname(otmp)));
  41. 		if (!otmp->spe || otmp->age > obj->age)
  42. 		    otmp->age = obj->age;
  43. 		otmp->spe += (int)obj->quan;
  44. 		if (otmp->lamplit && !obj->lamplit)
  45. 		    pline_The("new %s magically %s!", s, vtense(s, "ignite"));
  46. 		else if (!otmp->lamplit && obj->lamplit)
  47. 		    pline("%s out.", (obj->quan > 1L) ? "They go" : "It goes");
  48. 		if (obj->unpaid)
  49. 		    verbalize("You %s %s, you bought %s!",
  50. 			      otmp->lamplit ? "burn" : "use",
  51. 			      (obj->quan > 1L) ? "them" : "it",
  52. 			      (obj->quan > 1L) ? "them" : "it");
  53. 		if (obj->quan < 7L && otmp->spe == 7)
  54. 		    pline("%s now has seven%s candles attached.",
  55. 			  The(xname(otmp)), otmp->lamplit ? " lit" : "");
  56. 		/* candelabrum's light range might increase */
  57. 		if (otmp->lamplit) obj_merge_light_sources(otmp, otmp);
  58. 		/* candles are no longer a separate light source */
  59. 		if (obj->lamplit) end_burn(obj, TRUE);
  60. 		/* candles are now gone */
  61. 		useupall(obj);
  62. 	}
  63. }

snuff_candle

  1. boolean
  2. snuff_candle(otmp)  /* call in drop, throw, and put in box, etc. */
  3. register struct obj *otmp;
  4. {
  5. 	register boolean candle = Is_candle(otmp);
  6.  
  7. 	if ((candle || otmp->otyp == CANDELABRUM_OF_INVOCATION) &&
  8. 		otmp->lamplit) {
  9. 	    char buf[BUFSZ];
  10. 	    xchar x, y;
  11. 	    register boolean many = candle ? otmp->quan > 1L : otmp->spe > 1;
  12.  
  13. 	    (void) get_obj_location(otmp, &x, &y, 0);
  14. 	    if (otmp->where == OBJ_MINVENT ? cansee(x,y) : !Blind)
  15. 		pline("%s %scandle%s flame%s extinguished.",
  16. 		      Shk_Your(buf, otmp),
  17. 		      (candle ? "" : "candelabrum's "),
  18. 		      (many ? "s'" : "'s"), (many ? "s are" : " is"));
  19. 	   end_burn(otmp, TRUE);
  20. 	   return(TRUE);
  21. 	}
  22. 	return(FALSE);
  23. }

snuff_lit

  1. /* called when lit lamp is hit by water or put into a container or
  2. you've been swallowed by a monster; obj might be in transit while
  3. being thrown or dropped so don't assume that its location is valid */
  4. boolean
  5. snuff_lit(obj)
  6. struct obj *obj;
  7. {
  8. 	xchar x, y;
  9.  
  10. 	if (obj->lamplit) {
  11. 	    if (obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP ||
  12. 		    obj->otyp == BRASS_LANTERN || obj->otyp == POT_OIL) {
  13. 		(void) get_obj_location(obj, &x, &y, 0);
  14. 		if (obj->where == OBJ_MINVENT ? cansee(x,y) : !Blind)
  15. 		    pline("%s %s out!", Yname2(obj), otense(obj, "go"));
  16. 		end_burn(obj, TRUE);
  17. 		return TRUE;
  18. 	    }
  19. 	    if (snuff_candle(obj)) return TRUE;
  20. 	}
  21. 	return FALSE;
  22. }

catch_lit

  1. /* Called when potentially lightable object is affected by fire_damage().
  2. Return TRUE if object was lit and FALSE otherwise --ALI */
  3. boolean
  4. catch_lit(obj)
  5. struct obj *obj;
  6. {
  7. 	xchar x, y;
  8.  
  9. 	if (!obj->lamplit && (obj->otyp == MAGIC_LAMP || ignitable(obj))) {
  10. 	    if ((obj->otyp == MAGIC_LAMP ||
  11. 		 obj->otyp == CANDELABRUM_OF_INVOCATION) &&
  12. 		obj->spe == 0)
  13. 		return FALSE;
  14. 	    else if (obj->otyp != MAGIC_LAMP && obj->age == 0)
  15. 		return FALSE;
  16. 	    if (!get_obj_location(obj, &x, &y, 0))
  17. 		return FALSE;
  18. 	    if (obj->otyp == CANDELABRUM_OF_INVOCATION && obj->cursed)
  19. 		return FALSE;
  20. 	    if ((obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP ||
  21. 		 obj->otyp == BRASS_LANTERN) && obj->cursed && !rn2(2))
  22. 		return FALSE;
  23. 	    if (obj->where == OBJ_MINVENT ? cansee(x,y) : !Blind)
  24. 		pline("%s %s light!", Yname2(obj), otense(obj, "catch"));
  25. 	    if (obj->otyp == POT_OIL) makeknown(obj->otyp);
  26. 	    if (obj->unpaid && costly_spot(u.ux, u.uy) && (obj->where == OBJ_INVENT)) {
  27. 	        /* if it catches while you have it, then it's your tough luck */
  28. 		check_unpaid(obj);
  29. 	        verbalize("That's in addition to the cost of %s %s, of course.",
  30. 				Yname2(obj), obj->quan == 1 ? "itself" : "themselves");
  31. 		bill_dummy_object(obj);
  32. 	    }
  33. 	    begin_burn(obj, FALSE);
  34. 	    return TRUE;
  35. 	}
  36. 	return FALSE;
  37. }

use_lamp

  1. STATIC_OVL void
  2. use_lamp(obj)
  3. struct obj *obj;
  4. {
  5. 	char buf[BUFSZ];
  6.  
  7. 	if(Underwater) {
  8. 		pline("This is not a diving lamp.");
  9. 		return;
  10. 	}
  11. 	if(obj->lamplit) {
  12. 		if(obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP ||
  13. 				obj->otyp == BRASS_LANTERN)
  14. 		    pline("%s lamp is now off.", Shk_Your(buf, obj));
  15. 		else
  16. 		    You("snuff out %s.", yname(obj));
  17. 		end_burn(obj, TRUE);
  18. 		return;
  19. 	}
  20. 	/* magic lamps with an spe == 0 (wished for) cannot be lit */
  21. 	if ((!Is_candle(obj) && obj->age == 0)
  22. 			|| (obj->otyp == MAGIC_LAMP && obj->spe == 0)) {
  23. 		if (obj->otyp == BRASS_LANTERN)
  24. 			Your("lamp has run out of power.");
  25. 		else pline("This %s has no oil.", xname(obj));
  26. 		return;
  27. 	}
  28. 	if (obj->cursed && !rn2(2)) {
  29. 		pline("%s for a moment, then %s.",
  30. 		      Tobjnam(obj, "flicker"), otense(obj, "die"));
  31. 	} else {
  32. 		if(obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP ||
  33. 				obj->otyp == BRASS_LANTERN) {
  34. 		    check_unpaid(obj);
  35. 		    pline("%s lamp is now on.", Shk_Your(buf, obj));
  36. 		} else {	/* candle(s) */
  37. 		    pline("%s flame%s %s%s",
  38. 			s_suffix(Yname2(obj)),
  39. 			plur(obj->quan), otense(obj, "burn"),
  40. 			Blind ? "." : " brightly!");
  41. 		    if (obj->unpaid && costly_spot(u.ux, u.uy) &&
  42. 			  obj->age == 20L * (long)objects[obj->otyp].oc_cost) {
  43. 			const char *ithem = obj->quan > 1L ? "them" : "it";
  44. 			verbalize("You burn %s, you bought %s!", ithem, ithem);
  45. 			bill_dummy_object(obj);
  46. 		    }
  47. 		}
  48. 		begin_burn(obj, FALSE);
  49. 	}
  50. }

light_cocktail

  1. STATIC_OVL void
  2. light_cocktail(obj)
  3. 	struct obj *obj;	/* obj is a potion of oil */
  4. {
  5. 	char buf[BUFSZ];
  6.  
  7. 	if (u.uswallow) {
  8. 	    You(no_elbow_room);
  9. 	    return;
  10. 	}
  11.  
  12. 	if (obj->lamplit) {
  13. 	    You("snuff the lit potion.");
  14. 	    end_burn(obj, TRUE);
  15. 	    /*
  16. 	     * Free & add to re-merge potion.  This will average the
  17. 	     * age of the potions.  Not exactly the best solution,
  18. 	     * but its easy.
  19. 	     */
  20. 	    freeinv(obj);
  21. 	    (void) addinv(obj);
  22. 	    return;
  23. 	} else if (Underwater) {
  24. 	    There("is not enough oxygen to sustain a fire.");
  25. 	    return;
  26. 	}
  27.  
  28. 	You("light %s potion.%s", shk_your(buf, obj),
  29. 	    Blind ? "" : "  It gives off a dim light.");
  30. 	if (obj->unpaid && costly_spot(u.ux, u.uy)) {
  31. 	    /* Normally, we shouldn't both partially and fully charge
  32. 	     * for an item, but (Yendorian Fuel) Taxes are inevitable...
  33. 	     */
  34. 	    check_unpaid(obj);
  35. 	    verbalize("That's in addition to the cost of the potion, of course.");
  36. 	    bill_dummy_object(obj);
  37. 	}
  38. 	makeknown(obj->otyp);
  39.  
  40. 	if (obj->quan > 1L) {
  41. 	    obj = splitobj(obj, 1L);
  42. 	    begin_burn(obj, FALSE);	/* burn before free to get position */
  43. 	    obj_extract_self(obj);	/* free from inv */
  44.  
  45. 	    /* shouldn't merge */
  46. 	    obj = hold_another_object(obj, "You drop %s!",
  47. 				      doname(obj), (const char *)0);
  48. 	} else
  49. 	    begin_burn(obj, FALSE);
  50. }

dorub

  1. static NEARDATA const char cuddly[] = { TOOL_CLASS, GEM_CLASS, 0 };
  2.  
  3. int
  4. dorub()
  5. {
  6. 	struct obj *obj = getobj(cuddly, "rub");
  7.  
  8. 	if (obj && obj->oclass == GEM_CLASS) {
  9. 	    if (is_graystone(obj)) {
  10. 		use_stone(obj);
  11. 		return 1;
  12. 	    } else {
  13. 		pline("Sorry, I don't know how to use that.");
  14. 		return 0;
  15. 	    }
  16. 	}
  17.  
  18. 	if (!obj || !wield_tool(obj, "rub")) return 0;
  19.  
  20. 	/* now uwep is obj */
  21. 	if (uwep->otyp == MAGIC_LAMP) {
  22. 	    if (uwep->spe > 0 && !rn2(3)) {
  23. 		check_unpaid_usage(uwep, TRUE);		/* unusual item use */
  24. 		djinni_from_bottle(uwep);
  25. 		makeknown(MAGIC_LAMP);
  26. 		uwep->otyp = OIL_LAMP;
  27. 		uwep->spe = 0; /* for safety */
  28. 		uwep->age = rn1(500,1000);
  29. 		if (uwep->lamplit) begin_burn(uwep, TRUE);
  30. 		update_inventory();
  31. 	    } else if (rn2(2) && !Blind)
  32. 		You("see a puff of smoke.");
  33. 	    else pline(nothing_happens);
  34. 	} else if (obj->otyp == BRASS_LANTERN) {
  35. 	    /* message from Adventure */
  36. 	    pline("Rubbing the electric lamp is not particularly rewarding.");
  37. 	    pline("Anyway, nothing exciting happens.");
  38. 	} else pline(nothing_happens);
  39. 	return 1;
  40. }

dojump

  1. int
  2. dojump()
  3. {
  4. 	/* Physical jump */
  5. 	return jump(0);
  6. }

jump

  1. int
  2. jump(magic)
  3. int magic; /* 0=Physical, otherwise skill level */
  4. {
  5. 	coord cc;
  6.  
  7. 	if (!magic && (nolimbs(youmonst.data) || slithy(youmonst.data))) {
  8. 		/* normally (nolimbs || slithy) implies !Jumping,
  9. 		   but that isn't necessarily the case for knights */
  10. 		You_cant("jump; you have no legs!");
  11. 		return 0;
  12. 	} else if (!magic && !Jumping) {
  13. 		You_cant("jump very far.");
  14. 		return 0;
  15. 	} else if (u.uswallow) {
  16. 		if (magic) {
  17. 			You("bounce around a little.");
  18. 			return 1;
  19. 		}
  20. 		pline("You've got to be kidding!");
  21. 		return 0;
  22. 	} else if (u.uinwater) {
  23. 		if (magic) {
  24. 			You("swish around a little.");
  25. 			return 1;
  26. 		}
  27. 		pline("This calls for swimming, not jumping!");
  28. 		return 0;
  29. 	} else if (u.ustuck) {
  30. 		if (u.ustuck->mtame && !Conflict && !u.ustuck->mconf) {
  31. 		    You("pull free from %s.", mon_nam(u.ustuck));
  32. 		    u.ustuck = 0;
  33. 		    return 1;
  34. 		}
  35. 		if (magic) {
  36. 			You("writhe a little in the grasp of %s!", mon_nam(u.ustuck));
  37. 			return 1;
  38. 		}
  39. 		You("cannot escape from %s!", mon_nam(u.ustuck));
  40. 		return 0;
  41. 	} else if (Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) {
  42. 		if (magic) {
  43. 			You("flail around a little.");
  44. 			return 1;
  45. 		}
  46. 		You("don't have enough traction to jump.");
  47. 		return 0;
  48. 	} else if (!magic && near_capacity() > UNENCUMBERED) {
  49. 		You("are carrying too much to jump!");
  50. 		return 0;
  51. 	} else if (!magic && (u.uhunger <= 100 || ACURR(A_STR) < 6)) {
  52. 		You("lack the strength to jump!");
  53. 		return 0;
  54. 	} else if (Wounded_legs) {
  55. 		long wl = (Wounded_legs & BOTH_SIDES);
  56. 		const char *bp = body_part(LEG);
  57.  
  58. 		if (wl == BOTH_SIDES) bp = makeplural(bp);
  59. #ifdef STEED
  60. 		if (u.usteed)
  61. 		    pline("%s is in no shape for jumping.", Monnam(u.usteed));
  62. 		else
  63. #endif
  64. 		Your("%s%s %s in no shape for jumping.",
  65. 		     (wl == LEFT_SIDE) ? "left " :
  66. 			(wl == RIGHT_SIDE) ? "right " : "",
  67. 		     bp, (wl == BOTH_SIDES) ? "are" : "is");
  68. 		return 0;
  69. 	}
  70. #ifdef STEED
  71. 	else if (u.usteed && u.utrap) {
  72. 		pline("%s is stuck in a trap.", Monnam(u.usteed));
  73. 		return (0);
  74. 	}
  75. #endif
  76.  
  77. 	pline("Where do you want to jump?");
  78. 	cc.x = u.ux;
  79. 	cc.y = u.uy;
  80. 	if (getpos(&cc, TRUE, "the desired position") < 0)
  81. 		return 0;	/* user pressed ESC */
  82. 	if (!magic && !(HJumping & ~INTRINSIC) && !EJumping &&
  83. 			distu(cc.x, cc.y) != 5) {
  84. 		/* The Knight jumping restriction still applies when riding a
  85. 		 * horse.  After all, what shape is the knight piece in chess?
  86. 		 */
  87. 		pline("Illegal move!");
  88. 		return 0;
  89. 	} else if (distu(cc.x, cc.y) > (magic ? 6+magic*3 : 9)) {
  90. 		pline("Too far!");
  91. 		return 0;
  92. 	} else if (!cansee(cc.x, cc.y)) {
  93. 		You("cannot see where to land!");
  94. 		return 0;
  95. 	} else if (!isok(cc.x, cc.y)) {
  96. 		You("cannot jump there!");
  97. 		return 0;
  98. 	} else {
  99. 	    coord uc;
  100. 	    int range, temp;
  101.  
  102. 	    if(u.utrap)
  103. 		switch(u.utraptype) {
  104. 		case TT_BEARTRAP: {
  105. 		    register long side = rn2(3) ? LEFT_SIDE : RIGHT_SIDE;
  106. 		    You("rip yourself free of the bear trap!  Ouch!");
  107. 		    losehp(rnd(10), "jumping out of a bear trap", KILLED_BY);
  108. 		    set_wounded_legs(side, rn1(1000,500));
  109. 		    break;
  110. 		  }
  111. 		case TT_PIT:
  112. 		    You("leap from the pit!");
  113. 		    break;
  114. 		case TT_WEB:
  115. 		    You("tear the web apart as you pull yourself free!");
  116. 		    deltrap(t_at(u.ux,u.uy));
  117. 		    break;
  118. 		case TT_LAVA:
  119. 		    You("pull yourself above the lava!");
  120. 		    u.utrap = 0;
  121. 		    return 1;
  122. 		case TT_INFLOOR:
  123. 		    You("strain your %s, but you're still stuck in the floor.",
  124. 			makeplural(body_part(LEG)));
  125. 		    set_wounded_legs(LEFT_SIDE, rn1(10, 11));
  126. 		    set_wounded_legs(RIGHT_SIDE, rn1(10, 11));
  127. 		    return 1;
  128. 		}
  129.  
  130. 	    /*
  131. 	     * Check the path from uc to cc, calling hurtle_step at each
  132. 	     * location.  The final position actually reached will be
  133. 	     * in cc.
  134. 	     */
  135. 	    uc.x = u.ux;
  136. 	    uc.y = u.uy;
  137. 	    /* calculate max(abs(dx), abs(dy)) as the range */
  138. 	    range = cc.x - uc.x;
  139. 	    if (range < 0) range = -range;
  140. 	    temp = cc.y - uc.y;
  141. 	    if (temp < 0) temp = -temp;
  142. 	    if (range < temp)
  143. 		range = temp;
  144. 	    (void) walk_path(&uc, &cc, hurtle_step, (genericptr_t)&range);
  145.  
  146. 	    /* A little Sokoban guilt... */
  147. 	    if (In_sokoban(&u.uz))
  148. 		change_luck(-1);
  149.  
  150. 	    teleds(cc.x, cc.y, TRUE);
  151. 	    nomul(-1);
  152. 	    nomovemsg = "";
  153. 	    morehungry(rnd(25));
  154. 	    return 1;
  155. 	}
  156. }

tinnable

  1. boolean
  2. tinnable(corpse)
  3. struct obj *corpse;
  4. {
  5. 	if (corpse->oeaten) return 0;
  6. 	if (!mons[corpse->corpsenm].cnutrit) return 0;
  7. 	return 1;
  8. }

use_tinning_kit

  1. STATIC_OVL void
  2. use_tinning_kit(obj)
  3. register struct obj *obj;
  4. {
  5. 	register struct obj *corpse, *can;
  6.  
  7. 	/* This takes only 1 move.  If this is to be changed to take many
  8. 	 * moves, we've got to deal with decaying corpses...
  9. 	 */
  10. 	if (obj->spe <= 0) {
  11. 		You("seem to be out of tins.");
  12. 		return;
  13. 	}
  14. 	if (!(corpse = floorfood("tin", 2))) return;
  15. 	if (corpse->oeaten) {
  16. 		You("cannot tin %s which is partly eaten.",something);
  17. 		return;
  18. 	}
  19. 	if (touch_petrifies(&mons[corpse->corpsenm])
  20. 		&& !Stone_resistance && !uarmg) {
  21. 	    char kbuf[BUFSZ];
  22.  
  23. 	    if (poly_when_stoned(youmonst.data))
  24. 		You("tin %s without wearing gloves.",
  25. 			an(mons[corpse->corpsenm].mname));
  26. 	    else {
  27. 		pline("Tinning %s without wearing gloves is a fatal mistake...",
  28. 			an(mons[corpse->corpsenm].mname));
  29. 		Sprintf(kbuf, "trying to tin %s without gloves",
  30. 			an(mons[corpse->corpsenm].mname));
  31. 	    }
  32. 	    instapetrify(kbuf);
  33. 	}
  34. 	if (is_rider(&mons[corpse->corpsenm])) {
  35. 		(void) revive_corpse(corpse);
  36. 		verbalize("Yes...  But War does not preserve its enemies...");
  37. 		return;
  38. 	}
  39. 	if (mons[corpse->corpsenm].cnutrit == 0) {
  40. 		pline("That's too insubstantial to tin.");
  41. 		return;
  42. 	}
  43. 	consume_obj_charge(obj, TRUE);
  44.  
  45. 	if ((can = mksobj(TIN, FALSE, FALSE)) != 0) {
  46. 	    static const char you_buy_it[] = "You tin it, you bought it!";
  47.  
  48. 	    can->corpsenm = corpse->corpsenm;
  49. 	    can->cursed = obj->cursed;
  50. 	    can->blessed = obj->blessed;
  51. 	    can->owt = weight(can);
  52. 	    can->known = 1;
  53. 	    can->spe = -1;  /* Mark tinned tins. No spinach allowed... */
  54. 	    if (carried(corpse)) {
  55. 		if (corpse->unpaid)
  56. 		    verbalize(you_buy_it);
  57. 		useup(corpse);
  58. 	    } else {
  59. 		if (costly_spot(corpse->ox, corpse->oy) && !corpse->no_charge)
  60. 		    verbalize(you_buy_it);
  61. 		useupf(corpse, 1L);
  62. 	    }
  63. 	    can = hold_another_object(can, "You make, but cannot pick up, %s.",
  64. 				      doname(can), (const char *)0);
  65. 	} else impossible("Tinning failed.");
  66. }

use_unicorn_horn

  1. void
  2. use_unicorn_horn(obj)
  3. struct obj *obj;
  4. {
  5. #define PROP_COUNT 6		/* number of properties we're dealing with */
  6. #define ATTR_COUNT (A_MAX*3)	/* number of attribute points we might fix */
  7. 	int idx, val, val_limit,
  8. 	    trouble_count, unfixable_trbl, did_prop, did_attr;
  9. 	int trouble_list[PROP_COUNT + ATTR_COUNT];
  10.  
  11. 	if (obj && obj->cursed) {
  12. 	    long lcount = (long) rnd(100);
  13.  
  14. 	    switch (rn2(6)) {
  15. 	    case 0: make_sick(Sick ? Sick/3L + 1L : (long)rn1(ACURR(A_CON),20),
  16. 			xname(obj), TRUE, SICK_NONVOMITABLE);
  17. 		    break;
  18. 	    case 1: make_blinded(Blinded + lcount, TRUE);
  19. 		    break;
  20. 	    case 2: if (!Confusion)
  21. 			You("suddenly feel %s.",
  22. 			    Hallucination ? "trippy" : "confused");
  23. 		    make_confused(HConfusion + lcount, TRUE);
  24. 		    break;
  25. 	    case 3: make_stunned(HStun + lcount, TRUE);
  26. 		    break;
  27. 	    case 4: (void) adjattrib(rn2(A_MAX), -1, FALSE);
  28. 		    break;
  29. 	    case 5: (void) make_hallucinated(HHallucination + lcount, TRUE, 0L);
  30. 		    break;
  31. 	    }
  32. 	    return;
  33. 	}
  34.  
  35. /*
  36. * Entries in the trouble list use a very simple encoding scheme.
  37. */
  38. #define prop2trbl(X)	((X) + A_MAX)
  39. #define attr2trbl(Y)	(Y)
  40. #define prop_trouble(X) trouble_list[trouble_count++] = prop2trbl(X)
  41. #define attr_trouble(Y) trouble_list[trouble_count++] = attr2trbl(Y)
  42.  
  43. 	trouble_count = unfixable_trbl = did_prop = did_attr = 0;
  44.  
  45. 	/* collect property troubles */
  46. 	if (Sick) prop_trouble(SICK);
  47. 	if (Blinded > (long)u.ucreamed) prop_trouble(BLINDED);
  48. 	if (HHallucination) prop_trouble(HALLUC);
  49. 	if (Vomiting) prop_trouble(VOMITING);
  50. 	if (HConfusion) prop_trouble(CONFUSION);
  51. 	if (HStun) prop_trouble(STUNNED);
  52.  
  53. 	unfixable_trbl = unfixable_trouble_count(TRUE);
  54.  
  55. 	/* collect attribute troubles */
  56. 	for (idx = 0; idx < A_MAX; idx++) {
  57. 	    val_limit = AMAX(idx);
  58. 	    /* don't recover strength lost from hunger */
  59. 	    if (idx == A_STR && u.uhs >= WEAK) val_limit--;
  60. 	    /* don't recover more than 3 points worth of any attribute */
  61. 	    if (val_limit > ABASE(idx) + 3) val_limit = ABASE(idx) + 3;
  62.  
  63. 	    for (val = ABASE(idx); val < val_limit; val++)
  64. 		attr_trouble(idx);
  65. 	    /* keep track of unfixed trouble, for message adjustment below */
  66. 	    unfixable_trbl += (AMAX(idx) - val_limit);
  67. 	}
  68.  
  69. 	if (trouble_count == 0) {
  70. 	    pline(nothing_happens);
  71. 	    return;
  72. 	} else if (trouble_count > 1) {		/* shuffle */
  73. 	    int i, j, k;
  74.  
  75. 	    for (i = trouble_count - 1; i > 0; i--)
  76. 		if ((j = rn2(i + 1)) != i) {
  77. 		    k = trouble_list[j];
  78. 		    trouble_list[j] = trouble_list[i];
  79. 		    trouble_list[i] = k;
  80. 		}
  81. 	}
  82.  
  83. 	/*
  84. 	 *		Chances for number of troubles to be fixed
  85. 	 *		 0	1      2      3      4	    5	   6	  7
  86. 	 *   blessed:  22.7%  22.7%  19.5%  15.4%  10.7%   5.7%   2.6%	 0.8%
  87. 	 *  uncursed:  35.4%  35.4%  22.9%   6.3%    0	    0	   0	  0
  88. 	 */
  89. 	val_limit = rn2( d(2, (obj && obj->blessed) ? 4 : 2) );
  90. 	if (val_limit > trouble_count) val_limit = trouble_count;
  91.  
  92. 	/* fix [some of] the troubles */
  93. 	for (val = 0; val < val_limit; val++) {
  94. 	    idx = trouble_list[val];
  95.  
  96. 	    switch (idx) {
  97. 	    case prop2trbl(SICK):
  98. 		make_sick(0L, (char *) 0, TRUE, SICK_ALL);
  99. 		did_prop++;
  100. 		break;
  101. 	    case prop2trbl(BLINDED):
  102. 		make_blinded((long)u.ucreamed, TRUE);
  103. 		did_prop++;
  104. 		break;
  105. 	    case prop2trbl(HALLUC):
  106. 		(void) make_hallucinated(0L, TRUE, 0L);
  107. 		did_prop++;
  108. 		break;
  109. 	    case prop2trbl(VOMITING):
  110. 		make_vomiting(0L, TRUE);
  111. 		did_prop++;
  112. 		break;
  113. 	    case prop2trbl(CONFUSION):
  114. 		make_confused(0L, TRUE);
  115. 		did_prop++;
  116. 		break;
  117. 	    case prop2trbl(STUNNED):
  118. 		make_stunned(0L, TRUE);
  119. 		did_prop++;
  120. 		break;
  121. 	    default:
  122. 		if (idx >= 0 && idx < A_MAX) {
  123. 		    ABASE(idx) += 1;
  124. 		    did_attr++;
  125. 		} else
  126. 		    panic("use_unicorn_horn: bad trouble? (%d)", idx);
  127. 		break;
  128. 	    }
  129. 	}
  130.  
  131. 	if (did_attr)
  132. 	    pline("This makes you feel %s!",
  133. 		  (did_prop + did_attr) == (trouble_count + unfixable_trbl) ?
  134. 		  "great" : "better");
  135. 	else if (!did_prop)
  136. 	    pline("Nothing seems to happen.");
  137.  
  138. 	flags.botl = (did_attr || did_prop);
  139. #undef PROP_COUNT
  140. #undef ATTR_COUNT
  141. #undef prop2trbl
  142. #undef attr2trbl
  143. #undef prop_trouble
  144. #undef attr_trouble
  145. }

fig_transform

  1. /*
  2. * Timer callback routine: turn figurine into monster
  3. */
  4. void
  5. fig_transform(arg, timeout)
  6. genericptr_t arg;
  7. long timeout;
  8. {
  9. 	struct obj *figurine = (struct obj *)arg;
  10. 	struct monst *mtmp;
  11. 	coord cc;
  12. 	boolean cansee_spot, silent, okay_spot;
  13. 	boolean redraw = FALSE;
  14. 	char monnambuf[BUFSZ], carriedby[BUFSZ];
  15.  
  16. 	if (!figurine) {
  17. #ifdef DEBUG
  18. 	    pline("null figurine in fig_transform()");
  19. #endif
  20. 	    return;
  21. 	}
  22. 	silent = (timeout != monstermoves); /* happened while away */
  23. 	okay_spot = get_obj_location(figurine, &cc.x, &cc.y, 0);
  24. 	if (figurine->where == OBJ_INVENT ||
  25. 	    figurine->where == OBJ_MINVENT)
  26. 		okay_spot = enexto(&cc, cc.x, cc.y,
  27. 				   &mons[figurine->corpsenm]);
  28. 	if (!okay_spot ||
  29. 	    !figurine_location_checks(figurine,&cc, TRUE)) {
  30. 		/* reset the timer to try again later */
  31. 		(void) start_timer((long)rnd(5000), TIMER_OBJECT,
  32. 				FIG_TRANSFORM, (genericptr_t)figurine);
  33. 		return;
  34. 	}
  35.  
  36. 	cansee_spot = cansee(cc.x, cc.y);
  37. 	mtmp = make_familiar(figurine, cc.x, cc.y, TRUE);
  38. 	if (mtmp) {
  39. 	    Sprintf(monnambuf, "%s",an(m_monnam(mtmp)));
  40. 	    switch (figurine->where) {
  41. 		case OBJ_INVENT:
  42. 		    if (Blind)
  43. 			You_feel("%s %s from your pack!", something,
  44. 			    locomotion(mtmp->data,"drop"));
  45. 		    else
  46. 			You("see %s %s out of your pack!",
  47. 			    monnambuf,
  48. 			    locomotion(mtmp->data,"drop"));
  49. 		    break;
  50.  
  51. 		case OBJ_FLOOR:
  52. 		    if (cansee_spot && !silent) {
  53. 			You("suddenly see a figurine transform into %s!",
  54. 				monnambuf);
  55. 			redraw = TRUE;	/* update figurine's map location */
  56. 		    }
  57. 		    break;
  58.  
  59. 		case OBJ_MINVENT:
  60. 		    if (cansee_spot && !silent) {
  61. 			struct monst *mon;
  62. 			mon = figurine->ocarry;
  63. 			/* figurine carring monster might be invisible */
  64. 			if (canseemon(figurine->ocarry)) {
  65. 			    Sprintf(carriedby, "%s pack",
  66. 				     s_suffix(a_monnam(mon)));
  67. 			}
  68. 			else if (is_pool(mon->mx, mon->my))
  69. 			    Strcpy(carriedby, "empty water");
  70. 			else
  71. 			    Strcpy(carriedby, "thin air");
  72. 			You("see %s %s out of %s!", monnambuf,
  73. 			    locomotion(mtmp->data, "drop"), carriedby);
  74. 		    }
  75. 		    break;
  76. #if 0
  77. 		case OBJ_MIGRATING:
  78. 		    break;
  79. #endif
  80.  
  81. 		default:
  82. 		    impossible("figurine came to life where? (%d)",
  83. 				(int)figurine->where);
  84. 		break;
  85. 	    }
  86. 	}
  87. 	/* free figurine now */
  88. 	obj_extract_self(figurine);
  89. 	obfree(figurine, (struct obj *)0);
  90. 	if (redraw) newsym(cc.x, cc.y);
  91. }

figurine_location_checks

  1. STATIC_OVL boolean
  2. figurine_location_checks(obj, cc, quietly)
  3. struct obj *obj;
  4. coord *cc;
  5. boolean quietly;
  6. {
  7. 	xchar x,y;
  8.  
  9. 	if (carried(obj) && u.uswallow) {
  10. 		if (!quietly)
  11. 			You("don't have enough room in here.");
  12. 		return FALSE;
  13. 	}
  14. 	x = cc->x; y = cc->y;
  15. 	if (!isok(x,y)) {
  16. 		if (!quietly)
  17. 			You("cannot put the figurine there.");
  18. 		return FALSE;
  19. 	}
  20. 	if (IS_ROCK(levl[x][y].typ) &&
  21. 	    !(passes_walls(&mons[obj->corpsenm]) && may_passwall(x,y))) {
  22. 		if (!quietly)
  23. 		    You("cannot place a figurine in %s!",
  24. 			IS_TREE(levl[x][y].typ) ? "a tree" : "solid rock");
  25. 		return FALSE;
  26. 	}
  27. 	if (sobj_at(BOULDER,x,y) && !passes_walls(&mons[obj->corpsenm])
  28. 			&& !throws_rocks(&mons[obj->corpsenm])) {
  29. 		if (!quietly)
  30. 			You("cannot fit the figurine on the boulder.");
  31. 		return FALSE;
  32. 	}
  33. 	return TRUE;
  34. }

use_figurine

  1. STATIC_OVL void
  2. use_figurine(optr)
  3. struct obj **optr;
  4. {
  5. 	register struct obj *obj = *optr;
  6. 	xchar x, y;
  7. 	coord cc;
  8.  
  9. 	if (u.uswallow) {
  10. 		/* can't activate a figurine while swallowed */
  11. 		if (!figurine_location_checks(obj, (coord *)0, FALSE))
  12. 			return;
  13. 	}
  14. 	if(!getdir((char *)0)) {
  15. 		flags.move = multi = 0;
  16. 		return;
  17. 	}
  18. 	x = u.ux + u.dx; y = u.uy + u.dy;
  19. 	cc.x = x; cc.y = y;
  20. 	/* Passing FALSE arg here will result in messages displayed */
  21. 	if (!figurine_location_checks(obj, &cc, FALSE)) return;
  22. 	You("%s and it transforms.",
  23. 	    (u.dx||u.dy) ? "set the figurine beside you" :
  24. 	    (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ||
  25. 	     is_pool(cc.x, cc.y)) ?
  26. 		"release the figurine" :
  27. 	    (u.dz < 0 ?
  28. 		"toss the figurine into the air" :
  29. 		"set the figurine on the ground"));
  30. 	(void) make_familiar(obj, cc.x, cc.y, FALSE);
  31. 	(void) stop_timer(FIG_TRANSFORM, (genericptr_t)obj);
  32. 	useup(obj);
  33. 	*optr = 0;
  34. }

use_grease

  1. static NEARDATA const char lubricables[] = { ALL_CLASSES, ALLOW_NONE, 0 };
  2. static NEARDATA const char need_to_remove_outer_armor[] =
  3. 			"need to remove your %s to grease your %s.";
  4.  
  5. STATIC_OVL void
  6. use_grease(obj)
  7. struct obj *obj;
  8. {
  9. 	struct obj *otmp;
  10. 	char buf[BUFSZ];
  11.  
  12. 	if (Glib) {
  13. 	    pline("%s from your %s.", Tobjnam(obj, "slip"),
  14. 		  makeplural(body_part(FINGER)));
  15. 	    dropx(obj);
  16. 	    return;
  17. 	}
  18.  
  19. 	if (obj->spe > 0) {
  20. 		if ((obj->cursed || Fumbling) && !rn2(2)) {
  21. 			consume_obj_charge(obj, TRUE);
  22.  
  23. 			pline("%s from your %s.", Tobjnam(obj, "slip"),
  24. 			      makeplural(body_part(FINGER)));
  25. 			dropx(obj);
  26. 			return;
  27. 		}
  28. 		otmp = getobj(lubricables, "grease");
  29. 		if (!otmp) return;
  30. 		if ((otmp->owornmask & WORN_ARMOR) && uarmc) {
  31. 			Strcpy(buf, xname(uarmc));
  32. 			You(need_to_remove_outer_armor, buf, xname(otmp));
  33. 			return;
  34. 		}
  35. #ifdef TOURIST
  36. 		if ((otmp->owornmask & WORN_SHIRT) && (uarmc || uarm)) {
  37. 			Strcpy(buf, uarmc ? xname(uarmc) : "");
  38. 			if (uarmc && uarm) Strcat(buf, " and ");
  39. 			Strcat(buf, uarm ? xname(uarm) : "");
  40. 			You(need_to_remove_outer_armor, buf, xname(otmp));
  41. 			return;
  42. 		}
  43. #endif
  44. 		consume_obj_charge(obj, TRUE);
  45.  
  46. 		if (otmp != &zeroobj) {
  47. 			You("cover %s with a thick layer of grease.",
  48. 			    yname(otmp));
  49. 			otmp->greased = 1;
  50. 			if (obj->cursed && !nohands(youmonst.data)) {
  51. 			    incr_itimeout(&Glib, rnd(15));
  52. 			    pline("Some of the grease gets all over your %s.",
  53. 				makeplural(body_part(HAND)));
  54. 			}
  55. 		} else {
  56. 			Glib += rnd(15);
  57. 			You("coat your %s with grease.",
  58. 			    makeplural(body_part(FINGER)));
  59. 		}
  60. 	} else {
  61. 	    if (obj->known)
  62. 		pline("%s empty.", Tobjnam(obj, "are"));
  63. 	    else
  64. 		pline("%s to be empty.", Tobjnam(obj, "seem"));
  65. 	}
  66. 	update_inventory();
  67. }

reset_trapset

  1. static struct trapinfo {
  2. 	struct obj *tobj;
  3. 	xchar tx, ty;
  4. 	int time_needed;
  5. 	boolean force_bungle;
  6. } trapinfo;
  7.  
  8. void
  9. reset_trapset()
  10. {
  11. 	trapinfo.tobj = 0;
  12. 	trapinfo.force_bungle = 0;
  13. }

use_stone

  1. /* touchstones - by Ken Arnold */
  2. STATIC_OVL void
  3. use_stone(tstone)
  4. struct obj *tstone;
  5. {
  6. struct obj *obj;
  7. boolean do_scratch;
  8. const char *streak_color, *choices;
  9. char stonebuf[QBUFSZ];
  10. static const char scritch[] = "\"scritch, scritch\"";
  11. static const char allowall[3] = { COIN_CLASS, ALL_CLASSES, 0 };
  12. static const char justgems[3] = { ALLOW_NONE, GEM_CLASS, 0 };
  13. #ifndef GOLDOBJ
  14. struct obj goldobj;
  15. #endif
  16.  
  17. /* in case it was acquired while blinded */
  18. if (!Blind) tstone->dknown = 1;
  19. /* when the touchstone is fully known, don't bother listing extra
  20. junk as likely candidates for rubbing */
  21. choices = (tstone->otyp == TOUCHSTONE && tstone->dknown &&
  22. 		objects[TOUCHSTONE].oc_name_known) ? justgems : allowall;
  23. Sprintf(stonebuf, "rub on the stone%s", plur(tstone->quan));
  24. if ((obj = getobj(choices, stonebuf)) == 0)
  25. 	return;
  26. #ifndef GOLDOBJ
  27. if (obj->oclass == COIN_CLASS) {
  28. 	u.ugold += obj->quan;	/* keep botl up to date */
  29. 	goldobj = *obj;
  30. 	dealloc_obj(obj);
  31. 	obj = &goldobj;
  32. }
  33. #endif
  34.  
  35. if (obj == tstone && obj->quan == 1) {
  36. 	You_cant("rub %s on itself.", the(xname(obj)));
  37. 	return;
  38. }
  39.  
  40. if (tstone->otyp == TOUCHSTONE && tstone->cursed &&
  41. 	    obj->oclass == GEM_CLASS && !is_graystone(obj) &&
  42. 	    !obj_resists(obj, 80, 100)) {
  43. 	if (Blind)
  44. 	    pline("You feel something shatter.");
  45. 	else if (Hallucination)
  46. 	    pline("Oh, wow, look at the pretty shards.");
  47. 	else
  48. 	    pline("A sharp crack shatters %s%s.",
  49. 		  (obj->quan > 1) ? "one of " : "", the(xname(obj)));
  50. #ifndef GOLDOBJ
  51. /* assert(obj != &goldobj); */
  52. #endif
  53. 	useup(obj);
  54. 	return;
  55. }
  56.  
  57. if (Blind) {
  58. 	pline(scritch);
  59. 	return;
  60. } else if (Hallucination) {
  61. 	pline("Oh wow, man: Fractals!");
  62. 	return;
  63. }
  64.  
  65. do_scratch = FALSE;
  66. streak_color = 0;
  67.  
  68. switch (obj->oclass) {
  69. case GEM_CLASS:	/* these have class-specific handling below */
  70. case RING_CLASS:
  71. 	if (tstone->otyp != TOUCHSTONE) {
  72. 	    do_scratch = TRUE;
  73. 	} else if (obj->oclass == GEM_CLASS && (tstone->blessed ||
  74. 		(!tstone->cursed &&
  75. 		    (Role_if(PM_ARCHEOLOGIST) || Race_if(PM_GNOME))))) {
  76. 	    makeknown(TOUCHSTONE);
  77. 	    makeknown(obj->otyp);
  78. 	    prinv((char *)0, obj, 0L);
  79. 	    return;
  80. 	} else {
  81. 	    /* either a ring or the touchstone was not effective */
  82. 	    if (objects[obj->otyp].oc_material == GLASS) {
  83. 		do_scratch = TRUE;
  84. 		break;
  85. 	    }
  86. 	}
  87. 	streak_color = c_obj_colors[objects[obj->otyp].oc_color];
  88. 	break;		/* gem or ring */
  89.  
  90. default:
  91. 	switch (objects[obj->otyp].oc_material) {
  92. 	case CLOTH:
  93. 	    pline("%s a little more polished now.", Tobjnam(tstone, "look"));
  94. 	    return;
  95. 	case LIQUID:
  96. 	    if (!obj->known)		/* note: not "whetstone" */
  97. 		You("must think this is a wetstone, do you?");
  98. 	    else
  99. 		pline("%s a little wetter now.", Tobjnam(tstone, "are"));
  100. 	    return;
  101. 	case WAX:
  102. 	    streak_color = "waxy";
  103. 	    break;		/* okay even if not touchstone */
  104. 	case WOOD:
  105. 	    streak_color = "wooden";
  106. 	    break;		/* okay even if not touchstone */
  107. 	case GOLD:
  108. 	    do_scratch = TRUE;	/* scratching and streaks */
  109. 	    streak_color = "golden";
  110. 	    break;
  111. 	case SILVER:
  112. 	    do_scratch = TRUE;	/* scratching and streaks */
  113. 	    streak_color = "silvery";
  114. 	    break;
  115. 	default:
  116. 	    /* Objects passing the is_flimsy() test will not
  117. 	       scratch a stone.  They will leave streaks on
  118. 	       non-touchstones and touchstones alike. */
  119. 	    if (is_flimsy(obj))
  120. 		streak_color = c_obj_colors[objects[obj->otyp].oc_color];
  121. 	    else
  122. 		do_scratch = (tstone->otyp != TOUCHSTONE);
  123. 	    break;
  124. 	}
  125. 	break;		/* default oclass */
  126. }
  127.  
  128. Sprintf(stonebuf, "stone%s", plur(tstone->quan));
  129. if (do_scratch)
  130. 	pline("You make %s%sscratch marks on the %s.",
  131. 	      streak_color ? streak_color : (const char *)"",
  132. 	      streak_color ? " " : "", stonebuf);
  133. else if (streak_color)
  134. 	pline("You see %s streaks on the %s.", streak_color, stonebuf);
  135. else
  136. 	pline(scritch);
  137. return;
  138. }

use_trap

  1. /* Place a landmine/bear trap.  Helge Hafting */
  2. STATIC_OVL void
  3. use_trap(otmp)
  4. struct obj *otmp;
  5. {
  6. 	int ttyp, tmp;
  7. 	const char *what = (char *)0;
  8. 	char buf[BUFSZ];
  9. 	const char *occutext = "setting the trap";
  10.  
  11. 	if (nohands(youmonst.data))
  12. 	    what = "without hands";
  13. 	else if (Stunned)
  14. 	    what = "while stunned";
  15. 	else if (u.uswallow)
  16. 	    what = is_animal(u.ustuck->data) ? "while swallowed" :
  17. 			"while engulfed";
  18. 	else if (Underwater)
  19. 	    what = "underwater";
  20. 	else if (Levitation)
  21. 	    what = "while levitating";
  22. 	else if (is_pool(u.ux, u.uy))
  23. 	    what = "in water";
  24. 	else if (is_lava(u.ux, u.uy))
  25. 	    what = "in lava";
  26. 	else if (On_stairs(u.ux, u.uy))
  27. 	    what = (u.ux == xdnladder || u.ux == xupladder) ?
  28. 			"on the ladder" : "on the stairs";
  29. 	else if (IS_FURNITURE(levl[u.ux][u.uy].typ) ||
  30. 		IS_ROCK(levl[u.ux][u.uy].typ) ||
  31. 		closed_door(u.ux, u.uy) || t_at(u.ux, u.uy))
  32. 	    what = "here";
  33. 	if (what) {
  34. 	    You_cant("set a trap %s!",what);
  35. 	    reset_trapset();
  36. 	    return;
  37. 	}
  38. 	ttyp = (otmp->otyp == LAND_MINE) ? LANDMINE : BEAR_TRAP;
  39. 	if (otmp == trapinfo.tobj &&
  40. 		u.ux == trapinfo.tx && u.uy == trapinfo.ty) {
  41. 	    You("resume setting %s %s.",
  42. 		shk_your(buf, otmp),
  43. 		defsyms[trap_to_defsym(what_trap(ttyp))].explanation);
  44. 	    set_occupation(set_trap, occutext, 0);
  45. 	    return;
  46. 	}
  47. 	trapinfo.tobj = otmp;
  48. 	trapinfo.tx = u.ux,  trapinfo.ty = u.uy;
  49. 	tmp = ACURR(A_DEX);
  50. 	trapinfo.time_needed = (tmp > 17) ? 2 : (tmp > 12) ? 3 :
  51. 				(tmp > 7) ? 4 : 5;
  52. 	if (Blind) trapinfo.time_needed *= 2;
  53. 	tmp = ACURR(A_STR);
  54. 	if (ttyp == BEAR_TRAP && tmp < 18)
  55. 	    trapinfo.time_needed += (tmp > 12) ? 1 : (tmp > 7) ? 2 : 4;
  56. 	/*[fumbling and/or confusion and/or cursed object check(s)
  57. 	   should be incorporated here instead of in set_trap]*/
  58. #ifdef STEED
  59. 	if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) {
  60. 	    boolean chance;
  61.  
  62. 	    if (Fumbling || otmp->cursed) chance = (rnl(10) > 3);
  63. 	    else  chance = (rnl(10) > 5);
  64. 	    You("aren't very skilled at reaching from %s.",
  65. 		mon_nam(u.usteed));
  66. 	    Sprintf(buf, "Continue your attempt to set %s?",
  67. 		the(defsyms[trap_to_defsym(what_trap(ttyp))].explanation));
  68. 	    if(yn(buf) == 'y') {
  69. 		if (chance) {
  70. 			switch(ttyp) {
  71. 			    case LANDMINE:	/* set it off */
  72. 			    	trapinfo.time_needed = 0;
  73. 			    	trapinfo.force_bungle = TRUE;
  74. 				break;
  75. 			    case BEAR_TRAP:	/* drop it without arming it */
  76. 				reset_trapset();
  77. 				You("drop %s!",
  78. 			  the(defsyms[trap_to_defsym(what_trap(ttyp))].explanation));
  79. 				dropx(otmp);
  80. 				return;
  81. 			}
  82. 		}
  83. 	    } else {
  84. 	    	reset_trapset();
  85. 		return;
  86. 	    }
  87. 	}
  88. #endif
  89. 	You("begin setting %s %s.",
  90. 	    shk_your(buf, otmp),
  91. 	    defsyms[trap_to_defsym(what_trap(ttyp))].explanation);
  92. 	set_occupation(set_trap, occutext, 0);
  93. 	return;
  94. }

set_trap

  1. STATIC_PTR
  2. int
  3. set_trap()
  4. {
  5. 	struct obj *otmp = trapinfo.tobj;
  6. 	struct trap *ttmp;
  7. 	int ttyp;
  8.  
  9. 	if (!otmp || !carried(otmp) ||
  10. 		u.ux != trapinfo.tx || u.uy != trapinfo.ty) {
  11. 	    /* ?? */
  12. 	    reset_trapset();
  13. 	    return 0;
  14. 	}
  15.  
  16. 	if (--trapinfo.time_needed > 0) return 1;	/* still busy */
  17.  
  18. 	ttyp = (otmp->otyp == LAND_MINE) ? LANDMINE : BEAR_TRAP;
  19. 	ttmp = maketrap(u.ux, u.uy, ttyp);
  20. 	if (ttmp) {
  21. 	    ttmp->tseen = 1;
  22. 	    ttmp->madeby_u = 1;
  23. 	    newsym(u.ux, u.uy); /* if our hero happens to be invisible */
  24. 	    if (*in_rooms(u.ux,u.uy,SHOPBASE)) {
  25. 		add_damage(u.ux, u.uy, 0L);		/* schedule removal */
  26. 	    }
  27. 	    if (!trapinfo.force_bungle)
  28. 		You("finish arming %s.",
  29. 			the(defsyms[trap_to_defsym(what_trap(ttyp))].explanation));
  30. 	    if (((otmp->cursed || Fumbling) && (rnl(10) > 5)) || trapinfo.force_bungle)
  31. 		dotrap(ttmp,
  32. 			(unsigned)(trapinfo.force_bungle ? FORCEBUNGLE : 0));
  33. 	} else {
  34. 	    /* this shouldn't happen */
  35. 	    Your("trap setting attempt fails.");
  36. 	}
  37. 	useup(otmp);
  38. 	reset_trapset();
  39. 	return 0;
  40. }

use_whip

  1. STATIC_OVL int
  2. use_whip(obj)
  3. struct obj *obj;
  4. {
  5. char buf[BUFSZ];
  6. struct monst *mtmp;
  7. struct obj *otmp;
  8. int rx, ry, proficient, res = 0;
  9. const char *msg_slipsfree = "The bullwhip slips free.";
  10. const char *msg_snap = "Snap!";
  11.  
  12. if (obj != uwep) {
  13. 	if (!wield_tool(obj, "lash")) return 0;
  14. 	else res = 1;
  15. }
  16. if (!getdir((char *)0)) return res;
  17.  
  18. if (Stunned || (Confusion && !rn2(5))) confdir();
  19. rx = u.ux + u.dx;
  20. ry = u.uy + u.dy;
  21. mtmp = m_at(rx, ry);
  22.  
  23. /* fake some proficiency checks */
  24. proficient = 0;
  25. if (Role_if(PM_ARCHEOLOGIST)) ++proficient;
  26. if (ACURR(A_DEX) < 6) proficient--;
  27. else if (ACURR(A_DEX) >= 14) proficient += (ACURR(A_DEX) - 14);
  28. if (Fumbling) --proficient;
  29. if (proficient > 3) proficient = 3;
  30. if (proficient < 0) proficient = 0;
  31.  
  32. if (u.uswallow && attack(u.ustuck)) {
  33. 	There("is not enough room to flick your bullwhip.");
  34.  
  35. } else if (Underwater) {
  36. 	There("is too much resistance to flick your bullwhip.");
  37.  
  38. } else if (u.dz < 0) {
  39. 	You("flick a bug off of the %s.",ceiling(u.ux,u.uy));
  40.  
  41. } else if ((!u.dx && !u.dy) || (u.dz > 0)) {
  42. 	int dam;
  43.  
  44. #ifdef STEED
  45. 	/* Sometimes you hit your steed by mistake */
  46. 	if (u.usteed && !rn2(proficient + 2)) {
  47. 	    You("whip %s!", mon_nam(u.usteed));
  48. 	    kick_steed();
  49. 	    return 1;
  50. 	}
  51. #endif
  52. 	if (Levitation
  53. #ifdef STEED
  54. 			|| u.usteed
  55. #endif
  56. 		) {
  57. 	    /* Have a shot at snaring something on the floor */
  58. 	    otmp = level.objects[u.ux][u.uy];
  59. 	    if (otmp && otmp->otyp == CORPSE && otmp->corpsenm == PM_HORSE) {
  60. 		pline("Why beat a dead horse?");
  61. 		return 1;
  62. 	    }
  63. 	    if (otmp && proficient) {
  64. 		You("wrap your bullwhip around %s on the %s.",
  65. 		    an(singular(otmp, xname)), surface(u.ux, u.uy));
  66. 		if (rnl(6) || pickup_object(otmp, 1L, TRUE) < 1)
  67. 		    pline(msg_slipsfree);
  68. 		return 1;
  69. 	    }
  70. 	}
  71. 	dam = rnd(2) + dbon() + obj->spe;
  72. 	if (dam <= 0) dam = 1;
  73. 	You("hit your %s with your bullwhip.", body_part(FOOT));
  74. 	Sprintf(buf, "killed %sself with %s bullwhip", uhim(), uhis());
  75. 	losehp(dam, buf, NO_KILLER_PREFIX);
  76. 	flags.botl = 1;
  77. 	return 1;
  78.  
  79. } else if ((Fumbling || Glib) && !rn2(5)) {
  80. 	pline_The("bullwhip slips out of your %s.", body_part(HAND));
  81. 	dropx(obj);
  82.  
  83. } else if (u.utrap && u.utraptype == TT_PIT) {
  84. 	/*
  85. 	 *     Assumptions:
  86. 	 *
  87. 	 *	if you're in a pit
  88. 	 *		- you are attempting to get out of the pit
  89. 	 *		- or, if you are applying it towards a small
  90. 	 *		  monster then it is assumed that you are
  91. 	 *		  trying to hit it.
  92. 	 *	else if the monster is wielding a weapon
  93. 	 *		- you are attempting to disarm a monster
  94. 	 *	else
  95. 	 *		- you are attempting to hit the monster
  96. 	 *
  97. 	 *	if you're confused (and thus off the mark)
  98. 	 *		- you only end up hitting.
  99. 	 *
  100. 	 */
  101. 	const char *wrapped_what = (char *)0;
  102.  
  103. 	if (mtmp) {
  104. 	    if (bigmonst(mtmp->data)) {
  105. 		wrapped_what = strcpy(buf, mon_nam(mtmp));
  106. 	    } else if (proficient) {
  107. 		if (attack(mtmp)) return 1;
  108. 		else pline(msg_snap);
  109. 	    }
  110. 	}
  111. 	if (!wrapped_what) {
  112. 	    if (IS_FURNITURE(levl[rx][ry].typ))
  113. 		wrapped_what = something;
  114. 	    else if (sobj_at(BOULDER, rx, ry))
  115. 		wrapped_what = "a boulder";
  116. 	}
  117. 	if (wrapped_what) {
  118. 	    coord cc;
  119.  
  120. 	    cc.x = rx; cc.y = ry;
  121. 	    You("wrap your bullwhip around %s.", wrapped_what);
  122. 	    if (proficient && rn2(proficient + 2)) {
  123. 		if (!mtmp || enexto(&cc, rx, ry, youmonst.data)) {
  124. 		    You("yank yourself out of the pit!");
  125. 		    teleds(cc.x, cc.y, TRUE);
  126. 		    u.utrap = 0;
  127. 		    vision_full_recalc = 1;
  128. 		}
  129. 	    } else {
  130. 		pline(msg_slipsfree);
  131. 	    }
  132. 	    if (mtmp) wakeup(mtmp);
  133. 	} else pline(msg_snap);
  134.  
  135. } else if (mtmp) {
  136. 	if (!canspotmon(mtmp) &&
  137. 		!glyph_is_invisible(levl[rx][ry].glyph)) {
  138. 	   pline("A monster is there that you couldn't see.");
  139. 	   map_invisible(rx, ry);
  140. 	}
  141. 	otmp = MON_WEP(mtmp);	/* can be null */
  142. 	if (otmp) {
  143. 	    char onambuf[BUFSZ];
  144. 	    const char *mon_hand;
  145. 	    boolean gotit = proficient && (!Fumbling || !rn2(10));
  146.  
  147. 	    Strcpy(onambuf, cxname(otmp));
  148. 	    if (gotit) {
  149. 		mon_hand = mbodypart(mtmp, HAND);
  150. 		if (bimanual(otmp)) mon_hand = makeplural(mon_hand);
  151. 	    } else
  152. 		mon_hand = 0;	/* lint suppression */
  153.  
  154. 	    You("wrap your bullwhip around %s %s.",
  155. 		s_suffix(mon_nam(mtmp)), onambuf);
  156. 	    if (gotit && otmp->cursed) {
  157. 		pline("%s welded to %s %s%c",
  158. 		      (otmp->quan == 1L) ? "It is" : "They are",
  159. 		      mhis(mtmp), mon_hand,
  160. 		      !otmp->bknown ? '!' : '.');
  161. 		otmp->bknown = 1;
  162. 		gotit = FALSE;	/* can't pull it free */
  163. 	    }
  164. 	    if (gotit) {
  165. 		obj_extract_self(otmp);
  166. 		possibly_unwield(mtmp, FALSE);
  167. 		setmnotwielded(mtmp,otmp);
  168.  
  169. 		switch (rn2(proficient + 1)) {
  170. 		case 2:
  171. 		    /* to floor near you */
  172. 		    You("yank %s %s to the %s!", s_suffix(mon_nam(mtmp)),
  173. 			onambuf, surface(u.ux, u.uy));
  174. 		    place_object(otmp, u.ux, u.uy);
  175. 		    stackobj(otmp);
  176. 		    break;
  177. 		case 3:
  178. 		    /* right to you */
  179. #if 0
  180. 		    if (!rn2(25)) {
  181. 			/* proficient with whip, but maybe not
  182. 			   so proficient at catching weapons */
  183. 			int hitu, hitvalu;
  184.  
  185. 			hitvalu = 8 + otmp->spe;
  186. 			hitu = thitu(hitvalu,
  187. 				     dmgval(otmp, &youmonst),
  188. 				     otmp, (char *)0);
  189. 			if (hitu) {
  190. 			    pline_The("%s hits you as you try to snatch it!",
  191. 				the(onambuf));
  192. 			}
  193. 			place_object(otmp, u.ux, u.uy);
  194. 			stackobj(otmp);
  195. 			break;
  196. 		    }
  197. #endif /* 0 */
  198. 		    /* right into your inventory */
  199. 		    You("snatch %s %s!", s_suffix(mon_nam(mtmp)), onambuf);
  200. 		    if (otmp->otyp == CORPSE &&
  201. 			    touch_petrifies(&mons[otmp->corpsenm]) &&
  202. 			    !uarmg && !Stone_resistance &&
  203. 			    !(poly_when_stoned(youmonst.data) &&
  204. 				polymon(PM_STONE_GOLEM))) {
  205. 			char kbuf[BUFSZ];
  206.  
  207. 			Sprintf(kbuf, "%s corpse",
  208. 				an(mons[otmp->corpsenm].mname));
  209. 			pline("Snatching %s is a fatal mistake.", kbuf);
  210. 			instapetrify(kbuf);
  211. 		    }
  212. 		    otmp = hold_another_object(otmp, "You drop %s!",
  213. 					       doname(otmp), (const char *)0);
  214. 		    break;
  215. 		default:
  216. 		    /* to floor beneath mon */
  217. 		    You("yank %s from %s %s!", the(onambuf),
  218. 			s_suffix(mon_nam(mtmp)), mon_hand);
  219. 		    obj_no_longer_held(otmp);
  220. 		    place_object(otmp, mtmp->mx, mtmp->my);
  221. 		    stackobj(otmp);
  222. 		    break;
  223. 		}
  224. 	    } else {
  225. 		pline(msg_slipsfree);
  226. 	    }
  227. 	    wakeup(mtmp);
  228. 	} else {
  229. 	    if (mtmp->m_ap_type &&
  230. 		!Protection_from_shape_changers && !sensemon(mtmp))
  231. 		stumble_onto_mimic(mtmp);
  232. 	    else You("flick your bullwhip towards %s.", mon_nam(mtmp));
  233. 	    if (proficient) {
  234. 		if (attack(mtmp)) return 1;
  235. 		else pline(msg_snap);
  236. 	    }
  237. 	}
  238.  
  239. } else if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) {
  240. 	    /* it must be air -- water checked above */
  241. 	    You("snap your whip through thin air.");
  242.  
  243. } else {
  244. 	pline(msg_snap);
  245.  
  246. }
  247. return 1;
  248. }

use_pole

  1. static const char
  2. 	not_enough_room[] = "There's not enough room here to use that.",
  3. 	where_to_hit[] = "Where do you want to hit?",
  4. 	cant_see_spot[] = "won't hit anything if you can't see that spot.",
  5. 	cant_reach[] = "can't reach that spot from here.";
  6.  
  7. /* Distance attacks by pole-weapons */
  8. STATIC_OVL int
  9. use_pole (obj)
  10. 	struct obj *obj;
  11. {
  12. 	int res = 0, typ, max_range = 4, min_range = 4;
  13. 	coord cc;
  14. 	struct monst *mtmp;
  15.  
  16.  
  17. 	/* Are you allowed to use the pole? */
  18. 	if (u.uswallow) {
  19. 	    pline(not_enough_room);
  20. 	    return (0);
  21. 	}
  22. 	if (obj != uwep) {
  23. 	    if (!wield_tool(obj, "swing")) return(0);
  24. 	    else res = 1;
  25. 	}
  26. /* assert(obj == uwep); */
  27.  
  28. 	/* Prompt for a location */
  29. 	pline(where_to_hit);
  30. 	cc.x = u.ux;
  31. 	cc.y = u.uy;
  32. 	if (getpos(&cc, TRUE, "the spot to hit") < 0)
  33. 	    return 0;	/* user pressed ESC */
  34.  
  35. 	/* Calculate range */
  36. 	typ = uwep_skill_type();
  37. 	if (typ == P_NONE || P_SKILL(typ) <= P_BASIC) max_range = 4;
  38. 	else if (P_SKILL(typ) == P_SKILLED) max_range = 5;
  39. 	else max_range = 8;
  40. 	if (distu(cc.x, cc.y) > max_range) {
  41. 	    pline("Too far!");
  42. 	    return (res);
  43. 	} else if (distu(cc.x, cc.y) < min_range) {
  44. 	    pline("Too close!");
  45. 	    return (res);
  46. 	} else if (!cansee(cc.x, cc.y) &&
  47. 		   ((mtmp = m_at(cc.x, cc.y)) == (struct monst *)0 ||
  48. 		    !canseemon(mtmp))) {
  49. 	    You(cant_see_spot);
  50. 	    return (res);
  51. 	} else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */
  52. 	    You(cant_reach);
  53. 	    return res;
  54. 	}
  55.  
  56. 	/* Attack the monster there */
  57. 	if ((mtmp = m_at(cc.x, cc.y)) != (struct monst *)0) {
  58. 	    int oldhp = mtmp->mhp;
  59.  
  60. 	    bhitpos = cc;
  61. 	    check_caitiff(mtmp);
  62. 	    (void) thitmonst(mtmp, uwep);
  63. 	    /* check the monster's HP because thitmonst() doesn't return
  64. 	     * an indication of whether it hit.  Not perfect (what if it's a
  65. 	     * non-silver weapon on a shade?)
  66. 	     */
  67. 	    if (mtmp->mhp < oldhp)
  68. 		u.uconduct.weaphit++;
  69. 	} else
  70. 	    /* Now you know that nothing is there... */
  71. 	    pline(nothing_happens);
  72. 	return (1);
  73. }

use_cream_pie

  1. STATIC_OVL int
  2. use_cream_pie(obj)
  3. struct obj *obj;
  4. {
  5. 	boolean wasblind = Blind;
  6. 	boolean wascreamed = u.ucreamed;
  7. 	boolean several = FALSE;
  8.  
  9. 	if (obj->quan > 1L) {
  10. 		several = TRUE;
  11. 		obj = splitobj(obj, 1L);
  12. 	}
  13. 	if (Hallucination)
  14. 		You("give yourself a facial.");
  15. 	else
  16. 		pline("You immerse your %s in %s%s.", body_part(FACE),
  17. 			several ? "one of " : "",
  18. 			several ? makeplural(the(xname(obj))) : the(xname(obj)));
  19. 	if(can_blnd((struct monst*)0, &youmonst, AT_WEAP, obj)) {
  20. 		int blindinc = rnd(25);
  21. 		u.ucreamed += blindinc;
  22. 		make_blinded(Blinded + (long)blindinc, FALSE);
  23. 		if (!Blind || (Blind && wasblind))
  24. 			pline("There's %ssticky goop all over your %s.",
  25. 				wascreamed ? "more " : "",
  26. 				body_part(FACE));
  27. 		else /* Blind  && !wasblind */
  28. 			You_cant("see through all the sticky goop on your %s.",
  29. 				body_part(FACE));
  30. 	}
  31. 	if (obj->unpaid) {
  32. 		verbalize("You used it, you bought it!");
  33. 		bill_dummy_object(obj);
  34. 	}
  35. 	obj_extract_self(obj);
  36. 	delobj(obj);
  37. 	return(0);
  38. }

use_grapple

  1. STATIC_OVL int
  2. use_grapple (obj)
  3. 	struct obj *obj;
  4. {
  5. 	int res = 0, typ, max_range = 4, tohit;
  6. 	coord cc;
  7. 	struct monst *mtmp;
  8. 	struct obj *otmp;
  9.  
  10. 	/* Are you allowed to use the hook? */
  11. 	if (u.uswallow) {
  12. 	    pline(not_enough_room);
  13. 	    return (0);
  14. 	}
  15. 	if (obj != uwep) {
  16. 	    if (!wield_tool(obj, "cast")) return(0);
  17. 	    else res = 1;
  18. 	}
  19. /* assert(obj == uwep); */
  20.  
  21. 	/* Prompt for a location */
  22. 	pline(where_to_hit);
  23. 	cc.x = u.ux;
  24. 	cc.y = u.uy;
  25. 	if (getpos(&cc, TRUE, "the spot to hit") < 0)
  26. 	    return 0;	/* user pressed ESC */
  27.  
  28. 	/* Calculate range */
  29. 	typ = uwep_skill_type();
  30. 	if (typ == P_NONE || P_SKILL(typ) <= P_BASIC) max_range = 4;
  31. 	else if (P_SKILL(typ) == P_SKILLED) max_range = 5;
  32. 	else max_range = 8;
  33. 	if (distu(cc.x, cc.y) > max_range) {
  34. 	    pline("Too far!");
  35. 	    return (res);
  36. 	} else if (!cansee(cc.x, cc.y)) {
  37. 	    You(cant_see_spot);
  38. 	    return (res);
  39. 	} else if (!couldsee(cc.x, cc.y)) { /* Eyes of the Overworld */
  40. 	    You(cant_reach);
  41. 	    return res;
  42. 	}
  43.  
  44. 	/* What do you want to hit? */
  45. 	tohit = rn2(5);
  46. 	if (typ != P_NONE && P_SKILL(typ) >= P_SKILLED) {
  47. 	    winid tmpwin = create_nhwindow(NHW_MENU);
  48. 	    anything any;
  49. 	    char buf[BUFSZ];
  50. 	    menu_item *selected;
  51.  
  52. 	    any.a_void = 0;	/* set all bits to zero */
  53. 	    any.a_int = 1;	/* use index+1 (cant use 0) as identifier */
  54. 	    start_menu(tmpwin);
  55. 	    any.a_int++;
  56. 	    Sprintf(buf, "an object on the %s", surface(cc.x, cc.y));
  57. 	    add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
  58. 			 buf, MENU_UNSELECTED);
  59. 	    any.a_int++;
  60. 	    add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
  61. 			"a monster", MENU_UNSELECTED);
  62. 	    any.a_int++;
  63. 	    Sprintf(buf, "the %s", surface(cc.x, cc.y));
  64. 	    add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
  65. 			 buf, MENU_UNSELECTED);
  66. 	    end_menu(tmpwin, "Aim for what?");
  67. 	    tohit = rn2(4);
  68. 	    if (select_menu(tmpwin, PICK_ONE, &selected) > 0 &&
  69. 			rn2(P_SKILL(typ) > P_SKILLED ? 20 : 2))
  70. 		tohit = selected[0].item.a_int - 1;
  71. 	    free((genericptr_t)selected);
  72. 	    destroy_nhwindow(tmpwin);
  73. 	}
  74.  
  75. 	/* What did you hit? */
  76. 	switch (tohit) {
  77. 	case 0:	/* Trap */
  78. 	    /* FIXME -- untrap needs to deal with non-adjacent traps */
  79. 	    break;
  80. 	case 1:	/* Object */
  81. 	    if ((otmp = level.objects[cc.x][cc.y]) != 0) {
  82. 		You("snag an object from the %s!", surface(cc.x, cc.y));
  83. 		(void) pickup_object(otmp, 1L, FALSE);
  84. 		/* If pickup fails, leave it alone */
  85. 		newsym(cc.x, cc.y);
  86. 		return (1);
  87. 	    }
  88. 	    break;
  89. 	case 2:	/* Monster */
  90. 	    if ((mtmp = m_at(cc.x, cc.y)) == (struct monst *)0) break;
  91. 	    if (verysmall(mtmp->data) && !rn2(4) &&
  92. 			enexto(&cc, u.ux, u.uy, (struct permonst *)0)) {
  93. 		You("pull in %s!", mon_nam(mtmp));
  94. 		mtmp->mundetected = 0;
  95. 		rloc_to(mtmp, cc.x, cc.y);
  96. 		return (1);
  97. 	    } else if ((!bigmonst(mtmp->data) && !strongmonst(mtmp->data)) ||
  98. 		       rn2(4)) {
  99. 		(void) thitmonst(mtmp, uwep);
  100. 		return (1);
  101. 	    }
  102. 	    /* FALL THROUGH */
  103. 	case 3:	/* Surface */
  104. 	    if (IS_AIR(levl[cc.x][cc.y].typ) || is_pool(cc.x, cc.y))
  105. 		pline_The("hook slices through the %s.", surface(cc.x, cc.y));
  106. 	    else {
  107. 		You("are yanked toward the %s!", surface(cc.x, cc.y));
  108. 		hurtle(sgn(cc.x-u.ux), sgn(cc.y-u.uy), 1, FALSE);
  109. 		spoteffects(TRUE);
  110. 	    }
  111. 	    return (1);
  112. 	default:	/* Yourself (oops!) */
  113. 	    if (P_SKILL(typ) <= P_BASIC) {
  114. 		You("hook yourself!");
  115. 		losehp(rn1(10,10), "a grappling hook", KILLED_BY);
  116. 		return (1);
  117. 	    }
  118. 	    break;
  119. 	}
  120. 	pline(nothing_happens);
  121. 	return (1);
  122. }

do_break_wand

  1. #define BY_OBJECT	((struct monst *)0)
  2.  
  3. /* return 1 if the wand is broken, hence some time elapsed */
  4. STATIC_OVL int
  5. do_break_wand(obj)
  6. struct obj *obj;
  7. {
  8. static const char nothing_else_happens[] = "But nothing else happens...";
  9. register int i, x, y;
  10. register struct monst *mon;
  11. int dmg, damage;
  12. boolean affects_objects;
  13. boolean shop_damage = FALSE;
  14. int expltype = EXPL_MAGICAL;
  15. char confirm[QBUFSZ], the_wand[BUFSZ], buf[BUFSZ];
  16.  
  17. Strcpy(the_wand, yname(obj));
  18. Sprintf(confirm, "Are you really sure you want to break %s?",
  19. 	safe_qbuf("", sizeof("Are you really sure you want to break ?"),
  20. 				the_wand, ysimple_name(obj), "the wand"));
  21. if (yn(confirm) == 'n' ) return 0;
  22.  
  23. if (nohands(youmonst.data)) {
  24. 	You_cant("break %s without hands!", the_wand);
  25. 	return 0;
  26. } else if (ACURR(A_STR) < 10) {
  27. 	You("don't have the strength to break %s!", the_wand);
  28. 	return 0;
  29. }
  30. pline("Raising %s high above your %s, you break it in two!",
  31. 	  the_wand, body_part(HEAD));
  32.  
  33. /* [ALI] Do this first so that wand is removed from bill. Otherwise,
  34. * the freeinv() below also hides it from setpaid() which causes problems.
  35. */
  36. if (obj->unpaid) {
  37. 	check_unpaid(obj);		/* Extra charge for use */
  38. 	bill_dummy_object(obj);
  39. }
  40.  
  41. current_wand = obj;		/* destroy_item might reset this */
  42. freeinv(obj);		/* hide it from destroy_item instead... */
  43. setnotworn(obj);		/* so we need to do this ourselves */
  44.  
  45. if (obj->spe <= 0) {
  46. 	pline(nothing_else_happens);
  47. 	goto discard_broken_wand;
  48. }
  49. obj->ox = u.ux;
  50. obj->oy = u.uy;
  51. dmg = obj->spe * 4;
  52. affects_objects = FALSE;
  53.  
  54. switch (obj->otyp) {
  55. case WAN_WISHING:
  56. case WAN_NOTHING:
  57. case WAN_LOCKING:
  58. case WAN_PROBING:
  59. case WAN_ENLIGHTENMENT:
  60. case WAN_OPENING:
  61. case WAN_SECRET_DOOR_DETECTION:
  62. 	pline(nothing_else_happens);
  63. 	goto discard_broken_wand;
  64. case WAN_DEATH:
  65. case WAN_LIGHTNING:
  66. 	dmg *= 4;
  67. 	goto wanexpl;
  68. case WAN_FIRE:
  69. 	expltype = EXPL_FIERY;
  70. case WAN_COLD:
  71. 	if (expltype == EXPL_MAGICAL) expltype = EXPL_FROSTY;
  72. 	dmg *= 2;
  73. case WAN_MAGIC_MISSILE:
  74. wanexpl:
  75. 	explode(u.ux, u.uy,
  76. 		(obj->otyp - WAN_MAGIC_MISSILE), dmg, WAND_CLASS, expltype);
  77. 	makeknown(obj->otyp);	/* explode described the effect */
  78. 	goto discard_broken_wand;
  79. case WAN_STRIKING:
  80. 	/* we want this before the explosion instead of at the very end */
  81. 	pline("A wall of force smashes down around you!");
  82. 	dmg = d(1 + obj->spe,6);	/* normally 2d12 */
  83. case WAN_CANCELLATION:
  84. case WAN_POLYMORPH:
  85. case WAN_TELEPORTATION:
  86. case WAN_UNDEAD_TURNING:
  87. 	affects_objects = TRUE;
  88. 	break;
  89. default:
  90. 	break;
  91. }
  92.  
  93. /* magical explosion and its visual effect occur before specific effects */
  94. explode(obj->ox, obj->oy, 0, rnd(dmg), WAND_CLASS, EXPL_MAGICAL);
  95.  
  96. /* this makes it hit us last, so that we can see the action first */
  97. for (i = 0; i <= 8; i++) {
  98. 	bhitpos.x = x = obj->ox + xdir[i];
  99. 	bhitpos.y = y = obj->oy + ydir[i];
  100. 	if (!isok(x,y)) continue;
  101.  
  102. 	if (obj->otyp == WAN_DIGGING) {
  103. 	    if(dig_check(BY_OBJECT, FALSE, x, y)) {
  104. 		if (IS_WALL(levl[x][y].typ) || IS_DOOR(levl[x][y].typ)) {
  105. 		    /* normally, pits and holes don't anger guards, but they
  106. 		     * do if it's a wall or door that's being dug */
  107. 		    watch_dig((struct monst *)0, x, y, TRUE);
  108. 		    if (*in_rooms(x,y,SHOPBASE)) shop_damage = TRUE;
  109. 		}		    
  110. 		digactualhole(x, y, BY_OBJECT,
  111. 			      (rn2(obj->spe) < 3 || !Can_dig_down(&u.uz)) ?
  112. 			       PIT : HOLE);
  113. 	    }
  114. 	    continue;
  115. 	} else if(obj->otyp == WAN_CREATE_MONSTER) {
  116. 	    /* u.ux,u.uy creates it near you--x,y might create it in rock */
  117. 	    (void) makemon((struct permonst *)0, u.ux, u.uy, NO_MM_FLAGS);
  118. 	    continue;
  119. 	} else {
  120. 	    if (x == u.ux && y == u.uy) {
  121. 		/* teleport objects first to avoid race with tele control and
  122. 		   autopickup.  Other wand/object effects handled after
  123. 		   possible wand damage is assessed */
  124. 		if (obj->otyp == WAN_TELEPORTATION &&
  125. 		    affects_objects && level.objects[x][y]) {
  126. 		    (void) bhitpile(obj, bhito, x, y);
  127. 		    if (flags.botl) bot();		/* potion effects */
  128. 		}
  129. 		damage = zapyourself(obj, FALSE);
  130. 		if (damage) {
  131. 		    Sprintf(buf, "killed %sself by breaking a wand", uhim());
  132. 		    losehp(damage, buf, NO_KILLER_PREFIX);
  133. 		}
  134. 		if (flags.botl) bot();		/* blindness */
  135. 	    } else if ((mon = m_at(x, y)) != 0) {
  136. 		(void) bhitm(mon, obj);
  137. 	     /* if (flags.botl) bot(); */
  138. 	    }
  139. 	    if (affects_objects && level.objects[x][y]) {
  140. 		(void) bhitpile(obj, bhito, x, y);
  141. 		if (flags.botl) bot();		/* potion effects */
  142. 	    }
  143. 	}
  144. }
  145.  
  146. /* Note: if player fell thru, this call is a no-op.
  147. Damage is handled in digactualhole in that case */
  148. if (shop_damage) pay_for_damage("dig into", FALSE);
  149.  
  150. if (obj->otyp == WAN_LIGHT)
  151. 	litroom(TRUE, obj);	/* only needs to be done once */
  152.  
  153. discard_broken_wand:
  154. obj = current_wand;		/* [see dozap() and destroy_item()] */
  155. current_wand = 0;
  156. if (obj)
  157. 	delobj(obj);
  158. nomul(0);
  159. return 1;
  160. }

uhave_graystone

  1. STATIC_OVL boolean
  2. uhave_graystone()
  3. {
  4. 	register struct obj *otmp;
  5.  
  6. 	for(otmp = invent; otmp; otmp = otmp->nobj)
  7. 		if(is_graystone(otmp))
  8. 			return TRUE;
  9. 	return FALSE;
  10. }

add_class

  1. STATIC_OVL void
  2. add_class(cl, class)
  3. char *cl;
  4. char class;
  5. {
  6. 	char tmp[2];
  7. 	tmp[0] = class;
  8. 	tmp[1] = '\0';
  9. 	Strcat(cl, tmp);
  10. }

doapply

  1. int
  2. doapply()
  3. {
  4. 	struct obj *obj;
  5. 	register int res = 1;
  6. 	char class_list[MAXOCLASSES+2];
  7.  
  8. 	if(check_capacity((char *)0)) return (0);
  9.  
  10. 	if (carrying(POT_OIL) || uhave_graystone())
  11. 		Strcpy(class_list, tools_too);
  12. 	else
  13. 		Strcpy(class_list, tools);
  14. 	if (carrying(CREAM_PIE) || carrying(EUCALYPTUS_LEAF))
  15. 		add_class(class_list, FOOD_CLASS);
  16.  
  17. 	obj = getobj(class_list, "use or apply");
  18. 	if(!obj) return 0;
  19.  
  20. 	if (obj->oartifact && !touch_artifact(obj, &youmonst))
  21. 	    return 1;	/* evading your grasp costs a turn; just be
  22. 			   grateful that you don't drop it as well */
  23.  
  24. 	if (obj->oclass == WAND_CLASS)
  25. 	    return do_break_wand(obj);
  26.  
  27. 	switch(obj->otyp){
  28. 	case BLINDFOLD:
  29. 	case LENSES:
  30. 		if (obj == ublindf) {
  31. 		    if (!cursed(obj)) Blindf_off(obj);
  32. 		} else if (!ublindf)
  33. 		    Blindf_on(obj);
  34. 		else You("are already %s.",
  35. 			ublindf->otyp == TOWEL ?     "covered by a towel" :
  36. 			ublindf->otyp == BLINDFOLD ? "wearing a blindfold" :
  37. 						     "wearing lenses");
  38. 		break;
  39. 	case CREAM_PIE:
  40. 		res = use_cream_pie(obj);
  41. 		break;
  42. 	case BULLWHIP:
  43. 		res = use_whip(obj);
  44. 		break;
  45. 	case GRAPPLING_HOOK:
  46. 		res = use_grapple(obj);
  47. 		break;
  48. 	case LARGE_BOX:
  49. 	case CHEST:
  50. 	case ICE_BOX:
  51. 	case SACK:
  52. 	case BAG_OF_HOLDING:
  53. 	case OILSKIN_SACK:
  54. 		res = use_container(obj, 1);
  55. 		break;
  56. 	case BAG_OF_TRICKS:
  57. 		bagotricks(obj);
  58. 		break;
  59. 	case CAN_OF_GREASE:
  60. 		use_grease(obj);
  61. 		break;
  62. 	case LOCK_PICK:
  63. #ifdef TOURIST
  64. 	case CREDIT_CARD:
  65. #endif
  66. 	case SKELETON_KEY:
  67. 		(void) pick_lock(obj);
  68. 		break;
  69. 	case PICK_AXE:
  70. 	case DWARVISH_MATTOCK:
  71. 		res = use_pick_axe(obj);
  72. 		break;
  73. 	case TINNING_KIT:
  74. 		use_tinning_kit(obj);
  75. 		break;
  76. 	case LEASH:
  77. 		use_leash(obj);
  78. 		break;
  79. #ifdef STEED
  80. 	case SADDLE:
  81. 		res = use_saddle(obj);
  82. 		break;
  83. #endif
  84. 	case MAGIC_WHISTLE:
  85. 		use_magic_whistle(obj);
  86. 		break;
  87. 	case TIN_WHISTLE:
  88. 		use_whistle(obj);
  89. 		break;
  90. 	case EUCALYPTUS_LEAF:
  91. 		/* MRKR: Every Australian knows that a gum leaf makes an */
  92. 		/*	 excellent whistle, especially if your pet is a  */
  93. 		/*	 tame kangaroo named Skippy.			 */
  94. 		if (obj->blessed) {
  95. 		    use_magic_whistle(obj);
  96. 		    /* sometimes the blessing will be worn off */
  97. 		    if (!rn2(49)) {
  98. 			if (!Blind) {
  99. 			    char buf[BUFSZ];
  100.  
  101. 			    pline("%s %s %s.", Shk_Your(buf, obj),
  102. 				  aobjnam(obj, "glow"), hcolor("brown"));
  103. 			    obj->bknown = 1;
  104. 			}
  105. 			unbless(obj);
  106. 		    }
  107. 		} else {
  108. 		    use_whistle(obj);
  109. 		}
  110. 		break;
  111. 	case STETHOSCOPE:
  112. 		res = use_stethoscope(obj);
  113. 		break;
  114. 	case MIRROR:
  115. 		res = use_mirror(obj);
  116. 		break;
  117. 	case BELL:
  118. 	case BELL_OF_OPENING:
  119. 		use_bell(&obj);
  120. 		break;
  121. 	case CANDELABRUM_OF_INVOCATION:
  122. 		use_candelabrum(obj);
  123. 		break;
  124. 	case WAX_CANDLE:
  125. 	case TALLOW_CANDLE:
  126. 		use_candle(&obj);
  127. 		break;
  128. 	case OIL_LAMP:
  129. 	case MAGIC_LAMP:
  130. 	case BRASS_LANTERN:
  131. 		use_lamp(obj);
  132. 		break;
  133. 	case POT_OIL:
  134. 		light_cocktail(obj);
  135. 		break;
  136. #ifdef TOURIST
  137. 	case EXPENSIVE_CAMERA:
  138. 		res = use_camera(obj);
  139. 		break;
  140. #endif
  141. 	case TOWEL:
  142. 		res = use_towel(obj);
  143. 		break;
  144. 	case CRYSTAL_BALL:
  145. 		use_crystal_ball(obj);
  146. 		break;
  147. 	case MAGIC_MARKER:
  148. 		res = dowrite(obj);
  149. 		break;
  150. 	case TIN_OPENER:
  151. 		if(!carrying(TIN)) {
  152. 			You("have no tin to open.");
  153. 			goto xit;
  154. 		}
  155. 		You("cannot open a tin without eating or discarding its contents.");
  156. 		if(flags.verbose)
  157. 			pline("In order to eat, use the 'e' command.");
  158. 		if(obj != uwep)
  159. pline("Opening the tin will be much easier if you wield the tin opener.");
  160. 		goto xit;
  161.  
  162. 	case FIGURINE:
  163. 		use_figurine(&obj);
  164. 		break;
  165. 	case UNICORN_HORN:
  166. 		use_unicorn_horn(obj);
  167. 		break;
  168. 	case WOODEN_FLUTE:
  169. 	case MAGIC_FLUTE:
  170. 	case TOOLED_HORN:
  171. 	case FROST_HORN:
  172. 	case FIRE_HORN:
  173. 	case WOODEN_HARP:
  174. 	case MAGIC_HARP:
  175. 	case BUGLE:
  176. 	case LEATHER_DRUM:
  177. 	case DRUM_OF_EARTHQUAKE:
  178. 		res = do_play_instrument(obj);
  179. 		break;
  180. 	case HORN_OF_PLENTY:	/* not a musical instrument */
  181. 		if (obj->spe > 0) {
  182. 		    struct obj *otmp;
  183. 		    const char *what;
  184.  
  185. 		    consume_obj_charge(obj, TRUE);
  186. 		    if (!rn2(13)) {
  187. 			otmp = mkobj(POTION_CLASS, FALSE);
  188. 			if (objects[otmp->otyp].oc_magic) do {
  189. 			    otmp->otyp = rnd_class(POT_BOOZE, POT_WATER);
  190. 			} while (otmp->otyp == POT_SICKNESS);
  191. 			what = "A potion";
  192. 		    } else {
  193. 			otmp = mkobj(FOOD_CLASS, FALSE);
  194. 			if (otmp->otyp == FOOD_RATION && !rn2(7))
  195. 			    otmp->otyp = LUMP_OF_ROYAL_JELLY;
  196. 			what = "Some food";
  197. 		    }
  198. 		    pline("%s spills out.", what);
  199. 		    otmp->blessed = obj->blessed;
  200. 		    otmp->cursed = obj->cursed;
  201. 		    otmp->owt = weight(otmp);
  202. 		    otmp = hold_another_object(otmp, u.uswallow ?
  203. 				       "Oops!  %s out of your reach!" :
  204. 					(Is_airlevel(&u.uz) ||
  205. 					 Is_waterlevel(&u.uz) ||
  206. 					 levl[u.ux][u.uy].typ < IRONBARS ||
  207. 					 levl[u.ux][u.uy].typ >= ICE) ?
  208. 					       "Oops!  %s away from you!" :
  209. 					       "Oops!  %s to the floor!",
  210. 					       The(aobjnam(otmp, "slip")),
  211. 					       (const char *)0);
  212. 		    makeknown(HORN_OF_PLENTY);
  213. 		} else
  214. 		    pline(nothing_happens);
  215. 		break;
  216. 	case LAND_MINE:
  217. 	case BEARTRAP:
  218. 		use_trap(obj);
  219. 		break;
  220. 	case FLINT:
  221. 	case LUCKSTONE:
  222. 	case LOADSTONE:
  223. 	case TOUCHSTONE:
  224. 		use_stone(obj);
  225. 		break;
  226. 	default:
  227. 		/* Pole-weapons can strike at a distance */
  228. 		if (is_pole(obj)) {
  229. 			res = use_pole(obj);
  230. 			break;
  231. 		} else if (is_pick(obj) || is_axe(obj)) {
  232. 			res = use_pick_axe(obj);
  233. 			break;
  234. 		}
  235. 		pline("Sorry, I don't know how to use that.");
  236. 	xit:
  237. 		nomul(0);
  238. 		return 0;
  239. 	}
  240. 	if (res && obj && obj->oartifact) arti_speak(obj);
  241. 	nomul(0);
  242. 	return res;
  243. }

unfixable_trouble_count

  1. /* Keep track of unfixable troubles for purposes of messages saying you feel
  2. * great.
  3. */
  4. int
  5. unfixable_trouble_count(is_horn)
  6. 	boolean is_horn;
  7. {
  8. 	int unfixable_trbl = 0;
  9.  
  10. 	if (Stoned) unfixable_trbl++;
  11. 	if (Strangled) unfixable_trbl++;
  12. 	if (Wounded_legs
  13. #ifdef STEED
  14. 		    && !u.usteed
  15. #endif
  16. 				) unfixable_trbl++;
  17. 	if (Slimed) unfixable_trbl++;
  18. 	/* lycanthropy is not desirable, but it doesn't actually make you feel
  19. 	   bad */
  20.  
  21. 	/* we'll assume that intrinsic stunning from being a bat/stalker
  22. 	   doesn't make you feel bad */
  23. 	if (!is_horn) {
  24. 	    if (Confusion) unfixable_trbl++;
  25. 	    if (Sick) unfixable_trbl++;
  26. 	    if (HHallucination) unfixable_trbl++;
  27. 	    if (Vomiting) unfixable_trbl++;
  28. 	    if (HStun) unfixable_trbl++;
  29. 	}
  30. 	return unfixable_trbl;
  31. }
  32.  
  33. #endif /* OVLB */
  34.  
  35. /*apply.c*/