
//-------------------------------------------------------------------
//		DEMON ARTIFACT

ACTOR RLDemonArtifactItem : CustomInventory 16615
{
  -COUNTITEM
  +NOGRAVITY
  +FLOATBOB
  +INVENTORY.INVBAR
  +INVENTORY.UNDROPPABLE
  +INVENTORY.UNTOSSABLE
  +INVENTORY.BIGPOWERUP
  +INVENTORY.NEVERRESPAWN
  +DONTGIB
  Tag "Demon Artifact"
    //$category "DRLA Items"
  Inventory.InterHubAmount 3
  Inventory.MaxAmount 3
  Inventory.Icon "DMNAI0"
  Inventory.Pickupsound "misc/demonartifactpickup"
  Inventory.UseSound "misc/demonartifactuse"
  Inventory.PickupMessage "You picked up a Demon Artifact."
  Scale 0.5
  States
  {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_SpawnItemEx("RLDemonArtifactSoundEffect", 0,0,0, 0,0,0, 0, SXF_SETMASTER | SXF_NOCHECKPOSITION)
	TNT1 A 0 A_CheckFloor ("Hover")
	TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
  SpecialStartCheck:
	TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 2, "Duke2Stuff")
  SpawnLoop:
    DMNA A 1 Bright
    Loop
  Hover:
	TNT1 A 0 A_Warp (AAPTR_DEFAULT, 0,0,16, 0, WARPF_INTERPOLATE)
	TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
    Goto SpawnLoop
	
  Pickup:
	TNT1 A 0 A_JumpIfInventory("RLDemonArtifactLimit",0,"NoPickup")
	TNT1 A 0 A_GiveInventory("RLDemonArtifactLimit",1)
    Stop
	
  Use:
	TNT1 A 0 A_JumpIfInventory("RLUseDemonArtifact",1,"WeaponSelect")
    TNT1 A 0 A_GiveInventory("RLUseDemonArtifact", 1)
    TNT1 A 0 A_PlaySound("hud/generic", 5)
	TNT1 A 0 A_JumpIfInventory("RLFistSelected",1,"FistSelection")
  UseAgainToMod:
	TNT1 A 0 A_Print("Use the Demon Artifact again to apply to current weapon.\nThis can only be used on a \cgDemonic\c- weapon.\n\nPress \caDrop Item (DRLA)\c- to drop it, or switch weapons to cancel.", 5)
    Fail
  FistSelection:
	TNT1 A 0 A_Print("Press \caDrop Item (DRLA)\c- to drop the Demon Artifact, or switch weapons to cancel.", 5)
    Fail
  WeaponSelect:
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	TNT1 A 0 A_JumpIfInventory("RLFistSelected",1,"FistSelection")
  WeaponSelectMain:
    TNT1 A 0 A_JumpIfInventory("RLDeathsGazeSelected",1,"RLDeathsGaze")
    TNT1 A 0 A_JumpIfInventory("RLHellsReignSelected",1,"RLHellsReign")
    TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleSelected",1,"RLSoulstormRifle")
    TNT1 A 0 A_JumpIfInventory("RLUnmakerSelected",1,"RLUnmaker")
	TNT1 A 0 A_Jump(256, "AddonWeaponSelection")
	Goto AddonWeaponSelection
	
	
 // When making addon demonic weapons, inherit this artifact and copy this state into it.
 // Then fill it with any checks for weapon tokens you've added.
 // Add the state it will jump to and fill it just like the existing ones.
 
  AddonWeaponSelection:
//	TNT1 A 0 A_JumpIfInventory("RLAddonWeaponSelected",1,"RLAddonWeapon") // Like dis
	TNT1 A 0 A_Jump(256, "UnableToMod")
	Goto UnableToMod
	
  UnableToMod:
	TNT1 A 0 A_Print("This can only be used on a \cgDemonic\c- weapon.", 4)
    Fail
// DEMONICS
  RLDeathsGaze:
  RLDeathsGazeModding:
    TNT1 A 0 A_JumpIfInventory("RLDeathsGazeDemonArtifacts",0,"NoMod")
    TNT1 A 0 A_GiveInventory("RLDeathsGazeDemonArtifacts", 1)
    TNT1 A 0 A_GiveInventory("RLDeathsGazeDemonArtifactsLearntToken", 1)
	TNT1 A 0 A_TakeInventory("RLDemonArtifactLimit",1)
	TNT1 A 0 A_Print("The weapon shudders with unholy power...", 3)
    TNT1 A 0 A_TakeInventory("RLUseDemonArtifact", 1)
    TNT1 A 0 A_JumpIfInventory("RLDeathsGazeDemonArtifacts",0,"ENGAGEDEATHMODE")
    Stop
  RLHellsReign:
  RLHellsReignModding:
    TNT1 A 0 A_JumpIfInventory("RLHellsReignDemonArtifacts",0,"NoMod")
    TNT1 A 0 A_GiveInventory("RLHellsReignDemonArtifacts", 1)
    TNT1 A 0 A_GiveInventory("RLHellsReignDemonArtifactsLearntToken", 1)
	TNT1 A 0 A_TakeInventory("RLDemonArtifactLimit",1)
	TNT1 A 0 A_Print("The weapon shudders with unholy power...", 3)
    TNT1 A 0 A_TakeInventory("RLUseDemonArtifact", 1)
    TNT1 A 0 A_JumpIfInventory("RLHellsReignDemonArtifacts",0,"ENGAGEDEATHMODE")
    Stop
  RLSoulstormRifle:
  RLSoulstormRifleModding:
    TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",0,"NoMod")
    TNT1 A 0 A_GiveInventory("RLSoulstormRifleDemonArtifacts", 1)
    TNT1 A 0 A_GiveInventory("RLSoulstormRifleDemonArtifactsLearntToken", 1)
	TNT1 A 0 A_TakeInventory("RLDemonArtifactLimit",1)
	TNT1 A 0 A_Print("The weapon shudders with unholy power...", 3)
    TNT1 A 0 A_TakeInventory("RLUseDemonArtifact", 1)
    TNT1 A 0 A_JumpIfInventory("RLSoulstormRifleDemonArtifacts",0,"ENGAGEDEATHMODE")
    Stop
  RLUnmaker:
  RLUnmakerModding:
    TNT1 A 0 A_JumpIfInventory("RLUnmakerDemonArtifacts",0,"NoMod")
    TNT1 A 0 A_GiveInventory("RLUnmakerDemonArtifacts", 1)
    TNT1 A 0 A_GiveInventory("RLUnmakerDemonArtifactsLearntToken", 1)
	TNT1 A 0 A_TakeInventory("RLDemonArtifactLimit",1)
	TNT1 A 0 A_Print("The weapon shudders with unholy power...", 3)
    TNT1 A 0 A_TakeInventory("RLUseDemonArtifact", 1)
    TNT1 A 0 A_JumpIfInventory("RLUnmakerDemonArtifacts",0,"ENGAGEDEATHMODE")
    Stop
  NoMod:
    TNT1 A 0 A_Print("The weapon is already making your hair stand on end, making it\neven more fucking evil is a bad idea.", 8)
    TNT1 A 0 A_TakeInventory("RLUseDemonArtifact", 1)
    Fail
  ENGAGEDEATHMODE:
	TNT1 A 0 A_GiveInventory("RLDemonicWeaponMaxed",1, AAPTR_PLAYER1)
    Stop
  NoPickup:
	TNT1 A 0 A_JumpIfInventory("DRLA_ModsAntiLogFloodCheck",1,"NoPickup_NoPrint")
	TNT1 A 0 A_GiveInventory("DRLA_ModsAntiLogFloodCheck")
	TNT1 A 0 A_Print("Picking up more of these will probably do bad things.\nSuch evil power...", 5)
   NoPickup_NoPrint:
    TNT1 A 0
	Fail
//==============================================================================
	Duke2Stuff:
		"####" "#" 0 A_SpawnItemEx("RLDuke2WeaponCrate",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
//==============================================================================
//					--	DRPG Compatibility Stuff  --
//==============================================================================
	DRPGInit:
		"####" "#" 0 ACS_NamedExecuteAlways("ItemInit", 0)
		"####" "#" 0 A_Jump (256, "SpecialStartCheck")
		Goto SpecialStartCheck
  }
}
