Skip to content

Commit b8be578

Browse files
committed
Update script and other stuff
1 parent 64db34e commit b8be578

File tree

11 files changed

+363
-137
lines changed

11 files changed

+363
-137
lines changed

Splatoon/Gui/Layouts/Elements/LayoutDrawElement.cs

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ internal void LayoutDrawElement(Layout l, Element el, bool forceEnable = false)
242242
ImGuiEx.Tooltip("Fixed angle mode. Face fixed angle.");
243243
ImGui.SameLine();
244244
if(!el.RotationOverrideAngleOnlyMode)
245-
{
245+
{
246246
ImGuiEx.TextV("Rotate towards:");
247247
ImGui.SameLine();
248248
ImGuiEx.Text($"X:");
@@ -462,6 +462,83 @@ internal void LayoutDrawElement(Layout l, Element el, bool forceEnable = false)
462462
ImGui.SetNextItemWidth(200f);
463463
ImGuiEx.EnumCombo("##alter", ref el.TargetAlteration);
464464

465+
if(el.refActorType == 0)
466+
{
467+
ImGuiUtils.SizedText("Enumeration:".Loc(), WidthElement);
468+
ImGui.SameLine();
469+
ImGui.SetNextItemWidth(200f);
470+
ImGuiEx.EnumCombo("##enumerate", ref el.Enumeration);
471+
if(el.Enumeration != EnumerationType.None)
472+
{
473+
ImGuiUtils.SizedText("Center:".Loc(), WidthElement);
474+
ImGui.SameLine();
475+
ImGuiEx.Text($"X:");
476+
ImGui.SameLine();
477+
ImGui.SetNextItemWidth(50f);
478+
ImGui.DragFloat("##enumCx", ref el.EnumerationCenter.X, 0.1f);
479+
ImGui.SameLine();
480+
ImGuiEx.Text($"Y:");
481+
ImGui.SameLine();
482+
ImGui.SetNextItemWidth(50f);
483+
ImGui.DragFloat("##enumCy", ref el.EnumerationCenter.Y, 0.1f);
484+
485+
ImGuiUtils.SizedText("Starting Position:".Loc(), WidthElement);
486+
ImGui.SameLine();
487+
ImGuiEx.Text($"X:");
488+
ImGui.SameLine();
489+
ImGui.SetNextItemWidth(50f);
490+
ImGui.DragFloat("##enumSx", ref el.EnumerationStart.X, 0.1f);
491+
ImGui.SameLine();
492+
ImGuiEx.Text($"Y:");
493+
ImGui.SameLine();
494+
ImGui.SetNextItemWidth(50f);
495+
ImGui.DragFloat("##enumSy", ref el.EnumerationStart.Y, 0.1f);
496+
}
497+
ImGuiUtils.SizedText("Enumeration Positions:".Loc(), WidthElement);
498+
ImGui.SameLine();
499+
ImGuiEx.SetNextItemFullWidth();
500+
if(ImGui.BeginCombo($"##positions", el.EnumerationOrder.Count == 0?"Enter Enumeration Positions".Loc() : $"{el.EnumerationOrder.Print()}", ImGuiComboFlags.HeightLarge))
501+
{
502+
ref var inp = ref Ref<int>.Get("EnumerationInput");
503+
ImGui.SetNextItemWidth(150f);
504+
ImGui.InputInt("Add Position", ref inp);
505+
ImGui.SameLine();
506+
if(ImGuiEx.IconButtonWithText(FontAwesomeIcon.Plus, "Add"))
507+
{
508+
if(inp == 0)
509+
{
510+
Notify.Error("Enumeration starts with 1 or -1");
511+
}
512+
else if(el.EnumerationOrder.Contains(inp))
513+
{
514+
Notify.Error("This value is already added");
515+
}
516+
else
517+
{
518+
el.EnumerationOrder.Add(inp);
519+
el.EnumerationOrder.Sort();
520+
inp = 0;
521+
}
522+
}
523+
if(ImGuiEx.BeginDefaultTable("EnumTable", ["Point", "Func"], drawHeader: false))
524+
{
525+
foreach(var x in el.EnumerationOrder)
526+
{
527+
ImGui.TableNextRow();
528+
ImGui.TableNextColumn();
529+
ImGuiEx.Text($"{x}");
530+
ImGui.TableNextColumn();
531+
if(ImGuiEx.SmallIconButton(FontAwesomeIcon.Trash, $"Del{x}"))
532+
{
533+
new TickScheduler(() => el.EnumerationOrder.Remove(x));
534+
}
535+
}
536+
ImGui.EndTable();
537+
}
538+
ImGui.EndCombo();
539+
}
540+
}
541+
465542
ImGuiUtils.SizedText("Targetability: ".Loc(), WidthElement);
466543
ImGui.SameLine();
467544
ImGui.SetNextItemWidth(100f);
@@ -552,7 +629,7 @@ internal void LayoutDrawElement(Layout l, Element el, bool forceEnable = false)
552629
foreach(var x in Svc.Objects.OfType<IBattleNpc>().Where(x => x.IsCasting()))
553630
{
554631
ImGui.PushID(i++);
555-
if(ImGui.Selectable($"{ExcelActionHelper.GetActionName(x.CastActionId, true)} - {x.CurrentCastTime:F1}/{x.TotalCastTime:F1} - from {x.Name} N#{x.NameId} D#{x.DataId}", selected:el.refActorCastId.Contains(x.CastActionId), flags:ImGuiSelectableFlags.DontClosePopups))
632+
if(ImGui.Selectable($"{ExcelActionHelper.GetActionName(x.CastActionId, true)} - {x.CurrentCastTime:F1}/{x.TotalCastTime:F1} - from {x.Name} N#{x.NameId} D#{x.DataId}", selected: el.refActorCastId.Contains(x.CastActionId), flags: ImGuiSelectableFlags.DontClosePopups))
556633
{
557634
if(ImGuiEx.Shift) el.refActorCastId.Clear();
558635
el.refActorCastId.Toggle(x.CastActionId);
@@ -605,9 +682,24 @@ internal void LayoutDrawElement(Layout l, Element el, bool forceEnable = false)
605682
ImGui.Checkbox("Overcast".Loc(), ref el.refActorUseOvercast);
606683
ImGuiComponents.HelpMarker("Enable use of cast values that exceed cast time, effectively behaving like cast bar would continue to be displayed after cast already happened".Loc());
607684
}
685+
if(el.includeRotation && !el.RotationOverride)
686+
{
687+
ImGuiUtils.SizedText("", WidthElement);
688+
ImGui.SameLine();
689+
ImGui.Checkbox("Derive rotation from cast info", ref el.UseCastRotation);
690+
}
691+
/*
692+
ImGuiUtils.SizedText("", WidthElement);
693+
ImGui.SameLine();
694+
ImGui.Checkbox("Derive position from cast info", ref el.UseCastPosition);
695+
if(el.TargetAlteration != TargetAlteration.None)
696+
{
697+
ImGuiUtils.SizedText("", WidthElement);
698+
ImGui.SameLine();
699+
ImGui.Checkbox("Draw elements on cast targets", ref el.UseCastTarget);
700+
}*/
608701
}
609-
610-
ImGuiUtils.SizedText("Status requirement:".Loc(), WidthElement);
702+
ImGuiUtils.SizedText("Status requirement:".Loc(), WidthElement);
611703
ImGui.SameLine();
612704
ImGui.Checkbox("##buffreq", ref el.refActorRequireBuff);
613705
if(el.refActorRequireBuff)

Splatoon/Memory/AttachedInfo.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,18 @@ public static bool TryGetCastTime(nint ptr, IEnumerable<uint> castId, out float
213213
castTime = default;
214214
return false;
215215
}
216+
217+
public static bool TryGetCastTime(nint ptr, uint castId, out float castTime)
218+
{
219+
if(CastInfos.TryGetValue(ptr, out var info))
220+
{
221+
if(castId == info.ID)
222+
{
223+
castTime = (float)(Environment.TickCount64 - info.StartTime) / 1000f;
224+
return true;
225+
}
226+
}
227+
castTime = default;
228+
return false;
229+
}
216230
}

Splatoon/Memory/PackerActorCast.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ public readonly float RotationFromNorth
6565
[FieldOffset(28)]
6666
public ushort PosZ;
6767

68+
public readonly Vector3 Position
69+
{
70+
get
71+
{
72+
return new(((PosX * 3.0518043f) * 0.0099999998f) - 1000.0f, ((PosY * 3.0518043f) * 0.0099999998f) - 1000.0f, ((PosZ * 3.0518043f) * 0.0099999998f) - 1000.0f);
73+
}
74+
}
75+
6876
[FieldOffset(30)]
6977
[Obsolete("Unknown")]
7078
public ushort Unknown3;

Splatoon/RenderEngines/CommonRenderUtils.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using ECommons.ObjectLifeTracker;
66
using FFXIVClientStructs;
77
using FFXIVClientStructs.FFXIV.Client.Game.Object;
8+
using Splatoon.Serializables;
89
using System;
910
using System.Collections.Generic;
1011
using System.Linq;
@@ -96,6 +97,39 @@ void castFallback()
9697
return ret;
9798
}
9899

100+
internal static void HandleEnumeration(Element element, ref List<IGameObject> objectList)
101+
{
102+
if(element.Enumeration == EnumerationType.Clockwise || element.Enumeration == EnumerationType.Counter_Clockwise)
103+
{
104+
var orderedList = objectList.OrderBy(x =>
105+
{
106+
var relAngle = MathHelper.GetRelativeAngle(element.EnumerationCenter.ToVector2().ToVector3(0), element.EnumerationStart.ToVector2().ToVector3(0));
107+
var a = (MathHelper.GetRelativeAngle(element.EnumerationCenter.ToVector2().ToVector3(0), x.Position) + relAngle) % 360;
108+
return a;
109+
}).ToList();
110+
if(element.Enumeration == EnumerationType.Counter_Clockwise) orderedList.Reverse();
111+
List<IGameObject> newObjectList = [];
112+
foreach(var x in element.EnumerationOrder)
113+
{
114+
if(x > 0)
115+
{
116+
if(orderedList.Count > x - 1)
117+
{
118+
newObjectList.Add(orderedList[x - 1]);
119+
}
120+
}
121+
if(x < 0)
122+
{
123+
if(orderedList.Count >= -x)
124+
{
125+
newObjectList.Add(orderedList[^-x]);
126+
}
127+
}
128+
}
129+
objectList = newObjectList;
130+
}
131+
}
132+
99133
/// <summary>
100134
/// Accepts: Z-height vector. Returns: Z-height vector.
101135
/// </summary>

Splatoon/RenderEngines/DirectX11/DirectX11Renderer.cs

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ internal override bool ProcessElement(Element element, Layout layout = null, boo
323323
}
324324
else if(element.refActorType == 0)
325325
{
326+
List<IGameObject> objectList = [];
326327
foreach(var a in Svc.Objects)
327328
{
328329
var targetable = a.Struct()->GetIsTargetable();
@@ -332,58 +333,64 @@ internal override bool ProcessElement(Element element, Layout layout = null, boo
332333
if(layout == null || !layout.UseDistanceLimit || LayoutUtils.CheckDistanceCondition(layout, a.GetPositionXZY()))
333334
{
334335
ret = true;
335-
foreach(var obj in Utils.AlterTargetIfNeeded(element, a))
336+
objectList.Add(a);
337+
338+
}
339+
}
340+
}
341+
CommonRenderUtils.HandleEnumeration(element, ref objectList);
342+
foreach(var a in objectList)
343+
{
344+
foreach(var obj in Utils.AlterTargetIfNeeded(element, a))
345+
{
346+
var aradius = radius;
347+
if(element.includeHitbox) aradius += obj.HitboxRadius;
348+
if(element.type == 1)
349+
{
350+
DrawCircle(layout, element, obj.GetPositionXZY().X, obj.GetPositionXZY().Y, obj.GetPositionXZY().Z, aradius,
351+
element.includeRotation ? obj.GetRotationWithOverride(element) : 0f,
352+
obj);
353+
}
354+
else if(element.type == 3)
355+
{
356+
if(element.FaceMe)
336357
{
337-
var aradius = radius;
338-
if(element.includeHitbox) aradius += obj.HitboxRadius;
339-
if(element.type == 1)
340-
{
341-
DrawCircle(layout, element, obj.GetPositionXZY().X, obj.GetPositionXZY().Y, obj.GetPositionXZY().Z, aradius,
342-
element.includeRotation ? obj.GetRotationWithOverride(element) : 0f,
343-
obj);
344-
}
345-
else if(element.type == 3)
358+
var list = Utils.GetFacePositions(layout, element, obj, element.faceplayer);
359+
if(list != null)
346360
{
347-
if(element.FaceMe)
348-
{
349-
var list = Utils.GetFacePositions(layout, element, obj, element.faceplayer);
350-
if(list != null)
351-
{
352-
foreach(var pos in list)
353-
{
354-
var angle = ((element.FaceInvert ? 0 : 180) - (MathHelper.GetRelativeAngle(obj.Position.ToVector2(), pos.ToVector2()))).DegreesToRadians();
355-
AddRotatedLine(layout, element.FaceInvert ? pos.ToXZY() : obj.GetPositionXZY(), angle, element, aradius, obj.HitboxRadius, obj);
356-
}
357-
}
358-
}
359-
else
361+
foreach(var pos in list)
360362
{
361-
var angle = obj.GetRotationWithOverride(element);
362-
AddRotatedLine(layout, obj.GetPositionXZY(), angle, element, aradius, obj.HitboxRadius, obj);
363+
var angle = ((element.FaceInvert ? 0 : 180) - (MathHelper.GetRelativeAngle(obj.Position.ToVector2(), pos.ToVector2()))).DegreesToRadians();
364+
AddRotatedLine(layout, element.FaceInvert ? pos.ToXZY() : obj.GetPositionXZY(), angle, element, aradius, obj.HitboxRadius, obj);
363365
}
364-
365366
}
366-
else if(element.type == 4)
367+
}
368+
else
369+
{
370+
var angle = obj.GetRotationWithOverride(element);
371+
AddRotatedLine(layout, obj.GetPositionXZY(), angle, element, aradius, obj.HitboxRadius, obj);
372+
}
373+
374+
}
375+
else if(element.type == 4)
376+
{
377+
if(element.FaceMe)
378+
{
379+
var list = Utils.GetFacePositions(layout, element, obj, element.faceplayer);
380+
if(list != null)
367381
{
368-
if(element.FaceMe)
369-
{
370-
var list = Utils.GetFacePositions(layout, element, obj, element.faceplayer);
371-
if(list != null)
372-
{
373-
foreach(var pos in list)
374-
{
375-
var baseAngle = ((element.FaceInvert ? 0 : 180) - (MathHelper.GetRelativeAngle(obj.Position.ToVector2(), pos.ToVector2()))).DegreesToRadians();
376-
DrawCone(layout, element, element.FaceInvert ? pos.ToXZY() : obj.GetPositionXZY(), aradius, baseAngle, obj);
377-
}
378-
}
379-
}
380-
else
382+
foreach(var pos in list)
381383
{
382-
var baseAngle = obj.GetRotationWithOverride(element);
383-
DrawCone(layout, element, obj.GetPositionXZY(), aradius, baseAngle, obj);
384+
var baseAngle = ((element.FaceInvert ? 0 : 180) - (MathHelper.GetRelativeAngle(obj.Position.ToVector2(), pos.ToVector2()))).DegreesToRadians();
385+
DrawCone(layout, element, element.FaceInvert ? pos.ToXZY() : obj.GetPositionXZY(), aradius, baseAngle, obj);
384386
}
385387
}
386388
}
389+
else
390+
{
391+
var baseAngle = obj.GetRotationWithOverride(element);
392+
DrawCone(layout, element, obj.GetPositionXZY(), aradius, baseAngle, obj);
393+
}
387394
}
388395
}
389396
}

0 commit comments

Comments
 (0)