ACTOR MachineRifle : Weapon 
{
	Weapon.SelectionOrder 500
	Weapon.SlotNumber 4
	Weapon.AmmoType "RifleAmmo"
	Weapon.AmmoGive 15
	Weapon.AmmoUse 1
	Weapon.AmmoType2 "Magazine"
	Weapon.AmmoUse2 1
	Inventory.Pickupmessage "You got the Maschine Rifle!"
	Inventory.PickupSound "weapons/fist/swing"
	Obituary "%o was neutralized by %k's rifle."
	+WEAPON.NOALERT
	+WEAPON.AMMO_CHECKBOTH
	Tag "Maschine Rifle"
	Weapon.BobStyle "Smooth"
	Weapon.BobSpeed 2.0
	Weapon.BobRangeX 0.30
	Weapon.BobRangeY 0.40
	Scale 0.8
	States
	{
	Steady:
		Goto Ready
	SteadyAim:
		Goto Ready2
	Ready:
		ASLR H 1 Offset(200,50) A_PlaySound("weapons/rifle/up")
		ASLR I 1 Offset(175,49)
		ASLR J 1 Offset(140,47)
		ASLR K 1 Offset(110,45)
		ASLR L 1 Offset(65,43)
		ASLR M 1 Offset(50,41)
		ASLR N 1 Offset(40,39)
		ASLR O 1 Offset(32,38)
		ASLR P 1 Offset(28,37)
		ASLR Q 1 Offset(20,36)
		ASLR R 1 Offset(10,35)
		ASLR S 2 Offset(5,34)
		ASLR A 1 Offset(0,32)
		TNT1 A 0 A_Refire
	ReadyII:
		TNT1 A 0 ACS_NamedExecuteAlways("SynthLeft",0,0,0,0) //act.synth-fire LEFT(pri)
		TNT1 A 0 ACS_NamedExecuteAlways("SynthRight",0,0,0,0) //act.synth-fire RIGHT(sec)
		TNT1 A 0 A_JumpIfInventory("SynthFireRight",1,"ZoomIn")
		TNT1 A 0 A_JumpIfInventory("Magazine",0,2)
		TNT1 A 0 A_JumpIfInventory("RifleAmmo",1,2)
		ASLT A 1 A_WeaponReady
		Loop
		ASLT A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop
	Ready2:
		TNT1 A 0 A_FireBullets(0,0,1,0,"LaserDot",FBF_NOFLASH|FBF_NORANDOMPUFFZ)
		TNT1 A 0 A_JumpIfInventory("SynthFireLeft",1,"AimedFire")
		TNT1 A 0 A_JumpIfInventory("Magazine",0,2)
		TNT1 A 0 A_JumpIfInventory("RifleAmmo",1,3)
		IRON A 1 A_WeaponReady
		TNT1 A 0 A_Refire ("Ready2")
		Goto ZoomOut
		IRON A 1 A_WeaponReady (WRF_ALLOWRELOAD)
		TNT1 A 0 A_JumpIfInventory("SynthFireLeft",1,"AimedFire")
		TNT1 A 0 A_Refire ("Ready2")
		Goto ZoomOut
	Deselect:
		TNT1 A 0 A_TakeInventory("SynthFireActive",1)
		TNT1 A 0 A_TakeInventory("SynthFireLeft",1)
		TNT1 A 0 A_TakeInventory("SynthFireRight",1)
		TNT1 A 0 A_Takeinventory("ZoomIn",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_Takeinventory("Aiming",1)
		TNT1 A 0 A_PlaySound("weapons/rifle/deselect")
		ASLT A 1 Offset(15,40)
		ASLT A 1 Offset(30,55)
		ASLT A 1 Offset(45,75)
		ASLT A 1 Offset(60,100)
		ASLT A 1 Offset(75,130)
		TNT1 A 5
		TNT1 A 0 A_Lower
		Wait
	Select: 
		ASLT A 0 A_Raise
		Loop
	Fire:
		TNT1 A 0 A_JumpIfInventory("Magazine",1,1)
		Goto ReloadCheck
		TNT1 AAAA 0
		TNT1 A 0 A_JumpIfInventory("ZoomIn",1,"AimedFire")
		TNT1 A 0 A_TakeInventory("Magazine",1,TIF_NOTAKEINFINITE)
		ASLT A 0 A_AlertMonsters
		ASLT A 0 A_PlaySound("weapons/rifle/fire", 7)
		ASLT A 1 A_GunFlash
		ASLT A 0 A_SetPitch(pitch+0.1)
		ASLT A 1 Bright A_FireBullets(3,3,-1,7,"AltPuff2",0)
		TNT1 A 0 A_FireCustomMissile("GunSmokeSpawner",0,0,8,0)
		TNT1 A 0 A_FireCustomMissile("RifleCasingSpawner",0,0,8,-17)
		ASLT D 0 A_SetPitch(pitch-0.1)
		TNT1 A 0 A_ZoomFactor(0.996)
		ASLT D 1 Offset(0,33)
		TNT1 A 0 A_ZoomFactor(0.997)
		ASLT B 1 Offset(0,32)
		TNT1 A 0 A_ZoomFactor(0.999)
		ASLT A 1
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_ReFire
		Goto ReadyII
	AimedFire:
		TNT1 A 0 A_JumpIfInventory("Magazine",1,1)
		Goto ReloadCheck
		IRON A 0 A_AlertMonsters
		TNT1 A 0 A_TakeInventory("Magazine",1,TIF_NOTAKEINFINITE)
		IRFI A 0 A_PlaySound("weapons/rifle/fire", 7)
		TNT1 A 0 A_GunFlash("AltFlash")
		IRFI A 0 A_FireBullets(1,1,-1,7,"AltPuff2",0)
		TNT1 A 0 A_ZoomFactor(1.496)
		TNT1 A 0 A_Light2
		TNT1 A 0 A_FireCustomMissile("GunSmokeSpawner",0,0,8,0)
		TNT1 A 0 A_FireCustomMissile("RifleCasingSpawner",0,0,8,0)
		IRFI AB 1 Bright A_FireBullets(0,0,1,0,"LaserDot",FBF_NOFLASH|FBF_NORANDOMPUFFZ)
		TNT1 A 0 A_Light0
		TNT1 A 0 A_ZoomFactor(1.498)
		IRFI C 1 Offset(0,33) A_FireBullets(0,0,1,0,"LaserDot",FBF_NOFLASH|FBF_NORANDOMPUFFZ)
		TNT1 A 0 A_ZoomFactor(1.5)
		TNT1 A 0 Offset(0,32)
		IRON A 1 A_FireBullets(0,0,1,0,"LaserDot",FBF_NOFLASH|FBF_NORANDOMPUFFZ)
		TNT1 A 0 A_JumpIfInventory("SynthFireRight",1,"Ready2")
		IRON A 1 A_FireBullets(0,0,1,0,"LaserDot",FBF_NOFLASH|FBF_NORANDOMPUFFZ)
		TNT1 A 0 A_WeaponReady
		Goto ZoomOut
	Altfire:
		TNT1 A 0 A_JumpIfInventory("Aiming",1,"Ready2")
		TNT1 A 0 A_Giveinventory("ZoomIn",1)
		TNT1 A 0 A_ZoomFactor(1.5)
		TNT1 A 0 A_Giveinventory("Aiming",1)
		TNT1 A 0 A_PlayWeaponSound("weapons/riotgun/raise")
		IRSW A 1
		IRSW B 1 A_WeaponReady(1)
		Goto Ready2
	ZoomOut:
		TNT1 AAAAAA 0
		IRSW BA 2
		TNT1 A 0 A_Takeinventory("ZoomIn",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_Takeinventory("Aiming",1)
		Goto ReadyII
	Flash:
		RFLF A 1 BRIGHT A_Light2
		RFLF B 1 BRIGHT A_Light1
		Goto LightDone
	AltFlash:
		MRFL A 1 BRIGHT A_Light1
		Goto LightDone
	ReloadCheck:
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("RifleReload")==0, "NoReloadChamberCheck")
		Goto Reload
	Reload:
		TNT1 A 0 A_Takeinventory("ZoomIn",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		ASLR ABCD 1 
		TNT1 A 0 A_PlayWeaponSound("weapons/rifle/out")
		ASLR MN 3
		ASLR L 2
		ASLR KG 2
		ASLR GGGG 3
	ReloadChamberCheck:
		TNT1 A 0 A_JumpIfInventory ("ExtendedMags",1,"ReloadChamberCheck2")
		TNT1 A 0 A_JumpIfInventory("Magazine",1,"ReloadLoop2")
		Goto ReloadLoop
	ReloadChamberCheck2:
		TNT1 A 0 A_JumpIfInventory("Magazine",1,"ReloadLoop4")
		Goto ReloadLoop3
	ReloadLoop:
		TNT1 A 0 A_GiveInventory("Magazine")
		TNT1 A 0 A_TakeInventory("RifleAmmo",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_JumpIfInventory("Magazine",30,"ReloadEnd")
		TNT1 A 0 A_JumpIfInventory("RifleAmmo",1,"ReloadLoop")
		Goto ReloadEnd
	ReloadLoop2:
		TNT1 A 0 A_GiveInventory("Magazine")
		TNT1 A 0 A_TakeInventory("RifleAmmo",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_JumpIfInventory("Magazine",31,"ReloadEnd2")
		TNT1 A 0 A_JumpIfInventory("RifleAmmo",1,"ReloadLoop2")
		Goto ReloadEnd2
	ReloadLoop3:
		TNT1 A 0 A_GiveInventory("Magazine")
		TNT1 A 0 A_TakeInventory("RifleAmmo",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_JumpIfInventory("Magazine",40,"ReloadEnd")
		TNT1 A 0 A_JumpIfInventory("RifleAmmo",1,"ReloadLoop3")
		Goto ReloadEnd
	ReloadLoop4:
		TNT1 A 0 A_GiveInventory("Magazine")
		TNT1 A 0 A_TakeInventory("RifleAmmo",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_JumpIfInventory("Magazine",41,"ReloadEnd2")
		TNT1 A 0 A_JumpIfInventory("RifleAmmo",1,"ReloadLoop4")
		Goto ReloadEnd2
	ReloadEnd:
		TNT1 A 0 A_Takeinventory("Aiming",1)
		TNT1 A 0 A_PlayWeaponSound("weapons/rifle/in")
		ASLR HIJKLMNOP 1
		TNT1 A 0 A_PlayWeaponSound("weapons/rifle/bolt")
		ASLR QRS 2
		ASLR U 3
		TNT1 A 0 A_Refire
		Goto ReadyII
	ReloadEnd2:
		TNT1 A 0 A_Takeinventory("Aiming",1)
		TNT1 A 0 A_PlayWeaponSound("weapons/rifle/slap")
		ASLR HIJKLMNOP 1
		ASLR QRS 2
		ASLR U 3
		TNT1 A 0 A_Refire
		Goto ReadyII
		
	NoReloadChamberCheck:
		TNT1 A 0 A_JumpIfInventory ("ExtendedMags",1,"NoReloadChamberCheck2")
		TNT1 A 0 A_JumpIfInventory("Magazine",1,"NoReloadLoop2")
		Goto NoReloadLoop
	NoReloadChamberCheck2:
		TNT1 A 0 A_JumpIfInventory("Magazine",1,"NoReloadLoop4")
		Goto NoReloadLoop3
	NoReloadLoop:
		TNT1 A 0 A_GiveInventory("Magazine")
		TNT1 A 0 A_TakeInventory("RifleAmmo",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_JumpIfInventory("Magazine",30,"NoReloadEnd")
		TNT1 A 0 A_JumpIfInventory("RifleAmmo",1,"NoReloadLoop")
		Goto NoReloadEnd
	NoReloadLoop2:
		TNT1 A 0 A_GiveInventory("Magazine")
		TNT1 A 0 A_TakeInventory("RifleAmmo",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_JumpIfInventory("Magazine",31,"NoReloadEnd")
		TNT1 A 0 A_JumpIfInventory("RifleAmmo",1,"NoReloadLoop2")
		Goto NoReloadEnd
	NoReloadLoop3:
		TNT1 A 0 A_GiveInventory("Magazine")
		TNT1 A 0 A_TakeInventory("RifleAmmo",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_JumpIfInventory("Magazine",40,"NoReloadEnd")
		TNT1 A 0 A_JumpIfInventory("RifleAmmo",1,"NoReloadLoop3")
		Goto NoReloadEnd
	NoReloadLoop4:
		TNT1 A 0 A_GiveInventory("Magazine")
		TNT1 A 0 A_TakeInventory("RifleAmmo",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_JumpIfInventory("Magazine",41,"NoReloadEnd")
		TNT1 A 0 A_JumpIfInventory("RifleAmmo",1,"NoReloadLoop4")
		Goto NoReloadEnd
	NoReloadEnd:
		TNT1 A 0 A_ReFire
		Goto ReadyII
	Spawn:
		RIFL A -1
		Stop
	}
}

ACTOR Magazine : Ammo
{
	+IGNORESKILL
	Inventory.MaxAmount 31
	Ammo.BackpackMaxAmount 41
}

ACTOR Laserdot
{ 
	Decal "None"
    Mass 0
    Scale 0.125
    Radius 1
    Height 2
	Alpha 0.6
    +NOBLOCKMAP
    +NOGRAVITY
    +BLOODLESSIMPACT
    +ALWAYSPUFF
    +PUFFONACTORS
    +DONTSPLASH
	+NOTRIGGER
	+FORCEXYBILLBOARD
    Renderstyle Add
    Alpha 0.4
    States
    {
	Spawn:
		LSIT A 0
		LSIT A 1 BRIGHT A_FadeOut(0.1)
		Stop
	}
}

Actor ZoomIn : Inventory
{
	Inventory.Maxamount 1
}

Actor Aiming : Inventory
{
	Inventory.Maxamount 1
}