For some reason at a certain garrysmod update.. PLAYER_ATTACK1 started to override my ACT_VM_SECONDARYATTACK, i only noticed that it does this now, no idea in which update the bug came from, the problem is it overrides any other ACT_VM_ animation by it also doing a second anim (ACT_VM_PRIMARYATTACK) cant even do secondary attack right if i want both world, view models to animate, anyway around this?
Enter the enumeration number instead I guess. For example, ACT_VM_PRIMARYATTACK is the equivalent to 178
[QUOTE=thegrb93;22653561]Enter the enumeration number instead I guess. For example, ACT_VM_PRIMARYATTACK is the equivalent to 178[/QUOTE]
Thanks, ill try that.
Don't, it's exactly the same thing.
Is it your own gamemode where you have defined your own animation hooks?
[QUOTE=_Kilburn;22654592]Don't, it's exactly the same thing.
Is it your own gamemode where you have defined your own animation hooks?[/QUOTE]
No.. just a simple swep. Here's the code of the function:
[CODE]function SWEP:SecondaryAttack()
local nade = ents.Create("grenade_ar2")
nade:SetAngles(self.Owner:EyeAngles())
nade:SetOwner(self.Owner)
nade:Spawn()
if self.Owner:IsPlayer() then
self.Weapon:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
self.IdleTimer = CurTime() + self.Owner:GetViewModel():SequenceDuration()
nade:SetPos(self.Owner:GetViewModel():GetAttachment(1).Pos)
nade:SetVelocity(self.Owner:GetAimVector()* 1000)
self.Owner:ViewPunch(Angle(-math.Rand(2.5,3.2)))
self.Weapon:SetNextSecondaryFire(CurTime() + 1)
self.Weapon:SetNextPrimaryFire(CurTime() + 0.5)
self.Weapon:EmitSound("Weapon_SMG1.Double")
self.Owner:SetAnimation(PLAYER_ATTACK1)
else
nade:SetPos(self.Owner:GetShootPos()+ self.Owner:GetForward()* 8+ self.Owner:EyeAngles():Right()* 4.3)
nade:SetVelocity(self.Owner:GetAimVector()* 1500+ self.Owner:EyeAngles():Up()* 75)
self.Weapon:EmitSound("Weapon_SMG1.Double", 75, math.Rand(97,103)+self.RandomSPitch)
self.NPCClip2 = self.NPCClip2 - 1
end
end[/CODE]The first thing i've tried was switching the PLAYER_ATTACK1 before ACT_VM_, thought it would override the PLAYER_ animation, but no luck.
This is how animations are handled in the base gamemode:
[lua]function GM:DoAnimationEvent( ply, event, data )
if event == PLAYERANIMEVENT_ATTACK_PRIMARY then
if ply:Crouching() then
ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_CROUCH_PRIMARYFIRE )
else
ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_STAND_PRIMARYFIRE )
end
return ACT_VM_PRIMARYATTACK[/lua]
As you can see, when the primary attack animation event is received, it forces the viewmodel to play the primary attack animation as well, which is indeed quite annoying. I don't know if there is any simple way to prevent this from happening, but in the meantime, try doing this:
[lua]
hook.Add("DoAnimationEvent", "DoCustomFireAnimation", function(ply, event, data)
if event == PLAYERANIMEVENT_CUSTOM_GESTURE then
if data == 1 then
if ply:Crouching() then
ply:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_CROUCH_PRIMARYFIRE)
else
ply:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_STAND_PRIMARYFIRE)
end
return ACT_INVALID
end
end
end)
[/lua]
This should be shared, so you can put this somewhere in the shared.lua of your SWEP, like, at the very end of the file.
Then, instead of self.Owner:SetAnimation(PLAYER_ATTACK1), use this:
[lua]self.Owner:DoAnimationEvent(1, false)[/lua]
[QUOTE=_Kilburn;22655679]This is how animations are handled in the base gamemode:
function GM:DoAnimationEvent( ply, event, data )
if event == PLAYERANIMEVENT_ATTACK_PRIMARY then
if ply:Crouching() then
ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_CROUCH_PRIMARYFIRE )
else
ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_STAND_PRIMARYFIRE )
end
return ACT_VM_PRIMARYATTACK
As you can see, when the primary attack animation event is received, it forces the viewmodel to play the primary attack animation as well, which is indeed quite annoying. I don't know if there is any simple way to prevent this from happening, but in the meantime, try doing this:
hook.Add("DoAnimationEvent", "DoCustomFireAnimation", function(ply, event, data)
if event == PLAYERANIMEVENT_CUSTOM_GESTURE then
if data == 1 then
if ply:Crouching() then
ply:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_CROUCH_PRIMARYFIRE)
else
ply:AnimRestartGesture(GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_ATTACK_STAND_PRIMARYFIRE)
end
return ACT_INVALID
end
end
end)
This should be shared, so you can put this somewhere in the shared.lua of your SWEP, like, at the very end of the file.
Then, instead of self.Owner:SetAnimation(PLAYER_ATTACK1), use this:
self.Owner:DoAnimationEvent(1, false)[/QUOTE]
Works perfectly, thanks :)
I'm considering adding a hook to call into the SWEP to override DoAnimationEvent.
Sorry, you need to Log In to post a reply to this thread.