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

Commit 99356ec

Browse files
committed
Replace 'self.Owner' with 'self:GetOwner()'
- Replace 'self.Owner' with 'self:GetOwner()' - AUG: Add check if there's any ammunation before playing the reload animation
1 parent b0b9542 commit 99356ec

7 files changed

+62
-61
lines changed

Diff for: lua/weapons/weapon_ghost_augbar.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ function SWEP:SetZoom(state)
5656
return
5757
else
5858
if state then
59-
self.Owner:SetFOV(20, 0.3)
59+
self:GetOwner():SetFOV(20, 0.3)
6060
else
61-
self.Owner:SetFOV(0, 0.2)
61+
self:GetOwner():SetFOV(0, 0.2)
6262
end
6363
end
6464
end
@@ -87,6 +87,7 @@ function SWEP:PreDrop()
8787
end
8888

8989
function SWEP:Reload()
90+
if ( self:Clip1() == self.Primary.ClipSize or self:GetOwner():GetAmmoCount( self.Primary.Ammo ) <= 0 ) then return end
9091
self.Weapon:DefaultReload(ACT_VM_RELOAD)
9192
self:SetIronsights( false )
9293
self:SetZoom(false)

Diff for: lua/weapons/weapon_ghost_awp.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ function SWEP:SetZoom(state)
4242
return
4343
else
4444
if state then
45-
self.Owner:SetFOV(20, 0.3)
45+
self:GetOwner():SetFOV(20, 0.3)
4646
else
47-
self.Owner:SetFOV(0, 0.2)
47+
self:GetOwner():SetFOV(0, 0.2)
4848
end
4949
end
5050
end

Diff for: lua/weapons/weapon_ghost_base.lua

+25-25
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ function SWEP:PrimaryAttack(worldsnd)
232232

233233
if not self:CanPrimaryAttack() then return end
234234

235-
if CLIENT and LocalPlayer() == self.Owner then
235+
if CLIENT and LocalPlayer() == self:GetOwner() then
236236
self.Weapon:EmitSound( self.Primary.Sound, self.Primary.SoundLevel )
237237
else
238238
local tbl = {}
239239
for k, v in ipairs(player.GetAll()) do
240-
if v != self.Owner and v:IsGhost() then
240+
if v != self:GetOwner() and v:IsGhost() then
241241
table.insert(tbl, v)
242242
end
243243
end
@@ -252,14 +252,14 @@ function SWEP:PrimaryAttack(worldsnd)
252252

253253
self:TakePrimaryAmmo( 1 )
254254

255-
local owner = self.Owner
255+
local owner = self:GetOwner()
256256
if not IsValid(owner) or owner:IsNPC() or (not owner.ViewPunch) then return end
257257

258258
owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) * self.Primary.Recoil, 0 ) )
259259
end
260260

261261
function SWEP:DryFire(setnext)
262-
if CLIENT and LocalPlayer() == self.Owner then
262+
if CLIENT and LocalPlayer() == self:GetOwner() then
263263
self:EmitSound( "Weapon_Pistol.Empty" )
264264
end
265265

@@ -276,7 +276,7 @@ function SWEP:ShootEffects()
276276
end
277277

278278
function SWEP:CanPrimaryAttack()
279-
if not IsValid(self.Owner) then return end
279+
if not IsValid(self:GetOwner()) then return end
280280

281281
if self.Weapon:Clip1() <= 0 then
282282
self:DryFire(self.SetNextPrimaryFire)
@@ -286,7 +286,7 @@ function SWEP:CanPrimaryAttack()
286286
end
287287

288288
function SWEP:CanSecondaryAttack()
289-
if not IsValid(self.Owner) then return end
289+
if not IsValid(self:GetOwner()) then return end
290290

291291
if self.Weapon:Clip2() <= 0 then
292292
self:DryFire(self.SetNextSecondaryFire)
@@ -319,7 +319,7 @@ end
319319
function SWEP:ShootBullet( dmg, recoil, numbul, cone )
320320

321321
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
322-
-- self.Owner:SetAnimation( PLAYER_ATTACK1 )
322+
-- self:GetOwner():SetAnimation( PLAYER_ATTACK1 )
323323

324324
if not IsFirstTimePredicted() then return end
325325

@@ -328,12 +328,12 @@ function SWEP:ShootBullet( dmg, recoil, numbul, cone )
328328
numbul = numbul or 1
329329
cone = cone or 0.01
330330

331-
self.Owner:LagCompensation(true)
331+
self:GetOwner():LagCompensation(true)
332332

333333
local bullet = {}
334334
bullet.Num = numbul
335-
bullet.Src = self.Owner:GetShootPos()
336-
bullet.Dir = self.Owner:GetAimVector()
335+
bullet.Src = self:GetOwner():GetShootPos()
336+
bullet.Dir = self:GetOwner():GetAimVector()
337337
bullet.Spread = Vector( cone, cone, 0 )
338338
bullet.Tracer = 0
339339
bullet.TracerName = self.Tracer or "Tracer"
@@ -355,25 +355,25 @@ function SWEP:ShootBullet( dmg, recoil, numbul, cone )
355355
end
356356

357357
if SERVER then
358-
self.Owner:FireBullets(bullet)
358+
self:GetOwner():FireBullets(bullet)
359359
elseif LocalPlayer():IsGhost() then
360-
self.Owner:FireBullets(bullet)
360+
self:GetOwner():FireBullets(bullet)
361361
end
362362

363-
self.Owner:LagCompensation(false)
363+
self:GetOwner():LagCompensation(false)
364364

365365
-- Owner can die after firebullet
366-
if (not IsValid(self.Owner)) or (not self.Owner:Alive()) or self.Owner:IsNPC() then return end
366+
if (not IsValid(self:GetOwner())) or (not self:GetOwner():Alive()) or self:GetOwner():IsNPC() then return end
367367

368368
if ((game.SinglePlayer() and SERVER) or
369369
((not game.SinglePlayer()) and CLIENT and IsFirstTimePredicted())) then
370370

371371
-- reduce recoil if ironsighting
372372
recoil = sights and (recoil * 0.6) or recoil
373373

374-
local eyeang = self.Owner:EyeAngles()
374+
local eyeang = self:GetOwner():EyeAngles()
375375
eyeang.pitch = eyeang.pitch - recoil
376-
self.Owner:SetEyeAngles( eyeang )
376+
self:GetOwner():SetEyeAngles( eyeang )
377377
end
378378

379379
end
@@ -420,17 +420,17 @@ function SWEP:OnRestore()
420420
end
421421

422422
function SWEP:Ammo1()
423-
return IsValid(self.Owner) and self.Owner:GetAmmoCount(self.Primary.Ammo) or false
423+
return IsValid(self:GetOwner()) and self:GetOwner():GetAmmoCount(self.Primary.Ammo) or false
424424
end
425425

426426
-- The OnDrop() hook is useless for this as it happens AFTER the drop. OwnerChange
427427
-- does not occur when a drop happens for some reason. Hence this thing.
428428
function SWEP:PreDrop()
429-
if SERVER and IsValid(self.Owner) and self.Primary.Ammo ~= "none" then
429+
if SERVER and IsValid(self:GetOwner()) and self.Primary.Ammo ~= "none" then
430430
local ammo = self:Ammo1()
431431

432432
-- Do not drop ammo if we have another gun that uses this type
433-
for _, w in pairs(self.Owner:GetWeapons()) do
433+
for _, w in pairs(self:GetOwner():GetWeapons()) do
434434
if IsValid(w) and w ~= self and w:GetPrimaryAmmoType() == self:GetPrimaryAmmoType() then
435435
ammo = 0
436436
end
@@ -439,7 +439,7 @@ function SWEP:PreDrop()
439439
self.StoredAmmo = ammo
440440

441441
if ammo > 0 then
442-
self.Owner:RemoveAmmo(ammo, self.Primary.Ammo)
442+
self:GetOwner():RemoveAmmo(ammo, self.Primary.Ammo)
443443
end
444444
end
445445
end
@@ -522,18 +522,18 @@ function SWEP:DyingShot()
522522
end
523523

524524
-- Owner should still be alive here
525-
if IsValid(self.Owner) then
525+
if IsValid(self:GetOwner()) then
526526
local punch = self.Primary.Recoil or 5
527527

528528
-- Punch view to disorient aim before firing dying shot
529-
local eyeang = self.Owner:EyeAngles()
529+
local eyeang = self:GetOwner():EyeAngles()
530530
eyeang.pitch = eyeang.pitch - math.Rand(-punch, punch)
531531
eyeang.yaw = eyeang.yaw - math.Rand(-punch, punch)
532-
self.Owner:SetEyeAngles( eyeang )
532+
self:GetOwner():SetEyeAngles( eyeang )
533533

534-
MsgN(self.Owner:Nick() .. " fired his DYING SHOT")
534+
MsgN(self:GetOwner():Nick() .. " fired his DYING SHOT")
535535

536-
self.Owner.dying_wep = self.Weapon
536+
self:GetOwner().dying_wep = self.Weapon
537537

538538
self:PrimaryAttack(true)
539539

Diff for: lua/weapons/weapon_ghost_crowbar.lua

+19-19
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,24 @@ local sound_single = Sound("Weapon_Crowbar.Single")
4545
function SWEP:PrimaryAttack()
4646
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
4747

48-
if not IsValid(self.Owner) then return end
48+
if not IsValid(self:GetOwner()) then return end
4949

50-
if self.Owner.LagCompensation then -- for some reason not always true
51-
self.Owner:LagCompensation(true)
50+
if self:GetOwner().LagCompensation then -- for some reason not always true
51+
self:GetOwner():LagCompensation(true)
5252
end
5353

54-
local spos = self.Owner:GetShootPos()
55-
local sdest = spos + (self.Owner:GetAimVector() * 70)
54+
local spos = self:GetOwner():GetShootPos()
55+
local sdest = spos + (self:GetOwner():GetAimVector() * 70)
5656

57-
local tr_main = util.TraceLine({start=spos, endpos=sdest, filter=self.Owner, mask=MASK_SHOT_HULL})
57+
local tr_main = util.TraceLine({start=spos, endpos=sdest, filter=self:GetOwner(), mask=MASK_SHOT_HULL})
5858
local hitEnt = tr_main.Entity
5959

60-
if CLIENT and LocalPlayer() == self.Owner then
60+
if CLIENT and LocalPlayer() == self:GetOwner() then
6161
self.Weapon:EmitSound(sound_single, self.Primary.SoundLevel )
6262
else
6363
local tbl = {}
6464
for k, v in ipairs(player.GetHumans()) do
65-
if v != self.Owner and v:IsGhost() then
65+
if v != self:GetOwner() and v:IsGhost() then
6666
table.insert(tbl, v)
6767
end
6868
end
@@ -94,8 +94,8 @@ function SWEP:PrimaryAttack()
9494

9595
-- do a bullet just to make blood decals work sanely
9696
-- need to disable lagcomp because firebullets does its own
97-
self.Owner:LagCompensation(false)
98-
self.Owner:FireBullets({Num=1, Src=spos, Dir=self.Owner:GetAimVector(), Spread=Vector(0,0,0), Tracer=0, Force=1, Damage=0})
97+
self:GetOwner():LagCompensation(false)
98+
self:GetOwner():FireBullets({Num=1, Src=spos, Dir=self:GetOwner():GetAimVector(), Spread=Vector(0,0,0), Tracer=0, Force=1, Damage=0})
9999
else
100100
util.Effect("Impact", edata)
101101
end
@@ -111,31 +111,31 @@ function SWEP:PrimaryAttack()
111111

112112
-- Do another trace that sees nodraw stuff like func_button
113113
local tr_all = nil
114-
tr_all = util.TraceLine({start=spos, endpos=sdest, filter=self.Owner})
114+
tr_all = util.TraceLine({start=spos, endpos=sdest, filter=self:GetOwner()})
115115

116-
self.Owner:SetAnimation( PLAYER_ATTACK1 )
116+
self:GetOwner():SetAnimation( PLAYER_ATTACK1 )
117117

118118
if hitEnt and hitEnt:IsValid() and hitEnt:IsPlayer() and hitEnt:IsGhost() then
119119

120120
local dmg = DamageInfo()
121121
dmg:SetDamage(self.Primary.Damage)
122-
dmg:SetAttacker(self.Owner)
122+
dmg:SetAttacker(self:GetOwner())
123123
dmg:SetInflictor(self.Weapon)
124-
dmg:SetDamageForce(self.Owner:GetAimVector() * 1500)
125-
dmg:SetDamagePosition(self.Owner:GetPos())
124+
dmg:SetDamageForce(self:GetOwner():GetAimVector() * 1500)
125+
dmg:SetDamagePosition(self:GetOwner():GetPos())
126126
dmg:SetDamageType(DMG_CLUB)
127127
hitEnt:TakeDamageInfo(dmg)
128128

129129
-- self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER )
130130

131-
-- self.Owner:TraceHullAttack(spos, sdest, Vector(-16,-16,-16), Vector(16,16,16), 30, DMG_CLUB, 11, true)
132-
-- self.Owner:FireBullets({Num=1, Src=spos, Dir=self.Owner:GetAimVector(), Spread=Vector(0,0,0), Tracer=0, Force=1, Damage=20})
131+
-- self:GetOwner():TraceHullAttack(spos, sdest, Vector(-16,-16,-16), Vector(16,16,16), 30, DMG_CLUB, 11, true)
132+
-- self:GetOwner():FireBullets({Num=1, Src=spos, Dir=self:GetOwner():GetAimVector(), Spread=Vector(0,0,0), Tracer=0, Force=1, Damage=20})
133133

134134
end
135135
end
136136

137-
if self.Owner.LagCompensation then
138-
self.Owner:LagCompensation(false)
137+
if self:GetOwner().LagCompensation then
138+
self:GetOwner():LagCompensation(false)
139139
end
140140
end
141141

Diff for: lua/weapons/weapon_ghost_hl2smg.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ function SWEP:Reload()
7070

7171
self.Weapon:DefaultReload( ACT_VM_RELOAD )
7272
self:SetIronsights( false )
73-
if CLIENT and LocalPlayer() == self.Owner then
73+
if CLIENT and LocalPlayer() == self:GetOwner() then
7474
self:EmitSound( "Weapon_SMG1.Reload" )
7575
else
7676
local filter = RecipientFilter()
7777
for k, v in ipairs(player.GetHumans()) do
78-
if v != self.Owner and v:IsGhost() then
78+
if v != self:GetOwner() and v:IsGhost() then
7979
filter:AddPlayer(v)
8080
end
8181
end

Diff for: lua/weapons/weapon_ghost_rifle.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ function SWEP:SetZoom(state)
4949
return
5050
else
5151
if state then
52-
self.Owner:SetFOV(20, 0.3)
52+
self:GetOwner():SetFOV(20, 0.3)
5353
else
54-
self.Owner:SetFOV(0, 0.2)
54+
self:GetOwner():SetFOV(0, 0.2)
5555
end
5656
end
5757
end
@@ -81,7 +81,7 @@ function SWEP:PreDrop()
8181
end
8282

8383
function SWEP:Reload()
84-
if ( self:Clip1() == self.Primary.ClipSize or self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0 ) then return end
84+
if ( self:Clip1() == self.Primary.ClipSize or self:GetOwner():GetAmmoCount( self.Primary.Ammo ) <= 0 ) then return end
8585
self.Weapon:DefaultReload(ACT_VM_RELOAD)
8686
self:SetIronsights( false )
8787
self:SetZoom(false)

Diff for: lua/weapons/weapon_ghost_shotgun.lua

+8-8
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function SWEP:Reload()
5151
self:SetIronsights( false )
5252
if self.dt.reloading then return end
5353
if not IsFirstTimePredicted() then return end
54-
if self.Weapon:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 then
54+
if self.Weapon:Clip1() < self.Primary.ClipSize and self:GetOwner():GetAmmoCount( self.Primary.Ammo ) > 0 then
5555
if self:StartReload() then
5656
return
5757
end
@@ -68,7 +68,7 @@ function SWEP:StartReload()
6868

6969
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
7070

71-
local ply = self.Owner
71+
local ply = self:GetOwner()
7272

7373
if not ply or ply:GetAmmoCount(self.Primary.Ammo) <= 0 then
7474
return false
@@ -91,7 +91,7 @@ function SWEP:StartReload()
9191
end
9292

9393
function SWEP:PerformReload()
94-
local ply = self.Owner
94+
local ply = self:GetOwner()
9595

9696
-- prevent normal shooting in between reloads
9797
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
@@ -102,7 +102,7 @@ function SWEP:PerformReload()
102102

103103
if wep:Clip1() >= self.Primary.ClipSize then return end
104104

105-
self.Owner:RemoveAmmo( 1, self.Primary.Ammo, false )
105+
self:GetOwner():RemoveAmmo( 1, self.Primary.Ammo, false )
106106
self.Weapon:SetClip1( self.Weapon:Clip1() + 1 )
107107

108108
wep:SendWeaponAnim(ACT_VM_RELOAD)
@@ -119,12 +119,12 @@ end
119119

120120
function SWEP:CanPrimaryAttack()
121121
if self.Weapon:Clip1() <= 0 then
122-
if CLIENT and LocalPlayer() == self.Owner then
122+
if CLIENT and LocalPlayer() == self:GetOwner() then
123123
self:EmitSound( "Weapon_Shotgun.Empty" )
124124
else
125125
local filter = RecipientFilter()
126126
for k, v in ipairs(player.GetHumans()) do
127-
if v != self.Owner and v:IsGhost() then
127+
if v != self:GetOwner() and v:IsGhost() then
128128
filter:AddPlayer(v)
129129
end
130130
end
@@ -142,14 +142,14 @@ end
142142

143143
function SWEP:Think()
144144
if self.dt.reloading and IsFirstTimePredicted() then
145-
if self.Owner:KeyDown(IN_ATTACK) then
145+
if self:GetOwner():KeyDown(IN_ATTACK) then
146146
self:FinishReload()
147147
return
148148
end
149149

150150
if self.reloadtimer <= CurTime() then
151151

152-
if self.Owner:GetAmmoCount(self.Primary.Ammo) <= 0 then
152+
if self:GetOwner():GetAmmoCount(self.Primary.Ammo) <= 0 then
153153
self:FinishReload()
154154
elseif self.Weapon:Clip1() < self.Primary.ClipSize then
155155
self:PerformReload()

0 commit comments

Comments
 (0)