/* Galli Hunger Behaviour // */ machine GalliHunger { default state Start { action StartLook("LookProximity", 0.5) action SetAutoMovementBlend(true) action SetSpeedModifierWalk(1.0) action SetRunMode(false) action SetRand(0, 2) transition GetRand() > 0 { goto GrazeOnly } transition { goto SetWander } } state SetWander { transition SetWander() == true { action SetRandomTimerBetween(1, 3.0, 5.0) action SetFlockImpulse(true) goto GetTarget } } state GetTarget { transition AcquireTarget("food") { goto FoundFoodTarget } transition AcquireTree(10, true) { action SetFlockImpulse(false) goto GoingToTree } transition HasArrived() { goto Start } transition IsTimerUp(1) { goto GrazeStart } } state GoingToTree { transition HasArrived() { action SetStandStill() action SetSpeedDirect(0.0) action StopLook() action FaceSetPosition() goto FaceTree } transition InSetPosProximityRadius(0.8) { action SetStandStill() action SetSpeedDirect(0.0) action StopLook() action FaceSetPosition() goto FaceTree } } state FaceTree { transition HasArrived() { action SendEnclosureEvent("feeding_plant") action SetStandStill() action PlayAnim("eat", "md_lp", false) goto EatTree } } state EatTree { ;//action UpdateDeltaVariable("FoodEnergy", 0.005) action HerbEatTarget("tree") transition IsAnimStatePlaying("eat", false)==false { action StartLook("LookProximity", 0.5) goto TreeLook } } state TreeLook { action SetRandomTimerBetween(1, 2.0, 3.0) transition { action SetRand(0, 2) goto TreeLookCallWait } } state TreeLookCallWait { transition GetRand() == 0 { action PlayAnim("call", "02_lp", false) goto TreeLookWait } transition { goto TreeLookWait } } state TreeLookWait { transition IsTimerUp(1) { goto TreeEatWander } } state TreeEatWander { transition { goto Start } /* transition SetWander() { action SetRandomTimerBetween(1, 6.0, 7.0) goto TreeEatWanderLoop } */ } state TreeEatWanderLoop { transition IsTimerUp(1) { goto SetWander } } state GrazeOnly { action SetRandomTimerBetween(1, 10.0, 12.0) transition IsInGrazeArea() == false { goto GrazeWander } transition { goto Graze } } state GrazeWander { transition SetWander() { action SetFlockImpulse(true) goto GrazeWanderWait } } state GrazeWanderWait { transition IsInGrazeArea() == true { goto Graze } transition IsTimerUp(1) { goto Start } transition HasArrived() { goto GrazeWander } } state GrazeStart { action SetRandomTimerBetween(1, 7.0, 8.0) transition IsInGrazeArea() == false { action SetFlockImpulse(true) goto GetTarget } transition { goto Graze } } state Graze { action StopLook() action SendEnclosureEvent("feeding_plant") action SetStandStill() action SetAutoMovementBlend(false) action PlayAnim("eat", "lo_lp", false) action SetFlockImpulse(false) transition IsTimerUp(1) { goto GrazeEnd } transition { goto GrazeLoop } } state GrazeLoop { ;//action UpdateDeltaVariable("FoodEnergy", 0.005) action HerbEatTarget("grass") transition IsAnimStatePlaying("eat")==false { action StartLook("LookProximity", 0.5) action SetAutoMovementBlend(true) action SetRand(0, 2) goto GrazeLookCall } } state GrazeLookCall { transition GetRand() == 0 { action PlayAnim("call", "02_lp", false) goto GrazeLook } transition { goto GrazeLook } } state GrazeLook { action SetRandomTimerBetween(2, 1.0, 3.0) transition { goto GrazeLookLoop } } state GrazeLookLoop { transition IsTimerUp(2) { goto Graze } } state GrazeEnd { transition IsAnimStatePlaying("eat", false)==false { action SetAutoMovementBlend(true) goto Start } } state FoundFoodTarget { action SetRunMode(false) action SetSpeedModifierWalk(1.0) action SetFlockImpulse(false) transition SeekTarget(true, false) { goto SeekFood } transition { action ClearTarget() goto SetWander } } state SeekFood { transition HasArrived() { goto SeekFacingCheck } transition InTargetProximityRadius(1.7, true) { action SetStandStill() direct goto SeekFacingCheck } } state SeekFacingCheck { transition HasTarget() == false ;// as food may have disappeared { action ClearTarget() goto SetWander } transition IsFacingTargetUnit() { goto EatFood } transition { action FaceTarget() goto SeekFacingAlignWait } } state SeekFacingAlignWait { transition HasArrived() { goto EatFood } } state EatFood { transition { action SetStandStill() action StopLook() action SendEnclosureEvent("feeding_plant") action SetAutoMovementBlend(false) action SetSpeedDirect(0.0) action PlayAnim("eat", "lo_lp", true) goto EatFoodWait } } state EatFoodWait { transition IsAnimPlaying("eat", "lo_lp", true) == false { action SetAutoMovementBlend(true) action SetRandomTimerBetween(1, 6.0, 9.0) action PlayAnimLooping("chew", "lp", false, -1.0, 1.0) action StartLook("LookProximity", 0.5) goto EatFoodChew } } state EatFoodChew { ;//action UpdateDeltaVariable("FoodEnergy", 0.01) action HerbEatTarget("bale") transition IsTimerUp(1) { action StopAnimState("chew") action SetFlockImpulse(true) goto GetTarget } } ;------------------------ Exit States Begin ---------------------- exitstart state HungerCleanUp { action StopAnimState("eat") transition IsAnimStatePlaying("eat", true)==false { goto HungerCleanUpWait } transition { goto HungerCleanUpEnd } } state HungerCleanUpWait { transition IsAnimStatePlaying("eat", false)==false { goto HungerCleanUpEnd } } exitend state HungerCleanUpEnd { action SetFlockImpulse(true) action StopLook() } ;------------------------ Exit States End ---------------------- }