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

Anyway to predict if a room can be successfully placed/ know if it is actually placed when Choose Next Room? #29

Open
EiZi233 opened this issue May 4, 2023 · 3 comments
Labels
question This is not an issue, just a question about the plugin

Comments

@EiZi233
Copy link

EiZi233 commented May 4, 2023

No description provided.

@EiZi233 EiZi233 changed the title Anyway to detect if a room is sucessfully Anyway to predict if a room can be successfully placed/ know if it is actually placed when Generate Next Room? May 4, 2023
@EiZi233 EiZi233 changed the title Anyway to predict if a room can be successfully placed/ know if it is actually placed when Generate Next Room? Anyway to predict if a room can be successfully placed/ know if it is actually placed when Choose Next Room? May 4, 2023
@EiZi233
Copy link
Author

EiZi233 commented May 4, 2023

Greeting! I am using this amazing plugin and trying to write a cool logic for spawning the room. I am wondering when I choose a room in the Choose Next Room function, are the room guaranteed to be placed? What will happen if, like the room is too big and cannot be placed?

Let's say in the example in the plugin description, I want to spawn a secret room once and only once in my dungeon, what is going on in the plugin if that secret room did not successfully spawned? In that case there will be no secret room at all or the generate is aborted?

@EiZi233
Copy link
Author

EiZi233 commented May 4, 2023

And well some times the generator only spawn a single start room and no other rooms at all. Could this be caused by a similar issue?

Thanks!

@BenPyton
Copy link
Owner

BenPyton commented May 4, 2023

Hi @EiZi233

when I choose a room in the Choose Next Room function, are the room guaranteed to be placed? What will happen if, like the room is too big and cannot be placed?

No, the room you return in the ChooseNextRoomData function is not guaranteed to spawn.
If the room cannot be placed (overlapping other rooms) the function is re-called so you can try another room.
After 10 times of retry, no room will be placed and the generator will continue with another door.

what is going on in the plugin if that secret room did not successfully spawned? In that case there will be no secret room at all or the generate is aborted?

When the dungeon generator has finished to generate (either by door exhaustion or by ContinueToAddRoom returning false) the function IsValidDungeon will be called.
In that function you should check if you have one and only one secret room in the generated dungeon.
If you return false because of any of your not met requirements, the dungeon generator will clear the generated dungeon and will try to generate one.
If after 500 retries the IsValidDungeon returns always false, then the dungeon abandons the generation and returns what he currently has.

You can see the flowchart in the wiki to visualize the path taken by the dungeon generator.

So you should keep in mind that randomizing the room choice is very important. If you only have one room data of your secret room, then you should not have the same code path to return the secret room each time the ChooseNextRoomData is called. You have to randomize a little so you could return another random room instead, in case the secret room can't be spawned.

some times the generator only spawn a single start room and no other rooms at all. Could this be caused by a similar issue?

I don't know what your code is, but you are right, it could be caused by:

  • ContinueToAddRoom returning false just after the first room,
  • ChooseNextRoomData exhausting all its retries for the room to choose just after the first room,
  • IsValidDungeon always returning false and so exhausting all the retries.

Make sure your rooms have enough door. A room with only one room will stop naturally the generation for this dungeon "branch", since the only door will be used to connect to previous room.

I think I will add some warning or error messages for those cases.

Hope I answered your questions.

Bests.

@BenPyton BenPyton added the question This is not an issue, just a question about the plugin label May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is not an issue, just a question about the plugin
Projects
None yet
Development

No branches or pull requests

2 participants