summaryrefslogtreecommitdiff
path: root/entities/weapons/rad_base/shared.lua
diff options
context:
space:
mode:
Diffstat (limited to 'entities/weapons/rad_base/shared.lua')
-rw-r--r--entities/weapons/rad_base/shared.lua601
1 files changed, 300 insertions, 301 deletions
diff --git a/entities/weapons/rad_base/shared.lua b/entities/weapons/rad_base/shared.lua
index 63ef374..684572f 100644
--- a/entities/weapons/rad_base/shared.lua
+++ b/entities/weapons/rad_base/shared.lua
@@ -1,11 +1,11 @@
if SERVER then
AddCSLuaFile( "shared.lua" )
-
+
SWEP.Weight = 1
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
-
+
end
if CLIENT then
@@ -16,18 +16,18 @@ if CLIENT then
SWEP.ViewModelFOV = 75
SWEP.ViewModelFlip = true
-
+
SWEP.PrintName = "BASE WEAPON"
SWEP.IconLetter = "c"
SWEP.Slot = 0
SWEP.Slotpos = 0
-
+
SWEP.IconFont = "CSSelectIcons"
-
+
function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
//draw.SimpleText( self.IconLetter, self.IconFont, x + wide/2, y + tall/2.5, Color( 15, 20, 200, 255 ), TEXT_ALIGN_CENTER )
end
-
+
end
SWEP.HoldType = "pistol"
@@ -84,7 +84,7 @@ SWEP.FalloffDistances[ "Buckshot" ] = { Range = 300, Falloff = 500 }
SWEP.UseShellSounds = true
SWEP.ShellSounds = { "player/pl_shell1.wav", "player/pl_shell2.wav", "player/pl_shell3.wav" }
-SWEP.BuckshotShellSounds = { "weapons/fx/tink/shotgun_shell1.wav", "weapons/fx/tink/shotgun_shell2.wav", "weapons/fx/tink/shotgun_shell3.wav" }
+SWEP.BuckshotShellSounds = { "weapons/fx/tink/shotgun_shell1.wav", "weapons/fx/tink/shotgun_shell2.wav", "weapons/fx/tink/shotgun_shell3.wav" }
SWEP.Pitches = {}
SWEP.Pitches[ "Pistol" ] = 100
@@ -169,19 +169,19 @@ end
function SWEP:GetMoveScale( movetime, duration, mul )
mul = 1
-
+
if CurTime() - movetime < duration then
-
+
mul = math.Clamp( ( CurTime() - duration ) / movetime, 0, 1 )
-
+
end
-
+
if self.Weapon:GetNWBool( "ReverseAnim", false ) then
-
+
return -( mul - 1 ) ^ 3
-
+
end
-
+
return ( mul - 1 ) ^ 3 + 1
end
@@ -193,23 +193,23 @@ function SWEP:AngApproach( newang, ang, mul )
ang:RotateAroundAxis( ang:Right(), newang.x * mul )
ang:RotateAroundAxis( ang:Up(), newang.y * mul )
ang:RotateAroundAxis( ang:Forward(), newang.z * mul )
-
+
return ang
end
-function SWEP:PosApproach( newpos, pos, ang, mul )
+function SWEP:PosApproach( newpos, pos, ang, mul )
local right = ang:Right()
local up = ang:Up()
local forward = ang:Forward()
-
+
if not newpos then return pos end
pos = pos + newpos.x * right * mul
pos = pos + newpos.y * forward * mul
pos = pos + newpos.z * up * mul
-
+
return pos
end
@@ -218,7 +218,7 @@ function SWEP:MoveViewModelTo( newpos, newang, pos, ang, mul )
ang = self:AngApproach( newang, ang, mul )
pos = self:PosApproach( newpos, pos, ang, mul )
-
+
return pos, ang
end
@@ -226,40 +226,40 @@ end
function SWEP:Initialize()
self.Weapon:SetWeaponHoldType( self.HoldType )
-
+
end
function SWEP:Deploy()
if SERVER then
-
+
self.Weapon:SetZoomMode( 1 )
self.Owner:DrawViewModel( true )
-
- end
+
+ end
self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
-
+
return true
-
-end
+
+end
function SWEP:Holster()
-
+
return true
end
-function SWEP:Think()
+function SWEP:Think()
self.Weapon:ReloadThink()
if self.Owner:GetVelocity():Length() > 0 and self.Owner:KeyDown( IN_SPEED ) then
-
+
self.LastRunFrame = CurTime() + 0.3
-
+
self.Weapon:UnZoom()
-
+
end
end
@@ -267,19 +267,19 @@ end
function SWEP:SetZoomMode( num )
if num > #self.ZoomModes then
-
+
num = 1
self.Weapon:UnZoom()
-
+
end
-
+
self.Weapon:SetNWInt( "Mode", num )
-
+
if self.Owner:GetFOV() != self.ZoomModes[num] then
-
+
self.Owner:SetFOV( self.ZoomModes[num], self.ZoomSpeeds[num] )
-
+
end
end
@@ -287,7 +287,7 @@ end
function SWEP:GetZoomMode()
return self.Weapon:GetNWInt( "Mode", 1 )
-
+
end
function SWEP:UnZoom()
@@ -296,67 +296,67 @@ function SWEP:UnZoom()
self.Weapon:SetZoomMode( 1 )
self.Weapon:SetNWBool( "ReverseAnim", true )
-
+
self.Owner:DrawViewModel( true )
-
+
end
function SWEP:Reload()
if self.Weapon:Clip1() == self.Primary.ClipSize or self.Weapon:Clip1() > self.Owner:GetNWInt( "Ammo" .. self.AmmoType, 0 ) or self.HolsterMode or self.ReloadTime then return end
-
- if self.Owner:GetNWInt( "Ammo" .. self.AmmoType, 0 ) < 1 then
-
+
+ if self.Owner:GetNWInt( "Ammo" .. self.AmmoType, 0 ) < 1 then
+
self.Weapon:SetClip1( self.Primary.ClipSize )
-
+
return
-
+
end
if self.Weapon:GetZoomMode() != 1 then
-
+
self.Weapon:UnZoom()
-
- end
+
+ end
self.Weapon:DoReload()
-
+
end
function SWEP:StartWeaponAnim( anim )
-
+
if IsValid( self.Owner ) then
-
+
local vm = self.Owner:GetViewModel()
-
+
local idealSequence = self:SelectWeightedSequence( anim )
local nextSequence = self:FindTransitionSequence( self.Weapon:GetSequence(), idealSequence )
-
+
//vm:RemoveEffects( EF_NODRAW )
//vm:SetPlaybackRate( pbr )
if nextSequence > 0 then
-
+
vm:SendViewModelMatchingSequence( nextSequence )
-
+
else
-
+
vm:SendViewModelMatchingSequence( idealSequence )
-
+
end
return vm:SequenceDuration( vm:GetSequence() )
-
- end
-
+
+ end
+
end
function SWEP:DoReload()
local time = self.Weapon:StartWeaponAnim( ACT_VM_RELOAD )
-
+
self.Weapon:SetNextPrimaryFire( CurTime() + time + 0.080 )
-
+
self.ReloadTime = CurTime() + time
end
@@ -364,10 +364,10 @@ end
function SWEP:ReloadThink()
if self.ReloadTime and self.ReloadTime <= CurTime() then
-
+
self.ReloadTime = nil
self.Weapon:SetClip1( self.Primary.ClipSize )
-
+
end
end
@@ -377,120 +377,120 @@ function SWEP:CanSecondaryAttack()
if self.HolsterMode or self.Owner:KeyDown( IN_SPEED ) or self.LastRunFrame > CurTime() then return false end
if self.Weapon:Clip1() <= 0 and self.IsSniper then
-
+
if self.Weapon:GetZoomMode() != 1 then
-
+
self.Weapon:UnZoom()
-
+
end
-
+
return false
-
+
end
-
+
return true
-
+
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 ) < 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:Clip1() <= 0 then
-
+
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
self.Weapon:DoReload()
-
+
if self.Weapon:GetZoomMode() != 1 then
-
+
self.Weapon:UnZoom()
-
- end
-
+
+ end
+
return false
-
+
end
-
+
return true
-
+
end
-function SWEP:ShootEffects()
+function SWEP:ShootEffects()
if IsFirstTimePredicted() then
-
+
self.Owner:ViewPunch( Angle( math.Rand( -0.2, -0.1 ) * self.Primary.Recoil, math.Rand( -0.05, 0.05 ) * self.Primary.Recoil, 0 ) )
-
- end
-
- self.Owner:MuzzleFlash()
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
-
- self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
-
+
+ end
+
+ self.Owner:MuzzleFlash()
+ self.Owner:SetAnimation( PLAYER_ATTACK1 )
+
+ self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
+
if CLIENT then return end
-
+
if self.UseShellSounds then
-
+
local pitch = self.Pitches[ self.AmmoType ] + math.random( -3, 3 )
local tbl = self.ShellSounds
local pos = self.Owner:GetPos()
-
+
if self.AmmoType == "Buckshot" then
-
+
tbl = self.BuckshotShellSounds
-
+
end
-
+
timer.Simple( math.Rand( self.MinShellDelay, self.MaxShellDelay ), function() sound.Play( table.Random( tbl ), pos, 50, pitch ) end )
-
+
end
-
+
end
function SWEP:PrimaryAttack()
- if not self.Weapon:CanPrimaryAttack() then
-
+ if not self.Weapon:CanPrimaryAttack() then
+
self.Weapon:SetNextPrimaryFire( CurTime() + 0.25 )
-
- return
-
+
+ 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 )
-
+
end
end
@@ -498,31 +498,31 @@ end
function SWEP:SecondaryAttack()
if not self.Weapon:CanSecondaryAttack() then return end
-
+
self.Weapon:SetNextSecondaryFire( CurTime() + 0.25 )
-
+
if not self.IsSniper then
-
+
self.Weapon:ToggleLaser()
-
+
return
-
+
end
-
+
if SERVER then
-
+
if self.Weapon:GetZoomMode() == 1 then
-
+
self.Owner:DrawViewModel( false )
-
+
end
-
+
self.Weapon:SetZoomMode( self.Weapon:GetZoomMode() + 1 )
-
+
end
-
+
self.Weapon:EmitSound( self.Secondary.Sound )
-
+
end
function SWEP:ToggleLaser()
@@ -536,101 +536,101 @@ function SWEP:AdjustMouseSensitivity()
local num = self.Weapon:GetNWInt( "Mode", 1 )
local scale = ( self.ZoomModes[ num ] or 0 ) / 100
-
+
if scale == 0 then
-
+
return nil
-
+
end
return scale
-
-end
-function SWEP:GetDamageFalloffScale( distance )
+end
+
+function SWEP:GetDamageFalloffScale( distance )
+
+ local scale = 1
- local scale = 1
+ if distance > self.FalloffDistances[ self.AmmoType ].Range then
- if distance > self.FalloffDistances[ self.AmmoType ].Range then
+ scale = ( 1 - ( ( distance - self.FalloffDistances[ self.AmmoType ].Range ) / self.FalloffDistances[ self.AmmoType ].Falloff ) )
- scale = ( 1 - ( ( distance - self.FalloffDistances[ self.AmmoType ].Range ) / self.FalloffDistances[ self.AmmoType ].Falloff ) )
+ end
- end
-
return math.Clamp( scale, 0.1, 1.0 )
-
+
end
function SWEP:ShootBullets( damage, numbullets, aimcone, zoommode )
if SERVER then
-
+
self.Owner:AddStat( "Bullets", numbullets )
-
+
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.75, 0, 10 )
-
+
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.Force = damage * 2
bullet.Damage = damage
bullet.AmmoType = "Pistol"
-
+
//if self.IsSniper and self.AmmoType == "Sniper" then
-
+
//bullet.TracerName = "sniper_tracer"
-
+
//end
-
+
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 ( IsValid( tr.Entity ) and tr.Entity:IsPlayer() ) or math.random(1,5) != 1 then return end
-
+
self.Weapon:BulletPenetration( attacker, tr, dmginfo, 0 )
-
+
end
-
+
self.Owner:LagCompensation( true )
-
+
self.Owner:FireBullets( bullet )
-
+
self.Owner:LagCompensation( false )
-
+
end
function SWEP:GetPenetrationDistance( mat_type )
if ( mat_type == MAT_PLASTIC || mat_type == MAT_WOOD || mat_type == MAT_ALIENFLESH || mat_type == MAT_FLESH || mat_type == MAT_GLASS ) then
-
+
return 64
-
+
end
-
+
return 32
-
+
end
function SWEP:GetPenetrationDamageLoss( mat_type, distance, damage )
@@ -642,168 +642,168 @@ function SWEP:GetPenetrationDamageLoss( mat_type, distance, damage )
elseif( mat_type == MAT_TILE || mat_type == MAT_SAND || mat_type == MAT_DIRT ) then
return damage - ( distance * 1.2 )
end
-
+
return damage - ( distance * 1.8 )
-
+
end
--[[function SWEP:BulletPenetration( attacker, tr, dmginfo, bounce )
if ( !self or !IsValid( self.Weapon ) ) then return end
-
- if IsValid( tr.Entity ) and string.find( tr.Entity:GetClass(), "npc" ) then
-
- local effectdata = EffectData()
- effectdata:SetOrigin( tr.HitPos )
- util.Effect( "BloodImpact", effectdata )
-
- end
-
+
+ if IsValid( tr.Entity ) and string.find( tr.Entity:GetClass(), "npc" ) then
+
+ local effectdata = EffectData()
+ effectdata:SetOrigin( tr.HitPos )
+ util.Effect( "BloodImpact", effectdata )
+
+ end
+
// Don't go through more than 3 times
if ( bounce > 3 ) then return false end
-
+
// Direction (and length) that we are gonna penetrate
local PeneDir = tr.Normal * self:GetPenetrationDistance( tr.MatType )
-
+
local PeneTrace = {}
PeneTrace.endpos = tr.HitPos
PeneTrace.start = tr.HitPos + PeneDir
PeneTrace.mask = MASK_SHOT
PeneTrace.filter = { self.Owner }
-
- local PeneTrace = util.TraceLine( PeneTrace )
-
+
+ local PeneTrace = util.TraceLine( PeneTrace )
+
// Bullet didn't penetrate.
if ( PeneTrace.StartSolid or PeneTrace.Fraction >= 1.0 or tr.Fraction <= 0.0 ) then return false end
-
+
local distance = ( PeneTrace.HitPos - tr.HitPos ):Length()
local new_damage = self:GetPenetrationDamageLoss( tr.MatType, distance, dmginfo:GetDamage() )
-
+
if new_damage > 0 then
-
- local bullet =
- {
+
+ local bullet =
+ {
Num = 1,
Src = PeneTrace.HitPos,
- Dir = tr.Normal,
+ Dir = tr.Normal,
Spread = Vector( 0, 0, 0 ),
Tracer = 0,
Force = 5,
Damage = new_damage,
AmmoType = "Pistol",
}
-
+
bullet.Callback = function ( attacker, tr, dmginfo )
-
+
if IsValid( self ) and IsValid( self.Weapon ) then
-
+
self.Weapon:BulletPenetration( attacker, tr, dmginfo, bounce + 1 )
-
+
end
-
+
end
-
+
local effectdata = EffectData()
effectdata:SetOrigin( PeneTrace.HitPos )
effectdata:SetNormal( PeneTrace.Normal )
- util.Effect( "Impact", effectdata )
-
+ util.Effect( "Impact", effectdata )
+
local func = function( attacker, bullet )
-
+
if IsValid( attacker ) then
-
+
attacker.FireBullets( attacker, bullet, true )
-
+
end
-
+
end
-
+
timer.Simple( 0.05, function() func( attacker, bullet ) end )
-
+
if SERVER and tr.MatType != MAT_FLESH then
-
+
sound.Play( table.Random( GAMEMODE.Ricochet ), tr.HitPos, 100, math.random(90,120) )
-
+
end
-
+
end
-
+
end]]
function SWEP:BulletPenetration( attacker, tr, dmginfo, bounce )
if ( !self or not IsValid( self.Weapon ) ) then return end
-
- if IsValid( tr.Entity ) and string.find( tr.Entity:GetClass(), "npc" ) then
-
- local effectdata = EffectData()
- effectdata:SetOrigin( tr.HitPos )
- util.Effect( "BloodImpact", effectdata )
-
- end
-
+
+ if IsValid( tr.Entity ) and string.find( tr.Entity:GetClass(), "npc" ) then
+
+ local effectdata = EffectData()
+ effectdata:SetOrigin( tr.HitPos )
+ util.Effect( "BloodImpact", effectdata )
+
+ end
+
if ( bounce > 3 ) then return false end
-
+
local PeneDir = tr.Normal * self:GetPenetrationDistance( tr.MatType )
-
+
local PeneTrace = {}
PeneTrace.endpos = tr.HitPos
PeneTrace.start = tr.HitPos + PeneDir
PeneTrace.mask = MASK_SHOT
PeneTrace.filter = { self.Owner }
-
- local PeneTrace = util.TraceLine( PeneTrace )
-
+
+ local PeneTrace = util.TraceLine( PeneTrace )
+
if ( PeneTrace.StartSolid || PeneTrace.Fraction >= 1.0 || tr.Fraction <= 0.0 ) then return false end
-
+
local distance = ( PeneTrace.HitPos - tr.HitPos ):Length()
local new_damage = self:GetPenetrationDamageLoss( tr.MatType, distance, dmginfo:GetDamage() )
-
+
if new_damage > 0 then
-
- local bullet =
- {
+
+ local bullet =
+ {
Num = 1,
Src = PeneTrace.HitPos,
- Dir = tr.Normal,
+ Dir = tr.Normal,
Spread = Vector( 0, 0, 0 ),
Tracer = 0,
Force = 5,
Damage = new_damage,
AmmoType = "Pistol",
}
-
- bullet.Callback = function( a, b, c )
-
+
+ bullet.Callback = function( a, b, c )
+
if IsValid( self ) and IsValid( self.Weapon ) then
-
+
self.Weapon:BulletPenetration( attacker, tr, dmginfo, bounce + 1 )
-
- end
-
+
+ end
+
end
-
+
local effectdata = EffectData()
effectdata:SetOrigin( PeneTrace.HitPos );
effectdata:SetNormal( PeneTrace.Normal );
- util.Effect( "Impact", effectdata )
-
+ util.Effect( "Impact", effectdata )
+
timer.Simple( 0.01, function() attacker:FireBullets( bullet, true ) end )
-
+
if SERVER and tr.MatType != MAT_FLESH and bounce == 0 then
-
+
sound.Play( table.Random( GAMEMODE.Ricochet ), tr.HitPos, 100, math.random(90,120) )
-
+
end
-
+
end
-
+
end
function SWEP:ShouldNotDraw()
return self.Weapon:GetNWBool( "Laser", false )
-
+
end
if CLIENT then
@@ -813,7 +813,7 @@ if CLIENT then
SWEP.CrossBlue = CreateClientConVar( "cl_redead_crosshair_b", 255, true, false )
SWEP.CrossAlpha = CreateClientConVar( "cl_redead_crosshair_a", 255, true, false )
SWEP.CrossLength = CreateClientConVar( "cl_redead_crosshair_length", 10, true, false )
-
+
SWEP.DotMat = Material( "Sprites/light_glow02_add_noz" )
SWEP.LasMat = Material( "sprites/bluelaser1" )
@@ -824,120 +824,120 @@ SWEP.CrosshairScale = 1
function SWEP:LaserDraw()
local vm = self.Owner:GetViewModel()
-
+
if IsValid( vm ) then
-
+
local idx = vm:LookupAttachment( "1" )
-
+
if idx == 0 then idx = vm:LookupAttachment( "muzzle" ) end
-
+
local trace = util.GetPlayerTrace( ply )
local tr = util.TraceLine( trace )
local tbl = vm:GetAttachment( idx )
-
+
local pos = tr.HitPos
-
+
if vm:GetSequence() != ACT_VM_IDLE then
-
+
self.AngDiff = ( tbl.Ang - self.LastGoodAng ):Forward()
-
+
trace = {}
trace.start = tbl.Pos or Vector(0,0,0)
trace.endpos = trace.start + ( ( EyeAngles() + self.AngDiff ):Forward() * 99999 )
trace.filter = { self.Owner, self.Weapon }
-
+
local tr2 = util.TraceLine( trace )
-
+
pos = tr2.HitPos
-
+
else
-
+
self.LastGoodAng = tbl.Ang
-
+
end
-
+
cam.Start3D( EyePos(), EyeAngles() )
-
+
local dir = ( tbl.Ang ):Forward()
local start = tbl.Pos
-
+
render.SetMaterial( self.LasMat )
-
+
for i=0,254 do
-
+
render.DrawBeam( start, start + dir * 5, 2, 0, 12, Color( 255, 0, 0, 255 - i ) )
-
+
start = start + dir * 5
-
+
end
-
+
local dist = tr.HitPos:Distance( EyePos() )
local size = math.Rand( 6, 7 )
local dotsize = dist / size ^ 2
-
+
render.SetMaterial( self.DotMat )
render.DrawQuadEasy( pos, ( EyePos() - tr.HitPos ):GetNormal(), dotsize, dotsize, Color( 255, 0, 0, 255 ), 0 )
-
+
cam.End3D()
-
- end
+
+ end
end
function SWEP:DrawHUD()
if self.Weapon:ShouldNotDraw() then return end
-
+
if self.Weapon:GetNWBool( "Laser", false ) then return end
-
+
local mode = self.Weapon:GetZoomMode()
if not self.IsSniper or mode == 1 then
-
+
local cone = self.Primary.Cone
local scale = cone
-
+
if self.IsSniper 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 )
-
+
return
-
+
end
-
+
if mode != 1 then
-
+
local w = ScrW()
local h = ScrH()
local wr = ( h / 3 ) * 4
@@ -945,14 +945,13 @@ function SWEP:DrawHUD()
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 )
surface.DrawLine( 0, h * 0.50, w, h * 0.50 )
surface.DrawLine( w * 0.50, 0, w * 0.50, h )
-
+
end
-
-end
+end