Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: fix with subtarget targeting.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 23, 2023
1 parent 0d85749 commit aa0f11d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 60 deletions.
2 changes: 1 addition & 1 deletion RotationSolver/Helpers/ObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal static unsafe bool IsOthersPlayers(this GameObject obj)

internal static unsafe bool IsNPCEnemy(this GameObject obj)
=> obj.GetObjectKind() == ObjectKind.BattleNpc
&& obj.GetBattleNPCSubkind() == BattleNpcSubKind.Enemy
&& (byte)obj.GetBattleNPCSubkind() is (byte)BattleNpcSubKind.Enemy or 1
&& obj.CanAttack();

private unsafe static bool CanAttack(this GameObject actor)
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ private static void UpdateWork()
ActionUpdater.UpdateActionInfo();
PreviewUpdater.UpdateCastBarState();
TargetUpdater.UpdateTarget();
SocialUpdater.UpdateSocial();

RotationUpdater.UpdateRotation();

Expand Down
79 changes: 21 additions & 58 deletions RotationSolver/Updaters/SocialUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,6 @@ internal class SocialUpdater
"stroke",
};

static bool CanSocial
{
get
{
if (Service.Conditions[ConditionFlag.OccupiedInCutSceneEvent]
|| Service.Conditions[ConditionFlag.WatchingCutscene]
|| Service.Conditions[ConditionFlag.WatchingCutscene78]) return false;

return Service.Conditions[ConditionFlag.BoundByDuty]
|| Service.Conditions[ConditionFlag.BoundByDuty56]
|| Service.Conditions[ConditionFlag.BoundByDuty95];
}
}

internal static void Enable()
{
Service.DutyState.DutyStarted += DutyState_DutyStarted;
Expand All @@ -56,66 +42,43 @@ static async void DutyState_DutyCompleted(object sender, ushort e)
Service.Configuration.DutyEnd.AddMacro();
}

static void DutyState_DutyStarted(object sender, ushort e)
static async void DutyState_DutyStarted(object sender, ushort e)
{
var territory = Service.DataManager.GetExcelSheet<TerritoryType>().GetRow(e);
if (territory?.ContentFinderCondition?.Value?.HighEndDuty ?? false)
{
var str = territory.PlaceName?.Value?.Name.ToString() ?? "High-end Duty";
Service.ToastGui.ShowError(string.Format(LocalizationManager.RightLang.HighEndWarning, str));
}
}

internal static void Disable()
{
Service.DutyState.DutyStarted -= DutyState_DutyStarted;
Service.DutyState.DutyCompleted -= DutyState_DutyCompleted;
}
await Task.Delay(new Random().Next(1000));

internal static void UpdateSocial()
{
if (ActionUpdater.InCombat) return;
SayHelloToAuthor();
EventDutyStart();
}
var author = TargetUpdater.AllianceMembers.OfType<PlayerCharacter>()
.FirstOrDefault(c => c.ObjectId != Service.ClientState.LocalPlayer.ObjectId
&& ConfigurationHelper.AuthorKeys.Contains(EncryptString(c)));

static bool _author = false;
static RandomDelay _authorDelay = new RandomDelay(() => (0, 1));
private static void SayHelloToAuthor()
{
var started = _authorDelay.Delay(CanSocial);
if (!_author && started)
if (author != null)
{
var author = TargetUpdater. AllianceMembers.OfType<PlayerCharacter>()
.FirstOrDefault(c => c.ObjectId != Service.ClientState.LocalPlayer.ObjectId
&& ConfigurationHelper.AuthorKeys.Contains(EncryptString(c)));

if (author != null)
Service.TargetManager.SetTarget(author);
RSCommands.SubmitToChat($"/{macroToAuthor[new Random().Next(macroToAuthor.Count)]} <t>");
Service.ChatGui.PrintChat(new Dalamud.Game.Text.XivChatEntry()
{
Service.TargetManager.SetTarget(author);
RSCommands.SubmitToChat($"/{macroToAuthor[new Random().Next(macroToAuthor.Count)]} <t>");
Service.ChatGui.PrintChat(new Dalamud.Game.Text.XivChatEntry()
{
Message = string.Format(LocalizationManager.RightLang.Commands_SayHelloToAuthor, author.Name),
Type = Dalamud.Game.Text.XivChatType.Notice,
});
UIModule.PlaySound(20, 0, 0, 0);
Service.TargetManager.SetTarget(null);
}
Message = string.Format(LocalizationManager.RightLang.Commands_SayHelloToAuthor, author.Name),
Type = Dalamud.Game.Text.XivChatType.Notice,
});
UIModule.PlaySound(20, 0, 0, 0);
Service.TargetManager.SetTarget(null);
}
_author = started;

await Task.Delay(new Random().Next(1000));

Service.Configuration.DutyStart.AddMacro();
}

static bool _duty = false;
static RandomDelay _dutyDelay = new RandomDelay(() => (0, 0));
private static void EventDutyStart()
internal static void Disable()
{
var started = _dutyDelay.Delay(CanSocial);
if (!_duty && started)
{
Service.Configuration.DutyStart.AddMacro();
}
_duty = started;
Service.DutyState.DutyStarted -= DutyState_DutyStarted;
Service.DutyState.DutyCompleted -= DutyState_DutyCompleted;
}

internal static string EncryptString(PlayerCharacter player)
Expand Down

0 comments on commit aa0f11d

Please sign in to comment.