// Note: for maximum compatibility, "Rune.Type" ought to be synonymous to "Powerup.Type" but
// I have no idea how to do that in a clean, non-hacky way. (original author)
//What that means is that you can stack runes, unlike in the real Skulltag
//where you can only have one at a time.

//Hacky workaround time using ACS!!!

//=================================================================================================
//
// Strength rune
//
//=================================================================================================

// DoubleDamage is an internal powerup type in Skulltag, apparently
ACTOR PowerDoubleDamage : PowerDamage { DamageFactor "normal", 2 }

ACTOR StrengthRune : PowerupGiver //5100
{
	Game Doom
	Game Heretic
	Game Hexen
	//SpawnID 180
	+COUNTITEM
	+NOGRAVITY
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon STRRA0
	Inventory.MaxAmount 0
	Powerup.Type DoubleDamage
	Powerup.Duration 0x7FFFFFFD
	Inventory.PickupMessage "Strength!"
	Inventory.PickupAnnouncerEntry "strength"
	States
	{
	Spawn:
		STRR ABCD 6
		Loop
	}
}

ACTOR StrengthRunePickup : CustomInventory 5100
{
	Game Doom
	Game Heretic
	Game Hexen
	SpawnID 180
	+COUNTITEM
	+NOGRAVITY
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon STRRA0
	Inventory.MaxAmount 1
	Inventory.PickupMessage "Strength!"
	Inventory.PickupAnnouncerEntry "strength"
	States
	{
	Spawn:
		STRR ABCD 6
		Loop
	Use:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_RuneLimit", 0, 1)
		Stop
	}
}

//=================================================================================================
//
// Rage rune
//
//=================================================================================================

ACTOR PowerRageRune : PowerDoubleFiringSpeed {}

ACTOR RageRune : PowerupGiver //5101
{
	Game Doom
	Game Heretic
	Game Hexen
	//SpawnID 181
	+COUNTITEM
	+NOGRAVITY
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon RAGRA0
	Inventory.MaxAmount 0
	Powerup.Type RageRune
	Powerup.Duration 0x7FFFFFFD //Two years because you can't have infinite powerups
	Inventory.PickupMessage "Rage!"
	Inventory.PickupAnnouncerEntry "rage"
	States
	{
	Spawn:
		RAGR ABCDEFGH 6
		Loop
	}
}

ACTOR RageRunePickup : CustomInventory 5101
{
	Game Doom
	Game Heretic
	Game Hexen
	SpawnID 181
	+COUNTITEM
	+NOGRAVITY
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon RAGRA0
	Inventory.MaxAmount 1
	Inventory.PickupMessage "Rage!"
	Inventory.PickupAnnouncerEntry "rage"
	states
	{
	Spawn:
		RAGR ABCDEFGH 6
		Loop
	Use:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_RuneLimit", 0, 2)
		Stop
	}
}

//=================================================================================================
//
// Drain rune
//
//=================================================================================================

ACTOR PowerDrainerRune : PowerDrain {}

ACTOR DrainRune : PowerupGiver //5102
{
	Game Doom
	Game Heretic
	Game Hexen
	//SpawnID 182
	+COUNTITEM
	+NOGRAVITY
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon DRARA0
	Inventory.MaxAmount 0
	Powerup.Type DrainerRune
	Powerup.Duration 0x7FFFFFFD
	Inventory.PickupMessage "Drain!"
	Inventory.PickupAnnouncerEntry "drain"
	States
	{
	Spawn:
		DRAR ABCD 6
		Loop
	}
}

ACTOR DrainRunePickup : CustomInventory 5102
{
	Game Doom
	Game Heretic
	Game Hexen
	SpawnID 182
	+COUNTITEM
	+NOGRAVITY
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon DRARA0
	Inventory.MaxAmount 1
	Inventory.PickupMessage "Drain!"
	Inventory.PickupAnnouncerEntry "drain"
	States
	{
	Spawn:
		DRAR ABCD 6
		Loop
		
	Use:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_RuneLimit", 0, 3)
		Stop
	}
}

//=================================================================================================
//
// Spread rune
//
//=================================================================================================
ACTOR SpreadRune : PowerupGiver 5103 //This one would be doable using VXScript
{                                    //However i'm aiming for 1.8.6 compatibility so that's a no-no
	Game Doom
	Game Heretic
	Game Hexen
	SpawnID 183
	-COUNTITEM
     +THRUACTORS
     +NOBLOCKMAP
	+NOGRAVITY
	+FLOATBOB
	+INVENTORY.AUTOACTIVATE
     -PICKUP
	Inventory.Icon SPRRA0
	Inventory.MaxAmount 0
	Inventory.PickupMessage "Spread!"
	Inventory.PickupAnnouncerEntry "spread"
	States
	{
	Spawn:
		SPRR ABCD 6
		Loop
	}
}
//=================================================================================================
//
// Resistance rune
//
//=================================================================================================

// HalfDamage is an internal powerup type in Skulltag, apparently
ACTOR PowerHalfDamage : PowerProtection { DamageFactor "normal", 0.5 }

ACTOR ResistanceRune : PowerupGiver //5104
{
	Game Doom
	Game Heretic
	Game Hexen
	//SpawnID 184
	+COUNTITEM
	+NOGRAVITY
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon RESRA0
	Inventory.MaxAmount 0
	Powerup.Type HalfDamage
	Powerup.Duration 0x7FFFFFFD
	Inventory.PickupMessage "Resistance!"
	Inventory.PickupAnnouncerEntry "resistance"
	States
	{
	Spawn:
		RESR ABCDEFGH 6
		Loop
	}
}

ACTOR ResistanceRunePickup : CustomInventory 5104
{
	Game Doom
	Game Heretic
	Game Hexen
	SpawnID 184
	+COUNTITEM
	+NOGRAVITY
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon RESRA0
	Inventory.MaxAmount 1
	Inventory.PickupMessage "Resistance!"
	Inventory.PickupAnnouncerEntry "resistance"
	States
	{
	Spawn:
		RESR ABCDEFGH 6
		Loop
	Use:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_RuneLimit", 0, 5)
		Stop
	}
}

//=================================================================================================
//
// Regeneration rune
//
//=================================================================================================

ACTOR PowerRegenRune : PowerRegeneration {}

ACTOR RegenerationRune : PowerupGiver //5105
{
	Game Doom
	Game Heretic
	Game Hexen
	//SpawnID 185
	+COUNTITEM
	+NOGRAVITY
	+FLOATBOB
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon REGRA0
	Inventory.MaxAmount 0
	Powerup.Type RegenRune
	Powerup.Duration 0x7FFFFFFD
	Inventory.PickupMessage "Regeneration!"
	Inventory.PickupAnnouncerEntry "regeneration"
	States
	{
	Spawn:
		REGR AB 6
		Loop
	}
}

ACTOR RegenerationRunePickup : CustomInventory 5105
{
	Game Doom
	Game Heretic
	Game Hexen
	SpawnID 185
	+COUNTITEM
	+NOGRAVITY
	+FLOATBOB
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon REGRA0
	Inventory.MaxAmount 1
	Inventory.PickupMessage "Regeneration!"
	Inventory.PickupAnnouncerEntry "regeneration"
	States
	{
	Spawn:
		REGR AB 6
		Loop
	Use:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_RuneLimit", 0, 6)
		Stop
	}
}

//=================================================================================================
//
// Prosperity rune
//
//=================================================================================================
/* Not implemented in ZDoom 
ACTOR PowerProsperity : PowerProsperity
{
}
*/

ACTOR ProsperityRune : PowerupGiver 5106 //I tried to make it work, impossible without modifying the medikits themselves :(
{
	Game Doom
	Game Heretic
	Game Hexen
	SpawnID 186
	-COUNTITEM
     +THRUACTORS
     +NOBLOCKMAP
	+NOGRAVITY
	+FLOATBOB
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon PRSRA0
	Inventory.MaxAmount 1
	//Powerup.Type Prosperity
	Inventory.PickupMessage "Prosperity!"
	Inventory.PickupAnnouncerEntry "prosperity"
	States
	{
	Spawn:
		PRSR ABCD 6
		Loop
	Use:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_RuneLimit", 0, 7)
		Stop
	}
}

//=================================================================================================
//
// Reflection rune
//
//=================================================================================================
// Not implemented in ZDoom
ACTOR ReflectionRune : PowerupGiver 5107
{
	Game Doom
	Game Heretic
	Game Hexen
	SpawnID 187
	-COUNTITEM
     +THRUACTORS
     +NOBLOCKMAP
	+NOGRAVITY
	+FLOATBOB
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon REFRA0
	Inventory.MaxAmount 0
	//Powerup.Type Reflection
	Inventory.PickupMessage "Reflection!"
	Inventory.PickupAnnouncerEntry "reflection"
	States
	{
	Spawn:
		REFR BA 6
		Loop
	Use:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_RuneLimit", 0, 8)
		Stop
	}
}

//=================================================================================================
//
// High jump rune
//
//=================================================================================================

ACTOR PowerHJRune : PowerHighJump {}

ACTOR HighJumpRune : PowerupGiver //5108
{
	Game Doom
	Game Heretic
	Game Hexen
	//SpawnID 188
	+COUNTITEM
	+NOGRAVITY
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon HIJRA0
	Inventory.MaxAmount 0
	Powerup.Type HJRune
	Powerup.Duration 0x7FFFFFFD
	Inventory.PickupMessage "High Jump!"
	Inventory.PickupAnnouncerEntry "highjump"
	States
	{
	Spawn:
		HIJR ABCD 6
		Loop
	Use:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_RuneLimit", 0, 9)
		Stop
	}
}

ACTOR HighJumpRunePickup : CustomInventory 5108
{
	Game Doom
	Game Heretic
	Game Hexen
	SpawnID 188
	+COUNTITEM
	+NOGRAVITY
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon HIJRA0
	Inventory.MaxAmount 1
	Inventory.PickupMessage "High Jump!"
	Inventory.PickupAnnouncerEntry "highjump"
	States
	{
	Spawn:
		HIJR ABCD 6
		Loop
	Use:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_RuneLimit", 0, 9)
		Stop
	}
}

//=================================================================================================
//
// Haste rune
//
//=================================================================================================

//pun intended
ACTOR PowerSpeedRune : PowerSpeed {}

ACTOR HasteRune : PowerupGiver //5109
{
	Game Doom
	Game Heretic
	Game Hexen
	//SpawnID 189
	+COUNTITEM
	+NOGRAVITY
	+FLOATBOB
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon HASRA0
	Inventory.MaxAmount 0
	Powerup.Type SpeedRune
	Powerup.Duration 0x7FFFFFFD
	Inventory.PickupMessage "Haste!"
	Inventory.PickupAnnouncerEntry "haste"
	States
	{
	Spawn:
		HASR ABCD 6
		Loop
	Use:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_RuneLimit", 0, 10)
		Stop
	}
}

ACTOR HasteRunePickup : CustomInventory 5109
{
	Game Doom
	Game Heretic
	Game Hexen
	SpawnID 189
	+COUNTITEM
	+NOGRAVITY
	+FLOATBOB
	+INVENTORY.AUTOACTIVATE
	Inventory.Icon HASRA0
	Inventory.MaxAmount 1
	Inventory.PickupMessage "Haste!"
	Inventory.PickupAnnouncerEntry "haste"
	States
	{
	Spawn:
		HASR ABCD 6
		Loop
	Use:
		TNT1 A 0 ACS_NamedExecuteAlways("ST4ZD_RuneLimit", 0, 10)
		Stop
	}
}