Skip to content

Commit a37957d

Browse files
Merge pull request #2 from FFXIV-CombatReborn/nti-initial-updates
Lots of changes
2 parents 47ef817 + fb6758b commit a37957d

17 files changed

+67
-146
lines changed

RotationSolver.Basic/Actions/ActionBasicInfo.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public readonly struct ActionBasicInfo
5252
/// <summary>
5353
/// The animation lock time of this action.
5454
/// </summary>
55-
public readonly float AnimationLockTime => OtherConfiguration.AnimationLockTime?.TryGetValue(AdjustedID, out var time) ?? false ? time : 0.6f;
55+
[Obsolete("Use ActionManagerHelper.GetCurrentAnimationLock()")]
56+
public readonly float AnimationLockTime => ActionManagerHelper.GetCurrentAnimationLock();
5657

5758
/// <summary>
5859
/// The level of this action.

RotationSolver.Basic/Actions/ActionCooldownInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ internal bool CooldownCheck(bool isEmpty, bool onLastAbility, bool ignoreClippin
168168
{
169169
if (onLastAbility)
170170
{
171-
if (DataCenter.NextAbilityToNextGCD > _action.Info.AnimationLockTime + DataCenter.Ping + DataCenter.MinAnimationLock) return false;
171+
if (DataCenter.NextAbilityToNextGCD > ActionManagerHelper.GetCurrentAnimationLock() + DataCenter.Ping + DataCenter.MinAnimationLock) return false;
172172
}
173173
else if (!ignoreClippingCheck)
174174
{
175-
if (DataCenter.NextAbilityToNextGCD < _action.Info.AnimationLockTime) return false;
175+
if (DataCenter.NextAbilityToNextGCD < ActionManagerHelper.GetCurrentAnimationLock()) return false;
176176
}
177177
}
178178

RotationSolver.Basic/Actions/BaseAction.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class BaseAction : IBaseAction
3737
public uint AdjustedID => Info.AdjustedID;
3838

3939
/// <inheritdoc/>
40-
public float AnimationLockTime => Info.AnimationLockTime;
40+
public float AnimationLockTime => ActionManagerHelper.GetCurrentAnimationLock();
4141

4242
/// <inheritdoc/>
4343
public uint SortKey => Cooldown.CoolDownGroup;

RotationSolver.Basic/Configuration/Configs.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public const string
3939

4040
[ConditionBool, UI("Show RS logo animation",
4141
Filter = UiWindows)]
42-
private static readonly bool _drawIconAnimation = False;
42+
private static readonly bool _drawIconAnimation = false;
4343

4444
[ConditionBool, UI("Auto turn off when player is moving between areas.",
4545
Filter =BasicAutoSwitch)]

RotationSolver.Basic/DataCenter.cs

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace RotationSolver.Basic;
1515
internal static class DataCenter
1616
{
1717
private static uint _hostileTargetId = GameObject.InvalidGameObjectId;
18+
19+
public static bool IsActivated() => State || IsManual || Service.Config.TeachingMode;
1820
internal static BattleChara? HostileTarget
1921
{
2022
get
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using FFXIVClientStructs.FFXIV.Client.Game;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace RotationSolver.Basic.Helpers
9+
{
10+
internal static class ActionManagerHelper
11+
{
12+
public static unsafe float GetCurrentAnimationLock()
13+
{
14+
var actionManager = ActionManager.Instance();
15+
if (actionManager == null) return 0.6f;
16+
17+
var animationLockRaw = ((IntPtr)actionManager + 8);
18+
return *(float*)animationLockRaw;
19+
}
20+
}
21+
}

RotationSolver.Basic/Service.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace RotationSolver.Basic;
99

1010
internal class Service : IDisposable
1111
{
12-
public const string COMMAND = "/rotation", USERNAME = "ArchiDog1998", REPO = "RotationSolver";
12+
public const string COMMAND = "/rotation", USERNAME = "FFXIV-CombatReborn", REPO = "RotationSolverReborn";
1313

1414
// From https://GitHub.com/PunishXIV/Orbwalker/blame/master/Orbwalker/Memory.cs#L85-L87
1515
[Signature("F3 0F 10 05 ?? ?? ?? ?? 0F 2E C6 0F 8A", ScanType = ScanType.StaticAddress, Fallibility = Fallibility.Infallible)]

RotationSolver/Commands/RSCommands_Actions.cs

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ public static partial class RSCommands
1515
static DateTime _lastClickTime = DateTime.MinValue;
1616
static bool _lastState;
1717

18+
public static void IncrementState()
19+
{
20+
if (!DataCenter.State) { DoStateCommandType(StateCommandType.Auto); return; }
21+
if (DataCenter.State && !DataCenter.IsManual && DataCenter.TargetingType == TargetingType.Big) { DoStateCommandType(StateCommandType.Auto); return; }
22+
if (DataCenter.State && !DataCenter.IsManual) { DoStateCommandType(StateCommandType.Manual); return; }
23+
if (DataCenter.State && DataCenter.IsManual) { DoStateCommandType(StateCommandType.Cancel); return; }
24+
}
25+
1826
internal static unsafe bool CanDoAnAction(bool isGCD)
1927
{
2028
if (!_lastState || !DataCenter.State)

RotationSolver/Data/UiString.cs

-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ internal enum UiString
4848
[Description("Rotation Solver helped you by clicking actions {0:N0} times.")]
4949
ConfigWindow_About_ClickingCount,
5050

51-
[Description("You have said hello to other users {0:N0} times!")]
52-
ConfigWindow_About_SayHelloCount,
53-
5451
[Description("Macro")]
5552
ConfigWindow_About_Macros,
5653

RotationSolver/UI/ControlWindow.cs

+4
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ static void DrawCommandAction(IAction? gcd, IAction? ability, SpecialCommandType
225225
ImGui.TextColored(color, str);
226226

227227
var help = command.Local();
228+
if (ability != null)
229+
{
230+
help = help + "\n" + $"({ability.Name})";
231+
}
228232
string baseId = "ImgButton" + command.ToString();
229233

230234
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + Math.Max(0, strWidth / 2 - width / 2));

RotationSolver/UI/RotationConfigWindow.cs

+7-36
Original file line numberDiff line numberDiff line change
@@ -308,26 +308,6 @@ private void DrawSideBar()
308308
}
309309
}
310310
}
311-
312-
if (wholeWidth <= 60 * Scale
313-
? IconSet.GetTexture("https://storage.ko-fi.com/cdn/brandasset/kofi_s_logo_nolabel.png", out var texture)
314-
: IconSet.GetTexture("https://storage.ko-fi.com/cdn/brandasset/kofi_bg_tag_dark.png", out texture))
315-
{
316-
var width = Math.Min(150 * Scale, Math.Max(Scale * MIN_COLUMN_WIDTH, Math.Min(wholeWidth, texture.Width)));
317-
var size = new Vector2(width, width * texture.Height / texture.Width);
318-
size *= MathF.Max(Scale * MIN_COLUMN_WIDTH / size.Y, 1);
319-
var result = false;
320-
ImGuiHelper.DrawItemMiddle(() =>
321-
{
322-
ImGui.SetCursorPosY(ImGui.GetWindowSize().Y + ImGui.GetScrollY() - size.Y);
323-
result = ImGuiHelper.NoPaddingNoColorImageButton(texture.ImGuiHandle, size, "Donate Plugin");
324-
}, wholeWidth, size.X);
325-
326-
if (result)
327-
{
328-
Util.OpenLink("https://ko-fi.com/B0B0IN5DX");
329-
}
330-
}
331311
}
332312
}
333313

@@ -542,12 +522,13 @@ private static void DrawRotationCombo(float comboSize, Type[] rotations, ICustom
542522
{
543523
if( DataCenter.IsPvP)
544524
{
545-
Service.Config.PvPRotationChoice = r.GetType().FullName;
525+
Service.Config.PvPRotationChoice = r.FullName;
546526
}
547527
else
548528
{
549-
Service.Config.RotationChoice = r.GetType().FullName;
529+
Service.Config.RotationChoice = r.FullName;
550530
}
531+
Service.Config.Save();
551532
}
552533
ImguiTooltips.HoveredTooltip(rAttr.Description);
553534
ImGui.PopStyleColor();
@@ -698,19 +679,6 @@ private static void DrawAbout()
698679
}
699680
}
700681
}
701-
702-
var sayHelloCount = OtherConfiguration.RotationSolverRecord.SayingHelloCount;
703-
if (sayHelloCount > 0)
704-
{
705-
using var color = ImRaii.PushColor(ImGuiCol.Text, new Vector4(0.2f, 0.8f, 0.95f, 1));
706-
var countStr = string.Format(UiString.ConfigWindow_About_SayHelloCount.Local(), sayHelloCount);
707-
708-
ImGuiHelper.DrawItemMiddle(() =>
709-
{
710-
ImGui.TextWrapped(countStr);
711-
}, width, ImGui.CalcTextSize(countStr).X);
712-
}
713-
714682
_aboutHeaders.Draw();
715683
}
716684

@@ -1724,7 +1692,9 @@ private static void DrawRotationsLoaded()
17241692
if (IconSet.GetTexture(IconSet.GetJobIcon(jobs.Key, IconType.Framed), out var texture, 62574))
17251693
ImGui.Image(texture.ImGuiHandle, Vector2.One * 30 * Scale);
17261694

1727-
ImguiTooltips.HoveredTooltip(string.Join('\n', jobs.Select(t => t.GetCustomAttribute<UIAttribute>()?.Name ?? t.Name)));
1695+
ImguiTooltips.HoveredTooltip(string.Join('\n', jobs.Select(t => t.GetCustomAttribute<UIAttribute>()?.Name ?? t.Name)) +
1696+
Environment.NewLine +
1697+
string.Join('\n', jobs.Select(t => t.GetCustomAttribute<RotationAttribute>()?.Type ?? CombatType.None)));
17281698
}
17291699

17301700
ImGui.TableNextColumn();
@@ -2562,6 +2532,7 @@ private static void DrawNextAction()
25622532
ImGui.Text("Ability Remain: " + DataCenter.AbilityRemain.ToString());
25632533
ImGui.Text("Action Remain: " + DataCenter.AnimationLocktime.ToString());
25642534
ImGui.Text("Weapon Remain: " + DataCenter.WeaponRemain.ToString());
2535+
ImGui.Text("Animation Lock Delay: " + ActionManagerHelper.GetCurrentAnimationLock().ToString());
25652536
}
25662537

25672538
private static void DrawLastAction()

RotationSolver/UI/RotationConfigWindow_Config.cs

-23
Original file line numberDiff line numberDiff line change
@@ -268,29 +268,6 @@ private static void DrawBasicNamedConditions()
268268
private static void DrawBasicOthers()
269269
{
270270
_allSearchable.DrawItems(Configs.BasicParams);
271-
272-
if (Service.Config.SayHelloToAll)
273-
{
274-
var str = Player.Object.EncryptString();
275-
ImGui.SetNextItemWidth(ImGui.CalcTextSize(str).X + 10);
276-
ImGui.InputText("That is your HASH:", ref str, 100);
277-
278-
if (!DataCenter.ContributorsHash.Contains(str)
279-
&& !DownloadHelper.UsersHash.Contains(str)
280-
&& !DataCenter.AuthorHashes.ContainsKey(str))
281-
{
282-
if (ImGui.Button("DM your Hash to ArchiTed for being greeted."))
283-
{
284-
ImGui.SetClipboardText(str);
285-
Notify.Success($"Your hash \"{str}\" copied to clipboard.");
286-
Util.OpenLink("https://discord.com/users/1007293294100877322");
287-
}
288-
}
289-
}
290-
else
291-
{
292-
ImGui.TextColored(ImGuiColors.DalamudRed, "The author of RS loves being greeted by you!");
293-
}
294271
}
295272
#endregion
296273

RotationSolver/Updaters/MajorUpdater.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ private static void UpdateWork()
171171

172172
try
173173
{
174-
TargetUpdater.UpdateTarget();
175174
StateUpdater.UpdateState();
176175

177176
if (Service.Config.AutoLoadCustomRotations)
@@ -180,10 +179,13 @@ private static void UpdateWork()
180179
}
181180

182181
RotationUpdater.UpdateRotation();
183-
184-
RaidTimeUpdater.UpdateTimeline();
185-
ActionSequencerUpdater.UpdateActionSequencerAction();
186-
ActionUpdater.UpdateNextAction();
182+
if (DataCenter.IsActivated())
183+
{
184+
TargetUpdater.UpdateTarget();
185+
RaidTimeUpdater.UpdateTimeline();
186+
ActionSequencerUpdater.UpdateActionSequencerAction();
187+
ActionUpdater.UpdateNextAction();
188+
}
187189

188190
RSCommands.UpdateRotationState();
189191
PainterManager.UpdateSettings();

RotationSolver/Updaters/PreviewUpdater.cs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private static void UpdateEntry()
4242
new IconPayload(BitmapFontIcon.DPS),
4343
new TextPayload(showStr)
4444
);
45+
_dtrEntry.OnClick = RSCommands.IncrementState;
4546
}
4647
else if (_dtrEntry != null && _dtrEntry.Shown)
4748
{

RotationSolver/Updaters/RotationUpdater.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,11 @@ private static void UpdateCustomRotation()
553553

554554
private static Type? GetChosenType(IEnumerable<Type> types, string name)
555555
{
556-
var rotation = types.FirstOrDefault(r => r.GetType().FullName == name);
556+
var rotation = types.FirstOrDefault(r => r.FullName == name);
557557

558-
rotation ??= types.FirstOrDefault(r => r.GetType().Assembly.FullName!.Contains("SupportersRotations", StringComparison.OrdinalIgnoreCase));
558+
rotation ??= types.FirstOrDefault(r => r.Assembly.FullName!.Contains("SupportersRotations", StringComparison.OrdinalIgnoreCase));
559559

560-
rotation ??= types.FirstOrDefault(r => r.GetType().Assembly.FullName!.Contains("DefaultRotations", StringComparison.OrdinalIgnoreCase));
560+
rotation ??= types.FirstOrDefault(r => r.Assembly.FullName!.Contains("DefaultRotations", StringComparison.OrdinalIgnoreCase));
561561

562562
rotation ??= types.FirstOrDefault();
563563

RotationSolver/Updaters/SocialUpdater.cs

-67
Original file line numberDiff line numberDiff line change
@@ -139,73 +139,10 @@ internal static async void UpdateSocial()
139139
_canSaying = false;
140140
Service.Config.DutyStart.AddMacro();
141141
await Task.Delay(new Random().Next(1000, 1500));
142-
143-
SayHelloToUsers();
144142
}
145143
}
146144

147145
private static readonly ChatEntityComparer _comparer = new();
148-
private static async void SayHelloToUsers()
149-
{
150-
if (!Service.Config.SayHelloToAll)
151-
{
152-
return;
153-
}
154-
155-
var players = DataCenter.AllianceMembers.OfType<PlayerCharacter>()
156-
#if DEBUG
157-
#else
158-
.Where(c => c.ObjectId != Player.Object.ObjectId)
159-
#endif
160-
.Select(player => (player, player.EncryptString()))
161-
.Where(pair => !saidAuthors.Contains(pair.Item2)
162-
&& !OtherConfiguration.RotationSolverRecord.SaidUsers.Contains(pair.Item2));
163-
164-
IEnumerable<ChatEntity> entities = players
165-
.Select(c =>
166-
{
167-
if (!DataCenter.AuthorHashes.TryGetValue(c.Item2, out var nameDesc)) nameDesc = string.Empty;
168-
return (c.player, nameDesc);
169-
})
170-
.Where(p => !string.IsNullOrEmpty(p.nameDesc))
171-
.Select(p => new RotationAuthorChatEntity(p.player, p.nameDesc));
172-
173-
entities = entities.Union(players
174-
.Where(p => DataCenter.ContributorsHash.Contains(p.Item2))
175-
.Select(p => new ContributorChatEntity(p.player)), _comparer);
176-
177-
if (Service.Config.SayHelloToUsers)
178-
{
179-
entities = entities.Union(players
180-
.Where(p => DownloadHelper.UsersHash.Contains(p.Item2))
181-
.Select(p => new UserChatEntity(p.player)), _comparer);
182-
}
183-
184-
foreach (var entity in entities)
185-
{
186-
while (!entity.CanTarget && !DataCenter.InCombat)
187-
{
188-
await Task.Delay(100);
189-
}
190-
191-
#if DEBUG
192-
#else
193-
Svc.Targets.Target = entity.player;
194-
ECommons.Automation.Chat.Instance.SendMessage($"/{_macroToAuthor[new Random().Next(_macroToAuthor.Count)]} <t>");
195-
#endif
196-
Svc.Chat.Print(new Dalamud.Game.Text.XivChatEntry()
197-
{
198-
Message = entity.GetMessage(),
199-
Type = Dalamud.Game.Text.XivChatType.Notice,
200-
});
201-
UIModule.PlaySound(20, 0, 0, 0);
202-
entity.Dispose();
203-
204-
await Task.Delay(new Random().Next(800, 1200));
205-
Svc.Targets.Target = null;
206-
await Task.Delay(new Random().Next(800, 1200));
207-
}
208-
}
209146

210147
internal abstract class ChatEntity(PlayerCharacter character) : IDisposable
211148
{
@@ -247,10 +184,6 @@ public void Dispose()
247184
OtherConfiguration.RotationSolverRecord.SayingHelloCount++;
248185
var hash = player.EncryptString();
249186
saidAuthors.Add(hash);
250-
if (Service.Config.JustSayHelloOnce)
251-
{
252-
OtherConfiguration.RotationSolverRecord.SaidUsers.Add(hash);
253-
}
254187
}
255188
}
256189

manifest.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
2-
"Author": "ArchiTed",
2+
"Author": "The FFXIV-CombatReborn Team",
33
"Name": "Rotation Solver",
44
"InternalName": "RotationSolver",
55
"Description": "Analyses combat information every frame and finds the best action.\n\nThis means almost all the information available in one frame in combat, including the status of all players in the party, the status of any hostile targets, skill cooldowns, the MP and HP of characters, the location of characters, casting status of the hostile target, combo, combat duration, player level, etc.\nThen, it will highlight the best action on the hot bar, or help you to click on it.\nIt is designed for `general combat`, not for savage or ultimate. Use it carefully.",
66
"ApplicableVersion": "any",
77
"Tags": [
88
"combat",
9-
"rotation"
9+
"rotation",
10+
"auto",
11+
"solver",
12+
"pve",
13+
"pvp"
1014
],
1115
"CategoryTags": [
1216
"jobs"
@@ -17,7 +21,7 @@
1721
"CanUnloadAsync": false,
1822
"LoadPriority": 0,
1923
"IsTestingExclusive": false,
20-
"IconUrl": "https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/Images/Logo.png",
24+
"IconUrl": "https://raw.githubusercontent.com/FFXIV-CombatReborn/RotationSolverReborn/main/Images/Logo.png",
2125
"Punchline": "Analyses combat information every frame and finds the best action.",
2226
"AcceptsFeedback": true
2327
}

0 commit comments

Comments
 (0)