Skip to content

Commit

Permalink
AutoHook 3.0.0.7 [PUSH]
Browse files Browse the repository at this point in the history
Okay now i promise cordials work
  • Loading branch information
InitialDet committed Oct 18, 2023
1 parent f6a39fb commit e8e9e55
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 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.6</Version>
<Version>3.0.0.7</Version>
<Description>Auto hooks for you</Description>
<PackageProjectUrl>https://github.com/InitialDet/AutoHook</PackageProjectUrl>
<Configurations>Release;Debug</Configurations>
Expand Down
39 changes: 24 additions & 15 deletions AutoHook/Classes/AutoCasts/AutoCordial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,30 @@ 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;

public bool InvertCordialPriority;

private readonly List<(uint, uint)> _cordialList = new()
{
(IDs.Item.HiCordial, CordialHiRecovery),
(IDs.Item.HQCordial, CordialHqRecovery),
(IDs.Item.Cordial, CordialRecovery),
(IDs.Item.HQWateredCordial, CordialHqWateredRecovery),
(IDs.Item.WateredCordial, CordialWateredRecovery)
};

private readonly List<(uint, uint)> _invertedList = new()
{
(IDs.Item.HQWateredCordial, CordialHqWateredRecovery),
(IDs.Item.WateredCordial, CordialWateredRecovery),
(IDs.Item.HQCordial, CordialHqRecovery),
(IDs.Item.Cordial, CordialRecovery),
(IDs.Item.HiCordial, CordialHiRecovery)
};

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

public override bool CastCondition()
{
var cordialList = new List<(uint, uint)>
{
(IDs.Item.HiCordial, CordialHiRecovery),
(IDs.Item.Cordial, CordialRecovery),
(IDs.Item.WateredCordial, CordialWateredRecovery)
};
var cordialList = _cordialList;


if (InvertCordialPriority)
cordialList.Reverse();
cordialList = _invertedList;

foreach (var (id, recovery) in cordialList)
{
if (!PlayerResources.HaveCordialInInventory(id, out bool isHq))
if (!PlayerResources.HaveCordialInInventory(id))
continue;

var cordialRecovery = recovery;

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

Id = id;

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

Expand Down
6 changes: 3 additions & 3 deletions AutoHook/PluginUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ private static unsafe 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));
Service.PrintChat("Quant. Available: " + InventoryManager.Instance()->GetInventoryItemCount(IDs.Item.HiCordial));
Service.PrintChat("Watered Available: " + InventoryManager.Instance()->GetInventoryItemCount(IDs.Item.WateredCordial));
Service.PrintChat("HQ Watered Available: " + InventoryManager.Instance()->GetInventoryItemCount(IDs.Item.HQWateredCordial));


}
}
Expand Down
15 changes: 3 additions & 12 deletions AutoHook/Utils/PlayerResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ public static unsafe int GetRecastGroups(uint id, ActionType actionType = Action

public static unsafe void UseItems(uint id)
{
if (InventoryManager.Instance()->GetInventoryItemCount(id) > 0)
AgentInventoryContext.Instance()->UseItem(id);
AgentInventoryContext.Instance()->UseItem(id);
}

// RecastGroup 68 = Cordial pots
Expand Down Expand Up @@ -187,17 +186,9 @@ public static unsafe float GetCooldown(uint id, ActionType actionType)
public static unsafe bool HaveItemInInventory(uint id, bool isHQ = false)
=> InventoryManager.Instance()->GetInventoryItemCount(id, isHQ) > 0;

public static unsafe bool HaveCordialInInventory(uint id, out bool isHq)
public static unsafe bool HaveCordialInInventory(uint id)
{
isHq = false;

if (InventoryManager.Instance()->GetInventoryItemCount(id, true) > 0)
{
isHq = true;
return true;
}

return InventoryManager.Instance()->GetInventoryItemCount(id, false) > 0;
return InventoryManager.Instance()->GetInventoryItemCount(id) > 0;
}


Expand Down

0 comments on commit e8e9e55

Please sign in to comment.