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(const mgen_data &mg,
const coord_def &mg_pos)
{
const int htype = (mons_class_is_zombified(mg.cls) ? mg.base_type
: mg.cls);
dungeon_feature_type grid_wanted =
habitat2grid(mons_habitat_by_type(htype));
if (!in_bounds(mg_pos))
return (false);
// Occupied?
if (mgrd(mg_pos) != NON_MONSTER || mg_pos == you.pos())
return (false);
// Is the monster happy where we want to put it?
if (!grid_compatible(grid_wanted, grd(mg_pos), true))
return (false);
if (mg.behaviour != BEH_FRIENDLY && is_sanctuary(mg_pos.x, mg_pos.y))
return (false);
// Don't generate monsters on top of teleport traps.
// (How did they get there?)
int trap = trap_at_xy(mg_pos.x, mg_pos.y);
if (trap >= 0)
{
if (!_can_place_on_trap(mg.cls, env.trap[trap].type))
return (false);
}
return (true);
}
static bool _valid_monster_location(mgen_data &mg)
{
return _valid_monster_location(mg, mg.pos);
// Don't generate monsters on top of teleport traps.
// (How did they get there?)
int trap = trap_at_xy(mg.pos.x, mg.pos.y);
if (trap >= 0)
{
if (!_can_place_on_trap(mg.cls, env.trap[trap].type))
continue;
}
if (!in_bounds(fpos))
continue;
// Occupied?
if (mgrd(fpos) != NON_MONSTER || fpos == you.pos())
continue;
if (!grid_compatible(grid_wanted, grd(fpos), true))
continue;
if (mg.behaviour != BEH_FRIENDLY && is_sanctuary(fpos.x, fpos.y))
continue;
// Don't generate monsters on top of teleport traps.
// (How do they get there?)
int trap = trap_at_xy(fpos.x, fpos.y);
if (trap >= 0 && !_can_place_on_trap(mg.cls, env.trap[trap].type))
continue;
// Cool.. passes all tests.
break;
if (_valid_monster_location(mg, fpos))
break;