Fix not being able to attune to aetherytes/aethernet shards if certain other GameObjects share the same DataId

arr-p5
Liza 2024-07-13 13:47:49 +02:00
parent 73c6aae1e2
commit 0ed129f8a6
Signed by: liza
GPG Key ID: 7199F8D727D55F67
4 changed files with 21 additions and 10 deletions

View File

@ -27,6 +27,7 @@
"Y": -16.246998,
"Z": 147.02063
},
"StopDistance": 5,
"TerritoryId": 962,
"InteractionType": "Interact"
}

View File

@ -12,6 +12,7 @@
"Y": 1.9073486E-06,
"Z": 0.16778564
},
"StopDistance": 5,
"TerritoryId": 987,
"InteractionType": "AcceptQuest"
}

View File

@ -1,8 +1,10 @@
using System;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Questionable.Model;
using Questionable.Model.V1;
using ObjectKind = Dalamud.Game.ClientState.Objects.Enums.ObjectKind;
namespace Questionable.Controller.Steps.Interactions;
@ -37,7 +39,7 @@ internal static class AethernetShard
if (!gameFunctions.IsAetheryteUnlocked(AetheryteLocation))
{
logger.LogInformation("Attuning to aethernet shard {AethernetShard}", AetheryteLocation);
gameFunctions.InteractWith((uint)AetheryteLocation);
gameFunctions.InteractWith((uint)AetheryteLocation, ObjectKind.Aetheryte);
return true;
}

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Numerics;
using Dalamud.Game;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Types;
@ -29,6 +28,7 @@ using ContentFinderCondition = Lumina.Excel.GeneratedSheets.ContentFinderConditi
using ContentTalk = Lumina.Excel.GeneratedSheets.ContentTalk;
using EventPathMove = Lumina.Excel.GeneratedSheets.EventPathMove;
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
using ObjectKind = Dalamud.Game.ClientState.Objects.Enums.ObjectKind;
using Quest = Questionable.Model.Quest;
using TerritoryType = Lumina.Excel.GeneratedSheets.TerritoryType;
@ -316,11 +316,15 @@ internal sealed unsafe class GameFunctions
playerState->IsAetherCurrentUnlocked(aetherCurrentId);
}
public IGameObject? FindObjectByDataId(uint dataId)
public IGameObject? FindObjectByDataId(uint dataId, ObjectKind? kind = null)
{
foreach (var gameObject in _objectTable)
{
if (gameObject.DataId == dataId)
if (gameObject.ObjectKind is ObjectKind.Player or ObjectKind.Companion or ObjectKind.MountType
or ObjectKind.Retainer or ObjectKind.Housing)
continue;
if (gameObject.DataId == dataId && (kind == null || kind.Value == gameObject.ObjectKind))
{
return gameObject;
}
@ -330,9 +334,9 @@ internal sealed unsafe class GameFunctions
return null;
}
public bool InteractWith(uint dataId)
public bool InteractWith(uint dataId, ObjectKind? kind = null)
{
IGameObject? gameObject = FindObjectByDataId(dataId);
IGameObject? gameObject = FindObjectByDataId(dataId, kind);
if (gameObject != null)
{
_logger.LogInformation("Setting target with {DataId} to {ObjectId}", dataId, gameObject.EntityId);
@ -342,7 +346,7 @@ internal sealed unsafe class GameFunctions
long result = (long)TargetSystem.Instance()->InteractWithObject((GameObject*)gameObject.Address, false);
_logger.LogInformation("Interact result: {Result}", result);
return result > 0;
return result != 7 && result > 0;
}
_logger.LogDebug("Game object is null");
@ -413,11 +417,14 @@ internal sealed unsafe class GameFunctions
if (actionRow.TargetArea)
{
Vector3 position = gameObject.Position;
result = ActionManager.Instance()->UseActionLocation(ActionType.Action, (uint)action, location: &position);
_logger.LogInformation("UseAction {Action} on target area {Target} result: {Result}", action, gameObject,
result = ActionManager.Instance()->UseActionLocation(ActionType.Action, (uint)action,
location: &position);
_logger.LogInformation("UseAction {Action} on target area {Target} result: {Result}", action,
gameObject,
result);
}
else {
else
{
result = ActionManager.Instance()->UseAction(ActionType.Action, (uint)action, gameObject.GameObjectId);
_logger.LogInformation("UseAction {Action} on target {Target} result: {Result}", action, gameObject,
result);