U338 - dismounting into known traps

When dismounting by choice and not impaired, the player could end up in a
known trap even if better positions were available.  This change allows
the landing spot to prefer non-traps in these cases.
This commit is contained in:
cohrs
2003-06-08 17:51:57 +00:00
parent 083efbb630
commit e33b62192c
2 changed files with 30 additions and 21 deletions

View File

@@ -90,6 +90,7 @@ use correct pronoun for unique monsters
hostile monsters who follow you between levels won't do so if they're fleeing hostile monsters who follow you between levels won't do so if they're fleeing
options for font_size for map, menu, message, status, and text all had the options for font_size for map, menu, message, status, and text all had the
same description of "the size of the map font" in options.c same description of "the size of the map font" in options.c
when dismounting by choice and unimpaired, try not to land in a known trap
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes

View File

@@ -12,7 +12,7 @@ static NEARDATA const char steeds[] = {
S_QUADRUPED, S_UNICORN, S_ANGEL, S_CENTAUR, S_DRAGON, S_JABBERWOCK, '\0' S_QUADRUPED, S_UNICORN, S_ANGEL, S_CENTAUR, S_DRAGON, S_JABBERWOCK, '\0'
}; };
STATIC_DCL boolean FDECL(landing_spot, (coord *, int)); STATIC_DCL boolean FDECL(landing_spot, (coord *, int, int));
/* caller has decided that hero can't reach something while mounted */ /* caller has decided that hero can't reach something while mounted */
void void
@@ -415,29 +415,37 @@ kick_steed()
* Adapted from mail daemon code. * Adapted from mail daemon code.
*/ */
STATIC_OVL boolean STATIC_OVL boolean
landing_spot(spot, forceit) landing_spot(spot, reason, forceit)
coord *spot; /* landing position (we fill it in) */ coord *spot; /* landing position (we fill it in) */
int reason;
int forceit; int forceit;
{ {
int x, y, distance, min_distance = -1; int i = 0, x, y, distance, min_distance = -1;
boolean found = FALSE; boolean found = FALSE;
struct trap *t;
for (x = u.ux-1; x <= u.ux+1; x++) /* avoid known traps (i == 0), but allow them as a backup */
for (y = u.uy-1; y <= u.uy+1; y++) { if (reason != DISMOUNT_BYCHOICE || Stunned || Confusion || Fumbling) i = 1;
if (!isok(x, y) || (x == u.ux && y == u.uy)) continue; for (; !found && i < 2; ++i) {
for (x = u.ux-1; x <= u.ux+1; x++)
for (y = u.uy-1; y <= u.uy+1; y++) {
if (!isok(x, y) || (x == u.ux && y == u.uy)) continue;
if (ACCESSIBLE(levl[x][y].typ) && if (ACCESSIBLE(levl[x][y].typ) &&
!MON_AT(x,y) && !closed_door(x,y)) { !MON_AT(x,y) && !closed_door(x,y)) {
distance = distu(x,y); distance = distu(x,y);
if (min_distance < 0 || distance < min_distance || if (min_distance < 0 || distance < min_distance ||
(distance == min_distance && rn2(2))) { (distance == min_distance && rn2(2))) {
spot->x = x; if (i > 0 || (t = t_at(x, y)) == 0 || !t->tseen) {
spot->y = y; spot->x = x;
min_distance = distance; spot->y = y;
found = TRUE; min_distance = distance;
found = TRUE;
}
}
} }
} }
} }
/* If we didn't find a good spot and forceit is on, try enexto(). */ /* If we didn't find a good spot and forceit is on, try enexto(). */
if (forceit && min_distance < 0 && if (forceit && min_distance < 0 &&
@@ -458,7 +466,7 @@ dismount_steed(reason)
const char *verb = "fall"; const char *verb = "fall";
boolean repair_leg_damage = TRUE; boolean repair_leg_damage = TRUE;
unsigned save_utrap = u.utrap; unsigned save_utrap = u.utrap;
boolean have_spot = landing_spot(&cc,0); boolean have_spot = landing_spot(&cc,reason,0);
mtmp = u.usteed; /* make a copy of steed pointer */ mtmp = u.usteed; /* make a copy of steed pointer */
/* Sanity check */ /* Sanity check */
@@ -472,14 +480,14 @@ dismount_steed(reason)
verb = "are thrown"; verb = "are thrown";
case DISMOUNT_FELL: case DISMOUNT_FELL:
You("%s off of %s!", verb, mon_nam(mtmp)); You("%s off of %s!", verb, mon_nam(mtmp));
if (!have_spot) have_spot = landing_spot(&cc,1); if (!have_spot) have_spot = landing_spot(&cc,reason,1);
losehp(rn1(10,10), "riding accident", KILLED_BY_AN); losehp(rn1(10,10), "riding accident", KILLED_BY_AN);
set_wounded_legs(BOTH_SIDES, (int)HWounded_legs + rn1(5,5)); set_wounded_legs(BOTH_SIDES, (int)HWounded_legs + rn1(5,5));
repair_leg_damage = FALSE; repair_leg_damage = FALSE;
break; break;
case DISMOUNT_POLY: case DISMOUNT_POLY:
You("can no longer ride %s.", mon_nam(u.usteed)); You("can no longer ride %s.", mon_nam(u.usteed));
if (!have_spot) have_spot = landing_spot(&cc,1); if (!have_spot) have_spot = landing_spot(&cc,reason,1);
break; break;
case DISMOUNT_ENGULFED: case DISMOUNT_ENGULFED:
/* caller displays message */ /* caller displays message */