--any not reusable lua is made by me, originally an another guy worked for the
--lua but all he did is ask me stuff and give it to niko (the main developer)

addHook("SpinSpecial", function(player)
		if player.mo.skin == "nuko"
		and not (player.pflags & PF_THOKKED)
		and not player.powers[pw_shield]
		and not (player.pflags & PF_FULLSTASIS)
		and (player.pflags & PF_JUMPED)
		and not (player.mo.state == S_PLAY_PAIN)
		and (P_IsObjectOnGround(player.mo) == false) then
		S_StartSound(player.mo, sfx_spndsh) 
		player.mo.state = S_PLAY_SPINDASH
		player.charge = true
		player.pflags = $|PF_THOKKED 
	end
end)


	addHook("PlayerThink", function(player)
		if player.mo.skin == "nuko"
		and player.charge == true
		and not player.powers[pw_super]
		and (P_IsObjectOnGround(player.mo) == true) then
				S_StartSound(player.mo, sfx_zoom)
				player.mo.state = S_PLAY_ROLL
				player.charge = false
				player.pflags = $|PF_SPINNING
				P_Thrust(player.mo, player.mo.angle, 20*FRACUNIT)
		end
	end)

	addHook("PlayerThink", function(player)
		if player.mo.skin == "nuko"
		and player.charge == true
		and player.powers[pw_super]
		and (P_IsObjectOnGround(player.mo) == true) then
				S_StartSound(player.mo, sfx_zoom)
				player.mo.state = S_PLAY_ROLL
				player.charge = false
				player.pflags = $|PF_SPINNING
				P_Thrust(player.mo, player.mo.angle, 50*FRACUNIT)
				P_NukeEnemies(player.mo, player.mo, 1)
				P_StartQuake(20*FRACUNIT, 4)
		end
	end)
	
addHook("MobjMoveBlocked", function(mo)
    local player = mo.player
    if player.charge == true
	and player.powers[pw_super]
	player.mo.momz = player.speed/2 + player.mo.momz/10
	player.charge = false
	S_StartSound(player.mo, sfx_zoom)
	player.mo.state = S_PLAY_ROLL
	P_NukeEnemies(player.mo, player.mo, 1)
	P_StartQuake(20*FRACUNIT, 4)
	end
end, MT_PLAYER)

addHook("MobjMoveBlocked", function(mo)
    local player = mo.player
    if player.charge == true
	and not player.powers[pw_super]
	player.mo.momz = player.speed/2 + player.mo.momz/10
	player.charge = false
	S_StartSound(player.mo, sfx_zoom)
	player.mo.state = S_PLAY_ROLL
	end
end, MT_PLAYER)

addHook("SpinSpecial", function(player)
		if player.mo.skin == "nuko"
		and not (player.pflags & PF_THOKKED)
		and not player.powers[pw_shield]
		and not (player.pflags & PF_FULLSTASIS)
		and (player.pflags & PF_JUMPED)
		and not (player.mo.state == S_PLAY_PAIN)
		and (P_IsObjectOnGround(player.mo) == false) then
		S_StartSound(player.mo, sfx_spndsh) 
		player.mo.state = S_PLAY_RUN
		player.charge = true
		player.pflags = $|PF_THOKKED 
	end
end)

addHook("PlayerThink", function(player) 

	if not(player.mo) then return end 	

  if not (player.mo.skin == "nuko") then return end
	if (P_IsObjectOnGround(player.mo)) 
	and (player.mo.state == S_PLAY_RUN) 
	and not player.powers[pw_super]
		P_SpawnSkidDust(player, 13*FRACUNIT, sfx_none)
	end
end) 
--stretch lua by kirb, had to replace it because the normal stretch code was weird
--hi niko
		addHook("PlayerThink", function(player)
		if player.mo.skin == "nuko"
		and P_IsObjectOnGround(player.mo)
		 player.mo.spriteyscale = 1*FRACUNIT
	end
end)


		addHook("PlayerThink", function(player)
		if player.mo.skin == "nuko"
		and player.mo.momz > 1
		 player.mo.spriteyscale = 1*FRACUNIT + player.mo.momz/20
	end
end)

//Sonic Lost World Bounce Attack. made by MotdSpork. *Vine thud sfx*!
addHook("MobjThinker", function(nuko)
	if (nuko and nuko.skin == "nuko") //if you're nuko..
	and nuko.player.playerstate == PST_LIVE //you alive bruh?
	and not (nuko.player.powers[pw_super]) //super nuko has float instead
		if nuko.player.bounceattack == nil //if the variable doesnt exist
			nuko.player.bounceattack = 0 //create variable
		end
		if nuko.player.bouncenumber == nil //if the variable doesnt exist
			nuko.player.bouncenumber = 0 //create variable
			nuko.player.justchangedbouncenumber = 0 //create variable
		end
		if P_IsObjectOnGround(nuko) //are you on the ground?
		and nuko.player.bounceattack == 0 //the player isnt bouncing
			nuko.player.bouncenumber = 0 //set it to zero!
		end
		if nuko.player.usedown == nil //if the variable doesnt exist
		or not (nuko.player.cmd.buttons & BT_CUSTOM1) //not pressing the spin button?
			nuko.player.usedown = 0 //create variable
			nuko.player.justchangedbouncenumber = 0 //create variable
		end
		if P_IsObjectOnGround(nuko) //Is the player on the ground?
		and (nuko.player.cmd.buttons & BT_CUSTOM1) //Is the player holding the spin button?
			nuko.player.usedown = 1 //Set it to one!
		end
		if nuko.player.pflags & PF_JUMPED //if the player has jumped
		and not (nuko.player.pflags & PF_THOKKED) //and the player hasnt used their mid-air ability
		and not (P_IsObjectOnGround(nuko)) //and you arent on the ground.
		and nuko.player.cmd.buttons & BT_CUSTOM1 //pressing custom2?
		and nuko.player.bounceattack == 0 //checking if the custom variable it set to 0
		and nuko.player.usedown == 0 //make sure you arent holding the spin button.
		and not (nuko.player.exiting) //not...exiting the level?
		and nuko.health //you're alive?
		and not (P_PlayerInPain(nuko.player)) //not hurt are you?
			nuko.player.bounceattack = 1 //set it to one!
			P_SetObjectMomZ(nuko, -20*FRACUNIT) //make the player "shoot" downward
			//P_SetObjectMomZ(nuko, FixedMul(-35*FRACUNIT, nuko.scale)) //make the player shoot downwards 
			nuko.player.pflags = $1|PF_THOKKED //force the player into a "thokked" state
		end
			
		if (nuko.eflags & MFE_JUSTHITFLOOR) //you're on the ground.
		and not (nuko.player.pflags & PF_SPINNING) //you arent spinning....somehow
		and not (nuko.player.pflags & PF_STARTDASH) //you arent doing a spindash
		and not (nuko.tracer and nuko.tracer.type == MT_TUBEWAYPOINT) //not in a...zoomtube?
		and nuko.player.bounceattack == 1 //our custom variable is one right...?
		and nuko.health //is the player alive..?
		and not (P_PlayerInPain(nuko.player)) //not hurt are you?
			if nuko.player.bouncenumber == 0 //if he hasnt bounced yet
			and nuko.player.justchangedbouncenumber == 0 //if he hasnt left the ground yet
				nuko.player.justchangedbouncenumber = 1 //now he has!
				--nuko.player.bouncenumber = 1 //Set this to one!
				nuko.player.pflags = $1|PF_JUMPED //forcing the player into a jumping state.
				P_SetObjectMomZ(nuko, 12*FRACUNIT)
				if not (nuko.player.panim == PA_ROLL) //checking if the players animation is it's spinning anim.
					nuko.state = S_PLAY_ROLL //force the player into a spinning state.
				end
			end
			if nuko.player.bouncenumber == 1 //if it's currently on his first bounce
			and nuko.player.justchangedbouncenumber == 0 //if he hasnt left the ground yet
			and not (P_PlayerInPain(nuko.player)) //not hurt are you?
				nuko.player.justchangedbouncenumber = 1 //now he has!
				nuko.player.bouncenumber = 2 //set this to two!
				nuko.player.pflags = $1|PF_JUMPED //forcing the player into a jumping state.
				P_SetObjectMomZ(nuko, 13*FRACUNIT)
				if not (nuko.player.panim == PA_ROLL) //checking if the players animation is it's spinning anim.
					nuko.state = S_PLAY_ROLL //force the player into a spinning state.
				end
			end
			if nuko.player.bouncenumber == 2 //if it's currently on his second bounce
			and nuko.player.justchangedbouncenumber == 0 //if he hasnt left the ground yet
			and not (P_PlayerInPain(nuko.player)) //not hurt are you?
				nuko.player.justchangedbouncenumber = 1 //now he has!
				nuko.player.bouncenumber = 0 //set it back to zero
				nuko.state = S_PLAY_SPRING //change to spring frame, like is SLW!
				P_SetObjectMomZ(nuko, 15*FRACUNIT) //send the player upwards
				nuko.player.pflags = $1 & ~PF_JUMPED // No longer jumping. Don't land on an enemy!
			end
			nuko.player.bounceattack = 0 //set it back to zero.
			nuko.player.usedown = 1 //set it to one.
			nuko.player.pflags = $1 & ~PF_THOKKED //uncheck the thokked flag, allowing you to bounce again.
			S_StartSound(nuko, sfx_s3k77) //play a sound c:			
			
		end
		//some quick checks
		
		if nuko.player.bounceattack == 1 //checking our variable.
		and nuko.health //and you're alive
		and not (P_PlayerInPain(nuko.player)) //not hurt are you?
			P_SpawnThokMobj(nuko.player) //spawn the players thok object
			if not (nuko.player.panim == PA_ROLL) //checking if the players animation is it's spinning anim.
				nuko.state = S_PLAY_ROLL //force the player into a spinning state.
			end
			if (nuko.momz > (9000*P_MobjFlip(nuko))) // the player is going up...?  
				P_SetObjectMomZ(nuko, FixedMul(-35*FRACUNIT, nuko.scale)) //not anymore >.>
			end
		else 
			nuko.player.bounceattack = 0 //set it to 0
		end
		if nuko.player.bounceattack == 1 //checking if hes bouncing
			nuko.player.pflags = $1 & ~PF_SPINNING // you're no longer "spinning" if you were before
		end
		if not (nuko.player.pflags & PF_JUMPED) // if you are not actuallly jumping
			nuko.player.bounceattack = 0 //set this back to zero to be safe
		end
		
		if nuko.eflags & MFE_GOOWATER //is the player in THZ goop?
		or nuko.player.powers[pw_carry] //is the player being carried?
		//or nuko.player.pflags & PF_ROPEHANG //is the player on a ACZ ropehang?
			nuko.player.bounceattack = 0 //set to zero!
		end
		if not (nuko.player.pflags & PF_JUMPED) //if the player hasnt jumped
			nuko.player.bounceattack = 0 //set this to zero
		end
	end
end, MT_PLAYER)