//==============================================================================
//		FUNCTIONY THINGS
//==============================================================================

//==============================================================================
//			These are used to give bonuses to monsters that kill you.
//					Mostly used by DRPG aura monsters, heh.
//==============================================================================

ACTOR RLPlayerKilledBonus : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 
    TNT1 A 0 A_JumpIf(CheckClass("RLCyberdemon", AAPTR_DEFAULT, TRUE), "CyberdemonEffects")
    TNT1 A 0 A_JumpIf(CheckClass("RLSpiderMastermindBFG", AAPTR_DEFAULT, TRUE), "SpiderMastermindBFGEffects")
	Stop
  CyberdemonEffects:
    TNT1 A 0 A_JumpIf(CallACS("DRPGCheck"), 1)
	Stop
    TNT1 A 0 ACS_NamedExecuteAlways("GetAuraTokens", 0)
    TNT1 A 0 A_JumpIfInventory("DRPGPinkAuraToken", 1, 1)
	Stop
    TNT1 A 0 ACS_NamedExecuteAlways("HealMonster", 0, 20, 100)
	Stop
  SpiderMastermindBFGEffects:
    TNT1 A 0 A_JumpIf(CallACS("DRPGCheck"), 1)
	Stop
    TNT1 A 0 ACS_NamedExecuteAlways("GetAuraTokens", 0)
    TNT1 A 0 A_JumpIfInventory("DRPGPinkAuraToken", 1, 1)
	Stop
    TNT1 A 0 ACS_NamedExecuteAlways("HealMonster", 0, 20, 100)
	Stop
  }
}

ACTOR RLPlayerGibbedBonus : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 
    TNT1 A 0 A_JumpIf(CheckClass("RLCyberdemon", AAPTR_DEFAULT, TRUE), "CyberdemonEffects")
    TNT1 A 0 A_JumpIf(CheckClass("RLSpiderMastermindBFG", AAPTR_DEFAULT, TRUE), "SpiderMastermindBFGEffects")
	Stop
  CyberdemonEffects:
    TNT1 A 0 A_JumpIf(CallACS("DRPGCheck"), 1)
	Stop
    TNT1 A 0 ACS_NamedExecuteAlways("GetAuraTokens", 0)
    TNT1 A 0 A_JumpIfInventory("DRPGPinkAuraToken", 1, 1)
	Stop
    TNT1 A 0 ACS_NamedExecuteAlways("HealMonster", 0, 20, 100)
	Stop
  SpiderMastermindBFGEffects:
    TNT1 A 0 A_JumpIf(CallACS("DRPGCheck"), 1)
	Stop
    TNT1 A 0 ACS_NamedExecuteAlways("GetAuraTokens", 0)
    TNT1 A 0 A_JumpIfInventory("DRPGPinkAuraToken", 1, 1)
	Stop
    TNT1 A 0 ACS_NamedExecuteAlways("HealMonster", 0, 20, 100)
	Stop
  }
}

ACTOR RLScavengingExtraEffects : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 // Any effects given to the Technician for scavenging can be placed here, to work across all weapons.
    TNT1 A 0 A_GiveInventory ("RLArmorBonusNoMessage", 1) // Repairs his current armor
    TNT1 A 0 A_GiveInventory ("RLMisfireSpamPreventionCooldown", 1) // Prevents weapon spam after scavenging
	Stop
  IsFine:
    TNT1 A 0
	Stop
  }
}

//Gets rid of all the stuff that cancels on weapon switch.
ACTOR RLDeselectionFunction : RLCustomFunction
{
  States
  {
	
 // 	When making an addon that adds weapons, boots, armor, whatever, inherit this function.
 // 	Then fill the Addon states with anything you've added so that the mod will clear them properly.
 //
 //		This function clears all confirmations from the player on weapon switch, or wherever else is
 //		need for this to happen.
 
  Pickup:
    TNT1 A 0 
  DRLAInventory:
	TNT1 A 0 A_TakeInventory("RLFistDropAttempt",0)
	TNT1 A 0 A_TakeInventory("RLArmorModItemActivate",1)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	
	TNT1 A 0 A_TakeInventory("RLUseBulkMod",1)
	TNT1 A 0 A_TakeInventory("RLUsePowerMod",1)
	TNT1 A 0 A_TakeInventory("RLUseAgilityMod",1)
	TNT1 A 0 A_TakeInventory("RLUseTechnicalMod",1)
	TNT1 A 0 A_TakeInventory("RLUseNanoMod",1)
	TNT1 A 0 A_TakeInventory("RLUseFirestormMod",1)
	TNT1 A 0 A_TakeInventory("RLUseSniperMod",1)
	TNT1 A 0 A_TakeInventory("RLUseOnyxMod",1)
	
	TNT1 A 0 A_TakeInventory("RLUseDemonArtifact",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_TakeInventory("RLUseExperimentalPhaseDevice",1)	
	
	TNT1 A 0 A_TakeInventory("RLUseHatredSkull",1)
	TNT1 A 0 A_TakeInventory("RLUseBloodSkull",1)
	TNT1 A 0 A_TakeInventory("RLUseFireSkull",1)
	TNT1 A 0 A_Jump(256, "AddonInventory")
	Goto AddonInventory
	
 // 	Inherit this state and add all new addon inventory bar items to it.
 
	AddonInventory:
//		TNT1 A 0 A_TakeInventory("RLUseAddonItem",1) // Like dis
		TNT1 A 0 A_Jump(256, "DRLAArmors")
		Goto DRLAArmors
	
	DRLAArmors:
//Including all the armor manipulation tokens.
		TNT1 A 0 A_TakeInventory("RLGenericArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLRedArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLCerberusArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLFireShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTowerShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTacticalArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLAblativeGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLAblativeBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLAblativeRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBallisticGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBallisticBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBallisticRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLCybernanoGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLCybernanoBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLCybernanoRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLFireproofGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLFireproofBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLFireproofRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberSkinGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberSkinBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberSkinRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPowerGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPowerBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPowerRedArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLBallisticShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBallisticVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBulletProofVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLCyberwarriorArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLDuelistArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLEnergyShieldedVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLEnergyShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLGothicArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLMedicalArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNuclearArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPhaseshiftArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPlasmaShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLRechargeableEnergyShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLRepulsionWaveSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLSurvivalMediArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOnyxArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOverchargeSystemArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLBerserkerArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBerserkPowersuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBlazingPhoenixDeviceSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLCyberneticArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLEnergyDischargeHarnessArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLFrontlineEngineerSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLGeosGoldenGauntletArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLJetpackArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLKateMatterstormHarnessArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLKyleTeslaboltArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLLavaArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLMaleksArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLMedicalPowerArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanoAblativeArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNuclearPowerArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPrototypeAssaultShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLRoystensCommandArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLRyanCordellPsychicAmplifierSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLShieldedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLSoloOperativeSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTacticalAssemblerSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTerminusEst13BattlesuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTorgueBlastplateArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLWildWeaselPeacekeeperArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLXaserPowerArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLZeroDiamondAssaultForceArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLDemonicCarapaceArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNecroArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLSoulshatterArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLAngelicArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTheBeeArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLReactiveShieldSystemArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLChronotrooperArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLOModGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModBallisticVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModBulletProofVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModCyberwarriorArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModDuelistArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModEnergyShieldedVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModGothicArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModMedicalArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModPhaseshiftArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModRepulsionWaveSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModSurvivalMediArmorUse", 1)
		TNT1 A 0 A_Jump(256, "AddonArmors")
		Goto AddonArmors
	
 // 	Inherit this state and add all addon armors to it.
 
	AddonArmors:
//		TNT1 A 0 A_TakeInventory("RLAddonArmorUse",1) // Like dis
		TNT1 A 0 A_Jump(256, "DRLABoots")
		Goto DRLABoots
	
	DRLABoots:
		TNT1 A 0 A_TakeInventory("RLGenericBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLSteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLProtectiveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLPlasteelBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLCerberusBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLTacticalBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLAntigravSteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLAntigravProtectiveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLAntigravPlasteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLEnviromentalSteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLEnviromentalProtectiveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLEnviromentalPlasteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLFireproofSteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLFireproofProtectiveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLFireproofPlasteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLGrapplingSteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLGrapplingProtectiveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLGrapplingPlasteelBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLShockwaveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLAcidProofBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLGothicBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLPhaseshiftBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLEnviroBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLFrontlineEngineerBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLLavaBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLLeonidasBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLNuclearPowerBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLNyarlaptotepsBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLRoystensCombatBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLSoloOperativeBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLTacticalAssemblerBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLTorgueBlastBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLDemonicBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLAngelicBootsUse",1)
		TNT1 A 0 A_Jump(256, "AddonBoots")
		Goto AddonBoots
	
 // 	Inherit this state and add all addon boots to it.
 
	AddonBoots:
//		TNT1 A 0 A_TakeInventory("RLAddonBootsUse",1) // Like dis
		TNT1 A 0 A_Jump(256, "DeselectionFunctionFinished")
		Goto DeselectionFunctionFinished
	
	DeselectionFunctionFinished:
		TNT1 A 0
		Stop
  }
}

//Gets rid of all armor manipulation tokens.
ACTOR RLItemManipulationRemover : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 
		TNT1 A 0 A_TakeInventory("RLFistDropAttempt",0)
		TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
		TNT1 A 0 A_TakeInventory("RLWeaponDrop",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_TakeInventory("RLUseExperimentalPhaseDevice",1)
		
		TNT1 A 0 A_TakeInventory("RLUseHatredSkull",1)
		TNT1 A 0 A_TakeInventory("RLUseBloodSkull",1)
		TNT1 A 0 A_TakeInventory("RLUseFireSkull",1)	
		TNT1 A 0 A_Jump(256, "AddonInventory")
		Goto AddonInventory
	
 // 	Inherit this state and add all new addon inventory bar items to it.
 
	AddonInventory:
//		TNT1 A 0 A_TakeInventory("RLUseAddonItem",1) // Like dis
		TNT1 A 0 A_Jump(256, "DRLAArmors")
		Goto DRLAArmors
	
	DRLAArmors:
		TNT1 A 0 A_TakeInventory("RLGenericArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLRedArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLCerberusArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLFireShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTowerShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTacticalArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLAblativeGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLAblativeBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLAblativeRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBallisticGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBallisticBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBallisticRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLCybernanoGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLCybernanoBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLCybernanoRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLFireproofGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLFireproofBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLFireproofRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberSkinGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberSkinBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanofiberSkinRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPowerGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPowerBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPowerRedArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLBallisticShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBallisticVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBulletProofVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLCyberwarriorArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLDuelistArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLEnergyShieldedVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLEnergyShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLGothicArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLMedicalArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNuclearArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPhaseshiftArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPlasmaShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLRechargeableEnergyShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLRepulsionWaveSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLSurvivalMediArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOnyxArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOverchargeSystemArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLBerserkerArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBerserkPowersuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLBlazingPhoenixDeviceSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLCyberneticArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLEnergyDischargeHarnessArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLFrontlineEngineerSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLGeosGoldenGauntletArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLJetpackArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLKateMatterstormHarnessArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLKyleTeslaboltArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLLavaArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLMaleksArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLMedicalPowerArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNanoAblativeArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNuclearPowerArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLPrototypeAssaultShieldArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLRoystensCommandArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLRyanCordellPsychicAmplifierSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLShieldedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLSoloOperativeSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTacticalAssemblerSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTerminusEst13BattlesuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTorgueBlastplateArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLWildWeaselPeacekeeperArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLXaserPowerArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLZeroDiamondAssaultForceArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLDemonicCarapaceArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLNecroArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLSoulshatterArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLAngelicArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLTheBeeArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLReactiveShieldSystemArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLChronotrooperArmorUse", 1)
		
		TNT1 A 0 A_TakeInventory("RLOModGreenArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModBlueArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModRedArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModBallisticVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModBulletProofVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModCyberwarriorArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModDuelistArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModEnergyShieldedVestArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModGothicArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModMedicalArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModPhaseshiftArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModRepulsionWaveSuitArmorUse", 1)
		TNT1 A 0 A_TakeInventory("RLOModSurvivalMediArmorUse", 1)
		TNT1 A 0 A_Jump(256, "AddonArmors")
		Goto AddonArmors
	
 // 	Inherit this state and add all addon armors to it.
 
	AddonArmors:
//		TNT1 A 0 A_TakeInventory("RLAddonArmorUse",1) // Like dis
		TNT1 A 0 A_Jump(256, "DRLABoots")
		Goto DRLABoots
	
	DRLABoots:
		TNT1 A 0 A_TakeInventory("RLGenericBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLSteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLProtectiveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLPlasteelBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLCerberusBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLTacticalBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLAntigravSteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLAntigravProtectiveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLAntigravPlasteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLEnviromentalSteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLEnviromentalProtectiveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLEnviromentalPlasteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLFireproofSteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLFireproofProtectiveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLFireproofPlasteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLGrapplingSteelBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLGrapplingProtectiveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLGrapplingPlasteelBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLShockwaveBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLAcidProofBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLGothicBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLPhaseshiftBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLEnviroBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLFrontlineEngineerBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLLavaBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLLeonidasBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLNuclearPowerBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLNyarlaptotepsBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLRoystensCombatBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLSoloOperativeBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLTacticalAssemblerBootsUse",1)
		TNT1 A 0 A_TakeInventory("RLTorgueBlastBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLDemonicBootsUse",1)
		
		TNT1 A 0 A_TakeInventory("RLAngelicBootsUse",1)
		TNT1 A 0 A_Jump(256, "AddonBoots")
		Goto AddonBoots
	
 // 	Inherit this state and add all addon boots to it.
 
	AddonBoots:
//		TNT1 A 0 A_TakeInventory("RLAddonBootsUse",1) // Like dis
		TNT1 A 0 A_Jump(256, "DeselectionFunctionFinished")
		Goto DeselectionFunctionFinished
	
	DeselectionFunctionFinished:
		TNT1 A 0
		Stop
  }
}

// Hope you weren't touching the water.
ACTOR RLElectricWaterIsFun : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 
	TNT1 A 0 A_JumpIf(waterlevel >= 2, 1)
    Stop
	TNT1 A 0 A_DamageSelf(random (70,320), "Plasma", DMSS_NOFACTOR)
	TNT1 AAAAA 0 A_CustomRailgun (0, 0, "None", "White", RGF_SILENT | RGF_FULLBRIGHT, 0, 25, "RLParticleBeamCannonPuff2", frandom(0,359), frandom(-45,45), random(64,256), 1, 0.2, 0, "None", random(-16,16))
    TNT1 A 0 A_PlaySound ("misc/waterelectrocution", 7, 1, 0, 1.2)
    Stop
  }
}

// i herd u liek drop fists
ACTOR RLFistDropPunishment : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 
	TNT1 A 0 A_Die ("Suicide")
    Stop
  }
}

//Made this thing so I didn't have to change stuff in every friggin weapon everytime I fiddled with rarities. fugggfgdgssdfsdg
ACTOR RLRarityTokenRemover : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 
	// These are used for the HUD and PDA to identify weaponry types
	TNT1 A 0 A_TakeInventory("RLRapidfireTypeWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLPistolTypeWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLShotgunTypeWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLEfficientAmmoTypeWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLMeleeTypeWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLSingleShotRifleTypeWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLBasicAssemblyTypeWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLAdvancedAssemblyTypeWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLMasterAssemblyTypeWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLMultiAmmoWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLInfiniteAmmoWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLNuclearAmmoWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLRechargingAmmoWeapon", 1)
	
	// Used to color weapon name text on the HUD
	TNT1 A 0 A_TakeInventory("RLStandardWeaponToken", 1)
	TNT1 A 0 A_TakeInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_TakeInventory("RLExoticWeaponToken", 1)
	TNT1 A 0 A_TakeInventory("RLSuperiorWeaponToken", 1)
	TNT1 A 0 A_TakeInventory("RLSuperiorAssembledWeaponToken", 1)
	TNT1 A 0 A_TakeInventory("RLUniqueWeaponToken", 1)
	TNT1 A 0 A_TakeInventory("RLDemonicWeaponToken", 1)
	TNT1 A 0 A_TakeInventory("RLLegendaryWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLFistMessageSpamPreventer", 1)
    Stop
  }
}

ACTOR RLBaseWeaponRemover : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 
	TNT1 A 0 A_TakeInventory("RLWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLPistolWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLHeavyWeapon", 1)
	TNT1 A 0 A_TakeInventory("RLMarathonWeapon", 1)
    Stop
  }
}

ACTOR RLStartTeleport : ArtiTeleport
{
  -COUNTITEM
  -INVENTORY.INVBAR
  -INVENTORY.PICKUPFLASH
  -INVENTORY.FANCYPICKUPSOUND
  +INVENTORY.ALWAYSPICKUP
  +INVENTORY.AUTOACTIVATE
  Inventory.DefMaxAmount
  Inventory.Icon ""
  Inventory.PickupSound ""
  Inventory.PickupMessage ""
  Tag ""
  States
  {
  Spawn:
    TNT1 A 1
    Stop
  }
}

ACTOR RLScoutMapCheckFrigginAntiVoodooHax : RLCustomFunction
{
//I fucking hate Voodoo dolls. Hate hate hate HATE HAAAATE I HATE THAT HEDGEHOG
  States
  {
  Pickup:
    TNT1 A 0 
	TNT1 A 0 A_JumpIfInventory("RLScoutMap",1, "Finish")
	TNT1 A 0 A_GiveInventory("RLScoutMap",1)
    Stop
  Finish:
	TNT1 A 0
    Stop
  }
}

//------------------------------------------------------------------------------
//		EXPLODO STUFF

// This used to be for the Demolitionist, renaming it would take too much effort.
// It's used for explosion-based abilities, as it goes off with every big explosion.
ACTOR RLFireangelBonusCheck : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 
//	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1, "LevelCheck")
    Stop
//	TNT1 A 0 A_PlaySound("demolitionist/explosionbuff", 5)
//    TNT1 A 0 A_SetBlend("White", 0.15, 5)
    Stop
  }
}

ACTOR RLFireangelRadiusBonusCheck : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 
//	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1, "LevelCheck")
    Stop
  Finish:
	TNT1 A 0
    Stop
  }
}

//==============================================================================

// These define the scavenging drop rates for all the different weapon types
ACTOR RLEmitScavengedModExotic : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0
	TNT1 A 0 A_Jump(8, "EmitNano")
	TNT1 A 0 A_Jump(24, "EmitSniper", "EmitFirestorm")
	TNT1 A 0 A_Jump(256, "EmitBulk", "EmitPower", "EmitAgility" , "EmitTechnical")
	Goto EmitAgility
	
  EmitNano:
	TNT1 A 0 A_FireCustomMissile("DroppedRLNanoMod",0,0,0)
    Stop
  EmitFirestorm:
	TNT1 A 0 A_FireCustomMissile("DroppedRLFirestormMod",0,0,0)
    Stop
  EmitSniper:
	TNT1 A 0 A_FireCustomMissile("DroppedRLSniperMod",0,0,0)
    Stop
	
  EmitBulk:
	TNT1 A 0 A_FireCustomMissile("DroppedRLBulkMod",0,0,0)
    Stop
  EmitPower:
	TNT1 A 0 A_FireCustomMissile("DroppedRLPowerMod",0,0,0)
    Stop
  EmitAgility:
	TNT1 A 0 A_FireCustomMissile("DroppedRLAgilityMod",0,0,0)
    Stop
  EmitTechnical:
	TNT1 A 0 A_FireCustomMissile("DroppedRLTechnicalMod",0,0,0)
    Stop
  }
}

ACTOR RLEmitScavengedModSuperior : RLEmitScavengedModExotic
{
  States
  {
  Pickup:
    TNT1 A 0
	TNT1 A 0 A_Jump(14, "EmitNano")
	TNT1 A 0 A_Jump(56, "EmitSniper", "EmitFirestorm")
	TNT1 A 0 A_Jump(256, "EmitBulk", "EmitPower", "EmitAgility" , "EmitTechnical")
	Goto EmitAgility
  }
}

ACTOR RLEmitScavengedModUnique : RLEmitScavengedModExotic
{
  States
  {
  Pickup:
    TNT1 A 0
	TNT1 A 0 A_Jump(85, "EmitNano")
	TNT1 A 0 A_Jump(256, "EmitSniper", "EmitFirestorm")
	Goto EmitSniper
  }
}

ACTOR RLEmitScavengedModLegendary : RLEmitScavengedModExotic
{
  States
  {
  Pickup:
    TNT1 A 0
	TNT1 A 0 A_Jump(256, "EmitSniper", "EmitFirestorm", "EmitNano")
	Goto EmitNano
  }
}

//==============================================================================

ACTOR RLUniqueItemFound : RLCustomFunction
{
  States
  {
  Pickup:
    TNT1 A 0 
	TNT1 A 0 A_JumpIfInventory("RLUniqueBossActive", 1, "AlreadyActive", AAPTR_PLAYER1)
	TNT1 A 0 A_GiveInventory("RLUniqueBossActive", 1, AAPTR_PLAYER1)
    TNT1 A 0 A_SpawnItemEx("RLNewBossMessageDelayer", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
    Stop
  AlreadyActive:
    TNT1 A 0
    Stop
  }
}

ACTOR RLDemonicItemFound : RLUniqueItemFound
{
  States
  {
  Pickup:
    TNT1 A 0 
	TNT1 A 0 A_JumpIfInventory("RLDemonicBossActive", 1, "AlreadyActive", AAPTR_PLAYER1)
	TNT1 A 0 A_GiveInventory("RLDemonicBossActive", 1, AAPTR_PLAYER1)
    TNT1 A 0 A_SpawnItemEx("RLNewBossMessageDelayer", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
    Stop
  }
}

ACTOR RLLegendaryItemFound : RLUniqueItemFound
{
  States
  {
  Pickup:
    TNT1 A 0 
	TNT1 A 0 A_JumpIfInventory("RLLegendaryBossActive", 1, "AlreadyActive", AAPTR_PLAYER1)
	TNT1 A 0 A_GiveInventory("RLLegendaryBossActive", 1, AAPTR_PLAYER1)
    TNT1 A 0 A_SpawnItemEx("RLNewBossMessageDelayer", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
    Stop
  }
}

// EOF