Turn shit to using GetStat and the new convar sys.

This commit is contained in:
Fesiug 2023-12-17 19:47:52 -05:00
parent 2f91c17ce8
commit 0798e1d190
6 changed files with 73 additions and 43 deletions

View File

@ -133,10 +133,32 @@ local fallbackstat = {
["Reload_MagIn_Bonus1"] = 0.56, ["Reload_MagIn_Bonus1"] = 0.56,
["Reload_MagIn_Bonus2"] = 0.56+0.1, ["Reload_MagIn_Bonus2"] = 0.56+0.1,
["Sound_Cock"] = "Glock.Cock", ["Sound_Cock"] = "Glock.Cock",
["Damage"] = 0,
["Pellets"] = 1,
["Firemodes"] = { { Mode = 1 } },
["Delay"] = 0,
["Ammo"] = 0,
["Spread"] = 0,
["SpreadAdd"] = 0,
["SpreadDecay_Start"] = 0,
["SpreadDecay_End"] = 0,
["SpreadDecay_RampTime"] = 0,
["Speed_Move"] = 1,
["Speed_Aiming"] = 1,
["Speed_Reloading"] = 1,
["Speed_Firing"] = 1,
} }
function SWEP:GetStat( hand, stat ) function SWEP:GetStat( hand, stat )
return (self:BClass( hand )[stat] or fallbackstat[stat]) local thereturn = (self:BClass( hand )[stat] or fallbackstat[stat])
assert( thereturn, "No stat for " .. stat )
return thereturn
end
function BENNY_GetStat( class, stat )
local thereturn = (class[stat] or fallbackstat[stat])
assert( thereturn, "No stat for " .. stat )
return thereturn
end end
function SWEP:C_DualCheck() function SWEP:C_DualCheck()

View File

@ -233,20 +233,20 @@ function SWEP:Think()
self:SetAim( math.Approach( self:GetAim(), self:GetUserAim() and 1 or 0, FrameTime()/0.2 ) ) self:SetAim( math.Approach( self:GetAim(), self:GetUserAim() and 1 or 0, FrameTime()/0.2 ) )
if !self:C_AttackDown( false ) then for i=1, 2 do
self:SetWep1_Burst( 0 ) local hand = i==2
if !self:C_AttackDown( hand ) then
self:D_SetBurst( hand, 0 )
end end
if !self:C_AttackDown( true ) then
self:SetWep2_Burst( 0 )
end end
for i=1, 2 do for i=1, 2 do
local hand = i==2 local hand = i==2
local wep, wepc = self:BTable( hand ), self:BClass( hand ) local wep, wepc = self:BTable( hand ), self:BClass( hand )
if wepc and wepc.Features == "firearm" and self:D_GetDelay( hand ) < CurTime()-0.01 then if wepc and wepc.Features == "firearm" and self:D_GetDelay( hand ) < CurTime()-0.01 then
local mweh = math.Remap( CurTime(), self:D_GetShotTime( hand ), self:D_GetShotTime( hand )+wepc.SpreadDecay_RampTime, 0, 1 ) local mweh = math.Remap( CurTime(), self:D_GetShotTime( hand ), self:D_GetShotTime( hand ) + self:GetStat( hand, "SpreadDecay_RampTime" ), 0, 1 )
mweh = math.Clamp( mweh, 0, 1 ) mweh = math.Clamp( mweh, 0, 1 )
local decayfinal = Lerp( math.ease.InExpo( mweh ), wepc.SpreadDecay_Start, wepc.SpreadDecay_End ) local decayfinal = Lerp( math.ease.InExpo( mweh ), self:GetStat( hand, "SpreadDecay_Start" ), self:GetStat( hand, "SpreadDecay_End" ) )
self:D_SetSpread( hand, math.Approach( self:D_GetSpread( hand ), 0, decayfinal * FrameTime() ) ) self:D_SetSpread( hand, math.Approach( self:D_GetSpread( hand ), 0, decayfinal * FrameTime() ) )
end end
end end

View File

@ -58,6 +58,9 @@ CONVARS_CL["wep_ao_junk"] = { 0, 0, 1, true, true, "Whether offhand junk
CONVARS_CL["wep_toolgun"] = { "", nil, nil, true, true, "Toolgun tool." } CONVARS_CL["wep_toolgun"] = { "", nil, nil, true, true, "Toolgun tool." }
CONVARS_CL["cam_override"] = { "", nil, nil, false, true, "Override camera" }
CONVARS_CL["cam_unlock"] = { 0, 0, 1, false, false, "Unlock camera" }
CONVARS_CL_GEN = {} CONVARS_CL_GEN = {}
for i, v in pairs( CONVARS_CL ) do for i, v in pairs( CONVARS_CL ) do
CONVARS_CL_GEN[i] = CreateConVar( "benny_" .. i, v[1], (v[4] and FCVAR_USERINFO or 0) + (v[5] and FCVAR_ARCHIVE or 0), v[6], v[2], v[3] ) CONVARS_CL_GEN[i] = CreateConVar( "benny_" .. i, v[1], (v[4] and FCVAR_USERINFO or 0) + (v[5] and FCVAR_ARCHIVE or 0), v[6], v[2], v[3] )

View File

@ -41,7 +41,7 @@ local mewer = {
Size = 12, Size = 12,
Font = "Benny_10", Font = "Benny_10",
Stat = function( class ) Stat = function( class )
local bwep = math.Clamp( math.Remap( class.Damage * (class.Pellets or 1), 14, 80, 0, 1 ), 0, 1 ) local bwep = math.Clamp( math.Remap( BENNY_GetStat( class, "Damage" ) * ( BENNY_GetStat( class, "Pellets" ) or 1 ), 14, 80, 0, 1 ), 0, 1 )
local meowzor = math.ease.OutQuart( bwep ) local meowzor = math.ease.OutQuart( bwep )
return meowzor return meowzor
end, end,
@ -57,14 +57,14 @@ local mewer = {
weight_1, weight_2 = weight_1/totalscore, weight_2/totalscore weight_1, weight_2 = weight_1/totalscore, weight_2/totalscore
local score_1, score_2 = 1, 1 local score_1, score_2 = 1, 1
local truedelay = (1/class.Delay) local truedelay = ( 1 / BENNY_GetStat( class, "Delay" ) )
if class.Firemodes[1].Mode == 1 then if BENNY_GetStat( class, "Firemodes" )[1].Mode == 1 then
truedelay = math.min( truedelay, 60/300 ) truedelay = math.min( truedelay, 60/300 )
end end
score_1 = rmt1c( class.Damage * truedelay, 100, 350 ) score_1 = rmt1c( BENNY_GetStat( class, "Damage" ) * truedelay, 100, 350 )
score_1 = score_1 * weight_1 score_1 = score_1 * weight_1
score_2 = rmt1c( class.Ammo, 16, 42 ) score_2 = rmt1c( BENNY_GetStat( class, "Ammo" ), 16, 42 )
score_2 = score_2 * weight_2 score_2 = score_2 * weight_2
return score_1 + score_2 return score_1 + score_2
@ -85,7 +85,7 @@ local mewer = {
Size = 12, Size = 12,
Font = "Benny_10", Font = "Benny_10",
Stat = function( class ) Stat = function( class )
return math.Clamp( math.Remap( class.Spread, 1/60, 2, 1, 0 ), 0, 1 ) return math.Clamp( math.Remap( BENNY_GetStat( class, "Spread" ), 1/60, 2, 1, 0 ), 0, 1 )
end, end,
-- "How accurate the weapon is when firing single shots or short bursts.\nAffected by Spread and various Recoil stats." -- "How accurate the weapon is when firing single shots or short bursts.\nAffected by Spread and various Recoil stats."
}, },
@ -94,28 +94,28 @@ local mewer = {
Size = 12, Size = 12,
Font = "Benny_10", Font = "Benny_10",
Stat = function( class ) Stat = function( class )
return math.Clamp( math.Remap( class.SpreadAdd * (1/class.Delay), 1, 13, 1, 0 ), 0, 1 ) return math.Clamp( math.Remap( BENNY_GetStat( class, "SpreadAdd" ) * ( 1 / BENNY_GetStat( class, "Delay" ) ), 1, 13, 1, 0 ), 0, 1 )
end, end,
-- "How managable the weapon's recoil and spread is under sustained fire.\nAffected by RPM and various Recoil stats." -- "How managable the weapon's recoil and spread is under sustained fire.\nAffected by RPM and various Recoil stats."
}, },
-- { {
-- Name = "Handling", Name = "Handling",
-- Size = 12, Size = 12,
-- Font = "Benny_10", Font = "Benny_10",
-- Stat = function( class ) Stat = function( class )
-- return 0 return 0
-- end, end,
-- -- "How quickly this weapon readies from sprinting, aiming and deploying.\nAffected by Aim Down Sights Time, Sprint To Fire Time, and Deploy Time." -- "How quickly this weapon readies from sprinting, aiming and deploying.\nAffected by Aim Down Sights Time, Sprint To Fire Time, and Deploy Time."
-- }, },
-- { {
-- Name = "Maneuvering", Name = "Maneuvering",
-- Size = 12, Size = 12,
-- Font = "Benny_10", Font = "Benny_10",
-- Stat = function( class ) Stat = function( class )
-- return 0 return 0
-- end, end,
-- -- "How accurate the weapon is while not aiming.\nAffected by Hipfire Spread, Mid-air Spread, Sway, and Free Aim Angle." -- "How accurate the weapon is while not aiming.\nAffected by Hipfire Spread, Mid-air Spread, Sway, and Free Aim Angle."
-- }, },
{ {
Name = "Mobility", Name = "Mobility",
Size = 12, Size = 12,
@ -127,16 +127,16 @@ local mewer = {
local score_moving, score_aiming, score_reloading, score_firing = 1, 1, 1, 1 local score_moving, score_aiming, score_reloading, score_firing = 1, 1, 1, 1
score_moving = rmt1c( class.Speed_Move or 1, 0.75, 0.95 ) score_moving = rmt1c( BENNY_GetStat( class, "Speed_Move" ), 0.75, 0.95 )
score_moving = score_moving * weight_moving score_moving = score_moving * weight_moving
score_aiming = rmt1c( class.Speed_Aiming or 1, 0.75, 0.95 ) score_aiming = rmt1c( BENNY_GetStat( class, "Speed_Aiming" ), 0.75, 0.95 )
score_aiming = score_aiming * weight_aiming score_aiming = score_aiming * weight_aiming
score_reloading = rmt1c( class.Speed_Reloading or 1, 0.75, 0.9 ) score_reloading = rmt1c( BENNY_GetStat( class, "Speed_Reloading" ), 0.75, 0.9 )
score_reloading = score_reloading * weight_reloading score_reloading = score_reloading * weight_reloading
score_firing = rmt1c( class.Speed_Firing or 1, 0.75, 0.9 ) score_firing = rmt1c( BENNY_GetStat( class, "Speed_Firing" ), 0.75, 0.9 )
score_firing = score_firing * weight_firing score_firing = score_firing * weight_firing
return score_moving + score_aiming + score_reloading + score_firing return score_moving + score_aiming + score_reloading + score_firing

View File

@ -174,9 +174,6 @@ tempmapcameras["benny_test"]["barber"] = {
BENNY_ACTIVECAMERA = nil BENNY_ACTIVECAMERA = nil
local c_over = CreateConVar( "benny_cam_override", "" )
local c_unlock = CreateConVar( "benny_cam_unlock", 0 )
local si = 4 local si = 4
local ctrace = { local ctrace = {
start = nil, start = nil,
@ -275,7 +272,7 @@ function bennyfp( origin, angles, fov )
end end
hook.Add( "CalcView", "Benny_CalcView", function( ply, pos, ang, fov ) hook.Add( "CalcView", "Benny_CalcView", function( ply, pos, ang, fov )
if c_unlock:GetBool() then return end if ConVarCL_Bool("cam_unlock") then return end
if ply:NoclippingAndNotVaulting() then return end if ply:NoclippingAndNotVaulting() then return end
decide_active() decide_active()
local camera = BENNY_ACTIVECAMERA local camera = BENNY_ACTIVECAMERA
@ -305,7 +302,7 @@ hook.Add( "CalcView", "Benny_CalcView", function( ply, pos, ang, fov )
end end
end end
local st = c_over:GetString() local st = ConVarCL_String("cam_override")
if st != "" then if st != "" then
local st = string.Explode( " ", st ) local st = string.Explode( " ", st )
view.origin.x = tonumber(st[1]) view.origin.x = tonumber(st[1])

View File

@ -332,6 +332,14 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
surface.DrawRect( b_x + b_s + ((i-1)*ss(32+2)) + ss(1), b_y + b_bh + ss(4+2) + ss(1), ss(32*localperc) - ss(2), b_bh2 - ss(2) ) surface.DrawRect( b_x + b_s + ((i-1)*ss(32+2)) + ss(1), b_y + b_bh + ss(4+2) + ss(1), ss(32*localperc) - ss(2), b_bh2 - ss(2) )
end end
end end
if true then
surface.SetDrawColor( schema("bg") )
local s_h = ss(20)
surface.DrawRect( b_x, b_y - s_h - ss(4), b_w, s_h )
draw.SimpleText( string.format( "%f m/s", p:GetVelocity():Length2D()/39.3701 ), "Benny_24", b_x + b_w/2, b_y - s_h/2 - ss(4/2), schema_c("fg"), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
end
end end
do -- Vaulting do -- Vaulting
@ -570,7 +578,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
local touse1 = col_1 local touse1 = col_1
local touse1_primary = col_1a local touse1_primary = col_1a
local touse2 = col_2 local touse2 = col_2
if false then if ConVarCL_String("cam_override") != "" then
pl_x = tr1f:ToScreen().x pl_x = tr1f:ToScreen().x
pl_y = tr1f:ToScreen().y pl_y = tr1f:ToScreen().y
ps_x = tr1f:ToScreen().x ps_x = tr1f:ToScreen().x