/*
CREDITS:
Gun sprite - Will Rock (Ubisoft)
Fire sound - Command & Conquer 3 - Kane's Wrath (EA, for god's sake, can you return to roots again and make C&C as awesome as it was during your C&C series 3 reboot?!)
Alt fire (sounds and idea) - Team Fortress 2 (Valve)
Gun flash - Bane
*/

actor Tarpan : DoomWeapon 24532
{
   //$Category Weapons
   //$Title Tarpan
   //$Sprite TRPGX0
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "Lifted up a ''Tarpan'' machinegun! There's more than the wise elder's eye and glass can see... (4)" //Jezeli nie kojarzysz tego fragmentu, to prawdopodobnie zasypiales na polskim. Nie zebym mial cos przeciwko, ja rozumiem ten bol.
   Obituary "%o was gunned down by %k's ''Tarpan''."
   Weapon.UpSound "Tarpan/Up"
   Weapon.SelectionOrder 5
   Weapon.AmmoUse 1
   Weapon.AmmoGive 30
   Weapon.AmmoType "Boolet"
   Weapon.SlotNumber 4
   Weapon.Kickback 45
   Scale 1
   States
   {
   Ready:
     TRPG A 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
     Loop
   Deselect:
     TNT1 A 0 A_ZoomFactor(1)
     TNT1 A 0 A_StopSoundEx("SoundSlot5")
     TRPG A 1 A_Lower
     TRPG A 0 A_Lower
     Loop
   Select:
     TRPG A 1 A_Raise
     TRPG A 0 A_Raise
     Loop
   Reload:
     TNT1 A 0 A_PlaySound("Overwhelming/Mode",6,0.8)
     TNT1 A 0 A_Quake(1,7,0,2,none)
     TRPG A 0 A_JumpIfInventory("TarpanMode",1,"UnReload")
     TRPG A 0 A_GiveInventory("TarpanMode",1)
     TRPG A 0 A_Print("Homing boolets mode on.")
     TRPG A 15
     TRPG A 10 A_Weaponready(WRF_NOSWITCH|WRF_NOBOB)
     Goto Ready
   UnReload:
     TRPG A 0 A_TakeInventory("TarpanMode",1)
     TRPG A 0 A_Print("Homing boolets mode off.")
     TRPG A 15
     TRPG A 10 A_Weaponready(WRF_NOSWITCH|WRF_NOBOB)
     Goto ready
   Fire:
     TNT1 A 0 A_Jump(255,"Flash1","Flash2","Flash3","Flash4")
   Doink:
     TNT1 A 0 A_SetPitch(Pitch-0.5)
     TNT1 A 0 A_SetAngle(Angle-0.5)
	 TNT1 A 0 A_JumpIfInventory("CaliberUpgrade",1,"CaliberFire")
     TNT1 A 0 A_FireCustomMissile("TarpanShot",frandom(-1.0,1.0),1,11,3,0,frandom(-1.0,1.0))
     Goto Donk
   CaliberFire:
     TNT1 A 0 A_PlaySound("Weapons/WolgirHEndFire",8)
	 TNT1 A 0 A_FireCustomMissile("CaliberTarpanShot",frandom(-1.0,1.0),1,11,3,0,frandom(-1.0,1.0))
   Donk:
	 TNT1 A 0 A_GunFlash
     TNT1 A 0 A_GiveInventory("BooletCasing",1)
     TNT1 A 0 A_JumpIfInventory("TarpanTrigger",1,"Honk") //Why this? Well, if I use single channel, the fire sound cuts off while shooting continously. This prevents from that.
     TNT1 A 0 A_PlaySound("Tarpan/Fire",CHAN_WEAPON)
     TNT1 A 0 A_GiveInventory("TarpanTrigger",1)
   Yoink:
     TRPG B 1 A_ZoomFactor(0.99)
     TRPG C 1 A_ZoomFactor(0.995)
     TRPG D 1 A_ZoomFactor(1)
     TRPG A 0 A_ReFire
     TRPG FEDCB 1
     TRPG A 8
     Goto Ready
   Honk:
     TNT1 A 0 A_PlaySound("Tarpan/Fire",5)
     TNT1 A 0 A_TakeInventory("TarpanTrigger",1)
     Goto Yoink
   Flash1:
     TRPF A 1 Bright A_ZoomFactor(0.98)
	 Goto Doink
   Flash2:
     TRPF B 1 Bright A_ZoomFactor(0.98)
	 Goto Doink
   Flash3:
     TRPF C 1 Bright A_ZoomFactor(0.98)
	 Goto Doink
   Flash4:
     TRPF D 1 Bright A_ZoomFactor(0.98)
	 Goto Doink
   AltFire:
     TNT1 A 0 A_JumpIfInventory("BooletCasing",2,"AltFireHurr")
     TRPG A 0 A_PlaySound("Tarpan/Dry",6)
     TRPG BCDFEDCB 1
     TRPG A 8
     Goto Ready
   AltFireHurr:
     TNT1 A 0 A_PlaySound("Tarpan/Heal",6,0.3)
   AltFireMain:
     TNT1 A 0 A_JumpIfInventory("BooletCasing",2,2)
     TNT1 A 0 A_StopSound(6)
	 Goto HonkaCzongka+1
     TNT1 A 0 A_GunFlash
     TNT1 A 0 A_FireCustomMissile("HealingField") //A_FireCustomMissile("HealingStream",frandom(-1.0,1.0),0,2.5+random(0.70,-0.70),5.5+random(0.70,-0.70),0,frandom(-1.0,1.0))
	 TNT1 A 0 ACS_ExecuteAlways(685,0,0,0,0)
	 TNT1 A 0 A_SpawnItem("TarpanHealingExceptNotReally")
     TNT1 A 0 A_TakeInventory("BooletCasing",2)
	 TNT1 A 0 A_Jump(255,"AltFlash1","AltFlash2","AltFlash3","AltFlash4")
   AltFlash1:
     TRPH A 1 Bright A_ZoomFactor(0.97)
	 Goto HonkaCzongka
   AltFlash2:
     TRPH B 1 Bright A_ZoomFactor(0.97)
	 Goto HonkaCzongka
   AltFlash3:
     TRPH C 1 Bright A_ZoomFactor(0.97)
	 Goto HonkaCzongka
   AltFlash4:
     TRPH D 1 Bright A_ZoomFactor(0.97)
	 Goto HonkaCzongka
   HonkaCzongka:
	 TNT1 A 0 A_ReFire("AltFireMain")
     TNT1 A 0 A_StopSound(6)
     TRPG B 1 A_ZoomFactor(0.98)
     TRPG C 1 A_ZoomFactor(0.99)
     TRPG D 1 A_ZoomFactor(1)
     TRPG FEDCB 1
     TRPG A 8
	 Goto Ready
   Flash:
     TNT1 A 2 Bright A_Light1
     TNT1 A 2 Bright A_Light2
     Goto LightDone
   Spawn:
     TRPG X -1
     Stop
   }
}

Actor TarpanHealingExceptNotReally
{
	States
	{
		Spawn:
		TNT1 A 0
		TNT1 A 0 A_Explode(10,256,0)
		TNT1 A 1
		Stop
	}
}

actor TarpanTrigger : Inventory { Inventory.MaxAmount 1 }
actor TarpanMode : Inventory { Inventory.MaxAmount 1 }

actor TarpanShot : OverpowerShot
{
  Radius 11
  Height 8
  Speed 250
  Damage 8
  Projectile
  +RIPPER
  +THRUGHOST
  +EXPLODEONWATER
  +SEEKERMISSILE
  +DONTSEEKINVISIBLE
  +SCREENSEEKER
  Renderstyle Add
  DeathSound "weapons/larpaexp"
  Obituary "%o was gunned down by %k's ''Tarpan''."
  MissileType "OverpowerTrailer"
  Scale 0.1
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_ChangeVelocity (frandom(-5.5, 5.5), frandom(-5.5, 5.5), frandom(-2.75, 2.75), 0)
	TNT1 A 0 A_JumpIfInTargetInventory("TarpanMode",1,"HomerMode")
	10BA A 1 Bright
    loop
  HomerMode:
    10BA A 1 Bright A_SeekerMissile(9,14,SMF_LOOK|SMF_PRECISE,192,5)
    Goto Spawn
  Death:
    TNT1 A 0 A_JumpIfInTargetInventory("NukerUpgrade",1,"NukerDeath")
    TNT1 A 0 A_Explode(10,64,0)
    TNT1 A 0 A_Explode(10,64)
    TNT1 A 0 A_SpawnItemEx("PelletExplode",0,0,0,0,0,0,0,128,0)
    TNT1 BCD 4
    stop
  NukerDeath:
    TNT1 A 0 A_Explode(20,96,0)
    TNT1 A 0 A_Explode(20,96)
    TNT1 A 0 A_SpawnItemEx("NukerPelletExplode",0,0,0,0,0,0,0,128,0)
    TNT1 BCD 4
    stop
  }
}

actor CaliberTarpanShot : TarpanShot
{
	Damage 10
}

actor HealingField
{
  Radius 1
  Height 1
  Speed 0
  Damage 0
  Projectile
  +NOINTERACTION
  +CLIENTSIDEONLY
  Renderstyle Add
  Obituary "%k thought that healing isn't as rewarding as hurting people, so %o got overhealed in quite awful way."
  Scale 0.5
  Alpha 0.1
  States
  {
  Spawn:
	TNT1 A 0
	TNT1 AAAAA 0 A_SpawnItemEx("HealStreamFX",random(168,-168),random(168,-168),random(64,-24),random(0.85,-0.85),random(0.85,-0.85),random(1.25,1.75),random(0,359))
  Looplololo:
	YAE4 A 0 A_FadeOut(0.002)
	YAE4 A 1 Bright //A_SetScale(ScaleX-0.001,ScaleY-0.001)
    Loop
  Death:
    TNT1 A 0
	TNT1 A 0 A_Stop
	TNT1 A 0 A_GiveInventory("HealStreamItem",1)
	TNT1 A 0 A_FadeOut(0.05)
	TNT1 AAAAA 0 A_SpawnItemEx("HealStreamFX",random(168,-168),random(168,-168),random(64,-24),random(0.85,-0.85),random(0.85,-0.85),random(1.25,1.75),random(0,359))
    Stop
  }
}

actor HealStream
{
  Radius 11
  Height 8
  Speed 10
  Damage 0//5
  Projectile
  +RIPPER
  +THRUGHOST
  +DONTSPLASH
  +BLOODLESSIMPACT
  Renderstyle Add
  Obituary "%k thought that healing isn't as rewarding as hurting people, so %o got overhealed in quite awful way."
  Scale 0.03
  States
  {
  Spawn:
    TNT1 A 0
	TNT1 A 0 A_Jump(5,"HealSymbolSpawn")
	TNT1 A 0 A_SpawnItemEx("HealStreamTrail",random(2.0,2.0),random(2.0,2.0),random(2.0,2.0)) //To make it extra thick.
	TNT1 A 0 A_FadeOut(0.05)
    YAE4 A 1 Bright //A_SetScale(ScaleX-0.003,ScaleY-0.003)
    loop
  HealSymbolSpawn:
    TNT1 A 0 A_SpawnItemEx("HealStreamFX",random(8,-8),random(8,-8),random(8,-8),random(0.85,-0.85),random(0.85,-0.85),random(1.25,1.75),random(0,359))
    Goto Spawn+2
  }
}

ACTOR HealStreamTrail
{
   Renderstyle Add
   Alpha 0.8
   Scale 0.03
   //+FLOAT
   //+FLOATBOB
   +NOINTERACTION
   +CLIENTSIDEONLY
   States
   {
   Spawn:
    TNT1 AA 0 A_FadeOut(0.05)
    YAE4 A 1 //A_SetScale(ScaleX-0.003,ScaleY-0.003)
    Loop
   }
}

ACTOR HealStreamFX
{
   Renderstyle Add
   Alpha 0.5
   Scale 0.2
   //+FLOAT
   //+FLOATBOB
   +NOINTERACTION
   +CLIENTSIDEONLY
   States
   {
   Spawn:
    MED3 B 1 A_FadeOut(0.025)
    Loop
   }
}

ACTOR HealStreamItem : Health
{
   Inventory.PickupSound ""
   Inventory.PickupMessage ""
   Inventory.Amount 4
   Inventory.MaxAmount 999999
   +INVENTORY.ALWAYSPICKUP
   -COUNTITEM
   -INVENTORY.PICKUPFLASH
   States
   {
   Spawn:
    TNT1 A -1
	Stop
   }
}

ACTOR HealStreamDamager : CustomInventory
{
   Inventory.Amount 1
   Inventory.MaxAmount 1
   +INVENTORY.ALWAYSPICKUP
   +INVENTORY.AUTOACTIVATE
   States
   {
   Spawn:
    TNT1 A -1
	Stop
   Pickup:
    TNT1 A 0 DamageThing(10,0)
	Stop
   }
}