SNACKS_RESOURCE_INTRO:NEEDS[SnacksStress]
{
	name = Hydrazine
}

SNACKS_RESOURCE_INTRO[Hydrazine]:FOR[SnacksHydrazine]
{
	name = Hydrazine
	title = Hydrazine!
	description = If you're a fan of the Kerbfleet series by forum user Kuzzter, then this Snacks addon is for you! When kerbals get stressed, they can turn to "Hydrazine," a hard liquor created by Bill Kerman that's distilled from monopropellant and (hopefully) named so that Kerbfleet Command won't realize what the crew has been up to in deep space. An occasional shot of Hydrazine is great at calming nerves, but sometimes a kerbal ties one too many on and passes out.
}

RESOURCE_DEFINITION:NEEDS[SnacksStress]
{
	name = HydrazineVodka
	displayName = "Hydrazine"
	density = 0.0000121
	unitCost = .5
	flowMode = ALL_VESSEL
	transfer = PUMP
	isTweakable = true
	volume = 0.044
}

@PART[radialSnackTin]:NEEDS[SnacksStress]
{
	@MODULE[SnacksResourceSwitcher]
	{
		OPTION
		{
			name = Hydrazine

			RESOURCE
			{
				name = HydrazineVodka
				amount = 17
				maxAmount = 17
			}

			RESOURCE
			{
				name = Snacks
				amount = 148
				maxAmount = 148
			}
		}
	}
}

SNACKS_PART_RESOURCE:NEEDS[SnacksStress]
{
	name = HydrazineVodka

	resourceName = HydrazineVodka
	amount = 17
	maxAmount = 17
	isPerKerbal = false
}

SNACKS_RESOURCE_PROCESSOR:NEEDS[SnacksStress]
{
	name = TakeAShotOfHydrazine
	secondPerCycle = 21600

	PRECONDITION
	{
		name = CheckCondition
		conditionSummary = Stressed Out
	}

	PRECONDITION
	{
		name = CheckRandomChance
		dieRollMin = 1
		dieRollMax = 100
		targetNumber = 80
	}

	CONSUMED_RESOURCE
	{
		resourceName = HydrazineVodka
		amount = 1.0
		showInSnapshot = false
		failureResultAppliesOutcomes = false
	}
}

SNACKS_EVENT:NEEDS[SnacksStress]
{
	name = mellowOut
	eventCategory = categoryPostProcessCycle
	kerbalsAffected = affectsAllAssigned

	PRECONDITION 
	{
		name = CheckProcessorResult
		type = resultConsumptionSuccess
		processorName = TakeAShotOfHydrazine
		resourceName = HydrazineVodka
		cyclesRequired = 1
	}

	OUTCOME
	{
		name = ConsumeResource
		resourceName = Stress
		amount = 1
	}
}

SNACKS_EVENT:NEEDS[SnacksStress]
{
	name = drankTooMuch
	eventCategory = categoryPostProcessCycle
	kerbalsAffected = affectsAllAssigned

	PRECONDITION 
	{
		name = CheckProcessorResult
		type = resultConsumptionSuccess
		processorName = TakeAShotOfHydrazine
		resourceName = HydrazineVodka
		cyclesRequired = 1
	}

	PRECONDITION
	{
		name = CheckRandomChance
		dieRollMin = 1
		dieRollMax = 100
		targetNumber = 80
	}

	OUTCOME
	{
		name = FaintPenalty
		playerMessage = passes out from drinking too much!
		faintDurationSeconds = 180
	}
}

@PART[Large_Crewed_Lab]
{
	MODULE
	{
		name = SnacksConverter
		ConverterName = Distillery
		StartActionName = Start Distillery
		StopActionName = Stop Distillery
		AutoShutdown = false
		GeneratesHeat = false
		UseSpecialistBonus = false
		
		//At least one crew needs to be in the part to run the converter.
		minimumCrew = 1

		//This condition is set whenever the kerbal enters the part and the converter is active, and
		//when the converter is started. Since it's registered as a SKILL_LOSS_CONDITION, the kerbals will lose their
		//skills while the converter is running.
		conditionSummary = Brewing

		INPUT_RESOURCE
		{
			ResourceName = ElectricCharge
			Ratio = 0.4
			FlowMode = STAGE_PRIORITY_FLOW
		}

		INPUT_RESOURCE
		{
			ResourceName = Monopropellant
			Ratio = 0.0001
			FlowMode = STAGE_PRIORITY_FLOW
		}

		OUTPUT_RESOURCE
		{
			ResourceName = HydrazineVodka
			Ratio = 0.0000121
			FlowMode = ALL_VESSEL
		}

		//Works like an INPUT_RESOURCE except:
		// It applies to individual kerbals.
		// You can specify an AmountPerDay or AmountPerSecond.
		ROSTER_INPUT_RESOURCE
		{
			ResourceName = Stress

			//AmountPerDay will be translated into: AmountPerDay / seconds per homeworld day
			//This will override AmountPerSecond if it is defined in the node.
			AmountPerDay = 1
		}
	}
}