
//==============================================================================
//		PHASE DEVICES
//==============================================================================

Actor RLPhaseDeviceLimit : Ammo //If you cheat, bad things happen m'kay
{
  +INVENTORY.UNDROPPABLE
  +INVENTORY.UNTOSSABLE
  +INVENTORY.IGNORESKILL
  Inventory.Maxamount 4 // This value determines how many phase devices you can carry
  Ammo.BackpackAmount 0
  Ammo.BackpackMaxAmount 8 // And how much with backpacks
}

actor RLPhaseDevice : CustomInventory 16739
{
  -COUNTITEM
  +INVENTORY.FANCYPICKUPSOUND
  +INVENTORY.NEVERRESPAWN
  +INVENTORY.INVBAR
  +INVENTORY.UNDROPPABLE
  +INVENTORY.UNTOSSABLE
  Scale 0.4
    //$category "DRLA Items"
  Tag "Phase Device"
  Inventory.Icon "PHS1I0"
  Inventory.InterHubAmount 999
  Inventory.MaxAmount 999
  Inventory.PickupSound ""
  Inventory.PickupMessage ""
  states
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 1, "SpawnKeen")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 2, "SpawnDuke2")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 3, "SpawnMarathon")
  SpawnLoop:
    PHS1 A 10 Bright
    PHS1 A 10
    Loop
  Pickup:
	TNT1 A 0
	TNT1 A 0 A_JumpIfInventory("RLCoopPhaseRestriction",0,"NoPickup_NoPrint") // Prevents you from picking up additional useless devices
	TNT1 A 0 A_JumpIf(CallACS("RLMenuOpen") == 1, "NoPickup_NoPrint")
	TNT1 A 0 A_JumpIfInventory("RLPhaseDeviceLimit",0,"NoPickup")
	TNT1 A 0 A_GiveInventory("RLPhaseDeviceLimit",1)
    TNT1 A 0 A_PlaySound ("misc/phasedevicepickup", 7, 1, 0, 1)
    TNT1 A 0 A_Print ("Picked up a \ctPhase Device.\c-", 3, CONFONT)
    Stop
	
  Use:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(CallACS("RLMenuOpen") == 1, "NoPickup_NoPrint")
	TNT1 A 0 A_JumpIfInventory("DRPGDRLAActive",1,"DoorpegOutpostCheck")
  DoorpegCheckDone:
	TNT1 A 0 A_JumpIfInventory("RLUsePhaseDevice",1,"ActivateDevice")
    TNT1 A 0 A_GiveInventory("RLUsePhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseHomingPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseRecallPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseExperimentalPhaseDevice", 1)
    TNT1 A 0 A_PlaySound("hud/generic", 5)
	TNT1 A 0 A_Print("Use this phase device again to teleport to level start.\n\nPress \caDrop Item (DRLA)\c- to drop it, or switch weapons to cancel.", 5)
    Fail
  ActivateDevice:
    TNT1 A 0 A_Print (" ", 0)
    TNT1 A 0 A_TakeInventory("RLUsePhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseHomingPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseRecallPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseExperimentalPhaseDevice", 1)
	TNT1 A 0 A_TakeInventory("RLPhaseDeviceLimit",1)
	TNT1 A 0 A_GiveInventory("RLStartTeleport",1)
    TNT1 A 0 A_PlaySound ("misc/phasedeviceactivate", 7, 1, 0, 1)
	Stop
	
  NoPickup:
	TNT1 A 0 A_JumpIfInventory("DRLA_ModsAntiLogFloodCheck",1,"NoPickup_NoPrint")
	TNT1 A 0 A_GiveInventory("DRLA_ModsAntiLogFloodCheck")
	TNT1 A 0 A_Print("\ct= Phase Device =", 2, "CONFONT")
   NoPickup_NoPrint:
    TNT1 A 0
	Fail
	
//==============================================================================
  SpawnKeen:
	TNT1 A 0 A_SpawnItemEx("RLNeuralStunnerPickup",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
  SpawnDuke2:
	TNT1 A 0 A_SpawnItemEx("RLDuke2ItemCrate",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
  SpawnMarathon:
	TNT1 A 0 A_SpawnItemEx("RLMarathonClip",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
//==============================================================================
//					--	DRPG Compatibility Stuff  --
//==============================================================================
	DRPGInit:
		"####" "#" 0 ACS_NamedExecuteAlways("ItemInit", 0)
		"####" "#" 0 A_Jump (256, "SpawnLoop")
		Goto SpawnLoop
//==============================================================================
  DoorpegOutpostCheck:
	TNT1 A 0 ACS_NamedExecuteAlways("InOutpost", 0, "HEYSTOPTHAT")
	Goto DoorpegCheckDone
  HEYSTOPTHAT:
    TNT1 A 0 A_Print ("\ctPhase Devices\c- are disabled in the Outpost.", 3, CONFONT)
	Fail
  }
}

actor RLHomingPhaseDevice : CustomInventory 16740
{
  -COUNTITEM
  +INVENTORY.FANCYPICKUPSOUND
  +INVENTORY.NEVERRESPAWN
  +INVENTORY.INVBAR
  +INVENTORY.UNDROPPABLE
  +INVENTORY.UNTOSSABLE
  Scale 0.4
    //$category "DRLA Items"
  Tag "Homing Phase Device"
  Inventory.Icon "PHS2I0"
  Inventory.InterHubAmount 999
  Inventory.MaxAmount 999
  Inventory.PickupSound ""
  Inventory.PickupMessage ""
  states
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 1, "SpawnKeen")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 2, "SpawnDuke2")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 3, "SpawnMarathon")
  SpawnLoop:
    PHS2 A 10 Bright
    PHS2 A 10
    Loop
  Pickup:
	TNT1 A 0
	TNT1 A 0 A_JumpIfInventory("RLCoopPhaseRestriction",0,"NoPickup_NoPrint") // Prevents you from picking up additional useless devices
	TNT1 A 0 A_JumpIf(CallACS("RLMenuOpen") == 1, "NoPickup_NoPrint")
	TNT1 A 0 A_JumpIfInventory("RLPhaseDeviceLimit",0,"NoPickup")
	TNT1 A 0 A_GiveInventory("RLPhaseDeviceLimit",1)
    TNT1 A 0 A_PlaySound ("misc/phasedevicepickup", 7, 1, 0, 1)
    TNT1 A 0 A_Print ("Picked up a \ctHoming Phase Device.\c-", 3, CONFONT)
    Stop
	
  Use:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(CallACS("RLMenuOpen") == 1, "NoPickup_NoPrint")
	TNT1 A 0 A_JumpIfInventory("DRPGDRLAActive",1,"DoorpegOutpostCheck")
  DoorpegCheckDone:
	TNT1 A 0 A_JumpIfInventory("RLUseHomingPhaseDevice",1,"ActivateDevice")
    TNT1 A 0 A_GiveInventory("RLUseHomingPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUsePhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseRecallPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseExperimentalPhaseDevice", 1)
    TNT1 A 0 A_PlaySound("hud/generic", 5)
	TNT1 A 0 A_Print("Use this phase device again to teleport to another player.\n\nPress \caDrop Item (DRLA)\c- to drop it, or switch weapons to cancel.", 5)
    Fail
  ActivateDevice:
    TNT1 A 0 A_Print (" ", 0)
    TNT1 A 0 A_TakeInventory("RLUsePhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseHomingPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseRecallPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseExperimentalPhaseDevice", 1)
	TNT1 A 0 A_TakeInventory("RLPhaseDeviceLimit",1)
	TNT1 A 0 ACS_NamedExecuteAlways("RLPhaseDeviceHoming", 0)
	Stop
	
  NoPickup:
	TNT1 A 0 A_JumpIfInventory("DRLA_ModsAntiLogFloodCheck",1,"NoPickup_NoPrint")
	TNT1 A 0 A_GiveInventory("DRLA_ModsAntiLogFloodCheck")
	TNT1 A 0 A_Print("\ct= Homing Phase Device =", 2, "CONFONT")
   NoPickup_NoPrint:
    TNT1 A 0
	Fail
	
//==============================================================================
  SpawnKeen:
	TNT1 A 0 A_SpawnItemEx("RLNeuralStunnerPickup",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
  SpawnDuke2:
	TNT1 A 0 A_SpawnItemEx("RLDuke2ItemCrate",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
  SpawnMarathon:
	TNT1 A 0 A_SpawnItemEx("RLMarathonClip",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
//==============================================================================
//					--	DRPG Compatibility Stuff  --
//==============================================================================
	DRPGInit:
		"####" "#" 0 ACS_NamedExecuteAlways("ItemInit", 0)
		"####" "#" 0 A_Jump (256, "SpawnLoop")
		Goto SpawnLoop
//==============================================================================
  DoorpegOutpostCheck:
	TNT1 A 0 ACS_NamedExecuteAlways("InOutpost", 0, "HEYSTOPTHAT")
	Goto DoorpegCheckDone
  HEYSTOPTHAT:
    TNT1 A 0 A_Print ("\ctPhase Devices\c- are disabled in the Outpost.", 3, CONFONT)
	Fail
  }
}

actor RLRecallPhaseDevice : CustomInventory 16741
{
  -COUNTITEM
  +INVENTORY.FANCYPICKUPSOUND
  +INVENTORY.NEVERRESPAWN
  +INVENTORY.INVBAR
  +INVENTORY.UNDROPPABLE
  +INVENTORY.UNTOSSABLE
  Scale 0.4
    //$category "DRLA Items"
  Tag "Recall Phase Device"
  Inventory.Icon "PHS3I0"
  Inventory.InterHubAmount 999
  Inventory.MaxAmount 999
  Inventory.PickupSound ""
  Inventory.PickupMessage ""
  states
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 1, "SpawnKeen")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 2, "SpawnDuke2")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 3, "SpawnMarathon")
  SpawnLoop:
    PHS3 A 10 Bright
    PHS3 A 10
    Loop
  Pickup:
	TNT1 A 0
	TNT1 A 0 A_JumpIfInventory("RLCoopPhaseRestriction",0,"NoPickup_NoPrint") // Prevents you from picking up additional useless devices
	TNT1 A 0 A_JumpIf(CallACS("RLMenuOpen") == 1, "NoPickup_NoPrint")
	TNT1 A 0 A_JumpIfInventory("RLPhaseDeviceLimit",0,"NoPickup")
	TNT1 A 0 A_GiveInventory("RLPhaseDeviceLimit",1)
    TNT1 A 0 A_PlaySound ("misc/phasedevicepickup", 7, 1, 0, 1)
    TNT1 A 0 A_Print ("Picked up a \ctRecall Phase Device.\c-", 3, CONFONT)
    Stop
	
  Use:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(CallACS("RLMenuOpen") == 1, "NoPickup_NoPrint")
	TNT1 A 0 A_JumpIfInventory("DRPGDRLAActive",1,"DoorpegOutpostCheck")
  DoorpegCheckDone:
	TNT1 A 0 A_JumpIfInventory("RLUseRecallPhaseDevice",1,"ActivateDevice")
    TNT1 A 0 A_GiveInventory("RLUseRecallPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUsePhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseHomingPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseExperimentalPhaseDevice", 1)
    TNT1 A 0 A_PlaySound("hud/generic", 5)
	TNT1 A 0 A_Print("Use this phase device again to set or recall to teleport points.\n\nPress \caDrop Item (DRLA)\c- to drop it, or switch weapons to cancel.", 5)
    Fail
  ActivateDevice:
    TNT1 A 0 A_TakeInventory("RLUsePhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseHomingPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseRecallPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseExperimentalPhaseDevice", 1)
	TNT1 A 0 A_JumpIfInventory("RLRecallPhaseDevicePrimed",1,"TimeToSplit")
	TNT1 A 0 A_GiveInventory("RLRecallPhaseDevicePrimed")
	TNT1 A 0 ACS_NamedExecuteAlways("RLPhaseDeviceRecall", 0)
	TNT1 A 0 A_Print("\ccRecall point set.\nActivate again to teleport.", 3, "CONFONT")
	Fail
  TimeToSplit:
    TNT1 A 0 A_Print (" ", 0)
	TNT1 A 0 A_TakeInventory("RLPhaseDeviceLimit",1)
	TNT1 A 0 A_TakeInventory("RLRecallPhaseDevicePrimed")
	TNT1 A 0 ACS_NamedExecuteAlways("RLPhaseDeviceRecall", 0)
	Stop
	
  NoPickup:
	TNT1 A 0 A_JumpIfInventory("DRLA_ModsAntiLogFloodCheck",1,"NoPickup_NoPrint")
	TNT1 A 0 A_GiveInventory("DRLA_ModsAntiLogFloodCheck")
	TNT1 A 0 A_Print("\ct= Recall Phase Device =", 2, "CONFONT")
   NoPickup_NoPrint:
    TNT1 A 0
	Fail
	
//==============================================================================
  SpawnKeen:
	TNT1 A 0 A_SpawnItemEx("RLNeuralStunnerPickup",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
  SpawnDuke2:
	TNT1 A 0 A_SpawnItemEx("RLDuke2ItemCrate",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
  SpawnMarathon:
	TNT1 A 0 A_SpawnItemEx("RLMarathonClip",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
//==============================================================================
//					--	DRPG Compatibility Stuff  --
//==============================================================================
	DRPGInit:
		"####" "#" 0 ACS_NamedExecuteAlways("ItemInit", 0)
		"####" "#" 0 A_Jump (256, "SpawnLoop")
		Goto SpawnLoop
//==============================================================================
  DoorpegOutpostCheck:
	TNT1 A 0 ACS_NamedExecuteAlways("InOutpost", 0, "HEYSTOPTHAT")
	Goto DoorpegCheckDone
  HEYSTOPTHAT:
    TNT1 A 0 A_Print ("\ctPhase Devices\c- are disabled in the Outpost.", 3, CONFONT)
	Fail
  }
}

Actor RLRecallPhaseDevicePrimed : RLPermanentInventory
{
Inventory.InterHubAmount 0
inventory.maxamount 1
}

actor RLExperimentalPhaseDevice : CustomInventory 16742
{
  -COUNTITEM
  +INVENTORY.FANCYPICKUPSOUND
  +INVENTORY.NEVERRESPAWN
  +INVENTORY.INVBAR
  +INVENTORY.UNDROPPABLE
  +INVENTORY.UNTOSSABLE
  +DONTGIB
  Scale 0.4
    //$category "DRLA Items"
  Tag "Experimental Phase Device"
  Inventory.Icon "PHS4I0"
  Inventory.InterHubAmount 999
  Inventory.MaxAmount 999
  Inventory.PickupSound ""
  Inventory.PickupMessage ""
  states
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 1, "SpawnKeen")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 2, "SpawnDuke2")
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 3, "SpawnMarathon")
  SpawnLoop:
    PHS4 A 10 Bright
    PHS4 A 10
    Loop
  Pickup:
	TNT1 A 0
	TNT1 A 0 A_JumpIfInventory("RLCoopPhaseRestriction",0,"NoPickup_NoPrint") // Prevents you from picking up additional useless devices
	TNT1 A 0 A_JumpIf(CallACS("RLMenuOpen") == 1, "NoPickup_NoPrint")
	TNT1 A 0 A_JumpIfInventory("RLPhaseDeviceLimit",0,"NoPickup")
	TNT1 A 0 A_GiveInventory("RLPhaseDeviceLimit",1)
    TNT1 A 0 A_PlaySound ("misc/phasedevicepickup", 7, 1, 0, 1)
    TNT1 A 0 A_Print ("Picked up an \cdExperimental Phase Device.\c-", 3, CONFONT)
    Stop
	
  Use:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(CallACS("RLMenuOpen") == 1, "NoPickup_NoPrint")
	TNT1 A 0 A_JumpIfInventory("DRPGDRLAActive",1,"DoorpegOutpostCheck")
  DoorpegCheckDone:
	TNT1 A 0 A_JumpIfInventory("RLUseExperimentalPhaseDevice",1,"ActivateDevice")
    TNT1 A 0 A_GiveInventory("RLUseExperimentalPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUsePhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseHomingPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseRecallPhaseDevice", 1)
    TNT1 A 0 A_PlaySound("hud/generic", 5)
	TNT1 A 0 A_Print("Use this phase device again to activate teleport menu.\n\nPress \caDrop Item (DRLA)\c- to drop it, or switch weapons to cancel.", 5)
    Fail
  ActivateDevice:
    TNT1 A 0 A_Print (" ", 0)
    TNT1 A 0 A_TakeInventory("RLUsePhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseHomingPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseRecallPhaseDevice", 1)
    TNT1 A 0 A_TakeInventory("RLUseExperimentalPhaseDevice", 1)
	TNT1 A 0 ACS_NamedExecuteAlways("RLPhaseDeviceExperimental", 0)
	Fail
	
  NoPickup:
	TNT1 A 0 A_JumpIfInventory("DRLA_ModsAntiLogFloodCheck",1,"NoPickup_NoPrint")
	TNT1 A 0 A_GiveInventory("DRLA_ModsAntiLogFloodCheck")
	TNT1 A 0 A_Print("\cd= Experimental Phase Device =", 2, "CONFONT")
   NoPickup_NoPrint:
    TNT1 A 0
	Fail
	
//==============================================================================
  SpawnKeen:
	TNT1 A 0 A_SpawnItemEx("RLNeuralStunnerPickup",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
  SpawnDuke2:
	TNT1 A 0 A_SpawnItemEx("RLDuke2ItemCrate",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
  SpawnMarathon:
	TNT1 A 0 A_SpawnItemEx("RLMarathonClip",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
    Stop
//==============================================================================
//					--	DRPG Compatibility Stuff  --
//==============================================================================
	DRPGInit:
		"####" "#" 0 ACS_NamedExecuteAlways("ItemInit", 0)
		"####" "#" 0 A_Jump (256, "SpawnLoop")
		Goto SpawnLoop
//==============================================================================
  DoorpegOutpostCheck:
	TNT1 A 0 ACS_NamedExecuteAlways("InOutpost", 0, "HEYSTOPTHAT")
	Goto DoorpegCheckDone
  HEYSTOPTHAT:
    TNT1 A 0 A_Print ("\ctPhase Devices\c- are disabled in the Outpost.", 3, CONFONT)
	Fail
  }
}

Actor RLUsePhaseDevice : RLPermanentInventory {}
Actor RLUseHomingPhaseDevice : RLPermanentInventory {}
Actor RLUseRecallPhaseDevice : RLPermanentInventory {}
Actor RLUseExperimentalPhaseDevice : RLPermanentInventory {}
Actor RLCoopPhaseRestriction : RLPermanentInventory {}
