RynthSuite as of 2026-09-27 (internal 1816d05): AutoVendor (UtilityBelt port), missile/magic facing and arc line of sight, nav waypoint skipping, rebuff batch and item-enchant fixes, crafting fallback, Loot Editor AutoVendor folder and command-line open, release 2026.9.27.2
This commit is contained in:
parent
a19ee1904e
commit
d55ffda4ed
33 changed files with 4364 additions and 207 deletions
|
|
@ -54,6 +54,7 @@ public enum DoubleValueKey
|
|||
DamageVariance = 22,
|
||||
CurrentPowerMod = 23,
|
||||
AccuracyMod = 24,
|
||||
MaximumVelocity = 26, // missile launcher launch speed (m/s); known once appraised
|
||||
WeaponDefense = 29,
|
||||
UseRadius = 54,
|
||||
WeaponOffense = 61,
|
||||
|
|
@ -106,17 +107,59 @@ public class WorldObject
|
|||
// Set by WorldObjectCache when it creates/updates this object
|
||||
internal WorldObjectCache? Cache { get; set; }
|
||||
|
||||
public int Values(LongValueKey key, int defaultValue)
|
||||
=> Cache?.GetIntProperty(Id, (uint)key, defaultValue) ?? defaultValue;
|
||||
/// <summary>
|
||||
/// Values that answer Values() before any live read (AutoVendor: a vendor-list item
|
||||
/// built from the engine's vendor snapshot, or an item's known name). Null = live only.
|
||||
/// </summary>
|
||||
internal ItemPropertyOverlay? Overlay { get; set; }
|
||||
|
||||
public int Values(LongValueKey key, int defaultValue) => Values((int)key, defaultValue);
|
||||
|
||||
public int Values(int key, int defaultValue)
|
||||
=> Cache?.GetIntProperty(Id, (uint)key, defaultValue) ?? defaultValue;
|
||||
{
|
||||
var o = Overlay;
|
||||
if (o != null)
|
||||
{
|
||||
if (o.Ints.TryGetValue(unchecked((uint)key), out int v)) return v;
|
||||
if (!o.LiveFallback) return defaultValue;
|
||||
}
|
||||
return Cache?.GetIntProperty(Id, (uint)key, defaultValue) ?? defaultValue;
|
||||
}
|
||||
|
||||
public string Values(StringValueKey key, string defaultValue)
|
||||
=> Cache?.GetStringProperty(Id, (uint)key, defaultValue) ?? defaultValue;
|
||||
{
|
||||
var o = Overlay;
|
||||
if (o != null)
|
||||
{
|
||||
if (o.Strings.TryGetValue((uint)key, out string? v)) return v;
|
||||
if (!o.LiveFallback) return defaultValue;
|
||||
}
|
||||
return Cache?.GetStringProperty(Id, (uint)key, defaultValue) ?? defaultValue;
|
||||
}
|
||||
|
||||
public double Values(DoubleValueKey key, double defaultValue)
|
||||
=> Cache?.GetDoubleProperty(Id, (uint)key, defaultValue) ?? defaultValue;
|
||||
{
|
||||
var o = Overlay;
|
||||
if (o != null)
|
||||
{
|
||||
if (o.Doubles.TryGetValue((uint)key, out double v)) return v;
|
||||
if (!o.LiveFallback) return defaultValue;
|
||||
}
|
||||
return Cache?.GetDoubleProperty(Id, (uint)key, defaultValue) ?? defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fixed property values for a <see cref="WorldObject"/>. With LiveFallback off, a key
|
||||
/// that isn't here reads as the caller's default instead of the client object's value
|
||||
/// (a vendor-list item carries only what the vendor snapshot holds).
|
||||
/// </summary>
|
||||
internal sealed class ItemPropertyOverlay
|
||||
{
|
||||
public Dictionary<uint, int> Ints { get; } = new();
|
||||
public Dictionary<uint, string> Strings { get; } = new();
|
||||
public Dictionary<uint, double> Doubles { get; } = new();
|
||||
public bool LiveFallback { get; init; }
|
||||
}
|
||||
|
||||
// ── SpellInfo stub ────────────────────────────────────────────────────────
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ public class BuffManager : IDisposable
|
|||
private DateTime _lastBuffStanceAttempt = DateTime.MinValue;
|
||||
private int _buffStanceConsecutiveFails = 0;
|
||||
private bool _isForceRebuffing = false;
|
||||
// Set with _isForceRebuffing when the pass is the automatic batch (one buff fell
|
||||
// under RebuffSecondsRemaining), not the Force Rebuff button. The batch only tops
|
||||
// off buffs under RebuffTopOffSecondsRemaining; Force Rebuff recasts everything.
|
||||
private bool _isAutoBatchRebuff = false;
|
||||
private int _pendingSpellId = 0;
|
||||
private Action<string>? _onCastResolved;
|
||||
|
||||
|
|
@ -475,6 +479,7 @@ public class BuffManager : IDisposable
|
|||
public void ForceFullRebuff()
|
||||
{
|
||||
_isForceRebuffing = true;
|
||||
_isAutoBatchRebuff = false;
|
||||
_forceRebuffCastFamilies.Clear();
|
||||
_buffFailCooldownUntil.Clear(); // explicit recast-all must not be blocked by stale cooldowns
|
||||
_silentNoShowCounts.Clear(); // give parked families a fresh shot on FR too
|
||||
|
|
@ -496,6 +501,7 @@ public class BuffManager : IDisposable
|
|||
public void CancelBuffing()
|
||||
{
|
||||
_isForceRebuffing = false;
|
||||
_isAutoBatchRebuff = false;
|
||||
_isRechargingMana = false;
|
||||
_isRechargingStamina = false;
|
||||
_isHealingSelf = false;
|
||||
|
|
@ -810,15 +816,17 @@ public class BuffManager : IDisposable
|
|||
|
||||
if (_isForceRebuffing)
|
||||
{
|
||||
bool wasAutoBatch = _isAutoBatchRebuff;
|
||||
_isForceRebuffing = false;
|
||||
_host.Log($"[FR] complete — cast {_forceRebuffCastFamilies.Count} spell families");
|
||||
_isAutoBatchRebuff = false;
|
||||
_host.Log($"[FR] complete — cast {_forceRebuffCastFamilies.Count} spell families{(wasAutoBatch ? " (auto batch)" : "")}");
|
||||
// Order matters: the flag must already be false (IsBuffActive
|
||||
// short-circuits on _forceRebuffCastFamilies while it is set, so
|
||||
// every family would read "active"), and the set must still be
|
||||
// populated — it is what the audit iterates.
|
||||
AuditBatchSatisfied();
|
||||
_forceRebuffCastFamilies.Clear();
|
||||
_host.WriteToChat("[RynthAi] Force Rebuff Complete.", 1);
|
||||
_host.WriteToChat(wasAutoBatch ? "[RynthAi] Rebuff complete." : "[RynthAi] Force Rebuff Complete.", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1066,6 +1074,7 @@ public class BuffManager : IDisposable
|
|||
// no-show → re-park → another auto-batch → loop. Hard-reject
|
||||
// cooldowns are short-lived (120s) so they expire on their own.
|
||||
_isForceRebuffing = true;
|
||||
_isAutoBatchRebuff = true;
|
||||
_forceRebuffCastFamilies.Clear();
|
||||
}
|
||||
|
||||
|
|
@ -1377,13 +1386,23 @@ public class BuffManager : IDisposable
|
|||
// Force Rebuff: ignore live timers entirely — only spells we've already
|
||||
// cast THIS rebuff cycle count as "active". The whole point of FR is to
|
||||
// recast every spell so all timers align to the same start time.
|
||||
// The automatic batch shares FR's bookkeeping but must NOT recast
|
||||
// everything: one buff under the threshold used to refresh every buff,
|
||||
// even ones with 30+ minutes left (2026-09-27). It tops off only buffs
|
||||
// under RebuffTopOffSecondsRemaining (never less than RebuffSecondsRemaining,
|
||||
// so the buff that started the batch is always in it) and leaves the rest
|
||||
// to their own timers.
|
||||
if (_isForceRebuffing)
|
||||
return _forceRebuffCastFamilies.Contains(targetSpell.Family);
|
||||
{
|
||||
if (_forceRebuffCastFamilies.Contains(targetSpell.Family)) return true;
|
||||
if (!_isAutoBatchRebuff) return false;
|
||||
rebufferSecOverride = Math.Max(_settings.RebuffTopOffSecondsRemaining, _settings.RebuffSecondsRemaining);
|
||||
}
|
||||
|
||||
int targetLevel = GetSpellLevel(targetSpell);
|
||||
// Recast when remaining duration drops below this many seconds.
|
||||
// User-configurable via Advanced Settings → Buffing; overridden during
|
||||
// batch-rebuff passes (CheckAndCastSelfBuffs) to 1200s (20 min).
|
||||
// batch-rebuff passes (CheckAndCastSelfBuffs) by RebuffTopOffSecondsRemaining.
|
||||
int rebufferSec = Math.Max(0, rebufferSecOverride ?? _settings.RebuffSecondsRemaining);
|
||||
|
||||
// Tier-upgrade rule (applies to both item enchantments and player buffs):
|
||||
|
|
@ -1664,10 +1683,16 @@ public class BuffManager : IDisposable
|
|||
|
||||
// Learn the real ceiling this family lands at (Incantations cap below
|
||||
// their nominal tier) so IsBuffActive stops chasing an unreachable tier.
|
||||
// Recorded for EVERY entry read, including one the merge above
|
||||
// Recorded for every timed entry read, including one the merge above
|
||||
// discarded — the ceiling is about what this character can land, not
|
||||
// about which entry currently wins the family slot.
|
||||
RecordAchievedTier(spellInfo.Family, level);
|
||||
// about which entry currently wins the family slot. NOT for permanent
|
||||
// entries: those are item-granted ("Willpower Other I" on gear), not
|
||||
// something this character cast, and learning their tier as the
|
||||
// ceiling made a permanent level-1 enchant satisfy the family forever
|
||||
// (effective target 1, never expires): after a relog with the real
|
||||
// buff gone, Lucy went 17 minutes without Willpower (2026-09-27).
|
||||
if (!isPermanent)
|
||||
RecordAchievedTier(spellInfo.Family, level);
|
||||
|
||||
if (isPermanent && _loggedPermanentFamilies.Add(spellInfo.Family))
|
||||
_host.Log($"[BuffDiag] permanent player enchant tracked: id={spellInfo.Id} '{spellInfo.Name}' (fam={spellInfo.Family}, lvl={level}) — presence-only, not persisted" +
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ public class CombatManager : IDisposable
|
|||
// a perfectly good target in ~3 ticks (~1.2s at SpellCastIntervalMs=400).
|
||||
private bool _offensiveCastThisCycle;
|
||||
private DateTime _faceStartTime = DateTime.MinValue;
|
||||
private const double FACE_TIMEOUT_MS = 1000.0; // give up waiting and fire anyway (MISSILE only)
|
||||
private const double FACE_TIMEOUT_MS = 1000.0; // give up waiting and swing anyway (non-native MELEE only)
|
||||
private const double FACE_TOLERANCE_DEG = 15.0; // heading error threshold to fire
|
||||
|
||||
// ── Magic targeted-cast settle gate (root-cause fix 2026-06-19) ──────────
|
||||
|
|
@ -168,11 +168,11 @@ public class CombatManager : IDisposable
|
|||
// turn-to-face; a turn/stop MoveToState that lands during that deferred
|
||||
// windup ORPHANS the cast (DoSpellWords/CreatePlayerSpell never runs) → the
|
||||
// gesture animates but 0 damage / "You're too busy!" forever. Self-buffs are
|
||||
// immune (untargeted → synchronous, no turn). Fix: for MAGIC, never cast
|
||||
// mid-turn — keep turning until actually within angle, then release the turn
|
||||
// motions and let the stop reach the server (settle tick) BEFORE the cast.
|
||||
// immune (untargeted → synchronous, no turn). The 2026-06-19 fix turned the
|
||||
// bot itself until within angle, then released and settled before the cast;
|
||||
// since 2026-09-27 the bot doesn't turn for magic at all (the server's own
|
||||
// Rotate does it), and this only settles after releasing a turn melee left held.
|
||||
private DateTime _faceSettledAt = DateTime.MinValue;
|
||||
private const double FACE_MAX_WAIT_MS = 2500.0; // safety: heading never converges (jittery point-blank pose) → cast anyway rather than wedge
|
||||
private const double FACE_SETTLE_MS = 140.0; // let the turn-stop reach the server (≥ one 30Hz tick) before the cast packet
|
||||
|
||||
// ── Magic cast cadence guard ────────────────────────────────────────────
|
||||
|
|
@ -665,7 +665,9 @@ public class CombatManager : IDisposable
|
|||
double maxDist = _settings.MonsterRange;
|
||||
TargetingFSM.AttackType attackType = TargetingFSM.AttackType.Linear;
|
||||
if (RaycastInitialized && _raycastSystem?.TargetingFSM != null)
|
||||
attackType = _raycastSystem.GetAttackType(CurrentCombatMode, "");
|
||||
attackType = DetermineAttackTypeForLOS();
|
||||
bool losDebug = _settings.LosDebugLog;
|
||||
if (losDebug) LogLosDebugWeapon();
|
||||
|
||||
foreach (var wo in _worldFilter.GetLandscape())
|
||||
{
|
||||
|
|
@ -721,14 +723,12 @@ public class CombatManager : IDisposable
|
|||
if (dist > (isEngaged ? Math.Max(maxDist, DisengageDistance) : maxDist)) continue;
|
||||
|
||||
bool losBlocked = false;
|
||||
if (_settings.EnableRaycasting && RaycastInitialized && _raycastSystem != null)
|
||||
if (_settings.EnableRaycasting && RaycastInitialized && _raycastSystem?.TargetingFSM != null)
|
||||
{
|
||||
RaycastCheckCount++;
|
||||
if (_raycastSystem.IsTargetBlocked(_host, (uint)wo.Id, attackType))
|
||||
{
|
||||
RaycastBlockCount++;
|
||||
losBlocked = true;
|
||||
}
|
||||
losBlocked = _raycastSystem.TargetingFSM.IsTargetBlocked(_host, (uint)wo.Id, attackType, out var losDetail);
|
||||
if (losBlocked) RaycastBlockCount++;
|
||||
if (losDebug) LogLosDebug(wo, losBlocked, losDetail);
|
||||
}
|
||||
|
||||
// Don't blacklist from scan — just exclude from this result.
|
||||
|
|
@ -1337,9 +1337,12 @@ public class CombatManager : IDisposable
|
|||
private void DropTarget(string reason)
|
||||
{
|
||||
if (activeTargetId != 0)
|
||||
_host.Log($"[RynthAi] DropTarget 0x{activeTargetId:X8}: {reason}");
|
||||
_host.Log($"[RynthAi] DropTarget 0x{activeTargetId:X8}: {reason} [{DescribeTargetPos(activeTargetId)}]");
|
||||
activeTargetId = 0;
|
||||
_lockedTargetId = 0;
|
||||
// A turn held toward the dropped target must be let go, or the character keeps
|
||||
// spinning until something else happens to release it.
|
||||
if (_facingTarget) ClearCombatTurnMotions();
|
||||
_facingTarget = false;
|
||||
_returnToPhysicalCombat = false;
|
||||
_targetLockedAt = DateTime.MinValue;
|
||||
|
|
@ -1775,6 +1778,7 @@ public class CombatManager : IDisposable
|
|||
fsm.CrossbowArcVelocity = _settings.CrossbowArcVelocity;
|
||||
fsm.AtlatlArcVelocity = _settings.AtlatlArcVelocity;
|
||||
fsm.MagicArcVelocity = _settings.MagicArcVelocity;
|
||||
fsm.MissileArcClearance = _settings.MissileArcClearance;
|
||||
}
|
||||
|
||||
// Deferred predicted kill-shot swap: a cast that armed it is confirmed
|
||||
|
|
@ -1990,39 +1994,19 @@ public class CombatManager : IDisposable
|
|||
return true;
|
||||
}
|
||||
|
||||
// MAGIC: settle-before-cast facing gate. Never cast mid-turn and
|
||||
// never let a turn-stop ride alongside the cast packet — both orphan
|
||||
// the ACE server's deferred targeted-cast windup (root cause of
|
||||
// "animates but 0 damage / too busy"). Makes combat behave like the
|
||||
// working self-buff path. Applies regardless of UseNativeAttack
|
||||
// (native attack is a physical swing; in Magic mode the bot always
|
||||
// casts, so the facing race is the same with or without it).
|
||||
if (CurrentCombatMode == CombatMode.Magic)
|
||||
// MAGIC and MISSILE: the server turns the player to the target itself,
|
||||
// as retail did — ACE Rotate(target) before a targeted cast (and again
|
||||
// after the windup if needed) and before the first missile shot and
|
||||
// between repeat shots. So the bot doesn't turn at all. A client-side
|
||||
// turn servo on top only fought that rotation: missile characters spun
|
||||
// in circles between shots (2026-09-27, Lucy, Olthoi swarm at close
|
||||
// range), and for magic the server waits while the client holds a turn
|
||||
// (PendingTurnRelease), which is where the "animates but 0 damage / too
|
||||
// busy" orphaned windups came from. Applies with or without
|
||||
// UseNativeAttack. Only a turn another mode left held is released — with one
|
||||
// settle tick before a cast, so the stop doesn't ride with the packet.
|
||||
if (CurrentCombatMode == CombatMode.Magic || CurrentCombatMode == CombatMode.Missile)
|
||||
{
|
||||
double facingError = GetFacingError(activeTargetId);
|
||||
if (facingError > FACE_TOLERANCE_DEG)
|
||||
{
|
||||
FaceTarget(activeTargetId);
|
||||
if (!_facingTarget)
|
||||
{
|
||||
_facingTarget = true;
|
||||
_faceStartTime = DateTime.Now;
|
||||
}
|
||||
// Keep turning until actually within angle. Do NOT "fire
|
||||
// anyway" while still turning (that was the bug). Only a long
|
||||
// safety timeout falls through, so a jittery point-blank pose
|
||||
// can't wedge combat forever.
|
||||
if ((DateTime.Now - _faceStartTime).TotalMilliseconds < FACE_MAX_WAIT_MS)
|
||||
{
|
||||
LastCombatSkipReason = "facing-turning"; // D4 record-only
|
||||
return true;
|
||||
}
|
||||
_host.Log($"[CombatCast] facing did not converge in {FACE_MAX_WAIT_MS:0}ms (err={facingError:0.0}°) — releasing turn + casting anyway");
|
||||
}
|
||||
|
||||
// Within angle (or safety-timed-out). If we were turning, release
|
||||
// the turn motions and give the stop ONE settle tick to reach the
|
||||
// server BEFORE the cast packet.
|
||||
if (_facingTarget)
|
||||
{
|
||||
ClearCombatTurnMotions();
|
||||
|
|
@ -2031,7 +2015,8 @@ public class CombatManager : IDisposable
|
|||
LastCombatSkipReason = "face-settle-release"; // D4 record-only
|
||||
return true; // settle tick
|
||||
}
|
||||
if ((DateTime.Now - _faceSettledAt).TotalMilliseconds < FACE_SETTLE_MS)
|
||||
if (CurrentCombatMode == CombatMode.Magic
|
||||
&& (DateTime.Now - _faceSettledAt).TotalMilliseconds < FACE_SETTLE_MS)
|
||||
{
|
||||
LastCombatSkipReason = "face-settle-wait"; // D4 record-only
|
||||
return true; // let the turn-stop settle on the server first
|
||||
|
|
@ -2282,11 +2267,20 @@ public class CombatManager : IDisposable
|
|||
double bestScore = double.MinValue;
|
||||
double heldScore = double.MinValue; // scored total for the incumbent, for the switch log
|
||||
bool incumbentSeen = false;
|
||||
double acquireRange = Math.Max(1.0, _settings.MonsterRange);
|
||||
foreach (var c in _scannedTargets)
|
||||
{
|
||||
double s = ScoreCandidate(c);
|
||||
// The incumbent keeps stickiness and commitment only inside MonsterRange. The
|
||||
// scan holds a locked target out to DisengageDistance (MonsterRange+3 by default)
|
||||
// so a lone mob at the edge doesn't flip engage/peace, not so it can out-score
|
||||
// mobs inside the range the user set. Beyond MonsterRange it competes on its
|
||||
// merits, and any reasonable in-range mob takes over. Before this a target at
|
||||
// 5-8 m kept +45 and could hold off mobs at 3-5 m (2026-09-27, Olthoi swarm:
|
||||
// Monster Range 5, one target kept for over a minute, never out of range).
|
||||
if (c.Id == _lockedTargetId)
|
||||
{
|
||||
double meritScore = s;
|
||||
s += TARGET_SWITCH_STICKINESS;
|
||||
// Commitment: once we have COMMITTED to the locked target,
|
||||
// finishing it outranks any small positional edge a fresh mob
|
||||
|
|
@ -2334,6 +2328,8 @@ public class CombatManager : IDisposable
|
|||
|
||||
if (!undamaged || (withinFlightWindow && withinUndamagedGrace))
|
||||
s += DAMAGE_COMMITMENT_BONUS;
|
||||
if (c.Distance > acquireRange)
|
||||
s = meritScore; // beyond MonsterRange: no stickiness, no commitment (see above)
|
||||
heldScore = s;
|
||||
incumbentSeen = true;
|
||||
_lockedLastScore = s;
|
||||
|
|
@ -2365,8 +2361,10 @@ public class CombatManager : IDisposable
|
|||
// up) — if this floods the log, selection is thrashing again and the two
|
||||
// scores say by how much.
|
||||
if (_lockedTargetId != 0)
|
||||
_host.Log($"[CombatTarget] switch 0x{_lockedTargetId:X8} '{_worldFilter[_lockedTargetId]?.Name}' (score={(heldScore == double.MinValue ? "gone" : heldScore.ToString("0.0"))}) " +
|
||||
$"-> 0x{bestId:X8} '{_worldFilter[bestId]?.Name}' (score={bestScore:0.0})");
|
||||
_host.Log($"[CombatTarget] switch 0x{_lockedTargetId:X8} '{_worldFilter[_lockedTargetId]?.Name}' (score={(heldScore == double.MinValue ? "gone" : heldScore.ToString("0.0"))}, {DescribeTargetPos(_lockedTargetId)}) " +
|
||||
$"-> 0x{bestId:X8} '{_worldFilter[bestId]?.Name}' (score={bestScore:0.0}, {DescribeTargetPos(bestId)})");
|
||||
else
|
||||
_host.Log($"[CombatTarget] lock 0x{bestId:X8} '{_worldFilter[bestId]?.Name}' (score={bestScore:0.0}, {DescribeTargetPos(bestId)})");
|
||||
|
||||
activeTargetId = bestId;
|
||||
_lockedTargetId = bestId;
|
||||
|
|
@ -2898,21 +2896,92 @@ public class CombatManager : IDisposable
|
|||
return lines;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attack type for the scan's LOS test. Missile mode names the weapon in hand so the
|
||||
/// bow/crossbow/atlatl arc and its velocity apply (the scan used to pass "", which made
|
||||
/// every missile LOS test a straight line). Peace mode with a missile weapon picked counts
|
||||
/// as missile, so a target acquired from peace is tested with the arc it will be shot on.
|
||||
/// Magic stays a straight line, as before.
|
||||
/// </summary>
|
||||
private TargetingFSM.AttackType DetermineAttackTypeForLOS()
|
||||
{
|
||||
if (CurrentCombatMode == CombatMode.Magic)
|
||||
if (_raycastSystem?.TargetingFSM == null) return TargetingFSM.AttackType.Linear;
|
||||
|
||||
int mode = CurrentCombatMode;
|
||||
WorldObject? weapon = _equippedWeaponId != 0 ? _worldFilter[_equippedWeaponId] : null;
|
||||
bool missileWeapon = weapon != null && weapon.ObjectClass == AcObjectClass.MissileWeapon;
|
||||
if (mode == CombatMode.NonCombat && missileWeapon)
|
||||
mode = CombatMode.Missile;
|
||||
|
||||
string weaponName = mode == CombatMode.Missile && missileWeapon ? weapon!.Name ?? "" : "";
|
||||
return _raycastSystem.GetAttackType(mode, weaponName);
|
||||
}
|
||||
|
||||
// ── LOS / target-distance diagnostics ────────────────────────────────────
|
||||
// "Far away" can't be judged from the log without positions, so target lock, switch and
|
||||
// drop lines carry the 3D distance, its horizontal and vertical parts and both cells.
|
||||
// With LosDebugLog on, the scan also logs each target's LOS verdict (line / arc, rise,
|
||||
// hit point) when it changes and at most every LosDebugRepeatMs otherwise.
|
||||
private readonly Dictionary<int, (DateTime At, bool Blocked)> _losDebugLast = new();
|
||||
private const double LosDebugRepeatMs = 5000;
|
||||
private const double LosDebugMinGapMs = 1000;
|
||||
private int _losDebugWeaponId;
|
||||
|
||||
/// <summary>"d=6.2m (h=5.9 dz=+1.8) cell=0x61450123 me=0x61450119", or why it can't be measured.</summary>
|
||||
private string DescribeTargetPos(int targetId)
|
||||
{
|
||||
uint pid = _host.GetPlayerId();
|
||||
if (pid == 0 || targetId == 0) return "pos=?";
|
||||
if (!_host.TryGetObjectPosition(pid, out uint pc, out float px, out float py, out float pz))
|
||||
return "pos=? (no player position)";
|
||||
if (!_host.TryGetObjectPosition((uint)targetId, out uint tc, out float tx, out float ty, out float tz))
|
||||
return "pos=? (no target position)";
|
||||
double dx = (((tc >> 24) & 0xFF) * 192.0 + tx) - (((pc >> 24) & 0xFF) * 192.0 + px);
|
||||
double dy = (((tc >> 16) & 0xFF) * 192.0 + ty) - (((pc >> 16) & 0xFF) * 192.0 + py);
|
||||
double dz = tz - pz;
|
||||
double h = Math.Sqrt(dx * dx + dy * dy);
|
||||
double d = Math.Sqrt(h * h + dz * dz);
|
||||
return $"d={d:0.0}m (h={h:0.0} dz={dz:+0.0;-0.0;0.0}) cell=0x{tc:X8} me=0x{pc:X8}";
|
||||
}
|
||||
|
||||
private void LogLosDebug(WorldObject wo, bool blocked, in TargetingFSM.LosDetail det)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
if (_losDebugLast.TryGetValue(wo.Id, out var last))
|
||||
{
|
||||
// Get rule from current target name if available
|
||||
var targetObj = _worldFilter[activeTargetId];
|
||||
var rule = GetRuleForTarget(targetObj);
|
||||
if (rule != null && rule.UseArc) return TargetingFSM.AttackType.MagicArc;
|
||||
return TargetingFSM.AttackType.Linear;
|
||||
double ms = (now - last.At).TotalMilliseconds;
|
||||
bool changed = last.Blocked != blocked;
|
||||
if (ms < LosDebugMinGapMs || (!changed && ms < LosDebugRepeatMs)) return;
|
||||
}
|
||||
if (_losDebugLast.Count > 256) _losDebugLast.Clear();
|
||||
_losDebugLast[wo.Id] = (now, blocked);
|
||||
|
||||
if (_raycastSystem?.TargetingFSM != null)
|
||||
return _raycastSystem.GetAttackType(CurrentCombatMode, "");
|
||||
string verdict;
|
||||
if (!det.Checked) verdict = "clear (not tested: no geometry near the path)";
|
||||
else if (det.LineBlocked) verdict = "BLOCKED line";
|
||||
else if (det.ArcChecked && det.Arc.OutOfReach) verdict = "BLOCKED arc: out of reach at this velocity";
|
||||
else if (det.ArcChecked && det.Arc.Blocked) verdict = $"BLOCKED arc: hit {det.Arc.HitAlong:0.0}m out, {det.Arc.HitZ:+0.0;-0.0;0.0}m vs launch";
|
||||
else verdict = "clear";
|
||||
|
||||
return TargetingFSM.AttackType.Linear;
|
||||
string arcInfo = det.Velocity > 0
|
||||
? $" v={det.Velocity:0.0} rise={det.Arc.Sag:0.00} apex={det.Arc.Apex:0.00} clr={_settings.MissileArcClearance:0.0}{(det.ArcChecked ? "" : " (flat: line only)")}"
|
||||
: "";
|
||||
_host.Log($"[LOS] 0x{(uint)wo.Id:X8} '{wo.Name}' {verdict} | {det.Type}{(det.Dungeon ? " dungeon" : "")}{arcInfo} | {DescribeTargetPos(wo.Id)}");
|
||||
}
|
||||
|
||||
/// <summary>LOS debug: once per missile weapon, what the client knows of its launch speed.</summary>
|
||||
private void LogLosDebugWeapon()
|
||||
{
|
||||
int wid = _equippedWeaponId;
|
||||
if (wid == 0 || wid == _losDebugWeaponId) return;
|
||||
var weapon = _worldFilter[wid];
|
||||
if (weapon == null || weapon.ObjectClass != AcObjectClass.MissileWeapon) return;
|
||||
_losDebugWeaponId = wid;
|
||||
double maxVel = _worldFilter.GetDoubleProperty(wid, (uint)DoubleValueKey.MaximumVelocity, 0);
|
||||
var type = DetermineAttackTypeForLOS();
|
||||
float setting = _raycastSystem?.TargetingFSM?.VelocityFor(type) ?? 0f;
|
||||
_host.Log($"[LOS] missile weapon 0x{(uint)wid:X8} '{weapon.Name}': MaximumVelocity={(maxVel > 0 ? maxVel.ToString("0.0") : "unknown (not appraised)")}, " +
|
||||
$"LOS uses {type} v={setting:0.0}");
|
||||
}
|
||||
|
||||
private void FaceTarget(int targetId)
|
||||
|
|
@ -2961,6 +3030,15 @@ public class CombatManager : IDisposable
|
|||
_host.SetMotion(MotionTurnLeft, false);
|
||||
}
|
||||
|
||||
/// <summary>Let go of a turn the facing servo is holding. Called when combat stops
|
||||
/// ticking (macro off), which would otherwise leave the turn held for good.</summary>
|
||||
public void ReleaseHeldTurn()
|
||||
{
|
||||
if (!_facingTarget) return;
|
||||
_facingTarget = false;
|
||||
ClearCombatTurnMotions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True while a previously-issued combat cast is still resolving on the ACE
|
||||
/// server. Serializes magic casts so the next cast's turn/stop motion can't
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ public class MissileCraftingManager
|
|||
private const int APPLY_RETRY_MS = 2000;
|
||||
private const int CRAFT_TIMEOUT_MS = 15000;
|
||||
private const int EQUIP_DELAY_MS = 500;
|
||||
private const int ERROR_BACKOFF_MS = 60000;
|
||||
|
||||
private int _headBundleId = 0;
|
||||
private int _shaftBundleId = 0;
|
||||
|
|
@ -69,15 +70,33 @@ public class MissileCraftingManager
|
|||
|
||||
public void ProcessCrafting()
|
||||
{
|
||||
if (!_settings.EnableMissileCrafting) return;
|
||||
// While State isn't Idle the plugin holds combat, nav and looting, so turning
|
||||
// crafting off mid-craft must let go too.
|
||||
if (!_settings.EnableMissileCrafting)
|
||||
{
|
||||
if (State != CraftState.Idle) Reset("Missile crafting turned off");
|
||||
return;
|
||||
}
|
||||
if (IsBusy) return;
|
||||
|
||||
switch (State)
|
||||
// An exception here used to leave State where it was, and the bot stood still
|
||||
// forever with nothing in chat: say what broke, let go, and try again later.
|
||||
try
|
||||
{
|
||||
case CraftState.Idle: ProcessIdle(); break;
|
||||
case CraftState.Evaluating: ProcessEvaluating(); break;
|
||||
case CraftState.Combining: ProcessCombining(); break;
|
||||
case CraftState.EquippingAmmo: ProcessEquippingAmmo(); break;
|
||||
switch (State)
|
||||
{
|
||||
case CraftState.Idle: ProcessIdle(); break;
|
||||
case CraftState.Evaluating: ProcessEvaluating(); break;
|
||||
case CraftState.Combining: ProcessCombining(); break;
|
||||
case CraftState.EquippingAmmo: ProcessEquippingAmmo(); break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string reason = $"Stopped by an error ({ex.GetType().Name}: {ex.Message}); trying again in a minute";
|
||||
if (State == CraftState.Idle) ChatLog(reason); // Reset only speaks for a craft in progress
|
||||
Reset(reason);
|
||||
_lastAmmoCheck = DateTime.Now.AddMilliseconds(ERROR_BACKOFF_MS - AMMO_CHECK_INTERVAL_MS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -169,9 +188,22 @@ public class MissileCraftingManager
|
|||
if (bestCraftable != null)
|
||||
{ StartCrafting(bestCraftable, inv); return; }
|
||||
|
||||
// No ammo at all and only bundles the skill check calls risky: a bow with nothing
|
||||
// to shoot can't fight, so a combine that may fail beats standing there.
|
||||
if (tooHard != null)
|
||||
Reset($"No ammo, and Fletching {fletching?.Buffed} is too low to make {tooHard.OutputName} reliably " +
|
||||
$"(difficulty {tooHard.Difficulty}; a failed combine destroys both bundles)");
|
||||
{
|
||||
int skill = fletching?.Buffed ?? 250;
|
||||
ChatLog($"No ammo: making {tooHard.OutputName} anyway, about " +
|
||||
$"{AmmoRecipes.SuccessChance(skill, tooHard.Difficulty):P0} with Fletching {skill} " +
|
||||
"(a failed combine destroys both bundles)");
|
||||
StartCrafting(tooHard, inv);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fletching != null && fletching.Training < 2
|
||||
&& AmmoRecipes.BestCraftable(inv.Select(i => i.Name), category, 0, out var carried) == null
|
||||
&& carried != null)
|
||||
Reset($"No ammo, and Fletching is untrained, so the bundles for {carried.OutputName} can't be combined");
|
||||
else
|
||||
Reset("No ammo and no bundles available");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -903,7 +903,11 @@ public class WorldObjectCache
|
|||
float dx = gx1 - gx2;
|
||||
float dy = gy1 - gy2;
|
||||
float dz = z1 - z2;
|
||||
return Math.Sqrt(dx * dx + dy * dy + dz * dz);
|
||||
double d = Math.Sqrt(dx * dx + dy * dy + dz * dz);
|
||||
// A garbage position read (NaN/∞) must read as out of range. NaN fails every
|
||||
// "dist > limit" test, so it passed both the scan's range gate and Think's
|
||||
// disengage drop, and a target could be kept at any real distance.
|
||||
return double.IsFinite(d) ? d : double.MaxValue;
|
||||
}
|
||||
|
||||
/// <summary>Enumerate objects in player's inventory (no physics position).</summary>
|
||||
|
|
@ -1547,7 +1551,7 @@ public class WorldObjectCache
|
|||
|
||||
// ── Type-flag item classification ─────────────────────────────────────
|
||||
|
||||
private static AcObjectClass ClassifyByItemType(uint typeFlags)
|
||||
internal static AcObjectClass ClassifyByItemType(uint typeFlags)
|
||||
{
|
||||
// Most specific / unambiguous types first
|
||||
if ((typeFlags & ItemTypePromissoryNote) != 0) return AcObjectClass.TradeNote;
|
||||
|
|
|
|||
Loading…
Reference in a new issue