Hi everyone.
Im trying to make a Vintorez VSS SWEP more accurate. When the weapon is unscoped the accuracy is perfect. But when the weapon is scoped in its not very accurate at all.
As you can see in the code, i have tried to set the spread and cones close to 0, but with no luck.
The code may look wierd because the scopes from the original SWEP was not working with Gmod13 so i just used the scope code from the scout, but it is working fine now.
Also, on the bottom of the code there is a SWEP Offset code just to place it right in the on the W_model
Any help will be much appreciated :)
[lua]
if SERVER then
AddCSLuaFile("shared.lua")
end
if CLIENT then
SWEP.DrawAmmo = true
SWEP.DrawCrosshair = false
SWEP.ViewModelFOV = 76
SWEP.ViewModelFlip = true
SWEP.CSMuzzleFlashes = true
SWEP.Icon = "VGUI/ttt/icon_vintar"
SWEP.Slot = 6
SWEP.SlotPos = 1
SWEP.IconLetter = "i"
SWEP.DrawWeaponInfoBox = true
SWEP.HoldType = "ar2"
killicon.AddFont("weapon_rg_example", "CSKillIcons", SWEP.IconLetter, Color(255, 220, 0, 255))
SWEP.SwayScale = 1.0 // The scale of the viewmodel sway
SWEP.BobScale = 1.0 // The scale of the viewmodel bob
end
SWEP.Base = "weapon_tttbase"
------------
-- Info --
------------
SWEP.PrintName = "VSS Vintorez"
SWEP.Author = "Jigsaw"
SWEP.Purpose = "VSS Vintorez sniper rifle from STALKER"
SWEP.Instructions = "Zoom with right click. Shoot with Left."
-------------
-- Misc. --
-------------
SWEP.Spawnable = false
SWEP.AdminSpawnable = true
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.AmmoEnt = "item_ammo_smg1_ttt"
SWEP.Kind = WEAPON_EQUIP1
SWEP.CanBuy = { ROLE_TRAITOR }
SWEP.LimitedStock = false
SWEP.AllowDrop = true
SWEP.IsSilent = false
SWEP.Primary.Delay = 0.5
SWEP.EquipMenuData = {
type = "Weapon",
desc = "Silenced Semi-Automatic Sniper Rifle"
};
----------------------
-- Primary Fire --
----------------------
SWEP.Primary.Sound = Sound("vss/shoot.wav")
SWEP.Primary.Damage = 60
SWEP.Primary.NumShots = 1
SWEP.Primary.ClipSize = 5
SWEP.Primary.DefaultClip = 15
SWEP.Primary.Ammo = "smg1"
SWEP.MuzzleVelocity = 700
SWEP.FiresUnderwater = true
SWEP.Primary.Cone = 0.01
-------------------------
-- Secondary Fire --
-------------------------
-- Secondary Fire is used to switch ironsights and firemodes
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 1
SWEP.Secondary.Ammo = "none"
---------------------------------------
-- Recoil, Spread, and Spray --
---------------------------------------
SWEP.RecoverTime = 1.5
SWEP.MinRecoil = 0.2
SWEP.MaxRecoil = 2
SWEP.DeltaRecoil = 0.3
SWEP.MinSpread = 0.001
SWEP.MaxSpread = 0.001
SWEP.DeltaSpread = 0.001
SWEP.MinSpray = 0
SWEP.MaxSpray = 0.1
SWEP.DeltaSpray = 0.16
-------------------------
-- Effects/Visual --
-------------------------
SWEP.ViewModel = "models/weapons/v_stalkervss.mdl"
SWEP.WorldModel = "models/weapons/w_stalkervss.mdl"
SWEP.MuzzleEffect = "rg_muzzle_silenced" -- This is an extra muzzleflash effect
SWEP.ShellEffect = "rg_shelleject_rifle" -- This is a shell ejection effect
SWEP.MuzzleAttachment = "1"
SWEP.ShellEjectAttachment = "2"
-------------------
-- Modifiers --
-------------------
SWEP.CrouchModifier = 0.4 -- Applies if player is crouching.
SWEP.IronSightModifier = 0 -- Applies if player is in iron sight mode.
SWEP.RunModifier = 1.4 -- Applies if player is moving.
SWEP.JumpModifier = 1.6 -- Applies if player is in the air (jumping)
SWEP.Zoom1Cone = 0.001 --spread for when zoomed once
--------------------
-- Fire Modes --
--------------------
SWEP.AvailableFireModes = {"Semi"}
SWEP.SemiRPM = 30
SWEP.DrawFireModes = true
SWEP.Secondary.Sound = Sound("Default.Zoom")
SWEP.IronSightsPos = Vector( 5, -15, -2 )
SWEP.IronSightsAng = Vector( 2.6, 1.37, 3.5 )
function SWEP:SetZoom(state)
if CLIENT then
return
else
if state then
self.Owner:SetFOV(20, 0.3)
else
self.Owner:SetFOV(0, 0.2)
end
end
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
bIronsights = not self:GetIronsights()
self:SetIronsights( bIronsights )
if SERVER then
self:SetZoom(bIronsights)
else
self:EmitSound(self.Secondary.Sound)
end
self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
end
function SWEP:PreDrop()
self:SetZoom(false)
self:SetIronsights(false)
return self.BaseClass.PreDrop(self)
end
function SWEP:Reload()
self.Weapon:DefaultReload( ACT_VM_RELOAD );
self:SetIronsights( false )
self:SetZoom(false)
end
function SWEP:Holster()
self:SetIronsights(false)
self:SetZoom(false)
return true
end
if CLIENT then
local scope = surface.GetTextureID("sprites/scope")
function SWEP:DrawHUD()
if self:GetIronsights() then
surface.SetDrawColor( 0, 0, 0, 255 )
local x = ScrW() / 2.0
local y = ScrH() / 2.0
local scope_size = ScrH()
-- crosshair
local gap = 80
local length = scope_size
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 )
gap = 0
length = 50
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 )
-- cover edges
local sh = scope_size / 2
local w = (x - sh) + 2
surface.DrawRect(0, 0, w, scope_size)
surface.DrawRect(x + sh - 2, 0, w, scope_size)
surface.SetDrawColor(255, 0, 0, 255)
surface.DrawLine(x, y, x + 1, y + 1)
-- scope
surface.SetTexture(scope)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0)
else
return self.BaseClass.DrawHUD(self)
end
end
function SWEP:AdjustMouseSensitivity()
return (self:GetIronsights() and 0.2) or nil
end
end
SWEP.Offset = {
Pos = {
Up = 3,
Right = 0,
Forward = 2,
},
Ang = {
Up = 0,
Right = 0,
Forward = 0,
}
}
function SWEP:DrawWorldModel( )
local hand, offset, rotate
if not IsValid( self.Owner ) then
self:DrawModel( )
return
end
if not self.Hand then
self.Hand = self.Owner:LookupAttachment( "anim_attachment_rh" )
end
hand = self.Owner:GetAttachment( self.Hand )
if not hand then
self:DrawModel( )
return
end
offset = hand.Ang:Right( ) * self.Offset.Pos.Right + hand.Ang:Forward( ) * self.Offset.Pos.Forward + hand.Ang:Up( ) * self.Offset.Pos.Up
hand.Ang:RotateAroundAxis( hand.Ang:Right( ), self.Offset.Ang.Right )
hand.Ang:RotateAroundAxis( hand.Ang:Forward( ), self.Offset.Ang.Forward )
hand.Ang:RotateAroundAxis( hand.Ang:Up( ), self.Offset.Ang.Up )
self:SetRenderOrigin( hand.Pos + offset )
self:SetRenderAngles( hand.Ang )
self:DrawModel( )
end
[/lua]
anyone? :)
[lua]
SWEP.ConeSpray = 0 // accuracy
SWEP.ConeIncrement = 0 // Rate of innacuracy
SWEP.ConeMax = 0 // Maximum Innacuracy
SWEP.ConeDecrement = 0 // Rate of accuracy
[/lua]
That'll have pin point accuracy.
[QUOTE=Zonfire;39146270][lua]
SWEP.ConeSpray = 0 // accuracy
SWEP.ConeIncrement = 0 // Rate of innacuracy
SWEP.ConeMax = 0 // Maximum Innacuracy
SWEP.ConeDecrement = 0 // Rate of accuracy
[/lua]
That'll have pin point accuracy.[/QUOTE]
Thanks a lot, ill try that out!
-snip-
ajusted the remaining cone values, and it is now working perfedtly :)
Thanks for the help!
Sorry, you need to Log In to post a reply to this thread.