// Reflection

ACTOR ReflectSphereSpawnActor : CustomInventory 10080
{
	Tag "Reflection Sphere"
	//$Category Powerups
	//$Sprite LFSSA0
	+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("ReflectSphereSpawner")
	Nothing:
	  TNT1 A 1
	  TNT1 A -1
	  Stop
	}
}

ACTOR ReflectSphereSpawner : RandomSpawner
{
	DropItem "ReflectSphere"
}

ACTOR PowerIDMReflection : PowerReflection
{
	Inventory.Icon "REFLSP1"
}

ACTOR ReflectSphereReflection : PowerupGiver
{
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	-INVENTORY.INVBAR
	Powerup.Type "IDMReflection"
	Powerup.Duration -20
	Powerup.Colormap 1.5, 0.75, 0.0
}

ACTOR PowerReflectProtection : PowerProtection
{
	DamageFactor "Normal", 0.6667
}

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

ACTOR ReflectSphere : CustomInventory
{
    +FLOAT
    +FLOATBOB
	+COUNTITEM
	+INVENTORY.AUTOACTIVATE
	+INVENTORY.ALWAYSPICKUP
	-INVENTORY.INVBAR
    Inventory.PickupSound "misc/refl_pkup"
	Inventory.Pickupmessage "Reflection!"
	Inventory.PickupAnnouncerEntry "reflection"
	Inventory.RespawnTics 2100
    Inventory.MaxAmount 0
	Tag "Reflection Sphere"
	States
	{
	Spawn:
	  TNT1 A 0
	  TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("SphereNoGravCheck") == true,"NoGrav")
	SpawnLoop:
	  LFSS ABCDCB 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\nReflection!\n\n\n\n200 Health & 33% damage resistance!\nEnemy damage is reflected back!",4)
	  TNT1 A 0 Healthing(200,200)
	  TNT1 A 0 A_GiveInventory("ReflectSphereReflection")
	  TNT1 A 0 A_GiveInventory("ReflectSphereProtection")
	  Stop
	}
}

Damagetype "Reflection"
{
	Factor 1.0
	ReplaceFactor
}