blob: fcc853253b52740ae69b12ac7a1bfe148e6e0cb5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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
|