Skip to content

Commit

Permalink
do retainers ... and become FASTER!
Browse files Browse the repository at this point in the history
  • Loading branch information
Jukkales committed Apr 17, 2024
1 parent cb21608 commit 7cf66da
Show file tree
Hide file tree
Showing 30 changed files with 672 additions and 267 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "ECommons"]
path = ECommons
url = https://github.com/NightmareXIV/ECommons.git
[submodule "AutoRetainerAPI"]
path = AutoRetainerAPI
url = https://github.com/PunishXIV/AutoRetainerAPI.git
1 change: 1 addition & 0 deletions AutoRetainerAPI
Submodule AutoRetainerAPI added at 6f0aaa
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Changelog

I try to keep this changelog up to date with the latest changes in the project.

## [1.4.0.0]
- run retainers between runs
- speed up some things to save 1-2 seconds per run
- some refactorings (but i still dislike it)
- overall statistics now can show days

## [1.3.1.0]
- initial setup check bugfix

## [1.3.0.0]
- small overlay button on deep dungeon menu to open the farm window
- checks for minimal setup/floor before starting the farm
- some UI additions like support button and error message
- implemented paranoid mode
- safety checks for pomanders
- allow enter with deep dungeon menu open

## [1.2.1.0]
- disabling command now finishes the run first

## [1.2.0.0]
- command arguments control
- implemented farm modes Efficiency and Time

## [1.1.1.1]
- fixed stupid search logic bug (no really i fucked up xD)

## [1.1.1.0]
- search logic bugfixes
- added achievement tracker to statistics


## [1.1.0.0]
- Various bugfixes
- more statistics
- first draft of hoard searching

## [1.0.1.0]

- Various bugfixes preventing getting some hoards

## [1.0.0.0]

- Initial release
6 changes: 6 additions & 0 deletions HoardFarm.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{F9961719-46EC-4349-A596-03D00B234804}") = "HoardFarm", "HoardFarm\Hoar
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ECommons", "ECommons\ECommons\ECommons.csproj", "{D20CCCF7-6F38-4A04-BE73-5E501DACCAA2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoRetainerAPI", "AutoRetainerAPI\AutoRetainerAPI\AutoRetainerAPI.csproj", "{C0294C05-FD43-4EDF-9A4E-3E53DD4BBC88}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand All @@ -25,6 +27,10 @@ Global
{D20CCCF7-6F38-4A04-BE73-5E501DACCAA2}.Debug|x64.Build.0 = Debug|x64
{D20CCCF7-6F38-4A04-BE73-5E501DACCAA2}.Release|x64.ActiveCfg = Release|x64
{D20CCCF7-6F38-4A04-BE73-5E501DACCAA2}.Release|x64.Build.0 = Release|x64
{C0294C05-FD43-4EDF-9A4E-3E53DD4BBC88}.Debug|x64.ActiveCfg = Debug|x64
{C0294C05-FD43-4EDF-9A4E-3E53DD4BBC88}.Debug|x64.Build.0 = Debug|x64
{C0294C05-FD43-4EDF-9A4E-3E53DD4BBC88}.Release|x64.ActiveCfg = Release|x64
{C0294C05-FD43-4EDF-9A4E-3E53DD4BBC88}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
14 changes: 13 additions & 1 deletion HoardFarm/HoardFarm.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Globalization;
using AutoRetainerAPI;
using Dalamud;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
Expand All @@ -20,6 +21,8 @@ public sealed class HoardFarm : IDalamudPlugin
private readonly MainWindow mainWindow;
private readonly ConfigWindow configWindow;
private readonly DeepDungeonMenuOverlay deepDungeonMenuOverlay;
private readonly AutoRetainerApi autoRetainerApi;
private readonly RetainerService retainerService;
public WindowSystem WindowSystem = new("HoardFarm");

public HoardFarm(DalamudPluginInterface? pluginInterface)
Expand Down Expand Up @@ -50,6 +53,12 @@ public HoardFarm(DalamudPluginInterface? pluginInterface)
achievementService = new AchievementService();
Achievements = achievementService;

autoRetainerApi = new AutoRetainerApi();
RetainerApi = autoRetainerApi;

retainerService = new RetainerService();
RetainerScv = retainerService;

PluginInterface.UiBuilder.Draw += DrawUI;
PluginInterface.UiBuilder.OpenMainUi += () => OnCommand();
PluginInterface.UiBuilder.OpenConfigUi += ShowConfigWindow;
Expand All @@ -75,6 +84,7 @@ public HoardFarm(DalamudPluginInterface? pluginInterface)
};
}


private void FrameworkUpdate(IFramework framework)
{
YesAlreadyManager.Tick();
Expand All @@ -84,7 +94,9 @@ public void Dispose()
{
WindowSystem.RemoveAllWindows();
hoardFarmService.Dispose();
achievementService.Dispose();

autoRetainerApi.Dispose();
retainerService.Dispose();

Framework.Update -= FrameworkUpdate;
ECommonsMain.Dispose();
Expand Down
3 changes: 2 additions & 1 deletion HoardFarm/HoardFarm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>Jukkales</Authors>
<Version>1.3.1.0</Version>
<Version>1.4.0.0</Version>
<Description>HoardFarm Dalamud Plugin</Description>
<PackageProjectUrl>https://github.com/Jukkales/HoardFarm</PackageProjectUrl>
</PropertyGroup>
Expand Down Expand Up @@ -65,6 +65,7 @@

<ItemGroup>
<ProjectReference Include="..\ECommons\ECommons\ECommons.csproj"/>
<ProjectReference Include="..\AutoRetainerAPI\AutoRetainerAPI\AutoRetainerAPI.csproj"/>
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion HoardFarm/Model/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ public class Configuration : IPluginConfiguration
public int OverallFoundHoards { get; set; }
public int OverallTime { get; set; }
public bool ShowOverlay { get; set; } = true;
public bool ParanoidMode { get; set; } = false;
public bool ParanoidMode { get; set; }

public bool DoRetainers { get; set; }
public int RetainerMode { get; set; } = 1;

public void Save()
{
Expand Down
7 changes: 2 additions & 5 deletions HoardFarm/Service/AchievementService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace HoardFarm.Service;

public unsafe class AchievementService : IDisposable
public unsafe class AchievementService
{

public delegate void ReceiveAchievementProgressDelegate(Achievement* achievement, uint id, uint current, uint max);
Expand Down Expand Up @@ -33,8 +33,5 @@ private void ReceiveAchievementProgressDetour(Achievement* achievement, uint id,
}
ReceiveAchievementProgressHook.Original(achievement, id, current, max);
}

public void Dispose()
{
}

}
64 changes: 48 additions & 16 deletions HoardFarm/Service/HoardFarmService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using HoardFarm.IPC;
using HoardFarm.Model;
using HoardFarm.Tasks;
using HoardFarm.Tasks.TaskGroups;
using Lumina.Excel.GeneratedSheets;

namespace HoardFarm.Service;
Expand Down Expand Up @@ -140,6 +141,13 @@ private unsafe bool SearchLogic()

private void OnTimerUpdate(object? sender, ElapsedEventArgs e)
{
// Retainer do not increase runtime
if (RetainerScv.Running)
{
HoardModeStatus = "Retainer Running";
return;
}

SessionTime++;
Config.OverallTime++;

Expand All @@ -166,16 +174,14 @@ private void OnTimerUpdate(object? sender, ElapsedEventArgs e)
}
if (Player.Territory == HoHMapId1)
{
HoardModeStatus = "Please prepare";
HoardModeError = "Please prepare before starting.\nFloor One is not supported.";
FinishRun = true;
Enqueue(new LeaveDutyTask(), "Leave Duty");
Error("Please prepare before starting.\nFloor One is not supported.");
return;
}
if (!InHoH && !InRubySea && NotBusy() && !KyuseiInteractable())
{
HoardModeStatus = "Moving to HoH";
Enqueue(new MoveToHoHTask(), "Move to HoH");
Enqueue(new MoveToHoHTask());
EnqueueWait(1000);
}

if (InRubySea && NotBusy() && KyuseiInteractable())
Expand All @@ -186,12 +192,19 @@ private void OnTimerUpdate(object? sender, ElapsedEventArgs e)
HoardMode = false;
return;
}

if (CheckRetainer())
{
// Do retainers first
return;
}

HoardModeStatus = "Entering HoH";
if (Config.ParanoidMode)
{
EnqueueWait(Random.Shared.Next(3000, 6000));
}
Enqueue(new EnterHeavenOnHigh(), "Enter HoH");
Enqueue(new EnterHeavenOnHigh());
}

if (InHoH && NotBusy())
Expand All @@ -200,10 +213,8 @@ private void OnTimerUpdate(object? sender, ElapsedEventArgs e)
{
if (!CheckMinimalSetup())
{
HoardModeStatus = "Please prepare";
HoardModeError = "Please prepare before starting.\nYou need at least one Intuition Pomander\nand one Concealment.";
FinishRun = true;
Enqueue(new LeaveDutyTask(), "Leave Duty");
Error(
"Please prepare before starting.\nYou need at least one Intuition Pomander\nand one Concealment.");
return;
}

Expand All @@ -225,7 +236,7 @@ private void OnTimerUpdate(object? sender, ElapsedEventArgs e)
{
if (!Concealment)
{
Enqueue(new UsePomanderTask(Pomander.Concealment), "Use Concealment");
Enqueue(new UsePomanderTask(Pomander.Concealment, false), "Use Concealment");
}
Enqueue(new PathfindTask(hoardPosition, true, 1.5f), 60 * 1000, "Move to Hoard");
movingToHoard = true;
Expand Down Expand Up @@ -261,6 +272,17 @@ private void OnTimerUpdate(object? sender, ElapsedEventArgs e)
}
}

private bool CheckRetainer()
{
if (Config.DoRetainers && RetainerService.CheckRetainersDone(Config.RetainerMode == 1))
{
RetainerScv.StartProcess();
return true;
}

return false;
}

private bool CheckMinimalSetup()
{
if (!CanUsePomander(Pomander.Intuition))
Expand All @@ -275,12 +297,20 @@ private bool CheckMinimalSetup()
return CanUsePomander(Pomander.Safety) && CanUseMagicite();
}

private void LeaveDuty()
private void LeaveDuty(string message = "Leaving")
{
HoardModeStatus = "Leaving";
HoardModeStatus = message;
SessionRuns++;
Config.OverallRuns++;
Enqueue(new LeaveDutyTask(), "Leave Duty");
Enqueue(new LeaveDutyTask());
}

private void Error(string message)
{
HoardModeStatus = "Error";
HoardModeError = message;
FinishRun = true;
Enqueue(new LeaveDutyTask());
}

private void FindHoardPosition()
Expand Down Expand Up @@ -335,7 +365,8 @@ private void OnChatMessage(
{
intuitionUsed = true;
hoardAvailable = false;
HoardModeStatus = "No Hoard";
TaskManager.Abort();
LeaveDuty("No Hoard");
}

if (hoardFoundMessage.Equals(message.TextValue))
Expand All @@ -344,7 +375,8 @@ private void OnChatMessage(
SessionFoundHoards++;
Config.OverallFoundHoards++;
Achievements.Progress++;
HoardModeStatus = "Done";
TaskManager.Abort();
LeaveDuty("Done");
}
}

Expand Down
5 changes: 4 additions & 1 deletion HoardFarm/Service/PluginService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Game.ClientState.Objects;
using AutoRetainerAPI;
using Dalamud.Game.ClientState.Objects;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
Expand Down Expand Up @@ -43,4 +44,6 @@ public class PluginService
public static HoardFarmService HoardService { get; set; } = null!;
public static TaskManager TaskManager { get; set; } = null!;
public static AchievementService Achievements { get; set; } = null!;
public static AutoRetainerApi RetainerApi { get; set; } = null!;
public static RetainerService RetainerScv { get; set; } = null!;
}
Loading

0 comments on commit 7cf66da

Please sign in to comment.