-- Decompiled with the Synapse X Luau decompiler.

local v1 = {
	Died = 0, 
	Running = 1, 
	Swimming = 2, 
	Climbing = 3, 
	Jumping = 4, 
	GettingUp = 5, 
	FreeFalling = 6, 
	FallingDown = 7, 
	Landing = 8, 
	Splash = 9
};
local v2 = nil;
local v3 = {};
local l__ReplicatedStorage__4 = game:GetService("ReplicatedStorage");
local v5 = l__ReplicatedStorage__4:FindFirstChild("DefaultSoundEvents");
local v6 = UserSettings():IsUserFeatureEnabled("UserUseSoundDispatcher");
if v6 then
	if not v5 then
		v5 = Instance.new("Folder", l__ReplicatedStorage__4);
		v5.Name = "DefaultSoundEvents";
		v5.Archivable = false;
	end;
	local v7 = v5:FindFirstChild("RemoveCharacterEvent");
	if v7 == nil then
		v7 = Instance.new("RemoteEvent", v5);
		v7.Name = "RemoveCharacterEvent";
	end;
	local v8 = v5:FindFirstChild("AddCharacterLoadedEvent");
	if v8 == nil then
		v8 = Instance.new("RemoteEvent", v5);
		v8.Name = "AddCharacterLoadedEvent";
	end;
	v8:FireServer();
	game.Players.LocalPlayer.CharacterRemoving:connect(function(p1)
		v7:FireServer(game.Players.LocalPlayer);
	end);
end;
local l__Parent__9 = script.Parent.Parent;
local l__Head__10 = l__Parent__9:WaitForChild("Head");
while not v2 do
	for v11, v12 in pairs(l__Parent__9:GetChildren()) do
		if v12:IsA("Humanoid") then
			v2 = v12;
			break;
		end;
	end;
	if v2 then
		break;
	end;
	l__Parent__9.ChildAdded:wait();
end;
v3[v1.Died] = l__Head__10:WaitForChild("Died");
v3[v1.Running] = l__Head__10:WaitForChild("Running");
v3[v1.Swimming] = l__Head__10:WaitForChild("Swimming");
v3[v1.Climbing] = l__Head__10:WaitForChild("Climbing");
v3[v1.Jumping] = l__Head__10:WaitForChild("Jumping");
v3[v1.GettingUp] = l__Head__10:WaitForChild("GettingUp");
v3[v1.FreeFalling] = l__Head__10:WaitForChild("FreeFalling");
v3[v1.Landing] = l__Head__10:WaitForChild("Landing");
v3[v1.Splash] = l__Head__10:WaitForChild("Splash");
if v6 then
	local v13 = v5:FindFirstChild("DefaultServerSoundEvent");
else
	v13 = game:GetService("ReplicatedStorage"):FindFirstChild("DefaultServerSoundEvent");
end;
if v13 then
	v13.OnClientEvent:connect(function(p2, p3, p4)
		if p4 and p2.TimePosition ~= 0 then
			p2.TimePosition = 0;
		end;
		if p2.IsPlaying ~= p3 then
			p2.Playing = p3;
		end;
	end);
end;
local l__SoundService__1 = game:GetService("SoundService");
local v14 = {
	YForLineGivenXAndTwoPts = function(p5, p6, p7, p8, p9)
		local v15 = (p7 - p9) / (p6 - p8);
		return v15 * p5 + (p7 - v15 * p6);
	end, 
	Clamp = function(p10, p11, p12)
		return math.min(p12, math.max(p11, p10));
	end, 
	HorizontalSpeed = function(p13)
		return (p13.Velocity + Vector3.new(0, -p13.Velocity.Y, 0)).magnitude;
	end, 
	VerticalSpeed = function(p14)
		return math.abs(p14.Velocity.Y);
	end
};
local function u2()
	return game.Workspace.FilteringEnabled and l__SoundService__1.RespectFilteringEnabled;
end;
function v14.Play(p15)
	if u2() then
		p15.CharacterSoundEvent:FireServer(true, true);
	end;
	if p15.TimePosition ~= 0 then
		p15.TimePosition = 0;
	end;
	if not p15.IsPlaying then
		p15.Playing = true;
	end;
end;
function v14.Pause(p16)
	if u2() then
		p16.CharacterSoundEvent:FireServer(false, false);
	end;
	if p16.IsPlaying then
		p16.Playing = false;
	end;
end;
function v14.Resume(p17)
	if u2() then
		p17.CharacterSoundEvent:FireServer(true, false);
	end;
	if not p17.IsPlaying then
		p17.Playing = true;
	end;
end;
function v14.Stop(p18)
	if u2() then
		p18.CharacterSoundEvent:FireServer(false, true);
	end;
	if p18.IsPlaying then
		p18.Playing = false;
	end;
	if p18.TimePosition ~= 0 then
		p18.TimePosition = 0;
	end;
end;
local u3 = {};
function setSoundInPlayingLoopedSounds(p19)
	local v16 = #u3;
	local v17 = 1 - 1;
	while true do
		if u3[v17] == p19 then
			return;
		end;
		if 0 <= 1 then
			if v17 < v16 then

			else
				break;
			end;
		elseif v16 < v17 then

		else
			break;
		end;
		v17 = v17 + 1;	
	end;
	table.insert(u3, p19);
end;
function stopPlayingLoopedSoundsExcept(p20)
	local v18 = #u3 - -1;
	while true do
		if u3[v18] ~= p20 then
			v14.Pause(u3[v18]);
			table.remove(u3, v18);
		end;
		if 0 <= -1 then
			if v18 < 1 then

			else
				break;
			end;
		elseif 1 < v18 then

		else
			break;
		end;
		v18 = v18 + -1;	
	end;
end;
local v19 = {};
v19[Enum.HumanoidStateType.Dead] = function()
	stopPlayingLoopedSoundsExcept();
	v14.Play(v3[v1.Died]);
end;
v19[Enum.HumanoidStateType.RunningNoPhysics] = function(p21)
	stateUpdated(Enum.HumanoidStateType.Running, p21);
end;
local u4 = UserSettings():IsUserFeatureEnabled("UserFixCharacterSoundIssues");
local u5 = nil;
local u6 = 0;
v19[Enum.HumanoidStateType.Running] = function(p22)
	local v20 = v3[v1.Running];
	stopPlayingLoopedSoundsExcept(v20);
	if u4 and u5 == Enum.HumanoidStateType.Freefall and u6 > 0.1 then
		local v21 = v3[v1.FreeFalling];
		v21.Volume = math.min(1, math.max(0, (u6 - 50) / 110));
		v14.Play(v21);
		u6 = 0;
	end;
	if u4 then
		if p22 ~= nil and p22 > 0.5 then
			v14.Resume(v20);
			setSoundInPlayingLoopedSounds(v20);
			return;
		elseif p22 ~= nil then
			stopPlayingLoopedSoundsExcept();
			return;
		else
			return;
		end;
	elseif not (v14.HorizontalSpeed(l__Head__10) > 0.5) then
		stopPlayingLoopedSoundsExcept();
		return;
	end;
	v14.Resume(v20);
	setSoundInPlayingLoopedSounds(v20);
end;
v19[Enum.HumanoidStateType.Swimming] = function(p23)
	if u4 then
		local v22 = p23;
	else
		v22 = v14.VerticalSpeed(l__Head__10);
	end;
	if u5 ~= Enum.HumanoidStateType.Swimming and v22 > 0.1 then
		local v23 = v3[v1.Splash];
		v23.Volume = v14.Clamp(v14.YForLineGivenXAndTwoPts(v14.VerticalSpeed(l__Head__10), 100, 0.28, 350, 1), 0, 1);
		v14.Play(v23);
	end;
	local v24 = v3[v1.Swimming];
	stopPlayingLoopedSoundsExcept(v24);
	v14.Resume(v24);
	setSoundInPlayingLoopedSounds(v24);
end;
v19[Enum.HumanoidStateType.Climbing] = function(p24)
	local v25 = v3[v1.Climbing];
	if u4 then
		if p24 ~= nil and math.abs(p24) > 0.1 then
			v14.Resume(v25);
			stopPlayingLoopedSoundsExcept(v25);
		else
			v14.Pause(v25);
			stopPlayingLoopedSoundsExcept(v25);
		end;
	elseif v14.VerticalSpeed(l__Head__10) > 0.1 then
		v14.Resume(v25);
		stopPlayingLoopedSoundsExcept(v25);
	else
		stopPlayingLoopedSoundsExcept();
	end;
	setSoundInPlayingLoopedSounds(v25);
end;
v19[Enum.HumanoidStateType.Jumping] = function()
	if u5 == Enum.HumanoidStateType.Jumping then
		return;
	end;
	stopPlayingLoopedSoundsExcept();
	v14.Play(v3[v1.Jumping]);
end;
v19[Enum.HumanoidStateType.GettingUp] = function()
	stopPlayingLoopedSoundsExcept();
	v14.Play(v3[v1.GettingUp]);
end;
v19[Enum.HumanoidStateType.Freefall] = function()
	if u5 == Enum.HumanoidStateType.Freefall then
		return;
	end;
	v3[v1.FreeFalling].Volume = 0;
	stopPlayingLoopedSoundsExcept();
	u6 = math.max(u6, math.abs(l__Head__10.Velocity.y));
end;
v19[Enum.HumanoidStateType.FallingDown] = function()
	stopPlayingLoopedSoundsExcept();
end;
v19[Enum.HumanoidStateType.Landed] = function()
	stopPlayingLoopedSoundsExcept();
	if v14.VerticalSpeed(l__Head__10) > 75 then
		local v26 = v3[v1.Landing];
		v26.Volume = v14.Clamp(v14.YForLineGivenXAndTwoPts(v14.VerticalSpeed(l__Head__10), 50, 0, 100, 1), 0, 1);
		v14.Play(v26);
	end;
end;
v19[Enum.HumanoidStateType.Seated] = function()
	stopPlayingLoopedSoundsExcept();
end;
function stateUpdated(p25, p26)
	if v19[p25] ~= nil then
		if u4 then
			if p25 ~= Enum.HumanoidStateType.Running then
				if p25 ~= Enum.HumanoidStateType.Climbing then
					if p25 ~= Enum.HumanoidStateType.Swimming then
						if p25 == Enum.HumanoidStateType.RunningNoPhysics then
							v19[p25](p26);
						else
							v19[p25]();
						end;
					else
						v19[p25](p26);
					end;
				else
					v19[p25](p26);
				end;
			else
				v19[p25](p26);
			end;
		else
			v19[p25]();
		end;
	end;
	u5 = p25;
end;
v2.Died:connect(function()
	stateUpdated(Enum.HumanoidStateType.Dead);
end);
v2.Running:connect(function(p27)
	stateUpdated(Enum.HumanoidStateType.Running, p27);
end);
v2.Swimming:connect(function(p28)
	stateUpdated(Enum.HumanoidStateType.Swimming, p28);
end);
v2.Climbing:connect(function(p29)
	stateUpdated(Enum.HumanoidStateType.Climbing, p29);
end);
v2.Jumping:connect(function()
	stateUpdated(Enum.HumanoidStateType.Jumping);
end);
v2.GettingUp:connect(function()
	stateUpdated(Enum.HumanoidStateType.GettingUp);
end);
v2.FreeFalling:connect(function()
	stateUpdated(Enum.HumanoidStateType.Freefall);
end);
v2.FallingDown:connect(function()
	stateUpdated(Enum.HumanoidStateType.FallingDown);
end);
v2.StateChanged:connect(function(p30, p31)
	stateUpdated(p31);
end);
function onUpdate(p32, p33)
	local v27 = v3[v1.FreeFalling];
	if u5 == Enum.HumanoidStateType.Freefall then
		if l__Head__10.Velocity.Y < 0 then
			if 75 < v14.VerticalSpeed(l__Head__10) then
				v14.Resume(v27);
				v27.Volume = v14.Clamp(v27.Volume + p33 / 1.1 * (p32 / p33), 0, 1);
			else
				v27.Volume = 0;
			end;
		else
			v27.Volume = 0;
		end;
	else
		v14.Pause(v27);
	end;
	if u5 == Enum.HumanoidStateType.Running then
		if v14.HorizontalSpeed(l__Head__10) < 0.5 then
			v14.Pause(v3[v1.Running]);
		end;
	end;
end;
local v28 = tick();
while true do
	onUpdate(tick() - v28, 0.25);
	v28 = tick();
	wait(0.25);
end;