freeslot("MT_FIREFLOWERBOOST","SPR2_GRND","S_PLAY_FIRESURF","S_PLAY_SHELLING","S_PLAY_SHELLING2","S_PLAY_SHELLING3","S_PLAY_SHELLING4","S_PLAY_SHELLING5","sfx_flthr")

states[S_PLAY_FIRESURF] = {
	sprite = SPR_PLAY,
	frame = FF_ANIMATE|SPR2_GRND,
	tics = -1,
	var1 = 5,
	var2 = 2,
	nextstate = S_PLAY_STND
} 
addHook("PlayerThink",function(player,mo)

local play = player.mo


   if not mapheaderinfo[gamemap].fireflowerspecial then return end
    if not (player.powers[pw_shield] & SH_FIREFLOWER) then return end
	
	if player.canfireblast == nil
	 then player.canfireblast = 0
	  end
	  
	  if player.canfiresurfjump == nil
		 then player.canfiresurfjump = 0
		  end
	  
	  if P_IsObjectOnGround(play)
	   then player.canfireblast = 0
	     player.canfiresurfjump = 0
		 player.firesurfcomfort = 0
	    end
		
		if player.firesurfjumppress == nil
		 then player.firesurfjumppress = 0
		  end
		  
		  if (player.cmd.buttons & BT_JUMP)
		  then player.firesurfjumppress = $ + 1
		    else player.firesurfjumppress = 0
			 end
			 
			 if (player.cmd.buttons & BT_ATTACK) and player.canfireblast > 1
		  then player.firesurfsoundpress = $ + 1
		    else player.firesurfsoundpress = 0
			 end
		  
		
		
	   if player.firesurfcomfort == nil
	    then player.firesurfcomfort = 0
		end
		
	 if player.firesurfcomfort > 1
	   then player.firesurfcomfort = $ - 1
	    end

if (player.cmd.buttons & BT_ATTACK) and not P_IsObjectOnGround(play)
 and player.canfireblast <= 96 and player.firesurfcomfort <= 1 and
 player.mo.state ~= S_PLAY_SHELLING and player.powers[pw_carry] ~= CR_GRINDRAIL
 
 then player.canfireblast = $ + 1
  P_SpawnMobjFromMobj(player.mo, 0, 0, -40*FU, MT_FIREFLOWEREFFECT)
     P_SetObjectMomZ(play, -1*FU, false)
	 P_Thrust(player.mo, player.mo.angle, 1*FU)
	 player.pflags = $1 & ~PF_JUMPED
	 player.pflags = $1 & ~PF_SPINNING
	  player.mo.state = S_PLAY_FIRESURF
	
	end
	
	if player.canfireblast >= 1 and (player.cmd.buttons & BT_ATTACK)
	   and (player.cmd.buttons & BT_JUMP) and player.canfiresurfjump == 0
	   and player.firesurfjumppress <= 1
	  
	   
	   then P_SetObjectMomZ(play, 5*FU, false)
	     player.canfiresurfjump = 1
		 player.firesurfcomfort = 33
		 player.pflags = $|PF_JUMPED
		 player.mo.state = S_PLAY_SHELLING2
		 P_SpawnMobjFromMobj(player.mo, 0, 0, -40*FU, MT_FIREFLOWERBOOST)
		 P_SetObjectMomZ(play, 20*FU, false)
		 end
		 
		 if not P_IsObjectOnGround(play) and player.mo.state == S_PLAY_FIRESURF
		  and not (player.cmd.buttons & BT_ATTACK)
		   
		   then player.mo.state = S_PLAY_SHELLING2
		    end
			
			
			
			if (player.cmd.buttons & BT_ATTACK) and not P_IsObjectOnGround(play)
                 and player.canfireblast <= 96 and player.firesurfcomfort <= 1 and
                   player.mo.state ~= S_PLAY_SHELLING and player.firesurfsoundpress <= 1
				   
				   then S_StartSound(player.mo, sfx_flthr, 1)
				    end
					
					if (player.cmd.buttons & BT_SPIN) and player.powers[pw_carry] == CR_GRINDRAIL
					
					then 
					     
					      player.mo.GSgrind.railspeed = 80*FU*GS_RAILS.GrindFlip(player.mo, player.mo.GSgrind.myrail, true)
					     P_SpawnMobjFromMobj(player.mo, 0, 0, -40*FU, MT_FIREFLOWEREFFECT)
						 
					 end
					 
					 if player.powers[pw_super] then 
					 player.canfiresurfjump = 0
					 player.canfireblast = 0
					  end
					  
					if player.powers[pw_justsprung] then 
					 player.canfiresurfjump = 0
					 player.canfireblast = 0
					  end
					  
					 
	end)

addHook("PlayerThink",function(player,mo)

local play = player.mo

 if not (player.powers[pw_shield] & SH_FIREFLOWER) then return end
   if not mapheaderinfo[gamemap].fireflowerspecial then return end
	 
player.fireshield = (player.pflags & PF_JUMPED) and $ or false
if (player.pflags & PF_JUMPED)
    local ring = P_SpawnMobjFromMobj(player.mo, 0, 0, 0, MT_FIREFLOWEREFFECT)
	
	end
	end)
	
addHook("PlayerThink",function(player,mo)

local play = player.mo
	
if not (player.powers[pw_shield] & SH_FIREFLOWER) then return end
   if not mapheaderinfo[gamemap].fireflowerspecial then return end
    if not (player.pflags & PF_JUMPED) then return end
	 
player.firebounce = (player.pflags & PF_SPINDOWN) and (player.mo.eflags & MFE_JUSTHITFLOOR) and $ or false
if (player.pflags & PF_SPINDOWN) and (player.mo.eflags & MFE_JUSTHITFLOOR)
    local ring = P_SpawnMobjFromMobj(player.mo, 0, 0, 0, MT_FIREFLOWEREFFECTMULTISHOT)
	local ring = P_SpawnMobjFromMobj(player.mo, 0, 0, 0, MT_FIREFLOWERJUSTBOUNCED)
	local ring = P_Earthquake(player.mo, player.mo, 800*FRACUNIT)
	


end
end)

addHook("PlayerThink",function(player,mo)

local play = player.mo


 if not (player.powers[pw_shield] & SH_FIREFLOWER) then return end
   if not mapheaderinfo[gamemap].fireflowerspecial then return end
   if (player.pflags & PF_STARTDASH) then return end
	 
player.firespin = (player.pflags & PF_SPINNING) and $ or false
if (player.pflags & PF_SPINNING)
    local ring = P_SpawnMobjFromMobj(player.mo, 0, 0, 0, MT_FIREFLOWEREFFECT)
	local ring = P_SpawnMobjFromMobj(player.mo, 0, 0, 0, MT_FIREFLOWEREFFECTTHROWER)
	

end
end)

addHook("PlayerThink",function(player,mo)

local play = player.mo


 if not (player.powers[pw_shield] & SH_FIREFLOWER) then return end
   if not mapheaderinfo[gamemap].fireflowerspecial then return end
   if not (player.pflags & PF_STARTDASH) then return end
	 
player.firecharge = (player.pflags & PF_STARTDASH) and $ or false
if (player.pflags & PF_STARTDASH)
    local ring =  P_SpawnPlayerMissile(player.mo, MT_FIREFLOWEREFFECT2)
	local ring =  P_SpawnPlayerMissile(player.mo, MT_FIREFLOWEREFFECT3)

end
end)