Exemplo n.º 1
0
        private static void TestGetLocalGridEntities(Character me, EVE.ISXEVE.EVE eve, ILogger logger)
        {
            //var entities = EntityRepository.GetLocalGridEntities(me, eve);
              eve.RefreshStandings();
              var entities = eve.QueryEntities().Where(x => x.IsPC);

              //var anObj = LavishScript.Objects.GetObject("Local", "Romvex");
              //logger.Log(anObj.ToString());

              var pilot = new Pilot("Romvex ");
              logger.Log(pilot.ToString());

              foreach (var entity in entities)
              {
            logger.Log(entity.Name);
            logger.Log(LavishScriptObject.IsNullOrInvalid(entity.Owner.ToFleetMember).ToString());
            logger.Log(entity.Owner.CharID.ToString());
            logger.Log(entity.Owner.Corp.ID.ToString());
            logger.Log(entity.AllianceID.ToString());
            var standing = me.StandingTo(entity.CharID, entity.Corp.ID, entity.AllianceID);
            logger.Log(standing.AllianceToAlliance.ToString());
            logger.Log(standing.AllianceToCorp.ToString());
            logger.Log(standing.AllianceToPilot.ToString());
            logger.Log(standing.CorpToAlliance.ToString());
            logger.Log(standing.CorpToCorp.ToString());
            logger.Log(standing.CorpToPilot.ToString());
            logger.Log(standing.MeToAlliance.ToString());
            logger.Log(standing.MeToCorp.ToString());
            logger.Log(standing.MeToPilot.ToString());
              }
        }
Exemplo n.º 2
0
        /// <summary>
        ///   Gets the local grid entities.
        /// </summary>
        /// <param name="myMe"></param>
        /// <param name="myEVE">My eve.</param>
        /// <returns></returns>
        public static IEnumerable<EntityViewModel> GetLocalGridEntities(Character myMe, EVE.ISXEVE.EVE myEVE)
        {
            try
              {
            var entities = myEVE.QueryEntities().Where(entity => entity.IsPC && myMe.CharID != entity.CharID).ToArray();

            var oEntities = new List<EntityViewModel>();

            foreach (var entity in entities)
            {
              var standings = EntityHelper.ComputeStandings(myMe, entity);

              var newEntity = new EntityViewModel {Entity = entity, EntityStandings = standings};

              var cachedEntity = EntityCache.Get(newEntity);

              if (cachedEntity == null)
              {
            EntityCache.Add(newEntity);
              }
              else
              {
            if (cachedEntity.EntityStandings != newEntity.EntityStandings)
            {
              if (newEntity.EntityStandings > cachedEntity.EntityStandings)
              {
                EntityCache.Remove(newEntity);
                EntityCache.Add(newEntity);
              }

              if (newEntity.EntityStandings == 0 && cachedEntity.EntityStandings != 0)
              {
                newEntity.EntityStandings = cachedEntity.EntityStandings;
              }
            }
              }

              oEntities.Add(newEntity);
            }

            return oEntities;
              }
              catch (Exception e)
              {
            InnerSpace.Echo("GET LOCAL GRID ENTITIES ERROR :" + e.Message);

            return new List<EntityViewModel>();
              }
        }
Exemplo n.º 3
0
        /// <summary>
        ///   Computes the standings.
        ///   Between -10 and 10
        ///   11 = self
        /// </summary>
        /// <param name="myMe"></param>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public static int ComputeStandings(Character myMe, Entity entity)
        {
            var eCharId = entity.CharID;

              if (eCharId == myMe.CharID)
              {
            return 11;
              }

              if (entity.IsOwnedByAllianceMember || entity.IsOwnedByCorpMember || entity.IsFleetMember())
              {
            return 10;
              }

              var standing = myMe.StandingTo(entity.CharID, entity.Corp.ID, entity.AllianceID);

              var standingsImportant = new List<int>
              {
            standing.AllianceToAlliance,
            standing.AllianceToCorp,
            standing.AllianceToPilot,
            standing.CorpToAlliance,
            standing.CorpToCorp,
            standing.CorpToPilot,
            standing.MeToAlliance,
            standing.MeToCorp,
            standing.MeToPilot
              };

              var standingsPersonal = new List<int>
              {
            standing.MeToAlliance,
            standing.MeToCorp,
            standing.MeToPilot
              };

              var finishStandings = standingsPersonal.Min() < 0 ? standingsPersonal.Min() : standingsImportant.Max();

              return finishStandings;
        }
        /// <summary>
        ///   Called when [time setup].
        /// </summary>
        private void OneTimeSetup()
        {
            Frame.Wait(true);

              MyEve = new EVE.ISXEVE.EVE();
              MyMe = new Me();

              MyEve.RefreshStandings();
              MyEve.RefreshBookmarks();

              ActivePilot = MyMe.Name;

              Frame.Unlock();
        }
        /// <summary>
        ///   Does the work.
        /// </summary>
        /// <param name="myMe">My me.</param>
        /// <param name="myEVE">My eve.</param>
        private void DoWork(Character myMe, EVE.ISXEVE.EVE myEVE)
        {
            if (CurrentBotState == BotState.Active)
              {
            try
            {
              var allEntities = EntityRepository.GetLocalGridEntities(myMe, myEVE).ToArray();

              var engageableTargets = CombatHelper.FindEngageableTargets(myMe, myEVE, allEntities, EngageRules).ToList();

              Entities = new ObservableCollection<EntityViewModel>(allEntities);

              foreach (var engageableTarget in engageableTargets)
              {
            logger.Log(engageableTarget.EntityName + " " + " Corp: " + engageableTarget.Entity.Owner.Corp.Name + " " + engageableTarget.Entity.Owner.Corp.ID +
                       " AllyId: " + engageableTarget.Entity.Owner.AllianceID + " isFleet" + engageableTarget.Entity.FleetTag);
              }

              CombatHelper.Engage(myMe, myEVE, engageableTargets, EngageRules);
            }

            catch (Exception exc)
            {
              InnerSpace.Echo("DO WORK ERROR: " + exc.Message);
            }
              }
        }
        /// <summary>
        ///   Does the this on frame.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="LSEventArgs" /> instance containing the event data.</param>
        private void DoThisOnFrame(object sender, LSEventArgs e)
        {
            if (FrameActionScheduler.TryExecute())
              {
            try
            {
              var ext = new Extension();
              MyEve = ext.EVE();
              MyMe = ext.Me;

              DoWork(MyMe, MyEve);
            }
            catch (Exception exp)
            {
              InnerSpace.Echo(exp.Message);
            }
              }
        }
Exemplo n.º 7
0
        /// <summary>
        ///   Activates the tackle modules.
        /// </summary>
        /// <param name="myMe">My me.</param>
        /// <param name="myEve">My eve.</param>
        /// <param name="engageRules"></param>
        public static void ActivateModules(Character myMe, EVE.ISXEVE.EVE myEve, EngageRules engageRules)
        {
            var modules = myMe.Ship.GetModules();

              foreach (var module in modules)
              {
            var mItem = module.ToItem;

            var name = mItem.Name.ToLower();

            if (name.Contains("sensor booster"))
            {
              module.Activate();
            }
            else if (name.Contains("probe"))
            {
              //skip
            }
            else if (name.Contains("booster"))
            {
              if (engageRules.UseRepairer != null && engageRules.UseRepairer.Value)
              {
            module.Activate();
              }
            }
            else if (name.Contains("repairer"))
            {
              if (engageRules.UseRepairer != null && engageRules.UseRepairer.Value)
              {
            module.Activate();
              }
            }
            else if (name.Contains("cloak"))
            {
              module.Deactivate();
            }
            else if (name.Contains("cyno"))
            {
              //skip
            }
            else if (name.Contains("bomb"))
            {
              //skip
            }
            else if (name.Contains("microwarp"))
            {
              if (engageRules.UsePropulsion ?? DefaultActivatePropulsion)
              {
            module.Activate();
              }
            }
            else if (name.Contains("afterburner"))
            {
              if (engageRules.UsePropulsion ?? DefaultActivatePropulsion)
              {
            module.Activate();
              }
            }
            else
            {
              module.Activate();
            }
              }

              //engage drones last because modules might improve their effectiveness
              var myDrones = myMe.GetActiveDrones().Select(x => x.ID).ToList();

              myEve.DronesEngageMyTarget(myDrones);
        }
Exemplo n.º 8
0
        /// <summary>
        ///   Finds the engageable targets.
        /// </summary>
        /// <param name="myMe">My me.</param>
        /// <param name="myEVE">My eve.</param>
        /// <param name="entities">The entities.</param>
        /// <param name="engageRules">The engage rules.</param>
        /// <returns></returns>
        public static IEnumerable<EntityViewModel> FindEngageableTargets(Character myMe,
      EVE.ISXEVE.EVE myEVE, IEnumerable<EntityViewModel> entities, EngageRules engageRules)
        {
            var allNeutrals = entities.Where(
            x =>
              x.Entity.IsValid &&
              x.EntityStandings <= 0 &&
              x.EntityDistanceTo <= (engageRules.MaxRange ?? DefaultEngageRange)
            );

              if (!allNeutrals.Any())
              {
            return new List<EntityViewModel>();
              }

              //sort by capsule
              allNeutrals = allNeutrals.OrderBy(x => x.EntityGroup);

              var limitedTargets = allNeutrals.Take((int) myMe.MaxLockedTargets);

              return limitedTargets;
        }
Exemplo n.º 9
0
        /// <summary>
        ///   Does the tackle and returns the current valid engageable targets
        /// </summary>
        /// <param name="myMe">My me.</param>
        /// <param name="myEve">My eve.</param>
        /// <param name="entities">The entities.</param>
        /// <param name="engageRules">The engage rules.</param>
        public static void Engage(Character myMe, EVE.ISXEVE.EVE myEve,
      IEnumerable<EntityViewModel> entities, EngageRules engageRules)
        {
            IEnumerable<EntityViewModel> targettedNeuts = TargetNeuts(entities).ToList();

              //Tackle closest targetted neut
              EntityViewModel closestTargetedNeut = null;
              if (targettedNeuts.Any())
              {
            closestTargetedNeut = EntityHelper.FindClosestEntity(targettedNeuts);
              }

              if (closestTargetedNeut != null)
              {
            if (engageRules.GoBrawl ?? DefaultGoBrawl)
            {
              closestTargetedNeut.Entity.MakeActiveTarget();
              closestTargetedNeut.Entity.Orbit(500);
            }

            ActivateModules(myMe, myEve, engageRules);
              }
              else
              {
            var closestNeutNotTargetted = EntityHelper.FindClosestEntity(entities);

            if (closestNeutNotTargetted != null)
            {
              ActivateModules(myMe, myEve, engageRules);

              if (engageRules.GoBrawl ?? DefaultGoBrawl)
              {
            closestNeutNotTargetted.Entity.Approach();
            myEve.Execute(ExecuteCommand.CmdAccelerate);
              }
            }
              }
        }