diff --git a/Resources/HostileCastingArea.json b/Resources/HostileCastingArea.json index c2ddc9e31..cd7773c7d 100644 --- a/Resources/HostileCastingArea.json +++ b/Resources/HostileCastingArea.json @@ -514,5 +514,7 @@ 26064, 33445, 35218, - 32945 + 32945, + 22247, + 22238 ] \ No newline at end of file diff --git a/Resources/RotationSolverRecord.json b/Resources/RotationSolverRecord.json index a22cddddf..817ec055c 100644 --- a/Resources/RotationSolverRecord.json +++ b/Resources/RotationSolverRecord.json @@ -1,5 +1,5 @@ { - "ClickingCount": 94943, - "SayingHelloCount": 148, + "ClickingCount": 97701, + "SayingHelloCount": 158, "SaidUsers": [] } \ No newline at end of file diff --git a/RotationSolver.Basic/Configuration/Configs.cs b/RotationSolver.Basic/Configuration/Configs.cs index e0325d6d4..8105bc344 100644 --- a/RotationSolver.Basic/Configuration/Configs.cs +++ b/RotationSolver.Basic/Configuration/Configs.cs @@ -425,10 +425,6 @@ public const string [Range(0, 600, ConfigUnitType.Seconds)] public float AutoOffAfterCombatTime { get; set; } = 30; - [UI("The height of the drawing things.", Parent =nameof(UseOverlayWindow))] - [Range(0, 8, ConfigUnitType.Yalms, 0.02f)] - public float DrawingHeight { get; set; } = 3; - [UI("Drawing smoothness.", Parent = nameof(UseOverlayWindow))] [Range(0.005f, 0.05f, ConfigUnitType.Yalms, 0.001f)] public float SampleLength { get; set; } = 1; @@ -635,9 +631,6 @@ public const string [UI("Target color", Parent =nameof(TargetColor))] public Vector4 TargetColor { get; set; } = new(1f, 0.2f, 0f, 0.8f); - [UI("Sub-target color", Parent = nameof(TargetColor))] - public Vector4 SubTargetColor { get; set; } = new(1f, 0.9f, 0f, 0.8f); - [UI("The color of beneficial AoE positions", Parent =nameof(ShowBeneficialPositions))] public Vector4 BeneficialPositionColor { get; set; } = new(0.5f, 0.9f, 0.1f, 0.7f); diff --git a/RotationSolver/Localization/Localization.json b/RotationSolver/Localization/Localization.json index 0e3ae342a..bc24677d6 100644 --- a/RotationSolver/Localization/Localization.json +++ b/RotationSolver/Localization/Localization.json @@ -355,5 +355,7 @@ "UseGroundBeneficialAbilityName": "Use beneficial ground-targeted actions", "UseDefenseAbilityDescription": "It is recommended to check this option if you are playing Raids or you can plan the heal and defense ability usage by yourself.", "BeneficialAreaStrategyName": "Beneficial AoE strategy", - "UseGroundBeneficialAbilityWhenMovingName": "Use beneficial AoE actions when moving." + "UseGroundBeneficialAbilityWhenMovingName": "Use beneficial AoE actions when moving.", + "RotationSolver.Data.UiString.SpecialCommandType_TankStance": "Tank Stance", + "RotationSolver.Data.UiString.ConfigWindow_Actions_TTU": "Time to untargetable that this action needs the timeline be." } \ No newline at end of file diff --git a/RotationSolver/RotationSolverPlugin.cs b/RotationSolver/RotationSolverPlugin.cs index c352ab54f..b4562af0c 100644 --- a/RotationSolver/RotationSolverPlugin.cs +++ b/RotationSolver/RotationSolverPlugin.cs @@ -15,6 +15,9 @@ using RotationSolver.Localization; using RotationSolver.UI; using RotationSolver.Updaters; +using System.Runtime.InteropServices; +using XIVPainter.Enum; +using XIVPainter.Vfx; namespace RotationSolver; @@ -92,11 +95,7 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface) await DownloadHelper.DownloadAsync(); await RotationUpdater.GetAllCustomRotationsAsync(DownloadOption.Download); }); - //VfxManager.OnGround("vfx/monster/m0095/eff/m0095sp_07c4m.avfx", false); - VfxManager.Remove(); - var obj = VfxManager.OnGround("vfx/omen/eff/general_1bf.avfx", false); - //VfxManager.UpdateScale(obj, Vector3.One * 5); - //VfxManager.Test(obj); + //var vfx = new StaticVfx(GroundOmenFriendly.Rectangle02, Player.Object, Vector3.One); } internal static void ChangeUITranslation() diff --git a/RotationSolver/UI/PainterManager.cs b/RotationSolver/UI/PainterManager.cs index a7611e096..9b4ce86e2 100644 --- a/RotationSolver/UI/PainterManager.cs +++ b/RotationSolver/UI/PainterManager.cs @@ -130,20 +130,6 @@ public override void UpdateOnFrame(XIVPainter.XIVPainter painter) subItems.Add(_target); } - if (act.Target.HasValue && (DataCenter.AllHostileTargets.Contains(act.Target?.Target) || act.Target?.Target == Player.Object && !act.Setting.IsFriendly)) - { - var SColor = ImGui.GetColorU32(Service.Config.SubTargetColor); - - foreach (var t in act.Target!.Value.AffectedTargets) - { - if (t == act.Target?.Target) continue; - subItems.Add(new Drawing3DCircularSector(t.Position, targetRadius * ratio, SColor, 3) - { - IsFill = false, - }); - } - } - SubItems = [.. subItems]; base.UpdateOnFrame(painter); @@ -296,7 +282,6 @@ public static void Init() public static void UpdateSettings() { if (_painter == null) return; - _painter.DrawingHeight = Service.Config.DrawingHeight; _painter.SampleLength = Service.Config.SampleLength; _painter.UseTaskToAccelerate = Service.Config.UseTasksForOverlay; _painter.Enable = !Svc.Condition[ConditionFlag.OccupiedInCutSceneEvent] && Service.Config.UseOverlayWindow; diff --git a/RotationSolver/Updaters/ActionUpdater.cs b/RotationSolver/Updaters/ActionUpdater.cs index 3fdde7be8..219bddbbd 100644 --- a/RotationSolver/Updaters/ActionUpdater.cs +++ b/RotationSolver/Updaters/ActionUpdater.cs @@ -2,11 +2,14 @@ using Dalamud.Game.ClientState.Objects.SubKinds; using ECommons.DalamudServices; using ECommons.GameHelpers; +using ExCSS; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.UI.Agent; using RotationSolver.Commands; using System.Text.RegularExpressions; using System.Windows.Forms; +using XIVPainter.Enum; +using XIVPainter.Vfx; namespace RotationSolver.Updaters; @@ -17,7 +20,72 @@ internal static class ActionUpdater static RandomDelay _GCDDelay = new(() => Service.Config.WeaponDelay); internal static IAction? NextAction { get; set; } - internal static IBaseAction? NextGCDAction { get; set; } + + //private static StaticVfx? circle, sector, rectangle; + private static StaticVfx? drawer; + private static IBaseAction? _nextGCDAction; + const float gcdHeight = 5; + internal static IBaseAction? NextGCDAction + { + get => _nextGCDAction; + set + { + if (_nextGCDAction == value) return; + _nextGCDAction = value; + + + drawer?.Dispose(); + if (!Service.Config.ShowTarget) return; + + var player = Player.Object; + if (player == null) return; + + //circle ??= new(GroundOmenFriendly.Circle1, player, new Vector3(0, gcdHeight, 0)); + //sector ??= new(GroundOmenFriendly.CircularSector120, player, new Vector3(0, gcdHeight, 0)); + //rectangle ??= new(GroundOmenType.Rectangle02, player, new Vector3(0, gcdHeight, 0)); + + //circle.Enable = sector.Enable = rectangle.Enable = false; + //circle.Owner = sector.Owner = rectangle.Owner = player; + + if (value == null) return; + var target = value.Target?.Target; + if (target == null) return; + + var range = value.Action.EffectRange; + var size = new Vector3(range, gcdHeight, range); + switch(value.Action.CastType) + { + //ase 1: + case 2: + drawer = new(GroundOmenFriendly.Circle1, target, size); + //circle.Owner = target; + //circle.UpdateScale(size); + //circle.Enable = true; + break; + + case 3: + drawer = new(GroundOmenFriendly.CircularSector120, player, size) + { + Target = target + }; + //sector.Target = target; + //sector.UpdateScale(size); + //sector.Enable = true; + break; + + case 4: + size.X = 2; + drawer = new(GroundOmenFriendly.Rectangle02, player, size) + { + Target = target + }; + //rectangle.Target = target; + //rectangle.UpdateScale(size); + //rectangle.Enable = true; + break; + } + } + } internal static IAction? WrongAction { get; set; } static readonly Random _wrongRandom = new(); diff --git a/RotationSolver/VfxManager.cs b/RotationSolver/VfxManager.cs deleted file mode 100644 index bbf1edd61..000000000 --- a/RotationSolver/VfxManager.cs +++ /dev/null @@ -1,98 +0,0 @@ -using ECommons.DalamudServices; -using ECommons.Reflection; -using System.Runtime.InteropServices; - -namespace RotationSolver; -#if DEBUG -internal static class VfxManager -{ - internal static void Remove() - { - _vfxSpawnRemove.Value?.Invoke(null, []); - } - - internal static object? OnGround(string path, bool canLoop) - { - _vfxSpawnOnGround.Value?.Invoke(null, [path, canLoop]); - return _vfxObjectGetter.Value?.GetValue(null); - } - - internal static void UpdateScale(object? obj, Vector3 scale) - { - if (obj == null) return; - _vfxObjectScale.Value?.Invoke(obj, [scale]); - } - - internal unsafe static void Test(object? obj) - { - if (obj == null) return; - - var field = obj.GetType().BaseType!.GetRuntimeFields().FirstOrDefault(f => f.Name == "Vfx"); - if (field == null) return; - - var vfxStruct = (IntPtr)Pointer.Unbox((Pointer)field.GetValue(obj)!) + 0x45; - Svc.Log.Error(Marshal.ReadInt32(vfxStruct).ToString("X")); - } - - internal static void UpdateRotation(object? obj, Vector3 scale) - { - if (obj == null) return; - _vfxObjectRotation.Value?.Invoke(obj, [scale]); - } - - private static readonly Lazy _vfxObjectScale = new(() => - { - return GetMethodFromVfxObject("UpdateScale"); - }); - - private static readonly Lazy _vfxObjectRotation = new(() => - { - return GetMethodFromVfxObject("UpdateRotation"); - }); - - private static MethodInfo? GetMethodFromVfxObject(string name) - { - return _vfxObjectGetter?.Value?.GetValue(null)?.GetType().GetAllMethodInfo().FirstOrDefault(m => m.Name == name); - } - - private static readonly Lazy _vfxObjectGetter = new(() => - { - return _vfxSpawnType?.Value.GetAllPropertyInfo().FirstOrDefault(p => p.Name == "Vfx"); - }); - private static readonly Lazy _vfxSpawnType = new(() => GetTypeFromVfx("VfxSpawn")); - private static readonly Lazy _staticVfxType = new(() => GetTypeFromVfx("StaticVfx")); - - private static readonly Lazy _vfxSpawnOnGround = new(() => GetMethodFromVfx("OnGround")); - private static readonly Lazy _vfxSpawnRemove = new(() => GetMethodFromVfx("Remove")); - - private static MethodInfo? GetMethodFromVfx(string method) - { - var value = _vfxSpawnType.Value.GetAllMethodInfo().FirstOrDefault(m => m.Name == method); - if (value == null) - { - Svc.Log.Debug($"Failed to find the method {method}."); - } - return value; - } - - private static Type? GetTypeFromVfx(string typeName) - { - var value = _vfxEditorAssembly?.Value?.GetTypes().FirstOrDefault(t => t.Name == typeName); - if (value == null) - { - Svc.Log.Debug($"Failed to find the type {typeName}."); - } - return value; - } - - private static readonly Lazy _vfxEditorAssembly = new(() => - { - DalamudReflector.TryGetDalamudPlugin("VFXEditor", out var instance); - if (instance != null) - { - Svc.Log.Debug("Loaded VFX Editor successfully."); - } - return instance?.GetType().Assembly; - }); -} -#endif \ No newline at end of file diff --git a/RotationSolver/Watcher.cs b/RotationSolver/Watcher.cs index c3505eaf6..9296bb5b5 100644 --- a/RotationSolver/Watcher.cs +++ b/RotationSolver/Watcher.cs @@ -9,9 +9,9 @@ using FFXIVClientStructs.FFXIV.Client.Game; using Lumina.Excel.GeneratedSheets; using RotationSolver.Basic.Configuration; -using System.Runtime.InteropServices; -using System.Text; using System.Text.RegularExpressions; +using XIVPainter.Enum; +using XIVPainter.Vfx; using GameObject = FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject; namespace RotationSolver; @@ -21,13 +21,6 @@ public static class Watcher #if DEBUG private unsafe delegate bool OnUseAction(ActionManager* manager, ActionType actionType, uint actionID, ulong targetID, uint a4, uint a5, uint a6, void* a7); private static Hook? _useActionHook; - - private unsafe delegate void* GetResourceSyncPrototype(IntPtr pFileManager, uint* pCategoryId, char* pResourceType, uint* pResourceHash, char* pPath, void* pUnknown); - - private unsafe delegate void* GetResourceAsyncPrototype(IntPtr pFileManager, uint* pCategoryId, char* pResourceType, uint* pResourceHash, char* pPath, void* pUnknown, bool isUnknown); - - static Hook? _getResourceSyncHook; - static Hook? _getResourceAsyncHook; #endif private unsafe delegate long ProcessObjectEffect(GameObject* a1, ushort a2, ushort a3, long a4); @@ -45,12 +38,6 @@ public static void Enable() #if DEBUG _useActionHook = Svc.Hook.HookFromSignature("E8 ?? ?? ?? ?? EB 64 B1 01", UseActionDetour); //_useActionHook.Enable(); - - _getResourceSyncHook = Svc.Hook.HookFromSignature("E8 ?? ?? ?? ?? 48 8D 8F ?? ?? ?? ?? 48 89 87 ?? ?? ?? ?? 48 8D 54 24", GetResourceSyncDetour); - _getResourceSyncHook.Enable(); - - _getResourceAsyncHook = Svc.Hook.HookFromSignature("E8 ?? ?? ?? ?? 48 8B D8 EB 07 F0 FF 83", GetResourceAsyncDetour); - _getResourceAsyncHook.Enable(); #endif //From https://github.com/PunishXIV/Splatoon/blob/main/Splatoon/Memory/ObjectEffectProcessor.cs#L14 _processObjectEffectHook = Svc.Hook.HookFromSignature("40 53 55 56 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 0F B7 FA", ProcessObjectEffectDetour); @@ -75,7 +62,7 @@ public static void Enable() var effect = new MapEffectData(position, param1, param2); DataCenter.MapEffects.Enqueue(effect); #if DEBUG - Svc.Log.Debug(effect.ToString()); + //Svc.Log.Debug(effect.ToString()); #endif }); } @@ -84,8 +71,6 @@ public static void Disable() { #if DEBUG _useActionHook?.Dispose(); - _getResourceAsyncHook?.Dispose(); - _getResourceSyncHook?.Dispose(); #endif _processObjectEffectHook?.Dispose(); _actorVfxCreateHook?.Dispose(); @@ -111,7 +96,10 @@ private static IntPtr ActorVfxNewHandler(string path, IntPtr a2, IntPtr a3, floa var effect = new VfxNewData(obj?.ObjectId ?? Dalamud.Game.ClientState.Objects.Types.GameObject.InvalidGameObjectId, path); DataCenter.VfxNewData.Enqueue(effect); #if DEBUG - Svc.Log.Debug($"On Object {obj?.Name ?? "No Body"}, path: {effect}"); + if (!Enum.GetValues().Any(i => i.GetAttribute()?.Path == path)) + { + Svc.Log.Debug("Object: " + path); + } #endif } } @@ -159,60 +147,6 @@ private static unsafe bool UseActionDetour(ActionManager* manager, ActionType ac } return _useActionHook!.Original(manager, actionType, actionID, targetID, a4, a5, a6, a7); } - - private unsafe static void* GetResourceSyncDetour(IntPtr pFileManager, uint* pCategoryId, char* pResourceType, uint* pResourceHash, char* pPath, void* pUnknown) - { - return ResourceDetour(true, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, false); - } - - private unsafe static void* GetResourceAsyncDetour(IntPtr pFileManager, uint* pCategoryId, char* pResourceType, uint* pResourceHash, char* pPath, void* pUnknown, bool isUnknown) - { - return ResourceDetour(false, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown); - } - - private unsafe static void* ResourceDetour(bool isSync, IntPtr pFileManager, uint* pCategoryId, char* pResourceType, uint* pResourceHash, char* pPath, void* pUnknown, bool isUnknown) - { - var ret = CallOriginalResourceHandler(isSync, pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown); - - var path = ReadTerminatedString((byte*)pPath); - - if (path.EndsWith("avfx") && path.StartsWith("vfx/omen/eff/")) - { - Svc.Log.Debug(path); - } - - return ret; - } - - private static unsafe byte[] ReadTerminatedBytes(byte* ptr) - { - if (ptr == null) - { - return new byte[0]; - } - - var bytes = new List(); - while (*ptr != 0) - { - bytes.Add(*ptr); - ptr += 1; - } - - return bytes.ToArray(); - } - - internal static unsafe string ReadTerminatedString(byte* ptr) - { - return Encoding.UTF8.GetString(ReadTerminatedBytes(ptr)); - } - - private unsafe static void* CallOriginalResourceHandler(bool isSync, IntPtr pFileManager, uint* pCategoryId, char* pResourceType, uint* pResourceHash, char* pPath, void* pUnknown, bool isUnknown) - { - return isSync - ? _getResourceSyncHook!.Original(pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown) - : _getResourceAsyncHook!.Original(pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown); - } - #endif private static void UpdateRTTDetour(dynamic obj) diff --git a/XIVPainter b/XIVPainter index e0fb5bbc6..4310b7353 160000 --- a/XIVPainter +++ b/XIVPainter @@ -1 +1 @@ -Subproject commit e0fb5bbc686e807e6cd34ba6eb5b3cc96aac7640 +Subproject commit 4310b7353ad771b31ddc1f5949e5d8405bc4b95a