summaryrefslogtreecommitdiff
path: root/lua/entities/npc_huntable/init.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-08-07 18:22:29 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2017-08-07 18:22:29 -0400
commitdaa59a7835c350a09dcb207c714acf57828137f3 (patch)
treeae2c00da0e546447ca17a9c5d8492310e5e93f27 /lua/entities/npc_huntable/init.lua
downloadartery_editor-daa59a7835c350a09dcb207c714acf57828137f3.tar.gz
artery_editor-daa59a7835c350a09dcb207c714acf57828137f3.tar.bz2
artery_editor-daa59a7835c350a09dcb207c714acf57828137f3.zip
Inital Commit
Diffstat (limited to 'lua/entities/npc_huntable/init.lua')
-rw-r--r--lua/entities/npc_huntable/init.lua80
1 files changed, 80 insertions, 0 deletions
diff --git a/lua/entities/npc_huntable/init.lua b/lua/entities/npc_huntable/init.lua
new file mode 100644
index 0000000..fcc8532
--- /dev/null
+++ b/lua/entities/npc_huntable/init.lua
@@ -0,0 +1,80 @@
+AddCSLuaFile("cl_init.lua")
+AddCSLuaFile("shared.lua")
+include("shared.lua")
+local applyfields = {"Model", "Stats"}
+
+function ENT:Initialize()
+ --print("NPC spawned!")
+ --self:SetMoveType(MOVETYPE_STEP)
+ --self:SetSolid(SOLID_OBB)
+ --self:SetCollisionGroup(COLLISION_GROUP_PUSHAWAY )
+
+ --self:SetCollisionGroup(COLLISION_GROUP_INTERACTIVE)
+ for _, v in pairs(applyfields) do
+ assert(self[v], "NPC created without " .. v .. " this might be a bug!")
+ end
+
+ self:SetModel(self.Model)
+
+ if (self.Stats["Vitality"]) then
+ self:SetHealth(self.Stats["Vitality"])
+ else
+ print("NPC created with no stat for vitality, this might be a bug!")
+ end
+
+ if (self.Stats["Accel"]) then
+ self.loco:SetAcceleration(self.Stats["Accel"])
+ end
+
+ if (self.Stats["Decel"]) then
+ self.loco:SetDeceleration(self.Stats["Decel"])
+ end
+
+ if (self.Stats["Step"]) then
+ self.loco:SetJumpHeight(self.Stats["Step"])
+ end
+
+ if self.Stats["Speed"] then
+ self.loco:SetDesiredSpeed(self.Stats["Speed"])
+ end
+
+ if (self.OnSpawn) then
+ self:OnSpawn()
+ end
+end
+
+function ENT:OnInjured(dmg)
+ print("Ent OnInjured fired! dmg was", dmg)
+ if self.OnDammage ~= nil then
+ self:OnDammage(dmg)
+ end
+end
+
+function ENT:OnContact(ent)
+ if self.OnCollide ~= nil then
+ self:OnCollide(ent)
+ end
+end
+
+function ENT:OnKilled(dmg)
+ if (CLIENT) then return end
+ if not self.Drops then return end
+ --print("Looks like we have some drops")
+ --error("You need to code how item drops work!")
+ local itemstodrop = {}
+
+ for k, v in pairs(self.Drops) do
+ local rng = math.random(0, 100)
+ local itemname = self.Drops[k][1]
+ local itemchance = self.Drops[k][2]
+ local heightoffset = 10
+
+ if rng < itemchance then
+ --local drop = ART.GetItemByName(itemname)
+ --print("Createing a drop of",drop)
+ --ART.CreateDroppedItem(drop, self:GetPos())
+ end
+ end
+
+ self:BecomeRagdoll(dmg)
+end