Example #1
0
        public KillEntityAct(Body entity, CreatureAI creature, KillEntityTask.KillType mode) :
            base(creature)
        {
            Mode   = mode;
            Entity = entity;
            Name   = "Kill Entity";
            PlanAct.PlanType planType = PlanAct.PlanType.Adjacent;
            float            radius   = 0.0f;

            if (creature.Creature.Attacks[0].Mode == Attack.AttackMode.Melee)
            {
                planType = PlanAct.PlanType.Radius;
                radius   = creature.Creature.Attacks[0].Range;
            }
            Tree =
                new Parallel(
                    new Sequence
                    (
                        new GoToEntityAct(entity, creature)
            {
                MovingTarget = mode != KillEntityTask.KillType.Chop,
                PlanType     = planType,
                Radius       = radius
            },
                        new MeleeAct(Agent, entity)
                    ),
                    new Wrap(Verify)
                    );
        }
Example #2
0
 public GoToVoxelAct(VoxelHandle voxel, PlanAct.PlanType planType, CreatureAI creature, float radius = 0.0f) :
     base(creature)
 {
     Radius   = radius;
     Voxel    = voxel;
     Name     = "Go to DestinationVoxel";
     PlanType = planType;
 }
Example #3
0
 public GoToVoxelAct(string voxel, PlanAct.PlanType planType, CreatureAI creature, float radius = 0.0f) :
     base(creature)
 {
     Radius    = radius;
     PlanType  = planType;
     VoxelName = voxel;
     Name      = "Go to Voxel " + voxel;
 }
Example #4
0
 public GoToVoxelAct(string voxel, PlanAct.PlanType planType, CreatureAI creature, float radius = 0.0f) :
     base(creature)
 {
     Name = "Go to Voxel " + voxel;
     Tree = new Sequence(
         new ForLoop(
             new Sequence(
                 new PlanAct(Agent, "PathToVoxel", voxel, planType)
     {
         Radius = radius
     },
                 new FollowPathAnimationAct(Agent, "PathToVoxel")
                 )
             , 3, true),
         new StopAct(Agent));
 }
Example #5
0
 public GoToVoxelAct(Voxel voxel, PlanAct.PlanType planType, CreatureAI creature, float radius = 0.0f) :
     base(creature)
 {
     Voxel = voxel;
     Name  = "Go to Voxel";
     if (Voxel != null)
     {
         Tree = new Sequence(
             new SetBlackboardData <Voxel>(Agent, "TargetVoxel", Voxel),
             new PlanAct(Agent, "PathToVoxel", "TargetVoxel", planType)
         {
             Radius = radius
         },
             new FollowPathAnimationAct(Agent, "PathToVoxel"),
             new StopAct(Agent));
     }
 }
Example #6
0
 public RechargeObjectAct(MagicalObject entity, CreatureAI creature) :
     base(creature)
 {
     Entity = entity;
     Name   = "Recharge Object";
     PlanAct.PlanType planType = PlanAct.PlanType.Adjacent;
     Tree =
         new Domain(Verify(creature), new Sequence
                    (
                        new GoToEntityAct(Entity.GetRoot() as GameComponent, creature)
     {
         MovingTarget = true,
         PlanType     = planType,
         Radius       = 2.0f
     } | new Wrap(() => OnRechargeEnd(creature)),
                        new Wrap(Recharge)
     {
         Name = "Recharge Object"
     },
                        new Wrap(() => OnRechargeEnd(creature))
                    )) | new Wrap(() => OnRechargeEnd(creature));
 }
Example #7
0
        public KillEntityAct(Body entity, CreatureAI creature, KillEntityTask.KillType mode) :
            base(creature)
        {
            Mode   = mode;
            Entity = entity;
            Name   = "Kill Entity";
            PlanAct.PlanType planType = PlanAct.PlanType.Adjacent;
            float            radius   = 0.0f;

            if (creature.Creature.Attacks[0].Mode == Attack.AttackMode.Ranged)
            {
                planType = PlanAct.PlanType.Radius;
                radius   = creature.Creature.Attacks[0].Range;
            }
            if (creature.Movement.IsSessile)
            {
                Tree =
                    new Domain(Verify,
                               new Sequence
                               (
                                   new MeleeAct(Agent, entity)
                               ) | new Wrap(() => OnAttackEnd(creature))
                               );
            }
            else
            {
                Tree =
                    new Domain(Verify, new Sequence
                               (
                                   new GoToEntityAct(entity, creature)
                {
                    MovingTarget = mode != KillEntityTask.KillType.Chop,
                    PlanType     = planType,
                    Radius       = radius
                } | new Wrap(() => OnAttackEnd(creature)),
                                   new MeleeAct(Agent, entity)
                               ));
            }
        }
Example #8
0
        public ChopEntityAct(Body entity, CreatureAI creature) :
            base(creature)
        {
            Entity = entity;
            Name   = "Harvest Plant";
            PlanAct.PlanType planType = PlanAct.PlanType.Adjacent;
            float            radius   = 0.0f;

            if (creature.Creature.Attacks[0].Mode == Attack.AttackMode.Ranged)
            {
                planType = PlanAct.PlanType.Radius;
                radius   = creature.Creature.Attacks[0].Range;
            }
            if (creature.Movement.IsSessile)
            {
                Tree =
                    new Domain(Verify(Agent),
                               new Sequence
                               (
                                   new MeleeAct(Agent, entity)
                               ) | new Wrap(() => OnAttackEnd(creature)) | Verify(Agent)
                               );
            }
            else
            {
                Tree =
                    new Domain(Verify(Agent),
                               new Sequence
                               (
                                   new GoToEntityAct(entity, creature)
                {
                    MovingTarget = false,
                    PlanType     = planType,
                    Radius       = radius
                } | new Wrap(() => OnAttackEnd(creature)),
                                   new MeleeAct(Agent, entity)
                               ) | Verify(Agent));
            }
        }
Example #9
0
        public KillEntityAct(GameComponent entity, CreatureAI creature) :
            base(creature)
        {
            Entity = entity;
            Name   = "Kill Entity";

            // Get the closest structure that we might defend from.
            closestDefensiveStructure = creature.Faction.OwnedObjects.Where(b => !b.IsReserved && b.Tags.Contains("Defensive")).OrderBy(b => (b.Position - Entity.Position).LengthSquared()).FirstOrDefault();

            // Do not attempt to defend from faraway structures
            if (closestDefensiveStructure != null)
            {
                float distToStructure = (closestDefensiveStructure.Position - creature.Position).Length();
                float distToEntity    = (Entity.Position - creature.Position).Length();

                if (distToStructure > 1.5f * distToEntity || distToStructure > 20.0f)
                {
                    closestDefensiveStructure = null;
                }
            }

            PlanAct.PlanType planType = PlanAct.PlanType.Adjacent;
            float            radius   = 0.0f;

            if (creature.Creature.Attacks[0].Weapon.Mode == Weapon.AttackMode.Ranged)
            {
                planType = PlanAct.PlanType.Radius;
                radius   = creature.Creature.Attacks[0].Weapon.Range;
            }

            if (creature.Movement.IsSessile)
            {
                Tree =
                    new Domain(() => Verify(creature),
                               new Sequence
                               (
                                   new MeleeAct(Agent, entity)
                               ) | new Wrap(() => OnAttackEnd(creature))
                               );
            }
            else
            {
                if (closestDefensiveStructure == null || (closestDefensiveStructure.Position - creature.Position).Length() > 20.0f)
                {
                    Tree =
                        new Domain(() => Verify(creature),
                                   new Sequence
                                   (
                                       new GoToEntityAct(entity, creature)
                    {
                        MovingTarget = true,
                        PlanType     = planType,
                        Radius       = radius
                    } | new Wrap(() => OnAttackEnd(creature)),
                                       new MeleeAct(Agent, entity),
                                       new Wrap(() => OnAttackEnd(creature))
                                   ));
                }
                else
                {
                    closestDefensiveStructure.ReservedFor = creature;
                    Tree =
                        new Domain(() => Verify(creature),
                                   new Sequence
                                   (
                                       new GoToEntityAct(closestDefensiveStructure, creature)
                    {
                        PlanType = PlanAct.PlanType.Into,
                    } | new Wrap(() => OnAttackEnd(creature)),
                                       new TeleportAct(Creature.AI)
                    {
                        Location = closestDefensiveStructure.GetRotatedBoundingBox().Center(), Type = TeleportAct.TeleportType.Lerp
                    },
                                       new MeleeAct(Agent, entity)
                    {
                        DefensiveStructure = closestDefensiveStructure
                    },
                                       new Wrap(() => OnAttackEnd(creature))
                                   ));
                }
            }
        }