From e8624a3285ffb6e4a44634a0d9451d8f585d3f1d Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 21 Feb 2008 05:52:08 +0000 Subject: [PATCH] eel hiding behavior (trunk only) From a bug report: an exposed eel in an isolated pool--swamp rooms sometimes produce those--would never re-hide no matter how long you left its vicinity. Re-hiding is part of post-move handling and an eel with no adjacent water to move into would never reach that bit of code since it didn't move anywhere. The code used to re-hide monsters when you return to a previous level was ignoring eels altogether. Give unhidden eels a chance to hide earlier during monster movement and also when the hero returns to their level. Also a really minor bit to slow down hit point loss of eels out of water. I don't think anybody reverse genocides krakens to get experience any more since they don't provide a big bonus when they're out of water, so this change won't have much of an affect. --- doc/fixes35.0 | 1 + src/mon.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index f80ad40a1..9d832ea3f 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -281,6 +281,7 @@ changing alignment type resets alignment record to 0 (nomimally aligned) while polymorphed, suppress attribute gain/lose earned by pre-poly exercise wizard mode #monpolycontrol prompting asked about "it" when monster was unseen reprompt if player fails to make a menu choice during inventory identification +seen eels who were stuck in isolated pools would never re-hide Platform- and/or Interface-Specific Fixes diff --git a/src/mon.c b/src/mon.c index f7bd465f9..e89447d0a 100644 --- a/src/mon.c +++ b/src/mon.c @@ -423,7 +423,8 @@ register struct monst *mtmp; } else { /* but eels have a difficult time outside */ if (mtmp->data->mlet == S_EEL && !Is_waterlevel(&u.uz)) { - if(mtmp->mhp > 1) mtmp->mhp--; + /* as mhp gets lower, the rate of further loss slows down */ + if (mtmp->mhp > 1 && rn2(mtmp->mhp) > rn2(8)) mtmp->mhp--; monflee(mtmp, 2, FALSE, FALSE); } } @@ -554,6 +555,13 @@ movemon() mtmp->m_ap_type == M_AP_OBJECT) continue; if(mtmp->mundetected) continue; + } else if (mtmp->data->mlet == S_EEL && !mtmp->mundetected && + (mtmp->mflee || distu(mtmp->mx, mtmp->my) > 2) && + !canseemon(mtmp) && !rn2(4)) { + /* some eels end up stuck in isolated pools, where they + can't--or at least won't--move, so they never reach + their post-move chance to re-hide */ + if (hideunder(mtmp)) continue; } /* continue if the monster died fighting */ @@ -2438,7 +2446,9 @@ void hide_monst(mon) struct monst *mon; { - if ((is_hider(mon->data) || hides_under(mon->data)) && + boolean hider_under = hides_under(mon->data) || mon->data->mlet == S_EEL; + + if ((is_hider(mon->data) || hider_under) && !(mon->mundetected || mon->m_ap_type)) { xchar x = mon->mx, y = mon->my; char save_viz = viz_array[y][x]; @@ -2448,7 +2458,7 @@ struct monst *mon; if (is_hider(mon->data)) (void)restrap(mon); /* try again if mimic missed its 1/3 chance to hide */ if (mon->data->mlet == S_MIMIC && !mon->m_ap_type) (void)restrap(mon); - if (hides_under(mon->data)) (void)hideunder(mon); + if (hider_under) (void)hideunder(mon); viz_array[y][x] = save_viz; } }