Skip to content

Commit

Permalink
fix: mapgen: removing enemies near stairs
Browse files Browse the repository at this point in the history
  • Loading branch information
kiedtl committed Oct 27, 2023
1 parent 6b195ea commit 2572e27
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/mapgen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3002,12 +3002,24 @@ pub fn removeEnemiesNearEntry(level: usize) void {
);
defer dijk.deinit();
while (dijk.next()) |child| {
if (state.dungeon.at(child).mob) |mob|
if (mob.isHostileTo(state.player) and
fov.quickLOSCheck(down_staircase, child, types.Dungeon.tileOpacity))
{
if (state.dungeon.at(child).mob) |mob| {
if (!mob.isHostileTo(state.player))
continue;

const can_be_seen = for (&DIRECTIONS) |d| {
if (child.move(d, state.mapgeometry)) |neighbor| {
if (fov.quickLOSCheck(
down_staircase,
neighbor,
types.Dungeon.tileOpacity,
))
break true;
}
} else false;
if (child.distance(down_staircase) <= 3 or can_be_seen) {
mob.deinitNoCorpse();
};
}
}
}
}

Expand Down

0 comments on commit 2572e27

Please sign in to comment.