Skip to content

Commit

Permalink
AutoHook 3.0.0.5 [PUSH]
Browse files Browse the repository at this point in the history
Possible fix for #124
JA Localization updated
  • Loading branch information
InitialDet committed Oct 18, 2023
1 parent d929dd5 commit 1e92857
Show file tree
Hide file tree
Showing 14 changed files with 248 additions and 64 deletions.
2 changes: 1 addition & 1 deletion AutoHook/AutoHook.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>Det</Authors>
<Version>3.0.0.4</Version>
<Version>3.0.0.5</Version>
<Description>Auto hooks for you</Description>
<PackageProjectUrl>https://github.com/InitialDet/AutoHook</PackageProjectUrl>
<Configurations>Release;Debug</Configurations>
Expand Down
33 changes: 18 additions & 15 deletions AutoHook/Classes/AutoCasts/AutoCordial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ namespace AutoHook.Classes.AutoCasts;
public class AutoCordial : BaseActionCast
{
private const uint CordialHiRecovery = 400;
private const uint CordialHqRecovery = 350;
private const uint CordialRecovery = 300;
private const uint CordialHqWateredRecovery = 200;
private const uint CordialWateredRecovery = 150;

private bool _invertCordialPriority;
public bool InvertCordialPriority;

public AutoCordial() : base(UIStrings.Cordial, IDs.Item.Cordial, ActionType.Item)
{
Expand All @@ -26,26 +24,31 @@ public override string GetName()

public override bool CastCondition()
{
var cordialList = new List<(uint, bool, uint)>
var cordialList = new List<(uint, uint)>
{
(IDs.Item.HiCordial, false, CordialHiRecovery),
(IDs.Item.Cordial, true, CordialHqRecovery), //Hq
(IDs.Item.Cordial, false, CordialRecovery),
(IDs.Item.WateredCordial, true, CordialHqWateredRecovery), // Hq
(IDs.Item.WateredCordial, false, CordialWateredRecovery)
(IDs.Item.HiCordial, CordialHiRecovery),
(IDs.Item.Cordial, CordialRecovery),
(IDs.Item.WateredCordial, CordialWateredRecovery)
};


if (_invertCordialPriority)
if (InvertCordialPriority)
cordialList.Reverse();

foreach (var (id, hq, recovery) in cordialList)
foreach (var (id, recovery) in cordialList)
{
if (!PlayerResources.HaveItemInInventory(id, hq))

if (!PlayerResources.HaveCordialInInventory(id, out bool isHq))
continue;

var cordialRecovery = recovery;

if (isHq)
cordialRecovery += 50; // yep hardcoded (thumbsup emoji)

Id = id;

var notOvercaped = PlayerResources.GetCurrentGp() + recovery < PlayerResources.GetMaxGp();
var notOvercaped = PlayerResources.GetCurrentGp() + cordialRecovery < PlayerResources.GetMaxGp();
return notOvercaped && PlayerResources.IsPotOffCooldown();
}

Expand All @@ -62,7 +65,7 @@ public override void SetThreshold(int newCost)

protected override DrawOptionsDelegate DrawOptions => () =>
{
if (DrawUtil.Checkbox(UIStrings.AutoCastCordialPriority, ref _invertCordialPriority))
if (DrawUtil.Checkbox(UIStrings.AutoCastCordialPriority, ref InvertCordialPriority))
{
Service.Save();
}
Expand Down
6 changes: 3 additions & 3 deletions AutoHook/Classes/AutoCasts/AutoFood.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace AutoHook.Classes.AutoCasts;

public class AutoFood : BaseActionCast
public class AutoFood : BaseActionCast //todo
{
private float _secondsRemaining = 0;
public float SecondsRemaining = 0;

public AutoFood() : base(UIStrings.Food_Buff, 0, ActionType.Item)
{
Expand All @@ -17,7 +17,7 @@ public override string GetName()

public override bool CastCondition()
{
if (PlayerResources.CheckFoodBuff() > _secondsRemaining)
if (PlayerResources.GetStatusTime() > SecondsRemaining)
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion AutoHook/Classes/AutoCasts/AutoMakeShiftBait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override bool CastCondition()
return false;


bool available = PlayerResources.ActionAvailable(IDs.Actions.MakeshiftBait);
bool available = PlayerResources.ActionTypeAvailable(IDs.Actions.MakeshiftBait);
bool hasStacks = PlayerResources.HasAnglersArtStacks(MakeshiftBaitStacks);

return hasStacks && available;
Expand Down
2 changes: 1 addition & 1 deletion AutoHook/Classes/AutoCasts/AutoMooch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override bool CastCondition()
return true;
}

if (PlayerResources.ActionAvailable(IDs.Actions.Mooch))
if (PlayerResources.ActionTypeAvailable(IDs.Actions.Mooch))
{
Service.PrintDebug(@$"Mooch Available, casting normal mooch");
Id = IDs.Actions.Mooch;
Expand Down
4 changes: 2 additions & 2 deletions AutoHook/Classes/AutoCasts/AutoPrizeCatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override bool CastCondition()
if (!Enabled)
return false;

if (UseWhenMoochIIOnCD && PlayerResources.ActionAvailable(IDs.Actions.Mooch2))
if (UseWhenMoochIIOnCD && PlayerResources.ActionTypeAvailable(IDs.Actions.Mooch2))
return false;

if (UseOnlyWithIdenticalCast && !PlayerResources.HasStatus(IDs.Status.IdenticalCast))
Expand All @@ -40,7 +40,7 @@ public override bool CastCondition()
if (PlayerResources.HasStatus(IDs.Status.AnglersFortune))
return false;

return PlayerResources.ActionAvailable(IDs.Actions.PrizeCatch);
return PlayerResources.ActionTypeAvailable(IDs.Actions.PrizeCatch);
}

protected override DrawOptionsDelegate DrawOptions => () =>
Expand Down
2 changes: 1 addition & 1 deletion AutoHook/Classes/BaseActionCast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public bool IsAvailableToCast()
else
hasGp = currentGp <= GpThreshold;

var actionAvailable = PlayerResources.ActionAvailable(Id, ActionType);
var actionAvailable = PlayerResources.ActionTypeAvailable(Id, ActionType);

return hasGp && actionAvailable && condition;
}
Expand Down
1 change: 0 additions & 1 deletion AutoHook/Configurations/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class Configuration : IPluginConfiguration
public int DelayBetweenCastsMax = 1000;

public bool ShowStatusHeader = true;


// old config
public List<BaitPresetConfig> BaitPresetList = new List<BaitPresetConfig>()!;
Expand Down
4 changes: 2 additions & 2 deletions AutoHook/HookManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private void HookFish(BiteType bite)
if (hook is null or HookType.None)
return;

if (PlayerResources.ActionAvailable((uint)hook)) // Check if Powerful/Precision is available
if (PlayerResources.ActionTypeAvailable((uint)hook)) // Check if Powerful/Precision is available
{
Service.PrintDebug(@$"[HookManager] Using {hook.ToString()} hook.");
PlayerResources.CastActionDelayed((uint)hook, ActionType.Action, @$"{hook.ToString()}");
Expand Down Expand Up @@ -501,7 +501,7 @@ private delegate bool UseActionDelegate(IntPtr manager, ActionType actionType, u
private bool OnUseAction(IntPtr manager, ActionType actionType, uint actionId, GameObjectID targetId, uint a4,
uint a5, uint a6, IntPtr a7)
{
if (actionType == ActionType.Action && PlayerResources.ActionAvailable(actionId))
if (actionType == ActionType.Action && PlayerResources.ActionTypeAvailable(actionId))
switch (actionId)
{
case IDs.Actions.Cast:
Expand Down
38 changes: 22 additions & 16 deletions AutoHook/PluginUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using AutoHook.Data;
using AutoHook.Resources.Localization;
using AutoHook.Utils;
using FFXIVClientStructs.FFXIV.Client.Game;

namespace AutoHook;

Expand Down Expand Up @@ -54,25 +56,21 @@ public override void Draw()
ImGui.Spacing();
DrawUtil.Checkbox(UIStrings.Enable_AutoHook, ref Service.Configuration.PluginEnabled,
UIStrings.PluginUi_Draw_Enables_Disables);


ShowKofi();
ImGui.SameLine();
ShowPaypal();

ImGui.Indent();

if (Service.Configuration.PluginEnabled)
{
ImGui.TextColored(ImGuiColors.HealerGreen, UIStrings.Plugin_Enabled);
}
else
{
ImGui.TextColored(ImGuiColors.DalamudRed, UIStrings.Plugin_Disabled);
}

ImGui.Unindent();
ImGui.Spacing();



DrawChangelog();
ImGui.SameLine();
DrawLanguageSelector();
Expand All @@ -86,9 +84,10 @@ public override void Draw()
}

ImGui.SameLine();

//TestButtons();

#if DEBUG
TestButtons();
#endif

Debug();

ImGui.Spacing();
Expand Down Expand Up @@ -134,7 +133,11 @@ private void Debug()
private static void TestButtons()
{
if (ImGui.Button(@"Check"))
{
{
Service.PrintChat("-----------------");
Service.PrintChat("Cordial Available: " + PlayerResources.ActionTypeAvailable(IDs.Item.HiCordial, ActionType.Item));
Service.PrintChat("Cast Available: " + PlayerResources.ActionTypeAvailable(IDs.Actions.Cast));

}
}

Expand Down Expand Up @@ -170,10 +173,11 @@ public override void OnClose()
Service.Save();
}

private static void ShowKofi()
public static void ShowKofi()
{
string buttonText = UIStrings.Support_me_on_Ko_fi;

ImGui.SameLine();
string buttonText = UIStrings.Support_me_on_Ko_fi;
ImGui.PushStyleColor(ImGuiCol.Button, 0xFF000000 | 0x005E5BFF);
ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0xDD000000 | 0x005E5BFF);
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0xAA000000 | 0x005E5BFF);
Expand All @@ -186,8 +190,10 @@ private static void ShowKofi()
ImGui.PopStyleColor(3);
}

private static void ShowPaypal()
public static void ShowPaypal()
{

ImGui.SameLine();
string buttonText = @"PayPal";
ImGui.SameLine();
ImGui.PushStyleColor(ImGuiCol.Button, 0xFFA06020);
Expand Down Expand Up @@ -243,7 +249,7 @@ private void DrawChangelog()
return;

ImGui.SetNextWindowSize(new Vector2(400, 0));
if (ImGui.Begin($"{UIStrings.Changelog}", ref _openChangelog, ImGuiWindowFlags.AlwaysAutoResize))
if (ImGui.Begin($"{UIStrings.Changelog}", ref _openChangelog))
{
var changes = PluginChangeLog.Versions;

Expand Down
Loading

0 comments on commit 1e92857

Please sign in to comment.