Basic Jump Behavior
8 years ago

Today while practicing the 'Outpost Cache -> Junkyard Exit' jump and immediate upon transition teleshot strat- I discovered something interesting about jumping.

From the video you can see that it is pretty forgiving, you have what appears to be 5-10 frames to hit the jump button when you first enter your falling state.

Edited by the author 7 years ago
Denmark

You have precisely 7 frames to do this, and this is also why the green beam jump works and the only way to get the jump from Outpost Cache to Junkyard Exit. I tried to include this in my explanation in the Google docs, but I didn't really go into details so I guess I might as well here with the accompanying code. All the following code is from ots/Action/game/player/player.as in the game asset archive that was extracted.

When you press jump the game calls:

public function onJump() : void { if ((onGround || this.jumpException > 0) && !this.jumping) { if (!onWater) { _ySpeed = -JUMP_FORCE; } else { _ySpeed = -JUMP_FORCE; } this.jumpException = 0; if (!onGround && this.airborneFromTeleport) { this.onTeleJump(); } this.jumping = true; SoundManager.playSound("yuriJump"); } return; }// end function

so it allows you to jump if you're on the ground or you have a jumpException > 0. When you walk off a platform you get a jumpException of 7 (and it decreases by 1 every frame):

override protected function onLeaveGround() : void { super.onLeaveGround(); if (ySpeed > 0 && !this.jumping) { this.jumpException = 7; } return; }// end function

The same thing happens when you teleport. In that case the teleport function calls applyMomentum:

private function applyMomentum() : void { if (_ySpeed > 0) { _ySpeed = _ySpeed / 2; } if (_ySpeed < (-JUMP_FORCE) / 4) { this.onTeleJump(); _ySpeed = -JUMP_FORCE; } if (onGround) { this.jumpException = EXCEPTION_JUMP_FRAMES; } return; }// end function

private function tryTeleporting(param1:int, param2:int) : Boolean { if (!willCollide(param1, param2)) { this.level.particles.burst(this.x, this.y, "teleport", 1).startSize(6); setPosition(param1, param2); this.applyMomentum(); this.level.particles.burst(param1, param2, "teleport", 2); this.teleportTrail = this.level.particles.burst(param1, param2, "teleShot", 60); SoundManager.playSound("teleportSuccess"); this.airborneFromTeleport = true; this._grigoriTeleportTrigger = true; Steamworks.current.setStatInt("TELEPORT", (Steamworks.current.getStatInt("TELEPORT") + 1)); Steamworks.current.storeStats(); return true; } return false; }// end function

and EXCEPTION_JUMP_FRAMES = 6.

PrettzL likes this

So 7 frames for jumping without teleporting and 7 frames for jumping with teleporting?

Knowing that will definitely help with the consistency of nailing these tricky strats!

Great job ghuia. :D

Denmark

There is definitely 7 frames to jump when you're teleporting. Not completely sure if it's 7 or 8 when walking off a platform.

EDIT: The following stuff is wrong. There is no overridding going on. See my next post.

I think the game has a minor bug (I'm not sure on this) where when you teleport first the game sets jumpException = 6 because you teleported, but then since you left the ground the game overrides it with jumpException = 7. I think that's why you have 7 frames when you're teleporting rather than the 6 that

this.jumpException = EXCEPTION_JUMP_FRAMES;

would suggest. What I know for certain is that you have 7 frames because I have recorded myself doing it and I can always jump on the 7th frame, but never on the 8th.

Hm with that kind of a code override could it be possible that the first frame becomes invalidated while it is making this data adjustment?

Or another possibility, add a frame like you said an 8th frame when walking off?

Denmark

Actually I've been looking it a little more and I think I was wrong, there is no overriding going on. Teleporting works by directly calling setPosition but onLeaveGround is only called if you leave the ground with the method move().

What is really going on is the following:

Every frame both the teleshot and the player run onUpdate methods. Since the player was created before the teleshot it updates first. A player update basically consists of the following individual steps in the following order: updateControls - Check whether a key is pressed and adjust speed and such accordingly. updateAnimations - Irrelevant for our purposes updateCollisions - Irrelevant for our purposes updateProperties - This is where jumpException is decreased by 1.

For illustration lets say the player presses jump on the 7th frame. Then when a teleshot hits the following happens on the frame where the teleshot collides with a wall. Frame 1: player updates its state - teleshot still hasn't updated so the player doesn't do anything special. teleshot updates its state - it detects collision with a wall and sets player.jumpException = 6

Frame 2: player updates its state - now it knows we have teleported and it decreases player.jumpException to 5.

Frame 3: player updates its state - it decreases player.jumpException to 4.

Frame 4: player updates its state - it decreases player.jumpException to 3.

Frame 5: player updates its state -it decreases player.jumpException to 2.

Frame 6: player updates its state - it decreases player.jumpException to 1.

Frame 7 (jump is pressed): player.updateControls - jump is pressed so the game tests whether

(onGround || this.jumpException > 0) && !this.jumping

This is true since jumpException = 1. Therefore the game initiates a jump.

player.updateAnimations - Stuff happens player.updateCollisions - Stuff happens updateProperties - Here jumpException was supposed to be decreased to 0, but we managed to jump beforehand.

This explains why when a teleshot sets this.jumpException = 6 that really means we have 7 frames.

I'm unsure when exactly in the update process onLeaveGround is called so the time for when we walk off a platform could still be 7 or 8 frames depending on whether it's called before or after player.onUpdate().

UPDATE: You also have 7 frames when you walk off a platform that is because onLeaveGround is called before player.onUpdate. The way it works is that when a player object is created it registers first platformObject.onUpdate and only then player.onUpdate with the ON_UPDATE signal. So on a frame where you leave the ground the following would happen:

Frame 1: platformObject.onUpdate - this method detects that we left the ground via move and calls onLeaveGround which sets player.jumpException = 7 player.onUpdate - jumpException > 0 so it is decreased to 6.

Therefore coming out of frame 1 jumpException is 6 no matter if we walked off a platform or we teleported to another location.

SUMMARY: You always have 7 frames to jump when leaving solid ground.

PrettzL likes this
Game stats
Followers
105
Runs
428
Players
109
Latest threads
Posted 2 years ago
27 replies
Posted 6 years ago
1 reply
Posted 7 years ago
4 replies
Posted 7 years ago
21 replies