-- Fix for gmod 2008 by Botman.
-- Other credits goes to the CGRP community for helping me to sort out the correct animations.
------
-- NPC Animations
-- March 24, 2007
-- Rick Darkaliono
------

NPC_ANIMS_ENABLED = true

--Weapons that are always aimed
AlwaysAimed = 
{
	"weapon_physgun",
	"weapon_physcannon",
	"weapon_frag",
	"weapon_slam",
	"weapon_rpg",
	"gmod_tool",
}

--Weapons that are never aimed
NeverAimed =
{
	"hands"
}

--Weapons that can still be usable while not aimed
UsableHolstered =
{
	"hands"
}

Models = {

-- changed "humans" to "player"
              "models/player/group01/male_01.mdl",
			  "models/player/group01/male_02.mdl",
              "models/player/group01/male_03.mdl",
              "models/player/group01/male_04.mdl",
              "models/player/group01/male_06.mdl",
              "models/player/group01/male_07.mdl",
              "models/player/group01/male_08.mdl",
              "models/player/group01/male_09.mdl",
              "models/player/group02/male_01.mdl",
              "models/player/group02/male_02.mdl",
              "models/player/group02/male_03.mdl",
              "models/player/group02/male_04.mdl",
              "models/player/group02/male_06.mdl",
              "models/player/group02/male_07.mdl",
              "models/player/group02/male_08.mdl",
              "models/player/group02/male_09.mdl",
              "models/player/group03/male_01.mdl",
              "models/player/group03/male_02.mdl",
              "models/player/group03/male_03.mdl",
              "models/player/group03/male_04.mdl",
              "models/player/group03/male_06.mdl",
              "models/player/group03/male_07.mdl",
              "models/player/group03/male_08.mdl",
              "models/player/group03/male_09.mdl",
              "models/player/group03m/male_01.mdl",
              "models/player/group03m/male_02.mdl",
              "models/player/group03m/male_03.mdl",
              "models/player/group03m/male_04.mdl",
              "models/player/group03m/male_06.mdl",
              "models/player/group03m/male_07.mdl",
              "models/player/group03m/male_08.mdl",
              "models/player/group03m/male_09.mdl",
              "models/barnes/citizen/male_01.mdl",
              "models/barnes/citizen/male_02.mdl",
              "models/barnes/citizen/male_03.mdl",
              "models/barnes/citizen/male_04.mdl",
              "models/barnes/citizen/male_06.mdl",
              "models/barnes/citizen/male_07.mdl",
              "models/barnes/citizen/male_08.mdl",
              "models/barnes/citizen/male_09.mdl",
              "models/barnes/refugee/male_01.mdl",
              "models/barnes/refugee/male_02.mdl",
              "models/barnes/refugee/male_03.mdl",
              "models/barnes/refugee/male_04.mdl",
              "models/barnes/refugee/male_06.mdl",
              "models/barnes/refugee/male_07.mdl",
              "models/barnes/refugee/male_08.mdl",
              "models/barnes/refugee/male_09.mdl",

              "models/player/group01/female_01.mdl",
              "models/player/group01/female_02.mdl",
              "models/player/group01/female_03.mdl",
              "models/player/group01/female_04.mdl",
              "models/player/group01/female_06.mdl",
              "models/player/group01/female_07.mdl",
              "models/player/group01/female_08.mdl",
              "models/player/group01/female_09.mdl",
              "models/player/group02/female_01.mdl",
              "models/player/group02/female_02.mdl",
              "models/player/group02/female_03.mdl",
              "models/player/group02/female_04.mdl",
              "models/player/group02/female_06.mdl",
              "models/player/group02/female_07.mdl",
              "models/player/group03/female_01.mdl",
              "models/player/group03/female_02.mdl",
              "models/player/group03/female_03.mdl",
              "models/player/group03/female_04.mdl",
              "models/player/group03/female_06.mdl",
              "models/player/group03/female_07.mdl",
              "models/player/group03m/female_01.mdl",
              "models/player/group03m/female_02.mdl",
              "models/player/group03m/female_03.mdl",
              "models/player/group03m/female_04.mdl",
              "models/player/group03m/female_06.mdl",
              "models/player/group03m/female_07.mdl",
              "models/barnes/citizen/female_01.mdl",
              "models/barnes/citizen/female_02.mdl",
              "models/barnes/citizen/female_03.mdl",
              "models/barnes/citizen/female_04.mdl",
              "models/barnes/citizen/female_06.mdl",
              "models/barnes/citizen/female_07.mdl",
              "models/barnes/refugee/female_01.mdl",
              "models/barnes/refugee/female_02.mdl",
              "models/barnes/refugee/female_03.mdl",
              "models/barnes/refugee/female_04.mdl",
              "models/barnes/refugee/female_06.mdl",
              "models/barnes/refugee/female_07.mdl",
			  
			  "models/breen.mdl",
			  "models/odessa.mdl",
			  "models/barney.mdl",
			  "models/kleiner.mdl",
			  "models/magnusson.mdl",
			  "models/dog.mdl",
			  "models/gman_high.mdl",
			  "models/monk.mdl",
			  "models/alyx.mdl",
			  "models/eli.mdl",
			  "models/vortigaunt_doctor.mdl",
			  "models/Tactical_Rebel.mdl"
}

function HolsterToggle( ply )

	if( not NPC_ANIMS_ENABLED or not ply:IsValid() ) then return; end

	if( not ply:GetActiveWeapon():IsValid() ) then
		return;
	end
	
	if( ply:GetNWInt( "tiedup" ) == 1 ) then 
		return; 
	end

	if( ply:GetNWInt( "holstered" ) == 1 ) then
		
		for j, l in pairs( NeverAimed ) do
			
			if( l == ply:GetActiveWeapon():GetClass() ) then
				return;
			end
			
		end
	
		ply:DrawViewModel( true );
		MakeAim( ply );
	else
		
		for j, l in pairs( AlwaysAimed ) do
			
			if( l == ply:GetActiveWeapon():GetClass() ) then
				return;
			end
			
		end
		
		ply:DrawViewModel( false );
		MakeUnAim( ply );
	end

end
concommand.Add( "rp_toggleholster", HolsterToggle );
concommand.Add( "toggleholster", HolsterToggle );

function MakeAim( ply )

	if( not ply:GetActiveWeapon():IsValid() ) then return; end

	if( not ply:GetActiveWeapon():GetTable().Invisible ) then
		ply:DrawViewModel( true );
		ply:DrawWorldModel( true );
	else
		ply:DrawViewModel( false );
		ply:DrawWorldModel( false );
	end
	
	ply:GetActiveWeapon():SetNWBool( "NPCAimed", true );
	ply:GetActiveWeapon():SetNextPrimaryFire( CurTime() );
	
	ply:SetNWInt( "holstered", 0 );
	
	if( ply:GetActiveWeapon().ToggleWeaponHolster ) then
		ply:GetActiveWeapon():ToggleWeaponHolster( true );
	end
	
	--ply:SetField( "WeapAnim", GetWeaponAct( ply, ply:Weapon_TranslateActivity( ACT_HL2MP_IDLE ) or -1 ), false );

end

function MakeUnAim( ply )

	if( not ply:GetActiveWeapon():IsValid() ) then return; end

	ply:DrawViewModel( false );
	
	if( ply:GetActiveWeapon():IsValid() ) then
		ply:GetActiveWeapon():SetNWBool( "NPCAimed", false );
		
		local delay = true;
		
		for k, v in pairs( UsableHolstered ) do
			if( v == ply:GetActiveWeapon():GetClass() ) then
				delay = false;
			end
		end
		
		if( delay ) then
			ply:GetActiveWeapon():SetNextPrimaryFire( CurTime() + 999999 );
		end
		
		if( ply:GetActiveWeapon():GetNWBool( "ironsights" ) ) then
			ply:GetActiveWeapon():ToggleIronsight();
		end
	end
	
	ply:SetNWInt( "holstered", 1 );
	
	if( ply:GetActiveWeapon().ToggleWeaponHolster ) then
		ply:GetActiveWeapon():ToggleWeaponHolster( false );
	end
	
	--ply:SetField( "WeapAnim", GetWeaponAct( ply, ply:Weapon_TranslateActivity( ACT_HL2MP_IDLE ) or -1 ), false );

end

function NPCPlayerThink()

	if( not NPC_ANIMS_ENABLED ) then return; end

	for k, v in pairs( player.GetAll() ) do
	
		if( not v:GetTable().NPCLastWeapon or not v:GetActiveWeapon():IsValid() or v:GetTable().NPCLastWeapon ~= v:GetActiveWeapon():GetClass() ) then
	
			MakeUnAim( v );
			
			v:GetTable().NPCLastWeapon = "";
			
			if( v:GetActiveWeapon():IsValid() ) then
			
				v:GetTable().NPCLastWeapon = v:GetActiveWeapon():GetClass();
			
				for j, l in pairs( AlwaysAimed ) do
				
					if( l == v:GetActiveWeapon():GetClass() and not v:GetActiveWeapon():GetNWBool( "NPCAimed" ) ) then
						MakeAim( v );
					end
				
				end
			
			end
			
		end
	
	end

end
hook.Add( "Think", "NPCPlayerThink", NPCPlayerThink );


NPCAnim = { }

NPCAnim.CitizenMaleAnim = { }
NPCAnim.CitizenMaleModels = 
{

	        "models/humans/group01/male_01.mdl",
              "models/humans/group01/male_02.mdl",
              "models/humans/group01/male_03.mdl",
              "models/Tactical_Rebel.mdl",
	      "models/humans/group01/male_04.mdl",
              "models/humans/group01/male_06.mdl",
              "models/humans/group01/male_07.mdl",
              "models/humans/group01/male_08.mdl",
              "models/humans/group01/male_09.mdl",
              "models/humans/group02/male_01.mdl",
              "models/humans/group02/male_02.mdl",
              "models/humans/group02/male_03.mdl",
              "models/humans/group02/male_04.mdl",
              "models/humans/group02/male_06.mdl",
              "models/humans/group02/male_07.mdl",
              "models/humans/group02/male_08.mdl",
              "models/humans/group02/male_09.mdl",
              "models/humans/group03/male_01.mdl",
              "models/humans/group03/male_02.mdl",
              "models/humans/group03/male_03.mdl",
              "models/humans/group03/male_04.mdl",
              "models/humans/group03/male_06.mdl",
              "models/humans/group03/male_07.mdl",
              "models/humans/group03/male_08.mdl",
              "models/humans/group03/male_09.mdl",
              "models/humans/group03m/male_01.mdl",
              "models/humans/group03m/male_02.mdl",
              "models/humans/group03m/male_03.mdl",
              "models/humans/group03m/male_04.mdl",
              "models/humans/group03m/male_06.mdl",
              "models/humans/group03m/male_07.mdl",
              "models/humans/group03m/male_08.mdl",
              "models/humans/group03m/male_09.mdl",
              "models/barnes/citizen/male_01.mdl",
              "models/barnes/citizen/male_02.mdl",
              "models/barnes/citizen/male_03.mdl",
              "models/barnes/citizen/male_04.mdl",
              "models/barnes/citizen/male_06.mdl",
              "models/barnes/citizen/male_07.mdl",
              "models/barnes/citizen/male_08.mdl",
              "models/barnes/citizen/male_09.mdl",
              "models/barnes/refugee/male_01.mdl",
              "models/barnes/refugee/male_02.mdl",
              "models/barnes/refugee/male_03.mdl",
              "models/barnes/refugee/male_04.mdl",
              "models/barnes/refugee/male_06.mdl",
              "models/barnes/refugee/male_07.mdl",
              "models/barnes/refugee/male_08.mdl",
              "models/barnes/refugee/male_09.mdl",
}



for k, v in pairs( NPCAnim.CitizenMaleModels ) do

	NPCAnim.CitizenMaleModels[k] = string.lower( v );

end


NPCAnim.CitizenMaleAnim["idle"] = 1
NPCAnim.CitizenMaleAnim["walk"] = 6
NPCAnim.CitizenMaleAnim["run"] = 10
NPCAnim.CitizenMaleAnim["glide"] = 27
NPCAnim.CitizenMaleAnim["sit"] = 0
NPCAnim.CitizenMaleAnim["crouch"] = 5
NPCAnim.CitizenMaleAnim["crouchwalk"] = 8
 
NPCAnim.CitizenMaleAnim["pistolidle"] = 1
NPCAnim.CitizenMaleAnim["pistolwalk"] = 6
NPCAnim.CitizenMaleAnim["pistolrun"] = 10
NPCAnim.CitizenMaleAnim["pistolcrouchwalk"] = 8
NPCAnim.CitizenMaleAnim["pistolcrouch"] = 5
NPCAnim.CitizenMaleAnim["pistolaimidle"] = 317-47
NPCAnim.CitizenMaleAnim["pistolaimwalk"] = 340 - 22
NPCAnim.CitizenMaleAnim["pistolaimrun"] = 319 - 3
NPCAnim.CitizenMaleAnim["pistolaimcrouch"] = 271 + 87
NPCAnim.CitizenMaleAnim["pistolaimcrouchwalk"] = 342
NPCAnim.CitizenMaleAnim["pistolreload"] = 359
NPCAnim.CitizenMaleAnim["pistolfire"] = 285
 
NPCAnim.CitizenMaleAnim["smgidle"] = 311
NPCAnim.CitizenMaleAnim["smgrun"] = 338
NPCAnim.CitizenMaleAnim["smgwalk"] = 337
NPCAnim.CitizenMaleAnim["smgaimidle"] = 302
NPCAnim.CitizenMaleAnim["smgaimwalk"] = 340
NPCAnim.CitizenMaleAnim["smgcrouchwalk"] = 8
NPCAnim.CitizenMaleAnim["smgcrouch"] = 5
NPCAnim.CitizenMaleAnim["smgaimcrouch"] = 5 + 261
NPCAnim.CitizenMaleAnim["smgaimcrouchwalk"] = 342
NPCAnim.CitizenMaleAnim["smgaimrun"] = 319
NPCAnim.CitizenMaleAnim["smgreload"] = 359
NPCAnim.CitizenMaleAnim["smgfire"] = 289
 
NPCAnim.CitizenMaleAnim["ar2idle"] = 320
NPCAnim.CitizenMaleAnim["ar2walk"] = 337
NPCAnim.CitizenMaleAnim["ar2run"] = 338
NPCAnim.CitizenMaleAnim["ar2aimidle"] = 317
NPCAnim.CitizenMaleAnim["ar2aimwalk"] = 340
NPCAnim.CitizenMaleAnim["ar2aimrun"] = 319
NPCAnim.CitizenMaleAnim["ar2crouchwalk"] = 8
NPCAnim.CitizenMaleAnim["ar2crouch"] = 5
NPCAnim.CitizenMaleAnim["ar2aimcrouch"] = 5 + 261
NPCAnim.CitizenMaleAnim["ar2aimcrouchwalk"] = 342
NPCAnim.CitizenMaleAnim["ar2reload"] = 359
NPCAnim.CitizenMaleAnim["ar2fire"] = 281
 
NPCAnim.CitizenMaleAnim["shotgunidle"] = 320
NPCAnim.CitizenMaleAnim["shotgunwalk"] = 337
NPCAnim.CitizenMaleAnim["shotgunrun"] = 338
NPCAnim.CitizenMaleAnim["shotgunaimidle"] = 317
NPCAnim.CitizenMaleAnim["shotgunaimwalk"] = 340
NPCAnim.CitizenMaleAnim["shotgunaimrun"] = 319
NPCAnim.CitizenMaleAnim["shotguncrouchwalk"] = 8
NPCAnim.CitizenMaleAnim["shotguncrouch"] = 5
NPCAnim.CitizenMaleAnim["shotgunaimcrouch"] = 5 + 261
NPCAnim.CitizenMaleAnim["shotgunaimcrouchwalk"] = 342
NPCAnim.CitizenMaleAnim["shotgunreload"] = 361
NPCAnim.CitizenMaleAnim["shotgunfire"] = 288
 
NPCAnim.CitizenMaleAnim["crossbowidle"] = 311
NPCAnim.CitizenMaleAnim["crossbowwalk"] = 337
NPCAnim.CitizenMaleAnim["crossbowrun"] = 338
NPCAnim.CitizenMaleAnim["crossbowaimidle"] = 317
NPCAnim.CitizenMaleAnim["crossbowaimwalk"] = 340
NPCAnim.CitizenMaleAnim["crossbowaimrun"] = 319
NPCAnim.CitizenMaleAnim["crossbowcrouchwalk"] = 8
NPCAnim.CitizenMaleAnim["crossbowcrouch"] = 5
NPCAnim.CitizenMaleAnim["crossbowaimcrouch"] = 328
NPCAnim.CitizenMaleAnim["crossbowaimcrouchwalk"] = 342
NPCAnim.CitizenMaleAnim["crossbowreload"] = 359
NPCAnim.CitizenMaleAnim["crossbowfire"] = 288
 
NPCAnim.CitizenMaleAnim["meleeidle"] = 1
NPCAnim.CitizenMaleAnim["meleewalk"] = 6
NPCAnim.CitizenMaleAnim["meleerun"] = 10
NPCAnim.CitizenMaleAnim["meleeaimidle"] = 328
NPCAnim.CitizenMaleAnim["meleeaimcrouchwalk"] = 8 + 334
NPCAnim.CitizenMaleAnim["meleeaimcrouch"] = 5 + 266
NPCAnim.CitizenMaleAnim["meleecrouchwalk"] = 8
NPCAnim.CitizenMaleAnim["meleecrouch"] = 5
NPCAnim.CitizenMaleAnim["meleeaimwalk"] = 6 + 313
NPCAnim.CitizenMaleAnim["meleeaimrun"] = 10
NPCAnim.CitizenMaleAnim["meleefire"] = 277
 
NPCAnim.CitizenMaleAnim["rpgidle"] = 329
NPCAnim.CitizenMaleAnim["rpgwalk"] = 333
NPCAnim.CitizenMaleAnim["rpgrun"] = 338
NPCAnim.CitizenMaleAnim["rpgaimidle"] = 317
NPCAnim.CitizenMaleAnim["rpgaimwalk"] = 340
NPCAnim.CitizenMaleAnim["rpgaimrun"] = 319
NPCAnim.CitizenMaleAnim["rpgcrouchwalk"] = 8
NPCAnim.CitizenMaleAnim["rpgcrouch"] = 5
NPCAnim.CitizenMaleAnim["rpgaimcrouch"] = 328
NPCAnim.CitizenMaleAnim["rpgaimcrouchwalk"] = 342
NPCAnim.CitizenMaleAnim["rpgfire"] = 272
 
NPCAnim.CitizenMaleAnim["grenadeidle"] = 1
NPCAnim.CitizenMaleAnim["grenadewalk"] = 6
NPCAnim.CitizenMaleAnim["grenaderun"] = 10
NPCAnim.CitizenMaleAnim["grenadeaimidle"] = 1
NPCAnim.CitizenMaleAnim["grenadeaimcrouchwalk"] = 8
NPCAnim.CitizenMaleAnim["grenadeaimcrouch"] = 5
NPCAnim.CitizenMaleAnim["grenadecrouchwalk"] = 8
NPCAnim.CitizenMaleAnim["grenadecrouch"] = 5
NPCAnim.CitizenMaleAnim["grenadeaimwalk"] = 6
NPCAnim.CitizenMaleAnim["grenadeaimrun"] = 10
NPCAnim.CitizenMaleAnim["grenadefire"] = 273
 
NPCAnim.CitizenMaleAnim["slamidle"] = 1
NPCAnim.CitizenMaleAnim["slamwalk"] = 6
NPCAnim.CitizenMaleAnim["slamrun"] = 10
NPCAnim.CitizenMaleAnim["slamaimidle"] = 1
NPCAnim.CitizenMaleAnim["slamaimcrouchwalk"] = 8
NPCAnim.CitizenMaleAnim["slamaimcrouch"] = 5
NPCAnim.CitizenMaleAnim["slamcrouchwalk"] = 8
NPCAnim.CitizenMaleAnim["slamcrouch"] = 5
NPCAnim.CitizenMaleAnim["slamaimwalk"] = 6
NPCAnim.CitizenMaleAnim["slamaimrun"] = 10
NPCAnim.CitizenMaleAnim["slamfire"] = 273
 
NPCAnim.CitizenMaleAnim["physgunidle"] = 311
NPCAnim.CitizenMaleAnim["physgunwalk"] = 337
NPCAnim.CitizenMaleAnim["physgunrun"] = 338
NPCAnim.CitizenMaleAnim["physgunaimidle"] = 317
NPCAnim.CitizenMaleAnim["physgunaimwalk"] = 340
NPCAnim.CitizenMaleAnim["physgunaimrun"] = 340
NPCAnim.CitizenMaleAnim["physgunaimcrouchwalk"] = 5
NPCAnim.CitizenMaleAnim["physgunaimcrouch"] = 328-323

NPCAnim.CitizenMaleAnim["sitting"] = 374
NPCAnim.CitizenMaleAnim["chairsitting"] = 377

NPCAnim.CitizenFemaleAnim = { }
NPCAnim.CitizenFemaleModels = 
{
	
              "models/Humans/Group01/Female_01.mdl",
              "models/Humans/Group01/Female_02.mdl",
              "models/Humans/Group01/Female_03.mdl",
              "models/Humans/Group01/Female_04.mdl",
              "models/Humans/Group01/Female_06.mdl",
              "models/Humans/Group01/Female_07.mdl",
              "models/Humans/Group02/Female_01.mdl",
              "models/Humans/Group02/Female_02.mdl",
              "models/Humans/Group02/Female_03.mdl",
              "models/Humans/Group02/Female_04.mdl",
              "models/Humans/Group02/Female_06.mdl",
              "models/Humans/Group02/Female_07.mdl",
              "models/Humans/Group03/Female_01.mdl",
              "models/Humans/Group03/Female_02.mdl",
              "models/Humans/Group03/Female_03.mdl",
              "models/Humans/Group03/Female_04.mdl",
              "models/Humans/Group03/Female_06.mdl",
              "models/Humans/Group03/Female_07.mdl",
              "models/Humans/Group03m/Female_01.mdl",
              "models/Humans/Group03m/Female_02.mdl",
              "models/Humans/Group03m/Female_03.mdl",
              "models/Humans/Group03m/Female_04.mdl",
              "models/Humans/Group03m/Female_06.mdl",
              "models/Humans/Group03m/Female_07.mdl",	
              "models/barnes/citizen/female_01.mdl",
              "models/barnes/citizen/female_02.mdl",
              "models/barnes/citizen/female_03.mdl",
              "models/barnes/citizen/female_04.mdl",
              "models/barnes/citizen/female_06.mdl",
              "models/barnes/citizen/female_07.mdl",
              "models/barnes/refugee/female_01.mdl",
              "models/barnes/refugee/female_02.mdl",
              "models/barnes/refugee/female_03.mdl",
              "models/barnes/refugee/female_04.mdl",
              "models/barnes/refugee/female_06.mdl",
              "models/barnes/refugee/female_07.mdl",		  
}

for k, v in pairs( NPCAnim.CitizenFemaleModels ) do

	NPCAnim.CitizenFemaleModels[k] = string.lower( v );

end

NPCAnim.CitizenFemaleAnim["idle"] = 1
NPCAnim.CitizenFemaleAnim["walk"] = 6
NPCAnim.CitizenFemaleAnim["run"] = 10
NPCAnim.CitizenFemaleAnim["glide"] = 27
NPCAnim.CitizenFemaleAnim["sit"] = 0
NPCAnim.CitizenFemaleAnim["crouch"] = 5
NPCAnim.CitizenFemaleAnim["crouchwalk"] = 8

NPCAnim.CitizenFemaleAnim["pistolidle"] = 1
NPCAnim.CitizenFemaleAnim["pistolwalk"] = 6
NPCAnim.CitizenFemaleAnim["pistolrun"] = 10
NPCAnim.CitizenFemaleAnim["pistolcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["pistolcrouch"] = 60 + 272
NPCAnim.CitizenFemaleAnim["pistolaimidle"] = 304
NPCAnim.CitizenFemaleAnim["pistolaimwalk"] = 352
NPCAnim.CitizenFemaleAnim["pistolaimrun"] = 353
NPCAnim.CitizenFemaleAnim["pistolaimcrouch"] = 60 + 272
NPCAnim.CitizenFemaleAnim["pistolaimcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["pistolreload"] = 359
NPCAnim.CitizenFemaleAnim["pistolfire"] = 285

NPCAnim.CitizenFemaleAnim["smgidle"] = 311
NPCAnim.CitizenFemaleAnim["smgrun"] = 338
NPCAnim.CitizenFemaleAnim["smgwalk"] = 337
NPCAnim.CitizenFemaleAnim["smgaimidle"] = 317
NPCAnim.CitizenFemaleAnim["smgaimwalk"] = 340
NPCAnim.CitizenFemaleAnim["smgcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["smgcrouch"] = 5
NPCAnim.CitizenFemaleAnim["smgaimcrouch"] = 5
NPCAnim.CitizenFemaleAnim["smgaimcrouchwalk"] = 342
NPCAnim.CitizenFemaleAnim["smgaimrun"] = 334
NPCAnim.CitizenFemaleAnim["smgreload"] = 359
NPCAnim.CitizenFemaleAnim["smgfire"] = 289

NPCAnim.CitizenFemaleAnim["ar2idle"] = 311
NPCAnim.CitizenFemaleAnim["ar2walk"] = 337
NPCAnim.CitizenFemaleAnim["ar2run"] = 338
NPCAnim.CitizenFemaleAnim["ar2aimidle"] = 317
NPCAnim.CitizenFemaleAnim["ar2aimwalk"] = 340
NPCAnim.CitizenFemaleAnim["ar2aimrun"] = 319
NPCAnim.CitizenFemaleAnim["ar2crouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["ar2crouch"] = 5
NPCAnim.CitizenFemaleAnim["ar2aimcrouch"] = 5
NPCAnim.CitizenFemaleAnim["ar2aimcrouchwalk"] = 342
NPCAnim.CitizenFemaleAnim["ar2reload"] = 359
NPCAnim.CitizenFemaleAnim["ar2fire"] = 281

NPCAnim.CitizenFemaleAnim["shotgunidle"] = 311
NPCAnim.CitizenFemaleAnim["shotgunwalk"] = 337
NPCAnim.CitizenFemaleAnim["shotgunrun"] = 338
NPCAnim.CitizenFemaleAnim["shotgunaimidle"] = 317
NPCAnim.CitizenFemaleAnim["shotgunaimwalk"] = 340
NPCAnim.CitizenFemaleAnim["shotgunaimrun"] = 319
NPCAnim.CitizenFemaleAnim["shotguncrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["shotguncrouch"] = 5
NPCAnim.CitizenFemaleAnim["shotgunaimcrouch"] = 5
NPCAnim.CitizenFemaleAnim["shotgunaimcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["shotgunreload"] = 361
NPCAnim.CitizenFemaleAnim["shotgunfire"] = 288

NPCAnim.CitizenFemaleAnim["crossbowidle"] = 311
NPCAnim.CitizenFemaleAnim["crossbowwalk"] = 333
NPCAnim.CitizenFemaleAnim["crossbowrun"] = 343
NPCAnim.CitizenFemaleAnim["crossbowaimidle"] = 317
NPCAnim.CitizenFemaleAnim["crossbowaimwalk"] = 340
NPCAnim.CitizenFemaleAnim["crossbowaimrun"] = 319
NPCAnim.CitizenFemaleAnim["crossbowcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["crossbowcrouch"] = 5
NPCAnim.CitizenFemaleAnim["crossbowaimcrouch"] = 5
NPCAnim.CitizenFemaleAnim["crossbowaimcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["crossbowreload"] = 359
NPCAnim.CitizenFemaleAnim["crossbowfire"] = 288

NPCAnim.CitizenFemaleAnim["meleeidle"] = 1
NPCAnim.CitizenFemaleAnim["meleewalk"] = 6
NPCAnim.CitizenFemaleAnim["meleerun"] = 10
NPCAnim.CitizenFemaleAnim["meleeaimidle"] = 329 - 25
NPCAnim.CitizenFemaleAnim["meleeaimcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["meleeaimcrouch"] = 5
NPCAnim.CitizenFemaleAnim["meleecrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["meleecrouch"] = 5
NPCAnim.CitizenFemaleAnim["meleeaimwalk"] = 6
NPCAnim.CitizenFemaleAnim["meleeaimrun"] = 10
NPCAnim.CitizenFemaleAnim["meleefire"] = 277

NPCAnim.CitizenFemaleAnim["rpgidle"] = 311
NPCAnim.CitizenFemaleAnim["rpgwalk"] = 333
NPCAnim.CitizenFemaleAnim["rpgrun"] = 343
NPCAnim.CitizenFemaleAnim["rpgaimidle"] = 317
NPCAnim.CitizenFemaleAnim["rpgaimwalk"] = 340
NPCAnim.CitizenFemaleAnim["rpgaimrun"] = 319
NPCAnim.CitizenFemaleAnim["rpgcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["rpgcrouch"] = 5
NPCAnim.CitizenFemaleAnim["rpgaimcrouch"] = 5
NPCAnim.CitizenFemaleAnim["rpgaimcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["rpgfire"] = 272

NPCAnim.CitizenFemaleAnim["grenadeidle"] = 1
NPCAnim.CitizenFemaleAnim["grenadewalk"] = 6
NPCAnim.CitizenFemaleAnim["grenaderun"] = 10
NPCAnim.CitizenFemaleAnim["grenadeaimidle"] = 1
NPCAnim.CitizenFemaleAnim["grenadeaimcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["grenadeaimcrouch"] = 5
NPCAnim.CitizenFemaleAnim["grenadecrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["grenadecrouch"] = 5
NPCAnim.CitizenFemaleAnim["grenadeaimwalk"] = 6
NPCAnim.CitizenFemaleAnim["grenadeaimrun"] = 10
NPCAnim.CitizenFemaleAnim["grenadefire"] = 273

NPCAnim.CitizenFemaleAnim["slamidle"] = 1
NPCAnim.CitizenFemaleAnim["slamwalk"] = 6
NPCAnim.CitizenFemaleAnim["slamrun"] = 10
NPCAnim.CitizenFemaleAnim["slamaimidle"] = 1
NPCAnim.CitizenFemaleAnim["slamaimcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["slamaimcrouch"] = 5
NPCAnim.CitizenFemaleAnim["slamcrouchwalk"] = 8
NPCAnim.CitizenFemaleAnim["slamcrouch"] = 5
NPCAnim.CitizenFemaleAnim["slamaimwalk"] = 6
NPCAnim.CitizenFemaleAnim["slamaimrun"] = 10
NPCAnim.CitizenFemaleAnim["slamfire"] = 273

NPCAnim.CitizenFemaleAnim["physgunidle"] = 311
NPCAnim.CitizenFemaleAnim["physgunwalk"] = 333
NPCAnim.CitizenFemaleAnim["physgunrun"] = 343
NPCAnim.CitizenFemaleAnim["physgunaimidle"] = 317
NPCAnim.CitizenFemaleAnim["physgunaimwalk"] = 340
NPCAnim.CitizenFemaleAnim["physgunaimrun"] = 340
NPCAnim.CitizenFemaleAnim["physgunaimcrouchwalk"] = 5
NPCAnim.CitizenFemaleAnim["physgunaimcrouch"] = 5

NPCAnim.CombineMetroAnim = { }
NPCAnim.CombineMetroModels =
{
	 "models/police.mdl",
}

for k, v in pairs( NPCAnim.CombineMetroModels ) do

	NPCAnim.CombineMetroModels[k] = string.lower( v );

end


	NPCAnim.CombineMetroAnim["idle"] = 132
	NPCAnim.CombineMetroAnim["walk"] = 6
	NPCAnim.CombineMetroAnim["run"] = 10
	NPCAnim.CombineMetroAnim["glide"] = 27
	NPCAnim.CombineMetroAnim["sit"] = 60
	NPCAnim.CombineMetroAnim["crouch"] = 60
	NPCAnim.CombineMetroAnim["crouchwalk"] = 8

	NPCAnim.CombineMetroAnim["pistolidle"] = 1
	NPCAnim.CombineMetroAnim["pistolwalk"] = 6
	NPCAnim.CombineMetroAnim["pistolrun"] = 10
	NPCAnim.CombineMetroAnim["pistolcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["pistolcrouch"] = 358
	NPCAnim.CombineMetroAnim["pistolaimidle"] = 304
	NPCAnim.CombineMetroAnim["pistolaimwalk"] = 352
	NPCAnim.CombineMetroAnim["pistolaimrun"] = 353
	NPCAnim.CombineMetroAnim["pistolaimcrouch"] = 360
	NPCAnim.CombineMetroAnim["pistolaimcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["pistolreload"] = 359
	NPCAnim.CombineMetroAnim["pistolfire"] = 285

	NPCAnim.CombineMetroAnim["smgidle"] = 301
	NPCAnim.CombineMetroAnim["smgrun"] = 343
	NPCAnim.CombineMetroAnim["smgwalk"] = 339
	NPCAnim.CombineMetroAnim["smgaimidle"] = 302
	NPCAnim.CombineMetroAnim["smgaimwalk"] = 340
	NPCAnim.CombineMetroAnim["smgcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["smgcrouch"] = 358
	NPCAnim.CombineMetroAnim["smgaimcrouch"] = 360
	NPCAnim.CombineMetroAnim["smgaimcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["smgaimrun"] = 344
	NPCAnim.CombineMetroAnim["smgreload"] = 365
	NPCAnim.CombineMetroAnim["smgfire"] = 289

	NPCAnim.CombineMetroAnim["ar2idle"] = 301
	NPCAnim.CombineMetroAnim["ar2walk"] = 339
	NPCAnim.CombineMetroAnim["ar2run"] = 343
	NPCAnim.CombineMetroAnim["ar2aimidle"] = 302
	NPCAnim.CombineMetroAnim["ar2aimwalk"] = 340
	NPCAnim.CombineMetroAnim["ar2aimrun"] = 344
	NPCAnim.CombineMetroAnim["ar2crouchwalk"] = 8
	NPCAnim.CombineMetroAnim["ar2crouch"] = 358
	NPCAnim.CombineMetroAnim["ar2aimcrouch"] = 360
	NPCAnim.CombineMetroAnim["ar2aimcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["ar2reload"] = 359
	NPCAnim.CombineMetroAnim["ar2fire"] = 281

	NPCAnim.CombineMetroAnim["shotgunidle"] = 301
	NPCAnim.CombineMetroAnim["shotgunwalk"] = 6
	NPCAnim.CombineMetroAnim["shotgunrun"] = 10
	NPCAnim.CombineMetroAnim["shotgunaimidle"] = 302
	NPCAnim.CombineMetroAnim["shotgunaimwalk"] = 340
	NPCAnim.CombineMetroAnim["shotgunaimrun"] = 351
	NPCAnim.CombineMetroAnim["shotguncrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["shotguncrouch"] = 358
	NPCAnim.CombineMetroAnim["shotgunaimcrouch"] = 360
	NPCAnim.CombineMetroAnim["shotgunaimcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["shotgunreload"] = 359
	NPCAnim.CombineMetroAnim["shotgunfire"] = 281

	NPCAnim.CombineMetroAnim["crossbowidle"] = 301
	NPCAnim.CombineMetroAnim["crossbowwalk"] = 6
	NPCAnim.CombineMetroAnim["crossbowrun"] = 10
	NPCAnim.CombineMetroAnim["crossbowaimidle"] = 302
	NPCAnim.CombineMetroAnim["crossbowaimwalk"] = 340
	NPCAnim.CombineMetroAnim["crossbowaimrun"] = 351
	NPCAnim.CombineMetroAnim["crossbowcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["crossbowcrouch"] = 358
	NPCAnim.CombineMetroAnim["crossbowaimcrouch"] = 360
	NPCAnim.CombineMetroAnim["crossbowaimcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["crossbowreload"] = 359
	NPCAnim.CombineMetroAnim["crossbowfire"] = 288

	NPCAnim.CombineMetroAnim["meleeidle"] = 1
	NPCAnim.CombineMetroAnim["meleewalk"] = 6
	NPCAnim.CombineMetroAnim["meleerun"] = 10
	NPCAnim.CombineMetroAnim["meleeaimidle"] = 328
	NPCAnim.CombineMetroAnim["meleeaimcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["meleeaimcrouch"] = 360
	NPCAnim.CombineMetroAnim["meleecrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["meleecrouch"] = 358
	NPCAnim.CombineMetroAnim["meleeaimwalk"] = 323
	NPCAnim.CombineMetroAnim["meleeaimrun"] = 10
	NPCAnim.CombineMetroAnim["meleefire"] = 277

	NPCAnim.CombineMetroAnim["rpgidle"] = 301
	NPCAnim.CombineMetroAnim["rpgwalk"] = 6
	NPCAnim.CombineMetroAnim["rpgrun"] = 10
	NPCAnim.CombineMetroAnim["rpgaimidle"] = 302
	NPCAnim.CombineMetroAnim["rpgaimwalk"] = 340
	NPCAnim.CombineMetroAnim["rpgaimrun"] = 351
	NPCAnim.CombineMetroAnim["rpgcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["rpgcrouch"] = 60
	NPCAnim.CombineMetroAnim["rpgaimcrouch"] = 60
	NPCAnim.CombineMetroAnim["rpgaimcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["rpgreload"] = 359
	NPCAnim.CombineMetroAnim["rpgfire"] = 281

	NPCAnim.CombineMetroAnim["grenadeidle"] = 1
	NPCAnim.CombineMetroAnim["grenadewalk"] = 6
	NPCAnim.CombineMetroAnim["grenaderun"] = 10
	NPCAnim.CombineMetroAnim["grenadeaimidle"] = 1
	NPCAnim.CombineMetroAnim["grenadeaimcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["grenadeaimcrouch"] = 60
	NPCAnim.CombineMetroAnim["grenadecrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["grenadecrouch"] = 60
	NPCAnim.CombineMetroAnim["grenadeaimwalk"] = 6
	NPCAnim.CombineMetroAnim["grenadeaimrun"] = 10
	NPCAnim.CombineMetroAnim["grenadefire"] = 277

	NPCAnim.CombineMetroAnim["slamidle"] = 1
	NPCAnim.CombineMetroAnim["slamwalk"] = 6
	NPCAnim.CombineMetroAnim["slamrun"] = 10
	NPCAnim.CombineMetroAnim["slamaimidle"] = 1
	NPCAnim.CombineMetroAnim["slamaimcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["slamaimcrouch"] = 278
	NPCAnim.CombineMetroAnim["slamcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["slamcrouch"] = 278
	NPCAnim.CombineMetroAnim["slamaimwalk"] = 6
	NPCAnim.CombineMetroAnim["slamaimrun"] = 10
	NPCAnim.CombineMetroAnim["slamfire"] = 273

	NPCAnim.CombineMetroAnim["physgunidle"] = 301
	NPCAnim.CombineMetroAnim["physgunwalk"] = 6
	NPCAnim.CombineMetroAnim["physgunrun"] = 10
	NPCAnim.CombineMetroAnim["physgunaimidle"] = 302
	NPCAnim.CombineMetroAnim["physgunaimwalk"] = 340
	NPCAnim.CombineMetroAnim["physgunaimrun"] = 351
	NPCAnim.CombineMetroAnim["physgunaimcrouchwalk"] = 8
	NPCAnim.CombineMetroAnim["physgunaimcrouch"] = 60

NPCAnim.CombineOWAnim = { }

NPCAnim.CombineOWModels =
{
	
	"models/combine_super_soldier.mdl",
	"models/Combine_Soldier.mdl",
	"models/Combine_Soldier_PrisonGuard.mdl",
	"models/soldier_stripped.mdl",
	"models/urbantrenchcoat.mdl",
	"models/mobinfi_super_soldier.mdl",
	"models/mobinfi_soldier.mdl",
	"models/mobinfi_soldier_prisonguard.mdl",
	"models/thespectator/od.mdl",
}

for k, v in pairs( NPCAnim.CombineOWModels ) do

	NPCAnim.CombineOWModels[k] = string.lower( v );

end


NPCAnim.CombineOWAnim["idle"] = 134
NPCAnim.CombineOWAnim["walk"] = 136
NPCAnim.CombineOWAnim["run"] = 343
NPCAnim.CombineOWAnim["glide"] = 27
NPCAnim.CombineOWAnim["sit"] = 0
NPCAnim.CombineOWAnim["crouch"] = 5
NPCAnim.CombineOWAnim["crouchwalk"] = 341

NPCAnim.CombineOWAnim["pistolidle"] = 134
NPCAnim.CombineOWAnim["pistolwalk"] = 136
NPCAnim.CombineOWAnim["pistolrun"] = 343
NPCAnim.CombineOWAnim["pistolcrouchwalk"] = 341
NPCAnim.CombineOWAnim["pistolcrouch"] = 5
NPCAnim.CombineOWAnim["pistolaimidle"] = 302
NPCAnim.CombineOWAnim["pistolaimwalk"] = 340
NPCAnim.CombineOWAnim["pistolaimrun"] = 344
NPCAnim.CombineOWAnim["pistolaimcrouch"] = 5
NPCAnim.CombineOWAnim["pistolaimcrouchwalk"] = 341
NPCAnim.CombineOWAnim["pistolreload"] = 359
NPCAnim.CombineOWAnim["pistolfire"] = 289

NPCAnim.CombineOWAnim["smgidle"] = 1
NPCAnim.CombineOWAnim["smgrun"] = 343
NPCAnim.CombineOWAnim["smgwalk"] = 339
NPCAnim.CombineOWAnim["smgaimidle"] = 302
NPCAnim.CombineOWAnim["smgaimwalk"] = 340
NPCAnim.CombineOWAnim["smgcrouchwalk"] = 341
NPCAnim.CombineOWAnim["smgcrouch"] = 5
NPCAnim.CombineOWAnim["smgaimcrouch"] = 5
NPCAnim.CombineOWAnim["smgaimcrouchwalk"] = 341
NPCAnim.CombineOWAnim["smgaimrun"] = 344
NPCAnim.CombineOWAnim["smgreload"] = 359
NPCAnim.CombineOWAnim["smgfire"] = 289

NPCAnim.CombineOWAnim["ar2idle"] = 1
NPCAnim.CombineOWAnim["ar2walk"] = 339
NPCAnim.CombineOWAnim["ar2run"] = 343
NPCAnim.CombineOWAnim["ar2aimidle"] = 302
NPCAnim.CombineOWAnim["ar2aimwalk"] = 340
NPCAnim.CombineOWAnim["ar2aimrun"] = 344
NPCAnim.CombineOWAnim["ar2crouchwalk"] = 341
NPCAnim.CombineOWAnim["ar2crouch"] = 5
NPCAnim.CombineOWAnim["ar2aimcrouch"] = 5
NPCAnim.CombineOWAnim["ar2aimcrouchwalk"] = 341
NPCAnim.CombineOWAnim["ar2reload"] = 66
NPCAnim.CombineOWAnim["ar2fire"] = 416

NPCAnim.CombineOWAnim["shotgunidle"] = 1
NPCAnim.CombineOWAnim["shotgunwalk"] = 339
NPCAnim.CombineOWAnim["shotgunrun"] = 343
NPCAnim.CombineOWAnim["shotgunaimidle"] = 305
NPCAnim.CombineOWAnim["shotgunaimwalk"] = 348
NPCAnim.CombineOWAnim["shotgunaimrun"] = 349
NPCAnim.CombineOWAnim["shotguncrouchwalk"] = 341
NPCAnim.CombineOWAnim["shotguncrouch"] = 5
NPCAnim.CombineOWAnim["shotgunaimcrouch"] = 5
NPCAnim.CombineOWAnim["shotgunaimcrouchwalk"] = 341
NPCAnim.CombineOWAnim["shotgunreload"] = 359
NPCAnim.CombineOWAnim["shotgunfire"] = 281

NPCAnim.CombineOWAnim["crossbowidle"] = 1
NPCAnim.CombineOWAnim["crossbowwalk"] = 339
NPCAnim.CombineOWAnim["crossbowrun"] = 343
NPCAnim.CombineOWAnim["crossbowaimidle"] = 302
NPCAnim.CombineOWAnim["crossbowaimwalk"] = 340
NPCAnim.CombineOWAnim["crossbowaimrun"] = 344
NPCAnim.CombineOWAnim["crossbowcrouchwalk"] = 341
NPCAnim.CombineOWAnim["crossbowcrouch"] = 5
NPCAnim.CombineOWAnim["crossbowaimcrouch"] = 5
NPCAnim.CombineOWAnim["crossbowaimcrouchwalk"] = 341
NPCAnim.CombineOWAnim["crossbowreload"] = 359
NPCAnim.CombineOWAnim["crossbowfire"] = 281

NPCAnim.CombineOWAnim["meleeidle"] = 1
NPCAnim.CombineOWAnim["meleewalk"] = 339
NPCAnim.CombineOWAnim["meleerun"] = 343
NPCAnim.CombineOWAnim["meleeaimidle"] = 302
NPCAnim.CombineOWAnim["meleeaimcrouchwalk"] = 341
NPCAnim.CombineOWAnim["meleeaimcrouch"] = 5
NPCAnim.CombineOWAnim["meleecrouchwalk"] = 341
NPCAnim.CombineOWAnim["meleecrouch"] = 5
NPCAnim.CombineOWAnim["meleeaimwalk"] = 340
NPCAnim.CombineOWAnim["meleeaimrun"] = 344
NPCAnim.CombineOWAnim["meleefire"] = 281

NPCAnim.CombineOWAnim["rpgidle"] = 1
NPCAnim.CombineOWAnim["rpgwalk"] = 339
NPCAnim.CombineOWAnim["rpgrun"] = 343
NPCAnim.CombineOWAnim["rpgaimidle"] = 302
NPCAnim.CombineOWAnim["rpgaimwalk"] = 340
NPCAnim.CombineOWAnim["rpgaimrun"] = 344
NPCAnim.CombineOWAnim["rpgcrouchwalk"] = 341
NPCAnim.CombineOWAnim["rpgcrouch"] = 5
NPCAnim.CombineOWAnim["rpgaimcrouch"] = 5
NPCAnim.CombineOWAnim["rpgaimcrouchwalk"] = 341
NPCAnim.CombineOWAnim["rpgreload"] = 359
NPCAnim.CombineOWAnim["rpgfire"] = 281

NPCAnim.CombineOWAnim["grenadeidle"] = 1
NPCAnim.CombineOWAnim["grenadewalk"] = 335
NPCAnim.CombineOWAnim["grenaderun"] = 339
NPCAnim.CombineOWAnim["grenadeaimidle"] = 1
NPCAnim.CombineOWAnim["grenadeaimcrouchwalk"] = 337
NPCAnim.CombineOWAnim["grenadeaimcrouch"] = 5
NPCAnim.CombineOWAnim["grenadecrouchwalk"] = 337
NPCAnim.CombineOWAnim["grenadecrouch"] = 5
NPCAnim.CombineOWAnim["grenadeaimwalk"] = 336
NPCAnim.CombineOWAnim["grenadeaimrun"] = 340
NPCAnim.CombineOWAnim["grenadefire"] = 355

NPCAnim.CombineOWAnim["slamidle"] = 1
NPCAnim.CombineOWAnim["slamwalk"] = 335
NPCAnim.CombineOWAnim["slamrun"] = 339
NPCAnim.CombineOWAnim["slamaimidle"] = 1
NPCAnim.CombineOWAnim["slamaimcrouchwalk"] = 337
NPCAnim.CombineOWAnim["slamaimcrouch"] = 5
NPCAnim.CombineOWAnim["slamcrouchwalk"] = 337
NPCAnim.CombineOWAnim["slamcrouch"] = 5
NPCAnim.CombineOWAnim["slamaimwalk"] = 336
NPCAnim.CombineOWAnim["slamaimrun"] = 339
NPCAnim.CombineOWAnim["slamfire"] = 281

NPCAnim.CombineOWAnim["physgunidle"] = 1
NPCAnim.CombineOWAnim["physgunwalk"] = 339
NPCAnim.CombineOWAnim["physgunrun"] = 343
NPCAnim.CombineOWAnim["physgunaimidle"] = 302
NPCAnim.CombineOWAnim["physgunaimwalk"] = 340
NPCAnim.CombineOWAnim["physgunaimrun"] = 344
NPCAnim.CombineOWAnim["physgunaimcrouchwalk"] = 341
NPCAnim.CombineOWAnim["physgunaimcrouch"] = 5

WeapActivityTranslate = { }

WeapActivityTranslate[ACT_HL2MP_IDLE_PISTOL] = "pistol";
WeapActivityTranslate[ACT_HL2MP_IDLE_SMG1] = "smg";
WeapActivityTranslate[ACT_HL2MP_IDLE_AR2] = "ar2";
WeapActivityTranslate[ACT_HL2MP_IDLE_RPG] = "rpg";
WeapActivityTranslate[ACT_HL2MP_IDLE_GRENADE] = "grenade";
WeapActivityTranslate[ACT_HL2MP_IDLE_SHOTGUN] = "shotgun";
WeapActivityTranslate[ACT_HL2MP_IDLE_PHYSGUN] = "physgun";
WeapActivityTranslate[ACT_HL2MP_IDLE_CROSSBOW] = "crossbow";
WeapActivityTranslate[ACT_HL2MP_IDLE_SLAM] = "slam";
WeapActivityTranslate[ACT_HL2MP_IDLE_MELEE] = "melee";
WeapActivityTranslate[ACT_HL2MP_IDLE] = "";
WeapActivityTranslate["weapon_pistol"] = "pistol";
WeapActivityTranslate["weapon_357"] = "pistol";
WeapActivityTranslate["gmod_tool"] = "pistol";
WeapActivityTranslate["weapon_smg1"] = "smg";
WeapActivityTranslate["weapon_ar2"] = "ar2";
WeapActivityTranslate["weapon_rpg"] = "rpg";
WeapActivityTranslate["weapon_frag"] = "grenade";
WeapActivityTranslate["weapon_slam"] = "slam";
WeapActivityTranslate["weapon_physgun"] = "physgun";
WeapActivityTranslate["weapon_physcannon"] = "physgun";
WeapActivityTranslate["weapon_crossbow"] = "crossbow";
WeapActivityTranslate["weapon_shotgun"] = "shotgun";
WeapActivityTranslate["weapon_crowbar"] = "melee";
WeapActivityTranslate["weapon_stunstick"] = "melee";

function GetWeaponAct( ply, act )

	local weap = ply:GetActiveWeapon();
	
	if( weap == NULL or not weap:IsValid() ) then
		return "";
	end

	local class = weap:GetClass();
	
	local trans = "";
	local posttrans = "";
	
	if( weap:GetNWBool( "NPCAimed" ) ) then
		posttrans = "aim";	
	else
		
		if( weap:GetTable().NotHolsterAnim ) then
		
			act = weap:GetTable().NotHolsterAnim;
		
		end
	
	end

	if( act ~= -1 ) then
		trans = WeapActivityTranslate[act];
	else
		trans = WeapActivityTranslate[class];
	end
	
	return trans .. posttrans or "";

end



local function GetAnimTable( ply )

	local model = string.lower( ply:GetModel() );

	if( table.HasValue( NPCAnim.CitizenMaleModels, model ) ) then return NPCAnim.CitizenMaleAnim; end
	if( table.HasValue( NPCAnim.CitizenFemaleModels, model ) ) then return NPCAnim.CitizenFemaleAnim; end
	if( table.HasValue( NPCAnim.CombineMetroModels, model ) ) then return NPCAnim.CombineMetroAnim; end
	if( table.HasValue( NPCAnim.CombineOWModels, model ) ) then return NPCAnim.CombineOWAnim; end
	
	return NPCAnim.CitizenMaleAnim;

end

function NPCAnim.SetPlayerAnimation( ply, weapanim )

	if( not NPC_ANIMS_ENABLED ) then return; end
	
	local weap = ply:GetActiveWeapon();
	local animname = "";
	
	if( weap:IsValid() ) then
		animname = GetWeaponAct( ply, ply:Weapon_TranslateActivity( ACT_HL2MP_IDLE ) or -1 );
	end
	local seqname = animname;
	local crouch = "";

	if( ply:OnGround() and ply:KeyDown( IN_DUCK ) ) then
		crouch = "crouch";
	end
	
	if( ply:GetVelocity():Length() >= 120 and ply:KeyDown( IN_SPEED )) then

		seqname = seqname .. crouch .. "run";
	
	elseif( ply:GetVelocity():Length() >= 1 ) then
	
		seqname = seqname .. crouch .. "walk";
	
	else
		
		if( crouch == "crouch" ) then
			seqname = seqname .. crouch;
		else
			seqname = seqname .. crouch .. "idle";
		end
		
	end

	local AnimTable = GetAnimTable( ply );
	
	if( ( weapanim == PLAYER_ATTACK1 or weapanim == PLAYER_RELOAD ) and weap:IsValid() ) then

		local act = nil;
	
		if( weapanim == PLAYER_RELOAD ) then

			local actname = string.gsub( seqname, "aim", "" ) .. "reload";
			actname = string.gsub( actname, "idle", "" );
		
			local act = tonumber( AnimTable[actname] );
			
			if( act == nil ) then
				return;
			end

			ply:RestartGesture( act );
		
			return true;
			
		else
		
			if( string.find( seqname, "melee" ) or string.find( seqname, "grenade" ) or string.find( seqname, "slam" ) ) then
			
				local actname = string.gsub( seqname, "aim", "" ) .. "fire";
				actname = string.gsub( actname, "idle", "" );
			
				local act = tonumber( AnimTable[actname] );
				
				if( act == nil ) then
					return;
				end

				ply:RestartGesture( act );
				ply:Weapon_SetActivity( act, 0 );
				
				return true;
				
			end
		
			return;
			
		end
	
	end

	if ( ( not ply:OnGround() or ply:WaterLevel() > 4 ) and 
		   not ply:InVehicle() ) then
		seqname = "glide";
	end
 

	local actid = AnimTable[seqname];
	

/* ANIMATION HAND FIXING CODE
	-- HERE is where I'll tweak animations woot
	if( actid != nil ) then
		AnimationSequence = actid;
		actid = actid + AnimationsAdjustment;
	end
*/
	
	local seq = nil;

	if( actid == nil or actid == -1 ) then
		seq = ply:GetSequence();
	else
		seq = ply:SelectWeightedSequence( actid );
	end
	if( actid == 134 ) then
		seq = 134
	end
	if( actid == 136 ) then
		seq = 136
	end	

	if ( ply:GetSequence() == seq ) then return true; end

	
	
	ply:SetPlaybackRate( 1 );
	ply:ResetSequence( seq );
	ply:SetCycle( 1 );
	
	return true;

end
hook.Add( "SetPlayerAnimation", "NPCAnim.SetPlayerAnimation", NPCAnim.SetPlayerAnimation );