freeslot("MT_UNDERSHIELD","MT_FRONTSHIELD","MT_UNDERSHIELDCOSMETIC")

addHook("PlayerThink",function(player)

if not mapheaderinfo[gamemap].forceshieldstage then return end
 if player.freefallin == 1 then return end
 if not (player.powers[pw_shield] & SH_FORCE) then return end
  
   if player.forceshieldup == nil
    then player.forceshieldup = 0
	 end
	  
	   if player.forceshieldup > 0
	    then player.forceshieldup = $ - 1
		 end
		 
		 if player.forceshieldup == 1
		  then player.mo.momz = 20*FU
		   end
	   
	   if player.forceshieldon == nil
	    then player.forceshieldon = 0
		 end
		  
		 
		 
		 if (player.cmd.buttons & BT_SPIN)
		  then player.forceshieldon = $ + 1
		   else player.forceshieldon = 0
		   end
	   
	   if player.stopforce == nil
	  then player.stopforce = 0
	   end
	    
		if (player.mo.eflags & MFE_ONGROUND) and P_IsObjectOnGround(player.mo)
	     then player.stopforce = 0
	       end
		   
		   if player.powers[pw_carry] == CR_GRINDRAIL
	        then player.stopforce = 0
	           end
		   
		   
	 
	  if (player.cmd.buttons & BT_SPIN) and not P_IsObjectOnGround(player.mo)
	   and player.stopforce < 1 and player.forceshieldon <= 1 and
	   (player.pflags & PF_JUMPED) and (player.cmd.buttons & BT_ATTACK)
	    then P_SpawnMobjFromMobj(player.mo, 0, 0, -2*FU, MT_UNDERSHIELD)
		P_SpawnMobjFromMobj(player.mo, 0, -50*FU, -2*FU, MT_UNDERSHIELD)
		P_SpawnMobjFromMobj(player.mo, -50*FU, 0, -2*FU, MT_UNDERSHIELD)
		P_SpawnMobjFromMobj(player.mo, 0, 50*FU, -2*FU, MT_UNDERSHIELD)
		P_SpawnMobjFromMobj(player.mo, 50*FU, 0, -2*FU, MT_UNDERSHIELD)
		P_SpawnMobjFromMobj(player.mo, 50*FU, 50*FU, -2*FU, MT_UNDERSHIELD)
		
		P_SpawnMobjFromMobj(player.mo, 0, 0, -2*FU, MT_UNDERSHIELDCOSMETIC)
		P_SpawnMobjFromMobj(player.mo, 0, 0, -2*FU, MT_UNDERSHIELDCOSMETIC)
		P_SpawnMobjFromMobj(player.mo, 0, 0, -2*FU, MT_UNDERSHIELDCOSMETIC)
		
		
		S_StartSound(player.mo, sfx_appear, 1)
		     player.stopforce = $ + 1
			 player.forceshieldup = 4
			 
	end
	
	  end)