aboutsummaryrefslogtreecommitdiff
path: root/gamemode/npcsystem/aidirector.lua
diff options
context:
space:
mode:
authorAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-01-07 21:31:55 -0500
committerAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-01-07 21:31:55 -0500
commit790e96ffa5cb5e9eb3c44f6ede09612bafda2239 (patch)
tree63cad5072bd20dcdb769ecd4905b4ec1fa0ec845 /gamemode/npcsystem/aidirector.lua
parent406a4148506be540bcdac0f10f2256320c5c2771 (diff)
parent08331347cfc619852a177f9c120bf7328cd89d70 (diff)
downloadwintersurvival2-790e96ffa5cb5e9eb3c44f6ede09612bafda2239.tar.gz
wintersurvival2-790e96ffa5cb5e9eb3c44f6ede09612bafda2239.tar.bz2
wintersurvival2-790e96ffa5cb5e9eb3c44f6ede09612bafda2239.zip
Merge branch 'queue' of ssh://ssh.cogarr.org:43/home/git/wintersurvival2 into queue
Diffstat (limited to 'gamemode/npcsystem/aidirector.lua')
-rw-r--r--gamemode/npcsystem/aidirector.lua52
1 files changed, 44 insertions, 8 deletions
diff --git a/gamemode/npcsystem/aidirector.lua b/gamemode/npcsystem/aidirector.lua
index 073eea7..04e645d 100644
--- a/gamemode/npcsystem/aidirector.lua
+++ b/gamemode/npcsystem/aidirector.lua
@@ -8,21 +8,29 @@ concommand.Add("ws_spawnbird",function(ply,cmd,args)
SpawnNpcByName("Bird",ply:GetPos())
end)
+concommand.Add("ws_spawnnpc",function(ply,cmd,args)
+ if(!args[1]) then print("You must enter the name of an npc")
+ return end
+
+ local npc = GetNpcByName(args[1])
+ if(npc == nil) then print("Not a valid name!")
+ return end
+ SpawnNpcByName(args[1],ply:GetPos())
+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 +43,24 @@ 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
+ if(entdata.OnSpawn) then
+ ent.OnSpawn = entdata.OnSpawn
+ end
ent:Spawn()
end
@@ -43,7 +69,13 @@ 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",
+ [2] = "Antlion Scout",
+ [3] = "Antlion Pouncer"
+}
local Tick = CurTime()
hook.Add("Tick","SpawnAmbient",function()
if(CLIENT) then return end
@@ -75,7 +107,11 @@ 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))
+ local npc = GetNpcByName(ambientnpcs[randnpcnum])
+ if(npc:SpawnLocations(Pos)) then
+ SpawnNpcByName(ambientnpcs[randnpcnum],Pos)
+ end
break
end
end