Advertisement
Guest User

sh_anim.lua

a guest
Jan 21st, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.69 KB | None | 0 0
  1. local ActIndex = {
  2.     [ "pistol" ]         = ACT_HL2MP_IDLE_PISTOL,
  3.     [ "smg" ]             = ACT_HL2MP_IDLE_SMG1,
  4.     [ "grenade" ]         = ACT_HL2MP_IDLE_GRENADE,
  5.     [ "ar2" ]             = ACT_HL2MP_IDLE_AR2,
  6.     [ "shotgun" ]         = ACT_HL2MP_IDLE_SHOTGUN,
  7.     [ "rpg" ]             = ACT_HL2MP_IDLE_RPG,
  8.     [ "physgun" ]         = ACT_HL2MP_IDLE_PHYSGUN,
  9.     [ "crossbow" ]         = ACT_HL2MP_IDLE_CROSSBOW,
  10.     [ "melee" ]         = ACT_HL2MP_IDLE_MELEE,
  11.     [ "slam" ]             = ACT_HL2MP_IDLE_SLAM,
  12.     [ "normal" ]        = ACT_HL2MP_IDLE,
  13.     [ "fist" ]            = ACT_HL2MP_IDLE_FIST,
  14.     [ "melee2" ]        = ACT_HL2MP_IDLE_MELEE2,
  15.     [ "passive" ]        = ACT_HL2MP_IDLE_PASSIVE,
  16.     [ "knife" ]            = ACT_HL2MP_IDLE_KNIFE,
  17.     [ "duel" ]            = ACT_HL2MP_IDLE_DUEL,
  18.     [ "camera" ]        = ACT_HL2MP_IDLE_CAMERA,
  19.     [ "revolver" ]        = ACT_HL2MP_IDLE_REVOLVER    
  20. }
  21.    
  22.    
  23. --[[---------------------------------------------------------
  24.    Name: SetWeaponHoldType
  25.    Desc: Sets up the translation table, to translate from normal
  26.             standing idle pose, to holding weapon pose.
  27. -----------------------------------------------------------]]
  28. function SWEP:SetWeaponHoldType( t )
  29.  
  30.  
  31.     t = string.lower( t )
  32.     local index = ActIndex[ t ]
  33.    
  34.     if ( index == nil ) then
  35.         Msg( "SWEP:SetWeaponHoldType - ActIndex[ \""..t.."\" ] isn't set! (defaulting to normal)\n" )
  36.         t = "normal"
  37.         index = ActIndex[ t ]
  38.     end
  39.  
  40.  
  41.     self.ActivityTranslate = {}
  42.     self.ActivityTranslate [ ACT_MP_STAND_IDLE ]                 = index
  43.     self.ActivityTranslate [ ACT_MP_WALK ]                         = index+1
  44.     self.ActivityTranslate [ ACT_MP_RUN ]                         = index+2
  45.     self.ActivityTranslate [ ACT_MP_CROUCH_IDLE ]                 = index+3
  46.     self.ActivityTranslate [ ACT_MP_CROUCHWALK ]                 = index+4
  47.     self.ActivityTranslate [ ACT_MP_ATTACK_STAND_PRIMARYFIRE ]     = index+5
  48.     self.ActivityTranslate [ ACT_MP_ATTACK_CROUCH_PRIMARYFIRE ] = index+5
  49.     self.ActivityTranslate [ ACT_MP_RELOAD_STAND ]                 = index+6
  50.     self.ActivityTranslate [ ACT_MP_RELOAD_CROUCH ]                 = index+6
  51.     self.ActivityTranslate [ ACT_MP_JUMP ]                         = index+7
  52.     self.ActivityTranslate [ ACT_RANGE_ATTACK1 ]                 = index+8
  53.     self.ActivityTranslate [ ACT_MP_SWIM_IDLE ]                 = index+8
  54.     self.ActivityTranslate [ ACT_MP_SWIM ]                         = index+9
  55.    
  56.     -- "normal" jump animation doesn't exist
  57.     if t == "normal" then
  58.         self.ActivityTranslate [ ACT_MP_JUMP ] = ACT_HL2MP_JUMP_SLAM
  59.     end
  60.    
  61.     -- these two aren't defined in ACTs for whatever reason
  62.     if t == "knife" || t == "melee2" then
  63.         self.ActivityTranslate [ ACT_MP_CROUCH_IDLE ] = nil
  64.     end
  65.    
  66.     self:SetupWeaponHoldTypeForAI( t )
  67.  
  68.  
  69. end
  70.  
  71.  
  72. -- Default hold pos is the pistol
  73. SWEP:SetWeaponHoldType( "pistol" )
  74.  
  75.  
  76. --[[---------------------------------------------------------
  77.    Name: weapon:TranslateActivity( )
  78.    Desc: Translate a player's Activity into a weapon's activity
  79.          So for example, ACT_HL2MP_RUN becomes ACT_HL2MP_RUN_PISTOL
  80.          Depending on how you want the player to be holding the weapon
  81. -----------------------------------------------------------]]
  82. function SWEP:TranslateActivity( act )
  83.  
  84.  
  85.     if ( self.Owner:IsNPC() ) then
  86.         if ( self.ActivityTranslateAI[ act ] ) then
  87.             return self.ActivityTranslateAI[ act ]
  88.         end
  89.         return -1
  90.     end
  91.  
  92.  
  93.     if ( self.ActivityTranslate[ act ] != nil ) then
  94.         return self.ActivityTranslate[ act ]
  95.     end
  96.    
  97.     return -1
  98.  
  99.  
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement