Snapshot for release 2026.10.22.2 (internal e613280)
This commit is contained in:
parent
10c58b53b6
commit
893973d0dd
16 changed files with 871 additions and 188 deletions
|
|
@ -56,6 +56,7 @@ internal static class Program
|
|||
MagItemDescriberTests.Register(runner);
|
||||
ExpressionTests.Register(runner);
|
||||
MetaTests.Register(runner);
|
||||
SelfTestMetaTests.Register(runner);
|
||||
NoKillTests.Register(runner);
|
||||
MetaSchedulerTests.Register(runner);
|
||||
NavEngineTests.Register(runner);
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@ using RynthCore.RynthAiTests.Harness;
|
|||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// HP failsafe: under Emergency Heal At with heals failing (here: every heal sent and never answered,
|
||||
// as in a client log's hung casts), the character must not sit and die. 3 rounds of 2.5 s with no
|
||||
// rise: a forced jump (ActionPacer.ForceBreak), then healing again; 3 more: the macro stops and
|
||||
// "/lifestone" goes out (HpFailsafeRecall, default off; the tests turn it on).
|
||||
// as in a client log's hung casts), the character must not sit and die. Recall off: 3 rounds of 2.5 s
|
||||
// with no rise, a forced jump (ActionPacer.ForceBreak), then healing again. HpFailsafeRecall on
|
||||
// (default off; most tests here turn it on): 2 rounds, the jump, and the Lifestone Recall SPELL at
|
||||
// once (2026-10-22: not "/lifestone", whose long kneel got characters killed).
|
||||
internal static class HpFailsafeTests
|
||||
{
|
||||
private const uint Player = 0x50000B31;
|
||||
|
|
@ -20,19 +21,18 @@ internal static class HpFailsafeTests
|
|||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("hp failsafe: 7.5 s at Emergency Heal At with no heal landing -> one jump; 7.5 s more -> macro stop and /lifestone", BreakThenRecall);
|
||||
r.Add("hp failsafe: recall on, 5 s at Emergency Heal At with no heal landing -> one jump, the macro stop and Lifestone Recall cast once landed; portal space ends it", BreakThenRecall);
|
||||
r.Add("hp failsafe: a heal landing (+3%) restarts the count; health over the line ends it", HealLandingResets);
|
||||
r.Add("hp failsafe: HP Failsafe Recall off -> the jump still, no recall; no recall line -> 3 sends, then it gives up", RecallOffAndResends);
|
||||
r.Add("hp failsafe: HP Failsafe Recall off -> the jump at 7.5 s, no recall; no portal space -> 3 casts 3 s apart, then it gives up", RecallOffAndResends);
|
||||
r.Add("hp failsafe: a recall that never starts turns the macro back on and re-arms; the next recall after 30 s", FailedRecallResumes);
|
||||
r.Add("hp failsafe: another player's recall line is not ours; ours with its first letter dropped is", RecallLineIsOurs);
|
||||
r.Add("hp failsafe: Emergency Heal At 100 at full health is not an emergency", FullHealthAtHundred);
|
||||
r.Add("hp failsafe: nothing counts in portal space", NothingInPortalSpace);
|
||||
r.Add("hp failsafe: a death drops the pending recall (0 health, and the plugin's death hold): no /lifestone, the macro stays off", DeathDropsRecall);
|
||||
r.Add("hp failsafe: a death drops the pending recall (0 health, and the plugin's death hold): no Lifestone Recall, the macro stays off", DeathDropsRecall);
|
||||
r.Add("hp failsafe: a failed recall does not switch the macro back on past a VTank yield", VTankYieldRespected);
|
||||
r.Add("hp failsafe: our name unreadable: the recall line is taken as ours, and that is logged once", RecallNameUnreadable);
|
||||
r.Add("hp failsafe: HP Failsafe Recall is off by default; a profile with no saved value loads off, one that saved true keeps it", RecallOffByDefault);
|
||||
r.Add("hp failsafe: no recall without the spell or its mana: the jump, healing on, the macro keeps running, said once", NoSpellNoManaNoRecall);
|
||||
r.Add("hp failsafe: HP Failsafe Recall is off by default; a profile with no saved value loads off, an old saved true (before 10-22) loads off, a tick since then stays", RecallOffByDefault);
|
||||
r.Add("hp failsafe: a character that cannot heal at all (no spell, kit or potion) never jumps or recalls", NoHealCapabilityNeverFires);
|
||||
r.Add("hp failsafe: a character that can heal (a known Heal Self) and is stuck still jumps, then recalls when the option is on", CapableStuckStillRecalls);
|
||||
r.Add("hp failsafe: a character that can heal (a known Heal Self) and is stuck still jumps, then casts Lifestone Recall when the option is on", CapableStuckStillRecalls);
|
||||
r.Add("hp failsafe: a heal that went out proves the character can heal (a listed potion, no spell)", PotionSentProvesCapability);
|
||||
r.Add("vitals (L8):a heal the server leaves unanswered is not re-sent at the 2.5 s give-up after a 'too busy' answer", VitalResendObeysLatch);
|
||||
r.Add("vitals: under Emergency Heal At with a weapon out and no usable kit, a health potion before Heal Self's wand swap", EmergencyPotionBeforeWandSwap);
|
||||
|
|
@ -136,7 +136,7 @@ internal static class HpFailsafeTests
|
|||
public readonly RynthCore.PluginSdk.RynthCoreHost Host;
|
||||
public int MacroStops;
|
||||
|
||||
public Rig(int healthPct = 20, bool canHeal = true, bool recall = true)
|
||||
public Rig(int healthPct = 20, bool canHeal = true, bool recall = true, bool knowsRecall = true)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.WeaponCalls = true;
|
||||
|
|
@ -150,6 +150,7 @@ internal static class HpFailsafeTests
|
|||
if (canHeal)
|
||||
{
|
||||
foreach (var row in SpellTable.Rows) FakeHost.Spellbook.Add((uint)row.Id);
|
||||
if (!knowsRecall) FakeHost.Spellbook.Remove((uint)BuffManager.RecallSpellId);
|
||||
FakeHost.Skills[(Player, STypeLife)] = (400, 2);
|
||||
}
|
||||
else
|
||||
|
|
@ -194,6 +195,19 @@ internal static class HpFailsafeTests
|
|||
|
||||
public void At(double seconds) => NowAt = T0.AddMilliseconds(Math.Round(seconds * 1000));
|
||||
public bool Logged(string part) => FakeHost.Logs.Any(l => l.Contains(part, StringComparison.Ordinal));
|
||||
public static int Recalls => FakeHost.Casts.Count(c => c.SpellId == BuffManager.RecallSpellId);
|
||||
|
||||
/// <summary>Heartbeats as <see cref="Run"/>; each recall cast is answered at once (done, no teleport: a fizzle or refusal).</summary>
|
||||
public void RunAnswered(double from, double to)
|
||||
{
|
||||
for (int ms = (int)Math.Round(from * 1000); ms <= (int)Math.Round(to * 1000); ms += 100)
|
||||
{
|
||||
At(ms / 1000.0);
|
||||
int before = Recalls;
|
||||
B.OnHeartbeat();
|
||||
if (Recalls > before) FakeHost.UseDone(0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Heartbeats every 100 ms from <paramref name="from"/> up to and including <paramref name="to"/>.</summary>
|
||||
public void Run(double from, double to)
|
||||
|
|
@ -227,17 +241,26 @@ internal static class HpFailsafeTests
|
|||
var ctx = RynthAiJsonContext.Default.LegacyUiSettings;
|
||||
// A profile with no saved value for it: off.
|
||||
var node = System.Text.Json.Nodes.JsonNode.Parse(System.Text.Json.JsonSerializer.Serialize(new LegacyUiSettings(), ctx))!.AsObject();
|
||||
Check.True(node.Remove("HpFailsafeRecall"), "the key is a serialized setting");
|
||||
Check.True(node.Remove("HpFailsafeRecallOptIn"), "the key is a serialized setting, under its 10-22 name");
|
||||
Check.False(node.ContainsKey("HpFailsafeRecall"), "the old name is no longer written");
|
||||
var noKey = System.Text.Json.JsonSerializer.Deserialize(node.ToJsonString(), ctx)!;
|
||||
var live = new LegacyUiSettings { HpFailsafeRecall = true };
|
||||
CopySettings(noKey, live);
|
||||
Check.False(live.HpFailsafeRecall, "no saved value: the recall loads off");
|
||||
// A profile that saved true (the owner turned it on, or the earlier default was saved): kept.
|
||||
// A profile saved before 10-22 with the old name on (the default until 10-18): off now. The
|
||||
// recall stops the macro, heals included, mid-fight, and it was killing players.
|
||||
node["HpFailsafeRecall"] = true;
|
||||
var old = System.Text.Json.JsonSerializer.Deserialize(node.ToJsonString(), ctx)!;
|
||||
var live2 = new LegacyUiSettings { HpFailsafeRecall = true };
|
||||
CopySettings(old, live2);
|
||||
Check.False(live2.HpFailsafeRecall, "an old saved true (the old name) loads off");
|
||||
// Ticked again since (saved under the new name): kept.
|
||||
node.Remove("HpFailsafeRecall");
|
||||
node["HpFailsafeRecallOptIn"] = true;
|
||||
var saved = System.Text.Json.JsonSerializer.Deserialize(node.ToJsonString(), ctx)!;
|
||||
var live2 = new LegacyUiSettings();
|
||||
CopySettings(saved, live2);
|
||||
Check.True(live2.HpFailsafeRecall, "a saved true stays on");
|
||||
var live3 = new LegacyUiSettings();
|
||||
CopySettings(saved, live3);
|
||||
Check.True(live3.HpFailsafeRecall, "ticked since 10-22: stays on");
|
||||
}
|
||||
|
||||
// A melee character with nothing to heal with (no spell, kit or potion), resting or out-healed at
|
||||
|
|
@ -251,7 +274,7 @@ internal static class HpFailsafeTests
|
|||
Check.Eq(FakeHost.Casts.Count, 0, "nothing to cast with");
|
||||
Check.Eq(FakeHost.TapJumps, 0, "no failsafe jump");
|
||||
Check.Eq(r.B.HpFailsafeBreaks, 0, "nothing counted");
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "no /lifestone");
|
||||
Check.Eq(Rig.Recalls, 0, "no Lifestone Recall");
|
||||
Check.Eq(r.B.HpFailsafeRecalls, 0, "no recall");
|
||||
Check.True(r.S.IsMacroRunning, "the macro keeps running");
|
||||
|
||||
|
|
@ -270,7 +293,7 @@ internal static class HpFailsafeTests
|
|||
p.B.SetWorldObjectCache(cache);
|
||||
p.Run(0, 40);
|
||||
Check.Eq(FakeHost.TapJumps, 0, "no spell known, potions off: no jump");
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "and no recall");
|
||||
Check.Eq(Rig.Recalls, 0, "and no recall");
|
||||
Check.True(p.S.IsMacroRunning, "the macro keeps running");
|
||||
}
|
||||
finally { Done(); }
|
||||
|
|
@ -282,18 +305,19 @@ internal static class HpFailsafeTests
|
|||
try
|
||||
{
|
||||
var r = new Rig(healthPct: 20, canHeal: true, recall: true);
|
||||
r.Run(0, 15.0);
|
||||
r.Run(0, 5.0);
|
||||
Check.Eq(FakeHost.TapJumps, 1, "capable + stuck: the jump");
|
||||
Check.False(r.S.IsMacroRunning, "capable + stuck + recall on: the macro stops");
|
||||
r.Run(15.1, 16.0);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 1, "and /lifestone goes out");
|
||||
r.Run(5.1, 7.0);
|
||||
Check.Eq(Rig.Recalls, 1, "and Lifestone Recall is cast");
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "never /lifestone");
|
||||
|
||||
// The option off (the default): the jump only, the macro keeps running.
|
||||
var d = new Rig(healthPct: 20, canHeal: true, recall: false);
|
||||
d.Run(0, 30.0);
|
||||
Check.Eq(FakeHost.TapJumps, 1, "recall off: the jump still");
|
||||
Check.True(d.S.IsMacroRunning, "recall off: no stop");
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "recall off: no /lifestone");
|
||||
Check.Eq(Rig.Recalls, 0, "recall off: no Lifestone Recall");
|
||||
}
|
||||
finally { Done(); }
|
||||
}
|
||||
|
|
@ -318,7 +342,9 @@ internal static class HpFailsafeTests
|
|||
r.Run(0, 15.0);
|
||||
Check.True(FakeHost.Uses.Contains(Potion), "the potion is drunk");
|
||||
Check.Eq(FakeHost.TapJumps, 1, "it did not raise health: the failsafe jump");
|
||||
Check.False(r.S.IsMacroRunning, "and the recall stage");
|
||||
// This spellbook has no Lifestone Recall: no recall, healing goes on.
|
||||
Check.True(r.S.IsMacroRunning, "no recall spell: the macro keeps running");
|
||||
Check.True(r.Logged("no recall: this character doesn't know Lifestone Recall"), "said why");
|
||||
}
|
||||
finally { Done(); }
|
||||
}
|
||||
|
|
@ -328,32 +354,28 @@ internal static class HpFailsafeTests
|
|||
try
|
||||
{
|
||||
var r = new Rig(healthPct: 20);
|
||||
r.Run(0, 7.4);
|
||||
r.Run(0, 4.9);
|
||||
Check.True(FakeHost.Casts.Count > 0, "a heal went out (and is never answered)");
|
||||
Check.Eq(FakeHost.TapJumps, 0, "7.4 s: no jump yet");
|
||||
r.Run(7.5, 7.5);
|
||||
Check.Eq(FakeHost.TapJumps, 1, "7.5 s (3 rounds, no rise): one jump");
|
||||
Check.Eq(FakeHost.TapJumps, 0, "4.9 s: no jump yet");
|
||||
r.Run(5.0, 5.0);
|
||||
Check.Eq(FakeHost.TapJumps, 1, "5 s (2 rounds, no rise, recall on): one jump");
|
||||
Check.Eq(r.B.HpFailsafeBreaks, 1, "counted");
|
||||
Check.True(r.Logged("HP failsafe: health 20% at or under Emergency Heal At 30%, no heal landed in 7.5 s: breaking the cast with a jump"),
|
||||
"the break is logged");
|
||||
r.Run(7.6, 14.9);
|
||||
Check.Eq(FakeHost.TapJumps, 1, "only one jump");
|
||||
Check.True(r.S.IsMacroRunning, "14.9 s: still running");
|
||||
r.Run(15.0, 15.0);
|
||||
Check.False(r.S.IsMacroRunning, "15 s (3 more rounds): the macro is stopped");
|
||||
Check.True(r.Logged("HP failsafe: health 20% at or under Emergency Heal At 30%, no heal landed in 5 s: breaking the cast with a jump, then Lifestone Recall at once"),
|
||||
"the break is logged: " + string.Join(" | ", FakeHost.Logs.Where(l => l.Contains("HP failsafe"))));
|
||||
Check.False(r.S.IsMacroRunning, "with the jump: the macro is stopped, no second wait");
|
||||
Check.Eq(r.MacroStops, 1, "with the rest of a /ra stop");
|
||||
Check.Eq(r.B.HpFailsafeRecalls, 1, "counted");
|
||||
Check.True(FakeHost.Chat.Any(c => c.Contains("recalling to the lifestone")), "and said in chat");
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "the recall waits for the stop to take effect");
|
||||
r.Run(15.1, 15.5);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "500 ms later: still waiting for the stop to take effect");
|
||||
r.Run(15.6, 15.6);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 1, "600 ms later: one recall");
|
||||
Check.Eq(FakeHost.ChatCommands[0], BuffManager.RecallCommand, "/lifestone");
|
||||
r.B.OnChatWindowText("Mira is recalling to the lifestone.", 0);
|
||||
r.Run(15.7, 20);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 1, "the recall line: no resend");
|
||||
Check.True(r.Logged("HP failsafe: the recall started"), "logged");
|
||||
Check.True(FakeHost.Chat.Any(c => c.Contains("casting Lifestone Recall")), "and said in chat");
|
||||
Check.Eq(Rig.Recalls, 0, "not in the same heartbeat: the stop edge runs first");
|
||||
r.Run(5.1, 6.6);
|
||||
Check.Eq(Rig.Recalls, 1, "once landed from the jump (400 ms or more): one Lifestone Recall: " + string.Join(" | ", FakeHost.Logs.Where(l => l.Contains("HP failsafe")).TakeLast(6)));
|
||||
Check.Eq(FakeHost.Casts.Last(c => c.SpellId == BuffManager.RecallSpellId).Target, Player, "on ourselves");
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "never /lifestone");
|
||||
FakeHost.Portaling = true; // the recall went
|
||||
r.Run(6.7, 20);
|
||||
Check.Eq(Rig.Recalls, 1, "portal space: no recast");
|
||||
Check.True(r.Logged("HP failsafe: the recall went (portal space"), "logged");
|
||||
FakeHost.Portaling = false;
|
||||
}
|
||||
finally { Done(); }
|
||||
}
|
||||
|
|
@ -362,13 +384,14 @@ internal static class HpFailsafeTests
|
|||
{
|
||||
try
|
||||
{
|
||||
var r = new Rig(healthPct: 20);
|
||||
// The round counting, recall off (the jump at 3 rounds).
|
||||
var r = new Rig(healthPct: 20, recall: false);
|
||||
r.Run(0, 5.0);
|
||||
r.V.CurrentHealth = 22; // +2: regeneration, not a heal
|
||||
r.Run(5.1, 7.5);
|
||||
Check.Eq(FakeHost.TapJumps, 1, "+2% is not a heal landing: the jump at 7.5 s");
|
||||
|
||||
var h = new Rig(healthPct: 20);
|
||||
var h = new Rig(healthPct: 20, recall: false);
|
||||
h.Run(0, 5.0);
|
||||
h.V.CurrentHealth = 23; // +3: a heal landed
|
||||
h.Run(5.1, 12.4);
|
||||
|
|
@ -376,7 +399,7 @@ internal static class HpFailsafeTests
|
|||
h.Run(12.5, 12.6);
|
||||
Check.Eq(FakeHost.TapJumps, 1, "7.5 s after the heal with no other: the jump");
|
||||
|
||||
var o = new Rig(healthPct: 20);
|
||||
var o = new Rig(healthPct: 20, recall: false);
|
||||
o.Run(0, 5.0);
|
||||
o.V.CurrentHealth = 31; // over Emergency Heal At 30
|
||||
o.Run(5.1, 5.1);
|
||||
|
|
@ -397,15 +420,17 @@ internal static class HpFailsafeTests
|
|||
r.Run(0, 20);
|
||||
Check.Eq(FakeHost.TapJumps, 1, "recall off: the jump still");
|
||||
Check.True(r.S.IsMacroRunning, "recall off: the macro keeps running");
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "no recall");
|
||||
Check.Eq(Rig.Recalls, 0, "no recall");
|
||||
Check.True(r.Logged("HP Failsafe Recall is off"), "said once in the log");
|
||||
|
||||
var n = new Rig(healthPct: 20);
|
||||
n.Run(0, 15.0);
|
||||
n.Run(0, 5.0);
|
||||
Check.False(n.S.IsMacroRunning, "recall: macro stopped");
|
||||
n.Run(15.1, 25);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 3, "no recall line: sent 3 times, 1.5 s apart, then stopped");
|
||||
Check.True(n.Logged("no recall seen after 3 tries"), "and logged");
|
||||
n.RunAnswered(5.1, 8.0);
|
||||
Check.Eq(Rig.Recalls, 1, "the first cast; answered, no portal space");
|
||||
n.RunAnswered(8.1, 25);
|
||||
Check.Eq(Rig.Recalls, 3, "cast 3 times, 3 s apart, then stopped: " + string.Join(" | ", FakeHost.Logs.Where(l => l.Contains("HP failsafe")).TakeLast(8)));
|
||||
Check.True(n.Logged("no portal space after 3 cast(s) of Lifestone Recall"), "and logged");
|
||||
}
|
||||
finally { Done(); }
|
||||
}
|
||||
|
|
@ -416,41 +441,22 @@ internal static class HpFailsafeTests
|
|||
try
|
||||
{
|
||||
var n = new Rig(healthPct: 20);
|
||||
n.Run(0, 15.0);
|
||||
n.Run(0, 5.0);
|
||||
Check.False(n.S.IsMacroRunning, "recall: macro stopped");
|
||||
n.Run(15.1, 21.0);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 3, "3 tries, no recall line");
|
||||
n.RunAnswered(5.1, 17.0);
|
||||
Check.Eq(Rig.Recalls, 3, "3 casts, no portal space");
|
||||
Check.True(n.S.IsMacroRunning, "the macro is back on (the heals and kits run again)");
|
||||
Check.Eq(n.B.HpFailsafeRecallsFailed, 1, "a failed recall counted");
|
||||
Check.True(FakeHost.Chat.Any(c => c.Contains("macro back on to keep healing")), "said in chat");
|
||||
n.Run(21.1, 49.0);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 3, "inside the 30 s cooldown: no recall");
|
||||
n.RunAnswered(17.1, 40.0);
|
||||
Check.Eq(Rig.Recalls, 3, "inside the 30 s cooldown: no recall");
|
||||
Check.True(n.S.IsMacroRunning, "and the macro keeps running");
|
||||
int breaks = FakeHost.Logs.Count(l => l.Contains("HP failsafe: health 20% at or under Emergency Heal At 30%, no heal landed in"));
|
||||
Check.True(breaks >= 2, $"the failsafe re-armed: it reached the break stage again ({breaks})");
|
||||
n.Run(49.1, 75.0);
|
||||
Check.True(n.Logged("no recall: the last recall never started"), "the cooldown is said");
|
||||
n.RunAnswered(40.1, 75.0);
|
||||
Check.Eq(n.B.HpFailsafeRecalls, 2, "after the cooldown: the next recall");
|
||||
Check.True(FakeHost.ChatCommands.Count > 3, "sent");
|
||||
}
|
||||
finally { Done(); }
|
||||
}
|
||||
|
||||
// Only our own recall line ends the wait.
|
||||
private static void RecallLineIsOurs()
|
||||
{
|
||||
try
|
||||
{
|
||||
var r = new Rig(healthPct: 20);
|
||||
r.Run(0, 15.6);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 1, "the first recall");
|
||||
r.B.OnChatWindowText("Bob is recalling to the lifestone.", 0);
|
||||
r.Run(15.7, 17.1);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 2, "another player's recall line: sent again");
|
||||
Check.False(r.Logged("HP failsafe: the recall started"), "not taken as ours");
|
||||
r.B.OnChatWindowText("ira is recalling to the lifestone.", 0); // the first letter dropped by the chat layer
|
||||
r.Run(17.2, 22);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 2, "ours (first letter dropped): no more sends");
|
||||
Check.True(r.Logged("HP failsafe: the recall started"), "logged");
|
||||
Check.True(Rig.Recalls > 3, "cast");
|
||||
}
|
||||
finally { Done(); }
|
||||
}
|
||||
|
|
@ -469,31 +475,31 @@ internal static class HpFailsafeTests
|
|||
finally { Done(); }
|
||||
}
|
||||
|
||||
// A pending recall is dropped on death: after the respawn it must not send /lifestone or switch
|
||||
// A pending recall is dropped on death: after the respawn it must not cast the recall or switch
|
||||
// the macro on, against Stop Macro On Death.
|
||||
private static void DeathDropsRecall()
|
||||
{
|
||||
try
|
||||
{
|
||||
var r = new Rig(healthPct: 20);
|
||||
r.Run(0, 15.0);
|
||||
r.Run(0, 5.0);
|
||||
Check.False(r.S.IsMacroRunning, "recall pending: macro stopped");
|
||||
r.V.CurrentHealth = 0; // dead before the first send
|
||||
r.Run(15.1, 30);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "0 health: no /lifestone");
|
||||
r.V.CurrentHealth = 0; // dead before the first cast
|
||||
r.Run(5.1, 30);
|
||||
Check.Eq(Rig.Recalls, 0, "0 health: no Lifestone Recall");
|
||||
Check.False(r.S.IsMacroRunning, "the macro stays off");
|
||||
Check.True(r.Logged("the pending recall is dropped (dead)"), "logged");
|
||||
|
||||
// The plugin's death hold drops it too (the vitals cache still reads the old health).
|
||||
var p = new Rig(healthPct: 20);
|
||||
p.Run(0, 15.0);
|
||||
p.Run(0, 5.0);
|
||||
var plugin = new RynthAiPlugin();
|
||||
PacerEdgeTests.SetHost(plugin, p.Host);
|
||||
typeof(RynthAiPlugin).GetField("_buffManager", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.SetValue(plugin, p.B);
|
||||
FakeHost.Vitals = (0, 100, 0, 100, 0, 100);
|
||||
typeof(RynthAiPlugin).GetMethod("HoldForDeath", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.Invoke(plugin, null);
|
||||
p.Run(15.1, 30);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 0, "death hold: no /lifestone after the respawn");
|
||||
p.Run(5.1, 30);
|
||||
Check.Eq(Rig.Recalls, 0, "death hold: no Lifestone Recall after the respawn");
|
||||
Check.False(p.S.IsMacroRunning, "death hold: the macro stays off");
|
||||
Check.True(p.Logged("the pending recall is dropped (death)"), "logged");
|
||||
}
|
||||
|
|
@ -507,26 +513,35 @@ internal static class HpFailsafeTests
|
|||
{
|
||||
var r = new Rig(healthPct: 20);
|
||||
r.B.MayRestartMacro = () => false; // VTank runs and yield is on
|
||||
r.Run(0, 21.0);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 3, "3 tries, no recall line");
|
||||
r.RunAnswered(0, 21.0);
|
||||
Check.Eq(Rig.Recalls, 3, "3 casts, no portal space");
|
||||
Check.False(r.S.IsMacroRunning, "VTank yield: the macro stays off");
|
||||
Check.True(FakeHost.Chat.Any(c => c.Contains("the macro stays off (VTank yield)")), "said in chat");
|
||||
}
|
||||
finally { Done(); }
|
||||
}
|
||||
|
||||
private static void RecallNameUnreadable()
|
||||
// No recall the character can't make: without the spell, or with less mana than it costs, the jump
|
||||
// runs, healing goes on and the macro keeps running; the reason is logged once per episode.
|
||||
private static void NoSpellNoManaNoRecall()
|
||||
{
|
||||
try
|
||||
{
|
||||
var r = new Rig(healthPct: 20);
|
||||
FakeHost.Names.Remove(Player);
|
||||
r.Run(0, 15.6);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 1, "the first recall");
|
||||
r.B.OnChatWindowText("Bob is recalling to the lifestone.", 0);
|
||||
r.Run(15.7, 20);
|
||||
Check.Eq(FakeHost.ChatCommands.Count, 1, "no name to compare: taken as ours, no resend");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("our name could not be read")), 1, "logged once");
|
||||
var r = new Rig(healthPct: 20, knowsRecall: false);
|
||||
r.Run(0, 20);
|
||||
Check.True(FakeHost.TapJumps >= 1, "the jump still");
|
||||
Check.Eq(Rig.Recalls, 0, "no Lifestone Recall");
|
||||
Check.True(r.S.IsMacroRunning, "the macro keeps running");
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("no recall: this character doesn't know Lifestone Recall")), 1, "said once");
|
||||
|
||||
var m = new Rig(healthPct: 20);
|
||||
BuffManager.ManaCostOverride = id => id == BuffManager.RecallSpellId ? 50 : 0; // FakeHost.Reset sets 0 for all
|
||||
m.V.CurrentMana = 10;
|
||||
m.Run(0, 20);
|
||||
Check.True(FakeHost.TapJumps >= 1, "no mana: the jump still");
|
||||
Check.Eq(Rig.Recalls, 0, "no mana: no Lifestone Recall");
|
||||
Check.True(m.S.IsMacroRunning, "no mana: the macro keeps running");
|
||||
Check.True(m.Logged("is under Lifestone Recall's cost"), "said why");
|
||||
}
|
||||
finally { Done(); }
|
||||
}
|
||||
|
|
|
|||
255
Tools/RynthCore.RynthAiHostTests/Tests/SelfTestMetaTests.cs
Normal file
255
Tools/RynthCore.RynthAiHostTests/Tests/SelfTestMetaTests.cs
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using RynthCore.Plugin.RynthAi;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.RynthAi.Meta;
|
||||
using RynthCore.PluginSdk;
|
||||
using RynthCore.RynthAiHostTests.Fakes;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
using A = RynthCore.Plugin.RynthAi.LegacyUi.MetaActionType;
|
||||
using C = RynthCore.Plugin.RynthAi.LegacyUi.MetaConditionType;
|
||||
|
||||
namespace RynthCore.RynthAiHostTests.Tests;
|
||||
|
||||
// The in-game self-test meta (GameTests\RynthSelfTest.af, 2026-10-22): RynthAi tests itself on a
|
||||
// character by running this meta, and RynthCore's scripts\Run-GameTest.ps1 reads the results it saves
|
||||
// (rt_<check> = PASS / FAIL / SKIP in the character's pvars). These check offline that it parses as
|
||||
// written and that it walks its states and records results the way the script expects, on the fake
|
||||
// clock with RynthAi's own chat lines fed in. Nothing here plays the game: the real run does that.
|
||||
internal static class SelfTestMetaTests
|
||||
{
|
||||
private const uint Player = 0x50000A01;
|
||||
private static readonly string[] States = { "Default", "T1 Buff", "T2 Fight", "T3 Loot", "T4 Craft", "T4 Craft run", "Done" };
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("self-test meta: RynthSelfTest.af parses cleanly and every SetState goes to one of its states", ParsesCleanly);
|
||||
r.Add("self-test meta: a run with nothing to fight or craft passes buffing, skips the rest, puts options back", PlaysThrough);
|
||||
r.Add("self-test meta: buffing fails after 300 s without \"Force Rebuff Complete\"", BuffTimesOut);
|
||||
r.Add("self-test meta: missile crafting passes on \"Equipped ammo\", fails on a crafting error", Crafting);
|
||||
r.Add("self-test meta: ratargetcount[] is combat's target count; the fight is a SKIP when combat finds nothing to attack", FightTargets);
|
||||
}
|
||||
|
||||
// The first run on Freya (2026-10-22) failed the fight beside a buff bot: wobjectfindnearestmonster[]
|
||||
// found it (attackable), combat rightly left it alone, and after 180 s that read as a FAIL.
|
||||
private static void FightTargets()
|
||||
{
|
||||
var bare = new Run(Host());
|
||||
Check.Eq(bare.M.Expressions.Evaluate("ratargetcount[]"), "-1", "not wired: -1");
|
||||
bare.M.SetCombatTargetCount(() => 3);
|
||||
Check.Eq(bare.M.Expressions.Evaluate("ratargetcount[]"), "3", "wired: combat's count");
|
||||
|
||||
Run Beside(int targets)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.Names[Player] = "Selftest";
|
||||
FakeHost.Positions[Player] = (0xA9B4001Cu, 50f, 50f, 0f);
|
||||
const uint buffBot = 0x80000021;
|
||||
FakeHost.Names[buffBot] = "Pumpkin Buffer";
|
||||
FakeHost.Positions[buffBot] = (0xA9B4001Cu, 60f, 50f, 0f);
|
||||
FakeHost.ItemTypes[buffBot] = 0x10;
|
||||
var host = FakeHost.Create();
|
||||
var cache = FakeHost.MakeCache(host, Player, new[] { buffBot }, new Dictionary<uint, float> { [buffBot] = 1f });
|
||||
var r = new Run(host, cache, "T2 Fight");
|
||||
r.M.SetCombatTargetCount(() => targets);
|
||||
return r;
|
||||
}
|
||||
|
||||
var idle = Beside(0);
|
||||
idle.Tick();
|
||||
idle.Tick(2);
|
||||
Check.Eq(idle.P("rt_fight"), "PENDING", "something attackable in view: no SKIP at 2 s");
|
||||
Check.True(idle.S.EnableCombat, "combat on");
|
||||
idle.Tick(27);
|
||||
Check.Eq(idle.P("rt_fight"), "PENDING", "still waiting at 29 s");
|
||||
idle.Tick(2);
|
||||
Check.Eq(idle.P("rt_fight"), "SKIP", "SKIP at 30 s when combat's scan has no target");
|
||||
Check.True(idle.P("rt_fight_why").Contains("Pumpkin Buffer"), "names what was in view: " + idle.P("rt_fight_why"));
|
||||
|
||||
var stuck = Beside(2);
|
||||
stuck.Tick();
|
||||
stuck.Tick(2);
|
||||
stuck.Tick(30);
|
||||
Check.Eq(stuck.P("rt_fight"), "PENDING", "combat has targets: no SKIP at 30 s");
|
||||
stuck.Tick(150);
|
||||
Check.Eq(stuck.P("rt_fight"), "FAIL", "targets but no kill in 180 s: FAIL");
|
||||
Check.True(stuck.P("rt_fight_why").Contains("combat sees 2 target(s)"), "says what combat saw: " + stuck.P("rt_fight_why"));
|
||||
}
|
||||
|
||||
private static LoadedMeta Load()
|
||||
{
|
||||
for (var dir = new DirectoryInfo(AppContext.BaseDirectory); dir != null; dir = dir.Parent)
|
||||
{
|
||||
string path = Path.Combine(dir.FullName, "GameTests", "RynthSelfTest.af");
|
||||
if (File.Exists(path)) return AfFileParser.LoadFromText(File.ReadAllText(path));
|
||||
}
|
||||
throw new FileNotFoundException("GameTests\\RynthSelfTest.af not found above " + AppContext.BaseDirectory);
|
||||
}
|
||||
|
||||
private static IEnumerable<MetaRule> AllRules(IEnumerable<MetaRule> rules)
|
||||
{
|
||||
foreach (MetaRule r in rules)
|
||||
{
|
||||
yield return r;
|
||||
foreach (MetaRule c in AllRules(r.Children)) yield return c;
|
||||
foreach (MetaRule c in AllRules(r.ActionChildren)) yield return c;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ParsesCleanly()
|
||||
{
|
||||
LoadedMeta meta = Load();
|
||||
Check.Eq(string.Join(" | ", meta.Warnings), "", "no parse warnings");
|
||||
Check.Eq(string.Join(", ", meta.DeclaredStates), string.Join(", ", States), "the states, in order");
|
||||
Check.Eq(meta.StartState, "Default", "starts in Default");
|
||||
var all = AllRules(meta.Rules).ToList();
|
||||
// A DoAll's children are actions only (their Condition stays at the default, Never).
|
||||
var conditions = meta.Rules.Concat(meta.Rules.SelectMany(r => AllRules(r.Children)));
|
||||
Check.False(conditions.Any(r => r.Condition == C.Never), "no condition read as Never (an unknown keyword)");
|
||||
// An All's children are conditions only (their Action stays None); a DoAll's are the actions.
|
||||
var actions = meta.Rules.Concat(meta.Rules.SelectMany(r => AllRules(r.ActionChildren)));
|
||||
Check.False(actions.Any(r => r.Action == A.None), "no action read as None (an unknown keyword)");
|
||||
foreach (MetaRule r in all.Where(r => r.Action == A.SetMetaState))
|
||||
Check.True(meta.DeclaredStates.Contains(r.ActionData), $"SetState {{{r.ActionData}}} (in {r.State}) is a declared state");
|
||||
Check.True(all.Any(r => r.Action == A.ChatCommand && r.ActionData == "/ra stop"), "it stops the macro at the end");
|
||||
}
|
||||
|
||||
private sealed class Run
|
||||
{
|
||||
public readonly LegacyUiSettings S;
|
||||
public readonly MetaManager M;
|
||||
public readonly List<string> Ra = new();
|
||||
public DateTime Now = new(2026, 10, 22, 12, 0, 0);
|
||||
|
||||
public Run(RynthCoreHost host, WorldObjectCache? cache = null, string startState = "Default")
|
||||
{
|
||||
S = new LegacyUiSettings
|
||||
{
|
||||
IsMacroRunning = true, EnableMeta = true, CurrentState = startState, ForceStateReset = true,
|
||||
EnableCombat = true, EnableBuffing = true, EnableLooting = true, EnableNavigation = true,
|
||||
MetaRules = Load().Rules,
|
||||
};
|
||||
M = new MetaManager(S, host, new PlayerVitalsCache()) { Clock = () => Now };
|
||||
M.SetPlayerId(Player);
|
||||
M.SetRaCommandHandler(Ra.Add);
|
||||
if (cache != null) M.SetObjectCache(cache);
|
||||
}
|
||||
|
||||
public void Tick(double seconds = 0) { Now = Now.AddSeconds(seconds); M.Think(); }
|
||||
|
||||
/// <summary>Ticks a second at a time until the meta is in <paramref name="state"/>, at most <paramref name="max"/> times.</summary>
|
||||
public bool TickUntil(string state, int max = 20)
|
||||
{
|
||||
for (int i = 0; i < max && !string.Equals(S.CurrentState, state, StringComparison.OrdinalIgnoreCase); i++) Tick(1);
|
||||
return string.Equals(S.CurrentState, state, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public void Chat(string line) { M.HandleChat(line); Tick(); }
|
||||
public string P(string key) => M.Expressions.Evaluate($"getpvar[{key}]");
|
||||
}
|
||||
|
||||
private static RynthCoreHost Host()
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.Names[Player] = "Selftest";
|
||||
return FakeHost.Create();
|
||||
}
|
||||
|
||||
private static void PlaysThrough()
|
||||
{
|
||||
var run = new Run(Host());
|
||||
run.Tick();
|
||||
Check.False(run.S.EnableCombat || run.S.EnableBuffing || run.S.EnableLooting || run.S.EnableNavigation, "Default turns combat, buffing, looting and nav off");
|
||||
Check.Eq(run.P("rt_status"), "RUNNING", "rt_status RUNNING");
|
||||
Check.Eq(run.P("rt_meta"), "PASS", "rt_meta PASS");
|
||||
Check.Eq(run.P("rt_buff"), "PENDING", "rt_buff PENDING until tested");
|
||||
|
||||
Check.True(run.TickUntil("T1 Buff"), "on to T1 Buff");
|
||||
run.Tick();
|
||||
Check.True(run.S.EnableBuffing, "buffing on for the test");
|
||||
Check.True(run.Ra.Any(c => c.Contains("buff force")), "asks for a force rebuff");
|
||||
run.Chat("[RynthAi] Force Rebuff Complete.");
|
||||
Check.Eq(run.P("rt_buff"), "PASS", "buffing PASS on \"Force Rebuff Complete\"");
|
||||
Check.True(run.P("rt_buff_why").StartsWith("a force rebuff finished in "), "says how long it took: " + run.P("rt_buff_why"));
|
||||
|
||||
Check.True(run.TickUntil("Done"), "no monster, no kill, no bundles: on to Done");
|
||||
Check.Eq(run.P("rt_fight"), "SKIP", "fight SKIP with no monster in view");
|
||||
Check.Eq(run.P("rt_loot"), "SKIP", "looting SKIP without a kill");
|
||||
Check.Eq(run.P("rt_craft"), "SKIP", "missile crafting SKIP without bundles");
|
||||
run.Tick();
|
||||
Check.Eq(run.P("rt_status"), "DONE", "rt_status DONE");
|
||||
Check.True(run.S.EnableCombat && run.S.EnableBuffing && run.S.EnableLooting && run.S.EnableNavigation, "options put back as they were");
|
||||
run.Tick(3);
|
||||
Check.True(run.Ra.Any(c => c.TrimEnd().EndsWith("stop")), "stops the macro");
|
||||
}
|
||||
|
||||
private static void BuffTimesOut()
|
||||
{
|
||||
var run = new Run(Host());
|
||||
Check.True(run.TickUntil("T1 Buff"), "on to T1 Buff");
|
||||
run.Tick();
|
||||
run.Tick(299);
|
||||
Check.Eq(run.P("rt_buff"), "PENDING", "still waiting at 299 s");
|
||||
run.Tick(2);
|
||||
Check.Eq(run.P("rt_buff"), "FAIL", "FAIL after 300 s");
|
||||
Check.True(run.P("rt_buff_why").Contains("300 s"), "says why: " + run.P("rt_buff_why"));
|
||||
|
||||
var wedged = new Run(Host());
|
||||
wedged.TickUntil("T1 Buff");
|
||||
wedged.Tick();
|
||||
wedged.Chat("[RynthAi] Can't enter Magic mode (no wand found) - buffing paused.");
|
||||
Check.Eq(wedged.P("rt_buff"), "FAIL", "FAIL at once on a buffing error");
|
||||
Check.True(wedged.P("rt_buff_why").StartsWith("Can't enter Magic mode"), "the error is the reason: " + wedged.P("rt_buff_why"));
|
||||
}
|
||||
|
||||
private static (RynthCoreHost, WorldObjectCache) Archer()
|
||||
{
|
||||
var host = Host();
|
||||
FakeHost.Names[0x60000001] = "Bundle of Deadly Prismatic Arrowheads";
|
||||
FakeHost.Names[0x60000002] = "Bundle of Arrowshafts";
|
||||
FakeHost.Containers[0x60000001] = Player;
|
||||
FakeHost.Containers[0x60000002] = Player;
|
||||
host = FakeHost.Create();
|
||||
return (host, FakeHost.MakeCache(host, Player, new uint[] { 0x60000001, 0x60000002 }));
|
||||
}
|
||||
|
||||
private static void Crafting()
|
||||
{
|
||||
var (host, cache) = Archer();
|
||||
var run = new Run(host, cache, "T4 Craft");
|
||||
Check.True(run.TickUntil("T4 Craft run"), "bundles carried, no melee weapon or wand in hand: the craft runs");
|
||||
run.Tick();
|
||||
run.Chat("[RynthAi Craft] No wielded Arrows. Evaluating...");
|
||||
run.Chat("[RynthAi Craft] Crafting Deadly Prismatic Arrow x2");
|
||||
Check.Eq(run.P("rt_craft"), "PENDING", "not decided while crafting");
|
||||
run.Chat("[RynthAi Craft] Equipped ammo (id=0x80001234)");
|
||||
Check.Eq(run.P("rt_craft"), "PASS", "PASS on \"Equipped ammo\"");
|
||||
Check.True(run.P("rt_craft_why").StartsWith("made ammo from the bundles"), "says ammo was made: " + run.P("rt_craft_why"));
|
||||
Check.Eq(run.S.CurrentState, "Done", "then Done");
|
||||
|
||||
var (host2, cache2) = Archer();
|
||||
var rewield = new Run(host2, cache2, "T4 Craft");
|
||||
rewield.TickUntil("T4 Craft run");
|
||||
rewield.Tick();
|
||||
rewield.Chat("[RynthAi Craft] Equipping Deadly Prismatic Arrow");
|
||||
rewield.Chat("[RynthAi Craft] Equipped ammo (id=0x80001234)");
|
||||
Check.True(rewield.P("rt_craft_why").StartsWith("put carried ammo back on"), "says carried ammo went back on: " + rewield.P("rt_craft_why"));
|
||||
|
||||
var (host3, cache3) = Archer();
|
||||
var broken = new Run(host3, cache3, "T4 Craft");
|
||||
broken.TickUntil("T4 Craft run");
|
||||
broken.Tick();
|
||||
broken.Chat("[RynthAi Craft] Craft timed out — no response from server");
|
||||
Check.Eq(broken.P("rt_craft"), "FAIL", "FAIL on a crafting error");
|
||||
Check.True(broken.P("rt_craft_why").StartsWith("Craft timed out"), "the error is the reason: " + broken.P("rt_craft_why"));
|
||||
|
||||
var (host4, cache4) = Archer();
|
||||
var silent = new Run(host4, cache4, "T4 Craft");
|
||||
silent.TickUntil("T4 Craft run");
|
||||
silent.Tick();
|
||||
silent.Tick(76);
|
||||
Check.Eq(silent.P("rt_craft"), "FAIL", "FAIL when Missile Crafting says nothing for 75 s (the 10.19.1 break)");
|
||||
}
|
||||
}
|
||||
|
|
@ -96,8 +96,16 @@ internal static partial class Program
|
|||
unsafe
|
||||
{
|
||||
Eq(RynthCore.Plugin.Shared.RynthAiHubApiV1.BaseStructSize, (uint)(8 + 10 * sizeof(nint)), "the hub table's base size (10 functions)");
|
||||
Eq((uint)sizeof(RynthCore.Plugin.Shared.RynthAiHubApiV1), RynthCore.Plugin.Shared.RynthAiHubApiV1.BaseStructSize + (uint)sizeof(nint),
|
||||
"SessionStatsMore appended right after the base");
|
||||
// Append-only: each field added after the base sits at the offset readers check it by
|
||||
// (VaultedDungeonsEnabled, BackAwayFrom and SetPlayerCounter came after SessionStatsMore).
|
||||
RynthCore.Plugin.Shared.RynthAiHubApiV1 t = default;
|
||||
byte* at = (byte*)&t;
|
||||
Eq((int)((byte*)&t.SessionStatsMore - at), RynthCore.Plugin.Shared.RynthAiHubApiV1.SessionStatsMoreOffset, "SessionStatsMore appended right after the base");
|
||||
Eq((int)((byte*)&t.VaultedDungeonsEnabled - at), RynthCore.Plugin.Shared.RynthAiHubApiV1.VaultedDungeonsEnabledOffset, "VaultedDungeonsEnabled next");
|
||||
Eq((int)((byte*)&t.BackAwayFrom - at), RynthCore.Plugin.Shared.RynthAiHubApiV1.BackAwayFromOffset, "BackAwayFrom next");
|
||||
Eq((int)((byte*)&t.SetPlayerCounter - at), RynthCore.Plugin.Shared.RynthAiHubApiV1.SetPlayerCounterOffset, "SetPlayerCounter next");
|
||||
Eq((uint)sizeof(RynthCore.Plugin.Shared.RynthAiHubApiV1), (uint)(RynthCore.Plugin.Shared.RynthAiHubApiV1.SetPlayerCounterOffset + sizeof(nint)),
|
||||
"SetPlayerCounter is the last field (a new one appends here, with its own offset check)");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -381,18 +381,22 @@ namespace RynthLua.ScriptWindowsTests
|
|||
var (underId, under) = found.First(f => f.Id != iconId);
|
||||
AcIconImage? both = AcIconDecoder.Compose(dat, iconId, underId, 0);
|
||||
Check(both != null && both.Width == icon.Width && both.Height == icon.Height, "stacked: the icon's size");
|
||||
if (both == null) return;
|
||||
// Since 2026-10-09 (engine fd12e93) Compose repaints the dat's white outline band, as the client
|
||||
// does, so the icon on its own is Compose with no layers, not the raw Decode.
|
||||
AcIconImage? alone = AcIconDecoder.Compose(dat, iconId, 0, 0);
|
||||
Check(alone != null && alone.Pixels.Length == icon.Pixels.Length, "the icon alone: same size as decoded");
|
||||
if (both == null || alone == null) return;
|
||||
bool overOk = true, underOk = true;
|
||||
for (int i = 0; i < 1024; i++)
|
||||
{
|
||||
int a = icon.Pixels[i * 4 + 3];
|
||||
if (a == 255 && !both.Pixels.AsSpan(i * 4, 4).SequenceEqual(icon.Pixels.AsSpan(i * 4, 4))) overOk = false;
|
||||
if (a == 255 && !both.Pixels.AsSpan(i * 4, 4).SequenceEqual(alone.Pixels.AsSpan(i * 4, 4))) overOk = false;
|
||||
if (a == 0 && !both.Pixels.AsSpan(i * 4, 4).SequenceEqual(under.Pixels.AsSpan(i * 4, 4)) && under.Pixels[i * 4 + 3] == 255) underOk = false;
|
||||
}
|
||||
Check(overOk, $"stacked: opaque icon pixels win (0x{iconId:X8} over 0x{underId:X8})");
|
||||
Check(underOk, "stacked: where the icon is clear, the underlay shows");
|
||||
AcIconImage? missingLayers = AcIconDecoder.Compose(dat, iconId, 0x06FFFFFE, 0x06FFFFFD);
|
||||
Check(missingLayers != null && missingLayers.Pixels.AsSpan().SequenceEqual(icon.Pixels), "a missing underlay / overlay is left out");
|
||||
Check(missingLayers != null && missingLayers.Pixels.AsSpan().SequenceEqual(alone.Pixels), "a missing underlay / overlay is left out");
|
||||
Check(AcIconDecoder.Compose(dat, 0x06FFFFFE, underId, 0) == null, "no picture when the icon itself is missing");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1820,10 +1820,13 @@ namespace RynthLua.ScriptWindowsTests
|
|||
int Renders() => (int)r.Eval("renders").Number;
|
||||
long f = System.Diagnostics.Stopwatch.Frequency;
|
||||
|
||||
// Each pass is timed between a stamp before and one after it, not from "now" after it: on a
|
||||
// busy PC the gap after a pass can be longer than the 1/60 s being checked (2026-10-22).
|
||||
long before = System.Diagnostics.Stopwatch.GetTimestamp();
|
||||
RunHudPasses(p);
|
||||
long after = System.Diagnostics.Stopwatch.GetTimestamp();
|
||||
Check(Renders() == 1 && h.EverPassed && !h.FirstPassSinceShown && !h.PassNow, "just shown: a pass on the first tick");
|
||||
long left = h.NextPassAt - System.Diagnostics.Stopwatch.GetTimestamp();
|
||||
Check(left > 0 && left <= f / 20, "the next pass is one 20/s interval away");
|
||||
Check(h.NextPassAt > before && h.NextPassAt <= after + f / 20, "the next pass is one 20/s interval away");
|
||||
RunHudPasses(p);
|
||||
Check(Renders() == 1, "no pass before the interval");
|
||||
h.NextPassAt = 0;
|
||||
|
|
@ -1837,13 +1840,14 @@ namespace RynthLua.ScriptWindowsTests
|
|||
Check(Renders() == 3 && h.NextPassAt == due + f / 20, "interval passes keep their cadence");
|
||||
|
||||
r.Do("hud.RefreshRate = 60");
|
||||
before = System.Diagnostics.Stopwatch.GetTimestamp();
|
||||
RunHudPasses(p);
|
||||
left = h.NextPassAt - System.Diagnostics.Stopwatch.GetTimestamp();
|
||||
Check(Renders() == 4 && left > 0 && left <= f / 60, "a new RefreshRate starts at once, 60/s");
|
||||
after = System.Diagnostics.Stopwatch.GetTimestamp();
|
||||
Check(Renders() == 4 && h.NextPassAt > before && h.NextPassAt <= after + f / 60, "a new RefreshRate starts at once, 60/s");
|
||||
r.Do("hud.RefreshRate = 1");
|
||||
before = System.Diagnostics.Stopwatch.GetTimestamp();
|
||||
RunHudPasses(p);
|
||||
left = h.NextPassAt - System.Diagnostics.Stopwatch.GetTimestamp();
|
||||
Check(Renders() == 5 && left > f / 2, "1/s");
|
||||
Check(Renders() == 5 && h.NextPassAt - before > f / 2, "1/s");
|
||||
|
||||
// Input: a pass on the next tick whatever the rate.
|
||||
ApplyHudEvents(p, Ev(HudFormat.EvClicked, 1, h.Hash, Fnv("B", h.Hash), 1, 0));
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ internal static partial class Program
|
|||
Run(nameof(RecallNotLinked), RecallNotLinked);
|
||||
Run(nameof(DungeonLandblocksFromTheAtlas), DungeonLandblocksFromTheAtlas);
|
||||
Run(nameof(AtlasSearchAndBestMatch), AtlasSearchAndBestMatch);
|
||||
Run(nameof(AtlasRecallPlaces), AtlasRecallPlaces);
|
||||
Run(nameof(ArrowSingleTarget), ArrowSingleTarget);
|
||||
Run(nameof(ArrowAlongRoute), ArrowAlongRoute);
|
||||
Run(nameof(FavoritesAndRecent), FavoritesAndRecent);
|
||||
|
|
@ -380,6 +381,36 @@ internal static partial class Program
|
|||
|
||||
// ── Atlas ────────────────────────────────────────────────────────────────
|
||||
|
||||
// The recalls' landing spots are found by name (2026-10-22, Skippy: "neft" found nothing).
|
||||
private static void AtlasRecallPlaces()
|
||||
{
|
||||
Atlas atlas = Atlas.Parse(@"{""locations"":[
|
||||
{""id"":1,""name"":""Holtburg"",""type"":""Town"",""cell"":""A9B40019"",""place"":""outdoor"",""ns"":42.1,""ew"":33.6}],
|
||||
""recalls"":[
|
||||
{""spell"":5541,""name"":""Lost City of Neftet Recall"",""cell"":""8763000E"",""place"":""outdoor"",""ns"":-22.21,""ew"":6.22},
|
||||
{""spell"":1635,""name"":""Ulgrim's Recall"",""cell"":""01960118"",""place"":""dungeon""},
|
||||
{""spell"":1636,""name"":""Ulgrim's Recall"",""cell"":""01960118"",""place"":""dungeon""},
|
||||
{""spell"":2479,""name"":""Advance Camp Recall"",""cell"":""027B0200"",""place"":""dungeon"",""in"":""Vile-Smelling Refuse""},
|
||||
{""spell"":0,""name"":"" "",""cell"":""00000000"",""place"":""dungeon""}]}");
|
||||
Check(atlas.Locations.Count == 1, "the recalls stay out of Locations (the route planner's list)");
|
||||
Check(atlas.Recalls.Count == 5, "the recalls themselves unchanged");
|
||||
Check(atlas.RecallPlaces.Count == 3, "three recall places (Ulgrim's twice is one; no name, none)");
|
||||
bool allRecall = true;
|
||||
foreach (var p in atlas.RecallPlaces) allRecall &= p.Type == Atlas.RecallType && p.Id < 0;
|
||||
Check(allRecall, "type Recall, negative ids");
|
||||
|
||||
var hits = atlas.Search("neft", null, 10);
|
||||
Check(hits.Count == 1 && hits[0].Name == "Lost City of Neftet Recall", "\"neft\" finds Lost City of Neftet Recall");
|
||||
Check(hits.Count == 1 && hits[0].OnMap && Math.Abs(hits[0].Ns + 22.21) < 1e-9 && Math.Abs(hits[0].Ew - 6.22) < 1e-9, "at 22.21S, 6.22E");
|
||||
var best = atlas.FindBest("neftet", false, 0, 0);
|
||||
Check(best != null && best.Type == Atlas.RecallType, "/rnav go neftet resolves to it");
|
||||
Check(atlas.FindBest("ulgrim", false, 0, 0) == null, "a dungeon recall is no arrow target");
|
||||
var camp = atlas.Search("advance camp", null, 10);
|
||||
Check(camp.Count == 1 && camp[0].Desc == "in Vile-Smelling Refuse", "a dungeon recall says where it is");
|
||||
Check(atlas.Search("", Atlas.RecallType, 50).Count == 3, "the Recall type filter");
|
||||
Check(atlas.Search("holtburg", null, 10).Count == 1, "other searches unchanged");
|
||||
}
|
||||
|
||||
private static void AtlasSearchAndBestMatch()
|
||||
{
|
||||
Atlas atlas = Atlas.Parse(AtlasJson);
|
||||
|
|
|
|||
Loading…
Reference in a new issue