// Drain

ACTOR DrainSphereSpawnActor : CustomInventory 10083
{
	Tag "Drain Sphere"
	//$Category Powerups
	//$Sprite DRANA0
	+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("DrainSphereSpawner")
	Nothing:
	  TNT1 A 1
	  TNT1 A -1
	  Stop
	}
}

ACTOR DrainSphereSpawner : RandomSpawner
{
	DropItem "DrainSphere"
}

ACTOR DrainSphere : CustomInventory
{
	+FLOAT
	+FLOATBOB
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	+COUNTITEM
	-INVENTORY.INVBAR
	Inventory.PickupMessage "Drain!"
	Inventory.PickupSound "misc/p_pkup"
	Inventory.PickupAnnouncerEntry "drain"
	Inventory.RespawnTics 2100
	Inventory.MaxAmount 0
	Tag "Drain Sphere"
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("SphereNoGravCheck") == true,"NoGrav")
	SpawnLoop:
      DRAN 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\n\nDrain!\n\n\n\n50% damage resistance!\nYour weapons have lifesteal!")
	  TNT1 A 0 A_GiveInventory("DrainSphereDrain")
	  TNT1 A 0 A_GiveInventory("DrainSphereProtection")
	  Stop
	}
}

ACTOR PowerIDMDrain : PowerDrain
{
	Inventory.Icon "DRANSP1"
}

ACTOR PowerDrainProtection : PowerProtection
{
	DamageFactor "Normal", 0.5
}

ACTOR DrainSphereProtection : PowerupGiver
{
	Powerup.Duration -30
	Powerup.Type "DrainProtection"
	Inventory.MaxAmount 0
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	-INVENTORY.INVBAR
}

ACTOR DrainSphereDrain : PowerupGiver
{
	Powerup.Duration -30
	Powerup.Type "IDMDrain"
	Powerup.Strength 1.0
	Powerup.ColorMap 0.38,0.72,1.0
	Inventory.MaxAmount 0
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	-INVENTORY.INVBAR
}