machine EdDefend { state PreTestStart { action SetAutoMovementBlend(true) action SetRunMode(true) action SetSpeedModifier(1.0) action ClearTarget() action SetRandomTimerBetween(2, 15.0, 20.0) transition { direct goto TestStart } } state TestStart { action AcquireTarget("aggressor") transition HasTarget() { direct goto DefendChoose } transition { action SetWander() goto Wander } } state Wander { action AcquireTarget("aggressor") transition HasTarget() { direct goto DefendChoose } transition HasArrived() { goto TestStart } } ;// test end state DefendChoose { /* transition IsTimerUp(2) { goto FleeStart } transition InTargetProximity(15.0, true) == false { goto DefendStart } */ transition { ;//action AddRandomAnimation("call", "02_lp", 1.0, 2.0) action AddRandomAnimation("call", "01_lp", 2.0, 3.0) action SendEnclosureEvent("escape_predator") goto FleeStart } } /* state DefendStart { action AcquireTarget("aggressor") transition HasTarget() { action SetSpeedModifier(1.0) call Ram RamEnd } } */ state FleeStart { action AvoidTarget(50.0, true) transition { goto FleeStopCheck } } state FleeStopCheck { action UpdateFleeSpeed(0.05, false) transition IsTargetLatchedOn() { ;//call EdmontThrowOff DefendStart call EdmontThrowOff FleeStart } transition InTargetProximity(48.0, true) == false { action SetWander() goto Wander } /* transition { goto FleeStart } transition InTargetProximity(14.5, true) == false { goto DefendStart } */ } /* state RamEnd { action SetRandomTimerBetween(1, 5.0, 6.0) transition { goto RestPause } } state RestPause { transition IsTargetLatchedOn() { ;// call EdmontThrowOff DefendStart call EdmontThrowOff FleeStopCheck } transition IsTimerUp(1) { goto FleeStart } } */ ;//------------------------ Exit States Begin ---------------------- exitstart state CleanUp { action SetSpeedModifier(1.0) action StopAnimState("shake") ;// 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 { action UpdateFleeSpeed(0.05, false) transition IsNextDrive("Dead") { goto FleeEnd } transition IsNextDrive("Muster") { goto FleeEnd } transition IsTimerUp(1) { goto FleeEnd } transition InTargetProximity(48.0, true) == false { goto CautiousWait } } state FleeEnd { action SetSpeedModifier(1.0) action StopAnimState("shake") transition { goto CleanUpLoop } } state CleanUpLoop { transition IsAnimStatePlaying("shake") == false { goto CleanUpEnd } } exitend state CleanUpEnd { action UpdateFleeSpeed(1.0, true) action StopAllRandomAnimations() } ;//------------------------ Exit States End ---------------------- }