ACTOR PulverizerLoaded : Inventory {Inventory.MaxAmount 1}

//---------------------------------------------//
// Pulverizer AMMO: PRIMARY
//---------------------------------------------//

ACTOR PulvPrimary : Ammo
{
  Inventory.Amount 1
  Inventory.MaxAmount 9
  Ammo.BackpackAmount 0
  Ammo.BackpackMaxAmount 9
  Inventory.Icon "SHELA0"
}

//---------------------------------------------//
// Pulverizer AMMO: SECONDARY
//---------------------------------------------//

ACTOR PulvSecondary : Ammo
{
  Inventory.Amount 1
  Inventory.MaxAmount 15
  Ammo.BackpackAmount 5
  Ammo.BackpackMaxAmount 15
  Inventory.Icon "SHELA0"
}

ACTOR Pulverizer : Weapon
{
  +WEAPON.NOAUTOAIM
  Weapon.Kickback 100
  Obituary "%k smashed %o's ribcage open with the Pulverizer."
  Tag "Pulverizer"
  +WEAPON.AMMO_OPTIONAL
  Weapon.AmmoType "PulvPrimary"
  Weapon.AmmoType2 "PulvSecondary"
  Weapon.AmmoUse 0
  Weapon.AmmoUse2 0
  Weapon.AmmoGive2 10
  +WEAPON.NOALERT
  Weapon.BobStyle Smooth
  Weapon.BobSpeed 2.5
  Weapon.BobRangeX 0.5
  Weapon.BobRangeY 0.3
  States
  {
  Ready:
    PPSS A 0 A_JumpIfInventory("IsReloading",1,"ReloadCheck")
	PPSS A 0 A_JumpIfInventory("PendingQuickness",1,"ToQuick")
	PPSS A 0 A_JumpIfInventory("DoBlocking",1,"DoParry")
    PULI A 1 A_WeaponReady
    Goto Ready
  DoParry:
	TNT1 A 0 A_TakeInventory("DoBlocking",1)
	TNT1 A 0 A_PlaySoundEx("cloth/knife","SoundSlot5")
	KATB AB 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	KATB C 0 A_ZoomFactor(0.995)
	KATB C 1 A_GiveInventory("IsParrying",1)
	KATB C 0 A_ZoomFactor(0.98)
	KATB D 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	KATB C 0 A_ZoomFactor(0.97)
	KATB E 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	KATB C 0 A_ZoomFactor(0.96)
	KATB F 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	KATB C 0 A_ZoomFactor(0.955)
	KATB G 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	KATB C 0 A_ZoomFactor(0.96)
	KATB H 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	KATB E 0 A_TakeInventory("IsParrying",1)
	KATB C 0 A_ZoomFactor(0.97)
	KATB I 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	KATB C 0 A_ZoomFactor(0.98)
	KATB J 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	KATB K 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	Goto Ready
  ToQuick:
	TNT1 A 0 ACS_NamedExecute("ProcessQuick",0,0,0,0)
	GoTo Ready+2
  Deselect:
	 PULI BCDE 1
     TNT1 AAAAAAAAAA 0 A_Lower
	 TNT1 A 1 A_Lower
     Goto Deselect+4
  Select:
	 TNT1 A 0 A_SetCrosshair(16)
	 TNT1 AA 0 A_Raise
	 TNT1 A 1 A_WeaponReady
	 TNT1 A 0 A_PlaySoundEx("cloth/melee","SoundSlot6")
	 Goto SelectAnim
  SelectAnim:
	 KATS A 0 A_PlaySoundEx("pulv/pullout","SoundSlot6")
	 PULS ABCDEFGHIJKLM 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 Goto Ready
  QuickSelect:
	 PULI EDCB 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	 Goto Ready
  Fire:
	PUNG A 0 A_TakeInventory("PulverizerLoaded",1)
	PUNG A 0 A_TakeInventory("HitSomething",1)
	PULI A 0 A_PlaySoundEx("cloth/default","SoundSlot5")
	PULI ABCDE 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	PUNG A 0 A_JumpIf(0 == (ACS_ExecuteWithResult(559,0,0,0)), "SwingLeft")
	PUNG A 0 A_JumpIf(1 == (ACS_ExecuteWithResult(559,0,0,0)), "SwingRight")
	//PUNG A 0 A_JumpIf(2 == (ACS_ExecuteWithResult(559,0,0,0)), "SlashDown")
	Goto AutoLeft
  AltFire:
	PUNG A 0 A_GiveInventory("PulverizerLoaded",1)
	PUNG A 0 A_TakeInventory("HitSomething",1)
	PULI A 0 A_PlaySoundEx("cloth/default","SoundSlot5")
	PULI ABCDE 1 A_WeaponReady(WRF_NOFIRE | WRF_NOSWITCH)
	PUNG A 0 A_JumpIf(0 == (ACS_ExecuteWithResult(559,0,0,0)), "SwingLeft")
	PUNG A 0 A_JumpIf(1 == (ACS_ExecuteWithResult(559,0,0,0)), "SwingRight")
	//PUNG A 0 A_JumpIf(2 == (ACS_ExecuteWithResult(559,0,0,0)), "SlashDown")
	Goto AutoLeft
  AutoLeft:
	TNT1 A 0 A_JumpIfInventory("SwungLeft",1,"AutoRight")
	TNT1 A 0 A_GiveInventory("SwungLeft",1)
	Goto SwingLeft
  AutoRight:
	TNT1 A 0 A_TakeInventory("SwungLeft",1)
	Goto SwingRight
  SwingLeftHard:
	KATA A 0 A_PlaySoundEx("pulv/swingheavy","Weapon")
	Goto SwingLeft+6
  SwingRightHard:
	KATA A 0 A_PlaySoundEx("pulv/swingheavy","Weapon")
	Goto SwingRight+6
  SwingLeft:
	PUSL ABCD 1
	PUSL A 0 A_JumpIfInventory("PulverizerLoaded",1,"SwingLeftHard")
	KATA A 0 A_PlaySoundEx("pulv/swinglight","Weapon")
	PUSL EFGH 1
	TNT1 A 0 A_JumpIfInventory("PulverizerLoaded",1,"SwingLeftSmasher")
  SwingLeftNormal:
	MBBA A 0 A_CustomPunch(50, FALSE, 0, "PulverizerImpacter", 90)
	Goto SwingLeftEnd
  SwingLeftSmasher:
	TNT1 A 0 A_JumpIfInventory("PulvPrimary",1,3)
	MBBA A 0 A_CustomPunch(100, FALSE, 0, "PulverizerImpacter", 90)
	Goto SwingLeftEnd
	TNT1 AAA 0
	MCFI H 0 A_FireCustomMissile("PulverizerPuff",0,0,0,-2)
	MBBA A 0 A_CustomPunch(0.2, FALSE, 0, "PulverizerImpacter", 90)
	Goto SwingLeftEnd
  SwingLeftEnd:
	PUSL IJKLM 1 A_JumpIfInventory("HitSomething",1,"InterceptLeft")
	TNT1 A 2
	TNT1 A 0 A_ReFire("AutoLeft")
	Goto QuickSelect
  SwingRight:
	PUSR ABCD 1
	PUSL A 0 A_JumpIfInventory("PulverizerLoaded",1,"SwingRightHard")
	KATA A 0 A_PlaySoundEx("pulv/swinglight","Weapon")
	PUSR EFGH 1
	TNT1 A 0 A_JumpIfInventory("PulverizerLoaded",1,"SwingRightSmasher")
  SwingRightNormal:
    MBBA A 0 A_CustomPunch(50, FALSE, 0, "PulverizerImpacter", 90)
	Goto SwingRightEnd
  SwingRightSmasher:
	TNT1 A 0 A_JumpIfInventory("PulvPrimary",1,3)
	MBBA A 0 A_CustomPunch(100, FALSE, 0, "PulverizerImpacter", 90)
	Goto SwingRightEnd
	TNT1 AAA 0
	MCFI H 0 A_FireCustomMissile("PulverizerPuff",0,0,0,-2)
	MBBA A 0 A_CustomPunch(0.2, FALSE, 0, "PulverizerImpacter", 90)
	Goto SwingRightEnd
  SwingRightEnd:
	PUSR IJKLM 1 A_JumpIfInventory("HitSomething",1,"InterceptRight")
	TNT1 A 2
	TNT1 A 0 A_ReFire("AutoLeft")
	Goto QuickSelect
  InterceptLeft:
	PUIL A 0 A_TakeInventory("PulvPrimary",1)
	PUIL A 0 A_Recoil(2)
	PUIL A 0 A_CustomMissile("ShakeYourAssDouble")
	PUIL C 1 A_SetAngle(angle-9)
	PUIL A 0 A_SetPitch(pitch-2.0)
	PUIL D 1 A_SetAngle(angle-4)
	PUIL A 0 A_SetPitch(pitch-1.0)
	PUIL E 1 A_SetAngle(angle-1)
	PUIL A 0 A_SetPitch(pitch-0.5)
	PUIL F 1 A_SetAngle(angle-0.5)
	PUIL G 1 A_SetAngle(angle+0.1)
	TNT1 A 1 A_SetAngle(angle+0.25)
	TNT1 A 1 A_SetAngle(angle+0.5)
	TNT1 A 1 A_SetAngle(angle+0.8)
	Goto HandleRetract
  InterceptRight:
	PUIL A 0 A_TakeInventory("PulvPrimary",1)
	PUIL A 0 A_Recoil(2)
    PUIL A 0 A_CustomMissile("ShakeYourAssDouble")
	PUIR C 1 A_SetAngle(angle+9)
	PUIL A 0 A_SetPitch(pitch-2.0)
	PUIR D 1 A_SetAngle(angle+4)
	PUIL A 0 A_SetPitch(pitch-1.0)
	PUIR E 1 A_SetAngle(angle+1)
	PUIL A 0 A_SetPitch(pitch-0.5)
	PUIR F 1 A_SetAngle(angle+0.5)
	PUIR G 1 A_SetAngle(angle-0.1)
	TNT1 A 1 A_SetAngle(angle-0.25)
	TNT1 A 1 A_SetAngle(angle-0.5)
	TNT1 A 1 A_SetAngle(angle-0.8)
	Goto HandleRetract
  HandleRetract:
	PURL ABCDEFGH 1 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
	PURL I 0 A_PlaySoundEx("pulv/handledown","SoundSlot6")
	PURL IJKLMNOPQRS 1 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
	Goto QuickSelect
	
  //=================================================================================
  // AMMO CHECKING
  //=================================================================================
  ReloadCheck:
	 TNT1 A 0 A_TakeInventory("IsReloading",1)
	 TNT1 A 0 A_JumpIfInventory("Perk_Demo",1,"RCP")
	 TNT1 A 0 A_JumpIfInventory("PulvPrimary",5,"Ready")
	 TNT1 A 0 A_JumpIfInventory("PulvSecondary",1,"ReloadAnim")
	 Goto Ready
  RCP:
	 TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"RCP10")
	 TNT1 A 0 A_JumpIfInventory("PulvPrimary",7,"Ready")
	 TNT1 A 0 A_JumpIfInventory("PulvSecondary",1,"ReloadAnim")
	 Goto Ready
  RCP10:
	 TNT1 A 0 A_JumpIfInventory("PulvPrimary",9,"Ready")
	 TNT1 A 0 A_JumpIfInventory("PulvSecondary",1,"ReloadAnim")
	 Goto Ready
  //=================================================================================
  
  
  ReloadAnim:
	 //TNT1 A 0 A_JumpIfInventory("Perk_Commando",1,"ReloadAnimFast")
	 PURM ABCDEFGHI 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 PPRL G 0 A_PlaySoundEx("pulv/handledown","SoundSlot6")
	 PURM JKLMNOPQRSTUVWXYZ 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 PURN A 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 PURN B 0 A_PlaySoundEx("pulv/magout","SoundSlot5")
	 PURN BCDEFGHHIIIJK 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 PURN K 0 A_PlaySoundEx("pulv/magin","SoundSlot6")
	 Goto CalculateAmmo
	 
  //=================================================================================
  // AMMO CALCULATION
  //=================================================================================
  CalculateAmmo:
	 TNT1 A 0 A_JumpIfInventory("Perk_Demo",1,"CalculateAmmoPerk")
     TNT1 A 0 A_JumpIfInventory("PulvSecondary",1,2)
	 Goto ReloadEnd
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("PulvPrimary",5,"ReloadEnd")
	 TNT1 A 0 A_TakeInventory("PulvSecondary",1)
	 TNT1 A 0 A_GiveInventory("PulvPrimary",1)
	 Loop
  CalculateAmmoPerk:
     TNT1 A 0 A_JumpIfInventory("PerkLevel",10,"CalculateAmmoPerk10")
     TNT1 A 0 A_JumpIfInventory("PulvSecondary",1,2)
	 Goto ReloadEnd
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("PulvPrimary",7,"ReloadEnd")
	 TNT1 A 0 A_TakeInventory("PulvSecondary",1)
	 TNT1 A 0 A_GiveInventory("PulvPrimary",1)
	 Loop
  CalculateAmmoPerk10:
     TNT1 A 0 A_JumpIfInventory("PPSHSecondary",1,2)
	 Goto ReloadEnd
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("PPSHPrimary",9,"ReloadEnd")
	 TNT1 A 0 A_TakeInventory("PPSHSecondary",1)
	 TNT1 A 0 A_GiveInventory("PPSHPrimary",1)
	 Loop
  //=================================================================================
	 
   ReloadEnd:
	 //TNT1 A 0 A_JumpIfInventory("Perk_Commando",1,"ReloadEndFast")
	 PURN LMNOPQRSTUVWX 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 PURN K 0 A_PlaySoundEx("pulv/handleup","SoundSlot5")
	 PURN YZ 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 PURO ABCDEFGH 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 PPRL A 0 A_TakeInventory("IsReloading",1)
	 Goto QuickSelect
  }
}