105 lines
2.5 KiB
C#
105 lines
2.5 KiB
C#
using Dalamud.Game.ClientState.Conditions;
|
|
using Dalamud.Plugin.Services;
|
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
|
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
|
using LLib.GameUI;
|
|
|
|
namespace LLib.Buddy;
|
|
|
|
public static class BuddyActions
|
|
{
|
|
public const uint GysahlGreensItemId = 4868u;
|
|
|
|
private const uint SummonCompanionActionId = 24u;
|
|
|
|
private const uint DismissCompanionActionId = 25u;
|
|
|
|
public unsafe static bool TrySummonCompanion()
|
|
{
|
|
ActionManager* ptr = ActionManager.Instance();
|
|
if (ptr == null)
|
|
{
|
|
return false;
|
|
}
|
|
return ptr->UseAction(ActionType.GeneralAction, 24u, 3758096384uL, 0u, ActionManager.UseActionMode.None, 0u, null);
|
|
}
|
|
|
|
public unsafe static bool TryDismissCompanion()
|
|
{
|
|
ActionManager* ptr = ActionManager.Instance();
|
|
if (ptr == null)
|
|
{
|
|
return false;
|
|
}
|
|
return ptr->UseAction(ActionType.GeneralAction, 25u, 3758096384uL, 0u, ActionManager.UseActionMode.None, 0u, null);
|
|
}
|
|
|
|
public static bool TrySetOrder(byte order)
|
|
{
|
|
if (!BuddyStateHelper.IsCompanionSummoned())
|
|
{
|
|
return false;
|
|
}
|
|
GameMain.ExecuteCommand(500, order);
|
|
return true;
|
|
}
|
|
|
|
public unsafe static bool IsCompanionUnlocked()
|
|
{
|
|
UIState* ptr = UIState.Instance();
|
|
if (ptr != null)
|
|
{
|
|
return ptr->IsUnlockLinkUnlocked(8u);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public unsafe static bool CanSummonCompanion(ICondition condition)
|
|
{
|
|
if (!IsCompanionUnlocked())
|
|
{
|
|
return false;
|
|
}
|
|
if (BuddyStateHelper.IsCompanionSummoned())
|
|
{
|
|
return false;
|
|
}
|
|
if (condition[ConditionFlag.BoundByDuty] || condition[ConditionFlag.Mounted] || condition[ConditionFlag.InCombat])
|
|
{
|
|
return false;
|
|
}
|
|
InventoryManager* ptr = InventoryManager.Instance();
|
|
if (ptr == null || ptr->GetInventoryItemCount(4868u, isHq: false, checkEquipped: true, checkArmory: true, 0) == 0)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public unsafe static bool IsFeedAddonReady(IGameGui gameGui)
|
|
{
|
|
AtkUnitBase* addonPtr;
|
|
return gameGui.TryGetReadyAddon<AtkUnitBase>("BuddyFeed", out addonPtr);
|
|
}
|
|
|
|
public unsafe static bool TrySelectFeedItem(IGameGui gameGui, int index)
|
|
{
|
|
if (!gameGui.TryGetReadyAddon<AtkUnitBase>("BuddyFeed", out var addonPtr))
|
|
{
|
|
return false;
|
|
}
|
|
AddonCallback.Fire(addonPtr, 0, index);
|
|
return true;
|
|
}
|
|
|
|
public unsafe static bool TryConfirmFeed(IGameGui gameGui)
|
|
{
|
|
if (!gameGui.TryGetReadyAddon<AtkUnitBase>("SelectYesno", out var addonPtr))
|
|
{
|
|
return false;
|
|
}
|
|
AddonCallback.ClickYes(addonPtr);
|
|
return true;
|
|
}
|
|
}
|