/* Raptor Human Attack
//
// This machine should be used through the normal call mechanism
//
*/
machine RaptorVistorAttack
{
	default state AttackStart
	{
		transition IsTargetDead()
		{
			goto AttackExitEnd
		}
		;//action SetAesPosInterp(false)
		action LockMachine(false)
		action SetSpeedModifier(1.0)
		action SetRunMode(true)
		action StopLook()
		transition InTargetProximityRadius(1.15, true)
		{
			direct goto AttackSetup
		}
		transition IsTargetHuman()
		{
			goto SeekHuman
		}
		transition
		{
			goto AttackExitStart
		}
	}

	state SeekHuman
	{
		action SendEnclosureEvent("seek_prey")
		;//transition SeekTarget(true, false)
		transition ;//
		{
			action SetAvoidanceSteer(false)
			goto SeekLoop
		}
		transition
		{
			action ClearTarget()
			goto AttackExitStart
		}
	}

	state SeekLoop
	{
		/*
		Param0:		float	distance offset
		Param1:		float	rotation offset
		Param2:		bool	True if we should face target.
		Param3:		bool	True if we want a random rotation
		Param4:		bool	True if rotation is offset from forward
		*/
		action SeekTargetOffset(1.0, 0.0, false, false, true)
		transition HasTarget() == false
		{
			goto AttackExitEnd
		}
		transition IsTargetDead()
		{
			goto AttackExitEnd
		}
		transition InTargetProximityRadius(1.15, true)
		{
			direct goto AttackSetup
		}
/*		transition HasArrived()
		{
			goto SeekHuman
		}
*/	}


	state AttackSetup
	{
		transition IsTargetDead()
		{
			goto AttackExitEnd
		}

		action LockMachine(true)
		
		transition ControlHuman() == false
		{
			;// fail means abort our fsm
			goto AttackExitEnd
		}

		action LookEnd()
		action SetStandStill()
		action SetSpeedDirect(0.0)
		action SetAvoidanceSteer(false)
		;//action SetAvoidanceWorld(false)
		action SetAutoMovementBlend(false)
		action FaceTargetInstant()

		action SetAutoMovementBlendTarget(false)
		action StopAllUserAnimationsTarget()
		action SetTargetToFaceMe()

		action PlayAnim("atk", "vis01", false, 0.0)
		action SetRandomTimerBetween(1, 0.26, 0.26)
		transition
		{
			goto VisInit
		}
	}

	state VisInit
	{
		action FaceTargetInstant()
		action SetTargetToFaceMe()

		transition IsHumanWaitingToDie() == false
		{
			;// fail means abort our fsm
			goto AttackExitEnd
		}

		transition IsTimerUp(1)
		{
			action KillHuman()
			action PlayAnimTarget("hit", "bk", false)
			action SetLockLastPoseTarget("hit", "bk", false)
			direct goto AttackLoop
		}
	}

	state Attackloop
	{
		transition IsAnimPlaying("atk", "vis01", false) == false
		{
			action SetTransfromFromLocator("D", true)
			action StopAnimInstant("atk", "vis01")
			action PlayAnimInstant("idle", "brth_lp", false)
			action SetStandStill()
			action SetAutoMovementBlend(true)
			action SetRandomTimerBetween(3, 1.0, 1.0)

			goto AttackFinish
		}
	}

	state AttackFinish
	{
		transition IsTimerUp(3)
		{
			action SetAutoMovementBlend(false)
			action PlayAnimInstant("idle", "post_lp", false)
			goto PostureWait
		}
	}

	state PostureWait
	{
		transition IsAnimPlaying("idle", "post_lp", false) == false
		{
			action SetAutoMovementBlend(true)

			action SetSpeedModifierWalk(1.0)
			action SetRunMode(false)

			action SeekTargetOffset(4.0, 0, false, true, true)
			action SetRandomTimerBetween(1, 1.0, 1.0)
			action AddKillExperience(1, 0.0)
			goto MoveOffHuman
		}
	}

	state MoveOffHuman
	{
		transition IsTimerUp(1)
		{
			action SetStandStill()
			goto AttackExitStart
		}
		transition InTargetProximityRadius(1.0, false) == false
		{
			action SetStandStill()
			goto AttackExitStart
		}
		transition HasArrived()
		{
			goto AttackExitStart
		}
	}


;------------------------ Exit States Begin ----------------------
	exitstart state AttackExitStart
	{
		action UpdateVariable("Stress", -0.05)
		transition
		{
			goto AttackExitEnd
		}
	}

	exitend state AttackExitEnd
	{
		action SetSpeedModifier(1.0)
		action SetRunMode(false)
		action SetAvoidanceSteer(true)
		action SetAvoidanceWorld(true)
		action LookEnd()
		action StopAnimState("atk")
		action LockMachine(false)
		;//action SetAesPosInterp(true)
	}
;------------------------ Exit States End ----------------------
}
