Skip to content

Commit

Permalink
null check fc chest nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaksuhn committed Aug 13, 2024
1 parent c293b71 commit b0358fe
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 66 deletions.
5 changes: 2 additions & 3 deletions Automaton/Features/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,10 @@ internal unsafe void OnCommmandLowerQuality(string command, string arguments)
internal unsafe void OnCommandUseItem(string command, string arguments)
{
if (!uint.TryParse(arguments, out var itemId)) return;
var agent = AgentInventoryContext.Instance();
var agent = ActionManager.Instance();
if (agent == null) return;

var item = Inventory.GetItemInInventory(itemId, Inventory.PlayerInventory);
agent->UseItem(item->ItemId);
agent->UseAction(itemId >= 2_000_000 ? ActionType.KeyItem : ActionType.Item, itemId, extraParam: 65535);
}
#endregion

Expand Down
30 changes: 25 additions & 5 deletions Automaton/Features/FCChestTabRename.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,34 @@ private unsafe void PreDraw(AddonEvent type, AddonArgs args)
{
var addon = (AtkUnitBase*)args.Addon;
if (Config.TabOne != string.Empty)
Utils.GetNodeByIDChain(addon->GetRootNode(), 1, 9, 10, 9)->GetAsAtkTextNode()->NodeText.SetString(Config.TabOne);
{
var node = Utils.GetNodeByIDChain(addon->GetRootNode(), 1, 9, 10, 9);
if (node is not null)
node->GetAsAtkTextNode()->NodeText.SetString(Config.TabOne);
}
if (Config.TabTwo != string.Empty)
Utils.GetNodeByIDChain(addon->GetRootNode(), 1, 9, 11, 9)->GetAsAtkTextNode()->NodeText.SetString(Config.TabTwo);
{
var node = Utils.GetNodeByIDChain(addon->GetRootNode(), 1, 9, 11, 9);
if (node is not null)
node->GetAsAtkTextNode()->NodeText.SetString(Config.TabTwo);
}
if (Config.TabThree != string.Empty)
Utils.GetNodeByIDChain(addon->GetRootNode(), 1, 9, 12, 9)->GetAsAtkTextNode()->NodeText.SetString(Config.TabThree);
{
var node = Utils.GetNodeByIDChain(addon->GetRootNode(), 1, 9, 12, 9);
if (node is not null)
node->GetAsAtkTextNode()->NodeText.SetString(Config.TabThree);
}
if (Config.TabFour != string.Empty)
Utils.GetNodeByIDChain(addon->GetRootNode(), 1, 9, 13, 9)->GetAsAtkTextNode()->NodeText.SetString(Config.TabFour);
{
var node = Utils.GetNodeByIDChain(addon->GetRootNode(), 1, 9, 13, 9);
if (node is not null)
node->GetAsAtkTextNode()->NodeText.SetString(Config.TabFour);
}
if (Config.TabFive != string.Empty)
Utils.GetNodeByIDChain(addon->GetRootNode(), 1, 9, 14, 9)->GetAsAtkTextNode()->NodeText.SetString(Config.TabFive);
{
var node = Utils.GetNodeByIDChain(addon->GetRootNode(), 1, 9, 14, 9);
if (node is not null)
node->GetAsAtkTextNode()->NodeText.SetString(Config.TabFive);
}
}
}
4 changes: 4 additions & 0 deletions Automaton/Features/HuntRelayHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class HuntRelayHelperConfiguration
[BoolConfig] public bool OnlySendLocalHuntsToLocalChannels = true;
[BoolConfig] public bool AssumeBlankWorldsAreLocal = false;
[BoolConfig] public bool DontRepeatRelays = true;
[BoolConfig] public bool OverrideMinionFlag = true;
[BoolConfig] public bool AllowPartialWorldMatches = false;
[BoolConfig] public bool DryRun = false;
[StringConfig] public string ChatMessagePattern = "[<world>] <type> -> <flag>";
Expand Down Expand Up @@ -126,6 +127,9 @@ public override void DrawConfig()
ImGui.Checkbox("Don't repeat relays", ref Config.DontRepeatRelays);
ImGuiComponents.HelpMarker("Don't send relays to the channel in which you clicked the relay payload.");

//ImGui.Checkbox("Override minion flags", ref Config.OverrideMinionFlag);
//ImGuiComponents.HelpMarker("Override minion relay flags with the location of the SS Rank");

ImGui.Checkbox("Allow partial world matching", ref Config.AllowPartialWorldMatches);
ImGuiComponents.HelpMarker("This will allow matching shorthands of worlds (e.g. \"behe\" -> Behemoth) but may result in false positives.");

Expand Down
5 changes: 2 additions & 3 deletions Automaton/Features/ISLock&Move.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public override void Disable()
Svc.Condition.ConditionChange -= CheckToLockAndMove;
}

private bool lockingOn;
private unsafe void CheckToJump(IFramework framework)
{
if (Svc.Targets.Target == null || Svc.Targets.Target.ObjectKind != Dalamud.Game.ClientState.Objects.Enums.ObjectKind.CardStand)
Expand Down Expand Up @@ -59,9 +58,9 @@ private unsafe void CheckToLockAndMove(ConditionFlag flag, bool value)
if (MJIManager.Instance()->CurrentMode == 1)
{
TaskManager.Enqueue(() => { lockingOn = true; Chat.Instance.SendMessage("/lockon on"); });
TaskManager.Enqueue(() => { Chat.Instance.SendMessage("/lockon on"); });
TaskManager.EnqueueDelay(new Random().Next(100, 250));
TaskManager.Enqueue(() => { if (Player.IsTargetLocked) { Chat.Instance.SendMessage("/automove on"); lockingOn = false; } });
TaskManager.Enqueue(() => { if (Player.IsTargetLocked) { Chat.Instance.SendMessage("/automove on"); } });
}
});
}
Expand Down
1 change: 1 addition & 0 deletions Automaton/IPC/PandorasBoxIPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Automaton.IPC;

#nullable disable
#pragma warning disable CS0649
internal class PandorasBoxIPC
{
public static string Name = "PandorasBox";
Expand Down
1 change: 1 addition & 0 deletions Automaton/IPC/QoLBarIPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Automaton.IPC;

#nullable disable
#pragma warning disable CS0649
internal class QoLBarIPC
{
public static string Name = "QoLBar";
Expand Down
7 changes: 1 addition & 6 deletions Automaton/UI/DebugWindow.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Dalamud.Interface.Windowing;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using ImGuiNET;

Expand All @@ -17,12 +16,8 @@ public DebugWindow() : base($"{Name} - Debug {P.GetType().Assembly.GetName().Ver
};
}

public static void Dispose()
{

}
public static void Dispose() { }

private int id;
public unsafe override void Draw()
{
var agent = AgentMap.Instance();
Expand Down
3 changes: 1 addition & 2 deletions Automaton/UI/HaselWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ private void DrawConfig()
{
ImGuiHelpers.SafeTextColoredWrapped(Colors.Grey2, $"{entry.InternalName}:");
ImGui.SameLine();
ImGuiHelpers.ClickToCopyText(entry.Repo);
if (ImGui.IsItemHovered()) ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
ImGuiEx.TextCopy(entry.Repo);
}
}

Expand Down
4 changes: 0 additions & 4 deletions Automaton/Utilities/Enums.cs

This file was deleted.

1 change: 1 addition & 0 deletions Automaton/Utilities/Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Runtime.InteropServices;

namespace Automaton.Utilities;
#pragma warning disable CS0649
internal unsafe class Memory
{
public unsafe delegate void RidePillionDelegate(BattleChara* target, int seatIndex);
Expand Down
3 changes: 0 additions & 3 deletions Automaton/Utilities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ namespace Automaton.Utilities;

public unsafe static class Player
{
private delegate void SetPosition(float x, float y, float z);
private static SetPosition _setPosition = null!;

public static IPlayerCharacter Object => Svc.ClientState.LocalPlayer;
public static bool Available => Svc.ClientState.LocalPlayer != null;
public static bool Interactable => Available && Object.IsTargetable;
Expand Down
51 changes: 51 additions & 0 deletions Automaton/Utilities/SSRanks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Dalamud.Game.Text.SeStringHandling.Payloads;

namespace Automaton.Utilities;
public static class SSRanks
{
public static Vector2 Lakeland => new(23.3f, 22.1f);
public static Vector2 AmhAraeng => new(27.5f, 35.2f);
public static Vector2 IlMheg => new(13.5f, 23.0f);
public static Vector2 Raktika => new(24.48f, 37.34f);
public static Vector2 Kholusia => new(34.09f, 10.03f);
public static Vector2 TheTempest => new(12.9f, 22.2f);

public static Vector2 Labyrinthos => new(25.56f, 16.13f);
public static Vector2 Thavnair => new(24.3f, 16.8f);
public static Vector2 Garlemald => new(20.3f, 23.7f);
public static Vector2 MareLamentorum => new(18.6f, 30.2f);
public static Vector2 Elpis => new(22.7f, 19.5f);
public static Vector2 UltimaThule => new(14.05f, 29.41f);

public static Vector2 YakTel => new(29.59f, 18.56f);
public static Vector2 Urqopacha => new(26.0f, 27.9f);
public static Vector2 Kozamauka => new(13.8f, 14.8f);
public static Vector2 Shaaloni => new(13.35f, 14.33f);
public static Vector2 HeritageFound => new(17.46f, 21.22f);
public static Vector2 LivingMemory => new(34.4f, 26.3f);

public static Vector2 TerritoryToSSRank(this uint territory, MapLinkPayload maplink) => territory switch
{
831 => Lakeland,
814 => Kholusia,
815 => AmhAraeng,
816 => IlMheg,
817 => Raktika,
818 => TheTempest,

956 => Labyrinthos,
957 => Thavnair,
958 => Garlemald,
959 => MareLamentorum,
961 => Elpis,
960 => UltimaThule,

1189 => YakTel,
1187 => Urqopacha,
1188 => Kozamauka,
1190 => Shaaloni,
1191 => HeritageFound,
1192 => LivingMemory,
_ => new(maplink.RawX, maplink.RawY)
};
}
40 changes: 0 additions & 40 deletions Automaton/Utilities/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,44 +165,4 @@ public static void RemoveWindow<T>() where T : Window
var sibNode = node->PrevSiblingNode;
return sibNode != null ? GetNodeByIDChain(sibNode, ids) : null;
}

public static unsafe bool GetUnitBase(string name, out AtkUnitBase* unitBase, int index = 1)
{
unitBase = GetUnitBase(name, index);
return unitBase != null;
}

public static unsafe AtkUnitBase* GetUnitBase(string name, int index = 1) => (AtkUnitBase*)Svc.GameGui.GetAddonByName(name, index);

public static unsafe T* GetUnitBase<T>(string? name = null, int index = 1) where T : unmanaged
{
if (string.IsNullOrEmpty(name))
{
var attr = (Addon)typeof(T).GetCustomAttribute(typeof(Addon));
if (attr != null)
{
name = attr.AddonIdentifiers.FirstOrDefault();
}
}

return string.IsNullOrEmpty(name) ? null : (T*)Svc.GameGui.GetAddonByName(name, index);
}

public static unsafe bool GetUnitBase<T>(out T* unitBase, string? name = null, int index = 1) where T : unmanaged
{
unitBase = null;
if (string.IsNullOrEmpty(name))
{
var attr = (Addon)typeof(T).GetCustomAttribute(typeof(Addon));
if (attr != null)
{
name = attr.AddonIdentifiers.FirstOrDefault();
}
}

if (string.IsNullOrEmpty(name)) return false;

unitBase = (T*)Svc.GameGui.GetAddonByName(name, index);
return unitBase != null;
}
}

0 comments on commit b0358fe

Please sign in to comment.