///////////////////
// VOTING PISTOL //
///////////////////
actor StrVotingDevice : Weapon
{
    Tag "Voting Device"
    +UNDROPPABLE
    +NOALERT
    +CHEATNOTWEAPON
    States
    {
      Ready:
        PISG A 1 A_WeaponReady
        loop

      Deselect:
        TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_Lower
        TNT1 A 1 A_Lower
        loop

      Select:
        TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_Raise
        TNT1 A 1 A_Raise
        loop

      Fire:
        TNT1 A 0 ACS_NamedExecuteWithResult("StrVotingPistol", 1)
        goto FireFinish

      AltFire:
        TNT1 A 0 ACS_NamedExecuteWithResult("StrVotingPistol", 2)

      FireFinish:
        PISG BCB 3
        TNT1 A 0 A_TakeInventory("StrVotingDevice")
        goto Ready

      Spawn:
        PIST A -1
        stop
    }
}

actor StrAlreadyGotCredits : Inventory { Inventory.MaxAmount 1 +UNDROPPABLE -INVBAR }

actor StrBackpackCooldownTimer : Inventory { Inventory.MaxAmount 0x7FFFFFFF +UNDROPPABLE -INVBAR } // in case any other patch implements troll-proof pickups

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// REPLACEMENT WEAPONS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ACTOR StrMarineAllyProtection : PowerProtection
{
	Powerup.Duration 0x7FFFFFFF
	DamageFactor "MarineAlly", 0
	Damagefactor "Bossfactor", 0
}

ACTOR AutoShotgun : RandomSpawner 5118
{
  DropItem "SuperShotgun"
}

ACTOR LandMineLayer : RandomSpawner 25084
{
  DropItem "Chainsaw"
}

ACTOR DERLauncher : RandomSpawner
{
  DropItem "RocketLauncher"
}

ACTOR HRL : RandomSpawner 20103
{
  DropItem "RocketLauncher"
}

ACTOR DEPlasmaRifle : RandomSpawner
{
  DropItem "PlasmaRifle"
}

ACTOR StunnerRifle
{
  +NOBLOCKMAP
  +NOSECTOR
  +NOGRAVITY
  +THRUACTORS
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_SpawnItemEx("Berserk", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
    TNT1 A 0 A_SpawnItemEx("Berserk", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
    TNT1 A 0 A_SpawnItemEx("Allmap", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
    TNT1 A 0 A_SpawnItemEx("Backpack", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
	Stop
  }
}

ACTOR Railgun : RandomSpawner 20102
{
  DropItem "PlasmaRifle"
}

ACTOR DEBFG9000 : RandomSpawner
{
  DropItem "BFG9000"
}

ACTOR Flamer : RandomSpawner 20105
{
  DropItem "PlasmaRifle"
}

ACTOR PyroCannon : RandomSpawner 20107
{
  DropItem "BFG9000"
}

ACTOR Repeater : RandomSpawner 20100
{
  DropItem "PlasmaRifle"
}

ACTOR Devastator : RandomSpawner 20101
{
  DropItem "BFG9000"
}

ACTOR Mines 25085
{
  +NOBLOCKMAP
  +NOSECTOR
  +NOGRAVITY
  +THRUACTORS
  States
  {
  Spawn:
    TNT1 A 0
	TNT1 A 0 A_Jump(128, "BigRocket")
    TNT1 A 0 A_SpawnItemEx("RocketAmmo", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
    TNT1 A 0 A_SpawnItemEx("Clip", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
    TNT1 A 0 A_SpawnItemEx("Shell", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
	Stop
  BigRocket:
    TNT1 A 0 A_SpawnItemEx("RocketBox", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
	Stop
  }
}

ACTOR Gas 22106
{
  +NOBLOCKMAP
  +NOSECTOR
  +NOGRAVITY
  +THRUACTORS
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_SpawnItemEx("RocketAmmo", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
    TNT1 A 0 A_SpawnItemEx("Cell", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
	Stop
  }
}

ACTOR Fuel 22107
{
  +NOBLOCKMAP
  +NOSECTOR
  +NOGRAVITY
  +THRUACTORS
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 A 0 A_SpawnItemEx("RocketBox", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
    TNT1 A 0 A_SpawnItemEx("CellPack", 0, 0, 0, frandom(0,2), frandom(0,2), frandom(0,2), frandom(0,360), SXF_NOCHECKPOSITION, 0)
	Stop
  }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// MARINE REINFORCEMENTS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Actor MarineItem : CustomInventory 25003
{
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up some marine reinforcements."
  inventory.maxamount 10
  Tag "Marine Reinforcements"
  inventory.icon MARIA0
  +INVENTORY.INVBAR
  Scale 0.75
  States
  {
  Spawn:
   	MARP A -1 BRIGHT
    	Stop
  Use:
        TNT1 A 1 A_SpawnItem("TeleportFog", 64, 16, 0, 0)
        TNT1 A 0 A_Jump(128, "Tier2")
        TNT1 A 0 A_Jump(256, "Shotgun", "Chaingun")
		Goto Shotgun
	Shotgun: //25% (1/4)
        TNT1 A 0 A_SpawnItem("STMarineShotgun", 64, 16, 0, 1)
		Stop
	Chaingun: //25% (1/4)
        TNT1 A 0 A_SpawnItem("STMarineChaingun", 64, 16, 0, 1)
		Stop
	Tier2:
        TNT1 A 0 A_Jump(128, "Tier3")
		TNT1 A 0 A_Jump(25, "Flamer")
		TNT1 A 0 A_Jump(256, "SSG", "ASG")
		Goto SSG
	SSG: //11.25% (9/80)
        TNT1 A 0 A_SpawnItem("STMarineSSG", 64, 16, 0, 1)
		Stop
	ASG: //11.25% (9/80)
		TNT1 A 0 A_SpawnItem("STMarineAutoShotgun", 64, 16, 0, 1)
		Stop
	Flamer: //5% (4/80 -> 1/20)
		TNT1 A 0 A_SpawnItem("STMarineFlamer", 64, 16, 0, 1)
		Stop
	Tier3:
        TNT1 A 0 A_Jump(128, "Tier4")
		TNT1 A 0 A_Jump(51, "HRL")
		Goto Rocket
	Rocket: //10% (4/40 -> 2/20)
        TNT1 A 0 A_SpawnItem("STMarineRocket", 64, 16, 0, 1)
		Stop
	HRL: //2.5% (1/40)
		TNT1 A 0 A_SpawnItem("STMarineHRL", 64, 16, 0, 1)
		Stop
	Tier4:
		TNT1 A 0 A_Jump(51, "Repeater")
		TNT1 A 0 A_Jump(256, "Plasma", "Railgun")
		Goto Plasma
	Plasma: //5% (2/40 -> 1/20)
        TNT1 A 0 A_SpawnItem("STMarinePlasma", 64, 16, 0, 1)
		Stop
	Railgun: //5% (2/40 -> 1/20)
		TNT1 A 0 A_SpawnItem("STMarineRailgun", 64, 16, 0, 1)
		Stop
	Repeater: //2.5% (1/40)
		TNT1 A 0 A_SpawnItem("STMarineRepeater", 64, 16, 0, 1)
		Stop
  }
}

Actor STMarineShotgun 12851
{
	Painchance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "Shotgun Marine"
	Damagefactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	AttackSound "weapons/shotgf"
	Species "Player"
	States
	{
	Spawn:
		PLA3 A 4 A_Look
		Loop
	See:
		PLA3 ABCD 4 A_Chase
		Loop
	Missile:
		PLA3 E 0 A_JumpIfInventory("ShotgunmarineTimer", 1, "See")
		PLA3 E 3 A_FaceTarget
		PLA3 F 7 bright A_CustomBulletAttack(4, 3, 7, 5, "MarineImmunePuff")
		PLA3 F 0 A_GiveInventory("ShotgunmarineTimer", 1)
		Goto See
	Pain:
		PLA3 G 4
		PLA3 G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		PLA3 H 10
		PLA3 I 10 A_Scream
		PLA3 J 10 A_NoBlocking
		PLA3 KLM 10
		PLA3 N -1
		Stop
	XDeath:
		PLA3 O 5
		PLA3 P 5 A_XScream
		PLA3 Q 5 A_NoBlocking
		PLA3 RSTUV 5
		PLA3 W -1
		Stop
	}
}

Actor ShotgunmarineTimer : Powerup
{
	Powerup.Duration 27
}

Actor STMarineSSG 12853
{
	Painchance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "Supershotgun Marine"
	Damagefactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	AttackSound "weapons/sshotf"
	Species "Player"
	States
	{
	Spawn:
		PLA9 A 4 A_Look
		Loop
	See:
		PLA9 ABCD 4 A_Chase
		Loop
	Missile:
		PLA9 E 3 A_FaceTarget
		PLA9 F 7 bright A_CustomBulletAttack(11.25, 7.125, 20, 5, "MarineImmunePuff")
		PLA9 E 14
		PLA9 E 14 A_PlaySound ("weapons/sshoto")
		PLA9 E 13 A_PlaySound ("weapons/sshotl")
		PLA9 E 11 A_PlaySound ("weapons/sshotc")
		Goto See
	Pain:
		PLA9 G 4
		PLA9 G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		PLA9 H 10
		PLA9 I 10 A_Scream
		PLA9 J 10 A_NoBlocking
		PLA9 KLM 10
		PLA9 N -1
		Stop
	XDeath:
		PLA9 O 5
		PLA9 P 5 A_XScream
		PLA9 Q 5 A_NoBlocking
		PLA9 RSTUV 5
		PLA9 W -1
		Stop
	}
}

Actor STMarineChaingun 12852
{
	Painchance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "Chaingun Marine"
	Damagefactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	AttackSound "weapons/chngun"
	Species "Player"
	States
	{
	Spawn:
		PLA4 A 4 A_Look
		Loop
	See:
		PLA4 ABCD 4 A_Chase
		Loop
	Missile:
		PLA4 E 2 A_FaceTarget
		PLA4 FF 4 bright A_CustomBulletAttack(0, 0, 1, 5, "MarineImmunePuff")
		PLA4 FF 4 bright A_CustomBulletAttack(4.2, 3, 1, 5, "MarineImmunePuff")
		TNT1 A 0 A_CPosRefire
		Goto Missile+3
	Pain:
		PLA4 G 4
		PLA4 G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		PLA4 H 10
		PLA4 I 10 A_Scream
		PLA4 J 10 A_NoBlocking
		PLA4 KLM 10
		PLA4 N -1
		Stop
	XDeath:
		PLA4 O 5
		PLA4 P 5 A_XScream
		PLA4 Q 5 A_NoBlocking
		PLA4 RSTUV 5
		PLA4 W -1
		Stop
	}
}

Actor STMarineRocket 12854
{
	Painchance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "Rocket Marine"
	Damagefactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	Species "Player"
	States
	{
	Spawn:
		PLA5 A 4 A_Look
		Loop
	See:
		PLA5 ABCD 4 A_Chase
		Loop
	Missile:
		PLA5 E 8 A_FaceTarget
		PLA5 F 12 bright A_CustomMissile("ZMarineRocket")
		PLA5 E 8 A_SpidRefire
		Goto Missile+1
	Pain:
		PLA5 G 4
		PLA5 G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		PLA5 H 10
		PLA5 I 10 A_Scream
		PLA5 J 10 A_NoBlocking
		PLA5 KLM 10
		PLA5 N -1
		Stop
	XDeath:
		PLA5 O 5
		PLA5 P 5 A_XScream
		PLA5 Q 5 A_NoBlocking
		PLA5 RSTUV 5
		PLA5 W -1
		Stop
	}
}

actor ZMarineRocket
{
  obituary "%o rode %k's rocket."
  radius 11
  height 8
  speed 20
  damage 20
  seesound "weapons/rocklf"
  deathsound "weapons/rocklx"
  Decal Scorch
  PROJECTILE
  Damagetype "MarineAlly"
  +RANDOMIZE
  +ROCKETTRAIL
  -THRUGHOST
  states
  {
  Spawn:
    MISL A 1 bright
    loop
  Death:
    TNT1 A 0 A_SetTranslucent (0.67,1)
    MISL B 8 bright A_Explode(128, 128, 0)
    MISL C 6 bright
    MISL D 4 bright
    stop
  }
}

Actor STMarinePlasma 12855
{
	Painchance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "Plasmagun Marine"
	Damagefactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	AttackSound "weapons/plasmaf"
	Species "Player"
	States
	{
	Spawn:
		PLA6 A 4 A_Look
		Loop
	See:
		PLA6 ABCD 4 A_Chase
		Loop
	Missile:
		PLA6 E 5 A_FaceTarget
		PLA6 F 2 bright A_CustomMissile("MarinePlasmaBall")
		PLA6 E 1 A_SpidRefire
		Goto Missile+1
	Pain:
		PLA6 G 4
		PLA6 G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		PLA6 H 10
		PLA6 I 10 A_Scream
		PLA6 J 10 A_NoBlocking
		PLA6 KLM 10
		PLA6 N -1
		Stop
	XDeath:
		PLA6 O 5
		PLA6 P 5 A_XScream
		PLA6 Q 5 A_NoBlocking
		PLA6 RSTUV 5
		PLA6 W -1
		Stop
	}
}

Actor MarinePlasmaBall : PlasmaBall
{
	Damagetype "MarineAlly"
}

Actor STMarineRailgun
{
	Painchance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "Railgun Marine"
	Damagefactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	AttackSound "weapons/railgf"
	Decal RailScorch
	Species "Player"
	States
	{
	Spawn:
		PRAI A 4 A_Look
		Loop
	See:
		PRAI ABCD 4 A_Chase
		Loop
	Missile:
		TNT1 A 0 A_Jump(256, "Red", "Yellow", "Blue")
	Red:
		TNT1 A 0 A_PlaySound("weapons/railch")
		PRAI EE 6 A_FaceTarget
		TNT1 A 0 A_StopSound(5)
		PRAI F 4 bright A_CustomRailgun(100, 0, "Red", "white", 0, 1, 0, "MarineImmunePuff")
		PRAI E 23
		Goto See
	Yellow:
		TNT1 A 0 A_PlaySound("weapons/railch")
		PRAI EEEE 6 A_FaceTarget
		TNT1 A 0 A_StopSound(5)
		PRAI G 4 bright A_CustomRailgun(200, 0, "Yellow", "white", 0, 1, 0, "MarineImmunePuff")
		PRAI E 23
		Goto See
	Blue:
		TNT1 A 0 A_PlaySound("weapons/railch")
		PRAI EEEEEE 6 A_FaceTarget
		PRAI H 4 bright A_CustomRailgun(300, 0, "Blue", "white", 0, 1, 0, "MarineImmunePuff")
		PRAI E 23
		Goto See
	Pain:
		PRAI I 4
		PRAI I 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		PRAI J 10
		PRAI K 10 A_Scream
		PRAI L 10 A_NoBlocking
		PRAI MNO 10
		PRAI P -1
		Stop
	XDeath:
		PRAI Q 5
		PRAI R 5 A_XScream
		PRAI S 5 A_NoBlocking
		PRAI TUVWX 5
		PRAI Y -1
		Stop
	}
}


Actor STMarineAutoShotgun
{
	PainChance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "AutoShotgun Marine"
	DamageFactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	AttackSound "weapons/asgfir"
	Species "Player"
	States
	{
	Spawn:
		AYAS A 4 A_Look
		Loop
	See:
		AYAS ABCD 4 A_Chase
		Loop
	Missile:
		AYAS E 4 A_FaceTarget
    	AYAS F 5 Bright A_CustomBulletAttack(5, 4, 7, 5, "MarineImmunePuff")
    	AYAS E 6
		TNT1 A 0 A_PlaySound("weapons/asgld1")
    	AYAS E 4 A_CPosRefire
    	AYAS F 5 Bright A_CustomBulletAttack(5, 4, 7, 5, "MarineImmunePuff")
    	AYAS E 6
		TNT1 A 0 A_PlaySound("weapons/asgld1")
    	AYAS E 4 A_CPosRefire
    	AYAS F 5 Bright A_CustomBulletAttack(5, 4, 7, 5, "MarineImmunePuff")
    	AYAS E 6
		TNT1 A 0 A_PlaySound("weapons/asgld1")
    	AYAS E 4 A_CPosRefire
    	AYAS F 5 Bright A_CustomBulletAttack(5, 4, 7, 5, "MarineImmunePuff")
    	AYAS E 6
		TNT1 A 0 A_PlaySound("weapons/asgld1")
        Goto See
	Pain:
		AYAS G 4
		AYAS G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		AYAS H 10
		AYAS I 10 A_Scream
		AYAS J 10 A_NoBlocking
		AYAS KLM 10
		AYAS N -1
		Stop
	XDeath:
		AYAS O 5
		AYAS P 5 A_XScream
		AYAS Q 5 A_NoBlocking
		AYAS RSTUV 5
		AYAS W -1
		Stop
	}
}

Actor STMarineHRL
{
	PainChance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "Homing Rocket Marine"
	DamageFactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	Species "Player"
	States
	{
	Spawn:
		PHRL A 4 A_Look
		Loop
	See:
		PHRL ABCD 4 A_Chase
		Loop
	Missile:
		PLA5 E 8 A_FaceTarget
		PLA5 F 12 bright A_CustomMissile("MarineHomRocket1")
		PLA5 E 8 A_SpidRefire
		Goto Missile+1
	Pain:
		PHRL G 4
		PHRL G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		PHRL H 10
		PHRL I 10 A_Scream
		PHRL J 10 A_NoBlocking
		PHRL KLM 10
		PHRL N -1
		Stop
	XDeath:
		PHRL O 5
		PHRL P 5 A_XScream
		PHRL Q 5 A_NoBlocking
		PHRL RSTUV 5
		PHRL W -1
		Stop
	}
}

Actor MarineHomRocket1
{
   Radius 8
   Height 11
   Speed 30
   Damage 20
   PROJECTILE
   +SEEKERMISSILE
   +ROCKETTRAIL
   -THRUGHOST
   SeeSound "weapons/hrlfir"
   DeathSound "weapons/hrlexp"
   DamageType "MarineAlly"
   Decal Scorch
   States
   {
   Spawn:
      HMIS A 4 Bright A_SeekerMissile (5,7)
      HMIS A 4 Bright
      HMIS A 2 Bright A_SeekerMissile (2,5)
      HMIS A 2 Bright
      Goto Spawn+2
   Death:
      TNT1 A 0 A_SetTranslucent (0.67,1)
      MISL C 8 Bright A_Explode(128,128,0)
      MISL D 5 Bright
      Stop
   }
}

Actor STMarineRepeater
{
	PainChance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "Plasma Repeater Marine"
	DamageFactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	AttackSound "weapons/repfir"
	Species "Player"
	States
	{
	Spawn:
		PREP A 4 A_Look
		Loop
	See:
		PREP ABCD 4 A_Chase
		Loop
	Missile:
		PREP E 2 A_FaceTarget
		PREP FF 4 bright A_CustomBulletAttack(0, 0, 2, 5, "MarineImmuneRepPuff")
		PREP FF 4 bright A_CustomBulletAttack(4, 4, 2, 5, "MarineImmuneRepPuff")
		TNT1 A 0 A_CPosRefire
		Goto Missile+3
	Pain:
		PREP G 4
		PREP G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		PREP H 10
		PREP I 10 A_Scream
		PREP J 10 A_NoBlocking
		PREP KLM 10
		PREP N -1
		Stop
	XDeath:
		PREP O 5
		PREP P 5 A_XScream
		PREP Q 5 A_NoBlocking
		PREP RSTUV 5
		PREP W -1
		Stop
	}
}

Actor MarineImmuneRepPuff
{
   Radius 3
   Height 3
   RenderStyle Add
   Alpha 0.75
   DamageType "MarineAlly"
   +ALWAYSPUFF
   +PUFFONACTORS
   +NOGRAVITY
   +NOBLOCKMAP
   +PUFFGETSOWNER
   DeathSound "weapons/buzz"
   Decal FireDemonScorch
   States
   {
   Spawn:
      MBLS A 1 Bright
      MBLS A 2 Bright A_Explode(32,88,0)
      MBLS BCDEFG 3 Bright
      stop
   }
}

Actor STMarineFlamer
{
	PainChance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "Flamer Marine"
	DamageFactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
    MaxTargetRange 380
	Species "Player"
    States
    {
    Spawn:
        ALFL A 4 A_Look
        Loop
    See:
		ALFL ABCD 4 A_Chase
		Loop
    Missile:
		TNT1 A 0 A_JumpIfCloser(560,1)
		Goto See
        ALFL E 10 A_FaceTarget
      	ALFL FFFFFFFFF 1 A_CustomMissile("MarineFTFire",32,0,random(-4,4),0)
		TNT1 A 0 A_CPosRefire
		TNT1 A 0 A_JumpIfCloser(560,1)
		Goto See
		TNT1 A 0
        Goto Missile+2
    Pain:
		ALFL G 4
		ALFL G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
        Goto See
    Death:
		ALFL H 10
		ALFL I 10 A_Scream
		ALFL J 10 A_NoBlocking
		ALFL KLM 10
		ALFL N -1
		Stop
	XDeath:
		ALFL O 5
		ALFL P 5 A_XScream
		ALFL Q 5 A_NoBlocking
		ALFL RSTUV 5
		ALFL W -1
		Stop
    }
}

Actor MarineFTFire
{
   Radius 2
   Height 4
   Speed 16
   Damage 1
   PROJECTILE
   RenderStyle Add
   DamageType "MarineAlly"
   Alpha 0.67
   Scale 0.67
   SeeSound "weapons/flamer"
   DeathSound "weapons/scorch"
   DONTHURTSHOOTER
   +DONTSPLASH
   States
   {
   Spawn:
      TNT1 A 2 Bright
      FRFX ABCD 2 Bright A_Explode(2,8,0)
      FRFX D 0 Bright A_Lowgravity
      FRFX EFG 2 Bright A_Explode(2,16,0)
      FRFX HIJ 2 Bright A_Explode(2,32,0)
      FRFX KLM 2 Bright A_Explode(2,64,0)
      FRFX NO 2 Bright
      stop
   Death:
      FRFX HIJ 2 Bright A_Explode(2,32,0)
      FRFX J 0 A_CustomMissile ("MarineDropFire",0,0,0,4)
      FRFX KLM 2 Bright A_Explode(2,64,0)
      FRFX NO 2 Bright
      stop
   }
}

Actor MarineDropFire
{
   Radius 8
   Height 40
   PROJECTILE
   RenderStyle Add
   DamageType "MarineAlly"
   Alpha 0.90
   DONTHURTSHOOTER
   +PAINLESS
   -NOGRAVITY
   +LOWGRAVITY
   +NOEXPLODEFLOOR
   +NODAMAGETHRUST
   +DONTSPLASH
   States
   {
   Spawn:
      FLME A 1 Bright A_Playsound("weapons/onfire")
      FLME A 1 Bright A_Explode(2,16,0)
      FLME BCDEFGHIJKLMN 2 Bright A_Explode(2,16,0)
      FLME A 1 Bright A_Playsound("weapons/onfire")
      FLME A 1 Bright A_Explode(2,32,0)
      FLME BCDEFGHIJKLMN 2 Bright A_Explode(2,16,0)
      FLME A 1 Bright A_Playsound("weapons/onfire")
      FLME A 1 Bright A_Explode(2,32,0)
      FLME BCDEFGHIJKLMN 2 Bright A_Explode(2,16,0)
      FLME A 1 Bright A_Playsound("weapons/onfire")
      FLME A 1 Bright A_Explode(2,32,0)
      FLME BCDEFGHIJKLMN 2 Bright A_Explode(2,16,0)
      FLME A 1 Bright A_Playsound("weapons/onfire")
      FLME A 1 Bright A_Explode(2,32,0)
      FLME BCDEFGHIJKLMN 2 Bright A_Explode(2,16,0)
      FLME A 0 A_Jump(192,"Death")
      Goto Spawn+60
   Death:
      TNT1 A 1 Bright
      Stop
   }
}

ACTOR MarineImmunePuff : BulletPuff
{
	Alpha 1.0
	Mass 1
	Damagetype "MarineAlly"
	States
	{
	Spawn:
	Melee:
	    PUFF A 2
	    PUFF A 0 A_Jump(128,2)
	    PUFF A 2 A_SpawnItemEx("MPuff2",0,0,0,0,0,0,0,128)
	    PUFF BCD 4
	    Stop
	}
}

ACTOR MPuff2
{
	PROJECTILE
	+NOCLIP
	Mass 1
	States
	{
	Spawn:
		PUFF E 2
		PUFF E 2 A_PlaySound("puff/ric")
		PUFF FGH 4
		Stop
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SENTRY ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor Sentry 12856
{
//$Category Stronghold_Marines
	mass 9999999999
        damagefactor "overmindfactor", 10
        radius 16
	height 16
	health 300
        maxstepheight 512
        maxdropoffheight 512
		Tag "Sentry Gun"
	+THRUSPECIES
	+MTHRUSPECIES
	+shootable
	+noblood
	+friendly
	+lookallaround
	+missilemore
	+missileevenmore
        +NORADIUSDMG
	speed 0

	states
 	{

 	spawn:
 		DGUN A 4 a_look
 		loop

 	see:
 		DGUN A 4 A_chase
 		loop
 	missile:
 		DGUN A 4 A_facetarget
 		DGUN B 4 A_custommissile("SentryPlasma", 16, -10, 0)
 		DGUN C 4 A_custommissile("SentryPlasma", 16, 10, 0)
 		DGUN A 7 A_CPosRefire //was A 4
 		loop
 	death:
 		TNT1 A 4
 		stop
 	}

}

actor SentryPlasma
{
	radius 1
	height 2
	speed 20
        damage 3
        scale 0.3
	damagetype "bossfactor"
	+DONTBLAST
        +THRUGHOST
	projectile
        translation "192:207=208:223","240:246=223:223"
        SeeSound "weapons/repfir"
        DeathSound "weapons/railf1"
	states
 	{
 	spawn:
   		PLSS AB 4 Bright
   		loop
 	Death:
   		PLSE ABCDE 4 Bright
                TNT1 A 0
  		Stop
 	}
}

actor SentryItem : CustomInventory 25004
{
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up a deployable sentry turret."
  inventory.maxamount 5
  inventory.icon SENIA0
  Tag "Sentry Turret"
  +INVENTORY.INVBAR
  scale 0.75
   states
  {
  Spawn:
   		SENP A -1 BRIGHT
    	stop
  use:
  		TNT1 A 1 A_PlaySound("DSSTPLAC", CHAN_AUTO, 0.7)
		TNT1 A 1 A_SpawnItem("ItemFog", 64, 16, 0, 1)
                TNT1 A 1 a_spawnitem("Sentry", 64, 0, 0, 1)
  		stop
  }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BARREL SPAWNER ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor BarrelItem : CustomInventory 25005
{
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up a portable barrel."
  inventory.maxamount 10
  inventory.icon BARIA0
  Tag "Barrel"
  +INVENTORY.INVBAR
  scale 0.75
  states
  {
  Spawn:
   	BARP A -1 BRIGHT
    	stop
  Use:
        TNT1 A 1 A_SpawnItem("ItemFog", 64, 16, 0, 1)
        TNT1 A 0 A_SpawnItem("ExplosiveBarrelTimer", 64, 16, 0, 1)
  	stop
  }
}

actor ExplosiveBarrelTimer
{
  obituary "%o went boom."
  health 20
  radius 10
  height 34
  deathsound "world/barrelx"
  speed 0
  MONSTER
  +SOLID
  +SHOOTABLE
  +NOBLOOD
  +DONTGIB
  +NOICEDEATH
  +FRIENDLY
  +NORADIUSDMG
  states
  {
  Spawn:
    BAR1 A 35 A_ChangeFlag("INVULNERABLE",1)
    BAR1 A 0 A_ChangeFlag("INVULNERABLE",0)
    BAR1 AB 6 A_Look
    Goto Spawn+2
    loop
  See:
    BAR1 AB 2 A_Chase
    loop
  Melee:
    BAR1 ABABABABABABABABABABABABABABABABAB 6
    goto Death
  Death:
    BEXP A 5 bright
    BEXP B 5 bright A_Scream
    BEXP C 5 bright
    BEXP D 10 bright A_Explode
    BEXP E 10 bright
    stop
  }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// COINS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor CoinItem : CustomInventory 25006
{
//$Category Stronghold_Items
	ConversationID 300
	gravity 0.6
	inventory.pickupmessage "Picked up a coin."
	inventory.maxamount 100000
	inventory.icon SACKA0
	Tag "Credits"
	+INVENTORY.KEEPDEPLETED
	states
	{
	Spawn:
		COIN A 1500
		COIN A 2 A_FadeOut
		goto Spawn+1
	Use:
//TODO: Make it so it drops 10 or so coins
		TNT1 A 0 A_SpawnItem("CoinItem", 64, 16, 0, 0)
		stop
	}
}

// Item that monsters give player when they die. An ACS script gives the player the equal amount in CoinItem.
actor AwardItem : Inventory
{
	+INVENTORY.UNDROPPABLE
	inventory.maxamount 1000000
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// LIFES ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor LifeItem : CustomInventory 25926
{
//$Category Stronghold_Items
  scale 0.75
  inventory.pickupmessage "Picked up an extra life!"
  inventory.maxamount 9
  inventory.icon HERIA0
  Tag "Lives (Multiplayer Use Only)"
  +INVENTORY.INVBAR
  +INVENTORY.KEEPDEPLETED
  +INVENTORY.UNDROPPABLE
  states
  {
  Spawn:
   	HERP A -1 Bright
    	stop
  Use:
        TNT1 A 0 ACS_ExecuteWithResult(897, 0, 0, 0) // Allows the script to fail
  	stop
  }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// JAILTRACKER //////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Player is given this when they're in jail
actor JailTracker : Inventory
{
	+INVENTORY.UNDROPPABLE
	+INVENTORY.INTERHUBSTRIP 
	inventory.maxamount 1
}

// Player is given one of these per each player in jail
actor JailTrackerAllPlayers : Inventory
{
	+INVENTORY.UNDROPPABLE
	+INVENTORY.INTERHUBSTRIP
	inventory.maxamount 10000
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// MONSTERTRACKER ///////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
// Player is given one of these for each of the number of monsters left to kill this wave
actor MonsterTracker : Inventory
{
	+INVENTORY.UNDROPPABLE
	+INVENTORY.INTERHUBSTRIP
	inventory.maxamount 10000
}
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// WAVETRACKER //////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
// Player is given one of these for each of the number of monsters left to kill this wave
actor WaveTracker : Inventory
{
	+INVENTORY.UNDROPPABLE
	+INVENTORY.INTERHUBSTRIP
	inventory.maxamount 10000
}


actor HUDCredits : Inventory // Displays top bar when in Intermission
{
	+INVENTORY.UNDROPPABLE
	+INVENTORY.INTERHUBSTRIP
	Inventory.MaxAmount 1
}  */

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// THRUSTDUMMY //////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Used for scripts that thrust player to detect when he's not where he should be
actor ThrustDummy : Inventory
{
	+INVENTORY.UNDROPPABLE
	+INVENTORY.INTERHUBSTRIP
	Inventory.MaxAmount 1
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SUPER SHIELD...? ////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor StrongholdCompatGreenArmorSpawner : CustomInventory
{
  +INVENTORY.ALWAYSPICKUP
  Inventory.PickupMessage ""
  Inventory.PickupSound ""
  States
  {
  Spawn:
    ARM1 A 6
    ARM1 B 7 Bright
    Loop
  Pickup:
	TNT1 A 0 A_SpawnItemEx("GreenArmor",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	Stop
  }
}

actor StrongholdCompatBlueArmorSpawner : CustomInventory
{
  +INVENTORY.ALWAYSPICKUP
  Inventory.PickupMessage ""
  Inventory.PickupSound ""
  States
  {
  Spawn:
    ARM2 A 6
    ARM2 B 6 Bright
    Loop
  Pickup:
	TNT1 A 0 A_SpawnItemEx("BlueArmor",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	Stop
  }
}

actor StrongholdCompatMegasphereSpawner : CustomInventory
{
  +INVENTORY.ALWAYSPICKUP
  Inventory.PickupMessage ""
  Inventory.PickupSound ""
  States
  {
  Spawn:
    MEGA A -1
	Stop
  Pickup:
	TNT1 A 0 A_SpawnItemEx("Megasphere",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	Stop
  }
}

actor SuperShieldReplacementSpawner 10716
{
  +NOBLOCKMAP
  +NOSECTOR
  +NOGRAVITY
  +THRUACTORS
  States
  {
  Spawn:
    TNT1 A 0
	TNT1 A 0 A_SpawnItemEx("Megasphere", 0, 0, 0, 0, 0, 0, 0, 0, 0)
	Stop
  }
}
/*
actor SuperShield : BasicArmorPickup 10716
{
//$Category Stronghold_Items
  armor.savepercent 100.0
  armor.saveamount 300
  inventory.icon "ARMXA0"
  inventory.pickupmessage "Picked up the super shield!"
  states
  {
  Spawn:
    ARMX AB 3 Bright
    loop
  }
}
*/

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PORTABLE MEDICINE ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor PSuperMedKit : HealthPickup 12791
{
//$Category Stronghold_Items
  health 100
  inventory.maxamount 10
  inventory.icon "PMH2A0"
  inventory.pickupmessage "Picked up a portable super medkit."
  Tag "Portable Super Medkit"
  +COUNTITEM
  states
  {
  Spawn:
    PM02 A -1
    stop
  }
}

actor PMedKit : HealthPickup 12792
{
//$Category Stronghold_Items
  health 25
  inventory.maxamount 10
  inventory.icon "PMH1A0"
  inventory.pickupmessage "Picked up a portable medkit."
  Tag "Portable Medkit"
  +COUNTITEM
  states
  {
  Spawn:
    PM01 ABCD 2 
    loop
  }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// POWER UPS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TIME FREEZER //////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
actor TimeFreezerItem : PowerupGiver 12793
{
//$Category Stronghold_Items
 scale 0.75
 inventory.pickupmessage "Picked up a time freeze sphere."
 inventory.icon "FRZIA0"
 inventory.maxamount 1
 inventory.usesound "pickups/slowmo"
 powerup.color "00 33 FF" 0.10
 powerup.type "TimeFreezer"
 powerup.duration 1050
 Tag "Time Freeze"
 +INVENTORY.FANCYPICKUPSOUND
 +INVENTORY.INVBAR
 states
 {
 Spawn:
   FRZP A -1 BRIGHT
   stop
 }
}

actor TimeFreezerPickup : CustomInventory 24027
{
    +INVENTORY.BIGPOWERUP
    +INVENTORY.PICKUPFLASH
    +COUNTITEM
    Inventory.PickupMessage "Time Freeze1"
    Inventory.PickupSound "misc/p_pkup"
    Inventory.PickupAnnouncerEntry "timefreeze"
    states
    {
      Spawn:
        TIME ABCD 4 BRIGHT
        Loop

      Pickup:
        TNT1 A 0 A_JumpIfInventory("PowerTimeFreezer",1,"PickupFail")
        TNT1 A 1 A_GiveInventory("TimeFreezerPickup2")
        stop

      PickupFail:
        TIME ABCD 4 BRIGHT
        fail
    }
}

Actor TimeFreezerPickupReplacer : RandomSpawner replaces TimeFreezerPickup
{
 DropItem "Berserk"
}

actor TimeFreezerPickup2 : PowerupGiver
{
//$Category Stronghold_Items
 SpawnID 229
 scale 0.75
 inventory.pickupmessage "Time Freeze1"
 inventory.pickupannouncerentry "timefreeze"
 //inventory.icon "TIMEA0"
 inventory.maxamount 10
 inventory.usesound "pickups/slowmo"
 powerup.color "00 33 FF" 0.1
 powerup.type "TimeFreezer"
 powerup.duration -30
 +INVENTORY.FANCYPICKUPSOUND
 +INVENTORY.AUTOACTIVATE
 states
 {
 Spawn:
   TIME ABCD 4 BRIGHT
   loop
 }
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// QUAD DAMAGE ////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor PowerQuadDamage : PowerDamage
{
damagefactor "normal", 4
inventory.icon "DOOMA0"
}

actor QuadDamageItem : PowerupGiver 12794
{
//$Category Stronghold_Items
 scale 0.75
 inventory.pickupmessage "Picked up a quad damage sphere."
 powerup.color RedMap
 inventory.maxamount 3
 inventory.usesound "pickups/slowmo"
 inventory.icon "DAMIA0"
 powerup.type QuadDamage
 powerup.duration 1050
 Tag "Quad Damage"
 +INVENTORY.FANCYPICKUPSOUND
   states
 {
 Spawn:
   DAMP A -1 BRIGHT
   stop
 }
}

actor QuadDamagePowerup : CustomInventory 24028
{
    +INVENTORY.PICKUPFLASH
    +INVENTORY.BIGPOWERUP
    +COUNTITEM
    Inventory.PickupMessage "Doomsphere!"
    Inventory.PickupSound "misc/p_pkup"
    Inventory.PickupAnnouncerEntry "doomsphere"
    states
    {
      Spawn:
        DOOM ABCD 4 BRIGHT
        Loop

      Pickup:
        TNT1 A 0 A_JumpIfInventory("PowerQuadDamage",1,"PickupFail")
        TNT1 A 1 A_GiveInventory("QuadDamagePowerup2")
        stop

      PickupFail:
        DOOM ABCD 4 BRIGHT
        fail
    }
}

actor QuadDamagePowerup2 : PowerupGiver
{
//$Category Stronghold_Items
 SpawnID 228
 scale 0.75
 inventory.pickupmessage "Doomsphere!"
 inventory.pickupannouncerentry "doomsphere"
 powerup.color RedMap
 inventory.usesound "pickups/slowmo"
 //inventory.icon "DOOMA0"
 powerup.type QuadDamage
 powerup.duration -30
 +INVENTORY.FANCYPICKUPSOUND
 +INVENTORY.AUTOACTIVATE
   states
 {
 Spawn:
   DOOM ABCD 4 BRIGHT
   loop
 }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INVULNERABILITY ///////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor InvulnerabilityItem : PowerupGiver 12795
{
//$Category Stronghold_Items
 scale 0.75
 inventory.pickupmessage "Picked up an invulnerability sphere."
 inventory.icon "INVIA0"
 inventory.maxamount 3
 inventory.usesound "pickups/slowmo"
 powerup.color InverseMap
 powerup.type "Invulnerable"
 powerup.duration 1575
 Tag "Invulnerability"
 +INVENTORY.FANCYPICKUPSOUND
 states
 {
 Spawn:
   INVP A -1 BRIGHT
   stop
 }
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// MAX ARMOR+ //////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ACTOR MaxArmorBonus2 : BasicArmorBonus 12796
{
//$Category Stronghold_Items
	Radius 20
	Height 16
	Inventory.Pickupmessage "Picked up a max armor bonus."
	Armor.Savepercent 33.33333
	Armor.Saveamount 5
	Armor.Maxsaveamount 200
	Armor.MaxBonus 5
	Armor.MaxBonusMax 200
	+COUNTITEM
	+INVENTORY.ALWAYSPICKUP
	states
	{
	Spawn:
		BON4 ABCDCB 6 BRIGHT
		loop
	}
}

// The following is a hack separating the above into two actors, with one that stays in the player's inventory,
// so that the game can count how many the player has. This ultimately wasn't needed so I've commented it out just
// in case this ever becomes a problem. Make sure to comment out the above if you use this.
/*
ACTOR MaxArmorBonus2 : CustomInventory 12796
{
	Radius 20
	Height 16
	Inventory.Pickupmessage "Picked up a max armor bonus."
	+COUNTITEM
	+INVENTORY.UNDROPPABLE
	+INVENTORY.ALWAYSPICKUP
	states
	{
	Spawn:
		BON4 ABCDCB 6 BRIGHT
		loop
	Pickup:
		TNT1 A 0 A_GiveInventory ("MaxArmorBonus2real")
		TNT1 A 0 A_GiveInventory ("MaxArmorBonus2counter")
		stop
	Use:	// Dummy use state to make item stay in inventory
		TNT1 A 0
		fail
	}
}

ACTOR MaxArmorBonus2real : BasicArmorBonus
{
	Armor.Savepercent 33.33333
	Armor.Saveamount 5
	Armor.Maxsaveamount 200
	Armor.MaxBonus 5
	Armor.MaxBonusMax 50
	+INVENTORY.ALWAYSPICKUP
}
*/

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// MAX HEALTH+ /////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ACTOR MaxHealthBonus2 : UpgradeStamina 12797
{
//$Category Stronghold_Items
Radius 20
Height 16
Inventory.Pickupmessage "Picked up a max health bonus."
Inventory.Amount 5
Inventory.MaxAmount 200
+COUNTITEM
+INVENTORY.ALWAYSPICKUP
states
  {
  Spawn:
    BON3 ABCDCB 6 BRIGHT
    loop
  }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// REGENERATION //////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor RegenerationItem : PowerupGiver 24031
{
//$Category Stronghold_Items
 scale 0.75
 inventory.pickupmessage "Picked up a regeneration sphere."
 inventory.icon "RESIA0"
 inventory.maxamount 3
 inventory.usesound "pickups/slowmo"
 powerup.color "FF 00 AE" 0.10
 powerup.type "Regeneration"
 powerup.duration 3150
 Tag "Regeneration"
 +INVENTORY.FANCYPICKUPSOUND
 states
 {
 Spawn:
   RESP A -1 BRIGHT
   stop
 }
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BARRIER ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor WallItem : CustomInventory 12798
{
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up a barrier kit."
  inventory.pickupsound "misc/p_pkup"
  inventory.maxamount 3
  inventory.icon WALIA0
  Tag "Barrier Kit"
  +INVENTORY.INVBAR
  scale 0.75
   states
  {
  Spawn:
   		WALP A -1 BRIGHT
    	stop
  use:
  		TNT1 A 0 A_SpawnItemEx("WallSpawner",64,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
		stop
  }
}

actor WallSpawner
{
  +ISMONSTER
  +NOBLOCKMAP
  Radius 4
  Height 4
  States
  {
  Spawn:
  		TNT1 A 0
		TNT1 A 1 A_SpawnItemEx("WallPlaced",  60, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
		TNT1 A 1 A_SpawnItemEx("WallPlaced",  50, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
  		TNT1 A 1 A_SpawnItemEx("WallPlaced",  40, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
		TNT1 A 1 A_SpawnItemEx("WallPlaced",  30, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
  		TNT1 A 1 A_SpawnItemEx("WallPlaced",  20, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
  		TNT1 A 1 A_SpawnItemEx("WallPlaced",  10, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
  		TNT1 A 1 A_SpawnItemEx("WallPlaced",  0,  32, 0, 0, 0, 0, 90,  SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
  		TNT1 A 1 A_SpawnItemEx("WallPlaced",  -10, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
		TNT1 A 1 A_SpawnItemEx("WallPlaced",  -20, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
  		TNT1 A 1 A_SpawnItemEx("WallPlaced",  -30, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
  		TNT1 A 1 A_SpawnItemEx("WallPlaced",  -40, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
		TNT1 A 1 A_SpawnItemEx("WallPlaced",  -50, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
		TNT1 A 1 A_SpawnItemEx("WallPlaced",  -60, 32, 0, 0, 0, 0, 90, SXF_SETMASTER | SXF_NOCHECKPOSITION, 0)
  SpawnLoop:
		TNT1 A 1
  		Loop
  }
}

actor WallBolt
{
  PROJECTILE
  +NOCLIP
  Speed 1
  Damage 0
  RenderStyle Add
  Alpha 1.0
  Scale 0.33
  States
  {
  Spawn:
    WLXP A 1 A_FadeOut(0.025)
	Loop
  }
}

actor WallBolt2 : WallBolt
{
  States
  {
  Spawn:
    WLXP B 1 A_FadeOut(0.025)
	Loop
  }
}

actor WallPlaced
{
	health 500000
	mass 0x7fffffff
	radius 8
	height 128
	speed 0
	scale 0.5
	damage 0
	+FRIENDLY
	+DONTBLAST
	+SOLID
	+SHOOTABLE
	+NOBLOOD
	+NORADIUSDMG
	+ISMONSTER
	Species "Player"
	DeathSound "WallItem/Explode"
	states
 	{
 	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("RedSparkleTiny",frandom(-10.0,10.0),0,0,0,0,frandom(0.05,2.00),0,128,235)
		TNT1 A 0 A_SpawnItemEx("RedSparkleSmall",frandom(-10.0,10.0),0,0,0,0,frandom(0.05,2.00),0,128,235)
		TNT1 A 0 A_SpawnItemEx("RedSparkleMedium",frandom(-10.0,10.0),0,0,0,0,frandom(0.05,2.00),0,128,235)
		TNT1 A 0 A_JumpIfInventory("WallTimer",5000,"Die")
		TNT1 A 1 A_GiveInventory("WallTimer",1)
  		Loop
	Die:
	    TNT1 A 1 A_Die
		Wait
 	Death:
 		TNT1 A 0 A_Scream
		TNT1 A 0 A_KillSiblings
		TNT1 AAAA 0 A_CustomMissile("WallBolt",random(10,50),0,random(0,360),2,random(-15,15))
		TNT1 AAAA 0 A_CustomMissile("WallBolt2",random(10,50),0,random(0,360),2,random(-15,15))
 		Stop
  	}
}

actor WallTimer : Inventory
{
  Inventory.MaxAmount 5000
}

actor RedSparkle
{
  height 2
  radius 1
  speed 1.0
  +MISSILE +NOINTERACTION
  renderstyle Add
  alpha 0.9
  translation "80:96=175:191"
  states
  {
  Spawn:
    PTCL ABCABCABCABCABCABC 2 bright
  Death:
    PTCL ABC 2 bright A_FadeOut (0.1)
    loop
  }
}

actor RedSparkleRandom : RandomSpawner
{
  DropItem "RedSparkleTiny"
  DropItem "RedSparkleSmall"
  DropItem "RedSparkleMedium"
}

actor RedSparkleTiny   : RedSparkle { scale 0.125 }
actor RedSparkleSmall  : RedSparkle { scale 0.2 }
actor RedSparkleMedium : RedSparkle { scale 0.4 }

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// RANDOM WEAPON ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor RandomWeaponItem : CustomInventory 25023
{
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up a random weapon sphere."
  inventory.maxamount 5
  inventory.icon WEPIA0
  Tag "Random Weapon"
  +INVENTORY.INVBAR
  scale 0.75
  states
  {
  Spawn:
   	WEPP A -1 BRIGHT
    	stop
  Use:
	TNT1 A 0 A_Jump(64, "ASG")        //      1 / 4      (25.0%)
	TNT1 A 0 A_Jump(64, "Mines")      //      3 / 16     (18.8%)
	TNT1 A 0 A_Jump(64, "RL")         //      9 / 64     (14.1%)
	TNT1 A 0 A_Jump(64, "PR")         //     27 / 256    (10.6%)
	TNT1 A 0 A_Jump(64, "HRL")        //     81 / 1024    (7.9%)
	TNT1 A 0 A_Jump(64, "Stunner")    //    243 / 4096    (5.9%)
	TNT1 A 0 A_Jump(64, "RG")         //    729 / 16384   (4.4%)
	TNT1 A 0 A_Jump(64, "Flamer")     //   2187 / 65536   (3.3%)
	TNT1 A 0 A_Jump(64, "BFG9000")    //   6561 / 262144  (2.5%)
	TNT1 A 0 A_Jump(64, "Devastator") //  19683 / 1048576 (1.8%)
	TNT1 A 0 A_Jump(64, "PyroCannon") //  59049 / 4194304 (1.4%)
	Goto Repeater                     // 177147 / 4194304 (4.2%)
  BFG9000:
	TNT1 A 0 A_SpawnItemEx("DEBFG9000", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("CellPack", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Cell", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  PyroCannon:
	TNT1 A 0 A_SpawnItemEx("PyroCannon", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Gas", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Fuel", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  Devastator:
	TNT1 A 0 A_SpawnItemEx("Devastator", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("CellPack", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Cell", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Cell", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Cell", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  Repeater:
	TNT1 A 0 A_SpawnItemEx("Repeater", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("CellPack", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Cell", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  Flamer:
	TNT1 A 0 A_SpawnItemEx("Flamer", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Gas", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Fuel", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  RG:
	TNT1 A 0 A_SpawnItemEx("Railgun", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("CellPack", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Cell", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  Stunner:
	TNT1 A 0 A_SpawnItemEx("StunnerRifle", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("CellPack", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Cell", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  PR:
	TNT1 A 0 A_SpawnItemEx("DEPlasmaRifle", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("CellPack", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Cell", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  RL:
	TNT1 A 0 A_SpawnItemEx("DERLauncher", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("RocketBox", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("RocketAmmo", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  HRL:
	TNT1 A 0 A_SpawnItemEx("HRL", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("RocketBox", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("RocketAmmo", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("RocketAmmo", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("RocketAmmo", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  Mines:
	TNT1 A 0 A_SpawnItemEx("LandMineLayer", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("ClipBox", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Clip", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Mines", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Mines", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  ASG:
	TNT1 A 0 A_SpawnItemEx("Autoshotgun", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("ShellBox", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
	TNT1 A 0 A_SpawnItemEx("Shell", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 0)
  	stop
  }
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AUTO DRONE ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ACTOR AutoDroneItem : CustomInventory 24025
{
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up an autodrone."
  inventory.maxamount 2
  inventory.icon DRNIA0
  Tag "Autodrone"
  +INVENTORY.INVBAR
  scale 0.75
  states
  {
  Spawn:
   	DRNP A -1 BRIGHT
    	stop
  Use:
       TNT1 A 0 A_JumpIfInventory("ForceCubeTimerRight",1,3)
       TNT1 A 0 A_GiveInventory("ForceCubeTimerRight",1)
       TNT1 A 0 A_SpawnItemEx("ForceCube1Right",0,0,0,0,0,0,0,33,0)
       Stop
       TNT1 A 0 A_JumpIfInventory("ForceCubeTimerLeft",1,3)
       TNT1 A 0 A_GiveInventory("ForceCubeTimerLeft",1)
       TNT1 A 0 A_SpawnItemEx("ForceCube1Left",0,0,0,0,0,0,0,33,0)
       Stop
       TNT1 A 0
       Loop
   }
}

ACTOR ForceCube1Right
{
    Radius 0
    Height 0
    +NOTIMEFREEZE
    States
    {
    Spawn:
        TNT1 A 0
        TNT1 A 0 A_SpawnItemEx("ForceCubeGiverRight",0,0,0,0,0,0,0,33,0)
        Stop
    }
}

ACTOR ForceCube1Left
{
    Radius 0
    Height 0
    +NOTIMEFREEZE
    States
    {
    Spawn:
        TNT1 A 0
        TNT1 A 0 A_SpawnItemEx("ForceCubeGiverLeft",0,0,0,0,0,0,0,33,0)
        Stop
    }
}

ACTOR ForceCube2Right : CustomInventory
{
    +AUTOACTIVATE
    +NOTIMEFREEZE
    States
    {
    Pickup:
        TNT1 A 0 A_SpawnItemEx("RightCube",28,16,36,0,0,0,0,33,0)
        Stop
    }
}

ACTOR ForceCube2Left : CustomInventory
{
    States
    {
    Pickup:
        TNT1 A 0 A_SpawnItemEx("LeftCube",28,-16,36,0,0,0,0,33,0)
        Stop
    }
}

ACTOR ForceCubeTimerLeft : CustomInventory
{
   +NOTIMEFREEZE
   +INVENTORY.INTERHUBSTRIP
   States
   {
   Use:
       TNT1 A 0
       Stop
   }
}

ACTOR ForceCubeTimerRight : CustomInventory
{
   +NOTIMEFREEZE
   +INVENTORY.INTERHUBSTRIP
   States
   {
   Use:
       TNT1 A 0
       Stop
   }
}

ACTOR ForceCubeTimer2 : Inventory
{
    +NOTIMEFREEZE
    Inventory.Amount 1
    Inventory.MaxAmount 4200
    States
    {
    Spawn:
        TNT1 A 0
        Stop
    }
}

ACTOR ForceCubeGiverRight
{
    Health 1000000000
    Radius 0
    Height 0
    Speed 0
    +NONSHOOTABLE
    +MISSILEMORE
    +MISSILEEVENMORE
    +NOTIMEFREEZE
    MinMissileChance 0
    States
    {
    Spawn:
        TNT1 A 1 A_Look
        Loop
    See:
        TNT1 A 1 A_Chase
        Loop
    Missile:
        TNT1 A 0 A_JumpIfInTargetInventory("ForceCubeTimerRight",1,2)
        TNT1 A 0 A_Jump(256,"Death")
        TNT1 A 0 A_JumpIfInventory("ForceCubeTimer2",4200,"Death")
        TNT1 A 0 A_GiveInventory("ForceCubeTimer2",1)
        TNT1 A 1 A_GiveToTarget("ForceCube2Right",1)
        Loop
    Death:
        TNT1 A 0 A_TakeFromTarget("ForceCubeTimerRight",1)
        Stop
    }
}

ACTOR ForceCubeGiverLeft
{
    Health 1000000000
    Radius 0
    Height 0
    Speed 0
    +NONSHOOTABLE
    +MISSILEMORE
    +MISSILEEVENMORE
    +NOTIMEFREEZE
    MinMissileChance 0
    States
    {
    Spawn:
        TNT1 A 1 A_Look
        Loop
    See:
        TNT1 A 1 A_Chase
        Loop
    Missile:
        TNT1 A 0 A_JumpIfInTargetInventory("ForceCubeTimerLeft",1,2)
        TNT1 A 0 A_Jump(256,"Death")
        TNT1 A 0 A_JumpIfInventory("ForceCubeTimer2",4200,"Death")
        TNT1 A 0 A_GiveInventory("ForceCubeTimer2",1)
        TNT1 A 1 A_GiveToTarget("ForceCube2Left",1)
        Loop
    Death:
        TNT1 A 0 A_TakeFromTarget("ForceCubeTimerLeft",1)
        Stop
    }
}

ACTOR RightCube
{
    Radius 0
    Height 0
    Speed 0
    Scale 0.1
    +FRIENDLY
    +NOGRAVITY
    +NOTIMEFREEZE
    +MISSILEMORE
    +MISSILEEVENMORE
    MinMissileChance 0
    States
    {
    Spawn:
    	DRON AA 1 A_LookEx(2,0,800,0,135,"See")
        Stop
    See:
	DRON A 0 A_Jump(240,3) // the higher the number, the less frequent it attacks
        DRON A 1 A_CustomMissile("AutoDroneBall",8,0,0,0)
        TNT1 A 0 A_PlaySound("ForceCube/Fire")
        DRON A 1
        Stop
    }
}

ACTOR LeftCube
{
    Radius 0
    Height 0
    Speed 0
    Scale 0.1
    +FRIENDLY
    +NOGRAVITY
    +NOTIMEFREEZE
    +MISSILEMORE
    +MISSILEEVENMORE
    MinMissileChance 0
    States
    {
    Spawn:
    	DRON AA 1 A_LookEx(2,0,800,0,135,"See")
        Stop
    See:
	DRON A 0 A_Jump(240,3) // the higher the number, the less frequent it attacks
        DRON A 1 A_CustomMissile("AutoDroneBall",8,0,0,0)
        TNT1 A 0 A_PlaySound("ForceCube/Fire")
        DRON A 1
        Stop
    }
}

ACTOR AutoDroneBall
{
   Radius 8
   Height 8
   Speed 20
   Damage 48
   PROJECTILE
   RENDERSTYLE ADD
   ALPHA 0.90
   Scale 0.2
   damagetype "bossfactor"
   +NOTIMEFREEZE
   +THRUGHOST
   SeeSound "weapons/devbal"
   DeathSound "weapons/devex2"
   States
   {
   Spawn:
      DBA2 AB 4 Bright
      Loop
   Death:
      DBA2 C 4 Bright
      DBA2 DE 4 Bright
      Stop
   }
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SMARTBOMB ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


actor SmartBombItem : CustomInventory 24026
{
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up the smart bomb!"
  inventory.maxamount 1
  inventory.icon SMAIA0
  Tag "Smart Bomb"
  +INVENTORY.INVBAR
  scale 0.75
  states
  {
  Spawn:
   	SMAP A -1 BRIGHT
    	stop
  Use:
        TNT1 A 1 A_SpawnItemEx("SmartBombGrenade", 0, 0, 32, 0, 10, 6, 90)
        stop
  }
}

actor SmartBombGrenade
{
	projectile
	-nogravity
	+hexenbounce
	+bounceonactors
	+canbouncewater
	+noexplodefloor
	+slidesonwalls
	-noteleport
	bouncefactor 0.6
	painsound ""
        damagetype "corefriendly"
	obituary "%o got blinded by %k."
        speed 6
	radius 2
	height 2
	damage 0
        States
        {
         Spawn:
          UVGR ABCD 1
          UVGR ABCD 2
          UVGR ABCD 4
          UVGR A 16 A_Stop
          UVGR A 0 A_PlaysoundEx("UVCharge","voice",0,1)
          UVGR A 0 A_SpawnItemEx("smallestlightemmit", 0, 0, 0, 0, 0, 0, 0, 128)
          UVGR A 0 A_SpawnItemEx("smallerlightemmit", 0, 0, 0, 0, 0, 0, 0, 128)
          UVGR E 170 BRIGHT A_SpawnItemEx("smalllightemmit", 0, 0, 0, 0, 0, 0, 0, 128)
          UVGR E 0 BRIGHT A_SpawnItemEx("Blindinglightemmit", 0, 0, 0, 0, 0, 0, 0, 128)
          UVGR E 0 BRIGHT A_SpawnItemEx("MoreBlindinglightemmit", 0, 0, 0, 0, 0, 0, 0, 128)
          UVGR E 0 BRIGHT A_SpawnItemEx("MostBlindinglightemmit", 0, 0, 0, 0, 0, 0, 0, 128)
          UVGR E 0 BRIGHT A_CustomMissile("LightRailer", 0, 0, 0)
          UVGR E 0 BRIGHT Radius_Quake(9,17,0,64,0)
          UVGR E 1 BRIGHT A_SpawnItemEx("RingLightemmit1", 0, 0, 0, 0, 0, 0, 0, 128)
	  UVGR E 1 BRIGHT A_SpawnItemEx("RingLightemmit2", 0, 0, 0, 0, 0, 0, 0, 128)
	  UVGR E 1 BRIGHT A_SpawnItemEx("RingLightemmit3", 0, 0, 0, 0, 0, 0, 0, 128)
	  UVGR E 1 BRIGHT A_SpawnItemEx("RingLightemmit4", 0, 0, 0, 0, 0, 0, 0, 128)
	  UVGR E 1 BRIGHT A_SpawnItemEx("RingLightemmit5", 0, 0, 0, 0, 0, 0, 0, 128)
          TNT1 A 15
          stop
		}
}

actor smalllightemmit
{
 radius 0
 height 0
 Renderstyle ADD
 alpha 0.75
 scale 0.5
 States
 {
   Spawn:
    WHFL A 170 BRIGHT
    WHFL A 1 BRIGHT A_Fadeout(0.05)
    goto spawn+1
 }
}

actor smallerlightemmit : smalllightemmit
{
scale 0.35
}

actor smallestlightemmit : smalllightemmit
{
scale 0.2
}

actor Blindinglightemmit : smalllightemmit
{
 alpha 0.5
 scale 1.0
 States
 {
  Spawn:
   WHFL A 50 BRIGHT
   WHFL A 1 BRIGHT A_Fadeout(0.05)
   goto spawn+1
}
}

actor moreBlindinglightemmit : Blindinglightemmit
{
 scale 0.75
}

actor mostBlindinglightemmit : Blindinglightemmit
{
 scale 0.5
}

actor Lightrailer
{
    +MissileMore
    +LOOKALLAROUND
    obituary "%o got blinded a smart bomb!"
    reactiontime 25
    MinMissileChance 0
    damagetype "corefriendly"
    Speed 0
    Radius 0
    Height 0
    States
    {
    Spawn:
        TNT1 A 0 A_Changeflag("FRIENDLY", 1)
        TNT1 A 1 A_Look
        TNT1 A 0 A_Changeflag("FRIENDLY", 0)
        TNT1 A 1 A_Look
        TNT1 A 0 A_Changeflag("FRIENDLY", 1)
        TNT1 A 1 A_Look
        TNT1 A 0 A_Changeflag("FRIENDLY", 0)
        TNT1 A 1 A_Look
        Stop
    See:
        TNT1 A 1 A_Facetarget
        TNT1 A 1 A_CustomRailgun (200, 0, NONE, WHITE, 1)
        TNT1 A 0 A_CustomRailgun (200, 0, NONE, GREY, 1)
        TNT1 A 0 A_CustomRailgun (200, 0, NONE, GREY, 1)
        TNT1 A 0 A_CustomRailgun (200, 0, NONE, WHITE, 1)
        TNT1 A 0 A_CustomRailgun (200, 0, NONE, GREY, 1)
        TNT1 A 0 A_CustomRailgun (200, 0, NONE, GREY, 1)
        TNT1 A 0 A_CustomRailgun (200, 0, NONE, WHITE, 1)
        TNT1 A 0 A_Countdown
        goto spawn
    }
}

actor RingLightemmit1
{
 radius 0
 height 0
 Renderstyle ADD
 alpha 0.5
 scale 5.0
 States
{
Spawn:
 WHFL B 2 BRIGHT
 stop
}
}

actor ringlightemmit2 : ringlightemmit1
{
 alpha 0.4
 scale 6.0
}

actor ringlightemmit3 : ringlightemmit1
{
 alpha 0.3
 scale 7.0
}

actor ringlightemmit4 : ringlightemmit1
{
 alpha 0.2
 scale 8.0
}

actor ringlightemmit5 : ringlightemmit1
{
 alpha 0.1
 scale 9.0
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// VAMPIRISM / DRAIN /////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor DrainItem : PowerupGiver 24040
{
//$Category Stronghold_Items
 scale 0.75
 inventory.pickupmessage "Picked up a vampirism sphere."
 inventory.icon "VAMIA0"
 inventory.maxamount 3
 inventory.usesound "pickups/slowmo"
 powerup.color "AA 00 00" 0.20
 powerup.type "Drain"
 powerup.duration 1575
 Tag "Vampirism"
 +INVENTORY.FANCYPICKUPSOUND
 states
 {
 Spawn:
   VAMP A -1 BRIGHT
   stop
 }
}

///////////////////////////////////////////////////////////////////////////////////////////////////////
// PROTECTION /////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

actor PowerQuarterDamage : PowerProtection
{
damagefactor "normal", 0.25
inventory.icon "MEGAA0"
}

actor ProtectionItem : PowerupGiver 24041
{
//$Category Stronghold_Items
 scale 0.75
 inventory.pickupmessage "Picked up a protection sphere."
 inventory.icon "PROIA0"
 inventory.maxamount 5
 inventory.usesound "pickups/slowmo"
 powerup.color "FF AA 00" 0.10
 powerup.type QuarterDamage
 powerup.duration 1575
 Tag "Protection"
 +INVENTORY.FANCYPICKUPSOUND
 states
 {
 Spawn:
   PROP A -1 BRIGHT
   stop
 }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// MORPHPOWERUP /////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////

ACTOR MorphPlayerItem : PowerUpGiver 24042
{
//$Category Stronghold_Items
 scale 0.75
 Inventory.PickupMessage "Picked up a morph sphere."
 inventory.usesound "pickups/slowmo"
 inventory.maxamount 2
 inventory.icon "MORIA0"
 Powerup.Type MorphPlayer
 Powerup.Duration 1575
 Tag "Morpher"
 +INVENTORY.FANCYPICKUPSOUND
 states
 {
 Spawn:
   MORP A -1 BRIGHT
   stop
 }
}

ACTOR PowerMorphPlayer : PowerMorph
{
	PowerMorph.PlayerClass "MorphedPlayer"
	PowerMorph.MorphStyle (MRF_FULLHEALTH|MRF_ADDSTAMINA|MRF_WHENINVULNERABLE|MRF_NEWTIDBEHAVIOUR|MRF_LOSEACTUALWEAPON)
}

/////////////////////////////////////////////////////////////////////////////////////////////////
// I WIN BUTTON - POWERUP ///////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////

actor PowerOSPDamage : PowerDamage {
  damagefactor "normal", 4
}
actor PowerOSPSpeed : PowerSpeed {
  Speed 2.0
}

actor OSPInv : PowerupGiver {
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  Inventory.MaxAmount 0
  Powerup.Duration -60
  Powerup.Type "Invulnerable"
  Powerup.Color GoldMap
  States
  {
  Spawn:
    MEGA A 6
    Loop
  }
}
actor OSPQuad : PowerupGiver {
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  Inventory.MaxAmount 0
  Powerup.Duration -60
  Powerup.Type "OSPDamage"
  Powerup.color "FF 00 00", 0.35
  States
  {
  Spawn:
    MEGA A 6
    Loop
  }
}
actor OSPSpeed : PowerupGiver {
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  Inventory.MaxAmount 0
  Powerup.Duration -60
  Powerup.Type "OSPSpeed"
  States
  {
  Spawn:
    MEGA A 6
    Loop
  }
}

actor OSPPower : PowerupGiver {
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  Inventory.MaxAmount 0
  Powerup.Duration -60
  Powerup.Type "WeaponLevel2"
  States
  {
  Spawn:
    MEGA A 6
    Loop
  }
}

actor OSPHealth : Health {
  Inventory.Amount 300
  Inventory.MaxAmount 300
  States
  {
  Spawn:
    SOUL A 6
    Loop
  }
}

actor IWinButtonItem : CustomInventory 23475
{
//$Category Stronghold_Items
  inventory.maxamount 1
  Inventory.Icon IWBIA0
  Inventory.PickupMessage "You got the I Win Button. Yay!"
  +INVENTORY.INVBAR
  Tag "I Win Button"
  states
  {
    Spawn:
      IWBP A -1 BRIGHT
      stop
    Use:
      TNT1 A 0 A_GiveInventory("OSPInv")
      TNT1 A 0 A_GiveInventory("OSPQuad")
      TNT1 A 0 A_GiveInventory("OSPSpeed")
      //TNT1 A 0 A_GiveInventory("OSPPower")
      //TNT1 A 0 A_GiveInventory("OSPHealth")
	  TNT1 A 0 A_SpawnItemEx("AllMap",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	  TNT1 A 0 A_SpawnItemEx("Blursphere",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	  TNT1 A 0 A_SpawnItemEx("Megasphere",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
      stop
  }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SUPER SENTRY //////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Actor SuperSentryItem : CustomInventory 25008
{
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up a deployable super sentry turret."
  inventory.maxamount 3
  inventory.icon SSEIA0
  Tag "Super Sentry Turret"
  +INVENTORY.INVBAR
  Scale 0.75
  States
  {
  Spawn:
   		SSEN A -1 BRIGHT
    	Stop
  Use:
  		TNT1 A 1 A_PlaySound("DSSTPLAC", CHAN_AUTO, 0.7)
		TNT1 A 1 A_SpawnItem("ItemFog", 64, 16, 0, 1)
		TNT1 A 1 A_SpawnItem("SuperSentry", 64, 0, 0, 1)
  		Stop
  }
}

Actor SuperSentryPlasma
{
	radius 1
	height 2
	speed 20
        damage 4
        scale 0.3
	damagetype "bossfactor"
	+NOEXTREMEDEATH
	+DONTBLAST
	+PAINLESS
        +THRUGHOST
	PROJECTILE
        translation "192:207=208:223","240:246=223:223"
        SeeSound "weapons/repfir"
        DeathSound "weapons/railf1"
	states
 	{
 	spawn:
   		PLSS AB 4 Bright
   		loop
 	Death:
   		PLSE ABCDE 4 Bright
		TNT1 A 0
  		Stop
 	}
}

Actor SuperSentry
{
//$Category Stronghold_Marines
	mass 9999999999
	DamageFactor "overmindfactor", 10
	radius 16
	height 16
	health 100000
	maxstepheight 512
	maxdropoffheight 512
	Species "Player"
	+nodamage
	+THRUSPECIES
	+MTHRUSPECIES
	-shootable
	+notarget
	+noblood
	+friendly
	+lookallaround
	+missilemore
	+missileevenmore
	+NORADIUSDMG
	speed 0
	states
 	{
 	spawn:
 		DGUN A 4 a_look
 		loop
 	see:
 		DGUN A 4 A_chase
 		loop
	missile:
 		DGUN A 4 A_facetarget
		Goto Missile+2
		DGUN A 2 A_facetarget
 		DGUN B 4 A_custommissile("SuperSentryPlasma", 16, -10, 0)
 		DGUN C 4 A_custommissile("SuperSentryPlasma", 16, 10, 0)
 		DGUN A 4 A_CPosRefire //was A 4
 		Goto Missile+1
	death:
 		TNT1 A 4
 		stop
 	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ELITE MARINE REINFORCEMENTS //////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Actor SuperMarineItem : CustomInventory 25009
{
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up some elite marine reinforcements."
  inventory.maxamount 3
  Tag "Elite Marine Reinforcements"
  inventory.icon SMRIA0
  +INVENTORY.INVBAR
  Scale 0.75
  States
  {
  Spawn:
   	SMAR A -1 BRIGHT
    	Stop
  Use:
	TNT1 A 1 A_SpawnItem("TeleportFog", 64, 16, 0, 0)
	TNT1 A 0 A_Jump(128, "PyroCannon")
	TNT1 A 0 A_SpawnItem("STMarineBFG", 64, 16, 0, 1)
	Stop
  PyroCannon:
	TNT1 A 0 A_Jump(128, "Devastator")
	TNT1 A 0 A_SpawnItem("STMarinePyroCannon", 64, 16, 0, 1)
	Stop
  Devastator:
	TNT1 A 0 A_SpawnItem("STMarineDevastator", 64, 16, 0, 1)
	Stop
  }
}

Actor SuperMarineTimer : Powerup
{
	Powerup.Duration 52
}

Actor STMarineBFG
{
	PainChance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+MISSILEMORE
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "BFG Marine"
	DamageFactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	Species "Player"
	States
	{
	Spawn:
		PB10 A 4 A_Look
		Loop
	See:
		PB10 ABCD 4 A_Chase
		Loop
	Missile:
		TNT1 A 0 A_JumpIfInventory("SuperMarineTimer", 1, "See")
		TNT1 A 0 A_ChangeFlag("NOPAIN",1)
		TNT1 A 0 A_PlaySound("weapons/bfgf")
		PB10 EEEEE 6 A_FaceTarget
		PB10 E 1
      	PB10 F 10 A_CustomMissile("MarineBFGBall")
      	PB10 E 33
		TNT1 A 0 A_GiveInventory("SuperMarineTimer", 1)
		TNT1 A 0 A_ChangeFlag("NOPAIN",0)
		Goto See
	Pain:
		PB10 G 4
		PB10 G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		PB10 H 10
		PB10 I 10 A_Scream
		PB10 J 10 A_NoBlocking
		PB10 KLM 10
		PB10 N -1
		Stop
	XDeath:
		PB10 O 5
		PB10 P 5 A_XScream
		PB10 Q 5 A_NoBlocking
		PB10 RSTUV 5
		PB10 W -1
		Stop
	}
}

Actor MarineBFGBall
{
  Radius 13
  Height 8
  Speed 25
  Damage 100
  RenderStyle Add
  Alpha 0.75
  DeathSound "weapons/bfgx"
  DamageType "MarineAlly"
  PROJECTILE
  +RANDOMIZE
  Decal BFGLightning
  States
  {
  Spawn:
    BFS1 AB 4 bright
    Loop
  Death:
    BFE1 A 8 bright A_Explode(128,256,0)
    BFE1 BCDEF 8 bright
    Stop
  }
}

Actor STMarinePyroCannon
{
	PainChance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 10
	Health 300
	Speed 8
	Tag "Pyro Cannon Marine"
	DamageFactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	Species "Player"
	States
	{
	Spawn:
		PPYR A 4 A_Look
		Loop
	See:
		PPYR ABCD 4 A_Chase
		Loop
	Missile:
		TNT1 A 0 A_JumpIfInventory("SuperMarineTimer", 1, "See")
		TNT1 A 0 A_ChangeFlag("NOPAIN",1)
		PPYR EE 6 A_FaceTarget
		PPYR E 1
		PPYR F 15 A_CustomMissile("MarinePyroShot")
      	PPYR E 20
		TNT1 A 0 A_GiveInventory("SuperMarineTimer", 1)
		TNT1 A 0 A_ChangeFlag("NOPAIN",0)
		Goto See
	Pain:
		PPYR G 4
		PPYR G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		PPYR H 10
		PPYR I 10 A_Scream
		PPYR J 10 A_NoBlocking
		PPYR KLM 10
		PPYR N -1
		Stop
	XDeath:
		PPYR O 5
		PPYR P 5 A_XScream
		PPYR Q 5 A_NoBlocking
		PPYR RSTUV 5
		PPYR W -1
		Stop
	}
}

Actor MarinePyroShot
{
   Radius 8
   Height 12
   Speed 30
   Damage 100
   PROJECTILE
   RenderStyle Add
   DamageType "MarineAlly"
   Alpha 0.95
   Scale 0.75
   SeeSound "weapons/hellfi"
   DeathSound "weapons/hellex"
   Decal BigScorch
   States
   {
   Spawn:
      PBAL ABA 4 Bright
	  PBAL BA 4 Bright A_Explode(64,128,0)
      Loop
   Death:
      PYXP AB 2 Bright
      PYXP C 2 Bright A_Explode(128,256,0)
      PYXP C 0 Bright A_CustomMissile("MarinePyroSpawner",0,0,0,4)
      PYXP C 0 Bright A_CustomMissile("MarinePyroSpawner",0,0,45,4)
      PYXP C 0 Bright A_CustomMissile("MarinePyroSpawner",0,0,90,4)
      PYXP C 0 Bright A_CustomMissile("MarinePyroSpawner",0,0,135,4)
      PYXP C 0 Bright A_CustomMissile("MarinePyroSpawner",0,0,180,4)
      PYXP C 0 Bright A_CustomMissile("MarinePyroSpawner",0,0,225,4)
      PYXP C 0 Bright A_CustomMissile("MarinePyroSpawner",0,0,270,4)
      PYXP C 0 Bright A_CustomMissile("MarinePyroSpawner",0,0,315,4)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,0,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,4.75,4.75,18.5,0,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,17.5,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,4.4,4.4,18.5,45,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,6.3,6.3,18.5,45,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,72.5,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,90,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,4.75,4.75,18.5,90,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,107.5,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,4.4,4.4,18.5,135,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,6.3,6.3,18.5,135,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,162.5,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,180,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,4.75,4.75,18.5,180,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,197.5,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,4.4,4.4,18.5,225,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,6.3,6.3,18.5,225,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,252.5,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,270,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,4.75,4.75,18.5,270,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,287.5,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,4.4,4.4,18.5,315,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,6.3,6.3,18.5,315,SXF_ABSOLUTEANGLE)
	  PYXP C 0 Bright A_SpawnItemEx("MarinePyroFlare",0,0,0,3.7,3.7,18.5,342.5,SXF_ABSOLUTEANGLE)
      PYXP DEFGHIJKLMNOPQRSTU 2 Bright
      stop
   }
}

Actor MarinePyroSpawner
{
   Radius 1
   Height 1
   PROJECTILE
   Speed 15
   +RIPPER
   +BLOODLESSIMPACT
   +PAINLESS
   States
   {
   Spawn:
      TNT1 AAAAA 5 Bright A_CustomMissile("MarinePyroBoom",0,0,0,4)
      stop
   }
}

Actor MarinePyroBoom
{
   Radius 0
   Height 1
   PROJECTILE
   RenderStyle Add
   Alpha 0.95
   Scale 0.67
   +THRUGHOST
   SeeSound "weapons/boom1"
   States
   {
   Spawn:
      PYXP ABCDEFGHIJKLMNOPQRSTU 2 Bright
      stop
   }
}

Actor MarinePyroFlare
{
   Radius 8
   Height 11
   Speed 35
   Damage 7
   PROJECTILE
   RenderStyle Add
   DamageType "MarineAlly"
   Decal DoomImpScorch
   Alpha 0.95
   -NOGRAVITY
   +THRUGHOST
   DeathSound "weapons/bang1"
   States
   {
   Spawn:
      TNT1 A 1 Bright A_SpawnItemEx("PyroFX",0,0,0,0,0,0,0,128)
      loop
   Death:
      FRFX HIJ 2 Bright
      FRFX J 0 A_Explode(48,64,0)
      FRFX J 0 A_SpawnItem("MarineDropFire",0,0)
      FRFX KLMNO 2 Bright
      stop
   }
}


Actor STMarineDevastator
{
	PainChance 160
	MONSTER
	-COUNTKILL
	-ACTIVATEMCROSS
	+NOTIMEFREEZE
	+NODROPOFF
	Radius 16
	Height 56
	Mass 100
	Health 300
	Speed 8
	Tag "Plasma Devastator Marine"
	DamageFactor "MarineAlly", 0
	SeeSound "marine/sight"
    ActiveSound "marine/active"
    DeathSound "marine/death"
    PainSound "marine/pain"
	Species "Player"
	States
	{
	Spawn:
		PDEV A 4 A_Look
		Loop
	See:
		PDEV ABCD 4 A_Chase
		Loop
	Missile:
		TNT1 A 0 A_JumpIfInventory("SuperMarineTimer", 1, "See")
		TNT1 A 0 A_ChangeFlag("NOPAIN",1)
		TNT1 A 0 A_PlaySound("weapons/devchr")
		PDEV EEEEEEEEE 6 A_FaceTarget
		PDEV E 1 A_PlaySound("weapons/devfir")
      	PDEV F 10 A_CustomMissile("MarineDevastatorBall")
      	PDEV E 7
		TNT1 A 0 A_GiveInventory("SuperMarineTimer", 1)
		TNT1 A 0 A_ChangeFlag("NOPAIN",0)
		Goto See
	Pain:
		PDEV G 4
		PDEV G 4 A_Pain
		TNT1 A 0 A_Chase("", "", CHF_FASTCHASE)
		Goto See
	Death:
		PDEV H 10
		PDEV I 10 A_Scream
		PDEV J 10 A_NoBlocking
		PDEV KLM 10
		PDEV N -1
		Stop
	XDeath:
		PDEV O 5
		PDEV P 5 A_XScream
		PDEV Q 5 A_NoBlocking
		PDEV RSTUV 5
		PDEV W -1
		Stop
	}
}

Actor MarineDevastatorBall
{
   Radius 12
   Height 8
   Speed 30
   Damage 150
   PROJECTILE
   RenderStyle Add
   Alpha 0.90
   DamageType "MarineAlly"
   DeathSound "weapons/devexp"
   Decal DevastatorLightning
   States
   {
   Spawn:
      DBAL AB 4 Bright
      DBAL A 4 Bright A_Explode(64,128,0)
      DBAL A 0 Bright A_Jump (160,3)
      DBAL AAA 0 Bright A_CustomMissile("MarineLiteShot",0,0,Random(0,360))
      DBAL B 4 Bright A_Explode(64,128,0)
      DBAL B 0 Bright A_Jump (160,3)
      DBAL BBB 0 Bright A_CustomMissile("MarineLiteShot",0,0,Random(0,360))
      Goto Spawn+2
   Death:
      DBAL C 5 Bright
      DBAL D 5 Bright A_Explode(128,256,0)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,18,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,36,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,54,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,72,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,90,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,108,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,126,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,144,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,144,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,162,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,180,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,196,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,216,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,234,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,252,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,270,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,288,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,306,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,324,6)
      DBAL D 0 Bright A_CustomMissile("MarineDevastatorBall2",0,0,342,6)
      DBAL EFG 5 Bright
      DBAL HI 3 Bright
      Stop
   }
}

Actor MarineDevastatorBall2
{
   Radius 8
   Height 8
   Speed 10
   Damage 6
   PROJECTILE
   RenderStyle Add
   Alpha 0.90
   DamageType "MarineAlly"
   Decal DoomImpScorch
   +FORCEXYBILLBOARD
   SeeSound "weapons/devbal"
   DeathSound "weapons/devex2" 
   States
   {
   Spawn:
      DBA2 AB 4 Bright
      Loop
   Death:
      DBA2 C 1 Bright
      DBA2 C 3 Bright A_Explode(48,64,0)
      DBA2 DE 4 Bright
      Stop
   }
}

Actor MarineLiteShot
{
   Radius 8
   Height 12
   Speed 32
   Damage 6
   PROJECTILE
   RenderStyle Add
   Alpha 0.85
   DamageType "MarineAlly"
   +RIPPER
   +FORCEXYBILLBOARD
   SeeSound "weapons/devlit"
   DeathSound "weapons/devzap" 
   States
   {
   Spawn:
      DLIT AAABBBCCC 1 Bright A_SpawnItemEx("LiteTrail",0,0,0,0,0,0,0,0,128)
      Loop
   Death:
      DLIT DEFGHIJKLMNO 1 Bright
      Stop
   }
}

ACTOR LiteTrail
{
   Radius 1
   Height 1
   PROJECTILE
   RENDERSTYLE ADD
   ALPHA 0.67
   +FORCEXYBILLBOARD
   States
   {
   Spawn:
      DLIT ABC 3 Bright
      stop
   }
}

/////////////////////////////////////////////////////////////////////////
////////////////////////Flying Rat Brigade///////////////////////////////
/////////////////////////////////////////////////////////////////////////

Actor PlaneRatItem : CustomInventory 23480
 {
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up some Trained Rat Pilots."
  inventory.maxamount 10
  Tag "Trained Rat Reinforcements"
  inventory.icon RATIA0
  +INVENTORY.INVBAR
  +GHOST
  scale 0.75
  states
  {
  Spawn:
   	RATP A -1 BRIGHT
    	stop
  Use:
        TNT1 A 1 A_SpawnItem("TeleportFog", 64, 16, 0, 1)
TNT1 A 1 A_SpawnItemEx("StupidRatPlaneMonster2", 0, 0, 28, 6, 0, 0, 0, SXF_SETMASTER|SXF_NOCHECKPOSITION|SXF_TRANSFERTRANSLATION)
Stop
}
}

 Actor PlaneRatItem2 : CustomInventory 23482
 {
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up some Elite Rat Pilots."
  inventory.maxamount 2
  Tag "Elite Rat Reinforcements"
  inventory.icon ERTIA0
  +INVENTORY.INVBAR
  +GHOST
  scale 0.75
  states
  {
  Spawn:
   	ERTP A -1 BRIGHT
    	stop
  Use:
        TNT1 A 1 A_SpawnItem("TeleportFog", 64, 16, 0, 1)
TNT1 A 1 A_SpawnItemEx("StupidRatPlaneMonster3", 0, 0, 28, 6, 0, 0, 0, SXF_SETMASTER|SXF_NOCHECKPOSITION|SXF_TRANSFERTRANSLATION)
Stop
}
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// WEAPON POWERUP ITEM...? //////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

actor WeaponPowerItem : CustomInventory 25007
{
//$Category Stronghold_Items
  inventory.pickupmessage "Picked up a powerup fountain kit."
  inventory.maxamount 3
  inventory.icon POWIA0
  tag "Powerup Fountain Kit"
  +INVENTORY.INVBAR
  scale 0.75
  states
  {
  Spawn:
   	POWP A -1 BRIGHT
    	stop
  Pickup:
  	TNT1 A 1 A_PlaySound("pickup")
  	stop
  Use:
	TNT1 A 0 A_SpawnItemEx("StrongholdCompatibilityEditionPowerupFountain",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION,0)
	Stop
  }
}

actor StrongholdCompatibilityEditionPowerupFountain
{
  +NOBLOCKMAP
  +NOSECTOR
  +NOGRAVITY
  +THRUACTORS
  States
  {
  Spawn:
    TNT1 A 0
    TNT1 AAAAAAAAAAAAAAAAAAAAAAAAA 1 A_SpawnItemEx("HealthBonus", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 16), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 AAAAAAAAAA 1 A_SpawnItemEx("ArmorBonus", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 16), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 AAAAA 2 A_SpawnItemEx("Stimpack", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 12),frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 AA 2 A_SpawnItemEx("Medikit", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 12), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 AAAAA 2 A_SpawnItemEx("Clip", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 16), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 AAAAA 2 A_SpawnItemEx("Shell", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 16), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 AAAAAAA 2 A_SpawnItemEx("RocketAmmo", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 16), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 AAAAA 2 A_SpawnItemEx("Cell", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 16), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 AAAA 2 A_SpawnItemEx("Gas", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 16), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 AA 2 A_SpawnItemEx("Mines", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 16), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 2 A_SpawnItemEx("ClipBox", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 12), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 2 A_SpawnItemEx("ShellBox", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 12), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 AAA 2 A_SpawnItemEx("RocketBox", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 12), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 2 A_SpawnItemEx("CellPack", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 12), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 2 A_SpawnItemEx("Fuel", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 16), frandom(0,360),SXF_NOCHECKPOSITION,0)

    TNT1 A 7 A_SpawnItemEx("Backpack", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 8), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 7 A_SpawnItemEx("AllMap", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 8), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 7 A_SpawnItemEx("Infrared", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 8), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 7 A_SpawnItemEx("GreenArmor", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 8), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 7 A_SpawnItemEx("Berserk", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 8), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 7 A_SpawnItemEx("BlueArmor", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 8), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 7 A_SpawnItemEx("SoulSphere", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 8), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 7 A_SpawnItemEx("Megasphere", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 4), frandom(0,360),SXF_NOCHECKPOSITION,0)
    TNT1 A 7 A_SpawnItemEx("BlurSphere", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 4), frandom(0,360),SXF_NOCHECKPOSITION,0)
//    TNT1 A 7 A_SpawnItemEx("InvulnerabilitySphere", 0, 0, 128, frandom(0, 4), frandom(0, 4), frandom(0, 16), frandom(0,360),SXF_NOCHECKPOSITION,0)
  	stop
  }
}