SRB2 Message Board  

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

Reply
 
Thread Tools Search this Thread
Old 08-23-2016   #1
Zero_the_artificial
A Weavile Enthusiast
 
Zero_the_artificial's Avatar
Default Need help integrating a fix in my Character's Script!

Hiya people!

I've been having some issues with a certain character that's been sitting in Submissions for a while now, and Judges have tried to help me with a certain glitch involving one of the character's abilites. Problem is... I am absolutely clueless when it comes to Lua, so any advices and LITERAL CORRECTIONS to the code went over my head because I just didn't understand what to do.

The following is the part of the code that should be changed:

Code:
addHook("MobjSpawn", function(mo) mo.dashing = 0 end, MT_PLAYER)
addHook("MobjSpawn", function(mo) mo.dashslow = 0 end, MT_PLAYER)
//Thanks to BlueBlurForever for letting me use his "Dashing" Script!
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin == "weavile"
		and not (player.pflags & PF_NIGHTSMODE)
	    and (player.cmd.buttons & BT_USE)
		and not (player.pflags & (PF_ROPEHANG|PF_CARRIED|PF_ITEMHANG|PF_MACESPIN))
		and not (player.exiting)
		and not (player.pflags & PF_TIMEOVER)
		and not (player.pflags & PF_SPINNING)
	    and not (player.mo.state == S_PLAY_DIE)
	    and not (player.weapondelay)
		and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
        and P_IsObjectOnGround(player.mo)
	    and (player.mo.dashing == 0)
	    and (player.mo.dashslow == 0)
				    S_StartSound(mo, sfx_wclaw)
					player.mo.state = S_PLAY_ATK1
                    A_Thrust(player.mo, 60, 1)
					player.powers[pw_nocontrol] = 32767
					player.powers[pw_invulnerability] = 25
			player.mo.dashing = 1
            end
			if player.mo.dashing == 1
			player.mo.dashing = 0
			player.mo.dashslow = 1
			end
			if player.mo.dashslow == 1
			and player.mo.momx == 0
			and player.mo.momy == 0
			player.powers[pw_nocontrol] = 0
			player.powers[pw_invulnerability] = 0
			player.mo.state = S_PLAY_RUN1
			player.mo.dashslow = 0
			end
			if (player.mo.state == S_PLAY_SPRING) then
			player.powers[pw_nocontrol] = 0
			player.powers[pw_invulnerability] = 0
        end
	end
end)

addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin == "weavile"
				and not (player.pflags & PF_NIGHTSMODE)
			player.powers[pw_underwater] = 1073741824
			player.powers[pw_spacetime] = 1073741824
		end
	end
end)
Zipper said that I had to do the following:
Spoiler: quite long
Right, so:

"addHook("MobjSpawn", function(mo) mo.invuln = 0 end, MT_PLAYER)" You'll need this at the start.

Code:
    S_StartSound(mo, sfx_wclaw)
    player.mo.state = S_PLAY_ATK1
    A_Thrust(player.mo, 60, 1)
    player.powers[pw_nocontrol] = 32767
    player.powers[pw_invulnerability] = 25
    player.mo.dashing = 1
This is where you'd check if player.powers[pw_invulnerability] is above 25, right before setting it. If it's above 25, skip that part, and make player.mo.invuln equal 1.

Code:
if player.mo.dashslow == 1
			and player.mo.momx == 0
			and player.mo.momy == 0
			player.powers[pw_nocontrol] = 0
			player.powers[pw_invulnerability] = 0
			player.mo.state = S_PLAY_RUN1
			player.mo.dashslow = 0
			end
			if (player.mo.state == S_PLAY_SPRING) then
			player.powers[pw_nocontrol] = 0
			player.powers[pw_invulnerability] = 0
        end
Before setting pw_invulnerability to 0, check if mo.invuln was 1 (which would mean the player was invulnerable when we started). If it's NOT 1, (they weren't invincible) set the invulnerability to 0. After that, set player.mo.invuln to 0, it's fulfilled its purpose for this check.


Again, I just don't understand what I'm supposed to do. English isn't my main language, and Lua is something I just can't understand, so combine them and you get complete frustration and running around in circles doing nothing.

Any help will be appreciated. Many, many thanks!
hope im not breaking any rules, jeez im scared :<
__________________
Weavile slayed Dragons before it was cool. ᕙ(⌐■ᨎ■)ᕗ
http://steamcommunity.com/groups/TemmieIsGod
Zero_the_artificial is offline   Reply With Quote
Old 08-24-2016   #2
Prime 2.0
Grape flavored
Administrator
 
Prime 2.0's Avatar
Default

Why would I have advised you to post here if it would be breaking the rules? Sheesh. =P
__________________
Science tells us that nothing can be proven, only rendered more likely to be true. If we do not question what we already know, how can we know, much less admit, when we're wrong? Such things are vital to progress.
Prime 2.0 is offline   Reply With Quote
Old 08-24-2016   #3
Zero_the_artificial
A Weavile Enthusiast
 
Zero_the_artificial's Avatar
Default

I don't know, I'm scared of anything, even if I know what I'm doing isn't against the rules ;w;

Anyways, I think I should explain the glitch.

Weavile has a ground attack where she throws herself forward and temporarily turns invincible. Thing is, if you are already invincible via the item box, the attack will break it. You also fully stop after the attack finishes, so you can't really keep up speed with it. Also, if you're on a conveyor belt and use this attack, you'll freeze where the attack stops, and be unable to move.
Again, any help will be appreciated.
__________________
Weavile slayed Dragons before it was cool. ᕙ(⌐■ᨎ■)ᕗ
http://steamcommunity.com/groups/TemmieIsGod
Zero_the_artificial is offline   Reply With Quote
Old 08-25-2016   #4
Zipper
Soulja boy I tell 'em
Judge
 
Zipper's Avatar
Default

I should just stop beating around the bush, huh?

Here's a fix I applied myself. It worked fine during my tests, but feel free to notify me if there are any problems you see.

Code:
//you don't need 5 MobjSpawn hooks for this, one size fits all
addHook("MobjSpawn", function(mo) 
	mo.airdash = 0
	mo.airdashlock = 0
	mo.timer3 = 0
	mo.dashing = 0
	mo.preinvuln = 0
end, MT_PLAYER)

//Thanks to BlueBlurForever for letting me use his "Dashing" Script!
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin == "weavile"
		and not (player.pflags & PF_NIGHTSMODE)
	    and (player.cmd.buttons & BT_USE)
		and not (player.pflags & (PF_ROPEHANG|PF_CARRIED|PF_ITEMHANG|PF_MACESPIN))
		and not (player.exiting)
		and not (player.pflags & PF_TIMEOVER)
		and not (player.pflags & PF_SPINNING)
	    and not (player.mo.state == S_PLAY_DIE)
	    and not (player.weapondelay)
		and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
        and P_IsObjectOnGround(player.mo)
	    and (player.mo.dashing == 0)
				    S_StartSound(mo, sfx_wclaw)
					player.mo.state = S_PLAY_ATK1
                    A_Thrust(player.mo, 60, 1)
					player.powers[pw_nocontrol] = 32767
					if (player.powers[pw_invulnerability] > 25) then
						//so here's the deal: we were already invulnerable, AND we have more than 25 tics left. so we keep a new variable that helps us
						//with any more checks ahead.
						player.preinvuln = 1			
					else
						player.powers[pw_invulnerability] = 25
					end					
					player.mo.dashing = 1
        end
		//you never actually needed dashing AND dashslow, one just turns the other on instantly, so "dashing" was just wasted
			if player.mo.dashing == 1
			and player.mo.momx == 0
			and player.mo.momy == 0
				player.powers[pw_nocontrol] = 0
				player.mo.state = S_PLAY_RUN1
				player.mo.dashing = 0
				//if we had the invulnerability flag up from earlier, we won't do anything, we want to keep our invincibility.
				if (player.preinvuln == 0) then
					player.powers[pw_invulnerability] = 0
				end
				player.preinvuln = 0;
			end
			//SPRING is also the jumping state, just sayin'
			if (player.mo.state == S_PLAY_SPRING and player.mo.dashing == 1) then
				player.powers[pw_nocontrol] = 0
				player.mo.dashing = 0;
				//again, we shouldn't be interrupted.
				if (player.preinvuln == 0) then
					player.powers[pw_invulnerability] = 0
				end
				player.preinvuln = 0
			end
	end
end)
I tried to explain in the comments, but I'll reiterate:

-MobjSpawn is actually really useful for setting up custom variables. Not obligatory, but helpful.

-dashslow is worthless.

-You enable a custom variable (preinvuln, in this case) if you're already invincible and have more than 25 tics (25 being the limit your dash attack gives, as you wrote in the code). You CHECK for this custom variable when you're ending your dash and removing invincibility. After the check, you reset it to 0, since it won't be used again until you dash again.

-I checked for "dashing" when looking at S_PLAY_SPRING, because if I hadn't it just removed invincibility when jumping :V
Zipper is offline   Reply With Quote
Old 08-25-2016   #5
Zero_the_artificial
A Weavile Enthusiast
 
Zero_the_artificial's Avatar
Default

Okay, this worked.

Kinda.

You see, the invincibility glitch is now solved, which is great, but... Something's still not fixed.


So, since you're unable to move until the attack is finished, and the conveyor belt keeps moving you, you're stuck and can't move. Is there a way to end the attack without the need of the character having to fully stop? It not only would fix this issue, but it would make Weavile's movement more fluid. It would be like a little boost on the ground.

Thanks for everything!
__________________
Weavile slayed Dragons before it was cool. ᕙ(⌐■ᨎ■)ᕗ
http://steamcommunity.com/groups/TemmieIsGod
Zero_the_artificial is offline   Reply With Quote
Old 08-25-2016   #6
Zipper
Soulja boy I tell 'em
Judge
 
Zipper's Avatar
Default

You COULD just start a new timer that decreases every tic. Like, when she dashes, just set "player.mo.dashtimer = 50" (or whatever you want to call it), and add

Code:
 if (player.mo.dashtimer > 0) then
    player.mo.dashtimer = $ - 1;
 end
And add this to the old check;

Code:
if player.mo.dashing == 1
			and ((player.mo.momx == 0
			and player.mo.momy == 0) or (player.mo.dashtimer == 0))
Mess with this a bit, and it should work. You might want to reset the dashtimer to 0 whenever you CANCEL your dash as well. (You know, the part where you check for S_PLAY_SPRING)
Zipper is offline   Reply With Quote
Old 08-25-2016   #7
Zero_the_artificial
A Weavile Enthusiast
 
Zero_the_artificial's Avatar
Default

Quote:
Originally Posted by Zipper View Post
things i can't understand
...
I tried to understand what I was supposed to do, and here's what I did:
[My edits are marked]

Code:
//you don't need 5 MobjSpawn hooks for this, one size fits all
addHook("MobjSpawn", function(mo) 
	mo.airdash = 0
	mo.airdashlock = 0
	mo.timer3 = 0
	mo.dashing = 0
	mo.preinvuln = 0
	mo.dashtimer = 0
end, MT_PLAYER)

//Thanks to BlueBlurForever for letting me use his "Dashing" Script!
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin == "weavile"
		and not (player.pflags & PF_NIGHTSMODE)
	    and (player.cmd.buttons & BT_USE)
		and not (player.pflags & (PF_ROPEHANG|PF_CARRIED|PF_ITEMHANG|PF_MACESPIN))
		and not (player.exiting)
		and not (player.pflags & PF_TIMEOVER)
		and not (player.pflags & PF_SPINNING)
	    and not (player.mo.state == S_PLAY_DIE)
	    and not (player.weapondelay)
		and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
        and P_IsObjectOnGround(player.mo)
	    and (player.mo.dashing == 0)
				    S_StartSound(mo, sfx_wclaw)
					player.mo.state = S_PLAY_ATK1
                    A_Thrust(player.mo, 60, 1)
					player.powers[pw_nocontrol] = 32767
					if (player.powers[pw_invulnerability] > 25) then
						//so here's the deal: we were already invulnerable, AND we have more than 25 tics left. so we keep a new variable that helps us
						//with any more checks ahead.
						player.preinvuln = 1			
					else
						player.powers[pw_invulnerability] = 25
					end					
					player.mo.dashing = 1
					player.mo.dashtimer = 50
					 if (player.mo.dashtimer > 0) then
						player.mo.dashtimer = $ - 1;
				end
        end
		//you never actually needed dashing AND dashslow, one just turns the other on instantly, so "dashing" was just wasted
			if player.mo.dashing == 1
			and ((player.mo.momx == 0
			and player.mo.momy == 0) or (player.mo.dashtimer == 0))
				player.powers[pw_nocontrol] = 0
				player.mo.state = S_PLAY_RUN1
				player.mo.dashing = 0
				//if we had the invulnerability flag up from earlier, we won't do anything, we want to keep our invincibility.
				if (player.preinvuln == 0) then
					player.powers[pw_invulnerability] = 0
				end
				player.preinvuln = 0;
			end
			//SPRING is also the jumping state, just sayin'
			if (player.mo.state == S_PLAY_SPRING and player.mo.dashing == 1) then
				player.powers[pw_nocontrol] = 0
				player.mo.dashing = 0;
				//again, we shouldn't be interrupted.
				if (player.preinvuln == 0) then
					player.powers[pw_invulnerability] = 0
					player.mo.dashtimer = 0
				end
				player.preinvuln = 0
			end
	end
end)
The attack still works, but you still get stuck on conveyor belts if you decide to use the attack.
__________________
Weavile slayed Dragons before it was cool. ᕙ(⌐■ᨎ■)ᕗ
http://steamcommunity.com/groups/TemmieIsGod
Zero_the_artificial is offline   Reply With Quote
Old 08-26-2016   #8
Zipper
Soulja boy I tell 'em
Judge
 
Zipper's Avatar
Default

Quote:
Originally Posted by Zero_the_artificial View Post
...


Code:
//you don't need 5 MobjSpawn hooks for this, one size fits all
addHook("MobjSpawn", function(mo) 
	mo.airdash = 0
	mo.airdashlock = 0
	mo.timer3 = 0
	mo.dashing = 0
	mo.preinvuln = 0
	mo.dashtimer = 0
end, MT_PLAYER)

//Thanks to BlueBlurForever for letting me use his "Dashing" Script!
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin == "weavile"
		and not (player.pflags & PF_NIGHTSMODE)
	    and (player.cmd.buttons & BT_USE)
		and not (player.pflags & (PF_ROPEHANG|PF_CARRIED|PF_ITEMHANG|PF_MACESPIN))
		and not (player.exiting)
		and not (player.pflags & PF_TIMEOVER)
		and not (player.pflags & PF_SPINNING)
	    and not (player.mo.state == S_PLAY_DIE)
	    and not (player.weapondelay)
		and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
        and P_IsObjectOnGround(player.mo)
	    and (player.mo.dashing == 0)
				    S_StartSound(mo, sfx_wclaw)
					player.mo.state = S_PLAY_ATK1
                    A_Thrust(player.mo, 60, 1)
					player.powers[pw_nocontrol] = 32767
					if (player.powers[pw_invulnerability] > 25) then
						//so here's the deal: we were already invulnerable, AND we have more than 25 tics left. so we keep a new variable that helps us
						//with any more checks ahead.
						player.preinvuln = 1			
					else
						player.powers[pw_invulnerability] = 25
					end					
					player.mo.dashing = 1
					player.mo.dashtimer = 50
					
        end

        if (player.mo.dashtimer > 0) then
	    player.mo.dashtimer = $ - 1;
	end

		//you never actually needed dashing AND dashslow, one just turns the other on instantly, so "dashing" was just wasted
			if player.mo.dashing == 1
			and ((player.mo.momx == 0
			and player.mo.momy == 0) or (player.mo.dashtimer == 0))
				player.powers[pw_nocontrol] = 0
				player.mo.state = S_PLAY_RUN1
				player.mo.dashing = 0
				//if we had the invulnerability flag up from earlier, we won't do anything, we want to keep our invincibility.
				if (player.preinvuln == 0) then
					player.powers[pw_invulnerability] = 0
				end
				player.preinvuln = 0;
			end
			//SPRING is also the jumping state, just sayin'
			if (player.mo.state == S_PLAY_SPRING and player.mo.dashing == 1) then
				player.powers[pw_nocontrol] = 0
				player.mo.dashing = 0;
				//again, we shouldn't be interrupted.
				if (player.preinvuln == 0) then
					player.powers[pw_invulnerability] = 0
				
				end
                                	player.mo.dashtimer = 0
				player.preinvuln = 0
			end
	end
end)
Try this. We want the dashtimer to drop ON ITS OWN in the code. With the way you wrote it, it only decreases ONCE when you use the dash attack, so it's stuck at 49. (Feel free to use the print() function to see your values at all times, this is very helpful for debugging.)

Also, dashtimer should ALWAYS be changed to 0 when a dash ends, so you didn't need to put it inside the "preinvuln" check.

I'm pretty sure I messed it up somewhere, but oh well! (also oh my god this syntax is slowly becoming unreadable)
Zipper is offline   Reply With Quote
Old 08-26-2016   #9
Zero_the_artificial
A Weavile Enthusiast
 
Zero_the_artificial's Avatar
Default

Quote:
Originally Posted by Zipper View Post
Try this. We want the dashtimer to drop ON ITS OWN in the code. With the way you wrote it, it only decreases ONCE when you use the dash attack, so it's stuck at 49. (Feel free to use the print() function to see your values at all times, this is very helpful for debugging.)

Also, dashtimer should ALWAYS be changed to 0 when a dash ends, so you didn't need to put it inside the "preinvuln" check.

I'm pretty sure I messed it up somewhere, but oh well! (also oh my god this syntax is slowly becoming unreadable)
I think I'm going to go insane. I can't understand what I'm supposed to do, I barely know what I'm doing. Sorry for being such a nuisence, but I really want to fix this.
__________________
Weavile slayed Dragons before it was cool. ᕙ(⌐■ᨎ■)ᕗ
http://steamcommunity.com/groups/TemmieIsGod
Zero_the_artificial is offline   Reply With Quote
Old 08-26-2016   #10
Zipper
Soulja boy I tell 'em
Judge
 
Zipper's Avatar
Default

I didn't quote the code for shits and giggles, I edited it. Just sayin' :P
Zipper is offline   Reply With Quote
Old 08-27-2016   #11
Zero_the_artificial
A Weavile Enthusiast
 
Zero_the_artificial's Avatar
Default

Quote:
Originally Posted by Zipper View Post
I didn't quote the code for shits and giggles, I edited it. Just sayin' :P
Thing is, I can't seem to understand how to implement your edit in a way that actually works, or that doesn't completely destroy the code while you're tying to dash.
__________________
Weavile slayed Dragons before it was cool. ᕙ(⌐■ᨎ■)ᕗ
http://steamcommunity.com/groups/TemmieIsGod
Zero_the_artificial is offline   Reply With Quote
Old 08-27-2016   #12
Prime 2.0
Grape flavored
Administrator
 
Prime 2.0's Avatar
Default

Quote:
Originally Posted by Zero_the_artificial View Post
Thing is, I can't seem to understand how to implement your edit in a way that actually works, or that doesn't completely destroy the code while you're tying to dash.
By completely, 100% replacing the dash code that is already in your wad with a copy/paste of Zipper's. He did the whole thing for you.

That said, the //Airdash animation code, which you didn't paste above, seems to interfere. It might be a duplicate, I haven't looked that closely.
__________________
Science tells us that nothing can be proven, only rendered more likely to be true. If we do not question what we already know, how can we know, much less admit, when we're wrong? Such things are vital to progress.

Last edited by Prime 2.0; 08-27-2016 at 04:40 PM.
Prime 2.0 is offline   Reply With Quote
Old 08-27-2016   #13
Zero_the_artificial
A Weavile Enthusiast
 
Zero_the_artificial's Avatar
Default

Quote:
Originally Posted by Prime 2.0 View Post
By completely, 100% replacing the dash code that is already in your wad with a copy/paste of Zipper's. He did the whole thing for you.

That said, the //Airdash animation code, which you didn't paste above, seems to interfere. It might be a duplicate, I haven't looked that closely.
Just in case, I deleted the entire code and copy/pasted what Zipper posted, and it still didn't work. Therefore, I don't think the Airdash part of the code is interfiering. Again, it did fix the Invincibility glitch, but it still has this conveyor belt glitch. You can't move unless you get out of the coneyor belt or get hit.

EDIT: Lat' is currently helping out via pm.
__________________
Weavile slayed Dragons before it was cool. ᕙ(⌐■ᨎ■)ᕗ
http://steamcommunity.com/groups/TemmieIsGod

Last edited by Zero_the_artificial; 08-27-2016 at 09:59 PM.
Zero_the_artificial is offline   Reply With Quote
Old 08-30-2016   #14
ManimiFire
Meow Motherfuckers.
 
ManimiFire's Avatar
Default

Well, it's just my opinion, but when you did:

Code:
if player.mo.dashing == 1
and ((player.mo.momx == 0
and player.mo.momy == 0) or (player.mo.dashtimer == 0))
That's mean that the dash is over if the player not move forward, backward or to sides, even by a little.

And when you dashed into this conveyor, the conveyor still moved you when you got to player.mo.dashing = 1...

So, as my opinion, I think something is wrong with:

Code:
and ((player.mo.momx == 0...
__________________
Check out my youtube channel: https://www.youtube.com/channel/UCd1...hUkNvNA93RPI8g

Last edited by ManimiFire; 08-30-2016 at 09:47 AM.
ManimiFire is offline   Reply With Quote
Old 08-30-2016   #15
toaster
トースタちゃん
 
toaster's Avatar
Default

A good alternate suggestion would be to check player.rmomx and player.rmomy instead of the player.mo's momx and momy as Manimi correctly suggested. These alternate fields are the player's momentum with the conveyor's motion subtracted.
__________________
Quote:
<fickle> giant robo-hood that rips the map apart with her bare hands
shameless plug: please check out my sonic mania lego ideas project, it could become a real thing if yalls support it
toaster is offline   Reply With Quote
Old 08-30-2016   #16
Zero_the_artificial
A Weavile Enthusiast
 
Zero_the_artificial's Avatar
Default

Oh I'm sorry for not saying this: Lat' has already helped me out fixing this!

Now I play the waiting game in the Submissions :3
__________________
Weavile slayed Dragons before it was cool. ᕙ(⌐■ᨎ■)ᕗ
http://steamcommunity.com/groups/TemmieIsGod
Zero_the_artificial 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 04:44 PM.


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