-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
71 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Automaton.Tasks; | ||
using Dalamud.Game.Gui.ContextMenu; | ||
|
||
namespace Automaton.Features; | ||
[Tweak] | ||
internal class RetrieveMateria : Tweak | ||
{ | ||
public override string Name => "Retrieve All Materia"; | ||
public override string Description => "Adds a context menu item that will retrieve all materia from an item."; | ||
|
||
public override void Enable() => Svc.ContextMenu.OnMenuOpened += OnOpenContextMenu; | ||
public override void Disable() => Svc.ContextMenu.OnMenuOpened -= OnOpenContextMenu; | ||
|
||
private void OnOpenContextMenu(IMenuOpenedArgs args) | ||
{ | ||
if (args.MenuType != ContextMenuType.Inventory || args.Target is not MenuTargetInventory inv || inv.TargetItem == null || inv.TargetItem.Value.ItemId == 0) return; | ||
args.AddMenuItem(new MenuItem | ||
{ | ||
PrefixChar = 'C', | ||
Name = "Retrieve All Materia", | ||
OnClicked = (a) => P.Automation.Start(new RetrieveAllMateria(inv.TargetItem.Value)), | ||
IsEnabled = inv.TargetItem.Value.Materia.ToArray().Any(m => m != 0) && !Svc.Condition[ConditionFlag.Occupied39], | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Dalamud.Game.Inventory; | ||
using FFXIVClientStructs.FFXIV.Client.Game; | ||
using FFXIVClientStructs.FFXIV.Client.Game.Event; | ||
using System.Threading.Tasks; | ||
|
||
namespace Automaton.Tasks; | ||
public sealed class RetrieveAllMateria(GameInventoryItem item) : CommonTasks | ||
{ | ||
protected override async Task Execute() | ||
{ | ||
Status = $"Retrieving Materia"; | ||
var materias = item.Materia.ToArray().Where(x => x != 0); | ||
foreach (var materia in materias) | ||
{ | ||
Retrieve(); | ||
await WaitUntilThenFalse(() => Svc.Condition[ConditionFlag.Occupied39], "RetrivingMateria"); | ||
} | ||
} | ||
|
||
private unsafe void Retrieve() | ||
{ | ||
try | ||
{ | ||
var _item = (InventoryItem*)item.Address; | ||
P.Memory.RetrieveMateria?.Invoke(EventFramework.Instance(), 0x390001, _item->Container, _item->Slot, 0); | ||
} | ||
catch (Exception e) { e.Log(); } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters