Cave spawning

From Pikmin Technical Knowledge Base
Revision as of 23:43, 17 October 2016 by Espyo (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

  1. For each TekiInfo entry in the sublevel's configuration...
    1. Store the minimum amount of enemies to spawn.
    2. Store the spawn coordinate type.
    3. Do the spawn algorithm with this enemy type, amount, and spawn coordinate type.
  2. If the number of enemies hasn't reached {f002} yet...
    1. For each TekiInfo entry in the sublevel's configuration...
      1. Grab its random distribution weight and add it to a list.
    2. Randomly decide what enemy to spawn next, using the weighted list built in the last step.
    3. Store the enemy's type.
    4. Store the spawn coordinate type.
    5. Do the spawn algorithm with this enemy type, amount of 1, and spawn coordinate type.

Spawn algorithm

  1. For every unit that makes up the fully-built cave...
    1. For every spawn coordinate inside that unit...
      1. If all of the possible spawn positions have been used up, finish the whole enemy spawn process.
      2. If this coordinate is out of bounds, skip it.
      3. If this coordinate has already been used, skip it.
      4. Decide how many enemies to spawn here, picking randomly between the spawn coordinate's amount limits.
      5. For each one in that amount...
        1. If the total number of enemies is equal to {f002}, finish the whole enemy spawn process.
        2. If the number of enemies spawned here surpasses the intended amount, leave this algorithm.
        3. Spawn that enemy in these coordinates.
      6. Mark this spawn coordinate as used.