ACTOR FleshrendPickup : CustomInventory
{
	Inventory.PickupSound "misc/w_pkup"
	Inventory.PickupMessage "Obtained a really damn stylish ''Fleshrend'' sawed-off! Peeling off the skins - multiple enemies at a time! (3)"
	States
	{
		Spawn:
		RNDG X -1
		Stop
		Pickup:
		TNT1 A 0 A_JumpIfInventory("FleshrendPickupCounter",2,"CheckAmmo")
		Goto GiveItNevertheless
		CheckAmmo:
		TNT1 A 0 A_JumpIfInventory("ShellsAmmo",0,"Bailure")
		GiveItNevertheless:
		TNT1 A 0 A_GiveInventory("Fleshrend")
		TNT1 A 0 A_GiveInventory("FleshrendPickupCounter")
		Stop
		Bailure:
		RNDG X 1
		Fail
	}
}

actor Fleshrend : Weapon
{
  Game Doom
  Weapon.AmmoUse 2
  Weapon.AmmoUse2 2
  Weapon.AmmoGive 4
  Weapon.AmmoType "ShellsAmmo"
  Weapon.AmmoType2 "ShellsAmmo"
  Weapon.SlotNumber 3
  Weapon.SelectionOrder 2
  Weapon.UpSound "Fleshrend/Up"
  Weapon.Kickback 150
  Inventory.PickupSound "misc/w_pkup"
  Inventory.PickupMessage "Obtained a really damn stylish ''Fleshrend'' sawed-off! Peeling off the skins - multiple enemies at a time! (3)"
  Obituary "%o was plastered over local furniture by %k's ''Fleshrend''."
  Weapon.BobStyle InverseSmooth
  Weapon.BobSpeed 2.0
  Weapon.BobRangeY 0.5
  Weapon.BobRangeX 0.7
  +NOALERT
  +AMMO_CHECKBOTH
  //+NOAUTOAIM
  States
  {
  Ready:
    RNDG A 0 A_JumpIfInventory("FleshrendPickupCounter",2,"TwinReady")
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	RNDR A 1 A_JumpIf(Health<75,1)
	RNDR BC 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	RNDR D 1 A_JumpIf(Health<50,1)
	RNDR EF 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	RNDR G 1 A_JumpIf(Health<25,1)
	RNDR H 1
  ReadyMain:
	RNDG A 0 A_GiveInventory("SynthFireActive",1)
	RNDG A 0 ACS_NamedExecuteAlways("SynthLeft")
	RNDG A 0 ACS_NamedExecuteAlways("SynthRight")
	RNDG A 0 A_Gunflash("Dualwelding",GFF_NOEXTCHANGE)
  SingleLIdle:
    TNT1 A 0 A_JumpIfInventory("FleshrendPickupCounter",2,"LIdle")
	TNT1 A 0 A_JumpIfInventory("SynthFireZoom",1,"Punch")
    TNT1 A 1 A_WeaponReady(WRF_NOFIRE|WRF_ALLOWZOOM)
	Loop
  TwinReady:
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	RN2L A 1 A_JumpIf(Health<75,1)
	RN2L BC 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	RN2L D 1 A_JumpIf(Health<50,1)
	RN2L EF 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	RN2L G 1 A_JumpIf(Health<25,1)
	RN2L H 1
	RN2U A 1 A_GiveInventory("SynthFireActive",1)
	RNDG A 0 ACS_NamedExecuteAlways("SynthLeft")
	RNDG A 0 ACS_NamedExecuteAlways("SynthRight")
	RNDG A 0 A_Gunflash("Dualwelding",GFF_NOEXTCHANGE)
  LIdle:
	RNDG A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
	RNDG A 0 A_JumpIfInventory("SynthFireZoom",1,"Punch")
    RNDG B 1 A_WeaponReady(12|WRF_ALLOWZOOM)
    Loop
  Deselect:
    TNT1 A 0 SetPlayerProperty(0, 0, PROP_INSTANTWEAPONSWITCH)
	TNT1 A 0 A_GunFlash("NullFlash",GFF_NOEXTCHANGE)
	TNT1 A 0 A_TakeInventory("SynthFireActive",1)
	TNT1 A 0 A_TakeInventory("SynthFireLeft",1)
	TNT1 A 0 A_TakeInventory("SynthFireRight",1)
    RNDG A 0 A_JumpIfInventory("FleshrendPickupCounter",2,"TwinDeselect")
    RNDN CBA 1
    TNT1 AA 0 A_Lower
    TNT1 A 1 A_Lower
	Goto Deselect+9
  TwinDeselect:
    /*RN2U A 1	//Had to resign from this here, as with gunflash whoring in synth fire, it causes silly visual bug.
    RN2L HGFEDCBA 1
    Goto DeselectMain
  DeselectMain:*/
    RN3N CBA 1
    TNT1 AA 0 A_Lower
    TNT1 A 1 A_Lower
	Goto TwinDeselect+3
  Select:
    TNT1 A 0 SetPlayerProperty(0, 1, PROP_INSTANTWEAPONSWITCH)
  HonkaCzongka:
    TNT1 A 0 A_Raise
	TNT1 A 1 A_Raise
    Loop

  Fire:
	TNT1 A 0
	Stop
  SingleLFire:
    RNDF A 0 A_JumpIfInventory("ShellsAmmo",2,1)
	Goto Nope
	RNDF A 0 A_PlaySound("Fleshrend/Fire",1,0.7)
	RNDF A 0 A_PlaySound("Fleshrend/Add",5,0.6)
	RNDF A 0 A_FireCustomMissile("GunsmokeSpawner_Medium",0,0,12,0)
    RNDF A 0 A_FireBullets(8.0, 2.0, 16, 5, "BulletPuff")
	RNDF A 0 A_AlertMonsters
	RNDF A 0 A_Recoil(2)
	RNDF A 0 A_Light2
    RNDF A 1 Bright A_SetPitch(pitch-2.5)
	RNDF B 1 Bright A_SetPitch(pitch-1.25)
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR A 1 A_JumpIf(Health<75,2)
	RNDR BC 1
	RNDF A 0 A_Light1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR D 1 A_JumpIf(Health<50,2)
	RNDR EFG 1
	RNDR C 0 A_Light0
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR H 1 A_JumpIf(Health<25,2)
	RNDR I 1
	RNDR I 0 A_PlaySound("Fleshrend/Out",4,0.6)
	RNDR JJ 0 A_FireCustomMissile("FleshyCasingSpawner",0,0,-1,2)
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR J 1 A_JumpIf(Health<75,2)
	RNDR KL 1
	RNDR O 0 A_PlaySound("Fleshrend/In",4,0.5)
	RNDR MNO 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR P 1 A_JumpIf(Health<50,2)
	RNDR QRST 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR U 1 A_JumpIf(Health<25,2)
	RNDG A 2
	RNDR A 0 A_JumpIfInventory("SynthFireLeft",1,"SingleLFire")
	Goto RightIdle
  Nope:
	RNDT A 0 A_PlaySound("Fleshrend/Dry",4,0.8)
	RNDT ABC 1
	RNDG A 8
    Goto RightIdle
  RightIdle:
	RNDG A 1
	RNDG A 0 A_JumpIfInventory("MacheteGoesFast",1,"SingleCaberToss")
	RNDG A 0 A_JumpIfInventory("FleshRendPickupCounter", 2, "FlashRestart") // Can't believe it was actually this stupidly simple.
	RNDG A 0 A_JumpIfInventory("SynthFireLeft",1,"SingleLFire")
	Loop
  FlashRestart: // The reason both guns fire is because the right gunflash is still checking for the left token! Restart and everything's great.
	TNT1 A 0 A_Gunflash("Dualwelding",GFF_NOEXTCHANGE)
	Stop
  SingleCaberToss:
	RNDG A 1 A_JumpIfInventory("MacheteAmmo",1,1)
	Goto RightIdle
	MCHT A 0 A_TakeInventory("MacheteAmmo",1)
	RNDN CBA 1

    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	TNT1 A 1 A_JumpIf(Health<75,1)
	TNT1 A 1
    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	TNT1 A 1 A_JumpIf(Health<50,1)
	TNT1 A 1
    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	TNT1 A 1 A_JumpIf(Health<25,1)
	TNT1 A 1
    MC4S A 0 A_PlaySound("Machete1/Slash",1,0.9)
    MC4S A 0 A_PlaySound("Machete2/Slash",5,0.2)
	MCHT ABC 1
	TNT1 A 0 A_JumpIfInventory("PowerStrength2",1,3)
	MCHT A 0 A_SpawnItemEX("MacheterangProjectile",cos(-pitch)*48,0,32+(sin(-pitch)*48),cos(-pitch)*35,0,sin(-pitch)*35,0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	TNT1 A 0 A_Jump(256,2)
	MCHT A 0 A_SpawnItemEX("MacheterangBerserkProjectile",cos(-pitch)*48,0,32+(sin(-pitch)*48),cos(-pitch)*25,0,sin(-pitch)*25,0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	// This solution is ten times better. Just let it bouncecount out.
    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	MCHT D 1 A_JumpIf(Health<75,1)
	MCHT E 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	MCHT F 1 A_JumpIf(Health<50,1)
	MCHT G 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	MCHT H 1 A_JumpIf(Health<25,1)
	MCHT I 1
	TNT1 A 3

	RNDN ABC 1
	Goto RightIdle

  Zoom:
    RNDG A 0 A_GiveInventory("SynthFireZoom",1)
    Goto SingleLIdle
  Punch:
    RNDG A 0 A_JumpIfInventory("FleshrendPickupCounter",2,"TwinPunch")
    FMGU F 0 A_PlaySound("Punch/Swing",6,1.0)
	SDKU A 0 A_GiveInventory("ZoomReFire",1)
	QML1 A 0 A_JumpIfInventory("PowerStrength2",1,2)
    QML1 A 0 A_Jump(256,3)
  	FML1 A 0 A_SetBlend("Orange",0.05,10)
	FML1 A 0 A_PlaySound("Melee/Firepunch",0)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<75,2)
	"####" A 1 A_SetPitch(pitch-0.3)
	"####" B 1 A_SetPitch(pitch-0.3)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<50,2)
	"####" C 1 A_SetPitch(pitch-0.3)
	"####" D 1 A_SetPitch(pitch-0.3)
	"####" A 0 A_JumpIfInventory("PowerStrength2",1,3)
	"####" A 0 A_CustomPunch(30, 1, 0, "PunchCracker", 100)
	"####" A 0 A_Jump(256,2)
	"####" A 0 A_CustomPunch(90, 1, 0, "FlamePunchCracker", 150)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<25,2)
	"####" E 1 A_SetPitch(pitch+0.3)
	"####" F 1 A_SetPitch(pitch+0.3)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<75,2)
	"####" G 1 A_SetPitch(pitch+0.3)
	"####" H 1 A_SetPitch(pitch+0.3)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<50,2)
	"####" I 1
	"####" J 1
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<25,2)
	"####" K 1
	TNT1 A 5
	TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWZOOM)
	RN2N A 0 A_TakeInventory("ZoomReFire",1)
    RN2N A 0 A_TakeInventory("SynthFireZoom",1)
	Goto SingleLIdle
  TwinPunch:
    FMGU F 0 A_PlaySound("Punch/Swing",6,1.0)
    FMGU F 0 A_JumpIfInventory("ZoomReFire",1,"PunchFleshAndBlood")
	RN2N CBA 1
	SDKU A 0 A_GiveInventory("ZoomReFire",1)
  PunchFleshAndBlood:
	QML1 A 0 A_JumpIfInventory("PowerStrength2",1,2)
    QML1 A 0 A_Jump(256,3)
  	FML1 A 0 A_SetBlend("Orange",0.05,10)
	FML1 A 0 A_PlaySound("Melee/Firepunch",0)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<75,2)
	"####" A 1 A_SetPitch(pitch-0.3)
	"####" B 1 A_SetPitch(pitch-0.3)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<50,2)
	"####" C 1 A_SetPitch(pitch-0.3)
	"####" D 1 A_SetPitch(pitch-0.3)
	"####" A 0 A_JumpIfInventory("PowerStrength2",1,3)
	"####" A 0 A_CustomPunch(30, 1, 0, "PunchCracker", 100)
	"####" A 0 A_Jump(256,2)
	"####" A 0 A_CustomPunch(90, 1, 0, "FlamePunchCracker", 150)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<25,2)
	"####" E 1 A_SetPitch(pitch+0.3)
	"####" F 1 A_SetPitch(pitch+0.3)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<75,2)
	"####" G 1 A_SetPitch(pitch+0.3)
	"####" H 1 A_SetPitch(pitch+0.3)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<50,2)
	"####" I 1
	"####" J 1
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<25,2)
	"####" K 1
	TNT1 A 5
	TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWZOOM)
	RN2N ABC 1
	RN2N A 0 A_TakeInventory("ZoomReFire",1)
    RN2N A 0 A_TakeInventory("SynthFireZoom",1)
	Goto LIdle

  LFire:
    RNDF A 0 A_JumpIfInventory("ShellsAmmo",2,1)
	Goto LNope
	RNDF A 0 A_PlaySound("Fleshrend/Fire",1,0.7)
	RNDF A 0 A_PlaySound("Fleshrend/Add",5,0.6)
	RNDF A 0 A_FireCustomMissile("GunsmokeSpawner_Medium",0,0,-14,0)
    RNDF A 0 A_FireBullets(8.0, 2.0, 16, 5, "BulletPuff")
	RNDF A 0 A_AlertMonsters
	RNDF A 0 A_Recoil(2)
	RNDF A 0 A_Light2
    RNDF C 1 Bright A_SetPitch(pitch-2.5)
	RNDF D 1 Bright A_SetPitch(pitch-1.25)
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDL A 1 A_JumpIf(Health<75,2)
	RNDL BC 1
	RNDF D 0 A_Light1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDL D 1 A_JumpIf(Health<50,2)
	RNDL EFG 1
	RNDL C 0 A_Light0
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDL H 1 A_JumpIf(Health<25,2)
	RNDL I 1
	RNDL I 0 A_PlaySound("Fleshrend/Out",6,0.6)
	RNDR JJ 0 A_FireCustomMissile("FleshyCasingSpawnerReversed",0,0,-1,2)
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDL J 1 A_JumpIf(Health<75,2)
	RNDL KL 1
	RNDL O 0 A_PlaySound("Fleshrend/In",6,0.5)
	RNDL MNO 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDL P 1 A_JumpIf(Health<50,2)
	RNDL QRST 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDL U 1 A_JumpIf(Health<25,2)
	RNDG B 2
	RNDR A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
	Goto LIdle
  LNope:
	RNDT A 0 A_PlaySound("Fleshrend/Dry",4,0.8)
	RNDT DEF 1
	RNDG B 8
    Goto LIdle
  NullFlash:
    TNT1 A 0
	Stop
  Dualwelding:
    RNDG A 0 A_JumpIfInventory("FleshrendPickupCounter",2,"Ridle")
	TNT1 A 0 A_JumpIfInventory("SynthFireActive",1,1)
	Stop
	TNT1 A 0 A_Light0
	Goto RightIdle
  RIdle:
	RNDG A 1
	RNDG A 0 A_JumpIfInventory("MacheteGoesFast",1,"CaberToss")
	RNDG A 0 A_JumpIfInventory("SynthFireRight",1,"RFire")
    Loop
  RFire:
    RNDF A 0 A_JumpIfInventory("ShellsAmmo",2,1)
	Goto RNope
	RNDF A 0 A_PlaySound("Fleshrend/Fire",1,0.7)
	RNDF A 0 A_PlaySound("Fleshrend/Add",5,0.6)
	RNDF A 0 A_FireCustomMissile("GunsmokeSpawner_Medium",0,0,14,0)
    RNDF A 0 A_FireBullets(8.0, 2.0, 16, 5, "BulletPuff")
	RNDF A 0 A_AlertMonsters
	RNDF A 0 A_Recoil(2)
	RNDF A 0 A_Light2
    RNDF A 1 Bright A_SetPitch(pitch-2.5)
	RNDF B 1 Bright A_SetPitch(pitch-1.25)
	RNDF A 0 A_Light1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR A 1 A_JumpIf(Health<75,2)
	RNDR BC 1
	RNDR C 0 A_Light0
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR D 1 A_JumpIf(Health<50,2)
	RNDR EFG 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR H 1 A_JumpIf(Health<25,2)
	RNDR I 1
	RNDR I 0 A_PlaySound("Fleshrend/Out",4,0.6)
	RNDR JJ 0 A_FireCustomMissile("FleshyCasingSpawner",0,0,-1,2)
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR J 1 A_JumpIf(Health<75,2)
	RNDR KL 1
	RNDR O 0 A_PlaySound("Fleshrend/In",4,0.5)
	RNDR MNO 1 
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR P 1 A_JumpIf(Health<50,2)
	RNDR QRST 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	RNDR U 1 A_JumpIf(Health<25,2)
	RNDG A 2
	RNDL A 0 A_JumpIfInventory("SynthFireRight",1,"RFire")
	Goto RIdle
  RNope:
	RNDT D 0 A_PlaySound("Fleshrend/Dry",4,0.8)
	RNDT ABC 1
	RNDG A 8
    Goto RIdle
  AltFire:
	Stop
  CaberToss:
  	RNDG A 1 A_JumpIfInventory("MacheteAmmo",1,1)
	Goto RIdle
	MCHT A 0 A_TakeInventory("MacheteAmmo",1)
	RNDN CBA 1

    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	TNT1 A 1 A_JumpIf(Health<75,1)
	TNT1 A 1
    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	TNT1 A 1 A_JumpIf(Health<50,1)
	TNT1 A 1
    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	TNT1 A 1 A_JumpIf(Health<25,1)
	TNT1 A 1
    MC4S A 0 A_PlaySound("Machete1/Slash",1,0.9)
    MC4S A 0 A_PlaySound("Machete2/Slash",5,0.2)
	MCHT ABC 1
	TNT1 A 0 A_JumpIfInventory("PowerStrength2",1,3)
	MCHT A 0 A_SpawnItemEX("MacheterangProjectile",cos(-pitch)*48,0,32+(sin(-pitch)*48),cos(-pitch)*35,0,sin(-pitch)*35,0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	TNT1 A 0 A_Jump(256,2)
	MCHT A 0 A_SpawnItemEX("MacheterangBerserkProjectile",cos(-pitch)*48,0,32+(sin(-pitch)*48),cos(-pitch)*25,0,sin(-pitch)*25,0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	// This solution is ten times better. Just let it bouncecount out.
    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	MCHT D 1 A_JumpIf(Health<75,1)
	MCHT E 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	MCHT F 1 A_JumpIf(Health<50,1)
	MCHT G 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	MCHT H 1 A_JumpIf(Health<25,1)
	MCHT I 1
	TNT1 A 3

	RNDN ABC 1
	Goto RIdle
  Spawn:
    RNDG X -1
    Stop
  }
}
ACTOR FleshrendPickupCounter : Inventory
{
Inventory.Icon "TNT1A0"
Inventory.MaxAmount 2
Inventory.Amount 1
-INVBAR
States
{
RNDG X -1
Stop
}
}