summaryrefslogtreecommitdiff
path: root/entities/weapons/rad_cmp/shared.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-05-30 14:42:09 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-05-30 14:42:09 -0400
commit2736f498f30220b858fc6fac23e7ddc4a597df6d (patch)
tree374ceadedb654b00e09dac321620a8320830f734 /entities/weapons/rad_cmp/shared.lua
downloadredead-2736f498f30220b858fc6fac23e7ddc4a597df6d.tar.gz
redead-2736f498f30220b858fc6fac23e7ddc4a597df6d.tar.bz2
redead-2736f498f30220b858fc6fac23e7ddc4a597df6d.zip
Inital commit
Diffstat (limited to 'entities/weapons/rad_cmp/shared.lua')
-rw-r--r--entities/weapons/rad_cmp/shared.lua174
1 files changed, 174 insertions, 0 deletions
diff --git a/entities/weapons/rad_cmp/shared.lua b/entities/weapons/rad_cmp/shared.lua
new file mode 100644
index 0000000..35a68ef
--- /dev/null
+++ b/entities/weapons/rad_cmp/shared.lua
@@ -0,0 +1,174 @@
+if SERVER then
+
+ AddCSLuaFile("shared.lua")
+
+end
+
+if CLIENT then
+
+ SWEP.ViewModelFOV = 55
+ SWEP.ViewModelFlip = false
+
+ SWEP.PrintName = "CMP-250"
+ SWEP.IconLetter = "f"
+ SWEP.Slot = 3
+ SWEP.Slotpos = 1
+
+end
+
+SWEP.HoldType = "smg"
+
+SWEP.Base = "rad_base"
+
+SWEP.UseHands = true
+
+SWEP.ViewModel = "models/weapons/c_smg1.mdl"
+SWEP.WorldModel = "models/weapons/w_smg1.mdl"
+
+SWEP.SprintPos = Vector (3.6907, -0.6364, -0.5846)
+SWEP.SprintAng = Vector (-2.2928, 28.9069, 0)
+
+SWEP.IsSniper = false
+SWEP.AmmoType = "SMG"
+SWEP.FirstShot = true
+
+SWEP.Primary.Sound = Sound( "Weapon_smg1.Burst" )
+SWEP.Primary.Sound2 = Sound( "weapons/smg1/smg1_fireburst1.wav" )
+SWEP.Primary.ReloadSound = Sound( "Weapon_smg1.reload" )
+SWEP.Primary.Recoil = 12.5
+SWEP.Primary.Damage = 30
+SWEP.Primary.NumShots = 3
+SWEP.Primary.Cone = 0.045
+SWEP.Primary.Delay = 0.600
+
+SWEP.Primary.ClipSize = 18
+SWEP.Primary.Automatic = true
+
+function SWEP:PrimaryAttack()
+
+ if not self.Weapon:CanPrimaryAttack() then
+
+ self.Weapon:SetNextPrimaryFire( CurTime() + 0.25 )
+
+ return
+
+ end
+
+ self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
+ self.Weapon:EmitSound( self.Primary.Sound, 100, math.random(95,105) )
+ self.Weapon:SetClip1( self.Weapon:Clip1() - self.Primary.NumShots )
+ self.Weapon:ShootEffects()
+
+ if self.IsSniper and self.Weapon:GetZoomMode() == 1 then
+
+ self.Weapon:ShootBullets( self.Primary.Damage, self.Primary.NumShots, self.Primary.SniperCone, 1 )
+
+ else
+
+ self.Weapon:ShootBullets( self.Primary.Damage, self.Primary.NumShots, self.Primary.Cone, self.Weapon:GetZoomMode() )
+
+ end
+
+ if self.Weapon:GetZoomMode() > 1 then
+
+ self.Weapon:UnZoom()
+
+ end
+
+ if SERVER then
+
+ self.Owner:AddAmmo( self.AmmoType, self.Primary.NumShots * -1 )
+ self.Owner:EmitSound( self.Primary.Sound2, 100, math.random( 120, 130 ) )
+
+ end
+
+end
+
+function SWEP:CanPrimaryAttack()
+
+ if self.HolsterMode or self.ReloadTime or self.LastRunFrame > CurTime() then return false end
+
+ if self.Owner:GetNWInt( "Ammo" .. self.AmmoType, 0 ) < self.Primary.NumShots then
+
+ self.Weapon:EmitSound( self.Primary.Empty )
+
+ return false
+
+ end
+
+ if self.Weapon:Clip1() <= 0 then
+
+ self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
+ self.Weapon:DoReload()
+
+ if self.Weapon:GetZoomMode() != 1 then
+
+ self.Weapon:UnZoom()
+
+ end
+
+ return false
+
+ end
+
+ return true
+
+end
+
+--[[function SWEP:PrimaryAttack()
+
+ if not self.Weapon:CanPrimaryAttack() then
+
+ self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
+ return
+
+ end
+
+ if self.FirstShot then
+
+ self.Weapon:EmitSound( self.Primary.Sound, 100, math.random(95,105) )
+ self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.ShotDelay )
+ self.AutoShoot = CurTime() + self.Primary.ShotDelay
+
+ else
+
+ self.Owner:EmitSound( self.Primary.Sound2, 100, math.random(95,105) )
+ self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
+
+ end
+
+ self.FirstShot = !self.FirstShot
+
+ self.Weapon:ShootBullets( self.Primary.Damage, self.Primary.NumShots, self.Primary.Cone, self.Weapon:GetZoomMode() )
+ self.Weapon:TakePrimaryAmmo( 1 )
+ self.Weapon:ShootEffects()
+
+ if SERVER then
+
+ self.Owner:AddAmmo( self.AmmoType, -1 )
+
+ end
+
+end]]
+
+function SWEP:DoReload()
+
+ local time = self.Weapon:StartWeaponAnim( ACT_VM_RELOAD )
+
+ self.Weapon:SetNextPrimaryFire( CurTime() + time + 0.100 )
+ self.Weapon:EmitSound( self.Primary.ReloadSound )
+
+ self.ReloadTime = CurTime() + time
+
+end
+
+function SWEP:ReloadThink()
+
+ if self.ReloadTime and self.ReloadTime <= CurTime() then
+
+ self.ReloadTime = nil
+ self.Weapon:SetClip1( self.Primary.ClipSize )
+
+ end
+
+end \ No newline at end of file