
//==============================================================================
//			PLUTONIA PLAYER
//==============================================================================

Actor FDPlutPlayer : DoomPlayer
{
  Player.DisplayName "Plutguy"
  Player.viewheight 48
  Player.attackzoffset 15
  Player.Forwardmove 0.6 1.0
  Player.Sidemove 0.6 1.0
  Player.damagescreencolor Red, 0.5
  Species "Player"
  PainChance 256
  +THRUSPECIES
  
  Player.StartItem "FDPlutPistol"
  Player.StartItem "FDPlutPistolAmmo", 6
  Player.StartItem "FDPlutFist"
  Player.StartItem "FDPlutBullets", 50
  Player.StartItem "FDPlutoniaToken"
}

//==============================================================================
//			TNT PLAYER
//==============================================================================

Actor FDTNTPlayer : DoomPlayer
{
  Player.DisplayName "TNTguy"
  Player.viewheight 48
  Player.attackzoffset 15
  Player.Forwardmove 0.6 1.0
  Player.Sidemove 0.6 1.0
  Player.damagescreencolor Red, 0.5
  Species "Player"
  PainChance 256
  +THRUSPECIES
  
  Player.StartItem "FDTNTPistol"
  Player.StartItem "FDTNTPistolAmmo", 17
  Player.StartItem "FDTNTFist"
  Player.StartItem "FDTNTBullets", 50
  Player.StartItem "FDTNTToken"
}

//==============================================================================
//			DOOM II PLAYER
//==============================================================================

Actor FDDoom2Player : DoomPlayer
{
  Player.DisplayName "Doomguy"
  Player.viewheight 48
  Player.attackzoffset 15
  Player.Forwardmove 0.6 1.0
  Player.Sidemove 0.6 1.0
  Player.damagescreencolor Red, 0.5
  Species "Player"
  PainChance 256
  +THRUSPECIES
  
  Player.StartItem "FDDoom2Pistol"
  Player.StartItem "FDDoom2PistolAmmo", 15
  Player.StartItem "FDDoom2Fist"
  Player.StartItem "FDDoom2Bullets", 50
  Player.StartItem "FDDoom2Token"
}

//==============================================================================
//				INVENTORY INHERITANCE
//==============================================================================

Actor FDBoolean : Inventory 
{
  +INVENTORY.UNTOSSABLE
  +INVENTORY.IGNORESKILL
inventory.maxamount 1
}

Actor FDCounter : Inventory 
{
  +INVENTORY.UNTOSSABLE
  +INVENTORY.IGNORESKILL
inventory.maxamount 99999
}

ACTOR FDCustomFunction : CustomInventory
{
  -COUNTITEM
  +INVENTORY.ALWAYSPICKUP
  Inventory.PickupMessage ""
  Inventory.PickupSound ""
  States
  {
  Spawn:
    TNT1 A 1
    Stop
  Pickup:
    TNT1 A 0 
	TNT1 A 0
    Stop
  }
}

Actor FDPlutoniaToken	: FDBoolean {}
Actor FDTNTToken		: FDBoolean {}
Actor FDDoom2Token		: FDBoolean {}

//==============================================================================
//				TEST ITEMS
//==============================================================================

ACTOR FDTestInventory : CustomInventory
{
  +INVENTORY.INVBAR
  +INVENTORY.UNTOSSABLE
  +INVENTORY.BIGPOWERUP
  Tag "Test Inventory"
  Inventory.MaxAmount 100
  Inventory.Icon "PAMMD0"
  Inventory.Pickupsound ""
  Inventory.UseSound ""
  Inventory.PickupMessage ""
  States
  {
  Spawn:
    TNT1 A -1
    Stop
  Pickup:
    TNT1 A 0 A_GiveInventory("FDHealthBonusPickup", 1)
    Stop
  Use:
    TNT1 A 0 
	TNT1 A 0 A_Print ("aeiou", 1)
    Stop
  }
}

ACTOR FDTestInventory2 : FDTestInventory
{
  Tag "Test Inventory 2"
  Inventory.Icon "DAMMC0"
}

//==============================================================================
//				BULLET PUFFS
//==============================================================================
// Parts adapted from LegenDoom, again, because lazy

Actor FDBulletPuff : BulletPuff
{ 
  DamageType "Bullet"
  +THRUGHOST
  +NOEXTREMEDEATH
  +PUFFONACTORS
  +PUFFGETSOWNER
  +MTHRUSPECIES
  +THRUSPECIES
  +NOTIMEFREEZE
  +HITTRACER
  +NOTELEPORT
  +FORCEXYBILLBOARD
  -ALLOWPARTICLES
  -RANDOMIZE
  RenderStyle Add
  Species "Player"
  Alpha 0.98
  Scale 0.05
  VSpeed 0
  States
  {
   Spawn:
   XDeath:
	TNT1 A 0
	TNT1 A 0 A_Jump(256, "BleedingTarget")
	Goto BleedingTarget
   Melee:
   Crash:
	TNT1 A 0 A_Jump(256, "SparkingTarget")
	Goto SparkingTarget
	
   BleedingTarget:
	TNT1 A 0 A_CheckFlag ("NOBLOOD", "Crash", AAPTR_TRACER)
    TNT1 A 0 A_PlaySound("bullet/hitflesh", CHAN_WEAPON, (CallACS("FD_bulletvolume")/65536.0), 0, 1.8)
	TNT1 A 0
	Stop
	
   SparkingTarget:
    TNT1 A 0 A_PlaySound("bullet/ricochet", CHAN_WEAPON, (CallACS("FD_bulletvolume")/65536.0), 0, 1.2)
	TNT1 A 0 A_JumpIf(CallACS("FD_bulletpuffs") == 0, "NormalPuff")
	TNT1 A 0 A_JumpIf(CallACS("FD_bulletpuffs") == 2, 1)
	Goto FadeLoop
	TNT1 A 0 A_SpawnItemEx("FDGunSmoke",0,0,0, 0,0,frandom(0.1,0.3), 0, SXF_NOCHECKPOSITION)
    TNT1 A 0 A_Jump (256, 1,2,3,4,5,6,7)
    TNT1 AAAAAAA 0 A_SpawnItemEx ("FDBulletPuffSpark", frandom(-2.0,2.0),frandom(-2.0,2.0),frandom(-2.0,2.0) ,frandom(-5.0,5.0),frandom(-5.0,5.0),frandom(-1.0,4.0), 0, SXF_NOCHECKPOSITION)
    Goto FadeLoop
  FadeLoop:
    TNT1 A 0 A_JumpIf (alpha <= 0.4, "FadeLoop2")
    OGLO A 1 Bright Light("FDBulletPuffLight") A_SetScale (scalex * 1.10)
    TNT1 A 0 A_FadeTo (0, 0.1, 1)
    Loop
  FadeLoop2:
    OGLO A 1 Bright A_SetScale (scalex * 1.10)
    TNT1 A 0 A_FadeTo (0, 0.1, 1)
    Loop
	
   NormalPuff:
    TNT1 A 0 A_SetTranslucent (0.5, 0)
    TNT1 A 0 ThrustThingZ (0, 5, 0, 1)
    TNT1 A 0 A_SetScale (1.0)
	PUFF A 4 Bright
	PUFF BCD 4
	Stop
  }
}

Actor FDGibBulletPuff : FDBulletPuff
{ 
  +EXTREMEDEATH
  -NOEXTREMEDEATH
}

Actor FDPainlessBulletPuff : FDBulletPuff
{ 
  +PAINLESS
}

Actor FDFistPuff : FDBulletPuff
{ 
  DamageType "Melee"
  -NOEXTREMEDEATH
  States
  {
   SparkingTarget:
    TNT1 A 0 A_PlaySound("plutfist/hit", 7, 1, 0, 1.2)
	TNT1 A 10
	Stop
	
   BleedingTarget:
	TNT1 A 0 A_CheckFlag ("NOBLOOD", "SparkingTarget", AAPTR_TRACER)
    TNT1 A 0 A_PlaySound("bullet/hitflesh", CHAN_WEAPON, 1, 0, 1.8)
    TNT1 A 0 A_PlaySound("plutfist/hit", 7, 1, 0, 1.2)
	TNT1 A 10
	Stop
  }
}

Actor FDTNTFistPuff : FDFistPuff
{ 
  States
  {
   Spawn:
   XDeath:
	TNT1 A 0
	TNT1 A 0 A_JumpIfInventory ("FDTNTFistComboOne", 1, 3, AAPTR_TARGET)
	TNT1 A 0 A_GiveInventory ("FDTNTFistComboOne", 1, AAPTR_TARGET)
	TNT1 A 0 A_Jump(256, "BleedingTarget")
	Goto BleedingTarget
	TNT1 A 0 A_TakeInventory ("FDTNTFistComboOne", 1, AAPTR_TARGET)
	TNT1 A 0 A_GiveInventory ("FDTNTFistComboTwo", 1, AAPTR_TARGET)
	TNT1 A 0 A_Jump(256, "BleedingTarget")
	Goto BleedingTarget
   Melee:
	TNT1 A 0 A_JumpIfInventory ("FDTNTFistComboOne", 1, 3, AAPTR_TARGET)
	TNT1 A 0 A_GiveInventory ("FDTNTFistComboOne", 1, AAPTR_TARGET)
   Crash:
	TNT1 A 0 A_Jump(256, "SparkingTarget")
	Goto SparkingTarget
	TNT1 A 0 A_TakeInventory ("FDTNTFistComboOne", 1, AAPTR_TARGET)
	TNT1 A 0 A_GiveInventory ("FDTNTFistComboTwo", 1, AAPTR_TARGET)
	TNT1 A 0 A_Jump(256, "SparkingTarget")
	Goto SparkingTarget
  }
}

Actor FDTNTUppercutPuff : FDBulletPuff
{ 
  DamageType "Melee"
  -NOEXTREMEDEATH
  States
  {
   SparkingTarget:
    TNT1 A 0 A_PlaySound("tntfist/uppercuthit", 7, 1, 0, 1.2)
	TNT1 A 0 A_GiveInventory ("FDTNTFistUppercutThrust", 1, AAPTR_TRACER)
	TNT1 A 10
	Stop
	
   BleedingTarget:
	TNT1 A 0 A_CheckFlag ("NOBLOOD", "SparkingTarget", AAPTR_TRACER)
	TNT1 A 0 A_GiveInventory ("FDTNTFistUppercutThrust", 1, AAPTR_TRACER)
    TNT1 A 0 A_PlaySound("tntfist/uppercutflesh", CHAN_WEAPON, 1, 0, 1.8)
    TNT1 A 0 A_PlaySound("tntfist/uppercuthit", 7, 1, 0, 1.2)
	TNT1 A 10
	Stop
  }
}

Actor FDTNTBerserkUppercutPuff : FDBulletPuff
{ 
  DamageType "Melee"
  -NOEXTREMEDEATH
  States
  {
   SparkingTarget:
    TNT1 A 0 A_PlaySound("tntfist/uppercuthit", 7, 1, 0, 1.2)
	TNT1 A 0 A_GiveInventory ("FDTNTFistBerserkUppercutThrust", 1, AAPTR_TRACER)
	TNT1 A 0 A_JumpIf(CallACS("FD_quakes") == 0, 2)
    TNT1 A 0 A_Quake (1, 4, 0, 48, "")
	TNT1 A 10
	Stop
	
   BleedingTarget:
	TNT1 A 0 A_CheckFlag ("NOBLOOD", "SparkingTarget", AAPTR_TRACER)
	TNT1 A 0 A_GiveInventory ("FDTNTFistBerserkUppercutThrust", 1, AAPTR_TRACER)
	TNT1 A 0 A_JumpIf(CallACS("FD_quakes") == 0, 2)
    TNT1 A 0 A_Quake (1, 4, 0, 48, "")
    TNT1 A 0 A_PlaySound("tntfist/uppercutflesh", CHAN_WEAPON, 1, 0, 1.8)
    TNT1 A 0 A_PlaySound("tntfist/uppercuthit", 7, 1, 0, 1.2)
	TNT1 A 10
	Stop
  }
}

ACTOR FDTNTFistComboOne : Powerup
{
	Powerup.Duration 20
}

ACTOR FDTNTFistComboTwo : Powerup
{
	Powerup.Duration 20
}

ACTOR FDTNTFistUppercutThrust : FDCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 ThrustThingZ (0, 20, 0, 0)
	TNT1 A 0
    Stop
  }
}

ACTOR FDTNTFistBerserkUppercutThrust : FDCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 ThrustThingZ (0, 50, 0, 0)
	TNT1 A 0
    Stop
  }
}

Actor FDChainsawPuff : FDBulletPuff
{ 
  DamageType "Melee"
  States
  {
   BleedingTarget:
	TNT1 A 0 A_CheckFlag ("NOBLOOD", "Crash", AAPTR_TRACER)
    TNT1 A 0 A_PlaySound("doom2chainsaw/hitflesh", CHAN_WEAPON, 1, 0, 1.8)
	TNT1 A 0
	Stop
	
   SparkingTarget:
    TNT1 A 0 A_PlaySound("doom2chainsaw/hitwall", CHAN_WEAPON, (CallACS("FD_bulletvolume")/65536.0), 0, 1.2)
	TNT1 A 0 A_JumpIf(CallACS("FD_bulletpuffs") == 0, "NormalPuff")
	TNT1 A 0 A_JumpIf(CallACS("FD_bulletpuffs") == 2, 1)
	Goto FadeLoop
	TNT1 A 0 A_SpawnItemEx("FDGunSmoke",0,0,0, 0,0,frandom(0.1,0.3), 0, SXF_NOCHECKPOSITION)
    TNT1 A 0 A_Jump (256, 1,2,3,4,5,6,7)
    TNT1 AAAAAAA 0 A_SpawnItemEx ("FDBulletPuffSpark", frandom(-2.0,2.0),frandom(-2.0,2.0),frandom(-2.0,2.0) ,frandom(-5.0,5.0),frandom(-5.0,5.0),frandom(-1.0,4.0), 0, SXF_NOCHECKPOSITION)
    Goto FadeLoop
  }
}

Actor FDPlutBFGPuff : FDBulletPuff
{ 
  DamageType "Plasma"
  Decal "BFGLightning"
  Scale 1.25
  -NOEXTREMEDEATH
  +ALWAYSPUFF
  +EXTREMEDEATH
  States
  {
   Spawn:
   XDeath:
   Melee:
   Crash:
    TNT1 A 0
    TNT1 AAAAAAAAAAAAA 0 A_SpawnItemEx ("FDPlutBFGRayDelay", random(-256,256),random(-256,256),random(-256,256), 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_TRANSFERPOINTERS)
    TNT1 A 0 A_PlaySound("plutbfg9000/explode", 7, 0.5, 0, 0.2)
    TNT1 A 0 A_Explode(250, 256, 0, 1, 256)
	TNT1 A 0 A_JumpIf(CallACS("FD_quakes") == 0, 4)
    TNT1 A 0 A_Quake (1, 16, 0, 2048, "")
    TNT1 A 0 A_Quake (4, 12, 0, 1024, "")
    TNT1 A 0 A_Quake (8, 8, 0, 512, "")
	TNT1 A 0 A_JumpIf(CallACS("FD_particles") == 0, "DeathAnimation")
    TNT1 A 0 A_Jump (256, 1,2,3)
	TNT1 AAAAAA 0 A_SpawnParticle (ffff6b, SPF_FULLBRIGHT | SPF_RELATIVE, random(10,70), random(1,10), frandom(0,360), 0,0,0, frandom(0.2,12.0),frandom(-0.2,0.2),frandom(-6.0,6.0), 0,0,0, 0.98, -1)
    TNT1 A 0 A_Jump (256, 1,2,3)
	TNT1 AAAAAAAAAAAA 0 A_SpawnParticle (439337, SPF_FULLBRIGHT | SPF_RELATIVE, random(35,105), random(1,20), frandom(0,360), 0,0,0, frandom(0.2,12.0),frandom(-0.2,0.2),frandom(-6.0,6.0), 0,0,0, 0.98, -1)
    TNT1 A 0 A_Jump (256, 1,2,3)
	TNT1 AAAAAAAAAAAAAA 0 A_SpawnParticle (5fcf57, SPF_FULLBRIGHT | SPF_RELATIVE, random(35,105), random(1,20), frandom(0,360), 0,0,0, frandom(0.2,12.0),frandom(-0.2,0.2),frandom(-6.0,6.0), 0,0,0, 0.98, -1)
    TNT1 A 0 A_Jump (256, 1,2,3)
	TNT1 AAAAAAAA 0 A_SpawnParticle (ffffff, SPF_FULLBRIGHT | SPF_RELATIVE, random(10,70), random(1,10), frandom(0,360), 0,0,0, frandom(0.2,12.0),frandom(-0.2,0.2),frandom(-6.0,6.0), 0,0,0, 0.98, -1)
    TNT1 A 0 A_Jump (256, "DeathAnimation")
	Goto DeathAnimation
  DeathAnimation:
   DeathAnimation:
	BFXP AB 4 Bright
	BFXP CD 3 Bright
	BFXP EF 2 Bright
	Stop
  }
}

Actor FDTNTBFGRay : FDBulletPuff
{ 
  DamageType "Plasma"
  Decal "BFGLightning"
  Scale 0.75
  Alpha 0.5
  -NOEXTREMEDEATH
  +ALWAYSPUFF
  +MTHRUSPECIES
  +PUFFGETSOWNER
  States
  {
   Spawn:
   XDeath:
   Melee:
   Crash:
	TNT1 A 0 A_JumpIf(CallACS("FD_particles") == 0, "DeathAnimation")
    TNT1 A 0 A_Jump (256, 1,2,3)
	TNT1 AAAA 0 A_SpawnParticle (ffff6b, SPF_FULLBRIGHT | SPF_RELATIVE, random(10,70), random(1,10), frandom(0,360), 0,0,0, frandom(0.2,12.0),frandom(-0.2,0.2),frandom(-6.0,6.0), 0,0,0, 0.98, -1)
    TNT1 A 0 A_Jump (256, 1,2,3)
	TNT1 AAAAAAAA 0 A_SpawnParticle (439337, SPF_FULLBRIGHT | SPF_RELATIVE, random(35,105), random(1,20), frandom(0,360), 0,0,0, frandom(0.2,12.0),frandom(-0.2,0.2),frandom(-6.0,6.0), 0,0,0, 0.98, -1)
    TNT1 A 0 A_Jump (256, 1,2,3)
	TNT1 AAAAAAAAA 0 A_SpawnParticle (5fcf57, SPF_FULLBRIGHT | SPF_RELATIVE, random(35,105), random(1,20), frandom(0,360), 0,0,0, frandom(0.2,12.0),frandom(-0.2,0.2),frandom(-6.0,6.0), 0,0,0, 0.98, -1)
    TNT1 A 0 A_Jump (256, 1,2,3)
	TNT1 AAAAA 0 A_SpawnParticle (ffffff, SPF_FULLBRIGHT | SPF_RELATIVE, random(10,70), random(1,10), frandom(0,360), 0,0,0, frandom(0.2,12.0),frandom(-0.2,0.2),frandom(-6.0,6.0), 0,0,0, 0.98, -1)
    TNT1 A 0 A_Jump (256, "DeathAnimation")
	Goto DeathAnimation
  DeathAnimation:
	BFE2 ABCD 4 Bright
	Stop
  }
}

Actor FDTNTSimpleMaserPuff : FDBulletPuff
{ 
  DamageType "Plasma"
  Decal ""
  Scale 0.6
  -NOEXTREMEDEATH
  +ALWAYSPUFF
  +BLOODLESSIMPACT
  States
  {
   Spawn:
   XDeath:
   Melee:
   Crash:
    TNT1 A 5
	Stop
  }
}

Actor FDTNTPainlessSimpleMaserPuff : FDTNTSimpleMaserPuff
{ 
  +PAINLESS
}

Actor FDHarmlessPuff : BulletPuff // used for cosmetic lightning
{ 
  +THRUACTORS
  +NODAMAGETHRUST
  +BLOODLESSIMPACT
  +PAINLESS
  +NOTELEPORT
  States
  {
  Melee:
  Spawn:
    TNT1 A 5
    Stop
  }
}

Actor FDBulletPuffSpark
{ 
  +THRUACTORS
  +NOTELEPORT
//  +NOINTERACTION
  Radius 4
  Height 4
  RenderStyle Add
  Alpha 0.68
  Scale 0.02
  Gravity 0.7
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_SetScale (scalex * frandom(0.5,1.5))
  FadeLoop:
    OGLO A 1 Bright A_FadeTo (0, 0.05, 1)
    Loop
  }
}

//==============================================================================
//				GUN CASINGS
//==============================================================================
// Copied across from LegenDoom because I'm lazy

// Base is Wildweasel's casings from WW-Terror pls don't shoot lasers at me I just wanted nice casing physics
ACTOR FD9mmCasing
{
	PROJECTILE
	-NOGRAVITY
	-NOBLOCKMAP
	+THRUACTORS
    +NOTELEPORT
	BounceType Doom
	BounceSound "casings/bullet"
	WallBounceSound "casings/bullet"
	BounceFactor 0.15
	WallBounceFactor 0.08
	Mass 5
	Radius 3
	Height 3
	Scale 0.2
	States
	{
	Spawn:
		9MMC ABCDEFGH 2
		"####" A 0 A_JumpIf(waterlevel >= 1, 1)
		Loop
		"####" I 1 A_FadeTo(0, 0.1, 1)
		Loop
	Death:
		"####" A 0 A_ChangeFlag ("MOVEWITHSECTOR", 1)
		"####" A 0 A_Jump(256,"FadeOut1","FadeOut2")
	FadeOut1:
		"####" A 0 A_Jump (128, 2)
		"####" A 0 A_SetScale (scalex - (scalex * 2), scaley)
		"####" I 1000 A_SetTics (CallACS("FD_guncasingstimer")*35)
		"####" I 1 A_FadeTo(0, 0.01, 1)
		Wait
	FadeOut2:
		"####" A 0 A_Jump (128, 2)
		"####" A 0 A_SetScale (scalex - (scalex * 2), scaley)
		"####" J 1000 A_SetTics (CallACS("FD_guncasingstimer")*35)
		"####" J 1 A_FadeTo(0, 0.01, 1)
		Wait
	}
}
ACTOR FDSilent9mmCasing : FD9mmCasing
{
	BounceSound ""
	WallBounceSound ""
}

ACTOR FDTNTCasing : FD9mmCasing
{
	States
	{
	Spawn:
		TNTC ABCDEFGH 2
		"####" A 0 A_JumpIf(waterlevel >= 1, 1)
		Loop
		"####" I 1 A_FadeTo(0, 0.1, 1)
		Loop
	}
}

ACTOR FDSilentTNTCasing : FDTNTCasing
{
	BounceSound ""
	WallBounceSound ""
}

ACTOR FD9mmCasingSpawner
{
  Radius 4
  Height 4
  Speed 20
  Damage 0
  Projectile
  +THRUACTORS
  +NOCLIP
  +NOTELEPORT
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FD9mmCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(3,5), frandom(-55,-80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilent9mmCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(3,5), frandom(-55,-80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

ACTOR FDTNTCasingSpawner : FD9mmCasingSpawner
{
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FDTNTCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(3,5), frandom(-55,-80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilentTNTCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(3,5), frandom(-55,-80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

ACTOR FDTNTCasingSpawner2 : FD9mmCasingSpawner
{
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FDTNTCasing",0,0,0, frandom(7,8),frandom(1.5,2.5),frandom(3,5), frandom(55,80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilentTNTCasing",0,0,0, frandom(7,8),frandom(1.5,2.5),frandom(3,5), frandom(55,80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

ACTOR FDRevolverCasingSpawner : FD9mmCasingSpawner
{
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FD9mmCasing",0,0,0, frandom(-2,1),frandom(-0.5,0.5),frandom(-3,-1), 0, SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilent9mmCasing",0,0,0, frandom(-2,1),frandom(-0.5,0.5),frandom(-3,-1), 0, SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

ACTOR FDShellCasing : FD9mmCasing
{
	BounceSound "casings/shell"
	WallBounceSound "casings/shell"
	Scale 0.13
	States
	{
	Spawn:
		12GS ABCDEFGH 2
		"####" A 0 A_JumpIf(waterlevel >= 1, 1)
		Loop
		"####" I 1 A_FadeTo(0, 0.1, 1)
		Loop
	}
}

ACTOR FDSilentShellCasing : FDShellCasing
{
	BounceSound ""
	WallBounceSound ""
}

ACTOR FDTNTShellCasing : FD9mmCasing
{
	BounceSound "casings/shell"
	WallBounceSound "casings/shell"
	Scale 0.13
	States
	{
	Spawn:
		TNTS ABCDEFGH 2
		"####" A 0 A_JumpIf(waterlevel >= 1, 1)
		Loop
		"####" I 1 A_FadeTo(0, 0.1, 1)
		Loop
	}
}

ACTOR FDSilentTNTShellCasing : FDTNTShellCasing
{
	BounceSound ""
	WallBounceSound ""
}

ACTOR FDShellCasingSpawner : FD9mmCasingSpawner
{
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FDShellCasing",0,0,0, frandom(7,8),frandom(-2.5,-1.5),frandom(3,5), frandom(75,110), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilentShellCasing",0,0,0, frandom(7,8),frandom(-2.5,-1.5),frandom(3,5), frandom(75,110), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

ACTOR FDShellCasingSpawner2 : FD9mmCasingSpawner
{
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FDShellCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(-3,-5), frandom(-140,-180), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilentShellCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(-3,-5), frandom(-140,-180), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

ACTOR FDShellCasingSpawner3 : FD9mmCasingSpawner
{
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FDShellCasing",0,0,0, frandom(7,8),frandom(-2.5,-1.5),frandom(3,5), frandom(-75,-110), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilentShellCasing",0,0,0, frandom(7,8),frandom(-2.5,-1.5),frandom(3,5), frandom(-75,-110), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

ACTOR FDTNTShellCasingSpawner : FD9mmCasingSpawner
{
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FDTNTShellCasing",0,0,0, frandom(7,8),frandom(-2.5,-1.5),frandom(3,5), frandom(75,110), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilentTNTShellCasing",0,0,0, frandom(7,8),frandom(-2.5,-1.5),frandom(3,5), frandom(75,110), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

ACTOR FDTNTShellCasingSpawner2 : FD9mmCasingSpawner
{
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FDTNTShellCasing",0,0,0, frandom(7,8),frandom(-2.5,-1.5),frandom(3,5), frandom(-75,-110), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilentTNTShellCasing",0,0,0, frandom(7,8),frandom(-2.5,-1.5),frandom(3,5), frandom(-75,-110), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

ACTOR FD556mmSmallCasing : FD9mmCasing
{
	BounceSound "casings/chaingun"
	WallBounceSound "casings/chaingun"
	Scale 0.13
	States
	{
	Spawn:
		556C ABCDEFGH 2
		"####" A 0 A_JumpIf(waterlevel >= 1, 1)
		Loop
		"####" I 1 A_FadeTo(0, 0.1, 1)
		Loop
	}
}

ACTOR FDSilent556mmSmallCasing : FD556mmSmallCasing
{
	BounceSound ""
	WallBounceSound ""
}

ACTOR FD556mmSmallCasingSpawner : FD9mmCasingSpawner
{
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FD556mmSmallCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(3,5), frandom(-55,-80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilent556mmSmallCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(3,5), frandom(-55,-80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

ACTOR FD556mmCasing : FD9mmCasing
{
	BounceSound "casings/chaingun"
	WallBounceSound "casings/chaingun"
	Scale 0.2
	States
	{
	Spawn:
		556C ABCDEFGH 2
		"####" A 0 A_JumpIf(waterlevel >= 1, 1)
		Loop
		"####" I 1 A_FadeTo(0, 0.1, 1)
		Loop
	}
}

ACTOR FDSilent556mmCasing : FD556mmCasing
{
	BounceSound ""
	WallBounceSound ""
}

ACTOR FD556mmCasingSpawner : FD9mmCasingSpawner
{
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FD556mmCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(3,5), frandom(-55,-80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilent556mmCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(3,5), frandom(-55,-80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

ACTOR FDGrenadeCasing : FD9mmCasing
{
	BounceSound "casings/shell" // could've sworn I had grenade casing sounds kicking around, but I can't goddamn find them
	WallBounceSound "casings/shell"
	Scale 0.2
	States
	{
	Spawn:
		40MM ABCDEFGH 2
		"####" A 0 A_JumpIf(waterlevel >= 1, 1)
		Loop
		"####" I 1 A_FadeTo(0, 0.1, 1)
		Loop
		
	Death:
		"####" A 0 A_Jump(256,"FadeOut1","FadeOut2","FadeOut3","FadeOut4")
	FadeOut1:
		"####" A 0 A_Jump (128, 2)
		"####" A 0 A_SetScale (scalex - (scalex * 2), scaley)
		"####" I 1000 A_SetTics (CallACS("FD_guncasingstimer")*35)
		"####" I 1 A_FadeTo(0, 0.01, 1)
		Wait
	FadeOut2:
		"####" A 0 A_Jump (128, 2)
		"####" A 0 A_SetScale (scalex - (scalex * 2), scaley)
		"####" J 1000 A_SetTics (CallACS("FD_guncasingstimer")*35)
		"####" J 1 A_FadeTo(0, 0.01, 1)
		Wait
	FadeOut3:
		"####" A 0 A_Jump (128, 2)
		"####" A 0 A_SetScale (scalex - (scalex * 2), scaley)
		"####" K 1000 A_SetTics (CallACS("FD_guncasingstimer")*35)
		"####" K 1 A_FadeTo(0, 0.01, 1)
		Wait
	FadeOut4:
		"####" A 0 A_Jump (128, 2)
		"####" A 0 A_SetScale (scalex - (scalex * 2), scaley)
		"####" L 1000 A_SetTics (CallACS("FD_guncasingstimer")*35)
		"####" L 1 A_FadeTo(0, 0.01, 1)
		Wait
	}
}

ACTOR FDSilentGrenadeCasing : FDGrenadeCasing
{
	BounceSound ""
	WallBounceSound ""
}

ACTOR FDGrenadeCasingSpawner : FD9mmCasingSpawner
{
  States
  {
  Spawn:
    TNT1 A 1
  Death:
	TNT1 A 0 A_JumpIf(CallACS("FD_casingsound") == 0, "SilentCasing")
    TNT1 A 0 A_SpawnItemEx("FDGrenadeCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(3,5), frandom(-55,-80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  SilentCasing:
    TNT1 A 0 A_SpawnItemEx("FDSilentGrenadeCasing",0,0,0, frandom(7,8),frandom(2.5,1.5),frandom(3,5), frandom(-55,-80), SXF_NOCHECKPOSITION | SXF_ORIGINATOR)
    Stop
  }
}

//==============================================================================
//				GUN SMOKE
//==============================================================================
// Copied across from LegenDoom because I'm lazy

ACTOR FDGunSmoke
{
	PROJECTILE
	+THRUACTORS
	+NOTELEPORT
    +DONTSPLASH
	Speed 20
	Radius 3
	Height 3
	RenderStyle Translucent
	Alpha 0.25
	Scale 0.3
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_ScaleVelocity (0.01)
		TNT1 A 0 A_SetScale (scalex * frandom(0.08,0.14))
		TNT1 A 0 A_Jump (128, 2)
		TNT1 A 0 A_SetScale (scalex - (scalex * 2), scaley)
		SMOK ABCDEFGHIJKLMNOPQ 1 A_FadeTo(0, 0.01, 1)
		Stop
	}
}

ACTOR FDGunSmokeSpawner : FD9mmCasingSpawner
{
  Speed 7
  States
  {
  Spawn:
    TNT1 A 1
//	TNT1 A 0 A_SetPitch (velz, 0)
  Death:
    TNT1 A 0 A_SpawnItemEx("FDGunSmoke",0,0,0, velx,vely+frandom(-0.2,0.2),velz, 0, SXF_NOCHECKPOSITION | SXF_ORIGINATOR | SXF_ABSOLUTEVELOCITY)
    TNT1 AA 0 A_SpawnItemEx("FDGunSmoke",0,0,0, velx+frandom(0.2,0.2),vely+frandom(-0.2,0.2),velz, 0, SXF_NOCHECKPOSITION | SXF_ORIGINATOR | SXF_ABSOLUTEVELOCITY)
    Stop
  }
}

ACTOR FDTNTMissileTrail : FDGunSmoke
{
	Alpha 0.35
	Scale 0.3
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SetScale (scalex * frandom(0.95,1.05))
		TNT1 A 0 A_Jump (128, 2)
		TNT1 A 0 A_SetScale (scalex - (scalex * 2), scaley)
		WEXP ABCDEF 1 A_FadeTo(0, 0.01, 1)
		Stop
	}
}

//==============================================================================
//				WEAPON INHERITANCE
//==============================================================================

ACTOR FDWeapon : Weapon
{
  Weapon.Kickback 100
   // Bobstyle shamelessly stolen from some cop while he was distracted fighting terrorists
   // Or more likely, from Wildweasel's Terrorists!
  Weapon.BobStyle Alpha
  Weapon.BobSpeed 2.5
  Weapon.BobRangeX 0.2
  Weapon.BobRangeY 0.5
  Weapon.UpSound "items/weaponswap1"
  Inventory.Pickupmessage ""
  Inventory.PickupSound ""
  Weapon.AmmoGive 0
  Weapon.AmmoUse 1
  +AMMO_OPTIONAL
  +NOALERT
//  +CHEATNOTWEAPON
  +NOTIMEFREEZE
  States
  {
  Ready:
    "####" "#" 1 A_TakeInventory ("FDWeapon", 1)
    Goto Deselect
  Select:
    "####" "#" 1 A_Raise
    Loop
  Deselect:
    "####" "#" 1 A_Lower
    Loop
  Fire:
    "####" "#" 1
    Goto Ready
  }
}

ACTOR FDBFGWeapon : FDWeapon
{
  Weapon.BobRangeX 0.08
  Weapon.BobRangeY 0.15
}

ACTOR FDNoFists replaces Fist
{
}

ACTOR FDNoPistol replaces Pistol
{
}

//==============================================================================
//				ITEM VISUALS INHERITANCE
//==============================================================================

actor FDItemVisualPlutonia
{
	Radius 16
	Height 8
	VisibleToPlayerClass "FDPlutPlayer"
	+THRUACTORS
	+NOCLIP
    +FORCEYBILLBOARD
	+NOTONAUTOMAP
    +DONTSPLASH
	+NOTELEPORT
    States
    {
    Spawn:
	    TNT1 A 1
	    TNT1 A 0 A_Jump(256, "Check")
		Goto Check
    Check:
        TNT1 A 0 A_CheckFlag("SPECIAL", 1, AAPTR_MASTER)
        Stop
    Warp:
        TNT1 A 0 A_Warp(AAPTR_MASTER, 0, 0, 0, 0, WARPF_INTERPOLATE | WARPF_COPYINTERPOLATION | WARPF_NOCHECKPOSITION, "Spawn")
        Stop
    }
}

actor FDItemVisualTNT : FDItemVisualPlutonia
{
	VisibleToPlayerClass "FDTNTPlayer"
}

actor FDItemVisualDoom2 : FDItemVisualPlutonia
{
	VisibleToPlayerClass "FDDoom2Player"
}

//==============================================================================

#include "decorate/weaponitems.dec"
#include "decorate/ammo.dec"
#include "decorate/keys.dec"
#include "decorate/items.dec"

#include "decorate/plutonia/fist.dec"
#include "decorate/plutonia/chainsaw.dec"
#include "decorate/plutonia/pistol.dec"
#include "decorate/plutonia/shotgun.dec"
#include "decorate/plutonia/supershotgun.dec"
#include "decorate/plutonia/chaingun.dec"
#include "decorate/plutonia/rocketlauncher.dec"
#include "decorate/plutonia/plasmarifle.dec"
#include "decorate/plutonia/bfg9000.dec"

#include "decorate/TNT/fist.dec"
#include "decorate/TNT/chainsaw.dec"
#include "decorate/TNT/pistol.dec"
#include "decorate/TNT/shotgun.dec"
#include "decorate/TNT/supershotgun.dec"
#include "decorate/TNT/chaingun.dec"
#include "decorate/TNT/rocketlauncher.dec"
#include "decorate/TNT/plasmarifle.dec"
#include "decorate/TNT/bfg9000.dec"

#include "decorate/doom2/fist.dec"
#include "decorate/doom2/chainsaw.dec"
#include "decorate/doom2/pistol.dec"
#include "decorate/doom2/shotgun.dec"
#include "decorate/doom2/supershotgun.dec"
#include "decorate/doom2/chaingun.dec"
#include "decorate/doom2/rocketlauncher.dec"
#include "decorate/doom2/plasmarifle.dec"
#include "decorate/doom2/bfg9000.dec"
