//==============================================================================
//
// CAPTURE THE FLAG STUFF
//
//==============================================================================

//Message stuff

actor ST4ZD_BlueCTFReturnMessageSpawner
{
	+NOBLOCKMAP
	+NOINTERACTION
	states
	{
	Spawn:
		TNT1 AA 1 A_RadiusGive("ST4ZD_BlueCTFReturnMessage", 16383, RGF_CUBE, 1)
		stop
	}
}

ACTOR ST4ZD_BlueCTFReturnMessage : CustomInventory
{
+INVENTORY.AUTOACTIVATE
+ALWAYSPICKUP
States
{
Spawn:
TNT1 A 1
Stop
Use:
Pickup:
TNT1 AA 1 A_Print("The blue flag has been returned!")
Stop
}
}

//Original team starts (Unused)

Actor BlueStart : Dummything 5080 {}

Actor RedStart : Dummything 5081 {}

//Token items to know the state of the flag, score, etc.

ACTOR HasRedFlag : Inventory {Inventory.MaxAmount 1 +INTERHUBSTRIP}
ACTOR SpawnRedFlag : Inventory {Inventory.MaxAmount 1 }
ACTOR SpawnFakeRedFlag : Inventory {Inventory.MaxAmount 1 }

ACTOR HasBlueFlag : Inventory {Inventory.MaxAmount 1 +INTERHUBSTRIP}
ACTOR SpawnBlueFlag : Inventory {Inventory.MaxAmount 1 }
ACTOR SpawnFakeBlueFlag : Inventory {Inventory.MaxAmount 1 }

ACTOR GetRedFlag : Inventory {Inventory.MaxAmount 1 +INTERHUBSTRIP}
ACTOR GetBlueFlag : Inventory {Inventory.MaxAmount 1 +INTERHUBSTRIP}
ACTOR STZD_ImmaBot : Inventory {Inventory.MaxAmount 1 +UNDROPPABLE}

//No one will reach the score limit unless that person is REALLY REALLY bored
ACTOR RedScore : Inventory {Inventory.MaxAmount 32767} 
ACTOR BlueScore : Inventory {Inventory.MaxAmount 32767} 
ACTOR IsPlayingCTF : Inventory {Inventory.MaxAmount 1}

ACTOR CTFRFlagIcon
{
Health 100
Radius 1
Height 1
+NOCLIP
-SOLID
-SHOOTABLE
+NOBLOCKMAP
+THRUACTORS
+NOGRAVITY
+INVULNERABLE
States
{
Spawn:
RFLA A 2
Stop
}
}

ACTOR CTFBFlagIcon
{
Health 100
Radius 1
Height 1
+NOCLIP
-SOLID
-SHOOTABLE
+NOBLOCKMAP
+THRUACTORS
+NOGRAVITY
+INVULNERABLE
States
{
Spawn:
BFLA A 2
Stop
}
}

ACTOR CTFRedFlagIconSpawner : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	+INVENTORY.AUTOACTIVATE
	States
	{
	Spawn:
		TNT1 A 1
		Loop
	Pickup:
    Use:
	    TNT1 A 0 A_SpawnItem("CTFRFlagIcon", -16)
		Stop
	}
}

ACTOR CTFBlueFlagIconSpawner : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	+INVENTORY.AUTOACTIVATE
	States
	{
	Spawn:
		TNT1 A 1
		Loop
	Pickup:
    Use:
	    TNT1 A 0 A_SpawnItem("CTFBFlagIcon", -16)
		Stop
	}
}

//This actor is a container for CTF score items, when you score 1 point
//either RedScore or BlueScore is given depending on your team, and
//is recieved by this actor, then to know how much score there is
//an ACS script checks every 4 tics how much of each actor is in this 
//actor's inventory and updates the score on screen depending on the amount
ACTOR CTFScoreSystem
{
Health 100
Radius 1
Height 1
+NOCLIP
-SOLID
-SHOOTABLE
+NOBLOCKMAP
+THRUACTORS
+INVULNERABLE
States
{
Spawn:
TNT1 A 1
TNT1 A 0 A_GiveInventory("IsPlayingCTF", 1)
TNT1 A 0 Thing_ChangeTID(0, 1898668)
TNT1 A -1
Wait
}
}

//Other stuff like flags and their capture spots
ACTOR RedFlagCapSpot : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	States
	{
	Spawn:
		TNT1 A 1
		Loop
	Pickup:
	    TNT1 A 1 A_JumpIfInventory("HasBlueFlag", 1, "Capture")
		Fail
	Capture:
		TNT1 A 1 ACS_NamedExecuteAlways("ST4ZD_CaptureBlueFlag", 0)
		Fail
	}
}

ACTOR RedFlagSpot : CustomInventory 5131
{
	Game Doom
	Radius 1
	Height 1
	Inventory.PickupMessage "Lol"
	-PICKUP
	+THRUACTORS
	+NOBLOCKMAP
	States
	{
	Spawn:
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("SpawnRedFlag", 10)
		TNT1 A 0 Thing_ChangeTID(0, 9131)
		TNT1 A 0 A_SpawnItem("RedFlag")
		TNT1 A 0 A_SpawnItem("RedFlagCapSpot")
		TNT1 A 0 A_SpawnItem("CTFScoreSystem")
		Goto Waiting
	Spawn2:
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("SpawnRedFlag", 10)
		TNT1 A 0 Thing_ChangeTID(0, 9131)
		TNT1 A 0 A_SpawnItem("RedFlag")
		Goto Waiting
	SpawnFake:
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("SpawnFakeRedFlag", 10)
		TNT1 A 0 Thing_ChangeTID(0, 9131)
		TNT1 A 0 A_SpawnItem("FakeRedFlag")
		Goto Waiting
	Waiting:
	    TNT1 A 1 A_JumpIfInventory("SpawnRedFlag", 1, "Spawn2")
		TNT1 A 0 A_JumpIfInventory("SpawnFakeRedFlag", 1, "SpawnFake")
		Loop
	Pickup:
		TNT1 A 0 A_Print("Crap!")
		Goto Waiting
	}
}

ACTOR BlueFlagCapSpot : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	States
	{
	Spawn:
		TNT1 A 1
		Loop
	Pickup:
	    TNT1 A 1 A_JumpIfInventory("HasRedFlag", 1, "Capture")
		Fail
	Capture:
		TNT1 A 1 ACS_NamedExecuteAlways("ST4ZD_CaptureRedFlag", 0)
		Fail
	}
}

ACTOR BlueFlagSpot : CustomInventory 5130
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage "Lol"
	-PICKUP
	+NOBLOCKMAP
	+THRUACTORS
	States
	{
	Spawn:
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("SpawnBlueFlag", 10)
		TNT1 A 0 Thing_ChangeTID(0, 9130)
		TNT1 A 0 A_SpawnItem("BlueFlag")
		TNT1 A 0 A_SpawnItem("BlueFlagCapSpot")
		Goto Waiting
	Spawn2:
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("SpawnBlueFlag", 10)
		TNT1 A 0 Thing_ChangeTID(0, 9130)
		TNT1 A 0 A_SpawnItem("BlueFlag")
		Goto Waiting
	SpawnFake:
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("SpawnFakeBlueFlag", 10)
		TNT1 A 0 Thing_ChangeTID(0, 9130)
		TNT1 A 0 A_SpawnItem("FakeBlueFlag")
		Goto Waiting
	Waiting:
	    TNT1 A 1 A_JumpIfInventory("SpawnBlueFlag", 1, "Spawn2")
		TNT1 A 0 A_JumpIfInventory("SpawnFakeBlueFlag", 1, "SpawnFake")
		Loop
	Pickup:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_CaptureRedFlag", 0)
		Goto Waiting
	}
}

ACTOR RedFlag : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	+NEVERRESPAWN
	States
	{
	Spawn:
	    RFLA ABC 3
		RFLA DEF 3 Bright
		loop
	Pickup:
	    TNT1 A 0 A_TakeInventory("RedFlag", 100)
	    TNT1 A 0 A_JumpIfInventory("GetRedFlag", 1, "DoGiveFlag")
		//TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnFakeRedFlag", 0)
		Fail
		//TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnRedFlag", 0)
		//Stop
	DoGiveFlag:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_StealRedFlag", 0)
		TNT1 A 0 A_GiveInventory("HasRedFlag", 1)
		Stop
	}
}

ACTOR LoopsLeftToReturn : Inventory {Inventory.MaxAmount 40 }

ACTOR RedFlagDrop : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	+NEVERRESPAWN
	States
	{
	Spawn:
	    RFLA ABC 3
		RFLA DEF 3 Bright
		TNT1 A 0 A_JumpIfInventory("LoopsLeftToReturn", 40, "ReturnFlag")
		TNT1 A 0 A_GiveInventory("LoopsLeftToReturn", 1)
		loop
	Pickup:
	    TNT1 A 0 A_TakeInventory("RedFlagDrop", 100)
	    RFLA A 1 A_JumpIfInventory("GetRedFlag", 1, "DoGiveFlag")
		TNT1 A 0 A_JumpIfInventory("GetBlueFlag", 1, "ReturnFlag")
		Fail
	ReturnFlag:
	    TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnRedFlag", 0)
		Stop
	DoGiveFlag:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_StealRedFlag", 0)
		TNT1 A 0 A_GiveInventory("HasRedFlag", 1)
		Stop
	}
}

ACTOR FakeRedFlag
{
	Game Doom
	Radius 1
	Height 1
	-PICKUP
	+NOBLOCKMAP
	+THRUACTORS
	+NEVERRESPAWN
	-SOLID
	States
	{
	Spawn: //cooldown to pick up the flag again
		RFLA ABC 3
		RFLA DEF 3 Bright
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnRedFlag", 0)
		Stop
	}
}
/*
ACTOR RedFlagDrop : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	-PICKUP
	+ALWAYSPICKUP
	+NEVERRESPAWN
	States
	{
	Spawn:
		RFLA ABC 3
		RFLA DEF 3 Bright
		loop
	Pickup:
		//TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnRedFlag", 0)
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnFakeBlueFlag", 0)
		TNT1 A 0 A_TakeInventory("RedFlagDrop", 1)
		stop
	}
}
*/
ACTOR BlueFlag : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	-PICKUP
	//+ALWAYSPICKUP this flag caused a bug and for 2 weeks i didn't know what
	+NEVERRESPAWN //was actually causing it, i finally found out!
	States
	{
	Spawn:
	    BFLA ABC 3
		BFLA DEF 3 Bright
		loop
	Pickup:
	    TNT1 A 0 A_TakeInventory("BlueFlag", 100)
	    TNT1 A 0 A_JumpIfInventory("GetBlueFlag", 1, "DoGiveFlag")
		//TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnFakeBlueFlag", 0)
		Fail
	DoGiveFlag:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_StealBlueFlag", 0)
		TNT1 A 0 A_GiveInventory("HasBlueFlag", 1)
		Stop
	}
}

ACTOR FakeBlueFlag
{
	Game Doom
	Radius 1
	Height 1
	-PICKUP
	+NOBLOCKMAP
	+THRUACTORS
	+NEVERRESPAWN
	-SOLID
	States
	{
	Spawn: //cooldown to pick up the flag again
		BFLA ABC 3
		BFLA DEF 3 Bright
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnBlueFlag", 0)
		Stop
	}
}
/*
ACTOR BlueFlagDrop : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	-PICKUP
	+ALWAYSPICKUP
	+NEVERRESPAWN
	States
	{
	Spawn:
		BFLA ABC 3
		BFLA DEF 3 Bright
		loop
	Pickup:
		//TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnBlueFlag", 0)
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnFakeBlueFlag", 0)
		stop
	}
}
*/
ACTOR BlueFlagDrop : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	+NEVERRESPAWN
	States
	{
	Spawn:
	    BFLA ABC 3
		BFLA DEF 3 Bright
		TNT1 A 0 A_JumpIfInventory("LoopsLeftToReturn", 40, "ReturnFlag")
		TNT1 A 0 A_GiveInventory("LoopsLeftToReturn", 1)
		loop
	Pickup:
	    TNT1 A 0 A_TakeInventory("BlueFlagDrop", 100)
	    BFLA A 1 A_JumpIfInventory("GetBlueFlag", 1, "DoGiveFlag")
		TNT1 A 0 A_JumpIfInventory("GetRedFlag", 1, "ReturnFlag")
		Fail
	ReturnFlag:
	    TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnBlueFlag", 0)
		Stop
	DoGiveFlag:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_StealBlueFlag", 0)
		TNT1 A 0 A_GiveInventory("HasBlueFlag", 1)
		Stop
	}
}

//==============================================================================
//
// SKULLTAG STUFF
//
//==============================================================================
//A copy paste of the stuff seen above but slightly modified so the flag
//now looks like a skull, and the capture points are moved to other place
//and made visible, plus other minor stuff.
//And simplified it quite a bit, which means it might be more or less buggier

//Token items to know the state of the skull, score, etc.

ACTOR HasRedSkull : Inventory {Inventory.MaxAmount 1 +INTERHUBSTRIP}
ACTOR SpawnRedSkull : Inventory {Inventory.MaxAmount 1 }
ACTOR SpawnFakeRedSkull : Inventory {Inventory.MaxAmount 1 }

ACTOR HasBlueSkull : Inventory {Inventory.MaxAmount 1 +INTERHUBSTRIP}
ACTOR SpawnBlueSkull : Inventory {Inventory.MaxAmount 1 }
ACTOR SpawnFakeBlueSkull : Inventory {Inventory.MaxAmount 1 }

ACTOR GetRedSkull : Inventory {Inventory.MaxAmount 1 +INTERHUBSTRIP}
ACTOR GetBlueSkull : Inventory {Inventory.MaxAmount 1 +INTERHUBSTRIP}

ACTOR IsPlayingST : Inventory {Inventory.MaxAmount 1}

ACTOR STScoreSystem
{
Health 100
Radius 1
Height 1
+NOCLIP
-SOLID
-SHOOTABLE
+NOBLOCKMAP
+THRUACTORS
+INVULNERABLE
States
{
Spawn:
TNT1 A 1
TNT1 A 0 A_GiveInventory("IsPlayingST", 1)
TNT1 A 0 Thing_ChangeTID(0, 1898669)
TNT1 A -1
Wait
}
}

//Other stuff like skulls and the score pillar
ACTOR HellScorePillar : CustomInventory 5020
{
	Game Doom
	Radius 20
	Height 26
	-NOTDMATCH
	Inventory.PickupMessage ""
	States
	{
	Spawn:
		HLSP A 1
		Loop
	Pickup:
	    HLSP A 1 A_JumpIfInventory("HasBlueSkull", 1, "TagBlueSkull")
		HLSP A 1 A_JumpIfInventory("HasRedSkull", 1, "TagRedSkull")
		Fail
	TagRedSkull:
		TNT1 A 1 ACS_NamedExecuteAlways("ST4ZD_CaptureRedSkull", 0)
		HLSP D 35
		HLSP E 140
		Fail
	TagBlueSkull:
		TNT1 A 1 ACS_NamedExecuteAlways("ST4ZD_CaptureBlueSkull", 0)
		HLSP B 35
		HLSP C 140
		Fail
	}
}

//New score pillar things because it is far too stupid to allow the
//player to capture in the enemy base

ACTOR HellScorePillarBlue : CustomInventory 10022
{
	Game Doom
	Radius 20
	Height 26
	-NOTDMATCH
	Inventory.PickupMessage ""
	States
	{
	Spawn:
		HLSP A 1
		Loop
	Pickup:
		HLSP A 1 A_JumpIfInventory("HasRedSkull", 1, "TagRedSkull")
		Fail
	TagRedSkull:
		TNT1 A 1 ACS_NamedExecuteAlways("ST4ZD_CaptureRedSkull", 0)
		HLSP D 35
		HLSP E 140
		Fail
	TagBlueSkull:
		TNT1 A 1 ACS_NamedExecuteAlways("ST4ZD_CaptureBlueSkull", 0)
		HLSP B 35
		HLSP C 140
		Fail
	}
}

ACTOR HellScorePillarRed : CustomInventory 10021
{
	Game Doom
	Radius 20
	Height 26
	-NOTDMATCH
	Inventory.PickupMessage ""
	States
	{
	Spawn:
		HLSP A 1
		Loop
	Pickup:
	    HLSP A 1 A_JumpIfInventory("HasBlueSkull", 1, "TagBlueSkull")
		Fail
	TagRedSkull:
		TNT1 A 1 ACS_NamedExecuteAlways("ST4ZD_CaptureRedSkull", 0)
		HLSP D 35
		HLSP E 140
		Fail
	TagBlueSkull:
		TNT1 A 1 ACS_NamedExecuteAlways("ST4ZD_CaptureBlueSkull", 0)
		HLSP B 35
		HLSP C 140
		Fail
	}
}
//Had to make up a new number for the skulls since in the regular
//ST they are the same as the normal skullkeys, that means that
//you have to go through a teeny tiny bit of extra effort to make
//maps work for this mod
ACTOR RedSkullSpot : CustomInventory 10131
{
	Game Doom
	Radius 1
	Height 1
	Inventory.PickupMessage "Lol"
	-PICKUP
	+THRUACTORS
	+NOBLOCKMAP
	States
	{
	Spawn:
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("SpawnRedSkull", 100)
		TNT1 A 0 Thing_ChangeTID(0, 10131)
		TNT1 A 0 A_SpawnItem("RedSkullST")
		TNT1 A 0 A_SpawnItem("STScoreSystem")
		Goto Waiting
	Spawn2:
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("SpawnRedSkull", 100)
		TNT1 A 0 Thing_ChangeTID(0, 10131)
		TNT1 A 0 A_SpawnItem("RedSkullST")
		Goto Waiting
	Waiting:
	    TNT1 A 1 A_JumpIfInventory("SpawnRedSkull", 1, "Spawn2")
		Loop
	Pickup:
		TNT1 A 0
		Goto Waiting
	}
}

ACTOR BlueSkullSpot : CustomInventory 10130
{
	Game Doom
	Radius 1
	Height 1
	Inventory.PickupMessage "Lol"
	-PICKUP
	+THRUACTORS
	+NOBLOCKMAP
	States
	{
	Spawn:
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("SpawnBlueSkull", 100)
		TNT1 A 0 Thing_ChangeTID(0, 10130)
		TNT1 A 0 A_SpawnItem("BlueSkullST")
		TNT1 A 0 A_SpawnItem("STScoreSystem")
		Goto Waiting
	Spawn2:
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("SpawnBlueSkull", 100)
		TNT1 A 0 Thing_ChangeTID(0, 10130)
		TNT1 A 0 A_SpawnItem("BlueSkullST")
		Goto Waiting
	Waiting:
	    TNT1 A 1 A_JumpIfInventory("SpawnBlueSkull", 1, "Spawn2")
		Loop
	Pickup:
		TNT1 A 0 A_Print("Crap!")
		Goto Waiting
	}
}

ACTOR RedSkullST : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	Inventory.PickupFlash ""
	+NEVERRESPAWN
	//+NOSCREENFLASH
	States
	{
	Spawn:
	    RSKU A 10
		RSKU B 10 BRIGHT
		loop
	Pickup:
	    TNT1 A 0 A_TakeInventory("RedSkullST", 100)
	    TNT1 A 0 A_JumpIfInventory("GetRedSkull", 1, "DoGiveFlag")
		//TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnRedSkull", 0)
		Fail
	DoGiveFlag:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_StealRedSkull", 0)
		TNT1 A 0 A_PlaySound("GetRedSkull", 9, 100, 0, 0)
		TNT1 A 0 A_GiveInventory("HasRedSkull", 1)
		Stop
	}
}

ACTOR RedSkullDrop : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	Inventory.PickupFlash ""
	+NEVERRESPAWN
	//+NOSCREENFLASH
	States
	{
	Spawn:
	    RSKU A 10
		RSKU B 10 BRIGHT
		TNT1 A 0 A_GiveInventory("LoopsLeftToReturn", 1)
		TNT1 A 0 A_JumpIfInventory("LoopsLeftToReturn", 40, "ReturnThis")
		loop
	//Pickup:
	    //TNT1 A 0 A_TakeInventory("RedSkullDrop", 100)
	    //TNT1 A 0 A_JumpIfInventory("GetRedSkull", 1, "DoGiveFlag")
		//TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnRedSkull", 0)
		//TNT1 A 0 A_JumpIfInventory("STZD_ImmaBot", 1, "FailedBoi")
		//Stop
	FailedBoi:
	    RSKU A 10
		RSKU B 10 BRIGHT
		Fail
	Pickup:
	    TNT1 A 0 A_TakeInventory("BlueSkullST", 100)
	    TNT1 A 0 A_JumpIfInventory("GetRedSkull", 1, "DoGiveFlag")
		TNT1 A 0 A_JumpIfInventory("GetBlueSkull", 1, "ReturnThis")
		//TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnBlueSkull", 0)
		//TNT1 A 0 A_JumpIfInventory("STZD_ImmaBot", 1, "FailedBoi")
		Stop
	ReturnThis:
	    TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnRedSkull", 0)
		Stop
	DoGiveFlag:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_StealRedSkull", 0)
		TNT1 A 0 A_PlaySound("GetRedSkull", 9, 100, 0, 0)
		TNT1 A 0 A_GiveInventory("HasRedSkull", 1)
		Stop
	}
}

ACTOR BlueSkullST : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	Inventory.PickupFlash ""
	-PICKUP
	+NEVERRESPAWN
	States
	{
	Spawn:
	    BSKU A 10
		BSKU B 10 BRIGHT
		loop
	Pickup:
	    TNT1 A 0 A_TakeInventory("BlueSkullST", 100)
	    TNT1 A 0 A_JumpIfInventory("GetBlueSkull", 1, "DoGiveFlag")
		//TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnBlueSkull", 0)
		Fail
	DoGiveFlag:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_StealBlueSkull", 0)
		TNT1 A 0 A_PlaySound("GetBlueSkull", 9, 100, 0, 0)
		TNT1 A 0 A_GiveInventory("HasBlueSkull", 1)
		Stop
	}
}

ACTOR BlueSkullDrop : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	Inventory.PickupFlash ""
	-PICKUP
	+NEVERRESPAWN
	States
	{
	Spawn:
	    BSKU A 10
		BSKU B 10 BRIGHT
		TNT1 A 0 A_GiveInventory("LoopsLeftToReturn", 1)
		TNT1 A 0 A_JumpIfInventory("LoopsLeftToReturn", 40, "ReturnThis")
		loop
	Pickup:
	    TNT1 A 0 A_TakeInventory("BlueSkullST", 100)
	    TNT1 A 0 A_JumpIfInventory("GetBlueSkull", 1, "DoGiveFlag")
		TNT1 A 0 A_JumpIfInventory("GetRedSkull", 1, "ReturnThis")
		//TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnBlueSkull", 0)
		//TNT1 A 0 A_JumpIfInventory("STZD_ImmaBot", 1, "FailedBoi")
		Stop
	DoGiveFlag:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_StealBlueSkull", 0)
		TNT1 A 0 A_PlaySound("GetBlueSkull", 9, 100, 0, 0)
		TNT1 A 0 A_GiveInventory("HasBlueSkull", 1)
		Stop
	ReturnThis:
	    TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_ReturnBlueSkull", 0)
		Stop
	FailedBoi:
	    BSKU A 10
		BSKU B 10 BRIGHT
		Fail
	}
}

ACTOR STRSkullIcon
{
Health 100
Radius 1
Height 1
Scale 1.5
+NOCLIP
-SOLID
-SHOOTABLE
+NOBLOCKMAP
+THRUACTORS
+NOGRAVITY
+INVULNERABLE
States
{
Spawn:
RSKU A 2 BRIGHT
Stop
}
}

ACTOR STBSkullIcon
{
Health 100
Radius 1
Height 1
Scale 1.5
+NOCLIP
-SOLID
-SHOOTABLE
+NOBLOCKMAP
+THRUACTORS
+NOGRAVITY
+INVULNERABLE
States
{
Spawn:
BSKU A 2 BRIGHT
Stop
}
}

ACTOR STRedSkullIconSpawner : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	+INVENTORY.AUTOACTIVATE
	States
	{
	Spawn:
		TNT1 A 1
		Loop
	Pickup:
    Use:
	    TNT1 A 0 A_SpawnItem("STRSkullIcon", 0, 55)
		Stop
	}
}

ACTOR STBlueSkullIconSpawner : CustomInventory
{
	Game Doom
	Radius 20
	Height 26
	Inventory.PickupMessage ""
	+INVENTORY.AUTOACTIVATE
	States
	{
	Spawn:
		TNT1 A 1
		Loop
	Pickup:
    Use:
	    TNT1 A 0 A_SpawnItem("STBSkullIcon", 0, 55)
		Stop
	}
}