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