Benny/gamemodes/benny/gamemode/modules/player/sh_player.lua

88 lines
2.1 KiB
Lua
Raw Normal View History

local PT = FindMetaTable( "Player" )
2023-11-06 14:03:14 -05:00
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
2023-11-06 14:03:14 -05:00
if w then aim = w:GetUserAim() and math.ease.OutCubic( aim ) or math.ease.InCubic( aim ) end
local pos = self:GetPos()
local perc = math.TimeFraction( self:GetViewOffset().z, self:GetViewOffsetDucked().z, self:GetCurrentViewOffset().z )
pos.z = pos.z + Lerp( perc, 64, 52 )
pos:Add( Lerp( aim, 16, 16 ) * ang:Right() )
pos:Add( Lerp( aim, -64, -32 ) * ang:Forward() )
pos:Add( 0 * ang:Up() )
pos:Add( Lerp( aim, 16, 16 ) * ang:Up() * (ang.p/90) )
local tr = util.TraceHull( {
start = self:GetPos() + Vector( 0, 0, Lerp( perc, 64, 52 ) ),
endpos = pos,
mins = -Vector( 4, 4, 4 ),
maxs = Vector( 4, 4, 4 ),
filter = self
})
return tr.HitPos, ang, 90
end
function PT:INV_Get()
if !self.INV then
print( "Inventory created")
self.INV = {}
end
return self.INV
2023-10-09 15:05:58 -04:00
end
do
local translat = {
2023-11-12 19:59:12 -05:00
["melee"] = { 1, 1 },
["special"] = { 1, 2 },
["pistol"] = { 2, 1 },
["smg"] = { 3, 1 },
["shotgun"] = { 4, 1 },
["rifle"] = { 5, 1 },
2023-11-03 13:20:39 -04:00
["machinegun"] = { 5, 2 },
2023-11-12 19:59:12 -05:00
["grenade"] = { 6, 1 },
["utility"] = { 6, 2 },
2023-11-11 21:08:34 -05:00
["equipment"] = { 7, 1 },
2023-10-09 15:05:58 -04:00
}
-- PROTO: Cache this!
function PT:INV_Buckets()
local inventorylist = {
[1] = {},
[2] = {},
[3] = {},
[4] = {},
2023-11-03 13:20:39 -04:00
[5] = {},
[6] = {},
2023-11-11 21:08:34 -05:00
[7] = {},
2023-10-09 15:05:58 -04:00
}
2023-11-12 19:59:12 -05:00
local inv = self:INV_Get()
2023-10-09 15:05:58 -04:00
for i, bucket in ipairs( inventorylist ) do
local temp = {}
2023-11-12 19:59:12 -05:00
for id, data in pairs( inv ) do
2023-10-09 15:05:58 -04:00
local idata = WEAPONS[data.Class]
local translated = translat[idata.Type]
if i == translated[1] then
table.insert( temp, { id, translated[2] } )
end
end
2023-11-12 19:59:12 -05:00
table.sort( temp, function(a, b) return (inv[b[1]]["Acquisition"] + (b[2]*10000)) > (inv[a[1]]["Acquisition"] + (a[2]*10000)) end )
2023-10-09 15:05:58 -04:00
for i, v in ipairs( temp ) do
table.insert( bucket, v[1] )
end
end
return inventorylist
end
end