daddies about to kill himself BUT I fixed it :D

This commit is contained in:
Fesiug 2023-11-16 22:18:45 -05:00
parent 9856e6e6cc
commit 95b96ddb7b
4 changed files with 34 additions and 30 deletions

View File

@ -1,65 +1,56 @@
-- Weapon ID
function SWEP:D_GetID( hand )
return hand and self:GetWep2() or self:GetWep1()
return (hand == true) and self:GetWep2() or (hand == false) and self:GetWep1()
end
function SWEP:D_SetID( hand, value )
return hand and self:SetWep2( value ) or self:SetWep1( value )
return (hand == true) and self:SetWep2( value ) or (hand == false) and self:SetWep1( value )
end
-- Wep. Clip ID
function SWEP:D_GetMagID( hand )
return hand and self:GetWep2_Clip() or self:GetWep1_Clip()
return (hand == true) and self:GetWep2_Clip() or (hand == false) and self:GetWep1_Clip()
end
function SWEP:D_SetMagID( hand, value )
print( "SetMagID: " .. tostring(hand) .. " given " .. value )
return hand and self:SetWep2_Clip( value ) or self:SetWep1_Clip( value )
return (hand == true) and self:SetWep2_Clip( value ) or (hand == false) and self:SetWep1_Clip( value )
end
-- Weapon Firemode
function SWEP:D_GetFiremode( hand )
assert( hand != nil )
return hand and self:GetWep2_Firemode() or self:GetWep1_Firemode()
return (hand == true) and self:GetWep2_Firemode() or (hand == false) and self:GetWep1_Firemode()
end
function SWEP:D_SetFiremode( hand, value )
assert( hand != nil )
return hand and self:SetWep2_Firemode( value ) or self:SetWep1_Firemode( value )
return (hand == true) and self:SetWep2_Firemode( value ) or (hand == false) and self:SetWep1_Firemode( value )
end
-- Weapon Burst
function SWEP:D_GetBurst( hand )
assert( hand != nil )
return hand and self:GetWep2_Burst() or self:GetWep1_Burst()
return (hand == true) and self:GetWep2_Burst() or (hand == false) and self:GetWep1_Burst()
end
function SWEP:D_SetBurst( hand, value )
assert( hand != nil )
return hand and self:SetWep2_Burst( value ) or self:SetWep1_Burst( value )
return (hand == true) and self:SetWep2_Burst( value ) or (hand == false) and self:SetWep1_Burst( value )
end
-- Internal SWEP Delay
function SWEP:D_GetDelay( hand )
assert( hand != nil )
return hand and self:GetDelay2() or self:GetDelay1()
return (hand == true) and self:GetDelay2() or (hand == false) and self:GetDelay1()
end
function SWEP:D_SetDelay( hand, value )
assert( hand != nil )
return hand and self:SetDelay2( value ) or self:SetDelay1( value )
return (hand == true) and self:SetDelay2( value ) or (hand == false) and self:SetDelay1( value )
end
-- Internal SWEP Clip
function SWEP:D_GetClip( hand )
assert( hand != nil )
return hand and self:Clip2() or self:Clip1()
return (hand == true) and self:Clip2() or (hand == false) and self:Clip1()
end
function SWEP:D_SetClip( hand, value )
assert( hand != nil )
return hand and self:SetClip2( value ) or self:SetClip1( value )
return (hand == true) and self:SetClip2( value ) or (hand == false) and self:SetClip1( value )
end
function SWEP:BDeploy( hand, id )

View File

@ -77,6 +77,7 @@ function SWEP:B_Ammo( hand, value )
local p = self:GetOwner()
local inv = p:INV_Get()
self:D_SetClip( hand, value )
print( hand, value )
assert( self:D_GetMagID( hand ) != "", "There is no magazine loaded!" )
inv[ self:D_GetMagID( hand ) ].Ammo = value
end
@ -104,8 +105,8 @@ function SWEP:Reload()
local p = self:GetOwner()
local inv = p:INV_Get()
if p:KeyPressed( IN_RELOAD ) then
for i=1, 2 do
local hand = i==2
-- for i=1, 2 do
local hand = self:GetTempHandedness()--true--i==2
local wep_table = self:BTable( hand )
local wep_class = self:BClass( hand )
if wep_table then
@ -135,9 +136,18 @@ function SWEP:Reload()
PrintTable( maglist )
local mag = maglist[1]
if mag then
wep_table.Loaded = mag
self:D_SetMagID( hand, mag )
self:D_SetClip( hand, inv[mag].Ammo )
if hand then
self:SetWep2_Clip( mag )
self:SetClip2( inv[mag].Ammo )
inv[self:GetWep2()].Loaded = mag
else
self:SetWep1_Clip( mag )
self:SetClip1( inv[mag].Ammo )
inv[self:GetWep1()].Loaded = mag
end
-- wep_table.Loaded = mag
-- self:D_SetMagID( hand, mag )
-- self:D_SetClip( hand, inv[mag].Ammo )
B_Sound( self, wep_class.Sound_MagIn )
else
B_Sound( self, "Common.NoAmmo" )
@ -145,7 +155,7 @@ function SWEP:Reload()
end
self:TPReload()
end
end
-- end
end
return true
end
@ -162,6 +172,11 @@ function SWEP:Think()
else
self:SetUserAim( p:KeyDown( IN_ATTACK2 ) )
end
if p:KeyPressed( IN_ZOOM ) and (SERVER or (CLIENT and IsFirstTimePredicted())) then
self:SetTempHandedness( !self:GetTempHandedness() )
end
self:SetAim( math.Approach( self:GetAim(), self:GetUserAim() and 1 or 0, FrameTime()/0.2 ) )
if !p:KeyDown( IN_ATTACK ) then

View File

@ -746,7 +746,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
draw.SimpleText( "Clip2: " .. wep:Clip2(), "Trebuchet24", bx+mx, by+24*0, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( "ID2: " .. wep:GetWep2(), "Trebuchet24", bx+mx, by+24*1, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( "MagID2: " .. wep:D_GetMagID( true ), "Trebuchet24", bx+mx, by+24*2, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( "T_MagID2: " .. wep1_table.Loaded, "Trebuchet24", bx+mx, by+24*3, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( "T_MagID2: " .. wep2_table.Loaded, "Trebuchet24", bx+mx, by+24*3, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
end
end
end )

View File

@ -196,8 +196,6 @@ hook.Add("StartCommand", "Benny_INV_StartCommand", function( ply, cmd )
end
end
wep:SetTempHandedness( cmd:KeyDown( IN_ZOOM ) )
end
end)