/// Ability: Air Jump
// allow you to preform a extra jump by pressing jump twice

// CUSTOMIZE SECTION START
local skin = "sbag2025" // your character here
local ajheight = -25 // how high you want your double jump to go
local sound = sfx_jump // the sound of the double jump
local circlespawneffect = true // make this true to enable a circle spawn effect
local objectspawned = MT_SPINDUST // if circle spawn is on, this is what should spawn in a circle when you double jump
local objectspeed = 25 // if circle spawn is on, this is how fast the object will go outwards when spawned
local changestate = true // make this true if you want your state to switch to something else
local thestate = S_PLAY_ROLL // the state to change to if changestate is true
// CUSTOMIZE SECTION END PROCCED BELOW IF YOU KNOW WHAT YOUR DOING


addHook("PlayerSpawn", function(player)
    if player.mo and player.mo.skin == skin	
		player.mo.charability = CA_NONE 
	end
end)

addHook("AbilitySpecial", function(player)
    if player.mo and player.mo.skin == skin
	and not (player.pflags & PF_THOKKED)
		player.pflags = $1|PF_THOKKED
		P_SetObjectMomZ(player.mo,ajheight*FRACUNIT)
		S_StartSound(player.mo, sound)
			player.mo.state = S_PLAY_ROLL
			player.pflags = $ |PF_JUMPED
		if circlespawneffect == true
			for i = 1, 16 
				local object = P_SpawnMobjFromMobj(player.mo, 0,0,0,objectspawned)
				object.target = player.mo
				object.fuse = TICRATE
				object.scale = player.mo.scale
				object.destscale = player.mo.scale/8
				P_InstaThrust(object, i*ANGLE_22h, objectspeed*FRACUNIT)
				object.momz = 0
			end
		end
		if changestate == true
			player.mo.state = thestate
		end
		
    end
end)

