/*
CREDITS:
INFO - Frankensprite - a sprite made of parts of other sprites.
Just like frankenstein is a mashup of other people's limbs. Crazy, eh?

Sprites:
Frankensprite - Mike12, bits from 3DRealms (Shadow Warrior)
Projectile - ?

Sounds:
Up - ID (ET: Quake Wars)
Fire - ?
Reload - ID (Quake 2)
Time manipulations - Raven (Wolfenstein 3)
Mode change - ?
*/

ACTOR Comrade : Weapon 24509
{
   //$Category Weapons
   //$Title Comrade
   //$Sprite RTGGX0
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "You got the ''Comrade'' rotary grenade launcher! Lemme introduce my way to see the opressors... dead. (6)"
   Obituary "%o rained %o with handful of grenades - for the union!"
   Weapon.UpSound "Weapons/ComradeUp"
   Weapon.SelectionOrder 3
   Weapon.AmmoGive1 20
   Weapon.AmmoGive2 20
   Weapon.AmmoType "RawketAmmo"
   Weapon.AmmoType2 "NukeCellAmmo"
   Weapon.AmmoUse 1
   Weapon.AmmoUse2 1
   Weapon.Kickback 45
   Weapon.SlotNumber 6
   Scale 0.65
   States
   {
   Spawn:
      RTGG X -1
      Stop
   Ready:
      RTGG A 0 A_JumpIfInventory("ComradeMode",1,"BouncerReady")
      RTGG A 0 A_JumpIfInventory("ComradeWait",1,"ReadyCooldown")
      RTGG A 0 A_JumpIfInventory("ComradeTrigger",1,"TimeReady")
      RTGG A 1 A_WeaponReady
	  TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
      Loop
   BouncerReady:
      RTGG A 0 A_JumpIfInventory("ComradeWait",1,"BouncerReadyCooldown")
      RTGG A 0 A_JumpIfInventory("ComradeTrigger",1,"BouncerTimeReady")
      RTGG F 1 A_WeaponReady
	  TNT1 A 0 A_JumpIfInventory("RO_GotoReload", 1, "Reload")
      Loop
   TimeReady:
      RTGG A 0 A_JumpIfInventory("NukeCellAmmo",1,1)
      Goto UnTime
      RTGG A 0 A_JumpIfInventory("ComradeTimer",35,"TakeBiscuits")
      RTGG A 0 A_SetBlend("Cyan",0.1,2)
      RTGG A 0 A_GiveInventory("ComradeTimer",1)
      RTGG A 0 A_JumpIfInventory("ComradeMode",1,"BouncerTimeReady")
      RTGG A 1 A_WeaponReady
	  TNT1 A 0 A_JumpIfInventory("RO_GotoZoom", 1, "Zoom")
      Loop
   BouncerTimeReady:
      RTGG F 1 A_WeaponReady
	  TNT1 A 0 A_JumpIfInventory("RO_GotoZoom", 1, "Zoom")
      Goto TimeReady
   ReadyCooldown:
      RTGG A 0 A_TakeInventory("ComradeWait",1)
      RTGG A 1 A_WeaponReady(WRF_NOSECONDARY)
	  TNT1 A 0 A_JumpIfInventory("RO_GotoZoom", 1, "Zoom")
      Goto Ready
   BouncerReadyCooldown:
      RTGG A 0 A_TakeInventory("ComradeWait",1)
      RTGG F 1 A_WeaponReady(WRF_NOSECONDARY)
	  TNT1 A 0 A_JumpIfInventory("RO_GotoZoom", 1, "Zoom")
      Goto Ready
   TakeBiscuits:
      RTGG A 0 A_TakeInventory("ComradeTimer",35)
      RTGG A 0 A_TakeInventory("NukeCellAmmo",1,TIF_NOTAKEINFINITE)
      Goto TimeReady
   Deselect:
      RTGG A 0 A_JumpIfInventory("ComradeTrigger",1,"Nou")
      RTGG A 0 A_TakeInventory("ComradeDeselected",1)
      RTGG A 0 A_TakeInventory("ComradeTrigger",1)
      RTGG A 0 A_TakeInventory("PowerComradeTimeFreeze",1)
      RTGG A 0 A_TakeInventory("ComradeWait",99)
      RTGG A 0 A_ZoomFactor(1)
      RTGG A 0 A_StopSound(6)
      RTGG A 1 A_Lower
      RTGG A 0 A_Lower
      Loop
   Select:
      RTGG A 1 A_Raise
      Loop
   Fire:
      RTGF A 0 A_JumpIfInventory("ComradeTrigger",1,"FireTime")
      RTGG A 0 A_JumpIfInventory("ComradeMode",1,"BouncerFire")
      RTGF AAAA 0 A_FireCustomMissile("ComradeGrenade",frandom(7,-7),0,10,-5,0,frandom(3,-3))
      RTGF A 0 A_FireCustomMissile("ComradeGrenade",frandom(7,-7),1,10,-5,0,frandom(3,-3))
   Biscuits:
      RTGF A 0 A_Recoil(4)
      RTGF A 0 A_PlaySoundEx("Weapons/ErasusAmbient","SoundSlot5")
      RTGF A 0 A_PlayWeaponSound("Weapons/ComradeFire")
      RTGF A 0 ACS_Execute(851,0,30+random(8,-8),20+random(8,-8),0)
      RTGF A 0 A_PlaySoundEx("Weapons/ComradeReload","SoundSlot6")
      RTGF A 1 Bright A_ZoomFactor(0.95)
      RTGF B 0 ACS_Execute(851,0,20+random(6,-6),15+random(6,-6),0)
      RTGF B 1 Bright A_ZoomFactor(0.97)
      RTGG B 0 ACS_Execute(851,0,10+random(4,-4),5+random(4,-4),0)
      RTGG B 2 A_ZoomFactor(0.98)
      RTGG C 2 A_ZoomFactor(0.99)
      RTGG D 1 A_ZoomFactor(1)
      RTGG E 1
      RTGG A 2
      RTGG A 0 A_Refire
      RTGG A 2
      Goto Ready
   BouncerFire:
      RTGF AAAA 0 A_FireCustomMissile("ComradeBounceGrenade",frandom(7,-7),0,10,-5,0,frandom(3,-3))
      RTGF A 0 A_FireCustomMissile("ComradeBounceGrenade",frandom(7,-7),1,10,-5,0,frandom(3,-3))
	  Goto Biscuits
   FireTime:
      /*RTGG A 0 A_JumpIfInventory("NukeCellAmmo",1,1)
      //Goto UnTime
      RTGG A 0 A_TakeInventory("NukeCellAmmo",1)*/
      RTGG A 0 A_JumpIfInventory("ComradeMode",1,"BouncerTimeFire")
      RTGF AAAA 0 A_FireCustomMissile("ComradeGrenade",frandom(7,-7),0,10,-5,0,frandom(3,-3))
      RTGF A 0 A_FireCustomMissile("ComradeGrenade",frandom(7,-7),1,10,-5,0,frandom(3,-3))
   Pancakes:
      RTGG A 0 A_SetBlend("Cyan",0.3,12)
      RTGG A 0 A_PlaySound("Weapons/ErasusAmbient",CHAN_WEAPON|CHAN_NOPAUSE,0.75,0,ATTN_NONE)
      RTGF A 1 Bright
      RTGF B 1 Bright
      RTGG B 2
      RTGG C 2
      RTGG D 1
      RTGG E 1
      RTGG A 2
      //RTGG A 0 A_Refire
      //RTGG A 2
      Goto Ready
   BouncerTimeFire:
      RTGF AAAA 0 A_FireCustomMissile("ComradeBounceGrenade",frandom(7,-7),0,10,-5,0,frandom(3,-3))
      RTGF A 0 A_FireCustomMissile("ComradeBounceGrenade",frandom(7,-7),1,10,-5,0,frandom(3,-3))
	  Goto Pancakes
   AltFire:
      RTGG A 0 A_JumpIfInventory("ComradeTrigger",1,"UnTime")
      RTGG A 0 A_GiveInventory("ComradeTrigger",1)
      RTGG A 0 A_PlaySound("Weapons/ComradeTimeFreezeStart",5|CHAN_NOPAUSE,1,0,ATTN_NONE)
      RTGG A 0 A_PlaySound("Weapons/ComradeTimeFreezeLoop",6|CHAN_NOPAUSE,1,1,ATTN_NONE)
      RTGG A 0 A_SetBlend("Cyan",0.3,28)
      RTGG A 1 A_ZoomFactor(0.99)
      RTGG A 1 A_ZoomFactor(0.98)
      RTGG A 1 A_ZoomFactor(0.97)
      RTGG A 1 A_ZoomFactor(0.94)
      RTGG A 1 A_ZoomFactor(0.92)
      RTGG A 1 A_ZoomFactor(0.9)
      RTGG A 1 A_ZoomFactor(0.875)
      RTGG A 1 A_ZoomFactor(0.85)
      RTGG A 1 A_ZoomFactor(0.825)
      RTGG A 1 A_ZoomFactor(0.815)
      RTGG A 1 A_ZoomFactor(0.8075)
      RTGG A 0 A_GiveInventory("ComradeTimeStop",1)
      RTGG A 1 A_ZoomFactor(0.8)
      RTGG A 0 A_GiveInventory("ComradeTimeStop",1)
      RTGG A 10 A_GiveInventory("ComradeTimeStop",1)
      Goto Ready
   Nou:
      RTGG A 0 A_GiveInventory("ComradeDeselected",1)
   UnTime:
      RTGG A 0 A_TakeInventory("ComradeTrigger",1)
      RTGG A 0 A_PlaySound("Weapons/ComradeTimeFreezeStop",5|CHAN_NOPAUSE,1,0,ATTN_NONE)
      RTGG A 0 A_StopSound(6)
      RTGG A 0 A_SetBlend("Cyan",0.5,36)
      RTGG A 0 A_TakeInventory("PowerComradeTimeFreeze",1)
      RTGG A 1 A_ZoomFactor(0.8)
      RTGG A 1 A_ZoomFactor(0.825)
      RTGG A 1 A_ZoomFactor(0.85)
      RTGG A 1 A_ZoomFactor(0.875)
      RTGG A 1 A_ZoomFactor(0.9)
      RTGG A 1 A_ZoomFactor(0.92)
      RTGG A 1 A_ZoomFactor(0.94)
      RTGG A 1 A_ZoomFactor(0.97)
      RTGG A 1 A_ZoomFactor(0.98)
      RTGG A 1 A_ZoomFactor(0.99)
      RTGG A 1 A_ZoomFactor(1)
      RTGG A 10
      RTGG A 0 A_GiveInventory("ComradeWait",35)
      RTGG A 0 A_JumpIfInventory("ComradeDeselected",1,"Deselect")
      Goto Ready
   Reload: //Fire mode
      RTGG A 0 A_JumpIfInventory("ComradeTrigger",1,"TimeReload")
      RTGG A 0 A_Quake(2, 9, 0, 2, "none")
      RTGG A 0 A_PlaySound("Weapons/ComradeMode",6)
      RTGG A 0 A_JumpIfInventory("ComradeMode",1,"UnReload")
      RTGG A 0 A_Print("Bouncer Mode")
      RTGG A 0 A_GiveInventory("ComradeMode",1)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(1,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(3,35)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(4,36)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(6,38)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(4,36)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(3,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(1,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(0,32)
      RTGG FF 8 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
	  Goto Ready
   UnReload:
      RTGG A 0 A_Print("Impact Mode")
	  RTGG A 0 A_TakeInventory("ComradeMode",1)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(1,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(3,35)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(4,36)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(6,38)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(4,36)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(3,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(1,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(0,32)
	  RTGG AA 8 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
	  Goto Ready

   TimeReload:
      RTGG A 0 A_SetBlend("Cyan",0.2,45)
      RTGG A 0 A_JumpIfInventory("ComradeMode",1,"TimeUnReload")
      RTGG A 0 A_Print("Bouncer Mode")
      RTGG A 0 A_GiveInventory("ComradeMode",1)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(1,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(3,35)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(4,36)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(6,38)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(4,36)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(3,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(1,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG A 1 Offset(0,32)
      RTGG FF 8 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
	  Goto Ready
   TimeUnReload:
      RTGG A 0 A_Print("Impact Mode")
	  RTGG A 0 A_TakeInventory("ComradeMode",1)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(1,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(3,35)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(4,36)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(6,38)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(4,36)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(3,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(1,33)
      RTGG A 0 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
      RTGG F 1 Offset(0,32)
	  RTGG AA 8 A_WeaponReady(WRF_NOSWITCH|WRF_NOFIRE)
	  Goto Ready
   }
}

ACTOR ComradeMode : Inventory
{
   Inventory.MaxAmount 1
}

ACTOR ComradeTrigger : Inventory
{
   Inventory.MaxAmount 1
}

ACTOR ComradeDeselected : Inventory
{
   Inventory.MaxAmount 1
}

ACTOR ComradeTimer : Inventory
{
   Inventory.MaxAmount 35
}

ACTOR ComradeWait : Inventory
{
   Inventory.MaxAmount 99
}

ACTOR ComradeGrenade
{
   Obituary "%k launched on %o a rain of grenades."
   Radius 6
   Height 10
   Speed 45
   Damage 35
   Scale 0.8
   PROJECTILE
   +THRUGHOST
   +EXPLODEONWATER
   -NOGRAVITY
   Gravity 0.55
   States
   {
   Spawn:
      PAGG A 0
      PAGG A 0 ThrustThingZ(0, 15, 0, 1)
   Roflcopter:
      PAGG A 1 Bright A_SpawnItemEx("BarrageTrail",-7,0.1*random(8,12),0.1*random(8,12),0.1*random(1,3),0.1*random(1,3),0.1*random(1,3),random(0,359),0)
      Loop
   Death:
      TNT1 A 0 A_PlaySound("Weapons/BustExplo")
      TNT1 A 0 A_JumpIfInTargetInventory("NukerUpgrade",1,"NukerDeath")
      TNT1 A 0 A_StopSoundEx("SoundSlot5")
      TNT1 A 0 A_Explode(125,128)
      TNT1 A 0 A_SpawnItemEx("MissileExplode",0,0,0,0,0,0,0,128,0)
      TNT1 BCD 5
      stop
   NukerDeath:
      TNT1 A 0 A_StopSoundEx("SoundSlot5")
      TNT1 A 0 A_Explode(250,192)
      TNT1 A 1 A_SpawnItemEx("NukerMissileExplode",0,0,0,0,0,0,0,128,0)
      TNT1 BCD 5
      stop
   }
}

ACTOR ComradeBounceGrenade : ComradeGrenade
{
   Gravity 0.85
   Speed 30
   BounceSound "Weapons/ComradeBounce"
   BounceType Hexen
   BounceCount 6
   BounceFactor 0.5
   States
   {
   Spawn:
      PAGG A 0
      PAGG A 0 ThrustThingZ(0, 25, 0, 1)
   Roflcopter:
      PAGG A 1 Bright A_SpawnItemEx("BarrageTrail",-7,0.1*random(8,12),0.1*random(8,12),0.1*random(1,3),0.1*random(1,3),0.1*random(1,3),random(0,359),0)
      Loop
   }
}

actor PowerComradeTimeFreeze : PowerTimeFreezer
{
	Inventory.icon "TNT1A0"
}

actor ComradeTimeStop : PowerupGiver
{
	inventory.maxamount 0
	+INVENTORY.AUTOACTIVATE
	powerup.type "ComradeTimeFreeze"
	powerup.duration 0x7FFFFFFF
	states
	{
	Spawn:
		TNT1 A -1
		Stop
	}
}
