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