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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue