Advertisement
Guest User

Untitled

a guest
May 28th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.29 KB | None | 0 0
  1. hook.Add("UpdateAnimation","sg", function( ply, velocity, maxseqgroundspeed )
  2.    
  3.     local eye = ply:EyeAngles()
  4.    
  5.         // correct player angles
  6.     ply:SetLocalAngles( eye )
  7.  
  8.     if CLIENT then
  9.                 // set rendering angles for zombie
  10.         ply:SetRenderAngles( eye )
  11.     end
  12.    
  13.     local estyaw = math.Clamp( math.atan2(velocity.y, velocity.x) * 180 / math.pi, -180, 180 )
  14.     local myaw = math.NormalizeAngle(math.NormalizeAngle(eye.y) - estyaw)
  15.    
  16.         // set the move_yaw (because it's not an hl2mp model)
  17.     //ply:SetPoseParameter("move_yaw", -myaw)
  18.    
  19.     local len2d = velocity:Length2D()
  20.     local rate = 1.0
  21.    
  22.     if len2d > 0.5 then
  23.             rate =  ( ( len2d * 0.8 ) / maxseqgroundspeed )
  24.     end
  25.    
  26.     rate = math.Clamp(rate, 0, 1.5)
  27.        // you can obviously set your own playback rate
  28.    
  29.     ply:SetPlaybackRate( rate )
  30. end)
  31.  
  32. hook.Add("CalcMainActivity","sg", function( ply, velocity )
  33.     ply.CalcIdeal = ACT_MP_STAND_IDLE
  34.     ply.CalcSeqOverride = -1
  35.    
  36. //  if self:HandlePlayerDriving( ply ) ||
  37.     //  self:HandlePlayerJumping( ply ) ||
  38.     //  self:HandlePlayerDucking( ply, velocity ) ||
  39.     //  self:HandlePlayerSwimming( ply ) then
  40.        
  41. //  else
  42.         local len2d = velocity:Length2D()
  43.        
  44.         if len2d > 210 then
  45.             ply.CalcIdeal = ACT_MP_RUN
  46.         elseif len2d > 0.5 then
  47.             ply.CalcIdeal = ACT_MP_WALK
  48.         end
  49. //  end
  50.    
  51.     // a bit of a hack because we're missing ACTs for a couple holdtypes
  52.     local weapon = ply:GetActiveWeapon()
  53.    
  54.     if ply.CalcIdeal == ACT_MP_CROUCH_IDLE &&
  55.         IsValid(weapon) &&
  56.         ( weapon._InternalHoldType == "knife" || weapon._InternalHoldType == "melee2" ) then
  57.        
  58.         ply.CalcSeqOverride = ply:LookupSequence("cidle_" .. weapon._InternalHoldType)
  59.     end
  60.    
  61.     if( ply.m_iPunchAttack and CurTime() < ply.m_iPunchAttack ) then
  62.         return ply.CalcIdeal, ply:LookupSequence( "sit" )
  63.     end
  64.    
  65.     return ply.CalcIdeal, ply.CalcSeqOverride
  66. end)
  67.  
  68. hook.Add("DoAnimationEvent","sg", function( ply, event, data )
  69.     if event == PLAYERANIMEVENT_ATTACK_PRIMARY then
  70.  
  71.         ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MELEE_ATTACK_SWING_GESTURE )
  72.         return ACT_VM_PRIMARYATTACK
  73.        
  74.     elseif event == PLAYERANIMEVENT_JUMP then
  75.    
  76.         ply.m_bJumping = true
  77.         ply.m_bFirstJumpFrame = true
  78.         ply.m_flJumpStartTime = CurTime()
  79.        
  80.         ply:AnimRestartMainSequence()
  81.        
  82.         return ACT_INVALID
  83.     end
  84.    
  85.     return nil
  86. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement