using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using RynthCore.Plugin.RynthAi.LegacyUi; using RynthCore.Plugin.RynthAi.Loot; using RynthCore.Plugin.RynthAi.Meta; using RynthCore.Plugin.RynthAi.Raycasting; using RynthCore.Loot.VTank; using RynthCore.Plugin.Shared; namespace RynthCore.Plugin.RynthAi; /// /// All /ra chat commands — partial class split from RynthAiPlugin. /// public sealed partial class RynthAiPlugin { private CommandReply? _reply; /// What chat commands say back: typed ones always answer, a meta's are quiet when they work (CommandReply.cs). internal CommandReply Reply => _reply ??= new CommandReply( (text, color) => Host.WriteToChat(text, color), line => Host.Log(line), () => _metaCommandDepth > 0 || _metaManager?.IsExecutingAction == true); /// A chat line (lists, status, help, and lines that already answered a command): shown either way. private void ChatLine(string text) => Reply.Info(text); /// A command worked: what changed and the value now (quiet, logged, when a meta sent it). private void ReplyOk(string text) => Reply.Ok(text); /// A command didn't work: why, and the usage (a meta's repeats once a minute). private void ReplyFail(string text) => Reply.Fail(text); /// An action that reports whether it went out: or . private void ReplyIf(bool ok, string okText, string failText) { if (ok) ReplyOk(okText); else ReplyFail(failText); } /// /// A line from code that returns one string for either outcome (the dashboard's nav, meta and /// settings-profile loads and saves, the Items list fill and clean): a failure by its wording, /// else it worked. /// private void ReplyResult(string text) { if (ResultFailed(text)) ReplyFail(text); else ReplyOk(text); } private static readonly Regex ResultFailedRx = new( @"^(\[RynthAi\] )?(Can't|Couldn't|No |Not logged in|Nav NOT saved|Nav save failed|Your inventory|Settings not ready|Save failed|Dashboard not ready)" + @"|' can't be used| not loaded: | already exists\.", RegexOptions.CultureInvariant); /// True when a one-string result (see ) says it didn't work. internal static bool ResultFailed(string text) => ResultFailedRx.IsMatch(text); /// /ra items clean and the engine Items panel's Remove Missing button (RynthPluginCleanItems). internal void CleanMissingItems() => ReplyResult(_dashboard?.CleanMissingItems(_objectCache, _playerId) ?? "[RynthAi] Settings not ready."); private void HandleHelpCommand() { ChatLine("[RynthAi] === Commands ==="); ChatLine("[RynthAi] /ra fellow — fellowship diagnostics and queries"); ChatLine("[RynthAi] /ra help — show this list"); ChatLine("[RynthAi] /ra find [words] — Find a Feature: search every RynthSuite feature, where it is and its command"); ChatLine("[RynthAi] /ra acmaps [folder |scan|announce on|off] — ACMAPS Maps: your own ACMAPS map of this dungeon"); ChatLine("[RynthAi] /ra version — RynthAi version and build date, and the engine it runs on"); ChatLine("[RynthAi] /ra server - which server RynthCore says this is, its overrides, and the server plugin's settings"); ChatLine("[RynthAi] /ra power <0-100|auto> — set attack power (auto = recklessness-aware)"); ChatLine("[RynthAi] /ra dfheight [on|off|status|window] — Dirty Fighting rotation: attack heights by the effects on the target"); ChatLine("[RynthAi] /ra meleewalls [on|off] — Melee through walls: melee reaches a monster within 4 m behind a wall (not a building's)"); ChatLine("[RynthAi] /ra debuffall [on|off] — Debuff every monster in range before attacking (toggle)"); ChatLine("[RynthAi] /ra cast — cast spell on current target"); ChatLine("[RynthAi] /ra buffs — show active buff timers"); ChatLine("[RynthAi] /ra buffitems [list|allow|block|add|addselected|remove|repeat|open] — the buff items RynthAi may use"); ChatLine("[RynthAi] /ra scan — show nearby monsters"); ChatLine("[RynthAi] /ra cache — show object cache summary"); ChatLine("[RynthAi] /ra cache2 — show raw object cache IDs"); ChatLine("[RynthAi] /ra attackable — check if target is attackable"); ChatLine("[RynthAi] /ra wielded — show wielded items"); ChatLine("[RynthAi] /ra dumpprops [0xId] — every property of the selection (else yourself)"); ChatLine("[RynthAi] /ra iteminfo [name] — the selected (or named) item's details, Mag-Tools style"); ChatLine("[RynthAi] /ra mexec — evaluate meta expression"); ChatLine("[RynthAi] /ra listvars — show session variables"); ChatLine("[RynthAi] /ra listpvars — show persistent variables"); ChatLine("[RynthAi] /ra listgvars — show global variables"); ChatLine("[RynthAi] /ra give [count] to — give exact-named item(s) to player"); ChatLine("[RynthAi] /ra givep [count] to — partial item name match"); ChatLine("[RynthAi] /ra givexp [count] to — partial player name match"); ChatLine("[RynthAi] /ra givepp [count] to — partial item and player"); ChatLine("[RynthAi] /ra giver [count] to — regex item name match"); ChatLine("[RynthAi] /ra givea[p|xp|pp|r] to — give ALL matching stacks ('… stop' cancels the queue)"); ChatLine("[RynthAi] /ra gap to — alias for giveapp (give all, partial item + partial player)"); ChatLine("[RynthAi] /ra ig to — give items matching loot profile"); ChatLine("[RynthAi] /ra igp to — ig with partial player name"); ChatLine("[RynthAi] /ra use[i|l][p|pi|lp] [on ] — use item (i=inv, l=land, p=partial)"); ChatLine("[RynthAi] /ra raycast — raycast system status"); ChatLine("[RynthAi] /ra lostest [mode] — LoS test (mode: linear|bow|crossbow|atlatl|magic)"); ChatLine("[RynthAi] /ra losline [on|off] — Show Line of Sight: a line to the combat target, green = clear, red = blocked (toggle)"); ChatLine("[RynthAi] /ra landtest — terrain heightmap info for player's landblock"); ChatLine("[RynthAi] /ra rayland — landscape raycast test (down + 4 cardinals)"); ChatLine("[RynthAi] /ra buildinfo — nearby geometry info"); ChatLine("[RynthAi] /ra navdebug — show nav coordinate/debug info"); ChatLine("[RynthAi] /ra addnavpt — append a waypoint at current location to loaded nav"); ChatLine("[RynthAi] /ra nav save [name] — save the route; a name saves it as .nav"); ChatLine("[RynthAi] /ra nav load — load a nav from NavProfiles (none by that name: a new empty one)"); ChatLine("[RynthAi] /ra nav list — list the navs in NavProfiles"); ChatLine("[RynthAi] /ra nav restart — run the loaded route again from its first point (a stop/start keeps its place; a finished Once route stays done)"); ChatLine("[RynthAi] /ra meta load — load a meta from MetaFiles (none by that name: a new blank one)"); ChatLine("[RynthAi] /ra meta new — create a blank meta and load it"); ChatLine("[RynthAi] /ra meta list — list the metas in MetaFiles"); ChatLine("[RynthAi] /ra meta repair — fill the loaded .af's CallState rules that call no state from the .met of the same name"); ChatLine("[RynthAi] /ra lua run — run a RynthLua script (same as /lua run; also stop, list, exec )"); ChatLine("[RynthAi] /ra items fill — add weapons, healing kits, lockpicks and pet essences from your pack"); ChatLine("[RynthAi] /ra aetheria [status|unbox|on|off] — unbox Coalesced Aetheria with an Aetheria Mana Stone (Unbox Aetheria When Idle)"); ChatLine("[RynthAi] /ra autoconfirm [status|on|off|<50-100>] — Yes to the craft-chance prompt at that % or better (Mini Remote > Crafting)"); ChatLine("[RynthAi] /ra kits [status|make [N]|stop|floor <0-100>|show] — make Plentiful Healing Kits from their ingredients, macro off (Mini Remote > Crafting > Kits)"); ChatLine("[RynthAi] /ra kits auto [status|on|off|below N|upto M] — Make kits when low: with the macro on and nothing around, make kits when fewer than N are carried"); ChatLine("[RynthAi] /ra ammo [status|make|stop|show] — arrows, quarrels or darts carried for the launcher in hand; make up to M now, at a safe moment (Mini Remote > Crafting > Ammo)"); ChatLine("[RynthAi] /ra ammo auto [status|on|off|below N|upto M] — Make ammo when low: with the macro on and nothing around, make ammo between fights when fewer than N are carried"); ChatLine("[RynthAi] /ra petelement [status|any|fire|cold|acid|lightning|nether|slash|pierce|bludgeon] — the element combat pets are summoned for (Mini Remote > Pets)"); ChatLine("[RynthAi] /ra offhand [auto|shield|weapon|none] [rule] — the off hand (shield / dual wield), global or for a Monsters rule; dual on|off"); ChatLine("[RynthAi] /ra dunnav — navigate to NS/EW coords through dungeon (no nav file needed)"); ChatLine("[RynthAi] /ra dunnav-to — walk to an object in this dungeon, any floor (a monster, say)"); ChatLine("[RynthAi] /ra dunnav-patrol — circular hunt patrol through the whole dungeon (no nav file needed)"); ChatLine("[RynthAi] /ra dunnav-explore [stop|status|resume|done] — walk through every room of this dungeon once, then stop (fights, loots, buffs as set)"); ChatLine("[RynthAi] /ra dunnav-explore lever [door ] [at ] [plate] — pull a lever (or step on a plate) for a shut door, then carry on"); ChatLine("[RynthAi] /ra dunroute to exit|far|portal | |room [overwrite] — save a Once nav from here to there in this dungeon"); ChatLine("[RynthAi] /ra dunpatrol-save [overwrite] — save the patrol dunnav-patrol would walk from here as a circular nav"); ChatLine("[RynthAi] /ra dunroute info | where — describe a saved nav (points, length, cells, this dungeon's?) | where you are, the portals known"); ChatLine("[RynthAi] /ra hazard add|del|list|near — mark current cell as lava/acid so patrol avoids it"); ChatLine("[RynthAi] /ra jump[swzxc] [heading] [holdtime] — jump with optional face/direction (s=run w=fwd x=back z=strafeL c=strafeR)"); ChatLine("[RynthAi] /ra corpseinfo — show corpse range/open diagnostics"); ChatLine("[RynthAi] /ra pace — what the server is still answering (one action at a time)"); ChatLine("[RynthAi] /ra owncorpse [go|stop] — where your corpse is; travel back to it, or stop"); ChatLine("[RynthAi] /ra corpsecheck — explain whether a corpse would be looted"); ChatLine("[RynthAi] /ra corpseopen — force the nearest corpse open flow"); ChatLine("[RynthAi] /ra fellowinfo — show fellowship tracker state"); ChatLine("[RynthAi] /ra lootparse — inspect the selected loot profile"); ChatLine("[RynthAi] /ra lootcheckinv — test the loot profile against inventory"); ChatLine("[RynthAi] /ra lootcheck — classify selected item (on|off = auto on click)"); ChatLine("[RynthAi] /ra lootname add|remove|list|radius|clear — loot anything in the world with that name while botting (a chest is opened, an item picked up; *part* matches part of a name)"); ChatLine("[RynthAi] /ra chests — Loot Nearby Chests: on or off, what it is doing, and the chests it is leaving alone and why"); ChatLine("[RynthAi] /ra loot why — which loot rule takes the selected item, and why the rules above it didn't"); ChatLine("[RynthAi] /ra loot mode [profile|rares] — loot by the loot profile, or rares and needed mana stones only"); ChatLine("[RynthAi] /ra loot today — Keep # per day rules: what this character picked up in each one's window (clear |all)"); ChatLine("[RynthAi] /ra loot add [keep|keep N|salvage|sell|read] [name|like] [preview] — add a loot rule for the selected item"); ChatLine("[RynthAi] /ra dumpinv — dump all inventory items (cache + direct)"); ChatLine("[RynthAi] /ra combat — dump combat state machine snapshot"); ChatLine("[RynthAi] /ra mstats [monster] — its evades, resists, hits, spells and kills this session (list | reset | show | hide)"); ChatLine("[RynthAi] /ra timed [server|all] list | add | remove|on|off|run | show — commands sent every N seconds (window: the RynthAi options menu > Timed commands)"); ChatLine("[RynthAi] /ra buttons [server|all] list | add