From f1e99d19a5aa6e5fa61518366235e3da09689d0b Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sat, 2 Jan 2016 22:10:06 -0500 Subject: Ai overhual now working --- gamemode/npcsystem/aidirector.lua | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'gamemode/npcsystem/aidirector.lua') 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 -- cgit v1.2.3-70-g09d2