“Cloudsurfing” in Final Fantasy VII

Final Fantasy games tend to have weird and crazy bugs, and VII was certainly no different. A bug beloved of speedrunners is called “Cloudsurfing,” where taking advantage of the way the game detects walkable overworld triangles and the way they’re cached to use Chocobos to walk over oceans and through mountains. Properly utilized, it can be used to skip a large portion of Disc 1.

AceZephyr explains it all in a 38-minute video:

Can I summarize it? I’ll try—

Prior Final Fantasy games used a simple tilemap to represent terrain. Final Fantasy VII’s overworld switched over to a world made up of triangles, each of which with a terrain code that indicated which entities can traverse it.

The triangles, additionally, are divided into square chunks. No triangle extends outside its chunk. Additionally, in each chunk, the triangle vertices aren’t represented literally for each triangle. Instead, the triangle coordinates are indexes into a list of coordinates, all to save a bit more memory.

Now, while each chunk is much smaller than the entire overworld, each can have over 100 triangles, so the code does some additional optimization. It keeps track of the last six triangles Cloud has touched, and checks them first when moving. If a triangle in this list is touched, then the search is stopped without checking the 100+ other triangles in the chunk.

Now, chunks are loaded into memory dynamically as Cloud explores, both for interaction and for rendering. The game loads the 25 chunks immediately around him off the disk, and some more in the direction the camera is facing. These chunks are constantly going stale (going out of range) and being refreshed as Cloud moves and the camera changes direction. Chunks are stored in a linked list, so are usually located by pointers, which means the chunks don’t need to be actually moved in memory, but instead references to them are copied and moved around. Some older chunks stick around in memory, then, while new ones are loaded, and the new chunks get moved to the top of the list.

Now this is the hardest part for me to explain, as I don’t have the firmest grasp on it….

When Cloud boards most vehicles, his entity is despawned and the vehicle is created with an empty list of cached triangles. But when he gets on a Chocobo, his entity is not despawned. While the Chocobo has its own cached list of triangles, since Cloud is still being rendered on screen, his entity is preserved, and with it pointers to the last triangles he interacted with. These are kept, unused, while the Chocobo handles all of the collision and terrain checking.

When Cloud gets off Choccy, he still has a list of the last triangles he interacted with… but they refer to the data from the chunk he was last in. Now the game is smart enough that, if this is different from his original chunk, to refresh things, but if it’s the same chunk I think this doesn’t happen. But this doesn’t mean everything will work without problems. The chunks will probably be loaded in a different order, and that means the cached triangles will refer to different data.

And since the vertices themselves aren’t stored in the triangle list, but indexes* to another list of data, it’s possible for some of this data to come from outside of the expected area, and for there to be duplicated coordinates among them.

Due to the way FFVII figures out which triangle Cloud is in, if two of the points in a triangle are on the same location, the game becomes much less discerning about whether Cloud is inside it or not. And if all three of the triangle’s vertices are in the same spot, forming what’s called a point triangle, just a single dot, then the game can’t declare Cloud is outside of it at all! So long as that triangle gets checked first, then the game will think Cloud is inside that triangle, so long as he’s in the same chunk. This could potentially turn the whole thing walkable.

Did I get it sufficiently right? Watch the video, and decide for yourself!

* The English graduate in me demands I point out that I know I’m being inconsistent with the plurals of vertex and index. Properly, like how I’m not writing vertexes, I should be writing indices, not indexes. I think that index is used more in contemporary English, so I made an editorial decision to pluralize it in a more familiar way. There, explanation: given.

Leave a Reply

Your email address will not be published. Required fields are marked *