ACTOR SFortGrenadeLauncher : GrenadeLauncher
{
  Weapon.SelectionOrder 500
  Inventory.RestrictedTo "DemolitionerPlayer"
  Tag "Grenade Launcher"
  -WEAPON.NOAUTOFIRE
  +WEAPON.NOAUTOAIM
  +WEAPON.NOLMS
  +WEAPON.ALLOW_WITH_RESPAWN_INVUL
  States
  {
  Ready:
	GRLG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
	Loop
  Deselect:
    GRLG A 0 A_Lower
    Loop
  Select:
    GRLG A 1 A_Raise
    Loop
  Fire:
    //GRLG B 3
	TNT1 A 0 A_GunFlash
    TNT1 A 0 A_TakeInventory("PowerInvulnerable",1)
    TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
    GRLG B 20 A_FireCustomMissile("SFortGrenade",0,1,0,0,0,5)
    TNT1 A 0 A_ReFire
    Goto Ready
  AltFire:
    TNT1 A 0 A_PlaySound("Weapons/PipeBeep")
    PRXL D 2 A_GiveInventory("DetonatePipe", 1)
    PRXL E 2 A_TakeInventory("DetonatePipe", 99)
    PRXL A 12 A_WeaponReady(WRF_NOPRIMARY|WRF_NOSECONDARY|WRF_NOBOB)
    Goto Ready
  Quad:
    TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO)
    Goto Fire+3
  Flash:
    GRLF A 3 bright A_Light1
    GRLF B 3 bright
    GRLF CD 3 bright A_Light2
    Goto LightDone
  Reload:
    TNT1 A 0 A_Print("$INFO_DEMOLITIONER",0.0625)
    Goto Ready
  }
}

ACTOR SFortGrenade : Grenade replaces Grenade
{
  ProjectileKickBack 300
  Damage (0)
  Speed 30
  Gravity 0.3
  Decal Scorch
  Decal BigScorch
  +DEHEXPLOSION
  States
  {
  Spawn:
    SGRN A 105 Bright
	SGRN A 1 Bright A_Die
    Goto Death
  Death:
    TNT1 A 0 A_Scream
    TNT1 A 0 A_PlaySound("weapons/debris",CHAN_BODY)
	TNT1 A 0 A_ChangeVelocity(0,0,0,CVF_REPLACE)
	TNT1 A 0 A_ChangeFlag(NOGRAVITY,1)
	MISL B 8 Bright A_Explode(128,128,1,0,32)
    MISL C 6 Bright
    MISL D 4 Bright
    Stop
  }
}

ACTOR SFortStickyBombLauncher : Weapon
{
  Inventory.PickupSound "misc/w_pkup"
  Inventory.PickupMessage "You got the Sticky Bomb Launcher!"
  Inventory.RestrictedTo "DemolitionerPlayer"
  Tag "Sticky Bomb Launcher"
  Obituary "%o couldn't see %k's sticky bombs."
  Weapon.AmmoType1 "RocketAmmo"
  Weapon.AmmoType2 "StickyBomb"
  Weapon.AmmoGive1 6
  Weapon.AmmoGive2 0
  Weapon.AmmoUse1 1
  Weapon.AmmoUse2 0
  Weapon.KickBack 200
  Weapon.SelectionOrder 900
  +WEAPON.AMMO_OPTIONAL
  +WEAPON.ALT_AMMO_OPTIONAL
  +WEAPON.NOAUTOAIM
  +WEAPON.NOLMS
  +WEAPON.ALLOW_WITH_RESPAWN_INVUL
  States
  {
  Spawn:
    PRXP A -1
    Loop
  Ready:
    PRXL A 1 A_WeaponReady(WRF_ALLOWRELOAD)
    Loop
  Select:
    PRXL A 1 A_Raise
    Loop
  Deselect:
    TNT1 A 0 A_Lower
    Loop
  Fire:
	TNT1 A 0 A_JumpIfNoAmmo("Ready")
	TNT1 A 0 A_JumpIfInventory("StickyBomb",10,"Ready")
	TNT1 A 0 A_TakeInventory("PowerInvulnerable",1)
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	TNT1 A 0 A_TakeInventory("DetonatePipe",99)
    TNT1 A 0 A_PlaySound("Weapons/PipeFire")
    TNT1 A 0 A_JumpIfInventory("BlueTeamToken",1,"BlueFire")
    //TNT1 A 0 A_JumpIfInventory("RedTeamToken",1,"RedFire")
    TNT1 A 0 A_JumpIfInventory("GreenTeamToken",1,"GreenFire")
    TNT1 A 0 A_JumpIfInventory("GoldTeamToken",1,"GoldFire")
	Goto RedFire // If no team game is played, color the mines always red.
  BlueFire:
    PRXL B 4 A_FireCustomMissile("BlueBombProj",frandom(-1,1),1,0,0,0,4)
	Goto FireEnd
  RedFire:
    PRXL B 4 A_FireCustomMissile("RedBombProj",frandom(-1,1),1,0,0,0,4)
	Goto FireEnd
  GreenFire:
    PRXL B 4 A_FireCustomMissile("GreenBombProj",frandom(-1,1),1,0,0,0,4)
	Goto FireEnd
  GoldFire:
    PRXL B 4 A_FireCustomMissile("GoldBombProj",frandom(-1,1),1,0,0,0,4)
	Goto FireEnd
  FireEnd:
    PRXL CDE 4 A_WeaponReady(WRF_NOPRIMARY|WRF_NOBOB)
    PRXL A 6 A_WeaponReady(WRF_NOPRIMARY|WRF_NOBOB)
    PRXL A 1 A_ReFire
    Goto Ready
  Quad:
    TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO)
	Goto Fire+4
  AltFire:
    TNT1 A 0 A_PlaySound("Weapons/PipeBeep")
    PRXL D 2 A_GiveInventory("DetonatePipe", 1)
    PRXL E 2 A_TakeInventory("DetonatePipe", 99)
    PRXL A 12 A_WeaponReady(WRF_NOPRIMARY|WRF_NOSECONDARY|WRF_NOBOB)
    Goto Ready
  Reload:
    TNT1 A 0 A_Print("$INFO_DEMOLITIONER",0.0625)
    Goto Ready
  }
}

ACTOR BlueBombProj
{
  Radius 3
  Height 6
  Damage (0)
  DamageType "Grenade"
  Speed 35
  Scale 0.5
  Obituary "%o couldn't see %k's sticky bombs."
  SelfObituary "%o went kaboom with %p own sticky bombs."
  Projectile
  ProjectileKickBack 400
  //BounceFactor 0.0
  //Decal Scorch
  //Decal BigScorch
  //+HEXENBOUNCE
  //+CANBOUNCEWATER
  //+EXPLODEONWATER
  //+BOUNCEONACTORS
  //+SKYEXPLODE
  +DEHEXPLOSION
  +THRUGHOST
  -NOGRAVITY
  -SLIDESONWALLS
  States
  {
  Spawn:
    SBBL ABC 1
    Loop
  Death:
    TNT1 A 0 A_CustomMissile("BluePlantedBomb", 0, 0, 0, CMF_TRACKOWNER)
	TNT1 A 0 A_GiveInventory("StickyBomb",1,AAPTR_TARGET)
    SBBL D 1 A_PlaySound("Weapons/PipeHit")
    Stop
  XDeath:
    TNT1 A 0 A_Stop
	//TNT1 A 0 A_TakeInventory("StickyBomb",1,0,AAPTR_TARGET)
	TNT1 A 0 A_PlaySound("weapons/debris",CHAN_BODY)
    TNT1 A 0 A_PlaySound("weapons/rocklx",CHAN_VOICE)
    TNT1 A 0 A_NoGravity
	TNT1 A 0 A_SetScale(1.25)
	TNT1 A 0 A_SetDamageType("Grenade")
    MISL B 8 Bright A_Explode(128,160,1,0,32)
	MISL C 6 Bright
	MISL D 4 Bright
    Stop
  }
}

ACTOR RedBombProj : BlueBombProj
{
  States
  {
  Spawn:
    SBRE ABC 1
    Loop
  Death:
    TNT1 A 0 A_CustomMissile("RedPlantedBomb", 0, 0, 0, CMF_TRACKOWNER)
	TNT1 A 0 A_GiveInventory("StickyBomb",1,AAPTR_TARGET)
    SBRE D 1 A_PlaySound("Weapons/PipeHit")
    Stop
  }
}

ACTOR GreenBombProj : BlueBombProj
{
  States
  {
  Spawn:
    SBGR ABC 1 
    Loop
  Death:
    TNT1 A 0 A_CustomMissile("GreenPlantedBomb", 0, 0, 0, CMF_TRACKOWNER)
	TNT1 A 0 A_GiveInventory("StickyBomb",1,AAPTR_TARGET)
    SBGR D 1 A_PlaySound("Weapons/PipeHit")
    Stop
  }
}

ACTOR GoldBombProj : BlueBombProj
{
  States
  {
  Spawn:
    SBYE ABC 1 
    Loop
  Death:
    TNT1 A 0 A_CustomMissile("GoldPlantedBomb", 0, 0, 0, CMF_TRACKOWNER)
	TNT1 A 0 A_GiveInventory("StickyBomb",1,AAPTR_TARGET)
    SBYE D 1 A_PlaySound("Weapons/PipeHit")
    Stop
  }
}

ACTOR BluePlantedBomb
{
  Radius 3
  Height 3
  Damage (0)
  DamageType "Grenade"
  Speed 0
  Scale 0.5
  Obituary "%o couldn't see %k's sticky bombs."
  SelfObituary "%o went kaboom with %p own sticky bombs."
  Projectile
  ProjectileKickBack 400
  Decal Scorch
  Decal BigScorch
  //WallBounceFactor 0.5
  +CanBounceWater
  +MoveWithSector
  +HexenBounce
  +ThruGhost
  +NoTarget
  +DEHEXPLOSION
  -MISSILE
  -SlidesOnWalls
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_Stop
  SpawnLoop:
    SBBL D 2 A_JumpIfInTargetInventory("DetonatePipe", 1, "Death") //Destroys the mine if the player uses Altfire.
    TNT1 A 0 A_JumpIfInTargetInventory("DemolitionerToken", 1, "SpawnLoop") //Destroys if the player is dead, this is used to avoid ownership issues on respawn.
    Goto Death
  Death:
    SBBL D 1 A_PlaySound("Weapons/PipeBeep")
    SBBL AD 1
	Goto Death2
  Death2:
	TNT1 A 0 A_TakeInventory("StickyBomb",1,0,AAPTR_TARGET)
	TNT1 A 0 A_PlaySound("weapons/debris",CHAN_BODY)
    TNT1 A 0 A_PlaySound("weapons/rocklx")
    TNT1 A 0 A_NoGravity
	TNT1 A 0 A_SetTranslucent(0.75)
	TNT1 A 0 A_SetScale(1.25)
	TNT1 A 0 A_SetDamageType("Grenade")
    MISL B 8 Bright A_Explode(128,160,1,0,32)
	MISL C 6 Bright
	MISL D 4 Bright
    Stop
  }
}

ACTOR RedPlantedBomb : BluePlantedBomb
{
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_Stop
  SpawnLoop:
    SBRE D 2 A_JumpIfInTargetInventory("DetonatePipe", 1, "Death") //Destroys the mine if the player uses Altfire.
    TNT1 A 0 A_JumpIfInTargetInventory("DemolitionerToken", 1, "SpawnLoop") //Destroys if the player is dead, this is used to avoid ownership issues on respawn.
    Goto Death
  Death:
    SBRE D 1 A_PlaySound("Weapons/PipeBeep")
    SBRE AD 1
	Goto Death2
  }
}

ACTOR GreenPlantedBomb : BluePlantedBomb
{
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_Stop
  SpawnLoop:
    SBGR D 2 A_JumpIfInTargetInventory("DetonatePipe", 1, "Death") //Destroys the mine if the player uses Altfire.
    TNT1 A 0 A_JumpIfInTargetInventory("DemolitionerToken", 1, "SpawnLoop") //Destroys if the player is dead, this is used to avoid ownership issues on respawn.
    Goto Death
  Death:
    SBGR D 1 A_PlaySound("Weapons/PipeBeep")
    SBGR AD 1
	Goto Death2
  }
}

ACTOR GoldPlantedBomb : BluePlantedBomb
{
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_Stop
  SpawnLoop:
    SBYE D 2 A_JumpIfInTargetInventory("DetonatePipe", 1, "Death") //Destroys the mine if the player uses Altfire.
    TNT1 A 0 A_JumpIfInTargetInventory("DemolitionerToken", 1, "SpawnLoop") //Destroys if the player is dead, this is used to avoid ownership issues on respawn.
    Goto Death
  Death:
    SBYE D 1 A_PlaySound("Weapons/PipeBeep")
	SBYE AD 1
	Goto Death2
  }
}

ACTOR DemolitionerToken : Inventory {}

ACTOR Planted : Inventory {}

ACTOR DetonatePipe : Inventory {Inventory.MaxAmount 1}

ACTOR DemolitionerFist : SFortFist
{
  Inventory.RestrictedTo "DemolitionerPlayer"
  States
  {
  AltFire:
    TNT1 A 0 A_PlaySound("Weapons/PipeBeep")
    PRXL D 2 A_GiveInventory("DetonatePipe", 1)
    PRXL E 2 A_TakeInventory("DetonatePipe", 99)
    PRXL A 12 A_WeaponReady(WRF_NOPRIMARY|WRF_NOSECONDARY|WRF_NOBOB)
    Goto Ready
  Reload:
    TNT1 A 0 A_Print("$INFO_DEMOLITIONER",0.0625)
    Goto Ready
  }
}

ACTOR DemolitionerPistol : SFortPistol
{
	Inventory.RestrictedTo "DemolitionerPlayer"
	States
	{
	AltFire:
      TNT1 A 0 A_PlaySound("Weapons/PipeBeep")
      PRXL D 2 A_GiveInventory("DetonatePipe", 1)
      PRXL E 2 A_TakeInventory("DetonatePipe", 99)
      PRXL A 12 A_WeaponReady(WRF_NOPRIMARY|WRF_NOSECONDARY|WRF_NOBOB)
      Goto Ready
	Reload:
	  TNT1 A 0 A_Print("$INFO_DEMOLITIONER",0.0625)//TNT1 A 0 ACS_NamedExecuteAlways("ClassInfo_Enter",0)
	  Goto Ready
	}
}

ACTOR DemolitionerShotgun : SFortShotgun
{
  Inventory.RestrictedTo "DemolitionerPlayer"
  States
  {
  Fire:
  FireNormal:
	TNT1 A 0 A_JumpIfInventory("ShotgunCooldown",1,"Ready")
    TNT1 A 0 A_GiveInventory("ShotgunCooldown")
	TNT1 A 0 A_TakeInventory("PowerInvulnerable",1)
    //SHTG A 3
	TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"Quad")
	TNT1 A 0 A_GunFlash
	TNT1 A 0 A_FireBullets(0.0,0.0,1,12,"SFortBulletPuff",FBF_NORANDOM)
    TNT1 A 0 A_FireBullets(5.6,1.75,9,12,"SFortBulletPuff",FBF_NORANDOM|FBF_USEAMMO)
	SHTG A 7
  FireReload:
    SHTG BC 5 A_WeaponReady(WRF_NOPRIMARY|WRF_NOBOB)
	TNT1 A 0 A_PlaySound("weapons/shotgr",CHAN_WEAPON)
    SHTG D 4 A_WeaponReady(WRF_NOPRIMARY|WRF_NOBOB)
	TNT1 A 0 A_TakeInventory("ShotgunReload")
    SHTG CB 5 A_WeaponReady(WRF_NOPRIMARY|WRF_NOBOB)
    SHTG A 6 A_WeaponReady(WRF_NOPRIMARY|WRF_NOBOB) //3
	TNT1 A 0 A_TakeInventory("ShotgunCooldown")
    SHTG A 1 A_ReFire
    Goto Ready
  Quad:
    TNT1 A 0 A_Playsound("misc/qdmg",CHAN_AUTO)
	Goto FireNormal+4 //+5
  AltFire:
    TNT1 A 0 A_PlaySound("Weapons/PipeBeep")
    PRXL D 2 A_GiveInventory("DetonatePipe", 1)
    PRXL E 2 A_TakeInventory("DetonatePipe", 99)
    PRXL A 12 A_WeaponReady(WRF_NOPRIMARY|WRF_NOSECONDARY|WRF_NOBOB)
    Goto Ready
  Reload:
    TNT1 A 0 A_Print("$INFO_DEMOLITIONER",0.0625)
    Goto Ready
  }
}

ACTOR DemolitionerNailgun : SFortNailgun
{
  Inventory.RestrictedTo "DemolitionerPlayer"
  States
  {
  AltFire:
    TNT1 A 0 A_PlaySound("Weapons/PipeBeep")
    PRXL D 2 A_GiveInventory("DetonatePipe", 1)
    PRXL E 2 A_TakeInventory("DetonatePipe", 99)
    PRXL A 12 A_WeaponReady(WRF_NOPRIMARY|WRF_NOSECONDARY|WRF_NOBOB)
    Goto Ready
  Reload:
    TNT1 A 0 A_Print("$INFO_DEMOLITIONER",0.0625)
    Goto Ready
  }
}