Permalink
Browse files

TTT: Small SWEP changes

* 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...
1 parent 43e4182 commit 046b3d585b8e37b519d6ea3cd69a2a89b9c75e8d @robotboy655 robotboy655 committed Feb 19, 2014
Showing with 122 additions and 114 deletions.
  1. +8 −8 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_beacon/shared.lua
  2. +3 −3 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_binoculars/shared.lua
  3. +5 −5 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_c4/shared.lua
  4. +3 −3 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_cse/shared.lua
  5. +4 −4 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_decoy/shared.lua
  6. +4 −4 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_defuser/shared.lua
  7. +4 −4 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_flaregun/shared.lua
  8. +3 −3 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_health_station/shared.lua
  9. +11 −13 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_m16/shared.lua
  10. +8 −8 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_phammer/shared.lua
  11. +10 −9 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_push/shared.lua
  12. +4 −4 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_radio/shared.lua
  13. +1 −1 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_sipistol/shared.lua
  14. +1 −1 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_stungun/shared.lua
  15. +3 −3 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_teleport/shared.lua
  16. +3 −3 garrysmod/gamemodes/terrortown/entities/weapons/weapon_ttt_wtester/shared.lua
  17. +13 −12 garrysmod/gamemodes/terrortown/entities/weapons/weapon_tttbase/shared.lua
  18. +3 −3 garrysmod/gamemodes/terrortown/entities/weapons/weapon_tttbasegrenade/shared.lua
  19. +1 −1 garrysmod/gamemodes/terrortown/entities/weapons/weapon_zm_mac10/shared.lua
  20. +5 −4 garrysmod/gamemodes/terrortown/entities/weapons/weapon_zm_rifle/shared.lua
  21. +25 −18 garrysmod/gamemodes/terrortown/entities/weapons/weapon_zm_shotgun/shared.lua
@@ -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()
@@ -121,7 +121,7 @@ function SWEP:BeaconDrop()
end
end
- self.Weapon:EmitSound(throwsound)
+ self:EmitSound(throwsound)
end
function SWEP:BeaconStick()
@@ -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})
@@ -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()
@@ -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
@@ -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
@@ -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)
@@ -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
@@ -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
@@ -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})
@@ -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
@@ -120,7 +120,7 @@ function SWEP:DropDevice()
end
end
- self.Weapon:EmitSound(throwsound)
+ self:EmitSound(throwsound)
return cse
end
@@ -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
@@ -103,7 +103,7 @@ function SWEP:DecoyDrop()
end
end
- self.Weapon:EmitSound(throwsound)
+ self:EmitSound(throwsound)
end
function SWEP:DecoyStick()
@@ -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})
@@ -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)
@@ -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
@@ -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()
@@ -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
@@ -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
@@ -97,7 +97,7 @@ function SWEP:HealthDrop()
end
end
- self.Weapon:EmitSound(throwsound)
+ self:EmitSound(throwsound)
end
@@ -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
@@ -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()
@@ -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
-
-
@@ -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()
@@ -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
@@ -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
@@ -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)
@@ -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
Oops, something went wrong.

0 comments on commit 046b3d5

Please sign in to comment.