Source:NetHack 3.4.3/src/steed.c

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

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

Top of file

  1. /*	SCCS Id: @(#)steed.c	3.4	2003/01/10	*/
  2. /* Copyright (c) Kevin Hugo, 1998-1999. */
  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.  
  3.  
  4. #ifdef STEED
  5.  
  6. /* Monsters that might be ridden */
  7. static NEARDATA const char steeds[] = {
  8. 	S_QUADRUPED, S_UNICORN, S_ANGEL, S_CENTAUR, S_DRAGON, S_JABBERWOCK, '\0'
  9. };
  10.  
  11. STATIC_DCL boolean FDECL(landing_spot, (coord *, int, int));

rider_cant_reach

  1. /* caller has decided that hero can't reach something while mounted */
  2. void
  3. rider_cant_reach()
  4. {
  5. You("aren't skilled enough to reach from %s.", y_monnam(u.usteed));
  6. }

Putting the saddle on

  1. /*** Putting the saddle on ***/

can_saddle

  1. /* Can this monster wear a saddle? */
  2. boolean
  3. can_saddle(mtmp)
  4. 	struct monst *mtmp;
  5. {
  6. 	struct permonst *ptr = mtmp->data;
  7.  
  8. 	return (index(steeds, ptr->mlet) && (ptr->msize >= MZ_MEDIUM) &&
  9. 			(!humanoid(ptr) || ptr->mlet == S_CENTAUR) &&
  10. 			!amorphous(ptr) && !noncorporeal(ptr) &&
  11. 			!is_whirly(ptr) && !unsolid(ptr));
  12. }

use_saddle

  1. int
  2. use_saddle(otmp)
  3. 	struct obj *otmp;
  4. {
  5. 	struct monst *mtmp;
  6. 	struct permonst *ptr;
  7. 	int chance;
  8. 	const char *s;
  9.  
  10.  
  11. 	/* Can you use it? */
  12. 	if (nohands(youmonst.data)) {
  13. 		You("have no hands!");	/* not `body_part(HAND)' */
  14. 		return 0;
  15. 	} else if (!freehand()) {
  16. 		You("have no free %s.", body_part(HAND));
  17. 		return 0;
  18. 	}
  19.  
  20. 	/* Select an animal */
  21. 	if (u.uswallow || Underwater || !getdir((char *)0)) {
  22. 	    pline(Never_mind);
  23. 	    return 0;
  24. 	}
  25. 	if (!u.dx && !u.dy) {
  26. 	    pline("Saddle yourself?  Very funny...");
  27. 	    return 0;
  28. 	}
  29. 	if (!isok(u.ux+u.dx, u.uy+u.dy) ||
  30. 			!(mtmp = m_at(u.ux+u.dx, u.uy+u.dy)) ||
  31. 			!canspotmon(mtmp)) {
  32. 	    pline("I see nobody there.");
  33. 	    return 1;
  34. 	}
  35.  
  36. 	/* Is this a valid monster? */
  37. 	if (mtmp->misc_worn_check & W_SADDLE ||
  38. 			which_armor(mtmp, W_SADDLE)) {
  39. 	    pline("%s doesn't need another one.", Monnam(mtmp));
  40. 	    return 1;
  41. 	}
  42. 	ptr = mtmp->data;
  43. 	if (touch_petrifies(ptr) && !uarmg && !Stone_resistance) {
  44. 	    char kbuf[BUFSZ];
  45.  
  46. 	    You("touch %s.", mon_nam(mtmp));
  47. 	    if (!(poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))) {
  48. 		Sprintf(kbuf, "attempting to saddle %s", an(mtmp->data->mname));
  49. 		instapetrify(kbuf);
  50. 	    }
  51. 	}
  52. 	if (ptr == &mons[PM_INCUBUS] || ptr == &mons[PM_SUCCUBUS]) {
  53. 	    pline("Shame on you!");
  54. 	    exercise(A_WIS, FALSE);
  55. 	    return 1;
  56. 	}
  57. 	if (mtmp->isminion || mtmp->isshk || mtmp->ispriest ||
  58. 			mtmp->isgd || mtmp->iswiz) {
  59. 	    pline("I think %s would mind.", mon_nam(mtmp));
  60. 	    return 1;
  61. 	}
  62. 	if (!can_saddle(mtmp)) {
  63. 		You_cant("saddle such a creature.");
  64. 		return 1;
  65. 	}
  66.  
  67. 	/* Calculate your chance */
  68. 	chance = ACURR(A_DEX) + ACURR(A_CHA)/2 + 2*mtmp->mtame;
  69. 	chance += u.ulevel * (mtmp->mtame ? 20 : 5);
  70. 	if (!mtmp->mtame) chance -= 10*mtmp->m_lev;
  71. 	if (Role_if(PM_KNIGHT))
  72. 	    chance += 20;
  73. 	switch (P_SKILL(P_RIDING)) {
  74. 	case P_ISRESTRICTED:
  75. 	case P_UNSKILLED:
  76. 	default:
  77. 	    chance -= 20;	break;
  78. 	case P_BASIC:
  79. 	    break;
  80. 	case P_SKILLED:
  81. 	    chance += 15;	break;
  82. 	case P_EXPERT:
  83. 	    chance += 30;	break;
  84. 	}
  85. 	if (Confusion || Fumbling || Glib)
  86. 	    chance -= 20;
  87. 	else if (uarmg &&
  88. 		(s = OBJ_DESCR(objects[uarmg->otyp])) != (char *)0 &&
  89. 		!strncmp(s, "riding ", 7))
  90. 	    /* Bonus for wearing "riding" (but not fumbling) gloves */
  91. 	    chance += 10;
  92. 	else if (uarmf &&
  93. 		(s = OBJ_DESCR(objects[uarmf->otyp])) != (char *)0 &&
  94. 		!strncmp(s, "riding ", 7))
  95. 	    /* ... or for "riding boots" */
  96. 	    chance += 10;
  97. 	if (otmp->cursed)
  98. 	    chance -= 50;
  99.  
  100. 	/* Make the attempt */
  101. 	if (rn2(100) < chance) {
  102. 	    You("put the saddle on %s.", mon_nam(mtmp));
  103. 	    if (otmp->owornmask) remove_worn_item(otmp, FALSE);
  104. 	    freeinv(otmp);
  105. 	    /* mpickobj may free otmp it if merges, but we have already
  106. 	       checked for a saddle above, so no merger should happen */
  107. 	    (void) mpickobj(mtmp, otmp);
  108. 	    mtmp->misc_worn_check |= W_SADDLE;
  109. 	    otmp->owornmask = W_SADDLE;
  110. 	    otmp->leashmon = mtmp->m_id;
  111. 	    update_mon_intrinsics(mtmp, otmp, TRUE, FALSE);
  112. 	} else
  113. 	    pline("%s resists!", Monnam(mtmp));
  114. 	return 1;
  115. }

Riding the monster

  1. /*** Riding the monster ***/

can_ride

  1. /* Can we ride this monster?  Caller should also check can_saddle() */
  2. boolean
  3. can_ride(mtmp)
  4. 	struct monst *mtmp;
  5. {
  6. 	return (mtmp->mtame && humanoid(youmonst.data) &&
  7. 			!verysmall(youmonst.data) && !bigmonst(youmonst.data) &&
  8. 			(!Underwater || is_swimmer(mtmp->data)));
  9. }

doride

  1. int
  2. doride()
  3. {
  4. 	boolean forcemount = FALSE;
  5.  
  6. 	if (u.usteed)
  7. 	    dismount_steed(DISMOUNT_BYCHOICE);
  8. 	else if (getdir((char *)0) && isok(u.ux+u.dx, u.uy+u.dy)) {
  9. #ifdef WIZARD
  10. 	if (wizard && yn("Force the mount to succeed?") == 'y')
  11. 		forcemount = TRUE;
  12. #endif
  13. 	    return (mount_steed(m_at(u.ux+u.dx, u.uy+u.dy), forcemount));
  14. 	} else
  15. 	    return 0;
  16. 	return 1;
  17. }

mount_steed

  1. /* Start riding, with the given monster */
  2. boolean
  3. mount_steed(mtmp, force)
  4. 	struct monst *mtmp;	/* The animal */
  5. 	boolean force;		/* Quietly force this animal */
  6. {
  7. 	struct obj *otmp;
  8. 	char buf[BUFSZ];
  9. 	struct permonst *ptr;
  10.  
  11. 	/* Sanity checks */
  12. 	if (u.usteed) {
  13. 	    You("are already riding %s.", mon_nam(u.usteed));
  14. 	    return (FALSE);
  15. 	}
  16.  
  17. 	/* Is the player in the right form? */
  18. 	if (Hallucination && !force) {
  19. 	    pline("Maybe you should find a designated driver.");
  20. 	    return (FALSE);
  21. 	}
  22. 	/* While riding Wounded_legs refers to the steed's,
  23. 	 * not the hero's legs.
  24. 	 * That opens up a potential abuse where the player
  25. 	 * can mount a steed, then dismount immediately to
  26. 	 * heal leg damage, because leg damage is always
  27. 	 * healed upon dismount (Wounded_legs context switch).
  28. 	 * By preventing a hero with Wounded_legs from
  29. 	 * mounting a steed, the potential for abuse is
  30. 	 * minimized, if not eliminated altogether.
  31. 	 */
  32. 	if (Wounded_legs) {
  33. 	    Your("%s are in no shape for riding.", makeplural(body_part(LEG)));
  34. #ifdef WIZARD
  35. 	    if (force && wizard && yn("Heal your legs?") == 'y')
  36. 		HWounded_legs = EWounded_legs = 0;
  37. 	    else
  38. #endif
  39. 	    return (FALSE);
  40. 	}
  41.  
  42. 	if (Upolyd && (!humanoid(youmonst.data) || verysmall(youmonst.data) ||
  43. 			bigmonst(youmonst.data) || slithy(youmonst.data))) {
  44. 	    You("won't fit on a saddle.");
  45. 	    return (FALSE);
  46. 	}
  47. 	if(!force && (near_capacity() > SLT_ENCUMBER)) {
  48. 	    You_cant("do that while carrying so much stuff.");
  49. 	    return (FALSE);
  50. 	}
  51.  
  52. 	/* Can the player reach and see the monster? */
  53. 	if (!mtmp || (!force && ((Blind && !Blind_telepat) ||
  54. 		mtmp->mundetected ||
  55. 		mtmp->m_ap_type == M_AP_FURNITURE ||
  56. 		mtmp->m_ap_type == M_AP_OBJECT))) {
  57. 	    pline("I see nobody there.");
  58. 	    return (FALSE);
  59. 	}
  60. 	if (u.uswallow || u.ustuck || u.utrap || Punished ||
  61. 	    !test_move(u.ux, u.uy, mtmp->mx-u.ux, mtmp->my-u.uy, TEST_MOVE)) {
  62. 	    if (Punished || !(u.uswallow || u.ustuck || u.utrap))
  63. 		You("are unable to swing your %s over.", body_part(LEG)); 
  64. 	    else
  65. 		You("are stuck here for now.");
  66. 	    return (FALSE);
  67. 	}
  68.  
  69. 	/* Is this a valid monster? */
  70. 	otmp = which_armor(mtmp, W_SADDLE);
  71. 	if (!otmp) {
  72. 	    pline("%s is not saddled.", Monnam(mtmp));
  73. 	    return (FALSE);
  74. 	}
  75. 	ptr = mtmp->data;
  76. 	if (touch_petrifies(ptr) && !Stone_resistance) {
  77. 	    char kbuf[BUFSZ];
  78.  
  79. 	    You("touch %s.", mon_nam(mtmp));
  80. 	    Sprintf(kbuf, "attempting to ride %s", an(mtmp->data->mname));
  81. 	    instapetrify(kbuf);
  82. 	}
  83. 	if (!mtmp->mtame || mtmp->isminion) {
  84. 	    pline("I think %s would mind.", mon_nam(mtmp));
  85. 	    return (FALSE);
  86. 	}
  87. 	if (mtmp->mtrapped) {
  88. 	    struct trap *t = t_at(mtmp->mx, mtmp->my);
  89.  
  90. 	    You_cant("mount %s while %s's trapped in %s.",
  91. 		     mon_nam(mtmp), mhe(mtmp),
  92. 		     an(defsyms[trap_to_defsym(t->ttyp)].explanation));
  93. 	    return (FALSE);
  94. 	}
  95.  
  96. 	if (!force && !Role_if(PM_KNIGHT) && !(--mtmp->mtame)) {
  97. 	    /* no longer tame */
  98. 	    newsym(mtmp->mx, mtmp->my);
  99. 	    pline("%s resists%s!", Monnam(mtmp),
  100. 		  mtmp->mleashed ? " and its leash comes off" : "");
  101. 	    if (mtmp->mleashed) m_unleash(mtmp, FALSE);
  102. 	    return (FALSE);
  103. 	}
  104. 	if (!force && Underwater && !is_swimmer(ptr)) {
  105. 	    You_cant("ride that creature while under water.");
  106. 	    return (FALSE);
  107. 	}
  108. 	if (!can_saddle(mtmp) || !can_ride(mtmp)) {
  109. 	    You_cant("ride such a creature.");
  110. 	    return (0);
  111. 	}
  112.  
  113. 	/* Is the player impaired? */
  114. 	if (!force && !is_floater(ptr) && !is_flyer(ptr) &&
  115. 			Levitation && !Lev_at_will) {
  116. 	    You("cannot reach %s.", mon_nam(mtmp));
  117. 	    return (FALSE);
  118. 	}
  119. 	if (!force && uarm && is_metallic(uarm) &&
  120. 			greatest_erosion(uarm)) {
  121. 	    Your("%s armor is too stiff to be able to mount %s.",
  122. 			uarm->oeroded ? "rusty" : "corroded",
  123. 			mon_nam(mtmp));
  124. 	    return (FALSE);
  125. 	}
  126. 	if (!force && (Confusion || Fumbling || Glib || Wounded_legs ||
  127. 		otmp->cursed || (u.ulevel+mtmp->mtame < rnd(MAXULEV/2+5)))) {
  128. 	    if (Levitation) {
  129. 		pline("%s slips away from you.", Monnam(mtmp));
  130. 		return FALSE;
  131. 	    }
  132. 	    You("slip while trying to get on %s.", mon_nam(mtmp));
  133.  
  134. 	    Sprintf(buf, "slipped while mounting %s",
  135. 		    /* "a saddled mumak" or "a saddled pony called Dobbin" */
  136. 		    x_monnam(mtmp, ARTICLE_A, (char *)0,
  137. 			SUPPRESS_IT|SUPPRESS_INVISIBLE|SUPPRESS_HALLUCINATION,
  138. 			     TRUE));
  139. 	    losehp(rn1(5,10), buf, NO_KILLER_PREFIX);
  140. 	    return (FALSE);
  141. 	}
  142.  
  143. 	/* Success */
  144. 	if (!force) {
  145. 	    if (Levitation && !is_floater(ptr) && !is_flyer(ptr))
  146. 	    	/* Must have Lev_at_will at this point */
  147. 	    	pline("%s magically floats up!", Monnam(mtmp));
  148. 	    You("mount %s.", mon_nam(mtmp));
  149. 	}
  150. 	/* setuwep handles polearms differently when you're mounted */
  151. 	if (uwep && is_pole(uwep)) unweapon = FALSE;
  152. 	u.usteed = mtmp;
  153. 	remove_monster(mtmp->mx, mtmp->my);
  154. 	teleds(mtmp->mx, mtmp->my, TRUE);
  155. 	return (TRUE);
  156. }

exercise_steed

  1. /* You and your steed have moved */
  2. void
  3. exercise_steed()
  4. {
  5. 	if (!u.usteed)
  6. 		return;
  7.  
  8. 	/* It takes many turns of riding to exercise skill */
  9. 	if (u.urideturns++ >= 100) {
  10. 	    u.urideturns = 0;
  11. 	    use_skill(P_RIDING, 1);
  12. 	}
  13. 	return;
  14. }

kick_steed

  1. /* The player kicks or whips the steed */
  2. void
  3. kick_steed()
  4. {
  5. 	char He[4];
  6. 	if (!u.usteed)
  7. 	    return;
  8.  
  9. 	/* [ALI] Various effects of kicking sleeping/paralyzed steeds */
  10. 	if (u.usteed->msleeping || !u.usteed->mcanmove) {
  11. 	    /* We assume a message has just been output of the form
  12. 	     * "You kick <steed>."
  13. 	     */
  14. 	    Strcpy(He, mhe(u.usteed));
  15. 	    *He = highc(*He);
  16. 	    if ((u.usteed->mcanmove || u.usteed->mfrozen) && !rn2(2)) {
  17. 		if (u.usteed->mcanmove)
  18. 		    u.usteed->msleeping = 0;
  19. 		else if (u.usteed->mfrozen > 2)
  20. 		    u.usteed->mfrozen -= 2;
  21. 		else {
  22. 		    u.usteed->mfrozen = 0;
  23. 		    u.usteed->mcanmove = 1;
  24. 		}
  25. 		if (u.usteed->msleeping || !u.usteed->mcanmove)
  26. 		    pline("%s stirs.", He);
  27. 		else
  28. 		    pline("%s rouses %sself!", He, mhim(u.usteed));
  29. 	    } else
  30. 		pline("%s does not respond.", He);
  31. 	    return;
  32. 	}
  33.  
  34. 	/* Make the steed less tame and check if it resists */
  35. 	if (u.usteed->mtame) u.usteed->mtame--;
  36. 	if (!u.usteed->mtame && u.usteed->mleashed) m_unleash(u.usteed, TRUE);
  37. 	if (!u.usteed->mtame || (u.ulevel+u.usteed->mtame < rnd(MAXULEV/2+5))) {
  38. 	    newsym(u.usteed->mx, u.usteed->my);
  39. 	    dismount_steed(DISMOUNT_THROWN);
  40. 	    return;
  41. 	}
  42.  
  43. 	pline("%s gallops!", Monnam(u.usteed));
  44. 	u.ugallop += rn1(20, 30);
  45. 	return;
  46. }

landing_spot

  1. /*
  2. * Try to find a dismount point adjacent to the steed's location.
  3. * If all else fails, try enexto().  Use enexto() as a last resort because
  4. * enexto() chooses its point randomly, possibly even outside the
  5. * room's walls, which is not what we want.
  6. * Adapted from mail daemon code.
  7. */
  8. STATIC_OVL boolean
  9. landing_spot(spot, reason, forceit)
  10. coord *spot;	/* landing position (we fill it in) */
  11. int reason;
  12. int forceit;
  13. {
  14. int i = 0, x, y, distance, min_distance = -1;
  15. boolean found = FALSE;
  16. struct trap *t;
  17.  
  18. /* avoid known traps (i == 0) and boulders, but allow them as a backup */
  19. if (reason != DISMOUNT_BYCHOICE || Stunned || Confusion || Fumbling) i = 1;
  20. for (; !found && i < 2; ++i) {
  21. 	for (x = u.ux-1; x <= u.ux+1; x++)
  22. 	    for (y = u.uy-1; y <= u.uy+1; y++) {
  23. 		if (!isok(x, y) || (x == u.ux && y == u.uy)) continue;
  24.  
  25. 		if (ACCESSIBLE(levl[x][y].typ) &&
  26. 			    !MON_AT(x,y) && !closed_door(x,y)) {
  27. 		    distance = distu(x,y);
  28. 		    if (min_distance < 0 || distance < min_distance ||
  29. 			    (distance == min_distance && rn2(2))) {
  30. 			if (i > 0 || (((t = t_at(x, y)) == 0 || !t->tseen) &&
  31. 				      (!sobj_at(BOULDER, x, y) ||
  32. 				       throws_rocks(youmonst.data)))) {
  33. 			    spot->x = x;
  34. 			    spot->y = y;
  35. 			    min_distance = distance;
  36. 			    found = TRUE;
  37. 			}
  38. 		    }
  39. 		}
  40. 	    }
  41. }
  42.  
  43. /* If we didn't find a good spot and forceit is on, try enexto(). */
  44. if (forceit && min_distance < 0 &&
  45. 		!enexto(spot, u.ux, u.uy, youmonst.data))
  46. 	return FALSE;
  47.  
  48. return found;
  49. }

dismount_steed

  1. /* Stop riding the current steed */
  2. void
  3. dismount_steed(reason)
  4. 	int reason;		/* Player was thrown off etc. */
  5. {
  6. 	struct monst *mtmp;
  7. 	struct obj *otmp;
  8. 	coord cc;
  9. 	const char *verb = "fall";
  10. 	boolean repair_leg_damage = TRUE;
  11. 	unsigned save_utrap = u.utrap;
  12. 	boolean have_spot = landing_spot(&cc,reason,0);
  13.  
  14. 	mtmp = u.usteed;		/* make a copy of steed pointer */
  15. 	/* Sanity check */
  16. 	if (!mtmp)		/* Just return silently */
  17. 	    return;
  18.  
  19. 	/* Check the reason for dismounting */
  20. 	otmp = which_armor(mtmp, W_SADDLE);
  21. 	switch (reason) {
  22. 	    case DISMOUNT_THROWN:
  23. 		verb = "are thrown";
  24. 	    case DISMOUNT_FELL:
  25. 		You("%s off of %s!", verb, mon_nam(mtmp));
  26. 		if (!have_spot) have_spot = landing_spot(&cc,reason,1);
  27. 		losehp(rn1(10,10), "riding accident", KILLED_BY_AN);
  28. 		set_wounded_legs(BOTH_SIDES, (int)HWounded_legs + rn1(5,5));
  29. 		repair_leg_damage = FALSE;
  30. 		break;
  31. 	    case DISMOUNT_POLY:
  32. 		You("can no longer ride %s.", mon_nam(u.usteed));
  33. 		if (!have_spot) have_spot = landing_spot(&cc,reason,1);
  34. 		break;
  35. 	    case DISMOUNT_ENGULFED:
  36. 		/* caller displays message */
  37. 		break;
  38. 	    case DISMOUNT_BONES:
  39. 		/* hero has just died... */
  40. 		break;
  41. 	    case DISMOUNT_GENERIC:
  42. 		/* no messages, just make it so */
  43. 		break;
  44. 	    case DISMOUNT_BYCHOICE:
  45. 	    default:
  46. 		if (otmp && otmp->cursed) {
  47. 		    You("can't.  The saddle %s cursed.",
  48. 			otmp->bknown ? "is" : "seems to be");
  49. 		    otmp->bknown = TRUE;
  50. 		    return;
  51. 		}
  52. 		if (!have_spot) {
  53. 		    You("can't. There isn't anywhere for you to stand.");
  54. 		    return;
  55. 		}
  56. 		if (!mtmp->mnamelth) {
  57. 			pline("You've been through the dungeon on %s with no name.",
  58. 				an(mtmp->data->mname));
  59. 			if (Hallucination)
  60. 				pline("It felt good to get out of the rain.");
  61. 		} else
  62. 			You("dismount %s.", mon_nam(mtmp));
  63. 	}
  64. 	/* While riding these refer to the steed's legs
  65. 	 * so after dismounting they refer to the player's
  66. 	 * legs once again.
  67. 	 */
  68. 	if (repair_leg_damage) HWounded_legs = EWounded_legs = 0;
  69.  
  70. 	/* Release the steed and saddle */
  71. 	u.usteed = 0;
  72. 	u.ugallop = 0L;
  73.  
  74. 	/* Set player and steed's position.  Try moving the player first
  75. 	   unless we're in the midst of creating a bones file. */
  76. 	if (reason == DISMOUNT_BONES) {
  77. 	    /* move the steed to an adjacent square */
  78. 	    if (enexto(&cc, u.ux, u.uy, mtmp->data))
  79. 		rloc_to(mtmp, cc.x, cc.y);
  80. 	    else	/* evidently no room nearby; move steed elsewhere */
  81. 		(void) rloc(mtmp, FALSE);
  82. 	    return;
  83. 	}
  84. 	if (!DEADMONSTER(mtmp)) {
  85. 	    place_monster(mtmp, u.ux, u.uy);
  86. 	    if (!u.uswallow && !u.ustuck && have_spot) {
  87. 		struct permonst *mdat = mtmp->data;
  88.  
  89. 		/* The steed may drop into water/lava */
  90. 		if (!is_flyer(mdat) && !is_floater(mdat) && !is_clinger(mdat)) {
  91. 		    if (is_pool(u.ux, u.uy)) {
  92. 			if (!Underwater)
  93. 			    pline("%s falls into the %s!", Monnam(mtmp),
  94. 							surface(u.ux, u.uy));
  95. 			if (!is_swimmer(mdat) && !amphibious(mdat)) {
  96. 			    killed(mtmp);
  97. 			    adjalign(-1);
  98. 			}
  99. 		    } else if (is_lava(u.ux, u.uy)) {
  100. 			pline("%s is pulled into the lava!", Monnam(mtmp));
  101. 			if (!likes_lava(mdat)) {
  102. 			    killed(mtmp);
  103. 			    adjalign(-1);
  104. 			}
  105. 		    }
  106. 		}
  107. 	    /* Steed dismounting consists of two steps: being moved to another
  108. 	     * square, and descending to the floor.  We have functions to do
  109. 	     * each of these activities, but they're normally called
  110. 	     * individually and include an attempt to look at or pick up the
  111. 	     * objects on the floor:
  112. 	     * teleds() --> spoteffects() --> pickup()
  113. 	     * float_down() --> pickup()
  114. 	     * We use this kludge to make sure there is only one such attempt.
  115. 	     *
  116. 	     * Clearly this is not the best way to do it.  A full fix would
  117. 	     * involve having these functions not call pickup() at all, instead
  118. 	     * calling them first and calling pickup() afterwards.  But it
  119. 	     * would take a lot of work to keep this change from having any
  120. 	     * unforseen side effects (for instance, you would no longer be
  121. 	     * able to walk onto a square with a hole, and autopickup before
  122. 	     * falling into the hole).
  123. 	     */
  124. 		/* [ALI] No need to move the player if the steed died. */
  125. 		if (!DEADMONSTER(mtmp)) {
  126. 		    /* Keep steed here, move the player to cc;
  127. 		     * teleds() clears u.utrap
  128. 		     */
  129. 		    in_steed_dismounting = TRUE;
  130. 		    teleds(cc.x, cc.y, TRUE);
  131. 		    in_steed_dismounting = FALSE;
  132.  
  133. 		    /* Put your steed in your trap */
  134. 		    if (save_utrap)
  135. 			(void) mintrap(mtmp);
  136. 		}
  137. 	    /* Couldn't... try placing the steed */
  138. 	    } else if (enexto(&cc, u.ux, u.uy, mtmp->data)) {
  139. 		/* Keep player here, move the steed to cc */
  140. 		rloc_to(mtmp, cc.x, cc.y);
  141. 		/* Player stays put */
  142. 	    /* Otherwise, kill the steed */
  143. 	    } else {
  144. 		killed(mtmp);
  145. 		adjalign(-1);
  146. 	    }
  147. 	}
  148.  
  149. 	/* Return the player to the floor */
  150. 	if (reason != DISMOUNT_ENGULFED) {
  151. 	    in_steed_dismounting = TRUE;
  152. 	    (void) float_down(0L, W_SADDLE);
  153. 	    in_steed_dismounting = FALSE;
  154. 	    flags.botl = 1;
  155. 	    (void)encumber_msg();
  156. 	    vision_full_recalc = 1;
  157. 	} else
  158. 	    flags.botl = 1;
  159. 	/* polearms behave differently when not mounted */
  160. 	if (uwep && is_pole(uwep)) unweapon = TRUE;
  161. 	return;
  162. }

place_monster

  1. void
  2. place_monster(mon, x, y)
  3. struct monst *mon;
  4. int x, y;
  5. {
  6. if (mon == u.usteed ||
  7. 	    /* special case is for convoluted vault guard handling */
  8. 	    (DEADMONSTER(mon) && !(mon->isgd && x == 0 && y == 0))) {
  9. 	impossible("placing %s onto map?",
  10. 		   (mon == u.usteed) ? "steed" : "defunct monster");
  11. 	return;
  12. }
  13. mon->mx = x, mon->my = y;
  14. level.monsters[x][y] = mon;
  15. }
  16.  
  17. #endif /* STEED */
  18.  
  19. /*steed.c*/