engine/maps/source/MapUtils.cpp
// Check to see if there is a hostile creature adjacent to the creature represented by
// the given creature ID.
Check to see if there is a hostile creature adjacent to the creature represented by
the given creature ID.
Check to see if there is a hostile creature adjacent to the creature represented by the given creature ID .
bool MapUtils::adjacent_hostile_creature_exists(const string& creature_id, MapPtr map)
{
  if (map)
  {
    Coordinate creature_location = map->get_location(creature_id);
    vector<Coordinate> adjacent_coords = CoordUtils::get_adjacent_map_coordinates(map->size(), creature_location.first, creature_location.second);
    for (const Coordinate& c : adjacent_coords)
    {
      TilePtr tile = map->at(c);
      if (tile)
      {
        CreaturePtr creature = tile->get_creature();
        if (creature)
        {
          if (creature->hostile_to(creature_id))
          {
            return true;
          }
        }
      }
    }
  }
  return false;
}
bool MapUtils :: adjacent_hostile_creature_exists ( const string & creature_id , MapPtr map ) { if ( map ) { Coordinate creature_location = map -> get_location ( creature_id ) ; vector < Coordinate > adjacent_coords = CoordUtils :: get_adjacent_map_coordinates ( map -> size ( ) , creature_location . first , creature_location . second ) ; for ( const Coordinate & c : adjacent_coords ) { TilePtr tile = map -> at ( c ) ; if ( tile ) { CreaturePtr creature = tile -> get_creature ( ) ; if ( creature ) { if ( creature -> hostile_to ( creature_id ) ) { return true ; } } } } } return false ; }
Check to see if there is a hostile creature adjacent to the creature represented by
the given creature ID.
Check to see if there is a hostile creature adjacent to the creature represented by the given creature ID .
// Is the creature on this tile hostile to the ID passed in?