Skip to content

Commit

Permalink
AutoHook 2.4.2.3 [PUSH]
Browse files Browse the repository at this point in the history
#66 Fix
plus minor fixes
  • Loading branch information
InitialDet committed Jan 31, 2023
1 parent c77375a commit 4ddcebd
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 76 deletions.
1 change: 0 additions & 1 deletion AutoHook/AutoHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class AutoHook : IDalamudPlugin

private static AutoGig AutoGig = null!;


public HookingManager HookManager;

PlayerResources PlayerResources;
Expand Down
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>2.4.2.2</Version>
<Version>2.4.2.3</Version>
<Description>Auto hooks for you</Description>
<PackageProjectUrl>https://github.com/InitialDet/AutoHook</PackageProjectUrl>
<Configurations>Release;Debug</Configurations>
Expand Down
4 changes: 2 additions & 2 deletions AutoHook/Classes/AvailableAutoCast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public override bool CastCondition()
if (PlayerResources.HasStatus(IDs.Status.PrizeCatch))
return false;

if (PlayerResources.HasStatus(IDs.Status.MakeshiftBait) && !AutoCastsConfig.EnableMakeshiftPatience)
if (PlayerResources.HasStatus(IDs.Status.MakeshiftBait) && !_acConfig.EnableMakeshiftPatience)
return false;

return true;
Expand All @@ -208,7 +208,7 @@ public override bool CastCondition()
if (PlayerResources.HasStatus(IDs.Status.PrizeCatch))
return false;

if (PlayerResources.HasStatus(IDs.Status.MakeshiftBait) && !AutoCastsConfig.EnableMakeshiftPatience)
if (PlayerResources.HasStatus(IDs.Status.MakeshiftBait) && !_acConfig.EnableMakeshiftPatience)
return false;

return true;
Expand Down
10 changes: 2 additions & 8 deletions AutoHook/Classes/BaseActionCast.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
using AutoHook.Configurations;
using AutoHook.Data;
using AutoHook.Utils;
using Dalamud.Logging;
using FFXIVClientStructs.FFXIV.Client.Game;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoHook.Classes;
public abstract class BaseActionCast
{
protected BaitConfig? _baitConfig = null;
protected readonly static AutoCastsConfig _acConfig = Service.Configuration.AutoCastsCfg;

protected BaseActionCast(string name, uint id, ActionType actionType = ActionType.Spell)
{
Expand Down Expand Up @@ -56,7 +50,7 @@ public bool IsAvailableToCast(BaitConfig? baitConfig)
if (!Enabled)
return false;

if (DoesCancelMooch && AutoCastsConfig.IsMoochAvailable && AutoCastsConfig.DontCancelMooch)
if (DoesCancelMooch && PlayerResources.IsMoochAvailable() && _acConfig.DontCancelMooch)
return false;

uint currentGp = PlayerResources.GetCurrentGP();
Expand Down
21 changes: 2 additions & 19 deletions AutoHook/Configurations/AutoCastsConfig.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Collections.Generic;
using AutoHook.Classes;
using AutoHook.Data;
using AutoHook.Utils;
using Dalamud.Logging;
using FFXIVClientStructs.FFXIV.Client.Game;

namespace AutoHook.Configurations;
Expand All @@ -17,9 +15,9 @@ public class AutoCastsConfig
public bool OnlyMoochIntuition = false;

public bool EnablePatience = false;
public static bool EnableMakeshiftPatience = false;
public bool EnableMakeshiftPatience = false;

public static bool DontCancelMooch = true;
public bool DontCancelMooch = true;

public uint SelectedPatienceID = IDs.Actions.Patience2; // Default to Patience2

Expand Down Expand Up @@ -53,7 +51,6 @@ public class AutoCastsConfig

public bool EnableCordialFirst = false;

public static bool IsMoochAvailable = false;

// i could make the code more optimized but im too lazy rn.
public AutoCast? GetNextAutoCast(BaitConfig? baitConfig)
Expand All @@ -63,8 +60,6 @@ public class AutoCastsConfig

BaitConfig = baitConfig;

IsMoochAvailable = CheckMoochAvailable();

if (!PlayerResources.ActionAvailable(IDs.Actions.Cast))
return null;

Expand Down Expand Up @@ -158,18 +153,6 @@ private bool UseMooch(out uint id)
return false;
}

private bool CheckMoochAvailable()
{
if (PlayerResources.ActionAvailable(IDs.Actions.Mooch))
return true;

else if (PlayerResources.ActionAvailable(IDs.Actions.Mooch2))
return true;

return false;
}


private BaseActionCast? GetCordials()
{
bool useCordial = false;
Expand Down
14 changes: 7 additions & 7 deletions AutoHook/Ui/TabAutoCasts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void DrawHeader()
if (cfg.EnableAll)
{
ImGui.SameLine();
if (DrawUtil.Checkbox("Don't Cancel Mooch", ref AutoCastsConfig.DontCancelMooch, "Actions that cancel mooch wont be used (e.g. Chum, Fish Eyes, Prize Catch etc.)"))
if (DrawUtil.Checkbox("Don't Cancel Mooch", ref cfg.DontCancelMooch, "Actions that cancel mooch wont be used (e.g. Chum, Fish Eyes, Prize Catch etc.)"))
{
Service.Configuration.Save();
}
Expand Down Expand Up @@ -102,7 +102,7 @@ private void DrawExtraOptionsAutoMooch()
Service.Configuration.Save();
}

if (ImGui.Checkbox("Only use when Fisher's Intution is active", ref cfg.OnlyMoochIntuition))
if (ImGui.Checkbox("Only use when Fisher's Intution is active##fi_mooch", ref cfg.OnlyMoochIntuition))
{
Service.Configuration.Save();
}
Expand Down Expand Up @@ -130,11 +130,11 @@ private void DrawPatience()
private void DrawExtraOptionsPatience()
{

var enabled = AutoCastsConfig.EnableMakeshiftPatience;
var enabled = cfg.EnableMakeshiftPatience;

if (DrawUtil.Checkbox("Use when Makeshift Bait is active", ref enabled))
if (DrawUtil.Checkbox("Use when Makeshift Bait is active##patience_makeshift", ref enabled))
{
AutoCastsConfig.EnableMakeshiftPatience = enabled;
cfg.EnableMakeshiftPatience = enabled;
Service.Configuration.Save();
}

Expand Down Expand Up @@ -244,7 +244,7 @@ private void DrawExtraOptionPrizeCatch()
if (DrawUtil.Checkbox("Only use when Mooch II is on NOT available - READ >>>", ref cfg.AutoPrizeCatch.UseWhenMoochIIOnCD, ">Make sure 'Use Mooch II' is enabled or else it wont work<\nThis could save you 100gp if going only for mooches"))
{ }

if (DrawUtil.Checkbox("Only use when Identical Cast is active", ref cfg.AutoPrizeCatch.UseOnlyWithIdenticalCast))
if (DrawUtil.Checkbox("Only use when Identical Cast is active##ic_prize_catch", ref cfg.AutoPrizeCatch.UseOnlyWithIdenticalCast))
{ }
}

Expand All @@ -267,7 +267,7 @@ private void DrawChum()

private void DrawExtraOptionsChum()
{
if (DrawUtil.Checkbox("Only use when Fisher's Intution is active", ref cfg.AutoChum.OnlyUseWithIntuition))
if (DrawUtil.Checkbox("Only use when Fisher's Intution is active##fi_chum", ref cfg.AutoChum.OnlyUseWithIntuition))
{ }
}

Expand Down
4 changes: 2 additions & 2 deletions AutoHook/Ui/TabBaseConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void DrawCheckBoxDoubleTripleHook(BaitConfig cfg)
ImGui.TextColored(ImGuiColors.DalamudYellow, "Double/Triple Hook Settings");
ImGui.Spacing();

ImGui.Checkbox("Only use when Identical Cast is active", ref cfg.UseDHTHOnlySurfaceSlap);
ImGui.Checkbox("Only use when Identical Cast is active##surface_slap", ref cfg.UseDHTHOnlySurfaceSlap);
ImGui.Spacing();
ImGui.Separator();
ImGui.Spacing();
Expand Down Expand Up @@ -298,7 +298,7 @@ public void DrawAutoMooch(BaitConfig cfg)
Service.Configuration.Save();
}

if (ImGui.Checkbox("Only use when Fisher's Intution is active", ref cfg.OnlyMoochIntuition))
if (ImGui.Checkbox("Only use when Fisher's Intution is active##Mooch", ref cfg.OnlyMoochIntuition))
{
Service.Configuration.Save();
}
Expand Down
16 changes: 9 additions & 7 deletions AutoHook/Ui/TabGeneral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,17 @@ private void DrawChangelog()
ImGui.TextWrapped("- Added changelog button");

ImGui.Separator();
ImGui.TextWrapped("2.4.2.1");
ImGui.TextWrapped("- Gig hitbox enabled by default");
ImGui.Separator();
ImGui.Spacing();

if (ImGui.TreeNode("2.4.2.X - Small Fixes"))
{
ImGui.TextWrapped("- Gig hitbox is now enabled by default");
ImGui.TextWrapped("- Fixed the order of the Chum Timer Min/Max fields");
ImGui.TextWrapped("- Fixed some options not saving correctly");
ImGui.TreePop();
}

ImGui.TextWrapped("2.4.2.2");
ImGui.TextWrapped("- Fixed order of Chum Timer Min/Max fields");
ImGui.Separator();
ImGui.Spacing();
ImGui.Spacing();

if (ImGui.BeginChild("old_versions", new Vector2(0, 150), true))
{
Expand Down
41 changes: 12 additions & 29 deletions AutoHook/Utils/PlayerResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ public void Dispose()
//receiveActionEffectHook?.Disable();
}


public static bool IsMoochAvailable()
{
if (ActionAvailable(IDs.Actions.Mooch))
return true;

else if (ActionAvailable(IDs.Actions.Mooch2))
return true;

return false;
}

public static bool HasStatus(uint statusID)
{
if (Service.ClientState.LocalPlayer?.StatusList == null)
Expand Down Expand Up @@ -141,7 +153,6 @@ public static unsafe float GetPotCooldown()
public static unsafe bool HaveItemInInventory(uint id, bool isHQ = false)
=> InventoryManager.Instance()->GetInventoryItemCount(id, isHQ) > 0;


static bool isCastingDelay = false;
static uint NextActionID = 0;
static uint LastActionID = 0;
Expand Down Expand Up @@ -179,7 +190,6 @@ public static void CastActionDelayed(uint id, ActionType actionType = ActionType
}
}


static bool isCastingNoDelay = false;

public static void CastActionNoDelay(uint id, ActionType actionType = ActionType.Spell)
Expand All @@ -203,23 +213,6 @@ public static void CastActionNoDelay(uint id, ActionType actionType = ActionType
isCastingNoDelay = false;
}

/*
private void ReceiveActionEffectDetour(int sourceObjectId, IntPtr sourceActor, IntPtr position, IntPtr effectHeader, IntPtr effectArray, IntPtr effectTrail)
{
receiveActionEffectHook!.Original(sourceObjectId, sourceActor, position, effectHeader, effectArray, effectTrail);
ActionEffectHeader header = Marshal.PtrToStructure<ActionEffectHeader>(effectHeader);
if (sourceObjectId == Service.ClientState.LocalPlayer?.ObjectId)
{
if (header.ActionId == LastActionID)
{
LastActionID = NextActionID;
ResetAutoCast();
}
}
}*/

public static async void ResetAutoCast()
{
if (delay <= 0)
Expand Down Expand Up @@ -247,14 +240,4 @@ private static int ConditionalDelay() =>
_ => 0,
};

[StructLayout(LayoutKind.Explicit)]
private struct ActionEffectHeader
{
[FieldOffset(0x0)] public long TargetObjectId;
[FieldOffset(0x8)] public uint ActionId;
[FieldOffset(0x14)] public uint UnkObjectId;
[FieldOffset(0x18)] public ushort Sequence;
[FieldOffset(0x1A)] public ushort Unk_1A;
}

}

0 comments on commit 4ddcebd

Please sign in to comment.