Advertisement
ExtReMLapin

Untitled

Dec 12th, 2013
857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.53 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5. function GM:CalcMainActivity( ply, velocity )
  6.     // Define defaults
  7.     local ideal = (ply.AggrStance and ACT_IDLE_ANGRY_MELEE) or ACT_IDLE
  8.    
  9.     local wep = ply:GetActiveWeapon()
  10.     local SHOTGUN = false
  11.     if (IsValid( wep )) then
  12.         local class = wep:GetClass()
  13.         if (class == "weapon_shotgun") then SHOTGUN = true end
  14.         if (class == "weapon_grymod_scar") then RIFLE = true end
  15.     else
  16.         RIFLE = false
  17.         SHOTGUN = false
  18.     end
  19.     local seq = -1
  20.     if (SHOTGUN) then ideal = (ply.AggrStance and ACT_IDLE_SHOTGUN_AGITATED) or ACT_IDLE_SHOTGUN_RELAXED end
  21.     if (RIFLE)   then ideal = ACT_IDLE_ANGRY_SMG1 end
  22.     // Determine speed
  23.     local len2d = velocity:Length2D()
  24.     local RUNNING = ((len2d >= 180) )
  25.     local WALKING = (len2d > 0 and !RUNNING)
  26.     local SRUNNING = ((len2d >= 500) and (ply:GetNWBool("Speed",true)) and !RIFLE)
  27.    
  28.  
  29.     if (RUNNING or WALKING) then ply.AggrStance = false end
  30.    
  31.     // Are we crouching?
  32.     if (ply:Crouching()) then
  33.         ideal = ACT_COVER_LOW_RPG
  34.         if (RIFLE && !WALKING && !RUNNIING) then seq = "crouch_aim_smg1" end
  35.         if (WALKING) then ideal = ACT_RUN_CROUCH end
  36.         if (RUNNING) then ideal = ACT_RUN_CROUCH end
  37.        
  38.         if (WALKING && RIFLE) then seq = "crouchrunaimingall1" end
  39.         if (RUNNING && RIFLE) then seq = "crouchrunholdingall1" end
  40.         --if (WALKING || RUNNING) && SHOTGUN then ideal = ACT_WALK_CROUCH_RIFLE end
  41.         if ply:Health() < 30 then ideal = ACT_RUN_PROTECTED end
  42.     else
  43.         if (WALKING) then ideal = ACT_RUN end
  44.         if (RUNNING) then ideal = ACT_RUN end
  45.         if (SRUNNING) then seq = "sprint_all" end
  46.    
  47.      if (WALKING && RIFLE) then ideal = ACT_WALK_AIM_RIFLE end
  48.      if RUNNING && RIFLE then seq = "run_AR2_Relaxed_all" end
  49.         -- if RUNNING && RIFLE then ideal = ACT_RUN_RIFLE end
  50.         --if (WALKING || RUNNING) && SHOTGUN then ideal = ACT_WALK_RIFLE_RELAXED end
  51.     end
  52.    
  53.    
  54.     local eyeAngles = ply:EyeAngles();
  55.     local yaw = velocity:Angle().yaw;
  56.     local normalized = math.NormalizeAngle(yaw - eyeAngles.y);
  57.  
  58.     ply:SetPoseParameter("move_yaw", normalized);
  59.    
  60.  
  61.    
  62.     // Return
  63.     return ideal, ply:LookupSequence(seq)
  64. end
  65.  
  66.        
  67. function GM:TranslateActivity( ply, act )
  68.     /*local aggr = ply:GetAggr()
  69.     if (!aggr) then return act end
  70.     local wep = ply:GetActiveWeapon()
  71.     if (!IsValid( wep )) then return act end
  72.     local class = wep:GetClass()
  73.     local trans = Translate[ class ]
  74.     if (!trans) then return act end
  75.     return trans[ act ] or act*/
  76.     return act
  77. end
  78.  
  79. function GM:DoAnimationEvent( ply, event, data )
  80.     if event == PLAYERANIMEVENT_ATTACK_PRIMARY then
  81.         local wep = ply:GetActiveWeapon()
  82.         if (!IsValid( wep )) then return end
  83.         local class = wep:GetClass()
  84.         if (SERVER) then
  85.             if (class == "weapon_crowbar") || (wep.IsMelee) then
  86.                 ply:PlayAction( ACT_MELEE_ATTACK_SWING, 0.8 )
  87.             end
  88.             if (class == "weapon_shotgun") then
  89.                 ply:PlayAction( ACT_RANGE_ATTACK_SHOTGUN, 0.8 )
  90.             end
  91.         end
  92.         ply.AggrStance = true
  93.         return ACT_VM_PRIMARYATTACK
  94.            
  95.     elseif event == PLAYERANIMEVENT_RELOAD then
  96.    
  97.         if ply:Crouching() then
  98.  
  99.             ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_RELOAD_CROUCH )
  100.         else
  101.             ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_MP_RELOAD_STAND )
  102.         end
  103.        
  104.         return ACT_INVALID
  105.            
  106.     elseif event == PLAYERANIMEVENT_JUMP then
  107.    
  108.         ply.m_bJumping = true
  109.         ply.m_bFirstJumpFrame = true
  110.         ply.m_flJumpStartTime = CurTime()
  111.        
  112.         ply:AnimRestartMainSequence()
  113.        
  114.         return ACT_INVALID
  115.            
  116.     elseif event == PLAYERANIMEVENT_CANCEL_RELOAD then
  117.    
  118.         ply:AnimResetGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD )
  119.        
  120.         return ACT_INVALID
  121.     end
  122.  
  123.     return nil
  124. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement