aboutsummaryrefslogtreecommitdiff
path: root/gamemode/npcsystem/aidirector.lua
diff options
context:
space:
mode:
authorAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-01-02 22:10:06 -0500
committerAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-01-02 22:10:06 -0500
commitf1e99d19a5aa6e5fa61518366235e3da09689d0b (patch)
tree7ad13becc83a0c507c87ac2d543d285d73eebb0a /gamemode/npcsystem/aidirector.lua
parent4dec7baa800e1bc73c659d04ad70edef2c0fc529 (diff)
downloadwintersurvival2-f1e99d19a5aa6e5fa61518366235e3da09689d0b.tar.gz
wintersurvival2-f1e99d19a5aa6e5fa61518366235e3da09689d0b.tar.bz2
wintersurvival2-f1e99d19a5aa6e5fa61518366235e3da09689d0b.zip
Ai overhual now working
Diffstat (limited to 'gamemode/npcsystem/aidirector.lua')
-rw-r--r--gamemode/npcsystem/aidirector.lua34
1 files changed, 26 insertions, 8 deletions
diff --git a/gamemode/npcsystem/aidirector.lua b/gamemode/npcsystem/aidirector.lua
index 073eea7..4051204 100644
--- a/gamemode/npcsystem/aidirector.lua
+++ b/gamemode/npcsystem/aidirector.lua
@@ -11,18 +11,16 @@ end)
function SpawnNpcByName(name, position)
if(CLIENT) then return end
entdata = GetNpcByName(name)
+ if not entdata then
+ print("Could not find npc data for name " .. name)
+ return
+ end
ent = ents.Create("ws_npc_ambient")
ent:SetPos(position)
- if(entdata.Speed) then
- ent.Speed = entdata.Speed
- end
if(entdata.Model) then
ent.Model = entdata.Model
end
- if(entdata.vitality) then
- ent:SetHealth(entdata.vitality)
- end
if(entdata.Drops) then
ent.Drops = entdata.Drops
end
@@ -35,6 +33,21 @@ function SpawnNpcByName(name, position)
if(entdata.Act) then
ent.Act = entdata.Act
end
+ if(entdata.Stats) then
+ ent.Stats = entdata.Stats
+ end
+ if(entdata.IdleSequences) then
+ ent.IdleSequences = entdata.IdleSequences
+ end
+ if(entdata.Attacks) then
+ ent.Attacks = entdata.Attacks
+ end
+ if(entdata.AttackPriority) then
+ ent.AttackPriority = entdata.AttackPriority
+ end
+ if(entdata.AwareEnemies) then
+ ent.AwareEnemies = entdata.AwareEnemies
+ end
ent:Spawn()
end
@@ -43,7 +56,11 @@ local traceline = util.TraceLine
local contents = util.PointContents
local Up = Vector(0,0,1)
---Randomly spawn bird npc's around?
+--Randomly spawn npc's around?
+local ambientnpcs = {
+ [0] = "Bird",
+ [1] = "Zombie"
+}
local Tick = CurTime()
hook.Add("Tick","SpawnAmbient",function()
if(CLIENT) then return end
@@ -75,7 +92,8 @@ hook.Add("Tick","SpawnAmbient",function()
if (C != CONTENTS_WATER and C != CONTENTS_WATER+CONTENTS_TRANSLUCENT) then
--print("Appropriate place found, spawning bird)")
- SpawnNpcByName("Bird",Pos)
+ local randnpcnum = math.Round(math.Rand(0, #ambientnpcs))
+ SpawnNpcByName(ambientnpcs[randnpcnum],Pos)
break
end
end