<?xml version="1.0" encoding="UTF-8"?>
<InteractionResponseData>
	<InteractionResponses>
		
		<!-- Wild Animal Response to player -->
		<Item key="WildAnimalCallResponse">
			<Flags>HostileInteractionsInterrupt UnarmedDamageInteractionsInterrupt</Flags>
			<States>
				<Item key="Start">
					<Flags>InitialState</Flags>
					<Reactions>
						<Item>HandleScenarioReactLook</Item>
						<Item>HandleNoScenarioReactLook</Item>
					</Reactions>
				</Item>
				
				<Item key="ScenarioReactLook">
					<Reactions>
						<Item>HandleThreatResponseScenario</Item>
						<Item>HandleScenarioFailure</Item>
					</Reactions>
				</Item>

				<Item key="NoScenarioReactLook">
					<Reactions>
						<Item>HandleThreatResponseNoScenario</Item>
					</Reactions>
				</Item>

				<Item key="WaitForThreatResponse">
					<Reactions>
						<Item>HandleThreatResponseStarted</Item>
					</Reactions>
				</Item>
        
				<Item key="Finish">
					<Flags>FinalState</Flags>
				</Item>
        
			</States>
			
			<Reactions>

				<Item key="HandleScenarioReactLook">
					<!-- Must be using scenario -->
					<Condition type="CAIConditionArePedConfigFlagsSet">
						<ConfigFlags>CPED_CONFIG_FLAG_UsingScenario</ConfigFlags>
					</Condition>
					<Action type="CInteractionScenarioReactionAnimation">
						<EventType>AET_Threatening</EventType>
						<Lifetime value="2.0f"/>
						<!-- The event is only valid for this long if the task doesn't react to it -->
						<AnimationTime value="60.0f"/>
						<!-- Set this to a large value. We'll exit the animation manually when the interaction ends. -->
						<MinReactionRateOverride value="1.4f" />
						<MaxReactionRateOverride value="1.5f" />
						<UpdateReactionTargetIfAlreadyReacting value="true" />
					</Action>
					<State>ScenarioReactLook</State>
					<Flags>DontClearFlags</Flags>
				</Item>
				
				<Item key="HandleNoScenarioReactLook">
					<!-- Must be not be using scenario -->
					<Condition type="CAIConditionNot">
						<Condition type="CAIConditionArePedConfigFlagsSet">
							<ConfigFlags>CPED_CONFIG_FLAG_UsingScenario</ConfigFlags>
						</Condition>
					</Condition>
					<Action type="CInteractionActionReact">
						<fReactionTimeMin value="0.75f" />
						<fReactionTimeMax value="1.5f" />
						<bUseHeadingOffsetWhenFacingTarget value="true" />
						<fReactHeadingThreshold value="1.570f" />
						<fReactHeadingLowerBound value="1.300f" />
						<fReactHeadingUpperBound value="1.740f" />
						<bReactForever value="false" />
						<EmotionalPreset>Interaction_Panic</EmotionalPreset>
						<RequestPriority>eTaskHigh</RequestPriority>
					</Action>
					<State>NoScenarioReactLook</State>
					<Flags>DontClearFlags</Flags>
				</Item>

				<Item key="HandleThreatResponseScenario">
					<!-- CASE: Reaction intro completed as expected. -->
					<Condition type="CAIConditionAnd">
						<Conditions>
							<Condition type="CInteractionConditionTimeout">
								<Time value="2.00f" />
							</Condition>
							<Condition type="CAIConditionHasCompletedAmbientReactIntro" />
						</Conditions>
					</Condition>
					<Action type="CInteractionActionThreatResponseAnimal"/>
					<State>WaitForThreatResponse</State>
				</Item>

				<Item key="HandleScenarioFailure">
					<Condition type="CAIConditionOr">
						<Conditions>
							<!-- CASE: Ped is no longer using a scenario. -->
							<Condition type="CAIConditionNot">
								<Condition type="CAIConditionArePedConfigFlagsSet">
									<ConfigFlags>CPED_CONFIG_FLAG_UsingScenario</ConfigFlags>
								</Condition>
							</Condition>
							<!-- CASE: The request to play the reaction animation failed. -->
							<Condition type="CAIConditionAnd">
								<Conditions>
									<Condition type="CAIConditionNot">
										<Condition type="CAIConditionIsTaskRunning">
											<TaskHash>TASK_AMBIENT_REACT</TaskHash>
										</Condition>
									</Condition>
									<Condition type="CAIConditionNot">
										<Condition type="CAIConditionHasValidAmbientEvent"/>
									</Condition>
								</Conditions>
							</Condition>
						</Conditions>
					</Condition>
					<State>Start</State>
					<Flags>DontClearFlags</Flags>
				</Item>
				
				<Item key="HandleThreatResponseNoScenario">
					<Condition type="CAIConditionAnd">
						<Conditions>
							<Condition type="CInteractionConditionTimeout">
								<Time value="1.00f" />
							</Condition>
							<Condition type="CAIConditionNot">
								<Condition type="CInteractionConditionIsReactingToTarget"/>
							</Condition>
						</Conditions>
					</Condition>
					<Action type="CInteractionActionThreatResponseAnimal"/>
					<State>WaitForThreatResponse</State>
				</Item>

				<Item key="HandleThreatResponseStarted">
					<Condition type="CAIConditionIsTaskRunning">
						<TaskHash>TASK_THREAT_RESPONSE</TaskHash>
					</Condition>
					<Action />
					<State>Finish</State>
				</Item>

			</Reactions>
			
		</Item>
		
	</InteractionResponses>
</InteractionResponseData>
