// --------------------------------------------------------------------------
//
// AK47 (Demo weapon "Appears on weapons training")
//
// --------------------------------------------------------------------------

ACTOR "AK47" : CSDMOWeapon //5010
{

	Weapon.SisterWeapon ak47_rat

+AMMO_OPTIONAL

	Weapon.SelectionOrder 200
  weapon.ammotype "AK47Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "762mmAmmo"//*762mmAmmo
  weapon.ammouse2 0
  weapon.ammogive2 0 //30
	obituary "%k killed %o with AK-47."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Picked up an AK-47."
	Tag "AK-47"
	Weapon.UpSound "AK47/Ready"
	//AttackSound "AK47/Fire"
	Scale 0.18
	
	States
	{
	Ready:
		W01D Z 1 A_WeaponReady
		Loop





	Deselect:
	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 2, 0, 0)
    TNT1 A 1 
	Goto DeselectLoop

	Select:
	TNT1 A 1 A_Raise
	TNT1 AA 0 A_Raise
	TNT1 A 0 ACS_ExecuteAlways(798, 0, 215, 0, 0)//Weapon Weight
    TNT1 A 1 A_TakeInventory("CrosshairType",2)

	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 1, 0, 0)
    TNT1 A 0 A_JumpIfInventory("RAT_Trigger",1,"RAT_TriggerSelect")
//	TNT1 A 0 A_TakeInventory("If_melee_RAT",1)
	
		W01A BCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W01B ABCDEFGHIJK 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready
		
	RAT_TriggerSelect:
    TNT1 A 0 A_TakeInventory("Rat_Trigger",1)
		W01A BCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W01B ABCDEFGHIJK 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready		
		
		
	Fire:
	
		W01D Z 0 A_JumpIfNoAmmo("AltFire")

		W01D A 1 A_GunFlash //1
		W01D B 1 A_WEAPONREADY(WRF_NOFIRE)//1
		W01D C 1 A_WEAPONREADY(WRF_NOFIRE) //1 *D
W01D A 1 A_WEAPONREADY(WRF_NOFIRE) //D
		TNT1 A 0 A_Refire//0
		W01D EFGHIJKLMNOP 1 A_WeaponReady //1 *QRSTUVWXYZ
		Goto Ready


  Altfire:
    TNT1 A 0 A_JumpIfInventory("AK47Clip",30,"Ready")
    TNT1 A 0 A_JumpIfInventory("762mmAmmo",1,"ReloadStart")
    goto Ready

	ReloadStart:
		W01E ABCDEFGHIJKLM 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("AK47/Reload", 6)
		W01E NOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE) //1
		W01F ABCDEFGHIJKLMNOPQ 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto ReloadAmmo
		
		
  ReloadAmmo:
    TNT1 A 0 A_GiveInventory("AK47Clip",1)
    TNT1 A 0 A_TakeInventory("762mmAmmo",1)
    TNT1 A 0 A_JumpIfInventory("AK47Clip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("762mmAmmo",1,"ReloadAmmo")
    goto ReloadEnd


	ReloadEnd:	
		W01F RSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE) //1
		W01G ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE) //1
		W01H ABCDEFGHI 1 A_WEAPONREADY(WRF_NOFIRE) //1
		Goto Ready




	Flash:
	TNT1 A 0 ACS_ExecuteAlways(799, 0, 0, 0, 0)
	TNT1 A 0 A_GiveInventory("CrosshairGrow", 7)
TNT1 A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,12,1)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound ("AK47/FIRE")
		TNT1 A 0 A_PlaySound("AK47/Distant", 7)

		TNT1 A 0 A_FireCustomMissile("RifleCaseSpawn",5,0,12,-6)
        TNT1 A 0 BRIGHT A_FireCustomMissile("Tracer", frandom(-2.15,2.15), 0, 11, 0, 0, frandom(-2.15,2.15))
		TNT1 A 2 A_FireBullets(0.6, 0.6, 1, 100.0, "ak47Bullet")//8.85
TNT1 A 0 A_SetPitch(pitch-1.0)
TNT1 A 0 A_SetANgle(angle-0.4)
TNT1 A 0 A_SetANgle(angle+0.3)
		Goto LightDone
 	Spawn:
		W01Z A -1
		Stop
	}
}