RynthSuite as of 2026-11-15 (internal edf82e9): release 2026.11.15.1
This commit is contained in:
parent
b48c49f76e
commit
047117cbb0
11 changed files with 419 additions and 23 deletions
|
|
@ -50,6 +50,7 @@ public partial class CombatManager
|
|||
internal const double PassedOverBeyondRangeM = 15.0;
|
||||
|
||||
internal const string PassedOverLos = "line of sight blocked";
|
||||
internal const string PassedOverOtherLevel = "too far above or below for melee";
|
||||
internal const string PassedOverBlacklisted = "blacklisted";
|
||||
internal const string PassedOverNeverAttack = "on the never-attack list";
|
||||
internal const string PassedOverGhost = "a ghost (the server doesn't have it)";
|
||||
|
|
|
|||
|
|
@ -74,7 +74,26 @@ public partial class CombatManager
|
|||
/// </summary>
|
||||
internal string? OnSelectionChanged(uint selected, bool ours)
|
||||
{
|
||||
if (!_settings.FightSelectedTarget || ours) return null;
|
||||
if (ours)
|
||||
{
|
||||
// A monster RynthAi selected itself in the last SelfSelect.WindowMs: not followed. Said
|
||||
// (once per monster) when it isn't the one being fought, so a report shows a player's
|
||||
// click taken for the bot's own (R-20261112-030126-63b5: the log couldn't say why).
|
||||
// A held selection (below) stays held: the bot's pick isn't the player's change of mind.
|
||||
int sid = unchecked((int)selected);
|
||||
if (_settings.FightSelectedTarget && sid != activeTargetId)
|
||||
NoteSelectionIgnored(sid, "taken as RynthAi's own selection (it selected that monster moments ago)");
|
||||
return null;
|
||||
}
|
||||
// The player's own selection: it replaces any held one.
|
||||
Volatile.Write(ref _heldSelectionId, 0);
|
||||
if (!_settings.FightSelectedTarget)
|
||||
{
|
||||
HoldSelection(selected);
|
||||
NoteSettingOff(selected);
|
||||
return null;
|
||||
}
|
||||
_settingOffNoted = false;
|
||||
int fid = ForcedTargetId;
|
||||
if (fid != 0 && !_forcedBySelection) return null; // a /ra targetlock lock: kept
|
||||
|
||||
|
|
@ -89,7 +108,13 @@ public partial class CombatManager
|
|||
|
||||
int id = unchecked((int)selected);
|
||||
if (id == fid) return null;
|
||||
if (!_settings.IsMacroRunning || !_settings.EnableCombat) return null;
|
||||
if (!_settings.IsMacroRunning || !_settings.EnableCombat)
|
||||
{
|
||||
NoteSelectionIgnored(id, (!_settings.IsMacroRunning ? "the macro isn't running" : "Combat is off") +
|
||||
" (fought if it is still selected when it is)");
|
||||
HoldSelection(selected);
|
||||
return null;
|
||||
}
|
||||
|
||||
string? refusal = SelectedTargetRefusal(id);
|
||||
if (refusal != null)
|
||||
|
|
@ -121,6 +146,65 @@ public partial class CombatManager
|
|||
return far ? "far" : "locked";
|
||||
}
|
||||
|
||||
// ── A selection made while it couldn't be followed ───────────────────────
|
||||
// R-20261115-051911-9105 (2026-11-15, 2026.11.12.1): "stopped working, toggling it doesn't help".
|
||||
// Only selection CHANGES were followed. The player turned Combat off, selected a monster
|
||||
// attacking them, then turned Combat back on with it still selected: the bot locked another
|
||||
// monster by lowest health, and nothing in the log said why. The same with the setting turned
|
||||
// on (or the macro started) while a monster is already selected. Now the player's monster
|
||||
// selection made while the setting, the macro or Combat was off is held, and fought when all
|
||||
// three are on if it is still the game's selection (any later selection of the player's, or a
|
||||
// deselect, replaces it; the bot selecting something else in the meantime leaves it unselected).
|
||||
private volatile int _heldSelectionId;
|
||||
private bool _settingOffNoted;
|
||||
|
||||
private void HoldSelection(uint selected)
|
||||
{
|
||||
var wo = selected != 0 ? _worldFilter[unchecked((int)selected)] : null;
|
||||
if (wo != null && (int)wo.ObjectClass == (int)AcObjectClass.Monster && selected != _playerId)
|
||||
Volatile.Write(ref _heldSelectionId, unchecked((int)selected));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HandleCombatTrigger, every tick (pump thread): a monster the player selected while the setting,
|
||||
/// the macro or Combat was off, still selected now that all three are on, is followed like a new
|
||||
/// selection. Returns what OnSelectionChanged did (null = nothing held, or no longer selected).
|
||||
/// </summary>
|
||||
internal string? FollowHeldSelection()
|
||||
{
|
||||
int held = Volatile.Read(ref _heldSelectionId);
|
||||
if (held == 0 || !_settings.FightSelectedTarget || !_settings.IsMacroRunning || !_settings.EnableCombat) return null;
|
||||
if (Interlocked.CompareExchange(ref _heldSelectionId, 0, held) != held) return null;
|
||||
uint id = unchecked((uint)held);
|
||||
if (!_host.HasGetSelectedItemId || _host.GetSelectedItemId() != id) return null; // selected away since
|
||||
if (ForcedTargetId == id) return null;
|
||||
string name = _worldFilter[held]?.Name ?? "";
|
||||
_host.Log($"[CombatTarget] fight-selected: 0x{id:X8} '{name}' is still selected from before the setting, the macro and Combat were all on: following it now");
|
||||
return OnSelectionChanged(id, false);
|
||||
}
|
||||
|
||||
/// <summary>The setting off: one line (per time it is off) when the player selects a monster.</summary>
|
||||
private void NoteSettingOff(uint selected)
|
||||
{
|
||||
if (_settingOffNoted || selected == 0 || selected == _playerId) return;
|
||||
var wo = _worldFilter[unchecked((int)selected)];
|
||||
if (wo == null || (int)wo.ObjectClass != (int)AcObjectClass.Monster) return;
|
||||
_settingOffNoted = true;
|
||||
_host.Log($"[CombatTarget] fight-selected: 0x{selected:X8} '{wo.Name}' not followed: the setting \"Fight the monster I select\" is off " +
|
||||
"(said once while it stays off)");
|
||||
}
|
||||
|
||||
private int _selectionIgnoredNotedId;
|
||||
|
||||
/// <summary>A monster selection the setting didn't follow and otherwise wouldn't log: one line per monster.</summary>
|
||||
private void NoteSelectionIgnored(int id, string why)
|
||||
{
|
||||
var wo = _worldFilter[id];
|
||||
if (wo == null || (int)wo.ObjectClass != (int)AcObjectClass.Monster || _selectionIgnoredNotedId == id) return;
|
||||
_selectionIgnoredNotedId = id;
|
||||
_host.Log($"[CombatTarget] fight-selected: 0x{unchecked((uint)id):X8} '{wo.Name}' not followed: {why}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// /ra targetlock on the monster this setting already fights: it becomes the explicit lock
|
||||
/// (selections no longer move it). True when it did.
|
||||
|
|
|
|||
|
|
@ -1146,9 +1146,9 @@ public partial class CombatManager : IDisposable
|
|||
// filters below — that's what distinguishes "out of range" from "all filtered out".
|
||||
scanTotal++;
|
||||
bool hasMobPos = false;
|
||||
float tx = 0f, ty = 0f;
|
||||
float tx = 0f, ty = 0f, tz = 0f;
|
||||
double dist = hasPlayerPos
|
||||
? _worldFilter.DistanceFrom(meCell, meX, meY, meZ, wo.Id, out hasMobPos, out tx, out ty)
|
||||
? _worldFilter.DistanceFrom(meCell, meX, meY, meZ, wo.Id, out hasMobPos, out tx, out ty, out tz)
|
||||
: double.MaxValue;
|
||||
if (dist <= maxDist) scanRing++;
|
||||
|
||||
|
|
@ -1239,6 +1239,16 @@ public partial class CombatManager : IDisposable
|
|||
// ignored monster is not counted in either (it is dropped before the LOS check).
|
||||
if (!isForced && PriorityOf(wo.Id) <= 0) continue;
|
||||
|
||||
// On the floor above or below, or high on a ledge (2026-11-12): melee can't reach it from
|
||||
// here. A test character locked golems 6 m up in a building and swung under them until they
|
||||
// came down. Not counted as a monster nearby out of sight, so navigation (the hunt's walk up
|
||||
// the stairs) isn't held for it.
|
||||
if (hasMobPos && OutOfMeleeReachUpOrDown(dist, tz - meZ) && MeleeIsTheAttackOn(wo, attackType))
|
||||
{
|
||||
if (notePassed) NotePassedOver(wo.Id, dist, PassedOverOtherLevel);
|
||||
continue;
|
||||
}
|
||||
|
||||
bool losBlocked = false;
|
||||
if (LosBlockedOverride != null)
|
||||
losBlocked = LosBlockedOverride(wo.Id);
|
||||
|
|
@ -2901,9 +2911,15 @@ public partial class CombatManager : IDisposable
|
|||
// a late death notice killed a neighbour. Dropping it also hid it from the scan for
|
||||
// 4 s, and with no other mob in range the bot went to peace mid-fight.
|
||||
bool noticeForSwappedMob = pendingKillId != 0 && pendingKillId != tid;
|
||||
// A damage line naming the target (ResolveHitVictim stamped it) is an attack too.
|
||||
// A damage line naming the target (ResolveHitVictim stamped it) is an attack too, but only
|
||||
// one since this fight began. R-20261112-030126-63b5 (2026-11-13, a mage with a pet and
|
||||
// damage-over-time spells in a same-named pack): the player selected a monster ("Fight the
|
||||
// monster I select") that a ring had hurt a while before; 0.7 s after the switch, before any
|
||||
// cast at it, the pet's kill of the monster just left named the same name. The old hit
|
||||
// counted as an attack, so the selected monster was dropped as the dead one, kept off the
|
||||
// scan, and the selection ended "killed" - the bot went back to its own pick.
|
||||
bool curAttacked = _fightTargetId != tid || _fightCastCount > 0 || _pendingOffensiveTargetId == tid
|
||||
|| (tid != 0 && _hitAt.ContainsKey(tid));
|
||||
|| (tid != 0 && _hitAt.TryGetValue(tid, out DateTime curHitAt) && curHitAt >= _fightStartedAt);
|
||||
// A ring, wall or chain spell kills neighbours too. The server's health for the fight
|
||||
// target lands before its kill notice (ACE sends the 0 with the lethal hit), so a fight
|
||||
// target the server still says is alive didn't die: the notice is a same-named
|
||||
|
|
@ -4826,6 +4842,7 @@ public partial class CombatManager : IDisposable
|
|||
/// </summary>
|
||||
public void HandleCombatTrigger()
|
||||
{
|
||||
FollowHeldSelection(); // Fight the monster I select: one selected before it could be followed
|
||||
if (_scannedTargets.Count == 0) return;
|
||||
if (TryLockForcedTarget()) return; // Target lock (/ra targetlock): CombatManager.TargetLock.cs
|
||||
// Pull-away in progress: keep the incumbent until the kite ends (do not switch mid-flee).
|
||||
|
|
@ -7017,6 +7034,22 @@ public partial class CombatManager : IDisposable
|
|||
/// <summary>The line-of-sight check is skipped for melee within this (same units as Monster Range).</summary>
|
||||
internal const double MeleeIgnoresLosWithin = 4.0;
|
||||
|
||||
/// <summary>Melee leaves out a monster more than this above or below the character...</summary>
|
||||
internal const double MeleeMaxRiseM = 3.0;
|
||||
/// <summary>...when it is also this steep from here (rise over run, about 37 degrees): a monster up a ramp
|
||||
/// or a hillside is walked to, one on the floor above or a ledge overhead is not.</summary>
|
||||
internal const double MeleeMaxSlope = 0.75;
|
||||
|
||||
/// <summary>A monster <paramref name="dist"/> m away (3D), <paramref name="dz"/> m above (+) or below (-),
|
||||
/// is out of melee's reach: on another floor, or on a ledge or a roof.</summary>
|
||||
internal static bool OutOfMeleeReachUpOrDown(double dist, double dz)
|
||||
{
|
||||
double rise = Math.Abs(dz);
|
||||
if (!(rise > MeleeMaxRiseM)) return false;
|
||||
double run = Math.Sqrt(Math.Max(0, dist * dist - dz * dz));
|
||||
return rise > run * MeleeMaxSlope;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This monster gets melee: the attack type says so (Melee, or peace with a melee weapon in hand),
|
||||
/// or the fight's plan picks a melee weapon (a wand still in hand from buffing, about to swap).
|
||||
|
|
|
|||
|
|
@ -1379,8 +1379,12 @@ public class WorldObjectCache
|
|||
/// position as read (landblock-local) so the caller needn't read it again.
|
||||
/// </summary>
|
||||
public double DistanceFrom(uint cell1, float x1, float y1, float z1, int id2, out bool hasPos, out float x2, out float y2)
|
||||
=> DistanceFrom(cell1, x1, y1, z1, id2, out hasPos, out x2, out y2, out _);
|
||||
|
||||
/// <summary>The same, with the object's height (<paramref name="z2"/>) as read.</summary>
|
||||
public double DistanceFrom(uint cell1, float x1, float y1, float z1, int id2, out bool hasPos, out float x2, out float y2, out float z2)
|
||||
{
|
||||
hasPos = _host.TryGetObjectPosition(unchecked((uint)id2), out uint cell2, out x2, out y2, out float z2);
|
||||
hasPos = _host.TryGetObjectPosition(unchecked((uint)id2), out uint cell2, out x2, out y2, out z2);
|
||||
if (!hasPos)
|
||||
return double.MaxValue;
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,12 @@ internal sealed class OutdoorHunt
|
|||
/// <summary>A partial path whose end is within this of the monster still counts (the last step is combat's).</summary>
|
||||
public double ReachYd { get; set; } = 3;
|
||||
/// <summary>
|
||||
/// A walk whose end is more than this below or above the monster doesn't reach it (2026-11-12): RynthNav
|
||||
/// finds the ground up to 64 yd under a goal, so a monster on a roof, a ledge or the floor above read as
|
||||
/// reached from the spot under it, and the character stood there swinging up at it.
|
||||
/// </summary>
|
||||
public double ReachRiseYd { get; set; } = 3;
|
||||
/// <summary>
|
||||
/// A walk longer than this times Hunt Range is too far round: the first test hunt (10-23) chose a buff bot
|
||||
/// 12 yd away inside a building, a 143 yd walk; the walk led her past Hunt Range from it, she gave up,
|
||||
/// turned back, and chose it again, every second.
|
||||
|
|
@ -283,7 +289,7 @@ internal sealed class OutdoorHunt
|
|||
if (!moved && !due) return new Decision(Act.None, TargetId: TargetId);
|
||||
var w = PlanWalk(me, meCell, target.Pos, target.Cell);
|
||||
var p = w.P;
|
||||
if (Reaches(p))
|
||||
if (Reaches(p, target.Pos))
|
||||
{
|
||||
_plannedTo = target.Pos;
|
||||
_lastPlan = now;
|
||||
|
|
@ -303,7 +309,7 @@ internal sealed class OutdoorHunt
|
|||
else
|
||||
{
|
||||
Skip(target.Id, now);
|
||||
Note = $"'{target.Name}' can't be reached any more ({Describe(p, w.Why)}): left out for {SkipSec:0} s";
|
||||
Note = $"'{target.Name}' can't be reached any more ({Describe(p, w.Why, target.Pos)}): left out for {SkipSec:0} s";
|
||||
}
|
||||
}
|
||||
TargetId = 0;
|
||||
|
|
@ -326,11 +332,11 @@ internal sealed class OutdoorHunt
|
|||
var w = PlanWalk(me, meCell, c.Pos, c.Cell);
|
||||
var p = w.P;
|
||||
if (p.Status == PathStatus.Unavailable) return new Decision(Act.Idle, Why: "no pathfinder");
|
||||
if (Reaches(p)) _viable.Add((c, w));
|
||||
if (Reaches(p, c.Pos)) _viable.Add((c, w));
|
||||
else
|
||||
{
|
||||
Skip(c.Id, now);
|
||||
Note = $"'{c.Name}' left out for {SkipSec:0} s: {Describe(p, w.Why)}";
|
||||
Note = $"'{c.Name}' left out for {SkipSec:0} s: {Describe(p, w.Why, c.Pos)}";
|
||||
}
|
||||
}
|
||||
if (_viable.Count > 0)
|
||||
|
|
@ -452,11 +458,11 @@ internal sealed class OutdoorHunt
|
|||
var c = _eligible[i];
|
||||
var w = PlanWalk(me, meCell, c.Pos, c.Cell);
|
||||
if (w.P.Status == PathStatus.Unavailable) return new Decision(Act.Idle, Why: "no pathfinder");
|
||||
if (Reaches(w.P)) walks[i] = w;
|
||||
if (Reaches(w.P, c.Pos)) walks[i] = w;
|
||||
else
|
||||
{
|
||||
Skip(c.Id, now);
|
||||
Note = $"'{c.Name}' left out for {SkipSec:0} s: {Describe(w.P, w.Why)}";
|
||||
Note = $"'{c.Name}' left out for {SkipSec:0} s: {Describe(w.P, w.Why, c.Pos)}";
|
||||
}
|
||||
}
|
||||
if (walks.Count == 0) return Waiting();
|
||||
|
|
@ -593,12 +599,19 @@ internal sealed class OutdoorHunt
|
|||
|
||||
private bool InArea(Vec p) => RadiusYd <= 0 || p.FlatDistanceTo(Anchor) <= RadiusYd;
|
||||
|
||||
private bool Reaches(PathResult p) =>
|
||||
private bool Reaches(PathResult p, Vec goal) =>
|
||||
p.Corners.Count > 0 && (p.Status == PathStatus.Ok || (p.Status == PathStatus.Partial && p.Gap <= ReachYd))
|
||||
&& p.Length <= RangeYd * MaxWalkFactor;
|
||||
&& p.Length <= RangeYd * MaxWalkFactor && Math.Abs(EndRise(p, goal)) <= ReachRiseYd;
|
||||
|
||||
private string Describe(PathResult p, string why = "") => p.Status switch
|
||||
/// <summary>How far the monster is above (+) or below (-) the walk's end.</summary>
|
||||
private static double EndRise(PathResult p, Vec goal) => p.Corners.Count > 0 ? goal.Z - p.Corners[^1].Z : 0;
|
||||
|
||||
private string Describe(PathResult p, string why, Vec goal) => p.Status switch
|
||||
{
|
||||
_ when p.Corners.Count > 0 && Math.Abs(EndRise(p, goal)) > ReachRiseYd
|
||||
&& (p.Status == PathStatus.Ok || p.Status == PathStatus.Partial)
|
||||
=> EndRise(p, goal) > 0 ? $"{EndRise(p, goal):0} yd above the walk's end (on a ledge, a roof or the floor above)"
|
||||
: $"{-EndRise(p, goal):0} yd below the walk's end",
|
||||
_ when p.Corners.Count > 0 && p.Length > RangeYd * MaxWalkFactor
|
||||
&& (p.Status == PathStatus.Ok || p.Status == PathStatus.Partial) => $"a {p.Length:0} yd walk, too far round",
|
||||
_ when why.Length > 0 => why,
|
||||
|
|
|
|||
|
|
@ -124,6 +124,9 @@ internal sealed class AutoVendorManager
|
|||
// Stacks a split made to be sold, and the rule that sold the stack they came from: sold even when
|
||||
// a rule matches them differently at their new size ("Value = 250,000" on a one-note stack).
|
||||
private readonly Dictionary<uint, string> _splitOffForSale = new();
|
||||
// Per item key: the unit value read off a stack a split made (fresh from the server). Kept across
|
||||
// sessions, since the stale stacks it corrects stay stale until relog.
|
||||
private readonly Dictionary<string, int> _freshUnit = new(StringComparer.Ordinal);
|
||||
// Identifies AutoVendor asks for outside the session's ID pass (a split-off stack, a loose note).
|
||||
private readonly Dictionary<uint, (int Attempts, long LastAt)> _extraIds = new();
|
||||
private readonly HashSet<uint> _waitIdLogged = new();
|
||||
|
|
@ -1744,8 +1747,12 @@ internal sealed class AutoVendorManager
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Per item (weenie, else name): the Value / StackSize that the most units carry. A stack's Value goes
|
||||
/// stale after a split (too high) or a merge (too low); the untouched stacks outnumber them.
|
||||
/// Per item (weenie, else name): the true Value / StackSize. A stack's Value goes stale after a split
|
||||
/// (too high) or a merge (too low) and stays so until relog. A stack a split just made comes fresh from
|
||||
/// the server, so its unit wins and is remembered (<see cref="_freshUnit"/>); otherwise the unit the
|
||||
/// most units carry. The vote alone failed once the last full stack was split: 79 stale peas outvoted
|
||||
/// the 21 split off, the 21 read too dear to fit, were merged back, and the split came again until
|
||||
/// the 8-try stop (2026-11-12).
|
||||
/// </summary>
|
||||
private Dictionary<string, int> TrueUnitValues(List<WorldObject> inv)
|
||||
{
|
||||
|
|
@ -1759,10 +1766,12 @@ internal sealed class AutoVendorManager
|
|||
if (!votes.TryGetValue(key, out var byUnit)) votes[key] = byUnit = new Dictionary<int, long>();
|
||||
int unit = value / stack;
|
||||
byUnit[unit] = byUnit.GetValueOrDefault(unit) + stack;
|
||||
if (_splitOffForSale.ContainsKey(unchecked((uint)wo.Id)) && unit > 0)
|
||||
_freshUnit[key] = unit;
|
||||
}
|
||||
var result = new Dictionary<string, int>(StringComparer.Ordinal);
|
||||
foreach (var (key, byUnit) in votes)
|
||||
result[key] = AutoVendorPlanner.MostCarriedUnit(byUnit);
|
||||
result[key] = AutoVendorPlanner.TrueUnit(byUnit, _freshUnit.GetValueOrDefault(key));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -570,6 +570,13 @@ internal static class AutoVendorPlanner
|
|||
return VendorPlan.Split(item, amount, why);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The unit value to trust for one item: one read off a stack the server just made (a split's new
|
||||
/// stack) wins, since every older stack's Value may be stale; else <see cref="MostCarriedUnit"/>.
|
||||
/// </summary>
|
||||
internal static int TrueUnit(IReadOnlyDictionary<int, long> unitsByValue, int freshUnit) =>
|
||||
freshUnit > 0 ? freshUnit : MostCarriedUnit(unitsByValue);
|
||||
|
||||
/// <summary>The unit value carrying the most units (ties: the higher value, the safe side for a vendor's max).</summary>
|
||||
internal static int MostCarriedUnit(IReadOnlyDictionary<int, long> unitsByValue)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -447,6 +447,25 @@ internal static class Program
|
|||
Eq(AutoVendorPlanner.MostCarriedUnit(new Dictionary<int, long> { [25_000] = 50, [30_000] = 50 }), 30_000, "tie: the higher value");
|
||||
Eq(AutoVendorPlanner.MostCarriedUnit(new Dictionary<int, long>()), 0, "nothing: 0 (no override)");
|
||||
|
||||
// 2026-11-12 (DreamWeave, Pyreal Peas): the last full stack (100) split 21 off with 44 free slots. The
|
||||
// 79 left keep 100 peas' Value (63,291 a pea) and outvote the 21 (50,000): read at that price the 21
|
||||
// didn't fit, were merged back, and the split came again until the 8-try stop. The split-off stack
|
||||
// is fresh from the server, so its unit wins.
|
||||
var staleVotes = new Dictionary<int, long> { [5_000_000 / 79] = 79, [50_000] = 21 };
|
||||
Eq(AutoVendorPlanner.MostCarriedUnit(staleVotes), 5_000_000 / 79, "the vote alone picks the stale price");
|
||||
Eq(AutoVendorPlanner.TrueUnit(staleVotes, 50_000), 50_000, "a split-off stack's fresh unit wins");
|
||||
Eq(AutoVendorPlanner.TrueUnit(staleVotes, 0), 5_000_000 / 79, "no fresh unit: the vote");
|
||||
var lastFull = AutoVendorPlanner.PlanNext(v, none, new List<SellItem> { PyPea(1, 100) }, Pack(0, free: 44));
|
||||
Eq(lastFull.Kind, PlanKind.Split, "44 free: split...");
|
||||
Eq(lastFull.SplitAmount, 21, "...21 off");
|
||||
SellItem StalePea(uint id, int stack) => new() { Id = id, Name = "Pyreal Pea", Value = 5_000_000 / 79 * stack, StackSize = stack,
|
||||
Class = AcObjectClass.Misc, ItemType = 0x40000000, RuleName = "S: Peas", MaxStack = 100, Wcid = 9003 };
|
||||
var staleRead = AutoVendorPlanner.PlanNext(v, none, new List<SellItem> { StalePea(1, 79), StalePea(2, 21) }, Pack(0, free: 43));
|
||||
Eq(staleRead.Kind, PlanKind.Merge, "at the stale price the 21 is merged back (the loop)");
|
||||
var freshRead = AutoVendorPlanner.PlanNext(v, none, new List<SellItem> { PyPea(1, 79), PyPea(2, 21) }, Pack(0, free: 43));
|
||||
Eq(freshRead.Kind, PlanKind.Sell, "at the fresh price the 21 is sold");
|
||||
Eq(freshRead.Sells.Single().Id, 2u, "the split-off 21");
|
||||
|
||||
var unknownMax = AutoVendorPlanner.PlanNext(v, none, new List<SellItem> { S(1, "Gem", 100_000, stack: 100), S(2, "Gem", 50_000, stack: 50) }, Pack(0, free: 3));
|
||||
Eq(unknownMax.Kind, PlanKind.Split, "unknown max stack: the old plain split");
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ internal static class FightSelectedTests
|
|||
r.Add("fight selected: a /ra targetlock lock is never moved; /ra targetlock on the selected one makes it explicit", TargetLockInteraction);
|
||||
r.Add("fight selected: the setting off releases it; /ra fightselected, the settings face, profiles, metas", SettingPlumbing);
|
||||
r.Add("fight selected: /ra why says it is fighting the monster you selected", WhySaysSo);
|
||||
r.Add("fight selected: a monster selected while Combat, the macro or the setting was off is fought once they are on (R-20261115-051911-9105)", HeldSelectionFollowed);
|
||||
r.Add("fight selected: a same-named neighbour's kill notice doesn't end the selected monster before it is attacked (R-20261112-030126-63b5)", NeighbourKillKeepsSelected);
|
||||
}
|
||||
|
||||
// ── Rig ───────────────────────────────────────────────────────────────────
|
||||
|
|
@ -124,6 +126,19 @@ internal static class FightSelectedTests
|
|||
|
||||
private static void PlayerSelectionWins()
|
||||
{
|
||||
// Macro stopped or Combat off: not followed, and the log says why (once per monster).
|
||||
var off = new Rig();
|
||||
off.S.IsMacroRunning = false;
|
||||
Check.Eq(off.Select(B), null, "macro stopped: not followed");
|
||||
off.Select(0);
|
||||
off.Select(B);
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("'Mob B' not followed: the macro isn't running")), 1, "logged once");
|
||||
off.S.IsMacroRunning = true;
|
||||
off.S.EnableCombat = false;
|
||||
Check.Eq(off.Select(A), null, "Combat off: not followed");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("'Mob A' not followed: Combat is off")), "logged");
|
||||
Check.Eq(off.Forced, 0, "no lock");
|
||||
|
||||
var t = new Rig();
|
||||
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), Boss, "normal: the Boss's priority wins");
|
||||
Check.Eq(t.Select(B), "locked", "the player selects B");
|
||||
|
|
@ -169,6 +184,11 @@ internal static class FightSelectedTests
|
|||
bot.P.OnSelectedTargetChange(B, A);
|
||||
Check.Eq(t.Forced, 0, "the bot selecting another monster: not the player's");
|
||||
Check.Eq(t.Pick((A, 2), (B, 6)), A, "still A");
|
||||
// R-20261112-030126-63b5: an ignored monster selection says why (a player's click
|
||||
// taken for the bot's own shows in a report); the fight target's re-select doesn't.
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("fight-selected") && l.Contains("'Mob B' not followed: taken as RynthAi's own selection")),
|
||||
"the bot's selection of another monster is logged");
|
||||
Check.False(FakeHost.Logs.Any(l => l.Contains("'Mob A' not followed")), "its own target's re-select isn't");
|
||||
|
||||
// Several marks in a row: the earlier ones are still the bot's (not just the last).
|
||||
SelfSelect.Mark(Boss);
|
||||
|
|
@ -393,6 +413,153 @@ internal static class FightSelectedTests
|
|||
Check.True(bot.AllChat.Contains("likely: fighting the monster you selected"), "the interpretation: " + bot.AllChat);
|
||||
}
|
||||
|
||||
// R-20261115-051911-9105 (2026-11-15): the player turned Combat off, selected a monster that was
|
||||
// attacking them, turned Combat back on with it still selected, and the bot fought another
|
||||
// (lowest health). Only selection changes were followed; toggling the setting didn't help either.
|
||||
private static void HeldSelectionFollowed()
|
||||
{
|
||||
// Combat off: the selection is held, then fought when Combat comes back on.
|
||||
var t = new Rig();
|
||||
t.S.EnableCombat = false;
|
||||
FakeHost.SelectedItem = B;
|
||||
Check.Eq(t.Select(B), null, "Combat off: not followed yet");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("'Mob B' not followed: Combat is off")), "logged");
|
||||
t.S.EnableCombat = true;
|
||||
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), B, "Combat on, B still selected: B, over the Boss and the closer A");
|
||||
Check.Eq(t.Forced, I(B), "as the selected monster");
|
||||
Check.True(t.Combat.ForcedBySelection, "a selection lock");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("'Mob B' is still selected from before")), "logged");
|
||||
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), B, "kept");
|
||||
|
||||
// The setting off: said once while it stays off; turned on with B selected, B is fought.
|
||||
t = new Rig(on: false);
|
||||
FakeHost.SelectedItem = A;
|
||||
t.Select(A);
|
||||
FakeHost.SelectedItem = B;
|
||||
t.Select(B);
|
||||
Check.Eq(FakeHost.Logs.Count(l => l.Contains("not followed: the setting \"Fight the monster I select\" is off")), 1, "the setting off: one line");
|
||||
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), Boss, "off: normal priority");
|
||||
t.S.FightSelectedTarget = true;
|
||||
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), B, "the setting turned on with B selected: B");
|
||||
|
||||
// The macro started with B selected: the same.
|
||||
t = new Rig();
|
||||
t.S.IsMacroRunning = false;
|
||||
FakeHost.SelectedItem = B;
|
||||
t.Select(B);
|
||||
t.S.IsMacroRunning = true;
|
||||
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), B, "macro started with B selected: B");
|
||||
|
||||
// Selected away since (the bot's own pick, or the player's deselect): nothing held is fought.
|
||||
t = new Rig();
|
||||
t.S.EnableCombat = false;
|
||||
FakeHost.SelectedItem = B;
|
||||
t.Select(B);
|
||||
FakeHost.SelectedItem = Corpse; // e.g. the looter opened a corpse
|
||||
t.S.EnableCombat = true;
|
||||
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), Boss, "B no longer selected: normal priority");
|
||||
Check.Eq(t.Forced, 0, "no lock");
|
||||
t = new Rig();
|
||||
t.S.EnableCombat = false;
|
||||
FakeHost.SelectedItem = B;
|
||||
t.Select(B);
|
||||
FakeHost.SelectedItem = 0;
|
||||
t.Select(0);
|
||||
t.S.EnableCombat = true;
|
||||
FakeHost.SelectedItem = B; // even if B were the selection again by the bot's doing
|
||||
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), Boss, "a deselect drops the held one");
|
||||
// The bot's own selection doesn't replace a held one.
|
||||
t = new Rig();
|
||||
t.S.EnableCombat = false;
|
||||
FakeHost.SelectedItem = B;
|
||||
t.Select(B);
|
||||
t.Combat.OnSelectionChanged(A, ours: true);
|
||||
t.Combat.OnSelectionChanged(B, ours: true); // and back
|
||||
t.S.EnableCombat = true;
|
||||
Check.Eq(t.Pick((A, 2), (B, 6), (Boss, 4)), B, "the bot's selections in between don't drop it");
|
||||
}
|
||||
|
||||
// R-20261112-030126-63b5 (2026-11-13, a mage with a pet and damage-over-time spells, a pack of
|
||||
// same-named monsters): the player selected a monster, the bot switched to it, and 0.7 s later,
|
||||
// before a single cast at it, a kill notice for the monster it had just left (the pet's or a
|
||||
// DoT's kill) named the same name. The selected monster was taken for the dead one: dropped,
|
||||
// kept off the scan as killed, "fight-selected ... ended: killed", and the bot went back to
|
||||
// its own pick. The "not attacked yet" guard counted a hit from any time as an attack on it,
|
||||
// and this one had been hurt by a ring a while before it was selected.
|
||||
private static void NeighbourKillKeepsSelected()
|
||||
{
|
||||
const uint X = 0x80000A21, Y = 0x80000A22, Wcid = 3001;
|
||||
const string Name = "Bovine Brute";
|
||||
DateTime now = DateTime.Now;
|
||||
RynthClock.TestNow = () => now;
|
||||
try
|
||||
{
|
||||
FakeHost.Reset();
|
||||
SelfSelect.Reset();
|
||||
FakeHost.WeaponCalls = true; // installs GetCurrentCombatMode
|
||||
FakeHost.CombatModeValue = CombatMode.Magic;
|
||||
Place(Player, "Me", 96, 96, creature: false);
|
||||
FakeHost.PlayerPose = (Lb | 0x1C, 96f, 96f, 0f);
|
||||
Place(X, Name, 96, 98);
|
||||
Place(Y, Name, 96, 100);
|
||||
FakeHost.Wcids[X] = Wcid;
|
||||
FakeHost.Wcids[Y] = Wcid;
|
||||
var s = new LegacyUiSettings
|
||||
{
|
||||
MonsterRange = 20, TargetSelection = 1 /* closest */, TargetLock = false,
|
||||
IsMacroRunning = true, EnableCombat = true, FightSelectedTarget = true,
|
||||
};
|
||||
var host = FakeHost.Create();
|
||||
var cache = FakeHost.MakeCache(host, Player, new[] { X, Y });
|
||||
var store = new RynthCore.Plugin.RynthAi.CreatureData.MonsterDamageStore();
|
||||
store.SetManualHp(Wcid, 5000);
|
||||
var c = new CombatManager(host, s, cache);
|
||||
c.SetPlayerId(Player);
|
||||
c.SetDamageStores(null, store);
|
||||
c.TargetClock = () => now;
|
||||
uint Pick()
|
||||
{
|
||||
c.SetScannedTargetsForTests(new[] { (X, 2.0), (Y, 4.0) }.Select(t => new CombatManager.ScannedTarget
|
||||
{
|
||||
Id = I(t.Item1), Distance = t.Item2, Angle = 0, Bearing = double.NaN, Name = Name,
|
||||
}));
|
||||
c.HandleCombatTrigger();
|
||||
if (c.activeTargetId != 0) c.EngageForTest(c.activeTargetId); // Think's BeginFight for the new target
|
||||
return unchecked((uint)c.activeTargetId);
|
||||
}
|
||||
|
||||
Check.Eq(Pick(), X, "the bot fights X (closest)");
|
||||
// A ring hurts both: the first line is the fight target's, the second the neighbour Y's.
|
||||
c.HandleChatForDamage($"You wither {Name} for 1482 points with Clouded Soul.");
|
||||
c.HandleChatForDamage($"You twist {Name} for 1222 points with Clouded Soul.");
|
||||
Check.True(cache.IsHealthEstimated(I(Y)), "Y was hit by the ring (a damage estimate)");
|
||||
|
||||
now = now.AddSeconds(6);
|
||||
Check.Eq(c.OnSelectionChanged(Y, false), "locked", "the player selects Y");
|
||||
Check.Eq(Pick(), Y, "the bot switches to Y");
|
||||
|
||||
now = now.AddMilliseconds(700);
|
||||
c.OnKillNotification($"{Name}'s last strength withers before you!"); // X died (the pet's kill)
|
||||
Check.Eq(c.activeTargetId, I(Y), "Y, never attacked since it was selected, is kept");
|
||||
Check.False(c.IsKillSuppressed(I(Y)), "and not kept off the scan as killed");
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("but it hasn't been attacked yet")), "logged: " + string.Join(" | ", FakeHost.Logs.Where(l => l.Contains("Kill"))));
|
||||
Check.Eq(Pick(), Y, "still fought");
|
||||
Check.Eq(c.ForcedTargetId, I(Y), "still the monster the player selected");
|
||||
Check.False(FakeHost.Logs.Any(l => l.Contains("fight-selected") && l.Contains("ended")), "the selection didn't end");
|
||||
|
||||
// Hit in this fight: its own kill notice ends it, as before.
|
||||
now = now.AddSeconds(1);
|
||||
c.HandleChatForDamage($"You wither {Name} for 1482 points with Incantation of Nether Bolt.");
|
||||
now = now.AddMilliseconds(500);
|
||||
c.OnKillNotification($"You reduce {Name} to a drained, twisted corpse!");
|
||||
Check.Eq(c.activeTargetId, 0, "hit since it was selected: its notice drops it");
|
||||
Check.True(c.IsKillSuppressed(I(Y)), "as killed");
|
||||
Pick();
|
||||
Check.True(FakeHost.Logs.Any(l => l.Contains("fight-selected") && l.Contains("ended: killed")), "the selection ends: killed");
|
||||
}
|
||||
finally { RynthClock.TestNow = null; }
|
||||
}
|
||||
|
||||
// ── Plugin harness ───────────────────────────────────────────────────────
|
||||
|
||||
private sealed class Bot
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ internal static class OutdoorHuntTests
|
|||
r.Add("hunt: the next monster is the shortest walk, not the nearest in a straight line (one behind a building)", ShortestWalk);
|
||||
r.Add("hunt: a higher Priority comes first, whatever the walk", PriorityFirst);
|
||||
r.Add("hunt: no way to a monster (a cliff, water): left out for a while; a walk ending close enough still counts", Unreachable);
|
||||
r.Add("hunt (11-12): a walk ending under a monster on a roof or the floor above doesn't reach it; one up a slope does", AboveTheWalk);
|
||||
r.Add("hunt: it stays within Hunt Radius of where it started (0 = anywhere)", Radius);
|
||||
r.Add("hunt: plans again when the monster moves, the walk runs out, or a while passes; not every tick", Replan);
|
||||
r.Add("hunt: nothing in range: it waits where it is (no walk back to the start); Hunt Radius defaults to anywhere", WaitsWhereItIs);
|
||||
|
|
@ -407,6 +408,31 @@ internal static class OutdoorHuntTests
|
|||
Check.False(h.IsSkipped(1, T0.AddSeconds(h.SkipSec + 1)), "and tried again after SkipSec");
|
||||
}
|
||||
|
||||
// 11-12: RynthNav finds the ground up to 64 yd under a goal, so a walk to a monster on a roof ended under it
|
||||
// as an Ok walk, and the character stood there swinging up at it.
|
||||
private static void AboveTheWalk()
|
||||
{
|
||||
var me = V(1000, 1000);
|
||||
var h = new OutdoorHunt();
|
||||
h.Start(T0, me);
|
||||
var nav = new Nav();
|
||||
var roof = new OutdoorHunt.Vec(1006, 1000, 8); // on a roof, 8 yd up
|
||||
var below = new OutdoorHunt.Vec(1009, 1000, -6); // the floor below
|
||||
var slope = new OutdoorHunt.Vec(1020, 1000, 8); // up a hillside, 8 yd up
|
||||
nav.Overrides[(1006, 1000)] = new(OutdoorHunt.PathStatus.Ok, new[] { V(1006, 1000) }, 6, 8);
|
||||
nav.Overrides[(1009, 1000)] = new(OutdoorHunt.PathStatus.Ok, new[] { V(1009, 1000) }, 9, 6);
|
||||
nav.Overrides[(1020, 1000)] = new(OutdoorHunt.PathStatus.Ok, new[] { new OutdoorHunt.Vec(1020, 1000, 7.6) }, 22, 0.4);
|
||||
var list = Sorted(new OutdoorHunt.Candidate(1, "Roof", roof, roof.DistanceTo(me), 1),
|
||||
new OutdoorHunt.Candidate(2, "Below", below, below.DistanceTo(me), 1),
|
||||
new OutdoorHunt.Candidate(3, "Hill", slope, slope.DistanceTo(me), 1));
|
||||
var d = h.Tick(T0, me, true, list, nav.Path);
|
||||
Check.Eq(d.TargetId, 3, "the one up the hillside (the walk ends level with it); not the ones above and below the walk's end");
|
||||
Check.True(h.IsSkipped(1, T0.AddSeconds(60)) && h.IsSkipped(2, T0.AddSeconds(60)), "the roof and the floor below are left out a while");
|
||||
var notes = string.Join(" | ", h.PendingNotes);
|
||||
Check.True(notes.Contains("8 yd above the walk's end"), "says it is above: " + notes);
|
||||
Check.True(notes.Contains("6 yd below the walk's end"), "says it is below: " + notes);
|
||||
}
|
||||
|
||||
private static void Radius()
|
||||
{
|
||||
var start = V(1000, 1000);
|
||||
|
|
|
|||
|
|
@ -55,9 +55,42 @@ internal static class TargetingTests
|
|||
Check.Eq(missile.Tick(), 0u, "missile, 3 yd, a wall between: nor do arrows");
|
||||
}
|
||||
|
||||
// 11-12: a test character locked golems on the floor above (d 9.0, h 6.7, dz +6.0; d 7.4, h 3.3, dz +6.6) and
|
||||
// swung under them. Melee leaves out a monster more than 3 m up or down and steeper than 0.75 from here.
|
||||
private static void MeleeOtherFloor()
|
||||
{
|
||||
Check.True(CombatManager.OutOfMeleeReachUpOrDown(9.0, 6.0), "the golem on the floor above (h 6.7, dz +6.0)");
|
||||
Check.True(CombatManager.OutOfMeleeReachUpOrDown(7.4, 6.6), "the other one (h 3.3, dz +6.6)");
|
||||
Check.True(CombatManager.OutOfMeleeReachUpOrDown(6.5, -6.0), "and on the floor below");
|
||||
Check.False(CombatManager.OutOfMeleeReachUpOrDown(2.2, 0.9), "on the same floor");
|
||||
Check.False(CombatManager.OutOfMeleeReachUpOrDown(10.0, 4.0), "up a ramp or a hillside (h 9.2, dz +4.0)");
|
||||
Check.False(CombatManager.OutOfMeleeReachUpOrDown(3.5, 2.9), "2.9 m up, close: within reach");
|
||||
|
||||
var up = new ScanPick(20);
|
||||
up.Place(A, "Mob A", north: 3, up: 6);
|
||||
up.Place(B, "Mob B", north: 8);
|
||||
FakeHost.WeaponCalls = true;
|
||||
FakeHost.CombatModeValue = CombatMode.Melee;
|
||||
Check.Eq(up.Tick(), B, "melee: the one 8 m off on this floor, not the one 3 m off on the floor above");
|
||||
|
||||
var alone = new ScanPick(20);
|
||||
alone.Place(A, "Mob A", north: 3, up: 6);
|
||||
FakeHost.WeaponCalls = true;
|
||||
FakeHost.CombatModeValue = CombatMode.Melee;
|
||||
Check.Eq(alone.Tick(), 0u, "melee: no target when the only one is on the floor above");
|
||||
Check.False(alone.C.HasNearbyMonsters, "and it doesn't hold navigation (the hunt walks up to it)");
|
||||
|
||||
var magic = new ScanPick(20);
|
||||
magic.Place(A, "Mob A", north: 3, up: 6);
|
||||
FakeHost.WeaponCalls = true;
|
||||
FakeHost.CombatModeValue = CombatMode.Magic;
|
||||
Check.Eq(magic.Tick(), A, "magic: one on a balcony in sight is still a target");
|
||||
}
|
||||
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("targeting: melee within 4 yd ignores the raycast; beyond it, or with magic or missile, it counts", MeleeThroughWalls);
|
||||
r.Add("targeting (11-12): melee leaves out a monster on the floor above or below; magic doesn't", MeleeOtherFloor);
|
||||
r.Add("targeting: each scheme picks its monster", SchemesPick);
|
||||
r.Add("targeting: unknown health counts as full; ties go to the closest, then the lower id", UnknownHealthAndTies);
|
||||
r.Add("targeting: Target Lock keeps the target when a better one of its tier appears", LockKeeps);
|
||||
|
|
@ -581,9 +614,9 @@ internal static class TargetingTests
|
|||
}
|
||||
|
||||
/// <summary>A monster <paramref name="north"/>/<paramref name="east"/> m from the player.</summary>
|
||||
public void Place(uint id, string name, double north = 0, double east = 0)
|
||||
public void Place(uint id, string name, double north = 0, double east = 0, double up = 0)
|
||||
{
|
||||
TargetingTests.Place(id, name, (float)(96 + east), (float)(96 + north));
|
||||
TargetingTests.Place(id, name, (float)(96 + east), (float)(96 + north), z: (float)up);
|
||||
if (!_ids.Contains(id)) _ids.Add(id);
|
||||
}
|
||||
|
||||
|
|
@ -664,10 +697,10 @@ internal static class TargetingTests
|
|||
}
|
||||
}
|
||||
|
||||
private static void Place(uint id, string name, float x, float y, bool creature = true)
|
||||
private static void Place(uint id, string name, float x, float y, bool creature = true, float z = 0f)
|
||||
{
|
||||
FakeHost.Names[id] = name;
|
||||
FakeHost.Positions[id] = (Lb | 0x1C, x, y, 0f);
|
||||
FakeHost.Positions[id] = (Lb | 0x1C, x, y, z);
|
||||
if (creature) FakeHost.ItemTypes[id] = 0x10;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue