SWEP Custom Animation Mapping?

Hi. Not sure what to do here. I have a viewmodel with a custom animation attached to it, and when it sends the animation event ACT_VM_PRIMARYATTACK or anything like that, it seems to choose a random animation from the viewmodel. How do a map certain animations to ACT_VM_PRIMARYATTACK? I’m not even sure this is what you do. How do I get the weapon to play the correct animation? Do I have to decompile and recompile the model? I can’t find anything on the wiki, so I’m kinda stuck.

Any responses are appreciated, thanks.

Try using

Entity:SendViewModelMatchingSequence instead, that lets you send custom sequences to the viewmodel, E.G.

local vm = self.Owner:GetViewModel()
local name = 'somesequence'
local seq = vm:LookupSequence( name )
vm:SendViewModelMatchingSequence( seq )

That works fine, but now it breaks the rest of the reloading code. Here it is:

function SWEP:Reload()
	if (self.Weapon:Clip1() < self.Primary.ClipSize) then
		if self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then
			self.Weapon:EmitSound( ReloadSound )
		local ply = self.Owner
		local view = ply:GetViewModel()
		local name = 'machine_reload'
		local seq = view:LookupSequence( name )
		view:SendViewModelMatchingSequence( seq )
		self:SetIronsights( false )

Should probably clarify, it breaks it by once the anim is finished it doesn’t reload.

Well you aren’t doing anything. You’ve sent the anim and the sound, but you haven’t done anything with the clip.

Yeah, I saw that. I’m modifying someone’s base, and without the new line of code the reload works fine, so I assumed that it did that by default somehow?

Try to find the Reload function in your SWEP base’s code then, it might help you figure out what’s happening

There is no reload func in the swep base code. It’s user defined.

Also, on another note, the SWEP.Automatic isn’t working. Even when it is set to true, it does nothing when I hold down the mouse button. Do I have to code that behavior?

It’s SWEP.Primary.Automatic, and check for any calls to Reload or SequenceDuration