Skip to content

Commit

Permalink
TTT: Small SWEP changes
Browse files Browse the repository at this point in the history
* Replaced all self.Weapon to self
* Adjusted ironsights on Mac 10 and M16
* Fixed reload with full clip making the zooming spazz out on M16 and
Rifle
* Fixed being able to use ironsights on shotgun while reloading
* Fixed pressing reload with full clip switching off ironsights
  • Loading branch information
robotboy655 committed Feb 19, 2014
1 parent 43e4182 commit 046b3d5
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 114 deletions.
Expand Up @@ -66,14 +66,14 @@ function SWEP:OnDrop()
end

function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )

if self:CanPrimaryAttack() then
self:BeaconDrop()
end
end
function SWEP:SecondaryAttack()
self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )

if self:CanPrimaryAttack() then
self:BeaconStick()
Expand Down Expand Up @@ -121,7 +121,7 @@ function SWEP:BeaconDrop()
end
end

self.Weapon:EmitSound(throwsound)
self:EmitSound(throwsound)
end

function SWEP:BeaconStick()
Expand All @@ -131,7 +131,7 @@ function SWEP:BeaconStick()

if self.Planted then return end

local ignore = {ply, self.Weapon}
local ignore = {ply, self}
local spos = ply:GetShootPos()
local epos = spos + ply:GetAimVector() * 80
local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})
Expand Down Expand Up @@ -180,17 +180,17 @@ function SWEP:PlacedBeacon()
end

function SWEP:PickupBeacon()
if self.Weapon:Clip1() >= self.Primary.ClipSize then
if self:Clip1() >= self.Primary.ClipSize then
return false
else
self.Weapon:SetClip1(self.Weapon:Clip1() + 1)
self:SetClip1(self:Clip1() + 1)
return true
end
end

-- Ammo hackery after getting bought
function SWEP:WasBought(buyer)
self.Weapon:SetClip1(self.Weapon:Clip1() + 2)
self:SetClip1(self:Clip1() + 2)
end

function SWEP:Reload()
Expand Down Expand Up @@ -227,7 +227,7 @@ end

-- not able to do DrawModel stuff in Deploy, so here's a hack
function SWEP:Think()
if SERVER and not hidden and IsValid(self.Owner) and self.Owner:GetActiveWeapon() == self.Weapon then
if SERVER and not hidden and IsValid(self.Owner) and self.Owner:GetActiveWeapon() == self then
self.Owner:DrawViewModel(false)
self.Owner:DrawWorldModel(false)
hidden = true
Expand Down
Expand Up @@ -64,10 +64,10 @@ end


function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + 0.1 )
self:SetNextPrimaryFire( CurTime() + 0.1 )

if self:IsTargetingCorpse() and not self.dt.processing then
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )

if SERVER then
self.dt.processing = true
Expand All @@ -78,7 +78,7 @@ end

local click = Sound("weapons/sniper/sniper_zoomin.wav")
function SWEP:SecondaryAttack()
self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )

if CLIENT and IsFirstTimePredicted() then
LocalPlayer():EmitSound(click)
Expand Down
Expand Up @@ -51,12 +51,12 @@ SWEP.NoSights = true
local throwsound = Sound( "Weapon_SLAM.SatchelThrow" )

function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:BombDrop()
end

function SWEP:SecondaryAttack()
self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
self:BombStick()
end

Expand Down Expand Up @@ -104,8 +104,8 @@ function SWEP:BombDrop()
ply:SetAnimation( PLAYER_ATTACK1 )
end

self.Weapon:EmitSound(throwsound)
self.Weapon:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
self:EmitSound(throwsound)
self:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
end

-- again replicating slam, now its attach fn
Expand All @@ -116,7 +116,7 @@ function SWEP:BombStick()

if self.Planted then return end

local ignore = {ply, self.Weapon}
local ignore = {ply, self}
local spos = ply:GetShootPos()
local epos = spos + ply:GetAimVector() * 80
local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})
Expand Down
Expand Up @@ -49,12 +49,12 @@ SWEP.AllowDrop = false
SWEP.DeathScanDelay = 15

function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:DropDevice()
end

function SWEP:SecondaryAttack()
self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
self:DropDevice()
end

Expand Down Expand Up @@ -120,7 +120,7 @@ function SWEP:DropDevice()
end
end

self.Weapon:EmitSound(throwsound)
self:EmitSound(throwsound)

return cse
end
Expand Down
Expand Up @@ -54,12 +54,12 @@ function SWEP:OnDrop()
end

function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )

self:DecoyStick()
end
function SWEP:SecondaryAttack()
self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )

self:DecoyStick()
end
Expand Down Expand Up @@ -103,7 +103,7 @@ function SWEP:DecoyDrop()
end
end

self.Weapon:EmitSound(throwsound)
self:EmitSound(throwsound)
end

function SWEP:DecoyStick()
Expand All @@ -113,7 +113,7 @@ function SWEP:DecoyStick()

if self.Planted then return end

local ignore = {ply, self.Weapon}
local ignore = {ply, self}
local spos = ply:GetShootPos()
local epos = spos + ply:GetAimVector() * 80
local tr = util.TraceLine({start=spos, endpos=epos, filter=ignore, mask=MASK_SOLID})
Expand Down
Expand Up @@ -46,7 +46,7 @@ SWEP.WeaponID = AMMO_DEFUSER

local defuse = Sound("c4.disarmfinish")
function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )

local spos = self.Owner:GetShootPos()
local sdest = spos + (self.Owner:GetAimVector() * 80)
Expand All @@ -61,14 +61,14 @@ function SWEP:PrimaryAttack()
sound.Play(defuse, bomb:GetPos())
end

self.Weapon:SetNextPrimaryFire( CurTime() + (self.Primary.Delay * 2) )
self:SetNextPrimaryFire( CurTime() + (self.Primary.Delay * 2) )
end
end
end

function SWEP:SecondaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetNextSecondaryFire( CurTime() + 0.1 )
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextSecondaryFire( CurTime() + 0.1 )
end


Expand Down
Expand Up @@ -184,13 +184,13 @@ function SWEP:ShootFlare()
end

function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )

if not self:CanPrimaryAttack() then return end

self.Weapon:EmitSound( self.Primary.Sound )
self:EmitSound( self.Primary.Sound )

self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )

self:ShootFlare()

Expand All @@ -203,7 +203,7 @@ function SWEP:PrimaryAttack()
end

if ( (game.SinglePlayer() && SERVER) || CLIENT ) then
self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
self:SetNetworkedFloat( "LastShootTime", CurTime() )
end
end

Expand Down
Expand Up @@ -55,11 +55,11 @@ function SWEP:OnDrop()
end

function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:HealthDrop()
end
function SWEP:SecondaryAttack()
self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
self:HealthDrop()
end

Expand Down Expand Up @@ -97,7 +97,7 @@ function SWEP:HealthDrop()
end
end

self.Weapon:EmitSound(throwsound)
self:EmitSound(throwsound)
end


Expand Down
Expand Up @@ -43,15 +43,15 @@ SWEP.WorldModel = "models/weapons/w_rif_m4a1.mdl"

SWEP.Primary.Sound = Sound( "Weapon_M4A1.Single" )

SWEP.IronSightsPos = Vector(-7.58, -9.2, 0.55)
SWEP.IronSightsPos = Vector(-7.58, -9.2, 1.55)
SWEP.IronSightsAng = Vector(2.599, -1.3, -3.6)


function SWEP:SetZoom(state)
if CLIENT then return end
if not (IsValid(self.Owner) and self.Owner:IsPlayer()) then return end
if state then
self.Owner:SetFOV(35, 0.5)
self.Owner:SetFOV(40, 0.5)
else
self.Owner:SetFOV(0, 0.2)
end
Expand All @@ -60,17 +60,17 @@ end
-- Add some zoom to ironsights for this gun
function SWEP:SecondaryAttack()
if not self.IronSightsPos then return end
if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
if self:GetNextSecondaryFire() > CurTime() then return end

bIronsights = not self:GetIronsights()

self:SetIronsights( bIronsights )

if SERVER then
self:SetZoom(bIronsights)
self:SetZoom( bIronsights )
end

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

function SWEP:PreDrop()
Expand All @@ -80,16 +80,14 @@ function SWEP:PreDrop()
end

function SWEP:Reload()
self.Weapon:DefaultReload( ACT_VM_RELOAD );
self:SetIronsights( false )
self:SetZoom(false)
if ( self:Clip1() == self.Primary.ClipSize or self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0 ) then return end
self:DefaultReload( ACT_VM_RELOAD )
self:SetIronsights( false )
self:SetZoom( false )
end


function SWEP:Holster()
self:SetIronsights(false)
self:SetZoom(false)
self:SetIronsights( false )
self:SetZoom( false )
return true
end


Expand Up @@ -100,7 +100,7 @@ function SWEP:PreDrop()
self:SetCharge(0)

-- OnDrop does not happen on client
self.Weapon:CallOnClient("HideGhost", "")
self:CallOnClient("HideGhost", "")
end

function SWEP:HideGhost()
Expand All @@ -110,7 +110,7 @@ function SWEP:HideGhost()
end

function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire(CurTime() + 0.1)
self:SetNextPrimaryFire(CurTime() + 0.1)
if not self:CanPrimaryAttack() then return end

if SERVER then
Expand All @@ -125,19 +125,19 @@ function SWEP:PrimaryAttack()

self:CreateHammer(tr.Entity, tr.HitPos)

self.Weapon:EmitSound(self.Primary.Sound)
self:EmitSound(self.Primary.Sound)

self:TakePrimaryAmmo(1)

self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
end
end
end

function SWEP:SecondaryAttack()
if self.IsCharging then return end

self.Weapon:SetNextSecondaryFire( CurTime() + 0.1 )
self:SetNextSecondaryFire( CurTime() + 0.1 )

if not (self:CanPrimaryAttack() and (self:GetNextPrimaryFire() - CurTime()) <= 0) then return end

Expand Down Expand Up @@ -215,11 +215,11 @@ if SERVER then
if self:GetCharge() >= 1 then
self:CreateHammer(tr.Entity, tr.HitPos)

self.Weapon:EmitSound(self.Primary.Sound)
self:EmitSound(self.Primary.Sound)

self:TakePrimaryAmmo(1)

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

self.IsCharging = false
self:SetCharge(0)
Expand Down Expand Up @@ -318,7 +318,7 @@ if CLIENT then
surface.DrawOutlinedRect(0, 0, 50, 15)

local sz = 48
local next = self.Weapon:GetNextPrimaryFire()
local next = self:GetNextPrimaryFire()
local ready = (next - CurTime()) <= 0
local frac = 1.0
if not ready then
Expand Down

0 comments on commit 046b3d5

Please sign in to comment.