// -- FX --

ACTOR RPGMuzzleSmall
{
	+NOGRAVITY
	+NOBLOCKMAP
	-SOLID
	+NOCLIP
	+CLIENTSIDEONLY
	RenderStyle Add
	Scale 0.35
	States
	{
	Spawn:
	SMKP KGD 1
	SMKP A 0 A_ScaleVelocity(0.8)
	SMKP ABC 3 A_FadeOut(0.15)
	SMKP A 0 A_ScaleVelocity(0.8)
	SMKP DEF 3 A_FadeOut(0.15)
	SMKP A 0 A_ScaleVelocity(0.8)
	SMKP GHI 3 A_FadeOut(0.15)
	SMKP A 0 A_ScaleVelocity(0.8)
	SMKP JK 3 A_FadeOut(0.15)
	Stop
	}
}

ACTOR RPGMuzzleLarge : RPGMuzzleSmall
{
	Scale 1.1
	Alpha 0.75
	States
	{
	Spawn:
	SMKP KGD 1
	SMKP A 0 A_ScaleVelocity(0.8)
	SMKP AABBCC 4 A_FadeOut(0.1)
	SMKP A 0 A_ScaleVelocity(0.8)
	SMKP DDEEFF 4 A_FadeOut(0.1)
	SMKP A 0 A_ScaleVelocity(0.8)
	SMKP GGHHII 4 A_FadeOut(0.1)
	SMKP A 0 A_ScaleVelocity(0.8)
	SMKP JJKKKK 4 A_FadeOut(0.1)
	Stop
	}
}

ACTOR RPGMuzzleFX
{
	+NOBLOCKMAP
	+CLIENTSIDEONLY
	Speed 40
	States
	{
	Spawn:
	TNT1 A 1
	TNT1 A 0 A_Stop
	TNT1 AAAA 0 A_SpawnItemEx("RPGMuzzleSmall",0,random(-2,2),random(-2,2),0,random(-3,3),random(-3,3))
	TNT1 AAAAAA 0 A_SpawnItemEx("RPGMuzzleLarge",0,random(-64,64),random(-64,64),0,random(-5,5),random(-5,5))
	TNT1 AAAAAA 0 A_SpawnItemEx("CasingSpark",0,random(-3,3),random(-3,3),0,random(-8,8),random(-8,8))
	Stop
	}
}

ACTOR RPGRFX_Smoke : RPGMuzzleSmall
{
	Scale 0.04
	Alpha 0.5
	Renderstyle Translucent
	States
	{
	Spawn:
	SMKP A 0 A_ScaleVelocity(0.8)
	BKSM B 2 A_FadeOut(0.15)
	Loop
	}
}

ACTOR RPGRFX_Spark : RPGMuzzleSmall
{
	Scale 0.2
	Alpha 1.0
	Gravity 1.0
	-NOGRAVITY
	States
	{
	Spawn:
	SPRK A 5 bright
	SPRK AAAAAAAAAA 3 A_FadeOut(0.1)
	Stop
	}
}

ACTOR RPGRFX_ThickSmoke : RPGMuzzleSmall
{
	Scale 0.3
	Renderstyle Translucent
	Alpha 0.3
	States
	{
	Spawn:
	SMKP A 0 A_ScaleVelocity(0.8)
	BKSM B 8 A_FadeOut(0.1)
	Loop
	}
}

ACTOR RPGRocketFX : RPGMuzzleFX
{
	Speed 0
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 AA 0 A_SpawnItemEx("RPGRFX_ThickSmoke",0,random(-2,2),random(-2,2),0,random(-1,1),random(-1,1))
	
	TNT1 AA 0 A_SpawnItemEx("RPGRFX_Spark",0,random(-2,2),random(-2,2),random(-8,-1),random(-7,7),random(-7,1))
	
	TNT1 AA 0 A_SpawnItemEx("RPGRFX_Smoke",12,random(-2,2),random(-2,2),0,random(-3,3),random(-3,3))
	TNT1 AA 0 A_SpawnItemEx("RPGRFX_Smoke",-12,random(-2,2),random(-2,2),0,random(-3,3),random(-3,3))
	TNT1 AA 0 A_SpawnItemEx("RPGRFX_Smoke",0,random(-2,2),random(-2,2),0,random(-3,3),random(-3,3))
	TNT1 AAAAAA 0 A_SpawnItemEx("CasingSpark",0,random(-3,3),random(-3,3),random(-10,-5),random(-8,8),random(-8,8))
	Stop
	}
}

ACTOR RPGFragment
{
	+CLIENTSIDEONLY
	+NOCLIP
	-NOGRAVITY
	Speed 10
	Scale 0.5
	Alpha 1.0
	Gravity 1.0
	States
	{
	Spawn:
	TNT1 A 0
	TNT1 A 0 A_Jump(255,"Frag1","Frag2","Frag3")
	Goto Frag1
	
	Frag1:
	FRGM A 64
	FRGM AAAAAAAAAA 1 A_FadeOut(0.1)
	Stop
	
	Frag2:
	FRGM B 64
	FRGM BBBBBBBBBB 1 A_FadeOut(0.1)
	Stop
	
	Frag3:
	FRGM C 64
	FRGM CCCCCCCCCC 1 A_FadeOut(0.1)
	Stop
	
	}
	
}

ACTOR RPGDud
{
	BounceSound "rpg/dud"
	BounceCount 6
	BounceType "Doom"
	BounceFactor 0.2
	WallBounceFactor 0.2
	Gravity 1.0
	Radius 6
	Height 16
	Projectile
	-NOGRAVITY
	Speed 1
	Damage 0
	+CLIENTSIDEONLY
	States
	{
		Spawn:
		RPRR A 1
		Loop
		
		Death:
		RPRR A 200
		RPRR AAAAAAAAAA 1 A_FadeOut(0.1)
		Stop
	}
}

ACTOR RPGRocket
{
  Radius 11
  Height 8
  Speed 30
  Damage 100
  Projectile
  Scale 1.0
  Obituary "%k \cJ> \cKRPG \cJ> \cD%o" // "%o rode %k's rocket."
  States
  {
  Spawn:
	RPGR A 0
	RPGR A 0 A_PlaySoundEx("rpg/loop","Body",true)
	Goto Flying
  Flying:
	RPGR A 0 A_SpawnItemEx("RPGRocketFX",0,0,0)
	RPGR A 0 A_GiveInventory("DudTimer",1)
    RPRR A 1 Bright
    Loop
  Dud:
	MISL A 0 A_STOP
	MISL A 0 A_CustomMissile("RPGDud",0,0,0,0,-90)
	MISL A 0 A_PlaySoundEx("rpg/dud","Body")
	Stop
  Death:
	MISL A 0 A_StopSoundEx("Body")
	
	MISL A 0 A_JumpIfInventory("DudTimer",5,1)
	Goto Dud
	
    TNT1 A 0 A_AlertMonsters
    TNT1 A 0 A_SpawnItemEx("UltraExplosionRPG")
	TNT1 A 0 A_CheckFloor("FloorChunks")
	TNT1 A 0 A_CheckCeiling("CeilingChunks")
	Goto WallChunks
  WallChunks:
	TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("RPGFragment",random(-2,2),random(-2,2),random(-2,2),random(-20,10),random(-5,5),Random(-2,1))
	Goto End
  FloorChunks:
	TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("RPGFragment",random(-2,2),random(-2,2),random(-2,2),random(-5,5),random(-5,5),Random(10,20))
	Goto End
  CeilingChunks:
	TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx("RPGFragment",random(-2,2),random(-2,2),random(-2,2),random(-5,5),random(-5,5),Random(-20,-10))
	Goto End
  End:
    TNT1 A 20
    stop
  }
}

// -- actual gun --

ACTOR DudTimer : Inventory { Inventory.MaxAmount 10 }
ACTOR RPGZoomed : Inventory { Inventory.MaxAmount 1 }
ACTOR RPGDeselect : Inventory { Inventory.MaxAmount 1 }

ACTOR RPGPrimary : Ammo
{
  Inventory.Amount 1
  Inventory.MaxAmount 1
  Ammo.BackpackAmount 0
  Ammo.BackpackMaxAmount 0
  +IGNORESKILL
  Inventory.Icon "ROCKA0"
}

ACTOR RPGSecondary : Ammo
{
  Inventory.Amount 1
  Inventory.MaxAmount 12
  Ammo.BackpackAmount 1
  Ammo.BackpackMaxAmount 12
  +IGNORESKILL
  Inventory.Icon "ROCKA0"
}

ACTOR RPG7 : DoomWeapon
{
  Weapon.SelectionOrder 2500
  Weapon.AmmoUse 0
  Weapon.AmmoGive2 2
  Weapon.AmmoType "RPGPrimary"
  Weapon.AmmoType2 "RPGSecondary"
  +WEAPON.AMMO_OPTIONAL
  +WEAPON.NOAUTOFIRE
  Inventory.PickupMessage "You got the RPG-7. Blow shit up."
  Inventory.PickupSound "rpg/click"
  Tag "RPG-7"
  Scale 0.5
  States
  {
  Ready:
	PPSS A 0 A_JumpIfInventory("IsReloading",1,"ReloadCheck")
	PPSS A 0 A_JumpIfInventory("DoBlocking",1,"QuickMelee")
	RPGI A 0 A_JumpIfInventory("RPGPrimary",1,1)
	Goto ReadyEmpty
	RPGI B 0 A_JumpIfInventory("RPGZoomed",1,"ReadyZoomed")
    RPGI B 1 A_WeaponReady
    Loop
  ReadyEmpty:
	RPGI B 0 A_JumpIfInventory("RPGZoomed",1,"ReadyZoomedEmpty")
	RPGI A 1 A_WeaponReady
	Goto Ready
  ReadyZoomed:
	RPTR E 1 A_WeaponReady
	Goto Ready
  ReadyZoomedEmpty:
	RPTR D 1 A_WeaponReady
	Goto Ready
  Deselect:
	TNT1 A 0 A_GiveInventory("RPGDeselect",1)
	TNT1 A 0 A_JumpIfInventory("RPGZoomed",1,"ZoomOut")
	TNT1 A 0 A_TakeInventory("RPGDeselect",1)
	TNT1 A 0 A_PlaySoundEx("rpg/putaway","SoundSlot5")
	RPGI A 0 A_JumpIfInventory("RPGPrimary",1,1)
	Goto DeselectEmpty
	RPS2 JIHGFEDCBA 1
	Goto DeselectLoop
  DeselectEmpty:
	RPS1 JIHGFEDCBA 1
	Goto DeselectLoop
  DeselectLoop:
	TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_Lower
    TNT1 A 1 A_Lower
    Loop
	
  AltFire:
	TNT1 A 0 A_JumpIfInventory("RPGZoomed",1,"ZoomOut")
	Goto ZoomIn
	
  ZoomIn:
	TNT1 A 0 A_GiveInventory("RPGZoomed",1)
	TNT1 A 0 A_ZoomFactor(1.5)
	TNT1 A 0 A_JumpIfInventory("RPGPrimary",1,1)
	Goto ZoomInEmpty
	RPTR FGH 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto Ready
  ZoomInEmpty:
	RPTR ABC 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto Ready
	
  ZoomOut:
	TNT1 A 0 A_TakeInventory("RPGZoomed",1)
	TNT1 A 0 A_ZoomFactor(1.0)
	TNT1 A 0 A_JumpIfInventory("RPGPrimary",1,1)
	Goto ZoomOutEmpty
	RPTR HGF 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPTR A 0 A_JumpIfInventory("RPGDeselect",1,"Deselect")
	Goto Ready
  ZoomOutEmpty:
	RPTR CBA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPTR A 0 A_JumpIfInventory("RPGDeselect",1,"Deselect")
	Goto Ready
	
  Select:
	TNT1 A 0 A_Raise
	TNT1 A 1 A_WeaponReady
	Goto SelectAnim
  SelectAnim:
	RPGR M 0 A_PlaySoundEx("rpg/deploy","SoundSlot6")
	RPGI A 0 A_JumpIfInventory("RPGPrimary",1,1)
	Goto SelectEmpty
	RPS2 ABCDEFGHIJ 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
    Goto Ready
  SelectEmpty:
	RPS1 ABCDEFGHIJ 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto Ready
  Fire:
	MISG B 0 A_JumpIfInventory("RPGPrimary",1,1)
	Goto Ready
	RPGF B 0 A_PlayWeaponSound("rpg/fire")
	RPGF B 0 A_PlaySoundEx("rpg/firedistant","SoundSlot5")
	RPGF B 0 A_PlaySoundEx("rpg/sweetener","SoundSlot6")
	RPGF B 0 A_JumpIfInventory("RPGZoomed",1,"FireZoomed")
	RPGF B 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	MISG B 0 A_FireCustomMissile("RPGMuzzleFX",0,0)
	MISG B 0 A_TakeInventory("RPGPrimary",1)
	MISG B 0 A_FireCustomMissile("RPGRocket",0,0)
	MISG B 0 A_FireCustomMissile("ShakeYourAssQuad",0,0)
	MISG B 0 A_Recoil(8.0)
	MISG B 0 A_SetPitch(Pitch-10.0)
	RPGF BCDEFG 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGI A 4 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGF H 0 A_JumpIfInventory("RPGSecondary",1,"ReloadAnim")
	Goto Ready
	
  FireZoomed:
    RPTR I 1 bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	MISG B 0 A_FireCustomMissile("RPGMuzzleFX",0,0)
	MISG B 0 A_TakeInventory("RPGPrimary",1)
	MISG B 0 A_FireCustomMissile("RPGRocket",0,0)
	MISG B 0 A_FireCustomMissile("ShakeYourAssQuad",0,0)
	MISG B 0 A_Recoil(8.0)
	MISG B 0 A_SetPitch(Pitch-5.0)
	RPTR JKLMN 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPTR D 4 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGF A 0 A_GiveInventory("IsReloading",1)
	Goto Ready
	
  QuickMelee:
	 RPML A 0 A_GunFlash("RPGKick")
	 RPML A 0 A_GiveInventory("PowerKicking",1)
	 KIKL ABC 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 PPSM B 0 A_PlaySoundEx("melee/kick","Weapon")
	 KIKL D 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 PPSM D 0 A_CustomPunch (random(10,20),1,0,"BlockPuff",96)
	 KIKL E 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 KIKL F 3 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 KIKL EDCBA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	 RPML A 0 A_TakeInventory("PowerKicking",1)
	 PPSM A 0 A_TakeInventory("DoBlocking",1)
	 Goto Ready
	 
  RPGKick:
	 RPGI A 0 A_JumpIfInventory("RPGPrimary",1,1)
	 Goto RPGKickEmpty
	 RPGI B 14
	 Stop
  RPGKickEmpty:
	 RPGI A 14
	 Stop
	
  // This only happens if you're empty anyway
  ZoomToReload:
	TNT1 A 0 A_TakeInventory("RPGZoomed",1)
	TNT1 A 0 A_ZoomFactor(1.0)
	RPTR CBA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	Goto ReloadAnim
	
  ReloadCheck:
	TNT1 A 0 A_TakeInventory("IsReloading",1)
	TNT1 A 0 A_JumpIfInventory("RPGPrimary",1,"Ready")
	TNT1 A 0 A_JumpIfInventory("RPGSecondary",1,"ReloadAnim")
	Goto Ready
	
  ReloadAnim:
	TNT1 A 0 A_JumpIfInventory("RPGZoomed",1,"ZoomToReload")
	RPGR ABCD 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	
	RPGR E 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR F 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR G 4 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR H 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)

	RPGR IJKL 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR M 0 A_PlaySoundEx("rpg/tink","SoundSlot6")
	RPGR M 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR N 3 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR O 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR M 0 A_PlaySoundEx("rpg/slide","SoundSlot6")
	RPGR P 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR Q 0 A_TakeInventory("RPGSecondary",1)
	RPGR Q 0 A_GiveInventory("RPGPrimary",1)
	RPGR M 0 A_PlaySoundEx("rpg/click","SoundSlot5")
	RPGR Q 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR R 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR S 3 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR TUV 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR W 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR X 3 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR Y 2 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR Z 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
	RPGR Z 0 A_TakeInventory("DoBlocking",1)
	Goto Ready
	
  Spawn:
    RPGP Z -1
    Stop
  }
}