Oh, that's a rehaul of the ammo system and MORE S-
This commit is contained in:
parent
b25ce7ce1e
commit
b022449187
|
@ -19,10 +19,10 @@ function ENT:Use( activator )
|
|||
local wep = activator:GetActiveWeapon()
|
||||
local bt, bc = wep:BTable(), wep:BClass()
|
||||
for i=1, 3 do
|
||||
if bt["Ammo" .. i] and bt.Loaded != i then
|
||||
bt["Ammo" .. i] = bc.Ammo
|
||||
wep:BSend( { "Ammo" .. i, false, bc.Ammo } )
|
||||
end
|
||||
-- if bt["Ammo" .. i] and bt.Loaded != i then
|
||||
-- bt["Ammo" .. i] = bc.Ammo
|
||||
-- wep:BSend( { "Ammo" .. i, false, bc.Ammo } )
|
||||
-- end
|
||||
end
|
||||
self:EmitSound( "benny/weapons/mp5k/boltdrop.ogg", 70, 100, 0.5 )
|
||||
end
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
function SWEP:DrawWorldModel()
|
||||
local p = self:GetOwner()
|
||||
local wm = self.CWM
|
||||
local class = self:BClass( false )
|
||||
if class then
|
||||
if !IsValid(wm) then
|
||||
wm = ClientsideModel( class.WModel )
|
||||
self.CWM = wm
|
||||
end
|
||||
wm:SetModel( class.WModel )
|
||||
wm:SetNoDraw( true )
|
||||
wm:AddEffects( EF_BONEMERGE )
|
||||
wm:SetParent( p )
|
||||
|
||||
-- if IsValid(p) then
|
||||
-- -- Specify a good position
|
||||
-- local offsetVec = Vector(12.8, -1.4, 2.6)
|
||||
-- local offsetAng = Angle(180 - 10, 180, 0)
|
||||
--
|
||||
-- local boneid = p:LookupBone("ValveBiped.Bip01_R_Hand") -- Right Hand
|
||||
-- if !boneid then return end
|
||||
|
||||
-- local matrix = p:GetBoneMatrix(boneid)
|
||||
-- if !matrix then return end
|
||||
|
||||
-- local newPos, newAng = LocalToWorld(offsetVec, offsetAng, matrix:GetTranslation(), matrix:GetAngles())
|
||||
|
||||
-- wm:SetPos(newPos)
|
||||
-- wm:SetAngles(newAng)
|
||||
|
||||
-- wm:SetupBones()
|
||||
-- else
|
||||
-- wm:SetPos(self:GetPos())
|
||||
-- wm:SetAngles(self:GetAngles())
|
||||
-- wm:SetupBones()
|
||||
-- end
|
||||
|
||||
if self:GetUserAim() then wm:DrawModel() end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,39 @@
|
|||
|
||||
function SWEP:CallFire()
|
||||
local class = self:BClass( false )
|
||||
function SWEP:BFire( hand )
|
||||
if self:BTable( hand ) then
|
||||
local wep_table = self:BTable( hand )
|
||||
local wep_class = self:BClass( hand )
|
||||
|
||||
if wep_class.Fire then
|
||||
if wep_class.Fire( self, wep_table ) then return end
|
||||
end
|
||||
if self:D_GetDelay( hand ) > CurTime() then
|
||||
return
|
||||
end
|
||||
if self:D_GetBurst( hand ) >= self:B_Firemode( hand ).Mode then
|
||||
return
|
||||
end
|
||||
if self:D_GetClip( hand ) == 0 then
|
||||
B_Sound( self, wep_class.Sound_DryFire )
|
||||
self:D_SetDelay( hand, CurTime() + 0.2 )
|
||||
return
|
||||
end
|
||||
|
||||
self:B_Ammo( hand, self:D_GetClip( hand ) - 1 )
|
||||
|
||||
B_Sound( self, wep_class.Sound_Fire )
|
||||
self:TPFire()
|
||||
self:CallFire( hand )
|
||||
|
||||
self:D_SetDelay( hand, CurTime() + wep_class.Delay )
|
||||
self:D_SetBurst( hand, self:D_GetBurst( hand ) + 1 )
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function SWEP:CallFire( hand )
|
||||
local p = self:GetOwner()
|
||||
local class = self:BClass( hand )
|
||||
local spread = class.Spread or 0
|
||||
for i=1, class.Pellets or 1 do
|
||||
local dir = self:GetOwner():EyeAngles()
|
||||
|
@ -12,18 +45,18 @@ function SWEP:CallFire()
|
|||
dir:RotateAroundAxis( dir:Up(), spread * radius * math.cos( circ ) )
|
||||
dir:RotateAroundAxis( dir:Forward(), 0 )
|
||||
local tr = util.TraceLine( {
|
||||
start = self:GetOwner():EyePos(),
|
||||
endpos = self:GetOwner():EyePos() + dir:Forward() * 8192,
|
||||
filter = self:GetOwner()
|
||||
start = p:EyePos(),
|
||||
endpos = p:EyePos() + dir:Forward() * 8192,
|
||||
filter = p
|
||||
} )
|
||||
|
||||
self:FireBullets( {
|
||||
Attacker = self:GetOwner(),
|
||||
Damage = self:BClass( false ).Damage,
|
||||
Force = self:BClass( false ).Damage/10,
|
||||
Src = self:GetOwner():EyePos(),
|
||||
Attacker = p,
|
||||
Damage = class.Damage,
|
||||
Force = class.Damage/10,
|
||||
Src = p:EyePos(),
|
||||
Dir = dir:Forward(),
|
||||
IgnoreEntity = self:GetOwner(),
|
||||
IgnoreEntity = p,
|
||||
Callback = self.BulletCallback,
|
||||
} )
|
||||
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
|
||||
|
||||
-- Holdtype thingys
|
||||
do
|
||||
local ActIndex = {
|
||||
[ "pistol" ] = ACT_HL2MP_IDLE_PISTOL,
|
||||
[ "smg" ] = ACT_HL2MP_IDLE_SMG1,
|
||||
[ "grenade" ] = ACT_HL2MP_IDLE_GRENADE,
|
||||
[ "ar2" ] = ACT_HL2MP_IDLE_AR2,
|
||||
[ "shotgun" ] = ACT_HL2MP_IDLE_SHOTGUN,
|
||||
[ "rpg" ] = ACT_HL2MP_IDLE_RPG,
|
||||
[ "physgun" ] = ACT_HL2MP_IDLE_PHYSGUN,
|
||||
[ "crossbow" ] = ACT_HL2MP_IDLE_CROSSBOW,
|
||||
[ "melee" ] = ACT_HL2MP_IDLE_MELEE,
|
||||
[ "slam" ] = ACT_HL2MP_IDLE_SLAM,
|
||||
[ "normal" ] = ACT_HL2MP_IDLE,
|
||||
[ "fist" ] = ACT_HL2MP_IDLE_FIST,
|
||||
[ "melee2" ] = ACT_HL2MP_IDLE_MELEE2,
|
||||
[ "passive" ] = ACT_HL2MP_IDLE_PASSIVE,
|
||||
[ "knife" ] = ACT_HL2MP_IDLE_KNIFE,
|
||||
[ "duel" ] = ACT_HL2MP_IDLE_DUEL,
|
||||
[ "camera" ] = ACT_HL2MP_IDLE_CAMERA,
|
||||
[ "magic" ] = ACT_HL2MP_IDLE_MAGIC,
|
||||
[ "revolver" ] = ACT_HL2MP_IDLE_REVOLVER,
|
||||
|
||||
[ "suitcase" ] = ACT_HL2MP_IDLE,
|
||||
[ "melee_angry" ] = ACT_HL2MP_IDLE_MELEE_ANGRY,
|
||||
[ "angry" ] = ACT_HL2MP_IDLE_ANGRY,
|
||||
[ "scared" ] = ACT_HL2MP_IDLE_SCARED,
|
||||
[ "zombie" ] = ACT_HL2MP_IDLE_ZOMBIE,
|
||||
[ "cower" ] = ACT_HL2MP_IDLE_COWER,
|
||||
}
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Name: SetWeaponHoldType
|
||||
Desc: Sets up the translation table, to translate from normal
|
||||
standing idle pose, to holding weapon pose.
|
||||
-----------------------------------------------------------]]
|
||||
function SWEP:SetWeaponHoldType( t )
|
||||
|
||||
t = string.lower( t )
|
||||
local index = ActIndex[ t ]
|
||||
|
||||
if ( index == nil ) then
|
||||
Msg( "SWEP:SetWeaponHoldType - ActIndex[ \"" .. t .. "\" ] isn't set! (defaulting to normal)\n" )
|
||||
t = "normal"
|
||||
index = ActIndex[ t ]
|
||||
end
|
||||
|
||||
self.ActivityTranslate = {}
|
||||
self.ActivityTranslate[ ACT_MP_STAND_IDLE ] = index
|
||||
self.ActivityTranslate[ ACT_MP_WALK ] = index + 1
|
||||
self.ActivityTranslate[ ACT_MP_RUN ] = index + 2
|
||||
self.ActivityTranslate[ ACT_MP_CROUCH_IDLE ] = index + 3
|
||||
self.ActivityTranslate[ ACT_MP_CROUCHWALK ] = index + 4
|
||||
self.ActivityTranslate[ ACT_MP_ATTACK_STAND_PRIMARYFIRE ] = index + 5
|
||||
self.ActivityTranslate[ ACT_MP_ATTACK_CROUCH_PRIMARYFIRE ] = index + 5
|
||||
self.ActivityTranslate[ ACT_MP_RELOAD_STAND ] = index + 6
|
||||
self.ActivityTranslate[ ACT_MP_RELOAD_CROUCH ] = index + 6
|
||||
self.ActivityTranslate[ ACT_MP_JUMP ] = index + 7
|
||||
self.ActivityTranslate[ ACT_RANGE_ATTACK1 ] = index + 8
|
||||
self.ActivityTranslate[ ACT_MP_SWIM ] = index + 9
|
||||
|
||||
-- "normal" jump animation doesn't exist
|
||||
if ( t == "normal" ) then
|
||||
self.ActivityTranslate[ ACT_MP_JUMP ] = ACT_HL2MP_JUMP_SLAM
|
||||
end
|
||||
|
||||
if ( t == "suitcase" ) then
|
||||
self.ActivityTranslate[ ACT_MP_STAND_IDLE ] = ACT_HL2MP_IDLE_SUITCASE
|
||||
self.ActivityTranslate[ ACT_MP_WALK ] = ACT_HL2MP_WALK_SUITCASE
|
||||
self.ActivityTranslate[ ACT_MP_JUMP ] = ACT_HL2MP_JUMP_SLAM
|
||||
end
|
||||
|
||||
if ( t == "rpg" ) then
|
||||
self.ActivityTranslate[ ACT_MP_CROUCH_IDLE ] = ACT_HL2MP_IDLE_CROUCH_AR2
|
||||
self.ActivityTranslate[ ACT_MP_CROUCHWALK ] = ACT_HL2MP_WALK_CROUCH_AR2
|
||||
end
|
||||
|
||||
--self:SetupWeaponHoldTypeForAI( t )
|
||||
|
||||
end
|
||||
|
||||
-- Default hold pos is the pistol
|
||||
SWEP:SetWeaponHoldType( "pistol" )
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Name: weapon:TranslateActivity()
|
||||
Desc: Translate a player's Activity into a weapon's activity
|
||||
So for example, ACT_HL2MP_RUN becomes ACT_HL2MP_RUN_PISTOL
|
||||
Depending on how you want the player to be holding the weapon
|
||||
-----------------------------------------------------------]]
|
||||
function SWEP:TranslateActivity( act )
|
||||
|
||||
if ( self.Owner:IsNPC() ) then
|
||||
if ( self.ActivityTranslateAI[ act ] ) then
|
||||
return self.ActivityTranslateAI[ act ]
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
if ( self.ActivityTranslate[ act ] != nil ) then
|
||||
return self.ActivityTranslate[ act ]
|
||||
end
|
||||
|
||||
return -1
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
SWEP.GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_SHOTGUN, 0.85 }
|
||||
SWEP.GestureReload = { ACT_FLINCH_STOMACH, 0.3 }
|
||||
SWEP.GestureDraw = { ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND, 0.75 }
|
||||
SWEP.GestureHolster = { ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND, 0.65 }
|
||||
function SWEP:TPFire()
|
||||
if CLIENT and !IsFirstTimePredicted() then return end
|
||||
local target = self:BClass( false ).GestureFire
|
||||
if !target then
|
||||
target = self.GestureFire
|
||||
end
|
||||
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
|
||||
end
|
||||
function SWEP:TPReload()
|
||||
if CLIENT and !IsFirstTimePredicted() then return end
|
||||
local target = self:BClass( false ).GestureReload
|
||||
if !target then
|
||||
target = self.GestureReload
|
||||
end
|
||||
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
|
||||
end
|
||||
function SWEP:TPDraw()
|
||||
if CLIENT and !IsFirstTimePredicted() then return end
|
||||
local target = self:BClass( false ).GestureDraw
|
||||
if !target then
|
||||
target = self.GestureDraw
|
||||
end
|
||||
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
|
||||
end
|
||||
function SWEP:TPHolster()
|
||||
if CLIENT and !IsFirstTimePredicted() then return end
|
||||
local target = self:BClass( false ) and self:BClass( false ).GestureHolster
|
||||
if !target then
|
||||
target = self.GestureHolster
|
||||
end
|
||||
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
|
||||
end
|
|
@ -10,37 +10,55 @@ end
|
|||
|
||||
-- Wep. Clip ID
|
||||
function SWEP:D_GetMagID( hand )
|
||||
return hand and self:GetWep1Clip() or self:GetWep1Clip()
|
||||
return hand and self:GetWep2_Clip() or self:GetWep1_Clip()
|
||||
end
|
||||
|
||||
function SWEP:D_SetMagID( hand, value )
|
||||
return hand and self:SetWep1Clip( value ) or self:SetWep1Clip( value )
|
||||
print( "SetMagID: " .. tostring(hand) .. " given " .. value )
|
||||
return hand and self:SetWep2_Clip( value ) or self:SetWep1_Clip( value )
|
||||
end
|
||||
|
||||
-- Weapon Firemode
|
||||
function SWEP:D_GetFiremode( hand )
|
||||
assert( hand != nil )
|
||||
return hand and self:GetWep2_Firemode() or self:GetWep1_Firemode()
|
||||
end
|
||||
|
||||
function SWEP:D_SetFiremode( hand, value )
|
||||
assert( hand != nil )
|
||||
return hand and self:SetWep2_Firemode( value ) or self:SetWep1_Firemode( value )
|
||||
end
|
||||
|
||||
-- Weapon Burst
|
||||
function SWEP:D_GetBurst( hand )
|
||||
assert( hand != nil )
|
||||
return hand and self:GetWep2_Burst() or self:GetWep1_Burst()
|
||||
end
|
||||
|
||||
function SWEP:D_SetBurst( hand, value )
|
||||
assert( hand != nil )
|
||||
return hand and self:SetWep2_Burst( value ) or self:SetWep1_Burst( value )
|
||||
end
|
||||
|
||||
-- Internal SWEP Delay
|
||||
function SWEP:D_GetDelay( hand )
|
||||
return hand and self:Clip2() or self:Clip1()
|
||||
assert( hand != nil )
|
||||
return hand and self:GetDelay2() or self:GetDelay1()
|
||||
end
|
||||
|
||||
function SWEP:D_SetDelay( hand, value )
|
||||
assert( hand != nil )
|
||||
return hand and self:SetDelay2( value ) or self:SetDelay1( value )
|
||||
end
|
||||
|
||||
-- Internal SWEP Clip
|
||||
function SWEP:D_GetClip( hand )
|
||||
assert( hand != nil )
|
||||
return hand and self:Clip2() or self:Clip1()
|
||||
end
|
||||
|
||||
function SWEP:D_SetClip( hand, value )
|
||||
assert( hand != nil )
|
||||
return hand and self:SetClip2( value ) or self:SetClip1( value )
|
||||
end
|
||||
|
||||
|
@ -61,16 +79,23 @@ function SWEP:BDeploy( hand, id )
|
|||
|
||||
assert( item, "That item doesn't exist. " .. tostring(item) )
|
||||
|
||||
print(debug.Trace())
|
||||
self:D_SetID( hand, id )
|
||||
if item.Loaded then
|
||||
local mid = inv[ item.Loaded ]
|
||||
if mid then
|
||||
self:D_SetMagID( hand, item.Loaded )
|
||||
self:D_SetClip( hand, mid.Ammo )
|
||||
end
|
||||
end
|
||||
|
||||
-- PROTO: Make grenade/melee/firearm logic way way better.
|
||||
if class.Features == "firearm" then
|
||||
if item.Loaded != 0 then
|
||||
assert( item[ "Ammo" .. item.Loaded ], "That magazine doesn't exist." )
|
||||
end
|
||||
-- if item.Loaded != "" then
|
||||
-- assert( inv[ item.Loaded ], "That magazine doesn't exist." )
|
||||
-- end
|
||||
|
||||
self:D_SetClip( hand, item.Loaded == 0 and 0 or item[ "Ammo" .. item.Loaded ] )
|
||||
-- self:D_SetClip( hand, item.Loaded == "" and 0 or inv[ "Ammo" .. item.Loaded ] )
|
||||
else
|
||||
self:D_SetClip( hand, 0 )
|
||||
end
|
||||
|
@ -89,6 +114,6 @@ function SWEP:BHolster( hand )
|
|||
end
|
||||
|
||||
self:D_SetID( hand, "" )
|
||||
self:D_SetMagID( hand, 0 )
|
||||
self:D_SetMagID( hand, "" )
|
||||
self:D_SetClip( hand, 0 )
|
||||
end
|
|
@ -25,6 +25,13 @@ AddCSLuaFile( "sh_firing.lua" )
|
|||
include ( "sh_firing.lua" )
|
||||
AddCSLuaFile( "sh_inv.lua" )
|
||||
include ( "sh_inv.lua" )
|
||||
AddCSLuaFile( "sh_holdtypes.lua" )
|
||||
include ( "sh_holdtypes.lua" )
|
||||
|
||||
AddCSLuaFile( "cl_wm.lua" )
|
||||
if CLIENT then
|
||||
include ( "cl_wm.lua" )
|
||||
end
|
||||
|
||||
function SWEP:SetupDataTables()
|
||||
self:NetworkVar( "Float", 0, "Aim" )
|
||||
|
@ -33,46 +40,22 @@ function SWEP:SetupDataTables()
|
|||
self:NetworkVar( "Float", 3, "GrenadeDownStart" )
|
||||
self:NetworkVar( "String", 0, "Wep1" )
|
||||
self:NetworkVar( "String", 1, "Wep2" )
|
||||
self:NetworkVar( "Int", 0, "Wep1Clip" )
|
||||
self:NetworkVar( "Int", 1, "Wep2Clip" )
|
||||
self:NetworkVar( "Int", 2, "Wep1Burst" )
|
||||
self:NetworkVar( "Int", 3, "Wep2Burst" )
|
||||
self:NetworkVar( "Int", 4, "Wep1_Firemode" )
|
||||
self:NetworkVar( "Int", 5, "Wep2_Firemode" )
|
||||
self:NetworkVar( "String", 2, "Wep1_Clip" )
|
||||
self:NetworkVar( "String", 3, "Wep2_Clip" )
|
||||
self:NetworkVar( "Int", 0, "Wep1_Burst" )
|
||||
self:NetworkVar( "Int", 1, "Wep2_Burst" )
|
||||
self:NetworkVar( "Int", 2, "Wep1_Firemode" )
|
||||
self:NetworkVar( "Int", 3, "Wep2_Firemode" )
|
||||
self:NetworkVar( "Bool", 0, "UserAim" )
|
||||
self:NetworkVar( "Bool", 1, "GrenadeDown" )
|
||||
self:NetworkVar( "Bool", 2, "TempHandedness" )
|
||||
|
||||
self:SetWep1_Firemode( 1 )
|
||||
self:SetWep2_Firemode( 1 )
|
||||
end
|
||||
|
||||
function SWEP:PrimaryAttack()
|
||||
if !self:BTable() then
|
||||
return
|
||||
end
|
||||
if self:BClass().Fire then
|
||||
if self:BClass( false ).Fire( self, self:BTable( false ) ) then return end
|
||||
end
|
||||
if self:GetDelay1() > CurTime() then
|
||||
return
|
||||
end
|
||||
if self:GetWep1Burst() >= self:B_Firemode( false ).Mode then
|
||||
return
|
||||
end
|
||||
if self:Clip1() == 0 then
|
||||
B_Sound( self, self:BClass( false ).Sound_DryFire )
|
||||
self:SetDelay1( CurTime() + 0.2 )
|
||||
return
|
||||
end
|
||||
|
||||
self:B_Ammo( false, self:Clip1() - 1 )
|
||||
|
||||
B_Sound( self, self:BClass( false ).Sound_Fire )
|
||||
self:TPFire()
|
||||
self:CallFire()
|
||||
|
||||
self:SetDelay1( CurTime() + self:BClass( false ).Delay )
|
||||
self:SetWep1Burst( self:GetWep1Burst() + 1 )
|
||||
self:BFire( self:GetTempHandedness() )
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -90,15 +73,12 @@ function SWEP:BClass( alt )
|
|||
end
|
||||
end
|
||||
|
||||
function SWEP:B_Ammo( alt, value )
|
||||
local clip = (alt and self:GetWep2Clip() or self:GetWep1Clip())
|
||||
assert( clip > 0, "You cannot mess with an EMPTY magazine!")
|
||||
if alt then
|
||||
self:SetClip2( value )
|
||||
else
|
||||
self:SetClip1( value )
|
||||
end
|
||||
self:BTable( alt )["Ammo" .. clip] = value
|
||||
function SWEP:B_Ammo( hand, value )
|
||||
local p = self:GetOwner()
|
||||
local inv = p:INV_Get()
|
||||
self:D_SetClip( hand, value )
|
||||
assert( self:D_GetMagID( hand ) != "", "There is no magazine loaded!" )
|
||||
inv[ self:D_GetMagID( hand ) ].Ammo = value
|
||||
end
|
||||
|
||||
function SWEP:B_Firemode( alt )
|
||||
|
@ -121,35 +101,54 @@ function SWEP:SecondaryAttack()
|
|||
end
|
||||
|
||||
function SWEP:Reload()
|
||||
if self:GetOwner():KeyPressed( IN_RELOAD ) then for i=1, 2 do
|
||||
local p = self:GetOwner()
|
||||
local inv = p:INV_Get()
|
||||
if p:KeyPressed( IN_RELOAD ) then
|
||||
for i=1, 2 do
|
||||
local hand = i==2
|
||||
if self:BTable( hand ) then
|
||||
if self:BClass( hand ).Reload then
|
||||
if self:BClass( hand ).Reload( self, self:BTable( hand ) ) then return end
|
||||
local wep_table = self:BTable( hand )
|
||||
local wep_class = self:BClass( hand )
|
||||
if wep_table then
|
||||
print( "First Test: ", i, wep_table, WEAPONS[wep_table.Class].Name )
|
||||
if wep_class.Reload then
|
||||
if wep_class.Reload( self, wep_table ) then return end
|
||||
end
|
||||
if self:D_GetDelay( hand ) > CurTime() then
|
||||
return false
|
||||
end
|
||||
|
||||
if self:D_GetMagID( hand ) != 0 then
|
||||
B_Sound( self, self:BClass( hand ).Sound_MagOut )
|
||||
self:D_SetClip( hand, 0 )
|
||||
self:D_SetMagID( hand, 0 )
|
||||
self:BTable( hand ).Loaded = 0
|
||||
else
|
||||
local maglist = { self:BTable( hand ).Ammo1, self:BTable( hand ).Ammo2, self:BTable( hand ).Ammo3 }
|
||||
for i, v in SortedPairsByValue( maglist, true ) do
|
||||
if v == 0 then B_Sound( self, "Common.NoAmmo" ) return end
|
||||
self:BTable( hand ).Loaded = i
|
||||
self:D_SetClip( hand, v )
|
||||
self:D_SetMagID( hand, i )
|
||||
break
|
||||
local mid = self:D_GetMagID( hand )
|
||||
assert( mid == "" or inv[mid], "That magazine doesn't exist." )
|
||||
if mid != "" then
|
||||
B_Sound( self, wep_class.Sound_MagOut )
|
||||
|
||||
if inv[mid].Ammo == 0 then
|
||||
if SERVER or (CLIENT and IsFirstTimePredicted()) then
|
||||
p:INV_Discard( mid )
|
||||
end
|
||||
end
|
||||
|
||||
self:D_SetClip( hand, 0 )
|
||||
self:D_SetMagID( hand, "" )
|
||||
wep_table.Loaded = ""
|
||||
else
|
||||
local maglist = p:INV_FindMag( "mag_" .. wep_table.Class )
|
||||
PrintTable( maglist )
|
||||
local mag = maglist[1]
|
||||
-- print(hand, i, mag, wep_class.Name)
|
||||
if mag then
|
||||
wep_table.Loaded = mag
|
||||
self:D_SetMagID( hand, mag )
|
||||
self:D_SetClip( hand, inv[mag].Ammo )
|
||||
-- B_Sound( self, wep_class.Sound_MagIn )
|
||||
else
|
||||
-- B_Sound( self, "Common.NoAmmo" )
|
||||
end
|
||||
B_Sound( self, self:BClass( hand ).Sound_MagIn )
|
||||
end
|
||||
self:TPReload()
|
||||
end
|
||||
end end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -168,15 +167,20 @@ function SWEP:Think()
|
|||
self:SetAim( math.Approach( self:GetAim(), self:GetUserAim() and 1 or 0, FrameTime()/0.2 ) )
|
||||
|
||||
if !p:KeyDown( IN_ATTACK ) then
|
||||
self:SetWep1Burst( 0 )
|
||||
self:SetWep1_Burst( 0 )
|
||||
self:SetWep2_Burst( 0 )
|
||||
end
|
||||
|
||||
local ht = "normal"
|
||||
if self:GetUserAim() then
|
||||
if self:BClass( false ) then
|
||||
if self:BClass( true ) then
|
||||
ht = "duel"
|
||||
else
|
||||
ht = self:BClass( false ).HoldType or "revolver"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if ht == "normal" and self:GetHoldType() != "normal" then
|
||||
self:TPHolster()
|
||||
|
@ -203,192 +207,3 @@ end
|
|||
function SWEP:Holster()
|
||||
return true
|
||||
end
|
||||
|
||||
SWEP.GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_SHOTGUN, 0.85 }
|
||||
SWEP.GestureReload = { ACT_FLINCH_STOMACH, 0.3 }
|
||||
SWEP.GestureDraw = { ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND, 0.75 }
|
||||
SWEP.GestureHolster = { ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND, 0.65 }
|
||||
function SWEP:TPFire()
|
||||
if CLIENT and !IsFirstTimePredicted() then return end
|
||||
local target = self:BClass( false ).GestureFire
|
||||
if !target then
|
||||
target = self.GestureFire
|
||||
end
|
||||
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
|
||||
end
|
||||
function SWEP:TPReload()
|
||||
if CLIENT and !IsFirstTimePredicted() then return end
|
||||
local target = self:BClass( false ).GestureReload
|
||||
if !target then
|
||||
target = self.GestureReload
|
||||
end
|
||||
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
|
||||
end
|
||||
function SWEP:TPDraw()
|
||||
if CLIENT and !IsFirstTimePredicted() then return end
|
||||
local target = self:BClass( false ).GestureDraw
|
||||
if !target then
|
||||
target = self.GestureDraw
|
||||
end
|
||||
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
|
||||
end
|
||||
function SWEP:TPHolster()
|
||||
if CLIENT and !IsFirstTimePredicted() then return end
|
||||
local target = self:BClass( false ) and self:BClass( false ).GestureHolster
|
||||
if !target then
|
||||
target = self.GestureHolster
|
||||
end
|
||||
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
|
||||
end
|
||||
|
||||
if CLIENT then
|
||||
|
||||
function SWEP:DrawWorldModel()
|
||||
local p = self:GetOwner()
|
||||
local wm = self.CWM
|
||||
local class = self:BClass( false )
|
||||
if class then
|
||||
if !IsValid(wm) then
|
||||
wm = ClientsideModel( class.WModel )
|
||||
self.CWM = wm
|
||||
end
|
||||
wm:SetModel( class.WModel )
|
||||
wm:SetNoDraw( true )
|
||||
wm:AddEffects( EF_BONEMERGE )
|
||||
wm:SetParent( p )
|
||||
|
||||
-- if IsValid(p) then
|
||||
-- -- Specify a good position
|
||||
-- local offsetVec = Vector(12.8, -1.4, 2.6)
|
||||
-- local offsetAng = Angle(180 - 10, 180, 0)
|
||||
--
|
||||
-- local boneid = p:LookupBone("ValveBiped.Bip01_R_Hand") -- Right Hand
|
||||
-- if !boneid then return end
|
||||
|
||||
-- local matrix = p:GetBoneMatrix(boneid)
|
||||
-- if !matrix then return end
|
||||
|
||||
-- local newPos, newAng = LocalToWorld(offsetVec, offsetAng, matrix:GetTranslation(), matrix:GetAngles())
|
||||
|
||||
-- wm:SetPos(newPos)
|
||||
-- wm:SetAngles(newAng)
|
||||
|
||||
-- wm:SetupBones()
|
||||
-- else
|
||||
-- wm:SetPos(self:GetPos())
|
||||
-- wm:SetAngles(self:GetAngles())
|
||||
-- wm:SetupBones()
|
||||
-- end
|
||||
|
||||
if self:GetUserAim() then wm:DrawModel() end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Holdtype thingys
|
||||
do
|
||||
local ActIndex = {
|
||||
[ "pistol" ] = ACT_HL2MP_IDLE_PISTOL,
|
||||
[ "smg" ] = ACT_HL2MP_IDLE_SMG1,
|
||||
[ "grenade" ] = ACT_HL2MP_IDLE_GRENADE,
|
||||
[ "ar2" ] = ACT_HL2MP_IDLE_AR2,
|
||||
[ "shotgun" ] = ACT_HL2MP_IDLE_SHOTGUN,
|
||||
[ "rpg" ] = ACT_HL2MP_IDLE_RPG,
|
||||
[ "physgun" ] = ACT_HL2MP_IDLE_PHYSGUN,
|
||||
[ "crossbow" ] = ACT_HL2MP_IDLE_CROSSBOW,
|
||||
[ "melee" ] = ACT_HL2MP_IDLE_MELEE,
|
||||
[ "slam" ] = ACT_HL2MP_IDLE_SLAM,
|
||||
[ "normal" ] = ACT_HL2MP_IDLE,
|
||||
[ "fist" ] = ACT_HL2MP_IDLE_FIST,
|
||||
[ "melee2" ] = ACT_HL2MP_IDLE_MELEE2,
|
||||
[ "passive" ] = ACT_HL2MP_IDLE_PASSIVE,
|
||||
[ "knife" ] = ACT_HL2MP_IDLE_KNIFE,
|
||||
[ "duel" ] = ACT_HL2MP_IDLE_DUEL,
|
||||
[ "camera" ] = ACT_HL2MP_IDLE_CAMERA,
|
||||
[ "magic" ] = ACT_HL2MP_IDLE_MAGIC,
|
||||
[ "revolver" ] = ACT_HL2MP_IDLE_REVOLVER,
|
||||
|
||||
[ "suitcase" ] = ACT_HL2MP_IDLE,
|
||||
[ "melee_angry" ] = ACT_HL2MP_IDLE_MELEE_ANGRY,
|
||||
[ "angry" ] = ACT_HL2MP_IDLE_ANGRY,
|
||||
[ "scared" ] = ACT_HL2MP_IDLE_SCARED,
|
||||
[ "zombie" ] = ACT_HL2MP_IDLE_ZOMBIE,
|
||||
[ "cower" ] = ACT_HL2MP_IDLE_COWER,
|
||||
}
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Name: SetWeaponHoldType
|
||||
Desc: Sets up the translation table, to translate from normal
|
||||
standing idle pose, to holding weapon pose.
|
||||
-----------------------------------------------------------]]
|
||||
function SWEP:SetWeaponHoldType( t )
|
||||
|
||||
t = string.lower( t )
|
||||
local index = ActIndex[ t ]
|
||||
|
||||
if ( index == nil ) then
|
||||
Msg( "SWEP:SetWeaponHoldType - ActIndex[ \"" .. t .. "\" ] isn't set! (defaulting to normal)\n" )
|
||||
t = "normal"
|
||||
index = ActIndex[ t ]
|
||||
end
|
||||
|
||||
self.ActivityTranslate = {}
|
||||
self.ActivityTranslate[ ACT_MP_STAND_IDLE ] = index
|
||||
self.ActivityTranslate[ ACT_MP_WALK ] = index + 1
|
||||
self.ActivityTranslate[ ACT_MP_RUN ] = index + 2
|
||||
self.ActivityTranslate[ ACT_MP_CROUCH_IDLE ] = index + 3
|
||||
self.ActivityTranslate[ ACT_MP_CROUCHWALK ] = index + 4
|
||||
self.ActivityTranslate[ ACT_MP_ATTACK_STAND_PRIMARYFIRE ] = index + 5
|
||||
self.ActivityTranslate[ ACT_MP_ATTACK_CROUCH_PRIMARYFIRE ] = index + 5
|
||||
self.ActivityTranslate[ ACT_MP_RELOAD_STAND ] = index + 6
|
||||
self.ActivityTranslate[ ACT_MP_RELOAD_CROUCH ] = index + 6
|
||||
self.ActivityTranslate[ ACT_MP_JUMP ] = index + 7
|
||||
self.ActivityTranslate[ ACT_RANGE_ATTACK1 ] = index + 8
|
||||
self.ActivityTranslate[ ACT_MP_SWIM ] = index + 9
|
||||
|
||||
-- "normal" jump animation doesn't exist
|
||||
if ( t == "normal" ) then
|
||||
self.ActivityTranslate[ ACT_MP_JUMP ] = ACT_HL2MP_JUMP_SLAM
|
||||
end
|
||||
|
||||
if ( t == "suitcase" ) then
|
||||
self.ActivityTranslate[ ACT_MP_STAND_IDLE ] = ACT_HL2MP_IDLE_SUITCASE
|
||||
self.ActivityTranslate[ ACT_MP_WALK ] = ACT_HL2MP_WALK_SUITCASE
|
||||
self.ActivityTranslate[ ACT_MP_JUMP ] = ACT_HL2MP_JUMP_SLAM
|
||||
end
|
||||
|
||||
if ( t == "rpg" ) then
|
||||
self.ActivityTranslate[ ACT_MP_CROUCH_IDLE ] = ACT_HL2MP_IDLE_CROUCH_AR2
|
||||
self.ActivityTranslate[ ACT_MP_CROUCHWALK ] = ACT_HL2MP_WALK_CROUCH_AR2
|
||||
end
|
||||
|
||||
--self:SetupWeaponHoldTypeForAI( t )
|
||||
|
||||
end
|
||||
|
||||
-- Default hold pos is the pistol
|
||||
SWEP:SetWeaponHoldType( "pistol" )
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Name: weapon:TranslateActivity()
|
||||
Desc: Translate a player's Activity into a weapon's activity
|
||||
So for example, ACT_HL2MP_RUN becomes ACT_HL2MP_RUN_PISTOL
|
||||
Depending on how you want the player to be holding the weapon
|
||||
-----------------------------------------------------------]]
|
||||
function SWEP:TranslateActivity( act )
|
||||
|
||||
if ( self.Owner:IsNPC() ) then
|
||||
if ( self.ActivityTranslateAI[ act ] ) then
|
||||
return self.ActivityTranslateAI[ act ]
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
if ( self.ActivityTranslate[ act ] != nil ) then
|
||||
return self.ActivityTranslate[ act ]
|
||||
end
|
||||
|
||||
return -1
|
||||
|
||||
end
|
||||
end
|
|
@ -294,10 +294,15 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
|||
local wep2 = wep:BTable( true )
|
||||
local wep2c = wep:BClass( true )
|
||||
|
||||
for i=1, 2 do
|
||||
local hand = i==2
|
||||
if wep:BTable( hand ) then -- New Weapon HUD
|
||||
local wep_table = wep:BTable( hand )
|
||||
local wep_class = wep:BClass( hand )
|
||||
|
||||
if wep1 then -- New Weapon HUD
|
||||
local p_w, p_h = ss(156), ss(64)
|
||||
local p_x, p_y = sw - b - p_w, sh - b - p_h
|
||||
if hand then p_y = p_y - p_h - ss(20+4+4) end
|
||||
local pb = ss(4)
|
||||
local pb2 = pb*2
|
||||
|
||||
|
@ -309,37 +314,84 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
|||
surface.SetDrawColor( scheme["fg"] )
|
||||
surface.DrawRect( p_x+pb, p_y+pb, p_w-pb2, t_h )
|
||||
|
||||
draw.SimpleText( wep1c.Name, "Benny_16", p_x+ss(6), p_y+ss(5), scheme["bg"], TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( wep_class.Name, "Benny_16", p_x+ss(6), p_y+ss(5), scheme["bg"], TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
draw.SimpleText( wep:D_GetID( false ), "Benny_10", p_x+p_w-pb2, p_y+ss(7), scheme["bg"], TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( wep:D_GetID( hand ), "Benny_10", p_x+p_w-pb2, p_y+ss(7), scheme["bg"], TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||
|
||||
if wep:BClass( false ).Firemodes then -- Firemode
|
||||
if wep_class.Firemodes then -- Firemode
|
||||
surface.SetDrawColor( scheme["fg"] )
|
||||
surface.DrawRect( p_x+pb, p_y + pb + t_h + ss(2), ss(30), ss(10) )
|
||||
|
||||
draw.SimpleText( wep:B_FiremodeName( false ), "Benny_12", p_x + pb + ss(14.5), p_y + pb + t_h + ss(8), scheme["bg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||
draw.SimpleText( wep:B_FiremodeName( hand ), "Benny_12", p_x + pb + ss(14.5), p_y + pb + t_h + ss(8), scheme["bg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||
-- draw.SimpleText( "[AMMO TYPE]", "Benny_10", p_x + pb + ss(30+4), p_y + pb + t_h + ss(8), scheme["fg"], TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
|
||||
end
|
||||
if wep:BClass( false ).Ammo then -- Ammo
|
||||
if wep_class.Ammo then -- Ammo
|
||||
local b_w, b_h = ss(3), ss(10)
|
||||
local lw, lh = ss(2), ss(2)
|
||||
surface.SetDrawColor( scheme["fg"] )
|
||||
|
||||
local ammo = math.max( wep:Clip1(), wep:BClass( false ).Ammo )
|
||||
local ammo = math.max( wep:D_GetClip( hand ), wep_class.Ammo )
|
||||
if ammo>30 then b_w, b_h = ss(3), ss(4) end
|
||||
|
||||
local offset = b_h
|
||||
local count = 1
|
||||
for i=1, ammo do
|
||||
local thefunk = surface.DrawRect
|
||||
if i > wep:Clip1() then
|
||||
if i > wep:D_GetClip( hand ) then
|
||||
thefunk = surface.DrawOutlinedRect
|
||||
end
|
||||
if i!=1 and i%30 == 1 then
|
||||
count = 1
|
||||
offset = offset + b_h + lh
|
||||
end
|
||||
thefunk( p_x + p_w - b_w - pb - ((count-1)*(b_w+lw)), p_y + p_h - offset - pb, b_w, b_h, ss(0.5) )
|
||||
count = count + 1
|
||||
end
|
||||
draw.SimpleText( wep:D_GetClip( hand ), "Benny_12", p_x + p_w - pb - ss(1), p_y + p_h - offset - ss(12+3), scheme["fg"], TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||
end
|
||||
if wep_class.Ammo then -- Magazines
|
||||
local m_w, m_h = ss( 14 ), ss( 24 )
|
||||
local m_x, m_y = p_x + p_w - m_w, p_y - m_h - ss(1)--p_x - m_w, p_y + p_h - m_h
|
||||
local bb = ss( 1 )
|
||||
local b2 = ss( 2 )
|
||||
local b3 = ss( 3 )
|
||||
local b4 = ss( 4 )
|
||||
local maglist = p:INV_FindMag( "mag_" .. wep_table.Class, wep:D_GetMagID( hand ) )
|
||||
|
||||
if i%30 == 0 then
|
||||
count = 1
|
||||
offset = offset + b_h + lh
|
||||
local newmaglist = {}
|
||||
if wep:D_GetMagID( hand ) != "" then
|
||||
table.insert( newmaglist, wep:D_GetMagID( hand ) )
|
||||
end
|
||||
for i, v in ipairs( maglist ) do
|
||||
table.insert( newmaglist, v )
|
||||
end
|
||||
for id, tag in ipairs( newmaglist ) do
|
||||
assert( inv[tag], "That magazine doesn't exist." )
|
||||
local chunk = ((ss(1)+m_w)*(id-1))
|
||||
surface.SetDrawColor( scheme["bg"] )
|
||||
surface.DrawRect( m_x - chunk, m_y, m_w, m_h )
|
||||
|
||||
surface.SetDrawColor( scheme["fg"] )
|
||||
surface.DrawOutlinedRect( m_x + bb - chunk, m_y + bb, m_w - b2, m_h - b2, ss( 0.5 ) )
|
||||
|
||||
local perc = math.abs( math.cos( CurTime() ) )
|
||||
|
||||
local s1 = (m_h - b2 - b2)
|
||||
local s2 = (m_h - b2 - b2) * ( inv[tag].Ammo / WEAPONS[inv[tag].Class].Ammo )
|
||||
local s3 = math.floor( s2 - s1 )
|
||||
|
||||
local m1, m2, m3, m4 = m_x + bb + bb - chunk, m_y + bb + bb - s3, m_w - b2 - b2, s2
|
||||
local active = tag == wep:D_GetMagID( hand )
|
||||
if active then
|
||||
draw.SimpleText( "x", "Benny_10", m_x + (m_w/2) - chunk, m_y + (m_h/2), scheme["fg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||
end
|
||||
surface.DrawRect( m1, m2, m3, m4 )
|
||||
|
||||
if active then
|
||||
render.SetScissorRect( m1, m2, m1 + m3, m2 + m4, true )
|
||||
draw.SimpleText( "x", "Benny_10", m_x + (m_w/2) - chunk, m_y + (m_h/2), scheme["bg"], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||
render.SetScissorRect( 0, 0, 0, 0, false )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -426,8 +478,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
|||
end
|
||||
end
|
||||
|
||||
do -- Quickinv
|
||||
|
||||
if wep then -- Quickinv
|
||||
local inv = p:INV_Get()
|
||||
local gap = ss(1)
|
||||
local size_textx = ss(96)
|
||||
|
@ -676,14 +727,27 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
|||
end
|
||||
end
|
||||
|
||||
if false and p:BennyCheck() then
|
||||
if true and p:BennyCheck() then
|
||||
local bx, by = sw/2, sh*(0.75)
|
||||
local mx = 50
|
||||
|
||||
local wep1_table, wep1_class = wep:BTable( false ), wep:BClass( false )
|
||||
if wep1_table then
|
||||
draw.SimpleText( wep1_class.Name, "Trebuchet24", bx-mx, by+24*-1, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( "Clip1: " .. wep:Clip1(), "Trebuchet24", bx-mx, by+24*0, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( "ID1: " .. wep:GetWep1(), "Trebuchet24", bx-mx, by+24*1, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( "MagID1: " .. wep:D_GetMagID( false ), "Trebuchet24", bx-mx, by+24*2, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( "T_MagID1: " .. wep1_table.Loaded, "Trebuchet24", bx-mx, by+24*3, color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
|
||||
end
|
||||
|
||||
local wep2_table, wep2_class = wep:BTable( true ), wep:BClass( true )
|
||||
if wep2_table then
|
||||
draw.SimpleText( wep2_class.Name, "Trebuchet24", bx+mx, by+24*-1, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( "Clip2: " .. wep:Clip2(), "Trebuchet24", bx+mx, by+24*0, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( "ID2: " .. wep:GetWep2(), "Trebuchet24", bx+mx, by+24*1, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( "MagID2: " .. wep:D_GetMagID( true ), "Trebuchet24", bx+mx, by+24*2, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( "T_MagID2: " .. wep1_table.Loaded, "Trebuchet24", bx+mx, by+24*3, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
end
|
||||
end
|
||||
end )
|
||||
|
||||
|
|
|
@ -16,13 +16,15 @@ concommand.Add("benny_debug_give", function(ply, cmd, args)
|
|||
|
||||
local item = {
|
||||
Class = args[1],
|
||||
Loaded = 1,
|
||||
Ammo1 = class.Ammo,
|
||||
Ammo2 = class.Ammo,
|
||||
Ammo3 = class.Ammo,
|
||||
Acquisition = CurTime(),
|
||||
}
|
||||
|
||||
if class.Features == "firearm" then
|
||||
item.Loaded = ""
|
||||
elseif class.Features == "magazine" then
|
||||
item.Ammo = class.Ammo
|
||||
end
|
||||
|
||||
inv[str] = item
|
||||
|
||||
-- PROTO: WriteTable.
|
||||
|
@ -44,8 +46,18 @@ end, "arg 1: player ent index, arg 2: classname")
|
|||
|
||||
-- PROTO: Move this all into weapon code.
|
||||
concommand.Add("benny_inv_equip", function( ply, cmd, args )
|
||||
if ply:BennyCheck() then ply:GetActiveWeapon():BDeploy( false, args[1] ) end
|
||||
end)
|
||||
if ply:BennyCheck() then ply:GetActiveWeapon():BDeploy( args[2] and true or false, args[1] ) end
|
||||
end,
|
||||
function(cmd, args)
|
||||
args = string.Trim(args:lower())
|
||||
local meow = {}
|
||||
for i, v in SortedPairs( Entity(1):INV_Get() ) do
|
||||
if string.lower(i):find(args) then
|
||||
table.insert( meow, cmd .. " " .. i )
|
||||
end
|
||||
end
|
||||
return meow
|
||||
end, "arg 1: item id, arg 2 does offhand")
|
||||
|
||||
-- PROTO: Move this all into weapon code.
|
||||
concommand.Add("benny_inv_holster", function( ply, cmd, args )
|
||||
|
@ -200,6 +212,7 @@ if CLIENT then
|
|||
end
|
||||
|
||||
function button:DoRightClick()
|
||||
RunConsoleCommand( "benny_debug_give", "mag_" .. New.ClassName )
|
||||
end
|
||||
|
||||
function button:Paint( w, h )
|
||||
|
|
|
@ -75,20 +75,33 @@ SORTS = {
|
|||
["Acquisition"] = function( a, b ) return inv[b]["Acquisition"] > inv[a]["Acquisition"] end,
|
||||
}
|
||||
|
||||
function PT:INV_Find( class )
|
||||
function PT:INV_Find( class, exclude )
|
||||
local inv = self:INV_Get()
|
||||
local results = {}
|
||||
for i, v in pairs( inv ) do
|
||||
if v.Class == class then
|
||||
if v.Class == class and i != (exclude or "") then
|
||||
table.insert( results, i )
|
||||
end
|
||||
end
|
||||
-- PROTO: HOLY SHIT THIS SUCKS, MAKES A FUNCTION EVERY FRAME, AND MIGHT RUN EVERY FRAME!!!
|
||||
-- PROTO: HOLY SHIT THIS SUCKS, MAKES A FUNCTION AND MIGHT RUN EVERY FRAME!!!
|
||||
table.sort( results, function( a, b ) return inv[b]["Acquisition"] > inv[a]["Acquisition"] end )
|
||||
-- table.sort( results, SORTS["Acquisition"] )
|
||||
return results
|
||||
end
|
||||
|
||||
function PT:INV_FindMag( class, exclude )
|
||||
local inv = self:INV_Get()
|
||||
local results = {}
|
||||
for i, v in pairs( inv ) do
|
||||
if v.Class == class and i != (exclude or "") then
|
||||
table.insert( results, i )
|
||||
end
|
||||
end
|
||||
-- PROTO: HOLY SHIT THIS SUCKS, MAKES A FUNCTION AND MIGHT RUN EVERY FRAME!!!
|
||||
table.sort( results, function( a, b ) return (inv[b]["Ammo"] - (inv[b]["Acquisition"]/(2^16))) < (inv[a]["Ammo"] - (inv[a]["Acquisition"]/(2^16))) end )
|
||||
return results
|
||||
end
|
||||
|
||||
do
|
||||
local translat = {
|
||||
["melee"] = { 1, 1 },
|
||||
|
@ -101,6 +114,7 @@ do
|
|||
["grenade"] = { 6, 1 },
|
||||
["utility"] = { 6, 2 },
|
||||
["equipment"] = { 7, 1 },
|
||||
["magazine"] = { 8, 1 },
|
||||
}
|
||||
|
||||
-- PROTO: Cache this!
|
||||
|
@ -113,6 +127,7 @@ do
|
|||
[5] = {},
|
||||
[6] = {},
|
||||
[7] = {},
|
||||
[8] = {},
|
||||
}
|
||||
-- PROTO: HOLY SHIT THIS SUCKS, MAKES A FUNCTION EVERY FRAME, AND RUNS EVERY FRAME!!!
|
||||
local inv = self:INV_Get()
|
||||
|
@ -175,11 +190,14 @@ hook.Add("StartCommand", "Benny_INV_StartCommand", function( ply, cmd )
|
|||
|
||||
if id > 0 and inv_bucketlist[id] and inv[inv_bucketlist[id]] then
|
||||
wep:BDeploy( false, inv_bucketlist[ id ] )
|
||||
if CLIENT and IsFirstTimePredicted() and wep:D_GetID( false ) == inv_bucketlist[ply.CLIENTDESIRE] then
|
||||
if CLIENT and (wep:D_GetID( false ) == ply.CLIENTDESIRE) then
|
||||
ply.CLIENTDESIRE = 0
|
||||
print("Fixed")
|
||||
end
|
||||
end
|
||||
|
||||
wep:SetTempHandedness( cmd:KeyDown( IN_ZOOM ) )
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
|
@ -1331,3 +1331,22 @@ do -- Equipment, nothing here is guaranteed.
|
|||
}
|
||||
|
||||
end
|
||||
|
||||
-- Ammo generator
|
||||
|
||||
for class, data in pairs( WEAPONS ) do
|
||||
if data.Features == "firearm" then
|
||||
WEAPONS["mag_" .. class] = {
|
||||
Name = "MAG: " .. WEAPONS[class].Name,
|
||||
Description = "Magazine for the " .. WEAPONS[class].Name .. ".",
|
||||
Type = "magazine",
|
||||
|
||||
WModel = "models/weapons/w_pist_glock18.mdl",
|
||||
HoldType = "slam",
|
||||
|
||||
Ammo = WEAPONS[class].Ammo,
|
||||
|
||||
Features = "magazine",
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue