//Lua for spring sound suppression and replacement with bouncy sound
//Credit for the code goes to Chaobrother and Callmore. Thank you so much for the help!

//Declaration of the sound effect

freeslot(
"sfx_candy"
)

//Main function - sound suppressor
addHook("MobjThinker", function(mo)
    --Prevents leakage to other maps.
   if gamemap == 867 
   -- Compare sector effects. 1 is non speed capped, 3 is.
    then if P_PlayerTouchingSectorSpecial(mo.player,3,1) or P_PlayerTouchingSectorSpecial(mo.player,3,3)
    S_StopSoundByID(mo,sfx_kc2f)
	
	else return end
	
	//Attempt at playing sound anywhere in sector, would work without triggers but it's faulty
	 //if not S_IdPlaying(sfx_ghit)
       // S_StartSound(mo, sfx_ghit)
    //end
	
	
    end
  end
, MT_PLAYER)

addHook("ThinkFrame", function ()
if gamemap == 867 
then for p in players.iterate
		if P_PlayerTouchingSectorSpecial(p,3,1) or P_PlayerTouchingSectorSpecial(p,3,3)
		S_StopSoundByID(p.mo,sfx_kc2f)
		end
end
end
end)