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

ACTOR "BIZON" : CSDMOWeapon //5010
{
	Weapon.SisterWeapon Bizon_rat

+AMMO_OPTIONAL

	Weapon.SelectionOrder 300
  weapon.ammotype "BIZONClip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "9mmAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0 //64
	obituary "%k killed %o with PP-Bizon."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Pickep up a PP-Bizon"
	Tag "PP-Bizon"
	Weapon.UpSound "BIZON/Ready"
	//AttackSound "BIZON/Fire"
	Scale 0.16

	States
	{
	Ready:
		W04E D 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, 240, 0, 0)//Weapon Weight
    TNT1 A 1 A_TakeInventory("CrosshairType",2)

//    TNT1 A 0 A_JumpIfInventory("If_melee_RAT",1,"Select_Rat")

	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 1, 0, 0)
//	TNT1 A 0 A_TakeInventory("If_melee_RAT",1)
	    TNT1 A 0 A_JumpIfInventory("RAT_Trigger",1,"RAT_TriggerSelect")

		TNT1 A 1 A_WEAPONREADY(WRF_NOFIRE)
		W04A DEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W04B ABCDEFGHIJKLMN 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

	Rat_TriggerSelect:
    TNT1 A 0 A_TakeInventory("Rat_Trigger",1)

		TNT1 A 1 A_WEAPONREADY(WRF_NOFIRE)
		W04A DEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W04B ABCDEFGHIJKLMN 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready

	Fire:

	W04E D 0 A_JumpIfNoAmmo("AltFire")
	
	
		W04D A 1 A_GunFlash
		W04D B 1 A_WEAPONREADY(WRF_NOFIRE)
		W04D C 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_Refire
		W04D DEFGHIJKLMNOPQRSTUVWXYZ 1 A_WeaponReady
		W04E ABCD 1 A_WeaponReady
		Goto Ready



  Altfire:
    TNT1 A 0 A_JumpIfInventory("BIZONClip",64,"Ready")
    TNT1 A 0 A_JumpIfInventory("9mmAmmo",1,"ReloadStart")
    goto Ready


	ReloadStart:
		W04F ABCDEFGHIJKLM 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("BIZON/Reload", 6)
		W04F NOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W04G ABCDEFGHIJKLMNOP 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto ReloadAmmo

  ReloadAmmo:
    TNT1 A 0 A_GiveInventory("BizonClip",1)
    TNT1 A 0 A_TakeInventory("9mmAmmo",1)
    TNT1 A 0 A_JumpIfInventory("BizonClip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("9mmAmmo",1,"ReloadAmmo")
    goto ReloadEnd
	
	
	ReloadEnd:
		W04G QRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W04H ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W04I ABCDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready	
	
	



	Flash:
	TNT1 A 0 ACS_ExecuteAlways(799, 0, 0, 0, 0)
	TNT1 A 0 A_GiveInventory("CrosshairGrow", 6)
	TNT1 A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,13,3)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound ("BIZON/FIRE")
		TNT1 A 0 A_PlaySound("BIZON/Distant", 7)
		TNT1 A 0 A_FireCustomMissile("RifleCaseSpawn",5,0,12,-6)
        TNT1 A 0 BRIGHT A_FireCustomMissile("Tracer", frandom(-1.5,1.5), 0, 11, 0, 0, frandom(-1.5,1.5))
		TNT1 A 2 A_FireBullets(4, 4, 1, 35.0, "BizonBullet")//6,65
		Goto LightDone
 	Spawn:
		W04Z A -1
		Stop
	}
}