ACTOR TriShotAcid
{
  Radius 13
  Height 8
  Speed 35
  Damage 20
  Projectile
  +RANDOMIZE
  -NOGRAVITY
  Gravity 0.75
  RenderStyle Add
  Alpha 0.9
  Scale 0.25
  Decal "AcidSplashSmall"
  Obituary "%o was dissolved." // "%o was melted by %k's plasma gun."
  States
  {
  Spawn:
	TRSP A 0
	TRSP A 0 A_PlaySoundEx("acid/loop","Body",true)
  Flying:
	TRSP S 1 bright A_SpawnItemEx("PukeFXSmall",0,0,0)
	Loop
  Death:
	VOMT A 0 A_StopSoundEx("Body")
	VOMT A 0 A_PlaySoundEx("acid/splash","Body")
	CRFX C 0// A_SpawnItemEx("CranusBallExplodeFX",0,0,0)
	TNT1 A 1
    Stop
  }
}

ACTOR PukeFXSmall
{
	+NOBLOCKMAP
	+CLIENTSIDEONLY
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 AAAA 0 A_SpawnItemEx("PukePuffSmall",random(-1,1),random(-1,1),random(-1,1),0,random(-2,2),random(-2,2))
	Stop
	}
}

ACTOR PukePuffSmall
{
	+NOBLOCKMAP
	+CLIENTSIDEONLY
	Renderstyle Add
	Alpha 0.9
	Scale 0.15
	States
	{
	Spawn:
	VOMT CCCCCCCCCC 1 A_FadeOut(0.1)
	Stop
	}
}

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

ACTOR TriShotSecondary : Ammo
{
  Inventory.Amount 1
  Inventory.MaxAmount 60
  Ammo.BackpackAmount 6
  Ammo.BackpackMaxAmount 60
  Inventory.Icon "SHELA0"
}

ACTOR "Acid Tri-Shot" : Weapon
{
  Weapon.SelectionOrder 1300
  Weapon.AmmoUse 0
  Weapon.AmmoGive2 12
  Weapon.AmmoType "TriShotPrimary"
  Weapon.AmmoType2 "TriShotSecondary"
  Inventory.PickupMessage "You got the Caustic Triad."
  Obituary "%o was dissolved by %k's Caustic Triad."
  Tag "Caustic Triad"
  +WEAPON.AMMO_OPTIONAL
  States
  {
  Ready:
    TRSI A 1 A_WeaponReady
    Loop
  Deselect:
	TRDS DCBA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto Deselecting
  Deselecting:
	TNT1 AAAAAAAAAAAAAAA 0 A_Lower
    TNT1 A 1 A_Lower
    Loop
  Select:
	TNT1 A 0 A_Raise
	TNT1 A 1 A_WeaponReady
	Goto SelectAnim
  SelectAnim:
    TRSS ABCDEF 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
    Goto Ready
  Fire:
	SHTG A 0 A_JumpIfInventory("TriShotPrimary",3,"FireAll3")
	// We don't have 3 shells in the chamber so fire sub-par
	SHTG A 0 A_JumpIfInventory("TriShotPrimary",2,"FireSub2")
	SHTG A 0 A_JumpIfInventory("TriShotPrimary",1,"FireSub1")
	Goto ReloadCheck
	
	/*
  AltFire:
	SHTG A 0 A_JumpIfInventory("TriShotPrimary",3,1)
	Goto Ready
	PPFI AAAAAAAAAA 0 A_FireCustomMissile("TriShotAcid",random(-5,5),0,0,0,0,random(-5,5))
	PPFI A 0 A_PlaySound("trishot/firehuge", CHAN_WEAPON)
	PPFI A 0 A_FireCustomMissile("ShakeYourAss",0,0)
	PPFI A 0 A_FireCustomMissile("SplayerMuzzleFX",0,0,8)
	PPFI A 0 A_TakeInventory("TriShotPrimary",3)
	PPFI A 0 A_Recoil(4)
	Goto FireAnimFull
	*/
	
  FireAll3:
	// Acid probably shouldn't gib enemies
	// PPFI A 0 A_FireBullets (0, 0, 3, 17, "BP_TorsoGib",0,90)
	PPFI A 0 A_FireBullets (8.2, 5.1, 20, 4, "VenomPuff")
	PPFI A 0 A_PlaySound("trishot/firehuge", CHAN_WEAPON)
	PPFI A 0 A_FireCustomMissile("ShakeYourAssQuad",0,0)
	PPFI A 0 A_FireCustomMissile("SplayerMuzzleFX",0,0,8)
	PPFI A 0 A_TakeInventory("TriShotPrimary",3)
	TNT1 A 0 A_SpawnItemEx("ShooterLight",0,0,0)
	PPFI A 0 A_Recoil(8)
	PPFI A 0 A_SetPitch(pitch-12.5)
	Goto FireAnimFull
	
  FireSub2:
	PPFI A 0 A_FireBullets (8.2, 5.1, 14, 4, "VenomPuff")
	PPFI A 0 A_PlaySound("trishot/firesmall", CHAN_WEAPON)
	PPFI A 0 A_FireCustomMissile("ShakeYourAssDouble",0,0)
	PPFI A 0 A_FireCustomMissile("SplayerMuzzleFX",0,0,8)
	PPFI A 0 A_TakeInventory("TriShotPrimary",3)
	TNT1 A 0 A_SpawnItemEx("ShooterLight",0,0,0)
	PPFI A 0 A_Recoil(5)
	PPFI A 0 A_SetPitch(pitch-8.5)
	Goto FireAnimSub
	
  FireSub1:
	PPFI A 0 A_FireBullets (8.2, 5.1, 7, 4, "VenomPuff")
	PPFI A 0 A_PlaySound("trishot/firesmall", CHAN_WEAPON)
	PPFI A 0 A_FireCustomMissile("ShakeYourAssDouble",0,0)
	PPFI A 0 A_FireCustomMissile("SplayerMuzzleFX",0,0,8)
	PPFI A 0 A_TakeInventory("TriShotPrimary",3)
	TNT1 A 0 A_SpawnItemEx("ShooterLight",0,0,0)
	PPFI A 0 A_Recoil(5)
	PPFI A 0 A_SetPitch(pitch-4.5)
	Goto FireAnimSub
	
  // -- ACTUAL FIRE ANIMS --
  FireAnimFull:
	TRSI B 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSI DEFGH 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto FireReloadCheck
	
  FireAnimSub:
	TRSI C 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSI D 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSI E 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSI D 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto FireReloadCheck
	
  FireReloadCheck:
	TNT1 A 0 A_JumpIfInventory("TriShotPrimary",1,"Ready")
	TNT1 A 0 A_JumpIfInventory("TriShotSecondary",1,"ReloadAnim")
	Goto Ready
	
  ReloadCheck:
	TNT1 A 0 A_JumpIfInventory("TriShotPrimary",3,"Ready")
	TNT1 A 0 A_JumpIfInventory("TriShotSecondary",1,"ReloadAnim")
	Goto Ready
	
  ReloadAnim:
	TRSR ABCDEFG 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSR H 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSR I 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSR J 0 A_PlaySoundEx("trishot/open","SoundSlot6")
	TRSR JKLMN 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSR O 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSR P 3 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSR Q 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSR A 0 A_JumpIfInventory("TriShotSecondary",3,"Insert3")
	TRSR A 0 A_JumpIfInventory("TriShotSecondary",2,"Insert2")
	Goto Insert1
	
  Insert3:
	TRR3 A 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto InsertAnim
  Insert2:
	TRR2 A 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto InsertAnim
  Insert1:
	TRR1 A 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto InsertAnim

  InsertAnim:
	"####" BCD 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	"####" E 0 A_PlaySoundEx("trishot/insert","SoundSlot5")
	"####" EF 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	"####" G 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	"####" H 3 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	"####" I 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	"####" K 0 A_PlaySoundEx("trishot/metal","SoundSlot6")
	"####" JK 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	"####" L 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	"####" M 3 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	"####" NOP 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto CalculateAmmo
	
  CalculateAmmo:
     TNT1 A 0 A_JumpIfInventory("TriShotSecondary",1,2)
	 Goto ReloadClose
	 TNT1 AAA 0
	 TNT1 A 0 A_JumpIfInventory("TriShotPrimary",3,"ReloadClose")
	 TNT1 A 0 A_TakeInventory("TriShotSecondary",1)
	 TNT1 A 0 A_GiveInventory("TriShotPrimary",1)
	 Loop
	
  ReloadClose:
	TRSR K 0 A_PlaySoundEx("trishot/close","SoundSlot5")
	TRSR KJI 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSR H 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSR G 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSR F 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	TRSR EDCBA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto Ready
	
  Spawn:
    SHOT A -1
    Stop
  }
}