summaryrefslogtreecommitdiff
path: root/entities/weapons/rad_m1014
diff options
context:
space:
mode:
Diffstat (limited to 'entities/weapons/rad_m1014')
-rw-r--r--entities/weapons/rad_m1014/shared.lua196
1 files changed, 98 insertions, 98 deletions
diff --git a/entities/weapons/rad_m1014/shared.lua b/entities/weapons/rad_m1014/shared.lua
index 9d4ca65..2b176a5 100644
--- a/entities/weapons/rad_m1014/shared.lua
+++ b/entities/weapons/rad_m1014/shared.lua
@@ -1,18 +1,18 @@
if SERVER then
AddCSLuaFile("shared.lua")
-
+
end
if CLIENT then
SWEP.ViewModelFlip = true
-
+
SWEP.PrintName = "M1014 Shotgun"
SWEP.IconLetter = "B"
SWEP.Slot = 3
SWEP.Slotpos = 3
-
+
end
SWEP.HoldType = "shotgun"
@@ -45,64 +45,64 @@ function SWEP:Deploy()
self.Weapon:SetNextPrimaryFire( CurTime() + 0.3 )
if SERVER then
-
+
self.Weapon:SetZoomMode( 1 )
-
- end
-
+
+ end
+
self.InIron = false
self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
-
+
return true
-
-end
+
+end
function SWEP:CanPrimaryAttack()
if self.HolsterMode or self.LastRunFrame > CurTime() then return false end
-
- if self.Owner:GetNWInt( "Ammo"..self.AmmoType, 0 ) < 1 then
-
+
+ if self.Owner:GetNWInt( "Ammo"..self.AmmoType, 0 ) < 1 then
+
self.Weapon:EmitSound( self.Primary.Empty )
- return false
-
+ return false
+
end
-
+
if self.Weapon:GetNWBool( "Reloading", false ) then
-
+
self.Weapon:SetNWBool( "Reloading", false )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
-
+
self.Weapon:SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH )
-
+
return false
-
+
end
if self.Weapon:Clip1() <= 0 then
-
+
self.Weapon:SetNWBool( "Reloading", true )
self.Weapon:SetVar( "ReloadTimer", CurTime() + 0.5 )
self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
-
+
return false
-
+
end
-
+
return true
-
+
end
function SWEP:PrimaryAttack()
- if not self.Weapon:CanPrimaryAttack() then
-
+ if not self.Weapon:CanPrimaryAttack() then
+
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
- return
-
+ return
+
end
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
@@ -110,17 +110,17 @@ function SWEP:PrimaryAttack()
self.Weapon:ShootBullets( self.Primary.Damage, self.Primary.NumShots, self.Primary.Cone, self.Weapon:GetZoomMode() )
self.Weapon:TakePrimaryAmmo( 1 )
self.Weapon:ShootEffects()
-
+
if self.Weapon:GetZoomMode() > 1 then
-
+
self.Weapon:UnZoom()
-
+
end
-
+
if SERVER then
-
+
self.Owner:AddAmmo( self.AmmoType, -1 )
-
+
end
end
@@ -128,73 +128,73 @@ end
function SWEP:Reload()
if self.HolsterMode or self.Weapon:Clip1() == self.Primary.ClipSize then return end
-
+
if self.Weapon:Clip1() < self.Primary.ClipSize and not self.Weapon:GetNWBool( "Reloading", false ) then
-
+
self.Weapon:SetNWBool( "Reloading", true )
self.Weapon:SetVar( "ReloadTimer", CurTime() + 0.5 )
self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
-
+
end
-
+
end
function SWEP:Think()
if self.Owner:KeyDown( IN_WALK ) and self.HolsterTime < CurTime() then
-
+
self.HolsterTime = CurTime() + 2
--[[self.HolsterMode = !self.HolsterMode
-
+
if self.HolsterMode then
-
+
self.Owner:SetLuaAnimation( self.HoldType )
-
+
else
-
+
self.Owner:StopAllLuaAnimations( 0.5 )
-
+
end]]
-
+
end
if self.Weapon:GetNWBool( "Reloading", false ) then
-
+
if self.Weapon:GetVar( "ReloadTimer", 0 ) < CurTime() then
-
+
// Finsished reload
if self.Weapon:Clip1() >= self.Primary.ClipSize then
-
+
self.Weapon:SetNWBool( "Reloading", false )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
-
+
self.Weapon:SendWeaponAnim( ACT_SHOTGUN_RELOAD_FINISH )
-
+
return
-
+
end
-
+
// Next cycle
self.Weapon:SetVar( "ReloadTimer", CurTime() + 0.75 )
self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
-
+
// Add ammo
self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
-
+
end
-
+
end
if self.Owner:GetVelocity():Length() > 0 then
-
+
if self.Owner:KeyDown( IN_SPEED ) then
-
+
self.LastRunFrame = CurTime() + 0.3
-
+
end
-
+
end
end
@@ -202,61 +202,61 @@ end
function SWEP:ShootBullets( damage, numbullets, aimcone, zoommode )
if SERVER then
-
+
self.Owner:AddStat( "Bullets", 1 )
-
+
end
local scale = aimcone
-
+
if self.Owner:KeyDown( IN_FORWARD ) or self.Owner:KeyDown( IN_BACK ) or self.Owner:KeyDown( IN_MOVELEFT ) or self.Owner:KeyDown( IN_MOVERIGHT ) then
-
+
scale = aimcone * 1.75
-
+
elseif self.Owner:KeyDown( IN_DUCK ) or self.Owner:KeyDown( IN_WALK ) then
-
+
scale = math.Clamp( aimcone / 1.25, 0, 10 )
-
+
end
-
+
local tracer = 1
-
+
if ( zoommode or 1 ) > 1 then
-
+
tracer = 0
-
+
end
-
+
local bullet = {}
bullet.Num = numbullets
- bullet.Src = self.Owner:GetShootPos()
- bullet.Dir = self.Owner:GetAimVector()
- bullet.Spread = Vector( scale, scale, 0 )
+ bullet.Src = self.Owner:GetShootPos()
+ bullet.Dir = self.Owner:GetAimVector()
+ bullet.Spread = Vector( scale, scale, 0 )
bullet.Tracer = 0
- bullet.Force = damage * 2
- bullet.Damage = damage
+ bullet.Force = damage * 2
+ bullet.Damage = damage
bullet.AmmoType = "Pistol"
bullet.TracerName = tracername
bullet.Callback = function ( attacker, tr, dmginfo )
-
+
dmginfo:ScaleDamage( self:GetDamageFalloffScale( tr.HitPos:Distance( self.Owner:GetShootPos() ) ) )
-
+
if tr.Entity.NextBot then
-
+
tr.Entity:OnLimbHit( tr.HitGroup, dmginfo )
-
+
end
-
+
if math.random(1,6) == 1 then
-
+
self.Weapon:BulletPenetration( attacker, tr, dmginfo, 0 )
-
+
end
end
-
+
self.Owner:FireBullets( bullet )
-
+
end
function SWEP:DrawHUD()
@@ -264,36 +264,36 @@ function SWEP:DrawHUD()
if self.Weapon:ShouldNotDraw() then return end
if not self.IsSniper and not self.Owner:GetNWBool( "InIron", false ) then
-
+
local x = ScrW() * 0.5
local y = ScrH() * 0.5
local scalebywidth = ( ScrW() / 1024 ) * 10
local scale = self.Primary.Cone
-
+
if self.Owner:KeyDown( IN_FORWARD ) or self.Owner:KeyDown( IN_BACK ) or self.Owner:KeyDown( IN_MOVELEFT ) or self.Owner:KeyDown( IN_MOVERIGHT ) then
-
+
scale = self.Primary.Cone * 1.75
-
+
elseif self.Owner:KeyDown( IN_DUCK ) or self.Owner:KeyDown( IN_WALK ) then
-
+
scale = math.Clamp( self.Primary.Cone / 1.25, 0, 10 )
-
+
end
-
+
scale = scale * scalebywidth
-
+
local dist = math.abs( self.CrosshairScale - scale )
self.CrosshairScale = math.Approach( self.CrosshairScale, scale, FrameTime() * 2 + dist * 0.05 )
-
+
local gap = 40 * self.CrosshairScale
local length = gap + self.CrossLength:GetInt()
-
+
surface.SetDrawColor( self.CrossRed:GetInt(), self.CrossGreen:GetInt(), self.CrossBlue:GetInt(), self.CrossAlpha:GetInt() )
surface.DrawLine( x - length, y, x - gap, y )
surface.DrawLine( x + length, y, x + gap, y )
surface.DrawLine( x, y - length, x, y - gap )
surface.DrawLine( x, y + length, x, y + gap )
-
+
end
-
+
end