public Ammo Clone() { var ammo = new Ammo(); ammo.TypeId = TypeId; ammo.DamageType = DamageType; ammo.Range = Range; ammo.Quantity = Quantity; return ammo; }
public void LoadSettings() { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var settingsPath = Path.Combine(path, Cache.Instance.FilterPath(_characterName) + ".xml"); var reloadSettings = _characterName != Cache.Instance.DirectEve.Me.Name; if (File.Exists(settingsPath)) { reloadSettings = _lastModifiedDate != File.GetLastWriteTime(settingsPath); } if (!reloadSettings) { return; } _characterName = Cache.Instance.DirectEve.Me.Name; _lastModifiedDate = File.GetLastWriteTime(settingsPath); if (!File.Exists(settingsPath)) { // Clear settings AgentName = string.Empty; AutoStart = false; RandomDelay = 0; WindowXPosition = null; WindowYPosition = null; LootHangar = string.Empty; AmmoHangar = string.Empty; MissionsPath = Path.Combine(path, "Missions"); MaximumHighValueTargets = 0; MaximumLowValueTargets = 0; Ammo.Clear(); MinimumAmmoCharges = 0; WeaponGroupId = 0; ReserveCargoCapacity = 0; MaximumWreckTargets = 0; SpeedTank = false; OrbitDistance = 0; ActivateRepairModules = 0; DeactivateRepairModules = 0; MinimumShieldPct = 0; MinimumArmorPct = 0; MinimumCapacitorPct = 0; SafeShieldPct = 0; SafeArmorPct = 0; SafeCapacitorPct = 0; UseDrones = false; DroneTypeId = 0; DroneControlRange = 0; DroneMinimumShieldPct = 0; DroneMinimumArmorPct = 0; DroneMinimumCapacitorPct = 0; DroneRecallCapacitorPct = 0; LongRangeDroneRecallCapacitorPct = 0; Blacklist.Clear(); return; } var xml = XDocument.Load(settingsPath).Root; DebugStates = (bool?)xml.Element("debugStates") ?? false; DebugPerformance = (bool?)xml.Element("debugPerformance") ?? false; AutoStart = (bool?)xml.Element("autoStart") ?? false; RandomDelay = (int?)xml.Element("randomDelay") ?? 0; EnableStorylines = (bool?)xml.Element("enableStorylines") ?? false; WindowXPosition = (int?)xml.Element("windowXPosition"); WindowYPosition = (int?)xml.Element("windowYPosition"); CombatShipName = (string)xml.Element("combatShipName"); SalvageShipName = (string)xml.Element("salvageShipName"); LootHangar = (string)xml.Element("lootHangar"); AmmoHangar = (string)xml.Element("ammoHangar"); CreateSalvageBookmarks = (bool?)xml.Element("createSalvageBookmarks") ?? false; BookmarkPrefix = (string)xml.Element("bookmarkPrefix") ?? "Salvage:"; MinimumWreckCount = (int?)xml.Element("minimumWreckCount") ?? 1; AfterMissionSalvaging = (bool?)xml.Element("afterMissionSalvaging") ?? false; UnloadLootAtStation = (bool?)xml.Element("unloadLootAtStation") ?? false; AgentName = (string)xml.Element("agentName"); var missionsPath = (string)xml.Element("missionsPath"); MissionsPath = !string.IsNullOrEmpty(missionsPath) ? Path.Combine(path, missionsPath) : Path.Combine(path, "Missions"); MaximumHighValueTargets = (int?)xml.Element("maximumHighValueTargets") ?? 2; MaximumLowValueTargets = (int?)xml.Element("maximumLowValueTargets") ?? 2; Ammo.Clear(); var ammoTypes = xml.Element("ammoTypes"); if (ammoTypes != null) { foreach (var ammo in ammoTypes.Elements("ammoType")) { Ammo.Add(new Ammo(ammo)); } } MinimumAmmoCharges = (int?)xml.Element("minimumAmmoCharges") ?? 0; WeaponGroupId = (int?)xml.Element("weaponGroupId") ?? 0; ReserveCargoCapacity = (int?)xml.Element("reserveCargoCapacity") ?? 0; MaximumWreckTargets = (int?)xml.Element("maximumWreckTargets") ?? 0; SpeedTank = (bool?)xml.Element("speedTank") ?? false; OrbitDistance = (int?)xml.Element("orbitDistance") ?? 0; ActivateRepairModules = (int?)xml.Element("activateRepairModules") ?? 65; DeactivateRepairModules = (int?)xml.Element("deactivateRepairModules") ?? 95; MinimumShieldPct = (int?)xml.Element("minimumShieldPct") ?? 100; MinimumArmorPct = (int?)xml.Element("minimumArmorPct") ?? 100; MinimumCapacitorPct = (int?)xml.Element("minimumCapacitorPct") ?? 50; SafeShieldPct = (int?)xml.Element("safeShieldPct") ?? 0; SafeArmorPct = (int?)xml.Element("safeArmorPct") ?? 0; SafeCapacitorPct = (int?)xml.Element("safeCapacitorPct") ?? 0; LootEverything = (bool?)xml.Element("lootEverything") ?? true; UseDrones = (bool?)xml.Element("useDrones") ?? true; DroneTypeId = (int?)xml.Element("droneTypeId") ?? 0; DroneControlRange = (int?)xml.Element("droneControlRange") ?? 0; DroneMinimumShieldPct = (int?)xml.Element("droneMinimumShieldPct") ?? 50; DroneMinimumArmorPct = (int?)xml.Element("droneMinimumArmorPct") ?? 50; DroneMinimumCapacitorPct = (int?)xml.Element("droneMinimumCapacitorPct") ?? 0; DroneRecallShieldPct = (int?)xml.Element("droneRecallShieldPct") ?? 0; DroneRecallArmorPct = (int?)xml.Element("droneRecallArmorPct") ?? 0; DroneRecallCapacitorPct = (int?)xml.Element("droneRecallCapacitorPct") ?? 0; LongRangeDroneRecallShieldPct = (int?)xml.Element("longRangeDroneRecallShieldPct") ?? 0; LongRangeDroneRecallArmorPct = (int?)xml.Element("longRangeDroneRecallArmorPct") ?? 0; LongRangeDroneRecallCapacitorPct = (int?)xml.Element("longRangeDroneRecallCapacitorPct") ?? 0; Blacklist.Clear(); var blacklist = xml.Element("blacklist"); if (blacklist != null) { foreach (var mission in blacklist.Elements("mission")) { Blacklist.Add((string)mission); } } if (SettingsLoaded != null) { SettingsLoaded(this, new EventArgs()); } }
public void LoadSettings() { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var settingsPath = Path.Combine(path, Cache.Instance.FilterPath(_characterName) + ".xml"); var reloadSettings = _characterName != Cache.Instance.DirectEve.Me.Name; if (File.Exists(settingsPath)) { reloadSettings = _lastModifiedDate != File.GetLastWriteTime(settingsPath); } if (!reloadSettings) { return; } _characterName = Cache.Instance.DirectEve.Me.Name; _lastModifiedDate = File.GetLastWriteTime(settingsPath); if (!File.Exists(settingsPath)) { // Clear settings AgentName = string.Empty; AutoStart = false; waitDecline = false; SaveLog = false; maxLineConsole = 1000; Disable3D = false; RandomDelay = 0; minStandings = 10; MinimumDelay = 0; MinimumDelay = 0; minStandings = 10; WindowXPosition = null; WindowYPosition = null; LootHangar = string.Empty; AmmoHangar = string.Empty; MissionsPath = Path.Combine(path, "Missions"); bookmarkWarpOut = string.Empty; MaximumHighValueTargets = 0; MaximumLowValueTargets = 0; Ammo.Clear(); FactionFitting.Clear(); MissionFitting.Clear(); MinimumAmmoCharges = 0; WeaponGroupId = 0; ReserveCargoCapacity = 0; MaximumWreckTargets = 0; SpeedTank = false; OrbitDistance = 0; NosDistance = 38000; MinimumPropulsionModuleDistance = 0; MinimumPropulsionModuleCapacitor = 0; ActivateRepairModules = 0; DeactivateRepairModules = 0; MinimumShieldPct = 0; MinimumArmorPct = 0; MinimumCapacitorPct = 0; SafeShieldPct = 0; SafeArmorPct = 0; SafeCapacitorPct = 0; UseDrones = false; DroneTypeId = 0; DroneControlRange = 0; DroneMinimumShieldPct = 0; DroneMinimumArmorPct = 0; DroneMinimumCapacitorPct = 0; DroneRecallCapacitorPct = 0; LongRangeDroneRecallCapacitorPct = 0; UseGatesInSalvage = false; Blacklist.Clear(); FactionBlacklist.Clear(); return; } var xml = XDocument.Load(settingsPath).Root; DebugStates = (bool?)xml.Element("debugStates") ?? false; DebugPerformance = (bool?)xml.Element("debugPerformance") ?? false; AutoStart = (bool?)xml.Element("autoStart") ?? false; waitDecline = (bool?)xml.Element("waitDecline") ?? false; SaveLog = (bool?)xml.Element("saveLog") ?? false; maxLineConsole = (int?)xml.Element("maxLineConsole") ?? 1000; Disable3D = (bool?)xml.Element("disable3D") ?? false; RandomDelay = (int?)xml.Element("randomDelay") ?? 0; MinimumDelay = (int?)xml.Element("minimumDelay") ?? 0; minStandings = (float?)xml.Element("minStandings") ?? 10; UseGatesInSalvage = (bool?)xml.Element("useGatesInSalvage") ?? false; BattleshipInvasionLimit = (int?)xml.Element("battleshipInvasionLimit") ?? 0; BattlecruiserInvasionLimit = (int?)xml.Element("battlecruiserInvasionLimit") ?? 0; CruiserInvasionLimit = (int?)xml.Element("cruiserInvasionLimit") ?? 0; FrigateInvasionLimit = (int?)xml.Element("frigateInvasionLimit") ?? 0; InvasionRandomDelay = (int?)xml.Element("invasionRandomDelay") ?? 0; InvasionMinimumDelay = (int?)xml.Element("invasionMinimumDelay") ?? 0; EnableStorylines = (bool?)xml.Element("enableStorylines") ?? false; WindowXPosition = (int?)xml.Element("windowXPosition"); WindowYPosition = (int?)xml.Element("windowYPosition"); CombatShipName = (string)xml.Element("combatShipName"); SalvageShipName = (string)xml.Element("salvageShipName"); LootHangar = (string)xml.Element("lootHangar"); AmmoHangar = (string)xml.Element("ammoHangar"); CreateSalvageBookmarks = (bool?)xml.Element("createSalvageBookmarks") ?? false; BookmarkPrefix = (string)xml.Element("bookmarkPrefix") ?? "Salvage:"; MinimumWreckCount = (int?)xml.Element("minimumWreckCount") ?? 1; AfterMissionSalvaging = (bool?)xml.Element("afterMissionSalvaging") ?? false; UnloadLootAtStation = (bool?)xml.Element("unloadLootAtStation") ?? false; AgentName = (string)xml.Element("agentName"); bookmarkWarpOut = (string)xml.Element("bookmarkWarpOut"); var missionsPath = (string)xml.Element("missionsPath"); MissionsPath = !string.IsNullOrEmpty(missionsPath) ? Path.Combine(path, missionsPath) : Path.Combine(path, "Missions"); MaximumHighValueTargets = (int?)xml.Element("maximumHighValueTargets") ?? 2; MaximumLowValueTargets = (int?)xml.Element("maximumLowValueTargets") ?? 2; Ammo.Clear(); var ammoTypes = xml.Element("ammoTypes"); if (ammoTypes != null) { foreach (var ammo in ammoTypes.Elements("ammoType")) { Ammo.Add(new Ammo(ammo)); } } MinimumAmmoCharges = (int?)xml.Element("minimumAmmoCharges") ?? 0; FactionFitting.Clear(); var factionFittings = xml.Element("factionfittings"); if (factionFittings != null) { foreach (var factionfitting in factionFittings.Elements("factionfitting")) { FactionFitting.Add(new FactionFitting(factionfitting)); } if (FactionFitting.Exists(m => m.Faction.ToLower() == "default")) { DefaultFitting = FactionFitting.Find(m => m.Faction.ToLower() == "default"); if (!(DefaultFitting.Fitting == "") && !(DefaultFitting.Fitting == null)) { FittingsDefined = true; } else { Logging.Log("Settings: Error! No default fitting specified or fitting is incorrect. Fitting manager will not be used."); } } else { Logging.Log("Settings: Error! No default fitting specified or fitting is incorrect. Fitting manager will not be used."); } } else { Logging.Log("Settings: No faction fittings specified. Fitting manager will not be used."); } MissionFitting.Clear(); var missionFittings = xml.Element("missionfittings"); if (missionFittings != null) { foreach (var missionfitting in missionFittings.Elements("missionfitting")) { MissionFitting.Add(new MissionFitting(missionfitting)); } } WeaponGroupId = (int?)xml.Element("weaponGroupId") ?? 0; ReserveCargoCapacity = (int?)xml.Element("reserveCargoCapacity") ?? 0; MaximumWreckTargets = (int?)xml.Element("maximumWreckTargets") ?? 0; SpeedTank = (bool?)xml.Element("speedTank") ?? false; OrbitDistance = (int?)xml.Element("orbitDistance") ?? 0; NosDistance = (int?)xml.Element("NosDistance") ?? 38000; MinimumPropulsionModuleDistance = (int?)xml.Element("minimumPropulsionModuleDistance") ?? 5000; MinimumPropulsionModuleCapacitor = (int?)xml.Element("minimumPropulsionModuleCapacitor") ?? 0; ActivateRepairModules = (int?)xml.Element("activateRepairModules") ?? 65; DeactivateRepairModules = (int?)xml.Element("deactivateRepairModules") ?? 95; MinimumShieldPct = (int?)xml.Element("minimumShieldPct") ?? 100; MinimumArmorPct = (int?)xml.Element("minimumArmorPct") ?? 100; MinimumCapacitorPct = (int?)xml.Element("minimumCapacitorPct") ?? 50; SafeShieldPct = (int?)xml.Element("safeShieldPct") ?? 0; SafeArmorPct = (int?)xml.Element("safeArmorPct") ?? 0; SafeCapacitorPct = (int?)xml.Element("safeCapacitorPct") ?? 0; LootEverything = (bool?)xml.Element("lootEverything") ?? true; UseDrones = (bool?)xml.Element("useDrones") ?? true; DroneTypeId = (int?)xml.Element("droneTypeId") ?? 0; DroneControlRange = (int?)xml.Element("droneControlRange") ?? 0; DroneMinimumShieldPct = (int?)xml.Element("droneMinimumShieldPct") ?? 50; DroneMinimumArmorPct = (int?)xml.Element("droneMinimumArmorPct") ?? 50; DroneMinimumCapacitorPct = (int?)xml.Element("droneMinimumCapacitorPct") ?? 0; DroneRecallShieldPct = (int?)xml.Element("droneRecallShieldPct") ?? 0; DroneRecallArmorPct = (int?)xml.Element("droneRecallArmorPct") ?? 0; DroneRecallCapacitorPct = (int?)xml.Element("droneRecallCapacitorPct") ?? 0; LongRangeDroneRecallShieldPct = (int?)xml.Element("longRangeDroneRecallShieldPct") ?? 0; LongRangeDroneRecallArmorPct = (int?)xml.Element("longRangeDroneRecallArmorPct") ?? 0; LongRangeDroneRecallCapacitorPct = (int?)xml.Element("longRangeDroneRecallCapacitorPct") ?? 0; Blacklist.Clear(); var blacklist = xml.Element("blacklist"); if (blacklist != null) { foreach (var mission in blacklist.Elements("mission")) { Blacklist.Add((string)mission); } } FactionBlacklist.Clear(); var factionblacklist = xml.Element("factionblacklist"); if (factionblacklist != null) { foreach (var faction in factionblacklist.Elements("faction")) { FactionBlacklist.Add((string)faction); } } if (SettingsLoaded != null) { SettingsLoaded(this, new EventArgs()); } }
public void LoadSettings() { var repairstopwatch = new Stopwatch(); Settings.Instance.characterName = Cache.Instance.DirectEve.Me.Name; Settings.Instance.settingsPath = Path.Combine(Settings.Instance.path, Cache.Instance.FilterPath(Settings.Instance.characterName) + ".xml"); var reloadSettings = Settings.Instance.characterName != Cache.Instance.DirectEve.Me.Name; if (File.Exists(Settings.Instance.settingsPath)) { reloadSettings = _lastModifiedDate != File.GetLastWriteTime(Settings.Instance.settingsPath); } if (!reloadSettings) { return; } _lastModifiedDate = File.GetLastWriteTime(settingsPath); if (!File.Exists(Settings.Instance.settingsPath)) //if the settings file does not exist initialize these values. Should we not halt when missing the settings XML? { // Clear settings //AgentName = string.Empty; CharacterMode = "dps"; AutoStart = false; SaveConsoleLog = true; maxLineConsole = 1000; waitDecline = false; Disable3D = false; RandomDelay = 0; minStandings = 10; MinimumDelay = 0; minStandings = 10; WindowXPosition = null; WindowYPosition = null; LootHangar = string.Empty; AmmoHangar = string.Empty; BookmarkHangar = string.Empty; LootContainer = string.Empty; MissionsPath = Path.Combine(path, "Missions"); bookmarkWarpOut = string.Empty; MaximumHighValueTargets = 0; MaximumLowValueTargets = 0; Ammo.Clear(); ItemsBlackList.Clear(); WreckBlackList.Clear(); FactionFitting.Clear(); AgentsList.Clear(); MissionFitting.Clear(); MinimumAmmoCharges = 0; WeaponGroupId = 0; ReserveCargoCapacity = 0; MaximumWreckTargets = 0; SpeedTank = false; OrbitDistance = 0; OptimalRange = 0; NosDistance = 38000; MinimumPropulsionModuleDistance = 3000; MinimumPropulsionModuleCapacitor = 35; ActivateRepairModules = 0; DeactivateRepairModules = 0; MinimumShieldPct = 0; MinimumArmorPct = 0; MinimumCapacitorPct = 0; SafeShieldPct = 0; SafeArmorPct = 0; SafeCapacitorPct = 0; UseDrones = false; DroneTypeId = 0; DroneControlRange = 0; DroneMinimumShieldPct = 0; DroneMinimumArmorPct = 0; DroneMinimumCapacitorPct = 0; DroneRecallCapacitorPct = 0; LongRangeDroneRecallCapacitorPct = 0; UseGatesInSalvage = false; Blacklist.Clear(); FactionBlacklist.Clear(); missionName = null; //missionbookmarktoagentloops = 0; return; } var xml = XDocument.Load(Settings.Instance.settingsPath).Root; // // these are listed by feature and should likely be re-ordered to reflect that // DebugStates = (bool?)xml.Element("debugStates") ?? false; //enables more console logging having to do with the sub-states within each state DebugPerformance = (bool?)xml.Element("debugPerformance") ?? false; //enabled more console logging having to do with the time it takes to execute each state CharacterMode = (string)xml.Element("characterMode") ?? "dps"; //other option is "salvage" AutoStart = (bool?)xml.Element("autoStart") ?? false; // auto Start enabled or disabled by default? SaveConsoleLog = (bool?)xml.Element("saveLog") ?? true; // save the console log to file maxLineConsole = (int?)xml.Element("maxLineConsole") ?? 1000; // maximum console log lines to show in the GUI Disable3D = (bool?)xml.Element("disable3D") ?? false; // Disable3d graphics while in space RandomDelay = (int?)xml.Element("randomDelay") ?? 0; MinimumDelay = (int?)xml.Element("minimumDelay") ?? 0; minStandings = (float?)xml.Element("minStandings") ?? 10; waitDecline = (bool?)xml.Element("waitDecline") ?? false; UseGatesInSalvage = (bool?)xml.Element("useGatesInSalvage") ?? false; // if our mission does not despawn (likely someone in the mission looting our stuff?) use the gates when salvaging to get to our bookmarks UseLocalWatch = (bool?)xml.Element("UseLocalWatch") ?? true; LocalBadStandingPilotsToTolerate = (int?)xml.Element("LocalBadStandingPilotsToTolerate") ?? 1; LocalBadStandingLevelToConsiderBad = (double?)xml.Element("LocalBadStandingLevelToConsiderBad") ?? -0.1; BattleshipInvasionLimit = (int?)xml.Element("battleshipInvasionLimit") ?? 0; // if this number of battleships lands on grid while in a mission we will enter panic BattlecruiserInvasionLimit = (int?)xml.Element("battlecruiserInvasionLimit") ?? 0; // if this number of battlecruisers lands on grid while in a mission we will enter panic CruiserInvasionLimit = (int?)xml.Element("cruiserInvasionLimit") ?? 0; // if this number of cruisers lands on grid while in a mission we will enter panic FrigateInvasionLimit = (int?)xml.Element("frigateInvasionLimit") ?? 0; // if this number of frigates lands on grid while in a mission we will enter panic InvasionRandomDelay = (int?)xml.Element("invasionRandomDelay") ?? 0; // random relay to stay docked InvasionMinimumDelay = (int?)xml.Element("invasionMinimumDelay") ?? 0; // minimum delay to stay docked EnableStorylines = (bool?)xml.Element("enableStorylines") ?? false; IskPerLP = (double?)xml.Element("IskPerLP") ?? 600; //used in value calculations UndockDelay = (int?)xml.Element("undockdelay") ?? 10; //Delay when undocking - not in use UndockPrefix = (string)xml.Element("undockprefix") ?? "Insta"; //Undock bookmark prefix - used by traveler - not in use WindowXPosition = (int?)xml.Element("windowXPosition") ?? 1600; //windows position (needs to be changed, default is off screen) WindowYPosition = (int?)xml.Element("windowYPosition") ?? 1050; //windows position (needs to be changed, default is off screen) CombatShipName = (string)xml.Element("combatShipName") ?? ""; SalvageShipName = (string)xml.Element("salvageShipName") ?? ""; TransportShipName = (string)xml.Element("transportShipName") ?? ""; LootHangar = (string)xml.Element("lootHangar"); AmmoHangar = (string)xml.Element("ammoHangar"); BookmarkHangar = (string)xml.Element("bookmarkHangar"); LootContainer = (string)xml.Element("lootContainer"); CreateSalvageBookmarks = (bool?)xml.Element("createSalvageBookmarks") ?? false; BookmarkPrefix = (string)xml.Element("bookmarkPrefix") ?? "Salvage:"; MinimumWreckCount = (int?)xml.Element("minimumWreckCount") ?? 1; AfterMissionSalvaging = (bool?)xml.Element("afterMissionSalvaging") ?? false; SalvageMultpleMissionsinOnePass = (bool?)xml.Element("salvageMultpleMissionsinOnePass") ?? false; UnloadLootAtStation = (bool?)xml.Element("unloadLootAtStation") ?? false; //AgentName = (string) xml.Element("agentName"); bookmarkWarpOut = (string)xml.Element("bookmarkWarpOut") ?? ""; EVEProcessMemoryCeiling = (int?)xml.Element("EVEProcessMemoryCeiling") ?? 900; EVEProcessMemoryCeilingLogofforExit = (string)xml.Element("EVEProcessMemoryCeilingLogofforExit") ?? "exit"; DontShootFrigatesWithSiegeorAutoCannons = (bool?)xml.Element("DontShootFrigatesWithSiegeorAutoCannons") ?? false; //Assume InnerspaceProfile CloseQuestorCMDUplinkInnerspaceProfile = (bool?)xml.Element("CloseQuestorCMDUplinkInnerspaceProfile") ?? true; CloseQuestorCMDUplinkIsboxerCharacterSet = (bool?)xml.Element("CloseQuestorCMDUplinkIsboxerCharacterSet") ?? false; walletbalancechangelogoffdelay = (int?)xml.Element("walletbalancechangelogoffdelay") ?? 30; walletbalancechangelogoffdelayLogofforExit = (string)xml.Element("walletbalancechangelogoffdelayLogofforExit") ?? "exit"; SessionsLog = (bool?)xml.Element("SessionsLog") ?? true; DroneStatsLog = (bool?)xml.Element("DroneStatsLog") ?? true; WreckLootStatistics = (bool?)xml.Element("WreckLootStatistics") ?? true; MissionStats1Log = (bool?)xml.Element("MissionStats1Log") ?? true; MissionStats2Log = (bool?)xml.Element("MissionStats2Log") ?? true; MissionStats3Log = (bool?)xml.Element("MissionStats3Log") ?? true; PocketStatistics = (bool?)xml.Element("PocketStatistics") ?? true; PocketStatsUseIndividualFilesPerPocket = (bool?)xml.Element("PocketStatsUseIndividualFilesPerPocket") ?? true; var missionsPath = (string)xml.Element("missionsPath"); MissionsPath = !string.IsNullOrEmpty(missionsPath) ? Path.Combine(path, missionsPath) : Path.Combine(path, "Missions"); LowSecMissions = (bool?)xml.Element("LowSecMissions") ?? false; MaximumHighValueTargets = (int?)xml.Element("maximumHighValueTargets") ?? 2; MaximumLowValueTargets = (int?)xml.Element("maximumLowValueTargets") ?? 2; Ammo.Clear(); var ammoTypes = xml.Element("ammoTypes"); if (ammoTypes != null) { foreach (var ammo in ammoTypes.Elements("ammoType")) { Ammo.Add(new Ammo(ammo)); } } MinimumAmmoCharges = (int?)xml.Element("minimumAmmoCharges") ?? 0; UseFittingManager = (bool?)xml.Element("UseFittingManager") ?? true; //agent list AgentsList.Clear(); var agentList = xml.Element("agentsList"); if (agentList != null) { if (agentList.HasElements) { int i = 0; foreach (var agent in agentList.Elements("agentList")) { AgentsList.Add(new AgentsList(agent)); i++; } if (i >= 2) { MultiAgentSupport = true; Logging.Log("Settings: Found more than one agent in your character XML: MultiAgentSupport is true"); } else { MultiAgentSupport = false; Logging.Log("Settings: Found only one agent in your character XML: MultiAgentSupport is false"); } } else { Logging.Log("Settings: agentList exists in your characters config but no agents were listed."); } } else { Logging.Log("Settings: Error! No Agents List specified."); } FactionFitting.Clear(); var factionFittings = xml.Element("factionfittings"); if (UseFittingManager) { if (factionFittings != null) { foreach (var factionfitting in factionFittings.Elements("factionfitting")) { FactionFitting.Add(new FactionFitting(factionfitting)); } if (FactionFitting.Exists(m => m.Faction.ToLower() == "default")) { DefaultFitting = FactionFitting.Find(m => m.Faction.ToLower() == "default"); if ((DefaultFitting.Fitting == "") || (DefaultFitting.Fitting == null)) { UseFittingManager = false; Logging.Log("Settings: Error! No default fitting specified or fitting is incorrect. Fitting manager will not be used."); } Logging.Log("Settings: Faction Fittings defined. Fitting manager will be used when appropriate."); } else { UseFittingManager = false; Logging.Log("Settings: Error! No default fitting specified or fitting is incorrect. Fitting manager will not be used."); } } else { UseFittingManager = false; Logging.Log("Settings: No faction fittings specified. Fitting manager will not be used."); } } MissionFitting.Clear(); var missionFittings = xml.Element("missionfittings"); if (UseFittingManager) { if (missionFittings != null) { foreach (var missionfitting in missionFittings.Elements("missionfitting")) { MissionFitting.Add(new MissionFitting(missionfitting)); } } } WeaponGroupId = (int?)xml.Element("weaponGroupId") ?? 0; ReserveCargoCapacity = (int?)xml.Element("reserveCargoCapacity") ?? 0; MaximumWreckTargets = (int?)xml.Element("maximumWreckTargets") ?? 0; SpeedTank = (bool?)xml.Element("speedTank") ?? false; OrbitDistance = (int?)xml.Element("orbitDistance") ?? 0; OptimalRange = (int?)xml.Element("optimalRange") ?? 0; NosDistance = (int?)xml.Element("NosDistance") ?? 38000; MinimumPropulsionModuleDistance = (int?)xml.Element("minimumPropulsionModuleDistance") ?? 5000; MinimumPropulsionModuleCapacitor = (int?)xml.Element("minimumPropulsionModuleCapacitor") ?? 0; ActivateRepairModules = (int?)xml.Element("activateRepairModules") ?? 65; DeactivateRepairModules = (int?)xml.Element("deactivateRepairModules") ?? 95; MinimumShieldPct = (int?)xml.Element("minimumShieldPct") ?? 100; MinimumArmorPct = (int?)xml.Element("minimumArmorPct") ?? 100; MinimumCapacitorPct = (int?)xml.Element("minimumCapacitorPct") ?? 50; SafeShieldPct = (int?)xml.Element("safeShieldPct") ?? 0; SafeArmorPct = (int?)xml.Element("safeArmorPct") ?? 0; SafeCapacitorPct = (int?)xml.Element("safeCapacitorPct") ?? 0; LootEverything = (bool?)xml.Element("lootEverything") ?? true; UseDrones = (bool?)xml.Element("useDrones") ?? true; DroneTypeId = (int?)xml.Element("droneTypeId") ?? 0; DroneControlRange = (int?)xml.Element("droneControlRange") ?? 0; DroneMinimumShieldPct = (int?)xml.Element("droneMinimumShieldPct") ?? 50; DroneMinimumArmorPct = (int?)xml.Element("droneMinimumArmorPct") ?? 50; DroneMinimumCapacitorPct = (int?)xml.Element("droneMinimumCapacitorPct") ?? 0; DroneRecallShieldPct = (int?)xml.Element("droneRecallShieldPct") ?? 0; DroneRecallArmorPct = (int?)xml.Element("droneRecallArmorPct") ?? 0; DroneRecallCapacitorPct = (int?)xml.Element("droneRecallCapacitorPct") ?? 0; LongRangeDroneRecallShieldPct = (int?)xml.Element("longRangeDroneRecallShieldPct") ?? 0; LongRangeDroneRecallArmorPct = (int?)xml.Element("longRangeDroneRecallArmorPct") ?? 0; LongRangeDroneRecallCapacitorPct = (int?)xml.Element("longRangeDroneRecallCapacitorPct") ?? 0; MaterialsForWarOreID = (int?)xml.Element("MaterialsForWarOreID") ?? 20; MaterialsForWarOreQty = (int?)xml.Element("MaterialsForWarOreQty") ?? 8000; Blacklist.Clear(); var blacklist = xml.Element("blacklist"); if (blacklist != null) { foreach (var mission in blacklist.Elements("mission")) { Blacklist.Add((string)mission); } } FactionBlacklist.Clear(); var factionblacklist = xml.Element("factionblacklist"); if (factionblacklist != null) { foreach (var faction in factionblacklist.Elements("faction")) { FactionBlacklist.Add((string)faction); } } WreckBlackListSmallWrecks = (bool?)xml.Element("WreckBlackListSmallWrecks") ?? false; WreckBlackListMediumWrecks = (bool?)xml.Element("WreckBlackListMediumWrecks") ?? false; // // if enabled the following would keep you from looting (or salvaging?) small wrecks // //list of small wreck if (WreckBlackListSmallWrecks) { WreckBlackList.Add(26557); WreckBlackList.Add(26561); WreckBlackList.Add(26564); WreckBlackList.Add(26567); WreckBlackList.Add(26570); WreckBlackList.Add(26573); WreckBlackList.Add(26576); WreckBlackList.Add(26579); WreckBlackList.Add(26582); WreckBlackList.Add(26585); WreckBlackList.Add(26588); WreckBlackList.Add(26591); WreckBlackList.Add(26594); WreckBlackList.Add(26935); } // // if enabled the following would keep you from looting (or salvaging?) medium wrecks // //list of medium wreck if (WreckBlackListMediumWrecks) { WreckBlackList.Add(26558); WreckBlackList.Add(26562); WreckBlackList.Add(26568); WreckBlackList.Add(26574); WreckBlackList.Add(26580); WreckBlackList.Add(26586); WreckBlackList.Add(26592); WreckBlackList.Add(26934); } logpath = (Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\log\\" + Cache.Instance.DirectEve.Me.Name + "\\"); //logpath_s = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\log\\"; ConsoleLogPath = Path.Combine(logpath + "Console\\"); ConsoleLogFile = Path.Combine(ConsoleLogPath + string.Format("{0:MM-dd-yyyy}", DateTime.Today) + "-" + Cache.Instance.DirectEve.Me.Name + "-" + "console" + ".log"); SessionsLogPath = Path.Combine(logpath); SessionsLogFile = Path.Combine(SessionsLogPath + Cache.Instance.DirectEve.Me.Name + ".Sessions.log"); DroneStatsLogPath = Path.Combine(logpath); DroneStatslogFile = Path.Combine(DroneStatsLogPath + Cache.Instance.DirectEve.Me.Name + ".DroneStats.log"); WreckLootStatisticsPath = Path.Combine(logpath); WreckLootStatisticsFile = Path.Combine(WreckLootStatisticsPath + Cache.Instance.DirectEve.Me.Name + ".WreckLootStatisticsDump.log"); MissionStats1LogPath = Path.Combine(logpath, "missionstats\\"); MissionStats1LogFile = Path.Combine(MissionStats1LogPath + Cache.Instance.DirectEve.Me.Name + ".Statistics.log"); MissionStats2LogPath = Path.Combine(logpath, "missionstats\\"); MissionStats2LogFile = Path.Combine(MissionStats2LogPath + Cache.Instance.DirectEve.Me.Name + ".DatedStatistics.log"); MissionStats3LogPath = Path.Combine(logpath, "missionstats\\"); MissionStats3LogFile = Path.Combine(MissionStats3LogPath + Cache.Instance.DirectEve.Me.Name + ".CustomDatedStatistics.csv"); PocketStatisticsPath = Path.Combine(logpath, "pocketstats\\"); PocketStatisticsFile = Path.Combine(PocketStatisticsPath + Cache.Instance.DirectEve.Me.Name + "pocketstats-combined.csv"); //create all the logging directories even if they aren't configured to be used - we can adjust this later if it really bugs people to have some potentially empty directories. Directory.CreateDirectory(logpath); Directory.CreateDirectory(ConsoleLogPath); Directory.CreateDirectory(SessionsLogPath); Directory.CreateDirectory(DroneStatsLogPath); Directory.CreateDirectory(WreckLootStatisticsPath); Directory.CreateDirectory(MissionStats1LogPath); Directory.CreateDirectory(MissionStats2LogPath); Directory.CreateDirectory(MissionStats3LogPath); Directory.CreateDirectory(PocketStatisticsPath); if (SettingsLoaded != null) { SettingsLoaded(this, new EventArgs()); } }
public void LoadSettings() { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var settingsPath = Path.Combine(path, Cache.Instance.FilterPath(_characterName) + ".xml"); var repairstopwatch = new Stopwatch(); var reloadSettings = _characterName != Cache.Instance.DirectEve.Me.Name; if (File.Exists(settingsPath)) { reloadSettings = _lastModifiedDate != File.GetLastWriteTime(settingsPath); } if (!reloadSettings) { return; } _characterName = Cache.Instance.DirectEve.Me.Name; _lastModifiedDate = File.GetLastWriteTime(settingsPath); if (!File.Exists(settingsPath)) { // Clear settings //AgentName = string.Empty; CharacterMode = "dps"; AutoStart = false; SaveConsoleLog = true; maxLineConsole = 1000; waitDecline = false; Disable3D = false; RandomDelay = 0; minStandings = 10; MinimumDelay = 0; minStandings = 10; WindowXPosition = null; WindowYPosition = null; LootHangar = string.Empty; AmmoHangar = string.Empty; BookmarkHangar = string.Empty; LootContainer = string.Empty; MissionsPath = Path.Combine(path, "Missions"); bookmarkWarpOut = string.Empty; MaximumHighValueTargets = 0; MaximumLowValueTargets = 0; Ammo.Clear(); ItemsBlackList.Clear(); WreckBlackList.Clear(); FactionFitting.Clear(); AgentsList.Clear(); MissionFitting.Clear(); MinimumAmmoCharges = 0; WeaponGroupId = 0; ReserveCargoCapacity = 0; MaximumWreckTargets = 0; SpeedTank = false; OrbitDistance = 0; OptimalRange = 0; NosDistance = 38000; MinimumPropulsionModuleDistance = 3000; MinimumPropulsionModuleCapacitor = 35; ActivateRepairModules = 0; DeactivateRepairModules = 0; MinimumShieldPct = 0; MinimumArmorPct = 0; MinimumCapacitorPct = 0; SafeShieldPct = 0; SafeArmorPct = 0; SafeCapacitorPct = 0; UseDrones = false; DroneTypeId = 0; DroneControlRange = 0; DroneMinimumShieldPct = 0; DroneMinimumArmorPct = 0; DroneMinimumCapacitorPct = 0; DroneRecallCapacitorPct = 0; LongRangeDroneRecallCapacitorPct = 0; UseGatesInSalvage = false; Blacklist.Clear(); FactionBlacklist.Clear(); missionName = null; //missionbookmarktoagentloops = 0; return; } var xml = XDocument.Load(settingsPath).Root; DebugStates = (bool?)xml.Element("debugStates") ?? false; DebugPerformance = (bool?)xml.Element("debugPerformance") ?? false; CharacterMode = (string)xml.Element("characterMode") ?? "dps"; //other option is "salvage" AutoStart = (bool?)xml.Element("autoStart") ?? false; SaveConsoleLog = (bool?)xml.Element("saveLog") ?? true; maxLineConsole = (int?)xml.Element("maxLineConsole") ?? 1000; waitDecline = (bool?)xml.Element("waitDecline") ?? false; Disable3D = (bool?)xml.Element("disable3D") ?? true; RandomDelay = (int?)xml.Element("randomDelay") ?? 0; MinimumDelay = (int?)xml.Element("minimumDelay") ?? 0; minStandings = (float?)xml.Element("minStandings") ?? 10; UseGatesInSalvage = (bool?)xml.Element("useGatesInSalvage") ?? false; UseLocalWatch = (bool?)xml.Element("UseLocalWatch") ?? true; LocalBadStandingPilotsToTolerate = (int?)xml.Element("LocalBadStandingPilotsToTolerate") ?? 1; LocalBadStandingLevelToConsiderBad = (double?)xml.Element("LocalBadStandingLevelToConsiderBad") ?? -0.1; BattleshipInvasionLimit = (int?)xml.Element("battleshipInvasionLimit") ?? 0; BattlecruiserInvasionLimit = (int?)xml.Element("battlecruiserInvasionLimit") ?? 0; CruiserInvasionLimit = (int?)xml.Element("cruiserInvasionLimit") ?? 0; FrigateInvasionLimit = (int?)xml.Element("frigateInvasionLimit") ?? 0; InvasionRandomDelay = (int?)xml.Element("invasionRandomDelay") ?? 0; InvasionMinimumDelay = (int?)xml.Element("invasionMinimumDelay") ?? 0; EnableStorylines = (bool?)xml.Element("enableStorylines") ?? false; IskPerLP = (double?)xml.Element("IskPerLP") ?? 600; UndockDelay = (int?)xml.Element("undockdelay") ?? 10; UndockPrefix = (string)xml.Element("undockprefix") ?? "Insta"; WindowXPosition = (int?)xml.Element("windowXPosition") ?? 1600; WindowYPosition = (int?)xml.Element("windowYPosition") ?? 1050; CombatShipName = (string)xml.Element("combatShipName") ?? ""; SalvageShipName = (string)xml.Element("salvageShipName") ?? ""; TransportShipName = (string)xml.Element("transportShipName") ?? ""; MaterialShipName = (string)xml.Element("materialShipName") ?? ""; LootHangar = (string)xml.Element("lootHangar"); AmmoHangar = (string)xml.Element("ammoHangar"); BookmarkHangar = (string)xml.Element("bookmarkHangar"); LootContainer = (string)xml.Element("lootContainer"); CreateSalvageBookmarks = (bool?)xml.Element("createSalvageBookmarks") ?? false; CreateSalvageBookmarksIn = (string)xml.Element("createSalvageBookmarksIn") ?? "Player"; BookmarkPrefix = (string)xml.Element("bookmarkPrefix") ?? "Salvage:"; MinimumWreckCount = (int?)xml.Element("minimumWreckCount") ?? 1; AfterMissionSalvaging = (bool?)xml.Element("afterMissionSalvaging") ?? false; SalvageMultpleMissionsinOnePass = (bool?)xml.Element("salvageMultpleMissionsinOnePass") ?? false; UnloadLootAtStation = (bool?)xml.Element("unloadLootAtStation") ?? false; //AgentName = (string) xml.Element("agentName"); bookmarkWarpOut = (string)xml.Element("bookmarkWarpOut") ?? "insta"; EVEProcessMemoryCeiling = (int?)xml.Element("EVEProcessMemoryCeiling") ?? 900; EVEProcessMemoryCeilingLogofforExit = (string)xml.Element("EVEProcessMemoryCeilingLogofforExit") ?? "exit"; DontShootFrigatesWithSiegeorAutoCannons = (bool?)xml.Element("DontShootFrigatesWithSiegeorAutoCannons") ?? false; //Assume InnerspaceProfile CloseQuestorCMDUplinkInnerspaceProfile = (bool?)xml.Element("CloseQuestorCMDUplinkInnerspaceProfile") ?? true; CloseQuestorCMDUplinkIsboxerCharacterSet = (bool?)xml.Element("CloseQuestorCMDUplinkIsboxerCharacterSet") ?? false; walletbalancechangelogoffdelay = (int?)xml.Element("walletbalancechangelogoffdelay") ?? 30; walletbalancechangelogoffdelayLogofforExit = (string)xml.Element("walletbalancechangelogoffdelayLogofforExit") ?? "exit"; SessionsLog = (bool?)xml.Element("SessionsLog") ?? true; DroneStatsLog = (bool?)xml.Element("DroneStatsLog") ?? true; WreckLootStatistics = (bool?)xml.Element("WreckLootStatistics") ?? true; MissionStats1Log = (bool?)xml.Element("MissionStats1Log") ?? true; MissionStats2Log = (bool?)xml.Element("MissionStats2Log") ?? true; MissionStats3Log = (bool?)xml.Element("MissionStats3Log") ?? true; PocketStatistics = (bool?)xml.Element("PocketStatistics") ?? true; var missionsPath = (string)xml.Element("missionsPath"); MissionsPath = !string.IsNullOrEmpty(missionsPath) ? Path.Combine(path, missionsPath) : Path.Combine(path, "Missions"); LowSecMissions = (bool?)xml.Element("LowSecMissions") ?? false; MaximumHighValueTargets = (int?)xml.Element("maximumHighValueTargets") ?? 2; MaximumLowValueTargets = (int?)xml.Element("maximumLowValueTargets") ?? 2; Ammo.Clear(); var ammoTypes = xml.Element("ammoTypes"); if (ammoTypes != null) { foreach (var ammo in ammoTypes.Elements("ammoType")) { Ammo.Add(new Ammo(ammo)); } } MinimumAmmoCharges = (int?)xml.Element("minimumAmmoCharges") ?? 0; UseFittingManager = (bool?)xml.Element("UseFittingManager") ?? true; //agent list AgentsList.Clear(); var agentList = xml.Element("agentsList"); if (agentList != null) { int i = 0; foreach (var agent in agentList.Elements("agentList")) { AgentsList.Add(new AgentsList(agent)); i++; } if (i >= 2) { MultiAgentSupport = true; } else { MultiAgentSupport = false; } } else { Logging.Log("Settings: Error! No Agents List specified."); } FactionFitting.Clear(); var factionFittings = xml.Element("factionfittings"); if (UseFittingManager) { if (factionFittings != null) { foreach (var factionfitting in factionFittings.Elements("factionfitting")) { FactionFitting.Add(new FactionFitting(factionfitting)); } if (FactionFitting.Exists(m => m.Faction.ToLower() == "default")) { DefaultFitting = FactionFitting.Find(m => m.Faction.ToLower() == "default"); if ((DefaultFitting.Fitting == "") || (DefaultFitting.Fitting == null)) { UseFittingManager = false; Logging.Log("Settings: Error! No default fitting specified or fitting is incorrect. Fitting manager will not be used."); } Logging.Log("Settings: Faction Fittings defined. Fitting manager will be used when appropriate."); } else { UseFittingManager = false; Logging.Log("Settings: Error! No default fitting specified or fitting is incorrect. Fitting manager will not be used."); } } else { UseFittingManager = false; Logging.Log("Settings: No faction fittings specified. Fitting manager will not be used."); } } MissionFitting.Clear(); var missionFittings = xml.Element("missionfittings"); if (UseFittingManager) { if (missionFittings != null) { foreach (var missionfitting in missionFittings.Elements("missionfitting")) { MissionFitting.Add(new MissionFitting(missionfitting)); } } } WeaponGroupId = (int?)xml.Element("weaponGroupId") ?? 0; ReserveCargoCapacity = (int?)xml.Element("reserveCargoCapacity") ?? 0; MaximumWreckTargets = (int?)xml.Element("maximumWreckTargets") ?? 0; SpeedTank = (bool?)xml.Element("speedTank") ?? false; OrbitDistance = (int?)xml.Element("orbitDistance") ?? 0; OptimalRange = (int?)xml.Element("optimalRange") ?? 0; NosDistance = (int?)xml.Element("NosDistance") ?? 38000; MinimumPropulsionModuleDistance = (int?)xml.Element("minimumPropulsionModuleDistance") ?? 5000; MinimumPropulsionModuleCapacitor = (int?)xml.Element("minimumPropulsionModuleCapacitor") ?? 0; ActivateRepairModules = (int?)xml.Element("activateRepairModules") ?? 65; DeactivateRepairModules = (int?)xml.Element("deactivateRepairModules") ?? 95; MinimumShieldPct = (int?)xml.Element("minimumShieldPct") ?? 100; MinimumArmorPct = (int?)xml.Element("minimumArmorPct") ?? 100; MinimumCapacitorPct = (int?)xml.Element("minimumCapacitorPct") ?? 50; SafeShieldPct = (int?)xml.Element("safeShieldPct") ?? 0; SafeArmorPct = (int?)xml.Element("safeArmorPct") ?? 0; SafeCapacitorPct = (int?)xml.Element("safeCapacitorPct") ?? 0; LootEverything = (bool?)xml.Element("lootEverything") ?? true; UseDrones = (bool?)xml.Element("useDrones") ?? true; DroneTypeId = (int?)xml.Element("droneTypeId") ?? 0; DroneControlRange = (int?)xml.Element("droneControlRange") ?? 0; DroneMinimumShieldPct = (int?)xml.Element("droneMinimumShieldPct") ?? 50; DroneMinimumArmorPct = (int?)xml.Element("droneMinimumArmorPct") ?? 50; DroneMinimumCapacitorPct = (int?)xml.Element("droneMinimumCapacitorPct") ?? 0; DroneRecallShieldPct = (int?)xml.Element("droneRecallShieldPct") ?? 0; DroneRecallArmorPct = (int?)xml.Element("droneRecallArmorPct") ?? 0; DroneRecallCapacitorPct = (int?)xml.Element("droneRecallCapacitorPct") ?? 0; LongRangeDroneRecallShieldPct = (int?)xml.Element("longRangeDroneRecallShieldPct") ?? 0; LongRangeDroneRecallArmorPct = (int?)xml.Element("longRangeDroneRecallArmorPct") ?? 0; LongRangeDroneRecallCapacitorPct = (int?)xml.Element("longRangeDroneRecallCapacitorPct") ?? 0; MaterialsForWarOreID = (int?)xml.Element("MaterialsForWarOreID") ?? 20; MaterialsForWarOreQty = (int?)xml.Element("MaterialsForWarOreQty") ?? 8000; Blacklist.Clear(); var blacklist = xml.Element("blacklist"); if (blacklist != null) { foreach (var mission in blacklist.Elements("mission")) { Blacklist.Add((string)mission); } } FactionBlacklist.Clear(); var factionblacklist = xml.Element("factionblacklist"); if (factionblacklist != null) { foreach (var faction in factionblacklist.Elements("faction")) { FactionBlacklist.Add((string)faction); } } WreckBlackListSmallWrecks = (bool?)xml.Element("WreckBlackListSmallWrecks") ?? false; WreckBlackListMediumWrecks = (bool?)xml.Element("WreckBlackListMediumWrecks") ?? false; // // if enabled the following would keep you from looting (or salvaging?) small wrecks // //list of small wreck if (WreckBlackListSmallWrecks) { WreckBlackList.Add(26557); WreckBlackList.Add(26561); WreckBlackList.Add(26564); WreckBlackList.Add(26567); WreckBlackList.Add(26570); WreckBlackList.Add(26573); WreckBlackList.Add(26576); WreckBlackList.Add(26579); WreckBlackList.Add(26582); WreckBlackList.Add(26585); WreckBlackList.Add(26588); WreckBlackList.Add(26591); WreckBlackList.Add(26594); WreckBlackList.Add(26935); } // // if enabled the following would keep you from looting (or salvaging?) medium wrecks // //list of medium wreck if (WreckBlackListMediumWrecks) { WreckBlackList.Add(26558); WreckBlackList.Add(26562); WreckBlackList.Add(26568); WreckBlackList.Add(26574); WreckBlackList.Add(26580); WreckBlackList.Add(26586); WreckBlackList.Add(26592); WreckBlackList.Add(26934); } logpath = (Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\log\\" + Cache.Instance.DirectEve.Me.Name + "\\"); logpath_s = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\log\\"; ConsoleLogPath = Path.Combine(logpath, "Console\\"); ConsoleLogFile = (ConsoleLogPath + string.Format("{0:MM-dd-yyyy}", DateTime.Today) + "-" + Cache.Instance.DirectEve.Me.Name + "-" + "console" + ".log"); SessionsLogPath = logpath_s; SessionsLogFile = (SessionsLogPath + Cache.Instance.DirectEve.Me.Name + ".Sessions.log"); DroneStatsLogPath = logpath; DroneStatslogFile = (DroneStatsLogPath + Cache.Instance.DirectEve.Me.Name + ".DroneStats.log"); WreckLootStatisticsPath = logpath; WreckLootStatisticsFile = (logpath + Cache.Instance.DirectEve.Me.Name + ".WreckLootStatisticsDump.log"); MissionStats1LogPath = logpath_s; MissionStats1LogFile = (MissionStats1LogPath + Cache.Instance.DirectEve.Me.Name + ".Statistics.log"); MissionStats2LogPath = logpath_s; MissionStats2LogFile = (MissionStats2LogPath + Cache.Instance.DirectEve.Me.Name + ".DatedStatistics.log"); MissionStats3LogPath = logpath_s; MissionStats3LogFile = (MissionStats3LogPath + Cache.Instance.DirectEve.Me.Name + ".CustomDatedStatistics.log"); PocketStatisticsPath = Path.Combine(logpath, "pocketstats\\"); PocketStatisticsFile = Path.Combine(PocketStatisticsPath, "pocketstats - generic"); if (SettingsLoaded != null) { SettingsLoaded(this, new EventArgs()); } }
/// <summary> /// Loot any wrecks & cargo containers close by /// </summary> private void LootWrecks() { var cargo = Cache.Instance.DirectEve.GetShipsCargo(); if (cargo.Window == null) { // No, command it to open Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.OpenCargoHoldOfActiveShip); return; } // Ship's cargo is not ready yet if (!cargo.IsReady) { return; } var shipsCargo = cargo.Items.Select(i => new ItemCache(i)).ToList(); var freeCargoCapacity = cargo.Capacity - cargo.UsedCapacity; var lootWindows = Cache.Instance.DirectEve.Windows.OfType <DirectContainerWindow>().Where(w => !string.IsNullOrEmpty(w.Name) && w.Name.StartsWith("loot_")); foreach (var window in lootWindows) { // The window is not ready, then continue if (!window.IsReady) { continue; } // Get the container var containerEntity = Cache.Instance.EntityById(window.ItemId); // Does it no longer exist or is it out of transfer range or its looted if (containerEntity == null || containerEntity.Distance > 2500 || Cache.Instance.LootedContainers.Contains(containerEntity.Id)) { Logging.Log("Salvage: Closing loot window [" + window.ItemId + "]"); window.Close(); continue; } // Get the container that is associated with the cargo container var container = Cache.Instance.DirectEve.GetContainer(window.ItemId); // List its items var items = container.Items.Select(i => new ItemCache(i)); // Build a list of items to loot var lootItems = new List <ItemCache>(); // Walk through the list of items ordered by highest value item first foreach (var item in items.OrderByDescending(i => i.IskPerM3)) { // We pick up loot depending on isk per m3 var isMissionItem = Cache.Instance.MissionItems.Contains((item.Name ?? string.Empty).ToLower()); // Never pick up contraband (unless its the mission item) if (!isMissionItem && item.IsContraband) { continue; } // Do we want to loot other items? if (!isMissionItem && !LootEverything) { continue; } // We are at our max, either make room or skip the item if ((freeCargoCapacity - item.TotalVolume) <= (isMissionItem ? 0 : ReserveCargoCapacity)) { // We can't drop items in this container anyway, well get it after its salvaged if (!isMissionItem && containerEntity.GroupId != (int)Group.CargoContainer) { continue; } // Make a list of items which are worth less List <ItemCache> worthLess; if (isMissionItem) { worthLess = shipsCargo; } else if (item.IskPerM3.HasValue) { worthLess = shipsCargo.Where(sc => sc.IskPerM3.HasValue && sc.IskPerM3 < item.IskPerM3).ToList(); } else { worthLess = shipsCargo.Where(sc => sc.IskPerM3.HasValue).ToList(); } // Remove mission item from this list worthLess.RemoveAll(wl => Cache.Instance.MissionItems.Contains((wl.Name ?? string.Empty).ToLower())); worthLess.RemoveAll(wl => (wl.Name ?? string.Empty).ToLower() == Cache.Instance.BringMissionItem); // Consider dropping ammo if it concerns the mission item! if (!isMissionItem) { worthLess.RemoveAll(wl => Ammo.Any(a => a.TypeId == wl.TypeId)); } // Nothing is worth less then the current item if (worthLess.Count() == 0) { continue; } // Not enough space even if we dumped the crap if ((freeCargoCapacity + worthLess.Sum(wl => wl.TotalVolume)) < item.TotalVolume) { if (isMissionItem) { Logging.Log("Salvage: Not enough space for mission item! Need [" + item.TotalVolume + "] maximum available [" + (freeCargoCapacity + worthLess.Sum(wl => wl.TotalVolume)) + "]"); } continue; } // Start clearing out items that are worth less var moveTheseItems = new List <DirectItem>(); foreach (var wl in worthLess.OrderBy(wl => wl.IskPerM3.HasValue ? wl.IskPerM3.Value : double.MaxValue).ThenByDescending(wl => wl.TotalVolume)) { // Mark this item as moved moveTheseItems.Add(wl.DirectItem); // Substract (now) free volume freeCargoCapacity += wl.TotalVolume; // We freed up enough space? if ((freeCargoCapacity - item.TotalVolume) >= ReserveCargoCapacity) { break; } } if (moveTheseItems.Count > 0) { // If this is not a cargo container, then jettison loot if (containerEntity.GroupId != (int)Group.CargoContainer || isMissionItem) { if (DateTime.Now.Subtract(_lastJettison).TotalSeconds < 185) { return; } Logging.Log("Salvage: Jettisoning [" + moveTheseItems.Count + "] items to make room for the more valuable loot"); // Note: This could (in theory) f**k up with the bot jettison an item and // then picking it up again :/ (granted it should never happen unless // mission item volume > reserved volume cargo.Jettison(moveTheseItems.Select(i => i.ItemId)); _lastJettison = DateTime.Now; return; } // Move items to the cargo container container.Add(moveTheseItems); // Remove it from the ships cargo list shipsCargo.RemoveAll(i => moveTheseItems.Any(wl => wl.ItemId == i.Id)); Logging.Log("Salvage: Moving [" + moveTheseItems.Count + "] items into the cargo container to make room for the more valuable loot"); } } // Update free space freeCargoCapacity -= item.TotalVolume; lootItems.Add(item); } // Mark container as looted Cache.Instance.LootedContainers.Add(containerEntity.Id); // Loot actual items if (lootItems.Count != 0) { Logging.Log("Salvage: Looting container [" + containerEntity.Name + "][" + containerEntity.Id + "], [" + lootItems.Count + "] valuable items"); cargo.Add(lootItems.Select(i => i.DirectItem)); } else { Logging.Log("Salvage: Container [" + containerEntity.Name + "][" + containerEntity.Id + "] contained no valuable items"); } } // Open a container in range foreach (var containerEntity in Cache.Instance.Containers.Where(e => e.Distance <= 2500)) { // Emptry wreck, ignore if (containerEntity.GroupId == (int)Group.Wreck && containerEntity.IsWreckEmpty) { continue; } // We looted this container if (Cache.Instance.LootedContainers.Contains(containerEntity.Id)) { continue; } // We already opened the loot window var window = lootWindows.FirstOrDefault(w => w.ItemId == containerEntity.Id); if (window != null) { continue; } // Ignore open request within 10 seconds if (_openedContainers.ContainsKey(containerEntity.Id) && DateTime.Now.Subtract(_openedContainers[containerEntity.Id]).TotalSeconds < 10) { continue; } // Open the container Logging.Log("Salvage: Opening container [" + containerEntity.Name + "][" + containerEntity.Id + "]"); containerEntity.OpenCargo(); _openedContainers[containerEntity.Id] = DateTime.Now; break; } }
/// <summary> /// Loot any wrecks & cargo containers close by /// </summary> private void LootWrecks() { var cargo = Cache.Instance.DirectEve.GetShipsCargo(); if (cargo.Window == null) { // No, command it to open Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.OpenCargoHoldOfActiveShip); return; } // Ship's cargo is not ready yet if (!cargo.IsReady) { return; } var shipsCargo = cargo.Items.Select(i => new ItemCache(i)).ToList(); var freeCargoCapacity = cargo.Capacity - cargo.UsedCapacity; var lootWindows = Cache.Instance.DirectEve.Windows.OfType <DirectContainerWindow>().Where(w => w.Type == "form.LootCargoView"); foreach (var window in lootWindows) { // The window is not ready, then continue if (!window.IsReady) { continue; } // Get the container var containerEntity = Cache.Instance.EntityById(window.ItemId); // Does it no longer exist or is it out of transfer range or its looted if (containerEntity == null || containerEntity.Distance > (int)Distance.SafeScoopRange || Cache.Instance.LootedContainers.Contains(containerEntity.Id)) { Logging.Log("Salvage: Closing loot window [" + window.ItemId + "]"); window.Close(); continue; } // Get the container that is associated with the cargo container var container = Cache.Instance.DirectEve.GetContainer(window.ItemId); // List its items var items = container.Items.Select(i => new ItemCache(i)); // Build a list of items to loot var lootItems = new List <ItemCache>(); if (Settings.Instance.WreckLootStatistics) { // Log all items found in the wreck File.AppendAllText(Settings.Instance.WreckLootStatisticsFile, "TIME: " + string.Format("{0:dd/MM/yyyy HH:mm:ss}", DateTime.Now) + "\n"); File.AppendAllText(Settings.Instance.WreckLootStatisticsFile, "NAME: " + containerEntity.Name + "\n"); File.AppendAllText(Settings.Instance.WreckLootStatisticsFile, "ITEMS:" + "\n"); foreach (var item in items.OrderBy(i => i.TypeId)) { File.AppendAllText(Settings.Instance.WreckLootStatisticsFile, "TypeID: " + item.TypeId.ToString() + "\n"); File.AppendAllText(Settings.Instance.WreckLootStatisticsFile, "Name: " + item.Name + "\n"); File.AppendAllText(Settings.Instance.WreckLootStatisticsFile, "Quantity: " + item.Quantity.ToString() + "\n"); File.AppendAllText(Settings.Instance.WreckLootStatisticsFile, "=\n"); } File.AppendAllText(Settings.Instance.WreckLootStatisticsFile, ";" + "\n"); } //if (freeCargoCapacity < 1000) //this should allow BSs to dump scrapmetal but haulers and noctus' to hold onto it //{ // // Dump scrap metal if we have any // if (containerEntity.Name == "Cargo Container" && shipsCargo.Any(i => i.IsScrapMetal)) // { // foreach (var item in shipsCargo.Where(i => i.IsScrapMetal)) // { // container.Add(item.DirectItem); // freeCargoCapacity += item.TotalVolume; // } // // shipsCargo.RemoveAll(i => i.IsScrapMetal); // } //} // Walk through the list of items ordered by highest value item first foreach (var item in items.OrderByDescending(i => i.IskPerM3)) { if (freeCargoCapacity < 1000) //this should allow BSs to not pickup large low value items but haulers and noctus' to scoop everything { // We never want to pick up a cap booster if (item.GroupID == (int)Group.CapacitorGroupCharge) { continue; } // We never want to pick up metal scraps //if (item.IsScrapMetal) // continue; } // We pick up loot depending on isk per m3 var isMissionItem = Cache.Instance.MissionItems.Contains((item.Name ?? string.Empty).ToLower()); // Never pick up contraband (unless its the mission item) if (!isMissionItem && item.IsContraband) { continue; } // Do we want to loot other items? if (!isMissionItem && !LootEverything) { continue; } // Do not pick up items that cannot enter in a freighter container (unless its the mission item) // Note: some mission items that are alive have been allowed to be // scooped because unloadlootstate.MoveCommonMissionCompletionitems // will move them into the hangar floor not the loot location if (!isMissionItem && item.IsAliveandWontFitInContainers) { continue; } // We are at our max, either make room or skip the item if ((freeCargoCapacity - item.TotalVolume) <= (isMissionItem ? 0 : ReserveCargoCapacity)) { // We can't drop items in this container anyway, well get it after its salvaged if (!isMissionItem && containerEntity.GroupId != (int)Group.CargoContainer) { continue; } // Make a list of items which are worth less List <ItemCache> worthLess; if (isMissionItem) { worthLess = shipsCargo; } else if (item.IskPerM3.HasValue) { worthLess = shipsCargo.Where(sc => sc.IskPerM3.HasValue && sc.IskPerM3 < item.IskPerM3).ToList(); } else { worthLess = shipsCargo.Where(sc => sc.IskPerM3.HasValue).ToList(); } // Remove mission item from this list worthLess.RemoveAll(wl => Cache.Instance.MissionItems.Contains((wl.Name ?? string.Empty).ToLower())); worthLess.RemoveAll(wl => (wl.Name ?? string.Empty).ToLower() == Cache.Instance.BringMissionItem); // Consider dropping ammo if it concerns the mission item! if (!isMissionItem) { worthLess.RemoveAll(wl => Ammo.Any(a => a.TypeId == wl.TypeId)); } // Nothing is worth less then the current item if (worthLess.Count() == 0) { continue; } // Not enough space even if we dumped the crap if ((freeCargoCapacity + worthLess.Sum(wl => wl.TotalVolume)) < item.TotalVolume) { if (isMissionItem) { Logging.Log("Salvage: Not enough space for mission item! Need [" + item.TotalVolume + "] maximum available [" + (freeCargoCapacity + worthLess.Sum(wl => wl.TotalVolume)) + "]"); } continue; } // Start clearing out items that are worth less var moveTheseItems = new List <DirectItem>(); foreach (var wl in worthLess.OrderBy(wl => wl.IskPerM3.HasValue ? wl.IskPerM3.Value : double.MaxValue).ThenByDescending(wl => wl.TotalVolume)) { // Mark this item as moved moveTheseItems.Add(wl.DirectItem); // Subtract (now) free volume freeCargoCapacity += wl.TotalVolume; // We freed up enough space? if ((freeCargoCapacity - item.TotalVolume) >= ReserveCargoCapacity) { break; } } if (moveTheseItems.Count > 0) { // If this is not a cargo container, then jettison loot if (containerEntity.GroupId != (int)Group.CargoContainer || isMissionItem) { if (DateTime.Now.Subtract(_lastJettison).TotalSeconds < (int)Time.DelayBetweenJetcans_seconds) { return; } Logging.Log("Salvage: Jettisoning [" + moveTheseItems.Count + "] items to make room for the more valuable loot"); // Note: This could (in theory) f**k up with the bot jettison an item and // then picking it up again :/ (granted it should never happen unless // mission item volume > reserved volume cargo.Jettison(moveTheseItems.Select(i => i.ItemId)); _lastJettison = DateTime.Now; return; } // Move items to the cargo container container.Add(moveTheseItems); // Remove it from the ships cargo list shipsCargo.RemoveAll(i => moveTheseItems.Any(wl => wl.ItemId == i.Id)); Logging.Log("Salvage: Moving [" + moveTheseItems.Count + "] items into the cargo container to make room for the more valuable loot"); } } // Update free space freeCargoCapacity -= item.TotalVolume; lootItems.Add(item); } // Mark container as looted Cache.Instance.LootedContainers.Add(containerEntity.Id); // Loot actual items if (lootItems.Count != 0) { Logging.Log("Salvage: Looting container [" + containerEntity.Name + "][ID: " + containerEntity.Id + "], [" + lootItems.Count + "] valuable items"); cargo.Add(lootItems.Select(i => i.DirectItem)); } else { Logging.Log("Salvage: Container [" + containerEntity.Name + "][ID: " + containerEntity.Id + "] contained no valuable items"); } } // Open a container in range foreach (var containerEntity in Cache.Instance.Containers.Where(e => e.Distance <= (int)Distance.SafeScoopRange)) { // Emptry wreck, ignore if (containerEntity.GroupId == (int)Group.Wreck && containerEntity.IsWreckEmpty) { continue; } // We looted this container if (Cache.Instance.LootedContainers.Contains(containerEntity.Id)) { continue; } // We already opened the loot window var window = lootWindows.FirstOrDefault(w => w.ItemId == containerEntity.Id); if (window != null) { continue; } // Ignore open request within 10 seconds if (_openedContainers.ContainsKey(containerEntity.Id) && DateTime.Now.Subtract(_openedContainers[containerEntity.Id]).TotalSeconds < 10) { continue; } // Don't even try to open a wreck if you are speed tanking and you aren't processing a loot action if (Settings.Instance.SpeedTank == true && Cache.Instance.OpenWrecks == false) { continue; } // Don't even try to open a wreck if you are specified LootEverything as false and you aren't processing a loot action // this is currently commented out as it would keep golems and other non-speed tanked ships from looting the field as they cleared // missions, but NOT stick around after killing things to clear it ALL. Looteverything==false does NOT mean loot nothing //if (Settings.Instance.LootEverything == false && Cache.Instance.OpenWrecks == false) // continue; // Open the container Logging.Log("Salvage: Opening container [" + containerEntity.Name + "][ID: " + containerEntity.Id + "]"); containerEntity.OpenCargo(); _openedContainers[containerEntity.Id] = DateTime.Now; break; } }