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: [url]http://wiki.garrysmod.com/?title=SWEP.Reload[/url]
[QUOTE=Commander11;29742448][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: [url]http://wiki.garrysmod.com/?title=SWEP.Reload[/url][/QUOTE]
Right. And how do i change the speed with that?
Sorry for the bump, but I was actually looking to do something like that.
[CODE]self.Owner:GetViewModel():SetPlaybackRate(2)[/CODE]
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?
[QUOTE=Ablationer;39341152]Sorry for the bump, but I was actually looking to do something like that.
[CODE]self.Owner:GetViewModel():SetPlaybackRate(2)[/CODE]
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?[/QUOTE]
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
[CODE]self:SetNextPrimaryFire(CurTime() + (self.Owner:GetViewModel():SequenceDuration()/2))[/CODE]
Unless you mean something else, because it seems there is another, hardcoded timer for the reload alone.
[QUOTE=Ablationer;39343214]That's what I did with
[CODE]self:SetNextPrimaryFire(CurTime() + (self.Owner:GetViewModel():SequenceDuration()/2))[/CODE]
Unless you mean something else, because it seems there is another, hardcoded timer for the reload alone.[/QUOTE]
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
[CODE]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[/CODE]
The last line doesn't seem to be doing anything.
[QUOTE=Ablationer;39349810]Here's how it looks
[CODE]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[/CODE]
The last line doesn't seem to be doing anything.[/QUOTE]
Where are you defining self.Reloadaftershoot?
In the PrimaryAttack() , but that's for something else.
[CODE]self.Reloadaftershoot = CurTime() + self.Primary.Delay[/CODE]
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?
[QUOTE=Ablationer;39364616]So... What kind of function would I need? How would it look like?[/QUOTE]
That's up to you to make.
Sorry, you need to Log In to post a reply to this thread.