Add BennyCheck, clean hook names

This commit is contained in:
Fesiug 2023-11-06 14:03:14 -05:00
parent ed336f6cfd
commit 79ca331ada
4 changed files with 27 additions and 22 deletions

View File

@ -274,7 +274,7 @@ function bennyfp( origin, angles, fov )
return pos, ang, 90
end
hook.Add( "CalcView", "MyCalcView", function( ply, pos, ang, fov )
hook.Add( "CalcView", "Benny_CalcView", function( ply, pos, ang, fov )
if c_unlock:GetBool() then return end
if ply:GetMoveType() == MOVETYPE_NOCLIP then return end
decide_active()
@ -292,8 +292,7 @@ hook.Add( "CalcView", "MyCalcView", function( ply, pos, ang, fov )
end
end
-- PROTO: Add correct benny weapon check
if true or IsValid(ply:GetActiveWeapon()) and ply:GetActiveWeapon():GetAim() > 0 then
if ply:BennyCheck() then -- and ply:GetActiveWeapon():GetAim() > 0 then
view.drawviewer = true
view.origin, view.angles, view.fov = bennyfp( view.origin, view.angles, view.fov )
end

View File

@ -13,7 +13,7 @@ local hide = {
["CHudZoom"] = true,
}
hook.Add( "HUDShouldDraw", "HideHUD", function( name )
hook.Add( "HUDShouldDraw", "Benny_HUDShouldDraw", function( name )
if ( hide[ name ] ) then return false end
end )
@ -218,7 +218,10 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
end
do -- Weapon
assert( IsValid(wep) and wep:GetClass() == "benny", "Failed to retrieve 'benny' weapon!" )
if !(IsValid(wep) and wep:GetClass() == "benny") then
print( "Failed to retrieve 'benny' weapon!" )
return
end
local inv = p:INV_Get()
local wep1 = wep:BTable( false )
local wep1c = wep:BClass( false )
@ -278,8 +281,8 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
size = ss(2)
by = by - ss(9-3)
elseif count>60 then
size = ss(3)
by = by - ss(7)
size = ss(2)
by = by - ss(6)
elseif count>30 then
size = ss(3)
by = by - ss(5)
@ -662,12 +665,13 @@ do
local function Equip()
local ply = LocalPlayer()
local buckets = ply:INV_Buckets()
if buckets[bucket_selected][item_selected] then
if buckets[bucket_selected] and buckets[bucket_selected][item_selected] then
RunConsoleCommand( "benny_inv_equip", buckets[bucket_selected][item_selected] )
end
end
local function Wrap( ply, num )
local buckets = ply:INV_Buckets()
if !buckets[num] then return end
if bucket_selected == num then
item_selected = item_selected + 1
if item_selected > #buckets[bucket_selected] then
@ -727,22 +731,22 @@ do
Wrap( ply, 5 )
end,
["slot6"] = function( ply )
-- Wrap( ply, 6 )
Wrap( ply, 6 )
end,
["slot7"] = function( ply )
-- Wrap( ply, 7 )
Wrap( ply, 7 )
end,
["slot8"] = function( ply )
-- Wrap( ply, 8 )
Wrap( ply, 8 )
end,
["slot9"] = function( ply )
-- Wrap( ply, 9 )
Wrap( ply, 9 )
end,
["slot0"] = function( ply )
-- Wrap( ply, 0 )
Wrap( ply, 0 )
end,
}
hook.Add( "PlayerBindPress", "inv", function( ply, bind, pressed, code )
hook.Add( "PlayerBindPress", "Benny_PlayerBindPress", function( ply, bind, pressed, code )
if qt[bind] and pressed then
qt[bind]( ply )
return true

View File

@ -7,7 +7,7 @@ local blop = Angle()
local lastmoveangle = 0
local lastmoveangle_lerp
TPSOverride = TPSOverride or Angle()
hook.Add( "CreateMove", "CamFuck", function( cmd )
hook.Add( "CreateMove", "Benny_CreateMove", function( cmd )
if false and BENNY_ACTIVECAMERA and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then
local x, y = cmd:GetForwardMove(), cmd:GetSideMove()
@ -54,18 +54,16 @@ hook.Add( "CreateMove", "CamFuck", function( cmd )
end
if true and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then -- FPS cam
local p = LocalPlayer()
local w = p:GetActiveWeapon()
if !IsValid(w) then w = false end
local aimed = w and w:GetUserAim() or false
if p:BennyCheck() and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then -- FPS cam
local aimed = w:GetUserAim()
local opos, ang = p:CamSpot( TPSOverride )
ang:Add( Angle( cmd:GetMouseY()*0.022, -cmd:GetMouseX()*0.022, 0 ) )
ang:Normalize()
if aimed then
local tr = util.TraceLine( {
start = opos,

View File

@ -1,12 +1,16 @@
local PT = FindMetaTable( "Player" )
function PT:BennyCheck()
return ( self:GetActiveWeapon():IsValid() and self:GetActiveWeapon():GetClass() == "benny" and self:GetActiveWeapon().GetUserAim )
end
function PT:CamSpot( ang )
local w = self:GetActiveWeapon()
if !IsValid( w ) then w = false end
local aim = w and w:GetAim() or 0
aim = w:GetUserAim() and math.ease.OutCubic( aim ) or math.ease.InCubic( aim )
if w then aim = w:GetUserAim() and math.ease.OutCubic( aim ) or math.ease.InCubic( aim ) end
local pos = self:GetPos()