From 096a5bff99727b45f69f4cf0263e4bdd32da8e1a Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sun, 10 Jan 2016 19:54:32 -0500 Subject: Fixed NPC bounding box issue --- entities/entities/ws_npc_ambient/init.lua | 6 +++++- entities/entities/ws_npc_ambient/shared.lua | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'entities') diff --git a/entities/entities/ws_npc_ambient/init.lua b/entities/entities/ws_npc_ambient/init.lua index d169357..1f08884 100644 --- a/entities/entities/ws_npc_ambient/init.lua +++ b/entities/entities/ws_npc_ambient/init.lua @@ -7,11 +7,15 @@ include('shared.lua') function ENT:Initialize() --print("NPC spawned!") --self:SetMoveType(MOVETYPE_STEP) - self:SetSolid(SOLID_VPHYSICS) + self:SetSolid(SOLID_OBB) --self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE) if(self.Model) then self:SetModel(self.Model) else print("NPC created without model, this might be a bug!") end + if(not self.Stats) then + print("NPC created without any stats, this is a bug!") + return + end if(self.Stats["Vitality"]) then self:SetHealth(self.Stats["Vitality"]) print("Helath set to " .. self.Stats["Vitality"]) diff --git a/entities/entities/ws_npc_ambient/shared.lua b/entities/entities/ws_npc_ambient/shared.lua index d41558d..c14de1e 100644 --- a/entities/entities/ws_npc_ambient/shared.lua +++ b/entities/entities/ws_npc_ambient/shared.lua @@ -19,7 +19,7 @@ end function ENT:DefaultBehaviour() while ( true ) do --Main loop for ai - + print("Going into behavior for " .. self.Name) --Update aware enemies local players = ents.FindByClass("Player") for k,v in pairs(players) do @@ -49,6 +49,7 @@ function ENT:DefaultBehaviour() local randanim = math.Round(math.Rand(0,#self.IdleSequences)) self:PlaySequenceAndWait( self.IdleSequences[randanim] ) self:StartActivity( ACT_IDLE ) + print("Acting idle") --If there's noone within 4000 units, just remove ourselves to save server resources local closest = 5000 for k,v in pairs(player.GetAll()) do @@ -57,7 +58,8 @@ function ENT:DefaultBehaviour() closest = thisdist end end - if(closest > 4000) then self:BecomeRagdoll(DamageInfo()) end + if(closest > 4000) then + print("Closes player is " .. closest .. " removeing self...") self:BecomeRagdoll(DamageInfo()) end else --We have a target to attack! -- cgit v1.2.3-70-g09d2