/* Generic Herbivore Hurt Behaviour // */ machine HerbHurt { state Start { action SetRand(0, 4) transition GetRand() == 0 { action SetStandStill() action SetSpeedDirect(0.0) goto HurtCall } transition { goto HurtRunAway } } state HurtCall { action SetAutoMovementBlend(false) action PlayAnimInstant("idle", "post_lp", false) transition { goto HurtCallWait } } state HurtCallWait { transition IsAnimPlaying("idle", "post_lp", false) == false { action SetAutoMovementBlend(true) goto HurtRunAway } } state HurtRunAway { action SetRunMode(true) action SetSpeedModifier(1.0) transition AcquireTarget("aggressor") == false { action SetWander() action SetRandomTimerBetween(1, 5.0, 6.0) goto HurtWander } transition { action AddRandomAnimation("call", "02_lp", 3.0, 5.0) action AddRandomAnimation("call", "01_lp", 2.0, 6.0) action SetRandomTimerBetween(1, 12.0, 15.0) goto FoundTarget } } state HurtWander { transition HasArrived() { goto CleanUp } transition IsTimerUp(1) { action SetStandStill() goto CleanUp } } state FoundTarget { action AvoidTarget(50.0, true) transition InTargetProximity(48.0) == false { goto CleanUp } transition IsTimerUp(1) { goto CleanUp } } ;//------------------------ Exit States Begin ---------------------- exitstart state CleanUp { action StopLook() transition { goto CleanUpEnd } } exitend state CleanUpEnd { action SetStandStill() action SetHurt(false, 0) action StopAllRandomAnimations() action SetAutoMovementBlend(true) } ;//------------------------ Exit States End ---------------------- }