Handler, weapon select, color

This commit is contained in:
Fesiug 2024-03-12 18:43:31 -04:00
parent bf36cb7d24
commit 34a294da95
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
6 changed files with 109 additions and 23 deletions

View File

@ -69,12 +69,19 @@ function SWEP:SetActive( ent )
if ent:GetOwner() != p then return false end if ent:GetOwner() != p then return false end
if self:GetActiveR():IsValid() then self:Deactive() end if self:GetActiveR():IsValid() then self:Deactive() end
self:SetActiveR( ent ) self:SetActiveR( ent )
self:ItemR( "Deploy" ) if self:ItemR() then
self:ItemR( "Deploy" )
self:ItemR():SetNoDraw( false )
end
return true return true
end end
function SWEP:Deactive() function SWEP:Deactive()
local p = self:GetOwner() local p = self:GetOwner()
if self:ItemR() then
self:ItemR( "Holster" )
self:ItemR():SetNoDraw( true )
end
self:SetActiveR( NULL ) self:SetActiveR( NULL )
end end
@ -131,6 +138,7 @@ function SWEP:EquipItem( ent )
ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES ) ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
ent:AddEffects( EF_BONEMERGE ) ent:AddEffects( EF_BONEMERGE )
ent:SetMoveType( MOVETYPE_NONE ) ent:SetMoveType( MOVETYPE_NONE )
ent:SetNoDraw( true )
ent:SetParent( p ) ent:SetParent( p )
ent:SetOwner( p ) ent:SetOwner( p )
ent:SetPos( vector_origin ) ent:SetPos( vector_origin )
@ -164,6 +172,7 @@ function SWEP:DropItem()
ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES ) ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
ent:RemoveEffects( EF_BONEMERGE ) ent:RemoveEffects( EF_BONEMERGE )
ent:SetMoveType( MOVETYPE_VPHYSICS ) ent:SetMoveType( MOVETYPE_VPHYSICS )
ent:SetNoDraw( false )
ent:SetPos( p:EyePos() + p:GetAimVector() * 0 ) ent:SetPos( p:EyePos() + p:GetAimVector() * 0 )
ent:SetAngles( p:EyeAngles() + Angle( 0, 180, 0 ) ) ent:SetAngles( p:EyeAngles() + Angle( 0, 180, 0 ) )
@ -192,7 +201,7 @@ function SWEP:Think()
self:ItemR("Think") self:ItemR("Think")
end end
self:SetHoldType( self:ItemR() and "revolver" or "normal" ) self:SetHoldType( self:ItemR() and (self:ItemR().Class.HoldType or "rpg") or "normal" )
else else
print( self, "Thinking without an owner." ) print( self, "Thinking without an owner." )
end end

View File

@ -79,15 +79,19 @@ local function regenfonts()
end end
regenfonts() regenfonts()
local COLOR_DARK = Color( 40, 40, 80 ) -- local COLOR_DARK = Color( 40, 40, 80 )
local COLOR_BRIGHT = Color( 80, 80, 160 ) -- local COLOR_BRIGHT = Color( 80, 80, 160 )
local COLOR_MAIN = Color( 160, 160, 240 ) -- local COLOR_MAIN = Color( 160, 160, 240 )
local COLOR_DARK = Color( 54, 44, 39 )
local COLOR_BRIGHT = Color( 94, 84, 79 )
local COLOR_MAIN = Color( 255, 238, 169 )
-- Drawing -- Drawing
function GM:HUDPaint() function GM:HUDPaint()
local p = LocalPlayer() local p = LocalPlayer()
local w, h = ScrW(), ScrH() local w, h = ScrW(), ScrH()
local handler = p:BennyCheck() local handler = p:HandlerCheck()
stack = util.Stack() stack = util.Stack()
S_Push( 20, 20 ) S_Push( 20, 20 )
@ -106,14 +110,16 @@ function GM:HUDPaint()
hScisoff() hScisoff()
S_Pop() S_Pop()
S_Push( 20, h - 60 - 20 ) if handler then
for i, v in ipairs( p:GetInventory():GetWeighted() ) do S_Push( 20, h - 60 - 20 )
hCol( v == handler:GetActiveR() and COLOR_BRIGHT or COLOR_DARK ) for i, v in ipairs( p:GetInventory():GetWeighted() ) do
hRect( 0, 0, 120, 60 ) hCol( v == handler:GetActiveR() and COLOR_BRIGHT or COLOR_DARK )
local x, y = hXY( 0, 0 ) hRect( (i-1)*(120+10), 0, 120, 60 )
draw.SimpleText( l8( v.Class.PrintName ) .. "(" .. v:GetClip() .. "/" .. v.Class.ClipSize .. ")", "HUD_24", x + 120/2, y + 60/2, COLOR_MAIN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) local x, y = hXY( (i-1)*(120+10), 0 )
end draw.SimpleText( l8( v.Class.PrintName ) .. "(" .. v:GetClip() .. "/" .. v.Class.ClipSize .. ")", "HUD_24", x + 120/2, y + 60/2, COLOR_MAIN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
S_Pop() end
S_Pop()
end
if stack:Size() != 0 then print("Stack unfinished.") end if stack:Size() != 0 then print("Stack unfinished.") end
return return

View File

@ -9,10 +9,6 @@ function PT:GetItems()
return return
end end
function PT:HandlerCheck()
return self:GetActiveWeapon().AEItemHandler and self:GetActiveWeapon()
end
InventoryMeta = {} InventoryMeta = {}
function InventoryMeta:Destroy() function InventoryMeta:Destroy()
@ -157,7 +153,7 @@ local dads = {
local function beatup( ply, num ) local function beatup( ply, num )
local inv = ply:GetInventory():GetWeighted() local inv = ply:GetInventory():GetWeighted()
local wep = ply:BennyCheck() local wep = ply:HandlerCheck()
local ent = inv[num] local ent = inv[num]
if ent then if ent then

View File

@ -48,6 +48,7 @@ AddItem( "base", {
"Acquisition", "Acquisition",
}, },
}, },
HoldType = "slam",
["Initialize"] = function( class, ent, handler ) ["Initialize"] = function( class, ent, handler )
print( class, "Initialized base initialization" ) print( class, "Initialized base initialization" )
@ -89,6 +90,7 @@ AddItem( "base_firearm", {
"DelayReload", "DelayReload",
}, },
}, },
HoldType = "rpg",
Delay = 0.1, Delay = 0.1,
Pellets = 1, Pellets = 1,
@ -106,17 +108,68 @@ AddItem( "base_firearm", {
print( class, "Initialized a firearm" ) print( class, "Initialized a firearm" )
end, end,
["Think"] = function( class, ent, handler )
local InProcess = ent:GetBurstCount() > 0
local Topped = ent:GetBurstCount() == class.BurstCount
local Runaway = class.BurstRunaway
local BAuto = class.BurstAuto
local Firedown = handler:GetOwner():KeyDown( IN_ATTACK )
if Runaway and InProcess and !Topped then
class["Attack"]( class, ent, handler )
else
if !Firedown then
if !Topped and InProcess then
ent:SetDelayBurst( CurTime() + class.BurstDelay )
end
ent:SetBurstCount( 0 )
end
if Topped and BAuto then
ent:SetBurstCount( 0 )
ent:SetDelayBurst( CurTime() + class.BurstDelay )
end
end
end,
["Attack"] = function( class, ent, handler ) ["Attack"] = function( class, ent, handler )
if ent:GetClip() <= 0 then return end if ent:GetClip() <= 0 then return end
if ent:GetDelay() > CurTime() then return end if ent:GetDelay() > CurTime() then return end
if ent:GetBurstCount() >= class.BurstCount then return end
ent:SetBurstCount( ent:GetBurstCount() + 1 )
ent:SetClip( ent:GetClip() - 1 ) ent:SetClip( ent:GetClip() - 1 )
ent:SetDelay( CurTime() + class.Delay ) ent:SetDelay( CurTime() + class.Delay )
handler:EmitSound( class.FireSound, 140, 100, 0.4, CHAN_STATIC )
local acc = 0
local p = handler:GetOwner()
handler:FireBullets( {
Attacker = p,
Damage = 1,
Force = 1,
Num = class.Pellets,
Dir = p:GetAimVector(),
Src = p:GetShootPos(),
Spread = Vector( acc, acc, 0 ),
} )
end, end,
["Reload"] = function( class, ent, handler ) ["Reload"] = function( class, ent, handler )
if ent:GetClip() >= class.ClipSize then return end
if ent:GetDelay() > CurTime() then return end
handler:EmitSound( "weapons/m4a1/m4a1_boltpull.wav", 70, 125, 0.4, CHAN_STATIC )
ent:SetDelay( CurTime() + 0.5 )
ent:SetClip( class.ClipSize ) ent:SetClip( class.ClipSize )
end, end,
["Deploy"] = function( class, ent, handler )
handler:EmitSound( "weapons/usp/usp_slideback.wav", 70, 125, 0.4, CHAN_STATIC )
ent:SetDelay( CurTime() + 0.5 )
end,
["Holster"] = function( class, ent, handler )
handler:EmitSound( "weapons/m4a1/m4a1_deploy.wav", 70, 125, 0.4, CHAN_STATIC )
ent:SetDelay( CurTime() + 0.5 )
end,
}) })
AddItem( "mk23", { AddItem( "mk23", {
@ -125,10 +178,11 @@ AddItem( "mk23", {
Category = "pistol", Category = "pistol",
Base = "base_firearm", Base = "base_firearm",
Model = "models/weapons/w_pist_elite_single.mdl", Model = "models/weapons/w_pist_usp.mdl",
HoldType = "revolver",
ClipSize = 12, ClipSize = 12,
Delay = (60/300), Delay = (60/350),
FireSound = "weapons/usp/usp_unsil-1.wav", FireSound = "weapons/usp/usp_unsil-1.wav",
Accuracy = 5/60, Accuracy = 5/60,
@ -138,6 +192,24 @@ AddItem( "mk23", {
Accuracy_Decay = 5, Accuracy_Decay = 5,
}) })
AddItem( "fnc", {
PrintName = "#Item.fnc.Name",
Description = "#Item.fnc.Description",
Base = "base_firearm",
Model = "models/weapons/w_rif_ar556.mdl",
HoldType = "rpg",
ClipSize = 30,
Delay = (60/750),
FireSound = "weapons/m4a1/m4a1_unsil-1.wav",
Accuracy = 1,
Accuracy_Add = 0.4,
Accuracy_Reset = 0.4,
Accuracy_Decay = 12,
})
for ID, Data in pairs(ITEMS) do for ID, Data in pairs(ITEMS) do
local tent = {} local tent = {}
tent.Base = "b-itembase" tent.Base = "b-itembase"

View File

@ -4,4 +4,7 @@ Languages["en-us"] = L
L["Name"] = "English (United States)" L["Name"] = "English (United States)"
L["#Item.mk23.Name"] = "MK.23" L["#Item.mk23.Name"] = "MK.23"
L["#Item.mk23.Description"] = "Special forces sidearm" L["#Item.mk23.Description"] = "Special forces sidearm"
L["#Item.fnc.Name"] = "FNC Para"
L["#Item.fnc.Description"] = "Imported assault rifle"

View File

@ -125,7 +125,7 @@ function PT:MakeCharacter()
end end
end end
function PT:BennyCheck() function PT:HandlerCheck()
local wep = self:GetActiveWeapon() local wep = self:GetActiveWeapon()
return ( wep:IsValid() and wep:GetClass() == "itemhandler" and wep.GetActiveR ) and wep or false return ( wep:IsValid() and wep:GetClass() == "itemhandler" and wep.GetActiveR ) and wep or false
end end