Actor AssaultRifleGiver : CustomInventory Replaces "Assault Rifle "
{ //Scripted (Mutiplayer weapon spawn can break as well as functions in the upgrade ACS code... this counts for all upgradable weapon actors)
Scale 0.95
-COUNTITEM
+INVENTORY.BIGPOWERUP
+INVENTORY.AUTOACTIVATE
+INVENTORY.IGNORESKILL
Inventory.PickupSound "items/assaultrifle"
Inventory.PickupMessage "Assault Rifle"
States
{
   Spawn:
     TNT1 A 0
	 TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("CheckWeaponWorldSpawn") == 2,1)
	 Goto SpawnDropped
	 MGUN A -1
	 Wait
   SpawnDropped:
     TNT1 A 1 A_SpawnItem("AsssaultRifleGiverDropped")
	 Stop
   Pickup:
	 TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("MPWeaponCheck") == 2,"PickupMP")
	 TNT1 A 0 A_JumpIfInventory("Burst Rifle",1,"GiveUpgrade")
	 TNT1 A 0 A_GiveInventory("BulletMag",20)
	 TNT1 A 1 A_GiveInventory(" Assault Rifle ",1)
	 Stop
   GiveUpgrade:
     TNT1 A 0 A_GiveInventory("BulletMag",40)
     TNT1 A 1 A_GiveInventory("Burst Rifle",1)
	 Stop
   PickupMP:
     TNT1 A 0 A_JumpIfInventory(" Assault Rifle ",1,"Nope")
	 TNT1 A 0 A_JumpIfInventory("Burst Rifle",1,"Nope")
	 TNT1 A 0 A_GiveInventory("BulletMag",20)
     TNT1 A 1 ACS_NamedExecuteAlways("SpawnWeaponActive",0,4)
	 Fail
   Nope:
     MGUN A 1
	 Fail
	 }
}

Actor AsssaultRifleGiverDropped : AssaultRifleGiver
{
+INVENTORY.TOSSED
+INVENTORY.NEVERRESPAWN
States
{
  Spawn:
   MGUN A -1
   Loop
  Pickup:
   TNT1 A 0 A_JumpIfInventory("Burst Rifle",1,"GiveUpgrade")
   TNT1 A 0 A_GiveInventory("BulletMag",20)
   TNT1 A 1 A_GiveInventory(" Assault Rifle ",1)
   Stop
   }
}

ACTOR AssRifleLoaded : Inventory {Inventory.MaxAmount 1}
ACTOR AssRifleStartToken : Inventory {Inventory.MaxAmount 1}

Actor " Assault Rifle " : "Assault Rifle "
{ //Scripted (Mutiplayer weapon spawn can break as well as functions in the upgrade ACS code... this counts for all upgradable weapon actors)
Weapon.AmmoGive 0
Weapon.AmmoGive2 0
Dropitem "AsssaultRifleGiverDropped"
+INVENTORY.UNDROPPABLE
States
{
	Select:
		TNT1 A 0 A_Raise
		Wait
	Deselect:
		TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
		TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
		TNT1 A 0 A_TakeInventory("MineAction",1)
		TNT1 A 0 A_TakeInventory("RailgunAction",1)
		TNT1 A 0 A_TakeInventory("WEMAction",1)
	DeselectLoop:
	    TNT1 A 0 A_Lower
		AS02 A 1 A_Lower
		Loop
	Ready:
	    TNT1 A 1 A_TakeInventory("WEMAction",1)
        TNT1 A 0 A_JumpIfInventory("AssRifleStartToken",1,1)
	    Goto Startup
		TNT1 A 0 A_PlayWeaponSound("items/assaultrifle")
		AS01 ABCDEF 1
		AS01 GH 1
		Goto ReadyLoop
	ReadyLoop:
		AS02 A 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		TNT1 A 0 A_JumpIfInventory("WEMAction",1,"LowerWeapon")
		Loop
	Startup:
	    AS03 VUTSW 1
		TNT1 A 0 A_PlaySound("assaultrifle/startup")
		Goto AltFire2+15
	LowerWeapon:
	    TNT1 A 0 A_TakeInventory("WEMAction",1)
	    AS03 R 1 A_PlayWeaponSound("weapons/weapondown")
		AS03 STUV 1
	    TNT1 A 1
		Wait
	Fire:
		TNT1 A 0 A_JumpIfNoAmmo("Empty")	
		TNT1 A 0 A_PlaySound("weapons/assaultrifle")
		TNT1 A 0 A_AlertMonsters	
		TNT1 A 0 A_GunFlash
		TNT1 A 0 Radius_Quake(1,2,0,1,0)
		TNT1 A 0 A_SpawnItemEx("RifleCasing",30,3,25,Random(2,4),Random(3,6),Random(3,6),0,SXF_NOCHECKPOSITION|SXF_CLIENTSIDE,0)
		TNT1 A 0 A_Light1
		AS02 B 2 Bright A_FireBullets(4.0,2.4,1,Random(5,7),"ModdedBulletPuff")
		TNT1 A 0 A_Light0
		AS02 CD 1
		TNT1 A 0 A_JumpIfInventory("ARMagazine",1,"Fire2")
		AS02 EE 1 A_Refire
		Goto ReadyLoop
	Fire2:
		TNT1 A 0 A_PlaySound("weapons/assaultrifle")
		TNT1 A 0 A_AlertMonsters	
		TNT1 A 0 A_GunFlash
		TNT1 A 0 Radius_Quake(1,2,0,1,0)
		TNT1 A 0 A_SpawnItemEx("RifleCasing",30,3,25,Random(2,4),Random(3,6),Random(3,6),0,SXF_NOCHECKPOSITION|SXF_CLIENTSIDE,0)
		TNT1 A 0 A_Light2
		AS02 B 2 Bright A_FireBullets(4.0,2.4,1,Random(5,7),"ModdedBulletPuff")
		TNT1 A 0 A_Light0
		AS02 CD 1
		AS02 EE 1 A_Refire("Fire")
		Goto ReadyLoop
	Flash:
		TNT1 A 3 Bright A_Light1
		Goto LightDone
	Empty:
		TNT1 A 0 A_PlayWeaponSound("weapons/click")
		AS02 AAAAAAAAAA 1 A_WeaponReady(WRF_NOFIRE)
		Goto AltFire
	AltFire:
	    TNT1 A 0 A_JumpIfInventory("ARMagazine",1,2)
		TNT1 A 0 A_TakeInventory("AssRifleLoaded",1)
	    TNT1 A 0 A_JumpIfInventory("AssRifleLoaded",1,"AltFireSecond")
		TNT1 A 0 A_JumpIfInventory("ARMagazine",41,2)
		TNT1 A 0 A_JumpIfInventory("BulletMag",1,"AltFire2")
		AS02 A 1 A_WeaponReady(WRF_NOFIRE)
		Goto ReadyLoop
	AltFireSecond:
		TNT1 A 0 A_JumpIfInventory("ARMagazine",40,2)
		TNT1 A 0 A_JumpIfInventory("BulletMag",1,"AltFire2")
		AS02 A 1 A_WeaponReady(WRF_NOFIRE)
		Goto ReadyLoop
	AltFire2:
		AS02 F 1 A_PlayWeaponSound("weapons/arreload")
		AS02 GHIJKLMNO 1
		AS02 P 1 A_FireCustomMissile("AREmptyMagSpawner",0,0,0,1)
		AS02 QR 1
		AS02 S 3
		AS02 TUV 1
		TNT1 A 0 A_JumpIfInventory("AssRifleLoaded",1,1)
		Goto ReloadWeapon2
	ReloadWeapon:
		TNT1 A 0 A_TakeInventory("BulletMag",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_GiveInventory("ARMagazine",1)
		TNT1 A 0 A_JumpIfInventory("ARMagazine",40,"ReloadDone")
		TNT1 A 0 A_JumpIfInventory("BulletMag",1,"ReloadWeapon")
		Goto ReloadDone
	ReloadWeapon2:
		TNT1 A 0 A_TakeInventory("BulletMag",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_GiveInventory("ARMagazine",1)
		TNT1 A 0 A_JumpIfInventory("ARMagazine",41,2)
		TNT1 A 0 A_JumpIfInventory("BulletMag",1,"ReloadWeapon2")
	ReloadDone:
		AS02 W 2
		AS02 XYZ 1
		AS03 ABCD 1
		AS02 KJIHGF 1
		TNT1 A 0 A_JumpIfInventory("AssRifleLoaded",1,"ReadyLoop")
	ReloadFull:
		AS03 EF 2
		TNT1 A 0 A_GiveInventory("AssRifleLoaded",1)
		TNT1 A 0 A_GiveInventory("AssRifleStartToken",1)
		AS03 G 1 A_PlayWeaponSound("weapons/arclick")
		AS03 HIJKLMNOPQ 1
		Goto ReadyLoop
	GrenadeCheck:
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,"GrenadeToss")
		TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
		Goto ReadyLoop
	GrenadeToss:
		TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
		AS03 RSTUV 1
		TNT1 A 4
	HGRN ABCDEFGHI 1
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadepin")
	HGRN JKLM 2
	TNT1 A 11
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	TNT1 A 0 A_TakeInventory("HandGrenadeAmmo",1,TIF_NOTAKEINFINITE)
	HGRN N 1 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
	HGRN OPQRS 1
	HGRN TU 2
		TNT1 A 6 A_TakeInventory("HandGrenadeAction",1)
		TNT1 A 0 A_PlayWeaponSound("assaultshotgun/draw")
		AS03 VUTSR 1
		Goto ReadyLoop
	MineCheck:
		TNT1 A 0 A_JumpIfInventory("MineAmmo",1,"MineToss")
		TNT1 A 0 A_TakeInventory("MineAction",1)
		Goto ReadyLoop
	MineToss:
		TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
		AS03 RSTUV 1
		TNT1 A 8
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	MINE ABCDEF 1
	TNT1 A 0 A_TakeInventory("MineAmmo",1,TIF_NOTAKEINFINITE)
	MINE G 1 A_FireCustomMissile("ThrownMine",0,0,0,0,false)
	MINE HI 1
	MINE JKLM 1
	TNT1 A 5 A_TakeInventory("MineAction",1)
		TNT1 A 0 A_PlayWeaponSound("assaultshotgun/draw")
		AS03 VUTSR 1
		Goto ReadyLoop
		}
}

ACTOR BurstRifleUpgradeToken : Inventory {Inventory.MaxAmount 1}
ACTOR BurstRifleSemi : Inventory {Inventory.MaxAmount 1}
ACTOR BurstSlapToken : Inventory {Inventory.MaxAmount 1}
ACTOR BurstStartToken : Inventory {Inventory.MaxAmount 1}

ACTOR "Burst Rifle" : " Assault Rifle "
{ //Scripted (Mutiplayer weapon spawn can break as well as functions in the upgrade ACS code... this counts for all upgradable weapon actors)
//Creator: Fluffy
//Origin: Nexus Infinity
//Sprite: BSXX/ZRIZ
//Title: "Pulse Assault Shotgun" 
Scale 0.8
Weapon.AmmoType "BRMagazine"
Weapon.SelectionOrder 4832
Weapon.KickBack 50
Inventory.PickupSound "br/pickup"
Obituary "%o was shot dead by %k's Burst Rifle."
Inventory.PickupMessage "Burst Rifle"
Dropitem "AsssaultRifleGiverDropped"
Tag "Burst Rifle"
+NOAUTOFIRE
+WEAPON.AMMO_OPTIONAL
+WEAPON.NOALERT
+WEAPON.CHEATNOTWEAPON
+INVENTORY.UNDROPPABLE
States
{
	Spawn:
		ZRIZ A -1
		Stop
	Deselect:
		TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
		TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
		TNT1 A 0 A_TakeInventory("MineAction",1)
		TNT1 A 0 A_TakeInventory("RailgunAction",1)
		TNT1 A 0 A_TakeInventory("WEMAction",1)
	DeselectLoop:
		TNT1 A 0 A_Lower
		BS21 A 1 A_Lower
		Loop
	Select:
		TNT1 A 0 A_Raise
		Wait
	Ready:
	    TNT1 A 1 A_TakeInventory("RailgunAction",1)
	    TNT1 A 0 A_JumpIfInventory("BurstStartToken",1,1)
		Goto Startup
		TNT1 A 0 A_PlayWeaponSound("br/draw")
		BS20 ABCDEFGH 1
	ReadyLoop:
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		TNT1 A 0 A_JumpIfInventory("RailgunAction",1,"Zoom")
		TNT1 A 0 A_JumpIfInventory("WEMAction",1,"LowerWeapon")
		BS21 A 1 A_WeaponReady
		Loop
	Startup:
	    TNT1 A 0 A_GiveInventory("BurstRifleUpgradeToken",1)
		TNT1 A 0 A_TakeInventory(" Assault Rifle ",1)
	    TNT1 A 0 A_GiveInventory("BurstStartToken",1)
		BS23 XYZ 1
		Goto MaxReload+19
	LowerWeapon:
	    TNT1 A 0 A_TakeInventory("WEMAction",1)
	    TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
		BS23 STUVW 1
	    TNT1 A 1
		Wait
	Fire:
	    TNT1 A 0 A_JumpIfNoAmmo("Empty")
		TNT1 A 0 A_JumpIfInventory("BurstRifleSemi",1,"Fire2")
	    TNT1 A 0 A_PlayWeaponSound("br/burstfire")
	    TNT1 A 0 A_AlertMonsters	
		TNT1 A 0 A_GunFlash
		TNT1 A 0 Radius_Quake(1,2,0,1,0)
	    TNT1 A 0 A_SpawnItemEx("RifleCasing",30,3,25,Random(2,4),Random(3,6),Random(3,6),0)
		TNT1 A 0 A_Light1
		BS21 B 1 Bright A_FireBullets(3.1,2.0,-1,Random(40,55),"SniperBulletPuff")
		BS21 C 1 Bright
		TNT1 A 0 A_Light0
		BS21 E 1
	    TNT1 A 0 A_JumpIfInventory("BRMagazine",1,1)
		Goto Empty	
	    TNT1 A 0 A_AlertMonsters	
		TNT1 A 0 A_GunFlash
		TNT1 A 0 Radius_Quake(1,2,0,1,0)
	    TNT1 A 0 A_SpawnItemEx("RifleCasing",30,3,25,Random(2,4),Random(3,6),Random(3,6),0)
		TNT1 A 0 A_Light1
		BS21 F 1 Bright A_FireBullets(3.1,2.0,-1,Random(40,55),"SniperBulletPuff")
		TNT1 A 0 A_Light0
		BS21 G 2
	    TNT1 A 0 A_JumpIfInventory("BRMagazine",1,1)
		Goto Empty
	    TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_GunFlash
		TNT1 A 0 Radius_Quake(1,2,0,1,0)
	    TNT1 A 0 A_SpawnItemEx("RifleCasing",30,3,25,Random(2,4),Random(3,6),Random(3,6),0)
		TNT1 A 0 A_Light2
		BS21 H 1 Bright A_FireBullets(3.1,2.0,-1,Random(40,55),"SniperBulletPuff")
		TNT1 A 0 A_Light0
		BS21 I 2
    EndFire:
	    BS21 JKL 2
		BS21 MN 2 A_Refire
		Goto ReadyLoop
	Fire2:
	    TNT1 A 0 A_PlayWeaponSound("br/fire")
	    TNT1 A 0 A_AlertMonsters	
		TNT1 A 0 A_GunFlash
		TNT1 A 0 Radius_Quake(1,2,0,1,0)
	    TNT1 A 0 A_SpawnItemEx("RifleCasing",30,3,25,Random(2,4),Random(3,6),Random(3,6),0)
		TNT1 A 0 A_Light1
		BS21 B 1 Bright A_FireBullets(1.0,0.4,-1,Random(40,55),"SniperBulletPuff")
		BS21 C 1 Bright
		BS21 D 1 Bright
		TNT1 A 0 A_Light0
		BS21 O 2
		BS21 PMN 2 A_WeaponReady
		Goto ReadyLoop
	Flash:
		TNT1 A 0
		Goto LightDone
    Empty:
	    TNT1 A 0 A_PlayWeaponSound("weapons/click")
        BS21 MMMNNNAAA 1 A_WeaponReady(WRF_NOFIRE)
    AltFire:
  	    TNT1 A 0 A_JumpIfInventory("BRMagazine",31,2)
        TNT1 A 0 A_JumpIfInventory("BulletMag",1,2)
		TNT1 A 0
		Goto ReadyLoop
		TNT1 A 0 A_JumpIfInventory("BRMagazine",1,"MaxReload")
	    BS21 QRSTU 1
		BS21 VWXY 2
		BS21 "Z" 1
		BS22 A 1 A_PlayWeaponSound("br/bolt2")
		BS22 BCD 1
		BS22 EFGHI 2
		BS22 J 1 A_PlayWeaponSound("br/magout")
		BS22 KLM 1
		BS22 N Random(1,6) A_FireCustomMissile("AREmptyMagSpawner",0,0,0,1)
		BS23 N Random(1,6)
		BS23 O Random(1,6)
		BS23 P Random(1,6)
		BS23 Q Random(1,6)
		BS22 OPQ 1
		BS22 R 2
    Reload:
	    TNT1 A 0 A_TakeInventory("BulletMag",1)
	    TNT1 A 0 A_GiveInventory("BRMagazine",1)
	    TNT1 A 0 A_JumpIfInventory("BRMagazine",30,2)
	    TNT1 A 0 A_JumpIfInventory("BulletMag",1,"Reload")
		BS22 S 2 A_PlayWeaponSound("br/magin")
		BS22 TU 3
		BS22 VW 2
		BS23 EFGH 1
		BS23 I 2
		BS23 J 2 A_PlayWeaponSound("br/bolt1")
		BS23 KLM 2
		BS21 TSRQ 1
		Goto ReadyLoop
	MaxReload:
	    BS21 QRSTU 1
		BS23 R 1
		BS22 W 1
		BS22 UTS 2
		BS22 R 1 A_PlayWeaponSound("br/magout")
		BS22 QPO 1
		BS22 N Random(1,6) A_FireCustomMissile("AREmptyMagSpawner",0,0,0,1)
		BS23 N Random(1,6)
		BS23 O Random(1,6)
		BS23 P Random(1,6)
		BS23 Q Random(1,6)
		BS22 OPQ 1
		BS22 R 2
    Reload2:
	    TNT1 A 0 A_TakeInventory("BulletMag",1)
	    TNT1 A 0 A_GiveInventory("BRMagazine",1)
	    TNT1 A 0 A_JumpIfInventory("BRMagazine",31,2)
	    TNT1 A 0 A_JumpIfInventory("BulletMag",1,"Reload2")
		BS22 S 2 A_PlayWeaponSound("br/magin")
		BS22 TU 2
		BS22 VW 1
		BS22 XY 1
		BS22 "Z" 2
		BS23 A 2 A_PlayWeaponSound("br/slap")
		BS23 BCD 2
		BS21 V 2
		BS21 UTSRQ 1
		Goto ReadyLoop
    GrenadeCheck:
	    TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,"GrenadeToss")
		TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	    Goto ReadyLoop
    GrenadeToss:
  	    TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	    BS23 STUVW 1
	    TNT1 A 4
	HGRN ABCDEFGHI 1
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadepin")
	HGRN JKLM 2
	TNT1 A 11
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	TNT1 A 0 A_TakeInventory("HandGrenadeAmmo",1,TIF_NOTAKEINFINITE)
	HGRN N 1 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
	HGRN OPQRS 1
	HGRN TU 2
	    TNT1 A 6 A_TakeInventory("HandGrenadeAction",1)
		BS23 WVUTS 1
		Goto ReadyLoop
    MineCheck:
		TNT1 A 0 A_JumpIfInventory("MineAmmo",1,"MineToss")
		TNT1 A 0 A_TakeInventory("MineAction",1)
		Goto ReadyLoop
    MineToss:
  	    TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	    BS23 STUVW 1
	    TNT1 A 8
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	MINE ABCDEF 1
	TNT1 A 0 A_TakeInventory("MineAmmo",1,TIF_NOTAKEINFINITE)
	MINE G 1 A_FireCustomMissile("ThrownMine",0,0,0,0,false)
	MINE HI 1
	MINE JKLM 1
	TNT1 A 5 A_TakeInventory("MineAction",1)
		BS23 WVUTS 1
		Goto ReadyLoop
    Zoom:
		TNT1 A 0 A_TakeInventory("RailgunAction",1)
		TNT1 A 0 A_JumpIfInventory("BurstRifleSemi",1,"Zoom2")
		TNT1 A 0 A_PlaySound("enforcer/mode")
		TNT1 A 0 A_GiveInventory("BurstRifleSemi",1)
		BS21 L 2 A_Print("Semi fire",1)
		BS21 MN 2
		Goto ReadyLoop
    Zoom2:
		TNT1 A 0 A_PlaySound("enforcer/mode")
		TNT1 A 0 A_TakeInventory("BurstRifleSemi",1)
		BS21 L 2 A_Print("Burst fire",1)
		BS21 MN 2
		Goto ReadyLoop
		}
}

ACTOR BRMagazine : Ammo
{
Inventory.Amount 0
Inventory.MaxAmount 31
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 31
Inventory.Icon "ZRIZA0"
+IGNORESKILL
}