summaryrefslogtreecommitdiff
path: root/entities/weapons/rad_sg552/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_sg552/shared.lua
downloadredead-2736f498f30220b858fc6fac23e7ddc4a597df6d.tar.gz
redead-2736f498f30220b858fc6fac23e7ddc4a597df6d.tar.bz2
redead-2736f498f30220b858fc6fac23e7ddc4a597df6d.zip
Inital commit
Diffstat (limited to 'entities/weapons/rad_sg552/shared.lua')
-rw-r--r--entities/weapons/rad_sg552/shared.lua159
1 files changed, 159 insertions, 0 deletions
diff --git a/entities/weapons/rad_sg552/shared.lua b/entities/weapons/rad_sg552/shared.lua
new file mode 100644
index 0000000..9d22ef2
--- /dev/null
+++ b/entities/weapons/rad_sg552/shared.lua
@@ -0,0 +1,159 @@
+if SERVER then
+
+ AddCSLuaFile("shared.lua")
+
+end
+
+if CLIENT then
+
+ SWEP.ViewModelFlip = true
+
+ SWEP.PrintName = "SG 552"
+ SWEP.IconLetter = "A"
+ SWEP.Slot = 4
+ SWEP.Slotpos = 2
+
+end
+
+SWEP.HoldType = "ar2"
+
+SWEP.Base = "rad_base"
+
+SWEP.ViewModel = "models/weapons/v_rif_sg552.mdl"
+SWEP.WorldModel = "models/weapons/w_rif_sg552.mdl"
+
+SWEP.SprintPos = Vector (-2.629, -4.8963, 1.4033)
+SWEP.SprintAng = Vector (-7.3401, -31.7536, 3.9563)
+
+SWEP.ZoomModes = { 0, 35 }
+SWEP.ZoomSpeeds = { 0.25, 0.35 }
+
+SWEP.IsSniper = true
+SWEP.AmmoType = "Rifle"
+
+SWEP.Primary.Sound = Sound( "Weapon_SG552.Single" )
+SWEP.Primary.Recoil = 6.5
+SWEP.Primary.Damage = 60
+SWEP.Primary.NumShots = 1
+SWEP.Primary.Cone = 0.005
+SWEP.Primary.SniperCone = 0.020
+SWEP.Primary.Delay = 0.210
+
+SWEP.Primary.ClipSize = 30
+SWEP.Primary.Automatic = true
+
+function SWEP:SetZoomMode( num )
+
+ if num > 2 then
+
+ num = 1
+
+ self.Weapon:UnZoom()
+
+ end
+
+ self.Weapon:SetNWInt( "Mode", num )
+ self.Owner:SetFOV( self.ZoomModes[num], self.ZoomSpeeds[num] )
+
+end
+
+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() - 1 )
+ 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, -1 )
+
+ end
+
+end
+
+function SWEP:DrawHUD()
+
+ if self.Weapon:ShouldNotDraw() then return end
+
+ local mode = self.Weapon:GetZoomMode()
+
+ local cone = self.Primary.Cone
+ local scale = cone
+
+ if mode == 1 then
+
+ cone = self.Primary.SniperCone
+ scale = cone
+
+ end
+
+ local x = ScrW() * 0.5
+ local y = ScrH() * 0.5
+ local scalebywidth = ( ScrW() / 1024 ) * 10
+
+ 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 = cone * 1.75
+
+ elseif self.Owner:KeyDown( IN_DUCK ) or self.Owner:KeyDown( IN_WALK ) then
+
+ scale = math.Clamp( cone / 1.75, 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() //20 * self.CrosshairScale
+
+ 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 )
+
+ if mode != 1 then
+
+ local w = ScrW()
+ local h = ScrH()
+ local wr = ( h / 3 ) * 4
+
+ surface.SetTexture( surface.GetTextureID( "gmod/scope" ) )
+ surface.SetDrawColor( 0, 0, 0, 255 )
+ surface.DrawTexturedRect( ( w / 2 ) - wr / 2, 0, wr, h )
+
+ surface.SetDrawColor( 0, 0, 0, 255 )
+ surface.DrawRect( 0, 0, ( w / 2 ) - wr / 2, h )
+ surface.DrawRect( ( w / 2 ) + wr / 2, 0, w - ( ( w / 2 ) + wr / 2 ), h )
+
+ end
+
+end \ No newline at end of file