freeslot("S_PLAY_BOWSERBOOST","S_PLAY_CANTBOOST","S_BOWSERSONICDUMMYSTATE","S_SONICSTARFIREBOOSTGO","MT_SONICM1BOOSTAURA","S_SONICM1BOOSTAURA","S_SONICM1BOOSTAURA2","sfx_bsfir","MT_BOWSERCUTSCENECLASHFIREWHITE3","S_BOWSERSONICDUMMYSTATE")
states[S_PLAY_BOWSERBOOST] = {
	sprite = SPR_PLAY,
	frame = SPR2_FRUN,
	tics = 1,
	nextstate = S_PLAY_FLOAT_RUN
}
states[S_PLAY_CANTBOOST] = {
	sprite = SPR_PLAY,
	frame = SPR2_FRUN,
	tics = 1,
	nextstate = S_PLAY_FLOAT_RUN
}

//function made by i.-p!
local function SpawnLoop(mo, int_type, speed, ang, mox)
    if mo and mo.valid
    local tx = FixedMul(mox, cos(ang))
    local ty = FixedMul(mox, sin(ang))
        for i = 0, 7
            local ring = P_SpawnMobjFromMobj(mo, 0,0, mo.height/2, int_type)
            P_SetOrigin(ring, mo.x + tx, mo.y + ty, mo.z + (mo.height/2))
            if i == 0
                P_InstaThrust(ring, mo.angle + ANGLE_90, speed*2)
            elseif i == 1
                P_InstaThrust(ring, mo.angle + ANGLE_90, speed)
                P_SetObjectMomZ(ring, speed/2, false)
            elseif i == 2
                P_SetObjectMomZ(ring, speed/2, false)
            elseif i == 3
                P_InstaThrust(ring, mo.angle - ANGLE_90, speed)
                P_SetObjectMomZ(ring, speed/4, false)
            elseif i == 4
                P_InstaThrust(ring, mo.angle - ANGLE_90, speed*2)
            elseif i == 5
                P_InstaThrust(ring, mo.angle - ANGLE_90, speed)
                P_SetObjectMomZ(ring, (speed*-1)/2, false)
            elseif i == 6
                P_SetObjectMomZ(ring, (speed*-1)/2, false)
            elseif i == 7
                P_InstaThrust(ring, mo.angle + ANGLE_90, speed)
                P_SetObjectMomZ(ring, (speed*-1)/2, false)
                end
            end
        end
    end

addHook("PlayerThink",function(player)
 if not mapheaderinfo[gamemap].bowserfight then return end
 
 if mapheaderinfo[gamemap].bowserfight 
  camera.chase = true
   end
 
 if player.boostcooldown == nil
   then player.boostcooldown = 0
      end
	  
	  if player.boostcooldown >= 1 and player.mo.state ~= S_BOWSERSONICDUMMYSTATE
	   then player.boostcooldown = $1 - 1
	      end
		  
		  if player.mo.state == S_BOWSERSONICDUMMYSTATE
		   then player.boostcooldown = 5*TICRATE
		    end
			
			if player.sonicfireboostsoundcd == nil
             then player.sonicfireboostsoundcd = 0
                end
				
				  if (player.cmd.buttons & BT_ATTACK)
				   player.sonicfireboostsoundcd = $1 + 1
				    else player.sonicfireboostsoundcd = 0
				     end
				 
 
 if (player.cmd.buttons & BT_ATTACK) and player.mo.state ~= S_PLAY_CANTBOOST
  and player.boostcooldown < 1*TICRATE and player.mo.state ~= S_SONICSTARFIREBOOSTGO and player.mo.dialoguethinker ~= true 
	 P_InstaThrust(player.mo,player.mo.angle,230*FRACUNIT)
	 
	 SpawnLoop(player.mo, MT_SONICM1BOOSTAURA, FU * 40,  player.mo.angle, 160* FU)
	
	player.drawangle = camera.angle
	 player.mo.state = S_PLAY_BOWSERBOOST
	 end
	 
	 if player.mo.state == S_PLAY_CANTBOOST
	 P_InstaThrust(player.mo,player.mo.angle + FixedAngle(180*FRACUNIT),5*FRACUNIT)
	 player.drawangle = camera.angle
	 end
	 
	 if (player.cmd.buttons & BT_ATTACK) and player.sonicfireboostsoundcd <= 1
	  and player.boostcooldown < 1*TICRATE
	   S_StartSound(player.mo, sfx_bsfir)
	    end
end)