Editing Cave spawning
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | This page explains the game's process behind spawning enemies in a cave. This is obtained through | + | 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 further notice, this only applies to spawning enemies.}} |
− | == | + | ==Process== |
− | + | Some time after the cave is built out of its [[Cave unit list file|available units]], it will run the "main algorithm" in order to spawn enemies. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | == | + | ===Main algorithm=== |
− | + | # For each <code>TekiInfo</code> entry in the [[Cave definition file|sublevel's configuration]]... | |
+ | ## Store the minimum amount of enemies to spawn. | ||
+ | ## Store the spawn coordinate type. | ||
+ | ## Do the [[#Spawn algorithm|spawn algorithm]] with this enemy type, amount, and spawn coordinate type. | ||
+ | # If the number of enemies hasn't reached <code>{f002}</code> yet... | ||
+ | ## For each <code>TekiInfo</code> entry in the sublevel's configuration... | ||
+ | ### 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. | ||
+ | ## Store the enemy's 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=== |
− | # | + | # For every unit that makes up the fully-built cave... |
− | + | ## For every [[Cave unit definition file#layout.txt|spawn coordinate inside that unit]]... | |
− | + | ### If all of the possible spawn positions have been used up, finish the whole enemy spawn process. | |
− | + | ### 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 total number of enemies is equal to <code>{f002}</code>, finish the whole enemy spawn process. | |
− | + | #### If the number of enemies spawned here surpasses the intended amount, leave this algorithm. | |
− | + | #### Spawn that enemy in these coordinates. | |
− | + | ### Mark this spawn coordinate as used. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | # | ||
− | # For | ||
− | # | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | # | ||
− | ## | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | # | ||
− | ## If | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | # | ||
− | ## If this | ||
− | |||
− | ## | ||
− | |||
− | |||
− | |||
− | |||
− | ### | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | ## | ||
− | |||
− | ## If | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | ## | ||
− | # | ||
− | |||
− | |||
− | |||
− | |||
− | # If | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | # | ||
− | ## | ||
− | ## | ||
− | # | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
[[Category:Pikmin 2]] | [[Category:Pikmin 2]] | ||
[[Category:Algorithms]] | [[Category:Algorithms]] |