• utilise animation activities
    7 replies, posted
Hello there, im kinda new to models and animations, so keep that in mind. I made a swep and the most of it does work, except for these two animations: ACT_VM_PRIMARYATTACK_EMPTY ACT_VM_RELOAD This reload animation does work. ACT_VM_RELOAD_EMPTY Its only a small problem, but it just feels wrong when you have a bullet inside the gun barrel and he still pulls the slide back. Or when the slide doesnt stop when no more bullets are left in the mag. Thanks for reading this, Deadalus, aka Lucas.
All of this depends on the viewmodel you're using. Can you link to the model?
-- File removed -- This is an updated version of my old one (the old one is one steam, this update isnt currently, I want to get rid of the bug first) Thanks for the answer, Deadalus, aka Lucas.
Using this code I was able to get the activity enum list: [code]] lua_Run local pWep = Entity(1):GetActiveWeapon() for i = 0, pWep:GetSequenceCount() - 1 do print(pWep:GetSequenceActivityName(i)) end > local pWep = Entity(1):GetActiveWeapon() for i = 0, pWep:GetSequenceCount() - 1 do print(pWep:GetSequenceActivityName(i)) end... ACT_VM_IDLE ACT_VM_DRAW ACT_VM_PRIMARYATTACK ACT_VM_PRIMARYATTACK ACT_VM_PRIMARYATTACK ACT_VM_PRIMARYATTACK_EMPTY ACT_VM_RELOAD ACT_VM_RELOAD_EMPTY[/code] I manually played each activity and they all seem to work correctly. The code included with the zip doesn't even seem to utilise ACT_VM_PRIMARYATTACK_EMPTY or ACT_VM_RELOAD_EMPTY.
[CODE]function SWEP() if ( self.Weapon:Clip1() <= 1 ) then if ( self:Ammo1() <= 0 ) then return end self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK_EMPTY ) end else if ( self.Weapon:Clip1() >= 1 ) then if ( self:Ammo1() <= 0 ) then return end self.Weapon:SendWeaponAnim( ACT_VM_RELOAD_EMPTY ) end end[/CODE] I forgot to include this code. This was an early and never continued attempt to utilise them. Buuut it didnt work and im not that advanced in lua, so I didnt knew how to do it elsewise.
Where are you calling this code? You also need a method name, it can't just be SWEP.
@code_gs Wow, I really think im retarded, but I got it now. Primary Attack Empty: [code]function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then return end local bullet = {} bullet.Num = self.Primary.NumShots bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector( self.Primary.Cone / 90, self.Primary.Cone / 90, 0 ) bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0) bullet.Tracer = self.Primary.Tracer bullet.Force = self.Primary.Force bullet.Damage = self.Primary.Damage bullet.AmmoType = self.Primary.Ammo self.Owner:FireBullets( bullet ) self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) self.Owner:MuzzleFlash() self.Owner:SetAnimation( PLAYER_ATTACK1 ) self.Weapon:EmitSound(Sound(self.Primary.Sound)) self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0.5, 1 )) if (self.Primary.TakeAmmoPerBullet) then self:TakePrimaryAmmo(self.Primary.NumShots) else self:TakePrimaryAmmo(1) end self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) -------------------------------- --shoot_last animation trigger-- if self.Weapon:Clip1() == 0 then self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK_EMPTY ) end -------------------------------- end[/code] Reload Empty [code]function SWEP:Reload() self:SetIronsights( false ) 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 ---------------------------------- --reload_empty animation trigger-- if self.Weapon:Clip1() == 0 then self.Weapon:SendWeaponAnim( ACT_VM_RELOAD_EMPTY ) end ---------------------------------- end[/code] This works perfectly, but thank, I dont know why but you gave me the idea.
Just to note, you don't have to use self.Weapon. It'll work fine with just self.
Sorry, you need to Log In to post a reply to this thread.