Nico-s Nextbots Script < ESSENTIAL ⚡ >
-- Play the scream (both server & client) self:EmitSound(CONFIG.ScreamSound, 85, 100, 1, CHAN_AUTO)
ENT.Base = "base_nextbot" ENT.Type = "nextbot"
-- ----------------------------------------------------------------- -- Optional: footstep sounds – makes the bot feel more alive -- ----------------------------------------------------------------- function ENT:FootStepSound() self:EmitSound(CONFIG.FootstepSound, 70, 100, 0.5, CHAN_AUTO) end
-- ----------------------------------------------------------------- -- Core AI loop – runs every tick on the server -- ----------------------------------------------------------------- function ENT:RunBehaviour() while true do -- 1️⃣ Acquire / validate target if not IsValid(self.CurrentTarget) or not self.CurrentTarget:Alive() then self.CurrentTarget = self:FindClosestPlayer() end Nico-s Nextbots Script
-- 4️⃣ Attack if close enough and cooldown elapsed if distToTarget <= CONFIG.AttackDistance ^ 2 and CurTime() > self.NextAttack then self:AttackTarget() self.NextAttack = CurTime() + CONFIG.AttackCooldown end end end
return nearest end
-- ----------------------------------------------------------------- -- Helper: Find the nearest viable player -- ----------------------------------------------------------------- function ENT:FindClosestPlayer() local nearest = nil local nearestDist = CONFIG.ChaseRadius -- Play the scream (both server & client)
-- Internal state self.NextAttack = 0 self.CurrentTarget = nil end
-- ----------------------------------------------------------------- -- Attack routine – plays a scream and damages the player -- ----------------------------------------------------------------- function ENT:AttackTarget() if not IsValid(self.CurrentTarget) then return end
-- Simple damage packet (feel free to replace with a more complex system) local dmg = DamageInfo() dmg:SetAttacker(self) dmg:SetInflictor(self) dmg:SetDamage(30) -- damage per hit dmg:SetDamageType(DMG_SLASH) -- any type you like self.CurrentTarget:TakeDamageInfo(dmg) Nico-s Nextbots Script
local dist = self:GetPos():DistToSqr(ply:GetPos()) if dist < nearestDist ^ 2 then nearest = ply nearestDist = math.sqrt(dist) end end
-- Pre‑cache the scream sound to avoid hitches util.PrecacheSound(CONFIG.ScreamSound) util.PrecacheSound(CONFIG.FootstepSound) end
coroutine.yield() end end
if SERVER then self:SetMoveType(MOVETYPE_STEP) self:SetSolid(SOLID_BBOX) self:SetHealth(100)