diff --git a/ChatTwo/GameFunctions/GameFunctions.cs b/ChatTwo/GameFunctions/GameFunctions.cs index 7d6ba75..1531c78 100755 --- a/ChatTwo/GameFunctions/GameFunctions.cs +++ b/ChatTwo/GameFunctions/GameFunctions.cs @@ -33,6 +33,9 @@ internal unsafe class GameFunctions : IDisposable { [Signature("E8 ?? ?? ?? ?? EB 20 48 8B 46 28", Fallibility = Fallibility.Fallible)] private readonly delegate* unmanaged _openAchievement = null!; + [Signature("E8 ?? ?? ?? ?? 84 C0 49 8B DE", Fallibility = Fallibility.Fallible)] + private readonly delegate* unmanaged _inInstance = null!; + #endregion #region Hooks @@ -255,6 +258,14 @@ internal unsafe class GameFunctions : IDisposable { } } + internal bool IsInInstance() { + if (this._inInstance == null) { + return false; + } + + return this._inInstance() != 0; + } + internal void ClickNoviceNetworkButton() { var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.ChatLog); // case 3 diff --git a/ChatTwo/PayloadHandler.cs b/ChatTwo/PayloadHandler.cs index 298abd4..9c9f898 100755 --- a/ChatTwo/PayloadHandler.cs +++ b/ChatTwo/PayloadHandler.cs @@ -450,14 +450,15 @@ internal sealed class PayloadHandler { var isLeader = party.Length == 0 || this.Ui.Plugin.ClientState.LocalContentId == leader; var member = party.FirstOrDefault(member => member.Name.TextValue == player.PlayerName && member.World.Id == player.World.RowId); var isInParty = member != default; + var inInstance = this.Ui.Plugin.Functions.IsInInstance(); var inPartyInstance = this.Ui.Plugin.DataManager.GetExcelSheet()!.GetRow(this.Ui.Plugin.ClientState.TerritoryType)?.TerritoryIntendedUse is (41 or 47 or 48 or 52 or 53); if (isLeader) { if (!isInParty) { - if (inPartyInstance) { + if (inInstance && inPartyInstance) { if (chunk.Message?.ContentId is not null or 0 && ImGui.Selectable("Invite to Party")) { this.Ui.Plugin.Functions.Party.InviteInInstance(chunk.Message!.ContentId); } - } else if (ImGui.BeginMenu("Invite to Party")) { + } else if (!inInstance && ImGui.BeginMenu("Invite to Party")) { if (ImGui.Selectable("Same world")) { this.Ui.Plugin.Functions.Party.InviteSameWorld(player.PlayerName, (ushort) player.World.RowId, chunk.Message?.ContentId ?? 0); } @@ -470,7 +471,7 @@ internal sealed class PayloadHandler { } } - if (isInParty && member != null) { + if (isInParty && member != null && (!inInstance || (inInstance && inPartyInstance))) { if (ImGui.Selectable("Promote")) { this.Ui.Plugin.Functions.Party.Promote(player.PlayerName, (ulong) member.ContentId); }