aboutsummaryrefslogtreecommitdiff
path: root/gamemode/npcsystem/aidirector.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/npcsystem/aidirector.lua')
-rw-r--r--gamemode/npcsystem/aidirector.lua67
1 files changed, 66 insertions, 1 deletions
diff --git a/gamemode/npcsystem/aidirector.lua b/gamemode/npcsystem/aidirector.lua
index a9d21c0..353a8eb 100644
--- a/gamemode/npcsystem/aidirector.lua
+++ b/gamemode/npcsystem/aidirector.lua
@@ -82,6 +82,64 @@ local ambientnpcs = {
[2] = "Antlion Scout",
[3] = "Antlion Pouncer"
}
+
+local builtinnpcs = {
+ ["npc_zombie"] = {
+ {"Meat",100},
+ {"Meat",100},
+ {"Meat",100},
+ {"Meat",100},
+ {"Meat",80},
+ {"Meat",40},
+ {"Meat",10},
+ },
+ ["npc_antlion"] = {
+ {"Meat",100},
+ {"Meat",100},
+ {"Meat",80},
+ {"Meat",50},
+ {"Chitin",80},
+ {"Chitin",50},
+ },
+ ["npc_crow"] = {
+ {"Meat",100},--Birds will drop at least 1 meat, and have a 50% chance of dropping 2
+ {"Meat",50},
+ {"Feather",100},
+ {"Feather",100},
+ {"Feather",80},
+ {"Feather",80},
+ {"Feather",40},
+ {"Feather",40},
+ {"Feather",40},
+ {"Feather",40},
+ }
+}
+local npcnames = table.GetKeys(builtinnpcs)
+
+hook.Add("OnNPCKilled","spawnnpcloot",function(npc,attacker,inflictor)
+ if npc:GetClass() == "npc_antlionguard" then
+ local drop = ents.Create("ws_item")
+ drop.Item = GetItemByName("Heart of Beast")
+ drop:SetModel(drop.Item.Model)
+ drop:SetPos(npc:GetPos() + (npc:GetUp() * 20))
+ drop:Spawn()
+ end
+ if builtinnpcs[npc:GetClass()] == nil then return end
+ local npctbl = builtinnpcs[npc:GetClass()]
+ local heightoffset = 20
+ for k,v in pairs(npctbl) do
+ local rng = math.random(0,100)
+ if rng < v[2] then
+ local drop = ents.Create("ws_item")
+ drop.Item = GetItemByName(v[1])
+ drop:SetModel(drop.Item.Model)
+ drop:SetPos(npc:GetPos() + (npc:GetUp() * heightoffset))
+ drop:Spawn()
+ heightoffset = heightoffset + 10
+ end
+ end
+end)
+
local Tick = CurTime()
hook.Add("Tick","SpawnAmbient",function()
if(CLIENT) then return end
@@ -121,7 +179,14 @@ hook.Add("Tick","SpawnAmbient",function()
continue
end
if(npc:SpawnLocations(Pos)) then
- SpawnNpcByName(ambientnpcs[randnpcnum],Pos)
+ --Spawn a random npc
+ local npcname = npcnames[ math.random( #npcnames ) ]
+ if math.random(0,100) == 1 then
+ npcname = "npc_antlionguard"
+ end
+ local e = ents.Create(npcname)
+ e:SetPos(Pos)
+ e:Spawn()
end
break
end