Help with lua

Status
Not open for further replies.

MarioFreak2001

that one gal
I was wondering if you could make it so that when a player jumps, they would be in the springing animation, but a few frames later, would be in the spinning animation, kinda like in Sonic 06.
 
You sure can!

If you want to do it under a timer, as you mentioned in this post, set up a player variable that increments every tic. Remember that 35 tics = 1 second, so if you want the jump state to last for 1 second, change the player's state after the variable hits 35. So it would look something like this:

Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if player.counter == nil then player.counter = 0 end
		if (player.pflags & PF_JUMPED)
			player.counter = $1 + 1
		elseif P_IsObjectOnGround(player.mo)
			player.counter = 0
		end
		if player.counter >= 35
			if (player.counter % 8) > 3
				player.mo.state = S_PLAY_FALL1
			else player.mo.state = S_PLAY_FALL2
			end
		end
	end
end)

If you instead want to make it so that it instead detects when the player stops rising, the same way it works in 06 afaik, change the player's state when the z momentum is negative:

Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if player.counter == nil then player.counter = 0 end
		if (player.pflags & PF_JUMPED) and player.mo.momz < 0
			if player.counter > 3
				player.mo.state = S_PLAY_FALL1
			else player.mo.state = S_PLAY_FALL2
			end
			player.counter = $1 + 1
			if player.counter > 7 then player.counter = 0 end
		elseif not player.counter == 0 then player.counter = 0
		end
	end
end)
This also puts the player back into the spin state when he bounces off an enemy because of the small height boost, which I think is kind of cool but up to you.

Also keep in mind that these codes merely change the jump's appearance; if you want to change other things like the ability to be damaged or preventing mid-air moves, you'll need to do some additional scripting.
 
I meant when you jump you would be in the "spring" animation, but 3 or 4 frames later, would go into the spinning animation. I think you got it backwards, but it's still pretty cool!
 
Ah, my bad. Must've misread your post. Same idea, though—only you would have to force the state to S_PLAY_SPRING while the player is traveling upwards, or under a timer.
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top