
//Dusk damage chart (type: Dmg)
//SP: 25
//MP: 20


//Ass rifle. Abreviation for ASSault rifle. Not a thicc weapon.
ACTOR Dusk_assrifle_newammo : DuskWeapon //replaces chaingun
{
	+POWERED_UP 
	Weapon.SisterWeapon Dusk_assrifle

+WEAPON.NOAUTOAIM
	Weapon.SelectionOrder 1
Weapon.Slotnumber 5
//	Weapon.SisterWeapon Dusk_Assrifle_Fastfire

	Weapon.AmmoUse 1
	Weapon.AmmoGive 20//40
	Weapon.AmmoType "Dusk_Wep5Ammo"
	Weapon.UpSound "ass_rifle/raise"

	Inventory.PickupMessage "$ASSR_PICK"
	Obituary "$ASSR_OB"
	Tag "Assault rifle"
	States
	{
	Ready:
TNT1 A 0 A_JumpIfInventory("Doosk_ExplosiveBarrelWeapon",1,"Select_Barrel")
TNT1 A 0 A_JumpIfInventory("Doosk_HereticBarrelWeapon",1,"Select_HereticBarrel")
TNT1 A 0 A_JumpIfInventory("Doosk_SoapWeapon",1,"Select_Soap")

		W05C A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop
	Deselect:
    TNT1 A 0 A_TakeInventory("SetWeaponMemory",50)
    TNT1 A 0 A_GiveInventory("SetWeaponMemory",8)
	DeselectLoop:
		TST1 AAA 0 A_Lower
		TST1 A 1 A_Lower
		Loop
	Select:
		TNT1 A 0 A_SetCrosshair(14)
    TNT1 A 0 A_TakeInventory("SetWeaponActual",50)
    TNT1 A 0 A_GiveInventory("SetWeaponActual",8)
		TNT1 A 1 A_WeaponReady//(WRF_NOFIRE)
		W05A ABCDEFGHIJKL 1 A_WeaponReady//(WRF_NOFIRE)
		Goto Ready


	Reload://Weapon spin
	TNT1 A 0 A_PlaySound("sickles/fire")
		W01D A 0 A_CustomPunch(2 * random(1, 10), TRUE, 0, "MeleePuff")

		W05D ABCDE 1 A_WeaponReady (WRF_NOBOB)//(WRF_ALLOWRELOAD)
		W05D FGHIJKLMNOPQRSTUVWXYZ 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready

	
	
	Fire:
		W05D A 0 A_Gunflash	 		TNT1 A 0 A_GiveInventory("Player_WeaponShot",1)
		TNT1 A 0 A_JUMP(256, "Fire1","Fire2","Fire3")//Jumps into random muzzleflashes animaitons.

	Fire1:
		W05H AB 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		Goto FireContinue
	Fire2:
		W05H DE 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		Goto FireContinue
	Fire3:
		W05H FG 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		Goto FireContinue

//The rest of the fire animation.
	FireContinue:
//	Fire_Stacked2:
TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",31,	"Fire_Stacked2")
TNT1 A 0 A_JumpIfInventory("Fastfire_TotemAmount",1,	"Fire_Stacked1")

	  TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("MultiplayerCheck",0,0,0,0) == 2,2)
TNT1 A 0 A_JumpIf(CallACS("brokenass_firerate")==1, "Fire_Broken")//If mutator is detected, jumps into broken animation.
		W05F CDE 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire
		W05F F 1 A_WeaponReady (WRF_ALLOWRELOAD)
	FireContinue_Normal:
		W05F GHIJKLMNOPQRSTUVWXYZ 1 A_WeaponReady (WRF_ALLOWRELOAD)
		W05G AB 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto Ready




	Fire_Stacked1:
		W05F C 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire("Fire")
		W05F DE 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
		W05F F 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto FireContinue_Normal


	Fire_Stacked2:
		TNT1 A 0 A_Refire("Fire")
		W05F CDE 1 bright A_WeaponReady (WRF_ALLOWRELOAD)
		W05F F 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto FireContinue_Normal











//Broken fire sequence. For the memes.
	Fire_Broken:
		TNT1 A 0 A_JUMP(256, "Fire_Broken1","Fire_Broken2","Fire_Broken3")

	Fire_Broken1:
		W05F CD 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire
		W05F EF 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto FireContinue_Normal

	Fire_Broken2:
		W05F CDE 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire
		W05F F 1 A_WeaponReady (WRF_ALLOWRELOAD)
		Goto FireContinue_Normal

	Fire_Broken3:
		W05F CDEF 1 bright A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH)
		TNT1 A 0 A_Refire
		Goto FireContinue_Normal








	Flash:
		TNT1 A 0 A_FireBullets (AssrifleSpreadHorz, AssrifleSpreadVert, 1, AssrifleDmg, "WeaponPuff")//10
	FlashContinue:
		TNT1 A 0 A_PlaySound("ass_rifle/fire", CHAN_WEAPON)
	TNT1 A 0 ACS_NamedExecuteAlways("Weapon_Recoil", 0, 4, 0, 0)
	 
	TNT1 A 1 A_JumpIf(CallACS("CasingsType")==1, "CasingSpawner")
//Sprite casings
		C05B ABC 1 A_Light2
		C05B DEFG 1 A_Light1
		TNT1 A 0 A_Light0
		C05B HIJKL 1 
Goto LightDone	

	
//Actor casings		
	CasingSpawner:
		TNT1 A 0 A_FireCustomMissile("AssaultCaseSpawn",5,0,12,-6)//,-10,0,3,6)
		TNT1 A 3 A_Light2
		TNT1 A 4 A_Light1
		TNT1 A 0 A_Light0
		Goto LightDone




	Spawn:
		W05Z A -1
		Stop
	}
}


