coroutine.yield() end end
if SERVER then self:SetMoveType(MOVETYPE_STEP) self:SetSolid(SOLID_BBOX) self:SetHealth(100)
-- ========================================================= -- BASIC NEXTBOT SETUP -- ========================================================= AddCSLuaFile() -- make the file sent to clients (for the model & sounds)
-- 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
-- ----------------------------------------------------------------- -- Helper: Find the nearest viable player -- ----------------------------------------------------------------- function ENT:FindClosestPlayer() local nearest = nil local nearestDist = CONFIG.ChaseRadius
-- ----------------------------------------------------------------- -- Attack routine – plays a scream and damages the player -- ----------------------------------------------------------------- function ENT:AttackTarget() if not IsValid(self.CurrentTarget) then return end
-- Optional: push the player a little local push = (self.CurrentTarget:GetPos() - self:GetPos()):GetNormalized() * 200 self.CurrentTarget:SetVelocity(push) end coroutine
-- Internal state self.NextAttack = 0 self.CurrentTarget = nil end
-- ----------------------------------------------------------------- -- Cleanup – ensure the entity disappears cleanly -- ----------------------------------------------------------------- function ENT:OnRemove() self:StopMoving() end
ENT.Base = "base_nextbot" ENT.Type = "nextbot" tolerance = CONFIG.AttackDistance
local dist = self:GetPos():DistToSqr(ply:GetPos()) if dist < nearestDist ^ 2 then nearest = ply nearestDist = math.sqrt(dist) end end
if distToTarget > CONFIG.LoseRadius ^ 2 then -- Too far – give up and look for another player self.CurrentTarget = nil coroutine.yield() else -- 3️⃣ Move toward the player self:MoveToPos(self.CurrentTarget:GetPos(), tolerance = CONFIG.AttackDistance, timeout = 10, repath = 1, maxage = 2, goalpos = self.CurrentTarget:GetPos() )