Weapon Reload Speed

Posted this a while back in the wrong section, Hoping i could find an answer here.

How would i go go about making a weapon reload faster? Is it possible to change this animation’s speed?
[lua]
function SWEP:Reload()
self.Weapon:DefaultReload( ACT_VM_RELOAD ) //animation for reloading
end
[/lua]

[lua]
function SWEP:Reload()

if self.ReloadingTime and CurTime() <= self.ReloadingTime then return end

if ( self:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 ) then

	self:DefaultReload( ACT_VM_RELOAD )
            local AnimationTime = self.Owner:GetViewModel():SequenceDuration()
            self.ReloadingTime = CurTime() + AnimationTime
            self:SetNextPrimaryFire(CurTime() + AnimationTime)
            self:SetNextSecondaryFire(CurTime() + AnimationTime)

end

end
[/lua]

From the wiki example: http://wiki.garrysmod.com/?title=SWEP.Reload

Right. And how do i change the speed with that?

Sorry for the bump, but I was actually looking to do something like that.


self.Owner:GetViewModel():SetPlaybackRate(2)

I tried to use that, and it worked, it reloads twice as fast, but the problem is, you still can’t shoot until the full delay of the normal speed animation has been waited out.
I tried with self:SetNextPrimaryFire(CurTime() + (self.Owner:GetViewModel():SequenceDuration()/2))

But it still didn’t fix it. Any idea?

Divide the time delay till you can shoot by the amount you’re speeding up the animation by.
If you wanted to double the playback rate just multiply it by 2 then divide the time you can reload, by 2.

That’s what I did with


self:SetNextPrimaryFire(CurTime() + (self.Owner:GetViewModel():SequenceDuration()/2))

Unless you mean something else, because it seems there is another, hardcoded timer for the reload alone.

Show all the code you have in your reload function.

As far as I know, you can’t change the speed of the normal Reload function because its based on the default weapon animation time, before you can “SetPlaybackRate”.

Couldn’t you just set a custom reload function to refill the magazine after the modified playback is done?

You need to make your own reload function before doing anything else.

if SWEP:SetDeploySpeed( double ) exists then why can’t SetReloadSpeed() exist?

Here’s how it looks


function SWEP:Reload()
	if ( self.Reloadaftershoot > CurTime() ) then return end 

	self.Weapon:DefaultReload(ACT_VM_RELOAD) 
	self.Owner:GetViewModel():SetPlaybackRate(2)
	self:SetNextPrimaryFire(CurTime() + (self.Owner:GetViewModel():SequenceDuration()/2))

end

The last line doesn’t seem to be doing anything.

Where are you defining self.Reloadaftershoot?

In the PrimaryAttack() , but that’s for something else.


self.Reloadaftershoot = CurTime() + self.Primary.Delay

It’s just a thing to prevent the reload function until your firing delay has been waited out. It doesn’t have anything to do with what I’m trying to do here.

Press R twice as fast

DefaultReload runs an animation, gets the length of said animation, And does the mathematics needed for magazine refilling.

DefaultReload also plays that animation by default, it also stops your Think Function from running During said animation.

Thus you need a custom function.

So… What kind of function would I need? How would it look like?

That’s up to you to make.