// I have no clue where these sprites came from.
// Code and sounds by Aenima.

ACTOR AR-10 : DoomWeapon 22396
{
 //$Category Weapons
	//+WEAPON.NOAUTOSWITCHTO
	+WEAPON.WIMPY_WEAPON
	+CHEATNOTWEAPON
	//+AXEBLOOD
	Decal CBulletScorch
	//Inventory.PickupSound "weapons/getgun3"
	Inventory.PickupMessage "You found an Armalite AR-10!"
	Obituary "%o was penetrated by %k's Armalite."
	Weapon.AmmoType		"AR10Bullet"
	Weapon.AmmoGive		21
	Weapon.AmmoUse		1
	Weapon.AmmoType2	"Clip"
	Weapon.AmmoGive2	60
	Weapon.AmmoUse2		0
	Weapon.Kickback 200//40
	Radius				12
	Height				12
	YScale				.11
	XScale				.09
	+AMMO_OPTIONAL
	+NOALERT
	+NOAUTOFIRE
	Weapon.SelectionOrder 706
	States
	{
	Spawn:
		AR1O A 35
		Loop
	Click:
		PSIG A 0 A_PlaySound("DryFire")
		Goto Reload
	Ready:
		AR10 A 1 A_WeaponReady(WRF_ALLOWRELOAD)
    	//AR10 A 0 A_JumpIfNoAmmo("reload")
		TNT1 A 0 A_JumpIfInventory("IsReloading",1,"Reload")
		LOOP
	Reload:
		TNT1 A 0 A_Takeinventory("IsReloading",1)
		NULL A 0 A_JumpIfInventory("AR10bullet",21,2)
		NULL A 0 A_JumpIfInventory("Clip",1,2)
		fams A 0
		Goto Ready
		
		AR1R AABBCCDDEE 1
		fams A 0 A_PlaySoundex("AR10r1", Voice)
		AR1R E 10
		NULL A 0 A_FireCustomMissile(SpentClip2,0,0,3,-5)
		AR1R E 15
		fams A 0 A_PlaySoundEx("AR10r2", Item)
		AR1R FFFEE 1
		AR1R DDDDCCCBBA 1
		
        Load:
		NULL A 0
		MP5G A 0 A_TakeInventory("Clip", 1)
		MP5G A 0 A_GiveInventory("AR10bullet", 1)
		MP5G A 0 A_JumpIfInventory("AR10bullet",21,2)
		MP5G A 0 A_JumpIfInventory("Clip",1,2)
		MP5G A 0
		Goto Ready
		MP5G A 0
		Goto Load
	Deselect:
		TNT1 A 0 A_Takeinventory("IsReloading",1)
    		BERT D 0 ACS_ExecuteAlways(779,0, 4,0,0)
	Deselect1:
		AR10 A 0 A_Lower
		AR10 A 1 A_Lower
		Loop
	Select:
                //NULL AAAAAAAAAAAAAAA 0 A_Raise
    TNT1 A 0 A_JumpIfInventory("InstantSwitch",1, "Ready")
    BERT K 0 ACS_ExecuteAlways(779,0, 4,0,0)
		AR1R D 0 A_Raise
		AR1R DDDCCCBB 1 A_Raise
		AR1R B 0 A_Raise
		AR1R B 1 A_Raise
	Select2:
		AR1R A 0 A_Raise
		AR1R A 1 A_Raise
		Loop
     AltFire:
        SAWD A 0 
		Goto Reload
	Burst:
		NULL A 0 A_JumpIfNoAmmo("click")
		NULL A 0 A_PlayWeaponSound("AR10Fire")
		NULL A 0 A_FireBullets(0.3,0,1,random(5,6),"SSTBulletPuff1",0)
		NULL A 0 A_FireBullets(0,0.3,1,random(5,6),"SSTBulletPuff1",1)//5
		NULL A 0 A_SpawnItemEx ("ChaingunEcho", 0,0,0, 0,0,0, 0, 160)
		G36F A 0 A_FireCustomMissile ("TracerRound", 0, 0, random(8,10), random(-3,-1))
		BERT B 0 A_FireCustomMissile("BulletCasingSpawner",0,0,10,-6)
		NULL A 0 A_AlertMonsters
		AR10 B 1 Bright A_Light2
		TNT1 A 0 ACS_ExecuteAlways(925,0, random(170,210),0,0)
		AR10 C 1 Bright A_Light1
		AR10 D 1 A_Light0
		AR10 E 1
				
		NULL A 0 A_JumpIfNoAmmo("click")
		NULL A 0 A_PlayWeaponSound("AR10Fire")
		NULL A 0 A_FireBullets(0.6,0,1,random(5,6),"SSTBulletPuff1",0)
		NULL A 0 A_FireBullets(0,0.6,1,random(5,6),"SSTBulletPuff1",1)//5
		NULL A 0 A_SpawnItemEx ("ChaingunEcho", 0,0,0, 0,0,0, 0, 160)
		G36F A 0 A_FireCustomMissile ("TracerRound", 0, 0, random(8,10), random(-3,-1))
		BERT B 0 A_FireCustomMissile("BulletCasingSpawner",0,0,10,-6)
		NULL A 0 A_AlertMonsters
		AR10 B 1 Bright A_Light2
		TNT1 A 0 ACS_ExecuteAlways(925,0, random(210,230),0,0)
		AR10 C 1 Bright A_Light1
		AR10 D 1 A_Light0
		AR10 E 1
		Goto Single
				
	Fire:
		TNT1 A 0 A_JumpIfInventory("IsReloading",1,"Reload")
        SAWD J 0 A_JumpIfInventory("AR10fullauto",1,"Auto")
        SAWD J 0 A_JumpIfInventory("AR10burst",1,"Burst")
	Single:
		NULL A 0 A_JumpIfNoAmmo("click")
		NULL A 0 A_PlayWeaponSound("AR10Fire")
		NULL A 0 A_FireBullets(0.9,0,1,random(5,6),"SSTBulletPuff1",0)
		NULL A 0 A_FireBullets(0,0.9,1,random(5,6),"SSTBulletPuff1",1)//5
		NULL A 0 A_SpawnItemEx ("ChaingunEcho", 0,0,0, 0,0,0, 0, 160)
		G36F A 0 A_FireCustomMissile ("TracerRound", 0, 0, random(8,10), random(-3,-1))
		BERT B 0 A_FireCustomMissile("BulletCasingSpawner",0,0,10,-6)
		NULL A 0 A_AlertMonsters
		AR10 B 1 Bright A_Light2
		TNT1 A 0 ACS_ExecuteAlways(925,0, random(280,290),0,0)
		AR10 C 1 Bright A_Light1
		AR10 D 1 A_Light0
		AR10 E 1//2
		AR10 AA 1 A_WeaponReady
		NULL A 0 A_JumpIfNoAmmo("click")
		//AR10 A 1
		Goto Ready
	Auto:
		NULL A 0 A_JumpIfNoAmmo("click")
		
		TNT1 A 0 A_SetAngle(angle+random(-1,1))
		
		NULL A 0 A_PlayWeaponSound("AR10Fire")
		NULL A 0 A_FireBullets(1,0,1,random(5,6),"SSTBulletPuff1",0)
		NULL A 0 A_FireBullets(0,1,1,random(5,6),"SSTBulletPuff1",1)//5
		NULL A 0 A_SpawnItemEx ("ChaingunEcho", 0,0,0, 0,0,0, 0, 160)
		G36F A 0 A_FireCustomMissile ("TracerRound", 0, 0, random(8,10), random(-3,-1))
		BERT B 0 A_FireCustomMissile("BulletCasingSpawner",0,0,10,-6)
		NULL A 0 A_AlertMonsters
		TNT1 A 0 A_SetPitch(pitch-1)
		AR10 B 1 Bright A_Light2
		TNT1 A 0 ACS_ExecuteAlways(925,0, random(80,160),0,0)
		AR10 C 1 Bright A_Light1
		AR10 D 1 A_Light0
		AR10 E 1//2
		NULL A 0 A_JumpIfNoAmmo("click")
		AR10 A 1 A_ReFire
		Goto Ready
	}
}

ACTOR AR10Bullet : Ammo
{
      +IgnoreSkill
    Inventory.MaxAmount 21
}

ACTOR AR10burst : Inventory
{
Inventory.Amount 1
Inventory.MaxAmount 1
}
ACTOR AR10fullauto : Inventory
{
Inventory.Amount 1
Inventory.MaxAmount 1
}

ACTOR IsReloading : Inventory
{
   Inventory.Amount 1
   Inventory.MaxAmount 1
   -INVBAR
}

ACTOR SpentClip2
{
   Height 10
   Radius 8
   Speed 5
   Scale 0.95
   PROJECTILE
   +DOOMBOUNCE
   - NOGRAVITY
   -NOLIFTDROP 
   SeeSound "clipbounce"
   BounceFactor 0.3
   States
   {
   Spawn:
      CLP3 A 0 A_PlaySound("NULL")
      CLP3 ABCDEFGA 2
	  CLP3 A 0 A_JumpIf(waterlevel == 3, "Death")
      CLP3 A 0 A_JumpIf(waterlevel == 2, "Death")
      CLP3 A 0 A_JumpIf(waterlevel == 1, "Death")
      Goto Spawn+1
   Death:
      CLP3 A 0 A_Jump(32,6)
      CLP3 A 0 A_Jump(37,6)
      CLP3 A 0 A_Jump(43,6)
      CLP3 A 0 A_Jump(51,6)
      CLP3 A 0 A_Jump(85,6)
      CLP3 A 0 A_Jump(128,6)
      CLP3 A 350
      Stop
      CLP3 B 350
      Stop
      CLP3 C 350
      Stop
      CLP3 D 350
      Stop
      CLP3 E 350
      Stop
      CLP3 F 350
      Stop
   }
}