Items, HUD, wip. Weps won't bonemerge?

This commit is contained in:
Fesiug 2024-03-07 22:34:29 -05:00
parent 8db88566ad
commit 97d2eebf4e
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
10 changed files with 173 additions and 24 deletions

View File

@ -0,0 +1,70 @@
---------------------
-- Your Name is Benny
---------------------
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_anim"
ENT.BennyItem = true
function ENT:Initialize()
self:SetModel( self.Class.Model or "models/weapons/w_357.mdl" )
if SERVER then
self:PhysicsInit( SOLID_VPHYSICS )
self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
self:GetPhysicsObject():Wake()
end
self.Class:Initialize( self )
end
local function recurse( modify, includer )
local basevars = ITEMS[includer].BaseClass
if ITEMS[includer].BaseClass then
recurse( modify, ITEMS[includer].Base )
end
local localvars = ITEMS[includer]:GetRaw("Vars")
if localvars then
for i, v in pairs( localvars ) do
if !modify[i] then modify[i] = {} end
table.Add( modify[i], v )
end
end
end
function ENT:SetupDataTables()
local NWVars = {}
recurse( NWVars, self.ID )
for varname, varlist in pairs(NWVars) do
local numba = 0
for keyind, keyname in ipairs(varlist) do
self:NetworkVar( varname, numba, keyname )
numba = numba + 1
end
end
end
if SERVER then
function ENT:PhysicsCollide( data, collider )
if ( data.DeltaTime > 0.1 ) then
--self:EmitSound( str, 70, 100, 1, CHAN_STATIC )
end
return
end
else
hook.Add("NotifyShouldTransmit", "AE_NotifyShouldTransmit", function( ent, shouldtransmit )
if ent.BennyItem then
if shouldtransmit then
if ent:GetOwner() == LocalPlayer() then
ent:SetPredictable( true )
end
else
ent:SetPredictable( false )
end
end
end)
end

View File

@ -2,7 +2,7 @@
AddCSLuaFile()
SWEP.Base = "weapon_base"
SWEP.AEItemHandler = true
SWEP.BennyItemHandler = true
SWEP.ViewModel = "models/weapons/c_arms.mdl"
SWEP.ViewModelFOV = 74
@ -117,7 +117,7 @@ end
function SWEP:EquipItem( ent )
local p = self:GetOwner()
if CLIENT then print("FUCK OFF") debug.Trace() return end
if IsValid(ent) and ent.AEItem then
if IsValid(ent) and ent.BennyItem then
if ent:GetOwner() != NULL then
print( ent, "belongs to", ent:GetOwner(), "!! Not equipping." )
return
@ -129,7 +129,7 @@ function SWEP:EquipItem( ent )
print("Pick up", ent)
ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
ent:RemoveEffects( EF_ITEM_BLINK )
ent:AddEffects( EF_BONEMERGE + EF_BONEMERGE_FASTCULL )
ent:SetParent( p )
ent:SetOwner( p )
ent:SetPos( vector_origin )
@ -138,7 +138,7 @@ function SWEP:EquipItem( ent )
ent:EmitSound( "ae/items/pickup.ogg", 70, 100, 1, CHAN_STATIC )
--self:SetActive( ent )
self:SetActive( ent )
local inv = p:GetInventory()
inv[ent] = true
inv:Sync()
@ -158,9 +158,9 @@ function SWEP:DropItem()
ent:SetParent( NULL )
ent:SetOwner( NULL )
local ep = ent:GetPhysicsObject()
ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
ent:AddEffects( EF_ITEM_BLINK )
ent:RemoveEffects( EF_BONEMERGE + EF_BONEMERGE_FASTCULL )
ent:SetPos( p:EyePos() + p:GetAimVector() * 0 )
ent:SetAngles( p:EyeAngles() + Angle( 0, 180, 0 ) )

View File

@ -8,7 +8,7 @@ local cam_r = CreateConVar( "b-cam_r", 12 )
local cam_u = CreateConVar( "b-cam_u", 0 )
local cam_fov = CreateConVar( "b-cam_fov", 75 )
local m = 2
local m = 3
local m2 = Vector( m, m, m )
local m1 = m2:GetNegated()

View File

@ -32,10 +32,6 @@ local function hCol( r, g, b, a )
return surface.SetDrawColor( r, g, b, a )
end
local function hCoo( col )
return col
end
local function hRect( x, y, w, h )
gx, gy = hXY()
x = (x or 0) + gx
@ -52,29 +48,72 @@ local function hORect( x, y, w, h, r )
surface.DrawOutlinedRect( x, y, w, h, r )
end
local function hScis( x, y, w, h )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
render.SetScissorRect( x, y, x+w, y+h, true )
end
local function hScisoff()
render.SetScissorRect( 0, 0, 0, 0, false )
end
local sizes = {
8, 10, 16, 24, 48
}
local function regenfonts()
for index, scale in ipairs( sizes ) do
surface.CreateFont("HUD_" .. scale, {
font = "Carbon Plus Bold",
size = scale,
weight = 0,
extended = false,
italic = false,
antialias = true,
})
end
end
regenfonts()
local COLOR_DARK = Color( 40, 40, 80 )
local COLOR_BRIGHT = Color( 80, 80, 160 )
local COLOR_MAIN = Color( 160, 160, 240 )
-- Drawing
function GM:HUDPaint()
local p = LocalPlayer()
local w, h = ScrW(), ScrH()
stack = util.Stack()
-- Centered
S_Push( ScrW()/2, ScrH()/2 )
-- Push Top, Centered Health
S_Push( -320/2, -440 )
S_Push( 20, 20 )
hCol( COLOR_DARK )
hRect( 0, 0, 320, 30 )
hRect( 0, 0, 320, 40 )
local x, y = hXY( 6, 0 )
draw.SimpleText( "BENNY", "HUD_48", x, y, COLOR_MAIN )
hCol( COLOR_MAIN )
hRect( 2, 2, 320-2-2, 30-2-2 )
hRect( 4, 4, (320-4-4) * math.abs( math.sin(CurTime()) ), 40-4-4 )
hScis( 4, 4, (320-4-4) * math.abs( math.sin(CurTime()) ), 40-4-4 )
local x, y = hXY( 6, 0 )
draw.SimpleText( "BENNY", "HUD_48", x, y, COLOR_DARK )
hScisoff()
S_Pop()
S_Push( 20, h - 60 - 20 )
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
hCol( COLOR_DARK )
hRect( 0, 0, 120, 60 )
local x, y = hXY( 0, 0 )
draw.SimpleText( l8( v.Class.PrintName ), "HUD_24", x + 120/2, y + 60/2, COLOR_MAIN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
end
S_Pop()
if stack:Size() != 0 then print("Stack unfinished.") end
return
end

View File

@ -162,7 +162,7 @@ local mwheel = {
local function beatup( ply, num )
local inv = ply:GetInventory():GetWeighted()
local wep = ply:HandlerCheck()
local wep = ply:BennyCheck()
local ent = inv[num]
if ent then
@ -178,7 +178,7 @@ local function boba( ply, mwheel )
if mwheel != 0 then
print("Test", math.Round( CurTime()%60, 4 ), mwheel )
local inv = ply:GetInventory():GetWeighted()
local wep = ply:HandlerCheck()
local wep = ply:BennyCheck()
local inf = table.Flip( inv )
local currpos = inf[wep:GetActiveR()]

View File

@ -113,7 +113,7 @@ AddItem( "mk23", {
Category = "pistol",
Base = "base_firearm",
Model = "models/weapons/w_pist_usp.mdl",
Model = "models/weapons/w_smg1.mdl",
ClipSize = 12,
Delay = (60/300),
@ -125,3 +125,17 @@ AddItem( "mk23", {
Accuracy_Reset = 0.4,
Accuracy_Decay = 5,
})
for ID, Data in pairs(ITEMS) do
local tent = {}
tent.Base = "b-itembase"
tent.PrintName = Data.PrintName or ID
tent.ID = ID
tent.Class = ITEMS[ID]
tent.Spawnable = true
tent.AdminOnly = false
tent.Category = "Other"
-- print("aei_" .. ID)
scripted_ents.Register( tent, "b-item_" .. ID )
end

View File

@ -0,0 +1,14 @@
---------------------
-- Your Name is Benny
---------------------
Languages = {}
function l8( inp )
return Languages["en-us"][inp] or Languages["en-us"][inp] or inp
end
local AD, IN = AddCSLuaFile, include
AD("languages/en-us.lua")
IN("languages/en-us.lua")

View File

@ -0,0 +1,7 @@
local L = {}
Languages["en-us"] = L
L["Name"] = "English (United States)"
L["#Item.mk23.Name"] = "MK.23"
L["#Item.mk23.Description"] = "Special forces sidearm"

View File

@ -23,6 +23,9 @@ function GM:PlayerSpawn( ply )
ply:MakeCharacter()
end
function GM:PlayerNoClip()
return true
end
local PT = FindMetaTable( "Player" )

View File

@ -8,6 +8,8 @@ BENNY = {}
local AC, IN = AddCSLuaFile, include
AC("language.lua")
IN("language.lua")
AC("camera.lua")
IN("camera.lua")
AC("items.lua")