Snapshot for release 2026.10.12.2 (internal 2dd3d00)
This commit is contained in:
parent
3c4f093e3d
commit
fe1eca0ca7
4 changed files with 381 additions and 10 deletions
|
|
@ -32,6 +32,7 @@ internal static class ManaReserveTests
|
|||
r.Add("mana reserve: combat holds an attack it can't pay for, and casts once mana is back", CombatHoldsCast);
|
||||
r.Add("mana reserve: a melee fighter's attacks aren't held; Get Mana At off means no reserve", MeleeAndOff);
|
||||
r.Add("mana reserve: the dat's BaseMana is read (when this PC has a portal.dat)", DatBaseMana);
|
||||
r.Add("mana reserve: a buff that would leave mana under the reserve waits for Stamina to Mana (melee too)", BuffWaitsForReserve);
|
||||
}
|
||||
|
||||
private static int Family(string name) => SpellTableStub.GetById(SpellTable.Named(name).First().Id)!.Family;
|
||||
|
|
@ -84,6 +85,28 @@ internal static class ManaReserveTests
|
|||
return ActivityArbiter.Decide(in inputs);
|
||||
}
|
||||
|
||||
// 2026-10-12, Drakkon (melee): a full rebuff spent mana down to 6%, under Stamina to Mana's cost.
|
||||
private static void BuffWaitsForReserve()
|
||||
{
|
||||
var r = new Rig(mana: 300); // in Magic stance: the buff path readies magic before this check
|
||||
int bane = Id("Blade Bane VI"); // level VI: cost 60 here
|
||||
int reserve = r.B.ManaReserve();
|
||||
Check.True(reserve > 0, $"a reserve for a melee character too ({reserve})");
|
||||
|
||||
Check.False(r.B.BuffWaitsForMana(bane, "Blade Bane"), "300/383: the buff goes");
|
||||
Check.Eq(FakeHost.Casts.Count, 0, "nothing cast by the check");
|
||||
|
||||
r.V.CurrentMana = (uint)(reserve + 30); // the buff (60) would leave it under the reserve
|
||||
Check.True(r.B.BuffWaitsForMana(bane, "Blade Bane"), "the buff waits");
|
||||
Check.Eq(FakeHost.Casts.Count, 1, "Stamina to Mana is cast instead");
|
||||
Check.Eq(FamilyOfCast(0), Family("Stamina to Mana Self I"), $"it is Stamina to Mana ({NameOf(FakeHost.Casts[0].SpellId)})");
|
||||
|
||||
// Under even the lowest Stamina to Mana's cost (10) and the buff's: buffing waits, no cast.
|
||||
var low = new Rig(mana: 5);
|
||||
Check.True(low.B.BuffWaitsForMana(bane, "Blade Bane"), "5/383: buffing waits for regen");
|
||||
Check.Eq(FakeHost.Casts.Count, 0, "nothing the server would refuse is sent");
|
||||
}
|
||||
|
||||
private static void ReserveChoosesStaminaToMana()
|
||||
{
|
||||
// Over Get Mana At 20% (77 of 383), but under 1.5x the top Stamina to Mana's cost.
|
||||
|
|
|
|||
|
|
@ -21,6 +21,183 @@ internal static class ManaStoneChoiceTests
|
|||
r.Add("mana stones: a stone just drained refills worn gear though its read still says empty", DrainedStoneRefills);
|
||||
r.Add("mana stones: a stone that gave its mana is not used again; 'fully charged' holds refills", GaveManaNotReused);
|
||||
r.Add("mana stones: tapping off, a stone whose charge can't be read is identified, then used", UnreadableStoneIdentified);
|
||||
r.Add("mana charges: a stack of 5 refills the gear 5 times", StackOfFiveRefillsFiveTimes);
|
||||
r.Add("mana charges: a single stone (stack of 1) that gave its mana is not used again", SingleStoneNotReused);
|
||||
r.Add("mana charges: used up, the next charge of that name is found (retail: each use destroys one)", NextChargeFoundByName);
|
||||
r.Add("mana charges: never taken for the empty stone to drain loot into", ChargeIsNeverEmptyStone);
|
||||
r.Add("mana charges: refill gear even when ManaStone rules name only other stones", ChargesIgnoreStoneRules);
|
||||
r.Add("mana stones: the server's 'low on Mana' refills gear whose read is stale-high", ServerLowRefills);
|
||||
r.Add("mana stones: worn gear is identified again, so a stale-high read follows the gear", GearReadRefreshed);
|
||||
r.Add("mana charges: overnight idle, the gear never runs dry (re-identify)", () => Overnight(identify: true));
|
||||
r.Add("mana charges: overnight idle, the gear never runs dry (server warnings only)", () => Overnight(identify: false));
|
||||
}
|
||||
|
||||
private const uint ChargeA = 0x80400031, ChargeB = 0x80400032, ChargeC = 0x80400033;
|
||||
private const string ManaCharge = "Great Mana Charge";
|
||||
private const string NeedMore = "The Mana Stone gives 1,000 points of mana to the following items: Khanda-handled Mace.\nYou need 2,000 more mana to fully charge your items.";
|
||||
|
||||
// 2026-10-11 report: armor ran dry overnight with Mana Charges in the pack. The prime suspect
|
||||
// (a stack of charges marked empty after one refill) doesn't happen with retail data: ACE Mana
|
||||
// Charges (wcid 4612-4616, 9060, 20179, 27329) don't stack and every use destroys one. But a stack
|
||||
// must still count as a source until it's gone.
|
||||
private static void StackOfFiveRefillsFiveTimes()
|
||||
{
|
||||
using var rig = new Rig(tapping: false, new (uint, int?)[] { (ChargeA, 1000) }, stoneName: ManaCharge);
|
||||
FakeHost.Ints[(ChargeA, StackSizeKey)] = 5;
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnPlayer.Count, i, $"refill {i} from the stack");
|
||||
Check.Eq(rig.OnPlayer[i - 1], ChargeA, "the same stack");
|
||||
rig.Chat(NeedMore);
|
||||
int left = FakeHost.Ints[(ChargeA, StackSizeKey)] - 1;
|
||||
if (left > 0) FakeHost.Ints[(ChargeA, StackSizeKey)] = left;
|
||||
else rig.Destroy(ChargeA);
|
||||
}
|
||||
rig.Run(10_000);
|
||||
Check.Eq(rig.OnPlayer.Count, 5, "the stack is used up: nothing more to use");
|
||||
}
|
||||
|
||||
private static void SingleStoneNotReused()
|
||||
{
|
||||
using var rig = new Rig(tapping: false, new (uint, int?)[] { (StoneA, 3000), (StoneB, 1000) });
|
||||
FakeHost.Ints[(StoneA, StackSizeKey)] = 1;
|
||||
FakeHost.Ints[(StoneB, StackSizeKey)] = 1;
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnPlayer.Count, 1, "the fuller stone first");
|
||||
Check.Eq(rig.OnPlayer[0], StoneA, "stone A");
|
||||
rig.Chat(NeedMore); // A survived its destroy roll; its read still says 3000
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnPlayer.Count, 2, "the gear still needs mana");
|
||||
Check.Eq(rig.OnPlayer[1], StoneB, "stone B, not A again");
|
||||
}
|
||||
|
||||
private static void NextChargeFoundByName()
|
||||
{
|
||||
using var rig = new Rig(tapping: false, new (uint, int?)[] { (ChargeA, 1000), (ChargeB, 1000) }, stoneName: ManaCharge);
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
rig.Run(1000);
|
||||
rig.Chat(NeedMore);
|
||||
rig.Destroy(rig.OnPlayer[^1]); // ACE: Mana Charges always break (destroy chance 1.0)
|
||||
rig.Chat("The Mana Stone is destroyed.");
|
||||
}
|
||||
Check.Eq(rig.OnPlayer.Count, 2, "both charges used");
|
||||
Check.True(rig.OnPlayer[0] != rig.OnPlayer[1], "one each");
|
||||
rig.Run(10_000);
|
||||
Check.Eq(rig.OnPlayer.Count, 2, "none left");
|
||||
rig.AddStone(ChargeC, 1000); // bought another
|
||||
rig.Run(6000);
|
||||
Check.Eq(rig.OnPlayer.Count, 3, "the new charge is found by name");
|
||||
Check.Eq(rig.OnPlayer[2], ChargeC, "charge C");
|
||||
}
|
||||
|
||||
private static void ChargeIsNeverEmptyStone()
|
||||
{
|
||||
using var rig = new Rig(tapping: true, new (uint, int?)[] { (ChargeA, null) }, ringToDrain: true, stoneName: ManaCharge, maceMana: 5000);
|
||||
rig.Run(3000);
|
||||
Check.Eq(rig.OnRing.Count, 0, "an unread Mana Charge is not used to drain the looted ring (it would pour its charge into it)");
|
||||
Check.Eq(rig.M.CountEmptyStones(), 0, "no empty stone slots from charges");
|
||||
Check.False(rig.M.HasEmptyManaStone(), "no empty stone");
|
||||
}
|
||||
|
||||
private static void ChargesIgnoreStoneRules()
|
||||
{
|
||||
FakeHost.Reset();
|
||||
var host = FakeHost.Create();
|
||||
var cache = new WorldObjectCache(host);
|
||||
var s = new LegacyUiSettings { EnableManaTapping = true };
|
||||
s.ConsumableRules.Add(new ConsumableRule { Name = "Greater Mana Stone", Type = "ManaStone" });
|
||||
var m = new ManaStoneManager(host, s, cache);
|
||||
WorldObject W(string name) => new(0x60001000, name, AcObjectClass.ManaStone);
|
||||
Check.True(m.IsRefillStone(W("Massive Mana Charge")), "a Mana Charge refills gear though the rules name only a stone");
|
||||
Check.False(m.IsRefillStone(W("Major Mana Stone")), "an unnamed stone still doesn't");
|
||||
s.EnableManaTapping = false;
|
||||
Check.True(m.IsRefillStone(W("Tiny Mana Charge")), "tapping off too");
|
||||
}
|
||||
|
||||
private static void ServerLowRefills()
|
||||
{
|
||||
// The mace was identified at 90% and reads that forever (the fake never updates it).
|
||||
using var rig = new Rig(tapping: false, new (uint, int?)[] { (ChargeA, 1000), (ChargeB, 1000) }, stoneName: ManaCharge, maceMana: 4500);
|
||||
rig.Run(30_000);
|
||||
Check.Eq(rig.OnPlayer.Count, 0, "the read says 90%: nothing to do");
|
||||
rig.Chat("Your Khanda-handled Mace is low on Mana.");
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnPlayer.Count, 1, "the server's warning wins over the read");
|
||||
rig.Chat(NeedMore);
|
||||
rig.Destroy(rig.OnPlayer[0]);
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnPlayer.Count, 2, "still short of full: the next charge");
|
||||
rig.Chat("The Mana Stone gives 1,000 points of mana to the following items: Khanda-handled Mace.");
|
||||
rig.Chat("Your items are fully charged."); // as a line of its own
|
||||
rig.Run(5 * 60_000);
|
||||
Check.Eq(rig.OnPlayer.Count, 2, "full: back to the reads (90%)");
|
||||
}
|
||||
|
||||
private static void GearReadRefreshed()
|
||||
{
|
||||
using var rig = new Rig(tapping: false, new (uint, int?)[] { (ChargeA, 1000) }, stoneName: ManaCharge, maceMana: 4500);
|
||||
rig.Run(2000);
|
||||
int first = FakeHost.IdRequests.Count(i => i == Mace);
|
||||
Check.True(first >= 1, "the worn mace is identified");
|
||||
rig.Run(5 * 60_000);
|
||||
Check.Eq(FakeHost.IdRequests.Count(i => i == Mace), first, "not again within 10 minutes");
|
||||
rig.Run(6 * 60_000);
|
||||
Check.Eq(FakeHost.IdRequests.Count(i => i == Mace), first + 1, "again after 10 minutes");
|
||||
FakeHost.Ints[(Mace, CurManaKey)] = 1000; // that appraisal shows it at 20%
|
||||
rig.Run(1000);
|
||||
Check.Eq(rig.OnPlayer.Count, 1, "the fresh read refills it");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Twelve hours with the macro running and nothing else to do. The mace burns 1 mana every 5 s
|
||||
/// (8,640 over the night, it starts at 4,500 of 5,000); its read changes only when it is
|
||||
/// identified, or never (identify: false). The server side follows ACE: "low on Mana" two
|
||||
/// minutes before empty, a charge gives what the gear needs and is destroyed.
|
||||
/// </summary>
|
||||
private static void Overnight(bool identify)
|
||||
{
|
||||
var charges = new (uint, int?)[10];
|
||||
for (int i = 0; i < charges.Length; i++) charges[i] = (0x80400100u + (uint)i, 1000);
|
||||
using var rig = new Rig(tapping: false, charges, stoneName: ManaCharge, maceMana: 4500, identify: identify);
|
||||
const int max = 5000;
|
||||
int real = 4500, lowest = real, idsSeen = 0;
|
||||
double acc = 0;
|
||||
bool warned = false;
|
||||
const long step = 500;
|
||||
for (long t = 0; t < 12L * 3600 * 1000; t += step)
|
||||
{
|
||||
rig.Now += step;
|
||||
acc += 0.2 * step / 1000.0;
|
||||
if (acc >= 1) { int burn = Math.Min((int)acc, real); real -= burn; acc -= (int)acc; }
|
||||
lowest = Math.Min(lowest, real);
|
||||
if (real * 5 <= 120) { if (!warned) { warned = true; rig.Chat(real > 0 ? "Your Khanda-handled Mace is low on Mana." : "Your Khanda-handled Mace is out of Mana."); } }
|
||||
else warned = false;
|
||||
|
||||
int usesBefore = FakeHost.UsesOn.Count;
|
||||
rig.M.OnHeartbeat(0);
|
||||
|
||||
for (; idsSeen < FakeHost.IdRequests.Count; idsSeen++)
|
||||
if (FakeHost.IdRequests[idsSeen] == Mace) FakeHost.Ints[(Mace, CurManaKey)] = real; // the appraisal lands
|
||||
|
||||
for (int u = usesBefore; u < FakeHost.UsesOn.Count; u++)
|
||||
{
|
||||
var (src, target) = FakeHost.UsesOn[u];
|
||||
if (target != Player) continue;
|
||||
int charge = FakeHost.Ints.TryGetValue((src, CurManaKey), out int c) ? c : 0;
|
||||
int give = Math.Min(max - real, charge);
|
||||
if (give <= 0) { rig.Chat("You have no items equipped that need mana."); continue; }
|
||||
real += give;
|
||||
rig.Chat($"The Mana Stone gives {give:N0} points of mana to the following items: Khanda-handled Mace.\n" +
|
||||
(real >= max ? "Your items are fully charged." : $"You need {max - real:N0} more mana to fully charge your items."));
|
||||
rig.Destroy(src);
|
||||
rig.Chat("The Mana Stone is destroyed.");
|
||||
}
|
||||
}
|
||||
Check.True(lowest > 0, $"the mace never ran dry (lowest {lowest})");
|
||||
Check.True(rig.OnPlayer.Count >= 4, $"charges were used ({rig.OnPlayer.Count})");
|
||||
Check.True(rig.OnPlayer.Count <= 10, "no more uses than charges");
|
||||
}
|
||||
|
||||
// ── Refill rig (2026-10-11) ───────────────────────────────────────────
|
||||
|
|
@ -33,24 +210,29 @@ internal static class ManaStoneChoiceTests
|
|||
private const uint Player = 0x50000E01;
|
||||
private const uint StoneA = 0x80400001, StoneB = 0x80400002, StoneC = 0x80400003;
|
||||
private const uint Mace = 0x80400010, Ring = 0x80400020;
|
||||
private const uint CurManaKey = 107, MaxManaKey = 108, WieldedSlotKey = 10;
|
||||
private const uint CurManaKey = 107, MaxManaKey = 108, WieldedSlotKey = 10, StackSizeKey = 12;
|
||||
|
||||
private sealed class Rig : IDisposable
|
||||
{
|
||||
public long Now = 1_000_000;
|
||||
public readonly LegacyUiSettings S;
|
||||
public readonly ManaStoneManager M;
|
||||
public readonly WorldObjectCache C;
|
||||
private readonly string _stoneName;
|
||||
|
||||
/// <param name="stones">Stone id and its charge read (null = can't be read).</param>
|
||||
public Rig(bool tapping, (uint Id, int? Mana)[] stones, bool ringToDrain = false)
|
||||
/// <param name="identify">The engine can identify objects (RequestId).</param>
|
||||
public Rig(bool tapping, (uint Id, int? Mana)[] stones, bool ringToDrain = false,
|
||||
string stoneName = "Moderate Mana Stone", int maceMana = 0, bool identify = true)
|
||||
{
|
||||
FakeHost.Reset();
|
||||
FakeHost.UseOnCalls = true;
|
||||
FakeHost.WeaponCalls = true; // RequestId, HasAppraisalData
|
||||
FakeHost.WeaponCalls = identify; // RequestId, HasAppraisalData
|
||||
FakeHost.Names[Player] = "Stone Tester";
|
||||
_stoneName = stoneName;
|
||||
foreach (var (id, mana) in stones)
|
||||
{
|
||||
FakeHost.Names[id] = "Moderate Mana Stone";
|
||||
FakeHost.Names[id] = stoneName;
|
||||
FakeHost.Containers[id] = Player;
|
||||
SetMana(id, mana);
|
||||
}
|
||||
|
|
@ -58,7 +240,7 @@ internal static class ManaStoneChoiceTests
|
|||
FakeHost.Wielders[Mace] = Player;
|
||||
FakeHost.Ints[(Mace, WieldedSlotKey)] = 0x100000;
|
||||
FakeHost.Ints[(Mace, MaxManaKey)] = 5000;
|
||||
FakeHost.Ints[(Mace, CurManaKey)] = 0; // and it keeps reading 0: worn-item mana is an appraisal too
|
||||
FakeHost.Ints[(Mace, CurManaKey)] = maceMana; // and it keeps reading that: worn-item mana is an appraisal too
|
||||
var ids = new List<uint>();
|
||||
foreach (var st in stones) ids.Add(st.Id);
|
||||
ids.Add(Mace);
|
||||
|
|
@ -72,11 +254,11 @@ internal static class ManaStoneChoiceTests
|
|||
}
|
||||
|
||||
var host = FakeHost.Create(Player);
|
||||
var cache = FakeHost.MakeCache(host, Player, ids);
|
||||
C = FakeHost.MakeCache(host, Player, ids);
|
||||
S = new LegacyUiSettings { EnableManaTapping = tapping, ManaTapMinMana = 100 };
|
||||
S.IsMacroRunning = true;
|
||||
ManaStoneManager.Clock = () => Now;
|
||||
M = new ManaStoneManager(host, S, cache);
|
||||
M = new ManaStoneManager(host, S, C);
|
||||
if (ringToDrain) M.MarkLootedForTap(unchecked((int)Ring));
|
||||
}
|
||||
|
||||
|
|
@ -97,6 +279,26 @@ internal static class ManaStoneChoiceTests
|
|||
|
||||
public void Chat(string line) => M.OnChatWindowText(line);
|
||||
|
||||
/// <summary>A stone or charge arrives in the pack (bought, looted).</summary>
|
||||
public void AddStone(uint id, int? mana, int stack = 0)
|
||||
{
|
||||
FakeHost.Names[id] = _stoneName;
|
||||
FakeHost.Containers[id] = Player;
|
||||
SetMana(id, mana);
|
||||
if (stack > 0) FakeHost.Ints[(id, StackSizeKey)] = stack;
|
||||
_ = C[unchecked((int)id)];
|
||||
}
|
||||
|
||||
/// <summary>The server destroyed it (used up): it leaves the client and the cache.</summary>
|
||||
public void Destroy(uint id)
|
||||
{
|
||||
FakeHost.Names.Remove(id);
|
||||
FakeHost.Containers.Remove(id);
|
||||
FakeHost.Ints.Remove((id, CurManaKey));
|
||||
FakeHost.Ints.Remove((id, StackSizeKey));
|
||||
C.OnDeleteObject(id);
|
||||
}
|
||||
|
||||
public List<uint> OnPlayer => FakeHost.UsesOn.Where(u => u.Target == Player).Select(u => u.Source).ToList();
|
||||
public List<uint> OnRing => FakeHost.UsesOn.Where(u => u.Target == Ring).Select(u => u.Source).ToList();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue