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

Commit

Permalink
fix: casting action preview and some configs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 3, 2024
1 parent 31c74a0 commit ff2fd04
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 45 deletions.
4 changes: 2 additions & 2 deletions Resources/RotationSolverRecord.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ClickingCount": 97701,
"SayingHelloCount": 158,
"ClickingCount": 98903,
"SayingHelloCount": 162,
"SaidUsers": []
}
4 changes: 4 additions & 0 deletions RotationSolver.Basic/Actions/BaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public ActionConfig Config
{
Service.Config.RotationActionConfig[ID] = value
= Setting.CreateConfig?.Invoke() ?? new();
if (Action.ClassJob.Value?.GetJobRole() == JobRole.Tank)
{
value.AoeCount = 2;
}
if (value.TimeToUntargetable == 0)
{
value.TimeToUntargetable = value.TimeToKill;
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public const string
private static readonly bool _showInfoOnToast = true;

[ConditionBool, UI("Lock the movement when casting or when doing some actions.", Filter = Extra)]
private static readonly bool _poslockCasting = false;
private static readonly bool _poslockCasting = true;

[UI("", Action = ActionID.PassageOfArmsPvE, Parent = nameof(PoslockCasting))]
public bool PosPassageOfArms { get; set; } = false;
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,6 @@
"BeneficialAreaStrategyName": "Beneficial AoE strategy",
"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."
"RotationSolver.Data.UiString.ConfigWindow_Actions_TTU": "Time to untargetable that this action needs the timeline be.",
"TargetDelayName": "The range of random delay for finding a target."
}
15 changes: 14 additions & 1 deletion RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,20 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface)
await DownloadHelper.DownloadAsync();
await RotationUpdater.GetAllCustomRotationsAsync(DownloadOption.Download);
});
//var vfx = new StaticVfx(GroundOmenFriendly.Rectangle02, Player.Object, Vector3.One);

#if DEBUG
if (Player.Available)
{
_ = new ActorVfx(Player.Object, Player.Object,
"vfx/ws/2rp_ws_s06/eff/2rp_ws06c0h.avfx")
{
};
//_ = new StaticVfx("vfx/lockon/eff/com_share0c.avfx", Player.Object, Vector3.One)
//{
// //DeadTime = DateTime.Now.AddSeconds(5),
//};
}
#endif
}

internal static void ChangeUITranslation()
Expand Down
18 changes: 14 additions & 4 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,24 @@ public static void DisplayEvent(this ActionEventInfo info)
public unsafe static ImFontPtr GetFont(float size)
{
var style = new Dalamud.Interface.GameFonts.GameFontStyle(Dalamud.Interface.GameFonts.GameFontStyle.GetRecommendedFamilyAndSize(Dalamud.Interface.GameFonts.GameFontFamily.Axis, size));
var font = Svc.PluginInterface.UiBuilder.GetGameFontHandle(style).ImFont;

if ((IntPtr)font.NativePtr == IntPtr.Zero)
var handle = Svc.PluginInterface.UiBuilder.FontAtlas.NewGameFontHandle(style);

try
{
var font = handle.Lock().ImFont;

if ((IntPtr)font.NativePtr == IntPtr.Zero)
{
return ImGui.GetFont();
}
font.Scale = size / style.BaseSizePt;
return font;
}
catch
{
return ImGui.GetFont();
}
font.Scale = size / style.BaseSizePt;
return font;
}

public static void SearchCombo<T>(string popId, string name, ref string searchTxt, T[] items, Func<T, string> getSearchName, Action<T> selectAction, string searchingHint, ImFontPtr? font = null, Vector4? color = null)
Expand Down
46 changes: 17 additions & 29 deletions RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ internal static class ActionUpdater

internal static IAction? NextAction { get; set; }

//private static StaticVfx? circle, sector, rectangle;
private static StaticVfx? drawer;
private static StaticVfx? circle, sector, rectangle;
private static IBaseAction? _nextGCDAction;
const float gcdHeight = 5;
internal static IBaseAction? NextGCDAction
Expand All @@ -33,19 +32,17 @@ internal static IBaseAction? NextGCDAction
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 ??= new(GroundOmenFriendly.Circle1, player, new Vector3(0, gcdHeight, 0));
sector ??= new(GroundOmenFriendly.CircularSector120, player, new Vector3(0, gcdHeight, 0));
rectangle ??= new(GroundOmenFriendly.Rectangle01, player, new Vector3(0, gcdHeight, 0));

//circle.Enable = sector.Enable = rectangle.Enable = false;
//circle.Owner = sector.Owner = rectangle.Owner = player;
circle.Enable = sector.Enable = rectangle.Enable = false;
circle.Owner = sector.Owner = rectangle.Owner = player;

if (value == null) return;
var target = value.Target?.Target;
Expand All @@ -55,33 +52,24 @@ internal static IBaseAction? NextGCDAction
var size = new Vector3(range, gcdHeight, range);
switch(value.Action.CastType)
{
//ase 1:
//case 1:
case 2:
drawer = new(GroundOmenFriendly.Circle1, target, size);
//circle.Owner = target;
//circle.UpdateScale(size);
//circle.Enable = true;
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;
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;
size.X = value.Action.XAxisModifier / 2;
rectangle.Target = target;
rectangle.UpdateScale(size);
rectangle.Enable = true;
break;
}
}
Expand Down
55 changes: 49 additions & 6 deletions RotationSolver/Updaters/RaidTimeUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using Lumina.Excel.GeneratedSheets;
using Newtonsoft.Json.Linq;
using RotationSolver.Basic.Configuration.Timeline;
using RotationSolver.UI;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using XIVPainter.Vfx;

namespace RotationSolver.Updaters;
internal static partial class RaidTimeUpdater
Expand Down Expand Up @@ -182,7 +185,7 @@ private static void Chat_ChatMessage(Dalamud.Game.Text.XivChatType type, uint se

private static void GameNetwork_NetworkMessage(nint dataPtr, ushort opCode, uint sourceActorId, uint targetActorId, Dalamud.Game.Network.NetworkMessageDirection direction)
{
if (direction != Dalamud.Game.Network.NetworkMessageDirection.ZoneDown) return;
//if (direction != Dalamud.Game.Network.NetworkMessageDirection.ZoneDown) return;
OpCode op = (OpCode)opCode;

switch (op)
Expand All @@ -209,18 +212,57 @@ private static void GameNetwork_NetworkMessage(nint dataPtr, ushort opCode, uint
private static void OnCast(IntPtr dataPtr, uint targetActorId)
{
var name = GetNameFromObjectId(targetActorId);
var actionId = ReadUshort(dataPtr, 0);

foreach (var item in DataCenter.TimelineItems)
{
if (!item.IsInWindow) continue;
if (item.Type is not TimelineType.StartsUsing) continue;

if (!item["id", ReadUshort(dataPtr, 0)]) continue;
if (!item["id", actionId]) continue;
if (!item["source", name]) continue;

item.UpdateRaidTimeOffset();
break;
}

OmenCastingAction(dataPtr, targetActorId, actionId);
}

private static void OmenCastingAction(IntPtr dataPtr, uint targetActorId, ushort actionId)
{
var tar = DataCenter.AllHostileTargets.FirstOrDefault(t => t.ObjectId == targetActorId);
if (tar == null) return;

var castingTime = ReadFloat(dataPtr, 0x08);
var action = Svc.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>()?.GetRow(actionId);
var omenStr = action?.Omen.Value?.Path.RawString;
if (action != null && !string.IsNullOrEmpty(omenStr))
{
//Unknown30 May be that the action should be used.
Svc.Log.Debug($"{action.RowId} {action.Name.RawString} {omenStr}");

if (action.TargetArea)
{
//Target Area??
}
else
{
var x = action.XAxisModifier > 0 ? action.XAxisModifier / 2 : action.EffectRange;
var scale = new Vector3(x, 10, action.EffectRange);
_ = new StaticVfx($"vfx/omen/eff/{omenStr}.avfx", tar, scale)
{
DeadTime = DateTime.Now.AddSeconds(castingTime),
RotateAddition = action.AnimationStart.Row switch
{
10 => MathF.PI / 2,
11 => -MathF.PI / 2,
_ => 0,
}
//TODO: The casting target, maybe. for some special type of actions.
};
}
}
}

static DateTime _actionUpdateTime = DateTime.MinValue;
Expand Down Expand Up @@ -290,6 +332,11 @@ private unsafe static uint ReadUint(IntPtr dataPtr, int offset)
return *(uint*)(dataPtr + offset);
}

private unsafe static float ReadFloat(IntPtr dataPtr, int offset)
{
return *(float*)(dataPtr + offset);
}

private static string GetNameFromObjectId(uint id)
{
var obj = Svc.Objects.SearchById(id);
Expand All @@ -298,11 +345,7 @@ private static string GetNameFromObjectId(uint id)

if (!string.IsNullOrEmpty(name)) return name;

#if DEBUG
return "Failed to find the NPC name!";
#else
return obj?.Name.TextValue ?? string.Empty;
#endif
}

private static async void ClientState_TerritoryChanged(ushort id)
Expand Down
2 changes: 1 addition & 1 deletion XIVPainter

0 comments on commit ff2fd04

Please sign in to comment.