diff options
| author | Apickx <apickx@cogarr.com> | 2018-03-08 20:19:27 -0500 |
|---|---|---|
| committer | Apickx <apickx@cogarr.com> | 2018-03-08 20:19:27 -0500 |
| commit | 8e050456d610a7adf087b8b065f3fba2f21d3c2d (patch) | |
| tree | 82b6c45fc2b6483ecbd0b5107626f7ed514f52bd | |
| parent | ae57e4ea207da17023bf418dfdd3822527051b6f (diff) | |
| download | wintersurvival2-8e050456d610a7adf087b8b065f3fba2f21d3c2d.tar.gz wintersurvival2-8e050456d610a7adf087b8b065f3fba2f21d3c2d.tar.bz2 wintersurvival2-8e050456d610a7adf087b8b065f3fba2f21d3c2d.zip | |
Revamed all npcs to now use the hl2 builtins
Added antlion gaurd npcs, who will drop the item needed to make spells.
| -rw-r--r-- | gamemode/itemsystem/items/heartofbeast.lua | 31 | ||||
| -rw-r--r-- | gamemode/itemsystem/items/spell_fireball.lua | 9 | ||||
| -rw-r--r-- | gamemode/itemsystem/items/spell_teleport.lua | 9 | ||||
| -rw-r--r-- | gamemode/npcsystem/aidirector.lua | 67 |
4 files changed, 97 insertions, 19 deletions
diff --git a/gamemode/itemsystem/items/heartofbeast.lua b/gamemode/itemsystem/items/heartofbeast.lua new file mode 100644 index 0000000..75acfdf --- /dev/null +++ b/gamemode/itemsystem/items/heartofbeast.lua @@ -0,0 +1,31 @@ +local ITEM = {} +ITEM.Name = "Heart of Beast" +ITEM.Desc = "The heart of a wild beast" +ITEM.Class = "Other" +ITEM.Model = "models/props_combine/breenlight.mdl" +ITEM.Icon = Material("wintersurvival2/hud/ws1_icons/icon_rock") +ITEM.Burnable = false +ITEM.CD = 0.3 +ITEM.Range = 120 +ITEM.HoldType = "melee" + +ITEM.Structure = {} +ITEM.Recipe = nil +ITEM.Tools = nil +ITEM.CookCD = 1 +ITEM.CookProduct = nil +ITEM.Ghost = nil + +--These are just here to tell the editors/developers what functions are available.. dont un-comment them out, as this could affect all the items. + +function ITEM:OnEnchanted(enchanttalbe, nearbyrunes) + if math.random(0,1) == 0 then + enchanttalbe:AddItem("Fireball",1) + else + enchanttalbe:AddItem("Teleport",1) + end +end + + + +RegisterItem(ITEM) diff --git a/gamemode/itemsystem/items/spell_fireball.lua b/gamemode/itemsystem/items/spell_fireball.lua index dc7d7e0..8a2b048 100644 --- a/gamemode/itemsystem/items/spell_fireball.lua +++ b/gamemode/itemsystem/items/spell_fireball.lua @@ -20,15 +20,6 @@ ITEM.Structure = { }, } -ITEM.Recipe = { - Resources = { - ["Plank"] = 2, - ["Rope"] = 1, - ["Sap"] = 1, - }, - Tools = {}, -} - ITEM.CD = 0.25 ITEM.Range = 9999 diff --git a/gamemode/itemsystem/items/spell_teleport.lua b/gamemode/itemsystem/items/spell_teleport.lua index e86f388..521dca2 100644 --- a/gamemode/itemsystem/items/spell_teleport.lua +++ b/gamemode/itemsystem/items/spell_teleport.lua @@ -20,15 +20,6 @@ ITEM.Structure = { }, } -ITEM.Recipe = { - Resources = { - ["Plank"] = 2, - ["Rope"] = 1, - ["Sap"] = 1, - }, - Tools = {}, -} - ITEM.CD = 0.25 ITEM.Range = 9999 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
|
