// Guardsphere

ACTOR GuardSphereSpawnActor : CustomInventory 10076
{
	Tag "Guardsphere (Insanity)"
	//$Category Powerups
	//$Sprite GARDA0
	+NOBLOCKMAP
	+NOGRAVITY
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 1
	  TNT1 A 1 A_JumpIf(ACS_NamedExecuteWithResult("GunModifierSpawn") == 666,"Nothing")
	  TNT1 A 1 A_SpawnItemEx("GuardSphereSpawner")
	Nothing:
	  TNT1 A 1
	  TNT1 A -1
	  Stop
	}
}

ACTOR GuardSphereSpawner : RandomSpawner
{
	DropItem "IDMGuardSphere"
}

ACTOR PowerIDMQuarterDamage : PowerProtection
{
    DamageFactor "Normal", 0.25
	Inventory.Icon "GARDSP1"
	+DONTRIP
}

ACTOR GuardsphereProtection : PowerupGiver
{
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	-INVENTORY.INVBAR
	Inventory.MaxAmount 0
	Powerup.Type "IDMQuarterDamage"
	Powerup.Duration -30
	Powerup.Color GreenMap
}

ACTOR IDMGuardSphere : CustomInventory
{
    +FLOAT
    +FLOATBOB
	+COUNTITEM
	-INVENTORY.INVBAR
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	Inventory.PickupMessage "Guardsphere!"
    Inventory.PickupSound "misc/guard_pkup"
	Inventory.PickupAnnouncerEntry "guardsphere"
	Inventory.RespawnTics 2100
	Tag "Guardsphere"
    //$Category Powerups
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("SphereNoGravCheck") == true,"NoGrav")
	SpawnLoop:
	  GARD ABCD 6 Bright
	  Loop
	NoGrav:
	  TNT1 A 0 A_ScaleVelocity(0)
	  TNT1 A 0 A_ChangeFlag(NOGRAVITY,true)
	  Goto SpawnLoop
	Pickup:
	  TNT1 A 0 A_JumpIfInventory("PowerRageInvulnerable",1,"NoProt")
	  TNT1 A 0 A_GiveInventory("PickupProtection")
	NoProt:
	  TNT1 A 0 A_Print("\n\n\n\n\nGuardsphere!\n\n\n\n75% damage resistance!")
	  TNT1 A 0 A_GiveInventory("GuardSphereProtection")
	  Stop
	}
}