Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.

Commit 3a8a17d

Browse files
committed
Fixed weapon prediction
- Fixed weapon prediction - Added secondary sound to AUG - Fixed small gaps while zooming (AUG and AWP) - Respect "Lowered ironsights"
1 parent 4e73290 commit 3a8a17d

File tree

4 files changed

+61
-56
lines changed

4 files changed

+61
-56
lines changed

Diff for: lua/weapons/weapon_ghost_augbar.lua

+24-19
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ SWEP.HeadshotMultiplier = 2.5
4242
SWEP.Secondary.Automatic = false
4343
SWEP.UseHands = true
4444
SWEP.Secondary.Ammo = "none"
45+
SWEP.Secondary.Sound = Sound("Default.Zoom")
4546

4647
SWEP.ScopeZooms = {1}
4748
SWEP.ViewModel = Model("models/weapons/cstrike/c_rif_aug.mdl")
@@ -52,15 +53,13 @@ SWEP.IronSightsAng = Vector( 2.6, 1.37, 3.5 )
5253
SWEP.IronSightZoom = 1
5354

5455
function SWEP:SetZoom(state)
55-
if CLIENT then
56-
return
57-
else
58-
if state then
59-
self:GetOwner():SetFOV(20, 0.3)
60-
else
61-
self:GetOwner():SetFOV(0, 0.2)
62-
end
63-
end
56+
if IsValid(self:GetOwner()) and self:GetOwner():IsPlayer() then
57+
if state then
58+
self:GetOwner():SetFOV(20, 0.3)
59+
else
60+
self:GetOwner():SetFOV(0, 0.2)
61+
end
62+
end
6463
end
6564

6665
-- Add some zoom to ironsights for this gun
@@ -72,10 +71,10 @@ function SWEP:SecondaryAttack()
7271

7372
self:SetIronsights( bIronsights )
7473

75-
if SERVER then
76-
self:SetZoom(bIronsights)
77-
else
78-
end
74+
self:SetZoom(bIronsights)
75+
if (CLIENT) then
76+
self:EmitSound(self.Secondary.Sound)
77+
end
7978

8079
self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
8180
end
@@ -104,10 +103,12 @@ if CLIENT then
104103
function SWEP:DrawHUD()
105104
if self:GetIronsights() then
106105
surface.SetDrawColor( 0, 0, 0, 255 )
106+
local scrW = ScrW()
107+
local scrH = ScrH()
107108

108-
local x = ScrW() / 2.0
109-
local y = ScrH() / 2.0
110-
local scope_size = ScrH()
109+
local x = scrW / 2.0
110+
local y = scrH / 2.0
111+
local scope_size = scrH
111112

112113
-- crosshair
113114
local gap = 80
@@ -130,6 +131,10 @@ if CLIENT then
130131
local w = (x - sh) + 2
131132
surface.DrawRect(0, 0, w, scope_size)
132133
surface.DrawRect(x + sh - 2, 0, w, scope_size)
134+
135+
-- cover gaps on top and bottom of screen
136+
surface.DrawLine( 0, 0, scrW, 0 )
137+
surface.DrawLine( 0, scrH - 1, scrW, scrH - 1 )
133138

134139
surface.SetDrawColor(255, 0, 0, 255)
135140
surface.DrawLine(x, y, x + 1, y + 1)
@@ -139,12 +144,12 @@ if CLIENT then
139144
surface.SetDrawColor(255, 255, 255, 255)
140145

141146
surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0)
142-
143147
else
144148
return self.BaseClass.DrawHUD(self)
145149
end
146150
end
151+
147152
function SWEP:AdjustMouseSensitivity()
148-
return (self:GetIronsights() and 0.2) or nil
153+
return (self:GetIronsights() and 0.2) or nil
149154
end
150-
end
155+
end

Diff for: lua/weapons/weapon_ghost_awp.lua

+21-18
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ SWEP.IronSightsPos = Vector( 5, -15, -2 )
3838
SWEP.IronSightsAng = Vector( 2.6, 1.37, 3.5 )
3939

4040
function SWEP:SetZoom(state)
41-
if CLIENT then
42-
return
43-
else
44-
if state then
45-
self:GetOwner():SetFOV(20, 0.3)
46-
else
47-
self:GetOwner():SetFOV(0, 0.2)
48-
end
49-
end
41+
if IsValid(self:GetOwner()) and self:GetOwner():IsPlayer() then
42+
if state then
43+
self:GetOwner():SetFOV(20, 0.3)
44+
else
45+
self:GetOwner():SetFOV(0, 0.2)
46+
end
47+
end
5048
end
5149

5250
-- Add some zoom to ironsights for this gun
@@ -58,11 +56,10 @@ function SWEP:SecondaryAttack()
5856

5957
self:SetIronsights( bIronsights )
6058

61-
if SERVER then
62-
self:SetZoom(bIronsights)
63-
else
64-
self:EmitSound(self.Secondary.Sound)
65-
end
59+
self:SetZoom(bIronsights)
60+
if (CLIENT) then
61+
self:EmitSound(self.Secondary.Sound)
62+
end
6663

6764
self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
6865
end
@@ -74,6 +71,7 @@ function SWEP:PreDrop()
7471
end
7572

7673
function SWEP:Reload()
74+
if ( self:Clip1() == self.Primary.ClipSize or self:GetOwner():GetAmmoCount( self.Primary.Ammo ) <= 0 ) then return end
7775
self.Weapon:DefaultReload(ACT_VM_RELOAD)
7876
self:SetIronsights( false )
7977
self:SetZoom(false)
@@ -90,10 +88,12 @@ if CLIENT then
9088
function SWEP:DrawHUD()
9189
if self:GetIronsights() then
9290
surface.SetDrawColor( 0, 0, 0, 255 )
91+
local scrW = ScrW()
92+
local scrH = ScrH()
9393

94-
local x = ScrW() / 2.0
95-
local y = ScrH() / 2.0
96-
local scope_size = ScrH()
94+
local x = scrW / 2.0
95+
local y = scrH / 2.0
96+
local scope_size = scrH
9797

9898
-- crosshair
9999
local gap = 80
@@ -116,6 +116,10 @@ if CLIENT then
116116
local w = (x - sh) + 2
117117
surface.DrawRect(0, 0, w, scope_size)
118118
surface.DrawRect(x + sh - 2, 0, w, scope_size)
119+
120+
-- cover gaps on top and bottom of screen
121+
surface.DrawLine( 0, 0, scrW, 0 )
122+
surface.DrawLine( 0, scrH - 1, scrW, scrH - 1 )
119123

120124
surface.SetDrawColor(255, 0, 0, 255)
121125
surface.DrawLine(x, y, x + 1, y + 1)
@@ -125,7 +129,6 @@ if CLIENT then
125129
surface.SetDrawColor(255, 255, 255, 255)
126130

127131
surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0)
128-
129132
else
130133
return self.BaseClass.DrawHUD(self)
131134
end

Diff for: lua/weapons/weapon_ghost_base.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ function SWEP:PrimaryAttack(worldsnd)
255255
local owner = self:GetOwner()
256256
if not IsValid(owner) or owner:IsNPC() or (not owner.ViewPunch) then return end
257257

258-
owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) * self.Primary.Recoil, 0 ) )
258+
owner:ViewPunch( Angle( util.SharedRandom(self:GetClass(),-0.2,-0.1,0) * self.Primary.Recoil, util.SharedRandom(self:GetClass(),-0.1,0.1,1) * self.Primary.Recoil, 0 ) )
259259
end
260260

261261
function SWEP:DryFire(setnext)
@@ -321,7 +321,6 @@ function SWEP:ShootBullet( dmg, recoil, numbul, cone )
321321
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
322322
-- self:GetOwner():SetAnimation( PLAYER_ATTACK1 )
323323

324-
if not IsFirstTimePredicted() then return end
325324

326325
local sights = self:GetIronsights()
327326

@@ -397,7 +396,6 @@ function SWEP:DrawWeaponSelection() end
397396
function SWEP:SecondaryAttack()
398397

399398
if self.NoSights or (not self.IronSightsPos) then return end
400-
--if self:GetNextSecondaryFire() > CurTime() then return end
401399

402400
self:SetIronsights(not self:GetIronsights())
403401

@@ -410,6 +408,7 @@ function SWEP:Deploy()
410408
end
411409

412410
function SWEP:Reload()
411+
if ( self:Clip1() == self.Primary.ClipSize or self:GetOwner():GetAmmoCount( self.Primary.Ammo ) <= 0 ) then return end
413412
self.Weapon:DefaultReload(self.ReloadAnim)
414413
self:SetIronsights( false )
415414
end
@@ -544,6 +543,7 @@ function SWEP:DyingShot()
544543
return fired
545544
end
546545

546+
local ttt_lowered = CreateConVar("ttt_ironsights_lowered", "1", FCVAR_ARCHIVE)
547547
local LOWER_POS = Vector(0, 0, -2)
548548

549549
local IRONSIGHT_TIME = 0.25
@@ -580,7 +580,7 @@ function SWEP:GetViewModelPosition( pos, ang )
580580
if not bIron then mul = 1 - mul end
581581
end
582582

583-
local offset = self.IronSightsPos + vector_origin
583+
local offset = self.IronSightsPos + (ttt_lowered:GetBool() and LOWER_POS or vector_origin)
584584

585585
if self.IronSightsAng then
586586
ang = ang * 1

Diff for: lua/weapons/weapon_ghost_rifle.lua

+12-15
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,13 @@ SWEP.IronSightsPos = Vector( 5, -15, -2 )
4545
SWEP.IronSightsAng = Vector( 2.6, 1.37, 3.5 )
4646

4747
function SWEP:SetZoom(state)
48-
if CLIENT then
49-
return
50-
else
51-
if state then
52-
self:GetOwner():SetFOV(20, 0.3)
53-
else
54-
self:GetOwner():SetFOV(0, 0.2)
55-
end
56-
end
48+
if IsValid(self:GetOwner()) and self:GetOwner():IsPlayer() then
49+
if state then
50+
self:GetOwner():SetFOV(20, 0.3)
51+
else
52+
self:GetOwner():SetFOV(0, 0.2)
53+
end
54+
end
5755
end
5856

5957
-- Add some zoom to ironsights for this gun
@@ -64,12 +62,11 @@ function SWEP:SecondaryAttack()
6462
local bIronsights = not self:GetIronsights()
6563

6664
self:SetIronsights( bIronsights )
67-
68-
if SERVER then
69-
self:SetZoom(bIronsights)
70-
else
71-
self:EmitSound(self.Secondary.Sound)
72-
end
65+
66+
self:SetZoom(bIronsights)
67+
if (CLIENT) then
68+
self:EmitSound(self.Secondary.Sound)
69+
end
7370

7471
self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
7572
end

0 commit comments

Comments
 (0)