Skip to content

Commit

Permalink
Added first storyline automation (Materials For War Preparation)
Browse files Browse the repository at this point in the history
Fixed MarketWindow stuff
Added DirectOrderRange to DirectOrder's
  • Loading branch information
Da-Teach committed Feb 27, 2011
1 parent bbdeeb0 commit 33cd2f1
Show file tree
Hide file tree
Showing 9 changed files with 489 additions and 20 deletions.
Binary file modified DirectEve/DirectEve.dll
Binary file not shown.
50 changes: 31 additions & 19 deletions Questor.Modules/AgentInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public AgentInteraction()
AmmoToLoad = new List<Ammo>();
}

public long AgentId { get; set; }
public DirectAgent Agent
{
get { return Cache.Instance.DirectEve.GetAgentById(AgentId); }
}

public bool ForceAccept { get; set; }
public AgentInteractionState State { get; set; }
public AgentInteractionPurpose Purpose { get; set; }

Expand All @@ -49,7 +56,7 @@ private void LoadSpecificAmmo(IEnumerable<DamageType> damageTypes)

private void WaitForConversation()
{
var agentWindow = Cache.Instance.Agent.Window;
var agentWindow = Agent.Window;
if (agentWindow == null || !agentWindow.IsReady)
return;

Expand All @@ -60,7 +67,7 @@ private void WaitForConversation()

private void ReplyToAgent()
{
var agentWindow = Cache.Instance.Agent.Window;
var agentWindow = Agent.Window;
if (agentWindow == null || !agentWindow.IsReady)
return;

Expand Down Expand Up @@ -163,7 +170,7 @@ private DamageType GetMissionDamageType(string html)

private void WaitForMission()
{
var agentWindow = Cache.Instance.Agent.Window;
var agentWindow = Agent.Window;
if (agentWindow == null || !agentWindow.IsReady)
return;

Expand All @@ -178,18 +185,23 @@ private void WaitForMission()
return;
}

var mission = Cache.Instance.Mission;
var mission = Cache.Instance.DirectEve.AgentMissions.FirstOrDefault(m => m.AgentId == AgentId);
if (mission == null)
return;

// Is the mission offered?
if (mission.State == (int) MissionState.Offered && (mission.Type == "Courier" || mission.Type == "Mining" || mission.Type == "Trade" || Settings.Instance.Blacklist.Any(m => m.ToLower() == Cache.Instance.MissionName.ToLower())))
var missionName = Cache.Instance.FilterPath(mission.Name);

if (!ForceAccept)
{
Logging.Log("AgentInteraction: Declining courier/mining/trade/blacklisted mission [" + Cache.Instance.MissionName + "]");
// Is the mission offered?
if (mission.State == (int) MissionState.Offered && (mission.Type == "Courier" || mission.Type == "Mining" || mission.Type == "Trade" || Settings.Instance.Blacklist.Any(m => m.ToLower() == missionName.ToLower())))
{
Logging.Log("AgentInteraction: Declining courier/mining/trade/blacklisted mission [" + missionName + "]");

State = AgentInteractionState.DeclineMission;
_nextAction = DateTime.Now.AddSeconds(7);
return;
State = AgentInteractionState.DeclineMission;
_nextAction = DateTime.Now.AddSeconds(7);
return;
}
}

var html = agentWindow.Objective;
Expand All @@ -204,10 +216,10 @@ private void WaitForMission()

var loadedAmmo = false;

var missionXmlPath = Path.Combine(Settings.Instance.MissionsPath, Cache.Instance.MissionName + ".xml");
var missionXmlPath = Path.Combine(Settings.Instance.MissionsPath, missionName + ".xml");
if (File.Exists(missionXmlPath))
{
Logging.Log("AgentInteraction: Loading mission xml [" + Cache.Instance.MissionName + "]");
Logging.Log("AgentInteraction: Loading mission xml [" + missionName + "]");
try
{
var missionXml = XDocument.Load(missionXmlPath);
Expand All @@ -226,22 +238,22 @@ private void WaitForMission()

if (!loadedAmmo)
{
Logging.Log("AgentInteraction: No damage type for [" + Cache.Instance.MissionName + "] specified");
Logging.Log("AgentInteraction: Detecting damage type for [" + missionName + "]");

Cache.Instance.DamageType = GetMissionDamageType(html);
LoadSpecificAmmo(new[] {Cache.Instance.DamageType});
}

if (mission.State == (int) MissionState.Offered)
{
Logging.Log("AgentInteraction: Accepting mission [" + Cache.Instance.MissionName + "]");
Logging.Log("AgentInteraction: Accepting mission [" + missionName + "]");

State = AgentInteractionState.AcceptMission;
_nextAction = DateTime.Now.AddSeconds(7);
}
else // If we already accepted the mission, close the convo
{
Logging.Log("AgentInteraction: Mission [" + Cache.Instance.MissionName + "] already accepted");
Logging.Log("AgentInteraction: Mission [" + missionName + "] already accepted");
Logging.Log("AgentInteraction: Closing conversation");

State = AgentInteractionState.CloseConversation;
Expand All @@ -251,7 +263,7 @@ private void WaitForMission()

private void AcceptMission()
{
var agentWindow = Cache.Instance.Agent.Window;
var agentWindow = Agent.Window;
if (agentWindow == null || !agentWindow.IsReady)
return;

Expand All @@ -273,7 +285,7 @@ private void AcceptMission()

private void DeclineMission()
{
var agentWindow = Cache.Instance.Agent.Window;
var agentWindow = Agent.Window;
if (agentWindow == null || !agentWindow.IsReady)
return;

Expand All @@ -296,7 +308,7 @@ private void DeclineMission()

public void CloseConversation()
{
var agentWindow = Cache.Instance.Agent.Window;
var agentWindow = Agent.Window;
if (agentWindow == null)
{
Logging.Log("AgentInteraction: Done");
Expand All @@ -321,7 +333,7 @@ public void ProcessState()
break;

case AgentInteractionState.StartConversation:
Cache.Instance.Agent.InteractWith();
Agent.InteractWith();

Logging.Log("AgentInteraction: Waiting for conversation");
State = AgentInteractionState.WaitForConversation;
Expand Down
29 changes: 28 additions & 1 deletion Questor/Questor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Questor
using System.Reflection;
using DirectEve;
using global::Questor.Modules;
using global::Questor.Storylines;

public class Questor
{
Expand All @@ -29,6 +30,7 @@ public class Questor
private DateTime _lastPulse;
private MissionController _missionController;
private Panic _panic;
private Storyline _storyline;

private Salvage _salvage;
private Traveler _traveler;
Expand All @@ -54,6 +56,7 @@ public Questor()
_missionController = new MissionController();
_drones = new Drones();
_panic = new Panic();
_storyline = new Storyline();

Settings.Instance.SettingsLoaded += SettingsLoaded;

Expand Down Expand Up @@ -102,11 +105,14 @@ public void SettingsLoaded(object sender, EventArgs e)
ValidSettings = false;
}

if (Cache.Instance.Agent == null || !Cache.Instance.Agent.IsValid)
var agent = Cache.Instance.DirectEve.GetAgentByName(Settings.Instance.AgentName);
if (agent == null || !agent.IsValid)
{
Logging.Log("Settings: Unable to locate agent [" + Settings.Instance.AgentName + "]");
ValidSettings = false;
}
else
_agentInteraction.AgentId = agent.AgentId;

AutoStart = Settings.Instance.AutoStart;
}
Expand Down Expand Up @@ -325,6 +331,15 @@ private void OnFrame(object sender, EventArgs e)
case QuestorState.Start:
if (_agentInteraction.State == AgentInteractionState.Idle)
{
if (_storyline.HasStoryline())
{
Logging.Log("Questor: Storyline detected, doing storyline.");

_storyline.Reset();
State = QuestorState.Storyline;
break;
}

Logging.Log("AgentInteraction: Start conversation [Start Mission]");

_agentInteraction.State = AgentInteractionState.StartConversation;
Expand Down Expand Up @@ -665,6 +680,18 @@ private void OnFrame(object sender, EventArgs e)
ApplySettings();
}
break;

case QuestorState.Storyline:
_storyline.ProcessState();

if (_storyline.State == StorylineState.Done)
{
Logging.Log("Questor: We have completed the storyline, returning to base");

State = QuestorState.GotoBase;
break;
}
break;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Questor/Questor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Questor.cs" />
<Compile Include="QuestorState.cs" />
<Compile Include="Storylines\IStoryline.cs" />
<Compile Include="Storylines\MaterialsForWarPreparation.cs" />
<Compile Include="Storylines\Storyline.cs" />
<Compile Include="Storylines\StorylineState.cs" />
<EmbeddedResource Include="frmMain.resx">
<DependentUpon>frmMain.cs</DependentUpon>
</EmbeddedResource>
Expand Down
1 change: 1 addition & 0 deletions Questor/QuestorState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ public enum QuestorState
Error,
Panic,
CombatHelper,
Storyline
}
}
10 changes: 10 additions & 0 deletions Questor/Storylines/IStoryline.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Questor.Storylines
{
interface IStoryline
{
StorylineState Arm();
StorylineState PreAcceptMission();
StorylineState PostAcceptMission();
StorylineState PostCompleteMission();
}
}
Loading

0 comments on commit 33cd2f1

Please sign in to comment.