Need help integrating a fix in my Character's Script!

Status
Not open for further replies.

DrStephen

My PhD is made out of foam.
Judge
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:
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 :<
 
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.
 
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
 
Okay, this worked.

Kinda.

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


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!
 
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)
 
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
	[I][B]mo.dashtimer = 0[/B][/I]
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
					[I][B]player.mo.dashtimer = 50
					 if (player.mo.dashtimer > 0) then
						player.mo.dashtimer = $ - 1;
				end[/B][/I]
        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
			[I][B]and player.mo.momy == 0) or (player.mo.dashtimer == 0))[/B][/I]
				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
				[I][B]	player.mo.dashtimer = 0[/B][/I]
				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.
 
...


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
	[I][B]mo.dashtimer = 0[/B][/I]
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
					[I][B]player.mo.dashtimer = 50
					[/B][/I]
        end

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

		//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
			[I][B]and player.mo.momy == 0) or (player.mo.dashtimer == 0))[/B][/I]
				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
                                [I][B]	player.mo.dashtimer = 0[/B][/I]
				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)
 
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.
 
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.
 
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.
 
Last edited:
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.
 
Last edited:
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...
 
Last edited:
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.
 
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
 
Status
Not open for further replies.

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

Back
Top