Seal purchase options
This commit is contained in:
parent
b069af3a24
commit
facac551ca
@ -40,6 +40,7 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
|
|
||||||
private Stage _currentStageInternal = Stage.Stop;
|
private Stage _currentStageInternal = Stage.Stop;
|
||||||
private DateTime _continueAt = DateTime.MinValue;
|
private DateTime _continueAt = DateTime.MinValue;
|
||||||
|
private SealPurchaseOption? _selectedPurchaseOption;
|
||||||
|
|
||||||
public DeliverooPlugin(DalamudPluginInterface pluginInterface, ChatGui chatGui, GameGui gameGui,
|
public DeliverooPlugin(DalamudPluginInterface pluginInterface, ChatGui chatGui, GameGui gameGui,
|
||||||
Framework framework, ClientState clientState, ObjectTable objectTable, TargetManager targetManager)
|
Framework framework, ClientState clientState, ObjectTable objectTable, TargetManager targetManager)
|
||||||
@ -70,6 +71,7 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
{
|
{
|
||||||
PluginLog.Information($"Changing stage from {_currentStageInternal} to {value}");
|
PluginLog.Information($"Changing stage from {_currentStageInternal} to {value}");
|
||||||
_currentStageInternal = value;
|
_currentStageInternal = value;
|
||||||
|
_turnInWindow.Debug = CurrentStage.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +88,6 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
{
|
{
|
||||||
_turnInWindow.IsOpen = true;
|
_turnInWindow.IsOpen = true;
|
||||||
_turnInWindow.Multiplier = GetSealMultiplier();
|
_turnInWindow.Multiplier = GetSealMultiplier();
|
||||||
_turnInWindow.CurrentVentureCount = GetCurrentVentureCount();
|
|
||||||
|
|
||||||
if (!_turnInWindow.State)
|
if (!_turnInWindow.State)
|
||||||
{
|
{
|
||||||
@ -97,9 +98,21 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
if (_turnInWindow.State && CurrentStage == Stage.Stop)
|
if (_turnInWindow.State && CurrentStage == Stage.Stop)
|
||||||
{
|
{
|
||||||
CurrentStage = Stage.TargetPersonnelOfficer;
|
CurrentStage = Stage.TargetPersonnelOfficer;
|
||||||
|
_selectedPurchaseOption = _turnInWindow.SelectedOption;
|
||||||
|
if (_selectedPurchaseOption.ItemId == 0)
|
||||||
|
_selectedPurchaseOption = null;
|
||||||
|
else if (GetCurrentSealCount() > GetSealCap() / 2)
|
||||||
|
CurrentStage = Stage.TargetQuartermaster;
|
||||||
|
|
||||||
|
if (TryGetAddonByName<AddonGrandCompanySupplyList>("GrandCompanySupplyList", out var gcSupplyList) &&
|
||||||
|
IsAddonReady(&gcSupplyList->AtkUnitBase))
|
||||||
|
CurrentStage = Stage.SelectItemToTurnIn;
|
||||||
|
|
||||||
|
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var gcExchange) &&
|
||||||
|
IsAddonReady(gcExchange))
|
||||||
|
CurrentStage = Stage.CloseGcExchange;
|
||||||
}
|
}
|
||||||
|
|
||||||
_turnInWindow.Debug = CurrentStage.ToString();
|
|
||||||
switch (CurrentStage)
|
switch (CurrentStage)
|
||||||
{
|
{
|
||||||
case Stage.TargetPersonnelOfficer:
|
case Stage.TargetPersonnelOfficer:
|
||||||
@ -159,6 +172,17 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case Stage.TurnInSelected:
|
case Stage.TurnInSelected:
|
||||||
|
if (TryGetAddonByName<AddonSelectYesno>("SelectYesno", out var addonSelectYesno) &&
|
||||||
|
IsAddonReady(&addonSelectYesno->AtkUnitBase))
|
||||||
|
{
|
||||||
|
if (MemoryHelper.ReadSeString(&addonSelectYesno->PromptText->NodeText).ToString()
|
||||||
|
.StartsWith("Do you really want to trade a high-quality item?"))
|
||||||
|
{
|
||||||
|
addonSelectYesno->AtkUnitBase.FireCallbackInt(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (TryGetAddonByName<AddonGrandCompanySupplyReward>("GrandCompanySupplyReward",
|
if (TryGetAddonByName<AddonGrandCompanySupplyReward>("GrandCompanySupplyReward",
|
||||||
out var addonSupplyReward) && IsAddonReady(&addonSupplyReward->AtkUnitBase))
|
out var addonSupplyReward) && IsAddonReady(&addonSupplyReward->AtkUnitBase))
|
||||||
{
|
{
|
||||||
@ -188,9 +212,17 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
case Stage.CloseGcSupply:
|
case Stage.CloseGcSupply:
|
||||||
if (SelectSelectString(3))
|
if (SelectSelectString(3))
|
||||||
{
|
{
|
||||||
// you can occasionally get a 'not enough seals' warning lol
|
if (_selectedPurchaseOption == null)
|
||||||
_continueAt = DateTime.Now.AddSeconds(1);
|
{
|
||||||
CurrentStage = Stage.TargetQuartermaster;
|
_turnInWindow.State = false;
|
||||||
|
CurrentStage = Stage.Stop;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// you can occasionally get a 'not enough seals' warning lol
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(1);
|
||||||
|
CurrentStage = Stage.TargetQuartermaster;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -198,7 +230,12 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
case Stage.CloseGcSupplyThenStop:
|
case Stage.CloseGcSupplyThenStop:
|
||||||
if (SelectSelectString(3))
|
if (SelectSelectString(3))
|
||||||
{
|
{
|
||||||
if (GetCurrentSealCount() <= 2000 + 200)
|
if (_selectedPurchaseOption == null)
|
||||||
|
{
|
||||||
|
_turnInWindow.State = false;
|
||||||
|
CurrentStage = Stage.Stop;
|
||||||
|
}
|
||||||
|
else if (GetCurrentSealCount() <= 2000 + _selectedPurchaseOption!.SealCost)
|
||||||
{
|
{
|
||||||
_turnInWindow.State = false;
|
_turnInWindow.State = false;
|
||||||
CurrentStage = Stage.Stop;
|
CurrentStage = Stage.Stop;
|
||||||
@ -234,7 +271,7 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
var selectRank = stackalloc AtkValue[]
|
var selectRank = stackalloc AtkValue[]
|
||||||
{
|
{
|
||||||
new() { Type = ValueType.Int, Int = 1 },
|
new() { Type = ValueType.Int, Int = 1 },
|
||||||
new() { Type = ValueType.Int, Int = 0 /* position within list */ },
|
new() { Type = ValueType.Int, Int = (int)_selectedPurchaseOption!.Rank },
|
||||||
new() { Type = 0, Int = 0 },
|
new() { Type = 0, Int = 0 },
|
||||||
new() { Type = 0, Int = 0 },
|
new() { Type = 0, Int = 0 },
|
||||||
new() { Type = 0, Int = 0 },
|
new() { Type = 0, Int = 0 },
|
||||||
@ -259,13 +296,7 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
var selectType = stackalloc AtkValue[]
|
var selectType = stackalloc AtkValue[]
|
||||||
{
|
{
|
||||||
new() { Type = ValueType.Int, Int = 2 },
|
new() { Type = ValueType.Int, Int = 2 },
|
||||||
/*
|
new() { Type = ValueType.Int, Int = (int)_selectedPurchaseOption!.Type },
|
||||||
* 2 = weapons
|
|
||||||
* 3 = armor
|
|
||||||
* 1 = materiel
|
|
||||||
* 4 = materials
|
|
||||||
*/
|
|
||||||
new() { Type = ValueType.Int, Int = 1 /* position within list */ },
|
|
||||||
new() { Type = 0, Int = 0 },
|
new() { Type = 0, Int = 0 },
|
||||||
new() { Type = 0, Int = 0 },
|
new() { Type = 0, Int = 0 },
|
||||||
new() { Type = 0, Int = 0 },
|
new() { Type = 0, Int = 0 },
|
||||||
@ -288,20 +319,24 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
||||||
IsAddonReady(addonExchange))
|
IsAddonReady(addonExchange))
|
||||||
{
|
{
|
||||||
int venturesToBuy = (GetCurrentSealCount() - 2000) / 200;
|
int toBuy = (GetCurrentSealCount() - 2000) / _selectedPurchaseOption!.SealCost;
|
||||||
venturesToBuy = Math.Min(venturesToBuy, 65000 - GetCurrentVentureCount());
|
bool isVenture = _selectedPurchaseOption!.ItemId == 21072;
|
||||||
if (venturesToBuy == 0)
|
if (isVenture)
|
||||||
|
toBuy = Math.Min(toBuy, 65000 - GetCurrentVentureCount());
|
||||||
|
|
||||||
|
if (toBuy == 0)
|
||||||
{
|
{
|
||||||
|
_turnInWindow.State = false;
|
||||||
CurrentStage = Stage.Stop;
|
CurrentStage = Stage.Stop;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_chatGui.Print($"Buying {venturesToBuy} ventures...");
|
_chatGui.Print($"Buying {toBuy}x {_selectedPurchaseOption!.Name}...");
|
||||||
var selectReward = stackalloc AtkValue[]
|
var selectReward = stackalloc AtkValue[]
|
||||||
{
|
{
|
||||||
new() { Type = ValueType.Int, Int = 0 },
|
new() { Type = ValueType.Int, Int = 0 },
|
||||||
new() { Type = ValueType.Int, Int = 0 /* position within list?? */ },
|
new() { Type = ValueType.Int, Int = _selectedPurchaseOption!.Position },
|
||||||
new() { Type = ValueType.Int, Int = venturesToBuy },
|
new() { Type = ValueType.Int, Int = toBuy },
|
||||||
new() { Type = 0, Int = 0 },
|
new() { Type = 0, Int = 0 },
|
||||||
new() { Type = ValueType.Bool, Byte = 1 },
|
new() { Type = ValueType.Bool, Byte = 1 },
|
||||||
new() { Type = ValueType.Bool, Byte = 0 },
|
new() { Type = ValueType.Bool, Byte = 0 },
|
||||||
@ -310,13 +345,22 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
new() { Type = 0, Int = 0 }
|
new() { Type = 0, Int = 0 }
|
||||||
};
|
};
|
||||||
addonExchange->FireCallback(9, selectReward);
|
addonExchange->FireCallback(9, selectReward);
|
||||||
_continueAt = DateTime.Now.AddSeconds(1);
|
_continueAt = DateTime.Now.AddSeconds(0.5);
|
||||||
CurrentStage = Stage.CloseGcExchange;
|
CurrentStage = Stage.ConfirmReward;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case Stage.ConfirmReward:
|
||||||
|
if (SelectSelectYesno(0))
|
||||||
|
{
|
||||||
|
CurrentStage = Stage.CloseGcExchange;
|
||||||
|
_continueAt = DateTime.Now.AddSeconds(0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case Stage.CloseGcExchange:
|
case Stage.CloseGcExchange:
|
||||||
{
|
{
|
||||||
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
if (TryGetAddonByName<AtkUnitBase>("GrandCompanyExchange", out var addonExchange) &&
|
||||||
@ -521,6 +565,18 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private unsafe bool SelectSelectYesno(int choice)
|
||||||
|
{
|
||||||
|
if (TryGetAddonByName<AddonSelectYesno>("SelectYesno", out var addonSelectYesno) &&
|
||||||
|
IsAddonReady(&addonSelectYesno->AtkUnitBase))
|
||||||
|
{
|
||||||
|
addonSelectYesno->AtkUnitBase.FireCallbackInt(choice);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private decimal GetSealMultiplier()
|
private decimal GetSealMultiplier()
|
||||||
{
|
{
|
||||||
// priority seal allowance
|
// priority seal allowance
|
||||||
@ -563,6 +619,7 @@ public class DeliverooPlugin : IDalamudPlugin
|
|||||||
SelectRewardRank,
|
SelectRewardRank,
|
||||||
SelectRewardType,
|
SelectRewardType,
|
||||||
SelectReward,
|
SelectReward,
|
||||||
|
ConfirmReward,
|
||||||
CloseGcExchange,
|
CloseGcExchange,
|
||||||
|
|
||||||
Stop,
|
Stop,
|
||||||
|
39
Deliveroo/SealPurchaseOption.cs
Normal file
39
Deliveroo/SealPurchaseOption.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace Deliveroo;
|
||||||
|
|
||||||
|
internal sealed class SealPurchaseOption
|
||||||
|
{
|
||||||
|
public SealPurchaseOption(uint itemId, string name, PurchaseRank rank, PurchaseType type, int position,
|
||||||
|
int sealCost)
|
||||||
|
{
|
||||||
|
ItemId = itemId;
|
||||||
|
Name = name;
|
||||||
|
Rank = rank;
|
||||||
|
Type = type;
|
||||||
|
Position = position;
|
||||||
|
SealCost = sealCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint ItemId { get; }
|
||||||
|
public string Name { get; }
|
||||||
|
public PurchaseRank Rank { get; }
|
||||||
|
public PurchaseType Type { get; }
|
||||||
|
public int Position { get; }
|
||||||
|
public int SealCost { get; }
|
||||||
|
|
||||||
|
public enum PurchaseRank : int
|
||||||
|
{
|
||||||
|
First = 0,
|
||||||
|
Second = 1,
|
||||||
|
Third = 2,
|
||||||
|
Unknown = int.MaxValue,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PurchaseType : int
|
||||||
|
{
|
||||||
|
Materiel = 1,
|
||||||
|
Weapons = 2,
|
||||||
|
Armor = 3,
|
||||||
|
Materials = 4,
|
||||||
|
Unknown = int.MaxValue,
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,29 @@
|
|||||||
using System.Numerics;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
using Dalamud.Interface.Colors;
|
using Dalamud.Interface.Colors;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
namespace Deliveroo;
|
namespace Deliveroo;
|
||||||
|
|
||||||
internal sealed class TurnInWindow : Window
|
internal sealed class TurnInWindow : Window
|
||||||
{
|
{
|
||||||
|
private int _sealPurchaseSelected = 0;
|
||||||
|
|
||||||
|
private readonly List<SealPurchaseOption> _sealPurchaseOptions = new()
|
||||||
|
{
|
||||||
|
new SealPurchaseOption(0, "Buy Nothing", SealPurchaseOption.PurchaseRank.Unknown,
|
||||||
|
SealPurchaseOption.PurchaseType.Unknown, 0, 0),
|
||||||
|
new SealPurchaseOption(21072, "Venture", SealPurchaseOption.PurchaseRank.First,
|
||||||
|
SealPurchaseOption.PurchaseType.Materiel, 0, 200),
|
||||||
|
new SealPurchaseOption(5530, "Coke", SealPurchaseOption.PurchaseRank.Third,
|
||||||
|
SealPurchaseOption.PurchaseType.Materials, 31, 200),
|
||||||
|
};
|
||||||
|
|
||||||
public TurnInWindow()
|
public TurnInWindow()
|
||||||
: base("Turn In###DeliverooTurnIn")
|
: base("GC Delivery###DeliverooTurnIn")
|
||||||
{
|
{
|
||||||
Position = new Vector2(100, 100);
|
Position = new Vector2(100, 100);
|
||||||
PositionCondition = ImGuiCond.FirstUseEver;
|
PositionCondition = ImGuiCond.FirstUseEver;
|
||||||
@ -17,9 +32,8 @@ internal sealed class TurnInWindow : Window
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool State { get; set; }
|
public bool State { get; set; }
|
||||||
public decimal Multiplier { get; set; }
|
public decimal Multiplier { private get; set; }
|
||||||
|
public SealPurchaseOption SelectedOption => _sealPurchaseOptions[_sealPurchaseSelected];
|
||||||
public int CurrentVentureCount { get; set; }
|
|
||||||
|
|
||||||
public string Debug { get; set; }
|
public string Debug { get; set; }
|
||||||
|
|
||||||
@ -42,12 +56,26 @@ internal sealed class TurnInWindow : Window
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
int current = 0;
|
ImGui.BeginDisabled(state);
|
||||||
ImGui.Combo("", ref current, new string[] { $"Ventures ({CurrentVentureCount:N0})" }, 1);
|
string[] comboValues = _sealPurchaseOptions.Select(x =>
|
||||||
|
{
|
||||||
|
if (x.ItemId == 0)
|
||||||
|
return x.Name;
|
||||||
|
|
||||||
|
return $"{x.Name} ({GetItemCount(x.ItemId):N0}x)";
|
||||||
|
}).ToArray();
|
||||||
|
ImGui.Combo("", ref _sealPurchaseSelected, comboValues, comboValues.Length);
|
||||||
|
ImGui.EndDisabled();
|
||||||
|
|
||||||
ImGui.Unindent(27);
|
ImGui.Unindent(27);
|
||||||
|
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
ImGui.Text($"Debug (State): {Debug}");
|
ImGui.Text($"Debug (State): {Debug}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private unsafe int GetItemCount(uint itemId)
|
||||||
|
{
|
||||||
|
InventoryManager* inventoryManager = InventoryManager.Instance();
|
||||||
|
return inventoryManager->GetInventoryItemCount(itemId, false, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user