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

local Settings = script.Parent.ACS_Modulo:WaitForChild("Config")
local Weapon = script.Parent:FindFirstChildOfClass("Tool")
local WeaponData = require(Weapon:WaitForChild("ACS_Settings"))

local ACS_Storage = workspace:WaitForChild("ACS_WorkSpace")

local Modules = Engine:WaitForChild("Modules")

local Hitmarker = require(Modules:WaitForChild("Hitmarker"))
local Ragdoll = require(Modules: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
task.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

task.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.HitEffect:FireAllClients(nil, Position, HitPart, Normal, Material, WeaponData)
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) * WeaponData.DamageFallOf
	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 WeaponData.BulletPenetration < Helmetfactor.Value then
				damage = Traveleddamage * (WeaponData.BulletPenetration / Helmetfactor.Value)
				HelmetDamage = (Traveleddamage * ((100 - WeaponData.BulletPenetration) / Helmetfactor.Value))

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

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

				if VestDamage <= 0 then
					VestDamage = 0.5
				end
			elseif Vest.Value > 0 and WeaponData.BulletPenetration >= Vestfactor.Value then
				damage = Traveleddamage
				VestDamage = (Traveleddamage * ((100 - WeaponData.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()
		task.wait(3) -- How long the Enemy reloads
		ammo = Settings.Ammo.Value
		if w then
			w = 0.14
		end
		r = false
	elseif boo then
		task.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
