Handler, weapon select, color
This commit is contained in:
parent
bf36cb7d24
commit
34a294da95
|
@ -69,12 +69,19 @@ function SWEP:SetActive( ent )
|
|||
if ent:GetOwner() != p then return false end
|
||||
if self:GetActiveR():IsValid() then self:Deactive() end
|
||||
self:SetActiveR( ent )
|
||||
self:ItemR( "Deploy" )
|
||||
if self:ItemR() then
|
||||
self:ItemR( "Deploy" )
|
||||
self:ItemR():SetNoDraw( false )
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function SWEP:Deactive()
|
||||
local p = self:GetOwner()
|
||||
if self:ItemR() then
|
||||
self:ItemR( "Holster" )
|
||||
self:ItemR():SetNoDraw( true )
|
||||
end
|
||||
self:SetActiveR( NULL )
|
||||
end
|
||||
|
||||
|
@ -131,6 +138,7 @@ function SWEP:EquipItem( ent )
|
|||
ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
|
||||
ent:AddEffects( EF_BONEMERGE )
|
||||
ent:SetMoveType( MOVETYPE_NONE )
|
||||
ent:SetNoDraw( true )
|
||||
ent:SetParent( p )
|
||||
ent:SetOwner( p )
|
||||
ent:SetPos( vector_origin )
|
||||
|
@ -164,6 +172,7 @@ function SWEP:DropItem()
|
|||
ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
|
||||
ent:RemoveEffects( EF_BONEMERGE )
|
||||
ent:SetMoveType( MOVETYPE_VPHYSICS )
|
||||
ent:SetNoDraw( false )
|
||||
|
||||
ent:SetPos( p:EyePos() + p:GetAimVector() * 0 )
|
||||
ent:SetAngles( p:EyeAngles() + Angle( 0, 180, 0 ) )
|
||||
|
@ -192,7 +201,7 @@ function SWEP:Think()
|
|||
self:ItemR("Think")
|
||||
|
||||
end
|
||||
self:SetHoldType( self:ItemR() and "revolver" or "normal" )
|
||||
self:SetHoldType( self:ItemR() and (self:ItemR().Class.HoldType or "rpg") or "normal" )
|
||||
else
|
||||
print( self, "Thinking without an owner." )
|
||||
end
|
||||
|
|
|
@ -79,15 +79,19 @@ local function regenfonts()
|
|||
end
|
||||
regenfonts()
|
||||
|
||||
local COLOR_DARK = Color( 40, 40, 80 )
|
||||
local COLOR_BRIGHT = Color( 80, 80, 160 )
|
||||
local COLOR_MAIN = Color( 160, 160, 240 )
|
||||
-- local COLOR_DARK = Color( 40, 40, 80 )
|
||||
-- local COLOR_BRIGHT = Color( 80, 80, 160 )
|
||||
-- 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
|
||||
function GM:HUDPaint()
|
||||
local p = LocalPlayer()
|
||||
local w, h = ScrW(), ScrH()
|
||||
local handler = p:BennyCheck()
|
||||
local handler = p:HandlerCheck()
|
||||
stack = util.Stack()
|
||||
|
||||
S_Push( 20, 20 )
|
||||
|
@ -106,14 +110,16 @@ function GM:HUDPaint()
|
|||
hScisoff()
|
||||
S_Pop()
|
||||
|
||||
S_Push( 20, h - 60 - 20 )
|
||||
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
|
||||
hCol( v == handler:GetActiveR() and COLOR_BRIGHT or COLOR_DARK )
|
||||
hRect( 0, 0, 120, 60 )
|
||||
local x, y = hXY( 0, 0 )
|
||||
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 )
|
||||
end
|
||||
S_Pop()
|
||||
if handler then
|
||||
S_Push( 20, h - 60 - 20 )
|
||||
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
|
||||
hCol( v == handler:GetActiveR() and COLOR_BRIGHT or COLOR_DARK )
|
||||
hRect( (i-1)*(120+10), 0, 120, 60 )
|
||||
local x, y = hXY( (i-1)*(120+10), 0 )
|
||||
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 )
|
||||
end
|
||||
S_Pop()
|
||||
end
|
||||
|
||||
if stack:Size() != 0 then print("Stack unfinished.") end
|
||||
return
|
||||
|
|
|
@ -9,10 +9,6 @@ function PT:GetItems()
|
|||
return
|
||||
end
|
||||
|
||||
function PT:HandlerCheck()
|
||||
return self:GetActiveWeapon().AEItemHandler and self:GetActiveWeapon()
|
||||
end
|
||||
|
||||
InventoryMeta = {}
|
||||
|
||||
function InventoryMeta:Destroy()
|
||||
|
@ -157,7 +153,7 @@ local dads = {
|
|||
|
||||
local function beatup( ply, num )
|
||||
local inv = ply:GetInventory():GetWeighted()
|
||||
local wep = ply:BennyCheck()
|
||||
local wep = ply:HandlerCheck()
|
||||
|
||||
local ent = inv[num]
|
||||
if ent then
|
||||
|
|
|
@ -48,6 +48,7 @@ AddItem( "base", {
|
|||
"Acquisition",
|
||||
},
|
||||
},
|
||||
HoldType = "slam",
|
||||
|
||||
["Initialize"] = function( class, ent, handler )
|
||||
print( class, "Initialized base initialization" )
|
||||
|
@ -89,6 +90,7 @@ AddItem( "base_firearm", {
|
|||
"DelayReload",
|
||||
},
|
||||
},
|
||||
HoldType = "rpg",
|
||||
|
||||
Delay = 0.1,
|
||||
Pellets = 1,
|
||||
|
@ -106,17 +108,68 @@ AddItem( "base_firearm", {
|
|||
print( class, "Initialized a firearm" )
|
||||
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 )
|
||||
if ent:GetClip() <= 0 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: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,
|
||||
|
||||
["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 )
|
||||
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", {
|
||||
|
@ -125,10 +178,11 @@ AddItem( "mk23", {
|
|||
Category = "pistol",
|
||||
Base = "base_firearm",
|
||||
|
||||
Model = "models/weapons/w_pist_elite_single.mdl",
|
||||
Model = "models/weapons/w_pist_usp.mdl",
|
||||
HoldType = "revolver",
|
||||
|
||||
ClipSize = 12,
|
||||
Delay = (60/300),
|
||||
Delay = (60/350),
|
||||
FireSound = "weapons/usp/usp_unsil-1.wav",
|
||||
|
||||
Accuracy = 5/60,
|
||||
|
@ -138,6 +192,24 @@ AddItem( "mk23", {
|
|||
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
|
||||
local tent = {}
|
||||
tent.Base = "b-itembase"
|
||||
|
|
|
@ -5,3 +5,6 @@ L["Name"] = "English (United States)"
|
|||
|
||||
L["#Item.mk23.Name"] = "MK.23"
|
||||
L["#Item.mk23.Description"] = "Special forces sidearm"
|
||||
|
||||
L["#Item.fnc.Name"] = "FNC Para"
|
||||
L["#Item.fnc.Description"] = "Imported assault rifle"
|
|
@ -125,7 +125,7 @@ function PT:MakeCharacter()
|
|||
end
|
||||
end
|
||||
|
||||
function PT:BennyCheck()
|
||||
function PT:HandlerCheck()
|
||||
local wep = self:GetActiveWeapon()
|
||||
return ( wep:IsValid() and wep:GetClass() == "itemhandler" and wep.GetActiveR ) and wep or false
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue