/* Generic Herbivore Flee Behaviour // */ machine HerbFlee { default state Start { action SetAutoMovementBlend(true) action SetRunMode(true) action SetSpeedModifier(1.0) transition AcquireTarget("aggressor") { action StartLook("LookTarget", 1.0) action SendEnclosureEvent("escape_predator") ;//action AddRandomAnimation("call", "02_lp", 1.0, 2.0) action AddRandomAnimation("call", "01_lp", 2.0, 3.0) goto FoundTarget } } state FoundTarget { action AvoidTarget(50.0, true) action UpdateFleeSpeed(0.05, false) transition InTargetProximity(48.0, true) == false { goto SetWander } } state SetWander { action SetWander() action SetRandomTimerBetween(1, 17.0, 20.0) transition { goto Wander } } state Wander { transition HasArrived() { goto SetWander } transition InTargetProximity(45.0, true) { ;//action AddRandomAnimation("call", "02_lp", 1.0, 2.0) action AddRandomAnimation("call", "01_lp", 2.0, 3.0) goto FoundTarget } transition IsTimerUp(1) { goto SetWander } } ;------------------------ Exit States Begin ---------------------- exitstart state CleanUp { ;// stay in this state a little while transition { action SetStandStill() action SetRandomTimerBetween(1, 5.0, 6.0) action StartLook("LookRandom", 1.5) goto CautiousWait } } state CautiousWait { transition IsNextDrive("Flee") { goto FleeEnd } transition IsNextDrive("Muster") { goto FleeEnd } transition IsTimerUp(1) { goto FleeEnd } transition AcquireTarget("aggressor") { action AvoidTarget(50.0, true) goto CautiousFlee } } state CautiousFlee { transition IsNextDrive("Dead") { goto FleeEnd } transition IsNextDrive("Muster") { goto FleeEnd } transition IsTimerUp(1) { goto FleeEnd } action UpdateFleeSpeed(0.05, false) transition InTargetProximity(48.0, true) == false { goto CautiousWait } } state FleeEnd { action StopLook() transition { goto CleanUpEnd } } exitend state CleanUpEnd { action SetStandStill() action StopAllRandomAnimations() action UpdateFleeSpeed(1.0, true) } ;------------------------ Exit States End ---------------------- }