Lets Build Ocarina of Time Part 2
Understanding the boot values
With this array properly annotated, we can begin to compare/contrast these values with other types of boots. This will help us understand what these 17 numbers actually do for each type of boots. We can start by thinking about the most obvious thing that the iron boots do to the player: make them move slower. So let’s compare the iron boots with the normal adult Kokiri boots:
The annotated values are the only things that are different about the Iron boots. Also, now that we know that there is an entirely different “boot” used while the player is underwater, we can further refine our analysis by realizing that these values only affect the player while on land.
So at this point, it’s helpful to go and play the game! Let’s load up the game and switch between the two types of boots and gather a list of differences that we can use to understand these highlighted numbers. Then, we will modify these numbers to see how that list of differences changes.
Let’s start by compiling the code to generate a rom file that we can load into our emulator of choice. I will not cover the compilation instructions in this article, but they are well documented here: https://github.com/Lucasjlw/oot/blob/master/README.md
Here is the list of differences that I found:
- Iron boots make the player walk/run slower.
- The player’s roll speed is reduced.
- The player’s turn speed is reduced.
- The player’s “gravity” is increased. (They fall faster/don’t jump as far).
- Backflipping and sidehopping speed is reduced.
We have three values, and 6 different observed differences. We can, however, make the assumption that all of the differences related to the “speed” of the player are handled by the same value. Therefore, we have the following list:
- When wearing iron boots, player’s speed in all forms is reduced.
- The player falls to the ground faster.
- Turning speed is reduced.
NOTE: We treat turning speed as different than other types of movement speed because it is not linear motion.
Let’s test this hypothesis by modifying the values, compiling the code, and seeing how everything changes afterwards.
We changed the 0 that was present in the PLAYER_IRON_BOOTS array into 350 to match what was in the PLAYER_KOKIRI_BOOTS. Let’s compile the code now and play the game to see what this does for the iron boots. We should see one of our three “differences” disappear since it is now the same as the Kokiri boots.
After playing around and switching between the boots, we can see that the animation that plays while walking in the iron boots is now a lot faster. It may look like Link is moving faster because of this, but he is actually moving just as slow as he usually does while wearing the iron boots; the animation just makes it looks like he's moving faster.
Okay cool, we know what this value does. Let’s move on to the next value:
We changed the last value back to 0, and changed the second value from 300 to 600. We want to put the other value back to the default state so we can see what each value does in isolation since we have no idea whether these values have a combined effect. It’s possible that a combination of two values modifies Link’s behavior in ways we do not expect, so we want to change only one of them at a time.
Let’s compile the game and see the results.
After playing around with the new iron boot value, we notice two things:
- Link is moving faster
- Link’s iron boot walk animation is the same.
So now we know which value determines Link's movement speed. This also confirms our assumption that the previous value modifies the animation speed instead of Link's movement speed.
We have one more value to test, but at this point, we pretty much know what it must do: change the "gravity" felt by Link. Let's play around with this value as well.
So let's do that now:
After compiling and playing around with the new boot values, we can confirm that the -160 value was in fact modifying Link's "gravity". If you backflip in game, he now jumps as high in iron boots as he does with Kokiri boots.
Our initial hypothesis was wrong... Remember our list of three "differences" we found when comparing the default Kokiri boots with the default iron boots? Instead of turn speed, we had a value for animation speed. Our other two guesses were correct, however. Even though we were not 100% correct in our guess, it was still a very wise idea to come up with this list because it gave us a good reference/framework to move forward in our analysis.
Following this methodology of generating an initial hypothesis, modifying the code based on this hypothesis, and comparing the results to our hypothesis will let us go very far in trying to understand this complicated code. We will continue to do so for the remainder of this series and this methodology is a very good approach to take when trying to figure out anything complex.
We now know what some of these values are for, and we can annotate this array appropriately for our future reference. To be more concise, we will describe each value's purpose by using its index value as a reference.
Awesome! In the next article, we're going to continue on and try to figure out the rest of these values by using the hover boots. See you soon!
The Ocarina of Time code comes from https://github.com/zeldaret/oot and is thanks to the hard work of many open-source developers. Please consider supporting their awesome work.