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

cave_map_generator.lua: limit find_path dimensions to inner board. #5407

Closed
wants to merge 1 commit into from

Conversation

virtualghetto
Copy link

find_path last 2 arguments are the dimensions of the map.
If you create 2 chambers and a passage at the bottom edge of the map, the generated path will be impassable because it goes into the border.
This PR makes find_path consider the inner board only for its path calculation.

@github-actions github-actions bot added the Lua API Issues with the Lua engine and API. label Jan 2, 2021
@CelticMinstrel CelticMinstrel self-assigned this Feb 12, 2021
CelticMinstrel added a commit that referenced this pull request Feb 15, 2021
@CelticMinstrel
Copy link
Member

I think the above linked commit should fix this in a cleaner way. Your patch just creates the question of "why -2?" which is confusing.

@virtualghetto
Copy link
Author

I think the above linked commit should fix this in a cleaner way. Your patch just creates the question of "why -2?" which is confusing.

Because -1 didn't work either for my patch :)

I just tested your patch and it suffers the same problem.
adding the following to it will fix it without having to mess with the last two parameters of find_path.
or x == params.map_width -1 or y == params.map_height -1

Remember, when a cave map dimensions are given as 20,20,
19,19 would then be the impassable bottom right border corner
and 18,18 is the passable the inner right bottom corner.

@CelticMinstrel
Copy link
Member

Yeah, that makes sense. Pretty sure 0 is correct for the left and top border though?

@virtualghetto
Copy link
Author

Yes. 0,0 is the top left impassable border corner and 1,1 is the passable inner corner.

This is the map that I tested it on.
It creates four keeps at each corner and it connects each other with a passage along the map edge.

    map_generation=lua
    [generator]
        id="cavegen"
        config_name="Lua Cave Generator"
        create_map = << return wesnoth.require("cave_map_generator").generate_map(...) >>

        village_density=0

        terrain_wall = "Xu"
        terrain_clear = "Uu"
        terrain_keep = "Kud"
        terrain_castle = "Cud"
        terrain_village = "Uu^Vud"

        # Bottom right inside corner is 18,18
        map_width=20
        map_height=20
        [chamber]
            id=mini_01
            x=18
            y=18
            size=1
            [item_location]
                id = 1
                place_castle = yes
            [/item_location]
        [/chamber]
        [chamber]
            id=mini_02
            x=1
            y=18
            size=1
            [item_location]
                id = 2
                place_castle = yes
            [/item_location]
            [passage]
                destination=mini_01
            [/passage]
        [/chamber]
        [chamber]
            id=mini_03
            x=1
            y=1
            size=1
            [item_location]
                id = 3
                place_castle = yes
            [/item_location]
            [passage]
                destination=mini_02
            [/passage]
        [/chamber]
        [chamber]
            id=mini_04
            x=18
            y=1
            size=1
            [item_location]
                id = 4
                place_castle = yes
            [/item_location]
            [passage]
                destination=mini_03
            [/passage]
            [passage]
                destination=mini_01
            [/passage]
        [/chamber]
    [/generator]

@virtualghetto virtualghetto deleted the path_dimensions branch February 18, 2021 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lua API Issues with the Lua engine and API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants