local Q=game.Debris local Y=game.ReplicatedStorage:WaitForChild("\065\067\083\095\069\110\103\105\110\101")local G=Y:WaitForChild("\069\118\101\110\116\111\115")local L=require(Y.ServerConfigs:WaitForChild("\067\111\110\102\105\103"))local H=script.Parent.ACS_Modulo:WaitForChild("\067\111\110\102\105\103")local j=workspace:WaitForChild("\065\067\083\095\087\111\114\107\083\112\097\099\101")local i=Y:WaitForChild("\077\111\100\117\108\111\115")local s=require(i:WaitForChild("\072\105\116\109\097\114\107\101\114"))local q=require(i:WaitForChild("\082\097\103\100\111\108\108"))local d=j:FindFirstChild("\083\101\114\118\101\114")local E=j:FindFirstChild("\067\108\105\101\110\116")local r={d,E;j}local O=false wait(3)script.Parent.ForceField:Destroy()script.Parent.Humanoid.Died:connect(function()q(script.Parent)if script.Parent:FindFirstChild("\071\117\110")~=nil then script.Parent.Gun.CanCollide=true end O=true Q:AddItem(script.Parent,game.Players.RespawnTime)end)local z=false local S=nil function onTouched(Q)if Q.Parent==nil then return end local Y=Q.Parent:findFirstChild("\072\117\109\097\110\111\105\100")if Y==nil then S=Q end end function waitForChild(Q,Y)local G=Q:findFirstChild(Y)if G then return G end while true do G=Q.ChildAdded:wait()if G.Name==Y then return G end end end local D=script.Parent local I=waitForChild(D,"\072\117\109\097\110\111\105\100")local v=waitForChild(D,"\084\111\114\115\111")local t=waitForChild(D,"\076\101\102\116 \076\101\103")local a=waitForChild(D,"\082\105\103\104\116 \076\101\103")t.Touched:connect(onTouched)a.Touched:connect(onTouched)function getHumanoid(Q)for Q,Y in pairs(Q:GetChildren())do if Y:IsA("\072\117\109\097\110\111\105\100")then return Y end end end local F=script.Parent local h=getHumanoid(F)local f=F.Torso local Z=F:FindFirstChild("\072\101\097\100")local T=game:GetService("\080\097\116\104\102\105\110\100\105\110\103\083\101\114\118\105\099\101")local n=game:GetService("\080\108\097\121\101\114\115")local w=Spread/100 local o=0 local m=0 wait(.1)local K=H.Ammo.Value local g=.14 local c=1/(FireRate/60)local X=false local M=script.Parent local k=M:WaitForChild("\071\114\105\112")function Hitmaker(Q,Y,L,H)G.Hit:FireAllClients(nil,Y,Q,L,H,nil)end function CheckForHumanoid(Q)local Y=false local G=nil if Q then if Q.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")or Q.Parent.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")then Y=true if Q.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")then G=Q.Parent.Humanoid elseif Q.Parent.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")then G=Q.Parent.Parent.Humanoid end else Y=false end end return Y,G end function CalcularDano(Q,Y,G,L)local H=0 local j=0 local i=0 local s=Q-(math.ceil(Y)/40)*FallOfDamage if G.Parent:FindFirstChild("\083\097\117\100\101")~=nil then local Q=G.Parent.Saude.Protecao.VestVida local Y=G.Parent.Saude.Protecao.VestProtect local q=G.Parent.Saude.Protecao.HelmetVida local d=G.Parent.Saude.Protecao.HelmetProtect if L=="\072\101\097\100"then if q.Value>0 and BulletPenetration<d.Value then H=s*(BulletPenetration/d.Value)i=s*((100-BulletPenetration)/d.Value)if i<=0 then i=.5 end elseif q.Value>0 and BulletPenetration>=d.Value then H=s i=s*((100-BulletPenetration)/d.Value)if i<=0 then i=1 end elseif q.Value<=0 then H=s end else if Q.Value>0 and BulletPenetration<Y.Value then H=s*(BulletPenetration/Y.Value)j=s*((100-BulletPenetration)/Y.Value)if j<=0 then j=.5 end elseif Q.Value>0 and BulletPenetration>=Y.Value then H=s j=s*((100-BulletPenetration)/Y.Value)if j<=0 then j=1 end elseif Q.Value<=0 then H=s end end else H=s end if H<=0 then H=1 end return H,j,i end function Damage(Q,Y,G,L)if Q.Parent:FindFirstChild("\083\097\117\100\101")~=nil then local Y=Q.Parent.Saude.Protecao.VestVida local H=Q.Parent.Saude.Protecao.HelmetVida Y.Value=Y.Value-G H.Value=H.Value-L end Q:TakeDamage(Y)end local function l(Q)if Q and K~=H.Ammo.Value or K==0 then X=true if g then g=.03 end k.Reload:Play()wait(3)K=H.Ammo.Value if g then g=.14 end X=false elseif Q then wait(.1)end end local function V()if not O then local Q,Y=H.ShotDistance.Value,nil for G,L in ipairs(game.Players:GetPlayers())do if L.Character and(L.Character:FindFirstChild("\072\117\109\097\110\111\105\100")and L:DistanceFromCharacter(k.Position)<Q)then Q,Y=L:DistanceFromCharacter(k.Position),L end end if Y then return Y.Character:GetModelCFrame(),Q,(CFrame.new(Y.Character.Humanoid.WalkToPoint)).lookVector else return nil end end end
---------------------------------------------------------------|
---------------------------------------------------------------|
---------------------------------------------------------------|
local Debris = game.Debris

local Engine = game.ReplicatedStorage:WaitForChild("ACS_Engine")
local Evt = Engine:WaitForChild("Eventos")
local ServerConfig = require(Engine.ServerConfigs:WaitForChild("Config"))

local Settings = script.Parent.ACS_Modulo:WaitForChild("Config")

local ACS_Storage = workspace:WaitForChild("ACS_WorkSpace")

local Modulos = Engine:WaitForChild("Modulos")

local Hitmarker = require(Modulos:WaitForChild("Hitmarker"))
local Ragdoll = require(Modulos:WaitForChild("Ragdoll"))

local Ignore_Model = ACS_Storage:FindFirstChild("Server")

local BulletModel = ACS_Storage:FindFirstChild("Client")

local Ray_Ignore = { Ignore_Model, BulletModel, ACS_Storage }

local Dead = false

wait(3)
script.Parent.ForceField:Destroy()

script.Parent.Humanoid.Died:connect(function()
	Ragdoll(script.Parent)
	if script.Parent:FindFirstChild("Gun") ~= nil then
		script.Parent.Gun.CanCollide = true
	end
	Dead = true
	Debris:AddItem(script.Parent, game.Players.RespawnTime)
end)

local CanSee = false
local CurrentPart = nil

function onTouched(hit)
	if hit.Parent == nil then
		return
	end

	local humanoid = hit.Parent:findFirstChild("Humanoid")

	if humanoid == nil then
		CurrentPart = hit
	end
end

function waitForChild(parent, childName)
	local child = parent:findFirstChild(childName)

	if child then
		return child
	end

	while true do
		--print(childName)

		child = parent.ChildAdded:wait()

		if child.Name == childName then
			return child
		end
	end
end

local Figure = script.Parent
local Humanoid = waitForChild(Figure, "Humanoid")
local Torso = waitForChild(Figure, "Torso")
local Left = waitForChild(Figure, "Left Leg")
local Right = waitForChild(Figure, "Right Leg")

Left.Touched:connect(onTouched)
Right.Touched:connect(onTouched)

function getHumanoid(model)
	for _, v in pairs(model:GetChildren()) do
		if v:IsA("Humanoid") then
			return v
		end
	end
end

local zombie = script.Parent
local human = getHumanoid(zombie)
local hroot = zombie.Torso
local head = zombie:FindFirstChild("Head")

local pfs = game:GetService("PathfindingService")
local players = game:GetService("Players")

local RecoilSpread = Spread / 100
local perception = 0
local Memory = 0

wait(0.1)

local ammo = Settings.Ammo.Value -- How much ammo the Enemy has
local w = 0.14
local RPM = 1 / (FireRate / 60)
local r = false
local t = script.Parent

local h = t:WaitForChild("Grip")

function Hitmaker(HitPart, Position, Normal, Material)
	Evt.Hit:FireAllClients(nil, Position, HitPart, Normal, Material, nil)
end

function CheckForHumanoid(L_225_arg1)
	local L_226_ = false
	local L_227_ = nil
	if L_225_arg1 then
		if L_225_arg1.Parent:FindFirstChild("Humanoid") or L_225_arg1.Parent.Parent:FindFirstChild("Humanoid") then
			L_226_ = true
			if L_225_arg1.Parent:FindFirstChild("Humanoid") then
				L_227_ = L_225_arg1.Parent.Humanoid
			elseif L_225_arg1.Parent.Parent:FindFirstChild("Humanoid") then
				L_227_ = L_225_arg1.Parent.Parent.Humanoid
			end
		else
			L_226_ = false
		end
	end
	return L_226_, L_227_
end

function CalcularDano(DanoBase, Dist, Vitima, Type)
	local damage = 0
	local VestDamage = 0
	local HelmetDamage = 0
	local Traveleddamage = DanoBase - (math.ceil(Dist) / 40) * FallOfDamage
	if Vitima.Parent:FindFirstChild("Saude") ~= nil then
		local Vest = Vitima.Parent.Saude.Protecao.VestVida
		local Vestfactor = Vitima.Parent.Saude.Protecao.VestProtect
		local Helmet = Vitima.Parent.Saude.Protecao.HelmetVida
		local Helmetfactor = Vitima.Parent.Saude.Protecao.HelmetProtect

		if Type == "Head" then
			if Helmet.Value > 0 and BulletPenetration < Helmetfactor.Value then
				damage = Traveleddamage * (BulletPenetration / Helmetfactor.Value)
				HelmetDamage = (Traveleddamage * ((100 - BulletPenetration) / Helmetfactor.Value))

				if HelmetDamage <= 0 then
					HelmetDamage = 0.5
				end
			elseif Helmet.Value > 0 and BulletPenetration >= Helmetfactor.Value then
				damage = Traveleddamage
				HelmetDamage = (Traveleddamage * ((100 - BulletPenetration) / Helmetfactor.Value))

				if HelmetDamage <= 0 then
					HelmetDamage = 1
				end
			elseif Helmet.Value <= 0 then
				damage = Traveleddamage
			end
		else
			if Vest.Value > 0 and BulletPenetration < Vestfactor.Value then
				damage = Traveleddamage * (BulletPenetration / Vestfactor.Value)
				VestDamage = (Traveleddamage * ((100 - BulletPenetration) / Vestfactor.Value))

				if VestDamage <= 0 then
					VestDamage = 0.5
				end
			elseif Vest.Value > 0 and BulletPenetration >= Vestfactor.Value then
				damage = Traveleddamage
				VestDamage = (Traveleddamage * ((100 - BulletPenetration) / Vestfactor.Value))

				if VestDamage <= 0 then
					VestDamage = 1
				end
			elseif Vest.Value <= 0 then
				damage = Traveleddamage
			end
		end
	else
		damage = Traveleddamage
	end
	if damage <= 0 then
		damage = 1
	end

	return damage, VestDamage, HelmetDamage
end

function Damage(VitimaHuman, Dano, DanoColete, DanoCapacete)
	if VitimaHuman.Parent:FindFirstChild("Saude") ~= nil then
		local Colete = VitimaHuman.Parent.Saude.Protecao.VestVida
		local Capacete = VitimaHuman.Parent.Saude.Protecao.HelmetVida
		Colete.Value = Colete.Value - DanoColete
		Capacete.Value = Capacete.Value - DanoCapacete
	end
	VitimaHuman:TakeDamage(Dano)
end

local function reload(boo)
	if (boo and ammo ~= Settings.Ammo.Value) or ammo == 0 then
		r = true
		if w then
			w = 0.03
		end
		h.Reload:Play()
		wait(3) -- How long the Enemy reloads
		ammo = Settings.Ammo.Value
		if w then
			w = 0.14
		end
		r = false
	elseif boo then
		wait(0.1)
	end
end
local function near()
	if not Dead then
		local dis, pl = Settings.ShotDistance.Value, nil -- Range of the Enemy
		for _, v in ipairs(game.Players:GetPlayers()) do
			if v.Character and v.Character:FindFirstChild("Humanoid") and v:DistanceFromCharacter(h.Position) < dis then
				dis, pl = v:DistanceFromCharacter(h.Position), v
			end
		end
		if pl then
			return pl.Character:GetModelCFrame(), dis, CFrame.new(pl.Character.Humanoid.WalkToPoint).lookVector
		else
			return nil
		end
	end
end
