Skip to content

Commit

Permalink
Fixed bugged scheduler, reverted to traditional command line.
Browse files Browse the repository at this point in the history
Added Ganondorf's fitting code, modified to use char xml files
instead of mission files.
  • Loading branch information
chantling committed May 28, 2011
1 parent 0517d6d commit ccee8f4
Show file tree
Hide file tree
Showing 16 changed files with 459 additions and 203 deletions.
Binary file modified DirectEve/DirectEve.dll
Binary file not shown.
38 changes: 30 additions & 8 deletions Questor.Modules/AgentInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private void WaitForMission()
{
Logging.Log("AgentInteraction: Mission [" + missionName + "] already accepted");
Logging.Log("AgentInteraction: Closing conversation");

//CheckFaction();
State = AgentInteractionState.CloseConversation;
_nextAction = DateTime.Now.AddSeconds(7);
}
Expand Down Expand Up @@ -402,15 +402,37 @@ public bool CheckFaction()
// Load faction xml
var xml = XDocument.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Factions.xml"));
var faction = xml.Root.Elements("faction").Where(f => (string) f.Attribute("logo") == logo).FirstOrDefault();
//Cache.Instance.factionFit = "Default";
Cache.Instance.Fitting = "Default";
if (faction != null)
{
var factionName = ((string) faction.Attribute("name"));
Logging.Log("AgentInteraction: Mission enemy faction: " + factionName);
if (Settings.Instance.FactionBlacklist.Any(m => m.ToLower() == factionName.ToLower()))
return true;
}
{
var factionName = ((string)faction.Attribute("name"));
Logging.Log("AgentInteraction: Mission enemy faction: " + factionName);
if (Settings.Instance.FactionBlacklist.Any(m => m.ToLower() == factionName.ToLower()))
return true;
if (Settings.Instance.FactionFitting.Any(m => m.Faction.ToLower() == factionName.ToLower()))
{
var FactionFitting = Settings.Instance.FactionFitting.FirstOrDefault(m => m.Faction.ToLower() == factionName.ToLower());
Cache.Instance.factionFit = (string)FactionFitting.Fitting;
Logging.Log("AgentInteraction: Faction fitting " + FactionFitting.Faction);
Cache.Instance.Fitting = Cache.Instance.factionFit;
return false;
}
}
else
{
var FactionFitting = Settings.Instance.FactionFitting.FirstOrDefault(m => m.Faction.ToLower() == "default");
Cache.Instance.factionFit = (string)FactionFitting.Fitting;
Logging.Log("AgentInteraction: Faction fitting " + FactionFitting.Faction);
Cache.Instance.Fitting = Cache.Instance.factionFit;
return false;
}
}
return false;
var _FactionFitting = Settings.Instance.FactionFitting.FirstOrDefault(m => m.Faction.ToLower() == "default");
Cache.Instance.factionFit = (string)_FactionFitting.Fitting;
Logging.Log("AgentInteraction: Faction fitting " + _FactionFitting.Faction);
Cache.Instance.Fitting = Cache.Instance.factionFit;
return false;
}

public void CloseConversation()
Expand Down
Binary file modified Questor.Modules/Arm.cs
Binary file not shown.
5 changes: 5 additions & 0 deletions Questor.Modules/ArmState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ public enum ArmState
SwitchToSalvageShip,
ActivateSalvageShip,
NotEnoughAmmo,
WaitForFitting,
OpenFittingWindow,
WaitForFittingWindow,
ChoseFitting,

}
}
41 changes: 41 additions & 0 deletions Questor.Modules/Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ public DirectAgentMission GetAgentMission(long agentId)
/// </summary>
/// <returns></returns>
public string BringMissionItem { get; private set; }
public string Fitting { get; set; }
public string currentFit { get; set; }
public string factionFit { get; set; }
public string missionFit { get; set; }

public DirectWindow GetWindowByCaption(string caption)
{
Expand Down Expand Up @@ -613,10 +617,44 @@ public void RefreshMissionItems(long agentId)
MissionItems.Clear();
BringMissionItem = string.Empty;

//Fitting = "Default";
var FactionFitting = Settings.Instance.FactionFitting.FirstOrDefault(m => m.Faction.ToLower() == "default");
var _factionFit = (string)FactionFitting.Fitting;
Fitting = _factionFit;

var mission = GetAgentMission(agentId);
if (mission == null)
return;

if (Settings.Instance.MissionFitting.Any(m => m.Mission.ToLower() == mission.Name.ToLower()))
{
// if we've got multiple copies of the same mission, find the one with the matching faction
if (Settings.Instance.MissionFitting.Any(m => m.Faction.ToLower() == factionFit.ToLower() && (m.Mission.ToLower() == mission.Name.ToLower())))
{
var MissionFitting = Settings.Instance.MissionFitting.FirstOrDefault(m => m.Faction.ToLower() == factionFit.ToLower() && (m.Mission.ToLower() == mission.Name.ToLower()));
missionFit = (string)MissionFitting.Fitting;
Logging.Log("Cache: Mission: " + MissionFitting.Mission + " - Faction: " + factionFit + " - Fitting: " + MissionFitting.Fitting);
Fitting = missionFit;
}
else //otherwise just use the first copy of that mission
{
var MissionFitting = Settings.Instance.MissionFitting.FirstOrDefault(m => m.Mission.ToLower() == mission.Name.ToLower());
missionFit = (string)MissionFitting.Fitting;
//Logging.Log("Cache: Mission: " + MissionFitting.Mission + " - Fitting: " + MissionFitting.Fitting);
Fitting = missionFit;
}
}
else if (factionFit != null)
Fitting = factionFit;

if (Fitting == "")
{
FactionFitting = Settings.Instance.FactionFitting.FirstOrDefault(m => m.Faction.ToLower() == "default");
factionFit = (string)FactionFitting.Fitting;
//Logging.Log("AgentInteraction: Faction fitting " + FactionFitting.Faction);
Fitting = factionFit;
}

var missionName = FilterPath(mission.Name);
var missionXmlPath = Path.Combine(Settings.Instance.MissionsPath, missionName + ".xml");
if (!File.Exists(missionXmlPath))
Expand All @@ -630,6 +668,9 @@ public void RefreshMissionItems(long agentId)

BringMissionItem = (string) xdoc.Root.Element("bring") ?? string.Empty;
BringMissionItem = BringMissionItem.ToLower();

//load fitting setting from the mission file
//Fitting = (string)xdoc.Root.Element("fitting") ?? "default";
}
catch (Exception ex)
{
Expand Down
89 changes: 89 additions & 0 deletions Questor.Modules/CharSchedule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// ------------------------------------------------------------------------------
// <copyright from='2010' to='2015' company='THEHACKERWITHIN.COM'>
// Copyright (c) TheHackerWithin.COM. All Rights Reserved.
//
// Please look in the accompanying license.htm file for the license that
// applies to this source code. (a copy can also be found at:
// http://www.thehackerwithin.com/license.htm)
// </copyright>
// -------------------------------------------------------------------------------


namespace Questor.Modules
{
using System.Xml.Linq;
using System.Globalization;
using Questor.Modules;
using System;
//using System.Windows.Forms;

public class CharSchedule
{
public CharSchedule(XElement element)
{
CultureInfo enUS = new CultureInfo("en-US");
User = (string)element.Attribute("user");
PW = (string)element.Attribute("pw");
Name = (string)element.Attribute("name");

stopTimeSpecified = false;
startTimeSpecified = false;
string _start = (string)element.Attribute("start");
string _stop = (string)element.Attribute("stop");
DateTime _startTime = new DateTime();
DateTime _stopTime = new DateTime();
if (_start != null)
{
if (!DateTime.TryParseExact(_start, "HH:mm", enUS, DateTimeStyles.None, out _startTime))
{
Logging.Log("[CharSchedule] Couldn't parse starttime. Starting now.");
_startTime = DateTime.Now;
}
else
startTimeSpecified = true;
}
else
{
Logging.Log("[CharSchedule] No start time specified. Starting now.");
_startTime = DateTime.Now;
}
Start = _startTime;

if (_stop != null)
{
if (!DateTime.TryParseExact(_stop, "HH:mm", enUS, DateTimeStyles.None, out _stopTime))
{
Logging.Log("[CharSchedule] Couldn't parse stoptime.");
_stopTime = DateTime.Now.AddHours(24);
}
else
stopTimeSpecified = true;
}
else
{
Logging.Log("[CharSchedule] No stop time specified.");
_stopTime = DateTime.Now.AddHours(24);
}
Stop = _stopTime;

if ((string)element.Attribute("runtime") != null)
{
RunTime = (double)element.Attribute("runtime");
stopTimeSpecified = true;
}
else
RunTime = -1;
}



public string User { get; private set; }
public string PW { get; private set; }
public string Name { get; private set; }
public DateTime Start { get; set; }
public DateTime Stop { get; set; }
public double RunTime { get; set; }
public bool stopTimeSpecified { get; set; }
public bool startTimeSpecified { get; set; }
}
}
11 changes: 11 additions & 0 deletions Questor.Modules/EntityCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,17 @@ public bool IsTrackingDisruptingMe
}
}

public int Health
{
get
{
if (_directEntity != null)
return (int)((_directEntity.ShieldPct + _directEntity.ArmorPct + _directEntity.StructurePct) * 100);

return 0;
}
}

public bool IsSentry
{
get
Expand Down
48 changes: 48 additions & 0 deletions Questor.Modules/Fitting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ------------------------------------------------------------------------------
// <copyright from='2010' to='2015' company='THEHACKERWITHIN.COM'>
// Copyright (c) TheHackerWithin.COM. All Rights Reserved.
//
// Please look in the accompanying license.htm file for the license that
// applies to this source code. (a copy can also be found at:
// http://www.thehackerwithin.com/license.htm)
// </copyright>
// -------------------------------------------------------------------------------
namespace Questor.Modules
{
using System;
using System.Xml.Linq;

public class FactionFitting
{
public FactionFitting()
{
}

public FactionFitting(XElement factionfitting)
{
Faction = (string)factionfitting.Attribute("faction") ?? "";
Fitting = (string)factionfitting.Attribute("fitting") ?? "";
}

public string Faction { get; private set; }
public string Fitting { get; private set; }
}

public class MissionFitting
{
public MissionFitting()
{
}

public MissionFitting(XElement missionfitting)
{
Mission = (string)missionfitting.Attribute("mission") ?? "";
Faction = (string)missionfitting.Attribute("faction") ?? "Default";
Fitting = (string)missionfitting.Attribute("fitting") ?? "";
}

public string Mission { get; private set; }
public string Faction { get; private set; }
public string Fitting { get; private set; }
}
}
2 changes: 2 additions & 0 deletions Questor.Modules/Questor.Modules.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@
<Compile Include="ArmState.cs" />
<Compile Include="Cache.cs" />
<Compile Include="CategoryID.cs" />
<Compile Include="CharSchedule.cs" />
<Compile Include="Combat.cs" />
<Compile Include="CombatState.cs" />
<Compile Include="DamageType.cs" />
<Compile Include="Defense.cs" />
<Compile Include="Drones.cs" />
<Compile Include="DroneState.cs" />
<Compile Include="EntityCache.cs" />
<Compile Include="Fitting.cs" />
<Compile Include="GroupID.cs" />
<Compile Include="InvType.cs" />
<Compile Include="ItemCache.cs" />
Expand Down
32 changes: 19 additions & 13 deletions Questor.Modules/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public class Settings
public Settings()
{
Ammo = new List<Ammo>();
FactionFitting = new List<FactionFitting>();
MissionFitting = new List<MissionFitting>();
Blacklist = new List<string>();
FactionBlacklist = new List<string>();
FactionBlacklist = new List<string>();
}

public bool DebugStates { get; set; }
Expand Down Expand Up @@ -62,6 +64,8 @@ public Settings()
public int MaximumLowValueTargets { get; set; }

public List<Ammo> Ammo { get; private set; }
public List<FactionFitting> FactionFitting { get; private set; }
public List<MissionFitting> MissionFitting { get; private set; }

public int MinimumAmmoCharges { get; set; }

Expand Down Expand Up @@ -106,10 +110,6 @@ public Settings()
public int? WindowYPosition { get; set; }
public event EventHandler<EventArgs> SettingsLoaded;

public string startTimeString { get; set; }
public string stopTimeString { get; set; }
public double runTime { get; set; }

public void LoadSettings()
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Expand Down Expand Up @@ -147,6 +147,8 @@ public void LoadSettings()
MaximumLowValueTargets = 0;

Ammo.Clear();
FactionFitting.Clear();
MissionFitting.Clear();

MinimumAmmoCharges = 0;

Expand Down Expand Up @@ -181,10 +183,6 @@ public void LoadSettings()
Blacklist.Clear();
FactionBlacklist.Clear();

startTimeString = null;
stopTimeString = null;
runTime = -1;

return;
}

Expand Down Expand Up @@ -231,6 +229,18 @@ public void LoadSettings()

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));

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;
Expand Down Expand Up @@ -277,10 +287,6 @@ public void LoadSettings()
foreach (var faction in factionblacklist.Elements("faction"))
FactionBlacklist.Add((string) faction);

startTimeString = (string)xml.Element("startTime");
stopTimeString = (string)xml.Element("stopTime");
runTime = (double?)xml.Element("runTime") ?? -1;

if (SettingsLoaded != null)
SettingsLoaded(this, new EventArgs());
}
Expand Down
Loading

0 comments on commit ccee8f4

Please sign in to comment.