#include "Decorate/Guns/Projectile/Cauterizer.txt"

ACTOR CauterizerSelected : Inventory { Inventory.MaxAmount 1 }

ACTOR Cauterizer : GuncasterWeapon replaces Skullrod
{
   Inventory.PickupSound "Guncaster/Laugh1"
   Inventory.PickupMessage "$GOTCAUTERIZER"
   Obituary "$KILLCAUTERIZER"
   Weapon.UpSound "Cauterizer/Up" 
   Weapon.SelectionOrder 5
   Weapon.AmmoGive 4
   Weapon.AmmoType "CauterizerAmmo"
   Weapon.AmmoUse 1
   Weapon.SlotNumber 6
   Weapon.BobStyle InverseSmooth
   Weapon.BobSpeed 1.8
   Weapon.BobRangeY 0.7
   Weapon.BobRangeX 0.9
   +NOALERT
   States
   {
   Spawn:
      CAUG X -1
      Stop
   Ready:
   	  CCUG A 0 A_JumpIfInventory("PowerSuitToken",1,2)
	  CAUG A 0
      "####" A 0 A_JumpIf(CallACS("GunslingerMode"), "ZweiReady")
      "####" A 0 A_JumpIfInventory("PowerGunzerking",1,"ZweiReady")
      "####" A 1 A_WeaponReady(WRF_ALLOWZOOM|WRF_ALLOWRELOAD)
      Loop
   DeselectMain:
   	  CCUG A 0 A_JumpIfInventory("PowerSuitToken",1,2)
	  CAUG A 0
      "####" A 0 A_TakeInventory("CauterizerSelected")
      "####" A 0 A_JumpIf(CallACS("GunslingerMode"), "ZweiDeselect")
      "####" A 0 A_JumpIfInventory("PowerGunzerking",1,"ZweiDeselect")
      "####" A 1 A_Lower
      "####" A 0 A_Lower
      Loop
   Select:
   	  CCUG A 0 A_JumpIfInventory("PowerSuitToken",1,2)
	  CAUG A 0
      "####" A 0 A_GiveInventory("CauterizerSelected")
      "####" A 0 A_JumpIf(CallACS("GunslingerMode"), "ZweiSelect")
      "####" A 0 A_JumpIfInventory("PowerGunzerking",1,"ZweiSelect")
      "####" A 1 A_Raise
      Loop  
   Fire:
      CCUF A 0 A_JumpIfInventory("PowerSuitToken",1,2)
	  CAUF A 0
      "####" A 0 A_PlaySound("Cauterizer/Fire",1,0.5)
      "####" A 0 A_PlaySound("Cauterizer/Add",0,0.7)
      "####" A 0 A_SetBlend("Cyan",0.1,8)
      //"####" A 0 A_Recoil(7)
      "####" A 0 A_AlertMonsters
      "####" A 0 A_Quake (4, 9, 0, 3, none)
      "####" A 0 A_FireCustomMissile("Thunderball",0,1,6,-8)
      "####" A 0 A_SetPitch(pitch-0.5)
      "####" A 0 A_SetAngle(angle-0.5)
      "####" A 1 Bright A_ZoomFactor(0.99)
      "####" A 0 A_SetPitch(pitch-1)
      "####" A 0 A_SetAngle(angle-1)
      "####" B 1 Bright A_ZoomFactor(0.97)
      "####" A 0 A_SetPitch(pitch-1.5)
      "####" A 0 A_SetAngle(angle-1.5)
      CCUT A 0 A_JumpIfInventory("PowerSuitToken",1,2)
	  CAUT A 0
      "####" A 1 A_ZoomFactor(0.96)
      "####" A 0 A_SetPitch(pitch-1.5)
      "####" A 0 A_SetAngle(angle-1.5)
      "####" B 1 A_ZoomFactor(0.94)
      "####" A 0 A_SetPitch(pitch-0.5)
      "####" A 0 A_SetAngle(angle-0.5)
      "####" C 1 A_ZoomFactor(0.92)
      "####" A 0 A_SetPitch(pitch+0.5)
      "####" A 0 A_SetAngle(angle+0.5)
      "####" D 1 A_ZoomFactor(0.91)
      "####" A 0 A_SetPitch(pitch+0.5)
      "####" A 0 A_SetAngle(angle+0.5)
      "####" E 1 A_ZoomFactor(0.905)
      "####" A 0 A_SetPitch(pitch+0.5)
      "####" A 0 A_SetAngle(angle+0.5)
	  "####" F 1 A_ZoomFactor(0.92)
      "####" A 0 A_SetPitch(pitch+0.5)
      "####" A 0 A_SetAngle(angle+0.5)
	  "####" G 1 A_ZoomFactor(0.93)
      "####" A 0 A_SetPitch(pitch+0.5)
      "####" A 0 A_SetAngle(angle+0.5)
	  "####" H 1 A_ZoomFactor(0.94)
      "####" A 0 A_SetPitch(pitch+0.5)
      "####" A 0 A_SetAngle(angle+0.5)
	  "####" I 1 A_ZoomFactor(0.95)
      "####" A 0 A_SetPitch(pitch+0.5)
      "####" A 0 A_SetAngle(angle+0.5)
	  "####" J 1 A_ZoomFactor(0.96)
      "####" A 0 A_SetPitch(pitch+0.25)
      "####" A 0 A_SetAngle(angle+0.25)
	  "####" K 1 A_ZoomFactor(0.97)
      "####" A 0 A_SetPitch(pitch+0.25)
      "####" A 0 A_SetAngle(angle+0.25)
	  "####" L 1 A_ZoomFactor(0.98)
      "####" A 0 A_SetPitch(pitch+0.25)
      "####" A 0 A_SetAngle(angle+0.25)
	  "####" M 1 A_ZoomFactor(0.99)
      "####" A 0 A_SetPitch(pitch+0.25)
      "####" A 0 A_SetAngle(angle+0.25)
      CCUG A 0 A_JumpIfInventory("PowerSuitToken",1,2)
	  CAUG A 0
	  "####" A 7 A_ZoomFactor(1)
	  "####" A 0 A_ReFire
      Goto Ready
	  
	AltFire:
      CCUM A 0 A_JumpIfInventory("PowerSuitToken",1,2)
      CAUM A 0
	  "####" A 0
	  Goto Super::CheckForMagic
	  
	Zoom:
      "####" A 0 A_JumpIf(CallACS("GunslingerMode"),"Gunzerk")
	  "####" A 0 A_JumpIfInventory("PowerGunzerking",1,"Gunzerk")
	  Goto Regular
	Regular:
	  "####" A 0 A_JumpIfInventory("PowerMidasMode",1,4)
	  CCUK A 0 A_JumpIfInventory("PowerSuitToken",1,2)
	  CAUK A 0
	  "####" A 0
	  Goto Super::Zoom
	  CCUK A 0 A_JumpIfInventory("PowerSuitToken",1,2)
	  CAMK A 0
	  "####" A 0
	  Goto Super::Zoom
	  
	Gunzerk:
	  "####" A 0 A_JumpIfInventory("PowerMidasMode",1,4)
	  1CUK A 0 A_JumpIfInventory("PowerSuitToken",1,2)
	  1AUK A 0
	  "####" A 0
	  Goto Super::Zoom
	  1CUK A 0 A_JumpIfInventory("PowerSuitToken",1,2)
	  1AMK A 0
	  "####" A 0
	  Goto Super::Zoom
	  
	  
	//Zweihander

   ZweiSelect:
      3AUG A 1 A_Raise
      Loop
   ZweiDeselect:
	  TNT1 A 0 A_GunFlash("Nullify",GFF_NOEXTCHANGE)
	  TNT1 A 0 A_TakeInventory("SynthFireActive",1)
	  TNT1 A 0 A_TakeInventory("SynthFireLeft",1)
	  TNT1 A 0 A_TakeInventory("SynthFireRight",1)
   Zweihander:
	  3AUG A 0 A_Lower
	  3AUG A 1 A_Lower
	  Loop
   ZweiReady:
	  3AUG A 0 A_GiveInventory("SynthFireActive",1)
	  3AUG A 0 ACS_NamedExecuteAlways("SynthLeft")
	  3AUG A 0 ACS_NamedExecuteAlways("SynthRight")
	  3AUG A 0 A_Gunflash("Flash",GFF_NOEXTCHANGE)
	  Goto RIdle

   //Right
   
   RIdle:
	  1AUG A 0 A_JumpIfInventory("SynthFireRight",1,"RFire")
	  1AUG A 1 A_WeaponReady(WRF_NOFIRE|WRF_ALLOWZOOM)
      TNT1 A 0 A_JumpIf(CallACS("GunslingerMode"), "RIdle")
	  1AUG A 0 A_JumpIfInventory("PowerGunzerking",1,"RIdle") 
	  Goto BackToReady
   BackToReady:
	  1AUG A 0 A_GunFlash("Nullify",GFF_NOEXTCHANGE)
	  Goto Ready
   RFire:
      TNT1 A 0 A_JumpIf(CallACS("GunslingerMode"),2)
	  1AUG A 0 A_JumpIfInventory("PowerGunzerking",1,1) 
	  Goto BackToReady
	  1AUG A 0 A_JumpIfInventory("HexenCounter",1,"HexenR")
	  1AUG A 1 A_JumpIfInventory("CauterizerAmmo",1,"RConfirmed")
	  Goto RIdle
   HexenR:
	  1AUG A 1 A_JumpIfInventory("GreenMana",3,1)
      Goto RIdle
   RConfirmed:
      1AUF A 0 A_PlaySound("Cauterizer/Fire",1,0.5)
      1AUF A 0 A_PlaySound("Cauterizer/Add",0,0.7)
      1AUF A 0 A_SetBlend("Cyan",0.1,8)
      //1AUF A 0 A_Recoil(3.5)
      1AUF A 0 A_AlertMonsters
      1AUF A 0 A_Quake (4, 9, 0, 3, none)
      1AUF A 0 A_FireCustomMissile("Thunderball",0,1,8,-8)
      //1AUF A 0 A_TakeInventory("CauterizerAmmo",1,TIF_NOTAKEINFINITE)
      1AUF A 0 A_SetPitch(pitch-0.25)
      1AUF A 0 A_SetAngle(angle-0.25)
      1AUF A 1 Bright A_ZoomFactor(0.99)
      1AUF A 0 A_SetPitch(pitch-0.5)
      1AUF A 0 A_SetAngle(angle-0.5)
      1AUF B 1 Bright A_ZoomFactor(0.97)
      1AUF A 0 A_SetPitch(pitch-0.75)
      1AUF A 0 A_SetAngle(angle-0.75)
      1AUT A 1 A_ZoomFactor(0.96)
      1AUF A 0 A_SetPitch(pitch-0.75)
      1AUF A 0 A_SetAngle(angle-0.75)
      1AUT B 1 A_ZoomFactor(0.94)
      1AUF A 0 A_SetPitch(pitch-0.25)
      1AUF A 0 A_SetAngle(angle-0.25)
      1AUT C 1 A_ZoomFactor(0.92)
      1AUF A 0 A_SetPitch(pitch+0.25)
      1AUF A 0 A_SetAngle(angle+0.25)
      1AUT D 1 A_ZoomFactor(0.91)
      1AUF A 0 A_SetPitch(pitch+0.25)
      1AUF A 0 A_SetAngle(angle+0.25)
      1AUT E 1 A_ZoomFactor(0.905)
      1AUF A 0 A_SetPitch(pitch+0.25)
      1AUF A 0 A_SetAngle(angle+0.25)
	  1AUT F 1 A_ZoomFactor(0.92)
      1AUF A 0 A_SetPitch(pitch+0.25)
      1AUF A 0 A_SetAngle(angle+0.25)
	  1AUT G 1 A_ZoomFactor(0.93)
      1AUF A 0 A_SetPitch(pitch+0.25)
      1AUF A 0 A_SetAngle(angle+0.25)
	  1AUT H 1 A_ZoomFactor(0.94)
      1AUF A 0 A_SetPitch(pitch+0.25)
      1AUF A 0 A_SetAngle(angle+0.25)
	  1AUT I 1 A_ZoomFactor(0.95)
      1AUF A 0 A_SetPitch(pitch+0.25)
      1AUF A 0 A_SetAngle(angle+0.25)
	  1AUT J 1 A_ZoomFactor(0.96)
      1AUF A 0 A_SetPitch(pitch+0.125)
      1AUF A 0 A_SetAngle(angle+0.125)
	  1AUT K 1 A_ZoomFactor(0.97)
      1AUF A 0 A_SetPitch(pitch+0.125)
      1AUF A 0 A_SetAngle(angle+0.125)
	  1AUT L 1 A_ZoomFactor(0.98)
      1AUF A 0 A_SetPitch(pitch+0.125)
      1AUF A 0 A_SetAngle(angle+0.125)
	  1AUT M 1 A_ZoomFactor(0.99)
      1AUF A 0 A_SetPitch(pitch+0.125)
      1AUF A 0 A_SetAngle(angle+0.125)
	  1AUG A 7 A_ZoomFactor(1)
	  1AUG A 0 A_JumpIfInventory("SynthFireRight",1,"RFire")
	  Goto RIdle
	  
   //Left
   
   Nullify:
	  TNT1 A 0
	  Stop
   Flash:
	  TNT1 A 0 A_Light0
   LIdle:
	  2AUG A 1 A_JumpIfInventory("SynthFireLeft",1,"LFire")
	  Loop
   LFire:
      TNT1 A 0 A_JumpIf(CallACS("GunslingerMode"),2)
	  2AUG A 0 A_JumpIfInventory("PowerGunzerking",1,1) 
	  Goto BackToReady
	  2AUG A 0 A_JumpIfInventory("HexenCounter",1,"HexenL")
	  2AUG A 1 A_JumpIfInventory("CauterizerAmmo",1,"LConfirmed")
	  Goto RIdle
   HexenL:
	  2AUG A 1 A_JumpIfInventory("GreenMana",3,1)
      Goto RIdle
   LConfirmed:
      2AUF A 0 A_PlaySound("Cauterizer/Fire",1,0.5)
      2AUF A 0 A_PlaySound("Cauterizer/Add",0,0.7)
      2AUF A 0 A_SetBlend("Cyan",0.1,8)
      //2AUF A 0 A_Recoil(3.5)
      2AUF A 0 A_AlertMonsters
      2AUF A 0 A_Quake (4, 9, 0, 3, none)
      2AUF A 0 A_FireCustomMissile("Thunderball",0,1,-8,-8)
      //2AUF A 0 A_TakeInventory("CauterizerAmmo",1,TIF_NOTAKEINFINITE)
      2AUF A 0 A_SetPitch(pitch-0.25)
      2AUF A 0 A_SetAngle(angle-0.25)
      2AUF A 1 Bright A_ZoomFactor(0.99)
      2AUF A 0 A_SetPitch(pitch-0.5)
      2AUF A 0 A_SetAngle(angle-0.5)
      2AUF B 1 Bright A_ZoomFactor(0.97)
      2AUF A 0 A_SetPitch(pitch-0.75)
      2AUF A 0 A_SetAngle(angle-0.75)
      2AUT A 1 A_ZoomFactor(0.96)
      2AUF A 0 A_SetPitch(pitch-0.75)
      2AUF A 0 A_SetAngle(angle-0.75)
      2AUT B 1 A_ZoomFactor(0.94)
      2AUF A 0 A_SetPitch(pitch-0.25)
      2AUF A 0 A_SetAngle(angle-0.25)
      2AUT C 1 A_ZoomFactor(0.92)
      2AUF A 0 A_SetPitch(pitch+0.25)
      2AUF A 0 A_SetAngle(angle+0.25)
      2AUT D 1 A_ZoomFactor(0.91)
      2AUF A 0 A_SetPitch(pitch+0.25)
      2AUF A 0 A_SetAngle(angle+0.25)
      2AUT E 1 A_ZoomFactor(0.905)
      2AUF A 0 A_SetPitch(pitch+0.25)
      2AUF A 0 A_SetAngle(angle+0.25)
	  2AUT F 1 A_ZoomFactor(0.92)
      2AUF A 0 A_SetPitch(pitch+0.25)
      2AUF A 0 A_SetAngle(angle+0.25)
	  2AUT G 1 A_ZoomFactor(0.93)
      2AUF A 0 A_SetPitch(pitch+0.25)
      2AUF A 0 A_SetAngle(angle+0.25)
	  2AUT H 1 A_ZoomFactor(0.94)
      2AUF A 0 A_SetPitch(pitch+0.25)
      2AUF A 0 A_SetAngle(angle+0.25)
	  2AUT I 1 A_ZoomFactor(0.95)
      2AUF A 0 A_SetPitch(pitch+0.25)
      2AUF A 0 A_SetAngle(angle+0.25)
	  2AUT J 1 A_ZoomFactor(0.96)
      2AUF A 0 A_SetPitch(pitch+0.125)
      2AUF A 0 A_SetAngle(angle+0.125)
	  2AUT K 1 A_ZoomFactor(0.97)
      2AUF A 0 A_SetPitch(pitch+0.125)
      2AUF A 0 A_SetAngle(angle+0.125)
	  2AUT L 1 A_ZoomFactor(0.98)
      2AUF A 0 A_SetPitch(pitch+0.125)
      2AUF A 0 A_SetAngle(angle+0.125)
	  2AUT M 1 A_ZoomFactor(0.99)
      2AUF A 0 A_SetPitch(pitch+0.125)
      2AUF A 0 A_SetAngle(angle+0.125)
	  2AUG A 7 A_ZoomFactor(1)
	  2AUG A 0 A_JumpIfInventory("SynthFireLeft",1,"LFire")
	  Goto LIdle
	}
}