SRB2 Message Board  

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

Reply
 
Thread Tools Search this Thread
Old 06-28-2017   #1
MarioFreak2001
The Cyan Knux
 
MarioFreak2001's Avatar
Default Sonic 06 style thok?

I'm trying to make a Sonic 06 style thok, and I need some help.
Here's the code:

addHook("ThinkFrame", do
for player in players.iterate
if player.mo and player.mo.skin == player.mo.skin
if not (player.mo.thoktimer)
player.mo.thoktimer = 0
end
if player.mo.thoktimer > 0
player.mo.thoktimer = $1 - 1
end
if player.pflags & PF_THOKKED
and (not(player.homing))
and player.powers[pw_super] == 0
//P_InstaThrust(player.mo, player.mo.angle, 50*FRACUNIT)
A_Thrust(player.mo, 50, 1)
local thok = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_THOK)
thok.color = player.mo.color
thok.scale = player.mo.scale
thok.fuse = 3
player.mo.momz = 0
end
end
end
end)

Sonic keeps getting thrusted forward, which is the desired effect, but I want him to stop 1 second after thoking. And I don't know how to do that.
EDIT: Ignore the code not looking right.
EDIT: Also I want him to drop like a rock when the thok ends like in Sonic 06
__________________
Set your volume at full, then click this.

Last edited by MarioFreak2001; 06-28-2017 at 03:56 PM.
MarioFreak2001 is offline   Reply With Quote
Old 06-28-2017   #2
Yacker
Metallic
 
Yacker's Avatar
Default

You have the right idea with thoktimer, you're just not doing anything with it.
Set thoktimer to however many tics you want it to last when the player thoks (i.e. if you wanted it to last 1 second you'd set it to 35) and add a check if player.mo.thoktimer == 0 directly after player.mo.thoktimer = $1 - 1 so it's in the player.mo.thoktimer > 0 if-end, set the players momx and momy to 0 and momz to what ever you may deem necessary if thoktimer is 0.

You may also wish to keep the players momz to 0 during the thok, which you could do by adding player.mo.momz = 0 in with the code that decrements thoktimer.
Yacker is offline   Reply With Quote
Old 06-28-2017   #3
MarioFreak2001
The Cyan Knux
 
MarioFreak2001's Avatar
Default

Quote:
Originally Posted by Yacker View Post
You have the right idea with thoktimer, you're just not doing anything with it.
Set thoktimer to however many tics you want it to last when the player thoks (i.e. if you wanted it to last 1 second you'd set it to 35) and add a check if player.mo.thoktimer == 0 directly after player.mo.thoktimer = $1 - 1 so it's in the player.mo.thoktimer > 0 if-end, set the players momx and momy to 0 and momz to what ever you may deem necessary if thoktimer is 0.

You may also wish to keep the players momz to 0 during the thok, which you could do by adding player.mo.momz = 0 in with the code that decrements thoktimer.
I'm getting a bit confused...
I'm not that great with coding, so could you explain it a bit clearer?
__________________
Set your volume at full, then click this.
MarioFreak2001 is offline   Reply With Quote
Old 06-28-2017   #4
Yacker
Metallic
 
Yacker's Avatar
Default

Spoiler:
Code:
			if player.pflags & PF_THOKKED
			and (not(player.homing))
			and player.powers[pw_super] == 0
				//P_InstaThrust(player.mo, player.mo.angle, 50*FRACUNIT)
				A_Thrust(player.mo, 50, 1)
				local thok = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_THOK)
				thok.color = player.mo.color
				thok.scale = player.mo.scale
				thok.fuse = 3
				player.mo.momz = 0
			end


At this part, you'd want to add player.mo.thoktimer = 35, so it'd look like this:

Spoiler:
Code:
			if player.pflags & PF_THOKKED
			and (not(player.homing))
			and player.powers[pw_super] == 0
				//P_InstaThrust(player.mo, player.mo.angle, 50*FRACUNIT)
				A_Thrust(player.mo, 50, 1)
				local thok = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_THOK)
				thok.color = player.mo.color
				thok.scale = player.mo.scale
				thok.fuse = 3
				player.mo.momz = 0
				player.mo.thoktimer = 35
			end


Then at this part
Spoiler:
Code:
			if player.mo.thoktimer > 0
				player.mo.thoktimer = $1 - 1
			end

You'd want to add
if player.mo.thoktimer == 0
player.mo.momx = 0
player.mo.momy = 0
player.mo.momz = -20*FRACUNIT
end

so it'd look like:

Spoiler:
Code:
			if player.mo.thoktimer > 0
				player.mo.thoktimer = $1 - 1
				if player.mo.thoktimer == 0
					player.mo.momx = 0
					player.mo.momy = 0
					player.mo.momz = -20*FRACUNIT
				end
			end


This makes it so when you thok you set thoktimer to 35, which is equivelant to 1 second because srb2 has 35 tics in 1 second. It decrements thoktimer until it reaches 0, and when it does, it resets your momentum and makes you drop faster.
Yacker is offline   Reply With Quote
Old 06-28-2017   #5
MarioFreak2001
The Cyan Knux
 
MarioFreak2001's Avatar
Default

So, should it look like this?

Quote:
addHook("ThinkFrame", do
for player in players.iterate
if player.mo and player.mo.skin == player.mo.skin
if not (player.mo.thoktimer)
player.mo.thoktimer = 0
end
if player.mo.thoktimer > 0
player.mo.thoktimer = $1 - 1
if player.mo.thoktimer == 0
player.mo.momx = 0
player.mo.momy = 0
player.mo.momz = -20*FRACUNIT
end
end
if player.pflags & PF_THOKKED
and (not(player.homing))
and player.powers[pw_super] == 0
//P_InstaThrust(player.mo, player.mo.angle, 50*FRACUNIT)
A_Thrust(player.mo, 50, 1)
local thok = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_THOK)
thok.color = player.mo.color
thok.scale = player.mo.scale
thok.fuse = 3
player.mo.momz = 0
player.mo.thoktimer = 35
end
end
end
end)
EDIT: It's not working. I just end up with the same result as the original code.
__________________
Set your volume at full, then click this.

Last edited by MarioFreak2001; 06-28-2017 at 05:11 PM.
MarioFreak2001 is offline   Reply With Quote
Old 06-28-2017   #6
Yacker
Metallic
 
Yacker's Avatar
Default

Oh, I mis-read the code. My apologies. You'd want to add a seperate variable to dictate whether or not you've already thokked in that jump, and set thoktimer to 35 in that instead. This could be achieved by changing a variable depending on whether or not the player's got PF_THOKKED already, and code before that checking for both PF_THOKKED and that variable, which sets thoktimer to 35, and only thrusting if thoktimer is above 0.

Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin == player.mo.skin
			if not (player.mo.thoktimer)
				player.mo.thoktimer = 0
			end
			if not (player.mo.canthok)
				player.mo.canthok = 0
			end
			if player.mo.thoktimer > 0
				player.mo.thoktimer = $1 - 1
				if player.mo.thoktimer == 0
					player.mo.momx = 0
					player.mo.momy = 0
					player.mo.momz = -20*FRACUNIT
				end
			end
			if player.pflags & PF_THOKKED
			and (not(player.homing))
			and player.powers[pw_super] == 0
			and player.mo.thoktimer > 0
				//P_InstaThrust(player.mo, player.mo.angle, 50*FRACUNIT)
				A_Thrust(player.mo, 50, 1)
				local thok = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_THOK)
				thok.color = player.mo.color
				thok.scale = player.mo.scale
				thok.fuse = 3
				player.mo.momz = 0
			end
			if player.pflags & PF_THOKKED and player.mo.canthok == 1
				player.mo.thoktimer = 35
			end
			if player.pflags & PF_THOKKED
				player.mo.canthok = 0
			else
				player.mo.canthok = 1
			end
		end
	end
end)
This should work, for instance.
Yacker 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 06:43 AM.


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