示例#1
0
bool Entity::can_see(Map* map, int x, int y, int z)
{
  if (z == 999) { // z defaults to 999
    z = posz;
  }
  if (!map || !has_sense(SENSE_SIGHT)) {
    return false;
  }
  return map->senses(posx, posy, posz, x, y, z, SENSE_SIGHT);
}
示例#2
0
void Monster::make_plans()
{
  Player *player = GAME.player;
  Map *map = GAME.map;
// TODO: Support different senses
// TODO: Support non-aggressive monsters
  bool senses_player = false;
  if (has_sense(SENSE_SIGHT) && can_sense(map, player->posx, player->posy)) {
    senses_player = true;
  }
  if (senses_player) {
    target = player;
    wander_target = Point(player->posx, player->posy);
// TODO: Don't hard-code wander_duration.  Make it a Monster_type stat?
    wander_duration = 15;
  } else {
    target = NULL;
  }
}