diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs
index fa21c11..a641dda 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs
@@ -2466,17 +2466,21 @@ public class CombatManager : IDisposable
if (targetWcid != 0 && _damageStore != null)
{
uint eff = _damageStore.GetEffectiveWeapon(targetWcid);
- if (eff != 0) { targetWeaponId = (int)eff; weaponSource = "DamageTab"; }
+ if (eff != 0 && IsUsableCombatWeapon((int)eff)) { targetWeaponId = (int)eff; weaponSource = "DamageTab"; }
}
if (targetWeaponId == 0)
{
// No Damage-tab choice yet → element/wand auto (element from rule.DamageType or weakness).
- var bestWeapon = _settings.ItemRules.FirstOrDefault(i => i.Element.Equals(desired, StringComparison.OrdinalIgnoreCase))
- ?? _settings.ItemRules.FirstOrDefault();
+ // Casters are skipped when the character has no War/Void Magic: a wand listed
+ // above the bow for the same element put a missile character in Magic mode,
+ // casting war spells the server refused ("You don't have all the components")
+ // while combat held the action lock and the route never ran.
+ var bestWeapon = _settings.ItemRules.FirstOrDefault(i => i.Element.Equals(desired, StringComparison.OrdinalIgnoreCase) && IsUsableCombatWeapon(i.Id))
+ ?? _settings.ItemRules.FirstOrDefault(i => IsUsableCombatWeapon(i.Id));
if (bestWeapon != null) { targetWeaponId = bestWeapon.Id; weaponSource = "ItemRules"; }
}
- if (targetWeaponId == 0)
+ if (targetWeaponId == 0 && CanAttackWithMagic)
{
targetWeaponId = FindWandInItems();
if (targetWeaponId != 0) weaponSource = "FindWandInItems";
@@ -3415,6 +3419,23 @@ public class CombatManager : IDisposable
private static bool IsWandObject(WorldObject wo) =>
wo.ObjectClass == AcObjectClass.WandStaffOrb || IsWandName(wo.Name);
+ /// War or Void Magic trained — the character can attack with a caster.
+ /// Skills not read yet count as trained, like the other skill gates here.
+ private bool CanAttackWithMagic =>
+ _charSkills == null
+ || _charSkills[AcSkillType.WarMagic].Training >= 2
+ || _charSkills[AcSkillType.VoidMagic].Training >= 2;
+
+ /// A weapon combat may fight with: anything but a caster when the character
+ /// has no attack magic. An id missing from the world cache stays a candidate — the
+ /// caller already handles that. Debuff casting picks its wand separately.
+ private bool IsUsableCombatWeapon(int id)
+ {
+ if (CanAttackWithMagic) return true;
+ var wo = _worldFilter[id];
+ return wo == null || !IsWandObject(wo);
+ }
+
private static bool IsWandName(string name)
{
if (string.IsNullOrEmpty(name)) return false;
@@ -3564,6 +3585,7 @@ public class CombatManager : IDisposable
bool useVoid = element.Equals("Nether", StringComparison.OrdinalIgnoreCase);
bool warTrained = _charSkills == null || _charSkills[AcSkillType.WarMagic].Training >= 2;
bool voidTrained = _charSkills == null || _charSkills[AcSkillType.VoidMagic].Training >= 2;
+ if (!warTrained && !voidTrained) return 0; // no attack magic — used to fall through to War anyway
if (useVoid && !voidTrained && warTrained) useVoid = false;
if (!useVoid && !warTrained && voidTrained) useVoid = true;
diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs
index 8c67ddc..c9e55c7 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs
@@ -1890,6 +1890,20 @@ public sealed partial class RynthAiPlugin
: string.Equals(wo.Name, name, StringComparison.OrdinalIgnoreCase))
return wo;
}
+
+ // The live walk above can miss carried items: off AC's main thread it only
+ // knows names from the engine's name snapshot, and an item missing from it
+ // drops out of the walk. Fall back to every object the cache knows and ask
+ // the client who holds it — "/ub usei X" said "Not found" for an item that
+ // "/ub use X" found, because the cache had it filed under the landscape.
+ foreach (var wo in _objectCache.AllKnownObjects())
+ {
+ if ((partial
+ ? wo.Name.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0
+ : string.Equals(wo.Name, name, StringComparison.OrdinalIgnoreCase))
+ && IsCarriedByPlayer(wo.Id))
+ return wo;
+ }
}
if (land)
@@ -1918,6 +1932,22 @@ public sealed partial class RynthAiPlugin
return null;
}
+ /// True when the client says the player holds this object: worn or
+ /// wielded, in the main pack, or in a side pack (item → pack → player).
+ private bool IsCarriedByPlayer(int objectId)
+ {
+ if (_playerId == 0 || !Host.HasGetObjectOwnershipInfo) return false;
+ uint id = unchecked((uint)objectId);
+ for (int depth = 0; depth < 3; depth++)
+ {
+ if (!Host.TryGetObjectOwnershipInfo(id, out uint container, out uint wielder, out _)) return false;
+ if (wielder == _playerId || container == _playerId) return true;
+ if (container == 0) return false;
+ id = container;
+ }
+ return false;
+ }
+
private void HandleUseCommand(string[] parts, bool inv, bool land, bool partial)
{
if (parts.Length < 3)