2018-05-02 06:32:59 +08:00
SWEP.Base = " weapon_zs_basemelee "
SWEP.PrintName = " Junk Pack "
SWEP.Description = " It's simply a pack of wooden junk kept together with some duct tape. \n Very useful for making barricades when no materials are around. \n Needs something like a hammer and nails to keep the things in place. "
SWEP.ViewModel = " models/weapons/c_aegiskit.mdl "
2014-10-02 08:49:54 +08:00
SWEP.WorldModel = " models/props_debris/wood_board06a.mdl "
2018-05-02 06:32:59 +08:00
SWEP.UseHands = true
2014-10-02 08:49:54 +08:00
SWEP.AmmoIfHas = true
2018-05-02 06:32:59 +08:00
SWEP.AllowEmpty = true
2014-10-02 08:49:54 +08:00
SWEP.Primary . ClipSize = 1
SWEP.Primary . Automatic = false
SWEP.Primary . Ammo = " SniperRound "
SWEP.Primary . Delay = 1
2018-05-02 06:32:59 +08:00
SWEP.Primary . DefaultClip = 4
2014-10-02 08:49:54 +08:00
2015-04-19 13:54:47 +08:00
SWEP.Secondary . ClipSize = 1
SWEP.Secondary . DefaultClip = 1
SWEP.Secondary . Ammo = " dummy "
2014-10-02 08:49:54 +08:00
SWEP.Secondary . Automatic = true
SWEP.Secondary . Delay = 0.15
SWEP.WalkSpeed = SPEED_NORMAL
SWEP.FullWalkSpeed = SPEED_SLOWEST
SWEP.JunkModels = {
Model ( " models/props_debris/wood_board04a.mdl " ) ,
Model ( " models/props_debris/wood_board06a.mdl " ) ,
Model ( " models/props_debris/wood_board02a.mdl " ) ,
Model ( " models/props_debris/wood_board01a.mdl " ) ,
Model ( " models/props_debris/wood_board07a.mdl " ) ,
Model ( " models/props_c17/furnituredrawer002a.mdl " ) ,
Model ( " models/props_c17/furnituredrawer003a.mdl " ) ,
Model ( " models/props_c17/furnituredrawer001a_chunk01.mdl " ) ,
Model ( " models/props_c17/furniturechair001a_chunk01.mdl " ) ,
Model ( " models/props_c17/furnituredrawer001a_chunk02.mdl " ) ,
Model ( " models/props_c17/furnituretable003a.mdl " ) ,
Model ( " models/props_c17/furniturechair001a.mdl " )
}
2018-05-02 06:32:59 +08:00
SWEP.HoldType = " physgun "
2014-10-02 08:49:54 +08:00
function SWEP : SetReplicatedAmmo ( count )
self : SetDTInt ( 0 , count )
end
function SWEP : GetReplicatedAmmo ( )
return self : GetDTInt ( 0 )
end
function SWEP : GetWalkSpeed ( )
if self : GetPrimaryAmmoCount ( ) > 0 then
return self.FullWalkSpeed
end
end
function SWEP : PrimaryAttack ( )
if not self : CanPrimaryAttack ( ) then return end
2018-05-02 06:32:59 +08:00
local aimvec = self : GetOwner ( ) : GetAimVector ( )
local shootpos = self : GetOwner ( ) : GetShootPos ( )
local tr = util.TraceLine ( { start = shootpos , endpos = shootpos + aimvec * 32 , filter = self : GetOwner ( ) } )
2014-10-02 08:49:54 +08:00
self : SetNextPrimaryAttack ( CurTime ( ) + self.Primary . Delay )
self : EmitSound ( " weapons/iceaxe/iceaxe_swing1.wav " , 75 , math.random ( 75 , 80 ) )
self : SendWeaponAnim ( ACT_VM_PRIMARYATTACK )
self.IdleAnimation = CurTime ( ) + math.min ( self.Primary . Delay , self : SequenceDuration ( ) )
if SERVER then
2018-05-02 06:32:59 +08:00
self : GetOwner ( ) : RestartGesture ( ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE )
2014-10-02 08:49:54 +08:00
local ent = ents.Create ( " prop_physics " )
if ent : IsValid ( ) then
local ang = aimvec : Angle ( )
ang : RotateAroundAxis ( ang : Forward ( ) , 90 )
ent : SetPos ( tr.HitPos )
ent : SetAngles ( ang )
2018-05-02 06:32:59 +08:00
ent : SetModel ( self.JunkModels [ math.random ( # self.JunkModels ) ] )
2014-10-02 08:49:54 +08:00
ent : Spawn ( )
ent : SetHealth ( 350 )
ent.NoVolumeCarryCheck = true
2018-05-02 06:32:59 +08:00
ent.NoDisTime = CurTime ( ) + 15
ent.NoDisOwner = self : GetOwner ( )
2014-10-02 08:49:54 +08:00
local phys = ent : GetPhysicsObject ( )
if phys : IsValid ( ) then
phys : SetMass ( math.min ( phys : GetMass ( ) , 50 ) )
2018-05-02 06:32:59 +08:00
phys : SetVelocityInstantaneous ( self : GetOwner ( ) : GetVelocity ( ) )
2014-10-02 08:49:54 +08:00
end
2018-05-02 06:32:59 +08:00
ent : SetPhysicsAttacker ( self : GetOwner ( ) )
2014-10-02 08:49:54 +08:00
self : TakePrimaryAmmo ( 1 )
end
end
end
function SWEP : SecondaryAttack ( )
end
function SWEP : Reload ( )
end
function SWEP : CanPrimaryAttack ( )
2018-05-02 06:32:59 +08:00
if self : GetOwner ( ) : IsHolding ( ) or self : GetOwner ( ) : GetBarricadeGhosting ( ) then return false end
2014-10-02 08:49:54 +08:00
2018-05-02 06:32:59 +08:00
if math.abs ( self : GetOwner ( ) : GetVelocity ( ) . z ) >= 256 then return false end
2014-10-02 08:49:54 +08:00
if self : GetPrimaryAmmoCount ( ) <= 0 then
self : SetNextPrimaryFire ( CurTime ( ) + self.Primary . Delay )
return false
end
return true
end
function SWEP : Think ( )
if self.IdleAnimation and self.IdleAnimation <= CurTime ( ) then
self.IdleAnimation = nil
self : SendWeaponAnim ( ACT_VM_IDLE )
end
if SERVER then
local count = self : GetPrimaryAmmoCount ( )
if count ~= self : GetReplicatedAmmo ( ) then
self : SetReplicatedAmmo ( count )
2018-05-02 06:32:59 +08:00
self : GetOwner ( ) : ResetSpeed ( )
2014-10-02 08:49:54 +08:00
end
end
end