Skip to content

Commit

Permalink
Merge pull request #525 from FFXIV-CombatReborn/mergeWIP
Browse files Browse the repository at this point in the history
fixed autorotation AI bug, fixed thaliak bug, fixed color reset bug
  • Loading branch information
CarnifexOptimus authored Dec 29, 2024
2 parents 1b3f2a9 + a27591c commit ce0f105
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 34 deletions.
3 changes: 2 additions & 1 deletion BossMod/BossModule/AIHints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public void Clear()
// fill list of potential targets from world state
public void FillPotentialTargets(WorldState ws, bool playerIsDefaultTank)
{
var playerInFate = ws.Client.ActiveFate.ID != 0 && ws.Party.Player()?.Level <= Service.LuminaRow<Lumina.Excel.Sheets.Fate>(ws.Client.ActiveFate.ID)?.ClassJobLevelMax;
var playerInFate = ws.Client.ActiveFate.ID != 0 && (ws.Party.Player()?.Level <= Service.LuminaRow<Lumina.Excel.Sheets.Fate>(ws.Client.ActiveFate.ID)?.ClassJobLevelMax
|| Service.LuminaRow<Lumina.Excel.Sheets.Fate>(ws.Client.ActiveFate.ID)?.EurekaFate == 1); // TODO: find out how to get the current player elemental level
var allowedFateID = playerInFate ? ws.Client.ActiveFate.ID : 0;
foreach (var actor in ws.Actors.Where(a => a.IsTargetable && !a.IsAlly && !a.IsDead))
{
Expand Down
3 changes: 2 additions & 1 deletion BossMod/BossModule/AIHintsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public void Update(AIHints hints, int playerSlot, float maxCastTime)

private void CalculateAutoHints(AIHints hints, Actor player)
{
var inFate = _ws.Client.ActiveFate.ID != 0 && player.Level <= Service.LuminaRow<Lumina.Excel.Sheets.Fate>(_ws.Client.ActiveFate.ID)?.ClassJobLevelMax;
var inFate = _ws.Client.ActiveFate.ID != 0 && (_ws.Party.Player()?.Level <= Service.LuminaRow<Lumina.Excel.Sheets.Fate>(_ws.Client.ActiveFate.ID)?.ClassJobLevelMax
|| Service.LuminaRow<Lumina.Excel.Sheets.Fate>(_ws.Client.ActiveFate.ID)?.EurekaFate == 1); // TODO: find out how to get the current player elemental level
var center = inFate ? _ws.Client.ActiveFate.Center : player.PosRot.XYZ();
var (e, bitmap) = Obstacles.Find(center);
var resolution = bitmap?.PixelSize ?? 0.5f;
Expand Down
1 change: 0 additions & 1 deletion BossMod/Data/ActionEffect.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Runtime.InteropServices;
using System.Text;

namespace BossMod;

Expand Down
29 changes: 9 additions & 20 deletions BossMod/Debug/DebugCollision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ private void DrawColliderMeshPCBNode(string tag, MeshPCB.FileNode* node, ref Mat

using var n = _tree.Node2(tag);
if (n.SelectedOrHovered)
VisualizeColliderMeshPCBNode(node, ref world, new(1, 1, 0, 0.7f), objMatId, objMatId, _materialId, _materialMask);
VisualizeColliderMeshPCBNode(node, ref world, Colors.CollisionColor1, objMatId, objMatId, _materialId, _materialMask);
if (!n.Opened)
return;

Expand Down Expand Up @@ -434,13 +434,13 @@ public void VisualizeCollider(Collider* coll, BitMask filterId, BitMask filterMa
for (int i = 0; i < cast->Header->NumMeshes; ++i)
{
var elem = cast->Elements + i;
VisualizeColliderMesh(elem->Mesh, new Vector4(0, 1, 0, 0.7f), _materialId, _materialMask);
VisualizeColliderMesh(elem->Mesh, Colors.CollisionColor1, _materialId, _materialMask);
}
}
}
break;
case ColliderType.Mesh:
VisualizeColliderMesh((ColliderMesh*)coll, new(_streamedMeshes.Contains((nint)coll) ? 0 : 1, 1, 0, 0.7f), _materialId, _materialMask);
VisualizeColliderMesh((ColliderMesh*)coll, _streamedMeshes.Contains((nint)coll) ? Colors.CollisionColor1 : Colors.CollisionColor2, _materialId, _materialMask);
break;
case ColliderType.Box:
{
Expand Down Expand Up @@ -482,7 +482,7 @@ public void VisualizeCollider(Collider* coll, BitMask filterId, BitMask filterMa
}
}

private void VisualizeColliderMesh(ColliderMesh* coll, Vector4 color, BitMask filterId, BitMask filterMask)
private void VisualizeColliderMesh(ColliderMesh* coll, uint color, BitMask filterId, BitMask filterMask)
{
if (coll != null && !coll->MeshIsSimple && coll->Mesh != null)
{
Expand All @@ -491,13 +491,12 @@ private void VisualizeColliderMesh(ColliderMesh* coll, Vector4 color, BitMask fi
}
}

private void VisualizeColliderMeshPCBNode(MeshPCB.FileNode* node, ref Matrix4x3 world, Vector4 color, ulong objMatId, ulong objMatInvMask, BitMask filterId, BitMask filterMask)
private void VisualizeColliderMeshPCBNode(MeshPCB.FileNode* node, ref Matrix4x3 world, uint color, ulong objMatId, ulong objMatInvMask, BitMask filterId, BitMask filterMask)
{
if (node == null)
return;

var colorArgb = ToArgb(color);
if (node->NumVertsRaw + node->NumVertsCompressed > 0)
if (node->NumVertsRaw + node->NumVertsCompressed != 0)
{
for (var i = 0; i < node->NumPrims; ++i)
{
Expand All @@ -507,26 +506,16 @@ private void VisualizeColliderMeshPCBNode(MeshPCB.FileNode* node, ref Matrix4x3
var v2 = world.TransformCoordinate(node->Vertex(prim.V2));
var v3 = world.TransformCoordinate(node->Vertex(prim.V3));

Camera.Instance?.DrawWorldLine(v1, v2, colorArgb);
Camera.Instance?.DrawWorldLine(v2, v3, colorArgb);
Camera.Instance?.DrawWorldLine(v3, v1, colorArgb);
Camera.Instance?.DrawWorldLine(v1, v2, color);
Camera.Instance?.DrawWorldLine(v2, v3, color);
Camera.Instance?.DrawWorldLine(v3, v1, color);
}
}

VisualizeColliderMeshPCBNode(node->Child1, ref world, color, objMatId, objMatInvMask, filterId, filterMask);
VisualizeColliderMeshPCBNode(node->Child2, ref world, color, objMatId, objMatInvMask, filterId, filterMask);
}

private static uint ToArgb(Vector4 color)
{
var r = (byte)(color.X * 255);
var g = (byte)(color.Y * 255);
var b = (byte)(color.Z * 255);
var a = (byte)(color.W * 255);

return (uint)((a << 24) | (b << 16) | (g << 8) | r);
}

private void VisualizeOBB(ref AABB localBB, ref Matrix4x3 world, uint color)
{
var aaa = world.TransformCoordinate(new(localBB.Min.X, localBB.Min.Y, localBB.Min.Z));
Expand Down
14 changes: 7 additions & 7 deletions BossMod/Framework/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,16 @@ private static void ResetColors()
{
var defaultConfig = ColorConfig.DefaultConfig;
var currentConfig = Service.Config.Get<ColorConfig>();
var properties = typeof(ColorConfig).GetProperties(BindingFlags.Public | BindingFlags.Instance);
var fields = typeof(ColorConfig).GetFields(BindingFlags.Public | BindingFlags.Instance);

for (var i = 0; i < properties.Length; ++i)
for (var i = 0; i < fields.Length; ++i)
{
var property = properties[i];
if (!property.CanWrite)
continue;
property.SetValue(currentConfig, property.GetValue(defaultConfig));
var field = fields[i];
var value = field.GetValue(defaultConfig);
if (value is Color or Color[])
field.SetValue(currentConfig, value);
}
currentConfig.ArenaBackground = defaultConfig.ArenaBackground;

currentConfig.Modified.Fire();
Service.Log("Colors have been reset to default values.");
}
Expand Down
8 changes: 4 additions & 4 deletions BossMod/Modules/Endwalker/Alliance/A31Thaliak/Tetraktys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public override void OnEventEnvControl(byte index, uint state)

if (state != 0x00020001)
return;
var tutorialDone = Module.FindComponent<TetraktuosKosmosCounter>()?.NumCasts > 0;
var tutorialDone = Module.FindComponent<TetraktuosKosmosCounter>()?.NumCasts != 0;
var activationTime = WorldState.FutureTime(7.9f);

if (!tutorialDone)
Expand All @@ -179,13 +179,13 @@ private void HandleTutorial(byte index, DateTime activationTime)
{
switch (index)
{
case 0x14:
case 0x12:
AddAOEs([0, 1, 2, 3], activationTime);
break;
case 0x15:
case 0x14:
AddAOEs([4, 5, 6, 7], activationTime);
break;
case 0x12:
case 0x15:
AddAOEs([8, 9, 10, 11], activationTime);
break;
}
Expand Down

0 comments on commit ce0f105

Please sign in to comment.