Source:NetHack 3.4.3/src/dokick.c

From NetHackWiki
Jump to: navigation, search

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

Top of file[edit]

  1. /*	SCCS Id: @(#)dokick.c	3.4	2003/12/04	*/
  2. /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
  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 "eshk.h"
  3.  
  4. #define is_bigfoot(x)	((x) == &mons[PM_SASQUATCH])
  5. #define martial()	(martial_bonus() || is_bigfoot(youmonst.data) || \
  6. 		(uarmf && uarmf->otyp == KICKING_BOOTS))
  7.  
  8. static NEARDATA struct rm *maploc;
  9. static NEARDATA const char *gate_str;
  10.  
  11. extern boolean notonhead;	/* for long worms */
  12.  
  13. STATIC_DCL void FDECL(kickdmg, (struct monst *, BOOLEAN_P));
  14. STATIC_DCL void FDECL(kick_monster, (XCHAR_P, XCHAR_P));
  15. STATIC_DCL int FDECL(kick_object, (XCHAR_P, XCHAR_P));
  16. STATIC_DCL char *FDECL(kickstr, (char *));
  17. STATIC_DCL void FDECL(otransit_msg, (struct obj *, BOOLEAN_P, long));
  18. STATIC_DCL void FDECL(drop_to, (coord *,SCHAR_P));
  19.  
  20. static NEARDATA struct obj *kickobj;
  21.  
  22. static const char kick_passes_thru[] = "kick passes harmlessly through";

kickdmg[edit]

  1. STATIC_OVL void
  2. kickdmg(mon, clumsy)
  3. register struct monst *mon;
  4. register boolean clumsy;
  5. {
  6. 	register int mdx, mdy;
  7. 	register int dmg = ( ACURRSTR + ACURR(A_DEX) + ACURR(A_CON) )/ 15;
  8. 	int kick_skill = P_NONE;
  9. 	int blessed_foot_damage = 0;
  10. 	boolean trapkilled = FALSE;
  11.  
  12. 	if (uarmf && uarmf->otyp == KICKING_BOOTS)
  13. 	    dmg += 5;
  14.  
  15. 	/* excessive wt affects dex, so it affects dmg */
  16. 	if (clumsy) dmg /= 2;
  17.  
  18. 	/* kicking a dragon or an elephant will not harm it */
  19. 	if (thick_skinned(mon->data)) dmg = 0;
  20.  
  21. 	/* attacking a shade is useless */
  22. 	if (mon->data == &mons[PM_SHADE])
  23. 	    dmg = 0;
  24.  
  25. 	if ((is_undead(mon->data) || is_demon(mon->data)) && uarmf &&
  26. 		uarmf->blessed)
  27. 	    blessed_foot_damage = 1;
  28.  
  29. 	if (mon->data == &mons[PM_SHADE] && !blessed_foot_damage) {
  30. 	    pline_The("%s.", kick_passes_thru);
  31. 	    /* doesn't exercise skill or abuse alignment or frighten pet,
  32. 	       and shades have no passive counterattack */
  33. 	    return;
  34. 	}
  35.  
  36. 	if(mon->m_ap_type) seemimic(mon);
  37.  
  38. 	check_caitiff(mon);
  39.  
  40. 	/* squeeze some guilt feelings... */
  41. 	if(mon->mtame) {
  42. 	    abuse_dog(mon);
  43. 	    if (mon->mtame)
  44. 		monflee(mon, (dmg ? rnd(dmg) : 1), FALSE, FALSE);
  45. 	    else
  46. 		mon->mflee = 0;
  47. 	}
  48.  
  49. 	if (dmg > 0) {
  50. 		/* convert potential damage to actual damage */
  51. 		dmg = rnd(dmg);
  52. 		if (martial()) {
  53. 		    if (dmg > 1) kick_skill = P_MARTIAL_ARTS;
  54. 		    dmg += rn2(ACURR(A_DEX)/2 + 1);
  55. 		}
  56. 		/* a good kick exercises your dex */
  57. 		exercise(A_DEX, TRUE);
  58. 	}
  59. 	if (blessed_foot_damage) dmg += rnd(4);
  60. 	if (uarmf) dmg += uarmf->spe;
  61. 	dmg += u.udaminc;	/* add ring(s) of increase damage */
  62. 	if (dmg > 0)
  63. 		mon->mhp -= dmg;
  64. 	if (mon->mhp > 0 && martial() && !bigmonst(mon->data) && !rn2(3) &&
  65. 	    mon->mcanmove && mon != u.ustuck && !mon->mtrapped) {
  66. 		/* see if the monster has a place to move into */
  67. 		mdx = mon->mx + u.dx;
  68. 		mdy = mon->my + u.dy;
  69. 		if(goodpos(mdx, mdy, mon, 0)) {
  70. 			pline("%s reels from the blow.", Monnam(mon));
  71. 			if (m_in_out_region(mon, mdx, mdy)) {
  72. 			    remove_monster(mon->mx, mon->my);
  73. 			    newsym(mon->mx, mon->my);
  74. 			    place_monster(mon, mdx, mdy);
  75. 			    newsym(mon->mx, mon->my);
  76. 			    set_apparxy(mon);
  77. 			    if (mintrap(mon) == 2) trapkilled = TRUE;
  78. 			}
  79. 		}
  80. 	}
  81.  
  82. 	(void) passive(mon, TRUE, mon->mhp > 0, AT_KICK);
  83. 	if (mon->mhp <= 0 && !trapkilled) killed(mon);
  84.  
  85. 	/* may bring up a dialog, so put this after all messages */
  86. 	if (kick_skill != P_NONE)	/* exercise proficiency */
  87. 	    use_skill(kick_skill, 1);
  88. }

kick_monster[edit]

  1. STATIC_OVL void
  2. kick_monster(x, y)
  3. register xchar x, y;
  4. {
  5. 	register boolean clumsy = FALSE;
  6. 	register struct monst *mon = m_at(x, y);
  7. 	register int i, j;
  8.  
  9. 	bhitpos.x = x;
  10. 	bhitpos.y = y;
  11. 	if (attack_checks(mon, (struct obj *)0)) return;
  12. 	setmangry(mon);
  13.  
  14. 	/* Kick attacks by kicking monsters are normal attacks, not special.
  15. 	 * This is almost always worthless, since you can either take one turn
  16. 	 * and do all your kicks, or else take one turn and attack the monster
  17. 	 * normally, getting all your attacks _including_ all your kicks.
  18. 	 * If you have >1 kick attack, you get all of them.
  19. 	 */
  20. 	if (Upolyd && attacktype(youmonst.data, AT_KICK)) {
  21. 	    struct attack *uattk;
  22. 	    int sum;
  23. 	    schar tmp = find_roll_to_hit(mon);
  24.  
  25. 	    for (i = 0; i < NATTK; i++) {
  26. 		/* first of two kicks might have provoked counterattack
  27. 		   that has incapacitated the hero (ie, floating eye) */
  28. 		if (multi < 0) break;
  29.  
  30. 		uattk = &youmonst.data->mattk[i];
  31. 		/* we only care about kicking attacks here */
  32. 		if (uattk->aatyp != AT_KICK) continue;
  33.  
  34. 		if (mon->data == &mons[PM_SHADE] &&
  35. 			(!uarmf || !uarmf->blessed)) {
  36. 		    /* doesn't matter whether it would have hit or missed,
  37. 		       and shades have no passive counterattack */
  38. 		    Your("%s %s.", kick_passes_thru, mon_nam(mon));
  39. 		    break;	/* skip any additional kicks */
  40. 		} else if (tmp > rnd(20)) {
  41. 		    You("kick %s.", mon_nam(mon));
  42. 		    sum = damageum(mon, uattk);
  43. 		    (void)passive(mon, (boolean)(sum > 0), (sum != 2), AT_KICK);
  44. 		    if (sum == 2)
  45. 			break;		/* Defender died */
  46. 		} else {
  47. 		    missum(mon, uattk);
  48. 		    (void)passive(mon, 0, 1, AT_KICK);
  49. 		}
  50. 	    }
  51. 	    return;
  52. 	}
  53.  
  54. 	if(Levitation && !rn2(3) && verysmall(mon->data) &&
  55. 	   !is_flyer(mon->data)) {
  56. 		pline("Floating in the air, you miss wildly!");
  57. 		exercise(A_DEX, FALSE);
  58. 		(void) passive(mon, FALSE, 1, AT_KICK);
  59. 		return;
  60. 	}
  61.  
  62. 	i = -inv_weight();
  63. 	j = weight_cap();
  64.  
  65. 	if(i < (j*3)/10) {
  66. 		if(!rn2((i < j/10) ? 2 : (i < j/5) ? 3 : 4)) {
  67. 			if(martial() && !rn2(2)) goto doit;
  68. 			Your("clumsy kick does no damage.");
  69. 			(void) passive(mon, FALSE, 1, AT_KICK);
  70. 			return;
  71. 		}
  72. 		if(i < j/10) clumsy = TRUE;
  73. 		else if(!rn2((i < j/5) ? 2 : 3)) clumsy = TRUE;
  74. 	}
  75.  
  76. 	if(Fumbling) clumsy = TRUE;
  77.  
  78. 	else if(uarm && objects[uarm->otyp].oc_bulky && ACURR(A_DEX) < rnd(25))
  79. 		clumsy = TRUE;
  80. doit:
  81. 	You("kick %s.", mon_nam(mon));
  82. 	if(!rn2(clumsy ? 3 : 4) && (clumsy || !bigmonst(mon->data)) &&
  83. 	   mon->mcansee && !mon->mtrapped && !thick_skinned(mon->data) &&
  84. 	   mon->data->mlet != S_EEL && haseyes(mon->data) && mon->mcanmove &&
  85. 	   !mon->mstun && !mon->mconf && !mon->msleeping &&
  86. 	   mon->data->mmove >= 12) {
  87. 		if(!nohands(mon->data) && !rn2(martial() ? 5 : 3)) {
  88. 		    pline("%s blocks your %skick.", Monnam(mon),
  89. 				clumsy ? "clumsy " : "");
  90. 		    (void) passive(mon, FALSE, 1, AT_KICK);
  91. 		    return;
  92. 		} else {
  93. 		    mnexto(mon);
  94. 		    if(mon->mx != x || mon->my != y) {
  95. 			if(glyph_is_invisible(levl[x][y].glyph)) {
  96. 			    unmap_object(x, y);
  97. 			    newsym(x, y);
  98. 			}
  99. 			pline("%s %s, %s evading your %skick.", Monnam(mon),
  100. 				(can_teleport(mon->data) ? "teleports" :
  101. 				 is_floater(mon->data) ? "floats" :
  102. 				 is_flyer(mon->data) ? "swoops" :
  103. 				 (nolimbs(mon->data) || slithy(mon->data)) ?
  104. 					"slides" : "jumps"),
  105. 				clumsy ? "easily" : "nimbly",
  106. 				clumsy ? "clumsy " : "");
  107. 			(void) passive(mon, FALSE, 1, AT_KICK);
  108. 			return;
  109. 		    }
  110. 		}
  111. 	}
  112. 	kickdmg(mon, clumsy);
  113. }

ghitm[edit]

  1. /*
  2. *  Return TRUE if caught (the gold taken care of), FALSE otherwise.
  3. *  The gold object is *not* attached to the fobj chain!
  4. */
  5. boolean
  6. ghitm(mtmp, gold)
  7. register struct monst *mtmp;
  8. register struct obj *gold;
  9. {
  10. 	boolean msg_given = FALSE;
  11.  
  12. 	if(!likes_gold(mtmp->data) && !mtmp->isshk && !mtmp->ispriest
  13. 			&& !is_mercenary(mtmp->data)) {
  14. 		wakeup(mtmp);
  15. 	} else if (!mtmp->mcanmove) {
  16. 		/* too light to do real damage */
  17. 		if (canseemon(mtmp)) {
  18. 		    pline_The("%s harmlessly %s %s.", xname(gold),
  19. 			      otense(gold, "hit"), mon_nam(mtmp));
  20. 		    msg_given = TRUE;
  21. 		}
  22. 	} else {
  23. #ifdef GOLDOBJ
  24. long value = gold->quan * objects[gold->otyp].oc_cost;
  25. #endif
  26. 		mtmp->msleeping = 0;
  27. 		mtmp->meating = 0;
  28. 		if(!rn2(4)) setmangry(mtmp); /* not always pleasing */
  29.  
  30. 		/* greedy monsters catch gold */
  31. 		if (cansee(mtmp->mx, mtmp->my))
  32. 		    pline("%s catches the gold.", Monnam(mtmp));
  33. #ifndef GOLDOBJ
  34. 		mtmp->mgold += gold->quan;
  35. #endif
  36. 		if (mtmp->isshk) {
  37. 			long robbed = ESHK(mtmp)->robbed;
  38.  
  39. 			if (robbed) {
  40. #ifndef GOLDOBJ
  41. 				robbed -= gold->quan;
  42. #else
  43. 				robbed -= value;
  44. #endif
  45. 				if (robbed < 0) robbed = 0;
  46. 				pline_The("amount %scovers %s recent losses.",
  47. 				      !robbed ? "" : "partially ",
  48. 				      mhis(mtmp));
  49. 				ESHK(mtmp)->robbed = robbed;
  50. 				if(!robbed)
  51. 					make_happy_shk(mtmp, FALSE);
  52. 			} else {
  53. 				if(mtmp->mpeaceful) {
  54. #ifndef GOLDOBJ
  55. 				    ESHK(mtmp)->credit += gold->quan;
  56. #else
  57. 				    ESHK(mtmp)->credit += value;
  58. #endif
  59. 				    You("have %ld %s in credit.",
  60. 					ESHK(mtmp)->credit,
  61. 					currency(ESHK(mtmp)->credit));
  62. 				} else verbalize("Thanks, scum!");
  63. 			}
  64. 		} else if (mtmp->ispriest) {
  65. 			if (mtmp->mpeaceful)
  66. 			    verbalize("Thank you for your contribution.");
  67. 			else verbalize("Thanks, scum!");
  68. 		} else if (is_mercenary(mtmp->data)) {
  69. 		    long goldreqd = 0L;
  70.  
  71. 		    if (rn2(3)) {
  72. 			if (mtmp->data == &mons[PM_SOLDIER])
  73. 			   goldreqd = 100L;
  74. 			else if (mtmp->data == &mons[PM_SERGEANT])
  75. 			   goldreqd = 250L;
  76. 			else if (mtmp->data == &mons[PM_LIEUTENANT])
  77. 			   goldreqd = 500L;
  78. 			else if (mtmp->data == &mons[PM_CAPTAIN])
  79. 			   goldreqd = 750L;
  80.  
  81. 			if (goldreqd) {
  82. #ifndef GOLDOBJ
  83. 			   if (gold->quan > goldreqd +
  84. 				(u.ugold + u.ulevel*rn2(5))/ACURR(A_CHA))
  85. #else
  86. 			   if (value > goldreqd +
  87. 				(money_cnt(invent) + u.ulevel*rn2(5))/ACURR(A_CHA))
  88. #endif
  89. 			    mtmp->mpeaceful = TRUE;
  90. 			}
  91. 		     }
  92. 		     if (mtmp->mpeaceful)
  93. 			    verbalize("That should do.  Now beat it!");
  94. 		     else verbalize("That's not enough, coward!");
  95. 		}
  96.  
  97. #ifndef GOLDOBJ
  98. 		dealloc_obj(gold);
  99. #else
  100. 		add_to_minv(mtmp, gold);
  101. #endif
  102. 		return TRUE;
  103. 	}
  104.  
  105. 	if (!msg_given) miss(xname(gold), mtmp);
  106. 	return FALSE;
  107. }

container_impact_dmg[edit]

  1. /* container is kicked, dropped, thrown or otherwise impacted by player.
  2. * Assumes container is on floor.  Checks contents for possible damage. */
  3. void
  4. container_impact_dmg(obj)
  5. struct obj *obj;
  6. {
  7. 	struct monst *shkp;
  8. 	struct obj *otmp, *otmp2;
  9. 	long loss = 0L;
  10. 	boolean costly, insider;
  11. 	xchar x = obj->ox, y = obj->oy;
  12.  
  13. 	/* only consider normal containers */
  14. 	if (!Is_container(obj) || Is_mbag(obj)) return;
  15.  
  16. 	costly = ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) &&
  17. 		  costly_spot(x, y));
  18. 	insider = (*u.ushops && inside_shop(u.ux, u.uy) &&
  19. 		   *in_rooms(x, y, SHOPBASE) == *u.ushops);
  20.  
  21. 	for (otmp = obj->cobj; otmp; otmp = otmp2) {
  22. 	    const char *result = (char *)0;
  23.  
  24. 	    otmp2 = otmp->nobj;
  25. 	    if (objects[otmp->otyp].oc_material == GLASS &&
  26. 		otmp->oclass != GEM_CLASS && !obj_resists(otmp, 33, 100)) {
  27. 		result = "shatter";
  28. 	    } else if (otmp->otyp == EGG && !rn2(3)) {
  29. 		result = "cracking";
  30. 	    }
  31. 	    if (result) {
  32. 		if (otmp->otyp == MIRROR) change_luck(-2);
  33.  
  34. 		/* eggs laid by you.  penalty is -1 per egg, max 5,
  35. 		 * but it's always exactly 1 that breaks */
  36. 		if (otmp->otyp == EGG && otmp->spe && otmp->corpsenm >= LOW_PM)
  37. 		    change_luck(-1);
  38. 		You_hear("a muffled %s.", result);
  39. 		if (costly)
  40. 		    loss += stolen_value(otmp, x, y,
  41. 					 (boolean)shkp->mpeaceful, TRUE);
  42. 		if (otmp->quan > 1L)
  43. 		    useup(otmp);
  44. 		else {
  45. 		    obj_extract_self(otmp);
  46. 		    obfree(otmp, (struct obj *) 0);
  47. 		}
  48. 	    }
  49. 	}
  50. 	if (costly && loss) {
  51. 	    if (!insider) {
  52. 		You("caused %ld %s worth of damage!", loss, currency(loss));
  53. 		make_angry_shk(shkp, x, y);
  54. 	    } else {
  55. 		You("owe %s %ld %s for objects destroyed.",
  56. 		    mon_nam(shkp), loss, currency(loss));
  57. 	    }
  58. 	}
  59. }

kick_object[edit]

  1. STATIC_OVL int
  2. kick_object(x, y)
  3. xchar x, y;
  4. {
  5. 	int range;
  6. 	register struct monst *mon, *shkp;
  7. 	struct trap *trap;
  8. 	char bhitroom;
  9. 	boolean costly, isgold, slide = FALSE;
  10.  
  11. 	/* if a pile, the "top" object gets kicked */
  12. 	kickobj = level.objects[x][y];
  13.  
  14. 	/* kickobj should always be set due to conditions of call */
  15. 	if(!kickobj || kickobj->otyp == BOULDER
  16. 			|| kickobj == uball || kickobj == uchain)
  17. 		return(0);
  18.  
  19. 	if ((trap = t_at(x,y)) != 0 &&
  20. 			(((trap->ttyp == PIT ||
  21. 			   trap->ttyp == SPIKED_PIT) && !Passes_walls) ||
  22. 			 trap->ttyp == WEB)) {
  23. 		if (!trap->tseen) find_trap(trap);
  24. 		You_cant("kick %s that's in a %s!", something,
  25. 			 Hallucination ? "tizzy" :
  26. 			 (trap->ttyp == WEB) ? "web" : "pit");
  27. 		return 1;
  28. 	}
  29.  
  30. 	if(Fumbling && !rn2(3)) {
  31. 		Your("clumsy kick missed.");
  32. 		return(1);
  33. 	}
  34.  
  35. 	if(kickobj->otyp == CORPSE && touch_petrifies(&mons[kickobj->corpsenm])
  36. 			&& !Stone_resistance && !uarmf) {
  37. 	    char kbuf[BUFSZ];
  38.  
  39. 	    You("kick the %s with your bare %s.",
  40. 		corpse_xname(kickobj, TRUE), makeplural(body_part(FOOT)));
  41. 	    if (!(poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))) {
  42. 		You("turn to stone...");
  43. 		killer_format = KILLED_BY;
  44. 		/* KMH -- otmp should be kickobj */
  45. 		Sprintf(kbuf, "kicking %s without boots",
  46. 			an(corpse_xname(kickobj, TRUE)));
  47. 		killer = kbuf;
  48. 		done(STONING);
  49. 	    }
  50. 	}
  51.  
  52. 	/* range < 2 means the object will not move.	*/
  53. 	/* maybe dexterity should also figure here.     */
  54. 	range = (int)((ACURRSTR)/2 - kickobj->owt/40);
  55.  
  56. 	if(martial()) range += rnd(3);
  57.  
  58. 	if (is_pool(x, y)) {
  59. 	    /* you're in the water too; significantly reduce range */
  60. 	    range = range / 3 + 1;	/* {1,2}=>1, {3,4,5}=>2, {6,7,8}=>3 */
  61. 	} else {
  62. 	    if (is_ice(x, y)) range += rnd(3),  slide = TRUE;
  63. 	    if (kickobj->greased) range += rnd(3),  slide = TRUE;
  64. 	}
  65.  
  66. 	/* Mjollnir is magically too heavy to kick */
  67. 	if(kickobj->oartifact == ART_MJOLLNIR) range = 1;
  68.  
  69. 	/* see if the object has a place to move into */
  70. 	if(!ZAP_POS(levl[x+u.dx][y+u.dy].typ) || closed_door(x+u.dx, y+u.dy))
  71. 		range = 1;
  72.  
  73. 	costly = ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) &&
  74. 				    costly_spot(x, y));
  75. 	isgold = (kickobj->oclass == COIN_CLASS);
  76.  
  77. 	if (IS_ROCK(levl[x][y].typ) || closed_door(x, y)) {
  78. 	    if ((!martial() && rn2(20) > ACURR(A_DEX)) ||
  79. 		    IS_ROCK(levl[u.ux][u.uy].typ) || closed_door(u.ux, u.uy)) {
  80. 		if (Blind)
  81. 		    pline("It doesn't come loose.");
  82. 		else
  83. 		    pline("%s %sn't come loose.",
  84. 			  The(distant_name(kickobj, xname)),
  85. 			  otense(kickobj, "do"));
  86. 		return (!rn2(3) || martial());
  87. 	    }
  88. 	    if (Blind)
  89. 		pline("It comes loose.");
  90. 	    else
  91. 		pline("%s %s loose.",
  92. 		      The(distant_name(kickobj, xname)),
  93. 		      otense(kickobj, "come"));
  94. 	    obj_extract_self(kickobj);
  95. 	    newsym(x, y);
  96. 	    if (costly && (!costly_spot(u.ux, u.uy) ||
  97. 		    !index(u.urooms, *in_rooms(x, y, SHOPBASE))))
  98. 		addtobill(kickobj, FALSE, FALSE, FALSE);
  99. 	    if (!flooreffects(kickobj, u.ux, u.uy, "fall")) {
  100. 		place_object(kickobj, u.ux, u.uy);
  101. 		stackobj(kickobj);
  102. 		newsym(u.ux, u.uy);
  103. 	    }
  104. 	    return 1;
  105. 	}
  106.  
  107. 	/* a box gets a chance of breaking open here */
  108. 	if(Is_box(kickobj)) {
  109. 		boolean otrp = kickobj->otrapped;
  110.  
  111. 		if(range < 2) pline("THUD!");
  112.  
  113. 		container_impact_dmg(kickobj);
  114.  
  115. 		if (kickobj->olocked) {
  116. 		    if (!rn2(5) || (martial() && !rn2(2))) {
  117. 			You("break open the lock!");
  118. 			kickobj->olocked = 0;
  119. 			kickobj->obroken = 1;
  120. 			if (otrp) (void) chest_trap(kickobj, LEG, FALSE);
  121. 			return(1);
  122. 		    }
  123. 		} else {
  124. 		    if (!rn2(3) || (martial() && !rn2(2))) {
  125. 			pline_The("lid slams open, then falls shut.");
  126. 			if (otrp) (void) chest_trap(kickobj, LEG, FALSE);
  127. 			return(1);
  128. 		    }
  129. 		}
  130. 		if(range < 2) return(1);
  131. 		/* else let it fall through to the next cases... */
  132. 	}
  133.  
  134. 	/* fragile objects should not be kicked */
  135. 	if (hero_breaks(kickobj, kickobj->ox, kickobj->oy, FALSE)) return 1;
  136.  
  137. 	/* too heavy to move.  range is calculated as potential distance from
  138. 	 * player, so range == 2 means the object may move up to one square
  139. 	 * from its current position
  140. 	 */
  141. 	if(range < 2 || (isgold && kickobj->quan > 300L)) {
  142. 	    if(!Is_box(kickobj)) pline("Thump!");
  143. 	    return(!rn2(3) || martial());
  144. 	}
  145.  
  146. 	if (kickobj->quan > 1L && !isgold) kickobj = splitobj(kickobj, 1L);
  147.  
  148. 	if (slide && !Blind)
  149. 	    pline("Whee!  %s %s across the %s.", Doname2(kickobj),
  150. 		  otense(kickobj, "slide"), surface(x,y));
  151.  
  152. 	obj_extract_self(kickobj);
  153. 	(void) snuff_candle(kickobj);
  154. 	newsym(x, y);
  155. 	mon = bhit(u.dx, u.dy, range, KICKED_WEAPON,
  156. 		   (int FDECL((*),(MONST_P,OBJ_P)))0,
  157. 		   (int FDECL((*),(OBJ_P,OBJ_P)))0,
  158. 		   kickobj);
  159.  
  160. 	if(mon) {
  161. 	    if (mon->isshk &&
  162. 		    kickobj->where == OBJ_MINVENT && kickobj->ocarry == mon)
  163. 		return 1;	/* alert shk caught it */
  164. 	    notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y);
  165. 	    if (isgold ? ghitm(mon, kickobj) :	/* caught? */
  166. 		    thitmonst(mon, kickobj))	/* hit && used up? */
  167. 		return(1);
  168. 	}
  169.  
  170. 	/* the object might have fallen down a hole */
  171. 	if (kickobj->where == OBJ_MIGRATING) {
  172. 	    if (costly) {
  173. 		if(isgold)
  174. 		    costly_gold(x, y, kickobj->quan);
  175. 		else (void)stolen_value(kickobj, x, y,
  176. 					(boolean)shkp->mpeaceful, FALSE);
  177. 	    }
  178. 	    return 1;
  179. 	}
  180.  
  181. 	bhitroom = *in_rooms(bhitpos.x, bhitpos.y, SHOPBASE);
  182. 	if (costly && (!costly_spot(bhitpos.x, bhitpos.y) ||
  183. 			*in_rooms(x, y, SHOPBASE) != bhitroom)) {
  184. 	    if(isgold)
  185. 		costly_gold(x, y, kickobj->quan);
  186. 	    else (void)stolen_value(kickobj, x, y,
  187. 				    (boolean)shkp->mpeaceful, FALSE);
  188. 	}
  189.  
  190. 	if(flooreffects(kickobj,bhitpos.x,bhitpos.y,"fall")) return(1);
  191. 	place_object(kickobj, bhitpos.x, bhitpos.y);
  192. 	stackobj(kickobj);
  193. 	newsym(kickobj->ox, kickobj->oy);
  194. 	return(1);
  195. }

kickstr[edit]

  1. STATIC_OVL char *
  2. kickstr(buf)
  3. char *buf;
  4. {
  5. 	const char *what;
  6.  
  7. 	if (kickobj) what = distant_name(kickobj,doname);
  8. 	else if (IS_DOOR(maploc->typ)) what = "a door";
  9. 	else if (IS_TREE(maploc->typ)) what = "a tree";
  10. 	else if (IS_STWALL(maploc->typ)) what = "a wall";
  11. 	else if (IS_ROCK(maploc->typ)) what = "a rock";
  12. 	else if (IS_THRONE(maploc->typ)) what = "a throne";
  13. 	else if (IS_FOUNTAIN(maploc->typ)) what = "a fountain";
  14. 	else if (IS_GRAVE(maploc->typ)) what = "a headstone";
  15. #ifdef SINKS
  16. 	else if (IS_SINK(maploc->typ)) what = "a sink";
  17. #endif
  18. 	else if (IS_ALTAR(maploc->typ)) what = "an altar";
  19. 	else if (IS_DRAWBRIDGE(maploc->typ)) what = "a drawbridge";
  20. 	else if (maploc->typ == STAIRS) what = "the stairs";
  21. 	else if (maploc->typ == LADDER) what = "a ladder";
  22. 	else if (maploc->typ == IRONBARS) what = "an iron bar";
  23. 	else what = "something weird";
  24. 	return strcat(strcpy(buf, "kicking "), what);
  25. }

dokick[edit]

  1. int
  2. dokick()
  3. {
  4. 	int x, y;
  5. 	int avrg_attrib;
  6. 	register struct monst *mtmp;
  7. 	boolean no_kick = FALSE;
  8. 	char buf[BUFSZ];
  9.  
  10. 	if (nolimbs(youmonst.data) || slithy(youmonst.data)) {
  11. 		You("have no legs to kick with.");
  12. 		no_kick = TRUE;
  13. 	} else if (verysmall(youmonst.data)) {
  14. 		You("are too small to do any kicking.");
  15. 		no_kick = TRUE;
  16. #ifdef STEED
  17. 	} else if (u.usteed) {
  18. 		if (yn_function("Kick your steed?", ynchars, 'y') == 'y') {
  19. 		    You("kick %s.", mon_nam(u.usteed));
  20. 		    kick_steed();
  21. 		    return 1;
  22. 		} else {
  23. 		    return 0;
  24. 		}
  25. #endif
  26. 	} else if (Wounded_legs) {
  27. 		/* note: jump() has similar code */
  28. 		long wl = (EWounded_legs & BOTH_SIDES);
  29. 		const char *bp = body_part(LEG);
  30.  
  31. 		if (wl == BOTH_SIDES) bp = makeplural(bp);
  32. 		Your("%s%s %s in no shape for kicking.",
  33. 		     (wl == LEFT_SIDE) ? "left " :
  34. 			(wl == RIGHT_SIDE) ? "right " : "",
  35. 		     bp, (wl == BOTH_SIDES) ? "are" : "is");
  36. 		no_kick = TRUE;
  37. 	} else if (near_capacity() > SLT_ENCUMBER) {
  38. 		Your("load is too heavy to balance yourself for a kick.");
  39. 		no_kick = TRUE;
  40. 	} else if (youmonst.data->mlet == S_LIZARD) {
  41. 		Your("legs cannot kick effectively.");
  42. 		no_kick = TRUE;
  43. 	} else if (u.uinwater && !rn2(2)) {
  44. 		Your("slow motion kick doesn't hit anything.");
  45. 		no_kick = TRUE;
  46. 	} else if (u.utrap) {
  47. 		switch (u.utraptype) {
  48. 		    case TT_PIT:
  49. 			pline("There's not enough room to kick down here.");
  50. 			break;
  51. 		    case TT_WEB:
  52. 		    case TT_BEARTRAP:
  53. 			You_cant("move your %s!", body_part(LEG));
  54. 			break;
  55. 		    default:
  56. 			break;
  57. 		}
  58. 		no_kick = TRUE;
  59. 	}
  60.  
  61. 	if (no_kick) {
  62. 		/* ignore direction typed before player notices kick failed */
  63. 		display_nhwindow(WIN_MESSAGE, TRUE);	/* --More-- */
  64. 		return 0;
  65. 	}
  66.  
  67. 	if(!getdir((char *)0)) return(0);
  68. 	if(!u.dx && !u.dy) return(0);
  69.  
  70. 	x = u.ux + u.dx;
  71. 	y = u.uy + u.dy;
  72.  
  73. 	/* KMH -- Kicking boots always succeed */
  74. 	if (uarmf && uarmf->otyp == KICKING_BOOTS)
  75. 	    avrg_attrib = 99;
  76. 	else
  77. 	    avrg_attrib = (ACURRSTR+ACURR(A_DEX)+ACURR(A_CON))/3;
  78.  
  79. 	if(u.uswallow) {
  80. 		switch(rn2(3)) {
  81. 		case 0:  You_cant("move your %s!", body_part(LEG));
  82. 			 break;
  83. 		case 1:  if (is_animal(u.ustuck->data)) {
  84. 				pline("%s burps loudly.", Monnam(u.ustuck));
  85. 				break;
  86. 			 }
  87. 		default: Your("feeble kick has no effect."); break;
  88. 		}
  89. 		return(1);
  90. 	}
  91. 	if (Levitation) {
  92. 		int xx, yy;
  93.  
  94. 		xx = u.ux - u.dx;
  95. 		yy = u.uy - u.dy;
  96. 		/* doors can be opened while levitating, so they must be
  97. 		 * reachable for bracing purposes
  98. 		 * Possible extension: allow bracing against stuff on the side?
  99. 		 */
  100. 		if (isok(xx,yy) && !IS_ROCK(levl[xx][yy].typ) &&
  101. 			!IS_DOOR(levl[xx][yy].typ) &&
  102. 			(!Is_airlevel(&u.uz) || !OBJ_AT(xx,yy))) {
  103. 		    You("have nothing to brace yourself against.");
  104. 		    return(0);
  105. 		}
  106. 	}
  107.  
  108. 	wake_nearby();
  109. 	u_wipe_engr(2);
  110.  
  111. 	maploc = &levl[x][y];
  112.  
  113. 	/* The next five tests should stay in    */
  114. 	/* their present order: monsters, pools, */
  115. 	/* objects, non-doors, doors.		 */
  116.  
  117. 	if(MON_AT(x, y)) {
  118. 		struct permonst *mdat;
  119.  
  120. 		mtmp = m_at(x, y);
  121. 		mdat = mtmp->data;
  122. 		if (!mtmp->mpeaceful || !canspotmon(mtmp))
  123. 		    flags.forcefight = TRUE; /* attack even if invisible */
  124. 		kick_monster(x, y);
  125. 		flags.forcefight = FALSE;
  126. 		/* see comment in attack_checks() */
  127. 		if (!DEADMONSTER(mtmp) &&
  128. 		    !canspotmon(mtmp) &&
  129. 		    /* check x and y; a monster that evades your kick by
  130. 		       jumping to an unseen square doesn't leave an I behind */
  131. 		    mtmp->mx == x && mtmp->my == y &&
  132. 		    !glyph_is_invisible(levl[x][y].glyph) &&
  133. 		    !(u.uswallow && mtmp == u.ustuck))
  134. 			map_invisible(x, y);
  135. 		if((Is_airlevel(&u.uz) || Levitation) && flags.move) {
  136. 		    int range;
  137.  
  138. 		    range = ((int)youmonst.data->cwt + (weight_cap() + inv_weight()));
  139. 		    if (range < 1) range = 1; /* divide by zero avoidance */
  140. 		    range = (3*(int)mdat->cwt) / range;
  141.  
  142. 		    if(range < 1) range = 1;
  143. 		    hurtle(-u.dx, -u.dy, range, TRUE);
  144. 		}
  145. 		return(1);
  146. 	}
  147. 	if (glyph_is_invisible(levl[x][y].glyph)) {
  148. 		unmap_object(x, y);
  149. 		newsym(x, y);
  150. 	}
  151. 	if (is_pool(x, y) ^ !!u.uinwater) {
  152. 		/* objects normally can't be removed from water by kicking */
  153. 		You("splash some water around.");
  154. 		return 1;
  155. 	}
  156.  
  157. 	kickobj = (struct obj *)0;
  158. 	if (OBJ_AT(x, y) &&
  159. 	    (!Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)
  160. 	     || sobj_at(BOULDER,x,y))) {
  161. 		if(kick_object(x, y)) {
  162. 		    if(Is_airlevel(&u.uz))
  163. 			hurtle(-u.dx, -u.dy, 1, TRUE); /* assume it's light */
  164. 		    return(1);
  165. 		}
  166. 		goto ouch;
  167. 	}
  168.  
  169. 	if(!IS_DOOR(maploc->typ)) {
  170. 		if(maploc->typ == SDOOR) {
  171. 		    if(!Levitation && rn2(30) < avrg_attrib) {
  172. 			cvt_sdoor_to_door(maploc);	/* ->typ = DOOR */
  173. 			pline("Crash!  %s a secret door!",
  174. 			      /* don't "kick open" when it's locked
  175. 				 unless it also happens to be trapped */
  176. 			(maploc->doormask & (D_LOCKED|D_TRAPPED)) == D_LOCKED ?
  177. 			      "Your kick uncovers" : "You kick open");
  178. 			exercise(A_DEX, TRUE);
  179. 			if(maploc->doormask & D_TRAPPED) {
  180. 			    maploc->doormask = D_NODOOR;
  181. 			    b_trapped("door", FOOT);
  182. 			} else if (maploc->doormask != D_NODOOR &&
  183. 				   !(maploc->doormask & D_LOCKED))
  184. 			    maploc->doormask = D_ISOPEN;
  185. 			if (Blind)
  186. 			    feel_location(x,y);	/* we know it's gone */
  187. 			else
  188. 			    newsym(x,y);
  189. 			if (maploc->doormask == D_ISOPEN ||
  190. 			    maploc->doormask == D_NODOOR)
  191. 			    unblock_point(x,y);	/* vision */
  192. 			return(1);
  193. 		    } else goto ouch;
  194. 		}
  195. 		if(maploc->typ == SCORR) {
  196. 		    if(!Levitation && rn2(30) < avrg_attrib) {
  197. 			pline("Crash!  You kick open a secret passage!");
  198. 			exercise(A_DEX, TRUE);
  199. 			maploc->typ = CORR;
  200. 			if (Blind)
  201. 			    feel_location(x,y);	/* we know it's gone */
  202. 			else
  203. 			    newsym(x,y);
  204. 			unblock_point(x,y);	/* vision */
  205. 			return(1);
  206. 		    } else goto ouch;
  207. 		}
  208. 		if(IS_THRONE(maploc->typ)) {
  209. 		    register int i;
  210. 		    if(Levitation) goto dumb;
  211. 		    if((Luck < 0 || maploc->doormask) && !rn2(3)) {
  212. 			maploc->typ = ROOM;
  213. 			maploc->doormask = 0; /* don't leave loose ends.. */
  214. 			(void) mkgold((long)rnd(200), x, y);
  215. 			if (Blind)
  216. 			    pline("CRASH!  You destroy it.");
  217. 			else {
  218. 			    pline("CRASH!  You destroy the throne.");
  219. 			    newsym(x, y);
  220. 			}
  221. 			exercise(A_DEX, TRUE);
  222. 			return(1);
  223. 		    } else if(Luck > 0 && !rn2(3) && !maploc->looted) {
  224. 			(void) mkgold((long) rn1(201, 300), x, y);
  225. 			i = Luck + 1;
  226. 			if(i > 6) i = 6;
  227. 			while(i--)
  228. 			    (void) mksobj_at(rnd_class(DILITHIUM_CRYSTAL,
  229. 					LUCKSTONE-1), x, y, FALSE, TRUE);
  230. 			if (Blind)
  231. 			    You("kick %s loose!", something);
  232. 			else {
  233. 			    You("kick loose some ornamental coins and gems!");
  234. 			    newsym(x, y);
  235. 			}
  236. 			/* prevent endless milking */
  237. 			maploc->looted = T_LOOTED;
  238. 			return(1);
  239. 		    } else if (!rn2(4)) {
  240. 			if(dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz)) {
  241. 			    fall_through(FALSE);
  242. 			    return(1);
  243. 			} else goto ouch;
  244. 		    }
  245. 		    goto ouch;
  246. 		}
  247. 		if(IS_ALTAR(maploc->typ)) {
  248. 		    if(Levitation) goto dumb;
  249. 		    You("kick %s.",(Blind ? something : "the altar"));
  250. 		    if(!rn2(3)) goto ouch;
  251. 		    altar_wrath(x, y);
  252. 		    exercise(A_DEX, TRUE);
  253. 		    return(1);
  254. 		}
  255. 		if(IS_FOUNTAIN(maploc->typ)) {
  256. 		    if(Levitation) goto dumb;
  257. 		    You("kick %s.",(Blind ? something : "the fountain"));
  258. 		    if(!rn2(3)) goto ouch;
  259. 		    /* make metal boots rust */
  260. 		    if(uarmf && rn2(3))
  261. 			if (!rust_dmg(uarmf, "metal boots", 1, FALSE, &youmonst)) {
  262. 				Your("boots get wet.");
  263. 				/* could cause short-lived fumbling here */
  264. 			}
  265. 		    exercise(A_DEX, TRUE);
  266. 		    return(1);
  267. 		}
  268. 		if(IS_GRAVE(maploc->typ) || maploc->typ == IRONBARS)
  269. 		    goto ouch;
  270. 		if(IS_TREE(maploc->typ)) {
  271. 		    struct obj *treefruit;
  272. 		    /* nothing, fruit or trouble? 75:23.5:1.5% */
  273. 		    if (rn2(3)) {
  274. 			if ( !rn2(6) && !(mvitals[PM_KILLER_BEE].mvflags & G_GONE) )
  275. 			    You_hear("a low buzzing."); /* a warning */
  276. 			goto ouch;
  277. 		    }
  278. 		    if (rn2(15) && !(maploc->looted & TREE_LOOTED) &&
  279. 			  (treefruit = rnd_treefruit_at(x, y))) {
  280. 			long nfruit = 8L-rnl(7), nfall;
  281. 			short frtype = treefruit->otyp;
  282. 			treefruit->quan = nfruit;
  283. 			if (is_plural(treefruit))
  284. 			    pline("Some %s fall from the tree!", xname(treefruit));
  285. 			else
  286. 			    pline("%s falls from the tree!", An(xname(treefruit)));
  287. 			nfall = scatter(x,y,2,MAY_HIT,treefruit);
  288. 			if (nfall != nfruit) {
  289. 			    /* scatter left some in the tree, but treefruit
  290. 			     * may not refer to the correct object */
  291. 			    treefruit = mksobj(frtype, TRUE, FALSE);
  292. 			    treefruit->quan = nfruit-nfall;
  293. 			    pline("%ld %s got caught in the branches.",
  294. 				nfruit-nfall, xname(treefruit));
  295. 			    dealloc_obj(treefruit);
  296. 			}
  297. 			exercise(A_DEX, TRUE);
  298. 			exercise(A_WIS, TRUE);	/* discovered a new food source! */
  299. 			newsym(x, y);
  300. 			maploc->looted |= TREE_LOOTED;
  301. 			return(1);
  302. 		    } else if (!(maploc->looted & TREE_SWARM)) {
  303. 		    	int cnt = rnl(4) + 2;
  304. 			int made = 0;
  305. 		    	coord mm;
  306. 		    	mm.x = x; mm.y = y;
  307. 			while (cnt--) {
  308. 			    if (enexto(&mm, mm.x, mm.y, &mons[PM_KILLER_BEE])
  309. 				&& makemon(&mons[PM_KILLER_BEE],
  310. 					       mm.x, mm.y, MM_ANGRY))
  311. 				made++;
  312. 			}
  313. 			if ( made )
  314. 			    pline("You've attracted the tree's former occupants!");
  315. 			else
  316. 			    You("smell stale honey.");
  317. 			maploc->looted |= TREE_SWARM;
  318. 			return(1);
  319. 		    }
  320. 		    goto ouch;
  321. 		}
  322. #ifdef SINKS
  323. 		if(IS_SINK(maploc->typ)) {
  324. 		    int gend = poly_gender();
  325. 		    short washerndx = (gend == 1 || (gend == 2 && rn2(2))) ?
  326. 					PM_INCUBUS : PM_SUCCUBUS;
  327.  
  328. 		    if(Levitation) goto dumb;
  329. 		    if(rn2(5)) {
  330. 			if(flags.soundok)
  331. 			    pline("Klunk!  The pipes vibrate noisily.");
  332. 			else pline("Klunk!");
  333. 			exercise(A_DEX, TRUE);
  334. 			return(1);
  335. 		    } else if(!(maploc->looted & S_LPUDDING) && !rn2(3) &&
  336. 			  !(mvitals[PM_BLACK_PUDDING].mvflags & G_GONE)) {
  337. 			if (Blind)
  338. 			    You_hear("a gushing sound.");
  339. 			else
  340. 			    pline("A %s ooze gushes up from the drain!",
  341. 					 hcolor(NH_BLACK));
  342. 			(void) makemon(&mons[PM_BLACK_PUDDING],
  343. 					 x, y, NO_MM_FLAGS);
  344. 			exercise(A_DEX, TRUE);
  345. 			newsym(x,y);
  346. 			maploc->looted |= S_LPUDDING;
  347. 			return(1);
  348. 		    } else if(!(maploc->looted & S_LDWASHER) && !rn2(3) &&
  349. 			      !(mvitals[washerndx].mvflags & G_GONE)) {
  350. 			/* can't resist... */
  351. 			pline("%s returns!", (Blind ? Something :
  352. 							"The dish washer"));
  353. 			if (makemon(&mons[washerndx], x, y, NO_MM_FLAGS))
  354. 			    newsym(x,y);
  355. 			maploc->looted |= S_LDWASHER;
  356. 			exercise(A_DEX, TRUE);
  357. 			return(1);
  358. 		    } else if(!rn2(3)) {
  359. 			pline("Flupp!  %s.", (Blind ?
  360. 				      "You hear a sloshing sound" :
  361. 				      "Muddy waste pops up from the drain"));
  362. 			if(!(maploc->looted & S_LRING)) { /* once per sink */
  363. 			    if (!Blind)
  364. 				You("see a ring shining in its midst.");
  365. 			    (void) mkobj_at(RING_CLASS, x, y, TRUE);
  366. 			    newsym(x, y);
  367. 			    exercise(A_DEX, TRUE);
  368. 			    exercise(A_WIS, TRUE);	/* a discovery! */
  369. 			    maploc->looted |= S_LRING;
  370. 			}
  371. 			return(1);
  372. 		    }
  373. 		    goto ouch;
  374. 		}
  375. #endif
  376. 		if (maploc->typ == STAIRS || maploc->typ == LADDER ||
  377. 						    IS_STWALL(maploc->typ)) {
  378. 		    if(!IS_STWALL(maploc->typ) && maploc->ladder == LA_DOWN)
  379. 			goto dumb;
  380. ouch:
  381. 		    pline("Ouch!  That hurts!");
  382. 		    exercise(A_DEX, FALSE);
  383. 		    exercise(A_STR, FALSE);
  384. 		    if (Blind) feel_location(x,y); /* we know we hit it */
  385. 		    if (is_drawbridge_wall(x,y) >= 0) {
  386. 			pline_The("drawbridge is unaffected.");
  387. 			/* update maploc to refer to the drawbridge */
  388. 			(void) find_drawbridge(&x,&y);
  389. 			maploc = &levl[x][y];
  390. 		    }
  391. 		    if(!rn2(3)) set_wounded_legs(RIGHT_SIDE, 5 + rnd(5));
  392. 		    losehp(rnd(ACURR(A_CON) > 15 ? 3 : 5), kickstr(buf),
  393. 			KILLED_BY);
  394. 		    if(Is_airlevel(&u.uz) || Levitation)
  395. 			hurtle(-u.dx, -u.dy, rn1(2,4), TRUE); /* assume it's heavy */
  396. 		    return(1);
  397. 		}
  398. 		goto dumb;
  399. 	}
  400.  
  401. 	if(maploc->doormask == D_ISOPEN ||
  402. 	   maploc->doormask == D_BROKEN ||
  403. 	   maploc->doormask == D_NODOOR) {
  404. dumb:
  405. 		exercise(A_DEX, FALSE);
  406. 		if (martial() || ACURR(A_DEX) >= 16 || rn2(3)) {
  407. 			You("kick at empty space.");
  408. 			if (Blind) feel_location(x,y);
  409. 		} else {
  410. 			pline("Dumb move!  You strain a muscle.");
  411. 			exercise(A_STR, FALSE);
  412. 			set_wounded_legs(RIGHT_SIDE, 5 + rnd(5));
  413. 		}
  414. 		if ((Is_airlevel(&u.uz) || Levitation) && rn2(2)) {
  415. 		    hurtle(-u.dx, -u.dy, 1, TRUE);
  416. 		    return 1;		/* you moved, so use up a turn */
  417. 		}
  418. 		return(0);
  419. 	}
  420.  
  421. 	/* not enough leverage to kick open doors while levitating */
  422. 	if(Levitation) goto ouch;
  423.  
  424. 	exercise(A_DEX, TRUE);
  425. 	/* door is known to be CLOSED or LOCKED */
  426. 	if(rnl(35) < avrg_attrib + (!martial() ? 0 : ACURR(A_DEX))) {
  427. 		boolean shopdoor = *in_rooms(x, y, SHOPBASE) ? TRUE : FALSE;
  428. 		/* break the door */
  429. 		if(maploc->doormask & D_TRAPPED) {
  430. 		    if (flags.verbose) You("kick the door.");
  431. 		    exercise(A_STR, FALSE);
  432. 		    maploc->doormask = D_NODOOR;
  433. 		    b_trapped("door", FOOT);
  434. 		} else if(ACURR(A_STR) > 18 && !rn2(5) && !shopdoor) {
  435. 		    pline("As you kick the door, it shatters to pieces!");
  436. 		    exercise(A_STR, TRUE);
  437. 		    maploc->doormask = D_NODOOR;
  438. 		} else {
  439. 		    pline("As you kick the door, it crashes open!");
  440. 		    exercise(A_STR, TRUE);
  441. 		    maploc->doormask = D_BROKEN;
  442. 		}
  443. 		if (Blind)
  444. 		    feel_location(x,y);		/* we know we broke it */
  445. 		else
  446. 		    newsym(x,y);
  447. 		unblock_point(x,y);		/* vision */
  448. 		if (shopdoor) {
  449. 		    add_damage(x, y, 400L);
  450. 		    pay_for_damage("break", FALSE);
  451. 		}
  452. 		if (in_town(x, y))
  453. 		  for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
  454. 		    if (DEADMONSTER(mtmp)) continue;
  455. 		    if((mtmp->data == &mons[PM_WATCHMAN] ||
  456. 			mtmp->data == &mons[PM_WATCH_CAPTAIN]) &&
  457. 			couldsee(mtmp->mx, mtmp->my) &&
  458. 			mtmp->mpeaceful) {
  459. 			if (canspotmon(mtmp))
  460. 			    pline("%s yells:", Amonnam(mtmp));
  461. 			else
  462. 			    You_hear("someone yell:");
  463. 			verbalize("Halt, thief!  You're under arrest!");
  464. 			(void) angry_guards(FALSE);
  465. 			break;
  466. 		    }
  467. 		  }
  468. 	} else {
  469. 	    if (Blind) feel_location(x,y);	/* we know we hit it */
  470. 	    exercise(A_STR, TRUE);
  471. 	    pline("WHAMMM!!!");
  472. 	    if (in_town(x, y))
  473. 		for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
  474. 		    if (DEADMONSTER(mtmp)) continue;
  475. 		    if ((mtmp->data == &mons[PM_WATCHMAN] ||
  476. 				mtmp->data == &mons[PM_WATCH_CAPTAIN]) &&
  477. 			    mtmp->mpeaceful && couldsee(mtmp->mx, mtmp->my)) {
  478. 			if (canspotmon(mtmp))
  479. 			    pline("%s yells:", Amonnam(mtmp));
  480. 			else
  481. 			    You_hear("someone yell:");
  482. 			if(levl[x][y].looted & D_WARNED) {
  483. 			    verbalize("Halt, vandal!  You're under arrest!");
  484. 			    (void) angry_guards(FALSE);
  485. 			} else {
  486. 			    verbalize("Hey, stop damaging that door!");
  487. 			    levl[x][y].looted |= D_WARNED;
  488. 			}
  489. 			break;
  490. 		    }
  491. 		}
  492. 	}
  493. 	return(1);
  494. }

drop_to[edit]

  1. STATIC_OVL void
  2. drop_to(cc, loc)
  3. coord *cc;
  4. schar loc;
  5. {
  6. 	/* cover all the MIGR_xxx choices generated by down_gate() */
  7. 	switch (loc) {
  8. 	 case MIGR_RANDOM:	/* trap door or hole */
  9. 		    if (Is_stronghold(&u.uz)) {
  10. 			cc->x = valley_level.dnum;
  11. 			cc->y = valley_level.dlevel;
  12. 			break;
  13. 		    } else if (In_endgame(&u.uz) || Is_botlevel(&u.uz)) {
  14. 			cc->y = cc->x = 0;
  15. 			break;
  16. 		    } /* else fall to the next cases */
  17. 	 case MIGR_STAIRS_UP:
  18. 	 case MIGR_LADDER_UP:
  19. 		    cc->x = u.uz.dnum;
  20. 		    cc->y = u.uz.dlevel + 1;
  21. 		    break;
  22. 	 case MIGR_SSTAIRS:
  23. 		    cc->x = sstairs.tolev.dnum;
  24. 		    cc->y = sstairs.tolev.dlevel;
  25. 		    break;
  26. 	 default:
  27. 	 case MIGR_NOWHERE:
  28. 		    /* y==0 means "nowhere", in which case x doesn't matter */
  29. 		    cc->y = cc->x = 0;
  30. 		    break;
  31. 	}
  32. }

impact_drop[edit]

  1. void
  2. impact_drop(missile, x, y, dlev)
  3. struct obj *missile;
  4. xchar x, y, dlev;
  5. {
  6. 	schar toloc;
  7. 	register struct obj *obj, *obj2;
  8. 	register struct monst *shkp;
  9. 	long oct, dct, price, debit, robbed;
  10. 	boolean angry, costly, isrock;
  11. 	coord cc;
  12.  
  13. 	if(!OBJ_AT(x, y)) return;
  14.  
  15. 	toloc = down_gate(x, y);
  16. 	drop_to(&cc, toloc);
  17. 	if (!cc.y) return;
  18.  
  19. 	if (dlev) {
  20. 		/* send objects next to player falling through trap door.
  21. 		 * checked in obj_delivery().
  22. 		 */
  23. 		toloc = MIGR_NEAR_PLAYER;
  24. 		cc.y = dlev;
  25. 	}
  26.  
  27. 	costly = costly_spot(x, y);
  28. 	price = debit = robbed = 0L;
  29. 	angry = FALSE;
  30. 	shkp = (struct monst *) 0;
  31. 	/* if 'costly', we must keep a record of ESHK(shkp) before
  32. 	 * it undergoes changes through the calls to stolen_value.
  33. 	 * the angry bit must be reset, if needed, in this fn, since
  34. 	 * stolen_value is called under the 'silent' flag to avoid
  35. 	 * unsavory pline repetitions.
  36. 	 */
  37. 	if(costly) {
  38. 	    if ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0) {
  39. 		debit	= ESHK(shkp)->debit;
  40. 		robbed	= ESHK(shkp)->robbed;
  41. 		angry	= !shkp->mpeaceful;
  42. 	    }
  43. 	}
  44.  
  45. 	isrock = (missile && missile->otyp == ROCK);
  46. 	oct = dct = 0L;
  47. 	for(obj = level.objects[x][y]; obj; obj = obj2) {
  48. 		obj2 = obj->nexthere;
  49. 		if(obj == missile) continue;
  50. 		/* number of objects in the pile */
  51. 		oct += obj->quan;
  52. 		if(obj == uball || obj == uchain) continue;
  53. 		/* boulders can fall too, but rarely & never due to rocks */
  54. 		if((isrock && obj->otyp == BOULDER) ||
  55. 		   rn2(obj->otyp == BOULDER ? 30 : 3)) continue;
  56. 		obj_extract_self(obj);
  57.  
  58. 		if(costly) {
  59. 		    price += stolen_value(obj, x, y,
  60. 				(costly_spot(u.ux, u.uy) &&
  61. 				 index(u.urooms, *in_rooms(x, y, SHOPBASE))),
  62. 				TRUE);
  63. 		    /* set obj->no_charge to 0 */
  64. 		    if (Has_contents(obj))
  65. 			picked_container(obj);	/* does the right thing */
  66. 		    if (obj->oclass != COIN_CLASS)
  67. 			obj->no_charge = 0;
  68. 		}
  69.  
  70. 		add_to_migration(obj);
  71. 		obj->ox = cc.x;
  72. 		obj->oy = cc.y;
  73. 		obj->owornmask = (long)toloc;
  74.  
  75. 		/* number of fallen objects */
  76. 		dct += obj->quan;
  77. 	}
  78.  
  79. 	if (dct && cansee(x,y)) {	/* at least one object fell */
  80. 	    const char *what = (dct == 1L ? "object falls" : "objects fall");
  81.  
  82. 	    if (missile)
  83. 		pline("From the impact, %sother %s.",
  84. 		      dct == oct ? "the " : dct == 1L ? "an" : "", what);
  85. 	    else if (oct == dct)
  86. 		pline("%s adjacent %s %s.",
  87. 		      dct == 1L ? "The" : "All the", what, gate_str);
  88. 	    else
  89. 		pline("%s adjacent %s %s.",
  90. 		      dct == 1L ? "One of the" : "Some of the",
  91. 		      dct == 1L ? "objects falls" : what, gate_str);
  92. 	}
  93.  
  94. 	if(costly && shkp && price) {
  95. 		if(ESHK(shkp)->robbed > robbed) {
  96. 		    You("removed %ld %s worth of goods!", price, currency(price));
  97. 		    if(cansee(shkp->mx, shkp->my)) {
  98. 			if(ESHK(shkp)->customer[0] == 0)
  99. 			    (void) strncpy(ESHK(shkp)->customer,
  100. 					   plname, PL_NSIZ);
  101. 			if(angry)
  102. 			    pline("%s is infuriated!", Monnam(shkp));
  103. 			else pline("\"%s, you are a thief!\"", plname);
  104. 		    } else  You_hear("a scream, \"Thief!\"");
  105. 		    hot_pursuit(shkp);
  106. 		    (void) angry_guards(FALSE);
  107. 		    return;
  108. 		}
  109. 		if(ESHK(shkp)->debit > debit) {
  110. 		    long amt = (ESHK(shkp)->debit - debit);
  111. 		    You("owe %s %ld %s for goods lost.",
  112. 			Monnam(shkp),
  113. 			amt, currency(amt));
  114. 		}
  115. 	}
  116.  
  117. }

ship_object[edit]

  1. /* NOTE: ship_object assumes otmp was FREED from fobj or invent.
  2. * <x,y> is the point of drop.  otmp is _not_ an <x,y> resident:
  3. * otmp is either a kicked, dropped, or thrown object.
  4. */
  5. boolean
  6. ship_object(otmp, x, y, shop_floor_obj)
  7. xchar  x, y;
  8. struct obj *otmp;
  9. boolean shop_floor_obj;
  10. {
  11. 	schar toloc;
  12. 	xchar ox, oy;
  13. 	coord cc;
  14. 	struct obj *obj;
  15. 	struct trap *t;
  16. 	boolean nodrop, unpaid, container, impact = FALSE;
  17. 	long n = 0L;
  18.  
  19. 	if (!otmp) return(FALSE);
  20. 	if ((toloc = down_gate(x, y)) == MIGR_NOWHERE) return(FALSE);
  21. 	drop_to(&cc, toloc);
  22. 	if (!cc.y) return(FALSE);
  23.  
  24. 	/* objects other than attached iron ball always fall down ladder,
  25. 	   but have a chance of staying otherwise */
  26. 	nodrop = (otmp == uball) || (otmp == uchain) ||
  27. 		(toloc != MIGR_LADDER_UP && rn2(3));
  28.  
  29. 	container = Has_contents(otmp);
  30. 	unpaid = (otmp->unpaid || (container && count_unpaid(otmp->cobj)));
  31.  
  32. 	if(OBJ_AT(x, y)) {
  33. 	    for(obj = level.objects[x][y]; obj; obj = obj->nexthere)
  34. 		if(obj != otmp) n += obj->quan;
  35. 	    if(n) impact = TRUE;
  36. 	}
  37. 	/* boulders never fall through trap doors, but they might knock
  38. 	   other things down before plugging the hole */
  39. 	if (otmp->otyp == BOULDER &&
  40. 		((t = t_at(x, y)) != 0) &&
  41. 		(t->ttyp == TRAPDOOR || t->ttyp == HOLE)) {
  42. 	    if (impact) impact_drop(otmp, x, y, 0);
  43. 	    return FALSE;		/* let caller finish the drop */
  44. 	}
  45.  
  46. 	if (cansee(x, y))
  47. 	    otransit_msg(otmp, nodrop, n);
  48.  
  49. 	if (nodrop) {
  50. 	    if (impact) impact_drop(otmp, x, y, 0);
  51. 	    return(FALSE);
  52. 	}
  53.  
  54. 	if(unpaid || shop_floor_obj) {
  55. 	    if(unpaid) {
  56. 		subfrombill(otmp, shop_keeper(*u.ushops));
  57. 		(void)stolen_value(otmp, u.ux, u.uy, TRUE, FALSE);
  58. 	    } else {
  59. 		ox = otmp->ox;
  60. 		oy = otmp->oy;
  61. 		(void)stolen_value(otmp, ox, oy,
  62. 			  (costly_spot(u.ux, u.uy) &&
  63. 			      index(u.urooms, *in_rooms(ox, oy, SHOPBASE))),
  64. 			  FALSE);
  65. 	    }
  66. 	    /* set otmp->no_charge to 0 */
  67. 	    if(container)
  68. 		picked_container(otmp); /* happens to do the right thing */
  69. 	    if(otmp->oclass != COIN_CLASS)
  70. 		otmp->no_charge = 0;
  71. 	}
  72.  
  73. 	if (otmp == uwep) setuwep((struct obj *)0);
  74. 	if (otmp == uquiver) setuqwep((struct obj *)0);
  75. 	if (otmp == uswapwep) setuswapwep((struct obj *)0);
  76.  
  77. 	/* some things break rather than ship */
  78. 	if (breaktest(otmp)) {
  79. 	    const char *result;
  80.  
  81. 	    if (objects[otmp->otyp].oc_material == GLASS
  82. #ifdef TOURIST
  83. 		|| otmp->otyp == EXPENSIVE_CAMERA
  84. #endif
  85. 		) {
  86. 		if (otmp->otyp == MIRROR)
  87. 		    change_luck(-2);
  88. 		result = "crash";
  89. 	    } else {
  90. 		/* penalty for breaking eggs laid by you */
  91. 		if (otmp->otyp == EGG && otmp->spe && otmp->corpsenm >= LOW_PM)
  92. 		    change_luck((schar) -min(otmp->quan, 5L));
  93. 		result = "splat";
  94. 	    }
  95. 	    You_hear("a muffled %s.",result);
  96. 	    obj_extract_self(otmp);
  97. 	    obfree(otmp, (struct obj *) 0);
  98. 	    return TRUE;
  99. 	}
  100.  
  101. 	add_to_migration(otmp);
  102. 	otmp->ox = cc.x;
  103. 	otmp->oy = cc.y;
  104. 	otmp->owornmask = (long)toloc;
  105. 	/* boulder from rolling boulder trap, no longer part of the trap */
  106. 	if (otmp->otyp == BOULDER) otmp->otrapped = 0;
  107.  
  108. 	if(impact) {
  109. 	    /* the objs impacted may be in a shop other than
  110. 	     * the one in which the hero is located.  another
  111. 	     * check for a shk is made in impact_drop.  it is, e.g.,
  112. 	     * possible to kick/throw an object belonging to one
  113. 	     * shop into another shop through a gap in the wall,
  114. 	     * and cause objects belonging to the other shop to
  115. 	     * fall down a trap door--thereby getting two shopkeepers
  116. 	     * angry at the hero in one shot.
  117. 	     */
  118. 	    impact_drop(otmp, x, y, 0);
  119. 	    newsym(x,y);
  120. 	}
  121. 	return(TRUE);
  122. }

obj_delivery[edit]

  1. void
  2. obj_delivery()
  3. {
  4. 	register struct obj *otmp, *otmp2;
  5. 	register int nx, ny;
  6. 	long where;
  7.  
  8. 	for (otmp = migrating_objs; otmp; otmp = otmp2) {
  9. 	    otmp2 = otmp->nobj;
  10. 	    if (otmp->ox != u.uz.dnum || otmp->oy != u.uz.dlevel) continue;
  11.  
  12. 	    obj_extract_self(otmp);
  13. 	    where = otmp->owornmask;		/* destination code */
  14. 	    otmp->owornmask = 0L;
  15.  
  16. 	    switch ((int)where) {
  17. 	     case MIGR_STAIRS_UP:   nx = xupstair,  ny = yupstair;
  18. 				break;
  19. 	     case MIGR_LADDER_UP:   nx = xupladder,  ny = yupladder;
  20. 				break;
  21. 	     case MIGR_SSTAIRS:	    nx = sstairs.sx,  ny = sstairs.sy;
  22. 				break;
  23. 	     case MIGR_NEAR_PLAYER: nx = u.ux,  ny = u.uy;
  24. 				break;
  25. 	     default:
  26. 	     case MIGR_RANDOM:	    nx = ny = 0;
  27. 				break;
  28. 	    }
  29. 	    if (nx > 0) {
  30. 		place_object(otmp, nx, ny);
  31. 		stackobj(otmp);
  32. 		(void)scatter(nx, ny, rnd(2), 0, otmp);
  33. 	    } else {		/* random location */
  34. 		/* set dummy coordinates because there's no
  35. 		   current position for rloco() to update */
  36. 		otmp->ox = otmp->oy = 0;
  37. 		rloco(otmp);
  38. 	    }
  39. 	}
  40. }

otransit_msg[edit]

  1. STATIC_OVL void
  2. otransit_msg(otmp, nodrop, num)
  3. register struct obj *otmp;
  4. register boolean nodrop;
  5. long num;
  6. {
  7. 	char obuf[BUFSZ];
  8.  
  9. 	Sprintf(obuf, "%s%s",
  10. 		 (otmp->otyp == CORPSE &&
  11. 			type_is_pname(&mons[otmp->corpsenm])) ? "" : "The ",
  12. 		 xname(otmp));
  13.  
  14. 	if(num) { /* means: other objects are impacted */
  15. 	    Sprintf(eos(obuf), " %s %s object%s",
  16. 		    otense(otmp, "hit"),
  17. 		    num == 1L ? "another" : "other",
  18. 		    num > 1L ? "s" : "");
  19. 	    if(nodrop)
  20. 		Sprintf(eos(obuf), ".");
  21. 	    else
  22. 		Sprintf(eos(obuf), " and %s %s.",
  23. 			otense(otmp, "fall"), gate_str);
  24. 	    pline("%s", obuf);
  25. 	} else if(!nodrop)
  26. 	    pline("%s %s %s.", obuf, otense(otmp, "fall"), gate_str);
  27. }

down_gate[edit]

  1. /* migration destination for objects which fall down to next level */
  2. schar
  3. down_gate(x, y)
  4. xchar x, y;
  5. {
  6. 	struct trap *ttmp;
  7.  
  8. 	gate_str = 0;
  9. 	/* this matches the player restriction in goto_level() */
  10. 	if (on_level(&u.uz, &qstart_level) && !ok_to_quest())
  11. 	    return MIGR_NOWHERE;
  12.  
  13. 	if ((xdnstair == x && ydnstair == y) ||
  14. 		(sstairs.sx == x && sstairs.sy == y && !sstairs.up)) {
  15. 	    gate_str = "down the stairs";
  16. 	    return (xdnstair == x && ydnstair == y) ?
  17. 		    MIGR_STAIRS_UP : MIGR_SSTAIRS;
  18. 	}
  19. 	if (xdnladder == x && ydnladder == y) {
  20. 	    gate_str = "down the ladder";
  21. 	    return MIGR_LADDER_UP;
  22. 	}
  23.  
  24. 	if (((ttmp = t_at(x, y)) != 0 && ttmp->tseen) &&
  25. 		(ttmp->ttyp == TRAPDOOR || ttmp->ttyp == HOLE)) {
  26. 	    gate_str = (ttmp->ttyp == TRAPDOOR) ?
  27. 		    "through the trap door" : "through the hole";
  28. 	    return MIGR_RANDOM;
  29. 	}
  30. 	return MIGR_NOWHERE;
  31. }
  32.  
  33. /*dokick.c*/