mirror of
https://github.com/HaodongMo/ArcCW.git
synced 2025-03-04 03:13:30 -05:00
Call ModifyBodygroups on wm even if vm isn't valid (fix #142)
This commit is contained in:
parent
b103744a8b
commit
8d29d6c482
@ -1050,33 +1050,38 @@ function SWEP:RefreshBGs()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
if SERVER then
|
||||
self:SetupShields()
|
||||
end
|
||||
end
|
||||
|
||||
local tpmdl = self.WMModel or self
|
||||
|
||||
if IsValid(vm) then
|
||||
for i = 0, (vm:GetNumBodyGroups()) do
|
||||
if self.Bodygroups[i] then
|
||||
vm:SetBodygroup(i, self.Bodygroups[i])
|
||||
end
|
||||
end
|
||||
|
||||
self:GetBuff_Hook("Hook_ModifyBodygroups", {vm = vm, eles = ae, wm = false})
|
||||
self:GetBuff_Hook("Hook_ModifyBodygroups", {vm = self.WMModel or self, eles = ae, wm = true})
|
||||
end
|
||||
|
||||
for slot, v in pairs(self.Attachments) do
|
||||
if !v.Installed then continue end
|
||||
for i = 0, (tpmdl:GetNumBodyGroups()) do
|
||||
if self.Bodygroups[i] then
|
||||
tpmdl:SetBodygroup(i, self.Bodygroups[i])
|
||||
end
|
||||
end
|
||||
self:GetBuff_Hook("Hook_ModifyBodygroups", {vm = tpmdl, eles = ae, wm = true})
|
||||
|
||||
local func = self:GetBuff_Stat("Hook_ModifyAttBodygroups", slot)
|
||||
if func and v.VElement and IsValid(v.VElement.Model) then
|
||||
func(self, {vm = vm, element = v.VElement, slottbl = v, wm = false})
|
||||
end
|
||||
if func and v.WElement and IsValid(v.WElement.Model) then
|
||||
func(self, {vm = self.WMModel, element = v.WElement, slottbl = v, wm = true})
|
||||
end
|
||||
for slot, v in pairs(self.Attachments) do
|
||||
if !v.Installed then continue end
|
||||
|
||||
local func = self:GetBuff_Stat("Hook_ModifyAttBodygroups", slot)
|
||||
if func and v.VElement and IsValid(v.VElement.Model) and IsValid(vm) then
|
||||
func(self, {vm = vm, element = v.VElement, slottbl = v, wm = false})
|
||||
end
|
||||
if func and v.WElement and IsValid(v.WElement.Model) then
|
||||
func(self, {vm = tpmdl, element = v.WElement, slottbl = v, wm = true})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -139,11 +139,7 @@ function SWEP:InitialDefaultClip()
|
||||
end
|
||||
|
||||
function SWEP:Initialize()
|
||||
if (!IsValid(self:GetOwner()) or self:GetOwner():IsNPC()) and self:IsValid() and self.NPC_Initialize and SERVER then
|
||||
self:NPC_Initialize()
|
||||
end
|
||||
|
||||
if game.SinglePlayer() and self:GetOwner():IsValid() and SERVER then
|
||||
if SERVER and game.SinglePlayer() and IsValid(self:GetOwner()) and self:GetOwner():IsPlayer() then
|
||||
self:CallOnClient("Initialize")
|
||||
end
|
||||
|
||||
@ -242,7 +238,12 @@ function SWEP:Initialize()
|
||||
|
||||
hook.Run("ArcCW_WeaponInit", self)
|
||||
|
||||
self:AdjustAtts()
|
||||
if (!IsValid(self:GetOwner()) or self:GetOwner():IsNPC()) and self:IsValid() and self.NPC_Initialize then
|
||||
self:NPC_Initialize()
|
||||
else
|
||||
self:AdjustAtts()
|
||||
self:RefreshBGs()
|
||||
end
|
||||
end
|
||||
|
||||
function SWEP:Holster(wep)
|
||||
|
@ -29,11 +29,6 @@ function SWEP:NPC_Initialize()
|
||||
self:SetNextPrimaryFire(CurTime())
|
||||
self:SetNextSecondaryFire(CurTime() + 30)
|
||||
self:GetOwner():NextThink(CurTime())
|
||||
|
||||
if self.PreAdjustAtts then
|
||||
self.PreAdjustAtts = false
|
||||
self:AdjustAtts()
|
||||
end
|
||||
end
|
||||
|
||||
function SWEP:AssignRandomAttToSlot(slot)
|
||||
@ -109,6 +104,7 @@ function SWEP:NPC_SetupAttachments()
|
||||
end
|
||||
|
||||
self:AdjustAtts()
|
||||
self:RefreshBGs()
|
||||
|
||||
timer.Simple(0.25, function()
|
||||
if !IsValid(self) then return end
|
||||
|
Loading…
Reference in New Issue
Block a user