I've been having a lot of fun playing around more with the punch hopping trick recently. I've not yet got to the stage of creating any WIPs because I don't yet know how to use it optimally, but I think I'm getting closer!
(Warning: Essay ahead :P - just skip to my explanation of the lua script if you want to experiment and don't care about the details)
I've found some memory locations that track Rayman's speed, and discovered more how Rayman's speed works. When Rayman punches, his speed rises above it's normal maximum, and after the punch ends it eventually resets. But the key is that there are a few frames after the punch ends where the speed is stilll above maximum, and another punch done in those frames will raise the speed higher. (This only works if Rayman is in the air, but obviously using this trick he will be in the air pretty much constantly.)
This is why punch hopping (punching when in the air, jumping the frame the animation ends and then punching again the next frame) works so well, not just because Rayman can go indefinitely high, but because his speed is constantly rising. However, now that I understand why the speed is rising, I realise that in general he would move quicker if he didn't jump in between the two punches, because this loses some momentum. He does still need to stay in the air though, so you have to jump occasionally, but only enough to stay off the ground.
To summarise, the best way through a level is:
- Start by taking a running jump, and punch the next frame
- When the punching animation ends (the 'critical frame') jump again, and punch the next frame
- From now on, at every critical frame, do one of the following:
A: If you can do it without landing, just punch
B: If you need more height, jump and punch next frame
- Then wait until the next critical frame, rinse and repeat
This means the normal strategy (i.e. to stay a roughly consistent height) is to alternate punch hops and just punches, taking a bouncing movement around the level. I'm really pleased with this, not just because it's faster, but because it means an optimal run won't happen all off the top of the screen anymore!
There is one further issue, which is that since we're abusing the fact that the speed does not reset by stringing together punches, it becomes very hard to turn corners, the best you can do is take a long sweeping arc. If you need to turn a corner sharply though, there is a way you can do it at the cost of some speed. If, after jumping while holding your new direction, you wait a few frames before punching, this gives your speed in the previous direction some time to reduce, and therefore means you can turn at a sharper angle. The exact amount of frames you should wait depends on how sharp a turn you need to make, but it should never need to be more than about 10.
Knowing all this, I created
a series of macros to automate the trick, for my own use and if anyone else wants to play around with it.
There are three different options available, mapped to the keys J, K, and L (but feel free to remap them to suit your preferences):
J: Standard Punch Hop - Jumps, punches next frame, and waits until the critical frame. Use to get off the ground originally, or when you need more height.
K: Punch Boosting - Punches and waits until the critical frame. Use when you can do it without landing.
L: Delayed Punch Hop - Jumps, waits 10 frames, punches, and then waits until the critical frame. Loses speed so use only for turning sharply.
Using these, the normal strategy around a level is simply: J, J (to get into the air), and then alternating K,J,K,J... with an extra J if you need to gain extra height and L if you ever need to turn sharply.
To use them, hold the direction you want to travel and the necessary key, and press frame advance. The action occurs with a delay of one frame (because it was easier to code that way :P) and as such each macro actually takes you to the frame
before the critical one so that they can be strung together.
They will sometimes fail if there was lag on the first frame (although it should work around any other lag). If that happens, go back and wait one frame first before using it.
The 10 frame wait in the delayed punch hop is kind of arbitrary. To really optimise a turn you would need to choose the minimum wait necessary. This would have to be done manually, but I put that macro in just for help with routing.
If anyone else wants to experiment, these macros should make it a lot easier to do so. Even if you just want to mess around, it's a lot of fun to hold down J and frame advance and blast all over the level with reckless abandon!
One other thing. I mentioned before that it was possible to get over certain gates. Now that it's so easy to use this trick I've realised you can get over
all gates in the game, as long as you are high enough above them! That means the routes for most levels will be even shorter, since you don't have to press most of the switches. The only gates you need to open now are ones for Globox to get through.
And to think I used to play this game normally...