Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter-26 BSP Interiors: Entities spawning in walls #202

Open
DireTabacchi opened this issue Jan 16, 2023 · 1 comment
Open

Chapter-26 BSP Interiors: Entities spawning in walls #202

DireTabacchi opened this issue Jan 16, 2023 · 1 comment

Comments

@DireTabacchi
Copy link

I was testing what I had of the BSP Interiors chapter (up to right before resetting the build_random_map function to build a random map with all three builders), and I found several entities (items and foes) sometimes spawning in the walls. I double checked my potential errors with a recent clone of the repo and compiling the code for this chapter, I found that the same thing was happening: items and foes in walls.

After some investigation, I believe it may be something about the southern and eastern walls of each new room not being calculated correctly and the spawner thinking that they are valid places to place entities, as it seems that the walls they are spawning in are the southern and eastern ones of the rooms they are supposed to spawn in.

These items are unobtainable as the tiles with walls are still counted as walls and not traverse-able. However foes that spawn in walls are still able to move out of walls if their pathing takes them to a tile that is a traverse-able tile.

Here is an example of what I find, with the cloned-repo code.
image

Another example:
image

@Didgety
Copy link

Didgety commented Nov 24, 2023

I need to verify this doesn't cause bugs with any other maps before creating a PR, but in spawner.rs:

Changing:

pub fn spawn_room(ecs: &mut World, room : &Rect, map_depth : i32) {
    // ...
    while !added && tries < 20 {
        let x = (room.x1 + rng.roll_dice(1, i32::abs(room.x2 - room.x1))) as usize;
        let y = (room.y1 + rng.roll_dice(1, i32::abs(room.y2 - room.y1))) as usize;
    // ...
    }
}

To:

pub fn spawn_room(ecs: &mut World, room : &Rect, map_depth : i32) {
    // ...
    while !added && tries < 20 {
        let x = (room.x1 + rng.roll_dice(1, i32::abs(room.x2 - room.x1)) - 1) as usize;
        let y = (room.y1 + rng.roll_dice(1, i32::abs(room.y2 - room.y1)) - 1) as usize;
    // ...
    }
}

Fixes the issue, but causes an off-by-one in the west and north directions on the maps from preceding chapters. I haven't figured out the root cause of why this specific map type has the wrong coordinates for items. However, it's addressed in the next chapter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants