Hey, i wondered if there had a way to change the prop launched (Small BB's) speed and distance they can travel. I tried many thing, but none worked so far.
Here's my current code for the primaryattack
[code]function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK) -- View model animation
self.Weapon:EmitSound( self.Primary.Sound )
self:TakePrimaryAmmo( 1 )
self.Owner:ViewPunch( Angle( math.Rand(-self.Primary.RecoilXRand,-self.Primary.RecoilXRand) * self.Primary.Recoil, math.Rand(self.Primary.RecoilYRand,-self.Primary.RecoilYRand) *self.Primary.Recoil, 0 ) )
if SERVER then
local bar = ents.Create("prop_physics")
bar:SetModel("models/Cheeezy/Marble/marble.mdl")
bar:SetPos(self.Owner:GetShootPos())
bar:SetOwner(self.Owner)
bar:SetPhysicsAttacker(self.Owner)
bar:Spawn()
bar:GetPhysicsObject():SetMass(15)
local phys = bar:GetPhysicsObject()
local eAng = self.Owner:EyeAngles()
local Spray = 0.07*1000000000
local spread = (eAng:Up() * (math.random() * Spray - (Spray*0.1)) + eAng:Right() * (math.random() * Spray - (Spray*0.1)))
local spread2 = (eAng:Up() * (math.random() * Spray - (Spray*-0.01)))
phys:ApplyForceCenter(self.Owner:GetAimVector() * 1999999999 + spread + spread2)
phys:AddAngleVelocity(Vector(999999,9999,0))
timer.Simple(1, function()
local ent = bar
local targ = bar:EntIndex()..bar:GetClass() //Give it a unique name
ent:SetKeyValue("targetname",targ)
local dissolver = ents.Create("env_entity_dissolver")
dissolver:SetPos(Vector(0,0,0)) //Doesn't need to be in any particular position
dissolver:SetKeyValue("target",targ)
dissolver:SetKeyValue("magnitude",300)
dissolver:SetKeyValue("dissolvetype",4)
dissolver:Spawn()
dissolver:Activate()
dissolver:Fire("Dissolve")
end)
end
end[/code]
And is there any tutorial showing how i could make the Secondary attack a zoom?
Also i need some some help for a gamemode i'm working on, if someone could help me with small thing, and teach me some more lua, send me a Private message please. I'll tell you more detail about the gamemode privatly.
Thanks ^^
For the speed I do it this way :
[code]phys:SetVelocity(self.Owner:GetAimVector() * 1200 + self.Owner:GetVelocity()[/code]
for the secondary attack you should probably use [url=http://wiki.garrysmod.com/?title=SWEP.TranslateFOV]SWEP.TranslateFOV[/url]
and I'd be more then willing to answer a few questions, my username is aoe325.
Sorry, you need to Log In to post a reply to this thread.