//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)

//BATTLEPLUS STUFF FOR SOUND INSANITY ZONE AND PIANO KEY FREESLOT DECLARATIONS

freeslot(
"sfx_pia3", "sfx_pias3", "sfx_pia4", "sfx_pias4", "sfx_pia5", "sfx_pias5", "sfx_pia6", "sfx_pias6", 
"sfx_pib3", "sfx_pib4", "sfx_pib5", "sfx_pib6",
"sfx_pic2", "sfx_pics2", "sfx_pic3", "sfx_pics3", "sfx_pic4", "sfx_pics4", "sfx_pic5", "sfx_pics5",
"sfx_pid2", "sfx_pids2", "sfx_pid3", "sfx_pids3", "sfx_pid4", "sfx_pids4", "sfx_pid5", "sfx_pids5",
"sfx_pie2", "sfx_pie3", "sfx_pie4", "sfx_pie5",
"sfx_pif2", "sfx_pifs2", "sfx_pif3", "sfx_pifs3", "sfx_pif4", "sfx_pifs4", "sfx_pif5", "sfx_pifs5",
"sfx_pig2", "sfx_pigs2", "sfx_pig3", "sfx_pigs3", "sfx_pig4", "sfx_pigs4", "sfx_pig5", "sfx_pigs5"
)

if not r_l then rawset(_G, "r_l", {}) end
if not e_l then rawset(_G, "e_l", {}) end

r_l[871] = {
{65344, 192, 384},
{65472, 192, 384},
{65344, 64, 384},
{65472, 64, 384},
{64, 192, 256},
{192, 192, 256},
{64, 64, 256},
{192, 64, 256},
{64, 65472, 0},
{192, 65472, 0},
{64, 65344, 0},
{192, 65344, 0},
{65344, 65472, 128},
{65472, 65472, 128},
{65344, 65344, 128},
{65472, 65344, 128},
{2560, 65088, 512},
{3328, 64960, 416},
{3200, 64960, 432},
{2944, 65088, 464},
{2816, 65088, 480},
{3072, 64960, 448},
{2944, 64960, 464},
{2688, 65088, 496},
{2432, 64960, 528},
{1920, 65088, 592},
{1792, 65088, 608},
{2304, 64960, 544},
{2176, 64960, 560},
{2176, 65088, 560},
{2048, 65088, 576},
{2560, 64960, 512},
{2176, 65088, 560},
{62976, 576, 512},
{63744, 448, 608},
{63616, 448, 592},
{63360, 576, 560},
{63232, 576, 544},
{63488, 448, 576},
{63360, 448, 560},
{63104, 576, 528},
{62848, 448, 496},
{62336, 576, 432},
{62208, 576, 416},
{62720, 448, 480},
{62592, 448, 464},
{62592, 576, 464},
{62464, 576, 448},
{62976, 448, 512},
{62592, 576, 464},
{60608, 65216, 384},
{60480, 65216, 384},
{60864, 65216, 384},
{60736, 65216, 384},
{60864, 65216, 384},
{60608, 64320, 384},
{60480, 64320, 384},
{60864, 64320, 384},
{60736, 64320, 384},
{60864, 64320, 384},
{61120, 64832, 384},
{61120, 64960, 384},
{61120, 64576, 384},
{61120, 64704, 384},
{61120, 64576, 384},
{60224, 64832, 384},
{60224, 64960, 384},
{60224, 64576, 384},
{60224, 64704, 384},
{60224, 64576, 384},
{4800, 1248, 384},
{4672, 1248, 384},
{5056, 1248, 384},
{4928, 1248, 384},
{5056, 1248, 384},
{4800, 336, 384},
{4672, 336, 384},
{5056, 336, 384},
{4928, 336, 384},
{5056, 336, 384},
{5312, 816, 384},
{5312, 944, 384},
{5312, 560, 384},
{5312, 688, 384},
{5312, 560, 384},
{4416, 816, 384},
{4416, 944, 384},
{4416, 560, 384},
{4416, 688, 384},
{4416, 560, 384},
{64448, 64496, 0},
{64448, 63866, 0},
{64448, 63236, 0},
{64448, 62543, 0},
{1088, 64496, 0},
{1088, 63866, 0},
{1088, 63236, 0},
{1088, 62528, 0},
{0, 64496, 0},
{0, 63866, 0},
{0, 63236, 0},
{0, 62606, 0},
{0, 2930, 0},
{0, 2300, 0},
{0, 1670, 0},
{0, 1040, 0},
{1088, 3008, 0},
{1088, 2300, 0},
{1088, 1670, 0},
{1088, 1040, 0},
{64448, 3008, 0},
{64448, 2300, 0},
{64448, 1670, 0},
{64448, 1040, 0},
{63936, 4352, 128},
{64320, 4288, 59},
{64064, 3904, 51},
{64576, 4672, 56},
{64768, 4992, 70},
{65088, 5248, 64},
{65408, 5504, 73},
{256, 5632, 62},
{640, 5760, 65},
{1024, 5824, 66},
{1472, 5824, 67},
{1856, 5760, 65},
{2240, 5632, 62},
{2624, 5440, 60},
{2944, 5184, 53},
{3264, 4928, 60},
{3520, 4672, 70},
{3776, 4288, 74},
{4000, 3968, 49},
{1600, 61184, 128},
{1216, 61248, 59},
{1472, 61632, 51},
{960, 60864, 56},
{768, 60544, 70},
{448, 60288, 64},
{128, 60032, 73},
{65280, 59904, 62},
{64896, 59776, 65},
{64512, 59712, 66},
{64064, 59712, 67},
{63680, 59776, 65},
{63296, 59904, 62},
{62912, 60096, 60},
{62592, 60352, 53},
{62272, 60608, 60},
{62016, 60864, 70},
{61760, 61248, 74},
{61536, 61568, 49}
}

e_l[97] = {
{62368, 61664, 0},
{63136, 60576, 0},
{63648, 61408, 0},
{64096, 60896, 0},
{64800, 61344, 0},
{160, 60768, 0},
{65248, 61792, 0},
{672, 61600, 0},
{64416, 64352, 0},
{64480, 64352, 0},
{1120, 64352, 0},
{1056, 64352, 0},
{1120, 1184, 0},
{1056, 1184, 0},
{64416, 1184, 0},
{64480, 1184, 0},
{65408, 128, 253},
{128, 128, 256},
{128, 65408, 0},
{65408, 65408, 117},
{60672, 65216, 384},
{60224, 64768, 384},
{61120, 64768, 384},
{60672, 64320, 384},
{4864, 1248, 384},
{4416, 768, 384},
{5312, 768, 384},
{4864, 336, 384}
}