示例#1
0
 /// <summary>
 /// Constructs a simple squad push plugin
 /// </summary>
 /// <param name="OnlyWhenKill">Push only when killing is possible</param>
 /// <param name="OnlyCapsules">Push only capsule carrying pirates</param>
 /// <param name="CrystalEmergency">Ignore OnlyWhenKill if a capsule is about to be scored</param>
 /// <param name="PrioritizeCapsules">Prioiritize capsule carriers</param>
 public SquadPushPlugin(bool OnlyWhenKill = true, bool OnlyCapsules = false, bool CrystalEmergency = true, bool PrioritizeCapsules = true)
 {
     Scorer = obj =>
     {
         if (obj is Pirate && Bot.Engine.IsAliveAfterTurn((Pirate)obj, 0) && (!OnlyCapsules || ((Pirate)obj).HasCapsule()))
         {
             return(((Pirate)obj).HasCapsule() ? 2 : 1);
         }
         else
         {
             return(0);
         }
     };
     PushMapper = (obj, attackers) =>
     {
         if (!(obj is Pirate))
         {
             return(new PushMapping());
         }
         if (CrystalEmergency && !Bot.Engine.CanKill(attackers, obj))
         {
             return(PushMapping.ByNumPushes(attackers, (obj as Pirate).NumPushesForCapsuleLoss, obj.ClosestBorder()));
         }
         return(PushMapping.ByDistance(attackers, obj.DistanceFromBorder(), obj.ClosestBorder()));
     };
     this.Ascending = false;
 }
示例#2
0
        public bool DoTurn(Squad squad)
        {
            SquadPushPlugin pusher = new SquadPushPlugin(x => x.StickyBombs.Length > 0 ? 1 : 0, true,
                                                         (obj, attackers) => Bot.Engine.CanKill(attackers, obj)
                    ? PushMapping.ByDistance(attackers, obj.DistanceFromBorder(), obj.ClosestBorder())
                    : new PushMapping());

            bool res = pusher.DoTurn(squad);

            if (GameEngine.UNSAFE_SQUAD_PLUGINS)
            {
                return(false);
            }
            else
            {
                return(res);
            }
        }