-- Decompiled with the Synapse X Luau decompiler.

local v1 = script:FindFirstAncestor("MainUI");
local u1 = 0;
local l__LocalPlayer__2 = game.Players.LocalPlayer;
local l__TweenService__3 = game:GetService("TweenService");
return function(p1, p2, p3)
	local v2 = game.ReplicatedStorage.Entities.Screech:Clone();
	local v3 = math.random(-1, 1) * 2;
	if p1.dead then
		return;
	end;
	if v3 < 0 then
		v3 = -1.1;
	end;
	u1 = u1 + 1;
	local l__unit__4 = (p1.finalCamCFrame.LookVector * Vector3.new(-1, 0, -1) + Vector3.new(0, v3, 0)).unit;
	local l__p__5 = p1.finalCamCFrame.p;
	v2:SetPrimaryPartCFrame(CFrame.new(l__p__5 + l__unit__4 * 4, l__p__5) * CFrame.new(0, 0.5, 0));
	v2.Parent = p1.cam;
	local v6 = {};
	for v7, v8 in pairs(v2.Animations:GetChildren()) do
		if v8:IsA("Animation") then
			v6[v8.Name] = v2.AnimationController:LoadAnimation(v8);
		end;
	end;
	local v9 = tick();
	v6.Idle:Play();
	delay(math.random(1, 5) / 6, function()
		if v2:FindFirstChild("Root") then
			v2.Root.Sound:Play();
		end;
	end);
	local v10 = tick();
	local l__RunService__11 = game:GetService("RunService");
	local u4 = false;
	local u5 = v2.PrimaryPart.CFrame;
	local u6 = true;
	local l__PointLight__7 = v2.Base.Attachment.PointLight;
	local u8 = 0;
	local l__Humanoid__9 = l__LocalPlayer__2.Character.Humanoid;
	local u10 = false;
	local l__PrimaryPart__11 = l__LocalPlayer__2.Character.PrimaryPart;
	local u12 = false;
	local u13 = 6.5 + math.random(1, 10) / 5;
	local v12 = l__RunService__11:BindToRenderStep("screechStuff" .. u1, 100, function(p4)
		if not u4 then
			v2.PrimaryPart.CFrame = u5;
		else
			game:GetService("RunService"):UnbindFromRenderStep("screechStuff" .. u1);
		end;
		if u6 then
			local v13 = (p1.finalCamCFrame.LookVector.unit - l__unit__4).Magnitude * 100;
			l__PointLight__7.Brightness = math.clamp(50 - v13, 0, 50) / 50;
			if v13 < 35 then
				u8 = u8 + p4;
			end;
			if u8 >= 0.1 or l__Humanoid__9.Parent:GetAttribute("Hiding") then
				u10 = true;
			end;
			if not (not game.ReplicatedStorage.GameData.EntityDisableScreech.Value) or not (not l__PrimaryPart__11.Anchored) or l__Humanoid__9.Health < 1 then
				u12 = true;
				u10 = false;
				u13 = 0;
			end;
		end;
	end);
	p1.camShaker:ShakeOnce(0.5, 12, 3, 1);
	for v14 = 1, 1000000 do
		task.wait();
		local l__p__15 = p1.finalCamCFrame.p;
		u5 = CFrame.new(l__p__15 + l__unit__4 * 3.5, l__p__15) * CFrame.new(0, 0.5, 0);
		if v10 + u13 < tick() then
			break;
		end;
		if u10 then
			break;
		end;
	end;
	local v16 = tick();
	local l__CFrame__17 = v2.PrimaryPart.CFrame;
	if u12 or (not (not p1.tool) and p1.tool.Name == "Crucifix" and u10 == false or l__Humanoid__9.Health < 1) then
		local v18, v19, v20 = CFrame.new(Vector3.new(0, 0, 0), l__unit__4):ToOrientation();
		p1.ax_t = math.deg(v19);
		p1.ay_t = math.deg(v18);
		wait(0.2);
		game.ReplicatedStorage.EntityInfo.Screech:FireServer(false);
	else
		game.ReplicatedStorage.EntityInfo.Screech:FireServer(u10);
		if u10 then
			v6.Caught:Play();
			script.Caught:Play();
			p1.camShaker:ShakeOnce(6, 42, 0, 1);
		else
			v6.Attack:Play();
			script.Attack:Play();
			p1.camShaker:ShakeOnce(8, 42, 0, 1);
		end;
		v2.Root.Sound:Stop();
		l__PointLight__7.Brightness = 1;
		local v21, v22, v23 = CFrame.new(Vector3.new(0, 0, 0), l__unit__4):ToOrientation();
		u6 = false;
		for v24 = 1, 1000000 do
			task.wait();
			local l__p__25 = p1.finalCamCFrame.p;
			u5 = l__CFrame__17:Lerp(CFrame.new(l__p__25 + l__unit__4 * 3.5, l__p__25) * CFrame.new(0, 0.5, 0), (l__TweenService__3:GetValue((tick() - v16) / 0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In)));
			if v16 + 0.1 < tick() then
				break;
			end;
		end;
		local v26 = tick();
		for v27 = 1, 1000000 do
			task.wait();
			u5 = CFrame.new(p1.finalCamCFrame.Position + p1.finalCamCFrame.LookVector * 3, p1.finalCamCFrame.Position) * CFrame.new(0, 0.5, 0);
			if v26 + 2 < tick() then
				break;
			end;
		end;
	end;
	u4 = true;
	v2:Destroy();
	game:GetService("RunService"):UnbindFromRenderStep("screechStuff" .. u1);
end;