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
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));
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", "");
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) {
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)
*/
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