SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Help

Reply
 
Thread Tools Search this Thread
Old 4 Weeks Ago   #1
MarioFreak2001
My wrist is better now :D
 
MarioFreak2001's Avatar
Default Help with lua

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.
__________________
Have a bowl, Mr. Squidward!
MarioFreak2001 is offline   Reply With Quote
Old 4 Weeks Ago   #2
Lach
 
Lach's Avatar
Default

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.
Lach is offline   Reply With Quote
Old 4 Weeks Ago   #3
MarioFreak2001
My wrist is better now :D
 
MarioFreak2001's Avatar
Default

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!
__________________
Have a bowl, Mr. Squidward!
MarioFreak2001 is offline   Reply With Quote
Old 4 Weeks Ago   #4
Lach
 
Lach's Avatar
Default

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.
Lach is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:59 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.