Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aurum vale improvements, fixes etc, merge vbm #624

Merged
merged 8 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion BossMod/ActionQueue/Casters/PCT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ public void Dispose() { }
private void Customize(ActionDefinitions d)
{
d.RegisterChargeIncreaseTrait(AID.StrikingMuse, TraitID.EnhancedPictomancyII);
d.RegisterChargeIncreaseTrait(AID.LivingMuse, TraitID.EnhancedPictomancyIV);
foreach (var creature in new AID[] { AID.LivingMuse, AID.PomMuse, AID.WingedMuse, AID.ClawedMuse, AID.FangedMuse })
d.RegisterChargeIncreaseTrait(creature, TraitID.EnhancedPictomancyIV);

d.Spell(AID.Smudge)!.TransformAngle = (ws, _, _, _) => _config.AlignDashToCamera
? ws.Client.CameraAzimuth + 180.Degrees()
Expand Down
4 changes: 2 additions & 2 deletions BossMod/Autorotation/MiscAI/AutoPull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa
if (strategy.Enabled(Track.Hunt) && Bossmods.ActiveModule?.Info?.Category == BossModuleInfo.Category.Hunt && Bossmods.ActiveModule?.PrimaryActor is Actor p && p.InCombat && p.HPRatio < 0.95f)
{
Hints.SetPriority(p, 0);
primaryTarget = p;
primaryTarget = Hints.ForcedTarget = p;
return;
}

Expand All @@ -48,7 +48,7 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa
if (bestEnemy != null)
{
bestEnemy.Priority = 0;
primaryTarget = bestEnemy.Actor;
primaryTarget = Hints.ForcedTarget = bestEnemy.Actor;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion BossMod/Data/PartyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ public Actor[] WithoutSlot(bool includeDead = false, bool excludeAlliance = fals
// find a slot index containing specified player (by name); returns -1 if not found
public int FindSlot(ReadOnlySpan<char> name, StringComparison cmp = StringComparison.CurrentCultureIgnoreCase)
{
for (var i = 0; i < Members.Length; ++i)
var length = Members.Length;
for (var i = 0; i < length; ++i)
if (name.Equals(Members[i].Name, cmp))
return i;
return -1;
Expand Down
69 changes: 59 additions & 10 deletions BossMod/Debug/DebugCollision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ private void DrawColliderMesh(ColliderMesh* coll)
return;

var mesh = (MeshPCB*)coll->Mesh;
DrawColliderMeshPCBNode("Root", mesh->RootNode, ref coll->World, coll->Collider.ObjectMaterialValue & coll->Collider.ObjectMaterialMask, ~coll->Collider.ObjectMaterialMask);
DrawColliderMeshPCBNode("Root", mesh->RootNode, ref coll->World, coll->Collider.ObjectMaterialValue & coll->Collider.ObjectMaterialMask, ~coll->Collider.ObjectMaterialMask, coll);
}

private void DrawColliderMeshPCBNode(string tag, MeshPCB.FileNode* node, ref Matrix4x3 world, ulong objMatId, ulong objMatInvMask)
private void DrawColliderMeshPCBNode(string tag, MeshPCB.FileNode* node, ref Matrix4x3 world, ulong objMatId, ulong objMatInvMask, ColliderMesh* coll)
{
if (node == null)
return;
Expand All @@ -381,18 +381,57 @@ private void DrawColliderMeshPCBNode(string tag, MeshPCB.FileNode* node, ref Mat
return;

_tree.LeafNode2($"Header: {node->Header:X16}");

if (_tree.LeafNode2($"AABB: {AABBStr(node->LocalBounds)}").SelectedOrHovered)
VisualizeOBB(ref node->LocalBounds, ref world, Colors.CollisionColor1);

using var nv = _tree.Node2($"Vertices: {node->NumVertsRaw}+{node->NumVertsCompressed}", node->NumVertsRaw + node->NumVertsCompressed == 0);
if (nv.Opened)
{
using var nv = _tree.Node2($"Vertices: {node->NumVertsRaw}+{node->NumVertsCompressed}", node->NumVertsRaw + node->NumVertsCompressed == 0);
if (nv.Opened)
// Collect all vertices
Vector3 translation = coll->Translation;
Vector3 rotation = coll->Rotation;

List<(Vector3 vertex, int index, char type)> vertices = [];

for (var i = 0; i < node->NumVertsRaw + node->NumVertsCompressed; ++i)
{
var v = node->Vertex(i);
var transformedVertex = ApplyTransformation(v, translation, rotation);
vertices.Add((transformedVertex, i, i < node->NumVertsRaw ? 'r' : 'c'));
}

var playerPos = Service.ClientState.LocalPlayer!.Position;
// Sort vertices by distance to player position, ignore height

vertices.Sort((a, b) =>
{
for (int i = 0; i < node->NumVertsRaw + node->NumVertsCompressed; ++i)
var distA = (playerPos.X - a.vertex.X) * (playerPos.X - a.vertex.X) +
(playerPos.Z - a.vertex.Z) * (playerPos.Z - a.vertex.Z);

var distB = (playerPos.X - b.vertex.X) * (playerPos.X - b.vertex.X) +
(playerPos.Z - b.vertex.Z) * (playerPos.Z - b.vertex.Z);

return distA.CompareTo(distB);
});

// Render vertices in sorted order
foreach (var (vertex, index, type) in vertices)
{
var vertexStr = $"new({vertex.X.ToString("F3", System.Globalization.CultureInfo.InvariantCulture)}f, {vertex.Z.ToString("F3", System.Globalization.CultureInfo.InvariantCulture)}f)";
using var node2 = _tree.Node2($"[{index}] ({type}): {Vec3Str(vertex)}");
if (node2.SelectedOrHovered)
{
var v = node->Vertex(i);
if (_tree.LeafNode2($"[{i}] ({(i < node->NumVertsRaw ? 'r' : 'c')}): {Vec3Str(v)}").SelectedOrHovered)
VisualizeVertex(world.TransformCoordinate(v), Colors.CollisionColor2);
VisualizeVertex(vertex, Colors.CollisionColor2);
}

if (ImGui.BeginPopupContextItem())
{
if (ImGui.MenuItem("Copy to Clipboard"))
{
ImGui.SetClipboardText(vertexStr);
}
ImGui.EndPopup();
}
}
}
Expand All @@ -406,8 +445,8 @@ private void DrawColliderMeshPCBNode(string tag, MeshPCB.FileNode* node, ref Mat
VisualizeTriangle(node, ref prim, ref world, Colors.CollisionColor2);
}
}
DrawColliderMeshPCBNode($"Child 1 (+{node->Child1Offset})", node->Child1, ref world, objMatId, objMatId);
DrawColliderMeshPCBNode($"Child 2 (+{node->Child2Offset})", node->Child2, ref world, objMatId, objMatId);
DrawColliderMeshPCBNode($"Child 1 (+{node->Child1Offset})", node->Child1, ref world, objMatId, objMatId, coll);
DrawColliderMeshPCBNode($"Child 2 (+{node->Child2Offset})", node->Child2, ref world, objMatId, objMatId, coll);
}

private void DrawResource(Resource* res)
Expand Down Expand Up @@ -615,4 +654,14 @@ private void ContextCollider(Collider* coll)
if (ImGui.Checkbox("Flag: global visit", ref globalVisit))
coll->VisibilityFlags ^= 2;
}

static Vector3 ApplyTransformation(Vector3 vertex, Vector3 translation, Vector3 rotation)
{
var rotX = rotation.X;
var rotY = rotation.Y;
var rotZ = rotation.Z;
var rotMatrix = Matrix4x4.CreateRotationX(rotX) * Matrix4x4.CreateRotationY(rotY) * Matrix4x4.CreateRotationZ(rotZ);
var rotatedVertex = Vector3.Transform(vertex, rotMatrix);
return rotatedVertex + translation;
}
}
9 changes: 7 additions & 2 deletions BossMod/Framework/MovementOverride.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void Dispose()
_rmiFlyHook.Dispose();
}

private bool NavmeshActive()
private bool FollowpathActive()
{
if (_navmeshPathIsRunning == null && _dalamud.TryGetData<bool[]>("vnav.PathIsRunning", out var data))
_navmeshPathIsRunning = data;
Expand All @@ -116,7 +116,7 @@ private void RMIWalkDetour(void* self, float* sumLeft, float* sumForward, float*
_rmiWalkHook.Original(self, sumLeft, sumForward, sumTurnLeft, haveBackwardOrStrafe, a6, bAdditiveUnk);

// TODO: we really need to introduce some extra checks that PlayerMoveController::readInput does - sometimes it skips reading input, and returning something non-zero breaks stuff...
var movementAllowed = bAdditiveUnk == 0 && _rmiWalkIsInputEnabled1(self) && _rmiWalkIsInputEnabled2(self) && !NavmeshActive();
var movementAllowed = bAdditiveUnk == 0 && _rmiWalkIsInputEnabled1(self) && _rmiWalkIsInputEnabled2(self) && !FollowpathActive();
var misdirectionMode = PlayerHasMisdirection();
if (!movementAllowed && misdirectionMode)
{
Expand Down Expand Up @@ -169,6 +169,11 @@ private void RMIFlyDetour(void* self, PlayerMoveControllerFlyInput* result)
{
_forcedControlState = null;
_rmiFlyHook.Original(self, result);

// do nothing while followpath is running
if (FollowpathActive())
return;

// TODO: we really need to introduce some extra checks that PlayerMoveController::readInput does - sometimes it skips reading input, and returning something non-zero breaks stuff...
if (result->Forward == 0 && result->Left == 0 && result->Up == 0 && DirectionToDestination(true) is var relDir && relDir != null)
{
Expand Down
3 changes: 2 additions & 1 deletion BossMod/Framework/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public unsafe Plugin(IDalamudPluginInterface dalamud, ICommandManager commandMan
InteropGenerator.Runtime.Resolver.GetInstance.Resolve();

dalamud.Create<Service>();
Service.LogHandler = (string msg) => Service.Logger.Debug(msg);
Service.LogHandlerDebug = (string msg) => Service.Logger.Debug(msg);
Service.LogHandlerVerbose = (string msg) => Service.Logger.Verbose(msg);
Service.LuminaGameData = dataManager.GameData;
Service.WindowSystem = new("bmr");
//Service.Device = pluginInterface.UiBuilder.Device;
Expand Down
6 changes: 4 additions & 2 deletions BossMod/Framework/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ public sealed class Service
#pragma warning restore CS8618

#pragma warning disable CA2211
public static Action<string>? LogHandler;
public static void Log(string msg) => LogHandler?.Invoke(msg);
public static Action<string>? LogHandlerDebug;
public static Action<string>? LogHandlerVerbose;
public static void Log(string msg) => LogHandlerDebug?.Invoke(msg);
public static void LogVerbose(string msg) => LogHandlerVerbose?.Invoke(msg);

public static Lumina.GameData? LuminaGameData;
public static Lumina.Excel.ExcelSheet<T>? LuminaSheet<T>() where T : struct, Lumina.Excel.IExcelRow<T> => LuminaGameData?.GetExcelSheet<T>(Lumina.Data.Language.English);
Expand Down
2 changes: 1 addition & 1 deletion BossMod/Framework/WorldStateGameSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private unsafe void UpdateActors()

if (obj != null && (obj->EntityId & 0xFF000000) == 0xFF000000)
{
// Service.Log($"[WorldState] Skipping bad object #{i} with id {obj->EntityId:X}");
Service.LogVerbose($"[WorldState] Skipping bad object #{i} with id {obj->EntityId:X}");
obj = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ public override void OnActorCreated(Actor actor)
{
if (actor.OID == (uint)OID.BitingWind)
{
if (actor.Position == new WPos(-74f, -180f))
if (actor.Position.Z == -180f)
CurrentPattern = Pattern.EWEW;
else if (actor.Position == new WPos(-74f, -210f))
else if (actor.Position.Z == -210f)
CurrentPattern = Pattern.WEWE;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ void AddAOEs(AOEShape shape)
var crystals = Module.Enemies((uint)OID.AllaganCrystal);
var count = crystals.Count;
for (var i = 0; i < count; ++i)
_aoes.Add(new(shape, WPos.ClampToGrid(crystals[i].Position), default, Module.CastFinishAt(spell, 0.5f)));
{
var crystal = crystals[i];
_aoes.Add(new(shape, WPos.ClampToGrid(crystal.Position), crystal.Rotation, Module.CastFinishAt(spell, 0.5f)));
}
}
switch (spell.Action.ID)
{
Expand Down
Loading