How does one turn down the damned weapon accuracy?
4 replies, posted
I'm trying to wrap my head around the concept of making sweps in lua, and am rather confused as to how I increase/decrease the accuracy. Not talking about recoil, I mean the cone of fire. Rate me dumb if it's obvious, but please let me know if you know how...
I thought there was a hook for it, but I cannot seem to find it, sorry.
What do you mean by turning on the accuary?Post your swep code and tell me exactly you want to do in the code , then maybe I can help..
He's stated what he wants, he doesn't need to post any code.
He wants to be able to edit the accuracy, so like a cone of fire.
[QUOTE=LuckyLuke;22562101]He's stated what he wants, he doesn't need to post any code.
He wants to be able to edit the accuracy, so like a cone of fire.[/QUOTE]
Well, if we knew how he was firing bullets then maybe we could work out how he'd make them fire in a cone. He can speak for himself.
[lua]
function SWEP:PrimaryAttack()
local coneMagnitude = 5// offset magnitude that the bullet might be fired at
if ( !self:CanPrimaryAttack() ) then return end
local bullet = {}
bullet.Num = self.Primary.NumberofShots
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector() + Vector( math.random()*coneMagnitude, math.random()*coneMagnitude, math.random()*coneMagnitude ):Normalize()
bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0)
bullet.Tracer = 0
bullet.Force = self.Primary.Force
bullet.Damage = self.Primary.Damage
bullet.AmmoType = self.Primary.Ammo
local rnda = self.Primary.Recoil * -1
local rndb = self.Primary.Recoil * math.random(-1, 1)
self:ShootEffects()
self.Owner:FireBullets( bullet )
self:EmitSound(Sound(self.Primary.Sound))
self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) )
self:TakePrimaryAmmo(self.Primary.TakeAmmo)
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
end
[/lua]
^Something like this if you're doing it like the example swep.
Sorry, you need to Log In to post a reply to this thread.