Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lifestream enhancements #10

Merged
merged 3 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RebornToolbox/Common/IpcSubscribers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ internal static bool IsEnabled

[EzIPC("Lifestream.Abort", applyPrefix: false)]
internal static readonly Action Abort;

[EzIPC("Lifestream.AethernetTeleport", applyPrefix: false)]
internal static readonly Func<string, bool> AethernetTeleport;
internal static void Dispose()
=> IPCSubscriber_Common.DisposeAll(_disposalTokens);
}
Expand Down
30 changes: 12 additions & 18 deletions RebornToolbox/Features/ChocoboRacing/ChocoboRacing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ private unsafe void OnUpdate(IFramework framework)
return;
}

var selectedDutyName = addon->AtkValues[18].GetValueAsString();
var selectedDutyName = addon->AtkValues[18].GetValueAsString()
.Replace("\u0002\u001a\u0002\u0002\u0003", string.Empty)
.Replace("\u0002\u001a\u0002\u0001\u0003", string.Empty);
if (selectedDutyName.Contains(GetSelectedDutyName(), StringComparison.InvariantCultureIgnoreCase))
{
Callback.Fire((AtkUnitBase*)addon, true, 12, 0);
Expand All @@ -145,28 +147,20 @@ private string GetSelectedDutyName()
var row = ContentRoulettes.First(c => c.RowId == routeId);
return row.Name.ToString();
}

// Credit: https://github.com/ffxivcode/AutoDuty/blob/26a61eefdba148bc5f46694f915f402315e9f128/AutoDuty/Helpers/QueueHelper.cs#L247
private uint HeadersCount(uint before, List<AtkComponentTreeListItem> list)
private static uint HeadersCount(int before, List<AtkComponentTreeListItem> list)
{
uint count = 0;
for (int i = 0; i < before; i++)
{
if (list[i].UIntValues[0] == 4 || list[i].UIntValues[0] == 2)
count++;
}

return count;
return (uint)list.Take(before).Count(item => item.UIntValues[0] == 0 || item.UIntValues[0] == 1);
}

// Credit: https://github.com/ffxivcode/AutoDuty/blob/26a61eefdba148bc5f46694f915f402315e9f128/AutoDuty/Helpers/QueueHelper.cs#L258
private unsafe void SelectDuty(AddonContentsFinder* addonContentsFinder)
{
if (addonContentsFinder == null) return;

var vectorDutyListItems = addonContentsFinder->DutyList->Items;
List<AtkComponentTreeListItem> listAtkComponentTreeListItems = [];
vectorDutyListItems.ForEach(pointAtkComponentTreeListItem => listAtkComponentTreeListItems.Add(*(pointAtkComponentTreeListItem.Value)));
Callback.Fire((AtkUnitBase*)addonContentsFinder, true, 3, HeadersCount((uint)addonContentsFinder->DutyList->SelectedItemIndex, listAtkComponentTreeListItems) + 1); // - (HeadersCount(addonContentsFinder->DutyList->SelectedItemIndex, listAtkComponentTreeListItems) + 1));
var dutyItems = addonContentsFinder->DutyList->Items;
var itemList = dutyItems.Select(itemPtr => *(itemPtr.Value)).ToList();
int selectedIndex = addonContentsFinder->DutyList->SelectedItemIndex;
uint headersBeforeSelected = HeadersCount(selectedIndex, itemList);
uint callbackIndex = headersBeforeSelected + 1;
Callback.Fire((AtkUnitBase*)addonContentsFinder, true, 3, callbackIndex);
}

}
23 changes: 9 additions & 14 deletions RebornToolbox/Features/MBShoppingList/MBShoppingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public void QueueMoveToMarketboardTasks()
case 129:
MoveToNearestMarketboard();
return;
// case 130:
// QueueUldahMoveToMarketboardTasks();
// return;
case 130:
QueueUldahMoveToMarketboardTasks();
return;
case 132:
QueueGridMoveToMarketboardTasks();
return;
Expand All @@ -134,28 +134,23 @@ public void QueueMoveToMarketboardTasks()

private void QueueUldahMoveToMarketboardTasks()
{
TaskManager.Enqueue(() => VNavmesh_IPCSubscriber.Nav_IsReady());
TaskManager.Enqueue(() => VNavmesh_IPCSubscriber.SimpleMove_PathfindAndMoveTo(uldahTransitionPosition, false));
TaskManager.EnqueueDelay(5000);
TaskManager.Enqueue(() =>
!VNavmesh_IPCSubscriber.Path_IsRunning() && !VNavmesh_IPCSubscriber.Nav_PathfindInProgress());
TaskManager.Enqueue(() => Lifestream_IPCSubscriber.AethernetTeleport("sapphire"));
TaskManager.Enqueue(() => Svc.ClientState.TerritoryType == 131);
TaskManager.Enqueue(GenericHelpers.IsScreenReady);
TaskManager.Enqueue(() => VNavmesh_IPCSubscriber.Nav_IsReady());
TaskManager.Enqueue(MoveToNearestMarketboard);
}

private uint marketboardDataId = 2000402;
private uint otherMoreStupidMarketboardDataId = 2000442;

private Vector3 oldGridTransitionPosition = new Vector3(11.458f, 1.275f, -15.702f);
private Vector3 oldGridBowerHousePosition = new Vector3(141.558f, 13.571f, -97.028f);

private void QueueGridMoveToMarketboardTasks()
{
TaskManager.Enqueue(() => VNavmesh_IPCSubscriber.Nav_IsReady());
TaskManager.Enqueue(() =>
VNavmesh_IPCSubscriber.SimpleMove_PathfindAndMoveTo(oldGridTransitionPosition, false));
TaskManager.Enqueue(() =>
!VNavmesh_IPCSubscriber.Path_IsRunning() && !VNavmesh_IPCSubscriber.Nav_PathfindInProgress());
TaskManager.Enqueue(() => Lifestream_IPCSubscriber.AethernetTeleport("bower"));
TaskManager.Enqueue(() => Svc.ClientState.TerritoryType == 133);
TaskManager.Enqueue(GenericHelpers.IsScreenReady);
TaskManager.Enqueue(() => VNavmesh_IPCSubscriber.Nav_IsReady());
TaskManager.Enqueue(() =>
Expand All @@ -168,7 +163,7 @@ private void QueueGridMoveToMarketboardTasks()

private void MoveToNearestMarketboard()
{
var marketBoard = Svc.Objects.Where(o => o.DataId == marketboardDataId)
var marketBoard = Svc.Objects.Where(o => o.DataId == marketboardDataId || o.DataId == otherMoreStupidMarketboardDataId)
.OrderBy(o => Vector3.Distance(o.Position, Player.Position)).FirstOrDefault();
if (marketBoard == null)
{
Expand Down