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

Monsters should not spawn on unwalkable tiles #8300

Closed
Playtester opened this issue May 3, 2024 · 3 comments · Fixed by #8324
Closed

Monsters should not spawn on unwalkable tiles #8300

Playtester opened this issue May 3, 2024 · 3 comments · Fixed by #8324
Assignees
Labels
component:core A fault that lies within the main framework of rAthena mode:prerenewal A fault that exists within the pre-renewal mode status:confirmed Issue that has been validated by a developer to affect rAthena type:bug Issue that is a bug within rAthena

Comments

@Playtester
Copy link
Member

rAthena Hash

30928a0

Client Date

2021-11-03

Server Mode

Pre-Renewal

Result

Monsters spawn on unwalkable tiles, for example the Hydras in iz_dun03.

Relevant Log Output

No response

Expected Result

Monsters never spawn on walkable tiles, if no walkable tile could be found after a while (I assume it does a number of attempts), the monster is just spawned on a random location on the map instead.

For example there are ~30 hydras that spawn randomly on iz_dun03 instead of just 10.

How to Reproduce

Check spawns in iz_dun03.

Official Information

If you check iz_dun03, you will see that those fixed position Hydras that rAthena has are not there on any official server.

Modifications that may affect results

No response

@Playtester Playtester added status:confirmed Issue that has been validated by a developer to affect rAthena component:core A fault that lies within the main framework of rAthena mode:prerenewal A fault that exists within the pre-renewal mode type:bug Issue that is a bug within rAthena labels May 3, 2024
@Playtester
Copy link
Member Author

Playtester commented May 4, 2024

This is how it works on official servers:

  • The spawn area is divided into 4 quadrants (-x,-y), (x,-y), (-x,y) and (x,y), 4 lines (-x,0), (x,0), (0,-y) and (0, y) and 1 dot (exact tile)
  • Starting with a random quadrant, a random tile is picked
  • A picked tile is valid if it's not a wall and it's not within 4 (north, east) or 5 cells (south, west) from the edge of the map
  • Once a valid tile was found this tile is used and the search is done
  • If no valid tile was found, it continues to search in: (Line)->(Square)->(Line)->(Dot)->(Line)->(Square)->(Line)->(Square)
  • If there are no valid tiles, it will search 50 times map-wide for a valid cell, ignoring 15 cells from the edge of the map (the same code is used for teleporation except warp portals are invalid cells for teleportation)

@Playtester Playtester self-assigned this May 11, 2024
Playtester added a commit that referenced this issue May 11, 2024
- When searching for a map-wide free cell, the tiles 15 cells from the edge are no longer considered
  * Added a configuration to change the edge size to any value between 4 and 40
- When searching for a free cell, the tiles 4-5 cells from the edge are now considered invalid and trigger a retry
- Searching for a free cell now defaults to 50 tries, but if the "no spawn on player" option is active, those failed attempts are not counted towards the limit anymore
- When a monster spawns in a defined area there will now be 9 attempts to spawn it on a valid cell within the area; if all 9 attempts fail, there will now be 50 tries to spawn it map-wide before it gives up
- When a monster has fixed spawn coordinates, but those coordinates are a wall, it will now spawn in a random location map-wide instead
- Fixes #8300
@Playtester
Copy link
Member Author

Playtester commented May 12, 2024

Further tests on spawns area:

  • Both (0,0) and (1,1) result in a single fixed spawn cell, there's no 3x3 area variance on (1,1)
  • (2,2) on the other hand spawns in a 5x5 region, but the center 3x3 area has a much higher chance to be picked
  • (3,3) results in a 9x9 region already
  • (2,1) results in a 5x1 region
  • (5,5) results in a 17x17 region

Conclusion: The area for finding a spawn cell is one radius lower than we expected (1->1x1, 2->3x3, 3->5x5), but the "find spawn cell" code is actually called twice, which doubles the potential area but results in a much higher chance for center cells to be picked (1x1 stays 1x1, 3x3 becomes 5x5 with 3x3 focus, 5x5 becomes 9x9 with 5x5 focus).

@Playtester
Copy link
Member Author

Playtester commented May 19, 2024

From further testing we found out that first randomization of the area already happens at server start.

So for example on (3,3), at server start, each monster's center cell will be placed in a 5x5 area around the spawn center. And then each time the monster spawn, it will then be placed in a 5x5 around its own center cell. That's why the total possible area is 9x9, but until the next server restart, the same monster will still always respawn in a 5x5 area.

The center cell can even be outside of the map.

Playtester added a commit that referenced this issue May 19, 2024
- When searching for a map-wide free cell, the tiles 15 cells from the edge are no longer considered
  * Added a configuration to change the edge size to any value between 1 and 40
- When searching for a free cell, the tiles 4-5 cells from the edge are now considered invalid and trigger a retry
  * If you make the edge size smaller than this, it will use edge size instead
- Searching for a free cell now defaults to 50 tries, but if the "no spawn on player" option is active, those failed attempts are not counted towards the limit anymore
- When a monster spawns in a defined area there will now be 8 attempts to spawn it on a valid cell within the area and then one attempt on the center cell; if all 9 attempts fail, there will now be 50 tries to spawn it map-wide before it gives up
- When a monster has fixed spawn coordinates, but those coordinates are a wall, it will now spawn in a random location map-wide instead
  * This also applies to icewall blocking the cell unless the boss_monster command was used
- Each monster in an area spawn will now receive its own spawn center within the spawn area on server start
  * This results in the spawn area being larger but having a bias towards the center
  * Added a configuration to disable this behavior
- Fixed slave monsters always being active and constantly calling the "search freecell" function even though neither them nor their master have been spotted yet
- Fixed map server crash when setting no_spawn_on_player to 100 (follow-up to 33b2b02)
- Updated prontera field spawns to official episode 18+
- Updated all champion mob respawn times to 3 minutes and sorted them by map name
- Fixes #8300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:core A fault that lies within the main framework of rAthena mode:prerenewal A fault that exists within the pre-renewal mode status:confirmed Issue that has been validated by a developer to affect rAthena type:bug Issue that is a bug within rAthena
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant