aboutsummaryrefslogtreecommitdiff
path: root/entities
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-10-24 12:12:19 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-10-24 12:12:19 -0400
commit74c7a160da34897ebdf18aaff02b8c9b65809949 (patch)
treedb2a084d02f4acc3d7c99ec20e573101e448aef6 /entities
parentd7f44fc24da959658b597e64d842661aa41f6515 (diff)
downloadartery-74c7a160da34897ebdf18aaff02b8c9b65809949.tar.gz
artery-74c7a160da34897ebdf18aaff02b8c9b65809949.tar.bz2
artery-74c7a160da34897ebdf18aaff02b8c9b65809949.zip
Various other updates and bugfixes
Diffstat (limited to 'entities')
-rw-r--r--entities/entities/npc_townie/init.lua25
-rw-r--r--entities/entities/npc_townie/shared.lua116
2 files changed, 10 insertions, 131 deletions
diff --git a/entities/entities/npc_townie/init.lua b/entities/entities/npc_townie/init.lua
index 66cfaf1..a444348 100644
--- a/entities/entities/npc_townie/init.lua
+++ b/entities/entities/npc_townie/init.lua
@@ -47,31 +47,6 @@ function ENT:Initialize()
self:SetUseType( SIMPLE_USE )
self.DialogCursors = {}
- --[[
- 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"])
- else print("NPC created with no stat for vitality, this might be a bug!")end
- if(self.Stats["Accel"]) then self.loco:SetAcceleration(self.Stats["Accel"])end
- if(self.Stats["Decel"]) then self.loco:SetDeceleration(self.Stats["Decel"]) end
- if(self.Stats["Step"]) then self.loco:SetJumpHeight(self.Stats["Step"]) end
- if(self.OnSpawn) then self:OnSpawn() end
- --self:SetModel( "models/Humans/Group01/Female_01.mdl" )
- ]]
- --[[
- self:SetHullType( HULL_HUMAN );
- self:SetHullSizeNormal();
-
- self:SetSolid( SOLID_BBOX )
- self:SetMoveType( MOVETYPE_STEP )
-
- self:CapabilitiesAdd( CAP_MOVE_GROUND or CAP_OPEN_DOORS or CAP_ANIMATEDFACE or CAP_TURN_HEAD or CAP_USE_SHOT_REGULATOR or CAP_AIM_GUN )
-
- self:SetMaxYawSpeed( 5000 )
- ]]--
end
function ENT:OnInjured(dmg)
diff --git a/entities/entities/npc_townie/shared.lua b/entities/entities/npc_townie/shared.lua
index 437275a..e7f02c7 100644
--- a/entities/entities/npc_townie/shared.lua
+++ b/entities/entities/npc_townie/shared.lua
@@ -1,97 +1,8 @@
ENT.Base = "base_nextbot"
-//WS stuff
-ENT.Drops = nil
-ENT.OnDammage = nil
-ENT.Speed = 0
-ENT.Model = nil
-
-ENT.Behave = nil
-ENT.Act = nil
-
-/*---------------------------------------------------------
- Name: OnRemove
- Desc: Called just before entity is deleted
----------------------------------------------------------*/
function ENT:OnRemove()
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")
-
- --Find the enemy with the highest priority
- local maxpriority = -1
- local maxprioritytarget = nil
- for k,v in pairs(self.AwareEnemies) do
- local priority = self:AttackPriority(v)
- if(priority == nil) then
- print("Nill priority hit after ")
- PrintTable(self)
- end
- if(priority > maxpriority) then
- maxpriority = priority
- maxprioritytarget = v
- end
- end
- self.Target = maxprioritytarget
-
- --If we can't find anyone to attack, just stay idle
- if(self.Target == nil) then
- --print("Couldn't find anyone to attack!")
- --Play an idle sequence
- 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
- local thisdist = self:GetPos():Distance(v:GetPos())
- if(thisdist < closest) then
- closest = thisdist
- end
- end
- if(closest > 4000) then
- print("Closes player is " .. closest .. " removeing self...")
- self:BecomeRagdoll(DamageInfo())
- end
- else
- --We have a target to attack!
-
- --Find which attack will do the most dammage
- local maxdammage = -1
- local maxdammagefunc = nil
- for k,v in pairs(self.Attacks) do
- local dammagefunc = nil
- local attackfunc = nil
- for i,j in pairs(v) do
- dammagefunc = i
- attackfunc = j
- end
- local dammage = dammagefunc(self, self.Target)
- if(dammage > maxdammage) then
- maxdammage = dammage
- maxdammagefunc = attackfunc
- end
- end
-
- --Do that attack
- if(maxdammagefunc) then
- maxdammagefunc(self, self.Target)
- end
- end
- coroutine.yield()
- end
-
- coroutine.yield()
-end
-]]
-
function ENT:BehaveAct()
if(self.Act) then
self:Act()
@@ -111,11 +22,6 @@ function ENT:OnStuck()
end
function ENT:selectNewNode()
- --print("selectNewNode called")
- --debug.Trace()
- --print("Selecting from nodes")
- --PrintTable(self.allowedNodes)
- --local nodes = ents.FindByClass("info_townienode")
if #self.allowedNodes == 0 then return end
local rnode = table.Random(self.allowedNodes)
return rnode
@@ -124,7 +30,6 @@ end
local removeblock = {
["prop_door_rotating"] = function(bot,ent)
ent:Fire("OpenAwayFrom",bot:GetName())
- --Couln't get it to open correct direction, back up and go through
timer.Simple(3,function()
ent:Fire("Close")
end)
@@ -133,7 +38,7 @@ local removeblock = {
function ENT:BehaveUpdate(num)
if not self.BehaveThread then return end
- if self.curnode ~= nil and self.curnode:IsValid() then
+ if self.curnode and self.curnode:IsValid() then
if self.curnode:GetPos():Distance(self:GetPos()) < 5 then
if self.nodereached == false then
self.curnode.OnReached(self)
@@ -153,20 +58,19 @@ function ENT:BehaveUpdate(num)
["filter"] = self
}
local tr = util.TraceLine(trdata)
- if tr.Hit then
- --print(tr.Entity)
- if removeblock[tr.Entity:GetClass()] ~= nil then
- removeblock[tr.Entity:GetClass()](self,tr.Entity)
- end
+ local ecl
+ --print("tr",tr,"tr.entity",tr.Entity)
+ if (tr ~= nil) and (tr.Entity ~= nil) and tr.Entity:IsValid() then
+ --print("Not returning")
+ ecl = tr.Entity:GetClass()
+ end
+ if tr.Hit and removeblock[ecl] ~= nil then
+ removeblock[ecl](self,tr.Entity)
end
local ok, message = coroutine.resume( self.BehaveThread )
- if ( ok == false ) then
-
-
+ if not ok then
self.BehaveThread = nil
Msg( self, "error: ", message, "\n" );
-
-
end
end