harbingerofme / DebugToolkit

Debugging commands for Risk of Rain 2. Previously known as RoR2Cheats.
https://thunderstore.io/package/IHarbHD/DebugToolkit/
BSD 3-Clause "New" or "Revised" License
14 stars 8 forks source link

Fix spawning issues with spawn_ai #152

Closed SChinchi closed 8 months ago

SChinchi commented 8 months ago

The last change to this command used the spawn card for spawning and with reference to the player's foot position (#149). This introduced various issues.

  1. Not every master has a spawn card, which requires constructing one on the fly.
  2. Spawning via the spawn card eventually calls CharacterMaster.Respawn which recalculates the spawning position to be on the ground. That in combination with CharacterBody.footPosition would ensure enemies spawn properly on the ground. For example, an Imp Overlord (as a player) is too tall and the respawn adjustment would fail to find the ground if the spawning was done from its core position. However, this change causes flyers to spawn under the player and into the ground. Other big entities instead force the player to clip into the ground as their colliders overlap. While this overlapping existed with the previous method, due to their relative positions they would just push each other away laterally. The solution is to take the spawning entity's size into account and spawn it far enough so there are no collisions. Flyers also now spawn above the player's head.

A lot of the calculations involved to address the second issue also play into the fact that spawning multiple flyers in the same spot causes them to be flung away. As such, the command had not been very useful to spawn, for example, multiple wisps, at the same time. I have changed the spawning procedure for flyers to spawn them in a ring with a radius big enough to ensure no overlap. This increases with respect to the number of requested spawns.

Another issue with this command irrelevant to the above, is that the character master keeps a reference to its ai components and it has no safeguards for null checking before acting on them. This can cause errors for a braindead entity, so the array is emptied. I figured it was too small of a change to make a whole separate PR for it.