Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 41.91 KB | None | 0 0
  1. --Hey hey hey! It's fucking NPC animations version three! This time with no Rick Dark shit.
  2. --Credits to YO MOMMA ( Original hook ), Entoros( Holdtype thing -- Which is no more, since garry added that in :/ )
  3. AddCSLuaFile( "animations.lua" )
  4. resource.AddFile( "models/Gustavio/alyxanimtree.mdl" )
  5. resource.AddFile( "models/Gustavio/combineanimtree.mdl" )
  6. resource.AddFile( "models/Gustavio/maleanimtree.mdl" )
  7. resource.AddFile( "models/Gustavio/femaleanimtree.mdl" )
  8. resource.AddFile( "models/Gustavio/metroanimtree.mdl" )
  9. resource.AddFile( "models/Gustavio/barneyanimtree.mdl" )
  10.  
  11. local meta = FindMetaTable( "Player" )
  12. local model
  13. function meta:GetGender()
  14.  
  15.     model = self:GetModel()
  16.     if table.HasValue( Anims.Female[ "models" ], model ) or self:GetNWString( "gender", "Male" ) == "Female" then
  17.         return "Female"
  18.     end
  19.    
  20.     return "Male"
  21.  
  22. end
  23.  
  24. if SERVER then
  25.     --Weapons that are always aimed
  26.     AlwaysAimed = {
  27.         "weapon_physgun",
  28.         "weapon_physcannon",
  29.         "weapon_frag",
  30.         "weapon_slam",
  31.         "weapon_rpg",
  32.         "gmod_tool"
  33.     }
  34.  
  35.     --Weapons that are never aimed
  36.     NeverAimed = {
  37.     }
  38.    
  39.     function meta:SetAiming( bool )
  40.         local wep = self:GetActiveWeapon()
  41.         if self:GetNWBool( "arrested", false ) then
  42.             bool = false
  43.         end
  44.         if ValidEntity( wep ) then
  45.             if table.HasValue( AlwaysAimed, wep:GetClass() ) then
  46.                 bool = true
  47.             end
  48.             if table.HasValue( NeverAimed, wep:GetClass() ) then
  49.                 bool = false
  50.             end
  51.             if bool then
  52.                 wep:SetNextPrimaryFire( CurTime() )
  53.             else
  54.                 wep:SetNextPrimaryFire( CurTime() + 999999 )
  55.             end
  56.         end
  57.         self:DrawViewModel( bool )
  58.         self:SetNWBool( "aiming", bool )
  59.     end
  60.    
  61.     local function HolsterToggle( ply, cmd, args )
  62.         ply:SetAiming( !ply:GetAiming() )
  63.     end
  64.     concommand.Add( "rp_toggleholster", HolsterToggle );
  65.     concommand.Add( "toggleholster", HolsterToggle );
  66.    
  67.     hook.Add( "PlayerSpawn", "BeginAimTimer", function( ply )
  68.         timer.Create( ply:SteamID() .. "TiramisuAimTimer", 0.1, 0, function()
  69.             if ValidEntity( ply ) then
  70.                 if ply.TiramisuLastWeapon and ValidEntity( ply:GetActiveWeapon() ) and ply:GetActiveWeapon():GetClass() != ply.TiramisuLastWeapon then
  71.                     ply:SetAiming( false )
  72.                     ply.TiramisuLastWeapon = ply:GetActiveWeapon():GetClass()
  73.                 else
  74.                     if ValidEntity( ply:GetActiveWeapon() ) then
  75.                         ply.TiramisuLastWeapon = ply:GetActiveWeapon():GetClass()
  76.                     end
  77.                 end
  78.             end
  79.         end)
  80.     end)
  81.  
  82.        hook.Add( "KeyPress", "TiramisuAimCheck", function(ply, key)
  83.                if ValidEntity( ply ) and ValidEntity( ply:GetActiveWeapon() ) then
  84.                        if key == IN_ATTACK or key == IN_ATTACK2 then
  85.                                ply:SetAiming( true )
  86.                        end
  87.                end
  88.        end )
  89.    
  90. end
  91.  
  92. function meta:GetAiming()
  93.     if self:GetNWBool( "aiming", false ) then
  94.         return true
  95.     end
  96.    
  97.     return false
  98. end
  99.  
  100. meta = nil
  101.  
  102. Anims = {}
  103. Anims.Male = {}
  104. Anims.Male[ "models" ] = {
  105.     "models/Gustavio/maleanimtree.mdl",
  106.     "models/Gustavio/combineanimtree.mdl",
  107.     "models/Gustavio/metroanimtree.mdl"
  108. }
  109. Anims.Male[ "default" ] = {
  110.        [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_IDLE",
  111.         --[ "idle" ] = "&sequence:LineIdle01;models/Gustavio/maleanimtree.mdl",
  112.        [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK",
  113.        [ "run" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RUN",
  114.        [ "jump" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_JUMP",
  115.        [ "land" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_LAND",
  116.        [ "fly" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_GLIDE",
  117.        [ "sit" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_BUSY_SIT_CHAIR",
  118.        [ "sitentry" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_BUSY_SIT_CHAIR_ENTRY",
  119.        [ "sitexit" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_BUSY_SIT_CHAIR_EXIT",
  120.     [ "swim" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_GLIDE",
  121.        [ "sitground" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_BUSY_SIT_GROUND",
  122.        [ "sitgroundentry" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_BUSY_SIT_GROUND_ENTRY",
  123.        [ "sitgroundexit" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_BUSY_SIT_GROUND_EXIT",
  124.        [ "flinch" ] = {
  125.                ["explosion"] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_GESTURE_FLINCH_BLAST"
  126.                },
  127.         [ "crouch" ] = {
  128.                 [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_COVER_LOW",
  129.                 [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_CROUCH",
  130.                 [ "aimidle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  131.                 [ "aimwalk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_CROUCH_AIM_RIFLE"
  132.         },
  133.         [ "aim" ] = {
  134.                [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_IDLE_AIM_RIFLE_STIMULATED",
  135.                [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_AIM_RIFLE_STIMULATED",
  136.                [ "run" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RUN_AIM_RIFLE_STIMULATED"
  137.        }
  138. }
  139. Anims.Male[ "pistol" ] = {
  140.        [ "idle" ] = "ACT_IDLE",
  141.        [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_PISTOL",
  142.        [ "run" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_RUN_PISTOL",
  143.        [ "crouch" ] = {
  144.                [ "idle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_COVER_PISTOL_LOW",
  145.                [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_CROUCH",
  146.                [ "aimidle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_COVER_PISTOL_LOW",
  147.                [ "aimwalk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_CROUCH"
  148.                },
  149.        [ "aim" ] = {
  150.                [ "idle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_IDLE_ANGRY_PISTOL",
  151.                [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_AIM_PISTOL",
  152.                [ "run" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_RUN_AIM_PISTOL"
  153.        },
  154.         [ "fire" ] = "ACT_GESTURE_RANGE_ATTACK_PISTOL",
  155.        [ "reload" ] = "ACT_GESTURE_RELOAD_PISTOL"
  156. }
  157. Anims.Male[ "ar2" ] = {
  158.        [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_IDLE_SMG1_RELAXED",
  159.        [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_RIFLE_RELAXED",
  160.        [ "run" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RUN_RIFLE_RELAXED",
  161.        [ "crouch" ] = {
  162.                [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_COVER_LOW",
  163.                [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_CROUCH_RIFLE",
  164.                [ "aimidle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  165.                [ "aimwalk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_CROUCH_AIM_RIFLE"
  166.                },
  167.        [ "aim" ] = {
  168.                [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_IDLE_AIM_RIFLE_STIMULATED",
  169.                [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_AIM_RIFLE_STIMULATED",
  170.                [ "run" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RUN_AIM_RIFLE_STIMULATED"
  171.        },
  172.         ["fire"] = "ACT_GESTURE_RANGE_ATTACK_SMG1"
  173. }
  174.  
  175. Anims.Male[ "smg" ] = {
  176.        [ "idle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_IDLE_SMG1",
  177.        [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_RIFLE",
  178.        [ "run" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_RUN_RIFLE",
  179.        [ "crouch" ] = {
  180.                [ "idle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_COVER_SMG1_LOW",
  181.                [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_CROUCH",
  182.                [ "aimidle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_COVER_SMG1_LOW",
  183.                [ "aimwalk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_CROUCH"
  184.                },
  185.        [ "aim" ] = {
  186.                [ "idle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_IDLE_ANGRY_SMG1",
  187.                [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_RIFLE",
  188.                [ "run" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_RUN_RIFLE"
  189.        },
  190.         [ "fire" ] = "ACT_GESTURE_RANGE_ATTACK_SMG1",
  191.        [ "reload" ] = "ACT_GESTURE_RELOAD_SMG1"
  192. }
  193.  
  194. Anims.Male[ "shotgun" ] = {
  195.        [ "idle" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_IDLE",
  196.        [ "walk" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_WALK_RIFLE",
  197.        [ "run" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_RUN_RIFLE",
  198.        [ "crouch" ] = {
  199.                [ "idle" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_COVER_LOW",
  200.                [ "walk" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_WALK_CROUCH_RIFLE",
  201.                [ "aimidle" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_RANGE_AIM_AR2_LOW",
  202.                [ "aimwalk" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_WALK_CROUCH_RIFLE"
  203.                },
  204.        [ "aim" ] = {
  205.                [ "idle" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_IDLE_ANGRY_SHOTGUN",
  206.                [ "walk" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_WALK_AIM_SHOTGUN",
  207.                [ "run" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_RUN_AIM_SHOTGUN"
  208.        },
  209.         ["fire"] = "ACT_GESTURE_RANGE_ATTACK_SHOTGUN"
  210. }
  211.  
  212. Anims.Male[ "crossbow" ] = {
  213.        [ "idle" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_IDLE",
  214.        [ "walk" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_WALK_RIFLE",
  215.        [ "run" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_RUN_RIFLE",
  216.        [ "crouch" ] = {
  217.                [ "idle" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_COVER_LOW",
  218.                [ "walk" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_WALK_CROUCH_RIFLE",
  219.                [ "aimidle" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_RANGE_AIM_AR2_LOW",
  220.                [ "aimwalk" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_WALK_CROUCH_RIFLE"
  221.                },
  222.        [ "aim" ] = {
  223.                [ "idle" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_IDLE_ANGRY",
  224.                [ "walk" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_WALK_AIM_RIFLE",
  225.                [ "run" ] = "&switch:models/Gustavio/combineanimtree.mdl;ACT_RUN_AIM_RIFLE"
  226.        },
  227.         ["fire"] = "ACT_GESTURE_RANGE_ATTACK_AR2"
  228. }
  229.  
  230. Anims.Male[ "rpg" ] = {
  231.        [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_IDLE_RPG",
  232.        [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_RPG_RELAXED",
  233.        [ "run" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RUN_RPG_RELAXED",
  234.        [ "crouch" ] = {
  235.                [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_COVER_LOW_RPG",
  236.                [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_CROUCH_RPG",
  237.                [ "aimidle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  238.                [ "aimwalk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_CROUCH_AIM_RIFLE"
  239.                },
  240.        [ "aim" ] = {
  241.                [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_IDLE_ANGRY_RPG",
  242.                [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_AIM_RIFLE_STIMULATED",
  243.                [ "run" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RUN_AIM_RIFLE_STIMULATED"
  244.        },
  245.         ["fire"] = "ACT_GESTURE_RANGE_ATTACK_SMG1"
  246. }
  247.  
  248. Anims.Male[ "melee" ] = {
  249.         [ "idle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_IDLE",
  250.        [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK",
  251.        [ "run" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_RUN",
  252.        [ "crouch" ] = {
  253.                [ "idle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_COVER_PISTOL_LOW",
  254.                [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_CROUCH",
  255.                [ "aimidle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_COVER_PISTOL_LOW",
  256.                [ "aimwalk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_CROUCH"
  257.                },
  258.        [ "aim" ] = {
  259.                [ "idle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_IDLE_ANGRY_MELEE",
  260.                [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_ANGRY",
  261.                [ "run" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_RUN"
  262.        },
  263.         ["fire"] = "ACT_MELEE_ATTACK_SWING_GESTURE"
  264. }
  265.  
  266. Anims.Male[ "grenade" ] = {
  267.        [ "idle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_IDLE",
  268.        [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK",
  269.        [ "run" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_RUN",
  270.        [ "crouch" ] = {
  271.                [ "idle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_COVER_PISTOL_LOW",
  272.                [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_CROUCH",
  273.                [ "aimidle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_COVER_PISTOL_LOW",
  274.                [ "aimwalk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_CROUCH"
  275.                },
  276.        [ "aim" ] = {
  277.                [ "idle" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_IDLE_ANGRY_MELEE",
  278.                [ "walk" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_WALK_ANGRY",
  279.                [ "run" ] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_RUN"
  280.        },
  281.         ["fire"] = "&switch:models/Gustavio/metroanimtree.mdl;ACT_COMBINE_THROW_GRENADE"
  282. }
  283.  
  284. Anims.Male[ "slam" ] = {
  285.        [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_IDLE",
  286.        [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_SUITCASE",
  287.        [ "run" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RUN",
  288.        [ "crouch" ] = {
  289.                [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_COVER_LOW",
  290.                [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_CROUCH",
  291.                [ "aimidle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  292.                [ "aimwalk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_CROUCH_RPG"
  293.                },
  294.        [ "aim" ] = {
  295.                [ "idle" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_IDLE_PACKAGE",
  296.                [ "walk" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_WALK_PACKAGE",
  297.                [ "run" ] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_RUN"
  298.        },
  299.         ["fire"] = "&switch:models/Gustavio/maleanimtree.mdl;ACT_PICKUP_RACK"
  300. }
  301.  
  302.  
  303. Anims.Female = {}
  304. Anims.Female[ "models" ] = {
  305.     "models/Gustavio/femaleanimtree.mdl",
  306.     "models/Gustavio/alyxanimtree.mdl"
  307. }
  308. Anims.Female[ "default" ] = {
  309.        [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_IDLE",
  310.        [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK",
  311.        [ "run" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RUN",
  312.        [ "jump" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_JUMP",
  313.        [ "land" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_LAND",
  314.        [ "fly" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_GLIDE",
  315.        [ "sit" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_BUSY_SIT_CHAIR",
  316.        [ "sitentry" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_BUSY_SIT_CHAIR_ENTRY",
  317.        [ "sitexit" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_BUSY_SIT_CHAIR_EXIT",
  318.     [ "swim" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_GLIDE",
  319.        [ "sitground" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_BUSY_SIT_GROUND",
  320.        [ "sitgroundentry" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_BUSY_SIT_GROUND_ENTRY",
  321.        [ "sitgroundexit" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_BUSY_SIT_GROUND_EXIT",
  322.        [ "flinch" ] = {
  323.                ["explosion"] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_GESTURE_FLINCH_BLAST"
  324.                },
  325.         [ "crouch" ] = {
  326.                 [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_COVER_LOW",
  327.                 [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_CROUCH",
  328.                 [ "aimidle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  329.                 [ "aimwalk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_CROUCH_AIM_RIFLE"
  330.         },
  331.         [ "aim" ] = {
  332.                [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_IDLE_AIM_RIFLE_STIMULATED",
  333.                [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_AIM_RIFLE_STIMULATED",
  334.                [ "run" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RUN_AIM_RIFLE_STIMULATED"
  335.        }
  336. }
  337. Anims.Female[ "pistol" ] = {
  338.        [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_IDLE_PISTOL",
  339.        [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK",
  340.        [ "run" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RUN",
  341.        [ "crouch" ] = {
  342.                [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_COVER_LOW",
  343.                [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_CROUCH",
  344.                [ "aimidle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  345.                [ "aimwalk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_CROUCH_AIM_RIFLE"
  346.                },
  347.        [ "aim" ] = {
  348.                [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_IDLE_ANGRY_PISTOL",
  349.                [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_AIM_PISTOL",
  350.                [ "run" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RUN_AIM_PISTOL"
  351.        },
  352.         [ "fire" ] = "ACT_GESTURE_RANGE_ATTACK_PISTOL",
  353. }
  354. Anims.Female[ "ar2" ] = {
  355.        [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_IDLE_SMG1_RELAXED",
  356.        [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_RIFLE_RELAXED",
  357.        [ "run" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RUN_RIFLE_RELAXED",
  358.        [ "crouch" ] = {
  359.                [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_COVER_LOW",
  360.                [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_CROUCH_RIFLE",
  361.                [ "aimidle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  362.                [ "aimwalk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_CROUCH_AIM_RIFLE"
  363.                },
  364.        [ "aim" ] = {
  365.                [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_IDLE_AIM_RIFLE_STIMULATED",
  366.                [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_AIM_RIFLE_STIMULATED",
  367.                [ "run" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RUN_AIM_RIFLE_STIMULATED"
  368.        },
  369.         ["fire"] = "ACT_GESTURE_RANGE_ATTACK_SMG1"
  370. }
  371.  
  372. Anims.Female[ "smg" ] = {
  373.        [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_IDLE_SMG1",
  374.        [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_RIFLE",
  375.        [ "run" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RUN_RIFLE",
  376.        [ "crouch" ] = {
  377.                [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_COVER_LOW",
  378.                [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_CROUCH_RIFLE",
  379.                [ "aimidle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  380.                [ "aimwalk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_CROUCH_AIM_RIFLE"
  381.                },
  382.        [ "aim" ] = {
  383.                [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_IDLE_ANGRY_SMG1",
  384.                [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_AIM_RIFLE",
  385.                [ "run" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RUN_AIM_RIFLE"
  386.        },
  387.         [ "fire" ] = "ACT_GESTURE_RANGE_ATTACK_SMG1",
  388. }
  389.  
  390. Anims.Female[ "shotgun" ] = {
  391.        [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_IDLE_SHOTGUN_STIMULATED",
  392.        [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_RIFLE_RELAXED",
  393.        [ "run" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RUN_RIFLE_RELAXED",
  394.        [ "crouch" ] = {
  395.                [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_COVER_LOW",
  396.                [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_CROUCH_RIFLE",
  397.                [ "aimidle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  398.                [ "aimwalk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_CROUCH_RIFLE"
  399.                },
  400.        [ "aim" ] = {
  401.                [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_IDLE_ANGRY_RPG",
  402.                [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_AIM_RIFLE",
  403.                [ "run" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RUN_AIM_RIFLE"
  404.        },
  405.         ["fire"] = "ACT_GESTURE_RANGE_ATTACK_SHOTGUN"
  406. }
  407.  
  408. Anims.Female[ "crossbow" ] = {
  409.        [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_IDLE_SMG1_RELAXED",
  410.        [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_RIFLE_RELAXED",
  411.        [ "run" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RUN_RIFLE_RELAXED",
  412.        [ "crouch" ] = {
  413.                [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_COVER_LOW",
  414.                [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_CROUCH_RIFLE",
  415.                [ "aimidle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  416.                [ "aimwalk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_CROUCH_AIM_RIFLE"
  417.                },
  418.        [ "aim" ] = {
  419.                [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_IDLE_AIM_RIFLE_STIMULATED",
  420.                [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_AIM_RIFLE_STIMULATED",
  421.                [ "run" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RUN_AIM_RIFLE_STIMULATED"
  422.        },
  423.         ["fire"] = "ACT_GESTURE_RANGE_ATTACK_SMG1"
  424. }
  425.  
  426. Anims.Female[ "rpg" ] = {
  427.        [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_IDLE_RPG",
  428.        [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_RPG_RELAXED",
  429.        [ "run" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RUN_RPG_RELAXED",
  430.        [ "crouch" ] = {
  431.                [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_COVER_LOW_RPG",
  432.                [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_CROUCH_RPG",
  433.                [ "aimidle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  434.                [ "aimwalk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_CROUCH_AIM_RIFLE"
  435.                },
  436.        [ "aim" ] = {
  437.                [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_IDLE_ANGRY_RPG",
  438.                [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_AIM_RIFLE_STIMULATED",
  439.                [ "run" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RUN_AIM_RIFLE_STIMULATED"
  440.        },
  441.         ["fire"] = "ACT_GESTURE_RANGE_ATTACK_SMG1"
  442. }
  443.  
  444. Anims.Female[ "melee" ] = {
  445.        [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_IDLE",
  446.        [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK",
  447.        [ "run" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RUN",
  448.        [ "crouch" ] = {
  449.                [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_COVER_LOW",
  450.                [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_CROUCH",
  451.                [ "aimidle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_COVER_PISTOL_LOW",
  452.                [ "aimwalk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_CROUCH"
  453.                },
  454.        [ "aim" ] = {
  455.                [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_IDLE_MANNEDGUN",
  456.                [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_PACKAGE",
  457.                [ "run" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RUN"
  458.        },
  459.         ["fire"] = "ACT_MELEE_ATTACK_SWING"
  460. }
  461.  
  462. Anims.Female[ "grenade" ] = {
  463.        [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_IDLE",
  464.        [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK",
  465.        [ "run" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RUN",
  466.        [ "crouch" ] = {
  467.                [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_COVER_LOW",
  468.                [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_CROUCH",
  469.                [ "aimidle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_COVER_PISTOL_LOW",
  470.                [ "aimwalk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_CROUCH"
  471.                },
  472.        [ "aim" ] = {
  473.                [ "idle" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_IDLE_ANGRY_PISTOL",
  474.                [ "walk" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_WALK_PACKAGE",
  475.                [ "run" ] = "&switch:models/Gustavio/alyxanimtree.mdl;ACT_RUN"
  476.        },
  477.         ["fire"] = "ACT_MELEE_ATTACK_SWING"
  478. }
  479.  
  480.  
  481. Anims.Female[ "slam" ] = {
  482.        [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_IDLE",
  483.        [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_SUITCASE",
  484.        [ "run" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RUN",
  485.        [ "crouch" ] = {
  486.                [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_COVER_LOW",
  487.                [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_CROUCH",
  488.                [ "aimidle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RANGE_AIM_SMG1_LOW",
  489.                [ "aimwalk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_CROUCH_RPG"
  490.                },
  491.        [ "aim" ] = {
  492.                [ "idle" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_IDLE_PACKAGE",
  493.                [ "walk" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_WALK_PACKAGE",
  494.                [ "run" ] = "&switch:models/Gustavio/femaleanimtree.mdl;ACT_RUN"
  495.        },
  496.         ["fire"] = "ACT_PICKUP_RACK"
  497. }
  498.  
  499. --local cachetable = {}
  500. local function FindEnumeration( actname ) --Finds the enumeration number based on it's name.
  501.  
  502.     --if cachetable[actname] then return cachetable[actname] end
  503.  
  504.     for k, v in pairs ( _E ) do
  505.         if(  k == actname ) then
  506.             --cachetable[actname] = v
  507.             return tonumber( v );
  508.         end
  509.     end
  510.    
  511.     return -1;
  512.  
  513. end
  514.  
  515. local function FindName( actnum ) --Finds the enumeration name based on it's number.
  516.     for k, v in pairs ( _E ) do
  517.         if(  v == actnum ) then
  518.             return tostring( k );
  519.         end
  520.     end
  521.    
  522.     return "ACT_IDLE";
  523. end
  524.  
  525. local function HandleLuaAnimation( ply, animation )
  526.    
  527.     if CLIENT then
  528.         if !ply.InLuaSequence then
  529.             ply.InLuaSequence = true
  530.             ply:SetLuaAnimation( animation )
  531.         end
  532.     end
  533.    
  534. end
  535.  
  536. function HandleSequence( ply, seq ) --Internal function to handle different sequence types.
  537.    
  538.     --print( seq )
  539.    
  540.     local exp
  541.     local exp2
  542.     local model
  543.     local sequence
  544.     local skeletonanim
  545.     local gender
  546.     local lastseq
  547.     --print( ply:GetModel() )
  548.    
  549.     /*
  550.     if ply.Sequence == seq then
  551.         return FindEnumeration(lastseq)
  552.     end*/
  553.    
  554.     if !ply.SpecialModel then
  555.         ply.SpecialModel = ply:GetNWBool( "specialmodel", false )
  556.     end
  557.    
  558.  
  559.     if !ply.Sequence then
  560.         ply.Sequence = "none"
  561.     end
  562.    
  563.     --if ply.Sequence != seq then
  564.         --print(ply.Sequence .. "GEGSJ")
  565.         if !string.match( seq, "&" ) then
  566.             /*
  567.             if !ply.SpecialModel and seq != "" then
  568.                 timer.Simple( 0.2, function()
  569.                     if string.lower( ply:GetModel() ) != "models/gustavio/" .. string.lower( ply:GetGender() ) .. "animtree.mdl" and !string.match( seq, "models" ) then
  570.                         --print( "Changing model to " .. "models/Gustavio/" .. string.lower( ply:GetGender() ) .. "animtree.mdl LOL!" )
  571.                         ply:SetModel( "models/Gustavio/" .. string.lower( ply:GetGender() ) .. "animtree.mdl" )
  572.                     end
  573.                 end)
  574.             end*/
  575.         else
  576.             ply.Sequence = seq
  577.             if string.match( seq, "sequence" ) then
  578.                 exp = string.Explode( ";", string.gsub( seq, "&", "" ) )
  579.                 exp2 = string.Explode( ":", exp[1] )
  580.                 model = exp2[2]
  581.                 if !model then
  582.                     model = "models/Gustavio/" .. string.lower( ply:GetGender() ) .. "animtree.mdl"
  583.                 end
  584.                 if( ply:GetModel() != model and !ply.SpecialModel ) then
  585.                     --print( "Changing model to " .. model )
  586.                     ply:SetModel( model )
  587.                 end
  588.                 timer.Simple( 0, function()
  589.                     if string.match( exp2[2], "g_" ) or string.match( exp2[2], "gesture" ) then
  590.                         ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( string.gsub( exp2[2], ";", "" ) ) )
  591.                     else
  592.                         ply:SetSequence( ply:LookupSequence( string.gsub( exp2[2], ";", "" ) ) )
  593.                     end
  594.                 end)
  595.                 return ply:LookupSequence( string.gsub( exp2[2], ";", "" ) )
  596.             elseif string.match( seq, "number" ) then
  597.                 exp = string.Explode( ":", string.gsub( seq, "&", "" ) )
  598.                 return tonumber( FindName(exp[2]) )
  599.             end
  600.            
  601.             if string.match( seq, "lua" ) then
  602.                 exp = string.Explode( ";", string.gsub( seq, "&", "" ) )
  603.                 exp2 = string.Explode( ":", exp[1] )
  604.                 sequence = exp2[2]
  605.                 skeletonanim = exp[2] or "ACT_DIERAGDOLL"
  606.                 HandleLuaAnimation( ply, sequence )
  607.                 return FindEnumeration( skeletonanim )
  608.             else
  609.                 if ply.InLuaSequence then
  610.                     if CLIENT then
  611.                         ply:StopAllLuaAnimations()
  612.                     end
  613.                     ply.InLuaSequence = false
  614.                 end
  615.             end
  616.            
  617.             if string.match( seq, "switch" ) then --Internal handler used to switch skeletons.
  618.                 exp = string.Explode( ";", string.gsub( seq, "&", "" ) )
  619.                 exp2 = string.Explode( ":", exp[1] )
  620.                 model = exp2[2]
  621.                 seq = exp[2]
  622.                 if( ply:GetModel() != string.lower(model) and !ply.SpecialModel and ply:GetNWBool( "charloaded", false )) then
  623.                     --print( "Switching model to " .. model )
  624.                     --print(ply.SpecialModel)
  625.                     --print(ply:GetModel())
  626.                     ply:SetModel( model )
  627.                 end
  628.                 return FindEnumeration( seq )
  629.             end
  630.         end
  631.     --end
  632.  
  633.     --print( tostring( FindEnumeration( seq ) ) )
  634.     --print(seq)
  635.     return FindEnumeration( seq )
  636.    
  637. end
  638.  
  639. local shotgunholdtypes = {
  640.     "shotgun",
  641.     "physgun"
  642.    
  643. }
  644.  
  645. local meleeholdtypes = {
  646.     "passive",
  647.     "knife",
  648.     "melee2",
  649.     "melee"
  650. }
  651.        
  652. local function DetectHoldType( act ) --This is just a function used to group up similar holdtype for them to use the same sequences, since NPC animations are kinda limited.
  653.     --You can add or remove to this list as you see fit, if you feel like creating a different holdtype.
  654.    
  655.     if string.match(  act, "pistol" ) then
  656.         return "pistol"
  657.     end
  658.     for k, v in pairs( shotgunholdtypes ) do
  659.         if string.match( act, v ) then
  660.             return "shotgun"
  661.         end
  662.     end
  663.     for k, v in pairs( meleeholdtypes ) do
  664.         if string.match( act, v ) then
  665.             return "melee"
  666.         end
  667.     end
  668.     if string.match(  act, "ar2" ) then
  669.         return "ar2"
  670.     end
  671.     if string.match(  act, "smg" ) then
  672.         return "smg"
  673.     end
  674.     if string.match(  act, "rpg" ) then
  675.         return "rpg"
  676.     end
  677.     if string.match(  act, "grenade" ) then
  678.         return "grenade"
  679.     end
  680.     if string.match(  act, "slam" ) then
  681.         return "slam"
  682.     end
  683.     return "default"
  684.    
  685. end
  686.  
  687. function GM:UpdateAnimation( ply, velocity, maxseqgroundspeed ) -- This handles everything about how sequences run, the framerate, boneparameters, everything.
  688.    
  689.     local eye
  690.     local estyaw
  691.     local myaw
  692.     local len2d
  693.     local rate
  694.     eye = ply:EyeAngles()
  695.     if !ply:GetNWBool( "sittingchair", false ) then
  696.         ply:SetLocalAngles( eye )
  697.         ply:SetEyeTarget( ply:EyePos( ) )
  698.     end
  699.  
  700.     if CLIENT then
  701.         if !ply:GetNWBool( "sittingchair", false ) then
  702.             ply:SetRenderAngles( eye )
  703.         end
  704.     end
  705.    
  706.     estyaw = math.Clamp( math.atan2(velocity.y, velocity.x) * 180 / 3.141592, -180, 180 )
  707.     myaw = math.NormalizeAngle(math.NormalizeAngle(eye.y) - estyaw)
  708.  
  709.     if !ply:GetNWBool( "sittingchair", false ) then
  710.         ply:SetPoseParameter("move_yaw", myaw * -1 )
  711.     else
  712.         ply:SetPoseParameter("move_yaw", 0 )
  713.     end
  714.     --This set of boneparameters are all set to 0 to avoid having the engine setting them to something else, thus resulting in  awkwardly twisted models
  715.     ply:SetPoseParameter("aim_yaw", 0 )
  716.     ply:SetPoseParameter("body_yaw", 0 )
  717.     ply:SetPoseParameter("spine_yaw", 0 )
  718.     ply:SetPoseParameter("head_roll", 0 )
  719.    
  720.     len2d = velocity:Length2D() --Velocity in the x and y axis
  721.     rate = 1.0
  722.    
  723.     if len2d > 0.5 then
  724.             rate =  ( ( len2d * 0.8 ) / maxseqgroundspeed )
  725.     end
  726.    
  727.     rate = math.Clamp(rate, 0, 1.5)
  728.     ply:SetPlaybackRate( rate )
  729.    
  730. end
  731.  
  732. function GM:HandlePlayerJumping( ply ) --Handles jumping
  733.  
  734.        local holdtype
  735.        --If we're not on the ground, then play the gliding animation.
  736.         if !ply.Jumping and !ply:OnGround() and !ply:GetNWBool( "sittingchair", false ) then
  737.                 ply.Jumping = true
  738.                 ply.FirstJumpFrame = false
  739.                 ply.JumpStartTime = CurTime()
  740.         end
  741.        
  742.         if ply.Jumping then
  743.                 if ply.FirstJumpFrame then
  744.                         ply.FirstJumpFrame = false
  745.                         ply:AnimRestartMainSequence()
  746.                 end
  747.                
  748.                 if ply:WaterLevel() >= 2 then
  749.                         ply.Jumping = false
  750.                         ply:AnimRestartMainSequence()
  751.                 end
  752.                
  753.                 if (CurTime() - ply.JumpStartTime) > 0.4 then --If we have been on the air for more than 0.4 seconds, then we're meant to play the land animation.
  754.                    if ply:OnGround() and !ply.Landing and !ply:GetNWBool( "observe" ) then
  755.                             ply.Landing = true
  756.                             timer.Simple( 0.3, function()
  757.                                     ply.Landing = false
  758.                                     ply.Jumping = false
  759.                             end)
  760.                         return true
  761.                    end
  762.                 else
  763.                     if ply:OnGround() and !ply.Landing then
  764.                         ply.Jumping = false
  765.                        ply:AnimRestartMainSequence()
  766.                     end
  767.                end
  768.                
  769.                if ply.Jumping then --If we're still on a part of the jumping sequence, that means we're either on the process of jumping or landing.
  770.               if !ply.Landing then
  771.                            ply.CalcIdeal = ACT_JUMP
  772.               else
  773.                         ply.CalcIdeal = ACT_LAND
  774.             end
  775.                    return true
  776.                end
  777.        end
  778.        
  779.        return false
  780. end
  781.  
  782. function GM:HandlePlayerDucking( ply, velocity ) --Handles crouching
  783.  
  784.         local holdtype = "default"
  785.         if( ValidEntity(  ply:GetActiveWeapon() ) ) then
  786.             holdtype = DetectHoldType( ply:GetActiveWeapon():GetHoldType() )
  787.         end
  788.        if ply:Crouching() then
  789.             if ply:GetNWBool( "aiming", false ) then
  790.                len2d = velocity:Length2D() -- the velocity on the x and y axis.
  791.                if len2d > 0.5 then
  792.                        ply.CalcIdeal =  HandleSequence( ply, Anims[ ply:GetGender() ][ holdtype ][ "crouch" ][ "aimwalk" ] )
  793.                else
  794.                        ply.CalcIdeal =  HandleSequence( ply, Anims[ ply:GetGender() ][ holdtype][ "crouch" ][ "aimidle" ] )
  795.                end
  796.             else
  797.                 len2d = velocity:Length2D()
  798.                
  799.                if len2d > 0.5 then
  800.                         ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ holdtype ][ "crouch" ][ "walk" ] )
  801.                else
  802.                        ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ holdtype ][ "crouch" ][ "idle" ] )
  803.                end
  804.             end
  805.             return true
  806.        end
  807.        
  808.        return false
  809. end
  810.  
  811. function GM:HandlePlayerSwimming( ply ) --Handles swimming.
  812.  
  813.        if ply:WaterLevel() >= 2 then
  814.                 ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ "default" ][ "swim" ] )
  815.                 return true
  816.         end
  817.        
  818.        return false
  819. end
  820.  
  821. function GM:HandlePlayerDriving( ply ) --Handles sequences while in vehicles.
  822.  
  823.     local vehicle
  824.     local class
  825.  
  826.        if ply:InVehicle() then
  827.             vehicle = ply:GetVehicle()
  828.            class = vehicle:GetClass()
  829.             if ( class == "prop_vehicle_prisoner_pod" and vehicle:GetModel() == "models/vehicles/prisoner_pod_inner.mdl" ) then
  830.                     ply.CalcIdeal = HandleSequence( ply, "ACT_IDLE" )
  831.            else
  832.                     ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ "default" ][ "sit" ] )
  833.            end
  834.  
  835.            return true
  836.         end
  837. end
  838.  
  839. function GM:HandleExtraActivities( ply ) --Drop in here everything additional you need checks for.
  840.  
  841.     --Use this hook for all the other sequenced activities you may wanna add, like uh, flying I guess.
  842.  
  843.         if ply:GetNWBool( "sittingchair", false ) then
  844.             if !ply.IsSittingDamn then
  845.                 ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ "default" ][ "sitentry" ]  )
  846.                 timer.Simple( 1.5, function()
  847.                     ply.IsSittingDamn = true
  848.                 end)
  849.                 return true
  850.             else
  851.                 ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ "default" ][ "sit" ]  )
  852.                 return true
  853.             end
  854.         else
  855.             if ply.IsSittingDamn then
  856.                 ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ "default" ][ "sitexit" ]  )
  857.                 timer.Simple( 0.8, function()
  858.                     ply.IsSittingDamn = false
  859.                 end)
  860.                 return true
  861.             end
  862.         end
  863.        
  864.         if ply:GetNWBool( "sittingground", false ) then
  865.             if !ply.IsSittingGround then
  866.                 ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ "default" ][ "sitgroundentry" ]  )
  867.                 timer.Simple( 1.7, function()
  868.                     ply.IsSittingGround = true
  869.                 end)
  870.                 return true
  871.             else
  872.                 ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ "default" ][ "sitground" ]  )
  873.                 return true
  874.             end
  875.         else
  876.             if ply.IsSittingGround then
  877.                 ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ "default" ][ "sitgroundexit" ]  )
  878.                 timer.Simple( 1.2, function()
  879.                     ply.IsSittingGround = false
  880.                 end)
  881.                 return true
  882.             end
  883.         end
  884.        
  885.        return false
  886.  
  887. end
  888.  
  889. function GM:CalcMainActivity( ply, velocity )
  890.         --This is the hook used to handle sequences, if you need to add additional activities you should check the hook above.
  891.         --By a general rule you don't have to touch this hook at all.
  892.         local holdtype = "default"
  893.         if( ValidEntity(  ply:GetActiveWeapon() ) ) then
  894.             holdtype = DetectHoldType( ply:GetActiveWeapon():GetHoldType() )
  895.         end
  896.         ply.CalcIdeal = ACT_IDLE
  897.         ply.CalcSeqOverride = -1
  898.        
  899.         if self:HandleExtraActivities( ply ) or self:HandlePlayerDriving( ply ) or
  900.                 self:HandlePlayerJumping( ply ) or
  901.                 self:HandlePlayerDucking( ply, velocity ) or
  902.                 self:HandlePlayerSwimming( ply )
  903.         then
  904.             --We do nothing, I guess, lol.
  905.         else
  906.             len2d = velocity:Length2D()
  907.                
  908.             if ply:GetNWBool( "aiming", false ) then
  909.                 if len2d > 135 then
  910.                     ply.CalcIdeal =  HandleSequence( ply, Anims[ ply:GetGender() ][  holdtype ][ "run" ] )
  911.                 elseif len2d > 0.1 then
  912.                     ply.CalcIdeal =  HandleSequence( ply, Anims[ ply:GetGender() ][  holdtype ][ "aim" ][ "walk" ] )
  913.                 else
  914.                     ply.CalcIdeal  = HandleSequence( ply, Anims[ ply:GetGender() ][  holdtype ][ "aim" ][ "idle" ] )
  915.                 end
  916.             else
  917.                 if len2d > 135 then
  918.                     ply.CalcIdeal =  HandleSequence( ply, Anims[ ply:GetGender() ][  holdtype ][ "run" ] )
  919.                                         if SERVER then
  920.                                                 ply:SetAiming( false )
  921.                                         end
  922.                 elseif len2d > 0.1 then
  923.                     ply.CalcIdeal =  HandleSequence( ply, Anims[ ply:GetGender() ][  holdtype ][ "walk" ] )
  924.                 else
  925.                     ply.CalcIdeal =  HandleSequence( ply, Anims[ ply:GetGender() ][  holdtype ][ "idle" ] )
  926.                 end
  927.             end
  928.         end
  929.        
  930.         --print( tostring( ply.CalcIdeal ) )
  931.        
  932.         return ply.CalcIdeal, ply.CalcSeqOverride
  933. end    
  934.        
  935. function GM:TranslateActivity( ply, act )
  936.        
  937.         --We're not translating through the weapon, thus, this hook isn't used.
  938.         return act
  939.        
  940. end
  941.  
  942. function GM:DoAnimationEvent( ply, event, data ) -- This is for gestures.
  943.  
  944.         holdtype = "default"
  945.         if( ValidEntity(  ply:GetActiveWeapon() ) ) then
  946.             holdtype = DetectHoldType( ply:GetActiveWeapon():GetHoldType() )
  947.         end
  948.  
  949.         if event == PLAYERANIMEVENT_ATTACK_PRIMARY then
  950.                 if Anims[ ply:GetGender() ][ holdtype ][ "fire" ] then
  951.                     if !string.match( Anims[ ply:GetGender() ][ holdtype ][ "fire" ], "&lua" ) then
  952.                         if( string.match( Anims[ ply:GetGender() ][ holdtype ][ "fire" ], "GESTURE" ) ) then
  953.                                 ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, FindEnumeration(  Anims[ ply:GetGender() ][ holdtype ][ "fire" ] ) ) -- Not a sequence, so I don't use HandleSequence here.
  954.                         else
  955.                             ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ holdtype ][ "fire" ] )
  956.                         end
  957.                     else
  958.                         exp = string.Explode( ";", string.gsub( Anims[ ply:GetGender() ][ holdtype ][ "fire" ], "&", "" ) )
  959.                         exp2 = string.Explode( ":", exp[1] )
  960.                         sequence = exp2[2]
  961.                         if CLIENT then
  962.                             ply:SetLuaAnimation( sequence )
  963.                         end
  964.                     end
  965.                 else
  966.                         ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_GESTURE_RANGE_ATTACK_SMG1 )
  967.                 end
  968.  
  969.                return ACT_VM_PRIMARYATTACK
  970.                
  971.        elseif event == PLAYERANIMEVENT_RELOAD then
  972.                 if Anims[ ply:GetGender() ][ holdtype ][ "reload" ] then
  973.                         if( string.match( Anims[ ply:GetGender() ][ holdtype ][ "reload" ], "GESTURE" ) ) then
  974.                                 ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, FindEnumeration(  Anims[ ply:GetGender() ][ holdtype ][ "reload" ] ) )
  975.                         else
  976.                             --ply.CalcIdeal = HandleSequence( ply, Anims[ ply:GetGender() ][ holdtype ][ "reload" ] )
  977.                         end
  978.                 else
  979.                        ply:AnimRestartGesture( GESTURE_SLOT_ATTACK_AND_RELOAD, ACT_GESTURE_RELOAD_SMG1 )
  980.                 end
  981.                
  982.                return ACT_INVALID
  983.         elseif event == PLAYERANIMEVENT_CANCEL_RELOAD then
  984.        
  985.                ply:AnimResetGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD )
  986.                
  987.                return ACT_INVALID
  988.        end
  989.                
  990.        if event == PLAYERANIMEVENT_JUMP then
  991.        
  992.                ply.Jumping = true
  993.                ply.FirstJumpFrame = true
  994.                ply.JumpStartTime = CurTime()
  995.                
  996.                ply:AnimRestartMainSequence()
  997.                
  998.                return ACT_INVALID
  999.                
  1000.         end
  1001.  
  1002.        return nil
  1003. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement