Skip to content

Commit

Permalink
Add party leave
Browse files Browse the repository at this point in the history
  • Loading branch information
GiR_Zippo committed Jul 17, 2024
1 parent cd5e4b0 commit d15d7ad
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
9 changes: 2 additions & 7 deletions HypnotoadPlugin/GameFunctions/MovementFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public void Initialize(Vector3 position, float rotation)
{
DesiredPosition = position;
DesiredRotation = new Angle(rotation);

Api.PluginLog.Debug(DesiredRotation.ToString());
}

public Vector3 getVector3(string rString)
Expand Down Expand Up @@ -70,9 +68,6 @@ public void Move()
move.Precision = 0.05f;
move.DesiredPosition = DesiredPosition;

//cam.DesiredAzimuth = DesiredRotation;
//cam.Enabled = true;

Api.Framework.RunOnTick(delegate
{
cancelMovementToken = new CancellationTokenSource();
Expand Down Expand Up @@ -132,7 +127,7 @@ private async Task RunMoveTask(CancellationToken token)
else
round = 4; //4 rounds until we give up

//check if we reached out position
//check if we reached our position
var dist = move.DesiredPosition - Api.ClientState.LocalPlayer.Position;
dist.Y = 0.0f;
if (dist.LengthSquared() <= move.Precision * move.Precision)
Expand All @@ -141,7 +136,7 @@ private async Task RunMoveTask(CancellationToken token)
cam.Enabled = true;
move.Enabled = false;

await Task.Delay(300, token).ContinueWith(static tsk => { }, token);
await Task.Delay(800, token).ContinueWith(static tsk => { }, token);
cam.Enabled = false;
break;
}
Expand Down
32 changes: 30 additions & 2 deletions HypnotoadPlugin/GameFunctions/Party.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Client.UI.Info;
using HypnotoadPlugin.Offsets;
using HypnotoadPlugin.Utils;
using System;
using System.Threading;

namespace HypnotoadPlugin.GameFunctions;

public class Party : IDisposable
{
public enum AcceptFlags
{
Accept_Teleport = 0b00000001,
Accept_GroupInv = 0b00000010,
}

private static readonly Lazy<Party> LazyInstance = new(static () => new Party());

private Party()
Expand All @@ -25,6 +33,9 @@ private Party()

private AutoSelect.AutoSelectYes YesNoAddon { get; set; } = null;

private byte AcceptLock { get; set; } = 0;


public void Initialize()
{
YesNoAddon = new AutoSelect.AutoSelectYes();
Expand All @@ -36,11 +47,17 @@ public void Dispose()
YesNoAddon = null;
}

public bool IsAcceptFlagSet(AcceptFlags flag) => ((AcceptFlags)AcceptLock & flag) == flag;

public void ClearFlags() => AcceptLock = 0;

public void SetFlag(AcceptFlags flag) => AcceptLock |= (byte)flag;

public unsafe void PartyInvite(string message)
{
if (message == "")
{
AcceptPartyInviteEnable();
YesNoAddon.Enable();
return;
}
string character = message.Split(';')[0];
Expand Down Expand Up @@ -84,8 +101,19 @@ public unsafe void Teleport(bool showMenu)
YesNoAddon.Enable();
}

public unsafe void PartyLeave()
{
YesNoAddon.Enable();

Api.Framework.RunOnTick(delegate
{
Chat.SendMessage("/leave");
}, default(TimeSpan), 10, default(CancellationToken));
}

public unsafe void AcceptDisable()
{
YesNoAddon.Disable();
//if (AcceptLock == 0)
YesNoAddon.Disable();
}
}
2 changes: 1 addition & 1 deletion HypnotoadPlugin/HypnotoadPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<Description>BardMusicPlayer &amp; LightAmp companion for enhanced functionality.</Description>
<PackageProjectUrl>https://github.com/GiR-Zippo/Hypnotoad-Plugin</PackageProjectUrl>
<Version>0.0.1.36</Version>
<Version>0.0.1.37</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions HypnotoadPlugin/IPC/IPCProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public IPCProvider(Hypnotoad toad)
Register("PartyInvite", (string data) => { Party.Instance.PartyInvite(data); });
Register("PartyInviteAccept", () => Party.Instance.AcceptPartyInviteEnable());
Register("PartySetLead", (string data) => Party.Instance.PromoteCharacter(data));
Register("PartyLeave", () => Party.Instance.PartyLeave());
Register("PartyEnterHouse", () => Party.Instance.EnterHouse());
Register("PartyTeleport", (bool showMenu) => Party.Instance.Teleport(showMenu));
Register("PartyFollow", (string data) => FollowSystem.FollowCharacter(data.Split(';')[0], Convert.ToUInt16(data.Split(';')[1])));
Expand Down

0 comments on commit d15d7ad

Please sign in to comment.