From daa59a7835c350a09dcb207c714acf57828137f3 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 7 Aug 2017 18:22:29 -0400 Subject: Inital Commit --- lua/entities/npc_huntable/init.lua | 80 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 lua/entities/npc_huntable/init.lua (limited to 'lua/entities/npc_huntable/init.lua') 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 -- cgit v1.2.3-70-g09d2