Implemented Hook_PlayerTakeDamage

This commit is contained in:
Haodong Mo 2020-08-16 20:17:56 +10:00
parent 132d1ee8df
commit dbbf483175
4 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,18 @@
hook.Add("EntityTakeDamage", "ArcCW_DoAttDMG", function(ent, dmg)
if !ent:IsPlayer() then return end
local wpn = ent:GetActiveWeapon()
if !wpn.ArcCW then return end
for i, k in pairs(wpn.Attachments) do
if !k.Installed then continue end
local atttbl = ArcCW.AttachmentTable[k.Installed]
if atttbl.Hook_PlayerTakeDamage then
atttbl.Hook_PlayerTakeDamage(wpn, {slot = i, atthp = k.HP, dmg = dmg})
end
end
wpn:SendAttHP()
end)

View File

@ -54,8 +54,9 @@ att.Model = ""
att.HideModel = false
att.ModelBodygroups = ""
att.ModelSkin = 0
att.ModelScale = 1
att.ModelScale = Vector(1, 1, 1)
att.ModelOffset = Vector(0, 0, 0)
att.OffsetAng = Angle(0, 0, 0)
att.ModelIsShield = false
att.DrawFunc = function(self, element, wm) end
@ -78,6 +79,9 @@ att.DamageOnShoot = 0
att.DamageOnReload = 0
att.DamagePerSecond = 0
-- {slot = int, atthp = float, dmg = DamageInfo}
att.Hook_PlayerTakeDamage = function(wep, data) end
-- {slot = int, oldhp = float, dmg = float}
att.Hook_AttTakeDamage = function(wep, data) end

View File

@ -125,6 +125,15 @@ function SWEP:Reload()
self:SetNWBool("reloading", true)
for i, k in pairs(self.Attachments) do
if !k.Installed then continue end
local atttbl = ArcCW.AttachmentTable[k.Installed]
if atttbl.DamageOnReload then
self:DamageAttachment(i, atttbl.DamageOnReload)
end
end
if !self.ReloadInSights then
self:ExitSights()
self.Sighted = false

Binary file not shown.