/*
	modified FLASHLIGHT FROM GHOSTED 3 Alpha
*/
#include "Actors/Weapons/G2_FlashlightLight.txt"

actor FlashLightSwitch : Inventory
{
	Inventory.Amount 0
	Inventory.MaxAmount 1
}

actor Switch : Inventory
{
	Inventory.Amount 0
	Inventory.MaxAmount 1
}

actor G2_FLSHoldTime : Inventory
{
	Inventory.Amount 0
	Inventory.MaxAmount 110
}

ACTOR Flashlight : G2_Weapon 30030
{
	+NOALERT
	Inventory.PickupMessage "You got the Flashlight!" 
	Inventory.PickupSound "misc/d3pickup" 
	Weapon.SelectionOrder 3500 
	Weapon.AmmoType "BatteryPower"
	Weapon.AmmoUse  0
	Weapon.AmmoGive 15000
	+WEAPON.NOAUTOAIM
	+INVENTORY.UNDROPPABLE
	+WEAPON.NOAUTOFIRE
	States 
	{ 
	Spawn: 
		FLSH A -1 
		loop
	Ready: 
		D3FG B 1
		goto Ready3

	On:
		D3FG A 0 A_PlayWeaponSound("weapons/flashlight_switch")
	On_Silent:
		D3FG A 0 A_GiveInventory("G2_UsesLightSource",1)
		D3FG A 1 ACS_NamedExecuteAlways("lights_flashlight", 0, 0, 0, 0)
	OnLoop:
		D3FG A 0 A_TakeInventory("BatteryPower",1)
		D3FG A 0 A_Light2
		TNT1 A 0 A_JumpIfInventory("FlashLightSwitch",1,"Off")
		D3FG A 0 A_GiveInventory("Switch")
		TNT1 A 0 A_TakeInventory("FlashLightSwitch")
		D3FG A 1 A_WeaponReady
		D3FG A 0 A_JumpIfInventory("G2_UsesLightSource", 1, "ShouldOnLoop")
		D3FG A 0 
		Goto Ready3
	ShouldOnLoop:
		D3FG A 0 A_JumpIfInventory("BatteryPower", 1, "OnLoop")
		Goto Ready3
	Off:
		D3FG B 0 
		D3FG B 0 ACS_NamedExecuteWithResult("sound_alert_flashlight")
		D3FG B 0 A_PlayWeaponSound("weapons/flashlight_switch")
	Off_Silent:
		D3FG B 0 A_Light0
	Ready3:
		D3FG B 0 A_TakeInventory("FlashLightSwitch")
		D3FG B 0 A_TakeInventory("Switch")
		D3FG B 0 A_TakeInventory("G2_UsesLightSource",1)
		D3FG B 1 A_WeaponReady
		loop
	Deselect: 
		D3FG B 0 A_Light0
		D3FG B 0 A_TakeInventory("G2_UsesLightSource",1)
		D3FG B 1 A_Lower
		D3FG BB 0 A_Lower
		loop 
	Select: 
		D3FG B 1 A_Raise
		D3FG BB 0 A_Raise
		loop 
	Fire: 
		D3FG A 0 A_TakeInventory("G2_FLSHoldTime")
	Hold:
		D3FG A 0 A_JumpIfInventory("Switch", 1, "Hold.On")
	Hold.Off:
		D3FG B 1 A_GiveInventory("G2_FLSHoldTime", 1)
		D3FG B 1 A_JumpIfInventory("G2_FLSHoldTime", 8, "Silent")
		D3FG B 0 A_Refire
		Goto Loud
	Hold.On:
		D3FG A 1 A_GiveInventory("G2_FLSHoldTime", 1)
		D3FG A 1 A_JumpIfInventory("G2_FLSHoldTime", 8, "Silent")
		D3FG A 0 A_Refire
		Goto Loud
	Loud:
		D3FG A 2 A_TakeInventory("G2_FLSHoldTime")
		TNT1 A 0 A_JumpIfInventory("FlashLightSwitch",1,"Off")
		TNT1 A 0 A_JumpIfInventory("Switch",1,"Off")
		D3FG A 0 A_JumpIfInventory("BatteryPower", 1, "On")
		Goto Ready3
	Silent:
		D3FG A 0
		D3FG A 0 A_PlayWeaponSound("Weapons/flashlight_switch_quiet")
		D3FG A 0 A_TakeInventory("G2_FLSHoldTime")
		TNT1 A 0 A_JumpIfInventory("FlashLightSwitch",1,"Off_Silent")
		TNT1 A 0 A_JumpIfInventory("Switch",1,"Off_Silent")
		D3FG A 0 A_JumpIfInventory("BatteryPower", 1, "On_Silent")
		Goto Ready3
	} 
}

actor G2_FlashlightType : Inventory
{
	Inventory.MaxAmount 16
	Inventory.Amount 1
}