From: nethack.rankin Date: Sat, 16 Mar 2013 01:44:28 +0000 (+0000) Subject: poly'd hero hiding feedback X-Git-Tag: MOVE2GIT~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fec898110251265194ad10dd7aef1814b161ef2f;p=nethack poly'd hero hiding feedback When hiding as a monster, say so during the #monster command and also list being hidden in the status section of enlightenment/^X. Also, prevent hiding on the floor or ceiling on the planes of air and water. (Didn't apply to monsters, who only hide on ROOM spots.) Half the change to dohide() is just revised indentation. --- diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 44a8e7e3a..118ba60c8 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -780,6 +780,7 @@ for poly'd hero hiding on ceiling, attack by sea monsters won't move them into hero's position unless it is over water or they're already on land for poly'd hero hiding on ceiling, attack by long worm might fill hero's destination with worm's tail, so double check and maybe choose again +poly'd hero can't hide on floor or ceiling when on Planes of Air or Water when shop prices are adjusted, handle roundoff (integer truncation) better for hero poly'd into a monster form that lacks a weapon attack but has a claw attack, use wielded weapon even when claw attack isn't the very first diff --git a/include/extern.h b/include/extern.h index 71c7a54b7..2dd1e3e31 100644 --- a/include/extern.h +++ b/include/extern.h @@ -197,6 +197,7 @@ E int NDECL(doextlist); E int NDECL(extcmd_via_menu); E int NDECL(enter_explore_mode); E void FDECL(enlightenment, (int,int)); +E void FDECL(youhiding, (BOOLEAN_P,int)); E void FDECL(show_conduct, (int)); E int FDECL(xytod, (SCHAR_P,SCHAR_P)); E void FDECL(dtoxy, (coord *,int)); diff --git a/src/cmd.c b/src/cmd.c index 510315449..064d85a88 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1582,6 +1582,9 @@ int final; surface(u.ux, u.uy)); /* catchall; shouldn't happen */ you_are(buf, from_what(WWALKING)); } + if (Upolyd && (u.uundetected || youmonst.m_ap_type != M_AP_NOTHING)) + youhiding(TRUE, final); + /* internal troubles, mostly in the order that prayer ranks them */ if (Stoned) you_are("turning to stone", ""); if (Slimed) you_are("turning into slime", ""); @@ -1609,6 +1612,7 @@ int final; if (Hallucination) you_are("hallucinating", ""); if (Blind) you_are("blind", from_what(BLINDED)); if (Deaf) you_are("deaf", from_what(DEAF)); + /* external troubles, more or less */ if (Punished) { if (uball) { @@ -2222,6 +2226,65 @@ doattributes(VOID_ARGS) return 0; } +void +youhiding(via_enlghtmt, msgflag) +boolean via_enlghtmt; /* englightment line vs topl message */ +int msgflag; /* for variant message phrasing */ +{ + char *bp, buf[BUFSZ]; + + Strcpy(buf, "hiding"); + if (youmonst.m_ap_type != M_AP_NOTHING) { + /* mimic; hero is only able to mimic a strange object or gold + or hallucinatory alternative to gold, so we skip the details + for the hypothetical furniture and monster cases */ + bp = eos(strcpy(buf, "mimicking")); + if (youmonst.m_ap_type == M_AP_OBJECT) { + Sprintf(bp, " %s", an(simple_typename(youmonst.mappearance))); + } else if (youmonst.m_ap_type == M_AP_FURNITURE) { + Strcpy(bp, " something"); + } else if (youmonst.m_ap_type == M_AP_MONSTER) { + Strcpy(bp, " someone"); + } else { + ; /* something unexpected; leave 'buf' as-is */ + } + } else if (u.uundetected) { + bp = eos(buf); /* points past "hiding" */ + if (youmonst.data->mlet == S_EEL) { + if (is_pool(u.ux, u.uy)) + Sprintf(bp, " in the %s", waterbody_name(u.ux, u.uy)); + } else if (hides_under(youmonst.data)) { + struct obj *o = level.objects[u.ux][u.uy]; + + if (o) + Sprintf(bp, " underneath %s", ansimpleoname(o)); + } else if (is_clinger(youmonst.data) || Flying) { + /* Flying: 'lurker above' hides on ceiling but doesn't cling */ + Sprintf(bp, " on the %s", ceiling(u.ux, u.uy)); + } else { + /* on floor; is_hider() but otherwise not special: 'trapper' */ + if (u.utrap && u.utraptype == TT_PIT) { + struct trap *t = t_at(u.ux, u.uy); + + Sprintf(bp, " in a %spit", + (t && t->ttyp == SPIKED_PIT) ? "spiked " : ""); + } else + Sprintf(bp, " on the %s", surface(u.ux, u.uy)); + } + } else { + ; /* shouldn't happen; will result in generic "you are hiding" */ + } + + if (via_enlghtmt) { + int final = msgflag; /* 'final' is used by you_are() macro */ + + you_are(buf, ""); + } else { + /* for dohide(), when player uses '#monster' command */ + You("are %s %s.", msgflag ? "already" : "now", buf); + } +} + /* KMH, #conduct * (shares enlightenment's tense handling) */ diff --git a/src/polyself.c b/src/polyself.c index f40726696..7bafe84dd 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -1322,38 +1322,69 @@ dogaze() int dohide() { - boolean ismimic = youmonst.data->mlet == S_MIMIC; - - if (u.ustuck || - (u.utrap && - /* floor hiders (trapper) can hide while stuck in pits, - ceiling hiders can't (after using '>' to get there) */ - (u.utraptype != TT_PIT || is_clinger(youmonst.data)))) { - You_cant("hide while you're %s.", - !u.ustuck ? "trapped" : - !sticks(youmonst.data) ? "being held" : - humanoid(u.ustuck->data) ? "holding someone" : - "holding that creature"); - if (u.uundetected || - (ismimic && youmonst.m_ap_type != M_AP_NOTHING)) { - u.uundetected = 0; - youmonst.m_ap_type = M_AP_NOTHING; - newsym(u.ux, u.uy); - } - return 0; + boolean ismimic = youmonst.data->mlet == S_MIMIC, + on_ceiling = is_clinger(youmonst.data) || Flying; + + /* can't hide while being held (or holding) or while trapped + (except for floor hiders [trapper or mimic] in pits) */ + if (u.ustuck || (u.utrap && (u.utraptype != TT_PIT || on_ceiling))) { + You_cant("hide while you're %s.", + !u.ustuck ? "trapped" : + !sticks(youmonst.data) ? "being held" : + humanoid(u.ustuck->data) ? "holding someone" : + "holding that creature"); + if (u.uundetected || + (ismimic && youmonst.m_ap_type != M_AP_NOTHING)) { + u.uundetected = 0; + youmonst.m_ap_type = M_AP_NOTHING; + newsym(u.ux, u.uy); + } + return 0; + } + /* note: the eel and hides_under cases are hypothetical; + such critters aren't offered the option of hiding via #monster */ + if (youmonst.data->mlet == S_EEL && !is_pool(u.ux, u.uy)) { + if (IS_FOUNTAIN(levl[u.ux][u.uy].typ)) + The("fountain is not deep enough to hide in."); + else + There("is no water to hide in here."); + u.uundetected = 0; + return 0; + } + if (hides_under(youmonst.data) && !level.objects[u.ux][u.uy]) { + There("is nothing to hide under here."); + u.uundetected = 0; + return 0; + } + /* Planes of Air and Water */ + if (on_ceiling && !has_ceiling(&u.uz)) { + There("is nowhere to hide above you."); + u.uundetected = 0; + return 0; } + if ((is_hider(youmonst.data) && !Flying) && /* floor hider */ + (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz))) { + There("is nowhere to hide beneath you."); + u.uundetected = 0; + return 0; + } + /* TODO? inhibit floor hiding at furniture locations, or + else make youhiding() give smarter messages at such spots */ + if (u.uundetected || (ismimic && youmonst.m_ap_type != M_AP_NOTHING)) { - You("are already hiding."); - return(0); + youhiding(FALSE, 1); /* "you are already hiding" */ + return 0; } + if (ismimic) { - /* should bring up a dialog "what would you like to imitate?" */ - youmonst.m_ap_type = M_AP_OBJECT; - youmonst.mappearance = STRANGE_OBJECT; + /* should bring up a dialog "what would you like to imitate?" */ + youmonst.m_ap_type = M_AP_OBJECT; + youmonst.mappearance = STRANGE_OBJECT; } else - u.uundetected = 1; - newsym(u.ux,u.uy); - return(1); + u.uundetected = 1; + newsym(u.ux, u.uy); + youhiding(FALSE, 0); /* "you are now hiding" */ + return 1; } int