Contents

Missed spawn cubes flying directly due east or west will carry on almost indefinitely, even sailing through the walls of the level and eventually wrapping around to the other side of the map. Given enough time, this will result in an nearly endless string of spawn cubes crossing the level (or multiple such streams in case there are multiple monster spawners and/or spawn spots arranged in this fashion).

Therefore, to obtain the effect of the spawn cube flying to its spawn point, it is important that the initial reactiontime value corresponds to how many times A_SpawnFly will be called until reaching the destination point. The idea is very simple: take the distance to run, divide it by the cube's flying speed, and by the number of tics it takes for A_SpawnFly to be called. (By the way, given how the computation is made, if the spawn cube's states are not homogeneous in length, this will break too, because A_BrainSpit assumes the length of the cube's spawn state is the length of all its flying states.)

Here, P_SpawnMissile will take care of the hard part of separating the spawn cube's speed into both a east-west component (momx) and an north-south component (momy). So we can just take one of these components, and the corresponding distance, and it'll be a lot simpler than having to bother with Pythagoreanizing both axes.

Of course, if the target is directly east or west, then the distance is 0.

The speed should also be zero, which would lead to a divide by zero crash, if it were not for the inaccurate trigonometry tables which prevents an actor's momentum from being purely orthogonal to the grid.

Because reactiontime is a signed 32-bit integer, after 4,294,967,296 decrement operations the reactiontime value would wrap around the entire 32-bit space and finally reach 0, causing a monster to spawn. Since the decrement operation is called once every 3 tics, this would take approximately 11.67 years, making it essentially impossible to witness in practice. However, through the direct editing of memory values, it has been shown that the spawn cube would indeed eventually spawn a monster, discounting any other bugs that might cause the game to crash before 11.67 years had elapsed.

A level set up to demonstrate this bug (file info). The level contains a monster spawner which will dispense spawn cubes in each cardinal direction, with each spawn spot evenly spaced from it; wait until it shoots east and west to see this bug.