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

Prevent PlaceUniqueMonster() loop from finding random location for quest monsters with a set position #7464

Merged
merged 2 commits into from
Oct 8, 2024

Conversation

kphoenix137
Copy link
Collaborator

@kphoenix137 kphoenix137 commented Oct 8, 2024

Fixes: #7463

PlaceUniqueMonst() is a function that does what the name suggests, with logic as follows:

  1. Find a random valid location to place the unique monster, assigning the chosen valid location to position
  2. If the monster is a quest unique monster, overwrite position with a set location
  3. Complete setting up the unique monster data and place it in the map

While this may not be the fix for the linked issue report, this does change the order of operations, to prevent running the loop to find a spawn location for monsters that already have a predefined location. Since these quest monsters have a very specific location, typically involving set pieces or set levels, their spawning conditions are predetermined to be valid, and we don't need to run the checks like we do with randomly placed unique monsters. As a result, the infinite loop problem will no longer occur with Lazarus and his minion uniques.

An explanation for the infinite loop where every map tile is considered "Solid" and causes spawning condition checks to fail can be found here: #7463 (comment)

The proper solution can be found here: #7465

@kphoenix137 kphoenix137 changed the title Fix PlaceUniqueMonst() Prevent PlaceUniqueMonster() loop from finding valid location for quest monsters Oct 8, 2024
@kphoenix137 kphoenix137 changed the title Prevent PlaceUniqueMonster() loop from finding valid location for quest monsters Prevent PlaceUniqueMonster() loop from finding random location for quest monsters Oct 8, 2024
@kphoenix137 kphoenix137 changed the title Prevent PlaceUniqueMonster() loop from finding random location for quest monsters Prevent PlaceUniqueMonster() loop from finding random location for quest monsters with a set position Oct 8, 2024
if (UberRow == 0 || UberCol == 0) {
UberDiabloMonsterIndex = -1;
return;
}
position = { UberRow - 2, UberCol };
UberDiabloMonsterIndex = static_cast<int>(ActiveMonsterCount);
break;
default:
hasPredefinedPosition = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably just place the fallback here instead of using a bool

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also moving the position logic to it's own sub method will allow you to simplify things even more.

@AJenbo AJenbo merged commit 06528a5 into diasurgical:master Oct 8, 2024
23 checks passed
@StephenCWills StephenCWills added this to the 1.5.4 milestone Oct 19, 2024
@StephenCWills StephenCWills modified the milestones: 1.5.4, 1.6.0 Oct 19, 2024
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

Successfully merging this pull request may close these issues.

[Issue Report]: Game loads endlessly
3 participants