Skip to content

Commit

Permalink
Merge pull request #272 from FFXIV-CombatReborn/update-715
Browse files Browse the repository at this point in the history
Update 7.15
  • Loading branch information
NostraThomas99 authored Dec 17, 2024
2 parents dc8bb78 + 37fe50e commit 0b1084e
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 178 deletions.
17 changes: 16 additions & 1 deletion GatherBuddy.GameData/Data/Fish/Data7.1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,22 @@ private static void ApplyCrossroads(this GameData data)
.Time(540, 660);
data.Apply(44347, Patch.Crossroads) // Cloudsail
.Bait(data, 43853)
.Bite(data, HookSet.Powerful, BiteType.Strong);
.Bite(data, HookSet.Powerful, BiteType.Strong);
data.Apply(44334, Patch.Crossroads) // Oily Ropefish
.Bait(data, 28634)
.Bite(data, HookSet.Powerful, BiteType.Strong);
data.Apply(44336, Patch.Crossroads) // Yak Awak Core
.Bait(data, 28634)
.Bite(data, HookSet.Precise, BiteType.Weak);
data.Apply(44336, Patch.Crossroads) // Inktopus
.Bait(data, 28634)
.Bite(data, HookSet.Powerful, BiteType.Strong);
data.Apply(44337, Patch.Crossroads) // Honeycomb Sponge
.Bait(data, 28634)
.Bite(data, HookSet.Precise, BiteType.Weak);
data.Apply(44338, Patch.Crossroads) // Cenote Oyster
.Bait(data, 28634)
.Bite(data, HookSet.Precise, BiteType.Weak);
}
// @formatter:on
}
31 changes: 11 additions & 20 deletions GatherBuddy/AutoGather/AutoGather.Movement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void MoveToCloseNode(IGameObject gameObject, Gatherable targetItem, Conf
{
StopNavigation();
AutoStatus = "Waiting for GP to regenerate...";
}
}
else
{
// Use consumables with cast time just before gathering a node when player is surely not mounted
Expand Down Expand Up @@ -176,37 +176,28 @@ private void Navigate(Vector3 destination, bool shouldFly)

StopNavigation();
CurrentDestination = destination;
var correctedDestination = GetCorrectedDestination(destination);
var correctedDestination = GetCorrectedDestination(CurrentDestination);
GatherBuddy.Log.Debug($"Navigating to {destination} (corrected to {correctedDestination})");

LastNavigationResult = VNavmesh_IPCSubscriber.SimpleMove_PathfindAndMoveTo(correctedDestination, shouldFly);
}

private static Vector3 GetCorrectedDestination(Vector3 destination)
{
var correctedDestination = destination;

if (WorldData.NodeOffsets.TryGetValue(destination, out var offset))
correctedDestination = offset;

try
{
if (Vector3.Distance(Player.Position, offset) < 3 && Vector3.Distance(Player.Position, destination) > 3)
{
correctedDestination = offset;
GatherBuddy.Log.Debug($"Offset exists, corrected destination: {correctedDestination}");
}
}
else
{
try
correctedDestination = VNavmesh_IPCSubscriber.Query_Mesh_NearestPoint(correctedDestination, 3, 3);
if (Vector3.Distance(correctedDestination, destination) is var distance and > 3)
{
correctedDestination = VNavmesh_IPCSubscriber.Query_Mesh_NearestPoint(correctedDestination, 3, 3);
if (Vector3.Distance(correctedDestination, destination) is var distance and > 3)
{
GatherBuddy.Log.Warning($"Offset is ignored, because distance {distance} is too large after correcting for mesh.");
correctedDestination = VNavmesh_IPCSubscriber.Query_Mesh_NearestPoint(destination, 3, 3);
}
GatherBuddy.Log.Warning($"Offset is ignored, because distance {distance} is too large after correcting for mesh.");
correctedDestination = VNavmesh_IPCSubscriber.Query_Mesh_NearestPoint(destination, 3, 3);
}
catch (Exception)
{ }
}
catch (Exception) { }

return correctedDestination;
}
Expand Down
167 changes: 11 additions & 156 deletions GatherBuddy/Gui/Interface.DebugTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
using static GatherBuddy.FishTimer.FishRecord;
using ImRaii = OtterGui.Raii.ImRaii;
using System.Text;
using System.Threading.Tasks;
using ECommons.GameHelpers;
using ECommons.ImGuiMethods;
using Newtonsoft.Json;

namespace GatherBuddy.Gui;

Expand Down Expand Up @@ -557,164 +553,23 @@ private void DrawDebugTab()
}
}

if (ImGui.CollapsingHeader("World Positions (Offset Creation)"))
if (ImGui.CollapsingHeader("Saved World Objects"))
{
DrawWorldObjectDebug();
}
}

private bool _isFlightAllowed = true;
private bool _autoFillOffsetValues = true;

private void DrawWorldObjectDebug()
{
ImGui.Checkbox("Fly", ref _isFlightAllowed);
ImGuiUtil.HoverTooltip("Fly when navigating using below buttons");
ImGui.SameLine();
ImGui.Checkbox("Auto-Fill Offset Values", ref _autoFillOffsetValues);
ImGuiUtil.HoverTooltip("Automatically fill offset values in table with player's current position");

if (ImGui.Button("Import"))
{
try
{
var settings = new JsonSerializerSettings();
var text = ImGuiUtil.GetClipboardText();
var vectors = JsonConvert.DeserializeObject<List<OffsetPair>>(text, settings) ?? [];
int inserted = 0;
foreach (var offset in vectors)
{
WorldData.NodeOffsets[offset.Original] = offset.Offset;
GatherBuddy.Log.Information($"Added offset {offset} to dictionary");
inserted++;
}

WorldData.SaveOffsetsToFile();
Notify.Success($"{inserted} offsets were imported");
}
catch (Exception ex)
{
Notify.Error($"Failed to import offsets: {ex.Message}");
}
}
ImGui.SameLine();
if (ImGui.Button("Export"))
{
var settings = new JsonSerializerSettings();
var offsetString = JsonConvert.SerializeObject(WorldData.NodeOffsets.Select(x => new OffsetPair(x.Key, x.Value)).ToList(), Formatting.Indented, settings);
ImGui.SetClipboardText(offsetString);
Notify.Info("Node offsets exported to clipboard");
}

var nodes = GatherBuddy.GameData.GatheringNodes.Where(o => o.Value.Territory.Id == Svc.ClientState.TerritoryType).Select(o => o.Value);

if (!nodes.Any())
{
ImGui.Text("No known gathering nodes in current zone");
return;
}

if (ImGui.BeginTable("Node Positions", 6, ImGuiTableFlags.Borders | ImGuiTableFlags.Resizable))
{
ImGui.TableSetupColumn("Node Name");
ImGui.TableSetupColumn("Contents");
ImGui.TableSetupColumn("Nav Button");
ImGui.TableSetupColumn("Offset Nav");
ImGui.TableSetupColumn("Distances");
ImGui.TableSetupColumn("Create Offset");

ImGui.TableHeadersRow();

foreach (var node in nodes)
using var group = ImRaii.Group();
ImGui.Text("Saved Gatherables");
foreach (var kvp in WorldData.WorldLocationsByNodeId)
{
var positions = node.WorldPositions.SelectMany(p => p.Value);
foreach (var position in positions)
ImGui.PushID(kvp.Key.ToString());
ImGui.Text($"{kvp.Key}");
foreach (var loc in kvp.Value)
{
ImGui.TableNextRow();
DrawPositionRow(position, node);
ImGui.Indent();
ImGui.Text($"{loc}");
ImGui.Unindent();
}
ImGui.PopID();
}

ImGui.EndTable();
}
}

private void DrawPositionRow(Vector3 position, GatheringNode node)
{
ImGui.PushID(position.ToString());
ImGui.TableSetColumnIndex(0);
ImGui.Text(node.Name);

ImGui.TableSetColumnIndex(1);
var contentsStrings = node.Items.Select(i => i.Name);
foreach (var contents in contentsStrings)
{
ImGui.Text(contents.ToString());
}

ImGui.TableSetColumnIndex(2);
DrawNavButton(position);

Vector3? offset = WorldData.NodeOffsets.TryGetValue(position, out var offsetRaw) ? offsetRaw : null;

ImGui.TableSetColumnIndex(3);
if (offset.HasValue)
{
DrawNavButton(offset.Value);
if (ImGui.Button("Clear Offset"))
{
WorldData.NodeOffsets.Remove(position);
Task.Run(WorldData.SaveOffsetsToFile);
}
}
else
{
ImGui.Text("No Offset");
}

ImGui.TableSetColumnIndex(4);
var positionDistance = Vector3.Distance(position, Player.Position);
var offsetDistance = offset.HasValue ? Vector3.Distance(offset.Value, Player.Position) : 0;
var distanceBetweenPositionAndOffset = offset.HasValue ? Vector3.Distance(position, offset.Value) : 0;
ImGui.Text($"Distance to actual node: {positionDistance}");
ImGui.Text($"Distance to offset: {offsetDistance}");
ImGui.Text($"Distance between: {distanceBetweenPositionAndOffset}");

ImGui.TableSetColumnIndex(5);
if (_autoFillOffsetValues)
{
_offsetX = Player.Position.X;
_offsetY = Player.Position.Y;
_offsetZ = Player.Position.Z;
}
ImGui.SetNextItemWidth(60);
ImGui.InputFloat($"X", ref _offsetX);
ImGui.SameLine();
ImGui.SetNextItemWidth(60);
ImGui.InputFloat("Y", ref _offsetY);
ImGui.SameLine();
ImGui.SetNextItemWidth(60);
ImGui.InputFloat("Z", ref _offsetZ);
if (ImGui.Button("Set Offset"))
{
Vector3 vector = new Vector3(_offsetX, _offsetY, _offsetZ);
WorldData.AddOffset(position, vector);
}
ImGui.PopID();
}

private float _offsetX = 0;
private float _offsetY = 0;
private float _offsetZ = 0;

private void DrawNavButton(Vector3 position)
{
if (ImGui.Button(position.ToString()))
{
VNavmesh_IPCSubscriber.Path_Stop();
VNavmesh_IPCSubscriber.SimpleMove_PathfindAndMoveTo(position, _isFlightAllowed);
}
ImGuiUtil.HoverTooltip("Click to move to position via vnavmesh");
}

private void DrawAutoGatherDebug()
Expand Down
6 changes: 6 additions & 0 deletions GatherBuddy/SeFunctions/FishLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,10 @@ public bool FishIsUnlocked(uint fishId)

public bool IsUnlocked(Fish fish)
=> !fish.InLog || (fish.IsSpearFish ? SpearFishIsUnlocked(fish.FishId) : FishIsUnlocked(fish.FishId));

public void SetAllUnlocked()
{
for (var i = 0; i < _fishStore.Length; ++i)
_fish[i] = 0xFF;
}
}
2 changes: 1 addition & 1 deletion GatherBuddy/SeFunctions/FishLogData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace GatherBuddy.SeFunctions;
public sealed class FishLogData : SeAddressBase
{
public FishLogData(ISigScanner sigScanner)
: base(sigScanner, "4C 8D 2D ?? ?? ?? ?? 41 8B EF")
: base(sigScanner, "4C 8D 2D ?? ?? ?? ?? 49 8B 03")
{ }
}

0 comments on commit 0b1084e

Please sign in to comment.