Skip to content

Commit

Permalink
Merge pull request #559 from FFXIV-CombatReborn/mergeWIP
Browse files Browse the repository at this point in the history
BA absolute virtue WIP
  • Loading branch information
CarnifexOptimus authored Jan 17, 2025
2 parents ea6b975 + 06e6401 commit 6b18ec5
Show file tree
Hide file tree
Showing 28 changed files with 525 additions and 167 deletions.
2 changes: 1 addition & 1 deletion BossMod/BossModule/MiniArena.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ArenaBounds Bounds
public float ScreenMarginSize => 20 * Config.ArenaScale;

// these are set at the beginning of each draw
public Vector2 ScreenCenter { get; private set; }
public Vector2 ScreenCenter;
private Angle _cameraAzimuth;
private float _cameraSinAzimuth;
private float _cameraCosAzimuth = 1;
Expand Down
13 changes: 12 additions & 1 deletion BossMod/Components/ThinIce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,18 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
ShapeDistance.InvertedDonut(pos, ddistance, ddistance + 0.5f),
ShapeDistance.InvertedRect(pos, offset, 0.5f, 0.5f, 0.5f)
};
hints.AddForbiddenZone(p => forbidden.Max(f => f(p)), DateTime.MaxValue);
float maxDistanceFunc(WPos pos)
{
var minDistance = float.MinValue;
for (var i = 0; i < forbidden.Count; ++i)
{
var distance = forbidden[i](pos);
if (distance > minDistance)
minDistance = distance;
}
return minDistance;
}
hints.AddForbiddenZone(maxDistanceFunc, DateTime.MaxValue);
}
}
}
2 changes: 1 addition & 1 deletion BossMod/Data/ActionSpeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static int SpeedStatToModifier(int stat, int level)
}

public static int AdjustRecastMS(int baselineMS, int speedMod, int hasteMod) => Math.Max(baselineMS * speedMod / 1000 * hasteMod / 100, 1500);
public static float Round(int ms) => (ms / 10) * 0.01f;
public static float Round(int ms) => ms / 10 * 0.01f;

public static int GCDRawMS(int speedStat, int hasteStat, int level, int baselineMS = 2500) => AdjustRecastMS(baselineMS, SpeedStatToModifier(speedStat, level), hasteStat);
public static float GCDRounded(int speedStat, int hasteStat, int level, int baselineMS = 2500) => Round(GCDRawMS(speedStat, hasteStat, level, baselineMS));
Expand Down
37 changes: 22 additions & 15 deletions BossMod/Data/ActorState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,43 @@ protected override void Exec(WorldState ws)
}
}

public IEnumerable<Operation> CompareToInitial()
public List<Operation> CompareToInitial()
{
foreach (var act in this)
List<Operation> ops = new(_actors.Count * 2);

foreach (var act in _actors.Values)
{
yield return new OpCreate(act.InstanceID, act.OID, act.SpawnIndex, act.Name, act.NameID, act.Type, act.Class, act.Level, act.PosRot, act.HitboxRadius, act.HPMP, act.IsTargetable, act.IsAlly, act.OwnerID, act.FateID);
var instanceID = act.InstanceID;
ops.Add(new OpCreate(instanceID, act.OID, act.SpawnIndex, act.Name, act.NameID, act.Type, act.Class, act.Level, act.PosRot, act.HitboxRadius, act.HPMP, act.IsTargetable, act.IsAlly, act.OwnerID, act.FateID));
if (act.IsDead)
yield return new OpDead(act.InstanceID, true);
ops.Add(new OpDead(instanceID, true));
if (act.InCombat)
yield return new OpCombat(act.InstanceID, true);
ops.Add(new OpCombat(instanceID, true));
if (act.ModelState != default)
yield return new OpModelState(act.InstanceID, act.ModelState);
ops.Add(new OpModelState(instanceID, act.ModelState));
if (act.EventState != 0)
yield return new OpEventState(act.InstanceID, act.EventState);
ops.Add(new OpEventState(instanceID, act.EventState));
if (act.TargetID != 0)
yield return new OpTarget(act.InstanceID, act.TargetID);
ops.Add(new OpTarget(instanceID, act.TargetID));
if (act.MountId != 0)
yield return new OpMount(act.InstanceID, act.MountId);
ops.Add(new OpMount(instanceID, act.MountId));
if (act.Tether.ID != 0)
yield return new OpTether(act.InstanceID, act.Tether);
ops.Add(new OpTether(instanceID, act.Tether));
if (act.CastInfo != null)
yield return new OpCastInfo(act.InstanceID, act.CastInfo);
for (var i = 0; i < act.Statuses.Length; ++i)
if (act.Statuses[i].ID != 0)
yield return new OpStatus(act.InstanceID, i, act.Statuses[i]);
ops.Add(new OpCastInfo(instanceID, act.CastInfo));
for (var j = 0; j < act.Statuses.Length; ++j)
{
var status = act.Statuses[j];
if (status.ID != 0)
ops.Add(new OpStatus(instanceID, j, status));
}
}
return ops;
}

public void Tick(float dt)
{
foreach (var act in this)
foreach (var act in _actors.Values)
{
act.PrevPosRot = act.PosRot;
if (act.CastInfo != null)
Expand Down
138 changes: 104 additions & 34 deletions BossMod/Data/ClientState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,45 +75,94 @@ public static unsafe T GetGauge<T>(in Gauge gauge) where T : unmanaged
}
public unsafe T GetGauge<T>() where T : unmanaged => GetGauge<T>(GaugePayload);

public IEnumerable<WorldState.Operation> CompareToInitial()
public List<WorldState.Operation> CompareToInitial()
{
List<WorldState.Operation> ops = new(12);
if (CountdownRemaining != null)
yield return new OpCountdownChange(CountdownRemaining);
ops.Add(new OpCountdownChange(CountdownRemaining));

if (AnimationLock > 0)
yield return new OpAnimationLockChange(AnimationLock);
if (AnimationLock != 0)
ops.Add(new OpAnimationLockChange(AnimationLock));

if (ComboState.Remaining > 0)
yield return new OpComboChange(ComboState);
if (ComboState.Remaining != 0)
ops.Add(new OpComboChange(ComboState));

if (PlayerStats != default)
yield return new OpPlayerStatsChange(PlayerStats);

var cooldowns = Cooldowns.Select((v, i) => (i, v)).Where(iv => iv.v.Total > 0).ToList();
if (cooldowns.Count > 0)
yield return new OpCooldown(false, cooldowns);
ops.Add(new OpPlayerStatsChange(PlayerStats));

var cdlen = Cooldowns.Length;
if (cdlen != 0)
{
var cooldowns = new List<(int, Cooldown)>(cdlen);

for (var i = 0; i < cdlen; ++i)
{
var cds = Cooldowns[i];
if (cds.Total != 0)
cooldowns.Add((i, cds));
}
if (cooldowns.Count != 0)
ops.Add(new OpCooldown(false, cooldowns));
}
if (DutyActions.Any(a => a != default))
yield return new OpDutyActionsChange(DutyActions[0], DutyActions[1]);
ops.Add(new OpDutyActionsChange(DutyActions[0], DutyActions[1]));

var bozjaHolster = BozjaHolster.Select((v, i) => ((BozjaHolsterID)i, v)).Where(iv => iv.v > 0).ToList();
if (BozjaHolster.Any(count => count != 0))
yield return new OpBozjaHolsterChange(bozjaHolster);
var holsterlen = BozjaHolster.Length;
if (holsterlen != 0)
{
var bozjaHolster = new List<(BozjaHolsterID, byte)>(holsterlen);
for (var i = 0; i < holsterlen; ++i)
{
var holster = BozjaHolster[i];
if (holster != 0)
bozjaHolster.Add(((BozjaHolsterID)i, holster));
}
var hasNonZeroHolster = false;
for (var i = 0; i < holsterlen; ++i)
{
if (BozjaHolster[i] != 0)
{
hasNonZeroHolster = true;
break;
}
}
if (hasNonZeroHolster)
ops.Add(new OpBozjaHolsterChange(bozjaHolster));
}

if (BlueMageSpells.Any(a => a != 0))
yield return new OpBlueMageSpellsChange(BlueMageSpells);
var hasNonZeroBMSpell = false;
for (var i = 0; i < BlueMageSpells.Length; ++i)
{
if (BlueMageSpells[i] != 0)
{
hasNonZeroBMSpell = true;
break;
}
}
if (hasNonZeroBMSpell)
ops.Add(new OpBlueMageSpellsChange(BlueMageSpells));

if (ClassJobLevels.Any(a => a != 0))
yield return new OpClassJobLevelsChange(ClassJobLevels);
var hasNonZeroLevels = false;
for (var i = 0; i < ClassJobLevels.Length; ++i)
{
if (ClassJobLevels[i] != 0)
{
hasNonZeroLevels = true;
break;
}
}
if (hasNonZeroLevels)
ops.Add(new OpClassJobLevelsChange(ClassJobLevels));

if (ActiveFate.ID != 0)
yield return new OpActiveFateChange(ActiveFate);
ops.Add(new OpActiveFateChange(ActiveFate));

if (ActivePet.InstanceID != 0)
yield return new OpActivePetChange(ActivePet);
ops.Add(new OpActivePetChange(ActivePet));

if (FocusTargetId != 0)
yield return new OpFocusTargetChange(FocusTargetId);
ops.Add(new OpFocusTargetChange(FocusTargetId));
return ops;
}

public void Tick(float dt)
Expand Down Expand Up @@ -223,17 +272,25 @@ protected override void Exec(WorldState ws)
{
if (Reset)
Array.Fill(ws.Client.Cooldowns, default);
foreach (var cd in Cooldowns)

for (var i = 0; i < Cooldowns.Count; ++i)
{
var cd = Cooldowns[i];
ws.Client.Cooldowns[cd.group] = cd.value;
}
ws.Client.CooldownsChanged.Fire(this);
}
public override void Write(ReplayRecorder.Output output)
{
var count = Cooldowns.Count;
output.EmitFourCC("CLCD"u8);
output.Emit(Reset);
output.Emit((byte)Cooldowns.Count);
foreach (var e in Cooldowns)
output.Emit((byte)e.group).Emit(e.value.Elapsed).Emit(e.value.Total);
output.Emit((byte)count);
for (var i = 0; i < count; ++i)
{
var cd = Cooldowns[i];
output.Emit((byte)cd.group).Emit(cd.value.Elapsed).Emit(cd.value.Total);
}
}
}

Expand All @@ -255,16 +312,23 @@ public sealed record class OpBozjaHolsterChange(List<(BozjaHolsterID entry, byte
protected override void Exec(WorldState ws)
{
Array.Fill(ws.Client.BozjaHolster, (byte)0);
foreach (var e in Contents)
for (var i = 0; i < Contents.Count; ++i)
{
var e = Contents[i];
ws.Client.BozjaHolster[(int)e.entry] = e.count;
}
ws.Client.BozjaHolsterChanged.Fire(this);
}
public override void Write(ReplayRecorder.Output output)
{
var count = Contents.Count;
output.EmitFourCC("CLBH"u8);
output.Emit((byte)Contents.Count);
foreach (var e in Contents)
output.Emit((byte)count);
for (var i = 0; i < count; ++i)
{
var e = Contents[i];
output.Emit((byte)e.entry).Emit(e.count);
}
}
}

Expand All @@ -280,10 +344,13 @@ protected override void Exec(WorldState ws)
}
public override void Write(ReplayRecorder.Output output)
{
var len = Values.Length;
output.EmitFourCC("CBLU"u8);
output.Emit((byte)Values.Length);
foreach (var e in Values)
output.Emit(e);
for (var i = 0; i < len; ++i)
{
output.Emit(Values[i]);
}
}
}

Expand All @@ -301,10 +368,13 @@ protected override void Exec(WorldState ws)
}
public override void Write(ReplayRecorder.Output output)
{
var len = Values.Length;
output.EmitFourCC("CLVL"u8);
output.Emit((byte)Values.Length);
foreach (var e in Values)
output.Emit(e);
output.Emit((byte)len);
for (var i = 0; i < len; ++i)
{
output.Emit(Values[i]);
}
}
}

Expand Down
5 changes: 2 additions & 3 deletions BossMod/Data/NetworkState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ public readonly record struct ServerIPC(Network.ServerIPC.PacketID ID, ushort Op

public uint IDScramble;

public IEnumerable<WorldState.Operation> CompareToInitial()
public List<WorldState.Operation> CompareToInitial()
{
if (IDScramble != 0)
yield return new OpIDScramble(IDScramble);
return IDScramble != 0 ? [new OpIDScramble(IDScramble)] : [];
}

public Event<OpIDScramble> IDScrambleChanged = new();
Expand Down
11 changes: 7 additions & 4 deletions BossMod/Data/PartyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@ public int FindSlot(ReadOnlySpan<char> name, StringComparison cmp = StringCompar
return -1;
}

public IEnumerable<WorldState.Operation> CompareToInitial()
public List<WorldState.Operation> CompareToInitial()
{
for (var i = 0; i < Members.Length; ++i)
var length = Members.Length;
List<WorldState.Operation> ops = new(length + 1);
for (var i = 0; i < length; ++i)
if (Members[i].IsValid())
yield return new OpModify(i, Members[i]);
ops.Add(new OpModify(i, Members[i]));
if (LimitBreakCur != 0 || LimitBreakMax != 10000)
yield return new OpLimitBreakChange(LimitBreakCur, LimitBreakMax);
ops.Add(new OpLimitBreakChange(LimitBreakCur, LimitBreakMax));
return ops;
}

// implementation of operations
Expand Down
6 changes: 4 additions & 2 deletions BossMod/Data/WaymarkState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ public Vector3? this[Waymark wm]
private set => this[(int)wm] = value;
}

public IEnumerable<WorldState.Operation> CompareToInitial()
public List<WorldState.Operation> CompareToInitial()
{
List<WorldState.Operation> waymarks = new(8);
foreach (var i in _setMarkers.SetBits())
yield return new OpWaymarkChange((Waymark)i, _positions[i]);
waymarks.Add(new OpWaymarkChange((Waymark)i, _positions[i]));
return waymarks;
}

// implementation of operations
Expand Down
Loading

0 comments on commit 6b18ec5

Please sign in to comment.