/* * relocate: * Make the monster's new location be the specified one, updating * all the relevant state. */ void relocate(THING *th, const coord *new_loc) { struct room *oroom; if (!ce(*new_loc, th->t_pos)) { mvaddch2(th->t_pos.y, th->t_pos.x, th->t_oldch); th->t_room = roomin(new_loc); set_oldch(th, new_loc); oroom = th->t_room; moat(th->t_pos.y, th->t_pos.x) = NULL; if (oroom != th->t_room) th->t_dest = find_dest(th); th->t_pos = *new_loc; moat(new_loc->y, new_loc->x) = th; } move(new_loc->y, new_loc->x); if (see_monst(th)) addch2(th->t_disguise); else if (on(player, SEEMONST)) { standout(); addch2(th->t_type); standend2(); } }
/* * seen_stairs: * Return TRUE if the player has seen the stairs */ bool seen_stairs() { THING *tp; move(stairs.y, stairs.x); if (inch() == STAIRS) /* it's on the map */ return TRUE; if (ce(hero, stairs)) /* It's under him */ return TRUE; /* * if a monster is on the stairs, this gets hairy */ if ((tp = moat(stairs.y, stairs.x)) != NULL) { if (see_monst(tp) && on(*tp, ISRUN)) /* if it's visible and awake */ return TRUE; /* it must have moved there */ if (on(player, SEEMONST) /* if she can detect monster */ && tp->t_oldch == STAIRS) /* and there once were stairs */ return TRUE; /* it must have moved there */ } return FALSE; }
void invis_on() { THING *mp; player.t_flags |= CANSEE; for (mp = mlist; mp != NULL; mp = next(mp)) if (on(*mp, ISINVIS) && see_monst(mp) && !on(player, ISHALU)) mvaddch(mp->t_pos.y, mp->t_pos.x, mp->t_disguise); }
/* * unsee: * Turn off the ability to see invisible */ unsee() { register THING *th; for (th = mlist; th != NULL; th = next(th)) if (on(*th, ISINVIS) && see_monst(th)) { move(th->t_pos.y, th->t_pos.x); addrawch(th->t_oldch); } player.t_flags &= ~CANSEE; }
/* * invis_on: * Turn on the ability to see invisible */ invis_on() { register THING *th; player.t_flags |= CANSEE; for (th = mlist; th != NULL; th = next(th)) if (on(*th, ISINVIS) && see_monst(th)) { move(th->t_pos.y, th->t_pos.x); addch(th->t_disguise); } }
/* * visuals: * change the characters for the player */ visuals() { register THING *tp; register bool seemonst; if (!after) return; /* * change the things */ for (tp = lvl_obj; tp != NULL; tp = next(tp)) if (cansee(tp->o_pos.y, tp->o_pos.x)) { PC_GFX_PASSGE_COLOR(tp->o_pos.y, tp->o_pos.x, 0, 0x70); mvaddrawch(tp->o_pos.y, tp->o_pos.x, rnd_thing()); PC_GFX_NOCOLOR(0x70); } /* * change the stairs */ if (!seenstairs && cansee(stairs.y, stairs.x)) { PC_GFX_PASSGE_COLOR(stairs.y, stairs.x, 0, 0x70); mvaddrawch(stairs.y, stairs.x, rnd_thing()); PC_GFX_NOCOLOR(0x70); } /* * change the monsters */ seemonst = on(player, SEEMONST); for (tp = mlist; tp != NULL; tp = next(tp)) if (see_monst(tp)){ PC_GFX_PASSGE_COLOR(tp->t_pos.y, tp->t_pos.x, 0, 0x70); if (tp->t_type == 'M' && tp->t_disguise != 'M') mvaddrawch(tp->t_pos.y, tp->t_pos.x, rnd_thing()); else mvaddrawch(tp->t_pos.y, tp->t_pos.x, rnd(26) + 'A'); PC_GFX_NOCOLOR(0x70); } else if (seemonst) { standout(); mvaddrawch(tp->t_pos.y, tp->t_pos.x, rnd(26) + 'A'); standend(); } }
/* * turn_see: * Put on or off seeing monsters on this level */ bool turn_see(bool turn_off) { THING *mp; bool can_see, add_new; add_new = FALSE; for (mp = mlist; mp != NULL; mp = next(mp)) { move(mp->t_pos.y, mp->t_pos.x); can_see = see_monst(mp); if (turn_off) { if (!can_see) addch(mp->t_oldch); } else { if (!can_see) standout(); if (!on(player, ISHALU)) addch(mp->t_type); else addch(rnd(26) + 'A'); if (!can_see) { standend(); add_new++; } } } if (turn_off) player.t_flags &= ~SEEMONST; else player.t_flags |= SEEMONST; return add_new; }
/* * find_dest: * find the proper destination for the monster */ const coord * find_dest(const THING *tp) { THING *obj; int prob; if ((prob = monsters[tp->t_type - 'A'].m_carry) <= 0 || tp->t_room == proom || see_monst(tp)) return &hero; for (obj = lvl_obj; obj != NULL; obj = next(obj)) { if (obj->o_type == SCROLL && obj->o_which == S_SCARE) continue; if (roomin(&obj->o_pos) == tp->t_room && rnd(100) < prob) { for (tp = mlist; tp != NULL; tp = next(tp)) if (tp->t_dest == &obj->o_pos) break; if (tp == NULL) return &obj->o_pos; } } return &hero; }