Difference between revisions of "Cave spawning"
Jump to navigation
Jump to search
(Created page with "This page explains the game's process behind spawning enemies in a cave. This is obtained through observation, and is subject to have some parts incorrect. {{note|Until furth...") |
(Corrections.) |
||
Line 14: | Line 14: | ||
## For each <code>TekiInfo</code> entry in the sublevel's configuration... | ## For each <code>TekiInfo</code> entry in the sublevel's configuration... | ||
### Grab its random distribution weight and add it to a list. | ### Grab its random distribution weight and add it to a list. | ||
− | ## Randomly decide what enemy to spawn next, using the weighted list built in the last step. | + | ## While the number of enemies hasn't reached <code>{f002}</code>... |
− | ## Store the enemy's type. | + | ### Randomly decide what enemy to spawn next, using the weighted list built in the last step. |
− | ## Store the spawn coordinate type. | + | ### Store the enemy's type. |
− | ## Do the [[#Spawn algorithm|spawn algorithm]] with this enemy type, amount of 1, and spawn coordinate type. | + | ### Store the spawn coordinate type. |
+ | ### Do the [[#Spawn algorithm|spawn algorithm]] with this enemy type, amount of 1, and spawn coordinate type. | ||
===Spawn algorithm=== | ===Spawn algorithm=== | ||
− | # | + | # While the intended amount of enemies hasn't been spawned yet... |
− | + | ## If all of the possible spawn positions have been used up, finish the whole enemy spawn process. | |
− | + | ## Pick a random spawn coordinate (every unit in the cave has [[Cave unit definition file#layout.txt|a set of spawn coordinates]]). | |
− | ### If this coordinate is out of bounds, skip it. | + | ## If this coordinate is out of bounds, skip it. |
− | + | ## If this coordinate has already been used, skip it. | |
− | + | ## Decide how many enemies to spawn here, picking randomly between the spawn coordinate's amount limits. | |
− | + | ## For each one in that amount... | |
− | + | ### If the number of enemies spawned here surpasses the intended amount, leave this algorithm. | |
− | + | ### Spawn that enemy in these coordinates (with slight variation). | |
− | + | ## Mark this spawn coordinate as used. | |
− | |||
[[Category:Pikmin 2]] | [[Category:Pikmin 2]] | ||
[[Category:Algorithms]] | [[Category:Algorithms]] |
Revision as of 00:05, 26 October 2016
This page explains the game's process behind spawning enemies in a cave. This is obtained through observation, and is subject to have some parts incorrect.
Editor's note: Until further notice, this only applies to spawning enemies.
Process
Some time after the cave is built out of its available units, it will run the "main algorithm" in order to spawn enemies.
Main algorithm
- For each
TekiInfo
entry in the sublevel's configuration...- Store the minimum amount of enemies to spawn.
- Store the spawn coordinate type.
- Do the spawn algorithm with this enemy type, amount, and spawn coordinate type.
- If the number of enemies hasn't reached
{f002}
yet...- For each
TekiInfo
entry in the sublevel's configuration...- Grab its random distribution weight and add it to a list.
- While the number of enemies hasn't reached
{f002}
...- Randomly decide what enemy to spawn next, using the weighted list built in the last step.
- Store the enemy's type.
- Store the spawn coordinate type.
- Do the spawn algorithm with this enemy type, amount of 1, and spawn coordinate type.
- For each
Spawn algorithm
- While the intended amount of enemies hasn't been spawned yet...
- If all of the possible spawn positions have been used up, finish the whole enemy spawn process.
- Pick a random spawn coordinate (every unit in the cave has a set of spawn coordinates).
- If this coordinate is out of bounds, skip it.
- If this coordinate has already been used, skip it.
- Decide how many enemies to spawn here, picking randomly between the spawn coordinate's amount limits.
- For each one in that amount...
- If the number of enemies spawned here surpasses the intended amount, leave this algorithm.
- Spawn that enemy in these coordinates (with slight variation).
- Mark this spawn coordinate as used.