Ejemplo n.º 1
0
 static LandPredatorBrain()
 {
     PredatorTreeRoot = BT.Selector(
         LandAnimalBrain.LyingDownTree,
         BT.If(x => x.Alertness > LandAnimalBrain.AlertThreshold && x.Alertness < LandAnimalBrain.FullyAlertThreshold && x.AnimationState != AnimalAnimationState.Flee && x.AnimationState != AnimalAnimationState.AlertIdle && x.OnFlatGround,
               // play an alert reaction before fleeing and intermittently while alert
               PlayFixedTimeAnimation(AnimalAnimationState.AlertIdle, LandAnimalBrain.AlertIdleTime)),
         MovementBehaviors.Flee,
         GroupBehaviors.SleepNearLeader,
         BT.If(x => x.Hunger > HungerThreshold,
               BT.Selector(
                   TryEatNearbyCorpses,
                   new HuntMemoryBehavior()
     {
         NoNearbyFoodBehavior = LandAnimalBrain.LandAnimalFindFood
     })),
         GroupBehaviors.StayNearLeader(10f),
         //TODO: show a failed chase if there are no corpses neary to eat
         BT.If(MovementBehaviors.ShouldReturnHome,
               MovementBehaviors.WanderHome),
         BT.If(x => x.Alertness < Animal.FleeThreshold && RandomUtil.Chance(LandAnimalBrain.ChanceToLieDown) && x.OnFlatGround,
               PlayAnimation(AnimalAnimationState.LyingDown, LandAnimalBrain.LyingTickDuration)),
         BT.If(x => RandomUtil.Chance(LandAnimalBrain.ChanceToIdle) && x.OnFlatGround,
               PlayAnimation(AnimalAnimationState.Idle, _ => RandomUtil.Range(LandAnimalBrain.MinIdleTime, LandAnimalBrain.MaxIdleTime))),
         MovementBehaviors.Wander);
 }
Ejemplo n.º 2
0
 static HerdAnimalBrain()
 {
     HerdAnimalTreeRoot =
         BT.Selector("Herd Brain",
                     LandAnimalBrain.LyingDownTree,
                     PerceptionBehaviors.Alert,
                     MovementBehaviors.Flee,
                     GroupBehaviors.SleepNearLeader,
                     LandAnimalBrain.FindAndEatPlants,
                     GroupBehaviors.StayNearLeader(20f),
                     MovementBehaviors.TryReturnHome,
                     RelaxBehaviors.Relax,
                     MovementBehaviors.Wander);
 }
 static HerdAnimalBrain()
 {
     HerdAnimalTreeRoot =
         BT.Selector(
             LandAnimalBrain.LyingDownTree,
             BT.If(x => x.Alertness > LandAnimalBrain.AlertThreshold && x.Alertness < LandAnimalBrain.FullyAlertThreshold && x.AnimationState != AnimalAnimationState.Flee && x.AnimationState != AnimalAnimationState.AlertIdle && x.OnFlatGround,
                   // play an alert reaction before fleeing and intermittently while alert
                   PlayFixedTimeAnimation(AnimalAnimationState.AlertIdle, LandAnimalBrain.AlertIdleTime)),
             MovementBehaviors.Flee,
             GroupBehaviors.SleepNearLeader,
             new FindAndEatPlantsMemoryBehavior()
     {
         NoNearbyFoodBehavior = LandAnimalBrain.LandAnimalFindFood
     },
             GroupBehaviors.StayNearLeader(20f),
             BT.If(MovementBehaviors.ShouldReturnHome,
                   MovementBehaviors.WanderHome),
             BT.If(x => x.Alertness < Animal.FleeThreshold && RandomUtil.Chance(LandAnimalBrain.ChanceToLieDown) && x.OnFlatGround,
                   PlayAnimation(AnimalAnimationState.LyingDown, LandAnimalBrain.LyingTickDuration)),
             BT.If(x => RandomUtil.Chance(LandAnimalBrain.ChanceToIdle) && x.OnFlatGround,
                   PlayAnimation(AnimalAnimationState.Idle, _ => RandomUtil.Range(LandAnimalBrain.MinIdleTime, LandAnimalBrain.MaxIdleTime))),
             MovementBehaviors.Wander);
 }