diff --git a/Changelog/2026-10-11-character-and-server-menus.md b/Changelog/2026-10-11-character-and-server-menus.md new file mode 100644 index 0000000..44c9870 --- /dev/null +++ b/Changelog/2026-10-11-character-and-server-menus.md @@ -0,0 +1,64 @@ +# RynthAi: Mini Remote right-click menu with Character and server sections; Spells added + +Pairs with the matching RynthCore commit on `sk`, which sends the server sections. + +## What changed + +- **Right-clicking the Mini Remote** (its Remote tab, in the floating window, RynthCore's Mini + Remote window or the dashboard drawer) now opens a menu in two halves: + - **Character** (top): windows every server has. + - **Spells**: the spell catalog and buff profile editor, the same window as `/ra spells`. + - **Skills**, **Inventory** and **Item Count**: RynthCore panels. They are listed when + RynthCore can run `/rc` commands. + - **Inventory HUDs setup**. + - **Server section** (bottom): the windows of the server plugins installed for the world + you're on. + - RynthCore decides the list: which server you're on, which plugins are installed and what + each one adds. It sends the list to RynthAi (the `"servermenu"` remote command, parsed by + `Huds/ServerMenuModel.cs`). + - On Infinite Leaftide it lists: + - the Mini Remote's Character, Quests, Pets, Banking, Gear and Games tabs (each greyed out + until the server reports that feature on); + - Guardian (RynthAi); + - Bounties (RynthILT, only when installed); + - Progression. + - A server's section shows only while you're on that server or it is forced, and only when + one of its plugins is installed. A new server or server plugin only needs registering in + RynthCore; this menu doesn't change. + - Forcing: when no installed server plugin matches the world, the section offers + "Treat this world as ". + - For Infinite Leaftide this turns on RynthCore's session override (`/rc ilt on`) and this + character's "Treat this world as ILT". + - With that per-character override on, the Infinite Leaftide section shows even when + RynthCore doesn't detect ILT. It is labelled "(forced)". + - With an older RynthCore, or its ImGui layer off, no list arrives. The menu then falls back + to RynthAi's own Infinite Leaftide entries. + - The server-features status line, the "Treat this world as ILT" checkbox and "Refresh server + features" moved from the Options menu to the Infinite Leaftide section. +- **The Options button** now holds only the Mini Remote's settings: sections, layout, slot size, + lock and hide, and Inventory HUDs setup. +- **Fix:** the Options button didn't open its menu while the tab bar was showing. The button sits + inside the Remote tab, whose ID ImGui adds to the popup's. The popup now opens at window level. + +## Files + +- `Huds/ServerMenuModel.cs`: new. It parses the `"servermenu"` payload and recognizes + `tab:` items. +- `Huds/MiniRemoteHud.cs`: + - the right-click menu (`RenderMenu`, `RenderCharacterMenu`, `RenderServerMenu`, + `RenderLocalIltMenu`, `RenderIltStatus`); + - the Options popup is now opened from a flag (`_openOptions`). +- `Huds/HudController.cs`: `RunEngineCommand`, which runs a `/rc` command on the pump thread. +- `RynthAiPlugin.cs`: the `servermenu` remote command, handled before settings exist. +- `Tools/RynthCore.RynthAiHostTests/Tests/ServerMenuTests.cs`: new (payload parsing, malformed + lines, tab features). + +## Testing + +- Host tests: 616 of 617 pass. The one failure is the known map-bake test, which needs the real + dat files. The three new server menu tests pass. +- In game: right-click the Mini Remote on and off an ILT world. Check that: + - the Character half shows Spells, Skills, Inventory and Item Count; + - the Infinite Leaftide half appears only on ILT, or when forced; + - the tab items switch tabs; + - Guardian and Bounties open their panels. diff --git a/Changelog/2026-10-11-charms-tab-banking.md b/Changelog/2026-10-11-charms-tab-banking.md new file mode 100644 index 0000000..8bbb6dd --- /dev/null +++ b/Changelog/2026-10-11-charms-tab-banking.md @@ -0,0 +1,81 @@ +# Mini Remote: a Charms tab, and Banking brought up to date with ACECustom's /bank + +Pairs with the matching RynthCore commit on `sk`. + +## Charms tab (ILT) + +- **New Mini Remote tab, Charms.** It sits after Gear and replaces both the engine's Settings > + Charms Tracking page and the charm toggles that were on the Gear tab. +- **Summary line:** how many charms are acquired and how many are active, with a Refresh button. +- **The table has one row per ACECustom registry charm**, with these columns: + - Charm (hover for its effect); + - Acquired: Carried, Stored (carried before, remembered per character) or No; + - Status: ON, OFF, or ? while its appraisal is pending; + - Tier; + - Server: Enabled, Disabled, or - when not reported; + - a Toggle button that uses the carried copy. When several copies are carried, it uses the one + that's ON. +- **Guardian Hand** rows follow, each with its own Toggle, plus a "Guardian Hand matching" note. +- The tab rescans every 3 s while the Mini Remote window is open. Toggles are refused while an + item action is already waiting. +- **Gear tab:** the charm strip is gone. Dispel / Surging Strength now opens by default, and a note + says where the charms went. +- **Where to open it:** + - the Mini Remote tab bar; + - the local ILT menu; + - `/ra hub open charms` (`charm` also works); + - the engine's ILT server menu (the matching engine). +- `GetCharmsJson` stays exported for older engines, which still have the Settings page. + +## Banking (ILT), per ACECustom upstream `/bank` (2026-10-11) + +- **Prestige Coins** balance row, read from `/bank`. The Mini Remote's bank strip shows "PC:" when + you have some, and the copy line includes them. +- **Deposit:** pick what to deposit and press Deposit. The choices are Everything, Pyreals, + Pyreal peas, Luminance, Luminance tokens (`/b lum`), Legendary keys, Mythical keys, + Enlightened coins, Weakly enlightened coins, Prestige coins and Trade notes. +- **Withdraw:** pick a kind and type an amount. The kinds are Pyreals, Luminance, Legendary keys, + Mythical keys, Enlightened coins, Weakly enlightened coins, Prestige coins and Trade notes. + - Trade notes take a denomination (100 to 250,000) and a count of up to 50,000. The panel shows + the total in pyreals. + - Bad input is refused before anything is sent. +- The server's reply lines (Deposited, Withdrew, refusals) show under the buttons. The balances + refresh 1.5 s after each action. +- **Throttles:** + - Deposits, withdrawals and transfers share the server's 5 s bank-action spacing. + - Plain balance refreshes are spaced on their own, so they no longer hold up an action. +- **Session rates:** money moved between the bank and your pack is no longer counted as income. + While a deposit, withdrawal or transfer is under way (about 12 s, extended by each Deposited or + Withdrew line), bank and pack changes are not added to the income figures. + +## Files + +- `IltHub/IltCharms.cs` (new): the Charms tab. +- `IltHub/IltCharmTracker.cs`: `CharmState.ToggleId`, the copy to use. +- `IltHub/IltGear.cs`: charm strip removed. +- `IltHub/IltSections.cs`, `IltHubController.cs`, `IltHubUi.cs`, `HudState.cs`: the tab is wired in. +- `IltHub/IltBankCommands.cs` (new): deposit and withdraw command building, and reply recognition. + It has no dependencies, so it can be tested on its own. +- `IltHub/IltBanking.cs`, `IltHubState.cs`: Prestige Coins, the deposit and withdraw UI, and the + throttles. +- `IltHub/IltSessionRates.cs`: ignores money moves. +- `Huds/MiniRemoteHud.cs`: the "PC:" cell. + +## Tests + +- `Tests/BankCommandTests.cs`, 4 new tests: + - deposit commands; + - withdraw commands, including trade notes; + - withdraw input refusals; + - reply-line recognition. +- `Tests/InventoryAttributeFilterTests.cs`, 5 new tests of the engine's inventory filter (the + engine file is linked into the test project): + - each rule kind; + - items not yet identified; + - match all vs match any; + - value conversions and names; + - the saved settings line. + +Result: 636 of 637 pass. The one failure is the known map-bake test, which needs local dats. + +Not yet tested in game. diff --git a/Changelog/2026-10-11-fix-loot-merge-pacing.md b/Changelog/2026-10-11-fix-loot-merge-pacing.md new file mode 100644 index 0000000..65a4f09 --- /dev/null +++ b/Changelog/2026-10-11-fix-loot-merge-pacing.md @@ -0,0 +1,40 @@ +# RynthAi: corpses with several keeps are looted to the end + +## What Silentkelpie saw (2026-10-11, flight recorder 23:13) + +Corpses with three or four keeps (Necrolytic Extracts, Coalesced Aetheria) were closed with +items still on them. On corpse 0xF021B0AB: + +- 22:59:47.07 first pickup sent; the server merges it into the pack's stack (StackableMerge), + InventoryRemoveObject at 48.88. +- 22:59:53.01 second pickup sent, 4.1 s later, with nothing happening in between. InventoryRemoveObject at 54.83. +- 22:59:58.60 corpse closed: the 12 s LootCorpseTimeoutMs ran out. Everything else on it was left. + +## Causes + +1. **A merged item was never "in the inventory".** The pickup counts as done once the item shows + up in a pack. A stack merge removes the picked object, and the client keeps no container for it, + so it never showed up there. Each stackable keep waited the full PickupArriveMaxMs (4 s) + before the next pickup went out. +2. **The corpse timeout counted from the claim, not from the last progress.** With about 6 s per + stackable item, three of them used up the 12 s, and the corpse was abandoned mid-loot. + +## Fix (CorpseOpenController) + +- An item that left the corpse and has no container is taken as merged into a stack. It is + confirmed once its bend-down has played, about 1 s, with the reason "merged into a stack in the pack". +- Every confirmed pickup restarts the corpse timeout. The timeout now means 12 s without taking anything. + +## Tests (LootCorpseTests) + +- `loot pacing: an item merged into a stack in the pack is confirmed without the 4 s arrival wait` + (before: 4064 ms). +- `loot pacing: each item taken restarts the corpse timeout, so a corpse with many keeps is looted to the end` + (before: 1 of 3 taken, then abandoned). + +## Not fixed here + +On corpse 0xF0266213 (23:12:47 to 23:13:00) the client sent its own Use on the open corpse about +2 s after each merge. RynthAi did not send it (it has no engine marker in the recorder). That Use +closed the corpse, and RynthAi reopened it each time, at about 5 s per item. Something +other than RynthAi's loot path sent it: another plugin, or a click or key. diff --git a/Changelog/2026-10-11-items-remove-missing.md b/Changelog/2026-10-11-items-remove-missing.md new file mode 100644 index 0000000..856d950 --- /dev/null +++ b/Changelog/2026-10-11-items-remove-missing.md @@ -0,0 +1,47 @@ +# Items: Remove Missing (clean out items no longer in your inventory) + +Pairs with the matching RynthCore commit on `sk`, which adds the Remove Missing button to the Items panel. + +## Why + +The Items lists (weapons and consumables) keep an entry for every item ever added. Sold, dropped, +traded or used-up items stayed listed. The lists were cleaned only once: when a profile copied +from another character was first loaded. + +## What changed + +- **Remove Missing:** a new button at the top of the engine's Items panel, and a new chat command, + `/ra items clean`. Both drop listed weapons and consumables whose item is no longer in your + inventory. Your inventory means the main pack, side packs and wielded gear. +- **Re-pointing instead of removing:** when an entry's item is gone but your pack holds an + unlisted item with the same name (a new stack of healing kits, a replacement weapon), the entry + is pointed at that item. Its element or type stays as you set it. +- **Duplicates:** a second entry for an item that is already listed is removed. +- **Safe while loading:** nothing is removed while your inventory is still arriving after login, + or while the inventory reads as empty. +- **Report:** a chat line lists what was removed and what was re-pointed. +- **Profile copy check:** the one-time check on a profile copied from another character uses the + same rules. Before, it kept a dead entry whenever any item of that name existed; now it + re-points the entry or removes the duplicate. +- `/ra items` with no argument now lists both `fill` and `clean`. + +## Files + +- `LegacyUi/LegacyWeaponsUi.cs`: `CleanMissing` (`PruneNotOwned` now calls it). +- `LegacyUi/LegacyDashboardRenderer.cs`: `CleanMissingItems`, with the loading guards and the + chat report. +- `RynthAiCommands.cs`, `RynthAiPlugin.cs`: `/ra items clean`. +- `PluginExports.cs`: the `RynthPluginCleanItems` export, used by the engine button. + +## Tests + +`Tools/RynthCore.RynthAiHostTests/Tests/ItemsCleanTests.cs`, 3 new tests: + +- gone entries are removed and owned ones are kept; +- a gone entry is re-pointed at an unlisted item of the same name (case-insensitive), keeping its + element; +- a gone duplicate of an item that is already listed is removed, not re-pointed. + +Result: 622 of 623 pass. The one failure is the known map-bake test, which needs local dats. + +Not yet tested in game. diff --git a/Changelog/2026-10-11-loot-unseen-corpse-items.md b/Changelog/2026-10-11-loot-unseen-corpse-items.md new file mode 100644 index 0000000..6f0449c --- /dev/null +++ b/Changelog/2026-10-11-loot-unseen-corpse-items.md @@ -0,0 +1,31 @@ +# RynthAi: corpse items the object cache missed are looted + +## The bug + +Silentkelpie, 2026-10-11: a Necrolytic Extract on his own kill was left on the corpse. The +loot profile had Keep rules for it (by name), and there was no `[LootEval]` line for it at all. + +Corpse looting only judges what `WorldObjectCache.GetContainedItems` returns, and that only +holds objects the cache has classified. The cache never processed a create for the extract, +so it was in neither the inventory nor the landscape set. The looter never saw it, judged the +other 13 items, and finished the corpse. When the corpse went away the cache logged the extract +as `DELETE-BEFORE-CLASSIFY`. The loot rules themselves were fine: the same profile keeps a +"Necrolytic Extract" (class Misc) with rule 57. + +## The fix + +While a corpse is open, every 500 ms the looter asks the client what the corpse holds +(`GetContainerContents`). It looks up any item the cache is missing (the cache's lazy lookup +files it) and judges it like the rest. A rescue is logged at Trace: + + [RynthAi] Corpse loot: found 1 item(s) on 0xF0703900 the object cache had missed: 0xF0703199 'Necrolytic Extract' Misc. + +An engine without `GetContainerContents` behaves as before. + +## Tests + +`LootCorpseTests`: +- an item whose create never reached the cache is found and looted; +- with no `GetContainerContents`, nothing changes and nothing breaks. + +`FakeHost.ContentsCalls` is a new opt-in fake for `GetContainerContents`. diff --git a/Changelog/2026-10-11-mini-remote-ilt-tabs.md b/Changelog/2026-10-11-mini-remote-ilt-tabs.md new file mode 100644 index 0000000..75172cd --- /dev/null +++ b/Changelog/2026-10-11-mini-remote-ilt-tabs.md @@ -0,0 +1,82 @@ +# RynthAi: the ILT Hub becomes the Mini Remote's tabs + +Pairs with the matching RynthCore commit on `sk`, which adds the Guardian panel under the bar's ILT button. + +## What changed + +The ILT Hub and the Mini Remote are now one window, called **Mini Remote**. + +- **Tabs.** The Mini Remote has a tab bar: **Remote** (the existing sections), then on ILT + worlds **Character, Quests, Pets, Banking, Gear and Games**. + - Each tab shows once the server reports that ILT feature on. + - Off ILT worlds there is no tab bar, so the Mini Remote looks as it did before. + - The selected tab is saved per character in `huds.json` (`MiniRemoteTab`). + - Each ILT tab draws at a fixed size, and the window follows it. Both the floating window and + RynthCore's Mini Remote window refit when the tab changes. + - Right-click Options belongs to the Remote tab. The ILT tabs keep their own right-click menus. + - The dashboard's Mini Remote drawer stays Remote-only. It is too narrow for the tabs, and its + Options menu points to the Mini Remote window instead. +- **The separate ILT Hub windows are gone.** Their saved open/closed flags + (`CharacterWindowOpen`, `PetsWindowOpen`, `QuestTrackerPoppedOut` and the rest) are ignored when + `ilt-hub.json` loads. + - The Games hand HUD and the quest favorites HUD still float on their own. + - The favorites HUD's "Open quest tracker" now switches the Mini Remote to its Quests tab. +- **Commands.** + - `/ra hub open
[show|hide|toggle]` switches the Mini Remote to that tab. It shows the + floating Mini Remote unless RynthCore's window already hosts it. `hide` goes back to Remote. + - `/ra hub tab
` only switches tabs. RynthCore's dashboard uses it after opening its + own Mini Remote window. +- **Guardian moved to RynthCore's ILT button.** + - The Temple guardian tools (riddle answers, Give, the phrasebook) draw in RynthCore's new + Guardian panel, through the new embed surface `"guardian"` (`RynthPluginRenderEmbed`). + - `/ra guardian window [show|hide|toggle]` and the Options menu's "Guardian panel" open that + panel through `/rc guardian`. + - The Mini Remote's "Guardian answer" section is unchanged. +- **RynthAi's own Bounties feature is removed.** RynthILT's Bounties panel (the ILT button, + `/rc bounties`) is the one bounty tracker. + - `/ra bounty ...` and `/ra hub open bounties` open that panel. + - The old `Bounty` block in `ilt-hub.json` is ignored on load. + - The `IltBounties` trace category is gone. +- **Wording.** Chat prefixes changed from `[ILT Hub]` to `[Mini Remote]`. The Settings tooltips + and the Server Features status line now say "Mini Remote" as well. + +## Files + +- `Huds/MiniRemoteHud.cs`: the tab bar (`RenderBody`) and the pending tab switch (`RequestTab`). + `BeginTab` calls `igBeginTabItem` with a null `p_open`, because ImGui.NET only wraps the flags + overload together with a close button. The Options menu's ILT group now links to the Guardian + and Bounties panels. +- `Huds/HudController.cs`: `HandleTabCommand(tab, mode)`. +- `Huds/HudState.cs`: `MiniRemoteTab`. +- `IltHub/IltSections.cs`: the tab list, tab ids and `IsTab`. Bounties was removed. +- `IltHub/IltHubUi.cs`: `TabSize`, `RenderTab` and `RenderGuardianPanel`. The per-section windows + were removed. +- `IltHub/IltHubController.cs`: + - `MiniRemoteTabCommand`, `OffersTabs`, `RenderTab`, `RenderGuardianPanel` and + `OpenEnginePanel`. + - The `tab` verb. + - Bounty and guardian-window verbs go to the engine panels. +- `IltHub/IltQuests.cs`: `RenderTab`. The popped-out tracker window was removed. +- `IltHub/IltHubContext.cs`: `ShowTab`. +- `IltHub/IltHubState.cs` and `IltHub/IltHubStore.cs`: the window flags and the bounty state were + removed. +- `IltHub/IltBounties.cs`, `IltHub/IltBountyParse.cs` and + `Tools/RynthCore.RynthAiHostTests/Tests/BountyTests.cs`: deleted. +- `PluginExports.cs`: the `"guardian"` embed surface. +- `RynthAiPlugin.LocalFeatures.cs`: `RenderEmbeddedGuardian` and the tab command wiring. +- `RynthAiPlugin.cs` and `Diagnostics/RynthLog.cs`: wording, and the `IltBounties` category was + removed. +- `LegacyUi/LegacyAdvancedSettingsUi.cs`, `IltHub/ServerFeatureGate.cs` and the other `IltHub/*` + files: wording. + +## Testing + +- Host tests: 613 of 614 pass. The one failure is the known map-bake test, which needs the real + dat files. +- In game, on an ILT world, check that: + - the tabs appear as features report on; + - the window refits per tab; + - the Char launcher opens the Character tab; + - the bar's ILT button lists Bounties and Guardian, and the Guardian panel draws the guardian + tools; + - `/ra hub open quests` switches tabs. diff --git a/Changelog/2026-10-11-mini-remote-merge.md b/Changelog/2026-10-11-mini-remote-merge.md new file mode 100644 index 0000000..41259e6 --- /dev/null +++ b/Changelog/2026-10-11-mini-remote-merge.md @@ -0,0 +1,41 @@ +# RynthAi: one Mini Remote, resizable slots + +## What changed + +There were two Mini Remotes: RynthCore's own "Mini Remote" window (an empty grid of quick-launch +slots) and RynthAi's floating "MINI REMOTE" (stats, item grid, toggles, bank, rebuff, translate). +They are now one window. + +- **The engine's Mini Remote window hosts RynthAi's remote.** It is the same window you get from + the bar button, `/rc miniremote`, or the dashboard's Hub launcher. It shows every RynthAi + section, Toggles included, and resizes itself to fit them. + - New embed surface `RynthPluginRenderEmbed("miniremote-window")`, next to the existing + `"miniremote"` (the dashboard drawer, which still leaves Toggles out). + - While that window shows the remote, RynthAi's floating copy stays hidden + (`HudController.MiniRemoteInEngineWindow`), so there is only ever one on screen. + `/ra remote` says where the remote is instead of opening a second one. + - In the window, the Options menu offers the Toggles section and leaves out "Floating window too". +- **Grow and shrink the slot boxes.** + - Ctrl+mouse wheel over the slot grid makes the boxes bigger or smaller, 2 px per notch. + - Options > "Slot size" slider (18-64 px) with a Default (28 px) button. + - Saved per character in `huds.json` as `MiniRemoteSlotSize`. Older files, which don't have + it, get the default. + - The columns, and the window or drawer around them, refit to the new size. + +## Files + +- `Huds/HudState.cs`: `MiniRemoteSlotSize` plus its range constants; clamped in `HudStore.Normalize`. +- `Huds/MiniRemoteHud.cs`: the slot size is read from state rather than a constant, plus + Ctrl+wheel, the Options slider and the `window` embed mode. +- `Huds/HudController.cs`: `RenderEmbedded(bool window)`, `MiniRemoteInEngineWindow`, the + floating window suppressed while the engine hosts the remote, and the `/ra remote` reply. +- `PluginExports.cs` and `RynthAiPlugin.LocalFeatures.cs`: the `"miniremote-window"` surface. + +Needs the matching RynthCore engine (Mini Remote window host, same date). An older engine never +asks for `"miniremote-window"`, so with one this plugin behaves as before, apart from the +resizable slots. + +## Tests + +- RynthAi host tests: 619 tests, 618 passed. The one failure is the map bake (0x6346), which + already failed before this change. diff --git a/Changelog/2026-10-11-nav-closest-waypoint.md b/Changelog/2026-10-11-nav-closest-waypoint.md new file mode 100644 index 0000000..5877f8a --- /dev/null +++ b/Changelog/2026-10-11-nav-closest-waypoint.md @@ -0,0 +1,72 @@ +# Navigation: Go To Closest Waypoint (on by default) + +Pairs with the matching RynthCore commit on `sk`, which shows the option on the engine Settings page. + +## Why + +Navigation only looked for the closest waypoint at macro start. Two cases went the long way round: + +- **After a pause:** combat, looting, buffing and doors stop nav, then hand back to it. Nav carried + on to the waypoint it was heading for before the pause, even when a chase had taken the + character next to a different part of the route. It walked back to the old waypoint first. +- **Already past the nearest point:** macro start picked the nearest waypoint even when the + character had just walked past it. Nav turned round to touch it, then turned back. + +## What changed + +- **New option: Advanced Settings > Navigation > Getting Back On Route > Go To Closest Waypoint.** + It is on by default. It is also on the engine Settings page under Navigation, and metas can read + or set it as `NavResumeNearest`. +- **With the option on:** + - **Macro start:** heads for the closest waypoint, as before. + - **Back from a pause that moved the character 10 yd or more:** re-picks the closest waypoint + instead of walking back to the old one. A pause that moved the character less than 10 yd + carries on to the same waypoint. A move of more than 400 yd counts as a teleport, which the + portal handling already deals with. + - **No turning back:** when the closest spot on the route is on the leg after the nearest + waypoint (the character already walked past it), nav heads for the next waypoint. A Linear + route follows its current direction. A step (recall, portal, chat, pause, NPC) is never + skipped to or over. + - **Loading a Circular or Linear route:** starts at its nearest waypoint, as before. + - Once routes still only look ahead of the current step, and Follow routes are not changed. + - A detour or area hold in progress keeps control, so the re-pick does not interrupt it. + - Indoors, macro start still compares the nearest waypoints by walking distance on the + dungeon map. +- **With the option off:** + - Pauses carry on to the waypoint nav was heading for. + - Macro start keeps the last waypoint. + - A loaded route starts at its first point. + - Hazard escapes and corpse runs still rejoin at the closest waypoint, because they take the + character off the route. + +## Files + +- `NavigationEngine.cs`: + - remembers where a pause started (`MarkPausePosition`); + - re-picks on the first steer tick back (`ResumeAfterPause`); + - `ResumeFromNearestWaypoint(bool always = false)` now honours the setting; + - `PassedToward` and `SegmentDistSq` implement the no-turning-back rule. +- `LegacyUiSettings.cs`: `NavResumeNearest` (default true), plus the engine DTO field (nullable, + so an absent value keeps the plugin's setting). +- `LegacyDashboardRenderer.cs`: engine round trip, `CopySettings`, and the route-load start index. +- `NavRouteParser.StartsAtFirstPoint`: the shared route-load rule, also used by + `MetaManager.StartIndexForRoute`. +- `LegacyAdvancedSettingsUi.cs`: the checkbox and its tooltip. +- `ExpressionEngine.cs`: the `NavResumeNearest` setting name for metas. +- `RynthAiPlugin.HazardEscape.cs`, `RynthAiPlugin.OwnCorpse.cs`: always rejoin at the closest + waypoint. + +## Tests + +`Tools/RynthCore.RynthAiHostTests`, 5 new tests: + +- macro start skips a nearest waypoint already walked past, but not one still ahead; +- back from a pause that moved 10 yd or more, nav heads for the closest waypoint; +- back from a pause that moved less than 10 yd, nav keeps its waypoint; +- with the option off: the pause and macro-start cases keep the last waypoint, and hazard or + corpse rejoins still re-pick; +- the route-load start rule. + +Result: 619 of 620 pass. The one failure is the known map-bake test, which needs local dats. + +Not yet tested in game. diff --git a/Changelog/2026-10-11-popout-embed-crash.md b/Changelog/2026-10-11-popout-embed-crash.md new file mode 100644 index 0000000..0dcf9cb --- /dev/null +++ b/Changelog/2026-10-11-popout-embed-crash.md @@ -0,0 +1,46 @@ +# RynthAi: fix the client crash when the Mini Remote (or Guardian) is popped out + +Pairs with the matching RynthCore commit on `sk`, which carries the engine half of the fix. + +## The crash + +All four client crashes on 2026-10-11 between 21:32 and 21:38 (dumps + +- The Application event log (.NET Runtime 1026) gives the stack: + - `ImGuiPopOuts.RenderAll` + - `ImGuiPanelHost.DrawPopped` + - `MiniRemoteFace.Draw` + - `PluginManager.RenderEmbed` + - an access violation inside coreclr +- The Mini Remote had been popped out into its own window, and RynthCore asked RynthAi to draw it + there. +- A popped-out panel has its own ImGui context. RynthAi's embedded surfaces always switched to + `Host.ImGuiContext`, the engine's main context, which isn't mid-frame at that point. ImGui + dereferenced a null current window, and an access violation can't be caught, so the client + died. +- It happened on the first frame the popped-out Mini Remote showed: the Char (hub) button's + left-click, or right after login when the window was left popped out. +- The 4 to 9 seconds of "MAIN THREAD HANG DETECTED" before each exit was the runtime writing the + crash dump, not a separate hang. + +## Fix + +- The embedded surfaces (`miniremote`, `miniremote-window`, `guardian`) draw in the context that + is current when RynthCore calls (`EmbedContext` in `RynthAiPlugin.LocalFeatures.cs`). That is + the window RynthCore has begun, whether it's docked or popped out. +- `RynthPluginRenderEmbed` accepts the names with a `:popout` suffix. the matching RynthCore + sends those from a pop-out so older RynthAi builds decline instead of crashing. +- With this build the popped-out Mini Remote and Guardian show RynthAi's own content. + +## Files + +- `PluginExports.cs`: strips the `:popout` suffix. +- `RynthAiPlugin.LocalFeatures.cs`: `EmbedContext`, used by `RenderEmbeddedMiniRemote` and + `RenderEmbeddedGuardian`. + +## Testing + +- Host tests: 616 of 617 pass. The one failure is the known map-bake test, which needs the real + dat files. +- Not yet checked in game: pop out the Mini Remote and the Guardian panel, use the Char button, + and log in with the Mini Remote left popped out. diff --git a/Changelog/2026-10-11-recall-on-death.md b/Changelog/2026-10-11-recall-on-death.md new file mode 100644 index 0000000..1aa5c15 --- /dev/null +++ b/Changelog/2026-10-11-recall-on-death.md @@ -0,0 +1,59 @@ +# Recall On Death: cast a recall spell or use a recall item after dying + +Pairs with the matching RynthCore commit on `sk`, which shows the option on the Settings page. + +## What changed + +- **New option: Settings > On Death > Recall On Death.** The choices are: + - Off (the default); + - Cast a recall spell: pick it from the nav editor's recall list (Primary Portal Recall by + default); + - Use a recall item: type the item's name as it shows in your inventory. An exact name wins; + otherwise the first item whose name contains it is used. +- **When it runs:** + - after you die while the macro is running; + - once you've respawned and the existing 5-second settle after the death portal is over; + - Stop Macro On Death still recalls first, because the recall is armed at the moment you die. +- **While it runs:** + - nothing else runs (no combat, buffing, looting or nav); + - a spell first gets a wand and magic mode, the same step a nav Recall waypoint takes; + - a fizzle or failed use is retried every 4 s for a spell and every 6 s for an item, up to + 5 tries; + - once portal space or a landblock change shows the teleport happened, nothing more is fired. +- **Afterwards:** + - 3 s after landing, nav rejoins its route at the closest waypoint; + - Travel Back To My Corpse then starts from the landing spot. A Primary Portal Recall to your + hunting ground makes that walk much shorter. +- **Giving up:** after 5 tries or 60 s, it says why in chat and carries on from where you are. +- **Not started**, with a chat line saying why, when: + - the item isn't in your inventory; + - no item name is set; + - the engine can't cast or use items. +- Dying again during a recall cancels it. + +## Files + +- `DeathRecallRun.cs` (new): the attempt as a pure, clock-driven state machine: when to fire, when + the teleport counts as done, when to give up. +- `RynthAiPlugin.DeathRecall.cs` (new): armed on the death edge, started on the respawn edge, + ticked after the death hold; spell cast or item use, the chat report, then nav and the corpse + trip. +- `RynthAiPlugin.Safety.cs`, `RynthAiPlugin.cs`: wiring. +- `LegacyUiSettings.cs`: `DeathRecallMode`, `DeathRecallSpellId`, `DeathRecallItem`, plus the + engine DTO fields (nullable, so an older engine leaves them alone). +- `LegacyDashboardRenderer.cs`: engine round trip and `CopySettings`. +- `ExpressionEngine.cs`: the three setting names for metas. + +## Tests + +`Tools/RynthCore.RynthAiHostTests/Tests/DeathRecallTests.cs`, 5 new tests: + +- fires at once, then retries every 4 s; +- portal space stops the firing, and the run is done 3 s after landing; +- a landblock change counts as the teleport; +- gives up after 5 tries, with items retried every 6 s; +- never fires while not ready, and times out after 60 s. + +Result: 627 of 628 pass. The one failure is the known map-bake test, which needs local dats. + +Not yet tested in game. diff --git a/Changelog/2026-10-11-shared-session-stats.md b/Changelog/2026-10-11-shared-session-stats.md new file mode 100644 index 0000000..e358602 --- /dev/null +++ b/Changelog/2026-10-11-shared-session-stats.md @@ -0,0 +1,99 @@ +# Mini Remote and Tracker: one set of session-stat rules + +RynthTracker 0.4.0 (previous: 0.3.0). Pairs with the matching RynthCore commit on `sk`, which adds the Tracker panel's new rows. + +## Why + +Before this release the Mini Remote and the Tracker panel computed the same stats with different code: + +| Stat | Tracker (RynthTracker 0.3.0) | Mini Remote (RynthAi before) | +|---|---|---| +| Luminance | Character lum (6), plus Aelrynth's bank totals (9102 / 9103). On ACECustom it missed all banked lum and counted bank withdrawals as income. | ACECustom bank lum (9005) only, so it missed lum on retail ACE and on Aelrynth. | +| Kills | Kill notices, plus corpse kills from multi-target spells | Kill notices only | +| XP | Rises, polled every 0.5 s | Net change since the start, polled every 5 s | +| Worlds | All | ILT only ("Session stats: ILT worlds only") | +| Reload | The session carried over | The session started over | +| Lum in the last 5 minutes, pass-up | Neither tracked | Neither tracked | + +## What changed + +- **One shared engine:** `Plugins/Shared/SessionStats.cs` holds the rules, and + `Plugins/Shared/SessionStatsTracker.cs` feeds it from the game. Both plugins compile them in, so + every number below is computed the same way in both. + - **XP:** the rise of TotalExperience (1), read every 0.5 s. + - **Luminance, per server:** + - Retail ACE: the rise of AvailableLuminance (6). + - Aelrynth: as before, the Bank mod's auto-banked total (9102) added and its drawn total (9103) + taken out. + - ACECustom: the rise of BankedLuminance (9005). Once that property is read: + - rises of AvailableLuminance (6) are ignored, because there they are bank withdrawals; + - lum moved in by "Deposited N luminance" or "Received N luminance from X" is taken out of + the next bank rises (a line whose rise hasn't arrived within 60 s is dropped); + - "You've banked N Luminance." counts on its own only until a bank property (9005 or 9102) + is read. + - **Luminance in the last 5 minutes (new):** a rolling 5-minute window, kept in 5-second + buckets. + - **Pass-up (new):** ACECustom doesn't send the allegiance lum counters (9013 / 9014) to the + client. Pass-up is therefore bank income minus your own "You've banked" lines, because a + vassal's pass-up reaches the bank without a chat line. Fellowship and Zone Share splits also + arrive silently, so they are included. It is shown only where the bank is read (ACECustom). + - **Kills:** kill notices, plus corpse kills of monsters you hit with a multi-target spell + (`KillCounter`, moved to Shared). + - **XP per kill, deaths and Radiance:** unchanged from the Tracker. + - **Session lifecycle:** saved every 30 s and restored after a plugin reload (same client, + same character, saved within the last 10 minutes); a logout ends the session. + - RynthTracker saves to `%LOCALAPPDATA%\RynthCore\tracker`, the Mini Remote to + `%LOCALAPPDATA%\RynthCore\miniremote-stats`. + - Saves from RynthTracker 0.3.0 still load (the new keys are optional). +- **The Mini Remote's Stats section now works on every world:** + - It shows Time, XP/h, Lum/h, Lum 5m, Pass-up/h (ACECustom) and Kills/h, plus Coins/h and Pyr/h + on ILT. + - The Reset XP and Report buttons also work everywhere. Report now includes lum in the last + 5 minutes and pass-up. +- **ILT Character tab "Session rates":** + - XP, Luminance, its last 5 minutes (with the per-hour pace), pass-up and Kills now come from + the shared stats. + - Coins, pyreals and item conversions are unchanged. + - The Reset button resets both the coin counts and the shared stats. +- **RynthTracker's snapshot JSON** gains these keys: + - `l5`: lum in the last 5 minutes; + - `pt`: pass-up total; + - `ph`: pass-up per hour; + - `pk`: 1 when pass-up is known. + + The existing keys are unchanged. +- **Removed:** `IltLumIncome` and the `IltParse.LumBanked` regex. RynthAi's kill path no longer + calls `IltHubController.RecordKill`. + +The Tracker panel and the Mini Remote each keep their own session and their own reset. They +match when both started at the same login; resetting one doesn't reset the other. + +## Files + +- `Plugins/Shared/SessionStats.cs` (new), `Plugins/Shared/SessionStatsTracker.cs` (new). +- `Plugins/Shared/KillCounter.cs`, `Plugins/Shared/TrackerSessionStore.cs`: moved from RynthTracker + into the `RynthCore.Plugin.Shared` namespace. The store adds `DirectoryFor` and the new save keys. +- `Plugins/RynthCore.Plugin.RynthTracker/RynthTrackerPlugin.cs`: a thin wrapper over the shared tracker, version 0.4.0. +- `Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs`, `RynthAiPlugin.LocalFeatures.cs`: own a + `SessionStatsTracker` and forward login, logout, shutdown, tick, chat, kill, object and health + events to it. +- `Plugins/RynthCore.Plugin.RynthAi/Huds/MiniRemoteHud.cs`, `Huds/HudController.cs`: universal Stats. +- `Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSessionRates.cs`, `IltHubController.cs`, `IltParse.cs`. +- `Tools/RynthCore.TrackerSessionTests`: new `SessionStatsTests.cs`, covering: + - ILT bank lum, deposits, transfers, withdrawals and spending; + - pass-up; + - the chat fallback; + - Aelrynth and retail lum; + - the 5-minute window; + - kills and XP per kill; + - reload equivalence; + - parsing older saves. +- `Tools/RynthCore.RynthAiHostTests`: `LumIncomeTests` removed (it tested `IltLumIncome`). + +## Testing + +- TrackerSessionTests: 275 assertions, all pass. +- RynthAi host tests: 614 of 615 pass. The one failure is the known map-bake test, which needs + the dats. +- RynthAi and RynthTracker both publish as NativeAOT in Release. +- Not yet checked in game. diff --git a/Changelog/2026-10-11-sk-rynthai-work-through-10-10.md b/Changelog/2026-10-11-sk-rynthai-work-through-10-10.md new file mode 100644 index 0000000..90f5b5c --- /dev/null +++ b/Changelog/2026-10-11-sk-rynthai-work-through-10-10.md @@ -0,0 +1,65 @@ +# SK RynthAi work through 2026-10-10, rebased on 2026.10.12.1 + +Replaces the closed per-feature PRs RynthSuite #2-#11 and the earlier `sk` commits. This commit +carries everything from those PRs that main doesn't already have, merged onto release 2026.10.12.1 +with the conflicts resolved. Work from 2026-10-11 follows in separate commits. +`HandWrittenVersion` stays `0.5.0-legacy-ui`. + +The merge-stack result the looter reads is engine API v81 now (rynth's 2026.10.12.1 took v80); +`HasGetMergeStackResult` in the SDK checks that, so an older engine just reports it unavailable. + +## Needs a decision: item info + +Both sides had `/ra iteminfo`. This commit keeps the Mag-Tools port (settings window, field and +rating toggles, click trigger, pet or line layout, T11 fields) and folds in rynth's additions: + +- `/ra iteminfo ` describes an inventory item by name. +- Items RynthAi selects itself (looter, meta `selectitem`) are not described. +- The line ends with the looter's verdict (`| Loot: [Keep] rule`), as a preview. +- The default prefix is `[RynthAi Item] `, so RynthChat files it under Items. +- Rynth's "Item Info On Select" checkbox, the meta setting `ItemInfoOnSelect` and the engine's + settings DTO drive `ItemInfoSettings.OnSelect`; an Options button opens the Item Info window. + +To do that it **removes** rynth's `RynthAiPlugin.ItemInfo.cs`, `ItemInfo/ItemInfoText.cs` and +`Tests/ItemInfoTests.cs`. If rynth prefers his implementation, this is the part to drop. + +## How the merge with 2026.10.11.1 was settled + +- Rynth's side: pet essence refill-loop guard, typed-object filing (`WorldObjectCache`), spell + category and power (`SpellDatabase`), Decal synthetic keys, dungeon hazards, radar walls, meta + UI, and install paths (everything links `Plugins/Shared/RynthInstallPaths.cs`). +- Ours: the T11 loot catalog, keys and `/ra t11`, `LootItemRules`, the T11 loot tests, and + `RynthLog` categories in loot logging. +- Both: `LootRuleText` (rynth's text plus the T11 property keys and Gear Grade table), the + `MonsterEditor` JSON context, chat hooks, and the host test list. + +## Features + +- **ILT Hub** (`IltHub/`): character, quests, pets and pet stats, banking, gear and equip suits, + games, buff keepers, guardian answers, temple attributes, sigil chain, lum income, session + rates, USD import, and a server feature gate so ILT-only parts stay off elsewhere. +- **Attribute raiser and augmentation planner** with UB's InfiniteLeaftide cost math and + per-server cost settings (`IltAttributeRaiser`, `IltAugCosts`, `IltProgression`). +- **HUDs** (`Huds/`): Mini Remote, combat HUD and item count HUD, with an icon cache. +- **Item info** as above (`MagItemDescriber`, `MagItemInfoSettings`, `LegacyItemInfoUi`). +- **Chat translation** (`Translate/`): per-channel auto-translation with its own settings UI. +- **Ground loot** (`GroundLootController`). +- **Nav:** route editing in the dashboard, breadcrumbs, and a route overlay + (`NavRouteEditing`, `NavBreadcrumbTracker`, `NavOverlayRenderer`). +- **Spells:** a spell catalog generated from the client's spell table + (`SpellCatalog.tsv`, `Tools/Generate-SpellCatalog.ps1`), buff profiles, and a Spells window. +- **Creature data:** UB's damage seed in the Auto element ranking (`Shared/UbMobSeed.cs`, + `UbMobSeedStore`), and VirindiTank profile and USD monster imports (plugin and Monster Editor). +- **Loot:** the ACECustom T11 item state for item ID and loot rules; "Include T11 attributes" + when adding an item to a loot profile; unknown VTank conditions bounded by their length code. +- **Corpses:** only the "Killed by" line names the killer. +- **Diagnostics:** per-category, per-process RynthAi log files (`Diagnostics/RynthLog.cs`). +- **Plumbing:** the plugin calls cimgui through its own binding (`ImGuiNativeBinding`), window + placement helpers (`UiPlacement`), and the plugin exports the engine's overlay, embed and remote + commands use (`PluginExports`). + +## Testing + +- `dotnet build -c Release`: RynthAi plugin and Monster Editor. +- LootSdkTests pass. +- RynthAiHostTests pass except the map bake, which needs the real dat files on the test machine. diff --git a/Changelog/2026-10-11-universal-quests-pets.md b/Changelog/2026-10-11-universal-quests-pets.md new file mode 100644 index 0000000..8099985 --- /dev/null +++ b/Changelog/2026-10-11-universal-quests-pets.md @@ -0,0 +1,50 @@ +# RynthAi: Quests and Pets on every server; "Server: " in the right-click menu + +Pairs with the matching RynthCore commit on `sk`. + +## What changed + +- **Quests and Pets are universal.** + - They were Infinite Leaftide tabs. Now they show on every server, in every Mini Remote: the + floating window, RynthCore's Mini Remote window, and that window popped out. + - The tab bar runs: Remote, Quests, Pets. On ILT worlds the ILT tabs follow: Character, + Banking, Gear, Games. + - The quest tracker (`/myquests`) and the pet roster, priorities and healing pet tick and read + chat on every world (`IltHubController.IsUniversal`). + - The ILT-only parts of those tabs show only on ILT worlds: + - Quests: the quest bonus list (`/qb`). + - Pets: the Summon Essence Refill and Universal Summoning Mastery charms, and the `/pets` and + `/shinies` logs. +- **Guardian stays ILT only.** It's still RynthCore's ILT panel, listed under the server section. +- **Right-click menu:** + - Top: **Character**, with Spells, Quests, Pets, Skills, Inventory, Item Count and Inventory + HUDs setup. + - Bottom: **Server: ** (e.g. "Server: Infinite Leaftide"), with the installed + server plugins' windows. For ILT that's the Character, Banking, Gear and Games tabs, + Guardian, Bounties and Progression. + - With an older RynthCore that still lists Quests and Pets under the server, they are left out + there so they don't show twice. + +## Files + +- `IltHub/IltSections.cs`: the tab order (universal first) and `IsUniversal`. +- `IltHub/IltHubController.cs`: + - `SectionAvailable`: Quests and Pets are always available; + - new `TabShown`; + - universal features tick and read chat on every world. +- `IltHub/IltPets.cs`, `IltHub/IltQuests.cs`: the ILT-only parts are gated on an ILT world. +- `Huds/MiniRemoteHud.cs`: + - the tab bar (`TabShown`); + - Quests and Pets under Character; + - the "Server: " header; + - universal tabs skipped in the server section. +- `Tools/RynthCore.RynthAiHostTests/Tests/ServerMenuTests.cs`: a universal-tabs test. + +## Testing + +- Host tests: 617 of 618 pass. The one failure is the known map-bake test, which needs the real + dat files. The new universal-tabs test passes. +- Not yet checked in game: + - Quests and Pets tabs on a non-ILT world; + - the "Server: Infinite Leaftide" section on ILT; + - no `/qb`, `/pets` or `/shinies` being sent off ILT. diff --git a/Changelog/2026-10-13-rynthnet-status-id-cmode.md b/Changelog/2026-10-13-rynthnet-status-id-cmode.md new file mode 100644 index 0000000..41306f5 --- /dev/null +++ b/Changelog/2026-10-13-rynthnet-status-id-cmode.md @@ -0,0 +1,23 @@ +# RynthNet 0.1.1: object id and combat mode in the shared status + +Pairs with the RynthCore engine's Characters panel (`/rc characters`, RynthCore +`feature/characters-panel`). + +## What changed + +- Each client's shared status (sent every `statusIntervalMs`) now has two more fields: + - `id`: the character's object id. It is the same on every client, so the Characters panel can + select that character with a click when it is in view. + - `cmode`: AC's combat mode (1 peace, 2 melee, 4 missile, 8 magic). The panel shows a stance + when the macro is off. +- The fields are optional. A 0.1.0 client's status simply lacks them, and readers treat every + status field as optional. +- `Docs/RYNTHNET.md` now lists the fields and points to the Characters panel as the NetworkUI HUD. + +## Files + +- `RynthNetPlugin.Status.cs`: the two fields. `cmode` is written only when the host has + `GetCurrentCombatMode`, which reads a cached value off AC's thread. +- `RynthNetPlugin.cs`: version 0.1.1. + +Not yet tested in game. diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffCastChain.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffCastChain.cs new file mode 100644 index 0000000..d245173 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffCastChain.cs @@ -0,0 +1,206 @@ +// ============================================================================ +// RynthSuite - Plugins/RynthCore.Plugin.RynthAi/Combat/BuffCastChain.cs +// Buff cast chaining: the next buff of a pass goes out on the last buff's UseDone, +// without waiting for the client to finish playing the cast's recoil. +// +// Why: in a buff pass every buff waited on the animation gate (ActionPacer.GestureHolds +// and CastGateWatchdog.CanCastNow, both the client's CMotionInterp queue) after the +// server's UseDone for the previous buff: "[Pace] Buff waits: the character is still +// animating" after each UseDone, and the next buff ~550 ms later (UseDone to next buff: +// median 553 ms over 74 buffs, bimodal at ~50 and ~550 ms). On ACE the server clears +// IsBusy just before it sends that UseDone (Player_Magic.cs: IsBusy = false; +// SendUseDoneEvent()), and VerifyBusy only checks IsBusy, so it takes the next cast at +// once; the client is still showing the recoil the server already finished. +// +// The fast path (LegacyUiSettings.FastBuffChain, default on) opens ONLY the animation +// gate, and only when all of these hold: +// * the last action RynthAi sent was one of BuffManager's own buff casts +// (ActionPacer.Started and AttacksSent unchanged since it went out); +// * the very next UseDone after it is the last one (no other UseDone since) and its +// error is 0; +// * that UseDone was seen less than WindowMs ago; +// * no movement call reached the client since the buff went out (MoveAudit.MovementSends +// unchanged): a stop, a start or a turn starts a motion the client still has to play, so +// the next buff waits on the animation gate for it (a buff went out 50 ms after a nav stop); +// * no refusal has turned the fast path off for this buff pass. +// Every other gate stays: the pacer's outstanding-action gate, the pending cast, the +// server-resolution wait, the busy count, the cast interval, the stance (EnsureMagicMode), +// the mana floor, the too-busy backoff. BuffManager also takes the fast path only while +// no vital is under any of its lines (the mana reserve included), and drops it for a buff +// that would need Stamina to Mana first, so no kit, potion or vital cast rides it. +// +// Refusals (the crash this protects against: a tight retry loop on "You're too busy!" +// re-enters AC's AddTextToScroll -> AV 0x00460D1D, see BuffManager.OnChatWindowText and +// CastGateWatchdog): the throttle, the park and the escalating backoff are untouched, and +// any refusal of a buff cast that went out on the fast path (the client's CastSpell +// returning false, a "too busy" line for it, or an error in its UseDone) turns the fast +// path off for the rest of the pass, logged. Every refusal during buffing is counted for +// as a running total since load, logged one line each, and each pass ends with a summary line. +// ============================================================================ + +using System; + +namespace RynthCore.Plugin.RynthAi; + +internal sealed class BuffCastChain +{ + /// The fast path is only taken this long after the last buff's UseDone was seen. + public const double WindowMs = 1500; + + // The last buff cast BuffManager sent. + private int _spellId; + private string _name = ""; + private int _seqAtSend; + private long _startedAfter; + private long _attacksAfter; + private long _movesAfter; + private bool _moveCounted; // MovementWaits counted for this send + private bool _wasFast; + private bool _heldForAnimation; // the next buff goes through the animation gate (HoldForAnimation) + private bool _answerSeen; // the first UseDone after it was read + private bool _answerOk; // ... and it was UseDone(0), the next UseDone after the send + private DateTime _answerSeenAt = DateTime.MinValue; + + // This pass. + private bool _inPass; + private bool _offThisPass; + private int _passCasts, _passFast, _passClient, _passServer, _passTooBusy; + + // Running totals since load. + public int ClientRefusals { get; private set; } + public int ServerRefusals { get; private set; } + public int TooBusyLines { get; private set; } + public int FastCasts { get; private set; } + public int BuffCasts { get; private set; } + public int PassesSwitchedOff { get; private set; } + /// Times the fast path was refused because a movement call went out after the last buff. + public int MovementWaits { get; private set; } + + /// True when a refusal turned the fast path off for the rest of this pass. + public bool OffThisPass => _offThisPass; + public bool InPass => _inPass; + + public void PassStart() + { + if (_inPass) return; + _inPass = true; + _offThisPass = false; + _passCasts = _passFast = _passClient = _passServer = _passTooBusy = 0; + } + + /// The pass is over (complete or cancelled): one summary line. + public void PassEnd(string how, Action log) + { + if (!_inPass) return; + _inPass = false; + log($"[BuffChain] buff pass {how}: {_passCasts} buff cast(s), {_passFast} on the fast path" + + $"{(_offThisPass ? " (fast path switched off by a refusal)" : "")}; refusals this pass: client {_passClient}, " + + $"server {_passServer}, too-busy lines {_passTooBusy}; totals: client {ClientRefusals}, server {ServerRefusals}, " + + $"too-busy lines {TooBusyLines}, {FastCasts} of {BuffCasts} buff casts on the fast path"); + _offThisPass = false; + } + + /// A buff cast went out. is the UseDone count read before the send; + /// / are ActionPacer's counts and + /// MoveAudit.MovementSends, all read after it. + public void Sent(int spellId, string name, int seqAtSend, long started, long attacks, long moves, bool fast) + { + _spellId = spellId; + _name = name; + _seqAtSend = seqAtSend; + _startedAfter = started; + _attacksAfter = attacks; + _movesAfter = moves; + _moveCounted = false; + _wasFast = fast; + _heldForAnimation = false; + _answerSeen = false; + _answerOk = false; + _answerSeenAt = DateTime.MinValue; + BuffCasts++; + _passCasts++; + if (fast) { FastCasts++; _passFast++; } + } + + /// The client refused a buff cast (CastSpell returned false: nothing went out). + public void ClientRefused(int spellId, string name, bool fast, Action log) + { + ClientRefusals++; + _passClient++; + log($"[BuffChain] refusal (client): CastSpell refused '{name}' (id {spellId}){(fast ? " on the fast path" : "")}" + + $" - totals client {ClientRefusals}, server {ServerRefusals}, too-busy lines {TooBusyLines}"); + if (fast) SwitchOff("the client refused a fast-path cast", log); + _spellId = 0; // nothing went out: nothing to chain on + } + + /// + /// Each tick: reads the first UseDone after the last buff cast. An error in it is a server refusal + /// (counted, logged; on the fast path the fast path is off for the pass). + /// + public void Observe(bool hasLast, int lastSeq, uint lastErr, int seqNow, DateTime now, Action log) + { + if (_spellId == 0 || _answerSeen || !hasLast) return; + if (lastSeq <= _seqAtSend) return; // not answered yet + _answerSeen = true; + _answerSeenAt = now; + bool next = lastSeq == _seqAtSend + 1 && seqNow == lastSeq; + _answerOk = next && lastErr == 0; + if (next && lastErr != 0) + { + ServerRefusals++; + _passServer++; + log($"[BuffChain] refusal (server): UseDone error 0x{lastErr:X} for '{_name}'{(_wasFast ? " on the fast path" : "")}" + + $" - totals client {ClientRefusals}, server {ServerRefusals}, too-busy lines {TooBusyLines}"); + if (_wasFast) SwitchOff($"the server refused a fast-path cast (0x{lastErr:X})", log); + } + } + + /// A "You're too busy!" line while (a buff of ours) waited for its result. + public void TooBusyLine(int pendingSpellId, Action log) + { + if (!_inPass || pendingSpellId == 0) return; + TooBusyLines++; + _passTooBusy++; + bool ours = pendingSpellId == _spellId; + log($"[BuffChain] refusal (too-busy line) while '{(ours ? _name : $"spell {pendingSpellId}")}' was pending" + + $"{(ours && _wasFast ? " (sent on the fast path)" : "")} - totals client {ClientRefusals}, server {ServerRefusals}, too-busy lines {TooBusyLines}"); + if (ours && _wasFast) SwitchOff("a fast-path cast drew 'You're too busy!'", log); + } + + /// The next buff needs another cast first (Stamina to Mana for the mana reserve): no fast + /// path until the next buff cast goes out. + public void HoldForAnimation() => _heldForAnimation = true; + + private void SwitchOff(string why, Action log) + { + if (_offThisPass) return; + _offThisPass = true; + PassesSwitchedOff++; + log($"[BuffChain] {why}: the next buffs of this pass wait for the animation again"); + } + + /// + /// May the next buff skip the animation gate? says why it may (for the log). + /// The caller has checked the setting, the pacing and the vitals. + /// + public bool Eligible(long started, long attacks, long moves, bool hasLast, int lastSeq, uint lastErr, int seqNow, DateTime now, out string why) + { + why = ""; + if (_offThisPass || _heldForAnimation || _spellId == 0 || !_answerSeen || !_answerOk) return false; + if (started != _startedAfter || attacks != _attacksAfter) return false; // something else went out since + if (!hasLast || lastSeq != _seqAtSend + 1 || seqNow != lastSeq || lastErr != 0) return false; // another UseDone since + double age = (now - _answerSeenAt).TotalMilliseconds; + if (age > WindowMs) return false; + if (moves != _movesAfter) // a stop, start or turn went out since: its motion must play first + { + if (!_moveCounted) { _moveCounted = true; MovementWaits++; } + return false; + } + why = $"'{_name}' answered UseDone(0) {age:0} ms ago"; + return true; + } + + public string Describe() => + $"Buff chain: {FastCasts} of {BuffCasts} buff casts on the fast path; refusals client {ClientRefusals}, " + + $"server {ServerRefusals}, too-busy lines {TooBusyLines}; passes switched off {PassesSwitchedOff}; movement waits {MovementWaits}"; +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.BuffProfile.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.BuffProfile.cs new file mode 100644 index 0000000..2449847 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.BuffProfile.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.IO; + +namespace RynthCore.Plugin.RynthAi; + +/// +/// Buff profiles (Spells window / Loaded Files → Buffs): when one is chosen, its enabled +/// spells replace the built-in buff list, in the profile's order. Each entry is a base name +/// ("Strength Self") resolved to the best tier the character knows like the built-in list; +/// spells without a tier ladder (server-custom or lore names) fall back to the best known +/// spell of the same ACE spell family. +/// +public partial class BuffManager +{ + // Re-checking the file's timestamp every call would hit the disk ~30x a second. + private const int BuffProfileRecheckMs = 3000; + + private string _buffProfilePath = string.Empty; + private DateTime _buffProfileWriteUtc; + private long _buffProfileCheckedAt = long.MinValue / 2; + private List? _profileKeys; + private readonly Dictionary _profileByKey = new(StringComparer.OrdinalIgnoreCase); + + /// Name of the buff profile in use, or null when buffing uses its built-in list. + public string? ActiveBuffProfileName { get; private set; } + + /// Spells (enabled entries) in the active buff profile; 0 with no profile. + public int ActiveBuffProfileCount => _profileKeys?.Count ?? 0; + + /// + /// Follows : loads the profile when the + /// path changes or the file is re-saved (the Spells window's Save), drops it when the path is + /// cleared. A missing or unreadable file means the built-in list, with one chat line. + /// + private void SyncBuffProfile() + { + string path = _settings.CurrentBuffProfilePath ?? string.Empty; + long now = Environment.TickCount64; + bool pathChanged = !path.Equals(_buffProfilePath, StringComparison.OrdinalIgnoreCase); + if (!pathChanged && now - _buffProfileCheckedAt < BuffProfileRecheckMs) return; + _buffProfileCheckedAt = now; + + if (path.Length == 0) + { + if (pathChanged) ClearBuffProfile("[RynthAi] Buffing: built-in buff list."); + _buffProfilePath = path; + return; + } + + DateTime writeUtc; + try { writeUtc = File.Exists(path) ? File.GetLastWriteTimeUtc(path) : DateTime.MinValue; } + catch { writeUtc = DateTime.MinValue; } + if (!pathChanged && writeUtc == _buffProfileWriteUtc) return; + + _buffProfilePath = path; + _buffProfileWriteUtc = writeUtc; + SpellCatalog.EnsureLoaded(m => _host.Log(m)); + if (!BuffProfileStore.TryLoad(path, out BuffProfile profile, out string error)) + { + ClearBuffProfile($"[RynthAi] Buff profile '{Path.GetFileNameWithoutExtension(path)}' could not be read ({error}) - using the built-in buff list."); + return; + } + ApplyBuffProfile(profile); + _host.WriteToChat($"[RynthAi] Buffing: profile '{profile.Name}' ({ActiveBuffProfileCount} spell(s)).", 5); + } + + /// Uses 's enabled entries as the buff list (tests call this directly). + internal void ApplyBuffProfile(BuffProfile profile) + { + _profileByKey.Clear(); + var keys = new List(profile.Entries.Count); + foreach (var e in profile.Entries) + { + if (!e.Enabled || string.IsNullOrWhiteSpace(e.Key)) continue; + // One cast per base name: two tiers of the same line would fight over one family. + if (_profileByKey.ContainsKey(e.Key)) continue; + _profileByKey[e.Key] = e; + keys.Add(e.Key); + } + _profileKeys = keys; + ActiveBuffProfileName = profile.Name; + } + + private void ClearBuffProfile(string chatLine) + { + bool had = _profileKeys != null; + _profileKeys = null; + _profileByKey.Clear(); + ActiveBuffProfileName = null; + if (had || chatLine.Contains("could not be read", StringComparison.Ordinal)) + _host.WriteToChat(chatLine, 5); + } + + /// The active profile's base names, or null to use the built-in list. + private List? ProfileBuffList() + { + SyncBuffProfile(); + return _profileKeys is { Count: > 0 } keys ? new List(keys) : null; + } + + /// Casting skill for a buff: the catalog school for profile spells, else by name. + internal AcSkillType SkillFor(string baseName) => + _profileByKey.TryGetValue(baseName, out var e) && e.School.Length > 0 + ? SpellCatalog.SkillForSchool(e.School) + : SkillForBuff(baseName); + + /// + /// Profile spells whose base name has no tier ladder: the best spell of the same family the + /// character knows, capped by the buffing tier for its skill. Self and item spells win over + /// Other ones at the same level. 0 when the spellbook snapshot is cold or nothing is known. + /// + private int ResolveProfileFallback(string baseName, AcSkillType skill) + { + if (!_profileByKey.TryGetValue(baseName, out var entry) || !_spellManager.IsKnownSnapshotWarm) return 0; + + int maxTier = _spellManager.GetHighestBuffSpellTier(skill); + SpellCatalogEntry? best = null; + foreach (var c in SpellCatalog.Family(entry.FamilyId)) + { + if (!c.IsBuff || c.Level > maxTier || !_spellManager.IsKnownSpellId(c.Id)) continue; + if (best == null || Rank(c) > Rank(best)) best = c; + } + if (best != null) return best.Id; + // Family unknown to the catalog: the exact spell picked in the Spells window. + return entry.SpellId != 0 && _spellManager.IsKnownSpellId(entry.SpellId) ? entry.SpellId : 0; + + static long Rank(SpellCatalogEntry c) => + (long)c.Level * 1_000_000 + (c.IsSelf || c.IsItemTarget ? 100_000 : 0) + c.Power; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.HpFailsafe.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.HpFailsafe.cs new file mode 100644 index 0000000..7124cd9 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.HpFailsafe.cs @@ -0,0 +1,266 @@ +// ============================================================================ +// RynthSuite - Combat/BuffManager.HpFailsafe.cs +// The HP failsafe: at or under Emergency Heal At, a character whose heals keep +// failing (refused, fizzled, never sent, or out-healed) must not sit and die. +// +// Measured by health, not by counting heal attempts: a round of FailsafeRoundMs +// with no rise of FailsafeRiseMinPct counts as a failed round (whatever the +// reason: a stuck cast, 'too busy', no mana, no kits). +// 1. FailsafeRoundsToBreak failed rounds: ActionPacer.ForceBreak (a jump; on +// ACE's fast tick it fails the cast in progress, Player.HandleActionJump). +// Starts are held until landed, then the vitals step heals again. +// 2. FailsafeRoundsToRecall more failed rounds after the break: recall to the +// lifestone ("/lifestone", ACE GameAction TeleToLifestone) when +// HpFailsafeRecall is on. The macro is switched off first, because ACE +// cancels the recall when the character moves during its animation and +// refuses it while busy (Player_Location.HandleActionTeleToLifestone). +// 3. No " is recalling to the lifestone." after RecallMaxSends tries +// (ACE refuses the recall while busy, under a PK timer or with recalls +// disabled, which is just the stuck state this is for): the macro is +// switched back on, so the heals and kits run again, and the failsafe +// re-arms; the next recall waits RecallCooldownMs. A failed recall must not +// leave the character standing at low health with nothing running. Only a +// macro the failsafe itself stopped is switched back on, never past a VTank +// yield (MayRestartMacro), and a death drops the pending recall (the player's +// Stop Macro On Death stands). +// Health back over the line (or 100%) ends the episode. Nothing counts in portal space. +// ============================================================================ + +using System; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthAi; + +public partial class BuffManager +{ + internal const double FailsafeRoundMs = 2500; + internal const int FailsafeRoundsToBreak = 3; + internal const int FailsafeRoundsToRecall = 3; + // A rise this large (health %) means a heal landed; natural regeneration is smaller. + private const int FailsafeRiseMinPct = 3; + // The recall goes this long after the macro stop (the stop edge runs on the next tick), + // and is sent again this often, a few times, until our "is recalling to the lifestone" is seen. + private const double RecallFirstDelayMs = 600; + private const double RecallResendMs = 1500; + private const int RecallMaxSends = 3; + /// After a recall that never started, the next one waits this long (the heals run meanwhile). + internal const double RecallCooldownMs = 30_000; + internal const string RecallCommand = "/lifestone"; + + private bool _fsActive; + private DateTime _fsRoundStart; + private int _fsLowHp; + private int _fsFailedRounds; + private bool _fsBroken; + private bool _fsRecallLogged; + private DateTime _fsRecallNotBefore = DateTime.MinValue; + + private bool _recallPending; + private bool _recallSeen; + private int _recallSends; + private DateTime _recallNextAt; + + /// Set by the plugin: the rest of a /ra stop (nav stop, pause cancel) for the recall. + internal Action? MacroStopForRecall { get; set; } + /// Set by the plugin: false when the macro must not be started now (VTank yield). Null = may. + internal Func? MayRestartMacro { get; set; } + + // The macro is off because the failsafe stopped it for a recall (only then does it switch it back on). + private bool _macroStoppedByFailsafe; + private bool _recallNameLogged; + + internal int HpFailsafeBreaks { get; private set; } + internal int HpFailsafeRecalls { get; private set; } + internal int HpFailsafeRecallsFailed { get; private set; } + + private bool Portaling() + { + try { return _host.HasIsPortaling && _host.IsPortaling(); } catch { return false; } + } + + /// Once per heartbeat while the macro runs, before the pacing gate. + private void TickHpFailsafe() + { + int at = _settings.EmergencyHealAt; + if (at <= 0 || _vitals.MaxHealth <= 0 || _recallPending || Portaling()) { ResetHpFailsafe(); return; } + int hp = _vitals.HealthPct; + DateTime now = Now; + if (hp > at || hp >= 100) + { + if (_fsActive && (_fsFailedRounds > 0 || _fsBroken)) + _host.Log($"[Vitals] HP failsafe: health back to {hp}% (over Emergency Heal At {at}%)."); + ResetHpFailsafe(); + return; + } + if (!_fsActive) + { + _fsActive = true; + _fsRoundStart = now; + _fsLowHp = hp; + _fsFailedRounds = 0; + _fsBroken = false; + return; + } + if (hp >= _fsLowHp + FailsafeRiseMinPct) + { + // A heal landed: the heals work, start counting again from here. + _fsLowHp = hp; + _fsRoundStart = now; + _fsFailedRounds = 0; + return; + } + if (hp < _fsLowHp) _fsLowHp = hp; + if ((now - _fsRoundStart).TotalMilliseconds < FailsafeRoundMs) return; + + _fsFailedRounds++; + _fsRoundStart = now; + double failedSec = _fsFailedRounds * FailsafeRoundMs / 1000.0; + if (!_fsBroken) + { + if (_fsFailedRounds < FailsafeRoundsToBreak) return; + string why = $"HP failsafe: health {hp}% at or under Emergency Heal At {at}%, no heal landed in {failedSec:0.#} s"; + bool jumped = ActionPacer.ForceBreak(_host, why); + if (jumped) HpFailsafeBreaks++; + _host.Log($"[Vitals] {why}: {(jumped ? "breaking the cast with a jump, then healing again" : "no jump available (or one under way), healing again")}."); + _fsBroken = true; + _fsFailedRounds = 0; + return; + } + if (_fsFailedRounds < FailsafeRoundsToRecall) return; + if (!_settings.HpFailsafeRecall) + { + if (!_fsRecallLogged) + { + _fsRecallLogged = true; + _host.Log($"[Vitals] HP failsafe: health {hp}%, heals still failing {failedSec:0.#} s after the break; HP Failsafe Recall is off, no recall."); + } + return; + } + if (now < _fsRecallNotBefore) + { + // The last recall never started: heal on and break again, the next recall after the cooldown. + _fsBroken = false; + _fsFailedRounds = 0; + return; + } + StartFailsafeRecall(now, hp, failedSec); + } + + private void ResetHpFailsafe() + { + _fsActive = false; + _fsFailedRounds = 0; + _fsBroken = false; + _fsRecallLogged = false; + } + + private void StartFailsafeRecall(DateTime now, int hp, double failedSec) + { + HpFailsafeRecalls++; + _settings.IsMacroRunning = false; + _macroStoppedByFailsafe = true; + _recallNameLogged = false; + MacroStopForRecall?.Invoke(); + _recallPending = true; + _recallSeen = false; + _recallSends = 0; + _recallNextAt = now.AddMilliseconds(RecallFirstDelayMs); + string line = $"HP failsafe: health {hp}%, heals still failing {failedSec:0.#} s after the break: macro stopped, recalling to the lifestone."; + _host.Log("[Vitals] " + line); + _host.WriteToChat("[RynthAi] " + line, 2); + ResetHpFailsafe(); + } + + /// Every heartbeat, macro running or not: sends a pending recall, or gives up on it. + private void TickFailsafeRecall() + { + if (!_recallPending) return; + DateTime now = Now; + if (_recallSeen) + { + _recallPending = false; + _macroStoppedByFailsafe = false; + _host.Log("[Vitals] HP failsafe: the recall started."); + return; + } + if (_vitals.MaxHealth > 0 && _vitals.CurrentHealth == 0) + { + CancelPendingRecall("dead"); + return; + } + if (_settings.IsMacroRunning) + { + // Someone switched the macro back on: their call, the recall is dropped. + _recallPending = false; + _macroStoppedByFailsafe = false; + _host.Log("[Vitals] HP failsafe: the macro was started again; the recall is dropped."); + return; + } + if (now < _recallNextAt) return; + if (_recallSends >= RecallMaxSends || !_host.HasInvokeChatParser) + { + _recallPending = false; + HpFailsafeRecallsFailed++; + _fsRecallNotBefore = now.AddMilliseconds(RecallCooldownMs); + string why = _host.HasInvokeChatParser + ? $"no recall seen after {_recallSends} tries of {RecallCommand} (refused: busy, a PK timer or recalls disabled)" + : "this engine has no chat parser, so no recall"; + string what; + if (!_macroStoppedByFailsafe) what = "the macro stays as it is"; + else if (MayRestartMacro != null && !MayRestartMacro()) what = "the macro stays off (VTank yield)"; + else + { + _settings.IsMacroRunning = true; // the heals and kits run again; the failsafe re-arms + what = "macro back on to keep healing"; + } + _macroStoppedByFailsafe = false; + string line = $"HP failsafe: {why}: {what}; next recall in {RecallCooldownMs / 1000:0} s at the earliest."; + _host.Log("[Vitals] " + line); + _host.WriteToChat("[RynthAi] " + line, 2); + return; + } + _host.InvokeChatParser(RecallCommand); + _recallSends++; + _recallNextAt = now.AddMilliseconds(RecallResendMs); + } + + /// + /// The plugin's death hold (and a 0-health read): a pending recall is dropped and the macro is + /// left off, so nothing re-sends /lifestone or restarts the macro after the respawn. + /// + internal void CancelPendingRecall(string why) + { + if (!_recallPending) return; + _recallPending = false; + _macroStoppedByFailsafe = false; + _host.Log($"[Vitals] HP failsafe: the pending recall is dropped ({why}); the macro stays off."); + } + + /// OnChatWindowText: " is recalling to the lifestone." while a recall is pending. + private void ObserveRecallLine(string lower) + { + if (!_recallPending || !lower.Contains("is recalling to the lifestone")) return; + string me = ""; + try + { + uint id = unchecked((uint)_host.GetPlayerId()); + if (id != 0 && _host.HasGetObjectName && _host.TryGetObjectName(id, out string n)) me = n ?? ""; + } + catch { me = ""; } + // Someone else's recall ("Bob is recalling to the lifestone.") is not ours. The chat layer + // can drop a line's first letter ("ou cast ..."), so the name may arrive without it. + if (me.Length > 0) + { + string who = lower.Substring(0, lower.IndexOf(" is recalling to the lifestone", StringComparison.Ordinal)).Trim(); + string mine = me.ToLowerInvariant(); + bool ours = who == mine || (who.Length == mine.Length - 1 && who.Length > 0 && mine.EndsWith(who, StringComparison.Ordinal)); + if (!ours) return; + } + else if (!_recallNameLogged) + { + _recallNameLogged = true; + _host.Log("[Vitals] HP failsafe: our name could not be read; any 'is recalling to the lifestone' line is taken as ours."); + } + _recallSeen = true; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.Recharge.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.Recharge.cs new file mode 100644 index 0000000..2d14e29 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.Recharge.cs @@ -0,0 +1,98 @@ +// ============================================================================ +// RynthSuite - Combat/BuffManager.Recharge.cs +// Recharge (VTank's "Recharge" hotkey, /ra recharge): one vitals pass now, with +// the current settings, whether the macro runs or not. +// +// The pass is CheckVitals with the idle lines (Top Off HP / Top Off Stam / Top +// Off Mana) whatever is in range, so a character between fights tops off now +// instead of waiting for the next idle moment; the emergency lines still come +// first. It uses what the vitals step uses (kits, Heal Self / Revitalize / +// Stamina to Mana, listed potions; Stamina to Health at its own line) and does +// one thing: a heal, a stamina or a mana recharge. Nothing under a line: it says +// so and does nothing. +// +// Requested from any thread (chat commands run on AC's thread); the pass runs on +// the next heartbeat (pump thread) once the server has answered the last action +// and no cast or kit is in flight, waiting up to RechargeWaitMs. +// ============================================================================ + +using System; +using System.Threading; + +namespace RynthCore.Plugin.RynthAi; + +public partial class BuffManager +{ + internal const long RechargeWaitMs = 5000; + + private int _rechargeRequested; + private long _rechargeRequestedAt; + + /// Asks for one recharge pass on the next heartbeat. Any thread. + public void RequestRecharge() + { + Interlocked.Exchange(ref _rechargeRequestedAt, Environment.TickCount64); + Interlocked.Exchange(ref _rechargeRequested, 1); + } + + /// A requested pass is waiting to run. + internal bool RechargePending => Volatile.Read(ref _rechargeRequested) != 0; + + /// HeartbeatCore, every tick (macro on or off): runs a requested pass when the character is free. + private void TickRechargeRequest() + { + if (Volatile.Read(ref _rechargeRequested) == 0) return; + long waited = Environment.TickCount64 - Interlocked.Read(ref _rechargeRequestedAt); + + string busy = RechargeBusyReason(); + if (busy.Length > 0) + { + if (waited < RechargeWaitMs) return; + Interlocked.Exchange(ref _rechargeRequested, 0); + _host.WriteToChat($"[RynthAi] Recharge: not done, the character stayed busy ({busy}).", 1); + return; + } + Interlocked.Exchange(ref _rechargeRequested, 0); + _host.WriteToChat("[RynthAi] Recharge: " + RechargeOnceNow(), 1); + } + + /// What holds a recharge pass back right now ("" = nothing). + private string RechargeBusyReason() + { + if (_vitals.MaxHealth <= 0) return "vitals not read yet"; + if (_pendingSpellId != 0) return "a cast is in flight"; + if (KitPending()) return "a kit is in flight"; + if (!PacerAllows(out string why)) return "server answering the last action: " + why; + if (!CastGateWatchdog.CanCastNow(_host.CanCastNow, s => _host.Log(s))) return "a gesture is animating"; + if (BusyCount > 0) return $"busy count {BusyCount}"; + return ""; + } + + /// + /// One vitals pass with the idle (Top Off) lines. Returns what it did, for chat. Pump thread + /// (internal for the host tests). + /// + internal string RechargeOnceNow() + { + int hp = _vitals.HealthPct, st = _vitals.StaminaPct, mn = _vitals.ManaPct; + Func? saved = InCombatOverride; + InCombatOverride = static () => false; // the Top Off lines, monsters or not + bool acted; + try { acted = CheckVitals(); } + finally { InCombatOverride = saved; } + + string vitals = $"health {hp}%, stamina {st}%, mana {mn}%"; + _host.Log($"[RynthAi] Recharge (one pass, Top Off lines): {vitals}; acted={acted} heal={_isHealingSelf} stam={_isRechargingStamina} mana={_isRechargingMana} why='{_vitalWhy}'"); + if (!acted) + { + bool under = hp < _settings.TopOffHP || st < _settings.TopOffStam || mn < _settings.TopOffMana; + return under + ? $"nothing could recharge ({vitals}; Top Off {_settings.TopOffHP}/{_settings.TopOffStam}/{_settings.TopOffMana}%{(_vitalWhy.Length > 0 ? "; " + _vitalWhy : "")})." + : $"nothing to do ({vitals}, all at or over Top Off {_settings.TopOffHP}/{_settings.TopOffStam}/{_settings.TopOffMana}%)."; + } + if (_isHealingSelf) return $"healing ({vitals})."; + if (_isRechargingStamina) return $"restoring stamina ({vitals})."; + if (_isRechargingMana) return $"restoring mana ({vitals})."; + return $"vitals step busy ({vitals})."; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.RecoveryRetry.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.RecoveryRetry.cs new file mode 100644 index 0000000..a2d048a --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.RecoveryRetry.cs @@ -0,0 +1,184 @@ +// ============================================================================ +// RynthSuite - Combat/BuffManager.RecoveryRetry.cs +// Fast retry of the recovery vitals (Heal Self, Stamina to Health, Revitalize, +// Stamina to Mana) after the server's "not enough mana" answer. +// +// ACE (origin/master, Creature_Magic.GetManaCost) rolls Mana Conversion on every +// cast attempt: a trained caster pays between the full cost and 1 mana. The roll +// and the check run before the windup (Player_Magic.CalculateManaUsage), so a +// refusal costs nothing: no mana, no busy period, no recoil, only UseDone 0x401. +// At low mana the cast goes through on a good roll, so trying again soon is the +// way to get it off. Before this, the refusal rested the spell's family (LowManaHealRestSec). +// +// Bounds (the refusal-spam crash class, see the "too busy" handler): the retry +// gap is never under RecoveryRetryMinMs, at most RecoveryRetryMaxPerSecond +// recovery casts go out in any second while an episode is open, and an episode +// stops after RecoveryRetryMaxRefusals mana refusals in a row (any recovery +// spell); the refused family then rests as before (a vital LowManaHealRestSec, 2 s). +// ============================================================================ + +using System; +using System.Collections.Generic; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi; + +public partial class BuffManager +{ + internal const int RecoveryRetryMinMs = 200; + internal const int RecoveryRetryMaxMs = 5000; + internal const int RecoveryRetryMaxPerSecond = 5; + internal const int RecoveryRetryMaxRefusals = 20; + // A refusal this long after the last one starts a new episode; an open episode with no refusal + // for this long ends. Above the slowest retry gap (the setting's 5000 ms maximum) with room for + // the pacing in between, so a slow setting never ends its own episode between two retries. + internal const double RecoveryEpisodeStaleMs = RecoveryRetryMaxMs + 2000; + // Stamina to Mana is attempted only above this stamina % (the CheckVitals and mana floor gates). + private const int RecoveryMinStaminaToConvert = 15; + + private bool _recoveryOpen; + private DateTime _recoveryStartedAt; + private DateTime _recoveryLastRefusalAt; + private int _recoveryRefusals; + private readonly Dictionary _recoveryNextAt = new(); + private readonly List _recoveryNames = new(); + // Recovery casts sent (any time), for the per-second ceiling. + private readonly Queue _recoveryAttempts = new(); + // The base name of the pending vital ("Stamina to Mana Self"...), set by CastVital. + private string _pendingVitalBase = ""; + + /// Recovery casts held by the per-second ceiling (tests, status). + internal int RecoveryRateHolds { get; private set; } + /// The last episode summary line (tests, status). + internal string LastRecoverySummary { get; private set; } = ""; + /// True while a fast-retry episode is open (tests). + internal bool RecoveryRetryOpen => _recoveryOpen; + + internal static bool IsRecoveryVital(string baseName) => + baseName is "Heal Self" or "Stamina to Health Self" or "Revitalize Self" or "Stamina to Mana Self"; + + private int RecoveryRetryMs => Math.Clamp(_settings.RecoveryRetryMs, RecoveryRetryMinMs, RecoveryRetryMaxMs); + + /// + /// Why a fast retry can't help now, or "" when it can. Untrained Mana Conversion pays the full + /// cost every time (GetManaCost returns the base cost), so a retry would only be refused again; + /// trained, the least a cast can cost is 1 mana. + /// + private string RecoveryRetryBlocked(string baseName) + { + if (!IsSkillUsable(AcSkillType.ManaConversion)) return "Mana Conversion not trained (no cost roll)"; + if (_vitals.MaxMana > 0 && _vitals.CurrentMana < 1) return "no mana at all"; + if (baseName == "Stamina to Mana Self" && _vitals.StaminaPct <= RecoveryMinStaminaToConvert) + return $"stamina {_vitals.StaminaPct}% too low to convert"; + if (baseName == "Stamina to Health Self" && _vitals.StaminaPct <= _settings.StaminaToHealthMinStamina) + return $"stamina {_vitals.StaminaPct}% too low to convert"; + return ""; + } + + /// + /// "Not enough mana" for the pending cast. Returns true when it was a recovery vital that will be + /// retried soon (the caller then skips the family rest); false leaves the old handling. + /// + private bool OnRecoveryManaRefusal(SpellInfo? pending) + { + if (pending == null || _pendingSpellId != _pendingVitalSpellId || !IsRecoveryVital(_pendingVitalBase)) + return false; + DateTime now = Now; + if (_recoveryOpen && (now - _recoveryLastRefusalAt).TotalMilliseconds > RecoveryEpisodeStaleMs) + EndRecoveryEpisode(now, "no refusal for a while", success: false, ""); + if (!_recoveryOpen) + { + _recoveryOpen = true; + _recoveryStartedAt = now; + _recoveryRefusals = 0; + _recoveryNames.Clear(); + } + _recoveryRefusals++; + _recoveryLastRefusalAt = now; + if (!_recoveryNames.Contains(pending.Name)) _recoveryNames.Add(pending.Name); + string blocked = RecoveryRetryBlocked(_pendingVitalBase); + if (blocked.Length > 0) + { + EndRecoveryEpisode(now, blocked, success: false, ""); + return false; + } + if (_recoveryRefusals >= RecoveryRetryMaxRefusals) + { + EndRecoveryEpisode(now, $"{_recoveryRefusals} refusals in a row", success: false, ""); + return false; + } + _recoveryNextAt[pending.Family] = now.AddMilliseconds(RecoveryRetryMs); + if (_recoveryRefusals == 1) + _host.Log($"[Vitals] {pending.Name}: not enough mana (mana {_vitals.CurrentMana}); retrying every {RecoveryRetryMs} ms for a Mana Conversion roll (at most {RecoveryRetryMaxPerSecond}/s, {RecoveryRetryMaxRefusals} refusals)."); + return true; + } + + /// A result line for : a retried cast went through. + private void OnRecoveryCastResult(int family, string name) + { + if (_recoveryOpen && _recoveryNextAt.ContainsKey(family)) + EndRecoveryEpisode(Now, "", success: true, name); + } + + private void EndRecoveryEpisode(DateTime now, string why, bool success, string name) + { + if (!_recoveryOpen) return; + _recoveryOpen = false; + _recoveryNextAt.Clear(); + double ms = (now - _recoveryStartedAt).TotalMilliseconds; + string names = string.Join(", ", _recoveryNames); + LastRecoverySummary = success + ? $"[Vitals] {name} went through after {_recoveryRefusals + 1} attempts ({_recoveryRefusals} refused for mana: {names}) in {ms:0} ms." + : $"[Vitals] stopped retrying {names} after {_recoveryRefusals} mana refusals in {ms:0} ms ({why})."; + _host.Log(LastRecoverySummary); + } + + /// + /// Ends an episode with no refusal for RecoveryEpisodeStaleMs (the cast went through unseen, the + /// vital is no longer needed, or something else took over), so a stale one never keeps letting + /// casts past Spell Interval. Once per heartbeat. + /// + private void ExpireRecoveryEpisode() + { + if (_recoveryOpen && (Now - _recoveryLastRefusalAt).TotalMilliseconds > RecoveryEpisodeStaleMs) + EndRecoveryEpisode(Now, $"no refusal for {RecoveryEpisodeStaleMs / 1000:0} s", success: false, ""); + } + + /// + /// The cast interval gate lets a due recovery retry through: the retry gap (RecoveryRetryMs) + /// replaces Spell Interval for it, and the per-second ceiling still applies in CastVital. + /// + private bool RecoveryRetryDue() + { + if (!_recoveryOpen) return false; + DateTime now = Now; + foreach (var at in _recoveryNextAt.Values) + if (now >= at) return true; + return false; + } + + /// CastVital's gate for a recovery vital while an episode is open: "" to cast, else why it waits. + private string RecoveryRetryHolds(int family) + { + if (!_recoveryOpen) return ""; + DateTime now = Now; + if (_recoveryNextAt.TryGetValue(family, out DateTime next) && now < next) + return $"retrying after a mana refusal in {(next - now).TotalMilliseconds:0} ms"; + while (_recoveryAttempts.Count > 0 && (now - _recoveryAttempts.Peek()).TotalMilliseconds >= 1000) + _recoveryAttempts.Dequeue(); + if (_recoveryAttempts.Count >= RecoveryRetryMaxPerSecond) + { + RecoveryRateHolds++; + return $"{RecoveryRetryMaxPerSecond} recovery casts in the last second"; + } + return ""; + } + + private void NoteRecoveryAttempt() + { + DateTime now = Now; + while (_recoveryAttempts.Count > 0 && (now - _recoveryAttempts.Peek()).TotalMilliseconds >= 1000) + _recoveryAttempts.Dequeue(); + _recoveryAttempts.Enqueue(now); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.ScriptHook.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.ScriptHook.cs new file mode 100644 index 0000000..07e1f7b --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.ScriptHook.cs @@ -0,0 +1,133 @@ +using System; +using RynthCore.PluginSdk; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthAi; + +// The heal seam of the script-provided combat hook (RynthAi.Combat, CombatHookInterface.cs): +// CheckVitals asks the script for the heal spell (and its target: the player, or a monster for a +// drain) before kits. The cast itself goes through CastVital, the same steps as Heal Self. +public partial class BuffManager +{ + /// + /// True when the hook handled this vitals check: waiting for the answer, or the answer was + /// cast (or its wand swap is in flight). False = the native order (kit, Heal Self, potion). + /// + private bool TryScriptHeal(int healLine, bool inCombat) + { + // AC just said "You're too busy!": the same pacing as a Heal Self (AttemptVitalCast). + if (DateTime.Now < _busyBackoffUntil && (DateTime.Now - _lastCastAttempt).TotalMilliseconds < BusyHealRetryMs) + { + _vitalWhy = $"AC too busy, waiting {(_busyBackoffUntil - DateTime.Now).TotalMilliseconds:0} ms"; + _healWaitKind = "too-busy backoff"; + return true; + } + + var slot = CombatHook.Heal; + // The request names RynthAi's fight target when it opened (informational: the monster with + // live health data, e.g. for a drain). A fight target change does not re-ask (the heal keeps + // its deadline); the answer's target is checked as things stand when it comes. The + // answer's target 0 still means the player. + var cm = _combatManager; + uint fight = cm == null ? 0u : unchecked((uint)cm.activeTargetId); + var outcome = CombatHook.Step(slot, fight, () => BuildHealRequest(healLine, inCombat), s => _host.Log(s), + out uint spell, out uint target, out _); + switch (outcome) + { + case CombatHook.Outcome.Native: + return false; + case CombatHook.Outcome.Wait: + _vitalWhy = $"waiting for '{CombatHook.Owner}' to choose the heal"; + _healWaitKind = "script choosing the heal"; + return true; + } + + uint player = (uint)_host.GetPlayerId(); + if (target == 0) target = player; + string? why = ScriptHealProblem(spell, target, player); + if (why != null) + { + CombatHook.Reject(slot, why, s => _host.Log(s)); + return false; + } + string name = SpellTableStub.GetById((int)spell)?.Name ?? $"spell {spell}"; + bool handled = CastVital((int)spell, target, LabelHealing, name + " (script)", out bool sent); + if (!handled) + { + CombatHook.Reject(slot, _vitalWhy.Length > 0 ? _vitalWhy : "it couldn't be cast", s => _host.Log(s)); + return false; + } + // A script-chosen heal takes no early nudge (HeldNudgeUrgent): its result can come later + // than RynthAi's own heals' (Vitality Siphon: 2.42-2.75 s after the incantation, 2026-10-10 + // log), or never (a resisted or dead target), and an early nudge steps the character. + if (sent && _cast.Current is { } sentCast && sentCast.SpellId == (int)spell) sentCast.Script = true; + if (sent) ActionPacer.MarkScriptCast((int)spell); // the stuck-cast breaker gives it the same room + // Handled: cast, or a swap step to Magic mode is in flight (the next check asks again). + CombatHook.Cast(slot, sent ? spell : 0, sent ? target : 0, sent ? ActionPacer.LastCastSeqAtSend : -1); + if (sent) _host.Log($"[RynthAi] Vitals: script heal id={spell} '{name}' at 0x{target:X8} (owner '{CombatHook.Owner}')."); + return true; + } + + /// Why the script's heal can't be cast, or null when it can. + private string? ScriptHealProblem(uint spell, uint target, uint player) + { + if (!_spellManager.IsKnownSpellId((int)spell)) return $"spell {spell} isn't known"; + // The refusal memory RynthAi's own heal honours (AttemptVitalCast): a level the server + // said there are no components for. + if (LevelLacksComponents((int)spell)) return $"spell {spell} has no components (refused by the server; RynthAi uses a lower level)"; + if (target == player) return null; + // A heal cast at anything but the player has to take health from the target and give it + // to the caster (a vital transfer: Drain Health, Vitality Siphon...). Any other spell at a + // monster heals or buffs the monster. + if (!IsDrainToCaster((int)spell)) return $"spell {spell} at a monster is not a drain (a heal may target a monster only with a vital transfer to the caster)"; + var cm = _combatManager; + // Monster rule Priority 0 = never attacked: a drain at one is refused too, even when it is + // still the fight target (its rule changed before Think dropped it) or still scanned. + if (cm != null && cm.IsIgnored(unchecked((int)target))) return "the target is ignored (monster rule Priority 0)"; + bool listed = cm != null && unchecked((uint)cm.activeTargetId) == target; + if (!listed && cm != null) + foreach (var t in cm.ScannedTargets) + if (unchecked((uint)t.Id) == target) { listed = true; break; } + if (!listed) return "the target is not the player, the fight target or a scanned monster"; + if (_host.HasObjectIsAttackable && !_host.ObjectIsAttackable(target)) return "the target is not attackable"; + return null; + } + + /// + /// True for a vital transfer from the target to the caster (Drain Health Other, Vitality + /// Siphon, Soul Shroud, Drain Mana/Stamina...), read from the spell catalog: a + /// "...Transfertocaster" family, cast on Other, described as taking the target's vital and + /// giving it to the caster. A spell the catalog doesn't have (a custom server's) counts by its + /// name: "Drain " or "Siphon". + /// + internal static bool IsDrainToCaster(int spellId) + { + SpellCatalog.EnsureLoaded(); + var e = SpellCatalog.Get(spellId); + if (e != null) + return e.FamilyName.EndsWith("Transfertocaster", StringComparison.OrdinalIgnoreCase) + && e.Target.Equals("Other", StringComparison.OrdinalIgnoreCase) + && e.Description.Contains("the target's", StringComparison.OrdinalIgnoreCase) + && e.Description.Contains("to the caster", StringComparison.OrdinalIgnoreCase); + string name = SpellTableStub.GetById(spellId)?.Name ?? ""; + return name.Contains("Drain ", StringComparison.OrdinalIgnoreCase) || name.Contains("Siphon", StringComparison.OrdinalIgnoreCase); + } + + private CombatRequestV1 BuildHealRequest(int healLine, bool inCombat) + { + bool known = _vitals.MaxHealth > 0; + var cm = _combatManager; + float fightHealth = cm?.FightTargetHealthRatio ?? -1f; + return new CombatRequestV1 + { + TargetHealth = fightHealth, + HealthPct = known ? _vitals.HealthPct : -1, + StaminaPct = _vitals.MaxStamina > 0 ? _vitals.StaminaPct : -1, + ManaPct = _vitals.MaxMana > 0 ? _vitals.ManaPct : -1, + HealLine = healLine, + InCombat = inCombat ? 1 : 0, + CombatMode = CurrentCombatMode, + }; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.cs index 15c1682..b9335e1 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffManager.cs @@ -6,7 +6,7 @@ using RynthCore.Plugin.Shared; namespace RynthCore.Plugin.RynthAi; -public class BuffManager : IDisposable +public partial class BuffManager : IDisposable { private readonly RynthCoreHost _host; private readonly LegacyUiSettings _settings; @@ -126,9 +126,10 @@ public class BuffManager : IDisposable // a buff bot's level 8 expiring over our own fresh VI (2026-10-05). Permanent marks an // item-granted entry (no expiry), which CastBuffsOverItemBuffs leaves out. private readonly Dictionary> _familyLiveEntries = new(); - // Highest tier this session has CAST per family (nominal level). The achieved-tier cap - // applies only once the target tier has been tried, so a family deliberately cast low - // first (the tier-7 creature bootstrap before 8s) still upgrades. + // Highest tier CONFIRMED per family since load (nominal level; written on the cast's + // confirmation, so a fizzled or refused try doesn't count). The achieved-tier cap applies + // only once the target tier has gone through, so a family deliberately cast low first (the + // tier-7 creature bootstrap before 8s) still upgrades, and a failed upgrade is retried. private readonly Dictionary _familyAttemptedTier = new(); /// Keyed by (objectId, spellFamily) packed as long. private readonly Dictionary _itemBuffTimers = new(); @@ -144,6 +145,13 @@ public class BuffManager : IDisposable // Force Rebuff cycle tracking — when set, IsBuffActive consults this instead // of the live timer dicts so FR re-casts every spell to align all timers. private readonly HashSet _forceRebuffCastFamilies = new(); + // The level each family CONFIRMED at in this run (the highest), written only where the family + // joins _forceRebuffCastFamilies; an upgrade that fizzles or is refused leaves it alone. + private readonly Dictionary _runConfirmedLevelByFamily = new(); + // The buff cast in flight that is an upgrade (a lower level of its family was on), 0 = none. + // A failed upgrade is not counted or rested; it is cast again at the next opportunity, paced + // like any cast. + private int _pendingUpgradeSpellId; // Per-family diagnostic throttle — last reason string we logged. Suppresses // dup spam when IsBuffActive is polled every tick by NeedsAnyBuff + CheckAndCastSelfBuffs. @@ -262,6 +270,14 @@ public class BuffManager : IDisposable internal Func Clock { get => _cast.Clock; set => _cast.Clock = value; } private DateTime Now => _cast.Now; + // Buff cast chaining (Combat/BuffCastChain.cs): the next buff of a pass goes out + // on the last buff's UseDone(0) without waiting for the recoil animation; refusals counted. + private readonly BuffCastChain _chain = new(); + internal BuffCastChain Chain => _chain; + /// This tick skipped the animation gate (the fast path): only a buff cast may go out. + private bool _fastChainTick; + private string _fastChainWhy = ""; + // Held-cast nudge (2026-10-05): a cast the server holds open (incantation, no result) is // only let go by a movement packet; StopCompletely from a standing character may send none. // Once per held cast: autorun on and straight off again, then no cast for this long. @@ -448,6 +464,19 @@ public class BuffManager : IDisposable return ManaUnderLine(true, out _) && ManaRefillPossible(); } + /// + /// For CombatManager's script hook, before : false when + /// costs more than the character's max mana, so the cost hold would + /// never lift. Same cost source and the same guards as OffensiveCastHold (no hold, no veto: + /// macro off, or max mana unknown); an unknown cost (0) is affordable. + /// + internal bool CanEverAfford(int spellId) + { + if (!_settings.IsMacroRunning || _vitals.MaxMana == 0) return true; + int cost = SpellManaCost(spellId); + return cost <= 0 || cost <= _vitals.MaxMana; + } + /// /// For CombatManager, before an attack or debuff cast: a reason to hold it, or null. Held when /// mana is under the spell's own cost (it would be refused), or under the refill line while @@ -477,13 +506,8 @@ public class BuffManager : IDisposable /// internal bool BuffWaitsForMana(int spellId, string buffName) { - if (_vitals.MaxMana == 0) return false; - int reserve = ManaReserve(); - int cost = SpellManaCost(spellId); + if (!BuffNeedsManaFirst(spellId, out bool cantPay, out int cost)) return false; uint cur = _vitals.CurrentMana; - bool cantPay = cost > 0 && cur < cost; - bool underReserveAfter = reserve > 0 && (long)cur - Math.Max(cost, 0) < reserve; - if (!cantPay && !underReserveAfter) return false; _vitalWhy = ""; if ((StaminaAllowsStaminaToMana() && AttemptVitalCast("Stamina to Mana Self")) || AttemptPotion("ManaPotion")) @@ -502,6 +526,21 @@ public class BuffManager : IDisposable return true; } + /// The reserve test BuffWaitsForMana acts on, with no side effect: true when mana can't + /// pay for the buff () or would be under the reserve after it. + private bool BuffNeedsManaFirst(int spellId, out bool cantPay, out int cost) + { + cantPay = false; + cost = 0; + if (_vitals.MaxMana == 0) return false; + int reserve = ManaReserve(); + cost = SpellManaCost(spellId); + uint cur = _vitals.CurrentMana; + cantPay = cost > 0 && cur < cost; + bool underReserveAfter = reserve > 0 && (long)cur - Math.Max(cost, 0) < reserve; + return cantPay || underReserveAfter; + } + private readonly Dictionary _castIssuedAtByFamily = new(); private readonly Dictionary _expiryAtCastByFamily = new(); private const double AuditSettleMs = 15_000.0; @@ -844,7 +883,7 @@ public class BuffManager : IDisposable { _isForceRebuffing = true; _isAutoBatchRebuff = false; - _forceRebuffCastFamilies.Clear(); + ClearRunFamilies(); _buffFailCooldownUntil.Clear(); // explicit recast-all must not be blocked by stale cooldowns _silentNoShowCounts.Clear(); // give parked families a fresh shot on FR too _unsatisfiedStrikes.Clear(); // ditto for the post-batch satisfaction audit @@ -855,9 +894,11 @@ public class BuffManager : IDisposable _pendingSpellId = 0; _lastCastAttempt = DateTime.MinValue; SaveBuffTimers(); + _chain.PassStart(); _host.WriteToChat("[RynthAi] Starting Force Rebuff...", 5); var list = BuildDynamicBuffList(); + LogFilterSkips(); // the skips of the pass just made _host.Log($"[FR] buff list ({list.Count}): {string.Join(", ", list)}"); _host.Log($"[FR] macroRunning={_settings.IsMacroRunning} liveRefreshed={_liveBuffsRefreshed}"); } @@ -870,6 +911,7 @@ public class BuffManager : IDisposable _isRechargingStamina = false; _isHealingSelf = false; _pendingSpellId = 0; + _chain.PassEnd("cancelled", s => _host.Log(s)); _host.WriteToChat("[RynthAi] Sequence cancelled.", 5); } @@ -1111,10 +1153,20 @@ public class BuffManager : IDisposable LogPostCastDiff(diag); } + // A recall the HP failsafe asked for goes out after the macro stop (BuffManager.HpFailsafe.cs). + TickFailsafeRecall(); + TickRechargeRequest(); // /ra recharge: one vitals pass, macro on or off (BuffManager.Recharge.cs) + if (!_settings.IsMacroRunning) return; // Close casts the server reports finished, and say once when one is being held open. PollCastTracker(); + ObserveBuffChain(); + _fastChainTick = false; + + // Heals failing at Emergency Heal At: break the cast, then recall (BuffManager.HpFailsafe.cs). + TickHpFailsafe(); + if (!_settings.IsMacroRunning) return; // A Magic stance we asked for: watch the client's mode every tick (see ObserveStance). ObserveStance(); @@ -1260,12 +1312,23 @@ public class BuffManager : IDisposable && expiryThen > issuedAt // it was on when we cast && st!.Expiration <= expiryThen.AddSeconds(2)) // and hasn't been refreshed active = false; + // An upgrade is cast over its own lower level, so the family is "on" whatever + // happened, at the give-up as well: it landed only when the entry MOVED (a later + // expiry, or the pending level or higher; an Incantation landing a level low shows + // a lower level, so for one it is the expiry that moves). Unmoved: a no-show. + if (active && _pendingSpellId == _pendingUpgradeSpellId) + { + bool later = _expiryAtCastByFamily.TryGetValue(pendingSpell.Family, out DateTime upThen) + && st!.Expiration > upThen.AddSeconds(2); + bool higher = st!.SpellLevel >= GetSpellLevel(pendingSpell); + active = later || higher; + } if (active) { // During an auto-batch / force-rebuff, IsBuffActive gates on // _forceRebuffCastFamilies (not timers), so the family MUST be // marked cast here or the batch respins this buff forever. - if (_isForceRebuffing) _forceRebuffCastFamilies.Add(pendingSpell.Family); + NoteBuffConfirmed(pendingSpell); _cast.Confirmed(_pendingSpellId, "confirmed in the enchantment registry"); _pendingSpellId = 0; // landed — registry confirms it; advance NoteCastAccepted(); // it went through — end any too-busy backoff @@ -1277,27 +1340,39 @@ public class BuffManager : IDisposable // A WARM snapshot already excludes unknown tiers, so a no-show // is lag/fizzle → retry (NO blacklist). A COLD snapshot has no // other tier-down signal → blacklist this id to drop a tier. - bool cold = !_spellManager.IsKnownSnapshotWarm; - if (cold) _spellManager.MarkSpellUnresolvable(_pendingSpellId); - - // Per-family silent-no-show bookkeeping (the /god loop break). - // Increment regardless of warmth — even the "warm → retry" path - // needs an upper bound, otherwise a buff whose family is in the - // dynamic list but can never actually land loops forever. + // An upgrade's no-show ends that attempt and nothing else: no strike, no 30 min park, + // no blacklist (any of them would delay the next try and the lower level it was cast + // over). Read before EndPendingUpgrade clears the pending upgrade. + bool isUpgrade = _pendingSpellId == _pendingUpgradeSpellId; int fam = pendingSpell.Family; - int noShowCount = _silentNoShowCounts.TryGetValue(fam, out int prev) ? prev + 1 : 1; - _silentNoShowCounts[fam] = noShowCount; - bool parked = false; - if (noShowCount >= SilentNoShowThreshold) + if (isUpgrade) { - _buffFailCooldownUntil[fam] = DateTime.Now + SilentNoShowCooldown; - parked = true; + _host.Log($"[BuffDiag] upgrade '{pendingSpell.Name}' (id={_pendingSpellId}, fam={fam}) not in the live registry after {sinceCastMs:0}ms (the lower level is unchanged): no strike, tried again."); } + else + { + bool cold = !_spellManager.IsKnownSnapshotWarm; + if (cold) _spellManager.MarkSpellUnresolvable(_pendingSpellId); - _host.Log($"[BuffDiag] self-buff '{pendingSpell.Name}' (id={_pendingSpellId}, fam={fam}) absent from live registry after {sinceCastMs:0}ms — " + - (cold ? "cold snapshot → blacklisted, tier-down." : "warm snapshot → retry (lag/fizzle).") + - $" noShows={noShowCount}/{SilentNoShowThreshold}" + - (parked ? $" — family parked {SilentNoShowCooldown.TotalMinutes:0}min." : "")); + // Per-family silent-no-show bookkeeping (the /god loop break). + // Increment regardless of warmth — even the "warm → retry" path + // needs an upper bound, otherwise a buff whose family is in the + // dynamic list but can never actually land loops forever. + int noShowCount = _silentNoShowCounts.TryGetValue(fam, out int prev) ? prev + 1 : 1; + _silentNoShowCounts[fam] = noShowCount; + bool parked = false; + if (noShowCount >= SilentNoShowThreshold) + { + _buffFailCooldownUntil[fam] = DateTime.Now + SilentNoShowCooldown; + parked = true; + } + + _host.Log($"[BuffDiag] self-buff '{pendingSpell.Name}' (id={_pendingSpellId}, fam={fam}) absent from live registry after {sinceCastMs:0}ms — " + + (cold ? "cold snapshot → blacklisted, tier-down." : "warm snapshot → retry (lag/fizzle).") + + $" noShows={noShowCount}/{SilentNoShowThreshold}" + + (parked ? $" — family parked {SilentNoShowCooldown.TotalMinutes:0}min." : "")); + } + EndPendingUpgrade(_pendingSpellId, "no-show"); _pendingSpellId = 0; _onCastResolved?.Invoke("self-buff no-show (registry)"); } @@ -1317,8 +1392,10 @@ public class BuffManager : IDisposable { int stuckId = _pendingSpellId; var stuck = SpellTableStub.GetById(stuckId); + // An upgrade: no strike, park or blacklist, as on the self-buff path. + bool isUpgrade = stuckId == _pendingUpgradeSpellId; bool confirmedKnown = _spellManager.IsKnownSnapshotWarm && _spellManager.IsKnownSpellId(stuckId); - if (!confirmedKnown) + if (!confirmedKnown && !isUpgrade) _spellManager.MarkSpellUnresolvable(stuckId); // 2026-05-25 — per-family silent-no-show bookkeeping on the @@ -1344,7 +1421,7 @@ public class BuffManager : IDisposable // there's no armor to bind to. int fam = stuck?.Family ?? 0; bool parked = false; - if (fam != 0) + if (fam != 0 && !isUpgrade) { int noShowCount = _silentNoShowCounts.TryGetValue(fam, out int prev) ? prev + 1 : 1; _silentNoShowCounts[fam] = noShowCount; @@ -1357,9 +1434,10 @@ public class BuffManager : IDisposable _host.Log($"[BuffChat] NO-CHAT TIMEOUT (armor) pending={stuckId} ('{stuck?.Name}') — no chat in " + $"{NoChatResolveTimeoutMs:0}ms. confirmedKnown={confirmedKnown}. " + - (confirmedKnown ? "Lag/busy — NOT blacklisted." : "Blacklisted → tier-down.") + - (fam != 0 ? $" noShows={_silentNoShowCounts[fam]}/{SilentNoShowThreshold}" : "") + + (isUpgrade ? "An upgrade: no strike, tried again." : confirmedKnown ? "Lag/busy — NOT blacklisted." : "Blacklisted → tier-down.") + + (fam != 0 && !isUpgrade ? $" noShows={_silentNoShowCounts[fam]}/{SilentNoShowThreshold}" : "") + (parked ? $" — family parked {SilentNoShowCooldown.TotalMinutes:0}min." : "")); + EndPendingUpgrade(_pendingSpellId, "no-chat timeout"); _pendingSpellId = 0; _onCastResolved?.Invoke("no-chat timeout (armor)"); } @@ -1368,7 +1446,11 @@ public class BuffManager : IDisposable } } - if ((DateTime.Now - _lastCastAttempt).TotalMilliseconds < _settings.SpellCastIntervalMs) + // A due recovery retry (BuffManager.RecoveryRetry.cs) gets past Spell Interval, for the vitals + // step only: the buffs after it still wait (intervalHeld below). A stale episode ends first. + ExpireRecoveryEpisode(); + bool intervalHeld = (DateTime.Now - _lastCastAttempt).TotalMilliseconds < _settings.SpellCastIntervalMs; + if (intervalHeld && !RecoveryRetryDue()) { Hold("cast interval"); return; @@ -1379,7 +1461,11 @@ public class BuffManager : IDisposable // a buff's enchantment lands before that). Heals keep their priority (ActionPacer's heal // rules). And not while RynthAi still has the character running: the arbiter's stop goes // out this tick, the cast the next one (a stop mid-windup disturbs the cast). - if (!PacerAllows(out string paceWhy)) + // Buff cast chaining (BuffCastChain): right after the server's UseDone(0) for our own last + // buff, the next buff skips the animation gate only (the pacer's gesture hold and the + // engine's cast gate below). Every other gate stays. + _fastChainTick = FastChainNow(); + if (!PacerAllows(out string paceWhy, gestureGate: !_fastChainTick)) { LastBuffSkipReason = "server answering the last action: " + paceWhy; Hold("server answering the last action", paceWhy); @@ -1402,7 +1488,7 @@ public class BuffManager : IDisposable // NeedsAnyBuff and is the sole writer of the "Buffing" string. // A heal goes ahead of a busy count the server has already finished (BusyHoldsHeal); // everything else still waits for the count to drop. - bool gateOpen = CastGateWatchdog.CanCastNow(_host.CanCastNow, s => _host.Log(s)); + bool gateOpen = _fastChainTick || CastGateWatchdog.CanCastNow(_host.CanCastNow, s => _host.Log(s)); bool busyHolds = BusyCount > 0 && !_pacerLetHealAhead // the pacing let this heal go ahead of an unanswered corpse use (its rules) && (ActiveHealLine(_vitals.HealthPct, _vitals.StaminaPct, out _, out _).Length == 0 || BusyHoldsHeal()); @@ -1420,6 +1506,13 @@ public class BuffManager : IDisposable return; } + // Only a recovery retry got past Spell Interval; nothing else goes inside it. + if (intervalHeld) + { + Hold("cast interval"); + return; + } + // The login refresh above held buffs only: the heal had its turn, the buffs wait. if (buffsHeldForRefresh) { @@ -1502,8 +1595,11 @@ public class BuffManager : IDisposable // only on the local gesture, so their UseObject landed while a buff was still // resolving server-side; the "You're too busy!" that drew cleared that buff's // pending state. When one of them acts, no buff cast follows in the same tick. + // Not on a fast-path tick (the animation gate was skipped for a buff cast only): they + // get their turn on the next tick that waited for the animation. DateTime beforeItems = _lastCastAttempt; - try { TryUseBuffItems(); TryMakeRations(); } catch { } + if (!_fastChainTick) + try { TryUseBuffItems(); TryMakeRations(); } catch { } if (_lastCastAttempt != beforeItems) return; if (_settings.EnableBuffing) @@ -1522,7 +1618,8 @@ public class BuffManager : IDisposable // every family would read "active"), and the set must still be // populated — it is what the audit iterates. AuditBatchSatisfied(); - _forceRebuffCastFamilies.Clear(); + ClearRunFamilies(); + _chain.PassEnd("complete", s => _host.Log(s)); _host.WriteToChat(wasAutoBatch ? "[RynthAi] Rebuff complete." : "[RynthAi] Force Rebuff Complete.", 1); } } @@ -1681,6 +1778,15 @@ public class BuffManager : IDisposable // works: no spell, Life Magic untrained, or out of components). if (curHealthPct < hpThreshold) { + // A script holding the heal kind (RynthAi.Combat) is asked first, before kits: a class + // that heals by draining monsters must not have a kit pre-empt it. The emergency step + // above stays native (the safety floor). Waiting for the answer counts as handled; a + // decline, a bad answer or no answer in time falls through to kit, Heal Self, potion. + if (CombatHook.IsActive(RynthAiCombat.KindHeal) && TryScriptHeal(hpThreshold, inCombat)) + { + _isHealingSelf = true; + return true; + } _vitalWhy = ""; bool healed = AttemptHealthKitUse(); string kitWhy = _vitalWhy; @@ -1929,6 +2035,20 @@ public class BuffManager : IDisposable spellId = payable; } } + return CastVital(spellId, (uint)_host.GetPlayerId(), VitalLabel(baseName), baseName, out _); + } + + /// + /// The cast step of a vital spell, shared by AttemptVitalCast (self vitals) and the script + /// hook's heal (a drain at a monster id goes through the same steps): the family park, the + /// wand swap / Magic stance, the pending-vital bookkeeping (confirmed by chat; released with + /// no strike when the line is late) and the heal latency. Returns "handled" as + /// AttemptVitalCast does (true also while a swap step is in flight); + /// says whether the cast actually went out. + /// + private bool CastVital(int spellId, uint targetId, string label, string what, out bool sent) + { + sent = false; // Parked after a hard server refusal (see OnChatWindowText) — the same // per-family cooldown the buff selectors honour. int family = SpellTableStub.GetById(spellId)?.Family ?? 0; @@ -1936,9 +2056,12 @@ public class BuffManager : IDisposable && _buffFailCooldownUntil.TryGetValue(family, out DateTime coolUntil) && DateTime.Now < coolUntil) return VitalNo($"parked for {(coolUntil - DateTime.Now).TotalSeconds:0} s more after a refusal or no-show"); + // A recovery vital retried after a mana refusal: its retry gap and the per-second ceiling. + if (IsRecoveryVital(what) && RecoveryRetryHolds(family) is { Length: > 0 } recoveryWhy) + return VitalNo(recoveryWhy); if (CurrentCombatMode != CombatMode.Magic && DateTime.Now < _vitalSwapBlockedUntil) return VitalNo("wand swap blocked, retrying shortly"); - bool urgentHeal = baseName is "Heal Self" or "Stamina to Health Self" && HealIsUrgent(_vitals.HealthPct, _vitals.StaminaPct); + bool urgentHeal = label == LabelHealing && HealIsUrgent(_vitals.HealthPct, _vitals.StaminaPct); if (!EnsureMagicMode(urgentHeal: urgentHeal)) { if (!_magicModeBlocked) { _healWaitKind = "wand swap / Magic stance"; return true; } // a swap step is in flight: yield the tick @@ -1952,21 +2075,24 @@ public class BuffManager : IDisposable // strike. Mirror the buff path: not handled, so the potion gets its turn. _pendingSpellId = spellId; _pendingVitalSpellId = spellId; // instant: confirmed by chat, never by the registry - _pendingVitalLabel = VitalLabel(baseName); - bool castOk = _host.CastSpellFor((uint)_host.GetPlayerId(), spellId, "Buff", - SpellTableStub.GetById(spellId)?.Name ?? baseName); + _pendingVitalLabel = label; + _pendingVitalBase = what; + bool castOk = _host.CastSpellFor(targetId, spellId, "Buff", + SpellTableStub.GetById(spellId)?.Name ?? what); _lastCastAttempt = DateTime.Now; if (!castOk) { _pendingSpellId = 0; return VitalNo($"the client refused the cast (spell {spellId})"); } + sent = true; + if (IsRecoveryVital(what)) NoteRecoveryAttempt(); NoteCastIssued(spellId); if (_pendingVitalLabel == LabelMana) _manaStarvedLogged = false; // the next starved spell logs again if (_pendingVitalLabel == LabelHealing) { _healSpellIds.Add(spellId); - _healLatency.HealSent(Now, baseName); + _healLatency.HealSent(Now, what); } return true; } @@ -2154,9 +2280,13 @@ public class BuffManager : IDisposable if (!ignoreMinSuccess && !KitChanceOk(kit.Id, kit.Name ?? "", missing, _settings.PeaceModeForKits)) return VitalNo($"{kit.Name} under Kit Min Success %"); if (_settings.PeaceModeForKits && mode != CombatMode.NonCombat && _host.HasChangeCombatMode) { - _host.ChangeCombatModeFor(CombatMode.NonCombat, "Buff", "peace mode for the healing kit"); - _lastCastAttempt = DateTime.Now; - _healWaitKind = "peace mode for the kit"; + // Only a request that went out starts the wait: a refusal (the engine turns stance changes away + // around a teleport) leaves no pacing state, so the next tick asks again. + if (_host.ChangeCombatModeFor(CombatMode.NonCombat, "Buff", "peace mode for the healing kit")) + { + _lastCastAttempt = DateTime.Now; + _healWaitKind = "peace mode for the kit"; + } return true; // use the kit next tick, once in peace mode } @@ -2187,8 +2317,8 @@ public class BuffManager : IDisposable if (!KitChanceOk(kit.Id, kit.Name ?? "", missing, _settings.PeaceModeForKits)) return false; if (_settings.PeaceModeForKits && mode != CombatMode.NonCombat && _host.HasChangeCombatMode) { - _host.ChangeCombatModeFor(CombatMode.NonCombat, "Buff", "peace mode for the stamina kit"); - _lastCastAttempt = DateTime.Now; + if (_host.ChangeCombatModeFor(CombatMode.NonCombat, "Buff", "peace mode for the stamina kit")) + _lastCastAttempt = DateTime.Now; return true; // use the kit next tick, once in peace mode } uint playerId = _host.GetPlayerId(); @@ -2392,7 +2522,7 @@ public class BuffManager : IDisposable DateTime now = DateTime.Now; foreach (string buffBaseName in desiredBuffs) { - AcSkillType castSkill = SkillForBuff(buffBaseName); + AcSkillType castSkill = SkillFor(buffBaseName); if (!IsSkillUsable(castSkill)) continue; int spellId = FindBestSpellId(buffBaseName, castSkill); if (spellId == 0) continue; @@ -2441,7 +2571,9 @@ public class BuffManager : IDisposable // cooldowns are short-lived (120s) so they expire on their own. _isForceRebuffing = true; _isAutoBatchRebuff = true; - _forceRebuffCastFamilies.Clear(); + ClearRunFamilies(); + _chain.PassStart(); + LogFilterSkips(); } List desiredBuffs = BuildDynamicBuffList(); @@ -2449,7 +2581,7 @@ public class BuffManager : IDisposable foreach (string buffBaseName in desiredBuffs) { - AcSkillType castSkill = SkillForBuff(buffBaseName); + AcSkillType castSkill = SkillFor(buffBaseName); if (!IsSkillUsable(castSkill)) { LastBuffSkipReason = $"skill not usable: {buffBaseName} ({castSkill})"; @@ -2509,9 +2641,24 @@ public class BuffManager : IDisposable // spent mana spell by spell down to 6%, under Stamina to Mana's cost, and he stood there // until regen reached it). A buff that would leave mana under the reserve waits for // Stamina to Mana first; when even that can't be paid for, buffing waits for regen. + // On the fast path (no animation gate) nothing but the buff may go out: when the reserve + // would send Stamina to Mana instead, the fast path is dropped for this buff and the next + // tick goes through the animation gate, where BuffWaitsForMana sends it. + if (_fastChainTick && BuffNeedsManaFirst(spellId, out _, out _)) + { + _fastChainTick = false; + _chain.HoldForAnimation(); + LastBuffSkipReason = "mana reserve before " + buffBaseName + ": Stamina to Mana waits for the animation"; + return true; + } if (BuffWaitsForMana(spellId, buffBaseName)) return true; + // An upgrade replaces this family's active lower level (read before the cast is recorded). + var spellInfo = SpellTableStub.GetById(spellId); + int upgradeTo = spellInfo == null ? 0 : IsItemEnchantment(spellInfo.Name) ? GetSpellLevel(spellInfo) : EffectiveTargetLevel(spellInfo); + int upgradeFrom = spellInfo != null && buffFamily != 0 ? ActiveLevelBelow(buffFamily, upgradeTo) : 0; + _pendingSpellId = spellId; if (buffFamily != 0) { @@ -2520,9 +2667,13 @@ public class BuffManager : IDisposable _expiryAtCastByFamily[buffFamily] = CurrentExpiryFor(buffFamily); } - var spellInfo = SpellTableStub.GetById(spellId); if (spellInfo != null) _host.WriteToChat($"[RynthAi] Casting: {spellInfo.Name}", 5); + if (upgradeFrom > 0 && spellInfo != null) + { + BuffUpgrades++; + _host.Log($"[Buff] upgrade: {buffBaseName} level {upgradeFrom} -> {upgradeTo} ({spellInfo.Name}){(_isForceRebuffing ? " in this buff run" : "")}"); + } // NOTE: timers are recorded ONLY on chat confirmation ("you cast X"), // never optimistically here. An optimistic item-timer at cast time // left a phantom 1h "active" buff whenever a cast silently failed @@ -2530,19 +2681,27 @@ public class BuffManager : IDisposable // buffed when it wasn't and never retried the known tier. if (diagnose) _host.Log($"[FR] CAST '{buffBaseName}' resolvedSpellId={spellId} (pending now set)"); + bool fast = _fastChainTick; + if (fast) + _host.Log($"[BuffChain] '{spellInfo?.Name ?? buffBaseName}' goes without waiting for the animation: {_fastChainWhy}"); + int seqAtSend = UseDoneSeqNow(); bool castOk = _host.CastSpellFor((uint)_host.GetPlayerId(), spellId, "Buff", spellInfo?.Name ?? buffBaseName); _lastCastAttempt = DateTime.Now; - if (castOk) NoteCastIssued(spellId); - if (castOk && buffFamily != 0 && spellInfo != null) + if (castOk) { - // Highest tier cast per family this session: IsBuffActive's landed-tier cap only - // applies once the target tier has been tried. - int castLevel = GetSpellLevel(spellInfo); - if (!_familyAttemptedTier.TryGetValue(buffFamily, out int prevAttempt) || castLevel > prevAttempt) - _familyAttemptedTier[buffFamily] = castLevel; + NoteCastIssued(spellId); + _chain.Sent(spellId, spellInfo?.Name ?? buffBaseName, seqAtSend, ActionPacer.Started, ActionPacer.AttacksSent, MoveAudit.MovementSends, fast); } + else + { + _chain.ClientRefused(spellId, spellInfo?.Name ?? buffBaseName, fast, s => _host.Log(s)); + } + // An upgrade in flight (its registry check and no-show handling differ; EndPendingUpgrade + // ends it on a failure). + _pendingUpgradeSpellId = upgradeFrom > 0 ? spellId : 0; if (!castOk) { + EndPendingUpgrade(spellId, "the client refused it"); // retried after SpellCastIntervalMs (_lastCastAttempt is set above) // Local CastSpell rejected — packet never went out, so no chat // will ever arrive. Clear the gate immediately so the cycle // doesn't hang on this spell. (No timer to undo — we no longer @@ -2556,8 +2715,14 @@ public class BuffManager : IDisposable return false; } - private int FindBestSpellId(string baseName, AcSkillType skill) - => _spellManager.GetDynamicSelfBuffId(baseName, skill); + /// Casts that replaced an active buff of the same family at a lower level (tests, status). + internal int BuffUpgrades { get; private set; } + + internal int FindBestSpellId(string baseName, AcSkillType skill) + { + int id = _spellManager.GetDynamicSelfBuffId(baseName, skill); + return id != 0 ? id : ResolveProfileFallback(baseName, skill); + } // True for enchantments that live on an ITEM (armor or weapon), NOT on the // player. These do NOT appear in ReadPlayerEnchantments, so they must be @@ -2584,7 +2749,8 @@ public class BuffManager : IDisposable }; foreach (string s in itemSpells) if (name.IndexOf(s, StringComparison.OrdinalIgnoreCase) >= 0) return true; - return false; + // Buff profiles can hold server-custom item spells the names above don't cover. + return SpellCatalog.IsItemSchoolBuff(name); } /// @@ -2775,7 +2941,11 @@ public class BuffManager : IDisposable // to their own timers. if (_isForceRebuffing) { - if (_forceRebuffCastFamilies.Contains(targetSpell.Family)) return true; + // Cast this run: done, unless a strictly higher level is castable now than the one this + // run cast (the priority buffs landed and raised the skill, or a higher spell was + // learned). Never lower: a skill that dropped leaves the run's cast alone. + if (_forceRebuffCastFamilies.Contains(targetSpell.Family)) + return !(CastLevelThisRun(targetSpell.Family) is int ran && ran > 0 && GetSpellLevel(targetSpell) > ran); if (!_isAutoBatchRebuff) return false; rebufferSecOverride = Math.Max(_settings.RebuffTopOffSecondsRemaining, _settings.RebuffSecondsRemaining); } @@ -2838,11 +3008,7 @@ public class BuffManager : IDisposable // skill reaches 8) landed at exactly what was cast; capping it there kept those // three at 7 while everything after them went to 8. No attempt recorded (fresh // login) keeps the cap, so a relog doesn't recast every capped Incantation. - int effectiveTarget = targetLevel; - bool triedLowerOnly = _familyAttemptedTier.TryGetValue(targetSpell.Family, out int attempted) && attempted < targetLevel; - if (!triedLowerOnly - && _familyAchievedTier.TryGetValue(targetSpell.Family, out int achieved) && achieved < effectiveTarget) - effectiveTarget = achieved; + int effectiveTarget = EffectiveTargetLevel(targetSpell); if (timer.SpellLevel < effectiveTarget) { @@ -2880,6 +3046,80 @@ public class BuffManager : IDisposable return false; } + /// The level this force/batch run CONFIRMED at, 0 = none confirmed. + private int CastLevelThisRun(int family) + => _runConfirmedLevelByFamily.TryGetValue(family, out int level) ? level : 0; + + private void ClearRunFamilies() + { + _forceRebuffCastFamilies.Clear(); + _runConfirmedLevelByFamily.Clear(); + } + + /// + /// A buff cast went through (chat, enchantment event or registry): the highest level confirmed + /// per family since load (the landed-tier cap's "tried" mark, so a failed upgrade is retried), + /// and in a force/batch run the family is done at that level. + /// + private void NoteBuffConfirmed(SpellInfo spell) + { + int level = GetSpellLevel(spell); + if (!_familyAttemptedTier.TryGetValue(spell.Family, out int prev) || level > prev) + _familyAttemptedTier[spell.Family] = level; + // The pending upgrade (or better) landed. + if (_pendingUpgradeSpellId != 0 && SpellTableStub.GetById(_pendingUpgradeSpellId) is { } up + && up.Family == spell.Family && level >= GetSpellLevel(up)) + _pendingUpgradeSpellId = 0; + if (!_isForceRebuffing) return; + _forceRebuffCastFamilies.Add(spell.Family); + if (!_runConfirmedLevelByFamily.TryGetValue(spell.Family, out int ran) || level > ran) + _runConfirmedLevelByFamily[spell.Family] = level; + } + + /// + /// The pending upgrade cast did not take (fizzle, refusal, no mana, + /// no-show): it is no longer pending, and it is cast again at the next opportunity. No try cap, + /// and no rest after a fizzle, a client refusal or a no-show; a server mana or component refusal + /// still rests the family as it does for any buff. + /// + private void EndPendingUpgrade(int spellId, string why) + { + if (spellId == 0 || spellId != _pendingUpgradeSpellId) return; + _pendingUpgradeSpellId = 0; + _host.Log($"[Buff] upgrade to {SpellTableStub.GetById(spellId)?.Name ?? spellId.ToString()} did not take ({why}); cast again at the next opportunity."); + } + /// + /// The level IsBuffActive holds a player buff to: the target spell's level, capped at the + /// highest level that family has landed at, once the target level has been confirmed and + /// saw it land lower (Incantations that land skill-capped). + /// + private int EffectiveTargetLevel(SpellInfo targetSpell) + { + int targetLevel = GetSpellLevel(targetSpell); + bool triedLowerOnly = _familyAttemptedTier.TryGetValue(targetSpell.Family, out int attempted) && attempted < targetLevel; + if (!triedLowerOnly && _familyAchievedTier.TryGetValue(targetSpell.Family, out int achieved) && achieved < targetLevel) + return achieved; + return targetLevel; + } + + /// + /// The level of that is on now (this run's confirmed cast during a + /// force/batch run, else a live timer or an item spell with time left), when it is below + /// ; 0 otherwise. A cast that replaces it is an upgrade. + /// + private int ActiveLevelBelow(int family, int newLevel) + { + int on = 0; + if (_isForceRebuffing && _forceRebuffCastFamilies.Contains(family)) on = CastLevelThisRun(family); + else if (_ramBuffTimers.TryGetValue(family, out RamTimerInfo? t) + && !(t.IsPermanent && _settings.CastBuffsOverItemBuffs) + && (t.IsPermanent || t.Expiration > DateTime.Now)) + on = t.SpellLevel; + else if (_itemSpellTimers.TryGetValue(family, out ItemSpellRecord? it) && it.ExpiresAt > DateTime.Now) + on = it.SpellLevel; + return on > 0 && on < newLevel ? on : 0; + } + /// True when the last live read holds an entry in at /// or above with more than left /// (a permanent one counts unless CastBuffsOverItemBuffs is on: then only our timed @@ -3313,7 +3553,7 @@ public class BuffManager : IDisposable foreach (string baseName in desiredBuffs) { - AcSkillType skill = SkillForBuff(baseName); + AcSkillType skill = SkillFor(baseName); if (!IsSkillUsable(skill)) continue; // Skill summary line — print once per unique skill. @@ -3371,11 +3611,213 @@ public class BuffManager : IDisposable } } + // What the character's weapons allow (BuildDynamicBuffList's weapon-aura filter). + // Physical = a melee or missile weapon is listed or wielded; Caster = a wand/staff/orb is listed, + // wielded, or (WieldUnlistedWandWhenNoneListed) in the pack; Unknown = something listed that the + // object cache can't classify (nothing is filtered then). + internal readonly record struct ListedWeaponKit(bool Physical, bool Caster, bool Unknown); + + // The kit is read from the object cache (a pack walk), so it is kept for KitTtlMs and + // recomputed early when the Items list (its reference or length), the unlisted-wand setting or + // the cache changes. A weapon swap shows within the TTL. + private ListedWeaponKit _kit; + private long _kitAt = long.MinValue / 2; + private List? _kitRules; + private int _kitRuleCount; + private bool _kitUnlisted; + private WorldObjectCache? _kitCache; + private const long KitTtlMs = 1000; + /// Clock (ms) for the kit's TTL; tests replace it. + internal Func KitClockMs = () => Environment.TickCount64; + /// Times the kit was actually computed (tests). + internal int KitComputations { get; private set; } + + internal ListedWeaponKit ListedWeapons() + { + long now = KitClockMs(); + var rules = _settings.ItemRules; + bool unlisted = _settings.WieldUnlistedWandWhenNoneListed; + if (ReferenceEquals(rules, _kitRules) && rules.Count == _kitRuleCount && unlisted == _kitUnlisted + && ReferenceEquals(_worldObjectCache, _kitCache) && now >= _kitAt && now - _kitAt < KitTtlMs) + return _kit; + _kit = ComputeListedWeapons(); + _kitAt = now; + _kitRules = rules; + _kitRuleCount = rules.Count; + _kitUnlisted = unlisted; + _kitCache = _worldObjectCache; + KitComputations++; + return _kit; + } + + private ListedWeaponKit ComputeListedWeapons() + { + var cache = _worldObjectCache; + if (cache == null) return new ListedWeaponKit(false, false, true); // no cache yet: can't tell, don't filter + bool physical = false, caster = false, unknown = false; + List rules; + try { rules = new List(_settings.ItemRules); } + catch { return new ListedWeaponKit(false, false, true); } // list edited mid-copy: don't filter this pass + foreach (var r in rules) + { + if (WeaponList.IsShieldRule(r)) continue; // a shield is neither + var wo = cache[r.Id]; + if (wo == null) { unknown = true; continue; } + if (!IsKnownWeaponClass(wo)) wo = cache.RefreshIdentity(wo); // blank name / Unknown class + if (!IsKnownWeaponClass(wo)) wo = cache.ReclassifyFromItemType(r.Id) ?? wo; // a stuck name-based guess + if (WorldObjectCache.IsAmmo(wo)) continue; // arrows are no weapon + if (wo.ObjectClass == AcObjectClass.MeleeWeapon || wo.ObjectClass == AcObjectClass.MissileWeapon) physical = true; + else if (WeaponList.IsWand(wo)) caster = true; + else if (wo.ObjectClass == AcObjectClass.Armor) continue; // a shield filed without the Shield action + else unknown = true; // still unclassified: don't filter on it + } + try + { + // What is in hand counts too (CombatManager.InHandWeaponId's rules: not ammo, not the off hand). + foreach (var wo in cache.GetDirectInventory(forceRefresh: true)) + { + if (WorldObjectCache.IsAmmo(wo)) continue; + if ((wo.Values(LongValueKey.CurrentWieldedLocation, 0) & OffhandRules.ShieldSlot) != 0) continue; + bool phys = wo.ObjectClass == AcObjectClass.MeleeWeapon || wo.ObjectClass == AcObjectClass.MissileWeapon; + bool wand = !phys && WeaponList.IsWand(wo); + if (!phys && !wand) continue; + if (!WorldObjectCache.IsWieldedByPlayer(_host, wo)) continue; + if (phys) physical = true; else caster = true; + } + // No wand listed or in hand, but buffing may wield one from the pack (WieldUnlistedWandWhenNoneListed, + // WeaponList.FindWand's unlisted branch: a WandStaffOrb by object class): that wand counts as a caster. + if (!caster && _settings.WieldUnlistedWandWhenNoneListed) + foreach (var wo in cache.GetInventory()) + if (wo.ObjectClass == AcObjectClass.WandStaffOrb) { caster = true; break; } + } + catch { unknown = true; } + return new ListedWeaponKit(physical, caster, unknown); + } + + private static bool IsKnownWeaponClass(WorldObject wo) => + wo.ObjectClass == AcObjectClass.MeleeWeapon || wo.ObjectClass == AcObjectClass.MissileWeapon + || wo.ObjectClass == AcObjectClass.WandStaffOrb || wo.ObjectClass == AcObjectClass.Armor + || WorldObjectCache.IsAmmo(wo); + + /// Why a weapon aura is left out for this kit, or "" when it stays. + internal static string WeaponAuraSkipReason(string buff, ListedWeaponKit kit) + { + if (kit.Unknown) return ""; + switch (buff) + { + case "Blood Drinker Self": + case "Heart Seeker Self": + case "Swift Killer Self": + return kit.Physical ? "" : "no melee or missile weapon listed"; + case "Spirit Drinker Self": + case "Hermetic Link Self": + return kit.Caster ? "" : "no wand listed"; + case "Defender Self": + return kit.Physical || kit.Caster ? "" : "no weapon or wand listed"; + default: + return ""; + } + } + + // Buffs BuildDynamicBuffList left out on its last pass, with the reason. Replaced (never edited) + // only when the content changes, so a reader on another thread (the settings face) never sees it + // change under it, and the summary text is rebuilt only then. + private IReadOnlyList<(string Buff, string Reason)> _filterSkips = Array.Empty<(string, string)>(); + private string _filterSummary = ""; + public IReadOnlyList<(string Buff, string Reason)> FilterSkips => _filterSkips; + private DateTime _filterSkipLoggedAt = DateTime.MinValue; + private string _filterSkipLoggedSummary = ""; + private const double FilterSkipLogMinSec = 30; + private const int SummaryNamesPerReason = 5; + + private void SetFilterSkips(List<(string Buff, string Reason)> skips) + { + var old = _filterSkips; + bool same = old.Count == skips.Count; + for (int i = 0; same && i < skips.Count; i++) same = old[i] == skips[i]; + if (same) return; + _filterSkips = skips.Count == 0 ? Array.Empty<(string, string)>() : skips; + _filterSummary = BuildSummary(skips); + } + + /// "skill untrained: A, B, C, D, E (+12 more); no melee or missile weapon listed: Blood Drinker, Heart Seeker". + internal static string BuildSummary(IReadOnlyList<(string Buff, string Reason)> skips) + { + if (skips.Count == 0) return ""; + var order = new List(); + var byReason = new Dictionary>(); + foreach (var (buff, reason) in skips) + { + if (!byReason.TryGetValue(reason, out var names)) { byReason[reason] = names = new List(); order.Add(reason); } + names.Add(ShortName(buff)); + } + var groups = new List(order.Count); + foreach (string reason in order) + { + var names = byReason[reason]; + string shown = string.Join(", ", names.GetRange(0, Math.Min(SummaryNamesPerReason, names.Count))); + if (names.Count > SummaryNamesPerReason) shown += $" (+{names.Count - SummaryNamesPerReason} more)"; + groups.Add($"{reason}: {shown}"); + } + return string.Join("; ", groups); + } + + private static string ShortName(string buff) + { + foreach (string suffix in new[] { " Self", " Mastery" }) + if (buff.EndsWith(suffix, StringComparison.Ordinal)) buff = buff.Substring(0, buff.Length - suffix.Length); + return buff; + } + + /// The skipped buffs grouped by reason, or "". + public string FilterSkipSummary() => _filterSummary; + + // One line per buff run (Force Rebuff, or the automatic batch starting). Same content as the + // last line is held back for FilterSkipLogMinSec; different content prints at once. Reads the + // skips of the BuildDynamicBuffList pass the caller just made. + private void LogFilterSkips() + { + string summary = _filterSummary; + if (summary.Length == 0) return; + var now = DateTime.Now; + if (summary == _filterSkipLoggedSummary && (now - _filterSkipLoggedAt).TotalSeconds < FilterSkipLogMinSec) return; + _filterSkipLoggedAt = now; + _filterSkipLoggedSummary = summary; + _host.WriteToChat($"[RynthAi] Buff run skips {_filterSkips.Count} buff(s) this character can't use - {summary}", 1); + _host.Log($"[Buff] filter skips: {summary}"); + } internal List BuildDynamicBuffList() { + // A chosen buff profile (Loaded Files -> Buffs) replaces the built-in list. The player + // picked every buff in it, so the unusable-buff filter (SkipUnusableBuffs) leaves it alone + // and there are no skips to report. + var profile = ProfileBuffList(); + if (profile != null) + { + SetFilterSkips(new List<(string Buff, string Reason)>()); + return profile; + } + var builtIn = BuildBuiltInBuffList(out var skips); + SetFilterSkips(skips); + return builtIn; + } + + /// + /// Buffing's built-in list (no buff profile chosen): creature mastery, Focus, Willpower and + /// Life Magic Mastery first, the other creature buffs for usable skills, life protections, + /// weapon auras, armor banes. Pump thread: it reads the character's skills. + /// + internal List BuildBuiltInBuffList() => BuildBuiltInBuffList(out _); + + /// What SkipUnusableBuffs (and untrained skills) left out, with the reason. + private List BuildBuiltInBuffList(out List<(string Buff, string Reason)> skips) + { + bool filter = _settings.SkipUnusableBuffs; + skips = new List<(string Buff, string Reason)>(); var step1_CreatureMastery = new List(); var step2_Focus = new List(); var step3_Willpower = new List(); + var step3b_LifeMastery = new List(); var step4_OtherCreature = new List(); var step5_LifeAndItem = new List(); var step6_WeaponAuras = new List(); @@ -3390,13 +3832,18 @@ public class BuffManager : IDisposable foreach (var kvp in CreatureSkillBuffs) { - if (IsSkillUsable(kvp.Key)) + if (!IsSkillUsable(kvp.Key)) { - if (kvp.Value.Contains("Creature Enchantment Mastery")) - step1_CreatureMastery.Add(kvp.Value); - else if (!BaseCreatureBuffs.Contains(kvp.Value)) - step4_OtherCreature.Add(kvp.Value); + // Always left out (no skill, no mastery to cast); the setting only decides whether it is reported. + if (filter && !BaseCreatureBuffs.Contains(kvp.Value)) skips.Add((kvp.Value, "skill untrained")); + continue; } + if (kvp.Value.Contains("Creature Enchantment Mastery")) + step1_CreatureMastery.Add(kvp.Value); + else if (kvp.Value == "Life Magic Mastery") + step3b_LifeMastery.Add(kvp.Value); + else if (!BaseCreatureBuffs.Contains(kvp.Value)) + step4_OtherCreature.Add(kvp.Value); } step5_LifeAndItem.AddRange(new List { @@ -3407,10 +3854,22 @@ public class BuffManager : IDisposable "Bludgeoning Protection Self" }); - step6_WeaponAuras.AddRange(new List { + var allAuras = new[] { "Blood Drinker Self", "Hermetic Link Self", "Heart Seeker Self", "Spirit Drinker Self", "Swift Killer Self", "Defender Self" - }); + }; + if (filter) + { + var kit = ListedWeapons(); + foreach (string aura in allAuras) + { + string why = WeaponAuraSkipReason(aura, kit); + if (why.Length == 0) step6_WeaponAuras.Add(aura); + else skips.Add((aura, why)); + } + } + else + step6_WeaponAuras.AddRange(allAuras); step7_ArmorBanes.AddRange(new List { "Impenetrability", "Acid Bane", "Blade Bane", "Bludgeoning Bane", @@ -3421,6 +3880,7 @@ public class BuffManager : IDisposable final.AddRange(step1_CreatureMastery); final.AddRange(step2_Focus); final.AddRange(step3_Willpower); + final.AddRange(step3b_LifeMastery); // the four that raise casting skill and mana come first final.AddRange(step4_OtherCreature); final.AddRange(step5_LifeAndItem); final.AddRange(step6_WeaponAuras); @@ -3430,7 +3890,10 @@ public class BuffManager : IDisposable // the cast loop never casts them and NeedsAnyBuff never waits on them: a skipped buff // can't hold the bot in Buffing. if (_settings.DisabledBuffs.Count > 0) + { final.RemoveAll(_settings.IsBuffDisabled); + skips.RemoveAll(s => _settings.IsBuffDisabled(s.Buff)); // the player already turned these off + } return final; } @@ -3460,7 +3923,7 @@ public class BuffManager : IDisposable // same pump tick, and that chat handler only marks the force-rebuff family // while _pendingSpellId is still set. Clearing pending here without marking // it would make an auto-batch respin this buff forever. - if (_isForceRebuffing) _forceRebuffCastFamilies.Add(pendingSpell.Family); + NoteBuffConfirmed(pendingSpell); _cast.Confirmed(_pendingSpellId, "enchantment landed"); _pendingSpellId = 0; NoteCastAccepted(); @@ -3517,7 +3980,11 @@ public class BuffManager : IDisposable public void OnChatWindowText(string text, int chatType) { string lower = text.ToLowerInvariant(); + ObserveRecallLine(lower); + // A scroll read that taught a spell (ACE: "The scroll is destroyed."): read the spellbook on + // the next buff check, so a newly learned higher level is cast (an upgrade) at once. + if (text.Trim() == "The scroll is destroyed.") _spellManager.InvalidateKnownSpells(); // Diagnostic: log every chat seen while waiting on a cast confirmation, // so we can see what AC is actually emitting and adjust our matchers. @@ -3592,6 +4059,8 @@ public class BuffManager : IDisposable SaveBuffTimers(); } _host.Log($"[BuffChat] PARKED pending={_pendingSpellId} — AC too busy (cast gesture in progress); throttle kept, backing off before re-issue."); + if (_pendingSpellId != _pendingVitalSpellId) + _chain.TooBusyLine(_pendingSpellId, s => _host.Log(s)); } if (!pendingRunning) _pendingSpellId = 0; @@ -3667,6 +4136,7 @@ public class BuffManager : IDisposable } _host.Log($"[BuffChat] CLEARED+COOLED pending={_pendingSpellId} ({BuffFailCooldownSec:0}s) — hard rejection in '{text}'"); } + EndPendingUpgrade(_pendingSpellId, "refused"); _pendingSpellId = 0; _onCastResolved?.Invoke("hard-reject"); return; @@ -3686,6 +4156,15 @@ public class BuffManager : IDisposable _lastManaRefusalAt = DateTime.Now; // a combat cast's refusal too: ManaStarved with costs unknown if (_pendingSpellId == 0) return; var pendingSpell = SpellTableStub.GetById(_pendingSpellId); + // A recovery vital tries again soon for a better Mana Conversion roll (RecoveryRetry). + if (OnRecoveryManaRefusal(pendingSpell)) + { + _host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} - not enough mana; retrying in {RecoveryRetryMs} ms, buffs {LowManaBuffPauseMs / 1000:0}s."); + _pendingSpellId = 0; + _lowManaPauseUntil = DateTime.Now.AddMilliseconds(LowManaBuffPauseMs); + _onCastResolved?.Invoke("not enough mana"); + return; + } double restSec = LowManaFamilyRestSec; if (pendingSpell != null) { @@ -3704,6 +4183,7 @@ public class BuffManager : IDisposable _buffFailCooldownUntil[pendingSpell.Family] = DateTime.Now.AddSeconds(restSec); } _host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} - not enough mana; resting the family {restSec:0}s, buffs {LowManaBuffPauseMs / 1000:0}s."); + EndPendingUpgrade(_pendingSpellId, "not enough mana"); _pendingSpellId = 0; _lowManaPauseUntil = DateTime.Now.AddMilliseconds(LowManaBuffPauseMs); _onCastResolved?.Invoke("not enough mana"); @@ -3728,20 +4208,53 @@ public class BuffManager : IDisposable _host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} via soft-fail in '{text}'"); } _lastCastAttempt = DateTime.MinValue; + EndPendingUpgrade(_pendingSpellId, "fizzled"); _pendingSpellId = 0; _onCastResolved?.Invoke("soft-fail"); return; } + // A script heal (a transfer such as Vitality Siphon) cast at a monster that resists it: + // "Doorheld Surveyor resists your spell" is its only result, no "due to casting" line + // follows. Closed here as CombatManager reads the same line for its own casts. + if (lower.Contains("resists your spell")) + { + var c = _cast.Open is { Done: false } o ? o + : _cast.Current is { Done: false, Refused: false } cur ? cur : null; + if (c != null && c.Script) + { + _cast.Result(null, "resisted"); + _host.Log($"[BuffChat] script heal '{c.Name}' resisted; pending={_pendingSpellId} cleared."); + _pendingSpellId = 0; + _onCastResolved?.Invoke("resisted"); + return; + } + } + // "You cast Incantation of Flame Bane on Gelidite Robe, refreshing ..." // "You cast Strength Self VIII" // The leading 'Y' is stripped by AC's chat-glyph layer before our handler // sees it — text actually arrives as "ou cast …". IndexOf works for both. + // A transfer to the caster names the spell after "due to casting " instead. + const string DueToCasting = "due to casting "; int castIdx = lower.IndexOf("ou cast ", StringComparison.Ordinal); + int skip = 8; // "ou cast " + bool viaDueToCasting = false; + if (castIdx < 0) + { + // A transfer to the caster names the spell after "due to casting": "You gain 51 points + // of health due to casting Vitality Siphon on Doorheld Surveyor" (a heal the script + // hook casts at a monster). Unread, the heal stayed "held" and its early nudge (autorun + // on/off) went out mid-cast: the character stepped forward (2026-10-10 log, 13 of 14 + // nudges). + castIdx = lower.IndexOf(DueToCasting, StringComparison.Ordinal); + skip = DueToCasting.Length; + viaDueToCasting = castIdx >= 0; + } if (castIdx < 0) return; - // Extract spell name: everything after "ou cast " up to " on " or "," - string afterCast = text.Substring(castIdx + 8); // skip "ou cast " + // Extract spell name: everything after "ou cast " (or "due to casting ") up to " on " or "," + string afterCast = text.Substring(castIdx + skip); int onIdx = afterCast.IndexOf(" on ", StringComparison.OrdinalIgnoreCase); int commaIdx = afterCast.IndexOf(','); int endIdx = afterCast.Length; @@ -3753,6 +4266,18 @@ public class BuffManager : IDisposable // line, "You cast Revitalize Self V and restore 70 points...", has no " on " or comma). var tracked = _cast.Result(afterCast, "result"); + // A "due to casting" line that matches no open cast is only a result when it names the + // pending spell (its cast closed first, on a UseDone). Otherwise it is not ours to read: + // one transfer can print several lines (Crimson Harvest, 2026-10-10), and RynthAi's own + // drain attacks (CombatManager, never tracked here) print one each. Read as results they + // recorded a timer, ended a too-busy backoff and resolved a cast that was still running. + if (viaDueToCasting && tracked == null) + { + string? pendingName = _pendingSpellId != 0 ? SpellTableStub.GetById(_pendingSpellId)?.Name : null; + if (pendingName == null || !string.Equals(spellName, pendingName, StringComparison.OrdinalIgnoreCase)) + return; + } + // Try to find the spell by name first (authoritative — this is what was actually cast) int spellId = SpellDatabase.GetIdByName(spellName); SpellInfo? spellInfo = spellId > 0 ? SpellTableStub.GetById(spellId) : null; @@ -3779,6 +4304,21 @@ public class BuffManager : IDisposable return; } + // A result naming a LOWER level of the pending family, or naming an earlier cast of ours + // (the cast tracker matched it to another send), is a late line: recorded for that spell, + // and the pending cast keeps waiting for its own result. An Incantation's line names the + // Incantation (BuffTests "You cast Incantation of Strength Self"), so a pending one is not + // exempt; one that never reports is judged by the registry poll at its give-up. + if (pendingInfo != null && spellInfo != null && spellInfo.Family == pendingInfo.Family + && (GetSpellLevel(spellInfo) < GetSpellLevel(pendingInfo) + || (tracked != null && tracked.SpellId != _pendingSpellId))) + { + if (IsItemEnchantment(spellInfo.Name)) RecordItemSpellCast(spellInfo); + else RecordSpellTimer(spellInfo); + _host.Log($"[BuffChat] result for '{spellInfo.Name}' is a lower level than pending={_pendingSpellId} ('{pendingInfo.Name}') - a late line, recorded; pending kept."); + return; + } + if (spellInfo != null) { _buffFailCooldownUntil.Remove(spellInfo.Family); // it cast — clear any stale hard-fail cooldown @@ -3786,6 +4326,7 @@ public class BuffManager : IDisposable // which never fires for instant vitals (Heal/Revitalize/Stamina to Mana), so // two slow confirmations hours apart parked Heal Self for 30 minutes. _silentNoShowCounts.Remove(spellInfo.Family); + OnRecoveryCastResult(spellInfo.Family, spellInfo.Name); NoteCastAccepted(); // AC accepted a cast — end any too-busy backoff // Chat-authoritative record: only NOW (AC confirmed "you cast X"). // Item/armor enchants live in _itemSpellTimers (what IsBuffActive @@ -3798,12 +4339,9 @@ public class BuffManager : IDisposable if (_pendingSpellId != 0) { - if (_isForceRebuffing) - { - var ps = SpellTableStub.GetById(_pendingSpellId); - if (ps != null) _forceRebuffCastFamilies.Add(ps.Family); - } - _host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} via ou-cast match name='{spellName}' resolvedId={spellId}"); + var ps = SpellTableStub.GetById(_pendingSpellId); + if (ps != null) NoteBuffConfirmed(ps); + _host.Log($"[BuffChat] CLEARED pending={_pendingSpellId} via {(viaDueToCasting ? "due-to-casting" : "ou-cast")} match name='{spellName}' resolvedId={spellId}"); } _pendingSpellId = 0; _onCastResolved?.Invoke($"cast '{spellName}'"); @@ -3829,7 +4367,52 @@ public class BuffManager : IDisposable /// private bool _pacerLetHealAhead; - private bool PacerAllows(out string why) + /// Each tick: the first UseDone after our last buff cast (a server refusal is counted there). + private void ObserveBuffChain() + { + if (!_host.HasUseDoneSeq) return; + bool hasLast = _host.TryGetLastUseDone(out int lastSeq, out uint lastErr); + _chain.Observe(hasLast, lastSeq, lastErr, _host.GetUseDoneSeq(), Now, s => _host.Log(s)); + } + + /// + /// The buff cast chain's fast path for this tick (see BuffCastChain): the setting is on, the + /// pacing is on, the character is in Magic stance, no vital is under any of its lines (so the + /// vitals step has nothing to send on a tick that skips the animation gate), and the last + /// action was our own buff cast answered by UseDone(0) moments ago. + /// + private bool FastChainNow() + { + _fastChainWhy = ""; + if (!_settings.FastBuffChain || !_settings.EnableBuffing || !ActionPacer.Enabled) return false; + if (!_host.HasUseDoneSeq || CurrentCombatMode != CombatMode.Magic) return false; + if (!VitalsClearOfEveryLine()) return false; + // A held stop is still to be sent: CastSpellFor would flush it inside this very cast (after the + // movement count the chain compares), so the buff waits for the animation gate instead. + if (MoveAudit.HasPendingStop) return false; + bool hasLast = _host.TryGetLastUseDone(out int lastSeq, out uint lastErr); + return _chain.Eligible(ActionPacer.Started, ActionPacer.AttacksSent, MoveAudit.MovementSends, hasLast, lastSeq, lastErr, + _host.GetUseDoneSeq(), Now, out _fastChainWhy); + } + + /// True when health, stamina and mana are at or over every line the vitals step acts on + /// (combat and idle, emergency included), and no kit or stamina run is in progress. + private bool VitalsClearOfEveryLine() + { + if (_vitals.MaxHealth == 0) return false; + if (KitPending() || _restamRun) return false; + int hp = _vitals.HealthPct, st = _vitals.StaminaPct, mp = _vitals.ManaPct; + if (HealthUnderAnyLine(hp, st)) return false; + if (hp < Math.Max(_settings.HealAt, _settings.TopOffHP)) return false; + if (_settings.EmergencyHealAt > 0 && hp <= _settings.EmergencyHealAt) return false; + if (_settings.StaminaToHealthAt > 0 && hp <= _settings.StaminaToHealthAt) return false; + if (mp < Math.Max(_settings.GetManaAt, _settings.TopOffMana)) return false; + if (ManaUnderLine(true, out _) || ManaUnderLine(false, out _)) return false; // the mana reserve too + if (st < Math.Max(_settings.RestamAt, _settings.TopOffStam)) return false; + return true; + } + + private bool PacerAllows(out string why, bool gestureGate = true) { why = ""; _pacerLetHealAhead = false; @@ -3842,7 +4425,7 @@ public class BuffManager : IDisposable } HealNeed need = HealNeedNow(); bool outstanding = ActionPacer.Current(_host) != null; - if (ActionPacer.MayStart(_host, "Buff", need, out why)) + if (ActionPacer.MayStart(_host, "Buff", need, out why, gestureGate)) { // A heal let ahead of an unanswered action: the busy count still counts that action, // so the busy gate below must not hold the heal again. @@ -3897,11 +4480,12 @@ public class BuffManager : IDisposable SendCastNudge(urgent: true); } - /// The held cast is a heal, or health is under a heal line: nudge it early. + /// The held cast is a heal, or health is under a heal line: nudge it early. Never a + /// cast the script hook chose (CastTracker.Cast.Script): those wait HeldAfterIncantMs. private bool HeldNudgeUrgent() { var held = _cast.Held; - if (held == null) return false; + if (held == null || held.Script) return false; return IsHealCast(held.SpellId) || (_vitals.MaxHealth > 0 && HealthUnderAnyLine(_vitals.HealthPct, _vitals.StaminaPct)); } @@ -4070,6 +4654,7 @@ public class BuffManager : IDisposable // Mirror that recovery here: visible retries, ≤2 capped re-equips per // episode, one-shot chat warn when wedged. private DateTime _buffStanceStuckSince = DateTime.MinValue; + private long _buffStanceStuckStartMs; // ActionPacer.NowMs when the clock started (a later engine refusal restarts it) private DateTime _buffStanceLastRecoverAt = DateTime.MinValue; private int _buffStanceReEquips; private bool _buffStanceWedgeWarned; @@ -4397,9 +4982,17 @@ public class BuffManager : IDisposable } // Deadlock episode tracking: wand wielded but mode refuses to flip. - if (_buffStanceStuckSince == DateTime.MinValue) + // The clock starts when a stance request has actually gone out (below), never on refusals: the + // engine turns stance changes away around a teleport or a death, and a clock counting through + // that would end in a re-equip UseObject on the wielded wand (a MOVE) and a burnt re-equip. + // A refusal newer than the clock's start means the request that started it was dropped (a teleport right after it went out): + // the clock restarts, so the refusals that follow are not counted as a wedged stance. + if (_buffStanceStuckSince != DateTime.MinValue && ActionPacer.LastEngineRefusalMs > _buffStanceStuckStartMs) + { _buffStanceStuckSince = DateTime.Now; - double stuckMs = (DateTime.Now - _buffStanceStuckSince).TotalMilliseconds; + _buffStanceStuckStartMs = ActionPacer.NowMs(); + } + double stuckMs = _buffStanceStuckSince == DateTime.MinValue ? 0 : (DateTime.Now - _buffStanceStuckSince).TotalMilliseconds; // Capped re-equip recovery (mirrors CombatManager): handles the rare // stale "wielded reads true" by resyncing the wield once or twice. @@ -4438,6 +5031,7 @@ public class BuffManager : IDisposable if ((DateTime.Now - _lastBuffStanceAttempt).TotalMilliseconds > gateMs && _host.ChangeCombatModeFor(CombatMode.Magic, "Buff", "wand wielded: Magic mode")) { + if (_buffStanceStuckSince == DateTime.MinValue) { _buffStanceStuckSince = DateTime.Now; _buffStanceStuckStartMs = ActionPacer.NowMs(); } NoteStanceRequest(); _lastBuffStanceAttempt = DateTime.Now; _lastCastAttempt = DateTime.Now; diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffProfile.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffProfile.cs new file mode 100644 index 0000000..fa29344 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/BuffProfile.cs @@ -0,0 +1,194 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using RynthCore.Install; + +namespace RynthCore.Plugin.RynthAi; + +/// +/// A buff profile: the spells buffing keeps up, in cast order. Built in the Spells window +/// (/ra spells) and chosen under Loaded Files (Buffs). Without one, buffing uses its +/// built-in list. +/// +public sealed class BuffProfile +{ + public int Schema = BuffProfileStore.CurrentSchema; + public string Name = ""; + public string Notes = ""; + public List Entries = new(); +} + +/// One spell line in a . +public sealed class BuffProfileEntry +{ + /// The spell picked in the Spells window (shown in the profile list). + public int SpellId; + public string Name = ""; + /// + /// Base name buffing resolves to the best tier the character knows ("Strength Self"); + /// see . + /// + public string Key = ""; + /// ACE spell family: the fallback when the base name has no tier ladder. + public int FamilyId; + public string School = ""; + public string Target = ""; + public int Level; + public bool Enabled = true; +} + +/// +/// Buff profile files: <SuiteDir>\RynthAi\BuffProfiles\<name>.json, shared by +/// every character like the Nav, Loot and Meta folders. +/// +internal static class BuffProfileStore +{ + public const int CurrentSchema = 1; + public const string FileExtension = ".json"; + + /// Tests point the folder at a temp directory. + internal static string? FolderOverride; + + public static string Folder => FolderOverride ?? Path.Combine(RynthInstallPaths.RynthAiDir, "BuffProfiles"); + + /// Full path for a profile name (sanitised for Windows file names). + public static string PathFor(string profileName) => + Path.Combine(Folder, SanitizeFileName(profileName) + FileExtension); + + /// Profile file names (with extension) in the folder, sorted. + public static List ListFileNames() + { + var list = new List(); + try + { + if (!Directory.Exists(Folder)) return list; + foreach (string f in Directory.GetFiles(Folder, "*" + FileExtension)) + list.Add(Path.GetFileName(f)); + list.Sort(StringComparer.OrdinalIgnoreCase); + } + catch { /* folder unreadable: no profiles */ } + return list; + } + + public static bool TryLoad(string path, out BuffProfile profile, out string error) + { + profile = new BuffProfile(); + error = ""; + try + { + if (string.IsNullOrWhiteSpace(path) || !File.Exists(path)) { error = "file not found"; return false; } + var p = JsonSerializer.Deserialize(File.ReadAllText(path), RynthAiJsonContext.Default.BuffProfile); + if (p == null) { error = "empty file"; return false; } + if (p.Schema > CurrentSchema) { error = $"made by a newer RynthAi (schema {p.Schema})"; return false; } + Normalize(p, Path.GetFileNameWithoutExtension(path)); + profile = p; + return true; + } + catch (Exception ex) + { + error = ex.Message; + return false; + } + } + + /// Writes the profile (temp file + move, so a crash never leaves half a file). + public static void Save(BuffProfile profile, string path) + { + Normalize(profile, Path.GetFileNameWithoutExtension(path)); + profile.Schema = CurrentSchema; + Directory.CreateDirectory(Path.GetDirectoryName(path)!); + string tmp = path + ".tmp"; + File.WriteAllText(tmp, JsonSerializer.Serialize(profile, RynthAiJsonContext.Default.BuffProfile)); + File.Move(tmp, path, overwrite: true); + } + + public static bool Delete(string path) + { + try + { + if (!File.Exists(path)) return false; + File.Delete(path); + return true; + } + catch { return false; } + } + + /// An entry for a catalog spell, with its buffing key worked out. + public static BuffProfileEntry EntryFor(SpellCatalogEntry e) => new() + { + SpellId = e.Id, + Name = e.Name, + Key = SpellCatalog.BuffKeyFor(e), + FamilyId = e.FamilyId, + School = e.School, + Target = e.Target, + Level = e.Level, + Enabled = true, + }; + + /// True when an entry with the same buffing key is already in the profile. + public static bool ContainsKey(BuffProfile p, string key) + { + foreach (var e in p.Entries) + if (e.Key.Equals(key, StringComparison.OrdinalIgnoreCase)) return true; + return false; + } + + /// + /// Catalog spell for one of buffing's built-in base names ("Strength Self", "Blade Bane", + /// "Blood Drinker Self"), used to start a profile from the built-in list. Null when the + /// catalog has no tier ladder for it. + /// + public static SpellCatalogEntry? CatalogSpellForBaseName(string baseName) + { + string[] candidates = + { + baseName + " I", "Aura of " + baseName + " I", baseName + " II", "Aura of " + baseName + " II", + baseName, "Incantation of " + baseName, + }; + foreach (string c in candidates) + { + var e = SpellCatalog.GetByName(c); + if (e != null) return e; + } + return null; + } + + /// Repairs nulls, blank keys and the name after loading or before saving. + public static void Normalize(BuffProfile p, string fallbackName) + { + p.Name = string.IsNullOrWhiteSpace(p.Name) ? fallbackName : p.Name.Trim(); + p.Notes ??= ""; + p.Entries ??= new List(); + p.Entries.RemoveAll(e => e == null || (e.SpellId == 0 && string.IsNullOrWhiteSpace(e.Key))); + foreach (var e in p.Entries) + { + e.Name ??= ""; + e.School ??= ""; + e.Target ??= ""; + e.Key ??= ""; + // Hand-edited files may hold only a spell id: fill the rest from the catalog. + var c = e.SpellId != 0 ? SpellCatalog.Get(e.SpellId) : null; + if (c != null) + { + if (e.Name.Length == 0) e.Name = c.Name; + if (e.Key.Length == 0) e.Key = SpellCatalog.BuffKeyFor(c); + if (e.FamilyId == 0) e.FamilyId = c.FamilyId; + if (e.School.Length == 0) e.School = c.School; + if (e.Target.Length == 0) e.Target = c.Target; + if (e.Level == 0) e.Level = c.Level; + } + if (e.Key.Length == 0) e.Key = SpellCatalog.StripTier(e.Name); + } + } + + /// Strips characters Windows forbids in file names; "Default" when nothing is left. + public static string SanitizeFileName(string name) + { + string t = (name ?? "").Trim(); + foreach (char c in Path.GetInvalidFileNameChars()) t = t.Replace(c, '_'); + if (t.Length > 80) t = t.Substring(0, 80); + return t.Length == 0 ? "Default" : t; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/CastTracker.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/CastTracker.cs index 7d64663..b6f92c1 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/CastTracker.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/CastTracker.cs @@ -38,6 +38,9 @@ internal sealed class CastTracker public bool Done; // its result line, or UseDone(0) after its incantation public bool Nudged; // the one movement nudge for this held cast has gone out public bool StuckLogged; + // The script combat hook chose this cast (a heal): no early nudge, HeldAfterIncantMs only. + // A Vitality Siphon's result can come 2.75 s after its incantation (2026-10-10 log). + public bool Script; public bool HasIncantation => IncantAt != DateTime.MinValue; } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.ScriptHook.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.ScriptHook.cs new file mode 100644 index 0000000..6a6ef98 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.ScriptHook.cs @@ -0,0 +1,291 @@ +using System; +using RynthCore.PluginSdk; +using RynthCore.Plugin.RynthAi.Combat; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthAi; + +// The attack seam of the script-provided combat hook (RynthAi.Combat, CombatHookInterface.cs): +// with a script holding the attack kind, AttackWithMagic asks it for the spell after its debuffs +// and before its own shape choice. RynthAi keeps everything around the cast: the scan, the +// target lock, the stance, the cadence and busy gates, and the cast bookkeeping. The script only +// names the spell (and optionally another scanned monster, or the player). +public partial class CombatManager +{ + // True on a tick where AttackWithMagic sent nothing because it is waiting on the script's + // answer: Think then ends the tick without stamping lastAttackCmd (like the wall hold). + private bool _scriptHeld; + + /// The player's vitals, for the hook's request (set by the plugin; null in tests that don't need it). + internal PlayerVitalsCache? Vitals { get; set; } + + /// The fight target's last known health ratio (0-1), or -1 when unknown or no target. + internal float FightTargetHealthRatio => activeTargetId == 0 ? -1f : _worldFilter.GetHealthRatio(activeTargetId); + + /// Host tests: true after a tick that held for the script's answer. + internal bool ScriptHeld => _scriptHeld; + + /// + /// True when the hook handled this attack cycle: held for the answer, or cast the script's + /// spell. False = RynthAi chooses as usual (no hook, a decline, a rejected answer, a timeout). + /// + private bool TryScriptAttack(WorldObject target, string element) + { + if (!CombatHook.IsActive(RynthAiCombat.KindAttack)) return false; // no hook: no per-tick lambdas + var slot = CombatHook.Attack; + uint forTarget = unchecked((uint)activeTargetId); + var outcome = CombatHook.Step(slot, forTarget, () => BuildAttackRequest(target), s => _host.Log(s), + out uint spell, out uint castTarget, out uint flags); + switch (outcome) + { + case CombatHook.Outcome.Native: + return false; + case CombatHook.Outcome.Wait: + _scriptHeld = true; + LastCombatSkipReason = "script-wait"; // D4 record-only + return true; + } + + if (castTarget == 0) castTarget = forTarget; + string? why = ScriptAttackProblem(spell, castTarget); + if (why != null) + { + CombatHook.Reject(slot, why, s => _host.Log(s)); + return false; + } + // A spell that costs more than max mana can never be paid, so the mana hold below would + // never lift: rejected, and RynthAi chooses its own spell this same tick. + bool affordable = true; + try { affordable = ManaCanEverAfford?.Invoke((int)spell) ?? true; } catch { affordable = true; } + if (!affordable) + { + CombatHook.Reject(slot, "costs more than max mana", s => _host.Log(s)); + return false; + } + // RynthAi's mana reserve holds the script's spell as it holds its own (ManaHoldsCast: mana + // under the spell's cost, or under the reserve kept for Stamina to Mana): nothing is sent, + // Think ends the tick on _manaCastHeld, and the answer is kept for the next tick. It is not + // a rejection, so RynthAi does not cast a spell of its own choosing instead. Once the + // request is past its deadline + StaleGraceMs, Step drops the answer and asks again. + if (ManaHoldsCast((int)spell)) return true; + if (!IssueScriptCast((int)spell, castTarget, flags, element)) + { + CombatHook.Reject(slot, "the client refused the cast", s => _host.Log(s)); + return false; + } + CombatHook.Cast(slot, spell, castTarget, ActionPacer.LastCastSeqAtSend); + return true; + } + + /// Why the script's answer can't be cast, or null when it can. + private string? ScriptAttackProblem(uint spell, uint castTarget) + { + if (_spellManager == null || !_spellManager.IsKnownSpellId((int)spell)) return $"spell {spell} isn't known"; + // A script spell the server refused outright (no components): parked like a vital level. + if (_scriptParkedUntil.TryGetValue((int)spell, out DateTime parked) && DateTime.Now < parked) + return $"spell {spell} was refused by the server, parked for {(parked - DateTime.Now).TotalSeconds:0} s more"; + uint player = _playerId != 0 ? _playerId : _host.GetPlayerId(); + if (castTarget == player) return null; + // Monster rule Priority 0 = IGNORE: not a target for a script either, even one attacking us. + // Checked before the fight-target match: a fight target whose rule changed to 0 is still + // the active target until Think drops it. + if (IsIgnored((int)castTarget)) return "the target is ignored (monster rule Priority 0)"; + bool listed = castTarget == unchecked((uint)activeTargetId); + for (int i = 0; !listed && i < _scannedTargets.Count; i++) + if (unchecked((uint)_scannedTargets[i].Id) == castTarget) listed = true; + if (!listed) return "the target is not the fight target, a scanned monster or the player"; + // The same veto as RynthAi's own casts: never offensive magic at something AC says isn't attackable. + if (_host.HasObjectIsAttackable && !_host.ObjectIsAttackable(castTarget)) return "the target is not attackable"; + return null; + } + + private CombatRequestV1 BuildAttackRequest(WorldObject target) + { + var v = Vitals; + bool vitalsKnown = v != null && v.MaxHealth > 0; + return new CombatRequestV1 + { + TargetHealth = _worldFilter.GetHealthRatio(activeTargetId), + HealthPct = vitalsKnown ? v!.HealthPct : -1, + StaminaPct = vitalsKnown && v!.MaxStamina > 0 ? v.StaminaPct : -1, + ManaPct = vitalsKnown && v!.MaxMana > 0 ? v.ManaPct : -1, + HealLine = 0, + InCombat = 1, + CombatMode = CurrentCombatMode, + }; + } + + /// + /// Sends the script's spell with RynthAi's own cast bookkeeping: the cadence guard + /// (MarkCombatCastIssued), the attack interval and the area flag. The pending-offensive + /// judgement (blacklist on no damage) is armed only for a single-target cast at the fight + /// target without NOJUDGE. A damaging cast at the fight target (not NOJUDGE) is tagged for + /// the Damage tab like RynthAi's own: wielded wand, element and level from the spell, the + /// fight's cast count and the last-fight snapshot; a single-target one also runs the + /// kill-shot prediction (EvaluateKillShot), as RynthAi's own cast does. + /// + private bool IssueScriptCast(int spellId, uint castTarget, uint flags, string fallbackElement) + { + bool area = (flags & RynthAiCombat.FlagArea) != 0; + bool noJudge = (flags & RynthAiCombat.FlagNoJudge) != 0; + string name = SpellTableStub.GetById(spellId)?.Name ?? $"spell {spellId}"; + bool ok; + try { ok = _host.CastSpellFor(castTarget, spellId, "Combat", name + " (script)"); } + catch { ok = false; } + if (!ok) return false; + ActionPacer.MarkScriptCast(spellId); + + MarkCombatCastIssued(); + StartCastChatTrace(spellId, unchecked((int)castTarget)); // the server's answers, logged as for RynthAi's own casts + SessionAttackCasts++; + CastsSinceLastKill++; + _lastSpellCast = DateTime.Now; + _scriptCastSpellId = spellId; + _scriptCastAt = DateTime.Now; + _scriptCastSent = ActionPacer.CastsSent; // includes this cast: any later send changes it + bool atFight = castTarget == unchecked((uint)activeTargetId); + bool judged = atFight && !area && !noJudge; + _lastCastWasRing = !judged; // anything else gets no per-target judgement + _wallFaceAt = DateTime.MinValue; + if (judged) + { + // What the NO DAMAGE report names as the last cast (ReportNoDamageCasts). + _lastOffensiveCastLine = $"script id={spellId} '{name}' target=0x{castTarget:X8}"; + _pendingOffensiveSpellId = spellId; + _pendingOffensiveCastAt = DateTime.Now; + _pendingOffensiveTargetId = activeTargetId; + NoteOffensiveSeq(); + } + // As the native block: a throw here must not fail the cast that already went out (the + // slot would stay Decided and the same answer be cast again). + // A single-target damaging cast at the fight target also takes part in RynthAi's kill-shot + // swap (Think arms it, the deferred swap moves on while the projectile flies), with the + // weapon, element and tier just tagged. Area, nojudge and off-target casts never do. + _predictKillSwap = false; + if (atFight && !noJudge) + { + try + { + TagScriptCast(spellId, area, fallbackElement); + if (!area) EvaluateKillShot(_lastCastWeaponId, _lastCastElement, _lastCastTier, isRing: false); + } + catch { } + } + LastCombatSkipReason = "script-cast"; // D4 record-only + string tags = (area ? " (area)" : "") + (noJudge ? " (nojudge)" : ""); + _host.Log($"[CombatCast] script id={spellId} '{name}' at 0x{castTarget:X8}{tags} " + + $"fight=0x{activeTargetId:X8} owner='{CombatHook.Owner}'"); + return true; + } + + /// + /// The damage attribution RynthAi's own cast does (AttackWithMagic), for a script's cast at + /// the fight target: the weapon, element and tier the pushed damage is filed under, the + /// Damage tab's latest tier, the casts-to-kill count and the last-fight snapshot. + /// + private void TagScriptCast(int spellId, bool area, string fallbackElement) + { + int castWand = InHandWeaponId(); + if (castWand == 0 || !IsWandObject(_worldFilter[castWand] ?? new WorldObject(0, ""))) castWand = FindWandInItems(); + _lastCastWeaponId = unchecked((uint)castWand); + // No element in the spell (a Life drain, say) on a caster with no War or Void: the plan's + // element (a weapon-weakness pick like "Slash") would be wrong, so it is filed under + // "Physical", the key RynthAi's own damage path already uses for vital drains. + _lastCastElement = ScriptSpellElement(spellId) ?? (AttackMagicTrained ? fallbackElement : "Physical"); + int castLevel = SpellTableStub.GetById(spellId)?.Level ?? 0; + if (castLevel <= 0 && SpellDatabase.TryGetCategoryAndPower(spellId, out _, out int castPower)) + castLevel = SpellDatabase.LevelFromPower(castPower); + if (castLevel <= 0) + castLevel = Math.Max(_spellManager?.GetHighestSpellTier(AcSkillType.WarMagic) ?? 0, + _spellManager?.GetHighestSpellTier(AcSkillType.VoidMagic) ?? 0); + _lastCastTier = area ? -castLevel : castLevel; // area casts filed with the rings (negative) + if (_fightTargetWcid != 0) _damageStore?.NoteCast(_fightTargetWcid, _lastCastTier, _fightTargetName); + _fightCastCount++; + if (_fightTargetWcid != 0) + { + _lastFightWcid = _fightTargetWcid; + _lastFightName = _worldFilter[activeTargetId]?.Name ?? _fightTargetName; + _lastFightWeaponId = _lastCastWeaponId; + _lastFightElement = _lastCastElement; + _lastFightTier = _lastCastTier; + _lastFightCount = _fightCastCount; + StampRecentFight(); + } + } + + /// + /// The element of a war/void attack spell, from RynthAi's own shape tables (base name, tier-7 + /// lore names, ring lore names, wall categories), else from its name's words; null when + /// none of those says. + /// + internal static string? ScriptSpellElement(int spellId) + { + string? name = SpellTableStub.GetById(spellId)?.Name; + if (string.IsNullOrEmpty(name)) return null; + string n = name.Trim(); + if (n.StartsWith("Incantation of ", StringComparison.OrdinalIgnoreCase)) n = n.Substring(15).Trim(); + int sp = n.LastIndexOf(' '); + if (sp > 0 && IsRoman(n.Substring(sp + 1))) n = n.Substring(0, sp); + + // Blade and Slash share their spells: answer Slash (the Damage tab's element name). + foreach (var kv in SpellShapes) + if (!kv.Key.Equals("Blade", StringComparison.OrdinalIgnoreCase) + && Array.Exists(kv.Value, b => b.Equals(n, StringComparison.OrdinalIgnoreCase))) + return kv.Key; + foreach (var table in new[] { WarTier7Lore, RingLoreNames }) + foreach (var kv in table) + if (!kv.Key.Equals("Blade", StringComparison.OrdinalIgnoreCase) + && Array.Exists(kv.Value, b => b.Equals(name.Trim(), StringComparison.OrdinalIgnoreCase))) + return kv.Key; + if (SpellDatabase.TryGetCategoryAndPower(spellId, out int category, out _)) + foreach (var kv in WallCategories) + if (kv.Value == category && !kv.Key.Equals("Blade", StringComparison.OrdinalIgnoreCase)) return kv.Key; + string byWords = PetChoice.ElementFromName(name); + return byWords.Length > 0 ? byWords : null; + + static bool IsRoman(string s) + { + if (s.Length == 0) return false; + foreach (char c in s) if (c != 'I' && c != 'V' && c != 'X') return false; + return true; + } + } + + // -- Refusal memory for script casts -- + + // The script's last cast, while it is still the last cast this plugin sent (ActionPacer counts + // every send: combat, buffs and heals, nav, commands, meta): a hard refusal arriving soon after + // it is the script spell's, and parks that spell. Forgotten once any other cast goes out, the + // spell's own success line arrives, or the window passes. + private int _scriptCastSpellId; + private DateTime _scriptCastAt = DateTime.MinValue; + private long _scriptCastSent; + private readonly System.Collections.Generic.Dictionary _scriptParkedUntil = new(); + + /// How long a script spell the server refused outright is rejected (as BuffManager parks a vital level). + internal const double ScriptParkSec = 600.0; + /// A refusal later than this after the script's cast is not attributed to it. + internal const double ScriptRefusalWindowMs = 2_000.0; + + /// Host tests: true while is parked after a refusal. + internal bool ScriptSpellParked(int spellId) => _scriptParkedUntil.TryGetValue(spellId, out DateTime u) && DateTime.Now < u; + + /// A chat line: park the script's last spell on a hard refusal (missing components, unknown spell). + private void NoteScriptCastRefusal(string text) + { + if (_scriptCastSpellId == 0) return; + if (ActionPacer.CastsSent != _scriptCastSent + || (DateTime.Now - _scriptCastAt).TotalMilliseconds > ScriptRefusalWindowMs) { _scriptCastSpellId = 0; return; } + string lo = text.ToLowerInvariant(); + string? own = SpellTableStub.GetById(_scriptCastSpellId)?.Name; + if (own != null && lo.Contains("ou cast " + own.ToLowerInvariant())) { _scriptCastSpellId = 0; return; } // it landed + if (!(lo.Contains("missing some required") || lo.Contains("you do not have the") + || lo.Contains("have all the components for this spell"))) return; + int spell = _scriptCastSpellId; + _scriptCastSpellId = 0; + _scriptParkedUntil[spell] = DateTime.Now.AddSeconds(ScriptParkSec); + _host.Log($"[CombatCast] script spell id={spell} '{SpellTableStub.GetById(spell)?.Name}' refused: '{text.Trim()}'. " + + $"Rejected for {ScriptParkSec / 60:0} min (RynthAi chooses instead while the script asks for it)."); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.TargetLock.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.TargetLock.cs new file mode 100644 index 0000000..7ff1979 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.TargetLock.cs @@ -0,0 +1,116 @@ +// ============================================================================ +// RynthSuite - Combat/CombatManager.TargetLock.cs +// Target lock (VTank's "Target lock" hotkey, /ra targetlock): the macro attacks +// the monster the player selected, ahead of the Targeting setting, the rule +// Priority tiers (Priority 0 "ignore" included) and the never-attack name list. +// +// The selected monster must be attackable and alive. It joins the scan like the +// engaged target (out to the disengage distance); LOS and the failure blacklist +// still apply, so a monster behind a wall waits until it is in sight. While it +// isn't in the scan the normal selection runs. The lock ends when it dies or +// turns into a corpse, gets blacklisted (unreachable), is out of the scan for +// ForcedTargetLostMs, or the player clears it (/ra targetlock off, or the same +// monster again). +// ============================================================================ + +using System; +using System.Threading; + +namespace RynthCore.Plugin.RynthAi; + +public partial class CombatManager +{ + /// Out of the scan this long (never in reach, or gone): the lock ends. + internal const double ForcedTargetLostMs = 30_000; + + private int _forcedTargetId; + // Pump-thread state: when the current forced target was first and last seen. + private int _forcedSeenFor; + private DateTime _forcedSince = DateTime.MinValue; + private DateTime _forcedLastInScan = DateTime.MinValue; + + /// The monster the player locked combat onto (0 = none). Any thread. + public int ForcedTargetId => Volatile.Read(ref _forcedTargetId); + + /// Why can't be locked onto, or null when it can. + internal string? ForcedTargetRefusal(int id) + { + if (id == 0) return "nothing is selected"; + if (unchecked((uint)id) == _playerId) return "that's you"; + var wo = _worldFilter[id]; + if (wo == null) return "it isn't known yet (try again in a moment)"; + if ((int)wo.ObjectClass != (int)AcObjectClass.Monster || IsSpellProjectileName(wo.Name)) return $"{wo.Name} isn't a monster"; + if (_host.HasObjectIsAttackable && !_host.ObjectIsAttackable(unchecked((uint)id))) return $"{wo.Name} can't be attacked"; + if (_worldFilter.GetHealthRatio(id) == 0f || _recentlyKilled.ContainsKey(id)) return $"{wo.Name} is dead"; + return null; + } + + /// Locks combat onto (checked with first). + internal void SetForcedTarget(int id) => Volatile.Write(ref _forcedTargetId, id); + + /// Ends the target lock (the monster stays the fight target until normal selection moves on). + internal void ClearForcedTarget() => Volatile.Write(ref _forcedTargetId, 0); + + /// + /// HandleCombatTrigger, before the normal selection: true when the forced target holds the + /// tick (locked now, or kept while it blinks out of the scan). + /// + private bool TryLockForcedTarget() + { + int fid = ForcedTargetId; + if (fid == 0) return false; + DateTime now = TargetClock(); + if (_forcedSeenFor != fid) + { + _forcedSeenFor = fid; + _forcedSince = now; + _forcedLastInScan = DateTime.MinValue; + } + + string? end = ForcedTargetEnded(fid, now); + if (end != null) + { + Interlocked.CompareExchange(ref _forcedTargetId, 0, fid); + string name = _worldFilter[fid]?.Name ?? $"0x{(uint)fid:X8}"; + _host.Log($"[CombatTarget] target lock on 0x{(uint)fid:X8} '{name}' ended: {end}"); + _host.WriteToChat($"[RynthAi] Target lock on {name} ended: {end}.", 1); + return false; + } + + foreach (var c in _scannedTargets) + { + if (c.Id != fid) continue; + _forcedLastInScan = now; + int priority = PriorityOf(fid); + if (_lockedTargetId == fid) + { + activeTargetId = fid; + _lockedPriority = priority; + _lockedLastSeen = c; + _lockedLastSeenInScan = now; + return true; + } + LockTarget(c, priority, $"target lock: picked by the player, {DescribeTargetPos(fid)}", + _lockedTargetId != 0 ? "target lock" : null); + return true; + } + + // Locked and briefly out of the scan: kept within the scan grace (the normal path would + // drop a Priority 0 monster at once). + return _lockedTargetId == fid && _lockedLastSeenInScan != DateTime.MinValue + && (now - _lockedLastSeenInScan).TotalMilliseconds <= TARGET_SCAN_GRACE_MS; + } + + private string? ForcedTargetEnded(int fid, DateTime now) + { + if (_recentlyKilled.ContainsKey(fid)) return "killed"; + var wo = _worldFilter[fid]; + if (wo != null && (int)wo.ObjectClass != (int)AcObjectClass.Monster) return "it died"; + if (wo != null && _worldFilter.GetHealthRatio(fid) == 0f) return "it died"; + if (_blacklistManager.IsBlacklisted(fid)) return "it can't be reached (blacklisted)"; + DateTime seen = _forcedLastInScan != DateTime.MinValue ? _forcedLastInScan : _forcedSince; + if ((now - seen).TotalMilliseconds > ForcedTargetLostMs) + return _forcedLastInScan == DateTime.MinValue ? "never in reach (out of range or out of sight)" : "out of reach"; + return null; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs index 21bbf75..6129802 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs @@ -65,6 +65,7 @@ public partial class CombatManager : IDisposable // equip path would only re-send ChangeCombatMode forever (it never re-equips a // "wielded" wand) — a hours-long wedge with NO m_cBusy pin so no watchdog fires. private DateTime _stanceStuckSince = DateTime.MinValue; + private long _stanceStuckStartMs; // ActionPacer.NowMs when the clock started (a later engine refusal restarts it) private DateTime _lastStanceRecoverAt = DateTime.MinValue; private const double StanceStuckRecoverMs = 8000; // Re-equip attempts spent in the CURRENT deadlock episode. ⚠ UseObject on an @@ -296,6 +297,11 @@ public partial class CombatManager : IDisposable /// Stamina to Mana), or null to cast. Null hook = never hold (2026-10-11). /// public Func? ManaReserveHold { get; set; } + /// + /// BuffManager.CanEverAfford, for the script hook: false when a spell costs more than max mana, + /// so ManaReserveHold would hold it forever. Null hook = always affordable. + /// + public Func? ManaCanEverAfford { get; set; } private bool _manaCastHeld; // AttackWithMagic held its cast for mana this tick private bool _manaHoldLogged; @@ -417,6 +423,36 @@ public partial class CombatManager : IDisposable private string _lastSwingEvidenceKind = "none"; private readonly CombatStallWatchdog _stallWatch = new(); + + // ── Early stall step and stale objects (Drakkon 2026-10-12, Olthoi in 0x6146) ──────────── + // The flight recorder showed the stall: the server answered a MeleeAttack with a MoveToObject + // to the target 2 m away, the character took a step and stopped, and the server waited for it + // to arrive; every further attack was dropped ("already in melee loop") until the watchdog's + // CancelAttack 6 s later, after which the server turned us and swung at once. Three such + // stalls cost 7-9 s each and one good target got blacklisted a second after the cancel. Now + // step 1 goes out after QuietStallMs when the stall is plain to see: attacks sent, no swing + // playing, the character standing still (see SampleMeleeQuiet). + // From 21:00 the same client fought four "Olthoi" for 25+ minutes without one swing: ghosts, + // objects the client still drew but the server no longer had for him (see GhostCheck.cs). Each + // was blacklisted for 30 s at a time, round and round, with navigation never getting a turn. + // Now a target that shows no swing after the step-1 re-issue, hasn't moved and that the server + // has said nothing about for GhostCheck.NoUpdateMs is a ghost: skipped until the server shows + // it is real (an update, a create, it moves) or the character changes landblock, and removed + // from the client when the engine can (plugin API v83 RemoveClientObject). + private readonly GhostCheck _ghostCheck = new(); + internal readonly GhostTracker Ghosts = new(); + private int _ghostsSkippedInScan; // ghosts the last scan passed over (lock log) + private GhostSpot? _lockSpot; // where the locked target was when locked + private uint _ghostLandblock; + private int _attacksSinceEvidence; // melee/missile attacks sent since the last hit, miss or kill + private bool _rebindThisTick; // AttackTarget sent a rebind CancelAttack this tick + private DateTime _lastAnimatingAt = DateTime.MinValue; // the motion queue last read busy (a swing playing) + private DateTime _lastPlayerMovedAt = DateTime.MinValue; // the character last moved QuietMoveM + private DateTime _lastQuietSampleAt = DateTime.MinValue; + private double _moveAnchorX, _moveAnchorY, _moveAnchorZ; + private const double QuietNoAnimMs = 1500; // no swing playing for this long + private const double QuietStillMs = 1000; // and standing still this long + private const double QuietMoveM = 0.3; private DateTime _stallToggleAt = DateTime.MinValue; // step 3 sent peace; the flip back follows private DateTime _lastMissileNoAmmoAt = DateTime.MinValue; // missile mode waiting on ammo is not a stall private int _stallRewieldId; // step 4 in progress (weapon id) @@ -787,6 +823,9 @@ public partial class CombatManager : IDisposable PickedWeaponWieldLoc = weaponWieldLoc, HasWieldedAmmoFlag = hasAmmo, LastCombatSkipReason = LastCombatSkipReason, + ScriptHookOwner = CombatHook.IsActive(RynthAiCombat.KindsAll) ? CombatHook.Owner : "", + ScriptHookKinds = CombatHook.IsActive(RynthAiCombat.KindsAll) ? CombatHook.Kinds : 0, + ScriptHook = CombatHook.Describe(), }; } @@ -817,6 +856,11 @@ public partial class CombatManager : IDisposable public int PickedWeaponWieldLoc; public bool HasWieldedAmmoFlag; public string LastCombatSkipReason; + /// The script holding the combat hook (RynthAi.Combat), "" when none; and its kinds (RynthAiCombat.Kind* bits). + public string ScriptHookOwner; + public uint ScriptHookKinds; + /// The hook's one-line summary (owner, lease, per-kind counters). + public string ScriptHook; } /// @@ -888,6 +932,14 @@ public partial class CombatManager : IDisposable bool hasPlayerPos = _host.TryGetObjectPosition((uint)playerId, out uint meCell, out float meX, out float meY, out float meZ); + // Ghosts that moved are real after all; a new landblock lets them all go. + _ghostsSkippedInScan = 0; + if (Ghosts.Count > 0) + { + if (hasPlayerPos) Ghosts.OnPlayerLandblock(meCell >> 16); + Ghosts.CheckMoved(TargetSpot); + } + foreach (var wo in _worldFilter.GetLandscape()) { if (wo.Id == playerId) continue; @@ -932,15 +984,21 @@ public partial class CombatManager : IDisposable // out of range and now cost only their distance, not the name list, blacklist, // attackable and health reads as well. bool isEngaged = wo.Id != 0 && (wo.Id == activeTargetId || wo.Id == _lockedTargetId); - if (dist > (isEngaged ? Math.Max(maxDist, DisengageDistance) : maxDist)) continue; + // Target lock (/ra targetlock): the player picked this one; the name list and + // Priority 0 don't keep it out (attackable, alive and LOS still do). + bool isForced = wo.Id != 0 && wo.Id == ForcedTargetId; + if (dist > (isEngaged || isForced ? Math.Max(maxDist, DisengageDistance) : maxDist)) continue; // User-configured "never attack" list — excluded from acquisition // entirely (an already-engaged match drops out of _scannedTargets // here and is released by the scan-grace timer in Think). - if (IsUserBlacklistedName(wo.Name)) continue; + if (!isForced && IsUserBlacklistedName(wo.Name)) continue; if (_blacklistManager.IsBlacklisted(wo.Id)) continue; + // A ghost (the server doesn't have it for us): skipped until it shows it is real. + if (Ghosts.IsGhost(wo.Id)) { _ghostsSkippedInScan++; continue; } + // Just killed (KillerNotification) but not yet a corpse — skip so we // don't re-lock and cast at it during its death animation. if (_recentlyKilled.ContainsKey(wo.Id)) continue; @@ -950,6 +1008,13 @@ public partial class CombatManager : IDisposable // Dead but not yet reclassified as corpse — skip if (_worldFilter.GetHealthRatio(wo.Id) == 0f) continue; + // Monster rule Priority 0 = IGNORE, with no exception: even one attacking us is never + // attacked (a monster worth fighting back needs a rule above 0). Left out of the + // scan entirely, so it is neither a target nor a reason to hold nav, + // combat, looting or buffs: every consumer reads this list or _nearbyNoLos, and an + // ignored monster is not counted in either (it is dropped before the LOS check). + if (!isForced && PriorityOf(wo.Id) <= 0) continue; + bool losBlocked = false; if (_settings.EnableRaycasting && RaycastInitialized && _raycastSystem?.TargetingFSM != null) { @@ -1007,6 +1072,7 @@ public partial class CombatManager : IDisposable // Diagnostic: surface every blacklist (any path) with id + reason so a // single login test is conclusive instead of another guess. _blacklistManager.Log = m => _host.Log($"[Blacklist] {m}"); + Ghosts.Cleared = (id, why) => _host.Log($"[Ghost] 0x{(uint)id:X8} '{_worldFilter[id]?.Name}' is real after all ({why}) - targetable again."); ElementTracker = new WeaponElementTracker(host); } @@ -1034,6 +1100,7 @@ public partial class CombatManager : IDisposable _recentlyKilled.Remove(id); _hitAt.Remove(id); _blacklistManager.ForgetTarget(id); + Ghosts.NoteDeleted(id); if (id == activeTargetId || id == _lockedTargetId || id == _lastAttackedTargetId) _awaitingCastResolution = false; @@ -1100,6 +1167,29 @@ public partial class CombatManager : IDisposable // chat-confirmation handler can record the cast against the right target // for blacklist judgement — even if activeTargetId has since changed. private int _pendingOffensiveTargetId = 0; + // The UseDone count at the pending offensive cast's send, and its answer (-1 = not seen yet). + private int _pendingOffensiveSeqAtSend; + private long _pendingOffensiveErr = -1; + /// Casts the server refused 'too busy' that were kept out of the no-damage count (tests, status). + internal int RefusedCastsNotJudged { get; private set; } + + private void NoteOffensiveSeq() + { + _pendingOffensiveSeqAtSend = _host.HasUseDoneSeq ? _host.GetUseDoneSeq() : 0; + _pendingOffensiveErr = -1; + } + + /// The first UseDone after the pending offensive cast's send is its answer. + private void ObserveOffensiveAnswer() + { + if (_pendingOffensiveErr >= 0 || !_host.HasUseDoneSeq) return; + try + { + if (_host.TryGetLastUseDone(out int seq, out uint err) && seq == _pendingOffensiveSeqAtSend + 1) + _pendingOffensiveErr = err; + } + catch { } + } private const double OFFENSIVE_NOCHAT_TIMEOUT_MS = 5000.0; // ACE doesn't emit "You cast X" chat for offensive war magic, so we infer // a successful server cast by NEGATION: if no "You're too busy!" arrives @@ -1530,6 +1620,9 @@ public partial class CombatManager : IDisposable // BuffManager's categorisation so a war spell the char can't actually // cast gets marked unresolvable and FindBestOffensiveSpellId drops to // an alternative, instead of silently re-firing the dead spell forever. + // A script's cast (RynthAi.Combat) is remembered on its own: it may not have armed the + // pending judgement (an area, nojudge or off-target cast) yet must not be re-cast forever. + NoteScriptCastRefusal(text); if (_pendingOffensiveSpellId != 0) { string lo = text.ToLowerInvariant(); @@ -1791,6 +1884,7 @@ public partial class CombatManager : IDisposable DateTime now = DateTime.Now; _lastSwingEvidenceAt = now; _lastSwingEvidenceKind = kind; + _attacksSinceEvidence = 0; switch (kind) { case "hit": _lastHitAt = now; break; @@ -1938,6 +2032,21 @@ public partial class CombatManager : IDisposable FlightRecorderSignal.Dump(_host, $"casts with no damage at 0x{(uint)tid:X8}"); } + /// + /// For the no-damage blacklist: is the locked target, no swing evidence + /// came since it was locked (not a hit or evade on anything), it hasn't moved since, and the + /// server has said nothing about it for . + /// + private bool LooksLikeGhost(int tid, out double silentMs) + { + silentMs = -1; + if (tid == 0 || tid != _lockedTargetId || _targetLockedAt == DateTime.MinValue) return false; + if (_lastSwingEvidenceAt >= _targetLockedAt) return false; + if (_lockSpot == null || TargetSpot(tid) is not GhostSpot now || now.MovedFrom(_lockSpot.Value)) return false; + silentMs = ServerSilentMs(tid, DateTime.Now); + return silentMs < 0 || silentMs >= GhostCheck.NoUpdateMs; + } + private void JudgePendingCast() { if (_pendingJudgeCastAt == DateTime.MinValue) return; @@ -1956,6 +2065,12 @@ public partial class CombatManager : IDisposable if (_consecutiveCastMisses >= _settings.BlacklistAttempts) { if (CurrentCombatMode == CombatMode.Magic) ReportNoDamageCasts(tid); + if (CurrentCombatMode != CombatMode.Magic && LooksLikeGhost(tid, out double silentMs)) + { + _consecutiveCastMisses = 0; + MarkGhost(tid, _worldFilter[tid]?.Name, silentMs, $"{_settings.BlacklistAttempts} attacks with no swing, no hit and no evade"); + return; + } _blacklistManager.ReportFailure(tid); if (_blacklistManager.IsBlacklisted(tid)) { @@ -1984,9 +2099,24 @@ public partial class CombatManager : IDisposable if (_pendingOffensiveSpellId == 0) return; if (_pendingOffensiveTargetId == 0) return; if (_pendingOffensiveCastAt == DateTime.MinValue) return; + ObserveOffensiveAnswer(); if ((DateTime.Now - _pendingOffensiveCastAt).TotalMilliseconds < OffensiveRefusalWindowMs) return; + // A refusal is not a cast (in a client log, three healthy targets were blacklisted 'after 3 + // no-damage casts' whose casts had all come back UseDone 0x1D): + // the answer 0x1D, or no answer yet while the server is taken as busy, is not judged. + bool refused = _pendingOffensiveErr == ActionPacer.TooBusyErr || (_pendingOffensiveErr < 0 && ActionPacer.ServerBusy); + if (refused) + { + RefusedCastsNotJudged++; + _host.Log($"[Blacklist] cast at 0x{(uint)_pendingOffensiveTargetId:X8} {(_pendingOffensiveErr >= 0 ? "refused 'too busy' (UseDone 0x1D)" : "unanswered while the server is busy")}: not counted as a no-damage cast"); + _pendingOffensiveSpellId = 0; + _pendingOffensiveTargetId = 0; + _pendingOffensiveCastAt = DateTime.MinValue; + return; + } + // Refusal window passed without a "too busy" — the server accepted // the gesture. Queue this cast for blacklist judgement. int targetId = _pendingOffensiveTargetId; @@ -2623,6 +2753,15 @@ public partial class CombatManager : IDisposable /// The least Attack Spell Delay on an engine without the server gates. internal const double NoGatesAttackFloorMs = 250; + /// Melee/missile: the first attack at a new target, with the server gates (see + /// ). + internal const double NewTargetPhysicalFloorMs = 200; + + /// Melee/missile: the attack after a CancelAttack (attack rebind or stall re-issue). + /// ACE answers the cancel within a server tick or two; a swing still playing holds the attack + /// through the busy count, so the full 1000 ms interval is not needed here. + internal const double AttackAfterCancelMs = 300; + /// True when is positive only because AC lowered it inline at a /// server UseDone the busy hook can't see (see ). internal bool BusyIsLeftover() @@ -2643,10 +2782,16 @@ public partial class CombatManager : IDisposable /// server gates (UseDone and the cast gesture): those already hold the cast until the /// previous one is finished, so the new target only waits . /// Casting at the same target keeps the full setting. + /// Melee/missile at a new target with the server gates: . + /// The 1000 ms is the re-assert cadence for the target being fought; the first swing at the + /// next one only waited out what was left of it ([CombatLatency] "interval 9xx" on most locks, + /// Drakkon 2026-10-12), while the busy count already holds the attack until the last swing's + /// AttackDone and an attack still bound to a live old target is released first (rebind). /// internal static double AttackIntervalMs(int combatMode, int attackSpellIntervalMs, bool hasServerGates, bool newTarget) { - if (combatMode != CombatMode.Magic) return 1000.0; + if (combatMode != CombatMode.Magic) + return newTarget && hasServerGates ? NewTargetPhysicalFloorMs : 1000.0; // 0 is allowed (2026-10-08): no delay of its own, the server gates (UseDone and the cast // gesture) alone hold the next cast until the last one is done. A file without the setting // keeps 1500 (the payload is nullable). An engine without those gates keeps a 250 ms floor, @@ -2684,6 +2829,7 @@ public partial class CombatManager : IDisposable private bool ThinkCore() { + _rebindThisTick = false; if (!_settings.EnableCombat) return false; // A stall-watchdog re-wield must finish (weapon back in hand) before anything @@ -2775,6 +2921,12 @@ public partial class CombatManager : IDisposable if (blacklisted) DropTarget("blacklisted"); + else if (target != null && activeTargetId != ForcedTargetId && PriorityOf(activeTargetId) <= 0) + { + // The rule says ignore (it changed, or the rule cache caught up). + ForgetScanned(activeTargetId); + DropTarget("ignored (monster rule Priority 0)"); + } else if (target != null && IsSpellProjectileName(target.Name)) DropTarget("spell projectile (not a monster)"); else if (target != null && (int)target.ObjectClass != (int)AcObjectClass.Monster) @@ -2919,12 +3071,13 @@ public partial class CombatManager : IDisposable // wield, attack or cast while the server is still answering the last action (a kit, a corpse // use, a buff, the last stance change). On ACE a mode change cancels a pending use's walk // and fails a cast in progress; that interleaving began every stuck-use stall on record. - // Melee/missile attack repeats skip the animation gate (gestureGate false): the server swings + // Melee/missile attack repeats skip the animation and settle gates and the 'too busy' latch (ACE + // sends no UseDone for a swing, so a latch set by a refused pickup would starve them): the server swings // on its own timers, a swing can't land inside a use's server turn because the use above holds // every attack until it is answered, and waiting for each swing animation would cost DPS. A // stance change still waits (ChangeCombatModeFor), and so does everything in peace/magic. bool attackRepeat = CurrentCombatMode == CombatMode.Melee || CurrentCombatMode == CombatMode.Missile; - if (!ActionPacer.MayStart(_host, "Combat", HealNeed.None, out _, gestureGate: !attackRepeat)) + if (!ActionPacer.MayStart(_host, "Combat", HealNeed.None, out _, animationGate: !attackRepeat, settleGate: !attackRepeat, attackRepeat: attackRepeat)) { LastCombatSkipReason = "server-answering"; // D4 record-only _tickWait = CombatLatencyTracker.Wait.Busy; @@ -3141,6 +3294,15 @@ public partial class CombatManager : IDisposable return true; } + // Waiting on a script's choice of spell (RynthAi.Combat): nothing was sent. The same + // as the wall hold: the attack interval doesn't start, the target and scan stay as they + // are, and the next tick asks again (bounded by the request's deadline). + if (_scriptHeld) + { + _tickWait = CombatLatencyTracker.Wait.Other; + return true; + } + // Don't restore the physical weapon on top of a cast just issued this tick // (AttackWithMagic → MarkCombatCastIssued): the UseObject + re-equip below would // truncate the in-flight gesture and strand Player.IsBusy. Defer one windup @@ -3225,6 +3387,10 @@ public partial class CombatManager : IDisposable RecordOffensiveCast(activeTargetId); lastAttackCmd = DateTime.Now; _lastAttackCmdTargetId = activeTargetId; + // A rebind sent only the CancelAttack: the attack follows as soon as the cancel can + // have landed, not a whole interval later ("lock->attack 1750 ms (interval 1671)"). + if (!physicalSent && _rebindThisTick) + lastAttackCmd = AttackAfterCancel(lastAttackCmd); // Predicted kill shot (set in AttackWithMagic): the cast we just fired // is expected to finish this mob. DON'T swap yet — on ACE a war cast is @@ -3313,7 +3479,22 @@ public partial class CombatManager : IDisposable return false; } - var act = _stallWatch.Tick(now, eligible, _lastSwingEvidenceAt, out double stalledMs); + bool quiet = SampleMeleeQuiet(now, eligible && mode == CombatMode.Melee); + + // After the step-1 re-issue: still no swing, not moved, nothing from the server = a ghost. + if (_ghostCheck.IsArmed) + { + int tid = activeTargetId; + double silent = ServerSilentMs(tid, now); + if (_ghostCheck.Check(tid, now, _lastSwingEvidenceAt, TargetSpot(tid), silent) == GhostCheck.Verdict.Ghost) + { + MarkGhost(tid, targetObj.Name, silent, $"no swing after {_attacksSinceEvidence} attack(s) and a re-issue"); + lastAttackCmd = now; + return true; + } + } + + var act = _stallWatch.Tick(now, eligible, _lastSwingEvidenceAt, out double stalledMs, quiet); switch (act) { case CombatStallWatchdog.StallAction.None: @@ -3341,10 +3522,14 @@ public partial class CombatManager : IDisposable switch (act) { case CombatStallWatchdog.StallAction.Reissue: + { ReleaseServerAttack("stall watchdog", log: false); - lastAttackCmd = now; // the attack goes out again one cycle later, after the cancel lands - _host.Log($"{head} re-issue: CancelAttack, attack 0x{activeTargetId:X8} again next cycle"); + lastAttackCmd = AttackAfterCancel(now); // the attack goes out again once the cancel has landed + _ghostCheck.Arm(activeTargetId, now, TargetSpot(activeTargetId)); + _host.Log($"{head} re-issue: CancelAttack, attack 0x{activeTargetId:X8} again next cycle" + + (_stallWatch.LastFireWasEarly ? $" (early: {stalledMs / 1000:0.0}s with no swing playing and the character standing still)" : "")); return true; + } case CombatStallWatchdog.StallAction.Reselect: { @@ -3363,13 +3548,22 @@ public partial class CombatManager : IDisposable // Same effect on the server as the wand heal: a mode change runs // HandleActionCancelAttack. EquipWeaponAndSetStance flips back after its // stance retry delay (~1 s with the flip backoff reset). - _host.ChangeCombatModeFor(CombatMode.NonCombat, "Combat/Stall", "stall watchdog: toggle the mode", force: true); - _stallToggleAt = now; - ResetStanceFlipBackoff(); - lastStanceAttempt = now; - _serverAttackTargetId = 0; - lastAttackCmd = now; - _host.Log($"{head} toggle mode: peace, then back to {CombatModeName(mode)} on the next stance pass"); + // Only a toggle the engine accepted starts the flip-back bookkeeping. A refusal (a teleport, + // a death) leaves it untouched and takes the ladder step back (Unfire), so it spends no step + // and the toggle is asked for again next tick. + if (_host.ChangeCombatModeFor(CombatMode.NonCombat, "Combat/Stall", "stall watchdog: toggle the mode", force: true)) + { + _stallToggleAt = now; + ResetStanceFlipBackoff(); + lastStanceAttempt = now; + _serverAttackTargetId = 0; + _host.Log($"{head} toggle mode: peace, then back to {CombatModeName(mode)} on the next stance pass"); + lastAttackCmd = now; + } + else + { + _stallWatch.Unfire(); + } return true; case CombatStallWatchdog.StallAction.Rewield: @@ -3382,6 +3576,117 @@ public partial class CombatManager : IDisposable private CombatStallWatchdog.StallAction _lastStallStep = CombatStallWatchdog.StallAction.None; + /// How long the server has said nothing about : the engine's + /// record (plugin API v83) when it has one, else the plugin's own OnUpdateObject/OnCreateObject + /// record; -1 when neither has any. + internal double ServerSilentMs(int id, DateTime now) + { + if (_host.HasGetObjectServerAge) + { + int age = _host.GetObjectServerAge((uint)id); + if (age >= 0) return age; + } + return Ghosts.SilentMs(id, now); + } + + /// + /// is a ghost: logged once, skipped by targeting until the server shows + /// it is real or the landblock changes, dropped as the target, and removed from the client + /// when the engine can (v83). Its no-damage blacklist entry, if any, is dropped (the ghost + /// mark outlives it). + /// + internal void MarkGhost(int id, string? name, double silentMs, string why) + { + if (id == 0) return; + uint pid = _playerId != 0 ? _playerId : _host.GetPlayerId(); + uint lb = pid != 0 && _host.TryGetObjectPosition(pid, out uint pc, out _, out _, out _) ? pc >> 16 : 0; + GhostSpot spot = TargetSpot(id) ?? new GhostSpot(double.NaN, double.NaN, double.NaN); + Ghosts.Mark(id, name ?? "", spot, lb, DateTime.Now); + _blacklistManager.ClearFailure(id); + string silent = silentMs < 0 ? "nothing from the server about it since it was first seen" : $"nothing from the server about it for {silentMs / 1000:0}s"; + _host.Log($"[Ghost] 0x{id:X8} '{name}' is a ghost: {why}, {silent}, it hasn't moved [{DescribeTargetPos(id)}]. " + + $"Skipped until the server sends anything about it or the landblock changes (ghosts now: {Ghosts.Count})."); + if (id == activeTargetId || id == _lockedTargetId) + DropTarget("ghost (the server doesn't have it)"); + if (_host.HasRemoveClientObject) + { + int r = _host.RemoveClientObject((uint)id); + _host.Log($"[Ghost] 0x{id:X8}: " + r switch + { + 1 => "removed from the client", + 2 => "removal queued (AC's main thread)", + -1 => "not removed: the client's DeleteObject isn't bound yet (no delete since the engine loaded)", + _ => "not removed: the engine refused (see the engine log)", + }); + } + } + + /// The server sent an update for (RynthAiPlugin.OnUpdateObject). + public void OnServerObjectUpdate(uint objectId) => Ghosts.NoteServerUpdate((int)objectId, DateTime.Now); + + /// The server created (RynthAiPlugin.OnCreateObject). + public void OnObjectCreated(uint objectId) => Ghosts.NoteServerUpdate((int)objectId, DateTime.Now, "the server created it again"); + + /// + /// Samples the swing animation and the character's position every stall-watch tick and says + /// whether melee is plainly stuck: at least two attacks sent since the last hit, miss or kill, + /// nothing animating for and the character not moving for + /// . A swing in progress animates and a server move-to to the target + /// moves the character, so neither reads as quiet. False without the engine's motion read. + /// + private bool SampleMeleeQuiet(DateTime now, bool melee) + { + if (!_host.HasGetCastBusyState) return false; + // A gap (combat paused, a loot run): start the clocks over rather than read the gap as quiet. + if (_lastQuietSampleAt == DateTime.MinValue || (now - _lastQuietSampleAt).TotalMilliseconds > CombatStallWatchdog.TickGapResetMs) + { + _lastAnimatingAt = now; + _lastPlayerMovedAt = now; + _moveAnchorX = double.NaN; + } + _lastQuietSampleAt = now; + + bool animating; + try { animating = _host.GetCastBusyState() != 0; } catch { animating = true; } + if (animating) _lastAnimatingAt = now; + + uint pid = _playerId != 0 ? _playerId : _host.GetPlayerId(); + if (pid != 0 && _host.TryGetObjectPosition(pid, out uint pc, out float px, out float py, out float pz)) + { + double gx = ((pc >> 24) & 0xFF) * 192.0 + px, gy = ((pc >> 16) & 0xFF) * 192.0 + py; + if (double.IsNaN(_moveAnchorX)) + { + _moveAnchorX = gx; _moveAnchorY = gy; _moveAnchorZ = pz; + } + else + { + double dx = gx - _moveAnchorX, dy = gy - _moveAnchorY, dz = pz - _moveAnchorZ; + if (dx * dx + dy * dy + dz * dz > QuietMoveM * QuietMoveM) + { + _moveAnchorX = gx; _moveAnchorY = gy; _moveAnchorZ = pz; + _lastPlayerMovedAt = now; + } + } + } + else _lastPlayerMovedAt = now; // no position: never call it standing still + + return melee + && _attacksSinceEvidence >= 2 + && (now - _lastAnimatingAt).TotalMilliseconds >= QuietNoAnimMs + && (now - _lastPlayerMovedAt).TotalMilliseconds >= QuietStillMs; + } + + /// Where a target is (landblock-global x/y and z), or null. + private GhostSpot? TargetSpot(int id) + { + if (id == 0 || !_host.TryGetObjectPosition((uint)id, out uint c, out float x, out float y, out float z)) return null; + return new GhostSpot(((c >> 24) & 0xFF) * 192.0 + x, ((c >> 16) & 0xFF) * 192.0 + y, z); + } + + /// The lastAttackCmd stamp that lets the next melee/missile attack go + /// after (the interval is 1000 ms there). + private static DateTime AttackAfterCancel(DateTime now) => now.AddMilliseconds(AttackAfterCancelMs - 1000.0); + /// Stall watchdog / attack-rebind counters for /ra why. public int StallEpisodes => _stallWatch.Episodes; public int StallRecoveries => _stallWatch.Recoveries; @@ -3652,6 +3957,7 @@ public partial class CombatManager : IDisposable public void HandleCombatTrigger() { if (_scannedTargets.Count == 0) return; + if (TryLockForcedTarget()) return; // Target lock (/ra targetlock): CombatManager.TargetLock.cs DateTime now = TargetClock(); double acquireRange = Math.Max(1.0, _settings.MonsterRange); @@ -3739,14 +4045,20 @@ public partial class CombatManager : IDisposable // One line per real switch. A switch should be a genuine event (target died, left, // or a higher priority showed up; with the lock off, something clearly better). If // this floods the log, selection is thrashing again. + int bestPriority = PriorityOf(best.Id); + LockTarget(best, bestPriority, $"{SchemeName(scheme)}: {DescribeSchemeValue(scheme, best)}, priority {bestPriority}, {DescribeTargetPos(best.Id)}", switchWhy); + } + + /// Makes the fight target (one log line; the switch says why). + private void LockTarget(ScannedTarget best, int bestPriority, string picked, string? switchWhy) + { int bestId = best.Id; - int bestPriority = PriorityOf(bestId); - string picked = $"{SchemeName(scheme)}: {DescribeSchemeValue(scheme, best)}, priority {bestPriority}, {DescribeTargetPos(bestId)}"; if (_lockedTargetId != 0) _host.Log($"[CombatTarget] switch 0x{_lockedTargetId:X8} '{_worldFilter[_lockedTargetId]?.Name}' ({switchWhy}, {DescribeTargetPos(_lockedTargetId)}) " + $"-> 0x{bestId:X8} '{_worldFilter[bestId]?.Name}' ({picked})"); else - _host.Log($"[CombatTarget] lock 0x{bestId:X8} '{_worldFilter[bestId]?.Name}' ({picked})"); + _host.Log($"[CombatTarget] lock 0x{bestId:X8} '{_worldFilter[bestId]?.Name}' ({picked})" + + (_ghostsSkippedInScan > 0 ? $" [{_ghostsSkippedInScan} ghost(s) in range skipped]" : "")); // [CombatLatency]: time this engagement from the lock to its first attack. double lockMs = Environment.TickCount64; @@ -3757,9 +4069,10 @@ public partial class CombatManager : IDisposable _lockedTargetId = bestId; _lockedPriority = bestPriority; _targetLockedAt = DateTime.Now; + _lockSpot = TargetSpot(bestId); _lastDamageDealtAt = DateTime.MinValue; _lockedLastSeen = best; // it was in this tick's scan: the grace covers a blink next tick - _lockedLastSeenInScan = now; + _lockedLastSeenInScan = TargetClock(); _consecutiveCastMisses = 0; _pendingJudgeCastAt = DateTime.MinValue; _facingTarget = false; @@ -3860,6 +4173,9 @@ public partial class CombatManager : IDisposable return progress != DateTime.MinValue && (now - progress).TotalMilliseconds <= UndamagedCommitmentMaxMs; } + /// True when the monster rule for says Priority 0 (never attacked). + internal bool IsIgnored(int id) => id != ForcedTargetId && PriorityOf(id) <= 0; + /// The Priority of the monster rule that applies to (its own /// row by name or match expression, else the DEFAULT row; 1 when neither exists). Cached per /// monster for ; the cache empties when the rule list changes. @@ -4039,14 +4355,33 @@ public partial class CombatManager : IDisposable /// The Items list's usable weapons, in list order, with their kind, element, rending and whether each is in hand. internal List ListedCandidates() { + var list = ListedCandidates(admitCasters: false, out List? leftOut); + // A script choosing the attack spells (RynthAi.Combat) can attack with a caster whatever + // War/Void training says, but only when the list has no melee/missile weapon to use: + // a fighter's listed buff wand must not pull it out of melee. + if (list.Count == 0 && leftOut != null && ScriptPicksAttack) + return ListedCandidates(admitCasters: true, out _); + if (list.Count == 0 && leftOut != null) + foreach (int id in leftOut) + if (_wandRejectedNoted.Add(id)) + _host.Log($"[EquipDiag] caster 0x{(uint)id:X8} '{_worldFilter[id]?.Name}' is not a combat weapon: {CanMagicDiag()}"); + return list; + } + + /// Take listed casters even with War and Void untrained. + /// The casters skipped for that (null when none). + private List ListedCandidates(bool admitCasters, out List? leftOut) + { + leftOut = null; int inHand = InHandWeaponId(); var list = new List(); foreach (var r in _settings.ItemRules) { - if (r.Id == 0 || !IsUsableCombatWeapon(r.Id)) continue; - if (list.Any(c => c.Id == r.Id)) continue; + if (r.Id == 0) continue; var wo = _worldFilter[r.Id]; if (wo == null) continue; + if (!admitCasters && !IsUsableCombatWeapon(r.Id)) { (leftOut ??= new List()).Add(r.Id); continue; } + if (list.Any(c => c.Id == r.Id)) continue; if (wo.ObjectClass == AcObjectClass.MissileWeapon && IsAmmoItem(wo)) continue; // listed arrows are the ammo choice, never a weapon to wield if (IsShieldItem(wo)) continue; // listed shields are the off hand's (CombatManager.Offhand.cs) var info = ElementTracker.Read(r.Id, wo.Name); @@ -4128,13 +4463,23 @@ public partial class CombatManager : IDisposable return any ? CreatureWeakness.FromAppraisal(m) : null; } + /// + /// Optional UtilityBelt damage seed lookup (wcid, name) → damage types best first, or null. + /// Set by the plugin when the seed store loads; null (default) leaves the ranking as before. + /// Called on the combat thread. + /// + internal Func?>? MobSeedLookup { get; set; } + /// The same by wcid and name; (optional) reads a live creature type. internal CreatureWeakness.Ranking? WeaknessFor(uint wcid, string? name, int objectId = 0) { name ??= ""; int ctype = CreatureTypeOf(wcid, name, objectId); string learned = wcid != 0 ? _damageStore?.GetBestElement(wcid) ?? "" : ""; - return CreatureWeakness.Rank(wcid, name, ctype, learned); + IReadOnlyList? seeded = null; + try { seeded = MobSeedLookup?.Invoke(wcid, name); } + catch { seeded = null; } // a bad seed file must never stop element choice + return CreatureWeakness.Rank(wcid, name, ctype, learned, seeded); } // Server replies seen when the last combat wield was sent (UseDone / WeenieError sequence). @@ -4148,7 +4493,7 @@ public partial class CombatManager : IDisposable { DateTime now = DateTime.Now; if (SwapTracker.PendingId != 0 && ServerRefusedSinceSend()) SwapTracker.Refused(now, WeaponName); - var step = SwapTracker.Next(chosenId, inHandId, now, WeaponName); + var step = SwapTracker.Next(chosenId, inHandId, now, WeaponName, forKey: activeTargetId); if (SwapTracker.Notice != null) { _host.Log($"[EquipDiag] {SwapTracker.Notice}"); @@ -4290,7 +4635,7 @@ public partial class CombatManager : IDisposable if ((DateTime.Now - _lastEquipDiagAt).TotalSeconds > 5) { _lastEquipDiagAt = DateTime.Now; - _host.Log($"[EquipDiag] no weapon found (source=none, desired='{desired}', ItemRules={_settings.ItemRules.Count}, MonsterRule='{rule?.Name ?? "null"}') — proceeding unarmed"); + _host.Log($"[EquipDiag] no weapon found (source=none, desired='{desired}', ItemRules={_settings.ItemRules.Count}, MonsterRule='{rule?.Name ?? "null"}', {CanMagicDiag()}) - proceeding unarmed"); } return EnsureUnarmedStance(); } @@ -4447,9 +4792,15 @@ public partial class CombatManager : IDisposable // watchdog won't) and RE-EQUIP the wand (UseObject resyncs the wield; on a // truly-unwielded wand it wields it, which is the actual fix). Without this // the bot sat in NonCombat for 5h, buffs expired, never fighting (2026-06-10). - if (_stanceStuckSince == DateTime.MinValue) + // The clock starts when a stance request has actually gone out (below), never on refusals + // (see BuffManager's _buffStanceStuckSince): a clock counting through them ends in a re-equip. + // A refusal newer than the clock's start: the request that started it was dropped (a teleport), so restart the clock. + if (_stanceStuckSince != DateTime.MinValue && ActionPacer.LastEngineRefusalMs > _stanceStuckStartMs) + { _stanceStuckSince = DateTime.Now; - double stuckMs = (DateTime.Now - _stanceStuckSince).TotalMilliseconds; + _stanceStuckStartMs = ActionPacer.NowMs(); + } + double stuckMs = _stanceStuckSince == DateTime.MinValue ? 0 : (DateTime.Now - _stanceStuckSince).TotalMilliseconds; // RE-EQUIP recovery — only for the first couple of attempts in an // episode (handles a stale "wielded reads true" on a wand that // actually isn't wielded). Capped: UseObject on a genuinely wielded @@ -4485,6 +4836,7 @@ public partial class CombatManager : IDisposable if ((DateTime.Now - lastStanceAttempt).TotalMilliseconds > StanceRetryDelayMs() && _host.ChangeCombatModeFor(desiredMode, "Combat", "stance")) { + if (_stanceStuckSince == DateTime.MinValue) { _stanceStuckSince = DateTime.Now; _stanceStuckStartMs = ActionPacer.NowMs(); } if (diagNow) { _lastEquipDiagAt = DateTime.Now; _host.Log($"[EquipDiag] wielded=true mode={CurrentCombatMode}→{desiredMode} (weapon=0x{targetWeaponId:X8} '{weaponObj.Name}' src={weaponSource}) — sending ChangeCombatMode"); } lastStanceAttempt = DateTime.Now; NoteStanceFlipSent(); @@ -5216,6 +5568,7 @@ public partial class CombatManager : IDisposable && !IsKnownDead(_serverAttackTargetId)) { _attackRebinds++; + _rebindThisTick = true; ReleaseServerAttack($"target is now 0x{targetId:X8} '{_worldFilter[activeTargetId]?.Name}' {DescribeTargetPos(activeTargetId)}", log: true); LastCombatSkipReason = "attack-rebind"; return false; @@ -5252,6 +5605,7 @@ public partial class CombatManager : IDisposable RynthCore.Plugin.Shared.ActionPacer.NoteAttackSent(); // nothing else starts before this swing plays _serverAttackTargetId = activeTargetId; + _attacksSinceEvidence++; LastCombatSkipReason = "attack"; // D4 record-only: physical attack sent this tick return true; } @@ -5299,6 +5653,7 @@ public partial class CombatManager : IDisposable { _wallFaceHeld = false; _manaCastHeld = false; + _scriptHeld = false; if (_spellManager == null || target == null) return; // Hard safety veto: never cast offensive magic at something AC's combat @@ -5399,6 +5754,11 @@ public partial class CombatManager : IDisposable } } + // A script chooses this cast (RynthAi.Combat, CombatManager.ScriptHook.cs): ask it, wait for + // its answer (held, not an attack yet), cast what it chose; a decline, a bad answer or no + // answer in time falls through to RynthAi's own choice below, this same tick. + if (TryScriptAttack(target, element)) return; + if (rule != null && PickBaseShape(rule) < 0) { _host.Log($"[CombatCast] rule '{rule.Name}' has no attack shapes enabled (UseArc/Ring/Streak/Bolt/Blast/Wall all false) — no offensive cast"); @@ -5464,6 +5824,7 @@ public partial class CombatManager : IDisposable _pendingOffensiveSpellId = offensiveSpellId; _pendingOffensiveCastAt = DateTime.Now; _pendingOffensiveTargetId = activeTargetId; + NoteOffensiveSeq(); // Tag this cast's weapon + element + tier so the pushed damage event // can be attributed to it, count it for casts-to-kill learning, then @@ -5596,13 +5957,32 @@ public partial class CombatManager : IDisposable private static bool IsWandObject(WorldObject wo) => WeaponList.IsWand(wo); - /// 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 => + /// War or Void Magic trained. Skills not read yet count as trained, like the + /// other skill gates here. + private bool AttackMagicTrained => _charSkills == null || _charSkills[AcSkillType.WarMagic].Training >= 2 || _charSkills[AcSkillType.VoidMagic].Training >= 2; + /// A script holds the attack kind (RynthAi.Combat): it picks the attack spell, from + /// any school, so a caster is the combat weapon whatever War/Void training says. + private static bool ScriptPicksAttack => CombatHook.IsActive(RynthAiCombat.KindAttack); + + /// The character can attack with a caster: War or Void Magic trained, or a script + /// choosing the attack spells (a Life-only caster whose script drains, for one). Gates the + /// wand fallback when no weapon was chosen; the Items list itself admits a caster under the + /// hook only when it has no melee/missile weapon (ListedCandidates). + private bool CanAttackWithMagic => AttackMagicTrained || ScriptPicksAttack; + + /// For the [EquipDiag] lines: canMagic and whether the script hook made it true. + private string CanMagicDiag() + { + bool trained = AttackMagicTrained, hook = ScriptPicksAttack; + return $"canMagic={trained || hook}" + (hook && !trained ? " (script attack hook)" : ""); + } + + private readonly HashSet _wandRejectedNoted = new(); + /// A weapon combat may fight with: anything the character has (in the world /// cache) but a caster when the character has no attack magic. Debuff casting picks its /// wand separately. An id missing from the cache is not a candidate: a weapon that was @@ -5613,7 +5993,7 @@ public partial class CombatManager : IDisposable { var wo = _worldFilter[id]; if (wo == null) return false; - return CanAttackWithMagic || !IsWandObject(wo); + return AttackMagicTrained || !IsWandObject(wo); } private static List BuildDebuffList(MonsterRule rule, string element) diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatStallWatchdog.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatStallWatchdog.cs index ad229c6..665c8a2 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatStallWatchdog.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatStallWatchdog.cs @@ -29,6 +29,12 @@ internal sealed class CombatStallWatchdog /// real stalls ran 12-49 s. public const double StallMs = 6000; + /// Melee that is plainly stuck - attacks sent, no swing playing, the character + /// standing still (CombatManager.SampleMeleeQuiet) - gets step 1 after this instead (Drakkon + /// 2026-10-12: the server's move-to the target stalled 2 m short; the cancel 6 s later fixed + /// it at once every time, so most of the 7-9 s per stall was the wait). + public const double QuietStallMs = 2500; + /// Time allowed for each step to show a swing before the next one. public const double StepMs = 3000; @@ -47,6 +53,7 @@ internal sealed class CombatStallWatchdog private DateTime _lastStepAt = DateTime.MinValue; private DateTime _cooldownUntil = DateTime.MinValue; private int _step; // steps fired in the current episode (0 = none) + private DateTime _prevStepAt = DateTime.MinValue; // _lastStepAt before the newest Fire (for Unfire) private DateTime _stallRef = DateTime.MinValue; // last swing (or episode start) before the stall /// Episodes where the watchdog acted (diagnostics / status). @@ -55,14 +62,18 @@ internal sealed class CombatStallWatchdog public int Recoveries { get; private set; } /// The last step fired in the current episode (0 = none). public int CurrentStep => _step; + /// The episode's step 1 fired on rather than . + public bool LastFireWasEarly { get; private set; } public static int StepCount => 4; /// /// Advance the watchdog. is the full precondition set; - /// the last hit, miss or kill. Returns the step to - /// carry out now (or Recovered / GaveUp for logging), with the stalled time. + /// the last hit, miss or kill. : + /// the caller sees no swing playing and the character standing still (step 1 after + /// ). Returns the step to carry out now (or Recovered / GaveUp for + /// logging), with the stalled time. /// - public StallAction Tick(DateTime now, bool eligible, DateTime lastEvidenceAt, out double stalledMs) + public StallAction Tick(DateTime now, bool eligible, DateTime lastEvidenceAt, out double stalledMs, bool quiet = false) { stalledMs = 0; bool gap = _lastTick != DateTime.MinValue @@ -96,7 +107,9 @@ internal sealed class CombatStallWatchdog if (_step == 0) { - if (stalledMs < StallMs) return StallAction.None; + bool early = quiet && stalledMs >= QuietStallMs; + if (stalledMs < StallMs && !early) return StallAction.None; + LastFireWasEarly = stalledMs < StallMs; Episodes++; _stallRef = refAt; return Fire(now); @@ -122,6 +135,7 @@ internal sealed class CombatStallWatchdog private StallAction Fire(DateTime now) { _step++; + _prevStepAt = _lastStepAt; _lastStepAt = now; return _step switch { @@ -132,6 +146,16 @@ internal sealed class CombatStallWatchdog }; } + /// Take back the step just returned because the caller could not carry it out (the engine refused the mode change): + /// a refusal spends no ladder step. The ladder returns to where it was, so the step fires again on the next tick. + public void Unfire() + { + if (_step <= 0) return; + _step--; + _lastStepAt = _prevStepAt; + if (_step == 0 && Episodes > 0) Episodes--; + } + private void ResetEpisode() { _eligibleSince = DateTime.MinValue; diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/FellowshipTracker.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/FellowshipTracker.cs index f4d4681..cdc6726 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/FellowshipTracker.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/FellowshipTracker.cs @@ -348,12 +348,40 @@ public class FellowshipTracker : IDisposable int bufPtr = Marshal.ReadInt32(addr); if (bufPtr == 0) return ""; IntPtr strAddr = new IntPtr(bufPtr + 0x14); - if (!IsReadablePointer(strAddr)) return ""; - string? raw = Marshal.PtrToStringAnsi(strAddr); - if (raw == null) return ""; - if (raw.Length > 64) raw = raw[..64]; - return raw; + // Bounded read: PtrToStringAnsi scans to a NUL however far that is, past + // the probed region into unmapped memory if the buffer is mid-free or never terminated. + return ReadBoundedAnsi(strAddr, MaxNameChars, ReadableBytesFrom(strAddr)); } catch { return ""; } } + + /// A fellowship member's name is at most this long (AC names are under 20). + internal const int MaxNameChars = 64; + + /// Bytes from to the end of its committed region (the probed + /// page run); 0 when the address is not readable. + internal static int ReadableBytesFrom(IntPtr ptr) + { + if (ptr == IntPtr.Zero) return 0; + if (VirtualQuery(ptr, out var mbi, Marshal.SizeOf()) == 0) return 0; + if (mbi.State != MEM_COMMIT) return 0; + if ((mbi.Protect & PAGE_NOACCESS) != 0 || (mbi.Protect & PAGE_GUARD) != 0) return 0; + long left = (long)mbi.BaseAddress + (long)mbi.RegionSize - (long)ptr; + return left <= 0 ? 0 : (int)Math.Min(left, int.MaxValue); + } + + /// + /// Reads a NUL-terminated ANSI string of at most characters and + /// never more than bytes from . An + /// unterminated run is cut at the bound, not scanned on. Internal for the tests. + /// + internal static unsafe string ReadBoundedAnsi(IntPtr addr, int maxChars, int readableBytes) + { + int limit = Math.Min(maxChars, readableBytes); + if (addr == IntPtr.Zero || limit <= 0) return ""; + byte* p = (byte*)addr; + int n = 0; + while (n < limit && p[n] != 0) n++; + return n == 0 ? "" : Marshal.PtrToStringAnsi(addr, n) ?? ""; + } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/GhostCheck.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/GhostCheck.cs new file mode 100644 index 0000000..0c681b7 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/GhostCheck.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections.Generic; + +namespace RynthCore.Plugin.RynthAi; + +// ── Ghost creatures (Drakkon 2026-10-12, Olthoi in 0x6146) ─────────────────────────────────── +// A ghost is an object the client still draws but the server no longer has for this player. +// Drakkon stood for 25+ minutes swinging at four of them: the engine's flight recorder shows every +// MeleeAttack answered within ~35 ms by AttackDone ActionCancelled, no CombatCommenceAttack, no +// motion; the "monsters" never moved, never died, and the server sent nothing about them after the +// character walked past at 20:58:15. A real Olthoi that walked up at 21:27 was killed in 6 s. The +// no-damage blacklist dropped each ghost for 30 s, so with four of them around the bot went round +// and round and navigation never got a turn. + +/// A point in landblock-global coordinates (x/y across landblocks, z as is). +internal readonly record struct GhostSpot(double X, double Y, double Z) +{ + /// Movement (m) that means the object is alive on the server. + public const double MovedM = 0.05; + + public bool MovedFrom(GhostSpot other) + { + double dx = X - other.X, dy = Y - other.Y, dz = Z - other.Z; + return dx * dx + dy * dy + dz * dz > MovedM * MovedM; + } +} + +/// +/// The verdict on one stalled target, armed when the stall watchdog's step 1 (CancelAttack + attack +/// again) goes out. Ghost once passed with no swing evidence since the +/// re-issue, the same target, not moved, and the server silent about it for +/// (a monster fighting anyone nearby gets motion updates every few seconds; even an idle one +/// answers an attack with a turn and a swing). Pure. +/// +internal sealed class GhostCheck +{ + public const double AnswerWaitMs = 1500; + public const double NoUpdateMs = 8000; + + public enum Verdict { None, Alive, Ghost } + + private int _target; + private DateTime _at; + private GhostSpot? _spot; + + public bool IsArmed => _target != 0; + + public void Arm(int targetId, DateTime now, GhostSpot? spot) + { + if (targetId == 0 || spot == null) { Disarm(); return; } + _target = targetId; + _at = now; + _spot = spot; + } + + public void Disarm() + { + _target = 0; + _spot = null; + } + + /// + /// : how long the server has said nothing about the target + /// (-1 = unknown: no record since the engine and the plugin started watching, which for an + /// object the client already had means nothing either). + /// + public Verdict Check(int targetId, DateTime now, DateTime lastEvidenceAt, GhostSpot? spot, double serverSilentMs) + { + if (_target == 0) return Verdict.None; + if (targetId != _target || lastEvidenceAt > _at || spot == null || spot.Value.MovedFrom(_spot!.Value) + || (serverSilentMs >= 0 && serverSilentMs < (now - _at).TotalMilliseconds)) + { + Disarm(); + return Verdict.Alive; // a swing, a move, a server message since the re-issue, or another target + } + if ((now - _at).TotalMilliseconds < AnswerWaitMs) return Verdict.None; + Disarm(); + return serverSilentMs < 0 || serverSilentMs >= NoUpdateMs ? Verdict.Ghost : Verdict.Alive; + } +} + +/// +/// The ghosts found this session. A ghost is skipped by targeting until the server shows it is +/// real after all (any update or create for its id, or it moves) or the character changes +/// landblock - not for a fixed time. Its server-update clock is kept here too, for engines before +/// plugin API v83 (no GetObjectServerAge). Pump thread only. +/// +internal sealed class GhostTracker +{ + public readonly record struct Ghost(int Id, string Name, GhostSpot Spot, uint Landblock, DateTime MarkedAt); + + private readonly Dictionary _ghosts = new(); + private readonly Dictionary _lastUpdate = new(); + private readonly List _scratch = new(); + private const int MaxUpdateEntries = 8192; + + /// Called with (id, why) when a ghost turns out real or is forgotten. + public Action? Cleared; + + public int Count => _ghosts.Count; + public IEnumerable All => _ghosts.Values; + public int MarkedTotal { get; private set; } + + public bool IsGhost(int id) => id != 0 && _ghosts.ContainsKey(id); + + public void Mark(int id, string name, GhostSpot spot, uint landblock, DateTime now) + { + if (id == 0) return; + if (!_ghosts.ContainsKey(id)) MarkedTotal++; + _ghosts[id] = new Ghost(id, name, spot, landblock, now); + } + + /// The server sent something about (OnUpdateObject / OnCreateObject). + public void NoteServerUpdate(int id, DateTime now, string what = "the server sent an update for it") + { + if (id == 0) return; + if (_lastUpdate.Count >= MaxUpdateEntries && !_lastUpdate.ContainsKey(id)) _lastUpdate.Clear(); + _lastUpdate[id] = now; + if (_ghosts.Remove(id)) Cleared?.Invoke(id, what); + } + + public void NoteDeleted(int id) + { + _lastUpdate.Remove(id); + _ghosts.Remove(id); + } + + /// Milliseconds since the plugin last saw a server update for , -1 none. + public double SilentMs(int id, DateTime now) + => _lastUpdate.TryGetValue(id, out DateTime t) ? Math.Max(0, (now - t).TotalMilliseconds) : -1; + + /// Ghosts that moved are real: cleared. null = no position. + public void CheckMoved(Func spotOf) + { + if (_ghosts.Count == 0) return; + _scratch.Clear(); + foreach (Ghost g in _ghosts.Values) + if (spotOf(g.Id) is GhostSpot s && s.MovedFrom(g.Spot)) _scratch.Add(g.Id); + foreach (int id in _scratch) + { + _ghosts.Remove(id); + Cleared?.Invoke(id, "it moved"); + } + } + + /// The character is in (high 16 bits of the cell): ghosts + /// marked in another landblock are let go. + public void OnPlayerLandblock(uint landblock) + { + if (_ghosts.Count == 0 || landblock == 0) return; + _scratch.Clear(); + foreach (Ghost g in _ghosts.Values) + if (g.Landblock != landblock) _scratch.Add(g.Id); + foreach (int id in _scratch) + { + _ghosts.Remove(id); + Cleared?.Invoke(id, "the character changed landblock"); + } + } + + public void Clear() + { + _ghosts.Clear(); + _lastUpdate.Clear(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/MissileCraftingManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/MissileCraftingManager.cs index aa06156..adadd13 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/MissileCraftingManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/MissileCraftingManager.cs @@ -223,7 +223,9 @@ public class MissileCraftingManager _combinesCompleted = 0; _allCombinesDone = false; - try { _host.ChangeCombatModeFor(CombatMode.NonCombat, "Crafting", "missile crafting needs peace mode"); } catch { } + _peaceSent = false; + _peaceAskedAt = DateTime.Now; // the wait for the stance counts from the first ask + TryPeaceForCrafting(); var headItems = inv.Where(i => recipe.IsHead(i.Name)).ToList(); var shaftItems = inv.Where(i => recipe.IsShaft(i.Name)).ToList(); @@ -258,6 +260,22 @@ public class MissileCraftingManager // COMBINING // ══════════════════════════════════════════════════════════════════ + private bool _peaceSent; + private DateTime _peaceAskedAt; + private const double PeaceWaitMaxMs = 2500; + + /// Asks for Peace mode until the engine accepts (a refusal is retried, not counted as sent). + private void TryPeaceForCrafting() + { + if (_peaceSent) return; + try + { + if (_host.HasGetCurrentCombatMode && _host.GetCurrentCombatMode() == CombatMode.NonCombat) { _peaceSent = true; return; } + _peaceSent = _host.ChangeCombatModeFor(CombatMode.NonCombat, "Crafting", "missile crafting needs peace mode"); + } + catch { } + } + private void ProcessCombining() { if (_allCombinesDone) @@ -283,6 +301,12 @@ public class MissileCraftingManager return; } + if (!_peaceSent) + { + TryPeaceForCrafting(); + if (!_peaceSent && (DateTime.Now - _peaceAskedAt).TotalMilliseconds < PeaceWaitMaxMs) return; // still asking, inside the ceiling + } + if ((DateTime.Now - _lastApplyAttempt).TotalMilliseconds >= APPLY_RETRY_MS) { try diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs index 5ad5396..c3bcecd 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs @@ -91,6 +91,26 @@ internal sealed class PetManager internal static Func Clock { get; set; } = static () => Environment.TickCount64; private static long NowMs => Clock(); + /// + /// Optional ILT Hub hook: when it returns true an EMPTY essence is used anyway, because + /// the server's Summon Essence Refill Charm refills it from banked pyreals on use. + /// Null (default) keeps the retail behaviour (spirit refill or park). + /// + public Func? AllowSummonOnEmpty { get; set; } + + /// + /// Optional ILT Hub hook: while it returns true no combat summon is started (e.g. the + /// healing-pet helper has its heal pet out). Null (default) never holds. + /// + public Func? HoldSummons { get; set; } + + /// + /// Optional ILT Hub hook, called when a pet already holds the slot and monsters are near. + /// Returns true after dismissing a non-combat (cosmetic) pet so a combat pet can follow. + /// Null (default) leaves whatever pet is out alone. + /// + public Func? YieldPetForCombat { get; set; } + public PetManager(RynthCoreHost host, LegacyUiSettings settings, WorldObjectCache objectCache, CombatManager? combat, CharacterSkills? skills) @@ -129,7 +149,7 @@ internal sealed class PetManager bool spiritGone = _activeSpiritId != 0 && _objectCache[_activeSpiritId] == null; if (spiritGone || DeviceHasCharges(_activeDeviceId)) { - _host.Log($"[RynthAi] Pet: refill complete (essence 0x{(uint)_activeDeviceId:X8})."); + RynthLog.Write(LogCat.Pets, $"[RynthAi] Pet: refill complete (essence 0x{(uint)_activeDeviceId:X8})."); GoIdle(); } } @@ -138,7 +158,7 @@ internal sealed class PetManager // decrement that never lands), and waiting on it would wedge the subsystem. if (_state != PetState.Idle && now - _actionIssuedAt > ActionTimeoutMs) { - _host.Log($"[RynthAi] Pet: action timeout in {_state} after {now - _actionIssuedAt}ms (essence 0x{(uint)_activeDeviceId:X8}); cooling down."); + RynthLog.Write(LogCat.Pets, $"[RynthAi] Pet: action timeout in {_state} after {now - _actionIssuedAt}ms (essence 0x{(uint)_activeDeviceId:X8}); cooling down."); if (_activeDeviceId != 0) _deviceCooldownUntil[_activeDeviceId] = now + DeviceFailCooldownMs; // A summon that we simply couldn't confirm very likely DID work — assume @@ -176,6 +196,10 @@ internal sealed class PetManager { _host.Log($"[RynthAi] Pet: essence 0x{(uint)_activeDeviceId:X8} reports empty; will refill."); _serverSaidFullUntil.Remove(_activeDeviceId); // really empty: the read is right again + // The server-side pyreal refill didn't happen (charm off / no pyreals): + // park the essence so the empty-summon path can't spin on it. + if (AllowSummonOnEmpty?.Invoke() == true && _activeDeviceId != 0) + _deviceCooldownUntil[_activeDeviceId] = NowMs + DeviceNoSpiritCooldownMs; GoIdle(); return; } @@ -203,7 +227,14 @@ internal sealed class PetManager { // A pet is already up (just summoned, or detected in the world) — done. if (now < _assumePetActiveUntil) return; - if (IsPetActive()) return; + if (IsPetActive()) + { + // A cosmetic pet in the slot steps aside for the fight; wait for the dismiss to land. + if (YieldPetForCombat != null && MonstersNearby() && YieldPetForCombat()) + _assumePetActiveUntil = now + 3000; + return; + } + if (HoldSummons?.Invoke() == true) return; // Only summon when mobs are near (the user's trigger). if (!MonstersNearby()) return; @@ -237,7 +268,15 @@ internal sealed class PetManager return; } - // charges == 0 → empty. Auto-refill from an Encapsulated Spirit. + // charges == 0 → empty. ILT shards with an active pyreal-refill charm refill + // the essence server-side on use, so summon straight away. + if (AllowSummonOnEmpty?.Invoke() == true) + { + IssueSummon(deviceId, charges); + return; + } + + // Otherwise auto-refill from an Encapsulated Spirit. if (_settings.PetAutoRefill) { int spiritId = FindEncapsulatedSpirit(); @@ -267,7 +306,7 @@ internal sealed class PetManager _activeSpiritId = 0; _preActionCharges = charges; _actionIssuedAt = NowMs; - _host.Log($"[RynthAi] Pet: summoning from essence 0x{(uint)deviceId:X8} (charges={charges})."); + RynthLog.Write(LogCat.Pets, $"[RynthAi] Pet: summoning from essence 0x{(uint)deviceId:X8} (charges={charges})."); _host.UseFor(unchecked((uint)deviceId), "Pet", "summon a pet from the essence"); } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellCatalog.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellCatalog.cs new file mode 100644 index 0000000..53ec2f1 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellCatalog.cs @@ -0,0 +1,232 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Reflection; + +namespace RynthCore.Plugin.RynthAi; + +/// One spell from ACECustom's spell catalog (Combat\SpellCatalog.tsv). +internal sealed class SpellCatalogEntry +{ + public int Id; + public string Name = ""; + /// Spell level 1-8 (ACE Spell.Level from Power vs SpellFormula.MinPower). + public int Level; + /// Buff, Debuff, Heal, Harm, Neutral, Projectile or Utility. + public string Effect = ""; + /// Self, Other, Item or Fellowship. + public string Target = ""; + /// ACE SpellCategory: spells in one family don't stack, the highest power wins. + public int FamilyId; + public string FamilyName = ""; + public int Power; + /// Seconds, or -1 for spells without a duration. + public int DurationSec; + /// Creature Enchantment, Life Magic, Item Enchantment, War Magic or Void Magic. + public string School = ""; + public int Mana; + public string Description = ""; + + public bool IsBuff => Effect.Equals("Buff", StringComparison.OrdinalIgnoreCase); + public bool IsSelf => Target.Equals("Self", StringComparison.OrdinalIgnoreCase); + public bool IsItemTarget => Target.Equals("Item", StringComparison.OrdinalIgnoreCase); +} + +/// +/// ACECustom's spell catalog (generated by Tools\Generate-SpellCatalog.ps1 from ACECustom +/// Reports\SpellCatalog-Full.csv). It is the spell list of the Spells window and buff profiles: +/// level, school, Self/Other/Item target and spell family per spell id. +/// +internal static class SpellCatalog +{ + private const string ResourceName = "RynthCore.Plugin.RynthAi.Combat.SpellCatalog.tsv"; + + /// The five magic schools, in the order the UI lists them. + public static readonly string[] Schools = + { + "Creature Enchantment", "Life Magic", "Item Enchantment", "War Magic", "Void Magic", + }; + + private static readonly object Gate = new(); + private static List _all = new(); + private static Dictionary _byId = new(); + private static Dictionary> _byFamily = new(); + private static Dictionary _byName = new(StringComparer.OrdinalIgnoreCase); + private static string[] _effects = Array.Empty(); + + public static bool IsLoaded => _all.Count > 0; + public static IReadOnlyList All => _all; + + /// Distinct effect types present in the catalog (Buff, Debuff, ...), sorted. + public static IReadOnlyList Effects => _effects; + + /// Loads the embedded catalog once. Safe to call repeatedly. + public static void EnsureLoaded(Action? log = null) + { + if (IsLoaded) return; + lock (Gate) + { + if (IsLoaded) return; + try + { + using Stream? stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(ResourceName); + if (stream == null) + { + log?.Invoke($"[RynthAi] Spell catalog resource missing: {ResourceName}"); + return; + } + using var reader = new StreamReader(stream, detectEncodingFromByteOrderMarks: true); + LoadFrom(reader); + } + catch (Exception ex) + { + log?.Invoke($"[RynthAi] Spell catalog load failed: {ex.Message}"); + } + } + } + + /// Parses catalog lines (tests feed their own). Replaces anything loaded before. + public static void LoadFrom(TextReader reader) + { + var all = new List(6400); + string? line; + while ((line = reader.ReadLine()) != null) + { + if (line.Length == 0 || line[0] == '#') continue; + string[] c = line.Split('\t'); + if (c.Length < 11 || !int.TryParse(c[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out int id)) + continue; + all.Add(new SpellCatalogEntry + { + Id = id, + Name = c[1], + Level = ParseInt(c[2]), + Effect = c[3], + Target = c[4], + FamilyId = ParseInt(c[5]), + FamilyName = c[6], + Power = ParseInt(c[7]), + DurationSec = ParseInt(c[8]), + School = c[9], + Mana = ParseInt(c[10]), + Description = c.Length > 11 ? c[11] : "", + }); + } + + var byId = new Dictionary(all.Count); + var byFamily = new Dictionary>(); + var byName = new Dictionary(StringComparer.OrdinalIgnoreCase); + var effects = new SortedSet(StringComparer.OrdinalIgnoreCase); + foreach (var e in all) + { + byId[e.Id] = e; + if (e.FamilyId != 0) + { + if (!byFamily.TryGetValue(e.FamilyId, out var list)) byFamily[e.FamilyId] = list = new List(); + list.Add(e); + } + // Several ids share a name (e.g. mastery lines); the lowest id is the canonical one. + byName.TryAdd(e.Name, e); + if (e.Effect.Length > 0) effects.Add(e.Effect); + } + + lock (Gate) + { + _byId = byId; + _byFamily = byFamily; + _byName = byName; + _effects = new List(effects).ToArray(); + _all = all; + } + } + + public static SpellCatalogEntry? Get(int spellId) => + _byId.TryGetValue(spellId, out var e) ? e : null; + + public static SpellCatalogEntry? GetByName(string name) => + !string.IsNullOrEmpty(name) && _byName.TryGetValue(name, out var e) ? e : null; + + /// Every spell in a family (empty when the family is unknown). + public static IReadOnlyList Family(int familyId) => + _byFamily.TryGetValue(familyId, out var list) ? list : (IReadOnlyList)Array.Empty(); + + /// + /// True for an Item Enchantment buff: it lands on armor or a weapon, not on the player, + /// so its timer can only come from the cast's chat line. Unknown names are false. + /// + public static bool IsItemSchoolBuff(string name) + { + var e = GetByName(name); + return e != null && e.IsBuff && e.School.Equals("Item Enchantment", StringComparison.OrdinalIgnoreCase); + } + + /// Casting skill for a school name; CreatureEnchantment when unrecognised. + public static AcSkillType SkillForSchool(string school) => school switch + { + "Life Magic" => AcSkillType.LifeMagic, + "Item Enchantment" => AcSkillType.ItemEnchantment, + "War Magic" => AcSkillType.WarMagic, + "Void Magic" => AcSkillType.VoidMagic, + _ => AcSkillType.CreatureEnchantment, + }; + + /// Short school label for narrow table columns. + public static string ShortSchool(string school) => school switch + { + "Creature Enchantment" => "Creature", + "Life Magic" => "Life", + "Item Enchantment" => "Item", + "War Magic" => "War", + "Void Magic" => "Void", + _ => school, + }; + + private static readonly string[] TierSuffixes = { " VIII", " VII", " VI", " IV", " V", " III", " II", " I" }; + + /// + /// A spell name without its tier: "Strength Self VI" → "Strength Self", + /// "Incantation of Blade Bane" → "Blade Bane", "Aura of Blood Drinker Self III" → + /// "Blood Drinker Self", "Impenetrability Incantation" → "Impenetrability". + /// Names without a tier (lore spells) come back unchanged. + /// + public static string StripTier(string name) + { + string n = (name ?? "").Trim(); + if (n.StartsWith("Incantation of ", StringComparison.OrdinalIgnoreCase)) n = n.Substring("Incantation of ".Length); + if (n.StartsWith("Aura of ", StringComparison.OrdinalIgnoreCase)) n = n.Substring("Aura of ".Length); + if (n.EndsWith(" Incantation", StringComparison.OrdinalIgnoreCase)) n = n.Substring(0, n.Length - " Incantation".Length); + foreach (string s in TierSuffixes) + { + if (n.EndsWith(s, StringComparison.Ordinal)) + { + n = n.Substring(0, n.Length - s.Length); + break; + } + } + return n.Trim(); + } + + /// + /// The buffing key for a spell: the base name buffing resolves to the best tier the character + /// knows ("Strength Self"). A Self or Item spell is its own ladder; for an Other spell + /// (including lore and server-custom names like "Might of the Lugians") the family's lowest + /// Self ladder is used, then its Item ladder, so buffing casts the self-castable form. + /// + public static string BuffKeyFor(SpellCatalogEntry e) + { + if (e.IsSelf || e.IsItemTarget) return StripTier(e.Name); + + SpellCatalogEntry? self = null, item = null; + foreach (var m in Family(e.FamilyId)) + { + if (!m.IsBuff) continue; + if (m.IsSelf && (self == null || m.Level < self.Level || (m.Level == self.Level && m.Id < self.Id))) self = m; + else if (m.IsItemTarget && (item == null || m.Level < item.Level || (m.Level == item.Level && m.Id < item.Id))) item = m; + } + return StripTier((self ?? item ?? e).Name); + } + + private static int ParseInt(string s) => + int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out int v) ? v : 0; +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellCatalog.tsv b/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellCatalog.tsv new file mode 100644 index 0000000..aac5dd1 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellCatalog.tsv @@ -0,0 +1,6268 @@ +# RynthAi spell catalog generated from ACECustom Reports\SpellCatalog-Full.csv by Tools\Generate-SpellCatalog.ps1. Do not edit by hand. +# Id Name Level Effect Target FamilyId FamilyName Power DurationSec School Mana Description +1 Strength Other I 1 Buff Other 1 StrengthRaising 1 1800 Creature Enchantment 10 Increases the target's Strength by 10 points. +2 Strength Self I 1 Buff Self 1 StrengthRaising 1 1800 Creature Enchantment 15 Increases the caster's Strength by 10 points. +3 Weakness Other I 1 Debuff Other 2 StrengthLowering 1 60 Creature Enchantment 10 Decreases the target's Strength by 10 points. +4 Weakness Self I 1 Debuff Self 2 StrengthLowering 15 60 Creature Enchantment 15 Decrease the caster's Strength by 10 points. +5 Heal Other I 1 Heal Other 79 HealthRaising 1 -1 Life Magic 10 Restores 10-25 points of the target's Health. +6 Heal Self I 1 Heal Self 67 HealingRaising 1 -1 Life Magic 15 Restores 10-25 points of the caster's Health. +7 Harm Other I 1 Harm Other 80 HealthLowering 1 -1 Life Magic 10 Drains 4-6 points of the target's Health. +8 Harm Self I 1 Harm Self 80 HealthLowering 15 -1 Life Magic 15 Drains 4-6 points of the caster's Health. +9 Infuse Mana Other I 1 Neutral Other 92 ManaTransferfromcaster 1 -1 Life Magic 10 Drains one-quarter of the caster's Mana and gives 75% of that to the target. +15 Vulnerability Other I 1 Debuff Other 38 MeleeDefenseLowering 1 60 Creature Enchantment 10 Decrease the target's Melee Defense skill by 10 points. +16 Vulnerability Self I 1 Debuff Self 38 MeleeDefenseLowering 1 60 Creature Enchantment 15 Decrease the target's Melee Defense skill by 10 points. +17 Invulnerability Other I 1 Buff Other 37 MeleeDefenseRaising 1 1800 Creature Enchantment 10 Increases the target's Melee Defense skill by 10 points. +18 Invulnerability Self I 1 Buff Self 37 MeleeDefenseRaising 1 1800 Creature Enchantment 15 Increases the caster's Melee Defense skill by 10 points. +19 Fire Protection Other I 1 Buff Other 109 FireProtection 1 1800 Life Magic 10 Reduces damage the target takes from fire by 9%. +20 Fire Protection Self I 1 Buff Self 109 FireProtection 1 1800 Life Magic 15 Reduces damage the caster takes from Fire by 9%. +21 Fire Vulnerability Other I 1 Debuff Other 110 FireVulnerability 25 60 Life Magic 10 Increases damage the target takes from Fire by 10%. +22 Fire Vulnerability Self I 1 Debuff Self 110 FireVulnerability 25 60 Life Magic 15 Increases damage the caster takes from Fire by 10%. +23 Armor Other I 1 Buff Other 115 ArmorRaising 1 1800 Life Magic 10 Increases the target's natural armor by 20 points. +24 Armor Self I 1 Buff Self 115 ArmorRaising 1 1800 Life Magic 15 Increases the caster's natural armor by 20 points. +25 Imperil Other I 1 Debuff Other 116 ArmorLowering 25 60 Life Magic 10 Decreases the target's natural armor by 20 points. +26 Imperil Self I 1 Debuff Self 116 ArmorLowering 25 60 Life Magic 20 Decreases the caster's natural armor by 20 points. +27 Flame Bolt I 1 Projectile Other 121 FireMissile 1 -1 War Magic 5 Shoots a bolt of flame at the target. The bolt does 16-31 points of fire damage to the first thing it hits. +28 Frost Bolt I 1 Projectile Other 119 ColdMissile 1 -1 War Magic 5 Shoots a bolt of frost at the target. The bolt does 16-31 points of cold damage to the first thing it hits. +35 Aura of Blood Drinker Self I 1 Buff Self 154 DamageRaising 1 1800 Item Enchantment 10 Increases a weapon's damage value by 2 points. +36 Blood Loather I 1 Debuff Item 155 DamageLowering 25 60 Item Enchantment 10 Decreases a weapon's damage value by 2 points. +37 Blade Bane I 1 Buff Item 174 SlashResistanceRaising 1 1800 Item Enchantment 10 Increases a shield or piece of armor's resistance to slashing damage by 10%. Target yourself to cast this spell on all of your equipped armor. +38 Blade Lure I 1 Debuff Item 175 SlashResistanceLowering 25 60 Item Enchantment 10 Decreases a shield or piece of armor's resistance to slashing damage by 10%. +47 Primary Portal Tie 4 Utility Self 200 PortalTie 150 -1 Item Enchantment 50 Links the caster to a targeted portal. +48 Primary Portal Recall 3 Utility Self 201 PortalRecall 100 -1 Item Enchantment 50 Transports the caster to the destination of the portal last successfully linked to with Primary Portal Tie. +49 Aura of Swift Killer Self I 1 Buff Self 158 WeaponTimeRaising 1 1800 Item Enchantment 10 Improves a weapon's speed by 10 points. +50 Leaden Weapon I 1 Debuff Item 159 WeaponTimeLowering 25 60 Item Enchantment 10 Worsens a weapon's speed by 10 points. +51 Impenetrability I 1 Buff Item 160 ArmorValueRaising 1 1800 Item Enchantment 10 Improves a shield or piece of armor's armor value by 20 points. Target yourself to cast this spell on all of your equipped armor. +53 Rejuvenation Other I 1 Buff Other 95 StaminaAccelerating 1 1800 Life Magic 10 Increases the rate at which the target regains Stamina by 10%. +54 Rejuvenation Self I 1 Buff Self 95 StaminaAccelerating 1 1800 Life Magic 15 Increases the rate at which the caster regains Stamina by 10%. +57 Magic Bolt 1 Projectile Other 122 PiercingMissile 1 -1 War Magic 10 Shoots a bolt of force at the target. The bolt does 8-16 points of piercing damage to the first thing it hits. +58 Acid Stream I 1 Neutral Other 117 AcidMissile 1 -1 War Magic 5 Shoots a stream of acid at the target. The stream does 16-31 points of acid damage to the first thing it hits. +59 Acid Stream II 2 Neutral Other 117 AcidMissile 50 -1 War Magic 10 Shoots a stream of acid at the target. The stream does 26-52 points of acid damage to the first thing it hits. +60 Acid Stream III 3 Neutral Other 117 AcidMissile 100 -1 War Magic 15 Shoots a stream of acid at the target. The stream does 42-84 points of acid damage to the first thing it hits. +61 Acid Stream IV 4 Neutral Other 117 AcidMissile 150 -1 War Magic 20 Shoots a stream of acid at the target. The stream does 52-105 points of acid damage to the first thing it hits. +62 Acid Stream V 5 Neutral Other 117 AcidMissile 200 -1 War Magic 25 Shoots a stream of acid at the target. The stream does 68-136 points of acid damage to the first thing it hits. +63 Acid Stream VI 6 Neutral Other 117 AcidMissile 250 -1 War Magic 30 Shoots a stream of acid at the target. The stream does 84-168 points of acid damage to the first thing it hits. +64 Shock Wave I 1 Neutral Other 118 BludgeoningMissile 1 -1 War Magic 5 Shoots a shock wave at the target. The wave does 16-31 points of bludgeoning damage to the first thing it hits. +65 Shock Wave II 2 Neutral Other 118 BludgeoningMissile 50 -1 War Magic 10 Shoots a shock wave at the target. The wave does 26-52 points of bludgeoning damage to the first thing it hits. +66 Shock Wave III 3 Neutral Other 118 BludgeoningMissile 100 -1 War Magic 15 Shoots a shock wave at the target. The wave does 42-84 points of bludgeoning damage to the first thing it hits. +67 Shock Wave IV 4 Neutral Other 118 BludgeoningMissile 150 -1 War Magic 20 Shoots a shock wave at the target. The wave does 52-105 points of bludgeoning damage to the first thing it hits. +68 Shock Wave V 5 Neutral Other 118 BludgeoningMissile 200 -1 War Magic 25 Shoots a shock wave at the target. The wave does 68-136 points of bludgeoning damage to the first thing it hits. +69 Shock Wave VI 6 Neutral Other 118 BludgeoningMissile 250 -1 War Magic 30 Shoots a shock wave at the target. The wave does 84-168 points of bludgeoning damage to the first thing it hits. +70 Frost Bolt II 2 Projectile Other 119 ColdMissile 50 -1 War Magic 10 Shoots a bolt of frost at the target. The bolt does 26-52 points of cold damage to the first thing it hits. +71 Frost Bolt III 3 Projectile Other 119 ColdMissile 100 -1 War Magic 15 Shoots a bolt of cold at the target. The bolt does 42-84 points of cold damage to the first thing it hits. +72 Frost Bolt IV 4 Projectile Other 119 ColdMissile 150 -1 War Magic 20 Shoots a bolt of cold at the target. The bolt does 52-105 points of cold damage to the first thing it hits. +73 Frost Bolt V 5 Projectile Other 119 ColdMissile 200 -1 War Magic 25 Shoots a bolt of cold at the target. The bolt does 68-136 points of cold damage to the first thing it hits. +74 Frost Bolt VI 6 Projectile Other 119 ColdMissile 250 -1 War Magic 30 Shoots a bolt of cold at the target. The bolt does 84-168 points of cold damage to the first thing it hits. +75 Lightning Bolt I 1 Projectile Other 120 ElectricMissile 1 -1 War Magic 5 Shoots a bolt of lighting at the target. The bolt does 16-31 points of electrical damage to the first thing it hits. +76 Lightning Bolt II 2 Projectile Other 120 ElectricMissile 50 -1 War Magic 10 Shoots a bolt of lighting at the target. The bolt does 26-52 points of electrical damage to the first thing it hits. +77 Lightning Bolt III 3 Projectile Other 120 ElectricMissile 100 -1 War Magic 15 Shoots a bolt of lighting at the target. The bolt does 42-84 points of electrical damage to the first thing it hits. +78 Lightning Bolt IV 4 Projectile Other 120 ElectricMissile 150 -1 War Magic 20 Shoots a bolt of lighting at the target. The bolt does 52-105 points of electrical damage to the first thing it hits. +79 Lightning Bolt V 5 Projectile Other 120 ElectricMissile 200 -1 War Magic 25 Shoots a bolt of lighting at the target. The bolt does 68-136 points of electrical damage to the first thing it hits. +80 Lightning Bolt VI 6 Projectile Other 120 ElectricMissile 250 -1 War Magic 30 Shoots a bolt of lighting at the target. The bolt does 84-168 points of electrical damage to the first thing it hits. +81 Flame Bolt II 2 Projectile Other 121 FireMissile 50 -1 War Magic 10 Shoots a bolt of flame at the target. The bolt does 26-52 points of fire damage to the first thing it hits. +82 Flame Bolt III 3 Projectile Other 121 FireMissile 100 -1 War Magic 15 Shoots a bolt of flame at the target. The bolt does 42-84 points of fire damage to the first thing it hits. +83 Flame Bolt IV 4 Projectile Other 121 FireMissile 150 -1 War Magic 20 Shoots a bolt of flame at the target. The bolt does 52-105 points of fire damage to the first thing it hits. +84 Flame Bolt V 5 Projectile Other 121 FireMissile 200 -1 War Magic 25 Shoots a bolt of flame at the target. The bolt does 68-136 points of fire damage to the first thing it hits. +85 Flame Bolt VI 6 Projectile Other 121 FireMissile 250 -1 War Magic 30 Shoots a bolt of flame at the target. The bolt does 84-168 points of fire damage to the first thing it hits. +86 Force Bolt I 1 Projectile Other 122 PiercingMissile 1 -1 War Magic 5 Shoots a bolt of force at the target. The bolt does 16-31 points of piercing damage to the first thing it hits. +87 Force Bolt II 2 Projectile Other 122 PiercingMissile 50 -1 War Magic 10 Shoots a bolt of force at the target. The bolt does 26-52 points of piercing damage to the first thing it hits. +88 Force Bolt III 3 Projectile Other 122 PiercingMissile 100 -1 War Magic 15 Shoots a bolt of force at the target. The bolt does 42-84 points of piercing damage to the first thing it hits. +89 Force Bolt IV 4 Projectile Other 122 PiercingMissile 150 -1 War Magic 20 Shoots a bolt of force at the target. The bolt does 52-105 points of piercing damage to the first thing it hits. +90 Force Bolt V 5 Projectile Other 122 PiercingMissile 200 -1 War Magic 25 Shoots a bolt of force at the target. The bolt does 68-136 points of piercing damage to the first thing it hits. +91 Force Bolt VI 6 Projectile Other 122 PiercingMissile 250 -1 War Magic 30 Shoots a bolt of force at the target. The bolt does 84-168 points of piercing damage to the first thing it hits. +92 Whirling Blade I 1 Neutral Other 123 SlashingMissile 1 -1 War Magic 5 Shoots a magical blade at the target. The bolt does 16-31 points of slashing damage to the first thing it hits. +93 Whirling Blade II 2 Neutral Other 123 SlashingMissile 50 -1 War Magic 10 Shoots a magical blade at the target. The bolt does 26-52 points of slashing damage to the first thing it hits. +94 Whirling Blade III 3 Neutral Other 123 SlashingMissile 100 -1 War Magic 15 Shoots a magical blade at the target. The bolt does 42-84 points of slashing damage to the first thing it hits. +95 Whirling Blade IV 4 Neutral Other 123 SlashingMissile 150 -1 War Magic 20 Shoots a magical blade at the target. The bolt does 52-105 points of slashing damage to the first thing it hits. +96 Whirling Blade V 5 Neutral Other 123 SlashingMissile 200 -1 War Magic 25 Shoots a magical blade at the target. The bolt does 68-136 points of slashing damage to the first thing it hits. +97 Whirling Blade VI 6 Neutral Other 123 SlashingMissile 250 -1 War Magic 30 Shoots a magical blade at the target. The bolt does 84-168 points of slashing damage to the first thing it hits. +99 Acid Blast III 3 Projectile Other 131 AcidBurst 125 -1 War Magic 15 Shoots three streams of acid outward from the caster. Each stream does 15-31 points of acid damage to the first thing it hits. +100 Acid Blast IV 4 Projectile Other 131 AcidBurst 175 -1 War Magic 20 Shoots three streams of acid outward from the caster. Each stream does 20-40 points of acid damage to the first thing it hits. +101 Acid Blast V 5 Projectile Other 131 AcidBurst 225 -1 War Magic 25 Shoots three streams of acid outward from the caster. Each stream does 26-52 points of acid damage to the first thing it hits. +102 Acid Blast VI 6 Projectile Other 131 AcidBurst 275 -1 War Magic 30 Shoots three streams of acid outward from the caster. Each stream does 34-69 points of acid damage to the first thing it hits. +103 Shock Blast III 3 Projectile Other 132 BludgeoningBurst 125 -1 War Magic 15 Shoots three shock waves outward from the caster. Each wave does 15-31 points of damage to the first thing it hits. +104 Shock Blast IV 4 Projectile Other 132 BludgeoningBurst 175 -1 War Magic 20 Shoots three shock waves outward from the caster. Each wave does 20-40 points of damage to the first thing it hits. +105 Shock Blast V 5 Projectile Other 132 BludgeoningBurst 225 -1 War Magic 25 Shoots three shock waves outward from the caster. Each wave does 26-52 points of damage to the first thing it hits. +106 Shock Blast VI 6 Projectile Other 132 BludgeoningBurst 275 -1 War Magic 30 Shoots three shock waves outward from the caster. Each wave does 34-69 points of damage to the first thing it hits. +107 Frost Blast III 3 Projectile Other 133 ColdBurst 125 -1 War Magic 15 Shoots three bolts of frost outward from the caster. Each bolt does 15-31 points of cold damage to the first thing it hits. +108 Frost Blast IV 4 Projectile Other 133 ColdBurst 175 -1 War Magic 20 Shoots three bolts of frost outward from the caster. Each bolt does 20-40 points of cold damage to the first thing it hits. +109 Frost Blast V 5 Projectile Other 133 ColdBurst 225 -1 War Magic 25 Shoots three bolts of frost outward from the caster. Each bolt does 26-52 points of cold damage to the first thing it hits. +110 Frost Blast VI 6 Projectile Other 133 ColdBurst 275 -1 War Magic 30 Shoots three bolts of frost outward from the caster. Each bolt does 34-69 points of cold damage to the first thing it hits. +111 Lightning Blast III 3 Projectile Other 134 ElectricBurst 125 -1 War Magic 15 Shoots three bolts of lightning outward from the caster. Each bolt does 15-31 points of electric damage to the first thing it hits. +112 Lightning Blast IV 4 Projectile Other 134 ElectricBurst 175 -1 War Magic 20 Shoots three bolts of lightning outward from the caster. Each bolt does 20-40 points of electric damage to the first thing it hits. +113 Lightning Blast V 5 Projectile Other 134 ElectricBurst 225 -1 War Magic 25 Shoots three bolts of lightning outward from the caster. Each bolt does 26-52 points of electric damage to the first thing it hits. +114 Lightning Blast VI 6 Projectile Other 134 ElectricBurst 275 -1 War Magic 30 Shoots three bolts of lightning outward from the caster. Each bolt does 34-69 points of electric damage to the first thing it hits. +115 Flame Blast III 3 Projectile Other 135 FireBurst 125 -1 War Magic 15 Shoots three bolts of flame outward from the caster. Each bolt does 15-31 points of fire damage to the first thing it hits. +116 Flame Blast IV 4 Projectile Other 135 FireBurst 175 -1 War Magic 20 Shoots three bolts of flame outward from the caster. Each bolt does 20-40 points of fire damage to the first thing it hits. +117 Flame Blast V 5 Projectile Other 135 FireBurst 225 -1 War Magic 25 Shoots three bolts of flame outward from the caster. Each bolt does 26-52 points of fire damage to the first thing it hits. +118 Flame Blast VI 6 Projectile Other 135 FireBurst 275 -1 War Magic 30 Shoots three bolts of flame outward from the caster. Each bolt does 34-69 points of fire damage to the first thing it hits. +119 Force Blast III 3 Projectile Other 136 PiercingBurst 125 -1 War Magic 15 Shoots three force bolts outward from the caster. Each bolt does 15-31 points of piercing damage to the first thing it hits. +120 Force Blast IV 4 Projectile Other 136 PiercingBurst 175 -1 War Magic 20 Shoots three force bolts outward from the caster. Each bolt does 20-40 points of piercing damage to the first thing it hits. +121 Force Blast V 5 Projectile Other 136 PiercingBurst 225 -1 War Magic 25 Shoots three force bolts outward from the caster. Each bolt does 26-52 points of piercing damage to the first thing it hits. +122 Force Blast VI 6 Projectile Other 136 PiercingBurst 275 -1 War Magic 30 Shoots three force bolts outward from the caster. Each bolt does 34-69 points of piercing damage to the first thing it hits. +123 Blade Blast III 3 Projectile Other 137 SlashingBurst 125 -1 War Magic 15 Shoots three whirling blades outward from the caster. Each blade does 10-20 points of slashing damage to the first thing it hits. +124 Blade Blast IV 4 Projectile Other 137 SlashingBurst 175 -1 War Magic 20 Shoots three whirling blades outward from the caster. Each blade does 20-40 points of slashing damage to the first thing it hits. +125 Blade Blast V 5 Projectile Other 137 SlashingBurst 225 -1 War Magic 25 Shoots three whirling blades outward from the caster. Each blade does 26-52 points of slashing damage to the first thing it hits. +126 Blade Blast VI 6 Projectile Other 137 SlashingBurst 275 -1 War Magic 30 Shoots three whirling blades outward from the caster. Each blade does 34-69 points of slashing damage to the first thing it hits. +127 Acid Volley III 3 Projectile Other 207 AcidVolley 125 -1 War Magic 15 Shoots three streams of acid toward the target. Each stream does 15-31 points of acid damage to the first thing it hits. +128 Acid Volley IV 4 Projectile Other 207 AcidVolley 175 -1 War Magic 20 Shoots three streams of acid toward the target. Each stream does 20-40 points of acid damage to the first thing it hits. +129 Acid Volley V 5 Projectile Other 207 AcidVolley 225 -1 War Magic 25 Shoots three streams of acid toward the target. Each stream does 26-52 points of acid damage to the first thing it hits. +130 Acid Volley VI 6 Projectile Other 207 AcidVolley 275 -1 War Magic 30 Shoots three streams of acid toward the target. Each stream does 34-69 points of acid damage to the first thing it hits. +131 Bludgeoning Volley III 3 Projectile Other 208 BludgeoningVolley 125 -1 War Magic 15 Shoots three shock waves toward the target. Each wave does 15-31 points of bludgeoning damage to the first thing it hits. +132 Bludgeoning Volley IV 4 Projectile Other 208 BludgeoningVolley 175 -1 War Magic 20 Shoots three shock waves toward the target. Each wave does 20-40 points of bludgeoning damage to the first thing it hits. +133 Bludgeoning Volley V 5 Projectile Other 208 BludgeoningVolley 225 -1 War Magic 25 Shoots three shock waves toward the target. Each wave does 26-52 points of bludgeoning damage to the first thing it hits. +134 Bludgeoning Volley VI 6 Projectile Other 208 BludgeoningVolley 275 -1 War Magic 30 Shoots three shock waves toward the target. Each wave does 34-69 points of bludgeoning damage to the first thing it hits. +135 Frost Volley III 3 Projectile Other 209 FrostVolley 125 -1 War Magic 15 Shoots three bolts of frost toward the target. Each bolt does 15-31 points of cold damage to the first thing it hits. +136 Frost Volley IV 4 Projectile Other 209 FrostVolley 175 -1 War Magic 20 Shoots three bolts of frost toward the target. Each bolt does 20-40 points of cold damage to the first thing it hits. +137 Frost Volley V 5 Projectile Other 209 FrostVolley 225 -1 War Magic 25 Shoots three bolts of frost toward the target. Each bolt does 26-52 points of cold damage to the first thing it hits. +138 Frost Volley VI 6 Projectile Other 209 FrostVolley 275 -1 War Magic 30 Shoots three bolts of frost toward the target. Each bolt does 34-69 points of cold damage to the first thing it hits. +139 Lightning Volley III 3 Projectile Other 210 LightningVolley 125 -1 War Magic 15 Shoots three bolts of lightning toward the target. Each bolt does 15-31 points of electric damage to the first thing it hits. +140 Lightning Volley IV 4 Projectile Other 210 LightningVolley 175 -1 War Magic 20 Shoots three bolts of lightning toward the target. Each bolt does 20-40 points of electric damage to the first thing it hits. +141 Lightning Volley V 5 Projectile Other 210 LightningVolley 225 -1 War Magic 25 Shoots three bolts of lightning toward the target. Each bolt does 26-52 points of electric damage to the first thing it hits. +142 Lightning Volley VI 6 Projectile Other 210 LightningVolley 275 -1 War Magic 30 Shoots three bolts of lightning toward the target. Each bolt does 34-69 points of electric damage to the first thing it hits. +143 Flame Volley III 3 Projectile Other 211 FlameVolley 125 -1 War Magic 15 Shoots three bolts of flame toward the target. Each bolt does 15-31 points of fire damage to the first thing it hits. +144 Flame Volley IV 4 Projectile Other 211 FlameVolley 175 -1 War Magic 20 Shoots three bolts of flame toward the target. Each bolt does 20-40 points of fire damage to the first thing it hits. +145 Flame Volley V 5 Projectile Other 211 FlameVolley 225 -1 War Magic 25 Shoots three bolts of flame toward the target. Each bolt does 26-52 points of fire damage to the first thing it hits. +146 Flame Volley VI 6 Projectile Other 211 FlameVolley 275 -1 War Magic 30 Shoots three bolts of flame toward the target. Each bolt does 34-69 points of fire damage to the first thing it hits. +147 Force Volley III 3 Projectile Other 212 ForceVolley 125 -1 War Magic 15 Shoots three bolts of force toward the target. Each bolt does 15-31 points of piercing damage to the first thing it hits. +148 Force Volley IV 4 Projectile Other 212 ForceVolley 175 -1 War Magic 20 Shoots three bolts of force toward the target. Each bolt does 20-40 points of piercing damage to the first thing it hits. +149 Force Volley V 5 Projectile Other 212 ForceVolley 225 -1 War Magic 25 Shoots three bolts of force toward the target. Each bolt does 26-52 points of piercing damage to the first thing it hits. +150 Force Volley VI 6 Projectile Other 212 ForceVolley 275 -1 War Magic 30 Shoots three bolts of force toward the target. Each bolt does 34-69 points of piercing damage to the first thing it hits. +151 Blade Volley III 3 Projectile Other 213 BladeVolley 125 -1 War Magic 15 Shoots three whirling blades toward the target. Each blade does 15-31 points of Slashing damage to the first thing it hits. +152 Blade Volley IV 4 Projectile Other 213 BladeVolley 175 -1 War Magic 20 Shoots three whirling blades toward the target. Each blade does 20-40 points of Slashing damage to the first thing it hits. +153 Blade Volley V 5 Projectile Other 213 BladeVolley 225 -1 War Magic 25 Shoots three whirling blades toward the target. Each blade does 26-52 points of Slashing damage to the first thing it hits. +154 Blade Volley VI 6 Projectile Other 213 BladeVolley 275 -1 War Magic 30 Shoots three whirling blades toward the target. Each blade does 34-69 points of Slashing damage to the first thing it hits. +157 Summon Primary Portal I 5 Utility Self 203 PortalItemCreation 200 60 Item Enchantment 70 Summons a portal that goes to the destination of the caster's linked portal. set with Primary Portal Tie. +158 Summon Primary Portal II 5 Utility Self 203 PortalItemCreation 225 180 Item Enchantment 90 Summons a portal that goes to the destination of the caster's linked portal. set with Primary Portal Tie. +159 Regeneration Other I 1 Buff Other 93 HealthAccelerating 1 1800 Life Magic 10 Increase target's natural healing rate by 10%. +160 Regeneration Other II 2 Buff Other 93 HealthAccelerating 50 1800 Life Magic 20 Increase target's natural healing rate by 25%. +161 Regeneration Other III 3 Buff Other 93 HealthAccelerating 100 1800 Life Magic 30 Increase target's natural healing rate by 40%. +162 Regeneration Other IV 4 Buff Other 93 HealthAccelerating 150 1800 Life Magic 40 Increase target's natural healing rate by 55%. +163 Regeneration Other V 5 Buff Other 93 HealthAccelerating 200 1800 Life Magic 50 Increase target's natural healing rate by 70%. +164 Regeneration Other VI 6 Buff Other 93 HealthAccelerating 250 2700 Life Magic 60 Increase target's natural healing rate by 85%. +165 Regeneration Self I 1 Buff Self 93 HealthAccelerating 1 1800 Life Magic 20 Increase caster's natural healing rate by 10%. +166 Regeneration Self II 2 Buff Self 93 HealthAccelerating 50 1800 Life Magic 30 Increase caster's natural healing rate by 25%. +167 Regeneration Self III 3 Buff Self 93 HealthAccelerating 100 1800 Life Magic 40 Increase caster's natural healing rate by 40%. +168 Regeneration Self IV 4 Buff Self 93 HealthAccelerating 150 1800 Life Magic 50 Increase caster's natural healing rate by 55%. +169 Regeneration Self V 5 Buff Self 93 HealthAccelerating 200 1800 Life Magic 60 Increase caster's natural healing rate by 70%. +170 Regeneration Self VI 6 Buff Self 93 HealthAccelerating 250 2700 Life Magic 70 Increase caster's natural healing rate by 85%. +171 Fester Other I 1 Debuff Other 94 HealthDecelerating 25 60 Life Magic 10 Decrease target's natural healing rate by 9%. +172 Fester Other II 2 Debuff Other 94 HealthDecelerating 75 90 Life Magic 20 Decrease target's natural healing rate by 20%. +173 Fester Other III 3 Debuff Other 94 HealthDecelerating 125 120 Life Magic 30 Decrease target's natural healing rate by 29%. +174 Fester Other IV 4 Debuff Other 94 HealthDecelerating 175 150 Life Magic 40 Decrease target's natural healing rate by 35%. +175 Fester Other V 5 Debuff Other 94 HealthDecelerating 225 180 Life Magic 50 Decrease target's natural healing rate by 41%. +176 Fester Other VI 6 Debuff Other 94 HealthDecelerating 275 210 Life Magic 60 Decrease target's natural healing rate by 46%. +178 Fester Self I 1 Debuff Self 94 HealthDecelerating 25 60 Life Magic 20 Decrease caster's natural healing rate by 9%. +179 Fester Self II 2 Debuff Self 94 HealthDecelerating 75 90 Life Magic 30 Decrease caster's natural healing rate by 20%. +180 Fester Self III 3 Debuff Self 94 HealthDecelerating 125 120 Life Magic 40 Decrease caster's natural healing rate by 29%. +181 Fester Self IV 4 Debuff Self 94 HealthDecelerating 175 150 Life Magic 50 Decrease caster's natural healing rate by 35%. +182 Fester Self V 5 Debuff Self 94 HealthDecelerating 225 180 Life Magic 60 Decrease caster's natural healing rate by 41%. +183 Fester Self VI 6 Debuff Self 94 HealthDecelerating 275 210 Life Magic 70 Decrease caster's natural healing rate by 46%. +184 Rejuvenation Other II 2 Buff Other 95 StaminaAccelerating 50 1800 Life Magic 20 Increases the rate at which the target regains Stamina by 25%. +185 Rejuvenation Other III 3 Buff Other 95 StaminaAccelerating 100 1800 Life Magic 30 Increases the rate at which the target regains Stamina by 40%. +186 Rejuvenation Other IV 4 Buff Other 95 StaminaAccelerating 150 1800 Life Magic 40 Increases the rate at which the target regains Stamina by 55%. +187 Rejuvenation Other V 5 Buff Other 95 StaminaAccelerating 200 1800 Life Magic 50 Increases the rate at which the target regains Stamina by 70%. +188 Rejuvenation Other VI 6 Buff Other 95 StaminaAccelerating 250 2700 Life Magic 60 Increases the rate at which the target regains Stamina by 85%. +189 Rejuvenation Self II 2 Buff Self 95 StaminaAccelerating 50 1800 Life Magic 30 Increases the rate at which the caster regains Stamina by 25%. +190 Rejuvenation Self III 3 Buff Self 95 StaminaAccelerating 100 1800 Life Magic 40 Increases the rate at which the caster regains Stamina by 40%. +191 Rejuvenation Self IV 4 Buff Self 95 StaminaAccelerating 150 1800 Life Magic 50 Increases the rate at which the caster regains Stamina by 55%. +192 Rejuvenation Self V 5 Buff Self 95 StaminaAccelerating 200 1800 Life Magic 60 Increases the rate at which the caster regains Stamina by 70%. +193 Rejuvenation Self VI 6 Buff Self 95 StaminaAccelerating 250 2700 Life Magic 70 Increases the rate at which the caster regains Stamina by 85%. +194 Exhaustion Other I 1 Debuff Other 96 StaminaDecelerating 25 60 Life Magic 10 Decreases the rate at which the target regains Stamina by 9%. +195 Exhaustion Other II 2 Debuff Other 96 StaminaDecelerating 75 90 Life Magic 20 Decreases the rate at which the target regains Stamina by 20%. +196 Exhaustion Other III 3 Debuff Other 96 StaminaDecelerating 125 120 Life Magic 30 Decreases the rate at which the target regains Stamina by 29%. +197 Exhaustion Other IV 4 Debuff Other 96 StaminaDecelerating 175 150 Life Magic 40 Decreases the rate at which the target regains Stamina by 35%. +198 Exhaustion Other V 5 Debuff Other 96 StaminaDecelerating 225 180 Life Magic 50 Decreases the rate at which the target regains Stamina by 41%. +199 Exhaustion Other VI 6 Debuff Other 96 StaminaDecelerating 275 210 Life Magic 60 Decreases the rate at which the target regains Stamina by 46%. +200 Exhaustion Self I 1 Debuff Self 96 StaminaDecelerating 25 60 Life Magic 20 Decreases the rate at which the caster regains Stamina by 9%. +201 Exhaustion Self II 2 Debuff Self 96 StaminaDecelerating 75 90 Life Magic 30 Decreases the rate at which the caster regains Stamina by 20%. +202 Exhaustion Self III 3 Debuff Self 96 StaminaDecelerating 125 120 Life Magic 40 Decreases the rate at which the caster regains Stamina by 29%. +203 Exhaustion Self IV 4 Debuff Self 96 StaminaDecelerating 175 150 Life Magic 50 Decreases the rate at which the caster regains Stamina by 35%. +204 Exhaustion Self V 5 Debuff Self 96 StaminaDecelerating 225 180 Life Magic 60 Decreases the rate at which the caster regains Stamina by 41%. +205 Exhaustion Self VI 6 Debuff Self 96 StaminaDecelerating 275 210 Life Magic 70 Decreases the rate at which the caster regains Stamina by 46%. +206 Mana Renewal Other I 1 Buff Other 97 ManaAccelerating 1 1800 Life Magic 10 Increases the target's natural mana rate by 10%. +207 Mana Renewal Other II 2 Buff Other 97 ManaAccelerating 50 1800 Life Magic 20 Increases the target's natural mana rate by 25%. +208 Mana Renewal Other III 3 Buff Other 97 ManaAccelerating 100 1800 Life Magic 30 Increases the target's natural mana rate by 40%. +209 Mana Renewal Other IV 4 Buff Other 97 ManaAccelerating 150 1800 Life Magic 40 Increases the target's natural mana rate by 55%. +210 Mana Renewal Other V 5 Buff Other 97 ManaAccelerating 200 1800 Life Magic 50 Increases the target's natural mana rate by 70%. +211 Mana Renewal Other VI 6 Buff Other 97 ManaAccelerating 250 2700 Life Magic 60 Increases the target's natural mana rate by 85%. +212 Mana Renewal Self I 1 Buff Self 97 ManaAccelerating 25 1800 Life Magic 20 Increases the caster's natural mana rate by 10%. +213 Mana Renewal Self II 2 Buff Self 97 ManaAccelerating 50 1800 Life Magic 30 Increases the caster's natural mana rate by 25%. +214 Mana Renewal Self III 3 Buff Self 97 ManaAccelerating 100 1800 Life Magic 40 Increases the caster's natural mana rate by 40%. +215 Mana Renewal Self IV 4 Buff Self 97 ManaAccelerating 150 1800 Life Magic 50 Increases the caster's natural mana rate by 55%. +216 Mana Renewal Self V 5 Buff Self 97 ManaAccelerating 200 1800 Life Magic 60 Increases the caster's natural mana rate by 70%. +217 Mana Renewal Self VI 6 Buff Self 97 ManaAccelerating 250 2700 Life Magic 70 Increases the caster's natural mana rate by 85%. +218 Mana Depletion Other I 1 Debuff Other 98 ManaDecelerating 25 60 Life Magic 10 Decreases target's natural mana rate by 9%. +219 Mana Depletion Other II 2 Debuff Other 98 ManaDecelerating 75 90 Life Magic 20 Decreases target's natural mana rate by 20%. +220 Mana Depletion Other III 3 Debuff Other 98 ManaDecelerating 125 120 Life Magic 30 Decreases target's natural mana rate by 29%. +221 Mana Depletion Other IV 4 Debuff Other 98 ManaDecelerating 175 150 Life Magic 40 Decreases target's natural mana rate by 35%. +222 Mana Depletion Other V 5 Debuff Other 98 ManaDecelerating 225 180 Life Magic 50 Decreases target's natural mana rate by 41%. +223 Mana Depletion Other VI 6 Debuff Other 98 ManaDecelerating 275 210 Life Magic 60 Decreases target's natural mana rate by 46%. +224 Mana Depletion Self I 1 Debuff Self 98 ManaDecelerating 25 60 Life Magic 20 Decreases caster's natural mana rate by 9%. +225 Mana Depletion Self II 2 Debuff Self 98 ManaDecelerating 75 90 Life Magic 30 Decreases caster's natural mana rate by 20%. +226 Mana Depletion Self III 3 Debuff Self 98 ManaDecelerating 125 120 Life Magic 40 Decreases caster's natural mana rate by 29%. +227 Mana Depletion Self IV 4 Debuff Self 98 ManaDecelerating 175 150 Life Magic 50 Decreases caster's natural mana rate by 35%. +228 Mana Depletion Self V 5 Debuff Self 98 ManaDecelerating 225 180 Life Magic 60 Decreases caster's natural mana rate by 41%. +229 Mana Depletion Self VI 6 Debuff Self 98 ManaDecelerating 275 210 Life Magic 70 Decreases caster's natural mana rate by 46%. +230 Vulnerability Other II 2 Debuff Other 38 MeleeDefenseLowering 75 90 Creature Enchantment 20 Decrease the target's Melee Defense skill by 15 points. +231 Vulnerability Other III 3 Debuff Other 38 MeleeDefenseLowering 125 120 Creature Enchantment 30 Decrease the target's Melee Defense skill by 20 points. +232 Vulnerability Other IV 4 Debuff Other 38 MeleeDefenseLowering 175 150 Creature Enchantment 40 Decrease the target's Melee Defense skill by 25 points. +233 Vulnerability Other V 5 Debuff Other 38 MeleeDefenseLowering 225 180 Creature Enchantment 50 Decrease the target's Melee Defense skill by 30 points. +234 Vulnerability Other VI 6 Debuff Other 38 MeleeDefenseLowering 275 210 Creature Enchantment 60 Decrease the target's Melee Defense skill by 35 points. +235 Vulnerability Self II 2 Debuff Self 38 MeleeDefenseLowering 75 90 Creature Enchantment 30 Decrease the target's Melee Defense skill by 15 points. +236 Vulnerability Self III 3 Debuff Self 38 MeleeDefenseLowering 125 120 Creature Enchantment 40 Decrease the target's Melee Defense skill by 20 points. +237 Vulnerability Self IV 4 Debuff Self 38 MeleeDefenseLowering 175 150 Creature Enchantment 50 Decrease the target's Melee Defense skill by 25 points. +238 Vulnerability Self V 5 Debuff Self 38 MeleeDefenseLowering 225 180 Creature Enchantment 60 Decrease the target's Melee Defense skill by 30 points. +239 Vulnerability Self VI 6 Debuff Self 38 MeleeDefenseLowering 275 210 Creature Enchantment 70 Decrease the target's Melee Defense skill by 35 points. +240 Invulnerability Other II 2 Buff Other 37 MeleeDefenseRaising 50 1800 Creature Enchantment 20 Increases the target's Melee Defense skill by 15 points. +241 Invulnerability Other III 3 Buff Other 37 MeleeDefenseRaising 100 1800 Creature Enchantment 30 Increases the target's Melee Defense skill by 20 points. +242 Invulnerability Other IV 4 Buff Other 37 MeleeDefenseRaising 150 1800 Creature Enchantment 40 Increases the target's Melee Defense skill by 25 points. +243 Invulnerability Other V 5 Buff Other 37 MeleeDefenseRaising 200 1800 Creature Enchantment 50 Increases the target's Melee Defense skill by 30 points. +244 Invulnerability Other VI 6 Buff Other 37 MeleeDefenseRaising 250 2700 Creature Enchantment 60 Increases the target's Melee Defense skill by 35 points. +245 Invulnerability Self II 2 Buff Self 37 MeleeDefenseRaising 50 1800 Creature Enchantment 30 Increases the caster's Melee Defense skill by 15 points. +246 Invulnerability Self III 3 Buff Self 37 MeleeDefenseRaising 100 1800 Creature Enchantment 40 Increases the caster's Melee Defense skill by 20 points. +247 Invulnerability Self IV 4 Buff Self 37 MeleeDefenseRaising 150 1800 Creature Enchantment 50 Increases the caster's Melee Defense skill by 25 points. +248 Invulnerability Self V 5 Buff Self 37 MeleeDefenseRaising 200 1800 Creature Enchantment 60 Increases the caster's Melee Defense skill by 30 points. +249 Invulnerability Self VI 6 Buff Self 37 MeleeDefenseRaising 250 2700 Creature Enchantment 70 Increases the caster's Melee Defense skill by 35 points. +250 Impregnability Other I 1 Buff Other 39 MissileDefenseRaising 1 1800 Creature Enchantment 10 Increases the target's Missile Defense skill by 10 points. +251 Impregnability Other II 2 Buff Other 39 MissileDefenseRaising 50 1800 Creature Enchantment 20 Increases the target's Missile Defense skill by 15 points. +252 Impregnability Other III 3 Buff Other 39 MissileDefenseRaising 100 1800 Creature Enchantment 30 Increases the target's Missile Defense skill by 20 points. +253 Impregnability Other IV 4 Buff Other 39 MissileDefenseRaising 150 1800 Creature Enchantment 40 Increases the target's Missile Defense skill by 25 points. +254 Impregnability Other V 5 Buff Other 39 MissileDefenseRaising 200 1800 Creature Enchantment 50 Increases the target's Missile Defense skill by 30 points. +255 Impregnability Other VI 6 Buff Other 39 MissileDefenseRaising 250 2700 Creature Enchantment 60 Increases the target's Missile Defense skill by 35 points. +256 Impregnability Self I 1 Buff Self 39 MissileDefenseRaising 1 1800 Creature Enchantment 15 Increases the caster's Missile Defense skill by 10 points. +257 Impregnability Self II 2 Buff Self 39 MissileDefenseRaising 50 1800 Creature Enchantment 30 Increases the caster's Missile Defense skill by 15 points. +258 Impregnability Self III 3 Buff Self 39 MissileDefenseRaising 100 1800 Creature Enchantment 40 Increases the caster's Missile Defense skill by 20 points. +259 Impregnability Self IV 4 Buff Self 39 MissileDefenseRaising 150 1800 Creature Enchantment 50 Increases the caster's Missile Defense skill by 25 points. +260 Impregnability Self V 5 Buff Self 39 MissileDefenseRaising 200 1800 Creature Enchantment 60 Increases the caster's Missile Defense skill by 30 points. +261 Impregnability Self VI 6 Buff Self 39 MissileDefenseRaising 250 2700 Creature Enchantment 70 Increases the caster's Missile Defense skill by 35 points. +262 Defenselessness Other I 1 Debuff Other 40 MissileDefenseLowering 1 60 Creature Enchantment 10 Decreases the target's Missile Defense skill by 10 points. +263 Defenselessness Other II 2 Debuff Other 40 MissileDefenseLowering 75 90 Creature Enchantment 20 Decreases the target's Missile Defense skill by 15 points. +264 Defenselessness Other III 3 Debuff Other 40 MissileDefenseLowering 125 120 Creature Enchantment 30 Decreases the target's Missile Defense skill by 20 points. +265 Defenselessness Other IV 4 Debuff Other 40 MissileDefenseLowering 175 150 Creature Enchantment 40 Decreases the target's Missile Defense skill by 25 points. +266 Defenselessness Other V 5 Debuff Other 40 MissileDefenseLowering 225 180 Creature Enchantment 50 Decreases the target's Missile Defense skill by 30 points. +267 Defenselessness Other VI 6 Debuff Other 40 MissileDefenseLowering 275 210 Creature Enchantment 60 Decreases the target's Missile Defense skill by 35 points. +268 Magic Resistance Other I 1 Buff Other 41 MagicDefenseRaising 1 1800 Creature Enchantment 10 Increases the target's Magic Defense skill by 10 points. +269 Magic Resistance Other II 2 Buff Other 41 MagicDefenseRaising 50 1800 Creature Enchantment 20 Increases the target's Magic Defense skill by 15 points. +270 Magic Resistance Other III 3 Buff Other 41 MagicDefenseRaising 100 1800 Creature Enchantment 30 Increases the target's Magic Defense skill by 20 points. +271 Magic Resistance Other IV 4 Buff Other 41 MagicDefenseRaising 150 1800 Creature Enchantment 40 Increases the target's Magic Defense skill by 25 points. +272 Magic Resistance Other V 5 Buff Other 41 MagicDefenseRaising 200 1800 Creature Enchantment 50 Increases the target's Magic Defense skill by 30 points. +273 Magic Resistance Other VI 6 Buff Other 41 MagicDefenseRaising 250 2700 Creature Enchantment 60 Increases the target's Magic Defense skill by 35 points. +274 Magic Resistance Self I 1 Buff Self 41 MagicDefenseRaising 1 1800 Creature Enchantment 15 Increases the caster's Magic Defense skill by 10 points. +275 Magic Resistance Self II 2 Buff Self 41 MagicDefenseRaising 50 1800 Creature Enchantment 30 Increases the caster's Magic Defense skill by 15 points. +276 Magic Resistance Self III 3 Buff Self 41 MagicDefenseRaising 100 1800 Creature Enchantment 40 Increases the caster's Magic Defense skill by 20 points. +277 Magic Resistance Self IV 4 Buff Self 41 MagicDefenseRaising 150 1800 Creature Enchantment 50 Increases the caster's Magic Defense skill by 25 points. +278 Magic Resistance Self V 5 Buff Self 41 MagicDefenseRaising 200 1800 Creature Enchantment 60 Increases the caster's Magic Defense skill by 30 points. +279 Magic Resistance Self VI 6 Buff Self 41 MagicDefenseRaising 250 2700 Creature Enchantment 70 Increases the caster's Magic Defense skill by 35 points. +280 Magic Yield Other I 1 Debuff Other 42 MagicDefenseLowering 1 60 Creature Enchantment 10 Decreases the target's Magic Defense skill by 10 points. +281 Magic Yield Other II 2 Debuff Other 42 MagicDefenseLowering 75 90 Creature Enchantment 20 Decreases the target's Magic Defense skill by 15 points. +282 Magic Yield Other III 3 Debuff Other 42 MagicDefenseLowering 125 120 Creature Enchantment 30 Decreases the target's Magic Defense skill by 20 points. +283 Magic Yield Other IV 4 Debuff Other 42 MagicDefenseLowering 175 150 Creature Enchantment 40 Decreases the target's Magic Defense skill by 25 points. +284 Magic Yield Other V 5 Debuff Other 42 MagicDefenseLowering 225 180 Creature Enchantment 50 Decreases the target's Magic Defense skill by 30 points. +285 Magic Yield Other VI 6 Debuff Other 42 MagicDefenseLowering 275 210 Creature Enchantment 60 Decreases the target's Magic Defense skill by 35 points. +286 Magic Yield Self I 1 Debuff Self 42 MagicDefenseLowering 1 60 Creature Enchantment 15 Decreases the caster's Magic Defense skill by 10 points. +287 Magic Yield Self II 2 Debuff Self 42 MagicDefenseLowering 75 90 Creature Enchantment 30 Decreases the caster's Magic Defense skill by 15 points. +288 Magic Yield Self III 3 Debuff Self 42 MagicDefenseLowering 125 120 Creature Enchantment 40 Decreases the caster's Magic Defense skill by 20 points. +289 Magic Yield Self IV 4 Debuff Self 42 MagicDefenseLowering 175 150 Creature Enchantment 50 Decreases the caster's Magic Defense skill by 25 points. +290 Magic Yield Self V 5 Debuff Self 42 MagicDefenseLowering 225 180 Creature Enchantment 60 Decreases the caster's Magic Defense skill by 30 points. +291 Magic Yield Self VI 6 Debuff Self 42 MagicDefenseLowering 275 210 Creature Enchantment 70 Decreases the caster's Magic Defense skill by 35 points. +292 Light Weapon Mastery Other I 1 Buff Other 17 AxeRaising 1 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. +293 Light Weapon Mastery Other II 2 Buff Other 17 AxeRaising 50 1800 Creature Enchantment 20 Increases the target's Light Weapons skill by 15 points. +294 Light Weapon Mastery Other III 3 Buff Other 17 AxeRaising 100 1800 Creature Enchantment 30 Increases the target's Light Weapons skill by 20 points. +295 Light Weapon Mastery Other IV 4 Buff Other 17 AxeRaising 150 1800 Creature Enchantment 40 Increases the target's Light Weapons skill by 25 points. +296 Light Weapon Mastery Other V 5 Buff Other 17 AxeRaising 200 1800 Creature Enchantment 50 Increases the target's Light Weapons skill by 30 points. +297 Light Weapon Mastery Other VI 6 Buff Other 17 AxeRaising 250 2700 Creature Enchantment 60 Increases the target's Light Weapons skill by 35 points. +298 Light Weapon Mastery Self I 1 Buff Self 17 AxeRaising 1 1800 Creature Enchantment 15 Increases the caster's Light Weapons skill by 10 points. +299 Light Weapon Mastery Self II 2 Buff Self 17 AxeRaising 50 1800 Creature Enchantment 30 Increases the caster's Light Weapons skill by 15 points. +300 Light Weapon Mastery Self III 3 Buff Self 17 AxeRaising 100 1800 Creature Enchantment 40 Increases the caster's Light Weapons skill by 20 points. +301 Light Weapon Mastery Self IV 4 Buff Self 17 AxeRaising 150 1800 Creature Enchantment 50 Increases the caster's Light Weapons skill by 25 points. +302 Light Weapon Mastery Self V 5 Buff Self 17 AxeRaising 200 1800 Creature Enchantment 60 Increases the caster's Light Weapons skill by 30 points. +303 Light Weapon Mastery Self VI 6 Buff Self 17 AxeRaising 250 2700 Creature Enchantment 70 Increases the caster's Light Weapons skill by 35 points. +304 Light Weapon Ineptitude Other I 1 Debuff Other 18 AxeLowering 1 60 Creature Enchantment 10 Decreases the target's Light Weapons skill by 10 points. +305 Light Weapon Ineptitude Other II 2 Debuff Other 18 AxeLowering 75 90 Creature Enchantment 20 Decreases the target's Light Weapons skill by 15 points. +306 Light Weapon Ineptitude Other III 3 Debuff Other 18 AxeLowering 125 120 Creature Enchantment 30 Decreases the target's Light Weapons skill by 20 points. +307 Light Weapon Ineptitude Other IV 4 Debuff Other 18 AxeLowering 175 150 Creature Enchantment 40 Decreases the target's Light Weapons skill by 25 points. +308 Light Weapon Ineptitude Other V 5 Debuff Other 18 AxeLowering 225 180 Creature Enchantment 50 Decreases the target's Light Weapons skill by 30 points. +309 Light Weapon Ineptitude Other VI 6 Debuff Other 18 AxeLowering 275 210 Creature Enchantment 60 Decreases the target's Light Weapons skill by 35 points. +310 Light Weapon Ineptitude Self I 1 Debuff Self 18 AxeLowering 1 60 Creature Enchantment 15 Decreases the caster's Light Weapons skill by 10 points. +311 Light Weapon Ineptitude Self II 2 Debuff Self 18 AxeLowering 75 90 Creature Enchantment 30 Decreases the caster's Light Weapons skill by 15 points. +312 Light Weapon Ineptitude Self III 3 Debuff Self 18 AxeLowering 125 120 Creature Enchantment 40 Decreases the caster's Light Weapons skill by 20 points. +313 Light Weapon Ineptitude Self IV 4 Debuff Self 18 AxeLowering 175 150 Creature Enchantment 50 Decreases the caster's Light Weapons skill by 25 points. +314 Light Weapon Ineptitude Self V 5 Debuff Self 18 AxeLowering 225 180 Creature Enchantment 60 Decreases the caster's Light Weapons skill by 30 points. +315 Light Weapon Ineptitude Self VI 6 Debuff Self 18 AxeLowering 275 210 Creature Enchantment 70 Decreases the caster's Light Weapons skill by 35 points. +316 Finesse Weapon Mastery Other I 1 Buff Other 23 DaggerRaising 1 1800 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 10 points. +317 Finesse Weapon Mastery Other II 2 Buff Other 23 DaggerRaising 50 1800 Creature Enchantment 20 Increases the target's Finesse Weapons skill by 15 points. +318 Finesse Weapon Mastery Other III 3 Buff Other 23 DaggerRaising 100 1800 Creature Enchantment 30 Increases the target's Finesse Weapons skill by 20 points. +319 Finesse Weapon Mastery Other IV 4 Buff Other 23 DaggerRaising 150 1800 Creature Enchantment 40 Increases the target's Finesse Weapons skill by 25 points. +320 Finesse Weapon Mastery Other V 5 Buff Other 23 DaggerRaising 200 1800 Creature Enchantment 50 Increases the target's Finesse Weapons skill by 30 points. +321 Finesse Weapon Mastery Other VI 6 Buff Other 23 DaggerRaising 250 2700 Creature Enchantment 60 Increases the target's Finesse Weapons skill by 35 points. +322 Finesse Weapon Mastery Self I 1 Buff Self 23 DaggerRaising 1 1800 Creature Enchantment 15 Increases the caster's Finesse Weapons skill by 10 points. +323 Finesse Weapon Mastery Self II 2 Buff Self 23 DaggerRaising 50 1800 Creature Enchantment 30 Increases the caster's Finesse Weapons skill by 15 points. +324 Finesse Weapon Mastery Self III 3 Buff Self 23 DaggerRaising 100 1800 Creature Enchantment 40 Increases the caster's Finesse Weapons skill by 20 points. +325 Finesse Weapon Mastery Self IV 4 Buff Self 23 DaggerRaising 150 1800 Creature Enchantment 50 Increases the caster's Finesse Weapons skill by 25 points. +326 Finesse Weapon Mastery Self V 5 Buff Self 23 DaggerRaising 200 1800 Creature Enchantment 60 Increases the caster's Finesse Weapons skill by 30 points. +327 Finesse Weapon Mastery Self VI 6 Buff Self 23 DaggerRaising 250 2700 Creature Enchantment 70 Increases the caster's Finesse Weapons skill by 35 points. +328 Finesse Weapon Ineptitude Other I 1 Debuff Other 24 DaggerLowering 1 60 Creature Enchantment 10 Decreases the target's Finesse Weapons skill by 10 points. +329 Finesse Weapon Ineptitude Other II 2 Debuff Other 24 DaggerLowering 75 90 Creature Enchantment 20 Decreases the target's Finesse Weapons skill by 15 points. +330 Finesse Weapon Ineptitude Other III 3 Debuff Other 24 DaggerLowering 125 120 Creature Enchantment 30 Decreases the target's Finesse Weapons skill by 20 points. +331 Finesse Weapon Ineptitude Other IV 4 Debuff Other 24 DaggerLowering 175 150 Creature Enchantment 40 Decreases the target's Finesse Weapons skill by 25 points. +332 Finesse Weapon Ineptitude Other V 5 Debuff Other 24 DaggerLowering 225 180 Creature Enchantment 50 Decreases the target's Finesse Weapon skill by 30 points. +333 Finesse Weapon Ineptitude Other VI 6 Debuff Other 24 DaggerLowering 275 210 Creature Enchantment 60 Decreases the target's Finesse Weapons skill by 35 points. +334 Finesse Weapon Ineptitude Self I 1 Debuff Self 24 DaggerLowering 1 60 Creature Enchantment 15 Decreases the caster's Finesse Weapons skill by 10 points. +335 Finesse Weapon Ineptitude Self II 2 Debuff Self 24 DaggerLowering 75 90 Creature Enchantment 30 Decreases the caster's Finesse Weapons skill by 15 points. +336 Finesse Weapon Ineptitude Self III 3 Debuff Self 24 DaggerLowering 125 120 Creature Enchantment 40 Decreases the caster's Finesse Weapons skill by 20 points. +337 Finesse Weapon Ineptitude Self IV 4 Debuff Self 24 DaggerLowering 175 150 Creature Enchantment 50 Decreases the caster's Finesse Weapons skill by 25 points. +338 Finesse Weapon Ineptitude Self V 5 Debuff Self 24 DaggerLowering 225 180 Creature Enchantment 60 Decreases the caster's Finesse Weapons skill by 30 points. +339 Finesse Weapon Ineptitude Self VI 6 Debuff Self 24 DaggerLowering 275 210 Creature Enchantment 70 Decreases the caster's Finesse Weapons skill by 35 points. +340 Light Weapon Mastery Other I 1 Buff Other 17 AxeRaising 1 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. +341 Light Weapon Mastery Other II 2 Buff Other 17 AxeRaising 50 1800 Creature Enchantment 20 Increases the target's Light Weapons skill by 15 points. +342 Light Weapon Mastery Other III 3 Buff Other 17 AxeRaising 100 1800 Creature Enchantment 30 Increases the target's Light Weapons skill by 20 points. +343 Light Weapon Mastery Other IV 4 Buff Other 17 AxeRaising 150 1800 Creature Enchantment 40 Increases the target's Light Weapons skill by 25 points. +344 Light Weapon Mastery Other V 5 Buff Other 17 AxeRaising 200 1800 Creature Enchantment 50 Increases the target's Light Weapons skill by 30 points. +345 Light Weapon Mastery Other VI 6 Buff Other 17 AxeRaising 250 2700 Creature Enchantment 60 Increases the target's Light Weapons skill by 35 points. +346 Light Weapon Mastery Self I 1 Buff Self 17 AxeRaising 1 1800 Creature Enchantment 15 Increases the caster's Light Weapons skill by 10 points. +347 Light Weapon Mastery Self II 2 Buff Self 17 AxeRaising 50 1800 Creature Enchantment 30 Increases the caster's Light Weapons skill by 15 points. +348 Light Weapon Mastery Self III 3 Buff Self 17 AxeRaising 100 1800 Creature Enchantment 40 Increases the caster's Light Weapons skill by 20 points. +349 Light Weapon Mastery Self IV 4 Buff Self 17 AxeRaising 150 1800 Creature Enchantment 50 Increases the caster's Light Weapons skill by 25 points. +350 Light Weapon Mastery Self V 5 Buff Self 17 AxeRaising 200 1800 Creature Enchantment 60 Increases the caster's Light Weapons skill by 30 points. +351 Light Weapon Mastery Self VI 6 Buff Self 17 AxeRaising 250 2700 Creature Enchantment 70 Increases the caster's Light Weapons skill by 35 points. +352 Light Weapon Ineptitude Other I 1 Debuff Other 18 AxeLowering 1 60 Creature Enchantment 10 Decreases the target's Light Weapons skill by 10 points. +353 Light Weapon Ineptitude Other II 2 Debuff Other 18 AxeLowering 75 90 Creature Enchantment 20 Decreases the target's Light Weapons skill by 15 points. +354 Light Weapon Ineptitude Other III 3 Debuff Other 18 AxeLowering 125 120 Creature Enchantment 30 Decreases the target's Light Weapons skill by 20 points. +355 Light Weapon Ineptitude Other IV 4 Debuff Other 18 AxeLowering 175 150 Creature Enchantment 40 Decreases the target's Light Weapons skill by 25 points. +356 Light Weapon Ineptitude Other V 5 Debuff Other 18 AxeLowering 225 180 Creature Enchantment 50 Decreases the target's Light Weapons skill by 30 points. +357 Light Weapon Ineptitude Other VI 6 Debuff Other 18 AxeLowering 275 210 Creature Enchantment 60 Decreases the target's Light Weapons skill by 35 points. +358 Light Weapon Ineptitude Self I 1 Debuff Self 18 AxeLowering 1 60 Creature Enchantment 15 Decreases the caster's Light Weapons skill by 10 points. +359 Light Weapon Ineptitude Self II 2 Debuff Self 18 AxeLowering 75 90 Creature Enchantment 30 Decreases the caster's Light Weapons skill by 15 points. +360 Light Weapon Ineptitude Self III 3 Debuff Self 18 AxeLowering 125 120 Creature Enchantment 40 Decreases the caster's Light Weapons skill by 20 points. +361 Light Weapon Ineptitude Self IV 4 Debuff Self 18 AxeLowering 175 150 Creature Enchantment 50 Decreases the caster's Light Weapons skill by 25 points. +362 Light Weapon Ineptitude Self V 5 Debuff Self 18 AxeLowering 225 180 Creature Enchantment 60 Decreases the caster's Light Weapons skill by 30 points. +363 Light Weapon Ineptitude Self VI 6 Debuff Self 18 AxeLowering 275 210 Creature Enchantment 70 Decreases the caster's Light Weapons skill by 35 points. +364 Light Weapon Mastery Other I 1 Buff Other 17 AxeRaising 1 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. +365 Light Weapon Mastery Other II 2 Buff Other 17 AxeRaising 50 1800 Creature Enchantment 20 Increases the target's Light Weapons skill by 15 points. +366 Light Weapon Mastery Other III 3 Buff Other 17 AxeRaising 100 1800 Creature Enchantment 30 Increases the target's Light Weapons skill by 20 points. +367 Light Weapon Mastery Other IV 4 Buff Other 17 AxeRaising 150 1800 Creature Enchantment 40 Increases the target's Light Weapons skill by 25 points. +368 Light Weapon Mastery Other V 5 Buff Other 17 AxeRaising 200 1800 Creature Enchantment 50 Increases the target's Light Weapons skill by 30 points. +369 Light Weapon Mastery Other VI 6 Buff Other 17 AxeRaising 250 2700 Creature Enchantment 60 Increases the target's Light Weapons skill by 35 points. +370 Light Weapon Mastery Self I 1 Buff Self 17 AxeRaising 1 1800 Creature Enchantment 15 Increases the caster's Light Weapons skill by 10 points. +371 Light Weapon Mastery Self II 2 Buff Self 17 AxeRaising 50 1800 Creature Enchantment 30 Increases the caster's Light Weapons skill by 15 points. +372 Light Weapon Mastery Self III 3 Buff Self 17 AxeRaising 100 1800 Creature Enchantment 40 Increases the caster's Light Weapons skill by 20 points. +373 Light Weapon Mastery Self IV 4 Buff Self 17 AxeRaising 150 1800 Creature Enchantment 50 Increases the caster's Light Weapons skill by 25 points. +374 Light Weapon Mastery Self V 5 Buff Self 17 AxeRaising 200 1800 Creature Enchantment 60 Increases the caster's Light Weapons skill by 30 points. +375 Light Weapon Mastery Self VI 6 Buff Self 17 AxeRaising 250 2700 Creature Enchantment 70 Increases the caster's Light Weapons skill by 35 points. +376 Light Weapon Ineptitude Other I 1 Debuff Other 18 AxeLowering 1 60 Creature Enchantment 10 Decreases the target's Light Weapons skill by 10 points. +377 Light Weapon Ineptitude Other II 2 Debuff Other 18 AxeLowering 75 90 Creature Enchantment 20 Decreases the target's Light Weapons skill by 15 points. +378 Light Weapon Ineptitude Other III 3 Debuff Other 18 AxeLowering 125 120 Creature Enchantment 30 Decreases the target's Light Weapons skill by 20 points. +379 Light Weapon Ineptitude Other IV 4 Debuff Other 18 AxeLowering 175 150 Creature Enchantment 40 Decreases the target's Light Weapons skill by 25 points. +380 Light Weapon Ineptitude Other V 5 Debuff Other 18 AxeLowering 225 180 Creature Enchantment 50 Decreases the target's Light Weapons skill by 30 points. +381 Light Weapon Ineptitude Other VI 6 Debuff Other 18 AxeLowering 275 210 Creature Enchantment 60 Decreases the target's Light Weapons skill by 35 points. +382 Light Weapon Ineptitude Self I 1 Debuff Self 18 AxeLowering 1 60 Creature Enchantment 15 Decreases the caster's Light Weapons skill by 10 points. +383 Light Weapon Ineptitude Self II 2 Debuff Self 18 AxeLowering 75 90 Creature Enchantment 30 Decreases the caster's Light Weapons skill by 15 points. +384 Light Weapon Ineptitude Self III 3 Debuff Self 18 AxeLowering 125 120 Creature Enchantment 40 Decreases the caster's Light Weapons skill by 20 points. +385 Light Weapon Ineptitude Self IV 4 Debuff Self 18 AxeLowering 175 150 Creature Enchantment 50 Decreases the caster's Light Weapons skill by 25 points. +386 Light Weapon Ineptitude Self V 5 Debuff Self 18 AxeLowering 225 180 Creature Enchantment 60 Decreases the caster's Light Weapons skill by 30 points. +387 Light Weapon Ineptitude Self VI 6 Debuff Self 18 AxeLowering 275 210 Creature Enchantment 70 Decreases the caster's Light Weapons skill by 35 points. +388 Light Weapon Mastery Other I 1 Buff Other 17 AxeRaising 1 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. +389 Light Weapon Mastery Other II 2 Buff Other 17 AxeRaising 50 1800 Creature Enchantment 20 Increases the target's Light Weapons skill by 15 points. +390 Light Weapon Mastery Other III 3 Buff Other 17 AxeRaising 100 1800 Creature Enchantment 30 Increases the target's Light Weapons skill by 20 points. +391 Light Weapon Mastery Other IV 4 Buff Other 17 AxeRaising 150 1800 Creature Enchantment 40 Increases the target's Light Weapons skill by 25 points. +392 Light Weapon Mastery Other V 5 Buff Other 17 AxeRaising 200 1800 Creature Enchantment 50 Increases the target's Light Weapons skill by 30 points. +393 Light Weapon Mastery Other VI 6 Buff Other 17 AxeRaising 250 2700 Creature Enchantment 60 Increases the target's Light Weapons skill by 35 points. +394 Light Weapon Mastery Self I 1 Buff Self 17 AxeRaising 1 1800 Creature Enchantment 15 Increases the caster's Light Weapons skill by 10 points. +395 Light Weapon Mastery Self II 2 Buff Self 17 AxeRaising 50 1800 Creature Enchantment 30 Increases the caster's Light Weapons skill by 15 points. +396 Light Weapon Mastery Self III 3 Buff Self 17 AxeRaising 100 1800 Creature Enchantment 40 Increases the caster's Light Weapons skill by 20 points. +397 Light Weapon Mastery Self IV 4 Buff Self 17 AxeRaising 150 1800 Creature Enchantment 50 Increases the caster's Light Weapons skill by 25 points. +398 Light Weapon Mastery Self V 5 Buff Self 17 AxeRaising 200 1800 Creature Enchantment 60 Increases the caster's Light Weapons skill by 30 points. +399 Light Weapon Mastery Self VI 6 Buff Self 17 AxeRaising 250 2700 Creature Enchantment 70 Increases the caster's Light Weapons skill by 35 points. +400 Light Weapon Ineptitude Other I 1 Debuff Other 18 AxeLowering 1 60 Creature Enchantment 10 Decreases the target's Light Weapons skill by 10 points. +401 Light Weapon Ineptitude Other II 2 Debuff Other 18 AxeLowering 75 90 Creature Enchantment 20 Decreases the target's Light Weapons skill by 15 points. +402 Light Weapon Ineptitude Other III 3 Debuff Other 18 AxeLowering 125 120 Creature Enchantment 30 Decreases the target's Light Weapons skill by 20 points. +403 Light Weapon Ineptitude Other IV 4 Debuff Other 18 AxeLowering 175 150 Creature Enchantment 40 Decreases the target's Light Weapons skill by 25 points. +404 Light Weapon Ineptitude Other V 5 Debuff Other 18 AxeLowering 225 180 Creature Enchantment 50 Decreases the target's Light Weapons skill by 30 points. +405 Light Weapon Ineptitude Other VI 6 Debuff Other 18 AxeLowering 275 210 Creature Enchantment 60 Decreases the target's Light Weapons skill by 35 points. +406 Light Weapon Ineptitude Self I 1 Debuff Self 18 AxeLowering 1 60 Creature Enchantment 15 Decreases the caster's Light Weapons skill by 10 points. +407 Light Weapon Ineptitude Self II 2 Debuff Self 18 AxeLowering 75 90 Creature Enchantment 30 Decreases the caster's Light Weapons skill by 15 points. +408 Light Weapon Ineptitude Self III 3 Debuff Self 18 AxeLowering 125 120 Creature Enchantment 40 Decreases the caster's Light Weapons skill by 20 points. +409 Light Weapon Ineptitude Self IV 4 Debuff Self 18 AxeLowering 175 150 Creature Enchantment 50 Decreases the caster's Light Weapons skill by 25 points. +410 Light Weapon Ineptitude Self V 5 Debuff Self 18 AxeLowering 225 180 Creature Enchantment 60 Decreases the caster's Light Weapons skill by 30 points. +411 Light Weapon Ineptitude Self VI 6 Debuff Self 18 AxeLowering 275 210 Creature Enchantment 70 Decreases the caster's Light Weapons skill by 35 points. +412 Heavy Weapon Mastery Other I 1 Buff Other 31 SwordRaising 1 1800 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 10 points. +413 Heavy Weapon Mastery Other II 2 Buff Other 31 SwordRaising 50 1800 Creature Enchantment 20 Increases the target's Heavy Weapons skill by 15 points. +414 Heavy Weapon Mastery Other III 3 Buff Other 31 SwordRaising 100 1800 Creature Enchantment 30 Increases the target's Heavy Weapons skill by 20 points. +415 Heavy Weapon Mastery Other IV 4 Buff Other 31 SwordRaising 150 1800 Creature Enchantment 40 Increases the target's Heavy Weapons skill by 25 points. +416 Heavy Weapon Mastery Other V 5 Buff Other 31 SwordRaising 200 1800 Creature Enchantment 50 Increases the target's Heavy Weapons skill by 30 points. +417 Heavy Weapon Mastery Other VI 6 Buff Other 31 SwordRaising 250 2700 Creature Enchantment 60 Increases the target's Heavy Weapons skill by 35 points. +418 Heavy Weapon Mastery Self I 1 Buff Self 31 SwordRaising 1 1800 Creature Enchantment 15 Increases the caster's Heavy Weapons skill by 10 points. +419 Heavy Weapon Mastery Self II 2 Buff Self 31 SwordRaising 50 1800 Creature Enchantment 30 Increases the caster's Heavy Weapons skill by 15 points. +420 Heavy Weapon Mastery Self III 3 Buff Self 31 SwordRaising 100 1800 Creature Enchantment 40 Increases the caster's Heavy Weapons skill by 20 points. +421 Heavy Weapon Mastery Self IV 4 Buff Self 31 SwordRaising 150 1800 Creature Enchantment 50 Increases the caster's Heavy Weapons skill by 25 points. +422 Heavy Weapon Mastery Self V 5 Buff Self 31 SwordRaising 200 1800 Creature Enchantment 60 Increases the caster's Heavy Weapons skill by 30 points. +423 Heavy Weapon Mastery Self VI 6 Buff Self 31 SwordRaising 250 2700 Creature Enchantment 70 Increases the caster's Heavy Weapons skill by 35 points. +424 Heavy Weapon Ineptitude Other I 1 Debuff Other 32 SwordLowering 1 60 Creature Enchantment 10 Decreases the target's Heavy Weapons skill by 10 points. +425 Heavy Weapon Ineptitude Other II 2 Debuff Other 32 SwordLowering 75 90 Creature Enchantment 20 Decreases the target's Heavy Weapons skill by 15 points. +426 Heavy Weapon Ineptitude Other III 3 Debuff Other 32 SwordLowering 125 120 Creature Enchantment 30 Decreases the target's Heavy Weapons skill by 20 points. +427 Heavy Weapon Ineptitude Other IV 4 Debuff Other 32 SwordLowering 175 150 Creature Enchantment 40 Decreases the target's Heavy Weapons skill by 25 points. +428 Heavy Weapon Ineptitude Other V 5 Debuff Other 32 SwordLowering 225 180 Creature Enchantment 50 Decreases the target's Heavy Weapons skill by 30 points. +429 Heavy Weapon Ineptitude Other VI 6 Debuff Other 32 SwordLowering 275 210 Creature Enchantment 60 Decreases the target's Heavy Weapons skill by 35 points. +430 Heavy Weapon Ineptitude Self I 1 Debuff Self 32 SwordLowering 1 60 Creature Enchantment 15 Decreases the caster's Heavy Weapons skill by 10 points. +431 Heavy Weapon Ineptitude Self II 2 Debuff Self 32 SwordLowering 75 90 Creature Enchantment 30 Decreases the caster's Heavy Weapons skill by 15 points. +432 Heavy Weapon Ineptitude Self III 3 Debuff Self 32 SwordLowering 125 120 Creature Enchantment 40 Decreases the caster's Heavy Weapons skill by 20 points. +433 Heavy Weapon Ineptitude Self IV 4 Debuff Self 32 SwordLowering 175 150 Creature Enchantment 50 Decreases the caster's Heavy Weapons skill by 25 points. +435 Heavy Weapon Ineptitude Self V 5 Debuff Self 32 SwordLowering 225 180 Creature Enchantment 60 Decreases the caster's Heavy Weapons skill by 30 points. +436 Heavy Weapon Ineptitude Self VI 6 Debuff Self 32 SwordLowering 275 210 Creature Enchantment 70 Decreases the caster's Heavy Weapons skill by 35 points. +437 Light Weapon Mastery Other I 1 Buff Other 17 AxeRaising 1 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. +438 Light Weapon Mastery Other II 2 Buff Other 17 AxeRaising 50 1800 Creature Enchantment 20 Increases the target's Light Weapons skill by 15 points. +439 Light Weapon Mastery Other III 3 Buff Other 17 AxeRaising 100 1800 Creature Enchantment 30 Increases the target's Light Weapons skill by 20 points. +440 Light Weapon Mastery Other IV 4 Buff Other 17 AxeRaising 150 1800 Creature Enchantment 40 Increases the target's Light Weapons skill by 25 points. +441 Light Weapon Mastery Other V 5 Buff Other 17 AxeRaising 200 1800 Creature Enchantment 50 Increases the target's Light Weapons skill by 30 points. +442 Light Weapon Mastery Other VI 6 Buff Other 17 AxeRaising 250 2700 Creature Enchantment 60 Increases the target's Light Weapons skill by 35 points. +443 Light Weapon Mastery Self I 1 Buff Self 17 AxeRaising 1 1800 Creature Enchantment 15 Increases the caster's Light Weapons skill by 10 points. +444 Light Weapon Mastery Self II 2 Buff Self 17 AxeRaising 50 1800 Creature Enchantment 30 Increases the caster's Light Weapons skill by 15 points. +445 Light Weapon Mastery Self III 3 Buff Self 17 AxeRaising 100 1800 Creature Enchantment 40 Increases the caster's Light Weapons skill by 20 points. +446 Light Weapon Mastery Self IV 4 Buff Self 17 AxeRaising 150 1800 Creature Enchantment 50 Increases the caster's Light Weapons skill by 25 points. +447 Light Weapon Mastery Self V 5 Buff Self 17 AxeRaising 200 1800 Creature Enchantment 60 Increases the caster's Light Weapons skill by 30 points. +448 Light Weapon Mastery Self VI 6 Buff Self 17 AxeRaising 250 2700 Creature Enchantment 70 Increases the caster's Light Weapons skill by 35 points. +449 Light Weapon Ineptitude Other I 1 Debuff Other 18 AxeLowering 1 60 Creature Enchantment 10 Decreases the target's Light Weapons skill by 10 points. +450 Light Weapon Ineptitude Other II 2 Debuff Other 18 AxeLowering 75 90 Creature Enchantment 20 Decreases the target's Light Weapons skill by 15 points. +451 Light Weapon Ineptitude Other III 3 Debuff Other 18 AxeLowering 125 120 Creature Enchantment 30 Decreases the target's Light Weapons skill by 20 points. +452 Light Weapon Ineptitude Other IV 4 Debuff Other 18 AxeLowering 175 150 Creature Enchantment 40 Decreases the target's Light Weapons skill by 25 points. +453 Light Weapon Ineptitude Other V 5 Debuff Other 18 AxeLowering 225 180 Creature Enchantment 50 Decreases the target's Light Weapons skill by 30 points. +454 Light Weapon Ineptitude Other VI 6 Debuff Other 18 AxeLowering 275 210 Creature Enchantment 60 Decreases the target's Light Weapons skill by 35 points. +455 Light Weapon Ineptitude Self I 1 Debuff Self 18 AxeLowering 1 60 Creature Enchantment 15 Decreases the caster's Light Weapons skill by 10 points. +456 Light Weapon Ineptitude Self II 2 Debuff Self 18 AxeLowering 75 90 Creature Enchantment 30 Decreases the caster's Light Weapons skill by 15 points. +457 Light Weapon Ineptitude Self III 3 Debuff Self 18 AxeLowering 125 120 Creature Enchantment 40 Decreases the caster's Light Weapons skill by 20 points. +458 Light Weapon Ineptitude Self IV 4 Debuff Self 18 AxeLowering 175 150 Creature Enchantment 50 Decreases the caster's Light Weapons skill by 25 points. +459 Light Weapon Ineptitude Self V 5 Debuff Self 18 AxeLowering 225 180 Creature Enchantment 60 Decreases the caster's Light Weapons skill by 30 points. +460 Light Weapon Ineptitude Self VI 6 Debuff Self 18 AxeLowering 275 210 Creature Enchantment 70 Decreases the caster's Light Weapons skill by 35 points. +461 Missile Weapon Mastery Other I 1 Buff Other 19 BowRaising 1 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 10 points. +462 Missile Weapon Mastery Other II 2 Buff Other 19 BowRaising 50 1800 Creature Enchantment 20 Increases the target's Missile Weapons skill by 15 points. +463 Missile Weapon Mastery Other III 3 Buff Other 19 BowRaising 100 1800 Creature Enchantment 30 Increases the target's Missile Weapons skill by 20 points. +464 Missile Weapon Mastery Other IV 4 Buff Other 19 BowRaising 150 1800 Creature Enchantment 40 Increases the target's Missile Weapons skill by 25 points. +465 Missile Weapon Mastery Other V 5 Buff Other 19 BowRaising 200 1800 Creature Enchantment 50 Increases the target's Missile Weapons skill by 30 points. +466 Missile Weapon Mastery Other VI 6 Buff Other 19 BowRaising 250 2700 Creature Enchantment 60 Increases the target's Missile Weapons skill by 35 points. +467 Missile Weapon Mastery Self I 1 Buff Self 19 BowRaising 1 1800 Creature Enchantment 15 Increases the caster's Missile Weapons skill by 10 points. +468 Missile Weapon Mastery Self II 2 Buff Self 19 BowRaising 50 1800 Creature Enchantment 30 Increases the caster's Missile Weapons skill by 15 points. +469 Missile Weapon Mastery Self III 3 Buff Self 19 BowRaising 100 1800 Creature Enchantment 40 Increases the caster's Missile Weapons skill by 20 points. +470 Missile Weapon Mastery Self IV 4 Buff Self 19 BowRaising 150 1800 Creature Enchantment 50 Increases the caster's Missile Weapons skill by 25 points. +471 Missile Weapon Mastery Self V 5 Buff Self 19 BowRaising 200 1800 Creature Enchantment 60 Increases the caster's Missile Weapons skill by 30 points. +472 Missile Weapon Mastery Self VI 6 Buff Self 19 BowRaising 250 2700 Creature Enchantment 70 Increases the caster's Missile Weapons skill by 35 points. +473 Missile Weapon Ineptitude Other I 1 Debuff Other 20 BowLowering 1 60 Creature Enchantment 10 Decreases the target's Missile Weapons skill by 10 points. +474 Missile Weapon Ineptitude Other II 2 Debuff Other 20 BowLowering 75 90 Creature Enchantment 20 Decreases the target's Missile Weapons skill by 15 points. +475 Missile Weapon Ineptitude Other III 3 Debuff Other 20 BowLowering 125 120 Creature Enchantment 30 Decreases the target's Missile Weapons skill by 20 points. +476 Missile Weapon Ineptitude Other IV 4 Debuff Other 20 BowLowering 175 150 Creature Enchantment 40 Decreases the target's Missile Weapons skill by 25 points. +477 Missile Weapon Ineptitude Other V 5 Debuff Other 20 BowLowering 225 180 Creature Enchantment 50 Decreases the target's Missile Weapons skill by 30 points. +478 Missile Weapon Ineptitude Other VI 6 Debuff Other 20 BowLowering 275 210 Creature Enchantment 60 Decreases the target's Missile Weapons skill by 35 points. +479 Missile Weapon Ineptitude Self I 1 Debuff Self 20 BowLowering 1 60 Creature Enchantment 15 Decreases the caster's Missile Weapons skill by 10 points. +480 Missile Weapon Ineptitude Self II 2 Debuff Self 20 BowLowering 75 90 Creature Enchantment 30 Decreases the caster's Missile Weapons skill by 15 points. +481 Missile Weapon Ineptitude Self III 3 Debuff Self 20 BowLowering 125 120 Creature Enchantment 40 Decreases the caster's Missile Weapons skill by 20 points. +482 Missile Weapon Ineptitude Self IV 4 Debuff Self 20 BowLowering 175 150 Creature Enchantment 50 Decreases the caster's Missile Weapons skill by 25 points. +483 Missile Weapon Ineptitude Self V 5 Debuff Self 20 BowLowering 225 180 Creature Enchantment 60 Decreases the caster's Missile Weapons skill by 30 points. +484 Missile Weapon Ineptitude Self VI 6 Debuff Self 20 BowLowering 275 210 Creature Enchantment 70 Decreases the caster's Missile Weapons skill by 35 points. +485 Missile Weapon Mastery Other I 1 Buff Other 19 BowRaising 1 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 10 points. +486 Missile Weapon Mastery Other II 2 Buff Other 19 BowRaising 50 1800 Creature Enchantment 20 Increases the target's Missile Weapons skill by 15 points. +487 Missile Weapon Mastery Other III 3 Buff Other 19 BowRaising 100 1800 Creature Enchantment 30 Increases the target's Missile Weapons skill by 20 points. +488 Missile Weapon Mastery Other IV 4 Buff Other 19 BowRaising 150 1800 Creature Enchantment 40 Increases the target's Missile Weapons skill by 25 points. +489 Missile Weapon Mastery Other V 5 Buff Other 19 BowRaising 200 1800 Creature Enchantment 50 Increases the target's Missile Weapons skill by 30 points. +490 Missile Weapon Mastery Other VI 6 Buff Other 19 BowRaising 250 2700 Creature Enchantment 60 Increases the target's Missile Weapons skill by 35 points. +491 Missile Weapon Mastery Self I 1 Buff Self 19 BowRaising 1 1800 Creature Enchantment 15 Increases the caster's Missile Weapons skill by 10 points. +492 Missile Weapon Mastery Self II 2 Buff Self 19 BowRaising 50 1800 Creature Enchantment 30 Increases the caster's Missile Weapons skill by 15 points. +493 Missile Weapon Mastery Self III 3 Buff Self 19 BowRaising 100 1800 Creature Enchantment 40 Increases the caster's Missile Weapons skill by 20 points. +494 Missile Weapon Mastery Self IV 4 Buff Self 19 BowRaising 150 1800 Creature Enchantment 50 Increases the caster's Missile Weapons skill by 25 points. +495 Missile Weapon Mastery Self V 5 Buff Self 19 BowRaising 200 1800 Creature Enchantment 60 Increases the caster's Missile Weapons skill by 30 points. +496 Missile Weapon Mastery Self VI 6 Buff Self 19 BowRaising 250 2700 Creature Enchantment 70 Increases the caster's Missile Weapons skill by 35 points. +497 Missile Weapon Ineptitude Other I 1 Debuff Other 20 BowLowering 1 60 Creature Enchantment 10 Decreases the target's Missile Weapons skill by 10 points. +498 Missile Weapon Ineptitude Other II 2 Debuff Other 20 BowLowering 75 90 Creature Enchantment 20 Decreases the target's Missile Weapons skill by 15 points. +499 Missile Weapon Ineptitude Other III 3 Debuff Other 20 BowLowering 125 120 Creature Enchantment 30 Decreases the target's Missile Weapons skill by 20 points. +500 Missile Weapon Ineptitude Other IV 4 Debuff Other 20 BowLowering 175 150 Creature Enchantment 40 Decreases the target's Missile Weapons skill by 25 points. +501 Missile Weapon Ineptitude Other V 5 Debuff Other 20 BowLowering 225 180 Creature Enchantment 50 Decreases the target's Missile Weapons skill by 30 points. +502 Missile Weapon Ineptitude Other VI 6 Debuff Other 20 BowLowering 275 210 Creature Enchantment 60 Decreases the target's Missile Weapons skill by 35 points. +503 Missile Weapon Ineptitude Self I 1 Debuff Self 20 BowLowering 1 60 Creature Enchantment 15 Decreases the caster's Missile Weapons skill by 10 points. +504 Missile Weapon Ineptitude Self II 2 Debuff Self 20 BowLowering 75 90 Creature Enchantment 30 Decreases the caster's Missile Weapons skill by 15 points. +505 Missile Weapon Ineptitude Self III 3 Debuff Self 20 BowLowering 125 120 Creature Enchantment 40 Decreases the caster's Missile Weapons skill by 20 points. +506 Missile Weapon Ineptitude Self IV 4 Debuff Self 20 BowLowering 175 150 Creature Enchantment 50 Decreases the caster's Missile Weapons skill by 25 points. +507 Missile Weapon Ineptitude Self V 5 Debuff Self 20 BowLowering 225 180 Creature Enchantment 60 Decreases the caster's Missile Weapons skill by 30 points. +508 Missile Weapon Ineptitude Self VI 6 Debuff Self 20 BowLowering 275 210 Creature Enchantment 70 Decreases the caster's Missile Weapons skill by 35 points. +509 Acid Protection Other I 1 Buff Other 101 AcidProtection 1 1800 Life Magic 10 Reduces damage the target takes from acid by 9%. +510 Acid Protection Other II 2 Buff Other 101 AcidProtection 50 1800 Life Magic 20 Reduces damage the target takes from acid by 20%. +511 Acid Protection Other III 3 Buff Other 101 AcidProtection 100 1800 Life Magic 30 Reduces damage the target takes from acid by 33%. +512 Acid Protection Other IV 4 Buff Other 101 AcidProtection 150 1800 Life Magic 40 Reduces damage the target takes from acid by 43%. +513 Acid Protection Other V 5 Buff Other 101 AcidProtection 200 1800 Life Magic 50 Reduces damage the target takes from acid by 50%. +514 Acid Protection Other VI 6 Buff Other 101 AcidProtection 250 2700 Life Magic 60 Reduces damage the target takes from acid by 60%. +515 Acid Protection Self I 1 Buff Self 101 AcidProtection 1 1800 Life Magic 15 Reduces damage the caster takes from acid by 9% +516 Acid Protection Self II 2 Buff Self 101 AcidProtection 50 1800 Life Magic 30 Reduces damage the caster takes from acid by 20%. +517 Acid Protection Self III 3 Buff Self 101 AcidProtection 100 1800 Life Magic 40 Reduces damage the caster takes from acid by 33%. +518 Acid Protection Self IV 4 Buff Self 101 AcidProtection 150 1800 Life Magic 50 Reduces damage the caster takes from acid by 43%. +519 Acid Protection Self V 5 Buff Self 101 AcidProtection 200 1800 Life Magic 60 Reduces damage the caster takes from acid by 50%. +520 Acid Protection Self VI 6 Buff Self 101 AcidProtection 250 2700 Life Magic 70 Reduces damage the caster takes from acid by 60%. +521 Acid Vulnerability Other I 1 Debuff Other 102 AcidVulnerability 25 60 Life Magic 10 Increases damage the target takes from acid by 10% +522 Acid Vulnerability Other II 2 Debuff Other 102 AcidVulnerability 75 90 Life Magic 20 Increases damage the target takes from acid by 25% +523 Acid Vulnerability Other III 3 Debuff Other 102 AcidVulnerability 125 120 Life Magic 30 Increases damage the target takes from acid by 50%. +524 Acid Vulnerability Other IV 4 Debuff Other 102 AcidVulnerability 175 150 Life Magic 40 Increases damage the target takes from acid by 75%. +525 Acid Vulnerability Other V 5 Debuff Other 102 AcidVulnerability 225 180 Life Magic 50 Increases damage the target takes from acid by 100%. +526 Acid Vulnerability Other VI 6 Debuff Other 102 AcidVulnerability 275 210 Life Magic 60 Increases damage the target takes from acid by 150%. +527 Acid Vulnerability Self I 1 Debuff Self 102 AcidVulnerability 25 60 Life Magic 15 Increases damage the caster takes from acid by 10% +528 Acid Vulnerability Self II 2 Debuff Self 102 AcidVulnerability 75 90 Life Magic 30 Increases damage the caster takes from acid by 25% +529 Acid Vulnerability Self III 3 Debuff Self 102 AcidVulnerability 125 120 Life Magic 40 Increases damage the caster takes from acid by 50%. +530 Acid Vulnerability Self IV 4 Debuff Self 102 AcidVulnerability 175 150 Life Magic 50 Increases damage the caster takes from acid by 75%. +531 Acid Vulnerability Self V 5 Debuff Self 102 AcidVulnerability 225 180 Life Magic 60 Increases damage the caster takes from acid by 100%. +532 Acid Vulnerability Self VI 6 Debuff Self 102 AcidVulnerability 275 210 Life Magic 70 Increases damage the caster takes from acid by 150%. +533 Missile Weapon Mastery Other I 1 Buff Other 19 BowRaising 1 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 10 points. +534 Missile Weapon Mastery Other II 2 Buff Other 19 BowRaising 50 1800 Creature Enchantment 20 Increases the target's Missile Weapons skill by 15 points. +535 Missile Weapon Mastery Other III 3 Buff Other 19 BowRaising 100 1800 Creature Enchantment 30 Increases the target's Missile Weapons skill by 20 points. +536 Missile Weapon Mastery Other IV 4 Buff Other 19 BowRaising 150 1800 Creature Enchantment 40 Increases the target's Missile Weapons skill by 25 points. +537 Missile Weapon Mastery Other V 5 Buff Other 19 BowRaising 200 1800 Creature Enchantment 50 Increases the target's Missile Weapons skill by 30 points. +538 Missile Weapon Mastery Other VI 6 Buff Other 19 BowRaising 250 2700 Creature Enchantment 60 Increases the target's Missile Weapons skill by 35 points. +539 Missile Weapon Mastery Self I 1 Buff Self 19 BowRaising 1 1800 Creature Enchantment 15 Increases the caster's Missile Weapons skill by 10 points. +540 Missile Weapon Mastery Self II 2 Buff Self 19 BowRaising 50 1800 Creature Enchantment 30 Increases the caster's Missile Weapons skill by 15 points. +541 Missile Weapon Mastery Self III 3 Buff Self 19 BowRaising 100 1800 Creature Enchantment 40 Increases the caster's Missile Weapons skill by 20 points. +542 Missile Weapon Mastery Self IV 4 Buff Self 19 BowRaising 150 1800 Creature Enchantment 50 Increases the caster's Missile Weapons skill by 25 points. +543 Missile Weapon Mastery Self V 5 Buff Self 19 BowRaising 200 1800 Creature Enchantment 60 Increases the caster's Missile Weapons skill by 30 points. +544 Missile Weapon Mastery Self VI 6 Buff Self 19 BowRaising 250 2700 Creature Enchantment 70 Increases the caster's Missile Weapons skill by 35 points. +545 Missile Weapon Ineptitude Other I 1 Debuff Other 20 BowLowering 1 60 Creature Enchantment 10 Decreases the target's Missile Weapons skill by 10 points. +546 Missile Weapon Ineptitude Other II 2 Debuff Other 20 BowLowering 75 90 Creature Enchantment 20 Decreases the target's Missile Weapons skill by 15 points. +547 Missile Weapon Ineptitude Other III 3 Debuff Other 20 BowLowering 125 120 Creature Enchantment 30 Decreases the target's Missile Weapons skill by 20 points. +548 Missile Weapon Ineptitude Other IV 4 Debuff Other 20 BowLowering 175 150 Creature Enchantment 40 Decreases the target's Missile Weapons skill by 25 points. +549 Missile Weapon Ineptitude Other V 5 Debuff Other 20 BowLowering 225 180 Creature Enchantment 50 Decreases the target's Missile Weapons skill by 30 points. +550 Missile Weapon Ineptitude Other VI 6 Debuff Other 20 BowLowering 275 210 Creature Enchantment 60 Decreases the target's Missile Weapons skill by 35 points. +551 Missile Weapon Ineptitude Self I 1 Debuff Self 20 BowLowering 1 60 Creature Enchantment 15 Decreases the caster's Missile Weapons skill by 10 points. +552 Missile Weapon Ineptitude Self II 2 Debuff Self 20 BowLowering 75 90 Creature Enchantment 30 Decreases the caster's Missile Weapons skill by 15 points. +553 Missile Weapon Ineptitude Self III 3 Debuff Self 20 BowLowering 125 120 Creature Enchantment 40 Decreases the caster's Missile Weapons skill by 20 points. +554 Missile Weapon Ineptitude Self IV 4 Debuff Self 20 BowLowering 175 150 Creature Enchantment 50 Decreases the caster's Missile Weapons skill by 25 points. +555 Missile Weapon Ineptitude Self V 5 Debuff Self 20 BowLowering 225 180 Creature Enchantment 60 Decreases the caster's Missile Weapons skill by 30 points. +556 Missile Weapon Ineptitude Self VI 6 Debuff Self 20 BowLowering 275 210 Creature Enchantment 70 Decreases the caster's Missile Weapons skill by 35 points. +557 Creature Enchantment Mastery Self I 1 Buff Self 43 CreatureEnchantmentRaising 1 1800 Creature Enchantment 15 Increases the caster's Creature Enchantment skill by 10 points. +558 Creature Enchantment Mastery Self II 2 Buff Self 43 CreatureEnchantmentRaising 50 1800 Creature Enchantment 30 Increases the caster's Creature Enchantment skill by 15 points. +559 Creature Enchantment Mastery Self III 3 Buff Self 43 CreatureEnchantmentRaising 100 1800 Creature Enchantment 40 Increases the caster's Creature Enchantment skill by 20 points. +560 Creature Enchantment Mastery Self IV 4 Buff Self 43 CreatureEnchantmentRaising 150 1800 Creature Enchantment 50 Increases the caster's Creature Enchantment skill by 25 points. +561 Creature Enchantment Mastery Self V 5 Buff Self 43 CreatureEnchantmentRaising 200 1800 Creature Enchantment 60 Increases the caster's Creature Enchantment skill by 30 points. +562 Creature Enchantment Mastery Self VI 6 Buff Self 43 CreatureEnchantmentRaising 250 2700 Creature Enchantment 70 Increases the caster's Creature Enchantment skill by 35 points. +563 Creature Enchantment Mastery Other I 1 Buff Other 43 CreatureEnchantmentRaising 1 1800 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 10 points. +564 Creature Enchantment Mastery Other II 2 Buff Other 43 CreatureEnchantmentRaising 50 1800 Creature Enchantment 20 Increases the target's Creature Enchantment skill by 15 points. +565 Creature Enchantment Mastery Other III 3 Buff Other 43 CreatureEnchantmentRaising 100 1800 Creature Enchantment 30 Increases the target's Creature Enchantment skill by 20 points. +566 Creature Enchantment Mastery Other IV 4 Buff Other 43 CreatureEnchantmentRaising 150 1800 Creature Enchantment 40 Increases the target's Creature Enchantment skill by 25 points. +567 Creature Enchantment Mastery Other V 5 Buff Other 43 CreatureEnchantmentRaising 200 1800 Creature Enchantment 50 Increases the target's Creature Enchantment skill by 30 points. +568 Creature Enchantment Mastery Other VI 6 Buff Other 43 CreatureEnchantmentRaising 250 2700 Creature Enchantment 60 Increases the target's Creature Enchantment skill by 35 points. +569 Creature Enchantment Ineptitude Other I 1 Debuff Other 44 CreatureEnchantmentLowering 1 60 Creature Enchantment 10 Decreases the target's Creature Enchantment skill by 10 points. +570 Creature Enchantment Ineptitude Other II 2 Debuff Other 44 CreatureEnchantmentLowering 75 90 Creature Enchantment 20 Decreases the target's Creature Enchantment skill by 15 points. +571 Creature Enchantment Ineptitude Other III 3 Debuff Other 44 CreatureEnchantmentLowering 125 120 Creature Enchantment 30 Decreases the target's Creature Enchantment skill by 20 points. +572 Creature Enchantment Ineptitude Other IV 4 Debuff Other 44 CreatureEnchantmentLowering 175 150 Creature Enchantment 40 Decreases the target's Creature Enchantment skill by 25 points. +573 Creature Enchantment Ineptitude Other V 5 Debuff Other 44 CreatureEnchantmentLowering 225 180 Creature Enchantment 50 Decreases the target's Creature Enchantment skill by 30 points. +574 Creature Enchantment Ineptitude Other VI 6 Debuff Other 44 CreatureEnchantmentLowering 275 210 Creature Enchantment 60 Decreases the target's Creature Enchantment skill by 35 points. +575 Creature Enchantment Ineptitude Self I 1 Debuff Self 44 CreatureEnchantmentLowering 1 60 Creature Enchantment 15 Decreases the caster's Creature Enchantment skill by 10 points. +576 Creature Enchantment Ineptitude Self II 2 Debuff Self 44 CreatureEnchantmentLowering 75 90 Creature Enchantment 30 Decreases the caster's Creature Enchantment skill by 15 points. +577 Creature Enchantment Ineptitude Self III 3 Debuff Self 44 CreatureEnchantmentLowering 125 120 Creature Enchantment 40 Decreases the caster's Creature Enchantment skill by 20 points. +578 Creature Enchantment Ineptitude Self IV 4 Debuff Self 44 CreatureEnchantmentLowering 175 150 Creature Enchantment 50 Decreases the caster's Creature Enchantment skill by 25 points. +579 Creature Enchantment Ineptitude Self V 5 Debuff Self 44 CreatureEnchantmentLowering 225 180 Creature Enchantment 60 Decreases the caster's Creature Enchantment skill by 30 points. +580 Creature Enchantment Ineptitude Self VI 6 Debuff Self 44 CreatureEnchantmentLowering 275 210 Creature Enchantment 70 Decreases the caster's Creature Enchantment skill by 35 points. +581 Item Enchantment Mastery Self I 1 Buff Self 45 ItemEnchantmentRaising 1 1800 Creature Enchantment 15 Increases the caster's Item Enchantment skill by 10 points. +582 Item Enchantment Mastery Self II 2 Buff Self 45 ItemEnchantmentRaising 50 1800 Creature Enchantment 30 Increases the caster's Item Enchantment skill by 15 points. +583 Item Enchantment Mastery Self III 3 Buff Self 45 ItemEnchantmentRaising 100 1800 Creature Enchantment 40 Increases the caster's Item Enchantment skill by 20 points. +584 Item Enchantment Mastery Self IV 4 Buff Self 45 ItemEnchantmentRaising 150 1800 Creature Enchantment 50 Increases the caster's Item Enchantment skill by 25 points. +585 Item Enchantment Mastery Self V 5 Buff Self 45 ItemEnchantmentRaising 200 1800 Creature Enchantment 60 Increases the caster's Item Enchantment skill by 30 points. +586 Item Enchantment Mastery Self VI 6 Buff Self 45 ItemEnchantmentRaising 250 2700 Creature Enchantment 70 Increases the caster's Item Enchantment skill by 35 points. +587 Item Enchantment Mastery Other I 1 Buff Other 45 ItemEnchantmentRaising 1 1800 Creature Enchantment 10 Increases the target's Item Enchantment skill by 10 points. +588 Item Enchantment Mastery Other II 2 Buff Other 45 ItemEnchantmentRaising 50 1800 Creature Enchantment 20 Increases the target's Item Enchantment skill by 15 points. +589 Item Enchantment Mastery Other III 3 Buff Other 45 ItemEnchantmentRaising 100 1800 Creature Enchantment 30 Increases the target's Item Enchantment skill by 20 points. +590 Item Enchantment Mastery Other IV 4 Buff Other 45 ItemEnchantmentRaising 150 1800 Creature Enchantment 40 Increases the target's Item Enchantment skill by 25 points. +591 Item Enchantment Mastery Other V 5 Buff Other 45 ItemEnchantmentRaising 200 1800 Creature Enchantment 50 Increases the target's Item Enchantment skill by 30 points. +592 Item Enchantment Mastery Other VI 6 Buff Other 45 ItemEnchantmentRaising 250 2700 Creature Enchantment 60 Increases the target's Item Enchantment skill by 35 points. +593 Item Enchantment Ineptitude Other I 1 Debuff Other 46 ItemEnchantmentLowering 1 60 Creature Enchantment 10 Decreases the target's Item Enchantment skill by 10 points. +594 Item Enchantment Ineptitude Other II 2 Debuff Other 46 ItemEnchantmentLowering 75 90 Creature Enchantment 20 Decreases the target's Item Enchantment skill by 15 points. +595 Item Enchantment Ineptitude Other III 3 Debuff Other 46 ItemEnchantmentLowering 125 120 Creature Enchantment 30 Decreases the target's Item Enchantment skill by 20 points. +596 Item Enchantment Ineptitude Other IV 4 Debuff Other 46 ItemEnchantmentLowering 175 150 Creature Enchantment 40 Decreases the target's Item Enchantment skill by 25 points. +597 Item Enchantment Ineptitude Other V 5 Debuff Other 46 ItemEnchantmentLowering 225 180 Creature Enchantment 50 Decreases the target's Item Enchantment skill by 30 points. +598 Item Enchantment Ineptitude Other VI 6 Debuff Other 46 ItemEnchantmentLowering 275 210 Creature Enchantment 60 Decreases the target's Item Enchantment skill by 35 points. +599 Item Enchantment Ineptitude Self I 1 Debuff Self 46 ItemEnchantmentLowering 1 60 Creature Enchantment 15 Decreases the caster's Item Enchantment skill by 10 points. +600 Item Enchantment Ineptitude Self II 2 Debuff Self 46 ItemEnchantmentLowering 75 90 Creature Enchantment 30 Decreases the caster's Item Enchantment skill by 15 points. +601 Item Enchantment Ineptitude Self III 3 Debuff Self 46 ItemEnchantmentLowering 125 120 Creature Enchantment 40 Decreases the caster's Item Enchantment skill by 20 points. +602 Item Enchantment Ineptitude Self IV 4 Debuff Self 46 ItemEnchantmentLowering 175 150 Creature Enchantment 50 Decreases the caster's Item Enchantment skill by 25 points. +603 Item Enchantment Ineptitude Self V 5 Debuff Self 46 ItemEnchantmentLowering 225 180 Creature Enchantment 60 Decreases the caster's Item Enchantment skill by 30 points. +604 Item Enchantment Ineptitude Self VI 6 Debuff Self 46 ItemEnchantmentLowering 275 210 Creature Enchantment 70 Decreases the caster's Item Enchantment skill by 35 points. +605 Life Magic Mastery Self I 1 Buff Self 47 LifeMagicRaising 1 1800 Creature Enchantment 15 Increases the caster's Life Magic skill by 10 points. +606 Life Magic Mastery Self II 2 Buff Self 47 LifeMagicRaising 50 1800 Creature Enchantment 30 Increases the caster's Life Magic skill by 15 points. +607 Life Magic Mastery Self III 3 Buff Self 47 LifeMagicRaising 100 1800 Creature Enchantment 40 Increases the caster's Life Magic skill by 20 points. +608 Life Magic Mastery Self IV 4 Buff Self 47 LifeMagicRaising 150 1800 Creature Enchantment 50 Increases the caster's Life Magic skill by 25 points. +609 Life Magic Mastery Self V 5 Buff Self 47 LifeMagicRaising 200 1800 Creature Enchantment 60 Increases the caster's Life Magic skill by 30 points. +610 Life Magic Mastery Self VI 6 Buff Self 47 LifeMagicRaising 250 2700 Creature Enchantment 70 Increases the caster's Life Magic skill by 35 points. +611 Life Magic Mastery Other I 1 Buff Other 47 LifeMagicRaising 1 1800 Creature Enchantment 10 Increases the target's Life Magic skill by 10 points. +612 Life Magic Mastery Other II 2 Buff Other 47 LifeMagicRaising 50 1800 Creature Enchantment 20 Increases the target's Life Magic skill by 15 points. +613 Life Magic Mastery Other III 3 Buff Other 47 LifeMagicRaising 100 1800 Creature Enchantment 30 Increases the target's Life Magic skill by 20 points. +614 Life Magic Mastery Other IV 4 Buff Other 47 LifeMagicRaising 150 1800 Creature Enchantment 40 Increases the target's Life Magic skill by 25 points. +615 Life Magic Mastery Other V 5 Buff Other 47 LifeMagicRaising 200 1800 Creature Enchantment 50 Increases the target's Life Magic skill by 30 points. +616 Life Magic Mastery Other VI 6 Buff Other 47 LifeMagicRaising 250 2700 Creature Enchantment 60 Increases the target's Life Magic skill by 35 points. +617 Life Magic Ineptitude Self I 1 Debuff Self 48 LifeMagicLowering 1 60 Creature Enchantment 15 Decreases the caster's Life Magic skill by 10 points. +618 Life Magic Ineptitude Self II 2 Debuff Self 48 LifeMagicLowering 75 90 Creature Enchantment 30 Decreases the caster's Life Magic skill by 15 points. +619 Life Magic Ineptitude Self III 3 Debuff Self 48 LifeMagicLowering 125 120 Creature Enchantment 40 Decreases the caster's Life Magic skill by 20 points. +620 Life Magic Ineptitude Self IV 4 Debuff Self 48 LifeMagicLowering 175 150 Creature Enchantment 50 Decreases the caster's Life Magic skill by 25 points. +621 Life Magic Ineptitude Self V 5 Debuff Self 48 LifeMagicLowering 225 180 Creature Enchantment 60 Decreases the caster's Life Magic skill by 30 points. +622 Life Magic Ineptitude Self VI 6 Debuff Self 48 LifeMagicLowering 275 210 Creature Enchantment 70 Decreases the caster's Life Magic skill by 35 points. +623 Life Magic Ineptitude Other I 1 Debuff Other 48 LifeMagicLowering 1 60 Creature Enchantment 10 Decreases the target's Life Magic skill by 10 points. +624 Life Magic Ineptitude Other II 2 Debuff Other 48 LifeMagicLowering 75 90 Creature Enchantment 10 Decreases the target's Life Magic skill by 15 points. +625 Life Magic Ineptitude Other III 3 Debuff Other 48 LifeMagicLowering 125 120 Creature Enchantment 30 Decreases the target's Life Magic skill by 20 points. +626 Life Magic Ineptitude Other IV 4 Debuff Other 48 LifeMagicLowering 175 150 Creature Enchantment 40 Decreases the target's Life Magic skill by 25 points. +627 Life Magic Ineptitude Other V 5 Debuff Other 48 LifeMagicLowering 225 180 Creature Enchantment 50 Decreases the target's Life Magic skill by 30 points. +628 Life Magic Ineptitude Other VI 6 Debuff Other 48 LifeMagicLowering 275 210 Creature Enchantment 60 Decreases the target's Life Magic skill by 35 points. +629 War Magic Mastery Self I 1 Buff Self 49 WarMagicRaising 1 1800 Creature Enchantment 15 Increases the caster's War Magic skill by 10 points. +630 War Magic Mastery Self II 2 Buff Self 49 WarMagicRaising 50 1800 Creature Enchantment 30 Increases the caster's War Magic skill by 15 points. +631 War Magic Mastery Self III 3 Buff Self 49 WarMagicRaising 100 1800 Creature Enchantment 40 Increases the caster's War Magic skill by 20 points. +632 War Magic Mastery Self IV 4 Buff Self 49 WarMagicRaising 150 1800 Creature Enchantment 50 Increases the caster's War Magic skill by 25 points. +633 War Magic Mastery Self V 5 Buff Self 49 WarMagicRaising 200 1800 Creature Enchantment 60 Increases the caster's War Magic skill by 30 points. +634 War Magic Mastery Self VI 6 Buff Self 49 WarMagicRaising 250 2700 Creature Enchantment 70 Increases the caster's War Magic skill by 35 points. +635 War Magic Mastery Other I 1 Buff Other 49 WarMagicRaising 1 1800 Creature Enchantment 10 Increases the target's War Magic skill by 10 points. +636 War Magic Mastery Other II 2 Buff Other 49 WarMagicRaising 50 1800 Creature Enchantment 20 Increases the target's War Magic skill by 15 points. +637 War Magic Mastery Other III 3 Buff Other 49 WarMagicRaising 100 1800 Creature Enchantment 30 Increases the target's War Magic skill by 20 points. +638 War Magic Mastery Other IV 4 Buff Other 49 WarMagicRaising 150 1800 Creature Enchantment 40 Increases the target's War Magic skill by 25 points. +639 War Magic Mastery Other V 5 Buff Other 49 WarMagicRaising 200 1800 Creature Enchantment 50 Increases the target's War Magic skill by 30 points. +640 War Magic Mastery Other VI 6 Buff Other 49 WarMagicRaising 250 2700 Creature Enchantment 60 Increases the target's War Magic skill by 35 points. +641 War Magic Ineptitude Self I 1 Debuff Self 50 WarMagicLowering 1 60 Creature Enchantment 15 Decreases the caster's War Magic skill by 10 points. +642 War Magic Ineptitude Self II 2 Debuff Self 50 WarMagicLowering 75 90 Creature Enchantment 30 Decreases the caster's War Magic skill by 15 points. +643 War Magic Ineptitude Self III 3 Debuff Self 50 WarMagicLowering 125 120 Creature Enchantment 40 Decreases the caster's War Magic skill by 20 points. +644 War Magic Ineptitude Self IV 4 Debuff Self 50 WarMagicLowering 175 150 Creature Enchantment 50 Decreases the caster's War Magic skill by 25 points. +645 War Magic Ineptitude Self V 5 Debuff Self 50 WarMagicLowering 225 180 Creature Enchantment 60 Decreases the caster's War Magic skill by 30 points. +646 War Magic Ineptitude Self VI 6 Debuff Self 50 WarMagicLowering 275 210 Creature Enchantment 70 Decreases the caster's War Magic skill by 35 points. +647 War Magic Ineptitude Other I 1 Debuff Other 50 WarMagicLowering 1 60 Creature Enchantment 10 Decreases the target's War Magic skill by 10 points. +648 War Magic Ineptitude Other II 2 Debuff Other 50 WarMagicLowering 75 90 Creature Enchantment 20 Decreases the target's War Magic skill by 15 points. +649 War Magic Ineptitude Other III 3 Debuff Other 50 WarMagicLowering 125 120 Creature Enchantment 30 Decreases the target's War Magic skill by 20 points. +650 War Magic Ineptitude Other IV 4 Debuff Other 50 WarMagicLowering 175 150 Creature Enchantment 40 Decreases the target's War Magic skill by 25 points. +651 War Magic Ineptitude Other V 5 Debuff Other 50 WarMagicLowering 225 180 Creature Enchantment 50 Decreases the target's War Magic skill by 30 points. +652 War Magic Ineptitude Other VI 6 Debuff Other 50 WarMagicLowering 275 210 Creature Enchantment 60 Decreases the target's War Magic skill by 35 points. +653 Mana Conversion Mastery Self I 1 Buff Self 51 ManaConversionRaising 1 1800 Creature Enchantment 15 Increases the caster's Mana Conversion skill by 10 points. +654 Mana Conversion Mastery Self II 2 Buff Self 51 ManaConversionRaising 50 1800 Creature Enchantment 30 Increases the caster's Mana Conversion skill by 15 points. +655 Mana Conversion Mastery Self III 3 Buff Self 51 ManaConversionRaising 100 1800 Creature Enchantment 40 Increases the caster's Mana Conversion skill by 20 points. +656 Mana Conversion Mastery Self IV 4 Buff Self 51 ManaConversionRaising 150 1800 Creature Enchantment 50 Increases the caster's Mana Conversion skill by 25 points. +657 Mana Conversion Mastery Self V 5 Buff Self 51 ManaConversionRaising 200 1800 Creature Enchantment 60 Increases the caster's Mana Conversion skill by 30 points. +658 Mana Conversion Mastery Self VI 6 Buff Self 51 ManaConversionRaising 250 2700 Creature Enchantment 70 Increases the caster's Mana Conversion skill by 35 points. +659 Mana Conversion Mastery Other I 1 Buff Other 51 ManaConversionRaising 1 1800 Creature Enchantment 10 Increases the target's Mana Conversion skill by 10 points. +660 Mana Conversion Mastery Other II 2 Buff Other 51 ManaConversionRaising 50 1800 Creature Enchantment 20 Increases the target's Mana Conversion skill by 15 points. +661 Mana Conversion Mastery Other III 3 Buff Other 51 ManaConversionRaising 100 1800 Creature Enchantment 30 Increases the target's Mana Conversion skill by 20 points. +662 Mana Conversion Mastery Other IV 4 Buff Other 51 ManaConversionRaising 150 1800 Creature Enchantment 40 Increases the target's Mana Conversion skill by 25 points. +663 Mana Conversion Mastery Other V 5 Buff Other 51 ManaConversionRaising 200 1800 Creature Enchantment 50 Increases the target's Mana Conversion skill by 30 points. +664 Mana Conversion Mastery Other VI 6 Buff Other 51 ManaConversionRaising 250 2700 Creature Enchantment 60 Increases the target's Mana Conversion skill by 35 points. +665 Mana Conversion Ineptitude Self I 1 Debuff Self 52 ManaConversionLowering 1 60 Creature Enchantment 15 Decreases the caster's Mana Conversion skill by 10 points. +666 Vitae 1 Neutral Other 204 Vitae 30 -1 Creature Enchantment 3 Death sucks +667 Mana Conversion Ineptitude Self II 2 Debuff Self 52 ManaConversionLowering 75 90 Creature Enchantment 30 Decreases the caster's Mana Conversion skill by 15 points. +668 Mana Conversion Ineptitude Self III 3 Debuff Self 52 ManaConversionLowering 125 120 Creature Enchantment 40 Decreases the caster's Mana Conversion skill by 20 points. +669 Mana Conversion Ineptitude Self IV 4 Debuff Self 52 ManaConversionLowering 175 150 Creature Enchantment 50 Decreases the caster's Mana Conversion skill by 25 points. +670 Mana Conversion Ineptitude Self V 5 Debuff Self 52 ManaConversionLowering 225 180 Creature Enchantment 60 Decreases the caster's Mana Conversion skill by 30 points. +671 Mana Conversion Ineptitude Self VI 6 Debuff Self 52 ManaConversionLowering 275 210 Creature Enchantment 70 Decreases the caster's Mana Conversion skill by 35 points. +672 Mana Conversion Ineptitude Other I 1 Debuff Other 52 ManaConversionLowering 1 60 Creature Enchantment 10 Decreases the target's Mana Conversion skill by 10 points. +673 Mana Conversion Ineptitude Other II 2 Debuff Other 52 ManaConversionLowering 75 90 Creature Enchantment 20 Decreases the target's Mana Conversion skill by 15 points. +674 Mana Conversion Ineptitude Other III 3 Debuff Other 52 ManaConversionLowering 125 120 Creature Enchantment 30 Decreases the target's Mana Conversion skill by 20 points. +675 Mana Conversion Ineptitude Other IV 4 Debuff Other 52 ManaConversionLowering 175 150 Creature Enchantment 40 Decreases the target's Mana Conversion skill by 25 points. +676 Mana Conversion Ineptitude Other V 5 Debuff Other 52 ManaConversionLowering 225 180 Creature Enchantment 50 Decreases the target's Mana Conversion skill by 30 points. +677 Mana Conversion Ineptitude Other VI 6 Debuff Other 52 ManaConversionLowering 275 210 Creature Enchantment 60 Decreases the target's Mana Conversion skill by 35 points. +678 Arcane Enlightenment Self I 1 Buff Self 53 ArcaneLoreRaising 1 1800 Creature Enchantment 15 Increases the caster's Arcane Lore skill by 10 points. +679 Arcane Enlightenment Self II 2 Buff Self 53 ArcaneLoreRaising 50 1800 Creature Enchantment 30 Increases the caster's Arcane Lore skill by 15 points. +680 Arcane Enlightenment Self III 3 Buff Self 53 ArcaneLoreRaising 100 1800 Creature Enchantment 40 Increases the caster's Arcane Lore skill by 20 points. +681 Arcane Enlightenment Self IV 4 Buff Self 53 ArcaneLoreRaising 150 1800 Creature Enchantment 50 Increases the caster's Arcane Lore skill by 25 points. +682 Arcane Enlightenment Self V 5 Buff Self 53 ArcaneLoreRaising 200 1800 Creature Enchantment 60 Increases the caster's Arcane Lore skill by 30 points. +683 Arcane Enlightenment Self VI 6 Buff Self 53 ArcaneLoreRaising 250 2700 Creature Enchantment 70 Increases the caster's Arcane Lore skill by 35 points. +684 Arcane Enlightenment Other I 1 Buff Other 53 ArcaneLoreRaising 1 1800 Creature Enchantment 10 Increases the target's Arcane Lore skill by 10 points. +685 Arcane Enlightenment Other II 2 Buff Other 53 ArcaneLoreRaising 50 1800 Creature Enchantment 20 Increases the target's Arcane Lore skill by 15 points. +686 Arcane Enlightenment Other III 3 Buff Other 53 ArcaneLoreRaising 100 1800 Creature Enchantment 30 Increases the target's Arcane Lore skill by 20 points. +687 Arcane Enlightenment Other IV 4 Buff Other 53 ArcaneLoreRaising 150 1800 Creature Enchantment 40 Increases the target's Arcane Lore skill by 25 points. +688 Arcane Enlightenment Other V 5 Buff Other 53 ArcaneLoreRaising 225 1800 Creature Enchantment 50 Increases the target's Arcane Lore skill by 30 points. +689 Arcane Enlightenment Other VI 6 Buff Other 53 ArcaneLoreRaising 250 2700 Creature Enchantment 60 Increases the target's Arcane Lore skill by 35 points. +690 Arcane Benightedness Self I 1 Debuff Self 54 ArcaneLoreLowering 1 60 Creature Enchantment 15 Decreases the caster's Arcane Lore skill by 10 points. +691 Arcane Benightedness Self II 2 Debuff Self 54 ArcaneLoreLowering 75 90 Creature Enchantment 30 Decreases the caster's Arcane Lore skill by 15 points. +692 Arcane Benightedness Self III 3 Debuff Self 54 ArcaneLoreLowering 125 120 Creature Enchantment 40 Decreases the caster's Arcane Lore skill by 20 points. +693 Arcane Benightedness Self IV 4 Debuff Self 54 ArcaneLoreLowering 175 150 Creature Enchantment 50 Decreases the caster's Arcane Lore skill by 25 points. +694 Arcane Benightedness Self V 5 Debuff Self 54 ArcaneLoreLowering 225 180 Creature Enchantment 60 Decreases the caster's Arcane Lore skill by 30 points. +695 Arcane Benightedness Self VI 6 Debuff Self 54 ArcaneLoreLowering 275 210 Creature Enchantment 70 Decreases the caster's Arcane Lore skill by 35 points. +696 Arcane Benightedness Other I 1 Debuff Other 54 ArcaneLoreLowering 1 60 Creature Enchantment 10 Decreases the target's Arcane Lore skill by 10 points. +697 Arcane Benightedness Other II 2 Debuff Other 54 ArcaneLoreLowering 75 90 Creature Enchantment 20 Decreases the target's Arcane Lore skill by 15 points. +698 Arcane Benightedness Other III 3 Debuff Other 54 ArcaneLoreLowering 125 120 Creature Enchantment 30 Decreases the target's Arcane Lore skill by 20 points. +699 Arcane Benightedness Other IV 4 Debuff Other 54 ArcaneLoreLowering 175 150 Creature Enchantment 40 Decreases the target's Arcane Lore skill by 25 points. +700 Arcane Benightedness Other V 5 Debuff Other 54 ArcaneLoreLowering 225 180 Creature Enchantment 50 Decreases the target's Arcane Lore skill by 30 points. +701 Arcane Benightedness Other VI 6 Debuff Other 54 ArcaneLoreLowering 275 210 Creature Enchantment 60 Decreases the target's Arcane Lore skill by 35 points. +702 Armor Tinkering Expertise Self I 1 Buff Self 55 AppraiseArmorRaising 1 1800 Creature Enchantment 15 Increases the caster's Armor Tinkering skill by 10 points. +703 Armor Tinkering Expertise Self II 2 Buff Self 55 AppraiseArmorRaising 50 1800 Creature Enchantment 30 Increases the caster's Armor Tinkering skill by 15 points. +704 Armor Tinkering Expertise Self III 3 Buff Self 55 AppraiseArmorRaising 100 1800 Creature Enchantment 40 Increases the caster's Armor Tinkering skill by 20 points. +705 Armor Tinkering Expertise Self IV 4 Buff Self 55 AppraiseArmorRaising 150 1800 Creature Enchantment 50 Increases the caster's Armor Tinkering skill by 25 points. +706 Armor Tinkering Expertise Self V 5 Buff Self 55 AppraiseArmorRaising 200 1800 Creature Enchantment 60 Increases the caster's Armor Tinkering skill by 30 points. +707 Armor Tinkering Expertise Self VI 6 Buff Self 55 AppraiseArmorRaising 250 2700 Creature Enchantment 70 Increases the caster's Armor Tinkering skill by 35 points. +708 Armor Tinkering Expertise Other I 1 Buff Other 55 AppraiseArmorRaising 1 1800 Creature Enchantment 10 Increases the target's Armor Tinkering skill by 10 points. +709 Armor Tinkering Expertise Other II 2 Buff Other 55 AppraiseArmorRaising 50 1800 Creature Enchantment 20 Increases the target's Armor Tinkering skill by 15 points. +710 Armor Tinkering Expertise Other III 3 Buff Other 55 AppraiseArmorRaising 100 1800 Creature Enchantment 30 Increases the target's Armor Tinkering skill by 20 points. +711 Armor Tinkering Expertise Other IV 4 Buff Other 55 AppraiseArmorRaising 150 1800 Creature Enchantment 40 Increases the target's Armor Tinkering skill by 25 points. +712 Armor Tinkering Expertise Other V 5 Buff Other 55 AppraiseArmorRaising 200 1800 Creature Enchantment 50 Increases the target's Armor Tinkering skill by 30 points. +713 Armor Tinkering Expertise Other VI 6 Buff Other 55 AppraiseArmorRaising 250 2700 Creature Enchantment 60 Increases the target's Armor Tinkering skill by 35 points. +714 Armor Tinkering Ignorance Self I 1 Debuff Self 56 AppraiseArmorLowering 1 60 Creature Enchantment 15 Decreases the caster's Armor Tinkering skill by 10 points. +715 Armor Tinkering Ignorance Self II 2 Debuff Self 56 AppraiseArmorLowering 75 90 Creature Enchantment 30 Decreases the caster's Armor Tinkering skill by 15 points. +716 Armor Tinkering Ignorance Self III 3 Debuff Self 56 AppraiseArmorLowering 125 120 Creature Enchantment 40 Decreases the caster's Armor Tinkering skill by 20 points. +717 Armor Tinkering Ignorance Self IV 4 Debuff Self 56 AppraiseArmorLowering 175 150 Creature Enchantment 50 Decreases the caster's Armor Tinkering skill by 25 points. +718 Armor Tinkering Ignorance Self V 5 Debuff Self 56 AppraiseArmorLowering 225 180 Creature Enchantment 60 Decreases the caster's Armor Tinkering skill by 30 points. +719 Armor Tinkering Ignorance Self VI 6 Debuff Self 56 AppraiseArmorLowering 275 210 Creature Enchantment 70 Decreases the caster's Armor Tinkering skill by 35 points. +720 Armor Tinkering Ignorance Other I 1 Debuff Other 56 AppraiseArmorLowering 1 60 Creature Enchantment 10 Decreases the target's Armor Tinkering skill by 10 points. +721 Armor Tinkering Ignorance Other II 2 Debuff Other 56 AppraiseArmorLowering 75 90 Creature Enchantment 20 Decreases the target's Armor Tinkering skill by 15 points. +722 Armor Tinkering Ignorance Other III 3 Debuff Other 56 AppraiseArmorLowering 125 120 Creature Enchantment 30 Decreases the target's Armor Tinkering skill by 20 points. +723 Armor Tinkering Ignorance Other IV 4 Debuff Other 56 AppraiseArmorLowering 175 150 Creature Enchantment 40 Decreases the target's Armor Tinkering skill by 25 points. +724 Armor Tinkering Ignorance Other V 5 Debuff Other 56 AppraiseArmorLowering 225 180 Creature Enchantment 50 Decreases the target's Armor Tinkering skill by 30 points. +725 Armor Tinkering Ignorance Other VI 6 Debuff Other 56 AppraiseArmorLowering 275 210 Creature Enchantment 60 Decreases the target's Armor Tinkering skill by 35 points. +726 Item Tinkering Expertise Self I 1 Buff Self 57 AppraiseItemRaising 1 1800 Creature Enchantment 15 Increases the caster's Item Tinkering skill by 10 points. +727 Item Tinkering Expertise Self II 2 Buff Self 57 AppraiseItemRaising 50 1800 Creature Enchantment 30 Increases the caster's Item Tinkering skill by 15 points. +728 Item Tinkering Expertise Self III 3 Buff Self 57 AppraiseItemRaising 100 1800 Creature Enchantment 40 Increases the caster's Item Tinkering skill by 20 points. +729 Item Tinkering Expertise Self IV 4 Buff Self 57 AppraiseItemRaising 150 1800 Creature Enchantment 50 Increases the caster's Item Tinkering skill by 25 points. +730 Item Tinkering Expertise Self V 5 Buff Self 57 AppraiseItemRaising 200 1800 Creature Enchantment 60 Increases the caster's Item Tinkering skill by 30 points. +731 Item Tinkering Expertise Self VI 6 Buff Self 57 AppraiseItemRaising 250 2700 Creature Enchantment 70 Increases the caster's Item Tinkering skill by 35 points. +732 Item Tinkering Expertise Other I 1 Buff Other 57 AppraiseItemRaising 1 1800 Creature Enchantment 10 Increases the target's Item Tinkering skill by 10 points. +733 Item Tinkering Expertise Other II 2 Buff Other 57 AppraiseItemRaising 50 1800 Creature Enchantment 20 Increases the target's Item Tinkering skill by 15 points. +734 Item Tinkering Expertise Other III 3 Buff Other 57 AppraiseItemRaising 100 1800 Creature Enchantment 30 Increases the target's Item Tinkering skill by 20 points. +735 Item Tinkering Expertise Other IV 4 Buff Other 57 AppraiseItemRaising 150 1800 Creature Enchantment 40 Increases the target's Item Tinkering skill by 25 points. +736 Item Tinkering Expertise Other V 5 Buff Other 57 AppraiseItemRaising 200 1800 Creature Enchantment 50 Increases the target's Item Tinkering skill by 30 points. +737 Item Tinkering Expertise Other VI 6 Buff Other 57 AppraiseItemRaising 250 2700 Creature Enchantment 60 Increases the target's Item Tinkering skill by 35 points. +738 Item Tinkering Ignorance Self I 1 Debuff Self 58 AppraiseItemLowering 1 60 Creature Enchantment 15 Decreases the caster's Item Tinkering skill by 10 points. +739 Item Tinkering Ignorance Self II 2 Debuff Self 58 AppraiseItemLowering 75 90 Creature Enchantment 30 Decreases the caster's Item Tinkering skill by 15 points. +740 Item Tinkering Ignorance Self III 3 Debuff Self 58 AppraiseItemLowering 125 120 Creature Enchantment 40 Decreases the caster's Item Tinkering skill by 20 points. +741 Item Tinkering Ignorance Self IV 4 Debuff Self 58 AppraiseItemLowering 175 150 Creature Enchantment 50 Decreases the caster's Item Tinkering skill by 25 points. +742 Item Tinkering Ignorance Self V 5 Debuff Self 58 AppraiseItemLowering 225 180 Creature Enchantment 60 Decreases the caster's Item Tinkering skill by 30 points. +743 Item Tinkering Ignorance Self VI 6 Debuff Self 58 AppraiseItemLowering 275 210 Creature Enchantment 70 Decreases the caster's Item Tinkering skill by 35 points. +744 Item Tinkering Ignorance Other I 1 Debuff Other 58 AppraiseItemLowering 1 60 Creature Enchantment 10 Decreases the target's Item Tinkering skill by 10 points. +745 Item Tinkering Ignorance Other II 2 Debuff Other 58 AppraiseItemLowering 75 90 Creature Enchantment 20 Decreases the target's Item Tinkering skill by 15 points. +746 Item Tinkering Ignorance Other III 3 Debuff Other 58 AppraiseItemLowering 125 120 Creature Enchantment 30 Decreases the target's Item Tinkering skill by 20 points. +747 Item Tinkering Ignorance Other IV 4 Debuff Other 58 AppraiseItemLowering 175 150 Creature Enchantment 40 Decreases the target's Item Tinkering skill by 25 points. +748 Item Tinkering Ignorance Other V 5 Debuff Other 58 AppraiseItemLowering 225 180 Creature Enchantment 50 Decreases the target's Item Tinkering skill by 30 points. +749 Item Tinkering Ignorance Other VI 6 Debuff Other 58 AppraiseItemLowering 275 210 Creature Enchantment 60 Decreases the target's Item Tinkering skill by 35 points. +750 Magic Item Tinkering Expertise Self I 1 Buff Self 59 AppraiseMagicItemRaising 1 1800 Creature Enchantment 15 Increases the caster's Magic Item Tinkering skill by 10 points. +751 Magic Item Tinkering Expertise Self II 2 Buff Self 59 AppraiseMagicItemRaising 50 1800 Creature Enchantment 30 Increases the caster's Magic Item Tinkering skill by 15 points. +752 Magic Item Tinkering Expertise Self III 3 Buff Self 59 AppraiseMagicItemRaising 100 1800 Creature Enchantment 40 Increases the caster's Magic Item Tinkering skill by 20 points. +753 Magic Item Tinkering Expertise Self IV 4 Buff Self 59 AppraiseMagicItemRaising 150 1800 Creature Enchantment 50 Increases the caster's Magic Item Tinkering skill by 25 points. +754 Magic Item Tinkering Expertise Self V 5 Buff Self 59 AppraiseMagicItemRaising 200 1800 Creature Enchantment 60 Increases the caster's Magic Item Tinkering skill by 30 points. +755 Magic Item Tinkering Expertise Self VI 6 Buff Self 59 AppraiseMagicItemRaising 250 2700 Creature Enchantment 70 Increases the caster's Magic Item Tinkering skill by 35 points. +756 Magic Item Tinkering Expertise Other I 1 Buff Other 59 AppraiseMagicItemRaising 1 1800 Creature Enchantment 10 Increases the target's Magic Item Tinkering skill by 10 points. +757 Magic Item Tinkering Expertise Other II 2 Buff Other 59 AppraiseMagicItemRaising 50 1800 Creature Enchantment 20 Increases the target's Magic Item Tinkering skill by 15 points. +758 Magic Item Tinkering Expertise Other III 2 Buff Other 59 AppraiseMagicItemRaising 75 1800 Creature Enchantment 30 Increases the target's Magic Item Tinkering skill by 20 points. +759 Magic Item Tinkering Expertise Other IV 3 Buff Other 59 AppraiseMagicItemRaising 125 1800 Creature Enchantment 40 Increases the target's Magic Item Tinkering skill by 25 points. +760 Magic Item Tinkering Expertise Other V 5 Buff Other 59 AppraiseMagicItemRaising 200 1800 Creature Enchantment 50 Increases the target's Magic Item Tinkering skill by 30 points. +761 Magic Item Tinkering Expertise Other VI 6 Buff Other 59 AppraiseMagicItemRaising 250 2700 Creature Enchantment 60 Increases the target's Magic Item Tinkering skill by 35 points. +762 Magic Item Tinkering Ignorance Self I 1 Debuff Self 60 AppraiseMagicItemLowering 1 60 Creature Enchantment 15 Decreases the caster's Magic Item Tinkering skill by 10 points. +763 Magic Item Tinkering Ignorance Self II 2 Debuff Self 60 AppraiseMagicItemLowering 75 90 Creature Enchantment 30 Decreases the caster's Magic Item Tinkering skill by 15 points. +764 Magic Item Tinkering Ignorance Self III 3 Debuff Self 60 AppraiseMagicItemLowering 125 120 Creature Enchantment 40 Decreases the caster's Magic Item Tinkering skill by 20 points. +765 Magic Item Tinkering Ignorance Self IV 4 Debuff Self 60 AppraiseMagicItemLowering 175 150 Creature Enchantment 50 Decreases the caster's Magic Item Tinkering skill by 25 points. +766 Magic Item Tinkering Ignorance Self V 5 Debuff Self 60 AppraiseMagicItemLowering 225 180 Creature Enchantment 60 Decreases the caster's Magic Item Tinkering skill by 30 points. +767 Magic Item Tinkering Ignorance Self VI 6 Debuff Self 60 AppraiseMagicItemLowering 275 210 Creature Enchantment 70 Decreases the caster's Magic Item Tinkering skill by 35 points. +768 Magic Item Tinkering Ignorance Other I 1 Debuff Other 60 AppraiseMagicItemLowering 1 60 Creature Enchantment 10 Decreases the target's Magic Item Tinkering skill by 10 points. +769 Magic Item Tinkering Ignorance Other II 2 Debuff Other 60 AppraiseMagicItemLowering 75 90 Creature Enchantment 20 Decreases the target's Magic Item Tinkering skill by 15 points. +770 Magic Item Tinkering Ignorance Other III 3 Debuff Other 60 AppraiseMagicItemLowering 125 120 Creature Enchantment 30 Decreases the target's Magic Item Tinkering skill by 20 points. +771 Magic Item Tinkering Ignorance Other IV 4 Debuff Other 60 AppraiseMagicItemLowering 175 150 Creature Enchantment 40 Decreases the target's Magic Item Tinkering skill by 25 points. +772 Magic Item Tinkering Ignorance Other V 5 Debuff Other 60 AppraiseMagicItemLowering 225 180 Creature Enchantment 50 Decreases the target's Magic Item Tinkering skill by 30 points. +773 Magic Item Tinkering Ignorance Other VI 6 Debuff Other 60 AppraiseMagicItemLowering 275 210 Creature Enchantment 60 Decreases the target's Magic Item Tinkering skill by 35 points. +774 Weapon Tinkering Expertise Self I 1 Buff Self 61 AppraiseWeaponRaising 1 1800 Creature Enchantment 15 Increases the caster's Weapon Tinkering skill by 10 points. +775 Weapon Tinkering Expertise Self II 2 Buff Self 61 AppraiseWeaponRaising 50 1800 Creature Enchantment 30 Increases the caster's Weapon Tinkering skill by 15 points. +776 Weapon Tinkering Expertise Self III 3 Buff Self 61 AppraiseWeaponRaising 100 1800 Creature Enchantment 40 Increases the caster's Weapon Tinkering skill by 20 points. +777 Weapon Tinkering Expertise Self IV 4 Buff Self 61 AppraiseWeaponRaising 150 1800 Creature Enchantment 50 Increases the caster's Weapon Tinkering skill by 25 points. +778 Weapon Tinkering Expertise Self V 5 Buff Self 61 AppraiseWeaponRaising 200 1800 Creature Enchantment 60 Increases the caster's Weapon Tinkering skill by 30 points. +779 Weapon Tinkering Expertise Self VI 6 Buff Self 61 AppraiseWeaponRaising 250 2700 Creature Enchantment 70 Increases the caster's Weapon Tinkering skill by 35 points. +780 Weapon Tinkering Expertise Other I 1 Buff Other 61 AppraiseWeaponRaising 1 1800 Creature Enchantment 10 Increases the target's Weapon Tinkering skill by 10 points. +781 Weapon Tinkering Expertise Other II 2 Buff Other 61 AppraiseWeaponRaising 50 1800 Creature Enchantment 20 Increases the target's Weapon Tinkering skill by 15 points. +782 Weapon Tinkering Expertise Other III 3 Buff Other 61 AppraiseWeaponRaising 100 1800 Creature Enchantment 30 Increases the target's Weapon Tinkering skill by 20 points. +783 Weapon Tinkering Expertise Other IV 4 Buff Other 61 AppraiseWeaponRaising 150 1800 Creature Enchantment 40 Increases the target's Weapon Tinkering skill by 25 points. +784 Weapon Tinkering Expertise Other V 5 Buff Other 61 AppraiseWeaponRaising 200 1800 Creature Enchantment 50 Increases the target's Weapon Tinkering skill by 30 points. +785 Weapon Tinkering Expertise Other VI 6 Buff Other 61 AppraiseWeaponRaising 250 2700 Creature Enchantment 60 Increases the target's Weapon Tinkering skill by 35 points. +786 Weapon Tinkering Ignorance Self I 1 Debuff Self 62 AppraiseWeaponLowering 1 60 Creature Enchantment 15 Decreases the caster's Weapon Tinkering skill by 10 points. +787 Weapon Tinkering Ignorance Self II 2 Debuff Self 62 AppraiseWeaponLowering 75 90 Creature Enchantment 30 Decreases the caster's Weapon Tinkering skill by 15 points. +788 Weapon Tinkering Ignorance Self III 3 Debuff Self 62 AppraiseWeaponLowering 125 120 Creature Enchantment 40 Decreases the caster's Weapon Tinkering skill by 20 points. +789 Weapon Tinkering Ignorance Self IV 4 Debuff Self 62 AppraiseWeaponLowering 175 150 Creature Enchantment 50 Decreases the caster's Weapon Tinkering skill by 25 points. +790 Weapon Tinkering Ignorance Self V 5 Debuff Self 62 AppraiseWeaponLowering 225 180 Creature Enchantment 60 Decreases the caster's Weapon Tinkering skill by 30 points. +791 Weapon Tinkering Ignorance Self VI 6 Debuff Self 62 AppraiseWeaponLowering 275 210 Creature Enchantment 70 Decreases the caster's Weapon Tinkering skill by 35 points. +792 Weapon Tinkering Ignorance Other I 1 Debuff Other 62 AppraiseWeaponLowering 1 60 Creature Enchantment 10 Decreases the target's Weapon Tinkering skill by 10 points. +793 Weapon Tinkering Ignorance Other II 2 Debuff Other 62 AppraiseWeaponLowering 75 90 Creature Enchantment 20 Decreases the target's Weapon Tinkering skill by 15 points. +794 Weapon Tinkering Ignorance Other III 3 Debuff Other 62 AppraiseWeaponLowering 125 120 Creature Enchantment 30 Decreases the target's Weapon Tinkering skill by 20 points. +795 Weapon Tinkering Ignorance Other IV 4 Debuff Other 62 AppraiseWeaponLowering 175 150 Creature Enchantment 40 Decreases the target's Weapon Tinkering skill by 25 points. +796 Weapon Tinkering Ignorance Other V 5 Debuff Other 62 AppraiseWeaponLowering 225 180 Creature Enchantment 50 Decreases the target's Weapon Tinkering skill by 30 points. +797 Weapon Tinkering Ignorance Other VI 6 Debuff Other 62 AppraiseWeaponLowering 275 210 Creature Enchantment 60 Decreases the target's Weapon Tinkering skill by 35 points. +798 Monster Attunement Self I 1 Buff Self 63 AssessMonsterRaising 1 1800 Creature Enchantment 15 Increases the caster's Assess Monster skill by 10 points. +799 Monster Attunement Self II 2 Buff Self 63 AssessMonsterRaising 50 1800 Creature Enchantment 30 Increases the caster's Assess Monster skill by 15 points. +800 Monster Attunement Self III 3 Buff Self 63 AssessMonsterRaising 100 1800 Creature Enchantment 40 Increases the caster's Assess Monster skill by 20 points. +801 Monster Attunement Self IV 4 Buff Self 63 AssessMonsterRaising 150 1800 Creature Enchantment 50 Increases the caster's Assess Monster skill by 25 points. +802 Monster Attunement Self V 5 Buff Self 63 AssessMonsterRaising 200 1800 Creature Enchantment 60 Increases the caster's Assess Monster skill by 30 points. +803 Monster Attunement Self VI 6 Buff Self 63 AssessMonsterRaising 250 2700 Creature Enchantment 70 Increases the caster's Assess Monster skill by 35 points. +804 Monster Attunement Other I 1 Buff Other 63 AssessMonsterRaising 1 1800 Creature Enchantment 10 Increases the target's Assess Monster skill by 10 points. +805 Monster Attunement Other II 2 Buff Other 63 AssessMonsterRaising 50 1800 Creature Enchantment 20 Increases the target's Assess Monster skill by 15 points. +806 Monster Attunement Other III 3 Buff Other 63 AssessMonsterRaising 100 1800 Creature Enchantment 30 Increases the target's Assess Monster skill by 20 points. +807 Monster Attunement Other IV 4 Buff Other 63 AssessMonsterRaising 150 1800 Creature Enchantment 40 Increases the target's Assess Monster skill by 25 points. +808 Monster Attunement Other V 5 Buff Other 63 AssessMonsterRaising 200 1800 Creature Enchantment 50 Increases the target's Assess Monster skill by 30 points. +809 Monster Attunement Other VI 6 Buff Other 63 AssessMonsterRaising 250 2700 Creature Enchantment 60 Increases the target's Assess Monster skill by 35 points. +810 Fire Protection Other II 2 Buff Other 109 FireProtection 50 1800 Life Magic 20 Reduces damage the target takes from fire by 20%. +811 Monster Unfamiliarity Self I 1 Debuff Self 64 AssessMonsterLowering 1 60 Creature Enchantment 15 Decreases the caster's Assess Monster skill by 10 points. +812 Monster Unfamiliarity Self II 2 Debuff Self 64 AssessMonsterLowering 75 90 Creature Enchantment 30 Decreases the caster's Assess Monster skill by 15 points. +813 Monster Unfamiliarity Self III 3 Debuff Self 64 AssessMonsterLowering 125 120 Creature Enchantment 40 Decreases the caster's Assess Monster skill by 20 points. +814 Monster Unfamiliarity Self IV 4 Debuff Self 64 AssessMonsterLowering 175 150 Creature Enchantment 50 Decreases the caster's Assess Monster skill by 25 points. +815 Monster Unfamiliarity Self V 5 Debuff Self 64 AssessMonsterLowering 225 180 Creature Enchantment 60 Decreases the caster's Assess Monster skill by 30 points. +816 Monster Unfamiliarity Self VI 6 Debuff Self 64 AssessMonsterLowering 275 210 Creature Enchantment 70 Decreases the caster's Assess Monster skill by 35 points. +817 Monster Unfamiliarity Other I 1 Debuff Other 64 AssessMonsterLowering 1 60 Creature Enchantment 10 Decreases the target's Assess Monster skill by 10 points. +818 Monster Unfamiliarity Other II 2 Debuff Other 64 AssessMonsterLowering 75 90 Creature Enchantment 20 Decreases the target's Assess Monster skill by 15 points. +819 Monster Unfamiliarity Other III 3 Debuff Other 64 AssessMonsterLowering 125 120 Creature Enchantment 30 Decreases the target's Assess Monster skill by 20 points. +820 Monster Unfamiliarity Other IV 4 Debuff Other 64 AssessMonsterLowering 175 150 Creature Enchantment 40 Decreases the target's Assess Monster skill by 25 points. +821 Monster Unfamiliarity Other V 5 Debuff Other 64 AssessMonsterLowering 225 180 Creature Enchantment 50 Decreases the target's Assess Monster skill by 30 points. +822 Monster Unfamiliarity Other VI 6 Debuff Other 64 AssessMonsterLowering 275 210 Creature Enchantment 60 Decreases the target's Assess Monster skill by 35 points. +824 Person Attunement Self I 1 Buff Self 205 AssessPersonRaising 1 1800 Creature Enchantment 15 Increases the caster's Assess Person skill by 10 points. +825 Person Attunement Self II 2 Buff Self 205 AssessPersonRaising 50 1800 Creature Enchantment 30 Increases the caster's Assess Person skill by 15 points. +826 Person Attunement Self III 3 Buff Self 205 AssessPersonRaising 100 1800 Creature Enchantment 40 Increases the caster's Assess Person skill by 20 points. +827 Person Attunement Self IV 4 Buff Self 205 AssessPersonRaising 150 1800 Creature Enchantment 50 Increases the caster's Assess Person skill by 25 points. +828 Person Attunement Self V 5 Buff Self 205 AssessPersonRaising 200 1800 Creature Enchantment 60 Increases the caster's Assess Person skill by 30 points. +829 Person Attunement Self VI 6 Buff Self 205 AssessPersonRaising 250 2700 Creature Enchantment 70 Increases the caster's Assess Person skill by 35 points. +830 Person Attunement Other I 1 Buff Other 205 AssessPersonRaising 1 1800 Creature Enchantment 10 Increases the target's Assess Person skill by 10 points. +831 Person Attunement Other II 2 Buff Other 205 AssessPersonRaising 50 1800 Creature Enchantment 20 Increases the target's Assess Person skill by 15 points. +832 Person Attunement Other III 3 Buff Other 205 AssessPersonRaising 100 1800 Creature Enchantment 30 Increases the target's Assess Person skill by 20 points. +833 Person Attunement Other IV 4 Buff Other 205 AssessPersonRaising 150 1800 Creature Enchantment 40 Increases the target's Assess Person skill by 25 points. +834 Person Attunement Other V 5 Buff Other 205 AssessPersonRaising 200 1800 Creature Enchantment 50 Increases the target's Assess Person skill by 30 points. +835 Person Attunement Other VI 6 Buff Other 205 AssessPersonRaising 250 2700 Creature Enchantment 60 Increases the target's Assess Person skill by 35 points. +836 Fire Protection Other III 3 Buff Other 109 FireProtection 100 1800 Life Magic 30 Reduces damage the target takes from fire by 33%. +837 Person Unfamiliarity Self I 1 Debuff Self 206 AssessPersonLowering 1 60 Creature Enchantment 15 Decreases the caster's Assess Person skill by 10 points. +838 Person Unfamiliarity Self II 2 Debuff Self 206 AssessPersonLowering 75 90 Creature Enchantment 30 Decreases the caster's Assess Person skill by 15 points. +839 Person Unfamiliarity Self III 3 Debuff Self 206 AssessPersonLowering 125 120 Creature Enchantment 40 Decreases the caster's Assess Person skill by 20 points. +840 Person Unfamiliarity Self IV 4 Debuff Self 206 AssessPersonLowering 175 150 Creature Enchantment 50 Decreases the caster's Assess Person skill by 25 points. +841 Person Unfamiliarity Self V 5 Debuff Self 206 AssessPersonLowering 225 180 Creature Enchantment 60 Decreases the caster's Assess Person skill by 30 points. +842 Person Unfamiliarity Self VI 6 Debuff Self 206 AssessPersonLowering 275 210 Creature Enchantment 70 Decreases the caster's Assess Person skill by 35 points. +843 Person Unfamiliarity Other I 1 Debuff Other 206 AssessPersonLowering 1 60 Creature Enchantment 10 Decreases the target's Assess Person skill by 10 points. +844 Person Unfamiliarity Other II 2 Debuff Other 206 AssessPersonLowering 75 90 Creature Enchantment 20 Decreases the target's Assess Person skill by 15 points. +845 Person Unfamiliarity Other III 3 Debuff Other 206 AssessPersonLowering 125 120 Creature Enchantment 30 Decreases the target's Assess Person skill by 20 points. +846 Person Unfamiliarity Other IV 4 Debuff Other 206 AssessPersonLowering 175 150 Creature Enchantment 40 Decreases the target's Assess Person skill by 25 points. +847 Person Unfamiliarity Other V 5 Debuff Other 206 AssessPersonLowering 225 180 Creature Enchantment 50 Decreases the target's Assess Person skill by 30 points. +848 Person Unfamiliarity Other VI 6 Debuff Other 206 AssessPersonLowering 275 210 Creature Enchantment 60 Decreases the target's Assess Person skill by 35 points. +849 Fire Protection Other IV 4 Buff Other 109 FireProtection 150 1800 Life Magic 40 Reduces damage the target takes from fire by 43%. +850 Deception Mastery Self I 1 Buff Self 65 DeceptionRaising 1 1800 Creature Enchantment 15 Increases the caster's Deception skill by 10 points. +851 Deception Mastery Self II 2 Buff Self 65 DeceptionRaising 50 1800 Creature Enchantment 30 Increases the caster's Deception skill by 15 points. +852 Deception Mastery Self III 3 Buff Self 65 DeceptionRaising 100 1800 Creature Enchantment 40 Increases the caster's Deception skill by 20 points. +853 Deception Mastery Self IV 4 Buff Self 65 DeceptionRaising 150 1800 Creature Enchantment 50 Increases the caster's Deception skill by 25 points. +854 Deception Mastery Self V 5 Buff Self 65 DeceptionRaising 200 1800 Creature Enchantment 60 Increases the caster's Deception skill by 30 points. +855 Deception Mastery Self VI 6 Buff Self 65 DeceptionRaising 250 2700 Creature Enchantment 70 Increases the caster's Deception skill by 35 points. +856 Deception Mastery Other I 1 Buff Other 65 DeceptionRaising 1 1800 Creature Enchantment 10 Increases the target's Deception skill by 10 points. +857 Deception Mastery Other II 2 Buff Other 65 DeceptionRaising 50 1800 Creature Enchantment 20 Increases the target's Deception skill by 15 points. +858 Deception Mastery Other III 3 Buff Other 65 DeceptionRaising 100 1800 Creature Enchantment 30 Increases the target's Deception skill by 20 points. +859 Deception Mastery Other IV 4 Buff Other 65 DeceptionRaising 150 1800 Creature Enchantment 40 Increases the target's Deception skill by 25 points. +860 Deception Mastery Other V 5 Buff Other 65 DeceptionRaising 200 1800 Creature Enchantment 50 Increases the target's Deception skill by 30 points. +861 Deception Mastery Other VI 6 Buff Other 65 DeceptionRaising 250 2700 Creature Enchantment 60 Increases the target's Deception skill by 35 points. +862 Deception Ineptitude Self I 1 Debuff Self 66 DeceptionLowering 1 60 Creature Enchantment 15 Decreases the caster's Deception skill by 10 points. +863 Deception Ineptitude Self II 2 Debuff Self 66 DeceptionLowering 75 90 Creature Enchantment 30 Decreases the caster's Deception skill by 15 points. +864 Deception Ineptitude Self III 3 Debuff Self 66 DeceptionLowering 125 120 Creature Enchantment 40 Decreases the caster's Deception skill by 20 points. +865 Deception Ineptitude Self IV 4 Debuff Self 66 DeceptionLowering 175 150 Creature Enchantment 50 Decreases the caster's Deception skill by 25 points. +866 Deception Ineptitude Self V 5 Debuff Self 66 DeceptionLowering 225 180 Creature Enchantment 60 Decreases the caster's Deception skill by 30 points. +867 Deception Ineptitude Self VI 6 Debuff Self 66 DeceptionLowering 275 210 Creature Enchantment 70 Decreases the caster's Deception skill by 35 points. +868 Deception Ineptitude Other I 1 Debuff Other 66 DeceptionLowering 1 60 Creature Enchantment 10 Decreases the target's Deception skill by 10 points. +869 Deception Ineptitude Other II 2 Debuff Other 66 DeceptionLowering 75 90 Creature Enchantment 20 Decreases the target's Deception skill by 15 points. +870 Deception Ineptitude Other III 3 Debuff Other 66 DeceptionLowering 125 120 Creature Enchantment 30 Decreases the target's Deception skill by 20 points. +871 Deception Ineptitude Other IV 4 Debuff Other 66 DeceptionLowering 175 150 Creature Enchantment 40 Decreases the target's Deception skill by 25 points. +872 Deception Ineptitude Other V 5 Debuff Other 66 DeceptionLowering 225 180 Creature Enchantment 50 Decreases the target's Deception skill by 30 points. +873 Deception Ineptitude Other VI 6 Debuff Other 66 DeceptionLowering 275 210 Creature Enchantment 60 Decreases the target's Deception skill by 35 points. +874 Healing Mastery Self I 1 Heal Self 67 HealingRaising 1 1800 Creature Enchantment 15 Increases the caster's Healing skill by 10 points. +875 Healing Mastery Self II 2 Heal Self 67 HealingRaising 50 1800 Creature Enchantment 30 Increases the caster's Healing skill by 15 points. +876 Healing Mastery Self III 3 Heal Self 67 HealingRaising 100 1800 Creature Enchantment 40 Increases the caster's Healing skill by 20 points. +877 Healing Mastery Self IV 4 Heal Self 67 HealingRaising 150 1800 Creature Enchantment 50 Increases the caster's Healing skill by 25 points. +878 Healing Mastery Self V 5 Heal Self 67 HealingRaising 200 1800 Creature Enchantment 60 Increases the caster's Healing skill by 30 points. +879 Healing Mastery Self VI 6 Heal Self 67 HealingRaising 250 2700 Creature Enchantment 70 Increases the caster's Healing skill by 35 points. +880 Healing Mastery Other I 1 Heal Other 67 HealingRaising 1 1800 Creature Enchantment 10 Increases the target's Healing skill by 10 points. +881 Healing Mastery Other II 2 Heal Other 67 HealingRaising 50 1800 Creature Enchantment 20 Increases the target's Healing skill by 15 points. +882 Healing Mastery Other III 3 Heal Other 67 HealingRaising 100 1800 Creature Enchantment 30 Increases the target's Healing skill by 20 points. +883 Healing Mastery Other IV 4 Heal Other 67 HealingRaising 150 1800 Creature Enchantment 40 Increases the target's Healing skill by 25 points. +884 Healing Mastery Other V 5 Heal Other 67 HealingRaising 200 1800 Creature Enchantment 50 Increases the target's Healing skill by 30 points. +885 Healing Mastery Other VI 6 Heal Other 67 HealingRaising 250 2700 Creature Enchantment 60 Increases the target's Healing skill by 35 points. +886 Healing Ineptitude Self I 1 Heal Self 68 HealingLowering 1 60 Creature Enchantment 15 Decreases the caster's Healing skill by 10 points. +887 Healing Ineptitude Self II 2 Heal Self 68 HealingLowering 75 90 Creature Enchantment 30 Decreases the caster's Healing skill by 15 points. +888 Healing Ineptitude Self III 3 Heal Self 68 HealingLowering 125 120 Creature Enchantment 40 Decreases the caster's Healing skill by 20 points. +889 Healing Ineptitude Self IV 4 Heal Self 68 HealingLowering 175 150 Creature Enchantment 50 Decreases the caster's Healing skill by 25 points. +890 Healing Ineptitude Self V 5 Heal Self 68 HealingLowering 225 180 Creature Enchantment 60 Decreases the caster's Healing skill by 30 points. +891 Healing Ineptitude Self VI 6 Heal Self 68 HealingLowering 275 210 Creature Enchantment 70 Decreases the caster's Healing skill by 35 points. +892 Healing Ineptitude Other I 1 Heal Other 68 HealingLowering 1 60 Creature Enchantment 10 Decreases the target's Healing skill by 10 points. +893 Healing Ineptitude Other II 2 Heal Other 68 HealingLowering 75 90 Creature Enchantment 20 Decreases the target's Healing skill by 15 points. +894 Healing Ineptitude Other III 3 Heal Other 68 HealingLowering 125 120 Creature Enchantment 30 Decreases the target's Healing skill by 20 points. +895 Healing Ineptitude Other IV 4 Heal Other 68 HealingLowering 175 150 Creature Enchantment 40 Decreases the target's Healing skill by 25 points. +896 Healing Ineptitude Other V 5 Heal Other 68 HealingLowering 225 180 Creature Enchantment 50 Decreases the target's Healing skill by 30 points. +897 Healing Ineptitude Other VI 6 Heal Other 68 HealingLowering 275 210 Creature Enchantment 60 Decreases the target's Healing skill by 35 points. +898 Leadership Mastery Self I 1 Buff Self 71 LeadershipRaising 1 1800 Creature Enchantment 15 Increases the caster's Leadership skill by 10 points. +899 Leadership Mastery Self II 1 Buff Self 71 LeadershipRaising 25 1800 Creature Enchantment 20 Increases the caster's Leadership skill by 15 points. +900 Leadership Mastery Self III 2 Buff Self 71 LeadershipRaising 75 1800 Creature Enchantment 30 Increases the caster's Leadership skill by 20 points. +901 Leadership Mastery Self IV 3 Buff Self 71 LeadershipRaising 125 1800 Creature Enchantment 40 Increases the caster's Leadership skill by 25 points. +902 Leadership Mastery Self V 5 Buff Self 71 LeadershipRaising 200 1800 Creature Enchantment 50 Increases the caster's Leadership skill by 30 points. +903 Leadership Mastery Self VI 6 Buff Self 71 LeadershipRaising 250 2700 Creature Enchantment 60 Increases the caster's Leadership skill by 35 points. +904 Leadership Mastery Other I 1 Buff Other 71 LeadershipRaising 1 1800 Creature Enchantment 10 Increases the target's Leadership skill by 10 points. +905 Leadership Mastery Other II 2 Buff Other 71 LeadershipRaising 50 1800 Creature Enchantment 20 Increases the target's Leadership skill by 15 points. +906 Leadership Mastery Other III 3 Buff Other 71 LeadershipRaising 100 1800 Creature Enchantment 30 Increases the target's Leadership skill by 20 points. +907 Leadership Mastery Other IV 4 Buff Other 71 LeadershipRaising 150 1800 Creature Enchantment 40 Increases the target's Leadership skill by 25 points. +908 Leadership Mastery Other V 5 Buff Other 71 LeadershipRaising 200 1800 Creature Enchantment 50 Increases the target's Leadership skill by 30 points. +909 Leadership Mastery Other VI 6 Buff Other 71 LeadershipRaising 250 2700 Creature Enchantment 60 Increases the target's Leadership skill by 35 points. +910 Leadership Ineptitude Self I 1 Debuff Self 72 LeadershipLowering 1 60 Creature Enchantment 15 Decreases the caster's Leadership skill by 10 points. +911 Leadership Ineptitude Self II 2 Debuff Self 72 LeadershipLowering 75 90 Creature Enchantment 30 Decreases the caster's Leadership skill by 15 points. +912 Leadership Ineptitude Self III 3 Debuff Self 72 LeadershipLowering 125 120 Creature Enchantment 40 Decreases the caster's Leadership skill by 20 points. +913 Leadership Ineptitude Self IV 4 Debuff Self 72 LeadershipLowering 175 150 Creature Enchantment 50 Decreases the caster's Leadership skill by 25 points. +914 Leadership Ineptitude Self V 5 Debuff Self 72 LeadershipLowering 225 180 Creature Enchantment 60 Decreases the caster's Leadership skill by 30 points. +915 Leadership Ineptitude Self VI 6 Debuff Self 72 LeadershipLowering 275 210 Creature Enchantment 70 Decreases the caster's Leadership skill by 35 points. +916 Leadership Ineptitude Other I 1 Debuff Other 72 LeadershipLowering 1 60 Creature Enchantment 10 Decreases the target's Leadership skill by 10 points. +917 Leadership Ineptitude Other II 2 Debuff Other 72 LeadershipLowering 75 90 Creature Enchantment 20 Decreases the target's Leadership skill by 15 points. +918 Leadership Ineptitude Other III 3 Debuff Other 72 LeadershipLowering 125 120 Creature Enchantment 30 Decreases the target's Leadership skill by 20 points. +919 Leadership Ineptitude Other IV 4 Debuff Other 72 LeadershipLowering 175 150 Creature Enchantment 40 Decreases the target's Leadership skill by 25 points. +920 Leadership Ineptitude Other V 5 Debuff Other 72 LeadershipLowering 225 180 Creature Enchantment 50 Decreases the target's Leadership skill by 30 points. +921 Leadership Ineptitude Other VI 6 Debuff Other 72 LeadershipLowering 275 210 Creature Enchantment 60 Decreases the target's Leadership skill by 35 points. +922 Lockpick Mastery Self I 1 Buff Self 73 LockpickRaising 1 1800 Creature Enchantment 15 Increases the caster's Lockpick skill by 10 points. +923 Lockpick Mastery Self II 2 Buff Self 73 LockpickRaising 50 1800 Creature Enchantment 30 Increases the caster's Lockpick skill by 15 points. +924 Lockpick Mastery Self III 3 Buff Self 73 LockpickRaising 100 1800 Creature Enchantment 40 Increases the caster's Lockpick skill by 20 points. +925 Lockpick Mastery Self IV 4 Buff Self 73 LockpickRaising 150 1800 Creature Enchantment 50 Increases the caster's Lockpick skill by 25 points. +926 Lockpick Mastery Self V 5 Buff Self 73 LockpickRaising 200 1800 Creature Enchantment 60 Increases the caster's Lockpick skill by 30 points. +927 Lockpick Mastery Self VI 6 Buff Self 73 LockpickRaising 250 2700 Creature Enchantment 70 Increases the caster's Lockpick skill by 35 points. +928 Lockpick Mastery Other I 1 Buff Other 73 LockpickRaising 1 1800 Creature Enchantment 10 Increases the target's Lockpick skill by 10 points. +929 Lockpick Mastery Other II 2 Buff Other 73 LockpickRaising 50 1800 Creature Enchantment 20 Increases the target's Lockpick skill by 15 points. +930 Lockpick Mastery Other III 3 Buff Other 73 LockpickRaising 100 1800 Creature Enchantment 30 Increases the target's Lockpick skill by 20 points. +931 Lockpick Mastery Other IV 4 Buff Other 73 LockpickRaising 150 1800 Creature Enchantment 40 Increases the target's Lockpick skill by 25 points. +932 Lockpick Mastery Other V 5 Buff Other 73 LockpickRaising 200 1800 Creature Enchantment 50 Increases the target's Lockpick skill by 30 points. +933 Lockpick Mastery Other VI 6 Buff Other 73 LockpickRaising 250 2700 Creature Enchantment 60 Increases the target's Lockpick skill by 35 points. +934 Lockpick Ineptitude Self I 1 Debuff Self 74 LockpickLowering 1 60 Creature Enchantment 15 Decreases the caster's Lockpick skill by 10 points. +935 Lockpick Ineptitude Self II 2 Debuff Self 74 LockpickLowering 75 90 Creature Enchantment 30 Decreases the caster's Lockpick skill by 15 points. +936 Lockpick Ineptitude Self III 3 Debuff Self 74 LockpickLowering 125 120 Creature Enchantment 40 Decreases the caster's Lockpick skill by 20 points. +937 Lockpick Ineptitude Self IV 4 Debuff Self 74 LockpickLowering 175 150 Creature Enchantment 50 Decreases the caster's Lockpick skill by 25 points. +938 Lockpick Ineptitude Self V 5 Debuff Self 74 LockpickLowering 225 180 Creature Enchantment 60 Decreases the caster's Lockpick skill by 30 points. +939 Lockpick Ineptitude Self VI 6 Debuff Self 74 LockpickLowering 275 210 Creature Enchantment 70 Decreases the caster's Lockpick skill by 35 points. +940 Lockpick Ineptitude Other I 1 Debuff Other 74 LockpickLowering 1 60 Creature Enchantment 10 Decreases the target's Lockpick skill by 10 points. +941 Lockpick Ineptitude Other II 2 Debuff Other 74 LockpickLowering 75 90 Creature Enchantment 20 Decreases the target's Lockpick skill by 15 points. +942 Lockpick Ineptitude Other III 3 Debuff Other 74 LockpickLowering 125 120 Creature Enchantment 30 Decreases the target's Lockpick skill by 20 points. +943 Lockpick Ineptitude Other IV 4 Debuff Other 74 LockpickLowering 175 150 Creature Enchantment 40 Decreases the target's Lockpick skill by 25 points. +944 Lockpick Ineptitude Other V 5 Debuff Other 74 LockpickLowering 225 180 Creature Enchantment 50 Decreases the target's Lockpick skill by 30 points. +945 Lockpick Ineptitude Other VI 6 Debuff Other 74 LockpickLowering 275 210 Creature Enchantment 60 Decreases the target's Lockpick skill by 35 points. +946 Fealty Self I 1 Buff Self 75 LoyaltyRaising 1 1800 Creature Enchantment 15 Increases the caster's Loyalty skill by 10 points. +947 Fealty Self II 2 Buff Self 75 LoyaltyRaising 50 1800 Creature Enchantment 30 Increases the caster's Loyalty skill by 15 points. +948 Fealty Self III 3 Buff Self 75 LoyaltyRaising 100 1800 Creature Enchantment 40 Increases the caster's Loyalty skill by 20 points. +949 Fealty Self IV 4 Buff Self 75 LoyaltyRaising 150 1800 Creature Enchantment 50 Increases the caster's Loyalty skill by 25 points. +950 Fealty Self V 5 Buff Self 75 LoyaltyRaising 200 1800 Creature Enchantment 60 Increases the caster's Loyalty skill by 30 points. +951 Fealty Self VI 6 Buff Self 75 LoyaltyRaising 250 2700 Creature Enchantment 70 Increases the caster's Loyalty skill by 35 points. +952 Fealty Other I 1 Buff Other 75 LoyaltyRaising 1 1800 Creature Enchantment 10 Increases the target's Loyalty skill by 10 points. +953 Fealty Other II 2 Buff Other 75 LoyaltyRaising 50 1800 Creature Enchantment 20 Increases the target's Loyalty skill by 15 points. +954 Fealty Other III 3 Buff Other 75 LoyaltyRaising 100 1800 Creature Enchantment 30 Increases the target's Loyalty skill by 20 points. +955 Fealty Other IV 4 Buff Other 75 LoyaltyRaising 150 1800 Creature Enchantment 40 Increases the target's Loyalty skill by 25 points. +956 Fealty Other V 5 Buff Other 75 LoyaltyRaising 200 1800 Creature Enchantment 50 Increases the target's Loyalty skill by 30 points. +957 Fealty Other VI 6 Buff Other 75 LoyaltyRaising 250 2700 Creature Enchantment 60 Increases the target's Loyalty skill by 35 points. +958 Faithlessness Self I 1 Debuff Self 76 LoyaltyLowering 1 60 Creature Enchantment 15 Decreases the caster's Loyalty skill by 10 points. +959 Faithlessness Self II 2 Debuff Self 76 LoyaltyLowering 75 90 Creature Enchantment 30 Decreases the caster's Loyalty skill by 15 points. +960 Faithlessness Self III 3 Debuff Self 76 LoyaltyLowering 125 120 Creature Enchantment 40 Decreases the caster's Loyalty skill by 20 points. +961 Faithlessness Self IV 4 Debuff Self 76 LoyaltyLowering 175 150 Creature Enchantment 50 Decreases the caster's Loyalty skill by 25 points. +962 Faithlessness Self V 5 Debuff Self 76 LoyaltyLowering 225 180 Creature Enchantment 60 Decreases the caster's Loyalty skill by 30 points. +963 Faithlessness Self VI 6 Debuff Self 76 LoyaltyLowering 275 210 Creature Enchantment 70 Decreases the caster's Loyalty skill by 35 points. +964 Faithlessness Other I 1 Debuff Other 76 LoyaltyLowering 1 60 Creature Enchantment 10 Decreases the target's Loyalty skill by 10 points. +965 Faithlessness Other II 2 Debuff Other 76 LoyaltyLowering 75 90 Creature Enchantment 20 Decreases the target's Loyalty skill by 15 points. +966 Faithlessness Other III 3 Debuff Other 76 LoyaltyLowering 125 120 Creature Enchantment 30 Decreases the target's Loyalty skill by 20 points. +967 Faithlessness Other IV 4 Debuff Other 76 LoyaltyLowering 175 150 Creature Enchantment 40 Decreases the target's Loyalty skill by 25 points. +968 Faithlessness Other V 5 Debuff Other 76 LoyaltyLowering 225 180 Creature Enchantment 50 Decreases the target's Loyalty skill by 30 points. +969 Faithlessness Other VI 6 Debuff Other 76 LoyaltyLowering 275 210 Creature Enchantment 60 Decreases the target's Loyalty skill by 35 points. +970 Jumping Mastery Self I 1 Buff Self 69 JumpRaising 1 1800 Creature Enchantment 15 Increases the caster's Jump skill by 10 points. +971 Jumping Mastery Self II 2 Buff Self 69 JumpRaising 50 1800 Creature Enchantment 30 Increases the caster's Jump skill by 15 points. +972 Jumping Mastery Self III 3 Buff Self 69 JumpRaising 100 1800 Creature Enchantment 40 Increases the caster's Jump skill by 20 points. +973 Jumping Mastery Self IV 4 Buff Self 69 JumpRaising 150 1800 Creature Enchantment 50 Increases the caster's Jump skill by 25 points. +974 Jumping Mastery Self V 5 Buff Self 69 JumpRaising 200 1800 Creature Enchantment 60 Increases the caster's Jump skill by 30 points. +975 Jumping Mastery Self VI 6 Buff Self 69 JumpRaising 250 2700 Creature Enchantment 70 Increases the caster's Jump skill by 35 points. +976 Jumping Mastery Other I 1 Buff Other 69 JumpRaising 1 1800 Creature Enchantment 10 Increases the target's Jump skill by 10 points. +977 Jumping Mastery Other II 2 Buff Other 69 JumpRaising 50 1800 Creature Enchantment 20 Increases the target's Jump skill by 15 points. +978 Jumping Mastery Other III 3 Buff Other 69 JumpRaising 100 1800 Creature Enchantment 30 Increases the target's Jump skill by 20 points. +979 Jumping Mastery Other IV 4 Buff Other 69 JumpRaising 150 1800 Creature Enchantment 40 Increases the target's Jump skill by 25 points. +980 Jumping Mastery Other V 5 Buff Other 69 JumpRaising 200 1800 Creature Enchantment 50 Increases the target's Jump skill by 30 points. +981 Jumping Mastery Other VI 6 Buff Other 69 JumpRaising 250 2700 Creature Enchantment 60 Increases the target's Jump skill by 35 points. +982 Sprint Self I 1 Buff Self 77 RunRaising 1 1800 Creature Enchantment 15 Increases the caster's Run skill by 10 points. +983 Sprint Self II 2 Buff Self 77 RunRaising 50 1800 Creature Enchantment 30 Increases the caster's Run skill by 15 points. +984 Sprint Self III 3 Buff Self 77 RunRaising 100 1800 Creature Enchantment 40 Increases the caster's Run skill by 20 points. +985 Sprint Self IV 4 Buff Self 77 RunRaising 150 1800 Creature Enchantment 50 Increases the caster's Run skill by 25 points. +986 Sprint Self V 5 Buff Self 77 RunRaising 200 1800 Creature Enchantment 60 Increases the caster's Run skill by 30 points. +987 Sprint Self VI 6 Buff Self 77 RunRaising 250 2700 Creature Enchantment 70 Increases the caster's Run skill by 35 points. +988 Sprint Other I 1 Buff Other 77 RunRaising 1 1800 Creature Enchantment 10 Increases the target's Run skill by 10 points. +989 Sprint Other II 2 Buff Other 77 RunRaising 50 1800 Creature Enchantment 20 Increases the target's Run skill by 15 points. +990 Sprint Other III 3 Buff Other 77 RunRaising 100 1800 Creature Enchantment 30 Increases the target's Run skill by 20 points. +991 Sprint Other IV 4 Buff Other 77 RunRaising 150 1800 Creature Enchantment 40 Increases the target's Run skill by 25 points. +992 Sprint Other V 5 Buff Other 77 RunRaising 200 1800 Creature Enchantment 50 Increases the target's Run skill by 30 points. +993 Sprint Other VI 6 Buff Other 77 RunRaising 250 2700 Creature Enchantment 60 Increases the target's Run skill by 35 points. +994 Leaden Feet Self I 1 Debuff Self 78 RunLowering 1 60 Creature Enchantment 15 Decreases the caster's Run skill by 10 points. +995 Leaden Feet Self II 2 Debuff Self 78 RunLowering 75 90 Creature Enchantment 30 Decreases the caster's Run skill by 15 points. +996 Leaden Feet Self III 3 Debuff Self 78 RunLowering 125 120 Creature Enchantment 40 Decreases the caster's Run skill by 20 points. +997 Leaden Feet Self IV 4 Debuff Self 78 RunLowering 175 150 Creature Enchantment 50 Decreases the caster's Run skill by 25 points. +998 Leaden Feet Self V 5 Debuff Self 78 RunLowering 225 180 Creature Enchantment 60 Decreases the caster's Run skill by 30 points. +999 Leaden Feet Self VI 6 Debuff Self 78 RunLowering 275 210 Creature Enchantment 70 Decreases the caster's Run skill by 35 points. +1000 Leaden Feet Other I 1 Debuff Other 78 RunLowering 1 60 Creature Enchantment 10 Decreases the target's Run skill by 10 points. +1001 Leaden Feet Other II 2 Debuff Other 78 RunLowering 75 90 Creature Enchantment 20 Decreases the target's Run skill by 15 points. +1002 Leaden Feet Other III 3 Debuff Other 78 RunLowering 125 120 Creature Enchantment 30 Decreases the target's Run skill by 20 points. +1003 Leaden Feet Other IV 4 Debuff Other 78 RunLowering 175 150 Creature Enchantment 40 Decreases the target's Run skill by 25 points. +1004 Leaden Feet Other V 5 Debuff Other 78 RunLowering 225 180 Creature Enchantment 50 Decreases the target's Run skill by 30 points. +1005 Leaden Feet Other VI 6 Debuff Other 78 RunLowering 275 210 Creature Enchantment 60 Decreases the target's Run skill by 35 points. +1006 Jumping Ineptitude Self I 1 Debuff Self 70 JumpLowering 1 60 Creature Enchantment 15 Decreases the caster's Jump skill by 10 points. +1007 Jumping Ineptitude Self II 2 Debuff Self 70 JumpLowering 75 90 Creature Enchantment 30 Decreases the caster's Jump skill by 15 points. +1008 Jumping Ineptitude Self III 3 Debuff Self 70 JumpLowering 125 120 Creature Enchantment 40 Decreases the caster's Jump skill by 20 points. +1009 Jumping Ineptitude Self IV 4 Debuff Self 70 JumpLowering 175 150 Creature Enchantment 50 Decreases the caster's Jump skill by 25 points. +1010 Jumping Ineptitude Self V 5 Debuff Self 70 JumpLowering 225 180 Creature Enchantment 60 Decreases the caster's Jump skill by 30 points. +1011 Jumping Ineptitude Self VI 6 Debuff Self 70 JumpLowering 275 210 Creature Enchantment 70 Decreases the caster's Jump skill by 35 points. +1012 Jumping Ineptitude Other I 1 Debuff Other 70 JumpLowering 1 60 Creature Enchantment 10 Decreases the target's Jump skill by 10 points. +1013 Jumping Ineptitude Other II 2 Debuff Other 70 JumpLowering 75 90 Creature Enchantment 20 Decreases the target's Jump skill by 15 points. +1014 Jumping Ineptitude Other III 3 Debuff Other 70 JumpLowering 125 120 Creature Enchantment 30 Decreases the target's Jump skill by 20 points. +1015 Jumping Ineptitude Other IV 4 Debuff Other 70 JumpLowering 175 150 Creature Enchantment 40 Decreases the target's Jump skill by 25 points. +1016 Jumping Ineptitude Other V 5 Debuff Other 70 JumpLowering 225 180 Creature Enchantment 50 Decreases the target's Jump skill by 30 points. +1017 Jumping Ineptitude Other VI 6 Debuff Other 70 JumpLowering 275 210 Creature Enchantment 60 Decreases the target's Jump skill by 35 points. +1018 Bludgeoning Protection Self I 1 Buff Self 103 BludgeonProtection 1 1800 Life Magic 15 Reduces damage the caster takes from Bludgeoning by 9%. +1019 Bludgeoning Protection Self II 2 Buff Self 103 BludgeonProtection 50 1800 Life Magic 30 Reduces damage the caster takes from Bludgeoning by 20%. +1020 Bludgeoning Protection Self III 3 Buff Self 103 BludgeonProtection 100 1800 Life Magic 40 Reduces damage the caster takes from Bludgeoning by 33%. +1021 Bludgeoning Protection Self IV 4 Buff Self 103 BludgeonProtection 150 1800 Life Magic 50 Reduces damage the caster takes from Bludgeoning by 43%. +1022 Bludgeoning Protection Self V 5 Buff Self 103 BludgeonProtection 200 1800 Life Magic 60 Reduces damage the caster takes from Bludgeoning by 50%. +1023 Bludgeoning Protection Self VI 6 Buff Self 103 BludgeonProtection 250 2700 Life Magic 70 Reduces damage the caster takes from Bludgeoning by 60%. +1024 Bludgeoning Protection Other I 1 Buff Other 103 BludgeonProtection 1 1800 Life Magic 10 Reduces damage the target takes from Bludgeoning by 9%. +1025 Bludgeoning Protection Other II 2 Buff Other 103 BludgeonProtection 50 1800 Life Magic 30 Reduces damage the target takes from Bludgeoning by 20%. +1026 Bludgeoning Protection Other III 3 Buff Other 103 BludgeonProtection 100 1800 Life Magic 30 Reduces damage the target takes from Bludgeoning by 33%. +1027 Bludgeoning Protection Other IV 4 Buff Other 103 BludgeonProtection 150 1800 Life Magic 40 Reduces damage the target takes from Bludgeoning by 43%. +1028 Bludgeoning Protection Other V 5 Buff Other 103 BludgeonProtection 200 1800 Life Magic 50 Reduces damage the target takes from Bludgeoning by 50%. +1029 Bludgeoning Protection Other VI 6 Buff Other 103 BludgeonProtection 250 2700 Life Magic 60 Reduces damage the target takes from Bludgeoning by 60%. +1030 Cold Protection Self I 1 Buff Self 105 ColdProtection 1 1800 Life Magic 15 Reduces damage the caster takes from Cold by 9%. +1031 Cold Protection Self II 2 Buff Self 105 ColdProtection 50 1800 Life Magic 30 Reduces damage the caster takes from Cold by 20%. +1032 Cold Protection Self III 3 Buff Self 105 ColdProtection 100 1800 Life Magic 40 Reduces damage the caster takes from Cold by 33%. +1033 Cold Protection Self IV 4 Buff Self 105 ColdProtection 150 1800 Life Magic 50 Reduces damage the caster takes from Cold by 43%. +1034 Cold Protection Self V 5 Buff Self 105 ColdProtection 200 1800 Life Magic 60 Reduces damage the caster takes from Cold by 50%. +1035 Cold Protection Self VI 6 Buff Self 105 ColdProtection 250 2700 Life Magic 70 Reduces damage the caster takes from Cold by 60%. +1036 Cold Protection Other I 1 Buff Other 105 ColdProtection 1 1800 Life Magic 10 Reduces damage the target takes from Cold by 9%. +1037 Cold Protection Other II 2 Buff Other 105 ColdProtection 50 1800 Life Magic 20 Reduces damage the target takes from Cold by 20%. +1038 Cold Protection Other III 3 Buff Other 105 ColdProtection 100 1800 Life Magic 30 Reduces damage the target takes from Cold by 33%. +1039 Cold Protection Other IV 4 Buff Other 105 ColdProtection 150 1800 Life Magic 40 Reduces damage the target takes from Cold by 43%. +1040 Cold Protection Other V 5 Buff Other 105 ColdProtection 200 1800 Life Magic 50 Reduces damage the target takes from Cold by 50%. +1041 Cold Protection Other VI 6 Buff Other 105 ColdProtection 250 2700 Life Magic 60 Reduces damage the target takes from Cold by 60%. +1042 Bludgeoning Vulnerability Self I 1 Debuff Self 104 BludgeonVulnerability 25 60 Life Magic 15 Increases damage the caster takes from Bludgeoning by 10%. +1043 Bludgeoning Vulnerability Self II 2 Debuff Self 104 BludgeonVulnerability 75 90 Life Magic 30 Increases damage the caster takes from Bludgeoning by 25%. +1044 Bludgeoning Vulnerability Self III 3 Debuff Self 104 BludgeonVulnerability 125 120 Life Magic 40 Increases damage the caster takes from Bludgeoning by 50%. +1045 Bludgeoning Vulnerability Self IV 4 Debuff Self 104 BludgeonVulnerability 175 150 Life Magic 50 Increases damage the caster takes from Bludgeoning by 75%. +1046 Bludgeoning Vulnerability Self V 5 Debuff Self 104 BludgeonVulnerability 225 180 Life Magic 60 Increases damage the caster takes from Bludgeoning by 100%. +1047 Bludgeoning Vulnerability Self VI 6 Debuff Self 104 BludgeonVulnerability 275 210 Life Magic 70 Increases damage the caster takes from Bludgeoning by 150%. +1048 Bludgeoning Vulnerability Other I 1 Debuff Other 104 BludgeonVulnerability 25 60 Life Magic 10 Increases damage the target takes from Bludgeoning by 10%. +1049 Bludgeoning Vulnerability Other II 2 Debuff Other 104 BludgeonVulnerability 75 90 Life Magic 20 Increases damage the target takes from Bludgeoning by 25%. +1050 Bludgeoning Vulnerability Other III 3 Debuff Other 104 BludgeonVulnerability 125 120 Life Magic 30 Increases damage the target takes from Bludgeoning by 50%. +1051 Bludgeoning Vulnerability Other IV 4 Debuff Other 104 BludgeonVulnerability 175 150 Life Magic 40 Increases damage the target takes from Bludgeoning by 75%. +1052 Bludgeoning Vulnerability Other V 5 Debuff Other 104 BludgeonVulnerability 225 180 Life Magic 50 Increases damage the target takes from Bludgeoning by 100%. +1053 Bludgeoning Vulnerability Other VI 6 Debuff Other 104 BludgeonVulnerability 275 210 Life Magic 60 Increases damage the target takes from Bludgeoning by 150%. +1054 Cold Vulnerability Self I 1 Debuff Self 106 ColdVulnerability 25 60 Life Magic 15 Increases damage the caster takes from Cold by 10%. +1055 Cold Vulnerability Self II 2 Debuff Self 106 ColdVulnerability 75 90 Life Magic 30 Increases damage the caster takes from Cold by 25%. +1056 Cold Vulnerability Self III 3 Debuff Self 106 ColdVulnerability 125 120 Life Magic 40 Increases damage the caster takes from Cold by 50%. +1057 Cold Vulnerability Self IV 4 Debuff Self 106 ColdVulnerability 175 150 Life Magic 50 Increases damage the caster takes from Cold by 75%. +1058 Cold Vulnerability Self V 5 Debuff Self 106 ColdVulnerability 225 180 Life Magic 60 Increases damage the caster takes from Cold by 100%. +1059 Cold Vulnerability Self VI 6 Debuff Self 106 ColdVulnerability 275 210 Life Magic 70 Increases damage the caster takes from Cold by 150%. +1060 Cold Vulnerability Other I 1 Debuff Other 106 ColdVulnerability 25 60 Life Magic 10 Increases damage the target takes from Cold by 10%. +1061 Cold Vulnerability Other II 2 Debuff Other 106 ColdVulnerability 75 90 Life Magic 20 Increases damage the target takes from Cold by 25%. +1062 Cold Vulnerability Other III 3 Debuff Other 106 ColdVulnerability 125 120 Life Magic 30 Increases damage the target takes from Cold by 50%. +1063 Cold Vulnerability Other IV 4 Debuff Other 106 ColdVulnerability 175 150 Life Magic 40 Increases damage the target takes from Cold by 75%. +1064 Cold Vulnerability Other V 5 Debuff Other 106 ColdVulnerability 225 180 Life Magic 50 Increases damage the target takes from Cold by 100%. +1065 Cold Vulnerability Other VI 6 Debuff Other 106 ColdVulnerability 275 210 Life Magic 60 Increases damage the target takes from Cold by 150%. +1066 Lightning Protection Self I 1 Buff Self 107 ElectricProtection 1 1800 Life Magic 15 Reduces damage the caster takes from Lightning by 9%. +1067 Lightning Protection Self II 2 Buff Self 107 ElectricProtection 50 1800 Life Magic 30 Reduces damage the caster takes from Lightning by 20%. +1068 Lightning Protection Self III 3 Buff Self 107 ElectricProtection 100 1800 Life Magic 40 Reduces damage the caster takes from Lightning by 33%. +1069 Lightning Protection Self IV 4 Buff Self 107 ElectricProtection 150 1800 Life Magic 50 Reduces damage the caster takes from Lightning by 43%. +1070 Lightning Protection Self V 5 Buff Self 107 ElectricProtection 200 1800 Life Magic 60 Reduces damage the caster takes from Lightning by 50%. +1071 Lightning Protection Self VI 6 Buff Self 107 ElectricProtection 250 2700 Life Magic 70 Reduces damage the caster takes from Lightning by 60%. +1072 Lightning Protection Other I 1 Buff Other 107 ElectricProtection 1 1800 Life Magic 10 Reduces damage the target takes from Lightning by 9%. +1073 Lightning Protection Other II 2 Buff Other 107 ElectricProtection 50 1800 Life Magic 20 Reduces damage the target takes from Lightning by 20%. +1074 Lightning Protection Other III 3 Buff Other 107 ElectricProtection 100 1800 Life Magic 30 Reduces damage the target takes from Lightning by 33%. +1075 Lightning Protection Other IV 4 Buff Other 107 ElectricProtection 150 1800 Life Magic 40 Reduces damage the target takes from Lightning by 43%. +1076 Lightning Protection Other V 5 Buff Other 107 ElectricProtection 200 1800 Life Magic 50 Reduces damage the target takes from Lightning by 50%. +1077 Lightning Protection Other VI 6 Buff Other 107 ElectricProtection 250 2700 Life Magic 60 Reduces damage the target takes from Lightning by 60%. +1078 Lightning Vulnerability Self I 1 Debuff Self 108 ElectricVulnerability 25 60 Life Magic 15 Increases damage the caster takes from Lightning by 10%. +1079 Lightning Vulnerability Self II 2 Debuff Self 108 ElectricVulnerability 75 90 Life Magic 30 Increases damage the caster takes from Lightning by 25%. +1080 Lightning Vulnerability Self III 3 Debuff Self 108 ElectricVulnerability 125 120 Life Magic 40 Increases damage the caster takes from Lightning by 50%. +1081 Lightning Vulnerability Self IV 4 Debuff Self 108 ElectricVulnerability 175 150 Life Magic 50 Increases damage the caster takes from Lightning by 75%. +1082 Lightning Vulnerability Self V 5 Debuff Self 108 ElectricVulnerability 225 180 Life Magic 60 Increases damage the caster takes from Lightning by 100%. +1083 Lightning Vulnerability Self VI 6 Debuff Self 108 ElectricVulnerability 275 210 Life Magic 70 Increases damage the caster takes from Lightning by 150%. +1084 Lightning Vulnerability Other I 1 Debuff Other 108 ElectricVulnerability 25 60 Life Magic 10 Increases damage the target takes from Lightning by 10%. +1085 Lightning Vulnerability Other II 2 Debuff Other 108 ElectricVulnerability 75 90 Life Magic 20 Increases damage the target takes from Lightning by 25%. +1086 Lightning Vulnerability Other III 3 Debuff Other 108 ElectricVulnerability 125 120 Life Magic 30 Increases damage the target takes from Lightning by 50%. +1087 Lightning Vulnerability Other IV 4 Debuff Other 108 ElectricVulnerability 175 150 Life Magic 40 Increases damage the target takes from Lightning by 75%. +1088 Lightning Vulnerability Other V 5 Debuff Other 108 ElectricVulnerability 225 180 Life Magic 50 Increases damage the target takes from Lightning by 100%. +1089 Lightning Vulnerability Other VI 6 Debuff Other 108 ElectricVulnerability 275 210 Life Magic 60 Increases damage the target takes from Lightning by 150%. +1090 Fire Protection Self II 2 Buff Self 109 FireProtection 50 1800 Life Magic 30 Reduces damage the caster takes from Fire by 20%. +1091 Fire Protection Self III 3 Buff Self 109 FireProtection 100 1800 Life Magic 40 Reduces damage the caster takes from Fire by 33%. +1092 Fire Protection Self IV 4 Buff Self 109 FireProtection 150 1800 Life Magic 50 Reduces damage the caster takes from Fire by 43%. +1093 Fire Protection Self V 5 Buff Self 109 FireProtection 200 1800 Life Magic 60 Reduces damage the caster takes from Fire by 50%. +1094 Fire Protection Self VI 6 Buff Self 109 FireProtection 250 2700 Life Magic 70 Reduces damage the caster takes from Fire by 60%. +1095 Fire Protection Other V 5 Buff Other 109 FireProtection 200 1800 Life Magic 50 Reduces damage the target takes from fire by 50%. +1096 Fire Protection Other VI 6 Buff Other 109 FireProtection 250 2700 Life Magic 60 Reduces damage the target takes from fire by 60%. +1097 Flaming Missile 1 Neutral Other 122 PiercingMissile 1 -1 War Magic 10 CREATURE MAGIC ONLY! +1098 Fire Vulnerability Self II 2 Debuff Self 110 FireVulnerability 75 90 Life Magic 30 Increases damage the caster takes from Fire by 25%. +1099 Fire Vulnerability Self III 3 Debuff Self 110 FireVulnerability 125 120 Life Magic 40 Increases damage the caster takes from Fire by 50%. +1100 Fire Vulnerability Self IV 4 Debuff Self 110 FireVulnerability 175 150 Life Magic 50 Increases damage the caster takes from Fire by 75%. +1101 Fire Vulnerability Self V 5 Debuff Self 110 FireVulnerability 225 180 Life Magic 60 Increases damage the caster takes from Fire by 100%. +1102 Fire Vulnerability Self VI 6 Debuff Self 110 FireVulnerability 275 210 Life Magic 70 Increases damage the caster takes from Fire by 150%. +1104 Fire Vulnerability Other II 2 Debuff Other 110 FireVulnerability 75 90 Life Magic 20 Increases damage the target takes from Fire by 25%. +1105 Fire Vulnerability Other III 3 Debuff Other 110 FireVulnerability 125 120 Life Magic 30 Increases damage the target takes from Fire by 50%. +1106 Fire Vulnerability Other IV 4 Debuff Other 110 FireVulnerability 175 150 Life Magic 40 Increases damage the target takes from Fire by 75%. +1107 Fire Vulnerability Other V 5 Debuff Other 110 FireVulnerability 225 180 Life Magic 50 Increases damage the target takes from Fire by 100%. +1108 Fire Vulnerability Other VI 6 Debuff Other 110 FireVulnerability 275 210 Life Magic 60 Increases damage the target takes from Fire by 150%. +1109 Blade Protection Self I 1 Buff Self 113 SlashProtection 1 1800 Life Magic 15 Reduces damage the caster takes from Slashing by 9%. +1110 Blade Protection Self II 2 Buff Self 113 SlashProtection 50 1800 Life Magic 30 Reduces damage the caster takes from Slashing by 20%. +1111 Blade Protection Self III 3 Buff Self 113 SlashProtection 100 1800 Life Magic 40 Reduces damage the caster takes from Slashing by 33%. +1112 Blade Protection Self IV 4 Buff Self 113 SlashProtection 150 1800 Life Magic 50 Reduces damage the caster takes from Slashing by 43%. +1113 Blade Protection Self V 5 Buff Self 113 SlashProtection 200 1800 Life Magic 60 Reduces damage the caster takes from Slashing by 50%. +1114 Blade Protection Self VI 6 Buff Self 113 SlashProtection 250 2700 Life Magic 70 Reduces damage the caster takes from Slashing by 60%. +1115 Blade Protection Other I 1 Buff Other 113 SlashProtection 1 1800 Life Magic 10 Reduces damage the target takes from Slashing by 9%. +1116 Blade Protection Other II 2 Buff Other 113 SlashProtection 50 1800 Life Magic 20 Reduces damage the target takes from Slashing by 20%. +1117 Blade Protection Other III 3 Buff Other 113 SlashProtection 100 1800 Life Magic 30 Reduces damage the target takes from Slashing by 33%. +1118 Blade Protection Other IV 4 Buff Other 113 SlashProtection 150 1800 Life Magic 40 Reduces damage the target takes from Slashing by 43%. +1119 Blade Protection Other V 5 Buff Other 113 SlashProtection 200 1800 Life Magic 50 Reduces damage the target takes from Slashing by 50%. +1120 Blade Protection Other VI 6 Buff Other 113 SlashProtection 250 2700 Life Magic 60 Reduces damage the target takes from Slashing by 60%. +1121 Blade Vulnerability Self I 1 Debuff Self 114 SlashVulnerability 25 60 Life Magic 15 Increases damage the caster takes from Slashing by 10%. +1122 Blade Vulnerability Self II 2 Debuff Self 114 SlashVulnerability 75 90 Life Magic 30 Increases damage the caster takes from Slashing by 25%. +1123 Blade Vulnerability Self III 3 Debuff Self 114 SlashVulnerability 125 120 Life Magic 40 Increases damage the caster takes from Slashing by 50%. +1124 Blade Vulnerability Self IV 4 Debuff Self 114 SlashVulnerability 175 150 Life Magic 50 Increases damage the caster takes from Slashing by 75%. +1125 Blade Vulnerability Self V 5 Debuff Self 114 SlashVulnerability 225 180 Life Magic 60 Increases damage the caster takes from Slashing by 100%. +1126 Blade Vulnerability Self VI 6 Debuff Self 114 SlashVulnerability 275 210 Life Magic 70 Increases damage the caster takes from Slashing by 150%. +1127 Blade Vulnerability Other I 1 Debuff Other 114 SlashVulnerability 25 60 Life Magic 10 Increases damage the target takes from Slashing by 10%. +1128 Blade Vulnerability Other II 2 Debuff Other 114 SlashVulnerability 75 90 Life Magic 20 Increases damage the target takes from Slashing by 25%. +1129 Blade Vulnerability Other III 3 Debuff Other 114 SlashVulnerability 125 120 Life Magic 30 Increases damage the target takes from Slashing by 50%. +1130 Blade Vulnerability Other IV 4 Debuff Other 114 SlashVulnerability 175 150 Life Magic 40 Increases damage the target takes from Slashing by 75%. +1131 Blade Vulnerability Other V 5 Debuff Other 114 SlashVulnerability 225 180 Life Magic 50 Increases damage the target takes from Slashing by 100%. +1132 Blade Vulnerability Other VI 6 Debuff Other 114 SlashVulnerability 275 210 Life Magic 60 Increases damage the target takes from Slashing by 150%. +1133 Piercing Protection Self I 1 Buff Self 111 PierceProtection 1 1800 Life Magic 15 Reduces damage the caster takes from Piercing by 9%. +1134 Piercing Protection Self II 2 Buff Self 111 PierceProtection 50 1800 Life Magic 30 Reduces damage the caster takes from Piercing by 20%. +1135 Piercing Protection Self III 3 Buff Self 111 PierceProtection 100 1800 Life Magic 40 Reduces damage the caster takes from Piercing by 33%. +1136 Piercing Protection Self IV 4 Buff Self 111 PierceProtection 150 1800 Life Magic 50 Reduces damage the caster takes from Piercing by 43%. +1137 Piercing Protection Self V 5 Buff Self 111 PierceProtection 200 1800 Life Magic 60 Reduces damage the caster takes from Piercing by 50%. +1138 Piercing Protection Self VI 6 Buff Self 111 PierceProtection 250 2700 Life Magic 70 Reduces damage the caster takes from Piercing by 60%. +1139 Piercing Protection Other I 1 Buff Other 111 PierceProtection 1 1800 Life Magic 10 Reduces damage the target takes from Piercing by 9%. +1140 Piercing Protection Other II 2 Buff Other 111 PierceProtection 50 1800 Life Magic 20 Reduces damage the target takes from Piercing by 20%. +1141 Piercing Protection Other III 3 Buff Other 111 PierceProtection 100 1800 Life Magic 30 Reduces damage the target takes from Piercing by 33%. +1142 Piercing Protection Other IV 4 Buff Other 111 PierceProtection 150 1800 Life Magic 40 Reduces damage the target takes from Piercing by 43%. +1143 Piercing Protection Other V 5 Buff Other 111 PierceProtection 200 1800 Life Magic 50 Reduces damage the target takes from Piercing by 50%. +1144 Piercing Protection Other VI 6 Buff Other 111 PierceProtection 250 2700 Life Magic 60 Reduces damage the target takes from Piercing by 60%. +1145 Piercing Vulnerability Self I 1 Debuff Self 112 PierceVulnerability 25 60 Life Magic 15 Increases damage the caster takes from Piercing by 10%. +1146 Piercing Vulnerability Self II 2 Debuff Self 112 PierceVulnerability 75 90 Life Magic 30 Increases damage the caster takes from Piercing by 25%. +1147 Piercing Vulnerability Self III 3 Debuff Self 112 PierceVulnerability 125 120 Life Magic 40 Increases damage the caster takes from Piercing by 50%. +1148 Piercing Vulnerability Self IV 4 Debuff Self 112 PierceVulnerability 175 150 Life Magic 50 Increases damage the caster takes from Piercing by 75%. +1149 Piercing Vulnerability Self V 5 Debuff Self 112 PierceVulnerability 225 180 Life Magic 60 Increases damage the caster takes from Piercing by 100%. +1150 Piercing Vulnerability Self VI 6 Debuff Self 112 PierceVulnerability 275 210 Life Magic 70 Increases damage the caster takes from Piercing by 150%. +1151 Piercing Vulnerability Other I 1 Debuff Other 112 PierceVulnerability 25 60 Life Magic 10 Increases damage the target takes from Piercing by 10%. +1152 Piercing Vulnerability Other II 2 Debuff Other 112 PierceVulnerability 75 90 Life Magic 20 Increases damage the target takes from Piercing by 25%. +1153 Piercing Vulnerability Other III 3 Debuff Other 112 PierceVulnerability 125 120 Life Magic 30 Increases damage the target takes from Piercing by 50%. +1154 Piercing Vulnerability Other IV 4 Debuff Other 112 PierceVulnerability 175 150 Life Magic 40 Increases damage the target takes from Piercing by 75%. +1155 Piercing Vulnerability Other V 5 Debuff Other 112 PierceVulnerability 225 180 Life Magic 50 Increases damage the target takes from Piercing by 100%. +1156 Piercing Vulnerability Other VI 6 Debuff Other 112 PierceVulnerability 275 210 Life Magic 60 Increases damage the target takes from Piercing by 150%. +1157 Heal Self II 2 Heal Self 67 HealingRaising 50 -1 Life Magic 30 Restores 15-35 points of the caster's Health. +1158 Heal Self III 3 Heal Self 67 HealingRaising 100 -1 Life Magic 40 Restores 20-45 points of the caster's Health. +1159 Heal Self IV 4 Heal Self 67 HealingRaising 150 -1 Life Magic 50 Restores 30-60 points of the caster's Health. +1160 Heal Self V 5 Heal Self 67 HealingRaising 200 -1 Life Magic 60 Restores 45-90 points of the caster's Health. +1161 Heal Self VI 6 Heal Self 67 HealingRaising 250 -1 Life Magic 70 Restores 55-120 points of the caster's Health. +1162 Heal Other II 2 Heal Other 79 HealthRaising 50 -1 Life Magic 20 Restores 15-35 points of the target's Health. +1163 Heal Other III 3 Heal Other 79 HealthRaising 100 -1 Life Magic 30 Restores 20-45 points of the target's Health. +1164 Heal Other IV 4 Heal Other 79 HealthRaising 150 -1 Life Magic 40 Restores 30-60 points of the target's Health. +1165 Heal Other V 5 Heal Other 79 HealthRaising 200 -1 Life Magic 50 Restores 45-90 points of the target's Health. +1166 Heal Other VI 6 Heal Other 79 HealthRaising 250 -1 Life Magic 60 Restores 55-120 points of the target's Health. +1167 Harm Self II 2 Harm Self 80 HealthLowering 75 -1 Life Magic 30 Drains 7-12 points of the caster's Health. +1168 Harm Self III 3 Harm Self 80 HealthLowering 125 -1 Life Magic 40 Drains 10-18 points of the caster's Health. +1169 Harm Self IV 4 Harm Self 80 HealthLowering 175 -1 Life Magic 50 Drains 16-30 points of the caster's Health. +1170 Harm Self V 5 Harm Self 80 HealthLowering 225 -1 Life Magic 60 Drains 23-45 points of the caster's Health. +1171 Harm Self VI 6 Harm Self 80 HealthLowering 275 -1 Life Magic 70 Drains 31-60 points of the caster's Health. +1172 Harm Other II 2 Harm Other 80 HealthLowering 75 -1 Life Magic 20 Drains 7-12 points of the target's Health. +1173 Harm Other III 3 Harm Other 80 HealthLowering 125 -1 Life Magic 30 Drains 10-19 points of the target's Health. +1174 Harm Other IV 4 Harm Other 80 HealthLowering 175 -1 Life Magic 40 Drains 16-33 points of the target's Health. +1175 Harm Other V 5 Harm Other 80 HealthLowering 225 -1 Life Magic 50 Drains 24-47 points of the target's Health. +1176 Harm Other VI 6 Harm Other 80 HealthLowering 275 -1 Life Magic 60 Drains 33-63 points of the target's Health. +1177 Revitalize Self I 1 Buff Self 81 StaminaRaising 1 -1 Life Magic 15 Restores 15-35 points of the caster's Stamina. +1178 Revitalize Self II 2 Buff Self 81 StaminaRaising 50 -1 Life Magic 30 Restores 20-45 points of the caster's Stamina. +1179 Revitalize Self III 3 Buff Self 81 StaminaRaising 100 -1 Life Magic 40 Restores 30-60 points of the caster's Stamina. +1180 Revitalize Self IV 4 Buff Self 81 StaminaRaising 150 -1 Life Magic 50 Restores 40-80 points of the caster's Stamina. +1181 Revitalize Self V 5 Buff Self 81 StaminaRaising 200 -1 Life Magic 60 Restores 60-120 points of the caster's Stamina. +1182 Revitalize Self VI 6 Buff Self 81 StaminaRaising 250 -1 Life Magic 70 Restores 80-160 points of the caster's Stamina. +1183 Revitalize Other I 1 Buff Other 81 StaminaRaising 1 -1 Life Magic 10 Restores 15-35 points of the target's Stamina. +1184 Revitalize Other II 2 Buff Other 81 StaminaRaising 50 -1 Life Magic 20 Restores 20-45 points of the target's Stamina. +1185 Revitalize Other III 3 Buff Other 81 StaminaRaising 100 -1 Life Magic 30 Restores 30-60 points of the target's Stamina. +1186 Revitalize Other IV 4 Buff Other 81 StaminaRaising 150 -1 Life Magic 40 Restores 40-80 points of the target's Stamina. +1187 Revitalize Other V 5 Buff Other 81 StaminaRaising 200 -1 Life Magic 50 Restores 60-120 points of the target's Stamina. +1188 Revitalize Other VI 6 Buff Other 81 StaminaRaising 250 -1 Life Magic 60 Restores 80-160 points of the target's Stamina. +1189 Enfeeble Self I 1 Debuff Self 82 StaminaLowering 15 -1 Life Magic 15 Drains 7-12 points of the caster's Stamina. +1190 Enfeeble Self II 2 Debuff Self 82 StaminaLowering 75 -1 Life Magic 20 Drains 7-12 points of the caster's Stamina. +1191 Enfeeble Self III 3 Debuff Self 82 StaminaLowering 125 -1 Life Magic 40 Drains 16-30 points of the caster's Stamina. +1192 Enfeeble Self IV 4 Debuff Self 82 StaminaLowering 175 -1 Life Magic 50 Drains 23-45 points of the caster's Stamina. +1193 Enfeeble Self V 5 Debuff Self 82 StaminaLowering 225 -1 Life Magic 60 Drains 31-60 points of the caster's Stamina. +1194 Enfeeble Self VI 6 Debuff Self 82 StaminaLowering 275 -1 Life Magic 70 Drains 38-75 points of the caster's Stamina. +1195 Enfeeble Other I 1 Debuff Other 82 StaminaLowering 1 -1 Life Magic 10 Drains 7-12 points of the target's Stamina. +1196 Enfeeble Other II 2 Debuff Other 82 StaminaLowering 75 -1 Life Magic 20 Drains 10-19 points of the target's Stamina. +1197 Enfeeble Other III 3 Debuff Other 82 StaminaLowering 125 -1 Life Magic 30 Drains 16-31 points of the target's Stamina. +1198 Enfeeble Other IV 4 Debuff Other 82 StaminaLowering 175 -1 Life Magic 40 Drains 24-47 points of the target's Stamina. +1199 Enfeeble Other V 5 Debuff Other 82 StaminaLowering 225 -1 Life Magic 50 Drains 32-63 points of the target's Stamina. +1200 Enfeeble Other VI 6 Debuff Other 82 StaminaLowering 275 -1 Life Magic 60 Drains 39-79 points of the target's Stamina. +1201 Mana Boost Self I 1 Buff Self 83 ManaRaising 1 -1 Life Magic 15 Restores 6-10 points of the caster's Mana. +1202 Mana Boost Self II 2 Buff Self 83 ManaRaising 50 -1 Life Magic 30 Restores 11-20 points of the caster's Mana. +1203 Mana Boost Self III 3 Buff Self 83 ManaRaising 100 -1 Life Magic 40 Restores 16-30 points of the caster's Mana. +1204 Mana Boost Self IV 4 Buff Self 83 ManaRaising 150 -1 Life Magic 50 Restores 26-50 points of the caster's Mana. +1205 Mana Boost Self V 5 Buff Self 83 ManaRaising 200 -1 Life Magic 60 Restores 38-75 points of the caster's Mana. +1206 Mana Boost Self VI 6 Buff Self 83 ManaRaising 250 -1 Life Magic 70 Restores 51-100 points of the caster's Mana. +1207 Mana Boost Other I 1 Buff Other 83 ManaRaising 1 -1 Life Magic 10 Restores 6-10 points of the target's Mana. +1208 Mana Boost Other II 2 Buff Other 83 ManaRaising 50 -1 Life Magic 20 Restores 11-20 points of the target's Mana. +1209 Mana Boost Other III 3 Buff Other 83 ManaRaising 100 -1 Life Magic 30 Restores 16-30 points of the target's Mana. +1210 Mana Boost Other IV 4 Buff Other 83 ManaRaising 150 -1 Life Magic 40 Restores 26-50 points of the target's Mana. +1211 Mana Boost Other V 5 Buff Other 83 ManaRaising 200 -1 Life Magic 50 Restores 38-75 points of the target's Mana. +1212 Mana Boost Other VI 6 Buff Other 83 ManaRaising 250 -1 Life Magic 60 Restores 51-100 points of the target's Mana. +1213 Mana Drain Self I 1 Debuff Self 84 ManaLowering 15 -1 Life Magic 15 Drains 4-6 points of the caster's Mana. +1214 Mana Drain Self II 2 Debuff Self 84 ManaLowering 75 -1 Life Magic 30 Drains 7-12 points of the caster's Mana. +1215 Mana Drain Self III 3 Debuff Self 84 ManaLowering 125 -1 Life Magic 40 Drains 10-18 points of the caster's Mana. +1216 Mana Drain Self IV 4 Debuff Self 84 ManaLowering 175 -1 Life Magic 50 Drains 16-30 points of the caster's Mana. +1217 Mana Drain Self V 5 Debuff Self 84 ManaLowering 225 -1 Life Magic 60 Drains 23-45 points of the caster's Mana. +1218 Mana Drain Self VI 6 Debuff Self 84 ManaLowering 275 -1 Life Magic 70 Drains 31-60 points of the caster's Mana. +1219 Mana Drain Other I 1 Debuff Other 84 ManaLowering 1 -1 Life Magic 10 Drains 4-6 points of the target's Mana. +1220 Mana Drain Other II 2 Debuff Other 84 ManaLowering 75 -1 Life Magic 20 Drains 7-12 points of the target's Mana. +1221 Mana Drain Other III 3 Debuff Other 84 ManaLowering 125 -1 Life Magic 30 Drains 10-19 points of the target's Mana. +1222 Mana Drain Other IV 4 Debuff Other 84 ManaLowering 175 -1 Life Magic 40 Drains 16-31 points of the target's Mana. +1223 Mana Drain Other V 5 Debuff Other 84 ManaLowering 225 -1 Life Magic 50 Drains 24-47 points of the target's Mana. +1224 Mana Drain Other VI 6 Debuff Other 84 ManaLowering 275 -1 Life Magic 60 Drains 32-63 points of the target's Mana. +1225 Infuse Health Other I 1 Neutral Other 88 HealthTransferfromcaster 1 -1 Life Magic 10 Drains one-quarter of the caster's Health and gives 75% of that to the target. +1226 Infuse Health Other II 2 Neutral Other 88 HealthTransferfromcaster 50 -1 Life Magic 20 Drains one-quarter of the caster's Health and gives 90% of that to the target. +1227 Infuse Health Other III 2 Neutral Other 88 HealthTransferfromcaster 75 -1 Life Magic 30 Drains one-quarter of the caster's Health and gives 105% of that to the target. +1228 Infuse Health Other IV 4 Neutral Other 88 HealthTransferfromcaster 150 -1 Life Magic 40 Drains one-quarter of the caster's Health and gives 120% of that to the target. +1229 Infuse Health Other V 5 Neutral Other 88 HealthTransferfromcaster 200 -1 Life Magic 50 Drains one-quarter of the caster's Health and gives 135% of that to the target. +1230 Infuse Health Other VI 6 Neutral Other 88 HealthTransferfromcaster 250 -1 Life Magic 60 Drains one-quarter of the caster's Health and gives 150% of that to the target. +1237 Drain Health Other I 1 Neutral Other 87 HealthTransfertocaster 38 -1 Life Magic 10 Drains 25% of the target's Health and gives 200% of it to the caster. +1238 Drain Health Other II 2 Neutral Other 87 HealthTransfertocaster 88 -1 Life Magic 20 Drains 25% of the target's Health and gives 160% of it to the caster. +1239 Drain Health Other III 3 Neutral Other 87 HealthTransfertocaster 138 -1 Life Magic 30 Drains 25% of the target's Health and gives 133% of it to the caster. +1240 Drain Health Other IV 4 Neutral Other 87 HealthTransfertocaster 188 -1 Life Magic 40 Drains one-quarter of the target's Health and gives 100% of it to the caster. +1241 Drain Health Other V 5 Neutral Other 87 HealthTransfertocaster 238 -1 Life Magic 50 Drains 30% of the target's Health and gives 100% of it to the caster. +1242 Drain Health Other VI 6 Neutral Other 87 HealthTransfertocaster 288 -1 Life Magic 60 Drains 40% of the target's Health and gives 75% of it to the caster. +1243 Infuse Stamina Other I 1 Neutral Other 90 StaminaTransferfromcaster 1 -1 Life Magic 10 Drains one-quarter of the caster's Stamina and gives 75% of that to the target. +1244 Infuse Stamina Other II 2 Neutral Other 90 StaminaTransferfromcaster 50 -1 Life Magic 20 Drains one-quarter of the caster's Stamina and gives 90% of that to the target. +1245 Infuse Stamina Other III 3 Neutral Other 90 StaminaTransferfromcaster 100 -1 Life Magic 30 Drains one-quarter of the caster's Stamina and gives 105% of that to the target. +1246 Infuse Stamina Other IV 4 Neutral Other 90 StaminaTransferfromcaster 150 -1 Life Magic 40 Drains one-quarter of the caster's Stamina and gives 120% of that to the target. +1247 Infuse Stamina Other V 5 Neutral Other 90 StaminaTransferfromcaster 200 -1 Life Magic 50 Drains one-quarter of the caster's Stamina and gives 135% of that to the target. +1248 Infuse Stamina Other VI 6 Neutral Other 90 StaminaTransferfromcaster 250 -1 Life Magic 60 Drains one-quarter of the caster's Stamina and gives 150% of that to the target. +1249 Drain Stamina Other I 1 Neutral Other 89 StaminaTransfertocaster 38 -1 Life Magic 10 Drains 10% of the target's Stamina and gives it to the caster. +1250 Drain Stamina Other II 2 Neutral Other 89 StaminaTransfertocaster 88 -1 Life Magic 20 Drains 15% of the target's Stamina and gives it to the caster. +1251 Drain Stamina Other III 3 Neutral Other 89 StaminaTransfertocaster 138 -1 Life Magic 30 Drains 20% of the target's Stamina and gives it to the caster. +1252 Drain Stamina Other IV 4 Neutral Other 89 StaminaTransfertocaster 188 -1 Life Magic 40 Drains one-quarter of the target's Stamina and gives it to the caster. +1253 Drain Stamina Other V 5 Neutral Other 89 StaminaTransfertocaster 238 -1 Life Magic 50 Drains 30% of the target's Stamina and gives it to the caster. +1254 Drain Stamina Other VI 6 Neutral Other 89 StaminaTransfertocaster 288 -1 Life Magic 60 Drains 40% of the target's Stamina and gives it to the caster. +1255 Infuse Mana Other II 2 Neutral Other 92 ManaTransferfromcaster 50 -1 Life Magic 20 Drains one-quarter of the caster's Mana and gives 90% of that to the target. +1256 Infuse Mana Other III 3 Neutral Other 92 ManaTransferfromcaster 100 -1 Life Magic 30 Drains one-quarter of the caster's Mana and gives 105% of that to the target. +1257 Infuse Mana Other IV 4 Neutral Other 92 ManaTransferfromcaster 150 -1 Life Magic 40 Drains one-quarter of the caster's Mana and gives 120% of that to the target. +1258 Infuse Mana Other V 5 Neutral Other 92 ManaTransferfromcaster 200 -1 Life Magic 50 Drains one-quarter of the caster's Mana and gives 135% of that to the target. +1259 Infuse Mana Other VI 6 Neutral Other 92 ManaTransferfromcaster 250 -1 Life Magic 60 Drains one-quarter of the caster's Mana and gives 150% of that to the target. +1260 Drain Mana Other I 1 Neutral Other 91 ManaTransfertocaster 38 -1 Life Magic 10 Drains 10% of the target's Mana and gives it to the caster. +1261 Drain Mana Other II 2 Neutral Other 91 ManaTransfertocaster 88 -1 Life Magic 20 Drains 15% of the target's Mana and gives it to the caster. +1262 Drain Mana Other III 3 Neutral Other 91 ManaTransfertocaster 138 -1 Life Magic 30 Drains 20% of the target's Mana and gives it to the caster. +1263 Drain Mana Other IV 4 Neutral Other 91 ManaTransfertocaster 188 -1 Life Magic 40 Drains one-quarter of the target's Mana and gives it to the caster. +1264 Drain Mana Other V 5 Neutral Other 91 ManaTransfertocaster 238 -1 Life Magic 50 Drains 30% of the target's Mana and gives it to the caster. +1265 Drain Mana Other VI 6 Neutral Other 91 ManaTransfertocaster 288 -1 Life Magic 60 Drains 40% of the target's Mana and gives it to the caster. +1266 Health to Stamina Other I 1 Heal Other 87 HealthTransfertocaster 1 -1 Life Magic 10 Drains one-half of the target's Health and gives 75% of that to his/her Stamina. +1267 Health to Stamina Other II 2 Heal Other 87 HealthTransfertocaster 50 -1 Life Magic 20 Drains one-half of the target's Health and gives 90% of that to his/her Stamina. +1268 Health to Stamina Other III 3 Heal Other 87 HealthTransfertocaster 100 -1 Life Magic 30 Drains one-half of the target's Health and gives 105% of that to his/her Stamina. +1269 Health to Stamina Other IV 4 Heal Other 87 HealthTransfertocaster 150 -1 Life Magic 40 Drains one-half of the target's Health and gives 120% of that to his/her Stamina. +1270 Health to Stamina Other V 5 Heal Other 87 HealthTransfertocaster 200 -1 Life Magic 50 Drains one-half of the target's Health and gives 135% of that to his/her Stamina. +1271 Health to Stamina Other VI 6 Heal Other 87 HealthTransfertocaster 250 -1 Life Magic 60 Drains one-half of the target's Health and gives 150% of that to his/her Stamina. +1272 Health to Stamina Self I 1 Heal Self 87 HealthTransfertocaster 1 -1 Life Magic 10 Drains one-half of the caster's Health and gives 90% of that to his/her Stamina (maximum of 50). +1273 Health to Stamina Self II 2 Heal Self 87 HealthTransfertocaster 50 -1 Life Magic 20 Drains one-half of the caster's Health and gives 100% of that to his/her Stamina (maximum of 100). +1274 Health to Stamina Self III 3 Heal Self 87 HealthTransfertocaster 100 -1 Life Magic 30 Drains one-half of the caster's Health and gives 110% of that to his/her Stamina (maximum of 150). +1275 Health to Stamina Self IV 4 Heal Self 87 HealthTransfertocaster 150 -1 Life Magic 40 Drains one-half of the caster's Health and gives 120% of that to his/her Stamina (maximum of 200). +1276 Health to Stamina Self V 5 Heal Self 87 HealthTransfertocaster 200 -1 Life Magic 50 Drains one-half of the caster's Health and gives 135% of that to his/her Stamina. +1277 Health to Stamina Self VI 6 Heal Self 87 HealthTransfertocaster 250 -1 Life Magic 60 Drains one-half of the caster's Health and gives 150% of that to his/her Stamina. +1278 Health to Mana Self I 1 Heal Self 87 HealthTransfertocaster 1 -1 Life Magic 10 Drains one-half of the caster's Health and gives 90% of that to his/her Mana (maximum of 50). +1279 Health to Mana Self II 2 Heal Self 87 HealthTransfertocaster 50 -1 Life Magic 20 Drains one-half of the caster's Health and gives 100% of that to his/her Mana (maximum of 100). +1280 Health to Mana Self III 3 Heal Self 87 HealthTransfertocaster 100 -1 Life Magic 30 Drains one-half of the caster's Health and gives 110% of that to his/her Mana (maximum of 150). +1281 Health to Mana Other IV 4 Heal Other 87 HealthTransfertocaster 150 -1 Life Magic 40 Drains one-half of the target's Health and gives 120% of that to his/her Mana. +1282 Health to Mana Other V 5 Heal Other 87 HealthTransfertocaster 200 -1 Life Magic 50 Drains one-half of the target's Health and gives 135% of that to his/her Mana. +1283 Health to Mana Other VI 6 Heal Other 87 HealthTransfertocaster 250 -1 Life Magic 60 Drains one-half of the target's Health and gives 150% of that to his/her Mana. +1284 Mana to Health Other I 1 Neutral Other 91 ManaTransfertocaster 1 -1 Life Magic 10 Drains one-half of the target's Mana and gives 75% of that to his/her Health. +1285 Mana to Health Other II 2 Neutral Other 91 ManaTransfertocaster 50 -1 Life Magic 20 Drains one-half of the target's Mana and gives 90% of that to his/her Health. +1286 Mana to Health Other III 3 Neutral Other 91 ManaTransfertocaster 100 -1 Life Magic 30 Drains one-half of the target's Mana and gives 105% of that to his/her Health. +1287 Mana to Health Other IV 4 Neutral Other 91 ManaTransfertocaster 150 -1 Life Magic 40 Drains one-half of the target's Mana and gives 120% of that to his/her Health. +1288 Mana to Health Other V 5 Neutral Other 91 ManaTransfertocaster 200 -1 Life Magic 50 Drains one-half of the target's Mana and gives 135% of that to his/her Health. +1289 Mana to Health Other VI 6 Neutral Other 91 ManaTransfertocaster 250 -1 Life Magic 60 Drains one-half of the target's Mana and gives 150% of that to his/her Health. +1290 Mana to Health Self I 1 Neutral Self 91 ManaTransfertocaster 1 -1 Life Magic 10 Drains one-half of the caster's Mana and gives 90% of that to his/her Health (maximum of 50). +1291 Mana to Health Self II 2 Neutral Self 91 ManaTransfertocaster 50 -1 Life Magic 20 Drains one-half of the caster's Mana and gives 100% of that to his/her Health (maximum of 100). +1292 Mana to Health Self III 3 Neutral Self 91 ManaTransfertocaster 100 -1 Life Magic 30 Drains one-half of the caster's Mana and gives 110% of that to his/her Health (maximum of 150). +1293 Mana to Health Self IV 4 Neutral Self 91 ManaTransfertocaster 150 -1 Life Magic 40 Drains one-half of the caster's Mana and gives 120% of that to his/her Health (maximum of 200). +1294 Mana to Health Self V 5 Neutral Self 91 ManaTransfertocaster 200 -1 Life Magic 50 Drains one-half of the caster's Mana and gives 135% of that to his/her Health. +1295 Mana to Health Self VI 6 Neutral Self 91 ManaTransfertocaster 250 -1 Life Magic 60 Drains one-half of the caster's Mana and gives 150% of that to his/her Health. +1296 Mana to Stamina Self I 1 Neutral Self 91 ManaTransfertocaster 1 -1 Life Magic 10 Drains one-half of the caster's Mana and gives 90% of that to his/her Stamina (maximum of 50). +1297 Mana to Stamina Self II 2 Neutral Self 91 ManaTransfertocaster 50 -1 Life Magic 20 Drains one-half of the caster's Mana and gives 100% of that to his/her Stamina (maximum of 100). +1298 Mana to Stamina Self III 3 Neutral Self 91 ManaTransfertocaster 100 -1 Life Magic 30 Drains one-half of the caster's Mana and gives 110% of that to his/her Stamina (maximum of 150). +1299 Mana to Stamina Self IV 4 Neutral Self 91 ManaTransfertocaster 150 -1 Life Magic 40 Drains one-half of the caster's Mana and gives 120% of that to his/her Stamina (maximum of 200). +1300 Mana to Stamina Self V 5 Neutral Self 91 ManaTransfertocaster 200 -1 Life Magic 50 Drains one-half of the caster's Mana and gives 135% of that to his/her Stamina. +1301 Mana to Stamina Self VI 6 Neutral Self 91 ManaTransfertocaster 250 -1 Life Magic 60 Drains one-half of the caster's Mana and gives 150% of that to his/her Stamina. +1302 Mana to Stamina Other I 1 Neutral Other 91 ManaTransfertocaster 1 -1 Life Magic 10 Drains one-half of the target's Mana and gives 75% of that to his/her stamina. +1303 Mana to Stamina Other II 2 Neutral Other 91 ManaTransfertocaster 50 -1 Life Magic 20 Drains one-half of the target's Mana and gives 90% of that to his/her stamina. +1304 Mana to Stamina Other III 3 Neutral Other 91 ManaTransfertocaster 100 -1 Life Magic 30 Drains one-half of the target's Mana and gives 105% of that to his/her stamina. +1305 Mana to Stamina Other IV 4 Neutral Other 91 ManaTransfertocaster 150 -1 Life Magic 40 Drains one-half of the target's Mana and gives 120% of that to his/her stamina. +1306 Mana to Stamina Other V 5 Neutral Other 91 ManaTransfertocaster 200 -1 Life Magic 50 Drains one-half of the target's Mana and gives 135% of that to his/her stamina. +1307 Mana to Stamina Other VI 6 Neutral Other 91 ManaTransfertocaster 250 -1 Life Magic 60 Drains one-half of the target's Mana and gives 150% of that to his/her stamina. +1308 Armor Self II 2 Buff Self 115 ArmorRaising 50 1800 Life Magic 30 Increases the caster's natural armor by 50 points. +1309 Armor Self III 3 Buff Self 115 ArmorRaising 100 1800 Life Magic 40 Increases the caster's natural armor by 75 points. +1310 Armor Self IV 4 Buff Self 115 ArmorRaising 150 1800 Life Magic 50 Increases the caster's natural armor by 100 points. +1311 Armor Self V 5 Buff Self 115 ArmorRaising 200 1800 Life Magic 60 Increases the caster's natural armor by 150 points. +1312 Armor Self VI 6 Buff Self 115 ArmorRaising 250 2700 Life Magic 70 Increases the caster's natural armor by 200 points. +1313 Armor Other II 2 Buff Other 115 ArmorRaising 50 1800 Life Magic 20 Increases the target's natural armor by 50 points. +1314 Armor Other III 3 Buff Other 115 ArmorRaising 100 1800 Life Magic 30 Increases the target's natural armor by 75 points. +1315 Armor Other IV 4 Buff Other 115 ArmorRaising 150 1800 Life Magic 40 Increases the target's natural armor by 100 points. +1316 Armor Other V 5 Buff Other 115 ArmorRaising 200 1800 Life Magic 50 Increases the target's natural armor by 150 points. +1317 Armor Other VI 6 Buff Other 115 ArmorRaising 250 2700 Life Magic 60 Increases the target's natural armor by 200 points. +1318 Imperil Self II 2 Debuff Self 116 ArmorLowering 75 90 Life Magic 30 Decreases the caster's natural armor by 50 points. +1319 Imperil Self III 3 Debuff Self 116 ArmorLowering 125 120 Life Magic 40 Decreases the caster's natural armor by 75 points. +1320 Imperil Self IV 4 Debuff Self 116 ArmorLowering 175 150 Life Magic 50 Decreases the caster's natural armor by 100 points. +1321 Imperil Self V 5 Debuff Self 116 ArmorLowering 225 180 Life Magic 60 Decreases the caster's natural armor by 150 points. +1322 Imperil Self VI 6 Debuff Self 116 ArmorLowering 275 210 Life Magic 70 Decreases the caster's natural armor by 200 points. +1323 Imperil Other II 2 Debuff Other 116 ArmorLowering 75 90 Life Magic 20 Decreases the target's natural armor by 50 points. +1324 Imperil Other III 3 Debuff Other 116 ArmorLowering 125 120 Life Magic 30 Decreases the target's natural armor by 75 points. +1325 Imperil Other IV 4 Debuff Other 116 ArmorLowering 175 150 Life Magic 40 Decreases the target's natural armor by 100 points. +1326 Imperil Other V 5 Debuff Other 116 ArmorLowering 225 180 Life Magic 50 Decreases the target's natural armor by 150 points. +1327 Imperil Other VI 6 Debuff Other 116 ArmorLowering 275 210 Life Magic 60 Decreases the target's natural armor by 200 points. +1328 Strength Self II 2 Buff Self 1 StrengthRaising 50 1800 Creature Enchantment 30 Increases the caster's Strength by 15 points. +1329 Strength Self III 3 Buff Self 1 StrengthRaising 100 1800 Creature Enchantment 40 Increases the caster's Strength by 20 points. +1330 Strength Self IV 4 Buff Self 1 StrengthRaising 150 1800 Creature Enchantment 50 Increases the caster's Strength by 25 points. +1331 Strength Self V 5 Buff Self 1 StrengthRaising 200 1800 Creature Enchantment 60 Increases the caster's Strength by 30 points. +1332 Strength Self VI 6 Buff Self 1 StrengthRaising 250 2700 Creature Enchantment 70 Increases the caster's Strength by 35 points. +1333 Strength Other II 2 Buff Other 1 StrengthRaising 50 1800 Creature Enchantment 20 Increases the target's Strength by 15 points. +1334 Strength Other III 3 Buff Other 1 StrengthRaising 100 1800 Creature Enchantment 30 Increases the target's Strength by 20 points. +1335 Strength Other IV 4 Buff Other 1 StrengthRaising 150 1800 Creature Enchantment 40 Increases the target's Strength by 25 points. +1336 Strength Other V 5 Buff Other 1 StrengthRaising 200 1800 Creature Enchantment 50 Increases the target's Strength by 30 points. +1337 Strength Other VI 6 Buff Other 1 StrengthRaising 250 2700 Creature Enchantment 60 Increases the target's Strength by 35 points. +1339 Weakness Other II 2 Debuff Other 2 StrengthLowering 75 90 Creature Enchantment 20 Decreases the target's Strength by 15 points. +1340 Weakness Other III 3 Debuff Other 2 StrengthLowering 125 120 Creature Enchantment 30 Decreases the target's Strength by 20 points. +1341 Weakness Other IV 4 Debuff Other 2 StrengthLowering 175 150 Creature Enchantment 40 Decreases the target's Strength by 25 points. +1342 Weakness Other V 5 Debuff Other 2 StrengthLowering 225 180 Creature Enchantment 50 Decreases the target's Strength by 30 points. +1343 Weakness Other VI 6 Debuff Other 2 StrengthLowering 275 210 Creature Enchantment 60 Decreases the target's Strength by 35 points. +1344 Weakness Self II 2 Debuff Self 2 StrengthLowering 75 90 Creature Enchantment 30 Decrease the caster's Strength by 15 points. +1345 Weakness Self III 3 Debuff Self 2 StrengthLowering 125 120 Creature Enchantment 40 Decrease the caster's Strength by 20 points. +1346 Weakness Self IV 4 Debuff Self 2 StrengthLowering 175 150 Creature Enchantment 50 Decrease the caster's Strength by 25 points. +1347 Weakness Self V 6 Debuff Self 2 StrengthLowering 250 180 Creature Enchantment 60 Decrease the caster's Strength by 30 points. +1348 Weakness Self VI 6 Debuff Self 2 StrengthLowering 275 210 Creature Enchantment 70 Decrease the caster's Strength by 35 points. +1349 Endurance Self I 1 Buff Self 3 EnduranceRaising 1 1800 Creature Enchantment 15 Increases the caster's Endurance by 10 points. +1350 Endurance Self II 2 Buff Self 3 EnduranceRaising 50 1800 Creature Enchantment 30 Increases the caster's Endurance by 15 points. +1351 Endurance Self III 3 Buff Self 3 EnduranceRaising 100 1800 Creature Enchantment 40 Increases the caster's Endurance by 20 points. +1352 Endurance Self IV 4 Buff Self 3 EnduranceRaising 150 1800 Creature Enchantment 50 Increases the caster's Endurance by 25 points. +1353 Endurance Self V 5 Buff Self 3 EnduranceRaising 200 1800 Creature Enchantment 60 Increases the caster's Endurance by 30 points. +1354 Endurance Self VI 6 Buff Self 3 EnduranceRaising 250 2700 Creature Enchantment 70 Increases the caster's Endurance by 35 points. +1355 Endurance Other I 1 Buff Other 3 EnduranceRaising 1 1800 Creature Enchantment 10 Increases the target's Endurance by 10 points. +1356 Endurance Other II 2 Buff Other 3 EnduranceRaising 50 1800 Creature Enchantment 20 Increases the target's Endurance by 15 points. +1357 Endurance Other III 3 Buff Other 3 EnduranceRaising 100 1800 Creature Enchantment 30 Increases the target's Endurance by 20 points. +1358 Endurance Other IV 4 Buff Other 3 EnduranceRaising 150 1800 Creature Enchantment 40 Increases the target's Endurance by 25 points. +1359 Endurance Other V 5 Buff Other 3 EnduranceRaising 200 1800 Creature Enchantment 50 Increases the target's Endurance by 30 points. +1360 Endurance Other VI 6 Buff Other 3 EnduranceRaising 250 2700 Creature Enchantment 60 Increases the target's Endurance by 35 points. +1361 Frailty Self I 1 Debuff Self 4 EnduranceLowering 15 60 Creature Enchantment 15 Decreases the caster's Endurance by 10 points. +1362 Frailty Self II 2 Debuff Self 4 EnduranceLowering 75 90 Creature Enchantment 30 Decreases the caster's Endurance by 15 points. +1363 Frailty Self III 3 Debuff Self 4 EnduranceLowering 125 120 Creature Enchantment 40 Decreases the caster's Endurance by 20 points. +1364 Frailty Self IV 4 Debuff Self 4 EnduranceLowering 175 150 Creature Enchantment 50 Decreases the caster's Endurance by 25 points. +1365 Frailty Self V 6 Debuff Self 4 EnduranceLowering 250 180 Creature Enchantment 60 Decreases the caster's Endurance by 30 points. +1366 Frailty Self VI 6 Debuff Self 4 EnduranceLowering 275 210 Creature Enchantment 70 Decreases the caster's Endurance by 35 points. +1367 Frailty Other I 1 Debuff Other 4 EnduranceLowering 1 60 Creature Enchantment 10 Decreases the target's Endurance by 10 points. +1368 Frailty Other II 2 Debuff Other 4 EnduranceLowering 75 90 Creature Enchantment 20 Decreases the target's Endurance by 15 points. +1369 Frailty Other III 3 Debuff Other 4 EnduranceLowering 125 120 Creature Enchantment 30 Decreases the target's Endurance by 20 points. +1370 Frailty Other IV 4 Debuff Other 4 EnduranceLowering 175 150 Creature Enchantment 40 Decreases the target's Endurance by 25 points. +1371 Frailty Other V 5 Debuff Other 4 EnduranceLowering 225 180 Creature Enchantment 50 Decreases the target's Endurance by 30 points. +1372 Frailty Other VI 6 Debuff Other 4 EnduranceLowering 275 210 Creature Enchantment 60 Decreases the target's Endurance by 35 points. +1373 Coordination Self I 1 Buff Self 7 CoordinationRaising 1 1800 Creature Enchantment 15 Increases the caster's Coordination by 10 points. +1374 Coordination Self II 2 Buff Self 7 CoordinationRaising 50 1800 Creature Enchantment 30 Increases the caster's Coordination by 15 points. +1375 Coordination Self III 3 Buff Self 7 CoordinationRaising 100 1800 Creature Enchantment 40 Increases the caster's Coordination by 20 points. +1376 Coordination Self IV 4 Buff Self 7 CoordinationRaising 150 1800 Creature Enchantment 50 Increases the caster's Coordination by 25 points. +1377 Coordination Self V 5 Buff Self 7 CoordinationRaising 200 1800 Creature Enchantment 60 Increases the caster's Coordination by 30 points. +1378 Coordination Self VI 6 Buff Self 7 CoordinationRaising 250 2700 Creature Enchantment 70 Increases the caster's Coordination by 35 points. +1379 Coordination Other I 1 Buff Other 7 CoordinationRaising 1 1800 Creature Enchantment 10 Increases the target's Coordination by 10 points. +1380 Coordination Other II 2 Buff Other 7 CoordinationRaising 50 1800 Creature Enchantment 20 Increases the target's Coordination by 15 points. +1381 Coordination Other III 3 Buff Other 7 CoordinationRaising 100 1800 Creature Enchantment 30 Increases the target's Coordination by 20 points. +1382 Coordination Other IV 4 Buff Other 7 CoordinationRaising 150 1800 Creature Enchantment 40 Increases the target's Coordination by 25 points. +1383 Coordination Other V 5 Buff Other 7 CoordinationRaising 200 1800 Creature Enchantment 50 Increases the target's Coordination by 30 points. +1384 Coordination Other VI 6 Buff Other 7 CoordinationRaising 250 2700 Creature Enchantment 60 Increases the target's Coordination by 35 points. +1385 Clumsiness Self I 1 Debuff Self 8 CoordinationLowering 15 60 Creature Enchantment 15 Decreases the caster's Coordination by 10 points. +1386 Clumsiness Self II 2 Debuff Self 8 CoordinationLowering 75 90 Creature Enchantment 30 Decreases the caster's Coordination by 15 points. +1387 Clumsiness Self III 3 Debuff Self 8 CoordinationLowering 125 120 Creature Enchantment 40 Decreases the caster's Coordination by 20 points. +1388 Clumsiness Self IV 4 Debuff Self 8 CoordinationLowering 175 150 Creature Enchantment 50 Decreases the caster's Coordination by 25 points. +1389 Clumsiness Self V 6 Debuff Self 8 CoordinationLowering 250 180 Creature Enchantment 60 Decreases the caster's Coordination by 30 points. +1390 Clumsiness Self VI 6 Debuff Self 8 CoordinationLowering 275 210 Creature Enchantment 70 Decreases the caster's Coordination by 35 points. +1391 Clumsiness Other I 1 Debuff Other 8 CoordinationLowering 1 60 Creature Enchantment 10 Decreases the target's Coordination by 10 points. +1392 Clumsiness Other II 2 Debuff Other 8 CoordinationLowering 75 90 Creature Enchantment 20 Decreases the target's Coordination by 15 points. +1393 Clumsiness Other III 3 Debuff Other 8 CoordinationLowering 125 120 Creature Enchantment 30 Decreases the target's Coordination by 20 points. +1394 Clumsiness Other IV 4 Debuff Other 8 CoordinationLowering 175 150 Creature Enchantment 40 Decreases the target's Coordination by 25 points. +1395 Clumsiness Other V 5 Debuff Other 8 CoordinationLowering 225 180 Creature Enchantment 50 Decreases the target's Coordination by 30 points. +1396 Clumsiness Other VI 6 Debuff Other 8 CoordinationLowering 275 210 Creature Enchantment 60 Decreases the target's Coordination by 35 points. +1397 Quickness Self I 1 Buff Self 5 QuicknessRaising 1 1800 Creature Enchantment 15 Increases the caster's Quickness by 10 points. +1398 Quickness Self II 2 Buff Self 5 QuicknessRaising 50 1800 Creature Enchantment 30 Increases the caster's Quickness by 15 points. +1399 Quickness Self III 3 Buff Self 5 QuicknessRaising 100 1800 Creature Enchantment 40 Increases the caster's Quickness by 20 points. +1400 Quickness Self IV 4 Buff Self 5 QuicknessRaising 150 1800 Creature Enchantment 50 Increases the caster's Quickness by 25 points. +1401 Quickness Self V 5 Buff Self 5 QuicknessRaising 200 1800 Creature Enchantment 60 Increases the caster's Quickness by 30 points. +1402 Quickness Self VI 6 Buff Self 5 QuicknessRaising 250 2700 Creature Enchantment 70 Increases the caster's Quickness by 35 points. +1403 Quickness Other I 1 Buff Other 5 QuicknessRaising 1 1800 Creature Enchantment 10 Increases the target's Quickness by 10 points. +1404 Quickness Other II 2 Buff Other 5 QuicknessRaising 50 1800 Creature Enchantment 20 Increases the target's Quickness by 15 points. +1405 Quickness Other III 3 Buff Other 5 QuicknessRaising 100 1800 Creature Enchantment 30 Increases the target's Quickness by 20 points. +1406 Quickness Other IV 4 Buff Other 5 QuicknessRaising 150 1800 Creature Enchantment 40 Increases the target's Quickness by 25 points. +1407 Quickness Other V 5 Buff Other 5 QuicknessRaising 200 1800 Creature Enchantment 50 Increases the target's Quickness by 30 points. +1408 Quickness Other VI 6 Buff Other 5 QuicknessRaising 250 2700 Creature Enchantment 60 Increases the target's Quickness by 35 points. +1409 Slowness Self I 1 Debuff Self 6 QuicknessLowering 15 60 Creature Enchantment 15 Decreases the caster's Quickness by 10 points. +1410 Slowness Self II 2 Debuff Self 6 QuicknessLowering 75 90 Creature Enchantment 30 Decreases the caster's Quickness by 15 points. +1411 Slowness Self III 3 Debuff Self 6 QuicknessLowering 125 120 Creature Enchantment 40 Decreases the caster's Quickness by 20 points. +1412 Slowness Self IV 4 Debuff Self 6 QuicknessLowering 175 150 Creature Enchantment 50 Decreases the caster's Quickness by 25 points. +1413 Slowness Self V 6 Debuff Self 6 QuicknessLowering 250 180 Creature Enchantment 60 Decreases the caster's Quickness by 30 points. +1414 Slowness Self VI 6 Debuff Self 6 QuicknessLowering 275 210 Creature Enchantment 70 Decreases the caster's Quickness by 35 points. +1415 Slowness Other I 1 Debuff Other 6 QuicknessLowering 1 60 Creature Enchantment 10 Decreases the target's Quickness by 10 points. +1416 Slowness Other II 2 Debuff Other 6 QuicknessLowering 75 90 Creature Enchantment 20 Decreases the target's Quickness by 15 points. +1417 Slowness Other III 3 Debuff Other 6 QuicknessLowering 125 120 Creature Enchantment 30 Decreases the target's Quickness by 20 points. +1418 Slowness Other IV 4 Debuff Other 6 QuicknessLowering 175 150 Creature Enchantment 40 Decreases the target's Quickness by 25 points. +1419 Slowness Other V 5 Debuff Other 6 QuicknessLowering 225 180 Creature Enchantment 50 Decreases the target's Quickness by 30 points. +1420 Slowness Other VI 6 Debuff Other 6 QuicknessLowering 275 210 Creature Enchantment 60 Decreases the target's Quickness by 35 points. +1421 Focus Self I 1 Buff Self 9 FocusRaising 1 1800 Creature Enchantment 15 Increases the caster's Focus by 10 points. +1422 Focus Self II 2 Buff Self 9 FocusRaising 50 1800 Creature Enchantment 30 Increases the caster's Focus by 15 points. +1423 Focus Self III 3 Buff Self 9 FocusRaising 100 1800 Creature Enchantment 40 Increases the caster's Focus by 20 points. +1424 Focus Self IV 4 Buff Self 9 FocusRaising 150 1800 Creature Enchantment 50 Increases the caster's Focus by 25 points. +1425 Focus Self V 5 Buff Self 9 FocusRaising 200 1800 Creature Enchantment 60 Increases the caster's Focus by 30 points. +1426 Focus Self VI 6 Buff Self 9 FocusRaising 250 2700 Creature Enchantment 70 Increases the caster's Focus by 35 points. +1427 Focus Other I 1 Buff Other 9 FocusRaising 1 1800 Creature Enchantment 10 Increases the target's Focus by 10 points. +1428 Focus Other II 2 Buff Other 9 FocusRaising 50 1800 Creature Enchantment 20 Increases the target's Focus by 15 points. +1429 Focus Other III 3 Buff Other 9 FocusRaising 100 1800 Creature Enchantment 30 Increases the target's Focus by 20 points. +1430 Focus Other IV 4 Buff Other 9 FocusRaising 150 1800 Creature Enchantment 40 Increases the target's Focus by 25 points. +1431 Focus Other V 5 Buff Other 9 FocusRaising 200 1800 Creature Enchantment 50 Increases the target's Focus by 30 points. +1432 Focus Other VI 6 Buff Other 9 FocusRaising 250 2700 Creature Enchantment 60 Increases the target's Focus by 35 points. +1433 Bafflement Self I 1 Debuff Self 10 FocusLowering 15 60 Creature Enchantment 15 Decreases the caster's Focus by 10 points. +1434 Bafflement Self II 2 Debuff Self 10 FocusLowering 75 90 Creature Enchantment 30 Decreases the caster's Focus by 15 points. +1435 Bafflement Self III 3 Debuff Self 10 FocusLowering 125 120 Creature Enchantment 40 Decreases the caster's Focus by 20 points. +1436 Bafflement Self IV 4 Debuff Self 10 FocusLowering 175 150 Creature Enchantment 50 Decreases the caster's Focus by 25 points. +1437 Bafflement Self V 6 Debuff Self 10 FocusLowering 250 180 Creature Enchantment 60 Decreases the caster's Focus by 30 points. +1438 Bafflement Self VI 6 Debuff Self 10 FocusLowering 275 210 Creature Enchantment 70 Decreases the caster's Focus by 35 points. +1439 Bafflement Other I 1 Debuff Other 10 FocusLowering 1 60 Creature Enchantment 10 Decreases the target's Focus by 10 points. +1440 Bafflement Other II 2 Debuff Other 10 FocusLowering 75 90 Creature Enchantment 20 Decreases the target's Focus by 15 points. +1441 Bafflement Other III 3 Debuff Other 10 FocusLowering 125 120 Creature Enchantment 30 Decreases the target's Focus by 20 points. +1442 Bafflement Other IV 4 Debuff Other 10 FocusLowering 175 150 Creature Enchantment 40 Decreases the target's Focus by 25 points. +1443 Bafflement Other V 5 Debuff Other 10 FocusLowering 225 180 Creature Enchantment 50 Decreases the target's Focus by 30 points. +1444 Bafflement Other VI 6 Debuff Other 10 FocusLowering 275 210 Creature Enchantment 60 Decreases the target's Focus by 35 points. +1445 Willpower Self I 1 Buff Self 11 SelfRaising 1 1800 Creature Enchantment 15 Increases the caster's Self by 10 points. +1446 Willpower Self II 2 Buff Self 11 SelfRaising 50 1800 Creature Enchantment 30 Increases the caster's Self by 15 points. +1447 Willpower Self III 3 Buff Self 11 SelfRaising 100 1800 Creature Enchantment 40 Increases the caster's Self by 20 points. +1448 Willpower Self IV 4 Buff Self 11 SelfRaising 150 1800 Creature Enchantment 50 Increases the caster's Self by 25 points. +1449 Willpower Self V 5 Buff Self 11 SelfRaising 200 1800 Creature Enchantment 60 Increases the caster's Self by 30 points. +1450 Willpower Self VI 6 Buff Self 11 SelfRaising 250 2700 Creature Enchantment 70 Increases the caster's Self by 35 points. +1451 Willpower Other I 1 Buff Other 11 SelfRaising 1 1800 Creature Enchantment 10 Increases the target's Self by 10 points. +1452 Willpower Other II 2 Buff Other 11 SelfRaising 50 1800 Creature Enchantment 20 Increases the target's Self by 15 points. +1453 Willpower Other III 3 Buff Other 11 SelfRaising 100 1800 Creature Enchantment 30 Increases the target's Self by 20 points. +1454 Willpower Other IV 4 Buff Other 11 SelfRaising 150 1800 Creature Enchantment 40 Increases the target's Self by 25 points. +1455 Willpower Other V 5 Buff Other 11 SelfRaising 200 1800 Creature Enchantment 50 Increases the target's Self by 30 points. +1456 Willpower Other VI 6 Buff Other 11 SelfRaising 250 2700 Creature Enchantment 60 Increases the target's Self by 35 points. +1457 Feeblemind Self I 1 Debuff Self 12 SelfLowering 15 60 Creature Enchantment 15 Decreases the caster's Self by 10 points. +1458 Feeblemind Self II 2 Debuff Self 12 SelfLowering 75 90 Creature Enchantment 30 Decreases the caster's Self by 15 points. +1459 Feeblemind Self III 3 Debuff Self 12 SelfLowering 125 120 Creature Enchantment 40 Decreases the caster's Self by 20 points. +1460 Feeblemind Self IV 4 Debuff Self 12 SelfLowering 175 150 Creature Enchantment 50 Decreases the caster's Self by 25 points. +1461 Feeblemind Self V 6 Debuff Self 12 SelfLowering 250 180 Creature Enchantment 60 Decreases the caster's Self by 30 points. +1462 Feeblemind Self VI 6 Debuff Self 12 SelfLowering 275 210 Creature Enchantment 70 Decreases the caster's Self by 35 points. +1463 Feeblemind Other I 1 Debuff Other 12 SelfLowering 1 60 Creature Enchantment 10 Decreases the target's Self by 10 points. +1464 Feeblemind Other II 2 Debuff Other 12 SelfLowering 75 90 Creature Enchantment 20 Decreases the target's Self by 15 points. +1465 Feeblemind Other III 3 Debuff Other 12 SelfLowering 125 120 Creature Enchantment 30 Decreases the target's Self by 20 points. +1466 Feeblemind Other IV 4 Debuff Other 12 SelfLowering 175 150 Creature Enchantment 40 Decreases the target's Self by 25 points. +1467 Feeblemind Other V 5 Debuff Other 12 SelfLowering 225 180 Creature Enchantment 50 Decreases the target's Self by 30 points. +1468 Feeblemind Other VI 6 Debuff Other 12 SelfLowering 275 210 Creature Enchantment 60 Decreases the target's Self by 35 points. +1469 Hermetic Void I 1 Debuff Item 194 ManaConversionModLowering 25 60 Item Enchantment 10 Decreases a magic casting implement's mana conversion bonus by 10%. +1470 Hermetic Void II 2 Debuff Item 194 ManaConversionModLowering 75 90 Item Enchantment 20 Decreases a magic casting implement's mana conversion bonus by 20%. +1471 Hermetic Void III 3 Debuff Item 194 ManaConversionModLowering 125 120 Item Enchantment 30 Decreases a magic casting implement's mana conversion bonus by 30%. +1472 Hermetic Void IV 4 Debuff Item 194 ManaConversionModLowering 175 150 Item Enchantment 40 Decreases a magic casting implement's mana conversion bonus by 40%. +1473 Hermetic Void V 5 Debuff Item 194 ManaConversionModLowering 225 180 Item Enchantment 50 Decreases a magic casting implement's mana conversion bonus by 50%. +1474 Hermetic Void VI 6 Debuff Item 194 ManaConversionModLowering 275 210 Item Enchantment 60 Decreases a magic casting implement's mana conversion bonus by 60%. +1475 Aura of Hermetic Link Self I 1 Buff Self 195 ManaConversionModRaising 25 1800 Item Enchantment 10 Increases a magic casting implement's mana conversion bonus by 10%. +1476 Aura of Hermetic Link Self II 2 Buff Self 195 ManaConversionModRaising 50 1800 Item Enchantment 20 Increases a magic casting implement's mana conversion bonus by 20%. +1477 Aura of Hermetic Link Self III 3 Buff Self 195 ManaConversionModRaising 100 1800 Item Enchantment 30 Increases a magic casting implement's mana conversion bonus by 30%. +1478 Aura of Hermetic Link Self IV 4 Buff Self 195 ManaConversionModRaising 150 1800 Item Enchantment 40 Increases a magic casting implement's mana conversion bonus by 40%. +1479 Aura of Hermetic Link Self V 5 Buff Self 195 ManaConversionModRaising 200 1800 Item Enchantment 50 Increases a magic casting implement's mana conversion bonus by 50%. +1480 Aura of Hermetic Link Self VI 6 Buff Self 195 ManaConversionModRaising 250 2700 Item Enchantment 60 Increases a magic casting implement's mana conversion bonus by 60%. +1481 Flaming Missile Volley 1 Projectile Other 122 PiercingMissile 1 -1 War Magic 10 CREATURE MAGIC ONLY! +1482 Impenetrability II 2 Buff Item 160 ArmorValueRaising 50 1800 Item Enchantment 20 Improves a shield or piece of armor's armor value by 50 points. Target yourself to cast this spell on all of your equipped armor. +1483 Impenetrability III 3 Buff Item 160 ArmorValueRaising 100 1800 Item Enchantment 30 Improves a shield or piece of armor's armor value by 75 points. Target yourself to cast this spell on all of your equipped armor. +1484 Impenetrability IV 4 Buff Item 160 ArmorValueRaising 150 1800 Item Enchantment 40 Improves a shield or piece of armor's armor value by 100 points. Target yourself to cast this spell on all of your equipped armor. +1485 Impenetrability V 5 Buff Item 160 ArmorValueRaising 200 1800 Item Enchantment 50 Improves a shield or piece of armor's armor value by 150 points. Target yourself to cast this spell on all of your equipped armor. +1486 Impenetrability VI 6 Buff Item 160 ArmorValueRaising 250 2700 Item Enchantment 60 Improves a shield or piece of armor's armor value by 200 points. Target yourself to cast this spell on all of your equipped armor. +1487 Brittlemail I 1 Debuff Item 161 ArmorValueLowering 25 60 Item Enchantment 10 Worsens a shield or piece of armor's armor value by 20 points. +1488 Brittlemail II 2 Debuff Item 161 ArmorValueLowering 75 90 Item Enchantment 20 Worsens a shield or piece of armor's armor value by 50 points. +1489 Brittlemail III 3 Debuff Item 161 ArmorValueLowering 125 120 Item Enchantment 30 Worsens a shield or piece of armor's armor value by 75 points. +1490 Brittlemail IV 4 Debuff Item 161 ArmorValueLowering 175 150 Item Enchantment 40 Worsens a shield or piece of armor's armor value by 100 points. +1491 Brittlemail V 5 Debuff Item 161 ArmorValueLowering 225 180 Item Enchantment 50 Worsens a shield or piece of armor's armor value by 150 points. +1492 Brittlemail VI 6 Debuff Item 161 ArmorValueLowering 275 210 Item Enchantment 60 Worsens a shield or piece of armor's armor value by 200 points. +1493 Acid Bane I 1 Buff Item 162 AcidResistanceRaising 1 1800 Item Enchantment 10 Increases a shield or piece of armor's resistance to acid damage by 10%. Target yourself to cast this spell on all of your equipped armor. +1494 Acid Bane II 2 Buff Item 162 AcidResistanceRaising 50 1800 Item Enchantment 20 Increases a shield or piece of armor's resistance to acid damage by 25%. Target yourself to cast this spell on all of your equipped armor. +1495 Acid Bane III 3 Buff Item 162 AcidResistanceRaising 100 1800 Item Enchantment 30 Increases a shield or piece of armor's resistance to acid damage by 50%. Target yourself to cast this spell on all of your equipped armor. +1496 Acid Bane IV 4 Buff Item 162 AcidResistanceRaising 150 1800 Item Enchantment 40 Increases a shield or piece of armor's resistance to acid damage by 75%. Target yourself to cast this spell on all of your equipped armor. +1497 Acid Bane V 5 Buff Item 162 AcidResistanceRaising 200 1800 Item Enchantment 50 Increases a shield or piece of armor's resistance to acid damage by 100%. Target yourself to cast this spell on all of your equipped armor. +1498 Acid Bane VI 6 Buff Item 162 AcidResistanceRaising 250 2700 Item Enchantment 60 Increases a shield or piece of armor's resistance to acid damage by 150%. Target yourself to cast this spell on all of your equipped armor. +1499 Acid Lure I 1 Debuff Item 163 AcidResistanceLowering 25 60 Item Enchantment 10 Decreases a shield or piece of armor's resistance to acid damage by 10%. +1500 Acid Lure II 2 Debuff Item 163 AcidResistanceLowering 75 90 Item Enchantment 20 Decreases a shield or piece of armor's resistance to acid damage by 25%. +1501 Acid Lure III 3 Debuff Item 163 AcidResistanceLowering 125 120 Item Enchantment 30 Decreases a shield or piece of armor's resistance to acid damage by 50%. +1502 Acid Lure IV 4 Debuff Item 163 AcidResistanceLowering 175 150 Item Enchantment 40 Decreases a shield or piece of armor's resistance to acid damage by 75%. +1503 Acid Lure V 5 Debuff Item 163 AcidResistanceLowering 225 180 Item Enchantment 50 Decreases a shield or piece of armor's resistance to acid damage by 100%. +1504 Acid Lure VI 6 Debuff Item 163 AcidResistanceLowering 275 210 Item Enchantment 60 Decreases a shield or piece of armor's resistance to acid damage by 150%. +1505 Bludgeon Lure I 1 Debuff Item 165 BludgeonResistanceLowering 25 60 Item Enchantment 10 Decreases a shield or piece of armor's resistance to bludgeoning damage by 10%. +1506 Bludgeon Lure II 2 Debuff Item 165 BludgeonResistanceLowering 75 90 Item Enchantment 20 Decreases a shield or piece of armor's resistance to bludgeoning damage by 25%. +1507 Bludgeon Lure III 3 Debuff Item 165 BludgeonResistanceLowering 125 120 Item Enchantment 30 Decreases a shield or piece of armor's resistance to bludgeoning damage by 50%. +1508 Bludgeon Lure IV 4 Debuff Item 165 BludgeonResistanceLowering 175 150 Item Enchantment 40 Decreases a shield or piece of armor's resistance to bludgeoning damage by 75%. +1509 Bludgeon Lure V 5 Debuff Item 165 BludgeonResistanceLowering 225 180 Item Enchantment 50 Decreases a shield or piece of armor's resistance to bludgeoning damage by 100%. +1510 Bludgeon Lure VI 6 Debuff Item 165 BludgeonResistanceLowering 275 210 Item Enchantment 60 Decreases a shield or piece of armor's resistance to bludgeoning damage by 150%. +1511 Bludgeon Bane I 1 Buff Item 164 BludgeonResistanceRaising 1 1800 Item Enchantment 10 Increases a shield or piece of armor's resistance to bludgeoning damage by 10%. Target yourself to cast this spell on all of your equipped armor. +1512 Bludgeon Bane II 2 Buff Item 164 BludgeonResistanceRaising 50 1800 Item Enchantment 20 Increases a shield or piece of armor's resistance to bludgeoning damage by 25%. Target yourself to cast this spell on all of your equipped armor. +1513 Bludgeon Bane III 3 Buff Item 164 BludgeonResistanceRaising 100 1800 Item Enchantment 30 Increases a shield or piece of armor's resistance to bludgeoning damage by 50%. Target yourself to cast this spell on all of your equipped armor. +1514 Bludgeon Bane IV 4 Buff Item 164 BludgeonResistanceRaising 150 1800 Item Enchantment 40 Increases a shield or piece of armor's resistance to bludgeoning damage by 75%. Target yourself to cast this spell on all of your equipped armor. +1515 Bludgeon Bane V 5 Buff Item 164 BludgeonResistanceRaising 200 1800 Item Enchantment 50 Increases a shield or piece of armor's resistance to bludgeoning damage by 100%. Target yourself to cast this spell on all of your equipped armor. +1516 Bludgeon Bane VI 6 Buff Item 164 BludgeonResistanceRaising 250 2700 Item Enchantment 60 Increases a shield or piece of armor's resistance to bludgeoning damage by 150%. Target yourself to cast this spell on all of your equipped armor. +1517 Frost Lure I 1 Debuff Item 167 ColdResistanceLowering 25 60 Item Enchantment 10 Decreases a shield or piece of armor's resistance to cold damage by 10%. +1518 Frost Lure II 2 Debuff Item 167 ColdResistanceLowering 75 90 Item Enchantment 20 Decreases a shield or piece of armor's resistance to cold damage by 25%. +1519 Frost Lure III 3 Debuff Item 167 ColdResistanceLowering 125 120 Item Enchantment 30 Decreases a shield or piece of armor's resistance to cold damage by 50%. +1520 Frost Lure IV 4 Debuff Item 167 ColdResistanceLowering 175 150 Item Enchantment 40 Decreases a shield or piece of armor's resistance to cold damage by 75%. +1521 Frost Lure V 5 Debuff Item 167 ColdResistanceLowering 225 180 Item Enchantment 50 Decreases a shield or piece of armor's resistance to cold damage by 100%. +1522 Frost Lure VI 6 Debuff Item 167 ColdResistanceLowering 275 210 Item Enchantment 60 Decreases a shield or piece of armor's resistance to cold damage by 150%. +1523 Frost Bane I 1 Buff Item 166 ColdResistanceRaising 1 1800 Item Enchantment 10 Increases a shield or piece of armor's resistance to cold damage by 10%. Target yourself to cast this spell on all of your equipped armor. +1524 Frost Bane II 2 Buff Item 166 ColdResistanceRaising 50 1800 Item Enchantment 20 Increases a shield or piece of armor's resistance to cold damage by 25%. Target yourself to cast this spell on all of your equipped armor. +1525 Frost Bane III 3 Buff Item 166 ColdResistanceRaising 100 1800 Item Enchantment 30 Increases a shield or piece of armor's resistance to cold damage by 50%. Target yourself to cast this spell on all of your equipped armor. +1526 Frost Bane IV 4 Buff Item 166 ColdResistanceRaising 150 1800 Item Enchantment 40 Increases a shield or piece of armor's resistance to cold damage by 75%. Target yourself to cast this spell on all of your equipped armor. +1527 Frost Bane V 5 Buff Item 166 ColdResistanceRaising 200 1800 Item Enchantment 50 Increases a shield or piece of armor's resistance to cold damage by 100%. Target yourself to cast this spell on all of your equipped armor. +1528 Frost Bane VI 6 Buff Item 166 ColdResistanceRaising 250 2700 Item Enchantment 60 Increases a shield or piece of armor's resistance to cold damage by 150%. Target yourself to cast this spell on all of your equipped armor. +1529 Lightning Lure I 1 Debuff Item 169 ElectricResistanceLowering 25 60 Item Enchantment 10 Decreases a shield or piece of armor's resistance to electric damage by 10%. +1530 Lightning Lure II 2 Debuff Item 169 ElectricResistanceLowering 75 90 Item Enchantment 20 Decreases a shield or piece of armor's resistance to electric damage by 25%. +1531 Lightning Lure III 3 Debuff Item 169 ElectricResistanceLowering 125 120 Item Enchantment 30 Decreases a shield or piece of armor's resistance to electric damage by 50%. +1532 Lightning Lure IV 4 Debuff Item 169 ElectricResistanceLowering 175 150 Item Enchantment 40 Decreases a shield or piece of armor's resistance to electric damage by 75%. +1533 Lightning Lure V 5 Debuff Item 169 ElectricResistanceLowering 225 180 Item Enchantment 50 Decreases a shield or piece of armor's resistance to electric damage by 100%. +1534 Lightning Lure VI 6 Debuff Item 169 ElectricResistanceLowering 275 210 Item Enchantment 60 Decreases a shield or piece of armor's resistance to electric damage by 150%. +1535 Lightning Bane I 1 Buff Item 168 ElectricResistanceRaising 1 1800 Item Enchantment 10 Increases a shield or piece of armor's resistance to electric damage by 10%. Target yourself to cast this spell on all of your equipped armor. +1536 Lightning Bane II 2 Buff Item 168 ElectricResistanceRaising 50 1800 Item Enchantment 20 Increases a shield or piece of armor's resistance to electric damage by 25%. Target yourself to cast this spell on all of your equipped armor. +1537 Lightning Bane III 3 Buff Item 168 ElectricResistanceRaising 100 1800 Item Enchantment 30 Increases a shield or piece of armor's resistance to electric damage by 50%. Target yourself to cast this spell on all of your equipped armor. +1538 Lightning Bane IV 4 Buff Item 168 ElectricResistanceRaising 150 1800 Item Enchantment 40 Increases a shield or piece of armor's resistance to electric damage by 75%. Target yourself to cast this spell on all of your equipped armor. +1539 Lightning Bane V 5 Buff Item 168 ElectricResistanceRaising 200 1800 Item Enchantment 50 Increases a shield or piece of armor's resistance to electric damage by 100%. Target yourself to cast this spell on all of your equipped armor. +1540 Lightning Bane VI 6 Buff Item 168 ElectricResistanceRaising 250 2700 Item Enchantment 60 Increases a shield or piece of armor's resistance to electric damage by 150%. Target yourself to cast this spell on all of your equipped armor. +1541 Flame Lure I 1 Debuff Item 171 FireResistanceLowering 25 60 Item Enchantment 10 Decreases a shield or piece of armor's resistance to fire damage by 10%. +1542 Flame Lure II 2 Debuff Item 171 FireResistanceLowering 75 90 Item Enchantment 20 Decreases a shield or piece of armor's resistance to fire damage by 25%. +1543 Flame Lure III 3 Debuff Item 171 FireResistanceLowering 125 120 Item Enchantment 30 Decreases a shield or piece of armor's resistance to fire damage by 50%. +1544 Flame Lure IV 4 Debuff Item 171 FireResistanceLowering 175 150 Item Enchantment 40 Decreases a shield or piece of armor's resistance to fire damage by 75%. +1545 Flame Lure V 5 Debuff Item 171 FireResistanceLowering 225 180 Item Enchantment 50 Decreases a shield or piece of armor's resistance to fire damage by 100%. +1546 Flame Lure VI 6 Debuff Item 171 FireResistanceLowering 275 210 Item Enchantment 60 Decreases a shield or piece of armor's resistance to fire damage by 150%. +1547 Flame Bane I 1 Buff Item 170 FireResistanceRaising 1 1800 Item Enchantment 10 Increases a shield or piece of armor's resistance to fire damage by 10%. Target yourself to cast this spell on all of your equipped armor. +1548 Flame Bane II 2 Buff Item 170 FireResistanceRaising 50 1800 Item Enchantment 20 Increases a shield or piece of armor's resistance to fire damage by 25%. Target yourself to cast this spell on all of your equipped armor. +1549 Flame Bane III 3 Buff Item 170 FireResistanceRaising 100 1800 Item Enchantment 30 Increases a shield or piece of armor's resistance to fire damage by 50%. Target yourself to cast this spell on all of your equipped armor. +1550 Flame Bane IV 4 Buff Item 170 FireResistanceRaising 150 1800 Item Enchantment 40 Increases a shield or piece of armor's resistance to fire damage by 75%. Target yourself to cast this spell on all of your equipped armor. +1551 Flame Bane V 5 Buff Item 170 FireResistanceRaising 200 1800 Item Enchantment 50 Increases a shield or piece of armor's resistance to fire damage by 100%. Target yourself to cast this spell on all of your equipped armor. +1552 Flame Bane VI 6 Buff Item 170 FireResistanceRaising 250 2700 Item Enchantment 60 Increases a shield or piece of armor's resistance to fire damage by 150%. Target yourself to cast this spell on all of your equipped armor. +1553 Blade Lure II 2 Debuff Item 175 SlashResistanceLowering 75 90 Item Enchantment 20 Decreases a shield or piece of armor's resistance to slashing damage by 25%. +1554 Blade Lure III 3 Debuff Item 175 SlashResistanceLowering 125 120 Item Enchantment 30 Decreases a shield or piece of armor's resistance to slashing damage by 50%. +1555 Blade Lure IV 4 Debuff Item 175 SlashResistanceLowering 175 150 Item Enchantment 40 Decreases a shield or piece of armor's resistance to slashing damage by 75%. +1556 Blade Lure V 5 Debuff Item 175 SlashResistanceLowering 225 180 Item Enchantment 50 Decreases a shield or piece of armor's resistance to slashing damage by 100%. +1557 Blade Lure VI 6 Debuff Item 175 SlashResistanceLowering 275 210 Item Enchantment 60 Decreases a shield or piece of armor's resistance to slashing damage by 150%. +1558 Blade Bane II 2 Buff Item 174 SlashResistanceRaising 50 1800 Item Enchantment 20 Increases a shield or piece of armor's resistance to slashing damage by 25%. Target yourself to cast this spell on all of your equipped armor. +1559 Blade Bane III 3 Buff Item 174 SlashResistanceRaising 100 1800 Item Enchantment 30 Increases a shield or piece of armor's resistance to slashing damage by 50%. Target yourself to cast this spell on all of your equipped armor. +1560 Blade Bane IV 4 Buff Item 174 SlashResistanceRaising 150 1800 Item Enchantment 40 Increases a shield or piece of armor's resistance to slashing damage by 75%. Target yourself to cast this spell on all of your equipped armor. +1561 Blade Bane V 5 Buff Item 174 SlashResistanceRaising 200 1800 Item Enchantment 50 Increases a shield or piece of armor's resistance to slashing damage by 100%. Target yourself to cast this spell on all of your equipped armor. +1562 Blade Bane VI 6 Buff Item 174 SlashResistanceRaising 250 2700 Item Enchantment 60 Increases a shield or piece of armor's resistance to slashing damage by 150%. Target yourself to cast this spell on all of your equipped armor. +1563 Piercing Lure I 1 Debuff Item 173 PierceResistanceLowering 25 60 Item Enchantment 10 Decreases a shield or piece of armor's resistance to piercing damage by 10%. +1564 Piercing Lure II 2 Debuff Item 173 PierceResistanceLowering 75 90 Item Enchantment 20 Decreases a shield or piece of armor's resistance to piercing damage by 25%. +1565 Piercing Lure III 3 Debuff Item 173 PierceResistanceLowering 125 120 Item Enchantment 30 Decreases a shield or piece of armor's resistance to piercing damage by 50%. +1566 Piercing Lure IV 4 Debuff Item 173 PierceResistanceLowering 175 150 Item Enchantment 40 Decreases a shield or piece of armor's resistance to piercing damage by 75%. +1567 Piercing Lure V 5 Debuff Item 173 PierceResistanceLowering 225 180 Item Enchantment 50 Decreases a shield or piece of armor's resistance to piercing damage by 100%. +1568 Piercing Lure VI 6 Debuff Item 173 PierceResistanceLowering 275 210 Item Enchantment 60 Decreases a shield or piece of armor's resistance to piercing damage by 150%. +1569 Piercing Bane I 1 Buff Item 172 PierceResistanceRaising 1 1800 Item Enchantment 10 Increases a shield or piece of armor's resistance to piercing damage by 10%. Target yourself to cast this spell on all of your equipped armor. +1570 Piercing Bane II 2 Buff Item 172 PierceResistanceRaising 50 1800 Item Enchantment 20 Increases a shield or piece of armor's resistance to piercing damage by 25%. Target yourself to cast this spell on all of your equipped armor. +1571 Piercing Bane III 3 Buff Item 172 PierceResistanceRaising 100 1800 Item Enchantment 30 Increases a shield or piece of armor's resistance to piercing damage by 50%. Target yourself to cast this spell on all of your equipped armor. +1572 Piercing Bane IV 4 Buff Item 172 PierceResistanceRaising 150 1800 Item Enchantment 40 Increases a shield or piece of armor's resistance to piercing damage by 75%. Target yourself to cast this spell on all of your equipped armor. +1573 Piercing Bane V 5 Buff Item 172 PierceResistanceRaising 200 1800 Item Enchantment 50 Increases a shield or piece of armor's resistance to piercing damage by 100%. Target yourself to cast this spell on all of your equipped armor. +1574 Piercing Bane VI 6 Buff Item 172 PierceResistanceRaising 250 2700 Item Enchantment 60 Increases a shield or piece of armor's resistance to piercing damage by 150%. Target yourself to cast this spell on all of your equipped armor. +1575 Strengthen Lock I 1 Buff Item 192 LockpickResistanceRaising 1 780 Item Enchantment 10 Increases a lock's resistance to picking by 10 points. +1576 Strengthen Lock II 2 Buff Item 192 LockpickResistanceRaising 50 780 Item Enchantment 20 Increases a lock's resistance to picking by 25 points. +1577 Strengthen Lock III 3 Buff Item 192 LockpickResistanceRaising 100 780 Item Enchantment 30 Increases a lock's resistance to picking by 50 points. +1578 Strengthen Lock IV 4 Buff Item 192 LockpickResistanceRaising 150 780 Item Enchantment 40 Increases a lock's resistance to picking by 75 points. +1579 Strengthen Lock V 5 Buff Item 192 LockpickResistanceRaising 200 1020 Item Enchantment 50 Increases a lock's resistance to picking by 100 points. +1580 Strengthen Lock VI 6 Buff Item 192 LockpickResistanceRaising 250 1020 Item Enchantment 60 Increases a lock's resistance to picking by 150 points. +1581 Weaken Lock I 1 Debuff Item 193 LockpickResistanceLowering 1 60 Item Enchantment 10 Decreases a lock's resistance to picking by 10 points. +1582 Weaken Lock II 2 Debuff Item 193 LockpickResistanceLowering 50 90 Item Enchantment 20 Decreases a lock's resistance to picking by 25 points. +1583 Weaken Lock III 3 Debuff Item 193 LockpickResistanceLowering 100 120 Item Enchantment 30 Decreases a lock's resistance to picking by 50 points. +1584 Weaken Lock IV 4 Debuff Item 193 LockpickResistanceLowering 150 150 Item Enchantment 40 Decreases a lock's resistance to picking by 75 points. +1585 Weaken Lock V 5 Debuff Item 193 LockpickResistanceLowering 200 180 Item Enchantment 50 Decreases a lock's resistance to picking by 100 points. +1586 Weaken Lock VI 6 Debuff Item 193 LockpickResistanceLowering 250 210 Item Enchantment 60 Decreases a lock's resistance to picking by 150 points. +1587 Aura of Heart Seeker Self I 1 Buff Self 152 AttackModRaising 1 1800 Item Enchantment 10 Increases a weapon's Attack Skill modifier by 2.5 percentage points. +1588 Aura of Heart Seeker Self II 2 Buff Self 152 AttackModRaising 50 1800 Item Enchantment 20 Increases a weapon's Attack Skill modifier by 5.0 percentage points. +1589 Aura of Heart Seeker Self III 3 Buff Self 152 AttackModRaising 100 1800 Item Enchantment 30 Increases a weapon's Attack Skill modifier by 7.5 percentage points. +1590 Aura of Heart Seeker Self IV 4 Buff Self 152 AttackModRaising 150 1800 Item Enchantment 40 Increases a weapon's Attack Skill modifier by 10.0 percentage points. +1591 Aura of Heart Seeker Self V 5 Buff Self 152 AttackModRaising 200 1800 Item Enchantment 50 Increases a weapon's Attack Skill modifier by 12.5 percentage points. +1592 Aura of Heart Seeker Self VI 6 Buff Self 152 AttackModRaising 250 2700 Item Enchantment 60 Increases a weapon's Attack Skill modifier by 15.0 percentage points. +1593 Turn Blade I 1 Debuff Item 153 AttackModLowering 25 60 Item Enchantment 10 Decreases a weapon's Attack Skill modifier by 2.5 percentage points. +1594 Turn Blade II 2 Debuff Item 153 AttackModLowering 75 90 Item Enchantment 20 Decreases a weapon's Attack Skill modifier by 5.0 percentage points. +1595 Turn Blade III 3 Debuff Item 153 AttackModLowering 125 120 Item Enchantment 30 Decreases a weapon's Attack Skill modifier by 7.5 percentage points. +1596 Turn Blade IV 4 Debuff Item 153 AttackModLowering 175 150 Item Enchantment 40 Decreases a weapon's Attack Skill modifier by 10.0 percentage points. +1597 Turn Blade V 5 Debuff Item 153 AttackModLowering 225 180 Item Enchantment 60 Decreases a weapon's Attack Skill modifier by 12.5 percentage points. +1598 Turn Blade VI 6 Debuff Item 153 AttackModLowering 275 210 Item Enchantment 70 Decreases a weapon's Attack Skill modifier by 15.0 percentage points. +1599 Aura of Defender Self I 1 Buff Self 156 DefenseModRaising 1 1800 Item Enchantment 10 Increases the Melee Defense skill modifier of a weapon or magic caster by 3%. +1601 Aura of Defender Self II 2 Buff Self 156 DefenseModRaising 50 1800 Item Enchantment 20 Increases the Melee Defense skill modifier of a weapon or magic caster by 5%. +1602 Aura of Defender Self III 3 Buff Self 156 DefenseModRaising 100 1800 Item Enchantment 30 Increases the Melee Defense skill modifier of a weapon or magic caster by 7.5%. +1603 Aura of Defender Self IV 4 Buff Self 156 DefenseModRaising 150 1800 Item Enchantment 40 Increases the Melee Defense skill modifier of a weapon or magic caster by 10%. +1604 Aura of Defender Self V 5 Buff Self 156 DefenseModRaising 200 1800 Item Enchantment 50 Increases the Melee Defense skill modifier of a weapon or magic caster by 13%. +1605 Aura of Defender Self VI 6 Buff Self 156 DefenseModRaising 250 2700 Item Enchantment 60 Increases the Melee Defense skill modifier of a weapon or magic caster by 15%. +1606 Lure Blade I 1 Debuff Item 157 DefenseModLowering 25 60 Item Enchantment 10 Decreases the Melee Defense skill modifier of a weapon or magic caster by 3%. +1607 Lure Blade II 2 Debuff Item 157 DefenseModLowering 75 90 Item Enchantment 20 Decreases the Melee Defense skill modifier of a weapon or magic caster by 5%. +1608 Lure Blade III 3 Debuff Item 157 DefenseModLowering 125 120 Item Enchantment 30 Decreases the Melee Defense skill modifier of a weapon or magic caster by 7.5%. +1609 Lure Blade IV 4 Debuff Item 157 DefenseModLowering 175 150 Item Enchantment 40 Decreases the Melee Defense skill modifier of a weapon or magic caster by 10%. +1610 Lure Blade V 5 Debuff Item 157 DefenseModLowering 225 180 Item Enchantment 50 Decreases the Melee Defense skill modifier of a weapon or magic caster by 13%. +1611 Lure Blade VI 6 Debuff Item 157 DefenseModLowering 275 210 Item Enchantment 60 Decreases the Melee Defense skill modifier of a weapon or magic caster by 15%. +1612 Aura of Blood Drinker Self II 2 Buff Self 154 DamageRaising 50 1800 Item Enchantment 20 Increases a weapon's damage value by 4 points. +1613 Aura of Blood Drinker Self III 3 Buff Self 154 DamageRaising 100 1800 Item Enchantment 30 Increases a weapon's damage value by 8 points. +1614 Aura of Blood Drinker Self IV 4 Buff Self 154 DamageRaising 150 1800 Item Enchantment 40 Increases a weapon's damage value by 12 points. +1615 Aura of Blood Drinker Self V 5 Buff Self 154 DamageRaising 200 1800 Item Enchantment 50 Increases a weapon's damage value by 16 points. +1616 Aura of Blood Drinker Self VI 6 Buff Self 154 DamageRaising 250 2700 Item Enchantment 60 Increases a weapon's damage value by 20 points. +1617 Blood Loather II 2 Debuff Item 155 DamageLowering 75 90 Item Enchantment 20 Decreases a weapon's damage value by 4 points. +1618 Blood Loather III 3 Debuff Item 155 DamageLowering 125 120 Item Enchantment 30 Decreases a weapon's damage value by 8 points. +1619 Blood Loather IV 4 Debuff Item 155 DamageLowering 175 150 Item Enchantment 40 Decreases a weapon's damage value by 12 points. +1620 Blood Loather V 5 Debuff Item 155 DamageLowering 225 180 Item Enchantment 60 Decreases a weapon's damage value by 16 points. +1621 Blood Loather VI 6 Debuff Item 155 DamageLowering 275 210 Item Enchantment 70 Decreases a weapon's damage value by 20 points. +1623 Aura of Swift Killer Self II 2 Buff Self 158 WeaponTimeRaising 50 1800 Item Enchantment 20 Improves a weapon's speed by 20 points. +1624 Aura of Swift Killer Self III 3 Buff Self 158 WeaponTimeRaising 100 1800 Item Enchantment 30 Improves a weapon's speed by 30 points. +1625 Aura of Swift Killer Self IV 4 Buff Self 158 WeaponTimeRaising 150 1800 Item Enchantment 40 Improves a weapon's speed by 40 points. +1626 Aura of Swift Killer Self V 5 Buff Self 158 WeaponTimeRaising 200 1800 Item Enchantment 50 Improves a weapon's speed by 50 points. +1627 Aura of Swift Killer Self VI 6 Buff Self 158 WeaponTimeRaising 250 2700 Item Enchantment 60 Improves a weapon's speed by 60 points. +1629 Leaden Weapon II 2 Debuff Item 159 WeaponTimeLowering 75 90 Item Enchantment 20 Worsens a weapon's speed by 20 points. +1630 Leaden Weapon III 3 Debuff Item 159 WeaponTimeLowering 125 120 Item Enchantment 30 Worsens a weapon's speed by 30 points. +1631 Leaden Weapon IV 4 Debuff Item 159 WeaponTimeLowering 175 150 Item Enchantment 40 Worsens a weapon's speed by 40 points. +1632 Leaden Weapon V 5 Debuff Item 159 WeaponTimeLowering 225 180 Item Enchantment 60 Worsens a weapon's speed by 50 points. +1633 Leaden Weapon VI 6 Debuff Item 159 WeaponTimeLowering 275 210 Item Enchantment 70 Worsens a weapon's speed by 60 points. +1634 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +1635 Lifestone Recall 3 Utility Self 201 PortalRecall 100 -1 Item Enchantment 50 Transports the caster to the Lifestone to which they have previously linked. +1636 Lifestone Sending 3 Neutral Item 215 LifestoneSending 125 -1 Item Enchantment 50 Transports the target to the last Lifestone he or she used. +1637 Summon Primary Portal III 6 Utility Self 203 PortalItemCreation 250 300 Item Enchantment 110 Summons a portal that goes to the destination of the caster's linked portal. set with Primary Portal Tie. +1638 Defenselessness Self I 1 Debuff Self 40 MissileDefenseLowering 1 60 Creature Enchantment 15 Decreases the caster's Missile Defense skill by 10 points. +1639 Defenselessness Self II 2 Debuff Self 40 MissileDefenseLowering 75 90 Creature Enchantment 30 Decreases the caster's Missile Defense skill by 15 points. +1640 Defenselessness Self III 3 Debuff Self 40 MissileDefenseLowering 125 120 Creature Enchantment 40 Decreases the caster's Missile Defense skill by 20 points. +1641 Defenselessness Self IV 4 Debuff Self 40 MissileDefenseLowering 175 150 Creature Enchantment 50 Decreases the caster's Missile Defense skill by 25 points. +1642 Defenselessness Self V 5 Debuff Self 40 MissileDefenseLowering 225 180 Creature Enchantment 60 Decreases the caster's Missile Defense skill by 30 points. +1643 Defenselessness Self VI 6 Debuff Self 40 MissileDefenseLowering 275 210 Creature Enchantment 70 Decreases the caster's Missile Defense skill by 35 points. +1644 The Gift of Sarneho 6 Buff Other 77 RunRaising 250 600 Creature Enchantment 70 Makes you superfast to catch all the bad people. +1658 Stamina to Health Other I 1 Neutral Other 89 StaminaTransfertocaster 1 -1 Life Magic 10 Drains one-half of the target's Stamina and gives 75% of that to his/her Health. +1659 Stamina to Health Other II 2 Neutral Other 89 StaminaTransfertocaster 50 -1 Life Magic 20 Drains one-half of the target's Stamina and gives 90% of that to his/her Health. +1660 Stamina to Health Other III 3 Neutral Other 89 StaminaTransfertocaster 100 -1 Life Magic 30 Drains one-half of the target's Stamina and gives 105% of that to his/her Health. +1661 Stamina to Health Other IV 4 Neutral Other 89 StaminaTransfertocaster 150 -1 Life Magic 40 Drains one-half of the target's Stamina and gives 120% of that to his/her Health. +1662 Stamina to Health Other V 5 Neutral Other 89 StaminaTransfertocaster 200 -1 Life Magic 50 Drains one-half of the target's Stamina and gives 135% of that to his/her Health. +1663 Stamina to Health Other VI 6 Neutral Other 89 StaminaTransfertocaster 250 -1 Life Magic 60 Drains one-half of the target's Stamina and gives 150% of that to his/her Health. +1664 Stamina to Health Self I 1 Neutral Self 89 StaminaTransfertocaster 1 -1 Life Magic 10 Drains one-half of the caster's Stamina and gives 90% of that to his/her Health (maximum of 50). +1665 Stamina to Health Self II 2 Neutral Self 89 StaminaTransfertocaster 50 -1 Life Magic 20 Drains one-half of the caster's Stamina and gives 100% of that to his/her Health (maximum of 100). +1666 Stamina to Health Self III 3 Neutral Self 89 StaminaTransfertocaster 100 -1 Life Magic 30 Drains one-half of the caster's Stamina and gives 110% of that to his/her Health (maximum of 150). +1667 Stamina to Health Self IV 4 Neutral Self 89 StaminaTransfertocaster 150 -1 Life Magic 40 Drains one-half of the caster's Stamina and gives 120% of that to his/her Health (maximum of 200). +1668 Stamina to Health Self V 5 Neutral Self 89 StaminaTransfertocaster 200 -1 Life Magic 50 Drains one-half of the caster's Stamina and gives 135% of that to his/her Health. +1669 Stamina to Health Self VI 6 Neutral Self 89 StaminaTransfertocaster 250 -1 Life Magic 60 Drains one-half of the caster's Stamina and gives 150% of that to his/her Health. +1670 Stamina to Mana Other I 1 Neutral Other 89 StaminaTransfertocaster 1 -1 Life Magic 10 Drains one-half of the target's Stamina and gives 75% of that to his/her Mana. +1671 Stamina to Mana Other II 2 Neutral Other 89 StaminaTransfertocaster 50 -1 Life Magic 20 Drains one-half of the target's Stamina and gives 90% of that to his/her Mana. +1672 Stamina to Mana Other III 3 Neutral Other 89 StaminaTransfertocaster 100 -1 Life Magic 30 Drains one-half of the target's Stamina and gives 105% of that to his/her Mana. +1673 Stamina to Mana Other IV 4 Neutral Other 89 StaminaTransfertocaster 150 -1 Life Magic 40 Drains one-half of the target's Stamina and gives 120% of that to his/her Mana. +1674 Stamina to Mana Other V 5 Neutral Other 89 StaminaTransfertocaster 200 -1 Life Magic 50 Drains one-half of the target's Stamina and gives 135% of that to his/her Mana. +1675 Stamina to Mana Other VI 6 Neutral Other 89 StaminaTransfertocaster 250 -1 Life Magic 60 Drains one-half of the target's Stamina and gives 150% of that to his/her Mana. +1676 Stamina to Mana Self I 1 Neutral Self 89 StaminaTransfertocaster 1 -1 Life Magic 10 Drains one-half of the caster's Stamina and gives 90% of that to his/her Mana (maximum of 50). +1677 Stamina to Mana Self II 2 Neutral Self 89 StaminaTransfertocaster 50 -1 Life Magic 20 Drains one-half of the caster's Stamina and gives 100% of that to his/her Mana (maximum of 100). +1678 Stamina to Mana Self III 3 Neutral Self 89 StaminaTransfertocaster 100 -1 Life Magic 30 Drains one-half of the caster's Stamina and gives 110% of that to his/her Mana (maximum of 150). +1679 Stamina to Mana Self IV 4 Neutral Self 89 StaminaTransfertocaster 150 -1 Life Magic 40 Drains one-half of the caster's Stamina and gives 120% of that to his/her Mana (maximum of 200). +1680 Stamina to Mana Self V 5 Neutral Self 89 StaminaTransfertocaster 200 -1 Life Magic 50 Drains one-half of the caster's Stamina and gives 135% of that to his/her Mana. +1681 Stamina to Mana Self VI 6 Neutral Self 89 StaminaTransfertocaster 250 -1 Life Magic 60 Drains one-half of the caster's Stamina and gives 150% of that to his/her Mana. +1702 Health to Mana Self IV 4 Heal Self 87 HealthTransfertocaster 150 -1 Life Magic 40 Drains one-half of the caster's Health and gives 120% of that to his/her Mana (maximum of 200). +1703 Health to Mana Self V 5 Heal Self 87 HealthTransfertocaster 200 -1 Life Magic 50 Drains one-half of the caster's Health and gives 135% of that to his/her Mana. +1704 Health to Mana Self VI 6 Heal Self 87 HealthTransfertocaster 250 -1 Life Magic 60 Drains one-half of the caster's Health and gives 150% of that to his/her Mana. +1705 Health to Mana Other I 1 Heal Other 87 HealthTransfertocaster 1 -1 Life Magic 10 Drains one-half of the target's Health and gives 75% of that to his/her Mana. +1706 Health to Mana Other II 2 Heal Other 87 HealthTransfertocaster 50 -1 Life Magic 20 Drains one-half of the target's Health and gives 90% of that to his/her Mana. +1707 Health to Mana Other III 3 Heal Other 87 HealthTransfertocaster 100 -1 Life Magic 30 Drains one-half of the target's Health and gives 105% of that to his/her Mana. +1708 Wedding Bliss 1 Buff Other 67 HealingRaising 1 -1 Life Magic 15 This is a gem that spectacularly symbolizes all the joys and challenges of marriage. It is a one-use item. so use it wisely to mark your commitment to share your life with another. Best used outdoors. in the open. +1709 Cooking Mastery Other I 1 Buff Other 216 CookingRaising 1 1800 Creature Enchantment 10 Increases the target's Cooking skill by 10 points. +1710 Cooking Mastery Other II 2 Buff Other 216 CookingRaising 50 1800 Creature Enchantment 20 Increases the target's Cooking skill by 15 points. +1711 Cooking Mastery Other III 3 Buff Other 216 CookingRaising 100 1800 Creature Enchantment 30 Increases the target's Cooking skill by 20 points. +1712 Cooking Mastery Other IV 4 Buff Other 216 CookingRaising 150 1800 Creature Enchantment 40 Increases the target's Cooking skill by 25 points. +1713 Cooking Mastery Other V 5 Buff Other 216 CookingRaising 200 1800 Creature Enchantment 50 Increases the target's Cooking skill by 30 points. +1714 Cooking Mastery Other VI 6 Buff Other 216 CookingRaising 250 2700 Creature Enchantment 60 Increases the target's Cooking skill by 35 points. +1715 Cooking Mastery Self I 1 Buff Self 216 CookingRaising 1 1800 Creature Enchantment 15 Increases the caster's Cooking skill by 10 points. +1716 Cooking Mastery Self II 2 Buff Self 216 CookingRaising 50 1800 Creature Enchantment 30 Increases the caster's Cooking skill by 15 points. +1717 Cooking Mastery Self III 3 Buff Self 216 CookingRaising 100 1800 Creature Enchantment 40 Increases the caster's Cooking skill by 20 points. +1718 Cooking Mastery Self IV 4 Buff Self 216 CookingRaising 150 1800 Creature Enchantment 50 Increases the caster's Cooking skill by 25 points. +1719 Cooking Mastery Self V 5 Buff Self 216 CookingRaising 200 1800 Creature Enchantment 60 Increases the caster's Cooking skill by 30 points. +1720 Cooking Mastery Self VI 6 Buff Self 216 CookingRaising 250 2700 Creature Enchantment 70 Increases the caster's Cooking skill by 35 points. +1721 Cooking Ineptitude Other I 1 Debuff Other 217 CookingLowering 1 60 Creature Enchantment 10 Decreases the target's Cooking skill by 10 points. +1722 Cooking Ineptitude Other II 2 Debuff Other 217 CookingLowering 75 90 Creature Enchantment 20 Decreases the target's Cooking skill by 15 points. +1723 Cooking Ineptitude Other III 3 Debuff Other 217 CookingLowering 125 120 Creature Enchantment 30 Decreases the target's Cooking skill by 20 points. +1724 Cooking Ineptitude Other IV 4 Debuff Other 217 CookingLowering 175 150 Creature Enchantment 40 Decreases the target's Cooking skill by 25 points. +1725 Cooking Ineptitude Other V 5 Debuff Other 217 CookingLowering 225 180 Creature Enchantment 50 Decreases the target's Cooking skill by 30 points. +1726 Cooking Ineptitude Other VI 6 Debuff Other 217 CookingLowering 275 210 Creature Enchantment 60 Decreases the target's Cooking skill by 35 points. +1727 Cooking Ineptitude Self I 1 Debuff Self 217 CookingLowering 1 60 Creature Enchantment 15 Decreases the caster's Cooking skill by 10 points. +1728 Cooking Ineptitude Self II 2 Debuff Self 217 CookingLowering 75 90 Creature Enchantment 30 Decreases the caster's Cooking skill by 15 points. +1729 Cooking Ineptitude Self III 3 Debuff Self 217 CookingLowering 125 120 Creature Enchantment 40 Decreases the caster's Cooking skill by 20 points. +1730 Cooking Ineptitude Self IV 4 Debuff Self 217 CookingLowering 175 150 Creature Enchantment 50 Decreases the caster's Cooking skill by 25 points. +1731 Cooking Ineptitude Self V 5 Debuff Self 217 CookingLowering 225 180 Creature Enchantment 60 Decreases the caster's Cooking skill by 30 points. +1732 Cooking Ineptitude Self VI 6 Debuff Self 217 CookingLowering 275 210 Creature Enchantment 70 Decreases the caster's Cooking skill by 35 points. +1733 Fletching Mastery Other I 1 Buff Other 218 FletchingRaising 1 1800 Creature Enchantment 10 Increases the target's Fletching skill by 10 points. +1734 Fletching Mastery Other II 2 Buff Other 218 FletchingRaising 50 1800 Creature Enchantment 20 Increases the target's Fletching skill by 15 points. +1735 Fletching Mastery Other III 3 Buff Other 218 FletchingRaising 100 1800 Creature Enchantment 30 Increases the target's Fletching skill by 20 points. +1736 Fletching Mastery Other IV 4 Buff Other 218 FletchingRaising 150 1800 Creature Enchantment 40 Increases the target's Fletching skill by 25 points. +1737 Fletching Mastery Other V 5 Buff Other 218 FletchingRaising 200 1800 Creature Enchantment 50 Increases the target's Fletching skill by 30 points. +1738 Fletching Mastery Other VI 6 Buff Other 218 FletchingRaising 250 2700 Creature Enchantment 60 Increases the target's Fletching skill by 35 points. +1739 Fletching Mastery Self I 1 Buff Self 218 FletchingRaising 1 1800 Creature Enchantment 15 Increases the caster's Fletching skill by 10 points. +1740 Fletching Mastery Self II 2 Buff Self 218 FletchingRaising 50 1800 Creature Enchantment 30 Increases the caster's Fletching skill by 15 points. +1741 Fletching Mastery Self III 3 Buff Self 218 FletchingRaising 100 1800 Creature Enchantment 40 Increases the caster's Fletching skill by 20 points. +1742 Fletching Mastery Self IV 4 Buff Self 218 FletchingRaising 150 1800 Creature Enchantment 50 Increases the caster's Fletching skill by 25 points. +1743 Fletching Mastery Self V 5 Buff Self 218 FletchingRaising 200 1800 Creature Enchantment 60 Increases the caster's Fletching skill by 30 points. +1744 Fletching Mastery Self VI 6 Buff Self 218 FletchingRaising 250 2700 Creature Enchantment 70 Increases the caster's Fletching skill by 35 points. +1745 Fletching Ineptitude Other I 1 Debuff Other 219 FletchingLowering 1 60 Creature Enchantment 10 Decreases the target's Fletching skill by 10 points. +1746 Fletching Ineptitude Other II 2 Debuff Other 219 FletchingLowering 75 90 Creature Enchantment 20 Decreases the target's Fletching skill by 15 points. +1747 Fletching Ineptitude Other III 3 Debuff Other 219 FletchingLowering 125 120 Creature Enchantment 30 Decreases the target's Fletching skill by 20 points. +1748 Fletching Ineptitude Other IV 4 Debuff Other 219 FletchingLowering 175 150 Creature Enchantment 40 Decreases the target's Fletching skill by 25 points. +1749 Fletching Ineptitude Other V 5 Debuff Other 219 FletchingLowering 225 180 Creature Enchantment 50 Decreases the target's Fletching skill by 30 points. +1750 Fletching Ineptitude Other VI 6 Debuff Other 219 FletchingLowering 275 210 Creature Enchantment 60 Decreases the target's Fletching skill by 35 points. +1751 Fletching Ineptitude Self I 1 Debuff Self 219 FletchingLowering 1 60 Creature Enchantment 15 Decreases the caster's Fletching skill by 10 points. +1752 Fletching Ineptitude Self II 2 Debuff Self 219 FletchingLowering 75 90 Creature Enchantment 30 Decreases the caster's Fletching skill by 15 points. +1753 Fletching Ineptitude Self III 3 Debuff Self 219 FletchingLowering 125 120 Creature Enchantment 40 Decreases the caster's Fletching skill by 20 points. +1754 Fletching Ineptitude Self IV 4 Debuff Self 219 FletchingLowering 175 150 Creature Enchantment 50 Decreases the caster's Fletching skill by 25 points. +1755 Fletching Ineptitude Self V 5 Debuff Self 219 FletchingLowering 225 180 Creature Enchantment 60 Decreases the caster's Fletching skill by 30 points. +1756 Fletching Ineptitude Self VI 6 Debuff Self 219 FletchingLowering 275 210 Creature Enchantment 70 Decreases the caster's Fletching skill by 35 points. +1757 Alchemy Mastery Other I 1 Buff Other 221 AlchemyRaising 1 1800 Creature Enchantment 10 Increases the target's Alchemy skill by 10 points. +1758 Alchemy Mastery Other II 2 Buff Other 221 AlchemyRaising 50 1800 Creature Enchantment 20 Increases the target's Alchemy skill by 15 points. +1759 Alchemy Mastery Other III 3 Buff Other 221 AlchemyRaising 100 1800 Creature Enchantment 30 Increases the target's Alchemy skill by 20 points. +1760 Alchemy Mastery Other IV 4 Buff Other 221 AlchemyRaising 150 1800 Creature Enchantment 40 Increases the target's Alchemy skill by 25 points. +1761 Alchemy Mastery Other V 5 Buff Other 221 AlchemyRaising 200 1800 Creature Enchantment 50 Increases the target's Alchemy skill by 30 points. +1762 Alchemy Mastery Other VI 6 Buff Other 221 AlchemyRaising 250 2700 Creature Enchantment 60 Increases the target's Alchemy skill by 35 points. +1763 Alchemy Mastery Self I 1 Buff Self 221 AlchemyRaising 1 1800 Creature Enchantment 15 Increases the caster's Alchemy skill by 10 points. +1764 Alchemy Mastery Self II 2 Buff Self 221 AlchemyRaising 50 1800 Creature Enchantment 30 Increases the caster's Alchemy skill by 15 points. +1765 Alchemy Mastery Self III 3 Buff Self 221 AlchemyRaising 100 1800 Creature Enchantment 40 Increases the caster's Alchemy skill by 20 points. +1766 Alchemy Mastery Self IV 4 Buff Self 221 AlchemyRaising 150 1800 Creature Enchantment 50 Increases the caster's Alchemy skill by 25 points. +1767 Alchemy Mastery Self V 5 Buff Self 221 AlchemyRaising 200 1800 Creature Enchantment 60 Increases the caster's Alchemy skill by 30 points. +1768 Alchemy Mastery Self VI 6 Buff Self 221 AlchemyRaising 250 2700 Creature Enchantment 70 Increases the caster's Alchemy skill by 35 points. +1769 Alchemy Ineptitude Other I 1 Debuff Other 220 AlchemyLowering 1 60 Creature Enchantment 10 Decreases the target's Alchemy skill by 10 points. +1770 Alchemy Ineptitude Other II 2 Debuff Other 220 AlchemyLowering 75 90 Creature Enchantment 20 Decreases the target's Alchemy skill by 15 points. +1771 Alchemy Ineptitude Other III 3 Debuff Other 220 AlchemyLowering 125 120 Creature Enchantment 30 Decreases the target's Alchemy skill by 20 points. +1772 Alchemy Ineptitude Other IV 4 Debuff Other 220 AlchemyLowering 175 150 Creature Enchantment 40 Decreases the target's Alchemy skill by 25 points. +1773 Alchemy Ineptitude Other V 5 Debuff Other 220 AlchemyLowering 225 180 Creature Enchantment 50 Decreases the target's Alchemy skill by 30 points. +1774 Alchemy Ineptitude Other VI 6 Debuff Other 220 AlchemyLowering 275 210 Creature Enchantment 60 Decreases the target's Alchemy skill by 35 points. +1775 Alchemy Ineptitude Self I 1 Debuff Self 220 AlchemyLowering 1 60 Creature Enchantment 15 Decreases the caster's Alchemy skill by 10 points. +1776 Alchemy Ineptitude Self II 2 Debuff Self 220 AlchemyLowering 75 90 Creature Enchantment 30 Decreases the caster's Alchemy skill by 15 points. +1777 Alchemy Ineptitude Self III 3 Debuff Self 220 AlchemyLowering 125 120 Creature Enchantment 40 Decreases the caster's Alchemy skill by 20 points. +1778 Alchemy Ineptitude Self IV 4 Debuff Self 220 AlchemyLowering 175 150 Creature Enchantment 50 Decreases the caster's Alchemy skill by 25 points. +1779 Alchemy Ineptitude Self V 5 Debuff Self 220 AlchemyLowering 225 180 Creature Enchantment 60 Decreases the caster's Alchemy skill by 30 points. +1780 Alchemy Ineptitude Self VI 6 Debuff Self 220 AlchemyLowering 275 210 Creature Enchantment 70 Decreases the caster's Alchemy skill by 35 points. +1781 Exploding Magma 6 Neutral Other 135 FireBurst 275 -1 War Magic 30 Exploding magma from unstable golems! +1782 Gertarh's Curse 5 Debuff Other 76 LoyaltyLowering 225 780 Creature Enchantment 50 Decreases your Loyalty skill by 30 points. +1783 Searing Disc 5 Neutral Other 222 AcidRing 200 -1 War Magic 80 Shoots eight waves of acid outward from the caster. Each wave does 42-84 points of acid damage to the first thing it hits. +1784 Horizon's Blades 5 Neutral Other 228 SlashingRing 200 -1 War Magic 80 Shoots eight blades outward from the caster. Each blade does 42-84 points of slashing damage to the first thing it hits. +1785 Cassius' Ring of Fire 5 Projectile Other 226 FireRing 200 -1 War Magic 80 Shoots eight waves of flame outward from the caster. Each wave does 42-84 points of fire damage to the first thing it hits. +1786 Nuhmudira's Spines 5 Neutral Other 227 PiercingRing 200 -1 War Magic 80 Shoots eight waves of force outward from the caster. Each wave does 42-84 points of piercing damage to the first thing it hits. +1787 Halo of Frost 5 Neutral Other 224 ColdRing 200 -1 War Magic 80 Shoots eight waves of frost outward from the caster. Each wave does 42-84 points of cold damage to the first thing it hits. +1788 Eye of the Storm 5 Neutral Other 225 ElectricRing 200 -1 War Magic 80 Shoots eight waves of lightning outward from the caster. Each wave does 42-84 points of electric damage to the first thing it hits. +1789 Tectonic Rifts 5 Neutral Other 223 BludgeoningRing 200 -1 War Magic 80 Shoots eight shock waves outward from the caster. Each wave does 42-84 points of bludgeoning damage to the first thing it hits. +1790 Acid Streak I 1 Projectile Other 243 AcidStreak 1 -1 War Magic 10 Sends a stream of acid streaking towards the target. The stream does 16-31 points of acid damage to the first thing it hits. +1791 Acid Streak II 2 Projectile Other 243 AcidStreak 50 -1 War Magic 20 Sends a stream of acid streaking towards the target. The stream does 18-35 points of acid damage to the first thing it hits. +1792 Acid Streak III 3 Projectile Other 243 AcidStreak 100 -1 War Magic 30 Sends a stream of acid streaking towards the target. The stream does 21-42 points of acid damage to the first thing it hits. +1793 Acid Streak IV 4 Projectile Other 243 AcidStreak 150 -1 War Magic 40 Sends a stream of acid streaking towards the target. The stream does 25-50 points of acid damage to the first thing it hits. +1794 Acid Streak V 5 Projectile Other 243 AcidStreak 200 -1 War Magic 50 Sends a stream of acid streaking towards the target. The stream does 29-59 points of acid damage to the first thing it hits. +1795 Acid Streak VI 6 Projectile Other 243 AcidStreak 250 -1 War Magic 60 Sends a stream of acid streaking towards the target. The stream does 36-71 points of acid damage to the first thing it hits. +1796 Flame Streak I 1 Projectile Other 247 FireStreak 1 -1 War Magic 10 Sends a bolt of flame streaking towards the target. The bolt does 16-31 points of fire damage to the first thing it hits. +1797 Flame Streak II 2 Projectile Other 247 FireStreak 50 -1 War Magic 20 Sends a bolt of flame streaking towards the target. The bolt does 18-35 points of fire damage to the first thing it hits. +1798 Flame Streak III 3 Projectile Other 247 FireStreak 100 -1 War Magic 30 Sends a bolt of flame streaking towards the target. The bolt does 21-42 points of fire damage to the first thing it hits. +1799 Flame Streak IV 4 Projectile Other 247 FireStreak 150 -1 War Magic 40 Sends a bolt of flame streaking towards the target. The bolt does 25-50 points of fire damage to the first thing it hits. +1800 Flame Streak V 5 Projectile Other 247 FireStreak 200 -1 War Magic 50 Sends a bolt of flame streaking towards the target. The bolt does 29-59 points of fire damage to the first thing it hits. +1801 Flame Streak VI 6 Projectile Other 247 FireStreak 250 -1 War Magic 60 Sends a bolt of flame streaking towards the target. The bolt does 36-71 points of fire damage to the first thing it hits. +1802 Force Streak I 1 Projectile Other 248 PiercingStreak 1 -1 War Magic 10 Sends a bolt of force streaking towards the target. The bolt does 16-31 points of piercing damage to the first thing it hits. +1803 Force Streak II 2 Projectile Other 248 PiercingStreak 50 -1 War Magic 20 Sends a bolt of force streaking towards the target. The bolt does 18-35 points of piercing damage to the first thing it hits. +1804 Force Streak III 3 Projectile Other 248 PiercingStreak 100 -1 War Magic 30 Sends a bolt of force streaking towards the target. The bolt does 21-42 points of piercing damage to the first thing it hits. +1805 Force Streak IV 4 Projectile Other 248 PiercingStreak 150 -1 War Magic 40 Sends a bolt of force streaking towards the target. The bolt does 25-50 points of piercing damage to the first thing it hits. +1806 Force Streak V 5 Projectile Other 248 PiercingStreak 200 -1 War Magic 50 Sends a bolt of force streaking towards the target. The bolt does 29-59 points of piercing damage to the first thing it hits. +1807 Force Streak VI 6 Projectile Other 248 PiercingStreak 250 -1 War Magic 60 Sends a bolt of force streaking towards the target. The bolt does 36-71 points of piercing damage to the first thing it hits. +1808 Frost Streak I 1 Projectile Other 245 ColdStreak 1 -1 War Magic 10 Sends a bolt of frost streaking towards the target. The bolt does 16-31 points of cold damage to the first thing it hits. +1809 Frost Streak II 2 Projectile Other 245 ColdStreak 50 -1 War Magic 20 Sends a bolt of frost streaking towards the target. The bolt does 18-35 points of cold damage to the first thing it hits. +1810 Frost Streak III 3 Projectile Other 245 ColdStreak 100 -1 War Magic 30 Sends a bolt of cold streaking towards the target. The bolt does 21-42 points of cold damage to the first thing it hits. +1811 Frost Streak IV 4 Projectile Other 245 ColdStreak 150 -1 War Magic 40 Sends a bolt of cold streaking towards the target. The bolt does 25-50 points of cold damage to the first thing it hits. +1812 Frost Streak V 5 Projectile Other 245 ColdStreak 200 -1 War Magic 50 Sends a bolt of cold streaking towards the target. The bolt does 29-59 points of cold damage to the first thing it hits. +1813 Frost Streak VI 6 Projectile Other 245 ColdStreak 250 -1 War Magic 60 Sends a bolt of cold streaking towards the target. The bolt does 36-71 points of cold damage to the first thing it hits. +1814 Lightning Streak I 1 Projectile Other 246 ElectricStreak 1 -1 War Magic 10 Sends a bolt of lighting streaking towards the target. The bolt does 16-31 points of electrical damage to the first thing it hits. +1815 Lightning Streak II 2 Projectile Other 246 ElectricStreak 50 -1 War Magic 20 Sends a bolt of lighting streaking towards the target. The bolt does 18-35 points of electrical damage to the first thing it hits. +1816 Lightning Streak III 3 Projectile Other 246 ElectricStreak 100 -1 War Magic 30 Sends a bolt of lighting streaking towards the target. The bolt does 21-42 points of electrical damage to the first thing it hits. +1817 Lightning Streak IV 4 Projectile Other 246 ElectricStreak 150 -1 War Magic 40 Sends a bolt of lighting streaking towards the target. The bolt does 25-50 points of electrical damage to the first thing it hits. +1818 Lightning Streak V 5 Projectile Other 246 ElectricStreak 200 -1 War Magic 50 Sends a bolt of lighting streaking towards the target. The bolt does 29-59 points of electrical damage to the first thing it hits. +1819 Lightning Streak VI 6 Projectile Other 246 ElectricStreak 250 -1 War Magic 60 Sends a bolt of lighting streaking towards the target. The bolt does 36-71 points of electrical damage to the first thing it hits. +1820 Shock Wave Streak I 1 Projectile Other 244 BludgeoningStreak 1 -1 War Magic 10 Sends a shock wave streaking towards the target. The wave does 16-31 points of bludgeoning damage to the first thing it hits. +1821 Shock Wave Streak II 2 Projectile Other 244 BludgeoningStreak 50 -1 War Magic 20 Sends a shock wave streaking towards the target. The wave does 18-35 points of bludgeoning damage to the first thing it hits. +1822 Shock Wave Streak III 3 Projectile Other 244 BludgeoningStreak 100 -1 War Magic 30 Sends a shock wave streaking towards the target. The wave does 21-42 points of bludgeoning damage to the first thing it hits. +1823 Shock Wave Streak IV 4 Projectile Other 244 BludgeoningStreak 150 -1 War Magic 40 Sends a shock wave streaking towards the target. The wave does 25-50 points of bludgeoning damage to the first thing it hits. +1824 Shock Wave Streak V 5 Projectile Other 244 BludgeoningStreak 200 -1 War Magic 50 Sends a shock wave streaking towards the target. The wave does 29-59 points of bludgeoning damage to the first thing it hits. +1825 Shock Wave Streak VI 6 Projectile Other 244 BludgeoningStreak 250 -1 War Magic 60 Sends a shock wave streaking towards the target. The wave does 36-71 points of bludgeoning damage to the first thing it hits. +1826 Whirling Blade Streak I 1 Projectile Other 249 SlashingStreak 1 -1 War Magic 10 Sends a magical blade streaking towards the target. The bolt does 16-31 points of slashing damage to the first thing it hits. +1827 Whirling Blade Streak II 2 Projectile Other 249 SlashingStreak 50 -1 War Magic 20 Sends a magical blade streaking towards the target. The bolt does 18-35 points of slashing damage to the first thing it hits. +1828 Whirling Blade Streak III 3 Projectile Other 249 SlashingStreak 100 -1 War Magic 30 Sends a magical blade streaking towards the target. The bolt does 21-42 points of slashing damage to the first thing it hits. +1829 Whirling Blade Streak IV 4 Projectile Other 249 SlashingStreak 150 -1 War Magic 40 Sends a magical blade streaking towards the target. The bolt does 25-50 points of slashing damage to the first thing it hits. +1830 Whirling Blade Streak V 5 Projectile Other 249 SlashingStreak 200 -1 War Magic 50 Sends a magical blade streaking towards the target. The bolt does 29-59 points of slashing damage to the first thing it hits. +1831 Whirling Blade Streak VI 6 Projectile Other 249 SlashingStreak 250 -1 War Magic 60 Sends a magical blade streaking towards the target. The bolt does 36-71 points of slashing damage to the first thing it hits. +1832 Torrential Acid 7 Neutral Other 236 AcidStrike 320 -1 War Magic 120 Rains nine streams of acid down at the area around the target. Each stream does 60-120 points of acid damage to the first thing it hits. +1833 Squall of Swords 7 Neutral Other 242 SlashingStrike 320 -1 War Magic 120 Rains nine whirling blades down at the area around the target. Each blade does 60-120 points of slashing damage to the first thing it hits. +1834 Firestorm 7 Neutral Other 240 FireStrike 320 -1 War Magic 120 Rains nine balls of flame down at the area around the target. Each ball does 60-120 points of fire damage to the first thing it hits. +1835 Splinterfall 7 Neutral Other 241 PiercingStrike 320 -1 War Magic 120 Rains nine bolts of force down at the area around the target. Each bolt does 60-120 points of piercing damage to the first thing it hits. +1836 Avalanche 7 Neutral Other 238 ColdStrike 320 -1 War Magic 120 Rains up to twelve balls of frost down at the area around the target. Each ball does 60-120 points of cold damage to the first thing it hits. This spell is not very accurate. and cannot be used indoors. +1837 Lightning Barrage 7 Neutral Other 239 ElectricStrike 320 -1 War Magic 120 Rains nine bolts of lightning down at the area around the target. Each bolt does 60-120 points of electric damage to the first thing it hits. +1838 Stone Fists 7 Neutral Other 237 BludgeoningStrike 320 -1 War Magic 120 Rains nine boulders down at the area around the target. Each boulder does 60-120 points of bludgeoning damage to the first thing it hits. +1839 Blistering Creeper 5 Neutral Other 229 AcidWall 200 -1 War Magic 80 Sends a wall of five balls of acid. two high. slowly towards the target. Each ball does 35-70 points of acid damage to the first thing it hits. The wall is created 2 meters in front of the caster. +1840 Bed of Blades 5 Neutral Other 235 SlashingWall 200 -1 War Magic 80 Sends a wall of five whirling blades. two high. slowly towards the target. Each blade does 35-70 points of slashing damage to the first thing it hits. The wall is created 2 meters in front of the caster. +1841 Slithering Flames 5 Neutral Other 233 FireWall 200 -1 War Magic 80 Sends a wall of five balls of fire. two high. slowly towards the target. Each ball does 35-70 points of fire damage to the first thing it hits. The wall is created 2 meters in front of the caster. +1842 Spike Strafe 5 Neutral Other 234 PiercingWall 200 -1 War Magic 80 Sends a wall of five bolts of force. two high. slowly towards the target. Each bolt does 35-70 points of piercing damage to the first thing it hits. The wall is created 2 meters in front of the caster. +1843 Foon-Ki's Glacial Floe 5 Neutral Other 231 ColdWall 200 -1 War Magic 80 Sends a wall of five balls of frost. two high. slowly towards the target. Each ball does 35-70 points of cold damage to the first thing it hits. The wall is created 2 meters in front of the caster. +1844 Os' Wall 5 Neutral Other 232 ElectricWall 200 -1 War Magic 80 Sends a wall of five bolts of lightning. two high. slowly towards the target. Each ball does 35-70 points of electric damage to the first thing it hits. The wall is created 2 meters in front of the caster. +1845 Hammering Crawler 5 Neutral Other 230 BludgeoningWall 200 -1 War Magic 80 Sends a wall of five shockwaves. two high. slowly towards the target. Each wave does 35-70 points of bludgeoning damage to the first thing it hits. The wall is created 2 meters in front of the caster. +1846 Curse of Black Fire 2 Debuff Other 42 MagicDefenseLowering 50 1020 Creature Enchantment 60 Decreases the target's Magic Defense skill by 10 points. +1847 Evaporate All Magic Other 2 Utility Other 250 Dispel 50 -1 Life Magic 50 Dispels all enchantments of level 1 from the target. +1848 Evaporate All Magic Other 2 Utility Other 250 Dispel 50 -1 Life Magic 50 Dispels 1-3 positive enchantments of level 1 from the target. +1849 Evaporate All Magic Other 2 Utility Other 250 Dispel 50 -1 Life Magic 40 Dispels all negative enchantments of level 1 from the target. +1850 Evaporate All Magic Self 2 Utility Self 250 Dispel 50 -1 Life Magic 50 Dispels all enchantments of level 1 from the caster. +1851 Evaporate All Magic Self 2 Utility Self 250 Dispel 50 -1 Life Magic 50 Dispels 1-3 positive enchantments of level 1 from the caster. +1852 Evaporate All Magic Self 2 Utility Self 250 Dispel 50 -1 Life Magic 40 Dispels all negative enchantments of level 1 from the caster. +1853 Extinguish All Magic Other 3 Utility Other 250 Dispel 100 -1 Life Magic 100 Dispels all enchantments of level 2 or lower from the target. +1854 Extinguish All Magic Other 3 Utility Other 250 Dispel 100 -1 Life Magic 100 Dispels 1-3 positive enchantments of level 2 or lower from the target. +1855 Extinguish All Magic Other 3 Utility Other 250 Dispel 100 -1 Life Magic 80 Dispels all negative enchantments of level 2 or lower from the target. +1856 Extinguish All Magic Self 5 Utility Self 250 Dispel 200 -1 Life Magic 100 Dispels all enchantments of level 2 or lower from the caster. +1857 Extinguish All Magic Self 3 Utility Self 250 Dispel 100 -1 Life Magic 100 Dispels 1-3 positive enchantments of level 2 or lower from the caster. +1858 Extinguish All Magic Self 3 Utility Self 250 Dispel 100 -1 Life Magic 80 Dispels all negative enchantments of level 2 or lower from the caster. +1859 Cleanse All Magic Other 4 Neutral Other 250 Dispel 150 -1 Life Magic 150 Dispels all enchantments of level 3 or lower from the target. +1860 Cleanse All Magic Other 4 Neutral Other 250 Dispel 150 -1 Life Magic 150 Dispels 2-4 positive enchantments of level 3 or lower from the target. +1861 Cleanse All Magic Other 4 Neutral Other 250 Dispel 150 -1 Life Magic 120 Dispels all negative enchantments of level 3 or lower from the target. +1862 Cleanse All Magic Self 4 Neutral Self 250 Dispel 150 -1 Life Magic 150 Dispels all enchantments of level 3 or lower from the caster. +1863 Cleanse All Magic Self 4 Neutral Self 250 Dispel 150 -1 Life Magic 150 Dispels 2-4 positive enchantments of level 3 or lower from the caster. +1864 Cleanse All Magic Self 4 Neutral Self 250 Dispel 150 -1 Life Magic 120 Dispels all negative enchantments of level 3 or lower from the caster. +1865 Devour All Magic Other 5 Neutral Other 250 Dispel 200 -1 Life Magic 200 Dispels all enchantments of level 4 or lower from the target. +1866 Devour All Magic Other 5 Neutral Other 250 Dispel 200 -1 Life Magic 200 Dispels 2-4 positive enchantments of level 4 or lower from the target. +1867 Devour All Magic Other 5 Neutral Other 250 Dispel 200 -1 Life Magic 160 Dispels all negative enchantments of level 4 or lower from the target. +1868 Devour All Magic Self 5 Neutral Self 250 Dispel 200 -1 Life Magic 200 Dispels all enchantments of level 4 or lower from the caster. +1869 Devour All Magic Self 5 Neutral Self 250 Dispel 200 -1 Life Magic 200 Dispels 2-4 positive enchantments of level 4 or lower from the caster. +1870 Devour All Magic Self 5 Neutral Self 250 Dispel 200 -1 Life Magic 160 Dispels all negative enchantments of level 4 or lower from the caster. +1871 Purge All Magic Other 6 Neutral Other 250 Dispel 250 -1 Life Magic 250 Dispels all enchantments of level 5 or lower from the target. +1872 Purge All Magic Other 6 Neutral Other 250 Dispel 250 -1 Life Magic 250 Dispels 2-6 positive enchantments of level 5 or lower from the target. +1873 Purge All Magic Other 6 Neutral Other 250 Dispel 250 -1 Life Magic 200 Dispels all negative enchantments of level 5 or lower from the target. +1874 Purge All Magic Self 6 Neutral Self 250 Dispel 250 -1 Life Magic 250 Dispels all enchantments of level 5 or lower from the caster. +1875 Purge All Magic Self 6 Neutral Self 250 Dispel 250 -1 Life Magic 250 Dispels 2-6 positive enchantments of level 5 or lower from the caster. +1876 Purge All Magic Self 6 Neutral Self 250 Dispel 250 -1 Life Magic 200 Dispels all negative enchantments of level 5 or lower from the caster. +1877 Nullify All Magic Other 7 Neutral Other 250 Dispel 300 -1 Life Magic 300 Dispels all enchantments of level 6 or lower from the target. +1878 Nullify All Magic Other 7 Neutral Other 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 positive enchantments of level 6 or lower from the target. +1879 Nullify All Magic Other 7 Neutral Other 250 Dispel 300 -1 Life Magic 240 Dispels all negative enchantments of level 6 or lower from the target. +1880 Nullify All Magic Self 7 Neutral Self 250 Dispel 300 -1 Life Magic 300 Dispels all enchantments of level 6 or lower from the caster. +1881 Nullify All Magic Self 7 Neutral Self 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 positive enchantments of level 6 or lower from the caster. +1882 Nullify All Magic Self 7 Neutral Self 250 Dispel 300 -1 Life Magic 240 Dispels all negative enchantments of level 6 or lower from the caster. +1883 Evaporate Creature Magic Other 2 Utility Other 250 Dispel 50 -1 Creature Enchantment 50 Dispels 1-3 Creature Magic enchantments of level 1 from the target. +1884 Evaporate Creature Magic Other 2 Utility Other 250 Dispel 50 -1 Creature Enchantment 50 Dispels 1-3 positive Creature Magic enchantments of level 1 from the target. +1885 Evaporate Creature Magic Other 2 Utility Other 250 Dispel 50 -1 Creature Enchantment 40 Dispels 3-6 negative Creature Magic enchantments of level 1 from the target. +1886 Evaporate Creature Magic Self 2 Utility Self 250 Dispel 50 -1 Creature Enchantment 50 Dispels 1-3 Creature Magic enchantments of level 1 from the caster. +1887 Evaporate Creature Magic Self 2 Utility Self 250 Dispel 50 -1 Creature Enchantment 50 Dispels 1-3 positive Creature Magic enchantments of level 1 from the caster. +1888 Evaporate Creature Magic Self 2 Utility Self 250 Dispel 50 -1 Creature Enchantment 40 Dispels 3-6 negative Creature Magic enchantments of level 1 from the caster. +1889 Extinguish Creature Magic Other 3 Utility Other 250 Dispel 100 -1 Creature Enchantment 100 Dispels 1-3 Creature Magic enchantments of level 2 or lower from the target. +1890 Extinguish Creature Magic Other 3 Utility Other 250 Dispel 100 -1 Creature Enchantment 100 Dispels 1-3 positive Creature Magic enchantments of level 2 or lower from the target. +1891 Extinguish Creature Magic Other 3 Utility Other 250 Dispel 100 -1 Creature Enchantment 80 Dispels 3-6 negative Creature Magic enchantments of level 2 or lower from the target. +1892 Extinguish Creature Magic Self 3 Utility Self 250 Dispel 100 -1 Creature Enchantment 100 Dispels 1-3 Creature Magic enchantments of level 2 or lower from the caster. +1893 Extinguish Creature Magic Self 3 Utility Self 250 Dispel 100 -1 Creature Enchantment 100 Dispels 1-3 positive Creature Magic enchantments of level 2 or lower from the caster. +1894 Extinguish Creature Magic Self 3 Utility Self 250 Dispel 100 -1 Creature Enchantment 80 Dispels 3-6 negative Creature Magic enchantments of level 2 or lower from the caster. +1895 Cleanse Creature Magic Other 4 Neutral Other 250 Dispel 150 -1 Creature Enchantment 150 Dispels 2-4 Creature Magic enchantments of level 3 or lower from the target. +1896 Cleanse Creature Magic Other 4 Neutral Other 250 Dispel 150 -1 Creature Enchantment 150 Dispels 2-4 positive Creature Magic enchantments of level 3 or lower from the target. +1897 Cleanse Creature Magic Other 4 Neutral Other 250 Dispel 150 -1 Creature Enchantment 120 Dispels 3-6 negative Creature Magic enchantments of level 3 or lower from the target. +1898 Cleanse Creature Magic Self 4 Neutral Self 250 Dispel 150 -1 Creature Enchantment 150 Dispels 2-4 Creature Magic enchantments of level 3 or lower from the caster. +1899 Cleanse Creature Magic Self 4 Neutral Self 250 Dispel 150 -1 Creature Enchantment 150 Dispels 2-4 positive Creature Magic enchantments of level 3 or lower from the caster. +1900 Cleanse Creature Magic Self 4 Neutral Self 250 Dispel 150 -1 Creature Enchantment 120 Dispels 3-6 negative Creature Magic enchantments of level 3 or lower from the caster. +1901 Devour Creature Magic Other 5 Neutral Other 250 Dispel 200 -1 Creature Enchantment 200 Dispels 2-4 Creature Magic enchantments of level 4 or lower from the target. +1902 Devour Creature Magic Other 5 Neutral Other 250 Dispel 200 -1 Creature Enchantment 200 Dispels 2-4 positive Creature Magic enchantments of level 4 or lower from the target. +1903 Devour Creature Magic Other 5 Neutral Other 250 Dispel 200 -1 Creature Enchantment 160 Dispels 3-6 negative Creature Magic enchantments of level 4 or lower from the target. +1904 Devour Creature Magic Self 5 Neutral Self 250 Dispel 200 -1 Creature Enchantment 200 Dispels 2-4 Creature Magic enchantments of level 4 or lower from the caster. +1905 Devour Creature Magic Self 5 Neutral Self 250 Dispel 200 -1 Creature Enchantment 200 Dispels 2-4 positive Creature Magic enchantments of level 4 or lower from the caster. +1906 Devour Creature Magic Self 5 Neutral Self 250 Dispel 200 -1 Creature Enchantment 160 Dispels 3-6 negative Creature Magic enchantments of level 4 or lower from the caster. +1907 Purge Creature Magic Other 6 Neutral Other 250 Dispel 250 -1 Creature Enchantment 250 Dispels 2-6 Creature Magic enchantments of level 5 or lower from the target. +1908 Purge Creature Magic Other 6 Neutral Other 250 Dispel 250 -1 Creature Enchantment 250 Dispels 2-6 positive Creature Magic enchantments of level 5 or lower from the target. +1909 Purge Creature Magic Other 6 Neutral Other 250 Dispel 250 -1 Creature Enchantment 200 Dispels 3-6 negative Creature Magic enchantments of level 5 or lower from the target. +1910 Purge Creature Magic Self 6 Neutral Self 250 Dispel 250 -1 Creature Enchantment 250 Dispels 2-6 Creature Magic enchantments of level 5 or lower from the caster. +1911 Purge Creature Magic Self 6 Neutral Self 250 Dispel 250 -1 Creature Enchantment 250 Dispels 2-6 positive Creature Magic enchantments of level 5 or lower from the caster. +1912 Purge Creature Magic Self 6 Neutral Self 250 Dispel 250 -1 Creature Enchantment 200 Dispels 3-6 negative Creature Magic enchantments of level 5 or lower from the caster. +1913 Nullify Creature Magic Other 7 Neutral Other 250 Dispel 300 -1 Creature Enchantment 300 Dispels 2-6 Creature Magic enchantments of level 6 or lower from the target. +1914 Nullify Creature Magic Other 7 Neutral Other 250 Dispel 300 -1 Creature Enchantment 300 Dispels 2-6 positive Creature Magic enchantments of level 6 or lower from the target. +1915 Nullify Creature Magic Other 7 Neutral Other 250 Dispel 300 -1 Creature Enchantment 240 Dispels 3-6 negative Creature Magic enchantments of level 6 or lower from the target. +1916 Nullify Creature Magic Self 7 Neutral Self 250 Dispel 300 -1 Creature Enchantment 300 Dispels 2-6 Creature Magic enchantments of level 6 or lower from the caster. +1917 Nullify Creature Magic Self 7 Neutral Self 250 Dispel 300 -1 Creature Enchantment 300 Dispels 2-6 positive Creature Magic enchantments of level 6 or lower from the caster. +1918 Nullify Creature Magic Self 7 Neutral Self 250 Dispel 300 -1 Creature Enchantment 240 Dispels 3-6 negative Creature Magic enchantments of level 6 or lower from the caster. +1919 Evaporate Item Magic 2 Utility Item 250 Dispel 50 -1 Item Enchantment 50 Dispels 1-3 Item Magic enchantments of level 1 from the target. +1920 Evaporate Item Magic 2 Utility Item 250 Dispel 50 -1 Item Enchantment 50 Dispels 1-3 positive Item Magic enchantments of level 1 from the target. +1921 Evaporate Item Magic 2 Utility Item 250 Dispel 50 -1 Item Enchantment 40 Dispels 3-6 negative Item Magic enchantments of level 1 from the target. +1922 Evaporate Item Magic 2 Utility Item 250 Dispel 50 -1 Item Enchantment 50 Dispels 1-3 Item Magic enchantments of level 1 from the caster. +1923 Evaporate Item Magic 2 Utility Item 250 Dispel 50 -1 Item Enchantment 50 Dispels 1-3 positive Item Magic enchantments of level 1 from the caster. +1924 Evaporate Item Magic 2 Utility Item 250 Dispel 50 -1 Item Enchantment 50 Dispels 1-3 negative Item Magic enchantments of level 1 from the caster. +1925 Extinguish Item Magic 3 Utility Item 250 Dispel 100 -1 Item Enchantment 100 Dispels 1-3 Item Magic enchantments of level 2 or lower from the target. +1926 Extinguish Item Magic 3 Utility Item 250 Dispel 100 -1 Item Enchantment 100 Dispels 1-3 positive Item Magic enchantments of level 2 or lower from the target. +1927 Extinguish Item Magic 3 Utility Item 250 Dispel 100 -1 Item Enchantment 80 Dispels 3-6 negative Item Magic enchantments of level 2 or lower from the target. +1928 Extinguish Item Magic 3 Utility Item 250 Dispel 100 -1 Item Enchantment 100 Dispels 1-3 Item Magic enchantments of level 2 or lower from the caster. +1929 Extinguish Item Magic 3 Utility Item 250 Dispel 100 -1 Item Enchantment 100 Dispels 1-3 positive Item Magic enchantments of level 2 or lower from the caster. +1930 Extinguish Item Magic 3 Utility Item 250 Dispel 100 -1 Item Enchantment 100 Dispels 1-3 negative Item Magic enchantments of level 2 or lower from the caster. +1931 Cleanse Item Magic 4 Neutral Item 250 Dispel 150 -1 Item Enchantment 150 Dispels 2-4 Item Magic enchantments of level 3 or lower from the target. +1932 Cleanse Item Magic 4 Neutral Item 250 Dispel 150 -1 Item Enchantment 150 Dispels 2-4 positive Item Magic enchantments of level 3 or lower from the target. +1933 Cleanse Item Magic 4 Neutral Item 250 Dispel 150 -1 Item Enchantment 120 Dispels 3-6 negative Item Magic enchantments of level 3 or lower from the target. +1934 Cleanse Item Magic 4 Neutral Item 250 Dispel 150 -1 Item Enchantment 150 Dispels 2-4 Item Magic enchantments of level 3 or lower from the caster. +1935 Cleanse Item Magic 4 Neutral Item 250 Dispel 150 -1 Item Enchantment 150 Dispels 2-4 positive Item Magic enchantments of level 3 or lower from the caster. +1936 Cleanse Item Magic 4 Neutral Item 250 Dispel 150 -1 Item Enchantment 150 Dispels 2-4 negative Item Magic enchantments of level 3 or lower from the caster. +1937 Devour Item Magic 5 Neutral Item 250 Dispel 200 -1 Item Enchantment 200 Dispels 2-4 Item Magic enchantments of level 4 or lower from the target. +1938 Devour Item Magic 5 Neutral Item 250 Dispel 200 -1 Item Enchantment 200 Dispels 2-4 positive Item Magic enchantments of level 4 or lower from the target. +1939 Devour Item Magic 5 Neutral Item 250 Dispel 200 -1 Item Enchantment 160 Dispels 3-6 negative Item Magic enchantments of level 4 or lower from the target. +1940 Devour Item Magic 5 Neutral Item 250 Dispel 200 -1 Item Enchantment 200 Dispels 2-4 Item Magic enchantments of level 4 or lower from the caster. +1941 Devour Item Magic 5 Neutral Item 250 Dispel 200 -1 Item Enchantment 200 Dispels 2-4 positive Item Magic enchantments of level 4 or lower from the caster. +1942 Devour Item Magic 5 Neutral Item 250 Dispel 200 -1 Item Enchantment 200 Dispels 2-4 negative Item Magic enchantments of level 4 or lower from the caster. +1943 Purge Item Magic 6 Neutral Item 250 Dispel 250 -1 Item Enchantment 250 Dispels 2-6 Item Magic enchantments of level 5 or lower from the target. +1944 Purge Item Magic 6 Neutral Item 250 Dispel 250 -1 Item Enchantment 250 Dispels 2-6 positive Item Magic enchantments of level 5 or lower from the target. +1945 Purge Item Magic 6 Neutral Item 250 Dispel 250 -1 Item Enchantment 200 Dispels 3-6 negative Item Magic enchantments of level 5 or lower from the target. +1946 Purge Item Magic 6 Neutral Item 250 Dispel 250 -1 Item Enchantment 250 Dispels 2-6 Item Magic enchantments of level 5 or lower from the caster. +1947 Purge Item Magic 6 Neutral Item 250 Dispel 250 -1 Item Enchantment 250 Dispels 2-6 positive Item Magic enchantments of level 5 or lower from the caster. +1948 Purge Item Magic 6 Neutral Item 250 Dispel 250 -1 Item Enchantment 250 Dispels 2-6 negative Item Magic enchantments of level 5 or lower from the caster. +1949 Nullify Item Magic 7 Neutral Item 250 Dispel 300 -1 Item Enchantment 300 Dispels 2-6 Item Magic enchantments of level 6 or lower from the target. +1950 Nullify Item Magic 7 Neutral Item 250 Dispel 300 -1 Item Enchantment 300 Dispels 2-6 positive Item Magic enchantments of level 6 or lower from the target. +1951 Nullify Item Magic 7 Neutral Item 250 Dispel 300 -1 Item Enchantment 240 Dispels 3-6 negative Item Magic enchantments of level 6 or lower from the target. +1952 Nullify Item Magic 7 Neutral Item 250 Dispel 300 -1 Item Enchantment 300 Dispels 2-6 Item Magic enchantments of level 6 or lower from the caster. +1953 Nullify Item Magic 7 Neutral Item 250 Dispel 300 -1 Item Enchantment 300 Dispels 2-6 positive Item Magic enchantments of level 6 or lower from the caster. +1954 Nullify Item Magic 7 Neutral Item 250 Dispel 300 -1 Item Enchantment 300 Dispels 2-6 negative Item Magic enchantments of level 6 or lower from the caster. +1955 Evaporate Life Magic Other 2 Utility Other 250 Dispel 50 -1 Life Magic 50 Dispels 1-3 Life Magic enchantments of level 1 from the target. +1956 Evaporate Life Magic Other 2 Utility Other 250 Dispel 50 -1 Life Magic 50 Dispels 1-3 positive Life Magic enchantments of level 1 from the target. +1957 Evaporate Life Magic Other 2 Utility Other 250 Dispel 50 -1 Life Magic 40 Dispels 3-6 negative Life Magic enchantments of level 1 from the target. +1958 Evaporate Life Magic Self 2 Utility Self 250 Dispel 50 -1 Life Magic 50 Dispels 1-3 Life Magic enchantments of level 1 from the caster. +1959 Evaporate Life Magic Self 2 Utility Self 250 Dispel 50 -1 Life Magic 50 Dispels 1-3 positive Life Magic enchantments of level 1 from the caster. +1960 Evaporate Life Magic Self 2 Utility Self 250 Dispel 50 -1 Life Magic 40 Dispels 3-6 negative Life Magic enchantments of level 1 from the caster. +1961 Extinguish Life Magic Other 3 Utility Other 250 Dispel 100 -1 Life Magic 100 Dispels 1-3 Life Magic enchantments of level 2 or lower from the target. +1962 Extinguish Life Magic Other 3 Utility Other 250 Dispel 100 -1 Life Magic 100 Dispels 1-3 positive Life Magic enchantments of level 2 or lower from the target. +1963 Extinguish Life Magic Other 3 Utility Other 250 Dispel 100 -1 Life Magic 80 Dispels 3-6 negative Life Magic enchantments of level 2 or lower from the target. +1964 Extinguish Life Magic Self 3 Utility Self 250 Dispel 100 -1 Life Magic 100 Dispels 1-3 Life Magic enchantments of level 2 or lower from the caster. +1965 Extinguish Life Magic Self 3 Utility Self 250 Dispel 100 -1 Life Magic 100 Dispels 1-3 positive Life Magic enchantments of level 2 or lower from the caster. +1966 Extinguish Life Magic Self 3 Utility Self 250 Dispel 100 -1 Life Magic 80 Dispels 3-6 negative Life Magic enchantments of level 2 or lower from the caster. +1967 Cleanse Life Magic Other 4 Neutral Other 250 Dispel 150 -1 Life Magic 150 Dispels 2-4 Life Magic enchantments of level 3 or lower from the target. +1968 Cleanse Life Magic Other 4 Neutral Other 250 Dispel 150 -1 Life Magic 150 Dispels 2-4 positive Life Magic enchantments of level 3 or lower from the target. +1969 Cleanse Life Magic Other 4 Neutral Other 250 Dispel 150 -1 Life Magic 120 Dispels 3-6 negative Life Magic enchantments of level 3 or lower from the target. +1970 Cleanse Life Magic Self 4 Neutral Self 250 Dispel 150 -1 Life Magic 150 Dispels 2-4 Life Magic enchantments of level 3 or lower from the caster. +1971 Cleanse Life Magic Self 4 Neutral Self 250 Dispel 150 -1 Life Magic 150 Dispels 2-4 positive Life Magic enchantments of level 3 or lower from the caster. +1972 Cleanse Life Magic Self 4 Neutral Self 250 Dispel 150 -1 Life Magic 120 Dispels 3-6 negative Life Magic enchantments of level 3 or lower from the caster. +1973 Devour Life Magic Other 5 Neutral Other 250 Dispel 200 -1 Life Magic 200 Dispels 2-4 Life Magic enchantments of level 4 or lower from the target. +1974 Devour Life Magic Other 5 Neutral Other 250 Dispel 200 -1 Life Magic 200 Dispels 2-4 positive Life Magic enchantments of level 4 or lower from the target. +1975 Devour Life Magic Other 5 Neutral Other 250 Dispel 200 -1 Life Magic 160 Dispels 3-6 negative Life Magic enchantments of level 4 or lower from the target. +1976 Devour Life Magic Self 5 Neutral Self 250 Dispel 200 -1 Life Magic 200 Dispels 2-4 Life Magic enchantments of level 4 or lower from the caster. +1977 Devour Life Magic Self 5 Neutral Self 250 Dispel 200 -1 Life Magic 200 Dispels 2-4 positive Life Magic enchantments of level 4 or lower from the caster. +1978 Devour Life Magic Self 5 Neutral Self 250 Dispel 200 -1 Life Magic 160 Dispels 3-6 negative Life Magic enchantments of level 4 or lower from the caster. +1979 Purge Life Magic Other 6 Neutral Other 250 Dispel 250 -1 Life Magic 250 Dispels 2-6 Life Magic enchantments of level 5 or lower from the target. +1980 Purge Life Magic Other 6 Neutral Other 250 Dispel 250 -1 Life Magic 250 Dispels 2-6 positive Life Magic enchantments of level 5 or lower from the target. +1981 Purge Life Magic Other 6 Neutral Other 250 Dispel 250 -1 Life Magic 200 Dispels 3-6 negative Life Magic enchantments of level 5 or lower from the target. +1982 Purge Life Magic Self 6 Neutral Self 250 Dispel 250 -1 Life Magic 250 Dispels 2-6 Life Magic enchantments of level 5 or lower from the caster. +1983 Purge Life Magic Self 6 Neutral Self 250 Dispel 250 -1 Life Magic 250 Dispels 2-6 positive Life Magic enchantments of level 5 or lower from the caster. +1984 Purge Life Magic Self 6 Neutral Self 250 Dispel 250 -1 Life Magic 200 Dispels 3-6 negative Life Magic enchantments of level 5 or lower from the caster. +1985 Nullify Life Magic Other 7 Neutral Other 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 Life Magic enchantments of level 6 or lower from the target. +1986 Nullify Life Magic Other 7 Neutral Other 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 positive Life Magic enchantments of level 6 or lower from the target. +1987 Nullify Life Magic Other 7 Neutral Other 250 Dispel 300 -1 Life Magic 240 Dispels 3-6 negative Life Magic enchantments of level 6 or lower from the target. +1988 Nullify Life Magic Self 7 Neutral Self 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 Life Magic enchantments of level 6 or lower from the caster. +1989 Nullify Life Magic Self 7 Neutral Self 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 positive Life Magic enchantments of level 6 or lower from the caster. +1990 Nullify Life Magic Self 7 Neutral Self 250 Dispel 300 -1 Life Magic 240 Dispels 3-6 negative Life Magic enchantments of level 6 or lower from the caster. +1991 Mana Blight 6 Debuff Other 84 ManaLowering 275 -1 Life Magic 60 Drains 5000 points of the target's Mana. +1992 Camping Mastery 1 Buff Other 221 AlchemyRaising 1 300 Creature Enchantment 10 Increases the target's chance of finding phat loot. +1993 Camping Ineptitude 1 Debuff Other 220 AlchemyLowering 1 300 Creature Enchantment 1 Decreases the target's chance of finding phat loot. +1994 Aura of Wound Twister 6 Buff Item 154 DamageRaising 250 1020 Item Enchantment 60 Increases a weapon's damage value by 25 points. +1995 Aura of Alacrity 2 Buff Item 158 WeaponTimeRaising 50 360 Item Enchantment 20 Improves a weapon's speed by 20 points. +1996 Aura of Soul Hunter 4 Buff Item 152 AttackModRaising 150 600 Item Enchantment 40 Increases a weapon's Attack Skill modifier by 10.0 percentage points. +1997 Life Giver 1 Buff Other 279 LifeGiverRaising 15 510 Life Magic 70 Increases maximum health by 15 points. +1998 Stamina Giver 1 Buff Other 281 StaminaGiverRaising 15 510 Life Magic 70 Increases maximum stamina by 15 points. +1999 Mana Giver 1 Buff Other 283 ManaGiverRaising 15 510 Life Magic 70 Increases maximum mana by 15 points. +2000 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2001 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2002 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2003 Warrior's Lesser Vitality 5 Buff Other 273 GreatVitalityRaising 240 510 Life Magic 70 Increases maximum health by 5 points. +2004 Warrior's Vitality 5 Buff Other 273 GreatVitalityRaising 245 510 Life Magic 70 Increases maximum health by 10 points. +2005 Warrior's Greater Vitality 6 Buff Other 273 GreatVitalityRaising 250 510 Life Magic 70 Increases maximum health by 15 points. +2006 Warrior's Ultimate Vitality 6 Buff Other 273 GreatVitalityRaising 260 510 Life Magic 70 Increases maximum health by 20 points. +2007 Warrior's Lesser Vigor 5 Buff Other 275 GreatVigorRaising 240 510 Life Magic 70 Increases maximum stamina by 10 points. +2008 Warrior's Vigor 5 Buff Other 275 GreatVigorRaising 245 510 Life Magic 70 Increases maximum stamina by 20 points. +2009 Warrior's Greater Vigor 6 Buff Other 275 GreatVigorRaising 250 510 Life Magic 70 Increases maximum stamina by 30 points. +2010 Warrior's Ultimate Vigor 6 Buff Other 275 GreatVigorRaising 260 510 Life Magic 70 Increases maximum stamina by 40 points. +2011 Wizard's Lesser Intellect 5 Buff Other 277 GreaterIntellectRaising 240 510 Life Magic 70 Increases maximum mana by 10 points. +2012 Wizard's Intellect 5 Buff Other 277 GreaterIntellectRaising 245 510 Life Magic 70 Increases maximum mana by 15 points. +2013 Wizard's Greater Intellect 6 Buff Other 277 GreaterIntellectRaising 250 510 Life Magic 70 Increases maximum mana by 20 points. +2014 Wizard's Ultimate Intellect 6 Buff Other 277 GreaterIntellectRaising 260 510 Life Magic 70 Increases maximum mana by 30 points. +2015 Aerfalle's Ward 6 Buff Item 160 ArmorValueRaising 295 1020 Item Enchantment 60 Improves a shield or piece of armor's armor value by 220 points. +2016 Impulse 3 Buff Other 283 ManaGiverRaising 100 10800 Life Magic 70 Increases maximum mana by 100 points. +2017 Bunny Smite 1 Debuff Other 80 HealthLowering 1 -1 Life Magic 10 Drains 1000-6000 points of the target's Health. +2018 Tormenter of Flesh 1 Debuff Other 80 HealthLowering 1 -1 Life Magic 10 Drains 1000-6000 points of the target's Health. +2019 The sundering of the crystal 5 Projectile Other 223 BludgeoningRing 200 -1 War Magic 80 Shoots eight shock waves outward from the caster. Each wave does 200-300 points of bludgeoning damage to the first thing it hits. +2020 Recall Asmolum 1 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2021 Thaumaturgic Shroud 7 Neutral Other 91 ManaTransfertocaster 350 -1 Life Magic 70 Drains one-half of the target's Mana and gives 200% of that to the caster. +2022 Soul Shroud 7 Neutral Other 87 HealthTransfertocaster 350 -1 Life Magic 70 Drains one-half of the target's Health and gives 200% of that to the caster. +2023 Recall the Sanctuary 5 Utility Self 214 PortalSending 200 -1 Item Enchantment 70 Transports the caster to the Ithaenc Cathedral. +2024 Recall Asmolum 2 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2025 RecallAsmolum 3 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2026 Nerve Burn 7 Neutral Other 89 StaminaTransfertocaster 350 -1 Life Magic 70 Drains one-half of the target's Stamina and gives 200% of that to the caster. +2027 Martyr 6 Neutral Other 88 HealthTransferfromcaster 250 -1 Life Magic 60 Drains all of the caster's Health and gives 1000% of that to the target. +2028 The Path to Kelderam's Ward 5 Buff Item 203 PortalItemCreation 200 60 Item Enchantment 70 Summons a PK-limited portal to the Catacombs beneath the Ithaenc Cathedral. +2029 Stamina Blight 6 Debuff Other 82 StaminaLowering 275 -1 Life Magic 60 Drains 5000 points of the target's Stamina. +2030 Flaming Blaze 6 Neutral Other 122 PiercingMissile 250 -1 War Magic 10 CREATURE MAGIC ONLY! +2031 Steel Thorns 6 Neutral Other 122 PiercingMissile 250 -1 War Magic 10 CREATURE MAGIC ONLY! +2032 Electric Blaze 6 Neutral Other 122 PiercingMissile 250 -1 War Magic 10 CREATURE MAGIC ONLY! +2033 Acidic Spray 6 Neutral Other 122 PiercingMissile 250 -1 War Magic 10 CREATURE MAGIC ONLY! +2034 Exploding Fury 6 Neutral Other 135 FireBurst 275 -1 War Magic 30 Exploding fury for baelzharon +2035 Electric Discharge 6 Neutral Other 120 ElectricMissile 250 -1 War Magic 30 CREATURE MAGIC ONLY! +2036 Fuming Acid 6 Neutral Other 117 AcidMissile 250 -1 War Magic 30 CREATURE MAGIC ONLY! +2037 Flaming Irruption 6 Neutral Other 121 FireMissile 250 -1 War Magic 30 CREATURE MAGIC ONLY! +2038 Exploding Ice 6 Neutral Other 135 FireBurst 275 -1 War Magic 30 Exploding fury for baelzharon +2039 Sparking Fury 6 Neutral Other 134 ElectricBurst 275 -1 War Magic 30 CREATURE MAGIC ONLY! +2040 The Path to Kelderam's Ward 5 Buff Item 203 PortalItemCreation 200 60 Item Enchantment 70 Will create a portal to the Sepulcher of the Hopeslayer. +2041 Aerlinthe Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 150 Transports the caster to Aerlinthe Island. +2042 Demon's Tongues 5 Neutral Other 233 FireWall 200 -1 War Magic 1 Sends a wall of lag towards the opponents. burning them to a tasty crisp. +2043 Weight of Eternity 8 Debuff Other 2 StrengthLowering 500 60 Creature Enchantment 1 Afflicts the target with the weight of thousands of years. +2044 Item Befoulment 6 Debuff Other 46 ItemEnchantmentLowering 275 400 Creature Enchantment 60 The target becomes totally ineffectual with Item magic. +2045 Demon Fists 7 Neutral Other 237 BludgeoningStrike 320 -1 War Magic 120 Rains LOTS of boulders down. smooshing any that oppose. +2046 Portal to Teth 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Fort Tethana. +2047 Demonskin 8 Buff Other 115 ArmorRaising 900 1020 Life Magic 60 The target's skin becomes hardened against physical damage. +2048 Boon of the Demon 6 Buff Other 41 MagicDefenseRaising 250 1020 Creature Enchantment 60 Gives the target a huge boost to their magic defense. +2049 Bile of the Hopeslayer 6 Buff Item 154 DamageRaising 250 1020 Item Enchantment 60 Coats a weapon in the bile of Bael'zharon. greatly increasing its damage. +2050 Young Love 1 Buff Other 67 HealingRaising 1 -1 Life Magic 15 This is a gem that spectacularly symbolizes all the joys and challenges of marriage. It is a one-use item. so use it wisely to mark your commitment to share your life with another. Best used outdoors. in the open. +2051 Young Love 1 Buff Other 67 HealingRaising 1 -1 Life Magic 15 This is a gem that spectacularly symbolizes all the joys and challenges of marriage. It is a one-use item. so use it wisely to mark your commitment to share your life with another. Best used outdoors. in the open. +2052 Executor's Boon 7 Buff Other 115 ArmorRaising 300 3600 Life Magic 70 Increases the target's natural armor by 225 points. +2053 Executor's Blessing 7 Buff Other 115 ArmorRaising 300 3600 Life Magic 70 Increases the caster's natural armor by 225 points. +2054 Synaptic Misfire 7 Debuff Other 10 FocusLowering 325 240 Creature Enchantment 70 Decreases the target's Focus by 40 points. +2055 Bafflement Self VII 7 Debuff Self 10 FocusLowering 325 240 Creature Enchantment 70 Decreases the caster's Focus by 40 points. +2056 Ataxia 7 Debuff Other 8 CoordinationLowering 325 240 Creature Enchantment 70 Decreases the target's Coordination by 40 points. +2057 Clumsiness Self VII 7 Debuff Self 8 CoordinationLowering 325 240 Creature Enchantment 70 Decreases the caster's Coordination by 40 points. +2058 Boon of Refinement 7 Buff Other 7 CoordinationRaising 300 3600 Creature Enchantment 70 Increases the target's Coordination by 40 points. +2059 Honed Control 7 Buff Other 7 CoordinationRaising 300 3600 Creature Enchantment 70 Increases the caster's Coordination by 40 points. +2060 Temeritous Touch 7 Buff Other 3 EnduranceRaising 300 3600 Creature Enchantment 70 Increases the target's Endurance by 40 points. +2061 Perseverance 7 Buff Other 3 EnduranceRaising 300 3600 Creature Enchantment 70 Increases the caster's Endurance by 40 points. +2062 Anemia 7 Debuff Other 82 StaminaLowering 325 -1 Life Magic 70 Drains 52-105 points of the target's Stamina. +2063 Enfeeble Self VII 7 Debuff Self 82 StaminaLowering 325 -1 Life Magic 70 Drains 50-100 points of the caster's Stamina. +2064 Self Loathing 7 Debuff Other 12 SelfLowering 325 240 Creature Enchantment 70 Decreases the target's Self by 40 points. +2065 Feeblemind Self VII 7 Debuff Self 12 SelfLowering 325 240 Creature Enchantment 70 Decreases the caster's Self by 40 points. +2066 Calming Gaze 7 Buff Other 9 FocusRaising 300 3600 Creature Enchantment 70 Increases the target's Focus by 40 points. +2067 Inner Calm 7 Buff Other 9 FocusRaising 300 3600 Creature Enchantment 70 Increases the caster's Focus by 40 points. +2068 Brittle Bones 7 Debuff Other 4 EnduranceLowering 325 240 Creature Enchantment 70 Decreases the target's Endurance by 40 points. +2069 Frailty Self VII 7 Debuff Self 4 EnduranceLowering 325 240 Creature Enchantment 70 Decreases the caster's Endurance by 40 points. +2070 Heart Rend 7 Debuff Other 80 HealthLowering 325 -1 Life Magic 70 Drains 42-79 points of the target's Health. +2071 Harm Self VII 7 Harm Self 80 HealthLowering 325 -1 Life Magic 70 Drains 40-75 points of the caster's Health. +2072 Adja's Gift 7 Buff Other 79 HealthRaising 300 -1 Life Magic 70 Restores 80-150 points of the target's Health. +2073 Adja's Intervention 7 Buff Other 67 HealingRaising 300 -1 Life Magic 70 Restores 80-150 points of the caster's Health. +2074 Gossamer Flesh 7 Debuff Other 116 ArmorLowering 325 240 Life Magic 70 Decreases the target's natural armor by 225 points. +2075 Imperil Self VII 7 Debuff Self 116 ArmorLowering 325 240 Life Magic 70 Decreases the caster's natural armor by 225 points. +2076 Mana Boost Other VII 7 Buff Other 83 ManaRaising 300 -1 Life Magic 70 Restores 51-100 points of the target's Mana. +2077 Mana Boost Self VII 7 Buff Self 83 ManaRaising 300 -1 Life Magic 70 Restores 51-100 points of the caster's Mana. +2078 Void's Call 7 Debuff Other 84 ManaLowering 325 -1 Life Magic 70 Drains 42-79 points of the target's Mana. +2079 Mana Drain Self VII 7 Debuff Self 84 ManaLowering 325 -1 Life Magic 70 Drains 40-75 points of the caster's Mana. +2080 Ogfoot 7 Buff Other 5 QuicknessRaising 300 3600 Creature Enchantment 70 Increases the target's Quickness by 40 points. +2081 Hastening 7 Buff Other 5 QuicknessRaising 300 3600 Creature Enchantment 70 Increases the caster's Quickness by 40 points. +2082 Replenish 7 Buff Other 81 StaminaRaising 300 -1 Life Magic 70 Restores 100-200 points of the target's Stamina. +2083 Robustification 7 Buff Other 81 StaminaRaising 300 -1 Life Magic 70 Restores 100-200 points of the caster's Stamina. +2084 Belly of Lead 7 Debuff Other 6 QuicknessLowering 325 240 Creature Enchantment 70 Decreases the target's Quickness by 40 points. +2085 Slowness Self VII 7 Debuff Self 6 QuicknessLowering 325 240 Creature Enchantment 70 Decreases the caster's Quickness by 40 points. +2086 Might of the 5 Mules 7 Buff Other 1 StrengthRaising 300 3600 Creature Enchantment 70 Increases the target's Strength by 40 points. +2087 Might of the Lugians 7 Buff Other 1 StrengthRaising 300 3600 Creature Enchantment 70 Increases the caster's Strength by 40 points. +2088 Senescence 7 Debuff Other 2 StrengthLowering 325 240 Creature Enchantment 70 Decreases the target's Strength by 40 points. +2089 Weakness Self VII 7 Debuff Self 2 StrengthLowering 325 240 Creature Enchantment 70 Decrease the caster's Strength by 40 points. +2090 Bolstered Will 7 Buff Other 11 SelfRaising 300 3600 Creature Enchantment 70 Increases the target's Self by 40 points. +2091 Mind Blossom 7 Buff Other 11 SelfRaising 300 3600 Creature Enchantment 70 Increases the caster's Self by 40 points. +2092 Olthoi's Bane 7 Buff Item 162 AcidResistanceRaising 300 3600 Item Enchantment 70 Increases a shield or piece of armor's resistance to acid damage by 170%. Target yourself to cast this spell on all of your equipped armor. +2093 Olthoi Bait 7 Debuff Item 163 AcidResistanceLowering 325 240 Item Enchantment 70 Decreases a shield or piece of armor's resistance to acid damage by 170%. +2094 Swordsman's Bane 7 Buff Item 174 SlashResistanceRaising 300 3600 Item Enchantment 70 Increases a shield or piece of armor's resistance to slashing damage by 170%. Target yourself to cast this spell on all of your equipped armor. +2095 Swordsman Bait 7 Debuff Item 175 SlashResistanceLowering 325 240 Item Enchantment 70 Decreases a shield or piece of armor's resistance to slashing damage by 170%. +2096 Aura of Infected Caress 7 Buff Item 154 DamageRaising 300 3600 Item Enchantment 70 Increases a weapon's damage value by 22 points. +2097 Pacification 7 Debuff Item 155 DamageLowering 325 240 Item Enchantment 70 Decreases a weapon's damage value by 22 points. +2098 Tusker's Bane 7 Buff Item 164 BludgeonResistanceRaising 300 3600 Item Enchantment 70 Increases a shield or piece of armor's resistance to bludgeoning damage by 170%. Target yourself to cast this spell on all of your equipped armor. +2099 Tusker Bait 7 Debuff Item 165 BludgeonResistanceLowering 325 240 Item Enchantment 70 Decreases a shield or piece of armor's resistance to bludgeoning damage by 170%. +2100 Tattercoat 7 Debuff Item 161 ArmorValueLowering 325 240 Item Enchantment 70 Worsens a shield or piece of armor's armor value by 220 points. +2101 Aura of Cragstone's Will 7 Buff Item 156 DefenseModRaising 300 3600 Item Enchantment 70 Increases the Melee Defense skill modifier of a weapon or magic caster by 17%. +2102 Inferno's Bane 7 Buff Item 170 FireResistanceRaising 300 3600 Item Enchantment 70 Increases a shield or piece of armor's resistance to fire damage by 170%. Target yourself to cast this spell on all of your equipped armor. +2103 Inferno Bait 7 Debuff Item 171 FireResistanceLowering 325 240 Item Enchantment 70 Decreases a shield or piece of armor's resistance to fire damage by 170%. +2104 Gelidite's Bane 7 Buff Item 166 ColdResistanceRaising 300 3600 Item Enchantment 70 Increases a shield or piece of armor's resistance to cold damage by 170%. Target yourself to cast this spell on all of your equipped armor. +2105 Gelidite Bait 7 Debuff Item 167 ColdResistanceLowering 325 240 Item Enchantment 70 Decreases a shield or piece of armor's resistance to cold damage by 170%. +2106 Aura of Elysa's Sight 7 Buff Item 152 AttackModRaising 300 3600 Item Enchantment 70 Increases a weapon's Attack Skill modifier by 17.0 percentage points. +2107 Cabalistic Ostracism 7 Debuff Item 194 ManaConversionModLowering 325 240 Item Enchantment 70 Decreases a magic casting implement's mana conversion bonus by 70%. +2108 Brogard's Defiance 7 Buff Item 160 ArmorValueRaising 300 3600 Item Enchantment 70 Improves a shield or piece of armor's armor value by 220 points. Target yourself to cast this spell on all of your equipped armor. +2109 Lugian's Speed 7 Debuff Item 159 WeaponTimeLowering 325 240 Item Enchantment 70 Worsens a weapon's speed by 70 points. +2110 Astyrrian's Bane 7 Buff Item 168 ElectricResistanceRaising 300 3600 Item Enchantment 70 Increases a shield or piece of armor's resistance to electric damage by 170%. Target yourself to cast this spell on all of your equipped armor. +2111 Astyrrian Bait 7 Debuff Item 169 ElectricResistanceLowering 325 240 Item Enchantment 70 Decreases a shield or piece of armor's resistance to electric damage by 170%. +2112 Wi's Folly 7 Debuff Item 157 DefenseModLowering 325 240 Item Enchantment 70 Decreases the Melee Defense skill modifier of a weapon or magic caster by 17%. +2113 Archer's Bane 7 Buff Item 172 PierceResistanceRaising 300 3600 Item Enchantment 70 Increases a shield or piece of armor's resistance to piercing damage by 170%. Target yourself to cast this spell on all of your equipped armor. +2114 Archer Bait 7 Debuff Item 173 PierceResistanceLowering 325 240 Item Enchantment 70 Decreases a shield or piece of armor's resistance to piercing damage by 170%. +2115 Fortified Lock 7 Buff Item 192 LockpickResistanceRaising 300 240 Item Enchantment 70 Increases a lock's resistance to picking by 200 points. +2116 Aura of Atlan's Alacrity 7 Buff Item 158 WeaponTimeRaising 300 3600 Item Enchantment 70 Improves a weapon's speed by 70 points. +2117 Aura of Mystic's Blessing 7 Buff Item 195 ManaConversionModRaising 300 3600 Item Enchantment 70 Increases a magic casting implement's mana conversion bonus by 70%. +2118 Clouded Motives 7 Debuff Item 153 AttackModLowering 325 240 Item Enchantment 70 Decreases a weapon's Attack Skill modifier by 17.0 percentage points. +2119 Vagabond's Gift 7 Debuff Item 193 LockpickResistanceLowering 300 240 Item Enchantment 70 Decreases a lock's resistance to picking by 200 points. +2120 Dissolving Vortex 7 Neutral Other 131 AcidBurst 325 -1 War Magic 35 Shoots five streams of acid outward from the caster. Each stream does 42-84 points of acid damage to the first thing it hits. +2121 Corrosive Flash 7 Neutral Other 243 AcidStreak 300 -1 War Magic 70 Sends a stream of acid streaking towards the target. The stream does 42-84 points of acid damage to the first thing it hits. +2122 Disintegration 7 Neutral Other 117 AcidMissile 300 -1 War Magic 35 Shoots a stream of acid at the target. The stream does 115-189 points of acid damage to the first thing it hits. +2123 Celdiseth's Searing 7 Neutral Other 207 AcidVolley 325 -1 War Magic 35 Shoots five streams of acid toward the target. Each stream does 42-84 points of acid damage to the first thing it hits. +2124 Sau Kolin's Sword 7 Neutral Other 137 SlashingBurst 325 -1 War Magic 35 Shoots five whirling blades outward from the caster. Each blade does 42-84 points of slashing damage to the first thing it hits. +2125 Flensing Wings 7 Neutral Other 213 BladeVolley 325 -1 War Magic 35 Shoots five whirling blades toward the target. Each blade does 42-84 points of Slashing damage to the first thing it hits. +2126 Thousand Fists 7 Neutral Other 208 BludgeoningVolley 325 -1 War Magic 35 Shoots five shock waves toward the target. Each wave does 42-84 points of bludgeoning damage to the first thing it hits. +2127 Silencia's Scorn 7 Neutral Other 135 FireBurst 325 -1 War Magic 35 Shoots five bolts of flame outward from the caster. Each bolt does 42-84 points of fire damage to the first thing it hits. +2128 Ilservian's Flame 7 Neutral Other 121 FireMissile 300 -1 War Magic 35 Shoots a bolt of flame at the target. The bolt does 115-189 points of fire damage to the first thing it hits. +2129 Sizzling Fury 7 Neutral Other 247 FireStreak 300 -1 War Magic 70 Sends a bolt of flame streaking towards the target. The bolt does 42-84 points of fire damage to the first thing it hits. +2130 Infernae 7 Neutral Other 211 FlameVolley 325 -1 War Magic 35 Shoots five bolts of flame toward the target. Each bolt does 42-84 points of fire damage to the first thing it hits. +2131 Stinging Needles 7 Neutral Other 136 PiercingBurst 325 -1 War Magic 35 Shoots five force bolts outward from the caster. Each bolt does 42-84 points of piercing damage to the first thing it hits. +2132 The Spike 7 Neutral Other 122 PiercingMissile 300 -1 War Magic 35 Shoots a bolt of force at the target. The bolt does 115-189 points of piercing damage to the first thing it hits. +2133 Outlander's Insolence 7 Neutral Other 248 PiercingStreak 300 -1 War Magic 70 Sends a bolt of force streaking towards the target. The bolt does 42-84 points of piercing damage to the first thing it hits. +2134 Fusillade 7 Neutral Other 212 ForceVolley 325 -1 War Magic 35 Shoots five bolts of force toward the target. Each bolt does 42-84 points of piercing damage to the first thing it hits. +2135 Winter's Embrace 7 Neutral Other 133 ColdBurst 325 -1 War Magic 35 Shoots five bolts of frost outward from the caster. Each bolt does 42-84 points of cold damage to the first thing it hits. +2136 Icy Torment 7 Neutral Other 119 ColdMissile 300 -1 War Magic 35 Shoots a bolt of cold at the target. The bolt does 115-189 points of cold damage to the first thing it hits. +2137 Sudden Frost 7 Neutral Other 245 ColdStreak 300 -1 War Magic 70 Sends a bolt of cold streaking towards the target. The bolt does 42-84 points of cold damage to the first thing it hits. +2138 Blizzard 7 Neutral Other 209 FrostVolley 325 -1 War Magic 35 Shoots five bolts of frost toward the target. Each bolt does 42-84 points of cold damage to the first thing it hits. +2139 Luminous Wrath 7 Neutral Other 134 ElectricBurst 325 -1 War Magic 35 Shoots five bolts of lightning outward from the caster. Each bolt does 42-84 points of electric damage to the first thing it hits. +2140 Alset's Coil 7 Neutral Other 120 ElectricMissile 300 -1 War Magic 35 Shoots a bolt of lighting at the target. The bolt does 115-189 points of electrical damage to the first thing it hits. +2141 Lhen's Flare 7 Neutral Other 246 ElectricStreak 300 -1 War Magic 70 Sends a bolt of lighting streaking towards the target. The bolt does 42-84 points of electrical damage to the first thing it hits. +2142 Tempest 7 Neutral Other 210 LightningVolley 325 -1 War Magic 35 Shoots five bolts of lightning toward the target. Each bolt does 42-84 points of electric damage to the first thing it hits. +2143 Pummeling Storm 7 Neutral Other 132 BludgeoningBurst 325 -1 War Magic 35 Shoots five shock waves outward from the caster. Each wave does 42-84 points of damage to the first thing it hits. +2144 Crushing Shame 7 Neutral Other 118 BludgeoningMissile 300 -1 War Magic 35 Shoots a shock wave at the target. The wave does 115-189 points of bludgeoning damage to the first thing it hits. +2145 Cameron's Curse 7 Neutral Other 244 BludgeoningStreak 300 -1 War Magic 70 Sends a shock wave streaking towards the target. The wave does 42-84 points of bludgeoning damage to the first thing it hits. +2146 Evisceration 7 Neutral Other 123 SlashingMissile 300 -1 War Magic 35 Shoots a magical blade at the target. The bolt does 115-189 points of slashing damage to the first thing it hits. +2147 Rending Wind 7 Neutral Other 249 SlashingStreak 300 -1 War Magic 70 Sends a magical blade streaking towards the target. The bolt does 42-84 points of slashing damage to the first thing it hits. +2148 Caustic Boon 7 Buff Other 101 AcidProtection 300 3600 Life Magic 70 Reduces damage the target takes from acid by 65%. +2149 Caustic Blessing 7 Buff Other 101 AcidProtection 300 3600 Life Magic 70 Reduces damage the caster takes from acid by 65%. +2150 Boon of the Blade Turner 7 Buff Other 113 SlashProtection 300 3600 Life Magic 70 Reduces damage the target takes from Slashing by 65%. +2151 Blessing of the Blade Turner 7 Buff Other 113 SlashProtection 300 3600 Life Magic 70 Reduces damage the caster takes from Slashing by 65%. +2152 Boon of the Mace Turner 7 Buff Other 103 BludgeonProtection 300 3600 Life Magic 70 Reduces damage the target takes from Bludgeoning by 65%. +2153 Blessing of the Mace Turner 7 Buff Other 103 BludgeonProtection 300 3600 Life Magic 70 Reduces damage the caster takes from Bludgeoning by 65%. +2154 Icy Boon 7 Buff Other 105 ColdProtection 300 3600 Life Magic 70 Reduces damage the target takes from Cold by 65%. +2155 Icy Blessing 7 Buff Other 105 ColdProtection 300 3600 Life Magic 70 Reduces damage the caster takes from Cold by 65%. +2156 Fiery Boon 7 Buff Other 109 FireProtection 300 3600 Life Magic 70 Reduces damage the target takes from fire by 65%. +2157 Fiery Blessing 7 Buff Other 109 FireProtection 300 3600 Life Magic 70 Reduces damage the caster takes from Fire by 65%. +2158 Storm's Boon 7 Buff Other 107 ElectricProtection 300 3600 Life Magic 70 Reduces damage the target takes from Lightning by 65%. +2159 Storm's Blessing 7 Buff Other 107 ElectricProtection 300 3600 Life Magic 70 Reduces damage the caster takes from Lightning by 65%. +2160 Boon of the Arrow Turner 7 Buff Other 111 PierceProtection 300 3600 Life Magic 70 Reduces damage the target takes from Piercing by 65%. +2161 Blessing of the Arrow Turner 7 Buff Other 111 PierceProtection 300 3600 Life Magic 70 Reduces damage the caster takes from Piercing by 65%. +2162 Olthoi's Gift 7 Buff Other 102 AcidVulnerability 325 240 Life Magic 70 Increases damage the target takes from acid by 185%. +2163 Acid Vulnerability Self VII 7 Debuff Self 102 AcidVulnerability 325 240 Life Magic 70 Increases damage the caster takes from acid by 185%. +2164 Swordsman's Gift 7 Buff Other 114 SlashVulnerability 325 240 Life Magic 70 Increases damage the target takes from Slashing by 185%. +2165 Blade Vulnerability Self VII 7 Debuff Self 114 SlashVulnerability 325 240 Life Magic 70 Increases damage the caster takes from Slashing by 185%. +2166 Tusker's Gift 7 Buff Other 104 BludgeonVulnerability 325 240 Life Magic 70 Increases damage the target takes from Bludgeoning by 185%. +2167 Bludgeoning Vulnerability Self VII 7 Debuff Self 104 BludgeonVulnerability 325 240 Life Magic 70 Increases damage the caster takes from Bludgeoning by 185%. +2168 Gelidite's Gift 7 Buff Other 106 ColdVulnerability 325 240 Life Magic 70 Increases damage the target takes from Cold by 185%. +2169 Cold Vulnerability Self VII 7 Debuff Self 106 ColdVulnerability 325 240 Life Magic 70 Increases damage the caster takes from Cold by 185%. +2170 Inferno's Gift 7 Buff Other 110 FireVulnerability 325 240 Life Magic 70 Increases damage the target takes from Fire by 185%. +2171 Fire Vulnerability Self VII 7 Debuff Self 110 FireVulnerability 325 240 Life Magic 70 Increases damage the caster takes from Fire by 185%. +2172 Astyrrian's Gift 7 Buff Other 108 ElectricVulnerability 325 240 Life Magic 70 Increases damage the target takes from Lightning by 185%. +2173 Lightning Vulnerability Self VII 7 Debuff Self 108 ElectricVulnerability 325 240 Life Magic 70 Increases damage the caster takes from Lightning by 185%. +2174 Archer's Gift 7 Buff Other 112 PierceVulnerability 325 240 Life Magic 70 Increases damage the target takes from Piercing by 185%. +2175 Piercing Vulnerability Self VII 7 Debuff Self 112 PierceVulnerability 325 240 Life Magic 70 Increases damage the caster takes from Piercing by 185%. +2176 Enervation 7 Debuff Other 96 StaminaDecelerating 325 240 Life Magic 70 Decreases the rate at which the target regains Stamina by 60%. +2177 Exhaustion Self VII 7 Debuff Self 96 StaminaDecelerating 325 240 Life Magic 70 Decreases the rate at which the caster regains Stamina by 60%. +2178 Decrepitude's Grasp 7 Debuff Other 94 HealthDecelerating 325 240 Life Magic 70 Decrease target's natural healing rate by 60%. +2179 Fester Self VII 7 Debuff Self 94 HealthDecelerating 325 240 Life Magic 70 Decrease caster's natural healing rate by 60%. +2180 Energy Flux 7 Debuff Other 98 ManaDecelerating 325 240 Life Magic 70 Decreases target's natural mana rate by 60%. +2181 Mana Depletion Self VII 7 Debuff Self 98 ManaDecelerating 325 240 Life Magic 70 Decreases caster's natural mana rate by 60%. +2182 Battlemage's Boon 7 Buff Other 97 ManaAccelerating 300 3600 Life Magic 70 Increases the target's natural mana rate by 115%. +2183 Battlemage's Blessing 7 Buff Other 97 ManaAccelerating 300 3600 Life Magic 70 Increases the caster's natural mana rate by 115%. +2184 Hydra's Head 7 Buff Other 93 HealthAccelerating 300 3600 Life Magic 70 Increase target's natural healing rate by 115%. +2185 Robustify 7 Buff Other 93 HealthAccelerating 300 3600 Life Magic 70 Increase caster's natural healing rate by 115%. +2186 Tenaciousness 7 Buff Other 95 StaminaAccelerating 300 3600 Life Magic 70 Increases the rate at which the target regains Stamina by 115%. +2187 Unflinching Persistence 7 Buff Other 95 StaminaAccelerating 300 3600 Life Magic 70 Increases the rate at which the caster regains Stamina by 115%. +2188 Bottle Breaker 7 Debuff Other 220 AlchemyLowering 325 240 Creature Enchantment 70 Decreases the target's Alchemy skill by 40 points. +2189 Alchemy Ineptitude Self VII 7 Debuff Self 220 AlchemyLowering 325 240 Creature Enchantment 70 Decreases the caster's Alchemy skill by 40 points. +2190 Silencia's Boon 7 Buff Other 221 AlchemyRaising 300 3600 Creature Enchantment 70 Increases the target's Alchemy skill by 40 points. +2191 Silencia's Blessing 7 Buff Other 221 AlchemyRaising 300 3600 Creature Enchantment 70 Increases the caster's Alchemy skill by 40 points. +2192 Hands of Chorizite 7 Debuff Other 54 ArcaneLoreLowering 325 240 Creature Enchantment 70 Decreases the target's Arcane Lore skill by 40 points. +2193 Arcane Benightedness Self VII 7 Debuff Self 54 ArcaneLoreLowering 325 240 Creature Enchantment 70 Decreases the caster's Arcane Lore skill by 40 points. +2194 Aliester's Boon 7 Buff Other 53 ArcaneLoreRaising 300 3600 Creature Enchantment 70 Increases the target's Arcane Lore skill by 40 points. +2195 Aliester's Blessing 7 Buff Other 53 ArcaneLoreRaising 300 3600 Creature Enchantment 70 Increases the caster's Arcane Lore skill by 40 points. +2196 Jibril's Boon 7 Buff Other 55 AppraiseArmorRaising 300 3600 Creature Enchantment 70 Increases the target's Armor Tinkering skill by 40 points. +2197 Jibril's Blessing 7 Buff Other 55 AppraiseArmorRaising 300 3600 Creature Enchantment 70 Increases the caster's Armor Tinkering skill by 40 points. +2198 Jibril's Vitae 7 Debuff Other 56 AppraiseArmorLowering 325 240 Creature Enchantment 70 Decreases the target's Armor Tinkering skill by 40 points. +2199 Armor Tinkering Ignorance Self VII 7 Debuff Self 56 AppraiseArmorLowering 325 240 Creature Enchantment 70 Decreases the caster's Armor Tinkering skill by 40 points. +2200 Light Weapon Ineptitude Other VII 7 Debuff Other 18 AxeLowering 325 240 Creature Enchantment 70 Decreases the target's Light Weapons skill by 40 points. +2201 Light Weapon Ineptitude Self VII 7 Debuff Self 18 AxeLowering 325 240 Creature Enchantment 70 Decreases the caster's Light Weapons skill by 40 points. +2202 Light Weapon Mastery Other VII 7 Buff Other 17 AxeRaising 300 3600 Creature Enchantment 70 Increases the target's Light Weapons skill by 40 points. +2203 Light Weapon Mastery Self VII 7 Buff Self 17 AxeRaising 300 3600 Creature Enchantment 70 Increases the caster's Light Weapons skill by 40 points. +2204 Missile Weapon Ineptitude Other VII 7 Debuff Other 20 BowLowering 325 240 Creature Enchantment 70 Decreases the target's Missile Weapons skill by 40 points. +2205 Missile Weapon Ineptitude Self VII 7 Debuff Self 20 BowLowering 325 240 Creature Enchantment 70 Decreases the caster's Missile Weapons skill by 40 points. +2206 Missile Weapon Mastery Other VII 7 Buff Other 19 BowRaising 300 3600 Creature Enchantment 70 Increases the target's Missile Weapons skill by 40 points. +2207 Missile Weapon Mastery Self VII 7 Buff Self 19 BowRaising 300 3600 Creature Enchantment 70 Increases the caster's Missile Weapons skill by 40 points. +2208 Challenger's Legacy 7 Debuff Other 217 CookingLowering 325 240 Creature Enchantment 70 Decreases the target's Cooking skill by 40 points. +2209 Cooking Ineptitude Self VII 7 Debuff Self 217 CookingLowering 325 240 Creature Enchantment 70 Decreases the caster's Cooking skill by 40 points. +2210 Morimoto's Boon 7 Buff Other 216 CookingRaising 300 3600 Creature Enchantment 70 Increases the target's Cooking skill by 40 points. +2211 Morimoto's Blessing 7 Buff Other 216 CookingRaising 300 3600 Creature Enchantment 70 Increases the caster's Cooking skill by 40 points. +2212 Wrath of Adja 7 Debuff Other 44 CreatureEnchantmentLowering 325 240 Creature Enchantment 70 Decreases the target's Creature Enchantment skill by 40 points. +2213 Creature Enchantment Ineptitude Self VII 7 Debuff Self 44 CreatureEnchantmentLowering 325 240 Creature Enchantment 70 Decreases the caster's Creature Enchantment skill by 40 points. +2214 Adja's Boon 7 Buff Other 43 CreatureEnchantmentRaising 300 3600 Creature Enchantment 70 Increases the target's Creature Enchantment skill by 40 points. +2215 Adja's Blessing 7 Buff Other 43 CreatureEnchantmentRaising 300 3600 Creature Enchantment 70 Increases the caster's Creature Enchantment skill by 40 points. +2216 Missile Weapon Ineptitude Other VII 7 Debuff Other 20 BowLowering 325 240 Creature Enchantment 70 Decreases the target's Missile Weapons skill by 40 points. +2217 Missile Weapon Ineptitude Self VII 7 Debuff Self 20 BowLowering 325 240 Creature Enchantment 70 Decreases the caster's Missile Weapons skill by 40 points. +2218 Missile Weapon Mastery Other VII 7 Buff Other 19 BowRaising 300 3600 Creature Enchantment 70 Increases the target's Missile Weapons skill by 40 points. +2219 Missile Weapon Mastery Self VII 7 Buff Self 19 BowRaising 300 3600 Creature Enchantment 70 Increases the caster's Missile Weapons skill by 40 points. +2220 Finesse Weapon Ineptitude Other VII 7 Debuff Other 24 DaggerLowering 325 240 Creature Enchantment 70 Decreases the target's Finesse Weapons skill by 40 points. +2221 Finesse Weapon Ineptitude Self VII 7 Debuff Self 24 DaggerLowering 325 240 Creature Enchantment 70 Decreases the caster's Finesse Weapons skill by 40 points. +2222 Finesse Weapon Mastery Other VII 7 Buff Other 23 DaggerRaising 300 3600 Creature Enchantment 70 Increases the target's Finesse Weapons skill by 40 points. +2223 Finesse Weapon Mastery Self VII 7 Buff Self 23 DaggerRaising 300 3600 Creature Enchantment 70 Increases the caster's Finesse Weapons skill by 40 points. +2224 Hearts on Sleeves 7 Debuff Other 66 DeceptionLowering 325 240 Creature Enchantment 70 Decreases the target's Deception skill by 40 points. +2225 Deception Ineptitude Self VII 7 Debuff Self 66 DeceptionLowering 325 240 Creature Enchantment 70 Decreases the caster's Deception skill by 40 points. +2226 Ketnan's Boon 7 Buff Other 65 DeceptionRaising 300 3600 Creature Enchantment 70 Increases the target's Deception skill by 40 points. +2227 Ketnan's Blessing 7 Buff Other 65 DeceptionRaising 300 3600 Creature Enchantment 70 Increases the caster's Deception skill by 40 points. +2228 Broadside of a Barn 7 Debuff Other 40 MissileDefenseLowering 325 240 Creature Enchantment 70 Decreases the target's Missile Defense skill by 40 points. +2229 Defenselessness Self VII 7 Debuff Self 40 MissileDefenseLowering 325 240 Creature Enchantment 70 Decreases the caster's Missile Defense skill by 40 points. +2230 Sashi Mu's Kiss 7 Debuff Other 76 LoyaltyLowering 325 240 Creature Enchantment 70 Decreases the target's Loyalty skill by 40 points. +2231 Faithlessness Self VII 7 Debuff Self 76 LoyaltyLowering 325 240 Creature Enchantment 70 Decreases the caster's Loyalty skill by 40 points. +2232 Odif's Boon 7 Buff Other 75 LoyaltyRaising 300 3600 Creature Enchantment 70 Increases the target's Loyalty skill by 40 points. +2233 Odif's Blessing 7 Buff Other 75 LoyaltyRaising 300 3600 Creature Enchantment 70 Increases the caster's Loyalty skill by 40 points. +2234 Twisted Digits 7 Debuff Other 219 FletchingLowering 325 240 Creature Enchantment 70 Decreases the target's Fletching skill by 40 points. +2235 Fletching Ineptitude Self VII 7 Debuff Self 219 FletchingLowering 325 240 Creature Enchantment 70 Decreases the caster's Fletching skill by 40 points. +2236 Lilitha's Boon 7 Buff Other 218 FletchingRaising 300 3600 Creature Enchantment 70 Increases the target's Fletching skill by 40 points. +2237 Lilitha's Blessing 7 Buff Other 218 FletchingRaising 300 3600 Creature Enchantment 70 Increases the caster's Fletching skill by 40 points. +2238 Unsteady Hands 7 Debuff Other 68 HealingLowering 325 240 Creature Enchantment 70 Decreases the target's Healing skill by 40 points. +2239 Healing Ineptitude Self VII 7 Heal Self 68 HealingLowering 325 240 Creature Enchantment 70 Decreases the caster's Healing skill by 40 points. +2240 Avalenne's Boon 7 Buff Other 67 HealingRaising 300 3600 Creature Enchantment 70 Increases the target's Healing skill by 40 points. +2241 Avalenne's Blessing 7 Buff Other 67 HealingRaising 300 3600 Creature Enchantment 70 Increases the caster's Healing skill by 40 points. +2242 Web of Deflection 7 Buff Other 39 MissileDefenseRaising 300 3600 Creature Enchantment 70 Increases the target's Missile Defense skill by 40 points. +2243 Aura of Deflection 7 Buff Other 39 MissileDefenseRaising 300 3600 Creature Enchantment 70 Increases the caster's Missile Defense skill by 40 points. +2244 Web of Defense 7 Buff Other 37 MeleeDefenseRaising 300 3600 Creature Enchantment 70 Increases the target's Melee Defense skill by 40 points. +2245 Aura of Defense 7 Buff Other 37 MeleeDefenseRaising 300 3600 Creature Enchantment 70 Increases the caster's Melee Defense skill by 40 points. +2246 Wrath of Celcynd 7 Debuff Other 46 ItemEnchantmentLowering 325 240 Creature Enchantment 70 Decreases the target's Item Enchantment skill by 40 points. +2247 Item Enchantment Ineptitude Self VII 7 Debuff Self 46 ItemEnchantmentLowering 325 240 Creature Enchantment 70 Decreases the caster's Item Enchantment skill by 40 points. +2248 Celcynd's Boon 7 Buff Other 45 ItemEnchantmentRaising 300 3600 Creature Enchantment 70 Increases the target's Item Enchantment skill by 40 points. +2249 Celcynd's Blessing 7 Buff Other 45 ItemEnchantmentRaising 300 3600 Creature Enchantment 70 Increases the caster's Item Enchantment skill by 40 points. +2250 Yoshi's Boon 7 Buff Other 57 AppraiseItemRaising 300 3600 Creature Enchantment 70 Increases the target's Item Tinkering skill by 40 points. +2251 Yoshi's Blessing 7 Buff Other 57 AppraiseItemRaising 300 3600 Creature Enchantment 70 Increases the caster's Item Tinkering skill by 40 points. +2252 Unfortunate Appraisal 7 Debuff Other 58 AppraiseItemLowering 325 240 Creature Enchantment 70 Decreases the target's Item Tinkering skill by 40 points. +2253 Item Tinkering Ignorance Self VII 7 Debuff Self 58 AppraiseItemLowering 325 240 Creature Enchantment 70 Decreases the caster's Item Tinkering skill by 40 points. +2254 Feat of Radaz 7 Debuff Other 70 JumpLowering 325 240 Creature Enchantment 70 Decreases the target's Jump skill by 40 points. +2255 Jumping Ineptitude Self VII 7 Debuff Self 70 JumpLowering 325 240 Creature Enchantment 70 Decreases the caster's Jump skill by 40 points. +2256 Jahannan's Boon 7 Buff Other 69 JumpRaising 300 3600 Creature Enchantment 70 Increases the target's Jump skill by 40 points. +2257 Jahannan's Blessing 7 Buff Other 69 JumpRaising 300 3600 Creature Enchantment 70 Increases the caster's Jump skill by 40 points. +2258 Gears Unwound 7 Debuff Other 78 RunLowering 325 240 Creature Enchantment 70 Decreases the target's Run skill by 40 points. +2259 Leaden Feet Self VII 7 Debuff Self 78 RunLowering 325 240 Creature Enchantment 70 Decreases the caster's Run skill by 40 points. +2260 Kwipetian Vision 7 Debuff Other 72 LeadershipLowering 325 240 Creature Enchantment 70 Decreases the target's Leadership skill by 40 points. +2261 Leadership Ineptitude Self VII 7 Debuff Self 72 LeadershipLowering 325 240 Creature Enchantment 70 Decreases the caster's Leadership skill by 40 points. +2262 Ar-Pei's Boon 7 Buff Other 71 LeadershipRaising 300 3600 Creature Enchantment 70 Increases the target's Leadership skill by 40 points. +2263 Ar-Pei's Blessing 7 Buff Other 71 LeadershipRaising 300 3600 Creature Enchantment 70 Increases the caster's Leadership skill by 40 points. +2264 Wrath of Harlune 7 Debuff Other 48 LifeMagicLowering 325 240 Creature Enchantment 70 Decreases the target's Life Magic skill by 40 points. +2265 Life Magic Ineptitude Self VII 7 Debuff Self 48 LifeMagicLowering 325 240 Creature Enchantment 70 Decreases the caster's Life Magic skill by 40 points. +2266 Harlune's Boon 7 Buff Other 47 LifeMagicRaising 300 3600 Creature Enchantment 70 Increases the target's Life Magic skill by 40 points. +2267 Harlune's Blessing 7 Buff Other 47 LifeMagicRaising 300 3600 Creature Enchantment 70 Increases the caster's Life Magic skill by 40 points. +2268 Fat Fingers 7 Debuff Other 74 LockpickLowering 325 240 Creature Enchantment 70 Decreases the target's Lockpick skill by 40 points. +2269 Lockpick Ineptitude Self VII 7 Debuff Self 74 LockpickLowering 325 240 Creature Enchantment 70 Decreases the caster's Lockpick skill by 40 points. +2270 Oswald's Boon 7 Buff Other 73 LockpickRaising 300 3600 Creature Enchantment 70 Increases the target's Lockpick skill by 40 points. +2271 Oswald's Blessing 7 Buff Other 73 LockpickRaising 300 3600 Creature Enchantment 70 Increases the caster's Lockpick skill by 40 points. +2272 Light Weapon Ineptitude Other VII 7 Debuff Other 18 AxeLowering 325 240 Creature Enchantment 70 Decreases the target's Light Weapons skill by 40 points. +2273 Light Weapon Ineptitude Self VII 7 Debuff Self 18 AxeLowering 325 240 Creature Enchantment 70 Decreases the caster's Light Weapons skill by 40 points. +2274 Light Weapon Mastery Other VII 7 Buff Other 17 AxeRaising 300 3600 Creature Enchantment 70 Increases the target's Light Weapons skill by 40 points. +2275 Light Weapon Mastery Self VII 7 Buff Self 17 AxeRaising 300 3600 Creature Enchantment 70 Increases the caster's Light Weapons skill by 40 points. +2276 Celdiseth's Boon 7 Buff Other 59 AppraiseMagicItemRaising 300 3600 Creature Enchantment 70 Increases the target's Magic Item Tinkering skill by 40 points. +2277 Celdiseth's Blessing 7 Buff Other 59 AppraiseMagicItemRaising 300 3600 Creature Enchantment 70 Increases the caster's Magic Item Tinkering skill by 40 points. +2278 Eyes Clouded 7 Debuff Other 60 AppraiseMagicItemLowering 325 240 Creature Enchantment 70 Decreases the target's Magic Item Tinkering skill by 40 points. +2279 Magic Item Tinkering Ignorance Self VII 7 Debuff Self 60 AppraiseMagicItemLowering 325 240 Creature Enchantment 70 Decreases the caster's Magic Item Tinkering skill by 40 points. +2280 Web of Resistance 7 Buff Other 41 MagicDefenseRaising 300 3600 Creature Enchantment 70 Increases the target's Magic Defense skill by 40 points. +2281 Aura of Resistance 7 Buff Other 41 MagicDefenseRaising 300 3600 Creature Enchantment 70 Increases the caster's Magic Defense skill by 40 points. +2282 Futility 7 Debuff Other 42 MagicDefenseLowering 325 240 Creature Enchantment 70 Decreases the target's Magic Defense skill by 40 points. +2283 Magic Yield Self VII 7 Debuff Self 42 MagicDefenseLowering 325 240 Creature Enchantment 70 Decreases the caster's Magic Defense skill by 40 points. +2284 Inefficient Investment 7 Debuff Other 52 ManaConversionLowering 325 240 Creature Enchantment 70 Decreases the target's Mana Conversion skill by 40 points. +2285 Mana Conversion Ineptitude Self VII 7 Debuff Self 52 ManaConversionLowering 325 240 Creature Enchantment 70 Decreases the caster's Mana Conversion skill by 40 points. +2286 Nuhmudira's Boon 7 Buff Other 51 ManaConversionRaising 300 3600 Creature Enchantment 70 Increases the target's Mana Conversion skill by 40 points. +2287 Nuhmudira's Blessing 7 Buff Other 51 ManaConversionRaising 300 3600 Creature Enchantment 70 Increases the caster's Mana Conversion skill by 40 points. +2288 Topheron's Boon 7 Buff Other 63 AssessMonsterRaising 300 3600 Creature Enchantment 70 Increases the target's Assess Monster skill by 40 points. +2289 Topheron's Blessing 7 Buff Other 63 AssessMonsterRaising 300 3600 Creature Enchantment 70 Increases the caster's Assess Monster skill by 40 points. +2290 Ignorance's Bliss 7 Debuff Other 64 AssessMonsterLowering 325 240 Creature Enchantment 70 Decreases the target's Assess Monster skill by 40 points. +2291 Monster Unfamiliarity Self VII 7 Debuff Self 64 AssessMonsterLowering 325 240 Creature Enchantment 70 Decreases the caster's Assess Monster skill by 40 points. +2292 Kaluhc's Boon 7 Buff Other 205 AssessPersonRaising 300 3600 Creature Enchantment 70 Increases the target's Assess Person skill by 40 points. +2293 Kaluhc's Blessing 7 Buff Other 205 AssessPersonRaising 300 3600 Creature Enchantment 70 Increases the caster's Assess Person skill by 40 points. +2294 Introversion 7 Debuff Other 206 AssessPersonLowering 325 240 Creature Enchantment 70 Decreases the target's Assess Person skill by 40 points. +2295 Person Unfamiliarity Self VII 7 Debuff Self 206 AssessPersonLowering 325 240 Creature Enchantment 70 Decreases the caster's Assess Person skill by 40 points. +2296 Light Weapon Ineptitude Other VII 7 Debuff Other 18 AxeLowering 325 240 Creature Enchantment 70 Decreases the target's Light Weapons skill by 40 points. +2297 Light Weapon Ineptitude Self VII 7 Debuff Self 18 AxeLowering 325 240 Creature Enchantment 70 Decreases the caster's Light Weapons skill by 40 points. +2298 Light Weapon Mastery Other VII 7 Buff Other 17 AxeRaising 300 3600 Creature Enchantment 70 Increases the target's Light Weapons skill by 40 points. +2299 Light Weapon Mastery Self VII 7 Buff Self 17 AxeRaising 300 3600 Creature Enchantment 70 Increases the caster's Light Weapons skill by 40 points. +2300 Saladur's Boon 7 Buff Other 77 RunRaising 300 3600 Creature Enchantment 70 Increases the target's Run skill by 40 points. +2301 Saladur's Blessing 7 Buff Other 77 RunRaising 300 3600 Creature Enchantment 70 Increases the caster's Run skill by 40 points. +2302 Light Weapon Ineptitude Other VII 7 Debuff Other 18 AxeLowering 325 240 Creature Enchantment 70 Decreases the target's Light Weapons skill by 40 points. +2303 Light Weapon Ineptitude Self VII 7 Debuff Self 18 AxeLowering 325 240 Creature Enchantment 70 Decreases the caster's Light Weapons skill by 40 points. +2304 Light Weapon Mastery Other VII 7 Buff Other 17 AxeRaising 300 3600 Creature Enchantment 70 Increases the target's Light Weapons skill by 40 points. +2305 Light Weapon Mastery Self VII 7 Buff Self 17 AxeRaising 300 3600 Creature Enchantment 70 Increases the caster's Light Weapons skill by 40 points. +2306 Heavy Weapon Ineptitude Other VII 7 Debuff Other 32 SwordLowering 325 240 Creature Enchantment 70 Decreases the target's Heavy Weapons skill by 40 points. +2307 Heavy Weapon Ineptitude Self VII 7 Debuff Self 32 SwordLowering 325 240 Creature Enchantment 70 Decreases the caster's Heavy Weapons skill by 40 points. +2308 Heavy Weapon Mastery Other VII 7 Buff Other 31 SwordRaising 300 3600 Creature Enchantment 70 Increases the target's Heavy Weapons skill by 40 points. +2309 Heavy Weapon Mastery Self VII 7 Buff Self 31 SwordRaising 300 3600 Creature Enchantment 70 Increases the caster's Heavy Weapons skill by 40 points. +2310 Missile Weapon Ineptitude Other VII 7 Debuff Other 20 BowLowering 325 240 Creature Enchantment 70 Decreases the target's Missile Weapons skill by 40 points. +2311 Missile Weapon Ineptitude Self VII 7 Debuff Self 20 BowLowering 325 240 Creature Enchantment 70 Decreases the caster's Missile Weapons skill by 40 points. +2312 Missile Weapon Mastery Other VII 7 Buff Other 19 BowRaising 300 3600 Creature Enchantment 70 Increases the target's Missile Weapons skill by 40 points. +2313 Missile Weapon Mastery Self VII 7 Buff Self 19 BowRaising 300 3600 Creature Enchantment 70 Increases the caster's Missile Weapons skill by 40 points. +2314 Light Weapon Ineptitude Other VII 7 Debuff Other 18 AxeLowering 325 240 Creature Enchantment 70 Decreases the target's Light Weapons skill by 40 points. +2315 Light Weapon Mastery Other VII 7 Buff Other 17 AxeRaising 300 3600 Creature Enchantment 70 Increases the target's Light Weapons skill by 40 points. +2316 Light Weapon Mastery Self VII 7 Buff Self 17 AxeRaising 300 3600 Creature Enchantment 70 Increases the caster's Light Weapons skill by 40 points. +2317 Light Weapon Ineptitude Other VII 7 Debuff Other 18 AxeLowering 325 240 Creature Enchantment 70 Decreases the target's Light Weapons skill by 40 points. +2318 Gravity Well 7 Debuff Other 38 MeleeDefenseLowering 325 240 Creature Enchantment 70 Decrease the target's Melee Defense skill by 40 points. +2319 Vulnerability Self VII 7 Debuff Self 38 MeleeDefenseLowering 325 240 Creature Enchantment 70 Decrease the target's Melee Defense skill by 40 points. +2320 Wrath of the Hieromancer 7 Debuff Other 50 WarMagicLowering 325 240 Creature Enchantment 70 Decreases the target's War Magic skill by 40 points. +2321 War Magic Ineptitude Self VII 7 Debuff Self 50 WarMagicLowering 325 240 Creature Enchantment 70 Decreases the caster's War Magic skill by 40 points. +2322 Hieromancer's Boon 7 Buff Other 49 WarMagicRaising 300 3600 Creature Enchantment 70 Increases the target's War Magic skill by 40 points. +2323 Hieromancer's Blessing 7 Buff Other 49 WarMagicRaising 300 3600 Creature Enchantment 70 Increases the caster's War Magic skill by 40 points. +2324 Koga's Boon 7 Buff Other 61 AppraiseWeaponRaising 300 3600 Creature Enchantment 70 Increases the target's Weapon Tinkering skill by 40 points. +2325 Koga's Blessing 7 Buff Other 61 AppraiseWeaponRaising 300 3600 Creature Enchantment 70 Increases the caster's Weapon Tinkering skill by 40 points. +2326 Eye of the Grunt 7 Debuff Other 62 AppraiseWeaponLowering 325 240 Creature Enchantment 70 Decreases the target's Weapon Tinkering skill by 40 points. +2327 Weapon Tinkering Ignorance Self VII 7 Debuff Self 62 AppraiseWeaponLowering 325 240 Creature Enchantment 70 Decreases the caster's Weapon Tinkering skill by 40 points. +2328 Vitality Siphon 7 Neutral Other 87 HealthTransfertocaster 325 -1 Life Magic 60 Drains 50% of the target's Health and gives 50% of it to the caster. +2329 Essence Void 7 Neutral Other 91 ManaTransfertocaster 325 -1 Life Magic 60 Drains 50% of the target's Mana and gives it to the caster. +2330 Vigor Siphon 7 Neutral Other 89 StaminaTransfertocaster 325 -1 Life Magic 60 Drains 50% of the target's Stamina and gives it to the caster. +2331 Health to Mana Other VII 7 Heal Other 87 HealthTransfertocaster 300 -1 Life Magic 70 Drains one-half of the target's Health and gives 175% of that to his/her Mana. +2332 Cannibalize 7 Neutral Other 87 HealthTransfertocaster 300 -1 Life Magic 70 Drains one-half of the caster's Health and gives 175% of that to his/her Mana. +2333 Health to Stamina Other VII 7 Heal Other 87 HealthTransfertocaster 300 -1 Life Magic 70 Drains one-half of the target's Health and gives 175% of that to his/her Stamina. +2334 Self Sacrifice 7 Neutral Other 87 HealthTransfertocaster 300 -1 Life Magic 70 Drains one-half of the caster's Health and gives 175% of that to his/her Stamina. +2335 Gift of Vitality 7 Neutral Other 88 HealthTransferfromcaster 300 -1 Life Magic 70 Drains one-quarter of the caster's Health and gives 175% of that to the target. +2336 Gift of Essence 7 Neutral Other 92 ManaTransferfromcaster 300 -1 Life Magic 70 Drains one-quarter of the caster's Mana and gives 175% of that to the target. +2337 Gift of Vigor 7 Neutral Other 90 StaminaTransferfromcaster 300 -1 Life Magic 70 Drains one-quarter of the caster's Stamina and gives 175% of that to the target. +2338 Mana to Health Other VII 7 Neutral Other 91 ManaTransfertocaster 300 -1 Life Magic 70 Drains one-half of the target's Mana and gives 175% of that to his/her Health. +2339 Energize Vitality 7 Neutral Other 91 ManaTransfertocaster 300 -1 Life Magic 70 Drains one-half of the caster's Mana and gives 175% of that to his/her Health. +2340 Mana to Stamina Other VII 7 Neutral Other 91 ManaTransfertocaster 300 -1 Life Magic 70 Drains one-half of the target's Mana and gives 175% of that to his/her stamina. +2341 Energize Vigor 7 Neutral Other 91 ManaTransfertocaster 300 -1 Life Magic 70 Drains one-half of the caster's Mana and gives 175% of that to his/her Stamina. +2342 Stamina to Health Other VII 7 Neutral Other 89 StaminaTransfertocaster 300 -1 Life Magic 70 Drains one-half of the target's Stamina and gives 175% of that to his/her Health. +2343 Rushed Recovery 7 Neutral Other 89 StaminaTransfertocaster 300 -1 Life Magic 70 Drains one-half of the caster's Stamina and gives 175% of that to his/her Health. +2344 Stamina to Mana Other VII 7 Neutral Other 89 StaminaTransfertocaster 300 -1 Life Magic 70 Drains one-half of the target's Stamina and gives 175% of that to his/her Mana. +2345 Meditative Trance 7 Neutral Other 89 StaminaTransfertocaster 300 -1 Life Magic 70 Drains one-half of the caster's Stamina and gives 175% of that to his/her Mana. +2346 Malediction 2 Debuff Other 284 ManaTakerLowering 50 510 Life Magic 70 Decreases maximum mana by 50 points. +2347 Concentration 3 Buff Other 13 FocusConcentration 100 1000 Creature Enchantment 40 Increases the caster's Focus by 25 points. +2348 Brilliance 6 Buff Other 15 FocusBrilliance 250 30 Creature Enchantment 60 Increases the target's Focus by 50 points for a short period of time. +2349 Hieromancer's Ward 5 Buff Item 190 ArmorLevelRaising 200 780 Item Enchantment 50 Improves a shield or piece of armor's armor value by 170 points. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. allowing additional magical defenses to be layered over it. +2350 Greater Decay Durance 5 Buff Item 188 AcidicResistanceRaising 200 780 Item Enchantment 50 Increases a shield or piece of armor's resistance to acid damage by 100%. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. allowing additional magical defenses to be layered over it. +2351 Greater Consumption Durance 5 Buff Item 186 FlameResistanceRaising 200 780 Item Enchantment 50 Increases a shield or piece of armor's resistance to fire damage by 100%. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. allowing additional magical defenses to be layered over it. +2352 Greater Stasis Durance 5 Buff Item 184 FrostResistanceRaising 200 780 Item Enchantment 50 Increases a shield or piece of armor's resistance to cold damage by 100%. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. allowing additional magical defenses to be layered over it. +2353 Greater Stimulation Durance 5 Buff Item 182 ElectricalResistanceRaising 200 780 Item Enchantment 50 Increases a shield or piece of armor's resistance to electric damage by 100%. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. allowing additional magical defenses to be layered over it. +2354 Lesser Piercing Durance 2 Buff Item 180 PiercingResistanceRaising 50 360 Item Enchantment 20 Increases a shield or piece of armor's resistance to piercing damage by 25%. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. allowing additional magical defenses to be layered over it. +2355 Lesser Slashing Durance 2 Buff Item 178 SlashingResistanceRaising 50 360 Item Enchantment 20 Increases a shield or piece of armor's resistance to slashing damage by 25%. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. allowing additional magical defenses to be layered over it. +2356 Lesser Bludgeoning Durance 2 Buff Item 176 BludgeoningResistanceRaising 50 360 Item Enchantment 20 Increases a shield or piece of armor's resistance to bludgeoning damage by 25%. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. allowing additional magical defenses to be layered over it. +2357 Fauna Perlustration 6 Buff Other 63 AssessMonsterRaising 250 1020 Creature Enchantment 60 Increases the target's Assess Monster skill by 60 points. +2358 Lyceum Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 150 Transports the caster to the Ishilai Lyceum. +2359 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2360 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2361 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2362 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2363 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2364 Egress 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2365 something you're gonna fear for a long time 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2366 Bovine Intervention 7 Neutral Other 237 BludgeoningStrike 350 -1 Creature Enchantment 300 When Cow gods intervene..... +2367 Groovy Portal Sending 8 Utility Self 214 PortalSending 2000 -1 Item Enchantment 50000 Sends you on a magical. groove-filled trip.... +2368 a powerful force 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2369 Expulsion 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target out of Lady Aerfalle's presence. +2370 Gift of Rotting Flesh 7 Buff Other 102 AcidVulnerability 325 120 Life Magic 70 Increases damage the target takes from Acid by 300%. +2371 Curse of Mortal Flesh 7 Buff Other 110 FireVulnerability 325 120 Life Magic 50 Increases damage the target takes from Fire by 300%. +2372 Price of Immortality 6 Debuff Other 94 HealthDecelerating 275 300 Life Magic 60 Prevents all natural healing by the target. +2373 Enervation of the Heart 6 Debuff Other 68 HealingLowering 250 60 Life Magic 30 Decreases maximum health by 50 points. +2374 Enervation of the Limb 6 Debuff Other 82 StaminaLowering 250 60 Life Magic 30 Decreases maximum stamina by 50 points. +2375 Enervation of the Mind 2 Debuff Other 284 ManaTakerLowering 50 60 Life Magic 30 Decreases maximum mana by 50 points. +2376 Glimpse of Annihilation 1 Buff Other 255 WarMysticRaising 5 300 Creature Enchantment 10 Increases the target's War Magic skill by 5 points. Additional enchancements to the skill can be layered over this. +2377 Vision of Annihilation 1 Buff Other 255 WarMysticRaising 10 300 Creature Enchantment 10 Increases the target's War Magic skill by 10 points. Additional enchancements to the skill can be layered over this. +2378 Beast Murmur 1 Buff Other 251 CreatureMysticRaising 10 300 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 10 points. Additional enchancements to the skill can be layered over this. +2379 Beast Whisper 1 Buff Other 251 CreatureMysticRaising 5 300 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 5 points. Additional enchancements to the skill can be layered over this. +2380 Grip of Instrumentality 1 Buff Other 253 ItemMysticRaising 1 300 Creature Enchantment 10 Increases the target's Item Enchantment skill by 10 points. Additional enchancements to the skill can be layered over this. +2381 Touch of Instrumentality 1 Buff Other 253 ItemMysticRaising 1 300 Creature Enchantment 10 Increases the target's Item Enchantment skill by 5 points. Additional enchancements to the skill can be layered over this. +2382 Unnatural Persistence 6 Buff Other 93 HealthAccelerating 285 3600 Life Magic 70 Increase caster's natural healing rate by 100%. +2383 Dark Flame 5 Neutral Other 121 FireMissile 200 -1 War Magic 25 Shoots a dark flame at the target. The flame does 68-136 points of righteous fire damage to the first thing it hits. +2384 Arcane Restoration 6 Buff Other 97 ManaAccelerating 285 3600 Life Magic 60 Increases the caster's natural mana rate by 100%. +2385 Vigilance 6 Buff Other 95 StaminaAccelerating 275 1020 Life Magic 60 Increases the rate at which the target regains Stamina by 100%. +2386 Indomitability 8 Buff Other 93 HealthAccelerating 550 1020 Life Magic 60 Increase target's natural healing rate by 200%. +2387 Determination 1 Buff Other 269 FocusIncrease 10 150 Creature Enchantment 10 Increases the target's Focus by 10 points. can be layered with other Focus spells. +2388 Caution 1 Buff Other 267 CoordinationIncrease 10 150 Creature Enchantment 10 Increases the target's Coordination by 10 points. can be layered with other Coordination spells. +2389 Vigor 1 Buff Other 263 EnduranceIncrease 10 150 Creature Enchantment 10 Increases the target's Endurance by 10 points. can be layered with other Endurance spells. +2390 Haste 1 Buff Other 265 QuicknessIncrease 10 150 Creature Enchantment 10 Increases the target's Quickness by 10 points. can be layered with other Quickness spells. +2391 Prowess 1 Buff Other 261 StrengthIncrease 10 150 Creature Enchantment 10 Increases the target's Strength by 10 points. can be layered with other Strength spells. +2392 Serenity 1 Buff Other 271 SelfIncrease 10 150 Creature Enchantment 10 Increases the target's Self by 10 points. can be layered with other Self spells. +2393 Force Armor 3 Buff Other 115 ArmorRaising 100 1800 Life Magic 40 Increases the caster's natural armor by 75 points. +2394 Acid Shield 3 Buff Other 101 AcidProtection 100 1800 Life Magic 40 Reduces damage the caster takes from acid by 33%. +2395 Electric Shield 3 Buff Other 107 ElectricProtection 100 1800 Life Magic 40 Reduces damage the caster takes from Lightning by 33%. +2396 Flame Shield 3 Buff Other 109 FireProtection 100 1800 Life Magic 40 Reduces damage the caster takes from fire by 33%. +2397 Ice Shield 3 Buff Other 105 ColdProtection 100 1800 Life Magic 40 Reduces damage the caster takes from Cold by 33%. +2398 Bludgeon Shield 3 Buff Other 103 BludgeonProtection 100 1800 Life Magic 40 Reduces damage the caster takes from Bludgeoning by 33%. +2399 Piercing Shield 3 Buff Other 111 PierceProtection 100 1800 Life Magic 40 Reduces damage the caster takes from Piercing by 33%. +2400 Slashing Shield 3 Buff Other 113 SlashProtection 100 1800 Life Magic 40 Reduces damage the caster takes from Slashing by 33%. +2401 Into the Garden 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2402 Essence Lull 3 Buff Item 83 ManaRaising 100 240 Item Enchantment 30 Reduces the rate at which mana is consumed. +2403 Balanced Breakfast 6 Buff Other 1 StrengthRaising 277 10800 Creature Enchantment 60 Increases the target's Strength by 35 points. +2404 Collector Acid Protection 7 Buff Other 101 AcidProtection 300 1800 Life Magic 70 Reduces damage the caster takes from acid by 90%. +2405 Collector Blade Protection 7 Buff Other 113 SlashProtection 300 1800 Life Magic 70 Reduces damage the caster takes from slashing by 90%. +2406 Collector Bludgeoning Protection 7 Buff Other 103 BludgeonProtection 300 1800 Life Magic 70 Reduces damage the caster takes from bludgeoning by 90%. +2407 Collector Cold Protection 7 Buff Other 105 ColdProtection 300 1800 Life Magic 70 Reduces damage the caster takes from cold by 90%. +2408 Collector Fire Protection 7 Buff Other 109 FireProtection 300 1800 Life Magic 70 Reduces damage the caster takes from fire by 90%. +2409 Collector Lightning Protection 7 Buff Other 107 ElectricProtection 300 1800 Life Magic 70 Reduces damage the caster takes from lightning by 90%. +2410 Collector Piercing Protection 7 Buff Other 111 PierceProtection 300 1800 Life Magic 70 Reduces damage the caster takes from piercing by 90%. +2411 Discipline 8 Buff Item 154 DamageRaising 450 1020 Item Enchantment 60 Increases a weapon's damage value by 30 points. +2412 Enduring Coordination 7 Buff Other 7 CoordinationRaising 310 10800 Creature Enchantment 70 Increases the target's Coordination by 35 points for three hours. +2413 Enduring Focus 7 Buff Other 9 FocusRaising 310 10800 Creature Enchantment 70 Increases the target's Focus by 35 points for three hours. +2414 Enduring Stoicism 7 Buff Other 3 EnduranceRaising 310 10800 Creature Enchantment 70 Increases the caster's Endurance by 35 points for three hours. +2415 Eye of the Hunter 1 Buff Item 325 BowDamageRaising 25 1020 Item Enchantment 50 Enhances the penetration of arrow shots. adding 25% to the bow's damage modifier. +2416 High Tension String 1 Buff Item 325 BowDamageRaising 20 1020 Item Enchantment 50 Enhances the penetration of arrow shots. adding 20% to the bow's damage modifier. +2417 Obedience 1 Buff Other 293 LeadershipObedienceRaising 10 780 Creature Enchantment 10 Increases the target's Leadership skill by 10 points. This can be combined with other Leadership-enhancing spells. +2418 Occult Potence 7 Buff Other 97 ManaAccelerating 310 10800 Life Magic 70 Doubles the target's natural mana renewal rate for three hours. +2419 Panic Attack 5 Debuff Other 8 CoordinationLowering 200 30 Creature Enchantment 300 Causes the target to quake and shiver uncontrollably. +2420 Panoply of the Queenslayer 6 Buff Other 115 ArmorRaising 250 10800 Life Magic 70 Increases the target's natural armor by 200 points for three hours. +2421 Paralyzing Fear 8 Debuff Other 6 QuicknessLowering 410 30 Creature Enchantment 300 Causes the target to freeze in horror. +2422 Send to Dryreach 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the town of Dryreach. +2423 Precise 1 Buff Other 331 ExtraBowSkillRaising 10 780 Creature Enchantment 10 This weapon is highly accurate in the hands of a skilled bowman. enchancing skill by 10 points. Additional spells can be layered over this. +2424 Rabbit's Eye 8 Buff Other 9 FocusRaising 500 1020 Creature Enchantment 70 Increases the target's Focus by 50 points. +2425 Stone Wall 7 Buff Other 3 EnduranceRaising 310 1020 Creature Enchantment 70 Increases the caster's Endurance by 50 points. +2426 Strong Pull 5 Buff Item 327 BowRangeRaising 200 1020 Item Enchantment 50 The tension of the bowstring gives this weapon enhanced range when wielded by a skilled bowman. +2427 Sugar Rush 8 Buff Other 7 CoordinationRaising 500 1020 Creature Enchantment 70 Increases the target's Coordination by 50 points. +2428 Timaru's Shelter 1 Buff Other 299 MagicDefenseShelterRaising 10 1800 Creature Enchantment 70 Increases the target's Magic Defense skill by 10 points. Additional protection can be layered over this. +2429 Timaru's Shelter 6 Buff Other 295 MeleeDefenseShelterRaising 280 1800 Life Magic 70 Increases the target's natural armor by 30 points. Additional protection can be layered over this. +2430 Timaru's Shelter 6 Buff Other 297 MissileDefenseShelterRaising 280 1800 Creature Enchantment 70 Increases the target's Quickness by 10 points. Additional protection can be layered over this. +2431 Vivification 6 Buff Other 93 HealthAccelerating 290 10800 Life Magic 70 Doubles the target's natural healing rate for three hours. +2432 Acid Ward 2 Buff Other 285 AcidWardProtection 50 10800 Life Magic 20 Reduces damage the target takes from acid by 20%. Additional magical protection can be layered over this. +2433 Flame Ward 1 Buff Other 287 FireWardProtection 20 10800 Life Magic 20 Reduces damage the target takes from fire by 20%. Additional magical protection can be layered over this. +2434 Frost Ward 1 Buff Other 289 ColdWardProtection 20 10800 Life Magic 20 Reduces damage the target takes from cold by 20%. Additional magical protection can be layered over this. +2435 Lightning Ward 2 Buff Other 291 ElectricWardProtection 50 10800 Life Magic 20 Reduces damage the target takes from lightning by 20%. Additional magical protection can be layered over this. +2436 Laying on of Hands 3 Buff Other 67 HealingRaising 100 780 Creature Enchantment 30 Increases the target's Healing skill by 25 points. +2437 Greater Rockslide 1 Buff Item 389 ExtraAttackModRaising 30 780 Item Enchantment 60 Increases a weapon's Attack Skill modifier by 5%. Additional spells can be layered over this. +2438 Lesser Rockslide 1 Buff Item 389 ExtraAttackModRaising 10 780 Item Enchantment 60 Increases a weapon's Attack Skill modifier by 1%. Additional spells can be layered over this. +2439 Rockslide 1 Buff Item 389 ExtraAttackModRaising 10 780 Item Enchantment 60 Increases a weapon's Attack Skill modifier by 3%. Additional spells can be layered over this. +2440 Greater Stone Cliffs 1 Buff Other 321 StoneCliffsRaising 15 780 Creature Enchantment 10 Increases the target's Melee Defense skill by 15 points. +2441 Lesser Stone Cliffs 1 Buff Other 321 StoneCliffsRaising 8 780 Creature Enchantment 10 Increases the target's Melee Defense skill by 8 points. +2442 Stone Cliffs 1 Buff Other 321 StoneCliffsRaising 12 780 Creature Enchantment 10 Increases the target's Melee Defense skill by 12 points. +2443 Greater Strength of Earth 1 Buff Other 261 StrengthIncrease 12 780 Creature Enchantment 40 Increases the target's Strength by 15 points. +2444 Lesser Strength of Earth 1 Buff Other 261 StrengthIncrease 4 780 Creature Enchantment 40 Increases the target's Strength by 8 points. +2445 Strength of Earth 1 Buff Other 261 StrengthIncrease 8 780 Creature Enchantment 40 Increases the target's Strength by 12 points. +2446 Greater Growth 1 Buff Other 309 GrowthRaising 30 780 Life Magic 30 Increase the target's natural healing rate by 75%. +2447 Lesser Growth 1 Buff Other 309 GrowthRaising 10 780 Life Magic 30 Increase caster's natural healing rate by 25%. +2448 Growth 1 Buff Other 309 GrowthRaising 20 780 Life Magic 30 Increase the target's natural healing rate by 50%. +2449 Greater Hunter's Acumen 1 Buff Other 267 CoordinationIncrease 12 780 Creature Enchantment 10 Increases the target's Coordination by 15 points. +2450 Lesser Hunter's Acumen 1 Buff Other 267 CoordinationIncrease 4 780 Creature Enchantment 10 Increases the target's Coordination by 8 points. +2451 Hunter's Acumen 1 Buff Other 267 CoordinationIncrease 8 780 Creature Enchantment 10 Increases the target's Coordination by 12 points. +2452 Greater Thorns 2 Buff Item 323 MaxDamageRaising 51 780 Item Enchantment 40 Increases a weapon's damage value by 4 points. +2453 Lesser Thorns 1 Buff Item 323 MaxDamageRaising 2 780 Item Enchantment 40 Increases a weapon's damage value by 2 points. +2454 Thorns 1 Buff Item 323 MaxDamageRaising 4 780 Item Enchantment 40 Increases a weapon's damage value by 3 points. +2455 Greater Cascade 1 Buff Other 311 CascadeAxeRaising 15 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. +2456 Lesser Cascade 1 Buff Other 311 CascadeAxeRaising 8 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 8 points. +2457 Cascade 1 Buff Other 311 CascadeAxeRaising 12 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 12 points. +2458 Greater Cascade 1 Buff Other 313 CascadeDaggerRaising 15 780 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 15 points. +2459 Lesser Cascade 1 Buff Other 313 CascadeDaggerRaising 8 780 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 8 points. +2460 Cascade 1 Buff Other 313 CascadeDaggerRaising 12 780 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 12 points. +2461 Greater Cascade 1 Buff Other 311 CascadeAxeRaising 15 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. +2462 Lesser Cascade 1 Buff Other 311 CascadeAxeRaising 8 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 8 points. +2463 Cascade 1 Buff Other 311 CascadeAxeRaising 12 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 12 points. +2464 Greater Cascade 1 Buff Other 311 CascadeAxeRaising 15 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. +2465 Lesser Cascade 1 Buff Other 311 CascadeAxeRaising 8 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 8 points. +2466 Cascade 1 Buff Other 311 CascadeAxeRaising 12 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 12 points. +2467 Greater Cascade 1 Buff Other 311 CascadeAxeRaising 15 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. +2468 Lesser Cascade 1 Buff Other 311 CascadeAxeRaising 8 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 8 points. +2469 Cascade 1 Buff Other 311 CascadeAxeRaising 12 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 12 points. +2470 Greater Still Water 1 Buff Other 263 EnduranceIncrease 12 780 Creature Enchantment 30 Increases the target's Endurance by 15 points. +2471 Lesser Still Water 1 Buff Other 263 EnduranceIncrease 4 780 Creature Enchantment 30 Increases the target's Endurance by 8 points. +2472 Still Water 1 Buff Other 263 EnduranceIncrease 8 780 Creature Enchantment 30 Increases the target's Endurance by 12 points. +2473 Greater Torrent 1 Buff Other 265 QuicknessIncrease 12 1800 Creature Enchantment 70 Increases the target's Quickness by 15 points. +2474 Lesser Torrent 1 Buff Other 265 QuicknessIncrease 4 1800 Creature Enchantment 70 Increases the target's Quickness by 8 points. +2475 Torrent 1 Buff Other 265 QuicknessIncrease 8 1800 Creature Enchantment 70 Increases the target's Quickness by 12 points. +2476 Safe Harbor 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the town of Timaru. +2477 Free Trip to the Aluvian Casino 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to Monty's Den of Iniquity. +2478 Cragstone Reinforcements camp recall 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Cragstone Reinforcements Camp portal. +2479 Advance Camp Recall 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Cragstone advance camp. +2480 Free Trip to the Gharun'dim Casino 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to Arshid's Den of Iniquity. +2481 Zaikhal Reinforcement Camp Recall 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Zaikhal Reinforcement Camp. +2482 Zaikhal Advance Camp Recall 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Zaikhal Advance Camp. +2483 Free Trip to the Sho Casino 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to Gan-Zo's Den of Iniquity. +2484 Hebian-to Reinforcements Camp Portal 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Hebian-to Reinforcements Camp. +2485 Hebian-to Advance Camp Recall 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Hebian-to Advance Camp. +2486 Blood Thirst 1 Buff Item 323 MaxDamageRaising 2 780 Item Enchantment 10 Increases a weapon's damage value by 2 points. +2487 Spirit Strike 1 Buff Item 323 MaxDamageRaising 2 780 Item Enchantment 10 Increases a weapon's damage value by 2 points. +2488 Weapon Familiarity 1 Buff Item 329 ExtraDefenseModRaising 8 780 Item Enchantment 30 The crafter of this weapon is intimately familiar with its handling and suffers no defense penalty while wielding it. Additional magical enhancements can be layered over this. +2489 Free Ride to the Shoushi Southeast Outpost Portal 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2490 Free Ride to the Holtburg South Outpost 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2491 Free Ride to the Holtburg West Outpost 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2492 Free Ride to the Shoushi West Outpost 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2493 Free Ride to the Yaraq East Outpost 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2494 Free Ride to the Yaraq North Outpost 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2495 Send Reinforcements 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2496 Send Reinforcements 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2497 Send Reinforcements 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2498 Send Reinforcements 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2499 Send Reinforcements 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2500 Send Reinforcements 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2501 Major Alchemical Prowess 1 Buff Other 333 ExtraAlchemySkillRaising 2 780 Creature Enchantment 10 Increases the target's Alchemy skill by 15 points. Additional spells can be layered over this. +2502 Major Arcane Prowess 1 Buff Other 335 ExtraArcaneLoreSkillRaising 15 780 Creature Enchantment 10 Increases the target's Arcane Lore skill by 15 points. Additional spells can be layered over this. +2503 Major Armor Tinkering Expertise 1 Buff Other 337 ExtraAppraiseArmorSkillRaising 2 780 Creature Enchantment 10 Increases the target's Armor Tinkering skill by 15 points. Additional spells can be layered over this. +2504 Major Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 15 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. Additional spells can be layered over this. +2505 Major Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 15 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 15 points. Additional spells can be layered over this. +2506 Major Cooking Prowess 1 Buff Other 339 ExtraCookingSkillRaising 2 780 Creature Enchantment 10 Increases the target's Cooking skill by 15 points. Additional spells can be layered over this. +2507 Major Creature Enchantment Aptitude 1 Buff Other 251 CreatureMysticRaising 15 780 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 15 points. Additional spells can be layered over this. +2508 Major Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 15 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 15 points. Additional spells can be layered over this. +2509 Major Finesse Weapon Aptitude 1 Buff Other 313 CascadeDaggerRaising 15 780 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 15 points. Additional spells can be layered over this. +2510 Major Deception Prowess 1 Buff Other 343 ExtraDeceptionSkillRaising 2 780 Creature Enchantment 10 Increases the target's Deception skill by 15 points. Additional spells can be layered over this. +2511 Major Fealty 1 Buff Other 345 ExtraLoyaltySkillRaising 15 780 Creature Enchantment 10 Increases the target's Loyalty skill by 15 points. Additional spells can be layered over this. +2512 Major Fletching Prowess 1 Buff Other 347 ExtraFletchingSkillRaising 2 780 Creature Enchantment 10 Increases the target's Fletching skill by 15 points. Additional spells can be layered over this. +2513 Major Healing Prowess 1 Buff Other 349 ExtraHealingSkillRaising 2 780 Creature Enchantment 10 Increases the target's Healing skill by 15 points. Additional spells can be layered over this. +2514 Major Impregnability 1 Buff Other 654 ExtraMissileDefenseSkillRaising 15 780 Creature Enchantment 10 Increases the target's Missile Defense skill by 15 points. Additional spells can be layered over this. +2515 Major Invulnerability 1 Buff Other 351 ExtraMeleeDefenseSkillRaising 15 780 Creature Enchantment 10 Increases the target's Melee Defense skill by 15 points. Additional spells can be layered over this. +2516 Major Item Enchantment Aptitude 1 Buff Other 253 ItemMysticRaising 15 780 Creature Enchantment 10 Increases the target's Item Enchantment skill by 15 points. Additional spells can be layered over this. +2517 Major Item Tinkering Expertise 1 Buff Other 353 ExtraAppraiseItemSkillRaising 2 780 Creature Enchantment 10 Increases the target's Item Tinkering skill by 15 points. Additional spells can be layered over this. +2518 Major Jumping Prowess 1 Buff Other 355 ExtraJumpingSkillRaising 2 780 Creature Enchantment 10 Increases the target's Jump skill by 15 points. Additional spells can be layered over this. +2519 Major Leadership 1 Buff Other 293 LeadershipObedienceRaising 2 780 Creature Enchantment 10 Increases the target's Leadership skill by 15 points. Additional spells can be layered over this. +2520 Major Life Magic Aptitude 1 Buff Other 357 ExtraLifeMagicSkillRaising 15 780 Creature Enchantment 10 Increases the target's Life Magic skill by 15 points. Additional spells can be layered over this. +2521 Major Lockpick Prowess 1 Buff Other 359 ExtraLockpickSkillRaising 2 780 Creature Enchantment 10 Increases the target's Lockpick skill by 15 points. Additional spells can be layered over this. +2522 Major Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 15 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. Additional spells can be layered over this. +2523 Major Magic Item Tinkering Expertise 1 Buff Other 361 ExtraAppraiseMagicItemSkillRaising 2 780 Creature Enchantment 10 Increases the target's Magic Item Tinkering skill by 15 points. Additional spells can be layered over this. +2524 Major Magic Resistance 1 Buff Other 299 MagicDefenseShelterRaising 15 780 Creature Enchantment 10 Increases the target's Magic Defense skill by 15 points. Additional spells can be layered over this. +2525 Major Mana Conversion Prowess 1 Buff Other 363 ExtraManaConversionSkillRaising 15 780 Creature Enchantment 10 Increases the target's Mana Conversion skill by 15 points. Additional spells can be layered over this. +2526 Major Monster Attunement 1 Buff Other 365 ExtraAssessCreatureSkillRaising 2 780 Creature Enchantment 10 Increases the target's Assess Creature skill by 15 points. Additional spells can be layered over this. +2527 Major Person Attunement 1 Buff Other 367 ExtraAssessPersonSkillRaising 2 780 Creature Enchantment 10 Increases the target's Assess Person skill by 15 points. Additional spells can be layered over this. +2528 Major Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 15 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. Additional spells can be layered over this. +2529 Major Sprint 1 Buff Other 369 ExtraRunSkillRaising 2 780 Creature Enchantment 10 Increases the target's Run skill by 15 points. Additional spells can be layered over this. +2530 Major Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 15 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. Additional spells can be layered over this. +2531 Major Heavy Weapon Aptitude 1 Buff Other 371 ExtraSwordSkillRaising 15 780 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 15 points. Additional spells can be layered over this. +2532 Major Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 15 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 15 points. Additional spells can be layered over this. +2533 Major Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 15 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. Additional spells can be layered over this. +2534 Major War Magic Aptitude 1 Buff Other 255 WarMysticRaising 15 780 Creature Enchantment 10 Increases the target's War Magic skill by 15 points. Additional spells can be layered over this. +2535 Major Weapon Tinkering Expertise 1 Buff Other 377 ExtraAppraiseWeaponSkillRaising 15 780 Creature Enchantment 10 Increases the target's Weapon Tinkering skill by 15 points. Additional spells can be layered over this. +2536 Minor Alchemical Prowess 1 Buff Other 333 ExtraAlchemySkillRaising 1 780 Creature Enchantment 10 Increases the target's Alchemy skill by 5 points. Additional spells can be layered over this. +2537 Minor Arcane Prowess 1 Buff Other 335 ExtraArcaneLoreSkillRaising 5 780 Creature Enchantment 10 Increases the target's Arcane Lore skill by 5 points. Additional spells can be layered over this. +2538 Minor Armor Tinkering Expertise 1 Buff Other 337 ExtraAppraiseArmorSkillRaising 1 780 Creature Enchantment 10 Increases the target's Armor Tinkering skill by 5 points. Additional spells can be layered over this. +2539 Minor Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 5 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 5 points. Additional spells can be layered over this. +2540 Minor Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 5 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 5 points. Additional spells can be layered over this. +2541 Minor Cooking Prowess 1 Buff Other 339 ExtraCookingSkillRaising 1 780 Creature Enchantment 10 Increases the target's Cooking skill by 5 points. Additional spells can be layered over this. +2542 Minor Creature Enchantment Aptitude 1 Buff Other 251 CreatureMysticRaising 5 780 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 5 points. Additional spells can be layered over this. +2543 Minor Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 5 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 5 points. Additional spells can be layered over this. +2544 Minor Finesse Weapon Aptitude 1 Buff Other 313 CascadeDaggerRaising 5 780 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 5 points. Additional spells can be layered over this. +2545 Minor Deception Prowess 1 Buff Other 343 ExtraDeceptionSkillRaising 1 780 Creature Enchantment 10 Increases the target's Deception skill by 5 points. Additional spells can be layered over this. +2546 Minor Fealty 1 Buff Other 345 ExtraLoyaltySkillRaising 1 780 Creature Enchantment 10 Increases the target's Loyalty skill by 5 points. Additional spells can be layered over this. +2547 Minor Fletching Prowess 1 Buff Other 347 ExtraFletchingSkillRaising 1 780 Creature Enchantment 10 Increases the target's Fletching skill by 5 points. Additional spells can be layered over this. +2548 Minor Healing Prowess 1 Buff Other 349 ExtraHealingSkillRaising 1 780 Creature Enchantment 10 Increases the target's Healing skill by 5 points. Additional spells can be layered over this. +2549 Minor Impregnability 1 Buff Other 654 ExtraMissileDefenseSkillRaising 5 780 Creature Enchantment 10 Increases the target's Missile Defense skill by 5 points. Additional spells can be layered over this. +2550 Minor Invulnerability 1 Buff Other 351 ExtraMeleeDefenseSkillRaising 5 780 Creature Enchantment 10 Increases the target's Melee Defense skill by 5 points. Additional spells can be layered over this. +2551 Minor Item Enchantment Aptitude 1 Buff Other 253 ItemMysticRaising 5 780 Creature Enchantment 10 Increases the target's Item Enchantment skill by 5 points. Additional spells can be layered over this. +2552 Minor Item Tinkering Expertise 1 Buff Other 353 ExtraAppraiseItemSkillRaising 1 780 Creature Enchantment 10 Increases the target's Item Tinkering skill by 5 points. Additional spells can be layered over this. +2553 Minor Jumping Prowess 1 Buff Other 355 ExtraJumpingSkillRaising 1 780 Creature Enchantment 10 Increases the target's Jump skill by 5 points. Additional spells can be layered over this. +2554 Minor Leadership 1 Buff Other 293 LeadershipObedienceRaising 1 780 Creature Enchantment 10 Increases the target's Leadership skill by 5 points. Additional spells can be layered over this. +2555 Minor Life Magic Aptitude 1 Buff Other 357 ExtraLifeMagicSkillRaising 5 780 Creature Enchantment 10 Increases the target's Life Magic skill by 5 points. Additional spells can be layered over this. +2556 Minor Lockpick Prowess 1 Buff Other 359 ExtraLockpickSkillRaising 1 780 Creature Enchantment 10 Increases the target's Lockpick skill by 5 points. Additional spells can be layered over this. +2557 Minor Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 5 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 5 points. Additional spells can be layered over this. +2558 Minor Magic Item Tinkering Expertise 1 Buff Other 361 ExtraAppraiseMagicItemSkillRaising 1 780 Creature Enchantment 10 Increases the target's Magic Item Tinkering skill by 5 points. Additional spells can be layered over this. +2559 Minor Magic Resistance 1 Buff Other 299 MagicDefenseShelterRaising 5 780 Creature Enchantment 10 Increases the target's Magic Defense skill by 5 points. Additional spells can be layered over this. +2560 Minor Mana Conversion Prowess 1 Buff Other 363 ExtraManaConversionSkillRaising 5 780 Creature Enchantment 10 Increases the target's Mana Conversion skill by 5 points. Additional spells can be layered over this. +2561 Minor Monster Attunement 1 Buff Other 365 ExtraAssessCreatureSkillRaising 1 780 Creature Enchantment 10 Increases the target's Assess Creature skill by 5 points. Additional spells can be layered over this. +2562 Minor Person Attunement 1 Buff Other 367 ExtraAssessPersonSkillRaising 1 780 Creature Enchantment 10 Increases the target's Assess Person skill by 5 points. Additional spells can be layered over this. +2563 Minor Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 5 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 5 points. Additional spells can be layered over this. +2564 Minor Sprint 1 Buff Other 369 ExtraRunSkillRaising 1 780 Creature Enchantment 10 Increases the target's Run skill by 5 points. Additional spells can be layered over this. +2565 Minor Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 5 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 5 points. Additional spells can be layered over this. +2566 Minor Heavy Weapon Aptitude 1 Buff Other 371 ExtraSwordSkillRaising 5 780 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 5 points. Additional spells can be layered over this. +2567 Minor Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 5 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 5 points. Additional spells can be layered over this. +2568 Minor Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 5 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 5 points. Additional spells can be layered over this. +2569 Minor War Magic Aptitude 1 Buff Other 255 WarMysticRaising 5 780 Creature Enchantment 10 Increases the target's War Magic skill by 5 points. Additional spells can be layered over this. +2570 Minor Weapon Tinkering Expertise 1 Buff Other 377 ExtraAppraiseWeaponSkillRaising 5 780 Creature Enchantment 10 Increases the target's Weapon Tinkering skill by 5 points. Additional spells can be layered over this. +2571 Major Armor 1 Buff Other 379 ArmorIncrease 40 780 Life Magic 10 Increases the target's natural armor by 40 points. Additional spells can be layered over this. +2572 Major Coordination 1 Buff Other 267 CoordinationIncrease 15 780 Creature Enchantment 10 Increases the target's Coordination by 15 points. Additional spells can be layered over this. +2573 Major Endurance 1 Buff Other 263 EnduranceIncrease 15 780 Creature Enchantment 10 Increases the target's Endurance by 15 points. Additional spells can be layered over this. +2574 Major Focus 1 Buff Other 269 FocusIncrease 15 780 Creature Enchantment 10 Increases the target's Focus by 15 points. Additional spells can be layered over this. +2575 Major Quickness 1 Buff Other 265 QuicknessIncrease 15 780 Creature Enchantment 10 Increases the target's Quickness by 15 points. Additional spells can be layered over this. +2576 Major Strength 1 Buff Other 261 StrengthIncrease 15 780 Creature Enchantment 10 Increases the target's Strength by 15 points. Additional spells can be layered over this. +2577 Major Willpower 1 Buff Other 271 SelfIncrease 15 780 Creature Enchantment 10 Increases the target's Self by 15 points. Additional spells can be layered over this. +2578 Minor Armor 1 Buff Other 379 ArmorIncrease 20 780 Life Magic 10 Increases the target's natural armor by 20 points. Additional spells can be layered over this. +2579 Minor Coordination 1 Buff Other 267 CoordinationIncrease 5 780 Creature Enchantment 10 Increases the target's Coordination by 5 points. Additional spells can be layered over this. +2580 Minor Endurance 1 Buff Other 263 EnduranceIncrease 5 780 Creature Enchantment 10 Increases the target's Endurance by 5 points. Additional spells can be layered over this. +2581 Minor Focus 1 Buff Other 269 FocusIncrease 5 780 Creature Enchantment 10 Increases the target's Focus by 5 points. Additional spells can be layered over this. +2582 Minor Quickness 1 Buff Other 265 QuicknessIncrease 5 780 Creature Enchantment 10 Increases the target's Quickness by 5 points. Additional spells can be layered over this. +2583 Minor Strength 1 Buff Other 261 StrengthIncrease 5 780 Creature Enchantment 10 Increases the target's Strength by 5 points. Additional spells can be layered over this. +2584 Minor Willpower 1 Buff Other 271 SelfIncrease 5 780 Creature Enchantment 10 Increases the target's Self by 5 points. Additional spells can be layered over this. +2585 Major Acid Bane 1 Buff Item 381 ExtraAcidResistanceRaising 2 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Acid damage by 15%. Additional spells can be layered over this. +2586 Major Blood Thirst 1 Buff Item 323 MaxDamageRaising 4 780 Item Enchantment 10 Increases a weapon's damage value by 4 points. Additional spells can be layered over this. +2587 Major Bludgeoning Bane 1 Buff Item 383 ExtraBludgeonResistanceRaising 2 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Bludgeoning damage by 15%. Additional spells can be layered over this. +2588 Major Defender 1 Buff Item 329 ExtraDefenseModRaising 5 780 Item Enchantment 10 Increases the Melee Defense skill modifier of a weapon or magic caster by 5%. Additional spells can be layered over this. +2589 Major Flame Bane 1 Buff Item 385 ExtraFireResistanceRaising 2 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Fire damage by 15%. Additional spells can be layered over this. +2590 Major Frost Bane 1 Buff Item 387 ExtraColdResistanceRaising 2 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Cold damage by 15%. Additional spells can be layered over this. +2591 Major Heart Thirst 1 Buff Item 389 ExtraAttackModRaising 5 780 Item Enchantment 10 Increases a weapon's Attack Skill modifier by 5%. Additional spells can be layered over this. +2592 Major Impenetrability 1 Buff Item 391 ExtraArmorValueRaising 2 780 Item Enchantment 10 Improves a shield or piece of armor's Armor value by 40 points. Additional spells can be layered over this. +2593 Major Piercing Bane 1 Buff Item 393 ExtraPierceResistanceRaising 2 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Piercing damage by 15%. Additional spells can be layered over this. +2594 Major Slashing Bane 1 Buff Item 395 ExtraSlashResistanceRaising 2 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Slashing damage by 15%. Additional spells can be layered over this. +2595 Major Storm Bane 1 Buff Item 397 ExtraElectricResistanceRaising 2 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Electric damage by 15%. Additional spells can be layered over this. +2596 Major Swift Hunter 1 Buff Item 399 ExtraWeaponTimeRaising 20 780 Item Enchantment 10 Improves a weapon's speed by 20 points. Additional spells can be layered over this. +2597 Minor Acid Bane 1 Buff Item 381 ExtraAcidResistanceRaising 1 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Acid damage by 10%. Additional spells can be layered over this. +2598 Minor Blood Thirst 1 Buff Item 323 MaxDamageRaising 2 780 Item Enchantment 10 Increases a weapon's damage value by 2 points. Additional spells can be layered over this. +2599 Minor Bludgeoning Bane 1 Buff Item 383 ExtraBludgeonResistanceRaising 1 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Bludgeoning damage by 10%. Additional spells can be layered over this. +2600 Minor Defender 1 Buff Item 329 ExtraDefenseModRaising 3 780 Item Enchantment 10 Increases the Melee Defense skill modifier of a weapon or magic caster by 3%. Additional spells can be layered over this. +2601 Minor Flame Bane 1 Buff Item 385 ExtraFireResistanceRaising 1 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Fire damage by 10%. Additional spells can be layered over this. +2602 Minor Frost Bane 1 Buff Item 387 ExtraColdResistanceRaising 1 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Cold damage by 10%. Additional spells can be layered over this. +2603 Minor Heart Thirst 1 Buff Item 389 ExtraAttackModRaising 3 780 Item Enchantment 10 Increases a weapon's Attack Skill modifier by 3%. Additional spells can be layered over this. +2604 Minor Impenetrability 1 Buff Item 391 ExtraArmorValueRaising 1 780 Item Enchantment 10 Improves a shield or piece of armor's Armor value by 20 points. Additional spells can be layered over this. +2605 Minor Piercing Bane 1 Buff Item 393 ExtraPierceResistanceRaising 1 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Piercing damage by 10%. Additional spells can be layered over this. +2606 Minor Slashing Bane 1 Buff Item 395 ExtraSlashResistanceRaising 1 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Slashing damage by 10%. Additional spells can be layered over this. +2607 Minor Storm Bane 1 Buff Item 397 ExtraElectricResistanceRaising 1 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Electric damage by 10%. Additional spells can be layered over this. +2608 Minor Swift Hunter 1 Buff Item 399 ExtraWeaponTimeRaising 10 780 Item Enchantment 10 Improves a weapon's speed by 10 points. Additional spells can be layered over this. +2609 Major Acid Ward 1 Buff Other 285 AcidWardProtection 2 780 Life Magic 10 Reduces damage the target takes from Acid by 15%. Additional spells can be layered over this. +2610 Major Bludgeoning Ward 1 Buff Other 401 BludgeonWardProtection 15 780 Life Magic 10 Reduces damage the target takes from Bludgeoning by 15%. Additional spells can be layered over this. +2611 Major Flame Ward 1 Buff Other 287 FireWardProtection 15 780 Life Magic 10 Reduces damage the target takes from Fire by 15%. Additional spells can be layered over this. +2612 Major Frost Ward 1 Buff Other 289 ColdWardProtection 15 780 Life Magic 10 Reduces damage the target takes from Cold by 15%. Additional spells can be layered over this. +2613 Major Piercing Ward 1 Buff Other 405 PierceWardProtection 15 780 Life Magic 10 Reduces damage the target takes from Piercing by 15%. Additional spells can be layered over this. +2614 Major Slashing Ward 1 Buff Other 403 SlashWardProtection 2 780 Life Magic 10 Reduces damage the target takes from Slashing by 15%. Additional spells can be layered over this. +2615 Major Storm Ward 1 Buff Other 291 ElectricWardProtection 2 780 Life Magic 10 Reduces damage the target takes from Lightning by 15%. Additional spells can be layered over this. +2616 Minor Acid Ward 1 Buff Other 285 AcidWardProtection 1 780 Life Magic 10 Reduces damage the target takes from Acid by 10%. Additional spells can be layered over this. +2617 Minor Bludgeoning Ward 1 Buff Other 401 BludgeonWardProtection 10 780 Life Magic 10 Reduces damage the target takes from Bludgeoning by 10%. Additional spells can be layered over this. +2618 Minor Flame Ward 1 Buff Other 287 FireWardProtection 10 780 Life Magic 10 Reduces damage the target takes from Fire by 10%. Additional spells can be layered over this. +2619 Minor Frost Ward 1 Buff Other 289 ColdWardProtection 10 780 Life Magic 10 Reduces damage the target takes from Cold by 10%. Additional spells can be layered over this. +2620 Minor Piercing Ward 1 Buff Other 405 PierceWardProtection 10 780 Life Magic 10 Reduces damage the target takes from Piercing by 10%. Additional spells can be layered over this. +2621 Minor Slashing Ward 1 Buff Other 403 SlashWardProtection 1 780 Life Magic 10 Reduces damage the target takes from Slashing by 10%. Additional spells can be layered over this. +2622 Minor Storm Ward 1 Buff Other 291 ElectricWardProtection 1 780 Life Magic 10 Reduces damage the target takes from Lightning by 10%. Additional spells can be layered over this. +2623 Major Health Gain 1 Buff Other 257 HealthRestoring 30 780 Life Magic 10 Increases the rate at which the target regains Health by 30%. Additional spells can be layered over this. +2624 Major Mana Gain 1 Buff Other 259 ManaRestoring 30 780 Life Magic 10 Increases the rate at which the target regains Mana by 30%. Additional spells can be layered over this. +2625 Major Stamina Gain 1 Buff Other 407 StaminaRestoring 30 780 Life Magic 10 Increases the rate at which the target regains Stamina by 30%. Additional spells can be layered over this. +2626 Minor Health Gain 1 Buff Other 257 HealthRestoring 15 780 Life Magic 10 Increases the rate at which the target regains Health by 15%. Additional spells can be layered over this. +2627 Minor Mana Gain 1 Buff Other 259 ManaRestoring 15 780 Life Magic 10 Increases the rate at which the target regains Mana by 15%. Additional spells can be layered over this. +2628 Minor Stamina Gain 1 Buff Other 407 StaminaRestoring 15 780 Life Magic 10 Increases the rate at which the target regains Stamina by 15%. Additional spells can be layered over this. +2629 Huntress' Boon 1 Buff Item 323 MaxDamageRaising 5 780 Item Enchantment 10 Increases the bow's base damage value by 5 points. Additional spells can be layered over this. +2630 Prey's Reflex 1 Buff Item 389 ExtraAttackModRaising 6 780 Item Enchantment 10 Allows the wielder to anticipate the movements of the target. adding 6% to the weapon's attack odds. Additional spells can be layered over this. +2631 Secret Descent 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Portals Target to Halls of Hollows Dungeon +2632 Secret Ascent 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Portals Target to the exit of Halls of Hollows Dungeon +2633 Breaking and Entering 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Portals Traget to the Regicide Dungeon +2634 Cautious Egress 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Portals target to the Regicide Dungeon Exit +2635 Witshire Passage 8 Neutral Item 214 PortalSending 2000 -1 Item Enchantment 50000 Summons a portal to the Witshire Dungeon +2636 Karenua's Curse 8 Debuff Other 74 LockpickLowering 500 900 Creature Enchantment 70 Decreases the target's Lockpick skill by 40 points. +2637 Invoking Aun Tanua 7 Neutral Other 121 FireMissile 300 -1 War Magic 100 Summons the Spirit of the Tumerok Warrior Aun Tanua to do 160-200 points of fire damage to the first thing it hits. +2638 Heart of Oak 1 Buff Other 13 FocusConcentration 3 780 Creature Enchantment 10 Increases the target's Self by 20 points. Additional spells can be layered over this. +2639 Repulsion 1 Debuff Other 284 ManaTakerLowering 20 60 Life Magic 30 Decreases maximum mana by 20 points. +2640 Devourer 1 Debuff Other 284 ManaTakerLowering 20 60 Life Magic 30 Decreases maximum mana by 20 points. +2641 Force to Arms 3 Debuff Other 284 ManaTakerLowering 100 60 Life Magic 30 Decreases maximum mana by 100 points. +2642 Consumption 1 Debuff Other 284 ManaTakerLowering 20 60 Life Magic 30 Decreases maximum mana by 20 points. +2643 Stasis 1 Debuff Other 284 ManaTakerLowering 20 60 Life Magic 30 Decreases maximum mana by 20 points. +2644 Lifestone Tie 3 Utility Self 200 PortalTie 100 -1 Item Enchantment 50 Links the caster to a targeted Lifestone. +2645 Portal Recall 3 Utility Self 201 PortalRecall 100 -1 Item Enchantment 50 Transports the caster to the destination of the last recallable portal the caster traveled through. +2646 Secondary Portal Tie 4 Utility Self 200 PortalTie 150 -1 Item Enchantment 50 Links the caster to a targeted portal. +2647 Secondary Portal Recall 3 Utility Self 201 PortalRecall 100 -1 Item Enchantment 50 Transports the caster to the destination of the portal last successfully linked to with Secondary Portal Tie. +2648 Summon Secondary Portal I 5 Utility Self 203 PortalItemCreation 200 60 Item Enchantment 70 Summons a portal that goes to the destination of the caster's linked portal. set with Secondary Portal Tie. +2649 Summon Secondary Portal II 5 Utility Self 203 PortalItemCreation 225 180 Item Enchantment 90 Summons a portal that goes to the destination of the caster's linked portal. set with Secondary Portal Tie. +2650 Summon Secondary Portal III 6 Utility Self 203 PortalItemCreation 250 300 Item Enchantment 110 Summons a portal that goes to the destination of the caster's linked portal. set with Secondary Portal Tie. +2651 Portal Sending Self Sacrifice 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2652 Portal Sending Merciless 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2653 Feeble Willpower 1 Buff Other 271 SelfIncrease 3 780 Creature Enchantment 10 Increases the target's Self by 3 points. Additional spells can be layered over this. +2654 Feeble Endurance 1 Buff Other 263 EnduranceIncrease 3 780 Creature Enchantment 10 Increases the target's Endurance by 3 points. Additional spells can be layered over this. +2655 Feeble Focus 1 Buff Other 269 FocusIncrease 3 780 Creature Enchantment 10 Increases the target's Focus by 3 points. Additional spells can be layered over this. +2656 Feeble Quickness 1 Buff Other 265 QuicknessIncrease 3 780 Creature Enchantment 10 Increases the target's Quickness by 15 points. Additional spells can be layered over this. +2657 Feeble Strength 1 Buff Other 261 StrengthIncrease 3 780 Creature Enchantment 10 Increases the target's Strength by 3 points. Additional spells can be layered over this. +2658 Feeble Coordination 1 Buff Other 267 CoordinationIncrease 3 780 Creature Enchantment 10 Increases the target's Coordination by 3 points. Additional spells can be layered over this. +2659 Moderate Coordination 1 Buff Other 267 CoordinationIncrease 10 3600 Creature Enchantment 10 Increases the target's Coordination by 10 points. Additional spells can be layered over this. +2660 Moderate Endurance 1 Buff Other 263 EnduranceIncrease 10 780 Creature Enchantment 10 Increases the target's Endurance by 10 points. Additional spells can be layered over this. +2661 Moderate Focus 1 Buff Other 269 FocusIncrease 10 780 Creature Enchantment 10 Increases the target's Focus by 10 points. Additional spells can be layered over this. +2662 Moderate Quickness 1 Buff Other 265 QuicknessIncrease 10 780 Creature Enchantment 10 Increases the target's Quickness by 10 points. Additional spells can be layered over this. +2663 Moderate Strength 1 Buff Other 261 StrengthIncrease 10 780 Creature Enchantment 10 Increases the target's Strength by 10 points. Additional spells can be layered over this. +2664 Moderate Willpower 1 Buff Other 271 SelfIncrease 10 780 Creature Enchantment 10 Increases the target's Self by 10 points. Additional spells can be layered over this. +2665 Essence Sluice 1 Buff Other 279 LifeGiverRaising 25 510 Life Magic 70 Increases maximum health by 25 points. +2666 Essence Glutton 1 Buff Other 279 LifeGiverRaising 30 510 Life Magic 70 Increases maximum health by 30 points. +2667 Essence Spike 1 Buff Other 279 LifeGiverRaising 20 510 Life Magic 70 Increases maximum health by 20 points. +2668 Nuhmudiras Benefaction 1 Buff Other 299 MagicDefenseShelterRaising 5 780 Creature Enchantment 10 Increases the target's Magic Defense skill by 5 points. Additional spells can be layered over this. +2669 Nuhmudiras Bestowment 1 Buff Other 299 MagicDefenseShelterRaising 15 780 Creature Enchantment 10 Increases the target's Magic Defense skill by 15 points. Additional spells can be layered over this. +2670 Nuhmudiras Endowment 1 Buff Other 299 MagicDefenseShelterRaising 10 780 Creature Enchantment 10 Increases the target's Magic Defense skill by 10 points. Additional spells can be layered over this. +2671 Portal to the Callous Heart 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2672 Ring of True Pain 5 Projectile Other 223 BludgeoningRing 200 -1 War Magic 80 Shoots eight shock waves outward from the caster. Each wave does 200-300 points of bludgeoning damage to the first thing it hits. +2673 Ring of Unspeakable Agony 5 Projectile Other 223 BludgeoningRing 200 -1 War Magic 80 Shoots eight shock waves outward from the caster. Each wave does 200-300 points of bludgeoning damage to the first thing it hits. +2674 Vicious Rebuke 7 Neutral Other 237 BludgeoningStrike 320 -1 War Magic 120 Kills the target. +2675 Feeble Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 3 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 3 points. Additional spells can be layered over this. +2676 Feeble Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 3 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 3 points. Additional spells can be layered over this. +2677 Feeble Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 3 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 3 points. Additional spells can be layered over this. +2678 Feeble Finesse Weapon Aptitude 1 Buff Other 313 CascadeDaggerRaising 3 780 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 3 points. Additional spells can be layered over this. +2679 Feeble Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 3 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 3 points. Additional spells can be layered over this. +2680 Feeble Mana Conversion Prowess 1 Buff Other 363 ExtraManaConversionSkillRaising 3 780 Creature Enchantment 10 Increases the target's Mana Conversion skill by 3 points. Additional spells can be layered over this. +2681 Feeble Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 3 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 3 points. Additional spells can be layered over this. +2682 Feeble Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 3 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 3 points. Additional spells can be layered over this. +2683 Feeble Heavy Weapon Aptitude 1 Buff Other 371 ExtraSwordSkillRaising 3 780 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 3 points. Additional spells can be layered over this. +2684 Feeble Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 3 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 3 points. Additional spells can be layered over this. +2685 Feeble Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 3 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 3 points. Additional spells can be layered over this. +2686 Moderate Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 10 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. Additional spells can be layered over this. +2687 Moderate Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 10 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 10 points. Additional spells can be layered over this. +2688 Moderate Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 10 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 10 points. Additional spells can be layered over this. +2689 Moderate Finesse Weapon Aptitude 1 Buff Other 313 CascadeDaggerRaising 10 780 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 10 points. Additional spells can be layered over this. +2690 Moderate Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 10 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. Additional spells can be layered over this. +2691 Moderate Mana Conversion Prowess 1 Buff Other 363 ExtraManaConversionSkillRaising 10 780 Creature Enchantment 10 Increases the target's Mana Conversion skill by 10 points. Additional spells can be layered over this. +2692 Moderate Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 10 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. Additional spells can be layered over this. +2693 Moderate Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 10 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. Additional spells can be layered over this. +2694 Moderate Heavy Weapon Aptitude 1 Buff Other 371 ExtraSwordSkillRaising 10 780 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 10 points. Additional spells can be layered over this. +2695 Moderate Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 10 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 10 points. Additional spells can be layered over this. +2696 Moderate Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 10 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. Additional spells can be layered over this. +2697 Aerfalle's Touch 7 Buff Other 421 AttributesDecrease 325 120 Creature Enchantment 300 Decreases all of the target's attributes by 45 points for 120 seconds. +2698 Aerfalle's Embrace 7 Buff Other 421 AttributesDecrease 325 120 Creature Enchantment 70 Decreases the attributes of all fellowship members by 45 points for 120 seconds. +2699 Auroric Whip 7 Neutral Other 246 ElectricStreak 300 -1 War Magic 70 Sends a bolt of lightning streaking towards the target. The stream does 150-200 points of lightning damage to the first thing it hits. +2700 Corrosive Cloud 7 Neutral Other 243 AcidStreak 300 -1 War Magic 70 Sends a cloud of acid streaking towards the target. The stream does 150-200 points of acid damage to the first thing it hits. +2701 Elemental Fury 7 Neutral Other 237 BludgeoningStrike 320 -1 War Magic 120 Burns the target for 150-200 damage. +2702 Elemental Fury 7 Neutral Other 237 BludgeoningStrike 320 -1 War Magic 120 Burns the target for 150-200 damage. +2703 Elemental Fury 7 Neutral Other 237 BludgeoningStrike 320 -1 War Magic 120 Disitegrates the target for 150-200 damage. +2704 Elemental Fury 7 Neutral Other 237 BludgeoningStrike 320 -1 War Magic 120 Jolts the target for 150-200 damage. +2705 Aerfalle's Enforcement 7 Buff Other 424 SkillsDecrease 325 120 Creature Enchantment 70 Lowers all fellowship members skills by 45 points for 120 seconds. +2706 Aerfalle's Gaze 7 Buff Other 424 SkillsDecrease 325 120 Creature Enchantment 70 Lowers targets skills by 45 points for 120 seconds. +2707 Elemental Pit 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2708 Stasis Field 2 Buff Other 421 AttributesDecrease 50 120 Life Magic 300 Decreases all of the target's attributes by 50 points. +2709 Summon Primary Portal I 5 Utility Self 203 PortalItemCreation 200 60 Item Enchantment 70 Summons a portal that goes to the destination of the caster's linked portal. set with Primary Portal Tie. +2710 Volcanic Blast 7 Projectile Other 247 FireStreak 300 -1 War Magic 70 Sends a stream of magma streaking towards the target. The stream does 150-200 points of acid damage to the first thing it hits. +2711 Acid Arc I 1 Neutral Other 117 AcidMissile 1 -1 War Magic 5 Shoots a stream of acid at the target. The stream does 16-30 points of acid damage to the first thing it hits. +2712 Acid Arc II 2 Neutral Other 117 AcidMissile 50 -1 War Magic 10 Shoots a stream of acid at the target. The stream does 26-52 points of acid damage to the first thing it hits. +2713 Acid Arc III 3 Neutral Other 117 AcidMissile 100 -1 War Magic 15 Shoots a stream of acid at the target. The stream does 42-84 points of acid damage to the first thing it hits. +2714 Acid Arc IV 4 Neutral Other 117 AcidMissile 150 -1 War Magic 20 Shoots a stream of acid at the target. The stream does 52-105 points of acid damage to the first thing it hits. +2715 Acid Arc V 5 Neutral Other 117 AcidMissile 200 -1 War Magic 25 Shoots a stream of acid at the target. The stream does 68-136 points of acid damage to the first thing it hits. +2716 Acid Arc VI 6 Neutral Other 117 AcidMissile 250 -1 War Magic 30 Shoots a stream of acid at the target. The stream does 84-168 points of acid damage to the first thing it hits. +2717 Acid Arc VII 7 Neutral Other 117 AcidMissile 300 -1 War Magic 35 Shoots a stream of acid at the target. The stream does 115-189 points of acid damage to the first thing it hits. +2718 Force Arc I 1 Neutral Other 122 PiercingMissile 1 -1 War Magic 5 Shoots a bolt of force at the target. The bolt does 16-30 points of piercing damage to the first thing it hits. +2719 Force Arc II 2 Neutral Other 122 PiercingMissile 50 -1 War Magic 10 Shoots a bolt of force at the target. The bolt does 26-52 points of piercing damage to the first thing it hits. +2720 Force Arc III 3 Neutral Other 122 PiercingMissile 100 -1 War Magic 15 Shoots a bolt of force at the target. The bolt does 42-84 points of piercing damage to the first thing it hits. +2721 Force Arc IV 4 Neutral Other 122 PiercingMissile 150 -1 War Magic 20 Shoots a bolt of force at the target. The bolt does 52-105 points of piercing damage to the first thing it hits. +2722 Force Arc V 5 Neutral Other 122 PiercingMissile 200 -1 War Magic 25 Shoots a bolt of force at the target. The bolt does 68-136 points of piercing damage to the first thing it hits. +2723 Force Arc VI 6 Neutral Other 122 PiercingMissile 250 -1 War Magic 30 Shoots a bolt of force at the target. The bolt does 84-168 points of piercing damage to the first thing it hits. +2724 Force Arc VII 7 Neutral Other 122 PiercingMissile 300 -1 War Magic 35 Shoots a bolt of force at the target. The bolt does 115-189 points of piercing damage to the first thing it hits. +2725 Frost Arc I 1 Neutral Other 119 ColdMissile 1 -1 War Magic 5 Shoots a bolt of frost at the target. The bolt does 16-30 points of cold damage to the first thing it hits. +2726 Frost Arc II 2 Neutral Other 119 ColdMissile 50 -1 War Magic 10 Shoots a bolt of frost at the target. The bolt does 26-52 points of cold damage to the first thing it hits. +2727 Frost Arc III 3 Neutral Other 119 ColdMissile 100 -1 War Magic 15 Shoots a bolt of cold at the target. The bolt does 42-84 points of cold damage to the first thing it hits. +2728 Frost Arc IV 4 Neutral Other 119 ColdMissile 150 -1 War Magic 20 Shoots a bolt of cold at the target. The bolt does 52-105 points of cold damage to the first thing it hits. +2729 Frost Arc V 5 Neutral Other 119 ColdMissile 200 -1 War Magic 25 Shoots a bolt of cold at the target. The bolt does 68-136 points of cold damage to the first thing it hits. +2730 Frost Arc VI 6 Neutral Other 119 ColdMissile 250 -1 War Magic 30 Shoots a bolt of cold at the target. The bolt does 84-168 points of cold damage to the first thing it hits. +2731 Frost Arc VII 7 Neutral Other 119 ColdMissile 300 -1 War Magic 35 Shoots a bolt of cold at the target. The bolt does 115-189 points of cold damage to the first thing it hits. +2732 Lightning Arc I 1 Neutral Other 120 ElectricMissile 1 -1 War Magic 5 Shoots a bolt of lighting at the target. The bolt does 16-30 points of electrical damage to the first thing it hits. +2733 Lightning Arc II 2 Neutral Other 120 ElectricMissile 50 -1 War Magic 10 Shoots a bolt of lighting at the target. The bolt does 26-52 points of electrical damage to the first thing it hits. +2734 Lightning Arc III 3 Neutral Other 120 ElectricMissile 100 -1 War Magic 15 Shoots a bolt of lighting at the target. The bolt does 42-84 points of electrical damage to the first thing it hits. +2735 Lightning Arc IV 4 Neutral Other 120 ElectricMissile 150 -1 War Magic 20 Shoots a bolt of lighting at the target. The bolt does 52-105 points of electrical damage to the first thing it hits. +2736 Lightning Arc V 5 Neutral Other 120 ElectricMissile 200 -1 War Magic 25 Shoots a bolt of lighting at the target. The bolt does 68-136 points of electrical damage to the first thing it hits. +2737 Lightning Arc VI 6 Neutral Other 120 ElectricMissile 250 -1 War Magic 30 Shoots a bolt of lighting at the target. The bolt does 84-168 points of electrical damage to the first thing it hits. +2738 Lightning Arc VII 7 Neutral Other 120 ElectricMissile 300 -1 War Magic 35 Shoots a bolt of lighting at the target. The bolt does 115-189 points of electrical damage to the first thing it hits. +2739 Flame Arc I 1 Neutral Other 121 FireMissile 1 -1 War Magic 5 Shoots a bolt of flame at the target. The bolt does 16-30 points of fire damage to the first thing it hits. +2740 Flame Arc II 2 Neutral Other 121 FireMissile 50 -1 War Magic 10 Shoots a bolt of flame at the target. The bolt does 26-52 points of fire damage to the first thing it hits. +2741 Flame Arc III 3 Neutral Other 121 FireMissile 100 -1 War Magic 15 Shoots a bolt of flame at the target. The bolt does 42-84 points of fire damage to the first thing it hits. +2742 Flame Arc IV 4 Neutral Other 121 FireMissile 150 -1 War Magic 20 Shoots a bolt of flame at the target. The bolt does 52-105 points of fire damage to the first thing it hits. +2743 Flame Arc V 5 Neutral Other 121 FireMissile 200 -1 War Magic 25 Shoots a bolt of flame at the target. The bolt does 68-136 points of fire damage to the first thing it hits. +2744 Flame Arc VI 6 Neutral Other 121 FireMissile 250 -1 War Magic 30 Shoots a bolt of flame at the target. The bolt does 84-168 points of fire damage to the first thing it hits. +2745 Flame Arc VII 7 Neutral Other 121 FireMissile 300 -1 War Magic 35 Shoots a bolt of flame at the target. The bolt does 115-189 points of fire damage to the first thing it hits. +2746 Shock Arc I 1 Neutral Other 118 BludgeoningMissile 1 -1 War Magic 5 Shoots a shock wave at the target. The wave does 16-30 points of bludgeoning damage to the first thing it hits. +2747 Shock Arc II 2 Neutral Other 118 BludgeoningMissile 50 -1 War Magic 10 Shoots a shock wave at the target. The wave does 26-52 points of bludgeoning damage to the first thing it hits. +2748 Shock Arc III 3 Neutral Other 118 BludgeoningMissile 100 -1 War Magic 15 Shoots a shock wave at the target. The wave does 42-84 points of bludgeoning damage to the first thing it hits. +2749 Shock Arc IV 4 Neutral Other 118 BludgeoningMissile 150 -1 War Magic 20 Shoots a shock wave at the target. The wave does 52-105 points of bludgeoning damage to the first thing it hits. +2750 Shock Arc V 5 Neutral Other 118 BludgeoningMissile 200 -1 War Magic 25 Shoots a shock wave at the target. The wave does 68-136 points of bludgeoning damage to the first thing it hits. +2751 Shock Arc VI 6 Neutral Other 118 BludgeoningMissile 250 -1 War Magic 30 Shoots a shock wave at the target. The wave does 84-168 points of bludgeoning damage to the first thing it hits. +2752 Shock Arc VII 7 Neutral Other 118 BludgeoningMissile 300 -1 War Magic 35 Shoots a shock wave at the target. The wave does 115-189 points of bludgeoning damage to the first thing it hits. +2753 Blade Arc I 1 Neutral Other 123 SlashingMissile 1 -1 War Magic 5 Shoots a magical blade at the target. The bolt does 16-30 points of slashing damage to the first thing it hits. +2754 Blade Arc II 2 Neutral Other 123 SlashingMissile 50 -1 War Magic 10 Shoots a magical blade at the target. The bolt does 26-52 points of slashing damage to the first thing it hits. +2755 Blade Arc III 3 Neutral Other 123 SlashingMissile 100 -1 War Magic 15 Shoots a magical blade at the target. The bolt does 42-84 points of slashing damage to the first thing it hits. +2756 Blade Arc IV 4 Neutral Other 123 SlashingMissile 150 -1 War Magic 20 Shoots a magical blade at the target. The bolt does 52-105 points of slashing damage to the first thing it hits. +2757 Blade Arc V 5 Neutral Other 123 SlashingMissile 200 -1 War Magic 25 Shoots a magical blade at the target. The bolt does 68-136 points of slashing damage to the first thing it hits. +2758 Blade Arc VI 6 Neutral Other 123 SlashingMissile 250 -1 War Magic 30 Shoots a magical blade at the target. The bolt does 84-168 points of slashing damage to the first thing it hits. +2759 Blade Arc VII 7 Neutral Other 123 SlashingMissile 300 -1 War Magic 35 Shoots a magical blade at the target. The bolt does 115-189 points of slashing damage to the first thing it hits. +2760 Martyr's Hecatomb I 1 Debuff Other 80 HealthLowering 1 -1 Life Magic 10 Drains one-quarter of the caster's health into a bolt of energy. When struck by the bolt. the target's health is reduced by 75% of the amount drained. +2761 Martyr's Hecatomb II 2 Debuff Other 80 HealthLowering 50 -1 Life Magic 20 Drains one-quarter of the caster's health into a bolt of energy. When struck by the bolt. the target's health is reduced by 90% of the amount drained. +2762 Martyr's Hecatomb III 3 Debuff Other 80 HealthLowering 100 -1 Life Magic 30 Drains one-quarter of the caster's health into a bolt of energy. When struck by the bolt. the target's health is reduced by 105% of the amount drained. +2763 Martyr's Hecatomb IV 4 Debuff Other 80 HealthLowering 150 -1 Life Magic 40 Drains one-quarter of the caster's health into a bolt of energy. When struck by the bolt. the target's health is reduced by 125% of the amount drained. +2764 Martyr's Hecatomb V 5 Debuff Other 80 HealthLowering 200 -1 Life Magic 50 Drains one-quarter of the caster's health into a bolt of energy. When struck by the bolt. the target's health is reduced by 150% of the amount drained. +2765 Martyr's Hecatomb VI 6 Debuff Other 80 HealthLowering 250 -1 Life Magic 60 Drains one-quarter of the caster's health into a bolt of energy. When struck by the bolt. the target's health is reduced by 175% of the amount drained. +2766 Martyr's Hecatomb VII 7 Debuff Other 80 HealthLowering 300 -1 Life Magic 70 Drains one-quarter of the caster's health into a bolt of energy. When struck by the bolt. the target's health is reduced by 200% of the amount drained. +2767 Martyr's Tenacity I 1 Debuff Other 82 StaminaLowering 1 -1 Life Magic 10 Drains one-quarter of the caster's stamina into a bolt of energy. When struck by the bolt. the target's stamina is reduced by 75% of the amount drained. +2768 Martyr's Tenacity II 2 Debuff Other 82 StaminaLowering 50 -1 Life Magic 20 Drains one-quarter of the caster's stamina into a bolt of energy. When struck by the bolt. the target's stamina is reduced by 90% of the amount drained. +2769 Martyr's Tenacity III 3 Debuff Other 82 StaminaLowering 100 -1 Life Magic 30 Drains one-quarter of the caster's stamina into a bolt of energy. When struck by the bolt. the target's stamina is reduced by 105% of the amount drained. +2770 Martyr's Tenacity IV 4 Debuff Other 82 StaminaLowering 150 -1 Life Magic 40 Drains one-quarter of the caster's stamina into a bolt of energy. When struck by the bolt. the target's stamina is reduced by 125% of the amount drained. +2771 Martyr's Tenacity V 5 Debuff Other 82 StaminaLowering 200 -1 Life Magic 50 Drains one-quarter of the caster's stamina into a bolt of energy. When struck by the bolt. the target's stamina is reduced by 150% of the amount drained. +2772 Martyr's Tenacity VI 6 Debuff Other 82 StaminaLowering 250 -1 Life Magic 60 Drains one-quarter of the caster's stamina into a bolt of energy. When struck by the bolt. the target's stamina is reduced by 175% of the amount drained. +2773 Martyr's Tenacity VII 7 Debuff Other 82 StaminaLowering 300 -1 Life Magic 70 Drains one-quarter of the caster's stamina into a bolt of energy. When struck by the bolt. the target's stamina is reduced by 200% of the amount drained. +2774 Martyr's Blight I 1 Debuff Other 84 ManaLowering 1 -1 Life Magic 10 Drains one-quarter of the caster's mana into a bolt of energy. When struck by the bolt. the target's mana is reduced by 75% of the amount drained. +2775 Martyr's Blight II 2 Debuff Other 84 ManaLowering 50 -1 Life Magic 20 Drains one-quarter of the caster's mana into a bolt of energy. When struck by the bolt. the target's mana is reduced by 90% of the amount drained. +2776 Martyr's Blight III 3 Debuff Other 84 ManaLowering 100 -1 Life Magic 30 Drains one-quarter of the caster's mana into a bolt of energy. When struck by the bolt. the target's mana is reduced by 105% of the amount drained. +2777 Martyr's Blight IV 4 Debuff Other 84 ManaLowering 150 -1 Life Magic 40 Drains one-quarter of the caster's mana into a bolt of energy. When struck by the bolt. the target's mana is reduced by 125% of the amount drained. +2778 Martyr's Blight V 5 Debuff Other 84 ManaLowering 200 -1 Life Magic 50 Drains one-quarter of the caster's mana into a bolt of energy. When struck by the bolt. the target's mana is reduced by 150% of the amount drained. +2779 Martyr's Blight VI 6 Debuff Other 84 ManaLowering 250 -1 Life Magic 60 Drains one-quarter of the caster's mana into a bolt of energy. When struck by the bolt. the target's mana is reduced by 175% of the amount drained. +2780 Martyr's Blight VII 7 Debuff Other 84 ManaLowering 300 -1 Life Magic 70 Drains one-quarter of the caster's mana into a bolt of energy. When struck by the bolt. the target's mana is reduced by 200% of the amount drained. +2781 Lesser Elemental Fury 7 Neutral Other 237 BludgeoningStrike 300 -1 War Magic 200 Disitegrates the target for 200 points of acid damage. +2782 Lesser Elemental Fury 7 Neutral Other 237 BludgeoningStrike 300 -1 War Magic 200 Burns the target for 200 points of fire damage. +2783 Lesser Elemental Fury 7 Neutral Other 237 BludgeoningStrike 300 -1 War Magic 200 Burns the target for 200 points of cold damage. +2784 Lesser Elemental Fury 7 Neutral Other 237 BludgeoningStrike 300 -1 War Magic 200 Jolts the target for 200 points of electric damage. +2785 Lesser Stasis Field 1 Buff Other 421 AttributesDecrease 20 120 Life Magic 300 Decreases all of the target's attributes by 20 points. +2786 Madness 7 Debuff Other 10 FocusLowering 325 240 Creature Enchantment 70 Wearing the mask makes you feel strange. +2787 Supremacy 7 Buff Other 529 AllegianceRaising 300 60 Creature Enchantment 70 Increases the Allegiance Rank by 1. +2788 Essence Blight 6 Debuff Other 84 ManaLowering 275 -1 Life Magic 60 Drains 5000 points of the targets Mana. +2789 Elemental Destruction 1 Debuff Other 80 HealthLowering 1 -1 Life Magic 10 Drains 8000 points of the target's Health. +2790 Weight of the World 6 Debuff Other 2 StrengthLowering 275 60 Creature Enchantment 1 Afflicts the target with the weight of the world. +2791 Rolling Death 7 Neutral Other 117 AcidMissile 320 -1 War Magic 120 A giant ball of acid. +2792 Rolling Death 7 Neutral Other 121 FireMissile 320 -1 War Magic 120 A giant ball of fire. +2793 Rolling Death 7 Neutral Other 119 ColdMissile 320 -1 War Magic 120 A giant ball of ice. +2794 Rolling Death 7 Neutral Other 120 ElectricMissile 320 -1 War Magic 120 A giant ball of lightning. +2795 Citadel Library 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2796 Citadel Surface 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2797 Proving Grounds Rolling Death 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2798 Proving Grounds High 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2799 Proving Grounds Low 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2800 Proving Grounds Mid 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2801 Proving Grounds Extreme 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2802 Proving Grounds High 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2803 Proving Grounds Low 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2804 Proving Grounds Mid 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2805 Impudence 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2806 Impudence 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2807 Impudence 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2808 Impudence 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2809 Moderate Arcane Prowess 1 Buff Other 335 ExtraArcaneLoreSkillRaising 10 780 Creature Enchantment 10 Increases the target's Arcane Lore skill by 10 points. Additional spells can be layered over this. +2810 Moderate Life Magic Aptitude 1 Buff Other 357 ExtraLifeMagicSkillRaising 10 780 Creature Enchantment 10 Increases the target's Life Magic skill by 10 points. Additional spells can be layered over this. +2811 Moderate Magic Resistance 1 Buff Other 299 MagicDefenseShelterRaising 10 780 Creature Enchantment 10 Increases the target's Magic Defense skill by 10 points. Additional spells can be layered over this. +2812 Moderate War Magic Aptitude 1 Buff Other 255 WarMysticRaising 10 780 Creature Enchantment 10 Increases the target's War Magic skill by 10 points. Additional spells can be layered over this. +2813 Mount Lethe Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 150 Transports the caster to the base of Mount Lethe. +2814 Priest's Curse 6 Neutral Other 122 PiercingMissile 250 -1 War Magic 30 Casts the Undead Priest's Curse on the target. The bolt does 61-120 points of piercing damage to the first thing it hits. +2815 Boom Black Firework OUT 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots out a Black Firework. +2816 Big Boom Black Firework OUT 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots out a Black Firework. +2817 Shockwave Black Firework OUT 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots out a Black Firework. +2818 Spiral Black Firework OUT 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots out a Black Firework. +2819 Sparkle Black Firework OUT 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots out a Black Firework. +2820 Blossom Black Firework OUT 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots out a Black Firework. +2821 Ring Black Firework OUT 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots out a Black Firework. +2822 Boom Blue Firework OUT 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots out a Blue Firework. +2823 Big Boom Blue Firework OUT 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots out a Blue Firework. +2824 Shockwave Blue Firework OUT 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots out a Blue Firework. +2825 Spiral Blue Firework OUT 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots out a Blue Firework. +2826 Sparkle Blue Firework OUT 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots out a Blue Firework. +2827 Blossom Blue Firework OUT 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots out a Blue Firework. +2828 Ring Blue Firework OUT 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots out a Blue Firework. +2829 Boom Green Firework OUT 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots out a Green Firework. +2830 Big Boom Green Firework OUT 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots out a Green Firework. +2831 Shockwave Green Firework OUT 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots out a Green Firework. +2832 Spiral Green Firework OUT 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots out a Green Firework. +2833 Sparkle Green Firework OUT 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots out a Green Firework. +2834 Blossom Green Firework OUT 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots out a Green Firework. +2835 Ring Green Firework OUT 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots out a Green Firework. +2836 Boom Orange Firework OUT 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots out a Orange Firework. +2837 Big Boom Orange Firework OUT 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots out a Orange Firework. +2838 Shockwave Orange Firework OUT 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots out a Orange Firework. +2839 Spiral Orange Firework OUT 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots out a Orange Firework. +2840 Sparkle Orange Firework OUT 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots out a Orange Firework. +2841 Blossom Orange Firework OUT 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots out a Orange Firework. +2842 Ring Orange Firework OUT 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots out a Orange Firework. +2843 Boom Purple Firework OUT 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots out a Purple Firework. +2844 Big Boom Purple Firework OUT 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots out a Purple Firework. +2845 Shockwave Purple Firework OUT 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots out a Purple Firework. +2846 Spiral Purple Firework OUT 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots out a Purple Firework. +2847 Sparkle Purple Firework OUT 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots out a Purple Firework. +2848 Blossom Purple Firework OUT 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots out a Purple Firework. +2849 Ring Purple Firework OUT 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots out a Purple Firework. +2850 Boom Red Firework OUT 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots out a Red Firework. +2851 Big Boom Red Firework OUT 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots out a Red Firework. +2852 Shockwave Red Firework OUT 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots out a Red Firework. +2853 Spiral Red Firework OUT 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots out a Red Firework. +2854 Sparkle Red Firework OUT 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots out a Red Firework. +2855 Blossom Red Firework OUT 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots out a Red Firework. +2856 Ring Red Firework OUT 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots out a Red Firework. +2857 Boom White Firework OUT 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots out a White Firework. +2858 Big Boom White Firework OUT 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots out a White Firework. +2859 Shockwave White Firework OUT 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots out a White Firework. +2860 Spiral White Firework OUT 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots out a White Firework. +2861 Sparkle White Firework OUT 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots out a White Firework. +2862 Blossom White Firework OUT 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots out a White Firework. +2863 Ring White Firework OUT 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots out a White Firework. +2864 Boom Yellow Firework OUT 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots out a Yellow Firework. +2865 Big Boom Yellow Firework OUT 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots out a Yellow Firework. +2866 Shockwave Yellow Firework OUT 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots out a Yellow Firework. +2867 Spiral Yellow Firework OUT 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots out a Yellow Firework. +2868 Sparkle Yellow Firework OUT 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots out a Yellow Firework. +2869 Blossom Yellow Firework OUT 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots out a Yellow Firework. +2870 Ring Yellow Firework OUT 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots out a Yellow Firework. +2871 Boom Black Firework UP 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots a Black Firework straight up. +2872 Big Boom Black Firework UP 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots a Black Firework straight up. +2873 Shockwave Black Firework UP 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots a Black Firework straight up. +2874 Spiral Black Firework UP 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots a Black Firework straight up. +2875 Sparkle Black Firework UP 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots a Black Firework straight up. +2876 Blossom Black Firework UP 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots a Black Firework straight up. +2877 Ring Black Firework UP 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots a Black Firework straight up. +2878 Boom Blue Firework UP 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots a Blue Firework straight up. +2879 Big Boom Blue Firework UP 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots a Blue Firework straight up. +2880 Shockwave Blue Firework UP 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots a Blue Firework straight up. +2881 Spiral Blue Firework UP 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots a Blue Firework straight up. +2882 Sparkle Blue Firework UP 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots a Blue Firework straight up. +2883 Blossom Blue Firework UP 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots a Blue Firework straight up. +2884 Ring Blue Firework UP 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots a Blue Firework straight up. +2885 Boom Green Firework UP 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots a Green Firework straight up. +2886 Big Boom Green Firework UP 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots a Green Firework straight up. +2887 Shockwave Green Firework UP 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots a Green Firework straight up. +2888 Spiral Green Firework UP 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots a Green Firework straight up. +2889 Sparkle Green Firework UP 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots a Green Firework straight up. +2890 Blossom Green Firework UP 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots a Green Firework straight up. +2891 Ring Green Firework UP 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots a Green Firework straight up. +2892 Boom Orange Firework UP 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots a Orange Firework straight up. +2893 Big Boom Orange Firework UP 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots a Orange Firework straight up. +2894 Shockwave Orange Firework UP 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots a Orange Firework straight up. +2895 Spiral Orange Firework UP 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots a Orange Firework straight up. +2896 Sparkle Orange Firework UP 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots a Orange Firework straight up. +2897 Blossom Orange Firework UP 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots a Orange Firework straight up. +2898 Ring Orange Firework UP 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots a Orange Firework straight up. +2899 Boom Purple Firework UP 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots a Purple Firework straight up. +2900 Big Boom Purple Firework UP 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots a Purple Firework straight up. +2901 Shockwave Purple Firework UP 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots a Purple Firework straight up. +2902 Spiral Purple Firework UP 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots a Purple Firework straight up. +2903 Sparkle Purple Firework UP 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots a Purple Firework straight up. +2904 Blossom Purple Firework UP 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots a Purple Firework straight up. +2905 Ring Purple Firework UP 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots a Purple Firework straight up. +2906 Boom Red Firework UP 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots a Red Firework straight up. +2907 Big Boom Red Firework UP 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots a Red Firework straight up. +2908 Shockwave Red Firework UP 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots a Red Firework straight up. +2909 Spiral Red Firework UP 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots a Red Firework straight up. +2910 Sparkle Red Firework UP 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots a Red Firework straight up. +2911 Blossom Red Firework UP 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots a Red Firework straight up. +2912 Ring Red Firework UP 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots a Red Firework straight up. +2913 Boom White Firework UP 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots a White Firework straight up. +2914 Big Boom White Firework UP 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots a White Firework straight up. +2915 Shockwave White Firework UP 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots a White Firework straight up. +2916 Spiral White Firework UP 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots a White Firework straight up. +2917 Sparkle White Firework UP 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots a White Firework straight up. +2918 Blossom White Firework UP 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots a White Firework straight up. +2919 Ring White Firework UP 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots a White Firework straight up. +2920 Boom Yellow Firework UP 1 Neutral Other 409 Fireworks 1 -1 War Magic 10 Shoots a Yellow Firework straight up. +2921 Big Boom Yellow Firework UP 2 Neutral Other 409 Fireworks 50 -1 War Magic 20 Shoots a Yellow Firework straight up. +2922 Shockwave Yellow Firework UP 3 Neutral Other 409 Fireworks 100 -1 War Magic 30 Shoots a Yellow Firework straight up. +2923 Spiral Yellow Firework UP 4 Neutral Other 409 Fireworks 150 -1 War Magic 40 Shoots a Yellow Firework straight up. +2924 Sparkle Yellow Firework UP 5 Neutral Other 409 Fireworks 200 -1 War Magic 50 Shoots a Yellow Firework straight up. +2925 Blossom Yellow Firework UP 6 Neutral Other 409 Fireworks 250 -1 War Magic 60 Shoots a Yellow Firework straight up. +2926 Ring Yellow Firework UP 7 Neutral Other 409 Fireworks 300 -1 War Magic 70 Shoots a Yellow Firework straight up. +2927 Old School Fireworks 1 Neutral Other 409 Fireworks 1 -1 War Magic 15 Original Anniversary Celebration Effect. +2928 Tusker Hide 6 Buff Other 115 ArmorRaising 250 5400 Life Magic 100 Increases the target's natural armor by 200 points. +2929 Tusker Might 6 Buff Other 1 StrengthRaising 276 5400 Creature Enchantment 100 Increases the caster's strength by 35. +2930 Tusker Skin 6 Buff Item 160 ArmorValueRaising 253 5400 Item Enchantment 70 Boosts a piece of armor by 200 points. +2931 Recall Aphus Lassel 5 Utility Self 214 PortalSending 225 -1 Item Enchantment 150 Teleports caster to Aphus Lassel. +2932 Tusker Leap 8 Buff Other 69 JumpRaising 401 10 Creature Enchantment 100 Boosts casters jump skill by 100 for a short time. +2933 Tusker Sprint 8 Buff Other 77 RunRaising 401 60 Creature Enchantment 100 Boosts casters run skill by 100 for a short time. +2934 Tusker Fists 7 Neutral Other 230 BludgeoningWall 325 -1 War Magic 120 A hail of tusker fists pummels a clear path ahead of the caster. +2935 Trial of the Tusker Hero 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports target to Mowen Udaun. +2936 Entrance to Tusker Island 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports target to Tusker Island. +2937 Moderate Impregnability 1 Buff Other 297 MissileDefenseShelterRaising 10 780 Creature Enchantment 10 Increases the target's Missile Defense skill by 10 points. Additional spells can be layered over this. +2938 Moderate Invulnerability 1 Buff Other 351 ExtraMeleeDefenseSkillRaising 10 780 Creature Enchantment 10 Increases the target's Melee Defense skill by 10 points. Additional spells can be layered over this. +2939 Entering the Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Temple of Enlightenment. +2940 Entering the Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Temple of Forgetfulness. +2941 Ulgrim's Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 150 A really really good spell. +2942 Free Ride to the Abandoned Mine 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2943 Recall to the Singularity Caul 5 Utility Self 214 PortalSending 225 -1 Item Enchantment 150 Teleports caster to the Singularity Caul. +2944 Storage Warehouse 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2945 Storage Warehouse 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2946 Moderate Creature Magic Aptitude 1 Buff Other 251 CreatureMysticRaising 10 780 Creature Enchantment 10 Increases the target's Creature Magic skill by 10 points. Additional spells can be layered over this. +2947 Nullify All Magic Other 7 Neutral Other 250 Dispel 300 -1 Life Magic 240 Dispels all negative enchantments of level 6 or lower from the target. This spell is not affected by mana conversion. +2948 Hieromancer's Great Ward 5 Buff Item 190 ArmorLevelRaising 200 780 Item Enchantment 50 Improves a shield or piece of armor's armor value by 220 points. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. +2949 Lightbringer's Way 6 Buff Item 154 DamageRaising 250 2700 Item Enchantment 60 Enhances the mettle and conviction of a weapon so that the metal bites deeper. The damage of the weapon is increased by 21 points. +2950 Maiden's Kiss 1 Buff Other 279 LifeGiverRaising 30 510 Life Magic 70 Enhances the health of the recipient by 30 points. +2951 Gates of Knorr 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2952 Courtyard of Knorr 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2953 Interior Gates of Knorr 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2954 Barracks Conveyance 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2955 Forge Conveyance 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2956 Research Chambers Conveyance 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2957 Seat of Knorr 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2958 Blessing of the Priestess 1 Buff Other 357 ExtraLifeMagicSkillRaising 5 300 Creature Enchantment 10 Increases the target's Life Magic skill by 5 points. Additional enchancements to the skill can be layered over this. +2959 Mark of the Priestess 1 Buff Other 357 ExtraLifeMagicSkillRaising 10 300 Creature Enchantment 10 Increases the target's Life Magic skill by 10 points. Additional enchancements to the skill can be layered over this. +2960 Greater Bludgeoning Durance 2 Buff Item 176 BludgeoningResistanceRaising 50 360 Item Enchantment 20 Increases a shield or piece of armor's resistance to bludgeoning damage by 100%. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. allowing additional magical defenses to be layered over it. +2961 Greater Piercing Durance 2 Buff Item 180 PiercingResistanceRaising 50 360 Item Enchantment 20 Increases a shield or piece of armor's resistance to piercing damage by 100%. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. allowing additional magical defenses to be layered over it. +2962 Greater Slashing Durance 2 Buff Item 178 SlashingResistanceRaising 50 360 Item Enchantment 20 Increases a shield or piece of armor's resistance to slashing damage by 100%. This spell resonates in harmony with the natural frequency of Thaumaturgic Plate crystal. allowing additional magical defenses to be layered over it. +2963 Aura of Hunter's Cunning 8 Buff Item 152 AttackModRaising 500 780 Item Enchantment 10 My prey shall know the bite of my steel long before it becomes aware of my presence. Increases the base offense bonus of a weapon by 18%. +2964 Aura of Hunter's Mark 8 Buff Item 156 DefenseModRaising 500 780 Item Enchantment 10 I shall be known by motion and cunning. all shall fear my mark. Increases the Melee Defense skill modifier of a weapon or magic caster by 18%. +2965 Aura of Murderous Intent 8 Buff Item 195 ManaConversionModRaising 500 3600 Item Enchantment 70 I shall know my mindset and my prey will learn to fear. Increases the mana conversion bonus of a casting implement by 80%. +2966 Aura of Murderous Thirst 8 Buff Item 154 DamageRaising 500 780 Item Enchantment 10 I shall drink the blood of my victims and it shall nourish my fevered desire. Increases the base damage of a weapon by 26. +2967 Aura of The Speedy Hunter 8 Buff Item 158 WeaponTimeRaising 500 780 Item Enchantment 10 My movements shall become as the wind. silent and swift. Decrease the base speed of a weapon by 30. +2968 Vision of the Hunter 8 Buff Item 325 BowDamageRaising 500 780 Item Enchantment 10 I will see with a sight beyond sight. Increases the base damage bonus of a weapon by 18%. +2969 Mother's Blessing 1 Buff Other 279 LifeGiverRaising 25 510 Life Magic 70 This spell increases the overall health of a character by 25 points. This is not stackable with other effects. +2970 Hunter's Lash 7 Neutral Other 137 SlashingBurst 300 -1 Life Magic 60 ...and the blood shall pour down my throat and sate the thirst. Deals 70-180 points of slashing damage to a player/creatures before resistance is applied. +2971 Bullseye 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the player to the logic test of Oswald's Lair. +2972 Oswald's Room 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports target to Oswald's Room +2973 Access to the Secret Lair 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the player to Oswald's Lair. +2974 Vagabond Passed 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports target to test of fleet feet. +2975 Moderate Item Enchantment Aptitude 1 Buff Other 253 ItemMysticRaising 10 780 Creature Enchantment 10 Increases the target's Item Enchantment skill by 10 points. Additional spells can be layered over this. +2976 Acid Spray 5 Neutral Other 131 AcidBurst 225 -1 War Magic 30 Sprayed acid from an olthoi egg. +2977 Portal spell to a hidden place 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2978 Nullify All Magic Other 7 Neutral Other 250 Dispel 375 -1 Life Magic 300 Dispels all enchantments of level 7 or lower from the target. +2979 Destiny's Wind 3 Buff Other 283 ManaGiverRaising 100 5400 Life Magic 70 Increases maximum mana by 100 points. +2980 Endless Vigor 7 Buff Other 81 StaminaRaising 350 5400 Life Magic 100 Increases maximum stamina by 100 points. +2981 Fellowship Heal I 1 Buff Fellowship 67 HealingRaising 1 -1 Life Magic 10 Restores 8-15 points of each fellow member. +2982 Fellowship Alchemy Mastery I 1 Buff Fellowship 221 AlchemyRaising 1 1800 Creature Enchantment 10 Increases each fellow's Alchemy skill by 10 points. +2983 Fellowship Evaporate Life Magic Self 2 Neutral Fellowship 250 Dispel 50 -1 Life Magic 50 Dispels 1-3 negative Life Magic enchantments of level 1 from each person in the fellowship. +2984 Lyceum of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the fellowship to the specified destination. +2985 Ardence 1 Buff Other 279 LifeGiverRaising 15 510 Life Magic 70 Increases maximum health by 15 points. +2986 Vim 1 Buff Other 81 StaminaRaising 15 5400 Life Magic 100 Increases maximum stamina by 15 points. +2987 Volition 1 Buff Other 283 ManaGiverRaising 15 5400 Life Magic 70 Increases maximum mana by 15 points. +2988 Beaten into Submission 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +2989 Portal to the Bandit Hideout. 6 Utility Self 214 PortalSending 250 -1 Item Enchantment 50 Transports the target to the specified destination. +2990 Knocked Out 6 Neutral Item 214 PortalSending 250 -1 Item Enchantment 50 Transports the target to the specified destination. +2991 Winter's Kiss 1 Buff Other 289 ColdWardProtection 13 7200 Life Magic 10 Reduces damage the target takes from Cold by 13%. Additional spells can be layered over this. +2992 Depletion 2 Buff Other 412 ManaDivide 50 30 Creature Enchantment 10 Reduces the total mana of target by half. +2993 Grace of the Unicorn 1 Buff Other 413 CoordinationIncrease2 2 10800 Creature Enchantment 10 Increases the target's Coordination by 2 points. Additional spells. including cantrips. can be layered over this. +2994 Plague 2 Buff Other 410 HealthDivide 50 30 Creature Enchantment 10 Target's total health is reduces by 50%. +2995 Power of the Dragon 1 Buff Other 414 StrengthIncrease2 2 10800 Creature Enchantment 10 Increases the target's Strength by 2 points. Additional spells. including Cantrips. can be layered over this. +2996 Scourge 2 Buff Other 411 StaminaDivide 50 30 Creature Enchantment 10 Target's total stamina is reduced by 50%. +2997 Splendor of the Firebird 1 Buff Other 415 FocusIncrease2 2 10800 Creature Enchantment 10 Increases the target's Focus by 2 points. Additional spells. including cantrips. can be layered over this. +2998 Wrath of the Puppeteer 3 Neutral Other 211 FlameVolley 125 -1 War Magic 15 Shoots three bolts of flame toward the target. Each bolt does 40-60 points of fire damage to the first thing it hits. +2999 Endurance of the Abyss 1 Buff Other 416 EnduranceIncrease2 2 780 Creature Enchantment 10 Increases the target's Endurance by 2 points. Additional spells. including Cantrips. can be layered over this. +3000 Ire of the Dark Prince 8 Debuff Other 116 ArmorLowering 500 10 Life Magic 60 Decreases the target's natural armor by 500 points. +3001 Puppet String 1 Buff Other 421 AttributesDecrease 25 60 Creature Enchantment 10 Reduces all target's attributes by 25 for one minute. +3002 Will of the Quiddity 1 Buff Other 417 SelfIncrease2 2 780 Creature Enchantment 10 Increases the target's Self by 2 points. Additional spells can be layered over this. +3003 Dark Wave 2 Buff Other 410 HealthDivide 50 10 Creature Enchantment 10 Lowers the total health of all fellowship member by half for ten seconds. +3004 Puppet Strings 1 Buff Other 421 AttributesDecrease 25 60 Creature Enchantment 10 Lowers the attributes of a fellowship by 25 points for one minute. +3005 Dispersion 1 Buff Other 420 MagicDefenseMultiply 1 780 Creature Enchantment 10 Enhances the target's base Magic Defense by 1%. this can be layered with other spells. +3006 Foresight 1 Buff Other 419 MissileDefenseMultiply 1 780 Creature Enchantment 10 Enhances the target's base Missile Defense by 1%. other spells can be layered on top of this spell. +3007 Uncanny Dodge 1 Buff Other 418 MeleeDefenseMultiply 1 780 Creature Enchantment 10 Enhances the target's base Melee Defense by 1% +3008 Finesse 1 Buff Other 267 CoordinationIncrease 8 780 Creature Enchantment 40 Increases the target's Coordination by 8 points. Additional spells can be layered over this. +3009 Thew 1 Buff Other 261 StrengthIncrease 8 780 Creature Enchantment 10 Increases the target's Strength by 8 points. Additional spells can be layered over this. +3010 Zeal 1 Buff Other 263 EnduranceIncrease 8 780 Creature Enchantment 10 Increases the target's Endurance by 8 points. Additional spells can be layered over this. +3011 Endless Sight 1 Buff Other 331 ExtraBowSkillRaising 8 780 Creature Enchantment 40 Increases the target's Missile Weapons Skill by 8 points. Additional spells can be layered over this. +3012 Far Sight 1 Buff Other 331 ExtraBowSkillRaising 8 780 Creature Enchantment 40 Increases the target's Missile Weapons Skill by 8 points. Additional spells can be layered over this. +3013 Fruit of the Oasis 1 Buff Other 257 HealthRestoring 20 780 Life Magic 10 Increases the rate at which the target regains Health by 20%. Additional spells can be layered over this. +3014 Water of the Oasis 1 Buff Other 259 ManaRestoring 20 780 Life Magic 10 Increases the rate at which the target regains Mana by 20%. Additional spells can be layered over this. +3015 Shade of the Oasis 1 Buff Other 407 StaminaRestoring 20 780 Life Magic 10 Increases the rate at which the target regains Stamina by 20%. Additional spells can be layered over this. +3016 Raptor's Sight 1 Buff Other 331 ExtraBowSkillRaising 8 780 Creature Enchantment 40 Increases the target's Missile Weapons Skill by 8 points. Additional spells can be layered over this. +3017 Greater Battle Dungeon Sending from Candeth Keep 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3018 Greater Battle Dungeon Sending from Fort Tethana 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3019 Greater Battle Dungeon Sending from Nanto 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3020 Greater Battle Dungeon Sending from Plateau 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3021 Greater Battle Dungeon Sending from Qalabar 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3022 Greater Battle Dungeon Sending from Tou-Tou 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3023 Greater Battle Dungeon Sending from Xarabydun 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3024 Greater Battle Dungeon Sending from Yaraq 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3025 Shriek 6 Neutral Other 118 BludgeoningMissile 280 -1 War Magic 30 A howling wail. Does 40-80 points of bludgeoning damage to the first thing it hits. +3026 Lesser Battle Dungeon Sending from Candeth Keep 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3027 Lesser Battle Dungeon Sending from Fort Tethana 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3028 Lesser Battle Dungeon Sending from Nanto 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3029 Lesser Battle Dungeon Sending from Plateau 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3030 Lesser Battle Dungeon Sending from Qalabar 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3031 Lesser Battle Dungeon Sending from Tou-Tou 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3032 Lesser Battle Dungeon Sending from Xarabydun 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3033 Lesser Battle Dungeon Sending from Yaraq 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3034 Benediction of Immortality 8 Buff Other 422 LifeGiverRaising2 500 780 Creature Enchantment 10 Increases the target's Health by 7 points. Additional spells. including Cantrips. can be layered over this. +3035 Closing of the Great Divide 8 Buff Other 423 ItemEnchantmentRaising2 500 780 Creature Enchantment 10 Increases the target's Item Enchantment by 3 points. Additional spells. including Cantrips. can be layered over this. +3036 Cold Grip of the Grave 8 Debuff Other 82 StaminaLowering 500 -1 Life Magic 60 Drains 300 points of the target's Stamina. +3037 Death's Call 8 Debuff Other 80 HealthLowering 500 -1 Life Magic 70 Drains 40 points of the target's Health. +3038 Death's Embrace 8 Debuff Other 80 HealthLowering 500 -1 Life Magic 70 Drains 50 points of the target's Health. +3039 Death's Feast 8 Debuff Other 80 HealthLowering 500 -1 Life Magic 60 Drains 150 points of the target's Health. +3040 Places Death's Kiss upon you. 8 Debuff Other 80 HealthLowering 500 -1 Life Magic 70 Drains 30 points of the target's Health. +3041 Essence Dissolution 8 Debuff Other 80 HealthLowering 500 -1 Life Magic 0 Drains 175 points of the target's Health. +3042 Grip of Death 8 Buff Other 424 SkillsDecrease 500 60 Creature Enchantment 10 Lowers all skills by 99%. +3043 Kiss of the Grave 8 Buff Other 411 StaminaDivide 500 120 Creature Enchantment 10 Lowers total stamina of each fellowship member by 50%. +3044 Lesser Benediction of Immortality 8 Buff Other 422 LifeGiverRaising2 500 780 Creature Enchantment 10 Increases the target's Health by 3 points. Additional spells. including Cantrips. can be layered over this. +3045 Lesser Closing of the Great Divide 8 Buff Other 423 ItemEnchantmentRaising2 500 780 Creature Enchantment 10 Increases the target's Item Enchantment by 1 point. Additional spells. including Cantrips. can be layered over this. +3046 Lesser Mists of Bur 5 Buff Other 115 ArmorRaising 240 3600 Life Magic 50 Increases the target's natural armor by 195 points. +3047 Matron's Barb 8 Debuff Other 84 ManaLowering 500 -1 Life Magic 0 Drains 250 point of the target's Mana. +3048 Minor Benediction of Immortality 8 Buff Other 422 LifeGiverRaising2 500 780 Creature Enchantment 10 Increases the target's Health by 5 points. Additional spells. including Cantrips. can be layered over this. +3049 Minor Closing of the Great Divide 8 Buff Other 423 ItemEnchantmentRaising2 500 780 Creature Enchantment 10 Increases the target's Item Enchantment by 2 points. Additional spells. including Cantrips. can be layered over this. +3050 Minor Mists of Bur 6 Buff Other 115 ArmorRaising 255 1800 Life Magic 50 Increases the target's natural armor by 205 points. +3051 Mire Foot 8 Debuff Other 78 RunLowering 500 120 Creature Enchantment 10 Target's run skill is reduces by 95%. +3052 Mists of Bur 7 Buff Other 115 ArmorRaising 305 1800 Life Magic 50 Increases the target's natural armor by 230 points. +3053 Paralyzing Touch 8 Buff Other 421 AttributesDecrease 500 60 Creature Enchantment 10 Lowers all attributes by 99%. +3054 Soul Dissolution 8 Debuff Other 80 HealthLowering 500 -1 Life Magic 70 Drains 750-1000 points of the target's Health. +3055 Asphyxiation 7 Buff Other 421 AttributesDecrease 300 120 Creature Enchantment 10 Lowers the attributes of a target by 30 points for two minutes. +3056 Death's Vice 8 Buff Other 421 AttributesDecrease 500 120 Creature Enchantment 10 Lowers total health of each fellowship member by 50%. +3057 Enervation 7 Buff Other 411 StaminaDivide 300 120 Creature Enchantment 10 Lowers the total stamina of a target by 20% for 2 minutes. +3058 Asphyiaxtion 7 Buff Other 421 AttributesDecrease 300 120 Creature Enchantment 10 Lowers the attributes of a target by 40 points for two minutes. +3059 Enervation 7 Buff Other 411 StaminaDivide 300 120 Creature Enchantment 10 Lowers the total stamina of a target by 30% for 2 minutes. +3060 Poison Blood 7 Buff Other 410 HealthDivide 300 45 Creature Enchantment 10 Lowers the total health of a target by 30% for 45 seconds. +3061 Taint Mana 7 Buff Other 412 ManaDivide 300 120 Creature Enchantment 10 Lowers the total mana of a target by 30% for 2 minutes. +3062 Asphyxiation 7 Buff Other 421 AttributesDecrease 300 120 Creature Enchantment 10 Lowers the attributes of a target by 20 points for two minutes. +3063 Enervation 7 Buff Other 411 StaminaDivide 300 120 Creature Enchantment 10 Lowers the total stamina of a target by 10% for 2 minutes. +3064 Poison Blood 7 Buff Other 410 HealthDivide 300 45 Creature Enchantment 10 Lowers the total health of a target by 10% for 45 seconds. +3065 Taint Mana 7 Buff Other 412 ManaDivide 300 120 Creature Enchantment 10 Lowers the total mana of a target by 10% for 2 minutes. +3066 Lesser Ward of Rebirth 6 Buff Other 93 HealthAccelerating 255 3600 Life Magic 70 Increase natural healing rate of all fellowship members by 100%. +3067 Matron's Curse 8 Buff Other 412 ManaDivide 500 120 Creature Enchantment 10 Lowers total mana of each fellowship member by 50%. +3068 Minor Ward of Rebirth 7 Buff Other 93 HealthAccelerating 310 3600 Life Magic 70 Increase natural healing rate of all fellowship members by 125%.. +3069 Poison Blood 7 Buff Other 410 HealthDivide 300 45 Creature Enchantment 10 Lowers the total health of a target by 20% for 45 seconds. +3070 Taint Mana 7 Buff Other 412 ManaDivide 300 120 Creature Enchantment 10 Lowers the total mana of a target by 20% for 2 minutes. +3071 Ward of Rebirth 8 Buff Other 93 HealthAccelerating 500 3600 Life Magic 70 Increase natural healing rate of all fellowship members by 150%. +3072 Hall of the Temple Guardians 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3073 Matron's Outer Chamber 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3074 Bruised Flesh 7 Buff Other 104 BludgeonVulnerability 300 120 Life Magic 10 Lowers bludgeoning resistance of a target by 100%. +3075 Flesh of Cloth 7 Buff Other 114 SlashVulnerability 300 120 Life Magic 10 Lowers slashing resistance of a target by 100%. +3076 Exposed Flesh 7 Buff Other 102 AcidVulnerability 300 120 Life Magic 10 Lowers acid resistance of a target by 100%. +3077 Flesh of Flint 7 Buff Other 110 FireVulnerability 300 120 Life Magic 10 Lowers flame resistance of a target by 100%. +3078 Weaken Flesh 7 Buff Other 112 PierceVulnerability 300 120 Life Magic 10 Lowers piercing resistance of a target by 100%. +3079 Thin Skin 7 Debuff Other 116 ArmorLowering 300 120 Life Magic 10 Lowers the natural armor of a target by 145. +3080 Bruised Flesh 7 Buff Other 104 BludgeonVulnerability 300 120 Life Magic 10 Lowers bludgeoning resistance of a target by 190%. +3081 Flesh of Cloth 7 Buff Other 114 SlashVulnerability 300 120 Life Magic 10 Lowers slashing resistance of a target by 190%. +3082 Exposed Flesh 7 Buff Other 102 AcidVulnerability 300 120 Life Magic 10 Lowers acid resistance of a target by 190%. +3083 Flesh of Flint 7 Buff Other 110 FireVulnerability 300 120 Life Magic 10 Lowers flame resistance of a target by 190%. +3084 Weaken Flesh 7 Buff Other 112 PierceVulnerability 300 120 Life Magic 10 Lowers piercing resistance of a target by 190%. +3085 Bruised Flesh 7 Buff Other 104 BludgeonVulnerability 300 120 Life Magic 10 Lowers bludgeoning resistance of a target by 160%. +3086 Flesh of Cloth 7 Buff Other 114 SlashVulnerability 300 120 Life Magic 10 Lowers slashing resistance of a target by 160%. +3087 Exposed Flesh 7 Buff Other 102 AcidVulnerability 300 120 Life Magic 10 Lowers acid resistance of a target by 160%. +3088 Flesh of Flint 7 Buff Other 110 FireVulnerability 300 120 Life Magic 10 Lowers flame resistance of a target by 160%. +3089 Weaken Flesh 7 Buff Other 112 PierceVulnerability 300 120 Life Magic 10 Lowers piercing resistance of a target by 160%. +3090 Thin Skin 7 Debuff Other 116 ArmorLowering 300 120 Life Magic 10 Lowers the natural armor of a target by 210. +3091 Thin Skin 7 Debuff Other 116 ArmorLowering 332 120 Life Magic 10 Lowers the natural armor of a target by 230. +3092 Lesser Skin of the Fiazhat 4 Buff Item 160 ArmorValueRaising 180 3600 Item Enchantment 70 Improves a shield or piece of armor's armor value by 180 points. +3093 Minor Skin of the Fiazhat 6 Buff Item 160 ArmorValueRaising 255 3600 Item Enchantment 70 Improves a shield or piece of armor's armor value by 205 points. +3094 Skin of the Fiazhat 7 Buff Item 160 ArmorValueRaising 305 3600 Item Enchantment 70 Improves a shield or piece of armor's armor value by 225 points. +3095 Crypt of Jexki Ki 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3096 Crypt of Ibrexi Jekti 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3097 Hall of the Guardians 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3098 Hall of the Greater Guardians 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3099 Hall of the Lesser Guardians 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3100 Antechamber of Ixir Zi's Temple 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3101 Crypt of Ixir Zi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3102 Kivik Lir's Temple 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3103 Crypt of Kixkti Xri 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3104 Hall of the Arbiter 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3105 Hall of the Arbiter 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3106 Hall of the Arbiter 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3107 Flay Soul 8 Neutral Other 123 SlashingMissile 500 -1 War Magic 35 Shoots a magical blade at the target. The bolt does 100-210 points of slashing damage to the first thing it hits. +3108 Flay Soul 8 Neutral Other 123 SlashingMissile 500 -1 War Magic 35 Shoots a magical blade at the target. The bolt does 100-220 points of slashing damage to the first thing it hits. +3109 Liquefy Flesh 8 Neutral Other 117 AcidMissile 500 -1 War Magic 35 Shoots a stream of acid at the target. The stream does 100-220 points of acid damage to the first thing it hits. +3110 Sear Flesh 8 Neutral Other 121 FireMissile 500 -1 War Magic 35 Shoots a bolt of flame at the target. The bolt does 100-220 points of fire damage to the first thing it hits. +3111 Soul Hammer 8 Neutral Other 118 BludgeoningMissile 500 -1 War Magic 35 Shoots a shock wave at the target. The wave does 100-220 points of bludgeoning damage to the first thing it hits. +3112 Soul Spike 8 Neutral Other 122 PiercingMissile 500 -1 War Magic 35 Shoots a bolt of force at the target. The bolt does 100-220 points of piercing damage to the first thing it hits. +3113 Flay Soul 8 Neutral Other 123 SlashingMissile 500 -1 War Magic 35 Shoots a magical blade at the target. The bolt does 100-200 points of slashing damage to the first thing it hits. +3114 Liquefy Flesh 8 Neutral Other 117 AcidMissile 500 -1 War Magic 35 Shoots a stream of acid at the target. The stream does 100-200 points of acid damage to the first thing it hits. +3115 Sear Flesh 8 Neutral Other 121 FireMissile 500 -1 War Magic 35 Shoots a bolt of flame at the target. The bolt does 100-200 points of fire damage to the first thing it hits. +3116 Soul Hammer 8 Neutral Other 118 BludgeoningMissile 500 -1 War Magic 35 Shoots a shock wave at the target. The wave does 100-200 points of bludgeoning damage to the first thing it hits. +3117 Soul Spike 8 Neutral Other 122 PiercingMissile 500 -1 War Magic 35 Shoots a bolt of force at the target. The bolt does 100-200 points of piercing damage to the first thing it hits. +3118 Liquefy Flesh 8 Neutral Other 117 AcidMissile 500 -1 War Magic 35 Shoots a stream of acid at the target. The stream does 100-210 points of acid damage to the first thing it hits. +3119 Sear Flesh 8 Neutral Other 121 FireMissile 500 -1 War Magic 35 Shoots a bolt of flame at the target. The bolt does 100-210 points of fire damage to the first thing it hits. +3120 Soul Hammer 8 Neutral Other 118 BludgeoningMissile 500 -1 War Magic 35 Shoots a shock wave at the target. The wave does 100-210 points of bludgeoning damage to the first thing it hits. +3121 Soul Spike 8 Neutral Other 122 PiercingMissile 500 -1 War Magic 35 Shoots a bolt of force at the target. The bolt does 100-210 points of piercing damage to the first thing it hits. +3122 Sacrificial Edge 8 Neutral Other 122 PiercingMissile 500 -1 War Magic 0 Shoots a single blade that deals 100-150 points of piercing damage at the target. +3123 Sacrificial Edges 8 Neutral Other 212 ForceVolley 500 -1 War Magic 0 Shoots three blades that deal 100-150 points of piercing damage at the target. +3124 Blight Mana 7 Buff Other 412 ManaDivide 300 300 Creature Enchantment 10 Lowers recipient's mana by 20% for 5 minutes. +3125 EnervateBeing 7 Buff Other 411 StaminaDivide 300 300 Creature Enchantment 10 Lowers recipent's Stamina by 20% for 5 minutes. +3126 Poison Health 7 Buff Other 410 HealthDivide 300 300 Creature Enchantment 10 Lowers recipient's health by 20% for 5 minutes. +3127 Fell Wind 8 Buff Other 411 StaminaDivide 500 300 Creature Enchantment 10 Lowers the total stamina of all fellowship members by 20% for 5 minutes. +3128 Infected Blood 8 Buff Other 410 HealthDivide 500 300 Creature Enchantment 10 Lowers the total health of all fellowship members by 20% for 5 minutes. +3129 Infirmed Mana 8 Buff Other 412 ManaDivide 500 300 Creature Enchantment 10 Lowers the total mana of all fellowship members by 20% for 5 minutes. +3130 Halls of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3131 Halls of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3132 Halls of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3133 Halls of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3134 Halls of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3135 Halls of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3136 Halls of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3137 Halls of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3138 Antechamber of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3139 Liazk Itzi's Crypt 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3140 Lair of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3141 Lair of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3142 Lair of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3143 Lair of Liazk Itzi 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3144 Liazk Itzi Guardians 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3145 Liazk Itzi Guardians 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3146 Liazk Itzi Guardians 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3147 Liazk Itzi Guardians 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3148 Liazk Itzi's Offering Room 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3149 Liazk Itzi's Offering Room 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3150 Liazk Itzi's Offering Room 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3151 Liazk Itzi's Offering Room 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3152 Inferior Scythe Aegis 5 Buff Other 113 SlashProtection 245 3600 Life Magic 40 Reduces damage the target takes from Slashing by 52%. +3153 Lesser Scythe Aegis 4 Buff Other 113 SlashProtection 195 3600 Life Magic 50 Reduces damage the target takes from Slashing by 45%. +3154 Scythe Aegis 6 Buff Other 113 SlashProtection 295 3600 Life Magic 60 Reduces damage the target takes from Slashing by 62%. +3155 Lesser Alacrity of the Conclave 4 Buff Other 7 CoordinationRaising 175 1800 Creature Enchantment 40 Enhances the Coordination of all Fellowship members by 25 points for 30 minutes. +3156 Alacrity of the Conclave 5 Buff Other 7 CoordinationRaising 225 1800 Creature Enchantment 50 Enhances the Coordination of all Fellowship members by 30 points for 30 minutes. +3157 Greater Alacrity of the Conclave 6 Buff Other 7 CoordinationRaising 275 2700 Creature Enchantment 60 Enhances the Coordination of all Fellowship members by 35 points for 45 minutes. +3158 Superior Alacrity of the Conclave 7 Buff Other 7 CoordinationRaising 325 3600 Creature Enchantment 70 Enhances the Coordination of all Fellowship members by 40 points for 60 minutes. +3159 Lesser Vivify the Conclave 4 Buff Other 3 EnduranceRaising 175 1800 Creature Enchantment 40 Enhances the Endurance of all Fellowship members by 25 points for 30 minutes. +3160 Vivify the Conclave 5 Buff Other 3 EnduranceRaising 225 1800 Creature Enchantment 50 Enhances the Endurance of all Fellowship members by 30 points for 30 minutes. +3161 Greater Vivify the Conclave 6 Buff Other 3 EnduranceRaising 275 2700 Creature Enchantment 60 Enhances the Endurance of all Fellowship members by 35 points for 45 minutes. +3162 Superior Vivify the Conclave 7 Buff Other 3 EnduranceRaising 325 3600 Creature Enchantment 70 Enhances the Endurance of all Fellowship members by 40 points for 60 minutes. +3163 Lesser Acumen of the Conclave 4 Buff Other 9 FocusRaising 175 1800 Creature Enchantment 40 Enhances the Focus of all Fellowship members by 25 points for 30 minutes. +3164 Acumen of the Conclave 5 Buff Other 9 FocusRaising 225 1800 Creature Enchantment 50 Enhances the Focus of all Fellowship members by 30 points for 30 minutes. +3165 Greater Acumen of the Conclave 6 Buff Other 9 FocusRaising 275 2700 Creature Enchantment 60 Enhances the Focus of all Fellowship members by 35 points for 45 minutes. +3166 Superior Acumen of the Conclave 7 Buff Other 9 FocusRaising 325 3600 Creature Enchantment 70 Enhances the Focus of all Fellowship members by 40 points for 60 minutes. +3167 Lesser Speed the Conclave 4 Buff Other 5 QuicknessRaising 175 1800 Creature Enchantment 40 Enhances the Quickness of all Fellowship members by 25 points for 30 minutes. +3168 Speed the Conclave 5 Buff Other 5 QuicknessRaising 225 1800 Creature Enchantment 50 Enhances the Quickness of all Fellowship members by 30 points for 30 minutes. +3169 Greater Speed the Conclave 6 Buff Other 5 QuicknessRaising 275 2700 Creature Enchantment 60 Enhances the Quickness of all Fellowship members by 35 points for 45 minutes. +3170 Superior Speed the Conclave 7 Buff Other 5 QuicknessRaising 325 3600 Creature Enchantment 70 Enhances the Quickness of all Fellowship members by 40 points for 60 minutes. +3171 Lesser Volition of the Conclave 4 Buff Other 11 SelfRaising 175 1800 Creature Enchantment 40 Enhances the Self of all Fellowship members by 25 points for 30 minutes. +3172 Volition of the Conclave 5 Buff Other 11 SelfRaising 225 1800 Creature Enchantment 50 Enhances the Self of all Fellowship members by 30 points for 30 minutes. +3173 Greater Volition of the Conclave 6 Buff Other 11 SelfRaising 275 2700 Creature Enchantment 60 Enhances the Self of all Fellowship members by 35 points for 45 minutes. +3174 Superior Volition of the Conclave 7 Buff Other 11 SelfRaising 325 3600 Creature Enchantment 70 Enhances the Self of all Fellowship members by 40 points for 60 minutes. +3175 Lesser Empowering the Conclave 4 Buff Other 1 StrengthRaising 175 1800 Creature Enchantment 40 Enhances the Strength of all Fellowship members by 25 points for 30 minutes. +3176 Empowering the Conclave 5 Buff Other 1 StrengthRaising 225 1800 Creature Enchantment 50 Enhances the Strength of all Fellowship members by 30 points for 30 minutes. +3177 Greater Empowering the Conclave 6 Buff Other 1 StrengthRaising 275 2700 Creature Enchantment 60 Enhances the Strength of all Fellowship members by 35 points for 45 minutes. +3178 Superior Empowering the Conclave 7 Buff Other 1 StrengthRaising 325 3600 Creature Enchantment 70 Enhances the Strength of all Fellowship members by 40 points for 60 minutes. +3179 Eradicate All Magic Other 7 Neutral Other 250 Dispel 350 -1 Life Magic 280 Dispels all negative enchantments of level 7 or lower from the target. +3180 Eradicate All Magic Self 7 Neutral Self 250 Dispel 350 -1 Life Magic 280 Dispels all negative enchantments of level 7 or lower from the caster. +3181 Nullify All Magic Other 7 Neutral Other 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 positive enchantments of level 6 or lower from the target. +3182 Nullify All Magic Self 7 Neutral Self 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 positive enchantments of level 6 or lower from the caster. +3183 Nullify All Magic Self 7 Neutral Self 250 Dispel 300 -1 Life Magic 300 Dispels all enchantments of level 6 or lower from the caster. +3184 Eradicate Creature Magic Other 7 Neutral Other 250 Dispel 350 -1 Creature Enchantment 280 Dispels 3-6 negative Creature Magic enchantments of level 7 or lower from the target. +3185 Eradicate Creature Magic Self 7 Neutral Self 250 Dispel 350 -1 Creature Enchantment 280 Dispels 3-6 negative Creature Magic enchantments of level 7 or lower from the caster. +3186 Nullify Creature Magic Other 7 Neutral Other 250 Dispel 300 -1 Creature Enchantment 300 Dispels 2-6 positive Creature Magic enchantments of level 6 or lower from the target. +3187 Nullify Creature Magic Self 7 Neutral Self 250 Dispel 300 -1 Creature Enchantment 300 Dispels 2-6 positive Creature Magic enchantments of level 6 or lower from the caster. +3188 Nullify Creature Magic Other 7 Neutral Other 250 Dispel 300 -1 Creature Enchantment 300 Dispels 2-6 Creature Magic enchantments of level 6 or lower from the target. +3189 Nullify Creature Magic Self 7 Neutral Self 250 Dispel 300 -1 Creature Enchantment 300 Dispels 2-6 Creature Magic enchantments of level 6 or lower from the caster. +3190 Eradicate Item Magic 7 Neutral Item 250 Dispel 350 -1 Item Enchantment 280 Dispels 3-6 negative Item Magic enchantments of level 7 or lower from the target. +3191 Nullify Item Magic 7 Neutral Item 250 Dispel 300 -1 Item Enchantment 300 Dispels 2-6 positive Item Magic enchantments of level 6 or lower from the target. +3192 Nullify Item Magic 7 Neutral Item 250 Dispel 300 -1 Item Enchantment 300 Dispels 2-6 Item Magic enchantments of level 6 or lower from the target. +3193 Eradicate Life Magic Other 7 Neutral Other 250 Dispel 350 -1 Life Magic 280 Dispels 3-6 negative Life Magic enchantments of level 7 or lower from the target. +3194 Eradicate Life Magic Self 7 Neutral Self 250 Dispel 350 -1 Life Magic 280 Dispels 3-6 negative Life Magic enchantments of level 7 or lower from the caster. +3195 Nullify Life Magic Other 7 Neutral Other 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 positive Life Magic enchantments of level 6 or lower from the target. +3196 Nullify Life Magic Self 7 Neutral Self 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 positive Life Magic enchantments of level 6 or lower from the caster. +3197 Nullify Life Magic Other 7 Neutral Other 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 Life Magic enchantments of level 6 or lower from the target. +3198 Nullify Life Magic Self 7 Neutral Self 250 Dispel 300 -1 Life Magic 300 Dispels 2-6 Life Magic enchantments of level 6 or lower from the caster. +3199 Minor Hermetic Link 1 Buff Item 425 ExtraManaConversionBonus 10 1800 Item Enchantment 10 Increases a magic casting implement's mana conversion bonus by 10%. +3200 Major Hermetic Link 1 Buff Item 425 ExtraManaConversionBonus 20 1800 Item Enchantment 10 Increases a magic casting implement's mana conversion bonus by 20%. +3201 Feeble Hermetic Link 1 Buff Item 425 ExtraManaConversionBonus 5 1800 Item Enchantment 10 Increases a magic casting implement's mana conversion bonus by 5%. +3202 Moderate Hermetic Link 1 Buff Item 425 ExtraManaConversionBonus 15 1800 Item Enchantment 10 Increases a magic casting implement's mana conversion bonus by 15%. +3203 Eradicate All Magic Other 7 Neutral Other 250 Dispel 350 -1 Life Magic 280 Dispels all negative enchantments of level 7 or lower from the target. This spell is not affected by mana conversion. +3204 Blazing Heart 2 Buff Other 279 LifeGiverRaising 50 14400 Life Magic 70 Increases maximum health by 50 points for 4 hours. +3205 Good Eating 1 Buff Other 351 ExtraMeleeDefenseSkillRaising 10 14400 Creature Enchantment 10 Increases the target's Melee Defense skill by 10 points for 4 hours. Additional spells can be layered over this (excluding other cantrips). +3206 Enliven 3 Buff Other 283 ManaGiverRaising 100 14400 Life Magic 70 Increases maximum mana by 100 points for 4 hours. +3207 Ore Fire 1 Buff Other 299 MagicDefenseShelterRaising 10 14400 Creature Enchantment 10 Increases the target's Magic Defense skill by 10 points for 4 hours. Additional spells can be layered over this (excluding other cantrips). +3208 Innervate 5 Buff Other 281 StaminaGiverRaising 200 14400 Life Magic 70 Increases maximum stamina by 200 points for 4 hours. +3209 Refreshment 1 Buff Other 297 MissileDefenseShelterRaising 10 14400 Creature Enchantment 10 Increases the target's Missile Defense skill by 10 points for 4 hours. Additional spells can be layered over this (excluding other cantrips). +3210 Agitate 7 Debuff Other 2 StrengthLowering 350 45 Creature Enchantment 70 The Shadow Child enrages the target. reducing the target's Strength by 15%. +3211 Annoyance 7 Debuff Other 4 EnduranceLowering 350 45 Creature Enchantment 70 The Shadow Child exasperates the target. reducing the target's Endurance by 15% . +3212 Guilt Trip 7 Debuff Other 8 CoordinationLowering 350 45 Creature Enchantment 70 The sad tale of the Shadow Child decreases the target's Coordination by 15%. +3213 Heart Ache 7 Debuff Other 12 SelfLowering 350 45 Creature Enchantment 70 The sad tale of the Shadow Child decreases the target's Self by 15%. +3214 Sorrow 7 Debuff Other 10 FocusLowering 350 45 Creature Enchantment 70 The sad tale of the Shadow Child decreases the target's Focus by 15%. +3215 Underfoot 7 Debuff Other 6 QuicknessLowering 350 45 Creature Enchantment 70 The Shadow Child gets in the target's way. reducing the target's Quickness by 15%. +3216 Transport to the Forbidden Catacombs 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3217 Cascade 1 Buff Other 331 ExtraBowSkillRaising 12 780 Creature Enchantment 30 Increases the target's Missile Weapons skill by 12 points. +3218 Greater Cascade 1 Buff Other 331 ExtraBowSkillRaising 15 780 Creature Enchantment 30 Increases the target's Missile Weapons skill by 15 points. +3219 Lesser Cascade 1 Buff Other 331 ExtraBowSkillRaising 8 780 Creature Enchantment 30 Increases the target's Missile Weapons skill by 8 points. +3220 Cascade 1 Buff Other 331 ExtraBowSkillRaising 12 780 Creature Enchantment 30 Increases the target's Missile Weapons skill by 12 points. +3221 Greater Cascade 1 Buff Other 331 ExtraBowSkillRaising 15 780 Creature Enchantment 30 Increases the target's Missile Weapons skill by 15 points. +3222 Lesser Cascade 1 Buff Other 331 ExtraBowSkillRaising 8 780 Creature Enchantment 30 Increases the target's Missile Weapons skill by 8 points. +3223 Cascade 1 Buff Other 363 ExtraManaConversionSkillRaising 12 780 Creature Enchantment 30 Increases the target's Mana Conversion skill by 12 points. +3224 Greater Cascade 1 Buff Other 363 ExtraManaConversionSkillRaising 15 780 Creature Enchantment 30 Increases the target's Mana Conversion skill by 15 points. +3225 Lesser Cascade 1 Buff Other 363 ExtraManaConversionSkillRaising 8 780 Creature Enchantment 30 Increases the target's Mana Conversion skill by 8 points. +3226 Cascade 1 Buff Other 371 ExtraSwordSkillRaising 12 780 Creature Enchantment 30 Increases the target's Heavy Weapons skill by 12 points. +3227 Greater Cascade 1 Buff Other 371 ExtraSwordSkillRaising 15 780 Creature Enchantment 30 Increases the target's Heavy Weapons skill by 15 points. +3228 Lesser Cascade 1 Buff Other 371 ExtraSwordSkillRaising 8 780 Creature Enchantment 30 Increases the target's Heavy Weapons skill by 8 points. +3229 Cascade 1 Buff Other 311 CascadeAxeRaising 12 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 12 points. +3230 Greater Cascade 1 Buff Other 311 CascadeAxeRaising 15 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. +3231 Lesser Cascade 1 Buff Other 311 CascadeAxeRaising 8 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 8 points. +3232 Cascade 1 Buff Other 331 ExtraBowSkillRaising 12 780 Creature Enchantment 30 Increases the target's Missile Weapons skill by 12 points. +3233 Greater Cascade 1 Buff Other 331 ExtraBowSkillRaising 15 780 Creature Enchantment 30 Increases the target's Missile Weapons skill by 15 points. +3234 Lesser Cascade 1 Buff Other 331 ExtraBowSkillRaising 8 780 Creature Enchantment 30 Increases the target's Missile Weapons skill by 8 points. +3235 Dark Power 1 Buff Other 417 SelfIncrease2 2 10800 Creature Enchantment 10 A dark power suffuses your being. increasing your Self by 2. +3236 Restorative Draught 5 Buff Other 79 HealthRaising 200 -1 Life Magic 1000 Restores 60-80 points of the target's Health. +3237 Fanaticism 1 Buff Other 426 WarMysticRaising2 2 10800 Creature Enchantment 10 A fervent need for destruction increases your War Magic skill by 2. +3238 Portal to Nanner Island 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to Nanner Island. +3239 Insight of the Khe 5 Buff Other 11 SelfRaising 245 60 Creature Enchantment 60 This spell enhances the caster's understanding of the mystical world. Self is raised by 32. +3240 Wisdom of the Khe 5 Buff Other 9 FocusRaising 245 60 Creature Enchantment 60 This spell enhances the caster's knowledge and ability to manipulate the mystical world. Focus is increased by 32. +3241 Flame Burst 7 Neutral Other 226 FireRing 325 -1 War Magic 80 A burst of superheated air blasts outward from the caster. +3242 Weave of Chorizite 6 Buff Other 428 MagicDefenseShelterRaising2 265 60 Creature Enchantment 10 Veins of chorizite serve to raise your magic defense. Magic Defense is raised by 2 points when this item is wielded. This is in addition to any spells and cantrips. +3243 Consecration 1 Buff Other 431 ItemMysticRaising2 2 10800 Creature Enchantment 10 The innate magic of the Homunculus enhances your Item Enchantment skill by 2. +3244 Divine Manipulation 1 Buff Other 430 CreatureMysticRaising2 2 10800 Creature Enchantment 10 The power to show creatures the way surges through you. Increases your Creature Enchantment skill by 2. +3245 Sacrosanct Touch 1 Buff Other 429 ExtraLifeMagicSkillRaising2 2 10800 Creature Enchantment 10 You feel urged to bless the worthy and punish the unworthy. Increases your Life Magic skill by 2. +3246 Adja's Benefaction 2 Buff Other 257 HealthRestoring 50 60 Life Magic 60 Adja bestows her blessing upon you. increasing your Health Regeneration Rate by 50%. This effect can be layered with normal spell effects. +3247 Adja's Favor 2 Buff Other 407 StaminaRestoring 50 60 Life Magic 60 Adja bestows her favor upon you. increasing your Stamina Regeneration Rate by 50%. This effect can be layered with normal spell effects. +3248 Adja's Grace 2 Buff Other 259 ManaRestoring 50 60 Life Magic 60 Adja bestows her grace upon you. increasing your Mana Regeneration Rate by 50%. This effect can be layered with normal spell effects. +3249 Ghostly Chorus 8 Buff Other 97 ManaAccelerating 1000 3600 Life Magic 60 A vision of a ghostly chorus sings to you. lifting your spirits and empowering you. Your rate of Mana Renewal increases by 200% for one hour. +3250 Major Spirit Thirst 1 Buff Item 323 MaxDamageRaising 3 780 Item Enchantment 10 Increases the elemental damage bonus of an elemental magic caster by 3%. Additional spells can be layered over this. +3251 Minor Spirit Thirst 1 Buff Item 323 MaxDamageRaising 1 780 Item Enchantment 10 Increases the elemental damage bonus of an elemental magic caster by 1%. Additional spells can be layered over this. +3252 Spirit Thirst 1 Buff Item 323 MaxDamageRaising 2 780 Item Enchantment 10 Increases a caster's damage mod by 0.02 points. Additional spells can be layered over this. +3253 Aura of Spirit Drinker Self I 1 Buff Self 695 SpellDamageRaising 1 1800 Item Enchantment 10 Increases the elemental damage bonus of an elemental magic caster by 1%. +3254 Aura of Spirit Drinker Self II 2 Buff Self 695 SpellDamageRaising 50 1800 Item Enchantment 20 Increases the elemental damage bonus of an elemental magic caster by 2%. +3255 Aura of Spirit Drinker Self III 3 Buff Self 695 SpellDamageRaising 100 1800 Item Enchantment 30 Increases the elemental damage bonus of an elemental magic caster by 3%. +3256 Aura of Spirit Drinker Self IV 4 Buff Self 695 SpellDamageRaising 150 1800 Item Enchantment 40 Increases the elemental damage bonus of an elemental magic caster by 4%. +3257 Aura of Spirit Drinker Self V 5 Buff Self 695 SpellDamageRaising 200 1800 Item Enchantment 50 Increases the elemental damage bonus of an elemental magic caster by 5%. +3258 Aura of Spirit Drinker Self VI 6 Buff Self 695 SpellDamageRaising 250 2700 Item Enchantment 60 Increases the elemental damage bonus of an elemental magic caster by 6%. +3259 Aura of Infected Spirit Caress 7 Buff Item 695 SpellDamageRaising 300 3600 Item Enchantment 70 Increases the elemental damage bonus of an elemental magic caster by 7%. +3260 Spirit Loather I 1 Debuff Item 155 DamageLowering 25 60 Item Enchantment 10 Decreases the elemental damage bonus of an elemental magic caster by 1%. +3261 Spirit Loather II 2 Debuff Item 155 DamageLowering 75 90 Item Enchantment 20 Decreases the elemental damage bonus of an elemental magic caster by 2%. +3262 Spirit Loather III 3 Debuff Item 155 DamageLowering 125 120 Item Enchantment 30 Decreases the elemental damage bonus of an elemental magic caster by 3%. +3263 Spirit Loather IV 4 Debuff Item 155 DamageLowering 175 150 Item Enchantment 40 Decreases the elemental damage bonus of an elemental magic caster by 4%. +3264 Spirit Loather V 5 Debuff Item 155 DamageLowering 225 180 Item Enchantment 60 Decreases the elemental damage bonus of an elemental magic caster by 5%. +3265 Spirit Loather VI 6 Debuff Item 155 DamageLowering 275 210 Item Enchantment 70 Decreases the elemental damage bonus of an elemental magic caster by 6%. +3266 Spirit Pacification 7 Debuff Item 155 DamageLowering 325 240 Item Enchantment 70 Decreases the elemental damage bonus of an elemental magic caster by 7%. +3267 Bit Between Teeth 6 Debuff Other 12 SelfLowering 285 300 Creature Enchantment 10 This spell decreases the target's Self by 75%. +3268 Biting Bonds 6 Buff Other 410 HealthDivide 285 300 Creature Enchantment 10 Lowers recipient's health by 40% for five minutes. +3269 Under The Lash 6 Debuff Other 116 ArmorLowering 285 300 Life Magic 70 Decreases the target's armor by 250 points for five minutes. +3270 Hezhit's Safety 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3271 Hezhit's Safety 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3272 Hezhit's Safety 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3273 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3274 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3275 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3276 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3277 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3278 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3279 Entrance to Hizk Ri's Temple 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3280 Return to the Corridor 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3281 Hizk Ri's Test 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3282 Hizk Ri's Test 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3283 Hizk Ri's Test 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3284 Consort Hezhit 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3285 Attendant Jrvik 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3286 Well of Tears 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3287 Well of Tears 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3288 Well of Tears 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3289 Patriarch Zixki 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3290 Jrvik's Safety 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3291 Jrvik's Safety 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3292 Jrvik's Safety 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3293 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3294 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3295 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3296 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3297 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3298 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3299 Zixk's Safety 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3300 Zixk's Safety 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3301 Zixk's Safety 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3302 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3303 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3304 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3305 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3306 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3307 Prison 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3308 Flange Aegis 6 Buff Other 103 BludgeonProtection 295 3600 Life Magic 60 Reduces damage the target takes from Bludgeoning by 62%. +3309 Inferior Flange Aegis 5 Buff Other 103 BludgeonProtection 245 3600 Life Magic 40 Reduces damage the target takes from Bludgeoning by 52%. +3310 Inferior Lance Aegis 5 Buff Other 111 PierceProtection 245 3600 Life Magic 40 Reduces damage the target takes from Piercing by 52%. +3311 Lance Aegis 6 Buff Other 111 PierceProtection 295 3600 Life Magic 60 Reduces damage the target takes from Piercing by 62%. +3312 Lesser Flange Aegis 4 Buff Other 103 BludgeonProtection 195 3600 Life Magic 50 Reduces damage the target takes from Bludgeoning by 45%. +3313 Lesser Lance Aegis 4 Buff Other 111 PierceProtection 195 3600 Life Magic 50 Reduces damage the target takes from Piercing by 45%. +3314 Chained to the Wall 6 Debuff Other 70 JumpLowering 285 300 Creature Enchantment 70 Decreases the target's Jump skill by 50% for five minutes. +3315 The Sewer 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3316 The Sewer 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3317 The Sewer 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3318 Hizk Ri's Crypt 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3319 Portal to Izji Qo's Temple 8 Utility Self 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3320 Lesser Corrosive Ward 4 Buff Other 101 AcidProtection 150 1800 Life Magic 40 Reduces damage all fellowship members take from acid by 43%. +3321 Corrosive Ward 5 Buff Other 101 AcidProtection 200 1800 Life Magic 50 Reduces damage all fellowship members take from acid by 50%. +3322 Greater Corrosive Ward 6 Buff Other 101 AcidProtection 250 2700 Life Magic 60 Reduces damage all fellowship members take from acid by 60%. +3323 Superior Corrosive Ward 7 Buff Other 101 AcidProtection 300 3600 Life Magic 70 Reduces damage all fellowship members take from acid by 65%. +3324 Lesser Scythe Ward 4 Buff Other 113 SlashProtection 150 1800 Life Magic 40 Reduces damage all fellowship members take from Slashing by 43%. +3325 Scythe Ward 5 Buff Other 113 SlashProtection 200 1800 Life Magic 50 Reduces damage all fellowship members take from Slashing by 50%. +3326 Greater Scythe Ward 6 Buff Other 113 SlashProtection 250 2700 Life Magic 60 Reduces damage all fellowship members take from Slashing by 60%. +3327 Superior Scythe Ward 7 Buff Other 113 SlashProtection 300 3600 Life Magic 70 Reduces damage all fellowship members take from Slashing by 65%. +3328 Lesser Flange Ward 4 Buff Other 103 BludgeonProtection 150 1800 Life Magic 40 Reduces damage all fellowship members take from Bludgeoning by 43%. +3329 Flange Ward 5 Buff Other 103 BludgeonProtection 200 1800 Life Magic 50 Reduces damage all fellowship members take from Bludgeoning by 50%. +3330 Greater Flange Ward 6 Buff Other 103 BludgeonProtection 250 2700 Life Magic 60 Reduces damage all fellowship members take from Bludgeoning by 60%. +3331 Superior Flange Ward 7 Buff Other 103 BludgeonProtection 300 3600 Life Magic 70 Reduces damage all fellowship members from Bludgeoning by 65%. +3332 Lesser Frore Ward 4 Buff Other 105 ColdProtection 150 1800 Life Magic 40 Reduces damage all fellowship members take from Cold by 43%. +3333 Frore Ward 5 Buff Other 105 ColdProtection 200 1800 Life Magic 50 Reduces damage all fellowship members take from Cold by 50%. +3334 Greater Frore Ward 6 Buff Other 105 ColdProtection 250 2700 Life Magic 60 Reduces damage all fellowship members take from Cold by 60%. +3335 Superior Frore Ward 7 Buff Other 105 ColdProtection 300 3600 Life Magic 70 Reduces damage all fellowship members take from Cold by 65%. +3336 Lesser Inferno Ward 4 Buff Other 109 FireProtection 150 1800 Life Magic 40 Reduces damage all fellowship members take from fire by 43%. +3337 Inferno Ward 5 Buff Other 109 FireProtection 200 1800 Life Magic 50 Reduces damage all fellowship members take from fire by 50%. +3338 Greater Inferno Ward 6 Buff Other 109 FireProtection 250 2700 Life Magic 60 Reduces damage all fellowship members take from fire by 60%. +3339 Superior Inferno Ward 7 Buff Other 109 FireProtection 300 3600 Life Magic 70 Reduces damage all fellowship members take from fire by 65%. +3340 Lesser Voltaic Ward 4 Buff Other 107 ElectricProtection 150 1800 Life Magic 40 Reduces damage all fellowship members take from Lightning by 43%. +3341 Voltaic Ward 5 Buff Other 107 ElectricProtection 200 1800 Life Magic 50 Reduces damage all fellowship members take from Lightning by 50%. +3342 Greater Voltaic Ward 6 Buff Other 107 ElectricProtection 250 2700 Life Magic 60 Reduces damage all fellowship members take from Lightning by 60%. +3343 Superior Voltaic Ward 7 Buff Other 107 ElectricProtection 300 3600 Life Magic 70 Reduces damage all fellowship members take from Lightning by 65%. +3344 Lesser Lance Ward 4 Buff Other 111 PierceProtection 150 1800 Life Magic 40 Reduces damage all fellowship members take from Piercing by 43%. +3345 Lance Ward 5 Buff Other 111 PierceProtection 200 1800 Life Magic 50 Reduces damage all fellowship members take from Piercing by 50%. +3346 Greater Lance Ward 6 Buff Other 111 PierceProtection 250 2700 Life Magic 60 Reduces damage all fellowship members take from Piercing by 60%. +3347 Superior Lance Ward 7 Buff Other 111 PierceProtection 300 3600 Life Magic 70 Reduces damage all fellowship members take from Piercing by 65%. +3348 Lesser Warden of the Clutch 4 Buff Other 39 MissileDefenseRaising 175 1800 Creature Enchantment 40 Enhances the Missile Defense of all Fellowship members by 25 points for 30 minutes. +3349 Inferior Warden of the Clutch 5 Buff Other 39 MissileDefenseRaising 225 1800 Creature Enchantment 50 Enhances the Missile Defense of all Fellowship members by 30 points for 30 minutes. +3350 Warden of the Clutch 6 Buff Other 39 MissileDefenseRaising 275 2700 Creature Enchantment 60 Enhances the Missile Defense of all Fellowship members by 35 points for 45 minutes. +3351 Potent Warden of the Clutch 7 Buff Other 39 MissileDefenseRaising 325 3600 Creature Enchantment 70 Enhances the Missile Defense of all Fellowship members by 40 points for 60 minutes. +3352 Lesser Guardian of the Clutch 4 Buff Other 37 MeleeDefenseRaising 175 1800 Creature Enchantment 40 Enhances the Melee Defense of all Fellowship members by 25 points for 30 minutes. +3353 Inferior Guardian of the Clutch 5 Buff Other 37 MeleeDefenseRaising 225 1800 Creature Enchantment 50 Enhances the Melee Defense of all Fellowship members by 30 points for 30 minutes. +3354 Guardian of the Clutch 6 Buff Other 37 MeleeDefenseRaising 275 2700 Creature Enchantment 60 Enhances the Melee Defense of all Fellowship members by 35 points for 45 minutes. +3355 Potent Guardian of the Clutch 7 Buff Other 37 MeleeDefenseRaising 325 3600 Creature Enchantment 70 Enhances the Melee Defense of all Fellowship members by 40 points for 60 minutes. +3356 Lesser Sanctifier of the Clutch 4 Buff Other 41 MagicDefenseRaising 175 1800 Creature Enchantment 40 Enhances the Magic Defense of all Fellowship members by 25 points for 30 minutes. +3357 Inferior Sanctifier of the Clutch 5 Buff Other 41 MagicDefenseRaising 225 1800 Creature Enchantment 50 Enhances the Magic Defense of all Fellowship members by 30 points for 30 minutes. +3358 Sanctifier of the Clutch 6 Buff Other 41 MagicDefenseRaising 275 2700 Creature Enchantment 60 Enhances the Magic Defense of all Fellowship members by 35 points for 45 minutes. +3359 Potent Sanctifier of the Clutch 7 Buff Other 41 MagicDefenseRaising 325 3600 Creature Enchantment 70 Enhances the Magic Defense of all Fellowship members by 40 points for 60 minutes. +3360 Entrance to the Burun Shrine 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3361 The Art of Destruction 7 Buff Other 49 WarMagicRaising 351 780 Creature Enchantment 10 Increases the target's War Magic skill by 11%. +3362 Blessing of the Horn 1 Buff Other 299 MagicDefenseShelterRaising 8 780 Creature Enchantment 10 Increases the target's Magic Defense skill by 8 points. +3363 Blessing of the Scale 1 Buff Other 351 ExtraMeleeDefenseSkillRaising 8 780 Creature Enchantment 10 Increases the target's Melee Defense skill by 8 points. +3364 Blessing of the Wing 1 Buff Other 297 MissileDefenseShelterRaising 8 780 Creature Enchantment 10 Increases the target's Missile Defense skill by 8 points. +3365 Gift of Enhancement 7 Buff Other 43 CreatureEnchantmentRaising 351 780 Creature Enchantment 10 Increases the target's Creature Enchantement by 11%. +3366 The Heart's Touch 7 Buff Other 47 LifeMagicRaising 351 780 Creature Enchantment 10 Increases the target's Life Magic skill by 11%. +3367 Leaping Legs 7 Buff Other 69 JumpRaising 351 780 Creature Enchantment 10 Increases the target's Jump skill by 11%. +3368 Mage's Understanding 7 Buff Other 51 ManaConversionRaising 351 780 Creature Enchantment 10 Increases the target's Mana Conversion skill by 11%. +3369 On the Run 7 Buff Other 77 RunRaising 351 780 Creature Enchantment 10 Increases the target's Run skill by 11%. +3370 Power of Enchantment 7 Buff Other 45 ItemEnchantmentRaising 351 780 Creature Enchantment 10 Increases the target's Item Enchantment skill by 11%. +3371 Greater Life Giver 1 Buff Other 279 LifeGiverRaising 25 510 Life Magic 70 Increases maximum health by 25 points. +3372 Debilitating Spore 6 Debuff Other 82 StaminaLowering 275 -1 Life Magic 60 Drains 5000 points of the target's stamina. +3373 Diseased Air 6 Debuff Other 84 ManaLowering 275 -1 Life Magic 60 Drains 5000 points of the target's Mana. +3374 Kivik Lir's Scorn 8 Debuff Other 80 HealthLowering 600 -1 Life Magic 10 Drains the target of 99% of their current health. +3375 Fungal Bloom 8 Buff Other 410 HealthDivide 500 15 Creature Enchantment 10 Lowers the total health of the target by 50%. +3376 Lesser Vision Beyond the Grave 1 Buff Other 433 SelfRaising2 1 3600 Creature Enchantment 10 Enhances your understanding of the flux between worlds. +3377 Minor Vision Beyond the Grave 1 Buff Other 433 SelfRaising2 2 3600 Creature Enchantment 10 Enhances your understanding of the flux between worlds. +3378 Vision Beyond the Grave 1 Buff Other 433 SelfRaising2 3 3600 Creature Enchantment 10 Enhances your understanding of the flux between worlds. +3379 Vitae 1 Neutral Other 204 Vitae 30 -1 Creature Enchantment 3 Death sucks +3380 Vitae 1 Neutral Other 204 Vitae 30 -1 Creature Enchantment 3 Death sucks +3381 Debilitating Spore 7 Debuff Other 82 StaminaLowering 375 -1 Life Magic 60 Drains 5000 points of stamina from each member of a fellowship. +3382 Diseased Air 7 Debuff Other 84 ManaLowering 375 -1 Life Magic 60 Drains 5000 points of mana from each member of a fellowship. +3383 Fungal Bloom 8 Buff Other 410 HealthDivide 500 15 Creature Enchantment 10 Lowers total health of each fellowship member by 50%. +3384 Lesser Conjurant Chant 4 Buff Other 43 CreatureEnchantmentRaising 175 1800 Creature Enchantment 40 Enhances the Creature Enchantment skill of all Fellowship members by 25 points for 30 minutes. +3385 Conjurant Chant 5 Buff Other 43 CreatureEnchantmentRaising 225 1800 Creature Enchantment 50 Enhances the Creature Enchantment skill of all Fellowship members by 30 points for 30 minutes. +3386 Greater Conjurant Chant 6 Buff Other 43 CreatureEnchantmentRaising 275 2700 Creature Enchantment 60 Enhances the Creature Enchantment skill of all Fellowship members by 35 points for 45 minutes. +3387 Superior Conjurant Chant 7 Buff Other 43 CreatureEnchantmentRaising 325 3600 Creature Enchantment 70 Enhances the Creature Enchantment skill of all Fellowship members by 40 points for 60 minutes. +3388 Lesser Artificant Chant 4 Buff Other 45 ItemEnchantmentRaising 175 1800 Creature Enchantment 40 Enhances the Item Enchantment skill of all Fellowship members by 25 points for 30 minutes. +3389 Artificant Chant 5 Buff Other 45 ItemEnchantmentRaising 225 1800 Creature Enchantment 50 Enhances the Item Enchantment skill of all Fellowship members by 30 points for 30 minutes. +3390 Greater Artificant Chant 6 Buff Other 45 ItemEnchantmentRaising 275 2700 Creature Enchantment 60 Enhances the Item Enchantment skill of all Fellowship members by 35 points for 45 minutes. +3391 Superior Artificant Chant 7 Buff Other 45 ItemEnchantmentRaising 325 3600 Creature Enchantment 70 Enhances the Item Enchantment skill of all Fellowship members by 40 points for 60 minutes. +3392 Lesser Vitaeic Chant 4 Buff Other 47 LifeMagicRaising 175 1800 Creature Enchantment 40 Enhances the Life Magic skill of all Fellowship members by 25 points for 30 minutes. +3393 Vitaeic Chant 5 Buff Other 47 LifeMagicRaising 225 1800 Creature Enchantment 50 Enhances the Life Magic skill of all Fellowship members by 30 points for 30 minutes. +3394 Greater Vitaeic Chant 6 Buff Other 47 LifeMagicRaising 275 2700 Creature Enchantment 60 Enhances the Life Magic skill of all Fellowship members by 35 points for 45 minutes. +3395 Superior Vitaeic Chant 7 Buff Other 47 LifeMagicRaising 325 3600 Creature Enchantment 70 Enhances the Life Magic skill of all Fellowship members by 40 points for 60 minutes. +3396 Lesser Conveyic Chant 4 Buff Other 51 ManaConversionRaising 175 1800 Creature Enchantment 40 Enhances the Mana Conversion skill of all Fellowship members by 25 points for 30 minutes. +3397 Conveyic Chant 5 Buff Other 51 ManaConversionRaising 225 1800 Creature Enchantment 50 Enhances the Mana Conversion skill of all Fellowship members by 30 points for 30 minutes. +3398 Greater Conveyic Chant 6 Buff Other 51 ManaConversionRaising 275 2700 Creature Enchantment 60 Enhances the Mana Conversion skill of all Fellowship members by 35 points for 45 minutes. +3399 Superior Conveyic Chant 7 Buff Other 51 ManaConversionRaising 325 3600 Creature Enchantment 70 Enhances the Mana Conversion skill of all Fellowship members by 40 points for 60 minutes. +3400 Lesser Hieromantic Chant 4 Buff Other 49 WarMagicRaising 175 1800 Creature Enchantment 40 Enhances the War Magic skill of all Fellowship members by 25 points for 30 minutes. +3401 Hieromantic Chant 5 Buff Other 49 WarMagicRaising 225 1800 Creature Enchantment 50 Enhances the War Magic skill of all Fellowship members by 30 points for 30 minutes. +3402 Greater Hieromantic Chant 6 Buff Other 49 WarMagicRaising 275 2700 Creature Enchantment 60 Enhances the War Magic skill of all Fellowship members by 35 points for 45 minutes. +3403 Superior Hieromantic Chant 7 Buff Other 49 WarMagicRaising 325 3600 Creature Enchantment 70 Enhances the War Magic skill of all Fellowship members by 40 points for 60 minutes. +3404 Evil Thirst 1 Debuff Other 280 LifeTakerLowering 10 510 Life Magic 70 The barbs of the Manacale of Biting Pain dig into your wrist. reducing your health. +3405 Gift of the Fiazhat 1 Buff Other 432 ManaRaising2 15 3600 Creature Enchantment 10 The gift of the Fiazhat enhances your magical capacity. +3406 Kivik Lir's Boon 8 Buff Other 196 VisionRaising 500 900 Creature Enchantment 10 Kivik Lir has granted a boon upon you. student. You have 15 minutes to complete the remaining two trials. Do not fail. +3407 Lesser Evil Thirst 1 Debuff Other 280 LifeTakerLowering 5 510 Life Magic 70 The barbs of the Manacale of Biting Pain dig into your wrist. reducing your health. +3408 Lesser Gift of the Fiazhat 1 Buff Other 432 ManaRaising2 5 3600 Creature Enchantment 10 The gift of the Fiazhat enhances your magical capacity. +3409 Minor Evil Thirst 1 Debuff Other 280 LifeTakerLowering 8 510 Life Magic 70 The barbs of the Manacale of Biting Pain dig into your wrist. reducing your health. +3410 Minor Gift of the Fiazhat 1 Buff Other 432 ManaRaising2 10 3600 Creature Enchantment 10 The gift of the Fiazhat enhances your magical capacity. +3411 Portal spell to a Hidden Chamber 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the player to Elysa's treasure chamber. +3412 Halls of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3413 Lesser Arena of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3414 Arena of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3415 Greater Arena of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3416 Gallery of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3417 Gallery of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3418 Gallery of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3419 Crypt of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3420 Lesser Haven of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3421 Haven of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3422 Greater Haven of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3423 Trials of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3424 Triumph Against the Trials 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3425 Lyceum of Kivik Lir 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the specified destination. +3426 Greater Withering 8 Neutral Other 222 AcidRing 550 -1 War Magic 10 Shoots a ring of acidic clouds out from the caster. Each cloud does 100-220 points of acid damage to the first thing it hits. +3427 Lesser Withering 7 Neutral Other 222 AcidRing 350 -1 War Magic 10 Shoots a ring of acidic clouds out from the caster. Each cloud does 100-200 points of acid damage to the first thing it hits. +3428 Withering 8 Neutral Other 222 AcidRing 450 -1 War Magic 10 Shoots a ring of acidic clouds out from the caster. Each cloud does 100-210 points of acid damage to the first thing it hits. +3429 Kivik Lir's Venom 8 Debuff Other 116 ArmorLowering 9999 3600 Life Magic 10 The Spirit of Kivik Lir curses you for despoiling her tomb. Your natural armor is reduced by 200 points for 1 hour. +3430 Inferior Scourge Aegis 5 Buff Other 101 AcidProtection 245 3600 Life Magic 40 Reduces damage the target takes from Acid by 52%. +3431 Lesser Scourge Aegis 4 Buff Other 101 AcidProtection 195 3600 Life Magic 40 Reduces damage the target takes from Acid by 45%. +3432 Scourge Aegis 6 Buff Other 101 AcidProtection 295 3600 Life Magic 40 Reduces damage the target takes from Acid by 62%. +3433 Decay 8 Debuff Other 94 HealthDecelerating 9999 3600 Life Magic 70 The Spirit of Kivik Lir curses you for despoiling her tomb. You can no longer recover health naturally for 1 hour. +3434 Eyes Beyond the Mist 1 Buff Other 434 CreatureEnchantmentRaising2 3 3600 Creature Enchantment 10 Enhances your understanding of the flux between worlds. +3435 Greater Mucor Blight 8 Buff Other 424 SkillsDecrease 500 15 Creature Enchantment 10 An explosion of fungal spores swirls in the air. reducing all your skills by 50%. +3436 Lesser Eyes Beyond the Mist 1 Buff Other 434 CreatureEnchantmentRaising2 1 3600 Creature Enchantment 10 Enhances your understanding of the flux between worlds. +3437 Lesser Mucor Blight 8 Buff Other 424 SkillsDecrease 500 15 Creature Enchantment 10 An explosion of fungal spores swirls in the air. reducing all your skills by 10%. +3438 Minor Eyes Beyond the Mist 1 Buff Other 434 CreatureEnchantmentRaising2 2 3600 Creature Enchantment 10 Enhances your understanding of the flux between worlds. +3439 Mucor Blight 8 Buff Other 424 SkillsDecrease 500 15 Creature Enchantment 10 An explosion of fungal spores swirls in the air. reducing all your skills by 20%. +3440 Health of the Lugian 7 Heal Other 93 HealthAccelerating 311 7200 Life Magic 10 Increase target's natural healing rate by 125%. +3441 Insight of the Lugian 7 Buff Other 97 ManaAccelerating 351 7200 Life Magic 10 Increases the target's natural mana rate by 125%. +3442 Stamina of the Lugian 7 Buff Other 95 StaminaAccelerating 351 7200 Life Magic 10 Increases the rate at which the target regains Stamina by 125%. +3443 Blight of the Swamp 7 Buff Other 410 HealthDivide 327 60 Creature Enchantment 10 The vile nature of the swamp swells within your body. you are afflicted with all manner of ill feelings and suffer greatly. All secondary attributes are reduced by 40% for the duration of the spell. +3444 Justice of The Sleeping One 8 Neutral Other 250 Dispel 400 -1 Creature Enchantment 300 This spell attempts to rip all positive creature magic from a single target. +3445 The Sleeping One's Purge 8 Neutral Other 250 Dispel 400 -1 Life Magic 300 This spell attempts to rip all positive creature magic from a single target. +3446 Wrath of the Swamp 7 Buff Other 410 HealthDivide 327 60 Creature Enchantment 10 The vile nature of the swamp swells within you and each of your companions. you are all afflicted with ill feelings and suffer greatly. All secondary attributes are reduced by 40% for the duration of the spell. +3447 Asphyxiating Spore Cloud 7 Debuff Other 96 StaminaDecelerating 326 60 Life Magic 70 A small cloud of spores surrounds you and your fellowship choking the vigor from your bodies. Causes stamina loss over time. +3448 Mass Blood Affliction 7 Debuff Other 94 HealthDecelerating 326 60 Life Magic 70 Pain wracks your body and the bodies of your fellowship members as painful spores burrow into your flesh and enter your blood stream. Causes health damage over time. +3449 Mass Blood Disease 7 Debuff Other 94 HealthDecelerating 325 40 Life Magic 70 Pain wracks your body and the bodies of your fellowship members as painful spores burrow into your flesh and enter your blood stream. Causes a large amount of damage over time. +3450 Cloud of Mold Spores 7 Debuff Other 96 StaminaDecelerating 325 40 Life Magic 70 A small cloud of spores pours into your lungs choking the vigor from your body. Stamina degenerates over time. +3451 Concussive Belch 7 Neutral Other 118 BludgeoningMissile 350 -1 War Magic 5 The creature let's out a violent belch that is laden with magical force. It damages a single target for 120-220 of bludgeon Damage. +3452 Concussive Wail 7 Neutral Other 223 BludgeoningRing 350 -1 War Magic 10 The creature let's out a violent wail that is laden with magical force. It sends a ring of damage around it dealing 80 ?Çô 200 damage bludgeoning damage. +3453 Feelun Blight 7 Neutral Other 226 FireRing 350 -1 War Magic 10 The creature summons the power of the mighty feelun tree and coalesces it into a blast of fire against a single target. It damages a single target for 120 -220 of fire damage. +3454 Wrath of the Feelun 7 Neutral Other 121 FireMissile 350 -1 War Magic 5 The creature summons the power of the mighty feelun tree and coalesces it into a blast of fire against a single target. It damages a single target for 120 - 220 of fire damage. +3455 Koruu Cloud 7 Neutral Other 224 ColdRing 350 -1 War Magic 10 A cloud of spores launches out of the creature inflicting powerful damage to all around. The spells deals 80 ?Çô 200 damage of cold damage with each bolt. +3456 Koruu's Wrath 7 Neutral Other 119 ColdMissile 350 -1 War Magic 5 A cloud of spores launches out of the creature inflicting powerful damage to all around. 120 - 220 of cold damage. +3457 Mana Bolt 7 Projectile Other 118 BludgeoningMissile 350 -1 War Magic 5 The creature launch a blast of pure mana at a single target dealing 50 ?Çô 100 damage. +3458 Mana Purge 7 Neutral Other 223 BludgeoningRing 350 -1 War Magic 80 The creature launch a blast of pure mana in a ring around itself dealing 50 ?Çô 100 damage with each bolt. +3459 Mucor Cloud 7 Neutral Other 131 AcidBurst 350 -1 War Magic 10 A cloud of spores launches out of the creature inflicting powerful damage to all around. This speall deals 80 ?Çô 200 damage acid damage with each bolt. +3460 Dissolving Vortex 7 Neutral Other 131 AcidBurst 350 -1 War Magic 5 A cloud of spores launches out of the creature inflicting powerful damage to a target. Deals 120 - 220 acid damage to a single target. +3461 Batter Flesh 7 Buff Other 104 BludgeonVulnerability 350 60 Life Magic 10 Target's flesh is left open and vulnerable to bludgeoning attacks. Increases damage the target takes from Bludgeoning by 200%. +3462 Canker Flesh 7 Buff Other 102 AcidVulnerability 350 60 Life Magic 10 Target's flesh is left open and vulnerable to acid attacks. Increases damage the target takes from acid by 200%. +3463 Char Flesh 7 Buff Other 110 FireVulnerability 350 60 Life Magic 10 Target's flesh is left open and vulnerable to fire attacks. Increases damage the target takes from fire by 200%. +3464 Numb Flesh 7 Buff Other 106 ColdVulnerability 350 60 Life Magic 10 Target's flesh is left open and vulnerable to cold attacks. Increases damage the target takes from Cold by 200%. +3465 Blood Affliction 7 Debuff Other 94 HealthDecelerating 326 600 Life Magic 10 Pain wracks your body as painful spores burrow into your flesh and enter your blood stream. +3466 Blood Disease 7 Debuff Other 94 HealthDecelerating 325 40 Life Magic 10 Pain wracks your body as painful spores burrow into your flesh and enter your blood stream. +3467 Choking Spores 7 Debuff Other 96 StaminaDecelerating 326 600 Life Magic 10 A small cloud of spores pours into your lungs choking the vigor from your body. +3468 Mold Spores 7 Debuff Other 96 StaminaDecelerating 326 40 Life Magic 10 A small cloud of spores pours into your lungs choking the vigor from your body. +3469 Parasitic Affliction 7 Debuff Other 94 HealthDecelerating 326 300 Life Magic 10 A host of parasites burrow into your flesh and begin to devour you from within your own blood. The healthier you are. the more potent these parasites become. +3470 Lesser Endless Well 4 Buff Other 97 ManaAccelerating 150 1800 Life Magic 40 Enhances the understanding of the ebb and flow of mana. All fellowship members received a 55% increase to their nautral mana recovery rate. +3471 The Endless Well 5 Buff Other 97 ManaAccelerating 200 1800 Life Magic 50 Enhances the understanding of the ebb and flow of mana. All fellowship members received a 70% increase to their nautral mana recovery rate. +3472 Greater Endless Well 6 Buff Other 97 ManaAccelerating 250 2700 Life Magic 60 Enhances the understanding of the ebb and flow of mana. All fellowship members received a 85% increase to their nautral mana recovery rate. +3473 Superior Endless Well 7 Buff Other 97 ManaAccelerating 300 3600 Life Magic 70 Enhances the understanding of the ebb and flow of mana. All fellowship members received a 115% increase to their nautral mana recovery rate. +3474 Lesser Soothing Wind 4 Buff Other 93 HealthAccelerating 150 1800 Life Magic 40 Enhances the blood flow and aids in knitting wounds closed. All fellowship member receive a 55% increase to their natural health recovery rate. +3475 The Soothing Wind 5 Buff Other 93 HealthAccelerating 200 1800 Life Magic 50 Enhances the blood flow and aids in knitting wounds closed. All fellowship member receive a 70% increase to their natural health recovery rate. +3476 Greater Soothing Wind 6 Buff Other 93 HealthAccelerating 250 2700 Life Magic 60 Enhances the blood flow and aids in knitting wounds closed. All fellowship member receive a 85% increase to their natural health recovery rate. +3477 Superior Soothing Wind 7 Buff Other 93 HealthAccelerating 300 3600 Life Magic 70 Enhances the blood flow and aids in knitting wounds closed. All fellowship member receive a 115% increase to their natural health recovery rate. +3478 Lesser Golden Wind 4 Buff Other 95 StaminaAccelerating 150 1800 Life Magic 40 Enhances the intake of air and utilization of energy. All fellowship member receive a 55% increase to their natural stamina recovery rate. +3479 The Golden Wind 5 Buff Other 95 StaminaAccelerating 200 1800 Life Magic 50 Enhances the intake of air and utilization of energy. All fellowship member receive a 70% increase to their natural stamina recovery rate. +3480 Greater Golden Wind 6 Buff Other 95 StaminaAccelerating 250 2700 Life Magic 60 Enhances the intake of air and utilization of energy. All fellowship member receive a 85% increase to their natural stamina recovery rate. +3481 Superior Golden Wind 7 Buff Other 95 StaminaAccelerating 300 3600 Life Magic 70 Enhances the intake of air and utilization of energy. All fellowship member receive a 115% increase to their natural stamina recovery rate. +3482 Izji Qo's Antechamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3483 Izji Qo's Defenders 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3484 Izji Qo's Defenders 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3485 Izji Qo's Defenders 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3486 Into the Receiving Chamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3487 Into the Receiving Chamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3488 Into the Receiving Chamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3489 Into the Receiving Chamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3490 Into the Receiving Chamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3491 Into the Receiving Chamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3492 Into the Receiving Chamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3493 Into the Receiving Chamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3494 Izji Qo's Crypt 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3495 Izji Qo's Test 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3496 Inzji Qo's Test 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3497 Izji Qo's Test 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3498 Disintegrated 3 Neutral Item 215 LifestoneSending 125 -1 Item Enchantment 50 Transports the target to the last Lifestone he or she used. +3499 Arcanum Salvaging Self I 1 Buff Self 435 SalvagingRaising 1 1800 Creature Enchantment 15 Increases the caster's Salvaging skill by 10 points. +3500 Arcanum Salvaging Self II 2 Buff Self 435 SalvagingRaising 50 1800 Creature Enchantment 30 Increases the caster's Salvaging skill by 15 points. +3501 Arcanum Salvaging Self III 3 Buff Self 435 SalvagingRaising 100 1800 Creature Enchantment 40 Increases the caster's Salvaging skill by 20 points. +3502 Arcanum Salvaging Self IV 4 Buff Self 435 SalvagingRaising 150 1800 Creature Enchantment 50 Increases the caster's Salvaging skill by 25 points. +3503 Arcanum Salvaging Self V 5 Buff Self 435 SalvagingRaising 200 1800 Creature Enchantment 60 Increases the caster's Salvaging skill by 30 points. +3504 Arcanum Salvaging Self VI 6 Buff Self 435 SalvagingRaising 250 2700 Creature Enchantment 70 Increases the caster's Salvaging skill by 35 points. +3505 Arcanum Salvaging VII 7 Buff Other 435 SalvagingRaising 300 3600 Creature Enchantment 70 Increases the caster's Salvaging skill by 40 points. +3506 Arcanum Enlightenment I 1 Buff Other 435 SalvagingRaising 1 1800 Creature Enchantment 10 Increases the target's Salvaging skill by 10 points. +3507 Arcanum Enlightenment II 2 Buff Other 435 SalvagingRaising 50 1800 Creature Enchantment 20 Increases the target's Salvaging skill by 15 points. +3508 Arcanum Enlightenment III 3 Buff Other 435 SalvagingRaising 100 1800 Creature Enchantment 30 Increases the target's Salvaging skill by 20 points. +3509 Arcanum Enlightenment IV 4 Buff Other 435 SalvagingRaising 150 1800 Creature Enchantment 40 Increases the target's Salvaging skill by 25 points. +3510 Arcanum Enlightenment V 5 Buff Other 435 SalvagingRaising 200 1800 Creature Enchantment 50 Increases the target's Salvaging skill by 30 points. +3511 Arcanum Enlightenment VI 6 Buff Other 435 SalvagingRaising 250 2700 Creature Enchantment 60 Increases the target's Salvaging skill by 35 points. +3512 Arcanum Enlightenment VII 7 Buff Other 435 SalvagingRaising 300 3600 Creature Enchantment 70 Increases the target's Salvaging skill by 40 points. +3513 Nuhmudira's Wisdom I 1 Buff Other 435 SalvagingRaising 1 1800 Creature Enchantment 15 Increases the caster's Salvaging skill by 10 points. +3514 Nuhmudira's Wisdom II 2 Buff Other 435 SalvagingRaising 50 1800 Creature Enchantment 30 Increases the caster's Salvaging skill by 15 points. +3515 Nuhmudira's Wisdom III 3 Buff Other 435 SalvagingRaising 100 1800 Creature Enchantment 40 Increases the caster's Salvaging skill by 20 points. +3516 Nuhmudira's Wisdom IV 4 Buff Other 435 SalvagingRaising 150 1800 Creature Enchantment 50 Increases the caster's Salvaging skill by 25 points. +3517 Nuhmudira's Wisdom V 5 Buff Other 435 SalvagingRaising 200 1800 Creature Enchantment 60 Increases the caster's Salvaging skill by 30 points. +3518 Nuhmudira's Wisdom VI 6 Buff Other 435 SalvagingRaising 250 2700 Creature Enchantment 70 Increases the caster's Salvaging skill by 35 points. +3519 Nuhmudira's Wisdom VII 7 Buff Other 435 SalvagingRaising 300 3600 Creature Enchantment 70 Increases the caster's Salvaging skill by 40 points. +3520 Nuhmudira's Enlightenment I 1 Buff Other 435 SalvagingRaising 1 1800 Creature Enchantment 10 Increases the target's Salvaging skill by 10 points. +3521 Nuhmudira's Enlightenment II 2 Buff Other 435 SalvagingRaising 50 1800 Creature Enchantment 20 Increases the target's Salvaging skill by 15 points. +3522 Nuhmudira's Enlightenment III 3 Buff Other 435 SalvagingRaising 100 1800 Creature Enchantment 30 Increases the target's Salvaging skill by 20 points. +3523 Nuhmudira's Enlightenment IV 4 Buff Other 435 SalvagingRaising 150 1800 Creature Enchantment 40 Increases the target's Salvaging skill by 25 points. +3524 Nuhmudira's Enlightenment V 5 Buff Other 435 SalvagingRaising 200 1800 Creature Enchantment 50 Increases the target's Salvaging skill by 30 points. +3525 Nuhmudira Enlightenment VI 6 Buff Other 435 SalvagingRaising 250 2700 Creature Enchantment 60 Increases the target's Salvaging skill by 35 points. +3526 Nuhmudira's Enlightenment 7 Buff Other 435 SalvagingRaising 300 3600 Creature Enchantment 70 Increases the target's Salvaging skill by 40 points. +3527 Intoxication I 3 Debuff Other 8 CoordinationLowering 130 300 Creature Enchantment 50 Decreases the target's Coordination by 20 points. +3528 Intoxication II 5 Debuff Other 8 CoordinationLowering 230 300 Creature Enchantment 50 Decreases the target's Coordination by 30 points. +3529 Intoxication III 7 Debuff Other 8 CoordinationLowering 330 300 Creature Enchantment 50 Decreases the target's Coordination by 40 points. +3530 Ketnan's Eye 8 Buff Other 9 FocusRaising 420 1800 Creature Enchantment 50 Increases the target's Focus by 50 points. +3531 Bobo's Quickening 8 Buff Other 5 QuicknessRaising 420 1800 Creature Enchantment 70 Increases the caster's Quickness by 50 points. +3532 Bobo's Focused Blessing 3 Buff Other 9 FocusRaising 140 300 Creature Enchantment 50 Increases the target's Focus by 25 points. +3533 Brighteyes' Favor 8 Buff Other 7 CoordinationRaising 420 1800 Creature Enchantment 60 Increases the caster's Coordination by 50 points. +3534 Free Ride to the K'nath Lair 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3535 Free Ride to Sanamar 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3536 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3537 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3538 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3539 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3540 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3541 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3542 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3543 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3544 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3545 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3546 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3547 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3548 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3549 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3550 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3551 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3552 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3553 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3554 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3555 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3556 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3557 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3558 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3559 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3560 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3561 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3562 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3563 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3564 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3565 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3566 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3567 Fiun Flee 1 Buff Other 515 ExtraRunSkillRaisingFiun 15 780 Creature Enchantment 10 Increases the target's Run skill by 15 points. Additional spells can be layered over this. +3568 Fiun Efficiency 1 Buff Other 516 ExtraManaConversionSkillRaisingFiun 10 780 Creature Enchantment 10 Increases the target's Mana Conversion skill by 10 points. Additional spells can be layered over this. +3569 Mana Boost 7 Buff Other 412 ManaDivide 300 1800 Creature Enchantment 10 Raises mana by 10% for 30 minutes. +3570 Stamina Boost 7 Buff Other 411 StaminaDivide 300 1800 Creature Enchantment 10 Raises Stamina by 10% for 30 minutes. +3571 Health Boost 7 Heal Other 410 HealthDivide 300 1800 Creature Enchantment 10 Raises health by 10% for 30 minutes. +3572 Inner Brilliance 1 Buff Other 269 FocusIncrease 12 600 Creature Enchantment 10 Raises target's Focus by 12 points. Additional spells can be layered over this. +3573 Inner Might 1 Buff Other 261 StrengthIncrease 12 600 Creature Enchantment 10 Raises target's Strength by 12 points. Additional spells can be layered over this. +3574 Inner Will 1 Buff Other 271 SelfIncrease 12 600 Creature Enchantment 10 Raises target's Self by 12 points. Additional spells can be layered over this. +3575 Perfect Balance 1 Buff Other 267 CoordinationIncrease 12 600 Creature Enchantment 10 Raises target's Coordination by 12 points. Additional spells can be layered over this. +3576 Perfect Health 1 Buff Other 263 EnduranceIncrease 12 600 Creature Enchantment 10 Raises target's Endurance by 12 points. Additional spells can be layered over this. +3577 Perfect Speed 1 Buff Other 265 QuicknessIncrease 12 600 Creature Enchantment 10 Raises target's Quickness by 12 points. Additional spells can be layered over this. +3578 Depths of Liazk Itzi's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3579 Underpassage of Liazk Itzi's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3580 Center of Liazk Itzi's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3581 Secrets of Liazk Itzi's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3582 Eaten! 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3583 Regurgitated 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3584 Qin Xikit's Receiving Chamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3585 Eaten! 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3586 Qin Xikit's Antechamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3587 Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3588 Secrets of Qin Xikit's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3589 Qin Xikit's Tomb 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3590 Regurgitated! 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3591 Access to Xi Ru's Font 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3592 Qin Xikit's Island 7 Buff Item 203 PortalItemCreation 351 900 Item Enchantment 110 Summons a portal to Qin Xikit's Island. +3593 Eaten! 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3594 Underpassage of Hizk Ri's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3595 Underpassage of Hizk Ri's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3596 Center of Hizk Ri's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3597 Secrets of Hizk Ri's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3598 Regurgitated 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3599 Eaten! 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3600 Depths of Ixir Zi's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3601 Underpassage of Ixir Zi's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3602 Center of Ixir Zi's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3603 Secrets of Ixir Zi's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3604 Regurgitated 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3605 Portal to Cragstone 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3606 Eaten! 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3607 Depth's of Izji Qo's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3608 Underpassage of Izji Qo's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3609 Center of Izji Qo's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3610 Secrets of Izji Qo's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3611 Regurgitated 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3612 Eaten! 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3613 Regurgitated 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3614 Underpassage of Kivik Lir's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3615 Center of Kivik Lir's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3616 Secrets of Kivik Lir's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3617 Depths of Kivik Lir's Temple 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3618 Portal to Western Aphus Lassel 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3619 Portal to the Black Death Catacombs 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3620 Portal to Black Spawn Den 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3621 Portal to Black Spawn Den 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3622 Portal to Black Spawn Den 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3623 Portal to Center of the Obsidian Plains 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3624 Portal to Hills Citadel 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3625 Portal to the Kara Wetlands 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3626 Portal to the Marescent Plateau Base 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3627 Portal to Neydisa Castle 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3628 Portal to the Northern Landbridge 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3629 Portal to the Olthoi Horde Nest 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3630 Portal to the Olthoi North 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3631 Portal to the Renegade Fortress 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3632 Portal to Ridge Citadel 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3633 Portal to the Southern Landbridge 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3634 Portal To Valley of Death 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3635 Portal to Wilderness Citadel 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3636 Kern's Boon 1 Buff Other 438 CascadeAxeRaising2 2 600 Creature Enchantment 10 Increases the target's Light Weapons skill by 2 points. Additional spells can be layered over this. +3637 Ranger's Boon 1 Buff Other 439 ExtraBowSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 2 points. Additional spells can be layered over this. +3638 Ranger's Boon 1 Buff Other 439 ExtraBowSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 2 points. Additional spells can be layered over this. +3639 Ranger's Boon 1 Buff Other 439 ExtraBowSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 2 points. Additional spells can be layered over this. +3640 Enchanter's Boon 1 Buff Other 430 CreatureMysticRaising2 2 780 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 2 points. Additional spells can be layered over this. +3641 Hieromancer's Boon 1 Buff Other 426 WarMysticRaising2 2 780 Creature Enchantment 10 Increases the target's War Magic skill by 2 points. Additional spells can be layered over this. +3642 Fencer's Boon 1 Buff Other 442 CascadeDaggerRaising2 2 780 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 2 points. Additional spells can be layered over this. +3643 Life Giver's Boon 1 Buff Other 429 ExtraLifeMagicSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Life Magic skill by 2 points. Additional spells can be layered over this. +3644 Kern's Boon 1 Buff Other 438 CascadeAxeRaising2 2 600 Creature Enchantment 10 Increases the target's Light Weapons skill by 2 points. Additional spells can be layered over this. +3645 Kern's Boon 1 Buff Other 438 CascadeAxeRaising2 2 600 Creature Enchantment 10 Increases the target's Light Weapons skill by 2 points. Additional spells can be layered over this. +3646 Kern's Boon 1 Buff Other 438 CascadeAxeRaising2 2 600 Creature Enchantment 10 Increases the target's Light Weapons skill by 2 points. Additional spells can be layered over this. +3647 Kern's Boon 1 Buff Other 438 CascadeAxeRaising2 2 600 Creature Enchantment 10 Increases the target's Light Weapons skill by 2 points. Additional spells can be layered over this. +3648 Soldier's Boon 1 Buff Other 447 ExtraSwordSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 2 points. Additional spells can be layered over this. +3649 Aerfalle's Embrace 7 Buff Other 421 AttributesDecrease 325 120 Creature Enchantment 70 Decreases the attributes of all fellowship members by 45 points for 120 seconds. +3650 Aerfalle's Enforcement 7 Buff Other 424 SkillsDecrease 325 120 Creature Enchantment 70 Lowers all fellowship members skills by 45 points for 120 seconds. +3651 Aerfalle's Gaze 7 Buff Other 424 SkillsDecrease 325 120 Creature Enchantment 70 Lowers target's skills by 45 points for 120 seconds. +3652 Aerfalle's Touch 7 Buff Other 421 AttributesDecrease 325 120 Creature Enchantment 300 Decreases all of the target's attributes by 45 points for 120 seconds. +3653 Acid Blast III 3 Projectile Other 131 AcidBurst 125 -1 War Magic 15 Shoots three streams of acid toward the target. Each stream does 11-21 points of acid damage to the first thing it hits. +3654 Acid Volley I 3 Projectile Other 207 AcidVolley 125 -1 War Magic 5 Shoots three streams of acid toward the target. Each stream does 4-10 points of acid damage to the first thing it hits. +3655 Acid Volley II 4 Projectile Other 207 AcidVolley 175 -1 War Magic 20 Shoots three streams of acid toward the target. Each stream does 8-16 points of acid damage to the first thing it hits. +3656 Blade Blast III 3 Projectile Other 137 SlashingBurst 125 -1 War Magic 15 Shoots three whirling blades outward from the caster. Each blade does 11-21 points of slashing damage to the first thing it hits. +3657 Blade Blast IV 4 Projectile Other 137 SlashingBurst 175 -1 War Magic 20 Shoots three whirling blades outward from the caster. Each blade does 11-21 points of slashing damage to the first thing it hits. +3658 Blade Volley I 3 Projectile Other 213 BladeVolley 125 -1 War Magic 5 Shoots three whirling blades toward the target. Each blade does 4-10 points of Slashing damage to the first thing it hits. +3659 Blade Volley II 4 Projectile Other 213 BladeVolley 175 -1 War Magic 10 Shoots three whirling blades toward the target. Each blade does 8-16 points of Slashing damage to the first thing it hits. +3660 Bludgeoning Volley I 3 Projectile Other 208 BludgeoningVolley 125 -1 War Magic 15 Shoots three shock waves toward the target. Each wave does 4-10 points of bludgeoning damage to the first thing it hits. +3661 Bludgeoning Volley II 4 Projectile Other 208 BludgeoningVolley 175 -1 War Magic 20 Shoots three shock waves toward the target. Each wave does 8-16 points of bludgeoning damage to the first thing it hits. +3662 Flame Blast I 2 Projectile Other 135 FireBurst 75 -1 War Magic 40 Shoots three streams of acid toward the target. Each stream does 11-21 points of acid damage to the first thing it hits. +3663 Flame Volley III 3 Projectile Other 211 FlameVolley 125 -1 War Magic 15 Shoots three bolts of flame toward the target. Each bolt does 4-10 points of fire damage to the first thing it hits. +3664 Flame Volley IV 4 Projectile Other 211 FlameVolley 175 -1 War Magic 20 Shoots three bolts of flame toward the target. Each bolt does 8-16 points of fire damage to the first thing it hits. +3665 Force Blast III 3 Projectile Other 136 PiercingBurst 125 -1 War Magic 15 Shoots three force bolts outward from the caster. Each bolt does 11-21 points of piercing damage to the first thing it hits. +3666 Force Blast IV 4 Projectile Other 136 PiercingBurst 175 -1 War Magic 20 Shoots three force bolts outward from the caster. Each bolt does 11-21 points of piercing damage to the first thing it hits. +3667 Force Volley III 3 Projectile Other 212 ForceVolley 125 -1 War Magic 15 Shoots three bolts of force toward the target. Each bolt does 4-10 points of piercing damage to the first thing it hits. +3668 Force Volley IV 4 Projectile Other 212 ForceVolley 175 -1 War Magic 20 Shoots three bolts of force toward the target. Each bolt does 8-16 points of piercing damage to the first thing it hits. +3669 Frost Blast III 3 Projectile Other 133 ColdBurst 125 -1 War Magic 15 Shoots three bolts of frost outward from the caster. Each bolt does 11-21 points of cold damage to the first thing it hits. +3670 Frost Blast IV 4 Projectile Other 133 ColdBurst 175 -1 War Magic 20 Shoots three bolts of frost outward from the caster. Each bolt does 11-21 points of cold damage to the first thing it hits. +3671 Frost Volley III 3 Projectile Other 209 FrostVolley 125 -1 War Magic 15 Shoots three bolts of frost toward the target. Each bolt does 4-10 points of cold damage to the first thing it hits. +3672 Frost Volley IV 4 Projectile Other 209 FrostVolley 175 -1 War Magic 20 Shoots three bolts of frost toward the target. Each bolt does 8-16 points of cold damage to the first thing it hits. +3673 Lightning Blast III 3 Projectile Other 134 ElectricBurst 125 -1 War Magic 15 Shoots three bolts of lightning outward from the caster. Each bolt does 11-21 points of electric damage to the first thing it hits. +3674 Lightning Blast IV 4 Projectile Other 134 ElectricBurst 175 -1 War Magic 20 Shoots three bolts of lightning outward from the caster. Each bolt does 11-21 points of electric damage to the first thing it hits. +3675 Lightning Volley III 3 Projectile Other 210 LightningVolley 125 -1 War Magic 15 Shoots three bolts of lightning toward the target. Each bolt does 4-10 points of electric damage to the first thing it hits. +3676 Lightning Volley IV 4 Projectile Other 210 LightningVolley 175 -1 War Magic 20 Shoots three bolts of lightning toward the target. Each bolt does 8-16 points of electric damage to the first thing it hits. +3677 Shock Blast III 3 Projectile Other 132 BludgeoningBurst 125 -1 War Magic 15 Shoots three shock waves outward from the caster. Each wave does 11-21 points of damage to the first thing it hits. +3678 Shock Blast IV 4 Projectile Other 132 BludgeoningBurst 175 -1 War Magic 20 Shoots three shock waves outward from the caster. Each wave does 11-21 points of damage to the first thing it hits. +3679 Prodigal Acid Bane 8 Buff Item 449 AcidResistanceRaisingRare 600 900 Item Enchantment 70 Increases a shield or piece of armor's resistance to acid damage by 500%. Target yourself to cast this spell on all of your equipped armor. +3680 Prodigal Acid Protection 8 Buff Other 448 AcidProtectionRare 600 900 Life Magic 70 Reduces damage the caster takes from acid by 99.9%. +3681 Prodigal Alchemy Mastery 8 Buff Other 450 AlchemyRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Alchemy skill by 250 points. +3682 Prodigal Arcane Enlightenment 8 Buff Other 456 ArcaneLoreRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Arcane Lore skill by 250 points. +3683 Prodigal Armor Expertise 8 Buff Other 452 AppraiseArmorRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Armor Tinkering skill by 250 points. +3684 Prodigal Armor 8 Buff Other 457 ArmorRaisingRare 600 900 Life Magic 70 Increases the caster's natural armor by 1000 points. +3685 Prodigal Light Weapon Mastery 8 Buff Other 462 AxeRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Light Weapons skill by 250 points. +3686 Prodigal Blade Bane 8 Buff Item 503 SlashResistanceRaisingRare 600 900 Item Enchantment 70 Increases a shield or piece of armor's resistance to slashing damage by 500%. Target yourself to cast this spell on all of your equipped armor. +3687 Prodigal Blade Protection 8 Buff Other 502 SlashProtectionRare 600 900 Life Magic 70 Reduces damage the caster takes from Slashing by 99.9%. +3688 Prodigal Blood Drinker 8 Buff Item 473 DamageRaisingRare 600 900 Item Enchantment 70 Increases a weapon's damage value by 50 points. +3689 Prodigal Bludgeon Bane 8 Buff Item 464 BludgeonResistanceRaisingRare 600 900 Item Enchantment 70 Increases a shield or piece of armor's resistance to bludgeoning damage by 500%. Target yourself to cast this spell on all of your equipped armor. +3690 Prodigal Bludgeon Protection 8 Buff Other 463 BludgeonProtectionRare 600 900 Life Magic 70 Reduces damage the caster takes from Bludgeoning by 99.9%. +3691 Prodigal Missile Weapon Mastery 8 Buff Other 465 BowRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Missile Weapons skill by 250 points. +3692 Prodigal Cold Protection 8 Buff Other 466 ColdProtectionRare 600 900 Life Magic 70 Reduces damage the caster takes from Cold by 99.9%. +3693 Prodigal Cooking Mastery 8 Buff Other 468 CookingRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Cooking skill by 250 points. +3694 Prodigal Coordination 8 Buff Other 469 CoordinationRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Coordination by 250 points. +3695 Prodigal Creature Enchantment Mastery 8 Buff Other 470 CreatureEnchantmentRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Creature Enchantment skill by 250 points. +3696 Prodigal Missile Weapon Mastery 8 Buff Other 465 BowRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Missile Weapons skill by 250 points. +3697 Prodigal Finesse Weapon Mastery 8 Buff Other 472 DaggerRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Finesse Weapons skill by 250 points. +3698 Prodigal Deception Mastery 8 Buff Other 474 DeceptionRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Deception skill by 250 points. +3699 Prodigal Defender 8 Buff Item 475 DefenseModRaisingRare 600 900 Item Enchantment 70 Increases the Melee Defense skill modifier of a weapon or magic caster by 25%. +3700 Prodigal Endurance 8 Buff Other 478 EnduranceRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Endurance by 250 points. +3701 Prodigal Fealty 8 Buff Other 490 LoyaltyRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Loyalty skill by 250 points. +3702 Prodigal Fire Protection 8 Buff Other 479 FireProtectionRare 600 900 Life Magic 70 Reduces damage the caster takes from Fire by 99.9%. +3703 Prodigal Flame Bane 8 Buff Item 480 FireResistanceRaisingRare 600 900 Item Enchantment 70 Increases a shield or piece of armor's resistance to fire damage by 500%. Target yourself to cast this spell on all of your equipped armor. +3704 Prodigal Fletching Mastery 8 Buff Other 481 FletchingRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Fletching skill by 250 points. +3705 Prodigal Focus 8 Buff Other 482 FocusRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Focus by 250 points. +3706 Prodigal Frost Bane 8 Buff Item 467 ColdResistanceRaisingRare 600 900 Item Enchantment 70 Increases a shield or piece of armor's resistance to cold damage by 500%. Target yourself to cast this spell on all of your equipped armor. +3707 Prodigal Healing Mastery 8 Buff Other 483 HealingRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Healing skill by 250 points. +3708 Prodigal Heart Seeker 8 Buff Item 461 AttackModRaisingRare 600 900 Item Enchantment 70 Increases a weapon's Attack Skill modifier by 25%. +3709 Prodigal Hermetic Link 8 Debuff Item 451 AppraisalResistanceLoweringRare 600 900 Item Enchantment 70 Increases a magic casting implement's mana conversion bonus by 100%. +3710 Prodigal Impenetrability 8 Buff Item 458 ArmorValueRaisingRare 600 900 Item Enchantment 70 Improves a shield or piece of armor's armor value by 1000 points. Target yourself to cast this spell on all of your equipped armor. +3711 Prodigal Impregnability 8 Buff Other 496 MissileDefenseRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Missile Defense skill by 250 points. +3712 Prodigal Invulnerability 8 Buff Other 495 MeleeDefenseRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Melee Defense skill by 250 points. +3713 Prodigal Item Enchantment Mastery 8 Buff Other 485 ItemEnchantmentRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Item Enchantment skill by 250 points. +3714 Prodigal Item Expertise 8 Buff Other 453 AppraiseItemRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Item Tinkering skill by 250 points. +3715 Prodigal Jumping Mastery 8 Buff Other 486 JumpRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Jump skill by 250 points. +3716 Prodigal Leadership Mastery 8 Buff Other 487 LeadershipRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Leadership skill by 250 points. +3717 Prodigal Life Magic Mastery 8 Buff Other 488 LifeMagicRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Life Magic skill by 250 points. +3718 Prodigal Lightning Bane 8 Buff Item 477 ElectricResistanceRaisingRare 600 900 Item Enchantment 70 Increases a shield or piece of armor's resistance to electric damage by 500%. Target yourself to cast this spell on all of your equipped armor. +3719 Prodigal Lightning Protection 8 Buff Other 476 ElectricProtectionRare 600 900 Life Magic 70 Reduces damage the caster takes from Lightning by 99.9%. +3720 Prodigal Lockpick Mastery 8 Buff Other 489 LockpickRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Lockpick skill by 250 points. +3721 Prodigal Light Weapon Mastery 8 Buff Other 462 AxeRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Light Weapons skill by 250 points. +3722 Prodigal Magic Item Expertise 8 Buff Other 454 AppraiseMagicItemRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Magic Item Tinkering skill by 250 points. +3723 Prodigal Magic Resistance 8 Buff Other 492 MagicDefenseRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Magic Defense skill by 250 points. +3724 Prodigal Mana Conversion Mastery 8 Buff Other 494 ManaConversionRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Mana Conversion skill by 250 points. +3725 Prodigal Mana Renewal 8 Buff Other 493 ManaAcceleratingRare 600 900 Life Magic 70 Increases the caster's natural mana rate by 1000%. +3726 Prodigal Monster Attunement 8 Buff Other 459 AssessMonsterRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Assess Monster skill by 250 points. +3727 Prodigal Person Attunement 8 Buff Other 460 AssessPersonRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Assess Person skill by 250 points. +3728 Prodigal Piercing Bane 8 Buff Item 498 PierceResistanceRaisingRare 600 900 Item Enchantment 70 Increases a shield or piece of armor's resistance to piercing damage by 500%. Target yourself to cast this spell on all of your equipped armor. +3729 Prodigal Piercing Protection 8 Buff Other 497 PierceProtectionRare 600 900 Life Magic 70 Reduces damage the caster takes from Piercing by 99.9%. +3730 Prodigal Quickness 8 Buff Other 499 QuicknessRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Quickness by 250 points. +3731 Prodigal Regeneration 8 Buff Other 484 HealthAcceleratingRare 600 900 Life Magic 70 Increase caster's natural healing rate by 1000%. +3732 Prodigal Rejuvenation 8 Buff Other 506 StaminaAcceleratingRare 600 900 Life Magic 70 Increases the rate at which the caster regains Stamina by 1000%. +3733 Prodigal Willpower 8 Buff Other 501 SelfRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Self by 250 points. +3734 Prodigal Light Weapon Mastery 8 Buff Other 462 AxeRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Light Weapons skill by 250 points. +3735 Prodigal Spirit Drinker 8 Buff Item 473 DamageRaisingRare 600 900 Item Enchantment 70 Increases a caster's damage mod by 15%. +3736 Prodigal Sprint 8 Buff Other 500 RunRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Run skill by 250 points. +3737 Prodigal Light Weapon Mastery 8 Buff Other 462 AxeRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Light Weapons skill by 250 points. +3738 Prodigal Strength 8 Buff Other 507 StrengthRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Strength by 250 points. +3739 Prodigal Swift Killer 8 Buff Item 512 WeaponTimeRaisingRare 600 900 Item Enchantment 70 Improves a weapon's speed by 1000 points. +3740 Prodigal Heavy Weapon Mastery 8 Buff Other 508 SwordRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Heavy Weapons skill by 250 points. +3741 Prodigal Missile Weapon Mastery 8 Buff Other 465 BowRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Missile Weapons skill by 250 points. +3742 Prodigal Light Weapon Mastery 8 Buff Other 462 AxeRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Light Weapons skill by 250 points. +3743 Prodigal War Magic Mastery 8 Buff Other 511 WarMagicRaisingRare 600 900 Creature Enchantment 70 Increases the caster's War Magic skill by 250 points. +3744 Prodigal Weapon Expertise 8 Buff Other 455 AppraiseWeaponRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Weapon Tinkering skill by 250 points. +3745 Inferior Inferno Aegis 5 Buff Other 109 FireProtection 245 3600 Life Magic 40 Reduces damage the target takes from Fire by 52%. +3746 Inferno Aegis 6 Buff Other 109 FireProtection 295 3600 Life Magic 40 Reduces damage the target takes from Fire by 62%. +3747 Lesser Inferno Aegis 4 Buff Other 109 FireProtection 195 3600 Life Magic 40 Reduces damage the target takes from Fire by 45%. +3748 Master Salvager's Greater Boon 7 Buff Other 435 SalvagingRaising 325 360 Creature Enchantment 70 Increases the caster's Salvaging skill by 45 points. +3749 Master Alchemist's Boon 7 Buff Other 221 AlchemyRaising 325 180 Creature Enchantment 50 Increases the caster's Alchemy skill by 45 points. +3750 Master Alchemist's Greater Boon 7 Buff Other 221 AlchemyRaising 325 360 Creature Enchantment 50 Increases the caster's Alchemy skill by 45 points. +3751 Master Chef's Boon 7 Buff Other 216 CookingRaising 325 180 Creature Enchantment 70 Increases the target's Cooking skill by 45 points. +3752 Master Chef's Greater Boon 7 Buff Other 216 CookingRaising 325 360 Creature Enchantment 70 Increases the target's Cooking skill by 45 points. +3753 Fletching Master's Boon 7 Buff Other 218 FletchingRaising 325 180 Creature Enchantment 50 Increases the target's Fletching skill by 45 points. +3754 Fletching Master's Greater Boon 7 Buff Other 218 FletchingRaising 325 360 Creature Enchantment 50 Increases the target's Fletching skill by 45 points. +3755 Master Lockpicker's Boon 7 Buff Other 73 LockpickRaising 325 180 Creature Enchantment 70 Increases the target's Lockpick skill by 45 points. +3756 Master Lockpicker's Greater Boon 7 Buff Other 73 LockpickRaising 325 360 Creature Enchantment 70 Increases the target's Lockpick skill by 45 points. +3757 Master Salvager's Boon 7 Buff Other 435 SalvagingRaising 325 180 Creature Enchantment 70 Increases the caster's Salvaging skill by 45 points. +3758 Inky Armor 1 Buff Other 513 ArmorIncreaseInkyArmor 1 3600 Life Magic 10 Your skin is coated with a fine layer of Niffis ink. Your natural armor is increased by 5 points. Additional spells can be layered over this. +3759 Mana Giver 1 Buff Other 283 ManaGiverRaising 15 510 Life Magic 70 Increases maximum mana by 15 points. +3760 Culinary Ecstasy 7 Buff Other 410 HealthDivide 300 1800 Creature Enchantment 10 All secondary attributes are increased by 10% for the duration of the spell. +3761 Fiun Resistance 1 Buff Other 514 MagicDefenseShelterRaisingFiun 5 780 Creature Enchantment 10 Increases the target's Magic Defense skill by 5 points. Additional spells can be layered over this. +3762 Defiled Temple Portal Sending 8 Utility Self 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to the Defiled Temple +3763 Balloon Ride 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3764 Summons a portal to the Banderling Shrine 5 Utility Self 203 PortalItemCreation 200 60 Item Enchantment 70 Summons a portal that goes to the destination of the caster's linked portal. set with Primary Portal Tie. +3765 Entry to the Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Bitterness +3766 Entry to the Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Bitterness +3767 Entry to the Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Bitterness +3768 Bitter Punishment 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to far above Ayn Tayan. +3769 Entry to the Mausoleum of Anger 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Anger +3770 Entry to the Mausoleum of Anger 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Anger +3771 Entry to the Mausoleum of Anger 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Anger +3772 Entry to the Mausoleum of Anger 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Anger +3773 Entry to the Mausoleum of Anger 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Anger +3774 Entry to the Mausoleum of Anger 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Anger +3775 Angry Punishment 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to high above the northern mountains +3776 Entry to the Mausoleum of Cruelty 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Cruelty +3777 Entry to the Mausoleum of Cruelty 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Cruelty +3778 Entry to the Mausoleum of Cruelty 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Cruelty +3779 Entry to the Mausoleum of Cruelty 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Cruelty +3780 Entry to the Mausoleum of Cruelty 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Cruelty +3781 Entry to the Mausoleum of Cruelty 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Cruelty +3782 Cruel Punishment 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to high above a Shadow Spire crater +3783 Entry to the Accursed Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Accursed Mausoleum of Bitterness +3784 Entry to the Accursed Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Accursed Mausoleum of Bitterness +3785 Entry to the Accursed Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Accursed Mausoleum of Bitterness +3786 Entry to the Accursed Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Accursed Mausoleum of Bitterness +3787 Entry to the Accursed Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Accursed Mausoleum of Bitterness +3788 Entry to the Accursed Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Accursed Mausoleum of Bitterness +3789 Slaughter Punishment 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to high above a Spire crater in the Obsidian Plains +3790 Entry to the Unholy Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Unholy Mausoleum of Bitterness +3791 Entry to the Unholy Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Unholy Mausoleum of Bitterness +3792 Entry to the Unholy Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Unholy Mausoleum of Bitterness +3793 Entry to the Unholy Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Unholy Mausoleum of Bitterness +3794 Entry to the Unholy Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Unholy Mausoleum of Bitterness +3795 Entry to the Unholy Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Unholy Mausoleum of Bitterness +3796 Entry to the Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Bitterness +3797 Entry to the Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Bitterness +3798 Entry to the Mausoleum of Bitterness 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Transports the target to an entrance of the Mausoleum of Bitterness +3799 Black Marrow Bliss 6 Debuff Other 84 ManaLowering 275 -1 Life Magic 60 The warm flavor of the Black Marrow Tea soothes your soul. +3800 Burning Spirit 1 Buff Other 517 AttributesIncreaseCantrip1 2 600 Creature Enchantment 10 Increases all attributes by 2 for 10 minutes. This effect layers on top of normal spells as well as cantrips. +3801 Shadow Touch 1 Buff Other 518 ExtraMeleeDefenseSkillRaising2 3 780 Creature Enchantment 10 Increases the target's Melee Defense skill by 3 points. +3802 Shadow Reek 1 Buff Other 426 WarMysticRaising2 3 780 Creature Enchantment 10 Increases the target's War Magic skill by 3 points. Additional spells can be layered over this. +3803 Shadow Shot 1 Buff Other 439 ExtraBowSkillRaising2 3 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 3 points. Additional spells can be layered over this. +3804 Shadow Shot 1 Buff Other 439 ExtraBowSkillRaising2 3 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 3 points. Additional spells can be layered over this. +3805 Acid Ring 5 Neutral Other 222 AcidRing 200 -1 War Magic 80 Shoots nine waves of acid outward from the caster. Each wave does 30-60 points of acid damage to the first thing it hits. +3806 Flame Ring 5 Neutral Other 226 FireRing 200 -1 War Magic 80 Shoots nine waves of flame outward from the caster. Each wave does 30-60 points of fire damage to the first thing it hits. +3807 Force Ring 5 Neutral Other 227 PiercingRing 200 -1 War Magic 80 Shoots nine waves of force outward from the caster. Each wave does 30-60 points of piercing damage to the first thing it hits. +3808 Lightning Ring 5 Neutral Other 225 ElectricRing 200 -1 War Magic 80 Shoots nine waves of lightning outward from the caster. Each wave does 30-60 points of electric damage to the first thing it hits. +3809 Minor Salvaging Aptitude 1 Buff Other 437 ExtraSalvagingRaising2 5 3600 Creature Enchantment 10 Increases the target's Salvaging skill by 5 points. +3810 Asheron?ÇÖs Benediction 3 Buff Other 520 ACTDPurchaseRewardSpellHealth 100 86400 Creature Enchantment 1 Raises health by 10% for 24 hours. Additional spells can be layered over this. +3811 Blackmoor?ÇÖs Favor 3 Buff Other 519 ACTDPurchaseRewardSpell 100 86400 Life Magic 1 Increases Natural Armor by 50 points for 24 hours. Additional spells can be layered over this. +3812 Tursh's Lair 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3813 Free Ride to Shoushi 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3814 Free Ride to Yaraq 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3815 Free Ride to Holtburg 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3816 Marksman's Ken 1 Buff Other 331 ExtraBowSkillRaising 10 2400 Creature Enchantment 10 The keen sight of the Hunters of the Raven Hand strengths your aim. increasing your Missile Weapons skill by 10 points. Additional spells can be layered over this. +3817 Hunter's Ward 1 Buff Other 379 ArmorIncrease 30 2400 Life Magic 10 Shadowy tendrils weave about you. forming a magical encasement increasing your natural armor by 30 points. Additional spells can be layered over this. +3818 Curse of Raven Fury 7 Debuff Other 80 HealthLowering 300 -1 Life Magic 150 Drains half of the caster?ÇÖs health and projects a ring of vicious energy outwards. When struck. the target?ÇÖs health is reduced by 200% of the amount drained from the caster. +3819 Conscript's Might 1 Buff Other 261 StrengthIncrease 10 2400 Creature Enchantment 10 The might of the Conscripts of the Raven Hand flows through you. bolstering your strength by 10 points. Additional spells can be layered over this. +3820 Conscript's Ward 1 Buff Other 379 ArmorIncrease 30 2400 Life Magic 10 Shadowy tendrils weave about you. forming a magical encasement increasing your natural armor by 30 points. Additional spells can be layered over this. +3821 Augur's Will 1 Buff Other 271 SelfIncrease 10 2400 Creature Enchantment 10 The will of the Augurs of the Raven Hand flows through you. increasing your Self by 10 points. Additional spells can be layered over this. +3822 Augur's Glare 1 Buff Other 269 FocusIncrease 10 2400 Creature Enchantment 10 You are filled with the intense dedication of the Augurs of the Raven Hand. increasing your Focus by 10 points. Additional spells can be layered over this. +3823 Augur's Ward 1 Buff Other 379 ArmorIncrease 30 2400 Life Magic 10 Shadowy tendrils weave about you. forming a magical encasement increasing your natural armor by 30 points. Additional spells can be layered over this. +3824 Marksman's Ken 1 Buff Other 331 ExtraBowSkillRaising 10 2400 Creature Enchantment 10 The keen sight of the Hunters of the Raven Hand strengths your aim. increasing your Missile Weapons skill by 10 points. Additional spells can be layered over this. +3825 Marksman's Ken 1 Buff Other 331 ExtraBowSkillRaising 10 2400 Creature Enchantment 10 The keen sight of the Hunters of the Raven Hand strengths your aim. increasing your Missile Weapons skill by 10 points. Additional spells can be layered over this. +3826 a powerful force 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3827 Lunnum's Embrace 8 Buff Item 160 ArmorValueRaising 500 3600 Item Enchantment 70 Improves a shield or piece of armor's armor value by 500 points. +3828 Rage of Grael 1 Buff Item 323 MaxDamageRaising 3 10800 Item Enchantment 10 Infuses a weapon with the rage of the ancient barbarian gladiator. Grael. Increases a weapon's damage value by 3 points. Additional spells can be layered over this. +3829 Blessing of the Sundew 1 Buff Other 259 ManaRestoring 25 10800 Life Magic 10 Increases the rate at which the target regains Mana by 25%. Additional spells can be layered over this. +3830 Blessing of the Fly Trap 1 Buff Other 257 HealthRestoring 25 10800 Life Magic 10 Increases the rate at which the target regains Health by 25%. Additional spells can be layered over this. +3831 Blessing of the Pitcher Plant 1 Buff Other 407 StaminaRestoring 25 10800 Life Magic 10 Increases the rate at which the target regains Stamina by 25%. Additional spells can be layered over this. +3832 Master's Voice 1 Buff Other 269 FocusIncrease 10 1800 Creature Enchantment 10 The sibilant voice of Adhorix helps improve your concentration. Your Focus is raised by 10. This effect stacks with other Focus-raising spells. +3833 Minor Salvaging Aptitude 1 Buff Other 437 ExtraSalvagingRaising2 5 780 Creature Enchantment 10 Increases the target's Salvaging skill by 5 points. Additional spells can be layered over this. +3834 Major Salvaging Aptitude 1 Buff Other 437 ExtraSalvagingRaising2 10 780 Creature Enchantment 10 Increases the target's Salvaging skill by 15 points. Additional spells can be layered over this. +3835 Leviathan's Curse 8 Debuff Other 80 HealthLowering 400 -1 Life Magic 70 Drains 150-400 points of the target's Health. +3836 Breath of the Deep 8 Neutral Other 119 ColdMissile 400 -1 War Magic 35 Shoots a bolt of cold at the target. The bolt does 200-350 points of cold damage to the first thing it hits. +3837 Water Island Access 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3838 Abandoned Mines Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3839 Brilliant Access 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3840 Dazzling Access 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3841 Devastated Access 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3842 Northeast Coast Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3843 Fire Island Access 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3844 Gatekeeper Access 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3845 Radiant Access 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3846 Ruined Access 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3847 Cataracts of Xik Minru 8 Neutral Item 214 PortalSending 500 -1 Item Enchantment 50 Sends target to the Cataracts of Xik Minru +3848 Combat Medication 7 Buff Other 93 HealthAccelerating 320 60 Life Magic 70 The energies imbued upon the ring weave a healing aura around you. increasing your natural healing rate by 130%. +3849 Night Runner 7 Buff Other 369 ExtraRunSkillRaising 350 60 Creature Enchantment 70 The energies imbued upon this ring surge through you. increasing your run skill by 40. Additional effects can be layered on top of this. +3850 Selflessness 8 Debuff Other 280 LifeTakerLowering 400 60 Life Magic 70 Your selflessness aids your fellows. but at a cost. Your health is reduced by 10. +3851 Corrupted Essence 1 Buff Other 269 FocusIncrease 15 600 Creature Enchantment 10 Dark forces channel through your essence. improving your focus. Your Focus is raised by 15. Additional spells can be layered over this. +3852 Ravenous Armor 1 Debuff Other 280 LifeTakerLowering 10 600 Life Magic 70 You feel your life force being sapped slowly by your armor. Your Maximum Health is reduced by 10. +3853 Ardent Defense 1 Buff Other 351 ExtraMeleeDefenseSkillRaising 12 600 Creature Enchantment 10 You are gifted with an improved defense against melee attacks. Your Melee Defense is raised by 12. Additional spells can be layered over this. +3854 True Loyalty 1 Buff Other 345 ExtraLoyaltySkillRaising 12 600 Creature Enchantment 10 Your loyalty knows no bounds while you wear this armor. Your Loyalty is raised by 12. Additional spells can be layered over this. +3855 Flight of Bats 3 Buff Other 67 HealingRaising 100 780 Creature Enchantment 30 Increases the target's Healing skill by 40 points. +3856 Ulgrim's Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 150 A really really good spell. +3857 Pumpkin Rain 7 Neutral Other 237 BludgeoningStrike 320 -1 War Magic 120 Rains eight of pumpkins down. smooshing any that oppose. +3858 Pumpkin Ring 5 Neutral Other 226 FireRing 200 -1 War Magic 80 Shoots eight waves of flame outward from the caster. Each wave does 40-80 points of fire damage to the first thing it hits. +3859 Pumpkin Wall 5 Neutral Other 233 FireWall 200 -1 War Magic 80 Sends a wall of five balls of fire. two high. slowly towards the target. Each ball does 30-60 points of fire damage to the first thing it hits. The wall is created 2 meters in front of the caster. +3860 Sweet Speed 8 Buff Other 369 ExtraRunSkillRaising 500 60 Creature Enchantment 50 Increases the target's Run by 100 points. +3861 Taste for Blood 1 Buff Other 377 ExtraAppraiseWeaponSkillRaising 8 600 Creature Enchantment 50 The feral instincts of the Mukkir give you a keener eye towards improving your weapons. Increases the target's Weapon Tinkering skill by 8 points. Additional spells can be layered over this. +3862 Duke Raoul's Pride 8 Buff Other 11 SelfRaising 420 1800 Creature Enchantment 70 Increases the caster's Self by 50 points. +3863 Hunter's Hardiness 8 Buff Other 3 EnduranceRaising 420 1800 Creature Enchantment 70 Increases the caster's Endurance by 50 points. +3864 Zongo's Fist 8 Buff Other 1 StrengthRaising 420 1800 Creature Enchantment 70 Increases the caster's Strength by 50 points. +3865 Glenden Wood Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 Sends the caster to Glenden Wood. +3866 Glacial Speed 8 Debuff Other 78 RunLowering 400 30 Creature Enchantment 50 Decreases the target's Run skill by 200 points. +3867 Embrace of the Chill Shadow 1 Buff Other 289 ColdWardProtection 12 10800 Life Magic 10 Reduces damage the target takes from Cold by 12%. Additional spells can be layered over this. +3868 Dardante's Keep Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 This spell sends the user to Dardante's Keep. +3869 Invocation of the Black Book 6 Buff Item 521 SaltAshAttackModRaising 250 1800 Item Enchantment 10 The dark energies of the Black Book of Salt and Ash have made your weapon strike more accurately. The Invocation has raised your weapon's Attack Modifier by 10%. Additional spells can be layered over this. +3870 Syphon Creature Essence 8 Neutral Other 250 Dispel 400 -1 Creature Enchantment 300 This spell attempts to rip all positive Creature Magic from a single target. +3871 Syphon Item Essence 8 Neutral Other 250 Dispel 400 -1 Creature Enchantment 300 Dispels all positive Item Enchantments of level 7 or lower from the players wielded weapon or caster. +3872 Syphon Life Essence 8 Neutral Other 250 Dispel 400 -1 Creature Enchantment 300 This spell attempts to rip all positive Life Magic from a single target. +3873 Essence's Command 8 Neutral Other 250 Dispel 400 -1 Life Magic 300 Dispels 1-3 positive Life Magic enchantments of level 7 or lower from each person in the fellowship. +3874 Death's Aura 8 Debuff Other 68 HealingLowering 400 -1 Life Magic 10 Drains 40-75 points of health from each member of the fellowship. +3875 Acidic Curse 8 Buff Other 102 AcidVulnerability 400 240 Life Magic 70 Increases damage all fellowship members take from acid by 185%. +3876 Curse of the Blades 8 Buff Other 114 SlashVulnerability 400 240 Life Magic 70 Increases damage all fellowship members take from Slashing by 185%. +3877 Corrosive Strike 8 Neutral Other 117 AcidMissile 400 -1 War Magic 35 Shoots a stream of acid at the target. The stream does 150-300 points of acid damage to the target. +3878 Incendiary Strike 8 Neutral Other 121 FireMissile 400 -1 War Magic 35 Shoots a bolt of flame at the target. The bolt does 150-300 points of fire damage to the target. +3879 Glacial Strike 8 Neutral Other 119 ColdMissile 400 -1 War Magic 35 Shoots a bolt of frost at the target. The bolt does 150-300 points of cold damage to the target. +3880 Galvanic Strike 8 Neutral Other 120 ElectricMissile 400 -1 War Magic 35 Shoots a bolt of lighting at the target. The bolt does 150-300 points of electrical damage to the target. +3881 Corrosive Ring 8 Neutral Other 222 AcidRing 400 -1 War Magic 80 Shoots eight waves of acid outward from the caster. Each wave does 100-200 points of acid damage to the first thing it hits. +3882 Incendiary Ring 8 Neutral Other 226 FireRing 400 -1 War Magic 80 Shoots eight waves of flame outward from the caster. Each wave does 100-200 points of fire damage to the first thing it hits. +3883 Pyroclastic Explosion 8 Projectile Other 226 FireRing 400 -1 War Magic 80 Shoots sixteen waves of flame outward from the caster. Each wave does 75-150 points of fire damage to the first thing it hits. +3884 Glacial Ring 8 Neutral Other 224 ColdRing 400 -1 War Magic 80 Shoots eight waves of frost outward from the caster. Each wave does 100-200 points of cold damage to the first thing it hits. +3885 Galvanic Ring 8 Neutral Other 225 ElectricRing 400 -1 War Magic 80 Shoots eight waves of lightning outward from the caster. Each wave does 100-200 points of electric damage to the first thing it hits. +3886 Magic Disarmament 8 Debuff Other 42 MagicDefenseLowering 400 60 Creature Enchantment 70 Decreases the target's Magic Defense skill by 200 points. +3887 Entering the Hatch 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Entering the Hatch +3888 Passage to the Rare Chambers 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Passage to the Rare Chambers +3889 Inner Burial Chamber Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Portals the user to the Inner Burial Chamber in the Ruschk Burial Mound dungeon. +3890 Will of the People 1 Buff Other 271 SelfIncrease 10 1800 Creature Enchantment 10 The words of Arwyth Margyle have boosted your Self by 10 points. This spell stacks with normal spells. but will be overridden by Major Willpower. +3891 Honor of the Bull 1 Buff Other 345 ExtraLoyaltySkillRaising 10 1800 Creature Enchantment 10 Your deidcation to the Viamontian cause has bolstered your loyalty by 10 points. This spell stacks with normal spells. but will be overridden by Major Loyalty. +3892 Summon Flame Seekers 7 Neutral Other 226 FireRing 300 -1 War Magic 80 Summons three Homing Flame Bolts. +3893 Summon Burning Haze 7 Neutral Other 226 FireRing 300 -1 War Magic 35 Creates a cloud of burning gases. +3894 Dark Persistence 1 Buff Other 416 EnduranceIncrease2 3 10800 Creature Enchantment 10 A dark power suffuses your being. increasing your Endurance by 3. +3895 Dark Reflexes 1 Buff Other 522 QuicknessIncrease2 3 10800 Creature Enchantment 10 A dark power suffuses your being. increasing your Quickness by 3. +3896 Dark Equilibrium 1 Buff Other 413 CoordinationIncrease2 3 10800 Creature Enchantment 10 A dark power suffuses your being. increasing your Coordination by 3. +3897 Dark Purpose 1 Buff Other 417 SelfIncrease2 3 10800 Creature Enchantment 10 A dark power suffuses your being. increasing your Self by 3. +3898 Pooky's Recall 1 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3899 Pooky's Recall 2 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3900 Pooky's Recall 3 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +3901 Egg Bomb 7 Neutral Other 121 FireMissile 300 -1 War Magic 35 Shoots an explosive egg at the target. The egg does 100-200 points of fire damage to the first thing it hits. +3902 Ring around the Rabbit 5 Neutral Other 228 SlashingRing 200 -1 War Magic 80 Shoots eight rabbits outward from the caster. Each rabbit does 40-80 points of slashing damage to the first thing it hits. +3903 Whirlwind 5 Neutral Other 223 BludgeoningRing 200 -1 War Magic 80 Eight whirlwinds move outward from the caster. Each whirlwind does 60-120 points of bludgeoning damage to the first thing it hits. +3904 Essence's Fury 7 Neutral Other 237 BludgeoningStrike 300 -1 War Magic 200 Corrodes the target for 200 points of acid damage. +3905 Essence's Fury 7 Neutral Other 237 BludgeoningStrike 300 -1 War Magic 200 Burns the target for 200 points of fire damage. +3906 Essence's Fury 7 Neutral Other 237 BludgeoningStrike 300 -1 War Magic 200 Freezes the target for 200 points of cold damage. +3907 Essence's Fury 7 Neutral Other 237 BludgeoningStrike 300 -1 War Magic 200 Shocks the target for 200 points of electric damage. +3908 Mana Blast 7 Projectile Other 84 ManaLowering 300 -1 Life Magic 70 Fires three bolts of energy. When struck by a bolt. the target's mana is reduced by 500. +3909 Mana Syphon 8 Debuff Other 98 ManaDecelerating 400 120 Life Magic 70 Decreases target's natural mana rate by 100%. +3910 Brain Freeze 8 Buff Other 424 SkillsDecrease 500 15 Creature Enchantment 10 The Essence strikes out with an icicle impaling your head. reducing all your skills by 50%. +3911 Spiral of Souls 8 Debuff Other 80 HealthLowering 400 -1 Life Magic 150 A spiral of energy sucks the life force out of all those around the caster for 40-75 points of damage. +3912 Lower Black Spear Temple Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the player to the lower levels of the Black Spear Temple. +3913 Aegis of the Golden Flame 7 Buff Other 115 ArmorRaising 310 3600 Life Magic 70 Increases the caster's natural armor by 235 points. +3914 Dark Vortex 8 Neutral Other 223 BludgeoningRing 400 -1 War Magic 80 A spinning vortex of shadow. +3915 Black Madness 7 Buff Other 424 SkillsDecrease 350 60 Creature Enchantment 10 A madness enters your mind. The gaping horror of the abyss fills you with dread. reducing all your skills by 30%. +3916 Flayed Flesh 8 Debuff Other 116 ArmorLowering 500 10 Life Magic 70 Decreases the target's natural armor by 500 points. +3917 Numbing Chill 8 Buff Other 106 ColdVulnerability 400 240 Life Magic 70 Increases damage all fellowship members take from cold by 185%. +3918 Flammable 8 Buff Other 110 FireVulnerability 400 240 Life Magic 70 Increases damage all fellowship members take from fire by 185%. +3919 Lightning Rod 8 Buff Other 108 ElectricVulnerability 400 240 Life Magic 70 Increases damage all fellowship members take from lightning by 185%. +3920 Tunnels to the Harbinger 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Tunnels to the Harbinger +3921 Harbinger's Lair 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Harbinger's Lair +3922 Tunnels to the Harbinger 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Tunnels to the Harbinger +3923 Tunnels to the Harbinger 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Tunnels to the Harbinger +3924 Tunnels to the Harbinger 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Tunnels to the Harbinger +3925 Harbinger's Lair 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Harbinger's Lair +3926 Harbinger's Fiery Touch 7 Neutral Other 121 FireMissile 300 -1 War Magic 50 Shoots a bolt of elemental energy at the target. The bolt does 130-220 points of fire damage to the first thing it hits. +3927 Charge Flesh 7 Buff Other 108 ElectricVulnerability 350 60 Life Magic 10 Target's flesh is left open and vulnerable to electric attacks. Increases damage the target takes from lightning by 200%. +3928 Disarmament 8 Debuff Other 38 MeleeDefenseLowering 400 60 Creature Enchantment 70 Decreases the target's Melee Defense skill by 200 points. +3929 Rossu Morta Chapterhouse Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 This spell teleports the caster to the Chapterhouse of the Rossu Morta. +3930 Whispering Blade Chapterhouse Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 This spell teleports the caster to the Chapterhouse of the Whispering Blade. +3931 Dark Vortex 8 Neutral Other 223 BludgeoningRing 400 -1 War Magic 80 A spinning vortex of shadow. +3932 Grael's Rage 8 Debuff Other 80 HealthLowering 400 -1 Life Magic 10 Drains 200-400 points of the target's Health. +3933 Black Spear Strike 8 Neutral Other 241 PiercingStrike 400 -1 War Magic 200 Impales the target for 250-300 points of piercing damage. +3934 Heavy Acid Ring 8 Neutral Other 222 AcidRing 400 -1 War Magic 80 Shoots 12 waves of acid outward from the caster. Each wave does 250-400 points of acid damage to the first thing it hits. +3935 Heavy Blade Ring 8 Neutral Other 228 SlashingRing 400 -1 War Magic 80 Shoots 12 waves of blades outward from the caster. Each wave does 250-400 points of slashing damage to the first thing it hits. +3936 Fire Bomb 8 Neutral Other 226 FireRing 400 -1 War Magic 80 Shoots 12 waves of flame outward from the caster. Each wave does 250-400 points of fire damage to the first thing it hits. +3937 Heavy Force Ring 8 Neutral Other 227 PiercingRing 400 -1 War Magic 80 Shoots 12 waves of force outward from the caster. Each wave does 250-400 points of piercing damage to the first thing it hits. +3938 Heavy Frost Ring 8 Neutral Other 224 ColdRing 400 -1 War Magic 80 Shoots 12 waves of frost outward from the caster. Each wave does 250-400 points of cold damage to the first thing it hits. +3939 Thaumic Bleed 8 Neutral Other 225 ElectricRing 400 -1 War Magic 80 Shoots 12 waves of lightning around the caster. Each wave does 250-300 points of electric damage to the first thing it hits. +3940 Exsanguinating Wave 8 Debuff Other 80 HealthLowering 400 -1 Life Magic 150 A wave of life draining energy. +3941 Heavy Lightning Ring 8 Neutral Other 225 ElectricRing 400 -1 War Magic 80 Shoots 12 waves of lightning outward from the caster. Each wave does 250-400 points of electric damage to the first thing it hits. +3942 Heavy Shock Ring 8 Neutral Other 223 BludgeoningRing 400 -1 War Magic 80 Shoots 12 waves of shock outward from the caster. Each wave does 250-400 points of bludgeoning damage to the first thing it hits. +3943 Burning Earth 8 Neutral Other 233 FireWall 400 -1 War Magic 80 A burning section of ground that deals 100-400 points of damage to whatever touches it. +3944 Rain of Spears 8 Neutral Other 241 PiercingStrike 400 -1 War Magic 120 Black Spears streak from the sky dealing 300 points of damage to whatever they hit. +3945 Raging Storm 8 Neutral Other 239 ElectricStrike 400 -1 War Magic 120 Rains LOTS of red lightning down. +3946 Acid Wave 8 Neutral Other 222 AcidRing 400 -1 War Magic 80 Shoots eight waves of acid forward from the caster. Each wave does 80-150 points of acid damage to the first thing it hits. +3947 Blade Wave 8 Neutral Other 228 SlashingRing 400 -1 War Magic 80 Shoots eight slashing waves forward from the caster. Each wave does 80-150 points of slashing damage to the first thing it hits. +3948 Flame Wave 8 Neutral Other 226 FireRing 400 -1 War Magic 80 Shoots eight waves of flame forward from the caster. Each wave does 80-150 points of fire damage to the first thing it hits. +3949 Force Wave 8 Neutral Other 227 PiercingRing 400 -1 War Magic 80 Shoots eight waves of force forward from the caster. Each wave does 80-150 points of piercing damage to the first thing it hits. +3950 Frost Wave 8 Neutral Other 224 ColdRing 400 -1 War Magic 80 Shoots eight waves of frost forward from the caster. Each wave does 80-150 points of cold damage to the first thing it hits. +3951 Lightning Wave 8 Neutral Other 225 ElectricRing 400 -1 War Magic 80 Shoots eight waves of lightning forward from the caster. Each wave does 80-100 points of electric damage to the first thing it hits. +3952 Shock Waves 8 Neutral Other 223 BludgeoningRing 400 -1 War Magic 80 Shoots eight shock waves forward from the caster. Each wave does 80-150 points of bludgeoning damage to the first thing it hits. +3953 Carraida?ÇÖs Benediction 3 Buff Other 520 ACTDPurchaseRewardSpellHealth 100 86400 Creature Enchantment 1 Raises health by 10% for 24 hours. Additional spells can be layered over this. +3954 Access to the White Tower 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Teleports the target into the White Tower. +3955 Epic Bludgeon Ward 1 Buff Other 401 BludgeonWardProtection 20 10800 Life Magic 20 Reduces damage the target takes from bludgeoning by 20%. Additional magical protection can be layered over this. +3956 Epic Piercing Ward 1 Buff Other 405 PierceWardProtection 20 10800 Life Magic 20 Reduces damage the target takes from piercing by 20%. Additional magical protection can be layered over this. +3957 Epic Slashing Ward 2 Buff Other 403 SlashWardProtection 50 10800 Life Magic 20 Reduces damage the target takes from slashing by 20%. Additional magical protection can be layered over this. +3958 White Tower Egress 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Teleports the target out of the White Tower. +3959 Redirect Motives 7 Debuff Other 80 HealthLowering 325 -1 Life Magic 70 In an attempt to redirect the motives of the wielder back to the law they are sworn to uphold this spell drains 50-100 points of the target's Health. +3960 Authority 8 Buff Item 154 DamageRaising 500 1020 Item Enchantment 60 Increases a weapon's damage value by 60 points. +3961 Defense of the Just 8 Buff Item 156 DefenseModRaising 500 3600 Item Enchantment 70 Increases the Melee Defense skill modifier of a weapon or magic caster by 60%. +3962 Bound to the Law 8 Debuff Other 38 MeleeDefenseLowering 400 240 Creature Enchantment 70 Target is bound to law and justice. The confines of the law do not always allow free action. Reduces Melee Defense by 60 points. +3963 Epic Coordination 1 Buff Other 267 CoordinationIncrease 25 780 Creature Enchantment 10 Increases the target's Coordination by 25 points. Additional spells can be layered over this. +3964 Epic Focus 1 Buff Other 269 FocusIncrease 25 780 Creature Enchantment 10 Increases the target's Focus by 25 points. Additional spells can be layered over this. +3965 Epic Strength 1 Buff Other 261 StrengthIncrease 25 780 Creature Enchantment 10 Increases the target's Strength by 25 points. Additional spells can be layered over this. +3966 Ringleader's Chambers 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Target is portaled into a the Bandit Ringleader?ÇÖs chambers +3967 Bandit Trap 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Target is portaled into a Sawato Bandit Trap! +3968 Bandit Hideout 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Target is portaled into the Sawato Bandit Hideout +3969 Acid Bomb 8 Neutral Other 222 AcidRing 400 -1 War Magic 80 Shoots 12 waves of acid outward from the caster. Each wave does 100-400 points of acid damage to the first thing it hits. +3970 Blade Bomb 8 Neutral Other 228 SlashingRing 400 -1 War Magic 80 Shoots 12 waves of blades outward from the caster. Each wave does 100-400 points of slashing damage to the first thing it hits. +3971 Fire Bomb 8 Neutral Other 226 FireRing 400 -1 War Magic 80 Shoots 12 waves of flame outward from the caster. Each wave does 100-400 points of fire damage to the first thing it hits. +3972 Force Bomb 8 Neutral Other 227 PiercingRing 400 -1 War Magic 80 Shoots 12 waves of force outward from the caster. Each wave does 100-400 points of piercing damage to the first thing it hits. +3973 Frost Bomb 8 Neutral Other 224 ColdRing 400 -1 War Magic 80 Shoots 12 waves of frost outward from the caster. Each wave does 100-400 points of cold damage to the first thing it hits. +3974 Lightning Bomb 8 Neutral Other 225 ElectricRing 400 -1 War Magic 80 Shoots 12 waves of lightning outward from the caster. Each wave does 200-1000 points of electric damage to the first thing it hits. +3975 Shock Bomb 8 Neutral Other 223 BludgeoningRing 400 -1 War Magic 80 Shoots 12 waves of shock outward from the caster. Each wave does 200-1000 points of bludgeoning damage to the first thing it hits. +3976 Incantation of Armor Other 8 Buff Other 115 ArmorRaising 400 5400 Life Magic 80 Increases the target's natural armor by 250 points. +3977 Coordination Other Incantation 8 Buff Other 7 CoordinationRaising 400 10800 Creature Enchantment 100 Increases the target's Coordination by 45 points. +3978 Focus Other Incantation 8 Buff Other 9 FocusRaising 400 10800 Creature Enchantment 100 Increases the target's Focus by 45 points. +3979 Strength Other Incantation 8 Buff Other 1 StrengthRaising 400 10800 Creature Enchantment 80 Increases the target's Strength by 45 points. +3980 Impenetrability Incantation 7 Buff Item 160 ArmorValueRaising 325 10800 Item Enchantment 100 Improves a shield or piece of armor's armor value by 240 points. Target yourself to cast this spell on all of your equipped armor. +3981 Mana Renewal Other Incantation 8 Buff Other 97 ManaAccelerating 400 10800 Life Magic 100 Increases the target's natural mana rate by 145%. +3982 Regeneration Other Incantation 8 Buff Other 93 HealthAccelerating 400 10800 Life Magic 100 Increase target's natural healing rate by 145%. +3983 Rejuvenation Other Incantation 8 Buff Other 95 StaminaAccelerating 400 10800 Life Magic 100 Increases the rate at which the target regains Stamina by 145%. +3984 Mukkir's Ferocity 1 Buff Item 389 ExtraAttackModRaising 4 10800 Item Enchantment 10 Increases a weapon's Attack Skill modifier by 4%. Additional spells can be layered over this. +3985 Mukkir Sense 1 Buff Item 329 ExtraDefenseModRaising 4 10800 Item Enchantment 10 Increases the Melee Defense skill modifier of a weapon or magic caster by 4%. Additional spells can be layered over this. +3986 Rock Fall 8 Neutral Other 118 BludgeoningMissile 400 -1 War Magic 35 A large falling block of black ice. +3987 Black Spear Strike 8 Neutral Other 241 PiercingStrike 400 -1 War Magic 200 Impales the target for 150-200 points of piercing damage. +3988 Black Spear Strike 8 Neutral Other 241 PiercingStrike 400 -1 War Magic 200 Impales the target for 200-250 points of piercing damage. +3989 Dark Lightning 8 Neutral Other 120 ElectricMissile 400 -1 War Magic 35 Shoots a bolt of lighting at the target. The bolt does 150-250 points of electrical damage to the first thing it hits. +3990 Heavy Frost Ring 8 Neutral Other 224 ColdRing 400 -1 War Magic 80 Shoots 12 waves of frost outward from the caster. Each wave does 100-150 points of cold damage to the first thing it hits. +3991 Thaumic Bleed 8 Neutral Other 225 ElectricRing 400 -1 War Magic 80 Shoots 8 waves of lightning around the caster. Each wave does 250-300 points of electric damage to the first thing it hits. +3992 Heavy Acid Ring 8 Neutral Other 222 AcidRing 400 -1 War Magic 80 Shoots 12 waves of acid outward from the caster. Each wave does 150-300 points of acid damage to the first thing it hits. +3993 Heavy Blade Ring 8 Neutral Other 228 SlashingRing 400 -1 War Magic 80 Shoots 12 waves of blades outward from the caster. Each wave does 150-300 points of slashing damage to the first thing it hits. +3994 Fire Bomb 8 Neutral Other 226 FireRing 400 -1 War Magic 80 Shoots 12 waves of flame outward from the caster. Each wave does 150-300 points of fire damage to the first thing it hits. +3995 Heavy Force Ring 8 Neutral Other 227 PiercingRing 400 -1 War Magic 80 Shoots 12 waves of force outward from the caster. Each wave does 150-300 points of piercing damage to the first thing it hits. +3996 Heavy Frost Ring 8 Neutral Other 224 ColdRing 400 -1 War Magic 80 Shoots 12 waves of frost outward from the caster. Each wave does 150-300 points of cold damage to the first thing it hits. +3997 Heavy Lightning Ring 8 Neutral Other 225 ElectricRing 400 -1 War Magic 80 Shoots 12 waves of lightning outward from the caster. Each wave does 150-300 points of electric damage to the first thing it hits. +3998 Dark Vortex 8 Neutral Other 223 BludgeoningRing 400 -1 War Magic 80 A spinning vortex of shadow. +3999 Exsanguinating Wave 8 Debuff Other 80 HealthLowering 400 -1 Life Magic 150 A wave of life draining energy. +4000 Heavy Shock Ring 8 Neutral Other 223 BludgeoningRing 400 -1 War Magic 80 Shoots 12 waves of shock outward from the caster. Each wave does 150-300 points of bludgeoning damage to the first thing it hits. +4001 Burning Earth 8 Neutral Other 233 FireWall 400 -1 War Magic 80 A burning section of ground that deals 200-500 points of damage to whatever touches it. +4002 Burning Earth 8 Neutral Other 233 FireWall 400 -1 War Magic 80 A burning section of ground that deals 100-200 points of damage to whatever touches it. +4003 Wall of Spears 8 Projectile Other 234 PiercingWall 400 -1 War Magic 120 Black Spears streak towards the target. Each spear does 150-250 points of piercing damage to the first thing it hits. +4004 Wall of Spears 8 Projectile Other 234 PiercingWall 400 -1 War Magic 120 Black Spears streak towards the target. Each spear does 100-150 points of piercing damage to the first thing it hits. +4005 Acid Wave 8 Neutral Other 222 AcidRing 400 -1 War Magic 80 Shoots eight waves of acid forward from the caster. Each wave does 20-100 points of acid damage to the first thing it hits. +4006 Blade Wave 8 Neutral Other 228 SlashingRing 400 -1 War Magic 80 Shoots eight slashing waves forward from the caster. Each wave does 20-100 points of slashing damage to the first thing it hits. +4007 Flame Wave 8 Neutral Other 226 FireRing 400 -1 War Magic 80 Shoots eight waves of flame forward from the caster. Each wave does 20-100 points of fire damage to the first thing it hits. +4008 Force Wave 8 Neutral Other 227 PiercingRing 400 -1 War Magic 80 Shoots eight waves of force forward from the caster. Each wave does 20-100 points of piercing damage to the first thing it hits. +4009 Frost Wave 8 Neutral Other 224 ColdRing 400 -1 War Magic 80 Shoots eight waves of frost forward from the caster. Each wave does 20-100 points of cold damage to the first thing it hits. +4010 Lightning Wave 8 Neutral Other 225 ElectricRing 400 -1 War Magic 80 Shoots eight waves of lightning forward from the caster. Each wave does 20-100 points of electric damage to the first thing it hits. +4011 Shock Waves 8 Neutral Other 223 BludgeoningRing 400 -1 War Magic 80 Shoots eight shock waves forward from the caster. Each wave does 20-100 points of bludgeoning damage to the first thing it hits. +4012 White Totem Temple Sending 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 The White Totem Gateway sends you to the White Totem Temple. +4013 Black Totem Temple Sending 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 The Black Totem Gateway sends you to the Black Totem Temple. +4014 Abyssal Totem Temple Sending 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 The Abyssal Totem Gateway sends you to the Abyssal Totem Temple. +4015 Ruschk Skin 1 Buff Other 513 ArmorIncreaseInkyArmor 10 10800 Life Magic 10 Increases the target's natural armor by 10 points. Additional spells can be layered over this. +4016 Shadow's Heart 1 Buff Other 349 ExtraHealingSkillRaising 25 10800 Creature Enchantment 10 Increases the target's Healing skill by 25 points. Additional spells can be layered over this. +4017 Phial's Accuracy 8 Buff Other 19 BowRaising 500 3600 Creature Enchantment 100 Increases the target's Missile Weapons skill by 800 points. +4018 Permafrost 8 Buff Item 160 ArmorValueRaising 475 3600 Item Enchantment 70 A frozen shell that offers a surprising amount of protection. +4019 Epic Quickness 1 Buff Other 265 QuicknessIncrease 25 780 Creature Enchantment 10 Increases the target's Quickness by 25 points. Additional spells can be layered over this. +4020 Epic Deception Prowess 1 Buff Other 343 ExtraDeceptionSkillRaising 25 780 Creature Enchantment 10 Increases the target's Deception skill by 25 points. Additional spells can be layered over this. +4021 Flurry of Stars 7 Neutral Other 137 SlashingBurst 300 -1 War Magic 70 Shoots five whirling blades quickly outward from the caster. Each blade does 115-189 points of slashing damage to the first thing it hits. +4022 Zombies Persistence 8 Buff Other 93 HealthAccelerating 545 60 Life Magic 50 Increase caster's natural healing rate by 200% for 60 seconds. +4023 Disco Inferno Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 This spell sends the player to the Night Club dungeon. +4024 Asheron?ÇÖs Lesser Benediction 3 Buff Other 520 ACTDPurchaseRewardSpellHealth 100 86400 Creature Enchantment 1 Raises health by 10% for 24 hours. Additional spells can be layered over this. +4025 Cast Iron Stomach 2 Buff Other 281 StaminaGiverRaising 50 10800 Life Magic 10 Increases maximum stamina by 50 points. +4026 Hematic Verdure 1 Buff Other 279 LifeGiverRaising 25 510 Life Magic 70 Increases maximum health by 25 points. +4027 Messenger's Stride 1 Buff Other 369 ExtraRunSkillRaising 30 780 Creature Enchantment 10 Increases the target's Run skill by 30 points. Additional spells can be layered over this. +4028 Snowball 1 Neutral Other 119 ColdMissile 1 -1 War Magic 10 A fluffy snowball. +4029 Return to the Hall of Champions 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Colosseum's Hall of Champions. +4030 Colosseum Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the starting Arena of the Colosseum. +4031 Advanced Colosseum Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the 6th Arena of the Colosseum. +4032 Colosseum Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the starting Arena of the Colosseum. +4033 Advanced Colosseum Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the 6th Arena of the Colosseum. +4034 Colosseum Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the starting Arena of the Colosseum. +4035 Advanced Colosseum Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the 6th Arena of the Colosseum. +4036 Colosseum Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the starting Arena of the Colosseum. +4037 Advanced Colosseum Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the 6th Arena of the Colosseum. +4038 Colosseum Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the starting Arena of the Colosseum. +4039 Advanced Colosseum Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the 6th Arena of the Colosseum. +4040 Master's Innervation 8 Buff Other 93 HealthAccelerating 1000 20 Life Magic 70 Increase caster's natural healing rate by 1000% for 20 seconds. +4041 The Path to Bur 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the world of Bur. +4042 The Winding Path to Bur 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the world of Bur. +4043 Kukuur Hide 7 Buff Other 115 ArmorRaising 350 120 Life Magic 100 Increases the caster's natural armor by 300 points. +4044 Acid Ball 7 Neutral Other 117 AcidMissile 320 -1 War Magic 120 A ball of acid. +4045 Flame Ball 7 Neutral Other 121 FireMissile 320 -1 War Magic 120 A ball of fire. +4046 Lightning Ball 7 Neutral Other 120 ElectricMissile 320 -1 War Magic 120 A ball of lightning. +4047 Artisan Alchemist's Inspiration 1 Buff Other 523 ExtraAlchemySkillRaising2 30 30 Creature Enchantment 10 Increases the target's Alchemy skill by 30 points. Additional spells can be layered over this. +4048 Artisan Cook's Inspiration 1 Buff Other 524 ExtraCookingSkillRaising2 30 30 Creature Enchantment 10 Increases the target's Cooking skill by 30 points. Additional spells can be layered over this. +4049 Artisan Fletcher's Inspiration 1 Buff Other 525 ExtraFletchingSkillRaising2 30 30 Creature Enchantment 10 Increases the target's Fletching skill by 30 points. Additional spells can be layered over this. +4050 Artisan Lockpicker's Inspiration 1 Buff Other 526 ExtraLockpickSkillRaising2 30 30 Creature Enchantment 10 Increases the target's Lockpick skill by 30 points. Additional spells can be layered over this. +4051 Master Alchemist's Inspiration 1 Buff Other 523 ExtraAlchemySkillRaising2 20 30 Creature Enchantment 10 Increases the target's Alchemy skill by 20 points. Additional spells can be layered over this. +4052 Master Cook's Inspiration 1 Buff Other 524 ExtraCookingSkillRaising2 20 30 Creature Enchantment 10 Increases the target's Cooking skill by 20 points. Additional spells can be layered over this. +4053 Master Fletcher's Inspiration 1 Buff Other 525 ExtraFletchingSkillRaising2 20 30 Creature Enchantment 10 Increases the target's Fletching skill by 20 points. Additional spells can be layered over this. +4054 Master Lockpicker's Inspiration 1 Buff Other 526 ExtraLockpickSkillRaising2 20 30 Creature Enchantment 10 Increases the target's Lockpick skill by 20 points. Additional spells can be layered over this. +4055 Journeyman Alchemist's Inspiration 1 Buff Other 523 ExtraAlchemySkillRaising2 10 30 Creature Enchantment 10 Increases the target's Alchemy skill by 10 points. Additional spells can be layered over this. +4056 Journeyman Cook's Inspiration 1 Buff Other 524 ExtraCookingSkillRaising2 10 30 Creature Enchantment 10 Increases the target's Cooking skill by 10 points. Additional spells can be layered over this. +4057 Journeyman Fletcher's Inspiration 1 Buff Other 525 ExtraFletchingSkillRaising2 10 30 Creature Enchantment 10 Increases the target's Fletching skill by 10 points. Additional spells can be layered over this. +4058 Journeyman Lockpicker's Inspiration 1 Buff Other 526 ExtraLockpickSkillRaising2 10 30 Creature Enchantment 10 Increases the target's Lockpick skill by 10 points. Additional spells can be layered over this. +4059 Endurance Other Incantation 8 Buff Other 3 EnduranceRaising 400 3600 Creature Enchantment 70 Increases the target's Endurance by 45 points. +4060 Quickness Other Incantation 8 Buff Other 5 QuicknessRaising 400 3600 Creature Enchantment 70 Increases the target's Quickness by 45 points. +4061 Willpower Other Incantation 8 Buff Other 11 SelfRaising 400 3600 Creature Enchantment 70 Increases the target's Self by 45 points. +4062 Empyrean Aegis 8 Buff Item 160 ArmorValueRaising 500 3600 Item Enchantment 70 Improves a shield or piece of armor's armor value by 500 points. +4063 Exit the Upper Catacomb 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the caverns of the Burun. +4064 Access the Upper Catacomb 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the upper chamber of the Falatacot. +4065 Lower Catacomb Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the lower catacomb of the Falatacot +4066 Access to the Ley Line Cavern 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 This spell transports the target to the Ley Line Cavern. +4067 Mucor Bolt 8 Projectile Other 80 HealthLowering 400 -1 Life Magic 100 Casting this spell creates a bolt of pure mana which sails toward its target. doing 0-100 points directly to health. +4068 Mucor Mana Well 8 Buff Other 527 MucorManaWell 400 10800 Life Magic 10 Consuming this fungus causes your ability to regenerate mana to rapidly increase. Your regeneration rate is increased by 100% (stacking with both normal spells and cantrips) for 3 hours. +4069 Mucor Jolt 8 Debuff Other 80 HealthLowering 400 -1 Life Magic 60 The mucor imbued into this weapon sap a small amount of strength from the target of your blow. dealing 0-70 points of damage directly to health. +4070 Empyrean Mana Absorbtion 3 Buff Other 283 ManaGiverRaising 100 7200 Life Magic 70 Increases maximum mana by 100 points. +4071 Empyrean Stamina Absorbtion 3 Buff Other 281 StaminaGiverRaising 100 7200 Life Magic 70 Increases maximum Stamina by 100 points. +4072 Aurlanaa's Resolve 1 Buff Other 528 StaminaRestoring2 20 3600 Life Magic 60 Increases your Stamina Regeneration Rate by 20%. This effect can be layered with other cantrips. +4073 Empyrean Regeneration 2 Buff Other 257 HealthRestoring 50 3600 Life Magic 60 Increases your Health Regeneration Rate by 50%. This effect can be layered with normal spell effects. +4074 Empyrean Rejuvenation 2 Buff Other 407 StaminaRestoring 50 3600 Life Magic 60 Increases your Stamina Regeneration Rate by 50%. This effect can be layered with normal spell effects. +4075 Empyrean Mana Renewal 2 Buff Other 259 ManaRestoring 50 3600 Life Magic 60 Increases your Mana Regeneration Rate by 50%. This effect can be layered with normal spell effects. +4076 Empyrean Enlightenment 8 Buff Other 53 ArcaneLoreRaising 500 3600 Creature Enchantment 70 Increases the target's Arcane Lore skill by 60 points. +4077 Mana Conversion Mastery Incantation 8 Buff Other 51 ManaConversionRaising 400 7200 Creature Enchantment 80 Increases the target's Mana Conversion skill by 45 points. +4078 Egg 1 Neutral Other 118 BludgeoningMissile 1 -1 War Magic 10 An egg. +4079 Work it Off 8 Neutral Item 214 PortalSending 400 -1 Item Enchantment 150 Teleports the target to the dishwashing room +4080 Paid in Full 8 Neutral Item 214 PortalSending 400 -1 Item Enchantment 150 Teleports the target to the kitchen +4081 Eye of the Tempest 8 Neutral Other 225 ElectricRing 400 -1 War Magic 120 Shoots twelve waves of lightning outward from the caster. Each wave does 60-120 points of electric damage to the first thing it hits. +4082 Big Fire 7 Neutral Other 121 FireMissile 300 -1 War Magic 5 A large ball of fire. +4083 Kresovus' Warren Portal Sending 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 The mysterious chest in Lord Kresovus' chambers has teleported you... +4084 Bur Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 Sends the caster to Bur. +4085 Entering Harraag's Hideout 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4086 Icy Shield 3 Buff Other 379 ArmorIncrease 100 3600 Life Magic 10 Increases the target's natural armor by 100 points. Additional spells can be layered over this. +4087 Armor Breach 7 Debuff Other 116 ArmorLowering 325 10 Life Magic 70 Decreases the target's natural armor by 225 points for 10 seconds. +4088 Withering Poison 8 Debuff Other 94 HealthDecelerating 500 240 Life Magic 70 Decreases the victim's natural healing rate by 75%. +4089 Assassin's Gift 8 Buff Other 65 DeceptionRaising 500 3600 Creature Enchantment 70 Raises the Assassin's Deception Skill by 100. +4090 Scarab's Shell 8 Buff Other 115 ArmorRaising 401 7200 Life Magic 70 Increases the target's natural armor by 260 points. +4091 Spear 7 Neutral Other 241 PiercingStrike 300 -1 War Magic 200 Impales the target for 150-250 points of piercing damage. +4092 Flame Grenade 7 Neutral Other 241 PiercingStrike 300 -1 War Magic 200 Burns the target for 80-240 points of fire damage. +4093 Don't Bite Me 1 Buff Other 401 BludgeonWardProtection 12 780 Life Magic 10 Reduces damage the target takes from Bludgeoning by 12%. Additional spells can be layered over this. +4094 Don't Burn Me 1 Buff Other 287 FireWardProtection 12 780 Life Magic 10 Reduces damage the target takes from Fire by 12%. Additional spells can be layered over this. +4095 Don't Stab Me 1 Buff Other 405 PierceWardProtection 12 780 Life Magic 10 Reduces damage the target takes from Piercing by 12%. Additional spells can be layered over this. +4096 Flame Chain 7 Neutral Other 121 FireMissile 320 -1 War Magic 60 Shoots five bolts of flame in a row at the target. Each bolt does 26-44 points of fire damage to the first thing it hits. This spell is more effective for long range attacks. +4097 Violet Rain 8 Neutral Other 239 ElectricStrike 400 -1 War Magic 120 Rains LOTS of lightning down. +4098 Treasure Room 7 Neutral Item 214 PortalSending 320 -1 Item Enchantment 50 Sends a player to BoneCrunch's Treasure Room. +4099 Strength of Diemos 8 Buff Other 1 StrengthRaising 410 10800 Creature Enchantment 70 Increases the target's Strength by 45 points. +4100 Breath of Renewal 7 Buff Other 67 HealingRaising 300 -1 Life Magic 70 Restores 500-750 points of the caster's Health. +4101 Champion's Skullduggery 7 Debuff Other 38 MeleeDefenseLowering 325 20 Creature Enchantment 70 Decrease the target's Melee Defense skill by 125 points. +4102 Champion's Clever Ruse 7 Debuff Other 42 MagicDefenseLowering 325 20 Creature Enchantment 70 Decrease the target's Magic Defense skill by 125 points. +4103 Black Water Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Portals the user to the lair of the Watcher of the Black Water. +4104 Champion Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to Gladiator Diemos' Arena. +4105 Champion Arena 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to The Master's Arena. +4106 Travel to the Paradox-touched Olthoi Queen's Lair 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Instantly transports the target to the Paradox-touched Olthoi Queen's Lair. +4107 Marrow Blight 8 Buff Other 421 AttributesDecrease 500 10 Creature Enchantment 10 Lowers all of the target's attributes by 10% for 10 seconds. +4108 Apathy 8 Debuff Other 2 StrengthLowering 400 30 Creature Enchantment 1 You feel as though a great weight has settled on you. You can't seem to gather enough strength to do much of anything. +4109 Greater Marrow Blight 8 Buff Other 421 AttributesDecrease 400 30 Creature Enchantment 10 You feel a sharp ache deep in your bones. Lowers all of the targets attributes by 50%. +4110 Poison 7 Debuff Other 80 HealthLowering 350 -1 Life Magic 70 Drains 40-80 points of the target's Health. +4111 Lesser Tusker Hide 6 Buff Other 115 ArmorRaising 250 60 Life Magic 100 Increases your natural armor by 200 points. +4112 Spirit Nullification 8 Debuff Item 155 DamageLowering 400 60 Item Enchantment 70 Your caster's usual glow of elemental power is extinguished. +4113 FoulRing 8 Debuff Other 80 HealthLowering 400 -1 Life Magic 150 A wave of foulness. +4114 Hypnotic Suggestion 8 Debuff Other 38 MeleeDefenseLowering 400 30 Creature Enchantment 70 A sudden urge to cluck like a chicken makes it difficult to defend yourself. Decreases your Melee Defense by 200 points. +4115 Mesmerizing Gaze 8 Buff Other 424 SkillsDecrease 400 60 Creature Enchantment 10 Mudmouth stares deep into your eyes and you find your mind wandering. even with the sounds of battle that surround you. Your skills are lowered by 20%. +4116 Trance 8 Debuff Other 42 MagicDefenseLowering 400 30 Creature Enchantment 70 Just look at that shiny thing over there! It's sooo beautiful. Decreases your Magic Defense by 200 points. +4117 Dark Shield 3 Buff Other 101 AcidProtection 100 60 Life Magic 40 Reduces damage the caster takes from acid damage by 50%. +4118 Dark Shield 3 Buff Other 107 ElectricProtection 100 60 Life Magic 40 Reduces damage the caster takes from lightning damage by 50%. +4119 Dark Shield 3 Buff Other 109 FireProtection 100 60 Life Magic 40 Reduces damage the caster takes from fire damage by 50%. +4120 Dark Shield 3 Buff Other 105 ColdProtection 100 60 Life Magic 40 Reduces damage the caster takes from Cold damage by 50%. +4121 Dark Shield 3 Buff Other 103 BludgeonProtection 100 60 Life Magic 40 Reduces damage the caster takes from bludgeon damage by 50%. +4122 Dark Shield 3 Buff Other 111 PierceProtection 100 60 Life Magic 40 Reduces damage the caster takes from Piercing damage by 50%. +4123 Dark Shield 3 Buff Other 113 SlashProtection 100 60 Life Magic 40 Reduces damage the caster takes from Slashing damage by 50%. +4124 Dark Nanners 8 Neutral Other 235 SlashingWall 400 -1 War Magic 120 Shoots a wall of ten Dark Nanners at the target. Each Dark Nanner does 50-150 points of slashing damage to the first thing it hits. +4125 Dark Nanners 8 Neutral Other 234 PiercingWall 400 -1 War Magic 120 Shoots a wall of ten Dark Nanners at the target. Each Dark Nanner does 50-150 points of piercing damage to the first thing it hits. +4126 Rain of Nanners 8 Neutral Other 241 PiercingStrike 400 -1 War Magic 120 Dark Nanners streak from the sky dealing 100-300 points of piercing damage to the first thing they hit. +4127 Portal Punch 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 A powerful punch which sends the target to Oolutanga's Refuge. +4128 Call of the Mhoire Forge 4 Neutral Item 214 PortalSending 150 -1 Item Enchantment 150 Calls the spirit to the location of the forge of House Mhoire. +4129 Travel to the Prodigal Shadow Child's Lair 8 Neutral Item 214 PortalSending 400 -1 Item Enchantment 50 Instantly transports the target to the Prodigal Shadow Child's Lair. +4130 Travel to the Prodigal Shadow Child's Sanctum 8 Neutral Item 214 PortalSending 400 -1 Item Enchantment 50 Instantly transports the target to the Prodigal Shadow Child's Sanctum. +4131 Spectral Light Weapon Mastery 6 Buff Other 462 AxeRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Light Weapons skill by 150 points for 9 minutes. +4132 Spectral Blood Drinker 6 Buff Item 473 DamageRaisingRare 250 180 Item Enchantment 70 Increases a weapon's damage value by 30 points for 3 minutes. +4133 Spectral Missile Weapon Mastery 6 Buff Other 465 BowRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Missile Weapons skill by 150 points for 9 minutes +4134 Spectral Missile Weapon Mastery 6 Buff Other 465 BowRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Missile_Weapons skill by 150 points for 9 minutes +4135 Spectral Finesse Weapon Mastery 6 Buff Other 472 DaggerRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Finesse Weapons skill by 150 points for 9 minutes. +4136 Spectral Light Weapon Mastery 6 Buff Other 462 AxeRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Light Weapons skill by 150 points for 9 minutes. +4137 Spectral Light Weapon Mastery 6 Buff Other 462 AxeRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Light Weapons skill by 150 points for 9 minutes. +4138 Spectral Light Weapon Mastery 6 Buff Other 462 AxeRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Light Weapons skill by 150 points for 9 minutes. +4139 Spectral Heavy Weapon Mastery 6 Buff Other 508 SwordRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Heavy Weapons skill by 150 points for 9 minutes. +4140 Spectral Missile Weapon Mastery 6 Buff Other 465 BowRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Missile_Weapons skill by 150 points for 9 minutes +4141 Spectral Light Weapon Mastery 6 Buff Other 462 AxeRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Light Weapons skill by 150 points for 9 minutes. +4142 Spectral War Magic Mastery 6 Buff Other 511 WarMagicRaisingRare 250 540 Creature Enchantment 70 Increases the caster's War Magic skill by 150 points for 9 minutes. +4143 Witnessing History 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 4. Stage 4 of Vision Quest +4144 Witnessing History 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 5. Stage 4 of Vision Quest +4145 Crossing the Threshold of Darkness 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 5 Teleports the PC to Branch 1. Stage 6 of Vision Quest +4146 Crossing the Threshold of Darkness 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 5 Teleports the PC to Branch 2. Stage 6 of Vision Quest +4147 Crossing the Threshold of Darkness 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 5 Teleports the PC to Branch 3. Stage 6 of Vision Quest +4148 Crossing the Threshold of Darkness 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 5 Teleports the PC to Branch 4. Stage 6 of Vision Quest +4149 Crossing the Threshold of Darkness 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 5 Teleports the PC to Branch 5. Stage 6 of Vision Quest +4150 Expulsion from Claude's Mind 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 5 Teleports the PC to Aun Kelauri's tent. +4151 Sending to the Other World 3 Neutral Other 214 PortalSending 125 -1 Item Enchantment 50 Teleports the PC to Branch 1. Stage 1 of Vision Quest +4152 Sending to the Other World 3 Neutral Other 214 PortalSending 125 -1 Item Enchantment 50 Teleports the PC to Branch 2. Stage 1 of Vision Quest +4153 Sending to the Other World 3 Neutral Other 214 PortalSending 125 -1 Item Enchantment 50 Teleports the PC to Branch 3. Stage 1 of Vision Quest +4154 Sending to the Other World 3 Neutral Other 214 PortalSending 125 -1 Item Enchantment 50 Teleports the PC to Branch 4. Stage 1 of Vision Quest +4155 Sending to the Other World 3 Neutral Other 214 PortalSending 125 -1 Item Enchantment 50 Teleports the PC to Branch 5. Stage 1 of Vision Quest +4156 Delving into Claude's Mind 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 1. Stage 2 of Vision Quest +4157 Delving into Claude's Mind 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 2. Stage 2 of Vision Quest +4158 Delving into Claude's Mind 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 3. Stage 2 of Vision Quest +4159 Delving into Claude's Mind 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 4. Stage 2 of Vision Quest +4160 Delving into Claude's Mind 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 5. Stage 2 of Vision Quest +4161 Exploring the Past 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 1. Stage 3 of Vision Quest +4162 Exploring the Past 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 2. Stage 3 of Vision Quest +4163 Exploring the Past 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 3. Stage 3 of Vision Quest +4164 Exploring the Past 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 4. Stage 3 of Vision Quest +4165 Exploring the Past 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 5. Stage 3 of Vision Quest +4166 Witnessing History 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 1. Stage 4 of Vision Quest +4167 Witnessing History 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 2. Stage 4 of Vision Quest +4168 Witnessing History 8 Neutral Item 214 PortalSending 900 -1 Item Enchantment 150 Teleports the PC to Branch 3. Stage 4 of Vision Quest +4169 Harbinger Blood Infusion 8 Buff Other 115 ArmorRaising 410 900 Life Magic 100 The Harbinger's blood suffuses your being. increasing your natural armor by 300 points. +4170 Harbinger's Coordination 1 Buff Other 413 CoordinationIncrease2 1 7200 Creature Enchantment 10 Increases Coordination 1 point above spells and most cantrips. +4171 Harbinger's Endurance 1 Buff Other 416 EnduranceIncrease2 1 7200 Creature Enchantment 10 Increases Endurance 1 point above spells and most cantrips. +4172 Harbinger's Focus 1 Buff Other 415 FocusIncrease2 1 7200 Creature Enchantment 10 Increases Focus 1 point above spells and most cantrips. +4173 Harbinger's Quickness 1 Buff Other 522 QuicknessIncrease2 1 7200 Creature Enchantment 10 Increases Quickness 1 point above spells and most cantrips. +4174 Harbinger's Strength 1 Buff Other 414 StrengthIncrease2 1 7200 Creature Enchantment 10 Increases Strength 1 point above spells and most cantrips. +4175 Harbinger's Willpower 1 Buff Other 417 SelfIncrease2 1 7200 Creature Enchantment 10 Increases Willpower 1 point above spells and most cantrips. +4176 Prodigal Harbinger's Lair 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target directly to the Prodigal Harbinger's Lair. +4177 Prodigal Harbinger's Antechamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target to the Prodigal Harbinger's Acid Prep Room. +4178 Prodigal Harbinger's Antechamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target to the Prodigal Harbinger's Cold Prep Room. +4179 Prodigal Harbinger's Antechamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target to the Prodigal Harbinger's Fire Prep Room. +4180 Prodigal Harbinger's Antechamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target to the Prodigal Harbinger's Lightning Prep Room. +4181 Essence Bolt 7 Projectile Other 117 AcidMissile 300 -1 War Magic 120 A dangerous looking ball of acid. +4182 Ball Lightning 8 Neutral Other 120 ElectricMissile 400 -1 War Magic 120 A sparking ball of lightning that deals 400 points of electric damage to the first thing it hits. +4183 Corrosive Veil 8 Neutral Other 117 AcidMissile 400 -1 War Magic 120 A wave of acid that deals 400 points of acid damage to the first thing it hits. +4184 Essence Bolt 7 Projectile Other 121 FireMissile 300 -1 War Magic 120 A dangerous looking ball of flame. +4185 Essence Bolt 7 Projectile Other 119 ColdMissile 300 -1 War Magic 120 A dangerous looking ball of Frost. +4186 Hoar Frost 8 Neutral Other 119 ColdMissile 400 -1 War Magic 120 A strangely spreading frost that deals 400 points of cold damage to the first thing it hits. +4187 Essence Bolt 7 Projectile Other 120 ElectricMissile 300 -1 War Magic 120 A dangerous looking ball of lightning. +4188 Shadowed Flame 8 Neutral Other 121 FireMissile 400 -1 War Magic 120 A dark flame that deals 400 points of fire damage to the first thing it hits. +4189 Harbinger Acid Protection 7 Buff Other 101 AcidProtection 350 120 Life Magic 70 Reduces damage the target takes from acid by 80%. +4190 Harbinger Cold Protection 7 Buff Other 105 ColdProtection 350 120 Life Magic 70 Reduces damage the target takes from Cold by 80%. +4191 Harbinger Flame Protection 7 Buff Other 109 FireProtection 350 120 Life Magic 70 Reduces damage the target takes from fire by 80%. +4192 Harbinger Lightning Protection 7 Buff Other 107 ElectricProtection 350 120 Life Magic 70 Reduces damage the target takes from Lightning by 80%. +4193 Harbinger Magic Defense 8 Buff Other 41 MagicDefenseRaising 400 60 Creature Enchantment 70 Increases the caster's Magic Defense skill by 400 points. +4194 Magical Void 7 Debuff Other 42 MagicDefenseLowering 350 30 Creature Enchantment 70 Decreases the target's Magic Defense skill by 350 points. +4195 Harbinger Melee Defense 8 Buff Other 37 MeleeDefenseRaising 400 60 Creature Enchantment 70 Increases the caster's Melee Defense skill by 400 points. +4196 Harbinger Missile Defense 8 Buff Other 39 MissileDefenseRaising 400 60 Creature Enchantment 70 Increases the caster's Missile Defense skill by 400 points. +4197 Naked to the Elements 7 Debuff Other 38 MeleeDefenseLowering 350 30 Creature Enchantment 70 Decrease the target's Melee Defense skill by 350 points. +4198 Paradox-touched Olthoi Infested Area Recall 5 Utility Self 214 PortalSending 225 -1 Item Enchantment 150 Transports the caster to the area infested by the Paradox-touched Olthoi. +4199 Frozen Armor 8 Buff Other 115 ArmorRaising 401 7200 Life Magic 70 A layer of thin but sturdy frost covers you. increasing your natural armor by 260. +4200 Into the Darkness 5 Neutral Item 214 PortalSending 200 -1 Item Enchantment 50 Teleports the target into a dark zombie filled dungeon. +4201 Numbing Chill 7 Buff Other 106 ColdVulnerability 340 180 Life Magic 70 A numbing chill that acclimates you to cold. +4202 Trevor's Zombie Strike 5 Neutral Other 233 FireWall 200 -1 War Magic 80 Damages the first thing it hits. +4203 Dark Crypt Entrance 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target into the Dark Crypt. +4204 Dark Crypt Entrance 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target into the Dark Crypt. +4205 Dark Crypt Entrance 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target into the Dark Crypt. +4206 Chewy Center 7 Neutral Other 250 Dispel 350 -1 Life Magic 280 Dispels all negative enchantments of level 7 or lower from the caster. +4207 Arena of the Pumpkin King 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Arena of the Pumpkin King. +4208 Spectral Flame 7 Neutral Other 119 ColdMissile 300 -1 War Magic 35 Shoots a bolt of spectral energy dealing 110-180 points of cold damage to the first thing it hits. +4209 Gummy Shield 8 Buff Other 41 MagicDefenseRaising 500 30 Creature Enchantment 70 Boosts the targets magic defense skill by 100 for a short time. +4210 The Jitters 8 Buff Other 39 MissileDefenseRaising 500 30 Creature Enchantment 70 Boosts the targets missile defense by 100 for a short time. +4211 Licorice Leap 8 Buff Other 69 JumpRaising 500 30 Creature Enchantment 100 Boosts casters jump skill by 100 for a short time. +4212 Sticky Melee 8 Buff Other 37 MeleeDefenseRaising 500 30 Creature Enchantment 70 Boosts the targets melee defense skill by 100 for a short time. +4213 Colosseum Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 Sends the caster to the Colosseum. +4214 Return to the Keep 4 Neutral Item 214 PortalSending 150 -1 Item Enchantment 50 This spell returns the caster to Candeth Keep. +4215 Shadow Armor 8 Buff Item 160 ArmorValueRaising 900 3600 Item Enchantment 70 The darkness envelops this armor. offering magical protection from harm. +4216 Frost Wave 7 Neutral Other 224 ColdRing 300 -1 War Magic 80 Shoots eight waves of frost forward from the caster. Each wave does 30-60 points of cold damage to the first thing it hits. +4217 Gourd Guard 8 Buff Item 160 ArmorValueRaising 410 3600 Item Enchantment 70 Improves the Pumpkin Shield's armor value by 300 points. +4218 Knockback 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Knocks the target back from the portal. +4219 Trial of the Arm 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target directly to the Prodigal Harbinger's Lair. +4220 Trial of the Heart 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target directly to the Prodigal Harbinger's Lair. +4221 Spectral Life Magic Mastery 6 Buff Other 488 LifeMagicRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Life Magic skill by 150 points for 9 minutes. +4222 Chambers Beneath 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target directly to the chambers beneath Linvak Tukal. +4223 Trials Graduation Chamber 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Portals the target to the Trials Graduation Chamber. +4224 Trial of the Mind 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Portals the target to Linvak Tukal's Trial of the Mind. +4225 Trials of the Arm. Mind and Heart 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Sends the target to the Trials of the Arm. Mind and Heart. +4226 Epic Endurance 1 Buff Other 263 EnduranceIncrease 25 780 Creature Enchantment 10 Increases the target's Endurance by 25 points. Additional spells can be layered over this. +4227 Epic Willpower 1 Buff Other 271 SelfIncrease 25 780 Creature Enchantment 10 Increases the target's Self by 25 points. Additional spells can be layered over this. +4228 Awakening 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 You awake as if from a dream. +4229 Journey Into the Past 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 This spell transports the target into the Apparition Black Death Catacomb. +4230 Bael'Zharon Dream Sending 7 Neutral Item 214 PortalSending 300 -1 Item Enchantment 50 Teleports the player into the dream realm of the Ithaenc Quiddity Seed. +4231 Leadership Mastery Other Incantation 7 Buff Other 71 LeadershipRaising 325 7200 Creature Enchantment 80 Increases the target's Leadership skill by 45 points. +4232 Epic Leadership 1 Buff Other 293 LeadershipObedienceRaising 25 780 Creature Enchantment 10 Increases the target's Leadership skill by 25 points. Additional spells can be layered over this. +4233 Aerbax Recall Center Platform 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4234 Aerbax Recall East Platform 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4235 Aerbax Recall North Platform 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4236 Aerbax Recall South Platform 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4237 Aerbax Recall West Platform 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4238 Aerbax Expulsion 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Portals the target off Aerbax's Platforms. +4239 Ring of Death 8 Projectile Other 80 HealthLowering 400 -1 Life Magic 150 A large explosion dealing massive ammounts of damage to everyone it hits. +4240 Aerbax's Magic Shield 8 Buff Other 41 MagicDefenseRaising 800 180 Creature Enchantment 70 Increases the caster's Magic Defense by 900 points. +4241 Aerbax Magic Shield Down 8 Buff Other 41 MagicDefenseRaising 800 180 Creature Enchantment 70 Nullifies Aerbax's Magic Shield. +4242 Aerbax's Melee Shield 8 Buff Other 37 MeleeDefenseRaising 800 180 Creature Enchantment 70 Increases the caster's Melee Defense by 900 points. +4243 Aerbax Melee Shield Down 8 Buff Other 37 MeleeDefenseRaising 800 180 Creature Enchantment 70 Nullifies Aerbax's Melee Shield. +4244 Aerbax's Missile Shield 8 Buff Other 39 MissileDefenseRaising 800 180 Creature Enchantment 70 Increases the caster's Missile Defense by 900 points. +4245 Aerbax Missile Shield Down 8 Buff Other 39 MissileDefenseRaising 800 180 Creature Enchantment 70 Nullifies Aerbax's Missile Shield. +4246 MeteorStrike 8 Neutral Other 239 ElectricStrike 400 -1 War Magic 1 Rains LOTS of red lightning down. +4247 Tanada Battle Burrows Portal Sending 7 Utility Self 214 PortalSending 300 -1 Item Enchantment 50 This spell transports the target to the Tanada Battle Burrows. +4248 Shroud Cabal North Outpost Sending 7 Neutral Item 214 PortalSending 300 -1 Item Enchantment 50 This spell sends the player to the Shroud Cabal Northern Outpost +4249 Shroud Cabal South Outpost Sending 7 Neutral Item 214 PortalSending 300 -1 Item Enchantment 50 This spell sends the player to the Shroud Cabal Southern Outpost +4250 Aerbax's Platform 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Portals the target to the Aerbax's Platform. +4251 Jester's Boot 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4252 Entrance to the Jester's Cell 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4253 Entrance to the Jester's Cell 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4254 Jester's Prison Hallway 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4255 Jester's Prison Entryway 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4256 Jester Recall 1 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4257 Jester Recall 2 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4258 Jester Recall 3 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4259 Jester Recall 4 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4260 Jester Recall 5 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4261 Jester Recall 6 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4262 Jester Recall 7 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4263 Jester Recall 8 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4264 Arcane Death 7 Neutral Other 122 PiercingMissile 300 -1 War Magic 35 Shoots a pyramid at the target. The pyramid does 250-500 points of piercing damage to the first thing it hits. +4265 Arcane Pyramid 7 Neutral Other 122 PiercingMissile 300 -1 War Magic 35 Shoots a pyramid at the target. The pyramid does 130-185 points of piercing damage to the first thing it hits. +4266 Blood Bolt 7 Projectile Other 80 HealthLowering 300 -1 Life Magic 70 Shoots a bolt of blood at your target that does 100-200 points of health damage. +4267 Cow 7 Neutral Other 118 BludgeoningMissile 300 -1 War Magic 35 Shoots a Cow at your target. Cow does 100-200 points of Bludgeoning damage. +4268 Fireworks 7 Neutral Other 121 FireMissile 300 -1 War Magic 35 Shoots fireworks at your target. The fireworks do 100-200 points of Fire damage. +4269 Present 7 Neutral Other 118 BludgeoningMissile 300 -1 War Magic 35 Shoots a Present at your target. Present does 100-200 points of slashing damage. +4270 Table 7 Neutral Other 118 BludgeoningMissile 300 -1 War Magic 35 Shoots a Table at your target. Table does 100-200 points of piercing damage. +4271 Acid Whip 5 Neutral Other 229 AcidWall 200 -1 War Magic 80 Sends a line of eight balls of acid towards the target. Each ball does 60-120 points of acid damage to the first thing it hits. The wall is created 2 meters in front of the caster. +4272 Razor Whip 5 Neutral Other 235 SlashingWall 200 -1 War Magic 80 Sends a line of eight whirling blades towards the target. Each ball does 60-120 points of slashing damage to the first thing it hits. The wall is created 2 meters in front of the caster. +4273 Spray of Coins 5 Neutral Other 230 BludgeoningWall 200 -1 War Magic 80 Sends a wall of thirty coins towards the target. Each coin does 1-30 points of bludgeoning damage to the first thing it hits. The wall is created 2 meters in front of the caster. +4274 Flame Whip 5 Neutral Other 233 FireWall 200 -1 War Magic 80 Sends a line of eight balls of fire towards the target. Each ball does 60-120 points of fire damage to the first thing it hits. The wall is created 2 meters in front of the caster. +4275 Electric Whip 5 Neutral Other 232 ElectricWall 200 -1 War Magic 80 Sends a line of eight bolts of lightning towards the target. Each ball does 60-120 points of electric damage to the first thing it hits. The wall is created 2 meters in front of the caster. +4276 Jester's Malevolent Eye 7 Neutral Other 223 BludgeoningRing 300 -1 War Magic 80 Shoots a beam of light at your target. It does 50-150 points of undefined damage. +4277 Jester's Prison Access 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4278 Rytheran's Library Portal Sending 7 Utility Self 214 PortalSending 300 -1 Item Enchantment 50 This spell sends the player to Rytheran's Library. +4280 Deck of Hands Favor 1 Buff Other 413 CoordinationIncrease2 15 600 Creature Enchantment 10 Increases the target's Coordination by 15 points. This spell stacks with normal spells and cantrip spells. +4281 Deck of Eyes Favor 1 Buff Other 415 FocusIncrease2 15 600 Creature Enchantment 10 Increases the target's Focus by 15 points. This spell stacks with normal spells and cantrip spells. +4282 Arcane Death 7 Neutral Other 122 PiercingMissile 300 -1 War Magic 35 Shoots a pyramid at the target. The pyramid does 250-500 points of piercing damage to the first thing it hits. +4283 Arcane Death 7 Neutral Other 122 PiercingMissile 300 -1 War Magic 35 Shoots a pyramid at the target. The pyramid does 250-500 points of piercing damage to the first thing it hits. +4284 Harm Self 7 Harm Self 80 HealthLowering 325 -1 Life Magic 70 Drains 100000 points of the caster's Health. +4285 Harm Self 7 Harm Self 80 HealthLowering 325 -1 Life Magic 70 Drains 900000 points of the caster's Health. +4286 Harm Self 7 Harm Self 80 HealthLowering 325 -1 Life Magic 70 Drains 300000 points of the caster's Health. +4287 Harm Self 7 Harm Self 80 HealthLowering 325 -1 Life Magic 70 Drains 700000 points of the caster's Health. +4288 Harm Self 7 Harm Self 80 HealthLowering 325 -1 Life Magic 70 Drains 500000 points of the caster's Health. +4289 Access the Messenger's Sanctuary 8 Neutral Item 214 PortalSending 1000 -1 Item Enchantment 150 Transports the target to the hidden cavern where Falatacot messengers tend to hide. +4290 Incantation of Armor Other 8 Buff Other 115 ArmorRaising 400 5400 Life Magic 80 Increases the target's natural armor by 250 points. +4291 Incantation of Armor Self 8 Buff Self 115 ArmorRaising 400 5400 Life Magic 80 Increases the caster's natural armor by 250 points. +4292 Incantation of Bafflement Other 8 Debuff Other 10 FocusLowering 400 300 Creature Enchantment 80 Decreases the target's Focus by 45 points. +4293 Incantation of Bafflement Self 8 Debuff Self 10 FocusLowering 400 300 Creature Enchantment 80 Decreases the caster's Focus by 45 points. +4294 Incantation of Clumsiness Other 8 Debuff Other 8 CoordinationLowering 400 300 Creature Enchantment 80 Decreases the target's Coordination by 45 points. +4295 Incantation of Clumsiness Self 8 Debuff Self 8 CoordinationLowering 400 300 Creature Enchantment 80 Decreases the caster's Coordination by 45 points. +4296 Incantation of Coordination Other 8 Buff Other 7 CoordinationRaising 400 5400 Creature Enchantment 80 Increases the target's Coordination by 45 points. +4297 Incantation of Coordination Self 8 Buff Self 7 CoordinationRaising 400 5400 Creature Enchantment 80 Increases the caster's Coordination by 45 points. +4298 Incantation of Endurance Other 8 Buff Other 3 EnduranceRaising 400 5400 Creature Enchantment 80 Increases the target's Endurance by 45 points. +4299 Incantation of Endurance Self 8 Buff Self 3 EnduranceRaising 400 5400 Creature Enchantment 80 Increases the caster's Endurance by 45 points. +4300 Incantation of Enfeeble Other 8 Debuff Other 82 StaminaLowering 400 -1 Life Magic 80 Drains 66-131 points of the target's Stamina. +4301 Incantation of Enfeeble Self 8 Debuff Self 82 StaminaLowering 400 -1 Life Magic 80 Drains 50-100 points of the caster's Stamina. +4302 Incantation of Feeblemind Other 8 Debuff Other 12 SelfLowering 400 300 Creature Enchantment 80 Decreases the target's Self by 45 points. +4303 Incantation of Feeblemind Self 8 Debuff Self 12 SelfLowering 400 300 Creature Enchantment 80 Decreases the caster's Self by 45 points. +4304 Incantation of Focus Other 8 Buff Other 9 FocusRaising 400 5400 Creature Enchantment 80 Increases the target's Focus by 45 points. +4305 Incantation of Focus Self 8 Buff Self 9 FocusRaising 400 5400 Creature Enchantment 80 Increases the caster's Focus by 45 points. +4306 Incantation of Frailty Other 8 Debuff Other 4 EnduranceLowering 400 300 Creature Enchantment 80 Decreases the target's Endurance by 45 points. +4307 Incantation of Frailty Self 8 Debuff Self 4 EnduranceLowering 400 300 Creature Enchantment 80 Decreases the caster's Endurance by 45 points. +4308 Incantation of Harm Other 8 Debuff Other 80 HealthLowering 400 -1 Life Magic 80 Drains 50-95 points of the target's Health. +4309 Incantation of Harm Self 8 Debuff Self 80 HealthLowering 400 -1 Life Magic 80 Drains 48-90 points of the caster's Health. +4310 Incantation of Heal Other 8 Buff Other 79 HealthRaising 400 -1 Life Magic 80 Restores 90-180 points of the target's Health. +4311 Incantation of Heal Self 8 Buff Self 67 HealingRaising 400 -1 Life Magic 80 Restores 90-180 points of the caster's Health. +4312 Incantation of Imperil Other 8 Debuff Other 116 ArmorLowering 400 300 Life Magic 80 Decreases the target's natural armor by 225 points. +4313 Incantation of Imperil Self 8 Debuff Self 116 ArmorLowering 400 300 Life Magic 80 Decreases the caster's natural armor by 225 points. +4314 Incantation of Mana Boost Other 8 Buff Other 83 ManaRaising 400 -1 Life Magic 80 Restores 51-100 points of the target's Mana. +4315 Incantation of Mana Boost Self 8 Buff Self 83 ManaRaising 400 -1 Life Magic 80 Restores 51-100 points of the caster's Mana. +4316 Incantation of Mana Drain Other 8 Debuff Other 84 ManaLowering 400 -1 Life Magic 80 Drains 52-95 points of the target's Mana. +4317 Incantation of Mana Drain Self 8 Debuff Self 84 ManaLowering 400 -1 Life Magic 80 Drains 48-90 points of the caster's Mana. +4318 Incantation of Quickness Other 8 Buff Other 5 QuicknessRaising 400 5400 Creature Enchantment 80 Increases the target's Quickness by 45 points. +4319 Incantation of Quickness Self 8 Buff Self 5 QuicknessRaising 400 5400 Creature Enchantment 80 Increases the caster's Quickness by 45 points. +4320 Incantation of Revitalize Other 8 Buff Other 81 StaminaRaising 400 -1 Life Magic 80 Restores 125-250 points of the target's Stamina. +4321 Incantation of Revitalize Self 8 Buff Self 81 StaminaRaising 400 -1 Life Magic 80 Restores 125-250 points of the caster's Stamina. +4322 Incantation of Slowness Other 8 Debuff Other 6 QuicknessLowering 400 300 Creature Enchantment 80 Decreases the target's Quickness by 45 points. +4323 Incantation of Slowness Self 8 Debuff Self 6 QuicknessLowering 400 300 Creature Enchantment 80 Decreases the caster's Quickness by 45 points. +4324 Incantation of Strength Other 8 Buff Other 1 StrengthRaising 400 5400 Creature Enchantment 80 Increases the target's Strength by 45 points. +4325 Incantation of Strength Self 8 Buff Self 1 StrengthRaising 400 5400 Creature Enchantment 80 Increases the caster's Strength by 45 points. +4326 Incantation of Weakness Other 8 Debuff Other 2 StrengthLowering 400 300 Creature Enchantment 80 Decreases the target's Strength by 45 points. +4327 Incantation of Weakness Self 8 Debuff Self 2 StrengthLowering 400 300 Creature Enchantment 80 Decrease the caster's Strength by 45 points. +4328 Incantation of Willpower Other 8 Buff Other 11 SelfRaising 400 5400 Creature Enchantment 80 Increases the target's Self by 45 points. +4329 Incantation of Willpower Self 8 Buff Self 11 SelfRaising 400 5400 Creature Enchantment 80 Increases the caster's Self by 45 points. +4330 Incantation of Nullify All Magic Other 8 Neutral Other 250 Dispel 400 -1 Life Magic 320 Dispels all negative enchantments of level 8 or lower from the target. +4331 Incantation of Nullify All Magic Self 8 Neutral Self 250 Dispel 400 -1 Life Magic 320 Dispels all negative enchantments of level 8 or lower from the caster. +4332 Incantation of Nullify All Magic Other 8 Neutral Other 250 Dispel 400 -1 Life Magic 340 Dispels 2-6 positive enchantments of level 8 or lower from the target. +4333 Incantation of Nullify All Magic Self 8 Neutral Self 250 Dispel 400 -1 Life Magic 340 Dispels all positive enchantments of level 8 or lower from the caster. +4334 Incantation of Nullify All Magic Other 8 Neutral Other 250 Dispel 400 -1 Life Magic 340 Dispels all enchantments of level 8 or lower from the target. +4335 Incantation of Nullify All Magic Self 8 Neutral Self 250 Dispel 400 -1 Life Magic 340 Dispels all enchantments of level 8 or lower from the caster. +4336 Incantation of Nullify Creature Magic Other 8 Neutral Other 250 Dispel 400 -1 Creature Enchantment 320 Dispels 3-6 negative Creature Magic enchantments of level 8 or lower from the target. +4337 Incantation of Nullify Creature Magic Self 8 Neutral Self 250 Dispel 400 -1 Creature Enchantment 320 Dispels 3-6 negative Creature Magic enchantments of level 8 or lower from the caster. +4338 Incantation of Nullify Creature Magic Other 8 Neutral Other 250 Dispel 400 -1 Creature Enchantment 340 Dispels 2-6 positive Creature Magic enchantments of level 6 or lower from the target. +4339 Incantation of Nullify Creature Magic Self 8 Neutral Self 250 Dispel 400 -1 Creature Enchantment 340 Dispels 2-6 positive Creature Magic enchantments of level 6 or lower from the caster. +4340 Incantation of Nullify Creature Magic Other 8 Neutral Other 250 Dispel 400 -1 Creature Enchantment 340 Dispels 2-6 Creature Magic enchantments of level 6 or lower from the target. +4341 Incantation of Nullify Creature Magic Self 8 Neutral Self 250 Dispel 400 -1 Creature Enchantment 340 Dispels 2-6 Creature Magic enchantments of level 6 or lower from the caster. +4342 Incantation of Nullify Item Magic 8 Neutral Item 250 Dispel 400 -1 Item Enchantment 320 Dispels 3-6 negative Item Magic enchantments of level 8 or lower from the target. +4343 Incantation of Nullify Item Magic 8 Neutral Item 250 Dispel 400 -1 Item Enchantment 340 Dispels 2-6 positive Item Magic enchantments of level 6 or lower from the target. +4344 Incantation of Nullify Item Magic 8 Neutral Item 250 Dispel 400 -1 Item Enchantment 340 Dispels 2-6 Item Magic enchantments of level 6 or lower from the target. +4345 Incantation of Nullify Life Magic Other 8 Neutral Other 250 Dispel 400 -1 Life Magic 320 Dispels 3-6 negative Life Magic enchantments of level 8 or lower from the target. +4346 Incantation of Nullify Life Magic Self 8 Neutral Self 250 Dispel 400 -1 Life Magic 320 Dispels 3-6 negative Life Magic enchantments of level 8 or lower from the caster. +4347 Incantation of Nullify Life Magic Other 8 Neutral Other 250 Dispel 400 -1 Life Magic 340 Dispels 2-6 positive Life Magic enchantments of level 8 or lower from the target. +4348 Incantation of Nullify Life Magic Self 8 Neutral Self 250 Dispel 400 -1 Life Magic 340 Dispels 2-6 positive Life Magic enchantments of level 8 or lower from the caster. +4349 Incantation of Nullify Life Magic Other 8 Neutral Other 250 Dispel 400 -1 Life Magic 340 Dispels 2-6 Life Magic enchantments of level 8 or lower from the target. +4350 Incantation of Nullify Life Magic Self 8 Neutral Self 250 Dispel 400 -1 Life Magic 340 Dispels 2-6 Life Magic enchantments of level 8 or lower from the caster. +4351 Incantation of Greater Alacrity of the Conclave 8 Buff Other 7 CoordinationRaising 400 5400 Creature Enchantment 80 Enhances the Coordination of all Fellowship members by 45 points for 60 minutes. +4352 Incantation of Greater Vivify the Conclave 8 Buff Other 3 EnduranceRaising 400 5400 Creature Enchantment 80 Enhances the Endurance of all Fellowship members by 45 points for 60 minutes. +4353 Incantation of Greater Acumen of the Conclave 8 Buff Other 9 FocusRaising 400 5400 Creature Enchantment 80 Enhances the Focus of all Fellowship members by 45 points for 60 minutes. +4354 Incantation of Greater Speed the Conclave 8 Buff Other 5 QuicknessRaising 400 5400 Creature Enchantment 80 Enhances the Quickness of all Fellowship members by 45 points for 60 minutes. +4355 Incantation of Greater Volition of the Conclave 8 Buff Other 11 SelfRaising 400 5400 Creature Enchantment 80 Enhances the Self of all Fellowship members by 45 points for 60 minutes. +4356 Incantation of Greater Empowering the Conclave 8 Buff Other 1 StrengthRaising 400 5400 Creature Enchantment 80 Enhances the Strength of all Fellowship members by 45 points for 60 minutes. +4357 Incantation of Greater Corrosive Ward 8 Buff Other 101 AcidProtection 400 5400 Life Magic 80 Reduces damage all fellowship members take from acid by 70% +4358 Incantation of Greater Scythe Ward 8 Buff Other 113 SlashProtection 400 5400 Life Magic 80 Reduces damage all fellowship members take from Slashing by 70% +4359 Incantation of Greater Flange Ward 8 Buff Other 103 BludgeonProtection 400 5400 Life Magic 80 Reduces damage all fellowship members from Bludgeoning by 70% +4360 Incantation of Greater Frore Ward 8 Buff Other 105 ColdProtection 400 5400 Life Magic 80 Reduces damage all fellowship members take from Cold by 70% +4361 Incantation of Greater Inferno Ward 8 Buff Other 109 FireProtection 400 5400 Life Magic 80 Reduces damage all fellowship members take from fire by 70% +4362 Incantation of Greater Voltaic Ward 8 Buff Other 107 ElectricProtection 400 5400 Life Magic 80 Reduces damage all fellowship members take from Lightning by 70% +4363 Incantation of Greater Lance Ward 8 Buff Other 111 PierceProtection 400 5400 Life Magic 80 Reduces damage all fellowship members take from Piercing by 70% +4364 Incantation of Greater Endless Well 8 Buff Other 97 ManaAccelerating 400 5400 Life Magic 80 Enhances the understanding of the ebb and flow of mana. All fellowship members received a 115% increase to their nautral mana recovery rate. +4365 Incantation of Greater Soothing Wind 8 Buff Other 93 HealthAccelerating 400 5400 Life Magic 80 Enhances the blood flow and aids in knitting wounds closed. All fellowship member receive a 115% increase to their natural health recovery rate. +4366 Incantation of Greater Golden Wind 8 Buff Other 95 StaminaAccelerating 400 5400 Life Magic 80 Enhances the intake of air and utilization of energy. All fellowship member receive a 115% increase to their natural stamina recovery rate. +4367 Incantation of Greater Conjurant Chant 8 Buff Other 43 CreatureEnchantmentRaising 400 5400 Creature Enchantment 80 Enhances the Creature Enchantment skill of all Fellowship members by 45 points for 60 minutes. +4368 Incantation of Warden of the Clutch 8 Buff Other 39 MissileDefenseRaising 400 5400 Creature Enchantment 80 Enhances the Missile Defense of all Fellowship members by 45 points for 60 minutes. +4369 Incantation of Guardian of the Clutch 8 Buff Other 37 MeleeDefenseRaising 400 5400 Creature Enchantment 80 Enhances the Melee Defense of all Fellowship members by 45 points for 60 minutes. +4370 Incantation of Greater Artificant Chant 8 Buff Other 45 ItemEnchantmentRaising 400 5400 Creature Enchantment 80 Enhances the Item Enchantment skill of all Fellowship members by 45 points for 60 minutes. +4371 Incantation of Greater Vitaeic Chant 8 Buff Other 47 LifeMagicRaising 400 5400 Creature Enchantment 80 Enhances the Life Magic skill of all Fellowship members by 45 points for 60 minutes. +4372 Incantation of Sanctifier of the Clutch 8 Buff Other 41 MagicDefenseRaising 400 5400 Creature Enchantment 80 Enhances the Magic Defense of all Fellowship members by 45 points for 60 minutes. +4373 Incantation of Greater Conveyic Chant 8 Buff Other 51 ManaConversionRaising 400 5400 Creature Enchantment 80 Enhances the Mana Conversion skill of all Fellowship members by 45 points for 60 minutes. +4374 Incantation of Greater Hieromantic Chant 8 Buff Other 49 WarMagicRaising 400 5400 Creature Enchantment 80 Enhances the War Magic skill of all Fellowship members by 45 points for 60 minutes. +4375 Incantation of Blossom Black Firework OUT 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots out a Black Firework. +4376 Incantation of Blossom Blue Firework OUT 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots out a Blue Firework. +4377 Incantation of Blossom Green Firework OUT 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots out a Green Firework. +4378 Incantation of Blossom Orange Firework OUT 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots out a Orange Firework. +4379 Incantation of Blossom Purple Firework OUT 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots out a Purple Firework. +4380 Incantation of Blossom Red Firework OUT 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots out a Red Firework. +4381 Incantation of Blossom White Firework OUT 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots out a White Firework. +4382 Incantation of Blossom Yellow Firework OUT 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots out a Yellow Firework. +4383 Incantation of Blossom Black Firework UP 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots a Black Firework straight up. +4384 Incantation of Blossom Blue Firework UP 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots a Blue Firework straight up. +4385 Incantation of Blossom Green Firework UP 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots a Green Firework straight up. +4386 Incantation of Blossom Orange Firework UP 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots a Orange Firework straight up. +4387 Incantation of Blossom Purple Firework UP 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots a Purple Firework straight up. +4388 Incantation of Blossom Red Firework UP 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots a Red Firework straight up. +4389 Incantation of Blossom White Firework UP 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots a White Firework straight up. +4390 Incantation of Blossom Yellow Firework UP 8 Neutral Other 409 Fireworks 400 -1 War Magic 80 Shoots a Yellow Firework straight up. +4391 Incantation of Acid Bane 8 Buff Item 162 AcidResistanceRaising 400 5400 Item Enchantment 80 Increases a shield or piece of armor's resistance to acid damage by 200%. Target yourself to cast this spell on all of your equipped armor. +4392 Incantation of Acid Lure 8 Debuff Item 163 AcidResistanceLowering 400 300 Item Enchantment 80 Decreases a shield or piece of armor's resistance to acid damage by 200%. +4393 Incantation of Blade Bane 8 Buff Item 174 SlashResistanceRaising 400 5400 Item Enchantment 80 Increases a shield or piece of armor's resistance to slashing damage by 200%. Target yourself to cast this spell on all of your equipped armor. +4394 Incantation of Blade Lure 8 Debuff Item 175 SlashResistanceLowering 400 300 Item Enchantment 80 Decreases a shield or piece of armor's resistance to slashing damage by 200%. +4395 Aura of Incantation of Blood Drinker Self 8 Buff Self 154 DamageRaising 400 5400 Item Enchantment 80 Increases a weapon's damage value by 24 points. +4396 Incantation of Blood Loather 8 Debuff Item 155 DamageLowering 400 300 Item Enchantment 80 Decreases a weapon's damage value by 24 points. +4397 Incantation of Bludgeon Bane 8 Buff Item 164 BludgeonResistanceRaising 400 5400 Item Enchantment 80 Increases a shield or piece of armor's resistance to bludgeoning damage by 200%. Target yourself to cast this spell on all of your equipped armor. +4398 Incantation of Bludgeon Lure 8 Debuff Item 165 BludgeonResistanceLowering 400 300 Item Enchantment 80 Decreases a shield or piece of armor's resistance to bludgeoning damage by 200%. +4399 Incantation of Brittlemail 8 Debuff Item 161 ArmorValueLowering 400 300 Item Enchantment 80 Worsens a shield or piece of armor's armor value by 300 points. +4400 Aura of Incantation of Defender Self 7 Buff Self 156 DefenseModRaising 350 5400 Item Enchantment 80 Increases the Melee Defense skill modifier of a weapon or magic caster by 20%. +4401 Incantation of Flame Bane 8 Buff Item 170 FireResistanceRaising 400 5400 Item Enchantment 80 Increases a shield or piece of armor's resistance to fire damage by 200%. Target yourself to cast this spell on all of your equipped armor. +4402 Incantation of Flame Lure 8 Debuff Item 171 FireResistanceLowering 400 300 Item Enchantment 80 Decreases a shield or piece of armor's resistance to fire damage by 200%. +4403 Incantation of Frost Bane 8 Buff Item 166 ColdResistanceRaising 400 5400 Item Enchantment 80 Increases a shield or piece of armor's resistance to cold damage by 200%. Target yourself to cast this spell on all of your equipped armor. +4404 Incantation of Frost Lure 8 Debuff Item 167 ColdResistanceLowering 400 300 Item Enchantment 80 Decreases a shield or piece of armor's resistance to cold damage by 200%. +4405 Aura of Incantation of Heart Seeker Self 8 Buff Self 152 AttackModRaising 400 5400 Item Enchantment 80 Increases a weapon's Attack Skill modifier by 20.0 percentage points. +4406 Incantation of Hermetic Void 8 Debuff Item 194 ManaConversionModLowering 400 300 Item Enchantment 80 Decreases a magic casting implement's mana conversion bonus by 80%. +4407 Incantation of Impenetrability 8 Buff Item 160 ArmorValueRaising 400 5400 Item Enchantment 80 Improves a shield or piece of armor's armor value by 240 points. Target yourself to cast this spell on all of your equipped armor. +4408 Incantation of Leaden Weapon 8 Debuff Item 159 WeaponTimeLowering 400 300 Item Enchantment 80 Worsens a weapon's speed by 80 points. +4409 Incantation of Lightning Bane 8 Buff Item 168 ElectricResistanceRaising 400 5400 Item Enchantment 80 Increases a shield or piece of armor's resistance to electric damage by 200%. Target yourself to cast this spell on all of your equipped armor. +4410 Incantation of Lightning Lure 8 Debuff Item 169 ElectricResistanceLowering 400 300 Item Enchantment 80 Decreases a shield or piece of armor's resistance to electric damage by 200%. +4411 Incantation of Lure Blade 8 Debuff Item 157 DefenseModLowering 400 300 Item Enchantment 80 Decreases the Melee Defense skill modifier of a weapon or magic caster by 20%. +4412 Incantation of Piercing Bane 8 Buff Item 172 PierceResistanceRaising 400 5400 Item Enchantment 80 Increases a shield or piece of armor's resistance to piercing damage by 200%. Target yourself to cast this spell on all of your equipped armor. +4413 Incantation of Piercing Lure 8 Debuff Item 173 PierceResistanceLowering 400 300 Item Enchantment 80 Decreases a shield or piece of armor's resistance to piercing damage by 200%. +4414 Aura of Incantation of Spirit Drinker Self 8 Buff Self 695 SpellDamageRaising 400 5400 Item Enchantment 80 Increases the elemental damage bonus of an elemental magic caster by 8%. +4415 Incantation of Spirit Loather 8 Debuff Item 155 DamageLowering 400 300 Item Enchantment 80 Decreases the elemental damage bonus of an elemental magic caster by 8%. +4416 Incantation of Strengthen Lock 8 Buff Item 192 LockpickResistanceRaising 400 300 Item Enchantment 80 Increases a lock's resistance to picking by 250 points. +4417 Aura of Incantation of Swift Killer Self 8 Buff Self 158 WeaponTimeRaising 400 5400 Item Enchantment 80 Improves a weapon's speed by 80 points. +4418 Aura of Incantation of Hermetic Link Self 8 Buff Self 195 ManaConversionModRaising 400 5400 Item Enchantment 80 Increases a magic casting implement's mana conversion bonus by 80%. +4419 Incantation of Turn Blade 8 Debuff Item 153 AttackModLowering 400 300 Item Enchantment 80 Decreases a weapon's Attack Skill modifier by 20.0 percentage points. +4420 Incantation of Weaken Lock 8 Debuff Item 193 LockpickResistanceLowering 400 300 Item Enchantment 80 Decreases a lock's resistance to picking by 250 points. +4421 Incantation of Acid Arc 8 Neutral Other 117 AcidMissile 400 -1 War Magic 40 Shoots a stream of acid at the target. The stream does 142-204 points of acid damage to the first thing it hits. +4422 Incantation of Blade Arc 8 Neutral Other 123 SlashingMissile 400 -1 War Magic 40 Shoots a magical blade at the target. The bolt does 142-204 points of slashing damage to the first thing it hits. +4423 Incantation of Flame Arc 8 Neutral Other 121 FireMissile 400 -1 War Magic 40 Shoots a bolt of flame at the target. The bolt does 142-204 points of fire damage to the first thing it hits. +4424 Incantation of Force Arc 8 Neutral Other 122 PiercingMissile 400 -1 War Magic 40 Shoots a bolt of force at the target. The bolt does 142-204 points of piercing damage to the first thing it hits. +4425 Incantation of Frost Arc 8 Neutral Other 119 ColdMissile 400 -1 War Magic 40 Shoots a bolt of cold at the target. The bolt does 142-204 points of cold damage to the first thing it hits. +4426 Incantation of Lightning Arc 8 Neutral Other 120 ElectricMissile 400 -1 War Magic 40 Shoots a bolt of lighting at the target. The bolt does 142-204 points of electrical damage to the first thing it hits. +4427 Incantation of Shock Arc 8 Neutral Other 118 BludgeoningMissile 400 -1 War Magic 40 Shoots a shock wave at the target. The wave does 142-204 points of bludgeoning damage to the first thing it hits. +4428 Incantation of Martyr's Hecatomb 8 Debuff Other 80 HealthLowering 400 -1 Life Magic 80 Drains one-quarter of the caster's health into a bolt of energy. When struck by the bolt. the target's health is reduced by 200% of the amount drained. +4429 Incantation of Martyr's Blight 8 Debuff Other 84 ManaLowering 400 -1 Life Magic 80 Drains one-quarter of the caster's mana into a bolt of energy. When struck by the bolt. the target's mana is reduced by 200% of the amount drained. +4430 Incantation of Martyr's Tenacity 8 Debuff Other 82 StaminaLowering 400 -1 Life Magic 80 Drains one-quarter of the caster's stamina into a bolt of energy. When struck by the bolt. the target's stamina is reduced by 200% of the amount drained. +4431 Incantation of Acid Blast 8 Projectile Other 131 AcidBurst 400 -1 War Magic 40 Shoots five streams of acid outward from the caster. Each stream does 47-94 points of acid damage to the first thing it hits. +4432 Incantation of Acid Streak 8 Projectile Other 243 AcidStreak 400 -1 War Magic 80 Sends a stream of acid streaking towards the target. The stream does 47-94 points of acid damage to the first thing it hits. +4433 Incantation of Acid Stream 8 Neutral Other 117 AcidMissile 400 -1 War Magic 40 Shoots a stream of acid at the target. The stream does 142-204 points of acid damage to the first thing it hits. +4434 Incantation of Acid Volley 8 Projectile Other 207 AcidVolley 400 -1 War Magic 40 Shoots five streams of acid toward the target. Each stream does 47-94 points of acid damage to the first thing it hits. +4435 Incantation of Blade Blast 8 Projectile Other 137 SlashingBurst 400 -1 War Magic 40 Shoots five whirling blades outward from the caster. Each blade does 47-94 points of slashing damage to the first thing it hits. +4436 Incantation of Blade Volley 8 Projectile Other 213 BladeVolley 400 -1 War Magic 40 Shoots five whirling blades toward the target. Each blade does 47-94 points of Slashing damage to the first thing it hits. +4437 Incantation of Bludgeoning Volley 8 Projectile Other 208 BludgeoningVolley 400 -1 War Magic 40 Shoots five shock waves toward the target. Each wave does 47-94 points of bludgeoning damage to the first thing it hits. +4438 Incantation of Flame Blast 8 Projectile Other 135 FireBurst 400 -1 War Magic 40 Shoots five bolts of flame outward from the caster. Each bolt does 47-94 points of fire damage to the first thing it hits. +4439 Incantation of Flame Bolt 8 Projectile Other 121 FireMissile 400 -1 War Magic 40 Shoots a bolt of flame at the target. The bolt does 142-204 points of fire damage to the first thing it hits. +4440 Incantation of Flame Streak 8 Projectile Other 247 FireStreak 400 -1 War Magic 80 Sends a bolt of flame streaking towards the target. The bolt does 47-94 points of fire damage to the first thing it hits. +4441 Incantation of Flame Volley 8 Projectile Other 211 FlameVolley 400 -1 War Magic 40 Shoots five bolts of flame toward the target. Each bolt does 47-94 points of fire damage to the first thing it hits. +4442 Incantation of Force Blast 8 Projectile Other 136 PiercingBurst 400 -1 War Magic 40 Shoots five force bolts outward from the caster. Each bolt does 47-94 points of piercing damage to the first thing it hits. +4443 Incantation of Force Bolt 8 Projectile Other 122 PiercingMissile 400 -1 War Magic 40 Shoots a bolt of force at the target. The bolt does 142-204 points of piercing damage to the first thing it hits. +4444 Incantation of Force Streak 8 Projectile Other 248 PiercingStreak 400 -1 War Magic 80 Sends a bolt of force streaking towards the target. The bolt does 47-94 points of piercing damage to the first thing it hits. +4445 Incantation of Force Volley 8 Projectile Other 212 ForceVolley 400 -1 War Magic 40 Shoots five bolts of force toward the target. Each bolt does 47-94 points of piercing damage to the first thing it hits. +4446 Incantation of Frost Blast 8 Projectile Other 133 ColdBurst 400 -1 War Magic 40 Shoots five bolts of frost outward from the caster. Each bolt does 47-94 points of cold damage to the first thing it hits. +4447 Incantation of Frost Bolt 8 Projectile Other 119 ColdMissile 400 -1 War Magic 40 Shoots a bolt of cold at the target. The bolt does 142-204 points of cold damage to the first thing it hits. +4448 Incantation of Frost Streak 8 Projectile Other 245 ColdStreak 400 -1 War Magic 80 Sends a bolt of cold streaking towards the target. The bolt does 47-94 points of cold damage to the first thing it hits. +4449 Incantation of Frost Volley 8 Projectile Other 209 FrostVolley 400 -1 War Magic 40 Shoots five bolts of frost toward the target. Each bolt does 47-94 points of cold damage to the first thing it hits. +4450 Incantation of Lightning Blast 8 Projectile Other 134 ElectricBurst 400 -1 War Magic 40 Shoots five bolts of lightning outward from the caster. Each bolt does 47-94 points of electric damage to the first thing it hits. +4451 Incantation of Lightning Bolt 8 Projectile Other 120 ElectricMissile 400 -1 War Magic 40 Shoots a bolt of lighting at the target. The bolt does 142-204 points of electrical damage to the first thing it hits. +4452 Incantation of Lightning Streak 8 Projectile Other 246 ElectricStreak 400 -1 War Magic 80 Sends a bolt of lighting streaking towards the target. The bolt does 47-94 points of electrical damage to the first thing it hits. +4453 Incantation of Lightning Volley 8 Projectile Other 210 LightningVolley 400 -1 War Magic 40 Shoots five bolts of lightning toward the target. Each bolt does 47-94 points of electric damage to the first thing it hits. +4454 Incantation of Shock Blast 8 Projectile Other 132 BludgeoningBurst 400 -1 War Magic 40 Shoots five shock waves outward from the caster. Each wave does 47-94 points of damage to the first thing it hits. +4455 Incantation of Shock Wave 8 Neutral Other 118 BludgeoningMissile 400 -1 War Magic 40 Shoots a shock wave at the target. The wave does 142-204 points of bludgeoning damage to the first thing it hits. +4456 Incantation of Shock Wave Streak 8 Projectile Other 244 BludgeoningStreak 400 -1 War Magic 80 Sends a shock wave streaking towards the target. The wave does 47-94 points of bludgeoning damage to the first thing it hits. +4457 Incantation of Whirling Blade 8 Neutral Other 123 SlashingMissile 400 -1 War Magic 40 Shoots a magical blade at the target. The bolt does 142-204 points of slashing damage to the first thing it hits. +4458 Incantation of Whirling Blade Streak 8 Projectile Other 249 SlashingStreak 400 -1 War Magic 80 Sends a magical blade streaking towards the target. The bolt does 47-94 points of slashing damage to the first thing it hits. +4459 Incantation of Acid Protection Other 8 Buff Other 101 AcidProtection 400 5400 Life Magic 80 Reduces damage the target takes from acid by 68% +4460 Incantation of Acid Protection Self 8 Buff Self 101 AcidProtection 400 5400 Life Magic 80 Reduces damage the caster takes from acid by 68% +4461 Incantation of Blade Protection Other 8 Buff Other 113 SlashProtection 400 5400 Life Magic 80 Reduces damage the target takes from Slashing by 68% +4462 Incantation of Blade Protection Self 8 Buff Self 113 SlashProtection 400 5400 Life Magic 80 Reduces damage the caster takes from Slashing by 68% +4463 Incantation of Bludgeoning Protection Other 8 Buff Other 103 BludgeonProtection 400 5400 Life Magic 80 Reduces damage the target takes from Bludgeoning by 68% +4464 Incantation of Bludgeoning Protection Self 8 Buff Self 103 BludgeonProtection 400 5400 Life Magic 80 Reduces damage the caster takes from Bludgeoning by 68% +4465 Incantation of Cold Protection Other 8 Buff Other 105 ColdProtection 400 5400 Life Magic 80 Reduces damage the target takes from Cold by 68% +4466 Incantation of Cold Protection Self 8 Buff Self 105 ColdProtection 400 5400 Life Magic 80 Reduces damage the caster takes from Cold by 68% +4467 Incantation of Fire Protection Other 8 Buff Other 109 FireProtection 400 5400 Life Magic 80 Reduces damage the target takes from fire by 68% +4468 Incantation of Fire Protection Self 8 Buff Self 109 FireProtection 400 5400 Life Magic 80 Reduces damage the caster takes from Fire by 68% +4469 Incantation of Lightning Protection Other 8 Buff Other 107 ElectricProtection 400 5400 Life Magic 80 Reduces damage the target takes from Lightning by 68% +4470 Incantation of Lightning Protection Self 8 Buff Self 107 ElectricProtection 400 5400 Life Magic 80 Reduces damage the caster takes from Lightning by 68% +4471 Incantation of Piercing Protection Other 8 Buff Other 111 PierceProtection 400 5400 Life Magic 80 Reduces damage the target takes from Piercing by 68% +4472 Incantation of Piercing Protection Self 8 Buff Self 111 PierceProtection 400 5400 Life Magic 80 Reduces damage the caster takes from Piercing by 68% +4473 Incantation of Acid Vulnerability Other 8 Debuff Other 102 AcidVulnerability 400 300 Life Magic 80 Increases damage the target takes from acid by 210%. +4474 Incantation of Acid Vulnerability Self 8 Debuff Self 102 AcidVulnerability 400 300 Life Magic 80 Increases damage the caster takes from acid by 210%. +4475 Incantation of Blade Vulnerability Other 8 Debuff Other 114 SlashVulnerability 400 300 Life Magic 80 Increases damage the target takes from Slashing by 210%. +4476 Incantation of Blade Vulnerability Self 8 Debuff Self 114 SlashVulnerability 400 300 Life Magic 80 Increases damage the caster takes from Slashing by 210%. +4477 Incantation of Bludgeoning Vulnerability Other 8 Debuff Other 104 BludgeonVulnerability 400 300 Life Magic 80 Increases damage the target takes from Bludgeoning by 210%. +4478 Incantation of Bludgeoning Vulnerability Self 8 Debuff Self 104 BludgeonVulnerability 400 300 Life Magic 80 Increases damage the caster takes from Bludgeoning by 210%. +4479 Incantation of Cold Vulnerability Other 8 Debuff Other 106 ColdVulnerability 400 300 Life Magic 80 Increases damage the target takes from Cold by 210%. +4480 Incantation of Cold Vulnerability Self 8 Debuff Self 106 ColdVulnerability 400 300 Life Magic 80 Increases damage the caster takes from Cold by 210%. +4481 Incantation of Fire Vulnerability Other 8 Debuff Other 110 FireVulnerability 400 300 Life Magic 80 Increases damage the target takes from Fire by 210%. +4482 Incantation of Fire Vulnerability Self 8 Debuff Self 110 FireVulnerability 400 300 Life Magic 80 Increases damage the caster takes from Fire by 210%. +4483 Incantation of Lightning Vulnerability Other 8 Debuff Other 108 ElectricVulnerability 400 300 Life Magic 80 Increases damage the target takes from Lightning by 210%. +4484 Incantation of Lightning Vulnerability Self 8 Debuff Self 108 ElectricVulnerability 400 300 Life Magic 80 Increases damage the caster takes from Lightning by 210%. +4485 Incantation of Piercing Vulnerability Other 8 Debuff Other 112 PierceVulnerability 400 300 Life Magic 80 Increases damage the target takes from Piercing by 210%. +4486 Incantation of Piercing Vulnerability Self 8 Debuff Self 112 PierceVulnerability 400 300 Life Magic 80 Increases damage the caster takes from Piercing by 210%. +4487 Incantation of Exhaustion Other 8 Debuff Other 96 StaminaDecelerating 400 300 Life Magic 80 Decreases the rate at which the target regains Stamina by 75%. +4488 Incantation of Exhaustion Self 8 Debuff Self 96 StaminaDecelerating 400 300 Life Magic 80 Decreases the rate at which the caster regains Stamina by 75%. +4489 Incantation of Fester Other 8 Debuff Other 94 HealthDecelerating 400 300 Life Magic 80 Decrease target's natural healing rate by 75%. +4490 Incantation of Fester Self 8 Debuff Self 94 HealthDecelerating 400 300 Life Magic 80 Decrease caster's natural healing rate by 75%. +4491 Incantation of Mana Depletion Other 8 Debuff Other 98 ManaDecelerating 400 300 Life Magic 80 Decreases target's natural mana rate by 75%. +4492 Incantation of Mana Depletion Self 8 Debuff Self 98 ManaDecelerating 400 300 Life Magic 80 Decreases caster's natural mana rate by 75%. +4493 Incantation of Mana Renewal Other 8 Buff Other 97 ManaAccelerating 400 5400 Life Magic 80 Increases the target's natural mana rate by 145%. +4494 Incantation of Mana Renewal Self 8 Buff Self 97 ManaAccelerating 400 5400 Life Magic 80 Increases the caster's natural mana rate by 145%. +4495 Incantation of Regeneration Other 8 Buff Other 93 HealthAccelerating 400 5400 Life Magic 80 Increase target's natural healing rate by 145%. +4496 Incantation of Regeneration Self 8 Buff Self 93 HealthAccelerating 400 5400 Life Magic 80 Increase caster's natural healing rate by 145%. +4497 Incantation of Rejuvenation Other 8 Buff Other 95 StaminaAccelerating 400 5400 Life Magic 80 Increases the rate at which the target regains Stamina by 145%. +4498 Incantation of Rejuvenation Self 8 Buff Self 95 StaminaAccelerating 400 5400 Life Magic 80 Increases the rate at which the caster regains Stamina by 145%. +4499 Incantation of Arcanum Salvaging Self 8 Buff Self 435 SalvagingRaising 400 5400 Creature Enchantment 80 Increases the caster's Salvaging skill by 45 points. +4500 Incantation of Arcanum Enlightenment 8 Buff Other 435 SalvagingRaising 400 5400 Creature Enchantment 80 Increases the target's Salvaging skill by 45 points. +4501 Incantation of Nuhmudira's Wisdom 8 Buff Other 435 SalvagingRaising 400 5400 Creature Enchantment 80 Increases the caster's Salvaging skill by 45 points. +4502 Incantation of Nuhmudira Enlightenment 8 Buff Other 435 SalvagingRaising 400 5400 Creature Enchantment 80 Increases the target's Salvaging skill by 45 points. +4503 Incantation of Alchemy Ineptitude Other 8 Debuff Other 220 AlchemyLowering 400 300 Creature Enchantment 80 Decreases the target's Alchemy skill by 45 points. +4504 Incantation of Alchemy Ineptitude Self 8 Debuff Self 220 AlchemyLowering 400 300 Creature Enchantment 80 Decreases the caster's Alchemy skill by 45 points. +4505 Incantation of Alchemy Mastery Other 8 Buff Other 221 AlchemyRaising 400 5400 Creature Enchantment 80 Increases the target's Alchemy skill by 45 points. +4506 Incantation of Alchemy Mastery Self 8 Buff Self 221 AlchemyRaising 400 5400 Creature Enchantment 80 Increases the caster's Alchemy skill by 45 points. +4507 Incantation of Arcane Benightedness Other 8 Debuff Other 54 ArcaneLoreLowering 400 300 Creature Enchantment 80 Decreases the target's Arcane Lore skill by 45 points. +4508 Incantation of Arcane Benightedness Self 8 Debuff Self 54 ArcaneLoreLowering 400 300 Creature Enchantment 80 Decreases the caster's Arcane Lore skill by 45 points. +4509 Incantation of Arcane Enlightenment Other 8 Buff Other 53 ArcaneLoreRaising 400 5400 Creature Enchantment 80 Increases the target's Arcane Lore skill by 45 points. +4510 Incantation of Arcane Enlightenment Self 8 Buff Self 53 ArcaneLoreRaising 400 5400 Creature Enchantment 80 Increases the caster's Arcane Lore skill by 45 points. +4511 Incantation of Armor Tinkering Expertise Other 8 Buff Other 55 AppraiseArmorRaising 400 5400 Creature Enchantment 80 Increases the target's Armor Tinkering skill by 45 points. +4512 Incantation of Armor Tinkering Expertise Self 8 Buff Self 55 AppraiseArmorRaising 400 5400 Creature Enchantment 80 Increases the caster's Armor Tinkering skill by 45 points. +4513 Incantation of Armor Tinkering Ignorance Other 8 Debuff Other 56 AppraiseArmorLowering 400 300 Creature Enchantment 80 Decreases the target's Armor Tinkering skill by 45 points. +4514 Incantation of Armor Tinkering Ignorance Self 8 Debuff Self 56 AppraiseArmorLowering 400 300 Creature Enchantment 80 Decreases the caster's Armor Tinkering skill by 45 points. +4515 Incantation of Light Weapon Ineptitude Other 8 Debuff Other 18 AxeLowering 400 300 Creature Enchantment 80 Decreases the target's Light Weapons skill by 45 points. +4516 Incantation of Light Weapon Ineptitude Self 8 Debuff Self 18 AxeLowering 400 300 Creature Enchantment 80 Decreases the caster's Light Weapons skill by 45 points. +4517 Incantation of Light Weapon Mastery Other 8 Buff Other 17 AxeRaising 400 5400 Creature Enchantment 80 Increases the target's Light Weapons skill by 45 points. +4518 Incantation of Light Weapon Mastery Self 8 Buff Self 17 AxeRaising 400 5400 Creature Enchantment 80 Increases the caster's Light Weapons skill by 45 points. +4519 Incantation of Missile Weapon Ineptitude Other 8 Debuff Other 20 BowLowering 400 300 Creature Enchantment 80 Decreases the target's Missile Weapons skill by 45 points. +4520 Incantation of Missile Weapon Ineptitude Self 8 Debuff Self 20 BowLowering 400 300 Creature Enchantment 80 Decreases the caster's Missile Weapons skill by 45 points. +4521 Incantation of Missile Weapon Mastery Other 8 Buff Other 19 BowRaising 400 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 45 points. +4522 Incantation of Missile Weapon Mastery Self 8 Buff Self 19 BowRaising 400 5400 Creature Enchantment 80 Increases the caster's Missile Weapons skill by 45 points. +4523 Incantation of Cooking Ineptitude Other 8 Debuff Other 217 CookingLowering 400 300 Creature Enchantment 80 Decreases the target's Cooking skill by 45 points. +4524 Incantation of Cooking Ineptitude Self 8 Debuff Self 217 CookingLowering 400 300 Creature Enchantment 80 Decreases the caster's Cooking skill by 45 points. +4525 Incantation of Cooking Mastery Other 8 Buff Other 216 CookingRaising 400 5400 Creature Enchantment 80 Increases the target's Cooking skill by 45 points. +4526 Incantation of Cooking Mastery Self 8 Buff Self 216 CookingRaising 400 5400 Creature Enchantment 80 Increases the caster's Cooking skill by 45 points. +4527 Incantation of Creature Enchantment Ineptitude Other 8 Debuff Other 44 CreatureEnchantmentLowering 400 300 Creature Enchantment 80 Decreases the target's Creature Enchantment skill by 45 points. +4528 Incantation of Creature Enchantment Ineptitude Self 8 Debuff Self 44 CreatureEnchantmentLowering 400 300 Creature Enchantment 80 Decreases the caster's Creature Enchantment skill by 45 points. +4529 Incantation of Creature Enchantment Mastery Other 8 Buff Other 43 CreatureEnchantmentRaising 400 5400 Creature Enchantment 80 Increases the target's Creature Enchantment skill by 45 points. +4530 Incantation of Creature Enchantment Mastery Self 8 Buff Self 43 CreatureEnchantmentRaising 400 5400 Creature Enchantment 80 Increases the caster's Creature Enchantment skill by 45 points. +4531 Incantation of Missile Weapon Ineptitude Other 8 Debuff Other 20 BowLowering 400 300 Creature Enchantment 80 Decreases the target's Missile Weapons skill by 45 points. +4532 Incantation of Missile Weapon Ineptitude Self 8 Debuff Self 20 BowLowering 400 300 Creature Enchantment 80 Decreases the caster's Missile Weapons skill by 45 points. +4533 Incantation of Missile Weapon Mastery Other 8 Buff Other 19 BowRaising 400 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 45 points. +4534 Incantation of Missile Weapon Mastery Self 8 Buff Self 19 BowRaising 400 5400 Creature Enchantment 80 Increases the caster's Missile Weapons skill by 45 points. +4535 Incantation of Finesse Weapon Ineptitude Other 8 Debuff Other 24 DaggerLowering 400 300 Creature Enchantment 80 Decreases the target's Finesse Weapons skill by 45 points. +4536 Incantation of Finesse Weapon Ineptitude Self 8 Debuff Self 24 DaggerLowering 400 300 Creature Enchantment 80 Decreases the caster's Finesse Weapons skill by 45 points. +4537 Incantation of Finesse Weapon Mastery Other 8 Buff Other 23 DaggerRaising 400 5400 Creature Enchantment 80 Increases the target's Finesse Weapons skill by 45 points. +4538 Incantation of Finesse Weapon Mastery Self 8 Buff Self 23 DaggerRaising 400 5400 Creature Enchantment 80 Increases the caster's Finesse Weapons skill by 45 points. +4539 Incantation of Deception Ineptitude Other 8 Debuff Other 66 DeceptionLowering 400 300 Creature Enchantment 80 Decreases the target's Deception skill by 45 points. +4540 Incantation of Deception Ineptitude Self 8 Debuff Self 66 DeceptionLowering 400 300 Creature Enchantment 80 Decreases the caster's Deception skill by 45 points. +4541 Incantation of Deception Mastery Other 8 Buff Other 65 DeceptionRaising 400 5400 Creature Enchantment 80 Increases the target's Deception skill by 45 points. +4542 Incantation of Deception Mastery Self 8 Buff Self 65 DeceptionRaising 400 5400 Creature Enchantment 80 Increases the caster's Deception skill by 45 points. +4543 Incantation of Defenselessness Other 8 Debuff Other 40 MissileDefenseLowering 400 300 Creature Enchantment 80 Decreases the target's Missile Defense skill by 45 points. +4544 Incantation of Defenselessness Self 8 Debuff Self 40 MissileDefenseLowering 400 300 Creature Enchantment 80 Decreases the caster's Missile Defense skill by 45 points. +4545 Incantation of Faithlessness Other 8 Debuff Other 76 LoyaltyLowering 400 300 Creature Enchantment 80 Decreases the target's Loyalty skill by 45 points. +4546 Incantation of Faithlessness Self 8 Debuff Self 76 LoyaltyLowering 400 300 Creature Enchantment 80 Decreases the caster's Loyalty skill by 45 points. +4547 Incantation of Fealty Other 8 Buff Other 75 LoyaltyRaising 400 5400 Creature Enchantment 80 Increases the target's Loyalty skill by 45 points. +4548 Incantation of Fealty Self 8 Buff Self 75 LoyaltyRaising 400 5400 Creature Enchantment 80 Increases the caster's Loyalty skill by 45 points. +4549 Incantation of Fletching Ineptitude Other 8 Debuff Other 219 FletchingLowering 400 300 Creature Enchantment 80 Decreases the target's Fletching skill by 45 points. +4550 Incantation of Fletching Ineptitude Self 8 Debuff Self 219 FletchingLowering 400 300 Creature Enchantment 80 Decreases the caster's Fletching skill by 45 points. +4551 Incantation of Fletching Mastery Other 8 Buff Other 218 FletchingRaising 400 5400 Creature Enchantment 80 Increases the target's Fletching skill by 45 points. +4552 Incantation of Fletching Mastery Self 8 Buff Self 218 FletchingRaising 400 5400 Creature Enchantment 80 Increases the caster's Fletching skill by 45 points. +4553 Incantation of Healing Ineptitude Other 8 Debuff Other 68 HealingLowering 400 300 Creature Enchantment 80 Decreases the target's Healing skill by 45 points. +4554 Incantation of Healing Ineptitude Self 8 Debuff Self 68 HealingLowering 400 300 Creature Enchantment 80 Decreases the caster's Healing skill by 45 points. +4555 Incantation of Healing Mastery Other 8 Buff Other 67 HealingRaising 400 5400 Creature Enchantment 80 Increases the target's Healing skill by 45 points. +4556 Incantation of Healing Mastery Self 8 Buff Self 67 HealingRaising 400 5400 Creature Enchantment 80 Increases the caster's Healing skill by 45 points. +4557 Incantation of Impregnability Other 8 Buff Other 39 MissileDefenseRaising 400 5400 Creature Enchantment 80 Increases the target's Missile Defense skill by 45 points. +4558 Incantation of Impregnability Self 8 Buff Self 39 MissileDefenseRaising 400 5400 Creature Enchantment 80 Increases the caster's Missile Defense skill by 45 points. +4559 Incantation of Invulnerability Other 8 Buff Other 37 MeleeDefenseRaising 400 5400 Creature Enchantment 80 Increases the target's Melee Defense skill by 45 points. +4560 Incantation of Invulnerability Self 8 Buff Self 37 MeleeDefenseRaising 400 5400 Creature Enchantment 80 Increases the caster's Melee Defense skill by 45 points. +4561 Incantation of Item Enchantment Ineptitude Other 8 Debuff Other 46 ItemEnchantmentLowering 400 300 Creature Enchantment 80 Decreases the target's Item Enchantment skill by 45 points. +4562 Incantation of Item Enchantment Ineptitude Self 8 Debuff Self 46 ItemEnchantmentLowering 400 300 Creature Enchantment 80 Decreases the caster's Item Enchantment skill by 45 points. +4563 Incantation of Item Enchantment Mastery Other 8 Buff Other 45 ItemEnchantmentRaising 400 5400 Creature Enchantment 80 Increases the target's Item Enchantment skill by 45 points. +4564 Incantation of Item Enchantment Mastery Self 8 Buff Self 45 ItemEnchantmentRaising 400 5400 Creature Enchantment 80 Increases the caster's Item Enchantment skill by 45 points. +4565 Incantation of Item Tinkering Expertise Other 8 Buff Other 57 AppraiseItemRaising 400 5400 Creature Enchantment 80 Increases the target's Item Tinkering skill by 45 points. +4566 Incantation of Item Tinkering Expertise Self 8 Buff Self 57 AppraiseItemRaising 400 5400 Creature Enchantment 80 Increases the caster's Item Tinkering skill by 45 points. +4567 Incantation of Item Tinkering Ignorance Other 8 Debuff Other 58 AppraiseItemLowering 400 300 Creature Enchantment 80 Decreases the target's Item Tinkering skill by 45 points. +4568 Incantation of Item Tinkering Ignorance Self 8 Debuff Self 58 AppraiseItemLowering 400 300 Creature Enchantment 80 Decreases the caster's Item Tinkering skill by 45 points. +4569 Incantation of Jumping Ineptitude Other 8 Debuff Other 70 JumpLowering 400 300 Creature Enchantment 80 Decreases the target's Jump skill by 45 points. +4570 Incantation of Jumping Ineptitude Self 8 Debuff Self 70 JumpLowering 400 300 Creature Enchantment 80 Decreases the caster's Jump skill by 45 points. +4571 Incantation of Jumping Mastery Other 8 Buff Other 69 JumpRaising 400 5400 Creature Enchantment 80 Increases the target's Jump skill by 45 points. +4572 Incantation of Jumping Mastery Self 8 Buff Self 69 JumpRaising 400 5400 Creature Enchantment 80 Increases the caster's Jump skill by 45 points. +4573 Incantation of Leaden Feet Other 8 Debuff Other 78 RunLowering 400 300 Creature Enchantment 80 Decreases the target's Run skill by 45 points. +4574 Incantation of Leaden Feet Self 8 Debuff Self 78 RunLowering 400 300 Creature Enchantment 80 Decreases the caster's Run skill by 45 points. +4575 Incantation of Leadership Ineptitude Other 8 Debuff Other 72 LeadershipLowering 400 300 Creature Enchantment 80 Decreases the target's Leadership skill by 45 points. +4576 Incantation of Leadership Ineptitude Self 8 Debuff Self 72 LeadershipLowering 400 300 Creature Enchantment 80 Decreases the caster's Leadership skill by 45 points. +4577 Incantation of Leadership Mastery Other 8 Buff Other 71 LeadershipRaising 400 5400 Creature Enchantment 80 Increases the target's Leadership skill by 45 points. +4578 Incantation of Leadership Mastery Self 8 Buff Self 71 LeadershipRaising 400 5400 Creature Enchantment 80 Increases the caster's Leadership skill by 45 points. +4579 Incantation of Life Magic Ineptitude Other 8 Debuff Other 48 LifeMagicLowering 400 300 Creature Enchantment 80 Decreases the target's Life Magic skill by 45 points. +4580 Incantation of Life Magic Ineptitude Self 8 Debuff Self 48 LifeMagicLowering 400 300 Creature Enchantment 80 Decreases the caster's Life Magic skill by 45 points. +4581 Incantation of Life Magic Mastery Other 8 Buff Other 47 LifeMagicRaising 400 5400 Creature Enchantment 80 Increases the target's Life Magic skill by 45 points. +4582 Incantation of Life Magic Mastery Self 8 Buff Self 47 LifeMagicRaising 400 5400 Creature Enchantment 80 Increases the caster's Life Magic skill by 45 points. +4583 Incantation of Lockpick Ineptitude Other 8 Debuff Other 74 LockpickLowering 400 300 Creature Enchantment 80 Decreases the target's Lockpick skill by 45 points. +4584 Incantation of Lockpick Ineptitude Self 8 Debuff Self 74 LockpickLowering 400 300 Creature Enchantment 80 Decreases the caster's Lockpick skill by 45 points. +4585 Incantation of Lockpick Mastery Other 8 Buff Other 73 LockpickRaising 400 5400 Creature Enchantment 80 Increases the target's Lockpick skill by 45 points. +4586 Incantation of Lockpick Mastery Self 8 Buff Self 73 LockpickRaising 400 5400 Creature Enchantment 80 Increases the caster's Lockpick skill by 45 points. +4587 Incantation of Light Weapon Ineptitude Other 8 Debuff Other 18 AxeLowering 400 300 Creature Enchantment 80 Decreases the target's Light Weapons skill by 45 points. +4588 Incantation of Light Weapon Ineptitude Self 8 Debuff Self 18 AxeLowering 400 300 Creature Enchantment 80 Decreases the caster's Light Weapons skill by 45 points. +4589 Incantation of Light Weapon Mastery Other 8 Buff Other 17 AxeRaising 400 5400 Creature Enchantment 80 Increases the target's Light Weapons skill by 45 points. +4590 Incantation of Light Weapon Mastery Self 8 Buff Self 17 AxeRaising 400 5400 Creature Enchantment 80 Increases the caster's Light Weapons skill by 45 points. +4591 Incantation of Magic Item Tinkering Expertise Other 8 Buff Other 59 AppraiseMagicItemRaising 400 5400 Creature Enchantment 80 Increases the target's Magic Item Tinkering skill by 45 points. +4592 Incantation of Magic Item Tinkering Expertise Self 8 Buff Self 59 AppraiseMagicItemRaising 400 5400 Creature Enchantment 80 Increases the caster's Magic Item Tinkering skill by 45 points. +4593 Incantation of Magic Item Tinkering Ignorance Other 8 Debuff Other 60 AppraiseMagicItemLowering 400 300 Creature Enchantment 80 Decreases the target's Magic Item Tinkering skill by 45 points. +4594 Incantation of Magic Item Tinkering Ignorance Self 8 Debuff Self 60 AppraiseMagicItemLowering 400 300 Creature Enchantment 80 Decreases the caster's Magic Item Tinkering skill by 45 points. +4595 Incantation of Magic Resistance Other 8 Buff Other 41 MagicDefenseRaising 400 5400 Creature Enchantment 80 Increases the target's Magic Defense skill by 45 points. +4596 Incantation of Magic Resistance Self 8 Buff Self 41 MagicDefenseRaising 400 5400 Creature Enchantment 80 Increases the caster's Magic Defense skill by 45 points. +4597 Incantation of Magic Yield Other 8 Debuff Other 42 MagicDefenseLowering 400 300 Creature Enchantment 80 Decreases the target's Magic Defense skill by 45 points. +4598 Incantation of Magic Yield Self 8 Debuff Self 42 MagicDefenseLowering 400 300 Creature Enchantment 80 Decreases the caster's Magic Defense skill by 45 points. +4599 Incantation of Mana Conversion Ineptitude Other 8 Debuff Other 52 ManaConversionLowering 400 300 Creature Enchantment 80 Decreases the target's Mana Conversion skill by 45 points. +4600 Incantation of Mana Conversion Ineptitude Self 8 Debuff Self 52 ManaConversionLowering 400 300 Creature Enchantment 80 Decreases the caster's Mana Conversion skill by 45 points. +4601 Incantation of Mana Conversion Mastery Other 8 Buff Other 51 ManaConversionRaising 400 5400 Creature Enchantment 80 Increases the target's Mana Conversion skill by 45 points. +4602 Incantation of Mana Conversion Mastery Self 8 Buff Self 51 ManaConversionRaising 400 5400 Creature Enchantment 80 Increases the caster's Mana Conversion skill by 45 points. +4603 Incantation of Monster Attunement Other 8 Buff Other 63 AssessMonsterRaising 400 5400 Creature Enchantment 80 Increases the target's Assess Monster skill by 45 points. +4604 Incantation of Monster Attunement Self 8 Buff Self 63 AssessMonsterRaising 400 5400 Creature Enchantment 80 Increases the caster's Assess Monster skill by 45 points. +4605 Incantation of Monster Unfamiliarity Other 8 Debuff Other 64 AssessMonsterLowering 400 300 Creature Enchantment 80 Decreases the target's Assess Monster skill by 45 points. +4606 Incantation of Monster Unfamiliarity Self 8 Debuff Self 64 AssessMonsterLowering 400 300 Creature Enchantment 80 Decreases the caster's Assess Monster skill by 45 points. +4607 Incantation of Person Attunement Other 8 Buff Other 205 AssessPersonRaising 400 5400 Creature Enchantment 80 Increases the target's Assess Person skill by 45 points. +4608 Incantation of Person Attunement Self 8 Buff Self 205 AssessPersonRaising 400 5400 Creature Enchantment 80 Increases the caster's Assess Person skill by 45 points. +4609 Incantation of Person Unfamiliarity Other 8 Debuff Other 206 AssessPersonLowering 400 300 Creature Enchantment 80 Decreases the target's Assess Person skill by 45 points. +4610 Incantation of Person Unfamiliarity Self 8 Debuff Self 206 AssessPersonLowering 400 300 Creature Enchantment 80 Decreases the caster's Assess Person skill by 45 points. +4611 Incantation of Light Weapon Ineptitude Other 8 Debuff Other 18 AxeLowering 400 300 Creature Enchantment 80 Decreases the target's Light Weapons skill by 45 points. +4612 Incantation of Light Weapon Ineptitude Self 8 Debuff Self 18 AxeLowering 400 300 Creature Enchantment 80 Decreases the caster's Light Weapons skill by 45 points. +4613 Incantation of Light Weapon Mastery Other 8 Buff Other 17 AxeRaising 400 5400 Creature Enchantment 80 Increases the target's Light Weapons skill by 45 points. +4614 Incantation of Light Weapon Mastery Self 8 Buff Self 17 AxeRaising 400 5400 Creature Enchantment 80 Increases the caster's Light Weapons skill by 45 points. +4615 Incantation of Sprint Other 8 Buff Other 77 RunRaising 400 5400 Creature Enchantment 80 Increases the target's Run skill by 45 points. +4616 Incantation of Sprint Self 8 Buff Self 77 RunRaising 400 5400 Creature Enchantment 80 Increases the caster's Run skill by 45 points. +4617 Incantation of Light Weapon Ineptitude Other 8 Debuff Other 18 AxeLowering 400 300 Creature Enchantment 80 Decreases the target's Light Weapons skill by 45 points. +4618 Incantation of Light Weapon Ineptitude Self 8 Debuff Self 18 AxeLowering 400 300 Creature Enchantment 80 Decreases the caster's Light Weapons skill by 45 points. +4619 Incantation of Light Weapon Mastery Other 8 Buff Other 17 AxeRaising 400 5400 Creature Enchantment 80 Increases the target's Light Weapons skill by 45 points. +4620 Incantation of Light Weapon Mastery Self 8 Buff Self 17 AxeRaising 400 5400 Creature Enchantment 80 Increases the caster's Light Weapons skill by 45 points. +4621 Incantation of Heavy Weapon Ineptitude Other 8 Debuff Other 32 SwordLowering 400 300 Creature Enchantment 80 Decreases the target's Heavy Weapons skill by 45 points. +4622 Incantation of Heavy Weapon Ineptitude Self 8 Debuff Self 32 SwordLowering 400 300 Creature Enchantment 80 Decreases the caster's Heavy Weapons skill by 45 points. +4623 Incantation of Heavy Weapon Mastery Other 8 Buff Other 31 SwordRaising 400 5400 Creature Enchantment 80 Increases the target's Heavy Weapons skill by 45 points. +4624 Incantation of Heavy Weapon Mastery Self 8 Buff Self 31 SwordRaising 400 5400 Creature Enchantment 80 Increases the caster's Heavy Weapons skill by 45 points. +4625 Incantation of Missile Weapon Ineptitude Other 8 Debuff Other 20 BowLowering 400 300 Creature Enchantment 80 Decreases the target's Missile Weapons skill by 45 points. +4626 Incantation of Missile Weapon Ineptitude Self 8 Debuff Self 20 BowLowering 400 300 Creature Enchantment 80 Decreases the caster's Missile Weapons skill by 45 points. +4627 Incantation of Missile Weapon Mastery Other 8 Buff Other 19 BowRaising 400 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 45 points. +4628 Incantation of Missile Weapon Mastery Self 8 Buff Self 19 BowRaising 400 5400 Creature Enchantment 80 Increases the caster's Missile Weapons skill by 45 points. +4629 Incantation of Light Weapon Ineptitude Other 8 Debuff Other 18 AxeLowering 400 300 Creature Enchantment 80 Decreases the target's Light Weapons skill by 45 points. +4630 Incantation of Light Weapon Mastery Other 8 Buff Other 17 AxeRaising 400 5400 Creature Enchantment 80 Increases the target's Light Weapons skill by 45 points. +4631 Incantation of Light Weapon Mastery Self 8 Buff Self 17 AxeRaising 400 5400 Creature Enchantment 80 Increases the caster's Light Weapons skill by 45 points. +4632 Incantation of Light Weapon Ineptitude Other 8 Debuff Other 18 AxeLowering 400 300 Creature Enchantment 80 Decreases the target's Light Weapons skill by 45 points. +4633 Incantation of Vulnerability Other 8 Debuff Other 38 MeleeDefenseLowering 400 300 Creature Enchantment 80 Decrease the target's Melee Defense skill by 45 points. +4634 Incantation of Vulnerability Self 8 Debuff Self 38 MeleeDefenseLowering 400 300 Creature Enchantment 80 Decrease the target's Melee Defense skill by 45 points. +4635 Incantation of War Magic Ineptitude Other 8 Debuff Other 50 WarMagicLowering 400 300 Creature Enchantment 80 Decreases the target's War Magic skill by 45 points. +4636 Incantation of War Magic Ineptitude Self 8 Debuff Self 50 WarMagicLowering 400 300 Creature Enchantment 80 Decreases the caster's War Magic skill by 45 points. +4637 Incantation of War Magic Mastery Other 8 Buff Other 49 WarMagicRaising 400 5400 Creature Enchantment 80 Increases the target's War Magic skill by 45 points. +4638 Incantation of War Magic Mastery Self 8 Buff Self 49 WarMagicRaising 400 5400 Creature Enchantment 80 Increases the caster's War Magic skill by 45 points. +4639 Incantation of Weapon Tinkering Expertise Other 8 Buff Other 61 AppraiseWeaponRaising 400 5400 Creature Enchantment 80 Increases the target's Weapon Tinkering skill by 45 points. +4640 Incantation of Weapon Tinkering Expertise Self 8 Buff Self 61 AppraiseWeaponRaising 400 5400 Creature Enchantment 80 Increases the caster's Weapon Tinkering skill by 45 points. +4641 Incantation of Weapon Tinkering Ignorance Other 8 Debuff Other 62 AppraiseWeaponLowering 400 300 Creature Enchantment 80 Decreases the target's Weapon Tinkering skill by 45 points. +4642 Incantation of Weapon Tinkering Ignorance Self 8 Debuff Self 62 AppraiseWeaponLowering 400 300 Creature Enchantment 80 Decreases the caster's Weapon Tinkering skill by 45 points. +4643 Incantation of Drain Health Other 8 Neutral Other 87 HealthTransfertocaster 400 -1 Life Magic 68 Drains 60% of the target's Health and gives 35% of it to the caster. +4644 Incantation of Drain Mana Other 8 Neutral Other 91 ManaTransfertocaster 400 -1 Life Magic 68 Drains 60% of the target's Mana and gives it to the caster. +4645 Incantation of Drain Stamina Other 8 Neutral Other 89 StaminaTransfertocaster 400 -1 Life Magic 68 Drains 60% of the target's Stamina and gives it to the caster. +4646 Incantation of Health to Mana Other 8 Neutral Other 87 HealthTransfertocaster 400 -1 Life Magic 80 Drains one-half of the target's Health and gives 200% of that to his/her Mana. +4647 Incantation of Health to Mana Self 8 Neutral Self 87 HealthTransfertocaster 400 -1 Life Magic 80 Drains one-half of the caster's Health and gives 200% of that to his/her Mana. +4648 Incantation of Health to Stamina Other 8 Neutral Other 87 HealthTransfertocaster 400 -1 Life Magic 80 Drains one-half of the target's Health and gives 200% of that to his/her Stamina. +4649 Incantation of Health to Stamina Self 8 Neutral Self 87 HealthTransfertocaster 400 -1 Life Magic 80 Drains one-half of the caster's Health and gives 200% of that to his/her Stamina. +4650 Incantation of Infuse Health Other 8 Neutral Other 88 HealthTransferfromcaster 400 -1 Life Magic 80 Drains one-quarter of the caster's Health and gives 200% of that to the target. +4651 Incantation of Infuse Mana Other 8 Neutral Other 92 ManaTransferfromcaster 400 -1 Life Magic 80 Drains one-quarter of the caster's Mana and gives 200% of that to the target. +4652 Incantation of Infuse Stamina Other 8 Neutral Other 90 StaminaTransferfromcaster 400 -1 Life Magic 80 Drains one-quarter of the caster's Stamina and gives 200% of that to the target. +4653 Incantation of Mana to Health Other 8 Neutral Other 91 ManaTransfertocaster 400 -1 Life Magic 80 Drains one-half of the target's Mana and gives 200% of that to his/her Health. +4654 Incantation of Mana to Health Self 8 Neutral Self 91 ManaTransfertocaster 400 -1 Life Magic 80 Drains one-half of the caster's Mana and gives 200% of that to his/her Health. +4655 Incantation of Mana to Stamina Other 8 Neutral Other 91 ManaTransfertocaster 400 -1 Life Magic 80 Drains one-half of the target's Mana and gives 200% of that to his/her stamina. +4656 Incantation of Mana to Stamina Self 8 Neutral Self 91 ManaTransfertocaster 400 -1 Life Magic 80 Drains one-half of the caster's Mana and gives 200% of that to his/her Stamina. +4657 Incantation of Stamina to Health Other 8 Neutral Other 89 StaminaTransfertocaster 400 -1 Life Magic 80 Drains one-half of the target's Stamina and gives 200% of that to his/her Health. +4658 Incantation of Stamina to Health Self 8 Neutral Self 89 StaminaTransfertocaster 400 -1 Life Magic 80 Drains one-half of the caster's Stamina and gives 200% of that to his/her Health. +4659 Incantation of Stamina to Mana Other 8 Neutral Other 89 StaminaTransfertocaster 400 -1 Life Magic 80 Drains one-half of the target's Stamina and gives 200% of that to his/her Mana. +4660 Epic Acid Bane 1 Buff Item 381 ExtraAcidResistanceRaising 3 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Acid damage by 20%. Additional spells can be layered over this. +4661 Epic Blood Thirst 1 Buff Item 323 MaxDamageRaising 5 780 Item Enchantment 10 Increases a weapon's damage value by 7 points. Additional spells can be layered over this. +4662 Epic Bludgeoning Bane 1 Buff Item 383 ExtraBludgeonResistanceRaising 3 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Bludgeoning damage by 20%. Additional spells can be layered over this. +4663 Epic Defender 1 Buff Item 329 ExtraDefenseModRaising 6 780 Item Enchantment 10 Increases the Melee Defense skill modifier of a weapon or magic caster by 7%. Additional spells can be layered over this. +4664 Epic Flame Bane 1 Buff Item 385 ExtraFireResistanceRaising 3 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Fire damage by 20%. Additional spells can be layered over this. +4665 Epic Frost Bane 1 Buff Item 387 ExtraColdResistanceRaising 3 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Cold damage by 20%. Additional spells can be layered over this. +4666 Epic Heart Thirst 1 Buff Item 389 ExtraAttackModRaising 6 780 Item Enchantment 10 Increases a weapon's Attack Skill modifier by 7%. Additional spells can be layered over this. +4667 Epic Impenetrability 1 Buff Item 391 ExtraArmorValueRaising 3 780 Item Enchantment 10 Improves a shield or piece of armor's Armor value by 60 points. Additional spells can be layered over this. +4668 Epic Piercing Bane 1 Buff Item 393 ExtraPierceResistanceRaising 3 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Piercing damage by 20%. Additional spells can be layered over this. +4669 Epic Slashing Bane 1 Buff Item 395 ExtraSlashResistanceRaising 3 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Slashing damage by 20%. Additional spells can be layered over this. +4670 Epic Spirit Thirst 1 Buff Item 323 MaxDamageRaising 4 780 Item Enchantment 10 Increases the elemental damage bonus of an elemental magic caster by 5%. Additional spells can be layered over this. +4671 Epic Storm Bane 1 Buff Item 397 ExtraElectricResistanceRaising 3 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Electric damage by 20%. Additional spells can be layered over this. +4672 Epic Swift Hunter 1 Buff Item 399 ExtraWeaponTimeRaising 25 780 Item Enchantment 10 Improves a weapon's speed by 30 points. Additional spells can be layered over this. +4673 Epic Acid Ward 1 Buff Other 285 AcidWardProtection 20 780 Life Magic 10 Reduces damage the target takes from Acid by 20%. Additional spells can be layered over this. +4674 Epic Bludgeoning Ward 1 Buff Other 401 BludgeonWardProtection 20 780 Life Magic 10 Reduces damage the target takes from Bludgeoning by 20%. Additional spells can be layered over this. +4675 Epic Flame Ward 1 Buff Other 287 FireWardProtection 20 780 Life Magic 10 Reduces damage the target takes from Fire by 20%. Additional spells can be layered over this. +4676 Epic Frost Ward 1 Buff Other 289 ColdWardProtection 20 780 Life Magic 10 Reduces damage the target takes from Cold by 20%. Additional spells can be layered over this. +4677 Epic Piercing Ward 1 Buff Other 405 PierceWardProtection 20 780 Life Magic 10 Reduces damage the target takes from Piercing by 20%. Additional spells can be layered over this. +4678 Epic Slashing Ward 1 Buff Other 403 SlashWardProtection 20 780 Life Magic 10 Reduces damage the target takes from Slashing by 20%. Additional spells can be layered over this. +4679 Epic Storm Ward 1 Buff Other 291 ElectricWardProtection 20 780 Life Magic 10 Reduces damage the target takes from Lightning by 20%. Additional spells can be layered over this. +4680 Epic Health Gain 1 Buff Other 257 HealthRestoring 45 780 Life Magic 10 Increases the rate at which the target regains Health by 45%. Additional spells can be layered over this. +4681 Epic Mana Gain 1 Buff Other 259 ManaRestoring 45 780 Life Magic 10 Increases the rate at which the target regains Mana by 45%. Additional spells can be layered over this. +4682 Epic Stamina Gain 1 Buff Other 407 StaminaRestoring 45 780 Life Magic 10 Increases the rate at which the target regains Stamina by 45%. Additional spells can be layered over this. +4683 Epic Alchemical Prowess 1 Buff Other 333 ExtraAlchemySkillRaising 25 780 Creature Enchantment 10 Increases the target's Alchemy skill by 25 points. Additional spells can be layered over this. +4684 Epic Arcane Prowess 1 Buff Other 335 ExtraArcaneLoreSkillRaising 25 780 Creature Enchantment 10 Increases the target's Arcane Lore skill by 25 points. Additional spells can be layered over this. +4685 Epic Armor Tinkering Expertise 1 Buff Other 337 ExtraAppraiseArmorSkillRaising 25 780 Creature Enchantment 10 Increases the target's Armor Tinkering skill by 25 points. Additional spells can be layered over this. +4686 Epic Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 25 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 25 points. Additional spells can be layered over this. +4687 Epic Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 25 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 25 points. Additional spells can be layered over this. +4688 Epic Cooking Prowess 1 Buff Other 339 ExtraCookingSkillRaising 25 780 Creature Enchantment 10 Increases the target's Cooking skill by 25 points. Additional spells can be layered over this. +4689 Epic Creature Enchantment Aptitude 1 Buff Other 251 CreatureMysticRaising 25 780 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 25 points. Additional spells can be layered over this. +4690 Epic Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 25 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 25 points. Additional spells can be layered over this. +4691 Epic Finesse Weapon Aptitude 1 Buff Other 313 CascadeDaggerRaising 25 780 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 25 points. Additional spells can be layered over this. +4692 Epic Fealty 1 Buff Other 345 ExtraLoyaltySkillRaising 25 780 Creature Enchantment 10 Increases the target's Loyalty skill by 25 points. Additional spells can be layered over this. +4693 Epic Fletching Prowess 1 Buff Other 347 ExtraFletchingSkillRaising 25 780 Creature Enchantment 10 Increases the target's Fletching skill by 25 points. Additional spells can be layered over this. +4694 Epic Healing Prowess 1 Buff Other 349 ExtraHealingSkillRaising 25 780 Creature Enchantment 10 Increases the target's Healing skill by 25 points. Additional spells can be layered over this. +4695 Epic Impregnability 1 Buff Other 654 ExtraMissileDefenseSkillRaising 25 780 Creature Enchantment 10 Increases the target's Missile Defense skill by 25 points. Additional spells can be layered over this. +4696 Epic Invulnerability 1 Buff Other 351 ExtraMeleeDefenseSkillRaising 25 780 Creature Enchantment 10 Increases the target's Melee Defense skill by 25 points. Additional spells can be layered over this. +4697 Epic Item Enchantment Aptitude 1 Buff Other 253 ItemMysticRaising 25 780 Creature Enchantment 10 Increases the target's Item Enchantment skill by 25 points. Additional spells can be layered over this. +4698 Epic Item Tinkering Expertise 1 Buff Other 353 ExtraAppraiseItemSkillRaising 25 780 Creature Enchantment 10 Increases the target's Item Tinkering skill by 25 points. Additional spells can be layered over this. +4699 Epic Jumping Prowess 1 Buff Other 355 ExtraJumpingSkillRaising 25 780 Creature Enchantment 10 Increases the target's Jump skill by 25 points. Additional spells can be layered over this. +4700 Epic Life Magic Aptitude 1 Buff Other 357 ExtraLifeMagicSkillRaising 25 780 Creature Enchantment 10 Increases the target's Life Magic skill by 25 points. Additional spells can be layered over this. +4701 Epic Lockpick Prowess 1 Buff Other 359 ExtraLockpickSkillRaising 25 780 Creature Enchantment 10 Increases the target's Lockpick skill by 25 points. Additional spells can be layered over this. +4702 Epic Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 25 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 25 points. Additional spells can be layered over this. +4703 Epic Magic Item Tinkering Expertise 1 Buff Other 361 ExtraAppraiseMagicItemSkillRaising 25 780 Creature Enchantment 10 Increases the target's Magic Item Tinkering skill by 25 points. Additional spells can be layered over this. +4704 Epic Magic Resistance 1 Buff Other 299 MagicDefenseShelterRaising 25 780 Creature Enchantment 10 Increases the target's Magic Defense skill by 25 points. Additional spells can be layered over this. +4705 Epic Mana Conversion Prowess 1 Buff Other 363 ExtraManaConversionSkillRaising 25 780 Creature Enchantment 10 Increases the target's Mana Conversion skill by 25 points. Additional spells can be layered over this. +4706 Epic Monster Attunement 1 Buff Other 365 ExtraAssessCreatureSkillRaising 25 780 Creature Enchantment 10 Increases the target's Assess Creature skill by 25 points. Additional spells can be layered over this. +4707 Epic Person Attunement 1 Buff Other 367 ExtraAssessPersonSkillRaising 25 780 Creature Enchantment 10 Increases the target's Assess Person skill by 25 points. Additional spells can be layered over this. +4708 Epic Salvaging Aptitude 1 Buff Other 437 ExtraSalvagingRaising2 25 780 Creature Enchantment 10 Increases the target's Salvaging skill by 25 points. Additional spells can be layered over this. +4709 Epic Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 25 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 25 points. Additional spells can be layered over this. +4710 Epic Sprint 1 Buff Other 369 ExtraRunSkillRaising 25 780 Creature Enchantment 10 Increases the target's Run skill by 25 points. Additional spells can be layered over this. +4711 Epic Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 25 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 25 points. Additional spells can be layered over this. +4712 Epic Heavy Weapon Aptitude 1 Buff Other 371 ExtraSwordSkillRaising 25 780 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 25 points. Additional spells can be layered over this. +4713 Epic Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 25 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 25 points. Additional spells can be layered over this. +4714 Epic Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 25 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 25 points. Additional spells can be layered over this. +4715 Epic War Magic Aptitude 1 Buff Other 255 WarMysticRaising 25 780 Creature Enchantment 10 Increases the target's War Magic skill by 25 points. Additional spells can be layered over this. +4716 Burning Curse 7 Debuff Other 80 HealthLowering 350 -1 Life Magic 70 Does 100-250 points of fire damage to the cursed target. +4717 Expedient Return to Ulgrim 4 Neutral Item 214 PortalSending 150 -1 Item Enchantment 150 Teleports target far above Ayan Baqur. +4718 Welcomed by the Blood Witches 8 Neutral Item 214 PortalSending 999 -1 Item Enchantment 50 This spell teleports the character to the Waiting Area of the Falatacot Visitor's Alcove. +4719 Welcomed by the Blood Witches 8 Neutral Item 214 PortalSending 999 -1 Item Enchantment 50 This spell teleports the character to the Outer Receiving Chamber of the Falatacot Visitor's Alcove. +4720 Welcomed by the Blood Witches 8 Neutral Item 214 PortalSending 999 -1 Item Enchantment 50 This spell teleports the character to the Inner Receiving Chamber of the Falatacot Visitor's Alcove. +4721 Travel to the Ruins of Degar'Alesh 8 Neutral Item 214 PortalSending 400 -1 Item Enchantment 50 Instantly transports the target to the Ruins of Degar'Alesh. +4722 Bleed Other 1 Buff Other 530 HealthDoT 10 30 Life Magic 20 Decreases target's health by 10 every heart beat. +4723 Bleed Self 1 Buff Self 530 HealthDoT 10 30 Life Magic 20 Decreases caster's health by 10 every heart beat. +4724 Gateway to Nyr'leha 7 Neutral Item 214 PortalSending 350 -1 Item Enchantment 50 The Gateway to Nyr'leha. ancient city from beneath the waves. +4725 The Pit of Heretics 7 Neutral Item 214 PortalSending 350 -1 Item Enchantment 50 Sends the target to the Sclavus Pit. +4726 Poison 7 Buff Other 410 HealthDivide 300 30 Creature Enchantment 10 Lowers the total health of the target by 15%. This spell can stack up to three times. +4727 Poison 7 Buff Other 536 HealthDivideSecondary 300 30 Creature Enchantment 10 Lowers the total health of the target by 15%. This spell can stack up to three times. +4728 Poison 7 Buff Other 537 HealthDivideTertiary 300 30 Creature Enchantment 10 Lowers the total health of the target by 15%. This spell can stack up to three times. +4729 Travel to the Catacombs of Tar'Kelyn 8 Neutral Item 214 PortalSending 400 -1 Item Enchantment 50 Instantly transports the target to the Catacombs of Tar'Kelyn. +4730 Novice Duelist's Coordination 1 Buff Other 568 SetCoordinationRaising 1 1800 Creature Enchantment 10 Increases the target's Coordination by 3 points. +4731 Apprentice Duelist's Coordination 1 Buff Other 568 SetCoordinationRaising 2 1800 Creature Enchantment 10 Increases the target's Coordination by 5 points. +4732 Journeyman Duelist's Coordination 1 Buff Other 568 SetCoordinationRaising 3 1800 Creature Enchantment 10 Increases the target's Coordination by 10 points. +4733 Master Duelist's Coordination 1 Buff Other 568 SetCoordinationRaising 4 1800 Creature Enchantment 10 Increases the target's Coordination by 20 points. +4734 Novice Hero's Endurance 1 Buff Other 567 SetEnduranceRaising 1 1800 Creature Enchantment 10 Increases the target's Endurance by 3 points. +4735 Apprentice Hero's Endurance 1 Buff Other 567 SetEnduranceRaising 2 1800 Creature Enchantment 10 Increases the target's Endurance by 5 points. +4736 Journeyman Hero's Endurance 1 Buff Other 567 SetEnduranceRaising 3 1800 Creature Enchantment 10 Increases the target's Endurance by 10 points. +4737 Master Hero's Endurance 1 Buff Other 567 SetEnduranceRaising 4 1800 Creature Enchantment 10 Increases the target's Endurance by 20 points. +4738 Novice Sage's Focus 1 Buff Other 570 SetFocusRaising 1 1800 Creature Enchantment 10 Increases the target's Focus by 3 points. +4739 Apprentice Sage's Focus 1 Buff Other 570 SetFocusRaising 2 1800 Creature Enchantment 10 Increases the target's Focus by 5 points. +4740 Journeyman Sage's Focus 1 Buff Other 570 SetFocusRaising 3 1800 Creature Enchantment 10 Increases the target's Focus by 10 points. +4741 Master Sage's Focus 1 Buff Other 570 SetFocusRaising 4 1800 Creature Enchantment 10 Increases the target's Focus by 20 points. +4742 Novice Rover's Quickness 1 Buff Other 569 SetQuicknessRaising 1 1800 Creature Enchantment 10 Increases the target's Quickness by 3 points. +4743 Apprentice Rover's Quickness 1 Buff Other 569 SetQuicknessRaising 2 1800 Creature Enchantment 10 Increases the target's Quickness by 5 points. +4744 Journeyman Rover's Quickness 1 Buff Other 569 SetQuicknessRaising 3 1800 Creature Enchantment 10 Increases the target's Quickness by 10 points. +4745 Master Rover's Quickness 1 Buff Other 569 SetQuicknessRaising 4 1800 Creature Enchantment 10 Increases the target's Quickness by 20 points. +4746 Novice Brute's Strength 1 Buff Other 566 SetStrengthRaising 1 1800 Creature Enchantment 10 Increases the target's Strength by 3 points. +4747 Apprentice Brute's Strength 1 Buff Other 566 SetStrengthRaising 2 1800 Creature Enchantment 10 Increases the target's Strength by 5 points. +4748 Journeyman Brute's Strength 1 Buff Other 566 SetStrengthRaising 3 1800 Creature Enchantment 10 Increases the target's Strength by 10 points. +4749 Master Brute's Strength 1 Buff Other 566 SetStrengthRaising 4 1800 Creature Enchantment 10 Increases the target's Strength by 20 points. +4750 Novice Adherent's Willpower 1 Buff Other 571 SetWillpowerRaising 1 1800 Creature Enchantment 10 Increases the target's Self by 3 points. +4751 Apprentice Adherent's Willpower 1 Buff Other 571 SetWillpowerRaising 2 1800 Creature Enchantment 10 Increases the target's Self by 5 points. +4752 Journeyman Adherent's Willpower 1 Buff Other 571 SetWillpowerRaising 3 1800 Creature Enchantment 10 Increases the target's Self by 10 points. +4753 Master Adherent's Willpower 1 Buff Other 571 SetWillpowerRaising 4 1800 Creature Enchantment 10 Increases the target's Self by 20 points. +4754 Apprentice Survivor's Health 1 Buff Other 572 SetHealthRaising 2 510 Life Magic 70 Increases maximum health by 3 points. +4755 Journeyman Survivor's Health 1 Buff Other 572 SetHealthRaising 3 510 Life Magic 70 Increases maximum health by 10 points. +4756 Apprentice Clairvoyant's Mana 1 Buff Other 574 SetManaRaising 2 510 Life Magic 70 Increases maximum mana by 6 points. +4757 Journeyman Clairvoyant's Mana 1 Buff Other 574 SetManaRaising 3 510 Life Magic 70 Increases maximum mana by 20 points. +4758 Apprentice Tracker's Stamina 1 Buff Other 573 SetStaminaRaising 2 510 Life Magic 70 Increases maximum stamina by 6 points. +4759 Journeyman Tracker's Stamina 1 Buff Other 573 SetStaminaRaising 3 510 Life Magic 70 Increases maximum stamina by 20 points. +4760 Incidental Acid Resistance 1 Buff Other 581 SetAcidResistanceRaising 1 780 Life Magic 10 Reduces damage the target takes from Acid by 2%. +4761 Crude Acid Resistance 1 Buff Other 581 SetAcidResistanceRaising 2 780 Life Magic 10 Reduces damage the target takes from Acid by 5%. +4762 Effective Acid Resistance 1 Buff Other 581 SetAcidResistanceRaising 3 780 Life Magic 10 Reduces damage the target takes from Acid by 10%. +4763 Masterwork Acid Resistance 1 Buff Other 581 SetAcidResistanceRaising 4 780 Life Magic 10 Reduces damage the target takes from Acid by 20%. +4764 Incidental Bludgeoning Resistance 1 Buff Other 578 SetBludgeonResistanceRaising 1 780 Life Magic 10 Reduces damage the target takes from Bludgeoning by 2%. +4765 Crude Bludgeoning Resistance 1 Buff Other 578 SetBludgeonResistanceRaising 2 780 Life Magic 10 Reduces damage the target takes from Bludgeoning by 5%. +4766 Effective Bludgeoning Resistance 1 Buff Other 578 SetBludgeonResistanceRaising 3 780 Life Magic 10 Reduces damage the target takes from Bludgeoning by 10%. +4767 Masterwork Bludgeoning Resistance 1 Buff Other 578 SetBludgeonResistanceRaising 4 780 Life Magic 10 Reduces damage the target takes from Bludgeoning by 20%. +4768 Incidental Flame Resistance 1 Buff Other 580 SetFlameResistanceRaising 1 780 Life Magic 10 Reduces damage the target takes from Fire by 2%. +4769 Crude Flame Resistance 1 Buff Other 580 SetFlameResistanceRaising 2 780 Life Magic 10 Reduces damage the target takes from Fire by 5%. +4770 Effective Flame Resistance 1 Buff Other 580 SetFlameResistanceRaising 3 780 Life Magic 10 Reduces damage the target takes from Fire by 10%. +4771 Masterwork Flame Resistance 1 Buff Other 580 SetFlameResistanceRaising 4 780 Life Magic 10 Reduces damage the target takes from Fire by 20%. +4772 Incidental Frost Resistance 1 Buff Other 582 SetFrostResistanceRaising 1 780 Life Magic 10 Reduces damage the target takes from Cold by 2%. +4773 Crude Frost Resistance 1 Buff Other 582 SetFrostResistanceRaising 2 780 Life Magic 10 Reduces damage the target takes from Cold by 5%. +4774 Effective Frost Resistance 1 Buff Other 582 SetFrostResistanceRaising 3 780 Life Magic 10 Reduces damage the target takes from Cold by 10%. +4775 Masterwork Frost Resistance 1 Buff Other 582 SetFrostResistanceRaising 4 780 Life Magic 10 Reduces damage the target takes from Cold by 20%. +4776 Incidental Lightning Resistance 1 Buff Other 583 SetLightningResistanceRaising 1 780 Life Magic 10 Reduces damage the target takes from Lightning by 2%. +4777 Crude Lightning Resistance 1 Buff Other 583 SetLightningResistanceRaising 2 780 Life Magic 10 Reduces damage the target takes from Lightning by 5%. +4778 Effective Lightning Resistance 1 Buff Other 583 SetLightningResistanceRaising 3 780 Life Magic 10 Reduces damage the target takes from Lightning by 10%. +4779 Masterwork Lightning Resistance 1 Buff Other 583 SetLightningResistanceRaising 4 780 Life Magic 10 Reduces damage the target takes from Lightning by 20%. +4780 Incidental Piercing Resistance 1 Buff Other 579 SetPierceResistanceRaising 1 780 Life Magic 10 Reduces damage the target takes from Piercing by 2%. +4781 Crude Piercing Resistance 1 Buff Other 579 SetPierceResistanceRaising 2 780 Life Magic 10 Reduces damage the target takes from Piercing by 5%. +4782 Effective Piercing Resistance 1 Buff Other 579 SetPierceResistanceRaising 3 780 Life Magic 10 Reduces damage the target takes from Piercing by 10%. +4783 Masterwork Piercing Resistance 1 Buff Other 579 SetPierceResistanceRaising 4 780 Life Magic 10 Reduces damage the target takes from Piercing by 20%. +4784 Incidental Slashing Resistance 1 Buff Other 577 SetSlashResistanceRaising 1 780 Life Magic 10 Reduces damage the target takes from Slashing by 2%. +4785 Crude Slashing Resistance 1 Buff Other 577 SetSlashResistanceRaising 2 780 Life Magic 10 Reduces damage the target takes from Slashing by 5%. +4786 Effective Slashing Resistance 1 Buff Other 577 SetSlashResistanceRaising 3 780 Life Magic 10 Reduces damage the target takes from Slashing by 10%. +4787 Masterwork Slashing Resistance 1 Buff Other 577 SetSlashResistanceRaising 4 780 Life Magic 10 Reduces damage the target takes from Slashing by 20%. +4788 Novice Concoctor's Alchemy Aptitude 1 Buff Other 559 SetAlchemyRaising 1 1800 Creature Enchantment 10 Increases the target's Alchemy skill by 3 points. +4789 Apprentice Concoctor's Alchemy Aptitude 1 Buff Other 559 SetAlchemyRaising 2 1800 Creature Enchantment 10 Increases the target's Alchemy skill by 5 points. +4790 Journeyman Concoctor's Alchemy Aptitude 1 Buff Other 559 SetAlchemyRaising 3 1800 Creature Enchantment 10 Increases the target's Alchemy skill by 10 points. +4791 Master Concoctor's Alchemy Aptitude 1 Buff Other 559 SetAlchemyRaising 4 1800 Creature Enchantment 10 Increases the target's Alchemy skill by 20 points. +4792 Novice Armorer's Armor Tinkering Aptitude 1 Buff Other 561 SetArmorExpertiseRaising 1 1800 Creature Enchantment 10 Increases the target's Armor Tinkering skill by 3 points. +4793 Apprentice Armorer's Armor Tinkering Aptitude 1 Buff Other 561 SetArmorExpertiseRaising 2 1800 Creature Enchantment 10 Increases the target's Armor Tinkering skill by 5 points. +4794 Journeyman Armorer's Armor Tinkering Aptitude 1 Buff Other 561 SetArmorExpertiseRaising 3 1800 Creature Enchantment 10 Increases the target's Armor Tinkering skill by 10 points. +4795 Master Armorer's Armor Tinkering Aptitude 1 Buff Other 561 SetArmorExpertiseRaising 4 1800 Creature Enchantment 10 Increases the target's Armor Tinkering skill by 20 points. +4796 Novice Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 1 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 3 points. +4797 Apprentice Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 2 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 5 points. +4798 Journeyman Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 3 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. +4799 Master Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 4 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 20 points. +4800 Novice Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 1 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 3 points. +4801 Apprentice Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 2 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 5 points. +4802 Journeyman Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 3 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 10 points. +4803 Master Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 4 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 20 points. +4804 Novice Chef's Cooking Aptitude 1 Buff Other 556 SetCookingRaising 1 1800 Creature Enchantment 10 Increases the target's Cooking skill by 3 points. +4805 Apprentice Chef's Cooking Aptitude 1 Buff Other 556 SetCookingRaising 2 1800 Creature Enchantment 10 Increases the target's Cooking skill by 5 points. +4806 Journeyman Chef's Cooking Aptitude 1 Buff Other 556 SetCookingRaising 3 1800 Creature Enchantment 10 Increases the target's Cooking skill by 10 points. +4807 Master Chef's Cooking Aptitude 1 Buff Other 556 SetCookingRaising 4 1800 Creature Enchantment 10 Increases the target's Cooking skill by 20 points. +4808 Novice Enchanter's Creature Aptitude 1 Buff Other 549 SetCreatureEnchantmentRaising 1 1800 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 3 points. +4809 Apprentice Enchanter's Creature Aptitude 1 Buff Other 549 SetCreatureEnchantmentRaising 2 1800 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 5 points. +4810 Journeyman Enchanter's Creature Aptitude 1 Buff Other 549 SetCreatureEnchantmentRaising 3 1800 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 10 points. +4811 Master Enchanter's Creature Aptitude 1 Buff Other 549 SetCreatureEnchantmentRaising 4 1800 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 20 points. +4812 Novice Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 1 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 3 points. +4813 Apprentice Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 2 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 5 points. +4814 Journeyman Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 3 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 10 points. +4815 Master Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 4 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 20 points. +4816 Novice Soldier's Finesse Weapon Aptitude 1 Buff Other 540 SetDaggerRaising 1 1800 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 3 points. +4817 Apprentice Soldier's Finesse Weapon Aptitude 1 Buff Other 540 SetDaggerRaising 2 1800 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 5 points. +4818 Journeyman Soldier's Finesse Weapon Aptitude 1 Buff Other 540 SetDaggerRaising 3 1800 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 10 points. +4819 Master Soldier's Finesse Weapon Aptitude 1 Buff Other 540 SetDaggerRaising 4 1800 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 20 points. +4820 Novice Huntsman's Fletching Aptitude 1 Buff Other 557 SetFletchingRaising 1 1800 Creature Enchantment 10 Increases the target's Fletching skill by 3 points. +4821 Apprentice Huntsman's Fletching Aptitude 1 Buff Other 557 SetFletchingRaising 2 1800 Creature Enchantment 10 Increases the target's Fletching skill by 5 points. +4822 Journeyman Huntsman's Fletching Aptitude 1 Buff Other 557 SetFletchingRaising 3 1800 Creature Enchantment 10 Increases the target's Fletching skill by 10 points. +4823 Master Huntsman's Fletching Aptitude 1 Buff Other 557 SetFletchingRaising 4 1800 Creature Enchantment 10 Increases the target's Fletching skill by 20 points. +4824 Novice Artifex's Item Aptitude 1 Buff Other 548 SetItemEnchantmentRaising 1 1800 Creature Enchantment 10 Increases the target's Item Enchantment skill by 3 points. +4825 Apprentice Artifex's Item Aptitude 1 Buff Other 548 SetItemEnchantmentRaising 2 1800 Creature Enchantment 10 Increases the target's Item Enchantment skill by 5 points. +4826 Journeyman Artifex's Item Aptitude 1 Buff Other 548 SetItemEnchantmentRaising 3 1800 Creature Enchantment 10 Increases the target's Item Enchantment skill by 10 points. +4827 Master Artifex's Item Aptitude 1 Buff Other 548 SetItemEnchantmentRaising 4 1800 Creature Enchantment 10 Increases the target's Item Enchantment skill by 20 points. +4828 Novice Inventor's Item Tinkering Aptitude 1 Buff Other 563 SetItemTinkeringRaising 1 1800 Creature Enchantment 10 Increases the target's Item Tinkering skill by 3 points. +4829 Apprentice Inventor's Item Tinkering Aptitude 1 Buff Other 563 SetItemTinkeringRaising 2 1800 Creature Enchantment 10 Increases the target's Item Tinkering skill by 5 points. +4830 Journeyman Inventor's Item Tinkering Aptitude 1 Buff Other 563 SetItemTinkeringRaising 3 1800 Creature Enchantment 10 Increases the target's Item Tinkering skill by 10 points. +4831 Master Inventor's Item Tinkering Aptitude 1 Buff Other 563 SetItemTinkeringRaising 4 1800 Creature Enchantment 10 Increases the target's Item Tinkering skill by 20 points. +4832 Novice Leaper's Jumping Aptitude 1 Buff Other 576 SetJumpingRaising 1 1800 Creature Enchantment 10 Increases the target's Jump skill by 3 points. +4833 Apprentice Leaper's Jumping Aptitude 1 Buff Other 576 SetJumpingRaising 2 1800 Creature Enchantment 10 Increases the target's Jump skill by 5 points. +4834 Journeyman Leaper's Jumping Aptitude 1 Buff Other 576 SetJumpingRaising 3 1800 Creature Enchantment 10 Increases the target's Jump skill by 10 points. +4835 Master Leaper's Jumping Aptitude 1 Buff Other 576 SetJumpingRaising 4 1800 Creature Enchantment 10 Increases the target's Jump skill by 20 points. +4836 Novice Theurge's Life Magic Aptitude 1 Buff Other 551 SetLifeMagicRaising 1 1800 Creature Enchantment 10 Increases the target's Life Magic skill by 3 points. +4837 Apprentice Theurge's Life Magic Aptitude 1 Buff Other 551 SetLifeMagicRaising 2 1800 Creature Enchantment 10 Increases the target's Life Magic skill by 5 points. +4838 Journeyman Theurge's Life Magic Aptitude 1 Buff Other 551 SetLifeMagicRaising 3 1800 Creature Enchantment 10 Increases the target's Life Magic skill by 10 points. +4839 Master Theurge's Life Magic Aptitude 1 Buff Other 551 SetLifeMagicRaising 4 1800 Creature Enchantment 10 Increases the target's Life Magic skill by 20 points. +4840 Novice Locksmith's Lockpick Aptitude 1 Buff Other 558 SetLockpickRaising 1 1800 Creature Enchantment 10 Increases the target's Lockpick skill by 3 points. +4841 Apprentice Locksmith's Lockpick Aptitude 1 Buff Other 558 SetLockpickRaising 2 1800 Creature Enchantment 10 Increases the target's Lockpick skill by 5 points. +4842 Journeyman Locksmith's Lockpick Aptitude 1 Buff Other 558 SetLockpickRaising 3 1800 Creature Enchantment 10 Increases the target's Lockpick skill by 10 points. +4843 Master Locksmith's Lockpick Aptitude 1 Buff Other 558 SetLockpickRaising 4 1800 Creature Enchantment 10 Increases the target's Lockpick skill by 20 points. +4844 Yeoman's Loyalty 1 Buff Other 565 SetLoyaltyRaising 1 1800 Creature Enchantment 10 Increases the target's Loyalty skill by 3 points. +4845 Squire's Loyalty 1 Buff Other 565 SetLoyaltyRaising 2 1800 Creature Enchantment 10 Increases the target's Loyalty skill by 5 points. +4846 Novice Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 1 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 3 points. +4847 Apprentice Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 2 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 5 points. +4848 Journeyman Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 3 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. +4849 Master Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 4 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 20 points. +4850 Novice Negator's Magic Resistance 1 Buff Other 554 SetMagicDefenseRaising 1 1800 Creature Enchantment 10 Increases the target's Magic Defense skill by 3 points. +4851 Apprentice Negator's Magic Resistance 1 Buff Other 554 SetMagicDefenseRaising 2 1800 Creature Enchantment 10 Increases the target's Magic Defense skill by 5 points. +4852 Journeyman Negator's Magic Resistance 1 Buff Other 554 SetMagicDefenseRaising 3 1800 Creature Enchantment 10 Increases the target's Magic Defense skill by 10 points. +4853 Master Negator's Magic Resistance 1 Buff Other 554 SetMagicDefenseRaising 4 1800 Creature Enchantment 10 Increases the target's Magic Defense skill by 20 points. +4854 Novice Arcanist's Magic Item Tinkering Aptitude 1 Buff Other 564 SetMagicItemExpertiseRaising 1 1800 Creature Enchantment 10 Increases the target's Magic Item Tinkering skill by 3 points. +4855 Apprentice Arcanist's Magic Item Tinkering Aptitude 1 Buff Other 564 SetMagicItemExpertiseRaising 2 1800 Creature Enchantment 10 Increases the target's Magic Item Tinkering skill by 5 points. +4856 Journeyman Arcanist's Magic Item Tinkering Aptitude 1 Buff Other 564 SetMagicItemExpertiseRaising 3 1800 Creature Enchantment 10 Increases the target's Magic Item Tinkering skill by 10 points. +4857 Master Arcanist's Magic Item Tinkering Aptitude 1 Buff Other 564 SetMagicItemExpertiseRaising 4 1800 Creature Enchantment 10 Increases the target's Magic Item Tinkering skill by 20 points. +4858 Novice Guardian's Invulnerability 1 Buff Other 552 SetMeleeDefenseRaising 1 1800 Creature Enchantment 10 Increases the target's Melee Defense skill by 3 points. +4859 Apprentice Guardian's Invulnerability 1 Buff Other 552 SetMeleeDefenseRaising 2 1800 Creature Enchantment 10 Increases the target's Melee Defense skill by 5 points. +4860 Journeyman Guardian's Invulnerability 1 Buff Other 552 SetMeleeDefenseRaising 3 1800 Creature Enchantment 10 Increases the target's Melee Defense skill by 10 points. +4861 Master Guardian's Invulnerability 1 Buff Other 552 SetMeleeDefenseRaising 4 1800 Creature Enchantment 10 Increases the target's Melee Defense skill by 20 points. +4862 Novice Wayfarer's Impregnability 1 Buff Other 553 SetMissileDefenseRaising 1 1800 Creature Enchantment 10 Increases the target's Missile Defense skill by 3 points. +4863 Apprentice Wayfarer's Impregnability 1 Buff Other 553 SetMissileDefenseRaising 2 1800 Creature Enchantment 10 Increases the target's Missile Defense skill by 5 points. +4864 Journeyman Wayfarer's Impregnability 1 Buff Other 553 SetMissileDefenseRaising 3 1800 Creature Enchantment 10 Increases the target's Missile Defense skill by 10 points. +4865 Master Wayfarer's Impregnability 1 Buff Other 553 SetMissileDefenseRaising 4 1800 Creature Enchantment 10 Increases the target's Missile Defense skill by 20 points. +4866 Novice Scavenger's Salvaging Aptitude 1 Buff Other 560 SetSalvagingRaising 1 1800 Creature Enchantment 10 Increases the target's Salvaging skill by 3 points. +4867 Apprentice Scavenger's Salvaging Aptitude 1 Buff Other 560 SetSalvagingRaising 2 1800 Creature Enchantment 10 Increases the target's Salvaging skill by 5 points. +4868 Novice Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 1 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 3 points. +4869 Apprentice Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 2 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 5 points. +4870 Journeyman Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 3 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. +4871 Master Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 4 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 20 points. +4872 Novice Messenger's Sprint Aptitude 1 Buff Other 575 SetSprintRaising 1 1800 Creature Enchantment 10 Increases the target's Run skill by 3 points. +4873 Apprentice Messenger's Sprint Aptitude 1 Buff Other 575 SetSprintRaising 2 1800 Creature Enchantment 10 Increases the target's Run skill by 5 points. +4874 Journeyman Messenger's Sprint Aptitude 1 Buff Other 575 SetSprintRaising 3 1800 Creature Enchantment 10 Increases the target's Run skill by 10 points. +4875 Master Messenger's Sprint Aptitude 1 Buff Other 575 SetSprintRaising 4 1800 Creature Enchantment 10 Increases the target's Run skill by 20 points. +4876 Novice Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 1 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 3 points. +4877 Apprentice Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 2 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 5 points. +4878 Journeyman Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 3 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. +4879 Master Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 4 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 20 points. +4880 Novice Soldier's Heavy Weapon Aptitude 1 Buff Other 538 SetSwordRaising 1 1800 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 3 points. +4881 Apprentice Soldier's Heavy Weapon Aptitude 1 Buff Other 538 SetSwordRaising 2 1800 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 5 points. +4882 Journeyman Soldier's Heavy Weapon Aptitude 1 Buff Other 538 SetSwordRaising 3 1800 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 10 points. +4883 Master Soldier's Heavy Weapon Aptitude 1 Buff Other 538 SetSwordRaising 4 1800 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 20 points. +4884 Novice Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 1 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 3 points. +4885 Apprentice Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 2 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 5 points. +4886 Journeyman Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 3 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 10 points. +4887 Master Archer's Missile Weapon Aptitude 1 Buff Other 545 SetBowRaising 4 1800 Creature Enchantment 10 Increases the target's Missile Weapons skill by 20 points. +4888 Novice Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 1 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 3 points. +4889 Apprentice Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 2 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 5 points. +4890 Journeyman Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 3 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 10 points. +4891 Master Soldier's Light Weapon Aptitude 1 Buff Other 539 SetAxeRaising 4 1800 Creature Enchantment 10 Increases the target's Light Weapons skill by 20 points. +4892 Novice Warlock's War Magic Aptitude 1 Buff Other 550 SetWarMagicRaising 1 1800 Creature Enchantment 10 Increases the target's War Magic skill by 3 points. +4893 Apprentice Warlock's War Magic Aptitude 1 Buff Other 550 SetWarMagicRaising 2 1800 Creature Enchantment 10 Increases the target's War Magic skill by 5 points. +4894 Journeyman Warlock's War Magic Aptitude 1 Buff Other 550 SetWarMagicRaising 3 1800 Creature Enchantment 10 Increases the target's War Magic skill by 10 points. +4895 Master Warlock's War Magic Aptitude 1 Buff Other 550 SetWarMagicRaising 4 1800 Creature Enchantment 10 Increases the target's War Magic skill by 20 points. +4896 Novice Swordsmith's Weapon Tinkering Aptitude 1 Buff Other 562 SetWeaponExpertiseRaising 1 1800 Creature Enchantment 10 Increases the target's Weapon Tinkering skill by 3 points. +4897 Apprentice Swordsmith's Weapon Tinkering Aptitude 1 Buff Other 562 SetWeaponExpertiseRaising 2 1800 Creature Enchantment 10 Increases the target's Weapon Tinkering skill by 5 points. +4898 Journeyman Swordsmith's Weapon Tinkering Aptitude 1 Buff Other 562 SetWeaponExpertiseRaising 3 1800 Creature Enchantment 10 Increases the target's Weapon Tinkering skill by 10 points. +4899 Master Swordsmith's Weapon Tinkering Aptitude 1 Buff Other 562 SetWeaponExpertiseRaising 4 1800 Creature Enchantment 10 Increases the target's Weapon Tinkering skill by 20 points. +4900 Society Initiate's Blessing 1 Buff Other 517 AttributesIncreaseCantrip1 3 3600 Creature Enchantment 10 Increases all attributes by 3. This effect layers on top of normal spells as well as cantrips. +4901 Society Adept's Blessing 1 Buff Other 517 AttributesIncreaseCantrip1 6 3600 Creature Enchantment 10 Increases all attributes by 6. This effect layers on top of normal spells as well as cantrips. +4902 Society Knight's Blessing 1 Buff Other 517 AttributesIncreaseCantrip1 9 3600 Creature Enchantment 10 Increases all attributes by 9. This effect layers on top of normal spells as well as cantrips. +4903 Society Lord's Blessing 1 Buff Other 517 AttributesIncreaseCantrip1 12 3600 Creature Enchantment 10 Increases all attributes by 12. This effect layers on top of normal spells as well as cantrips. +4904 Society Master's Blessing 1 Buff Other 517 AttributesIncreaseCantrip1 15 3600 Creature Enchantment 10 Increases all attributes by 15. This effect layers on top of normal spells as well as cantrips. +4905 Novice Challenger's Rejuvenation 1 Buff Other 555 SetStaminaAccelerating 1 2700 Life Magic 10 Increases the rate at which the target regains Stamina by 30%. +4906 Apprentice Challenger's Rejuvenation 1 Buff Other 555 SetStaminaAccelerating 2 2700 Life Magic 10 Increases the rate at which the target regains Stamina by 100%. +4907 Celestial Hand Stronghold Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 Sends the caster to the Celestial Hand Stronghold. +4908 Eldrytch Web Stronghold Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 Sends the caster to the Eldrytch Web Stronghold. +4909 Radiant Blood Stronghold Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 Sends the caster to the Radiant Blood Stronghold. +4910 Raider Tag 1 Debuff Other 80 HealthLowering 1 -1 Life Magic 50 Drains 1-2 points of the target's Health. +4911 Epic Armor 2 Buff Other 379 ArmorIncrease 60 780 Life Magic 10 Increases the target's natural armor by 60 points. Additional spells can be layered over this. +4912 Epic Weapon Tinkering Expertise 1 Buff Other 377 ExtraAppraiseWeaponSkillRaising 25 780 Creature Enchantment 10 Increases the target's Weapon Tinkering skill by 25 points. Additional spells can be layered over this. +4913 Aerlinthe Pyramid Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4914 Aerlinthe Pyramid Portal Exit 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4915 A'mun Pyramid Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4916 A'mun Pyramid Portal Exit 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4917 Esper Pyramid Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4918 Esper Pyramid Portal Exit 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4919 Halaetan Pyramid Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4920 Halaetan Pyramid Portal Exit 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4921 Linvak Pyramid Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4922 Linvak Pyramid Portal Exit 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4923 Obsidian Pyramid Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4924 Obsidian Pyramid Portal Exit 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4925 Dance 8 Buff Other 198 TransparencyRaising 800 30 Creature Enchantment 70 Causes the target to dance uncontrollably. +4926 Smite 8 Debuff Other 80 HealthLowering 400 -1 Life Magic 10 Drains 400-800 points of the target's Health. +4927 Incantation of Acid Stream with 300 Spellpower 7 Neutral Other 117 AcidMissile 300 -1 War Magic 40 Shoots a stream of acid at the target. The stream does 135-195 points of acid damage to the first thing it hits. +4928 Incantation of Acid Stream with 350 Spellpower 7 Neutral Other 117 AcidMissile 350 -1 War Magic 40 Shoots a stream of acid at the target. The stream does 135-195 points of acid damage to the first thing it hits. +4929 Harm 1 Harm Other 80 HealthLowering 1 -1 Life Magic 10 Drains 5-10 points of the target's Health. +4930 Flame Bolt I 8 Projectile Other 121 FireMissile 900 -1 War Magic 5 Shoots a mini fireball +4931 Mini Fireball 8 Neutral Other 121 FireMissile 900 -1 War Magic 5 Shoots a mini fireball +4932 Mini Fireball 8 Neutral Other 121 FireMissile 900 -1 War Magic 5 Shoots a mini fireball +4933 Slowness 1 Debuff Other 6 QuicknessLowering 1 5 Creature Enchantment 10 Decreases the target's Quickness by 9 points. +4934 Slowness 1 Debuff Other 6 QuicknessLowering 1 10 Creature Enchantment 10 Decreases the target's Quickness by 9 points. +4935 Slowness 1 Debuff Other 6 QuicknessLowering 1 20 Creature Enchantment 10 Decreases the target's Quickness by 9 points. +4936 Flame Bolt I 8 Projectile Other 121 FireMissile 900 -1 War Magic 5 Shoots a mini iceball +4937 Flame Bolt I 8 Projectile Other 121 FireMissile 900 -1 War Magic 5 Shoots a mini iceball +4938 Flame Bolt I 8 Projectile Other 121 FireMissile 900 -1 War Magic 5 Shoots a mini arrow +4939 Mini Uber 8 Neutral Other 121 FireMissile 900 -1 War Magic 50 Shoots a bolt of elemental energy at the target. +4940 Mini Ring 5 Neutral Other 227 PiercingRing 200 -1 War Magic 80 Shoots eight waves of force outward from the caster. +4941 Mini Ring 5 Neutral Other 227 PiercingRing 200 -1 War Magic 80 Shoots eight waves of force outward from the caster. +4942 Mini Ring 5 Neutral Other 227 PiercingRing 200 -1 War Magic 80 Shoots eight waves of force outward from the caster. +4943 Mini Fireball 8 Neutral Other 121 FireMissile 900 -1 War Magic 5 Shoots a mini fireball +4944 Slowness 1 Debuff Other 6 QuicknessLowering 1 40 Creature Enchantment 10 Decreases the target's Quickness by 9 points. +4945 Flame Bolt I 8 Projectile Other 121 FireMissile 900 -1 War Magic 5 Shoots a mini arrow +4946 Mini Ring 5 Neutral Other 227 PiercingRing 200 -1 War Magic 80 Shoots eight waves of force outward from the caster. +4947 Harm 1 Harm Other 80 HealthLowering 1 -1 Life Magic 10 Drains 10-20 points of the target's Health. +4948 Harm 1 Harm Other 80 HealthLowering 1 -1 Life Magic 10 Drains 20-30 points of the target's Health. +4949 Harm 1 Harm Other 80 HealthLowering 1 -1 Life Magic 10 Drains 60-80 points of the target's Health. +4950 Tactical Defense 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4951 Tactical Defense 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4952 Tactical Defense 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4953 Test Portal 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Target is portaled for testing purposes and doesn't really go anywhere. +4954 Crystalline Portal 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Target is portaled into up to the Crystalline Crag +4955 Portal Space Eddy 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Target is portaled for testing purposes and doesn't really go anywhere +4956 Tanada Sanctum Portal Sending 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 This spell sends the player to the Tanada Clan inner sanctum. +4957 Tanada Sanctum Return 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 This spell sends the player to Tanada Sajo in Hebian-To. +4958 Greater Rockslide 8 Buff Item 19 BowRaising 450 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 55 points. +4959 Lesser Rockslide 8 Buff Item 19 BowRaising 400 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 45 points. +4960 Lesser Rockslide 8 Buff Item 19 BowRaising 400 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 45 points. +4961 Lesser Rockslide 8 Buff Item 19 BowRaising 400 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 45 points. +4962 Rockslide 8 Buff Item 19 BowRaising 425 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 50 points. +4963 Rockslide 8 Buff Item 19 BowRaising 425 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 50 points. +4964 Rockslide 8 Buff Item 19 BowRaising 425 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 50 points. +4965 Greater Rockslide 8 Buff Item 19 BowRaising 450 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 55 points. +4966 Greater Rockslide 8 Buff Item 19 BowRaising 450 5400 Creature Enchantment 80 Increases the target's Missile Weapons skill by 55 points. +4967 Cleansing Ring of Fire 5 Projectile Other 226 FireRing 200 -1 War Magic 80 Shoots eight waves of flame outward from the caster. Each wave does 31-52 points of fire damage to the first thing it hits. +4968 Ranger's Boon 1 Buff Other 439 ExtraBowSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 15 points. Additional spells can be layered over this. +4969 Ranger's Boon 1 Buff Other 439 ExtraBowSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 15 points. Additional spells can be layered over this. +4970 Ranger's Boon 1 Buff Other 439 ExtraBowSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 15 points. Additional spells can be layered over this. +4971 Enchanter's Boon 1 Buff Other 430 CreatureMysticRaising2 2 780 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 15 points. Additional spells can be layered over this. +4972 Hieromancer's Boon 1 Buff Other 426 WarMysticRaising2 2 780 Creature Enchantment 10 Increases the target's War Magic skill by 15 points. Additional spells can be layered over this. +4973 Fencer's Boon 1 Buff Other 442 CascadeDaggerRaising2 2 780 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 15 points. Additional spells can be layered over this. +4974 Life Giver's Boon 1 Buff Other 429 ExtraLifeMagicSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Life Magic skill by 15 points. Additional spells can be layered over this. +4975 Kern's Boon 1 Buff Other 438 CascadeAxeRaising2 2 600 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. Additional spells can be layered over this. +4976 Kern's Boon 1 Buff Other 438 CascadeAxeRaising2 2 600 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. Additional spells can be layered over this. +4977 Kern's Boon 1 Buff Other 438 CascadeAxeRaising2 2 600 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. Additional spells can be layered over this. +4978 Kern's Boon 1 Buff Other 438 CascadeAxeRaising2 2 600 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. Additional spells can be layered over this. +4979 Soldier's Boon 1 Buff Other 447 ExtraSwordSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 15 points. Additional spells can be layered over this. +4980 Kern's Boon 1 Buff Other 438 CascadeAxeRaising2 2 600 Creature Enchantment 10 Increases the target's Light Weapons skill by 15 points. Additional spells can be layered over this. +4981 Incantation of Stamina to Mana Self 8 Neutral Self 89 StaminaTransfertocaster 400 -1 Life Magic 80 Drains one-half of the caster's Stamina and gives 200% of that to his/her Mana. +4982 Nimble Fingers - Lockpick 1 Buff Other 584 CraftingLockPickRaising 5 360 Creature Enchantment 70 Increases the target's Lockpick skill by 5 points. This stacks with all other Lockpick bonuses. +4983 Nimble Fingers - Alchemy 1 Buff Other 587 CraftingAlchemyRaising 5 360 Creature Enchantment 50 Increases the caster's Alchemy skill by 5 points. This stacks with all other Alchemy bonuses. +4984 Nimble Fingers - Cooking 1 Buff Other 586 CraftingCookingRaising 5 360 Creature Enchantment 70 Increases the target's Cooking skill by 5 points. This stacks with all other Cooking bonuses. +4985 Nimble Fingers - Fletching 1 Buff Other 585 CraftingFletchingRaising 5 360 Creature Enchantment 50 Increases the target's Fletching skill by 5 points. This stacks with all other Fletching bonuses. +4986 Assassin's Alchemy Kit 1 Buff Other 592 SkillPercentAlchemyRaising 1 360 Creature Enchantment 50 Increases the caster's Alchemy skill by 1%. This increase stacks with all other Alchemy increases. +4987 Olthoi Spit 1 Neutral Other 117 AcidMissile 1 -1 War Magic 5 A spell-like projectile of condensed olthoi acid. +4988 Tunnel Out 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 The olthoi matron tunnels away. +4989 Mysterious Portal 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4990 Floor Puzzle Bypass 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4991 Jump Puzzle Bypass 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4992 Direct Assassin Access 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +4993 Portal to Derethian Combat Arena 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the PK Challenge. +4994 Get over here! 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 The assassin teleports you to her. +4995 Portal to Derethian Combat Arena 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the PK Challenge. +4996 Portal to Derethian Combat Arena 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the PK Challenge. +4997 Portal to Derethian Combat Arena 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the PK Challenge. +4998 Arena Stamina 1 Buff Other 281 StaminaGiverRaising 15 180 Life Magic 70 Increases maximum stamina by 25 points. +4999 Arena Life 1 Buff Other 279 LifeGiverRaising 15 180 Life Magic 70 Increases maximum health by 25 points. +5000 Arena Mana 6 Buff Other 283 ManaGiverRaising 250 180 Life Magic 70 Increases maximum mana by 25 points. +5001 Arena Piercing Protection Other 8 Buff Other 111 PierceProtection 400 180 Life Magic 80 Reduces damage the target takes from Piercing by 70% +5002 Arena Acid Protection Other 8 Buff Other 101 AcidProtection 400 180 Life Magic 80 Reduces damage the target takes from acid by 70% +5003 Arena Blade Protection Other 8 Buff Other 113 SlashProtection 400 180 Life Magic 80 Reduces damage the target takes from Slashing by 70% +5004 Arena Bludgeoning Protection Other 8 Buff Other 103 BludgeonProtection 400 180 Life Magic 80 Reduces damage the target takes from Bludgeoning by 70% +5005 Arena Cold Protection Other 8 Buff Other 105 ColdProtection 400 180 Life Magic 80 Reduces damage the target takes from Cold by 70% +5006 Arena Fire Protection Other 8 Buff Other 109 FireProtection 400 180 Life Magic 80 Reduces damage the target takes from fire by 70% +5007 Arena Lightning Protection Other 8 Buff Other 107 ElectricProtection 400 180 Life Magic 80 Reduces damage the target takes from Lightning by 70% +5008 Apostate Nexus Portal Sending 5 Utility Self 214 PortalSending 200 -1 Item Enchantment 50 Teleports the user to the Apostate Nexus dungeon. +5009 Aerfalle's Greater Ward 8 Buff Item 160 ArmorValueRaising 401 3600 Item Enchantment 60 Improves a shield or piece of armor's armor value by 400 points. +5010 Entering Aerfalle's Sanctum 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5011 Geomantic Raze 8 Debuff Other 80 HealthLowering 400 -1 Life Magic 70 Drains 150-300 points of the target's Health. +5012 Mar'uun 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 A portal to the town of Mar'uun; there is something strange about it. +5013 Mar'uun 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 A portal to the town of Mar'uun; there is something strange about it. +5014 Mar'uun 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 A portal to the town of Mar'uun; there is something strange about it. +5015 Mar'uun 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 A portal to the town of Mar'uun; there is something strange about it. +5016 Mar'uun 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 A portal to the town of Mar'uun; there is something strange about it. +5017 Mar'uun 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 A portal to the town of Mar'uun; there is something strange about it. +5018 Story of the Unknown Warrior 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5019 Portalspace Rift 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 A rift in portal space. +5020 Portalspace Rift 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 A rift in portal space. +5021 Portalspace Rift 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 A rift in portal space. +5022 Portalspace Rift 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 A rift in portal space. +5023 Spectral Two Handed Combat Mastery 6 Buff Other 598 TwoHandedRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Two Handed Combat skill by 150 points for 9 minutes. +5024 Spectral Item Expertise 8 Buff Other 453 AppraiseItemRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Item Tinkering skill by 150 points. +5025 Prodigal Item Expertise 8 Buff Other 453 AppraiseItemRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Item Tinkering skill by 250 points. +5026 Prodigal Two Handed Combat Mastery 8 Buff Other 598 TwoHandedRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Two Handed Combat skill by 250 points. +5027 Greater Cascade 1 Buff Other 595 ExtraTwoHandedSkillRaising 15 780 Creature Enchantment 30 Increases the target's Two Handed Combat skill by 15 points. +5028 Lesser Cascade 1 Buff Other 595 ExtraTwoHandedSkillRaising 8 780 Creature Enchantment 30 Increases the target's Two Handed Combat skill by 8 points. +5029 Cascade 1 Buff Other 595 ExtraTwoHandedSkillRaising 12 780 Creature Enchantment 30 Increases the target's Two Handed Combat skill by 12 points. +5030 Two Handed Fighter's Boon 1 Buff Other 597 ExtraTwoHandedSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 2 points. Additional spells can be layered over this. +5031 Two Handed Fighter's Boon 1 Buff Other 597 ExtraTwoHandedSkillRaising2 2 780 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 15 points. Additional spells can be layered over this. +5032 Incantation of Two Handed Combat Mastery Self 8 Buff Self 593 TwoHandedRaising 400 5400 Creature Enchantment 80 Increases the caster's Two Handed Combat skill by 45 points. +5033 Epic Item Tinkering Expertise 1 Buff Other 353 ExtraAppraiseItemSkillRaising 25 780 Creature Enchantment 10 Increases the target's Item Tinkering skill by 25 points. Additional spells can be layered over this. +5034 Epic Two Handed Combat Aptitude 1 Buff Other 595 ExtraTwoHandedSkillRaising 25 780 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 25 points. Additional spells can be layered over this. +5035 Feeble Sword Aptitude 1 Buff Other 595 ExtraTwoHandedSkillRaising 3 780 Creature Enchantment 10 Increases the target's Sword skill by 3 points. Additional spells can be layered over this. +5036 Feeble Two Handed Combat Aptitude 1 Buff Other 595 ExtraTwoHandedSkillRaising 3 780 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 3 points. Additional spells can be layered over this. +5037 Item Tinkering Ignorance Other I 1 Debuff Other 58 AppraiseItemLowering 1 60 Creature Enchantment 10 Decreases the target's Item Tinkering skill by 10 points. +5038 Item Tinkering Ignorance Other II 2 Debuff Other 58 AppraiseItemLowering 75 90 Creature Enchantment 20 Decreases the target's Item Tinkering skill by 15 points. +5039 Item Tinkering Ignorance Other III 3 Debuff Other 58 AppraiseItemLowering 125 120 Creature Enchantment 30 Decreases the target's Item Tinkering skill by 20 points. +5040 Item Tinkering Ignorance Other IV 4 Debuff Other 58 AppraiseItemLowering 175 150 Creature Enchantment 40 Decreases the target's Item Tinkering skill by 25 points. +5041 Item Tinkering Ignorance Other V 5 Debuff Other 58 AppraiseItemLowering 225 180 Creature Enchantment 50 Decreases the target's Item Tinkering skill by 30 points. +5042 Item Tinkering Ignorance Other VI 6 Debuff Other 58 AppraiseItemLowering 275 210 Creature Enchantment 60 Decreases the target's Item Tinkering skill by 35 points. +5043 Unfortunate Appraisal 7 Debuff Other 58 AppraiseItemLowering 325 240 Creature Enchantment 70 Decreases the target's Item Tinkering skill by 40 points. +5044 Incantation of Item Tinkering Ignorance Other 8 Debuff Other 58 AppraiseItemLowering 400 300 Creature Enchantment 80 Decreases the target's Item Tinkering skill by 45 points. +5045 Item Tinkering Ignorance Self I 1 Debuff Self 58 AppraiseItemLowering 1 60 Creature Enchantment 15 Decreases the caster's Item Tinkering skill by 10 points. +5046 Item Tinkering Ignorance Self II 2 Debuff Self 58 AppraiseItemLowering 75 90 Creature Enchantment 30 Decreases the caster's Item Tinkering skill by 15 points. +5047 Item Tinkering Ignorance Self III 3 Debuff Self 58 AppraiseItemLowering 125 120 Creature Enchantment 40 Decreases the caster's Item Tinkering skill by 20 points. +5048 Item Tinkering Ignorance Self IV 4 Debuff Self 58 AppraiseItemLowering 175 150 Creature Enchantment 50 Decreases the caster's Item Tinkering skill by 25 points. +5049 Item Tinkering Ignorance Self V 5 Debuff Self 58 AppraiseItemLowering 225 180 Creature Enchantment 60 Decreases the caster's Item Tinkering skill by 30 points. +5050 Item Tinkering Ignorance Self VI 6 Debuff Self 58 AppraiseItemLowering 275 210 Creature Enchantment 70 Decreases the caster's Item Tinkering skill by 35 points. +5051 Item Tinkering Ignorance Self VII 7 Debuff Self 58 AppraiseItemLowering 325 240 Creature Enchantment 70 Decreases the caster's Item Tinkering skill by 40 points. +5052 Incantation of Item Tinkering Ignorance Self 8 Debuff Self 58 AppraiseItemLowering 400 300 Creature Enchantment 80 Decreases the caster's Item Tinkering skill by 45 points. +5053 Item Tinkering Expertise Other I 1 Buff Other 57 AppraiseItemRaising 1 1800 Creature Enchantment 10 Increases the target's Item Tinkering skill by 10 points. +5054 Item Tinkering Expertise Other II 2 Buff Other 57 AppraiseItemRaising 50 1800 Creature Enchantment 20 Increases the target's Item Tinkering skill by 15 points. +5055 Item Tinkering Expertise Other III 3 Buff Other 57 AppraiseItemRaising 100 1800 Creature Enchantment 30 Increases the target's Item Tinkering skill by 20 points. +5056 Item Tinkering Expertise Other IV 4 Buff Other 57 AppraiseItemRaising 150 1800 Creature Enchantment 40 Increases the target's Item Tinkering skill by 25 points. +5057 Item Tinkering Expertise Other V 5 Buff Other 57 AppraiseItemRaising 200 1800 Creature Enchantment 50 Increases the target's Item Tinkering skill by 30 points. +5058 Item Tinkering Expertise Other VI 6 Buff Other 57 AppraiseItemRaising 250 2700 Creature Enchantment 60 Increases the target's Item Tinkering skill by 35 points. +5059 Yoshi's Boon 7 Buff Other 57 AppraiseItemRaising 300 3600 Creature Enchantment 70 Increases the target's Item Tinkering skill by 40 points. +5060 Incantation of Item Tinkering Expertise Other 8 Buff Other 57 AppraiseItemRaising 400 5400 Creature Enchantment 80 Increases the target's Item Tinkering skill by 45 points. +5061 Item Tinkering Expertise Self I 1 Buff Self 57 AppraiseItemRaising 1 1800 Creature Enchantment 15 Increases the caster's Item Tinkering skill by 10 points. +5062 Item Tinkering Expertise Self II 2 Buff Self 57 AppraiseItemRaising 50 1800 Creature Enchantment 30 Increases the caster's Item Tinkering skill by 15 points. +5063 Item Tinkering Expertise Self III 3 Buff Self 57 AppraiseItemRaising 100 1800 Creature Enchantment 40 Increases the caster's Item Tinkering skill by 20 points. +5064 Item Tinkering Expertise Self IV 4 Buff Self 57 AppraiseItemRaising 150 1800 Creature Enchantment 50 Increases the caster's Item Tinkering skill by 25 points. +5065 Item Tinkering Expertise Self V 5 Buff Self 57 AppraiseItemRaising 200 1800 Creature Enchantment 60 Increases the caster's Item Tinkering skill by 30 points. +5066 Item Tinkering Expertise Self VI 6 Buff Self 57 AppraiseItemRaising 250 2700 Creature Enchantment 70 Increases the caster's Item Tinkering skill by 35 points. +5067 Yoshi's Blessing 7 Buff Other 57 AppraiseItemRaising 300 3600 Creature Enchantment 70 Increases the caster's Item Tinkering skill by 40 points. +5068 Incantation of Item Tinkering Expertise Self 8 Buff Self 57 AppraiseItemRaising 400 5400 Creature Enchantment 80 Increases the caster's Item Tinkering skill by 45 points. +5069 Major Item Tinkering Expertise 1 Buff Other 353 ExtraAppraiseItemSkillRaising 2 780 Creature Enchantment 10 Increases the target's Item Tinkering skill by 15 points. Additional spells can be layered over this. +5070 Major Two Handed Combat Aptitude 1 Buff Other 595 ExtraTwoHandedSkillRaising 15 780 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 15 points. Additional spells can be layered over this. +5071 Minor Item Tinkering Expertise 1 Buff Other 353 ExtraAppraiseItemSkillRaising 1 780 Creature Enchantment 10 Increases the target's Item Tinkering skill by 5 points. Additional spells can be layered over this. +5072 Minor Two Handed Combat Aptitude 1 Buff Other 595 ExtraTwoHandedSkillRaising 5 780 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 5 points. Additional spells can be layered over this. +5073 Moderate Item Tinkering Expertise 1 Buff Other 602 ExtraGearCraftSkillRaising 10 780 Creature Enchantment 10 Increases the target's Item Tinkering skill by 10 points. Additional spells can be layered over this. +5074 Moderate Two Handed Combat Aptitude 1 Buff Other 595 ExtraTwoHandedSkillRaising 10 780 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 10 points. Additional spells can be layered over this. +5075 Two Handed Combat Ineptitude Other I 1 Debuff Other 594 TwoHandedLowering 1 60 Creature Enchantment 10 Decreases the target's Two Handed Combat skill by 10 points. +5076 Two Handed Combat Ineptitude Other II 2 Debuff Other 594 TwoHandedLowering 75 90 Creature Enchantment 20 Decreases the target's Two Handed Combat skill by 15 points. +5077 Two Handed Combat Ineptitude Other III 3 Debuff Other 594 TwoHandedLowering 125 120 Creature Enchantment 30 Decreases the target's Two Handed Combat skill by 20 points. +5078 Two Handed Combat Ineptitude Other IV 4 Debuff Other 594 TwoHandedLowering 175 150 Creature Enchantment 40 Decreases the target's Two Handed Combat skill by 25 points. +5079 Two Handed Combat Ineptitude Other V 5 Debuff Other 594 TwoHandedLowering 225 180 Creature Enchantment 50 Decreases the target's Two Handed Combat skill by 30 points. +5080 Two Handed Combat Ineptitude Other VI 6 Debuff Other 594 TwoHandedLowering 275 210 Creature Enchantment 60 Decreases the target's Two Handed Combat skill by 35 points. +5081 Greased Palms 7 Debuff Other 594 TwoHandedLowering 325 240 Creature Enchantment 70 Decreases the target's Two Handed Combat skill by 40 points. +5082 Incantation of Two Handed Combat Ineptitude Other 8 Debuff Other 594 TwoHandedLowering 400 300 Creature Enchantment 80 Decreases the target's Two Handed Combat skill by 45 points. +5083 Two Handed Combat Ineptitude Self I 1 Debuff Self 594 TwoHandedLowering 1 60 Creature Enchantment 15 Decreases the caster's Two Handed Combat skill by 10 points. +5084 Two Handed Combat Ineptitude Self II 2 Debuff Self 594 TwoHandedLowering 75 90 Creature Enchantment 30 Decreases the caster's Two Handed Combat skill by 15 points. +5085 Two Handed Combat Ineptitude Self III 3 Debuff Self 594 TwoHandedLowering 125 120 Creature Enchantment 40 Decreases the caster's Two Handed Combat skill by 20 points. +5086 Two Handed Combat Ineptitude Self IV 4 Debuff Self 594 TwoHandedLowering 175 150 Creature Enchantment 50 Decreases the caster's Two Handed Combat skill by 25 points. +5087 Two Handed Combat Ineptitude Self V 5 Debuff Self 594 TwoHandedLowering 225 180 Creature Enchantment 60 Decreases the caster's Two Handed Combat skill by 30 points. +5088 Two Handed Combat Ineptitude Self VI 6 Debuff Self 594 TwoHandedLowering 275 210 Creature Enchantment 70 Decreases the caster's Two Handed Combat skill by 35 points. +5089 Two Handed Combat Ineptitude Self VII 7 Debuff Self 594 TwoHandedLowering 325 240 Creature Enchantment 70 Decreases the caster's Two Handed Combat skill by 40 points. +5090 Incantation of Two Handed Combat Ineptitude Self 8 Debuff Self 594 TwoHandedLowering 400 300 Creature Enchantment 80 Decreases the caster's Two Handed Combat skill by 45 points. +5091 Two Handed Combat Mastery Other I 1 Buff Other 593 TwoHandedRaising 1 1800 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 10 points. +5092 Two Handed Combat Mastery Other II 2 Buff Other 593 TwoHandedRaising 50 1800 Creature Enchantment 20 Increases the target's Two Handed Combat skill by 15 points. +5093 Two Handed Combat Mastery Other III 3 Buff Other 593 TwoHandedRaising 100 1800 Creature Enchantment 30 Increases the target's Two Handed Combat skill by 20 points. +5094 Two Handed Combat Mastery Other IV 4 Buff Other 593 TwoHandedRaising 150 1800 Creature Enchantment 40 Increases the target's Two Handed Combat skill by 25 points. +5095 Two Handed Combat Mastery Other V 5 Buff Other 593 TwoHandedRaising 200 1800 Creature Enchantment 50 Increases the target's Two Handed Combat skill by 30 points. +5096 Two Handed Combat Mastery Other VI 6 Buff Other 593 TwoHandedRaising 250 2700 Creature Enchantment 60 Increases the target's Two Handed Combat skill by 35 points. +5097 Boon of T'ing 7 Buff Other 593 TwoHandedRaising 300 3600 Creature Enchantment 70 Increases the target's Two Handed Combat skill by 40 points. +5098 Incantation of Two Handed Combat Mastery Other 8 Buff Other 593 TwoHandedRaising 400 5400 Creature Enchantment 80 Increases the target's Two Handed Combat skill by 45 points. +5099 Two Handed Combat Mastery Self I 1 Buff Self 593 TwoHandedRaising 1 1800 Creature Enchantment 15 Increases the caster's Two Handed Combat skill by 10 points. +5100 Two Handed Combat Mastery Self II 2 Buff Self 593 TwoHandedRaising 50 1800 Creature Enchantment 30 Increases the caster's Two Handed Combat skill by 15 points. +5101 Two Handed Combat Mastery Self III 3 Buff Self 593 TwoHandedRaising 100 1800 Creature Enchantment 40 Increases the caster's Two Handed Combat skill by 20 points. +5102 Two Handed Combat Mastery Self IV 4 Buff Self 593 TwoHandedRaising 150 1800 Creature Enchantment 50 Increases the caster's Two Handed Combat skill by 25 points. +5103 Two Handed Combat Mastery Self V 5 Buff Self 593 TwoHandedRaising 200 1800 Creature Enchantment 60 Increases the caster's Two Handed Combat skill by 30 points. +5104 Two Handed Combat Mastery Self VI 6 Buff Self 593 TwoHandedRaising 250 2700 Creature Enchantment 70 Increases the caster's Two Handed Combat skill by 35 points. +5105 Blessing of T'ing 7 Buff Other 593 TwoHandedRaising 300 3600 Creature Enchantment 70 Increases the caster's Two Handed Combat skill by 40 points. +5106 Master Inventor's Item Tinkering Aptitude 1 Buff Other 563 SetItemTinkeringRaising 4 1800 Creature Enchantment 10 Increases the target's Item Tinkering skill by 20 points. +5107 Novice Soldier's Two Handed Combat Aptitude 1 Buff Other 599 SetTwoHandedRaising 1 1800 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 3 points. +5108 Apprentice Soldier's Two Handed Combat Aptitude 1 Buff Other 599 SetTwoHandedRaising 2 1800 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 5 points. +5109 Journeyman Soldier's Two Handed Combat Aptitude 1 Buff Other 599 SetTwoHandedRaising 3 1800 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 10 points. +5110 Master Soldier's Two Handed Combat Aptitude 1 Buff Other 599 SetTwoHandedRaising 4 1800 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 20 points. +5111 Novice Inventor's Item Tinkering Aptitude 1 Buff Other 563 SetItemTinkeringRaising 1 1800 Creature Enchantment 10 Increases the target's Item Tinkering skill by 3 points. +5112 Apprentice Inventor's Item Tinkering Aptitude 1 Buff Other 563 SetItemTinkeringRaising 2 1800 Creature Enchantment 10 Increases the target's Item Tinkering skill by 5 points. +5113 Journeyman Inventor's Item Tinkering Aptitude 1 Buff Other 563 SetItemTinkeringRaising 3 1800 Creature Enchantment 10 Increases the target's Item Tinkering skill by 10 points. +5114 Expose Weakness VIII 8 Debuff Other 116 ArmorLowering 400 300 Life Magic 80 Decreases the target's natural armor by 225 points. +5115 Expose Weakness I 1 Debuff Other 116 ArmorLowering 25 60 Life Magic 10 Decreases the target's natural armor by 20 points. +5116 Expose Weakness II 2 Debuff Other 116 ArmorLowering 75 90 Life Magic 20 Decreases the target's natural armor by 50 points. +5117 Expose Weakness III 3 Debuff Other 116 ArmorLowering 125 120 Life Magic 30 Decreases the target's natural armor by 75 points. +5118 Expose Weakness IV 4 Debuff Other 116 ArmorLowering 175 150 Life Magic 40 Decreases the target's natural armor by 100 points. +5119 Expose Weakness V 5 Debuff Other 116 ArmorLowering 225 180 Life Magic 50 Decreases the target's natural armor by 150 points. +5120 Expose Weakness VI 6 Debuff Other 116 ArmorLowering 275 210 Life Magic 60 Decreases the target's natural armor by 200 points. +5121 Expose Weakness VII 7 Debuff Other 116 ArmorLowering 325 240 Life Magic 70 Decreases the target's natural armor by 225 points. +5122 Call of Leadership V 8 Buff Other 609 LeadershipHealthRaising 400 1800 Life Magic 80 Increases maximum health by 10 points for 30 minutes. +5123 Answer of Loyalty (Mana) I 4 Buff Other 607 LoyaltyManaRaising 175 1800 Life Magic 40 Enhances the Mana of all Fellowship members by 2 points for 30 minutes. +5124 Answer of Loyalty (Mana) II 5 Buff Other 607 LoyaltyManaRaising 225 1800 Life Magic 50 Enhances the Mana of all Fellowship members by 4 points for 30 minutes. +5125 Answer of Loyalty (Mana) III 6 Buff Other 607 LoyaltyManaRaising 275 1800 Life Magic 60 Enhances the Mana of all Fellowship members by 6 points for 30 minutes. +5126 Answer of Loyalty (Mana) IV 7 Buff Other 607 LoyaltyManaRaising 325 1800 Life Magic 70 Enhances the Mana of all Fellowship members by 8 points for 30 minutes. +5127 Answer of Loyalty (Mana) V 8 Buff Other 607 LoyaltyManaRaising 400 1800 Life Magic 80 Enhances the Mana of all Fellowship members by 10 points for 30 minutes. +5128 Answer of Loyalty (Stamina) I 4 Buff Other 608 LoyaltyStaminaRaising 175 1800 Life Magic 40 Enhances the Endurance of all Fellowship members by 2 points for 30 minutes. +5129 Answer of Loyalty (Stamina) II 5 Buff Other 608 LoyaltyStaminaRaising 225 1800 Life Magic 50 Enhances the Endurance of all Fellowship members by 4 points for 30 minutes. +5130 Answer of Loyalty (Stamina) III 6 Buff Other 608 LoyaltyStaminaRaising 275 1800 Life Magic 60 Enhances the Endurance of all Fellowship members by 6 points for 30 minutes. +5131 Answer of Loyalty (Stamina) IV 7 Buff Other 608 LoyaltyStaminaRaising 325 1800 Life Magic 70 Enhances the Endurance of all Fellowship members by 8 points for 30 minutes. +5132 Answer of Loyalty (Stamina) V 8 Buff Other 608 LoyaltyStaminaRaising 400 1800 Life Magic 80 Enhances the Endurance of all Fellowship members by 10 points for 30 minutes. +5133 Call of Leadership I 4 Buff Other 609 LeadershipHealthRaising 175 1800 Life Magic 40 Increases maximum health by 2 points for 30 minutes. +5134 Call of Leadership II 5 Buff Other 609 LeadershipHealthRaising 225 1800 Life Magic 50 Increases maximum health by 4 points for 30 minutes. +5135 Call of Leadership III 6 Buff Other 609 LeadershipHealthRaising 275 1800 Life Magic 60 Increases maximum health by 6 points for 30 minutes. +5136 Call of Leadership IV 7 Buff Other 609 LeadershipHealthRaising 325 1800 Life Magic 70 Increases maximum health by 8 points for 30 minutes. +5137 Augmented Understanding III 1 Buff Other 615 TrinketXPRaising 3 510 Life Magic 70 Increases experience by 6%. +5138 Augmented Damage I 1 Buff Other 610 TrinketDamageRaising 1 510 Life Magic 70 Increases damage rating by 1. +5139 Augmented Damage II 1 Buff Other 610 TrinketDamageRaising 2 510 Life Magic 70 Increases damage rating by 2. +5140 Augmented Damage III 1 Buff Other 610 TrinketDamageRaising 3 510 Life Magic 70 Increases damage rating by 3. +5141 Augmented Damage Reduction I 1 Debuff Other 611 TrinketDamageLowering 1 510 Life Magic 70 Increases damage reduction rating by 1. +5142 Augmented Damage Reduction II 1 Debuff Other 611 TrinketDamageLowering 2 510 Life Magic 70 Increases damage reduction rating by 2. +5143 Augmented Damage Reduction III 1 Debuff Other 611 TrinketDamageLowering 3 510 Life Magic 70 Increases damage reduction rating by 3. +5144 Augmented Health I 1 Buff Other 612 TrinketHealthRaising 1 510 Life Magic 70 Increases maximum health by 5 points. +5145 Augmented Health II 1 Buff Other 612 TrinketHealthRaising 2 510 Life Magic 70 Increases maximum health by 10 points. +5146 Augmented Health III 1 Buff Other 612 TrinketHealthRaising 3 510 Life Magic 70 Increases maximum health by 15 points. +5147 Augmented Mana I 1 Buff Other 614 TrinketManaRaising 1 510 Life Magic 70 Increases maximum mana by 10 points. +5148 Augmented Mana II 1 Buff Other 614 TrinketManaRaising 2 510 Life Magic 70 Increases maximum mana by 20 points. +5149 Augmented Mana III 1 Buff Other 614 TrinketManaRaising 3 510 Life Magic 70 Increases maximum mana by 30 points. +5150 Augmented Stamina I 1 Buff Other 613 TrinketStaminaRaising 1 510 Life Magic 70 Increases maximum stamina by 10 points. +5151 Augmented Stamina II 1 Buff Other 613 TrinketStaminaRaising 2 510 Life Magic 70 Increases maximum stamina by 20 points. +5152 Augmented Stamina III 1 Buff Other 613 TrinketStaminaRaising 3 510 Life Magic 70 Increases maximum stamina by 30 points. +5153 Augmented Understanding I 1 Buff Other 615 TrinketXPRaising 1 510 Life Magic 70 Increases experience by 2%. +5154 Augmented Understanding II 1 Buff Other 615 TrinketXPRaising 2 510 Life Magic 70 Increases experience by 4%. +5155 Virindi Whisper IV 4 Buff Other 616 DeceptionArcaneLoreRaising 150 60 Creature Enchantment 40 Increases the target's Arcane Lore skill by 32 points for 60 seconds. +5156 Virindi Whisper V 5 Buff Other 616 DeceptionArcaneLoreRaising 225 60 Creature Enchantment 50 Increases the target's Arcane Lore skill by 40 points for 60 seconds. +5157 Virindi Whisper I 1 Buff Other 616 DeceptionArcaneLoreRaising 1 60 Creature Enchantment 10 Increases the target's Arcane Lore skill by 8 points for 60 seconds. +5158 Virindi Whisper II 2 Buff Other 616 DeceptionArcaneLoreRaising 50 60 Creature Enchantment 20 Increases the target's Arcane Lore skill by 16 points for 60 seconds. +5159 Virindi Whisper III 3 Buff Other 616 DeceptionArcaneLoreRaising 100 60 Creature Enchantment 30 Increases the target's Arcane Lore skill by 24 points for 60 seconds. +5160 Mhoire Castle 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5161 Mhoire Castle Great Hall 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5162 Mhoire Castle Northeast Tower 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5163 Mhoire Castle Northwest Tower 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5164 Mhoire Castle Southeast Tower 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5165 Mhoire Castle Southwest Tower 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5166 Flaming Skull 7 Neutral Other 121 FireMissile 320 -1 War Magic 120 A burning skull +5167 Mhoire Castle Exit Portal 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5168 a spectacular view of the Mhoire lands 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 You've fallen into the spectral waters! +5169 a descent into the Mhoire catacombs 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 You've fallen into the spectral waters! +5170 a descent into the Mhoire catacombs 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 You've fallen into the spectral waters! +5171 Spectral Fountain Sip 6 Buff Other 617 HealOverTimeRaising 250 300 Life Magic 80 You've sipped the spectral waters. You're feeling pretty good. +5172 Spectral Fountain Sip 6 Buff Other 618 DamageOverTimeRaising 250 300 Life Magic 80 You've sipped the spectral waters. Your blood is poisoned. +5173 Spectral Fountain Sip 6 Buff Other 619 HealingResistRatingRaising 250 300 Life Magic 80 You've sipped the spectral waters. Your wounds are poisoned and don't heal as well. +5174 Mhoire's Blessing of Power 6 Buff Other 610 TrinketDamageRaising 250 300 Life Magic 80 Your damage has been augmented by the magic of the Mhoire blood. +5175 Facility Hub Recall 3 Utility Self 214 PortalSending 125 -1 Item Enchantment 10 Transports the caster to the Facilty Hub. +5176 Celestial Hand Basement 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5177 Radiant Blood Basement 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5178 Eldrytch Web Basement 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5179 Celestial Hand Basement 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5180 Radiant Blood Basement 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5181 Eldrytch Web Basement 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5182 Aura of Incantation of Spirit Drinker 7 Buff Item 695 SpellDamageRaising 350 5400 Item Enchantment 80 Increases the elemental damage bonus of an elemental magic caster by 8%. +5183 Aura of Incantation of Blood Drinker Self 7 Buff Self 154 DamageRaising 350 5400 Item Enchantment 80 Increases a weapon's damage value by 24 points. +5184 Rare Damage Boost VII 1 Buff Other 633 RareDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 7. +5185 Rare Damage Boost VIII 1 Buff Other 633 RareDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 8. +5186 Rare Damage Boost IX 1 Buff Other 633 RareDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 9. +5187 Rare Damage Boost X 1 Buff Other 633 RareDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 10. +5188 Rare Damage Reduction I 1 Buff Other 634 RareDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 1. +5189 Rare Damage Reduction II 1 Buff Other 634 RareDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 2. +5190 Rare Damage Reduction III 1 Buff Other 634 RareDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 3. +5191 Rare Damage Reduction IV 1 Buff Other 634 RareDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 4. +5192 Rare Damage Reduction V 1 Buff Other 634 RareDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 5. +5193 Rare Damage Reduction V 1 Buff Other 634 RareDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 5. +5194 Rare Damage Reduction V 1 Buff Other 634 RareDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 5. +5195 Rare Damage Reduction V 1 Buff Other 634 RareDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 5. +5196 Rare Damage Reduction V 1 Buff Other 634 RareDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 5. +5197 Rare Damage Reduction V 1 Buff Other 634 RareDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 5. +5198 Rare Damage Boost I 1 Buff Other 633 RareDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 1. +5199 Rare Damage Boost II 1 Buff Other 633 RareDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 2. +5200 Rare Damage Boost III 1 Buff Other 633 RareDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 3. +5201 Rare Damage Boost IV 1 Buff Other 633 RareDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 4. +5202 Rare Damage Boost V 1 Buff Other 633 RareDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 5. +5203 Rare Damage Boost VI 1 Buff Other 633 RareDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 6. +5204 Surge of Destruction 1 Buff Other 628 AetheriaProcDamageRatingRaising 1 8 Life Magic 70 The damage rating of the caster is increased by 20. +5205 Surge of Affliction 6 Buff Other 631 AetheriaProcDamageOverTimeRaising 250 19 Life Magic 80 The target loses 150 points of health over 19 seconds. +5206 Surge of Protection 1 Buff Other 629 AetheriaProcDamageReductionRaising 1 12 Life Magic 70 The damage reduction rating of the caster is increased by 20. +5207 Surge of Festering 6 Buff Other 619 HealingResistRatingRaising 250 12 Life Magic 80 The heal rating of the target is decreased by 20. +5208 Surge of Regeneration 6 Buff Other 630 AetheriaProcHealthOverTimeRaising 250 19 Life Magic 80 The caster gains 150 points of health over 19 seconds. +5209 Sigil of Fury I (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 1 510 Life Magic 70 Your critical damage rating is increased by 1. +5210 Sigil of Fury II (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 2 510 Life Magic 70 Your critical damage rating is increased by 2. +5211 Sigil of Fury III (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 3 510 Life Magic 70 Your critical damage rating is increased by 3. +5212 Sigil of Fury IV (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 4 510 Life Magic 70 Your critical damage rating is increased by 4. +5213 Sigil of Fury V (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 5 510 Life Magic 70 Your critical damage rating is increased by 5. +5214 Sigil of Fury VI (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 6 510 Life Magic 70 Your critical damage rating is increased by 6. +5215 Sigil of Fury VII (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 7 510 Life Magic 70 Your critical damage rating is increased by 7. +5216 Sigil of Fury VIII (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 8 510 Life Magic 70 Your critical damage rating is increased by 8. +5217 Sigil of Fury IX (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 9 510 Life Magic 70 Your critical damage rating is increased by 9. +5218 Sigil of Fury X (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 10 510 Life Magic 70 Your critical damage rating is increased by 10. +5219 Sigil of Fury XI (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 11 510 Life Magic 70 Your critical damage rating is increased by 11. +5220 Sigil of Fury XII (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 12 510 Life Magic 70 Your critical damage rating is increased by 12. +5221 Sigil of Fury XIII (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 13 510 Life Magic 70 Your critical damage rating is increased by 13. +5222 Sigil of Fury XIV (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 14 510 Life Magic 70 Your critical damage rating is increased by 14. +5223 Sigil of Fury XV (Critical Damage) 1 Buff Other 626 AetheriaCriticalDamageRaising 15 510 Life Magic 70 Your critical damage rating is increased by 15. +5224 Sigil of Destruction I 1 Buff Other 620 AetheriaDamageRatingRaising 1 510 Life Magic 70 Your damage rating is increased by 1. +5225 Sigil of Destruction II 1 Buff Other 620 AetheriaDamageRatingRaising 2 510 Life Magic 70 Your damage rating is increased by 2. +5226 Sigil of Destruction III 1 Buff Other 620 AetheriaDamageRatingRaising 3 510 Life Magic 70 Your damage rating is increased by 3. +5227 Sigil of Destruction IV 1 Buff Other 620 AetheriaDamageRatingRaising 4 510 Life Magic 70 Your damage rating is increased by 4. +5228 Sigil of Destruction V 1 Buff Other 620 AetheriaDamageRatingRaising 5 510 Life Magic 70 Your damage rating is increased by 5. +5229 Sigil of Destruction VI 1 Buff Other 620 AetheriaDamageRatingRaising 6 510 Life Magic 70 Your damage rating is increased by 6. +5230 Sigil of Destruction VII 1 Buff Other 620 AetheriaDamageRatingRaising 7 510 Life Magic 70 Your damage rating is increased by 7. +5231 Sigil of Destruction VIII 1 Buff Other 620 AetheriaDamageRatingRaising 8 510 Life Magic 70 Your damage rating is increased by 8. +5232 Sigil of Destruction IX 1 Buff Other 620 AetheriaDamageRatingRaising 9 510 Life Magic 70 Your damage rating is increased by 9. +5233 Sigil of Destruction X 1 Buff Other 620 AetheriaDamageRatingRaising 10 510 Life Magic 70 Your damage rating is increased by 10. +5234 Sigil of Destruction XI 1 Buff Other 620 AetheriaDamageRatingRaising 11 510 Life Magic 70 Your damage rating is increased by 11. +5235 Sigil of Destruction XII 1 Buff Other 620 AetheriaDamageRatingRaising 12 510 Life Magic 70 Your damage rating is increased by 12. +5236 Sigil of Destruction XIII 1 Buff Other 620 AetheriaDamageRatingRaising 13 510 Life Magic 70 Your damage rating is increased by 13. +5237 Sigil of Destruction XIV 1 Buff Other 620 AetheriaDamageRatingRaising 14 510 Life Magic 70 Your damage rating is increased by 14. +5238 Sigil of Destruction XV 1 Buff Other 620 AetheriaDamageRatingRaising 15 510 Life Magic 70 Your damage rating is increased by 15. +5239 Sigil of Defense I 1 Buff Other 621 AetheriaDamageReductionRaising 1 510 Life Magic 70 Your damage reduction rating is increased by 1. +5240 Sigil of Defense II 1 Buff Other 621 AetheriaDamageReductionRaising 2 510 Life Magic 70 Your damage reduction rating is increased by 2. +5241 Sigil of Defense III 1 Buff Other 621 AetheriaDamageReductionRaising 3 510 Life Magic 70 Your damage reduction rating is increased by 3. +5242 Sigil of Defense IV 1 Buff Other 621 AetheriaDamageReductionRaising 4 510 Life Magic 70 Your damage reduction rating is increased by 4. +5243 Sigil of Defense V 1 Buff Other 621 AetheriaDamageReductionRaising 5 510 Life Magic 70 Your damage reduction rating is increased by 5. +5244 Sigil of Defense VI 1 Buff Other 621 AetheriaDamageReductionRaising 6 510 Life Magic 70 Your damage reduction rating is increased by 6. +5245 Sigil of Defense VII 1 Buff Other 621 AetheriaDamageReductionRaising 7 510 Life Magic 70 Your damage reduction rating is increased by 7. +5246 Sigil of Defense VIII 1 Buff Other 621 AetheriaDamageReductionRaising 8 510 Life Magic 70 Your damage reduction rating is increased by 8. +5247 Sigil of Defense IX 1 Buff Other 621 AetheriaDamageReductionRaising 9 510 Life Magic 70 Your damage reduction rating is increased by 9. +5248 Sigil of Defense X 1 Buff Other 621 AetheriaDamageReductionRaising 10 510 Life Magic 70 Your damage reduction rating is increased by 10. +5249 Sigil of Defense XI 1 Buff Other 621 AetheriaDamageReductionRaising 11 510 Life Magic 70 Your damage reduction rating is increased by 11. +5250 Sigil of Defense XII 1 Buff Other 621 AetheriaDamageReductionRaising 12 510 Life Magic 70 Your damage reduction rating is increased by 12. +5251 Sigil of Defense XIII 1 Buff Other 621 AetheriaDamageReductionRaising 13 510 Life Magic 70 Your damage reduction rating is increased by 13. +5252 Sigil of Defense XIV 1 Buff Other 621 AetheriaDamageReductionRaising 14 510 Life Magic 70 Your damage reduction rating is increased by 14. +5253 Sigil of Defense XV 1 Buff Other 621 AetheriaDamageReductionRaising 15 510 Life Magic 70 Your damage reduction rating is increased by 15. +5254 Sigil of Growth I 1 Buff Other 627 AetheriaHealingAmplificationRaising 1 300 Life Magic 80 Your healing rating is increased by 1. +5255 Sigil of Growth II 1 Buff Other 627 AetheriaHealingAmplificationRaising 2 300 Life Magic 80 Your healing rating is increased by 2. +5256 Sigil of Growth III 1 Buff Other 627 AetheriaHealingAmplificationRaising 3 300 Life Magic 80 Your healing rating is increased by 3. +5257 Sigil of Growth IV 1 Buff Other 627 AetheriaHealingAmplificationRaising 4 300 Life Magic 80 Your healing rating is increased by 4. +5258 Sigil of Growth V 1 Buff Other 627 AetheriaHealingAmplificationRaising 5 300 Life Magic 80 Your healing rating is increased by 5. +5259 Sigil of Growth VI 1 Buff Other 627 AetheriaHealingAmplificationRaising 6 300 Life Magic 80 Your healing rating is increased by 6. +5260 Sigil of Growth VII 1 Buff Other 627 AetheriaHealingAmplificationRaising 7 300 Life Magic 80 Your healing rating is increased by 7. +5261 Sigil of Growth VIII 1 Buff Other 627 AetheriaHealingAmplificationRaising 8 300 Life Magic 80 Your healing rating is increased by 8. +5262 Sigil of Growth IX 1 Buff Other 627 AetheriaHealingAmplificationRaising 9 300 Life Magic 80 Your healing rating is increased by 9. +5263 Sigil of Growth X 1 Buff Other 627 AetheriaHealingAmplificationRaising 10 300 Life Magic 80 Your healing rating is increased by 10. +5264 Sigil of Growth XI 1 Buff Other 627 AetheriaHealingAmplificationRaising 11 300 Life Magic 80 Your healing rating is increased by 11. +5265 Sigil of Growth XII 1 Buff Other 627 AetheriaHealingAmplificationRaising 12 300 Life Magic 80 Your healing rating is increased by 12. +5266 Sigil of Growth XIII 1 Buff Other 627 AetheriaHealingAmplificationRaising 13 300 Life Magic 80 Your healing rating is increased by 13. +5267 Sigil of Growth XIV 1 Buff Other 627 AetheriaHealingAmplificationRaising 14 300 Life Magic 80 Your healing rating is increased by 14. +5268 Sigil of Growth XV 1 Buff Other 627 AetheriaHealingAmplificationRaising 15 300 Life Magic 80 Your healing rating is increased by 15. +5269 Sigil of Vigor I (Health) 1 Buff Other 623 AetheriaHealthRaising 1 510 Life Magic 70 Your health is increased by 1. +5270 Sigil of Vigor II (Health) 1 Buff Other 623 AetheriaHealthRaising 2 510 Life Magic 70 Your health is increased by 2. +5271 Sigil of Vigor III (Health) 1 Buff Other 623 AetheriaHealthRaising 3 510 Life Magic 70 Your health is increased by 3. +5272 Sigil of Vigor IV (Health) 1 Buff Other 623 AetheriaHealthRaising 4 510 Life Magic 70 Your health is increased by 4. +5273 Sigil of Vigor V (Health) 1 Buff Other 623 AetheriaHealthRaising 5 510 Life Magic 70 Your health is increased by 5. +5274 Sigil of Vigor VI (Health) 1 Buff Other 623 AetheriaHealthRaising 6 510 Life Magic 70 Your health is increased by 6. +5275 Sigil of Vigor VII (Health) 1 Buff Other 623 AetheriaHealthRaising 7 510 Life Magic 70 Your health is increased by 7. +5276 Sigil of Vigor VIII (Health) 1 Buff Other 623 AetheriaHealthRaising 8 510 Life Magic 70 Your health is increased by 8. +5277 Sigil of Vigor IX (Health) 1 Buff Other 623 AetheriaHealthRaising 9 510 Life Magic 70 Your health is increased by 9. +5278 Sigil of Vigor X (Health) 1 Buff Other 623 AetheriaHealthRaising 10 510 Life Magic 70 Your health is increased by 10. +5279 Sigil of Vigor XI (Health) 1 Buff Other 623 AetheriaHealthRaising 11 510 Life Magic 70 Your health is increased by 11. +5280 Sigil of Vigor XII (Health) 1 Buff Other 623 AetheriaHealthRaising 12 510 Life Magic 70 Your health is increased by 12. +5281 Sigil of Vigor XIII (Health) 1 Buff Other 623 AetheriaHealthRaising 13 510 Life Magic 70 Your health is increased by 13. +5282 Sigil of Vigor XIV (Health) 1 Buff Other 623 AetheriaHealthRaising 14 510 Life Magic 70 Your health is increased by 14. +5283 Sigil of Vigor XV (Health) 1 Buff Other 623 AetheriaHealthRaising 15 510 Life Magic 70 Your health is increased by 15. +5284 Sigil of Vigor I (Mana) 1 Buff Other 625 AetheriaManaRaising 1 510 Life Magic 70 Your mana is increased by 5. +5285 Sigil of Vigor II (Mana) 1 Buff Other 625 AetheriaManaRaising 2 510 Life Magic 70 Your mana is increased by 10. +5286 Sigil of Vigor III (Mana) 1 Buff Other 625 AetheriaManaRaising 3 510 Life Magic 70 Your mana is increased by 15. +5287 Sigil of Vigor IV (Mana) 1 Buff Other 625 AetheriaManaRaising 4 510 Life Magic 70 Your mana is increased by 20. +5288 Sigil of Vigor V (Mana) 1 Buff Other 625 AetheriaManaRaising 5 510 Life Magic 70 Your mana is increased by 25. +5289 Sigil of Vigor VI (Mana) 1 Buff Other 625 AetheriaManaRaising 6 510 Life Magic 70 Your mana is increased by 30. +5290 Sigil of Vigor VII (Mana) 1 Buff Other 625 AetheriaManaRaising 7 510 Life Magic 70 Your mana is increased by 35. +5291 Sigil of Vigor VIII (Mana) 1 Buff Other 625 AetheriaManaRaising 8 510 Life Magic 70 Your mana is increased by 40. +5292 Sigil of Vigor IX (Mana) 1 Buff Other 625 AetheriaManaRaising 9 510 Life Magic 70 Your mana is increased by 45. +5293 Sigil of Vigor X (Mana) 1 Buff Other 625 AetheriaManaRaising 10 510 Life Magic 70 Your mana is increased by 50. +5294 Sigil of Vigor XI (Mana) 1 Buff Other 625 AetheriaManaRaising 11 510 Life Magic 70 Your mana is increased by 55. +5295 Sigil of Vigor XII (Mana) 1 Buff Other 625 AetheriaManaRaising 12 510 Life Magic 70 Your mana is increased by 60. +5296 Sigil of Vigor XIII (Mana) 1 Buff Other 625 AetheriaManaRaising 13 510 Life Magic 70 Your mana is increased by 65. +5297 Sigil of Vigor XIV (Mana) 1 Buff Other 625 AetheriaManaRaising 14 510 Life Magic 70 Your mana is increased by 70. +5298 Sigil of Vigor XV (Mana) 1 Buff Other 625 AetheriaManaRaising 15 510 Life Magic 70 Your mana is increased by 75. +5299 Sigil of Vigor I (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 1 510 Life Magic 70 Your stamina is increased by 5. +5300 Sigil of Vigor II (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 2 510 Life Magic 70 Your stamina is increased by 10. +5301 Sigil of Vigor III (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 3 510 Life Magic 70 Your stamina is increased by 15. +5302 Sigil of Vigor IV (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 4 510 Life Magic 70 Your stamina is increased by 20. +5303 Sigil of Vigor V (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 5 510 Life Magic 70 Your stamina is increased by 25. +5304 Sigil of Vigor VI (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 6 510 Life Magic 70 Your stamina is increased by 30. +5305 Sigil of Vigor VII (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 7 510 Life Magic 70 Your stamina is increased by 35. +5306 Sigil of Vigor VIII (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 8 510 Life Magic 70 Your stamina is increased by 40. +5307 Sigil of Vigor IX (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 9 510 Life Magic 70 Your stamina is increased by 45. +5308 Sigil of Vigor X (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 10 510 Life Magic 70 Your stamina is increased by 50. +5309 Sigil of Vigor XI (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 11 510 Life Magic 70 Your stamina is increased by 55. +5310 Sigil of Vigor XII (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 12 510 Life Magic 70 Your stamina is increased by 60. +5311 Sigil of Vigor XIII (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 13 510 Life Magic 70 Your stamina is increased by 65. +5312 Sigil of Vigor XIV (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 14 510 Life Magic 70 Your stamina is increased by 70. +5313 Sigil of Vigor XV (Stamina) 1 Buff Other 624 AetheriaStaminaRaising 15 510 Life Magic 70 Your stamina is increased by 75. +5314 Blessing of Unity 6 Buff Other 617 HealOverTimeRaising 250 50 Life Magic 80 You heal 10 points of health every 5 seconds for 50 seconds. +5315 Sigil of Fury I (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 1. +5316 Sigil of Fury II (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 2. +5317 Sigil of Fury III (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 3. +5318 Sigil of Fury IV (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 4. +5319 Sigil of Fury V (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 5. +5320 Sigil of Fury VI (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 6. +5321 Sigil of Fury VII (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 7. +5322 Sigil of Fury VIII (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 8. +5323 Sigil of Fury IX (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 9. +5324 Sigil of Fury X (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 10. +5325 Sigil of Fury XI (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 11. +5326 Sigil of Fury XII (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 12. +5327 Sigil of Fury XIII (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 13. +5328 Sigil of Fury XIV (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 14. +5329 Sigil of Fury XV (Endurance) 1 Buff Other 635 AetheriaEnduranceRaising 1 510 Life Magic 70 Your endurance is increased by 15. +5330 Gear Knight Invasion Area Camp Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 Sends the caster to the Gear Knight Invasion Area Camp. +5331 Clouded Soul 8 Neutral Other 225 ElectricRing 700 -1 War Magic 80 Shoots eight waves of nether outward from the caster. Each wave does 200-250 points of nether damage to the first thing it hits. +5332 Bael'zharon's Nether Streak 8 Projectile Other 639 NetherStreak 700 -1 War Magic 80 Sends a bolt of nether streaking towards the target. The bolt does 125-200 points of nether damage to the first thing it hits. +5333 Bael'zharon's Nether Arc 8 Neutral Other 640 NetherMissile 700 -1 War Magic 40 Shoots a bolt of nether at the target. The bolt does 125-200 points of nether damage to the first thing it hits. +5334 Bael'zharons Curse of Destruction 8 Buff Other 636 NetherDamageOverTimeRaising 700 30 War Magic 80 The target loses 600 points of health over 30 seconds. +5335 Bael'zharons Curse of Minor Destruction 8 Buff Other 637 NetherDamageOverTimeRaising2 700 240 War Magic 80 The target loses 720 points of health over 120 seconds. +5336 Bael'zharons Curse of Festering 8 Buff Other 619 HealingResistRatingRaising 700 60 Life Magic 80 The heal rating of the target is decreased by 90. +5337 Destructive Curse VII 7 Buff Other 636 NetherDamageOverTimeRaising 325 30 Void Magic 70 The target loses 294 points of health over 30 seconds. +5338 Incantation of Destructive Curse 8 Buff Other 636 NetherDamageOverTimeRaising 400 30 Void Magic 80 The target loses 357 points of health over 30 seconds. +5339 Destructive Curse I 1 Buff Other 636 NetherDamageOverTimeRaising 25 30 Void Magic 10 The target loses 56 points of health over 30 seconds. +5340 Destructive Curse II 2 Buff Other 636 NetherDamageOverTimeRaising 75 30 Void Magic 20 The target loses 91 points of health over 30 seconds. +5341 Destructive Curse III 3 Buff Other 636 NetherDamageOverTimeRaising 125 30 Void Magic 30 The target loses 126 points of health over 30 seconds. +5342 Destructive Curse IV 4 Buff Other 636 NetherDamageOverTimeRaising 175 30 Void Magic 40 The target loses 154 points of health over 30 seconds. +5343 Destructive Curse V 5 Buff Other 636 NetherDamageOverTimeRaising 225 30 Void Magic 50 The target loses 189 points of health over 30 seconds. +5344 Destructive Curse VI 6 Buff Other 636 NetherDamageOverTimeRaising 275 30 Void Magic 60 The target loses 231 points of health over 30 seconds. +5345 Nether Streak V 5 Projectile Other 639 NetherStreak 200 -1 Void Magic 50 Sends a bolt of nether streaking towards the target. The bolt does 35-88 points of nether damage to the first thing it hits. +5346 Nether Streak VI 6 Projectile Other 639 NetherStreak 250 -1 Void Magic 60 Sends a bolt of nether streaking towards the target. The bolt does 42-105 points of nether damage to the first thing it hits. +5347 Nether Streak VII 7 Projectile Other 639 NetherStreak 300 -1 Void Magic 70 Sends a bolt of nether streaking towards the target. The bolt does 84-130 points of nether damage to the first thing it hits. +5348 Incantation of Nether Streak 8 Projectile Other 639 NetherStreak 400 -1 Void Magic 80 Sends a bolt of nether streaking towards the target. The bolt does 126-162 points of nether damage to the first thing it hits. +5349 Nether Bolt I 1 Projectile Other 640 NetherMissile 1 -1 Void Magic 5 Shoots a bolt of nether at the target. The bolt does 21-52 points of nether damage to the first thing it hits. +5350 Nether Bolt II 2 Projectile Other 640 NetherMissile 50 -1 Void Magic 10 Shoots a bolt of nether at the target. The bolt does 42-84 points of nether damage to the first thing it hits. +5351 Nether Bolt III 3 Projectile Other 640 NetherMissile 100 -1 Void Magic 15 Shoots a bolt of nether at the target. The bolt does 63-115 points of nether damage to the first thing it hits. +5352 Nether Bolt IV 4 Projectile Other 640 NetherMissile 150 -1 Void Magic 20 Shoots a bolt of nether at the target. The bolt does 73-146 points of nether damage to the first thing it hits. +5353 Nether Bolt V 5 Projectile Other 640 NetherMissile 200 -1 Void Magic 25 Shoots a bolt of nether at the target. The bolt does 84-178 points of nether damage to the first thing it hits. +5354 Nether Bolt VI 6 Projectile Other 640 NetherMissile 250 -1 Void Magic 30 Shoots a bolt of nether at the target. The bolt does 105-210 points of nether damage to the first thing it hits. +5355 Nether Bolt VII 7 Projectile Other 640 NetherMissile 300 -1 Void Magic 35 Shoots a bolt of nether at the target. The bolt does 168-262 points of nether damage to the first thing it hits. +5356 Incantation of Nether Bolt 8 Projectile Other 640 NetherMissile 400 -1 Void Magic 40 Shoots a bolt of nether at the target. The bolt does 252-325 points of nether damage to the first thing it hits. +5357 Nether Streak I 1 Projectile Other 639 NetherStreak 1 -1 Void Magic 10 Sends a bolt of nether streaking towards the target. The bolt does 10-27 points of nether damage to the first thing it hits. +5358 Nether Streak II 2 Projectile Other 639 NetherStreak 50 -1 Void Magic 20 Sends a bolt of nether streaking towards the target. The bolt does 21-42 points of nether damage to the first thing it hits. +5359 Nether Streak III 3 Projectile Other 639 NetherStreak 100 -1 Void Magic 30 Sends a bolt of nether streaking towards the target. The bolt does 25-56 points of nether damage to the first thing it hits. +5360 Nether Streak IV 4 Projectile Other 639 NetherStreak 150 -1 Void Magic 40 Sends a bolt of nether streaking towards the target. The bolt does 31-73 points of nether damage to the first thing it hits. +5361 Clouded Soul 5 Neutral Other 641 NetherRing 200 -1 Void Magic 80 Shoots eight waves of nether outward from the caster. Each wave does 94-147 points of nether damage to the first thing it hits. +5362 Nether Arc II 2 Neutral Other 640 NetherMissile 50 -1 Void Magic 10 Shoots a bolt of nether at the target. The bolt does 42-84 points of nether damage to the first thing it hits. +5363 Nether Arc III 3 Neutral Other 640 NetherMissile 100 -1 Void Magic 15 Shoots a bolt of nether at the target. The bolt does 63-115 points of nether damage to the first thing it hits. +5364 Nether Arc IV 4 Neutral Other 640 NetherMissile 150 -1 Void Magic 20 Shoots a bolt of nether at the target. The bolt does 73-147 points of nether damage to the first thing it hits. +5365 Nether Arc V 5 Neutral Other 640 NetherMissile 200 -1 Void Magic 25 Shoots a bolt of nether at the target. The bolt does 84-178 points of nether damage to the first thing it hits. +5366 Nether Arc VI 6 Neutral Other 640 NetherMissile 250 -1 Void Magic 30 Shoots a bolt of nether at the target. The bolt does 105-210 points of nether damage to the first thing it hits. +5367 Nether Arc VII 7 Neutral Other 640 NetherMissile 300 -1 Void Magic 35 Shoots a bolt of nether at the target. The bolt does 168-262 points of nether damage to the first thing it hits. +5368 Incantation of Nether Arc 8 Neutral Other 640 NetherMissile 400 -1 Void Magic 40 Shoots a bolt of nether at the target. The bolt does 252-325 points of nether damage to the first thing it hits. +5369 Nether Arc I 1 Neutral Other 640 NetherMissile 1 -1 Void Magic 5 Shoots a bolt of nether at the target. The bolt does 21-52 points of nether damage to the first thing it hits. +5370 Incantation of Nether Streak 8 Projectile Other 246 ElectricStreak 400 -1 Void Magic 80 Sends a bolt of lighting streaking towards the target. The bolt does 42-57 points of electrical damage to the first thing it hits. +5371 Festering Curse I 1 Buff Other 643 NetherDamageHealingReductionRaising 25 30 Void Magic 10 The heal rating of the target is decreased by 5. +5372 Festering Curse II 2 Buff Other 643 NetherDamageHealingReductionRaising 75 30 Void Magic 20 The heal rating of the target is decreased by 10. +5373 Festering Curse III 3 Buff Other 643 NetherDamageHealingReductionRaising 125 30 Void Magic 30 The heal rating of the target is decreased by 15. +5374 Festering Curse IV 4 Buff Other 643 NetherDamageHealingReductionRaising 175 30 Void Magic 40 The heal rating of the target is decreased by 20. +5375 Festering Curse V 5 Buff Other 643 NetherDamageHealingReductionRaising 225 30 Void Magic 50 The heal rating of the target is decreased by 25. +5376 Festering Curse VI 6 Buff Other 643 NetherDamageHealingReductionRaising 275 30 Void Magic 60 The heal rating of the target is decreased by 30. +5377 Festering Curse VII 7 Buff Other 643 NetherDamageHealingReductionRaising 325 30 Void Magic 70 The heal rating of the target is decreased by 35. +5378 Incantation of Festering Curse 8 Buff Other 643 NetherDamageHealingReductionRaising 400 30 Void Magic 80 The heal rating of the target is decreased by 45. +5379 Weakening Curse I 1 Debuff Other 642 NetherDamageRatingLowering 25 15 Void Magic 10 Decreases the target's damage rating by 1. +5380 Weakening Curse II 2 Debuff Other 642 NetherDamageRatingLowering 75 15 Void Magic 20 Decreases the target's damage rating by 2. +5381 Weakening Curse III 3 Debuff Other 642 NetherDamageRatingLowering 125 15 Void Magic 30 Decreases the target's damage rating by 4. +5382 Weakening Curse IV 4 Debuff Other 642 NetherDamageRatingLowering 175 15 Void Magic 40 Decreases the target's damage rating by 6. +5383 Weakening Curse V 5 Debuff Other 642 NetherDamageRatingLowering 225 15 Void Magic 50 Decreases the target's damage rating by 8. +5384 Weakening Curse VI 6 Debuff Other 642 NetherDamageRatingLowering 275 15 Void Magic 60 Decreases the target's damage rating by 10. +5385 Weakening Curse VII 7 Debuff Other 642 NetherDamageRatingLowering 325 15 Void Magic 70 Decreases the target's damage rating by 12. +5386 Incantation of Weakening Curse 8 Debuff Other 642 NetherDamageRatingLowering 400 15 Void Magic 80 Decreases the target's damage rating by 15. +5387 Corrosion I 1 Buff Other 637 NetherDamageOverTimeRaising2 1 -1 Void Magic 5 Sends a bolt of corrosion towards the target. The bolt does 76 points of damage over 15 seconds. +5388 Corrosion II 2 Buff Other 637 NetherDamageOverTimeRaising2 50 -1 Void Magic 10 Sends a bolt of corrosion towards the target. The bolt does 116 points of damage over 15 seconds. +5389 Corrosion III 3 Buff Other 637 NetherDamageOverTimeRaising2 100 -1 Void Magic 15 Sends a bolt of corrosion towards the target. The bolt does 152 points of damage over 15 seconds. +5390 Corrosion IV 4 Buff Other 637 NetherDamageOverTimeRaising2 150 -1 Void Magic 20 Sends a bolt of corrosion towards the target. The bolt does 192 points of damage over 15 seconds. +5391 Corrosion V 5 Buff Other 637 NetherDamageOverTimeRaising2 200 -1 Void Magic 25 Sends a bolt of corrosion towards the target. The bolt does 204 points of damage over 15 seconds. +5392 Corrosion VI 6 Buff Other 637 NetherDamageOverTimeRaising2 250 -1 Void Magic 30 Sends a bolt of corrosion towards the target. The bolt does 288 points of damage over 15 seconds. +5393 Corrosion VII 7 Buff Other 637 NetherDamageOverTimeRaising2 300 -1 Void Magic 35 Sends a bolt of corrosion towards the target. The bolt does 360 points of damage over 15 seconds. +5394 Incantation of Corrosion 8 Buff Other 637 NetherDamageOverTimeRaising2 400 -1 Void Magic 40 Sends a bolt of corrosion towards the target. The bolt does 448 points of damage over 15 seconds. +5395 Corruption I 1 Buff Other 638 NetherDamageOverTimeRaising3 1 -1 Void Magic 10 Sends 3 bolts of corruption outward from the caster. Each bolt does 56 points of damage over 30 seconds. +5396 Corruption II 2 Buff Other 638 NetherDamageOverTimeRaising3 50 -1 Void Magic 20 Sends 3 bolts of corruption outward from the caster. Each bolt does 91 points of damage over 30 seconds. +5397 Corruption III 3 Buff Other 638 NetherDamageOverTimeRaising3 100 -1 Void Magic 30 Sends 3 bolts of corruption outward from the caster. Each bolt does 126 points of damage over 30 seconds. +5398 Corruption IV 4 Buff Other 638 NetherDamageOverTimeRaising3 150 -1 Void Magic 40 Sends 3 bolts of corruption outward from the caster. Each bolt does 154 points of damage over 30 seconds. +5399 Corruption V 5 Buff Other 638 NetherDamageOverTimeRaising3 200 -1 Void Magic 50 Sends 3 bolts of corruption outward from the caster. Each bolt does 189 points of damage over 30 seconds. +5400 Corruption VI 6 Buff Other 638 NetherDamageOverTimeRaising3 250 -1 Void Magic 60 Sends 3 bolts of corruption outward from the caster. Each bolt does 231 points of damage over 30 seconds. +5401 Corruption VII 7 Buff Other 638 NetherDamageOverTimeRaising3 300 -1 Void Magic 70 Sends 5 bolts of corruption outward from the caster. Each bolt does 294 points of damage over 30 seconds. +5402 Incantation of Corruption 8 Buff Other 638 NetherDamageOverTimeRaising3 400 -1 Void Magic 80 Sends 5 bolts of corruption outward from the caster. Each bolt does 357 points of damage over 30 seconds. +5403 Void Magic Mastery Other I 1 Buff Other 645 VoidMagicRaising 1 1800 Creature Enchantment 10 Increases the target's Void Magic skill by 10 points. +5404 Void Magic Mastery Other II 2 Buff Other 645 VoidMagicRaising 50 1800 Creature Enchantment 20 Increases the target's Void Magic skill by 15 points. +5405 Void Magic Mastery Other III 3 Buff Other 645 VoidMagicRaising 100 1800 Creature Enchantment 30 Increases the target's Void Magic skill by 20 points. +5406 Void Magic Mastery Other IV 4 Buff Other 645 VoidMagicRaising 150 1800 Creature Enchantment 40 Increases the target's Void Magic skill by 25 points. +5407 Void Magic Mastery Other V 5 Buff Other 645 VoidMagicRaising 200 1800 Creature Enchantment 50 Increases the target's Void Magic skill by 30 points. +5408 Void Magic Mastery Other VI 6 Buff Other 645 VoidMagicRaising 250 2700 Creature Enchantment 60 Increases the target's Void Magic skill by 35 points. +5409 Void Magic Mastery Other VII 7 Buff Other 645 VoidMagicRaising 300 3600 Creature Enchantment 70 Increases the target's Void Magic skill by 40 points. +5410 Incantation of Void Magic Mastery Other 8 Buff Other 645 VoidMagicRaising 400 5400 Creature Enchantment 80 Increases the target's Void Magic skill by 45 points. +5411 Void Magic Mastery Self I 1 Buff Self 645 VoidMagicRaising 1 1800 Creature Enchantment 15 Increases the caster's Void Magic skill by 10 points. +5412 Void Magic Mastery Self II 2 Buff Self 645 VoidMagicRaising 50 1800 Creature Enchantment 30 Increases the caster's Void Magic skill by 15 points. +5413 Void Magic Mastery Self III 3 Buff Self 645 VoidMagicRaising 100 1800 Creature Enchantment 40 Increases the caster's Void Magic skill by 20 points. +5414 Void Magic Mastery Self IV 4 Buff Self 645 VoidMagicRaising 150 1800 Creature Enchantment 50 Increases the caster's Void Magic skill by 25 points. +5415 Void Magic Mastery Self V 5 Buff Self 645 VoidMagicRaising 200 1800 Creature Enchantment 60 Increases the caster's Void Magic skill by 30 points. +5416 Void Magic Mastery Self VI 6 Buff Self 645 VoidMagicRaising 250 2700 Creature Enchantment 70 Increases the caster's Void Magic skill by 35 points. +5417 Void Magic Mastery Self VII 7 Buff Self 645 VoidMagicRaising 300 3600 Creature Enchantment 70 Increases the caster's Void Magic skill by 40 points. +5418 Incantation of Void Magic Mastery Self 8 Buff Self 645 VoidMagicRaising 400 5400 Creature Enchantment 80 Increases the caster's Void Magic skill by 45 points. +5419 Void Magic Ineptitude Other I 1 Debuff Other 644 VoidMagicLowering 1 60 Creature Enchantment 10 Decreases the target's Void Magic skill by 10 points. +5420 Void Magic Ineptitude Other II 2 Debuff Other 644 VoidMagicLowering 75 90 Creature Enchantment 20 Decreases the target's Void Magic skill by 15 points. +5421 Void Magic Ineptitude Other III 3 Debuff Other 644 VoidMagicLowering 125 120 Creature Enchantment 30 Decreases the target's Void Magic skill by 20 points. +5422 Void Magic Ineptitude Other IV 4 Debuff Other 644 VoidMagicLowering 175 150 Creature Enchantment 40 Decreases the target's Void Magic skill by 25 points. +5423 Void Magic Ineptitude Other V 5 Debuff Other 644 VoidMagicLowering 225 180 Creature Enchantment 50 Decreases the target's Void Magic skill by 30 points. +5424 Void Magic Ineptitude Other VI 6 Debuff Other 644 VoidMagicLowering 275 210 Creature Enchantment 60 Decreases the target's Void Magic skill by 35 points. +5425 Void Magic Ineptitude Other VII 7 Debuff Other 644 VoidMagicLowering 325 240 Creature Enchantment 70 Decreases the target's Void Magic skill by 40 points. +5426 Incantation of Void Magic Ineptitude Other 8 Debuff Other 644 VoidMagicLowering 400 300 Creature Enchantment 80 Decreases the target's Void Magic skill by 45 points. +5427 Minor Void Magic Aptitude 1 Buff Other 646 VoidMysticRaising 5 780 Creature Enchantment 10 Increases the target's Void Magic skill by 5 points. Additional spells can be layered over this. +5428 Major Void Magic Aptitude 1 Buff Other 646 VoidMysticRaising 15 780 Creature Enchantment 10 Increases the target's Void Magic skill by 15 points. Additional spells can be layered over this. +5429 Epic Void Magic Aptitude 1 Buff Other 646 VoidMysticRaising 25 780 Creature Enchantment 10 Increases the target's Void Magic skill by 25 points. Additional spells can be layered over this. +5430 Moderate Void Magic Aptitude 1 Buff Other 646 VoidMysticRaising 10 780 Creature Enchantment 10 Increases the target's Void Magic skill by 10 points. Additional spells can be layered over this. +5431 Novice Shadow's Void Magic Aptitude 1 Buff Other 647 SetVoidMagicRaising 1 1800 Creature Enchantment 10 Increases the target's Void Magic skill by 3 points. +5432 Apprentice Voidlock's Void Magic Aptitude 1 Buff Other 647 SetVoidMagicRaising 2 1800 Creature Enchantment 10 Increases the target's Void Magic skill by 5 points. +5433 Journeyman Voidlock's Void Magic Aptitude 1 Buff Other 647 SetVoidMagicRaising 3 1800 Creature Enchantment 10 Increases the target's Void Magic skill by 10 points. +5434 Master Voidlock's Void Magic Aptitude 1 Buff Other 647 SetVoidMagicRaising 4 1800 Creature Enchantment 10 Increases the target's Void Magic skill by 20 points. +5435 Spectral Void Magic Mastery 6 Buff Other 648 VoidMagicRaisingRare 250 540 Creature Enchantment 70 Increases the caster's Void Magic skill by 150 points for 9 minutes. +5436 Prodigal Void Magic Mastery 8 Buff Other 648 VoidMagicRaisingRare 600 900 Creature Enchantment 70 Increases the caster's Void Magic skill by 250 points. +5437 Corruptor's Boon 1 Buff Other 649 VoidMysticRaising2 2 780 Creature Enchantment 10 Increases the target's Void Magic skill by 2 points. Additional spells can be layered over this. +5438 Corruptor's Boon 1 Buff Other 649 VoidMysticRaising2 2 780 Creature Enchantment 10 Increases the target's Void Magic skill by 15 points. Additional spells can be layered over this. +5439 Acid Spit Streak 1 7 Projectile Other 243 AcidStreak 300 -1 War Magic 70 Spits a stream of acid streaking towards the target. The stream does 54-94 points of acid damage to the first thing it hits. +5440 Acid Spit 1 7 Neutral Other 117 AcidMissile 300 -1 War Magic 35 Spits a stream of acid at the target. The stream does 149-219 points of acid damage to the first thing it hits. +5441 Acid Spit 2 8 Neutral Other 117 AcidMissile 400 -1 War Magic 40 Spits a stream of acid at the target. The stream does 182-232 points of acid damage to the first thing it hits. +5442 Acid Spit Arc 1 7 Neutral Other 117 AcidMissile 300 -1 War Magic 35 Spits a stream of acid at the target. The stream does 149-219 points of acid damage to the first thing it hits. +5443 Acid Spit Arc 2 8 Neutral Other 117 AcidMissile 400 -1 War Magic 40 Spits a stream of acid at the target. The stream does 182-232 points of acid damage to the first thing it hits. +5444 Acid Spit Blast 1 7 Projectile Other 131 AcidBurst 325 -1 War Magic 35 Spits five streams of acid outward from the caster. Each stream does 54-94 points of acid damage to the first thing it hits. +5445 Acid Spit Blast 2 8 Projectile Other 131 AcidBurst 400 -1 War Magic 40 Spits five streams of acid outward from the caster. Each stream does 61-106 points of acid damage to the first thing it hits. +5446 Acid Spit Volley 1 7 Projectile Other 207 AcidVolley 325 -1 War Magic 35 Spits five streams of acid toward the target. Each stream does 54-94 points of acid damage to the first thing it hits. +5447 Acid Spit Volley 2 8 Projectile Other 207 AcidVolley 400 -1 War Magic 40 Shoots five streams of acid toward the target. Each stream does 61-106 points of acid damage to the first thing it hits. +5448 Acid Spit Streak 8 Projectile Other 243 AcidStreak 400 -1 War Magic 80 Spits a stream of acid streaking towards the target. The stream does 61-106 points of acid damage to the first thing it hits. +5449 Surging Strength 1 Buff Other 650 LuminanceDamageRatingRaising 2 15 Life Magic 70 The damage rating of the caster is increased by 20. This spell stacks with other effects that boost damage rating. +5450 Towering Defense 1 Buff Other 651 LuminanceDamageReductionRaising 2 15 Life Magic 70 The damage reduction rating of the caster is increased by 30. This spell stacks with other effects that boost damage reduction rating. +5451 Luminous Vitality 1 Buff Other 652 LuminanceHealthRaising 5 10800 Life Magic 70 Increases maximum health by 5 points. This spell stacks with other effects that increase health. +5452 Queen's Willpower 8 Buff Other 11 SelfRaising 400 10800 Creature Enchantment 80 Increases the target's Self by 45 points. +5453 Queen's Armor 8 Buff Other 115 ArmorRaising 400 10800 Life Magic 80 Increases the target's natural armor by 250 points. +5454 Queen's Coordination 8 Buff Other 7 CoordinationRaising 400 10800 Creature Enchantment 80 Increases the target's Coordination by 45 points. +5455 Queen's Endurance 8 Buff Other 3 EnduranceRaising 400 10800 Creature Enchantment 80 Increases the target's Endurance by 45 points. +5456 Queen's Focus 8 Buff Other 9 FocusRaising 400 10800 Creature Enchantment 80 Increases the target's Focus by 45 points. +5457 Queen's Quickness 8 Buff Other 5 QuicknessRaising 400 10800 Creature Enchantment 80 Increases the target's Quickness by 45 points. +5458 Queen's Strength 8 Buff Other 1 StrengthRaising 400 10800 Creature Enchantment 80 Increases the target's Strength by 45 points. +5459 Queen's Piercing Protection 8 Buff Other 111 PierceProtection 400 10800 Life Magic 80 Reduces damage the target takes from Piercing by 68% +5460 Queen's Acid Protection 8 Buff Other 101 AcidProtection 400 10800 Life Magic 80 Reduces damage the target takes from acid by 68% +5461 Queen's Blade Protection 8 Buff Other 113 SlashProtection 400 10800 Life Magic 80 Reduces damage the target takes from Slashing by 68% +5462 Queen's Bludgeoning Protection 8 Buff Other 103 BludgeonProtection 400 10800 Life Magic 80 Reduces damage the target takes from Bludgeoning by 68% +5463 Queen's Cold Protection 8 Buff Other 105 ColdProtection 400 10800 Life Magic 80 Reduces damage the target takes from Cold by 68% +5464 Queen's Fire Protection 8 Buff Other 109 FireProtection 400 10800 Life Magic 80 Reduces damage the target takes from fire by 68% +5465 Queen's Lightning Protection 8 Buff Other 107 ElectricProtection 400 10800 Life Magic 80 Reduces damage the target takes from Lightning by 68% +5466 Queen's Rejuvenation 8 Buff Other 95 StaminaAccelerating 400 10800 Life Magic 80 Increases the rate at which the target regains Stamina by 145%. +5467 Queen's Mana Renewal 8 Buff Other 97 ManaAccelerating 400 10800 Life Magic 80 Increases the target's natural mana rate by 145%. +5468 Queen's Regeneration 8 Buff Other 93 HealthAccelerating 400 10800 Life Magic 80 Increase target's natural healing rate by 145%. +5469 Queen's Impregnability Other 8 Buff Other 39 MissileDefenseRaising 400 10800 Creature Enchantment 80 Increases the target's Missile Defense skill by 45 points. +5470 Queen's Invulnerability Other 8 Buff Other 37 MeleeDefenseRaising 400 10800 Creature Enchantment 80 Increases the target's Melee Defense skill by 45 points. +5471 Queen's Magic Resistance 8 Buff Other 41 MagicDefenseRaising 400 10800 Creature Enchantment 80 Increases the target's Magic Defense skill by 45 points. +5472 Queen's Mana Conversion Mastery 8 Buff Other 51 ManaConversionRaising 400 10800 Creature Enchantment 80 Increases the target's Mana Conversion skill by 45 points. +5473 Queen's Salvaging Mastery Other 8 Buff Other 435 SalvagingRaising 400 10800 Creature Enchantment 80 Increases the caster's Salvaging skill by 45 points. +5474 Queen's Sprint 8 Buff Other 77 RunRaising 400 10800 Creature Enchantment 80 Increases the target's Run skill by 45 points. +5475 Queen's Light Weapon Mastery 8 Buff Other 17 AxeRaising 400 10800 Creature Enchantment 80 Increases the target's Light Weapons skill by 45 points. +5476 Queen's War Magic Mastery 8 Buff Other 49 WarMagicRaising 400 10800 Creature Enchantment 80 Increases the target's War Magic skill by 45 points. +5477 Critical Damage Metamorphi I 1 Buff Other 626 AetheriaCriticalDamageRaising 1 510 Life Magic 70 Your critical damage rating is increased by 2. +5478 Critical Damage Metamorphi II 1 Buff Other 626 AetheriaCriticalDamageRaising 2 510 Life Magic 70 Your critical damage rating is increased by 4. +5479 Critical Damage Metamorphi III 1 Buff Other 626 AetheriaCriticalDamageRaising 3 510 Life Magic 70 Your critical damage rating is increased by 6. +5480 Critical Damage Metamorphi IV 1 Buff Other 626 AetheriaCriticalDamageRaising 4 510 Life Magic 70 Your critical damage rating is increased by 8. +5481 Critical Damage Metamorphi V 1 Buff Other 626 AetheriaCriticalDamageRaising 5 510 Life Magic 70 Your critical damage rating is increased by 10. +5482 Critical Damage Metamorphi VI 1 Buff Other 626 AetheriaCriticalDamageRaising 6 510 Life Magic 70 Your critical damage rating is increased by 12. +5483 Critical Damage Metamorphi VII 1 Buff Other 626 AetheriaCriticalDamageRaising 7 510 Life Magic 70 Your critical damage rating is increased by 14. +5484 Critical Damage Metamorphi VIII 1 Buff Other 626 AetheriaCriticalDamageRaising 8 510 Life Magic 70 Your critical damage rating is increased by 16. +5485 Critical Damage Metamorphi IX 1 Buff Other 626 AetheriaCriticalDamageRaising 9 510 Life Magic 70 Your critical damage rating is increased by 20. +5486 Critical Damage Metamorphi X 1 Buff Other 626 AetheriaCriticalDamageRaising 10 510 Life Magic 70 Your critical damage rating is increased by 24. +5487 Critical Damage Metamorphi XI 1 Buff Other 626 AetheriaCriticalDamageRaising 11 510 Life Magic 70 Your critical damage rating is increased by 30. +5489 Critical Damage Reduction Metamorphi I 1 Buff Other 653 AetheriaCriticalReductionRaising 1 510 Life Magic 70 Your critical damage reduction rating is increased by 2. +5490 Critical Damage Reduction Metamorphi II 1 Buff Other 653 AetheriaCriticalReductionRaising 2 510 Life Magic 70 Your critical damage reduction rating is increased by 4. +5491 Critical Damage Reduction Metamorphi III 1 Buff Other 653 AetheriaCriticalReductionRaising 3 510 Life Magic 70 Your critical damage reduction rating is increased by 6. +5492 Critical Damage Reduction Metamorphi IV 1 Buff Other 653 AetheriaCriticalReductionRaising 4 510 Life Magic 70 Your critical damage reduction rating is increased by 8. +5493 Critical Damage Reduction Metamorphi V 1 Buff Other 653 AetheriaCriticalReductionRaising 5 510 Life Magic 70 Your critical damage reduction rating is increased by 10. +5494 Critical Damage Reduction Metamorphi VI 1 Buff Other 653 AetheriaCriticalReductionRaising 6 510 Life Magic 70 Your critical damage reduction rating is increased by 12. +5495 Critical Damage Reduction Metamorphi VII 1 Buff Other 653 AetheriaCriticalReductionRaising 7 510 Life Magic 70 Your critical damage reduction rating is increased by 14. +5496 Critical Damage Reduction Metamorphi VIII 1 Buff Other 653 AetheriaCriticalReductionRaising 8 510 Life Magic 70 Your critical damage reduction rating is increased by 16. +5497 Critical Damage Reduction Metamorphi IX 1 Buff Other 653 AetheriaCriticalReductionRaising 9 510 Life Magic 70 Your critical damage reduction rating is increased by 20. +5498 Critical Damage Reduction Metamorphi X 1 Buff Other 653 AetheriaCriticalReductionRaising 10 510 Life Magic 70 Your critical damage reduction rating is increased by 24. +5499 Critical Damage Reduction Metamorphi XI 1 Buff Other 653 AetheriaCriticalReductionRaising 11 510 Life Magic 70 Your critical damage reduction rating is increased by 30. +5500 Damage Metamorphi I 1 Buff Other 620 AetheriaDamageRatingRaising 1 510 Life Magic 70 Your damage rating is increased by 1. +5501 Damage Metamorphi II 1 Buff Other 620 AetheriaDamageRatingRaising 2 510 Life Magic 70 Your damage rating is increased by 2. +5502 Damage Metamorphi III 1 Buff Other 620 AetheriaDamageRatingRaising 3 510 Life Magic 70 Your damage rating is increased by 3. +5503 Damage Metamorphi IV 1 Buff Other 620 AetheriaDamageRatingRaising 4 510 Life Magic 70 Your damage rating is increased by 4. +5504 Damage Metamorphi V 1 Buff Other 620 AetheriaDamageRatingRaising 5 510 Life Magic 70 Your damage rating is increased by 5. +5505 Damage Metamorphi VI 1 Buff Other 620 AetheriaDamageRatingRaising 6 510 Life Magic 70 Your damage rating is increased by 6. +5506 Damage Metamorphi VII 1 Buff Other 620 AetheriaDamageRatingRaising 7 510 Life Magic 70 Your damage rating is increased by 7. +5507 Damage Metamorphi VIII 1 Buff Other 620 AetheriaDamageRatingRaising 8 510 Life Magic 70 Your damage rating is increased by 8. +5508 Damage Metamorphi IX 1 Buff Other 620 AetheriaDamageRatingRaising 9 510 Life Magic 70 Your damage rating is increased by 10. +5509 Damage Metamorphi X 1 Buff Other 620 AetheriaDamageRatingRaising 10 510 Life Magic 70 Your damage rating is increased by 12. +5510 Damage Metamorphi XI 1 Buff Other 620 AetheriaDamageRatingRaising 11 510 Life Magic 70 Your damage rating is increased by 15. +5511 Damage Reduction Metamorphi I 1 Buff Other 621 AetheriaDamageReductionRaising 1 510 Life Magic 70 Your damage reduction rating is increased by 1. +5512 Damage Reduction Metamorphi II 1 Buff Other 621 AetheriaDamageReductionRaising 2 510 Life Magic 70 Your damage reduction rating is increased by 2. +5513 Damage Reduction Metamorphi III 1 Buff Other 621 AetheriaDamageReductionRaising 3 510 Life Magic 70 Your damage reduction rating is increased by 3. +5514 Damage Reduction Metamorphi IV 1 Buff Other 621 AetheriaDamageReductionRaising 4 510 Life Magic 70 Your damage reduction rating is increased by 4. +5515 Damage Reduction Metamorphi V 1 Buff Other 621 AetheriaDamageReductionRaising 5 510 Life Magic 70 Your damage reduction rating is increased by 5. +5516 Damage Reduction Metamorphi VI 1 Buff Other 621 AetheriaDamageReductionRaising 6 510 Life Magic 70 Your damage reduction rating is increased by 6. +5517 Damage Reduction Metamorphi VII 1 Buff Other 621 AetheriaDamageReductionRaising 7 510 Life Magic 70 Your damage reduction rating is increased by 7. +5518 Damage Reduction Metamorphi VIII 1 Buff Other 621 AetheriaDamageReductionRaising 8 510 Life Magic 70 Your damage reduction rating is increased by 8. +5519 Damage Reduction Metamorphi IX 1 Buff Other 621 AetheriaDamageReductionRaising 9 510 Life Magic 70 Your damage reduction rating is increased by 10. +5520 Damage Reduction Metamorphi X 1 Buff Other 621 AetheriaDamageReductionRaising 10 510 Life Magic 70 Your damage reduction rating is increased by 12. +5521 Damage Reduction Metamorphi XI 1 Buff Other 621 AetheriaDamageReductionRaising 11 510 Life Magic 70 Your damage reduction rating is increased by 15. +5522 Acid Spit Vulnerability 1 7 Debuff Other 102 AcidVulnerability 325 -1 War Magic 70 Increases damage the target takes from acid by 185%. +5523 Acid Spit Vulnerability 2 8 Debuff Other 102 AcidVulnerability 400 -1 War Magic 80 Increases damage the target takes from acid by 210%. +5524 Falling stalactite 8 Neutral Other 237 BludgeoningStrike 400 -1 War Magic 120 Stalactites fall from the ceiling piercing anyone below. +5525 Bloodstone Bolt I 1 Projectile Other 80 HealthLowering 1 -1 Life Magic 10 Shoots a bolt of corrupted life energy at the target. The bolt drains 16-40 points of health from the first thing it hits. +5526 Bloodstone Bolt II 2 Projectile Other 80 HealthLowering 50 -1 Life Magic 20 Shoots a bolt of corrupted life energy at the target. The bolt drains 32-64 points of health from the first thing it hits. +5527 Bloodstone Bolt III 3 Projectile Other 80 HealthLowering 100 -1 Life Magic 30 Shoots a bolt of corrupted life energy at the target. The bolt drains 48-88 points of health from the first thing it hits. +5528 Bloodstone Bolt IV 4 Projectile Other 80 HealthLowering 150 -1 Life Magic 40 Shoots a bolt of corrupted life energy at the target. The bolt drains 56-112 points of health from the first thing it hits. +5529 Bloodstone Bolt V 5 Projectile Other 80 HealthLowering 200 -1 Life Magic 50 Shoots a bolt of corrupted life energy at the target. The bolt drains 64-136 points of health from the first thing it hits. +5530 Bloodstone Bolt VI 6 Projectile Other 80 HealthLowering 250 -1 Life Magic 60 Shoots a bolt of corrupted life energy at the target. The bolt drains 80-160 points of health from the first thing it hits. +5531 Bloodstone Bolt VII 7 Projectile Other 80 HealthLowering 300 -1 Life Magic 70 Shoots a bolt of corrupted life energy at the target. The bolt drains 128-200 points of health from the first thing it hits. +5532 Incantation of Bloodstone Bolt 8 Projectile Other 80 HealthLowering 400 -1 Life Magic 80 Shoots a bolt of corrupted life energy at the target. The bolt drains 192-248 points of health from the first thing it hits. +5533 Entering Lord Kastellar's Lab 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5534 Entering the Bloodstone Factory 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5535 Acidic Blood 6 Neutral Other 117 AcidMissile 250 -1 War Magic 30 Shoots a stream of acidic blood at the target. The stream does 80-160 points of acid damage to the first thing it hits. +5536 Acidic Blood 8 Neutral Other 117 AcidMissile 400 -1 War Magic 40 Shoots a stream of acidic blood at the target. The stream does 135-195 points of acid damage to the first thing it hits. +5537 Acidic Blood 4 Neutral Other 117 AcidMissile 150 -1 War Magic 20 Shoots a stream of acidic blood at the target. The stream does 50-100 points of acid damage to the first thing it hits. +5538 Darkened Heart 1 Buff Other 649 VoidMysticRaising2 2 10800 Creature Enchantment 10 Your heart. darkened with hate. provides an increase to your Void Magic skill by 2. +5539 Warded Cavern Passage 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5540 Warded Dungeon Passage 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +5541 Lost City of Neftet Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 Sends the caster to the Lost City of Neftet. +5542 Burning Sands Infliction 7 Buff Other 618 DamageOverTimeRaising 350 30 Life Magic 80 You've been covered in burning sand. causing damage over time. The target loses 357 points of health over 30 seconds. +5543 Curse of the Burning Sands 7 Buff Other 619 HealingResistRatingRaising 350 300 Life Magic 80 Your wounds are cursed and don't heal as well. +5544 Nether Blast I 2 Projectile Other 135 FireBurst 75 -1 Void Magic 40 Shoots three bolts of nether outward from the caster. Each bolt does 10-21 points of nether damage to the first thing it hits. +5545 Nether Blast II 2 Projectile Other 135 FireBurst 75 -1 Void Magic 40 Shoots three bolts of nether outward from the caster. Each bolt does 10-21 points of nether damage to the first thing it hits. +5546 Nether Blast III 3 Projectile Other 135 FireBurst 125 -1 Void Magic 15 Shoots three bolts of nether outward from the caster. Each bolt does 21-47 points of nether damage to the first thing it hits. +5547 Nether Blast IV 4 Projectile Other 135 FireBurst 175 -1 Void Magic 20 Shoots three bolts of nether outward from the caster. Each bolt does 31-63 points of nether damage to the first thing it hits. +5548 Nether Blast V 5 Projectile Other 135 FireBurst 225 -1 Void Magic 25 Shoots three bolts of nether outward from the caster. Each bolt does 36-73 points of nether damage to the first thing it hits. +5549 Nether Blast VI 6 Projectile Other 135 FireBurst 275 -1 Void Magic 30 Shoots three bolts of nether outward from the caster. Each bolt does 42-89 points of nether damage to the first thing it hits. +5550 Nether Blast VII 7 Projectile Other 135 FireBurst 325 -1 Void Magic 35 Shoots five bolts of nether outward from the caster. Each bolt does 78-126 points of nether damage to the first thing it hits. +5551 Incantation of Nether Blast 8 Projectile Other 135 FireBurst 400 -1 Void Magic 40 Shoots five bolts of nether outward from the caster. Each bolt does 115-158 points of nether damage to the first thing it hits. +5552 Sigil of Purity IX 1 Buff Other 658 AetheriaDotResistanceRaising 9 510 Life Magic 70 Your DoT reduction rating is increased by 36. +5553 Sigil of Perserverance I 1 Buff Other 657 AetheriaHealthResistanceRaising 1 510 Life Magic 70 Your health drain resistance rating is increased by 4. +5554 Sigil of Perserverance X 1 Buff Other 657 AetheriaHealthResistanceRaising 10 510 Life Magic 70 Your health drain resistance rating is increased by 40. +5555 Sigil of Perserverance XI 1 Buff Other 657 AetheriaHealthResistanceRaising 11 510 Life Magic 70 Your health drain resistance rating is increased by 44. +5556 Sigil of Perserverance XII 1 Buff Other 657 AetheriaHealthResistanceRaising 12 510 Life Magic 70 Your health drain resistance rating is increased by 48. +5557 Sigil of Perserverance XIII 1 Buff Other 657 AetheriaHealthResistanceRaising 13 510 Life Magic 70 desc desc Your health drain resistance rating is increased by 52. +5558 Sigil of Perserverance XIV 1 Buff Other 657 AetheriaHealthResistanceRaising 14 510 Life Magic 70 desc desc Your health drain resistance rating is increased by 56. +5559 Sigil of Perserverance XV 1 Buff Other 657 AetheriaHealthResistanceRaising 15 510 Life Magic 70 desc desc Your health drain resistance rating is increased by 50. +5560 Sigil of Perserverance II 1 Buff Other 657 AetheriaHealthResistanceRaising 2 510 Life Magic 70 Your health drain resistance rating is increased by 8. +5561 Sigil of Perserverance III 1 Buff Other 657 AetheriaHealthResistanceRaising 3 510 Life Magic 70 Your health drain resistance rating is increased by 12. +5562 Sigil of Perserverance IV 1 Buff Other 657 AetheriaHealthResistanceRaising 4 510 Life Magic 70 Your health drain resistance rating is increased by 16. +5563 Sigil of Perserverance V 1 Buff Other 657 AetheriaHealthResistanceRaising 5 510 Life Magic 70 Your health drain resistance rating is increased by 20. +5564 Sigil of Perserverance VI 1 Buff Other 657 AetheriaHealthResistanceRaising 6 510 Life Magic 70 Your health drain resistance rating is increased by 24. +5565 Sigil of Perserverance VII 1 Buff Other 657 AetheriaHealthResistanceRaising 7 510 Life Magic 70 Your health drain resistance rating is increased by 28. +5566 Sigil of Perserverance VIII 1 Buff Other 657 AetheriaHealthResistanceRaising 8 510 Life Magic 70 Your health drain resistance rating is increased by 32. +5567 Sigil of Perserverance IX 1 Buff Other 657 AetheriaHealthResistanceRaising 9 510 Life Magic 70 Your health drain resistance rating is increased by 36. +5568 Sigil of Purity I 1 Buff Other 658 AetheriaDotResistanceRaising 1 510 Life Magic 70 Your DoT reduction rating is increased by 4. +5569 Sigil of Purity X 1 Buff Other 658 AetheriaDotResistanceRaising 10 510 Life Magic 70 Your DoT reduction rating is increased by 40. +5570 Sigil of Purity XI 1 Buff Other 658 AetheriaDotResistanceRaising 11 510 Life Magic 70 Your DoT reduction rating is increased by 44. +5571 Sigil of Purity XII 1 Buff Other 658 AetheriaDotResistanceRaising 12 510 Life Magic 70 Your DoT reduction rating is increased by 48. +5572 Sigil of Purity XIII 1 Buff Other 658 AetheriaDotResistanceRaising 13 510 Life Magic 70 Your DoT reduction rating is increased by 52. +5573 Sigil of Purity XIV 1 Buff Other 658 AetheriaDotResistanceRaising 14 510 Life Magic 70 Your DoT reduction rating is increased by 56. +5574 Sigil of Purity XV 1 Buff Other 658 AetheriaDotResistanceRaising 15 510 Life Magic 70 Your DoT reduction rating is increased by 60. +5575 Sigil of Purity II 1 Buff Other 658 AetheriaDotResistanceRaising 2 510 Life Magic 70 Your DoT reduction rating is increased by 8. +5576 Sigil of Purity III 1 Buff Other 658 AetheriaDotResistanceRaising 3 510 Life Magic 70 Your DoT reduction rating is increased by 12. +5577 Sigil of Purity IV 1 Buff Other 658 AetheriaDotResistanceRaising 4 510 Life Magic 70 Your DoT reduction rating is increased by 16. +5578 Sigil of Purity V 1 Buff Other 658 AetheriaDotResistanceRaising 5 510 Life Magic 70 Your DoT reduction rating is increased by 20. +5579 Sigil of Purity VI 1 Buff Other 658 AetheriaDotResistanceRaising 6 510 Life Magic 70 Your DoT reduction rating is increased by 24. +5580 Sigil of Purity VII 1 Buff Other 658 AetheriaDotResistanceRaising 7 510 Life Magic 70 Your DoT reduction rating is increased by 28. +5581 Sigil of Purity VIII 1 Buff Other 658 AetheriaDotResistanceRaising 8 510 Life Magic 70 Your DoT reduction rating is increased by 32. +5582 Nullify All Rares 8 Neutral Other 250 Dispel 600 -1 Life Magic 340 Dispels all rare enchantments on the player. +5583 Weave of Alchemy I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Alchemy skill by 2 points. +5584 Weave of Alchemy II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Alchemy skill by 4 points. +5585 Weave of Alchemy III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Alchemy skill by 6 points. +5586 Weave of Alchemy IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Alchemy skill by 8 points. +5587 Weave of Alchemy V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Alchemy skill by 10 points. +5588 Weave of Arcane Lore I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Arcane Lore skill by 2 points. +5589 Weave of Arcane Lore II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Arcane Lore skill by 4 points. +5590 Weave of Arcane Lore III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Arcane Lore skill by 6 points. +5591 Weave of Arcane Lore IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Arcane Lore skill by 8 points. +5592 Weave of Arcane Lore V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Arcane Lore skill by 10 points. +5593 Weave of Armor Tinkering I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Armor Tinkering skill by 2 points. +5594 Weave of Armor Tinkering II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Armor Tinkering skill by 4 points. +5595 Weave of Armor Tinkering III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Armor Tinkering skill by 6 points. +5596 Weave of Armor Tinkering IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Armor Tinkering skill by 8 points. +5597 Weave of Armor Tinkering V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Armor Tinkering skill by 10 points. +5598 Weave of Person Attunement I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Assess Person skill by 2 points. +5599 Weave of Person Attunement II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Assess Person skill by 4 points. +5600 Weave of Person Attunement III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Assess Person skill by 6 points. +5601 Weave of Person Attunement IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Assess Person skill by 8 points. +5602 Weave of the Person Attunement V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Assess Person skill by 10 points. +5603 Weave of Light Weapons I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 2 points. +5604 Weave of Light Weapons II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 4 points. +5605 Weave of Light Weapons III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 6 points. +5606 Weave of Light Weapons IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 8 points. +5607 Weave of Light Weapons V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 10 points. +5608 Weave of Missile Weapons I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 2 points. +5609 Weave of Missile Weapons II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 4 points. +5610 Weave of Missile Weapons III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 6 points. +5611 Weave of Missile Weapons IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 8 points. +5612 Weave of Missile Weapons V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 10 points. +5613 Weave of Cooking I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Cooking skill by 2 points. +5614 Weave of Cooking II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Cooking skill by 4 points. +5615 Weave of Cooking III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Cooking skill by 6 points. +5616 Weave of Cooking IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Cooking skill by 8 points. +5617 Weave of the Cooking V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Cooking skill by 10 points. +5618 Weave of Creature Enchantment I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Creature Enchantment skill by 2 points. +5619 Weave of Creature Enchantment II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Creature Enchantment skill by 4 points. +5620 Weave of Creature Enchantment III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Creature Enchantment skill by 6 points. +5621 Weave of Creature Enchantment IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Creature Enchantment skill by 8 points. +5622 Weave of the Creature Enchantment V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Creature Enchantment skill by 10 points. +5623 Weave of Missile Weapons I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 2 points. +5624 Weave of Missile Weapons II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 4 points. +5625 Weave of Missile Weapons III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 6 points. +5626 Weave of Missile Weapons IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 8 points. +5627 Weave of Missile Weapons V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 10 points. +5628 Weave of Finesse Weapons I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Finesse Weapons skill by 2 points. +5629 Weave of Finesse Weapons II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Finesse Weapons skill by 4 points. +5630 Weave of Finesse Weapons III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Finesse Weapons skill by 6 points. +5631 Weave of Finesse Weapons IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Finesse Weapons skill by 8 points. +5632 Weave of Finesse Weapons V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Finesse Weapons skill by 10 points. +5633 Weave of Deception I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Deception skill by 2 points. +5634 Weave of the Deception II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Deception skill by 4 points. +5635 Weave of the Deception III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Deception skill by 6 points. +5636 Weave of the Deception IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Deception skill by 8 points. +5637 Weave of the Deception V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Deception skill by 10 points. +5638 Weave of Fletching I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Fletching skill by 2 points. +5639 Weave of the Fletching II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Fletching skill by 4 points. +5640 Weave of the Fletching III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Fletching skill by 6 points. +5641 Weave of the Fletching IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Fletching skill by 8 points. +5642 Weave of the Fletching V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Fletching skill by 10 points. +5643 Weave of Healing I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Healing skill by 2 points. +5644 Weave of the Healing II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Healing skill by 4 points. +5645 Weave of the Healing III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Healing skill by 6 points. +5646 Weave of the Healing IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Healing skill by 8 points. +5647 Weave of the Healing V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Healing skill by 10 points. +5648 Weave of Item Enchantment I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Item Enchantment skill by 2 points. +5649 Weave of Item Enchantment II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Item Enchantment skill by 4 points. +5650 Weave of Item Enchantment III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Item Enchantment skill by 6 points. +5651 Weave of Item Enchantment IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Item Enchantment skill by 8 points. +5652 Weave of the Item Enchantment V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Item Enchantment skill by 10 points. +5653 Weave of Item Tinkering I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Item Tinkering skill by 2 points. +5654 Weave of Item Tinkering II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Item Tinkering skill by 4 points. +5655 Weave of Item Tinkering III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Item Tinkering skill by 6 points. +5656 Weave of Item Tinkering IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Item Tinkering skill by 8 points. +5657 Weave of the Item Tinkering V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Item Tinkering skill by 10 points. +5658 Weave of Leadership I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Leadership skill by 2 points. +5659 Weave of Leadership II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Leadership skill by 4 points. +5660 Weave of Leadership III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Leadership skill by 6 points. +5661 Weave of Leadership IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Leadership skill by 8 points. +5662 Weave of Leadership V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Leadership skill by 10 points. +5663 Weave of Life Magic I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Life Magic skill by 2 points. +5664 Weave of Life Magic II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Life Magic skill by 4 points. +5665 Weave of Life Magic III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Life Magic skill by 6 points. +5666 Weave of Life Magic IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Life Magic skill by 8 points. +5667 Weave of Life Magic V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Life Magic skill by 10 points. +5668 Weave of Fealty I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Loyalty skill by 2 points. +5669 Weave of Fealty II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Loyalty skill by 4 points. +5670 Weave of Fealty III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Loyalty skill by 6 points. +5671 Weave of Fealty IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Loyalty skill by 8 points. +5672 Weave of Fealty V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Loyalty skill by 10 points. +5673 Weave of Light Weapons I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 2 points. +5674 Weave of Light Weapons II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 4 points. +5675 Weave of Light Weapons III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 6 points. +5676 Weave of Light Weapons IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 8 points. +5677 Weave of Light Weapons V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 10 points. +5678 Weave of Magic Resistance I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Magic Defense skill by 2 points. +5679 Weave of Magic Resistance II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Magic Defense skill by 4 points. +5680 Weave of Magic Resistance III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Magic Defense skill by 6 points. +5681 Weave of Magic Resistance IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Magic Defense skill by 8 points. +5682 Weave of the Magic Resistance V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Magic Defense skill by 10 points. +5683 Weave of Magic Item Tinkering I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Magic Item Tinkering skill by 2 points. +5684 Weave of Magic Item Tinkering II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Magic Item Tinkering skill by 4 points. +5685 Weave of Magic Item Tinkering III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Magic Item Tinkering skill by 6 points. +5686 Weave of Magic Item Tinkering IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Magic Item Tinkering skill by 8 points. +5687 Weave of the Magic Item Tinkering V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Magic Item Tinkering skill by 10 points. +5688 Weave of Mana Conversion I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Mana Conversion skill by 2 points. +5689 Weave of Mana Conversion II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Mana Conversion skill by 4 points. +5690 Weave of Mana Conversion III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Mana Conversion skill by 6 points. +5691 Weave of Mana Conversion IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Mana Conversion skill by 8 points. +5692 Weave of Mana Conversion V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Mana Conversion skill by 10 points. +5693 Weave of Invulnerability I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Melee Defense skill by 2 points. +5694 Weave of Invulnerability II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Melee Defense skill by 4 points. +5695 Weave of Invulnerability III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Melee Defense skill by 6 points. +5696 Weave of Invulnerability IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Melee Defense skill by 8 points. +5697 Weave of the Invulnerability V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Melee Defense skill by 10 points. +5698 Weave of Impregnability I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Missile Defense skill by 2 points. +5699 Weave of Impregnability II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Missile Defense skill by 4 points. +5700 Weave of Impregnability III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Missile Defense skill by 6 points. +5701 Weave of Impregnability IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Missile Defense skill by 8 points. +5702 Weave of the Impregnability V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Missile Defense skill by 10 points. +5703 Weave of Salvaging I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Salvaging skill by 2 points. +5704 Weave of Salvaging II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Salvaging skill by 4 points. +5705 Weave of Salvaging III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Salvaging skill by 6 points. +5706 Weave of Salvaging IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Salvaging skill by 8 points. +5707 Weave of Salvaging V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Salvaging skill by 10 points. +5708 Weave of Light Weapons I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 2 points. +5709 Weave of Light Weapons II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 4 points. +5710 Weave of Light Weapons III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 6 points. +5711 Weave of Light Weapons IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 8 points. +5712 Weave of Light Weapons V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 10 points. +5713 Weave of Light Weapons I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 2 points. +5714 Weave of Light Weapons II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 4 points. +5715 Weave of Light Weapons III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 6 points. +5716 Weave of Light Weapons IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 8 points. +5717 Weave of Light Weapons V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 10 points. +5718 Weave of Heavy Weapons I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Heavy Weapons skill by 2 points. +5719 Weave of Heavy Weapons II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Heavy Weapons skill by 4 points. +5720 Weave of Heavy Weapons III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Heavy Weapons skill by 6 points. +5721 Weave of Heavy Weapons IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Heavy Weapons skill by 8 points. +5722 Weave of Heavy Weapons V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Heavy Weapons skill by 10 points. +5723 Weave of Missile Weapons I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 2 points. +5724 Weave of Missile Weapons II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 4 points. +5725 Weave of Missile Weapons III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 6 points. +5726 Weave of Missile Weapons IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 8 points. +5727 Weave of Missile Weapons V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Missile Weapons skill by 10 points. +5728 Weave of Two Handed Combat I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Two Handed Combat skill by 2 points. +5729 Weave of Two Handed Combat II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Two Handed Combat skill by 4 points. +5730 Weave of Two Handed Combat III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Two Handed Combat skill by 6 points. +5731 Weave of Two Handed Combat IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Two Handed Combat skill by 8 points. +5732 Weave of Two Handed Combat V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Two Handed Combat skill by 10 points. +5733 Weave of Light Weapons I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 2 points. +5734 Weave of Light Weapons II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 4 points. +5735 Weave of Light Weapons III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 6 points. +5736 Weave of Light Weapons IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 8 points. +5737 Weave of Light Weapons V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Light Weapons skill by 10 points. +5738 Weave of Void Magic I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Void Magic skill by 2 points. +5739 Weave of Void Magic II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Void Magic skill by 4 points. +5740 Weave of Void Magic III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Void Magic skill by 6 points. +5741 Weave of Void Magic IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Void Magic skill by 8 points. +5742 Weave of Void Magic V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Void Magic skill by 10 points. +5743 Weave of War Magic I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's War Magic skill by 2 points. +5744 Weave of War Magic II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's War Magic skill by 4 points. +5745 Weave of War Magic III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's War Magic skill by 6 points. +5746 Weave of War Magic IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's War Magic skill by 8 points. +5747 Weave of War Magic V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's War Magic skill by 10 points. +5748 Weave of Weapon Tinkering I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Weapon Tinkering skill by 2 points. +5749 Weave of Weapon Tinkering II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Weapon Tinkering skill by 4 points. +5750 Weave of Weapon Tinkering III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Weapon Tinkering skill by 6 points. +5751 Weave of Weapon Tinkering IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Weapon Tinkering skill by 8 points. +5752 Weave of the Weapon Tinkering V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Weapon Tinkering skill by 10 points. +5753 Cloaked in Skill 1 Buff Other 660 CloakAllSkillRaising 1 20 Creature Enchantment 70 Increases all of the target's skills by 20 for 20 seconds. +5754 Shroud of Darkness (Magic) 1 Debuff Other 661 CloakMagicDefenseLowering 1 -1 Creature Enchantment 70 Decreases the target's Magic Defense skill by half. +5755 Shroud of Darkness (Melee) 1 Debuff Other 662 CloakMeleeDefenseLowering 1 -1 Creature Enchantment 70 Decreases the targets's Melee Defense skill by half. +5756 Shroud of Darkness (Missile) 1 Debuff Other 663 CloakMissileDefenseLowering 1 -1 Creature Enchantment 70 Decreases the target's Missile Defense skill by half. +5757 Weave of Creature Attunement III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Assess Creature skill by 6 points. +5758 Weave of Creature Attunement IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Assess Creature skill by 8 points. +5759 Weave of the Creature Attunement V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Assess Creature skill by 10 points. +5760 Weave of Creature Attunement I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Assess Creature skill by 2 points. +5761 Weave of Creature Attunement II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Assess Creature skill by 4 points. +5762 Rolling Death 7 Neutral Other 117 AcidMissile 320 -1 War Magic 120 A giant snowball. +5763 Dirty Fighting Ineptitude Other I 1 Debuff Other 664 DirtyFightingLowering 1 60 Creature Enchantment 10 Decreases the target's Dirty Fighting skill by 10 points. +5764 Dirty Fighting Ineptitude Other II 2 Debuff Other 664 DirtyFightingLowering 75 90 Creature Enchantment 20 Decreases the target's Dirty Fighting skill by 15 points. +5765 Dirty Fighting Ineptitude Other III 3 Debuff Other 664 DirtyFightingLowering 125 120 Creature Enchantment 30 Decreases the target's Dirty Fighting skill by 20 points. +5766 Dirty Fighting Ineptitude Other IV 4 Debuff Other 664 DirtyFightingLowering 175 150 Creature Enchantment 40 Decreases the target's Dirty Fighting skill by 25 points. +5767 Dirty Fighting Ineptitude Other V 5 Debuff Other 664 DirtyFightingLowering 225 180 Creature Enchantment 50 Decreases the target's Dirty Fighting skill by 30 points. +5768 Dirty Fighting Ineptitude Other VI 6 Debuff Other 664 DirtyFightingLowering 275 210 Creature Enchantment 60 Decreases the target's Dirty Fighting skill by 35 points. +5769 Dirty Fighting Ineptitude Other VII 7 Debuff Other 664 DirtyFightingLowering 325 240 Creature Enchantment 70 Decreases the target's Dirty Fighting skill by 40 points. +5770 Incantation of Dirty Fighting Ineptitude Other 8 Debuff Other 664 DirtyFightingLowering 400 300 Creature Enchantment 80 Decreases the target's Dirty Fighting skill by 45 points. +5771 Dirty Fighting Mastery Other I 1 Buff Other 665 DirtyFightingRaising 1 1800 Creature Enchantment 10 Increases the target's Dirty Fighting skill by 10 points. +5772 Dirty Fighting Mastery Other II 2 Buff Other 665 DirtyFightingRaising 50 1800 Creature Enchantment 20 Increases the target's Dirty Fighting skill by 15 points. +5773 Dirty Fighting Mastery Other III 3 Buff Other 665 DirtyFightingRaising 100 1800 Creature Enchantment 30 Increases the target's Dirty Fighting skill by 20 points. +5774 Dirty Fighting Mastery Other IV 4 Buff Other 665 DirtyFightingRaising 150 1800 Creature Enchantment 40 Increases the target's Dirty Fighting skill by 25 points. +5775 Dirty Fighting Mastery Other V 5 Buff Other 665 DirtyFightingRaising 200 1800 Creature Enchantment 50 Increases the target's Dirty Fighting skill by 30 points. +5776 Dirty Fighting Mastery Other VI 6 Buff Other 665 DirtyFightingRaising 250 2700 Creature Enchantment 60 Increases the target's Dirty Fighting skill by 35 points. +5777 Dirty Fighting Mastery Other VII 7 Buff Other 665 DirtyFightingRaising 300 3600 Creature Enchantment 70 Increases the target's Dirty Fighting skill by 40 points. +5778 Incantation of Dirty Fighting Mastery Other 8 Buff Other 665 DirtyFightingRaising 400 5400 Creature Enchantment 80 Increases the target's Dirty Fighting skill by 45 points. +5779 Dirty Fighting Mastery Self I 1 Buff Self 665 DirtyFightingRaising 1 1800 Creature Enchantment 15 Increases the caster's Dirty Fighting skill by 10 points. +5780 Dirty Fighting Mastery Self II 2 Buff Self 665 DirtyFightingRaising 50 1800 Creature Enchantment 30 Increases the caster's Dirty Fighting skill by 15 points. +5781 Dirty Fighting Mastery Self III 3 Buff Self 665 DirtyFightingRaising 100 1800 Creature Enchantment 40 Increases the caster's Dirty Fighting skill by 20 points. +5782 Dirty Fighting Mastery Self IV 4 Buff Self 665 DirtyFightingRaising 150 1800 Creature Enchantment 50 Increases the caster's Dirty Fighting skill by 25 points. +5783 Dirty Fighting Mastery Self V 5 Buff Self 665 DirtyFightingRaising 200 1800 Creature Enchantment 60 Increases the caster's Dirty Fighting skill by 30 points. +5784 Dirty Fighting Mastery Self VI 6 Buff Self 665 DirtyFightingRaising 250 2700 Creature Enchantment 70 Increases the caster's Dirty Fighting skill by 35 points. +5785 Dirty Fighting Mastery Self VII 7 Buff Self 665 DirtyFightingRaising 300 3600 Creature Enchantment 70 Increases the caster's Dirty Fighting skill by 40 points. +5786 Incantation of Dirty Fighting Mastery Self 8 Buff Self 665 DirtyFightingRaising 400 5400 Creature Enchantment 80 Increases the caster's Dirty Fighting skill by 45 points. +5787 Dual Wield Ineptitude Other I 1 Debuff Other 667 DualWieldLowering 1 60 Creature Enchantment 10 Decreases the target's Dual Wield skill by 10 points. +5788 Dual Wield Ineptitude Other II 2 Debuff Other 667 DualWieldLowering 75 90 Creature Enchantment 20 Decreases the target's Dual Wield skill by 15 points. +5789 Dual Wield Ineptitude Other III 3 Debuff Other 667 DualWieldLowering 125 120 Creature Enchantment 30 Decreases the target's Dual Wield skill by 20 points. +5790 Dual Wield Ineptitude Other IV 4 Debuff Other 667 DualWieldLowering 175 150 Creature Enchantment 40 Decreases the target's Dual Wield skill by 25 points. +5791 Dual Wield Ineptitude Other V 5 Debuff Other 667 DualWieldLowering 225 180 Creature Enchantment 50 Decreases the target's Dual Wield skill by 30 points. +5792 Dual Wield Ineptitude Other VI 6 Debuff Other 667 DualWieldLowering 275 210 Creature Enchantment 60 Decreases the target's Dual Wield skill by 35 points. +5793 Dual Wield Ineptitude Other VII 7 Debuff Other 667 DualWieldLowering 325 240 Creature Enchantment 70 Decreases the target's Dual Wield skill by 40 points. +5794 Incantation of Dual Wield Ineptitude Other 8 Debuff Other 667 DualWieldLowering 400 300 Creature Enchantment 80 Decreases the target's Dual Wield skill by 45 points. +5795 Dual Wield Mastery Other I 1 Buff Other 668 DualWieldRaising 1 1800 Creature Enchantment 10 Increases the target's Dual Wield skill by 10 points. +5796 Dual Wield Mastery Other II 2 Buff Other 668 DualWieldRaising 50 1800 Creature Enchantment 20 Increases the target's Dual Wield skill by 15 points. +5797 Dual Wield Mastery Other III 3 Buff Other 668 DualWieldRaising 100 1800 Creature Enchantment 30 Increases the target's Dual Wield skill by 20 points. +5798 Dual Wield Mastery Other IV 4 Buff Other 668 DualWieldRaising 150 1800 Creature Enchantment 40 Increases the target's Dual Wield skill by 25 points. +5799 Dual Wield Mastery Other V 5 Buff Other 668 DualWieldRaising 200 1800 Creature Enchantment 50 Increases the target's Dual Wield skill by 30 points. +5800 Dual Wield Mastery Other VI 6 Buff Other 668 DualWieldRaising 250 2700 Creature Enchantment 60 Increases the target's Dual Wield skill by 35 points. +5801 Dual Wield Mastery Other VII 7 Buff Other 668 DualWieldRaising 300 3600 Creature Enchantment 70 Increases the target's Dual Wield skill by 40 points. +5802 Incantation of Dual Wield Mastery Other 8 Buff Other 668 DualWieldRaising 400 5400 Creature Enchantment 80 Increases the target's Dual Wield skill by 45 points. +5803 Dual Wield Mastery Self I 1 Buff Self 668 DualWieldRaising 1 1800 Creature Enchantment 15 Increases the caster's Dual Wield skill by 10 points. +5804 Dual Wield Mastery Self II 2 Buff Self 668 DualWieldRaising 50 1800 Creature Enchantment 30 Increases the caster's Dual Wield skill by 15 points. +5805 Dual Wield Mastery Self III 3 Buff Self 668 DualWieldRaising 100 1800 Creature Enchantment 40 Increases the caster's Dual Wield skill by 20 points. +5806 Dual Wield Mastery Self IV 4 Buff Self 668 DualWieldRaising 150 1800 Creature Enchantment 50 Increases the caster's Dual Wield skill by 25 points. +5807 Dual Wield Mastery Self V 5 Buff Self 668 DualWieldRaising 200 1800 Creature Enchantment 60 Increases the caster's Dual Wield skill by 30 points. +5808 Dual Wield Mastery Self VI 6 Buff Self 668 DualWieldRaising 250 2700 Creature Enchantment 70 Increases the caster's Dual Wield skill by 35 points. +5809 Dual Wield Mastery Self VII 7 Buff Self 668 DualWieldRaising 300 3600 Creature Enchantment 70 Increases the caster's Dual Wield skill by 40 points. +5810 Incantation of Dual Wield Mastery Self 8 Buff Self 668 DualWieldRaising 400 5400 Creature Enchantment 80 Increases the caster's Dual Wield skill by 45 points. +5811 Recklessness Ineptitude Other I 1 Debuff Other 670 RecklessnessLowering 1 60 Creature Enchantment 10 Decreases the target's Recklessness skill by 10 points. +5812 Recklessness Ineptitude Other II 2 Debuff Other 670 RecklessnessLowering 75 90 Creature Enchantment 20 Decreases the target's Recklessness skill by 15 points. +5813 Recklessness Ineptitude Other III 3 Debuff Other 670 RecklessnessLowering 125 120 Creature Enchantment 30 Decreases the target's Recklessness skill by 20 points. +5814 Recklessness Ineptitude Other IV 4 Debuff Other 670 RecklessnessLowering 175 150 Creature Enchantment 40 Decreases the target's Recklessness skill by 25 points. +5815 Recklessness Ineptitude Other V 5 Debuff Other 670 RecklessnessLowering 225 180 Creature Enchantment 50 Decreases the target's Recklessness skill by 30 points. +5816 Recklessness Ineptitude Other VI 6 Debuff Other 670 RecklessnessLowering 275 210 Creature Enchantment 60 Decreases the target's Recklessness skill by 35 points. +5817 Recklessness Ineptitude Other VII 7 Debuff Other 670 RecklessnessLowering 325 240 Creature Enchantment 70 Decreases the target's Recklessness skill by 40 points. +5818 Incantation of Recklessness Ineptitude Other 8 Debuff Other 670 RecklessnessLowering 400 300 Creature Enchantment 80 Decreases the target's Recklessness skill by 45 points. +5819 Recklessness Mastery Other I 1 Buff Other 671 RecklessnessRaising 1 1800 Creature Enchantment 10 Increases the target's Recklessness skill by 10 points. +5820 Recklessness Mastery Other II 2 Buff Other 671 RecklessnessRaising 50 1800 Creature Enchantment 20 Increases the target's Recklessness skill by 15 points. +5821 Recklessness Mastery Other III 3 Buff Other 671 RecklessnessRaising 100 1800 Creature Enchantment 30 Increases the target's Recklessness skill by 20 points. +5822 Recklessness Mastery Other IV 4 Buff Other 671 RecklessnessRaising 150 1800 Creature Enchantment 40 Increases the target's Recklessness skill by 25 points. +5823 Recklessness Mastery Other V 5 Buff Other 671 RecklessnessRaising 200 1800 Creature Enchantment 50 Increases the target's Recklessness skill by 30 points. +5824 Recklessness Mastery Other VI 6 Buff Other 671 RecklessnessRaising 250 2700 Creature Enchantment 60 Increases the target's Recklessness skill by 35 points. +5825 Recklessness Mastery Other VII 7 Buff Other 671 RecklessnessRaising 300 3600 Creature Enchantment 70 Increases the target's Recklessness skill by 40 points. +5826 Incantation of Recklessness Mastery Other 8 Buff Other 671 RecklessnessRaising 400 5400 Creature Enchantment 80 Increases the target's Recklessness skill by 45 points. +5827 Recklessness Mastery Self I 1 Buff Self 671 RecklessnessRaising 1 1800 Creature Enchantment 15 Increases the caster's Recklessness skill by 10 points. +5828 Recklessness Mastery Self II 2 Buff Self 671 RecklessnessRaising 50 1800 Creature Enchantment 30 Increases the caster's Recklessness skill by 15 points. +5829 Recklessness Mastery Self III 3 Buff Self 671 RecklessnessRaising 100 1800 Creature Enchantment 40 Increases the caster's Recklessness skill by 20 points. +5830 Recklessness Mastery Self IV 4 Buff Self 671 RecklessnessRaising 150 1800 Creature Enchantment 50 Increases the caster's Recklessness skill by 25 points. +5831 Recklessness Mastery Self V 5 Buff Self 671 RecklessnessRaising 200 1800 Creature Enchantment 60 Increases the caster's Recklessness skill by 30 points. +5832 Recklessness Mastery Self VI 6 Buff Self 671 RecklessnessRaising 250 2700 Creature Enchantment 70 Increases the caster's Recklessness skill by 35 points. +5833 Recklessness Mastery Self VII 7 Buff Self 671 RecklessnessRaising 300 3600 Creature Enchantment 70 Increases the caster's Recklessness skill by 40 points. +5834 Incantation of Recklessness Mastery Self 8 Buff Self 671 RecklessnessRaising 400 5400 Creature Enchantment 80 Increases the caster's Recklessness skill by 45 points. +5835 Shield Ineptitude Other I 1 Debuff Other 673 ShieldLowering 1 60 Creature Enchantment 10 Decreases the target's Shield skill by 10 points. +5836 Shield Ineptitude Other II 2 Debuff Other 673 ShieldLowering 75 90 Creature Enchantment 20 Decreases the target's Shield skill by 15 points. +5837 Shield Ineptitude Other III 3 Debuff Other 673 ShieldLowering 125 120 Creature Enchantment 30 Decreases the target's Shield skill by 20 points. +5838 Shield Ineptitude Other IV 4 Debuff Other 673 ShieldLowering 175 150 Creature Enchantment 40 Decreases the target's Shield skill by 25 points. +5839 Shield Ineptitude Other V 5 Debuff Other 673 ShieldLowering 225 180 Creature Enchantment 50 Decreases the target's Shield skill by 30 points. +5840 Shield Ineptitude Other VI 6 Debuff Other 673 ShieldLowering 275 210 Creature Enchantment 60 Decreases the target's Shield skill by 35 points. +5841 Shield Ineptitude Other VII 7 Debuff Other 673 ShieldLowering 325 240 Creature Enchantment 70 Decreases the target's Shield skill by 40 points. +5842 Incantation of Shield Ineptitude Other 8 Debuff Other 673 ShieldLowering 400 300 Creature Enchantment 80 Decreases the target's Shield skill by 45 points. +5843 Shield Mastery Other I 1 Buff Other 674 ShieldRaising 1 1800 Creature Enchantment 10 Increases the target's Shield skill by 10 points. +5844 Shield Mastery Other II 2 Buff Other 674 ShieldRaising 50 1800 Creature Enchantment 20 Increases the target's Shield skill by 15 points. +5845 Shield Mastery Other III 3 Buff Other 674 ShieldRaising 100 1800 Creature Enchantment 30 Increases the target's Shield skill by 20 points. +5846 Shield Mastery Other IV 4 Buff Other 674 ShieldRaising 150 1800 Creature Enchantment 40 Increases the target's Shield skill by 25 points. +5847 Shield Mastery Other V 5 Buff Other 674 ShieldRaising 200 1800 Creature Enchantment 50 Increases the target's Shield skill by 30 points. +5848 Shield Mastery Other VI 6 Buff Other 674 ShieldRaising 250 2700 Creature Enchantment 60 Increases the target's Shield skill by 35 points. +5849 Shield Mastery Other VII 7 Buff Other 674 ShieldRaising 300 3600 Creature Enchantment 70 Increases the target's Shield skill by 40 points. +5850 Incantation of Shield Mastery Other 8 Buff Other 674 ShieldRaising 400 5400 Creature Enchantment 80 Increases the target's Shield skill by 45 points. +5851 Shield Mastery Self I 1 Buff Self 674 ShieldRaising 1 1800 Creature Enchantment 15 Increases the caster's Shield skill by 10 points. +5852 Shield Mastery Self II 2 Buff Self 674 ShieldRaising 50 1800 Creature Enchantment 30 Increases the caster's Shield skill by 15 points. +5853 Shield Mastery Self III 3 Buff Self 674 ShieldRaising 100 1800 Creature Enchantment 40 Increases the caster's Shield skill by 20 points. +5854 Shield Mastery Self IV 4 Buff Self 674 ShieldRaising 150 1800 Creature Enchantment 50 Increases the caster's Shield skill by 25 points. +5855 Shield Mastery Self V 5 Buff Self 674 ShieldRaising 200 1800 Creature Enchantment 60 Increases the caster's Shield skill by 30 points. +5856 Shield Mastery Self VI 6 Buff Self 674 ShieldRaising 250 2700 Creature Enchantment 70 Increases the caster's Shield skill by 35 points. +5857 Shield Mastery Self VII 7 Buff Self 674 ShieldRaising 300 3600 Creature Enchantment 70 Increases the caster's Shield skill by 40 points. +5858 Incantation of Shield Mastery Self 8 Buff Self 674 ShieldRaising 400 5400 Creature Enchantment 80 Increases the caster's Shield skill by 45 points. +5859 Sneak Attack Ineptitude Other I 1 Debuff Other 676 SneakAttackLowering 1 60 Creature Enchantment 10 Decreases the target's Sneak Attack skill by 10 points. +5860 Sneak Attack Ineptitude Other II 2 Debuff Other 676 SneakAttackLowering 75 90 Creature Enchantment 20 Decreases the target's Sneak Attack skill by 15 points. +5861 Sneak Attack Ineptitude Other III 3 Debuff Other 676 SneakAttackLowering 125 120 Creature Enchantment 30 Decreases the target's Sneak Attack skill by 20 points. +5862 Sneak Attack Ineptitude Other IV 4 Debuff Other 676 SneakAttackLowering 175 150 Creature Enchantment 40 Decreases the target's Sneak Attack skill by 25 points. +5863 Sneak Attack Ineptitude Other V 5 Debuff Other 676 SneakAttackLowering 225 180 Creature Enchantment 50 Decreases the target's Sneak Attack skill by 30 points. +5864 Sneak Attack Ineptitude Other VI 6 Debuff Other 676 SneakAttackLowering 275 210 Creature Enchantment 60 Decreases the target's Sneak Attack skill by 35 points. +5865 Sneak Attack Ineptitude Other VII 7 Debuff Other 676 SneakAttackLowering 325 240 Creature Enchantment 70 Decreases the target's Sneak Attack skill by 40 points. +5866 Incantation of Sneak Attack Ineptitude Other 8 Debuff Other 676 SneakAttackLowering 400 300 Creature Enchantment 80 Decreases the target's Sneak Attack skill by 45 points. +5867 Sneak Attack Mastery Other I 1 Buff Other 677 SneakAttackRaising 1 1800 Creature Enchantment 10 Increases the target's Sneak Attack skill by 10 points. +5868 Sneak Attack Mastery Other II 2 Buff Other 677 SneakAttackRaising 50 1800 Creature Enchantment 20 Increases the target's Sneak Attack skill by 15 points. +5869 Sneak Attack Mastery Other III 3 Buff Other 677 SneakAttackRaising 100 1800 Creature Enchantment 30 Increases the target's Sneak Attack skill by 20 points. +5870 Sneak Attack Mastery Other IV 4 Buff Other 677 SneakAttackRaising 150 1800 Creature Enchantment 40 Increases the target's Sneak Attack skill by 25 points. +5871 Sneak Attack Mastery Other V 5 Buff Other 677 SneakAttackRaising 200 1800 Creature Enchantment 50 Increases the target's Sneak Attack skill by 30 points. +5872 Sneak Attack Mastery Other VI 6 Buff Other 677 SneakAttackRaising 250 2700 Creature Enchantment 60 Increases the target's Sneak Attack skill by 35 points. +5873 Sneak Attack Mastery Other VII 7 Buff Other 677 SneakAttackRaising 300 3600 Creature Enchantment 70 Increases the target's Sneak Attack skill by 40 points. +5874 Incantation of Sneak Attack Mastery Other 8 Buff Other 677 SneakAttackRaising 400 5400 Creature Enchantment 80 Increases the target's Sneak Attack skill by 45 points. +5875 Sneak Attack Mastery Self I 1 Buff Self 677 SneakAttackRaising 1 1800 Creature Enchantment 15 Increases the caster's Sneak Attack skill by 10 points. +5876 Sneak Attack Mastery Self II 2 Buff Self 677 SneakAttackRaising 50 1800 Creature Enchantment 30 Increases the caster's Sneak Attack skill by 15 points. +5877 Sneak Attack Mastery Self III 3 Buff Self 677 SneakAttackRaising 100 1800 Creature Enchantment 40 Increases the caster's Sneak Attack skill by 20 points. +5878 Sneak Attack Mastery Self IV 4 Buff Self 677 SneakAttackRaising 150 1800 Creature Enchantment 50 Increases the caster's Sneak Attack skill by 25 points. +5879 Sneak Attack Mastery Self V 5 Buff Self 677 SneakAttackRaising 200 1800 Creature Enchantment 60 Increases the caster's Sneak Attack skill by 30 points. +5880 Sneak Attack Mastery Self VI 6 Buff Self 677 SneakAttackRaising 250 2700 Creature Enchantment 70 Increases the caster's Sneak Attack skill by 35 points. +5881 Sneak Attack Mastery Self VII 7 Buff Self 677 SneakAttackRaising 300 3600 Creature Enchantment 70 Increases the caster's Sneak Attack skill by 40 points. +5882 Incantation of Sneak Attack Mastery Self 8 Buff Self 677 SneakAttackRaising 400 5400 Creature Enchantment 80 Increases the caster's Sneak Attack skill by 45 points. +5883 Minor Dirty Fighting Prowess 1 Buff Other 666 ExtraDirtyFightingRaising 1 780 Creature Enchantment 10 Increases the target's Dirty Fighting skill by 5 points. Additional spells can be layered over this. +5884 Minor Dual Wield Aptitude 1 Buff Other 669 ExtraDualWieldRaising 1 780 Creature Enchantment 10 Increases the target's Dual Wield skill by 5 points. Additional spells can be layered over this. +5885 Minor Recklessness Prowess 1 Buff Other 672 ExtraRecklessnessRaising 1 780 Creature Enchantment 10 Increases the target's Recklessness skill by 5 points. Additional spells can be layered over this. +5886 Minor Shield Aptitude 1 Buff Other 675 ExtraShieldRaising 1 780 Creature Enchantment 10 Increases the target's Shield skill by 5 points. Additional spells can be layered over this. +5887 Minor Sneak Attack Prowess 1 Buff Other 678 ExtraSneakAttackRaising 1 780 Creature Enchantment 10 Increases the target's Sneak Attack skill by 5 points. Additional spells can be layered over this. +5888 Major Dirty Fighting Prowess 1 Buff Other 666 ExtraDirtyFightingRaising 2 780 Creature Enchantment 10 Increases the target's Dirty Fighting skill by 15 points. Additional spells can be layered over this. +5889 Major Dual Wield Aptitude 1 Buff Other 669 ExtraDualWieldRaising 2 780 Creature Enchantment 10 Increases the target's Dual Wield skill by 15 points. Additional spells can be layered over this. +5890 Major Recklessness Prowess 1 Buff Other 672 ExtraRecklessnessRaising 2 780 Creature Enchantment 10 Increases the target's Recklessness skill by 15 points. Additional spells can be layered over this. +5891 Major Shield Aptitude 1 Buff Other 675 ExtraShieldRaising 2 780 Creature Enchantment 10 Increases the target's Shield skill by 15 points. Additional spells can be layered over this. +5892 Major Sneak Attack Prowess 1 Buff Other 678 ExtraSneakAttackRaising 2 780 Creature Enchantment 10 Increases the target's Sneak Attack skill by 15 points. Additional spells can be layered over this. +5893 Epic Dirty Fighting Prowess 1 Buff Other 666 ExtraDirtyFightingRaising 25 780 Creature Enchantment 10 Increases the target's Dirty Fighting skill by 25 points. Additional spells can be layered over this. +5894 Epic Dual Wield Aptitude 1 Buff Other 669 ExtraDualWieldRaising 25 780 Creature Enchantment 10 Increases the target's Dual Wield skill by 25 points. Additional spells can be layered over this. +5895 Epic Recklessness Prowess 1 Buff Other 672 ExtraRecklessnessRaising 25 780 Creature Enchantment 10 Increases the target's Recklessness skill by 25 points. Additional spells can be layered over this. +5896 Epic Shield Aptitude 1 Buff Other 675 ExtraShieldRaising 25 780 Creature Enchantment 10 Increases the target's Shield skill by 25 points. Additional spells can be layered over this. +5897 Epic Sneak Attack Prowess 1 Buff Other 678 ExtraSneakAttackRaising 25 780 Creature Enchantment 10 Increases the target's Sneak Attack skill by 25 points. Additional spells can be layered over this. +5898 Moderate Dirty Fighting Prowess 1 Buff Other 666 ExtraDirtyFightingRaising 10 780 Creature Enchantment 10 Increases the target's Dirty Fighting skill by 10 points. Additional spells can be layered over this. +5899 Moderate Dual Wield Aptitude 1 Buff Other 669 ExtraDualWieldRaising 10 780 Creature Enchantment 10 Increases the target's Dual Wield skill by 10 points. Additional spells can be layered over this. +5900 Moderate Recklessness Prowess 1 Buff Other 672 ExtraRecklessnessRaising 10 780 Creature Enchantment 10 Increases the target's Recklessness skill by 10 points. Additional spells can be layered over this. +5901 Moderate Shield Aptitude 1 Buff Other 675 ExtraShieldRaising 10 780 Creature Enchantment 10 Increases the target's Shield skill by 10 points. Additional spells can be layered over this. +5902 Moderate Sneak Attack Prowess 1 Buff Other 678 ExtraSneakAttackRaising 10 780 Creature Enchantment 10 Increases the target's Sneak Attack skill by 10 points. Additional spells can be layered over this. +5903 Prodigal Dual Wield Mastery 8 Buff Other 680 RareDualWieldRaising 600 900 Creature Enchantment 70 Increases the caster's Dual Wield skill by 250 points. +5904 Spectral Dual Wield Mastery 6 Buff Other 680 RareDualWieldRaising 250 540 Creature Enchantment 70 Increases the caster's Dual Wield skill by 150 points for 9 minutes. +5905 Prodigal Recklessness Mastery 8 Buff Other 681 RareRecklessnessRaising 600 900 Creature Enchantment 70 Increases the caster's Recklessness skill by 250 points. +5906 Spectral Recklessness Mastery 6 Buff Other 681 RareRecklessnessRaising 250 540 Creature Enchantment 70 Increases the caster's Recklessness skill by 150 points for 9 minutes. +5907 Prodigal Shield Mastery 8 Buff Other 682 RareShieldRaising 600 900 Creature Enchantment 70 Increases the caster's Shield skill by 250 points. +5908 Spectral Shield Mastery 6 Buff Other 682 RareShieldRaising 250 540 Creature Enchantment 70 Increases the caster's Shield skill by 150 points for 9 minutes. +5909 Prodigal Sneak Attack Mastery 8 Buff Other 683 RareSneakAttackRaising 600 900 Creature Enchantment 70 Increases the caster's Sneak Attack skill by 250 points. +5910 Spectral Sneak Attack Mastery 6 Buff Other 683 RareSneakAttackRaising 250 540 Creature Enchantment 70 Increases the caster's Sneak Attack skill by 150 points for 9 minutes. +5911 Prodigal Dirty Fighting Mastery 8 Buff Other 679 RareDirtyFightingRaising 600 900 Creature Enchantment 70 Increases the caster's Dirty Fighting skill by 250 points. +5912 Spectral Dirty Fighting Mastery 6 Buff Other 679 RareDirtyFightingRaising 250 540 Creature Enchantment 70 Increases the caster's Dirty Fighting skill by 150 points for 9 minutes. +5913 Weave of Dirty Fighting I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Dirty Fighting skill by 2 points. +5914 Weave of Dirty Fighting II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Dirty Fighting skill by 4 points. +5915 Weave of Dirty Fighting III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Dirty Fighting skill by 6 points. +5916 Weave of Dirty Fighting IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Dirty Fighting skill by 8 points. +5917 Weave of Dirty Fighting V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Dirty Fighting skill by 10 points. +5918 Weave of Dual Wield I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Dual Wield skill by 2 points. +5919 Weave of Dual Wield II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Dual Wield skill by 4 points. +5920 Weave of Dual Wield III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Dual Wield skill by 6 points. +5921 Weave of Dual Wield IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Dual Wield skill by 8 points. +5922 Weave of Dual Wield V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Dual Wield skill by 10 points. +5923 Weave of Recklessness I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Recklessness skill by 2 points. +5924 Weave of Recklessness II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Recklessness skill by 4 points. +5925 Weave of Recklessness III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Recklessness skill by 6 points. +5926 Weave of Recklessness IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Recklessness skill by 8 points. +5927 Weave of Recklessness V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Recklessness skill by 10 points. +5928 Weave of Shield I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Shield skill by 2 points. +5929 Weave of Shield II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Shield skill by 4 points. +5930 Weave of Shield III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Shield skill by 6 points. +5931 Weave of Shield IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Shield skill by 8 points. +5932 Weave of Shield V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Shield skill by 10 points. +5933 Weave of Sneak Attack I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Sneak Attack skill by 2 points. +5934 Weave of Sneak Attack II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Sneak Attack skill by 4 points. +5935 Weave of Sneak Attack III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Sneak Attack skill by 6 points. +5936 Weave of Sneak Attack IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Sneak Attack skill by 8 points. +5937 Weave of Sneak Attack V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Sneak Attack skill by 10 points. +5938 Blinding Assault 1 Buff Other 684 DFAttackSkillDebuff 1 20 Creature Enchantment 70 Decreases all of the target's attack skills by 20 for 20 seconds. +5939 Bleeding Assault 6 Buff Other 685 DFBleedDamage 250 20 Life Magic 80 The target loses 120 points of health over 20 seconds. +5940 Unbalancing Assault 1 Buff Other 686 DFDefenseSkillDebuff 1 20 Creature Enchantment 70 Decreases all of the target's defense skills by 20 for 20 seconds. +5941 Traumatic Assault 1 Buff Other 687 DFHealingDebuff 1 20 Creature Enchantment 70 Decreases heals cast on the target by a rating of 20 for 20 seconds. +5942 Blinding Blow 1 Buff Other 684 DFAttackSkillDebuff 1 20 Creature Enchantment 70 Decreases all of the target's attack skills by 10 for 20 seconds. +5943 Bleeding Blow 6 Buff Other 685 DFBleedDamage 250 20 Life Magic 80 The target loses 60 points of health over 20 seconds. +5944 Unbalancing Blow 1 Buff Other 686 DFDefenseSkillDebuff 1 20 Creature Enchantment 70 Decreases all of the target's defense skills by 10 for 20 seconds. +5945 Traumatic Blow 1 Buff Other 687 DFHealingDebuff 1 20 Creature Enchantment 70 Decreases heals cast on the target by a rating of 10 for 20 seconds. +5946 Novice Soldier's Dirty Fighting Aptitude 1 Buff Other 688 SetDirtyFightingRaising 1 1800 Creature Enchantment 10 Increases the target's Dirty Fighting skill by 3 points. +5947 Apprentice Soldier's Dirty Fighting Aptitude 1 Buff Other 688 SetDirtyFightingRaising 2 1800 Creature Enchantment 10 Increases the target's Dirty Fighting skill by 5 points. +5948 Journeyman Soldier's Dirty Fighting Aptitude 1 Buff Other 688 SetDirtyFightingRaising 3 1800 Creature Enchantment 10 Increases the target's Dirty Fighting skill by 10 points. +5949 Master Soldier's Dirty Fighting Aptitude 1 Buff Other 688 SetDirtyFightingRaising 4 1800 Creature Enchantment 10 Increases the target's Dirty Fighting skill by 20 points. +5950 Novice Soldier's Dual Wield Aptitude 1 Buff Other 689 SetDualWieldRaising 1 1800 Creature Enchantment 10 Increases the target's Dual Wield skill by 3 points. +5951 Apprentice Soldier's Dual Wield Aptitude 1 Buff Other 689 SetDualWieldRaising 2 1800 Creature Enchantment 10 Increases the target's Dual Wield skill by 5 points. +5952 Journeyman Soldier's Dual Wield Aptitude 1 Buff Other 689 SetDualWieldRaising 3 1800 Creature Enchantment 10 Increases the target's Dual Wield skill by 10 points. +5953 Master Soldier's Dual Wield Aptitude 1 Buff Other 689 SetDualWieldRaising 4 1800 Creature Enchantment 10 Increases the target's Dual Wield skill by 20 points. +5954 Novice Soldier's Recklessness Aptitude 1 Buff Other 690 SetRecklessnessRaising 1 1800 Creature Enchantment 10 Increases the target's Recklessness skill by 3 points. +5955 Apprentice Soldier's Recklessness Aptitude 1 Buff Other 690 SetRecklessnessRaising 2 1800 Creature Enchantment 10 Increases the target's Recklessness skill by 5 points. +5956 Journeyman Soldier's Recklessness Aptitude 1 Buff Other 690 SetRecklessnessRaising 3 1800 Creature Enchantment 10 Increases the target's Recklessness skill by 10 points. +5957 Master Soldier's Recklessness Aptitude 1 Buff Other 690 SetRecklessnessRaising 4 1800 Creature Enchantment 10 Increases the target's Recklessness skill by 20 points. +5958 Novice Soldier's Shield Aptitude 1 Buff Other 691 SetShieldRaising 1 1800 Creature Enchantment 10 Increases the target's Shield skill by 3 points. +5959 Apprentice Soldier's Shield Aptitude 1 Buff Other 691 SetShieldRaising 2 1800 Creature Enchantment 10 Increases the target's Shield skill by 5 points. +5960 Journeyman Soldier's Shield Aptitude 1 Buff Other 691 SetShieldRaising 3 1800 Creature Enchantment 10 Increases the target's Shield skill by 10 points. +5961 Master Soldier's Shield Aptitude 1 Buff Other 691 SetShieldRaising 4 1800 Creature Enchantment 10 Increases the target's Shield skill by 20 points. +5962 Novice Soldier's Sneak Attack Aptitude 1 Buff Other 692 SetSneakAttackRaising 1 1800 Creature Enchantment 10 Increases the target's Sneak Attack skill by 3 points. +5963 Apprentice Soldier's Sneak Attack Aptitude 1 Buff Other 692 SetSneakAttackRaising 2 1800 Creature Enchantment 10 Increases the target's Sneak Attack skill by 5 points. +5964 Journeyman Soldier's Sneak Attack Aptitude 1 Buff Other 692 SetSneakAttackRaising 3 1800 Creature Enchantment 10 Increases the target's Sneak Attack skill by 10 points. +5965 Master Soldier's Sneak Attack Aptitude 1 Buff Other 692 SetSneakAttackRaising 4 1800 Creature Enchantment 10 Increases the target's Sneak Attack skill by 20 points. +5966 Vigor of Mhoire 1 Buff Other 693 LifeGiverMhoire 20 10800 Life Magic 70 Increases maximum health by 20 points. +5967 Galvanic Arc 8 Neutral Other 120 ElectricMissile 400 -1 War Magic 40 Shoots a blue bolt of lighting at the target. The bolt does 200-300 points of electrical damage to the first thing it hits. +5968 Galvanic Blast 8 Projectile Other 134 ElectricBurst 400 -1 War Magic 40 Shoots five blue bolts of lightning outward from the caster. Each bolt does 50-100 points of electric damage to the first thing it hits. +5969 Galvanic Strike 8 Neutral Other 120 ElectricMissile 400 -1 War Magic 35 Shoots a bolt of blue lighting at the target. The bolt does 200-300 points of electrical damage to the target. +5970 Galvanic Streak 8 Projectile Other 246 ElectricStreak 400 -1 War Magic 80 Sends a bolt of lighting streaking towards the target. The bolt does 50-100 points of electrical damage to the first thing it hits. +5971 Galvanic Volley 8 Projectile Other 210 LightningVolley 400 -1 War Magic 40 Shoots five blue bolts of lightning toward the target. Each bolt does 50-100 points of electric damage to the first thing it hits. +5972 Galvanic Bomb 8 Neutral Other 225 ElectricRing 400 -1 War Magic 80 Shoots 12 waves of blue lightning outward from the caster. Each wave does 200-1000 points of electric damage to the first thing it hits. +5973 Protection of Mouf 1 Buff Other 289 ColdWardProtection 15 5400 Life Magic 10 Reduces damage the target takes from Cold by 15%. Additional spells can be layered over this. +5974 Rare Armor Damage Boost I 1 Buff Other 694 RareDamageRatingRaising2 1 10800 Life Magic 70 Your damage rating is increased by 1. +5975 Rare Armor Damage Boost II 1 Buff Other 694 RareDamageRatingRaising2 1 10800 Life Magic 70 Your damage rating is increased by 2. +5976 Rare Armor Damage Boost III 1 Buff Other 694 RareDamageRatingRaising2 1 10800 Life Magic 70 Your damage rating is increased by 3. +5977 Rare Armor Damage Boost IV 1 Buff Other 694 RareDamageRatingRaising2 1 10800 Life Magic 70 Your damage rating is increased by 4. +5978 Rare Armor Damage Boost V 1 Buff Other 694 RareDamageRatingRaising2 1 10800 Life Magic 70 Your damage rating is increased by 5. +5979 Blighted Touch 7 Buff Other 410 HealthDivide 327 60 Creature Enchantment 10 Sath'tik's blighted touch wracks your body. you are afflicted with his corruption and suffer greatly. All secondary attributes are reduced by 40% for the duration of the spell. +5980 Corrupted Touch 7 Buff Other 618 DamageOverTimeRaising 350 30 Life Magic 80 Sath'tik's corruption has seeped into your skin. causing damage over time. The target loses 357 points of health over 30 seconds. +5981 Sath'tik's Curse 7 Buff Other 619 HealingResistRatingRaising 350 300 Life Magic 80 Your wounds are cursed and don't heal as well. +5982 Aura of Hermetic Link Other I 1 Buff Other 195 ManaConversionModRaising 25 1800 Item Enchantment 10 Increases a magic casting implement's mana conversion bonus by 10%. +5983 Aura of Hermetic Link Other II 2 Buff Other 195 ManaConversionModRaising 50 1800 Item Enchantment 20 Increases a magic casting implement's mana conversion bonus by 20%. +5984 Aura of Hermetic Link Other III 3 Buff Other 195 ManaConversionModRaising 100 1800 Item Enchantment 30 Increases a magic casting implement's mana conversion bonus by 30%. +5985 Aura of Hermetic Link Other IV 4 Buff Other 195 ManaConversionModRaising 150 1800 Item Enchantment 40 Increases a magic casting implement's mana conversion bonus by 40%. +5986 Aura of Hermetic Link Other V 5 Buff Other 195 ManaConversionModRaising 200 1800 Item Enchantment 50 Increases a magic casting implement's mana conversion bonus by 50%. +5987 Aura of Hermetic Link Other VI 6 Buff Other 195 ManaConversionModRaising 250 2700 Item Enchantment 60 Increases a magic casting implement's mana conversion bonus by 60%. +5988 Aura of Hermetic Link Other VII 7 Buff Other 195 ManaConversionModRaising 300 3600 Item Enchantment 70 Increases a magic casting implement's mana conversion bonus by 70%. +5989 Aura of Incantation of Hermetic Link Other 8 Buff Other 195 ManaConversionModRaising 400 5400 Item Enchantment 80 Increases a magic casting implement's mana conversion bonus by 80%. +5990 Aura of Blood Drinker Other I 1 Buff Other 154 DamageRaising 1 1800 Item Enchantment 10 Increases a weapon's damage value by 2 points. +5991 Aura of Blood Drinker Other II 2 Buff Other 154 DamageRaising 50 1800 Item Enchantment 20 Increases a weapon's damage value by 4 points. +5992 Aura of Blood Drinker Other III 3 Buff Other 154 DamageRaising 100 1800 Item Enchantment 30 Increases a weapon's damage value by 8 points. +5993 Aura of Blood Drinker Other IV 4 Buff Other 154 DamageRaising 150 1800 Item Enchantment 40 Increases a weapon's damage value by 12 points. +5994 Aura of Blood Drinker Other V 5 Buff Other 154 DamageRaising 200 1800 Item Enchantment 50 Increases a weapon's damage value by 16 points. +5995 Aura of Blood Drinker Other VI 6 Buff Other 154 DamageRaising 250 2700 Item Enchantment 60 Increases a weapon's damage value by 20 points. +5996 Aura of Blood Drinker Other VII 7 Buff Other 154 DamageRaising 300 3600 Item Enchantment 70 Increases a weapon's damage value by 22 points. +5997 Aura of Incantation of Blood Drinker Other 8 Buff Other 154 DamageRaising 400 5400 Item Enchantment 80 Increases a weapon's damage value by 24 points. +5998 Aura of Incantation of Blood Drinker Other 7 Buff Other 154 DamageRaising 350 5400 Item Enchantment 80 Increases a weapon's damage value by 22 points. +5999 Aura of Defender Other I 1 Buff Other 156 DefenseModRaising 1 1800 Item Enchantment 10 Increases the Melee Defense skill modifier of a weapon or magic caster by 3%. +6000 Aura of Defender Other II 2 Buff Other 156 DefenseModRaising 50 1800 Item Enchantment 20 Increases the Melee Defense skill modifier of a weapon or magic caster by 5%. +6001 Aura of Defender Other III 3 Buff Other 156 DefenseModRaising 100 1800 Item Enchantment 30 Increases the Melee Defense skill modifier of a weapon or magic caster by 7.5%. +6002 Aura of Defender Other IV 4 Buff Other 156 DefenseModRaising 150 1800 Item Enchantment 40 Increases the Melee Defense skill modifier of a weapon or magic caster by 10%. +6003 Aura of Defender Other V 5 Buff Other 156 DefenseModRaising 200 1800 Item Enchantment 50 Increases the Melee Defense skill modifier of a weapon or magic caster by 13%. +6004 Aura of Defender Other VI 6 Buff Other 156 DefenseModRaising 250 2700 Item Enchantment 60 Increases the Melee Defense skill modifier of a weapon or magic caster by 15%. +6005 Aura of Defender Other VII 7 Buff Other 156 DefenseModRaising 300 3600 Item Enchantment 70 Increases the Melee Defense skill modifier of a weapon or magic caster by 17%. +6006 Aura of Incantation of Defender Other 7 Buff Other 156 DefenseModRaising 350 5400 Item Enchantment 80 Increases the Melee Defense skill modifier of a weapon or magic caster by 17%. +6007 Aura of Heart Seeker Other I 1 Buff Other 152 AttackModRaising 1 1800 Item Enchantment 10 Increases a weapon's Attack Skill modifier by 2.5 percentage points. +6008 Aura of Heart Seeker Other II 2 Buff Other 152 AttackModRaising 50 1800 Item Enchantment 20 Increases a weapon's Attack Skill modifier by 5.0 percentage points. +6009 Aura of Heart Seeker Other III 3 Buff Other 152 AttackModRaising 100 1800 Item Enchantment 30 Increases a weapon's Attack Skill modifier by 7.5 percentage points. +6010 Aura of Heart Seeker Other IV 4 Buff Other 152 AttackModRaising 150 1800 Item Enchantment 40 Increases a weapon's Attack Skill modifier by 10.0 percentage points. +6011 Aura of Heart Seeker Other V 5 Buff Other 152 AttackModRaising 200 1800 Item Enchantment 50 Increases a weapon's Attack Skill modifier by 12.5 percentage points. +6012 Aura of Heart Seeker Other VI 6 Buff Other 152 AttackModRaising 250 2700 Item Enchantment 60 Increases a weapon's Attack Skill modifier by 15.0 percentage points. +6013 Aura of Heart Seeker Other VII 7 Buff Other 152 AttackModRaising 300 3600 Item Enchantment 70 Increases a weapon's Attack Skill modifier by 17.0 percentage points. +6014 Aura of Incantation of Heart Seeker Other 8 Buff Other 152 AttackModRaising 400 5400 Item Enchantment 80 Increases a weapon's Attack Skill modifier by 20.0 percentage points. +6015 Aura of Spirit Drinker Other I 1 Buff Other 695 SpellDamageRaising 1 1800 Item Enchantment 10 Increases the elemental damage bonus of an elemental magic caster by 1%. +6016 Aura of Spirit Drinker Other II 2 Buff Other 695 SpellDamageRaising 50 1800 Item Enchantment 20 Increases the elemental damage bonus of an elemental magic caster by 2%. +6017 Aura of Spirit Drinker Other III 3 Buff Other 695 SpellDamageRaising 100 1800 Item Enchantment 30 Increases the elemental damage bonus of an elemental magic caster by 3%. +6018 Aura of Spirit Drinker Other IV 4 Buff Other 695 SpellDamageRaising 150 1800 Item Enchantment 40 Increases the elemental damage bonus of an elemental magic caster by 4%. +6019 Aura of Spirit Drinker Other V 5 Buff Other 695 SpellDamageRaising 200 1800 Item Enchantment 50 Increases the elemental damage bonus of an elemental magic caster by 5%. +6020 Aura of Spirit Drinker Other VI 6 Buff Other 695 SpellDamageRaising 250 2700 Item Enchantment 60 Increases the elemental damage bonus of an elemental magic caster by 6%. +6021 Aura of Spirit Drinker Other VII 7 Buff Other 695 SpellDamageRaising 300 3600 Item Enchantment 70 Increases the elemental damage bonus of an elemental magic caster by 7%. +6022 Aura of Incantation of Spirit Drinker Other 8 Buff Other 695 SpellDamageRaising 400 5400 Item Enchantment 80 Increases the elemental damage bonus of an elemental magic caster by 8%. +6023 Aura of Incantation of Spirit Drinker Other 7 Buff Other 695 SpellDamageRaising 350 5400 Item Enchantment 80 Increases the elemental damage bonus of an elemental magic caster by 7%. +6024 Aura of Swift Killer Other I 1 Buff Other 158 WeaponTimeRaising 1 1800 Item Enchantment 10 Improves a weapon's speed by 10 points. +6025 Aura of Swift Killer Other II 2 Buff Other 158 WeaponTimeRaising 50 1800 Item Enchantment 20 Improves a weapon's speed by 20 points. +6026 Aura of Swift Killer Other III 3 Buff Other 158 WeaponTimeRaising 100 1800 Item Enchantment 30 Improves a weapon's speed by 30 points. +6027 Aura of Swift Killer Other IV 4 Buff Other 158 WeaponTimeRaising 150 1800 Item Enchantment 40 Improves a weapon's speed by 40 points. +6028 Aura of Swift Killer Other V 5 Buff Other 158 WeaponTimeRaising 200 1800 Item Enchantment 50 Improves a weapon's speed by 50 points. +6029 Aura of Swift Killer Other VI 6 Buff Other 158 WeaponTimeRaising 250 2700 Item Enchantment 60 Improves a weapon's speed by 60 points. +6030 Aura of Swift Killer Other VII 7 Buff Other 158 WeaponTimeRaising 300 3600 Item Enchantment 70 Improves a weapon's speed by 70 points. +6031 Aura of Incantation of Swift Killer Other 8 Buff Other 158 WeaponTimeRaising 400 5400 Item Enchantment 80 Improves a weapon's speed by 80 points. +6032 Imprisoned 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +6033 Impudence 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +6034 Proving Grounds Rolling Death 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +6035 Spirit of Izexi 1 Buff Item 323 MaxDamageRaising 1 10800 Item Enchantment 10 Infuses a magic caster with the spirit of the Dark Falatacot. Izexi. Increases the elemental damage bonus of an elemental magic caster by 1%. Additional spells can be layered over this. +6036 No Escape 8 Debuff Other 78 RunLowering 500 180 Creature Enchantment 10 There is no escape! Target's run skill is reduced by 95%. +6037 Fleeting Will 6 Debuff Other 12 SelfLowering 285 180 Creature Enchantment 10 The voices in your head command you. This spell decreases the target's Self by 80%. +6038 Warm and Fuzzy 7 Buff Other 411 StaminaDivide 300 3600 Creature Enchantment 10 The cider makes you feel all warm and fuzzy inside. raising your Stamina by 10% for 1 hour. +6039 Legendary Weapon Tinkering Expertise 1 Buff Other 377 ExtraAppraiseWeaponSkillRaising 35 780 Creature Enchantment 10 Increases the target's Weapon Tinkering skill by 35 points. Additional spells can be layered over this. +6040 Legendary Alchemical Prowess 1 Buff Other 333 ExtraAlchemySkillRaising 35 780 Creature Enchantment 10 Increases the target's Alchemy skill by 35 points. Additional spells can be layered over this. +6041 Legendary Arcane Prowess 1 Buff Other 335 ExtraArcaneLoreSkillRaising 35 780 Creature Enchantment 10 Increases the target's Arcane Lore skill by 35 points. Additional spells can be layered over this. +6042 Legendary Armor Tinkering Expertise 1 Buff Other 337 ExtraAppraiseArmorSkillRaising 35 780 Creature Enchantment 10 Increases the target's Armor Tinkering skill by 35 points. Additional spells can be layered over this. +6043 Legendary Light Weapon Aptitude 1 Buff Other 311 CascadeAxeRaising 35 780 Creature Enchantment 10 Increases the target's Light Weapons skill by 35 points. Additional spells can be layered over this. +6044 Legendary Missile Weapon Aptitude 1 Buff Other 331 ExtraBowSkillRaising 35 780 Creature Enchantment 10 Increases the target's Missile Weapons skill by 35 points. Additional spells can be layered over this. +6045 Legendary Cooking Prowess 1 Buff Other 339 ExtraCookingSkillRaising 35 780 Creature Enchantment 10 Increases the target's Cooking skill by 35 points. Additional spells can be layered over this. +6046 Legendary Creature Enchantment Aptitude 1 Buff Other 251 CreatureMysticRaising 35 780 Creature Enchantment 10 Increases the target's Creature Enchantment skill by 35 points. Additional spells can be layered over this. +6047 Legendary Finesse Weapon Aptitude 1 Buff Other 313 CascadeDaggerRaising 35 780 Creature Enchantment 10 Increases the target's Finesse Weapons skill by 35 points. Additional spells can be layered over this. +6048 Legendary Deception Prowess 1 Buff Other 343 ExtraDeceptionSkillRaising 35 780 Creature Enchantment 10 Increases the target's Deception skill by 35 points. Additional spells can be layered over this. +6049 Legendary Dirty Fighting Prowess 1 Buff Other 666 ExtraDirtyFightingRaising 35 780 Creature Enchantment 10 Increases the target's Dirty Fighting skill by 35 points. Additional spells can be layered over this. +6050 Legendary Dual Wield Aptitude 1 Buff Other 669 ExtraDualWieldRaising 35 780 Creature Enchantment 10 Increases the target's Dual Wield skill by 35 points. Additional spells can be layered over this. +6051 Legendary Fealty 1 Buff Other 345 ExtraLoyaltySkillRaising 35 780 Creature Enchantment 10 Increases the target's Loyalty skill by 35 points. Additional spells can be layered over this. +6052 Legendary Fletching Prowess 1 Buff Other 347 ExtraFletchingSkillRaising 35 780 Creature Enchantment 10 Increases the target's Fletching skill by 35 points. Additional spells can be layered over this. +6053 Legendary Healing Prowess 1 Buff Other 349 ExtraHealingSkillRaising 35 780 Creature Enchantment 10 Increases the target's Healing skill by 35 points. Additional spells can be layered over this. +6054 Legendary Impregnability 1 Buff Other 654 ExtraMissileDefenseSkillRaising 35 780 Creature Enchantment 10 Increases the target's Missile Defense skill by 35 points. Additional spells can be layered over this. +6055 Legendary Invulnerability 1 Buff Other 351 ExtraMeleeDefenseSkillRaising 35 780 Creature Enchantment 10 Increases the target's Melee Defense skill by 35 points. Additional spells can be layered over this. +6056 Legendary Item Enchantment Aptitude 1 Buff Other 253 ItemMysticRaising 35 780 Creature Enchantment 10 Increases the target's Item Enchantment skill by 35 points. Additional spells can be layered over this. +6057 Legendary Item Tinkering Expertise 1 Buff Other 353 ExtraAppraiseItemSkillRaising 35 780 Creature Enchantment 10 Increases the target's Item Tinkering skill by 35 points. Additional spells can be layered over this. +6058 Legendary Jumping Prowess 1 Buff Other 355 ExtraJumpingSkillRaising 35 780 Creature Enchantment 10 Increases the target's Jump skill by 35 points. Additional spells can be layered over this. +6059 Legendary Leadership 1 Buff Other 293 LeadershipObedienceRaising 35 780 Creature Enchantment 10 Increases the target's Leadership skill by 35 points. Additional spells can be layered over this. +6060 Legendary Life Magic Aptitude 1 Buff Other 357 ExtraLifeMagicSkillRaising 35 780 Creature Enchantment 10 Increases the target's Life Magic skill by 35 points. Additional spells can be layered over this. +6061 Legendary Lockpick Prowess 1 Buff Other 359 ExtraLockpickSkillRaising 35 780 Creature Enchantment 10 Increases the target's Lockpick skill by 35 points. Additional spells can be layered over this. +6062 Legendary Magic Item Tinkering Expertise 1 Buff Other 361 ExtraAppraiseMagicItemSkillRaising 35 780 Creature Enchantment 10 Increases the target's Magic Item Tinkering skill by 35 points. Additional spells can be layered over this. +6063 Legendary Magic Resistance 1 Buff Other 299 MagicDefenseShelterRaising 35 780 Creature Enchantment 10 Increases the target's Magic Defense skill by 35 points. Additional spells can be layered over this. +6064 Legendary Mana Conversion Prowess 1 Buff Other 363 ExtraManaConversionSkillRaising 35 780 Creature Enchantment 10 Increases the target's Mana Conversion skill by 35 points. Additional spells can be layered over this. +6065 Legendary Monster Attunement 1 Buff Other 365 ExtraAssessCreatureSkillRaising 35 780 Creature Enchantment 10 Increases the target's Assess Creature skill by 35 points. Additional spells can be layered over this. +6066 Legendary Person Attunement 1 Buff Other 367 ExtraAssessPersonSkillRaising 35 780 Creature Enchantment 10 Increases the target's Assess Person skill by 35 points. Additional spells can be layered over this. +6067 Legendary Recklessness Prowess 1 Buff Other 672 ExtraRecklessnessRaising 35 780 Creature Enchantment 10 Increases the target's Recklessness skill by 35 points. Additional spells can be layered over this. +6068 Legendary Salvaging Aptitude 1 Buff Other 437 ExtraSalvagingRaising2 35 780 Creature Enchantment 10 Increases the target's Salvaging skill by 35 points. Additional spells can be layered over this. +6069 Legendary Shield Aptitude 1 Buff Other 675 ExtraShieldRaising 35 780 Creature Enchantment 10 Increases the target's Shield skill by 35 points. Additional spells can be layered over this. +6070 Legendary Sneak Attack Prowess 1 Buff Other 678 ExtraSneakAttackRaising 35 780 Creature Enchantment 10 Increases the target's Sneak Attack skill by 35 points. Additional spells can be layered over this. +6071 Legendary Sprint 1 Buff Other 369 ExtraRunSkillRaising 35 780 Creature Enchantment 10 Increases the target's Run skill by 35 points. Additional spells can be layered over this. +6072 Legendary Heavy Weapon Aptitude 1 Buff Other 371 ExtraSwordSkillRaising 35 780 Creature Enchantment 10 Increases the target's Heavy Weapons skill by 35 points. Additional spells can be layered over this. +6073 Legendary Two Handed Combat Aptitude 1 Buff Other 595 ExtraTwoHandedSkillRaising 35 780 Creature Enchantment 10 Increases the target's Two Handed Combat skill by 35 points. Additional spells can be layered over this. +6074 Legendary Void Magic Aptitude 1 Buff Other 646 VoidMysticRaising 35 780 Creature Enchantment 10 Increases the target's Void Magic skill by 35 points. Additional spells can be layered over this. +6075 Legendary War Magic Aptitude 1 Buff Other 255 WarMysticRaising 35 780 Creature Enchantment 10 Increases the target's War Magic skill by 35 points. Additional spells can be layered over this. +6076 Legendary Stamina Gain 2 Buff Other 407 StaminaRestoring 60 780 Life Magic 10 Increases the rate at which the target regains Stamina by 60%. Additional spells can be layered over this. +6077 Legendary Health Gain 2 Buff Other 257 HealthRestoring 60 780 Life Magic 10 Increases the rate at which the target regains Health by 60%. Additional spells can be layered over this. +6078 Legendary Mana Gain 2 Buff Other 259 ManaRestoring 60 780 Life Magic 10 Increases the rate at which the target regains Mana by 60%. Additional spells can be layered over this. +6079 Legendary Storm Ward 1 Buff Other 291 ElectricWardProtection 25 780 Life Magic 10 Reduces damage the target takes from Lightning by 25%. Additional spells can be layered over this. +6080 Legendary Acid Ward 1 Buff Other 285 AcidWardProtection 25 780 Life Magic 10 Reduces damage the target takes from Acid by 25%. Additional spells can be layered over this. +6081 Legendary Bludgeoning Ward 1 Buff Other 401 BludgeonWardProtection 25 780 Life Magic 10 Reduces damage the target takes from Bludgeoning by 25%. Additional spells can be layered over this. +6082 Legendary Flame Ward 1 Buff Other 287 FireWardProtection 25 780 Life Magic 10 Reduces damage the target takes from Fire by 25%. Additional spells can be layered over this. +6083 Legendary Frost Ward 1 Buff Other 289 ColdWardProtection 25 780 Life Magic 10 Reduces damage the target takes from Cold by 25%. Additional spells can be layered over this. +6084 Legendary Piercing Ward 1 Buff Other 405 PierceWardProtection 25 780 Life Magic 10 Reduces damage the target takes from Piercing by 25%. Additional spells can be layered over this. +6085 Legendary Slashing Ward 1 Buff Other 403 SlashWardProtection 25 780 Life Magic 10 Reduces damage the target takes from Slashing by 25%. Additional spells can be layered over this. +6086 Epic Hermetic Link 1 Buff Item 425 ExtraManaConversionBonus 25 1800 Item Enchantment 10 Increases a magic casting implement's mana conversion bonus by 25%. +6087 Legendary Hermetic Link 1 Buff Item 425 ExtraManaConversionBonus 30 1800 Item Enchantment 10 Increases a magic casting implement's mana conversion bonus by 30%. +6088 Legendary Acid Bane 1 Buff Item 381 ExtraAcidResistanceRaising 4 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Acid damage by 25%. Additional spells can be layered over this. +6089 Legendary Blood Thirst 1 Buff Item 323 MaxDamageRaising 10 780 Item Enchantment 10 Increases a weapon's damage value by 10 points. Additional spells can be layered over this. +6090 Legendary Bludgeoning Bane 1 Buff Item 383 ExtraBludgeonResistanceRaising 4 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Bludgeoning damage by 25%. Additional spells can be layered over this. +6091 Legendary Defender 1 Buff Item 329 ExtraDefenseModRaising 9 780 Item Enchantment 10 Increases the Melee Defense skill modifier of a weapon or magic caster by 9%. Additional spells can be layered over this. +6092 Legendary Flame Bane 1 Buff Item 385 ExtraFireResistanceRaising 4 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Fire damage by 25%. Additional spells can be layered over this. +6093 Legendary Frost Bane 1 Buff Item 387 ExtraColdResistanceRaising 4 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Cold damage by 25%. Additional spells can be layered over this. +6094 Legendary Heart Thirst 1 Buff Item 389 ExtraAttackModRaising 9 780 Item Enchantment 10 Increases a weapon's Attack Skill modifier by 9%. Additional spells can be layered over this. +6095 Legendary Impenetrability 1 Buff Item 391 ExtraArmorValueRaising 4 780 Item Enchantment 10 Improves a shield or piece of armor's Armor value by 80 points. Additional spells can be layered over this. +6096 Legendary Piercing Bane 1 Buff Item 393 ExtraPierceResistanceRaising 4 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Piercing damage by 25%. Additional spells can be layered over this. +6097 Legendary Slashing Bane 1 Buff Item 395 ExtraSlashResistanceRaising 4 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Slashing damage by 25%. Additional spells can be layered over this. +6098 Legendary Spirit Thirst 1 Buff Item 323 MaxDamageRaising 7 780 Item Enchantment 10 Increases the elemental damage bonus of an elemental magic caster by 7%. Additional spells can be layered over this. +6099 Legendary Storm Bane 1 Buff Item 397 ExtraElectricResistanceRaising 4 780 Item Enchantment 10 Increases a shield or piece of armor's resistance to Electric damage by 25%. Additional spells can be layered over this. +6100 Legendary Swift Hunter 1 Buff Item 399 ExtraWeaponTimeRaising 40 780 Item Enchantment 10 Improves a weapon's speed by 40 points. Additional spells can be layered over this. +6101 Legendary Willpower 1 Buff Other 271 SelfIncrease 35 780 Creature Enchantment 10 Increases the target's Self by 35 points. Additional spells can be layered over this. +6102 Legendary Armor 2 Buff Other 379 ArmorIncrease 80 780 Life Magic 10 Increases the target's natural armor by 80 points. Additional spells can be layered over this. +6103 Legendary Coordination 1 Buff Other 267 CoordinationIncrease 35 780 Creature Enchantment 10 Increases the target's Coordination by 35 points. Additional spells can be layered over this. +6104 Legendary Endurance 1 Buff Other 263 EnduranceIncrease 35 780 Creature Enchantment 10 Increases the target's Endurance by 35 points. Additional spells can be layered over this. +6105 Legendary Focus 1 Buff Other 269 FocusIncrease 35 780 Creature Enchantment 10 Increases the target's Focus by 35 points. Additional spells can be layered over this. +6106 Legendary Quickness 1 Buff Other 265 QuicknessIncrease 35 780 Creature Enchantment 10 Increases the target's Quickness by 35 points. Additional spells can be layered over this. +6107 Legendary Strength 1 Buff Other 261 StrengthIncrease 35 780 Creature Enchantment 10 Increases the target's Strength by 35 points. Additional spells can be layered over this. +6108 Summoning Mastery Other I 1 Buff Other 696 SummoningRaising 1 1800 Creature Enchantment 10 Increases the target's Summoning skill by 10 points. +6109 Summoning Mastery Other II 2 Buff Other 696 SummoningRaising 50 1800 Creature Enchantment 20 Increases the target's Summoning skill by 15 points. +6110 Summoning Mastery Other III 3 Buff Other 696 SummoningRaising 100 1800 Creature Enchantment 30 Increases the target's Summoning skill by 20 points. +6111 Summoning Mastery Other IV 4 Buff Other 696 SummoningRaising 150 1800 Creature Enchantment 40 Increases the target's Summoning skill by 25 points. +6112 Summoning Mastery Other V 5 Buff Other 696 SummoningRaising 200 1800 Creature Enchantment 50 Increases the target's Summoning skill by 30 points. +6113 Summoning Mastery Other VI 6 Buff Other 696 SummoningRaising 250 2700 Creature Enchantment 60 Increases the target's Summoning skill by 35 points. +6114 Summoning Mastery Other VII 7 Buff Other 696 SummoningRaising 300 3600 Creature Enchantment 70 Increases the target's Summoning skill by 40 points. +6115 Incantation of Summoning Mastery Other 8 Buff Other 696 SummoningRaising 400 5400 Creature Enchantment 80 Increases the target's Summoning skill by 45 points. +6116 Summoning Mastery Self I 1 Buff Self 696 SummoningRaising 1 1800 Creature Enchantment 15 Increases the caster's Summoning skill by 10 points. +6117 Summoning Mastery Self II 2 Buff Self 696 SummoningRaising 50 1800 Creature Enchantment 30 Increases the caster's Summoning skill by 15 points. +6118 Summoning Mastery Self III 3 Buff Self 696 SummoningRaising 100 1800 Creature Enchantment 40 Increases the caster's Summoning skill by 20 points. +6119 Summoning Mastery Self IV 4 Buff Self 696 SummoningRaising 150 1800 Creature Enchantment 50 Increases the caster's Summoning skill by 25 points. +6120 Summoning Mastery Self V 5 Buff Self 696 SummoningRaising 200 1800 Creature Enchantment 60 Increases the caster's Summoning skill by 30 points. +6121 Summoning Mastery Self VI 6 Buff Self 696 SummoningRaising 250 2700 Creature Enchantment 70 Increases the caster's Summoning skill by 35 points. +6122 Summoning Mastery Self VII 7 Buff Self 696 SummoningRaising 300 3600 Creature Enchantment 70 Increases the caster's Summoning skill by 40 points. +6123 Incantation of Summoning Mastery Self 8 Buff Self 696 SummoningRaising 400 5400 Creature Enchantment 80 Increases the caster's Summoning skill by 45 points. +6124 Epic Summoning Prowess 1 Buff Other 698 ExtraSummoningSkillRaising 25 780 Creature Enchantment 10 Increases the target's Summoning skill by 25 points. Additional spells can be layered over this. +6125 Legendary Summoning Prowess 1 Buff Other 698 ExtraSummoningSkillRaising 35 780 Creature Enchantment 10 Increases the target's Summoning skill by 35 points. Additional spells can be layered over this. +6126 Major Summoning Prowess 1 Buff Other 698 ExtraSummoningSkillRaising 2 780 Creature Enchantment 10 Increases the target's Summoning skill by 15 points. Additional spells can be layered over this. +6127 Minor Summoning Prowess 1 Buff Other 698 ExtraSummoningSkillRaising 1 780 Creature Enchantment 10 Increases the target's Summoning skill by 5 points. Additional spells can be layered over this. +6128 Moderate Summoning Prowess 1 Buff Other 698 ExtraSummoningSkillRaising 10 780 Creature Enchantment 10 Increases the target's Summoning skill by 10 points. Additional spells can be layered over this. +6129 Summoning Ineptitude Other I 1 Debuff Other 697 SummoningLowering 1 60 Creature Enchantment 10 Decreases the target's Summoning skill by 10 points. +6130 Summoning Ineptitude Other II 2 Debuff Other 697 SummoningLowering 75 90 Creature Enchantment 20 Decreases the target's Summoning skill by 15 points. +6131 Summoning Ineptitude Other III 3 Debuff Other 697 SummoningLowering 125 120 Creature Enchantment 30 Decreases the target's Summoning skill by 20 points. +6132 Summoning Ineptitude Other IV 4 Debuff Other 697 SummoningLowering 175 150 Creature Enchantment 40 Decreases the target's Summoning skill by 25 points. +6133 Summoning Ineptitude Other V 5 Debuff Other 697 SummoningLowering 225 180 Creature Enchantment 50 Decreases the target's Summoning skill by 30 points. +6134 Summoning Ineptitude Other VI 6 Debuff Other 697 SummoningLowering 275 210 Creature Enchantment 60 Decreases the target's Summoning skill by 35 points. +6135 Summoning Ineptitude Other VII 7 Debuff Other 697 SummoningLowering 325 240 Creature Enchantment 70 Decreases the target's Summoning skill by 40 points. +6136 Incantation of Summoning Ineptitude Other 8 Debuff Other 697 SummoningLowering 400 300 Creature Enchantment 80 Decreases the target's Summoning skill by 45 points. +6137 Weave of Summoning II 1 Buff Other 659 CloakSkillRaising 4 500 Creature Enchantment 70 Increases the target's Summoning skill by 4 points. +6138 Weave of Summoning III 1 Buff Other 659 CloakSkillRaising 6 500 Creature Enchantment 70 Increases the target's Summoning skill by 6 points. +6139 Weave of Summoning IV 1 Buff Other 659 CloakSkillRaising 8 500 Creature Enchantment 70 Increases the target's Summoning skill by 8 points. +6140 Weave of Summoning V 1 Buff Other 659 CloakSkillRaising 10 500 Creature Enchantment 70 Increases the target's Summoning skill by 10 points. +6141 Weave of Summoning I 1 Buff Other 659 CloakSkillRaising 2 500 Creature Enchantment 70 Increases the target's Summoning skill by 2 points. +6142 Novice Invoker's Summoning Aptitude 1 Buff Other 699 SetSummoningRaising 1 1800 Creature Enchantment 10 Increases the target's Summoning skill by 3 points. +6143 Apprentice Invoker's Summoning Aptitude 1 Buff Other 699 SetSummoningRaising 2 1800 Creature Enchantment 10 Increases the target's Summoning skill by 5 points. +6144 Journeyman Invoker's Summoning Aptitude 1 Buff Other 699 SetSummoningRaising 3 1800 Creature Enchantment 10 Increases the target's Summoning skill by 10 points. +6145 Master Invoker's Summoning Aptitude 1 Buff Other 699 SetSummoningRaising 4 1800 Creature Enchantment 10 Increases the target's Summoning skill by 20 points. +6146 Ride The Lightning 8 Buff Other 107 ElectricProtection 425 10800 Life Magic 80 Reduces damage the target takes from Lightning by 70%. +6147 Entrance to the Frozen Valley 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports target to the Frozen Valley. +6148 Begone and Be Afraid 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +6149 Rynthid Vision 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the specified destination. +6150 Rynthid Recall 5 Utility Self 214 PortalSending 225 -1 Item Enchantment 150 Transports the caster to the area overrun by the Rynthid. +6151 Crimson Storm 5 Neutral Other 225 ElectricRing 200 -1 War Magic 80 Shoots eight waves of lightning outward from the caster. Each wave does 42-84 points of electric damage to the first thing it hits. +6152 Rocky Shrapnel 8 Neutral Other 223 BludgeoningRing 400 -1 War Magic 80 Shoots 12 waves of boulders outward from the caster. Each wave does 100-400 points of bludgeoning damage to the first thing it hits. +6153 Tryptophan Coma 8 Debuff Other 6 QuicknessLowering 400 300 Creature Enchantment 80 You are soooooo sleepy. reducing your Quickness. +6154 Entering the Basement 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Entering the Basement +6155 Earthen Stomp 8 Neutral Other 223 BludgeoningRing 1200 -1 Life Magic 80 The stomp of these creatures creates powerful rings of destructive force. +6156 Viridian Ring 8 Debuff Other 80 HealthLowering 1200 -1 Life Magic 150 A powerful emanation that creates a ring of overwhelming life magic. +6157 Withering Ring 8 Buff Other 643 NetherDamageHealingReductionRaising 1200 -1 Life Magic 150 A terrible emanation that destroys the victim's ability to heal wounds. +6158 Poison Breath 8 Neutral Other 530 HealthDoT 1200 -1 Life Magic 40 A deadly cone of poison. +6159 Thorn Volley 8 Projectile Other 136 PiercingBurst 600 -1 Life Magic 40 A cone of thorns and quill like projectiles. +6160 Thorns 8 Neutral Other 122 PiercingMissile 400 -1 War Magic 40 Shoots a cluster of sharp thorns at the target. The cluster does 142-204 points of piercing damage to the first thing it hits. +6161 Acidic Thorns 8 Neutral Other 117 AcidMissile 400 -1 War Magic 40 Shoots a cluster of acidic thorns at the target. The cluster does 142-204 points of acid damage to the first thing it hits. +6162 Thorn Arc 8 Neutral Other 122 PiercingMissile 400 -1 War Magic 40 Shoots a cluster of sharp thorns at the target. The thorns do 142-204 points of piercing damage to the first thing it hits. +6163 Ring of Thorns 7 Projectile Other 227 PiercingRing 300 -1 War Magic 80 Shoots eight clusters of thorns outward from the caster. Each does 42-84 points of piercing damage to the first thing it hits. +6164 Deadly Ring of Thorns 8 Projectile Other 227 PiercingRing 1200 -1 War Magic 80 Shoots eight clusters of thorns outward from the caster. Each does 42-84 points of piercing damage to the first thing it hits. +6165 Deadly Thorn Volley 8 Projectile Other 136 PiercingBurst 1200 -1 Life Magic 40 A deadly cone of thorns and quill like projectiles. +6166 Poisoned Wounds 7 Buff Other 619 HealingResistRatingRaising 350 30 Life Magic 80 Your wounds are poisoned and don't heal as well. +6167 Poisoned Vitality 2 Buff Other 410 HealthDivide 50 30 Creature Enchantment 10 Poison flows in your veins reducing your total health by 50%. +6168 Deadly Ring of Lightning 8 Projectile Other 225 ElectricRing 1200 -1 War Magic 80 The power of storms creates a deadly ring of lightning. +6169 Deadly Lightning Volley 8 Projectile Other 134 ElectricBurst 1200 -1 War Magic 40 A deadly cone of lightning. +6170 Honeyed Life Mead 1 Buff Other 700 HoneyedLifeRaising 20 10800 Life Magic 70 Increases maximum health by 20 points. +6171 Honeyed Mana Mead 1 Buff Other 701 HoneyedManaRaising 20 10800 Life Magic 70 Increases maximum mana by 50 points. +6172 Honeyed Vigor Mead 1 Buff Other 702 HoneyedVigorRaising 20 10800 Life Magic 70 Increases maximum stamina by 50 points. +6173 Raging Heart 2 Buff Other 279 LifeGiverRaising 65 3600 Life Magic 70 Increases maximum health by 65 points for 1 hour. +6174 Twisting Wounds 1 Buff Other 703 TwistingWounds 2 1200 Life Magic 70 The Critical Damage Rating of the caster is increased by 10. +6175 Increasing Pain 1 Buff Other 650 LuminanceDamageRatingRaising 2 1200 Life Magic 70 The damage rating of the caster is increased by 10. This spell does not stack with Luminous Crystal of Surging Strength. +6176 Genius 6 Buff Other 15 FocusBrilliance 250 30 Creature Enchantment 60 Increases the caster's Focus by 50 points for a short period of time. +6177 Gauntlet Item Mastery 6 Buff Other 453 AppraiseItemRaisingRare 250 600 Creature Enchantment 70 Increases the caster's Item Tinkering skill by 150 points for 10 minutes. This effect does not stack with Prodigal rare spells. +6178 Gauntlet Weapon Mastery 6 Buff Other 455 AppraiseWeaponRaisingRare 250 600 Creature Enchantment 70 Increases the caster's Weapon Tinkering skill by 150 points for 10 minutes. This effect does not stack with Prodigal rare spells. +6179 Gauntlet Magic Item Mastery 6 Buff Other 454 AppraiseMagicItemRaisingRare 250 600 Creature Enchantment 70 Increases the caster's Magic Item Tinkering skill by 150 points for 10 minutes. This effect does not stack with Prodigal rare spells. +6180 Gauntlet Armor Mastery 6 Buff Other 452 AppraiseArmorRaisingRare 250 600 Creature Enchantment 70 Increases the caster's Armor Tinkering skill by 150 points for 10 minutes. This effect does not stack with Prodigal rare spells. +6181 Singeing Flames 8 Neutral Other 226 FireRing 400 -1 War Magic 80 Shoots eight waves of flame forward from the caster. Each wave does 150-250 points of fire damage to the first thing it hits. +6182 Over-Exerted 3 Buff Other 686 DFDefenseSkillDebuff 100 60 Creature Enchantment 70 Decreases all of the target's defense skills by 500 for 1 minute. +6183 Return to the Stronghold 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Gauntlet. +6184 Return to the Stronghold 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Gauntlet. +6185 Return to the Stronghold 3 Neutral Item 214 PortalSending 125 -1 Item Enchantment 50 Transports the target to the Gauntlet. +6186 Deafening Wail 8 Neutral Other 223 BludgeoningRing 1200 -1 War Magic 80 The bark of these creatures creates powerful rings of destructive force. +6187 Screeching Howl 8 Neutral Other 132 BludgeoningBurst 1200 -1 War Magic 40 A deafening howl creating deadly shockwaves. +6188 Earthquake 8 Neutral Other 223 BludgeoningRing 1200 -1 War Magic 80 The stomp of this creature violently shakes the ground. +6189 Searing Disc II 7 Neutral Other 222 AcidRing 300 -1 War Magic 90 Shoots eight waves of acid outward from the caster. Each wave does 49-96 points of acid damage to the first thing it hits. +6190 Horizon's Blades II 7 Neutral Other 228 SlashingRing 300 -1 War Magic 90 Shoots eight blades outward from the caster. Each blade does 49-98 points of slashing damage to the first thing it hits. +6191 Cassius' Ring of Fire II 7 Projectile Other 226 FireRing 300 -1 War Magic 90 Shoots eight waves of flame outward from the caster. Each wave does 49-98 points of fire damage to the first thing it hits. +6192 Nuhmudira's Spines II 7 Neutral Other 227 PiercingRing 300 -1 War Magic 90 Shoots eight waves of force outward from the caster. Each wave does 49-98 points of piercing damage to the first thing it hits. +6193 Halo of Frost II 7 Neutral Other 224 ColdRing 300 -1 War Magic 90 Shoots eight waves of frost outward from the caster. Each wave does 49-98 points of cold damage to the first thing it hits. +6194 Eye of the Storm II 7 Neutral Other 225 ElectricRing 300 -1 War Magic 90 Shoots eight waves of lightning outward from the caster. Each wave does 49-98 points of electric damage to the first thing it hits. +6195 Clouded Soul II 7 Neutral Other 641 NetherRing 300 -1 Void Magic 90 Shoots eight waves of nether outward from the caster. Each wave does 109-172 points of nether damage to the first thing it hits. +6196 Tectonic Rifts II 7 Neutral Other 223 BludgeoningRing 300 -1 War Magic 90 Shoots eight shock waves outward from the caster. Each wave does 49-96 points of bludgeoning damage to the first thing it hits. +6197 Eye of the Storm II 6 Neutral Other 225 ElectricRing 250 -1 War Magic 90 Shoots eight waves of lightning outward from the caster. Each wave does 49-98 points of electric damage to the first thing it hits. +6198 Incantation of Lightning Bolt 8 Projectile Other 120 ElectricMissile 400 -1 War Magic 40 Shoots a bolt of lighting at the target. The bolt does 142-204 points of electrical damage to the first thing it hits. +6199 Incantation of Lightning Arc 8 Neutral Other 120 ElectricMissile 400 -1 War Magic 40 Shoots a bolt of lighting at the target. The bolt does 142-204 points of electrical damage to the first thing it hits. +6200 Paragon's Dual Wield Mastery V 1 Buff Other 708 ParagonDualWieldRaising 5 5400 Creature Enchantment 80 Increases the wielder's Dual Wield skill by 5 points. +6201 Paragon's Finesse Weapon Mastery I 1 Buff Other 716 ParagonDaggerRaising 1 5400 Creature Enchantment 80 Increases the wielder's Finesse Weapons skill by 1 point. +6202 Paragon's Finesse Weapon Mastery II 1 Buff Other 716 ParagonDaggerRaising 2 5400 Creature Enchantment 80 Increases the wielder's Finesse Weapons skill by 2 points. +6203 Paragon's Finesse Weapon Mastery III 1 Buff Other 716 ParagonDaggerRaising 3 5400 Creature Enchantment 80 Increases the wielder's Finesse Weapons skill by 3 points. +6204 Paragon's Finesse Weapon Mastery IV 1 Buff Other 716 ParagonDaggerRaising 4 5400 Creature Enchantment 80 Increases the wielder's Finesse Weapons skill by 4 points. +6205 Paragon's Finesse Weapon Mastery V 1 Buff Other 716 ParagonDaggerRaising 5 5400 Creature Enchantment 80 Increases the wielder's Finesse Weapons skill by 5 points. +6206 Paragon's Heavy Weapon Mastery I 1 Buff Other 717 ParagonSwordRaising 1 5400 Creature Enchantment 80 Increases the wielder's Heavy Weapons skill by 1 point. +6207 Paragon's Heavy Weapon Mastery II 1 Buff Other 717 ParagonSwordRaising 2 5400 Creature Enchantment 80 Increases the wielder's Heavy Weapons skill by 2 points. +6208 Paragon's Heavy Weapon Mastery III 1 Buff Other 717 ParagonSwordRaising 3 5400 Creature Enchantment 80 Increases the wielder's Heavy Weapons skill by 3 points. +6209 Paragon's Heavy Weapon Mastery IV 1 Buff Other 717 ParagonSwordRaising 4 5400 Creature Enchantment 80 Increases the wielder's Heavy Weapons skill by 4 points. +6210 Paragon's Heavy Weapon Mastery V 1 Buff Other 717 ParagonSwordRaising 5 5400 Creature Enchantment 80 Increases the wielder's Heavy Weapons skill by 5 points. +6211 Paragon's Life Magic Mastery I 1 Buff Other 719 ParagonLifeMagicRaising 1 5400 Creature Enchantment 80 Increases the wielder's Life Magic skill by 1 point. +6212 Paragon's Life Magic Mastery II 1 Buff Other 719 ParagonLifeMagicRaising 2 5400 Creature Enchantment 80 Increases the wielder's Life Magic skill by 2 points. +6213 Paragon's Life Magic Mastery III 1 Buff Other 719 ParagonLifeMagicRaising 3 5400 Creature Enchantment 80 Increases the wielder's Life Magic skill by 3 points. +6214 Paragon's Life Magic Mastery IV 1 Buff Other 719 ParagonLifeMagicRaising 4 5400 Creature Enchantment 80 Increases the wielder's Life Magic skill by 4 points. +6215 Paragon's Life Magic Mastery V 1 Buff Other 719 ParagonLifeMagicRaising 5 5400 Creature Enchantment 80 Increases the wielder's Life Magic skill by 5 points. +6216 Paragon's Light Weapon Mastery I 1 Buff Other 715 ParagonAxeRaising 1 5400 Creature Enchantment 80 Increases the wielder's Light Weapons skill by 1 point. +6217 Paragon's Light Weapon Mastery II 1 Buff Other 715 ParagonAxeRaising 2 5400 Creature Enchantment 80 Increases the wielder's Light Weapons skill by 2 points. +6218 Paragon's Light Weapon Mastery III 1 Buff Other 715 ParagonAxeRaising 3 5400 Creature Enchantment 80 Increases the wielder's Light Weapons skill by 3 points. +6219 Paragon's Light Weapon Mastery IV 1 Buff Other 715 ParagonAxeRaising 4 5400 Creature Enchantment 80 Increases the wielder's Light Weapons skill by 4 points. +6220 Paragon's Light Weapon Mastery V 1 Buff Other 715 ParagonAxeRaising 5 5400 Creature Enchantment 80 Increases the wielder's Light Weapons skill by 5 points. +6221 Paragon's Missile Weapon Mastery I 1 Buff Other 721 ParagonBowRaising 1 5400 Creature Enchantment 80 Increases the wielder's Missile Weapons skill by 1 point. +6222 Paragon's Missile Weapon Mastery II 1 Buff Other 721 ParagonBowRaising 2 5400 Creature Enchantment 80 Increases the wielder's Missile Weapons skill by 2 points. +6223 Paragon's Missile Weapon Mastery III 1 Buff Other 721 ParagonBowRaising 3 5400 Creature Enchantment 80 Increases the wielder's Missile Weapons skill by 3 points. +6224 Paragon's Missile Weapon Mastery IV 1 Buff Other 721 ParagonBowRaising 4 5400 Creature Enchantment 80 Increases the wielder's Missile Weapons skill by 4 points. +6225 Paragon's Missile Weapon Mastery V 1 Buff Other 721 ParagonBowRaising 5 5400 Creature Enchantment 80 Increases the wielder's Missile Weapons skill by 5 points. +6226 Paragon's Recklessness Mastery I 1 Buff Other 709 ParagonRecklessnessRaising 1 5400 Creature Enchantment 80 Increases the wielder's Recklessness skill by 1 point. +6227 Paragon's Recklessness Mastery II 1 Buff Other 709 ParagonRecklessnessRaising 2 5400 Creature Enchantment 80 Increases the wielder's Recklessness skill by 2 points. +6228 Paragon's Recklessness Mastery III 1 Buff Other 709 ParagonRecklessnessRaising 3 5400 Creature Enchantment 80 Increases the wielder's Recklessness skill by 3 points. +6229 Paragon's Recklessness Mastery IV 1 Buff Other 709 ParagonRecklessnessRaising 4 5400 Creature Enchantment 80 Increases the wielder's Recklessness skill by 4 points. +6230 Paragon's Recklessness Mastery V 1 Buff Other 709 ParagonRecklessnessRaising 5 5400 Creature Enchantment 80 Increases the wielder's Recklessness skill by 5 points. +6231 Paragon's Sneak Attack Mastery I 1 Buff Other 710 ParagonSneakAttackRaising 1 5400 Creature Enchantment 80 Increases the wielder's Sneak Attack skill by 1 point. +6232 Paragon's Sneak Attack Mastery II 1 Buff Other 710 ParagonSneakAttackRaising 2 5400 Creature Enchantment 80 Increases the wielder's Sneak Attack skill by 2 points. +6233 Paragon's Sneak Attack Mastery III 1 Buff Other 710 ParagonSneakAttackRaising 3 5400 Creature Enchantment 80 Increases the wielder's Sneak Attack skill by 3 points. +6234 Paragon's Sneak Attack Mastery IV 1 Buff Other 710 ParagonSneakAttackRaising 4 5400 Creature Enchantment 80 Increases the wielder's Sneak Attack skill by 4 points. +6235 Paragon's Sneak Attack Mastery V 1 Buff Other 710 ParagonSneakAttackRaising 5 5400 Creature Enchantment 80 Increases the wielder's Sneak Attack skill by 5 points. +6236 Paragon's Two Handed Combat Mastery I 1 Buff Other 727 ParagonTwoHandedRaising 1 5400 Creature Enchantment 80 Increases the wielder's Two Handed Combat skill by 1 point. +6237 Paragon's Two Handed Combat Mastery II 1 Buff Other 727 ParagonTwoHandedRaising 2 5400 Creature Enchantment 80 Increases the wielder's Two Handed Combat skill by 2 points. +6238 Paragon's Two Handed Combat Mastery III 1 Buff Other 727 ParagonTwoHandedRaising 3 5400 Creature Enchantment 80 Increases the wielder's Two Handed Combat skill by 3 points. +6239 Paragon's Two Handed Combat Mastery IV 1 Buff Other 727 ParagonTwoHandedRaising 4 5400 Creature Enchantment 80 Increases the wielder's Two Handed Combat skill by 4 points. +6240 Paragon's Two Handed Combat Mastery V 1 Buff Other 727 ParagonTwoHandedRaising 5 5400 Creature Enchantment 80 Increases the wielder's Two Handed Combat skill by 5 points. +6241 Paragon's Void Magic Mastery I 1 Buff Other 720 ParagonVoidMagicRaising 1 5400 Creature Enchantment 80 Increases the wielder's Void Magic skill by 1 point. +6242 Paragon's Void Magic Mastery II 1 Buff Other 720 ParagonVoidMagicRaising 2 5400 Creature Enchantment 80 Increases the wielder's Void Magic skill by 2 points. +6243 Paragon's Void Magic Mastery III 1 Buff Other 720 ParagonVoidMagicRaising 3 5400 Creature Enchantment 80 Increases the wielder's Void Magic skill by 3 points. +6244 Paragon's Void Magic Mastery IV 1 Buff Other 720 ParagonVoidMagicRaising 4 5400 Creature Enchantment 80 Increases the wielder's Void Magic skill by 4 points. +6245 Paragon's Void Magic Mastery V 1 Buff Other 720 ParagonVoidMagicRaising 5 5400 Creature Enchantment 80 Increases the wielder's Void Magic skill by 5 points. +6246 Paragon's War Magic Mastery I 1 Buff Other 718 ParagonWarMagicRaising 1 5400 Creature Enchantment 80 Increases the wielder's War Magic skill by 1 point. +6247 Paragon's War Magic Mastery II 1 Buff Other 718 ParagonWarMagicRaising 2 5400 Creature Enchantment 80 Increases the wielder's War Magic skill by 2 points. +6248 Paragon's War Magic Mastery III 1 Buff Other 718 ParagonWarMagicRaising 3 5400 Creature Enchantment 80 Increases the wielder's War Magic skill by 3 points. +6249 Paragon's War Magic Mastery IV 1 Buff Other 718 ParagonWarMagicRaising 4 5400 Creature Enchantment 80 Increases the wielder's War Magic skill by 4 points. +6250 Paragon's War Magic Mastery V 1 Buff Other 718 ParagonWarMagicRaising 5 5400 Creature Enchantment 80 Increases the wielder's War Magic skill by 5 points. +6251 Paragon's Dirty Fighting Mastery I 1 Buff Other 707 ParagonDirtyFightingRaising 1 5400 Creature Enchantment 80 Increases the wielder's Dirty Fighting skill by 1 point. +6252 Paragon's Dirty Fighting Mastery II 1 Buff Other 707 ParagonDirtyFightingRaising 2 5400 Creature Enchantment 80 Increases the wielder's Dirty Fighting skill by 2 points. +6253 Paragon's Dirty Fighting Mastery III 1 Buff Other 707 ParagonDirtyFightingRaising 3 5400 Creature Enchantment 80 Increases the wielder's Dirty Fighting skill by 3 points. +6254 Paragon's Dirty Fighting Mastery IV 1 Buff Other 707 ParagonDirtyFightingRaising 4 5400 Creature Enchantment 80 Increases the wielder's Dirty Fighting skill by 4 points. +6255 Paragon's Dirty Fighting Mastery V 1 Buff Other 707 ParagonDirtyFightingRaising 5 5400 Creature Enchantment 80 Increases the wielder's Dirty Fighting skill by 5 points. +6256 Paragon's Dual Wield Mastery I 1 Buff Other 708 ParagonDualWieldRaising 1 5400 Creature Enchantment 80 Increases the wielder's Dual Wield skill by 1 point. +6257 Paragon's Dual Wield Mastery II 1 Buff Other 708 ParagonDualWieldRaising 2 5400 Creature Enchantment 80 Increases the wielder's Dual Wield skill by 2 points. +6258 Paragon's Dual Wield Mastery III 1 Buff Other 708 ParagonDualWieldRaising 3 5400 Creature Enchantment 80 Increases the wielder's Dual Wield skill by 3 points. +6259 Paragon's Dual Wield Mastery IV 1 Buff Other 708 ParagonDualWieldRaising 4 5400 Creature Enchantment 80 Increases the wielder's Dual Wield skill by 4 points. +6260 Paragon's Willpower V 1 Buff Other 726 ParagonWillpowerRaising 5 5400 Creature Enchantment 80 Increases the wielder's Self by 5 points. +6261 Paragon's Coordination I 1 Buff Other 723 ParagonCoordinationRaising 1 5400 Creature Enchantment 80 Increases the wielder's Coordination by 1 point. +6262 Paragon's Coordination II 1 Buff Other 723 ParagonCoordinationRaising 2 5400 Creature Enchantment 80 Increases the wielder's Coordination by 2 points. +6263 Paragon's Coordination III 1 Buff Other 723 ParagonCoordinationRaising 3 5400 Creature Enchantment 80 Increases the wielder's Coordination by 3 points. +6264 Paragon's Coordination IV 1 Buff Other 723 ParagonCoordinationRaising 4 5400 Creature Enchantment 80 Increases the wielder's Coordination by 4 points. +6265 Paragon's Coordination V 1 Buff Other 723 ParagonCoordinationRaising 5 5400 Creature Enchantment 80 Increases the wielder's Coordination by 5 points. +6266 Paragon's Endurance I 1 Buff Other 704 ParagonEnduranceRaising 1 5400 Creature Enchantment 80 Increases the wielder's Endurance by 1 point. +6267 Paragon's Endurance II 1 Buff Other 704 ParagonEnduranceRaising 2 5400 Creature Enchantment 80 Increases the wielder's Endurance by 2 points. +6268 Paragon's Endurance III 1 Buff Other 704 ParagonEnduranceRaising 3 5400 Creature Enchantment 80 Increases the wielder's Endurance by 3 points. +6269 Paragon's Endurance IV 1 Buff Other 704 ParagonEnduranceRaising 4 5400 Creature Enchantment 80 Increases the wielder's Endurance by 4 points. +6270 Paragon's Endurance V 1 Buff Other 704 ParagonEnduranceRaising 5 5400 Creature Enchantment 80 Increases the wielder's Endurance by 5 points. +6271 Paragon's Focus I 1 Buff Other 725 ParagonFocusRaising 1 5400 Creature Enchantment 80 Increases the wielder's Focus by 1 point. +6272 Paragon's Focus II 1 Buff Other 725 ParagonFocusRaising 2 5400 Creature Enchantment 80 Increases the wielder's Focus by 2 points. +6273 Paragon's Focus III 1 Buff Other 725 ParagonFocusRaising 3 5400 Creature Enchantment 80 Increases the wielder's Focus by 3 points. +6274 Paragon's Focus IV 1 Buff Other 725 ParagonFocusRaising 4 5400 Creature Enchantment 80 Increases the wielder's Focus by 4 points. +6275 Paragon's Focus V 1 Buff Other 725 ParagonFocusRaising 5 5400 Creature Enchantment 80 Increases the wielder's Focus by 5 points. +6276 Paragon Quickness I 1 Buff Other 724 ParagonQuicknessRaising 1 5400 Creature Enchantment 80 Increases the wielder's Quickness by 1 point. +6277 Paragon Quickness II 1 Buff Other 724 ParagonQuicknessRaising 2 5400 Creature Enchantment 80 Increases the wielder's Quickness by 2 points. +6278 Paragon Quickness III 1 Buff Other 724 ParagonQuicknessRaising 3 5400 Creature Enchantment 80 Increases the wielder's Quickness by 3 points. +6279 Paragon Quickness IV 1 Buff Other 724 ParagonQuicknessRaising 4 5400 Creature Enchantment 80 Increases the wielder's Quickness by 4 points. +6280 Paragon Quickness V 1 Buff Other 724 ParagonQuicknessRaising 5 5400 Creature Enchantment 80 Increases the wielder's Quickness by 5 points. +6281 Paragon's Strength I 1 Buff Other 722 ParagonStrengthRaising 1 5400 Creature Enchantment 80 Increases the wielder's Strength by 1 point. +6282 Paragon's Strength II 1 Buff Other 722 ParagonStrengthRaising 2 5400 Creature Enchantment 80 Increases the wielder's Strength by 2 points. +6283 Paragon's Strength III 1 Buff Other 722 ParagonStrengthRaising 3 5400 Creature Enchantment 80 Increases the wielder's Strength by 3 points. +6284 Paragon's Strength IV 1 Buff Other 722 ParagonStrengthRaising 4 5400 Creature Enchantment 80 Increases the wielder's Strength by 4 points. +6285 Paragon's Strength V 1 Buff Other 722 ParagonStrengthRaising 5 5400 Creature Enchantment 80 Increases the wielder's Strength by 5 points. +6286 Paragon's Willpower I 1 Buff Other 726 ParagonWillpowerRaising 1 5400 Creature Enchantment 80 Increases the wielder's Self by 1 point. +6287 Paragon's Willpower II 1 Buff Other 726 ParagonWillpowerRaising 2 5400 Creature Enchantment 80 Increases the wielder's Self by 2 points. +6288 Paragon's Willpower III 1 Buff Other 726 ParagonWillpowerRaising 3 5400 Creature Enchantment 80 Increases the wielder's Self by 3 points. +6289 Paragon's Willpower IV 1 Buff Other 726 ParagonWillpowerRaising 4 5400 Creature Enchantment 80 Increases the wielder's Self by 4 points. +6290 Paragon's Stamina V 1 Buff Other 706 ParagonStaminaRaising 10 5400 Life Magic 70 Increases maximum stamina by 10 points. +6291 Paragon's Critical Boost I 1 Buff Other 713 ParagonCriticalDamageRatingRaising 1 5400 Life Magic 70 The critical damage rating of the wielder is increased by 1. +6292 Paragon's Critical Damage Boost II 1 Buff Other 713 ParagonCriticalDamageRatingRaising 2 5400 Life Magic 70 The critical damage rating of the wielder is increased by 2. +6293 Paragon's Critical Damage Boost III 1 Buff Other 713 ParagonCriticalDamageRatingRaising 3 5400 Life Magic 70 The critical damage rating of the wielder is increased by 3. +6294 Paragon's Critical Damage Boost IV 1 Buff Other 713 ParagonCriticalDamageRatingRaising 4 5400 Life Magic 70 The damage rating of the wielder is increased by 4. +6295 Paragon's Critical Damage Boost V 1 Buff Other 713 ParagonCriticalDamageRatingRaising 5 5400 Life Magic 70 The critical damage rating of the wielder is increased by 5. +6296 Paragon's Critical Damage Reduction I 1 Buff Other 714 ParagonCriticalDamageReductionRatingRaising 1 5400 Life Magic 70 The critical damage reduction rating of the wielder is increased by 1. +6297 Paragon's Critical Damage Reduction II 1 Buff Other 714 ParagonCriticalDamageReductionRatingRaising 2 5400 Life Magic 70 The critical damage reduction rating of the wielder is increased by 2. +6298 Paragon's Critical Damage Reduction III 1 Buff Other 714 ParagonCriticalDamageReductionRatingRaising 3 5400 Life Magic 70 The critical damage reduction rating of the wielder is increased by 3. +6299 Paragon's Critical Damage Reduction IV 1 Buff Other 714 ParagonCriticalDamageReductionRatingRaising 4 5400 Life Magic 70 The critical damage reduction rating of the wielder is increased by 4. +6300 Paragon's Critical Damage Reduction V 1 Buff Other 714 ParagonCriticalDamageReductionRatingRaising 5 5400 Life Magic 70 The critical damage reduction rating of the wielder is increased by 5. +6301 Paragon's Damage Boost I 1 Buff Other 711 ParagonDamageRatingRaising 1 5400 Life Magic 70 The damage rating of the wielder is increased by 1. +6302 Paragon's Damage Boost II 1 Buff Other 711 ParagonDamageRatingRaising 2 5400 Life Magic 70 The damage rating of the wielder is increased by 2. +6303 Paragon's Damage Boost III 1 Buff Other 711 ParagonDamageRatingRaising 3 5400 Life Magic 70 The damage rating of the wielder is increased by 3. +6304 Paragon's Damage Boost IV 1 Buff Other 711 ParagonDamageRatingRaising 4 5400 Life Magic 70 The damage rating of the wielder is increased by 4. +6305 Paragon's Damage Boost V 1 Buff Other 711 ParagonDamageRatingRaising 5 5400 Life Magic 70 The damage rating of the wielder is increased by 5. +6306 Paragon's Damage Reduction I 1 Buff Other 712 ParagonDamageReductionRatingRaising 1 5400 Life Magic 70 The damage reduction rating of the wielder is increased by 1. +6307 Paragon's Damage Reduction II 1 Buff Other 712 ParagonDamageReductionRatingRaising 2 5400 Life Magic 70 The damage reduction rating of the wielder is increased by 2. +6308 Paragon's Damage Reduction III 1 Buff Other 712 ParagonDamageReductionRatingRaising 3 5400 Life Magic 70 The damage reduction rating of the wielder is increased by 3. +6309 Paragon's Damage Reduction IV 1 Buff Other 712 ParagonDamageReductionRatingRaising 4 5400 Life Magic 70 The damage reduction rating of the wielder is increased by 4. +6310 Paragon's Damage Reduction V 1 Buff Other 712 ParagonDamageReductionRatingRaising 5 5400 Life Magic 70 The damage reduction rating of the wielder is increased by 5. +6311 Paragon's Mana I 1 Buff Other 705 ParagonManaRaising 2 5400 Life Magic 70 Increases maximum mana by 2 points. +6312 Paragon's Mana II 1 Buff Other 705 ParagonManaRaising 4 5400 Life Magic 70 Increases maximum mana by 4 points. +6313 Paragon's Mana III 1 Buff Other 705 ParagonManaRaising 6 5400 Life Magic 70 Increases maximum mana by 6 points. +6314 Paragon's Mana IV 1 Buff Other 705 ParagonManaRaising 8 5400 Life Magic 70 Increases maximum mana by 8 points. +6315 Paragon's Mana V 1 Buff Other 705 ParagonManaRaising 10 5400 Life Magic 70 Increases maximum mana by 10 points. +6316 Paragon's Stamina I 1 Buff Other 706 ParagonStaminaRaising 2 5400 Life Magic 70 Increases maximum stamina by 2 points. +6317 Paragon's Stamina II 1 Buff Other 706 ParagonStaminaRaising 4 5400 Life Magic 70 Increases maximum stamina by 4 points. +6318 Paragon's Stamina III 1 Buff Other 706 ParagonStaminaRaising 6 5400 Life Magic 70 Increases maximum stamina by 6 points. +6319 Paragon's Stamina IV 1 Buff Other 706 ParagonStaminaRaising 8 5400 Life Magic 70 Increases maximum stamina by 8 points. +6320 Ring of Skulls II 7 Projectile Other 641 NetherRing 300 -1 Void Magic 90 Shoots eight nether skulls outward from the caster. Each skull does 109-172 points of nether damage to the first thing it hits. +6321 Viridian Rise Recall 6 Utility Self 214 PortalSending 250 -1 Item Enchantment 150 Transports the target to the specified destination. +6322 Viridian Rise Great Tree Recall 6 Utility Self 214 PortalSending 250 -1 Item Enchantment 150 Transports the target to the specified destination. +6323 Gauntlet Imperil Self 8 Debuff Self 116 ArmorLowering 400 1800 Life Magic 80 Decreases the caster's natural armor by 300 points. +6324 Gauntlet Vulnerability Self 8 Debuff Self 110 FireVulnerability 400 1800 Life Magic 80 Increases damage the caster takes from Fire by 210%. +6325 Celestial Hand Stronghold Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 Sends the caster to the Stronghold of the Celestial Hand. +6326 Eldrytch Web Stronghold Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 Sends the caster to the Stronghold of the Eldrytch Web. +6327 Radiant Blood Stronghold Recall 4 Utility Self 214 PortalSending 150 -1 Item Enchantment 50 Sends the caster to the Stronghold of the Radiant Blood. +6328 Gauntlet Critical Damage Boost I 1 Buff Other 732 GauntletCriticalDamageRatingRaising 1 10800 Life Magic 70 Your critical damage rating is increased by 1. +6329 Gauntlet Critical Damage Boost II 1 Buff Other 732 GauntletCriticalDamageRatingRaising 1 10800 Life Magic 70 Your critical damage rating is increased by 2. +6330 Gauntlet Damage Boost I 1 Buff Other 729 GauntletDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 1. +6331 Gauntlet Damage Boost II 1 Buff Other 729 GauntletDamageRatingRaising 1 10800 Life Magic 70 Your damage rating is increased by 2. +6332 Gauntlet Damage Reduction I 1 Buff Other 728 GauntletDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 1. +6333 Gauntlet Damage Reduction II 1 Buff Other 728 GauntletDamageReductionRatingRaising 1 10800 Life Magic 70 Your damage reduction rating is increased by 2. +6334 Gauntlet Critical Damage Reduction I 1 Buff Other 733 GauntletCriticalDamageReductionRatingRaising 1 10800 Life Magic 70 Your critical damage reduction rating is increased by 1. +6335 Gauntlet Critical Damage Reduction II 1 Buff Other 733 GauntletCriticalDamageReductionRatingRaising 1 10800 Life Magic 70 Your critical damage reduction rating is increased by 2. +6336 Gauntlet Healing Boost I 1 Buff Other 730 GauntletHealingRatingRaising 1 10800 Life Magic 70 Your healing rating is increased by 1. +6337 Gauntlet Healing Boost II 1 Buff Other 730 GauntletHealingRatingRaising 1 10800 Life Magic 70 Your healing rating is increased by 2. +6338 Gauntlet Vitality I 1 Buff Other 731 GauntletVitalityRaising 1 10800 Life Magic 70 Your vitality is increased by 1. +6339 Gauntlet Vitality II 1 Buff Other 731 GauntletVitalityRaising 1 10800 Life Magic 70 Your vitality is increased by 2. +6340 Gauntlet Vitality III 1 Buff Other 731 GauntletVitalityRaising 1 10800 Life Magic 70 Your vitality is increased by 3. diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellDatabase.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellDatabase.cs index 3fd4e6c..94eb121 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellDatabase.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellDatabase.cs @@ -94,6 +94,24 @@ public static class SpellDatabase return $"Unknown Spell ({spellId})"; } + /// Spell family and difficulty (power). False when the spell isn't in SpellData.txt. + public static bool TryGetSpellMeta(int spellId, out int family, out int difficulty) + { + if (_spellMeta.TryGetValue(spellId, out var meta)) + { + family = meta.Category; + difficulty = meta.Power; + return true; + } + family = 0; + difficulty = 0; + return false; + } + + /// True when the spell id is in the embedded table or the built-in recall list. + public static bool HasSpell(int spellId) => + _spellNames.ContainsKey(spellId) || _builtinSpells.ContainsKey(spellId); + public static string GetSpellNameOrId(int spellId) { if (_spellNames.TryGetValue(spellId, out string? name)) return name; diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellManager.cs index ba6b58a..57e5802 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/SpellManager.cs @@ -120,6 +120,8 @@ public class SpellManager SpellDatabase.Load(msg => _host.WriteToChat(msg, 2)); SpellDictionary = SpellDatabase.BuildNameToIdMap(); _nameToIds = SpellDatabase.BuildNameToIdsMap(); + // ACECustom catalog: school/level/target for the Spells window and buff profiles. + SpellCatalog.EnsureLoaded(msg => _host.WriteToChat(msg, 2)); _host.WriteToChat($"[RynthAi] Magic System Online: {SpellDictionary.Count} spells loaded.", 1); } catch (Exception ex) @@ -330,6 +332,19 @@ public class SpellManager /// public bool IsKnownSpellId(int id) => _knownSpellIds.Contains(id); + /// The next RefreshKnownSpells reads the spellbook at once (a spell was just learned). + public void InvalidateKnownSpells() => _lastKnownRefreshUtc = DateTime.MinValue; + + /// + /// Copy of the known-spell snapshot for the render thread (the Spells window). Call it on the + /// pump thread: RefreshKnownSpells refills the live set in place there. + /// + public HashSet CopyKnownSpellIds() + { + RefreshKnownSpells(); + return new HashSet(_knownSpellIds); + } + /// /// Refresh the known-spell inventory from the engine's main-thread /// spellbook snapshot (host ReadKnownSpells). Throttled. Safe no-op if the diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/WeaponSwapTracker.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/WeaponSwapTracker.cs index 0f0c4b5..bf4e822 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/WeaponSwapTracker.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/WeaponSwapTracker.cs @@ -13,8 +13,13 @@ namespace RynthCore.Plugin.RynthAi; /// * Retry cap: a weapon that doesn't reach the hand after sends is /// rested for ; combat carries on with what's in hand (logged once). /// * No flip-flop: having swapped A → B, swapping back to A within -/// is held, and so is any swap once landed inside -/// . Combat keeps fighting with B. +/// for the same fight (the same forKey, the target) is held, and so is any swap once +/// landed inside . Combat keeps +/// fighting with B. A NEW target that wants A back gets it at once (2026-10-12, Drakkon: +/// Lightning Quadrelle for a Giant Maggot, then the next target, a Grub weak to Bludgeon, +/// was fought with the Quadrelle for 5-10 s until the 20 s dwell from the last swap ran out +/// - "he attacks for about 5 seconds with the wrong element weapon"). The window cap still +/// bounds a fight that alternates between two kinds of monster. /// internal sealed class WeaponSwapTracker { @@ -44,6 +49,7 @@ internal sealed class WeaponSwapTracker private readonly List _landed = new(); private int _lastFrom, _lastTo; private DateTime _lastLandedAt = DateTime.MinValue; + private int _askKey, _pendingKey, _lastKey; // the fight (target id) each swap was for; 0 = unknown /// The weapon a swap is in flight for (0 = none). public int PendingId => _pendingId; @@ -56,11 +62,13 @@ internal sealed class WeaponSwapTracker /// /// What to do about with in hand - /// (0 = nothing readable in hand). + /// (0 = nothing readable in hand). is the fight the weapon is + /// chosen for (the target id; 0 = unknown, treated as the same fight as the last swap). /// - public Step Next(int chosenId, int inHandId, DateTime now, Func? nameOf = null) + public Step Next(int chosenId, int inHandId, DateTime now, Func? nameOf = null, int forKey = 0) { HoldReason = ""; + _askKey = forKey; if (chosenId == 0) return Step.InHand; if (inHandId == chosenId) @@ -84,7 +92,8 @@ internal sealed class WeaponSwapTracker if (inHandId != 0) { - if (chosenId == _lastFrom && inHandId == _lastTo && (now - _lastLandedAt).TotalMilliseconds < MinDwellMs) + bool sameFight = forKey == 0 || _lastKey == 0 || forKey == _lastKey; + if (sameFight && chosenId == _lastFrom && inHandId == _lastTo && (now - _lastLandedAt).TotalMilliseconds < MinDwellMs) { HoldReason = "just swapped away from it"; return Step.Hold; @@ -102,6 +111,7 @@ internal sealed class WeaponSwapTracker /// A wield of was sent with in hand. public void Sent(int id, int fromId, DateTime now) { + _pendingKey = _askKey; // the fight the last Next was asked about _pendingId = id; _pendingFrom = fromId; _pendingAt = now; @@ -129,6 +139,7 @@ internal sealed class WeaponSwapTracker _landed.Clear(); _lastFrom = _lastTo = 0; _lastLandedAt = DateTime.MinValue; + _askKey = _pendingKey = _lastKey = 0; HoldReason = ""; Notice = null; } @@ -139,6 +150,7 @@ internal sealed class WeaponSwapTracker { _lastFrom = _pendingFrom; _lastTo = _pendingId; + _lastKey = _pendingKey; _lastLandedAt = now; _landed.Add(now); } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/WorldObjectCache.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/WorldObjectCache.cs index 7d4502c..e7f4bd0 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/WorldObjectCache.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/WorldObjectCache.cs @@ -1228,6 +1228,13 @@ public class WorldObjectCache : defaultValue; } + /// + /// True when ownership is readable and the object has neither a container nor a wielder, + /// so it lies loose in the world. Unreadable ownership is false (a pack item is never a ground drop). + /// + public bool IsOnGround(int id) + => TryGetOwnership(id, out int containerId, out int wielderId, out _) && containerId == 0 && wielderId == 0; + public int GetContainerId(int id) { if (!TryGetOwnership(id, out int containerId, out _, out _)) @@ -1780,6 +1787,42 @@ public class WorldObjectCache return result; } + /// + /// Items the client lists inside that the cache never + /// classified, looked up now (the indexer's lazy lookup files them) and returned. + /// is what already found. + /// An item whose create the cache never processed is otherwise invisible to corpse + /// looting: it isn't in the inventory or landscape sets, so it is never a candidate + /// and the corpse is finished without it (2026-10-11, Silentkelpie: a Necrolytic + /// Extract on a corpse with a Keep rule, left behind with no log line; the cache + /// reported it DELETE-BEFORE-CLASSIFY when the corpse went away). + /// + public List RescueContainedItems(int containerId, IReadOnlyCollection known) + { + var rescued = new List(); + if (containerId == 0 || !_host.HasGetContainerContents) return rescued; + + uint[] buf = new uint[256]; + int count; + try { count = _host.GetContainerContents(unchecked((uint)containerId), buf); } + catch { return rescued; } + if (count <= 0) return rescued; + + var have = new HashSet(); + foreach (var wo in known) have.Add(wo.Id); + + for (int i = 0; i < Math.Min(count, buf.Length); i++) + { + int id = unchecked((int)buf[i]); + if (id == 0 || have.Contains(id)) continue; + WorldObject? wo = this[id]; + if (wo == null) continue; + if (wo.ObjectClass == AcObjectClass.Corpse || wo.ObjectClass == AcObjectClass.Monster) continue; + rescued.Add(wo); + } + return rescued; + } + /// Enumerate landscape creatures (received health updates or TYPE_CREATURE). public IEnumerable GetLandscape() { diff --git a/Plugins/RynthCore.Plugin.RynthAi/CombatHookInterface.cs b/Plugins/RynthCore.Plugin.RynthAi/CombatHookInterface.cs new file mode 100644 index 0000000..578e4b3 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/CombatHookInterface.cs @@ -0,0 +1,475 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthAi; + +/// +/// The script-provided combat hook (Shared/RynthAiCombatApi.cs): who holds it, for which kinds, +/// until when, and one request slot per kind. Static, like the interface table that serves it, +/// so it survives a re-Init of the plugin instance; everything runs on the plugin pump thread. +/// +/// RynthAi asks (CombatManager.AttackWithMagic for an attack, BuffManager.CheckVitals for a heal) +/// with : the first call opens a request and says Wait; later calls say Wait +/// until the answer is in (Decided), the answer is a decline (Native), or the deadline passes +/// (Native). The hook is active only while its lease is live, so a script plugin that stops +/// renewing (unloaded, crashed, stopped) leaves RynthAi native within one lease. +/// +internal static class CombatHook +{ + /// What a consumer does this tick. + internal enum Outcome { Native, Wait, Decided } + + /// One kind's request slot. + internal sealed class Slot + { + public readonly uint Kind; + public Slot(uint kind) => Kind = kind; + + public bool Open; + public CombatRequestV1 Request; + public bool Decided; + public uint DecidedSpell, DecidedTarget, DecidedFlags; + + // The last decision consumed (handed back in the next request). + public uint LastSeq, LastSpell, LastTarget; + public long LastAtMs; + // The cast in flight (PendingSpell 0 = none), with the UseDone count at its send, and the + // most recent resolved cast with its final answer (ResolvedErr -1 = none could be read). + public uint PendingSeq, PendingSpell, PendingTarget; + public long PendingAtMs; + public int PendingSeqAtSend = -1; + // The UseDone count that answers it: one more than its send count, or than the answer of the + // cast still in flight before it (both kinds, in send order); -1 = unknown (time limit only). + public int PendingExpectSeq = -1; + public uint ResolvedSeq, ResolvedSpell, ResolvedTarget; + public long ResolvedAtMs; + public int ResolvedErr = -1; + + /// The cast in flight is done: its answer (-1 = none read). + public void Resolve(int err) + { + if (PendingSpell == 0) return; + ResolvedSeq = PendingSeq; ResolvedSpell = PendingSpell; ResolvedTarget = PendingTarget; + ResolvedAtMs = PendingAtMs; ResolvedErr = err; + PendingSeq = PendingSpell = PendingTarget = 0; PendingAtMs = 0; PendingSeqAtSend = -1; PendingExpectSeq = -1; + InFlight.Remove(this); + } + + // Counters for /ra combat and the tests. + public int Opened, Casts, Declines, Timeouts, Rejects; + public long LastTimeoutLogMs = long.MinValue; + public long LastRejectLogMs = long.MinValue; + + public void Reset() + { + Open = false; Decided = false; Request = default; + DecidedSpell = DecidedTarget = DecidedFlags = 0; + LastSeq = LastSpell = LastTarget = 0; LastAtMs = 0; + PendingSeq = PendingSpell = PendingTarget = 0; PendingAtMs = 0; PendingSeqAtSend = -1; PendingExpectSeq = -1; + InFlight.Remove(this); + ResolvedSeq = ResolvedSpell = ResolvedTarget = 0; ResolvedAtMs = 0; ResolvedErr = -1; + Opened = Casts = Declines = Timeouts = Rejects = 0; + LastTimeoutLogMs = LastRejectLogMs = long.MinValue; + } + } + + /// Milliseconds clock (Environment.TickCount64; the host tests replace it). + internal static Func Clock = static () => Environment.TickCount64; + internal static long Now => Clock(); + + /// + /// The last UseDone (count, error), or null when the engine can't say: RynthAi sets it at Init. A + /// cast's answer is the first UseDone after its send (ctx.last.err). + /// + internal static Func<(int Seq, uint Err)?>? LastUseDone; + + // The casts in flight of both kinds, in send order: the UseDones answer them in that order. + private static readonly List InFlight = new(2); + + /// + /// Resolves the casts in flight (each tick, at Poll, and before the next cast goes out), in send + /// order: each one's answer is the UseDone after its send, or after the answer of the cast sent + /// before it (an attack and a heal both in flight). A later count with that one unseen, or no + /// UseDone within RynthAiCombat.ResolveTimeoutMs, resolves it with no answer (-1). + /// + public static void ObserveUseDone() + { + if (InFlight.Count == 0) return; + (int Seq, uint Err)? last; + try { last = LastUseDone?.Invoke(); } catch { last = null; } + long now = Now; + for (int i = 0; i < InFlight.Count;) + { + Slot s = InFlight[i]; + if (last is { } u && s.PendingExpectSeq >= 0 && u.Seq >= s.PendingExpectSeq) + { + s.Resolve(u.Seq == s.PendingExpectSeq ? unchecked((int)u.Err) : -1); // removes it + continue; + } + if (now - s.PendingAtMs >= RynthAiCombat.ResolveTimeoutMs) { s.Resolve(-1); continue; } + i++; + } + } + /// A timeout is logged at most this often per kind. + internal const long TimeoutLogIntervalMs = 60_000; + private const long RejectLogIntervalMs = 5_000; + /// A request this long past its deadline when RynthAi next asks is dropped and asked again. + internal const long StaleGraceMs = 1_000; + + public static string Owner { get; private set; } = ""; + public static uint Kinds { get; private set; } + public static long LeaseUntilMs { get; private set; } + public static uint AttackTimeoutMs { get; private set; } = RynthAiCombat.DefaultAttackTimeoutMs; + public static uint HealTimeoutMs { get; private set; } = RynthAiCombat.DefaultHealTimeoutMs; + + public static readonly Slot Attack = new(RynthAiCombat.KindAttack); + public static readonly Slot Heal = new(RynthAiCombat.KindHeal); + + private static uint _seq; + + /// Forget everything (plugin shutdown, host tests). + public static void Reset() + { + Owner = ""; + Kinds = 0; + LeaseUntilMs = 0; + AttackTimeoutMs = RynthAiCombat.DefaultAttackTimeoutMs; + HealTimeoutMs = RynthAiCombat.DefaultHealTimeoutMs; + Attack.Reset(); + Heal.Reset(); + _seq = 0; + } + + public static Slot? SlotFor(uint kind) => kind == RynthAiCombat.KindAttack ? Attack : kind == RynthAiCombat.KindHeal ? Heal : null; + + /// True while is held and the lease is live. + public static bool IsActive(uint kind) => (Kinds & kind) != 0 && Now < LeaseUntilMs; + + private static bool LeaseLive => Kinds != 0 && Now < LeaseUntilMs; + + /// Takes or renews the hook. Returns the kinds granted (0 = another owner's lease is live). + public static uint Claim(uint kinds, uint leaseMs, uint attackTimeoutMs, uint healTimeoutMs, string owner) + { + owner = (owner ?? "").Trim(); + if (owner.Length > RynthAiCombat.MaxOwnerLength) owner = owner.Substring(0, RynthAiCombat.MaxOwnerLength); + kinds &= RynthAiCombat.KindsAll; + long now = Now; + bool live = LeaseLive; + if (live && !string.Equals(Owner, owner, StringComparison.Ordinal)) return 0; + + // Kinds this owner no longer claims: their open requests are dropped (native that tick). + uint dropped = live ? Kinds & ~kinds : RynthAiCombat.KindsAll; + if ((dropped & RynthAiCombat.KindAttack) != 0) Cancel(Attack); + if ((dropped & RynthAiCombat.KindHeal) != 0) Cancel(Heal); + + if (kinds == 0) + { + Owner = ""; + Kinds = 0; + LeaseUntilMs = 0; + return 0; + } + Owner = owner; + Kinds = kinds; + LeaseUntilMs = now + RynthAiCombat.ClampLease(leaseMs); + AttackTimeoutMs = RynthAiCombat.ClampTimeout(attackTimeoutMs, RynthAiCombat.DefaultAttackTimeoutMs); + HealTimeoutMs = RynthAiCombat.ClampTimeout(healTimeoutMs, RynthAiCombat.DefaultHealTimeoutMs); + return kinds; + } + + /// Drops now; their open requests are cancelled. + public static void Release(uint kinds) + { + kinds &= RynthAiCombat.KindsAll; + if ((kinds & RynthAiCombat.KindAttack) != 0) Cancel(Attack); + if ((kinds & RynthAiCombat.KindHeal) != 0) Cancel(Heal); + Kinds &= ~kinds; + if (Kinds == 0) { Owner = ""; LeaseUntilMs = 0; } + } + + /// 1 when a request of is open and unanswered (copied to ). + public static bool Poll(uint kind, out CombatRequestV1 request) + { + request = default; + Slot? s = SlotFor(kind); + if (s == null || !IsActive(kind) || !s.Open || s.Decided || Now > s.Request.DeadlineMs) return false; + request = s.Request; + request.LastSeq = s.LastSeq; + request.LastSpell = s.LastSpell; + request.LastTarget = s.LastTarget; + request.LastAtMs = s.LastAtMs; + ObserveUseDone(); + request.ResolvedSeq = s.ResolvedSeq; + request.ResolvedSpell = s.ResolvedSpell; + request.ResolvedTarget = s.ResolvedTarget; + request.ResolvedAtMs = s.ResolvedAtMs; + request.ResolvedErr = s.ResolvedSpell != 0 ? s.ResolvedErr : -1; + request.PendingSeq = s.PendingSeq; + request.PendingSpell = s.PendingSpell; + request.PendingTarget = s.PendingTarget; + request.PendingAtMs = s.PendingAtMs; + return true; + } + + /// The answer to request . False = stale. + public static bool Decide(uint seq, uint kind, uint spellId, uint targetId, uint flags) + { + Slot? s = SlotFor(kind); + if (s == null || !IsActive(kind) || !s.Open || s.Decided || s.Request.Seq != seq || Now > s.Request.DeadlineMs) return false; + s.Decided = true; + s.DecidedSpell = spellId; + s.DecidedTarget = targetId; + s.DecidedFlags = flags; + return true; + } + + private static void Cancel(Slot s) + { + s.Open = false; + s.Decided = false; + } + + /// + /// One consumer step for . is what the request + /// is about (the attack target; for a heal the fight target, informational, 0 when none): an open + /// attack request about another target is dropped and a fresh one opened; a heal request is not. fills a new request's context (RynthAi's + /// view of the fight); Seq, Kind, TargetId and the times are set here. + /// + public static Outcome Step(Slot slot, uint forTarget, Func build, Action? log, + out uint spellId, out uint targetId, out uint flags) + { + spellId = targetId = flags = 0; + if (!IsActive(slot.Kind)) + { + Cancel(slot); + return Outcome.Native; + } + long now = Now; + // An attack about another target: the target moved on, ask afresh. A heal's target is only + // informational (the fight target), so a heal request keeps its deadline when the fight + // target changes; restarting it would let a target swap every few hundred ms hold the + // heal past its 750 ms deadline for ever. Its answer is still checked against the targets + // as they are when it comes (BuffManager.ScriptHealProblem). + if (slot.Open && slot.Kind == RynthAiCombat.KindAttack && slot.Request.TargetId != forTarget) Cancel(slot); + // RynthAi stopped asking for a while (its gates held the cast, or health came back over the + // line): an answer, or a missing one, from back then is stale. Ask afresh, no timeout counted. + if (slot.Open && now > slot.Request.DeadlineMs + StaleGraceMs) Cancel(slot); + + if (!slot.Open) + { + CombatRequestV1 r = build(); + r.StructSize = (uint)Unsafe.SizeOf(); + if (++_seq == 0) _seq = 1; + r.Seq = _seq; + r.Kind = slot.Kind; + r.TargetId = forTarget; + r.IssuedAtMs = now; + r.DeadlineMs = now + (slot.Kind == RynthAiCombat.KindAttack ? AttackTimeoutMs : HealTimeoutMs); + slot.Request = r; + slot.Open = true; + slot.Decided = false; + slot.Opened++; + return Outcome.Wait; + } + + if (slot.Decided) + { + if (slot.DecidedSpell == 0) + { + Consume(slot, 0, 0); + slot.Declines++; + return Outcome.Native; + } + spellId = slot.DecidedSpell; + targetId = slot.DecidedTarget; + flags = slot.DecidedFlags; + return Outcome.Decided; // the consumer validates, then Cast or Reject + } + + if (now > slot.Request.DeadlineMs) + { + Cancel(slot); + slot.Timeouts++; + if (slot.LastTimeoutLogMs == long.MinValue || now - slot.LastTimeoutLogMs >= TimeoutLogIntervalMs) + { + slot.LastTimeoutLogMs = now; + log?.Invoke($"[CombatHook] {RynthAiCombat.KindNames(slot.Kind)} request {slot.Request.Seq} unanswered after " + + $"{slot.Request.DeadlineMs - slot.Request.IssuedAtMs} ms ('{Owner}'): RynthAi chose instead " + + $"({slot.Timeouts} timeout(s) so far; logged at most once a minute)"); + } + return Outcome.Native; + } + return Outcome.Wait; + } + + /// + /// The decided spell went out (or was waited on): the request is done. + /// is the UseDone count read just before the send (ActionPacer.LastCastSeqAtSend); -1 reads the + /// last UseDone now instead. + /// + public static void Cast(Slot slot, uint spellId, uint targetId, int seqAtSend = -1) + { + Consume(slot, spellId, targetId, seqAtSend); + if (spellId != 0) slot.Casts++; // 0: handled without a cast (a wand swap step in flight) + } + + /// The decided spell failed RynthAi's checks: the request is done, RynthAi chooses. + public static void Reject(Slot slot, string why, Action? log) + { + uint seq = slot.Request.Seq, spell = slot.DecidedSpell, target = slot.DecidedTarget; + Consume(slot, 0, 0); + slot.Rejects++; + long now = Now; + if (slot.LastRejectLogMs == long.MinValue || now - slot.LastRejectLogMs >= RejectLogIntervalMs) + { + slot.LastRejectLogMs = now; + log?.Invoke($"[CombatHook] {RynthAiCombat.KindNames(slot.Kind)} request {seq}: spell {spell} at 0x{target:X8} rejected ({why}); RynthAi chose instead"); + } + } + + private static void Consume(Slot slot, uint spellId, uint targetId, int seqAtSend = -1) + { + slot.LastSeq = slot.Request.Seq; + slot.LastSpell = spellId; + slot.LastTarget = targetId; + slot.LastAtMs = Now; + if (spellId != 0) + { + // The cast before it resolves first (its answer if one came, else none). + ObserveUseDone(); + slot.Resolve(-1); + slot.PendingSeq = slot.Request.Seq; + slot.PendingSpell = spellId; + slot.PendingTarget = targetId; + slot.PendingAtMs = slot.LastAtMs; + // The count read before the send: a UseDone that lands between the send and this call is + // then still this cast's answer, not taken as the baseline. + if (seqAtSend >= 0) slot.PendingSeqAtSend = seqAtSend; + else try { slot.PendingSeqAtSend = LastUseDone?.Invoke()?.Seq ?? -1; } catch { slot.PendingSeqAtSend = -1; } + Slot? before = InFlight.Count > 0 ? InFlight[InFlight.Count - 1] : null; + if (slot.PendingSeqAtSend < 0) slot.PendingExpectSeq = -1; + else if (before != null && before.PendingExpectSeq < 0) slot.PendingExpectSeq = -1; // can't tell which answer is whose + else slot.PendingExpectSeq = Math.Max(slot.PendingSeqAtSend, before?.PendingExpectSeq ?? int.MinValue) + 1; + InFlight.Add(slot); + } + slot.Open = false; + slot.Decided = false; + } + + /// One line for /ra combat. + public static string Describe() + { + long now = Now; + bool live = LeaseLive; + string head = live + ? $"hook: '{Owner}' holds {RynthAiCombat.KindNames(Kinds)} (lease {Math.Max(0, LeaseUntilMs - now) / 1000.0:0.0}s)" + : "hook: none (RynthAi chooses every spell)"; + static string S(Slot s) => $"{s.Opened} asked, {s.Casts} cast, {s.Declines} declined, {s.Timeouts} timed out, {s.Rejects} rejected" + + (s.Open ? $", request {s.Request.Seq} open" : ""); + return $"{head} attack: {S(Attack)} heal: {S(Heal)}"; + } +} + +/// +/// RynthAi's side of the "RynthAi.Combat" interface: the table RynthPluginQueryInterface hands +/// out, and the functions behind it (pump thread, current plugin instance). +/// +internal static unsafe class CombatHookInterface +{ + private static RynthAiCombatApiV1* _table; + + public static IntPtr Query(string iface, uint version) + { + if (iface != RynthAiCombatApiV1.InterfaceName || version == 0 || version > RynthAiCombatApiV1.InterfaceVersion) return IntPtr.Zero; + if (_table == null) + { + var t = (RynthAiCombatApiV1*)NativeMemory.AllocZeroed((nuint)sizeof(RynthAiCombatApiV1)); + t->Version = RynthAiCombatApiV1.InterfaceVersion; + t->StructSize = (uint)sizeof(RynthAiCombatApiV1); + t->Claim = &Claim; + t->Release = &Release; + t->Poll = &Poll; + t->Decide = &Decide; + t->GetScanned = &GetScanned; + _table = t; + } + return (IntPtr)_table; + } + + /// Frees the table and drops the hook (plugin shutdown). Callers resolve it every tick. + public static void Shutdown() + { + var t = _table; + _table = null; + if (t != null) NativeMemory.Free(t); + CombatHook.Reset(); + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int Claim(uint kinds, uint leaseMs, uint attackTimeoutMs, uint healTimeoutMs, byte* owner) + { + try + { + string name = owner == null ? "" : Marshal.PtrToStringUTF8((IntPtr)owner) ?? ""; + return (int)CombatHook.Claim(kinds, leaseMs, attackTimeoutMs, healTimeoutMs, name); + } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static void Release(uint kinds) + { + try { CombatHook.Release(kinds); } catch { } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int Poll(uint kind, CombatRequestV1* req) + { + try + { + if (req == null || !CombatHook.Poll(kind, out CombatRequestV1 r)) return 0; + uint room = req->StructSize; + uint size = (uint)sizeof(CombatRequestV1); + if (room == 0 || room > size) room = size; // an older caller passes less; never write past it + r.StructSize = room; + Buffer.MemoryCopy(&r, req, room, room); + return 1; + } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int Decide(uint seq, uint kind, uint spellId, uint targetId, uint flags) + { + try { return CombatHook.Decide(seq, kind, spellId, targetId, flags) ? 1 : 0; } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int GetScanned(uint* ids, float* distances, int capacity) + { + try { return PluginExports.Runtime.Plugin?.CombatHookScanned(ids, distances, capacity) ?? 0; } + catch { return 0; } + } +} + +public sealed partial class RynthAiPlugin +{ + /// RynthAi.Combat GetScanned: the combat scan list, nearest first as scanned. + internal unsafe int CombatHookScanned(uint* ids, float* distances, int capacity) + { + var list = _combatManager?.ScannedTargets; + if (list == null) return 0; + int n = list.Count; + if (ids != null) + for (int i = 0; i < n && i < capacity; i++) + { + ids[i] = unchecked((uint)list[i].Id); + if (distances != null) distances[i] = (float)list[i].Distance; + } + return n; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs b/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs index f2049d8..316c846 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs @@ -40,13 +40,23 @@ public sealed partial class RynthAiPlugin private readonly Dictionary _corpseAbandonCounts = new(); private const int NeverOpenedAbandonRetryMs = 30_000; private readonly HashSet _ownershipSkipLogged = new(); - private readonly HashSet _corpseIdRequested = new(); // corpses whose LongDesc ID was already requested + private readonly HashSet _corpseIdRequested = new(); // corpses whose LongDesc ID request the engine ACCEPTED + private readonly Dictionary _corpseIdAskedAt = new(); // ActionPacer.NowMs of the newest accepted request, for the re-ask + private readonly Dictionary _corpseIdRefusedAt = new(); // ActionPacer.NowMs of the newest REFUSED request + private const long CorpseIdRefusedRetryMs = 250; // a refused request is retried no faster than this, per corpse + private const int CorpseIdPerTick = 2; // new accepted requests per scan tick (the refusal window ending must not burst) + private int _corpseIdAcceptedThisTick; + private long _corpseIdBudgetAt; // when the budget last started over (a scan tick, or CorpseIdRefusedRetryMs without one) + private const long CorpseIdReaskMs = 3000; // no appraisal data this long after an accepted request: ask once more private int _busyCount; private long _busyCountLastIncrementAt; private long _busyCountBecamePositiveAt; // when count first went 0→positive private const long BUSY_TIMEOUT_MS = 10_000; // safety: force-clear if stuck >10s private const long NameWaitMs = 3_000; // extra wait past the assess window for a corpse item's name private const long AppraisalWaitMs = 3_000; // extra wait past the assess window for an item's appraisal + private const long ContentsSweepMs = 500; // how often an open corpse's contents are checked for items the cache missed + private long _lastContentsSweepAt; + private int _lastContentsSweepCorpse; private const long AppraisalHoldTimeoutMarginMs = 1_000; // stop holding this long before the corpse timeout // Wedge detection: when AC's item-action state locks up (server-side, e.g. @@ -100,6 +110,25 @@ public sealed partial class RynthAiPlugin private long _currentLootItemStillSince; private long _currentLootItemLeftAt; private bool _currentLootItemSawAnim; + private bool _currentLootItemStackable; // a stack at send: it may merge into a pack stack and vanish + private bool _currentLootItemPipelined; // sent while the last pickup's Return played (ACE queues it) + private int _currentLootItemErrSeqAtSend; // TryGetLastWeenieError seq at the send (0 = unknown) + private int _currentLootItemFreeRetries; // resends after a too-busy answer (not counted as attempts) + // The last answered pickup, until the character has finished its "Return" (stood up again). + // The corpse/chest is closed only after this (2026-10-07), and the next move may go out while + // it plays: ACE queues a move that arrives during the Return as its NextPickup. + private int _settlingLootItemId; + private int _settlingContainerId; + private long _settlingSince; + private bool _settlingSawAnim; + private bool _settlingAllowsPipeline; + private int _pipelinedAfterItemId; // the answered pickup a move was already queued behind + // [LootEval] lines: one per item per open (a matched item was re-printed before every pickup). + private readonly Dictionary _lootEvalLogged = new(); + private int _manaStoneCapLoggedFor; // container the "ManaStone count for cap check" line was logged for + private int _manaStoneLiveCount; + private long _manaStoneLiveCountAt; + private const long ManaStoneLiveCountMs = 200; private long _pickupAnimSince; private string _currentLootItemActionLabel = string.Empty; private string _currentLootItemName = string.Empty; @@ -341,7 +370,11 @@ public sealed partial class RynthAiPlugin Log($"[RynthAi] Pruned _ownershipSkipLogged"); } if (_corpseIdRequested.Count > 200) + { _corpseIdRequested.Clear(); + _corpseIdAskedAt.Clear(); + _corpseIdRefusedAt.Clear(); + } if (_corpseSkipLogged.Count > 200) _corpseSkipLogged.Clear(); if (_corpseWaitingSince.Count > 200) @@ -367,9 +400,15 @@ public sealed partial class RynthAiPlugin { // Non-corpse container (chest, bag, etc.) — queue a loot-check once inventory arrives. _pendingLootCheckContainerId = sid; + // And a chest to loot, if it turns out eligible (RynthAiPlugin.ChestLoot.cs). + NoteContainerOpened(sid); return; } + // A corpse opened while a chest was the loot container: the server closed the chest. + if (_lootChestId != 0 && _lootChestId != sid) + _lootChestId = 0; + // _completedCorpses is authoritative. On an engine without CloseContainer (API // before v76) a looted corpse stays open server-side, so AC re-announces its // contents every time it re-streams into range on a patrol loop. Treat any reopen of a completed @@ -431,6 +470,9 @@ public sealed partial class RynthAiPlugin if (_pendingLootCheckContainerId != 0 && sid == _pendingLootCheckContainerId) { _pendingLootCheckContainerId = 0; + // A chest the looter takes: it logs and says per item what it does. + if (ChestLooterTakesContainer(sid)) + return; if (_objectCache != null) { foreach (WorldObject item in _objectCache.GetContainedItems(sid)) @@ -460,6 +502,9 @@ public sealed partial class RynthAiPlugin int sid = unchecked((int)objectId); if (_pendingLootCheckContainerId == sid) _pendingLootCheckContainerId = 0; + // A chest: closed by the player, the server (walked away) or our own close. Never reopened. + if (OnChestGone(sid, "was closed")) + return; bool wasOpenCorpse = _openedContainerId == sid; if (_openedContainerId == sid) { @@ -522,11 +567,14 @@ public sealed partial class RynthAiPlugin return; SyncCorpseContainerState(); + TickDeferredClose(settings); + TakeLootThisRequest(settings); // /ra lootthis (RynthAiPlugin.VTankHotkeys.cs) // ── Macro off / looting disabled / nav-boost — full stop and reset ── // Must come before the Buffing check so that turning off the macro always // clears motion state (smooth turns, autorun) set during corpse approach. - if (!settings.IsMacroRunning || !settings.EnableLooting || settings.BoostNavPriority) + // A container flagged with /ra lootthis is looted anyway (only that one). + if ((!settings.IsMacroRunning || !settings.EnableLooting || settings.BoostNavPriority) && !ForcedLootHolds()) { ResetCorpseTarget(); return; @@ -563,6 +611,7 @@ public sealed partial class RynthAiPlugin && _openedContainerId == 0) { LogCorpsesHeldByCombat(); + LogChestHeldByCombat(); FreezeCorpseTimeout(CorpseNowMs); return; // Keep our target, just wait — don't ResetCorpseTarget } @@ -585,6 +634,10 @@ public sealed partial class RynthAiPlugin return; } + // A chest the player or a meta opened: looted where it stands (RynthAiPlugin.ChestLoot.cs). + if (_targetCorpseId == 0 && _chestCandidateId != 0 && TryTakeOpenChest(settings, CorpseNowMs)) + return; + double maxMeters = GetCorpseApproachRangeMaxMeters(settings); double minMeters = GetCorpseApproachRangeMinMeters(settings, maxMeters); if (maxMeters <= 0.25) @@ -599,16 +652,25 @@ public sealed partial class RynthAiPlugin if (IsLootingBlockedByPack(settings) && !OwnCorpseBypassesPackGate(settings, maxMeters)) return; - if (!TryFindNearestCorpse(maxMeters, out WorldObject? corpse, out _)) + // A ground pickup already sent finishes before a corpse is claimed. + if (GroundPickupInFlight) { - // No corpses in range. STEP 4: nothing to release. The "Looting" - // string used to be held here from a just-completed corpse and - // had to be handed back so nav could resume; now HasLootWork - // simply stops returning true and the arbiter moves on by itself - // on the next tick. + TickGroundLoot(settings, maxMeters); return; } + if (!TryFindNearestCorpse(maxMeters, out WorldObject? corpse, out _)) + { + // No corpses in range. Loose ground items that match the loot profile + // get their turn here; HasLootWork keeps Looting while any remain. + TickGroundLoot(settings, maxMeters); + return; + } + + // A corpse outranks an unsent ground claim. + if (_groundTargetId != 0) + ResetGroundLoot(clearCaches: false); + if (corpse == null) return; @@ -695,6 +757,20 @@ public sealed partial class RynthAiPlugin FreezeCorpseTimeout(now); return; } + // The salvage panel is opening (UST used, execute not sent yet): the client would swallow + // the use (SalvageManager.PanelPending). Wait, with the claim's timeout clock stopped (this + // sits before the freeze reset below so the frozen age carries across held ticks). + if (_salvageManager?.PanelPending == true) + { + FreezeCorpseTimeout(now); + if (!_openHeldBySalvageLogged) + { + _openHeldBySalvageLogged = true; + LootDiag($"[RynthAi] Corpse loot: open of 0x{(uint)_targetCorpseId:X8} waits for the salvage panel (UST used, salvage not sent yet)."); + } + return; + } + _openHeldBySalvageLogged = false; _corpseHoldFrozenAge = -1; // One server action at a time (2026-10-06, ActionPacer): no open while the server is still @@ -761,6 +837,7 @@ public sealed partial class RynthAiPlugin } private long _corpseOpenBusyWaitSince; + private bool _openHeldBySalvageLogged; // Peace before the open: one request per claimed corpse, only with no monster within // LootStarveCloseYards (the same test that gives looting its turn while combat still has a @@ -768,6 +845,8 @@ public sealed partial class RynthAiPlugin private const long PeaceBeforeOpenMaxMs = 2500; private int _peaceBeforeOpenFor; private long _peaceBeforeOpenSince; + /// The peace request for _peaceBeforeOpenFor was accepted by the engine (a refusal is retried). + private bool _peaceSent; /// True while the open should wait for the peace-mode swap it just asked for. private bool WantsPeaceBeforeOpen(LegacyUiSettings settings, long now) @@ -781,10 +860,13 @@ public sealed partial class RynthAiPlugin if (_peaceBeforeOpenFor != _targetCorpseId) { _peaceBeforeOpenFor = _targetCorpseId; - _peaceBeforeOpenSince = now; - Host.ChangeCombatModeFor(CombatMode.NonCombat, "Loot", "peace before opening the corpse (Peace Mode When Idle)"); - return true; + _peaceBeforeOpenSince = now; // the ceiling counts from the first ask + _peaceSent = false; } + // One accepted request per corpse. A refusal (the engine turns stance changes away around a + // teleport) or a pacing hold is asked again on the next call, inside the same ceiling. + if (!_peaceSent) + _peaceSent = Host.ChangeCombatModeFor(CombatMode.NonCombat, "Loot", "peace before opening the corpse (Peace Mode When Idle)"); return now - _peaceBeforeOpenSince < PeaceBeforeOpenMaxMs; } // Wait for busy to genuinely clear before opening the next corpse. The backstop @@ -894,6 +976,38 @@ public sealed partial class RynthAiPlugin return EvaluateCorpseLootDecision(corpse).ShouldLoot; } + /// + /// Asks the engine to identify a corpse so its LongDesc (the killer name) arrives. Only a request the + /// engine accepted counts: it refuses RequestId around a teleport or a death and drops stale queued + /// requests, so a refused or dropped one is asked again. A refused one is retried every + /// CorpseIdRefusedRetryMs; an accepted one with no data is asked again every CorpseIdReaskMs, and only for + /// the corpse the bot is targeting or has open (any other corpse in range gets one accepted request, not a + /// stream). At most CorpseIdPerTick requests are accepted per scan tick, so a refusal window ending with + /// many uncached corpses in range does not burst. No give-up cap. + /// + private void TryRequestCorpseId(WorldObject corpse, string longDesc) + { + if (!string.IsNullOrWhiteSpace(longDesc) || !Host.HasRequestId) return; + long idNow = ActionPacer.NowMs(); + if (idNow - _corpseIdBudgetAt >= CorpseIdRefusedRetryMs) { _corpseIdAcceptedThisTick = 0; _corpseIdBudgetAt = idNow; } // evaluations outside a scan must not exhaust it for good + bool candidate = corpse.Id == _targetCorpseId || (_openedContainerId != 0 && corpse.Id == _openedContainerId); + bool due = !_corpseIdRequested.Contains(corpse.Id) + || (candidate && _corpseIdAskedAt.TryGetValue(corpse.Id, out long askedAt) && idNow - askedAt >= CorpseIdReaskMs); + if (!due || _corpseIdAcceptedThisTick >= CorpseIdPerTick) return; + if (_corpseIdRefusedAt.TryGetValue(corpse.Id, out long refusedAt) && idNow - refusedAt < CorpseIdRefusedRetryMs) return; + if (Host.RequestId(unchecked((uint)corpse.Id))) + { + _corpseIdRequested.Add(corpse.Id); + _corpseIdAskedAt[corpse.Id] = idNow; + _corpseIdRefusedAt.Remove(corpse.Id); + _corpseIdAcceptedThisTick++; + } + else + { + _corpseIdRefusedAt[corpse.Id] = idNow; + } + } + private CorpseLootDecision EvaluateCorpseLootDecision(WorldObject? corpse) { var settings = _dashboard?.Settings; @@ -913,9 +1027,7 @@ public sealed partial class RynthAiPlugin // Corpse LongDesc is only available after the object is identified. // Request ID so the killer name is populated for the next check. - if (string.IsNullOrWhiteSpace(longDesc) && Host.HasRequestId && _corpseIdRequested.Add(corpse.Id)) - Host.RequestId(unchecked((uint)corpse.Id)); - + TryRequestCorpseId(corpse, longDesc); string killerName = ExtractCorpseKillerName(longDesc) ?? string.Empty; string myName = GetPlayerNameForLootOwnership(); bool inFellowship = _fellowshipTracker?.IsInFellowship == true; @@ -1189,6 +1301,21 @@ public sealed partial class RynthAiPlugin long openAge = now - _openedContainerAt; + // A pickup in flight: only its answer is looked at (one ownership read), not the whole + // container. The snapshot below scans every object the cache knows with an ownership + // probe each and refreshes every item's identity - for a 100-item chest that ran on + // every tick of every pickup. A move is only ever sent after the contents were seen, + // so the observed-inventory gate below has already passed. + if (_currentLootItemMovePending && _openedContainerInventoryObservedAt != 0) + { + TickPendingCorpsePickup(settings); + if (_currentLootItemMovePending) + return; // Still waiting for this pickup's answer + if (_openedContainerId != corpseId) + return; // the retry finished or paused the corpse (no pack had room) + now = CorpseNowMs; + } + // Snapshot the corpse's contents ONCE per tick and reuse it everywhere below. // GetContainedItems scans the entire landscape+inventory set (200+ objects) with // a native ownership probe per object; this path used to call it up to 3× per tick @@ -1199,6 +1326,24 @@ public sealed partial class RynthAiPlugin for (int i = 0; i < containedItems.Count; i++) containedItems[i] = _objectCache.RefreshIdentity(containedItems[i]); + // Items the client has inside the corpse that the cache never classified (no create + // processed for them) are not in containedItems at all, so they were never judged + // and the corpse was finished without them. Ask the client what the corpse holds, + // at most every ContentsSweepMs, and look the missing ones up. + if (now - _lastContentsSweepAt >= ContentsSweepMs || _lastContentsSweepCorpse != corpseId) + { + _lastContentsSweepAt = now; + _lastContentsSweepCorpse = corpseId; + List missed = _objectCache.RescueContainedItems(corpseId, containedItems); + if (missed.Count > 0) + { + foreach (WorldObject wo in missed) + containedItems.Add(_objectCache.RefreshIdentity(wo)); + LootDiag($"[RynthAi] Corpse loot: found {missed.Count} item(s) on 0x{(uint)corpseId:X8} the object cache had missed: " + + string.Join(", ", missed.Select(w => $"0x{(uint)w.Id:X8} '{w.Name}' {w.ObjectClass}")) + "."); + } + } + // Fast path: items for this corpse are already in the cache. AC's CreateObject // burst populates the corpse's contents during the landscape sweep that precedes // the ViewContents packet, so OnUpdateObjectInventory effectively never fires for @@ -1207,7 +1352,7 @@ public sealed partial class RynthAiPlugin if (_openedContainerInventoryObservedAt == 0 && containedItems.Count > 0) { _openedContainerInventoryObservedAt = now; - LootDiag($"[RynthAi] Corpse loot: cache pre-populated for 0x{(uint)corpseId:X8} at {openAge}ms; skipping inv-wait."); + LootDiag($"[RynthAi] {LootTag}: cache pre-populated for 0x{(uint)corpseId:X8} at {openAge}ms; skipping inv-wait."); } else { @@ -1221,7 +1366,7 @@ public sealed partial class RynthAiPlugin if (openAge < Math.Max(300, settings.LootEmptyCorpseMs)) return; _openedContainerInventoryObservedAt = _openedContainerAt; - LootDiag($"[RynthAi] Corpse loot: no inventory update for 0x{(uint)corpseId:X8}; probing after {openAge}ms."); + LootDiag($"[RynthAi] {LootTag}: no inventory update for 0x{(uint)corpseId:X8}; probing after {openAge}ms."); } } @@ -1254,6 +1399,8 @@ public sealed partial class RynthAiPlugin { _corpseIdsRequested = true; _corpseIdsRequestedAt = now; + _lootEvalLogged.Clear(); + _manaStoneCapLoggedFor = 0; int requested = 0; int preClassified = 0; @@ -1287,13 +1434,12 @@ public sealed partial class RynthAiPlugin } if (requested > 0) - { - LootDiag($"[RynthAi] Corpse loot: requested {requested} item ID(s) (pre-classified {preClassified}) for 0x{(uint)corpseId:X8}."); - return; // One tick for server responses to start arriving - } - if (preClassified > 0) - LootDiag($"[RynthAi] Corpse loot: pre-classified {preClassified} item(s) without ID for 0x{(uint)corpseId:X8}."); - // Fall through: all items handled without ID requests — evaluate immediately + LootDiag($"[RynthAi] {LootTag}: requested {requested} item ID(s) (pre-classified {preClassified}) for 0x{(uint)corpseId:X8}."); + else if (preClassified > 0) + LootDiag($"[RynthAi] {LootTag}: pre-classified {preClassified} item(s) without ID for 0x{(uint)corpseId:X8}."); + // Fall through either way: items already decided (their appraisal is here, or the + // profile needs none for them) are picked up now while the other IDs stream in; + // the ones still waiting are held below and judged as their data arrives. } // Evaluate ALL items with data in one pass — do NOT gate evaluation on @@ -1364,6 +1510,12 @@ public sealed partial class RynthAiPlugin // Still no appraisal — fall through and classify best-effort. } + // A keeper already judged on this open is judged again only when its turn comes (it + // is the first match): that fresh pass is what Keep # and the mana stone cap count + // against. Re-running the profile on every waiting keeper each pass did nothing else. + if (firstMatchId != 0 && _lootEvalLogged.TryGetValue(item.Id, out string? judged) && judged.StartsWith("KEEP", StringComparison.Ordinal)) + continue; + // Evaluate against loot profile — pure classification, no UseObject. bool classified = ClassifyItemAgainstProfile(item, settings, out string actionLabel, out bool isSalvage, out string ruleLabel); // Nothing to salvage with: an item only a Salvage rule wants stays on the corpse. @@ -1383,8 +1535,14 @@ public sealed partial class RynthAiPlugin // once the assess window expires, so an unappraised item can match a // rule it should not. If keeps correlate with appraised=False, that // is the cause. - LootDiag($"[LootEval] '{item.Name}' cls={item.ObjectClass} id=0x{(uint)item.Id:X8} value={item.Values(19, 0)} stack={item.Values(12, 0)} type=0x{item.Values(1, 0):X} wcid={item.Values(unchecked((int)WorldObjectCache.DecalTypeKey), 0)} appraised={hasAppraisalData} timedOut={assessTimedOut} -> " + - (classified ? $"KEEP [{actionLabel}] rule='{ruleLabel}'" : noUst ? $"leave (Salvage rule '{ruleLabel}', no UST carried)" : "leave")); + // Once per item per open, and again only if the verdict changes (a matched item was + // re-printed before every pickup: ~200 lines for a 20-keeper chest). + string verdict = classified ? $"KEEP [{actionLabel}] rule='{ruleLabel}'" : noUst ? $"leave (Salvage rule '{ruleLabel}', no UST carried)" : "leave"; + if (!_lootEvalLogged.TryGetValue(item.Id, out string? loggedVerdict) || loggedVerdict != verdict) + { + _lootEvalLogged[item.Id] = verdict; + LootDiag($"[LootEval] '{item.Name}' cls={item.ObjectClass} id=0x{(uint)item.Id:X8} value={item.Values(19, 0)} stack={item.Values(12, 0)} type=0x{item.Values(1, 0):X} wcid={item.Values(unchecked((int)WorldObjectCache.DecalTypeKey), 0)} appraised={hasAppraisalData} timedOut={assessTimedOut} -> " + verdict); + } if (classified) { @@ -1409,48 +1567,55 @@ public sealed partial class RynthAiPlugin // Empty corpse check if (visibleItemCount == 0) { - if (openAge >= Math.Max(200, settings.LootEmptyCorpseMs)) + if (openAge >= Math.Max(200, settings.LootEmptyCorpseMs) && !LastPickupSettling(now)) { - LootDiag($"[RynthAi] Corpse loot: no items on 0x{(uint)corpseId:X8} after {openAge}ms; marking complete."); + LootDiag($"[RynthAi] {LootTag}: no items on 0x{(uint)corpseId:X8} after {openAge}ms; marking complete."); MarkCorpseCompleted(corpseId); } return; } - // Matched item — attempt pickup + // Matched item — attempt pickup. Its decision is final (its own appraisal is here, the + // profile needs none for it, or the wait for it ran out), so it goes now: there used to + // be a busy-count gate here for the assess window, but the RequestIds don't hold item + // moves (AC's one-item-at-a-time gate is the pending inventory request, not m_cBusy). if (firstMatchId != 0) { - // Within the assess window, gate on busy count so we don't race with - // RequestId responses still in flight. After the window, items without - // data are already being skipped — items we're picking up here have their - // own ID response back (and their busy-count contribution already decremented). - // If busy gets genuinely stuck, CheckBusyTimeout / ForceResetBusyCount handles - // it; don't add a second gate here that fights the first. - if (_busyCount > 0 && !assessTimedOut) - return; - // Keep room for weapon swaps: with a full pack the bow can't be put away to // switch to the wand, so buffs and spell heals stop (2026-09-28 death). Leave // the corpse rather than filling the last slots; -1 = side-pack capacity unknown. int freeSlots = WorldObjectCache.CountFreeItemSlots(Host, _objectCache); if (freeSlots >= 0 && freeSlots < WorldObjectCache.LootReserveFreeSlots) { - LootDiag($"[RynthAi] Corpse loot: skipping '{matchItemName}' on 0x{(uint)corpseId:X8} — {freeSlots} free slot(s), keeping {WorldObjectCache.LootReserveFreeSlots} for weapon swaps."); + if (LastPickupSettling(now)) + return; // the last item lands first, then the corpse closes + LootDiag($"[RynthAi] {LootTag}: skipping '{matchItemName}' on 0x{(uint)corpseId:X8} — {freeSlots} free slot(s), keeping {WorldObjectCache.LootReserveFreeSlots} for weapon swaps."); WorldObjectCache.WarnPackFull(Host, $"looting paused with {freeSlots} free slot(s) so weapon swaps still work"); MarkCorpseCompleted(corpseId); return; } - // The last pickup's bend-down still plays: the engine holds a move sent now until - // it ends, so wait and send it then. - if (PickupAnimating(CorpseNowMs)) + // The character still animates. Right after a pickup's answer that is its "Return" + // (standing up): ACE queues a move that arrives then and runs it the moment the + // Return ends (Player.HandleActionPutItemInContainer_Verify, NextPickup), so the next + // move goes out now - one, never two. Any other animation: wait until it ends. + bool pipelined = false; + if (PickupAnimating(now)) + { + if (!CanPipelinePickup(now)) + return; + pipelined = true; + } + + // The server still owes an answer to a cast or use: it refuses a pickup now. + if (PickupHeldByServerAction()) return; ChatLine($"[RynthAi] Loot rule: {matchItemName} -> [{matchActionLabel}] {matchRuleLabel}"); _currentLootItemId = firstMatchId; RynthCore.Plugin.RynthAi.ItemInfo.SelfSelect.Mark(unchecked((uint)firstMatchId)); Host.SelectItem(unchecked((uint)firstMatchId)); - LootDiag($"[RynthAi] Corpse loot: picking up 0x{(uint)firstMatchId:X8} '{matchItemName}' from corpse 0x{(uint)corpseId:X8}."); + LootDiag($"[RynthAi] {LootTag}: picking up 0x{(uint)firstMatchId:X8} '{matchItemName}' from corpse 0x{(uint)corpseId:X8}."); // Jump-loot: jump before the move to cancel the pickup animation. // Only jump when multiple items remain (single-item: no animation worth cancelling). @@ -1461,11 +1626,18 @@ public sealed partial class RynthAiPlugin && Host.HasMoveItemExternal && _vitals.CurrentStamina > 5; - if (useJumpLoot && remainingItems > 1) + if (useJumpLoot && remainingItems > 1 && !pipelined) Host.JumpNonAutonomous(Math.Clamp(settings.LootJumpHeight / 100f, 0.01f, 1f)); // Always a move into a pack, never a use: a use on a wearable corpse item is // get-and-wield, which put salvage jewellery on the character (2026-10-02). + int errSeqAtSend = LastWeenieErrorSeq(); + bool stackable = IsStackAtSend(firstMatchId); + if (pipelined) + { + _pipelinedAfterItemId = _settlingLootItemId; + LootDiag($"[RynthAi] {LootTag}: queuing 0x{(uint)firstMatchId:X8} '{matchItemName}' behind 0x{(uint)_settlingLootItemId:X8}'s Return."); + } LootPickupResult pickup = SendLootPickup(firstMatchId, matchItemName, corpseId); if (pickup == LootPickupResult.NoRoom || pickup == LootPickupResult.Refused) return; @@ -1478,7 +1650,7 @@ public sealed partial class RynthAiPlugin if (_busyCount > 0) return; - LootDiag($"[RynthAi] Corpse loot: use request failed for 0x{(uint)firstMatchId:X8}."); + LootDiag($"[RynthAi] {LootTag}: use request failed for 0x{(uint)firstMatchId:X8}."); if (IncrementCorpseItemAttempt(firstMatchId) >= 3) _processedCorpseItems.Add(firstMatchId); ResetCurrentLootItem(); @@ -1502,7 +1674,13 @@ public sealed partial class RynthAiPlugin _scrollLearner?.NoteLooted(firstMatchId, matchItemName, fromProfile: matchRuleLabel != ScrollLearner.RuleLabel); _currentLootItemMovePending = true; _currentLootItemMoveRequestedAt = now; - _currentLootItemMoveAttempts = 1; + // A queued move that the client or server turned away (the client's one-request + // slot still held, or "You're too busy") must not cost the item one of its 3 tries. + _currentLootItemMoveAttempts = pipelined ? 0 : 1; + _currentLootItemPipelined = pipelined; + _currentLootItemStackable = stackable; + _currentLootItemErrSeqAtSend = errSeqAtSend; + _currentLootItemFreeRetries = 0; _currentLootItemActionLabel = matchActionLabel; _currentLootItemName = matchItemName; _currentLootItemIsSalvage = matchIsSalvage; @@ -1510,23 +1688,75 @@ public sealed partial class RynthAiPlugin return; } - // All items evaluated, no matches left — mark corpse complete - if (pendingDataCount == 0) + // All items evaluated, no matches left — mark corpse complete, once the last pickup + // has played out (closing while it was under way: 2026-10-07). + if (pendingDataCount == 0 && !LastPickupSettling(now)) { - LootDiag($"[RynthAi] Corpse loot: all {visibleItemCount} items on 0x{(uint)corpseId:X8} evaluated; marking complete."); + LootDiag($"[RynthAi] {LootTag}: all {visibleItemCount} items on 0x{(uint)corpseId:X8} evaluated; marking complete."); MarkCorpseCompleted(corpseId); } } + // A pickup that merges into a stack already in the pack (a Silver Pea onto the Silver Peas): + // the server removes the corpse item (InventoryRemoveObject) and raises the pack stack's size, + // so the picked object never shows up in the inventory and the arrival check waited out + // PickupArriveMaxMs (in a client log, 39 stack pickups: median 5018 ms to confirm against + // 2731 ms). The stacks of that name in the inventory are noted when the pickup goes out; one that has grown since counts as arrival. + private readonly Dictionary _mergeBaseline = new(); + + private void NoteMergeTargets(int itemId, string itemName) + { + _mergeBaseline.Clear(); + if (_objectCache == null || string.IsNullOrEmpty(itemName)) return; + foreach (WorldObject inv in _objectCache.GetDirectInventory(forceRefresh: true)) + { + if (inv.Id == itemId || !string.Equals(inv.Name, itemName, StringComparison.Ordinal)) continue; + _mergeBaseline[inv.Id] = Math.Max(1, inv.Values(LongValueKey.StackCount, 1)); + } + } + + /// A same-name stack in the inventory has grown since the pickup went out. + private bool MergedIntoInventoryStack(out int stackId) + { + stackId = 0; + if (_objectCache == null) return false; + foreach (var kv in _mergeBaseline) + { + WorldObject? stack = _objectCache[kv.Key]; + if (stack == null || !InPlayerInventory(stack.Container)) continue; + if (Math.Max(1, stack.Values(LongValueKey.StackCount, 1)) > kv.Value) + { + stackId = kv.Key; + return true; + } + } + return false; + } + /// Longest a pickup waits on the motion queue (the engine's own hold is 2.5 s). internal const long PickupAnimMaxMs = 3000; - /// After the item leaves the corpse: how long to wait for its bend-down to start. + /// After a pickup's answer: how long to wait for its Return to show when none is seen. internal const long PickupSettleMs = 1000; /// Off the corpse but not seen in the inventory: counted after this anyway. internal const long PickupArriveMaxMs = 4000; + /// + /// An answer sooner than this after the send isn't believed: ACE plays the whole pickup + /// motion (about 0.75 s standing, longer in a combat stance) before it moves the item. + /// + internal const long PickupAnswerMinMs = 500; + + /// The next move is queued behind a Return only this soon after its answer. + internal const long PipelineWindowMs = 1000; + + /// Resends after a "You're too busy" that don't count as one of the item's 3 tries. + internal const int PickupFreeRetries = 3; + + private const uint WeenieErrorYoureTooBusy = 0x001D; + private const uint EventInventoryServerSaveFailed = 0x00A0; + /// The container is the character or a pack it carries. private bool InPlayerInventory(int containerId) { @@ -1538,7 +1768,8 @@ public sealed partial class RynthAiPlugin /// /// The character still has motions queued (the engine's cast gate, GetCastBusyState): /// the bend-down of the last pickup is playing. False after PickupAnimMaxMs of it, so a - /// stuck queue can't stop looting, and on an engine without the gate. + /// stuck queue can't stop looting, and on an engine without the gate. Each answered pickup + /// restarts that cap (queued pickups animate back to back for a whole chest). /// private bool PickupAnimating(long now) { @@ -1554,6 +1785,124 @@ public sealed partial class RynthAiPlugin return now - _pickupAnimSince < PickupAnimMaxMs; } + /// The engine's refusal counter now (0 when the engine can't say). + private int LastWeenieErrorSeq() + { + try + { + return Host.HasGetLastWeenieError && Host.TryGetLastWeenieError(out int seq, out _, out _, out _) ? seq : 0; + } + catch { return 0; } + } + + /// + /// The server turned the current item's move away since it was sent: "You're too busy" + /// (it arrived while the last pickup's bend-down still ran) or InventoryServerSaveFailed + /// naming the item. Someone else's refusal (a fizzle, a use) is not ours. + /// + private bool CurrentPickupRefused(out uint error) + { + error = 0; + try + { + if (!Host.HasGetLastWeenieError || !Host.TryGetLastWeenieError(out int seq, out uint err, out uint evt, out uint obj)) + return false; + if (seq == 0 || seq == _currentLootItemErrSeqAtSend) + return false; + error = err; + return err == WeenieErrorYoureTooBusy + || (evt == EventInventoryServerSaveFailed && obj == unchecked((uint)_currentLootItemId)); + } + catch { return false; } + } + + /// A stack when its move is sent: it may merge into a stack in the pack and be deleted. + private bool IsStackAtSend(int itemId) + { + WorldObject? wo = _objectCache?[itemId]; + if (wo == null) return false; + return wo.Values(LongValueKey.MaxStackSize, 0) > 1 || wo.Values(LongValueKey.StackCount, 0) > 1; + } + + /// + /// The client no longer has the object at all (no name, no position, no owner): a stack that + /// merged into one in the pack (ACE's StackableMerge sends InventoryRemoveObject for it, so it + /// never shows up in the inventory) or anything else the server took away. + /// + private bool ObjectGoneFromClient(int itemId) + { + uint uid = unchecked((uint)itemId); + if (!Host.HasGetObjectName || !Host.HasGetObjectPosition) + return false; // can't tell + try + { + if (Host.TryGetObjectName(uid, out string n) && !string.IsNullOrEmpty(n)) return false; + if (Host.TryGetObjectPosition(uid, out _, out _, out _, out _)) return false; + } + catch { return false; } + return true; + } + + /// + /// TickOpenCorpseLooting: a move may be queued behind the last pickup's Return now - the + /// answer was real (not timed out), it is fresh, it is on this container, and nothing was + /// queued behind it yet (at most one queued move: ACE refuses a second). + /// + private bool CanPipelinePickup(long now) => + Host.HasMoveItemExternal // a move (PutItemInContainer / StackableMerge), never a use + && _settlingLootItemId != 0 + && _settlingAllowsPipeline + && _settlingContainerId == _openedContainerId + && _pipelinedAfterItemId != _settlingLootItemId + && now - _settlingSince < PipelineWindowMs; + + /// + /// The last answered pickup is still playing out (its Return). True while it is: the corpse + /// or chest is not closed until it ends (2026-10-07: closed during the last pickup, and the + /// character picked the item up after the close). Settled once the character stands still + /// after its Return was seen, or PickupSettleMs after the answer when none was, or + /// PickupArriveMaxMs after the answer whatever the motion says. + /// + private bool LastPickupSettling(long now) + { + if (_settlingLootItemId == 0) + return false; + bool animating = PickupAnimating(now); + if (animating) _settlingSawAnim = true; + long since = now - _settlingSince; + bool settled = (!animating && (_settlingSawAnim || since >= PickupSettleMs)) || since >= PickupArriveMaxMs; + if (!settled) + return true; + _settlingLootItemId = 0; + _settlingContainerId = 0; + _settlingAllowsPipeline = false; + return false; + } + + private bool _pickupHeldLogged; + + /// + /// True while the server owes an answer to a cast or use (ActionPacer): ACE refuses a pickup + /// then (Player.HandleActionPutItemInContainer_Verify: IsBusy -> YoureTooBusy and + /// InventoryServerSaveFailed). In a client log, a pickup sent while Bloodstone Bolt VII + /// was unanswered came back 0x1D. The assess-timeout path skips the busy-count gate above, so + /// this is the gate that holds it. Logged once per hold. + /// + private bool PickupHeldByServerAction() + { + if (!ActionPacer.Outstanding(Host, out var pending) || pending == null) + { + _pickupHeldLogged = false; + return false; + } + if (!_pickupHeldLogged) + { + _pickupHeldLogged = true; + LootDiag($"[RynthAi] Corpse loot: pickup waits - the server still owes an answer to {ActionPacer.Describe(pending.Kind, pending.Label)} ({pending.Who})."); + } + return true; + } + private void TickPendingCorpsePickup(LegacyUiSettings settings) { if (_objectCache == null || _openedContainerId == 0 || _currentLootItemId == 0) @@ -1565,40 +1914,62 @@ public sealed partial class RynthAiPlugin long now = CorpseNowMs; WorldObject? currentItem = _objectCache[_currentLootItemId]; int currentContainer = currentItem?.Container ?? 0; - bool stillVisibleOnCorpse = IsCorpseItemVisible(_openedContainerId, _currentLootItemId); + // One ownership read, the same test GetContainedItems makes for the listing. + bool stillVisibleOnCorpse = currentItem != null && currentContainer == _openedContainerId; // Watch for this pickup's bend-down (the server plays it once the move reaches it). bool animating = PickupAnimating(now); if (animating) _currentLootItemSawAnim = true; - // Off the corpse is not done yet: confirming then closed the corpse while the pickup was - // still under way, and the character picked the last item up after the corpse closed - // (2026-10-07). It counts once the item shows up in the inventory (the main pack, a side - // pack, or merged into a stack already there: the picked object is gone) and its - // bend-down has played out. Off the corpse but never seen in the inventory: counted - // after PickupArriveMaxMs anyway, so looting can't stall on it. - if (currentItem == null || !stillVisibleOnCorpse || (currentContainer != 0 && currentContainer != _openedContainerId)) + // The server's answer: ACE moves the item at the end of the pickup motion and starts the + // Return in the same breath (InventoryPutObjInContainer, or for a stack that merges into + // one in the pack InventoryRemoveObject + SetStackSize). So the item is answered once it + // is off the container AND in the inventory (the main pack, a side pack) or merged away + // (a stack, now unowned, or the object gone from the client: it never shows up in the + // inventory, which made every merged stack wait PickupArriveMaxMs, 4 s, 2026-10-12). + // The corpse still isn't closed until the Return has played (LastPickupSettling). + if (!stillVisibleOnCorpse) { if (_currentLootItemLeftAt == 0) _currentLootItemLeftAt = now; - bool inInventory = currentItem == null || InPlayerInventory(currentContainer); + bool inPack = currentItem != null && InPlayerInventory(currentContainer); + // Merged into a stack in the pack (it never shows up in the inventory): gone from the + // client, unowned and a stack when sent (ours, 064a07a), or a same-name stack in the + // pack has grown since the send (PR #16) - whichever shows first. + int mergedInto = 0; + bool mergedAway = !inPack + && (currentItem == null || ObjectGoneFromClient(_currentLootItemId) || (currentContainer == 0 && _currentLootItemStackable) + || MergedIntoInventoryStack(out mergedInto)); + bool landed = inPack || mergedAway; + bool believable = now - _currentLootItemMoveRequestedAt >= PickupAnswerMinMs; long since = now - _currentLootItemLeftAt; - bool settled = !animating && (_currentLootItemSawAnim || since >= PickupSettleMs); - if (!(inInventory && settled) && since < PickupArriveMaxMs) + bool answered = landed && believable; + if (!answered && since < PickupArriveMaxMs) return; - ConfirmCurrentLootItemMoved( + ConfirmCurrentLootItem( now, currentItem == null ? "item left cache after use" - : (!stillVisibleOnCorpse + : inPack ? "item no longer listed on corpse" - : $"new container=0x{(uint)currentContainer:X8}")); + : mergedInto != 0 + ? $"merged into the stack 0x{(uint)mergedInto:X8} in the pack" + : mergedAway + ? "merged into a stack in the pack" + : $"off the corpse, not seen in a pack (container=0x{(uint)currentContainer:X8})", + answered); return; } + // The server turned the move away ("You're too busy": it arrived during the last + // pickup's bend-down, not its Return). Resend it as soon as the character is still, + // without counting it as one of the item's 3 tries. + bool refused = CurrentPickupRefused(out uint refusal); + // Item still on corpse — wait before retrying the UseObject. The window counts from // when the character is still: while a pickup animation plays the engine holds the // move, and a retry timed from the send gave up on items whose move had not gone // out yet (2026-10-07: moves ran ~2.2 s late, 3 tries at 0.5 s skipped the item). + // A queued move waits here through the last pickup's Return and its own bend-down. if (PickupAnimating(now)) { _currentLootItemStillSince = 0; @@ -1606,14 +1977,15 @@ public sealed partial class RynthAiPlugin } if (_currentLootItemStillSince == 0) _currentLootItemStillSince = now; + bool freeRetry = refused && _currentLootItemFreeRetries < PickupFreeRetries; long verifyWindowMs = Math.Max(150, settings.LootRetryTimeoutMs); long windowStart = Math.Max(_currentLootItemMoveRequestedAt, _currentLootItemStillSince); - if (now - windowStart < verifyWindowMs) + if (!freeRetry && now - windowStart < verifyWindowMs) return; - if (_currentLootItemMoveAttempts >= 3) + if (!freeRetry && _currentLootItemMoveAttempts >= 3) { - LootDiag($"[RynthAi] Corpse loot: pickup failed for 0x{(uint)_currentLootItemId:X8}; container remained 0x{(uint)_openedContainerId:X8} after {_currentLootItemMoveAttempts} attempt(s)."); + LootDiag($"[RynthAi] {LootTag}: pickup failed for 0x{(uint)_currentLootItemId:X8}; container remained 0x{(uint)_openedContainerId:X8} after {_currentLootItemMoveAttempts} attempt(s)."); _processedCorpseItems.Add(_currentLootItemId); ResetCurrentLootItem(); _lastLootActionAt = now; @@ -1622,17 +1994,28 @@ public sealed partial class RynthAiPlugin if (_busyCount > 0) return; // Client is busy — don't queue retry + if (PickupHeldByServerAction()) + return; // a retry now would be refused as too busy and use up an attempt RynthCore.Plugin.RynthAi.ItemInfo.SelfSelect.Mark(unchecked((uint)_currentLootItemId)); Host.SelectItem(unchecked((uint)_currentLootItemId)); + int errSeqAtSend = LastWeenieErrorSeq(); LootPickupResult retry = SendLootPickup(_currentLootItemId, _currentLootItemName, _openedContainerId); if (retry == LootPickupResult.NoRoom || retry == LootPickupResult.Refused) return; // SendLootPickup finished the item / corpse bool retried = retry == LootPickupResult.Moved || retry == LootPickupResult.Used; - _currentLootItemMoveAttempts++; + if (freeRetry) + _currentLootItemFreeRetries++; + else + _currentLootItemMoveAttempts++; + _currentLootItemErrSeqAtSend = errSeqAtSend; _currentLootItemMoveRequestedAt = now; + _currentLootItemStillSince = 0; + _currentLootItemSawAnim = false; _lastLootActionAt = now; - LootDiag($"[RynthAi] Corpse loot: retrying use for 0x{(uint)_currentLootItemId:X8} attempt {_currentLootItemMoveAttempts}."); + LootDiag(freeRetry + ? $"[RynthAi] {LootTag}: the server refused 0x{(uint)_currentLootItemId:X8} (error 0x{refusal:X}); sending it again now the character is still." + : $"[RynthAi] {LootTag}: retrying use for 0x{(uint)_currentLootItemId:X8} attempt {_currentLootItemMoveAttempts}."); if (!retried && _currentLootItemMoveAttempts >= 3) { @@ -1659,20 +2042,6 @@ public sealed partial class RynthAiPlugin return 0; } - private bool IsCorpseItemVisible(int corpseId, int itemId) - { - if (_objectCache == null || corpseId == 0 || itemId == 0) - return false; - - foreach (WorldObject item in _objectCache.GetContainedItems(corpseId)) - { - if (item.Id == itemId) - return true; - } - - return false; - } - /// /// Sends the pickup for a corpse item (: a move into a pack, /// never a use). NoRoom finishes the corpse like the free-slot check does; Refused @@ -1680,6 +2049,7 @@ public sealed partial class RynthAiPlugin /// private LootPickupResult SendLootPickup(int itemId, string itemName, int corpseId) { + NoteMergeTargets(itemId, itemName); bool ownCorpse = corpseId != 0 && corpseId == _ownRecoveryCorpseId; uint dest; LootPickupResult r = ownCorpse @@ -1693,16 +2063,16 @@ public sealed partial class RynthAiPlugin switch (r) { case LootPickupResult.Moved: - LootDiag($"[RynthAi] Corpse loot: moving 0x{(uint)itemId:X8} '{itemName}' into {(dest == _playerId ? "the main pack" : $"pack 0x{dest:X8}")}."); + LootDiag($"[RynthAi] {LootTag}: moving 0x{(uint)itemId:X8} '{itemName}' into {(dest == _playerId ? "the main pack" : $"pack 0x{dest:X8}")}."); break; case LootPickupResult.NoRoom: - LootDiag($"[RynthAi] Corpse loot: no pack has a free slot for '{itemName}' on 0x{(uint)corpseId:X8}; leaving the corpse."); + LootDiag($"[RynthAi] {LootTag}: no pack has a free slot for '{itemName}' on 0x{(uint)corpseId:X8}; leaving the corpse."); WorldObjectCache.WarnPackFull(Host, "looting stopped, no pack has a free slot"); ResetCurrentLootItem(); MarkCorpseCompleted(corpseId); break; case LootPickupResult.Refused: - LootDiag($"[RynthAi] Corpse loot: leaving '{itemName}' 0x{(uint)itemId:X8} — the engine has no move call and a use would put it on."); + LootDiag($"[RynthAi] {LootTag}: leaving '{itemName}' 0x{(uint)itemId:X8} — the engine has no move call and a use would put it on."); _processedCorpseItems.Add(itemId); ResetCurrentLootItem(); break; @@ -1710,13 +2080,29 @@ public sealed partial class RynthAiPlugin return r; } - private void ConfirmCurrentLootItemMoved(long now, string reason) + /// + /// The current pickup is done as far as the item goes (: the + /// server's answer was seen; false: it left the corpse and the wait for it ran out). The + /// character may still be standing up: that Return is tracked as the settling pickup. + /// + private void ConfirmCurrentLootItemMoved(long now, string reason) => ConfirmCurrentLootItem(now, reason, answered: true); + + private void ConfirmCurrentLootItem(long now, string reason, bool answered) { if (_currentLootItemId == 0) return; + int itemId = _currentLootItemId; _processedCorpseItems.Add(_currentLootItemId); - LootDiag($"[RynthAi] Corpse loot: pickup confirmed for 0x{(uint)_currentLootItemId:X8}; {reason}."); + LootDiag($"[RynthAi] {LootTag}: pickup confirmed for 0x{(uint)_currentLootItemId:X8}; {reason}" + + $" ({now - _currentLootItemMoveRequestedAt} ms after the send{(_currentLootItemPipelined ? ", queued" : "")})."); + // Each item taken is progress, so the corpse/chest timeout counts from the last pickup: + // a chest gets its 2 minutes per pickup, and a corpse with many keeps is no longer + // closed part way through by the 12 s timeout (SK, 2026-10-11). Not while a hold + // has the clock frozen. + if (_corpseHoldFrozenAge < 0 + && (IsChestLoot(_targetCorpseId) || (_targetCorpseId != 0 && _targetCorpseId == _openedContainerId))) + _corpseTargetSince = now; if (_openedContainerId != 0 && _openedContainerId == _ownRecoveryCorpseId) NoteOwnCorpseItemRecovered(now); if (!string.IsNullOrWhiteSpace(_currentLootItemName)) @@ -1731,6 +2117,14 @@ public sealed partial class RynthAiPlugin ResetCurrentLootItem(); _lastLootActionAt = now; + + // Its Return now plays: the close waits for it, and one move may be queued behind it. + _settlingLootItemId = itemId; + _settlingContainerId = _openedContainerId; + _settlingSince = now; + _settlingSawAnim = false; + _settlingAllowsPipeline = answered; + _pickupAnimSince = 0; // the next pickup's animation gets its own PickupAnimMaxMs } /// @@ -1747,7 +2141,8 @@ public sealed partial class RynthAiPlugin /// /// Caveat, deliberately kept: the in-range scan calls ShouldLootCorpse, /// which fires one Host.RequestId per corpse to populate the killer name - /// (guarded by _corpseIdRequested, so once per corpse ever). That is a + /// (guarded by _corpseIdRequested: once per accepted request, asked again after + /// CorpseIdReaskMs while no data has arrived). That is a /// memoized fetch rather than a mutation, and the old bottom-of-tick /// IsCorpseNavigationClaimActive call already did it on the same cadence — /// this moves it earlier in the tick, it does not add it. @@ -1755,7 +2150,7 @@ public sealed partial class RynthAiPlugin private bool HasLootWork(LegacyUiSettings settings, long nowMs) { _lootStarved = false; - if (!settings.IsMacroRunning || !settings.EnableLooting) + if (!settings.IsMacroRunning || (!settings.EnableLooting && !ForcedLootHolds())) return false; // The server refuses every use (UseRefusalWatch, Stuck): no loot work until the back-off @@ -1778,6 +2173,10 @@ public sealed partial class RynthAiPlugin if (IsLootingBlockedByPack(settings) && !OwnCorpseBypassesPackGate(settings, GetCorpseApproachRangeMaxMeters(settings))) return false; + // An open chest the player or a meta opened, eligible to loot (RynthAiPlugin.ChestLoot.cs). + if (HasChestLootWork(settings)) + return true; + // Loot grace: combat just ended and the corpse CreateObject has not // arrived yet. Hold Looting across that gap so nav doesn't walk away // from a body that is about to exist. @@ -1788,7 +2187,7 @@ public sealed partial class RynthAiPlugin if (maxMeters <= 0.25) return false; - return HasUnlootedCorpsesInRange(maxMeters); + return HasUnlootedCorpsesInRange(maxMeters) || HasGroundLootWork(settings); } /// @@ -1832,6 +2231,12 @@ public sealed partial class RynthAiPlugin if (_objectCache == null || _playerId == 0) return false; + // A new scan tick: the identify budget starts over, and the corpse the bot is going for asks first. + _corpseIdAcceptedThisTick = 0; + _corpseIdBudgetAt = ActionPacer.NowMs(); + foreach (int cid in new[] { _targetCorpseId, _openedContainerId }) + if (cid != 0 && _objectCache[cid] is { } cand && cand.ObjectClass == AcObjectClass.Corpse) + TryRequestCorpseId(cand, cand.Values(StringValueKey.LongDesc, string.Empty)); long now = CorpseNowMs; int playerId = unchecked((int)_playerId); foreach (WorldObject candidate in _objectCache.GetLandscapeObjects()) @@ -1916,7 +2321,7 @@ public sealed partial class RynthAiPlugin int corpseId = _openedContainerId != 0 ? _openedContainerId : _targetCorpseId; if (corpseId != 0) - LootDiag($"[RynthAi] Corpse loot: pausing navigation for corpse 0x{(uint)corpseId:X8}."); + LootDiag($"[RynthAi] {LootTag}: pausing navigation for corpse 0x{(uint)corpseId:X8}."); } /// @@ -1983,15 +2388,26 @@ public sealed partial class RynthAiPlugin // cache-classification race that bites AllKnownObjects() right after // RL/login. IsManaStone's name fallback also keys on Name (always // present), so the tally is reliable even before ITEM_TYPE lands. - int liveCount = 0; - if (_objectCache != null) + // One walk per pass, not one per stone: a chest with 9 stones walked the whole + // inventory 9 times in the same tick (ManaStoneLiveCountMs). + long nowMs = CorpseNowMs; + int liveCount; + if (_manaStoneLiveCountAt != 0 && nowMs - _manaStoneLiveCountAt < ManaStoneLiveCountMs) + liveCount = _manaStoneLiveCount; + else { - foreach (var inv in _objectCache.GetDirectInventory(forceRefresh: true)) + liveCount = 0; + if (_objectCache != null) { - if (string.IsNullOrEmpty(inv.Name)) continue; - if (_manaStoneManager?.IsManaStone(inv) == true) - liveCount++; + foreach (var inv in _objectCache.GetDirectInventory(forceRefresh: true)) + { + if (string.IsNullOrEmpty(inv.Name)) continue; + if (_manaStoneManager?.IsManaStone(inv) == true) + liveCount++; + } } + _manaStoneLiveCount = liveCount; + _manaStoneLiveCountAt = nowMs; } // Include stones already approved this session whose CreateObject event @@ -2005,9 +2421,13 @@ public sealed partial class RynthAiPlugin } int haveCount = liveCount + pendingNotYetCounted; - // One-time-per-corpse log so we can see what the count was based on. - if (!preview && _pendingManaStoneIds.Count == 0) + // One-time-per-corpse log so we can see what the count was based on (it was printed + // for every stone while none was approved: 9 lines a chest at the cap). + if (!preview && _pendingManaStoneIds.Count == 0 && _manaStoneCapLoggedFor != _openedContainerId) + { + _manaStoneCapLoggedFor = _openedContainerId; Host.Log($"[RynthAi] ManaStone count for cap check: live={liveCount} pending={pendingNotYetCounted} cap={settings.ManaStoneKeepCount} (cache_known={_objectCache?.AllKnownObjects().Count() ?? 0})"); + } // If this specific stone is already approved, return the same answer // we returned last time (no further log spam, no count change). @@ -2375,6 +2795,13 @@ public sealed partial class RynthAiPlugin if (corpseId == 0) return; + // A chest is finished and closed, never marked: it regenerates, and the next open loots it again. + if (IsChestLoot(corpseId)) + { + FinishChestLoot(corpseId, "completed", close: true, sayNothingMatched: true); + return; + } + _completedCorpses[corpseId] = CorpseNowMs; _corpseCooldownUntil.Remove(corpseId); _processedCorpseItems.Clear(); @@ -2389,7 +2816,13 @@ public sealed partial class RynthAiPlugin // server closes this corpse when the next UseObject open is sent. // Clear container state immediately; SyncCorpseContainerState guards against // re-claiming via _completedCorpses until the server's close lands. - CloseCorpseContainer(corpseId, "completed"); + // With another corpse to loot in range, no close at all: ACE closes the open + // container itself when the next one is used (Container.ActOnUse closes the player's + // LastOpenedContainerId first), so the close and its answer wait (CloseAnswerWaitMs) only + // delayed the next open. The close is held back (TickDeferredClose) and still sent if no + // other corpse is opened, or looting stops. + if (!(OtherCorpseToLoot(corpseId) && DeferClose(corpseId))) + CloseCorpseContainer(corpseId, "completed"); if (_openedContainerId == corpseId) { _openedContainerId = 0; @@ -2438,6 +2871,10 @@ public sealed partial class RynthAiPlugin _currentLootItemStillSince = 0; _currentLootItemLeftAt = 0; _currentLootItemSawAnim = false; + _currentLootItemStackable = false; + _currentLootItemPipelined = false; + _currentLootItemErrSeqAtSend = 0; + _currentLootItemFreeRetries = 0; _currentLootItemActionLabel = string.Empty; _currentLootItemName = string.Empty; _currentLootItemIsSalvage = false; @@ -2559,6 +2996,12 @@ public sealed partial class RynthAiPlugin if (watch && sent) _useRefusals.OnOpenSent(corpseId, now, seqBefore); LootDiag($"[RynthAi] Corpse loot: attempting open for 0x{(uint)corpseId:X8}."); + // The finished corpse held open (MarkCorpseCompleted): this use closes it on the server. + if (sent && _closeDeferredFor != 0 && _closeDeferredFor != corpseId) + { + LootDiag($"[RynthAi] Corpse loot: 0x{(uint)_closeDeferredFor:X8} is left for the server to close with this open."); + _closeDeferredFor = 0; + } return true; } @@ -2725,7 +3168,19 @@ public sealed partial class RynthAiPlugin if (rawOpen == _openedContainerId) return; + // A chest being looted ends on its own close (OnStopViewingObjectContents), not here: the + // engine's ground container is the last ViewContents, which a pack picked up out of the + // chest moves too. The loot timeout still ends it if the close is never seen. + if (IsChestLoot(_openedContainerId)) + return; + long now = CorpseNowMs; + // A finished corpse the client still shows (its close from the server not in yet: the next + // corpse was used without closing it, MarkCorpseCompleted) is not a close of the corpse we + // have open now. A real close of that one empties the client's container (or brings + // OnStopViewingObjectContents), never shows the old corpse again. + if (_openedContainerId != 0 && rawOpen != 0 && rawOpen != _openedContainerId && _completedCorpses.ContainsKey(rawOpen)) + return; if (_openedContainerId != 0 && rawOpen != _openedContainerId) { int previousOpen = _openedContainerId; @@ -2806,6 +3261,9 @@ public sealed partial class RynthAiPlugin private void HandleCorpseObjectDeleted(uint objectId) { int sid = unchecked((int)objectId); + // A chest leaving range (or despawning) ends its session; it is never completed-marked. + if (OnChestGone(sid, "left range")) + return; // Do NOT remove from _completedCorpses here. In AC, DeleteObject fires when a corpse // leaves render range as well as when it actually despawns — both look identical. // If we removed it here, the bot would re-open the same corpse when it circles back @@ -2815,6 +3273,8 @@ public sealed partial class RynthAiPlugin _corpseCooldownUntil.Remove(sid); _ownershipSkipLogged.Remove(sid); _corpseIdRequested.Remove(sid); + _corpseIdAskedAt.Remove(sid); + _corpseIdRefusedAt.Remove(sid); _corpseSkipLogged.Remove(sid); _corpseWaitingSince.Remove(sid); @@ -2909,9 +3369,17 @@ public sealed partial class RynthAiPlugin return minMeters; } - private static int GetCorpseTimeoutMs(LegacyUiSettings settings) + /// + /// How long a chest session may go without a pickup (the corpse timeout when that is longer). + /// A chest can hold dozens of items to assess and take, so the corpse timeout (12 s by default) + /// cut sessions short; each confirmed pickup restarts this clock (ConfirmCurrentLootItemMoved). + /// + internal const int ChestLootTimeoutMs = 120_000; + + private int GetCorpseTimeoutMs(LegacyUiSettings settings) { - return Math.Max(2000, settings.LootCorpseTimeoutMs); + int ms = Math.Max(2000, settings.LootCorpseTimeoutMs); + return IsChestLoot(_targetCorpseId) ? Math.Max(ms, ChestLootTimeoutMs) : ms; } private bool HasCorpseTimedOut(LegacyUiSettings settings, long now) @@ -2957,6 +3425,57 @@ public sealed partial class RynthAiPlugin private long _closeSentAt; private const long CloseAnswerWaitMs = 500; + // A finished corpse left open for the server to close when the next one is used (MarkCorpseCompleted). + private int _closeDeferredFor; + private long _closeDeferredAt; + /// A held-back close is sent anyway when no other corpse has been opened this long. + internal const long DeferredCloseMaxMs = 3000; + + /// Another corpse to loot is in range (the finished one is already marked completed). + private bool OtherCorpseToLoot(int doneCorpseId) + { + var settings = _dashboard?.Settings; + if (settings == null || _objectCache == null) return false; + double maxMeters = GetCorpseApproachRangeMaxMeters(settings); + if (maxMeters <= 0.25) return false; + return TryFindNearestCorpse(maxMeters, out WorldObject? next, out _) && next != null && next.Id != doneCorpseId; + } + + /// Holds the close of a finished corpse back. Only when the engine can close it later and + /// reports which container the client has open (so the hold can see the server close it). + private bool DeferClose(int corpseId) + { + if (!Host.HasCloseContainer || !Host.HasGetGroundContainerId) + return false; + if (unchecked((int)Host.GetGroundContainerId()) != corpseId && _openedContainerId != corpseId) + return false; + _closeDeferredFor = corpseId; + _closeDeferredAt = CorpseNowMs; + LootDiag($"[RynthAi] Corpse loot: 0x{(uint)corpseId:X8} done; no close sent (the server closes it when the next corpse is used)."); + return true; + } + + /// + /// Each tick: a held-back close. Gone from the client (the server closed it): done. Looting + /// stopped, or no other corpse opened within DeferredCloseMaxMs: the close is sent now. + /// + private void TickDeferredClose(LegacyUiSettings settings) + { + int id = _closeDeferredFor; + if (id == 0) return; + if (!Host.HasGetGroundContainerId || unchecked((int)Host.GetGroundContainerId()) != id) + { + _closeDeferredFor = 0; + LootDiag($"[RynthAi] Corpse loot: 0x{(uint)id:X8} closed by the server."); + return; + } + bool stopped = !settings.IsMacroRunning || !settings.EnableLooting || settings.BoostNavPriority; + if (!stopped && CorpseNowMs - _closeDeferredAt < DeferredCloseMaxMs) + return; + _closeDeferredFor = 0; + CloseCorpseContainer(id, stopped ? "completed; looting stopped" : "completed; no other corpse opened"); + } + private void CloseCorpseContainer(int corpseId, string why) { if (corpseId == 0 || !Host.HasCloseContainer) @@ -2971,10 +3490,10 @@ public sealed partial class RynthAiPlugin { _closeSentFor = corpseId; _closeSentAt = CorpseNowMs; - LootDiag($"[RynthAi] Corpse loot: closing 0x{(uint)corpseId:X8} ({why})."); + LootDiag($"[RynthAi] {LootTag}: closing 0x{(uint)corpseId:X8} ({why})."); } else - LootDiag($"[RynthAi] Corpse loot: close of 0x{(uint)corpseId:X8} not sent ({why})."); + LootDiag($"[RynthAi] {LootTag}: close of 0x{(uint)corpseId:X8} not sent ({why})."); } /// @@ -2987,7 +3506,7 @@ public sealed partial class RynthAiPlugin private void CloseOpenCorpseOnMacroStop() { int corpseId = _openedContainerId; - if (corpseId == 0 || !IsCorpseLikeObject(corpseId)) + if (corpseId == 0 || !(IsCorpseLikeObject(corpseId) || IsChestLoot(corpseId))) return; ResetCurrentLootItem(); @@ -3001,6 +3520,15 @@ public sealed partial class RynthAiPlugin return; long ageMs = _corpseTargetSince != 0 ? now - _corpseTargetSince : 0; + + // A chest: closed and let go, never marked (no open was sent, so no wedge count either). + if (IsChestLoot(corpseId)) + { + LootDiag($"[RynthAi] Chest loot: giving up on chest 0x{(uint)corpseId:X8} after {ageMs}ms ({reason})."); + ChatLine($"[RynthAi] Chest {reason}: giving up on 0x{(uint)corpseId:X8} after {ageMs}ms."); + FinishChestLoot(corpseId, "abandoned", close: true, sayNothingMatched: false); + return; + } LootDiag($"[RynthAi] Corpse loot: abandoning corpse 0x{(uint)corpseId:X8} after {ageMs}ms ({reason})."); ChatLine($"[RynthAi] Corpse {(reason == "refused" ? "refuses to open" : "timeout")}: giving up on 0x{(uint)corpseId:X8} after {ageMs}ms."); diff --git a/Plugins/RynthCore.Plugin.RynthAi/CreatureData/CreatureWeakness.cs b/Plugins/RynthCore.Plugin.RynthAi/CreatureData/CreatureWeakness.cs index 53f3965..a725575 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/CreatureData/CreatureWeakness.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/CreatureData/CreatureWeakness.cs @@ -58,10 +58,19 @@ internal static class CreatureWeakness /// /// The elements that hurt this monster most, or null when nothing is known. Order of /// sources: the server table (wcid + name), then what the Damage tab learned - /// () ahead of the creature-type ranking, then the type - /// ranking alone. 0 = unknown (the name keywords decide). + /// () ahead of the creature-type ranking, then the + /// UtilityBelt damage seed (, best first) ahead of the type + /// ranking, then the type ranking alone. 0 = unknown + /// (the name keywords decide). /// - public static Ranking? Rank(uint wcid, string? name, int creatureType, string? learnedBest) + /// + /// Damage types other players landed best on this monster (Monster Editor "Import UB + /// damage insights"), best first; null or empty = no seed. It reflects what players + /// owned as much as the monster's weakness, so it never outranks the server table or + /// this character's learned element; it only beats the generic creature-type average. + /// + public static Ranking? Rank(uint wcid, string? name, int creatureType, string? learnedBest, + IReadOnlyList? seeded = null) { EnsureLoaded(); name ??= ""; @@ -86,11 +95,36 @@ internal static class CreatureWeakness if (!e.Element.Equals(learned, StringComparison.OrdinalIgnoreCase)) r.Order.Add(e); return r; } + Ranking? seed = SeedRanking(seeded, type); + if (seed != null) + return seed; if (type != null) return new Ranking { Source = Pretty(type.Name) + " type", Order = new(type.Order) }; return null; } + /// + /// The seed's elements (normalised, de-duplicated, no multiplier: only the order is known), + /// then the creature type's remaining elements. Null when the seed names no element. + /// + private static Ranking? SeedRanking(IReadOnlyList? seeded, TypeInfo? type) + { + if (seeded == null || seeded.Count == 0) return null; + var r = new Ranking(); + var seen = new HashSet(StringComparer.OrdinalIgnoreCase); + foreach (string raw in seeded) + { + string e = Normalize(raw); + if (e.Length > 0 && seen.Add(e)) r.Order.Add((e, double.NaN)); + } + if (r.Order.Count == 0) return null; + r.Source = type != null ? $"UB seed, then {Pretty(type.Name)} type" : "UB seed"; + if (type != null) + foreach (var e in type.Order) + if (seen.Add(e.Element)) r.Order.Add(e); + return r; + } + /// /// The creature type the world-database table gives this monster (0 = not in it). Same match /// as : the wcid's row when its name agrees (or no name is given); no wcid, diff --git a/Plugins/RynthCore.Plugin.RynthAi/CreatureData/UbMobSeedStore.cs b/Plugins/RynthCore.Plugin.RynthAi/CreatureData/UbMobSeedStore.cs new file mode 100644 index 0000000..827ae57 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/CreatureData/UbMobSeedStore.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using RynthCore.CreatureSeed; +using RynthCore.Install; + +namespace RynthCore.Plugin.RynthAi.CreatureData; + +/// +/// Read-only view of the UtilityBelt damage-type seed (), +/// produced by the Monster Editor's "Import UB damage insights". +/// File: <SuiteDir>\RynthAi\CreatureData\ub-mob-seed.json. +/// +/// Used only as a fallback for the "Auto" damage type when a monster has no appraised +/// resists: it ranks damage types by what players actually landed on that monster, which +/// reflects what they owned as much as the monster's weakness. Never written by the plugin +/// and never fed into the per-character . +/// +/// Lookups are made from the combat thread only; the lock guards the occasional reload. +/// +internal sealed class UbMobSeedStore +{ + /// Minimum time between file-change checks (the editor may rewrite the seed while playing). + private static readonly TimeSpan ReloadCheckInterval = TimeSpan.FromSeconds(15); + + private readonly object _lock = new(); + private readonly Dictionary _byWcid = new(); + private readonly Dictionary _byName = new(StringComparer.OrdinalIgnoreCase); + private DateTime _loadedWriteUtc = DateTime.MinValue; + private DateTime _nextCheckUtc = DateTime.MinValue; + + private static string FilePath => + Path.Combine(RynthInstallPaths.RynthAiDir, "CreatureData", UbMobSeedFile.FileName); + + /// Number of seeded monsters currently loaded (wcid + name-only). + public int Count { get { lock (_lock) return _byWcid.Count + CountNameOnly(); } } + + /// Loads (or reloads) the seed when the file changed. Safe to call often. + public void Load() + { + lock (_lock) + { + _nextCheckUtc = DateTime.UtcNow + ReloadCheckInterval; + string path = FilePath; + if (!File.Exists(path)) + { + Clear(); + return; + } + + DateTime writeUtc; + try { writeUtc = File.GetLastWriteTimeUtc(path); } + catch { return; } + if (writeUtc == _loadedWriteUtc) return; + + try + { + var seed = JsonSerializer.Deserialize(File.ReadAllText(path), RynthAiJsonContext.Default.UbMobSeedFile); + Clear(); + _loadedWriteUtc = writeUtc; + if (seed == null || seed.Version > UbMobSeedFile.CurrentVersion) return; + + foreach (var e in seed.Entries) + { + if (e.Elements == null || e.Elements.Count < 2) continue; + if (e.Wcid != 0) _byWcid[e.Wcid] = e; + IndexName(e); + } + } + catch + { + // Corrupt or mid-write file: keep whatever was loaded before and retry on the next check. + } + } + } + + /// + /// Ranked damage types (best first) for a monster: exact wcid first, then name. + /// Returns false when the seed has nothing comparable for it. + /// + public bool TryGetRanked(uint wcid, string? name, out IReadOnlyList ranked) + { + lock (_lock) + { + // Checked under the lock: DateTime reads are not atomic on x86. Monitor is re-entrant. + if (DateTime.UtcNow >= _nextCheckUtc) Load(); + + UbMobSeedEntry? entry = null; + if (wcid != 0) _byWcid.TryGetValue(wcid, out entry); + if (entry == null && !string.IsNullOrWhiteSpace(name)) _byName.TryGetValue(name.Trim(), out entry); + + ranked = entry?.Elements ?? (IReadOnlyList)Array.Empty(); + return entry != null; + } + } + + /// + /// Name index: a wcid entry beats a name-only one; among equals the most-hit entry wins + /// (tier variants share a name, so the busiest variant is the best guess). + /// + private void IndexName(UbMobSeedEntry e) + { + if (string.IsNullOrWhiteSpace(e.Name)) return; + string key = e.Name.Trim(); + if (_byName.TryGetValue(key, out var existing)) + { + bool existingHasWcid = existing.Wcid != 0, newHasWcid = e.Wcid != 0; + if (existingHasWcid && !newHasWcid) return; + if (existingHasWcid == newHasWcid && existing.TotalHits >= e.TotalHits) return; + } + _byName[key] = e; + } + + private int CountNameOnly() + { + int n = 0; + foreach (var e in _byName.Values) if (e.Wcid == 0) n++; + return n; + } + + private void Clear() + { + _byWcid.Clear(); + _byName.Clear(); + _loadedWriteUtc = DateTime.MinValue; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/DeathRecallRun.cs b/Plugins/RynthCore.Plugin.RynthAi/DeathRecallRun.cs new file mode 100644 index 0000000..7766a0b --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/DeathRecallRun.cs @@ -0,0 +1,75 @@ +namespace RynthCore.Plugin.RynthAi; + +/// +/// One Recall On Death attempt (RynthAiPlugin.DeathRecall.cs), as a pure clock-driven state machine +/// so tests can run it. The plugin calls every frame and does what it answers: +/// = cast the spell / use the item now. A teleport is portal space seen, or +/// the landblock changing; once one is seen nothing more is fired, and after +/// out of portal space the run is . +/// +internal sealed class DeathRecallRun +{ + public enum Step { Wait, Fire, Done, Failed } + + public const long SpellRetryMs = 4_000; // a fizzle or interrupted cast: try again + public const long ItemRetryMs = 6_000; // a gem's use animation takes ~3 s before the portal + public const int MaxFires = 5; + public const long TimeoutMs = 60_000; + public const long SettleMs = 3_000; // out of portal space this long before nav/corpse travel + + private readonly long _retryMs; + private readonly long _startedAt; + private readonly uint _startLandblock; + private long _lastFireAt; + private long _teleportedAt; + private bool _sawPortal; + + public int Fires { get; private set; } + public string FailReason { get; private set; } = string.Empty; + public bool Teleported => _teleportedAt != 0 || _sawPortal; + + /// True for a gem or other item (slower retry), false for a spell. + /// Clock in ms. + /// Landblock (cell >> 16) at the start; 0 when unknown. + public DeathRecallRun(bool useItem, long now, uint startLandblock) + { + _retryMs = useItem ? ItemRetryMs : SpellRetryMs; + _startedAt = now; + _startLandblock = startLandblock; + } + + /// Clock in ms. + /// The client is in portal space. + /// Current landblock; 0 when unknown. + /// Ready to fire (a spell: wand wielded and in magic mode). + public Step Tick(long now, bool inPortalSpace, uint landblock, bool ready) + { + if (inPortalSpace) { _sawPortal = true; return Step.Wait; } + + bool moved = landblock != 0 && _startLandblock != 0 && landblock != _startLandblock; + if (_sawPortal || moved) + { + if (_teleportedAt == 0) _teleportedAt = now; + return now - _teleportedAt >= SettleMs ? Step.Done : Step.Wait; + } + + if (now - _startedAt > TimeoutMs) + return Fail($"no teleport within {TimeoutMs / 1000} s"); + if (Fires >= MaxFires && now - _lastFireAt >= _retryMs) + return Fail($"no teleport after {MaxFires} tries"); + if (!ready || Fires >= MaxFires) + return Step.Wait; + if (Fires > 0 && now - _lastFireAt < _retryMs) + return Step.Wait; + + Fires++; + _lastFireAt = now; + return Step.Fire; + } + + private Step Fail(string why) + { + FailReason = why; + return Step.Failed; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/DataWriteGuard.cs b/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/DataWriteGuard.cs new file mode 100644 index 0000000..f03c5ae --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/DataWriteGuard.cs @@ -0,0 +1,321 @@ +using System; +using System.Collections.Generic; +using System.IO; + +namespace RynthCore.Plugin.RynthAi.Diagnostics; + +/// Why a write in RynthAi's data folders failed (see ). +internal enum WriteFailureKind +{ + /// Windows refused: the folder or file isn't writable for this account, or Controlled folder access blocked acclient.exe. + AccessDenied, + /// The file carries the ReadOnly attribute and it couldn't be cleared. + ReadOnlyFile, + /// Another program holds the file open (editor, sync client, antivirus). + InUse, + DiskFull, + /// A OneDrive (cloud files) placeholder whose sync provider isn't running. + CloudProvider, + /// The folder doesn't exist and couldn't be created. + PathMissing, + Other, +} + +/// +/// Saves of metas, navs, loot profiles and settings profiles (2026-10-13). Players reported +/// that metas and navs "don't save" and that "the plugin folders are read only": every one of +/// those saves swallowed its exception, so a folder the client can't write looked like a save +/// that silently did nothing. Now: +/// - clears the ReadOnly attribute on our own file before it +/// is overwritten (works whenever the folder itself is writable); +/// - says in chat, once per folder per session, what couldn't be saved, +/// where and why (access denied / read-only file / file in use / ...), with the fix (the +/// launcher's Recovery Actions > Fix folder permissions). Every failure is logged +/// (throttled per folder so a failing autosave can't flood the log); +/// - is the startup self-check: it tries to create a file in +/// each data folder. +/// Chat lines are queued here and posted by the plugin tick once the character is in game +/// (), so a failure on any thread, or before login, still shows. +/// +internal static class DataWriteGuard +{ + public const string FixHint = + "Fix: in the RynthCore launcher, Recovery Actions > Fix folder permissions (one administrator prompt)."; + + /// A failing folder logs at most once per this many ms (plus a count of the skipped ones). + public const long LogThrottleMs = 60_000; + + private static readonly object Gate = new(); + private static readonly HashSet ReportedFolders = new(StringComparer.OrdinalIgnoreCase); + private static readonly Dictionary LastLog = new(StringComparer.OrdinalIgnoreCase); + private static readonly Queue PendingChat = new(); + + /// The plugin's log (Initialize sets it). Null: nothing is logged. + public static Action? LogSink; + + /// Milliseconds clock; tests replace it. + internal static Func Clock = () => Environment.TickCount64; + + /// Forgets what was reported (a new session; tests). + public static void Reset() + { + lock (Gate) + { + ReportedFolders.Clear(); + LastLog.Clear(); + PendingChat.Clear(); + } + } + + /// Chat lines waiting to be posted. + public static int PendingCount { get { lock (Gate) return PendingChat.Count; } } + + /// Posts the queued chat lines (plugin tick, in game). + public static void DrainChat(Action chat) + { + while (true) + { + string line; + lock (Gate) + { + if (PendingChat.Count == 0) return; + line = PendingChat.Dequeue(); + } + try { chat(line); } catch { } + } + } + + /// + /// Clears the ReadOnly attribute of an existing file we are about to overwrite. Returns + /// true when it was set and is now cleared. Never throws: when the folder isn't writable + /// either, the write that follows fails and is reported. + /// + public static bool PrepareOverwrite(string path) + { + try + { + if (string.IsNullOrEmpty(path) || !File.Exists(path)) return false; + FileAttributes a = File.GetAttributes(path); + if ((a & FileAttributes.ReadOnly) == 0) return false; + File.SetAttributes(path, a & ~FileAttributes.ReadOnly); + Log($"[RynthAi] {path} was marked read-only; cleared that so it can be saved."); + return true; + } + catch + { + return false; + } + } + + /// + /// Runs for (ReadOnly cleared first). + /// False when it threw; the failure is then reported (). + /// + public static bool TrySave(string what, string path, Action write) => TrySave(what, path, write, out _); + + /// + /// When it failed, the reason and the fix in plain words ("access denied (...). Fix: ..."), else empty. + /// The caller puts the failure in chat itself (an explicit save the + /// player asked for): nothing is queued, the folder still counts as reported. + public static bool TrySave(string what, string path, Action write, out string reason, bool callerShows = false) + { + reason = string.Empty; + try + { + PrepareOverwrite(path); + write(); + return true; + } + catch (Exception ex) + { + reason = Report(what, path, ex, callerShows); + return false; + } + } + + // ERROR_* as HRESULTs (0x8007xxxx). + private const int HrAccessDenied = unchecked((int)0x80070005); + private const int HrWriteProtect = unchecked((int)0x80070013); + private const int HrSharingViolation = unchecked((int)0x80070020); + private const int HrLockViolation = unchecked((int)0x80070021); + private const int HrHandleDiskFull = unchecked((int)0x80070027); + private const int HrDiskFull = unchecked((int)0x80070070); + private const int HrCloudProviderNotRunning = unchecked((int)0x8007016A); + private const int HrCloudNotInSync = unchecked((int)0x80070185); + private const int HrUserMappedFile = unchecked((int)0x800704C8); + + /// What kind of failure is, for a write of . + public static WriteFailureKind Classify(Exception ex, string? path) + { + switch (ex) + { + case UnauthorizedAccessException: + return IsReadOnlyFile(path) ? WriteFailureKind.ReadOnlyFile : WriteFailureKind.AccessDenied; + case DirectoryNotFoundException: + return WriteFailureKind.PathMissing; + case IOException io: + switch (io.HResult) + { + case HrSharingViolation: + case HrLockViolation: + case HrUserMappedFile: + return WriteFailureKind.InUse; + case HrDiskFull: + case HrHandleDiskFull: + return WriteFailureKind.DiskFull; + case HrCloudProviderNotRunning: + case HrCloudNotInSync: + return WriteFailureKind.CloudProvider; + case HrAccessDenied: + case HrWriteProtect: + return IsReadOnlyFile(path) ? WriteFailureKind.ReadOnlyFile : WriteFailureKind.AccessDenied; + } + return WriteFailureKind.Other; + default: + return WriteFailureKind.Other; + } + } + + private static bool IsReadOnlyFile(string? path) + { + try + { + return !string.IsNullOrEmpty(path) && File.Exists(path) + && (File.GetAttributes(path) & FileAttributes.ReadOnly) != 0; + } + catch { return false; } + } + + /// The reason in plain words. + public static string Describe(WriteFailureKind kind, Exception? ex) => kind switch + { + WriteFailureKind.AccessDenied => + "access denied (Windows doesn't let this game client write there: the folder's permissions, " + + "or Windows Security's Controlled folder access blocking acclient.exe)", + WriteFailureKind.ReadOnlyFile => "the file is marked read-only and RynthAi couldn't clear that", + WriteFailureKind.InUse => "the file is open in another program (an editor, OneDrive or backup sync, antivirus)", + WriteFailureKind.DiskFull => "the disk is full", + WriteFailureKind.CloudProvider => "the folder is synced by OneDrive (or another cloud app) that isn't running", + WriteFailureKind.PathMissing => "the folder doesn't exist and couldn't be created", + _ => ex?.Message ?? "unknown error", + }; + + /// What the player can do about it. + public static string Hint(WriteFailureKind kind) => kind switch + { + WriteFailureKind.AccessDenied or WriteFailureKind.ReadOnlyFile or WriteFailureKind.PathMissing => FixHint, + WriteFailureKind.InUse => "Close the program that has it open and save again.", + WriteFailureKind.DiskFull => "Free some disk space and save again.", + WriteFailureKind.CloudProvider => "Start OneDrive, or install RynthSuite outside the synced folder.", + _ => FixHint, + }; + + /// + /// A failed save of ("the meta", "the nav", ...) to + /// : logged (throttled per folder) and, the first time for that + /// folder this session, queued for chat. Returns the reason and the fix in plain words. + /// + public static string Report(string what, string path, Exception ex, bool callerShows = false) + { + WriteFailureKind kind = Classify(ex, path); + string reason = Describe(kind, ex); + string folder = FolderOf(path); + bool chat; + string? logLine = null; + lock (Gate) + { + chat = !AlreadyReported(folder); + ReportedFolders.Add(folder); + long now = Clock(); + if (!LastLog.TryGetValue(folder, out var last) || now - last.At >= LogThrottleMs || chat) + { + string skipped = last.Skipped > 0 ? $" ({last.Skipped} more failure(s) in this folder since the last line)" : ""; + logLine = $"[RynthAi] Save failed: {what} -> {path}: {reason} [{ex.GetType().Name}: {ex.Message}]{skipped}"; + LastLog[folder] = (now, 0); + } + else + { + LastLog[folder] = (last.At, last.Skipped + 1); + } + if (chat && !callerShows) + PendingChat.Enqueue($"[RynthAi] Couldn't save {what} to {path}: {reason}. {Hint(kind)} " + + "(Shown once per folder; later failures there go to the log.)"); + } + if (logLine != null) Log(logLine); + return $"{reason}. {Hint(kind)}"; + } + + /// One data folder the self-check couldn't write. + internal readonly record struct FolderProblem(string Folder, WriteFailureKind Kind, string Reason); + + /// + /// The startup self-check: creates (if missing) and writes a throw-away file in each of + /// . Returns the folders that failed; for those, one line goes + /// to the log and one summary line is queued for chat. + /// + public static List CheckFolders(IEnumerable folders) + { + var problems = new List(); + foreach (string folder in folders) + { + if (string.IsNullOrEmpty(folder)) continue; + string probe = Path.Combine(folder, $".rynthai-write-check-{Environment.ProcessId}-{Guid.NewGuid():N}.tmp"); + try + { + Directory.CreateDirectory(folder); + using (var fs = new FileStream(probe, FileMode.CreateNew, FileAccess.Write, FileShare.None, 1, FileOptions.DeleteOnClose)) + fs.WriteByte(0); + } + catch (Exception ex) + { + WriteFailureKind kind = Classify(ex, null); + problems.Add(new FolderProblem(folder, kind, Describe(kind, ex))); + Log($"[RynthAi] Data folder not writable: {folder}: {Describe(kind, ex)} [{ex.GetType().Name}: {ex.Message}]"); + } + finally + { + try { if (File.Exists(probe)) File.Delete(probe); } catch { } + } + } + + if (problems.Count > 0) + { + lock (Gate) + { + foreach (var p in problems) ReportedFolders.Add(p.Folder); // the save itself needn't repeat it + string list = problems.Count == 1 + ? problems[0].Folder + : $"{problems.Count} folders ({string.Join(", ", problems.ConvertAll(p => Path.GetFileName(p.Folder)))})"; + PendingChat.Enqueue($"[RynthAi] Can't write to {list}: {problems[0].Reason}. Metas, navs, loot and settings " + + $"saved there will NOT be kept. {Hint(problems[0].Kind)}"); + } + } + return problems; + } + + /// This folder, or one it is inside (e.g. SettingsProfiles for a character's folder), was reported. Under Gate. + private static bool AlreadyReported(string folder) + { + foreach (string f in ReportedFolders) + if (folder.Equals(f, StringComparison.OrdinalIgnoreCase) + || folder.StartsWith(f + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase)) + return true; + return false; + } + + /// The folder a failure is counted against. + internal static string FolderOf(string path) + { + try + { + string? dir = Path.GetDirectoryName(path); + return string.IsNullOrEmpty(dir) ? path : dir.TrimEnd('\\', '/'); + } + catch { return path; } + } + + private static void Log(string line) + { + try { LogSink?.Invoke(line); } catch { } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/RynthLog.cs b/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/RynthLog.cs new file mode 100644 index 0000000..6d62f4b --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/RynthLog.cs @@ -0,0 +1,1075 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; +using RynthCore.PluginSdk; +using RynthCore.Install; + +namespace RynthCore.Plugin.RynthAi; + +/// +/// One trace category per RynthAi function. Each category can be traced +/// independently (/ra trace <cat> on) into its own daily file under +/// Logs\Diagnostics\Trace, mirroring UtilityBelt's per-feature trace toggles. +/// +internal enum LogCat +{ + // ── Core / macro systems ─────────────────────────────────────────────── + General, + Commands, + Combat, + Buffing, + Pets, + WorldCache, + Navigation, + Doors, + Jumper, + Looting, + Inventory, + Salvage, + Vendor, + ManaStones, + Meta, + Expressions, + Quests, + Crafting, + Raycast, + Radar, + UI, + Remote, + Chat, + Huds, + + // ── ILT Hub (IltHub/) ────────────────────────────────────────────────── + IltHub, + IltOptions, + IltChat, + IltStore, + IltBanking, + IltPets, + IltQuests, + IltProgression, + IltRates, + IltGear, + IltGames, +} + +/// +/// Persisted diagnostics switches (Logs\Diagnostics\diagnostics.json). +/// Fields (not properties) so the source-generated +/// (IncludeFields) round-trips them without reflection under NativeAOT. +/// +internal sealed class RynthLogConfig +{ + /// Echo trace + exception lines to the in-game chat window (UB's "debug" switch). + public bool DebugToChat; + + /// Mirror every line into the daily RynthAi log file. + public bool FileLogAll = true; + + /// + /// Category names (see ) with tracing enabled. Kept in sync with + /// (every category at Trace or Info); only read when + /// is empty (diagnostics.json written by an older RynthAi). + /// + public List Traces = new(); + + /// + /// Per-category trace level (Off / Trace / Info) for every . Rewritten on + /// every load with the full category list and descriptions so the launcher can edit it. + /// + public List Categories = new(); + + /// Delete diagnostics files older than this many days. + public int RetainDays = 7; + + /// Roll a log file to a new numbered part once it exceeds this size (MB). + public int MaxFileMb = 10; + + /// Keep at most this many files per diagnostics folder (oldest pruned first). + public int MaxFiles = 30; + + /// + /// Per-event log levels for the named key events in . Rewritten on every + /// load with the full catalog (new events at their defaults, fresh descriptions), so the launcher + /// can list and edit every event without its own copy of the catalog. + /// + public List Events = new(); +} + +/// Where a named key event is written (see ). +internal enum LogEventLevel +{ + /// Not recorded at all. + Off = 0, + /// Only in the category trace file, and only while that category is traced. + Trace = 1, + /// Normal log: engine log + daily RynthAi file (+ trace file when traced). + Info = 2, +} + +/// +/// One persisted key-event switch in diagnostics.json. Only is read back; +/// the other fields are informational for the launcher and are refreshed from the catalog on load. +/// +internal sealed class LogEventSetting +{ + /// Stable event id, e.g. "IltHub.Login". + public string Key = string.Empty; + + /// "Info", "Trace" or "Off" (case-insensitive; anything else falls back to the default). + public string Level = nameof(LogEventLevel.Info); + + /// Default level for this event (informational). + public string Default = nameof(LogEventLevel.Info); + + /// Owning name (informational; picks the trace file). + public string Category = string.Empty; + + /// Human-readable description shown by the launcher. + public string Description = string.Empty; +} + +/// +/// One persisted category trace switch in diagnostics.json. decides where +/// the category's lines go: Off → dropped, Trace → the category trace +/// file, Info → the trace file AND the normal log. Normal lines are +/// unaffected. Only is read back. +/// +internal sealed class LogCategorySetting +{ + /// name, e.g. "Combat". + public string Name = string.Empty; + + /// "Off", "Trace" or "Info" (case-insensitive; anything else reads as Off). + public string Level = nameof(LogEventLevel.Off); + + /// Human-readable description shown by the launcher. + public string Description = string.Empty; +} + +/// +/// Catalog of named key events. Each one has its own configurable level, so a milestone like +/// "Hub login" can show in the normal log while the surrounding detail stays trace-only. +/// Add new events here; the launcher picks them up from diagnostics.json automatically. +/// +internal static class LogEvents +{ + // ── ILT Hub ──────────────────────────────────────────────────────────── + public const string IltLogin = "IltHub.Login"; + public const string IltWorldCheck = "IltHub.WorldCheck"; + public const string IltOptionsRefreshStart = "IltHub.OptionsRefreshStart"; + public const string IltOptionsRefreshed = "IltHub.OptionsRefreshed"; + public const string IltWindowShown = "IltHub.WindowShown"; + public const string IltWindowHidden = "IltHub.WindowHidden"; + public const string IltCommand = "IltHub.Command"; + public const string IltConfirmation = "IltHub.Confirmation"; + public const string IltLogout = "IltHub.Logout"; + + /// Catalog entry: key, owning category, default level, launcher description. + internal readonly record struct Definition(string Key, LogCat Category, LogEventLevel Default, string Description); + + /// Every known event, in launcher display order. + internal static readonly Definition[] Catalog = + { + new(IltLogin, LogCat.IltHub, LogEventLevel.Info, "ILT Hub: character logged in (character and world)."), + new(IltWorldCheck, LogCat.IltOptions, LogEventLevel.Info, "ILT Hub: login world check (ILT-like world or skipped)."), + new(IltOptionsRefreshStart, LogCat.IltOptions, LogEventLevel.Trace, "ILT Hub: server options refresh started."), + new(IltOptionsRefreshed, LogCat.IltOptions, LogEventLevel.Info, "ILT Hub: server options refreshed (source and on/off counts)."), + new(IltWindowShown, LogCat.IltHub, LogEventLevel.Info, "ILT: a Mini Remote ILT tab shown."), + new(IltWindowHidden, LogCat.IltHub, LogEventLevel.Trace, "ILT: Mini Remote hidden."), + new(IltCommand, LogCat.IltHub, LogEventLevel.Trace, "ILT Hub: /ra hub and /ra quests commands."), + new(IltConfirmation, LogCat.IltHub, LogEventLevel.Trace, "ILT Hub: chat confirmations requested, confirmed or expired."), + new(IltLogout, LogCat.IltHub, LogEventLevel.Trace, "ILT Hub: logout (features stopped)."), + }; + + /// Launcher description for each trace category. + internal static string DescribeCategory(LogCat cat) => cat switch + { + LogCat.General => "Uncategorised RynthAi lines.", + LogCat.Commands => "/ra chat commands and remote commands.", + LogCat.Combat => "Combat: targeting, attacks, spells, wield gates.", + LogCat.Buffing => "Buffing: buff timers, rebuff decisions, casts.", + LogCat.Pets => "Pet summoning and upkeep.", + LogCat.WorldCache => "World object cache: classification and ownership.", + LogCat.Navigation => "Navigation: routes, waypoints, movement state.", + LogCat.Doors => "Door detection and opening.", + LogCat.Jumper => "Jump commands.", + LogCat.Looting => "Corpse looting and loot rules.", + LogCat.Inventory => "Inventory: AutoStack, AutoCram, equip.", + LogCat.Salvage => "Salvage combining and use.", + LogCat.Vendor => "AutoVendor buy/sell.", + LogCat.ManaStones => "Mana stone use and recharging.", + LogCat.Meta => "Meta (VTank-style) state machine and actions.", + LogCat.Expressions => "Meta expression evaluation.", + LogCat.Quests => "Quest tracking.", + LogCat.Crafting => "Missile ammo crafting.", + LogCat.Raycast => "Line-of-sight raycasts and geometry loading.", + LogCat.Radar => "Radar window.", + LogCat.UI => "RynthAi UI windows and panels.", + LogCat.Remote => "Remote control (launcher/Avalonia commands).", + LogCat.Chat => "Chat parsing and chat diagnostics.", + LogCat.Huds => "Floating HUDs: item counts, Mini Remote, icons.", + LogCat.IltHub => "ILT Hub: window, login/logout, commands.", + LogCat.IltOptions => "ILT Hub: server options.", + LogCat.IltChat => "ILT Hub: chat parsing.", + LogCat.IltStore => "ILT Hub: store.", + LogCat.IltBanking => "ILT Hub: banking.", + LogCat.IltPets => "ILT Hub: pets.", + LogCat.IltQuests => "ILT Hub: quests.", + LogCat.IltProgression => "ILT Hub: progression.", + LogCat.IltRates => "ILT Hub: rates.", + LogCat.IltGear => "ILT Hub: gear.", + LogCat.IltGames => "ILT Hub: games.", + _ => cat.ToString(), + }; +} + +/// +/// Central RynthAi logging / debugging facility, modelled on UtilityBelt's Logger: +/// +/// — normal log line: engine log (as before) + daily rynthai_*.txt +/// + the category trace file when that category is being traced. +/// — verbose line, only recorded when the category is traced; optionally +/// echoed to chat when is on. +/// — full stack trace into exceptions_*.txt with per-signature +/// throttling so a per-frame fault can't fill the disk. +/// +/// Thread-safe: callable from the pump thread, the ImGui render thread and background tasks. +/// Chat echo is queued and drained on the pump thread by . +/// +internal static class RynthLog +{ + /// Default diagnostics root (inside the RynthAi data folder the installer creates). + public static readonly string DefaultDirectory = System.IO.Path.Combine(RynthInstallPaths.RynthAiDir, @"Logs\Diagnostics"); + + // ── Exception throttling (same budgets as UB's Logger) ──────────────── + private static readonly TimeSpan ExceptionBurstWindow = TimeSpan.FromSeconds(5); + private const int MaxExceptionsPerSignaturePerDay = 25; + private const int MaxExceptionsPerDay = 500; + + /// Upper bound on chat echo lines drained per tick (prevents chat floods). + private const int MaxChatLinesPerPump = 20; + + /// Upper bound on queued chat echo lines; extra lines are dropped (files still get them). + private const int MaxQueuedChatLines = 200; + + private static readonly object FileLock = new(); + private static readonly object ConfigLock = new(); + private static readonly Dictionary Writers = new(StringComparer.OrdinalIgnoreCase); + private static readonly Dictionary RollParts = new(StringComparer.OrdinalIgnoreCase); + private static readonly Dictionary ExceptionSignatures = new(); + private static readonly ConcurrentQueue ChatQueue = new(); + + // Per-category trace level as (int)LogEventLevel, indexed by (int)LogCat. Volatile reads are + // enough — changes are rare, reads are hot. Off = not traced, Trace = trace file, Info = trace + // file + normal log. + private static readonly int[] CategoryLevels = new int[Enum.GetValues().Length]; + + // Key-event levels and categories. Replaced wholesale on load (never mutated after publish), + // so hot-path readers on any thread can use them without a lock. + private static volatile Dictionary _eventLevels = BuildDefaultEventLevels(); + private static readonly Dictionary EventCategories = BuildEventCategories(); + + /// How often checks diagnostics.json for edits made by the launcher. + private const long ConfigPollIntervalMs = 2000; + private static long _nextConfigPollAt; + private static DateTime _configStampUtc = DateTime.MinValue; + + private static RynthCoreHost? _host; + private static RynthLogConfig _config = new(); + private static string _directory = DefaultDirectory; + private static string _openDay = string.Empty; + private static int _exceptionsToday; + // The process-wide exception hooks. Kept so Shutdown can take them off again: AppDomain and + // TaskScheduler live in the default context, so a handler left there holds this plugin's + // collectible context, and through it the engine generation, after a hot reload. + private static UnhandledExceptionEventHandler? _unhandledHandler; + private static EventHandler? _unobservedHandler; + private static bool _dirty; + + /// Folder holding rynthai_*.txt, exceptions_*.txt and diagnostics.json. + public static string Directory => _directory; + + /// Folder holding per-category {Category}_*.txt trace files. + public static string TraceDirectory => Path.Combine(_directory, "Trace"); + + /// When true, trace and exception lines are echoed to chat (UB's global debug). + public static bool DebugToChat + { + get => _config.DebugToChat; + set { lock (ConfigLock) { SyncFromDiskIfChanged(); _config.DebugToChat = value; SaveConfig(); } } + } + + /// When true, every line is mirrored to the daily RynthAi log file. + public static bool FileLogAll + { + get => _config.FileLogAll; + set { lock (ConfigLock) { SyncFromDiskIfChanged(); _config.FileLogAll = value; SaveConfig(); } } + } + + /// + /// Binds the logger to the plugin host, loads persisted switches, prunes old files and + /// installs the global unhandled-exception hooks. Safe to call more than once. + /// + public static void Init(RynthCoreHost host, string? directory = null) + { + _host = host; + _directory = string.IsNullOrWhiteSpace(directory) ? DefaultDirectory : directory; + + try + { + System.IO.Directory.CreateDirectory(_directory); + System.IO.Directory.CreateDirectory(TraceDirectory); + } + catch { /* folder is created lazily on first write as a fallback */ } + + // Write the merged catalog back when it changed so the launcher can list every event. + if (LoadConfig()) SaveConfig(); + Prune(); + RegisterGlobalHandlers(); + } + + // ═════════════════════════════════════════════════════════════════════ + // Public logging API + // ═════════════════════════════════════════════════════════════════════ + + /// + /// Normal log line. Always goes to the engine log (unchanged behaviour), plus the daily + /// RynthAi file and — if the category is traced — the category's trace file. + /// lines are re-routed by their "[Prefix]" when one is recognised. + /// + public static void Write(LogCat cat, string message) + { + if (string.IsNullOrEmpty(message)) return; + if (cat == LogCat.General) cat = CategoryFromPrefix(message); + + try { _host?.Log(message); } catch { /* host gone during unload */ } + + if (_config.FileLogAll) + AppendLine(DailyPath(_directory, "rynthai"), $"[{cat}] {message}"); + + if (IsTracing(cat)) + AppendLine(DailyPath(TraceDirectory, cat.ToString()), "INFO " + message); + } + + /// + /// Verbose diagnostic line. Recorded only when is traced, so call + /// sites can trace freely; guard expensive message building with . + /// When the category's level is Info the line is also promoted to the normal log + /// (engine log + daily RynthAi file). + /// + public static void Trace(LogCat cat, string message) + { + if (!IsTracing(cat) || string.IsNullOrEmpty(message)) return; + + AppendLine(DailyPath(TraceDirectory, cat.ToString()), "TRACE " + message); + if (GetCategoryLevel(cat) == LogEventLevel.Info) + { + try { _host?.Log($"[RynthAi:{cat}] {message}"); } catch { /* host gone during unload */ } + if (_config.FileLogAll) + AppendLine(DailyPath(_directory, "rynthai"), $"[{cat}] TRACE {message}"); + } + if (_config.DebugToChat) QueueChat($"[RynthAi:{cat}] {message}"); + } + + /// + /// Records an exception with its full stack trace. A one-line summary always goes to the + /// engine log; the detailed entry is throttled per signature (5 s burst window, + /// 25/signature/day, 500/day total) exactly like UB's Logger.LogException. + /// + public static void Exception(LogCat cat, Exception ex, string context = "") + { + if (ex == null) return; + + string where = string.IsNullOrEmpty(context) ? cat.ToString() : $"{cat}/{context}"; + string summary = $"[RynthAi] {where} error: {ex.GetType().Name}: {ex.Message}"; + try { _host?.Log(summary); } catch { } + + if (!ShouldRecordException(where, ex, out int repeat)) return; + + var sb = new StringBuilder(); + sb.Append("==== ").Append(where); + if (repeat > 1) sb.Append(" (occurrence ").Append(repeat).Append(" today)"); + sb.AppendLine(" ===="); + sb.Append(ex); + AppendLine(DailyPath(_directory, "exceptions"), sb.ToString(), flush: true); + + if (IsTracing(cat)) + AppendLine(DailyPath(TraceDirectory, cat.ToString()), "ERROR " + summary); + if (_config.DebugToChat) QueueChat(summary); + } + + /// + /// Named key event (see ). Its configured level decides where it goes: + /// Info → (normal log), Trace → , Off → dropped. + /// Levels are set per event in diagnostics.json, editable from the launcher. + /// + public static void Event(string eventKey, string message) + { + if (string.IsNullOrEmpty(message)) return; + LogCat cat = EventCategories.TryGetValue(eventKey, out LogCat c) ? c : LogCat.General; + string line = $"[{eventKey}] {message}"; + switch (GetEventLevel(eventKey)) + { + case LogEventLevel.Info: Write(cat, line); break; + case LogEventLevel.Trace: Trace(cat, line); break; + } + } + + /// Configured level for an event; unknown keys default to Info so nothing is silently lost. + public static LogEventLevel GetEventLevel(string eventKey) + => _eventLevels.TryGetValue(eventKey, out LogEventLevel l) ? l : LogEventLevel.Info; + + /// + /// True when would record anything for this key right now. Use it to skip + /// building an expensive message. + /// + public static bool IsEventEnabled(string eventKey) + { + LogEventLevel level = GetEventLevel(eventKey); + if (level == LogEventLevel.Info) return true; + return level == LogEventLevel.Trace + && EventCategories.TryGetValue(eventKey, out LogCat cat) && IsTracing(cat); + } + + /// True when the category is currently being traced (level Trace or Info; cheap; safe on hot paths). + public static bool IsTracing(LogCat cat) => GetCategoryLevel(cat) != LogEventLevel.Off; + + /// Current trace level of a category (Off, Trace or Info). + public static LogEventLevel GetCategoryLevel(LogCat cat) + { + int i = (int)cat; + return (uint)i < (uint)CategoryLevels.Length + ? (LogEventLevel)System.Threading.Volatile.Read(ref CategoryLevels[i]) + : LogEventLevel.Off; + } + + /// Sets a category's trace level and persists the change. + public static void SetCategoryLevel(LogCat cat, LogEventLevel level) + { + int i = (int)cat; + if ((uint)i >= (uint)CategoryLevels.Length) return; + lock (ConfigLock) + { + SyncFromDiskIfChanged(); + System.Threading.Volatile.Write(ref CategoryLevels[i], (int)level); + SaveConfig(); + } + } + + /// + /// Enables/disables tracing for a single category and persists the change. Enabling keeps a + /// category that is already at Info (promoted to the normal log) at Info. + /// + public static void SetTracing(LogCat cat, bool enabled) + { + int i = (int)cat; + if ((uint)i >= (uint)CategoryLevels.Length) return; + lock (ConfigLock) + { + SyncFromDiskIfChanged(); + ApplyTracing(i, enabled); + SaveConfig(); + } + } + + /// Enables/disables tracing for every category whose name starts with (empty = all). + public static int SetTracingByPrefix(string prefix, bool enabled) + { + int changed = 0; + lock (ConfigLock) + { + SyncFromDiskIfChanged(); + foreach (LogCat cat in Enum.GetValues()) + { + if (prefix.Length > 0 && !cat.ToString().StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) continue; + ApplyTracing((int)cat, enabled); + changed++; + } + SaveConfig(); + } + return changed; + } + + /// On → Trace unless already traced; off → Off. + private static void ApplyTracing(int index, bool enabled) + { + int current = System.Threading.Volatile.Read(ref CategoryLevels[index]); + int next = !enabled ? (int)LogEventLevel.Off + : current == (int)LogEventLevel.Off ? (int)LogEventLevel.Trace : current; + System.Threading.Volatile.Write(ref CategoryLevels[index], next); + } + + /// + /// Every category as "Name=Level" joined by ',', in enum order (Level: 0 Off, 1 Trace, 2 Info). + /// The engine Settings panel's Diagnostics tab draws its checkbox grid from this. + /// + public static string FormatCategoryLevels() + { + var sb = new StringBuilder(); + foreach (LogCat cat in Enum.GetValues()) + { + if (sb.Length > 0) sb.Append(','); + sb.Append(cat).Append('=').Append((int)GetCategoryLevel(cat)); + } + return sb.ToString(); + } + + /// + /// Applies a string. Unknown names and bad levels are + /// skipped, categories not listed keep their level, and diagnostics.json is written once, + /// only when something changed. Returns the number of categories changed. + /// + public static int ApplyCategoryLevels(string? levels) + { + if (string.IsNullOrWhiteSpace(levels)) return 0; + int changed = 0; + lock (ConfigLock) + { + SyncFromDiskIfChanged(); + foreach (string entry in levels.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)) + { + int eq = entry.IndexOf('='); + if (eq <= 0 || !TryParseCategory(entry[..eq], out LogCat cat)) continue; + if (!int.TryParse(entry[(eq + 1)..], out int level) || !Enum.IsDefined((LogEventLevel)level)) continue; + int i = (int)cat; + if (System.Threading.Volatile.Read(ref CategoryLevels[i]) == level) continue; + System.Threading.Volatile.Write(ref CategoryLevels[i], level); + changed++; + } + if (changed > 0) SaveConfig(); + } + return changed; + } + + /// Parses a category name case-insensitively (e.g. "ilthub", "Combat"). + public static bool TryParseCategory(string name, out LogCat cat) + => Enum.TryParse(name, ignoreCase: true, out cat) && Enum.IsDefined(cat); + + /// All categories currently being traced. + public static List TracedCategories() + { + var list = new List(); + foreach (LogCat cat in Enum.GetValues()) + if (IsTracing(cat)) list.Add(cat); + return list; + } + + // ═════════════════════════════════════════════════════════════════════ + // Lifecycle + // ═════════════════════════════════════════════════════════════════════ + + /// + /// Pump-thread housekeeping, called once per OnTick: drains queued chat echo lines and + /// flushes buffered file writes so a crash loses at most one tick of log output. + /// + public static void Pump() + { + // RynthCoreHost is a struct; unwrap the nullable copy before calling into it. + if (!ChatQueue.IsEmpty && _host is RynthCoreHost host) + { + for (int n = 0; n < MaxChatLinesPerPump && ChatQueue.TryDequeue(out string? line); n++) + { + try { if (host.HasWriteToChat) host.WriteToChat(line, 1); } catch { } + } + } + + if (_dirty) Flush(); + + // Pick up event-level / trace edits the launcher wrote while the game is running. + long now = Environment.TickCount64; + if (now >= _nextConfigPollAt) + { + _nextConfigPollAt = now + ConfigPollIntervalMs; + ReloadConfigIfChangedOnDisk(); + } + } + + /// Reloads diagnostics.json when its timestamp differs from our last load/save. + private static void ReloadConfigIfChangedOnDisk() + { + try + { + if (!File.Exists(ConfigPath)) return; + if (File.GetLastWriteTimeUtc(ConfigPath) == _configStampUtc) return; + lock (ConfigLock) + { + if (LoadConfig()) SaveConfig(); + } + try { _host?.Log("[RynthAi] diagnostics.json changed on disk - category and event log levels reloaded."); } catch { } + } + catch + { + // A half-written file is retried on the next poll. + } + } + + /// Flushes every open log writer to disk. + public static void Flush() + { + lock (FileLock) + { + foreach (var w in Writers.Values) + { + try { w.Flush(); } catch { } + } + _dirty = false; + } + } + + /// Flushes and closes every log file (plugin unload / logout). + public static void Shutdown() + { + UnregisterGlobalHandlers(); + lock (FileLock) + { + foreach (var w in Writers.Values) + { + try { w.Flush(); w.Dispose(); } catch { } + } + Writers.Clear(); + _dirty = false; + } + } + + /// + /// Deletes diagnostics files older than and trims each + /// folder to . Only touches *.txt files under the + /// diagnostics folders, never other RynthAi data. + /// + public static int Prune() + { + int removed = 0; + lock (FileLock) + { + removed += PruneFolder(_directory); + removed += PruneFolder(TraceDirectory); + } + return removed; + } + + /// Human-readable status lines for /ra trace status and /ra logs. + public static IEnumerable StatusLines() + { + var traced = TracedCategories(); + yield return $"[RynthAi] Debug-to-chat: {(DebugToChat ? "ON" : "off")} File log: {(FileLogAll ? "ON" : "off")}"; + yield return traced.Count == 0 + ? "[RynthAi] Tracing: (none)" + : "[RynthAi] Tracing: " + string.Join(", ", traced); + yield return $"[RynthAi] Logs: {_directory} (retain {_config.RetainDays} d, roll at {_config.MaxFileMb} MB)"; + } + + // ═════════════════════════════════════════════════════════════════════ + // Internals + // ═════════════════════════════════════════════════════════════════════ + + /// + /// Maps the "[Prefix]" convention used by existing plugin log lines onto a category so + /// that, e.g., "[BuffDiag] …" lands in the Buffing trace without touching the call site. + /// + private static LogCat CategoryFromPrefix(string message) + { + if (message.Length < 3 || message[0] != '[') return LogCat.General; + + if (Starts(message, "[Buff")) return LogCat.Buffing; + if (Starts(message, "[MetaCast") || Starts(message, "[Meta")) return LogCat.Meta; + if (Starts(message, "[Combat") || Starts(message, "[WieldGate") || Starts(message, "[Hazard") + || Starts(message, "[Kill") || Starts(message, "[ScanTele") || Starts(message, "[RynthAi combat")) + return LogCat.Combat; + if (Starts(message, "[Equip") || Starts(message, "[RynthAi dumpinv")) return LogCat.Inventory; + if (Starts(message, "[LOS") || Starts(message, "[Raycast") || Starts(message, "[GeoLoader")) return LogCat.Raycast; + if (Starts(message, "[Jumper")) return LogCat.Jumper; + if (Starts(message, "[ChatDiag") || Starts(message, "[RynthChat")) return LogCat.Chat; + if (Starts(message, "[Reclassify") || Starts(message, "[Classify")) return LogCat.WorldCache; + if (Starts(message, "[RynthAi navstate") || Starts(message, "[Nav")) return LogCat.Navigation; + if (Starts(message, "[IltHub")) return LogCat.IltHub; + return LogCat.General; + } + + private static bool Starts(string s, string prefix) => s.StartsWith(prefix, StringComparison.Ordinal); + + /// Builds {folder}\{stem}_yyyy-MM-dd.txt, with a numbered suffix once the day's file has rolled. + private static string DailyPath(string folder, string stem) + { + string key = folder + "|" + stem; + string day = DateTime.Now.ToString("yyyy-MM-dd"); + int part; + lock (FileLock) part = RollParts.TryGetValue(key + "|" + day, out int p) ? p : 0; + string name = part == 0 ? $"{stem}_{day}.txt" : $"{stem}_{day}_{part}.txt"; + return Path.Combine(folder, name); + } + + /// Appends a timestamped line, rolling the file when it passes the size cap. + private static void AppendLine(string path, string text, bool flush = false) + { + try + { + lock (FileLock) + { + RollDayIfNeeded(); + + if (!Writers.TryGetValue(path, out var writer)) + { + writer = OpenWriter(path); + Writers[path] = writer; + } + + writer.Write(DateTime.Now.ToString("HH:mm:ss.fff")); + writer.Write(' '); + writer.WriteLine(text); + _dirty = true; + if (flush) writer.Flush(); + + long cap = Math.Max(1, _config.MaxFileMb) * 1024L * 1024L; + if (writer.BaseStream.Length > cap) Roll(path, writer); + } + } + catch + { + // Logging must never throw into gameplay code (disk full, file locked, etc.). + } + } + + /// + /// Opens the writer for . Each file has one writing process: two + /// clients appending to one file each keep their own end-of-file offset and overwrite each + /// other's lines. When another client already holds the file, this process writes + /// {name}.{pid}.txt beside it instead (the engine's logs are per process the same way). + /// + private static StreamWriter OpenWriter(string path) + { + string folder = Path.GetDirectoryName(path)!; + System.IO.Directory.CreateDirectory(folder); + FileStream stream; + try + { + // FileShare.Read: readers (the launcher, editors) are fine; a second writer is refused. + stream = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Read); + } + catch (IOException) + { + string own = Path.Combine(folder, + $"{Path.GetFileNameWithoutExtension(path)}.{Environment.ProcessId}{Path.GetExtension(path)}"); + stream = new FileStream(own, FileMode.Append, FileAccess.Write, FileShare.Read); + } + return new StreamWriter(stream, new UTF8Encoding(false)) { AutoFlush = false }; + } + + /// Closes an oversized file and bumps its part number so the next write opens a fresh file. + private static void Roll(string path, StreamWriter writer) + { + try { writer.Flush(); writer.Dispose(); } catch { } + Writers.Remove(path); + + string file = Path.GetFileNameWithoutExtension(path); + string day = DateTime.Now.ToString("yyyy-MM-dd"); + int idx = file.IndexOf("_" + day, StringComparison.Ordinal); + string stem = idx > 0 ? file[..idx] : file; + string key = Path.GetDirectoryName(path) + "|" + stem + "|" + day; + RollParts[key] = (RollParts.TryGetValue(key, out int p) ? p : 0) + 1; + } + + /// Closes yesterday's writers at midnight so new lines go to the new day's files. + private static void RollDayIfNeeded() + { + string day = DateTime.Now.ToString("yyyy-MM-dd"); + if (day == _openDay) return; + + foreach (var w in Writers.Values) + { + try { w.Flush(); w.Dispose(); } catch { } + } + Writers.Clear(); + RollParts.Clear(); + ExceptionSignatures.Clear(); + _exceptionsToday = 0; + _openDay = day; + } + + /// Per-signature exception throttle (UB budgets). Returns false when the entry should be skipped. + private static bool ShouldRecordException(string where, Exception ex, out int occurrence) + { + occurrence = 0; + lock (FileLock) + { + RollDayIfNeeded(); + if (_exceptionsToday >= MaxExceptionsPerDay) return false; + + string topFrame = ex.StackTrace?.Split('\n')[0].Trim() ?? string.Empty; + string signature = $"{where}|{ex.GetType().FullName}|{topFrame}"; + DateTime now = DateTime.Now; + + if (ExceptionSignatures.TryGetValue(signature, out var seen)) + { + if (seen.count >= MaxExceptionsPerSignaturePerDay) return false; + // Repeats inside the burst window are dropped: a per-frame fault yields one entry per window. + if (now - seen.lastAt < ExceptionBurstWindow) return false; + occurrence = seen.count + 1; + } + else + { + occurrence = 1; + } + + ExceptionSignatures[signature] = (now, occurrence); + _exceptionsToday++; + return true; + } + } + + /// Hooks AppDomain / TaskScheduler so faults outside our try/catch blocks are still recorded. + private static void RegisterGlobalHandlers() + { + if (_unhandledHandler != null) return; + + _unhandledHandler = (_, e) => + { + if (e.ExceptionObject is Exception ex) Exception(LogCat.General, ex, "UnhandledException"); + Flush(); + }; + _unobservedHandler = (_, e) => + { + Exception(LogCat.General, e.Exception, "UnobservedTaskException"); + e.SetObserved(); + }; + AppDomain.CurrentDomain.UnhandledException += _unhandledHandler; + TaskScheduler.UnobservedTaskException += _unobservedHandler; + } + + /// + /// Takes the hooks off again (plugin shutdown). Without this every hot reload leaked the + /// whole engine generation: the shim logged "Engine gen N NOT unloaded" (2026-10-12). + /// + private static void UnregisterGlobalHandlers() + { + if (_unhandledHandler != null) AppDomain.CurrentDomain.UnhandledException -= _unhandledHandler; + if (_unobservedHandler != null) TaskScheduler.UnobservedTaskException -= _unobservedHandler; + _unhandledHandler = null; + _unobservedHandler = null; + } + + /// Queues a chat echo line for the pump thread (WriteToChat is not render-thread safe). + private static void QueueChat(string line) + { + if (ChatQueue.Count < MaxQueuedChatLines) ChatQueue.Enqueue(line); + } + + /// Removes old/excess *.txt files from one diagnostics folder. Caller holds . + private static int PruneFolder(string folder) + { + int removed = 0; + try + { + if (!System.IO.Directory.Exists(folder)) return 0; + + var files = new List(new DirectoryInfo(folder).GetFiles("*.txt")); + files.Sort((a, b) => b.LastWriteTimeUtc.CompareTo(a.LastWriteTimeUtc)); // newest first + DateTime cutoff = DateTime.UtcNow.AddDays(-Math.Max(1, _config.RetainDays)); + + for (int i = 0; i < files.Count; i++) + { + var f = files[i]; + bool tooOld = f.LastWriteTimeUtc < cutoff; + bool overCount = i >= Math.Max(5, _config.MaxFiles); + if (!tooOld && !overCount) continue; + if (Writers.ContainsKey(f.FullName)) continue; // never delete a file we're writing + + try { f.Delete(); removed++; } catch { } + } + } + catch { } + return removed; + } + + private static string ConfigPath => Path.Combine(_directory, "diagnostics.json"); + + /// + /// Loads persisted switches; missing or corrupt files fall back to defaults. Merges the event + /// catalog into and returns true when that changed the + /// config (new events, refreshed descriptions, dropped stale keys), so the caller can save it. + /// + private static bool LoadConfig() + { + lock (ConfigLock) + { + try + { + if (File.Exists(ConfigPath)) + { + _configStampUtc = File.GetLastWriteTimeUtc(ConfigPath); + string json = File.ReadAllText(ConfigPath); + _config = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.RynthLogConfig) ?? new RynthLogConfig(); + } + } + catch + { + _config = new RynthLogConfig(); + } + + _config.Traces ??= new List(); + bool categoriesChanged = MergeCategoryLevels(); + bool eventsChanged = MergeEventCatalog(); + return categoriesChanged || eventsChanged; + } + } + + /// + /// Publishes the per-category levels from (or, for a file + /// from an older RynthAi with no Categories list, from ) and + /// rebuilds the Categories list in enum order with fresh descriptions. Returns true when the + /// persisted list needs rewriting. Caller holds . + /// + private static bool MergeCategoryLevels() + { + var levels = new int[CategoryLevels.Length]; + bool fromCategories = _config.Categories != null && _config.Categories.Count > 0; + + if (fromCategories) + { + foreach (LogCategorySetting s in _config.Categories!) + { + if (s == null || !TryParseCategory(s.Name, out LogCat cat)) continue; + if (Enum.TryParse(s.Level, ignoreCase: true, out LogEventLevel lvl) && Enum.IsDefined(lvl)) + levels[(int)cat] = (int)lvl; + } + } + else + { + foreach (string name in _config.Traces) + if (TryParseCategory(name, out LogCat cat)) levels[(int)cat] = (int)LogEventLevel.Trace; + } + + for (int i = 0; i < levels.Length; i++) + System.Threading.Volatile.Write(ref CategoryLevels[i], levels[i]); + + List rows = BuildCategoryRows(); + bool changed = !fromCategories || _config.Categories!.Count != rows.Count; + for (int i = 0; !changed && i < rows.Count; i++) + { + LogCategorySetting? old = _config.Categories![i]; + if (old == null || old.Name != rows[i].Name || old.Level != rows[i].Level || old.Description != rows[i].Description) + changed = true; + } + _config.Categories = rows; + return changed; + } + + /// Snapshot of the live category levels as persisted rows, in enum order. + private static List BuildCategoryRows() + { + var rows = new List(CategoryLevels.Length); + foreach (LogCat cat in Enum.GetValues()) + { + rows.Add(new LogCategorySetting + { + Name = cat.ToString(), + Level = GetCategoryLevel(cat).ToString(), + Description = LogEvents.DescribeCategory(cat), + }); + } + return rows; + } + + /// + /// Rebuilds in catalog order, keeping each saved level and + /// publishing the live level table. Returns true when the persisted list needs rewriting. + /// + private static bool MergeEventCatalog() + { + var saved = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (LogEventSetting e in _config.Events ?? new List()) + if (e != null && !string.IsNullOrEmpty(e.Key)) saved[e.Key] = e; + + bool changed = (_config.Events?.Count ?? 0) != LogEvents.Catalog.Length; + var merged = new List(LogEvents.Catalog.Length); + var levels = new Dictionary(StringComparer.OrdinalIgnoreCase); + + foreach (LogEvents.Definition def in LogEvents.Catalog) + { + LogEventLevel level = def.Default; + if (saved.TryGetValue(def.Key, out LogEventSetting? s) + && Enum.TryParse(s.Level, ignoreCase: true, out LogEventLevel parsed) && Enum.IsDefined(parsed)) + level = parsed; + else + changed = true; // new event, or an unreadable level reset to its default + + var row = new LogEventSetting + { + Key = def.Key, + Level = level.ToString(), + Default = def.Default.ToString(), + Category = def.Category.ToString(), + Description = def.Description, + }; + if (s == null || s.Level != row.Level || s.Default != row.Default + || s.Category != row.Category || s.Description != row.Description) + changed = true; + + merged.Add(row); + levels[def.Key] = level; + } + + _config.Events = merged; + _eventLevels = levels; + return changed; + } + + /// Default level table, used until diagnostics.json has been loaded. + private static Dictionary BuildDefaultEventLevels() + { + var d = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (LogEvents.Definition def in LogEvents.Catalog) d[def.Key] = def.Default; + return d; + } + + /// Event key → owning category (fixed by the catalog). + private static Dictionary BuildEventCategories() + { + var d = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (LogEvents.Definition def in LogEvents.Catalog) d[def.Key] = def.Category; + return d; + } + + /// + /// Persists the current switches (trace set and category rows are rebuilt from the live levels). + /// Mutators call first, so a launcher edit made since our + /// last load is adopted before this write rather than silently reverted. + /// + private static void SaveConfig() + { + // Toggles come from both the pump thread (/ra trace) and the render thread (Diagnostics tab). + lock (ConfigLock) + { + try + { + _config.Traces = TracedCategories().ConvertAll(c => c.ToString()); + _config.Categories = BuildCategoryRows(); + System.IO.Directory.CreateDirectory(_directory); + File.WriteAllText(ConfigPath, JsonSerializer.Serialize(_config, RynthAiJsonContext.Default.RynthLogConfig)); + _configStampUtc = File.GetLastWriteTimeUtc(ConfigPath); + } + catch { } + } + } + + /// + /// Reloads diagnostics.json when the launcher has written it since our last load/save, so the + /// mutation that follows starts from the launcher's values. Caller holds . + /// + private static void SyncFromDiskIfChanged() + { + try + { + if (File.Exists(ConfigPath) && File.GetLastWriteTimeUtc(ConfigPath) != _configStampUtc) + LoadConfig(); + } + catch + { + // Unreadable file: keep our in-memory switches. + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/DungeonHazardStore.cs b/Plugins/RynthCore.Plugin.RynthAi/DungeonHazardStore.cs index 2ad95ea..9664dff 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/DungeonHazardStore.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/DungeonHazardStore.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; +using RynthCore.Install; namespace RynthCore.Plugin.RynthAi; diff --git a/Plugins/RynthCore.Plugin.RynthAi/DungeonHazardSurfaces.cs b/Plugins/RynthCore.Plugin.RynthAi/DungeonHazardSurfaces.cs index 32d0cd6..a081f6c 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/DungeonHazardSurfaces.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/DungeonHazardSurfaces.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using RynthCore.Plugin.RynthAi.Raycasting; +using RynthCore.Install; namespace RynthCore.Plugin.RynthAi; diff --git a/Plugins/RynthCore.Plugin.RynthAi/DungeonPathfinder.Rooms.cs b/Plugins/RynthCore.Plugin.RynthAi/DungeonPathfinder.Rooms.cs index 79a2b64..76bf7ad 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/DungeonPathfinder.Rooms.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/DungeonPathfinder.Rooms.cs @@ -55,7 +55,9 @@ internal static partial class DungeonPathfinder // castles most approach/exit points in short bend and junction cells sat on the bend's // outer wall (Rithwic Crypt: 440 of 488 under 0.25 m), and a dead end's look-in point is // its cell origin, which is inside the end cap. - internal const double WallClearance = 1.0; + // The patrol's is a setting (DungeonPatrolOptions.WallClearance, Settings "Distance From + // Walls"); this default is what dunnav paths and recovery detours always use. + internal const double WallClearance = DungeonPatrolOptions.WallClearanceDefault; // How far a point may be pushed off where its rule put it to get that clearance. private const double DoorwayPushMax = 2.0, CornerPushMax = 1.5, MiddlePushMax = 4.5; @@ -176,7 +178,7 @@ internal static partial class DungeonPathfinder /// private static NavRouteParser? BuildRoomPatrol( Dictionary graph, uint startCell, HashSet mainRoute, - IReadOnlySet? hazardCells, DungeonGeometry geo) + IReadOnlySet? hazardCells, DungeonGeometry geo, DungeonPatrolOptions o) { var rooms = BuildRooms(graph, geo, hazardCells); var patrolRooms = new HashSet(); @@ -255,7 +257,7 @@ internal static partial class DungeonPathfinder var steps = new List(walk.Count); foreach (var e in walk) steps.Add(new Step(e.From, e.To, e.Key)); var route = new NavRouteParser { RouteType = NavRouteType.Circular }; - route.Points.AddRange(EmitSteps(graph, geo, rooms, steps, closed: true, null, 0, null, 0, out _)); + route.Points.AddRange(EmitSteps(graph, geo, rooms, steps, closed: true, null, 0, null, 0, o, out _)); return route; } @@ -333,7 +335,8 @@ internal static partial class DungeonPathfinder if (cellPath.Count == 0) return pts; var start = WorldPoint(DungeonGeometry.NavToWorld(startEW), DungeonGeometry.NavToWorld(startNS), startZ, false); var dest = WorldPoint(DungeonGeometry.NavToWorld(destEW), DungeonGeometry.NavToWorld(destNS), destZ, false); - return EmitSteps(graph, geo, rooms, steps, closed: false, start, cellPath[0], dest, cellPath[cellPath.Count - 1], out doorways); + return EmitSteps(graph, geo, rooms, steps, closed: false, start, cellPath[0], dest, cellPath[cellPath.Count - 1], + DungeonPatrolOptions.Default, out doorways); } // ── Laying points along doorway steps ──────────────────────────────────── @@ -353,15 +356,16 @@ internal static partial class DungeonPathfinder /// private static List EmitSteps( Dictionary graph, DungeonGeometry geo, DungeonRooms rooms, List steps, bool closed, - NavPoint? start, uint startCell, NavPoint? dest, uint destCell, out int doorways) + NavPoint? start, uint startCell, NavPoint? dest, uint destCell, DungeonPatrolOptions o, out int doorways) { doorways = 0; var pts = new List(); + double wall = o.WallClearance; if (steps.Count == 0) { if (start != null && dest != null && rooms.RoomOf.TryGetValue(startCell, out int r0)) - CrossRoom(pts, graph, geo, rooms, r0, start, startCell, dest, destCell, revisit: false); + CrossRoom(pts, graph, geo, rooms, r0, start, startCell, dest, destCell, revisit: false, wall); return pts; } @@ -383,14 +387,14 @@ internal static partial class DungeonPathfinder int j = i; while (j + 1 < steps.Count && Continues(geo, steps[j], steps[j + 1])) j++; - RunPoints(graph, geo, rooms, steps, i, j, out var approach, out var middle, out var exit, out bool narrow); + RunPoints(graph, geo, rooms, steps, i, j, wall, out var approach, out var middle, out var exit, out bool narrow); if (narrow) doorways++; if (prev != null) { // Only the patrol looks into rooms; a path to somewhere (dunnav, a detour) doesn't. string? why = null; - bool revisit = i > 0 && (closed ? LooksIn(graph, rooms, lookedInto, steps[i - 1], steps[i], prev, approach, out why) : steps[i - 1].Key == steps[i].Key); - CrossRoom(pts, graph, geo, rooms, rooms.RoomOf[steps[i].From], prev, prevCell, approach, steps[i].From, revisit, why); + bool revisit = i > 0 && (closed ? LooksIn(graph, rooms, lookedInto, steps[i - 1], steps[i], prev, approach, o.LookInRoomMeters, out why) : steps[i - 1].Key == steps[i].Key); + CrossRoom(pts, graph, geo, rooms, rooms.RoomOf[steps[i].From], prev, prevCell, approach, steps[i].From, revisit, wall, why); } else firstApproach = approach; Append(pts, approach); @@ -403,14 +407,14 @@ internal static partial class DungeonPathfinder if (closed && firstApproach != null && prev != null) { - bool revisit = LooksIn(graph, rooms, lookedInto, steps[steps.Count - 1], steps[0], prev, firstApproach, out string why); - CrossRoom(pts, graph, geo, rooms, rooms.RoomOf[steps[0].From], prev, prevCell, firstApproach, steps[0].From, revisit, why); + bool revisit = LooksIn(graph, rooms, lookedInto, steps[steps.Count - 1], steps[0], prev, firstApproach, o.LookInRoomMeters, out string why); + CrossRoom(pts, graph, geo, rooms, rooms.RoomOf[steps[0].From], prev, prevCell, firstApproach, steps[0].From, revisit, wall, why); } if (!closed && dest != null && prev != null && rooms.RoomOf.TryGetValue(destCell, out int rd)) - CrossRoom(pts, graph, geo, rooms, rd, prev, prevCell, dest, destCell, revisit: false); + CrossRoom(pts, graph, geo, rooms, rd, prev, prevCell, dest, destCell, revisit: false, wall); DropCollinear(pts, closed); - KeepLegsOffWalls(geo, pts, closed); + KeepLegsOffWalls(geo, pts, closed, wall); return pts; } @@ -426,19 +430,19 @@ internal static partial class DungeonPathfinder /// across a corner), a corner is put in: the leg's tightest spot, pushed off the wall, /// kept only when both new legs are clearer than the old one. /// - internal static void KeepLegsOffWalls(DungeonGeometry geo, List pts, bool closed) + internal static void KeepLegsOffWalls(DungeonGeometry geo, List pts, bool closed, double wall = WallClearance) { int budget = pts.Count / 2 + 8, perLeg = 0; int i = 0; while (i < (closed ? pts.Count : pts.Count - 1) && pts.Count >= 2) { var a = pts[i]; var b = pts[(i + 1) % pts.Count]; - double least = LegLeast(geo, a, b, out double wx, out double wy, out double wz); - double target = Math.Min(LegMinClearance, Math.Min(PointClearance(geo, a), PointClearance(geo, b))); + double least = LegLeast(geo, a, b, wall, out double wx, out double wy, out double wz); + double target = Math.Min(Math.Min(LegMinClearance, wall), Math.Min(PointClearance(geo, a, wall), PointClearance(geo, b, wall))); if (least >= target - 0.05 || budget <= 0 || perLeg >= 3) { i++; perLeg = 0; continue; } // The corner leaving both new legs clearest, if that is clearly better. - NavPoint? best = BestCorner(geo, a, b, wx, wy, wz, least + 0.1, out _); + NavPoint? best = BestCorner(geo, a, b, wx, wy, wz, least + 0.1, wall, out _); if (best != null) { pts.Insert(i + 1, Tag(best, "leg-corner")); @@ -448,11 +452,11 @@ internal static partial class DungeonPathfinder // No one corner does it (a jog round two corners): a first corner the walk reaches // clear, then the best corner for the rest. bool two = false; - foreach (var first in CornerCandidates(geo, wx, wy, wz)) + foreach (var first in CornerCandidates(geo, wx, wy, wz, wall)) { - if (LegLeast(geo, a, first, out _, out _, out _) < target - 0.05 || TurnsBack(a, first, b)) continue; - double rest = LegLeast(geo, first, b, out double rx, out double ry, out double rz); - var second = BestCorner(geo, first, b, rx, ry, rz, Math.Max(rest, least) + 0.1, out double m2); + if (LegLeast(geo, a, first, wall, out _, out _, out _) < target - 0.05 || TurnsBack(a, first, b)) continue; + double rest = LegLeast(geo, first, b, wall, out double rx, out double ry, out double rz); + var second = BestCorner(geo, first, b, rx, ry, rz, Math.Max(rest, least) + 0.1, wall, out double m2); if (second == null || m2 <= least + 0.1) continue; pts.Insert(i + 1, Tag(first, "leg-corner")); pts.Insert(i + 2, Tag(second, "leg-corner")); @@ -468,10 +472,10 @@ internal static partial class DungeonPathfinder // Corners to try for a leg whose tightest spot is (wx, wy, wz): that spot pushed off the // wall, and the centres of the openings near it (a leg that jogs through the wrong side of a // junction needs the opening it skipped). - private static List CornerCandidates(DungeonGeometry geo, double wx, double wy, double wz) + private static List CornerCandidates(DungeonGeometry geo, double wx, double wy, double wz, double wall) { double cx = wx, cy = wy; - geo.PushClear(ref cx, ref cy, wz, WallClearance, LegCornerPushMax); + geo.PushClear(ref cx, ref cy, wz, wall, LegCornerPushMax); var list = new List { WorldPoint(cx, cy, wz, false) }; foreach (var d in geo.DoorwaysNear(wx, wy, wz, LegCornerSearch)) list.Add(WorldPoint(d.X, d.Y, d.Z, false)); return list; @@ -479,15 +483,15 @@ internal static partial class DungeonPathfinder // The candidate leaving both new legs a-corner-b clearest, if better than mustBeat. private static NavPoint? BestCorner(DungeonGeometry geo, NavPoint a, NavPoint b, double wx, double wy, double wz, - double mustBeat, out double bestMin) + double mustBeat, double wall, out double bestMin) { NavPoint? best = null; bestMin = mustBeat; - foreach (var corner in CornerCandidates(geo, wx, wy, wz)) + foreach (var corner in CornerCandidates(geo, wx, wy, wz, wall)) { - if (PointClearance(geo, corner) <= mustBeat) continue; + if (PointClearance(geo, corner, wall) <= mustBeat) continue; if (TurnsBack(a, corner, b)) continue; - double m = Math.Min(LegLeast(geo, a, corner, out _, out _, out _), LegLeast(geo, corner, b, out _, out _, out _)); + double m = Math.Min(LegLeast(geo, a, corner, wall, out _, out _, out _), LegLeast(geo, corner, b, wall, out _, out _, out _)); if (m > bestMin) { bestMin = m; best = corner; } } return best; @@ -504,30 +508,30 @@ internal static partial class DungeonPathfinder return (ux * vx + uy * vy) / (lu * lv) < Math.Cos(120.0 * Math.PI / 180.0); } - private static double LegLeast(DungeonGeometry geo, NavPoint a, NavPoint b, out double wx, out double wy, out double wz) + private static double LegLeast(DungeonGeometry geo, NavPoint a, NavPoint b, double wall, out double wx, out double wy, out double wz) => geo.LegClearance(DungeonGeometry.NavToWorld(a.EW), DungeonGeometry.NavToWorld(a.NS), a.Z * 240.0, DungeonGeometry.NavToWorld(b.EW), DungeonGeometry.NavToWorld(b.NS), b.Z * 240.0, - WallClearance, LegEndSkip, out wx, out wy, out wz); + wall, LegEndSkip, out wx, out wy, out wz); - private static double PointClearance(DungeonGeometry geo, NavPoint p) - => geo.ClearanceMemo(DungeonGeometry.NavToWorld(p.EW), DungeonGeometry.NavToWorld(p.NS), p.Z * 240.0, WallClearance + 0.5); + private static double PointClearance(DungeonGeometry geo, NavPoint p, double wall) + => geo.ClearanceMemo(DungeonGeometry.NavToWorld(p.EW), DungeonGeometry.NavToWorld(p.NS), p.Z * 240.0, wall + 0.5); - // A big room (its cells spread over 10 m or more) left again close to where it was entered is looked into: a + // A big room (its cells spread over 10 m or more by default: DungeonPatrolOptions.LookInRoomMeters, + // Settings "Walk Into Rooms From") left again close to where it was entered is looked into: a // walk to its middle and back. A straight crossing to a nearby opening would only skirt // it (the patrol hunts; the old cell walk went all round such rooms). Also any room left // by the opening it was entered by. - private const double LookInMinSpreadMeters = 10.0; private const double LookInMaxSkirtMeters = 8.0; // Once per room per lap: a hub room with many doorways was otherwise walked to its middle // again every time the patrol passed between two of its doorways. private static bool LooksIn(Dictionary graph, DungeonRooms rooms, HashSet lookedInto, - Step inStep, Step outStep, NavPoint entered, NavPoint leaving, out string why) + Step inStep, Step outStep, NavPoint entered, NavPoint leaving, double lookInMeters, out string why) { why = "cross"; if (!rooms.RoomOf.TryGetValue(outStep.From, out int r)) return false; double spread = RoomSpreadMeters(graph, rooms.Cells[r]); - bool big = spread >= LookInMinSpreadMeters; + bool big = spread >= lookInMeters; bool sameDoor = inStep.Key == outStep.Key; double skirt = NavPointYd(entered, leaving); bool look = (sameDoor && (big || rooms.Cells[r].Count == 1)) @@ -548,7 +552,7 @@ internal static partial class DungeonPathfinder // The diagonal of the box round a room's cell origins: 0 for the pieces of one junction // (several cells, one origin), 28 m for a 3x3 room of 10 m cells. - private static double RoomSpreadMeters(Dictionary graph, List cells) + internal static double RoomSpreadMeters(Dictionary graph, List cells) { double minN = double.MaxValue, maxN = double.MinValue, minE = double.MaxValue, maxE = double.MinValue; foreach (uint c in cells) @@ -582,18 +586,18 @@ internal static partial class DungeonPathfinder // The approach point before steps[i], the exit point after steps[j], and the opening centres // between them when the run turns (more than 25 degrees between openings). private static void RunPoints(Dictionary graph, DungeonGeometry geo, DungeonRooms rooms, - List steps, int i, int j, + List steps, int i, int j, double wall, out NavPoint approach, out List middle, out NavPoint exit, out bool narrow) { middle = new List(); if (i == j) { - if (!DoorwayPoints(graph, geo, rooms, steps[i].From, steps[i].To, out approach, out exit, out narrow)) narrow = false; + if (!DoorwayPoints(graph, geo, rooms, steps[i].From, steps[i].To, wall, out approach, out exit, out narrow)) narrow = false; return; } - DoorwayPoints(graph, geo, rooms, steps[i].From, steps[i].To, out approach, out _, out bool n0); - DoorwayPoints(graph, geo, rooms, steps[j].From, steps[j].To, out _, out exit, out bool n1); + DoorwayPoints(graph, geo, rooms, steps[i].From, steps[i].To, wall, out approach, out _, out bool n0); + DoorwayPoints(graph, geo, rooms, steps[j].From, steps[j].To, wall, out _, out exit, out bool n1); narrow = n0 || n1; var doors = new List<(DungeonDoorway Door, uint From, int Step)>(); for (int k = i; k <= j; k++) @@ -621,7 +625,7 @@ internal static partial class DungeonPathfinder var m = Note(Tag(WorldPoint(d.X, d.Y, d.Z, !d.IsWide), "run-opening"), steps[k].From, steps[k].From, steps[k].To, "doorway-run"); if (prevM != null && k == prevStep + 1 && rooms.RoomOf.TryGetValue(steps[prevStep].To, out int ra) && rooms.RoomOf.TryGetValue(steps[k].From, out int rb) && ra == rb) - PullThrough(middle, graph, geo, rooms, rooms.Cells[ra], prevM, steps[prevStep].To, m, steps[k].From); + PullThrough(middle, graph, geo, rooms, rooms.Cells[ra], prevM, steps[prevStep].To, m, steps[k].From, wall); Append(middle, m); prevM = m; prevStep = k; @@ -639,15 +643,15 @@ internal static partial class DungeonPathfinder /// NavPoint.Doorway). Unknown openings fall back to the old 30% / 50% points. /// private static bool DoorwayPoints(Dictionary graph, DungeonGeometry geo, DungeonRooms rooms, - uint a, uint b, out NavPoint approach, out NavPoint exit, out bool narrow) + uint a, uint b, double wall, out NavPoint approach, out NavPoint exit, out bool narrow) { narrow = false; if (geo.TryGetDoorway(a, b, out var d)) { var (nx, ny) = d.NormalFrom(a); narrow = !d.IsWide; - approach = Note(Tag(DoorwayPoint(geo, rooms, a, d, -nx, -ny, narrow), "approach"), a, a, b, "doorway"); - exit = Note(Tag(DoorwayPoint(geo, rooms, b, d, nx, ny, narrow), "exit"), b, a, b, "doorway"); + approach = Note(Tag(DoorwayPoint(geo, rooms, a, d, -nx, -ny, narrow, wall), "approach"), a, a, b, "doorway"); + exit = Note(Tag(DoorwayPoint(geo, rooms, b, d, nx, ny, narrow, wall), "exit"), b, a, b, "doorway"); return true; } @@ -656,8 +660,8 @@ internal static partial class DungeonPathfinder approach = Tag(new NavPoint { Type = NavPointType.Point, NS = na.NS + dNS * 0.3, EW = na.EW + dEW * 0.3, Z = (na.Z + dZ * 0.3) / 240.0 }, "cell-fallback"); exit = Tag(new NavPoint { Type = NavPointType.Point, NS = na.NS + dNS * 0.5, EW = na.EW + dEW * 0.5, Z = (na.Z + dZ * 0.5) / 240.0 }, "cell-fallback"); Note(approach, a, a, b, "doorway(no-opening)"); Note(exit, 0, a, b, "doorway(no-opening)"); - PushOffWalls(geo, approach, RoomCells(rooms, a), CornerPushMax); - PushOffWalls(geo, exit, null, CornerPushMax); // on the line between the two rooms + PushOffWalls(geo, approach, RoomCells(rooms, a), CornerPushMax, wall); + PushOffWalls(geo, exit, null, CornerPushMax, wall); // on the line between the two rooms return false; } @@ -669,12 +673,12 @@ internal static partial class DungeonPathfinder /// (in a corridor too narrow for the clearance, onto its middle). /// private static NavPoint DoorwayPoint(DungeonGeometry geo, DungeonRooms rooms, uint cell, DungeonDoorway d, - double dirX, double dirY, bool narrow) + double dirX, double dirY, bool narrow, double wall) { var cells = RoomCells(rooms, cell); - double s = PickStandoff(geo, cells, d, dirX, dirY, out double clearance); + double s = PickStandoff(geo, cells, d, dirX, dirY, out double clearance, wall); var p = WorldPoint(d.X + dirX * s, d.Y + dirY * s, d.Z, narrow); - if (clearance < WallClearance) PushOffWalls(geo, p, cells, DoorwayPushMax); + if (clearance < wall) PushOffWalls(geo, p, cells, DoorwayPushMax, wall); return p; } @@ -684,7 +688,7 @@ internal static partial class DungeonPathfinder // The longest standoff whose point is on the floor of the cell's room with WallClearance; // else the one with the most clearance (the longer of near ties); else the shortest. internal static double PickStandoff(DungeonGeometry geo, IReadOnlyCollection cells, DungeonDoorway d, - double dirX, double dirY, out double clearance) + double dirX, double dirY, out double clearance, double wall = WallClearance) { double bestS = -1; clearance = 0; @@ -692,20 +696,21 @@ internal static partial class DungeonPathfinder { double px = d.X + dirX * s, py = d.Y + dirY * s; if (!geo.OnFloorOfAny(cells, px, py, d.Z)) continue; - double c = geo.ClearanceMemo(px, py, d.Z, WallClearance + 0.5); - if (c >= WallClearance) { clearance = c; return s; } + double c = geo.ClearanceMemo(px, py, d.Z, wall + 0.5); + if (c >= wall) { clearance = c; return s; } if (bestS < 0 || c > clearance + 0.05) { bestS = s; clearance = c; } } return bestS > 0 ? bestS : DoorwayStandoffShortest; } - /// Moves a point (in place) to WallClearance from walls and floor edges, at most - /// , staying on the floor of when given. - private static void PushOffWalls(DungeonGeometry geo, NavPoint p, IReadOnlyCollection? cells, double maxMove) + /// Moves a point (in place) to (the patrol's wall distance, + /// WallClearance by default) from walls and floor edges, at most , + /// staying on the floor of when given. + private static void PushOffWalls(DungeonGeometry geo, NavPoint p, IReadOnlyCollection? cells, double maxMove, double wall) { double x = DungeonGeometry.NavToWorld(p.EW), y = DungeonGeometry.NavToWorld(p.NS); double ox = x, oy = y; - geo.PushClear(ref x, ref y, p.Z * 240.0, WallClearance, maxMove, cells); + geo.PushClear(ref x, ref y, p.Z * 240.0, wall, maxMove, cells); if (x == ox && y == oy) return; p.EW = DungeonGeometry.WorldToNav(x); p.NS = DungeonGeometry.WorldToNav(y); @@ -721,26 +726,26 @@ internal static partial class DungeonPathfinder /// private static void CrossRoom(List pts, Dictionary graph, DungeonGeometry geo, DungeonRooms rooms, int room, NavPoint from, uint fromCell, NavPoint to, uint toCell, - bool revisit, string? why = null) + bool revisit, double wall, string? why = null) { var cells = rooms.Cells[room]; Trace?.Invoke($"cross room {room} ({cells.Count}) revisit={revisit} from={fromCell:X8} to={toCell:X8}"); if (revisit) { - var mid = RoomMiddle(graph, geo, cells, out uint midCell); + var mid = RoomMiddle(graph, geo, cells, wall, out uint midCell); if (mid != null) { int before = pts.Count; Note(mid, midCell); - PullThrough(pts, graph, geo, rooms, cells, from, fromCell, mid, midCell); + PullThrough(pts, graph, geo, rooms, cells, from, fromCell, mid, midCell, wall); Append(pts, mid); - PullThrough(pts, graph, geo, rooms, cells, mid, midCell, to, toCell); + PullThrough(pts, graph, geo, rooms, cells, mid, midCell, to, toCell, wall); NoteCrossing(pts, before, room, why ?? "look-in"); return; } } int start = pts.Count; - PullThrough(pts, graph, geo, rooms, cells, from, fromCell, to, toCell); + PullThrough(pts, graph, geo, rooms, cells, from, fromCell, to, toCell, wall); NoteCrossing(pts, start, room, why ?? "cross"); } @@ -750,9 +755,10 @@ internal static partial class DungeonPathfinder // line, else the room's cells string-pulled with every leg that clear. Where the room is // too tight for that, the crossing as before (0.5 m either side). private static void PullThrough(List pts, Dictionary graph, DungeonGeometry geo, - DungeonRooms rooms, List cells, NavPoint from, uint fromCell, NavPoint to, uint toCell) + DungeonRooms rooms, List cells, NavPoint from, uint fromCell, NavPoint to, uint toCell, + double wall) { - if (Clear(geo, cells, from, to, WallClearance)) return; + if (Clear(geo, cells, from, to, wall)) return; // Through the room's own cells: the openings between them (or cell-centre midpoints), // pushed off the walls like every other point. @@ -768,20 +774,21 @@ internal static partial class DungeonPathfinder var na = graph[a]; var nb = graph[b]; corner = Note(Tag(new NavPoint { Type = NavPointType.Point, NS = (na.NS + nb.NS) * 0.5, EW = (na.EW + nb.EW) * 0.5, Z = (na.Z + nb.Z) * 0.5 / 240.0 }, "pull-midpoint"), a, a, b); } - PushOffWalls(geo, corner, cells, CornerPushMax); + PushOffWalls(geo, corner, cells, CornerPushMax, wall); corners.Add(corner); } corners.Add(to); var strict = new List(); - if (StringPull(strict, geo, cells, from, corners, WallClearance)) + if (StringPull(strict, geo, cells, from, corners, wall)) { foreach (var p in strict) Append(pts, p); return; } - if (Clear(geo, cells, from, to, CrossingClearance)) return; + double loosest = Math.Min(CrossingClearance, wall); + if (Clear(geo, cells, from, to, loosest)) return; var loose = new List(); - StringPull(loose, geo, cells, from, corners, CrossingClearance); + StringPull(loose, geo, cells, from, corners, loosest); foreach (var p in loose) Append(pts, p); } @@ -844,7 +851,7 @@ internal static partial class DungeonPathfinder // The point a patrol visits to look into a room: the middle of its cell centres when that // is on its floor, else the cell centre nearest that middle; then pushed off the walls. - private static NavPoint? RoomMiddle(Dictionary graph, DungeonGeometry geo, List cells, out uint midCell) + private static NavPoint? RoomMiddle(Dictionary graph, DungeonGeometry geo, List cells, double wall, out uint midCell) { midCell = 0; double sx = 0, sy = 0, sz = 0; @@ -872,7 +879,7 @@ internal static partial class DungeonPathfinder ? Tag(WorldPoint(sx, sy, sz, false), "room-middle") : Tag(WorldPoint(DungeonGeometry.NavToWorld(nearest.EW), DungeonGeometry.NavToWorld(nearest.NS), nearest.Z, false), "room-middle-cell"); // A one-cell dead end's origin is inside its end cap; a big room's middle can be a pillar. - PushOffWalls(geo, mid, cells, MiddlePushMax); + PushOffWalls(geo, mid, cells, MiddlePushMax, wall); return mid; } diff --git a/Plugins/RynthCore.Plugin.RynthAi/DungeonPathfinder.cs b/Plugins/RynthCore.Plugin.RynthAi/DungeonPathfinder.cs index ccf3678..5a698e0 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/DungeonPathfinder.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/DungeonPathfinder.cs @@ -451,98 +451,277 @@ internal static partial class DungeonPathfinder private const double PatrolMinKeepFraction = 0.20; /// - /// Returns the 2-core of the dungeon's walkable subgraph — the subset of - /// cells where every node has at least two walkable neighbours within the - /// set. Dead-end spurs of any length are stripped by repeatedly removing - /// leaf nodes (degree ≤ 1) until none remain. Only corridors that form - /// part of a cycle or connect two junctions survive, which is exactly the - /// "main route" a patrol bot should follow. + /// The cells the patrol walks, by : + /// Whole dungeon (default): every cell reachable from without + /// drops or hazards, less the dead-end areas of up to MaxDeadEndCells cells in all (closets, + /// a short corridor ending in a small room; ). Longer dead + /// ends are walked in until only that much is left ahead (a big room: to it), and back. + /// Loops only: the 2-core (cells on a loop or between two junctions), as before 2026-10-12: + /// every dead-end branch goes, however long. In a hive (0x6146 Matron Hive East: 524 + /// reachable, 2-core 171) that leaves two thirds of the dungeon unpatrolled. Where the + /// hazards cut the loops (the 2-core collapses but the dungeon isn't linear), the + /// reachable cells less the small dead-end areas, as Whole dungeon. + /// Everything: every reachable cell. /// - /// Falls back to the full reachable set if the pruned graph would be too - /// small to be useful (small or purely linear dungeons). + /// A linear dungeon (its hazard-free 2-core under PatrolMinKeepNodes or 20% of reachable) + /// keeps every reachable cell, spurs included, whatever the coverage: there the spurs are + /// the dungeon. + /// + /// (BuildRooms with the same hazards, when the map geometry is + /// there): dead-end areas are found room by room rather than cell by cell. /// - private static HashSet GetMainRouteNodes( + internal static HashSet GetMainRouteNodes( Dictionary graph, uint startCell, - IReadOnlySet? hazardCells = null) + IReadOnlySet? hazardCells = null, DungeonPatrolOptions? options = null, DungeonRooms? rooms = null) { + var o = options ?? DungeonPatrolOptions.Default; var (reachable, pruned) = ReachableAndCore(graph, startCell, hazardCells); int originalCount = reachable.Count; - // Fall back to full reachable set if pruning collapsed the graph - judged on the dungeon - // itself, not on what the hazards left. 2026-10-10, 0x6146: 3 acid cells + 35 lava-floor - // cells cut the loops (2-core 277 -> 68, under 20% of reachable), the fallback fired and - // the patrol walked into every dead-end 1-cell room. A dungeon with loops keeps its - // (smaller) 2-core around the hazards; only a dungeon that is linear without hazards, or - // a core under PatrolMinKeepNodes, falls back. + // Linear is judged on the dungeon itself, not on what the hazards left (2026-10-10, 0x6146: + // 3 acid cells + 35 lava-floor cells cut the loops, 2-core 277 -> 68). bool collapsed = pruned.Count < PatrolMinKeepNodes || pruned.Count < originalCount * PatrolMinKeepFraction; - HashSet result = pruned; - string how = "2-core used"; - if (collapsed && hazardCells != null && hazardCells.Count > 0) + bool linear = collapsed; + if (linear && hazardCells != null && hazardCells.Count > 0) { var (freeReach, freeCore) = ReachableAndCore(graph, startCell, null); - bool dungeonIsLinear = freeCore.Count < PatrolMinKeepNodes || freeCore.Count < freeReach.Count * PatrolMinKeepFraction; - if (!dungeonIsLinear) - { - // The hazards cut the loops; the rest of the dungeon hangs off them as long branches. - // Walk those, but not the short spurs (closets, 1-2 cell rooms behind a door). - result = TrimShortSpurs(graph, reachable, startCell, PatrolMaxSpurCells); - how = $"hazards cut the loops: all reachable cells but spurs of <= {PatrolMaxSpurCells} cells ({result.Count} kept)"; - } - else { result = reachable; how = $"FALLBACK: patrol uses all {originalCount} reachable cells, dead ends included"; } + linear = freeCore.Count < PatrolMinKeepNodes || freeCore.Count < freeReach.Count * PatrolMinKeepFraction; + } + + HashSet result; + string how; + if (o.Coverage == PatrolCoverage.Everything) + { + result = reachable; + how = $"everything: all {originalCount} reachable cells, dead ends included"; + } + else if (linear) + { + result = reachable; + how = $"linear: patrol uses all {originalCount} reachable cells, dead ends included"; + } + else if (o.Coverage == PatrolCoverage.LoopsOnly && !collapsed) + { + result = pruned; + how = $"loops only: the 2-core ({pruned.Count} cells)"; + } + else + { + result = TrimDeadEndPockets(graph, reachable, startCell, o.MaxDeadEndCells, rooms, o.LookInRoomMeters); + how = (o.Coverage == PatrolCoverage.LoopsOnly ? "loops only, but hazards cut the loops: " : "") + + $"all reachable cells but dead-end areas of <= {o.MaxDeadEndCells} cells{(rooms != null ? " (by room)" : "")} ({result.Count} kept)"; } - else if (collapsed) { result = reachable; how = $"FALLBACK: patrol uses all {originalCount} reachable cells, dead ends included"; } if (PointLog != null) MainRouteNote = $"main route from {startCell:X8}: {originalCount} reachable cells, 2-core {pruned.Count} " - + $"({hazardCells?.Count ?? 0} hazard cells) -> " + how; + + $"({hazardCells?.Count ?? 0} hazard cells) -> " + how + " [" + o.Describe() + "]"; return result; } - /// Dead-end spurs this short (cells from the tip to the first junction) are left out - /// when the hazards collapsed the 2-core. - internal const int PatrolMaxSpurCells = 3; + /// Dead-end areas this small (all their cells, from where they leave the rest of the + /// dungeon) are left out of the patrol by default (Settings: Skip Dead Ends Up To). + internal const int PatrolMaxDeadEndCells = DungeonPatrolOptions.MaxDeadEndCellsDefault; /// - /// without every dead-end spur of at most cells: - /// from each tip (one walkable neighbour) walk inward through corridor cells (two neighbours) - /// to the first junction; a chain that short goes. One pass, so a long branch keeps its far end. + /// The hazard cells the patrol keeps out of: (the live set: floor + /// textures, pools sighted, cells marked by hand), less the lava/acid floor cells + /// () when is + /// off. A floor cell that is also in (sighted or marked by hand, + /// DungeonHazardStore) stays avoided. Null when nothing is left. /// - internal static HashSet TrimShortSpurs(Dictionary graph, HashSet cells, uint keep, int maxSpur) + internal static IReadOnlySet? PatrolHazards(IReadOnlySet? all, IEnumerable? floorCells, + IReadOnlySet? markedCells, DungeonPatrolOptions? options) { - int Degree(uint id) - { - if (!graph.TryGetValue(id, out var n)) return 0; - int d = 0; - foreach (uint nb in n.Neighbors) - if (cells.Contains(nb) && graph.TryGetValue(nb, out var o) && !IsDropEdge(n, o)) d++; - return d; - } - var drop = new HashSet(); - foreach (uint tip in cells) - { - if (tip == keep || Degree(tip) != 1) continue; - var chain = new List { tip }; - uint prev = 0, cur = tip; - bool shortSpur = false; - while (true) - { - uint next = 0; - foreach (uint nb in graph[cur].Neighbors) - if (nb != prev && cells.Contains(nb) && graph.TryGetValue(nb, out var o) && !IsDropEdge(graph[cur], o)) { next = nb; break; } - if (next == 0) break; // an isolated pair: leave it - int d = Degree(next); - if (d >= 3) { shortSpur = true; break; } // reached a junction - if (d <= 1 || next == keep) break; // the whole thing is a line, or runs into the start - chain.Add(next); - if (chain.Count > maxSpur) break; // long branch: keep it - prev = cur; cur = next; - } - if (shortSpur && chain.Count <= maxSpur) foreach (uint c in chain) drop.Add(c); - } - var result = new HashSet(cells); - result.ExceptWith(drop); + if (all == null || all.Count == 0) return all; + if ((options ?? DungeonPatrolOptions.Default).AvoidHazardFloors || floorCells == null) return all; + var result = new HashSet(all); + foreach (uint c in floorCells) + if (markedCells == null || !markedCells.Contains(c)) result.Remove(c); return result; } + /// + /// without every dead-end area of at most + /// cells. A dead-end area (a pocket) is everything that hangs off the rest by one cell or + /// room: a closet, a corridor with a small room at its end, a little loop off a corridor. It + /// is measured whole, so a short corridor ending in a 3-5 cell room goes (2026-10-13: the spur + /// walk this replaces stopped at the room, whose cells join each other, and kept it; raising + /// its limit changed nothing in 0x6146). + /// + /// Pockets nest, and every one that small goes wherever it is: the patrol never walks into a + /// dead end of maxCells cells or fewer. A long branch is walked (and the small pockets off it + /// are not); where what is left of it ahead is that short, the patrol turns round. A branch to + /// a big room keeps it: a room spreading over or more (the + /// look-in size) counts as too big to skip, so a pocket holding one is never dropped. + /// + /// With (the map geometry is there) the pockets are found on the room + /// graph, a room's cells counted together: entering a room at all is entering it, and a + /// room's own corners (a star-shaped junction's arms) are not pockets of their own. Without, + /// cell by cell (and no room is big). + /// + /// Rooted at (the start): the side the start is on is never a pocket, + /// so a start in a closet keeps the closet and walks out of it. Everything hangs off the start + /// in that sense, so of what hangs off it the biggest part (the rest of the dungeon, or all + /// of it when the start is on a loop) always stays, however small the dungeon. + /// + internal static HashSet TrimDeadEndPockets(Dictionary graph, HashSet cells, uint keep, + int maxCells, DungeonRooms? rooms = null, + double bigRoomMeters = DungeonPatrolOptions.LookInRoomDefault) + { + var result = new HashSet(cells); + if (maxCells <= 0 || cells.Count == 0) return result; + if (rooms == null || !rooms.RoomOf.TryGetValue(keep, out int keepRoom)) + { + result.ExceptWith(DroppedPockets(FindDeadEndPockets(CellAdjacency(graph, cells), _ => 1, keep), maxCells)); + return result; + } + + var (adj, weight) = RoomAdjacency(graph, cells, rooms); + int Weight(uint r) => RoomSpreadMeters(graph, rooms.Cells[(int)r]) >= bigRoomMeters ? maxCells + 1 : weight[r]; + var droppedRooms = DroppedPockets(FindDeadEndPockets(adj, Weight, (uint)keepRoom), maxCells); + foreach (uint c in cells) + if (rooms.RoomOf.TryGetValue(c, out int r) && droppedRooms.Contains((uint)r)) result.Remove(c); + return result; + } + + /// The nodes of every pocket of at most , but the biggest + /// hanging off each root of the walk (the dungeon itself, seen from the start). + private static HashSet DroppedPockets(DeadEndPockets p, int maxSize) + { + var main = new HashSet(); + foreach (uint root in p.Roots) + { + DeadEndPocket? best = null; + foreach (var q in p.All) + if (q.Attach == root && (best == null || q.Size > best.Value.Size)) best = q; + if (best != null) main.Add(best.Value.Root); + } + var dropped = new HashSet(); + foreach (var q in p.All) + if (q.Size <= maxSize && !main.Contains(q.Root) && !dropped.Contains(q.Root)) + foreach (uint c in p.NodesOf(q)) dropped.Add(c); + return dropped; + } + + /// The room graph of : a node per room (its index) with cells in + /// the set, weighted by those cells, joined where two of their cells are walkable neighbours. + internal static (Dictionary> Adj, Dictionary Weight) RoomAdjacency( + Dictionary graph, HashSet cells, DungeonRooms rooms) + { + var weight = new Dictionary(); + foreach (uint c in cells) + if (rooms.RoomOf.TryGetValue(c, out int r)) weight[(uint)r] = weight.GetValueOrDefault((uint)r) + 1; + var adj = new Dictionary>(weight.Count); + foreach (uint r in weight.Keys) adj[r] = new List(); + foreach (var (c, nbs) in CellAdjacency(graph, cells)) + { + if (!rooms.RoomOf.TryGetValue(c, out int ra)) continue; + foreach (uint nb in nbs) + if (rooms.RoomOf.TryGetValue(nb, out int rb) && ra != rb && !adj[(uint)ra].Contains((uint)rb)) + adj[(uint)ra].Add((uint)rb); + } + return (adj, weight); + } + + /// The walkable neighbours (no drops) of each cell inside , each once. + private static Dictionary> CellAdjacency(Dictionary graph, HashSet cells) + { + var adj = new Dictionary>(cells.Count); + foreach (uint c in cells) + { + var list = new List(); + if (graph.TryGetValue(c, out var n)) + foreach (uint nb in n.Neighbors) + if (nb != c && cells.Contains(nb) && graph.TryGetValue(nb, out var o) && !IsDropEdge(n, o) && !list.Contains(nb)) + list.Add(nb); + adj[c] = list; + } + return adj; + } + + /// A dead-end area: and everything behind it hang off the rest by + /// alone. is its weight (cells), Attach not counted. + internal readonly record struct DeadEndPocket(uint Attach, uint Root, int Size); + + /// Every dead-end area of a graph, nested ones included (). + internal sealed class DeadEndPockets + { + internal readonly List Order = new(); + internal readonly Dictionary Disc = new(); + internal readonly Dictionary Count = new(); + /// Every pocket, in depth-first order of their roots (outer ones first). + public readonly List All = new(); + /// Where the walk started: keep, then a node of each part not connected to it. + public readonly List Roots = new(); + + /// The pocket's nodes: its root's subtree, a run of the depth-first order. + public IEnumerable NodesOf(DeadEndPocket p) + { + for (int k = Disc[p.Root], end = k + Count[p.Root]; k < end; k++) yield return Order[k]; + } + } + + /// + /// The dead-end areas of a graph seen from : a depth-first walk from it + /// (Tarjan's cut vertices), where a child w of v whose subtree has no way round v (low[w] >= + /// disc[v]) is a pocket hanging off v, weighing the sum of its nodes' weights. Nodes not + /// connected to keep are walked from the lowest id up. + /// + internal static DeadEndPockets FindDeadEndPockets(Dictionary> adj, Func weight, uint keep) + { + var r = new DeadEndPockets(); + var disc = r.Disc; + var count = r.Count; + var order = r.Order; + var size = new Dictionary(adj.Count); + var low = new Dictionary(adj.Count); + var parent = new Dictionary(adj.Count); + var roots = new List(); + if (adj.ContainsKey(keep)) roots.Add(keep); + var rest = new List(adj.Keys); + rest.Sort(); + roots.AddRange(rest); + var stack = new Stack<(uint Node, int Next)>(); + foreach (uint root in roots) + { + if (disc.ContainsKey(root)) continue; + r.Roots.Add(root); + disc[root] = low[root] = order.Count; order.Add(root); count[root] = 1; size[root] = weight(root); + stack.Push((root, 0)); + while (stack.Count > 0) + { + var (v, i) = stack.Pop(); + var nbs = adj[v]; + if (i < nbs.Count) + { + stack.Push((v, i + 1)); + uint w = nbs[i]; + if (!adj.ContainsKey(w)) continue; + if (!disc.ContainsKey(w)) + { + parent[w] = v; + disc[w] = low[w] = order.Count; order.Add(w); count[w] = 1; size[w] = weight(w); + stack.Push((w, 0)); + } + else if (!(parent.TryGetValue(v, out uint pv) && pv == w)) + low[v] = Math.Min(low[v], disc[w]); + continue; + } + // v finished: hand its low-link, node count and weight up to its parent. + if (parent.TryGetValue(v, out uint p)) + { + low[p] = Math.Min(low[p], low[v]); + count[p] += count[v]; + size[p] += size[v]; + } + } + } + + foreach (var (w, v) in parent) + if (low[w] >= disc[v]) r.All.Add(new DeadEndPocket(v, w, size[w])); + r.All.Sort((a, b) => disc[a.Root].CompareTo(disc[b.Root])); + return r; + } + /// The cells reachable from startCell (no drops, no hazards) and their 2-core. private static (HashSet Reachable, HashSet Core) ReachableAndCore( Dictionary graph, uint startCell, IReadOnlySet? hazardCells) @@ -620,15 +799,19 @@ internal static partial class DungeonPathfinder Dictionary graph, uint startCell, IReadOnlySet? hazardCells = null, - DungeonGeometry? geo = null) + DungeonGeometry? geo = null, + DungeonPatrolOptions? options = null) { - var mainRoute = GetMainRouteNodes(graph, startCell, hazardCells); + var o = (options ?? DungeonPatrolOptions.Default).Clamped(); + // Dead ends are judged room by room when the rooms can be made (the room patrol below). + var rooms = geo != null && geo.DoorwayCount > 0 ? BuildRooms(graph, geo, hazardCells) : null; + var mainRoute = GetMainRouteNodes(graph, startCell, hazardCells, o, rooms); // With the dungeon map geometry: the same coverage over rooms instead of cells, rooms // crossed directly, doorways taken straight on (DungeonPathfinder.Rooms.cs). if (geo != null && geo.DoorwayCount > 0) { - var byRoom = BuildRoomPatrol(graph, startCell, mainRoute, hazardCells, geo); + var byRoom = BuildRoomPatrol(graph, startCell, mainRoute, hazardCells, geo, o); if (byRoom != null && byRoom.Points.Count > 0) return byRoom; } @@ -714,7 +897,7 @@ internal static partial class DungeonPathfinder // off from every doorway): the cell walk's points still keep off the walls. if (geo != null) foreach (var p in route.Points) - PushOffWalls(geo, Tag(p, "cell-walk"), null, CornerPushMax); + PushOffWalls(geo, Tag(p, "cell-walk"), null, CornerPushMax, o.WallClearance); return route; } diff --git a/Plugins/RynthCore.Plugin.RynthAi/DungeonPatrolOptions.cs b/Plugins/RynthCore.Plugin.RynthAi/DungeonPatrolOptions.cs new file mode 100644 index 0000000..b5e2c46 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/DungeonPatrolOptions.cs @@ -0,0 +1,110 @@ +// DungeonPatrolOptions: the player-tunable side of the dungeon patrol (Settings > Navigation > +// Dungeon Patrol). Passed into DungeonPathfinder.BuildPatrolRoute as a value, never kept in a +// static: every build says what it was built with, and a reload starts from the settings again. +// The defaults are the patrol as it was before the settings existed (2026-10-12, f15c153), but +// for the dead-end limit: since 2026-10-13 it counts whole dead-end areas, default 10 (was 3). + +using System; +using System.Collections.Generic; +using System.Globalization; + +namespace RynthCore.Plugin.RynthAi; + +/// Which cells the patrol walks (Settings > Navigation > Dungeon Patrol > Coverage). +internal enum PatrolCoverage +{ + /// Every reachable cell but dead-end areas of up to MaxDeadEndCells cells (2026-10-12 on). + WholeDungeon = 0, + /// Only the loops and the corridors between junctions (the 2-core; before 2026-10-12). + LoopsOnly = 1, + /// Every reachable cell, every dead end included. + Everything = 2, +} + +internal sealed record DungeonPatrolOptions +{ + public const int MaxDeadEndCellsMin = 0, MaxDeadEndCellsMax = 30, MaxDeadEndCellsDefault = 10; + public const double WallClearanceMin = 0.5, WallClearanceMax = 2.0, WallClearanceDefault = 1.0; + public const double LookInRoomMin = 3.0, LookInRoomMax = 40.0, LookInRoomDefault = 10.0; + + public static readonly DungeonPatrolOptions Default = new(); + + public PatrolCoverage Coverage { get; init; } = PatrolCoverage.WholeDungeon; + + /// Whole dungeon (and Loops only when hazards cut the loops): dead-end areas this + /// small (all their cells: a closet, a short corridor with a small room at its end) are left + /// out, and the patrol turns round where a longer dead end has only this much left ahead. + /// A big room (LookInRoomMeters) is never left out. 0 = none left out. + /// . Until 2026-10-13 a spur limit (cells from + /// a tip to the first junction, default 3), which kept every corridor that ended in a room. + public int MaxDeadEndCells { get; init; } = MaxDeadEndCellsDefault; + + /// Lava/acid floor cells (Detector C, HazardTextures.txt) are kept out of the patrol. + /// Cells marked by hand or sighted as pools are avoided either way. Applied by the caller, + /// which knows which cells are which (). + public bool AvoidHazardFloors { get; init; } = true; + + /// Every point laid keeps at least this far (metres) from walls where there is room. + public double WallClearance { get; init; } = WallClearanceDefault; + + /// A room at least this big (metres across its cell centres) that the patrol only + /// skirts or leaves by the doorway it came in by gets a walk to its middle and back. + public double LookInRoomMeters { get; init; } = LookInRoomDefault; + + /// The options with every value in range (a hand-edited profile or a remote setting). + public DungeonPatrolOptions Clamped() => this with + { + Coverage = Enum.IsDefined(Coverage) ? Coverage : PatrolCoverage.WholeDungeon, + MaxDeadEndCells = Math.Clamp(MaxDeadEndCells, MaxDeadEndCellsMin, MaxDeadEndCellsMax), + WallClearance = double.IsFinite(WallClearance) ? Math.Clamp(WallClearance, WallClearanceMin, WallClearanceMax) : WallClearanceDefault, + LookInRoomMeters = double.IsFinite(LookInRoomMeters) ? Math.Clamp(LookInRoomMeters, LookInRoomMin, LookInRoomMax) : LookInRoomDefault, + }; + + public static string CoverageName(PatrolCoverage c) => c switch + { + PatrolCoverage.LoopsOnly => "loops only", + PatrolCoverage.Everything => "everything", + _ => "whole dungeon", + }; + + /// For the "main route from ..." diagnostic line and PatrolProof. + public string Describe() + { + var inv = CultureInfo.InvariantCulture; + string spurs = Coverage == PatrolCoverage.Everything ? "" : $", skip dead ends <= {MaxDeadEndCells}"; + return $"coverage {CoverageName(Coverage)}{spurs}, lava/acid floors {(AvoidHazardFloors ? "avoided" : "walked")}, " + + $"walls {WallClearance.ToString("0.0#", inv)} m, look into rooms >= {LookInRoomMeters.ToString("0.#", inv)} m"; + } +} + +/// +/// Notices a patrol setting changed while a patrol runs and says when to rebuild it: once the +/// new settings have stayed put for (the Settings panel saves on every +/// click of a +/- step, and a rebuild per click would restart the lap each time). One per +/// plugin instance, so nothing outlives a reload. +/// +internal sealed class PatrolSettingsWatch +{ + public const long SettleMs = 1000; + + private DungeonPatrolOptions? _built, _pending; + private long _pendingSince; + + /// The settings the running patrol was built with (null = none built yet). + public DungeonPatrolOptions? Built => _built; + + public void MarkBuilt(DungeonPatrolOptions options) + { + _built = options; + _pending = null; + } + + /// True when differs from what the patrol was built with + /// and has not changed for SettleMs. + public bool ShouldRebuild(DungeonPatrolOptions current, long nowMs) + { + if (_built == null || current.Equals(_built)) { _pending = null; return false; } + if (!current.Equals(_pending)) { _pending = current; _pendingSince = nowMs; return false; } + return nowMs - _pendingSince >= SettleMs; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/GroundLootController.cs b/Plugins/RynthCore.Plugin.RynthAi/GroundLootController.cs new file mode 100644 index 0000000..2017b85 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/GroundLootController.cs @@ -0,0 +1,355 @@ +// GroundLootController.cs — picks up loose ground items that match the active loot profile +// (UB-IT AutoGroundLoot, driven by RynthAi's own loot rules and corpse range). +// +// * Scan: every GroundScanIntervalMs, objects lying in the world (readable ownership with +// no container / wielder, finite distance) within the corpse max range, minus scenery / +// creatures / doors / corpses, are classified with the same ClassifyItemAgainstProfile +// the corpse looter uses. Stat-gated rules get a server appraisal first (a few per scan), +// then a best-effort classify once GroundAppraiseWaitMs passes. +// * Pickup: only once the activity arbiter has handed the tick to Looting (HasLootWork sees +// the matches, so navigation is already stopped). MoveItemExternal(item → player); ACE +// walks the character to the item and picks it up. Confirmed when the item leaves the +// ground, retried up to GroundMaxPickupAttempts, then put on a long cooldown. +// * Corpses always win: ground loot only runs when no corpse is claimed or open. +using System; +using System.Collections.Generic; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi; + +public sealed partial class RynthAiPlugin +{ + private const long GroundScanIntervalMs = 300; + /// Classify best-effort after waiting this long for an item's appraisal. + private const long GroundAppraiseWaitMs = 3_000; + /// Server move-to plus pickup animation must finish inside this window before a retry. + private const long GroundPickupVerifyMs = 5_000; + /// A claimed item whose pickup could never be sent (client stayed busy) is dropped after this. + private const long GroundClaimStallMs = 10_000; + /// Items that matched no rule are re-checked after this (profile edits, late appraisal). + private const long GroundLeaveCooldownMs = 60_000; + private const long GroundFailCooldownMs = 300_000; + private const int GroundMaxPickupAttempts = 3; + private const int GroundAppraisalsPerScan = 2; + + private long _groundLastScanAt; + private int _groundMatchesInRange; + private int _groundTargetId; + private long _groundTargetSince; + private long _groundPickupRequestedAt; + private int _groundPickupAttempts; + private string _groundTargetName = string.Empty; + private string _groundTargetAction = string.Empty; + private string _groundTargetRule = string.Empty; + private bool _groundTargetIsSalvage; + /// id → ms before which the item is not re-evaluated (left, failed or gone). + private readonly Dictionary _groundSkipUntil = new(); + /// id → ms of the first appraisal request (bounds the wait for stat data). + private readonly Dictionary _groundAppraiseAt = new(); + + /// A pickup request is out and not yet confirmed — corpse claims wait for it. + private bool GroundPickupInFlight => _groundTargetId != 0 && _groundPickupRequestedAt != 0; + + /// Arbiter input: a claimed ground item, or matching ground items seen by the last scan. + private bool HasGroundLootWork(LegacyUiSettings settings) + => settings.EnableGroundLoot && (_groundTargetId != 0 || _groundMatchesInRange > 0); + + /// + /// One ground-loot step (pump thread, called from TickCorpseOpening when no corpse is + /// claimed or open). Gating for macro / looting / buffing / combat is done by the caller. + /// + private void TickGroundLoot(LegacyUiSettings settings, double maxMeters) + { + if (!settings.EnableGroundLoot || _objectCache == null || _playerId == 0) + { + ResetGroundLoot(clearCaches: false); + return; + } + + long now = CorpseNowMs; + if (_groundTargetId != 0) + { + TickGroundTarget(maxMeters, now); + return; + } + + if (now - _groundLastScanAt < GroundScanIntervalMs) + return; + _groundLastScanAt = now; + PruneGroundCollections(now); + + WorldObject? best = ScanGroundLoot(settings, maxMeters, now, out double bestDist, + out string action, out string rule, out bool salvage); + if (best == null) + return; + + // HasLootWork reports the match; wait until the arbiter actually gives Looting the tick. + if (_activity != BotActivity.Looting) + return; + + _groundTargetId = best.Id; + _groundTargetSince = now; + _groundPickupRequestedAt = 0; + _groundPickupAttempts = 0; + _groundTargetName = best.Name ?? string.Empty; + _groundTargetAction = action; + _groundTargetRule = rule; + _groundTargetIsSalvage = salvage; + if (!(_navStopIssued && _navStoppedFor == BotActivity.Looting)) + StopNavFor(BotActivity.Looting); + LootDiag($"[RynthAi] Ground loot: claimed 0x{(uint)best.Id:X8} '{_groundTargetName}' dist={bestDist:F1}m [{action}] rule='{rule}'."); + TryRequestGroundPickup(now); + } + + /// + /// Finds the nearest ground item that matches the loot profile and counts all matches + /// in range (for ). Requests appraisal for stat-gated items. + /// + private WorldObject? ScanGroundLoot(LegacyUiSettings settings, double maxMeters, long now, + out double bestDist, out string bestAction, out string bestRule, out bool bestSalvage) + { + bestDist = double.MaxValue; + bestAction = bestRule = string.Empty; + bestSalvage = false; + _groundMatchesInRange = 0; + if (_objectCache == null || maxMeters <= 0.25) + return null; + // The profile loaders chat on every failed load; a 300 ms scan must not trigger that. + string profilePath = (settings.CurrentLootPath ?? string.Empty).Trim().Trim('"'); + if (profilePath.Length == 0 || !System.IO.File.Exists(profilePath)) + return null; + + int playerId = unchecked((int)_playerId); + int appraisalsSent = 0; + WorldObject? best = null; + + foreach (WorldObject wo in _objectCache.AllKnownObjects()) + { + if (wo.Id == playerId || IsGroundLootExcludedClass(wo.ObjectClass)) + continue; + if (_groundSkipUntil.TryGetValue(wo.Id, out long until)) + { + if (until > now) continue; + _groundSkipUntil.Remove(wo.Id); + } + if (string.IsNullOrWhiteSpace(wo.Name)) + continue; + + // Carried / contained items have no world position, so Distance is MaxValue for them. + double dist = _objectCache.Distance(playerId, wo.Id); + if (dist > maxMeters) + continue; + if (!_objectCache.IsOnGround(wo.Id)) + continue; + + uint uid = unchecked((uint)wo.Id); + bool appraised = Host.HasHasAppraisalData && Host.HasAppraisalData(uid); + if (!appraised && ItemNeedsAppraisalForLoot(wo)) + { + if (!_groundAppraiseAt.TryGetValue(wo.Id, out long firstAsk)) + { + if (appraisalsSent < GroundAppraisalsPerScan && _busyCount == 0 && Host.RequestId(uid)) + { + _groundAppraiseAt[wo.Id] = now; + appraisalsSent++; + } + continue; + } + if (now - firstAsk < GroundAppraiseWaitMs) + continue; + // Appraisal never arrived — classify best-effort, like the corpse assess window. + } + + bool keep = ClassifyItemAgainstProfile(wo, settings, out string action, out bool salvage, out string rule); + LootDiag($"[LootEval] ground '{wo.Name}' cls={wo.ObjectClass} dist={dist:F1}m appraised={appraised} -> " + + (keep ? $"KEEP [{action}] rule='{rule}'" : "leave")); + if (!keep) + { + _groundSkipUntil[wo.Id] = now + GroundLeaveCooldownMs; + continue; + } + + _groundMatchesInRange++; + if (dist < bestDist) + { + best = wo; + bestDist = dist; + bestAction = action; + bestRule = rule; + bestSalvage = salvage; + } + } + + return best; + } + + /// Follows a claimed item: confirm pickup, retry, or give up. + private void TickGroundTarget(double maxMeters, long now) + { + if (_objectCache == null) + return; + + int id = _groundTargetId; + WorldObject? item = _objectCache[id]; + if (item == null) + { + // Deleted from the world: decayed or another player took it. + LootDiag($"[RynthAi] Ground loot: 0x{(uint)id:X8} '{_groundTargetName}' is gone."); + FinishGroundTarget(now, GroundFailCooldownMs); + return; + } + + if (!_objectCache.IsOnGround(id) && _objectCache.GetContainerId(id) != 0) + { + LootDiag($"[RynthAi] Ground loot: pickup confirmed for 0x{(uint)id:X8} '{_groundTargetName}'."); + ChatLine($"[RynthAi] Looted [{_groundTargetAction}] {_groundTargetName} (ground)"); + if (_groundTargetIsSalvage) + _salvageManager?.EnqueueItem(unchecked((uint)id)); + FinishGroundTarget(now, GroundFailCooldownMs); + return; + } + + int playerId = unchecked((int)_playerId); + double dist = _objectCache.Distance(playerId, id); + if (dist > Math.Max(maxMeters * 1.5, maxMeters + 2.0)) + { + LootDiag($"[RynthAi] Ground loot: 0x{(uint)id:X8} '{_groundTargetName}' drifted out of range ({dist:F1}m); releasing."); + FinishGroundTarget(now, GroundLeaveCooldownMs); + return; + } + + if (_groundPickupRequestedAt == 0) + { + if (now - _groundTargetSince > GroundClaimStallMs) + { + LootDiag($"[RynthAi] Ground loot: could not send pickup for 0x{(uint)id:X8} (client busy); releasing."); + FinishGroundTarget(now, GroundLeaveCooldownMs); + return; + } + TryRequestGroundPickup(now); + return; + } + + if (now - _groundPickupRequestedAt < GroundPickupVerifyMs) + return; + + if (_groundPickupAttempts >= GroundMaxPickupAttempts) + { + LootDiag($"[RynthAi] Ground loot: pickup failed for 0x{(uint)id:X8} '{_groundTargetName}' after {_groundPickupAttempts} attempt(s)."); + FinishGroundTarget(now, GroundFailCooldownMs); + return; + } + + TryRequestGroundPickup(now); + } + + /// Sends the pickup (item → player's main pack) when the client isn't busy. + private void TryRequestGroundPickup(long now) + { + if (_busyCount > 0 || _groundTargetId == 0) + return; + + uint uid = unchecked((uint)_groundTargetId); + Host.SelectItem(uid); + bool sent = Host.HasMoveItemExternal + ? Host.MoveItemExternal(uid, _playerId, 0) + : Host.UseObject(uid); + _groundPickupAttempts++; + _groundPickupRequestedAt = now; + LootDiag($"[RynthAi] Ground loot: pickup {(sent ? "sent" : "rejected")} for 0x{uid:X8} attempt {_groundPickupAttempts}."); + } + + /// Releases the claimed item and parks it for . + private void FinishGroundTarget(long now, long cooldownMs) + { + if (_groundTargetId != 0) + { + _groundSkipUntil[_groundTargetId] = now + cooldownMs; + _groundAppraiseAt.Remove(_groundTargetId); + } + _groundTargetId = 0; + _groundTargetSince = 0; + _groundPickupRequestedAt = 0; + _groundPickupAttempts = 0; + _groundTargetName = _groundTargetAction = _groundTargetRule = string.Empty; + _groundTargetIsSalvage = false; + _groundLastScanAt = 0; // rescan straight away for the next item + } + + /// Drops the claim (and optionally the per-item caches, e.g. on logout or /ra groundloot scan). + private void ResetGroundLoot(bool clearCaches) + { + _groundTargetId = 0; + _groundTargetSince = 0; + _groundPickupRequestedAt = 0; + _groundPickupAttempts = 0; + _groundTargetName = _groundTargetAction = _groundTargetRule = string.Empty; + _groundTargetIsSalvage = false; + _groundMatchesInRange = 0; + if (!clearCaches) + return; + _groundSkipUntil.Clear(); + _groundAppraiseAt.Clear(); + _groundLastScanAt = 0; + } + + /// Keeps the per-item maps bounded. + private void PruneGroundCollections(long now) + { + if (_groundSkipUntil.Count > 512) + { + var expired = new List(); + foreach (var kv in _groundSkipUntil) + if (kv.Value <= now) expired.Add(kv.Key); + foreach (int k in expired) _groundSkipUntil.Remove(k); + } + if (_groundAppraiseAt.Count > 256) + { + var stale = new List(); + foreach (var kv in _groundAppraiseAt) + if (now - kv.Value > GroundLeaveCooldownMs) stale.Add(kv.Key); + foreach (int k in stale) _groundAppraiseAt.Remove(k); + } + } + + /// Scenery, creatures, fixtures and containers are never picked up from the ground. + private static bool IsGroundLootExcludedClass(AcObjectClass cls) => cls is + AcObjectClass.Unknown or AcObjectClass.Monster or AcObjectClass.Player or AcObjectClass.Npc + or AcObjectClass.Vendor or AcObjectClass.Portal or AcObjectClass.Door or AcObjectClass.Corpse + or AcObjectClass.Lifestone or AcObjectClass.Sign or AcObjectClass.Housing or AcObjectClass.Container + or AcObjectClass.CombatPet or AcObjectClass.Services; + + /// /ra groundloot [on|off|status|scan] + private void HandleGroundLootCommand(string[] parts) + { + var settings = _dashboard?.Settings; + if (settings == null) { ChatLine("[RynthAi] Not logged in."); return; } + + string verb = parts.Length >= 3 ? parts[2].Trim().ToLowerInvariant() : "status"; + switch (verb) + { + case "on": + settings.EnableGroundLoot = true; + _dashboard?.SaveSettings(); + ChatLine("[RynthAi] Ground loot ON (uses the loot profile and the corpse max range)."); + break; + case "off": + settings.EnableGroundLoot = false; + ResetGroundLoot(clearCaches: true); + _dashboard?.SaveSettings(); + ChatLine("[RynthAi] Ground loot OFF."); + break; + case "scan": + ResetGroundLoot(clearCaches: true); + ChatLine("[RynthAi] Ground loot: cleared skip list; rescanning."); + break; + default: + double yards = settings.CorpseApproachRangeMax; + string target = _groundTargetId != 0 ? $" | target '{_groundTargetName}' attempts={_groundPickupAttempts}" : string.Empty; + ChatLine($"[RynthAi] Ground loot {(settings.EnableGroundLoot ? "ON" : "OFF")} | range {yards:0.#} yd | " + + $"looting {(settings.EnableLooting ? "on" : "off")} | matches in range {_groundMatchesInRange} | " + + $"skipped {_groundSkipUntil.Count}{target}"); + break; + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/CombatHudTracker.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/CombatHudTracker.cs new file mode 100644 index 0000000..05820bd --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/CombatHudTracker.cs @@ -0,0 +1,223 @@ +// CombatHudTracker.cs — Pump-thread feed for the Mini Remote's Target and Summon rows. +// +// Target the creature combat is attacking (CombatManager.activeTargetId): name, health +// ratio from the object cache, distance. +// Summon the player's pet ("'s " in the landscape): health ratio (polled with +// QueryHealth) and time left (RemainingLifespan from one appraisal, then counted +// down locally). +// +// The render thread only reads the published immutable snapshot. +using System; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.Huds; + +/// Immutable view of the attack target and the active summon (render thread safe). +internal sealed record CombatHudSnapshot( + int TargetId, + string TargetName, + float TargetHealth, // 0..1, -1 = no health received yet + double TargetDistance, // yards, < 0 = unknown + int PetId, + string PetName, + float PetHealth, // 0..1, -1 = no health received yet + long PetExpiresAtMs, // Environment.TickCount64 deadline, 0 = lifespan unknown + int PetLifespanSec, // total lifespan, 0 = unknown + long PetSeenAtMs) // when this pet first appeared +{ + public static readonly CombatHudSnapshot Empty = new(0, string.Empty, -1f, -1, 0, string.Empty, -1f, 0, 0, 0); +} + +internal sealed class CombatHudTracker +{ + private const uint StypeLifespan = 267; + private const uint StypeRemainingLifespan = 268; + private const long ThinkIntervalMs = 250; + // QueryHealth makes the server stream that creature's health to us instead of the previous + // query's, so each pet poll is followed by a re-query of the combat / selected target. + private const long PetHealthPollMs = 3000; + private const long AppraiseRetryMs = 5000; + private const int AppraiseMaxAttempts = 3; + private const long PlayerNameRefreshMs = 30_000; + + private readonly RynthCoreHost _host; + private readonly Func _cache; + private readonly Func _attackTargetId; + + private volatile CombatHudSnapshot _snapshot = CombatHudSnapshot.Empty; + private long _lastThinkAt; + + private string _playerName = string.Empty; + private long _playerNameAt; + + // Current pet bookkeeping. + private int _petId; + private long _petSeenAt; + private long _petExpiresAt; + private int _petLifespanSec; + private int _appraiseAttempts; + private long _lastAppraiseAt; + private long _lastPetHealthAt; + + public CombatHudTracker(RynthCoreHost host, Func cache, Func attackTargetId) + { + _host = host; + _cache = cache; + _attackTargetId = attackTargetId; + } + + /// Latest target / summon view. + public CombatHudSnapshot Snapshot => _snapshot; + + private static long NowMs => Environment.TickCount64; + + /// Refreshes the snapshot (pump thread). Cheap when called every tick. + public void Tick() + { + long now = NowMs; + if (now - _lastThinkAt < ThinkIntervalMs) return; + _lastThinkAt = now; + + var cache = _cache(); + if (cache == null) { _snapshot = CombatHudSnapshot.Empty; return; } + + int playerId = unchecked((int)_host.GetPlayerId()); + int targetId = _attackTargetId(); + + // ── Attack target ── + string targetName = string.Empty; + float targetHealth = -1f; + double targetDist = -1; + if (targetId != 0) + { + targetName = cache[targetId]?.Name ?? string.Empty; + if (targetName.Length == 0 && _host.TryGetObjectName(unchecked((uint)targetId), out string n)) targetName = n; + if (targetName.Length == 0) targetName = $"0x{(uint)targetId:X8}"; + targetHealth = cache.GetHealthRatio(targetId); + if (playerId != 0) + { + double d = cache.Distance(playerId, targetId); + targetDist = d < double.MaxValue ? d : -1; + } + } + + // ── Summon ── + var pet = FindOwnPet(cache); + string petName = string.Empty; + float petHealth = -1f; + if (pet == null) + { + ForgetPet(); + } + else + { + if (pet.Id != _petId) StartTrackingPet(pet.Id, now); + petName = StripOwner(pet.Name); + TickPetLifespan(now); + TickPetHealth(now, targetId); + petHealth = cache.GetHealthRatio(_petId); + } + + _snapshot = new CombatHudSnapshot(targetId, targetName, targetHealth, targetDist, + _petId, petName, petHealth, _petExpiresAt, _petLifespanSec, _petSeenAt); + } + + public void OnLogout() + { + ForgetPet(); + _playerName = string.Empty; + _snapshot = CombatHudSnapshot.Empty; + } + + // ── Pet ───────────────────────────────────────────────────────────────── + + private WorldObject? FindOwnPet(WorldObjectCache cache) + { + string me = PlayerName(); + if (me.Length == 0) return null; + string prefix = me + "'s "; + foreach (var wo in cache.GetLandscape()) + if (wo != null && !string.IsNullOrEmpty(wo.Name) && wo.Name.StartsWith(prefix, StringComparison.Ordinal)) + return wo; + return null; + } + + private string PlayerName() + { + long now = NowMs; + if (_playerName.Length > 0 && now - _playerNameAt < PlayerNameRefreshMs) return _playerName; + uint pid = _host.GetPlayerId(); + if (pid != 0 && _host.TryGetObjectName(pid, out string n) && !string.IsNullOrEmpty(n)) + { + _playerName = n; + _playerNameAt = now; + } + return _playerName; + } + + /// "Silent's Fire Banshee" → "Fire Banshee". + private string StripOwner(string name) + { + string prefix = _playerName + "'s "; + return _playerName.Length > 0 && name.StartsWith(prefix, StringComparison.Ordinal) ? name[prefix.Length..] : name; + } + + private void StartTrackingPet(int id, long now) + { + _petId = id; + _petSeenAt = now; + _petExpiresAt = 0; + _petLifespanSec = 0; + _appraiseAttempts = 0; + _lastAppraiseAt = 0; + _lastPetHealthAt = 0; + RynthLog.Trace(LogCat.Huds, $"summon tracked 0x{(uint)id:X8}"); + } + + private void ForgetPet() + { + _petId = 0; + _petSeenAt = 0; + _petExpiresAt = 0; + _petLifespanSec = 0; + _appraiseAttempts = 0; + } + + /// + /// Appraises the new pet (at most times) and anchors the + /// countdown on the first RemainingLifespan the server returns. The pet's guid is new, so + /// any cached value belongs to this pet. + /// + private void TickPetLifespan(long now) + { + if (_petExpiresAt != 0) return; + uint uid = unchecked((uint)_petId); + + if (_host.HasGetObjectIntProperty && _host.TryGetObjectIntProperty(uid, StypeRemainingLifespan, out int remaining) && remaining > 0) + { + _petExpiresAt = now + remaining * 1000L; + if (_host.TryGetObjectIntProperty(uid, StypeLifespan, out int total) && total > 0) + _petLifespanSec = Math.Max(total, remaining); + RynthLog.Trace(LogCat.Huds, $"summon 0x{uid:X8}: {remaining}s left of {_petLifespanSec}s"); + return; + } + + if (_appraiseAttempts >= AppraiseMaxAttempts || !_host.HasRequestId) return; + if (_lastAppraiseAt != 0 && now - _lastAppraiseAt < AppraiseRetryMs) return; + _appraiseAttempts++; + _lastAppraiseAt = now; + _host.RequestId(uid); + } + + /// Polls the pet's health, then hands the server's health stream back to the fight target. + private void TickPetHealth(long now, int combatTargetId) + { + if (!_host.HasQueryHealth || now - _lastPetHealthAt < PetHealthPollMs) return; + _lastPetHealthAt = now; + _host.QueryHealth(unchecked((uint)_petId)); + + uint restore = combatTargetId != 0 ? unchecked((uint)combatTargetId) : 0; + if (restore == 0 && _host.HasGetSelectedItemId) restore = _host.GetSelectedItemId(); + if (restore != 0 && restore != unchecked((uint)_petId)) _host.QueryHealth(restore); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/DxtUtil.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/DxtUtil.cs new file mode 100644 index 0000000..f83fd04 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/DxtUtil.cs @@ -0,0 +1,442 @@ +// #region License +// /* +// Microsoft Public License (Ms-PL) +// MonoGame - Copyright © 2009 The MonoGame Team +// +// All rights reserved. +// +// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not +// accept the license, do not use the software. +// +// 1. Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under +// U.S. copyright law. +// +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2. Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, +// each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, +// each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. +// +// 3. Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, +// your patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object +// code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent +// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular +// purpose and non-infringement. +// */ +// #endregion License +// + +namespace RynthCore.Plugin.RynthAi.Huds +{ + using System.IO; + + internal static class DxtUtil + { + internal static byte[] DecompressDxt1(byte[] imageData, int width, int height) + { + using (MemoryStream imageStream = new MemoryStream(imageData)) + return DecompressDxt1(imageStream, width, height); + } + + internal static byte[] DecompressDxt1(Stream imageStream, int width, int height) + { + byte[] imageData = new byte[width * height * 4]; + + using (BinaryReader imageReader = new BinaryReader(imageStream)) + { + int blockCountX = (width + 3) / 4; + int blockCountY = (height + 3) / 4; + + for (int y = 0; y < blockCountY; y++) + { + for (int x = 0; x < blockCountX; x++) + { + DecompressDxt1Block(imageReader, x, y, blockCountX, width, height, imageData); + } + } + } + + return imageData; + } + + private static void DecompressDxt1Block(BinaryReader imageReader, int x, int y, int blockCountX, int width, int height, byte[] imageData) + { + ushort c0 = imageReader.ReadUInt16(); + ushort c1 = imageReader.ReadUInt16(); + + byte r0, g0, b0; + byte r1, g1, b1; + ConvertRgb565ToRgb888(c0, out r0, out g0, out b0); + ConvertRgb565ToRgb888(c1, out r1, out g1, out b1); + + uint lookupTable = imageReader.ReadUInt32(); + + for (int blockY = 0; blockY < 4; blockY++) + { + for (int blockX = 0; blockX < 4; blockX++) + { + byte r = 0, g = 0, b = 0, a = 255; + uint index = (lookupTable >> 2 * (4 * blockY + blockX)) & 0x03; + + if (c0 > c1) + { + switch (index) + { + case 0: + r = r0; + g = g0; + b = b0; + break; + case 1: + r = r1; + g = g1; + b = b1; + break; + case 2: + r = (byte)((2 * r0 + r1) / 3); + g = (byte)((2 * g0 + g1) / 3); + b = (byte)((2 * b0 + b1) / 3); + break; + case 3: + r = (byte)((r0 + 2 * r1) / 3); + g = (byte)((g0 + 2 * g1) / 3); + b = (byte)((b0 + 2 * b1) / 3); + break; + } + } + else + { + switch (index) + { + case 0: + r = r0; + g = g0; + b = b0; + break; + case 1: + r = r1; + g = g1; + b = b1; + break; + case 2: + r = (byte)((r0 + r1) / 2); + g = (byte)((g0 + g1) / 2); + b = (byte)((b0 + b1) / 2); + break; + case 3: + r = 0; + g = 0; + b = 0; + a = 0; + break; + } + } + + int px = (x << 2) + blockX; + int py = (y << 2) + blockY; + if ((px < width) && (py < height)) + { + int offset = ((py * width) + px) << 2; + imageData[offset] = r; + imageData[offset + 1] = g; + imageData[offset + 2] = b; + imageData[offset + 3] = a; + } + } + } + } + + internal static byte[] DecompressDxt3(byte[] imageData, int width, int height) + { + using (MemoryStream imageStream = new MemoryStream(imageData)) + return DecompressDxt3(imageStream, width, height); + } + + internal static byte[] DecompressDxt3(Stream imageStream, int width, int height) + { + byte[] imageData = new byte[width * height * 4]; + + using (BinaryReader imageReader = new BinaryReader(imageStream)) + { + int blockCountX = (width + 3) / 4; + int blockCountY = (height + 3) / 4; + + for (int y = 0; y < blockCountY; y++) + { + for (int x = 0; x < blockCountX; x++) + { + DecompressDxt3Block(imageReader, x, y, blockCountX, width, height, imageData); + } + } + } + + return imageData; + } + + private static void DecompressDxt3Block(BinaryReader imageReader, int x, int y, int blockCountX, int width, int height, byte[] imageData) + { + byte a0 = imageReader.ReadByte(); + byte a1 = imageReader.ReadByte(); + byte a2 = imageReader.ReadByte(); + byte a3 = imageReader.ReadByte(); + byte a4 = imageReader.ReadByte(); + byte a5 = imageReader.ReadByte(); + byte a6 = imageReader.ReadByte(); + byte a7 = imageReader.ReadByte(); + + ushort c0 = imageReader.ReadUInt16(); + ushort c1 = imageReader.ReadUInt16(); + + byte r0, g0, b0; + byte r1, g1, b1; + ConvertRgb565ToRgb888(c0, out r0, out g0, out b0); + ConvertRgb565ToRgb888(c1, out r1, out g1, out b1); + + uint lookupTable = imageReader.ReadUInt32(); + + int alphaIndex = 0; + for (int blockY = 0; blockY < 4; blockY++) + { + for (int blockX = 0; blockX < 4; blockX++) + { + byte r = 0, g = 0, b = 0, a = 0; + + uint index = (lookupTable >> 2 * (4 * blockY + blockX)) & 0x03; + + switch (alphaIndex) + { + case 0: + a = (byte)((a0 & 0x0F) | ((a0 & 0x0F) << 4)); + break; + case 1: + a = (byte)((a0 & 0xF0) | ((a0 & 0xF0) >> 4)); + break; + case 2: + a = (byte)((a1 & 0x0F) | ((a1 & 0x0F) << 4)); + break; + case 3: + a = (byte)((a1 & 0xF0) | ((a1 & 0xF0) >> 4)); + break; + case 4: + a = (byte)((a2 & 0x0F) | ((a2 & 0x0F) << 4)); + break; + case 5: + a = (byte)((a2 & 0xF0) | ((a2 & 0xF0) >> 4)); + break; + case 6: + a = (byte)((a3 & 0x0F) | ((a3 & 0x0F) << 4)); + break; + case 7: + a = (byte)((a3 & 0xF0) | ((a3 & 0xF0) >> 4)); + break; + case 8: + a = (byte)((a4 & 0x0F) | ((a4 & 0x0F) << 4)); + break; + case 9: + a = (byte)((a4 & 0xF0) | ((a4 & 0xF0) >> 4)); + break; + case 10: + a = (byte)((a5 & 0x0F) | ((a5 & 0x0F) << 4)); + break; + case 11: + a = (byte)((a5 & 0xF0) | ((a5 & 0xF0) >> 4)); + break; + case 12: + a = (byte)((a6 & 0x0F) | ((a6 & 0x0F) << 4)); + break; + case 13: + a = (byte)((a6 & 0xF0) | ((a6 & 0xF0) >> 4)); + break; + case 14: + a = (byte)((a7 & 0x0F) | ((a7 & 0x0F) << 4)); + break; + case 15: + a = (byte)((a7 & 0xF0) | ((a7 & 0xF0) >> 4)); + break; + } + ++alphaIndex; + + switch (index) + { + case 0: + r = r0; + g = g0; + b = b0; + break; + case 1: + r = r1; + g = g1; + b = b1; + break; + case 2: + r = (byte)((2 * r0 + r1) / 3); + g = (byte)((2 * g0 + g1) / 3); + b = (byte)((2 * b0 + b1) / 3); + break; + case 3: + r = (byte)((r0 + 2 * r1) / 3); + g = (byte)((g0 + 2 * g1) / 3); + b = (byte)((b0 + 2 * b1) / 3); + break; + } + + int px = (x << 2) + blockX; + int py = (y << 2) + blockY; + if ((px < width) && (py < height)) + { + int offset = ((py * width) + px) << 2; + imageData[offset] = r; + imageData[offset + 1] = g; + imageData[offset + 2] = b; + imageData[offset + 3] = a; + } + } + } + } + + internal static byte[] DecompressDxt5(byte[] imageData, int width, int height) + { + using (MemoryStream imageStream = new MemoryStream(imageData)) + return DecompressDxt5(imageStream, width, height); + } + + internal static byte[] DecompressDxt5(Stream imageStream, int width, int height) + { + byte[] imageData = new byte[width * height * 4]; + + using (BinaryReader imageReader = new BinaryReader(imageStream)) + { + int blockCountX = (width + 3) / 4; + int blockCountY = (height + 3) / 4; + + for (int y = 0; y < blockCountY; y++) + { + for (int x = 0; x < blockCountX; x++) + { + DecompressDxt5Block(imageReader, x, y, blockCountX, width, height, imageData); + } + } + } + + return imageData; + } + + private static void DecompressDxt5Block(BinaryReader imageReader, int x, int y, int blockCountX, int width, int height, byte[] imageData) + { + byte alpha0 = imageReader.ReadByte(); + byte alpha1 = imageReader.ReadByte(); + + ulong alphaMask = (ulong)imageReader.ReadByte(); + alphaMask += (ulong)imageReader.ReadByte() << 8; + alphaMask += (ulong)imageReader.ReadByte() << 16; + alphaMask += (ulong)imageReader.ReadByte() << 24; + alphaMask += (ulong)imageReader.ReadByte() << 32; + alphaMask += (ulong)imageReader.ReadByte() << 40; + + ushort c0 = imageReader.ReadUInt16(); + ushort c1 = imageReader.ReadUInt16(); + + byte r0, g0, b0; + byte r1, g1, b1; + ConvertRgb565ToRgb888(c0, out r0, out g0, out b0); + ConvertRgb565ToRgb888(c1, out r1, out g1, out b1); + + uint lookupTable = imageReader.ReadUInt32(); + + for (int blockY = 0; blockY < 4; blockY++) + { + for (int blockX = 0; blockX < 4; blockX++) + { + byte r = 0, g = 0, b = 0, a = 255; + uint index = (lookupTable >> 2 * (4 * blockY + blockX)) & 0x03; + + uint alphaIndex = (uint)((alphaMask >> 3 * (4 * blockY + blockX)) & 0x07); + if (alphaIndex == 0) + { + a = alpha0; + } + else if (alphaIndex == 1) + { + a = alpha1; + } + else if (alpha0 > alpha1) + { + a = (byte)(((8 - alphaIndex) * alpha0 + (alphaIndex - 1) * alpha1) / 7); + } + else if (alphaIndex == 6) + { + a = 0; + } + else if (alphaIndex == 7) + { + a = 0xff; + } + else + { + a = (byte)(((6 - alphaIndex) * alpha0 + (alphaIndex - 1) * alpha1) / 5); + } + + switch (index) + { + case 0: + r = r0; + g = g0; + b = b0; + break; + case 1: + r = r1; + g = g1; + b = b1; + break; + case 2: + r = (byte)((2 * r0 + r1) / 3); + g = (byte)((2 * g0 + g1) / 3); + b = (byte)((2 * b0 + b1) / 3); + break; + case 3: + r = (byte)((r0 + 2 * r1) / 3); + g = (byte)((g0 + 2 * g1) / 3); + b = (byte)((b0 + 2 * b1) / 3); + break; + } + + int px = (x << 2) + blockX; + int py = (y << 2) + blockY; + if ((px < width) && (py < height)) + { + int offset = ((py * width) + px) << 2; + imageData[offset] = r; + imageData[offset + 1] = g; + imageData[offset + 2] = b; + imageData[offset + 3] = a; + } + } + } + } + + private static void ConvertRgb565ToRgb888(ushort color, out byte r, out byte g, out byte b) + { + int temp; + + temp = (color >> 11) * 255 + 16; + r = (byte)((temp / 32 + temp) / 32); + temp = ((color & 0x07E0) >> 5) * 255 + 32; + g = (byte)((temp / 64 + temp) / 64); + temp = (color & 0x001F) * 255 + 16; + b = (byte)((temp / 32 + temp) / 32); + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs new file mode 100644 index 0000000..5520909 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs @@ -0,0 +1,579 @@ +// HudController.cs — Owner of RynthAi's floating HUD windows. +// +// * Pack item count HUD (ItemCountHud): icon + carried count for pinned items. +// * Mini Remote (MiniRemoteHud): session stats, attack target, summon (health / time +// left, fed by CombatHudTracker), 30 quick-use item slots, macro toggles, bank balances +// and rebuff buttons. +// * Inventory HUDs setup window (HudSetupUi): picks what the two HUDs show. Opened from +// the Inventory Management settings (ImGui Advanced Settings, the Avalonia Settings +// panel) or "/ra huds". +// * The same Mini Remote inside the engine's RynthAi dashboard (its Mini Remote drawer, +// RynthPluginRenderEmbed "miniremote") and inside the engine's Mini Remote window +// ("miniremote-window"): RenderEmbedded. Data polling runs while any of them shows it +// (MiniRemoteActive); the floating window stays hidden while the engine's window shows it +// (MiniRemoteInEngineWindow), so there is one Mini Remote on screen. +// Every HUD is an ordinary ImGui window, so it can be docked into / undocked from other +// ImGui windows and dragged outside the game window (multi-viewport). +// +// Threading: host reads and every game action run on the pump thread (Tick / posted +// actions). The render thread only reads the published pack snapshot and toggles simple +// flags; list edits are posted so the pump thread is the only writer. +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using RynthCore.Plugin.RynthAi.IltHub; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.Huds; + +/// One carried item name, aggregated over every stack in the pack. +internal sealed record HudPackRow(string Name, uint Wcid, uint IconDid, long Count, int FirstId); + +/// Immutable pack view published by the pump thread. +internal sealed class HudPackSnapshot +{ + public static readonly HudPackSnapshot Empty = new(Array.Empty()); + + public HudPackRow[] Rows { get; } + public Dictionary ByName { get; } + + public HudPackSnapshot(HudPackRow[] rows) + { + Rows = rows; + ByName = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (var r in rows) ByName[r.Name] = r; + } + + public long CountOf(string name) => ByName.TryGetValue(name, out var r) ? r.Count : 0; +} + +internal sealed class HudController +{ + private const uint StypeIcon = 8; // DataID Icon → PWD _iconID + private const int StypeStackSize = 12; + private const long PackScanIntervalMs = 1000; + private const long SaveIntervalMs = 5000; + + private readonly RynthCoreHost _host; + private readonly Func _cache; + private readonly HudStore _store; + private readonly ConcurrentQueue _posted = new(); + private readonly Dictionary _iconById = new(); + private readonly ItemCountHud _itemHud; + private readonly MiniRemoteHud _miniRemote; + private readonly HudSetupUi _setup; + private readonly CombatHudTracker _combat; + + private volatile HudPackSnapshot _pack = HudPackSnapshot.Empty; + private long _lastScanAt; + private long _lastSaveAt; + private bool _scanRequested; + + /// + /// How long a pack item the player selected stays assignable after the game selection moves + /// on (the combat bot re-selects monsters, so "the selected item" is often gone by the time + /// the player clicks a slot). + /// + private const long RememberSelectionMs = 120_000; + private uint _lastSeenSelection; + private int _lastPackSelId; + private long _lastPackSelAt; + private volatile string _assignCandidate = string.Empty; + + public HudController(RynthCoreHost host, string charFolder, Func cache, + LegacyDashboardRenderer dashboard, Func hub, HudIconCache icons, Func attackTargetId) + { + _host = host; + _cache = cache; + _store = new HudStore(charFolder); + State = _store.Load(); + Icons = icons; + Dashboard = dashboard; + Hub = hub; + _itemHud = new ItemCountHud(this); + _miniRemote = new MiniRemoteHud(this); + _setup = new HudSetupUi(this); + _combat = new CombatHudTracker(host, cache, attackTargetId); + } + + public HudState State { get; } + public HudIconCache Icons { get; } + public LegacyDashboardRenderer Dashboard { get; } + public Func Hub { get; } + public RynthCoreHost Host => _host; + + /// The Mini Remote's session stats (the same SessionStats code as RynthTracker); null if it failed to start. + public RynthCore.Plugin.Shared.SessionStatsTracker? SessionStats { get; init; } + + /// Latest pack view (render thread safe). + public HudPackSnapshot Pack => _pack; + + /// Latest attack target / summon view (render thread safe). + public CombatHudSnapshot Combat => _combat.Snapshot; + + /// + /// Name of the pack item a slot click would assign (current or remembered selection); empty + /// when there is none. Render thread safe. + /// + public string AssignCandidate => _assignCandidate; + + /// Chat translator views for the Mini Remote row; null until the translator exists. + public RynthCore.Plugin.RynthAi.Translate.TranslateUi? Translate { get; set; } + + /// Queues work for the next pump tick (safe from the render thread). + public void Post(Action action) => _posted.Enqueue(action); + + /// + /// Runs a RynthCore "/rc ..." command through the engine's chat dispatcher on the next pump + /// tick (any thread). Says so in chat when this RynthCore can't run it. + /// + public void RunEngineCommand(string command) + { + if (string.IsNullOrWhiteSpace(command)) return; + Post(() => + { + if (_host.HasInvokeChatParser && _host.InvokeChatParser(command)) return; + Chat($"[Mini Remote] {command} needs RynthCore's ImGui layer; type it in chat to see why."); + }); + } + + private static long NowMs => Environment.TickCount64; + + /// + /// How long after its last frame in the RynthAi dashboard's Mini Remote drawer the remote + /// still counts as on screen (the drawer draws every frame while it is out). + /// + private const long EmbeddedVisibleMs = 1500; + + /// When the Mini Remote last drew in an engine surface (TickCount64); written on the render thread. + private long _embeddedDrawnAt = long.MinValue / 2; + + /// When the engine's Mini Remote window last drew it (TickCount64); written on the render thread. + private long _windowDrawnAt = long.MinValue / 2; + + /// The Mini Remote is on screen: the floating window or an engine surface. Any thread. + public bool MiniRemoteActive => + State.ShowMiniRemote || NowMs - System.Threading.Interlocked.Read(ref _embeddedDrawnAt) < EmbeddedVisibleMs; + + /// + /// The engine's Mini Remote window is showing the remote: the floating copy stays hidden + /// meanwhile, so there is one Mini Remote on screen. Any thread. + /// + public bool MiniRemoteInEngineWindow => + NowMs - System.Threading.Interlocked.Read(ref _windowDrawnAt) < EmbeddedVisibleMs; + + // ── Pump thread ───────────────────────────────────────────────────────── + + public void Tick() + { + int guard = 0; + while (guard++ < 64 && _posted.TryDequeue(out var a)) + { + try { a(); } + catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "posted HUD action"); } + } + + long now = NowMs; + // The pack is only scanned while something shows it. + bool remote = MiniRemoteActive; + bool needPack = State.ShowItemHud || remote || State.ShowSetup; + if (needPack && (_scanRequested || now - _lastScanAt >= PackScanIntervalMs)) + { + _scanRequested = false; + _lastScanAt = now; + RebuildPack(); + } + + Icons.Tick(); + if (needPack) TrackPackSelection(now); + + // Target / summon polling sends health queries and appraisals, so it only runs while shown. + if (remote && (State.MiniShowTarget || State.MiniShowPet)) + _combat.Tick(); + + if (now - _lastSaveAt >= SaveIntervalMs) + { + _lastSaveAt = now; + _store.SaveIfDirty(State); + } + } + + public void OnLogout() + { + _store.SaveIfDirty(State); + _pack = HudPackSnapshot.Empty; + _iconById.Clear(); + _combat.OnLogout(); + } + + /// Aggregates the pack by item name and refreshes pinned entries' icon / WCID. + private void RebuildPack() + { + var cache = _cache(); + if (cache == null) return; + + var byName = new Dictionary(StringComparer.OrdinalIgnoreCase); + var seen = new HashSet(); + foreach (var wo in cache.GetInventory()) + { + if (wo == null || string.IsNullOrWhiteSpace(wo.Name)) continue; + seen.Add(wo.Id); + long count = Math.Max(1, wo.Values(StypeStackSize, 1)); + if (byName.TryGetValue(wo.Name, out var row)) + { + byName[wo.Name] = row with { Count = row.Count + count }; + continue; + } + byName[wo.Name] = new HudPackRow(wo.Name, Wcid(wo), IconOf(wo), count, wo.Id); + } + + // Forget icon lookups for items that left the pack. + if (_iconById.Count > seen.Count + 64) + foreach (int id in _iconById.Keys.Where(k => !seen.Contains(k)).ToList()) _iconById.Remove(id); + + var snap = new HudPackSnapshot(byName.Values.OrderBy(r => r.Name, StringComparer.OrdinalIgnoreCase).ToArray()); + _pack = snap; + + // Remember icon / WCID on pinned entries so they still draw while none are carried. + foreach (var e in State.ItemHudItems.Concat(State.MiniRemoteSlots)) + { + if (e.IsEmpty || !snap.ByName.TryGetValue(e.Name, out var r)) continue; + if (r.IconDid != 0) e.IconDid = r.IconDid; + if (r.Wcid != 0) e.Wcid = r.Wcid; + } + } + + private uint IconOf(WorldObject wo) + { + if (_iconById.TryGetValue(wo.Id, out uint icon) && icon != 0) return icon; + if (_host.HasGetObjectDataIdProperty && _host.TryGetObjectDataIdProperty(unchecked((uint)wo.Id), StypeIcon, out icon)) + _iconById[wo.Id] = icon; + return icon; + } + + private uint Wcid(WorldObject wo) + => _host.HasGetObjectWcid && _host.TryGetObjectWcid(unchecked((uint)wo.Id), out uint w) ? w : 0; + + // ── Actions (pump thread; post them from the render thread) ────────────── + + /// Rescans the pack on the next tick. + public void RequestScan() => _scanRequested = true; + + /// Uses one carried item by name (falls back to WCID when the name changed). + public void UseItem(HudItemEntry entry) + { + if (entry.IsEmpty) return; + var cache = _cache(); + if (cache == null || !_host.HasUseObject) return; + var inv = cache.GetInventory().Where(w => w != null).ToList(); + var wo = inv.FirstOrDefault(w => w.Name.Equals(entry.Name, StringComparison.OrdinalIgnoreCase)) + ?? (entry.Wcid != 0 ? inv.FirstOrDefault(w => Wcid(w) == entry.Wcid) : null); + if (wo == null) { Chat($"[RynthAi] No {entry.Name} in your pack."); return; } + _host.UseObject(unchecked((uint)wo.Id)); + RynthLog.Trace(LogCat.Huds, $"use {wo.Name} (0x{wo.Id:X8})"); + } + + /// Carried item by object id, or null. + private WorldObject? PackItem(int id) + => id == 0 ? null : _cache()?.GetInventory().FirstOrDefault(w => w != null && w.Id == id); + + /// + /// Remembers the last pack item selected in the game (native inventory, or the RynthCore + /// Inventory window, which mirrors its clicks to the game selection). Only re-checks the + /// pack when the selection changes. + /// + private void TrackPackSelection(long now) + { + if (!_host.HasGetSelectedItemId) return; + uint sel = _host.GetSelectedItemId(); + if (sel != _lastSeenSelection) + { + _lastSeenSelection = sel; + var wo = PackItem(unchecked((int)sel)); + if (wo != null) + { + _lastPackSelId = wo.Id; + _lastPackSelAt = now; + } + } + // The candidate label only feeds tooltips / menus: refresh it a few times a second. + if (now - _lastCandidateAt < 250) return; + _lastCandidateAt = now; + var candidate = AssignablePackItem(quiet: true); + _assignCandidate = candidate?.Name ?? string.Empty; + } + private long _lastCandidateAt; + + /// + /// The pack item to assign: the current game selection when it is carried, otherwise the + /// last carried item the player selected within . + /// + private WorldObject? AssignablePackItem(bool quiet = false) + { + if (!_host.HasGetSelectedItemId) + { + if (!quiet) Chat("[RynthAi] This client build can't read the selected item."); + return null; + } + uint selected = _host.GetSelectedItemId(); + var wo = PackItem(unchecked((int)selected)); + bool fellBack = false; + long rememberedAge = NowMs - _lastPackSelAt; + if (wo == null && _lastPackSelId != 0 && rememberedAge <= RememberSelectionMs) + { + wo = PackItem(_lastPackSelId); + fellBack = wo != null; + } + // Quiet calls feed tooltips several times a second: only real assignments are traced. + if (!quiet) + { + string selInfo = selected == 0 ? "none" : $"0x{selected:X8} ({(fellBack || wo == null ? DescribeCacheEntry(unchecked((int)selected)) : "in inventory")})"; + string result = wo == null ? "nothing to assign" + : fellBack ? $"fell back to remembered 0x{_lastPackSelId:X8} '{wo.Name}' ({rememberedAge / 1000.0:0.0} s old)" + : $"selected '{wo.Name}'"; + RynthLog.Trace(LogCat.Huds, $"assign candidate: selected={selInfo}; {result}"); + } + if (wo == null && !quiet) + Chat("[RynthAi] Click an item in your pack (game inventory or RynthCore Inventory) first, " + + "or drag it from the RynthCore Inventory onto the slot."); + return wo; + } + + /// The item to act on for "use the selected item" HUD actions. + private WorldObject? SelectedPackItem() => AssignablePackItem(); + + public void AddSelectedToItemHud() + { + var wo = SelectedPackItem(); + if (wo != null) AddToItemHud(wo.Name); + } + + public void AddToItemHud(string name) + { + if (string.IsNullOrWhiteSpace(name) || State.ItemHudItems.Any(e => e.Name.Equals(name, StringComparison.OrdinalIgnoreCase))) return; + var row = _pack.ByName.TryGetValue(name, out var r) ? r : null; + State.ItemHudItems.Add(new HudItemEntry { Name = name, Wcid = row?.Wcid ?? 0, IconDid = row?.IconDid ?? 0 }); + RynthLog.Trace(LogCat.Huds, $"item HUD += '{name}' (first id 0x{(uint)(row?.FirstId ?? 0):X8}, wcid {row?.Wcid ?? 0}, in pack scan: {(row != null ? "yes" : "no")})"); + } + + /// + /// Adds to the item count HUD (if missing) and shows the HUD. + /// Icon and WCID fill in on the next pack scan. Returns the chat confirmation. + /// + public string AddToItemHudAndShow(string name) + { + name = name.Trim(); + bool already = State.ItemHudItems.Any(e => e.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); + if (!already) AddToItemHud(name); + State.ShowItemHud = true; + RequestScan(); + return already ? $"{name} is already on the item count HUD." : $"Added {name} to the item count HUD."; + } + + public void RemoveFromItemHud(string name) + => State.ItemHudItems.RemoveAll(e => e.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); + + /// Moves a HUD entry up (-1) or down (+1) in display order. + public void MoveItemHudEntry(string name, int delta) + { + var list = State.ItemHudItems; + int i = list.FindIndex(e => e.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); + int j = i + delta; + if (i < 0 || j < 0 || j >= list.Count) return; + (list[i], list[j]) = (list[j], list[i]); + } + + /// Removes HUD entries for items no longer carried. + public void DropMissingFromItemHud() + { + var pack = _pack; + int n = State.ItemHudItems.RemoveAll(e => pack.CountOf(e.Name) == 0); + Chat(n > 0 ? $"[RynthAi] Removed {n} item(s) you no longer carry from the HUD." : "[RynthAi] Every HUD item is still in your pack."); + } + + /// Puts the selected (or last selected) pack item into Mini Remote slot . + public void SetSlotFromSelection(int slot) + { + if (slot < 0 || slot >= State.MiniRemoteSlots.Count) return; + var wo = AssignablePackItem(); + if (wo != null) AssignSlot(slot, wo); + } + + /// + /// Puts carried item into (-1 = first empty + /// slot). Used by drag-and-drop from the RynthCore Inventory and its "Add to Mini Remote" menu. + /// + public void SetSlotFromItemId(int slot, uint objectId) + { + var wo = PackItem(unchecked((int)objectId)); + if (wo == null) + { + // The cache's view of the id shows a classification miss (item filed outside inventory). + int invCount = _cache()?.GetInventory().Count() ?? -1; + RynthLog.Trace(LogCat.Huds, $"slot-from-id: 0x{objectId:X8} not in inventory ({invCount} items); {DescribeCacheEntry(unchecked((int)objectId))}"); + Chat("[RynthAi] That item is no longer in your pack."); + return; + } + RynthLog.Trace(LogCat.Huds, $"slot-from-id: 0x{objectId:X8} = '{wo.Name}' ({wo.ObjectClass}), requested slot {(slot < 0 ? "first empty" : (slot + 1).ToString("00"))}"); + if (slot < 0) slot = State.MiniRemoteSlots.FindIndex(e => e.IsEmpty); + if (slot < 0) { Chat("[RynthAi] Every Mini Remote slot is in use. Clear one first (right-click it)."); return; } + if (slot >= State.MiniRemoteSlots.Count) return; + AssignSlot(slot, wo); + } + + private void AssignSlot(int slot, WorldObject wo) + { + var row = _pack.ByName.TryGetValue(wo.Name, out var r) ? r : null; + var entry = new HudItemEntry { Name = wo.Name, Wcid = row?.Wcid ?? Wcid(wo), IconDid = row?.IconDid ?? IconOf(wo) }; + State.MiniRemoteSlots[slot] = entry; + RynthLog.Trace(LogCat.Huds, $"assign slot {slot + 1:00} = '{wo.Name}' 0x{(uint)wo.Id:X8} (wcid {entry.Wcid}, icon 0x{entry.IconDid:X8})"); + Chat($"[RynthAi] Mini Remote slot {slot + 1:00} = {wo.Name}."); + } + + /// How the world cache knows (for traces): name and class, or that it doesn't. + private string DescribeCacheEntry(int id) + { + var cache = _cache(); + if (cache == null) return "no world cache"; + var wo = cache[id]; + return wo == null ? "unknown to the world cache" : $"world cache has '{wo.Name}' as {wo.ObjectClass}"; + } + + /// + /// Remote command "remoteslot <slot|first> <objectId>" (RynthCore Inventory menu). + /// Slot is 1-based. Returns false when the value can't be parsed. + /// + public bool HandleRemoteSlot(string value) + { + var parts = (value ?? string.Empty).Split(' ', StringSplitOptions.RemoveEmptyEntries); + int slot = 0; + bool ok = parts.Length == 2 && uint.TryParse(parts[1], out _); + if (ok) + { + if (parts[0].Equals("first", StringComparison.OrdinalIgnoreCase)) slot = -1; + else if (int.TryParse(parts[0], out int n) && n >= 1) slot = n - 1; + else ok = false; + } + if (!ok) + { + RynthLog.Trace(LogCat.Huds, $"remoteslot '{value}': can't parse (expected ' ')"); + return false; + } + uint id = uint.Parse(parts[1]); + RynthLog.Trace(LogCat.Huds, $"remoteslot '{value}': slot {(slot < 0 ? "first empty" : (slot + 1).ToString("00"))}, id 0x{id:X8}"); + SetSlotFromItemId(slot, id); + return true; + } + + public void ClearSlot(int slot) + { + if (slot >= 0 && slot < State.MiniRemoteSlots.Count) State.MiniRemoteSlots[slot] = new HudItemEntry(); + } + + public void Chat(string text) + { + // Every message the player sees also lands in the Huds trace. + RynthLog.Trace(LogCat.Huds, "chat: " + text); + if (_host.HasWriteToChat) _host.WriteToChat(text, 1); + } + + /// + /// "/ra huds|itemhud|remote [show|hide|toggle]" and the matching remote command. + /// Returns the chat confirmation. + /// + public string HandleCommand(string which, string mode) + { + static bool Resolve(string m, bool current) => m.ToLowerInvariant() switch + { + "show" or "on" or "true" or "1" => true, + "hide" or "off" or "false" or "0" => false, + _ => !current, + }; + + switch (which) + { + case "itemhud": + State.ShowItemHud = Resolve(mode, State.ShowItemHud); + return State.ShowItemHud ? "Pack item count HUD shown." : "Pack item count HUD hidden."; + case "remote": + case "miniremote": + State.ShowMiniRemote = Resolve(mode, State.ShowMiniRemote); + if (State.ShowMiniRemote && MiniRemoteInEngineWindow) + return "The Mini Remote is open in RynthCore's Mini Remote window (bar button, /rc miniremote); the floating copy stays hidden while that window is open."; + return State.ShowMiniRemote ? "Mini Remote shown." : "Mini Remote hidden."; + default: + State.ShowSetup = Resolve(mode, State.ShowSetup); + return State.ShowSetup ? "Inventory HUDs window shown." : "Inventory HUDs window hidden."; + } + } + + /// + /// Puts the Mini Remote on tab ("" = the remote itself, else an ILT tab + /// id). Modes: "show" selects it and shows the Mini Remote (the floating one, unless RynthCore's + /// window hosts it); "hide" goes back to the remote tab when this tab is the one selected; + /// "toggle" does whichever undoes the current state; "select" only switches tabs (RynthCore's + /// dashboard opens its own window). Any thread: plain field writes the next frame applies. + /// Returns the chat reply. + /// + public string HandleTabCommand(string tab, string mode) + { + tab ??= string.Empty; + string label = tab.Length == 0 ? "Remote" : char.ToUpperInvariant(tab[0]) + tab.Substring(1); + bool selected = string.Equals(State.MiniRemoteTab, tab, StringComparison.OrdinalIgnoreCase); + string m = (mode ?? string.Empty).ToLowerInvariant(); + bool hide = m is "hide" or "off" or "close" + || (m is not ("show" or "on" or "open" or "select") && selected && MiniRemoteActive); + if (hide) + { + if (selected) _miniRemote.RequestTab(string.Empty); + return selected ? $"Mini Remote back on its Remote tab ({label} closed)." : $"The {label} tab isn't the one showing."; + } + _miniRemote.RequestTab(tab); + if (m == "select") return $"Mini Remote: {label} tab."; + if (!MiniRemoteActive && !MiniRemoteInEngineWindow) State.ShowMiniRemote = true; + return MiniRemoteInEngineWindow + ? $"Mini Remote (RynthCore's window): {label} tab." + : $"Mini Remote shown on its {label} tab."; + } + + // ── Render thread ─────────────────────────────────────────────────────── + + public void Render() + { + int pushed = LegacyDashboardRenderer.PushDashboardStyle(); + try + { + if (State.ShowSetup) _setup.Render(); + if (State.ShowItemHud) _itemHud.Render(); else _itemHud.OnHidden(); + // The engine's Mini Remote window hosts the same remote: draw one, not two. + if (State.ShowMiniRemote && !MiniRemoteInEngineWindow) _miniRemote.Render(); else _miniRemote.OnHidden(); + } + finally + { + ImGuiNET.ImGui.PopStyleColor(pushed); + } + } + + /// + /// Draws the Mini Remote into the engine's current ImGui window (the RynthAi dashboard's + /// Mini Remote drawer, or with the engine's Mini Remote window) + /// and returns the content size it wants. Render thread. + /// + public System.Numerics.Vector2 RenderEmbedded(bool window = false) + { + long now = NowMs; + System.Threading.Interlocked.Exchange(ref _embeddedDrawnAt, now); + if (window) System.Threading.Interlocked.Exchange(ref _windowDrawnAt, now); + int pushed = LegacyDashboardRenderer.PushDashboardStyle(); + try + { + return _miniRemote.RenderEmbedded(window); + } + finally + { + ImGuiNET.ImGui.PopStyleColor(pushed); + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudDraw.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudDraw.cs new file mode 100644 index 0000000..4f5cd3a --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudDraw.cs @@ -0,0 +1,56 @@ +// HudDraw.cs — Small ImGui drawing helpers shared by the HUD windows (render thread only). +using System; +using System.Numerics; +using ImGuiNET; + +namespace RynthCore.Plugin.RynthAi.Huds; + +internal static class HudDraw +{ + private static readonly Vector4 Opaque = new(1f, 1f, 1f, 1f); + private static readonly Vector4 Faded = new(1f, 1f, 1f, 0.35f); + private static readonly Vector4 NoBorder = Vector4.Zero; + + /// + /// Draws an item icon of pixels. While the texture is still + /// loading (or the item has no icon) a framed box with the name's first letter stands in. + /// fades it (e.g. none carried). + /// + public static void Icon(HudIconCache icons, uint iconDid, string name, float size, bool dim) + { + IntPtr tex = icons.GetTexture(iconDid); + var sz = new Vector2(size, size); + if (tex != IntPtr.Zero) + { + ImGui.Image(tex, sz, Vector2.Zero, Vector2.One, dim ? Faded : Opaque, NoBorder); + return; + } + Placeholder(name, sz, dim); + } + + /// Framed stand-in with the item's first letter, same footprint as an icon. + public static void Placeholder(string name, Vector2 size, bool dim) + { + Vector2 p = ImGui.GetCursorScreenPos(); + ImGui.Dummy(size); + var dl = ImGui.GetWindowDrawList(); + uint frame = ImGui.GetColorU32(new Vector4(0.45f, 0.55f, 0.65f, dim ? 0.35f : 0.8f)); + uint fill = ImGui.GetColorU32(new Vector4(0.12f, 0.16f, 0.22f, dim ? 0.35f : 0.8f)); + dl.AddRectFilled(p, p + size, fill, 3f); + dl.AddRect(p, p + size, frame, 3f); + if (string.IsNullOrEmpty(name)) return; + string letter = name.Substring(0, 1).ToUpperInvariant(); + Vector2 ts = ImGui.CalcTextSize(letter); + dl.AddText(p + (size - ts) * 0.5f, ImGui.GetColorU32(new Vector4(0.9f, 0.9f, 0.9f, dim ? 0.4f : 1f)), letter); + } + + /// "1468", "12.3k", "4.5m", "1.2b" — compact counts for tight HUD rows. + public static string Compact(double v) + { + double a = Math.Abs(v); + if (a >= 1e9) return (v / 1e9).ToString("0.0") + "b"; + if (a >= 1e6) return (v / 1e6).ToString("0.0") + "m"; + if (a >= 1e4) return (v / 1e3).ToString("0.0") + "k"; + return v.ToString("0"); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudIconCache.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudIconCache.cs new file mode 100644 index 0000000..0035700 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudIconCache.cs @@ -0,0 +1,266 @@ +// HudIconCache.cs — Item icons for the RynthAi HUD windows. +// +// An item's icon DID (PWD _iconID, 0x06xxxxxx) points at a Texture file in portal.dat. +// Decoding (dat read + pixel conversion) runs on the pump thread; the D3D9 texture is +// created lazily on the render thread, a few per frame, so a full pack never stalls a frame. +// Textures are POOL_MANAGED (they survive device resets) and are never released: plugin +// unload can run off the render thread, where touching the device is unsafe, and the +// whole set is a few hundred 32×32 icons. +using System; +using System.Collections.Concurrent; +using System.IO; +using System.Runtime.InteropServices; +using RynthCore.Plugin.RynthAi.Raycasting; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.Huds; + +internal sealed class HudIconCache +{ + // IDirect3DDevice9 / IDirect3DTexture9 vtable slots. + private const int VtCreateTexture = 23; + private const int VtLockRect = 19; + private const int VtUnlockRect = 20; + private const int VtRelease = 2; + private const uint D3DFMT_A8R8G8B8 = 21; + private const uint D3DPOOL_MANAGED = 1; + + /// Texture uploads allowed per rendered frame. + private const int UploadsPerFrame = 6; + /// Icons decoded per pump tick. + private const int DecodesPerTick = 12; + /// Runaway guard; a full character's icons are a few hundred. + private const int MaxIcons = 4000; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate int CreateTextureD(IntPtr dev, uint w, uint h, uint levels, uint usage, uint fmt, uint pool, out IntPtr tex, IntPtr shared); + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate int LockRectD(IntPtr tex, uint level, ref D3DLockedRect locked, IntPtr rect, uint flags); + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate int UnlockRectD(IntPtr tex, uint level); + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate uint ReleaseD(IntPtr obj); + + [StructLayout(LayoutKind.Sequential)] + private struct D3DLockedRect { public int Pitch; public IntPtr Bits; } + + /// Decoded icon in D3D A8R8G8B8 order (A<<24 | R<<16 | G<<8 | B). + private sealed class Decoded + { + public int Width; + public int Height; + public uint[] Pixels = Array.Empty(); + } + + private readonly RynthCoreHost _host; + private readonly Func _portal; + + // DID → decoded pixels (null value = decode failed, don't retry). + private readonly ConcurrentDictionary _decoded = new(); + // DIDs the render thread asked for that the pump thread hasn't decoded yet. + private readonly ConcurrentQueue _pending = new(); + private readonly ConcurrentDictionary _queued = new(); + + // Render thread only. + private readonly System.Collections.Generic.Dictionary _textures = new(); + private IntPtr _textureDevice; + private int _uploadFrame = -1; + private int _uploadsThisFrame; + + public HudIconCache(RynthCoreHost host, Func portal) + { + _host = host; + _portal = portal; + } + + // ── Render thread ─────────────────────────────────────────────────────── + + /// + /// ImGui texture id for , or IntPtr.Zero while it is still + /// being decoded / uploaded (callers draw a placeholder). + /// + public IntPtr GetTexture(uint iconDid) + { + if (iconDid == 0) return IntPtr.Zero; + IntPtr device = _host.D3DDevice; + if (device == IntPtr.Zero) return IntPtr.Zero; + + // A new device means the old textures belong to a dead device; forget them (not + // Release — the owning device may already be gone). + if (device != _textureDevice) + { + _textures.Clear(); + _textureDevice = device; + } + + if (_textures.TryGetValue(iconDid, out IntPtr tex)) return tex; + + if (!_decoded.TryGetValue(iconDid, out Decoded? d)) + { + if (_queued.TryAdd(iconDid, 0)) _pending.Enqueue(iconDid); + return IntPtr.Zero; + } + if (d == null) return IntPtr.Zero; + + int frame = ImGuiNET.ImGui.GetFrameCount(); + if (frame != _uploadFrame) { _uploadFrame = frame; _uploadsThisFrame = 0; } + if (_uploadsThisFrame >= UploadsPerFrame) return IntPtr.Zero; + _uploadsThisFrame++; + + tex = Upload(device, d); + // Failed uploads are remembered as Zero so they aren't retried every frame. + _textures[iconDid] = tex; + return tex; + } + + // ── Pump thread ───────────────────────────────────────────────────────── + + /// Decodes a batch of requested icons (dat reads stay off the render thread). + public void Tick() + { + var portal = _portal(); + if (portal == null || !portal.IsLoaded) return; + for (int i = 0; i < DecodesPerTick && _pending.TryDequeue(out uint did); i++) + { + _queued.TryRemove(did, out _); + if (_decoded.Count >= MaxIcons) { _decoded.TryAdd(did, null); continue; } + Decoded? d = null; + try { d = Decode(portal, did); } + catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, $"icon decode 0x{did:X8}"); } + _decoded[did] = d; + } + } + + // ── Decoding (Texture 0x06 → ARGB) ────────────────────────────────────── + + // Texture layout: Id(u32) Unknown(i32) Width(i32) Height(i32) Format(u32) Length(i32) + // Source[Length], then DefaultPaletteId(u32) for INDEX16 / P8. + private static Decoded? Decode(DatDatabase portal, uint textureId) + { + byte[]? data = portal.GetFileData(textureId); + if (data == null || data.Length < 24) return null; + using var ms = new MemoryStream(data); + using var r = new BinaryReader(ms); + r.ReadUInt32(); r.ReadInt32(); + int w = r.ReadInt32(), h = r.ReadInt32(); + uint fmt = r.ReadUInt32(); + int len = r.ReadInt32(); + if (w <= 0 || h <= 0 || w > 1024 || h > 1024 || len < 0 || ms.Position + len > ms.Length) return null; + byte[] src = r.ReadBytes(len); + uint palId = 0; + if ((fmt == 101 || fmt == 41) && ms.Position + 4 <= ms.Length) palId = r.ReadUInt32(); + + var px = new uint[w * h]; + static uint Argb(int a, int rr, int g, int b) => ((uint)a << 24) | ((uint)rr << 16) | ((uint)g << 8) | (uint)b; + + switch (fmt) + { + case 827611204: return FromRgba(DxtUtil.DecompressDxt1(src, w, h), w, h); // DXT1 + case 861165636: return FromRgba(DxtUtil.DecompressDxt3(src, w, h), w, h); // DXT3 + case 894720068: return FromRgba(DxtUtil.DecompressDxt5(src, w, h), w, h); // DXT5 + case 20: // R8G8B8, stored B,G,R + for (int i = 0; i < px.Length && i * 3 + 2 < src.Length; i++) px[i] = Argb(255, src[i * 3 + 2], src[i * 3 + 1], src[i * 3]); + break; + case 21: // A8R8G8B8, stored B,G,R,A + case 22: // X8R8G8B8 + for (int i = 0; i < px.Length && i * 4 + 3 < src.Length; i++) + px[i] = Argb(fmt == 22 ? 255 : src[i * 4 + 3], src[i * 4 + 2], src[i * 4 + 1], src[i * 4]); + break; + case 23: // R5G6B5 + for (int i = 0; i < px.Length && i * 2 + 1 < src.Length; i++) + { + int v = src[i * 2] | (src[i * 2 + 1] << 8); + px[i] = Argb(255, ((v >> 11) & 0x1F) << 3, ((v >> 5) & 0x3F) << 2, (v & 0x1F) << 3); + } + break; + case 26: // A4R4G4B4 + for (int i = 0; i < px.Length && i * 2 + 1 < src.Length; i++) + { + int v = src[i * 2] | (src[i * 2 + 1] << 8); + px[i] = Argb(((v >> 12) & 0xF) * 17, ((v >> 8) & 0xF) * 17, ((v >> 4) & 0xF) * 17, (v & 0xF) * 17); + } + break; + case 28: // A8 greyscale + for (int i = 0; i < px.Length && i < src.Length; i++) px[i] = Argb(255, src[i], src[i], src[i]); + break; + case 101: // INDEX16 + case 41: // P8 + { + uint[]? pal = LoadPalette(portal, palId); + if (pal == null || pal.Length == 0) return null; + bool p8 = fmt == 41; + for (int i = 0; i < px.Length; i++) + { + int idx; + if (p8) { if (i >= src.Length) break; idx = src[i]; } + else { if (i * 2 + 1 >= src.Length) break; idx = src[i * 2] | (src[i * 2 + 1] << 8); } + px[i] = pal[idx % pal.Length]; // palette entries are already ARGB + } + break; + } + default: + return null; + } + return new Decoded { Width = w, Height = h, Pixels = px }; + } + + /// Palette (0x04): Id(u32), Count(i32), Count × ARGB(u32). + private static uint[]? LoadPalette(DatDatabase portal, uint paletteId) + { + byte[]? data = portal.GetFileData(paletteId); + if (data == null || data.Length < 8) return null; + int n = BitConverter.ToInt32(data, 4); + if (n <= 0 || n > 65536) return null; + n = Math.Min(n, (data.Length - 8) / 4); + var pal = new uint[n]; + for (int i = 0; i < n; i++) pal[i] = BitConverter.ToUInt32(data, 8 + i * 4); + return pal; + } + + /// DxtUtil output (R,G,B,A bytes) → ARGB. + private static Decoded FromRgba(byte[] rgba, int w, int h) + { + var px = new uint[w * h]; + for (int i = 0; i < px.Length && i * 4 + 3 < rgba.Length; i++) + px[i] = ((uint)rgba[i * 4 + 3] << 24) | ((uint)rgba[i * 4] << 16) | ((uint)rgba[i * 4 + 1] << 8) | rgba[i * 4 + 2]; + return new Decoded { Width = w, Height = h, Pixels = px }; + } + + // ── D3D9 upload (render thread) ───────────────────────────────────────── + + private static unsafe IntPtr Upload(IntPtr device, Decoded d) + { + try + { + int hr = Vt(device, VtCreateTexture)(device, (uint)d.Width, (uint)d.Height, 1, 0, + D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, out IntPtr tex, IntPtr.Zero); + if (hr < 0 || tex == IntPtr.Zero) return IntPtr.Zero; + + var locked = new D3DLockedRect(); + if (Vt(tex, VtLockRect)(tex, 0, ref locked, IntPtr.Zero, 0) < 0) + { + Vt(tex, VtRelease)(tex); + return IntPtr.Zero; + } + // Row by row: the locked pitch can be wider than Width * 4. + for (int row = 0; row < d.Height; row++) + { + fixed (uint* src = &d.Pixels[row * d.Width]) + Buffer.MemoryCopy(src, (void*)IntPtr.Add(locked.Bits, row * locked.Pitch), d.Width * 4, d.Width * 4); + } + Vt(tex, VtUnlockRect)(tex, 0); + return tex; + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.Huds, ex, "icon upload"); + return IntPtr.Zero; + } + } + + private static unsafe T Vt(IntPtr obj, int index) where T : Delegate + { + void** vt = *(void***)obj; + return Marshal.GetDelegateForFunctionPointer((IntPtr)vt[index]); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudSetupUi.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudSetupUi.cs new file mode 100644 index 0000000..ff41ed1 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudSetupUi.cs @@ -0,0 +1,183 @@ +// HudSetupUi.cs — "Inventory HUDs" setup window (UtilityBelt Item Hud tab equivalent). +// +// * Show / hide the pack item count HUD and the Mini Remote. +// * Two lists: items on the HUD (left) and carried items not on it (right). +// "<" pins the highlighted right row, ">" unpins the highlighted left row, +// Up / Down reorder the HUD. "Add from inventory" pins the item selected in the game. +// * Mini Remote slots: pick a slot, then Set (selected game item) or Clear. +// Render thread only; list edits are posted to the pump thread. +using System; +using System.Linq; +using System.Numerics; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.Huds; + +internal sealed class HudSetupUi +{ + private const float ListIcon = 18f; + + private readonly HudController _hud; + private string _selOnHud = string.Empty; + private string _selInPack = string.Empty; + private string _packFilter = string.Empty; + private int _slot; + + public HudSetupUi(HudController hud) => _hud = hud; + + public void Render() + { + var s = _hud.State; + ImGui.SetNextWindowSize(new Vector2(640, 520), ImGuiCond.FirstUseEver); + bool open = true; + bool visible = ImGui.Begin("Inventory HUDs##rynthhudsetup", ref open); + if (!open) s.ShowSetup = false; + if (!visible) { ImGui.End(); return; } + + RenderHudToggles(s); + ImGui.Separator(); + RenderItemLists(s); + ImGui.Separator(); + RenderSlotPicker(s); + ImGui.End(); + } + + private static void RenderHudToggles(HudState s) + { + bool itemHud = s.ShowItemHud; + if (ImGui.Checkbox("Show pack item count HUD", ref itemHud)) s.ShowItemHud = itemHud; + ImGui.SameLine(); + bool names = s.ItemHudShowNames; + if (ImGui.Checkbox("with names", ref names)) s.ItemHudShowNames = names; + ImGui.SameLine(); + bool remote = s.ShowMiniRemote; + if (ImGui.Checkbox("Show Mini Remote", ref remote)) s.ShowMiniRemote = remote; + ImGui.TextDisabled("Both are separate windows: drag them anywhere, dock them into other RynthAi windows,"); + ImGui.TextDisabled("or pull them outside the game window. Right-click a HUD for its options."); + } + + private void RenderItemLists(HudState s) + { + ImGui.TextWrapped("Left = shown on the HUD. Right = in your pack but not on the HUD. " + + "< pins the highlighted right row; > removes the highlighted left row. " + + "Add from inventory uses the item selected in the game."); + + if (ImGui.Button("Scan pack")) _hud.Post(_hud.RequestScan); + ImGui.SameLine(); + if (ImGui.Button("Add from inventory")) _hud.Post(_hud.AddSelectedToItemHud); + ImGui.SameLine(); + if (ImGui.Button("Drop missing")) _hud.Post(_hud.DropMissingFromItemHud); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Remove HUD items you no longer carry."); + + var entries = s.ItemHudItems.ToArray(); + var pack = _hud.Pack; + float listH = 230f; + float colW = Math.Max(180f, (ImGui.GetContentRegionAvail().X - 50f) * 0.5f); + + // ── Left: on the HUD ── + ImGui.BeginGroup(); + ImGui.TextUnformatted($"On HUD ({entries.Length})"); + if (ImGui.BeginChild("##hudon", new Vector2(colW, listH), ImGuiChildFlags.Borders)) + { + foreach (var e in entries) + { + long count = pack.CountOf(e.Name); + if (Row(e.Name, e.IconDid, $"{e.Name} | {count:N0}", _selOnHud == e.Name, count == 0)) + _selOnHud = e.Name; + } + } + ImGui.EndChild(); + bool haveLeft = entries.Any(e => e.Name == _selOnHud); + ImGui.BeginDisabled(!haveLeft); + string upName = _selOnHud; + if (ImGui.SmallButton("Up")) _hud.Post(() => _hud.MoveItemHudEntry(upName, -1)); + ImGui.SameLine(); + if (ImGui.SmallButton("Down")) _hud.Post(() => _hud.MoveItemHudEntry(upName, +1)); + ImGui.EndDisabled(); + ImGui.EndGroup(); + + // ── Middle: move buttons ── + ImGui.SameLine(); + ImGui.BeginGroup(); + ImGui.Dummy(new Vector2(1, listH * 0.35f)); + ImGui.BeginDisabled(string.IsNullOrEmpty(_selInPack)); + string add = _selInPack; + if (ImGui.Button("<", new Vector2(36, 0))) { _hud.Post(() => _hud.AddToItemHud(add)); _selInPack = string.Empty; } + ImGui.EndDisabled(); + ImGui.BeginDisabled(!haveLeft); + string remove = _selOnHud; + if (ImGui.Button(">", new Vector2(36, 0))) { _hud.Post(() => _hud.RemoveFromItemHud(remove)); _selOnHud = string.Empty; } + ImGui.EndDisabled(); + ImGui.EndGroup(); + + // ── Right: in pack, not on the HUD ── + ImGui.SameLine(); + ImGui.BeginGroup(); + ImGui.TextUnformatted("Not on HUD"); + ImGui.SameLine(); + ImGui.SetNextItemWidth(Math.Max(80f, colW - 90f)); + ImGui.InputTextWithHint("##hudpackfilter", "filter", ref _packFilter, 64u); + if (ImGui.BeginChild("##hudoff", new Vector2(colW, listH), ImGuiChildFlags.Borders)) + { + var pinned = entries.Select(e => e.Name).ToHashSet(StringComparer.OrdinalIgnoreCase); + foreach (var r in pack.Rows) + { + if (pinned.Contains(r.Name)) continue; + if (_packFilter.Length > 0 && !r.Name.Contains(_packFilter, StringComparison.OrdinalIgnoreCase)) continue; + if (Row(r.Name, r.IconDid, $"{r.Name} | {r.Count:N0}", _selInPack == r.Name, false)) + _selInPack = r.Name; + // Double-click pins straight away. + if (ImGui.IsItemHovered() && ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left)) + { + string name = r.Name; + _hud.Post(() => _hud.AddToItemHud(name)); + } + } + if (pack.Rows.Length == 0) ImGui.TextDisabled("Scanning your pack..."); + } + ImGui.EndChild(); + ImGui.EndGroup(); + } + + /// Icon + label selectable row; returns true when clicked. + private bool Row(string name, uint iconDid, string label, bool selected, bool dim) + { + Vector2 start = ImGui.GetCursorPos(); + bool clicked = ImGui.Selectable($"##row{name}", selected, ImGuiSelectableFlags.AllowOverlap, new Vector2(0, ListIcon)); + ImGui.SetCursorPos(start); + HudDraw.Icon(_hud.Icons, iconDid, name, ListIcon, dim); + ImGui.SameLine(); + if (dim) ImGui.TextDisabled(label); + else ImGui.TextUnformatted(label); + return clicked; + } + + private void RenderSlotPicker(HudState s) + { + var slots = s.MiniRemoteSlots.ToArray(); + if (slots.Length == 0) return; + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Mini Remote slots"); + ImGui.TextDisabled($"Slot 01 = top-left of the Mini Remote grid ({HudState.MiniRemoteColumns} per row). " + + "Select an item in your pack, pick the slot, then Set."); + _slot = Math.Clamp(_slot, 0, slots.Length - 1); + string Label(int i) => $"{i + 1:00} - {(slots[i].IsEmpty ? "(empty)" : slots[i].Name)}"; + + ImGui.SetNextItemWidth(320); + if (ImGui.BeginCombo("##mrslot", Label(_slot))) + { + for (int i = 0; i < slots.Length; i++) + if (ImGui.Selectable(Label(i), i == _slot)) _slot = i; + ImGui.EndCombo(); + } + int slot = _slot; + ImGui.SameLine(); + if (ImGui.Button("Set")) _hud.Post(() => _hud.SetSlotFromSelection(slot)); + ImGui.SameLine(); + ImGui.BeginDisabled(slots[slot].IsEmpty); + if (ImGui.Button("Clear")) _hud.Post(() => _hud.ClearSlot(slot)); + ImGui.EndDisabled(); + ImGui.SameLine(); + if (ImGui.Button("Refresh")) _hud.Post(_hud.RequestScan); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudState.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudState.cs new file mode 100644 index 0000000..eaabf0d --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudState.cs @@ -0,0 +1,136 @@ +// HudState.cs — Persisted per-character settings for the floating HUD windows +// (\huds.json). Fields, not properties, so the source-generated +// RynthAiJsonContext (IncludeFields) round-trips them under NativeAOT. +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace RynthCore.Plugin.RynthAi.Huds; + +public sealed class HudState +{ + /// Mini Remote gem grid size (UB layout: 5 columns × 6 rows). + public const int MiniRemoteColumns = 5; + public const int MiniRemoteSlotCount = 30; + /// Mini Remote slot icon edge in pixels: the grow / shrink range and the default. + public const float MinMiniRemoteSlotSize = 18f, MaxMiniRemoteSlotSize = 64f, DefaultMiniRemoteSlotSize = 28f; + + /// The "Inventory HUDs" setup window is open. + public bool ShowSetup; + + // ── Pack item count HUD ── + public bool ShowItemHud; + public bool ItemHudShowNames; + public bool ItemHudLocked; + public float ItemHudIconSize = 20f; + /// Items shown on the HUD, in display order (matched by name). + public List ItemHudItems = new(); + + // ── Mini Remote ── + public bool ShowMiniRemote; + public bool MiniRemoteLocked; + /// Sections laid out side by side in columns (the V/H button) instead of stacked. + public bool MiniRemoteHorizontal; + public bool MiniShowStats = true; + /// Attack target row: name, health bar, distance. + public bool MiniShowTarget = true; + /// Pet row: the summon that is out (health, time left), else the next combat essence. + public bool MiniShowPet = true; + public bool MiniShowGems = true; + public bool MiniShowToggles = true; + public bool MiniShowBank = true; + public bool MiniShowRebuff = true; + /// Chat translator row: on/off, receive / send language swap. + public bool MiniShowTranslate = true; + /// Temple guardian row: the last riddle answer with a Give button (only while one is recent). + public bool MiniShowGuardian = true; + /// Gem grid slots, row-major from the top-left (empty Name = unassigned). + public List MiniRemoteSlots = new(); + /// + /// Slot icon edge in pixels (Ctrl+wheel over the slots, or Options > Slot size). + /// Clamped to ... + /// + public float MiniRemoteSlotSize = DefaultMiniRemoteSlotSize; + /// + /// The Mini Remote's selected tab: "" for the remote itself, else an ILT tab id + /// (IltSections.TabId: character, quests, pets, banking, gear, charms, games). + /// + public string MiniRemoteTab = string.Empty; +} + +/// An item pinned to a HUD. Matched by name; Wcid / IconDid are remembered so the +/// entry still shows its icon while none are carried. +public sealed class HudItemEntry +{ + public string Name = string.Empty; + public uint Wcid; + public uint IconDid; + + [JsonIgnore] public bool IsEmpty => string.IsNullOrWhiteSpace(Name); +} + +/// Loads / dirty-checked saves of . +internal sealed class HudStore +{ + private readonly string _charFolder; + private string _lastJson = string.Empty; + + public HudStore(string charFolder) => _charFolder = charFolder ?? string.Empty; + + private string StatePath => Path.Combine(_charFolder, "huds.json"); + + public HudState Load() + { + HudState? s = null; + try + { + if (_charFolder.Length > 0 && File.Exists(StatePath)) + { + string json = File.ReadAllText(StatePath); + s = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.HudState); + if (s != null) _lastJson = json; + } + } + catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, $"load {StatePath}"); } + s ??= new HudState(); + Normalize(s); + return s; + } + + /// Writes the state only when its JSON differs from the last write. + public void SaveIfDirty(HudState state) + { + if (_charFolder.Length == 0) return; + try + { + string json = JsonSerializer.Serialize(state, RynthAiJsonContext.Default.HudState); + if (json == _lastJson) return; + Directory.CreateDirectory(_charFolder); + string tmp = StatePath + ".tmp"; + File.WriteAllText(tmp, json); + File.Move(tmp, StatePath, overwrite: true); + _lastJson = json; + } + catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, $"save {StatePath}"); } + } + + /// Repairs null lists / out-of-range values after deserialization. + private static void Normalize(HudState s) + { + s.ItemHudItems ??= new(); + s.ItemHudItems.RemoveAll(e => e == null || e.IsEmpty); + s.ItemHudIconSize = Math.Clamp(s.ItemHudIconSize, 12f, 48f); + s.MiniRemoteSlots ??= new(); + for (int i = 0; i < s.MiniRemoteSlots.Count; i++) s.MiniRemoteSlots[i] ??= new HudItemEntry(); + while (s.MiniRemoteSlots.Count < HudState.MiniRemoteSlotCount) s.MiniRemoteSlots.Add(new HudItemEntry()); + if (s.MiniRemoteSlots.Count > HudState.MiniRemoteSlotCount) + s.MiniRemoteSlots.RemoveRange(HudState.MiniRemoteSlotCount, s.MiniRemoteSlots.Count - HudState.MiniRemoteSlotCount); + s.MiniRemoteTab ??= string.Empty; + // A huds.json from before the setting has no value (0): use the default. + s.MiniRemoteSlotSize = s.MiniRemoteSlotSize <= 0f || float.IsNaN(s.MiniRemoteSlotSize) + ? HudState.DefaultMiniRemoteSlotSize + : Math.Clamp(s.MiniRemoteSlotSize, HudState.MinMiniRemoteSlotSize, HudState.MaxMiniRemoteSlotSize); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/ItemCountHud.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/ItemCountHud.cs new file mode 100644 index 0000000..7ae9702 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/ItemCountHud.cs @@ -0,0 +1,89 @@ +// ItemCountHud.cs — Floating "pack item count" HUD: one row per pinned item with its +// icon, carried count and (optionally) name. Right-click for options. Render thread only. +using System.Linq; +using System.Numerics; +using ImGuiNET; + +namespace RynthCore.Plugin.RynthAi.Huds; + +internal sealed class ItemCountHud +{ + private const string OptionsPopup = "##itemhudopts"; + private static readonly Vector4 ColCount = new(0.95f, 0.95f, 0.95f, 1f); + private static readonly Vector4 ColNone = new(0.95f, 0.45f, 0.40f, 1f); + private static readonly Vector4 ColName = new(0.70f, 0.75f, 0.80f, 1f); + + private readonly HudController _hud; + private bool _rescueChecked; // off-screen check done for the current show + + public ItemCountHud(HudController hud) => _hud = hud; + + /// The HUD was not drawn this frame: check its position again on the next show. + public void OnHidden() => _rescueChecked = false; + + public void Render() + { + var s = _hud.State; + var entries = s.ItemHudItems.ToArray(); + var pack = _hud.Pack; + + var flags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar + | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNav; + if (s.ItemHudLocked) flags |= ImGuiWindowFlags.NoMove; + + // Right of and above centre, clear of the character in the middle of the view. + UiPlacement.CenterFirstUse(new Vector2(220, -160)); + ImGui.SetNextWindowBgAlpha(0.55f); + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(4, 4)); + ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 2)); + bool visible = ImGui.Begin("Item HUD##rynthitemhud", flags); + ImGui.PopStyleVar(2); + if (!visible) { ImGui.End(); return; } + UiPlacement.RescueOncePerShow(ref _rescueChecked); + + if (entries.Length == 0) + { + ImGui.TextDisabled("Item HUD is empty."); + ImGui.TextDisabled("Right-click > Edit items..."); + } + + float size = s.ItemHudIconSize; + foreach (var e in entries) + { + long count = pack.CountOf(e.Name); + HudDraw.Icon(_hud.Icons, e.IconDid, e.Name, size, count == 0); + if (ImGui.IsItemHovered()) ImGui.SetTooltip($"{e.Name}\n{count:N0} carried"); + ImGui.SameLine(); + // Vertically centre the text on the icon. + float pad = (size - ImGui.GetTextLineHeight()) * 0.5f; + if (pad > 0) ImGui.SetCursorPosY(ImGui.GetCursorPosY() + pad); + ImGui.TextColored(count == 0 ? ColNone : ColCount, count.ToString("N0")); + if (s.ItemHudShowNames) + { + ImGui.SameLine(); + ImGui.TextColored(ColName, e.Name); + } + } + + if (ImGui.IsWindowHovered() && ImGui.IsMouseReleased(ImGuiMouseButton.Right)) ImGui.OpenPopup(OptionsPopup); + RenderOptions(s); + ImGui.End(); + } + + private void RenderOptions(HudState s) + { + if (!ImGui.BeginPopup(OptionsPopup)) return; + ImGui.TextDisabled("Item HUD"); + bool names = s.ItemHudShowNames; + if (ImGui.Checkbox("Show names", ref names)) s.ItemHudShowNames = names; + bool locked = s.ItemHudLocked; + if (ImGui.Checkbox("Lock position", ref locked)) s.ItemHudLocked = locked; + float size = s.ItemHudIconSize; + ImGui.SetNextItemWidth(120); + if (ImGui.SliderFloat("Icon size", ref size, 12f, 48f, "%.0f")) s.ItemHudIconSize = size; + ImGui.Separator(); + if (ImGui.MenuItem("Edit items...")) s.ShowSetup = true; + if (ImGui.MenuItem("Hide HUD")) s.ShowItemHud = false; + ImGui.EndPopup(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/MiniRemoteHud.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/MiniRemoteHud.cs new file mode 100644 index 0000000..a4d2aa9 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/MiniRemoteHud.cs @@ -0,0 +1,953 @@ +// MiniRemoteHud.cs — The Mini Remote (UtilityBelt-style) for RynthAi. Render thread only. +// +// One window with tabs: Remote (the sections below), the universal tabs Quests and Pets (every +// world), and on ILT worlds the ILT tabs Character, Banking, Gear and Games (IltHubUi draws +// their bodies; an ILT tab shows once the server reports its feature on). The tab bar's +// selection is saved (HudState.MiniRemoteTab) and "/ra hub open
" or RynthCore's +// dashboard switch it (RequestTab). The Guardian (ILT only) and Bounties are RynthCore ILT +// panels (the bar's ILT button). +// Right-click on the remote: "Character" (Spells, Quests, Pets, Skills, Inventory, Item Count, +// Inventory HUDs: windows every server has), then "Server: ", i.e. the installed server +// plugins' windows for the world you're on, which RynthCore sends (ServerMenuModel), or "Treat +// this world as ..." when none matches. The Options button holds the Mini Remote's own settings. +// The V/H button stacks the sections (vertical) or lays them out in three columns (horizontal). +// +// Remote sections (each can be hidden from the Options menu): +// Stats session time and per-hour XP / luminance / kills / coins / pyreals (ILT rates) +// Target the creature combat is attacking: name, health bar, distance +// Pet the summon that is out (health bar, time left), else the next combat essence and +// whether it is ready +// Slots 5 × 6 quick-use item grid; click uses the item (an empty slot takes the selected +// pack item), right-click assigns / clears, and items dragged from the game's +// inventory or the RynthCore Inventory window drop straight into a slot. Ctrl+wheel +// over the grid (or Options > Slot size) grows / shrinks the boxes. +// Toggles macro and subsystem switches (same as the dashboard buttons; not in the drawer) +// Bank ILT bank balances (pyreals, luminance, keys, coins) +// Rebuff force rebuff / cancel rebuff +// Translate chat translator on/off and the receive <-> send language swap +// Guardian the last Temple guardian answer with a Give button (only while it is recent) +// All game actions are posted to the pump thread. +// +// RenderEmbedded draws the same sections and Options menu inside the engine's RynthAi dashboard +// (its Mini Remote drawer, opened by the Hub launcher's right-click or the drawer tab) and +// reports the size it wants; the drawer is sized from that. The drawer leaves out Toggles (the +// dashboard it sits on already has those switches) and the tabs (it is too narrow for them). +// RenderEmbedded(window: true) draws it in the engine's Mini Remote window instead (bar button, +// /rc miniremote): tabs and Toggles included, and the floating window stays hidden meanwhile +// (HudController), so that window is the one Mini Remote. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using System.Threading; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.IltHub; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.Huds; + +internal sealed class MiniRemoteHud +{ + private const string OptionsPopup = "##miniremoteopts"; + private const string MenuPopup = "##miniremotemenu"; + private const string SlotPopup = "##miniremoteslot"; + /// Pixels per Ctrl+wheel notch over the slot grid. + private const float SlotSizeStep = 2f; + /// Narrowest horizontal-layout column (fits the stat lines and the translate row). + private const float MinColumnWidth = 190f; + private const float HeaderButtonWidth = 80f; + + private static readonly Vector4 ColLabel = new(0.80f, 0.84f, 0.90f, 1f); + private static readonly Vector4 ColReady = new(0.40f, 0.95f, 0.45f, 1f); + private static readonly Vector4 ColOut = new(0.45f, 0.85f, 0.95f, 1f); + private static readonly Vector4 ColEmpty = new(0.95f, 0.45f, 0.40f, 1f); + private static readonly Vector4 ColBusy = new(0.95f, 0.80f, 0.35f, 1f); + + private readonly HudController _hud; + private int _slotMenuIndex = -1; + private bool _rescueChecked; // off-screen check done for the current show + private bool _columnOpen; // horizontal layout: a column was already started this frame (next one goes SameLine) + private bool _embedded; // true only inside RenderEmbedded (an engine surface) + private bool _inWindow; // with _embedded: the engine's Mini Remote window, not the dashboard drawer + // A tab switch asked for by a command or the engine (any thread), applied by the next tab bar; + // null = none. Starts as the saved tab so the first tab bar restores it. + private string? _pendingTab; + private bool _pendingTabFromState = true; + // This frame's tab bar showed the Remote tab (right-click Options belongs to it only). + private bool _onRemoteTab = true; + // The Options button was clicked this frame (the popup opens at window level). + private bool _openOptions; + // The ILT tabs offered this frame (reused, so a frame doesn't allocate). + private readonly List _tabs = new(); + + public MiniRemoteHud(HudController hud) => _hud = hud; + + /// The remote was not drawn this frame: check its position again on the next show. + public void OnHidden() => _rescueChecked = false; + + /// + /// Switches to tab ("" = the remote, else an ILT tab id) on the next + /// frame the tab bar draws. Any thread. + /// + public void RequestTab(string tab) + { + _pendingTabFromState = false; + Volatile.Write(ref _pendingTab, tab ?? string.Empty); + } + + public void Render() + { + var s = _hud.State; + var flags = ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar + | ImGuiWindowFlags.NoFocusOnAppearing; + if (s.MiniRemoteLocked) flags |= ImGuiWindowFlags.NoMove; + + // Left of and above centre, mirroring the Item HUD's first spot. + UiPlacement.CenterFirstUse(new Vector2(-220, -160)); + ImGui.SetNextWindowBgAlpha(0.70f); + bool open = true; + ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 3)); + bool visible = ImGui.Begin("Mini Remote##rynthminiremote", ref open, flags); + ImGui.PopStyleVar(); + if (!open) s.ShowMiniRemote = false; + if (!visible) { ImGui.End(); return; } + UiPlacement.RescueOncePerShow(ref _rescueChecked); + + RenderBody(s, _hud.Hub(), allowTabs: true); + + // Right-click on the remote opens the Character / server menu, unless a slot's own menu is + // open (the ILT tabs have their own right-click menus). + if (_onRemoteTab && _slotMenuIndex < 0 && ImGui.IsWindowHovered(ImGuiHoveredFlags.ChildWindows) && ImGui.IsMouseReleased(ImGuiMouseButton.Right)) + ImGui.OpenPopup(MenuPopup); + RenderOptions(s, embedded: false); + RenderMenu(s); + _slotMenuIndex = -1; + ImGui.End(); + } + + /// + /// The same sections drawn into the caller's current window (the engine's RynthAi dashboard + /// drawer, or with the engine's Mini Remote window; both size + /// themselves from the result) instead of a window of their own. Returns the content size it + /// wants: the selected tab's width, and the height drawn. + /// + public Vector2 RenderEmbedded(bool window = false) + { + var s = _hud.State; + _slotMenuIndex = -1; + _embedded = true; + _inWindow = window; + float startY = ImGui.GetCursorPosY(); + ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 3)); + try + { + float width = RenderBody(s, _hud.Hub(), allowTabs: !InDrawer); + + if (_onRemoteTab && _slotMenuIndex < 0 && ImGui.IsWindowHovered(ImGuiHoveredFlags.ChildWindows) && ImGui.IsMouseReleased(ImGuiMouseButton.Right)) + ImGui.OpenPopup(MenuPopup); + RenderOptions(s, embedded: true); + RenderMenu(s); + + float height = ImGui.GetCursorPosY() - startY - ImGui.GetStyle().ItemSpacing.Y; + return new Vector2(width, Math.Max(0f, height) + 2f); + } + finally + { + ImGui.PopStyleVar(); + _slotMenuIndex = -1; + _embedded = false; + _inWindow = false; + } + } + + // ── Tabs ──────────────────────────────────────────────────────────────── + + /// + /// The tab bar (when : the universal tabs on every world, the ILT + /// tabs on ILT worlds) and the selected tab: the remote, or a tab's body in a child of its + /// fixed size. Returns the width the content wants (never narrower than the tab bar's labels). + /// + private float RenderBody(HudState s, IltHubController? hub, bool allowTabs) + { + _onRemoteTab = true; + _tabs.Clear(); + if (allowTabs && hub != null) + { + foreach (IltSection section in IltSections.Tabs) + if (hub.TabShown(section)) _tabs.Add(section); + } + if (_tabs.Count == 0) + { + RenderRemote(s, hub); + return EmbeddedWidth(s); + } + + if (_pendingTabFromState) + { + _pendingTabFromState = false; + Interlocked.CompareExchange(ref _pendingTab, s.MiniRemoteTab ?? string.Empty, null); + } + string? pending = Interlocked.Exchange(ref _pendingTab, null); + float width = TabBarWidth(); + _onRemoteTab = false; + if (ImGui.BeginTabBar("##mrtabs", ImGuiTabBarFlags.FittingPolicyScroll | ImGuiTabBarFlags.NoTooltip)) + { + if (BeginTab(RemoteTabLabel, TabFlags(IltSections.RemoteTab, pending))) + { + _onRemoteTab = true; + s.MiniRemoteTab = IltSections.RemoteTab; + RenderRemote(s, hub); + width = Math.Max(width, EmbeddedWidth(s)); + ImGui.EndTabItem(); + } + foreach (IltSection section in _tabs) + { + string id = IltSections.TabId(section); + if (!BeginTab(TabLabels[(int)section], TabFlags(id, pending))) continue; + s.MiniRemoteTab = id; + Vector2 size = IltHubUi.TabSize(section); + // The tab draws into a child of its own size; tables in it scroll inside it. + ImGui.BeginChild(TabBodyIds[(int)section], size, ImGuiChildFlags.None, ImGuiWindowFlags.None); + hub!.RenderTab(section); + ImGui.EndChild(); + width = Math.Max(width, size.X); + ImGui.EndTabItem(); + } + ImGui.EndTabBar(); + } + return width; + } + + // Tab labels as NUL-terminated UTF-8 and the tab body child ids, indexed by (int)IltSection, + // built once so the tab bar doesn't allocate per frame. + private static readonly byte[] RemoteTabLabel = Utf8Z("Remote##mrtab"); + private static readonly byte[][] TabLabels = BuildPerSection(s => Utf8Z(IltSections.Label(s) + "##mrtab")); + private static readonly string[] TabBodyIds = BuildPerSection(s => "##mrtabbody_" + IltSections.TabId(s)); + + private static T[] BuildPerSection(Func make) + { + var result = new T[(int)IltSection.Guardian + 1]; + foreach (IltSection section in IltSections.Tabs) result[(int)section] = make(section); + return result; + } + + private static byte[] Utf8Z(string text) + { + byte[] bytes = new byte[System.Text.Encoding.UTF8.GetByteCount(text) + 1]; + System.Text.Encoding.UTF8.GetBytes(text, 0, text.Length, bytes, 0); + return bytes; + } + + /// + /// BeginTabItem without a close button: ImGui.NET only wraps the flags overload together with + /// p_open, and a non-null p_open draws an X on the tab. + /// + private static unsafe bool BeginTab(byte[] labelUtf8Z, ImGuiTabItemFlags flags) + { + fixed (byte* label = labelUtf8Z) + return ImGuiNative.igBeginTabItem(label, null, flags) != 0; + } + + /// SetSelected for the tab a command asked for this frame. + private static ImGuiTabItemFlags TabFlags(string id, string? pending) => + pending != null && string.Equals(pending, id, StringComparison.OrdinalIgnoreCase) + ? ImGuiTabItemFlags.SetSelected : ImGuiTabItemFlags.None; + + /// Width of every tab label side by side (the embedded window shouldn't be narrower, or tabs scroll). + private float TabBarWidth() + { + var style = ImGui.GetStyle(); + float w = ImGui.CalcTextSize("Remote").X + style.FramePadding.X * 2f; + foreach (IltSection section in _tabs) + w += style.ItemInnerSpacing.X + ImGui.CalcTextSize(IltSections.Label(section)).X + style.FramePadding.X * 2f; + return w; + } + + /// The Remote tab: the [V/H] [Options] row, then the sections in the chosen layout. + private void RenderRemote(HudState s, IltHubController? hub) + { + RenderHeaderRow(s); + if (s.MiniRemoteHorizontal) RenderHorizontal(s, hub); + else RenderVertical(s, hub); + } + + /// In the dashboard drawer (not the floating window or the engine's Mini Remote window). + private bool InDrawer => _embedded && !_inWindow; + + /// The Toggles section is drawn: chosen in Options, and never in the dashboard drawer. + private bool ShowToggles(HudState s) => s.MiniShowToggles && !InDrawer; + + /// + /// The width the sections need: one column stacked, else one per non-empty column side by side. + /// Never measured from what was drawn, since widgets fill the width they are given. + /// + private float EmbeddedWidth(HudState s) + { + float colW = ColumnWidth(s); + if (!s.MiniRemoteHorizontal) return colW; + int cols = 0; + if (s.MiniShowStats || s.MiniShowTarget || s.MiniShowPet) cols++; + if (s.MiniShowGems || ShowToggles(s)) cols++; + if (s.MiniShowBank || s.MiniShowRebuff || s.MiniShowTranslate || s.MiniShowGuardian) cols++; + cols = Math.Max(1, cols); + return cols * colW + (cols - 1) * ImGui.GetStyle().ItemSpacing.X; + } + + // ── Layout ────────────────────────────────────────────────────────────── + + /// [V/H] and [Options] buttons. Fixed widths so the auto-resizing window can't grow from them. + private void RenderHeaderRow(HudState s) + { + if (ImGui.Button((s.MiniRemoteHorizontal ? "H" : "V") + "##mrlayout", new Vector2(HeaderButtonWidth, 0))) + s.MiniRemoteHorizontal = !s.MiniRemoteHorizontal; + if (ImGui.IsItemHovered()) + ImGui.SetTooltip(s.MiniRemoteHorizontal ? "Horizontal: sections in columns. Click to stack them." : "Vertical: sections stacked. Click to lay them out in columns."); + ImGui.SameLine(); + // Opened by RenderOptions: this row sits inside the Remote tab, whose ID the popup must not get. + if (ImGui.Button("Options##mropts", new Vector2(HeaderButtonWidth, 0))) _openOptions = true; + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Mini Remote settings: sections, layout, slot size.\nRight-click the remote for the Character and server windows."); + } + + private void RenderVertical(HudState s, IltHubController? hub) + { + RenderStatusSections(s, hub); + RenderActionSections(s); + RenderEconomySections(s, hub); + } + + /// + /// Three side-by-side columns: status (stats, target, pet), actions (slots, toggles) and + /// economy (bank, rebuff, translate). Each column is a fixed-width child that grows only in + /// height; widgets sized from the available width would otherwise make the auto-resizing + /// window grow every frame. + /// + private void RenderHorizontal(HudState s, IltHubController? hub) + { + float colW = ColumnWidth(s); + _columnOpen = false; + if (s.MiniShowStats || s.MiniShowTarget || s.MiniShowPet) + { + BeginColumn("##mrcolstatus", colW); + RenderStatusSections(s, hub); + ImGui.EndChild(); + } + if (s.MiniShowGems || ShowToggles(s)) + { + BeginColumn("##mrcolactions", colW); + RenderActionSections(s); + ImGui.EndChild(); + } + if (s.MiniShowBank || s.MiniShowRebuff || s.MiniShowTranslate || s.MiniShowGuardian) + { + BeginColumn("##mrcoleconomy", colW); + RenderEconomySections(s, hub); + ImGui.EndChild(); + } + } + + /// Starts a column child (caller always calls EndChild, whatever BeginChild returned). + private void BeginColumn(string id, float width) + { + if (_columnOpen) ImGui.SameLine(); + _columnOpen = true; + ImGui.BeginChild(id, new Vector2(width, 0), ImGuiChildFlags.AutoResizeY, ImGuiWindowFlags.NoScrollbar); + } + + /// Wide enough for the slot grid at its current size, and never narrower than MinColumnWidth. + private static float ColumnWidth(HudState s) + { + int cols = HudState.MiniRemoteColumns; + float grid = cols * SlotButtonSize(s) + (cols - 1) * ImGui.GetStyle().ItemSpacing.X; + return Math.Max(MinColumnWidth, grid); + } + + /// Slot icon edge in pixels (the saved size, clamped). + private static float SlotSize(HudState s) => + Math.Clamp(s.MiniRemoteSlotSize, HudState.MinMiniRemoteSlotSize, HudState.MaxMiniRemoteSlotSize); + + /// Slot button edge including its 1 px frame padding on each side. + private static float SlotButtonSize(HudState s) => SlotSize(s) + 2f; + + /// + /// Grows (+) or shrinks (-) the slot boxes within the saved range (huds.json picks it up on + /// the next SaveIfDirty, like every other HUD setting). + /// + private static void ResizeSlots(HudState s, float delta) => + s.MiniRemoteSlotSize = Math.Clamp(SlotSize(s) + delta, HudState.MinMiniRemoteSlotSize, HudState.MaxMiniRemoteSlotSize); + + private void RenderStatusSections(HudState s, IltHubController? hub) + { + var combat = _hud.Combat; + if (s.MiniShowStats) RenderStats(hub); + if (s.MiniShowTarget) RenderTarget(combat); + if (s.MiniShowPet) RenderPet(hub, combat); + if (s.MiniShowStats) RenderStatButtons(hub); + } + + private void RenderActionSections(HudState s) + { + if (s.MiniShowGems) RenderSlots(s); + if (ShowToggles(s)) RenderToggles(_hud.Dashboard.Settings); + } + + private void RenderEconomySections(HudState s, IltHubController? hub) + { + if (s.MiniShowBank) RenderBank(hub); + if (s.MiniShowRebuff) RenderRebuff(); + if (s.MiniShowTranslate && _hud.Translate is { } translate) translate.RenderHubSection(); + if (s.MiniShowGuardian && IltActive(hub)) hub!.Guardian.RenderRemoteLine(); + } + + // ── Sections ──────────────────────────────────────────────────────────── + + private static bool IltActive(IltHubController? hub) => hub != null && hub.Options.IsIltLikeWorld; + + private static void Stat(string label, string value) + { + ImGui.TextColored(ColLabel, label); + ImGui.SameLine(); + ImGui.TextUnformatted(value); + } + + /// + /// Session stats on every world: the shared SessionStats (RynthTracker's code, so these match the + /// Tracker panel), plus ILT coins and pyreals. + /// + private void RenderStats(IltHubController? hub) + { + var v = _hud.SessionStats?.View ?? RynthCore.Plugin.Shared.SessionStatsView.Empty; + Stat("Time:", IltParse.Duration(TimeSpan.FromSeconds(SessionClock(v)))); + Stat("XP:", HudDraw.Compact(v.XpPerHour) + "/h"); + Stat("Lum:", HudDraw.Compact(v.LumPerHour) + "/h"); + Stat("Lum 5m:", HudDraw.Compact(v.LumLast5Min)); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Luminance earned in the last five minutes."); + if (v.PassUpTracked) + { + Stat("Pass-up:", HudDraw.Compact(v.PassUpPerHour) + "/h"); + if (ImGui.IsItemHovered()) ImGui.SetTooltip($"{v.LumPassUp:N0} this session.\n{IltSessionRates.PassUpTooltip}"); + } + Stat("Kills:", HudDraw.Compact(v.KillsPerHour) + "/h"); + if (!IltActive(hub)) return; + var r = hub!.Rates.Summary; + Stat("Coins:", HudDraw.Compact(r.CoinsPerHour) + "/h"); + Stat("Pyr:", HudDraw.Compact(r.PyrealsPerHour) + "/h"); + } + + /// Seconds since the session started; 0 before it has (no login yet). + private static double SessionClock(RynthCore.Plugin.Shared.SessionStatsView v) + => ReferenceEquals(v, RynthCore.Plugin.Shared.SessionStatsView.Empty) + ? 0 : Math.Max(0, (DateTime.UtcNow - v.SessionStartUtc).TotalSeconds); + + private static void RenderTarget(CombatHudSnapshot c) + { + if (c.TargetId == 0) { ImGui.TextDisabled("Target: none"); return; } + ImGui.TextColored(ColLabel, "Target:"); + ImGui.SameLine(); + ImGui.TextUnformatted(c.TargetName); + if (c.TargetDistance >= 0) + { + ImGui.SameLine(); + ImGui.TextDisabled($"{c.TargetDistance:F0}yd"); + } + HealthBar("##mrtargethp", c.TargetHealth); + } + + /// The live summon when one is out, else the ILT Hub's next-essence line. + private static void RenderPet(IltHubController? hub, CombatHudSnapshot c) + { + if (c.PetId != 0) + { + RenderSummon(hub, c); + return; + } + if (!IltActive(hub)) { ImGui.TextDisabled("Summon: none"); return; } + string name = hub!.Pets.HudPetName; + string status = hub.Pets.HudPetStatus; + if (name.Length == 0) { ImGui.TextDisabled("No combat pet set"); return; } + ImGui.TextUnformatted(name); + var col = status switch { "Ready" => ColReady, "Out" => ColOut, "Healing" => ColBusy, _ => ColEmpty }; + ImGui.TextColored(col, status); + } + + private static void RenderSummon(IltHubController? hub, CombatHudSnapshot c) + { + ImGui.TextColored(ColLabel, "Summon:"); + ImGui.SameLine(); + ImGui.TextUnformatted(c.PetName); + if (IltActive(hub) && hub!.Pets.HudPetStatus == "Healing") + { + ImGui.SameLine(); + ImGui.TextColored(ColBusy, "Healing"); + } + HealthBar("##mrpethp", c.PetHealth); + + long now = Environment.TickCount64; + if (c.PetExpiresAtMs != 0) + { + long leftMs = Math.Max(0, c.PetExpiresAtMs - now); + var left = TimeSpan.FromMilliseconds(leftMs); + string text = $"{FormatClock(left)} left"; + if (c.PetLifespanSec > 0) + { + float frac = Math.Clamp(leftMs / (c.PetLifespanSec * 1000f), 0f, 1f); + var col = left.TotalSeconds <= 30 ? ColEmpty : left.TotalSeconds <= 90 ? ColBusy : ColOut; + Bar("##mrpettime", frac, text, col); + } + else + { + ImGui.TextColored(left.TotalSeconds <= 30 ? ColEmpty : ColOut, text); + } + } + else + { + // No RemainingLifespan from the server: show how long it has been out instead. + var up = TimeSpan.FromMilliseconds(Math.Max(0, now - c.PetSeenAtMs)); + ImGui.TextDisabled($"Out {FormatClock(up)}"); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("The server hasn't reported this summon's lifespan yet."); + } + } + + private static string FormatClock(TimeSpan t) + => t.TotalHours >= 1 ? $"{(int)t.TotalHours}:{t.Minutes:00}:{t.Seconds:00}" : $"{t.Minutes}:{t.Seconds:00}"; + + /// Health ratio bar coloured green / yellow / red; "--" until the first health update. + private static void HealthBar(string id, float ratio) + { + if (ratio < 0f) { Bar(id, 0f, "HP --", ColLabel); return; } + var col = ratio > 0.6f ? ColReady : ratio > 0.3f ? ColBusy : ColEmpty; + Bar(id, ratio, $"HP {ratio * 100f:F0}%", col); + } + + private static void Bar(string id, float fraction, string overlay, Vector4 color) + { + float w = Math.Max(ImGui.GetContentRegionAvail().X, 140f); + ImGui.PushStyleColor(ImGuiCol.PlotHistogram, color with { W = 0.85f }); + ImGui.PushID(id); + ImGui.ProgressBar(fraction, new Vector2(w, 14f), overlay); + ImGui.PopID(); + ImGui.PopStyleColor(); + } + + private void RenderStatButtons(IltHubController? hub) + { + float w = (ImGui.GetContentRegionAvail().X - ImGui.GetStyle().ItemSpacing.X) * 0.5f; + w = Math.Max(w, 70f); + if (ImGui.Button("Reset XP", new Vector2(w, 0))) + _hud.Post(() => + { + _hud.SessionStats?.RequestReset(); + _hud.Hub()?.Rates.Reset(); + }); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Start the session stats over (the Tracker panel keeps its own session)."); + ImGui.SameLine(); + if (ImGui.Button("Report", new Vector2(w, 0))) _hud.Post(ReportToChat); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Print the session rates in your chat window (local only)."); + } + + /// One-line session summary written to local chat (pump thread). + private void ReportToChat() + { + var v = _hud.SessionStats?.View ?? RynthCore.Plugin.Shared.SessionStatsView.Empty; + string time = IltParse.Duration(TimeSpan.FromSeconds(SessionClock(v))); + string line = $"[RynthAi] Session {time}: XP {HudDraw.Compact(v.XpPerHour)}/h, Lum {HudDraw.Compact(v.LumPerHour)}/h " + + $"({HudDraw.Compact(v.LumLast5Min)} last 5m)"; + if (v.PassUpTracked) line += $", Pass-up {HudDraw.Compact(v.PassUpPerHour)}/h"; + line += $", Kills {HudDraw.Compact(v.KillsPerHour)}/h ({v.Kills:N0})"; + var hub = _hud.Hub(); + if (IltActive(hub)) + { + var r = hub!.Rates.Summary; + line += $", Coins {HudDraw.Compact(r.CoinsPerHour)}/h, Pyr {HudDraw.Compact(r.PyrealsPerHour)}/h"; + } + _hud.Chat(line); + } + + private void RenderSlots(HudState s) + { + var slots = s.MiniRemoteSlots.ToArray(); + var pack = _hud.Pack; + float slotSize = SlotSize(s); + ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(1, 1)); + ImGui.BeginGroup(); + for (int i = 0; i < slots.Length; i++) + { + if (i % HudState.MiniRemoteColumns != 0) ImGui.SameLine(); + var e = slots[i]; + long count = e.IsEmpty ? 0 : pack.CountOf(e.Name); + ImGui.PushID(i); + bool clicked; + IntPtr tex = e.IsEmpty ? IntPtr.Zero : _hud.Icons.GetTexture(e.IconDid); + if (tex != IntPtr.Zero) + { + var tint = count == 0 ? new Vector4(1, 1, 1, 0.35f) : Vector4.One; + clicked = ImGui.ImageButton("##slot", tex, new Vector2(slotSize, slotSize), Vector2.Zero, Vector2.One, Vector4.Zero, tint); + } + else + { + string label = e.IsEmpty ? string.Empty : e.Name.Substring(0, 1).ToUpperInvariant(); + if (e.IsEmpty) ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.10f, 0.13f, 0.18f, 0.6f)); + clicked = ImGui.Button(label + "##slot", new Vector2(slotSize + 2, slotSize + 2)); + if (e.IsEmpty) ImGui.PopStyleColor(); + } + if (ImGui.IsItemHovered()) + ImGui.SetTooltip(e.IsEmpty ? EmptySlotTip(i) : $"{e.Name}\n{count:N0} carried\nClick to use, right-click for options.\nCtrl+wheel: box size."); + int slotIndex = i; + if (clicked) + { + // Empty slot: click assigns the selected (or last selected) pack item. + if (e.IsEmpty) _hud.Post(() => _hud.SetSlotFromSelection(slotIndex)); + else + { + var entry = e; + _hud.Post(() => _hud.UseItem(entry)); + } + } + AcceptItemDrop(slotIndex, e.IsEmpty); + if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + { + _slotMenuIndex = i; + ImGui.OpenPopup(SlotPopup); + } + RenderSlotMenu(i, e); + ImGui.PopID(); + } + ImGui.EndGroup(); + ImGui.PopStyleVar(); + + // Ctrl+wheel over the grid: bigger / smaller boxes (the window / drawer refits to them). + var io = ImGui.GetIO(); + if (io.KeyCtrl && io.MouseWheel != 0f && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenBlockedByActiveItem)) + ResizeSlots(s, io.MouseWheel > 0f ? SlotSizeStep : -SlotSizeStep); + } + + /// + /// ImGui drag-and-drop payload type for one inventory item (uint object id). Must match + /// InventoryFace.ItemPayloadType in RynthCore.Engine, which publishes it while dragging. + /// + private const string ItemPayloadType = "RYNTH_INV_ITEM"; + + /// + /// Payload type for an AC-inventory drag whose item the engine guessed from the game selection + /// (uint object id); engines that hook AC's drag start send the real item as ItemPayloadType + /// instead. Must match ItemDragBridge.NativePayloadType in RynthCore.Engine. A guess can be the + /// wrong item, so it is taken by empty slots only and never replaces an assigned one. + /// + private const string GameItemPayloadType = "RYNTH_GAME_ITEM"; + + /// + /// Makes the last slot button a drop target: RynthCore Inventory drags on any slot, game + /// inventory drags on slots. + /// + private unsafe void AcceptItemDrop(int slot, bool empty) + { + if (!ImGui.BeginDragDropTarget()) return; + ImGuiPayloadPtr payload = ImGui.AcceptDragDropPayload(ItemPayloadType); + if (payload.NativePtr == null && empty) payload = ImGui.AcceptDragDropPayload(GameItemPayloadType); + if (payload.NativePtr != null && payload.Data != IntPtr.Zero && payload.DataSize >= sizeof(uint)) + { + uint objectId = *(uint*)payload.Data; + _hud.Post(() => _hud.SetSlotFromItemId(slot, objectId)); + } + ImGui.EndDragDropTarget(); + } + + private string EmptySlotTip(int index) + { + string candidate = _hud.AssignCandidate; + return candidate.Length > 0 + ? $"Slot {index + 1:00}: empty\nClick to assign {candidate}.\nOr drag an item here from the game inventory or the RynthCore Inventory.\nCtrl+wheel: box size." + : $"Slot {index + 1:00}: empty\nClick an item in your pack, then click here to assign it.\nOr drag an item here from the game inventory or the RynthCore Inventory.\nCtrl+wheel: box size."; + } + + /// Per-slot right-click menu (opened inside the slot's ID scope). + private void RenderSlotMenu(int index, HudItemEntry e) + { + if (!ImGui.BeginPopup(SlotPopup)) return; + _slotMenuIndex = index; + ImGui.TextDisabled(e.IsEmpty ? $"Slot {index + 1:00}" : $"Slot {index + 1:00}: {e.Name}"); + string candidate = _hud.AssignCandidate; + if (ImGui.MenuItem(candidate.Length > 0 ? $"Assign {candidate}" : "Assign selected item")) + _hud.Post(() => _hud.SetSlotFromSelection(index)); + if (!e.IsEmpty && ImGui.MenuItem("Clear slot")) _hud.Post(() => _hud.ClearSlot(index)); + ImGui.EndPopup(); + } + + private void RenderToggles(LegacyUiSettings settings) + { + var dash = _hud.Dashboard; + if (!ImGui.BeginTable("##mrtoggles", 3, ImGuiTableFlags.SizingStretchSame)) return; + Toggle("Macro", settings.IsMacroRunning, _ => dash.TogglePanelMacro()); + Toggle("Combat", settings.EnableCombat, on => dash.SetSubsystemEnabled(0, on)); + Toggle("Buff", settings.EnableBuffing, on => dash.SetSubsystemEnabled(1, on)); + Toggle("Nav", settings.EnableNavigation, on => dash.SetSubsystemEnabled(2, on)); + Toggle("Loot", settings.EnableLooting, on => dash.SetSubsystemEnabled(3, on)); + Toggle("Meta", settings.EnableMeta, on => dash.SetSubsystemEnabled(4, on)); + Toggle("Pet", settings.SummonPets, on => { settings.SummonPets = on; dash.SaveSettings(); }); + ImGui.EndTable(); + } + + /// A checkbox in the next table cell whose change is applied on the pump thread. + private void Toggle(string label, bool current, Action apply) + { + ImGui.TableNextColumn(); + bool v = current; + if (ImGui.Checkbox(label + "##mrt", ref v)) _hud.Post(() => apply(v)); + } + + private static void RenderBank(IltHubController? hub) + { + if (!IltActive(hub) || hub!.Options.IsOff(IltFeature.Bank)) return; + var b = hub.State.Bank; + if (b.LastUpdated == DateTime.MinValue) { ImGui.TextDisabled("Bank: not loaded (Options > Banking)"); return; } + Stat("P:", HudDraw.Compact(b.Pyreals)); + Stat("Lum:", HudDraw.Compact(b.Luminance)); + if (!ImGui.BeginTable("##mrbank", 2, ImGuiTableFlags.SizingStretchSame)) return; + ImGui.TableNextColumn(); Stat("LK:", HudDraw.Compact(b.LegendaryKeys)); + ImGui.TableNextColumn(); Stat("MK:", HudDraw.Compact(b.MythicalKeys)); + ImGui.TableNextColumn(); Stat("EC:", HudDraw.Compact(b.EnlightenedCoins)); + ImGui.TableNextColumn(); Stat("WE:", HudDraw.Compact(b.WeaklyEnlightenedCoins)); + // Prestige Coins (ACECustom 2026-10-04): only once the server has reported some. + if (b.PrestigeCoins > 0) { ImGui.TableNextColumn(); Stat("PC:", HudDraw.Compact(b.PrestigeCoins)); } + ImGui.EndTable(); + } + + private void RenderRebuff() + { + var dash = _hud.Dashboard; + ImGui.TextColored(ColLabel, "Rebuff:"); + float w = (ImGui.GetContentRegionAvail().X - ImGui.GetStyle().ItemSpacing.X) * 0.5f; + w = Math.Max(w, 70f); + if (ImGui.Button("FB", new Vector2(w, 0))) _hud.Post(dash.RequestForceRebuff); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Force rebuff: recast every buff now."); + ImGui.SameLine(); + if (ImGui.Button("CFB", new Vector2(w, 0))) _hud.Post(dash.RequestCancelForceRebuff); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Cancel the running rebuff."); + } + + /// + /// The Options popup. : drawn in an engine surface, where the + /// floating window's lock and hide don't apply. The dashboard drawer offers the floating + /// window as a separate choice; the engine's Mini Remote window replaces it, so it doesn't. + /// + private void RenderOptions(HudState s, bool embedded) + { + if (_openOptions) + { + _openOptions = false; + ImGui.OpenPopup(OptionsPopup); + } + if (!ImGui.BeginPopup(OptionsPopup)) return; + ImGui.TextDisabled("Mini Remote sections"); + Flag("Session stats", ref s.MiniShowStats); + Flag("Attack target", ref s.MiniShowTarget); + Flag("Pet / summon", ref s.MiniShowPet); + Flag("Item slots", ref s.MiniShowGems); + // The drawer's dashboard has these switches already; the setting is for the windows. + if (!InDrawer) Flag("Toggles", ref s.MiniShowToggles); + Flag("Bank", ref s.MiniShowBank); + Flag("Rebuff", ref s.MiniShowRebuff); + Flag("Translate", ref s.MiniShowTranslate); + Flag("Guardian answer", ref s.MiniShowGuardian); + ImGui.Separator(); + Flag("Horizontal layout", ref s.MiniRemoteHorizontal); + RenderSlotSizeSlider(s); + if (embedded && _inWindow) + { + if (ImGui.MenuItem("Inventory HUDs setup...")) s.ShowSetup = true; + } + else if (embedded) + { + Flag("Floating window too", ref s.ShowMiniRemote); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Also show the Mini Remote as its own window (/ra remote)."); + if (ImGui.MenuItem("Inventory HUDs setup...")) s.ShowSetup = true; + } + else + { + Flag("Lock position", ref s.MiniRemoteLocked); + if (ImGui.MenuItem("Inventory HUDs setup...")) s.ShowSetup = true; + if (ImGui.MenuItem("Hide Mini Remote")) s.ShowMiniRemote = false; + } + ImGui.EndPopup(); + } + + /// "Slot size" slider plus a reset, the menu twin of Ctrl+wheel over the slots. + private static void RenderSlotSizeSlider(HudState s) + { + float size = SlotSize(s); + ImGui.SetNextItemWidth(120f); + if (ImGui.SliderFloat("Slot size##mrslotsize", ref size, HudState.MinMiniRemoteSlotSize, HudState.MaxMiniRemoteSlotSize, "%.0f px")) + s.MiniRemoteSlotSize = MathF.Round(size); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Item slot box size (or Ctrl+wheel over the slots)."); + ImGui.SameLine(); + bool isDefault = s.MiniRemoteSlotSize == HudState.DefaultMiniRemoteSlotSize; + if (isDefault) ImGui.BeginDisabled(); + if (ImGui.SmallButton("Default##mrslotsize")) s.MiniRemoteSlotSize = HudState.DefaultMiniRemoteSlotSize; + if (isDefault) ImGui.EndDisabled(); + } + + // ── Right-click menu: Character, then this server's plugin windows ───────── + + /// RynthCore's server id for Infinite Leaftide (UI/ServerMenus.cs), the one RynthAi has features for. + private const string IltServerId = "ilt"; + + /// + /// The right-click menu. Top, "Character": windows every server has. Bottom: the server + /// section, i.e. the installed server plugins' windows for the world you're on (RynthCore + /// sends them, see ), or the "Treat this world as ..." choices + /// when none matches. + /// + private void RenderMenu(HudState s) + { + if (!ImGui.BeginPopup(MenuPopup)) return; + try + { + RenderCharacterMenu(s); + RenderServerMenu(_hud.Hub()); + } + finally { ImGui.EndPopup(); } + } + + /// + /// "Character": RynthAi's own windows, the universal Mini Remote tabs (Quests, Pets), and + /// RynthCore's panels when it runs /rc commands. + /// + private void RenderCharacterMenu(HudState s) + { + ImGui.TextDisabled("Character"); + var settings = _hud.Dashboard.Settings; + if (ImGui.MenuItem("Spells##mrspells", "/ra spells", settings.ShowSpellsWindow)) + settings.ShowSpellsWindow = !settings.ShowSpellsWindow; + if (ImGui.IsItemHovered()) ImGui.SetTooltip("The spell catalog and buff profiles."); + foreach (IltSection section in IltSections.Tabs) + { + if (!IltSections.IsUniversal(section)) continue; + string id = IltSections.TabId(section); + if (ImGui.MenuItem(IltSections.Label(section) + "##mrchar_" + id, "/ra hub open " + id)) + _hud.HandleTabCommand(id, "show"); + } + if (_hud.Host.HasInvokeChatParser) + { + if (ImGui.MenuItem("Skills##mrskills", "/rc skills")) _hud.RunEngineCommand("/rc skills toggle"); + if (ImGui.MenuItem("Inventory##mrinv", "/rc inventory")) _hud.RunEngineCommand("/rc inventory"); + if (ImGui.MenuItem("Item Count##mritemcount", "/rc itemcount")) _hud.RunEngineCommand("/rc itemcount"); + } + if (ImGui.MenuItem("Inventory HUDs setup...##mrsetup")) s.ShowSetup = true; + } + + /// + /// The server section. Each section RynthCore marks active is listed, and so is Infinite + /// Leaftide while this character's "Treat this world as ILT" is on (RynthAi's own override). + /// Without RynthCore's list it falls back to RynthAi's ILT entries. + /// + private void RenderServerMenu(IltHubController? hub) + { + ServerMenuGroup[]? groups = ServerMenuModel.Groups; + if (groups == null) + { + RenderLocalIltMenu(hub); + return; + } + if (groups.Length == 0) return; // no server plugin installed + + bool any = false; + foreach (ServerMenuGroup g in groups) + { + bool ilt = g.Id.Equals(IltServerId, StringComparison.OrdinalIgnoreCase); + bool forcedHere = ilt && hub?.ForceIltWorld == true; + if (!g.Active && !forcedHere) continue; + any = true; + ImGui.Separator(); + ImGui.TextDisabled("Server: " + (g.Active ? g.Name : g.Name + " (forced)")); + foreach (ServerMenuEntry item in g.Items) + { + string? tab = ServerMenuModel.TabOf(item.Feature); + // Universal tabs are under Character; RynthCore 2026.10.5.30 and older list them here too. + if (tab != null && IltSections.TryParse(tab, out IltSection listed) && IltSections.IsUniversal(listed)) continue; + bool enabled = tab == null || TabAvailable(hub, tab); + if (ImGui.MenuItem(item.Label + "##mrsrv_" + g.Id, item.Command, false, enabled)) + RunServerItem(item, tab); + if (item.Tooltip.Length > 0 && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) + ImGui.SetTooltip(enabled ? item.Tooltip : item.Tooltip + "\nShows once the server reports this feature on."); + } + if (ilt) RenderIltStatus(hub); + } + if (any) return; + + ImGui.Separator(); + ImGui.TextDisabled("Server: no installed server plugin matches this world"); + foreach (ServerMenuGroup g in groups) + { + if (g.ForceCommand.Length == 0) continue; + if (ImGui.MenuItem("Treat this world as " + g.Name + "##mrforce_" + g.Id, g.ForceCommand)) + ForceServer(g, hub); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Shows this server's windows here anyway. It only says which world this is:\nthe server still decides which features exist."); + } + } + + /// A Mini Remote tab switches here and now; anything else is a RynthCore command. + private void RunServerItem(ServerMenuEntry item, string? tab) + { + if (tab != null) _hud.HandleTabCommand(tab, "show"); + else if (item.Command.Length > 0) _hud.RunEngineCommand(item.Command); + } + + /// + /// Forces a server: RynthCore's session override, plus for Infinite Leaftide this character's + /// "Treat this world as ILT" (so RynthAi's tabs come too). + /// + private void ForceServer(ServerMenuGroup g, IltHubController? hub) + { + if (g.Id.Equals(IltServerId, StringComparison.OrdinalIgnoreCase) && hub != null) hub.ForceIltWorld = true; + _hud.RunEngineCommand(g.ForceCommand); + } + + private static bool TabAvailable(IltHubController? hub, string tab) => + hub != null && IltSections.TryParse(tab, out IltSection section) && IltSections.IsTab(section) && hub.SectionAvailable(section); + + /// + /// RynthAi's own Infinite Leaftide entries, for when RynthCore sends no server list (older + /// RynthCore, or its ImGui layer off): the tabs, and the Guardian / Bounties panels. + /// + private void RenderLocalIltMenu(IltHubController? hub) + { + if (hub == null || !hub.OffersTabs) return; + ImGui.Separator(); + ImGui.TextDisabled("Server: Infinite Leaftide"); + foreach (IltSection section in IltSections.Tabs) + { + if (IltSections.IsUniversal(section)) continue; // under Character + if (ImGui.MenuItem(IltSections.Label(section) + "##mrlocal", string.Empty, false, hub.SectionAvailable(section))) + _hud.HandleTabCommand(IltSections.TabId(section), "show"); + } + if (ImGui.MenuItem("Guardian##mrlocal", "/rc guardian", false, hub.SectionAvailable(IltSection.Guardian))) + _hud.Post(() => hub.OpenEnginePanel("guardian", "Guardian", "show")); + if (ImGui.MenuItem("Bounties##mrlocal", "/rc bounties")) + _hud.Post(() => hub.OpenEnginePanel("bounties", "Bounties", "show")); + RenderIltStatus(hub); + } + + /// + /// Under the Infinite Leaftide section while no ILT feature is on: why, this character's + /// "Treat this world as ILT" override and a server-features refresh. + /// + private static void RenderIltStatus(IltHubController? hub) + { + if (hub == null || hub.Available) return; + var o = hub.Options; + ImGui.TextDisabled(!o.IsIltLikeWorld ? "Not an ILT world." + : o.IsRefreshing || o.LastRefreshUtc == DateTime.MinValue ? "Checking server features..." + : "No ILT features reported."); + bool force = hub.ForceIltWorld; + if (ImGui.Checkbox("Treat this world as ILT##mrforce", ref force)) hub.ForceIltWorld = force; + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("World-identity override only: RynthAi asks the server which features exist.\nIt never turns a feature on by itself."); + if (ImGui.MenuItem("Refresh server features##mrrefresh")) hub.RequestOptionsRefresh(); + } + + private static void Flag(string label, ref bool value) + { + bool v = value; + if (ImGui.Checkbox(label, ref v)) value = v; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/ServerMenuModel.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/ServerMenuModel.cs new file mode 100644 index 0000000..875fff0 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/ServerMenuModel.cs @@ -0,0 +1,84 @@ +// ServerMenuModel.cs - The server sections RynthCore pushes for the Mini Remote's right-click menu. +// +// RynthCore defines each server it knows (Infinite Leaftide today), whether the client is on it +// (or forced onto it), and the windows its installed plugins add for it (UI/ServerMenus.cs in +// RynthCore). It sends that list as the "servermenu" remote command when it changes, and again +// every 30 s. The payload is one tab-separated line per section ("S", id, name, active 0/1, force +// command), then its items ("I", label, command, tooltip, feature). +// +// Groups stays null until the first push: an older RynthCore, or the ImGui shell off. The menu +// then falls back to RynthAi's own ILT entries. +using System; +using System.Collections.Generic; +using System.Threading; + +namespace RynthCore.Plugin.RynthAi.Huds; + +/// A server section item: an engine "/rc" command, or a Mini Remote tab ("tab:<id>" feature). +internal sealed record ServerMenuEntry(string Label, string Command, string Tooltip, string Feature); + +/// One server's section: shown while (detected or forced in RynthCore). +internal sealed record ServerMenuGroup(string Id, string Name, bool Active, string ForceCommand, ServerMenuEntry[] Items); + +internal static class ServerMenuModel +{ + /// Feature prefix for items that are Mini Remote tabs (drawn by RynthAi itself). + public const string TabFeaturePrefix = "tab:"; + + private static ServerMenuGroup[]? _groups; + + /// The latest sections from RynthCore; null until it sends any. Any thread. + public static ServerMenuGroup[]? Groups => Volatile.Read(ref _groups); + + /// Pump thread: stores a "servermenu" push. A malformed line is skipped, never thrown. + public static void Apply(string payload) => Volatile.Write(ref _groups, Parse(payload)); + + /// + /// Parses a payload. Items before the first section line, short lines and unknown line kinds + /// are skipped. + /// + public static ServerMenuGroup[] Parse(string? payload) + { + var groups = new List(); + if (string.IsNullOrEmpty(payload)) return groups.ToArray(); + + string id = "", name = "", force = ""; + bool active = false, open = false; + var items = new List(); + + void Close() + { + if (open) groups.Add(new ServerMenuGroup(id, name, active, force, items.ToArray())); + items.Clear(); + open = false; + } + + foreach (string raw in payload.Split('\n')) + { + string line = raw.TrimEnd('\r'); + if (line.Length == 0) continue; + string[] f = line.Split('\t'); + if (f[0] == "S" && f.Length >= 5) + { + Close(); + id = f[1]; + name = f[2]; + active = f[3] == "1"; + force = f[4]; + open = id.Length > 0 && name.Length > 0; + } + else if (f[0] == "I" && f.Length >= 5 && open && f[1].Length > 0) + { + items.Add(new ServerMenuEntry(f[1], f[2], f[3], f[4])); + } + } + Close(); + return groups.ToArray(); + } + + /// The tab id of a "tab:<id>" feature, else null. + public static string? TabOf(string feature) => + feature.StartsWith(TabFeaturePrefix, StringComparison.OrdinalIgnoreCase) && feature.Length > TabFeaturePrefix.Length + ? feature.Substring(TabFeaturePrefix.Length) + : null; +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAttributeRaiser.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAttributeRaiser.cs new file mode 100644 index 0000000..a5d3488 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAttributeRaiser.cs @@ -0,0 +1,637 @@ +// IltAttributeRaiser.cs — Infinite attributes: spend unassigned XP with the server's /attr. +// +// ACECustom (Infinite Leaftide) lets attributes and vitals go past the retail cap, so the +// client's XP tables stop applying. The server is the only source of truth: +// "/xp all" → "[XP] Your XP cost for next 1 Strength level is: 1,234" per stat +// "/attr " → "[ATTR] Strength attribute raised by 1, costing 1,234!" +// (Same commands UB's Leaftide XP Calculator drives; it raises one level at a time and +// re-reads the costs after each confirmation, which is what this does too.) +// +// Raise now / auto-raise run one loop: read costs → pick a stat → /attr 1 → wait for +// the [ATTR] reply → read costs again → ... until nothing ticked is affordable, a reply is +// not a success, or MaxRaisesPerRun. Only the ticked stats are ever spent on, never below +// the reserve (AttrKeepXp). Which stat comes next depends on the raise mode: +// Priority the first ticked stat in the order that is affordable (fills the top stat) +// RoundRobin one level per ticked stat in order, then around again +// Cheapest the ticked stat with the lowest next-level cost +// Manual +1 / +10 buttons send "/attr N" straight to the server (its reply shows in chat) +// once the known (+1) or projected (+10, 7.7% per level as in UB) cost fits the unassigned XP. +// +// Gated on ServerFeatureGate (via IltServerOptions.IsIltLikeWorld) and on the server not +// reporting /xp off. Everything here runs on the plugin pump thread. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltAttributeRaiser +{ + /// Raise modes (IltCharacterState.AttrRaiseMode). + public enum Mode { Priority = 0, RoundRobin = 1, Cheapest = 2 } + + /// /attr abbreviation, display name, vital? + public sealed record Stat(string Abbr, string Name, bool Vital); + + public static readonly Stat[] Stats = + { + new("str", "Strength", false), new("end", "Endurance", false), new("coo", "Coordination", false), + new("qui", "Quickness", false), new("foc", "Focus", false), new("sel", "Self", false), + new("hea", "Health", true), new("sta", "Stamina", true), new("man", "Mana", true), + }; + + /// UB's default priority (Coordination, Quickness, Strength, Endurance, Focus, Self, vitals). + public static readonly string[] DefaultOrder = { "coo", "qui", "str", "end", "foc", "sel", "hea", "sta", "man" }; + + public const int MaxRaisesPerRun = 200; + + /// + /// Per-level growth for projecting several levels from the one cost "/xp all" reports (UB's + /// Leaftide XP tab uses the same 7.7%). The server prices each level itself; this only labels + /// the +10 button and gates it on the XP you have. + /// + public const double ProjectedLevelGrowth = 0.077; + + private const long FirstAutoDelayMs = 30_000; // after login / arming, before the first auto run + private const int ReplyTimeoutMs = 8000; + /// A run with no reply/step for this long is ended (a lost callback must not wedge it). + private const long StallMs = 45_000; + + /// "Your base Strength is now 250!" / "Your base Maximum Health is now 900!" (older servers / UB wording). + private static readonly Regex BaseNow = new(@"Your base (?:Maximum )?(\w+) is now (\d+)!", RegexOptions.Compiled | RegexOptions.CultureInvariant); + + private readonly IltHubContext _ctx; + // Last known costs (display, and the passive chat reader). A run decides only from _runCosts: + // the costs in the "/xp all" reply read right before that step, never an older value. + private readonly Dictionary _cost = new(StringComparer.OrdinalIgnoreCase); + private Dictionary _runCosts = new(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _base = new(StringComparer.OrdinalIgnoreCase); + private long _costsAtMs; + private DateTime _costsAtLocal; + // Opening the Progression tab reads the costs once per login, like UB's XP tab does on load. + private bool _autoCostsTried; + + // Run state. _runId guards against a capture that completes after Stop / a newer run. + private enum Phase { Idle, ReadingCosts, Raising } + private Phase _phase; + private int _runId; + private bool _runAuto; + private int _runRaised; + private long _runSpent; + private readonly Dictionary _runGains = new(StringComparer.OrdinalIgnoreCase); + private int _rrNext; + private string _raisingAbbr = string.Empty; + private long _raisingCost; + + private long _lastProgressMs; + private long _nextAutoAtMs; + private volatile string _status = "Idle."; + private volatile string _lastRun = string.Empty; + + public IltAttributeRaiser(IltHubContext ctx) => _ctx = ctx; + + /// + /// True while another XP spender runs (IltProgression's spend-before-/enl loop sends /attr + /// outside the capture queue). Nothing here starts, by hand or on the timer, while it is. + /// + public Func? HoldOff { get; set; } + + private bool HeldOff + { + get { try { return HoldOff?.Invoke() == true; } catch { return false; } } + } + + private IltCharacterState C => _ctx.State.Character; + + public bool Running => _phase != Phase.Idle; + + // ── Order / selection helpers (also used by IltHubStore.Normalize) ───────── + + public static Stat? Find(string keyOrName) + { + if (string.IsNullOrWhiteSpace(keyOrName)) return null; + string k = keyOrName.Trim(); + foreach (var s in Stats) + if (s.Abbr.Equals(k, StringComparison.OrdinalIgnoreCase) || s.Name.Equals(k, StringComparison.OrdinalIgnoreCase)) + return s; + // Cost lines may say "MaxHealth" / "Maximum Health"; the reply may abbreviate. + string lower = k.ToLowerInvariant().Replace(" ", ""); + if (lower.StartsWith("maximum")) lower = lower.Substring(7); + else if (lower.StartsWith("max")) lower = lower.Substring(3); + foreach (var s in Stats) + if (s.Name.Equals(lower, StringComparison.OrdinalIgnoreCase) || lower.StartsWith(s.Abbr, StringComparison.Ordinal)) + return s; + return null; + } + + /// All nine abbreviations exactly once: saved order first, missing ones appended, junk dropped. + public static List RepairOrder(List? order) + { + var result = new List(); + foreach (string k in order ?? new List()) + { + Stat? s = Find(k); + if (s != null && !result.Contains(s.Abbr)) result.Add(s.Abbr); + } + foreach (string k in DefaultOrder) + if (!result.Contains(k)) result.Add(k); + return result; + } + + public static List RepairSelection(List? selection) + { + var result = new List(); + foreach (string k in selection ?? new List()) + { + Stat? s = Find(k); + if (s != null && !result.Contains(s.Abbr)) result.Add(s.Abbr); + } + return result; + } + + /// + /// Picks the next stat to raise. Pure (unit-testable): is the + /// priority order, the stats allowed, the + /// known next-level costs, what may be spent. Round robin starts at + /// and returns the index after the pick there. + /// + public static string? Pick(Mode mode, IReadOnlyList order, ICollection ticked, + IReadOnlyDictionary cost, long budget, ref int rrNext) + { + if (budget <= 0 || order.Count == 0) return null; + bool Affordable(string k) => ticked.Contains(k) && cost.TryGetValue(k, out long c) && c > 0 && c <= budget; + + switch (mode) + { + case Mode.RoundRobin: + for (int step = 0; step < order.Count; step++) + { + int i = ((rrNext % order.Count) + step) % order.Count; + if (!Affordable(order[i])) continue; + rrNext = i + 1; + return order[i]; + } + return null; + case Mode.Cheapest: + string? best = null; + long bestCost = long.MaxValue; + foreach (string k in order) // ties go to the higher-priority stat + { + if (!Affordable(k)) continue; + long c = cost[k]; + if (c < bestCost) { best = k; bestCost = c; } + } + return best; + default: + foreach (string k in order) + if (Affordable(k)) return k; + return null; + } + } + + // ── Gate ────────────────────────────────────────────────────────────────── + + /// Why the raiser can't run here, or null when it can. + public string? Blocker() + { + if (!_ctx.Options.IsIltLikeWorld) + return "Server features are off for this world (Settings > Misc > Server Features)."; + if (_ctx.Options.IsOff(IltFeature.Xp)) return "This server reports /xp as unavailable."; + if (!_ctx.Host.HasInvokeChatParser) return "This engine build can't send chat commands."; + return null; + } + + // ── Pump-thread lifecycle ───────────────────────────────────────────────── + + /// Tick. : another XP spender (auto-enlighten's loop) is running. + public void Tick(long nowMs, bool holdOff) + { + if (Running && nowMs - _lastProgressMs > StallMs) { Finish($"Stopped: no reply for {StallMs / 1000} s."); return; } + if (!C.AttrAutoRaise || Running || holdOff || HeldOff) return; + if (_nextAutoAtMs == 0) { _nextAutoAtMs = nowMs + FirstAutoDelayMs; return; } + if (nowMs < _nextAutoAtMs) return; + _nextAutoAtMs = nowMs + Math.Clamp(C.AttrAutoRaiseMinutes, 1, 1440) * 60_000L; + if (Blocker() != null || C.AttrRaiseStats.Count == 0) return; + if (_ctx.Inventory.PlayerQuad(IltInventory.QuadAvailableXp) <= Math.Max(0, C.AttrKeepXp)) return; + Start(auto: true); + } + + /// Passive: keeps costs / base values current when the player runs the commands by hand. + public void OnChat(string text) + { + var cost = IltParse.XpCost.Match(text); + if (cost.Success) + { + Stat? s = Find(cost.Groups[1].Value); + if (s != null) { _cost[s.Abbr] = IltParse.ParseLeadingLong(cost.Groups[2].Value); MarkCostsRead(); } + return; + } + var now = BaseNow.Match(text); + if (now.Success) + { + Stat? s = Find(now.Groups[1].Value); + if (s != null && int.TryParse(now.Groups[2].Value, out int v)) _base[s.Abbr] = v; + } + } + + public void OnLogout() + { + _runId++; + _phase = Phase.Idle; + _cost.Clear(); + _runCosts.Clear(); + _base.Clear(); + _costsAtMs = 0; + _autoCostsTried = false; + _nextAutoAtMs = 0; + _status = "Idle."; + } + + // ── Runs ────────────────────────────────────────────────────────────────── + + /// Starts a spend run (manual "Raise now" or the auto timer). + public void Start(bool auto) + { + if (Running) return; + string? blocked = Blocker(); + if (blocked != null) { _status = blocked; return; } + if (HeldOff) { _status = "Auto-enlighten is spending XP right now; try again when it finishes."; return; } + if (C.AttrRaiseStats.Count == 0) { _status = "Tick at least one attribute or vital to raise."; return; } + + _runId++; + _runAuto = auto; + _runRaised = 0; + _runSpent = 0; + _runGains.Clear(); + _rrNext = 0; + _runCosts = new Dictionary(StringComparer.OrdinalIgnoreCase); + _lastProgressMs = IltHubContext.NowMs; + RynthLog.Trace(LogCat.IltProgression, $"attr raise run {_runId} start (auto={auto}, mode={(Mode)C.AttrRaiseMode}, keep={C.AttrKeepXp}, stats={string.Join(",", C.AttrRaiseStats)})"); + ReadCosts(_runId, thenStep: true); + } + + public void Stop(string why = "Stopped.") + { + if (!Running) return; + Finish(why); + } + + /// Re-reads the costs only (the panel's Refresh button). + public void RefreshCosts() + { + if (Running || Blocker() != null) return; + ReadCosts(_runId, thenStep: false); + } + + /// Reads the costs once per login when the Progression tab is first shown. Pump thread. + public void EnsureCosts() + { + if (_autoCostsTried || _costsAtMs != 0 || Running || Blocker() != null) return; + _autoCostsTried = true; + ReadCosts(_runId, thenStep: false); + } + + /// + /// XP for raises when the next one costs , + /// each level dearer than the last. Saturates at long.MaxValue. + /// + public static long ProjectCost(long nextCost, int levels) + { + if (nextCost <= 0 || levels <= 0) return 0; + double total = 0, step = nextCost; + for (int i = 0; i < levels; i++) + { + total += step; + step *= 1 + ProjectedLevelGrowth; + } + return total >= long.MaxValue ? long.MaxValue : (long)total; + } + + private void MarkCostsRead() + { + _costsAtMs = IltHubContext.NowMs; + _costsAtLocal = DateTime.Now; + } + + /// + /// "+N" button: sends "/attr abbr N"; the server's reply shows in chat. Refused up front when + /// the known (or, for N > 1, projected) cost is more than the unassigned XP, like UB's XP tab. + /// + public void RaiseManual(string key, int levels) + { + Stat? s = Find(key); + if (s == null || levels <= 0) return; + if (Running) { _status = "Wait for the current raise run to finish (or Stop it)."; return; } + string? blocked = Blocker(); + if (blocked != null) { _status = blocked; return; } + if (HeldOff) { _status = "Auto-enlighten is spending XP right now; try again when it finishes."; return; } + levels = Math.Min(levels, 1000); + if (_cost.TryGetValue(s.Abbr, out long next) && next > 0) + { + long need = ProjectCost(next, levels); + long have = _ctx.Inventory.PlayerQuad(IltInventory.QuadAvailableXp); + if (need > have) + { + _status = $"Not enough unassigned XP for {s.Name} +{levels}: need {(levels > 1 ? "~" : "")}{IltParse.Compact(need)}, have {IltParse.Compact(have)}."; + return; + } + } + RynthLog.Trace(LogCat.IltProgression, $"attr manual raise {s.Abbr} +{levels}"); + int run = _runId; + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = $"/attr {s.Abbr} {levels}", + IsResponseLine = IsAttrReply, + IsTerminator = IsAttrReply, + IdleEndMs = 600, + FirstLineTimeoutMs = ReplyTimeoutMs, + Eat = false, + OnComplete = r => + { + string reply = r.TerminatorLine ?? r.Lines.FirstOrDefault() ?? (r.TimedOut ? "no reply" : ""); + _status = $"{s.Name} +{levels}: {reply}"; + if (run == _runId && !Running) ReadCosts(_runId, thenStep: false); + }, + }); + _status = $"Sent /attr {s.Abbr} {levels}..."; + } + + private static bool IsAttrReply(string t) + => t.StartsWith("[ATTR]", StringComparison.OrdinalIgnoreCase) || t.StartsWith("Your base", StringComparison.OrdinalIgnoreCase); + + private void ReadCosts(int run, bool thenStep) + { + // A plain refresh doesn't stack on one already queued; a run always gets its own reply. + if (!thenStep && _ctx.Capture.IsPending("/xp all")) return; + if (thenStep) + { + _phase = Phase.ReadingCosts; + if (_runRaised == 0) _status = "Reading XP costs (/xp all)..."; + } + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = "/xp all", + IsResponseLine = t => t.StartsWith("[XP]", StringComparison.OrdinalIgnoreCase), + IdleEndMs = 900, + FirstLineTimeoutMs = ReplyTimeoutMs, + Eat = true, + OnComplete = r => Guard(run, () => + { + if (r.UnknownCommand) { _ctx.Options.Set(IltFeature.Xp, IltTri.Off); if (run == _runId && thenStep) Finish("This server has no /xp command."); return; } + var fresh = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (string line in r.Lines) + { + var m = IltParse.XpCost.Match(line); + if (!m.Success) continue; + Stat? s = Find(m.Groups[1].Value); + if (s == null) continue; + fresh[s.Abbr] = IltParse.ParseLeadingLong(m.Groups[2].Value); + } + foreach (var kv in fresh) _cost[kv.Key] = kv.Value; + if (fresh.Count > 0) MarkCostsRead(); + RynthLog.Trace(LogCat.IltProgression, $"attr costs: {fresh.Count} line(s) (timedOut={r.TimedOut})"); + if (!thenStep || run != _runId || !Running) return; + if (fresh.Count == 0) { Finish(r.TimedOut ? "No reply to /xp all." : "No cost lines in the /xp all reply."); return; } + _runCosts = fresh; // a stat missing from this reply is not raised this step + _lastProgressMs = IltHubContext.NowMs; + Step(run); + }), + }); + } + + private void Step(int run) + { + if (run != _runId || !Running) return; + // The world can leave Server Features (or /xp go off) mid-run, and auto-enlighten can start. + if (Blocker() is string blocked) { Finish("Stopped: " + blocked); return; } + if (HeldOff) { Finish("Stopped: auto-enlighten started spending XP."); return; } + if (_runRaised >= MaxRaisesPerRun) { Finish($"Stopped after {MaxRaisesPerRun} raises (runs again later)."); return; } + + long have = _ctx.Inventory.PlayerQuad(IltInventory.QuadAvailableXp); + long budget = have - Math.Max(0, C.AttrKeepXp); + var ticked = new HashSet(C.AttrRaiseStats, StringComparer.OrdinalIgnoreCase); + string? pick = Pick((Mode)Math.Clamp(C.AttrRaiseMode, 0, 2), C.AttrOrder, ticked, _runCosts, budget, ref _rrNext); + if (pick == null) + { + Finish(_runRaised == 0 + ? (budget <= 0 ? "Nothing to spend (unassigned XP is at or below the reserve)." + : "Nothing affordable among the ticked stats.") + : string.Empty); + return; + } + + Stat s = Find(pick)!; + _phase = Phase.Raising; + _raisingAbbr = s.Abbr; + _raisingCost = _runCosts.TryGetValue(s.Abbr, out long c) ? c : 0; + _status = $"Raising {s.Name} +1 (cost {IltParse.Compact(_raisingCost)})..."; + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = $"/attr {s.Abbr} 1", + IsResponseLine = IsAttrReply, + IsTerminator = IsAttrReply, + IdleEndMs = 600, + FirstLineTimeoutMs = ReplyTimeoutMs, + Eat = true, + OnComplete = r => Guard(run, () => OnRaiseReply(run, s, r)), + }); + } + + private void OnRaiseReply(int run, Stat s, IltChatResult r) + { + if (run != _runId || !Running) return; + string reply = r.TerminatorLine ?? r.Lines.FirstOrDefault() ?? string.Empty; + var ok = IltParse.AttrRaised.Match(reply); + var baseNow = BaseNow.Match(reply); + // The reply must be about the stat we raised (another /attr sender could answer first). + if (ok.Success && Find(ok.Groups[1].Value) != s) ok = Match.Empty; + if (baseNow.Success && Find(baseNow.Groups[1].Value) != s) baseNow = Match.Empty; + if (!ok.Success && !baseNow.Success) + { + RynthLog.Trace(LogCat.IltProgression, $"attr raise {s.Abbr}: not a success ('{reply}', timedOut={r.TimedOut}, unknown={r.UnknownCommand})"); + Finish(r.UnknownCommand ? "This server has no /attr command." + : reply.Length > 0 ? $"Server: {reply}" : "No reply to /attr."); + return; + } + + long spent = ok.Success ? IltParse.ParseLeadingLong(ok.Groups[3].Value) : _raisingCost; + int levels = ok.Success && int.TryParse(ok.Groups[2].Value, out int n) ? n : 1; + if (baseNow.Success && int.TryParse(baseNow.Groups[2].Value, out int v)) _base[s.Abbr] = v; + else if (_base.TryGetValue(s.Abbr, out int b)) _base[s.Abbr] = b + levels; + _runGains[s.Abbr] = (_runGains.TryGetValue(s.Abbr, out int g) ? g : 0) + levels; + _runRaised += levels; + _runSpent += spent; + _cost.Remove(s.Abbr); // its next level costs more; re-read before deciding again + _runCosts.Clear(); + _lastProgressMs = IltHubContext.NowMs; + _status = $"Raised {s.Name} (+{_runRaised} this run, {IltParse.Compact(_runSpent)} XP)..."; + ReadCosts(run, thenStep: true); + } + + /// Runs a capture callback; an exception ends the run instead of leaving it Running. + private void Guard(int run, Action body) + { + try { body(); } + catch (Exception ex) + { + RynthLog.Exception(LogCat.IltProgression, ex, "attr raise callback"); + if (run == _runId && Running) Finish("Stopped: internal error (see the RynthAi log)."); + } + } + + private void Finish(string reason) + { + _phase = Phase.Idle; + _runId++; // late callbacks from this run are ignored + string summary = _runRaised > 0 + ? "Raised " + string.Join(", ", C.AttrOrder.Where(_runGains.ContainsKey).Select(k => $"{Find(k)!.Name} +{_runGains[k]}")) + + $" ({IltParse.Compact(_runSpent)} XP)." + : string.Empty; + string text = (summary + (reason.Length > 0 ? (summary.Length > 0 ? " " : "") + reason : "")).Trim(); + if (text.Length == 0) text = "Done."; + _status = text; + _lastRun = $"{DateTime.Now:t} {(_runAuto ? "auto" : "manual")}: {text}"; + RynthLog.Trace(LogCat.IltProgression, $"attr raise run finished: {text}"); + if (_runRaised > 0) _ctx.Chat($"[Mini Remote] Attribute raise ({(_runAuto ? "auto" : "manual")}): {text}"); + } + + // ── Engine Skills panel bridge ──────────────────────────────────────────── + + /// Appends "attr":{...} for the Progression tab. + public void AppendJson(StringBuilder sb) + { + string? blocked = Blocker(); + long have = _ctx.Inventory.PlayerQuad(IltInventory.QuadAvailableXp); + long budget = have - Math.Max(0, C.AttrKeepXp); + long now = IltHubContext.NowMs; + + sb.Append("\"attr\":{\"off\":").Append(blocked != null ? "true" : "false"); + Str(sb, "reason", blocked ?? string.Empty); + sb.Append(",\"auto\":").Append(C.AttrAutoRaise ? "true" : "false") + .Append(",\"every\":").Append(Math.Clamp(C.AttrAutoRaiseMinutes, 1, 1440)) + .Append(",\"mode\":").Append(Math.Clamp(C.AttrRaiseMode, 0, 2)) + .Append(",\"running\":").Append(Running ? "true" : "false"); + Str(sb, "keep", C.AttrKeepXp > 0 ? IltParse.Compact(C.AttrKeepXp) : "0"); + // The reserve box edits the exact number (the compact form above is lossy). + Str(sb, "keepFull", IltParse.N0(Math.Max(0, C.AttrKeepXp))); + Str(sb, "status", _status); + Str(sb, "lastRun", _lastRun); + Str(sb, "unassigned", $"Unassigned XP {IltParse.Compact(have)}" + + (C.AttrKeepXp > 0 ? $" (spendable {IltParse.Compact(Math.Max(0, budget))})" : "")); + string next = !C.AttrAutoRaise ? string.Empty + : Running ? "running" + : _nextAutoAtMs <= 0 ? "soon" + : IltParse.Duration(TimeSpan.FromMilliseconds(Math.Max(0, _nextAutoAtMs - now))); + Str(sb, "next", next); + Str(sb, "costsAge", _costsAtMs == 0 ? "costs not read yet" : $"costs read {Ago(now - _costsAtMs)} ago"); + Str(sb, "updated", _costsAtMs == 0 ? "-" : _costsAtLocal.ToString("HH:mm:ss")); + int level = _ctx.Inventory.PlayerInt(IltInventory.IntLevel); + long totalXp = _ctx.Inventory.PlayerQuad(IltInventory.QuadTotalXp); + Str(sb, "xpHeader", $"Level {(level > 0 ? level.ToString() : "?")} Total XP {(totalXp > 0 ? IltParse.Compact(totalXp) : "?")} Unassigned {IltParse.Compact(have)}"); + + var ticked = new HashSet(C.AttrRaiseStats, StringComparer.OrdinalIgnoreCase); + sb.Append(",\"rows\":["); + bool first = true; + foreach (string k in C.AttrOrder) + { + Stat? s = Find(k); + if (s == null) continue; + if (!first) sb.Append(','); + first = false; + bool known = _cost.TryGetValue(s.Abbr, out long c) && c > 0; + sb.Append('{'); + Str(sb, "key", s.Abbr, first: true); + Str(sb, "label", s.Name); + sb.Append(",\"vital\":").Append(s.Vital ? "true" : "false") + .Append(",\"on\":").Append(ticked.Contains(s.Abbr) ? "true" : "false") + .Append(",\"base\":").Append(_base.TryGetValue(s.Abbr, out int b) ? b : -1) + .Append(",\"afford\":").Append(known && c <= budget ? "true" : "false"); + Str(sb, "cost", known ? IltParse.Compact(c) : "?"); + // By hand (+1 / +10) only the unassigned XP limits, not the raiser's reserve. + long ten = known ? ProjectCost(c, 10) : 0; + sb.Append(",\"known\":").Append(known ? "true" : "false") + .Append(",\"afford1\":").Append(known && c <= have ? "true" : "false") + .Append(",\"afford10\":").Append(known && ten <= have ? "true" : "false"); + Str(sb, "cost10", known ? "~" + IltParse.Compact(ten) : "?"); + Str(sb, "costFull", known ? IltParse.N0(c) : ""); + Str(sb, "cost10Full", known ? IltParse.N0(ten) : ""); + sb.Append('}'); + } + sb.Append("]}"); + } + + private static string Ago(long ms) + { + long sec = Math.Max(0, ms / 1000); + return sec < 60 ? $"{sec}s" : sec < 3600 ? $"{sec / 60}m" : $"{sec / 3600}h {sec % 3600 / 60}m"; + } + + private static void Str(StringBuilder sb, string name, string value, bool first = false) + { + if (!first) sb.Append(','); + sb.Append('"').Append(name).Append("\":\"").Append(RynthAiPlugin.JsonEscape(value ?? string.Empty)).Append('"'); + } + + /// "prog attr…" commands from the Skills panel. Returns false when the verb isn't ours. + public bool HandleRemote(string verb, string[] a) + { + string arg1 = a.Length > 1 ? a[1] : string.Empty; + string arg2 = a.Length > 2 ? a[2] : string.Empty; + switch (verb) + { + case "attrauto": + C.AttrAutoRaise = arg1.Equals("on", StringComparison.OrdinalIgnoreCase); + _nextAutoAtMs = C.AttrAutoRaise ? IltHubContext.NowMs + FirstAutoDelayMs : 0; + if (!C.AttrAutoRaise && Running && _runAuto) Stop("Auto-raise turned off."); + return true; + case "attrevery": + if (int.TryParse(arg1, out int min)) + { + C.AttrAutoRaiseMinutes = Math.Clamp(min, 1, 1440); + if (C.AttrAutoRaise) _nextAutoAtMs = IltHubContext.NowMs + C.AttrAutoRaiseMinutes * 60_000L; + } + return true; + case "attrmode": + if (int.TryParse(arg1, out int mode)) C.AttrRaiseMode = Math.Clamp(mode, 0, 2); + return true; + case "attrkeep": + if (arg1.Length == 0 || arg1 == "0") C.AttrKeepXp = 0; + else if (IltParse.TryParseAmount(arg1, out long keep)) C.AttrKeepXp = Math.Max(0, keep); + return true; + case "attron": + { + Stat? s = Find(arg1); + if (s == null) return true; + bool on = arg2.Equals("on", StringComparison.OrdinalIgnoreCase); + C.AttrRaiseStats.RemoveAll(x => x.Equals(s.Abbr, StringComparison.OrdinalIgnoreCase)); + if (on) C.AttrRaiseStats.Add(s.Abbr); + return true; + } + case "attrmove": + { + Stat? s = Find(arg1); + if (s == null) return true; + int i = C.AttrOrder.FindIndex(x => x.Equals(s.Abbr, StringComparison.OrdinalIgnoreCase)); + int j = arg2.Equals("up", StringComparison.OrdinalIgnoreCase) ? i - 1 + : arg2.Equals("top", StringComparison.OrdinalIgnoreCase) ? 0 : i + 1; + if (i < 0 || j < 0 || j >= C.AttrOrder.Count || i == j) return true; + string item = C.AttrOrder[i]; + C.AttrOrder.RemoveAt(i); + C.AttrOrder.Insert(j, item); + return true; + } + case "attrorderreset": + C.AttrOrder = new List(DefaultOrder); + return true; + case "attrraise": + if (int.TryParse(arg2, out int levels)) RaiseManual(arg1, levels); + return true; + case "attrrun": Start(auto: false); return true; + case "attrstop": Stop(); return true; + case "attrcosts": RefreshCosts(); return true; + } + return false; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAugCosts.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAugCosts.cs new file mode 100644 index 0000000..ca5d654 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAugCosts.cs @@ -0,0 +1,224 @@ +// IltAugCosts.cs — luminance augmentation cost rules, per server (world name). +// +// Defaults are UB's Leaftide Augs tab (correct for InfiniteLeaftide): +// level i (1-based) costs (Base + (i-1) * Base * LinearPercent/100) * multiplier(i) +// multiplier(i) = M0 below S1, M1 from S1, M2 from S2, M3 from S3, M4 from S4 +// (UB: 1 / 4 / 8 / 16 / 24; a tier starts AT its S level). +// Another server can change the multipliers and every aug's base, growth, S1..S4, target cap +// and coins per level from the Progression tab; those edits are saved for that world only in +// one shared file, so every character on the world prices augs the same way. +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.Json; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +/// The saved file: one cost profile per world that was changed from the defaults. +public sealed class IltAugCostFile +{ + public Dictionary Servers = new(StringComparer.OrdinalIgnoreCase); +} + +/// A world's cost rules: the five tier multipliers and one row per aug. +public sealed class IltAugCostProfile +{ + public double[] Multipliers = (double[])IltAugCosts.DefaultMultipliers.Clone(); + public List Augs = new(); +} + +/// One aug's cost rule. Thresholds are 1-based levels; Cap 0 = no target limit. +public sealed class IltAugCostRow +{ + public string Key = string.Empty; + public long Base; + public double LinearPercent; + public int CoinsPerLevel; + public int S1, S2, S3, S4; + public int Cap; + + public IltAugCostRow Clone() => (IltAugCostRow)MemberwiseClone(); +} + +internal sealed class IltAugCosts +{ + /// UB's tier multipliers: below S1, from S1, from S2, from S3, from S4. + public static readonly double[] DefaultMultipliers = { 1, 4, 8, 16, 24 }; + + /// Highest target the planner accepts when an aug has no cap (keeps the plan sane). + public const int NoCapLimit = 100_000; + + /// Display order and labels; also the only keys a profile may hold. + public static readonly (string Key, string Label)[] Labels = + { + ("creature", "Creature"), ("item", "Item"), ("life", "Life"), ("war", "War"), ("void", "Void"), + ("duration", "Duration"), ("melee", "Melee"), ("missile", "Missile"), + ("specialization", "Specialization"), ("summon", "Summon"), + }; + + /// UB Augs.cs (ILT): cost models, coins per level and soft caps S1..S4; no target cap. + public static IltAugCostRow[] DefaultRows() => new[] + { + Row("creature", 750_000, 130, 3, 2750, 4000, 4750, 5250), + Row("item", 1_000_000, 165, 18, 1250, 2000, 3000, 3500), + Row("life", 975_000, 195, 12, 1000, 2000, 3000, 3750), + Row("war", 750_000, 140, 5, 1750, 2500, 3000, 3750), + Row("void", 800_000, 160, 5, 1750, 2500, 3000, 3750), + Row("duration", 400_000, 120, 5, 1000, 2000, 2500, 3000), + Row("melee", 750_000, 140, 5, 1750, 2500, 3000, 3750), + Row("missile", 750_000, 140, 5, 1750, 2500, 3000, 3750), + Row("specialization", 3_000_000, 200, 50, 1750, 2500, 3000, 3750), + Row("summon", 500_000, 125, 36, 1750, 2500, 3000, 3750), + }; + + private static IltAugCostRow Row(string key, long b, double lp, int coins, int s1, int s2, int s3, int s4) + => new() { Key = key, Base = b, LinearPercent = lp, CoinsPerLevel = coins, S1 = s1, S2 = s2, S3 = s3, S4 = s4, Cap = 0 }; + + /// The shared settings file. Tests point it at a scratch folder before first use. + public static string FilePath { get; set; } = Path.Combine(IltHubStore.SharedRoot, "ilt-aug-costs.json"); + + private IltAugCostFile? _file; + private string _lastJson = string.Empty; + private static readonly IltAugCostProfile Defaults = NewDefaultProfile(); + + public static string Label(string key) + { + foreach (var l in Labels) if (l.Key.Equals(key, StringComparison.OrdinalIgnoreCase)) return l.Label; + return key; + } + + private static IltAugCostProfile NewDefaultProfile() + => new() { Multipliers = (double[])DefaultMultipliers.Clone(), Augs = DefaultRows().ToList() }; + + private IltAugCostFile File_ + { + get + { + if (_file != null) return _file; + _file = new IltAugCostFile(); + try + { + if (File.Exists(FilePath)) + { + string json = File.ReadAllText(FilePath); + _file = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.IltAugCostFile) ?? new IltAugCostFile(); + _lastJson = json; + } + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"load {FilePath}"); _file = new IltAugCostFile(); } + var fixedUp = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (var kv in _file.Servers ?? new()) + if (kv.Value != null) fixedUp[kv.Key ?? string.Empty] = Normalize(kv.Value); + _file.Servers = fixedUp; + return _file; + } + } + + /// + /// Repairs a loaded or edited profile: five multipliers, exactly one row per known aug (missing + /// ones from the defaults, unknown ones dropped), non-negative values and S1 <= S2 <= S3 <= S4. + /// + public static IltAugCostProfile Normalize(IltAugCostProfile p) + { + var m = new double[5]; + for (int i = 0; i < 5; i++) + { + double v = p.Multipliers != null && i < p.Multipliers.Length ? p.Multipliers[i] : DefaultMultipliers[i]; + m[i] = double.IsFinite(v) ? Math.Clamp(v, 0, 1000) : DefaultMultipliers[i]; + } + p.Multipliers = m; + + var byKey = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (var r in p.Augs ?? new()) if (r != null && !string.IsNullOrEmpty(r.Key)) byKey[r.Key] = r; + var rows = new List(Labels.Length); + foreach (var def in DefaultRows()) + { + var r = byKey.TryGetValue(def.Key, out var have) ? have : def; + r.Key = def.Key; + r.Base = Math.Max(0, r.Base); + r.LinearPercent = double.IsFinite(r.LinearPercent) ? Math.Clamp(r.LinearPercent, 0, 100_000) : def.LinearPercent; + r.CoinsPerLevel = Math.Max(0, r.CoinsPerLevel); + r.S1 = Math.Max(0, r.S1); + r.S2 = Math.Max(r.S1, r.S2); + r.S3 = Math.Max(r.S2, r.S3); + r.S4 = Math.Max(r.S3, r.S4); + r.Cap = Math.Max(0, r.Cap); + rows.Add(r); + } + p.Augs = rows; + return p; + } + + /// The rules for : its saved profile, or the UB defaults. + public IltAugCostProfile For(string world) + => File_.Servers.TryGetValue(world ?? string.Empty, out var p) ? p : Defaults; + + /// True when has its own saved rules. + public bool IsCustom(string world) => File_.Servers.ContainsKey(world ?? string.Empty); + + /// Applies an edit to 's rules (copying the defaults first) and saves. + public void Edit(string world, Action change) + { + string key = world ?? string.Empty; + if (!File_.Servers.TryGetValue(key, out var p)) + { + p = NewDefaultProfile(); + File_.Servers[key] = p; + } + change(p); + Normalize(p); + Save(); + } + + /// Drops 's saved rules: it goes back to the UB defaults. + public void Reset(string world) + { + if (File_.Servers.Remove(world ?? string.Empty)) Save(); + } + + private void Save() + { + try + { + string json = JsonSerializer.Serialize(File_, RynthAiJsonContext.Default.IltAugCostFile); + if (json == _lastJson) return; + Directory.CreateDirectory(Path.GetDirectoryName(FilePath)!); + string tmp = FilePath + ".tmp"; + File.WriteAllText(tmp, json); + File.Move(tmp, FilePath, overwrite: true); + _lastJson = json; + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"save {FilePath}"); } + } + + /// Highest target the planner allows for at current level . + public static int Ceiling(IltAugCostRow r, int cur) => Math.Max(cur, r.Cap > 0 ? r.Cap : NoCapLimit); + + /// + /// Luminance for levels cur+1 .. tgt. Same result as UB's per-level loop, summed per tier in + /// closed form: within a tier the per-level base grows linearly, so each tier is an arithmetic series. + /// + public static decimal LumCost(IltAugCostRow r, double[] mult, int cur, int tgt) + { + int first = Math.Max(1, cur + 1); + if (tgt < first) return 0; + decimal b = r.Base; + decimal step = b * (decimal)r.LinearPercent / 100m; + // Tier t covers levels [lo[t], hi[t]) (1-based); the last tier has no end. + long[] lo = { 1, r.S1, r.S2, r.S3, r.S4 }; + long[] hi = { r.S1, r.S2, r.S3, r.S4, long.MaxValue }; + decimal total = 0; + for (int t = 0; t < 5; t++) + { + long a = Math.Max(first, lo[t]); + long z = Math.Min(tgt, hi[t] - 1); + if (z < a) continue; + decimal n = z - a + 1; + // sum over i=a..z of (b + (i-1)*step) = n*b + step * sum(i-1) = n*b + step * n*(a-1 + z-1)/2 + decimal levels = n * b + step * (n * ((a - 1) + (z - 1)) / 2m); + total += levels * (decimal)mult[t]; + } + return total; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBankCommands.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBankCommands.cs new file mode 100644 index 0000000..f63c53a --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBankCommands.cs @@ -0,0 +1,112 @@ +// IltBankCommands.cs — The /bank commands the Banking tab sends, and the reply lines it collects. +// +// Server contract (ACECustom PlayerCommands.HandleBank / Player_Bank, upstream 2026-10-11): +// /b d [code] deposit everything (no code) or one kind; "Deposited N ", +// "No found to deposit", "Deposited all !". +// /b lum bank luminance tokens: "Starting Banked Lum", one "Deposited N x " +// a kind, "Ending Banked Lum"; "No luminance tokens found to deposit". +// /b w withdraw: "Withdrew ...", "You don't have enough ...", "Failed to create ...". +// /b w n [n] trade notes by denomination (i v x l c d m md mm mmd). +// /b t transfer (IltBanking); Prestige Coins can't be transferred. +// Deposit, withdraw and transfer share one server throttle (bank_command_limit); a plain +// /bank balance doesn't touch it. Pure: no host calls, so the host tests cover it. +using System; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal static class IltBankCommands +{ + /// A deposit choice: label, and the command's argument after "/b d" ("" = all). + public static readonly (string Label, string Args)[] Deposits = + { + ("Everything", ""), + ("Pyreals", "p"), + ("Pyreal peas", "ps"), + ("Luminance", "l"), + ("Luminance tokens", "lum"), + ("Legendary keys", "k"), + ("Mythical keys", "mk"), + ("Enlightened coins", "e"), + ("Weakly enlightened coins", "we"), + ("Prestige coins", "pc"), + ("Trade notes", "n"), + }; + + /// A withdraw choice: label and the server code; "n" is trade notes (by denomination). + public static readonly (string Label, string Code)[] Withdrawals = + { + ("Pyreals", "p"), + ("Luminance", "l"), + ("Legendary keys", "k"), + ("Mythical keys", "mk"), + ("Enlightened coins", "e"), + ("Weakly enlightened coins", "we"), + ("Prestige coins", "pc"), + ("Trade notes", "n"), + }; + + /// Trade note denominations: label and code, in the server's order. + public static readonly (string Label, string Code, long Value)[] NoteDenominations = + { + ("I (100)", "i", 100), ("V (500)", "v", 500), ("X (1K)", "x", 1_000), ("L (5K)", "l", 5_000), + ("C (10K)", "c", 10_000), ("D (50K)", "d", 50_000), ("M (100K)", "m", 100_000), + ("MD (150K)", "md", 150_000), ("MM (200K)", "mm", 200_000), ("MMD (250K)", "mmd", 250_000), + }; + + /// The server refuses a trade-note withdrawal of more than this many notes. + public const int MaxNoteCount = 50_000; + + /// "/b d", "/b d p", or "/b lum" for the luminance tokens; empty for an unknown index. + public static string Deposit(int index) + { + if (index < 0 || index >= Deposits.Length) return string.Empty; + string args = Deposits[index].Args; + if (args.Length == 0) return "/b d"; + return args == "lum" ? "/b lum" : "/b d " + args; + } + + /// + /// "/b w p 1000000", or "/b w n mmd 5" for trade notes ( is then the + /// note count). Empty (with ) when the input can't be sent. + /// + public static string Withdraw(int index, long amount, int denomination, out string error) + { + error = string.Empty; + if (index < 0 || index >= Withdrawals.Length) { error = "Pick what to withdraw."; return string.Empty; } + if (amount <= 0) { error = "Amount must be positive."; return string.Empty; } + string code = Withdrawals[index].Code; + if (code != "n") return $"/b w {code} {amount}"; + if (denomination < 0 || denomination >= NoteDenominations.Length) { error = "Pick a note denomination."; return string.Empty; } + if (amount > MaxNoteCount) { error = $"At most {MaxNoteCount:N0} notes at a time."; return string.Empty; } + return $"/b w n {NoteDenominations[denomination].Code} {amount}"; + } + + /// + /// True for a line the server sends in reply to a deposit or withdrawal (so the tab can show + /// it as the result). Only lines the bank code writes; never "[BANK]" balance lines. + /// + public static bool IsActionReply(string line) + { + if (string.IsNullOrEmpty(line)) return false; + return line.StartsWith("Deposited ", StringComparison.Ordinal) + || line.StartsWith("Withdrew ", StringComparison.Ordinal) + || (line.StartsWith("No ", StringComparison.Ordinal) && line.EndsWith("to deposit", StringComparison.Ordinal)) + || line.StartsWith("Starting Banked Lum", StringComparison.Ordinal) + || line.StartsWith("Ending Banked Lum", StringComparison.Ordinal) + || line.StartsWith("Not deposited", StringComparison.Ordinal) + || line.StartsWith("You don't have enough", StringComparison.Ordinal) + || line.StartsWith("You cannot hold any more", StringComparison.Ordinal) + || line.StartsWith("You have not been luminance flagged", StringComparison.Ordinal) + || line.StartsWith("Failed to ", StringComparison.Ordinal) + || line.StartsWith("Warning: Requested", StringComparison.Ordinal) + || line.StartsWith("Amount must be", StringComparison.Ordinal) + || line.StartsWith("Cannot deposit while", StringComparison.Ordinal) + || line.StartsWith("[Deposit]", StringComparison.Ordinal) + || line.StartsWith("[Withdraw]", StringComparison.Ordinal) + || line.StartsWith("Invalid amount", StringComparison.Ordinal) + || line.StartsWith("Invalid denomination", StringComparison.Ordinal) + || line.StartsWith("Count must be", StringComparison.Ordinal) + || line.StartsWith("Count cannot exceed", StringComparison.Ordinal) + || line.StartsWith("You are not permitted to use bank commands", StringComparison.Ordinal); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBanking.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBanking.cs new file mode 100644 index 0000000..afa4e55 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBanking.cs @@ -0,0 +1,572 @@ +// IltBanking.cs — ILT Hub "Banking" tab: /bank balances, deposits, withdrawals, confirmed +// transfers, transaction log. +// +// Server contract (ACECustom PlayerCommands bank handler, upstream 2026-10-11): +// /bank → "[BANK] Your balances are:" then "[BANK] Pyreals: N", "Luminance:", +// "Legendary Keys:", "Mythical Keys:", "Enlightened Coins:", +// "Weakly Enlightened Coins:", "Prestige Coins: N (bound to you ...)". +// /b d, /b lum, /b w → deposits and withdrawals (IltBankCommands has the commands and replies). +// /bank t → "Transferred {N0} {Currency} to {Name}[ (offline)]" or an error; +// the recipient sees "Received {N0} {currency} from {Name}". +// Codes: p pyreals, l luminance, k legendary keys, mk mythical keys, e enl coins, we weak coins. +// Prestige Coins (pc) are bound: deposit and withdraw only. +// Deposit, withdraw and transfer share the server's bank_command_limit throttle; a balance +// refresh doesn't, so it has its own (client-side) spacing. +// Balance lines are parsed whenever they appear (player-typed /bank too) but only EATEN +// when the Hub asked. Transfers always need a confirmation (UB had none). +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltBanking : IIltFeature +{ + /// Transfer currency table: display name, /bank t code. + public static readonly (string Name, string Code)[] Currencies = + { + ("Pyreals", "p"), + ("Luminance", "l"), + ("Legendary Keys", "k"), + ("Mythical Keys", "mk"), + ("Enlightened Coins", "e"), + ("Weakly Enlightened Coins", "we"), + }; + private static readonly string[] CurrencyNames = Currencies.Select(c => c.Name).ToArray(); + private static readonly string[] DepositNames = IltBankCommands.Deposits.Select(d => d.Label).ToArray(); + private static readonly string[] WithdrawNames = IltBankCommands.Withdrawals.Select(w => w.Label).ToArray(); + private static readonly string[] NoteNames = IltBankCommands.NoteDenominations.Select(n => n.Label).ToArray(); + + /// Server throttle for deposit / withdraw / transfer (bank_command_limit). + private const long BankCommandSpacingMs = 5000; + /// Client spacing for balance refreshes (the server doesn't throttle a plain /bank). + private const long BalanceSpacingMs = 5000; + /// After a deposit or withdrawal, the balances are re-read this long after the reply. + private const long RefreshAfterActionMs = 1500; + + private readonly IltHubContext _ctx; + private readonly object _txLock = new(); + private readonly List _transactions; + private IltBankTransaction[] _txSnapshot = Array.Empty(); + private bool _txDirty; + + private long _lastBankCommandAt; + private long _lastBalanceAt; + private long _lastAutoRefreshAt; + /// When a quiet balance refresh is due after an action (0 = none). Pump thread. + private long _refreshDueAt; + /// Until then, money is moving between pack and bank (MovingMoney). Pump thread. + private long _moveUntil; + /// How long after a deposit / withdrawal reply the moved amounts are not income (covers the balance re-read). + private const long MoveWindowMs = 12_000; + + // Render-thread form state. + private string _amountText = string.Empty; + private string _withdrawText = string.Empty; + private string _txFilter = string.Empty; + private string _lastResult = string.Empty; + private volatile string _actionResult = string.Empty; + + /// Raised (pump thread) after a balance line updates the state; Character rates use the deltas. + public event Action? BalanceChanged; + + public IltBanking(IltHubContext ctx) + { + _ctx = ctx; + _transactions = ctx.Store.LoadTransactions(); + PublishSnapshot(); + } + + private IltBankState Bank => _ctx.State.Bank; + public bool Enabled => _ctx.Options.IsOn(IltFeature.Bank); + + /// + /// True while a deposit or withdrawal is moving money between the pack and the bank (sent from + /// this tab or typed): session rates then re-baseline instead of counting it as income. Pump thread. + /// + public bool MovingMoney => IltHubContext.NowMs < _moveUntil; + + /// Exposed for the one-time UB import (mutated under the lock). + public void ImportUb(Func, string> importer) + { + string summary; + lock (_txLock) + { + summary = importer(_transactions); + _txDirty = true; + } + PublishSnapshot(); + RynthLog.Write(LogCat.IltBanking, $"[IltHub] UB sidecar import: {summary}"); + } + + // ── Commands ──────────────────────────────────────────────────────────── + + /// Queues a /bank balance refresh (eaten when ). + public void RequestRefresh(bool quiet) + { + RynthLog.Trace(LogCat.IltBanking, $"RequestRefresh(quiet={quiet})"); + if (_ctx.Capture.IsPending("/bank")) return; + long now = IltHubContext.NowMs; + if (now - _lastBalanceAt < BalanceSpacingMs) return; + _lastBalanceAt = now; + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = "/bank", + IsResponseLine = t => t.StartsWith("[BANK]", StringComparison.OrdinalIgnoreCase), + IdleEndMs = 2000, + FirstLineTimeoutMs = 15000, + Eat = quiet, + OnComplete = r => + { + if (r.UnknownCommand) _ctx.Options.Set(IltFeature.Bank, IltTri.Off); + else if (r.Lines.Count > 0) _ctx.Options.Set(IltFeature.Bank, IltTri.On); + }, + }); + } + + /// + /// Validates and (after the UI confirm) sends a transfer. Pump thread. + /// Returns an error message, or empty when the command was queued. + /// + public string SendTransfer(int currencyIndex, long amount, string target) + { + RynthLog.Trace(LogCat.IltBanking, $"SendTransfer(currency={currencyIndex}, amount={amount}, target='{target}')"); + if (!Enabled) return "Bank is not available on this server."; + if (currencyIndex < 0 || currencyIndex >= Currencies.Length) return "Pick a currency."; + if (amount <= 0) return "Amount must be positive."; + target = (target ?? string.Empty).Trim(); + if (target.Length == 0) return "Enter a recipient."; + // The recipient is spliced into a chat command, so only character-name characters are + // allowed: no '/', control characters or line breaks that could start a second command. + if (!IltParse.CharacterName.IsMatch(target)) return "Recipient must be a character name (letters, spaces, ' and - only)."; + if (target.Equals(_ctx.CharName, StringComparison.OrdinalIgnoreCase)) return "You cannot transfer to yourself."; + long now = IltHubContext.NowMs; + if (now - _lastBankCommandAt < BankCommandSpacingMs) return "Bank commands are limited to one every 5 seconds."; + _lastBankCommandAt = now; + + string cmd = $"/bank t {Currencies[currencyIndex].Code} {amount} {target}"; + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = cmd, + IsResponseLine = t => t.StartsWith("Transferred ", StringComparison.Ordinal) + || t.StartsWith("Character '", StringComparison.Ordinal) + || t.StartsWith("You cannot transfer", StringComparison.Ordinal) + || t.StartsWith("You don't have enough", StringComparison.Ordinal) + || t.StartsWith("[Transfer]", StringComparison.Ordinal), + IdleEndMs = 500, + FirstLineTimeoutMs = 8000, + Eat = false, + OnComplete = r => + { + _lastResult = r.Lines.Count > 0 ? r.Lines[^1] : (r.TimedOut ? "No reply from server." : string.Empty); + // Balances changed: read them again shortly. + _refreshDueAt = IltHubContext.NowMs + RefreshAfterActionMs; + }, + }); + return string.Empty; + } + + /// + /// Sends a deposit ( index). Pump thread. Returns an + /// error message, or empty when the command was queued; the reply lands in the tab. + /// + public string SendDeposit(int index) + { + string cmd = IltBankCommands.Deposit(index); + if (cmd.Length == 0) return "Pick what to deposit."; + return SendAction(cmd, "Deposit"); + } + + /// + /// Sends a withdrawal ( index; for trade notes + /// is the note count). Pump thread; same result as SendDeposit. + /// + public string SendWithdraw(int index, long amount, int denomination) + { + string cmd = IltBankCommands.Withdraw(index, amount, denomination, out string error); + if (cmd.Length == 0) return error; + return SendAction(cmd, "Withdraw"); + } + + /// A deposit or withdrawal through the capture queue (shown, not eaten), then a quiet balance read. + private string SendAction(string cmd, string what) + { + RynthLog.Trace(LogCat.IltBanking, $"{what}: '{cmd}'"); + if (!Enabled) return "Bank is not available on this server."; + long now = IltHubContext.NowMs; + if (now - _lastBankCommandAt < BankCommandSpacingMs) return "Bank commands are limited to one every 5 seconds."; + _lastBankCommandAt = now; + _moveUntil = now + MoveWindowMs; + _actionResult = what + " sent..."; + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = cmd, + IsResponseLine = IltBankCommands.IsActionReply, + IdleEndMs = 800, + FirstLineTimeoutMs = 8000, + Eat = false, + OnComplete = r => + { + _actionResult = r.Lines.Count > 0 ? string.Join("\n", r.Lines.TakeLast(6)) + : r.TimedOut ? "No reply from the server." : string.Empty; + _refreshDueAt = IltHubContext.NowMs + RefreshAfterActionMs; + }, + }); + return string.Empty; + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + // Periodic quiet refresh only while the Hub is open and the server has /bank. + int every = Bank.AutoRefreshSeconds; + if (Enabled && _ctx.WindowOpen && every > 0 && nowMs - _lastAutoRefreshAt >= every * 1000L + && nowMs - _lastBalanceAt >= BalanceSpacingMs) + { + _lastAutoRefreshAt = nowMs; + RequestRefresh(quiet: true); + } + // The balance read a deposit, withdrawal or transfer asked for (retried until the spacing allows). + if (_refreshDueAt != 0 && nowMs >= _refreshDueAt && Enabled && nowMs - _lastBalanceAt >= BalanceSpacingMs) + { + _refreshDueAt = 0; + _lastAutoRefreshAt = nowMs; + RequestRefresh(quiet: true); + } + + if (_txDirty) + { + lock (_txLock) + { + _ctx.Store.SaveTransactionsIfDirty(_transactions); + _txDirty = false; + } + PublishSnapshot(); + } + } + + public bool OnChat(string text) + { + if (text.StartsWith("[BANK]", StringComparison.OrdinalIgnoreCase)) + { + ParseBalanceLine(text); + return false; // eating is decided by the capture queue + } + // A deposit or withdrawal reply (ours or a typed /b): the next balance and pack changes are moves. + if (text.StartsWith("Deposited ", StringComparison.Ordinal) || text.StartsWith("Withdrew ", StringComparison.Ordinal)) + _moveUntil = Math.Max(_moveUntil, IltHubContext.NowMs + MoveWindowMs); + TryLogTransaction(text); + return false; + } + + public void OnLogout() + { + lock (_txLock) _ctx.Store.SaveTransactionsIfDirty(_transactions); + } + + // ── Parsing ───────────────────────────────────────────────────────────── + + private void ParseBalanceLine(string text) + { + string body = text.Substring("[BANK]".Length).Trim(); + int colon = body.IndexOf(':'); + if (colon <= 0) return; + string label = body.Substring(0, colon).Trim(); + long value = IltParse.ParseLeadingLong(body.Substring(colon + 1)); + if (body.Substring(colon + 1).Trim().Length == 0) return; // header "Your balances are:" + + // Order matters: "Weakly Enlightened Coins" also contains "Enlightened Coins". + if (label.Contains("Prestige", StringComparison.OrdinalIgnoreCase)) Apply("PrestigeCoins", ref Bank.PrestigeCoins, value); + else if (label.Contains("Weakly", StringComparison.OrdinalIgnoreCase)) Apply("WeaklyEnlightenedCoins", ref Bank.WeaklyEnlightenedCoins, value); + else if (label.Contains("Enlightened", StringComparison.OrdinalIgnoreCase)) Apply("EnlightenedCoins", ref Bank.EnlightenedCoins, value); + else if (label.Contains("Mythical", StringComparison.OrdinalIgnoreCase)) Apply("MythicalKeys", ref Bank.MythicalKeys, value); + else if (label.Contains("Legendary", StringComparison.OrdinalIgnoreCase)) Apply("LegendaryKeys", ref Bank.LegendaryKeys, value); + else if (label.Contains("Luminance", StringComparison.OrdinalIgnoreCase)) Apply("Luminance", ref Bank.Luminance, value); + else if (label.Contains("Pyreal", StringComparison.OrdinalIgnoreCase)) Apply("Pyreals", ref Bank.Pyreals, value); + else return; + + Bank.LastUpdated = DateTime.Now; + _ctx.Options.Set(IltFeature.Bank, IltTri.On); + } + + private void Apply(string key, ref long field, long value) + { + long old = field; + field = value; + if (old != value) + { + try { BalanceChanged?.Invoke(key, old, value); } catch { } + } + } + + private void TryLogTransaction(string text) + { + if (!(text.StartsWith("Transferred ", StringComparison.Ordinal) || text.StartsWith("Received ", StringComparison.Ordinal))) + return; + // Only server system lines are logged. Anything another player can author (tells, says, + // emotes, any bracketed channel) is rejected so quoted "Transferred ..." text can't + // forge entries in the transaction log. + if (IsPlayerAuthoredLine(text)) + { + RynthLog.Trace(LogCat.IltBanking, "transaction ignored (player-authored line): " + text); + return; + } + + var sent = IltParse.BankSent.Match(text); + var recv = sent.Success ? System.Text.RegularExpressions.Match.Empty : IltParse.BankReceived.Match(text); + var m = sent.Success ? sent : recv; + if (!m.Success) return; + + string other = IltParse.StripMarkup(m.Groups[3].Value).Replace(" (offline)", string.Empty).Trim(); + var tx = new IltBankTransaction + { + Timestamp = DateTime.Now, + Type = sent.Success ? "Sent" : "Received", + Amount = IltParse.ParseLeadingLong(m.Groups[1].Value), + Currency = m.Groups[2].Value.Trim(), + OtherPlayer = other, + Description = text, + }; + lock (_txLock) + { + _transactions.Add(tx); + if (_transactions.Count > IltHubStore.MaxTransactions) + _transactions.RemoveRange(0, _transactions.Count - IltHubStore.MaxTransactions); + _txDirty = true; + } + } + + /// True for chat another player could have written (tells, says, channel or emote markup). + private static bool IsPlayerAuthoredLine(string text) + => text.Contains(" RequestRefresh(quiet: true)); + ImGui.SameLine(); + if (ImGui.SmallButton("Copy##bank")) ImGui.SetClipboardText(BuildCopyLine()); + ImGui.SameLine(); + ImGui.TextDisabled(Bank.LastUpdated == DateTime.MinValue ? "never updated" : "updated " + Bank.LastUpdated.ToString("g")); + + if (ImGui.BeginTable("##iltbal", 2, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV)) + { + Row("Pyreals", Bank.Pyreals); + Row("Luminance", Bank.Luminance); + Row("Legendary Keys", Bank.LegendaryKeys); + Row("Mythical Keys", Bank.MythicalKeys); + Row("Enlightened Coins", Bank.EnlightenedCoins); + Row("Weakly Enlightened Coins", Bank.WeaklyEnlightenedCoins); + Row("Prestige Coins", Bank.PrestigeCoins); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Bound to you: deposit and withdraw only, never transferred."); + ImGui.EndTable(); + } + + int refresh = Bank.AutoRefreshSeconds; + ImGui.SetNextItemWidth(120); + if (ImGui.InputInt("Auto-refresh seconds (0 = off)", ref refresh, 30)) + Bank.AutoRefreshSeconds = refresh <= 0 ? 0 : Math.Max(30, refresh); + + ImGui.Separator(); + RenderDepositWithdraw(); + ImGui.Separator(); + RenderTransferForm(); + ImGui.Separator(); + RenderTransactionLog(); + } + + private static void Row(string label, long value) + { + ImGui.TableNextRow(); + ImGui.TableNextColumn(); + ImGui.TextUnformatted(label); + ImGui.TableNextColumn(); + ImGui.TextUnformatted($"{IltParse.N0(value)} ({IltParse.Compact(value)})"); + } + + /// Deposit (one kind or everything, luminance tokens included) and withdraw (an amount, or trade notes). + private void RenderDepositWithdraw() + { + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Deposit"); + int dep = Math.Clamp(Bank.DepositIndex, 0, DepositNames.Length - 1); + ImGui.SetNextItemWidth(200); + if (ImGui.Combo("##bankdep", ref dep, DepositNames, DepositNames.Length)) Bank.DepositIndex = dep; + ImGui.SameLine(); + if (ImGui.Button("Deposit##bankdep")) + { + int index = dep; + _ctx.Post(() => { string err = SendDeposit(index); if (err.Length > 0) _actionResult = err; }); + } + if (ImGui.IsItemHovered()) + ImGui.SetTooltip(IltBankCommands.Deposit(dep) + "\nEverything banks all currencies, notes and luminance tokens." + + "\nThe server refuses while you are busy or moving."); + + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Withdraw"); + int wd = Math.Clamp(Bank.WithdrawIndex, 0, WithdrawNames.Length - 1); + ImGui.SetNextItemWidth(200); + if (ImGui.Combo("##bankwd", ref wd, WithdrawNames, WithdrawNames.Length)) Bank.WithdrawIndex = wd; + bool notes = IltBankCommands.Withdrawals[wd].Code == "n"; + int denom = Math.Clamp(Bank.WithdrawNoteIndex, 0, NoteNames.Length - 1); + if (notes) + { + ImGui.SameLine(); + ImGui.SetNextItemWidth(110); + if (ImGui.Combo("##bankwdnote", ref denom, NoteNames, NoteNames.Length)) Bank.WithdrawNoteIndex = denom; + } + ImGui.SetNextItemWidth(200); + ImGui.InputTextWithHint("##bankwdamt", notes ? "how many notes" : "amount, e.g. 250000, 1.5m", ref _withdrawText, 32u); + bool ok = IltParse.TryParseAmount(_withdrawText, out long amount); + ImGui.SameLine(); + ImGui.BeginDisabled(!ok); + if (ImGui.Button("Withdraw##bankwd")) + { + int index = wd, note = denom; + long amt = amount; + _ctx.Post(() => { string err = SendWithdraw(index, amt, note); if (err.Length > 0) _actionResult = err; }); + } + ImGui.EndDisabled(); + if (_withdrawText.Length > 0) + { + ImGui.SameLine(); + if (!ok) ImGui.TextColored(LegacyDashboardRenderer.ColHp, "invalid amount"); + else if (notes) ImGui.TextDisabled("= " + IltParse.N0(amount * IltBankCommands.NoteDenominations[denom].Value) + " pyreals"); + else ImGui.TextDisabled("= " + IltParse.N0(amount)); + } + + string result = _actionResult; + if (result.Length > 0) ImGui.TextWrapped(result); + } + + private void RenderTransferForm() + { + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Transfer"); + int idx = Math.Clamp(Bank.TransferCurrencyIndex, 0, Currencies.Length - 1); + ImGui.SetNextItemWidth(200); + if (ImGui.Combo("Currency##xfer", ref idx, CurrencyNames, CurrencyNames.Length)) + Bank.TransferCurrencyIndex = idx; + + ImGui.SetNextItemWidth(200); + ImGui.InputTextWithHint("Amount##xfer", "e.g. 250000, 1.5m, 2b", ref _amountText, 32u); + string target = Bank.TransferTarget; + ImGui.SetNextItemWidth(200); + if (ImGui.InputTextWithHint("Recipient##xfer", "character name", ref target, 64u)) + Bank.TransferTarget = target; + + bool amountOk = IltParse.TryParseAmount(_amountText, out long amount); + if (_amountText.Length > 0) + { + ImGui.SameLine(); + if (amountOk) ImGui.TextDisabled("= " + IltParse.N0(amount)); + else ImGui.TextColored(LegacyDashboardRenderer.ColHp, "invalid amount"); + } + + ImGui.BeginDisabled(!amountOk || string.IsNullOrWhiteSpace(Bank.TransferTarget)); + if (ImGui.Button("Send transfer...")) + { + int cur = idx; + long amt = amount; + string who = Bank.TransferTarget.Trim(); + _ctx.Confirm("Confirm bank transfer", + $"Send {IltParse.N0(amt)} {Currencies[cur].Name} to {who}?\n\nThis cannot be undone.", + () => + { + string err = SendTransfer(cur, amt, who); + _lastResult = err.Length > 0 ? err : "Transfer sent..."; + }, + "Send"); + } + ImGui.EndDisabled(); + if (_lastResult.Length > 0) ImGui.TextWrapped(_lastResult); + } + + private void RenderTransactionLog() + { + var snap = _txSnapshot; + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, $"Transactions ({snap.Length})"); + ImGui.SameLine(); + ImGui.SetNextItemWidth(180); + ImGui.InputTextWithHint("##txfilter", "filter player / currency", ref _txFilter, 64u); + ImGui.SameLine(); + if (ImGui.SmallButton("Copy CSV")) ImGui.SetClipboardText(BuildCsv(snap)); + + if (ImGui.BeginTable("##ilttx", 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.Resizable, + new Vector2(0, 220))) + { + ImGui.TableSetupScrollFreeze(0, 1); + ImGui.TableSetupColumn("When"); + ImGui.TableSetupColumn("Type"); + ImGui.TableSetupColumn("Amount"); + ImGui.TableSetupColumn("Currency"); + ImGui.TableSetupColumn("Player"); + ImGui.TableHeadersRow(); + for (int i = snap.Length - 1; i >= 0; i--) + { + var t = snap[i]; + if (_txFilter.Length > 0 + && !t.OtherPlayer.Contains(_txFilter, StringComparison.OrdinalIgnoreCase) + && !t.Currency.Contains(_txFilter, StringComparison.OrdinalIgnoreCase)) + continue; + ImGui.TableNextRow(); + ImGui.TableNextColumn(); ImGui.TextUnformatted(t.Timestamp.ToString("g")); + ImGui.TableNextColumn(); + ImGui.TextColored(t.Type == "Sent" ? LegacyDashboardRenderer.ColAmber : LegacyDashboardRenderer.ColGreen, t.Type); + ImGui.TableNextColumn(); ImGui.TextUnformatted(IltParse.N0(t.Amount)); + ImGui.TableNextColumn(); ImGui.TextUnformatted(t.Currency); + ImGui.TableNextColumn(); ImGui.TextUnformatted(t.OtherPlayer); + } + ImGui.EndTable(); + } + } + + /// One-line summary in UB's chat-paste format. + public string BuildCopyLine() + => $"Bank Balances - {_ctx.CharName} | P: {IltParse.N0(Bank.Pyreals)} | L: {IltParse.N0(Bank.Luminance)} | " + + $"LK: {IltParse.N0(Bank.LegendaryKeys)} | MK: {IltParse.N0(Bank.MythicalKeys)} | " + + $"Coins: {IltParse.N0(Bank.EnlightenedCoins)} | W Coins: {IltParse.N0(Bank.WeaklyEnlightenedCoins)} | " + + $"P Coins: {IltParse.N0(Bank.PrestigeCoins)} | " + + $"Updated: {(Bank.LastUpdated == DateTime.MinValue ? "never" : Bank.LastUpdated.ToString("g"))}"; + + private static string BuildCsv(IltBankTransaction[] rows) + { + var sb = new System.Text.StringBuilder("Timestamp,Type,Amount,Currency,Player\n"); + foreach (var t in rows) + sb.Append(t.Timestamp.ToString("s")).Append(',').Append(t.Type).Append(',').Append(t.Amount).Append(',') + .Append('"').Append(t.Currency.Replace("\"", "\"\"")).Append("\",\"") + .Append(t.OtherPlayer.Replace("\"", "\"\"")).Append("\"\n"); + return sb.ToString(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBuffKeepers.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBuffKeepers.cs new file mode 100644 index 0000000..f897eae --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBuffKeepers.cs @@ -0,0 +1,254 @@ +// IltBuffKeepers.cs — Rune-of-Dispel auto-dispel and Surging Strength keeper (Gear tab). +// +// Both read the player's enchantment list once a second (one shared read). +// Dispel: classifies active spells by NAME (SpellDatabase has no debuff flag): +// 1. Mire Foot (3051 / "mire"+"foot") → never (dispelling it is pointless) +// 2. user include list → dispel +// 3. beneficial pattern → keep +// 4. user exclude list → keep +// 5. known-harmful exact name or pattern → dispel +// and uses a Rune of Dispel (WCID 30133). Cooldown, verify after 2 s, up to 3 retries. +// Surging Strength: uses the Empowered Volcanic Ember when the buff is missing. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltBuffKeepers : IIltFeature +{ + private const int SpellMireFoot = 3051; + private const int MaxEnch = 256; + + private static readonly HashSet HarmfulExact = BuildHarmfulExact(); + private static readonly Regex HarmfulPattern = new( + @"\b(vulnerability|imperil|weakness|slowness|bane|exhaustion|mana burn|fester|curse of|blight of|burden of)\b", + RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + private static readonly Regex BeneficialPattern = new( + @"\b(invulnerability|invulnerable|protection|ward|armor|blessing|strength|coordination|endurance|quickness|focus|willpower|" + + @"regeneration|mana renewal|stamina renewal|health renewal|arcanum|cantrap|enhancement|augmentation|weave of|shroud of|" + + @"mantle of|cloak of|veil of|master's blessing|society|fellowship|loyalty|devotion)\b", + RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + + private static HashSet BuildHarmfulExact() + { + var set = new HashSet(StringComparer.OrdinalIgnoreCase); + foreach (string s in new[] { "weakness other", "vulnerability other", "imperil other", "slowness other", + "bane other", "exhaustion other", "mana burn other", "fester other" }) + { + set.Add(s); + set.Add("incantation of " + s); + } + foreach (string s in new[] { "belly of lead", "gelidite's gift", "inferno's gift", "senescence", "archer's gift", + "swordsman's gift", "leaden feet", "heart of ice", "burning soul", "withering" }) + set.Add(s); + return set; + } + + private readonly IltHubContext _ctx; + private readonly uint[] _ids = new uint[MaxEnch]; + private readonly double[] _exp = new double[MaxEnch]; + private long _lastRead; + + // Dispel state + private long _dispelCooldownUntil; + private long _verifyAt; + private int _retries; + private volatile string[] _harmfulNow = Array.Empty(); + private volatile string _dispelStatus = "idle"; + + // Surging state + private long _surgeCooldownUntil; + private volatile bool _surgeActive; + private volatile string _surgeStatus = "idle"; + + // Render-thread edit buffers + private string _newInclude = string.Empty, _newExclude = string.Empty; + + public IltBuffKeepers(IltHubContext ctx) => _ctx = ctx; + + private IltGearState G => _ctx.State.Gear; + + /// True when this spell should be dispelled (precedence documented above). + public bool IsHarmful(int spellId, string name) + { + if (spellId == SpellMireFoot || (name.Contains("mire", StringComparison.OrdinalIgnoreCase) && name.Contains("foot", StringComparison.OrdinalIgnoreCase))) + return false; + if (G.DispelInclusions.ToArray().Any(i => i.Length > 0 && name.Contains(i, StringComparison.OrdinalIgnoreCase))) return true; + if (BeneficialPattern.IsMatch(name)) return false; + if (G.DispelExclusions.ToArray().Any(e => e.Length > 0 && name.Contains(e, StringComparison.OrdinalIgnoreCase))) return false; + string bare = StripTier(name); + return HarmfulExact.Contains(name) || HarmfulExact.Contains(bare) || HarmfulPattern.IsMatch(name); + } + + /// "Vulnerability Other VII" → "vulnerability other" (roman numeral suffix removed). + private static string StripTier(string name) + { + string n = name.Trim(); + int sp = n.LastIndexOf(' '); + if (sp > 0) + { + string tail = n.Substring(sp + 1); + if (tail.Length > 0 && tail.All(ch => "IVXL".IndexOf(char.ToUpperInvariant(ch)) >= 0)) n = n.Substring(0, sp); + } + return n.ToLowerInvariant(); + } + + private WorldObject? FindRune() + => _ctx.Inventory.FindByWcid(IltInventory.WcidRuneOfDispel) + ?? _ctx.Inventory.FindByName(n => n.Equals("Rune of Dispel", StringComparison.OrdinalIgnoreCase) + || (n.Contains("dispel", StringComparison.OrdinalIgnoreCase) && n.Contains("rune", StringComparison.OrdinalIgnoreCase))); + + private WorldObject? FindEmber() + => _ctx.Inventory.FindByName(n => n.Contains("empowered", StringComparison.OrdinalIgnoreCase) + && n.Contains("volcanic", StringComparison.OrdinalIgnoreCase) + && n.Contains("ember", StringComparison.OrdinalIgnoreCase)); + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + if (!G.AutoDispel && !G.SurgingStrength) return; + if (nowMs - _lastRead < 1000) return; + _lastRead = nowMs; + if (!_ctx.Host.HasReadPlayerEnchantments) return; + + int n = _ctx.Host.ReadPlayerEnchantments(_ids, _exp, MaxEnch); + if (n < 0) return; + n = Math.Min(n, MaxEnch); + + var harmful = new List(); + bool surge = false; + for (int i = 0; i < n; i++) + { + int id = unchecked((int)_ids[i]); + string name = SpellDatabase.GetSpellName(id); + if (string.IsNullOrEmpty(name)) continue; + if (name.Contains("Surging Strength", StringComparison.OrdinalIgnoreCase)) surge = true; + if (G.AutoDispel && IsHarmful(id, name)) harmful.Add(name); + } + _harmfulNow = harmful.Distinct(StringComparer.OrdinalIgnoreCase).ToArray(); + _surgeActive = surge; + + if (G.AutoDispel) TickDispel(nowMs, harmful.Count > 0); + if (G.SurgingStrength) TickSurge(nowMs, surge); + } + + private void TickDispel(long now, bool anyHarmful) + { + // Verification / retry window after a rune use. + if (_verifyAt > 0) + { + if (now < _verifyAt) return; + if (!anyHarmful || _retries >= 3) + { + _dispelStatus = anyHarmful ? "debuffs remain after 3 retries" : "dispelled"; + _verifyAt = 0; + _dispelCooldownUntil = now + Math.Max(2, G.DispelCooldownSeconds) * 1000L; + return; + } + _retries++; + if (UseRune(now)) _verifyAt = now + 2500; + return; + } + + if (!anyHarmful) { _dispelStatus = "no harmful spells"; return; } + if (now < _dispelCooldownUntil) { _dispelStatus = "cooling down"; return; } + _retries = 0; + if (UseRune(now)) _verifyAt = now + 2000; + } + + private bool UseRune(long now) + { + if (_ctx.Inventory.IsBusy) return false; + var rune = FindRune(); + if (rune == null) { _dispelStatus = "no Rune of Dispel carried"; _dispelCooldownUntil = now + 30_000; _verifyAt = 0; return false; } + if (!_ctx.Inventory.Use(rune)) return false; + _dispelStatus = $"used {rune.Name} on {_harmfulNow.Length} debuff(s)"; + return true; + } + + private void TickSurge(long now, bool active) + { + if (active) { _surgeStatus = "Surging Strength active"; return; } + if (now < _surgeCooldownUntil || _ctx.Inventory.IsBusy) return; + var ember = FindEmber(); + if (ember == null) { _surgeStatus = "no Empowered Volcanic Ember carried"; _surgeCooldownUntil = now + 30_000; return; } + if (_ctx.Inventory.Use(ember)) _surgeStatus = "used " + ember.Name; + _surgeCooldownUntil = now + Math.Max(5, G.SurgingCooldownSeconds) * 1000L; + } + + public bool OnChat(string text) + { + if (!G.SurgingStrength) return false; + if (text.Contains("surging strength", StringComparison.OrdinalIgnoreCase)) + { + if (text.Contains("you cast", StringComparison.OrdinalIgnoreCase) && text.Contains("on yourself", StringComparison.OrdinalIgnoreCase)) + _surgeActive = true; + else if (text.Contains("has expired", StringComparison.OrdinalIgnoreCase)) + { + _surgeActive = false; + _surgeCooldownUntil = 0; // re-apply on the next read + } + } + return false; + } + + public void OnLogout() + { + _verifyAt = 0; + _harmfulNow = Array.Empty(); + } + + // ── UI (render thread) ────────────────────────────────────────────────── + + public void Render() + { + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Auto-dispel (Rune of Dispel)"); + bool ad = G.AutoDispel; + if (ImGui.Checkbox("Use a Rune of Dispel on harmful debuffs", ref ad)) G.AutoDispel = ad; + int cd = G.DispelCooldownSeconds; + ImGui.SetNextItemWidth(100); + if (ImGui.InputInt("Cooldown (s)##disp", ref cd)) G.DispelCooldownSeconds = Math.Max(2, cd); + ImGui.TextDisabled("Status: " + _dispelStatus); + var harm = _harmfulNow; + if (harm.Length > 0) ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "Harmful now: " + string.Join(", ", harm)); + if (ImGui.TreeNode("Always / never dispel lists")) + { + EditList("Always dispel (name contains)", G.DispelInclusions, ref _newInclude, "inc"); + EditList("Never dispel (name contains)", G.DispelExclusions, ref _newExclude, "exc"); + ImGui.TreePop(); + } + + ImGui.Separator(); + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Surging Strength"); + bool ss = G.SurgingStrength; + if (ImGui.Checkbox("Keep Surging Strength up (Empowered Volcanic Ember)", ref ss)) G.SurgingStrength = ss; + ImGui.TextDisabled("Status: " + (_surgeActive ? "active" : _surgeStatus)); + } + + private void EditList(string label, List list, ref string buffer, string id) + { + ImGui.TextUnformatted(label); + var snap = list.ToArray(); + for (int i = 0; i < snap.Length; i++) + { + ImGui.BulletText(snap[i]); + ImGui.SameLine(); + string victim = snap[i]; + if (ImGui.SmallButton($"x##{id}{i}")) _ctx.Post(() => list.Remove(victim)); + } + ImGui.SetNextItemWidth(200); + ImGui.InputTextWithHint($"##new{id}", "spell name text", ref buffer, 64u); + ImGui.SameLine(); + if (ImGui.SmallButton($"Add##{id}") && buffer.Trim().Length > 0) + { + string add = buffer.Trim(); + _ctx.Post(() => { if (!list.Contains(add, StringComparer.OrdinalIgnoreCase)) list.Add(add); }); + buffer = string.Empty; + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharmTracker.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharmTracker.cs new file mode 100644 index 0000000..5f92861 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharmTracker.cs @@ -0,0 +1,141 @@ +// IltCharmTracker.cs — Every ACECustom registry charm's state: the Mini Remote's Charms tab +// (IltCharms) and RynthPluginGetCharmsJson (an older engine's Settings "Charms Tracking" tab). +// +// Per charm it reports: +// acquired — "carried" (in pack / equipped now), "seen" (carried earlier this or a past +// session, remembered in IltCharacterState.CharmsSeen), or "no". +// active — "on" / "off" / "unknown". The charm's appraisal Use text ("Status: ON") wins; +// otherwise the player ability PropertyBool the server sets while it's active. +// The server deactivates abilities whose charm isn't possessed, so not carried = off. +// server — "off" when the server refused / reported the charm disabled, "on" when a feature +// dump reported it enabled, else "unknown" (clients can't query /charms). +// Pump thread only (inventory and property reads). +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltCharmTracker +{ + private readonly IltHubContext _ctx; + + public IltCharmTracker(IltHubContext ctx) => _ctx = ctx; + + /// + /// One charm's tracked state. is the carried copy a toggle uses + /// (the active one when one is on), 0 when none is carried. + /// + internal readonly record struct CharmState( + IltCharmDef Def, string Acquired, int Count, int Tier, int MaxTier, + IltTri Active, IltTri Server, DateTime LastSeenUtc, int ToggleId = 0); + + /// Evaluates every registry charm and refreshes the "seen" memory for carried ones. + public List Evaluate() + { + var inv = _ctx.Inventory; + var seenMap = _ctx.State.Character.CharmsSeen; + var result = new List(IltInventory.Charms.Length); + // One inventory pass, grouped by charm definition, instead of a WCID scan per charm. + var carried = new Dictionary>(); + foreach (var wo in inv.Items()) + { + var def = inv.CharmDefFor(wo); + if (def == null) continue; + if (!carried.TryGetValue(def, out var list)) carried[def] = list = new(); + list.Add(wo); + } + + foreach (var def in IltInventory.Charms) + { + carried.TryGetValue(def, out var items); + int count = items?.Count ?? 0; + int tier = 0, maxTier = 0, toggleId = 0; + IltTri active = IltTri.Off; + + if (count > 0) + { + // Server allows only one active charm per ability, so any ON item means ON. + bool anyOn = false, allKnown = true; + toggleId = items![0].Id; + foreach (var wo in items!) + { + var (t, m) = inv.CharmTier(wo); + if (t > tier) { tier = t; maxTier = m; } + var st = inv.CharmStatus(wo); + if (st == IltTri.On) { anyOn = true; toggleId = wo.Id; } + else if (st == IltTri.Unknown) allKnown = false; + } + if (anyOn) active = IltTri.On; + else if (def.PlayerFlag != 0 && inv.PlayerBool(def.PlayerFlag)) active = IltTri.On; + else active = allKnown ? IltTri.Off : IltTri.Unknown; + + if (!seenMap.TryGetValue(def.Name, out var seen)) seenMap[def.Name] = seen = new IltCharmSeen(); + if (tier > seen.Tier) { seen.Tier = tier; seen.MaxTier = maxTier; } + // Day resolution keeps the persisted state from changing (and re-saving) every poll. + var today = DateTime.UtcNow.Date; + if (seen.LastSeenUtc != today) seen.LastSeenUtc = today; + } + + seenMap.TryGetValue(def.Name, out var memory); + string acquired = count > 0 ? "carried" : memory != null ? "seen" : "no"; + if (count == 0 && memory != null) { tier = memory.Tier; maxTier = memory.MaxTier; } + + result.Add(new CharmState(def, acquired, count, tier, maxTier, active, + ServerState(def), memory?.LastSeenUtc ?? default, toggleId)); + } + return result; + } + + /// Server-side enabled state as far as the client has learned it. + private IltTri ServerState(IltCharmDef def) + { + var opts = _ctx.Options; + var tri = opts.Get(IltFeature.Charm(def.Name)); + // Universal Summoning Mastery also has a ServerConfig switch, reported separately. + if (Array.IndexOf(def.Wcids, IltInventory.WcidUniversalMasteryCharm) >= 0) + { + var cfg = opts.Get(IltFeature.UniversalMastery); + if (cfg == IltTri.Off || tri == IltTri.Off) return IltTri.Off; + if (cfg == IltTri.On || tri == IltTri.On) return IltTri.On; + } + return tri; + } + + /// JSON for RynthPluginGetCharmsJson. "available" is false off ILT-like worlds. + public string BuildJson() + { + var sb = new StringBuilder(4096); + bool available = _ctx.Options.IsIltLikeWorld; + sb.Append("{\"available\":").Append(available ? "true" : "false"); + sb.Append(",\"world\":\"").Append(RynthAiPlugin.JsonEscape(_ctx.Options.WorldName ?? string.Empty)).Append('"'); + if (!available) return sb.Append(",\"charms\":[]}").ToString(); + + var rows = Evaluate(); + sb.Append(",\"total\":").Append(rows.Count); + sb.Append(",\"acquiredCount\":").Append(rows.Count(r => r.Acquired != "no")); + sb.Append(",\"activeCount\":").Append(rows.Count(r => r.Active == IltTri.On)); + sb.Append(",\"charms\":["); + for (int i = 0; i < rows.Count; i++) + { + var r = rows[i]; + if (i > 0) sb.Append(','); + sb.Append("{\"name\":\"").Append(RynthAiPlugin.JsonEscape(r.Def.Name)).Append('"'); + sb.Append(",\"effect\":\"").Append(RynthAiPlugin.JsonEscape(r.Def.Effect)).Append('"'); + sb.Append(",\"acquired\":\"").Append(r.Acquired).Append('"'); + sb.Append(",\"count\":").Append(r.Count); + sb.Append(",\"tier\":").Append(r.Tier); + sb.Append(",\"maxTier\":").Append(r.MaxTier); + sb.Append(",\"active\":\"").Append(TriText(r.Active)).Append('"'); + sb.Append(",\"server\":\"").Append(TriText(r.Server)).Append('"'); + sb.Append(",\"lastSeen\":\"") + .Append(r.LastSeenUtc == default ? string.Empty : r.LastSeenUtc.ToString("yyyy-MM-dd")) + .Append("\"}"); + } + sb.Append("]}"); + return sb.ToString(); + } + + private static string TriText(IltTri t) => t switch { IltTri.On => "on", IltTri.Off => "off", _ => "unknown" }; +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharms.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharms.cs new file mode 100644 index 0000000..e74a59a --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharms.cs @@ -0,0 +1,217 @@ +// IltCharms.cs — The Mini Remote's "Charms" ILT tab: every ACECustom registry charm in one table. +// +// Per charm (IltCharmTracker): acquired ("carried" now, "stored" = carried before and remembered +// per character, or no), status ON / OFF from the charm's appraisal or the player's ability flag, +// best tier, and the server's switch when the client has learned it. A carried charm has a +// Toggle (using a charm flips it). The Guardian Hand isn't a registry charm (no published WCID), +// so it is matched by name or a configured WCID and listed under the table with its own Toggle. +// This was the engine Settings panel's "Charms Tracking" tab plus the Gear tab's charm strip. +// Scans run on the pump thread every 3 s while the Mini Remote is on screen; Render reads the +// published arrays only. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltCharms : IIltFeature +{ + private const long ScanIntervalMs = 3000; + + private readonly IltHubContext _ctx; + private readonly IltCharmTracker _tracker; + + /// A Guardian Hand carried now (name or WCID match). + private sealed record HandRow(int Id, string Name, IltTri Status, bool ServerDisabled); + + private volatile IltCharmTracker.CharmState[] _rows = Array.Empty(); + private volatile HandRow[] _hands = Array.Empty(); + private long _lastScan; + + public IltCharms(IltHubContext ctx, IltCharmTracker tracker) + { + _ctx = ctx; + _tracker = tracker; + } + + private IltGearState G => _ctx.State.Gear; + + private bool IsGuardianHand(WorldObject wo) + { + if (G.GuardianHandWcid != 0 && _ctx.Inventory.Wcid(wo) == G.GuardianHandWcid) return true; + string want = string.IsNullOrWhiteSpace(G.GuardianHandName) ? "Guardian Hand" : G.GuardianHandName.Trim(); + return wo.Name.Contains(want, StringComparison.OrdinalIgnoreCase) + || (wo.Name.Contains("guardian", StringComparison.OrdinalIgnoreCase) && wo.Name.Contains("hand", StringComparison.OrdinalIgnoreCase)); + } + + /// Pump thread: the registry table and the carried Guardian Hands. + private void Scan() + { + _rows = _tracker.Evaluate().ToArray(); + var inv = _ctx.Inventory; + var hands = new List(); + foreach (var wo in inv.Items().Where(IsGuardianHand)) + hands.Add(new HandRow(wo.Id, wo.Name, inv.CharmStatus(wo), _ctx.Options.IsOff(IltFeature.Charm("Guardian Hand")))); + _hands = hands.ToArray(); + } + + /// Uses (toggles) a charm (pump thread). + private void Toggle(int id) + { + var wo = _ctx.Inventory.Cache?[id]; + if (wo == null) return; + if (_ctx.Inventory.IsBusy) { _ctx.Chat("[Mini Remote] Busy - try the charm again in a moment."); return; } + _ctx.Inventory.Use(wo); + _lastScan = 0; // re-read the status soon (the appraisal refresh is throttled per item) + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + if (!_ctx.WindowOpen || nowMs - _lastScan < ScanIntervalMs) return; + _lastScan = nowMs; + Scan(); + } + + public bool OnChat(string text) => false; + + public void OnLogout() + { + _rows = Array.Empty(); + _hands = Array.Empty(); + _lastScan = 0; + } + + // ── UI (render thread) ────────────────────────────────────────────────── + + public void Render() + { + var rows = _rows; + if (rows.Length == 0) + { + ImGui.TextDisabled(_ctx.WindowOpen ? "Reading your charms..." : "Open the Mini Remote to read your charms."); + RenderGuardianHand(); + return; + } + + int acquired = rows.Count(r => r.Acquired != "no"), active = rows.Count(r => r.Active == IltTri.On); + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, $"{acquired} of {rows.Length} acquired, {active} active"); + ImGui.SameLine(); + if (ImGui.SmallButton("Refresh##charms")) _ctx.Post(() => { _lastScan = 0; }); + + const ImGuiTableFlags flags = ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerH | ImGuiTableFlags.SizingFixedFit + | ImGuiTableFlags.ScrollY; + float h = Math.Max(140f, ImGui.GetContentRegionAvail().Y - 110f); + if (ImGui.BeginTable("##iltcharms", 6, flags, new Vector2(0, h))) + { + ImGui.TableSetupScrollFreeze(0, 1); + ImGui.TableSetupColumn("Charm", ImGuiTableColumnFlags.WidthStretch); + ImGui.TableSetupColumn("Acquired", ImGuiTableColumnFlags.WidthFixed, 64); + ImGui.TableSetupColumn("Status", ImGuiTableColumnFlags.WidthFixed, 44); + ImGui.TableSetupColumn("Tier", ImGuiTableColumnFlags.WidthFixed, 40); + ImGui.TableSetupColumn("Server", ImGuiTableColumnFlags.WidthFixed, 58); + ImGui.TableSetupColumn("##toggle", ImGuiTableColumnFlags.WidthFixed, 52); + ImGui.TableHeadersRow(); + for (int i = 0; i < rows.Length; i++) RenderRow(i, rows[i]); + ImGui.EndTable(); + } + + RenderGuardianHand(); + ImGui.TextDisabled("Status comes from the charm's appraisal or your ability flag; a charm not carried is inactive."); + ImGui.TextDisabled("Stored = carried by this character before (remembered per character)."); + } + + private void RenderRow(int i, IltCharmTracker.CharmState r) + { + ImGui.PushID(i); + ImGui.TableNextRow(); + + ImGui.TableNextColumn(); + bool carried = r.Acquired == "carried"; + if (carried) ImGui.TextUnformatted(r.Def.Name); + else ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, r.Def.Name); + if (ImGui.IsItemHovered() && r.Def.Effect.Length > 0) ImGui.SetTooltip(r.Def.Effect); + + ImGui.TableNextColumn(); + if (carried) ImGui.TextColored(LegacyDashboardRenderer.ColGreen, r.Count > 1 ? $"Carried x{r.Count}" : "Carried"); + else if (r.Acquired == "seen") + { + ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "Stored"); + if (ImGui.IsItemHovered() && r.LastSeenUtc != default) + ImGui.SetTooltip("Last carried " + r.LastSeenUtc.ToString("yyyy-MM-dd")); + } + else ImGui.TextDisabled("No"); + + ImGui.TableNextColumn(); + if (!carried) ImGui.TextDisabled("-"); + else if (r.Active == IltTri.On) ImGui.TextColored(LegacyDashboardRenderer.ColGreen, "ON"); + else if (r.Active == IltTri.Off) ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "OFF"); + else + { + ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "?"); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Waiting for the charm's appraisal."); + } + + ImGui.TableNextColumn(); + ImGui.TextUnformatted(r.Tier <= 0 ? "-" : r.MaxTier > 0 ? $"{r.Tier}/{r.MaxTier}" : r.Tier.ToString()); + + ImGui.TableNextColumn(); + if (r.Server == IltTri.Off) + { + ImGui.TextColored(LegacyDashboardRenderer.ColHp, "Disabled"); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("The server refused or reported this charm as disabled."); + } + else if (r.Server == IltTri.On) ImGui.TextColored(LegacyDashboardRenderer.ColGreen, "Enabled"); + else + { + ImGui.TextDisabled("-"); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Not reported. The server only tells players when a charm is refused."); + } + + ImGui.TableNextColumn(); + if (carried && r.ToggleId != 0 && r.Server != IltTri.Off) + { + int id = r.ToggleId; + if (ImGui.SmallButton("Toggle")) _ctx.Post(() => Toggle(id)); + } + ImGui.PopID(); + } + + /// The Guardian Hand (not a registry charm): each carried one with a Toggle, and how it is matched. + private void RenderGuardianHand() + { + var hands = _hands; + foreach (var h in hands) + { + ImGui.PushID(h.Id); + if (h.ServerDisabled) ImGui.TextDisabled($"{h.Name} - disabled on this server"); + else + { + var col = h.Status == IltTri.On ? LegacyDashboardRenderer.ColGreen + : h.Status == IltTri.Off ? LegacyDashboardRenderer.ColTextMute : LegacyDashboardRenderer.ColAmber; + ImGui.TextColored(col, h.Status == IltTri.On ? "ON " : h.Status == IltTri.Off ? "OFF" : " ? "); + ImGui.SameLine(); + ImGui.TextUnformatted(h.Name); + ImGui.SameLine(); + int id = h.Id; + if (ImGui.SmallButton("Toggle")) _ctx.Post(() => Toggle(id)); + } + ImGui.PopID(); + } + + if (ImGui.TreeNode("Guardian Hand matching")) + { + string name = G.GuardianHandName; + ImGui.SetNextItemWidth(200); + if (ImGui.InputText("Name contains", ref name, 64u)) G.GuardianHandName = name; + int wcid = unchecked((int)G.GuardianHandWcid); + ImGui.SetNextItemWidth(140); + if (ImGui.InputInt("WCID (0 = name only)", ref wcid, 0)) G.GuardianHandWcid = unchecked((uint)Math.Max(0, wcid)); + ImGui.TreePop(); + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChatCapture.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChatCapture.cs new file mode 100644 index 0000000..31da8ca --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChatCapture.cs @@ -0,0 +1,199 @@ +// IltChatCapture.cs — Shared "send a server command and collect its reply" helper. +// +// Every ILT Hub feature that talks to ACECustom (/bank, /aug, /qb, /pets, /xp, /pb, +// /ilt features, the login probe, ...) goes through this one queue so that: +// * only one capture is in flight at a time (replies can't be attributed to the wrong +// request), +// * reply lines can be eaten so a Hub refresh doesn't spam the chat window, +// * an "Unknown command: X" reply is recognised uniformly (feature not on this server). +// All methods must be called on the plugin pump thread (OnTick / OnChatWindowText). +using System; +using System.Collections.Generic; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +/// Describes one command whose reply should be captured. +internal sealed class IltChatRequest +{ + /// Text handed to InvokeChatParser, e.g. "/bank". + public string Command = string.Empty; + /// True for lines that belong to this reply (captured, refresh the idle timer). + public Func IsResponseLine = _ => false; + /// Optional: a line that ends the reply immediately (it is captured too). + public Func? IsTerminator; + /// The reply is complete after this long with no new response line. + public int IdleEndMs = 2000; + /// Give up if no response line arrives within this long. + public int FirstLineTimeoutMs = 15000; + /// Hide captured lines from the chat window. + public bool Eat = true; + /// Invoked once on the pump thread when the capture finishes for any reason. + public Action? OnComplete; +} + +/// What a capture produced. +internal sealed class IltChatResult +{ + public readonly List Lines = new(); + /// No response line ever arrived. + public bool TimedOut; + /// The server answered "Unknown command: …" for this command. + public bool UnknownCommand; + /// The engine had no InvokeChatParser, so nothing was sent. + public bool NotSent; + public string? TerminatorLine; +} + +internal sealed class IltChatCapture +{ + private readonly RynthCoreHost _host; + private readonly Queue _queue = new(); + + private IltChatRequest? _active; + private IltChatResult? _activeResult; + private long _sentAt; + private long _lastLineAt; + + /// Minimum spacing between two sends so the server's own command throttles aren't tripped. + private const long SendSpacingMs = 400; + private long _lastSendAt; + + private static long NowMs => Environment.TickCount64; + + public IltChatCapture(RynthCoreHost host) => _host = host; + + /// True while a capture is in flight or queued. + public bool IsBusy => _active != null || _queue.Count > 0; + + /// True if a request with this exact command is queued or in flight (avoids duplicate refreshes). + public bool IsPending(string command) + { + if (_active != null && string.Equals(_active.Command, command, StringComparison.OrdinalIgnoreCase)) + return true; + foreach (var r in _queue) + if (string.Equals(r.Command, command, StringComparison.OrdinalIgnoreCase)) + return true; + return false; + } + + /// Queues a capture. It is sent from once earlier captures finish. + public void Enqueue(IltChatRequest request) + { + _queue.Enqueue(request); + RynthLog.Trace(LogCat.IltChat, $"enqueue '{request.Command}' (queue={_queue.Count}, busy={_active != null})"); + } + + /// Drops everything (logout / teardown). Pending callbacks are not invoked. + public void Clear() + { + if (_active != null || _queue.Count > 0) + RynthLog.Trace(LogCat.IltChat, $"clear: dropping active='{_active?.Command}' and {_queue.Count} queued"); + _queue.Clear(); + _active = null; + _activeResult = null; + } + + /// Starts queued captures and finishes the active one on idle/timeout. + public void Tick() + { + long now = NowMs; + if (_active != null && _activeResult != null) + { + bool gotAny = _activeResult.Lines.Count > 0; + if (gotAny && now - _lastLineAt >= _active.IdleEndMs) + Finish(); + else if (!gotAny && now - _sentAt >= _active.FirstLineTimeoutMs) + { + _activeResult.TimedOut = true; + Finish(); + } + } + + if (_active == null && _queue.Count > 0 && now - _lastSendAt >= SendSpacingMs) + StartNext(now); + } + + /// + /// Feed every incoming chat line. Returns true when the line belonged to the active + /// capture and that capture asked for its lines to be eaten. + /// + public bool OnChatLine(string rawText) + { + if (_active == null || _activeResult == null) return false; + string text = rawText.Trim(); + if (text.Length == 0) return false; + + // "Unknown command: blackjack" — ACE GameActionTalk reply for unregistered commands. + if (text.StartsWith("Unknown command:", StringComparison.OrdinalIgnoreCase) + && CommandWordMatches(text.Substring("Unknown command:".Length).Trim())) + { + _activeResult.UnknownCommand = true; + _activeResult.Lines.Add(text); + bool eat = _active.Eat; + Finish(); + return eat; + } + + if (_active.IsTerminator != null && _active.IsTerminator(text)) + { + _activeResult.TerminatorLine = text; + _activeResult.Lines.Add(text); + bool eat = _active.Eat; + Finish(); + return eat; + } + + if (!_active.IsResponseLine(text)) return false; + _activeResult.Lines.Add(text); + _lastLineAt = NowMs; + RynthLog.Trace(LogCat.IltChat, $"line '{_active.Command}'{(_active.Eat ? " [eaten]" : "")}: {text}"); + return _active.Eat; + } + + private bool CommandWordMatches(string word) + { + if (_active == null) return false; + // Request "/bank t p 5 Bob" → command word "bank". + string cmd = _active.Command.TrimStart('/', '@'); + int sp = cmd.IndexOf(' '); + if (sp >= 0) cmd = cmd.Substring(0, sp); + return string.Equals(cmd, word, StringComparison.OrdinalIgnoreCase); + } + + private void StartNext(long now) + { + var req = _queue.Dequeue(); + var result = new IltChatResult(); + if (!_host.HasInvokeChatParser) + { + RynthLog.Trace(LogCat.IltChat, $"not sent '{req.Command}': engine has no InvokeChatParser"); + result.NotSent = true; + try { req.OnComplete?.Invoke(result); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltChat, ex, $"capture callback '{req.Command}'"); } + return; + } + + _active = req; + _activeResult = result; + _sentAt = now; + _lastLineAt = now; + _lastSendAt = now; + RynthLog.Trace(LogCat.IltChat, $"send '{req.Command}' (idle={req.IdleEndMs} ms, timeout={req.FirstLineTimeoutMs} ms, eat={req.Eat})"); + _host.InvokeChatParser(req.Command); + } + + private void Finish() + { + var req = _active; + var res = _activeResult; + _active = null; + _activeResult = null; + if (req == null || res == null) return; + RynthLog.Trace(LogCat.IltChat, + $"complete '{req.Command}' in {NowMs - _sentAt} ms: lines={res.Lines.Count} timedOut={res.TimedOut} " + + $"unknown={res.UnknownCommand} terminator={(res.TerminatorLine != null)}"); + try { req.OnComplete?.Invoke(res); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltChat, ex, $"capture callback '{req.Command}'"); } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChunkClap.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChunkClap.cs new file mode 100644 index 0000000..79edab0 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChunkClap.cs @@ -0,0 +1,282 @@ +// IltChunkClap.cs — Lugian-hammer chunking and /clap automation (Gear tab). +// +// Chunk: uses a Lugian (Aetheria) Hammer on eligible items, one at a time: +// Aetheria — "Aetheria"/"Coalesced Aetheria" gems, not equipped, appraised, not flagged +// never-chunk (bool 9030), never levelled (ItemTotalXp quad 4 == 0), and +// max level (int 319) under the configured cap (Coalesced always qualifies). +// Corrupted — "Corrupted" melee/missile weapons with no tinks (171), no imbue (179), +// not equipped, not never-chunk, cleave (292) <= 1. +// Peace mode only unless ChunkInCombat; waits for the result line (10 s max). +// Clap: "/clap all" converts aetheria chunks + trinkets into coins server-side. Needs the +// AutoCraftingEnabled stamp; 30 min ± 2 min interval, first attempt ~1 min after enable. +using System; +using System.Collections.Generic; +using System.Linq; +using ImGuiNET; +using RynthCore.Loot; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltChunkClap : IIltFeature +{ + private const long ChunkResultWaitMs = 10_000; + private const long ClapFirstDelayMs = 60_000; + private const long ClapJitterMs = 120_000; + + private static readonly string[] ChunkDoneLines = + { + "You smash the aetheria with the hammer.", "The two artifacts link together effortlessly.", + "You successfully chunk the aetheria.", "You fail to chunk the aetheria.", + "The corrupted weapon is crushed into a fine powder.", "You smash the corrupted weapon with the hammer.", + "The corrupted weapon shatters into fragments.", "You fail to chunk the corrupted weapon.", + }; + private static readonly string[] ChunkRefusedLines = + { + "The aetheria is too powerful to chunk.", "You cannot chunk this aetheria.", + "The corrupted weapon is too powerful to chunk.", "You cannot chunk this corrupted weapon.", + }; + + private readonly IltHubContext _ctx; + private readonly Random _rng = new(); + + // Chunk state + private long _lastChunkAt; + private int _waitingOn; + private long _waitStartedAt; + private readonly HashSet _skip = new(); + private bool _manualPass; + private volatile string _chunkStatus = "idle"; + private int _chunked; + + // Clap state + private long _nextClapAt; + private volatile string _clapStatus = "idle"; + private bool _clapWasEnabled; + + public IltChunkClap(IltHubContext ctx) => _ctx = ctx; + + private IltGearState G => _ctx.State.Gear; + + // ── Chunk ─────────────────────────────────────────────────────────────── + + private WorldObject? FindHammer() + => _ctx.Inventory.FindByName(n => n.Equals("Lugian Aetheria Hammer", StringComparison.OrdinalIgnoreCase) + || n.Equals("Lugian Hammer", StringComparison.OrdinalIgnoreCase) + || n.EndsWith(" Lugian Hammer", StringComparison.OrdinalIgnoreCase)); + + /// True/false when decidable; null when appraisal is still needed. + private bool? IsChunkableAetheria(WorldObject wo) + { + if (wo.ObjectClass != AcObjectClass.Gem) return false; + bool coalesced = wo.Name.Equals("Coalesced Aetheria", StringComparison.OrdinalIgnoreCase); + if (!coalesced && (!wo.Name.Contains("Aetheria", StringComparison.OrdinalIgnoreCase) || wo.Name.Contains("Chunk", StringComparison.OrdinalIgnoreCase))) + return false; + var inv = _ctx.Inventory; + if (inv.IsEquipped(wo)) return false; + if (!inv.HasAppraisal(wo)) { inv.RequestAppraisal(wo); return null; } + if (inv.Bool(wo, IltInventory.BoolNeverChunk)) return false; + if (inv.Quad(wo, IltInventory.QuadItemTotalXp) != 0) return false; + return coalesced || inv.Int(wo, IltInventory.IntItemMaxLevel) < Math.Max(1, G.ChunkAetheriaUnderLevel); + } + + private bool? IsChunkableCorrupted(WorldObject wo) + { + if (wo.ObjectClass is not (AcObjectClass.MeleeWeapon or AcObjectClass.MissileWeapon)) return false; + if (!wo.Name.Contains("Corrupted", StringComparison.OrdinalIgnoreCase)) return false; + var inv = _ctx.Inventory; + if (inv.IsEquipped(wo)) return false; + if (!inv.HasAppraisal(wo)) { inv.RequestAppraisal(wo); return null; } + if (inv.Bool(wo, IltInventory.BoolNeverChunk)) return false; + if (inv.Int(wo, IltInventory.IntNumTimesTinkered) != 0 || inv.Int(wo, IltInventory.IntImbuedEffect) != 0) return false; + return inv.Int(wo, IltInventory.IntCleaving) <= 1; + } + + private WorldObject? NextChunkTarget() + { + foreach (var wo in _ctx.Inventory.Items()) + { + if (_skip.Contains(wo.Id)) continue; + if ((G.AutoChunkAetheria || _manualPass) && IsChunkableAetheria(wo) == true) return wo; + if ((G.AutoChunkCorrupted || _manualPass) && IsChunkableCorrupted(wo) == true) return wo; + } + return null; + } + + /// Runs one chunk pass now (both item kinds) regardless of the auto toggles. + public void ChunkNow() + { + RynthLog.Trace(LogCat.IltGear, $"ChunkNow()"); + _manualPass = true; + _lastChunkAt = 0; + _chunkStatus = "manual pass started"; + } + + private void TickChunk(long now) + { + if (!G.AutoChunkAetheria && !G.AutoChunkCorrupted && !_manualPass) return; + + if (_waitingOn != 0) + { + if (now - _waitStartedAt < ChunkResultWaitMs) return; + _skip.Add(_waitingOn); // no result line — don't hammer the same item forever + _waitingOn = 0; + } + if (now - _lastChunkAt < Math.Max(500, G.ChunkIntervalMs)) return; + _lastChunkAt = now; + + if (!G.ChunkInCombat && !_ctx.Inventory.InPeaceMode) { _chunkStatus = "waiting for peace mode"; return; } + if (_ctx.Inventory.IsBusy) return; + + var hammer = FindHammer(); + if (hammer == null) { _chunkStatus = "no Lugian Hammer carried"; _manualPass = false; return; } + var target = NextChunkTarget(); + if (target == null) + { + _chunkStatus = _chunked > 0 ? $"nothing left to chunk ({_chunked} this session)" : "nothing eligible"; + _manualPass = false; + return; + } + if (_ctx.Inventory.UseOn(hammer, unchecked((uint)target.Id))) + { + _waitingOn = target.Id; + _waitStartedAt = now; + _chunkStatus = "chunking " + target.Name; + } + } + + // ── Clap ──────────────────────────────────────────────────────────────── + + private bool HasClapMaterials() + { + var inv = _ctx.Inventory; + foreach (var wo in inv.Items()) + { + uint w = inv.Wcid(wo); + if ((w == IltInventory.WcidRedAetheriaChunk || w == IltInventory.WcidBlueAetheriaChunk) + && inv.Int(wo, IltInventory.IntItemMaxLevel) <= 3) + return true; + string n = wo.Name; + if (n.Equals("Red Aetheria Chunk", StringComparison.OrdinalIgnoreCase) || n.Equals("Blue Aetheria Chunk", StringComparison.OrdinalIgnoreCase) + || n.Equals("Ancient Empyrean Trinket", StringComparison.OrdinalIgnoreCase) || n.Equals("Ancient Falatacot Trinket", StringComparison.OrdinalIgnoreCase)) + return true; + } + return false; + } + + /// Sends "/clap all" through the capture queue (reply stays visible). + public void ClapNow(bool manual) + { + RynthLog.Trace(LogCat.IltGear, $"ClapNow(manual={manual})"); + if (_ctx.Options.IsOff(IltFeature.Clap)) { _clapStatus = "/clap is not available (server or AutoCraftingEnabled stamp)"; return; } + if (_ctx.Capture.IsPending("/clap all")) return; + if (!manual && !HasClapMaterials()) { _clapStatus = "no aetheria materials carried"; return; } + _clapStatus = "sending /clap all..."; + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = "/clap all", + IsResponseLine = t => t.StartsWith("Deposited ", StringComparison.Ordinal) + || t.StartsWith("[Clap]", StringComparison.OrdinalIgnoreCase) + || t.Contains("aetheria materials", StringComparison.OrdinalIgnoreCase) + || t.Contains("AutoCraftingEnabled", StringComparison.OrdinalIgnoreCase), + IdleEndMs = 800, + FirstLineTimeoutMs = 10_000, + Eat = false, + OnComplete = r => + { + if (r.UnknownCommand) { _ctx.Options.Set(IltFeature.Clap, IltTri.Off); _clapStatus = "/clap not available"; return; } + _clapStatus = r.Lines.Count > 0 ? r.Lines[^1] : "no reply"; + if (r.Lines.Any(l => l.StartsWith("Deposited ", StringComparison.Ordinal))) _ctx.Options.Set(IltFeature.Clap, IltTri.On); + }, + }); + } + + private void TickClap(long now) + { + // Automation only runs once the server has positively confirmed /clap (unknown = wait). + if (!G.AutoClap || !_ctx.Options.IsOn(IltFeature.Clap)) { _clapWasEnabled = false; return; } + if (!_clapWasEnabled) + { + _clapWasEnabled = true; + _nextClapAt = now + ClapFirstDelayMs; + _clapStatus = "first auto-clap in ~1 min"; + return; + } + if (now < _nextClapAt) return; + long interval = Math.Max(5, G.ClapIntervalMinutes) * 60_000L; + _nextClapAt = now + interval + (long)((_rng.NextDouble() * 2 - 1) * ClapJitterMs); + ClapNow(manual: false); + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + TickChunk(nowMs); + TickClap(nowMs); + } + + public bool OnChat(string text) + { + if (_waitingOn == 0) return false; + if (text.StartsWith("You're too busy", StringComparison.OrdinalIgnoreCase) || text.StartsWith("You are too busy", StringComparison.OrdinalIgnoreCase)) + { + _waitingOn = 0; // retry the same item next interval + return false; + } + if (ChunkDoneLines.Any(l => text.Contains(l, StringComparison.OrdinalIgnoreCase))) + { + _chunked++; + _waitingOn = 0; + } + else if (ChunkRefusedLines.Any(l => text.Contains(l, StringComparison.OrdinalIgnoreCase))) + { + _skip.Add(_waitingOn); + _waitingOn = 0; + } + return false; + } + + public void OnLogout() + { + _waitingOn = 0; + _skip.Clear(); + _manualPass = false; + _clapWasEnabled = false; + } + + // ── UI (render thread) ────────────────────────────────────────────────── + + public void Render() + { + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Chunking (Lugian Hammer)"); + bool a = G.AutoChunkAetheria, c = G.AutoChunkCorrupted, comb = G.ChunkInCombat; + if (ImGui.Checkbox("Auto-chunk low aetheria", ref a)) G.AutoChunkAetheria = a; + ImGui.SameLine(); + if (ImGui.Checkbox("Auto-chunk corrupted weapons", ref c)) G.AutoChunkCorrupted = c; + if (ImGui.Checkbox("Allow while in combat mode", ref comb)) G.ChunkInCombat = comb; + int under = G.ChunkAetheriaUnderLevel; + ImGui.SetNextItemWidth(100); + if (ImGui.InputInt("Chunk aetheria with max level below", ref under)) G.ChunkAetheriaUnderLevel = Math.Clamp(under, 1, 6); + if (ImGui.Button("Chunk eligible items now...")) _ctx.Confirm("Chunk items", + "Run one chunk pass now on every eligible aetheria and corrupted weapon?\nChunked items are destroyed.", + ChunkNow, "Chunk"); + ImGui.TextDisabled("Status: " + _chunkStatus); + + ImGui.Separator(); + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Clap (/clap all)"); + if (_ctx.Options.IsOff(IltFeature.Clap)) + { + ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "Not available (server off or AutoCraftingEnabled stamp missing)."); + return; + } + bool ac = G.AutoClap; + if (ImGui.Checkbox("Auto-clap periodically", ref ac)) G.AutoClap = ac; + int mins = G.ClapIntervalMinutes; + ImGui.SetNextItemWidth(100); + if (ImGui.InputInt("Interval (min)", ref mins)) G.ClapIntervalMinutes = Math.Max(5, mins); + if (ImGui.SmallButton("Clap now")) _ctx.Post(() => ClapNow(manual: true)); + ImGui.SameLine(); + ImGui.TextDisabled(_clapStatus); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltEquipSuits.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltEquipSuits.cs new file mode 100644 index 0000000..d028917 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltEquipSuits.cs @@ -0,0 +1,264 @@ +// IltEquipSuits.cs — UtilityBelt-style equipment profiles (.utl VTank loot files) (Gear tab, P2). +// +// A suit is a VTank loot profile: every carried wearable whose first matching rule is +// Keep belongs to the suit. Loading a suit: +// 1. dequip phase — equipped wearables NOT in the suit go to a pack with a free slot +// (WorldObjectCache.FindPackFor; never into a full pack — that crashes the client); +// 2. equip phase — suit items that aren't worn are used (AC equips on use). +// One action per 100 ms tick and only while not busy. An item is abandoned after 15 +// attempts; the whole load bails after 10 s with no progress. +// Search order: RynthAi EquipProfiles\, EquipProfiles, then UB's equip folders. +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using ImGuiNET; +using RynthCore.Loot; +using RynthCore.Loot.VTank; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.RynthAi.Loot; +using RynthCore.Install; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltEquipSuits : IIltFeature +{ + private const int MaxAttemptsPerItem = 15; + private const long NoProgressBailMs = 10_000; + private const long StepMs = 100; + + private readonly IltHubContext _ctx; + + // Load job (pump thread) + private readonly Queue _dequip = new(); + private readonly Queue _equip = new(); + private readonly Dictionary _attempts = new(); + private bool _running; + private long _lastStep, _lastProgress; + private int _doneCount; + private volatile string _status = "idle"; + + // Render snapshots + private volatile string[] _profiles = Array.Empty(); + private volatile string[] _preview = Array.Empty(); + private int _selected; + + public IltEquipSuits(IltHubContext ctx) => _ctx = ctx; + + private static readonly AcObjectClass[] WearableClasses = + { + AcObjectClass.Armor, AcObjectClass.Clothing, AcObjectClass.Gem, AcObjectClass.Jewelry, + AcObjectClass.MeleeWeapon, AcObjectClass.MissileWeapon, AcObjectClass.WandStaffOrb, + }; + + // ── Profile discovery ─────────────────────────────────────────────────── + + private IEnumerable SearchDirs() + { + string root = Path.Combine(IltHubStore.SharedRoot, "EquipProfiles"); + if (_ctx.CharName.Length > 0) yield return Path.Combine(root, _ctx.CharName); + yield return root; + string ub = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Decal Plugins", "UtilityBelt"); + string world = _ctx.Options.WorldName; + if (world.Length > 0 && _ctx.CharName.Length > 0) yield return Path.Combine(ub, world, _ctx.CharName, "equip"); + if (world.Length > 0) yield return Path.Combine(ub, world, "equip"); + yield return Path.Combine(ub, "equip"); + } + + /// All .utl profiles, first directory wins for duplicate names. + public List<(string Name, string Path)> ListProfiles() + { + var seen = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (string dir in SearchDirs()) + { + try + { + if (!Directory.Exists(dir)) continue; + foreach (string f in Directory.GetFiles(dir, "*.utl")) + { + string n = Path.GetFileNameWithoutExtension(f); + if (!seen.ContainsKey(n)) seen[n] = f; + } + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltGear, ex, $"equip dir {dir}"); } + } + return seen.OrderBy(k => k.Key, StringComparer.OrdinalIgnoreCase).Select(k => (k.Key, k.Value)).ToList(); + } + + private string? ResolveProfile(string? name) + { + if (string.IsNullOrWhiteSpace(name)) name = _ctx.CharName; + name = name!.Trim(); + if (name.EndsWith(".utl", StringComparison.OrdinalIgnoreCase)) name = name[..^4]; + return ListProfiles().FirstOrDefault(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).Path; + } + + /// Items the suit wants worn (first matching rule is Keep). + private List? SuitItems(string path, out string error) + { + error = string.Empty; + VTankLootProfile profile; + try { profile = VTankLootParser.Load(path); } + catch (Exception ex) { error = "could not read profile: " + ex.Message; return null; } + + var lootCtx = new VTankLootContext(_ctx.Host, _ctx.Inventory.PlayerId) { Cache = _ctx.Inventory.Cache }; + var list = new List(); + foreach (var wo in _ctx.Inventory.Items()) + { + if (Array.IndexOf(WearableClasses, wo.ObjectClass) < 0) continue; + if (_ctx.Inventory.Int(wo, IltInventory.IntValidLocations) == 0) continue; + VTankLootRule? match = null; + foreach (var rule in profile.Rules) + if (VTankLootEvaluator.Match(rule, wo, lootCtx)) { match = rule; break; } + if (match != null && match.Action == VTankLootAction.Keep) list.Add(wo); + } + return list; + } + + // ── Commands (pump thread) ────────────────────────────────────────────── + + public void RefreshProfileList() => _profiles = ListProfiles().Select(p => p.Name).ToArray(); + + /// Lists what a load would do without doing it. Returns lines (also shown in the UI). + public List Test(string? name) + { + var lines = new List(); + string? path = ResolveProfile(name); + if (path == null) { lines.Add($"Profile not found: {name ?? _ctx.CharName}"); _preview = lines.ToArray(); return lines; } + var suit = SuitItems(path, out string err); + if (suit == null) { lines.Add(err); _preview = lines.ToArray(); return lines; } + var suitIds = suit.Select(s => s.Id).ToHashSet(); + foreach (var wo in _ctx.Inventory.Items().Where(w => _ctx.Inventory.IsEquipped(w) && !suitIds.Contains(w.Id) + && Array.IndexOf(WearableClasses, w.ObjectClass) >= 0)) + lines.Add("dequip " + wo.Name); + foreach (var wo in suit.Where(w => !_ctx.Inventory.IsEquipped(w))) lines.Add("equip " + wo.Name); + if (lines.Count == 0) lines.Add("Already wearing this suit."); + _preview = lines.ToArray(); + return lines; + } + + /// Starts loading a suit. + public string Load(string? name) + { + RynthLog.Trace(LogCat.IltGear, $"Suits.Load(name='{name}')"); + if (_running) return "A suit load is already running."; + if (!_ctx.Host.HasMoveItemInternal || !_ctx.Host.HasUseObject) return "Engine lacks MoveItemInternal/UseObject."; + string? path = ResolveProfile(name); + if (path == null) return $"Profile not found: {name ?? _ctx.CharName}"; + var suit = SuitItems(path, out string err); + if (suit == null) return err; + + var suitIds = suit.Select(s => s.Id).ToHashSet(); + _dequip.Clear(); _equip.Clear(); _attempts.Clear(); + foreach (var wo in _ctx.Inventory.Items().Where(w => _ctx.Inventory.IsEquipped(w) && !suitIds.Contains(w.Id) + && Array.IndexOf(WearableClasses, w.ObjectClass) >= 0)) + _dequip.Enqueue(wo.Id); + foreach (var wo in suit.Where(w => !_ctx.Inventory.IsEquipped(w))) _equip.Enqueue(wo.Id); + + if (_dequip.Count + _equip.Count == 0) return "Already wearing this suit."; + _running = true; + _doneCount = 0; + _lastProgress = IltHubContext.NowMs; + _ctx.State.Gear.LastEquipProfile = Path.GetFileNameWithoutExtension(path); + _status = $"loading {Path.GetFileNameWithoutExtension(path)}: {_dequip.Count} off, {_equip.Count} on"; + return _status; + } + + public void Cancel(string why) + { + RynthLog.Trace(LogCat.IltGear, $"Suits.Cancel(why='{why}')"); + _running = false; + _dequip.Clear(); + _equip.Clear(); + _status = why; + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + if (!_running || nowMs - _lastStep < StepMs) return; + _lastStep = nowMs; + if (nowMs - _lastProgress > NoProgressBailMs) { Cancel($"no progress for 10 s - stopped ({_doneCount} done)"); return; } + if (_ctx.Inventory.IsBusy) return; + + var cache = _ctx.Inventory.Cache; + if (cache == null) { Cancel("cache not ready"); return; } + + // Dequip phase first so slots are free for the suit. + if (_dequip.Count > 0) + { + int id = _dequip.Peek(); + var wo = cache[id]; + if (wo == null || !_ctx.Inventory.IsEquipped(wo)) { _dequip.Dequeue(); Progress(nowMs); return; } + if (!Attempt(id)) { _dequip.Dequeue(); return; } + int pack = WorldObjectCache.FindPackFor(_ctx.Host, cache, includeMainPack: true, requireFree: 1); + if (pack == 0) { Cancel("no free pack slot for dequipped items - stopped"); return; } + _ctx.Host.MoveItemInternal(unchecked((uint)id), unchecked((uint)pack), 0, Math.Max(1, _ctx.Inventory.StackSize(wo))); + return; + } + + if (_equip.Count > 0) + { + int id = _equip.Peek(); + var wo = cache[id]; + if (wo == null || _ctx.Inventory.IsEquipped(wo)) { _equip.Dequeue(); Progress(nowMs); return; } + if (!Attempt(id)) { _equip.Dequeue(); return; } + _ctx.Inventory.Use(wo); + return; + } + + _running = false; + _status = $"suit loaded ({_doneCount} changes)"; + } + + /// Counts an attempt; false once the item has used up its attempts. + private bool Attempt(int id) + { + int n = _attempts.TryGetValue(id, out int a) ? a + 1 : 1; + _attempts[id] = n; + return n <= MaxAttemptsPerItem; + } + + private void Progress(long now) + { + _doneCount++; + _lastProgress = now; + } + + public bool OnChat(string text) => false; + public void OnLogout() => Cancel("idle"); + + // ── UI (render thread) ────────────────────────────────────────────────── + + public void Render() + { + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Equipment suits (.utl)"); + if (ImGui.SmallButton("Rescan profiles")) _ctx.Post(RefreshProfileList); + var profiles = _profiles; + if (profiles.Length == 0) + { + ImGui.TextDisabled($"No .utl files found ({System.IO.Path.Combine(RynthInstallPaths.RynthAiDir, "EquipProfiles")} or UtilityBelt equip folders)."); + } + else + { + _selected = Math.Clamp(_selected, 0, profiles.Length - 1); + ImGui.SetNextItemWidth(220); + ImGui.Combo("Suit", ref _selected, profiles, profiles.Length); + string pick = profiles[_selected]; + ImGui.SameLine(); + if (ImGui.SmallButton("Test")) _ctx.Post(() => Test(pick)); + ImGui.SameLine(); + if (ImGui.SmallButton("Load...")) + _ctx.Confirm("Load equipment suit", $"Swap to suit '{pick}'?\nItems not in the suit are moved to your packs.", + () => _ctx.Chat("[Mini Remote] " + Load(pick)), "Load"); + if (_running) + { + ImGui.SameLine(); + if (ImGui.SmallButton("Cancel")) _ctx.Post(() => Cancel("cancelled by player")); + } + } + ImGui.TextDisabled("Status: " + _status); + foreach (string l in _preview) ImGui.BulletText(l); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGames.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGames.cs new file mode 100644 index 0000000..3de6d8d --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGames.cs @@ -0,0 +1,254 @@ +// IltGames.cs — ILT Hub "Games" tab + hand HUD (P2): Blackjack, Fellowship Blackjack, Powerball. +// +// Every bet / ticket purchase spends banked luminance, so each one needs a confirm. +// Blackjack is commented out on the current ACECustom build ("Unknown command: +// blackjack"); the pad only appears when the login probe found the command. +// /blackjack , /hit, /stand, /double, /split (fellowship: /fblackjack, /fhit, ...; max 100B) +// /pb (info), /pb buy <1-500>, /pb tickets +// The HUD is a small always-on-top window shown while a hand is in progress. +using System; +using System.Collections.Generic; +using System.Numerics; +using System.Text.RegularExpressions; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltGames : IIltFeature +{ + private const long FBlackjackMaxBet = 100_000_000_000; + private static readonly Regex Dealt = new(@"^You were dealt (?:a |an )?(?.+?)\.$", RegexOptions.Compiled); + private static readonly Regex MyValue = new(@"Your (?:initial )?hand value is (?:now )?(?\d+)", RegexOptions.Compiled); + private static readonly Regex DealerValue = new(@"Rand's (?:current )?hand value is (?\d+)", RegexOptions.Compiled); + + private readonly IltHubContext _ctx; + + // Hand state (pump thread writes, render thread reads — simple fields / snapshot list) + private volatile bool _handActive; + private volatile bool _fellowshipHand; + private volatile string[] _cards = Array.Empty(); + private volatile int _myValue, _dealerValue; + private volatile string _lastResult = string.Empty; + + // Powerball info + private volatile string _pbDraw = string.Empty, _pbJackpot = string.Empty, _pbPrice = string.Empty, _pbStatus = string.Empty; + + // Render-thread input + private string _bjBetText = string.Empty, _fbjBetText = string.Empty; + + public IltGames(IltHubContext ctx) => _ctx = ctx; + + private IltGamesState S => _ctx.State.Games; + + public bool AnyGameAvailable => _ctx.Options.IsOn(IltFeature.Blackjack) || _ctx.Options.IsOn(IltFeature.FBlackjack) + || !_ctx.Options.IsOff(IltFeature.Powerball); + + // ── Commands (pump thread) ────────────────────────────────────────────── + + private void Send(string cmd) + { + if (_ctx.Host.HasInvokeChatParser) _ctx.Host.InvokeChatParser(cmd); + } + + private void StartBlackjack(bool fellowship, long bet) + { + _fellowshipHand = fellowship; + _cards = Array.Empty(); + _myValue = _dealerValue = 0; + _lastResult = string.Empty; + Send($"/{(fellowship ? "fblackjack" : "blackjack")} {bet}"); + } + + private void HandAction(string verb) => Send("/" + (_fellowshipHand ? "f" : "") + verb); + + public void RequestPowerballInfo() + { + RynthLog.Trace(LogCat.IltGames, $"RequestPowerballInfo()"); + if (_ctx.Options.IsOff(IltFeature.Powerball) || _ctx.Capture.IsPending("/pb")) return; + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = "/pb", + IsResponseLine = t => t.StartsWith("[Powerball]", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("Draw #", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("Jackpot Pool", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("Ticket Price", StringComparison.OrdinalIgnoreCase), + IdleEndMs = 1200, + FirstLineTimeoutMs = 8000, + Eat = true, + OnComplete = r => + { + if (r.UnknownCommand) { _ctx.Options.Set(IltFeature.Powerball, IltTri.Off); return; } + if (r.Lines.Count > 0) _ctx.Options.Set(IltFeature.Powerball, IltTri.On); + foreach (string l in r.Lines) ParsePowerball(l); + RynthLog.Trace(LogCat.IltGames, $"/pb info: {r.Lines.Count} line(s), timedOut={r.TimedOut}"); + _pbStatus = r.Lines.Count > 0 ? "updated " + DateTime.Now.ToString("t") : "no reply"; + }, + }); + } + + private void ParsePowerball(string l) + { + string t = l.Trim(); + if (t.StartsWith("Draw #", StringComparison.OrdinalIgnoreCase)) _pbDraw = t; + else if (t.StartsWith("Jackpot Pool", StringComparison.OrdinalIgnoreCase)) _pbJackpot = t; + else if (t.StartsWith("Ticket Price", StringComparison.OrdinalIgnoreCase)) _pbPrice = t; + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) { } + + public bool OnChat(string text) + { + // Powerball lines typed by the player still update the panel. + if (text.StartsWith("[Powerball]", StringComparison.OrdinalIgnoreCase)) + { + if (text.Contains("You bought", StringComparison.OrdinalIgnoreCase) || text.Contains("Insufficient", StringComparison.OrdinalIgnoreCase)) + _pbStatus = text; + return false; + } + string t = text.Trim(); + if (t.StartsWith("Draw #", StringComparison.OrdinalIgnoreCase) || t.StartsWith("Jackpot Pool", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("Ticket Price", StringComparison.OrdinalIgnoreCase)) + { + ParsePowerball(t); + return false; + } + + // Blackjack + var d = Dealt.Match(text); + if (d.Success) + { + var list = new List(_cards) { d.Groups["card"].Value }; + _cards = list.ToArray(); + _handActive = true; + return false; + } + var mv = MyValue.Match(text); + if (mv.Success) { _myValue = int.Parse(mv.Groups["v"].Value); _handActive = true; } + var dv = DealerValue.Match(text); + if (dv.Success) _dealerValue = int.Parse(dv.Groups["v"].Value); + if (text.StartsWith("The game begins!", StringComparison.OrdinalIgnoreCase)) _handActive = true; + + if (text.StartsWith("Blackjack! You win", StringComparison.OrdinalIgnoreCase) || text.StartsWith("You won with", StringComparison.OrdinalIgnoreCase) + || text.StartsWith("You tied with Rand", StringComparison.OrdinalIgnoreCase) || text.StartsWith("You lost with", StringComparison.OrdinalIgnoreCase) + || text.StartsWith("You busted", StringComparison.OrdinalIgnoreCase)) + _lastResult = text; + if (text.StartsWith("The blackjack game has ended", StringComparison.OrdinalIgnoreCase) + || text.StartsWith("You are not currently in a blackjack game", StringComparison.OrdinalIgnoreCase)) + _handActive = false; + if (text.StartsWith("You don't have enough luminance to place this bet", StringComparison.OrdinalIgnoreCase)) + { + _lastResult = text; + _handActive = false; + } + return false; + } + + public void OnLogout() + { + _handActive = false; + _cards = Array.Empty(); + } + + // ── UI (render thread) ────────────────────────────────────────────────── + + public void Render() + { + bool bj = _ctx.Options.IsOn(IltFeature.Blackjack), fbj = _ctx.Options.IsOn(IltFeature.FBlackjack); + if (!bj && !fbj && _ctx.Options.IsOff(IltFeature.Powerball)) + { + ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "No games are enabled on this server."); + return; + } + bool hud = _ctx.State.GamesHudVisible; + if (ImGui.Checkbox("Show hand HUD while playing", ref hud)) _ctx.State.GamesHudVisible = hud; + + if (bj && ImGui.CollapsingHeader("Blackjack", ImGuiTreeNodeFlags.DefaultOpen)) RenderBlackjack(false, ref _bjBetText); + if (fbj && ImGui.CollapsingHeader("Fellowship Blackjack", ImGuiTreeNodeFlags.DefaultOpen)) RenderBlackjack(true, ref _fbjBetText); + if (!bj && !fbj) ImGui.TextDisabled("Blackjack is not enabled on this server."); + if (!_ctx.Options.IsOff(IltFeature.Powerball) && ImGui.CollapsingHeader("Powerball", ImGuiTreeNodeFlags.DefaultOpen)) RenderPowerball(); + } + + private void RenderBlackjack(bool fellowship, ref string betText) + { + string id = fellowship ? "fbj" : "bj"; + if (betText.Length == 0) betText = IltParse.Compact(fellowship ? S.FellowshipBlackjackBet : S.BlackjackBet).ToLowerInvariant(); + ImGui.SetNextItemWidth(160); + ImGui.InputTextWithHint($"Bet (luminance)##{id}", "e.g. 1m, 500k", ref betText, 24u); + bool ok = IltParse.TryParseAmount(betText, out long bet) && (!fellowship || bet <= FBlackjackMaxBet); + ImGui.SameLine(); + ImGui.TextDisabled(ok ? IltParse.N0(bet) : fellowship ? "invalid (max 100B)" : "invalid"); + + ImGui.BeginDisabled(!ok || _handActive); + if (ImGui.Button($"Deal...##{id}")) + { + long b = bet; + if (fellowship) S.FellowshipBlackjackBet = b; else S.BlackjackBet = b; + _ctx.Confirm(fellowship ? "Fellowship Blackjack" : "Blackjack", + $"Bet {IltParse.N0(b)} banked luminance on a new hand?", () => StartBlackjack(fellowship, b), "Bet"); + } + ImGui.EndDisabled(); + + if (_handActive && _fellowshipHand == fellowship) RenderHandButtons(id); + if (_lastResult.Length > 0 && _fellowshipHand == fellowship) ImGui.TextWrapped(_lastResult); + } + + private void RenderHandButtons(string id) + { + ImGui.TextUnformatted($"Hand: {string.Join(", ", _cards)} ({_myValue}) Rand: {(_dealerValue > 0 ? _dealerValue.ToString() : "?")}"); + if (ImGui.Button($"Hit##{id}")) _ctx.Post(() => HandAction("hit")); + ImGui.SameLine(); + if (ImGui.Button($"Stand##{id}")) _ctx.Post(() => HandAction("stand")); + ImGui.SameLine(); + if (ImGui.Button($"Double...##{id}")) + _ctx.Confirm("Double down", "Double your bet on this hand?", () => HandAction("double"), "Double"); + ImGui.SameLine(); + if (ImGui.Button($"Split...##{id}")) + _ctx.Confirm("Split", "Split this hand (places a second bet)?", () => HandAction("split"), "Split"); + } + + private void RenderPowerball() + { + if (ImGui.SmallButton("Refresh##pb")) _ctx.Post(RequestPowerballInfo); + ImGui.SameLine(); + if (ImGui.SmallButton("My tickets")) _ctx.Post(() => Send("/pb tickets")); + if (_pbDraw.Length > 0) ImGui.TextUnformatted(_pbDraw); + if (_pbJackpot.Length > 0) ImGui.TextUnformatted(_pbJackpot); + if (_pbPrice.Length > 0) ImGui.TextUnformatted(_pbPrice); + // Buying spends banked luminance, so it needs a positive server confirmation of /pb. + if (!_ctx.Options.IsOn(IltFeature.Powerball)) + { + ImGui.TextDisabled("Ticket purchases unlock once the server confirms /pb (press Refresh)."); + if (_pbStatus.Length > 0) ImGui.TextWrapped(_pbStatus); + return; + } + int qty = S.PowerballQuantity; + ImGui.SetNextItemWidth(120); + if (ImGui.InputInt("Tickets", ref qty)) S.PowerballQuantity = Math.Clamp(qty, 1, 500); + ImGui.SameLine(); + if (ImGui.Button("Buy...")) + { + int q = S.PowerballQuantity; + _ctx.Confirm("Powerball", $"Buy {q} Powerball ticket(s)?\n{(_pbPrice.Length > 0 ? _pbPrice : "Tickets cost banked luminance.")}", + () => Send($"/pb buy {q}"), "Buy"); + } + if (_pbStatus.Length > 0) ImGui.TextWrapped(_pbStatus); + } + + /// Small HUD with the current hand; called every frame by the Hub UI. + public void RenderHud() + { + if (!_handActive || !_ctx.State.GamesHudVisible) return; + ImGui.SetNextWindowSize(new Vector2(300, 0), ImGuiCond.FirstUseEver); + bool open = true; + if (ImGui.Begin("Blackjack HUD##iltbjhud", ref open, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse)) + { + ImGui.TextColored(LegacyDashboardRenderer.ColAmber, _fellowshipHand ? "Fellowship Blackjack" : "Blackjack"); + RenderHandButtons("hud"); + } + ImGui.End(); + if (!open) _ctx.State.GamesHudVisible = false; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGear.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGear.cs new file mode 100644 index 0000000..9d2c15f --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGear.cs @@ -0,0 +1,65 @@ +// IltGear.cs — ILT Hub "Gear" tab: the gear tools. +// +// The sections are separate modules (buff keepers, chunk/clap, split arrows, equipment suits, +// VTank import) that this tab just lays out. The charm strip (registry charms and the Guardian +// Hand, with their toggles) is the Charms tab now (IltCharms). +using ImGuiNET; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltGear : IIltFeature +{ + public IltBuffKeepers Keepers { get; } + public IltChunkClap ChunkClap { get; } + public IltSplitArrows Split { get; } + public IltEquipSuits Suits { get; } + public IltUsdImporter Usd { get; } + + public IltGear(IltHubContext ctx) + { + Keepers = new IltBuffKeepers(ctx); + ChunkClap = new IltChunkClap(ctx); + Split = new IltSplitArrows(ctx); + Suits = new IltEquipSuits(ctx); + Usd = new IltUsdImporter(ctx); + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + Keepers.Tick(nowMs); + ChunkClap.Tick(nowMs); + Split.Tick(nowMs); + Suits.Tick(nowMs); + } + + public bool OnChat(string text) + { + bool eat = Keepers.OnChat(text); + eat |= ChunkClap.OnChat(text); + eat |= Split.OnChat(text); + eat |= Suits.OnChat(text); + return eat; + } + + public void OnLogout() + { + Keepers.OnLogout(); + ChunkClap.OnLogout(); + Split.OnLogout(); + Suits.OnLogout(); + } + + // ── UI (render thread) ────────────────────────────────────────────────── + + public void Render() + { + if (ImGui.CollapsingHeader("Dispel / Surging Strength", ImGuiTreeNodeFlags.DefaultOpen)) Keepers.Render(); + if (ImGui.CollapsingHeader("Chunking / Clap")) ChunkClap.Render(); + if (ImGui.CollapsingHeader("Split arrows")) Split.Render(); + if (ImGui.CollapsingHeader("Equipment suits")) Suits.Render(); + if (ImGui.CollapsingHeader("VirindiTank import")) Usd.Render(); + ImGui.TextDisabled("Charms and the Guardian Hand are on the Charms tab."); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardian.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardian.cs new file mode 100644 index 0000000..f7d9e1c --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardian.cs @@ -0,0 +1,571 @@ +// IltGuardian.cs - Temple of Enlightenment guardians (ILT Hub "Guardian" window). +// +// * Riddle translator: incoming "Guardian of ... tells you / says" lines (when chat auto-detect +// is on) and pasted text go through IltGuardianPhrasebook; the answer shows here and on the +// Mini Remote. +// * Hand-in: gives one of the answer item to the guardian (GiveObjectTo). For the Temple +// guardian, when none is carried and "buy missing" is on, it first buys one from the open or +// nearest vendor (VendorBuy). Runs as a small pump-thread state machine with timeouts; the +// client busy state is respected between steps. +// * Attribute tracker: IltTempleAttributes. +// +// Threading: OnChat / Tick / commands run on the pump thread; Render only reads volatile fields +// and posts actions through IltHubContext.Post. +using System; +using System.Linq; +using System.Numerics; +using ImGuiNET; +using RynthCore.Loot; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.RynthAi.Meta; +using RynthCore.Plugin.Shared; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltGuardian : IIltFeature +{ + /// The same guardian + answer from chat within this window is one prompt (tells repeat lines). + private const long DebounceMs = 2500; + private const long HandInTimeoutMs = 45_000; + private const long VendorOpenTimeoutMs = 10_000; + private const long BuyTimeoutMs = 10_000; + private const long ItemArriveTimeoutMs = 8_000; + private const long BusyRetryMs = 400; + private const int MaxGiveAttempts = 5; + /// How far (meters) to look for the guardian and a vendor. + private const double SearchRangeMeters = 60.0; + /// + /// PublicWeenieDesc BF_VENDOR. The world cache files vendors as creatures (Monster / Npc), never + /// AcObjectClass.Vendor, so vendors are recognised by this weenie flag. + /// + private const uint BfVendor = 0x200; + /// The Mini Remote shows the last answer for this long. + public static readonly TimeSpan AnswerShownFor = TimeSpan.FromMinutes(10); + + private enum Step { Idle, FindItem, OpenVendor, WaitVendor, Buy, WaitBuy, WaitItem, Give } + + private readonly IltHubContext _ctx; + private string _lastFingerprint = string.Empty; + private long _lastEmitAt; + + // Last prompt (written on the pump thread, read by the render thread). + private volatile string _lastLine = string.Empty; + private volatile string _lastAnswer = string.Empty; + private volatile string _lastNpc = string.Empty; + private long _lastAnswerTicksUtc; + private volatile string _handInStatus = "idle"; + + // Hand-in state machine (pump thread only). + private Step _step = Step.Idle; + private string _item = string.Empty; + private string _npc = string.Empty; + private bool _asked; + private long _startedAt; + private long _stepDeadline; + private long _nextStepAt; + private uint _vendorId; + private uint _buyRequest; + private int _giveAttempts; + + // Render-thread UI state. + private string _input = string.Empty; + + public IltGuardian(IltHubContext ctx, Func tracker, IltQuests quests) + { + _ctx = ctx; + Attributes = new IltTempleAttributes(ctx, tracker, quests); + } + + public IltTempleAttributes Attributes { get; } + + private IltGuardianState S => _ctx.State.Guardian; + + /// Last answer item ("" until a guardian prompt was translated). + public string LastAnswer => _lastAnswer; + /// Guardian the last answer goes to. + public string LastNpc => _lastNpc; + /// The hand-in sequence is running. + public bool HandInRunning => _step != Step.Idle; + public string HandInStatus => _handInStatus; + + /// Time since the last answer (MaxValue when there is none). + public TimeSpan LastAnswerAge + { + get + { + long t = System.Threading.Interlocked.Read(ref _lastAnswerTicksUtc); + return t == 0 ? TimeSpan.MaxValue : DateTime.UtcNow - new DateTime(t, DateTimeKind.Utc); + } + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + Attributes.Tick(nowMs); + StepHandIn(nowMs); + } + + public bool OnChat(string text) + { + if (!S.AutoDetectFromChat || !IltGuardianPhrasebook.LooksLikeIncomingGuardianLine(text)) return false; + _lastLine = text.Trim(); + string answer = IltGuardianPhrasebook.Translate(text); + if (!IltGuardianPhrasebook.IsAnswer(answer)) return false; + + string npc = IltGuardianPhrasebook.TurnInNpcFromLine(text); + long now = IltHubContext.NowMs; + string fingerprint = npc + "|" + answer; + if (fingerprint == _lastFingerprint && now - _lastEmitAt < DebounceMs) return false; + _lastFingerprint = fingerprint; + _lastEmitAt = now; + + SetAnswer(answer, npc); + _ctx.Chat($"[ILT Guardian] {npc} wants: {answer}"); + RynthLog.Write(LogCat.IltHub, $"[IltGuardian] chat answer '{answer}' for {npc}"); + if (S.AutoHandIn) StartHandIn(answer, npc, asked: false); + return false; // never hide the guardian's own lines + } + + public void OnLogout() + { + StopHandIn("stopped (logout)"); + Attributes.OnLogout(); + } + + private void SetAnswer(string answer, string npc) + { + _lastAnswer = answer; + _lastNpc = npc; + System.Threading.Interlocked.Exchange(ref _lastAnswerTicksUtc, DateTime.UtcNow.Ticks); + } + + /// Translates pasted text; a real answer becomes the current answer. Pump thread. + public string TranslateManual(string text) + { + string answer = IltGuardianPhrasebook.Translate(text); + if (!IltGuardianPhrasebook.IsAnswer(answer)) return answer; + string npc = IltGuardianPhrasebook.TurnInNpcFromInput(text); + _lastLine = text.Trim(); + SetAnswer(answer, npc); + return $"{answer} (give to {npc})"; + } + + // ── Hand-in ───────────────────────────────────────────────────────────── + + /// Starts giving to . Pump thread. + public string StartHandIn(string item, string npc, bool asked) + { + if (!IltGuardianPhrasebook.IsAnswer(item)) return "No answer to hand in yet."; + if (!_ctx.Host.HasGiveObjectTo) return SetStatus("can't give items: update the RynthCore engine (API v62+)."); + _item = item; + _npc = string.IsNullOrWhiteSpace(npc) ? IltGuardianPhrasebook.AttributeGuardian : npc; + _asked = asked; + _startedAt = IltHubContext.NowMs; + _nextStepAt = 0; + _vendorId = 0; + _buyRequest = 0; + _giveAttempts = 0; + _step = Step.FindItem; + RynthLog.Write(LogCat.IltHub, $"[IltGuardian] hand-in start: '{_item}' -> {_npc} ({(asked ? "asked" : "auto")})"); + return SetStatus($"handing {_item} to {_npc}..."); + } + + /// Stops a running hand-in. + public void StopHandIn(string why = "stopped") + { + if (_step == Step.Idle) return; + _step = Step.Idle; + SetStatus(why); + RynthLog.Write(LogCat.IltHub, $"[IltGuardian] hand-in {why}"); + } + + private string SetStatus(string text) + { + _handInStatus = text; + return text; + } + + private void Fail(string why) + { + _step = Step.Idle; + SetStatus("failed: " + why); + _ctx.Chat($"[ILT Guardian] Hand-in failed: {why}"); + RynthLog.Write(LogCat.IltHub, $"[IltGuardian] hand-in failed: {why}"); + } + + private void Next(Step step, long nowMs, long timeoutMs = 0) + { + _step = step; + _stepDeadline = timeoutMs > 0 ? nowMs + timeoutMs : 0; + } + + private void StepHandIn(long nowMs) + { + if (_step == Step.Idle || nowMs < _nextStepAt) return; + if (nowMs - _startedAt > HandInTimeoutMs) { Fail("timed out"); return; } + if (_stepDeadline != 0 && nowMs > _stepDeadline) { Fail(TimeoutText(_step)); return; } + + var host = _ctx.Host; + switch (_step) + { + case Step.FindItem: + if (FindHandInItem() != null) { Next(Step.Give, nowMs); break; } + if (!IsTempleGuardian(_npc) || !S.BuyMissingFromVendor) { LogItemNearMisses(); Fail($"no {_item} in your packs"); break; } + Next(Step.OpenVendor, nowMs); + break; + + case Step.OpenVendor: + { + if (!host.HasVendorTrade) { Fail($"no {_item} carried and vendor buying needs a newer RynthCore engine"); break; } + if (host.TryGetVendorInfo(out var open)) { _vendorId = open.VendorId; Next(Step.Buy, nowMs); break; } + var vendor = Nearest(IsVendor); + if (vendor == null) { LogVendorSearch(); Fail($"no {_item} carried and no vendor within {SearchRangeMeters:0} m"); break; } + RynthLog.Write(LogCat.IltHub, $"[IltGuardian] vendor for '{_item}': {vendor.Name} 0x{(uint)vendor.Id:X8}"); + SetStatus($"opening {vendor.Name} to buy {_item}..."); + host.UseFor(unchecked((uint)vendor.Id), "IltGuardian", $"buy {_item} for the Temple guardian", + _asked ? UseKind.Asked : UseKind.Auto); + Next(Step.WaitVendor, nowMs, VendorOpenTimeoutMs); + break; + } + + case Step.WaitVendor: + if (host.TryGetVendorInfo(out var info) && info.ItemCount > 0) { _vendorId = info.VendorId; Next(Step.Buy, nowMs); } + break; + + case Step.Buy: + { + if (!host.TryGetVendorInfo(out var v)) { Fail("the vendor closed"); break; } + if (v.TradeInFlight) { _nextStepAt = nowMs + BusyRetryMs; break; } + string want = NormalizeName(_item); + var match = host.GetVendorItems().FirstOrDefault(i => NormalizeName(i.Name) == want); + if (match == null) { Fail($"{v.Name} doesn't sell {_item}"); break; } + _buyRequest = host.VendorBuy(match.ObjectId, 1, v.VendorId); + if (_buyRequest == 0) + { + string why = host.TryGetVendorTradeStatus(out var st) && st.Message.Length > 0 ? st.Message : "refused"; + Fail($"couldn't buy {_item}: {why}"); + break; + } + SetStatus($"buying {_item} from {v.Name}..."); + Next(Step.WaitBuy, nowMs, BuyTimeoutMs); + break; + } + + case Step.WaitBuy: + if (!host.TryGetVendorTradeStatus(out var status) || status.RequestId != _buyRequest || !status.IsFinished) break; + if (!status.Succeeded) { Fail($"couldn't buy {_item}: {(status.Message.Length > 0 ? status.Message : status.Result.ToString())}"); break; } + Next(Step.WaitItem, nowMs, ItemArriveTimeoutMs); + break; + + case Step.WaitItem: + if (FindHandInItem() != null) Next(Step.Give, nowMs); + break; + + case Step.Give: + GiveStep(nowMs); + break; + } + } + + private void GiveStep(long nowMs) + { + if (_ctx.Inventory.IsBusy) + { + SetStatus("waiting for the client (busy)..."); + _nextStepAt = nowMs + BusyRetryMs; + return; + } + var item = FindHandInItem(); + if (item == null) { LogItemNearMisses(); Fail($"no {_item} in your packs"); return; } + var npc = Nearest(wo => wo.Name.Contains(_npc, StringComparison.OrdinalIgnoreCase)); + if (npc == null) { Fail($"{_npc} isn't nearby"); return; } + + int stack = _ctx.Inventory.StackSize(item); + bool ok = _ctx.Host.GiveObjectTo(unchecked((uint)item.Id), unchecked((uint)npc.Id), stack > 1 ? 1 : 0); + RynthLog.Write(LogCat.IltHub, $"[IltGuardian] give '{item.Name}' 0x{(uint)item.Id:X8} (stack {stack}) -> {npc.Name} 0x{(uint)npc.Id:X8}: {ok}"); + if (ok) + { + _step = Step.Idle; + SetStatus($"gave {item.Name} to {npc.Name}"); + _ctx.Chat($"[ILT Guardian] Gave {item.Name} to {npc.Name}."); + return; + } + if (++_giveAttempts >= MaxGiveAttempts) { Fail("the give was refused"); return; } + _nextStepAt = nowMs + BusyRetryMs; + } + + private static string TimeoutText(Step step) => step switch + { + Step.WaitVendor => "the vendor didn't open", + Step.WaitBuy => "the vendor didn't answer the purchase", + Step.WaitItem => "the bought item didn't arrive", + _ => "timed out", + }; + + private static bool IsTempleGuardian(string npc) => + npc.Contains(IltGuardianPhrasebook.TempleGuardian, StringComparison.OrdinalIgnoreCase); + + /// + /// A carried (not wielded) item named like the answer (case and spacing ignored). Reads AC's + /// live container contents: the cache's inventory set lags a purchase and also holds the open + /// vendor's stock, which can't be given. + /// + private WorldObject? FindHandInItem() + { + string want = NormalizeName(_item); + return CarriedItems().FirstOrDefault(wo => NormalizeName(wo.Name) == want && !_ctx.Inventory.IsEquipped(wo)); + } + + /// Live walk of the player's pack and side packs (falls back to the cache without the engine call). + private System.Collections.Generic.IReadOnlyList CarriedItems() + => _ctx.Inventory.Cache?.GetDirectInventory(forceRefresh: true) ?? Array.Empty(); + + /// Lower-case, trimmed, single-spaced name for comparisons. + private static string NormalizeName(string name) + => string.Join(' ', (name ?? string.Empty).Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries)).ToLowerInvariant(); + + /// Logs carried items sharing a word with the answer, so a name mismatch shows in the log. + private void LogItemNearMisses() + { + var items = CarriedItems(); + var words = NormalizeName(_item).Split(' ').Where(w => w.Length > 3).ToArray(); + var similar = items.Where(wo => words.Any(w => wo.Name.Contains(w, StringComparison.OrdinalIgnoreCase))) + .Take(8).Select(wo => $"'{wo.Name}' 0x{(uint)wo.Id:X8}").ToArray(); + RynthLog.Write(LogCat.IltHub, + $"[IltGuardian] no '{_item}' among {items.Count} carried items; similar names: {(similar.Length > 0 ? string.Join(", ", similar) : "none")}"); + } + + /// A vendor (weenie BF_VENDOR flag, or a cache entry already classed Vendor). + private bool IsVendor(WorldObject wo) + { + if (wo.ObjectClass == AcObjectClass.Vendor) return true; + var host = _ctx.Host; + return host.HasGetObjectBitfield && host.TryGetObjectBitfield(unchecked((uint)wo.Id), out uint bf) && (bf & BfVendor) != 0; + } + + /// Logs every vendor the cache sees with its distance (vendor search found none in range). + private void LogVendorSearch() + { + var cache = _ctx.Inventory.Cache; + int playerId = unchecked((int)_ctx.Inventory.PlayerId); + if (cache == null || playerId == 0) { RynthLog.Write(LogCat.IltHub, "[IltGuardian] vendor search: no world cache / player"); return; } + var landscape = cache.GetLandscapeObjects().ToList(); + var vendors = landscape.Where(IsVendor).Take(8) + .Select(wo => $"'{wo.Name}' 0x{(uint)wo.Id:X8} {cache.Distance(playerId, wo.Id):0.0} m").ToArray(); + RynthLog.Write(LogCat.IltHub, + $"[IltGuardian] vendor search: {landscape.Count} landscape objects, bitfield={(_ctx.Host.HasGetObjectBitfield ? "yes" : "no")}, " + + $"vendors: {(vendors.Length > 0 ? string.Join(", ", vendors) : "none")}"); + } + + /// Nearest landscape object matching within SearchRangeMeters. + private WorldObject? Nearest(Func match) + { + var cache = _ctx.Inventory.Cache; + int playerId = unchecked((int)_ctx.Inventory.PlayerId); + if (cache == null || playerId == 0) return null; + WorldObject? best = null; + double bestDist = SearchRangeMeters; + foreach (var wo in cache.GetLandscapeObjects()) + { + if (!match(wo)) continue; + double d = cache.Distance(playerId, wo.Id); + if (d <= bestDist) { bestDist = d; best = wo; } + } + return best; + } + + // ── Commands ──────────────────────────────────────────────────────────── + + /// + /// "/ra guardian translate <text>|handin|stop|chat on|off|auto on|off|buy on|off|refresh|status". + /// "window" is handled by the controller. Pump thread. + /// + public void HandleCommand(string[] args) + { + string sub = args.Length > 0 ? args[0].ToLowerInvariant() : "status"; + string rest = args.Length > 1 ? string.Join(" ", args.Skip(1)) : string.Empty; + switch (sub) + { + case "translate": + case "t": + _ctx.Chat("[ILT Guardian] " + TranslateManual(rest)); + break; + case "handin": + case "give": + _ctx.Chat("[ILT Guardian] " + StartHandIn(_lastAnswer, _lastNpc, asked: true)); + break; + case "stop": + StopHandIn(); + _ctx.Chat("[ILT Guardian] Hand-in stopped."); + break; + case "chat": + S.AutoDetectFromChat = Toggle(rest, S.AutoDetectFromChat); + _ctx.Chat($"[ILT Guardian] Chat auto-detect {(S.AutoDetectFromChat ? "on" : "off")}."); + break; + case "auto": + S.AutoHandIn = Toggle(rest, S.AutoHandIn); + _ctx.Chat($"[ILT Guardian] Auto hand-in {(S.AutoHandIn ? "on" : "off")}."); + break; + case "buy": + S.BuyMissingFromVendor = Toggle(rest, S.BuyMissingFromVendor); + _ctx.Chat($"[ILT Guardian] Buy missing Temple items {(S.BuyMissingFromVendor ? "on" : "off")}."); + break; + case "refresh": + _ctx.Chat("[ILT Guardian] " + Attributes.Refresh()); + break; + case "status": + _ctx.Chat($"[ILT Guardian] chat={(S.AutoDetectFromChat ? "on" : "off")} auto={(S.AutoHandIn ? "on" : "off")} buy={(S.BuyMissingFromVendor ? "on" : "off")} " + + $"answer={(_lastAnswer.Length > 0 ? $"{_lastAnswer} -> {_lastNpc}" : "-")} hand-in: {_handInStatus}"); + foreach (var r in Attributes.Snapshot) + _ctx.Chat($"[ILT Guardian] {r.Attribute,-12} {r.Npc,-16} #{r.Count} {r.Status} {r.Eta}"); + break; + default: + _ctx.Chat("[ILT Guardian] /ra guardian [window [show|hide]|translate |handin|stop|chat on|off|auto on|off|buy on|off|refresh|status]"); + break; + } + } + + private static bool Toggle(string mode, bool current) => mode.Trim().ToLowerInvariant() switch + { + "on" or "true" or "1" or "show" => true, + "off" or "false" or "0" or "hide" => false, + _ => !current, + }; + + // ── UI (render thread) ────────────────────────────────────────────────── + + /// Guardian window body. + public void Render() + { + if (ImGui.CollapsingHeader("Riddle translator", ImGuiTreeNodeFlags.DefaultOpen)) RenderTranslator(); + ImGui.Spacing(); + if (ImGui.CollapsingHeader("Attribute turn-ins", ImGuiTreeNodeFlags.DefaultOpen)) RenderTracker(); + } + + private void RenderTranslator() + { + var s = S; + // Plain bool writes; the pump thread reads them on its next tick. + bool chat = s.AutoDetectFromChat; + if (ImGui.Checkbox("Detect from chat##grdchat", ref chat)) s.AutoDetectFromChat = chat; + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Translate the guardians' tells as they arrive and show the answer here and on the Mini Remote."); + ImGui.SameLine(); + bool auto = s.AutoHandIn; + if (ImGui.Checkbox("Auto hand-in##grdauto", ref auto)) s.AutoHandIn = auto; + if (ImGui.IsItemHovered()) ImGui.SetTooltip("After a chat answer, give one of the item to the guardian automatically."); + ImGui.SameLine(); + bool buy = s.BuyMissingFromVendor; + if (ImGui.Checkbox("Buy if missing##grdbuy", ref buy)) s.BuyMissingFromVendor = buy; + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Temple guardian: when you carry none, buy one from the open or nearest vendor first."); + + string line = _lastLine; + if (line.Length > 0) + { + ImGui.TextDisabled("Heard:"); + ImGui.SameLine(); + ImGui.PushTextWrapPos(0f); + ImGui.TextDisabled(IltGuardianPhrasebook.MessageOf(line)); + ImGui.PopTextWrapPos(); + } + + string answer = _lastAnswer, npc = _lastNpc; + if (answer.Length > 0) + { + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, answer); + ImGui.SameLine(); + ImGui.TextDisabled("-> " + npc); + if (HandInRunning) + { + if (ImGui.SmallButton("Stop##grdstop")) _ctx.Post(() => StopHandIn()); + } + else if (ImGui.SmallButton("Hand in##grdgive")) + { + _ctx.Post(() => StartHandIn(answer, npc, asked: true)); + } + } + else ImGui.TextDisabled("No guardian answer yet."); + ImGui.TextDisabled("Hand-in: " + _handInStatus); + + ImGui.Spacing(); + ImGui.InputTextMultiline("##grdinput", ref _input, 2048u, new Vector2(-1, 54)); + if (ImGui.Button("Translate##grdtr")) + { + string text = _input; + _ctx.Post(() => _ctx.Chat("[ILT Guardian] " + TranslateManual(text))); + } + ImGui.SameLine(); + if (ImGui.Button("Clear##grdclr")) _input = string.Empty; + ImGui.SameLine(); + ImGui.TextDisabled("Paste a spell word or the riddle's question line."); + } + + private void RenderTracker() + { + if (ImGui.SmallButton("Refresh##grdref")) _ctx.Post(() => _ctx.Chat("[ILT Guardian] " + Attributes.Refresh())); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Re-read /myquests and /qb list (the server allows each once a minute)."); + ImGui.SameLine(); + DateTime synced = Attributes.SyncedUtc; + ImGui.TextDisabled(synced == DateTime.MinValue ? "/qb not read this session" : $"/qb read {synced.ToLocalTime():t}"); + ImGui.SameLine(); + if (ImGui.SmallButton("Reset counts##grdreset")) + _ctx.Confirm("Reset turn-in counts", "Forget the turn-in counts and cooldown estimates taken from /qb wait stamps? (/myquests counts are not affected.)", + Attributes.ResetCounts, "Reset"); + + var rows = Attributes.Snapshot; + if (rows.Length > 0 && ImGui.BeginTable("##grdattr", 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerH | ImGuiTableFlags.SizingStretchProp)) + { + ImGui.TableSetupColumn("Attribute", ImGuiTableColumnFlags.None, 1.0f); + ImGui.TableSetupColumn("NPC", ImGuiTableColumnFlags.None, 1.3f); + ImGui.TableSetupColumn("#", ImGuiTableColumnFlags.None, 0.35f); + ImGui.TableSetupColumn("Status", ImGuiTableColumnFlags.None, 0.9f); + ImGui.TableSetupColumn("Next", ImGuiTableColumnFlags.None, 1.5f); + ImGui.TableHeadersRow(); + foreach (var r in rows) + { + ImGui.TableNextRow(); + ImGui.TableNextColumn(); ImGui.TextUnformatted(r.Attribute); + ImGui.TableNextColumn(); ImGui.TextUnformatted(r.Npc); + ImGui.TableNextColumn(); ImGui.TextUnformatted(r.Count.ToString()); + ImGui.TableNextColumn(); + var col = r.Ready ? LegacyDashboardRenderer.ColGreen + : r.Status == "Unknown" ? LegacyDashboardRenderer.ColTextMute + : LegacyDashboardRenderer.ColAmber; + ImGui.TextColored(col, r.Status); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip(r.FromMyQuests ? "From /myquests (exact)." : "From /qb wait stamps (count and timer are estimates)."); + ImGui.TableNextColumn(); ImGui.TextUnformatted(r.Eta); + } + ImGui.EndTable(); + } + + int hours = S.CooldownHoursAssumed; + ImGui.SetNextItemWidth(140); + if (ImGui.SliderInt("Assumed cooldown (h)##grdhours", ref hours, 1, 72)) S.CooldownHoursAssumed = hours; + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Used only for rows /myquests doesn't report: how long a /qb wait stamp lasts."); + } + + /// + /// Mini Remote line: the last answer (for AnswerShownFor) with a Give / Stop button. + /// Draws nothing when there is no recent answer. Render thread. + /// + public void RenderRemoteLine() + { + string answer = _lastAnswer, npc = _lastNpc; + if (answer.Length == 0 || LastAnswerAge > AnswerShownFor) return; + ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "Guardian:"); + ImGui.SameLine(); + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, answer); + if (ImGui.IsItemHovered()) ImGui.SetTooltip($"Give to {npc}\nHand-in: {_handInStatus}"); + ImGui.SameLine(); + if (HandInRunning) + { + if (ImGui.SmallButton("Stop##mrgrd")) _ctx.Post(() => StopHandIn()); + } + else if (ImGui.SmallButton("Give##mrgrd")) + { + _ctx.Post(() => StartHandIn(answer, npc, asked: true)); + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardianPhrasebook.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardianPhrasebook.cs new file mode 100644 index 0000000..62491e8 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardianPhrasebook.cs @@ -0,0 +1,220 @@ +// IltGuardianPhrasebook.cs - Temple of Enlightenment spell words and Guardian of Attribute +// Enlightenment riddles mapped to the item each guardian wants (Infinite Leaftide). +// +// Pure functions only (no host calls), so the Guardian window may translate on the render thread. +// The riddle table matches on the closing question line; lead-in lines alone return "No match". +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal static class IltGuardianPhrasebook +{ + public const string TempleGuardian = "Guardian of the Temple of Enlightenment"; + public const string AttributeGuardian = "Guardian of Attribute Enlightenment"; + + /// Chat prefixes of an incoming guardian line ("tells you" or ACE's environmental "says"). + private static readonly string[] IncomingPrefixes = + { + TempleGuardian + " tells you", + AttributeGuardian + " tells you", + TempleGuardian + " says", + AttributeGuardian + " says", + }; + + /// Help text returned when nothing was pasted. + public const string PasteHint = "Paste a spell word or riddle text, then Translate."; + + /// Help text returned when the text didn't match any spell word or riddle. + public const string NoMatchHint = "No match: paste more lines from the guardian (especially the question line ending with ?)."; + + private static readonly Dictionary TempleSpells = new(StringComparer.OrdinalIgnoreCase) + { + { "Boquar", "Mugwort" }, { "Feazh", "Damiana" }, { "Kenrak", "Amaranth" }, + { "Puish", "Saffron" }, { "Shurov", "Comfrey" }, { "Volae", "Eyebright" }, + { "Cruath", "Ginseng" }, { "Helkas", "Wormwood" }, { "Malar", "Hyssop" }, + { "Quavosh", "Dragonsblood" }, { "Tugak", "Vervain" }, { "Yanoi", "Bistort" }, + { "Equin", "Mandrake" }, { "Jevak", "Myrrh" }, { "Ozhur", "Frankincense" }, + { "Roiga", "Yarrow" }, { "Uthoi", "Henbane" }, { "Zojak", "Hawthorn" }, + }; + + /// Spell words longest first so a short word never shadows a longer one. + private static readonly KeyValuePair[] TempleSpellsByLength = + TempleSpells.OrderByDescending(p => p.Key.Length).ToArray(); + + /// Normalized riddle phrases (longest first) and the item each answers. + private static readonly (string Needle, string Item)[] AttributeClues = BuildAttributeClues(); + + /// The same riddles split into meaningful words for the fuzzy fallback. + private static readonly (string Item, string[] Words)[] AttributeClueWords = + AttributeClues.Select(c => (c.Item, TokenizeMeaningfulWords(c.Needle))).ToArray(); + + private static (string, string)[] BuildAttributeClues() + { + var raw = new (string Phrase, string Item)[] + { + ("what stone of shadow wields such arm", "Powdered Onyx"), + ("what stone defends the mortal clay", "Powdered Agate"), + ("what heavy stone keeps adventurers healed", "Powdered Hematite"), + ("what heavy stone keeps adventure's healed", "Powdered Hematite"), + ("what honeyed stone bids pain to leave", "Powdered Amber"), + ("what draught unweaves that mages send", "Chorizite"), + ("what gem of life beats deep within", "Powdered Bloodstone"), + ("what ruddy gem calls vigor nigh", "Powdered Carnelian"), + ("what lunar gem gives peace to mind", "Powdered Moonstone"), + ("what verdant gem reveals the way", "Powdered Malachite"), + ("what crystal tunes the life it soothes", "Powdered Quartz"), + ("what gem of sky makes items nice", "Powdered Turquoise"), + ("what vial holds my burning scar", "Brimstone"), + ("which draught brings forth the fire's scent", "Turpeth"), + ("race the wind yet leave no trace", "Cadmia"), + ("grant the hand a dancer grace", "Cadmia"), + ("no wings I bear yet fleet I flee", "Cadmia"), + ("what draught awakens speed in thee", "Cadmia"), + ("what deaught awakens speed in thee", "Cadmia"), + ("what potion turns mana-use to one", "Cinnabar"), + ("what azure draught makes thunder weep", "Cobalt"), + ("what draught commands the winter's tide", "Colcothar"), + ("what pale draught prevents acid's writhe", "Gypsum"), + ("whate pale draught prevents acid's writhe", "Gypsum"), + ("what liquid turns heart grey between", "Quicksilver"), + ("what potion pierces the unseen end", "Realgar"), + ("what shadowed draught makes swiftness lie", "Stibnite"), + ("what verdant vial hides cuts unseen", "Verdigris"), + ("what potion shakes both flesh and floor", "Vitriol"), + ("what river wood trades life as art", "Alder Talisman"), + ("what wood enchants both bane and skill", "Ashwood Talisman"), + ("what pale wood casts the striker's bane", "Birch Talisman"), + ("what sacred stem keeps harm outside", "Cedar Talisman"), + ("what dark wood diminishes the foe's own tune", "Blackthorn Talisman"), + ("what hardwood charm makes others stand", "Ebony Talisman"), + ("what aged branch makes circles run", "Elder Talisman"), + ("what mystic bough binds here to yore", "Hazel Talisman"), + ("what poisoned branch brings creeping death", "Hemlock Talisman"), + ("what steadfast wood makes volleys rained", "Oak Talisman"), + ("what living wand makes allies mend", "Poplar Talisman"), + ("what sacred wood the self amends", "Rowan Talisman"), + ("what supple wood restores me here", "Willow Talisman"), + ("what ancient bough lets lifeblood grow", "Yew Talisman"), + }; + return raw.Select(t => (NormalizePhrase(t.Phrase), t.Item)) + .OrderByDescending(t => t.Item1.Length) + .ToArray(); + } + + /// Lowercase, curly apostrophes folded, punctuation collapsed to single spaces. + private static string NormalizePhrase(string s) + { + if (string.IsNullOrWhiteSpace(s)) return string.Empty; + string lower = s.Trim().ToLowerInvariant().Replace('\u2019', '\''); + var sb = new StringBuilder(lower.Length); + bool pendingSpace = false; + foreach (char c in lower) + { + bool wordCh = (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '\''; + if (!wordCh) { pendingSpace = true; continue; } + if (pendingSpace && sb.Length > 0) { sb.Append(' '); pendingSpace = false; } + sb.Append(c); + } + return sb.ToString().Trim(); + } + + /// Words of 3+ letters minus question / filler words. + private static string[] TokenizeMeaningfulWords(string normalized) => + normalized.Split(' ', StringSplitOptions.RemoveEmptyEntries) + .Where(w => w.Length >= 3 && w is not ("what" or "which" or "the" or "and" or "for")) + .ToArray(); + + /// + /// Typo-tolerant fallback: the riddle whose words overlap the input best, needing at least four + /// shared words and 72% of the riddle's words so a near-miss never maps to the wrong item. + /// + private static string? TryFuzzyAttributeMatch(string blob) + { + var inputWords = TokenizeMeaningfulWords(blob); + if (inputWords.Length == 0) return null; + var inputSet = new HashSet(inputWords, StringComparer.Ordinal); + string? bestItem = null; + double bestScore = 0d; + foreach (var (item, words) in AttributeClueWords) + { + if (words.Length == 0) continue; + int matches = words.Count(inputSet.Contains); + double score = (double)matches / words.Length; + if (matches >= 4 && score >= 0.72d && score > bestScore) + { + bestScore = score; + bestItem = item; + } + } + return bestItem; + } + + /// Resolves guardian text to an item name, or one of the help strings. + public static string Translate(string raw) + { + string blob = NormalizePhrase(raw); + if (blob.Length == 0) return PasteHint; + + var tokens = Regex.Split(blob, @"[^a-z0-9']+").Where(t => t.Length > 0).ToList(); + foreach (var pair in TempleSpellsByLength) + if (tokens.Any(t => t.Equals(pair.Key, StringComparison.OrdinalIgnoreCase))) + return pair.Value; + foreach (var pair in TempleSpellsByLength) + if (blob.Contains(pair.Key.ToLowerInvariant(), StringComparison.Ordinal)) + return pair.Value; + foreach (var (needle, item) in AttributeClues) + if (needle.Length > 0 && blob.Contains(needle, StringComparison.Ordinal)) + return item; + return TryFuzzyAttributeMatch(blob) ?? NoMatchHint; + } + + /// False for the help strings Translate returns when nothing matched. + public static bool IsAnswer(string translation) => + !string.IsNullOrWhiteSpace(translation) && translation != PasteHint && translation != NoMatchHint; + + /// True when the line starts like an incoming guardian tell / say. + public static bool LooksLikeIncomingGuardianLine(string raw) + { + if (string.IsNullOrWhiteSpace(raw)) return false; + string t = raw.TrimStart(); + foreach (string prefix in IncomingPrefixes) + if (t.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) + return true; + return false; + } + + /// The guardian to give the item to, read from an incoming line (Attribute when unclear). + public static string TurnInNpcFromLine(string raw) + { + if (!string.IsNullOrEmpty(raw) && raw.Contains(TempleGuardian, StringComparison.OrdinalIgnoreCase)) + return TempleGuardian; + return AttributeGuardian; + } + + /// + /// The guardian for manually pasted text: the name in a pasted chat line, else a Temple spell + /// word means the Temple guardian, else the Attribute guardian. + /// + public static string TurnInNpcFromInput(string raw) + { + if (string.IsNullOrWhiteSpace(raw)) return AttributeGuardian; + if (raw.Contains(TempleGuardian, StringComparison.OrdinalIgnoreCase)) return TempleGuardian; + if (raw.Contains(AttributeGuardian, StringComparison.OrdinalIgnoreCase)) return AttributeGuardian; + foreach (string word in TempleSpells.Keys) + if (raw.Contains(word, StringComparison.OrdinalIgnoreCase)) + return TempleGuardian; + return AttributeGuardian; + } + + /// The quoted message of a guardian line ("... tells you, \"text\"" → text); the line itself otherwise. + public static string MessageOf(string line) + { + int open = line.IndexOf('"'); + int close = line.LastIndexOf('"'); + return open >= 0 && close > open ? line.Substring(open + 1, close - open - 1).Trim() : line.Trim(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubContext.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubContext.cs new file mode 100644 index 0000000..a0f18ba --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubContext.cs @@ -0,0 +1,111 @@ +// IltHubContext.cs — Shared services handed to every ILT Hub feature. +// +// Threading contract: +// * Feature Tick / OnChat run on the plugin pump thread and may call the host freely. +// * Feature Render runs on the ImGui render thread and must NOT call AC actions directly. +// It calls Post(...) to run work on the next pump tick, or Confirm(...) to ask the +// player first (the confirmed action is then posted). This mirrors the existing +// DrainMetaCommands pattern in RynthAiPlugin. +using System; +using System.Collections.Concurrent; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +/// A yes/no question waiting for the player (a modal over the Mini Remote). +internal sealed class IltConfirmRequest +{ + public string Title = "Confirm"; + public string Message = string.Empty; + public string YesLabel = "Yes"; + /// Runs on the pump thread after the player clicks Yes. + public Action? OnYes; +} + +internal sealed class IltHubContext +{ + private readonly ConcurrentQueue _posted = new(); + private readonly ConcurrentQueue _confirms = new(); + private readonly Func _settings; + + public IltHubContext(RynthCoreHost host, IltHubState state, IltHubStore store, IltChatCapture capture, + IltServerOptions options, IltInventory inventory, Func settings) + { + Host = host; + State = state; + Store = store; + Capture = capture; + Options = options; + Inventory = inventory; + _settings = settings; + } + + public RynthCoreHost Host { get; } + public IltHubState State { get; } + public IltHubStore Store { get; } + public IltChatCapture Capture { get; } + public IltServerOptions Options { get; } + public IltInventory Inventory { get; } + + /// The live combat settings (rule lists the Pet picker / USD importer edit). Null before login. + public LegacyUiSettings? Settings => _settings(); + + /// Set by the controller when combat settings were edited and must be saved. + public Action? SaveCombatSettings; + + /// Logged-in character name (resolved at login). + public string CharName = string.Empty; + + /// True when the Mini Remote is on screen (features use it to gate auto-refreshes). + public bool WindowOpen => State.WindowVisible; + + /// + /// Shows the Mini Remote on one of its ILT tabs (set by the controller). Any thread: it only + /// records the tab and the show request, which the next frame applies. + /// + public Action? ShowTab; + + /// Writes a local chat line (never sent to the server). + public void Chat(string text) + { + if (Host.HasWriteToChat) Host.WriteToChat(text, 1); + } + + /// Queues work for the next pump tick (safe from the render thread). + public void Post(Action action) => _posted.Enqueue(action); + + /// Asks the player to confirm before runs on the pump thread. + public void Confirm(string title, string message, Action onYes, string yesLabel = "Yes") + => _confirms.Enqueue(new IltConfirmRequest { Title = title, Message = message, OnYes = onYes, YesLabel = yesLabel }); + + /// Render thread: takes the next pending confirmation, if any. + public bool TryTakeConfirm(out IltConfirmRequest request) => _confirms.TryDequeue(out request!); + + /// Pump thread: runs everything posted since the last tick. + public void DrainPosted() + { + int guard = 0; + while (guard++ < 64 && _posted.TryDequeue(out var a)) + { + try { a(); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "posted action"); } + } + } + + /// Elapsed-ms clock used for every Hub timer. + public static long NowMs => Environment.TickCount64; +} + +/// Contract every Hub feature module implements. +internal interface IIltFeature +{ + /// Pump-thread tick (~every plugin tick). + void Tick(long nowMs); + + /// Pump-thread chat line. Return true to hide the line from the chat window. + bool OnChat(string text); + + /// Logout / teardown: stop automation, drop transient state. + void OnLogout(); +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubController.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubController.cs new file mode 100644 index 0000000..e81fbd0 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubController.cs @@ -0,0 +1,612 @@ +// IltHubController.cs — Owns the ILT features behind the Mini Remote: state, services, feature +// modules, commands. +// +// RynthAiPlugin creates one controller per login session and forwards: +// OnTick → Tick() (pump thread) +// OnChatWindowText → OnChat() (pump thread; returns true to eat the line) +// OnRender → Render() (render thread: Games HUD, quest favorites HUD, confirmations) +// /ra hub ..., /ra quests ..., /ra guardian ... → HandleCommand() +// OnLogout / teardown → OnLogout() +// The ILT sections are Mini Remote tabs (RenderTab); the Guardian is RynthCore's ILT panel +// (RenderGuardianPanel), and bounties are the RynthILT plugin's (RynthCore's ILT button), so +// "/ra bounty" and "/ra guardian window" open those engine panels. +// The Quests and Pets tabs (and their features) are universal: every world. The ILT tabs only +// appear on ACECustom/ILT worlds where at least one server feature is on; on every other world +// the ILT features stay dormant (no probes, no chat, no tabs). +using System; +using System.Collections.Generic; +using System.Linq; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.RynthAi.Meta; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltHubController +{ + private const long SaveIntervalMs = 5000; + + private readonly IltHubContext _ctx; + private readonly IltHubUi _ui; + private readonly Func _quests; + private readonly List _features = new(); + private long _lastSaveAt; + private bool _questOutcomeHooked; + private bool _availabilityAnnounced; // "/ra hub to open" hint printed this session + + public IltBanking Banking { get; } + public IltPets Pets { get; } + public IltSessionRates Rates { get; } + public IltQuests Quests { get; } + public IltProgression Progression { get; } + public IltGear Gear { get; } + public IltGames Games { get; } + /// Registry charm acquired / active / server state (the Charms tab and RynthPluginGetCharmsJson). + public IltCharmTracker Charms { get; } + /// The Mini Remote's Charms tab (registry charms with toggles, the Guardian Hand). + public IltCharms CharmsTab { get; } + /// Temple guardians: riddle translator, hand-in, attribute turn-in tracker. + public IltGuardian Guardian { get; } + + public IltHubController(RynthCoreHost host, string charFolder, Func cache, + Func settings, Func quests, Action saveCombatSettings, + RynthCore.Plugin.Shared.SessionStatsTracker? sessionStats = null) + { + var store = new IltHubStore(host, charFolder); + var state = store.LoadState(); + var capture = new IltChatCapture(host); + var inventory = new IltInventory(host, cache); + IltHubContext? ctxRef = null; + var options = new IltServerOptions(host, capture, state, text => ctxRef?.Chat(text), settings); + // Settings > Misc shows whether the per-character Hub override is on too. + ServerFeatureGate.HubForceProvider = () => state.ForceLeaftideFeatures; + _ctx = new IltHubContext(host, state, store, capture, options, inventory, settings) { SaveCombatSettings = saveCombatSettings }; + ctxRef = _ctx; + _quests = quests; + + Banking = new IltBanking(_ctx); + Pets = new IltPets(_ctx); + Rates = new IltSessionRates(_ctx, sessionStats); + Quests = new IltQuests(_ctx, quests); + Progression = new IltProgression(_ctx); + Gear = new IltGear(_ctx); + Games = new IltGames(_ctx); + Charms = new IltCharmTracker(_ctx); + CharmsTab = new IltCharms(_ctx, Charms); + Guardian = new IltGuardian(_ctx, quests, Quests); + _features.AddRange(new IIltFeature[] { Banking, Pets, Rates, Quests, Progression, Gear, CharmsTab, Games, Guardian }); + + Banking.BalanceChanged += Rates.OnBankBalanceChanged; + Rates.MovingMoney = () => Banking.MovingMoney; + options.ProbeReplyTap = OnProbeReply; + _ui = new IltHubUi(this, _ctx); + _ctx.ShowTab = section => MiniRemoteTabCommand?.Invoke(IltSections.TabId(section), "show"); + } + + public IltHubState State => _ctx.State; + public IltServerOptions Options => _ctx.Options; + + /// + /// Shows / hides / toggles the Mini Remote ("show", "hide", "toggle"). Set by RynthAiPlugin; + /// returns the chat reply. Pump thread. + /// + public Func? MiniRemoteCommand { get; set; } + + /// + /// Puts the Mini Remote on a tab: (tab id from IltSections.TabId, "" = the remote itself; + /// mode "show" / "hide" / "toggle", or "select" to switch tabs without showing it). Set by + /// RynthAiPlugin; returns the chat reply. Any thread (plain field writes). + /// + public Func? MiniRemoteTabCommand { get; set; } + + /// True while the Mini Remote is on screen (set by RynthAiPlugin). + public Func? MiniRemoteVisible { get; set; } + + /// World is ILT-like and the server has at least one ILT feature on. + public bool Available => _ctx.Options.IsIltLikeWorld && _ctx.Options.AnyFeatureOn; + + /// + /// Whether a section can be shown now. The universal tabs (Quests, Pets) and Character always + /// can (Character explains why the ILT tabs are idle and holds the Force-ILT override); the + /// rest need server features. + /// + public bool SectionAvailable(IltSection section) => section switch + { + IltSection.Character => true, + IltSection.Quests or IltSection.Pet => true, + IltSection.Banking => Available && !_ctx.Options.IsOff(IltFeature.Bank), + IltSection.Games => Available && Games.AnyGameAvailable, + _ => Available, + }; + + /// + /// The Mini Remote offers the Infinite Leaftide tabs: an ILT-like world (or the Force-ILT + /// override). The Character tab then always shows; the others follow + /// . The universal tabs don't depend on this. + /// + public bool OffersTabs => _ctx.Options.IsIltLikeWorld; + + /// + /// Whether the Mini Remote's tab bar shows : a universal tab always, + /// an Infinite Leaftide tab on an ILT world once . + /// + public bool TabShown(IltSection section) => + IltSections.IsUniversal(section) || (OffersTabs && IltSections.IsTab(section) && SectionAvailable(section)); + + /// Render thread: one Mini Remote ILT tab's body (MiniRemoteHud draws the tab bar). + public void RenderTab(IltSection section) => _ui.RenderTab(section); + + /// Render thread: the Guardian panel's body (RynthPluginRenderEmbed "guardian"). + public void RenderGuardianPanel() => _ui.RenderGuardianPanel(); + + /// The Force-ILT world override (world identity only; features still come from the server). + public bool ForceIltWorld + { + get => _ctx.State.ForceLeaftideFeatures; + set => _ctx.State.ForceLeaftideFeatures = value; + } + + /// Re-asks the server which features are on (safe from the render thread: posted to the pump). + public void RequestOptionsRefresh() => _ctx.Post(() => _ctx.Options.Refresh(manual: true)); + + /// True when the cached options already say /myquests is off (skip the login refresh). + public bool SkipLoginQuestRefresh => _ctx.Options.IsIltLikeWorld && _ctx.Options.IsOff(IltFeature.Quests); + + // ── Lifecycle ─────────────────────────────────────────────────────────── + + /// Login: remember the character, hook PetManager, schedule the options check, import UB data once. + public void OnLoginComplete(string charName, PetManager? petManager) + { + _ctx.CharName = charName ?? string.Empty; + RynthLog.Event(LogEvents.IltLogin, $"login: char='{_ctx.CharName}' world='{_ctx.Options.WorldName}'"); + _ctx.Options.OnLoginComplete(); + _ctx.Inventory.Reset(); + Rates.Reset(); + + if (petManager != null) + { + petManager.AllowSummonOnEmpty = Pets.AllowSummonOnEmpty; + petManager.HoldSummons = Pets.HoldCombatSummons; + petManager.YieldPetForCombat = Pets.YieldPetForCombat; + } + + HookQuestOutcome(); + + if (!_ctx.State.UbSidecarsImported && _ctx.CharName.Length > 0) + { + _ctx.State.UbSidecarsImported = true; + string world = _ctx.Options.WorldName; + Banking.ImportUb(tx => _ctx.Store.ImportUbSidecars(_ctx.State, tx, world, _ctx.CharName)); + } + } + + private void HookQuestOutcome() + { + if (_questOutcomeHooked) return; + var t = _quests(); + if (t == null) return; + t.RefreshCompleted += () => _ctx.Options.NoteQuestTrackerOutcome(t.Disabled, t.Count); + _questOutcomeHooked = true; + } + + /// Pump-thread tick. + public void Tick() + { + long now = IltHubContext.NowMs; + _ctx.DrainPosted(); + _ctx.Capture.Tick(); + _ctx.Options.Tick(); + HookQuestOutcome(); + + // "Mini Remote on screen" gates bank auto-refresh and the gear / split-arrow scans. + _ctx.State.WindowVisible = MiniRemoteVisible?.Invoke() ?? false; + + // One hint per session once the server confirms ILT features. The Mini Remote is separate + // from the main RynthAi panel, so say how to open it. + if (!_availabilityAnnounced && Available) + { + _availabilityAnnounced = true; + if (!_ctx.State.WindowVisible) + _ctx.Chat("[Mini Remote] ILT server features detected. Open the Mini Remote (bar button, /rc miniremote) for the ILT tabs."); + } + + // The ILT features run only on ILT-like worlds; the universal ones (Quests, Pets) everywhere. + bool ilt = _ctx.Options.IsIltLikeWorld; + foreach (var f in _features) + { + if (!ilt && !IsUniversal(f)) continue; + try { f.Tick(now); } + catch (Exception ex) { RynthLog.Exception(CategoryOf(f), ex, $"{f.GetType().Name}.Tick"); } + } + + // Expire an unanswered chat confirmation so a stale "/ra hub confirm" can't fire it later. + if (_pendingAction != null && now - _pendingAt > ConfirmWindowMs) + { + RynthLog.Event(LogEvents.IltConfirmation, $"confirmation expired: {_pendingLabel}"); + _ctx.Chat($"[Mini Remote] Confirmation for '{_pendingLabel}' expired."); + ClearPending(); + } + + if (now - _lastSaveAt >= SaveIntervalMs) + { + _lastSaveAt = now; + _ctx.Store.SaveStateIfDirty(_ctx.State); + } + } + + /// Pump-thread chat line. Returns true when the line should be hidden. + public bool OnChat(string text) + { + if (string.IsNullOrEmpty(text)) return false; + string line = text.TrimEnd('\r', '\n'); + _ctx.Options.OnChatLine(line); + bool eat = _ctx.Capture.OnChatLine(line); + bool ilt = _ctx.Options.IsIltLikeWorld; + foreach (var f in _features) + { + if (!ilt && !IsUniversal(f)) continue; + try { eat |= f.OnChat(line); } + catch (Exception ex) { RynthLog.Exception(CategoryOf(f), ex, $"{f.GetType().Name}.OnChat"); } + } + return eat; + } + + /// The feature behind a universal tab (Quests, Pets): it runs on every world. + private static bool IsUniversal(IIltFeature f) => f is IltQuests or IltPets; + + /// Maps a feature module to its diagnostics category so its trace/exception lines land in its own file. + private static LogCat CategoryOf(IIltFeature f) => f switch + { + IltBanking => LogCat.IltBanking, + IltPets => LogCat.IltPets, + IltSessionRates => LogCat.IltRates, + IltQuests => LogCat.IltQuests, + IltProgression => LogCat.IltProgression, + IltGear or IltCharms => LogCat.IltGear, + IltGames => LogCat.IltGames, + _ => LogCat.IltHub, + }; + + /// Logout / teardown: stop automation and flush to disk. + public void OnLogout() + { + RynthLog.Event(LogEvents.IltLogout, $"logout: stopping features for '{_ctx.CharName}'"); + ClearPending(); + foreach (var f in _features) + { + try { f.OnLogout(); } + catch (Exception ex) { RynthLog.Exception(CategoryOf(f), ex, $"{f.GetType().Name}.OnLogout"); } + } + _ctx.Capture.Clear(); + _ctx.Store.SaveStateIfDirty(_ctx.State); + } + + /// + /// JSON for the engine Skills panel's Progression tab (RynthPluginGetProgressionJson). + /// "available" is false off ILT-like worlds; the panel then hides the ILT sections. Pump thread. + /// + public string BuildProgressionJson() + { + var sb = new System.Text.StringBuilder(2048); + sb.Append("{\"available\":").Append(Available ? "true" : "false"); + sb.Append(",\"world\":\"").Append(RynthAiPlugin.JsonEscape(_ctx.Options.WorldName ?? string.Empty)).Append("\","); + Progression.AppendSnapshotJson(sb); + sb.Append('}'); + return sb.ToString(); + } + + /// JSON for RynthPluginGetCharmsJson (an older engine's Settings "Charms Tracking" tab). Pump thread. + public string BuildCharmsJson() => Charms.BuildJson(); + + /// Render thread: Games HUD, quest favorites HUD and confirmation popups. + public void Render() => _ui.Render(); + + // ── Probe taps: reuse login-probe replies so tabs fill without extra commands ── + + private void OnProbeReply(string key, IltChatResult r) + { + if (r.Lines.Count == 0) return; + switch (key) + { + case IltFeature.Aug: Progression.ApplyAugLines(r.Lines); break; + case IltFeature.Pets: Pets.ApplyRoster(false, r.Lines); break; + case IltFeature.Shinies: Pets.ApplyRoster(true, r.Lines); break; + case IltFeature.Qb: Quests.ApplyQbProbe(r.Lines); break; + // Bank lines are parsed passively by IltBanking.OnChat as they arrive. + } + } + + // ── Commands ──────────────────────────────────────────────────────────── + + /// + /// "/ra hub [show|hide|toggle|open <section> [show|hide|toggle]|tab <section|remote>|refresh| + /// bank|status|force on|off|profile save|load|list ...|suit list|test|load ...]" (show/hide/toggle + /// drive the Mini Remote, open puts it on a tab, tab switches tabs without showing it), + /// "/ra quests [refresh|check <regex>|window|favhud]", "/ra pets [show|hide|toggle]", + /// "/ra bounty [show|hide|toggle]" (aliases bounties / bountys: RynthCore's ILT Bounties panel) + /// and "/ra guardian ..." (window: RynthCore's ILT Guardian panel; the rest IltGuardian.HandleCommand). + /// Pump thread. Returns false if not handled. + /// + public bool HandleCommand(string verb, string[] args) + { + RynthLog.Event(LogEvents.IltCommand, $"command: /ra {verb} {string.Join(" ", args)}".TrimEnd()); + if (verb.Equals("quests", StringComparison.OrdinalIgnoreCase)) + { + string sub = args.Length > 0 ? args[0].ToLowerInvariant() : "refresh"; + string mode = args.Length > 1 ? args[1].ToLowerInvariant() : "toggle"; + var cs = _ctx.State.Character; + switch (sub) + { + case "check" when args.Length > 1: + Quests.CheckCommand(string.Join(" ", args.Skip(1))); + break; + case "window": + OpenSection(IltSection.Quests, mode); + break; + case "favhud": + case "favorites": + cs.ShowQuestFavoritesHud = ResolveToggle(mode, cs.ShowQuestFavoritesHud); + _ctx.Chat(cs.ShowQuestFavoritesHud ? "[Mini Remote] Quest favorites HUD shown." : "[Mini Remote] Quest favorites HUD hidden."); + break; + default: + _ctx.Chat("[Mini Remote] " + Quests.RefreshQuests()); + break; + } + return true; + } + if (verb.Equals("pets", StringComparison.OrdinalIgnoreCase)) + { + // "/ra pets [show|hide|toggle]": same as "/ra hub open pets". + OpenSection(IltSection.Pet, args.Length > 0 ? args[0] : "toggle"); + return true; + } + if (IsBountyVerb(verb)) + { + // Bounties are the RynthILT plugin's (RynthCore's ILT button); open that panel. + OpenEnginePanel("bounties", "Bounties", args.Length > 0 ? args[0] : "toggle"); + return true; + } + if (verb.Equals("guardian", StringComparison.OrdinalIgnoreCase)) + { + // "/ra guardian window [show|hide|toggle]" opens RynthCore's ILT Guardian panel; + // everything else is the Guardian's. + if (args.Length > 0 && args[0].Equals("window", StringComparison.OrdinalIgnoreCase)) + OpenEnginePanel("guardian", "Guardian", args.Length > 1 ? args[1] : "toggle"); + else + Guardian.HandleCommand(args); + return true; + } + if (!verb.Equals("hub", StringComparison.OrdinalIgnoreCase)) return false; + + string cmd = args.Length > 0 ? args[0].ToLowerInvariant() : "toggle"; + string rest = args.Length > 1 ? string.Join(" ", args.Skip(1)) : string.Empty; + switch (cmd) + { + case "show": + case "hide": + case "toggle": + // The Mini Remote is the Hub's main window. + if (MiniRemoteCommand != null) _ctx.Chat(MiniRemoteCommand(cmd)); + else _ctx.Chat("[Mini Remote] The Mini Remote is not available yet."); + break; + case "open": + if (args.Length > 1 && IsBountyVerb(args[1])) + { + OpenEnginePanel("bounties", "Bounties", args.Length > 2 ? args[2] : "toggle"); + break; + } + if (args.Length < 2 || !IltSections.TryParse(args[1], out IltSection section)) + { + _ctx.Chat("[Mini Remote] Usage: /ra hub open character|quests|pets|banking|gear|charms|games|guardian|bounties [show|hide|toggle]"); + break; + } + OpenSection(section, args.Length > 2 ? args[2] : "toggle"); + break; + case "tab": + // The engine's dashboard: it opens its Mini Remote window itself, so only switch tabs. + if (args.Length > 1 && IltSections.TryParse(args[1], out IltSection tab) && IltSections.IsTab(tab)) + MiniRemoteTabCommand?.Invoke(IltSections.TabId(tab), "select"); + else + MiniRemoteTabCommand?.Invoke(IltSections.RemoteTab, "select"); + break; + case "refresh": _ctx.Options.Refresh(manual: true); break; + case "bank": Banking.RequestRefresh(quiet: false); break; + case "status": PrintStatus(); break; + case "force": + _ctx.State.ForceLeaftideFeatures = !rest.Equals("off", StringComparison.OrdinalIgnoreCase); + _ctx.Chat($"[Mini Remote] Force ILT world: {(_ctx.State.ForceLeaftideFeatures ? "on" : "off")}. Use /ra hub refresh to re-check the server."); + break; + case "profile": HandleProfile(args.Skip(1).ToArray()); break; + case "suit": HandleSuit(args.Skip(1).ToArray()); break; + case "clap": Gear.ChunkClap.ClapNow(manual: true); break; + case "attr": HandleAttr(args.Skip(1).ToArray()); break; + case "confirm": RunPending(); break; + case "cancel": + _ctx.Chat(_pendingAction != null ? $"[Mini Remote] Cancelled '{_pendingLabel}'." : "[Mini Remote] Nothing to cancel."); + ClearPending(); + break; + default: + _ctx.Chat("[Mini Remote] /ra hub [show|hide|toggle] (Mini Remote)|refresh|bank|status|force on|off|clap|confirm|cancel"); + _ctx.Chat("[Mini Remote] /ra hub open character|quests|pets|banking|gear|charms|games [show|hide|toggle] (Mini Remote tabs)"); + _ctx.Chat("[Mini Remote] /ra hub profile list|save [shared]|load /ra hub suit list|test|load [name]"); + _ctx.Chat("[Mini Remote] /ra hub attr run|stop|costs|status|auto on|off|every |raise (Skills panel > Progression)"); + _ctx.Chat("[Mini Remote] /ra quests [refresh|check |window [show|hide]|favhud [show|hide]] /ra pets [show|hide]"); + _ctx.Chat("[Mini Remote] /ra guardian [window|translate |handin|stop|chat on|off|auto on|off|buy on|off|refresh|status] (window: ILT button > Guardian)"); + _ctx.Chat("[Mini Remote] /ra bounty [show|hide|toggle] (RynthCore's ILT button > Bounties, /rc bounties)"); + break; + } + return true; + } + + /// "/ra hub attr ...": the attribute raiser from chat (same verbs as the Progression tab). + private void HandleAttr(string[] a) + { + var raiser = Progression.Attributes; + string sub = a.Length > 0 ? a[0].ToLowerInvariant() : "status"; + switch (sub) + { + case "run": raiser.HandleRemote("attrrun", new[] { "attrrun" }); break; + case "stop": raiser.HandleRemote("attrstop", new[] { "attrstop" }); break; + case "costs": raiser.HandleRemote("attrcosts", new[] { "attrcosts" }); break; + case "auto": raiser.HandleRemote("attrauto", new[] { "attrauto", a.Length > 1 ? a[1] : "off" }); break; + case "every": raiser.HandleRemote("attrevery", new[] { "attrevery", a.Length > 1 ? a[1] : "5" }); break; + case "raise" when a.Length > 2: raiser.HandleRemote("attrraise", new[] { "attrraise", a[1], a[2] }); break; + default: + var c = _ctx.State.Character; + string blocked = raiser.Blocker() ?? "ready"; + _ctx.Chat($"[Mini Remote] Attribute raiser: {blocked}; auto={(c.AttrAutoRaise ? $"on every {c.AttrAutoRaiseMinutes}m" : "off")} " + + $"mode={(IltAttributeRaiser.Mode)c.AttrRaiseMode} keep={IltParse.Compact(c.AttrKeepXp)} " + + $"stats={(c.AttrRaiseStats.Count > 0 ? string.Join(",", c.AttrOrder.Where(c.AttrRaiseStats.Contains)) : "none ticked")}"); + return; + } + } + + /// "/ra bounty", "/ra bounties" and the "/ra bountys" spelling all reach the Bounties panel. + public static bool IsBountyVerb(string verb) + => verb.Equals("bounty", StringComparison.OrdinalIgnoreCase) + || verb.Equals("bounties", StringComparison.OrdinalIgnoreCase) + || verb.Equals("bountys", StringComparison.OrdinalIgnoreCase); + + /// + /// Applies show / hide / toggle to a section: a Mini Remote tab, or for the Guardian + /// RynthCore's ILT panel. Says what happened. + /// + private void OpenSection(IltSection section, string mode) + { + if (!IltSections.IsTab(section)) + { + OpenEnginePanel(IltSections.TabId(section), IltSections.Label(section), mode); + return; + } + string reply = MiniRemoteTabCommand?.Invoke(IltSections.TabId(section), mode) ?? "The Mini Remote is not available yet."; + if (!SectionAvailable(section) && !mode.Equals("hide", StringComparison.OrdinalIgnoreCase)) + reply = $"The {IltSections.Label(section)} tab shows once the server reports that feature on."; + _ctx.Chat("[Mini Remote] " + reply); + } + + /// + /// Opens / closes one of RynthCore's ILT panels ("/rc bounties|guardian [show|hide|toggle]") + /// through the engine's chat dispatcher. Pump thread. + /// + public void OpenEnginePanel(string rcVerb, string label, string mode) + { + string m = (mode ?? string.Empty).ToLowerInvariant() switch + { + "show" or "on" or "open" => "show", + "hide" or "off" or "close" => "hide", + _ => "toggle", + }; + if (_ctx.Host.HasInvokeChatParser && _ctx.Host.InvokeChatParser($"/rc {rcVerb} {m}")) + return; + _ctx.Chat($"[Mini Remote] {label} is a RynthCore ILT panel: the bar's ILT button, or /rc {rcVerb}."); + } + + /// "show"/"on" → true, "hide"/"off" → false, anything else flips . + private static bool ResolveToggle(string mode, bool current) => mode switch + { + "show" or "on" or "true" or "1" => true, + "hide" or "off" or "false" or "0" => false, + _ => !current, + }; + + private void PrintStatus() + { + var o = _ctx.Options; + _ctx.Chat($"[Mini Remote] World '{o.WorldName}' ILT={o.IsIltLikeWorld} force={_ctx.State.ForceLeaftideFeatures} source={(o.Source.Length > 0 ? o.Source : "none")} " + + $"refreshed={(o.LastRefreshUtc == DateTime.MinValue ? "never" : o.LastRefreshUtc.ToLocalTime().ToString("t"))}"); + var bits = o.SnapshotBits(); + string on = string.Join(", ", bits.Where(b => b.Value == 1).Select(b => b.Key)); + string off = string.Join(", ", bits.Where(b => b.Value == 0).Select(b => b.Key)); + _ctx.Chat("[Mini Remote] on: " + (on.Length > 0 ? on : "-")); + _ctx.Chat("[Mini Remote] off: " + (off.Length > 0 ? off : "-")); + } + + private void HandleProfile(string[] a) + { + string sub = a.Length > 0 ? a[0].ToLowerInvariant() : "list"; + if (sub == "list") + { + var names = _ctx.Store.ListProfiles(); + _ctx.Chat("[Mini Remote] Profiles: " + (names.Count > 0 ? string.Join(", ", names) : "(none)")); + return; + } + if (a.Length < 2) { _ctx.Chat("[Mini Remote] Usage: /ra hub profile save [shared] | load "); return; } + if (sub == "save") + { + bool shared = a.Length > 2 && a[2].Equals("shared", StringComparison.OrdinalIgnoreCase); + _ctx.Chat(_ctx.Store.SaveProfile(_ctx.State, a[1], shared, out string err) + ? $"[Mini Remote] Saved {(shared ? "shared " : "")}profile '{a[1]}'." : "[Mini Remote] Save failed: " + err); + } + else if (sub == "load") + { + // Loading replaces the Hub's current settings, so it needs an explicit confirm. + string profile = a[1]; + RequestConfirm($"load Hub profile '{profile}' (replaces current Hub settings)", () => + _ctx.Chat(_ctx.Store.LoadProfile(_ctx.State, profile, out string err) + ? $"[Mini Remote] Loaded profile '{profile}'." : "[Mini Remote] Load failed: " + err)); + } + } + + // ── Chat confirmations for destructive commands ───────────────────────── + + /// How long a "/ra hub confirm" stays valid after the prompt. + private const long ConfirmWindowMs = 20000; + + private string? _pendingLabel; + private Action? _pendingAction; + private long _pendingAt; + + /// Arms a single pending action; a newer request replaces an older one. + private void RequestConfirm(string label, Action action) + { + _pendingLabel = label; + _pendingAction = action; + _pendingAt = IltHubContext.NowMs; + RynthLog.Event(LogEvents.IltConfirmation, $"confirmation requested: {label}"); + _ctx.Chat($"[Mini Remote] About to {label}. Type /ra hub confirm within {ConfirmWindowMs / 1000} s, or /ra hub cancel."); + } + + /// Runs the pending action if one is armed and still inside its window. + private void RunPending() + { + var action = _pendingAction; + string? label = _pendingLabel; + bool fresh = action != null && IltHubContext.NowMs - _pendingAt <= ConfirmWindowMs; + ClearPending(); + if (!fresh || action == null) { _ctx.Chat("[Mini Remote] Nothing to confirm."); return; } + + RynthLog.Event(LogEvents.IltConfirmation, $"confirmed: {label}"); + try { action(); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, $"confirmed action '{label}'"); } + } + + private void ClearPending() + { + _pendingAction = null; + _pendingLabel = null; + _pendingAt = 0; + } + + private void HandleSuit(string[] a) + { + string sub = a.Length > 0 ? a[0].ToLowerInvariant() : "list"; + string? name = a.Length > 1 ? string.Join(" ", a.Skip(1)) : null; + switch (sub) + { + case "list": + var list = Gear.Suits.ListProfiles(); + _ctx.Chat("[Mini Remote] Suits: " + (list.Count > 0 ? string.Join(", ", list.Select(p => p.Name)) : "(none)")); + break; + case "test": + foreach (string l in Gear.Suits.Test(name)) _ctx.Chat("[Mini Remote] " + l); + break; + case "load": + // Equipping a suit swaps gear mid-session, so it needs an explicit confirm. + RequestConfirm($"equip suit '{name ?? "(auto)"}'", () => _ctx.Chat("[Mini Remote] " + Gear.Suits.Load(name))); + break; + default: + _ctx.Chat("[Mini Remote] Usage: /ra hub suit list|test [name]|load [name]"); + break; + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubState.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubState.cs new file mode 100644 index 0000000..82581e2 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubState.cs @@ -0,0 +1,292 @@ +// IltHubState.cs — Persisted per-character state for the ILT Hub (Infinite Leaftide tools). +// +// Lives in \ilt-hub.json, deliberately separate from the combat settings +// profile (Default.json / /ra settings) so ILT data never leaks into combat profiles and +// non-ILT characters stay untouched. Serialized with the NativeAOT source-generated +// RynthAiJsonContext (IncludeFields = true), so plain public fields are used throughout. +using System; +using System.Collections.Generic; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +/// Root of everything the Hub remembers between sessions. +public sealed class IltHubState +{ + /// Bumped when the shape changes in a way that needs a migration. + public int SchemaVersion = 1; + + // ── Window / shell ────────────────────────────────────────────────────── + /// + /// Hub UI on screen: the Mini Remote or any ILT section window (IltHubController.Tick keeps it + /// current). Bank auto-refresh and the gear / split-arrow scans run only while it is true. + /// + public bool WindowVisible; + /// Unused since the tabbed Hub window was retired; kept so old files still load. + public int SelectedTab; + public bool GamesHudVisible = true; + + /// + /// "This world is an ACECustom/ILT shard even though its name isn't InfiniteLeaftide." + /// World-identity override ONLY: it makes the Hub ask the server for its options, it + /// never turns a feature on by itself. + /// + public bool ForceLeaftideFeatures; + + /// True once the one-time UtilityBelt sidecar import has run for this character. + public bool UbSidecarsImported; + + /// Last-seen server feature bits. Cache only — overwritten by every login refresh. + public IltServerOptionsSnapshot ServerOptions = new(); + + public IltBankState Bank = new(); + public IltPetState Pet = new(); + public IltCharacterState Character = new(); + public IltGearState Gear = new(); + public IltGamesState Games = new(); + public IltGuardianState Guardian = new(); +} + +/// Cached result of the server-options check (see IltServerOptions). +public sealed class IltServerOptionsSnapshot +{ + public string WorldName = string.Empty; + /// "ilt-features" (structured dump), "probe" (command probing) or "" (never refreshed). + public string Source = string.Empty; + public DateTime LastRefreshUtc = DateTime.MinValue; + /// Feature key → -1 unknown, 0 off, 1 on. + public Dictionary Bits = new(StringComparer.OrdinalIgnoreCase); +} + +// ── Banking ───────────────────────────────────────────────────────────────── + +public sealed class IltBankState +{ + public long Pyreals; + public long Luminance; + public long LegendaryKeys; + public long MythicalKeys; + public long EnlightenedCoins; + public long WeaklyEnlightenedCoins; + /// Bound to the character: deposit and withdraw only, never transferred. + public long PrestigeCoins; + public DateTime LastUpdated = DateTime.MinValue; + + /// Last transfer recipient typed into the transfer form. + public string TransferTarget = string.Empty; + public int TransferCurrencyIndex; + + /// Deposit / withdraw form choices (IltBankCommands.Deposits / Withdrawals / NoteDenominations). + public int DepositIndex; + public int WithdrawIndex; + public int WithdrawNoteIndex = 9; + + /// Re-issue /bank every N seconds while the Hub is open (0 = manual only). + public int AutoRefreshSeconds = 120; +} + +/// One "Transferred …" / "Received …" bank line seen in chat. +public sealed class IltBankTransaction +{ + public DateTime Timestamp; + /// "Sent" or "Received". + public string Type = string.Empty; + public string Currency = string.Empty; + public long Amount; + public string OtherPlayer = string.Empty; + public string Description = string.Empty; +} + +// ── Pet ───────────────────────────────────────────────────────────────────── + +public sealed class IltPetState +{ + // Healing-pet automation (UB "HealingBuddy" subset). + public bool HealingEnabled; + /// Exact name of the heal-pet essence to use; empty = auto-detect (Healing Buddy / Dule box). + public string HealPetName = string.Empty; + public int HealthThresholdPercent = 80; + /// Do not summon when current HP is below this (summoning mid-death wastes the use). 0 = off. + public int MinHealthPoints = 100; + public bool AutoDespawnAfterHeal = true; + public int RespawnDelaySeconds = 2; + public int PetTimeoutSeconds = 30; + + /// + /// Allow a combat summon from an EMPTY essence when the Summon Essence Refill Charm is + /// active (server refills from banked pyreals). Still requires the server flag to be on. + /// + public bool UsePyrealRefillPath; + + /// Last captured /pets and /shinies rosters (display only). + public List PetLog = new(); + public List ShinyLog = new(); + + // ── Pet roster (UB Pets-tab style) ── + /// Roster type shown in the Pet tab (IltPetKind: 0 Combat, 1 Healing, 2 Cosmetic). + public int RosterKind; + /// Roster sort (IltPetSort: 0 Priority, 1 Bond, 2 Potency, 3 Breed ready, 4 Level, 5 Uses, 6 Name). + public int RosterSort; + /// User type overrides by essence name; essences not listed are auto-classified. + public List Assignments = new(); + + /// Essence name of the chosen cosmetic (display) pet; empty = none. + public string CosmeticPetName = string.Empty; + /// Keep the cosmetic pet summoned while in peace mode; it is dismissed when a combat pet is needed. + public bool KeepCosmeticOut; + /// Seconds to wait before re-summoning the cosmetic pet after it despawns. + public int CosmeticRespawnSeconds = 15; +} + +/// A user's choice of summon type for one essence (matched by name, case-insensitive). +public sealed class IltPetAssignment +{ + public string Name = string.Empty; + /// IltPetKind as int (0 Combat, 1 Healing, 2 Cosmetic). + public int Kind; +} + +// ── Character ─────────────────────────────────────────────────────────────── + +public sealed class IltCharacterState +{ + /// Item → coin conversion table used by the session-rates strip. + public List ItemConversions = new() + { + new IltItemConversion { ItemName = "Strawberry Jam Jar", ItemsPerConversion = 100, CoinsPerConversion = 10 }, + new IltItemConversion { ItemName = "Ancient Pyreal", ItemsPerConversion = 100, CoinsPerConversion = 37 }, + }; + + /// Augmentation planner targets, keyed by aug type (lowercase). + public Dictionary AugTargets = new(StringComparer.OrdinalIgnoreCase); + /// Luminance price of one Enlightened Coin (planner math only; 0 = don't price coins). + public long LumPerEnlightenedCoin; + + /// Enlightenment planner target level (0 = current + 5). + public int EnlTargetLevel; + public int EnlightenedCoinsPerToken = 20; + /// + /// Auto-enlighten preference. Even when true it stays DISARMED each session until the + /// player confirms in the Hub, and the server's own Yes/No dialog is never auto-clicked. + /// + public bool AutoEnlightenEnabled; + public int AutoEnlightenCheckSeconds = 30; + /// Spend unassigned XP with /attr before sending /enl (enlightening wipes unspent XP). + public bool AutoEnlightenSpendXpFirst; + + // ── Attribute raiser (IltAttributeRaiser; Skills panel > Progression) ── + /// Spend unassigned XP on the ticked attributes/vitals every AttrAutoRaiseMinutes. + public bool AttrAutoRaise; + public int AttrAutoRaiseMinutes = 5; + /// IltAttributeRaiser.Mode: 0 priority (top of the order first), 1 round robin, 2 cheapest first. + public int AttrRaiseMode; + /// Unassigned XP the raiser never spends. + public long AttrKeepXp; + /// /attr abbreviations in raise-priority order (all nine; repaired on load). + public List AttrOrder = new(IltAttributeRaiser.DefaultOrder); + /// /attr abbreviations the raiser may spend on ("Raise now" and auto-raise). + public List AttrRaiseStats = new(); + + /// Quest Tracker search box contents. + public string QuestFilter = string.Empty; + public string QbFilter = string.Empty; + + /// Starred quest flag keys (lowercase), shown on the floating favorites HUD. + public List QuestFavorites = new(); + /// Quest tracker lists starred quests only. + public bool QuestFavoritesOnly; + /// Floating quest favorites HUD is shown. + public bool ShowQuestFavoritesHud; + public bool QuestFavoritesHudLocked; + // The ILT sections are Mini Remote tabs now (HudState.MiniRemoteTab); the old per-section + // "window open" flags in older files are ignored on load. + + /// + /// Registry charms this character has carried, keyed by charm name. Lets the Charms Tracking + /// tab report "acquired" for charms that are now in storage (the client only sees carried items). + /// + public Dictionary CharmsSeen = new(StringComparer.OrdinalIgnoreCase); +} + +/// Last time a charm was seen in the character's possession, with its best tier. +public sealed class IltCharmSeen +{ + public int Tier; + public int MaxTier; + public DateTime LastSeenUtc; +} + +public sealed class IltItemConversion +{ + public string ItemName = string.Empty; + public int ItemsPerConversion = 100; + public int CoinsPerConversion; +} + +// ── Gear ──────────────────────────────────────────────────────────────────── + +public sealed class IltGearState +{ + // Dispel (Rune of Dispel on harmful debuffs) + public bool AutoDispel; + public int DispelCooldownSeconds = 10; + /// Spell-name substrings that are ALWAYS dispelled. + public List DispelInclusions = new(); + /// Spell-name substrings that are NEVER dispelled. + public List DispelExclusions = new(); + + // Surging Strength (Empowered Volcanic Ember keeper) + public bool SurgingStrength; + public int SurgingCooldownSeconds = 15; + + // Aetheria / corrupted-weapon chunking + public bool AutoChunkAetheria; + public bool AutoChunkCorrupted; + public bool ChunkInCombat; + public int ChunkIntervalMs = 2000; + /// Only chunk aetheria whose max level is below this (Coalesced always chunks). + public int ChunkAetheriaUnderLevel = 4; + + // Auto-clap (/clap all) + public bool AutoClap; + public int ClapIntervalMinutes = 30; + + // Guardian Hand charm (WCID unpublished — name match until set) + public uint GuardianHandWcid; + public string GuardianHandName = "Guardian Hand"; + + // Split arrows (White Quartz imbue on missile weapons) + public int SplitArrowTarget = 3; + public bool SplitIgnoreImbued = true; + + // Equipment profiles (.utl suits) and VTank .usd import + public string LastEquipProfile = string.Empty; + public string LastUsdPath = string.Empty; +} + +// ── Games ─────────────────────────────────────────────────────────────────── + +public sealed class IltGamesState +{ + public long BlackjackBet = 1_000_000; + public long FellowshipBlackjackBet = 1_000_000; + public int PowerballQuantity = 1; +} + +// ── Guardian (Temple of Enlightenment) ────────────────────────────────────── + +public sealed class IltGuardianState +{ + /// Translate incoming guardian tells and show the answer (Guardian window + Mini Remote). + public bool AutoDetectFromChat = true; + /// After a chat answer, give the item to the guardian automatically. + public bool AutoHandIn; + /// Temple guardian only: buy one of the item from the nearest vendor when none is carried. + public bool BuyMissingFromVendor = true; + + /// Assumed attribute turn-in cooldown when only /qb wait stamps are known (hours). + public int CooldownHoursAssumed = 20; + /// Turn-ins counted from /qb wait-stamp transitions, keyed by attribute (fallback when /myquests lacks the flag). + public Dictionary TurnInCounts = new(StringComparer.OrdinalIgnoreCase); + /// Estimated end of each attribute's cooldown (UTC), keyed by attribute (same fallback). + public Dictionary CooldownUntilUtc = new(StringComparer.OrdinalIgnoreCase); +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubStore.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubStore.cs new file mode 100644 index 0000000..34afbaa --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubStore.cs @@ -0,0 +1,409 @@ +// IltHubStore.cs — Disk persistence for the ILT Hub. +// +// Files (all under the per-character settings folder the dashboard already uses): +// \ilt-hub.json live Hub state (IltHubState) +// \ilt-hub-transactions.json bank transaction log (capped) +// \ilt-hub-profiles\.json named per-character Hub profiles +// \IltHubProfiles\.json named profiles shared by every character +// Saves are dirty-checked (the serialized JSON is compared to what was last written) so +// the periodic save in Tick costs nothing when nothing changed. A one-time import pulls +// UtilityBelt's bankdata sidecars so players keep their balances and history. +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.Json; +using RynthCore.PluginSdk; +using RynthCore.Install; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltHubStore +{ + /// Maximum bank transactions kept on disk (oldest dropped first). + public const int MaxTransactions = 1000; + + /// Shared root (\RynthAi) for profiles usable by every character. + public static readonly string SharedRoot = RynthInstallPaths.RynthAiDir; + + private readonly RynthCoreHost _host; + private readonly string _charFolder; + private string _lastStateJson = string.Empty; + private string _lastTxJson = string.Empty; + + public IltHubStore(RynthCoreHost host, string charFolder) + { + _host = host; + _charFolder = charFolder ?? string.Empty; + } + + public string CharFolder => _charFolder; + private string StatePath => Path.Combine(_charFolder, "ilt-hub.json"); + private string TxPath => Path.Combine(_charFolder, "ilt-hub-transactions.json"); + private string CharProfileDir => Path.Combine(_charFolder, "ilt-hub-profiles"); + private static string SharedProfileDir => Path.Combine(SharedRoot, "IltHubProfiles"); + + // ── State ─────────────────────────────────────────────────────────────── + + /// Loads the live state, returning defaults when the file is missing or unreadable. + public IltHubState LoadState() + { + try + { + if (_charFolder.Length > 0 && File.Exists(StatePath)) + { + string json = File.ReadAllText(StatePath); + var s = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.IltHubState); + if (s != null) + { + Normalize(s); + _lastStateJson = json; + return s; + } + } + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"load {StatePath}"); } + return new IltHubState(); + } + + /// Writes the state only when its JSON differs from the last write. + public void SaveStateIfDirty(IltHubState state) + { + if (_charFolder.Length == 0) return; + try + { + string json = JsonSerializer.Serialize(state, RynthAiJsonContext.Default.IltHubState); + if (json == _lastStateJson) return; + Directory.CreateDirectory(_charFolder); + WriteAtomic(StatePath, json); + _lastStateJson = json; + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"save {StatePath}"); } + } + + /// Repairs null collections / out-of-range values after deserialization. + private static void Normalize(IltHubState s) + { + s.ServerOptions ??= new IltServerOptionsSnapshot(); + s.ServerOptions.Bits = new Dictionary(s.ServerOptions.Bits ?? new(), StringComparer.OrdinalIgnoreCase); + s.Bank ??= new IltBankState(); + s.Pet ??= new IltPetState(); + s.Pet.PetLog ??= new(); + s.Pet.ShinyLog ??= new(); + s.Pet.Assignments ??= new(); + s.Pet.Assignments.RemoveAll(a => a == null || string.IsNullOrWhiteSpace(a.Name)); + s.Pet.CosmeticPetName ??= string.Empty; + s.Pet.RosterKind = Math.Clamp(s.Pet.RosterKind, 0, 2); + s.Pet.RosterSort = Math.Clamp(s.Pet.RosterSort, 0, 6); + s.Pet.CosmeticRespawnSeconds = Math.Clamp(s.Pet.CosmeticRespawnSeconds, 5, 600); + s.Character ??= new IltCharacterState(); + s.Character.ItemConversions ??= new(); + s.Character.QuestFavorites ??= new(); + s.Character.QuestFavorites.RemoveAll(string.IsNullOrWhiteSpace); + s.Character.AugTargets = new Dictionary(s.Character.AugTargets ?? new(), StringComparer.OrdinalIgnoreCase); + s.Character.AttrOrder = IltAttributeRaiser.RepairOrder(s.Character.AttrOrder); + s.Character.AttrRaiseStats = IltAttributeRaiser.RepairSelection(s.Character.AttrRaiseStats); + s.Character.AttrAutoRaiseMinutes = Math.Clamp(s.Character.AttrAutoRaiseMinutes, 1, 1440); + s.Character.AttrRaiseMode = Math.Clamp(s.Character.AttrRaiseMode, 0, 2); + s.Character.AttrKeepXp = Math.Max(0, s.Character.AttrKeepXp); + s.Character.CharmsSeen = new Dictionary(s.Character.CharmsSeen ?? new(), StringComparer.OrdinalIgnoreCase); + s.Gear ??= new IltGearState(); + s.Gear.DispelInclusions ??= new(); + s.Gear.DispelExclusions ??= new(); + s.Games ??= new IltGamesState(); + s.Guardian ??= new IltGuardianState(); + s.Guardian.TurnInCounts = new Dictionary(s.Guardian.TurnInCounts ?? new(), StringComparer.OrdinalIgnoreCase); + s.Guardian.CooldownUntilUtc = new Dictionary(s.Guardian.CooldownUntilUtc ?? new(), StringComparer.OrdinalIgnoreCase); + s.Guardian.CooldownHoursAssumed = Math.Clamp(s.Guardian.CooldownHoursAssumed, 1, 72); + s.SelectedTab = Math.Clamp(s.SelectedTab, 0, 4); + s.Gear.SplitArrowTarget = Math.Clamp(s.Gear.SplitArrowTarget, 0, 10); + } + + // ── Transactions ──────────────────────────────────────────────────────── + + public List LoadTransactions() + { + try + { + if (_charFolder.Length > 0 && File.Exists(TxPath)) + { + string json = File.ReadAllText(TxPath); + var list = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.IltBankTransactionList); + if (list != null) { _lastTxJson = json; return list; } + } + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"load {TxPath}"); } + return new List(); + } + + public void SaveTransactionsIfDirty(List list) + { + if (_charFolder.Length == 0) return; + try + { + if (list.Count > MaxTransactions) + list.RemoveRange(0, list.Count - MaxTransactions); + string json = JsonSerializer.Serialize(list, RynthAiJsonContext.Default.IltBankTransactionList); + if (json == _lastTxJson) return; + Directory.CreateDirectory(_charFolder); + WriteAtomic(TxPath, json); + _lastTxJson = json; + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"save {TxPath}"); } + } + + // ── Profiles ──────────────────────────────────────────────────────────── + + /// Lists profile names. Shared ones are prefixed "shared:". + public List ListProfiles() + { + var names = new List(); + try + { + if (Directory.Exists(CharProfileDir)) + names.AddRange(Directory.GetFiles(CharProfileDir, "*.json").Select(Path.GetFileNameWithoutExtension).OfType()); + if (Directory.Exists(SharedProfileDir)) + names.AddRange(Directory.GetFiles(SharedProfileDir, "*.json").Select(p => "shared:" + Path.GetFileNameWithoutExtension(p))); + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"list profiles"); } + names.Sort(StringComparer.OrdinalIgnoreCase); + return names; + } + + /// Saves the preference parts of as a named profile. + public bool SaveProfile(IltHubState state, string name, bool shared, out string error) + { + error = string.Empty; + string safe = SanitizeName(name); + if (safe.Length == 0) { error = "Profile name is empty."; return false; } + try + { + string dir = shared ? SharedProfileDir : CharProfileDir; + Directory.CreateDirectory(dir); + var copy = Clone(state); + StripRuntime(copy); + WriteAtomic(Path.Combine(dir, safe + ".json"), JsonSerializer.Serialize(copy, RynthAiJsonContext.Default.IltHubState)); + return true; + } + catch (Exception ex) { error = ex.Message; return false; } + } + + /// + /// Loads a profile onto , keeping runtime data (balances, + /// server bits, rosters, import flag) from the current state. + /// + public bool LoadProfile(IltHubState target, string name, out string error) + { + error = string.Empty; + bool shared = name.StartsWith("shared:", StringComparison.OrdinalIgnoreCase); + string safe = SanitizeName(shared ? name.Substring(7) : name); + string path = Path.Combine(shared ? SharedProfileDir : CharProfileDir, safe + ".json"); + try + { + if (!File.Exists(path)) { error = $"Profile not found: {name}"; return false; } + var p = JsonSerializer.Deserialize(File.ReadAllText(path), RynthAiJsonContext.Default.IltHubState); + if (p == null) { error = "Profile file is empty."; return false; } + Normalize(p); + target.Pet = KeepRosters(p.Pet, target.Pet); + target.Character = p.Character; + target.Gear = p.Gear; + target.Games = p.Games; + target.Bank.AutoRefreshSeconds = p.Bank.AutoRefreshSeconds; + target.ForceLeaftideFeatures = p.ForceLeaftideFeatures; + target.GamesHudVisible = p.GamesHudVisible; + return true; + } + catch (Exception ex) { error = ex.Message; return false; } + } + + private static IltPetState KeepRosters(IltPetState incoming, IltPetState current) + { + incoming.PetLog = current.PetLog; + incoming.ShinyLog = current.ShinyLog; + return incoming; + } + + private static IltHubState Clone(IltHubState s) + => JsonSerializer.Deserialize(JsonSerializer.Serialize(s, RynthAiJsonContext.Default.IltHubState), + RynthAiJsonContext.Default.IltHubState) ?? new IltHubState(); + + /// Removes character-specific runtime data before a profile is written. + private static void StripRuntime(IltHubState s) + { + s.ServerOptions = new IltServerOptionsSnapshot(); + var keepRefresh = s.Bank.AutoRefreshSeconds; + s.Bank = new IltBankState { AutoRefreshSeconds = keepRefresh }; + s.Pet.PetLog = new(); + s.Pet.ShinyLog = new(); + s.UbSidecarsImported = false; + s.WindowVisible = false; + } + + private static string SanitizeName(string name) + { + var invalid = Path.GetInvalidFileNameChars(); + return new string((name ?? string.Empty).Trim().Where(c => !invalid.Contains(c)).ToArray()); + } + + // ── UtilityBelt sidecar import ────────────────────────────────────────── + + /// + /// One-time import of UB's bankdata (balances, transactions) and item conversions. + /// Searches Documents\Decal Plugins\UtilityBelt\<world>\<char>; when the world is + /// unknown every world folder containing the character is tried. Returns a summary. + /// + public string ImportUbSidecars(IltHubState state, List txLog, string world, string charName) + { + if (string.IsNullOrWhiteSpace(charName)) return "character name unknown"; + string ubRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Decal Plugins", "UtilityBelt"); + if (!Directory.Exists(ubRoot)) return "no UtilityBelt folder"; + + var charDirs = new List(); + if (!string.IsNullOrWhiteSpace(world)) + charDirs.Add(Path.Combine(ubRoot, world, charName)); + try + { + foreach (string w in Directory.GetDirectories(ubRoot)) + { + string d = Path.Combine(w, charName); + if (!charDirs.Contains(d, StringComparer.OrdinalIgnoreCase)) charDirs.Add(d); + } + } + catch { /* unreadable Documents subfolder: fall through with what we have */ } + + foreach (string dir in charDirs) + { + string bankDir = Path.Combine(dir, "bankdata"); + if (!Directory.Exists(bankDir) && !Directory.Exists(dir)) continue; + + int parts = 0; + parts += ImportBalances(Path.Combine(bankDir, "bankbalances.json"), state.Bank) ? 1 : 0; + int tx = ImportTransactions(Path.Combine(bankDir, "transactions.json"), txLog); + int conv = ImportConversions(new[] + { + Path.Combine(bankDir, "itemconversions.json"), + Path.Combine(dir, "itemconversions.json"), + }, state.Character.ItemConversions); + + if (parts + tx + conv > 0) + return $"imported from {dir}: balances {(parts > 0 ? "yes" : "no")}, {tx} transactions, {conv} conversions"; + } + return "no UtilityBelt bank data found for " + charName; + } + + private bool ImportBalances(string path, IltBankState bank) + { + if (!File.Exists(path)) return false; + try + { + using var doc = JsonDocument.Parse(File.ReadAllText(path)); + var root = doc.RootElement; + if (root.ValueKind != JsonValueKind.Object) return false; + bank.Pyreals = ReadLong(root, "Pyreals"); + bank.Luminance = ReadLong(root, "Luminance"); + bank.LegendaryKeys = ReadLong(root, "LegendaryKeys"); + bank.MythicalKeys = ReadLong(root, "MythicalKeys"); + bank.EnlightenedCoins = ReadLong(root, "EnlightenedCoins"); + bank.WeaklyEnlightenedCoins = ReadLong(root, "WeaklyEnlightenedCoins"); + if (TryGetProp(root, "LastUpdated", out var lu) && lu.ValueKind == JsonValueKind.String && lu.TryGetDateTime(out var dt)) + bank.LastUpdated = dt; + return true; + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"UB balances import"); return false; } + } + + private int ImportTransactions(string path, List txLog) + { + if (!File.Exists(path)) return 0; + try + { + using var doc = JsonDocument.Parse(File.ReadAllText(path)); + if (doc.RootElement.ValueKind != JsonValueKind.Array) return 0; + int added = 0; + foreach (var e in doc.RootElement.EnumerateArray()) + { + if (e.ValueKind != JsonValueKind.Object) continue; + var t = new IltBankTransaction + { + Type = ReadString(e, "Type"), + Currency = ReadString(e, "Currency"), + Amount = ReadLong(e, "Amount"), + OtherPlayer = ReadString(e, "OtherPlayer"), + Description = ReadString(e, "Description"), + }; + if (TryGetProp(e, "Timestamp", out var ts) && ts.ValueKind == JsonValueKind.String && ts.TryGetDateTime(out var dt)) + t.Timestamp = dt; + // Skip exact duplicates so re-running the import can't double the log. + if (txLog.Any(x => x.Timestamp == t.Timestamp && x.Amount == t.Amount && x.OtherPlayer == t.OtherPlayer)) continue; + txLog.Add(t); + added++; + } + txLog.Sort((a, b) => a.Timestamp.CompareTo(b.Timestamp)); + return added; + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"UB transactions import"); return 0; } + } + + private int ImportConversions(string[] paths, List table) + { + foreach (string path in paths) + { + if (!File.Exists(path)) continue; + try + { + using var doc = JsonDocument.Parse(File.ReadAllText(path)); + if (doc.RootElement.ValueKind != JsonValueKind.Array) continue; + int added = 0; + foreach (var e in doc.RootElement.EnumerateArray()) + { + string name = ReadString(e, "ItemName"); + if (name.Length == 0) continue; + var existing = table.FirstOrDefault(c => c.ItemName.Equals(name, StringComparison.OrdinalIgnoreCase)); + if (existing == null) { existing = new IltItemConversion { ItemName = name }; table.Add(existing); added++; } + existing.ItemsPerConversion = Math.Max(1, (int)ReadLong(e, "ItemsPerConversion")); + existing.CoinsPerConversion = (int)ReadLong(e, "CoinsPerConversion"); + } + return added; + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"UB conversions import"); } + } + return 0; + } + + // ── JSON helpers (case-insensitive property access) ───────────────────── + + private static bool TryGetProp(JsonElement obj, string name, out JsonElement value) + { + foreach (var p in obj.EnumerateObject()) + if (p.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) { value = p.Value; return true; } + value = default; + return false; + } + + private static long ReadLong(JsonElement obj, string name) + { + if (!TryGetProp(obj, name, out var v)) return 0; + if (v.ValueKind == JsonValueKind.Number && v.TryGetInt64(out long l)) return l; + if (v.ValueKind == JsonValueKind.String) return IltParse.ParseLeadingLong(v.GetString() ?? string.Empty); + return 0; + } + + private static string ReadString(JsonElement obj, string name) + { + if (!TryGetProp(obj, name, out var v)) return string.Empty; + return v.ValueKind switch + { + JsonValueKind.String => v.GetString() ?? string.Empty, + JsonValueKind.Number => v.GetRawText(), + _ => string.Empty, + }; + } + + /// Write-then-rename so a crash mid-write never leaves a truncated file. + private static void WriteAtomic(string path, string contents) + { + string tmp = path + ".tmp"; + File.WriteAllText(tmp, contents); + File.Move(tmp, path, overwrite: true); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubUi.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubUi.cs new file mode 100644 index 0000000..05bfb02 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubUi.cs @@ -0,0 +1,234 @@ +// IltHubUi.cs — The ILT sections' ImGui bodies (render thread only). +// +// The ILT sections are tabs of the Mini Remote (MiniRemoteHud draws the tab bar and calls +// RenderTab): Character (world status, Force-ILT, profiles, session rates), Quests (IltQuests), +// Pets, Banking, Gear, Charms and Games. A tab is offered only while the server reports its feature on. +// The Guardian (IltGuardian: Temple riddle translator, hand-in, attribute turn-in tracker) is a +// RynthCore ILT panel instead (the bar's ILT button, next to Bounties), drawn through +// RenderGuardianPanel. Render() keeps the floating extras: the Games HUD, the quest favorites HUD +// and the confirmation modal. Augmentations / Enlightenment / XP planning live on the engine +// Skills panel. All AC actions go through IltHubContext.Post / Confirm so nothing here touches +// the game directly. +using System; +using System.Numerics; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltHubUi +{ + private const string ConfirmPopupId = "Confirm##iltconfirm"; + + private readonly IltHubController _hub; + private readonly IltHubContext _ctx; + private IltConfirmRequest? _confirm; + private bool _confirmOpened; + private string _profileName = string.Empty; + private bool _profileShared; + private string[] _profileList = Array.Empty(); + private int _profileIdx; + // The last tab body drawn (for one shown log event per tab change); -1 = none yet. + private int _lastTabLogged = -1; + + public IltHubUi(IltHubController hub, IltHubContext ctx) + { + _hub = hub; + _ctx = ctx; + } + + /// The floating extras: Games HUD, quest favorites HUD and the confirmation modal. + public void Render() + { + _hub.Games.RenderHud(); + _hub.Quests.RenderFloatingWindows(); + RenderConfirm(); + } + + /// + /// Size of a Mini Remote tab's body (the old section window's default size): the tab draws in a + /// child this big, and the Mini Remote (or the engine window hosting it) fits to it. + /// + public static Vector2 TabSize(IltSection section) => section switch + { + IltSection.Character => new Vector2(520, 440), + IltSection.Quests => new Vector2(700, 500), + IltSection.Pet => new Vector2(560, 580), + IltSection.Banking => new Vector2(560, 520), + IltSection.Gear => new Vector2(560, 520), + IltSection.Charms => new Vector2(560, 520), + IltSection.Games => new Vector2(520, 440), + _ => new Vector2(520, 440), + }; + + /// Draws one Mini Remote ILT tab's body into the current (child) window. + public void RenderTab(IltSection section) + { + if ((int)section != _lastTabLogged) + { + _lastTabLogged = (int)section; + RynthLog.Event(LogEvents.IltWindowShown, $"{IltSections.Label(section)} tab shown (world='{_ctx.Options.WorldName}', available={_hub.Available})"); + } + switch (section) + { + case IltSection.Character: RenderCharacterBody(); break; + case IltSection.Quests: _hub.Quests.RenderTab(); break; + case IltSection.Pet: _hub.Pets.Render(); break; + case IltSection.Banking: _hub.Banking.Render(); break; + case IltSection.Gear: _hub.Gear.Render(); break; + case IltSection.Charms: _hub.CharmsTab.Render(); break; + case IltSection.Games: _hub.Games.Render(); break; + } + } + + /// + /// The Guardian panel's body (RynthCore's ILT Guardian panel, RynthPluginRenderEmbed + /// "guardian"), or why it's idle while the server hasn't reported ILT features. + /// + public void RenderGuardianPanel() + { + if (!_hub.SectionAvailable(IltSection.Guardian)) + { + RenderHeader(); + ImGui.Separator(); + RenderUnavailable(); + return; + } + _hub.Guardian.Render(); + } + + /// Character tab: world / options header, then session rates (or why the ILT tabs are idle). + private void RenderCharacterBody() + { + RenderHeader(); + ImGui.Separator(); + if (!_hub.Available) { RenderUnavailable(); return; } + if (ImGui.CollapsingHeader("Session rates", ImGuiTreeNodeFlags.DefaultOpen)) _hub.Rates.Render(); + ImGui.Spacing(); + ImGui.TextDisabled("XP planner, Augmentations and Enlightenment are on the Skills panel's Progression tab"); + ImGui.TextDisabled("(right-click the dashboard's Char button > Progression)."); + } + + private void RenderHeader() + { + var o = _ctx.Options; + string world = o.WorldName.Length > 0 ? o.WorldName : "unknown world"; + ImGui.TextColored(o.IsIltLikeWorld ? LegacyDashboardRenderer.ColTeal : LegacyDashboardRenderer.ColTextMute, world); + ImGui.SameLine(); + ImGui.TextDisabled(o.IsRefreshing ? "checking server options..." + : o.LastRefreshUtc == DateTime.MinValue ? "server options not checked yet" + : $"options via {o.Source} @ {o.LastRefreshUtc.ToLocalTime():t}"); + ImGui.SameLine(); + if (ImGui.SmallButton("Refresh##opts")) _ctx.Post(() => o.Refresh(manual: true)); + + bool force = _ctx.State.ForceLeaftideFeatures; + if (ImGui.Checkbox("Treat this world as ILT", ref force)) _ctx.State.ForceLeaftideFeatures = force; + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("World-identity override only: the Mini Remote asks the server which ILT features exist.\nIt never turns a feature on by itself."); + ImGui.SameLine(); + if (ImGui.SmallButton("Profiles...")) { ImGui.OpenPopup("##iltprofiles"); _ctx.Post(() => _profileList = _ctx.Store.ListProfiles().ToArray()); } + RenderProfilesPopup(); + } + + private void RenderProfilesPopup() + { + if (!ImGui.BeginPopup("##iltprofiles")) return; + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "ILT profiles (settings only; no balances)"); + ImGui.SetNextItemWidth(180); + ImGui.InputTextWithHint("##profname", "profile name", ref _profileName, 64u); + ImGui.SameLine(); + ImGui.Checkbox("shared", ref _profileShared); + ImGui.SameLine(); + if (ImGui.SmallButton("Save")) + { + string n = _profileName; bool sh = _profileShared; + _ctx.Post(() => + { + _ctx.Chat(_ctx.Store.SaveProfile(_ctx.State, n, sh, out string err) ? $"[Mini Remote] Saved profile '{n}'." : "[Mini Remote] Save failed: " + err); + _profileList = _ctx.Store.ListProfiles().ToArray(); + }); + } + var list = _profileList; + if (list.Length > 0) + { + _profileIdx = Math.Clamp(_profileIdx, 0, list.Length - 1); + ImGui.SetNextItemWidth(180); + ImGui.Combo("##proflist", ref _profileIdx, list, list.Length); + ImGui.SameLine(); + if (ImGui.SmallButton("Load")) + { + string n = list[_profileIdx]; + _ctx.Confirm("Load ILT profile", $"Replace the current ILT settings with profile '{n}'?", + () => _ctx.Chat(_ctx.Store.LoadProfile(_ctx.State, n, out string err) ? $"[Mini Remote] Loaded profile '{n}'." : "[Mini Remote] Load failed: " + err), + "Load"); + } + } + else ImGui.TextDisabled("No saved profiles."); + ImGui.EndPopup(); + } + + private void RenderUnavailable() + { + var o = _ctx.Options; + if (!o.IsIltLikeWorld) + { + ImGui.TextWrapped("This is not an Infinite Leaftide / ACECustom world, so the ILT tabs are idle. " + + "If this shard runs ACECustom under another name, tick 'Treat this world as ILT' and press Refresh."); + } + else if (o.IsRefreshing || o.LastRefreshUtc == DateTime.MinValue) + { + ImGui.TextWrapped("Checking which ILT features this server has enabled..."); + } + else + { + ImGui.TextWrapped("The server did not report any ILT features as enabled. Press Refresh to check again."); + } + } + + // ── Confirmation modal ────────────────────────────────────────────────── + + private void RenderConfirm() + { + if (_confirm == null) + { + if (!_ctx.TryTakeConfirm(out var next)) return; + _confirm = next; + _confirmOpened = false; + } + if (!_confirmOpened) + { + ImGui.OpenPopup(ConfirmPopupId); + _confirmOpened = true; + } + + ImGui.SetNextWindowSize(new Vector2(420, 0), ImGuiCond.Appearing); + bool keepOpen = true; + if (ImGui.BeginPopupModal(ConfirmPopupId, ref keepOpen, ImGuiWindowFlags.AlwaysAutoResize)) + { + ImGui.TextColored(LegacyDashboardRenderer.ColAmber, _confirm.Title); + ImGui.Separator(); + ImGui.TextWrapped(_confirm.Message); + ImGui.Spacing(); + if (ImGui.Button(_confirm.YesLabel + "##iltyes", new Vector2(120, 0))) + { + var act = _confirm.OnYes; + if (act != null) _ctx.Post(act); + _confirm = null; + ImGui.CloseCurrentPopup(); + } + ImGui.SameLine(); + if (ImGui.Button("Cancel##iltno", new Vector2(120, 0))) + { + _confirm = null; + ImGui.CloseCurrentPopup(); + } + ImGui.EndPopup(); + } + else + { + // Closed with the title-bar X (or never opened): treat as cancel. + _confirm = null; + } + if (!keepOpen) _confirm = null; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltInventory.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltInventory.cs new file mode 100644 index 0000000..ac77994 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltInventory.cs @@ -0,0 +1,315 @@ +// IltInventory.cs — Shared item / player-property helper for every ILT Hub feature. +// +// One place for: WCID lookups (cached — the engine call is cheap but not free), stack +// counting, "is it equipped", appraisal requests (throttled), charm ON/OFF status from the +// appraisal Use text, and player int/bool/quad reads. Features never talk to the cache or +// the host for item facts directly, so behaviour (and its edge cases) stays consistent. +// Pump-thread only. +using System; +using System.Collections.Generic; +using System.Linq; +using RynthCore.Loot; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +/// +/// Registered ACECustom charm (CharmAbilityRegistry): display name, every known WCID (base + +/// tier variants), the player PropertyBool the server sets while the ability is active (0 when +/// it is kept in memory only, like Auto-Rebuff) and a one-line effect summary. +/// +internal sealed record IltCharmDef(string Name, uint[] Wcids, uint PlayerFlag = 0, string Effect = ""); + +internal sealed class IltInventory +{ + // ── Well-known WCIDs (ACECustom content) ──────────────────────────────── + public const uint WcidPyreal = 273; + public const uint WcidEnlightenedCoin = 300004; + public const uint WcidEnlToken = 300000; + public const uint WcidEnlMedallion = 90000217; + public const uint WcidEnlSigil = 300101189; + public const uint WcidEnlCrest = 98769999; + public const uint WcidEncapsulatedSpirit = 49485; + public const uint WcidRuneOfDispel = 30133; + public const uint WcidSummonRefillCharm = 78780030; + public const uint WcidUniversalMasteryCharm = 78780031; + public static readonly uint[] WcidInfiniteCastingStone = { 777700019, 777700055 }; + public const uint WcidRedAetheriaChunk = 42636; + public const uint WcidBlueAetheriaChunk = 42635; + + // ── Property ids used by several features ─────────────────────────────── + public const uint IntStackSize = 12; + public const uint IntValidLocations = 9; + public const uint IntLevel = 25; + public const uint IntMaxStructure = 91; + public const uint IntStructure = 92; + public const uint IntNumTimesTinkered = 171; + public const uint IntImbuedEffect = 179; + public const uint IntCleaving = 292; + public const uint IntItemMaxLevel = 319; + public const uint IntSummoningMastery = 362; + public const uint IntEnlightenment = 390; + public const uint IntSplitArrowCount = 9031; + public const uint IntMaterialType = 131; + public const uint IntUses = 92; + /// ACECustom charm item: current tier (PropertyInt.CharmLevel). + public const uint IntCharmLevel = 50005; + /// ACECustom charm item: highest tier for this charm line (PropertyInt.CharmMaxLevel). + public const uint IntCharmMaxLevel = 50006; + public const uint StrUse = 14; + public const uint QuadTotalXp = 1; + public const uint QuadAvailableXp = 2; + public const uint QuadItemTotalXp = 4; + /// ACECustom PropertyInt64.BankedLuminance (sent with each XP batch). + public const uint QuadBankedLuminance = 9005; + public const uint BoolNeverChunk = 9030; + public const uint BoolPyrealRefillActive = 9049; + public const uint BoolUniversalMasteryActive = 50038; + + /// + /// Every charm in ACECustom's CharmAbilityRegistry (WCIDs and player flags match the server's + /// WCIDToAbilityId map and PropertyBool ids). Guardian Hand is not a registry charm and has no + /// published WCID — see IltGear. + /// + public static readonly IltCharmDef[] Charms = + { + new("Mana Barrier", new uint[] { 777700001, 777700054, 777710004, 777720004 }, 50010, + "Mana absorbs incoming damage (better ratio at higher tiers)."), + new("Infinite Casting", WcidInfiniteCastingStone, 50028, + "Infinite Casting Stone: spells cast without consuming components."), + new("Asheron's Favor", new uint[] { 777700020, 777710002, 777720002 }, 50030, + "+10 / 15 / 20% health and +50 / 100 / 250 natural armor."), + new("Artisan's", new uint[] { 777700021, 777710003, 777720003 }, 50031, + "Imbue success chance +4 / 8 / 12%."), + new("Shrapnel", new uint[] { 777700022 }, 50032, + "Tectonic Rifts cast as Rocky Shrapnel (Rocky Shrapnel must be learned)."), + new("Agony", new uint[] { 777700023 }, 50033, + "Tectonic Rifts I casts as Ring of Unspeakable Agony (the spell must be learned)."), + new("Split Cast", new uint[] { 777700024 }, 50035, + "Streak, Arc and Bolt spells split to several nearby targets."), + new("Explosive Arrow", new uint[] { 777700025, 777710005, 777720005 }, 50036, + "Arrow hits detonate an elemental ring at the target."), + new("Omni Strike", new uint[] { 777700026 }, 50037, + "Melee hits use the damage type the target is weakest to."), + new("Fork", new uint[] { 777700027, 777710007, 777720007 }, 50039, + "Streak, Arc and Bolt projectiles fork to nearby enemies (50 / 75 / 100% damage)."), + new("Auto-Rebuff", new uint[] { 777700300 }, 0, + "Keeps your buffs up automatically."), + new("Summon Essence Refill", new uint[] { WcidSummonRefillCharm }, BoolPyrealRefillActive, + "Refills an empty pet essence from banked pyreals when you summon."), + new("Universal Summoning Mastery", new uint[] { WcidUniversalMasteryCharm }, BoolUniversalMasteryActive, + "Use pet essences of any summoning mastery."), + }; + + private readonly RynthCoreHost _host; + private readonly Func _cache; + private readonly Dictionary _wcidCache = new(); + private readonly Dictionary _lastIdRequest = new(); + + /// Don't re-request appraisal for the same object more often than this. + private const long IdRequestThrottleMs = 30_000; + + public IltInventory(RynthCoreHost host, Func cache) + { + _host = host; + _cache = cache; + } + + public RynthCoreHost Host => _host; + public WorldObjectCache? Cache => _cache(); + public uint PlayerId => _host.GetPlayerId(); + + // ── Player state ──────────────────────────────────────────────────────── + + /// The client busy hourglass is up (an action is in progress). + public bool IsBusy => _host.HasGetBusyState && _host.GetBusyState() != 0; + + /// Player is in peace mode (combat mode NonCombat). True when the engine can't tell. + public bool InPeaceMode => !_host.HasGetCurrentCombatMode || _host.GetCurrentCombatMode() == CombatMode.NonCombat; + + public int PlayerInt(uint stype, int fallback = 0) + => _host.HasGetObjectIntProperty && _host.TryGetObjectIntProperty(PlayerId, stype, out int v) ? v : fallback; + + public bool PlayerBool(uint stype) + => _host.HasGetObjectBoolProperty && _host.TryGetObjectBoolProperty(PlayerId, stype, out bool v) && v; + + public long PlayerQuad(uint stype) + => _host.HasGetObjectQuadProperty && _host.TryGetObjectQuadProperty(PlayerId, stype, out long v) ? v : 0; + + /// Current/max health from the engine vitals read (0/0 when unavailable). + public (uint Cur, uint Max) PlayerHealth() + { + if (_host.HasGetPlayerVitals && _host.TryGetPlayerVitals(out uint h, out uint mh, out _, out _, out _, out _)) + return (h, mh); + return (0, 0); + } + + // ── Item facts ────────────────────────────────────────────────────────── + + /// All items the player carries or wears (snapshot). + public IEnumerable Items() => _cache()?.GetInventory() ?? Enumerable.Empty(); + + /// Weenie class id, cached per object (0 when unknown). + public uint Wcid(WorldObject wo) + { + if (_wcidCache.TryGetValue(wo.Id, out uint w) && w != 0) return w; + if (_host.HasGetObjectWcid && _host.TryGetObjectWcid(unchecked((uint)wo.Id), out w)) + _wcidCache[wo.Id] = w; + return w; + } + + public int Int(WorldObject wo, uint stype, int fallback = 0) => wo.Values(unchecked((int)stype), fallback); + + public bool Bool(WorldObject wo, uint stype) + => _host.HasGetObjectBoolProperty && _host.TryGetObjectBoolProperty(unchecked((uint)wo.Id), stype, out bool v) && v; + + public long Quad(WorldObject wo, uint stype) + => _host.HasGetObjectQuadProperty && _host.TryGetObjectQuadProperty(unchecked((uint)wo.Id), stype, out long v) ? v : 0; + + public string Str(WorldObject wo, uint stype) + => _host.HasGetObjectStringProperty && _host.TryGetObjectStringProperty(unchecked((uint)wo.Id), stype, out string v) ? v ?? string.Empty : string.Empty; + + /// Stack size (1 for non-stackables). + public int StackSize(WorldObject wo) => Math.Max(1, Int(wo, IntStackSize, 1)); + + /// Remaining uses on a structure item (essences, kits, salvage bags). + public int Uses(WorldObject wo) => Int(wo, IntStructure, 0); + + public bool IsEquipped(WorldObject wo) + => wo.WieldedLocation > 0 || (wo.Wielder != 0 && unchecked((uint)wo.Wielder) == PlayerId); + + public bool HasAppraisal(WorldObject wo) + => !_host.HasHasAppraisalData || _host.HasAppraisalData(unchecked((uint)wo.Id)); + + /// Requests appraisal data, throttled per object. Returns true if a request was sent. + public bool RequestAppraisal(WorldObject wo) + { + if (!_host.HasRequestId) return false; + long now = Environment.TickCount64; + if (_lastIdRequest.TryGetValue(wo.Id, out long last) && now - last < IdRequestThrottleMs) return false; + _lastIdRequest[wo.Id] = now; + return _host.RequestId(unchecked((uint)wo.Id)); + } + + // ── Finders / counters ────────────────────────────────────────────────── + + public WorldObject? FindByWcid(params uint[] wcids) + => Items().FirstOrDefault(wo => Array.IndexOf(wcids, Wcid(wo)) >= 0); + + public IEnumerable AllByWcid(params uint[] wcids) + => Items().Where(wo => Array.IndexOf(wcids, Wcid(wo)) >= 0); + + public WorldObject? FindByName(Func predicate) + => Items().FirstOrDefault(wo => predicate(wo.Name)); + + /// Total stack count of items with any of the given WCIDs. + public long CountByWcid(params uint[] wcids) + => AllByWcid(wcids).Sum(wo => (long)StackSize(wo)); + + /// Total stack count of items whose name matches exactly (case-insensitive). + public long CountByName(string name) + => Items().Where(wo => wo.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).Sum(wo => (long)StackSize(wo)); + + /// Total stack count of a sigil-chain item (singular or plural stack name; see IltSigilChain.NameIs). + public long CountByChainName(string chainName) + => Items().Where(wo => IltSigilChain.NameIs(wo.Name, chainName)).Sum(wo => (long)StackSize(wo)); + + /// + /// True when the player carries spell components or an Infinite Casting Stone that isn't + /// known to be switched OFF (an OFF stone doesn't waive components). + /// + public bool HasCastingSupplies() + => AllByWcid(WcidInfiniteCastingStone).Any(stone => CharmStatus(stone) != IltTri.Off) + || Items().Any(wo => wo.ObjectClass == AcObjectClass.SpellComponent); + + /// Free main-pack slots (best effort: capacity minus direct children; -1 when unknown). + public int FreeMainPackSlots() + { + var cache = _cache(); + if (cache == null) return -1; + int player = unchecked((int)PlayerId); + int capacity = PlayerInt((uint)LongValueKey.ItemsCapacity, 102); + int used = cache.GetDirectInventory() + .Count(wo => wo.Container == player && wo.WieldedLocation <= 0 && wo.ObjectClass != AcObjectClass.Container); + return Math.Max(0, capacity - used); + } + + // ── Charms ────────────────────────────────────────────────────────────── + + /// + /// ON/OFF/Unknown from the appraisal Use text ("... Status: ON"). Requests appraisal + /// (throttled) when the text isn't loaded yet. + /// + public IltTri CharmStatus(WorldObject charm) + { + string use = Str(charm, StrUse); + if (use.Length == 0) + { + RequestAppraisal(charm); + return IltTri.Unknown; + } + if (use.Contains("Status: ON", StringComparison.OrdinalIgnoreCase)) return IltTri.On; + if (use.Contains("Status: OFF", StringComparison.OrdinalIgnoreCase)) return IltTri.Off; + return IltTri.Unknown; + } + + /// + /// Charm tier and max tier from the item's CharmLevel / CharmMaxLevel ints, else parsed from + /// the appraisal Use text ("Charm [Tier 2/3]"). (0, 0) until the appraisal is loaded. + /// + public (int Tier, int MaxTier) CharmTier(WorldObject charm) + { + int tier = Int(charm, IntCharmLevel, 0), max = Int(charm, IntCharmMaxLevel, 0); + if (tier > 0) return (tier, max); + var m = CharmTierText.Match(Str(charm, StrUse)); + if (!m.Success) return (0, 0); + int.TryParse(m.Groups[1].Value, out tier); + if (m.Groups[2].Success) int.TryParse(m.Groups[2].Value, out max); + return (tier, max); + } + + private static readonly System.Text.RegularExpressions.Regex CharmTierText = + new(@"Charm \[Tier (\d+)(?:/(\d+))?\]", System.Text.RegularExpressions.RegexOptions.CultureInvariant); + + /// Charm definition for an item (by WCID), or null. + public IltCharmDef? CharmDefFor(WorldObject wo) + { + uint w = Wcid(wo); + if (w == 0) return null; + return Charms.FirstOrDefault(c => Array.IndexOf(c.Wcids, w) >= 0); + } + + /// + /// Every charm the player carries: registered WCIDs plus anything whose Use text starts + /// with "Charm [Tier" (generic ACECustom charm format, catches charms added later). + /// + public List CarriedCharms() + { + var list = new List(); + foreach (var wo in Items()) + { + if (CharmDefFor(wo) != null) { list.Add(wo); continue; } + if (wo.ObjectClass is AcObjectClass.MeleeWeapon or AcObjectClass.MissileWeapon or AcObjectClass.Armor + or AcObjectClass.Clothing or AcObjectClass.Container or AcObjectClass.Corpse) + continue; + if (Str(wo, StrUse).StartsWith("Charm [Tier", StringComparison.OrdinalIgnoreCase) + || wo.Name.EndsWith(" Charm", StringComparison.OrdinalIgnoreCase)) + list.Add(wo); + } + return list; + } + + // ── Actions ───────────────────────────────────────────────────────────── + + public bool Use(WorldObject wo) => _host.HasUseObject && _host.UseObject(unchecked((uint)wo.Id)); + + public bool UseOn(WorldObject source, uint targetId) + => _host.HasUseObjectOn && _host.UseObjectOn(unchecked((uint)source.Id), targetId); + + /// Forgets cached WCIDs / appraisal throttles (logout). + public void Reset() + { + _wcidCache.Clear(); + _lastIdRequest.Clear(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltParse.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltParse.cs new file mode 100644 index 0000000..fcc90e5 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltParse.cs @@ -0,0 +1,109 @@ +// IltParse.cs — Shared parsing / formatting helpers for ILT Hub server output. +// +// Centralised so every feature uses the same number parsing (commas, k/m/b/t suffixes), +// the same compact K/M/B display, and the same regexes. Regexes are static and built once; +// RegexOptions.Compiled is harmless under NativeAOT (it falls back to the interpreter). +using System; +using System.Globalization; +using System.Text.RegularExpressions; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal static class IltParse +{ + private const RegexOptions Opt = RegexOptions.Compiled | RegexOptions.CultureInvariant; + + /// "/aug" level line: "Creature: 1,234". + public static readonly Regex AugLine = new(@"^(\w+):\s*([\d,]+)$", Opt); + + /// "/pets" / "/shinies" roster entry: "12. Shiny Drudge Ravener". + public static readonly Regex RosterLine = new(@"^\s*(\d+)\.\s+(.+)$", Opt); + + /// Bank-command amount entry: "1.5m", "250,000", "2b". + public static readonly Regex AmountInput = new(@"^([\d,.]+)\s*([kmbt]?)$", Opt | RegexOptions.IgnoreCase); + + /// AC character name: starts with a letter, then letters, spaces, apostrophes or hyphens (max 32). + public static readonly Regex CharacterName = new(@"^[A-Za-z][A-Za-z '\-]{0,31}$", Opt); + + /// A comma-grouped or plain integer as printed by ACE's N0 format. + public const string AmountPattern = @"(?:\d{1,3}(?:,\d{3})+|\d+)"; + + /// "Transferred 5,000 Pyreals to Bob" (optional " (offline)" / trailing "--- note"). + public static readonly Regex BankSent = new( + @"^Transferred (" + AmountPattern + @") ([^']+?) to ([^-]+?)(?:\s*---.*)?$", Opt); + + /// "Received 5,000 Pyreals from Bob". + public static readonly Regex BankReceived = new( + @"^Received (" + AmountPattern + @") ([^']+?) from (.+?)(?:\s*---.*)?$", Opt); + + /// "/xp all" cost line: "[XP] Your XP cost for next 1 Strength level is: 1,234". + public static readonly Regex XpCost = new(@"\[XP\] Your XP cost for next 1 (\w+) level is: ([\d,]+)", Opt); + + /// "/attr" success: "[ATTR] Strength attribute raised by 10, costing 1,234!". + public static readonly Regex AttrRaised = new(@"^\[ATTR\] (\w+) attribute raised by (\d+), costing ([\d,]+)", Opt); + + /// Strips commas and parses the leading integer; 0 when absent. + public static long ParseLeadingLong(string text) + { + if (string.IsNullOrEmpty(text)) return 0; + string s = text.Replace(",", string.Empty).Trim(); + int end = 0; + while (end < s.Length && char.IsDigit(s[end])) end++; + return end > 0 && long.TryParse(s.AsSpan(0, end), NumberStyles.None, CultureInfo.InvariantCulture, out long v) ? v : 0; + } + + /// + /// Parses a user-entered amount with optional k/m/b/t suffix ("1.5m" → 1,500,000). + /// Returns false for empty, negative, or overflowing input. + /// + public static bool TryParseAmount(string input, out long amount) + { + amount = 0; + var m = AmountInput.Match((input ?? string.Empty).Trim()); + if (!m.Success) return false; + if (!decimal.TryParse(m.Groups[1].Value.Replace(",", string.Empty), NumberStyles.AllowDecimalPoint, + CultureInfo.InvariantCulture, out decimal baseVal)) + return false; + decimal mult = char.ToLowerInvariant(m.Groups[2].Value.Length > 0 ? m.Groups[2].Value[0] : ' ') switch + { + 'k' => 1_000m, + 'm' => 1_000_000m, + 'b' => 1_000_000_000m, + 't' => 1_000_000_000_000m, + _ => 1m, + }; + decimal total = Math.Floor(baseVal * mult); + if (total <= 0 || total > long.MaxValue) return false; + amount = (long)total; + return true; + } + + /// Compact display: 950 → "950", 12_300 → "12.3K", 4_500_000 → "4.50M", 2e9 → "2.00B". + public static string Compact(double value) + { + double a = Math.Abs(value); + string s = a >= 1e12 ? (value / 1e12).ToString("0.00", CultureInfo.InvariantCulture) + "T" + : a >= 1e9 ? (value / 1e9).ToString("0.00", CultureInfo.InvariantCulture) + "B" + : a >= 1e6 ? (value / 1e6).ToString("0.00", CultureInfo.InvariantCulture) + "M" + : a >= 1e3 ? (value / 1e3).ToString("0.0", CultureInfo.InvariantCulture) + "K" + : value.ToString("0", CultureInfo.InvariantCulture); + return s; + } + + /// Full grouped display: 1234567 → "1,234,567". + public static string N0(long value) => value.ToString("N0", CultureInfo.InvariantCulture); + + /// "3d 4h 12m 5s" style duration; "ready" when zero or negative. + public static string Duration(TimeSpan span) + { + if (span <= TimeSpan.Zero) return "ready"; + if (span.TotalDays >= 1) return $"{(int)span.TotalDays}d {span.Hours}h {span.Minutes}m"; + if (span.TotalHours >= 1) return $"{span.Hours}h {span.Minutes}m {span.Seconds}s"; + if (span.TotalMinutes >= 1) return $"{span.Minutes}m {span.Seconds}s"; + return $"{span.Seconds}s"; + } + + /// Strips "<Tell:…>" style markup the chat window sometimes leaves on names. + public static string StripMarkup(string text) + => Regex.Replace(text ?? string.Empty, @"<[^>]*>", string.Empty).Trim(); +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPetStats.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPetStats.cs new file mode 100644 index 0000000..eb58c6c --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPetStats.cs @@ -0,0 +1,323 @@ +// IltPetStats.cs — Mag-Tools / UtilityBelt-style stats for one carried pet essence. +// +// Line 1: Name, Bond N, Lvl N, Craft N +// Line 2: Sex, Growth, Mut N, Potency S (A act +P%), Mastery, DamageType +// Line 3: [D, DR, C, CD, CR, CDR] Uses cur/max Breed Ready|n/m|Rec 4h|Juv|Neut +// +// Property ids are ACECustom (ILT) pet-device qualities, the same ones UtilityBelt's Pets +// tab reads (UB Lib\IltPetAceConstants.cs). Bond, level, craft and ratings are appraisal +// data: they read 0 until the essence has been ID'd, which HasId reports. +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +/// Pet summon category (UB Pets "Type"). Persisted as int in . +internal enum IltPetKind { Combat = 0, Healing = 1, Cosmetic = 2 } + +/// Roster sort modes (persisted as int in ). +internal enum IltPetSort { Priority = 0, Bond = 1, Potency = 2, BreedReady = 3, Level = 4, Uses = 5, Name = 6 } + +/// One carried essence with its decoded stats. Built on the pump thread, read by the UI. +internal sealed class IltPetStats +{ + public int Id; + public string Name = string.Empty; + public uint Wcid; + public IltPetKind Kind; + /// Kind came from a user assignment rather than auto-detection. + public bool KindAssigned; + + public bool HasId; + public int Bond; + public int Level; + public int Craft; + public string Sex = "?"; + public string Growth = string.Empty; + public int Mutations; + public int StoredPotency; + public int ActivePotency; + public int DamageBonusPercent; + public string Mastery = string.Empty; + public string DamageType = string.Empty; + public int D, DR, C, CD, CR, CDR; + public int UsesCur; + public int UsesMax; + public string Breed = "-"; + public bool BreedReady; + + /// Chosen for its kind: in the combat summon list, the heal pet, or the cosmetic pet. + public bool Selected; + /// Combat summon priority (list index), or int.MaxValue when not in the list. + public int Priority = int.MaxValue; + + public string Line1 = string.Empty; + public string Line2 = string.Empty; + public string Line3 = string.Empty; +} + +/// Reads and formats . Pump thread only (host reads). +internal static class IltPetStatsReader +{ + // ── ACECustom / ACE property ids (UB IltPetAceConstants, PetEssenceItemInfoFormatter) ── + private const uint IntDamageType = 45; + private const uint IntMaxStructure = 91; + private const uint IntStructure = 92; + private const uint IntWorkmanship = 105; + private const uint IntSummoningMastery = 362; + private const uint IntUseLevelRequirement = 364; + private const uint IntUseRequiresLevel = 369; + private const uint IntGearDamage = 370; + private const uint IntGearDamageResist = 371; + private const uint IntGearCrit = 372; + private const uint IntGearCritResist = 373; + private const uint IntGearCritDamage = 374; + private const uint IntGearCritDamageResist = 375; + private const uint IntDamageRating = 307; + private const uint IntDamageResistRating = 308; + private const uint IntCritRating = 313; + private const uint IntCritDamageRating = 314; + private const uint IntCritResistRating = 315; + private const uint IntCritDamageResistRating = 316; + private const uint IntBondLevel = 9053; + private const uint IntCapturedDamageType = 9054; + private const uint IntPotencyStored = 9056; + private const uint IntMaleBreedingCharges = 9057; + private const uint IntMutDamage = 9070; + private const uint IntMutDamageResist = 9071; + private const uint IntMutCrit = 9072; + private const uint IntMutVitality = 9073; + private const uint IntMutPotency = 9074; + private const uint IntMutationCount = 9075; + private const uint IntMaturityKills = 9077; + private const uint FloatNextBreedingTime = 9056; + private const uint BoolNeutered = 9051; + private const uint BoolMaleOverride = 50053; + private const uint BoolJuvenile = 50054; + + // ACE PetPotencyMath defaults (UB PetEssencePotencyMath). + private const int PotencyActiveCap = 150; + private const int PotencyBondDivisor = 10; + private const double PotencyDamagePerLevelPercent = 2.0; + /// ACE pet_breeding_male_max_charges default. + private const int MaleMaxBreedingCharges = 10; + + /// Decodes every stat for and fills the three display lines. + public static IltPetStats Read(RynthCoreHost host, IltInventory inv, WorldObject wo, long unixNow) + { + uint id = unchecked((uint)wo.Id); + var s = new IltPetStats + { + Id = wo.Id, + Name = wo.Name, + Wcid = inv.Wcid(wo), + HasId = inv.HasAppraisal(wo), + UsesCur = inv.Int(wo, IntStructure), + UsesMax = inv.Int(wo, IntMaxStructure), + }; + + s.Bond = inv.Int(wo, IntBondLevel); + s.Level = inv.Int(wo, IntUseRequiresLevel); + if (s.Level <= 0) s.Level = inv.Int(wo, IntUseLevelRequirement); + s.Craft = inv.Int(wo, IntWorkmanship); + + // Sex: explicit override when the server set one, else ACE PetDevice.IsMale's GUID hash. + bool isMale = TryBool(host, id, BoolMaleOverride, out bool male) ? male : DeriveIsMale(wo.Id); + bool neutered = TryBool(host, id, BoolNeutered, out bool n) && n; + bool juvenile = TryBool(host, id, BoolJuvenile, out bool j) && j; + s.Sex = (isMale ? "M" : "F") + (neutered ? "n" : juvenile ? "j" : string.Empty); + + // Growth only exists on bred essences (9077 present, even when 0). + if (TryInt(host, id, IntMaturityKills, out int kills)) + s.Growth = !juvenile ? "Adult" : kills > 0 ? "Juv " + kills.ToString(CultureInfo.InvariantCulture) : "Juv"; + + int total = inv.Int(wo, IntMutationCount); + s.Mutations = total > 0 ? total + : inv.Int(wo, IntMutDamage) + inv.Int(wo, IntMutDamageResist) + inv.Int(wo, IntMutCrit) + + inv.Int(wo, IntMutVitality) + inv.Int(wo, IntMutPotency); + + s.StoredPotency = Math.Max(0, inv.Int(wo, IntPotencyStored)); + s.ActivePotency = ActivePotency(s.StoredPotency, s.Bond); + s.DamageBonusPercent = (int)Math.Round(s.ActivePotency * PotencyDamagePerLevelPercent); + + s.Mastery = inv.Int(wo, IntSummoningMastery) switch + { + 1 => "Primalist", + 2 => "Necromancer", + 3 => "Naturalist", + _ => string.Empty, + }; + + int dmg = inv.Int(wo, IntCapturedDamageType); + if (dmg <= 0) dmg = inv.Int(wo, IntDamageType); + s.DamageType = DamageTypeName(dmg); + + // Gear ratings first (what Mag ItemInfo shows), else the base rating ids. + s.D = inv.Int(wo, IntGearDamage); + s.DR = inv.Int(wo, IntGearDamageResist); + s.C = inv.Int(wo, IntGearCrit); + s.CR = inv.Int(wo, IntGearCritResist); + s.CD = inv.Int(wo, IntGearCritDamage); + s.CDR = inv.Int(wo, IntGearCritDamageResist); + if (s.D <= 0 && s.DR <= 0 && s.C <= 0 && s.CR <= 0 && s.CD <= 0 && s.CDR <= 0) + { + s.D = inv.Int(wo, IntDamageRating); + s.DR = inv.Int(wo, IntDamageResistRating); + s.C = inv.Int(wo, IntCritRating); + s.CD = inv.Int(wo, IntCritDamageRating); + s.CR = inv.Int(wo, IntCritResistRating); + s.CDR = inv.Int(wo, IntCritDamageResistRating); + } + + int charges = inv.Int(wo, IntMaleBreedingCharges); + double nextBreed = TryDouble(host, id, FloatNextBreedingTime, out double nb) ? nb : 0; + (s.Breed, s.BreedReady) = FormatBreed(isMale, neutered, juvenile, charges, nextBreed, unixNow); + + FormatLines(s); + return s; + } + + /// Builds Line1..Line3 from the decoded fields (Kind/Selected don't affect the text). + public static void FormatLines(IltPetStats s) + { + var l1 = new StringBuilder(s.Name); + if (s.Bond > 0) l1.Append(", Bond ").Append(s.Bond.ToString(CultureInfo.InvariantCulture)); + if (s.Level > 0) l1.Append(", Lvl ").Append(s.Level.ToString(CultureInfo.InvariantCulture)); + if (s.Craft > 0) l1.Append(", Craft ").Append(s.Craft.ToString(CultureInfo.InvariantCulture)); + s.Line1 = l1.ToString(); + + var l2 = new StringBuilder(s.Sex); + if (s.Growth.Length > 0) l2.Append(", Growth ").Append(s.Growth); + l2.Append(", Mut ").Append(s.Mutations.ToString(CultureInfo.InvariantCulture)); + l2.Append(", Potency ").Append(s.StoredPotency.ToString(CultureInfo.InvariantCulture)); + if (s.StoredPotency > 0) + l2.Append(" (").Append(s.ActivePotency.ToString(CultureInfo.InvariantCulture)) + .Append(" act +").Append(s.DamageBonusPercent.ToString(CultureInfo.InvariantCulture)).Append("%)"); + if (s.Mastery.Length > 0) l2.Append(", ").Append(s.Mastery); + if (s.DamageType.Length > 0) l2.Append(", ").Append(s.DamageType); + s.Line2 = l2.ToString(); + + var parts = new List(4); + string ratings = RatingsBracket(s); + if (ratings.Length > 0) parts.Add(ratings); + if (s.UsesMax > 0) parts.Add($"Uses {s.UsesCur}/{s.UsesMax}"); + else if (s.UsesCur > 0) parts.Add($"Uses {s.UsesCur}"); + if (s.Breed != "-") parts.Add("Breed " + s.Breed); + if (!s.HasId) parts.Add("ID pending"); + s.Line3 = parts.Count > 0 ? string.Join(" ", parts) : "-"; + } + + /// Orders rows for display; ties keep a stable name order. + public static IltPetStats[] Sort(IEnumerable rows, IltPetSort mode) + { + var list = new List(rows); + Comparison byName = (a, b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase); + Comparison cmp = mode switch + { + // Selected first, then combat priority, then name. + IltPetSort.Priority => (a, b) => Chain(b.Selected.CompareTo(a.Selected), a.Priority.CompareTo(b.Priority), byName(a, b)), + IltPetSort.Bond => (a, b) => Chain(b.Bond.CompareTo(a.Bond), byName(a, b)), + IltPetSort.Potency => (a, b) => Chain(b.StoredPotency.CompareTo(a.StoredPotency), b.ActivePotency.CompareTo(a.ActivePotency), byName(a, b)), + IltPetSort.BreedReady => (a, b) => Chain(b.BreedReady.CompareTo(a.BreedReady), b.Bond.CompareTo(a.Bond), byName(a, b)), + IltPetSort.Level => (a, b) => Chain(b.Level.CompareTo(a.Level), byName(a, b)), + IltPetSort.Uses => (a, b) => Chain(b.UsesCur.CompareTo(a.UsesCur), byName(a, b)), + _ => byName, + }; + list.Sort(cmp); + return list.ToArray(); + } + + private static int Chain(params int[] results) + { + foreach (int r in results) if (r != 0) return r; + return 0; + } + + /// ACE PetPotencyMath: min(stored, ceil(bond / 10)), at least 1 with any bond, capped at 150. + private static int ActivePotency(int stored, int bond) + { + if (stored <= 0 || bond <= 0) return 0; + int cap = Math.Max(1, (bond + PotencyBondDivisor - 1) / PotencyBondDivisor); + return Math.Min(stored, Math.Min(cap, PotencyActiveCap)); + } + + /// ACE PetDevice.IsMale when no override is set (murmur3 fmix32 on the object GUID). + private static bool DeriveIsMale(int objectId) + { + uint h = unchecked((uint)objectId); + h ^= h >> 16; + h = unchecked(h * 0x7feb352d); + h ^= h >> 15; + h = unchecked(h * 0x846ca68b); + h ^= h >> 16; + return (h & 1) == 0; + } + + /// Breeding cell: Neut / Juv / male charges n/max / female "Rec Nh" or "Ready". + private static (string Text, bool Ready) FormatBreed(bool isMale, bool neutered, bool juvenile, + int maleCharges, double nextBreedingUnix, long unixNow) + { + if (neutered) return ("Neut", false); + if (juvenile) return ("Juv", false); + if (isMale) + { + int ch = Math.Max(0, maleCharges); + return ($"{ch}/{MaleMaxBreedingCharges}", ch > 0); + } + if (nextBreedingUnix > 0 && unixNow < (long)nextBreedingUnix) + { + long remain = (long)nextBreedingUnix - unixNow; + int hours = (int)(remain / 3600); + return (hours > 0 ? $"Rec {hours}h" : $"Rec {(int)(remain % 3600 / 60)}m", false); + } + return ("Ready", true); + } + + private static string RatingsBracket(IltPetStats s) + { + var sb = new StringBuilder(); + void Add(string label, int v) + { + if (v <= 0) return; + if (sb.Length > 0) sb.Append(", "); + sb.Append(label).Append(' ').Append(v.ToString(CultureInfo.InvariantCulture)); + } + Add("D", s.D); Add("DR", s.DR); Add("C", s.C); Add("CD", s.CD); Add("CR", s.CR); Add("CDR", s.CDR); + return sb.Length > 0 ? "[" + sb + "]" : string.Empty; + } + + /// Single AC DamageType flag → name (combined flags return empty). + private static string DamageTypeName(int flags) => flags switch + { + 1 => "Slash", + 2 => "Pierce", + 4 => "Bludgeon", + 8 => "Cold", + 16 => "Fire", + 32 => "Acid", + 64 => "Lightning", + 1024 => "Nether", + _ => string.Empty, + }; + + private static bool TryBool(RynthCoreHost host, uint id, uint stype, out bool v) + { + v = false; + return host.HasGetObjectBoolProperty && host.TryGetObjectBoolProperty(id, stype, out v); + } + + private static bool TryInt(RynthCoreHost host, uint id, uint stype, out int v) + { + v = 0; + return host.HasGetObjectIntProperty && host.TryGetObjectIntProperty(id, stype, out v); + } + + private static bool TryDouble(RynthCoreHost host, uint id, uint stype, out double v) + { + v = 0; + return host.HasGetObjectDoubleProperty && host.TryGetObjectDoubleProperty(id, stype, out v); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPets.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPets.cs new file mode 100644 index 0000000..7d08ac6 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPets.cs @@ -0,0 +1,982 @@ +// IltPets.cs — ILT Hub "Pet" tab. +// +// * Pet roster (UtilityBelt Pets-tab style): every carried pet essence with three stat +// lines (bond / level / craft · sex / mutations / potency / mastery · ratings / uses / +// breeding), filtered by summon type (Combat / Healing / Cosmetic) and sortable. +// Pets are detected by type (essence WCID block, summoning-gem icon underlay, +// Summoning use requirement, ACECustom bond/potency) — a pet-like name only nominates +// an item for appraisal. Healing Buddy / Dule box and cosmetic naming pick the type, +// else Combat; any essence can be re-typed ("Add sel." or right-click a row). +// - Combat: the tick list is the existing ConsumableRules Type=="Pet" list that +// PetManager summons from (list order = summon priority) — no second summoner. +// - Healing: the tick picks the heal pet the healing state machine uses. +// - Cosmetic: the tick picks a display pet; "Keep cosmetic pet out" summons it in +// peace mode and dismisses it when PetManager needs the slot for a fight. +// Summon / Despawn act on the highlighted row (or the type's chosen pet). +// * Pet charms: Summon Essence Refill (server refills an empty essence from banked +// pyreals) and Universal Summoning Mastery, read from the charm appraisal text and the +// player bools the server stamps. Feeds PetManager.AllowSummonOnEmpty. +// * Healing pet (UB HealingBuddy subset): summons a heal pet when HP drops, dismisses it +// after the heal lands, holds PetManager's combat summons while it is out. +// * /pets and /shinies roster capture (read-only display). +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltPets : IIltFeature +{ + private static readonly string[] KindNames = { "Combat", "Healing", "Cosmetic" }; + private static readonly string[] SortNames = { "Priority", "Bond", "Potency", "Breed ready", "Level", "Uses", "Name" }; + + /// Un-ID'd essences auto-appraised per 2 s scan (keeps the server request rate low). + private const int AutoAppraisePerScan = 2; + + private readonly IltHubContext _ctx; + + // Healing-pet state machine. + private enum HealState { Idle, Summoning, Despawning } + private HealState _heal = HealState.Idle; + private long _healStartedAt; + private long _despawnAt; + private long _healCooldownUntil; + private int _healEssenceId; + private long _lastHealThink; + private string _healStatus = "idle"; + + // Roster snapshot (rebuilt on the pump thread, read by the render thread). + private volatile IltPetStats[] _pets = Array.Empty(); + private long _lastPetScan; + + // Active-pet / cosmetic bookkeeping (pump thread; the ui* copies are for the render thread). + private long _lastPresenceThink; + private int _lastSummonEssenceId; + private int _cosmeticOutEssenceId; + private long _cosmeticNextAt; + private volatile string _uiActivePet = string.Empty; + private volatile string _cosmeticStatus = "off"; + private volatile string _hudPetName = string.Empty; + private volatile string _hudPetStatus = string.Empty; + + /// Mini Remote pet line: the pet that is out, else the first combat essence in priority order. + public string HudPetName => _hudPetName; + /// Mini Remote pet status: "Out", "Ready", "Empty" or "Healing" (empty when there is no pet). + public string HudPetStatus => _hudPetStatus; + + // Charm / supply status cached for the render thread. + private volatile bool _uiRefillActive; + private volatile bool _uiMasteryActive; + private volatile bool _uiHasCasting = true; + + // Render-thread only: highlighted row and the sorted view cache. + private int _highlightId; + private IltPetStats[]? _viewSource; + private int _viewKind = -1; + private int _viewSort = -1; + private IltPetStats[] _view = Array.Empty(); + + public IltPets(IltHubContext ctx) => _ctx = ctx; + + private IltPetState S => _ctx.State.Pet; + + // ── Classification ────────────────────────────────────────────────────── + + // Pet-device type signals (client-visible assessment properties). + private const uint IntMaxStructure = 91; + private const uint IntUseRequiresSkill = 366; + private const uint IntUseRequiresSkillSpec = 368; + private const uint IntBondLevel = 9053; // ACECustom pet essence + private const uint IntPotencyStored = 9056; // ACECustom pet essence + private const int SkillSummoning = 54; + private const uint DidIconUnderlay = 52; + /// Low 24 bits of the summoning-gem icon underlay (0x06007420) every pet device carries. + private const uint SummonGemUnderlay = 0x007420; + + /// Icon-underlay verdict per object id (the DID never changes; only successful reads are cached). + private readonly Dictionary _underlayCache = new(); + + /// + /// True when the item is a pet device by type, not by name: the ACECustom combat + /// essence WCID block, the summoning-gem icon underlay, a Summoning-skill use + /// requirement, or ACECustom bond/potency properties. Names (" Essence", heal / + /// stamina / cosmetic pet naming) only make an item a candidate, which must then show + /// charges (MaxStructure) — so augmentation gems like "Jibril's Essence" stay out. + /// Spirits, charms, capture devices and summoned pet creatures are never pets. + /// + public bool IsPetDevice(WorldObject wo) + { + uint w = _ctx.Inventory.Wcid(wo); + if (w == IltInventory.WcidEncapsulatedSpirit) return false; + if (w is >= 78780030 and <= 78780089) return false; // charm block + if (w is >= 78780001 and <= 78780012) return false; // capture devices + if (w is >= 787802001 and <= 787802072) return false; // summoned combat pet creatures + if (w is >= 787801001 and <= 787801072) return true; // combat essence block + + if (HasSummonGemUnderlay(wo)) return true; + if (RequiresSummoning(wo)) return true; + if (_ctx.Inventory.Int(wo, IntBondLevel) > 0 || _ctx.Inventory.Int(wo, IntPotencyStored, -1) >= 0) return true; + + return IsPetNameCandidate(wo.Name) && _ctx.Inventory.Int(wo, IntMaxStructure) > 0; + } + + /// Name hints UB's pet scan uses; never sufficient on their own (see ). + private static bool IsPetNameCandidate(string n) + => n.EndsWith(" Essence", StringComparison.OrdinalIgnoreCase) + || LooksLikeHealPet(n) || LooksLikeStaminaPet(n) || LooksLikeCosmeticPet(n); + + /// UseRequiresSkill / UseRequiresSkillSpec is Summoning (appraisal data). + private bool RequiresSummoning(WorldObject wo) + => _ctx.Inventory.Int(wo, IntUseRequiresSkill) == SkillSummoning + || _ctx.Inventory.Int(wo, IntUseRequiresSkillSpec) == SkillSummoning; + + /// Icon underlay is the summoning gem (network-populated, no appraisal needed; engine 2026.10.4.19+). + private bool HasSummonGemUnderlay(WorldObject wo) + { + if (_underlayCache.TryGetValue(wo.Id, out bool known)) return known; + var host = _ctx.Host; + if (!host.HasGetObjectDataIdProperty + || !host.TryGetObjectDataIdProperty(unchecked((uint)wo.Id), DidIconUnderlay, out uint did)) + return false; + bool match = (did & 0x00FFFFFF) == SummonGemUnderlay; + _underlayCache[wo.Id] = match; + return match; + } + + /// "Healing Buddy" / "Dule box" naming used by the server's heal pets. + private static bool LooksLikeHealPet(string n) + => (n.Contains("healing", StringComparison.OrdinalIgnoreCase) && n.Contains("buddy", StringComparison.OrdinalIgnoreCase)) + || (n.Contains("dule", StringComparison.OrdinalIgnoreCase) && n.Contains("box", StringComparison.OrdinalIgnoreCase)); + + /// Stamina buddy / crate / pet naming. + private static bool LooksLikeStaminaPet(string n) + => n.Contains("stamina", StringComparison.OrdinalIgnoreCase) + && (n.Contains("buddy", StringComparison.OrdinalIgnoreCase) || n.Contains("crate", StringComparison.OrdinalIgnoreCase) + || n.Contains("pet", StringComparison.OrdinalIgnoreCase)); + + /// Cosmetic / plush / display pet naming. + private static bool LooksLikeCosmeticPet(string n) + => n.Contains("cosmetic", StringComparison.OrdinalIgnoreCase) || n.Contains("plush", StringComparison.OrdinalIgnoreCase) + || n.Contains("display pet", StringComparison.OrdinalIgnoreCase); + + /// Name candidate that hasn't been appraised yet, so its type can't be confirmed. + private bool IsUnconfirmedCandidate(WorldObject wo) + => IsPetNameCandidate(wo.Name) && !IsPetDevice(wo) + && _ctx.Host.HasHasAppraisalData && !_ctx.Inventory.HasAppraisal(wo); + + private IltPetAssignment? FindAssignment(string name) + => S.Assignments.FirstOrDefault(a => a.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); + + /// + /// Summon type for a carried item: the user's override wins, then the configured heal + /// pet. Anything else must be a pet device by type (); its + /// naming then picks Healing / Cosmetic, defaulting to Combat. Null = not a pet. + /// + private IltPetKind? ClassifyKind(WorldObject wo, out bool assigned) + { + var a = FindAssignment(wo.Name); + if (a != null) + { + assigned = true; + return (IltPetKind)Math.Clamp(a.Kind, 0, 2); + } + assigned = false; + if (NameIs(wo, S.HealPetName)) return IltPetKind.Healing; + if (!IsPetDevice(wo)) return null; + if (LooksLikeHealPet(wo.Name)) return IltPetKind.Healing; + if (LooksLikeCosmeticPet(wo.Name)) return IltPetKind.Cosmetic; + return IltPetKind.Combat; + } + + private static bool NameIs(WorldObject wo, string name) + => !string.IsNullOrWhiteSpace(name) && wo.Name.Equals(name.Trim(), StringComparison.OrdinalIgnoreCase); + + private WorldObject? FindCarried(string name) + => string.IsNullOrWhiteSpace(name) ? null : _ctx.Inventory.Items().FirstOrDefault(wo => NameIs(wo, name)); + + /// Heal-pet essence: the ticked heal pet, else the first Healing-typed essence. + private WorldObject? FindHealEssence() + { + if (!string.IsNullOrWhiteSpace(S.HealPetName)) return FindCarried(S.HealPetName); + return _ctx.Inventory.Items().FirstOrDefault(wo => ClassifyKind(wo, out _) == IltPetKind.Healing); + } + + // ── Charms / gates ────────────────────────────────────────────────────── + + /// Summon Essence Refill charm is carried and switched on (or the server stamped the player bool). + public bool RefillCharmActive() + { + if (_ctx.Inventory.PlayerBool(IltInventory.BoolPyrealRefillActive)) return true; + var charm = _ctx.Inventory.FindByWcid(IltInventory.WcidSummonRefillCharm); + return charm != null && _ctx.Inventory.CharmStatus(charm) == IltTri.On; + } + + public bool MasteryCharmActive() + { + if (_ctx.Options.IsOff(IltFeature.UniversalMastery)) return false; + if (_ctx.Inventory.PlayerBool(IltInventory.BoolUniversalMasteryActive)) return true; + var charm = _ctx.Inventory.FindByWcid(IltInventory.WcidUniversalMasteryCharm); + return charm != null && _ctx.Inventory.CharmStatus(charm) == IltTri.On; + } + + /// + /// PetManager hook: summon from an empty essence (spends banked pyreals) only when the + /// player opted in, the refill charm is active, and the server has positively confirmed + /// the feature: either /ilt features reported pet_refill on, or the server stamped the + /// player's refill bool. An unknown feature state never spends. + /// + public bool AllowSummonOnEmpty() + { + if (!S.UsePyrealRefillPath || !_ctx.Options.IsIltLikeWorld || !RefillCharmActive()) return false; + bool confirmed = _ctx.Options.IsOn(IltFeature.PetRefill) + || _ctx.Inventory.PlayerBool(IltInventory.BoolPyrealRefillActive); + if (!confirmed) RynthLog.Trace(LogCat.IltPets, "summon-on-empty refused: pet_refill not confirmed by the server"); + return confirmed; + } + + /// PetManager hook: hold combat summons while the heal pet cycle is running. + public bool HoldCombatSummons() => _heal != HealState.Idle; + + /// + /// PetManager hook (pump thread): a pet already holds the slot and monsters are near. + /// When that pet is the cosmetic pet, dismiss it so a combat pet can be summoned. + /// Returns true when a dismiss was issued. + /// + public bool YieldPetForCombat() + { + if (_heal != HealState.Idle || string.IsNullOrWhiteSpace(S.CosmeticPetName)) return false; + var pet = FindOwnPet(); + var essence = FindCarried(S.CosmeticPetName); + if (pet == null || essence == null) return false; + if (!PetMatchesEssence(pet, essence) && _cosmeticOutEssenceId != essence.Id) return false; + if (_ctx.Inventory.IsBusy || !_ctx.Inventory.Use(essence)) return false; + + long now = IltHubContext.NowMs; + _cosmeticOutEssenceId = 0; + _cosmeticNextAt = now + Math.Max(5, S.CosmeticRespawnSeconds) * 1000L; + _cosmeticStatus = "dismissed for combat"; + RynthLog.Trace(LogCat.IltPets, $"cosmetic pet '{pet.Name}' dismissed so a combat pet can be summoned"); + return true; + } + + // ── Rosters ───────────────────────────────────────────────────────────── + + /// Captures /pets or /shinies into the state (quiet). + public void RequestRoster(bool shinies) + { + RynthLog.Trace(LogCat.IltPets, $"RequestRoster(shinies={shinies})"); + string cmd = shinies ? "/shinies" : "/pets"; + if (_ctx.Capture.IsPending(cmd)) return; + string header = shinies ? "Your Shiny Log" : "Your Pet Log"; + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = cmd, + IsResponseLine = t => t.Contains(header, StringComparison.OrdinalIgnoreCase) || IltParse.RosterLine.IsMatch(t), + IsTerminator = t => t.Contains(header + " is empty", StringComparison.OrdinalIgnoreCase), + IdleEndMs = 1500, + FirstLineTimeoutMs = 10000, + Eat = true, + OnComplete = r => + { + if (r.UnknownCommand) { _ctx.Options.Set(shinies ? IltFeature.Shinies : IltFeature.Pets, IltTri.Off); return; } + if (r.Lines.Count == 0) return; + _ctx.Options.Set(shinies ? IltFeature.Shinies : IltFeature.Pets, IltTri.On); + ApplyRoster(shinies, r.Lines); + }, + }); + } + + /// Also used by the login probe tap so the roster fills without a second command. + public void ApplyRoster(bool shinies, List lines) + { + RynthLog.Trace(LogCat.IltPets, $"ApplyRoster(shinies={shinies}, lines={lines.Count})"); + var list = new List(); + foreach (string l in lines) + { + var m = IltParse.RosterLine.Match(l); + if (m.Success) list.Add(m.Groups[2].Value.Trim()); + } + if (shinies) S.ShinyLog = list; else S.PetLog = list; + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + if (nowMs - _lastPetScan >= 2000) + { + _lastPetScan = nowMs; + RebuildPetSnapshot(autoAppraise: true); + // Host reads (and appraisal requests) happen here, never on the render thread. + _uiRefillActive = RefillCharmActive(); + _uiMasteryActive = MasteryCharmActive(); + _uiHasCasting = _ctx.Inventory.HasCastingSupplies(); + } + if (nowMs - _lastHealThink >= 250) + { + _lastHealThink = nowMs; + TickHealing(nowMs); + } + if (nowMs - _lastPresenceThink >= 1000) + { + _lastPresenceThink = nowMs; + var pet = FindOwnPet(); + _uiActivePet = pet?.Name ?? string.Empty; + TickCosmetic(nowMs, pet); + UpdateHudPetLine(pet); + } + } + + /// Refreshes the Mini Remote's pet name / status pair (pump thread). + private void UpdateHudPetLine(WorldObject? pet) + { + if (pet != null) + { + _hudPetName = ResolveActiveEssence(pet)?.Name ?? pet.Name; + _hudPetStatus = _heal != HealState.Idle ? "Healing" : "Out"; + return; + } + var next = ChosenEssence(IltPetKind.Combat); + if (next == null) { _hudPetName = string.Empty; _hudPetStatus = string.Empty; return; } + _hudPetName = next.Name; + _hudPetStatus = _ctx.Inventory.Uses(next) == 0 && !AllowSummonOnEmpty() ? "Empty" : "Ready"; + } + + public bool OnChat(string text) + { + // " casts Heal Other ... and restores N points of your health." + if (_heal == HealState.Summoning + && text.Contains("casts", StringComparison.OrdinalIgnoreCase) + && text.Contains("heal other", StringComparison.OrdinalIgnoreCase) + && text.Contains("restores", StringComparison.OrdinalIgnoreCase) + && text.Contains("points of your health", StringComparison.OrdinalIgnoreCase)) + { + if (S.AutoDespawnAfterHeal) + { + _heal = HealState.Despawning; + _despawnAt = IltHubContext.NowMs + 1000; + _healStatus = "heal landed, dismissing"; + } + else + { + EndHealCycle(IltHubContext.NowMs, "heal landed"); + } + } + return false; + } + + public void OnLogout() + { + _heal = HealState.Idle; + _pets = Array.Empty(); + _uiActivePet = string.Empty; + _lastSummonEssenceId = 0; + _cosmeticOutEssenceId = 0; + _cosmeticNextAt = 0; + } + + // ── Healing pet ───────────────────────────────────────────────────────── + + private void TickHealing(long now) + { + if (!S.HealingEnabled) + { + if (_heal != HealState.Idle) { _heal = HealState.Idle; _healStatus = "off"; } + return; + } + + switch (_heal) + { + case HealState.Idle: + { + if (now < _healCooldownUntil) return; + var (cur, max) = _ctx.Inventory.PlayerHealth(); + if (max == 0) return; + int pct = (int)(cur * 100 / max); + if (pct >= Math.Clamp(S.HealthThresholdPercent, 1, 99)) { _healStatus = $"HP {pct}% ok"; return; } + if (S.MinHealthPoints > 0 && cur < S.MinHealthPoints) { _healStatus = "HP below minimum, not summoning"; return; } + if (_ctx.Inventory.IsBusy) return; + if (AnyOwnPetPresent()) { _healStatus = "another pet is out"; return; } + var essence = FindHealEssence(); + if (essence == null) { _healStatus = "no heal-pet essence found"; return; } + if (_ctx.Inventory.Uses(essence) == 0 && !AllowSummonOnEmpty()) { _healStatus = "heal-pet essence is empty"; return; } + if (!_ctx.Inventory.Use(essence)) return; + _healEssenceId = essence.Id; + _lastSummonEssenceId = essence.Id; + _healStartedAt = now; + _heal = HealState.Summoning; + _healStatus = $"summoning heal pet (HP {pct}%)"; + break; + } + case HealState.Summoning: + { + long timeout = Math.Max(5, S.PetTimeoutSeconds) * 1000L; + if (now - _healStartedAt < timeout) return; + // No heal seen in time: dismiss only if the pet is actually up. + if (AnyOwnPetPresent()) UseHealEssence(); + EndHealCycle(now, "timed out waiting for heal"); + break; + } + case HealState.Despawning: + { + if (now < _despawnAt || _ctx.Inventory.IsBusy) return; + if (AnyOwnPetPresent()) UseHealEssence(); + EndHealCycle(now, "dismissed"); + break; + } + } + } + + private void EndHealCycle(long now, string why) + { + _heal = HealState.Idle; + _healCooldownUntil = now + Math.Max(1, S.RespawnDelaySeconds) * 1000L; + _healStatus = why; + } + + private void UseHealEssence() + { + var cache = _ctx.Inventory.Cache; + var essence = cache?[_healEssenceId]; + if (essence != null) _ctx.Inventory.Use(essence); + } + + // ── Active pet ────────────────────────────────────────────────────────── + + /// The live "<Me>'s …" creature (server pet naming), or null. + private WorldObject? FindOwnPet() + { + var cache = _ctx.Inventory.Cache; + if (cache == null || _ctx.CharName.Length == 0) return null; + string prefix = _ctx.CharName + "'s "; + return cache.GetLandscape().FirstOrDefault(wo => wo != null && wo.Name.StartsWith(prefix, StringComparison.Ordinal)); + } + + private bool AnyOwnPetPresent() => FindOwnPet() != null; + + /// "Fire Banshee Essence (250)" → "Fire Banshee": the part the summoned creature is named after. + private static string EssenceBaseName(string essenceName) + { + int i = essenceName.IndexOf(" Essence", StringComparison.OrdinalIgnoreCase); + return (i > 0 ? essenceName[..i] : essenceName).Trim(); + } + + private static bool PetMatchesEssence(WorldObject pet, WorldObject essence) => PetMatchesEssence(pet, essence.Name); + + private static bool PetMatchesEssence(WorldObject pet, string essenceName) + { + string b = EssenceBaseName(essenceName); + return b.Length > 0 && pet.Name.Contains(b, StringComparison.OrdinalIgnoreCase); + } + + /// + /// Essence that summoned : the longest essence base name contained + /// in the creature's name, else the last essence this tab / the heal cycle used. + /// + private WorldObject? ResolveActiveEssence(WorldObject pet) + { + WorldObject? best = null; + int bestLen = 0; + WorldObject? last = null; + foreach (var wo in _ctx.Inventory.Items()) + { + if (wo.Id == _lastSummonEssenceId) last = wo; + if (ClassifyKind(wo, out _) == null) continue; + string b = EssenceBaseName(wo.Name); + if (b.Length > bestLen && pet.Name.Contains(b, StringComparison.OrdinalIgnoreCase)) + { + best = wo; + bestLen = b.Length; + } + } + return best ?? last; + } + + // ── Cosmetic pet ──────────────────────────────────────────────────────── + + /// Keeps the chosen cosmetic pet summoned while nothing else needs the pet slot. + private void TickCosmetic(long now, WorldObject? pet) + { + if (!S.KeepCosmeticOut) { _cosmeticStatus = "off"; return; } + if (string.IsNullOrWhiteSpace(S.CosmeticPetName)) { _cosmeticStatus = "no cosmetic pet ticked"; return; } + if (pet != null) + { + _cosmeticStatus = PetMatchesEssence(pet, S.CosmeticPetName) ? "out" : "another pet is out"; + return; + } + if (now < _cosmeticNextAt || _heal != HealState.Idle || _ctx.Inventory.IsBusy) return; + if (!_ctx.Inventory.InPeaceMode) { _cosmeticStatus = "waiting for peace mode"; return; } + var settings = _ctx.Settings; + if (settings != null && settings.IsMacroRunning && settings.SummonPets) { _cosmeticStatus = "combat summoner is active"; return; } + + var essence = FindCarried(S.CosmeticPetName); + if (essence == null) { _cosmeticStatus = "essence not carried"; return; } + if (_ctx.Inventory.Uses(essence) == 0 && !AllowSummonOnEmpty()) + { + _cosmeticStatus = "essence is empty"; + _cosmeticNextAt = now + 30_000; + return; + } + if (!_ctx.Inventory.Use(essence)) return; + _cosmeticOutEssenceId = essence.Id; + _lastSummonEssenceId = essence.Id; + // Covers the summon round-trip so the pet isn't re-summoned before it appears. + _cosmeticNextAt = now + Math.Max(5, S.CosmeticRespawnSeconds) * 1000L; + _cosmeticStatus = "summoning"; + RynthLog.Trace(LogCat.IltPets, $"cosmetic pet summon: {essence.Name}"); + } + + // ── Manual actions (pump thread) ──────────────────────────────────────── + + /// Summons from , or the current type's chosen pet when 0. + private void SummonPet(int essenceId, IltPetKind kind) + { + if (FindOwnPet() is { } outPet) { _ctx.Chat($"[Mini Remote] {outPet.Name} is already out — Despawn it first."); return; } + if (_heal != HealState.Idle) { _ctx.Chat("[Mini Remote] The heal-pet cycle is running."); return; } + if (_ctx.Inventory.IsBusy) { _ctx.Chat("[Mini Remote] Busy — try again in a moment."); return; } + + WorldObject? essence = essenceId != 0 ? _ctx.Inventory.Items().FirstOrDefault(w => w.Id == essenceId) : ChosenEssence(kind); + if (essence == null) { _ctx.Chat($"[Mini Remote] No {KindNames[(int)kind].ToLowerInvariant()} pet selected."); return; } + if (_ctx.Inventory.Uses(essence) == 0 && !AllowSummonOnEmpty()) { _ctx.Chat($"[Mini Remote] {essence.Name} has no uses left."); return; } + if (!_ctx.Inventory.Use(essence)) return; + + _lastSummonEssenceId = essence.Id; + if (NameIs(essence, S.CosmeticPetName)) _cosmeticOutEssenceId = essence.Id; + RynthLog.Trace(LogCat.IltPets, $"manual summon: {essence.Name}"); + } + + /// Dismisses the pet that is out by using the essence that summoned it again. + private void DespawnPet() + { + var pet = FindOwnPet(); + if (pet == null) { _ctx.Chat("[Mini Remote] No pet is out."); return; } + if (_ctx.Inventory.IsBusy) { _ctx.Chat("[Mini Remote] Busy — try again in a moment."); return; } + var essence = ResolveActiveEssence(pet); + if (essence == null) { _ctx.Chat($"[Mini Remote] Couldn't find the essence for {pet.Name}."); return; } + if (!_ctx.Inventory.Use(essence)) return; + + // A manual dismiss shouldn't be undone straight away by "Keep cosmetic pet out". + _cosmeticNextAt = IltHubContext.NowMs + Math.Max(5, S.CosmeticRespawnSeconds) * 1000L; + if (essence.Id == _cosmeticOutEssenceId) _cosmeticOutEssenceId = 0; + RynthLog.Trace(LogCat.IltPets, $"manual despawn: {pet.Name} via {essence.Name}"); + } + + /// The pet the type's tick selects: first combat priority, the heal pet, or the cosmetic pet. + private WorldObject? ChosenEssence(IltPetKind kind) + { + switch (kind) + { + case IltPetKind.Healing: + return FindHealEssence(); + case IltPetKind.Cosmetic: + return FindCarried(S.CosmeticPetName); + default: + var rules = PetRules(); + foreach (var r in rules) + { + var wo = _ctx.Inventory.Items().FirstOrDefault(w => w.Id == r.Id || NameIs(w, r.Name)); + if (wo != null) return wo; + } + return null; + } + } + + /// + /// Requests appraisal for every carried pet (refreshes bond / potency after fights) and + /// for un-appraised pet-named items, whose type is only known once the appraisal lands. + /// + private void ScanPack() + { + int pets = 0, candidates = 0; + foreach (var wo in _ctx.Inventory.Items()) + { + if (ClassifyKind(wo, out _) != null) + { + if (_ctx.Inventory.RequestAppraisal(wo)) pets++; + } + else if (IsUnconfirmedCandidate(wo) && _ctx.Inventory.RequestAppraisal(wo)) + { + candidates++; + } + } + if (pets == 0 && candidates == 0) + _ctx.Chat("[Mini Remote] Pets were appraised recently."); + else + _ctx.Chat(candidates > 0 + ? $"[Mini Remote] Appraising {pets} pet(s) and checking {candidates} pet-named item(s)…" + : $"[Mini Remote] Appraising {pets} pet(s)…"); + RebuildPetSnapshot(autoAppraise: false); + } + + /// Gives the item selected in the game a summon type (pump thread). + private void AddSelectedAs(IltPetKind kind) + { + if (!_ctx.Host.HasGetSelectedItemId) { _ctx.Chat("[Mini Remote] This client build can't read the selected item."); return; } + int id = unchecked((int)_ctx.Host.GetSelectedItemId()); + var wo = _ctx.Inventory.Items().FirstOrDefault(w => w.Id == id); + if (wo == null) { _ctx.Chat("[Mini Remote] Select a pet essence in your pack first."); return; } + SetKind(wo.Id, wo.Name, kind); + _ctx.Chat($"[Mini Remote] {wo.Name} added as a {KindNames[(int)kind].ToLowerInvariant()} pet."); + } + + /// + /// Re-types an essence (null = back to auto classification) and drops it from the other + /// types' selections so a pet is only ever chosen under one type. + /// + private void SetKind(int id, string name, IltPetKind? kind) + { + S.Assignments.RemoveAll(a => a.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); + if (kind is { } k) S.Assignments.Add(new IltPetAssignment { Name = name, Kind = (int)k }); + + if (kind != IltPetKind.Combat && PetRules().Any(r => r.Id == id || r.Name.Equals(name, StringComparison.OrdinalIgnoreCase))) + SetCombatSelected(id, name, false); + if (kind != IltPetKind.Healing && S.HealPetName.Trim().Equals(name, StringComparison.OrdinalIgnoreCase)) + S.HealPetName = string.Empty; + if (kind != IltPetKind.Cosmetic && S.CosmeticPetName.Trim().Equals(name, StringComparison.OrdinalIgnoreCase)) + S.CosmeticPetName = string.Empty; + RebuildPetSnapshot(autoAppraise: false); + } + + /// Applies a roster tick for the row's type (pump thread). + private void SetSelected(int id, string name, IltPetKind kind, bool on) + { + switch (kind) + { + case IltPetKind.Healing: S.HealPetName = on ? name : string.Empty; break; + case IltPetKind.Cosmetic: S.CosmeticPetName = on ? name : string.Empty; break; + default: SetCombatSelected(id, name, on); break; + } + RebuildPetSnapshot(autoAppraise: false); + } + + // ── Combat summon list (ConsumableRules Type=="Pet") ──────────────────── + + private List PetRules() + => _ctx.Settings?.ConsumableRules.Where(r => r.Type.Equals("Pet", StringComparison.OrdinalIgnoreCase)).ToList() + ?? new List(); + + /// Adds or removes an essence from the PetManager list (pump thread). + private void SetCombatSelected(int id, string name, bool on) + { + var settings = _ctx.Settings; + if (settings == null) return; + settings.ConsumableRules.RemoveAll(r => r.Type.Equals("Pet", StringComparison.OrdinalIgnoreCase) + && (r.Id == id || r.Name.Equals(name, StringComparison.OrdinalIgnoreCase))); + if (on) settings.ConsumableRules.Add(new ConsumableRule { Id = id, Name = name, Type = "Pet" }); + _ctx.SaveCombatSettings?.Invoke(); + } + + /// Moves a configured essence up (-1) or down (+1) in summon priority (pump thread). + private void MovePriority(int id, int delta) + { + var settings = _ctx.Settings; + if (settings == null) return; + var list = settings.ConsumableRules; + int idx = list.FindIndex(r => r.Id == id && r.Type.Equals("Pet", StringComparison.OrdinalIgnoreCase)); + if (idx < 0) return; + // Find the neighbouring Pet rule in the requested direction. + int j = idx + delta; + while (j >= 0 && j < list.Count && !list[j].Type.Equals("Pet", StringComparison.OrdinalIgnoreCase)) j += delta; + if (j < 0 || j >= list.Count) return; + (list[idx], list[j]) = (list[j], list[idx]); + _ctx.SaveCombatSettings?.Invoke(); + RebuildPetSnapshot(autoAppraise: false); + } + + // ── Roster snapshot (pump thread) ─────────────────────────────────────── + + private void RebuildPetSnapshot(bool autoAppraise) + { + var rules = PetRules(); + long unixNow = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); + var rows = new List(); + int appraised = 0; + foreach (var wo in _ctx.Inventory.Items()) + { + var kind = ClassifyKind(wo, out bool assigned); + if (kind == null) + { + // Pet-named but unconfirmed: its appraisal decides whether it is a pet device. + if (autoAppraise && appraised < AutoAppraisePerScan && IsUnconfirmedCandidate(wo) + && _ctx.Inventory.RequestAppraisal(wo)) + appraised++; + continue; + } + + var s = IltPetStatsReader.Read(_ctx.Host, _ctx.Inventory, wo, unixNow); + s.Kind = kind.Value; + s.KindAssigned = assigned; + int pri = rules.FindIndex(r => r.Id == wo.Id || r.Name.Equals(wo.Name, StringComparison.OrdinalIgnoreCase)); + s.Priority = pri >= 0 ? pri : int.MaxValue; + s.Selected = s.Kind switch + { + IltPetKind.Healing => NameIs(wo, S.HealPetName), + IltPetKind.Cosmetic => NameIs(wo, S.CosmeticPetName), + _ => pri >= 0, + }; + rows.Add(s); + + // Stats beyond uses need an appraisal; trickle the requests for un-ID'd essences. + if (autoAppraise && !s.HasId && appraised < AutoAppraisePerScan && _ctx.Inventory.RequestAppraisal(wo)) + appraised++; + } + _pets = rows.ToArray(); + } + + // ── UI (render thread) ────────────────────────────────────────────────── + + public void Render() + { + var settings = _ctx.Settings; + if (settings == null) { ImGui.TextDisabled("Not logged in."); return; } + + RenderRosterHeader(settings); + RenderRosterTable(); + // The tab is universal; the charms and the /pets and /shinies logs are ILT's. + bool ilt = _ctx.Options.IsIltLikeWorld; + if (ilt) + { + ImGui.Separator(); + RenderCharms(); + } + ImGui.Separator(); + RenderHealing(); + if (ilt) + { + ImGui.Separator(); + RenderRosters(); + } + } + + /// Type / Sort combos, action buttons, the active-summon line and per-type options. + private void RenderRosterHeader(LegacyUiSettings settings) + { + var kind = (IltPetKind)Math.Clamp(S.RosterKind, 0, 2); + + ImGui.TextUnformatted("Type"); + ImGui.SameLine(); + ImGui.SetNextItemWidth(100); + int k = (int)kind; + if (ImGui.Combo("##iltpetkind", ref k, KindNames, KindNames.Length)) { S.RosterKind = k; kind = (IltPetKind)k; _highlightId = 0; } + ImGui.SameLine(); + ImGui.TextUnformatted("Sort"); + ImGui.SameLine(); + ImGui.SetNextItemWidth(110); + int sort = Math.Clamp(S.RosterSort, 0, SortNames.Length - 1); + if (ImGui.Combo("##iltpetsort", ref sort, SortNames, SortNames.Length)) S.RosterSort = sort; + + int target = _highlightId; + var summonKind = kind; + if (ImGui.Button("Summon")) _ctx.Post(() => SummonPet(target, summonKind)); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Summon the highlighted pet (or this type's ticked pet)."); + ImGui.SameLine(); + if (ImGui.Button("Despawn")) _ctx.Post(DespawnPet); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Dismiss the pet that is out."); + ImGui.SameLine(); + if (ImGui.Button("Scan pack")) _ctx.Post(ScanPack); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Appraise every pet to refresh bond, potency and breeding, and check pet-named items\n(an \"... Essence\" name alone isn't enough — the item must be a summoning pet device)."); + ImGui.SameLine(); + if (ImGui.Button("Add sel.")) _ctx.Post(() => AddSelectedAs(summonKind)); + if (ImGui.IsItemHovered()) ImGui.SetTooltip($"Make the item selected in your pack a {KindNames[(int)kind].ToLowerInvariant()} pet."); + + string active = _uiActivePet; + if (active.Length > 0) ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Active summon: " + active); + else ImGui.TextDisabled("Active summon: none"); + + switch (kind) + { + case IltPetKind.Combat: + { + bool summon = settings.SummonPets; + if (ImGui.Checkbox("Summon when monsters are near", ref summon)) _ctx.Post(() => { settings.SummonPets = summon; _ctx.SaveCombatSettings?.Invoke(); }); + ImGui.SameLine(); + int minMobs = settings.PetMinMonsters; + ImGui.SetNextItemWidth(90); + if (ImGui.InputInt("Min monsters", ref minMobs)) _ctx.Post(() => { settings.PetMinMonsters = Math.Max(1, minMobs); _ctx.SaveCombatSettings?.Invoke(); }); + bool refill = settings.PetAutoRefill; + if (ImGui.Checkbox("Refill empty essences with Encapsulated Spirit", ref refill)) _ctx.Post(() => { settings.PetAutoRefill = refill; _ctx.SaveCombatSettings?.Invoke(); }); + ImGui.TextDisabled("Tick pets to add them to the summon list; with Sort = Priority the arrows set the order."); + break; + } + case IltPetKind.Healing: + ImGui.TextDisabled("Tick one heal pet (none ticked = first Healing Buddy / Dule box). Settings are below."); + break; + case IltPetKind.Cosmetic: + { + bool keep = S.KeepCosmeticOut; + if (ImGui.Checkbox("Keep cosmetic pet out", ref keep)) S.KeepCosmeticOut = keep; + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Peace mode only. Dismissed automatically when the combat summoner needs the pet slot."); + ImGui.SameLine(); + int resp = S.CosmeticRespawnSeconds; + ImGui.SetNextItemWidth(90); + if (ImGui.InputInt("Respawn (s)", ref resp)) S.CosmeticRespawnSeconds = Math.Clamp(resp, 5, 600); + ImGui.TextDisabled("Tick one cosmetic pet. Status: " + _cosmeticStatus); + break; + } + } + } + + /// Sorted rows of the current type, cached until the snapshot / type / sort changes. + private IltPetStats[] CurrentView() + { + var src = _pets; + int kind = Math.Clamp(S.RosterKind, 0, 2); + int sort = Math.Clamp(S.RosterSort, 0, SortNames.Length - 1); + if (!ReferenceEquals(src, _viewSource) || kind != _viewKind || sort != _viewSort) + { + _view = IltPetStatsReader.Sort(src.Where(p => (int)p.Kind == kind), (IltPetSort)sort); + _viewSource = src; + _viewKind = kind; + _viewSort = sort; + } + return _view; + } + + /// One table row per pet: tick · three stat lines (highlight / right-click menu) · priority arrows. + private void RenderRosterTable() + { + var rows = CurrentView(); + var kind = (IltPetKind)Math.Clamp(S.RosterKind, 0, 2); + bool showArrows = kind == IltPetKind.Combat && S.RosterSort == (int)IltPetSort.Priority; + + if (rows.Length == 0) + { + ImGui.TextDisabled(kind == IltPetKind.Cosmetic + ? "No cosmetic pets yet — select an essence in your pack and press Add sel., or right-click a pet in another type." + : $"No {KindNames[(int)kind].ToLowerInvariant()} pet essences carried."); + return; + } + + float lineH = ImGui.GetTextLineHeightWithSpacing(); + float tableH = Math.Min(320f, rows.Length * (lineH * 3 + 6) + 8); + if (!ImGui.BeginTable("##iltpets", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.ScrollY, new Vector2(0, tableH))) + return; + ImGui.TableSetupColumn("##sel", ImGuiTableColumnFlags.WidthFixed, 26); + ImGui.TableSetupColumn("##pet"); + ImGui.TableSetupColumn("##ord", ImGuiTableColumnFlags.WidthFixed, showArrows ? 52 : 1); + + foreach (var r in rows) + { + ImGui.TableNextRow(); + ImGui.TableNextColumn(); + bool on = r.Selected; + if (ImGui.Checkbox($"##psel{r.Id}", ref on)) + { + var row = r; + _ctx.Post(() => SetSelected(row.Id, row.Name, row.Kind, on)); + } + + ImGui.TableNextColumn(); + Vector2 start = ImGui.GetCursorPos(); + if (ImGui.Selectable($"##prow{r.Id}", _highlightId == r.Id, ImGuiSelectableFlags.AllowOverlap, new Vector2(0, lineH * 3 - ImGui.GetStyle().ItemSpacing.Y))) + _highlightId = _highlightId == r.Id ? 0 : r.Id; + RenderRowContextMenu(r); + ImGui.SetCursorPos(start); + ImGui.TextColored(DamageColor(r.DamageType), r.Line1); + ImGui.TextColored(LegacyDashboardRenderer.ColAmber, " " + r.Line2); + if (r.UsesMax > 0 && r.UsesCur == 0) ImGui.TextColored(LegacyDashboardRenderer.ColHp, " " + r.Line3); + else ImGui.TextDisabled(" " + r.Line3); + + ImGui.TableNextColumn(); + if (showArrows && r.Selected) + { + int id = r.Id; + if (ImGui.ArrowButton($"##pup{r.Id}", ImGuiDir.Up)) _ctx.Post(() => MovePriority(id, -1)); + ImGui.SameLine(); + if (ImGui.ArrowButton($"##pdn{r.Id}", ImGuiDir.Down)) _ctx.Post(() => MovePriority(id, +1)); + } + } + ImGui.EndTable(); + } + + /// Right-click menu on a roster row: summon / move to another type / clear override. + private void RenderRowContextMenu(IltPetStats r) + { + if (!ImGui.BeginPopupContextItem($"##pctx{r.Id}")) return; + var row = r; + if (ImGui.MenuItem("Summon")) _ctx.Post(() => SummonPet(row.Id, row.Kind)); + ImGui.Separator(); + for (int i = 0; i < KindNames.Length; i++) + { + if (i == (int)r.Kind) continue; + var to = (IltPetKind)i; + if (ImGui.MenuItem("Move to " + KindNames[i])) _ctx.Post(() => SetKind(row.Id, row.Name, to)); + } + if (r.KindAssigned && ImGui.MenuItem("Clear type override")) + _ctx.Post(() => SetKind(row.Id, row.Name, null)); + ImGui.EndPopup(); + } + + /// Line-1 colour by the pet's damage type (white when unknown / not appraised). + private static Vector4 DamageColor(string damageType) => damageType switch + { + "Fire" => new Vector4(1.00f, 0.55f, 0.30f, 1f), + "Cold" => new Vector4(0.55f, 0.80f, 1.00f, 1f), + "Acid" => new Vector4(0.55f, 0.95f, 0.45f, 1f), + "Lightning" => new Vector4(0.85f, 0.70f, 1.00f, 1f), + "Nether" => new Vector4(0.75f, 0.50f, 0.90f, 1f), + _ => new Vector4(0.95f, 0.95f, 0.95f, 1f), + }; + + private void RenderCharms() + { + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Pet charms"); + bool refillOff = _ctx.Options.IsOff(IltFeature.PetRefill); + ImGui.TextUnformatted("Summon Essence Refill: " + (refillOff ? "disabled on this server" : _uiRefillActive ? "ON" : "off / not carried")); + ImGui.BeginDisabled(refillOff); + bool usePath = S.UsePyrealRefillPath; + if (ImGui.Checkbox("Summon from empty essences while the refill charm is ON (spends banked pyreals)", ref usePath)) + S.UsePyrealRefillPath = usePath; + ImGui.EndDisabled(); + ImGui.TextUnformatted("Universal Summoning Mastery: " + + (_ctx.Options.IsOff(IltFeature.UniversalMastery) ? "disabled on this server" : _uiMasteryActive ? "ON" : "off / not carried")); + if (!_ctx.Options.IsOff(IltFeature.RequireComps) && !_uiHasCasting) + ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "No spell components or Infinite Casting Stone carried."); + } + + private void RenderHealing() + { + if (!ImGui.CollapsingHeader("Healing pet settings")) return; + bool en = S.HealingEnabled; + if (ImGui.Checkbox("Summon heal pet when health is low", ref en)) S.HealingEnabled = en; + string healPet = S.HealPetName; + ImGui.TextDisabled("Heal pet: " + (string.IsNullOrWhiteSpace(healPet) ? "auto (Healing Buddy / Dule box)" : healPet) + + " — tick one under Type = Healing."); + int thr = S.HealthThresholdPercent; + ImGui.SetNextItemWidth(160); + if (ImGui.SliderInt("Health % trigger", ref thr, 10, 99)) S.HealthThresholdPercent = thr; + int minHp = S.MinHealthPoints; + ImGui.SetNextItemWidth(100); + if (ImGui.InputInt("Don't summon below HP", ref minHp, 10)) S.MinHealthPoints = Math.Max(0, minHp); + bool desp = S.AutoDespawnAfterHeal; + if (ImGui.Checkbox("Dismiss after the heal", ref desp)) S.AutoDespawnAfterHeal = desp; + int resp = S.RespawnDelaySeconds; + ImGui.SetNextItemWidth(100); + if (ImGui.InputInt("Respawn delay (s)", ref resp)) S.RespawnDelaySeconds = Math.Max(1, resp); + int to = S.PetTimeoutSeconds; + ImGui.SetNextItemWidth(100); + if (ImGui.InputInt("Heal timeout (s)", ref to)) S.PetTimeoutSeconds = Math.Max(5, to); + ImGui.TextDisabled("Status: " + _healStatus); + } + + private void RenderRosters() + { + RenderRoster("Pet log", false, IltFeature.Pets, S.PetLog); + RenderRoster("Shiny log", true, IltFeature.Shinies, S.ShinyLog); + } + + private void RenderRoster(string label, bool shinies, string key, List list) + { + if (_ctx.Options.IsOff(key)) return; + var snap = list.ToArray(); + if (ImGui.TreeNode($"{label} ({snap.Length})##{key}")) + { + if (ImGui.SmallButton($"Refresh##{key}")) _ctx.Post(() => RequestRoster(shinies)); + foreach (string s in snap) ImGui.BulletText(s); + ImGui.TreePop(); + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltProgression.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltProgression.cs new file mode 100644 index 0000000..11b11f5 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltProgression.cs @@ -0,0 +1,775 @@ +// IltProgression.cs — Augmentation and Enlightenment planners, drawn by the engine's +// Skills panel (Progression tab) from AppendSnapshotJson; edits arrive via HandleRemote. +// +// Augs : "/aug" levels + the per-server cost rules in IltAugCosts (UB's ILT model by default: +// level i costs base + (i-1)*(base*LP/100), times 1/4/8/16/24 from S1..S4), coins per level. +// Enl : tier material/luminance table, requirement checklist, "/enl" on confirm. The +// server pops its own Yes/No dialog — the host cannot (and must not) click it. +// Optional auto-enlighten is disarmed every session and needs a hard confirm. +// XP : the Skills panel plans attribute/vital raises from the client's exact XP tables; +// this module spends unassigned XP ("/attr") before an auto-enlighten, and owns the +// infinite-attribute raiser (IltAttributeRaiser: server costs from "/xp all", manual +// or timed raises in a chosen order) drawn in the same tab. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltProgression : IIltFeature +{ + // ── Augmentation cost rules ───────────────────────────────────────────── + + /// Per-server aug cost rules (UB's ILT model unless this world was changed). + public IltAugCosts AugCosts { get; } = new(); + + /// The rules for the world we're on. + private IltAugCostProfile AugProfile => AugCosts.For(_ctx.Options.WorldName); + + // ── Enlightenment ─────────────────────────────────────────────────────── + + private const int BaseLevelForEnl = 275; + private const long AutoEnlCooldownMs = 60_000; + private const uint SpellVitae = 666; + + /// Materials for reaching enlightenment level (one step). + public static (string Item, uint Wcid, int Count, decimal Lum) EnlStepCost(int t) + { + if (t <= 5) return ("none", 0, 0, 0); + int count = t - 5; + if (t <= 50) return ("Enlightenment Tokens", IltInventory.WcidEnlToken, count, 0); + if (t <= 150) return ("Enlightenment Tokens", IltInventory.WcidEnlToken, count, t * 100_000_000m); + if (t <= 300) return ("Enlightenment Medallions", IltInventory.WcidEnlMedallion, count, t * 1_000_000_000m); + decimal mult = 1m + 0.5m * ((t - 300 - 1) / 50); + decimal lum = Math.Ceiling(t * 2_000_000_000m * mult); + return t <= 325 ? ("Enlightenment Sigils", IltInventory.WcidEnlSigil, count, lum) + : ("Enlightenment Crests", IltInventory.WcidEnlCrest, count, lum); + } + + // ── XP ────────────────────────────────────────────────────────────────── + + /// /attr abbreviation, display name, attribute stype (0 = vital), vital stype. + private static readonly (string Abbr, string Name, uint Attr, uint Vital)[] Stats = + { + ("str", "Strength", 1, 0), ("end", "Endurance", 2, 0), ("coo", "Coordination", 4, 0), + ("qui", "Quickness", 3, 0), ("foc", "Focus", 5, 0), ("sel", "Self", 6, 0), + ("hea", "Health", 0, 1), ("sta", "Stamina", 0, 3), ("man", "Mana", 0, 5), + }; + + private readonly IltHubContext _ctx; + private readonly Dictionary _augLevels = new(StringComparer.OrdinalIgnoreCase); + private volatile string _augStatus = "not loaded"; + // Opening the Progression tab pulls "/aug" once per login when nothing has loaded the levels yet. + private bool _augAutoTried; + + // Cached player facts for the render thread (refreshed in Tick). + private volatile int _enl, _level, _freeSlots; + private long _unassignedXp; + private volatile bool _peace, _hasVitae; + private readonly long[] _enlHave = new long[4]; // tokens, medallions, sigils, crests + // 301-325 sigil chain stock (pack items by name; EnlightenedCoins = bank + pack). Pump thread only. + private IltSigilStock _chain = new(); + private long _lastFactsAt; + private readonly uint[] _enchIds = new uint[256]; + private readonly double[] _enchExp = new double[256]; + + // Auto-enlighten (armed only after the in-session confirm). + private bool _autoArmed; + private long _lastAutoCheck; + private long _lastEnlSentAt = -AutoEnlCooldownMs; + private volatile string _enlStatus = string.Empty; + + // XP spend-before-enlighten loop. + private bool _spending; + private int _spendIdx, _spendSent, _spendNoProgress; + private long _spendLastAt, _spendLastXp; + private Action? _afterSpend; + + /// Infinite-attribute raiser (Progression tab "Attribute raiser" section). + public IltAttributeRaiser Attributes { get; } + + public IltProgression(IltHubContext ctx) + { + _ctx = ctx; + // Never two /attr spenders at once: the raiser waits while the spend-before-/enl loop runs. + Attributes = new IltAttributeRaiser(ctx) { HoldOff = () => _spending }; + } + + private IltCharacterState C => _ctx.State.Character; + + // ── Commands ──────────────────────────────────────────────────────────── + + public void RequestAugs() + { + RynthLog.Trace(LogCat.IltProgression, $"RequestAugs()"); + if (_ctx.Options.IsOff(IltFeature.Aug) || _ctx.Capture.IsPending("/aug")) return; + _augStatus = "loading..."; + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = "/aug", + IsResponseLine = t => t.StartsWith("---") || t.Contains("Augmentation Levels", StringComparison.OrdinalIgnoreCase) || IltParse.AugLine.IsMatch(t), + IdleEndMs = 2000, + FirstLineTimeoutMs = 15000, + Eat = true, + OnComplete = r => + { + if (r.UnknownCommand) { _ctx.Options.Set(IltFeature.Aug, IltTri.Off); _augStatus = "/aug not available"; return; } + ApplyAugLines(r.Lines); + }, + }); + } + + /// Parses "/aug" output (also fed from the login probe). + public void ApplyAugLines(List lines) + { + RynthLog.Trace(LogCat.IltProgression, $"ApplyAugLines(lines={lines.Count})"); + int n = 0; + foreach (string l in lines) + { + var m = IltParse.AugLine.Match(l.Trim()); + if (!m.Success) continue; + string key = m.Groups[1].Value.ToLowerInvariant(); + if (key == "specialize") key = "specialization"; + lock (_augLevels) _augLevels[key] = (int)IltParse.ParseLeadingLong(m.Groups[2].Value); + n++; + } + _augStatus = n > 0 ? $"{n} aug types @ {DateTime.Now:t}" : "no aug lines in reply"; + } + + /// Sends "/enl" (server shows the confirmation dialog). Pump thread. + public void SendEnlighten(string why) + { + RynthLog.Trace(LogCat.IltProgression, $"SendEnlighten(why='{why}')"); + if (!_ctx.Host.HasInvokeChatParser) return; + _lastEnlSentAt = IltHubContext.NowMs; + _ctx.Host.InvokeChatParser("/enl"); + _enlStatus = $"/enl sent ({why}) - click Yes in the AC dialog to confirm."; + _ctx.Chat("[Mini Remote] " + _enlStatus); + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + if (nowMs - _lastFactsAt >= 2000) + { + _lastFactsAt = nowMs; + RefreshFacts(); + } + TickSpend(nowMs); + Attributes.Tick(nowMs, holdOff: _spending); + + if (_autoArmed && C.AutoEnlightenEnabled && !_spending + && nowMs - _lastAutoCheck >= Math.Max(10, C.AutoEnlightenCheckSeconds) * 1000L) + { + _lastAutoCheck = nowMs; + TryAutoEnlighten(nowMs); + } + } + + public bool OnChat(string text) + { + Attributes.OnChat(text); + if (text.Contains("You have become enlightened", StringComparison.OrdinalIgnoreCase) + || text.Contains("You have risen to a higher tier of enlightenment", StringComparison.OrdinalIgnoreCase)) + { + _enlStatus = "Enlightened! " + DateTime.Now.ToString("t"); + _lastFactsAt = 0; + } + return false; + } + + public void OnLogout() + { + _autoArmed = false; + _spending = false; + Attributes.OnLogout(); + lock (_augLevels) _augLevels.Clear(); + _augAutoTried = false; + _augStatus = "not loaded"; + } + + // ── Facts / auto ──────────────────────────────────────────────────────── + + private void RefreshFacts() + { + var inv = _ctx.Inventory; + _enl = inv.PlayerInt(IltInventory.IntEnlightenment); + _level = inv.PlayerInt(IltInventory.IntLevel); + _unassignedXp = inv.PlayerQuad(IltInventory.QuadAvailableXp); + _peace = inv.InPeaceMode; + _freeSlots = inv.FreeMainPackSlots(); + _enlHave[0] = inv.CountByWcid(IltInventory.WcidEnlToken); + _enlHave[1] = inv.CountByWcid(IltInventory.WcidEnlMedallion); + _enlHave[2] = inv.CountByWcid(IltInventory.WcidEnlSigil); + _enlHave[3] = inv.CountByWcid(IltInventory.WcidEnlCrest); + _chain = new IltSigilStock + { + Sigils = _enlHave[2], + EnlightenedCoins = _ctx.State.Bank.EnlightenedCoins + inv.CountByWcid(IltInventory.WcidEnlightenedCoin), + AscensionCoins = inv.CountByChainName(IltSigilChain.AscensionCoin), + LifebloodElixirs = inv.CountByChainName(IltSigilChain.LifebloodElixir), + LifebloomResins = inv.CountByChainName(IltSigilChain.LifebloomResin), + YalaniTrinkets = inv.CountByChainName(IltSigilChain.YalaniTrinket), + NecrolyticExtracts = inv.CountByChainName(IltSigilChain.NecrolyticExtract), + LifeSplitters = inv.CountByChainName(IltSigilChain.LifeSplitter), + Plants = inv.CountByChainName(IltSigilChain.Plant), + }; + + _hasVitae = false; + if (_ctx.Host.HasReadPlayerEnchantments) + { + int n = _ctx.Host.ReadPlayerEnchantments(_enchIds, _enchExp, _enchIds.Length); + for (int i = 0; i < Math.Min(n, _enchIds.Length); i++) + if (_enchIds[i] == SpellVitae) { _hasVitae = true; break; } + } + } + + private long HaveFor(uint wcid) => wcid switch + { + IltInventory.WcidEnlToken => _enlHave[0], + IltInventory.WcidEnlMedallion => _enlHave[1], + IltInventory.WcidEnlSigil => _enlHave[2], + IltInventory.WcidEnlCrest => _enlHave[3], + _ => 0, + }; + + /// Checks the client-visible requirements for the next enlightenment. Empty = ready. + private List NextEnlBlockers() + { + var list = new List(); + int next = _enl + 1; + if (_level < BaseLevelForEnl + _enl) list.Add($"Need character level {BaseLevelForEnl + _enl} (have {_level})."); + if (!_peace) list.Add("Must be in peace mode."); + if (_hasVitae) list.Add("Must not have vitae."); + var cost = EnlStepCost(next); + if (cost.Count > 0 && HaveFor(cost.Wcid) < cost.Count) + { + // Sigils: the server takes finished sigils only, but say how many the craft chain could still make. + string craft = cost.Wcid == IltInventory.WcidEnlSigil + ? $"; the craft chain can make {IltParse.N0(IltSigilChain.Fulfillable(_chain) - _chain.Sigils)} more" + : string.Empty; + list.Add($"Need {cost.Count} {cost.Item} (have {HaveFor(cost.Wcid)}{craft})."); + } + if (cost.Lum > 0 && _ctx.State.Bank.Luminance < cost.Lum) list.Add($"Need {IltParse.Compact((double)cost.Lum)} banked luminance."); + return list; + } + + private void TryAutoEnlighten(long now) + { + if (_ctx.Options.IsOff(IltFeature.Enl)) return; + if (Attributes.Running) return; // the raiser is spending XP; check again next interval + if (now - _lastEnlSentAt < AutoEnlCooldownMs) return; + if (NextEnlBlockers().Count > 0) return; + if (C.AutoEnlightenSpendXpFirst && _unassignedXp > 0) + StartSpend(() => SendEnlighten("auto")); + else + SendEnlighten("auto"); + } + + // ── XP spend loop: cycles /attr 1 until unassigned XP stops dropping ── + + private void StartSpend(Action then) + { + _spending = true; + _spendIdx = 0; + _spendSent = 0; + _spendNoProgress = 0; + _spendLastAt = 0; + _spendLastXp = _ctx.Inventory.PlayerQuad(IltInventory.QuadAvailableXp); + _afterSpend = then; + _enlStatus = "Spending unassigned XP before enlightening..."; + } + + private void TickSpend(long now) + { + if (!_spending || now - _spendLastAt < 300) return; + _spendLastAt = now; + + long xp = _ctx.Inventory.PlayerQuad(IltInventory.QuadAvailableXp); + if (xp < _spendLastXp) _spendNoProgress = 0; else if (_spendSent > 0) _spendNoProgress++; + _spendLastXp = xp; + + // Stop after a full stat cycle with no XP drop, when XP is gone, or at the safety cap. + if (xp <= 0 || _spendNoProgress >= Stats.Length || _spendSent >= 300) + { + _spending = false; + var next = _afterSpend; + _afterSpend = null; + next?.Invoke(); + return; + } + if (_ctx.Inventory.IsBusy) return; + _ctx.Host.InvokeChatParser($"/attr {Stats[_spendIdx].Abbr} 1"); + _spendIdx = (_spendIdx + 1) % Stats.Length; + _spendSent++; + } + + // ── Engine Skills panel bridge (pump thread) ──────────────────────────── + // The engine's Skills panel draws Augmentations and Enlightenment from this snapshot and + // sends edits back as "prog ..." remote commands (HandleRemote). Planner math stays here so + // the Hub and the Skills panel can never disagree. Numbers are preformatted for display. + + /// Appends "aug":{...},"enl":{...},"attr":{...} to . Pump thread. + public void AppendSnapshotJson(StringBuilder sb) + { + // The snapshot is only polled while the Progression tab is open, so this is "on first view". + EnsureAugs(); + Attributes.EnsureCosts(); + AppendAugJson(sb); + sb.Append(','); + AppendEnlJson(sb); + sb.Append(','); + Attributes.AppendJson(sb); + } + + /// Pulls "/aug" once per login when the levels haven't been loaded (login probe or by hand). + private void EnsureAugs() + { + if (_augAutoTried || _ctx.Options.IsOff(IltFeature.Aug) || !_ctx.Host.HasInvokeChatParser) return; + bool loaded; + lock (_augLevels) loaded = _augLevels.Count > 0; + _augAutoTried = true; + if (!loaded) RequestAugs(); + } + + /// One aug's plan line: current level, clamped target, luminance and coins to get there. + private readonly record struct AugPlan(IltAugCostRow Def, string Label, int Cur, int Tgt, int Ceiling, decimal Lum, long Coins) + { + public int Inc => Tgt - Cur; + } + + private List BuildAugPlan() + { + Dictionary levels; + lock (_augLevels) levels = new Dictionary(_augLevels, StringComparer.OrdinalIgnoreCase); + var profile = AugProfile; + var plan = new List(profile.Augs.Count); + foreach (var a in profile.Augs) + { + int cur = levels.TryGetValue(a.Key, out int c) ? c : 0; + int ceiling = IltAugCosts.Ceiling(a, cur); + int tgt = Math.Clamp(C.AugTargets.TryGetValue(a.Key, out int t) ? t : cur, cur, ceiling); + plan.Add(new AugPlan(a, IltAugCosts.Label(a.Key), cur, tgt, ceiling, + IltAugCosts.LumCost(a, profile.Multipliers, cur, tgt), (long)(tgt - cur) * a.CoinsPerLevel)); + } + return plan; + } + + private void AppendAugJson(StringBuilder sb) + { + var plan = BuildAugPlan(); + + sb.Append("\"aug\":{\"off\":").Append(Bool(_ctx.Options.IsOff(IltFeature.Aug))); + Str(sb, "status", _augStatus); + sb.Append(",\"lumPerCoin\":").Append(C.LumPerEnlightenedCoin).Append(",\"rows\":["); + for (int i = 0; i < plan.Count; i++) + { + var p = plan[i]; + if (i > 0) sb.Append(','); + sb.Append('{'); + Str(sb, "key", p.Def.Key, first: true); + Str(sb, "label", p.Label); + sb.Append(",\"cur\":").Append(p.Cur).Append(",\"tgt\":").Append(p.Tgt).Append(",\"cap\":").Append(p.Ceiling) + .Append(",\"inc\":").Append(p.Inc); + Str(sb, "lum", p.Lum > 0 ? IltParse.Compact((double)p.Lum) : "-"); + sb.Append(",\"coins\":").Append(p.Coins).Append('}'); + } + sb.Append(']'); + + decimal totalLum = plan.Sum(p => p.Lum); + long totalCoins = plan.Sum(p => p.Coins); + long bankCoins = _ctx.State.Bank.EnlightenedCoins; + long lumPerCoin = C.LumPerEnlightenedCoin; + long coinsShort = Math.Max(0, totalCoins - bankCoins); + + // Totals row (UB's TOTALS line) and the e-coin summary under the table. + sb.Append(",\"totCur\":").Append(plan.Sum(p => p.Cur)) + .Append(",\"totTgt\":").Append(plan.Sum(p => p.Tgt)) + .Append(",\"totInc\":").Append(plan.Sum(p => p.Inc)) + .Append(",\"totCoins\":").Append(totalCoins); + Str(sb, "totLum", totalLum > 0 ? IltParse.Compact((double)totalLum) : "-"); + Str(sb, "coinsLine", $"E-coins needed: {IltParse.N0(totalCoins)} banked: {IltParse.N0(bankCoins)} short: {IltParse.N0(coinsShort)}"); + Str(sb, "lumToBuy", coinsShort == 0 ? "Lum to buy e-coins: none needed" + : lumPerCoin > 0 ? $"Lum to buy e-coins: ~{IltParse.Compact((double)coinsShort * lumPerCoin)}" + : "Lum to buy e-coins: set Lum per coin"); + // Older engine builds read these three. + Str(sb, "total", $"Total: {IltParse.Compact((double)totalLum)} luminance, {IltParse.N0(totalCoins)} coins"); + Str(sb, "short", coinsShort > 0 + ? $"Coins short: {IltParse.N0(coinsShort)}" + (lumPerCoin > 0 ? $" (~{IltParse.Compact((double)coinsShort * lumPerCoin)} luminance to buy)" : "") + : string.Empty); + Str(sb, "banked", $"Banked luminance: {IltParse.Compact(_ctx.State.Bank.Luminance)}"); + Str(sb, "copyDiscord", AugDiscordText(plan)); + Str(sb, "copyIngame", AugIngameText(plan)); + AppendAugCostJson(sb); + sb.Append('}'); + } + + /// "cfg":{...}: this world's cost rules for the "Cost settings" editor. + private void AppendAugCostJson(StringBuilder sb) + { + string world = _ctx.Options.WorldName; + var p = AugProfile; + var inv = System.Globalization.CultureInfo.InvariantCulture; + sb.Append(",\"cfg\":{"); + Str(sb, "world", world.Length > 0 ? world : "unknown world", first: true); + sb.Append(",\"custom\":").Append(Bool(AugCosts.IsCustom(world))).Append(",\"mults\":["); + for (int i = 0; i < p.Multipliers.Length; i++) + sb.Append(i > 0 ? "," : "").Append(p.Multipliers[i].ToString("R", inv)); + sb.Append("],\"rows\":["); + for (int i = 0; i < p.Augs.Count; i++) + { + var r = p.Augs[i]; + if (i > 0) sb.Append(','); + sb.Append('{'); + Str(sb, "key", r.Key, first: true); + Str(sb, "label", IltAugCosts.Label(r.Key)); + sb.Append(",\"base\":").Append(r.Base) + .Append(",\"pct\":").Append(r.LinearPercent.ToString("R", inv)) + .Append(",\"coins\":").Append(r.CoinsPerLevel) + .Append(",\"s1\":").Append(r.S1).Append(",\"s2\":").Append(r.S2) + .Append(",\"s3\":").Append(r.S3).Append(",\"s4\":").Append(r.S4) + .Append(",\"cap\":").Append(r.Cap).Append('}'); + } + sb.Append("]}"); + } + + /// "augcfg <aug> <field> <value>": one cost-rule edit for this world. + private void EditAugRule(string key, string field, string value) + { + var inv = System.Globalization.CultureInfo.InvariantCulture; + bool isInt = int.TryParse(value, System.Globalization.NumberStyles.Integer, inv, out int iv); + bool isNum = double.TryParse(value, System.Globalization.NumberStyles.Float, inv, out double dv); + long amount = 0; + bool isAmount = field == "base" && IltParse.TryParseAmount(value, out amount); + if (!isInt && !isNum && !isAmount) return; + AugCosts.Edit(_ctx.Options.WorldName, p => + { + var r = p.Augs.FirstOrDefault(x => x.Key.Equals(key, StringComparison.OrdinalIgnoreCase)); + if (r == null) return; + switch (field) + { + case "base": if (isAmount) r.Base = amount; break; + case "pct": if (isNum) r.LinearPercent = dv; break; + case "coins": if (isInt) r.CoinsPerLevel = iv; break; + case "s1": if (isInt) r.S1 = iv; break; + case "s2": if (isInt) r.S2 = iv; break; + case "s3": if (isInt) r.S3 = iv; break; + case "s4": if (isInt) r.S4 = iv; break; + case "cap": if (isInt) r.Cap = iv; break; + } + }); + } + + /// + /// UB's "Copy Discord" table in a code block. ASCII only: the engine reads the snapshot as ANSI. + /// + private string AugDiscordText(List plan) + { + string name = string.IsNullOrEmpty(_ctx.CharName) ? "character" : _ctx.CharName; + string rule = new('-', 56); + var t = new StringBuilder(); + t.Append("```\n").Append("Augmentations - ").Append(name).Append('\n').Append(rule).Append('\n'); + t.Append($"{"Type",-15} {"Current",-8} {"Target",-8} {"Inc",-5} {"Lum Cost",-10} {"Coins",-6}\n").Append(rule).Append('\n'); + foreach (var p in plan) + { + if (p.Cur <= 0 && p.Tgt <= 0) continue; + string lum = p.Lum > 0 ? IltParse.Compact((double)p.Lum) : "-"; + t.Append($"{p.Label,-15} {p.Cur,-8} {p.Tgt,-8} {p.Inc,-5} {lum,-10} {p.Coins,-6}\n"); + } + decimal totalLum = plan.Sum(p => p.Lum); + t.Append(rule).Append('\n'); + t.Append($"{"TOTALS:",-15} {plan.Sum(p => p.Cur),-8} {plan.Sum(p => p.Tgt),-8} {plan.Sum(p => p.Inc),-5} " + + $"{(totalLum > 0 ? IltParse.Compact((double)totalLum) : "-"),-10} {plan.Sum(p => p.Coins),-6}\n"); + t.Append("```"); + return t.ToString(); + } + + /// UB's "Copy In-Game": one line of current levels with short names, for pasting into chat. + private string AugIngameText(List plan) + { + string name = string.IsNullOrEmpty(_ctx.CharName) ? "character" : _ctx.CharName; + var parts = plan.Where(p => p.Cur > 0).Select(p => $"{AugShortName(p.Def.Key)}: {IltParse.N0(p.Cur)}").ToList(); + return parts.Count == 0 + ? $"Augmentation Levels - {name}: none loaded" + : $"Augmentation Levels - {name} ({IltParse.N0(plan.Sum(p => p.Cur))} total): {string.Join(", ", parts)}"; + } + + private static string AugShortName(string key) => key switch + { + "creature" => "Crit", + "duration" => "Dur", + "specialization" => "Spec", + "summon" => "Sum", + "melee" => "Mel", + "missile" => "Mis", + _ => char.ToUpperInvariant(key[0]) + key.Substring(1), + }; + + private void AppendEnlJson(StringBuilder sb) + { + int enl = _enl; + sb.Append("\"enl\":{\"off\":").Append(Bool(_ctx.Options.IsOff(IltFeature.Enl))); + Str(sb, "header", $"Enlightenment {enl} Level {_level} Unassigned XP {IltParse.Compact(_unassignedXp)}"); + var next = EnlStepCost(enl + 1); + Str(sb, "next", $"Next ({enl + 1}): " + (next.Count > 0 + ? $"{next.Count} {next.Item} (have {HaveFor(next.Wcid)})" + (next.Lum > 0 ? $" + {IltParse.Compact((double)next.Lum)} lum" : "") + : "no materials")); + + int target = C.EnlTargetLevel <= enl ? enl + 5 : C.EnlTargetLevel; + sb.Append(",\"enl\":").Append(enl).Append(",\"target\":").Append(target).Append(",\"plan\":["); + var totals = new Dictionary(); + decimal lumTotal = 0; + for (int t = enl + 1; t <= Math.Max(enl + 1, target) && t <= enl + 500; t++) + { + var s = EnlStepCost(t); + if (s.Count > 0) totals[s.Item] = (totals.TryGetValue(s.Item, out long v) ? v : 0) + s.Count; + lumTotal += s.Lum; + } + bool firstLine = true; + foreach (var kv in totals) { StrItem(sb, $"{IltParse.N0(kv.Value)} {kv.Key}", ref firstLine); } + if (lumTotal > 0) + StrItem(sb, $"{IltParse.Compact((double)lumTotal)} luminance (banked {IltParse.Compact(_ctx.State.Bank.Luminance)})", ref firstLine); + sb.Append(']'); + + int coinsPerToken = C.EnlightenedCoinsPerToken; + sb.Append(",\"coinsPerToken\":").Append(coinsPerToken); + string tokensShort = string.Empty; + if (totals.TryGetValue("Enlightenment Tokens", out long tokNeed) && coinsPerToken > 0) + { + long shortTok = Math.Max(0, tokNeed - _enlHave[0]); + if (shortTok > 0) tokensShort = $"Tokens short: {shortTok} (~{IltParse.N0(shortTok * coinsPerToken)} coins)"; + } + Str(sb, "tokensShort", tokensShort); + + AppendEnlCalculatorJson(sb, enl, target, totals, lumTotal); + + var blockers = NextEnlBlockers(); + sb.Append(",\"blockers\":["); + bool firstBlocker = true; + foreach (string b in blockers) StrItem(sb, b, ref firstBlocker); + sb.Append(']'); + Str(sb, "serverChecks", $"Server also checks: not in a dungeon, free pack slots ({(_freeSlots >= 0 ? _freeSlots.ToString() : "?")} free), " + + "all luminance augs (past 10), society master (past 30)."); + sb.Append(",\"auto\":").Append(Bool(C.AutoEnlightenEnabled)) + .Append(",\"armed\":").Append(Bool(_autoArmed)) + .Append(",\"spendFirst\":").Append(Bool(C.AutoEnlightenSpendXpFirst)) + .Append(",\"checkEvery\":").Append(C.AutoEnlightenCheckSeconds); + Str(sb, "status", _enlStatus); + sb.Append('}'); + } + + /// Per-level rows the calculator lists at most (a bigger range is summarised in the totals). + private const int EnlLevelRowsMax = 100; + + /// + /// UB-IT's Enlighten calculator: per-level table (green while stock lasts, the sigil chain counted), + /// material summary (still need / have), the 301-325 sigil chain, and the e-coin line shared with + /// token conversion. Appends "levels", "materials", "chain", "chainNote", "ecoins", "ecoinsLum". + /// + private void AppendEnlCalculatorJson(StringBuilder sb, int enl, int target, Dictionary totals, decimal lumTotal) + { + // Simulated stock: tokens, medallions, crests on hand, sigils via the chain, banked luminance. + long tok = _enlHave[0], med = _enlHave[1], crest = _enlHave[3]; + decimal lum = (decimal)_ctx.State.Bank.Luminance; + var chain = _chain.Clone(); + long sigilCraftable = IltSigilChain.Fulfillable(chain); + + sb.Append(",\"levels\":["); + int last = Math.Min(Math.Max(enl + 1, target), enl + EnlLevelRowsMax); + for (int t = enl + 1; t <= last; t++) + { + var s = EnlStepCost(t); + bool ok = lum >= s.Lum; + if (ok && s.Count > 0) + { + switch (s.Wcid) + { + case IltInventory.WcidEnlToken: ok = tok >= s.Count; if (ok) tok -= s.Count; break; + case IltInventory.WcidEnlMedallion: ok = med >= s.Count; if (ok) med -= s.Count; break; + case IltInventory.WcidEnlSigil: ok = sigilCraftable >= s.Count; if (ok) sigilCraftable -= s.Count; break; + default: ok = crest >= s.Count; if (ok) crest -= s.Count; break; + } + } + if (ok) lum -= s.Lum; + if (t > enl + 1) sb.Append(','); + sb.Append("{\"t\":").Append(t); + Str(sb, "item", ShortItem(s.Item)); + sb.Append(",\"count\":").Append(s.Count); + Str(sb, "lum", s.Lum > 0 ? IltParse.Compact((double)s.Lum) : "-"); + sb.Append(",\"ok\":").Append(Bool(ok)).Append('}'); + } + sb.Append(']'); + + // Material summary: Still need = demand minus what is on hand. + long sigilsNeed = totals.TryGetValue("Enlightenment Sigils", out long sn) ? sn : 0; + var shortfall = IltSigilChain.Shortfall(sigilsNeed, _chain); + decimal bankLum = (decimal)_ctx.State.Bank.Luminance; + sb.Append(",\"materials\":["); + bool firstMat = true; + void Mat(string label, string need, string have, bool ok) + { + if (!firstMat) sb.Append(','); + firstMat = false; + sb.Append('{'); + Str(sb, "label", label, first: true); + Str(sb, "need", need); + Str(sb, "have", have); + sb.Append(",\"ok\":").Append(Bool(ok)).Append('}'); + } + if (lumTotal > 0) + { + decimal lumStill = Math.Max(0, lumTotal - bankLum); + Mat("Luminance", lumStill > 0 ? IltParse.Compact((double)lumStill) : "0", IltParse.Compact((double)bankLum), lumStill == 0); + } + void Item(string key, string label, long have, bool extraOk = false) + { + if (!totals.TryGetValue(key, out long need)) return; + long still = Math.Max(0, need - have); + Mat(label, IltParse.N0(still), IltParse.N0(have), still == 0 || extraOk); + } + Item("Enlightenment Tokens", "Tokens", _enlHave[0]); + Item("Enlightenment Medallions", "Medallions", _enlHave[1]); + Item("Enlightenment Sigils", "Sigils", _enlHave[2], extraOk: shortfall.Covered); + Item("Enlightenment Crests", "Crests", _enlHave[3]); + sb.Append(']'); + + // Sigil chain rows (only when the plan reaches 301-325). + sb.Append(",\"chain\":["); + if (sigilsNeed > 0) + { + bool firstRow = true; + void Row(string label, long need, long have, bool ok, bool craft) + { + if (!firstRow) sb.Append(','); + firstRow = false; + sb.Append('{'); + Str(sb, "label", label, first: true); + sb.Append(",\"need\":").Append(need).Append(",\"have\":").Append(have) + .Append(",\"ok\":").Append(Bool(ok)).Append(",\"craft\":").Append(Bool(craft)).Append('}'); + } + Row("Ascension Coins", shortfall.AscensionToCraft, _chain.AscensionCoins, + shortfall.AscensionToCraft == 0 || (shortfall.CoinsShort == 0 && shortfall.TrinketsShort == 0), true); + Row("Lifeblood Elixirs", shortfall.ElixirsToCraft, _chain.LifebloodElixirs, + shortfall.ElixirsToCraft == 0 || (shortfall.ExtractsShort == 0 && shortfall.SplittersShort == 0 && shortfall.PlantsShort == 0), true); + Row("Lifebloom Resins", shortfall.ResinsToCraft, _chain.LifebloomResins, + shortfall.ResinsToCraft == 0 || (shortfall.SplittersShort == 0 && shortfall.PlantsShort == 0), true); + Row("E-coins", shortfall.CoinsShort, _chain.EnlightenedCoins, shortfall.CoinsShort == 0, false); + Row("Ancient Yalani Trinkets", shortfall.TrinketsShort, _chain.YalaniTrinkets, shortfall.TrinketsShort == 0, false); + Row("Necrolytic Extracts", shortfall.ExtractsShort, _chain.NecrolyticExtracts, shortfall.ExtractsShort == 0, false); + Row("Life Splitters", shortfall.SplittersShort, _chain.LifeSplitters, shortfall.SplittersShort == 0, false); + Row("Plants", shortfall.PlantsShort, _chain.Plants, shortfall.PlantsShort == 0, false); + } + sb.Append(']'); + Str(sb, "chainNote", sigilsNeed > 0 + ? $"Sigil = Lifeblood Elixir + Ascension Coin. {IltParse.N0(shortfall.SigilsToCraft)} to craft; " + + (shortfall.Covered ? "the chain covers them." : "Need = crafts left (in-between items) or mats to get (raw items).") + : string.Empty); + + // E-coins: Ascension Coin crafts first, then token conversion at the shop price. + long tokNeed = totals.TryGetValue("Enlightenment Tokens", out long tn) ? tn : 0; + IltSigilChain.EcoinDemand(_chain.EnlightenedCoins, shortfall.CoinsForCraft, Math.Max(0, tokNeed - _enlHave[0]), + C.EnlightenedCoinsPerToken, out _, out long tokensStill, out long coinsNeeded); + Str(sb, "ecoins", tokNeed > 0 || shortfall.CoinsForCraft > 0 + ? $"E-coins needed: {IltParse.N0(coinsNeeded)} have {IltParse.N0(_chain.EnlightenedCoins)} (bank + pack)" + + (shortfall.CoinsForCraft > 0 ? $" Ascension Coins use {IltParse.N0(shortfall.CoinsForCraft)}" : "") + + (tokensStill > 0 ? $" tokens still {IltParse.N0(tokensStill)}" : "") + : string.Empty); + long lumPerCoin = C.LumPerEnlightenedCoin; + Str(sb, "ecoinsLum", coinsNeeded <= 0 ? string.Empty + : lumPerCoin > 0 ? $"Lum to buy e-coins: ~{IltParse.Compact((double)coinsNeeded * lumPerCoin)}" + : "Lum to buy e-coins: set Lum per e-coin (Augmentations)"); + } + + /// Short label for the per-level table's item column. + private static string ShortItem(string item) => item switch + { + "Enlightenment Tokens" => "Tokens", + "Enlightenment Medallions" => "Medallions", + "Enlightenment Sigils" => "Sigils", + "Enlightenment Crests" => "Crests", + _ => "-", + }; + + private static string Bool(bool b) => b ? "true" : "false"; + + private static void Str(StringBuilder sb, string name, string value, bool first = false) + { + if (!first) sb.Append(','); + sb.Append('"').Append(name).Append("\":\"").Append(RynthAiPlugin.JsonEscape(value ?? string.Empty)).Append('"'); + } + + private static void StrItem(StringBuilder sb, string value, ref bool first) + { + if (!first) sb.Append(','); + first = false; + sb.Append('"').Append(RynthAiPlugin.JsonEscape(value)).Append('"'); + } + + /// + /// "prog" remote command from the engine Skills panel. Pump thread. The panel asks its own + /// confirmation before "enlighten" and "autoenl on|arm", so none is asked here. + /// + public void HandleRemote(string[] a) + { + if (a.Length == 0) return; + RynthLog.Trace(LogCat.IltProgression, $"HandleRemote({string.Join(" ", a)})"); + string arg1 = a.Length > 1 ? a[1] : string.Empty; + int.TryParse(a.Length > 2 ? a[2] : arg1, out int n); + string verb = a[0].ToLowerInvariant(); + if (verb.StartsWith("attr", StringComparison.Ordinal) && Attributes.HandleRemote(verb, a)) return; + switch (verb) + { + case "augload": RequestAugs(); break; + case "augreset": + // UB's "Reset Target": every target back to the current level. + lock (_augLevels) + foreach (var (key, _) in IltAugCosts.Labels) + C.AugTargets[key] = _augLevels.TryGetValue(key, out int c) ? c : 0; + break; + case "augtarget" when a.Length > 2: + foreach (var def in AugProfile.Augs) + { + if (!def.Key.Equals(arg1, StringComparison.OrdinalIgnoreCase)) continue; + int cur; + lock (_augLevels) cur = _augLevels.TryGetValue(def.Key, out int c) ? c : 0; + C.AugTargets[def.Key] = Math.Clamp(n, 0, IltAugCosts.Ceiling(def, cur)); + break; + } + break; + case "augmult" when a.Length > 2: + // "augmult ": tier 0 is below S1, tier 4 is from S4 on. + if (int.TryParse(arg1, out int tier) && tier is >= 0 and <= 4 + && double.TryParse(a[2], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out double mult)) + AugCosts.Edit(_ctx.Options.WorldName, p => p.Multipliers[tier] = mult); + break; + case "augcfg" when a.Length > 3: + EditAugRule(arg1, a[2].ToLowerInvariant(), a[3]); + break; + case "augcfgreset": + AugCosts.Reset(_ctx.Options.WorldName); + break; + case "lumpercoin": + if (IltParse.TryParseAmount(arg1, out long lpc)) C.LumPerEnlightenedCoin = Math.Max(0, lpc); + break; + case "enltarget": C.EnlTargetLevel = Math.Max(_enl + 1, n); break; + case "coinspertoken": C.EnlightenedCoinsPerToken = Math.Max(0, n); break; + case "enlighten": SendEnlighten("manual, Skills panel"); break; + case "autoenl": + switch (arg1.ToLowerInvariant()) + { + case "on": + C.AutoEnlightenEnabled = true; + _autoArmed = true; + _ctx.Chat("[Mini Remote] Auto-enlighten armed for this session."); + break; + case "arm": if (C.AutoEnlightenEnabled) _autoArmed = true; break; + default: C.AutoEnlightenEnabled = false; _autoArmed = false; break; + } + break; + case "spendfirst": C.AutoEnlightenSpendXpFirst = arg1.Equals("on", StringComparison.OrdinalIgnoreCase); break; + case "checkevery": C.AutoEnlightenCheckSeconds = Math.Max(10, n); break; + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltQuests.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltQuests.cs new file mode 100644 index 0000000..f9760c3 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltQuests.cs @@ -0,0 +1,456 @@ +// IltQuests.cs — Quest Tracker UI and Quest Bonus (/qb) list for the ILT Hub Character tab. +// +// Quest Tracker reuses the meta QuestTracker (the same /myquests cache the meta +// expression engine reads) — it never runs a second parser. Friendly names come from: +// 1. an optional user-supplied quests.xml (\RynthAi\quests.xml), +// 2. the description the server prints in /myquests, +// 3. the raw flag key. +// UB's bundled quests.xml is NOT embedded (no license on UB content). +// +// QB: "/qb list" prints a completed and an incomplete section; both are tracked +// separately (UB merged them). Server throttles /qb to once per minute. +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Numerics; +using System.Text.RegularExpressions; +using System.Xml; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.RynthAi.Meta; +using RynthCore.Install; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltQuests : IIltFeature +{ + /// Optional user quest-name file (UB-style or simple key/name XML). + public static readonly string QuestsXmlPath = System.IO.Path.Combine(RynthInstallPaths.RynthAiDir, @"quests.xml"); + + private static readonly Regex KillTaskRegex = new(@"(killtask|killcount|slayerquest|totalgolem.*dead|(kills$))", + RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + private static readonly Regex QbFlagLine = new(@"^[a-zA-Z0-9_\-!@\(\)?]+$", RegexOptions.Compiled | RegexOptions.CultureInvariant); + + private const long QuestRefreshCooldownMs = 60_000; + private const long QbCooldownMs = 60_000; + + private readonly IltHubContext _ctx; + private readonly Func _tracker; + private Dictionary _friendlyNames = new(StringComparer.OrdinalIgnoreCase); + private long _lastQuestRefreshAt = -QuestRefreshCooldownMs; + private long _lastQbAt = -QbCooldownMs; + + // QB results (replaced wholesale; read by the render thread). + private volatile string[] _qbCompleted = Array.Empty(); + private volatile string[] _qbIncomplete = Array.Empty(); + private volatile string _qbStatus = "not loaded"; + private long _qbCount = -1; + private volatile int _qbGeneration; // bumped per successful "/qb list"; 0 = never loaded this session + // Render-thread UI state. + private int _questView; // 0 timed, 1 kill tasks, 2 once, 3 all + + public IltQuests(IltHubContext ctx, Func tracker) + { + _ctx = ctx; + _tracker = tracker; + LoadFriendlyNames(); + } + + public enum QuestKind { Timed, KillTask, Once } + + public static QuestKind Classify(QuestRecord r) + { + if (KillTaskRegex.IsMatch(r.Key) && r.MaxSolves >= 0) return QuestKind.KillTask; + if (r.MaxSolves == 1 && r.Solves <= 1) return QuestKind.Once; + return QuestKind.Timed; + } + + public string FriendlyName(QuestRecord r) + { + if (_friendlyNames.TryGetValue(r.Key, out string? n) && !string.IsNullOrWhiteSpace(n)) return n; + if (!string.IsNullOrWhiteSpace(r.Description)) return r.Description; + return r.Key; + } + + // ── quests.xml (optional) ─────────────────────────────────────────────── + + /// Reads any element carrying a key/flag attribute plus a name/description. + public void LoadFriendlyNames() + { + var map = new Dictionary(StringComparer.OrdinalIgnoreCase); + try + { + if (File.Exists(QuestsXmlPath)) + { + using var reader = XmlReader.Create(QuestsXmlPath, new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, IgnoreComments = true }); + while (reader.Read()) + { + if (reader.NodeType != XmlNodeType.Element || !reader.HasAttributes) continue; + string? key = null, name = null; + while (reader.MoveToNextAttribute()) + { + string a = reader.Name.ToLowerInvariant(); + if (a is "key" or "flag" or "questflag" or "id") key = reader.Value; + else if (a is "name" or "description" or "title" or "friendlyname") name ??= reader.Value; + } + reader.MoveToElement(); + if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(name)) + map[key.Trim().ToLowerInvariant()] = name.Trim(); + } + } + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltQuests, ex, "quests.xml load"); } + _friendlyNames = map; + } + + // ── Commands ──────────────────────────────────────────────────────────── + + /// Quiet /myquests refresh with a 60 s client-side cooldown (server throttle). + public string RefreshQuests() + { + RynthLog.Trace(LogCat.IltQuests, $"RefreshQuests()"); + var t = _tracker(); + if (t == null) return "Quest tracker not ready."; + if (_ctx.Options.IsOff(IltFeature.Quests) || t.Disabled) return "/myquests is disabled on this server."; + long now = IltHubContext.NowMs; + if (now - _lastQuestRefreshAt < QuestRefreshCooldownMs) + return $"Wait {(QuestRefreshCooldownMs - (now - _lastQuestRefreshAt)) / 1000}s (server allows one /myquests per minute)."; + _lastQuestRefreshAt = now; + t.Refresh(quiet: true); + return "Refreshing quests..."; + } + + /// "/ra quests check <regex>" — lists up to 5 matching flags in chat. + public void CheckCommand(string pattern) + { + var t = _tracker(); + if (t == null) { _ctx.Chat("[Mini Remote] Quest tracker not ready."); return; } + Regex rx; + try { rx = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant, TimeSpan.FromMilliseconds(200)); } + catch (ArgumentException ex) { _ctx.Chat("[Mini Remote] Bad pattern: " + ex.Message); return; } + + var hits = t.Snapshot().Where(r => rx.IsMatch(r.Key) || rx.IsMatch(FriendlyName(r))).OrderBy(r => r.Key).ToList(); + if (hits.Count == 0) { _ctx.Chat($"[Mini Remote] No quest flags match '{pattern}' ({t.Count} cached)."); return; } + foreach (var r in hits.Take(5)) + _ctx.Chat($"[Mini Remote] {FriendlyName(r)} [{r.Key}] solves {r.Solves}{(r.MaxSolves > 0 ? "/" + r.MaxSolves : "")} - {IltParse.Duration(r.TimeUntilReady())}"); + if (hits.Count > 5) _ctx.Chat($"[Mini Remote] ...and {hits.Count - 5} more."); + } + + /// Captures "/qb list" (quiet). + public string RefreshQb() + { + RynthLog.Trace(LogCat.IltQuests, $"RefreshQb()"); + if (_ctx.Options.IsOff(IltFeature.Qb)) return "/qb is disabled on this server."; + long now = IltHubContext.NowMs; + if (now - _lastQbAt < QbCooldownMs) + return $"Wait {(QbCooldownMs - (now - _lastQbAt)) / 1000}s (server allows one /qb per minute)."; + if (_ctx.Capture.IsPending("/qb list")) return "Already loading..."; + _lastQbAt = now; + _qbStatus = "loading..."; + + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = "/qb list", + IsResponseLine = IsQbLine, + IsTerminator = t => t.Contains("Quest bonus list is empty", StringComparison.OrdinalIgnoreCase) + || t.Contains("\"qb\" is not currently enabled", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("[QB] This command may only be run once every", StringComparison.OrdinalIgnoreCase), + IdleEndMs = 5000, + FirstLineTimeoutMs = 30000, + Eat = true, + OnComplete = OnQbResult, + }); + return "Loading quest bonus list..."; + } + + private static bool IsQbLine(string t) + { + if (t.StartsWith("Your completed quest bonus list", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("Your incomplete quest bonus list", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("Your current quest bonus count", StringComparison.OrdinalIgnoreCase)) + return true; + if (!QbFlagLine.IsMatch(t)) return false; + if (t.StartsWith("You ", StringComparison.Ordinal) || t.StartsWith("The ", StringComparison.Ordinal)) return false; + return !(t.Contains("You have", StringComparison.OrdinalIgnoreCase) || t.Contains("command", StringComparison.OrdinalIgnoreCase) + || t.Contains("enabled", StringComparison.OrdinalIgnoreCase) || t.Contains("list", StringComparison.OrdinalIgnoreCase)); + } + + private void OnQbResult(IltChatResult r) + { + if (r.UnknownCommand) { _ctx.Options.Set(IltFeature.Qb, IltTri.Off); _qbStatus = "/qb not available"; return; } + if (r.TerminatorLine != null) + { + if (r.TerminatorLine.Contains("not currently enabled", StringComparison.OrdinalIgnoreCase)) + { _ctx.Options.Set(IltFeature.Qb, IltTri.Off); _qbStatus = "/qb is disabled on this server"; return; } + if (r.TerminatorLine.Contains("only be run once", StringComparison.OrdinalIgnoreCase)) + { _qbStatus = "rate limited by the server"; return; } + } + if (r.TimedOut) { _qbStatus = "no reply from server"; return; } + _ctx.Options.Set(IltFeature.Qb, IltTri.On); + + var done = new List(); + var todo = new List(); + List? current = null; + foreach (string line in r.Lines) + { + if (line.StartsWith("Your completed quest bonus list", StringComparison.OrdinalIgnoreCase)) { current = done; continue; } + if (line.StartsWith("Your incomplete quest bonus list", StringComparison.OrdinalIgnoreCase)) { current = todo; continue; } + if (line.StartsWith("Your current quest bonus count", StringComparison.OrdinalIgnoreCase)) + { + int colon = line.IndexOf(':'); + if (colon > 0) _qbCount = IltParse.ParseLeadingLong(line.Substring(colon + 1)); + continue; + } + if (line.Contains("is empty", StringComparison.OrdinalIgnoreCase)) continue; + (current ?? done).Add(line.Trim()); + } + done.Sort(StringComparer.OrdinalIgnoreCase); + todo.Sort(StringComparer.OrdinalIgnoreCase); + _qbCompleted = done.ToArray(); + _qbIncomplete = todo.ToArray(); + _qbStatus = $"{done.Count} completed, {todo.Count} incomplete"; + _qbGeneration++; + } + + /// Increments each time a "/qb list" reply is parsed (0 = not loaded this session). + public int QbGeneration => _qbGeneration; + + /// True when the last "/qb list" (completed or incomplete) contains the flag. + public bool QbHasFlag(string flag) + { + if (string.IsNullOrWhiteSpace(flag)) return false; + foreach (string f in _qbCompleted) + if (f.Equals(flag, StringComparison.OrdinalIgnoreCase)) return true; + foreach (string f in _qbIncomplete) + if (f.Equals(flag, StringComparison.OrdinalIgnoreCase)) return true; + return false; + } + + /// Login probe tap: "/qb" (no args) prints the count line. + public void ApplyQbProbe(List lines) + { + RynthLog.Trace(LogCat.IltQuests, $"ApplyQbProbe(lines={lines.Count})"); + foreach (string line in lines) + if (line.StartsWith("Your current quest bonus count", StringComparison.OrdinalIgnoreCase)) + { + int colon = line.IndexOf(':'); + if (colon > 0) _qbCount = IltParse.ParseLeadingLong(line.Substring(colon + 1)); + } + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) { } + public bool OnChat(string text) => false; + public void OnLogout() + { + _qbCompleted = Array.Empty(); + _qbIncomplete = Array.Empty(); + _qbCount = -1; + _qbStatus = "not loaded"; + _qbGeneration = 0; + } + + // ── UI (render thread) ────────────────────────────────────────────────── + + /// Quest tracker body, filling the Mini Remote's Quests tab (the table uses the remaining height). + public void RenderQuestTracker() + { + var t = _tracker(); + if (t == null) { ImGui.TextDisabled("Quest tracker not ready."); return; } + if (_ctx.Options.IsOff(IltFeature.Quests) || t.Disabled) + { + ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "/myquests is disabled on this server."); + return; + } + var cs = _ctx.State.Character; + + if (ImGui.SmallButton("Refresh##quests")) _ctx.Post(() => _ctx.Chat("[Mini Remote] " + RefreshQuests())); + ImGui.SameLine(); + if (ImGui.SmallButton("Reload quests.xml")) _ctx.Post(LoadFriendlyNames); + ImGui.SameLine(); + ImGui.TextDisabled(t.IsRefreshing ? "refreshing..." : t.LastStatus + + (t.LastRefreshUtc == DateTime.MinValue ? "" : " @ " + t.LastRefreshUtc.ToLocalTime().ToString("t"))); + + string filter = cs.QuestFilter; + ImGui.SetNextItemWidth(220); + if (ImGui.InputTextWithHint("##qfilter", "filter by name or key", ref filter, 64u)) + cs.QuestFilter = filter; + ImGui.SameLine(); + ImGui.RadioButton("Timed", ref _questView, 0); ImGui.SameLine(); + ImGui.RadioButton("Kill tasks", ref _questView, 1); ImGui.SameLine(); + ImGui.RadioButton("Once", ref _questView, 2); ImGui.SameLine(); + ImGui.RadioButton("All", ref _questView, 3); + + bool favOnly = cs.QuestFavoritesOnly; + if (ImGui.Checkbox("Favorites only", ref favOnly)) cs.QuestFavoritesOnly = favOnly; + ImGui.SameLine(); + bool favHud = cs.ShowQuestFavoritesHud; + if (ImGui.Checkbox("Show floating favorites HUD", ref favHud)) cs.ShowQuestFavoritesHud = favHud; + ImGui.SameLine(); + ImGui.TextDisabled("(click * to star a quest)"); + + var favorites = FavoriteSet(); + var rows = t.Snapshot() + .Where(r => favOnly ? favorites.Contains(r.Key) : _questView == 3 || (int)Classify(r) == ViewToKind(_questView)) + .Where(r => filter.Length == 0 || r.Key.Contains(filter, StringComparison.OrdinalIgnoreCase) + || FriendlyName(r).Contains(filter, StringComparison.OrdinalIgnoreCase)) + .OrderBy(r => r.TimeUntilReady()) + .ThenBy(r => FriendlyName(r), StringComparer.OrdinalIgnoreCase) + .ToArray(); + + if (ImGui.BeginTable("##iltquests", 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.Resizable, + new Vector2(0, -1))) + { + ImGui.TableSetupScrollFreeze(0, 1); + ImGui.TableSetupColumn("*", ImGuiTableColumnFlags.WidthFixed, 18); + ImGui.TableSetupColumn("Quest"); + ImGui.TableSetupColumn("Solves", ImGuiTableColumnFlags.WidthFixed, 70); + ImGui.TableSetupColumn("Ready", ImGuiTableColumnFlags.WidthFixed, 110); + ImGui.TableSetupColumn("Key"); + ImGui.TableHeadersRow(); + foreach (var r in rows) + { + ImGui.TableNextRow(); + ImGui.TableNextColumn(); + bool starred = favorites.Contains(r.Key); + ImGui.PushStyleColor(ImGuiCol.Text, starred ? FavStarOn : FavStarOff); + if (ImGui.Selectable($"*##fav{r.Key}", false)) + { + string key = r.Key; + _ctx.Post(() => ToggleFavorite(key)); + } + ImGui.PopStyleColor(); + if (ImGui.IsItemHovered()) ImGui.SetTooltip(starred ? "Remove from favorites" : "Add to favorites"); + ImGui.TableNextColumn(); ImGui.TextUnformatted(FriendlyName(r)); + ImGui.TableNextColumn(); ImGui.TextUnformatted(r.MaxSolves > 0 ? $"{r.Solves}/{r.MaxSolves}" : r.Solves.ToString()); + ImGui.TableNextColumn(); + var left = r.TimeUntilReady(); + if (Classify(r) == QuestKind.Once) ImGui.TextDisabled("done"); + else if (left <= TimeSpan.Zero) ImGui.TextColored(LegacyDashboardRenderer.ColGreen, "ready"); + else ImGui.TextUnformatted(IltParse.Duration(left)); + ImGui.TableNextColumn(); ImGui.TextDisabled(r.Key); + } + ImGui.EndTable(); + } + } + + private static int ViewToKind(int view) => view switch { 0 => (int)QuestKind.Timed, 1 => (int)QuestKind.KillTask, _ => (int)QuestKind.Once }; + + // ── Favorites / the Quests tab ────────────────────────────────────────── + + private static readonly Vector4 FavStarOn = new(1.00f, 0.82f, 0.25f, 1f); + private static readonly Vector4 FavStarOff = new(0.45f, 0.48f, 0.52f, 1f); + private const string FavHudPopup = "##questfavhudopts"; + + /// Starred keys as a set (render thread; the list itself is only edited on the pump thread). + private HashSet FavoriteSet() + => new(_ctx.State.Character.QuestFavorites.ToArray(), StringComparer.OrdinalIgnoreCase); + + /// Stars / unstars a quest flag (pump thread). + private void ToggleFavorite(string key) + { + var list = _ctx.State.Character.QuestFavorites; + if (list.RemoveAll(k => k.Equals(key, StringComparison.OrdinalIgnoreCase)) == 0) + list.Add(key.ToLowerInvariant()); + } + + /// The floating favorites HUD (the tracker itself is the Mini Remote's Quests tab). Called every frame. + public void RenderFloatingWindows() + { + var cs = _ctx.State.Character; + if (cs.ShowQuestFavoritesHud) RenderFavoritesHud(cs); + } + + /// The Mini Remote's Quests tab: the quest bonus (collapsed), then the tracker filling the rest. + public void RenderTab() + { + // The tab is universal (/myquests); the quest bonus list (/qb) is ILT's. + if (_ctx.Options.IsIltLikeWorld && ImGui.CollapsingHeader("Quest bonus (/qb)##qbwin")) RenderQb(); + RenderQuestTracker(); + } + + /// Compact always-on list of starred quests and when each is ready. + private void RenderFavoritesHud(IltCharacterState cs) + { + var flags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar + | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNav; + if (cs.QuestFavoritesHudLocked) flags |= ImGuiWindowFlags.NoMove; + ImGui.SetNextWindowPos(new Vector2(260, 120), ImGuiCond.FirstUseEver); + ImGui.SetNextWindowBgAlpha(0.55f); + if (!ImGui.Begin("Quest favorites##iltquestfavhud", flags)) { ImGui.End(); return; } + + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Quest favorites"); + var t = _tracker(); + var favorites = FavoriteSet(); + if (t == null || favorites.Count == 0) + { + ImGui.TextDisabled(t == null ? "Quest tracker not ready." : "No favorites yet - star quests in the tracker."); + } + else + { + var rows = t.Snapshot().Where(r => favorites.Contains(r.Key)) + .OrderBy(r => r.TimeUntilReady()).ThenBy(r => FriendlyName(r), StringComparer.OrdinalIgnoreCase).ToArray(); + if (rows.Length == 0) ImGui.TextDisabled("Starred quests not in /myquests yet."); + if (ImGui.BeginTable("##questfavrows", 2, ImGuiTableFlags.SizingFixedFit)) + { + foreach (var r in rows) + { + ImGui.TableNextRow(); + ImGui.TableNextColumn(); ImGui.TextUnformatted(FriendlyName(r)); + ImGui.TableNextColumn(); + var left = r.TimeUntilReady(); + if (Classify(r) == QuestKind.Once) ImGui.TextDisabled("done"); + else if (left <= TimeSpan.Zero) ImGui.TextColored(LegacyDashboardRenderer.ColGreen, "ready"); + else ImGui.TextUnformatted(IltParse.Duration(left)); + } + ImGui.EndTable(); + } + } + + if (ImGui.IsWindowHovered() && ImGui.IsMouseReleased(ImGuiMouseButton.Right)) ImGui.OpenPopup(FavHudPopup); + if (ImGui.BeginPopup(FavHudPopup)) + { + bool locked = cs.QuestFavoritesHudLocked; + if (ImGui.Checkbox("Lock position", ref locked)) cs.QuestFavoritesHudLocked = locked; + if (ImGui.MenuItem("Open quest tracker")) _ctx.ShowTab?.Invoke(IltSection.Quests); + if (ImGui.MenuItem("Refresh /myquests")) _ctx.Post(() => _ctx.Chat("[Mini Remote] " + RefreshQuests())); + if (ImGui.MenuItem("Hide favorites HUD")) cs.ShowQuestFavoritesHud = false; + ImGui.EndPopup(); + } + ImGui.End(); + } + + public void RenderQb() + { + if (_ctx.Options.IsOff(IltFeature.Qb)) + { + ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "/qb is disabled on this server."); + return; + } + if (ImGui.SmallButton("Load /qb list")) _ctx.Post(() => _ctx.Chat("[Mini Remote] " + RefreshQb())); + ImGui.SameLine(); + long count = _qbCount; + ImGui.TextDisabled((count >= 0 ? $"QB count {IltParse.N0(count)} - " : "") + _qbStatus); + + string filter = _ctx.State.Character.QbFilter; + ImGui.SetNextItemWidth(220); + if (ImGui.InputTextWithHint("##qbfilter", "filter flags", ref filter, 64u)) + _ctx.State.Character.QbFilter = filter; + + RenderQbList("Incomplete", _qbIncomplete, filter, LegacyDashboardRenderer.ColAmber); + RenderQbList("Completed", _qbCompleted, filter, LegacyDashboardRenderer.ColGreen); + } + + private static void RenderQbList(string label, string[] items, string filter, Vector4 color) + { + var shown = filter.Length == 0 ? items : items.Where(i => i.Contains(filter, StringComparison.OrdinalIgnoreCase)).ToArray(); + if (ImGui.TreeNode($"{label} ({shown.Length})##qb{label}")) + { + if (ImGui.SmallButton($"Copy##qbc{label}")) ImGui.SetClipboardText(string.Join(Environment.NewLine, shown)); + foreach (string s in shown) ImGui.TextColored(color, s); + ImGui.TreePop(); + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSections.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSections.cs new file mode 100644 index 0000000..eb5ea46 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSections.cs @@ -0,0 +1,104 @@ +// IltSections.cs - The Mini Remote's tabs and the Guardian panel. Quests and Pets are universal +// tabs (every server: /myquests and summoning essences aren't ILT's); Character, Banking, Gear, +// Charms and Games are Infinite Leaftide tabs. All are picked from the Mini Remote's tab bar (MiniRemoteHud) +// or "/ra hub open
". Guardian is ILT only and a RynthCore ILT panel instead (the bar's +// ILT button, next to Bounties; "/rc guardian"), drawn by this plugin through +// RynthPluginRenderEmbed("guardian"). +using System; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +/// ILT sections: the Mini Remote's tabs, then the Guardian panel. +internal enum IltSection +{ + Character, + Quests, + Pet, + Banking, + Gear, + Games, + /// Registry charms (acquired / status / tier / server) and the Guardian Hand. + Charms, + // Keep Guardian last: MiniRemoteHud sizes its per-tab tables by it. + Guardian, +} + +internal static class IltSections +{ + /// + /// The Mini Remote's tabs, in tab-bar order (after its own Remote tab): the universal ones + /// first, then the Infinite Leaftide ones. + /// + public static readonly IltSection[] Tabs = + { + IltSection.Quests, IltSection.Pet, + IltSection.Character, IltSection.Banking, IltSection.Gear, IltSection.Charms, IltSection.Games, + }; + + /// + /// True for the tabs every server gets (Quests, Pets); the rest are Infinite Leaftide's and + /// show only on an ILT world (or with the Force-ILT override). + /// + public static bool IsUniversal(IltSection s) => s is IltSection.Quests or IltSection.Pet; + + /// The Mini Remote's own tab (the remote itself): its tab id. + public const string RemoteTab = ""; + + public static string Label(IltSection s) => s switch + { + IltSection.Character => "Character", + IltSection.Quests => "Quests", + IltSection.Pet => "Pets", + IltSection.Banking => "Banking", + IltSection.Gear => "Gear", + IltSection.Games => "Games", + IltSection.Charms => "Charms", + IltSection.Guardian => "Guardian", + _ => s.ToString(), + }; + + /// + /// The section's tab id: saved as HudState.MiniRemoteTab and sent by the engine's dashboard + /// ("/ra hub tab <id>"). TryParse reads it back. + /// + public static string TabId(IltSection s) => s switch + { + IltSection.Character => "character", + IltSection.Quests => "quests", + IltSection.Pet => "pets", + IltSection.Banking => "banking", + IltSection.Gear => "gear", + IltSection.Games => "games", + IltSection.Charms => "charms", + IltSection.Guardian => "guardian", + _ => s.ToString().ToLowerInvariant(), + }; + + /// True for the sections drawn as Mini Remote tabs (all but the Guardian panel). + public static bool IsTab(IltSection s) => s != IltSection.Guardian; + + /// Parses a "/ra hub open" section name (a few aliases accepted). + public static bool TryParse(string text, out IltSection section) + { + switch ((text ?? string.Empty).Trim().ToLowerInvariant()) + { + case "character": case "char": case "rates": section = IltSection.Character; return true; + case "quests": case "quest": section = IltSection.Quests; return true; + case "pets": case "pet": section = IltSection.Pet; return true; + case "banking": case "bank": section = IltSection.Banking; return true; + case "gear": section = IltSection.Gear; return true; + case "games": case "game": section = IltSection.Games; return true; + case "charms": case "charm": section = IltSection.Charms; return true; + case "guardian": case "temple": case "riddle": section = IltSection.Guardian; return true; + default: section = IltSection.Character; return false; + } + } + + /// "show" / "hide" / "toggle" (anything else toggles) applied to the current state. + public static bool Resolve(string mode, bool current) => (mode ?? string.Empty).ToLowerInvariant() switch + { + "show" or "on" or "open" => true, + "hide" or "off" or "close" => false, + _ => !current, + }; +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltServerOptions.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltServerOptions.cs new file mode 100644 index 0000000..555f63f --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltServerOptions.cs @@ -0,0 +1,409 @@ +// IltServerOptions.cs — Per-feature enable bits for the ILT Hub, read from the server. +// +// UB gated every Leaftide tool on a single test (WorldName == "InfiniteLeaftide" or a +// Force checkbox). That lies on shards where the operator turned Powerball, /myquests or +// a charm off. This module instead keeps one tri-state bit per feature: +// * World identity: ServerFeatureGate (Settings > Misc server list, or its manual +// override / the Hub's ForceLeaftideFeatures) decides whether we even ASK — it never +// switches a feature on by itself. +// * Preferred source: a structured "/ilt features" dump (ILTFEATURE key=0|1 lines) once +// ACECustom ships it. Today the server prints "Coming Soon", so: +// * Fallback: a one-shot login probe of read-only commands (/bank, /aug, /qb, /pets, +// /shinies, /xp, /pb, /blackjack, /fblackjack, /clap with no args). Replies are eaten. +// /enl is NEVER probed — it opens the enlightenment confirmation dialog. +// * Passive: explicit server refusals seen in chat at any time flip a bit to Off +// ("Powerball lottery is not currently active", "myquests is not currently enabled", ...). +// Unknown bits are treated as OFF by anything that spends currency or runs automation. +using System; +using System.Collections.Generic; +using System.Linq; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +/// Feature keys used by the gate table. +internal static class IltFeature +{ + public const string Bank = "bank"; + public const string Aug = "aug"; + public const string Enl = "enl"; + public const string Qb = "qb"; + public const string Pets = "pets"; + public const string Shinies = "shinies"; + public const string Xp = "xp"; + public const string Blackjack = "blackjack"; + public const string FBlackjack = "fblackjack"; + public const string Powerball = "powerball"; + public const string Quests = "quests"; + public const string Clap = "clap"; + public const string PetRefill = "pet_refill"; + public const string UniversalMastery = "universal_mastery"; + public const string RequireComps = "require_spell_comps"; + public const string PetBond = "pet_bond"; + public const string PetPotency = "pet_potency"; + + /// Key for a per-charm "enabled" bit, e.g. Charm("Guardian Hand") → "charm:guardianhand". + public static string Charm(string charmName) + { + var chars = (charmName ?? string.Empty).Where(char.IsLetterOrDigit).Select(char.ToLowerInvariant).ToArray(); + return "charm:" + new string(chars); + } +} + +/// Tri-state feature value. +internal enum IltTri { Unknown = -1, Off = 0, On = 1 } + +internal sealed class IltServerOptions +{ + private readonly RynthCoreHost _host; + private readonly IltChatCapture _capture; + private readonly IltHubState _state; + private readonly Action _chat; + private readonly Func _settings; + + /// Feeds probe replies to features that can reuse them (e.g. /bank → Banking balances). + public Action? ProbeReplyTap; + + private bool _refreshInFlight; + private int _probesOutstanding; + private long _loginAt; + private bool _loginRefreshDone; + + /// Wait this long after login before the one-shot refresh so chat/world are settled. + private const long LoginRefreshDelayMs = 6000; + + /// + /// Upper bound on waiting for the world name. The engine hook / launch-context file can report + /// it well after the 6 s delay (late inject, Decal coexistence); deciding "not ILT" on an empty + /// name would leave every feature bit Unknown and the Hub hidden for the whole session. + /// + private const long WorldNameWaitMs = 60000; + + public IltServerOptions(RynthCoreHost host, IltChatCapture capture, IltHubState state, Action chat, + Func? settings = null) + { + _host = host; + _capture = capture; + _state = state; + _chat = chat; + _settings = settings ?? (() => null); + } + + // ── Identity ──────────────────────────────────────────────────────────── + + /// World name as reported by the engine login hook (empty if unknown). + public string WorldName + { + get + { + if (_host.HasGetWorldName && _host.TryGetWorldName(out string n) && !string.IsNullOrWhiteSpace(n)) + return n.Trim(); + return _state.ServerOptions.WorldName ?? string.Empty; + } + } + + /// + /// True when the world is (or is declared to be) an ACECustom/ILT shard: its name is in the + /// Settings > Misc server list, or an override is on (ServerFeatureGate). + /// + public bool IsIltLikeWorld + { + get + { + if (_state.ForceLeaftideFeatures) return true; + LegacyUiSettings? s; + try { s = _settings(); } catch { s = null; } + return ServerFeatureGate.IsEnabled(WorldName, s); + } + } + + /// True while a refresh (dump or probe) is running. + public bool IsRefreshing => _refreshInFlight; + + public string Source => _state.ServerOptions.Source; + public DateTime LastRefreshUtc => _state.ServerOptions.LastRefreshUtc; + + // ── Bit access ────────────────────────────────────────────────────────── + + public IltTri Get(string key) + => _state.ServerOptions.Bits.TryGetValue(key, out int v) ? (IltTri)Math.Clamp(v, -1, 1) : IltTri.Unknown; + + /// True only when the server positively reported the feature as available. + public bool IsOn(string key) => Get(key) == IltTri.On; + + /// True when the server positively reported the feature as unavailable. + public bool IsOff(string key) => Get(key) == IltTri.Off; + + public void Set(string key, IltTri value) + { + // Every feature gate reads these bits, so each transition is traced (IltOptions). + IltTri old = Get(key); + _state.ServerOptions.Bits[key] = (int)value; + if (old != value) RynthLog.Trace(LogCat.IltOptions, $"feature '{key}': {old} -> {value}"); + } + + /// At least one feature bit is On (Hub window shows only then, unless Force is on). + public bool AnyFeatureOn => _state.ServerOptions.Bits.Values.Any(v => v == 1); + + /// All known bits for the status display. + public IReadOnlyList> SnapshotBits() + => _state.ServerOptions.Bits.OrderBy(k => k.Key, StringComparer.OrdinalIgnoreCase).ToList(); + + // ── Lifecycle ─────────────────────────────────────────────────────────── + + /// Called at login: schedules the one-shot refresh (never a recurring timer). + public void OnLoginComplete() + { + _loginAt = Environment.TickCount64; + _loginRefreshDone = false; + } + + /// + /// Pump-thread tick: fires the delayed login refresh once. While the world name is still + /// unknown it keeps checking (a cheap string compare per tick) until the name arrives or + /// WorldNameWaitMs expires; only a known non-ILT world, or the timeout, ends the wait. + /// + public void Tick() + { + if (_loginRefreshDone || _loginAt == 0) return; + long sinceLogin = Environment.TickCount64 - _loginAt; + if (sinceLogin < LoginRefreshDelayMs) return; + + if (IsIltLikeWorld) + { + _loginRefreshDone = true; + RynthLog.Event(LogEvents.IltWorldCheck, + $"world check: '{WorldName}' is ILT-like (force={_state.ForceLeaftideFeatures}) - refreshing server options"); + Refresh(manual: false); + return; + } + + // World not reported yet: try again next tick rather than concluding "not ILT". + if (string.IsNullOrEmpty(WorldName) && sinceLogin < WorldNameWaitMs) + return; + + _loginRefreshDone = true; + RynthLog.Event(LogEvents.IltWorldCheck, + $"world check: '{WorldName}' is not ILT-like - login refresh skipped (waited {sinceLogin / 1000}s)"); + } + + /// + /// Runs the dump-then-probe refresh. Manual refreshes report progress in chat; the + /// login refresh is silent. + /// + public void Refresh(bool manual) + { + if (_refreshInFlight) + { + if (manual) _chat("[Mini Remote] Server options refresh already running."); + return; + } + if (!IsIltLikeWorld) + { + if (manual) _chat("[Mini Remote] This world is not in the Server Features list (Settings > Misc: add it, or tick the override)."); + return; + } + + _refreshInFlight = true; + _state.ServerOptions.WorldName = WorldName; + RynthLog.Event(LogEvents.IltOptionsRefreshStart, $"refresh start (manual={manual}, world='{WorldName}')"); + if (manual) _chat("[Mini Remote] Refreshing server options..."); + + // Step 1: structured dump. Lines start with "=== ILT Custom Features ===". + _capture.Enqueue(new IltChatRequest + { + Command = "/ilt features", + IsResponseLine = t => t.StartsWith("ILTFEATURE", StringComparison.OrdinalIgnoreCase) + || t.Contains("ILT Custom Features", StringComparison.OrdinalIgnoreCase) + || t.Equals("Coming Soon", StringComparison.OrdinalIgnoreCase), + IdleEndMs = 1200, + FirstLineTimeoutMs = 8000, + Eat = true, + OnComplete = r => OnFeatureDump(r, manual), + }); + } + + private void OnFeatureDump(IltChatResult r, bool manual) + { + var fromDump = new HashSet(StringComparer.OrdinalIgnoreCase); + foreach (string line in r.Lines) + { + if (!line.StartsWith("ILTFEATURE", StringComparison.OrdinalIgnoreCase)) continue; + foreach (var kv in ParseFeatureLine(line)) + { + Set(kv.Key, kv.Value); + fromDump.Add(kv.Key); + } + } + + _state.ServerOptions.Source = fromDump.Count > 0 ? "ilt-features" : "probe"; + RynthLog.Trace(LogCat.IltOptions, $"feature dump: {fromDump.Count} key(s) (timedOut={r.TimedOut}, unknown={r.UnknownCommand}) → source={_state.ServerOptions.Source}"); + RunProbes(fromDump, manual); + } + + /// + /// Parses "ILTFEATURE bank=1 powerball=0 charms=infinitecasting:1,guardianhand:0". + /// ServerConfig-style names ("powerball_enabled") are mapped onto Hub keys. + /// + internal static IEnumerable> ParseFeatureLine(string line) + { + string body = line.Substring("ILTFEATURE".Length).Trim(); + foreach (string token in body.Split(' ', StringSplitOptions.RemoveEmptyEntries)) + { + int eq = token.IndexOf('='); + if (eq <= 0) continue; + string key = token.Substring(0, eq).Trim(); + string val = token.Substring(eq + 1).Trim(); + + if (key.Equals("charms", StringComparison.OrdinalIgnoreCase)) + { + foreach (string pair in val.Split(',', StringSplitOptions.RemoveEmptyEntries)) + { + int c = pair.IndexOf(':'); + if (c <= 0) continue; + yield return new(IltFeature.Charm(pair.Substring(0, c)), ParseTri(pair.Substring(c + 1))); + } + continue; + } + yield return new(MapServerKey(key), ParseTri(val)); + } + } + + private static IltTri ParseTri(string v) + { + v = v.Trim().ToLowerInvariant(); + return v is "1" or "on" or "true" or "yes" ? IltTri.On + : v is "0" or "off" or "false" or "no" ? IltTri.Off + : IltTri.Unknown; + } + + private static string MapServerKey(string key) + { + string k = key.Trim().ToLowerInvariant(); + return k switch + { + "powerball_enabled" => IltFeature.Powerball, + "quest_info_enabled" => IltFeature.Quests, + "pet_device_pyreal_auto_refill_enabled" => IltFeature.PetRefill, + "pet_charm_universal_summoning_mastery_enabled" => IltFeature.UniversalMastery, + "pet_bond_enabled" => IltFeature.PetBond, + "pet_potency_enabled" => IltFeature.PetPotency, + _ => k.EndsWith("_enabled", StringComparison.Ordinal) ? k.Substring(0, k.Length - "_enabled".Length) : k, + }; + } + + // ── Probe ─────────────────────────────────────────────────────────────── + + /// One read-only probe: command, reply recogniser, feature key. + private readonly record struct Probe(string Key, string Command, Func IsReply); + + private static readonly Probe[] Probes = + { + new(IltFeature.Bank, "/bank", t => t.StartsWith("[BANK]", StringComparison.OrdinalIgnoreCase) + || t.Contains("not permitted to use bank", StringComparison.OrdinalIgnoreCase)), + new(IltFeature.Aug, "/aug", t => t.StartsWith("---") || t.Contains("Augmentation Levels", StringComparison.OrdinalIgnoreCase) + || IltParse.AugLine.IsMatch(t)), + new(IltFeature.Qb, "/qb", t => t.StartsWith("Your current quest bonus count", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("[QB]", StringComparison.OrdinalIgnoreCase)), + new(IltFeature.Pets, "/pets", t => t.Contains("Your Pet Log", StringComparison.OrdinalIgnoreCase) + || IltParse.RosterLine.IsMatch(t) || t.Contains("Professor Ruggan", StringComparison.OrdinalIgnoreCase)), + new(IltFeature.Shinies, "/shinies", t => t.Contains("Your Shiny Log", StringComparison.OrdinalIgnoreCase) + || IltParse.RosterLine.IsMatch(t) || t.Contains("Shiny creatures", StringComparison.OrdinalIgnoreCase)), + new(IltFeature.Xp, "/xp", t => t.StartsWith("[XP]", StringComparison.OrdinalIgnoreCase)), + new(IltFeature.Powerball, "/pb", t => t.StartsWith("[Powerball]", StringComparison.OrdinalIgnoreCase)), + new(IltFeature.Blackjack, "/blackjack", IsParamErrorOr("blackjack", "bet amount")), + new(IltFeature.FBlackjack,"/fblackjack", IsParamErrorOr("blackjack", "bet amount")), + new(IltFeature.Clap, "/clap", IsParamErrorOr("clap", "AutoCraftingEnabled")), + }; + + /// Recognises ACE's wrong-parameter-count reply (command exists) or a keyword reply. + private static Func IsParamErrorOr(string keyword, string keyword2) => t => + t.StartsWith("Invalid parameter count", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("Usage:", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("@" + keyword, StringComparison.OrdinalIgnoreCase) + || t.Contains(keyword2, StringComparison.OrdinalIgnoreCase) + || (t.Contains(keyword, StringComparison.OrdinalIgnoreCase) && !t.StartsWith(" alreadyKnown, bool manual) + { + var todo = Probes.Where(p => !alreadyKnown.Contains(p.Key)).ToList(); + + // /enl is never probed (it pops the enlightenment confirmation). On an ILT-like + // world the command is part of ACECustom, so it is assumed present unless the + // dump said otherwise. + if (!alreadyKnown.Contains(IltFeature.Enl)) + Set(IltFeature.Enl, IltTri.On); + + _probesOutstanding = todo.Count; + if (_probesOutstanding == 0) { CompleteRefresh(manual); return; } + + foreach (var p in todo) + { + var probe = p; + _capture.Enqueue(new IltChatRequest + { + Command = probe.Command, + IsResponseLine = probe.IsReply, + IdleEndMs = 1500, + FirstLineTimeoutMs = 8000, + Eat = true, + OnComplete = r => + { + // Unknown command → Off. Any recognised reply → On. Silence → leave Unknown. + if (r.UnknownCommand) Set(probe.Key, IltTri.Off); + else if (r.Lines.Count > 0) Set(probe.Key, IltTri.On); + RynthLog.Trace(LogCat.IltOptions, $"probe {probe.Command}: lines={r.Lines.Count} unknown={r.UnknownCommand} timedOut={r.TimedOut}"); + try { ProbeReplyTap?.Invoke(probe.Key, r); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltOptions, ex, $"probe tap {probe.Key}"); } + if (--_probesOutstanding <= 0) CompleteRefresh(manual); + }, + }); + } + } + + private void CompleteRefresh(bool manual) + { + _refreshInFlight = false; + _state.ServerOptions.LastRefreshUtc = DateTime.UtcNow; + int on = _state.ServerOptions.Bits.Values.Count(v => v == 1); + int off = _state.ServerOptions.Bits.Values.Count(v => v == 0); + // Building the per-bit list is skipped unless the event is actually going to be recorded. + if (RynthLog.IsEventEnabled(LogEvents.IltOptionsRefreshed)) + RynthLog.Event(LogEvents.IltOptionsRefreshed, $"options refreshed via {Source} (manual={manual}): {on} on, {off} off - " + + string.Join(" ", _state.ServerOptions.Bits.Select(b => $"{b.Key}={b.Value}"))); + if (manual) + _chat($"[Mini Remote] Server options refreshed via {Source}: {on} on, {off} off."); + } + + // ── Passive refusals ──────────────────────────────────────────────────── + + /// + /// Watches every chat line for explicit server refusals and flips the matching bit Off. + /// Cheap substring checks; runs on the pump thread. + /// + public void OnChatLine(string text) + { + if (text.Contains("Powerball lottery is not currently active", StringComparison.OrdinalIgnoreCase)) + Set(IltFeature.Powerball, IltTri.Off); + else if (text.Contains("\"myquests\" is not currently enabled", StringComparison.OrdinalIgnoreCase)) + Set(IltFeature.Quests, IltTri.Off); + else if (text.Contains("\"qb\" is not currently enabled", StringComparison.OrdinalIgnoreCase)) + Set(IltFeature.Qb, IltTri.Off); + else if (text.Contains("must have received the AutoCraftingEnabled quest stamp", StringComparison.OrdinalIgnoreCase)) + Set(IltFeature.Clap, IltTri.Off); + else if (text.Contains("Universal Summoning Mastery is not enabled on this server", StringComparison.OrdinalIgnoreCase)) + Set(IltFeature.UniversalMastery, IltTri.Off); + else if (text.Contains("Auto-Rebuff Charm is currently disabled globally", StringComparison.OrdinalIgnoreCase)) + Set(IltFeature.Charm("Auto-Rebuff"), IltTri.Off); + else if (text.Contains("not permitted to use bank commands", StringComparison.OrdinalIgnoreCase)) + Set(IltFeature.Bank, IltTri.Off); + } + + /// Records what the login /myquests refresh learned (called by the Hub after the Meta tracker finishes). + public void NoteQuestTrackerOutcome(bool disabled, int recordCount) + { + if (disabled) Set(IltFeature.Quests, IltTri.Off); + else if (recordCount > 0) Set(IltFeature.Quests, IltTri.On); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSessionRates.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSessionRates.cs new file mode 100644 index 0000000..820e997 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSessionRates.cs @@ -0,0 +1,267 @@ +// IltSessionRates.cs — Session earnings / per-hour rates for the ILT Hub Character tab. +// +// Sources (all passive — nothing is sent to the server except the optional bank refresh +// the Banking tab already does): +// XP, luminance (total, last 5 min, allegiance pass-up) and kills: the Mini Remote's +// SessionStatsTracker — RynthTracker's SessionStats code (Plugins\Shared), so this +// table, the Mini Remote and the Tracker panel count them the same way (2026-10-11). +// Coins positive bank Enlightened Coins deltas + carried coin (WCID 300004) gains. +// Pyreals positive bank pyreal deltas + carried pyreal (WCID 273) gains; MMD = 250k. +// Items gains of each item in the item→coin conversion table (carried count), +// converted to potential coins with ItemsPerConversion / CoinsPerConversion. +// A deposit or withdrawal only moves money between pack and bank: while Banking reports one +// (MovingMoney) the coin and pyreal baselines follow along without counting a gain. +using System; +using System.Collections.Generic; +using System.Linq; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltSessionRates : IIltFeature +{ + private const long PyrealsPerMmd = 250_000; + private const long SampleIntervalMs = 5000; + private const long RowsIntervalMs = 1000; + private const string PassUpLabel = " pass-up"; + + private readonly IltHubContext _ctx; + private readonly SessionStatsTracker? _stats; + private DateTime _start = DateTime.UtcNow; + + private long _coins; + private long _pyreals; + + // Carried-item baselines (last seen counts) for gain tracking. + private long _lastInvCoins = -1; + private long _lastInvPyreals = -1; + private readonly Dictionary _lastItemCounts = new(StringComparer.OrdinalIgnoreCase); + private readonly Dictionary _itemGains = new(StringComparer.OrdinalIgnoreCase); + private long _lastSampleAt; + private long _lastRowsAt; + + // Render snapshot. + private volatile RateRow[] _rows = Array.Empty(); + private sealed record RateRow(string Label, string Total, string PerHour); + + /// Coin and pyreal per-hour figures for the Mini Remote HUD (rebuilt every sample). + public sealed record RateSummary(double CoinsPerHour, double PyrealsPerHour); + private static readonly RateSummary EmptySummary = new(0, 0); + private volatile RateSummary _summary = EmptySummary; + + /// Latest coin / pyreal summary (safe from the render thread). + public RateSummary Summary => _summary; + /// When the coin / pyreal session (or the last Reset) started. + public DateTime SessionStartUtc => _start; + + public IltSessionRates(IltHubContext ctx, SessionStatsTracker? stats = null) + { + _ctx = ctx; + _stats = stats; + } + + /// True while money moves between pack and bank (set by the controller from Banking). Pump thread. + public Func? MovingMoney { get; set; } + + private bool Moving => MovingMoney?.Invoke() ?? false; + + /// Banking hook: bank balance changed (pump thread). + public void OnBankBalanceChanged(string key, long oldValue, long newValue) + { + RynthLog.Trace(LogCat.IltRates, $"balance {key}: {oldValue} -> {newValue}"); + // The first read after login only establishes the baseline (old value is the stale cache). + if (_lastSampleAt == 0) return; + if (Moving) return; // a deposit, not income + long delta = newValue - oldValue; + if (delta <= 0) return; // spending / sending isn't income + if (key == "EnlightenedCoins") _coins += delta; + else if (key == "Pyreals") _pyreals += delta; + } + + /// Coins, pyreals and item gains start over (login, or with ). + public void Reset() + { + RynthLog.Trace(LogCat.IltRates, $"Reset()"); + _start = DateTime.UtcNow; + _coins = _pyreals = 0; + _lastInvCoins = _lastInvPyreals = -1; + _lastItemCounts.Clear(); + _itemGains.Clear(); + _lastSampleAt = 0; + _lastRowsAt = 0; + _summary = EmptySummary; + } + + /// The player's reset (this tab, the Mini Remote): coins here and the shared session stats together. Pump thread. + public void ResetAll() + { + Reset(); + _stats?.RequestReset(); + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + // The shared stats move every 0.5 s; their rows refresh each second, coins every 5 s. + if (nowMs - _lastSampleAt < SampleIntervalMs) + { + if (nowMs - _lastRowsAt >= RowsIntervalMs) { _lastRowsAt = nowMs; BuildRows(); } + return; + } + _lastSampleAt = nowMs; + _lastRowsAt = nowMs; + var inv = _ctx.Inventory; + + long coinGain = Gain(ref _lastInvCoins, inv.CountByWcid(IltInventory.WcidEnlightenedCoin)); + long pyrealGain = Gain(ref _lastInvPyreals, inv.CountByWcid(IltInventory.WcidPyreal)); + // A withdrawal: the baselines moved, nothing earned. + if (!Moving) + { + _coins += coinGain; + _pyreals += pyrealGain; + } + + // ToArray: the render thread edits this table. + foreach (var conv in _ctx.State.Character.ItemConversions.ToArray()) + { + if (string.IsNullOrWhiteSpace(conv.ItemName)) continue; + long count = inv.CountByName(conv.ItemName); + long last = _lastItemCounts.TryGetValue(conv.ItemName, out long l) ? l : -1; + long gain = Gain(ref last, count); + _lastItemCounts[conv.ItemName] = last; + if (gain > 0) _itemGains[conv.ItemName] = (_itemGains.TryGetValue(conv.ItemName, out long g) ? g : 0) + gain; + } + + BuildRows(); + } + + /// Positive change since the last sample; the first sample only sets the baseline. + private static long Gain(ref long last, long current) + { + if (last < 0) { last = current; return 0; } + long d = current - last; + last = current; + return d > 0 ? d : 0; + } + + // Luminance chat goes to the shared session stats (RynthAiPlugin.OnChatWindowText). + public bool OnChat(string text) => false; + + public void OnLogout() => Reset(); + + // ── Rows ──────────────────────────────────────────────────────────────── + + private void BuildRows() + { + double hours = Math.Max((DateTime.UtcNow - _start).TotalHours, 1.0 / 3600); + _summary = new RateSummary(_coins / hours, _pyreals / hours); + var s = _stats?.View ?? SessionStatsView.Empty; + var rows = new List + { + new("XP", IltParse.Compact(s.Xp), IltParse.Compact(s.XpPerHour)), + new("Luminance", IltParse.Compact(s.Lum), IltParse.Compact(s.LumPerHour)), + // Per hour at the last five minutes' pace. + new(" last 5 min", IltParse.Compact(s.LumLast5Min), IltParse.Compact(s.LumLast5Min * 12.0)), + }; + if (s.PassUpTracked) + rows.Add(new RateRow(PassUpLabel, IltParse.Compact(s.LumPassUp), IltParse.Compact(s.PassUpPerHour))); + rows.Add(new RateRow("Kills", s.Kills.ToString(), s.KillsPerHour.ToString("0"))); + rows.Add(new RateRow("Enlightened Coins", IltParse.Compact(_coins), IltParse.Compact(_coins / hours))); + rows.Add(new RateRow("Pyreals", IltParse.Compact(_pyreals), IltParse.Compact(_pyreals / hours))); + rows.Add(new RateRow(" as MMD", (_pyreals / (double)PyrealsPerMmd).ToString("0.0"), (_pyreals / (double)PyrealsPerMmd / hours).ToString("0.0"))); + + double potentialCoins = 0; + foreach (var conv in _ctx.State.Character.ItemConversions.ToArray()) + { + if (!_itemGains.TryGetValue(conv.ItemName, out long gained) || gained == 0) continue; + double coins = conv.ItemsPerConversion > 0 ? gained / (double)conv.ItemsPerConversion * conv.CoinsPerConversion : 0; + potentialCoins += coins; + rows.Add(new RateRow(" " + conv.ItemName, IltParse.N0(gained), IltParse.Compact(gained / hours))); + } + if (potentialCoins > 0) + rows.Add(new RateRow("Potential coins (items)", potentialCoins.ToString("0"), (potentialCoins / hours).ToString("0.0"))); + _rows = rows.ToArray(); + } + + /// What the pass-up figure is (shared with the Mini Remote's Stats). + public const string PassUpTooltip = + "Luminance that reached your bank without a \"You've banked\" line: your vassals' pass-up.\n" + + "Fellowship and Zone Share splits arrive the same silent way and are included."; + + // ── UI (render thread) ────────────────────────────────────────────────── + + public void Render() + { + // The session clock is the shared stats' (it and the coins reset together). + var start = _stats?.View is { } v && v.SessionSeconds > 0 ? v.SessionStartUtc : _start; + ImGui.TextDisabled($"Session {IltParse.Duration(DateTime.UtcNow - start)}"); + ImGui.SameLine(); + if (ImGui.SmallButton("Reset##rates")) _ctx.Post(ResetAll); + + if (ImGui.BeginTable("##iltrates", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV)) + { + ImGui.TableSetupColumn("Metric"); + ImGui.TableSetupColumn("Session"); + ImGui.TableSetupColumn("Per hour"); + ImGui.TableHeadersRow(); + foreach (var r in _rows) + { + ImGui.TableNextRow(); + ImGui.TableNextColumn(); ImGui.TextUnformatted(r.Label); + if (ReferenceEquals(r.Label, PassUpLabel) && ImGui.IsItemHovered()) ImGui.SetTooltip(PassUpTooltip); + ImGui.TableNextColumn(); ImGui.TextUnformatted(r.Total); + ImGui.TableNextColumn(); ImGui.TextColored(LegacyDashboardRenderer.ColTeal, r.PerHour); + } + ImGui.EndTable(); + } + + if (ImGui.TreeNode("Item -> coin conversions")) + { + RenderConversionEditor(); + ImGui.TreePop(); + } + } + + private string _newItemName = string.Empty; + + private void RenderConversionEditor() + { + var list = _ctx.State.Character.ItemConversions; + int remove = -1; + for (int i = 0; i < list.Count; i++) + { + var c = list[i]; + ImGui.PushID(i); + ImGui.TextUnformatted(c.ItemName); + ImGui.SameLine(220); + int items = c.ItemsPerConversion, coins = c.CoinsPerConversion; + ImGui.SetNextItemWidth(70); + if (ImGui.InputInt("items", ref items, 0)) c.ItemsPerConversion = Math.Max(1, items); + ImGui.SameLine(); + ImGui.SetNextItemWidth(70); + if (ImGui.InputInt("coins", ref coins, 0)) c.CoinsPerConversion = Math.Max(0, coins); + ImGui.SameLine(); + if (ImGui.SmallButton("x")) remove = i; + ImGui.PopID(); + } + if (remove >= 0) + { + var victim = list[remove]; + _ctx.Post(() => list.Remove(victim)); + } + + ImGui.SetNextItemWidth(200); + ImGui.InputTextWithHint("##newconv", "exact item name", ref _newItemName, 96u); + ImGui.SameLine(); + if (ImGui.SmallButton("Add") && _newItemName.Trim().Length > 0 + && !list.Any(c => c.ItemName.Equals(_newItemName.Trim(), StringComparison.OrdinalIgnoreCase))) + { + var added = new IltItemConversion { ItemName = _newItemName.Trim(), ItemsPerConversion = 100, CoinsPerConversion = 0 }; + _ctx.Post(() => list.Add(added)); + _newItemName = string.Empty; + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSigilChain.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSigilChain.cs new file mode 100644 index 0000000..4cdbb10 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSigilChain.cs @@ -0,0 +1,114 @@ +// IltSigilChain.cs - The Enlightenment Sigil craft chain for /enl 301-325 (ACECustom tier 5: +// T - 5 sigils and T x 2B luminance per target level T). Every craft is one plus one makes one: +// Enlightened Coin + Ancient Yalani Trinket = Ascension Coin +// Life Splitter + Plant = Lifebloom Resin +// Lifebloom Resin + Necrolytic Extract = Lifeblood Elixir +// Lifeblood Elixir + Ascension Coin = Enlightenment Sigil +// Pure math (no host access) so the planner and the host tests share it. Mirrors UB-IT's +// EnlightenmentSigilChainPolicy. +using System; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +/// Stack counts of every item in the sigil chain. +internal sealed class IltSigilStock +{ + public long Sigils, AscensionCoins, LifebloodElixirs, LifebloomResins; + public long EnlightenedCoins, YalaniTrinkets, NecrolyticExtracts, LifeSplitters, Plants; + + public IltSigilStock Clone() => (IltSigilStock)MemberwiseClone(); +} + +/// +/// What a sigil demand still needs after using stock from the top of the chain down. "ToCraft" are +/// crafts left to do (intermediates); "Short" are raw materials left to get. +/// +internal sealed class IltSigilShortfall +{ + public long SigilsNeeded, SigilsToCraft, AscensionToCraft, ElixirsToCraft, ResinsToCraft; + /// E-coins the Ascension Coin crafts use (before stock). + public long CoinsForCraft; + public long CoinsShort, TrinketsShort, ExtractsShort, SplittersShort, PlantsShort; + + /// Stock (with the whole chain) covers every sigil. + public bool Covered => CoinsShort == 0 && TrinketsShort == 0 && ExtractsShort == 0 && SplittersShort == 0 && PlantsShort == 0; +} + +internal static class IltSigilChain +{ + public const int FirstTarget = 301; + public const int LastTarget = 325; + + // Item names (ACECustom ships no WCIDs for these yet, so they are counted by name). + public const string AscensionCoin = "Ascension Coin"; + public const string YalaniTrinket = "Ancient Yalani Trinket"; + public const string LifeSplitter = "Life Splitter"; + public const string Plant = "Plant"; + public const string LifebloomResin = "Lifebloom Resin"; + public const string NecrolyticExtract = "Necrolytic Extract"; + public const string LifebloodElixir = "Lifeblood Elixir"; + + public static bool IsSigilTarget(int t) => t >= FirstTarget && t <= LastTarget; + + /// Sigils for target levels current+1 .. target that fall inside 301-325 (T - 5 each). + public static long SigilsForRange(int current, int target) + { + long total = 0; + for (int t = Math.Max(current + 1, FirstTarget); t <= Math.Min(target, LastTarget); t++) + total += Math.Max(0, t - 5); + return total; + } + + /// Shortfall for : sigils first, then coins / elixirs, then resins, then raws. + public static IltSigilShortfall Shortfall(long sigilsNeeded, IltSigilStock stock) + { + var s = new IltSigilShortfall { SigilsNeeded = Math.Max(0, sigilsNeeded) }; + if (s.SigilsNeeded == 0) return s; + stock ??= new IltSigilStock(); + s.SigilsToCraft = Short(s.SigilsNeeded, stock.Sigils); + s.AscensionToCraft = Short(s.SigilsToCraft, stock.AscensionCoins); + s.ElixirsToCraft = Short(s.SigilsToCraft, stock.LifebloodElixirs); + s.CoinsForCraft = s.AscensionToCraft; + s.CoinsShort = Short(s.AscensionToCraft, stock.EnlightenedCoins); + s.TrinketsShort = Short(s.AscensionToCraft, stock.YalaniTrinkets); + s.ResinsToCraft = Short(s.ElixirsToCraft, stock.LifebloomResins); + s.ExtractsShort = Short(s.ElixirsToCraft, stock.NecrolyticExtracts); + s.SplittersShort = Short(s.ResinsToCraft, stock.LifeSplitters); + s.PlantsShort = Short(s.ResinsToCraft, stock.Plants); + return s; + } + + /// Sigils the stock can make: finished sigils plus the scarcer of the two craft paths. + public static long Fulfillable(IltSigilStock stock) + { + if (stock == null) return 0; + long coins = stock.AscensionCoins + Math.Min(stock.EnlightenedCoins, stock.YalaniTrinkets); + long resins = stock.LifebloomResins + Math.Min(stock.LifeSplitters, stock.Plants); + long elixirs = stock.LifebloodElixirs + Math.Min(resins, stock.NecrolyticExtracts); + return stock.Sigils + Math.Min(coins, elixirs); + } + + /// + /// Splits the e-coin pool between Ascension Coin crafts (served first) and token conversion. + /// is what is still to get for both. + /// + public static void EcoinDemand(long coinsHave, long coinsForSigils, long tokensShort, int coinsPerToken, + out long tokensFromCoins, out long tokensStill, out long coinsNeeded) + { + long rate = Math.Max(1, coinsPerToken); + long have = Math.Max(0, coinsHave), sigil = Math.Max(0, coinsForSigils), tok = Math.Max(0, tokensShort); + tokensFromCoins = Math.Min(tok, Math.Max(0, have - sigil) / rate); + tokensStill = tok - tokensFromCoins; + coinsNeeded = Math.Max(0, sigil - have) + tokensStill * rate; + } + + /// True for a chain item name (stack names may be plural; "Plant" must be the whole name). + public static bool NameIs(string itemName, string chainName) + { + string n = (itemName ?? string.Empty).Trim(); + return n.Equals(chainName, StringComparison.OrdinalIgnoreCase) + || n.Equals(chainName + "s", StringComparison.OrdinalIgnoreCase); + } + + private static long Short(long demand, long have) => Math.Max(0, demand - Math.Max(0, have)); +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSplitArrows.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSplitArrows.cs new file mode 100644 index 0000000..0c56885 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSplitArrows.cs @@ -0,0 +1,205 @@ +// IltSplitArrows.cs — Split-arrow imbuer (Gear tab, P2). +// +// ILT missile weapons carry a split-arrow count (int 9031). Each White Quartz salvage +// application adds one split and uses one tink. Per weapon: +// needed = min(target - current, 10 - tinks, 10 - current) +// The imbuer applies full (100-unit) White Quartz bags, lowest workmanship first, with +// UseObjectOn(salvage, weapon). AC then shows its own craft confirmation — the player +// clicks it; the imbuer waits (20 s) for the "successfully applies" / "fails to apply" +// line before the next step. Nothing is ever applied without the Hub confirm first. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using ImGuiNET; +using RynthCore.Loot; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltSplitArrows : IIltFeature +{ + private const int MaterialWhiteQuartz = 46; + private const uint IntNumItemsInMaterial = 170; + private const uint IntItemWorkmanship = 105; + private const long StepTimeoutMs = 20_000; + + private static readonly Regex Applied = new( + @"^(?[\w\s]+) successfully applies the (?[\w\s\-]+?)(\sSalvage.*)(\s?\(100\))?\s\(workmanship (?\d+\.\d+)\) to the (?[\w\s\'\-]+)\.$", + RegexOptions.Compiled | RegexOptions.CultureInvariant); + private static readonly Regex Failed = new( + @"^(?[\w\s]+) fails to apply the (?[\w\s\-]+?)(\sSalvage.*)(\s?\(100\))?\s\(workmanship (?\d+\.\d+)\) to the (?[\w\s\'\-]+)\.", + RegexOptions.Compiled | RegexOptions.CultureInvariant); + + private readonly IltHubContext _ctx; + + // Job state (pump thread) + private int _weaponId; + private int _remaining; + private bool _waiting; + private long _stepStartedAt; + private volatile string _status = "idle"; + + // Render snapshot of eligible weapons + private volatile WeaponRow[] _weapons = Array.Empty(); + private long _lastScan; + private sealed record WeaponRow(int Id, string Name, int Splits, int Tinks, bool Imbued, int Needed); + + public IltSplitArrows(IltHubContext ctx) => _ctx = ctx; + + private IltGearState G => _ctx.State.Gear; + public bool Running => _weaponId != 0; + + private int Needed(WorldObject w) + { + var inv = _ctx.Inventory; + int cur = inv.Int(w, IltInventory.IntSplitArrowCount); + int tinks = inv.Int(w, IltInventory.IntNumTimesTinkered); + int target = Math.Clamp(G.SplitArrowTarget, 0, 10); + return Math.Max(0, Math.Min(target - cur, Math.Min(10 - tinks, 10 - cur))); + } + + /// Full White Quartz bags, lowest workmanship first. + private List QuartzBags() + { + var inv = _ctx.Inventory; + return inv.Items() + .Where(wo => wo.ObjectClass == AcObjectClass.Salvage + && (inv.Int(wo, IltInventory.IntMaterialType) == MaterialWhiteQuartz || wo.Name.Contains("White Quartz", StringComparison.OrdinalIgnoreCase)) + && inv.Uses(wo) >= 100) + .OrderBy(Workmanship) + .ToList(); + } + + private double Workmanship(WorldObject bag) + { + int total = _ctx.Inventory.Int(bag, IntItemWorkmanship); + int items = Math.Max(1, _ctx.Inventory.Int(bag, IntNumItemsInMaterial, 1)); + return total / (double)items; + } + + /// Starts imbuing one weapon (pump thread, after the UI confirm). + public void Start(int weaponId) + { + var w = _ctx.Inventory.Cache?[weaponId]; + if (w == null) { _status = "weapon not found"; return; } + if (_ctx.Inventory.IsEquipped(w)) { _status = "unequip the weapon first"; return; } + int need = Needed(w); + if (need <= 0) { _status = $"{w.Name} needs no more splits"; return; } + _weaponId = weaponId; + _remaining = need; + _waiting = false; + _status = $"imbuing {w.Name}: {need} application(s)"; + } + + public void Stop(string why) + { + _weaponId = 0; + _waiting = false; + _status = why; + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + if (nowMs - _lastScan >= 3000 && _ctx.WindowOpen) + { + _lastScan = nowMs; + ScanWeapons(); + } + if (_weaponId == 0) return; + + if (_waiting) + { + if (nowMs - _stepStartedAt > StepTimeoutMs) Stop("no result within 20 s (craft dialog not confirmed?) - stopped"); + return; + } + if (_remaining <= 0) { Stop("done"); return; } + if (_ctx.Inventory.IsBusy) return; + + var bag = QuartzBags().FirstOrDefault(); + if (bag == null) { Stop("out of full White Quartz bags"); return; } + if (_ctx.Inventory.UseOn(bag, unchecked((uint)_weaponId))) + { + _waiting = true; + _stepStartedAt = nowMs; + _status = $"applying {bag.Name} - confirm the craft dialog in AC ({_remaining} left)"; + } + } + + public bool OnChat(string text) + { + if (!_waiting) return false; + if (Applied.IsMatch(text)) + { + _waiting = false; + _remaining--; + _status = $"applied ({_remaining} left)"; + } + else if (Failed.IsMatch(text)) + { + // A failed tink still consumes a tink slot — recompute from the weapon. + _waiting = false; + var w = _ctx.Inventory.Cache?[_weaponId]; + _remaining = w != null ? Math.Min(_remaining, Needed(w)) : 0; + _status = $"application failed ({_remaining} left)"; + } + return false; + } + + public void OnLogout() => Stop("idle"); + + private void ScanWeapons() + { + var inv = _ctx.Inventory; + var rows = new List(); + foreach (var wo in inv.Items()) + { + if (wo.ObjectClass != AcObjectClass.MissileWeapon) continue; + bool imbued = inv.Int(wo, IltInventory.IntImbuedEffect) != 0; + if (imbued && G.SplitIgnoreImbued) continue; + rows.Add(new WeaponRow(wo.Id, wo.Name, inv.Int(wo, IltInventory.IntSplitArrowCount), + inv.Int(wo, IltInventory.IntNumTimesTinkered), imbued, Needed(wo))); + } + _weapons = rows.OrderByDescending(r => r.Needed).ThenBy(r => r.Name).ToArray(); + _bagCount = QuartzBags().Count; + } + + private volatile int _bagCount; + + // ── UI (render thread) ────────────────────────────────────────────────── + + public void Render() + { + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Split arrows (White Quartz)"); + int tgt = G.SplitArrowTarget; + ImGui.SetNextItemWidth(120); + if (ImGui.SliderInt("Target splits", ref tgt, 0, 10)) G.SplitArrowTarget = tgt; + ImGui.SameLine(); + bool skip = G.SplitIgnoreImbued; + if (ImGui.Checkbox("Skip imbued weapons", ref skip)) G.SplitIgnoreImbued = skip; + ImGui.TextDisabled($"Full White Quartz bags carried: {_bagCount}"); + + foreach (var w in _weapons) + { + ImGui.PushID(w.Id); + ImGui.TextUnformatted($"{w.Name} splits {w.Splits}, tinks {w.Tinks}{(w.Imbued ? ", imbued" : "")}"); + ImGui.SameLine(); + ImGui.BeginDisabled(w.Needed <= 0 || Running); + if (ImGui.SmallButton($"Imbue +{w.Needed}")) + { + var row = w; + _ctx.Confirm("Split-arrow imbue", + $"Apply {row.Needed} White Quartz bag(s) to {row.Name}?\n\nEach application uses a tink and can fail.\n" + + "AC will ask you to confirm every craft.", + () => Start(row.Id), "Start"); + } + ImGui.EndDisabled(); + ImGui.PopID(); + } + if (_weapons.Length == 0) ImGui.TextDisabled("No missile weapons carried."); + if (Running && ImGui.SmallButton("Stop imbuing")) _ctx.Post(() => Stop("stopped by player")); + ImGui.TextDisabled("Status: " + _status); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltTempleAttributes.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltTempleAttributes.cs new file mode 100644 index 0000000..c8c4939 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltTempleAttributes.cs @@ -0,0 +1,298 @@ +// IltTempleAttributes.cs - Temple of Enlightenment attribute turn-in tracker (Guardian window). +// +// One row per Fiun attribute NPC plus the Guardian of Attribute Enlightenment riddle. Each row +// prefers the timed flag from /myquests (solves + exact cooldown). When /myquests lacks the flag +// it falls back to the "/qb list" wait stamp: a stamp appearing between two lists counts one +// turn-in and starts an estimated cooldown (CooldownHoursAssumed). Fallback counts and timers +// persist in IltGuardianState. +// +// Rows come from "infi attribute.csv" (RynthAi folder, then Documents\Asheron's Call - the UB +// location) when present: npc, attribute, stamp [, myQuestsKey]. Built-in rows missing from the +// file are appended. Pump thread computes; the render thread only reads Snapshot. +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using RynthCore.Install; +using RynthCore.Plugin.RynthAi.Meta; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +/// One tracked turn-in: the NPC, its attribute, the /qb wait flag and the /myquests keys to try. +internal sealed class IltTempleAttrRow +{ + public IltTempleAttrRow(string npc, string attribute, string stamp, string? myQuestsKey = null) + { + Npc = npc.Trim(); + Attribute = attribute.Trim(); + QbWaitFlag = ExtractQbFlag(stamp); + var keys = new List(); + void Add(string? k) + { + if (string.IsNullOrWhiteSpace(k)) return; + string t = k.Trim().ToLowerInvariant(); + if (!keys.Contains(t)) keys.Add(t); + } + Add(myQuestsKey); + Add(QbWaitFlag); + if (QbWaitFlag.EndsWith("Wait", StringComparison.OrdinalIgnoreCase) && QbWaitFlag.Length > 4) + Add(QbWaitFlag[..^4]); + MyQuestsKeys = keys.ToArray(); + } + + public string Npc { get; } + public string Attribute { get; } + /// /qb flag name (e.g. TempleAttributeStrengthWait). + public string QbWaitFlag { get; } + /// Lowercase /myquests keys in lookup order: CSV override, the wait flag, the flag without "Wait". + public string[] MyQuestsKeys { get; } + + /// "You've stamped X!" → "X"; a bare flag name is returned trimmed. + private static string ExtractQbFlag(string stamp) + { + string s = (stamp ?? string.Empty).Trim(); + const string prefix = "You've stamped "; + if (s.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) s = s[prefix.Length..]; + return s.Trim().TrimEnd('!', ' ', '\t', '\r', '\n'); + } +} + +/// What the Guardian window shows for one row. +internal sealed record IltTempleAttrStatus(string Attribute, string Npc, int Count, string Status, string Eta, bool Ready, bool FromMyQuests); + +internal sealed class IltTempleAttributes +{ + private const long RebuildIntervalMs = 1000; + private const string CsvName = "infi attribute.csv"; + + private static readonly IltTempleAttrRow[] DefaultRows = + { + new("Fiun Luunere", "Strength", "TempleAttributeStrengthWait"), + new("Fiun Bayaas", "Coordination", "TempleAttributeCoordinationWait"), + new("Fiun Ruun", "Endurance", "TempleAttributeEnduranceWait"), + new("Fiun Riish", "Quickness", "TempleAttributeQuicknessWait"), + new("Fiun Vasherr", "Focus", "TempleAttributeFocusWait"), + new("Fiun Noress", "Willpower", "TempleAttributeSelfWait"), + new("Fiun Vaelesh", "Health", "TempleAttributeHealthWait"), + new("Fiun Torrun", "Stamina", "TempleAttributeStamWait"), + new("Fiun Saeluun", "Mana", "TempleAttributeManaWait"), + new("Guardian (Attr)", "Riddle", "TempleAttributeRiddleWait"), + }; + + private readonly IltHubContext _ctx; + private readonly Func _tracker; + private readonly IltQuests _quests; + private readonly IltTempleAttrRow[] _rows; + // Wait-stamp presence per attribute at the previous "/qb list" (session only: a transition + // needs two lists in the same session). + private readonly Dictionary _lastHadWait = new(StringComparer.OrdinalIgnoreCase); + private int _seenQbGeneration; + private long _lastRebuildAt = -RebuildIntervalMs; + + private volatile IltTempleAttrStatus[] _snapshot = Array.Empty(); + private DateTime _syncedUtc = DateTime.MinValue; + + public IltTempleAttributes(IltHubContext ctx, Func tracker, IltQuests quests) + { + _ctx = ctx; + _tracker = tracker; + _quests = quests; + _rows = LoadRows(out string source); + RynthLog.Write(LogCat.IltHub, $"[IltGuardian] attribute rows: {_rows.Length} from {source}"); + } + + /// Rows as last computed (render thread reads this). + public IltTempleAttrStatus[] Snapshot => _snapshot; + + /// When the quest data behind the rows last changed (MinValue = never this session). + public DateTime SyncedUtc => _syncedUtc; + + private IltGuardianState S => _ctx.State.Guardian; + + // ── Rows file ─────────────────────────────────────────────────────────── + + /// The CSV in the RynthAi folder, else UB's Documents location; built-in rows otherwise. + private static IltTempleAttrRow[] LoadRows(out string source) + { + string[] candidates = + { + Path.Combine(RynthInstallPaths.RynthAiDir, CsvName), + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Asheron's Call", CsvName), + }; + foreach (string path in candidates) + { + try + { + if (!File.Exists(path)) continue; + var rows = ParseCsv(File.ReadAllLines(path)); + if (rows.Count == 0) continue; + source = path; + return MergeMissingDefaults(rows); + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, $"read {path}"); } + } + source = "built-in table"; + return DefaultRows; + } + + /// npc, attribute, stamp [, myQuestsKey]; a header row and blank lines are skipped. + private static List ParseCsv(string[] lines) + { + var rows = new List(); + foreach (string raw in lines) + { + string line = raw.Trim().TrimStart('\uFEFF'); + if (line.Length == 0) continue; + if (line.StartsWith("npc", StringComparison.OrdinalIgnoreCase) && line.Contains("attribute", StringComparison.OrdinalIgnoreCase)) + continue; + string[] seg = line.Split(','); + if (seg.Length < 3) continue; + string npc = seg[0].Trim(), attr = seg[1].Trim(); + string stamp; + string? key = null; + if (seg.Length == 4) { stamp = seg[2].Trim(); key = seg[3].Trim(); } + else stamp = string.Join(",", seg.Skip(2)).Trim(); // a full stamp chat line may contain commas + if (npc.Length == 0 || attr.Length == 0 || stamp.Length == 0) continue; + rows.Add(new IltTempleAttrRow(npc, attr, stamp, key)); + } + return rows; + } + + private static IltTempleAttrRow[] MergeMissingDefaults(List loaded) + { + var seen = new HashSet(loaded.Select(r => r.QbWaitFlag), StringComparer.OrdinalIgnoreCase); + foreach (var def in DefaultRows) + if (seen.Add(def.QbWaitFlag)) loaded.Add(def); + return loaded.ToArray(); + } + + // ── Pump thread ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) + { + int gen = _quests.QbGeneration; + if (gen != _seenQbGeneration) + { + _seenQbGeneration = gen; + if (gen > 0) ApplyQbTransitions(); + _syncedUtc = DateTime.UtcNow; + } + if (nowMs - _lastRebuildAt < RebuildIntervalMs) return; + _lastRebuildAt = nowMs; + Rebuild(); + } + + /// Re-asks the server for /myquests and "/qb list" (each limited to once a minute). + public string Refresh() => $"{_quests.RefreshQuests()} {_quests.RefreshQb()}"; + + /// Forgets the counted turn-ins and estimated cooldowns (the /qb fallback only). + public void ResetCounts() + { + S.TurnInCounts.Clear(); + S.CooldownUntilUtc.Clear(); + _lastRebuildAt = long.MinValue / 2; + } + + public void OnLogout() + { + _lastHadWait.Clear(); + _seenQbGeneration = 0; + _syncedUtc = DateTime.MinValue; + } + + private bool TryQuest(IltTempleAttrRow row, out QuestRecord rec) + { + rec = null!; + var t = _tracker(); + if (t == null) return false; + foreach (string key in row.MyQuestsKeys) + if (t.TryGetFlag(key, out rec)) return true; + return false; + } + + /// A new "/qb list" arrived: count wait stamps that appeared since the previous list. + private void ApplyQbTransitions() + { + int hours = Math.Max(1, S.CooldownHoursAssumed); + foreach (var row in _rows) + { + string key = row.Attribute; + bool hasWait = _quests.QbHasFlag(row.QbWaitFlag); + if (!TryQuest(row, out _)) + { + if (_lastHadWait.TryGetValue(key, out bool had) && !had && hasWait) + { + S.TurnInCounts[key] = (S.TurnInCounts.TryGetValue(key, out int n) ? n : 0) + 1; + S.CooldownUntilUtc[key] = DateTime.UtcNow.AddHours(hours); + RynthLog.Write(LogCat.IltHub, $"[IltGuardian] {key} turn-in counted from /qb (now {S.TurnInCounts[key]})"); + } + if (!hasWait) S.CooldownUntilUtc.Remove(key); + } + _lastHadWait[key] = hasWait; + } + } + + private void Rebuild() + { + bool qbLoaded = _quests.QbGeneration > 0; + int hours = Math.Max(1, S.CooldownHoursAssumed); + var list = new IltTempleAttrStatus[_rows.Length]; + for (int i = 0; i < _rows.Length; i++) + { + var row = _rows[i]; + if (TryQuest(row, out var rec)) + { + list[i] = FromQuest(row, rec); + continue; + } + + string key = row.Attribute; + int count = S.TurnInCounts.TryGetValue(key, out int c) ? c : 0; + if (!qbLoaded) + { + list[i] = new(key, row.Npc, count, "Unknown", "Refresh", false, false); + continue; + } + if (!_quests.QbHasFlag(row.QbWaitFlag)) + { + list[i] = new(key, row.Npc, count, "Ready", "-", true, false); + continue; + } + + // Wait stamp present: show the estimated cooldown, starting one if none is known. + if (!S.CooldownUntilUtc.TryGetValue(key, out DateTime until)) + S.CooldownUntilUtc[key] = until = DateTime.UtcNow.AddHours(hours); + until = AsUtc(until); + TimeSpan left = until - DateTime.UtcNow; + list[i] = left > TimeSpan.Zero + ? new(key, row.Npc, count, "Wait stamp", $"~{IltParse.Duration(left)} (est.)", false, false) + : new(key, row.Npc, count, "Wait stamp", "ready? (est.)", false, false); + } + _snapshot = list; + } + + /// A row backed by its /myquests flag: exact solves and cooldown. + private static IltTempleAttrStatus FromQuest(IltTempleAttrRow row, QuestRecord rec) + { + switch (IltQuests.Classify(rec)) + { + case IltQuests.QuestKind.KillTask: + return new(row.Attribute, row.Npc, rec.Solves, "Kill task", $"{rec.Solves}/{rec.MaxSolves}", false, true); + case IltQuests.QuestKind.Once: + return new(row.Attribute, row.Npc, rec.Solves, "Once", rec.Solves >= 1 ? "done" : "-", false, true); + default: + if (rec.IsReady()) return new(row.Attribute, row.Npc, rec.Solves, "Ready", "now", true, true); + TimeSpan left = rec.TimeUntilReady(); + string at = DateTime.Now.Add(left).ToString("ddd HH:mm"); + return new(row.Attribute, row.Npc, rec.Solves, "Cooldown", $"{IltParse.Duration(left)} ({at})", false, true); + } + } + + /// Stored times may load as Unspecified; they were written as UTC. + private static DateTime AsUtc(DateTime dt) => dt.Kind switch + { + DateTimeKind.Utc => dt, + DateTimeKind.Local => dt.ToUniversalTime(), + _ => DateTime.SpecifyKind(dt, DateTimeKind.Utc), + }; +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltUsdImporter.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltUsdImporter.cs new file mode 100644 index 0000000..d444a03 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltUsdImporter.cs @@ -0,0 +1,351 @@ +// IltUsdImporter.cs — VirindiTank .usd settings → RynthAi monster / weapon / consumable rules (Gear tab, P2). +// +// .usd is VTank's line-based table dump. Each table is: +// +// +// x count +// x count +// +// per cell: then +// Tables we read: MyMonsters (monster rules), weapons/wands/shields/combatitems (weapon +// rules), pets (pet essences), items/itemlist/buffeditems/AssistItems (consumables). +// Object ids are resolved against the current inventory (id first, then name). The +// import is previewed first and only applied after a confirm; existing rules with the +// same name / id are replaced, everything else is kept. +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using ImGuiNET; +using RynthCore.Loot; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal sealed class IltUsdImporter +{ + /// Default VTank profile folder when the Decal registry value is unavailable. + public const string DefaultVtProfileDir = @"C:\Games\VirindiPlugins\VirindiTank\"; + + private static readonly string[] Elements = { "Slash", "Pierce", "Bludgeon", "Fire", "Cold", "Lightning", "Acid", "Nether" }; + private static readonly HashSet WeaponTables = new(StringComparer.OrdinalIgnoreCase) { "weapons", "wands", "shields", "combatitems" }; + private static readonly HashSet ConsumableTables = new(StringComparer.OrdinalIgnoreCase) { "items", "itemlist", "buffeditems", "assistitems" }; + + /// One parsed table: column names and rows of raw cell strings. + private sealed class UsdTable + { + public string Name = string.Empty; + public string[] Columns = Array.Empty(); + public List Rows = new(); + + public string Get(string[] row, params string[] names) + { + foreach (string n in names) + { + int i = Array.FindIndex(Columns, c => c.Equals(n, StringComparison.OrdinalIgnoreCase)); + if (i >= 0 && i < row.Length) return row[i] ?? string.Empty; + } + return string.Empty; + } + } + + /// Result of a preview: the rules that would be written. + private sealed class ImportPlan + { + public string Path = string.Empty; + public List Monsters = new(); + public List Weapons = new(); + public List Consumables = new(); + public List Notes = new(); + } + + private readonly IltHubContext _ctx; + private volatile ImportPlan? _plan; + private volatile string _status = string.Empty; + private string _pathInput = string.Empty; + + public IltUsdImporter(IltHubContext ctx) + { + _ctx = ctx; + _pathInput = ctx.State.Gear.LastUsdPath; + } + + /// VTank's profile folder from Decal's registry entry, else the default install path. + public static string VtProfileDir() + { + try + { + using var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Software\Decal\Plugins\{642F1F48-16BE-48BF-B1D4-286652C4533E}"); + if (key?.GetValue("ProfilePath") is string p && p.Length > 0 && Directory.Exists(p)) return p; + } + catch { /* registry unavailable: fall back */ } + return DefaultVtProfileDir; + } + + // ── Parsing ───────────────────────────────────────────────────────────── + + private static List Parse(string[] lines) + { + var tables = new List(); + int i = 0; + while (i < lines.Length - 1) + { + string name = lines[i].Trim(); + if (name.Length == 0 || !int.TryParse(lines[i + 1].Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int cols) + || cols < 1 || cols > 32 || name.Any(char.IsWhiteSpace)) + { + i++; + continue; + } + + int p = i + 2; + if (p + cols * 2 >= lines.Length) { i++; continue; } + var t = new UsdTable { Name = name, Columns = new string[cols] }; + for (int c = 0; c < cols; c++) t.Columns[c] = lines[p++].Trim(); + p += cols; // type tokens + if (p >= lines.Length || !int.TryParse(lines[p].Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int rows) || rows < 0 || rows > 100_000) + { + i++; + continue; + } + p++; + bool ok = true; + for (int r = 0; r < rows && ok; r++) + { + var row = new string[cols]; + for (int c = 0; c < cols; c++) + { + if (p + 1 >= lines.Length) { ok = false; break; } + // Every cell is a tag line plus a value line; unknown tags are still two lines. + row[c] = lines[p + 1].Trim(); + p += 2; + } + if (ok) t.Rows.Add(row); + } + tables.Add(t); + i = p; + } + return tables; + } + + private static int ParseId(string s) + { + s = s.Trim(); + if (s.StartsWith("0x", StringComparison.OrdinalIgnoreCase) + && int.TryParse(s.AsSpan(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int hex)) return hex; + if (long.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out long l)) return unchecked((int)l); + return 0; + } + + private static bool ValidId(int id) => id != 0 && id != -1 && id != -5; + + private static bool ParseBool(string s) + => s.Equals("true", StringComparison.OrdinalIgnoreCase) || s == "1" || s.Equals("yes", StringComparison.OrdinalIgnoreCase); + + /// VTank damage value (name or AC damage-type bitmask) → RynthAi element, or null. + private static string? MapElement(string v) + { + v = v.Trim(); + if (v.Length == 0) return null; + foreach (string e in Elements) if (v.Equals(e, StringComparison.OrdinalIgnoreCase)) return e; + if (v.StartsWith("Bludg", StringComparison.OrdinalIgnoreCase)) return "Bludgeon"; + if (v.StartsWith("Pierc", StringComparison.OrdinalIgnoreCase)) return "Pierce"; + if (v.StartsWith("Electric", StringComparison.OrdinalIgnoreCase)) return "Lightning"; + if (v.StartsWith("Void", StringComparison.OrdinalIgnoreCase)) return "Nether"; + if (!int.TryParse(v, NumberStyles.Integer, CultureInfo.InvariantCulture, out int dt) || dt <= 0) return null; + return BitsToElement(dt); + } + + private static string? BitsToElement(int dt) + { + if ((dt & 1024) != 0) return "Nether"; + if ((dt & 16) != 0) return "Fire"; + if ((dt & 8) != 0) return "Cold"; + if ((dt & 64) != 0) return "Lightning"; + if ((dt & 32) != 0) return "Acid"; + if ((dt & 4) != 0) return "Bludgeon"; + if ((dt & 2) != 0) return "Pierce"; + if ((dt & 1) != 0) return "Slash"; + return null; + } + + /// Resolves a USD object (id, name) to a carried item. + private WorldObject? Resolve(int id, string name) + { + var cache = _ctx.Inventory.Cache; + if (cache == null) return null; + if (ValidId(id)) + { + var byId = cache[id]; + if (byId != null) return byId; + } + if (string.IsNullOrWhiteSpace(name)) return null; + return _ctx.Inventory.Items().FirstOrDefault(w => w.Name.Equals(name.Trim(), StringComparison.OrdinalIgnoreCase)); + } + + private static string ConsumableType(string name) + { + string n = name.ToLowerInvariant(); + if (n.Contains("essence")) return "Pet"; + if (n.Contains("kit")) return "HealthKit"; + if (n.Contains("mana stone") || n.Contains("mana charge")) return "ManaStone"; + if (n.Contains("stamina")) return "Stamina"; + if (n.Contains("lockpick")) return "Lockpick"; + return "General"; + } + + // ── Preview / apply (pump thread) ─────────────────────────────────────── + + public void Preview(string path) + { + path = (path ?? string.Empty).Trim().Trim('"'); + if (path.Length > 0 && !Path.IsPathRooted(path)) path = Path.Combine(VtProfileDir(), path); + if (!File.Exists(path)) { _status = "File not found: " + path; _plan = null; return; } + + string[] lines; + try { lines = File.ReadAllLines(path); } + catch (Exception ex) { _status = "Read failed: " + ex.Message; _plan = null; return; } + + var plan = new ImportPlan { Path = path }; + foreach (var t in Parse(lines)) + { + if (t.Name.Equals("MyMonsters", StringComparison.OrdinalIgnoreCase)) PlanMonsters(t, plan); + else if (WeaponTables.Contains(t.Name)) PlanWeapons(t, plan); + else if (t.Name.Equals("pets", StringComparison.OrdinalIgnoreCase)) PlanConsumables(t, plan, forceType: "Pet"); + else if (ConsumableTables.Contains(t.Name)) PlanConsumables(t, plan, forceType: null); + } + _ctx.State.Gear.LastUsdPath = path; + _plan = plan; + _status = $"Preview: {plan.Monsters.Count} monsters, {plan.Weapons.Count} weapons, {plan.Consumables.Count} consumables."; + } + + private void PlanMonsters(UsdTable t, ImportPlan plan) + { + foreach (var row in t.Rows) + { + string name = t.Get(row, "MonsterName", "Name").Trim(); + if (name.Length == 0) continue; + var rule = new MonsterRule + { + Name = name, + Priority = int.TryParse(t.Get(row, "AttackPriority", "Priority"), out int pri) ? Math.Max(0, pri) : 1, + DamageType = MapElement(t.Get(row, "DamageType")) ?? "Auto", + ExVuln = MapElement(t.Get(row, "SecondaryVuln", "ExtraVuln")) ?? "None", + PetDamage = MapElement(t.Get(row, "PetDamage")) ?? "PAuto", + UseRing = ParseBool(t.Get(row, "Ring")), + UseStreak = ParseBool(t.Get(row, "Streak")), + UseArc = ParseBool(t.Get(row, "Arc")), + Fester = ParseBool(t.Get(row, "Fester")), + Broadside = ParseBool(t.Get(row, "Broadside")), + GravityWell = ParseBool(t.Get(row, "GravityW", "GravityWell")), + Imperil = ParseBool(t.Get(row, "Imperil")), + Yield = ParseBool(t.Get(row, "Yield")), + Vuln = ParseBool(t.Get(row, "Vuln")), + }; + var weapon = Resolve(ParseId(t.Get(row, "WeaponToUse", "Weapon")), t.Get(row, "WeaponName")); + if (weapon != null) rule.WeaponId = weapon.Id; + else if (t.Get(row, "WeaponName").Length > 0) plan.Notes.Add($"{name}: weapon '{t.Get(row, "WeaponName")}' not carried"); + var off = Resolve(ParseId(t.Get(row, "SecondaryEquip", "Offhand")), t.Get(row, "OffhandName")); + if (off != null) rule.OffhandId = off.Id; + plan.Monsters.Add(rule); + } + } + + private void PlanWeapons(UsdTable t, ImportPlan plan) + { + // The VT "shields" table (or any row whose item wields into the shield slot) + // becomes an off-hand Shield entry, never a main-hand weapon. + bool shieldTable = t.Name.Equals("shields", StringComparison.OrdinalIgnoreCase); + foreach (var row in t.Rows) + { + int id = ParseId(t.Get(row, "Object", "ObjectId", "Id")); + string name = t.Get(row, "Name").Trim(); + var wo = Resolve(id, name); + if (wo == null) { if (name.Length > 0) plan.Notes.Add($"weapon '{name}' not carried"); continue; } + if (plan.Weapons.Any(w => w.Id == wo.Id)) continue; + bool isShield = shieldTable || RynthCore.Plugin.RynthAi.CombatManager.IsShieldItem(wo); + string element = BitsToElement(wo.Values(LongValueKey.DamageType, 0)) ?? "Slash"; + plan.Weapons.Add(new ItemRule + { + Id = wo.Id, + Name = wo.Name, + Action = isShield ? ItemRule.ShieldAction : ItemRule.WeaponAction, + Element = element, + }); + } + } + + private void PlanConsumables(UsdTable t, ImportPlan plan, string? forceType) + { + foreach (var row in t.Rows) + { + int id = ParseId(t.Get(row, "Object", "ObjectId", "Id")); + string name = t.Get(row, "Name").Trim(); + var wo = Resolve(id, name); + if (wo == null) { if (name.Length > 0) plan.Notes.Add($"item '{name}' not carried"); continue; } + if (wo.ObjectClass is AcObjectClass.MeleeWeapon or AcObjectClass.MissileWeapon or AcObjectClass.WandStaffOrb) continue; + if (plan.Consumables.Any(c => c.Id == wo.Id)) continue; + plan.Consumables.Add(new ConsumableRule { Id = wo.Id, Name = wo.Name, Type = forceType ?? ConsumableType(wo.Name) }); + } + } + + /// Writes the previewed rules into the live settings and saves them. + public void Apply() + { + var plan = _plan; + var s = _ctx.Settings; + if (plan == null || s == null) { _status = "Nothing to apply."; return; } + + foreach (var m in plan.Monsters) + { + s.MonsterRules.RemoveAll(r => r.Name.Equals(m.Name, StringComparison.OrdinalIgnoreCase)); + s.MonsterRules.Add(m); + } + foreach (var w in plan.Weapons) + { + s.ItemRules.RemoveAll(r => r.Id == w.Id); + s.ItemRules.Add(w); + } + foreach (var c in plan.Consumables) + { + s.ConsumableRules.RemoveAll(r => r.Id == c.Id); + s.ConsumableRules.Add(c); + } + _ctx.SaveCombatSettings?.Invoke(); + _status = $"Imported {plan.Monsters.Count} monsters, {plan.Weapons.Count} weapons, {plan.Consumables.Count} consumables."; + _ctx.Chat("[Mini Remote] " + _status); + _plan = null; + } + + // ── UI (render thread) ────────────────────────────────────────────────── + + public void Render() + { + ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Import VirindiTank settings (.usd)"); + ImGui.SetNextItemWidth(320); + ImGui.InputTextWithHint("##usdpath", @"full path or file name in C:\Games\VirindiPlugins\VirindiTank", ref _pathInput, 260u); + ImGui.SameLine(); + string p = _pathInput; + if (ImGui.SmallButton("Preview")) _ctx.Post(() => Preview(p)); + + var plan = _plan; + if (plan != null) + { + ImGui.TextUnformatted($"{plan.Monsters.Count} monster rules, {plan.Weapons.Count} weapons, {plan.Consumables.Count} consumables"); + if (ImGui.TreeNode("Preview details")) + { + foreach (var m in plan.Monsters.Take(50)) ImGui.BulletText($"Monster {m.Name} [{m.DamageType}] pri {m.Priority}"); + foreach (var w in plan.Weapons) ImGui.BulletText($"Weapon {w.Name} [{w.Element}]"); + foreach (var c in plan.Consumables) ImGui.BulletText($"{c.Type}: {c.Name}"); + foreach (var n in plan.Notes.Take(30)) ImGui.TextColored(LegacyDashboardRenderer.ColAmber, n); + ImGui.TreePop(); + } + if (ImGui.Button("Apply import...")) + _ctx.Confirm("Import VTank settings", + $"Write these rules into the current RynthAi profile?\nRules with the same monster name / item id are replaced.", + Apply, "Import"); + } + if (_status.Length > 0) ImGui.TextWrapped(_status); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/ServerFeatureGate.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/ServerFeatureGate.cs new file mode 100644 index 0000000..15643b5 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/IltHub/ServerFeatureGate.cs @@ -0,0 +1,129 @@ +// ServerFeatureGate.cs — Which worlds get the ILT / infinite-attribute features. +// +// One gate for everything ILT-shaped: the ILT Hub and Mini Remote, the Skills panel's +// Progression planners and the attribute raiser. A world is "on" when: +// * its name matches one of the server patterns in Settings > Misc (FeatureServerNames, +// '*' wildcard, case-insensitive; defaults cover InfiniteLeaftide), or +// * the manual override is ticked (Settings > Misc ForceServerFeatures, or the older +// per-character ILT Hub "Treat this world as ILT" / "/ra hub force on"). +// The gate only decides whether RynthAi ASKS the server; each feature still follows the +// server's own report (IltServerOptions bits), so a shard with /xp off keeps the raiser off. +using System; +using System.Collections.Generic; +using System.Linq; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.IltHub; + +internal static class ServerFeatureGate +{ + /// Patterns a fresh profile starts with (the names the old hard-coded check accepted). + public static readonly string[] DefaultServerNames = { "InfiniteLeaftide", "*Leaftide*" }; + + /// World name of the current session; set by RynthAiPlugin (empty before login). + public static Func? WorldNameProvider; + + /// The per-character ILT Hub override (ilt-hub.json); set by the Hub while it exists. + public static Func? HubForceProvider; + + public static string CurrentWorld + { + get + { + try { return (WorldNameProvider?.Invoke() ?? string.Empty).Trim(); } + catch { return string.Empty; } + } + } + + /// The patterns in force: the profile's list, or the defaults when there is no profile yet. + public static IReadOnlyList Patterns(LegacyUiSettings? settings) + => settings?.FeatureServerNames ?? (IReadOnlyList)DefaultServerNames; + + /// True when matches one of . + public static bool NameMatches(string world, IEnumerable? patterns, out string matched) + { + matched = string.Empty; + if (string.IsNullOrWhiteSpace(world) || patterns == null) return false; + foreach (string p in patterns) + { + if (string.IsNullOrWhiteSpace(p)) continue; + if (!Matches(world.Trim(), p.Trim())) continue; + matched = p.Trim(); + return true; + } + return false; + } + + /// Case-insensitive match where '*' stands for any run of characters (anywhere in the pattern). + public static bool Matches(string text, string pattern) + { + if (pattern.Length == 0) return false; + if (!pattern.Contains('*')) return text.Equals(pattern, StringComparison.OrdinalIgnoreCase); + + string[] parts = pattern.Split('*'); + int pos = 0; + for (int i = 0; i < parts.Length; i++) + { + string part = parts[i]; + if (part.Length == 0) continue; + if (i == 0) + { + if (!text.StartsWith(part, StringComparison.OrdinalIgnoreCase)) return false; + pos = part.Length; + continue; + } + if (i == parts.Length - 1) + return text.Length - pos >= part.Length && text.EndsWith(part, StringComparison.OrdinalIgnoreCase); + int at = text.IndexOf(part, pos, StringComparison.OrdinalIgnoreCase); + if (at < 0) return false; + pos = at + part.Length; + } + return true; + } + + /// Is the override on (Settings > Misc, or the per-character Hub checkbox)? + public static bool ForceOn(LegacyUiSettings? settings) + { + if (settings?.ForceServerFeatures == true) return true; + try { return HubForceProvider?.Invoke() == true; } + catch { return false; } + } + + /// The gate itself. + public static bool IsEnabled(string world, LegacyUiSettings? settings) + => ForceOn(settings) || NameMatches(world, Patterns(settings), out _); + + /// "InfiniteLeaftide, *Leaftide*" → trimmed, de-duplicated list (case-insensitive). + public static List ParseList(string? text) + { + var list = new List(); + if (string.IsNullOrWhiteSpace(text)) return list; + foreach (string raw in text.Split(new[] { ',', ';', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)) + { + string p = raw.Trim(); + if (p.Length > 0 && !list.Contains(p, StringComparer.OrdinalIgnoreCase)) list.Add(p); + } + return list; + } + + public static string FormatList(IEnumerable? patterns) + => patterns == null ? string.Empty : string.Join(", ", patterns.Where(p => !string.IsNullOrWhiteSpace(p))); + + /// One status line for Settings > Misc: the world, whether the features are on, and why. + public static string Describe(LegacyUiSettings? settings) + { + string world = CurrentWorld; + string shown = world.Length > 0 ? $"'{world}'" : "(not logged in)"; + if (settings?.ForceServerFeatures == true) + return $"This world {shown}: ON - manual override."; + if (NameMatches(world, Patterns(settings), out string matched)) + return $"This world {shown}: ON - matches '{matched}'."; + bool hubForce; + try { hubForce = HubForceProvider?.Invoke() == true; } catch { hubForce = false; } + if (hubForce) + return $"This world {shown}: ON - the Mini Remote's \"Treat this world as ILT\" override."; + return world.Length > 0 + ? $"This world {shown}: OFF - not in the list. Add it, or tick the override." + : "This world: not logged in yet."; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/ImGuiNativeBinding.cs b/Plugins/RynthCore.Plugin.RynthAi/ImGuiNativeBinding.cs new file mode 100644 index 0000000..9d75b96 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/ImGuiNativeBinding.cs @@ -0,0 +1,69 @@ +// ImGuiNativeBinding.cs - Binds ImGui.NET's "cimgui" P/Invokes to the cimgui module the +// engine already loaded. +// +// The engine ships its own build as RynthCore.cimgui.dll. Without this resolver, Windows +// resolves "cimgui" to a separate cimgui.dll: a second ImGui instance whose windows (ILT Hub, +// Pets, Quests, Mini Remote, Item HUD) are built but never reach the engine's draw data. +using System; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Threading; +using ImGuiNET; + +namespace RynthCore.Plugin.RynthAi; + +internal static class ImGuiNativeBinding +{ + private const string EngineModule = "RynthCore.cimgui.dll"; + private const string LegacyModule = "cimgui.dll"; + + private static int _configured; // 1 once the resolver is registered (survives DLL-copy reuse) + private static int _resolvedLogged; + + /// + /// Registers the resolver. Call before the first ImGui call (Initialize). The resolver can be + /// set only once per assembly, so later calls (a reused plugin DLL copy) are no-ops. + /// + public static void Ensure() + { + if (Interlocked.Exchange(ref _configured, 1) != 0) return; + try + { + NativeLibrary.SetDllImportResolver(typeof(ImGui).Assembly, Resolve); + RynthLog.Write(LogCat.UI, "[ImGui] native resolver registered (prefers the engine's " + EngineModule + ")."); + } + catch (InvalidOperationException) + { + // Already registered by an earlier instance in this process. + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.UI, ex, "ImGuiNativeBinding.Ensure"); + } + } + + /// Runs on the first cimgui P/Invoke: the engine's module, else whatever cimgui.dll is loaded. + private static IntPtr Resolve(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) + { + if (!string.Equals(libraryName, "cimgui", StringComparison.OrdinalIgnoreCase) && + !string.Equals(libraryName, LegacyModule, StringComparison.OrdinalIgnoreCase)) + return IntPtr.Zero; + + string bound = EngineModule; + IntPtr module = GetModuleHandleA(EngineModule); + if (module == IntPtr.Zero) + { + bound = LegacyModule; + module = GetModuleHandleA(LegacyModule); + } + + if (Interlocked.Exchange(ref _resolvedLogged, 1) == 0) + RynthLog.Write(LogCat.UI, module != IntPtr.Zero + ? $"[ImGui] cimgui bound to loaded {bound} (0x{module.ToInt64():X})." + : "[ImGui] no loaded cimgui module found; falling back to the default DLL search."); + return module; // IntPtr.Zero = default resolution + } + + [DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)] + private static extern IntPtr GetModuleHandleA(string lpModuleName); +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/ItemInfoText.cs b/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/ItemInfoText.cs deleted file mode 100644 index 6b4d217..0000000 --- a/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/ItemInfoText.cs +++ /dev/null @@ -1,318 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using RynthCore.Loot.Editing; -using RynthCore.Plugin.RynthAi.CreatureData; - -namespace RynthCore.Plugin.RynthAi.ItemInfo; - -/// One item's appraisal values, as reads them. -internal interface IItemInfoSource -{ - /// The name the client shows ("" when unknown). - string Name { get; } - bool TryInt(uint key, out int value); - bool TryFloat(uint key, out double value); - /// The item's spells (empty when none or not appraised). - IReadOnlyList SpellIds { get; } -} - -/// -/// /ra iteminfo's text: one item on one chat line, in the spirit of Mag-Tools' item info -/// (name, type, set, armor, ratings, damage and mods, imbues, slayer, tinks, spells by name, -/// wield and activation requirements, craft, material, value and burden). A field the -/// appraisal doesn't carry is left out. Pure: no host calls, so the host tests feed it a -/// fake source. -/// -internal static class ItemInfoText -{ - // STypeInt (AC / ACE PropertyInt numbering; the names in Meta/PropertyNames.cs). - internal const uint IntItemType = 1, IntEncumbrance = 5, IntStackSize = 12, IntRareId = 17, IntValue = 19, - IntArmorLevel = 28, IntBonded = 33, IntDamage = 44, IntDamageType = 45, IntWeaponSkill = 48, - IntWeaponTime = 49, IntWorkmanship = 105, IntSpellcraft = 106, IntCurMana = 107, IntMaxMana = 108, - IntItemDifficulty = 109, IntAllegianceRankLimit = 110, IntAttuned = 114, IntSkillLevelLimit = 115, - IntMaterial = 131, IntWieldReq = 158, IntWieldSkill = 159, IntWieldDiff = 160, IntSlayerType = 166, - IntTinks = 171, IntImbued = 179, IntElementalBonus = 204, IntSetId = 265, IntWieldReq2 = 270, - IntWieldSkill2 = 271, IntWieldDiff2 = 272, IntItemMaxLevel = 319; - - // STypeFloat (ACE PropertyFloat numbering). - internal const uint FloatDamageVariance = 22, FloatMeleeDefense = 29, FloatWeaponOffense = 62, FloatDamageMod = 63, - FloatManaConversion = 144, FloatMissileDefense = 149, FloatMagicDefense = 150, FloatElementalDamage = 152, - FloatCriticalMultiplier = 136, FloatCriticalFrequency = 147; - - /// Gear ratings (STypeInt 370-389) and their short tags, in print order. - internal static readonly (uint Key, string Tag)[] Ratings = - { - (370, "D"), (371, "DR"), (372, "C"), (373, "CR"), (374, "CD"), (375, "CDR"), - (376, "HB"), (379, "Vit"), (377, "NR"), (378, "LR"), (388, "OP"), (389, "OPR"), - (383, "PvP D"), (384, "PvP DR"), - }; - - // ItemType flags (STypeInt 1), most specific first. - private static readonly (uint Flag, string Name)[] Types = - { - (0x00040000, "Promissory Note"), (0x00080000, "Mana Stone"), (0x00001000, "Spell Component"), - (0x00000800, "Gem"), (0x00004000, "Key"), (0x40000000, "Salvage"), (0x20000000, "Tinkering Tool"), - (0x00000200, "Container"), (0x00008000, "Caster"), (0x00000100, "Missile Weapon"), - (0x00000001, "Melee Weapon"), (0x00000002, "Armor"), (0x00000004, "Clothing"), (0x00000008, "Jewelry"), - (0x00000020, "Food"), (0x00000040, "Money"), (0x00002000, "Writable"), (0x00000080, "Misc"), - }; - - // ImbuedEffect flags (STypeInt 179). - private static readonly (uint Flag, string Name)[] Imbues = - { - (0x0001, "Critical Strike"), (0x0002, "Crippling Blow"), (0x0004, "Armor Rending"), - (0x0008, "Slash Rending"), (0x0010, "Pierce Rending"), (0x0020, "Bludgeon Rending"), - (0x0040, "Acid Rending"), (0x0080, "Cold Rending"), (0x0100, "Lightning Rending"), - (0x0200, "Fire Rending"), (0x0400, "Melee Defense"), (0x0800, "Missile Defense"), - (0x1000, "Magic Defense"), (0x4000, "Nether Rending"), - }; - - // Equipment sets (STypeInt 265) whose ids are certain: the loot armor sets and Aetheria. - private static readonly Dictionary Sets = new() - { - [13] = "Soldier's", [14] = "Adept's", [15] = "Archer's", [16] = "Defender's", [17] = "Tinker's", - [18] = "Crafter's", [19] = "Hearty", [20] = "Dexterous", [21] = "Wise", [22] = "Swift", - [23] = "Hardened", [24] = "Reinforced", [25] = "Interlocking", [26] = "Flame Proof", - [27] = "Acid Proof", [28] = "Cold Proof", [29] = "Lightning Proof", - [35] = "Aetheria: Defense", [36] = "Aetheria: Destruction", [37] = "Aetheria: Fury", - [38] = "Aetheria: Growth", [39] = "Aetheria: Vigor", - }; - - // Attributes and vitals for attribute/vital wield requirements (ACE PropertyAttribute / PropertyAttribute2nd). - private static readonly string[] Attributes = { "", "Strength", "Endurance", "Quickness", "Coordination", "Focus", "Self" }; - private static readonly string[] Vitals = { "", "Max Health", "Health", "Max Stamina", "Stamina", "Max Mana", "Mana" }; - - private static readonly CultureInfo Inv = CultureInfo.InvariantCulture; - - /// - /// The item on one line. names a spell id (the plugin's - /// spell table). false adds a note that the server never - /// answered the ID, so only what the client already knew is shown. - /// - public static string Describe(IItemInfoSource item, Func spellName, bool identified = true) - { - var parts = new List(24); - int type = Int(item, IntItemType); - - // Name, with the material in front the way the game names loot ("Gold Ring"). - string name = item.Name.Trim(); - int material = Int(item, IntMaterial); - string full = WeaponNames.Full(name, material); - if (full.Length == 0) full = "(unnamed item)"; - string typeName = TypeName(type); - int stack = Int(item, IntStackSize); - var head = new StringBuilder(full); - if (stack > 1) head.Append(" x").Append(stack.ToString("N0", Inv)); - if (typeName.Length > 0) head.Append(" (").Append(typeName).Append(')'); - parts.Add(head.ToString()); - - if (Int(item, IntSetId) is int set and > 0) - parts.Add((Sets.TryGetValue(set, out string? setName) ? setName : "Set " + set) + " Set"); - - if (item.TryInt(IntArmorLevel, out int al) && (al > 0 || (type & 0x2) != 0)) - parts.Add("AL " + al.ToString(Inv)); - - string ratings = RatingText(item); - if (ratings.Length > 0) parts.Add(ratings); - - AddWeapon(item, type, parts); - - string imbues = ImbueText(Int(item, IntImbued)); - if (imbues.Length > 0) parts.Add(imbues); - - if (Int(item, IntSlayerType) is int slayer and > 0) - parts.Add(CreatureTypeNames.Name(slayer) + " Slayer"); - - if (item.TryInt(IntTinks, out int tinks) && tinks > 0) - parts.Add("Tinks " + tinks.ToString(Inv)); - - string spells = SpellText(item.SpellIds, spellName); - if (spells.Length > 0) parts.Add(spells); - - string wield = WieldText(item, IntWieldReq, IntWieldSkill, IntWieldDiff); - if (wield.Length > 0) parts.Add(wield); - string wield2 = WieldText(item, IntWieldReq2, IntWieldSkill2, IntWieldDiff2); - if (wield2.Length > 0) parts.Add(wield2); - - if (Int(item, IntSkillLevelLimit) is int skillLimit and > 0) parts.Add("Skill " + skillLimit.ToString(Inv) + " to activate"); - if (Int(item, IntAllegianceRankLimit) is int rank and > 0) parts.Add("Rank " + rank.ToString(Inv)); - if (Int(item, IntItemDifficulty) is int diff and > 0) parts.Add("Diff " + diff.ToString(Inv)); - if (Int(item, IntSpellcraft) is int spellcraft and > 0) parts.Add("Spellcraft " + spellcraft.ToString(Inv)); - if (item.TryInt(IntMaxMana, out int maxMana) && maxMana > 0) - parts.Add("Mana " + (item.TryInt(IntCurMana, out int cur) ? cur.ToString(Inv) + "/" : "") + maxMana.ToString(Inv)); - if (Int(item, IntItemMaxLevel) is int maxLevel and > 0) parts.Add("Max Level " + maxLevel.ToString(Inv)); - - if (item.TryInt(IntWorkmanship, out int craft) && craft > 0) parts.Add("Craft " + craft.ToString(Inv)); - string matName = WeaponNames.Material(material); - if (matName.Length > 0) parts.Add("Mat " + matName); - - if (Int(item, IntBonded) == 1) parts.Add("Bonded"); - if (Int(item, IntAttuned) == 1) parts.Add("Attuned"); - if (Int(item, IntRareId) is int rare and > 0) parts.Add("Rare #" + rare.ToString(Inv)); - - if (item.TryInt(IntValue, out int value)) parts.Add("Value " + value.ToString("N0", Inv)); - if (item.TryInt(IntEncumbrance, out int burden)) parts.Add("BU " + burden.ToString("N0", Inv)); - - if (!identified) parts.Add("(not identified: no reply from the server)"); - return string.Join(", ", parts); - } - - private static int Int(IItemInfoSource item, uint key) => item.TryInt(key, out int v) ? v : 0; - - /// The item's kind from its ItemType flags ("" when none is set). - internal static string TypeName(int itemType) - { - uint t = unchecked((uint)itemType); - foreach (var (flag, n) in Types) - if ((t & flag) != 0) return n; - return ""; - } - - /// "[D3 CD2 CDR1]" for the gear ratings that are set; "" for none. - internal static string RatingText(IItemInfoSource item) - { - var sb = new StringBuilder(); - foreach (var (key, tag) in Ratings) - { - if (!item.TryInt(key, out int r) || r <= 0) continue; - sb.Append(sb.Length == 0 ? "[" : " ").Append(tag).Append(r.ToString(Inv)); - } - return sb.Length == 0 ? "" : sb.Append(']').ToString(); - } - - private static void AddWeapon(IItemInfoSource item, int type, List parts) - { - uint t = unchecked((uint)type); - bool melee = (t & 0x1) != 0, missile = (t & 0x100) != 0, caster = (t & 0x8000) != 0; - bool weapon = melee || missile || caster; - - if (Int(item, IntWeaponSkill) is int skill and > 0 && weapon) - parts.Add(SkillName(skill)); - - int dmgType = Int(item, IntDamageType); - if (item.TryInt(IntDamage, out int max) && max > 0) - { - string dmg = "Dmg " + max.ToString(Inv); - if (item.TryFloat(FloatDamageVariance, out double variance) && variance > 0 && variance < 1) - { - int min = (int)Math.Round(max * (1.0 - variance), MidpointRounding.AwayFromZero); - dmg = $"Dmg {min.ToString(Inv)}-{max.ToString(Inv)}"; - } - string element = DamageTypeName(dmgType); - if (element.Length > 0) dmg += " " + element; - parts.Add(dmg); - } - else if (weapon && dmgType > 0) - { - string element = DamageTypeName(dmgType); - if (element.Length > 0) parts.Add(element); - } - if (Int(item, IntElementalBonus) is int elemBonus and > 0) parts.Add("+" + elemBonus.ToString(Inv) + " elemental dmg"); - if (weapon && item.TryInt(IntWeaponTime, out int speed) && speed > 0) parts.Add("Speed " + speed.ToString(Inv)); - - // Crushing Blow and Biting Strike, the way the client's appraisal names them (shown as - // SilentKelpie's fork shows them, rynth/RynthSuite PR #3). ACE deals a crit as damage x - // (1 + CriticalMultiplier) (DamageEvent), so 2.66 reads "Crushing Blow 3.66x"; 1.0 is an - // ordinary crit. CriticalFrequency is the weapon's own crit chance (default 10%, 5% casters). - if (weapon && item.TryFloat(FloatCriticalMultiplier, out double critMult) && critMult > 1.0) - parts.Add("Crushing Blow " + (1.0 + critMult).ToString("0.##", Inv) + "x"); - if (weapon && item.TryFloat(FloatCriticalFrequency, out double critFreq) && critFreq > 0 && critFreq < 1) - parts.Add("Biting Strike " + (critFreq * 100.0).ToString("0.#", Inv) + "%"); - - // Modifiers: 1.18 = +18%. Missile launchers' damage mod and casters' elemental mod too. - var mods = new List(6); - AddPercent(item, FloatWeaponOffense, "atk", mods, weapon); - if (missile) AddPercent(item, FloatDamageMod, "dmg", mods, true); - if (caster) AddPercent(item, FloatElementalDamage, "vs monsters", mods, true); - AddPercent(item, FloatMeleeDefense, "md", mods, weapon); - AddPercent(item, FloatMissileDefense, "mid", mods, weapon); - AddPercent(item, FloatMagicDefense, "mgd", mods, weapon); - AddPercent(item, FloatManaConversion, "mana c", mods, true); - if (mods.Count > 0) parts.Add("(" + string.Join(", ", mods) + ")"); - } - - private static void AddPercent(IItemInfoSource item, uint key, string label, List mods, bool allowed) - { - if (!allowed || !item.TryFloat(key, out double v) || double.IsNaN(v)) return; - // Multipliers (attack, defense, damage) are stored as 1.xx; mana conversion as 0.xx. - double pct = key == FloatManaConversion ? v * 100.0 : (v - 1.0) * 100.0; - int rounded = (int)Math.Round(pct, MidpointRounding.AwayFromZero); - if (rounded == 0) return; - mods.Add((rounded > 0 ? "+" : "") + rounded.ToString(Inv) + "% " + label); - } - - /// "Crippling Blow, Fire Rending" for the imbue flags; "" for none. - internal static string ImbueText(int flags) - { - if (flags == 0) return ""; - uint f = unchecked((uint)flags); - var names = new List(2); - foreach (var (flag, n) in Imbues) - if ((f & flag) != 0) names.Add(n); - return string.Join(", ", names); - } - - /// "Spells: A, B, C" by name, in the item's order, each once; "" for none. - internal static string SpellText(IReadOnlyList spellIds, Func spellName) - { - if (spellIds.Count == 0) return ""; - var seen = new HashSet(); - var names = new List(spellIds.Count); - foreach (int id in spellIds) - { - if (id <= 0 || !seen.Add(id)) continue; - string n = spellName(id); - names.Add(string.IsNullOrWhiteSpace(n) ? "spell " + id.ToString(Inv) : n); - } - return names.Count == 0 ? "" : "Spells: " + string.Join(", ", names); - } - - /// One wield requirement ("Wield Lvl 180", "Heavy Weapons 375 to wield"); "" for none. - internal static string WieldText(IItemInfoSource item, uint reqKey, uint skillKey, uint diffKey) - { - int req = Int(item, reqKey); - if (req <= 0) return ""; - int skill = Int(item, skillKey); - int diff = Int(item, diffKey); - string d = diff.ToString(Inv); - return req switch - { - 1 => $"{SkillName(skill)} {d} to wield", - 2 => $"Base {SkillName(skill)} {d} to wield", - 3 => $"{Pick(Attributes, skill, "Attribute")} {d} to wield", - 4 => $"Base {Pick(Attributes, skill, "Attribute")} {d} to wield", - 5 => $"{Pick(Vitals, skill, "Vital")} {d} to wield", - 6 => $"Base {Pick(Vitals, skill, "Vital")} {d} to wield", - 7 => $"Wield Lvl {d}", - 8 => $"{(diff >= 3 ? "Specialized" : "Trained")} {SkillName(skill)} to wield", - 12 => $"Heritage {d} to wield", - _ => $"Wield requirement {req.ToString(Inv)} ({skill.ToString(Inv)}, {d})", - }; - } - - private static string Pick(string[] names, int i, string fallback) => - i > 0 && i < names.Length ? names[i] : $"{fallback} {i.ToString(Inv)}"; - - /// AC's skill name for a skill id ("skill N" when unknown). - internal static string SkillName(int id) - { - foreach (var (sid, n) in LootRuleText.Skills) - if (sid == id) return n; - return "skill " + id.ToString(Inv); - } - - /// The damage type's name ("Slashing/Piercing" etc.); "" for none. - internal static string DamageTypeName(int flags) - { - if (flags <= 0) return ""; - foreach (var (id, n) in LootRuleText.DamageTypes) - if (id == flags) return n; - // Other combinations: the single flags joined. - var names = new List(3); - foreach (var (id, n) in LootRuleText.DamageTypes) - if (id > 0 && (id & (id - 1)) == 0 && (flags & id) != 0) names.Add(n); - return string.Join("/", names); - } -} diff --git a/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemDescriber.cs b/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemDescriber.cs new file mode 100644 index 0000000..e3c4a94 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemDescriber.cs @@ -0,0 +1,795 @@ +// MagItemDescriber.cs — one-line "Mag-style" item info (Mag-Tools ItemInfo / UtilityBelt ub-IT ItemInfo). +// +// Gold Ornate Long Sword (Slash Sword), Noble Relic Set, CS, Undead Slayer, Tinks 4, +// Applied: Steel x2, 152-236, 0.35v, +18%a, +12%md, Legendary Blood Thirst, Wield Lvl 180, +// Heavy Weapons 375, Diff 270, Craft 8, [D 3, CD 2] +// +// The same fields can also print as the pet-roster layout (IltPetStats: identity line, stats +// line, ratings/requirements line), plus a spells line: +// +// Gold Ornate Long Sword (Slash Sword), Noble Relic Set, Tinks 4, Applied: Steel x2, Craft 8 +// CS, Undead Slayer, 152-236, 0.35v, +18%a, +12%md +// [D 3, CD 2] Wield Lvl 180, Heavy Weapons 375, Diff 270 +// Spells: Legendary Blood Thirst +// +// Values follow what the ACECustom appraisal panel shows: the low damage end is rounded like the +// client, Crushing Blow is the dealt multiplier (1 + CriticalMultiplier), and imbue strengths, +// the T11 weapon / gear grades, property slots, procs, zone modifiers and item-aug wield gates +// come from the description text because the server keeps those properties off the wire; the +// T11 tier and weapon quality roll are real properties (ZcTier, WeaponAugScale*): +// +// Flaming Quarter Staff (Fire Staff), T16, Quality 1000, Props 2/5, Grade S (100%), Craft 9 +// FireRend +176%, Crushing Blow 3.66x, 1790-2069, 0.135v, +20%a, +20%md +// [CD 24] Wield 2,000 Item Augs +// +// Field order and per-class gating follow ub-IT (Tools/ItemInfo.cs ItemDescriptions.ToString, +// Lib/ItemDescribeMagShorthand.cs, Lib/ItemInfoHelper/ItemIdentifyFieldSet.cs); labels and the +// spell filter follow Mag-Tools. All ids are raw ACE properties (RynthCore reads CBaseQualities by +// STypeInt/STypeFloat/STypeString id — not Decal's remapped LongValueKey/DoubleValueKey numbers). +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; +using RynthCore.Loot; +using RynthCore.Loot.T11; + +namespace RynthCore.Plugin.RynthAi.ItemInfo; + +/// Property reads for one item. Implemented over the live object cache (see +/// ); a missing property returns false / empty. +internal interface IItemPropertySource +{ + string Name { get; } + AcObjectClass ObjectClass { get; } + bool TryGetInt(uint stype, out int value); + bool TryGetDouble(uint stype, out double value); + string GetString(uint stype); + /// Spell ids on the item (inscribed + cantrips), unsorted. + IReadOnlyList SpellIds { get; } +} + +/// Per-call output options, snapshotted from . +internal readonly record struct MagItemInfoOptions( + MagItemInfoField Hidden, int HiddenRatings, bool ShowValueAndBurden, bool AllSpells, int MaxListedSpells) +{ + /// Everything shown, Mag spell filter — used when no settings are loaded yet. + public static readonly MagItemInfoOptions Default = new(MagItemInfoField.None, 0, false, false, 26); + + public static MagItemInfoOptions From(MagItemInfoSettings? s) => s == null + ? Default + : new((MagItemInfoField)s.HiddenFields, s.HiddenRatings, s.ShowValueAndBurden, + s.SpellMode == MagItemInfoSettings.SpellModeAll, s.MaxListedSpells); + + public bool Shows(MagItemInfoField f) => (Hidden & f) == 0; +} + +/// Which pet-style line a field lands on (). +internal enum MagItemSection +{ + /// Line 1 after the name: set, AL, tinks, applied, craft, keyring. + Identity, + /// Line 2: imbues, slayer, damage, attack/defense/mana-conversion, protections. + Combat, + /// Line 3 lead: the "[D 3, CD 2]" cluster. + Ratings, + /// Line 3 tail: wield / activation / difficulty, value and burden. + Requirements, + /// Line 4: spell names. + Spells, +} + +/// +/// One described item: the title plus fields tagged with their section, kept in Mag print order +/// so reproduces the classic line exactly. +/// +internal sealed class MagItemDescription +{ + /// "[Material ]Name[ (DamageType Mastery)]". + public string Title = string.Empty; + public readonly List<(MagItemSection Section, string Text)> Segments = new(); + + public void Add(MagItemSection section, string text) + { + if (!string.IsNullOrEmpty(text)) Segments.Add((section, text)); + } + + /// Classic Mag one-liner: title, then every field comma-separated. + public string ToOneLine() + { + var sb = new StringBuilder(Title, 256); + foreach (var (_, text) in Segments) sb.Append(", ").Append(text); + return sb.ToString(); + } + + /// + /// Pet-roster layout: line 1 is always present; empty stat / requirement / spell lines are + /// dropped so plain armor stays short. + /// + public List ToPetLines() + { + var lines = new List(4); + + var identity = new StringBuilder(Title); + foreach (string t in Section(MagItemSection.Identity)) identity.Append(", ").Append(t); + lines.Add(identity.ToString()); + + string combat = string.Join(", ", Section(MagItemSection.Combat)); + if (combat.Length > 0) lines.Add(combat); + + // Like the pet roster's third line: ratings first, then the rest two-space separated. + var tail = new List(2); + string ratings = string.Join(", ", Section(MagItemSection.Ratings)); + if (ratings.Length > 0) tail.Add(ratings); + string reqs = string.Join(", ", Section(MagItemSection.Requirements)); + if (reqs.Length > 0) tail.Add(reqs); + if (tail.Count > 0) lines.Add(string.Join(" ", tail)); + + var spells = Section(MagItemSection.Spells); + if (spells.Count > 0) + { + // The verbose list is a single pre-labelled "Spells: a; b" segment. + lines.Add(spells.Count == 1 && spells[0].StartsWith("Spells:", StringComparison.Ordinal) + ? spells[0] + : "Spells: " + string.Join(", ", spells)); + } + return lines; + } + + private List Section(MagItemSection section) + { + var list = new List(); + foreach (var (s, text) in Segments) + if (s == section) list.Add(text); + return list; + } +} + +/// Builds the Mag-style item info line. +internal static class MagItemDescriber +{ + // ── ACE PropertyInt ids ────────────────────────────────────────────────── + private const uint IntBurden = 5; // EncumbranceVal + private const uint IntValue = 19; + private const uint IntArmorLevel = 28; + private const uint IntResistMagic = 36; // >= 9999 = unenchantable + private const uint IntMaxDamage = 44; // Damage + private const uint IntDamageType = 45; + private const uint IntAttackType = 47; + private const uint IntStructure = 92; // keyring uses remaining + private const uint IntWorkmanship = 105; + private const uint IntItemDifficulty = 109; // arcane lore requirement ("Diff") + private const uint IntActivationLevel = 115; // ItemSkillLevelLimit + private const uint IntMaterial = 131; + private const uint IntWieldReq = 158; + private const uint IntWieldSkill = 159; + private const uint IntWieldValue = 160; + private const uint IntSlayerCreature = 166; + private const uint IntNumItemsInMaterial = 170; // salvage: workmanship = 105 / 170 + private const uint IntTinks = 171; + private const uint IntActivationSkill = 176; // AppraisalItemSkill + private const uint IntImbued = 179; // ImbuedEffect (+ 303..306 for 2..5) + private const uint IntNumKeys = 193; + private const uint IntElementalBonus = 204; + private const uint IntEquipmentSet = 265; + private const uint IntWieldReq2 = 270; + private const uint IntWieldSkill2 = 271; + private const uint IntWieldValue2 = 272; + private const uint IntWeaponType = 353; // mastery + private const uint IntUseRequiresSkill = 366; + private const uint IntUseRequiresSkillLvl = 367; + private const uint IntUseRequiresSpec = 368; + private const uint IntUseRequiresLevel = 369; + private const uint IntSplitArrows = 9031; // ACECustom SplitArrowCount + + // ── ACE PropertyFloat ids ──────────────────────────────────────────────── + private const uint FloatArmorVsSlash = 13; // 13..19 = Slash/Pierce/Bludgeon/Cold/Fire/Acid/Electric + private const uint FloatVariance = 22; + private const uint FloatMaxVelocity = 26; + private const uint FloatMeleeDefense = 29; // WeaponDefense + private const uint FloatAttack = 62; // WeaponOffense + private const uint FloatDamageMod = 63; + private const uint FloatCritMultiplier = 136; + private const uint FloatManaConversion = 144; + private const uint FloatCritFrequency = 147; + private const uint FloatMissileDefense = 149; + private const uint FloatMagicDefense = 150; + private const uint FloatVsMonsters = 152; // ElementalDamageMod + private const uint FloatIgnoreArmor = 155; // armor cleaving + + // ── ACE PropertyString ids ─────────────────────────────────────────────── + private const uint StringUse = 14; // ACECustom: T11 armor/jewelry "Modifiers:" block + private const uint StringLongDesc = 16; // ACECustom: "Property Details:" lines (imbue strengths, grade, gates) + private const uint StringTinkerLog = 9007; // ACECustom: CSV of applied material ids + + /// ACECustom's WieldRequirement.Int64Stat: the client gets it as text, never as properties. + private const int WieldReqInt64Stat = 13; + + /// Gear ratings are small (1..~50). Anything above is a wrong key leaking through. + private const int MaxPlausibleRating = 200; + + /// Class-specific fields (ub-IT ItemIdentifyFieldSet). Generic fields print for every class. + [Flags] + private enum Field + { + None = 0, + DamageType = 1 << 0, + CritStats = 1 << 1, + Splits = 1 << 2, + Cleaves = 1 << 3, + Slayer = 1 << 4, + Range = 1 << 5, + Damage = 1 << 6, + AttackBonus = 1 << 7, + MeleeDefense = 1 << 8, + MissileDefense = 1 << 9, + MagicDefense = 1 << 10, + ManaConversion = 1 << 11, + ArmorCleave = 1 << 12, + WeaponDefenses = MeleeDefense | MissileDefense | MagicDefense, + } + + private static Field FieldsFor(AcObjectClass cls) => cls switch + { + AcObjectClass.MissileWeapon => Field.DamageType | Field.CritStats | Field.Splits | Field.Cleaves + | Field.Slayer | Field.Range | Field.Damage | Field.WeaponDefenses + | Field.ArmorCleave, + AcObjectClass.MeleeWeapon => Field.DamageType | Field.CritStats | Field.Cleaves | Field.Slayer + | Field.Damage | Field.AttackBonus | Field.WeaponDefenses + | Field.ArmorCleave, + AcObjectClass.WandStaffOrb => Field.DamageType | Field.CritStats | Field.Slayer | Field.Damage + | Field.WeaponDefenses | Field.ManaConversion, + AcObjectClass.Jewelry => Field.None, + // Armor / clothing / misc: keep Mag's generic bonus lines (shields roll %md etc.). + _ => Field.AttackBonus | Field.WeaponDefenses | Field.ManaConversion, + }; + + /// Full Mag-style line for one item (name first, comma-separated fields). + public static string Describe(IItemPropertySource item, MagItemInfoOptions options) + => Build(item, options).ToOneLine(); + + /// Reads every enabled field once, tagged by section (one-line or pet-style output). + public static MagItemDescription Build(IItemPropertySource item, MagItemInfoOptions options) + { + var d = new MagItemDescription(); + var sb = new StringBuilder(128); // title only + AcObjectClass cls = item.ObjectClass; + Field fields = FieldsFor(cls); + bool Has(Field f) => (fields & f) == f; + bool Show(MagItemInfoField f) => options.Shows(f); + + int Int(uint id) => item.TryGetInt(id, out int v) ? v : 0; + double Dbl(uint id, double fallback) => item.TryGetDouble(id, out double v) ? v : fallback; + + // ── Name: "[Material ]Name (DamageType Mastery)" ──────────────────────── + int material = Int(IntMaterial); + if (material > 0 && Show(MagItemInfoField.Material)) + { + string matName = MagItemInfoTables.Materials.TryGetValue(material, out string? m) ? m : $"material {material}"; + // Loot names usually omit the material; don't double it when the name already starts with it. + if (!item.Name.StartsWith(matName, StringComparison.OrdinalIgnoreCase)) + sb.Append(matName).Append(' '); + } + sb.Append(item.Name); + + if (Has(Field.DamageType) && Show(MagItemInfoField.TypeMastery)) + { + string dmgType = MagItemInfoTables.DamageTypeName(Int(IntDamageType)); + int mastery = Int(IntWeaponType); + string masteryName = mastery > 0 + ? (MagItemInfoTables.Masteries.TryGetValue(mastery, out string? mn) ? mn : $"Unknown mastery {mastery}") + : string.Empty; + string inner = $"{dmgType} {masteryName}".Trim(); + if (inner.Length > 0) sb.Append(" (").Append(inner).Append(')'); + } + d.Title = sb.ToString(); + + const MagItemSection Id = MagItemSection.Identity, Cbt = MagItemSection.Combat, Req = MagItemSection.Requirements; + string I(int v) => v.ToString(CultureInfo.InvariantCulture); + + // Text-only appraisal data (empty until the item has been IDed). + string longDesc = item.GetString(StringLongDesc); + var t11Server = new T11ServerProps( + Int(T11Catalog.PropZcTier), + Int(T11Catalog.PropWeaponAugScaleTier), + item.TryGetInt(T11Catalog.PropWeaponAugScaleQuality, out int quality) ? quality : -1); + T11ItemInfo t11 = T11ItemInfo.Parse(item.Name, longDesc, item.GetString(StringUse), t11Server); + + // ── Set ───────────────────────────────────────────────────────────────── + int set = Int(IntEquipmentSet); + if (set > 0 && Show(MagItemInfoField.Set)) + d.Add(Id, MagItemInfoTables.EquipmentSets.TryGetValue(set, out string? setName) ? setName : $"Unknown set {set}"); + + // ── T11 state: "T16, Gear B+ (4 lines), Props 3/5, Tainted" ─────────── + if (t11.IsT11 && Show(MagItemInfoField.T11)) + { + // "~" marks a tier estimated from the wield gates (older server, or not yet IDed). + d.Add(Id, t11.TierIsExact ? "T" + I(t11.Tier) : "~T" + I(t11.Tier)); + if (t11.WeaponQuality >= 0) d.Add(Id, "Quality " + I(t11.WeaponQuality)); + if (t11.GearGradeRank > 0) + d.Add(Id, t11.GearGradeLines > 0 ? $"Gear {t11.GearGrade} ({I(t11.GearGradeLines)} lines)" : $"Gear {t11.GearGrade}"); + if (t11.PropertySlots >= 0) + d.Add(Id, t11.PropertySlotCap > 0 ? $"Props {I(t11.PropertySlots)}/{I(t11.PropertySlotCap)}" : $"Props {I(t11.PropertySlots)}"); + if (t11.Tainted) d.Add(Id, "Tainted"); + } + + // ── Armor level ───────────────────────────────────────────────────────── + int al = Int(IntArmorLevel); + if (al > 0 && Show(MagItemInfoField.ArmorLevel)) d.Add(Id, "AL " + I(al)); + + // ── Imbues (ImbuedEffect 179 plus ImbuedEffect2..5 = 303..306) ───────── + if (Show(MagItemInfoField.Imbues)) + d.Add(Cbt, ImbueLabels(Int(IntImbued) | Int(303) | Int(304) | Int(305) | Int(306), ImbueStrengths(longDesc))); + + if (Has(Field.ArmorCleave) && Show(MagItemInfoField.ArmorCleave) && Dbl(FloatIgnoreArmor, 0) != 0) + d.Add(Cbt, "AC"); + + if (Has(Field.CritStats) && Show(MagItemInfoField.CritStats)) + { + // A crit deals 1 + CriticalMultiplier; a stored 1.0 is a normal 2x crit, so ACE only + // calls it Crushing Blow above 1.0. + double critMult = Dbl(FloatCritMultiplier, 0); + if (critMult > 1) d.Add(Cbt, $"Crushing Blow {Fmt(critMult + 1)}x"); + // Biting Strike replaces the base crit chance with this fraction. + double critFreq = Dbl(FloatCritFrequency, 0); + if (critFreq > 0) d.Add(Cbt, $"Biting Strike {Math.Round(critFreq * 100).ToString(CultureInfo.InvariantCulture)}%"); + } + + // T11 Cast on Strike procs: "Proc Force Arc 13%". + if (Show(MagItemInfoField.Imbues)) + foreach (var (procName, chance) in t11.Procs) + d.Add(Cbt, $"Proc {procName} {Fmt(chance)}%"); + + if (Has(Field.Splits) && Show(MagItemInfoField.Splits)) + { + int splits = Int(IntSplitArrows); + if (splits > 0) d.Add(Cbt, $"Splits ({I(splits)})"); + } + + if (Has(Field.Range) && Show(MagItemInfoField.Range)) + { + int yards = MissileRangeYards(Dbl(FloatMaxVelocity, 0)); + if (yards > 0) d.Add(Cbt, $"Range {I(yards)}yd"); + } + + if (Has(Field.Cleaves) && Show(MagItemInfoField.CleaveMultiStrike)) + { + int attackType = Int(IntAttackType); + int mastery = Int(IntWeaponType); + bool cleaving = (attackType == 4 && mastery == 11) || (attackType == 1 && mastery != 11 && mastery != 0); + if (cleaving) d.Add(Cbt, "Cleaving"); + else if (attackType is 160 or 166) d.Add(Cbt, "Multi-Strike"); + else if (attackType == 486) d.Add(Cbt, "Multi-Strike (3)"); + } + + // ── Slayer ────────────────────────────────────────────────────────────── + if (Has(Field.Slayer) && Show(MagItemInfoField.Slayer)) + { + string? slayer = MagItemInfoTables.CreatureTypeName(Int(IntSlayerCreature)); + if (slayer != null) d.Add(Cbt, slayer + " Slayer"); + } + + // ── Tinks + applied materials (TinkerLog) ────────────────────────────── + int tinks = Int(IntTinks); + if (tinks > 0 && Show(MagItemInfoField.Tinks)) d.Add(Id, "Tinks " + I(tinks)); + if (Show(MagItemInfoField.Applied)) + { + string applied = FormatTinkerLog(item.GetString(StringTinkerLog)); + if (applied.Length > 0) d.Add(Id, "Applied: " + applied); + } + + // ── Damage ────────────────────────────────────────────────────────────── + // T11 weapon grade sits with the identity fields: "Grade S (100%)". + if (Has(Field.Damage) && Show(MagItemInfoField.Damage) && t11.GradeRank > 0) + d.Add(Id, t11.DamagePercent >= 0 ? $"Grade {t11.Grade} ({I(t11.DamagePercent)}%)" : $"Grade {t11.Grade}"); + + if (Has(Field.Damage) && Show(MagItemInfoField.Damage)) + AddDamage(d, cls, Int(IntMaxDamage), Dbl(FloatVariance, 0), Int(IntElementalBonus), + Dbl(FloatDamageMod, 1), Dbl(FloatVsMonsters, 1)); + + // ── Attack / defense / mana conversion percents ─────────────────────── + bool defenses = Show(MagItemInfoField.Defenses); + if (Has(Field.AttackBonus) && Show(MagItemInfoField.Attack)) AddPercent(d, Dbl(FloatAttack, 1), "%a", 0); + if (Has(Field.MeleeDefense) && defenses) AddPercent(d, Dbl(FloatMeleeDefense, 1), "%md", 0); + if (Has(Field.MagicDefense) && defenses) AddPercent(d, Dbl(FloatMagicDefense, 1), "%mgc.d", 1); + if (Has(Field.MissileDefense) && defenses) AddPercent(d, Dbl(FloatMissileDefense, 1), "%msl.d", 1); + if (Has(Field.ManaConversion) && Show(MagItemInfoField.ManaConversion)) + { + double mc = Dbl(FloatManaConversion, 0); + if (mc != 0) d.Add(Cbt, Math.Round(mc * 100).ToString(CultureInfo.InvariantCulture) + "%mc"); + } + + // ── Spells ────────────────────────────────────────────────────────────── + bool unenchantable = Int(IntResistMagic) >= 9999; + if (Show(MagItemInfoField.Spells)) + AddSpells(d, item.SpellIds, unenchantable, options.AllSpells, options.MaxListedSpells); + + // ── Requirements ──────────────────────────────────────────────────────── + if (Show(MagItemInfoField.Wield)) + { + AddWieldRequirement(d, Int(IntWieldReq), Int(IntWieldSkill), Int(IntWieldValue)); + AddWieldRequirement(d, Int(IntWieldReq2), Int(IntWieldSkill2), Int(IntWieldValue2)); + // T11 gates (item augs, Triune Weave, charms) only exist as "Wield requires:" text. + foreach (T11WieldGate gate in t11.WieldGates) + d.Add(Req, $"Wield {gate.Amount.ToString("N0", CultureInfo.InvariantCulture)} {GateName(gate.Counter)}"); + } + + if (Show(MagItemInfoField.Activation)) + { + int useLevel = Int(IntUseRequiresLevel); + if (useLevel > 0) d.Add(Req, "Lvl " + I(useLevel)); + + // "Melee Defense 300 to Activate" — hidden when the wield requirement already covers it. + int actSkill = Int(IntActivationSkill), actLevel = Int(IntActivationLevel); + if (actLevel > 0 && (Int(IntWieldSkill) != actSkill || Int(IntWieldValue) < actLevel)) + d.Add(Req, $"{SkillName(actSkill)} {I(actLevel)} to Activate"); + + // Summoning essences / gems. + int useSkill = Int(IntUseRequiresSkill), useSkillLvl = Int(IntUseRequiresSkillLvl), useSpec = Int(IntUseRequiresSpec); + if (useSkill > 0 && useSkillLvl > 0) d.Add(Req, $"{SkillName(useSkill)} {I(useSkillLvl)}"); + if (useSpec > 0 && useSkillLvl > 0) d.Add(Req, $"Spec {SkillName(useSpec)} {I(useSkillLvl)}"); + } + + int diff = Int(IntItemDifficulty); + if (diff > 0 && Show(MagItemInfoField.Difficulty)) d.Add(Req, "Diff " + I(diff)); + + // ── Workmanship ───────────────────────────────────────────────────────── + int work = Show(MagItemInfoField.Craft) ? Int(IntWorkmanship) : 0; + if (cls == AcObjectClass.Salvage) + { + int items = Int(IntNumItemsInMaterial); + if (work > 0) + { + double avg = items > 0 ? (double)work / items : work; + d.Add(Id, "Work " + avg.ToString("N2", CultureInfo.InvariantCulture)); + } + } + else if (work > 0 && tinks != 10) // Mag: hide craft once fully tinked + { + d.Add(Id, "Craft " + I(work)); + } + + // ── Unenchantable armor: base protections [S/P/B/C/F/A/L] ───────────── + if (cls == AcObjectClass.Armor && unenchantable && Show(MagItemInfoField.Protections)) + { + var prot = new StringBuilder("["); + for (uint i = 0; i < 7; i++) + { + if (i > 0) prot.Append('/'); + prot.Append(Dbl(FloatArmorVsSlash + i, 0).ToString("N1", CultureInfo.InvariantCulture)); + } + d.Add(Cbt, prot.Append(']').ToString()); + } + + if (options.ShowValueAndBurden) + { + int value = Int(IntValue); + if (value > 0) d.Add(Req, "Value " + value.ToString("N0", CultureInfo.InvariantCulture)); + int burden = Int(IntBurden); + if (burden > 0) d.Add(Req, "BU " + I(burden)); + } + + // ── Ratings ───────────────────────────────────────────────────────────── + if (Show(MagItemInfoField.Ratings)) + { + d.Add(MagItemSection.Ratings, RatingsCluster(item, options.HiddenRatings)); + // T11 zone modifiers: the server drops a modifier's Gear* rating from the ratings it + // sends, so the modifier lines are the only place those values appear. + if (t11.Modifiers.Count > 0) + { + var mods = new List(t11.Modifiers.Count); + foreach (T11Modifier m in t11.Modifiers) + { + string mod = m.Value != 0 ? $"{m.Name} {(m.Value > 0 ? "+" : "")}{I(m.Value)}" : m.Name; + if (m.Tinkered != 0) mod += $" ({(m.Tinkered > 0 ? "+" : "")}{I(m.Tinkered)} tink)"; + if (m.Locked) mod += " (Locked)"; + mods.Add(mod); + } + d.Add(MagItemSection.Ratings, "Mods: " + string.Join(", ", mods)); + } + } + + if (cls == AcObjectClass.Misc && Show(MagItemInfoField.Keyring) + && item.Name.Contains("Keyring", StringComparison.OrdinalIgnoreCase)) + { + d.Add(Id, "Keys: " + I(Int(IntNumKeys))); + d.Add(Id, "Uses: " + I(Int(IntStructure))); + } + + return d; + } + + /// Mag imbue labels ("CS AR"), plus the ACE flags Mag predates (missile imbue, nether + /// rend); empty when no known bit is set. + private static string ImbueLabels(int mask, IReadOnlyDictionary strengths) + { + if (mask == 0) return string.Empty; + var sb = new StringBuilder(); + // Bare labels stay Mag-style "CS AR"; once a strength is shown, commas keep values readable. + string sep = strengths.Count > 0 ? ", " : " "; + void Flag(int bit, string label) + { + if ((mask & bit) == 0) return; + if (sb.Length > 0) sb.Append(sep); + sb.Append(label); + if (strengths.TryGetValue(bit, out string? value)) sb.Append(' ').Append(value); + } + Flag(0x0001, "CS"); + Flag(0x0002, "CB"); + Flag(0x0004, "AR"); + Flag(0x0008, "SlashRend"); + Flag(0x0010, "PierceRend"); + Flag(0x0020, "BludgeRend"); + Flag(0x0040, "AcidRend"); + Flag(0x0080, "FrostRend"); + Flag(0x0100, "LightRend"); + Flag(0x0200, "FireRend"); + Flag(0x4000, "NetherRend"); + Flag(0x0400, "MeleeImbue"); + Flag(0x0800, "MissileImbue"); + Flag(0x1000, "MagicImbue"); + Flag(0x2000, "Hematited"); + Flag(0x20000000, "MagicAbsorb"); + return sb.ToString(); // only unknown bits → empty → field skipped + } + + // ACECustom "Property Details:" imbue lines, e.g. "- Fire Rending: +176% Dmg", + // "- Armor Rending: 12.5% Ignored", "- Crippling Blow: 2.5x Crit Dmg". The value may carry a + // culture space before '%' and group separators. + private static readonly Regex ImbueDetailLine = new( + @"^\s*-\s*(?[A-Za-z' ]+?)\s*:\s*(?[+-]?[\d.,]+\s?[%x])", + RegexOptions.Multiline | RegexOptions.CultureInvariant); + + /// + /// Imbue bit → strength text ("+176%", "12.5%", "2.5x") from the description. Rendings are + /// matched by damage keyword because the server builds their names from DamageType.DisplayName. + /// + private static IReadOnlyDictionary ImbueStrengths(string longDesc) + { + var result = new Dictionary(); + if (string.IsNullOrEmpty(longDesc)) return result; + foreach (Match m in ImbueDetailLine.Matches(longDesc)) + { + int bit = ImbueBitForDetail(m.Groups["name"].Value); + if (bit != 0 && !result.ContainsKey(bit)) + result[bit] = m.Groups["value"].Value.Replace(" ", ""); + } + return result; + } + + private static int ImbueBitForDetail(string name) + { + bool Has(string s) => name.Contains(s, StringComparison.OrdinalIgnoreCase); + if (Has("Critical Strike")) return 0x0001; + if (Has("Crippling Blow")) return 0x0002; + if (Has("Armor Rending")) return 0x0004; + if (!Has("Rending")) return 0; + if (Has("Slash")) return 0x0008; + if (Has("Pierc")) return 0x0010; + if (Has("Bludg")) return 0x0020; + if (Has("Acid")) return 0x0040; + if (Has("Cold") || Has("Frost")) return 0x0080; + if (Has("Electric") || Has("Lightning")) return 0x0100; + if (Has("Fire")) return 0x0200; + if (Has("Nether")) return 0x4000; + return 0; + } + + /// Short wield-gate counter names: "Item Augs", "Triune Weave", charm names. + private static string GateName(T11Counter counter) => + counter == T11Counter.ItemAugmentations ? "Item Augs" : T11Catalog.CounterName(counter); + + /// Melee "min-max", variance, "+elem", "+mod%", wand "+N% vs. Monsters" (combat line). + private static void AddDamage(MagItemDescription d, AcObjectClass cls, int maxDmg, double variance, + int elemBonus, double dmgMod, double vsMonsters) + { + const MagItemSection Cbt = MagItemSection.Combat; + if (cls != AcObjectClass.MissileWeapon && maxDmg > 0) + { + string max = maxDmg.ToString(CultureInfo.InvariantCulture); + // The appraisal panel rounds the low end to a whole number (2069 * 0.865 → 1790). + long min = (long)Math.Round(maxDmg * (1 - variance), MidpointRounding.AwayFromZero); + d.Add(Cbt, variance > 0 ? min.ToString(CultureInfo.InvariantCulture) + "-" + max : max); + } + // Three places: loot variances are often x.xx5 and two places would misreport them. + if (variance > 0) + d.Add(Cbt, Math.Round(variance, 3).ToString("0.###", CultureInfo.InvariantCulture) + "v"); + if (elemBonus != 0) + d.Add(Cbt, "+" + elemBonus.ToString(CultureInfo.InvariantCulture)); + // A missing/zero multiplier means "no bonus" (0 would print as -100%). + if (dmgMod > 0 && dmgMod != 1) + d.Add(Cbt, "+" + Math.Round((dmgMod - 1) * 100).ToString(CultureInfo.InvariantCulture) + "%"); + if (vsMonsters > 0 && vsMonsters != 1) + d.Add(Cbt, "+" + Math.Round((vsMonsters - 1) * 100).ToString(CultureInfo.InvariantCulture) + "% vs. Monsters"); + } + + /// Mag "+18%a" from a 1.0-based multiplier; skips missing (≤0) and neutral 1.0. + private static void AddPercent(MagItemDescription d, double multiplier, string suffix, int decimals) + { + if (multiplier <= 0 || multiplier == 1) return; + double pct = Math.Round((multiplier - 1) * 100, decimals); + if (pct == 0) return; // rounds to nothing at this precision + // Signed like the appraisal panel ("Bonus to Attack Skill +20%"); penalties keep their '-'. + d.Add(MagItemSection.Combat, (pct > 0 ? "+" : "") + pct.ToString(CultureInfo.InvariantCulture) + suffix); + } + + /// "Wield Lvl 180" for a level requirement, else "Heavy Weapons 375". + private static void AddWieldRequirement(MagItemDescription d, int reqType, int skillOrAttr, int value) + { + // Int64 gates name a counter, not a skill; the T11 text supplies those. + if (value <= 0 || reqType == WieldReqInt64Stat) return; + string v = value.ToString(CultureInfo.InvariantCulture); + d.Add(MagItemSection.Requirements, reqType == 7 // WieldRequirement.Level + ? "Wield Lvl " + v + : SkillName(skillOrAttr) + " " + v); + } + + private static string SkillName(int skill) => + MagItemInfoTables.Skills.TryGetValue(skill, out string? name) ? name : $"Skill {skill}"; + + /// + /// Mag-Tools spell filter (ub-IT applies it to every item): keep cantrip Impen, Augmented + /// (trinket) spells, banes/Impen only on unenchantable gear, level 7+ weapon auras, and + /// named high-tier spells (cantrips); drop I–VI, level-7 lore buffs and Incantations. + /// Verbose lists every spell (capped) for troubleshooting. + /// + private static void AddSpells(MagItemDescription d, IReadOnlyList spellIds, bool unenchantable, + bool verbose, int maxVerbose) + { + if (spellIds.Count == 0) return; + var ids = new List(spellIds); + ids.Sort(); + ids.Reverse(); // Mag lists highest spell id first + + var seen = new HashSet(); + var verboseList = verbose ? new StringBuilder() : null; + int shown = 0, skippedVerbose = 0; + foreach (int id in ids) + { + if (!seen.Add(id)) continue; + bool known = SpellDatabase.HasSpell(id); + if (verboseList != null) + { + // Verbose is the troubleshooting view: list ids SpellData.txt doesn't know too. + if (shown >= maxVerbose) { skippedVerbose++; continue; } + verboseList.Append(shown == 0 ? "Spells: " : "; ") + .Append(known ? SpellDatabase.GetSpellName(id) : $"Spell {id}"); + shown++; + continue; + } + if (!known) continue; + string name = SpellDatabase.GetSpellName(id); + SpellDatabase.TryGetSpellMeta(id, out int family, out int difficulty); + if (ShouldShowSpell(name, family, difficulty, unenchantable)) + d.Add(MagItemSection.Spells, name); + } + if (verboseList == null || verboseList.Length == 0) return; + if (skippedVerbose > 0) verboseList.Append("; (+").Append(skippedVerbose).Append(" more spells)"); + d.Add(MagItemSection.Spells, verboseList.ToString()); + } + + private static bool ShouldShowSpell(string name, int family, int difficulty, bool unenchantable) + { + if (name.Contains("Minor Impenetrability") || name.Contains("Major Impenetrability") + || name.Contains("Epic Impenetrability") || name.Contains("Legendary Impenetrability")) + return true; + if (name.Contains("Augmented")) + return true; + + // Banes / Impen / Brogard's: only meaningful on unenchantable gear (loot armor + // already reflects them in AL and protections). + bool baneLike = name.Contains(" Bane") || name.Contains("Impen") || name.StartsWith("Brogard", StringComparison.Ordinal); + if (baneLike) return unenchantable; + + // Weapon auras (Elysa's Sight .. Swift Killer, Hermetic Link, Vision of the Hunter): + // level 7 (300) and 8+ (400+) only. + if ((family >= 152 && family <= 158) || family == 195 || family == 325) + return difficulty == 300 || difficulty >= 400; + + if (name.EndsWith(" I") || name.EndsWith(" II") || name.EndsWith(" III") + || name.EndsWith(" IV") || name.EndsWith(" V") || name.EndsWith(" VI")) + return false; + if (difficulty == 300) return false; // level-7 lore buffs (Might of the Lugians …) + if (name.Contains("Incantation")) return false; + return true; // cantrips: Legendary Strength, Epic Defender … + } + + /// Rating cluster "[D 11, C 8, CD 4]" from ACE Gear* ratings 370–389 + /// (); bit i of skips rating i. + private static string RatingsCluster(IItemPropertySource item, int hiddenMask) + { + var sb = new StringBuilder(); + var ratings = MagItemInfoCatalog.Ratings; + for (int i = 0; i < ratings.Length; i++) + { + if ((hiddenMask & (1 << i)) != 0) continue; + if (!item.TryGetInt(ratings[i].StatId, out int v) || v <= 0 || v > MaxPlausibleRating) continue; + sb.Append(sb.Length == 0 ? "[" : ", ").Append(ratings[i].Tag).Append(' ') + .Append(v.ToString(CultureInfo.InvariantCulture)); + } + return sb.Length > 0 ? sb.Append(']').ToString() : string.Empty; + } + + /// ACECustom TinkerLog CSV ("64,64,46") → "Steel x2, White Quartz". + private static string FormatTinkerLog(string csv) + { + if (string.IsNullOrWhiteSpace(csv)) return string.Empty; + var order = new List(); + var counts = new Dictionary(); + foreach (string raw in csv.Split(',')) + { + if (!int.TryParse(raw.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int id) || id <= 0) + continue; + if (counts.TryGetValue(id, out int c)) counts[id] = c + 1; + else { counts[id] = 1; order.Add(id); } + } + var sb = new StringBuilder(); + foreach (int id in order) + { + if (sb.Length > 0) sb.Append(", "); + sb.Append(MagItemInfoTables.Materials.TryGetValue(id, out string? name) ? name : $"material {id}"); + if (counts[id] > 1) sb.Append(" x").Append(counts[id]); + } + return sb.ToString(); + } + + /// Max ballistic range (45° arc, v²/g) in yards; 0 when velocity is missing. + private static int MissileRangeYards(double velocity) + { + if (double.IsNaN(velocity) || velocity <= 0) return 0; + double meters = velocity * velocity / 9.8; + return (int)Math.Round(meters * 1.0936133); + } + + private static string Fmt(double v) => Math.Round(v, 2).ToString(CultureInfo.InvariantCulture); +} + +/// over the live client object (RynthCore host reads). +internal sealed class CacheItemPropertySource : IItemPropertySource +{ + private readonly RynthCore.PluginSdk.RynthCoreHost _host; + private readonly uint _id; + private IReadOnlyList? _spells; + + public CacheItemPropertySource(RynthCore.PluginSdk.RynthCoreHost host, WorldObject wo) + { + _host = host; + _id = unchecked((uint)wo.Id); + Name = wo.Name; + ObjectClass = wo.ObjectClass; + } + + public string Name { get; } + public AcObjectClass ObjectClass { get; } + + public bool TryGetInt(uint stype, out int value) + { + value = 0; + return _host.HasGetObjectIntProperty && _host.TryGetObjectIntProperty(_id, stype, out value); + } + + public bool TryGetDouble(uint stype, out double value) + { + value = 0; + return _host.HasGetObjectDoubleProperty && _host.TryGetObjectDoubleProperty(_id, stype, out value); + } + + public string GetString(uint stype) => + _host.HasGetObjectStringProperty && _host.TryGetObjectStringProperty(_id, stype, out string? v) && v != null + ? v + : string.Empty; + + public IReadOnlyList SpellIds => _spells ??= ReadSpells(); + + private IReadOnlyList ReadSpells() + { + if (!_host.HasGetObjectSpellIds) return Array.Empty(); + uint[] buf = new uint[128]; + int n = _host.GetObjectSpellIds(_id, buf, buf.Length); + if (n <= 0) return Array.Empty(); + int take = Math.Min(n, buf.Length); + var list = new List(take); + for (int i = 0; i < take; i++) list.Add(unchecked((int)buf[i])); + return list; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemInfoSettings.cs b/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemInfoSettings.cs new file mode 100644 index 0000000..279eeba --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemInfoSettings.cs @@ -0,0 +1,257 @@ +// MagItemInfoSettings.cs — user options for the Mag-style item info line (/ra iteminfo). +// +// Stored per character inside LegacyUiSettings.ItemInfoSettings. Field visibility is kept as a +// *hidden* bitmask so any field added in a later release shows by default for existing profiles. +using System; + +namespace RynthCore.Plugin.RynthAi.ItemInfo; + +/// Toggleable sections of the item info line (bit set in HiddenFields = not printed). +[Flags] +public enum MagItemInfoField +{ + None = 0, + Material = 1 << 0, + TypeMastery = 1 << 1, + Set = 1 << 2, + ArmorLevel = 1 << 3, + Imbues = 1 << 4, + ArmorCleave = 1 << 5, + CritStats = 1 << 6, + Splits = 1 << 7, + Range = 1 << 8, + CleaveMultiStrike = 1 << 9, + Slayer = 1 << 10, + Tinks = 1 << 11, + Applied = 1 << 12, + Damage = 1 << 13, + Attack = 1 << 14, + Defenses = 1 << 15, + ManaConversion = 1 << 16, + Spells = 1 << 17, + Wield = 1 << 18, + Activation = 1 << 19, + Difficulty = 1 << 20, + Craft = 1 << 21, + Protections = 1 << 22, + Ratings = 1 << 23, + Keyring = 1 << 24, + /// ACECustom T11 state: tier, weapon quality, Gear Grade, property slots, Tainted. + T11 = 1 << 25, +} + +/// Persisted item-info options (JSON fields; see RynthAiJsonContext IncludeFields). +public sealed class MagItemInfoSettings +{ + /// Spell list modes for . + public const int SpellModeMag = 0, SpellModeAll = 1; + /// Mouse triggers for . + public const int ClickOff = 0, ClickLeft = 1, ClickRight = 2; + /// Output layouts for . + public const int LayoutOneLine = 0, LayoutPetLines = 1; + /// value meaning "use ". + public const int SameAsHeader = -1; + + // ── When to print ──────────────────────────────────────────────────────── + /// Print automatically when an item is selected. + public bool OnSelect; + /// + /// Print the selected item after a left () or right () + /// click in the game world / inventory — also re-prints an item that was already selected. + /// + public int ClickTrigger = ClickOff; + /// On-select class filters (manual /ra iteminfo ignores them). + public bool OnSelectWeapons = true; + public bool OnSelectArmor = true; + public bool OnSelectJewelry = true; + public bool OnSelectOther = true; + /// Seconds to wait for an ID before printing partial data. + public float IdTimeoutSec = 3f; + + // ── What to print ──────────────────────────────────────────────────────── + /// bits that are NOT printed. + public int HiddenFields; + /// Bit i set = [i] not printed. + public int HiddenRatings; + /// Append ", Value N, BU N". + public bool ShowValueAndBurden; + /// (Mag filter) or . + public int SpellMode = SpellModeMag; + /// Cap for the "all spells" list. + public int MaxListedSpells = 26; + + // ── How to print ───────────────────────────────────────────────────────── + /// (pet-roster style lines) or (Mag one-liner). + public int Layout = LayoutPetLines; + /// AC chat type passed to WriteToChat (selects the chat colour / window). + public int ChatType = 1; + /// Chat type for pet-style lines 2+, or . + public int DetailChatType = SameAsHeader; + /// + /// Text put in front of every line. RynthChat files lines starting "[RynthAi Item] " under + /// its Items tab (ChatClassifier.IsItemInfo). + /// + public string Prefix = "[RynthAi Item] "; + + /// Item Info settings window open. + public bool ShowWindow; + + public bool IsHidden(MagItemInfoField f) => (HiddenFields & (int)f) != 0; + + public void SetHidden(MagItemInfoField f, bool hidden) => + HiddenFields = hidden ? HiddenFields | (int)f : HiddenFields & ~(int)f; + + public bool IsRatingHidden(int index) => (HiddenRatings & (1 << index)) != 0; + + public void SetRatingHidden(int index, bool hidden) => + HiddenRatings = hidden ? HiddenRatings | (1 << index) : HiddenRatings & ~(1 << index); + + /// Clamp values a hand-edited or older profile could carry out of range. + public void Sanitize() + { + if (float.IsNaN(IdTimeoutSec) || IdTimeoutSec < 0.5f) IdTimeoutSec = 0.5f; + if (IdTimeoutSec > 15f) IdTimeoutSec = 15f; + if (SpellMode is not (SpellModeMag or SpellModeAll)) SpellMode = SpellModeMag; + MaxListedSpells = Math.Clamp(MaxListedSpells, 1, 64); + if (ChatType < 0 || ChatType > 31) ChatType = 1; + if (DetailChatType < SameAsHeader || DetailChatType > 31) DetailChatType = SameAsHeader; + if (ClickTrigger is not (ClickOff or ClickLeft or ClickRight)) ClickTrigger = ClickOff; + if (Layout is not (LayoutOneLine or LayoutPetLines)) Layout = LayoutPetLines; + Prefix ??= string.Empty; + if (Prefix.Length > 32) Prefix = Prefix[..32]; + } + + /// Back to first-run defaults (window stays open). + public void ResetToDefaults() + { + var d = new MagItemInfoSettings(); + OnSelect = d.OnSelect; + ClickTrigger = d.ClickTrigger; + Layout = d.Layout; + DetailChatType = d.DetailChatType; + OnSelectWeapons = d.OnSelectWeapons; OnSelectArmor = d.OnSelectArmor; + OnSelectJewelry = d.OnSelectJewelry; OnSelectOther = d.OnSelectOther; + IdTimeoutSec = d.IdTimeoutSec; + HiddenFields = d.HiddenFields; HiddenRatings = d.HiddenRatings; + ShowValueAndBurden = d.ShowValueAndBurden; + SpellMode = d.SpellMode; MaxListedSpells = d.MaxListedSpells; + ChatType = d.ChatType; Prefix = d.Prefix; + } +} + +/// Labels for the settings window and the /ra iteminfo field|rating commands. +public static class MagItemInfoCatalog +{ + public readonly record struct FieldInfo(MagItemInfoField Field, string Label, string Example); + public readonly record struct RatingInfo(uint StatId, string Tag, string Name); + + /// In print order. + public static readonly FieldInfo[] Fields = + { + new(MagItemInfoField.Material, "Material", "Gold Ornate Long Sword"), + new(MagItemInfoField.TypeMastery, "Damage type / mastery","(Slash Sword)"), + new(MagItemInfoField.Set, "Equipment set", "Noble Relic Set"), + new(MagItemInfoField.T11, "T11 tier / grade / slots", "T16, Gear B+ (4 lines), Props 3/5, Tainted"), + new(MagItemInfoField.ArmorLevel, "Armor level", "AL 650"), + new(MagItemInfoField.Imbues, "Imbues", "CS, AR, FireRend"), + new(MagItemInfoField.ArmorCleave, "Armor cleaving", "AC"), + new(MagItemInfoField.CritStats, "Crit mult / freq", "CritMult (1.5), CritFreq (0.15)"), + new(MagItemInfoField.Splits, "Split arrows", "Splits (2)"), + new(MagItemInfoField.Range, "Missile range", "Range 120yd"), + new(MagItemInfoField.CleaveMultiStrike, "Cleaving / Multi-Strike", "Cleaving"), + new(MagItemInfoField.Slayer, "Slayer", "Undead Slayer"), + new(MagItemInfoField.Tinks, "Tinks", "Tinks 4"), + new(MagItemInfoField.Applied, "Applied materials", "Applied: Steel x2"), + new(MagItemInfoField.Damage, "Damage", "152.48-236, 0.35v, +18, +10%"), + new(MagItemInfoField.Attack, "Attack bonus", "+18%a"), + new(MagItemInfoField.Defenses, "Defense bonuses", "12%md, 1.5%mgc.d, 1%msl.d"), + new(MagItemInfoField.ManaConversion, "Mana conversion", "6%mc"), + new(MagItemInfoField.Spells, "Spells", "Legendary Blood Thirst"), + new(MagItemInfoField.Wield, "Wield requirements", "Wield Lvl 180, Heavy Weapons 375"), + new(MagItemInfoField.Activation, "Activation / use reqs","Lvl 50, Melee Defense 300 to Activate"), + new(MagItemInfoField.Difficulty, "Arcane difficulty", "Diff 270"), + new(MagItemInfoField.Craft, "Craft / salvage work", "Craft 8"), + new(MagItemInfoField.Protections, "Protections (unenchantable armor)", "[1.0/0.8/1.2/...]"), + new(MagItemInfoField.Ratings, "Ratings", "[D 3, CD 2]"), + new(MagItemInfoField.Keyring, "Keyring keys / uses", "Keys: 3, Uses: 25"), + }; + + /// ACE gear ratings (PropertyInt 370–389) in Mag print order. + public static readonly RatingInfo[] Ratings = + { + new(370, "D", "Damage"), + new(371, "DR", "Damage Resist"), + new(372, "C", "Crit"), + new(374, "CD", "Crit Damage"), + new(373, "CR", "Crit Resist"), + new(375, "CDR", "Crit Damage Resist"), + new(376, "HB", "Healing Boost"), + new(379, "V", "Vitality"), + new(377, "NR", "Nether Resist"), + new(378, "LR", "Life Resist"), + new(383, "PKD", "PK Damage"), + new(384, "PKDR", "PK Damage Resist"), + new(388, "OP", "Overpower"), + new(389, "OPR", "Overpower Resist"), + }; + + /// Labels for , indexed by value. + public static readonly string[] ClickTriggers = { "Off", "Left mouse click", "Right mouse click" }; + + /// Labels for , indexed by value. + public static readonly string[] Layouts = { "One line (Mag-Tools)", "Pet-style lines" }; + + /// Common AC chat types for the colour picker (value passed to WriteToChat). + public static readonly (int Type, string Label)[] ChatTypes = + { + (0, "0 - Broadcast"), + (1, "1 - RynthAi default"), + (2, "2 - Speech"), + (3, "3 - Tell"), + (4, "4 - Outgoing tell"), + (5, "5 - System"), + (6, "6 - Combat"), + (7, "7 - Magic"), + (8, "8 - Channels"), + (10, "10 - Social"), + (12, "12 - Emote"), + (13, "13 - Advancement"), + (15, "15 - Help"), + (16, "16 - Appraisal"), + (17, "17 - Spellcasting"), + (18, "18 - Allegiance"), + (19, "19 - Fellowship"), + (21, "21 - Combat (enemy)"), + (22, "22 - Combat (self)"), + (24, "24 - Craft"), + (25, "25 - Salvaging"), + }; + + /// Field by enum name or label word, case-insensitive ("ratings", "slayer", "typemastery"). + public static bool TryFindField(string key, out MagItemInfoField field) + { + foreach (var f in Fields) + { + if (f.Field.ToString().Equals(key, StringComparison.OrdinalIgnoreCase) + || f.Label.Replace(" ", string.Empty).StartsWith(key, StringComparison.OrdinalIgnoreCase)) + { + field = f.Field; + return true; + } + } + field = MagItemInfoField.None; + return false; + } + + /// Rating index by tag ("CD") or name ("critdamage"), case-insensitive. + public static int FindRating(string key) + { + for (int i = 0; i < Ratings.Length; i++) + { + if (Ratings[i].Tag.Equals(key, StringComparison.OrdinalIgnoreCase) + || Ratings[i].Name.Replace(" ", string.Empty).Equals(key, StringComparison.OrdinalIgnoreCase)) + return i; + } + return -1; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemInfoTables.cs b/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemInfoTables.cs new file mode 100644 index 0000000..d90564a --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemInfoTables.cs @@ -0,0 +1,159 @@ +// MagItemInfoTables.cs — name tables for the Mag-style item info line (MagItemDescriber). +// Skill / mastery / set / material names follow UtilityBelt ub-IT (Lib/ItemInfoHelper/Dictionaries.cs, +// itself from Mag-Tools / Alinco / VTank). Slayer names use the full ACE CreatureType enum instead of +// ub-IT's 17-entry subset so every slayer resolves. +using System.Collections.Generic; +using System.Text; + +namespace RynthCore.Plugin.RynthAi.ItemInfo; + +internal static class MagItemInfoTables +{ + /// Skill id → name (wield / activation / summoning requirements). + public static readonly Dictionary Skills = new() + { + { 0x01, "Axe" }, { 0x02, "Bow" }, { 0x03, "Crossbow" }, { 0x04, "Dagger" }, { 0x05, "Mace" }, + { 0x06, "Melee Defense" }, { 0x07, "Missile Defense" }, { 0x08, "Sling" }, { 0x09, "Spear" }, + { 0x0A, "Staff" }, { 0x0B, "Sword" }, { 0x0C, "Thrown Weapons" }, { 0x0D, "Unarmed Combat" }, + { 0x0E, "Arcane Lore" }, { 0x0F, "Magic Defense" }, { 0x10, "Mana Conversion" }, + { 0x12, "Item Tinkering" }, { 0x13, "Assess Person" }, { 0x14, "Deception" }, { 0x15, "Healing" }, + { 0x16, "Jump" }, { 0x17, "Lockpick" }, { 0x18, "Run" }, { 0x1B, "Assess Creature" }, + { 0x1C, "Weapon Tinkering" }, { 0x1D, "Armor Tinkering" }, { 0x1E, "Magic Item Tinkering" }, + { 0x1F, "Creature Enchantment" }, { 0x20, "Item Enchantment" }, { 0x21, "Life Magic" }, + { 0x22, "War Magic" }, { 0x23, "Leadership" }, { 0x24, "Loyalty" }, { 0x25, "Fletching" }, + { 0x26, "Alchemy" }, { 0x27, "Cooking" }, { 0x28, "Salvaging" }, { 0x29, "Two Handed Combat" }, + { 0x2A, "Gearcraft" }, { 0x2B, "Void" }, { 0x2C, "Heavy Weapons" }, { 0x2D, "Light Weapons" }, + { 0x2E, "Finesse Weapons" }, { 0x2F, "Missile Weapons" }, { 0x30, "Shield" }, { 0x31, "Dual Wield" }, + { 0x32, "Recklessness" }, { 0x33, "Sneak Attack" }, { 0x34, "Dirty Fighting" }, { 0x35, "Challenge" }, + { 0x36, "Summoning" }, + }; + + /// ACE PropertyInt.WeaponType (353) → mastery name. + public static readonly Dictionary Masteries = new() + { + { 1, "Unarmed Weapon" }, { 2, "Sword" }, { 3, "Axe" }, { 4, "Mace" }, { 5, "Spear" }, { 6, "Dagger" }, + { 7, "Staff" }, { 8, "Bow" }, { 9, "Crossbow" }, { 10, "Thrown" }, { 11, "Two Handed Combat" }, { 12, "Wand" }, + }; + + /// ACE PropertyInt.MaterialType (131) → material name. + public static readonly Dictionary Materials = new() + { + { 1, "Ceramic" }, { 2, "Porcelain" }, { 4, "Linen" }, { 5, "Satin" }, { 6, "Silk" }, { 7, "Velvet" }, + { 8, "Wool" }, { 10, "Agate" }, { 11, "Amber" }, { 12, "Amethyst" }, { 13, "Aquamarine" }, + { 14, "Azurite" }, { 15, "Bag of Abyssal-Touched" }, { 16, "Black Opal" }, { 17, "Bloodstone" }, + { 18, "Carnelian" }, { 19, "Citrine" }, { 20, "Diamond" }, { 21, "Emerald" }, { 22, "Fire Opal" }, + { 23, "Green Garnet" }, { 24, "Green Jade" }, { 25, "Hematite" }, { 26, "Imperial Topaz" }, { 27, "Jet" }, + { 28, "Lapis Lazuli" }, { 29, "Lavender Jade" }, { 30, "Malachite" }, { 31, "Moonstone" }, { 32, "Onyx" }, + { 33, "Opal" }, { 34, "Peridot" }, { 35, "Red Garnet" }, { 36, "Red Jade" }, { 37, "Rose Quartz" }, + { 38, "Ruby" }, { 39, "Sapphire" }, { 40, "Smokey Quartz" }, { 41, "Sunstone" }, { 42, "Tiger Eye" }, + { 43, "Tourmaline" }, { 44, "Turquoise" }, { 45, "White Jade" }, { 46, "White Quartz" }, + { 47, "White Sapphire" }, { 48, "Yellow Garnet" }, { 49, "Yellow Topaz" }, { 50, "Zircon" }, + { 51, "Ivory" }, { 52, "Leather" }, { 53, "Armoredillo Hide" }, { 54, "Gromnie Hide" }, + { 55, "Reed Shark Hide" }, { 57, "Brass" }, { 58, "Bronze" }, { 59, "Copper" }, { 60, "Gold" }, + { 61, "Iron" }, { 62, "Pyreal" }, { 63, "Silver" }, { 64, "Steel" }, { 66, "Alabaster" }, + { 67, "Granite" }, { 68, "Marble" }, { 69, "Obsidian" }, { 70, "Sandstone" }, { 71, "Serpentine" }, + { 73, "Ebony" }, { 74, "Mahogany" }, { 75, "Oak" }, { 76, "Pine" }, { 77, "Teak" }, + }; + + /// ACE PropertyInt.EquipmentSetId (265) → set name. + public static readonly Dictionary EquipmentSets = BuildSets(); + + /// ACE CreatureType enum, index = value (0..101). Used for SlayerCreatureType (166). + private static readonly string[] CreatureTypes = + { + "Invalid", "Olthoi", "Banderling", "Drudge", "Mosswart", "Lugian", "Tumerok", "Mite", "Tusker", + "Phyntos Wasp", "Rat", "Auroch", "Cow", "Golem", "Undead", "Gromnie", "Reedshark", "Armoredillo", + "Fae", "Virindi", "Wisp", "Knathtead", "Shadow", "Mattekar", "Mumiyah", "Rabbit", "Sclavus", + "Shallows Shark", "Monouga", "Zefir", "Skeleton", "Human", "Shreth", "Chittick", "Moarsman", + "Olthoi Larvae", "Slithis", "Deru", "Fire Elemental", "Snowman", "Unknown", "Bunny", + "Lightning Elemental", "Rockslide", "Grievver", "Niffis", "Ursuin", "Crystal", "Hollow Minion", + "Scarecrow", "Idol", "Empyrean", "Hopeslayer", "Doll", "Marionette", "Carenzi", "Siraluun", + "Aun Tumerok", "Hea Tumerok", "Simulacrum", "Acid Elemental", "Frost Elemental", "Elemental", + "Statue", "Wall", "Altered Human", "Device", "Harbinger", "Dark Sarcophagus", "Chicken", + "Gotrok Lugian", "Margul", "Bleached Rabbit", "Nasty Rabbit", "Grimacing Rabbit", "Burun", "Target", + "Ghost", "Fiun", "Eater", "Penguin", "Ruschk", "Thrungus", "Viamontian Knight", "Remoran", "Swarm", + "Moar", "Enchanted Arms", "Sleech", "Mukkir", "Merwart", "Food", "Paradox Olthoi", "Harvest", + "Energy", "Apparition", "Aerbax", "Touched", "Blighted Moarsman", "Gear Knight", "Gurog", "A'nekshay", + }; + + /// Slayer creature name, or null for 0 / unknown values. + public static string? CreatureTypeName(int value) => + value > 0 && value < CreatureTypes.Length ? CreatureTypes[value] : null; + + /// + /// ACE DamageType flags (45) → "Slash", "Slash/Pierce", "Lightning" … Empty when no known bit is set. + /// + public static string DamageTypeName(int flags) + { + if (flags <= 0) return string.Empty; + var sb = new StringBuilder(); + void Add(int bit, string name) + { + if ((flags & bit) == 0) return; + if (sb.Length > 0) sb.Append('/'); + sb.Append(name); + } + Add(0x001, "Slash"); + Add(0x002, "Pierce"); + Add(0x004, "Bludgeon"); + Add(0x008, "Cold"); + Add(0x010, "Fire"); + Add(0x020, "Acid"); + Add(0x040, "Lightning"); + Add(0x400, "Nether"); + return sb.ToString(); + } + + private static Dictionary BuildSets() + { + var d = new Dictionary + { + { 2, "Test" }, { 4, "Carraida's Benediction" }, { 5, "Noble Relic Set" }, { 6, "Ancient Relic Set" }, + { 7, "Relic Alduressa Set" }, { 8, "Shou-jen Set" }, { 9, "Empyrean Rings Set" }, + { 10, "Arm, Mind, Heart Set" }, { 11, "Coat of the Perfect Light Set" }, + { 12, "Leggings of Perfect Light Set" }, { 13, "Soldier's Set" }, { 14, "Adept's Set" }, + { 15, "Archer's Set" }, { 16, "Defender's Set" }, { 17, "Tinker's Set" }, { 18, "Crafter's Set" }, + { 19, "Hearty Set" }, { 20, "Dexterous Set" }, { 21, "Wise Set" }, { 22, "Swift Set" }, + { 23, "Hardened Set" }, { 24, "Reinforced Set" }, { 25, "Interlocking Set" }, + { 26, "Flame Proof Set" }, { 27, "Acid Proof Set" }, { 28, "Cold Proof Set" }, + { 29, "Lightning Proof Set" }, { 30, "Dedication Set" }, { 31, "Gladiatorial Clothing Set" }, + { 32, "Ceremonial Clothing" }, { 33, "Protective Clothing" }, { 34, "Noobie Armor" }, + { 35, "Sigil of Defense" }, { 36, "Sigil of Destruction" }, { 37, "Sigil of Fury" }, + { 38, "Sigil of Growth" }, { 39, "Sigil of Vigor" }, { 40, "Heroic Protector Set" }, + { 41, "Heroic Destroyer Set" }, { 42, "Olthoi Armor D Red" }, { 43, "Olthoi Armor C Rat" }, + { 44, "Olthoi Armor C Red" }, { 45, "Olthoi Armor D Rat" }, { 46, "Upgraded Relic Alduressa Set" }, + { 47, "Upgraded Ancient Relic Set" }, { 48, "Upgraded Noble Relic Set" }, + { 49, "Weave of Alchemy" }, { 50, "Weave of Arcane Lore" }, { 51, "Weave of Armor Tinkering" }, + { 52, "Weave of Assess Person" }, { 53, "Weave of Light Weapons" }, { 54, "Weave of Missile Weapons" }, + { 55, "Weave of Cooking" }, { 56, "Weave of Creature Enchantment" }, { 57, "Weave of Missile Weapons" }, + { 58, "Weave of Finesse" }, { 59, "Weave of Deception" }, { 60, "Weave of Fletching" }, + { 61, "Weave of Healing" }, { 62, "Weave of Item Enchantment" }, { 63, "Weave of Item Tinkering" }, + { 64, "Weave of Leadership" }, { 65, "Weave of Life Magic" }, { 66, "Weave of Loyalty" }, + { 67, "Weave of Light Weapons" }, { 68, "Weave of Magic Defense" }, + { 69, "Weave of Magic Item Tinkering" }, { 70, "Weave of Mana Conversion" }, + { 71, "Weave of Melee Defense" }, { 72, "Weave of Missile Defense" }, { 73, "Weave of Salvaging" }, + { 74, "Weave of Light Weapons" }, { 75, "Weave of Light Weapons" }, { 76, "Weave of Heavy Weapons" }, + { 77, "Weave of Missile Weapons" }, { 78, "Weave of Two Handed Combat" }, { 79, "Weave of Light Weapons" }, + { 80, "Weave of Void Magic" }, { 81, "Weave of War Magic" }, { 82, "Weave of Weapon Tinkering" }, + { 83, "Weave of Assess Creature" }, { 84, "Weave of Dirty Fighting" }, { 85, "Weave of Dual Wield" }, + { 86, "Weave of Recklessness" }, { 87, "Weave of Shield" }, { 88, "Weave of Sneak Attack" }, + { 89, "Ninja_New" }, { 90, "Weave of Summoning" }, { 91, "Shrouded Soul" }, { 92, "Darkened Mind" }, + { 93, "Clouded Spirit" }, { 130, "Shimmering Shadows" }, { 131, "Brown Society Locket" }, + { 132, "Yellow Society Locket" }, { 133, "Red Society Band" }, { 134, "Green Society Band" }, + { 135, "Purple Society Band" }, { 136, "Blue Society Band" }, { 137, "Gauntlet Garb" }, + { 138, "Paragon" }, { 139, "Paragon" }, { 140, "Paragon" }, + }; + + // 94..129: Minor / Major / Blackfire × Stinging / Sparking / Smoldering / Shivering × + // Shrouded Soul / Darkened Mind / Clouded Spirit (same order as the VTank set list). + string[] tiers = { "Minor", "Major", "Blackfire" }; + string[] souls = { "Shrouded Soul", "Darkened Mind", "Clouded Spirit" }; + string[] elements = { "Stinging", "Sparking", "Smoldering", "Shivering" }; + int id = 94; + foreach (string tier in tiers) + foreach (string soul in souls) + foreach (string element in elements) + d[id++] = $"{tier} {element} {soul}"; + return d; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Jumper.cs b/Plugins/RynthCore.Plugin.RynthAi/Jumper.cs index 22ece09..3e6a1e8 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Jumper.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Jumper.cs @@ -89,11 +89,11 @@ internal sealed class Jumper _turningStartedAt = DateTime.UtcNow; if (_host.HasTurnToHeading) _host.TurnToHeadingBy("Jump", _targetHeading); - _host.Log($"[Jumper] Start turn->{_targetHeading:F0} letters='{directionLetters}' hold={_msToHoldDown}ms"); + RynthLog.Write(LogCat.Jumper, $"[Jumper] Start turn->{_targetHeading:F0} letters='{directionLetters}' hold={_msToHoldDown}ms"); } else { - _host.Log($"[Jumper] Start jump (no turn) letters='{directionLetters}' hold={_msToHoldDown}ms"); + RynthLog.Write(LogCat.Jumper, $"[Jumper] Start jump (no turn) letters='{directionLetters}' hold={_msToHoldDown}ms"); } return true; } @@ -118,7 +118,7 @@ internal sealed class Jumper { _isTurning = false; if (_host.TryGetPlayerHeading(out float current)) - _host.Log($"[Jumper] Turn done heading={current:F1}"); + RynthLog.Write(LogCat.Jumper, $"[Jumper] Turn done heading={current:F1}"); } if (_needToJump && !_isTurning) @@ -141,12 +141,12 @@ internal sealed class Jumper RestoreNav(); _waitingForJump = false; _addW = _addX = _addZ = _addC = _addShift = false; - _host.Log("[Jumper] Settle complete -> idle"); + RynthLog.Write(LogCat.Jumper, "[Jumper] Settle complete -> idle"); } } catch (Exception ex) { - _host.Log($"[Jumper] Tick exception: {ex.GetType().Name}: {ex.Message}"); + RynthLog.Write(LogCat.Jumper, $"[Jumper] Tick exception: {ex.GetType().Name}: {ex.Message}"); Cancel(); } } @@ -166,7 +166,7 @@ internal sealed class Jumper started = _host.CommenceJump(); _charging = started; _chargeStartedAt = DateTime.UtcNow; - _host.Log($"[Jumper] CommenceJump ok={started} hold={_msToHoldDown}ms " + + RynthLog.Write(LogCat.Jumper, $"[Jumper] CommenceJump ok={started} hold={_msToHoldDown}ms " + $"w={_addW} x={_addX} z={_addZ} c={_addC} shift={_addShift}"); } else @@ -174,7 +174,7 @@ internal sealed class Jumper started = _host.HasTapJump && _host.TapJump(); _waitingForJump = started; _jumpStartedAt = DateTime.UtcNow; - _host.Log($"[Jumper] TapJump fallback ok={started} " + + RynthLog.Write(LogCat.Jumper, $"[Jumper] TapJump fallback ok={started} " + $"w={_addW} x={_addX} z={_addZ} c={_addC} shift={_addShift}"); } @@ -200,13 +200,13 @@ internal sealed class Jumper if (_host.HasLaunchJumpWithMotion) { released = _host.LaunchJumpWithMotion(_addShift, _addW, _addX, _addZ, _addC); - _host.Log($"[Jumper] LaunchJumpWithMotion ok={released} charged={_msToHoldDown}ms " + + RynthLog.Write(LogCat.Jumper, $"[Jumper] LaunchJumpWithMotion ok={released} charged={_msToHoldDown}ms " + $"w={_addW} x={_addX} z={_addZ} c={_addC} shift={_addShift}"); } else { released = _host.HasDoJump && _host.DoJump(true); - _host.Log($"[Jumper] DoJump fallback ok={released} charged={_msToHoldDown}ms"); + RynthLog.Write(LogCat.Jumper, $"[Jumper] DoJump fallback ok={released} charged={_msToHoldDown}ms"); } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs index 0ffb9f2..325a6a2 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs @@ -11,9 +11,16 @@ internal sealed class LegacyAdvancedSettingsUi // Scratch buffer for the "never attack" name entry box. private string _newBlacklistName = ""; + // Server Features list being edited (committed on Enter / focus loss); null = show the saved list. + private string? _serverNamesEdit; private static readonly string[] AttackHeights = { "Low", "Medium", "High" }; private static readonly string[] NavLabelModeNames = { "Off", "Numbers", "Numbers and names" }; + private const string NavResumeNearestTip = + "On: starting the macro, loading a Circular or Linear route, and carrying on after a fight, loot, buff or door\n" + + "that moved you 10 yd or more all head for the closest waypoint on the route. A waypoint you have already\n" + + "walked past is skipped for the one after it, so nav doesn't turn back. Once routes only look ahead.\n" + + "Off: nav carries on to the waypoint it was heading for, and a loaded route starts at its first point."; private static readonly string[] TargetSelectionNames = { "Lowest health", "Closest", "Farthest", "Least turning" }; private static readonly string[] LootOwnershipModes = { "My Kills Only", "Fellowship Kills", "All Corpses" }; @@ -27,6 +34,15 @@ internal sealed class LegacyAdvancedSettingsUi private Func? _autoVendorStatus; public void SetAutoVendorStatusProvider(Func status) => _autoVendorStatus = status; + // Buffing page: the Force Buff button's actions and the list of buffs the unusable-buff + // filter is leaving out (wired by RynthAiPlugin once the BuffManager exists). + private Action? _forceBuff, _cancelBuff; + private Func? _buffSkips; + public void SetBuffActions(Action? force, Action? cancel, Func? skips) + { + _forceBuff = force; _cancelBuff = cancel; _buffSkips = skips; + } + private Func? _autoTradeStatus; public void SetAutoTradeStatusProvider(Func status) => _autoTradeStatus = status; private string _newAutoAcceptPattern = ""; @@ -68,6 +84,35 @@ internal sealed class LegacyAdvancedSettingsUi ImGui.End(); } + /// Settings > Misc "Server Features": the world list and the manual override (ServerFeatureGate). + private void RenderServerFeatures() + { + ImGui.Text("Server Features (ILT / infinite attributes)"); + ImGui.TextDisabled(IltHub.ServerFeatureGate.Describe(_settings)); + + string text = _serverNamesEdit ?? IltHub.ServerFeatureGate.FormatList(_settings.FeatureServerNames); + ImGui.SetNextItemWidth(320); + bool enter = ImGui.InputTextWithHint("Servers##featureServers", "InfiniteLeaftide, *Leaftide*", ref text, 512, + ImGuiInputTextFlags.EnterReturnsTrue); + if (ImGui.IsItemActive() || enter) _serverNamesEdit = text; + if ((enter || ImGui.IsItemDeactivatedAfterEdit()) && _serverNamesEdit != null) + { + _settings.FeatureServerNames = IltHub.ServerFeatureGate.ParseList(_serverNamesEdit); + _serverNamesEdit = null; + } + else if (!ImGui.IsItemActive()) _serverNamesEdit = null; + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Comma-separated world names that turn on the Mini Remote's ILT tabs, the Progression\n" + + "planners and the attribute raiser. * is a wildcard (*Leaftide* matches any\n" + + "name containing Leaftide). Case does not matter."); + + ImGui.Checkbox("Force enable on this server (manual override)", ref _settings.ForceServerFeatures); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Turn the features on for whatever world you are on, even if it is not in the list.\n" + + "Each feature still follows what the server reports (for example /xp off keeps\n" + + "the attribute raiser off)."); + } + private void RenderVendoring() { ImGui.Text("AutoVendor (UtilityBelt)"); @@ -279,6 +324,10 @@ internal sealed class LegacyAdvancedSettingsUi ImGui.SetTooltip("When acid or lava hurts you, stop everything (combat, buffs, healing, looting)\nand walk back out the way you came. The spot is remembered so the patrol avoids it.\nTurn off for a character that walks through acid on purpose."); ImGui.Checkbox("Enable Raycasting", ref _settings.EnableRaycasting); + ImGui.Separator(); + ImGui.Spacing(); + RenderServerFeatures(); + ImGui.Separator(); ImGui.Spacing(); ImGui.Text("Missile Arc Velocities (m/s)"); @@ -507,6 +556,32 @@ internal sealed class LegacyAdvancedSettingsUi "Lower = faster buff chains. 400ms is a good balance.\n" + "Below 200ms may cause fizzles or dropped casts on laggy servers."); + ImGui.SetNextItemWidth(180); + ImGui.SliderInt("Stuck Cast Break (ms)", ref _settings.StuckCastBreakMs, 0, 20000); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip( + "The longest a cast may stay unanswered before it is broken\n" + + "with a jump (the server then fails the cast). It fires sooner,\n" + + "about 2 s past the spell's normal cycle, when that is shorter.\n" + + "After a 'too busy' answer nothing is cast until the server answers.\n" + + "0 = never break."); + + ImGui.SetNextItemWidth(180); + ImGui.SliderInt("Recovery Retry (ms)", ref _settings.RecoveryRetryMs, 200, 5000); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip( + "Heal Self, Stamina to Health, Revitalize and Stamina to Mana refused\n" + + "for 'not enough mana' are tried again after this long: each try\n" + + "rolls Mana Conversion again, and a refusal costs nothing.\n" + + "At most 5 tries a second, 20 in a row."); + + ImGui.Checkbox("HP Failsafe Recall", ref _settings.HpFailsafeRecall); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip( + "At or under Emergency Heal At with heals failing: break the\n" + + "stuck cast with a jump and heal again; if that fails too,\n" + + "recall to the lifestone."); + ImGui.SetNextItemWidth(180); ImGui.SliderInt("Attack Spell Delay (ms)", ref _settings.AttackSpellIntervalMs, 0, 5000); if (ImGui.IsItemHovered()) @@ -645,6 +720,10 @@ internal sealed class LegacyAdvancedSettingsUi ImGui.Separator(); ImGui.Text("Getting Back On Route"); + ImGui.Checkbox("Go To Closest Waypoint", ref _settings.NavResumeNearest); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip(NavResumeNearestTip); + ImGui.Checkbox("Find A Way Back When Stuck", ref _settings.NavRecoveryEnabled); if (ImGui.IsItemHovered()) ImGui.SetTooltip("When a jump doesn't free a stuck character, or navigation wanders far off the route, plan a way back to the route around walls and obstacles (the dungeon map indoors, RynthNav outdoors) and open doors on the way. Off = only the jump and side-step escapes, as before."); @@ -756,6 +835,35 @@ internal sealed class LegacyAdvancedSettingsUi "For servers with buff augments, where your own cast is stronger or\n" + "lasts longer. On by default: on retail it costs a few extra casts."); + ImGui.Checkbox("Chain buffs on the server's answer", ref _settings.FastBuffChain); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip( + "Send the next buff as soon as the server finishes the last one,\n" + + "without waiting for the cast's recoil animation to end.\n" + + "A refused cast turns it off for the rest of that buff pass.\n" + + "On by default. Off = every buff waits for the animation."); + ImGui.Checkbox("Skip buffs this character can't use", ref _settings.SkipUnusableBuffs); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip( + "Leave out Blood Drinker / Heart Seeker / Swift Killer when you have no melee or\n" + + "missile weapon (listed or in hand), Spirit Drinker / Hermetic Link when you have no\n" + + "wand, and Defender when you have neither. Masteries for untrained skills are\n" + + "always skipped. On by default. Off = weapon enchantments are cast regardless of\n" + + "listed weapons."); + string skipped = _buffSkips?.Invoke() ?? ""; + if (_settings.SkipUnusableBuffs && skipped.Length > 0) + ImGui.TextWrapped("Skipping: " + skipped); + + ImGui.Spacing(); + if (ImGui.Button("Force Buff##forceBuff") && _forceBuff != null) _forceBuff(); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip( + "Recast every buff now, whatever time is left on it, starting with\n" + + "Creature Enchantment, Focus, Willpower and Life Magic.\n" + + "Same as /ra buff force (and the FR button)."); + ImGui.SameLine(); + if (ImGui.Button("Cancel##cancelBuff") && _cancelBuff != null) _cancelBuff(); + ImGui.Spacing(); ImGui.Separator(); ImGui.Text("Protections and Banes"); @@ -830,9 +938,14 @@ internal sealed class LegacyAdvancedSettingsUi ImGui.Checkbox("Recover My Corpse", ref _settings.LootOwnCorpse); if (ImGui.IsItemHovered()) ImGui.SetTooltip("When your own corpse (\"Corpse of \") is within loot range, open it and take\nevery item on it, whatever the loot profile and Loot From say."); - ImGui.Checkbox("Item Info On Select", ref _settings.ItemInfoOnSelect); + ImGui.Checkbox("Item Info On Select", ref _settings.ItemInfoSettings.OnSelect); if (ImGui.IsItemHovered()) ImGui.SetTooltip("Selecting an item prints its details to chat (/ra iteminfo)."); + ImGui.SameLine(); + if (ImGui.SmallButton("Options##iiOpts")) + _settings.ItemInfoSettings.ShowWindow = !_settings.ItemInfoSettings.ShowWindow; + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Open the RynthAi Item Info window (fields, ratings, click trigger, layout)."); ImGui.Checkbox("Travel Back To My Corpse", ref _settings.TravelToOwnCorpse); if (ImGui.IsItemHovered()) ImGui.SetTooltip("After a death, travel back to where you died with RynthNav (outdoors only),\nfighting on the way, recover the corpse, then carry on. Needs the macro running."); @@ -847,6 +960,9 @@ internal sealed class LegacyAdvancedSettingsUi ImGui.Checkbox("Combine Bags During Salvage", ref _settings.CombineBagsDuringSalvage); if (ImGui.IsItemHovered()) ImGui.SetTooltip("When salvaging an item, also add any under-full salvage bag of the same material to the salvage panel — the salvage operation merges them into a single bag."); + ImGui.Checkbox("Salvage Without The Panel", ref _settings.SalvageWithoutPanel); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Salvage (and combine bags) by sending the salvage request to the server directly: AC's salvage panel never opens. A request that changes nothing is tried once through the panel. Needs an engine with plugin API v82."); ImGui.Spacing(); ImGui.Separator(); diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.LocalFeatures.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.LocalFeatures.cs new file mode 100644 index 0000000..54bd732 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.LocalFeatures.cs @@ -0,0 +1,27 @@ +// LegacyDashboardRenderer.LocalFeatures.cs — style shared with the plugin's own ImGui windows +// (ILT Hub, floating HUDs, chat translator). +using System.Numerics; +using ImGuiNET; + +namespace RynthCore.Plugin.RynthAi.LegacyUi; + +internal sealed partial class LegacyDashboardRenderer +{ + /// Pushes RynthAi's window colours; returns the count for PopStyleColor. + internal static int PushDashboardStyle() + { + // Muted slate-blue accents. TitleBgActive replaces ImGui's default yellow on detached windows. + ImGui.PushStyleColor(ImGuiCol.FrameBg, new Vector4(0.18f, 0.22f, 0.28f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, new Vector4(0.24f, 0.30f, 0.38f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.FrameBgActive, new Vector4(0.30f, 0.38f, 0.48f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.CheckMark, new Vector4(0.85f, 0.90f, 1.00f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.PopupBg, new Vector4(0.10f, 0.14f, 0.20f, 0.98f)); + ImGui.PushStyleColor(ImGuiCol.Header, new Vector4(0.20f, 0.28f, 0.36f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.HeaderHovered, new Vector4(0.26f, 0.36f, 0.46f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.HeaderActive, new Vector4(0.32f, 0.44f, 0.58f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.TitleBg, new Vector4(0.14f, 0.18f, 0.24f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.TitleBgActive, new Vector4(0.22f, 0.30f, 0.40f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, new Vector4(0.10f, 0.14f, 0.20f, 0.85f)); + return 11; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.NavEdit.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.NavEdit.cs new file mode 100644 index 0000000..be4ea07 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.NavEdit.cs @@ -0,0 +1,224 @@ +// LegacyDashboardRenderer.NavEdit.cs — route editor commands from the engine Nav panel: +// multi-select move / duplicate / delete, set active, move a step to the player, nearest, +// reverse, snap to path, pause / portal / point-at-selection steps, simplify, recording and +// trail -> route. +// +// Commands arrive with indices into the route the panel last saw. Structural edits go +// through NavRouteEditing.Apply (copy-on-write) so the nav engine never sees a half-edited list. +using System; +using System.Collections.Generic; + +namespace RynthCore.Plugin.RynthAi.LegacyUi; + +internal sealed partial class LegacyDashboardRenderer +{ + /// How long an edit's result stays in the Nav panel's status line. + private const long NavEditStatusMs = 8_000; + + /// Spot closer than this to an existing waypoint is refused by "Snap to path", yards. + private const double SnapMinGapYards = 0.5; + + /// Decal ObjectClass.Portal, as VTank writes it in Portal steps. + private const int PortalObjectClass = 14; + + private string _navEditStatus = string.Empty; + private long _navEditStatusAt; + + /// Breadcrumb trail (set by the plugin once the nav overlay exists; null before login). + internal NavBreadcrumbTracker? NavBreadcrumbs { get; set; } + + private List RoutePoints => _settings.CurrentRoute.Points; + + /// The last edit's result while it is fresh, else empty. + private string CurrentNavEditStatus() => + _navEditStatus.Length > 0 && Environment.TickCount64 - _navEditStatusAt < NavEditStatusMs ? _navEditStatus : string.Empty; + + private void SetNavEditStatus(string text) + { + _navEditStatus = text; + _navEditStatusAt = Environment.TickCount64; + RynthLog.Trace(LogCat.Navigation, "[NavEdit] " + text); + } + + private void HandleNavEditCommand(NavCommand cmd) + { + switch (cmd.Cmd) + { + case "movePoints": + { + var sel = PointsAt(cmd.Indices); + if (sel.Count == 0 || cmd.Delta == 0) return; + EditRoute(l => NavRouteEditing.Move(l, sel, Math.Sign(cmd.Delta))); + break; + } + case "duplicatePoints": + { + var sel = PointsAt(cmd.Indices); + if (sel.Count == 0) return; + var copies = new List(); + EditRoute(l => NavRouteEditing.Duplicate(l, sel, copies)); + SetNavEditStatus($"Duplicated {copies.Count} step(s)."); + break; + } + case "deletePoints": + { + var sel = PointsAt(cmd.Indices); + if (sel.Count == 0) return; + EditRoute(l => NavRouteEditing.Remove(l, sel)); + SetNavEditStatus($"Deleted {sel.Count} step(s)."); + break; + } + case "setActive": + if (cmd.Index < 0 || cmd.Index >= RoutePoints.Count) return; + _settings.ActiveNavIndex = cmd.Index; + SaveSettings(); + SetNavEditStatus($"Active waypoint: {cmd.Index}."); + break; + + case "movePointHere": + { + if (cmd.Index < 0 || cmd.Index >= RoutePoints.Count || !TryNavHere(out NavPoint here)) return; + NavPoint p = RoutePoints[cmd.Index]; + p.NS = here.NS; p.EW = here.EW; p.Z = here.Z; + _navigationUi.TryAutoSaveNav(); + SetNavEditStatus($"Step {cmd.Index} moved to your position."); + break; + } + case "nearestActive": + { + int i = FindNearestWaypoint(_settings.CurrentRoute); + if (RoutePoints.Count == 0) return; + _settings.ActiveNavIndex = i; + SaveSettings(); + SetNavEditStatus($"Active waypoint: {i} (nearest)."); + break; + } + case "reverseRoute": + if (RoutePoints.Count < 2) return; + EditRoute(NavRouteEditing.Reverse); + SetNavEditStatus("Route reversed."); + break; + + case "snapToPath": + { + if (!TryNavHere(out NavPoint here)) return; + NavPoint? inserted = null; + string error = string.Empty; + EditRoute(l => { NavRouteEditing.TrySnapInsert(l, here.NS, here.EW, SnapMinGapYards, out inserted, out error); return l; }); + SetNavEditStatus(inserted != null ? $"Inserted a point on the path at step {RoutePoints.IndexOf(inserted)}." : error); + break; + } + case "addPause": + { + if (!TryNavHere(out NavPoint p)) return; + p.Type = NavPointType.Pause; + p.PauseTimeMs = (int)(Math.Clamp(cmd.Seconds, 0.1, 600.0) * 1000); + InsertNavPoint(p, cmd.AddMode, cmd.InsertAt); + SetNavEditStatus($"Added a {p.PauseTimeMs / 1000.0:0.#} s pause."); + break; + } + case "addPortal": + { + if (!TryDescribeNavSelection(out string name, out double ons, out double oew, out double oz) || !TryNavHere(out NavPoint p)) return; + p.Type = NavPointType.PortalNPC; + p.TargetName = name; + p.ObjectClass = PortalObjectClass; + p.PortalExitNS = ons; p.PortalExitEW = oew; p.PortalExitZ = oz; + InsertNavPoint(p, cmd.AddMode, cmd.InsertAt); + SetNavEditStatus($"Added Portal step '{name}'."); + break; + } + case "addPointAtSelected": + { + if (!TryDescribeNavSelection(out string name, out double ns, out double ew, out double z)) return; + InsertNavPoint(new NavPoint { Type = NavPointType.Point, NS = ns, EW = ew, Z = z }, cmd.AddMode, cmd.InsertAt); + SetNavEditStatus($"Added a point at '{name}'."); + break; + } + case "simplifyRoute": + { + double tol = Math.Clamp(cmd.Yards, 0.2, 10.0); + int ai = _settings.ActiveNavIndex; + NavPoint? keep = ai >= 0 && ai < RoutePoints.Count ? RoutePoints[ai] : null; + int removed = 0; + EditRoute(l => { removed = NavRouteEditing.Simplify(l, tol, keep); return l; }); + SetNavEditStatus($"Simplify ({tol:0.#} yd) removed {removed} point(s)."); + break; + } + case "setRecording": + _settings.IsRecordingNav = cmd.On; + SetNavEditStatus(cmd.On ? "Recording: walk the route; points are added for you." : "Recording stopped."); + break; + + case "trailToRoute": + { + NavCrumb[] trail = NavBreadcrumbs?.Trail ?? Array.Empty(); + List pts = NavBreadcrumbTracker.TrailToPoints(trail, _settings.NavOverlay.RecordSpacingYards, cmd.Reverse); + if (pts.Count < 2) { SetNavEditStatus("The trail is too short to make a route."); return; } + _settings.IsRecordingNav = false; + // A new unsaved route: the loaded file on disk is not changed (Save As keeps it). + _settings.CurrentRoute = new NavRouteParser { RouteType = NavRouteType.Once, Points = pts }; + _settings.CurrentNavPath = string.Empty; + _settings.ActiveNavIndex = 0; + RefreshNavFiles(); + SaveSettings(); + SetNavEditStatus($"{(cmd.Reverse ? "Backtrack" : "Trail")} route created: {pts.Count} points (unsaved)."); + break; + } + } + } + + /// Copy-on-write route edit, then the route file autosave. + private void EditRoute(Func, List> edit) + { + NavRouteEditing.Apply(_settings, edit); + _navigationUi.TryAutoSaveNav(); + } + + /// The route's points at ; out-of-range indices are skipped. + private HashSet PointsAt(List? indices) + { + var sel = new HashSet(); + if (indices == null) return sel; + var pts = RoutePoints; + foreach (int i in indices) + if (i >= 0 && i < pts.Count) sel.Add(pts[i]); + return sel; + } + + /// A Point at the player's position (Z in nav units), or false when the position is unknown. + private bool TryNavHere(out NavPoint p) + { + p = new NavPoint(); + if (!NavCoordinateHelper.TryGetNavPosition(_host, out double ns, out double ew, out double z)) + { + SetNavEditStatus("Position unavailable."); + return false; + } + p.NS = ns; p.EW = ew; p.Z = z; + return true; + } + + /// Name and nav position of the selected world object. + private bool TryDescribeNavSelection(out string name, out double ns, out double ew, out double navZ) + { + name = string.Empty; ns = ew = navZ = 0; + if (!_host.HasGetSelectedItemId) { SetNavEditStatus("Selection unavailable."); return false; } + uint sel = _host.GetSelectedItemId(); + if (sel == 0) { SetNavEditStatus("Select an object first."); return false; } + if (!_host.HasGetObjectName || !_host.TryGetObjectName(sel, out name) || string.IsNullOrWhiteSpace(name)) + { + SetNavEditStatus("The selected object has no name yet."); + return false; + } + if (_host.HasGetObjectPosition + && _host.TryGetObjectPosition(sel, out uint cell, out float x, out float y, out float z) + && NavCoordinateHelper.TryConvertPoseToCoords(cell, x, y, out ns, out ew)) + { + navZ = z / NavCoordinateHelper.NavZScale; + return true; + } + SetNavEditStatus($"Could not read the position of '{name}'."); + return false; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs index 5b2ef62..9e7fe4c 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs @@ -7,12 +7,13 @@ using System.Numerics; using System.Text.Json; using RynthCore.PluginSdk; using RynthCore.Plugin.RynthAi; +using RynthCore.Plugin.RynthAi.Diagnostics; using RynthCore.Plugin.RynthAi.Meta; using RynthCore.Plugin.Shared; namespace RynthCore.Plugin.RynthAi.LegacyUi; -internal sealed class LegacyDashboardRenderer +internal sealed partial class LegacyDashboardRenderer { internal static readonly Vector4 ColTeal = new(0.15f, 0.85f, 0.90f, 1.00f); internal static readonly Vector4 ColAmber = new(0.91f, 0.70f, 0.20f, 1.00f); @@ -53,7 +54,8 @@ internal sealed class LegacyDashboardRenderer private readonly List _navFiles = new(); private readonly List _lootFiles = new(); private readonly List _metaFiles = new(); - // Guards the four profile-name lists above against the cross-thread race + private readonly List _buffFiles = new(); + // Guards the profile-name lists above against the cross-thread race // between BuildSnapshotJson (Avalonia panel poll thread, ~30 Hz) and the // Refresh*Files mutators (AC pump thread). Enumerating a List while // another thread Clear()s it throws InvalidOperationException; when that @@ -297,6 +299,7 @@ internal sealed class LegacyDashboardRenderer public void SetMissileCraftingManager(MissileCraftingManager mgr) => _advancedSettingsUi.SetMissileCraftingManager(mgr); public void SetAutoVendorStatusProvider(Func status) => _advancedSettingsUi.SetAutoVendorStatusProvider(status); + public void SetBuffActions(Action? force, Action? cancel, Func? skips) => _advancedSettingsUi.SetBuffActions(force, cancel, skips); public void SetAutoTradeStatusProvider(Func status) => _advancedSettingsUi.SetAutoTradeStatusProvider(status); // The open vendor's AutoVendor profile path (null when no vendor is open), for the @@ -408,8 +411,7 @@ internal sealed class LegacyDashboardRenderer { _settings.CurrentRoute = NavRouteParser.Load(_settings.CurrentNavPath); _settings.ActiveNavIndex = - (_settings.CurrentRoute.RouteType == NavRouteType.Follow || - _settings.CurrentRoute.RouteType == NavRouteType.Once) + NavRouteParser.StartsAtFirstPoint(_settings.CurrentRoute.RouteType, _settings.NavResumeNearest) ? 0 : FindNearestWaypoint(_settings.CurrentRoute); } @@ -467,28 +469,48 @@ internal sealed class LegacyDashboardRenderer public void SaveSettings() { if (string.IsNullOrEmpty(_settingsFilePath)) return; + string json; try { CaptureTransientUiState(); - Directory.CreateDirectory(Path.GetDirectoryName(_settingsFilePath)!); - string json = JsonSerializer.Serialize(_settings, RynthAiJsonContext.Default.LegacyUiSettings); - File.WriteAllText(_settingsFilePath, json); + json = JsonSerializer.Serialize(_settings, RynthAiJsonContext.Default.LegacyUiSettings); + } + catch { return; } + if (WriteSettingsFile(_settingsFilePath, json)) + { _lastSavedJson = json; WriteActiveProfile(_settings.SelectedProfile); } - catch { } } + /// + /// Writes a settings profile. A failure (folder not writable, file read-only or in use) + /// is reported in chat once per folder and logged (DataWriteGuard); it used to be + /// swallowed, so settings that never reached the disk looked saved (2026-10-13). + /// + private static bool WriteSettingsFile(string path, string json, out string reason, bool callerShows = false) => + DataWriteGuard.TrySave("the settings profile", path, () => + { + Directory.CreateDirectory(Path.GetDirectoryName(path)!); + File.WriteAllText(path, json); + }, out reason, callerShows); + + private static bool WriteSettingsFile(string path, string json) => WriteSettingsFile(path, json, out _); + + /// After a failed autosave, when CheckAndSave may try again (not every tick). + private long _autosaveRetryAt; + internal const long AutosaveRetryMs = 10_000; + public string SaveAsProfile(string name) { if (string.IsNullOrEmpty(_charFolder)) return "Not logged in."; try { CaptureTransientUiState(); - Directory.CreateDirectory(_charFolder); string json = JsonSerializer.Serialize(_settings, RynthAiJsonContext.Default.LegacyUiSettings); string path = GetProfileFilePath(name); - File.WriteAllText(path, json); + if (!WriteSettingsFile(path, json, out string reason, callerShows: true)) + return $"Couldn't save profile '{name}' to {path}: {reason}"; _settings.SelectedProfile = name; _settingsFilePath = path; _lastSavedJson = json; @@ -521,19 +543,25 @@ internal sealed class LegacyDashboardRenderer private void CheckAndSave() { if (string.IsNullOrEmpty(_settingsFilePath)) return; + if (_autosaveRetryAt != 0 && Environment.TickCount64 < _autosaveRetryAt) return; + string json; try { CaptureTransientUiState(); - string json = JsonSerializer.Serialize(_settings, RynthAiJsonContext.Default.LegacyUiSettings); - if (json != _lastSavedJson) - { - Directory.CreateDirectory(Path.GetDirectoryName(_settingsFilePath)!); - File.WriteAllText(_settingsFilePath, json); - _lastSavedJson = json; - WriteActiveProfile(_settings.SelectedProfile); - } + json = JsonSerializer.Serialize(_settings, RynthAiJsonContext.Default.LegacyUiSettings); + } + catch { return; } + if (json == _lastSavedJson) return; + if (WriteSettingsFile(_settingsFilePath, json)) + { + _autosaveRetryAt = 0; + _lastSavedJson = json; + WriteActiveProfile(_settings.SelectedProfile); + } + else + { + _autosaveRetryAt = Environment.TickCount64 + AutosaveRetryMs; // not a failing write every tick } - catch { } } // ── Profile items from the pack ────────────────────────────────────────── @@ -599,6 +627,28 @@ internal sealed class LegacyDashboardRenderer return $"[RynthAi] Added {w} weapon(s) and {c} consumable(s) from your pack."; } + /// + /// /ra items clean and the Items panel's Remove Missing button: drops weapons and + /// consumables whose item is no longer in the pack (sold, dropped, used up, traded), + /// re-pointing an entry at an unlisted item of the same name when there is one. + /// Refuses while the inventory is still arriving, so a half-loaded pack can't empty the lists. + /// + public string CleanMissingItems(WorldObjectCache? cache, uint playerId) + { + if (cache == null || playerId == 0) return "[RynthAi] Not logged in."; + if (_packSetup != PackSetup.None) return "[RynthAi] Your inventory is still loading - try again in a few seconds."; + var inv = cache.GetDirectInventory(forceRefresh: true).ToList(); + if (inv.Count == 0) return "[RynthAi] Your inventory hasn't loaded yet - nothing was removed."; + + var (removed, relinked) = _weaponsUi.CleanMissing(inv); + if (removed.Count == 0 && relinked.Count == 0) return "[RynthAi] Items: everything listed is still in your inventory."; + SaveSettings(); + string msg = $"[RynthAi] Items: removed {removed.Count} no longer in your inventory"; + if (removed.Count > 0) msg += $" ({string.Join(", ", removed)})"; + if (relinked.Count > 0) msg += $"; re-pointed {relinked.Count} at another item of the same name ({string.Join(", ", relinked)})"; + return msg + "."; + } + // ── Per-server profile folders ─────────────────────────────────────────── private string ResolveServerFolder() @@ -772,9 +822,12 @@ internal sealed class LegacyDashboardRenderer _monsterWatcher.EnableRaisingEvents = false; } - Directory.CreateDirectory(_monstersFolder); string json = JsonSerializer.Serialize(_settings.MonsterRules, RynthAiJsonContext.Default.MonsterRuleList); - File.WriteAllText(path, json); + DataWriteGuard.TrySave("the monster rules", path, () => + { + Directory.CreateDirectory(_monstersFolder); + File.WriteAllText(path, json); + }); if (_monsterWatcher != null) _monsterWatcher.EnableRaisingEvents = wasEnabled; @@ -950,6 +1003,9 @@ internal sealed class LegacyDashboardRenderer StartMacroOnLogin = s.StartMacroOnLogin, PatrolOnLogin = s.PatrolOnLogin, YieldToVTank = s.YieldToVTank, + FeatureServerNames = IltHub.ServerFeatureGate.FormatList(s.FeatureServerNames), + ForceServerFeatures = s.ForceServerFeatures, + ServerFeaturesStatus = IltHub.ServerFeatureGate.Describe(s), EnableRaycasting = s.EnableRaycasting, UseArcs = s.UseArcs, BowArcVelocity = s.BowArcVelocity, @@ -976,6 +1032,9 @@ internal sealed class LegacyDashboardRenderer StaminaToHealthAt = s.StaminaToHealthAt, StaminaToHealthMinStamina = s.StaminaToHealthMinStamina, StopMacroOnDeath = s.StopMacroOnDeath, + DeathRecallMode = s.DeathRecallMode, + DeathRecallSpellId = s.DeathRecallSpellId, + DeathRecallItem = s.DeathRecallItem, StopMacroOnNoComponents = s.StopMacroOnNoComponents, StopLootingWhenPackFull = s.StopLootingWhenPackFull, StopMacroWhenPackFull = s.StopMacroWhenPackFull, @@ -1033,6 +1092,7 @@ internal sealed class LegacyDashboardRenderer ShowTerrainPassability = s.ShowTerrainPassability, NavLabelMode = NavLabelModes.Clamp(s.NavLabelMode), NavGuideLine = s.NavGuideLine, + NavResumeNearest = s.NavResumeNearest, OpenDoors = s.OpenDoors, OpenDoorRange = s.OpenDoorRange, AutoUnlockDoors = s.AutoUnlockDoors, @@ -1046,6 +1106,11 @@ internal sealed class LegacyDashboardRenderer NavTurnRateDegPerSec = s.NavTurnRateDegPerSec, NavTier1TurnSpeed = s.NavTier1TurnSpeed, PostPortalDelaySec = s.PostPortalDelaySec, + DunPatrolCoverage = s.DunPatrolCoverage, + DunPatrolSkipDeadEnds = s.DunPatrolSkipDeadEnds, + DunPatrolAvoidFloors = s.DunPatrolAvoidFloors, + DunPatrolWallDistance = s.DunPatrolWallDistance, + DunPatrolLookInSize = s.DunPatrolLookInSize, T2Speed = s.T2Speed, T2WalkWithinYd = s.T2WalkWithinYd, T2DistanceTo = s.T2DistanceTo, @@ -1058,6 +1123,7 @@ internal sealed class LegacyDashboardRenderer RebuffSecondsRemaining = s.RebuffSecondsRemaining, RebuffTopOffSecondsRemaining = s.RebuffTopOffSecondsRemaining, CastBuffsOverItemBuffs = s.CastBuffsOverItemBuffs, + SkipUnusableBuffs = s.SkipUnusableBuffs, DisabledBuffs = new List(s.DisabledBuffs), BuffMinSkillLevelTier1 = s.BuffMinSkillLevelTier1, BuffMinSkillLevelTier2 = s.BuffMinSkillLevelTier2, @@ -1082,11 +1148,12 @@ internal sealed class LegacyDashboardRenderer LootOwnCorpse = s.LootOwnCorpse, EscapeHazards = s.EscapeHazards, TravelToOwnCorpse = s.TravelToOwnCorpse, - ItemInfoOnSelect = s.ItemInfoOnSelect, + ItemInfoOnSelect = s.ItemInfoSettings.OnSelect, EnableAutostack = s.EnableAutostack, ReadUnknownScrolls = s.ReadUnknownScrolls, EnableCombineSalvage = s.EnableCombineSalvage, CombineBagsDuringSalvage = s.CombineBagsDuringSalvage, + SalvageWithoutPanel = s.SalvageWithoutPanel, LootInterItemDelayMs = s.LootInterItemDelayMs, LootContentSettleMs = s.LootContentSettleMs, LootEmptyCorpseMs = s.LootEmptyCorpseMs, @@ -1114,6 +1181,12 @@ internal sealed class LegacyDashboardRenderer AutoVendorTriesTime = s.AutoVendorTriesTime, OffhandDefault = s.OffhandDefault, PreferDualWield = s.PreferDualWield, + EnableGroundLoot = s.EnableGroundLoot, + // Diagnostics (per PC, RynthLog) + DiagDebugToChat = RynthLog.DebugToChat, + DiagFileLogAll = RynthLog.FileLogAll, + DiagCategories = RynthLog.FormatCategoryLevels(), + DiagFolder = RynthLog.Directory, }; return JsonSerializer.Serialize(payload, RynthAiJsonContext.Default.SettingsBridgePayload); } @@ -1162,6 +1235,9 @@ internal sealed class LegacyDashboardRenderer s.StartMacroOnLogin = p.StartMacroOnLogin; s.PatrolOnLogin = p.PatrolOnLogin; s.YieldToVTank = p.YieldToVTank; + if (p.FeatureServerNames != null) + s.FeatureServerNames = IltHub.ServerFeatureGate.ParseList(p.FeatureServerNames); + s.ForceServerFeatures = p.ForceServerFeatures; s.EnableRaycasting = p.EnableRaycasting; s.UseArcs = p.UseArcs; s.BowArcVelocity = p.BowArcVelocity; @@ -1190,6 +1266,10 @@ internal sealed class LegacyDashboardRenderer s.StaminaToHealthAt = Math.Clamp(p.StaminaToHealthAt, 0, 100); s.StaminaToHealthMinStamina = Math.Clamp(p.StaminaToHealthMinStamina, 0, 100); s.StopMacroOnDeath = p.StopMacroOnDeath; + // Absent (older engine) = unchanged. + if (p.DeathRecallMode is int recallMode) s.DeathRecallMode = Math.Clamp(recallMode, 0, 2); + if (p.DeathRecallSpellId is int recallSpell && recallSpell > 0) s.DeathRecallSpellId = recallSpell; + if (p.DeathRecallItem is string recallItem) s.DeathRecallItem = recallItem.Trim(); s.StopMacroOnNoComponents = p.StopMacroOnNoComponents; s.StopLootingWhenPackFull = p.StopLootingWhenPackFull; s.StopMacroWhenPackFull = p.StopMacroWhenPackFull; @@ -1247,6 +1327,7 @@ internal sealed class LegacyDashboardRenderer s.ShowTerrainPassability = p.ShowTerrainPassability; if (p.NavLabelMode >= 0) s.NavLabelMode = NavLabelModes.Clamp(p.NavLabelMode); if (p.NavGuideLine is bool guideLine) s.NavGuideLine = guideLine; + if (p.NavResumeNearest is bool resumeNearest) s.NavResumeNearest = resumeNearest; // absent = unchanged s.OpenDoors = p.OpenDoors; s.OpenDoorRange = p.OpenDoorRange; s.AutoUnlockDoors = p.AutoUnlockDoors; @@ -1260,6 +1341,12 @@ internal sealed class LegacyDashboardRenderer s.NavTurnRateDegPerSec = p.NavTurnRateDegPerSec; s.NavTier1TurnSpeed = p.NavTier1TurnSpeed; s.PostPortalDelaySec = p.PostPortalDelaySec; + // Dungeon patrol: absent (an older engine) = unchanged. + if (p.DunPatrolCoverage is int patrolCoverage) s.DunPatrolCoverage = Math.Clamp(patrolCoverage, 0, 2); + if (p.DunPatrolSkipDeadEnds is int patrolSpurs) s.DunPatrolSkipDeadEnds = Math.Clamp(patrolSpurs, DungeonPatrolOptions.MaxDeadEndCellsMin, DungeonPatrolOptions.MaxDeadEndCellsMax); + if (p.DunPatrolAvoidFloors is bool patrolFloors) s.DunPatrolAvoidFloors = patrolFloors; + if (p.DunPatrolWallDistance is float patrolWalls) s.DunPatrolWallDistance = (float)Math.Clamp(patrolWalls, DungeonPatrolOptions.WallClearanceMin, DungeonPatrolOptions.WallClearanceMax); + if (p.DunPatrolLookInSize is float patrolLookIn) s.DunPatrolLookInSize = (float)Math.Clamp(patrolLookIn, DungeonPatrolOptions.LookInRoomMin, DungeonPatrolOptions.LookInRoomMax); s.T2Speed = p.T2Speed; s.T2WalkWithinYd = p.T2WalkWithinYd; s.T2DistanceTo = p.T2DistanceTo; @@ -1272,6 +1359,7 @@ internal sealed class LegacyDashboardRenderer s.RebuffSecondsRemaining = p.RebuffSecondsRemaining; if (p.RebuffTopOffSecondsRemaining > 0) s.RebuffTopOffSecondsRemaining = p.RebuffTopOffSecondsRemaining; if (p.CastBuffsOverItemBuffs is bool castOverItems) s.CastBuffsOverItemBuffs = castOverItems; // absent = unchanged + if (p.SkipUnusableBuffs is bool skipUnusable) s.SkipUnusableBuffs = skipUnusable; // absent = unchanged if (p.DisabledBuffs is { } disabledBuffs) s.DisabledBuffs = new List(disabledBuffs); // absent = unchanged s.BuffMinSkillLevelTier1 = p.BuffMinSkillLevelTier1; s.BuffMinSkillLevelTier2 = p.BuffMinSkillLevelTier2; @@ -1293,11 +1381,12 @@ internal sealed class LegacyDashboardRenderer if (p.EscapeHazards is bool escape) s.EscapeHazards = escape; // absent = unchanged if (p.LootOwnCorpse is bool lootOwn) s.LootOwnCorpse = lootOwn; // absent = unchanged if (p.TravelToOwnCorpse is bool travelOwn) s.TravelToOwnCorpse = travelOwn; // absent = unchanged - if (p.ItemInfoOnSelect is bool infoOnSelect) s.ItemInfoOnSelect = infoOnSelect; // absent = unchanged + if (p.ItemInfoOnSelect is bool infoOnSelect) s.ItemInfoSettings.OnSelect = infoOnSelect; // absent = unchanged s.EnableAutostack = p.EnableAutostack; s.ReadUnknownScrolls = p.ReadUnknownScrolls; s.EnableCombineSalvage = p.EnableCombineSalvage; s.CombineBagsDuringSalvage = p.CombineBagsDuringSalvage; + if (p.SalvageWithoutPanel is bool salvNoPanel) s.SalvageWithoutPanel = salvNoPanel; // absent = unchanged s.LootInterItemDelayMs = p.LootInterItemDelayMs; s.LootContentSettleMs = p.LootContentSettleMs; s.LootEmptyCorpseMs = p.LootEmptyCorpseMs; @@ -1326,6 +1415,11 @@ internal sealed class LegacyDashboardRenderer // Off hand: only fields the sender actually included (the engine face doesn't draw them yet) if (p.OffhandDefault is string od && OffhandRules.TryParse(od, out var odMode)) s.OffhandDefault = OffhandRules.SettingValue(odMode); if (p.PreferDualWield is bool pdw) s.PreferDualWield = pdw; + s.EnableGroundLoot = p.EnableGroundLoot; + // Diagnostics: each setter rewrites diagnostics.json, so only touch what changed. + if (p.DiagDebugToChat != RynthLog.DebugToChat) RynthLog.DebugToChat = p.DiagDebugToChat; + if (p.DiagFileLogAll != RynthLog.FileLogAll) RynthLog.FileLogAll = p.DiagFileLogAll; + RynthLog.ApplyCategoryLevels(p.DiagCategories); SaveSettings(); } catch { } @@ -1498,12 +1592,11 @@ internal sealed class LegacyDashboardRenderer { string markerPath = GetActiveProfileMarkerPath(); if (string.IsNullOrEmpty(markerPath)) return; - try + DataWriteGuard.TrySave("the active-profile marker", markerPath, () => { Directory.CreateDirectory(_charFolder); File.WriteAllText(markerPath, profileName); - } - catch { } + }); } private void SwitchProfile(string newProfile) @@ -1551,8 +1644,7 @@ internal sealed class LegacyDashboardRenderer { _settings.CurrentRoute = NavRouteParser.Load(_settings.CurrentNavPath); _settings.ActiveNavIndex = - (_settings.CurrentRoute.RouteType == NavRouteType.Follow || - _settings.CurrentRoute.RouteType == NavRouteType.Once) + NavRouteParser.StartsAtFirstPoint(_settings.CurrentRoute.RouteType, _settings.NavResumeNearest) ? 0 : FindNearestWaypoint(_settings.CurrentRoute); } @@ -1604,8 +1696,14 @@ internal sealed class LegacyDashboardRenderer dst.NavTier1TurnSpeed = tmp.NavTier1TurnSpeed; dst.PostPortalDelaySec = tmp.PostPortalDelaySec; dst.NavRecoveryEnabled = tmp.NavRecoveryEnabled; + dst.NavResumeNearest = tmp.NavResumeNearest; dst.NavOffTrackYards = Math.Max(160f, tmp.NavOffTrackYards); dst.NavMaxDetourAttempts = Math.Clamp(tmp.NavMaxDetourAttempts, 1, 10); + dst.DunPatrolCoverage = tmp.DunPatrolCoverage; + dst.DunPatrolSkipDeadEnds = tmp.DunPatrolSkipDeadEnds; + dst.DunPatrolAvoidFloors = tmp.DunPatrolAvoidFloors; + dst.DunPatrolWallDistance = tmp.DunPatrolWallDistance; + dst.DunPatrolLookInSize = tmp.DunPatrolLookInSize; dst.T2Speed = tmp.T2Speed; dst.T2DistanceTo = tmp.T2DistanceTo; dst.T2ReissueMs = tmp.T2ReissueMs; @@ -1619,12 +1717,22 @@ internal sealed class LegacyDashboardRenderer dst.NavProfileIdx = tmp.NavProfileIdx; dst.LootProfileIdx = tmp.LootProfileIdx; dst.MetaProfileIdx = tmp.MetaProfileIdx; + dst.CurrentBuffProfilePath = tmp.CurrentBuffProfilePath ?? string.Empty; + dst.BuffProfileIdx = tmp.BuffProfileIdx; + dst.ShowSpellsWindow = tmp.ShowSpellsWindow; dst.EnableAutostack = tmp.EnableAutostack; dst.EnableAutocram = tmp.EnableAutocram; dst.ReadUnknownScrolls = tmp.ReadUnknownScrolls; dst.EnableCombineSalvage = tmp.EnableCombineSalvage; dst.CombineBagsDuringSalvage = tmp.CombineBagsDuringSalvage; + dst.SalvageWithoutPanel = tmp.SalvageWithoutPanel; dst.ShowTargetStaminaMana = tmp.ShowTargetStaminaMana; + // Item info (/ra iteminfo, "Describe items when selected") and the nav overlay are whole + // option objects; a hand-edited profile can carry null or out-of-range values. + dst.ItemInfoSettings = tmp.ItemInfoSettings ?? new(); + dst.ItemInfoSettings.Sanitize(); + dst.NavOverlay = tmp.NavOverlay ?? new(); + dst.NavOverlay.Sanitize(); dst.EnableMissileCrafting = tmp.EnableMissileCrafting; dst.MissileCraftAmmoThreshold= tmp.MissileCraftAmmoThreshold; dst.LootInterItemDelayMs = tmp.LootInterItemDelayMs; @@ -1659,6 +1767,9 @@ internal sealed class LegacyDashboardRenderer dst.StaminaToHealthAt = tmp.StaminaToHealthAt; dst.StaminaToHealthMinStamina= tmp.StaminaToHealthMinStamina; dst.StopMacroOnDeath = tmp.StopMacroOnDeath; + dst.DeathRecallMode = Math.Clamp(tmp.DeathRecallMode, 0, 2); + dst.DeathRecallSpellId = tmp.DeathRecallSpellId > 0 ? tmp.DeathRecallSpellId : 48; + dst.DeathRecallItem = tmp.DeathRecallItem ?? string.Empty; dst.StopMacroOnNoComponents = tmp.StopMacroOnNoComponents; dst.StopLootingWhenPackFull = tmp.StopLootingWhenPackFull; dst.StopMacroWhenPackFull = tmp.StopMacroWhenPackFull; @@ -1706,13 +1817,15 @@ internal sealed class LegacyDashboardRenderer dst.LootOwnCorpse = tmp.LootOwnCorpse; dst.EscapeHazards = tmp.EscapeHazards; dst.TravelToOwnCorpse = tmp.TravelToOwnCorpse; - dst.ItemInfoOnSelect = tmp.ItemInfoOnSelect; dst.LootOnlyRareCorpses = tmp.LootOnlyRareCorpses; + dst.EnableGroundLoot = tmp.EnableGroundLoot; dst.PeaceModeWhenIdle = tmp.PeaceModeWhenIdle; dst.RebuffWhenIdle = tmp.RebuffWhenIdle; dst.RebuffSecondsRemaining = tmp.RebuffSecondsRemaining; dst.RebuffTopOffSecondsRemaining = tmp.RebuffTopOffSecondsRemaining; dst.CastBuffsOverItemBuffs = tmp.CastBuffsOverItemBuffs; + dst.FastBuffChain = tmp.FastBuffChain; + dst.SkipUnusableBuffs = tmp.SkipUnusableBuffs; dst.DisabledBuffs = tmp.DisabledBuffs; dst.BlacklistAttempts = tmp.BlacklistAttempts; dst.BlacklistTimeoutSec = tmp.BlacklistTimeoutSec; @@ -1743,6 +1856,7 @@ internal sealed class LegacyDashboardRenderer dst.MonsterRules = tmp.MonsterRules; dst.MonsterNameBlacklist = tmp.MonsterNameBlacklist ?? new(); dst.ItemRules = tmp.ItemRules; + dst.AmmoRules = tmp.AmmoRules ?? new(); dst.ConsumableRules = tmp.ConsumableRules; dst.BuffRules = tmp.BuffRules; dst.MetaRules = tmp.MetaRules; @@ -1810,12 +1924,17 @@ internal sealed class LegacyDashboardRenderer dst.StartMacroOnLogin = tmp.StartMacroOnLogin; dst.PatrolOnLogin = tmp.PatrolOnLogin; dst.YieldToVTank = tmp.YieldToVTank; + dst.FeatureServerNames = tmp.FeatureServerNames ?? new(IltHub.ServerFeatureGate.DefaultServerNames); + dst.ForceServerFeatures = tmp.ForceServerFeatures; dst.ShowTerrainPassability = tmp.ShowTerrainPassability; dst.NavLabelMode = NavLabelModes.Clamp(tmp.NavLabelMode); dst.NavGuideLine = tmp.NavGuideLine; dst.GiveQueueIntervalMs = tmp.GiveQueueIntervalMs; dst.T11ItemAugsOverride = tmp.T11ItemAugsOverride; dst.SpellCastIntervalMs = tmp.SpellCastIntervalMs; + dst.StuckCastBreakMs = tmp.StuckCastBreakMs; + dst.RecoveryRetryMs = tmp.RecoveryRetryMs; + dst.HpFailsafeRecall = tmp.HpFailsafeRecall; dst.AttackSpellIntervalMs = tmp.AttackSpellIntervalMs; dst.EmbeddedNavs = tmp.EmbeddedNavs; dst.SuppressRetailRadar = tmp.SuppressRetailRadar; @@ -1871,7 +1990,8 @@ internal sealed class LegacyDashboardRenderer _targetMana = 0; _targetMaxMana = 0; _targetHealthDisplay = targetId == 0 ? "0" : "--"; - if (targetId != 0 && _host.HasQueryHealth) _host.QueryHealth(targetId); + // No health query here: RynthAiPlugin.OnSelectedTargetChange sends the one guarded + // query (creatures only); this ran on every corpse and item the engine selects. } public void OnUpdateHealth(uint targetId, float healthRatio, uint currentHealth, uint maxHealth) @@ -2095,6 +2215,40 @@ internal sealed class LegacyDashboardRenderer RefreshNavFiles(); RefreshLootFiles(); RefreshMetaFiles(); + RefreshBuffProfileFiles(); + } + + /// + /// Buff profile list for Loaded Files (Buffs): "Built-in" first (buffing's own list), then + /// every BuffProfiles\*.json. Re-selects the saved path; a missing file falls back to Built-in. + /// Public so the Spells window can refresh it after saving or deleting a profile. + /// + public void RefreshBuffProfileFiles() + { + var list = new List { BuiltInBuffProfileLabel }; + int idx = 0; + foreach (string file in BuffProfileStore.ListFileNames()) + { + list.Add(file); + if (Path.Combine(BuffProfileStore.Folder, file).Equals(_settings.CurrentBuffProfilePath, StringComparison.OrdinalIgnoreCase)) + idx = list.Count - 1; + } + lock (_profileListsLock) { _buffFiles.Clear(); _buffFiles.AddRange(list); } + _settings.BuffProfileIdx = idx; + } + + /// Label of the first Buffs entry: no profile, buffing uses its built-in list. + public const string BuiltInBuffProfileLabel = "Built-in"; + + /// + /// Makes the buff profile buffing uses (empty = built-in list) and saves + /// the settings. BuffManager notices the path change on its next tick. + /// + public void SetActiveBuffProfile(string path) + { + _settings.CurrentBuffProfilePath = path ?? string.Empty; + RefreshBuffProfileFiles(); + SaveSettings(); } private void RefreshProfilesList() @@ -2338,10 +2492,10 @@ internal sealed class LegacyDashboardRenderer _host.WriteToChat($"[RynthAi] {_settings.CurrentRoute.LoadWarning}", 4); } // Follow and Once routes start from the top so opening Recall/Portal/Chat - // actions always fire. Circular and Linear routes jump in at the nearest point. + // actions always fire. Circular and Linear routes jump in at the nearest point + // (unless NavResumeNearest is off). _settings.ActiveNavIndex = - (_settings.CurrentRoute.RouteType == NavRouteType.Follow || - _settings.CurrentRoute.RouteType == NavRouteType.Once) + NavRouteParser.StartsAtFirstPoint(_settings.CurrentRoute.RouteType, _settings.NavResumeNearest) ? 0 : FindNearestWaypoint(_settings.CurrentRoute); SaveSettings(); @@ -2394,6 +2548,13 @@ internal sealed class LegacyDashboardRenderer ActiveNavIndex = _settings.ActiveNavIndex, NavFiles = new List(_navFiles), Points = points, + MapEdit = NavMapEdit.Version, + TrackBreadcrumbs = _settings.NavOverlay.TrackBreadcrumbs, + ShowRouteOverlay = _settings.NavOverlay.ShowRouteMarkers, + IsRecording = _settings.IsRecordingNav, + TrailPoints = NavBreadcrumbs?.Trail.Length ?? 0, + TrailYards = NavBreadcrumbs?.TrailYards ?? 0, + EditStatus = CurrentNavEditStatus(), }; return JsonSerializer.Serialize(payload, RynthAiJsonContext.Default.NavBridgePayload); } @@ -2423,6 +2584,18 @@ internal sealed class LegacyDashboardRenderer SaveSettings(); break; + case "setBreadcrumbs": + // Nav panel "Breadcrumbs": record (and draw) the walked trail. + _settings.NavOverlay.TrackBreadcrumbs = cmd.On; + SaveSettings(); + break; + + case "setRouteOverlay": + // Nav panel "Route overlay": route rings / lines, waypoint labels, guide line. + _settings.NavOverlay.ShowRouteMarkers = cmd.On; + SaveSettings(); + break; + case "addWaypoint": _host.SetMotionBy("UI", 0x6500000D, false); // stop TurnRight _host.SetMotionBy("UI", 0x6500000E, false); // stop TurnLeft @@ -2499,6 +2672,36 @@ internal sealed class LegacyDashboardRenderer int ni = _navFiles.IndexOf(cmd.NavName); if (ni >= 0) { _selectedNavIdx = ni; LoadSelectedNav(); SaveSettings(); } break; + + default: + // Route editor commands (multi-select edits, pause / portal steps, trail -> route). + HandleNavEditCommand(cmd); + break; + } + } + catch { } + } + + /// + /// The Dungeon Map's route edits (addPointAt / movePointTo / setActive, see NavMapEdit), + /// dispatched from RynthPluginSendNavCommand. Same thread and save path as HandleNavCommand. + /// + public void HandleMapNavCommand(NavCommand cmd) + { + try + { + switch (NavMapEdit.Apply(_settings, cmd, out string status)) + { + case NavMapEdit.Result.RouteChanged: _navigationUi.TryAutoSaveNav(); break; + case NavMapEdit.Result.ActiveChanged: SaveSettings(); break; + } + // "setActive" is shared with the Nav panel's route editor (HandleNavEditCommand): + // same effect (ActiveNavIndex + settings save), and the result goes to the Nav + // panel's status line either way. + if (status.Length > 0) + { + SetNavEditStatus(status); + _host.Log($"[RynthAi] Map route edit: {status}"); } } catch { } @@ -2559,18 +2762,23 @@ internal sealed class LegacyDashboardRenderer // while a Refresh*Files mutator Clear()s it on the pump thread — that // race threw InvalidOperationException and, escaping this snapshot // poll's reverse-P/Invoke boundary, fail-fasted the NativeAOT runtime. - List profilesCopy, navCopy, lootCopy, metaCopy; + List profilesCopy, navCopy, lootCopy, metaCopy, buffCopy; lock (_profileListsLock) { profilesCopy = new List(_profiles); navCopy = new List(_navFiles); lootCopy = new List(_lootFiles); metaCopy = new List(_metaFiles); + buffCopy = new List(_buffFiles); } AppendStringArray(sb, "profiles", profilesCopy); sb.Append(','); AppendStringArray(sb, "navProfiles", navCopy); sb.Append(','); AppendStringArray(sb, "lootProfiles", lootCopy); sb.Append(','); AppendStringArray(sb, "metaProfiles", metaCopy); sb.Append(','); + AppendStringArray(sb, "buffProfiles", buffCopy); sb.Append(','); + AppendString(sb, "currentBuffName", + string.IsNullOrEmpty(_settings.CurrentBuffProfilePath) ? BuiltInBuffProfileLabel : Path.GetFileNameWithoutExtension(_settings.CurrentBuffProfilePath)); sb.Append(','); + AppendInt(sb, "selectedBuffIdx", _settings.BuffProfileIdx); sb.Append(','); AppendString(sb, "currentNavName", string.IsNullOrEmpty(_settings.CurrentNavPath) ? "None" : Path.GetFileNameWithoutExtension(_settings.CurrentNavPath)); sb.Append(','); AppendString(sb, "currentLootName", @@ -2704,7 +2912,7 @@ internal sealed class LegacyDashboardRenderer } /// - /// Profile kinds: 0 = nav, 1 = loot, 2 = meta, 3 = settings profile. + /// Profile kinds: 0 = nav, 1 = loot, 2 = meta, 3 = settings profile, 4 = buff profile. /// Index is into the matching list returned in BuildSnapshotJson. /// public void SelectProfileAtIndex(int kind, int index) @@ -2715,7 +2923,7 @@ internal sealed class LegacyDashboardRenderer // AddRange() on the pump thread — a torn read or // ArgumentOutOfRangeException. Snapshot the one list this call needs // under _profileListsLock first, mirroring BuildSnapshotJson. - string? navFile = null, lootFile = null, metaFile = null, profileName = null; + string? navFile = null, lootFile = null, metaFile = null, profileName = null, buffFile = null; lock (_profileListsLock) { switch (kind) @@ -2724,6 +2932,7 @@ internal sealed class LegacyDashboardRenderer case 1: if (index >= 0 && index < _lootFiles.Count) lootFile = _lootFiles[index]; break; case 2: if (index >= 0 && index < _metaFiles.Count) metaFile = _metaFiles[index]; break; case 3: if (index >= 0 && index < _profiles.Count) profileName = _profiles[index]; break; + case 4: if (index >= 0 && index < _buffFiles.Count) buffFile = _buffFiles[index]; break; } } @@ -2752,6 +2961,10 @@ internal sealed class LegacyDashboardRenderer case 3: if (profileName != null) SwitchProfile(profileName); break; + case 4: + if (buffFile != null) + SetActiveBuffProfile(index == 0 ? string.Empty : Path.Combine(BuffProfileStore.Folder, buffFile)); + break; } } @@ -3039,9 +3252,21 @@ internal sealed class LegacyDashboardRenderer case "save_file": if (!string.IsNullOrEmpty(cmd.Path)) { - AfFileWriter.Save(cmd.Path, _settings.MetaRules, _settings.EmbeddedNavs); - _settings.CurrentMetaPath = cmd.Path; - SaveSettings(); + string savePath = cmd.Path; + bool saved; + string why; + lock (_settings.MetaRulesLock) + saved = DataWriteGuard.TrySave("the meta", savePath, + () => AfFileWriter.Save(savePath, _settings.MetaRules, _settings.EmbeddedNavs), out why, callerShows: true); + if (saved) + { + _settings.CurrentMetaPath = savePath; + SaveSettings(); + } + else + { + ReportMetaApply(false, $"Meta not saved to {savePath}: {why}"); + } } break; @@ -3167,7 +3392,7 @@ internal sealed class LegacyDashboardRenderer _host.WriteToChat($"[RynthAi] Converted .met → {System.IO.Path.GetFileName(path)} for editing (original .met left untouched).", 1); } lock (_settings.MetaRulesLock) - AfFileWriter.Save(path, _settings.MetaRules, _settings.EmbeddedNavs); + DataWriteGuard.TrySave("the meta", path, () => AfFileWriter.Save(path, _settings.MetaRules, _settings.EmbeddedNavs)); } catch { } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyItemInfoUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyItemInfoUi.cs new file mode 100644 index 0000000..374c4d4 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyItemInfoUi.cs @@ -0,0 +1,295 @@ +using System; +using System.Numerics; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.ItemInfo; + +namespace RynthCore.Plugin.RynthAi.LegacyUi; + +/// +/// "RynthAi Item Info" window: every option of the Mag-style item info line (/ra iteminfo) with +/// a live preview of the selected item. Edits go straight into +/// and are saved by the dashboard autosave. +/// Opened from Advanced Settings → Display or with /ra iteminfo settings. +/// +internal sealed class LegacyItemInfoUi +{ + private readonly LegacyUiSettings _settings; + + // Supplied by RynthAiPlugin (it owns the host + object cache). + private Func? _describeSelected; // selected item's line (no prefix) or null when nothing is selected + private Action? _printSelected; // same path as /ra iteminfo (requests an ID when needed) + private Action? _testChatType; // prints a sample line with the given chat type + + // Preview is rebuilt on a timer or when an output option changes, not every frame. + private const long PreviewRefreshMs = 500; + private string? _previewText; + private long _previewAt; + private MagItemInfoOptions _previewOptions; + + private static readonly Vector4 ExampleColor = new(0.60f, 0.66f, 0.74f, 1f); + + public LegacyItemInfoUi(LegacyUiSettings settings) => _settings = settings; + + public void SetHooks(Func describeSelected, Action printSelected, Action testChatType) + { + _describeSelected = describeSelected; + _printSelected = printSelected; + _testChatType = testChatType; + } + + public void Render() + { + // Re-read every frame: loading a character profile replaces the settings object. + MagItemInfoSettings s = _settings.ItemInfoSettings; + if (!s.ShowWindow) return; + + ImGui.SetNextWindowSize(new Vector2(560, 600), ImGuiCond.FirstUseEver); + if (ImGui.Begin("RynthAi Item Info##ItemInfoSettings", ref s.ShowWindow)) + { + RenderPreview(s); + RenderWhen(s); + RenderFields(s); + RenderSpellsAndRatings(s); + RenderChat(s); + + ImGui.Spacing(); + ImGui.Separator(); + if (ImGui.Button("Reset all to defaults##ii")) + { + s.ResetToDefaults(); + _previewAt = 0; + } + ImGui.SameLine(); + if (ImGui.Button("Close##ii")) s.ShowWindow = false; + } + ImGui.End(); + } + + // ── Preview ────────────────────────────────────────────────────────────── + + private void RenderPreview(MagItemInfoSettings s) + { + if (!ImGui.CollapsingHeader("Preview (selected item)##ii", ImGuiTreeNodeFlags.DefaultOpen)) return; + + var options = MagItemInfoOptions.From(s); + long now = Environment.TickCount64; + if (_describeSelected != null && (now - _previewAt >= PreviewRefreshMs || options != _previewOptions)) + { + try { _previewText = _describeSelected(); } + catch (Exception ex) { _previewText = "Preview failed: " + ex.Message; } + _previewAt = now; + _previewOptions = options; + } + + // Pet-style output is up to four lines plus wrapping. + float previewHeight = s.Layout == MagItemInfoSettings.LayoutPetLines ? 110 : 70; + ImGui.BeginChild("iiPreview", new Vector2(0, previewHeight), ImGuiChildFlags.Borders); + if (string.IsNullOrEmpty(_previewText)) + ImGui.TextDisabled("Select an item to preview its info line."); + else + ImGui.TextWrapped(s.Prefix + _previewText); + ImGui.EndChild(); + + if (ImGui.Button("Print to chat##iiPrint")) _printSelected?.Invoke(); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Same as /ra iteminfo: IDs the selected item first when needed."); + ImGui.SameLine(); + if (ImGui.Button("Refresh##iiRefresh")) _previewAt = 0; + } + + // ── When to print ──────────────────────────────────────────────────────── + + private static void RenderWhen(MagItemInfoSettings s) + { + if (!ImGui.CollapsingHeader("When to print##ii", ImGuiTreeNodeFlags.DefaultOpen)) return; + + ImGui.Checkbox("Describe items when selected##iiOnSel", ref s.OnSelect); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Print the info every time the selection changes to an item.\n/ra iteminfo always works, whatever is set here."); + + RenderClickTrigger(s, "##iiClick"); + + ImGui.Text("Item types:"); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Which items the select / click triggers describe.\n/ra iteminfo and Print to chat ignore these."); + ImGui.Indent(); + ImGui.BeginDisabled(!s.OnSelect && s.ClickTrigger == MagItemInfoSettings.ClickOff); + ImGui.Checkbox("Weapons##iiSelW", ref s.OnSelectWeapons); ImGui.SameLine(); + ImGui.Checkbox("Armor & clothing##iiSelA", ref s.OnSelectArmor); ImGui.SameLine(); + ImGui.Checkbox("Jewelry##iiSelJ", ref s.OnSelectJewelry); ImGui.SameLine(); + ImGui.Checkbox("Other items##iiSelO", ref s.OnSelectOther); + ImGui.EndDisabled(); + ImGui.Unindent(); + + ImGui.SetNextItemWidth(200); + if (ImGui.SliderFloat("ID wait (seconds)##iiTimeout", ref s.IdTimeoutSec, 0.5f, 15f, "%.1f s")) + s.Sanitize(); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("How long to wait for an unidentified item's appraisal\nbefore printing what is already known."); + } + + /// + /// "ID on click" combo (Off / Left / Right). Shared with Advanced Settings → Display, so + /// keeps the ImGui ids unique per window. + /// + public static void RenderClickTrigger(MagItemInfoSettings s, string idSuffix) + { + ImGui.SetNextItemWidth(200); + if (ImGui.Combo("ID + print on click" + idSuffix, ref s.ClickTrigger, + MagItemInfoCatalog.ClickTriggers, MagItemInfoCatalog.ClickTriggers.Length)) + s.Sanitize(); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip( + "Clicking an item in the world or your packs IDs it and prints its info,\n" + + "even when it was already selected. Clicks on RynthCore windows, drags and\n" + + "held-button camera turns are ignored.\n" + + "Right click prints whatever item is selected after the click: if your client\n" + + "doesn't select on right click, left-click to select, then right-click to print.\n" + + "Needs the ImGui overlay enabled."); + } + + /// Layout combo (pet-style lines / one line). Shared with Advanced Settings → Display. + public static void RenderLayout(MagItemInfoSettings s, string idSuffix) + { + ImGui.SetNextItemWidth(200); + if (ImGui.Combo("Layout" + idSuffix, ref s.Layout, MagItemInfoCatalog.Layouts, MagItemInfoCatalog.Layouts.Length)) + s.Sanitize(); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip( + "Pet-style lines (like the ILT Hub pet roster):\n" + + " 1 Name (type mastery), set, AL, tinks, applied, craft\n" + + " 2 imbues, slayer, damage, variance, %a / %md / %mc\n" + + " 3 [ratings] wield / activation / diff, value\n" + + " 4 Spells: …\n" + + "One line: the classic Mag-Tools single line."); + } + + // ── Field toggles ──────────────────────────────────────────────────────── + + private void RenderFields(MagItemInfoSettings s) + { + if (!ImGui.CollapsingHeader("Fields##ii", ImGuiTreeNodeFlags.DefaultOpen)) return; + + if (ImGui.SmallButton("All on##iiFields")) s.HiddenFields = 0; + ImGui.SameLine(); + if (ImGui.SmallButton("All off##iiFields")) + { + foreach (var f in MagItemInfoCatalog.Fields) s.SetHidden(f.Field, true); + } + ImGui.SameLine(); + ImGui.TextDisabled("(the item name is always printed)"); + + if (ImGui.BeginTable("iiFieldTable", 2, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingStretchProp)) + { + ImGui.TableSetupColumn("Field", ImGuiTableColumnFlags.WidthStretch, 0.45f); + ImGui.TableSetupColumn("Example", ImGuiTableColumnFlags.WidthStretch, 0.55f); + foreach (var f in MagItemInfoCatalog.Fields) + { + ImGui.TableNextRow(); + ImGui.TableNextColumn(); + bool shown = !s.IsHidden(f.Field); + if (ImGui.Checkbox($"{f.Label}##iiF{(int)f.Field}", ref shown)) + s.SetHidden(f.Field, !shown); + ImGui.TableNextColumn(); + ImGui.TextColored(ExampleColor, f.Example); + } + ImGui.TableNextRow(); + ImGui.TableNextColumn(); + ImGui.Checkbox("Value & burden##iiValBu", ref s.ShowValueAndBurden); + ImGui.TableNextColumn(); + ImGui.TextColored(ExampleColor, "Value 12,500, BU 220"); + ImGui.EndTable(); + } + } + + // ── Spells + per-rating toggles ────────────────────────────────────────── + + private static void RenderSpellsAndRatings(MagItemInfoSettings s) + { + if (!ImGui.CollapsingHeader("Spells & ratings##ii")) return; + + ImGui.BeginDisabled(s.IsHidden(MagItemInfoField.Spells)); + ImGui.Text("Spell list:"); + ImGui.SameLine(); + ImGui.RadioButton("Mag filter##iiSpMag", ref s.SpellMode, MagItemInfoSettings.SpellModeMag); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Cantrips, level 7+ weapon auras, Augmented spells,\nand Impen/banes only on unenchantable gear."); + ImGui.SameLine(); + ImGui.RadioButton("All spells##iiSpAll", ref s.SpellMode, MagItemInfoSettings.SpellModeAll); + if (s.SpellMode == MagItemInfoSettings.SpellModeAll) + { + ImGui.SetNextItemWidth(200); + if (ImGui.SliderInt("Max spells listed##iiSpMax", ref s.MaxListedSpells, 1, 64)) + s.Sanitize(); + } + ImGui.EndDisabled(); + + ImGui.Spacing(); + ImGui.BeginDisabled(s.IsHidden(MagItemInfoField.Ratings)); + ImGui.Text("Ratings shown:"); + ImGui.SameLine(); + if (ImGui.SmallButton("All##iiRat")) s.HiddenRatings = 0; + ImGui.SameLine(); + if (ImGui.SmallButton("None##iiRat")) s.HiddenRatings = (1 << MagItemInfoCatalog.Ratings.Length) - 1; + if (ImGui.BeginTable("iiRatingTable", 3)) + { + var ratings = MagItemInfoCatalog.Ratings; + for (int i = 0; i < ratings.Length; i++) + { + ImGui.TableNextColumn(); + bool shown = !s.IsRatingHidden(i); + if (ImGui.Checkbox($"{ratings[i].Tag} - {ratings[i].Name}##iiR{i}", ref shown)) + s.SetRatingHidden(i, !shown); + } + ImGui.EndTable(); + } + ImGui.EndDisabled(); + } + + // ── Chat output ────────────────────────────────────────────────────────── + + private void RenderChat(MagItemInfoSettings s) + { + if (!ImGui.CollapsingHeader("Chat output##ii", ImGuiTreeNodeFlags.DefaultOpen)) return; + + RenderLayout(s, "##iiLayout"); + + ChatTypeCombo("Chat type / colour##iiChat", ref s.ChatType, allowSameAsHeader: false); + ImGui.SameLine(); + if (ImGui.Button("Test##iiChatTest")) _testChatType?.Invoke(s.ChatType); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Print a sample line with this chat type to see its colour."); + + // Pet-style only: the roster draws its detail lines in a second colour. + ImGui.BeginDisabled(s.Layout != MagItemInfoSettings.LayoutPetLines); + ChatTypeCombo("Detail lines colour##iiChatDetail", ref s.DetailChatType, allowSameAsHeader: true); + ImGui.SameLine(); + if (ImGui.Button("Test##iiChatDetailTest")) + _testChatType?.Invoke(s.DetailChatType == MagItemInfoSettings.SameAsHeader ? s.ChatType : s.DetailChatType); + ImGui.EndDisabled(); + if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) + ImGui.SetTooltip("Chat type for lines 2-4 of the pet-style layout\n(the name line uses the colour above)."); + + ImGui.SetNextItemWidth(220); + ImGui.InputText("Line prefix##iiPrefix", ref s.Prefix, 32); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Text put in front of every item info line (may be empty)."); + } + + /// Chat type picker; adds the "same as name line" entry (-1). + private static void ChatTypeCombo(string label, ref int chatType, bool allowSameAsHeader) + { + const string SameLabel = "Same as name line"; + string current = chatType == MagItemInfoSettings.SameAsHeader ? SameLabel : $"{chatType}"; + foreach (var (type, name) in MagItemInfoCatalog.ChatTypes) + if (type == chatType) { current = name; break; } + + ImGui.SetNextItemWidth(220); + if (!ImGui.BeginCombo(label, current)) return; + if (allowSameAsHeader && ImGui.Selectable(SameLabel, chatType == MagItemInfoSettings.SameAsHeader)) + chatType = MagItemInfoSettings.SameAsHeader; + foreach (var (type, name) in MagItemInfoCatalog.ChatTypes) + if (ImGui.Selectable(name, type == chatType)) chatType = type; + ImGui.EndCombo(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyMetaUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyMetaUi.cs index 165283a..140f3c7 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyMetaUi.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyMetaUi.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Numerics; using ImGuiNET; using RynthCore.Plugin.RynthAi.Meta; +using RynthCore.Install; namespace RynthCore.Plugin.RynthAi.LegacyUi; @@ -1238,7 +1239,8 @@ internal sealed class LegacyMetaUi } lock (_settings.MetaRulesLock) - AfFileWriter.Save(path, _settings.MetaRules, _settings.EmbeddedNavs); + RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.TrySave("the meta", path, + () => AfFileWriter.Save(path, _settings.MetaRules, _settings.EmbeddedNavs)); } catch { } } @@ -1254,10 +1256,18 @@ internal sealed class LegacyMetaUi return; } - Directory.CreateDirectory(MetaFolder); string filePath = Path.Combine(MetaFolder, _saveName + ".af"); + bool saved; + string why; lock (_settings.MetaRulesLock) - AfFileWriter.Save(filePath, _settings.MetaRules, _settings.EmbeddedNavs); + saved = RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.TrySave("the meta", filePath, + () => AfFileWriter.Save(filePath, _settings.MetaRules, _settings.EmbeddedNavs), out why); + if (!saved) + { + _statusMessage = $"Couldn't save {filePath}: {why}"; + _statusTime = DateTime.Now; + return; + } _statusMessage = $"Saved to {_saveName}.af"; _statusTime = DateTime.Now; diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyNavigationUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyNavigationUi.cs index 72fb301..591e743 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyNavigationUi.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyNavigationUi.cs @@ -263,7 +263,9 @@ internal sealed class LegacyNavigationUi return Math.Clamp(active, 0, newCount - 1); } - public const string NavFolder = @"C:\Games\RynthSuite\RynthAi\NavProfiles"; + /// NavProfiles in the resolved RynthSuite folder. It was hard-coded to C:\Games, so with a + /// moved install /ra nav save <name> wrote where the nav picker never looks (2026-10-13). + public static string NavFolder => Path.Combine(RynthCore.Install.RynthInstallPaths.RynthAiDir, "NavProfiles"); public void TryAutoSaveNav() { @@ -274,7 +276,10 @@ internal sealed class LegacyNavigationUi if (TryGetEmbeddedKey(path, out string key)) _settings.EmbeddedNavs[key] = _settings.CurrentRoute.ToLines(); else - _settings.CurrentRoute.Save(path); + { + NavRouteParser route = _settings.CurrentRoute; + RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.TrySave("the nav", path, () => route.Save(path)); + } } catch (Exception ex) { _host.Log($"[RynthAi] Nav auto-save to {path} failed: {ex.Message}"); } } @@ -313,7 +318,9 @@ internal sealed class LegacyNavigationUi do path = Path.Combine(NavFolder, $"Route {n++}.nav"); while (File.Exists(path)); } - route.Save(path); + string target = path; + if (!RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.TrySave("the nav", target, () => route.Save(target), out string why, callerShows: true)) + return $"[RynthAi] Nav NOT saved to {target}: {why}"; _settings.CurrentNavPath = path; return $"[RynthAi] Saved {route.Points.Count} waypoints to {Path.GetFileName(path)}."; } diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacySpellsUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacySpellsUi.cs new file mode 100644 index 0000000..62d76f7 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacySpellsUi.cs @@ -0,0 +1,806 @@ +// LegacySpellsUi.cs - "RynthAi Spells" window (/ra spells). +// +// Left: ACECustom's spell catalog with school / level / target / effect / known filters and +// sortable columns (click a header; Shift+click adds a second sort key). +// Right: the buff profile editor. A saved profile chosen here ("Use for buffing") or under +// Loaded Files → Buffs replaces buffing's built-in list. +// +// Render thread only. The plugin hands in pump-thread data: the known-spell copy, the built-in +// buff list, and applies the chosen profile path. +using System; +using System.Collections.Generic; +using System.IO; +using System.Numerics; +using System.Threading; +using ImGuiNET; + +namespace RynthCore.Plugin.RynthAi.LegacyUi; + +internal sealed unsafe class LegacySpellsUi +{ + private const string WindowTitle = "RynthAi Spells##RynthAiSpells"; + private const string ConfirmPopupId = "Confirm##rynthaispells"; + + /// Catalog table columns, in display order (the sort specs report these indexes). + private enum Col { Add, Name, School, Level, Target, Effect, Family, Known } + private const int ColumnCount = 8; + + private static readonly string[] TargetFilters = { "All targets", "Self", "Other", "Item", "Fellowship" }; + private static readonly string[] TargetOrder = { "Self", "Other", "Item", "Fellowship" }; + + private static readonly Vector4 WarnColor = new(1f, 0.72f, 0.30f, 1f); + private static readonly Vector4 GoodColor = new(0.45f, 0.85f, 0.45f, 1f); + + private readonly LegacyUiSettings _settings; + private Action? _requestActiveProfile; // plugin applies it on the pump thread + private Action? _refreshProfileList; // Loaded Files list after save / delete + + // Pump-thread handoffs (Volatile / Interlocked: written on the pump thread, read here). + private HashSet? _known; + private List? _builtInList; + private int _builtInRequested; + + // Catalog filters. + private string _search = ""; + private readonly bool[] _schoolOn = { true, true, true, true, true }; + private readonly bool[] _levelOn = { true, true, true, true, true, true, true, true }; + private string[] _effectItems = Array.Empty(); + private int _effectIdx = -1; // -1 until the catalog is loaded, then "Buff" + private int _targetIdx; + private bool _knownOnly; + + // Filtered + sorted rows: rebuilt only when a filter, the sort or the known set changes. + private readonly List _rows = new(); + private bool _rowsDirty = true; + private HashSet? _rowsKnown; + private (Col Col, bool Asc)[] _sort = { (Col.School, true), (Col.Level, false) }; + + // Profile editor. + private BuffProfile _edit = NewProfile(); + private string? _editPath; // null = never saved + private bool _dirty; + private readonly HashSet _editKeys = new(StringComparer.OrdinalIgnoreCase); + private List _files = new(); + private string _status = ""; + private bool _statusIsWarning; + + private bool _wasVisible; + private bool _rescueChecked; + + // Yes/No confirmation (opened at window level so the popup id stack matches). + private string _confirmText = ""; + private Action? _confirmAction; + private bool _openConfirm; + + public LegacySpellsUi(LegacyUiSettings settings) => _settings = settings; + + public void SetHooks(Action requestActiveProfile, Action refreshProfileList) + { + _requestActiveProfile = requestActiveProfile; + _refreshProfileList = refreshProfileList; + } + + /// True while the window is open (the plugin only feeds it data then). + public bool Visible => _settings.ShowSpellsWindow; + + // ── Pump-thread side ──────────────────────────────────────────────────── + + /// Pump thread: a fresh copy of the character's known spell ids. + public void SetKnownSpells(HashSet ids) => Volatile.Write(ref _known, ids); + + /// Pump thread: true once per "Add built-in list" click. + public bool TakeBuiltInRequest() => Interlocked.Exchange(ref _builtInRequested, 0) == 1; + + /// Pump thread: answer to . + public void SetBuiltInList(List baseNames) => Volatile.Write(ref _builtInList, baseNames); + + // ── Window ────────────────────────────────────────────────────────────── + + public void Render() + { + if (!_settings.ShowSpellsWindow) + { + _wasVisible = false; + _rescueChecked = false; + return; + } + if (!_wasVisible) + { + _wasVisible = true; + OnShown(); + } + + UiPlacement.CenterFirstUse(new Vector2(40, 40)); + ImGui.SetNextWindowSize(new Vector2(1140, 660), ImGuiCond.FirstUseEver); + if (ImGui.Begin(WindowTitle, ref _settings.ShowSpellsWindow)) + { + UiPlacement.RescueOncePerShow(ref _rescueChecked); + ApplyBuiltInList(); + + if (!SpellCatalog.IsLoaded) + { + ImGui.TextDisabled("The spell catalog is not loaded yet (it loads at login; see chat for errors)."); + } + else + { + EnsureEffectItems(); + float avail = ImGui.GetContentRegionAvail().X; + float leftW = MathF.Max(460f, avail * 0.58f); + + if (ImGui.BeginChild("##spcatalog", new Vector2(leftW, 0), ImGuiChildFlags.Borders | ImGuiChildFlags.ResizeX)) + { + RenderFilters(); + RenderCatalogTable(); + } + ImGui.EndChild(); + + ImGui.SameLine(); + if (ImGui.BeginChild("##spprofile", Vector2.Zero, ImGuiChildFlags.Borders)) + RenderProfileEditor(); + ImGui.EndChild(); + } + + RenderConfirmPopup(); + } + ImGui.End(); + } + + /// Each time the window opens: refresh the file list and open the active profile. + private void OnShown() + { + RefreshFiles(); + if (_editPath != null || _dirty) return; + string active = _settings.CurrentBuffProfilePath ?? ""; + if (active.Length > 0 && File.Exists(active)) LoadProfile(active); + } + + private void EnsureEffectItems() + { + if (_effectItems.Length > 0) return; + var effects = SpellCatalog.Effects; + _effectItems = new string[effects.Count + 1]; + _effectItems[0] = "All effects"; + for (int i = 0; i < effects.Count; i++) _effectItems[i + 1] = effects[i]; + // Buff profiles are about buffs, so the list starts there. + _effectIdx = Math.Max(0, Array.FindIndex(_effectItems, s => s.Equals("Buff", StringComparison.OrdinalIgnoreCase))); + _rowsDirty = true; + } + + // ── Catalog: filters ──────────────────────────────────────────────────── + + private void RenderFilters() + { + ImGui.SetNextItemWidth(190); + if (ImGui.InputTextWithHint("##spsearch", "Search name or family", ref _search, 64)) _rowsDirty = true; + + ImGui.SameLine(); + ImGui.SetNextItemWidth(110); + if (ImGui.Combo("##speffect", ref _effectIdx, _effectItems, _effectItems.Length)) _rowsDirty = true; + + ImGui.SameLine(); + ImGui.SetNextItemWidth(100); + if (ImGui.Combo("##sptarget", ref _targetIdx, TargetFilters, TargetFilters.Length)) _rowsDirty = true; + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Self: cast on yourself. Other: cast on a target (buffing casts the Self version).\nItem: lands on your weapon or armor."); + + ImGui.SameLine(); + bool knownReady = Volatile.Read(ref _known) != null; + if (ImGui.Checkbox("Known only##spknown", ref _knownOnly)) _rowsDirty = true; + if (ImGui.IsItemHovered()) + ImGui.SetTooltip(knownReady + ? "Only spells in your spellbook." + : "Waiting for your spellbook (it is read a few seconds after login)."); + + ImGui.TextUnformatted("School:"); + for (int i = 0; i < SpellCatalog.Schools.Length; i++) + { + ImGui.SameLine(); + if (ImGui.Checkbox(SpellCatalog.ShortSchool(SpellCatalog.Schools[i]) + "##spsch" + i, ref _schoolOn[i])) _rowsDirty = true; + } + ImGui.SameLine(); + if (ImGui.SmallButton("All##spschall")) SetAll(_schoolOn, true); + ImGui.SameLine(); + if (ImGui.SmallButton("None##spschnone")) SetAll(_schoolOn, false); + + ImGui.TextUnformatted("Level: "); + for (int i = 0; i < _levelOn.Length; i++) + { + ImGui.SameLine(); + if (ImGui.Checkbox((i + 1) + "##splvl" + i, ref _levelOn[i])) _rowsDirty = true; + } + ImGui.SameLine(); + if (ImGui.SmallButton("All##splvlall")) SetAll(_levelOn, true); + ImGui.SameLine(); + if (ImGui.SmallButton("None##splvlnone")) SetAll(_levelOn, false); + } + + private void SetAll(bool[] flags, bool on) + { + for (int i = 0; i < flags.Length; i++) flags[i] = on; + _rowsDirty = true; + } + + // ── Catalog: table ────────────────────────────────────────────────────── + + private void RenderCatalogTable() + { + RebuildRowsIfNeeded(); + ImGui.TextDisabled($"{_rows.Count} of {SpellCatalog.All.Count} spells. Click a header to sort, Shift+click for a second sort. + or double-click adds a buff."); + + const ImGuiTableFlags flags = ImGuiTableFlags.Sortable | ImGuiTableFlags.SortMulti | ImGuiTableFlags.RowBg + | ImGuiTableFlags.ScrollY | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.Resizable + | ImGuiTableFlags.Hideable | ImGuiTableFlags.SizingFixedFit; + if (!ImGui.BeginTable("##spcattable", ColumnCount, flags, Vector2.Zero)) return; + + ImGui.TableSetupScrollFreeze(0, 1); + ImGui.TableSetupColumn("##add", ImGuiTableColumnFlags.NoSort | ImGuiTableColumnFlags.NoHide | ImGuiTableColumnFlags.WidthFixed, 22); + ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.NoHide | ImGuiTableColumnFlags.WidthStretch); + ImGui.TableSetupColumn("School", ImGuiTableColumnFlags.DefaultSort | ImGuiTableColumnFlags.WidthFixed, 62); + ImGui.TableSetupColumn("Lvl", ImGuiTableColumnFlags.DefaultSort | ImGuiTableColumnFlags.PreferSortDescending | ImGuiTableColumnFlags.WidthFixed, 30); + ImGui.TableSetupColumn("Target", ImGuiTableColumnFlags.WidthFixed, 56); + ImGui.TableSetupColumn("Effect", ImGuiTableColumnFlags.WidthFixed, 64); + ImGui.TableSetupColumn("Family", ImGuiTableColumnFlags.DefaultHide | ImGuiTableColumnFlags.WidthFixed, 150); + ImGui.TableSetupColumn("Known", ImGuiTableColumnFlags.WidthFixed, 42); + ImGui.TableHeadersRow(); + + if (ReadSortSpecs()) RebuildRowsIfNeeded(); + + ImGuiListClipper* native = ImGuiNative.ImGuiListClipper_ImGuiListClipper(); + try + { + var clipper = new ImGuiListClipperPtr(native); + clipper.Begin(_rows.Count); + while (clipper.Step()) + for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + RenderCatalogRow(_rows[i]); + clipper.End(); + } + finally + { + ImGuiNative.ImGuiListClipper_destroy(native); + } + ImGui.EndTable(); + } + + private void RenderCatalogRow(SpellCatalogEntry e) + { + string key = e.IsBuff ? SpellCatalog.BuffKeyFor(e) : ""; + bool inProfile = key.Length > 0 && _editKeys.Contains(key); + + ImGui.TableNextRow(); + ImGui.PushID(e.Id); + + ImGui.TableSetColumnIndex((int)Col.Add); + if (!e.IsBuff) ImGui.TextDisabled("-"); + else if (inProfile) ImGui.TextColored(GoodColor, "*"); + else if (ImGui.SmallButton("+")) AddSpell(e); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip(!e.IsBuff ? "Only buffs can go in a buff profile." + : inProfile ? $"Already in the profile (as {key})." : $"Add to the profile (buffing casts {key})."); + + ImGui.TableSetColumnIndex((int)Col.Name); + if (ImGui.Selectable(e.Name, inProfile, ImGuiSelectableFlags.AllowDoubleClick) + && ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left) && e.IsBuff && !inProfile) + AddSpell(e); + if (ImGui.IsItemHovered()) SpellTooltip(e, key); + + ImGui.TableSetColumnIndex((int)Col.School); + ImGui.TextUnformatted(SpellCatalog.ShortSchool(e.School)); + ImGui.TableSetColumnIndex((int)Col.Level); + ImGui.TextUnformatted(e.Level > 0 ? e.Level.ToString() : "-"); + ImGui.TableSetColumnIndex((int)Col.Target); + ImGui.TextUnformatted(e.Target); + ImGui.TableSetColumnIndex((int)Col.Effect); + ImGui.TextUnformatted(e.Effect); + ImGui.TableSetColumnIndex((int)Col.Family); + ImGui.TextUnformatted(e.FamilyName); + ImGui.TableSetColumnIndex((int)Col.Known); + if (_rowsKnown == null) ImGui.TextDisabled("?"); + else if (_rowsKnown.Contains(e.Id)) ImGui.TextColored(GoodColor, "yes"); + + ImGui.PopID(); + } + + private static void SpellTooltip(SpellCatalogEntry e, string key) + { + ImGui.BeginTooltip(); + ImGui.PushTextWrapPos(ImGui.GetFontSize() * 30f); + ImGui.TextUnformatted($"{e.Name} (id {e.Id}, level {e.Level})"); + ImGui.TextUnformatted($"{e.School}, {e.Target}, {e.Effect}"); + if (e.FamilyName.Length > 0) ImGui.TextUnformatted($"Family: {e.FamilyName} (#{e.FamilyId}); power {e.Power}"); + string duration = e.DurationSec > 0 ? FormatDuration(e.DurationSec) : "none"; + ImGui.TextUnformatted($"Mana {e.Mana}, duration {duration}"); + if (key.Length > 0) ImGui.TextUnformatted($"Buffing casts: {key} (best level you know)"); + if (e.Description.Length > 0) + { + ImGui.Separator(); + ImGui.TextUnformatted(e.Description); + } + ImGui.PopTextWrapPos(); + ImGui.EndTooltip(); + } + + private static string FormatDuration(int seconds) => + seconds >= 3600 ? $"{seconds / 3600}h {seconds % 3600 / 60}m" + : seconds >= 60 ? $"{seconds / 60}m" + : $"{seconds}s"; + + /// Copies the table's sort specs into . True when they changed. + private bool ReadSortSpecs() + { + ImGuiTableSortSpecsPtr specs = ImGui.TableGetSortSpecs(); + if (specs.NativePtr == null || !specs.SpecsDirty) return false; + + var keys = new List<(Col, bool)>(specs.SpecsCount); + for (int i = 0; i < specs.SpecsCount; i++) + { + ImGuiTableColumnSortSpecs s = specs.NativePtr->Specs[i]; + // SortDirection is one byte natively; mask off whatever follows it. + bool descending = ((int)s.SortDirection & 0xFF) == (int)ImGuiSortDirection.Descending; + keys.Add(((Col)s.ColumnIndex, !descending)); + } + if (keys.Count > 0) _sort = keys.ToArray(); + specs.SpecsDirty = false; + _rowsDirty = true; + return true; + } + + private void RebuildRowsIfNeeded() + { + HashSet? known = Volatile.Read(ref _known); + if (!_rowsDirty && ReferenceEquals(known, _rowsKnown)) return; + _rowsDirty = false; + _rowsKnown = known; + + string? effect = _effectIdx > 0 && _effectIdx < _effectItems.Length ? _effectItems[_effectIdx] : null; + string? target = _targetIdx > 0 ? TargetFilters[_targetIdx] : null; + string search = _search.Trim(); + + _rows.Clear(); + foreach (var e in SpellCatalog.All) + { + int school = SchoolRank(e.School); + if (school < _schoolOn.Length && !_schoolOn[school]) continue; + if (e.Level >= 1 && e.Level <= _levelOn.Length && !_levelOn[e.Level - 1]) continue; + if (effect != null && !e.Effect.Equals(effect, StringComparison.OrdinalIgnoreCase)) continue; + if (target != null && !e.Target.Equals(target, StringComparison.OrdinalIgnoreCase)) continue; + if (_knownOnly && known != null && !known.Contains(e.Id)) continue; + if (search.Length > 0 + && e.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) < 0 + && e.FamilyName.IndexOf(search, StringComparison.OrdinalIgnoreCase) < 0) + continue; + _rows.Add(e); + } + _rows.Sort(CompareRows); + } + + private int CompareRows(SpellCatalogEntry a, SpellCatalogEntry b) + { + foreach (var (col, asc) in _sort) + { + int c = col switch + { + Col.Name => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase), + Col.School => SchoolRank(a.School).CompareTo(SchoolRank(b.School)), + Col.Level => a.Level.CompareTo(b.Level), + Col.Target => TargetRank(a.Target).CompareTo(TargetRank(b.Target)), + Col.Effect => string.Compare(a.Effect, b.Effect, StringComparison.OrdinalIgnoreCase), + Col.Family => string.Compare(a.FamilyName, b.FamilyName, StringComparison.OrdinalIgnoreCase), + // Ascending puts known spells first. + Col.Known => IsKnown(b).CompareTo(IsKnown(a)), + _ => 0, + }; + if (c != 0) return asc ? c : -c; + } + int n = string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase); + return n != 0 ? n : a.Id.CompareTo(b.Id); + } + + private bool IsKnown(SpellCatalogEntry e) => _rowsKnown != null && _rowsKnown.Contains(e.Id); + + /// Position in ; unknown schools sort last. + private static int SchoolRank(string school) + { + int i = Array.IndexOf(SpellCatalog.Schools, school); + return i < 0 ? SpellCatalog.Schools.Length : i; + } + + /// Self, Other, Item, Fellowship, then anything else. + private static int TargetRank(string target) + { + for (int i = 0; i < TargetOrder.Length; i++) + if (TargetOrder[i].Equals(target, StringComparison.OrdinalIgnoreCase)) return i; + return TargetOrder.Length; + } + + // ── Profile editor ────────────────────────────────────────────────────── + + private void RenderProfileEditor() + { + string active = _settings.CurrentBuffProfilePath ?? ""; + bool editIsActive = _editPath != null && active.Equals(_editPath, StringComparison.OrdinalIgnoreCase); + + ImGui.TextUnformatted("Buffing uses: " + (active.Length == 0 ? BuiltInLabel : Path.GetFileNameWithoutExtension(active))); + if (!_settings.EnableBuffing) + { + ImGui.SameLine(); + ImGui.TextColored(WarnColor, "(Buffing is off)"); + } + + // Open / New / Save / Delete. + string preview = _editPath == null ? "(new, not saved)" : Path.GetFileNameWithoutExtension(_editPath); + if (_dirty) preview += " *"; + ImGui.SetNextItemWidth(200); + if (ImGui.BeginCombo("##spopen", preview, ImGuiComboFlags.HeightLarge)) + { + if (_files.Count == 0) ImGui.TextDisabled("No saved profiles yet."); + foreach (string file in _files) + { + string path = Path.Combine(BuffProfileStore.Folder, file); + bool selected = path.Equals(_editPath, StringComparison.OrdinalIgnoreCase); + if (ImGui.Selectable(Path.GetFileNameWithoutExtension(file), selected) && !selected) + ConfirmIfDirty("open another profile", () => LoadProfile(path)); + } + ImGui.EndCombo(); + } + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Open a saved profile (RynthAi\\BuffProfiles)."); + + ImGui.SameLine(); + if (ImGui.Button("New##spnew")) ConfirmIfDirty("start a new profile", StartNewProfile); + ImGui.SameLine(); + if (ImGui.Button("Save##spsave")) Save(thenActivate: false); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Saves to BuffProfiles\\.json. Change the name to save a copy."); + ImGui.SameLine(); + ImGui.BeginDisabled(_editPath == null); + if (ImGui.Button("Delete##spdel")) ConfirmDelete(); + ImGui.EndDisabled(); + ImGui.SameLine(); + if (ImGui.Button("Refresh##sprefresh")) RefreshFiles(); + + string name = _edit.Name; + ImGui.SetNextItemWidth(-1); + if (ImGui.InputTextWithHint("##spname", "Profile name", ref name, 80)) + { + _edit.Name = name; + _dirty = true; + } + + // Which list buffing uses. + if (editIsActive) + { + ImGui.TextColored(GoodColor, _dirty ? "Buffing uses this profile (save to apply edits)." : "Buffing uses this profile."); + } + else if (ImGui.Button("Use for buffing##spuse")) + { + Save(thenActivate: true); + } + if (active.Length > 0) + { + ImGui.SameLine(); + if (ImGui.Button("Use built-in list##spbuiltin")) + { + _requestActiveProfile?.Invoke(""); + SetStatus("Buffing goes back to its built-in list."); + } + } + + ImGui.Separator(); + if (ImGui.Button("Add built-in list##spaddbuiltin")) + { + Interlocked.Exchange(ref _builtInRequested, 1); + SetStatus("Reading buffing's built-in list..."); + } + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Adds the spells buffing casts without a profile (for this character's skills), as a starting point."); + ImGui.SameLine(); + ImGui.BeginDisabled(_edit.Entries.Count == 0); + if (ImGui.Button("Clear##spclear")) Confirm("Remove every spell from this profile?", ClearEntries); + ImGui.EndDisabled(); + ImGui.SameLine(); + int enabled = 0; + foreach (var en in _edit.Entries) if (en.Enabled) enabled++; + ImGui.TextDisabled($"{enabled} of {_edit.Entries.Count} on"); + + float notesH = ImGui.GetTextLineHeightWithSpacing() * 3.2f; + float statusH = ImGui.GetTextLineHeightWithSpacing() * 1.4f; + RenderEntriesTable(MathF.Max(80f, ImGui.GetContentRegionAvail().Y - notesH - statusH - ImGui.GetStyle().ItemSpacing.Y * 2)); + + string notes = _edit.Notes; + if (ImGui.InputTextMultiline("##spnotes", ref notes, 2000, new Vector2(-1, notesH))) + { + _edit.Notes = notes; + _dirty = true; + } + if (ImGui.IsItemHovered() && notes.Length == 0) ImGui.SetTooltip("Notes for this profile."); + + if (_status.Length > 0) + { + if (_statusIsWarning) ImGui.TextColored(WarnColor, _status); + else ImGui.TextDisabled(_status); + } + } + + private void RenderEntriesTable(float height) + { + int moveFrom = -1, moveTo = -1, remove = -1; + + const ImGuiTableFlags flags = ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.BordersInnerV + | ImGuiTableFlags.Resizable | ImGuiTableFlags.SizingFixedFit; + if (ImGui.BeginTable("##spentries", 7, flags, new Vector2(0, height))) + { + ImGui.TableSetupScrollFreeze(0, 1); + ImGui.TableSetupColumn("On", ImGuiTableColumnFlags.WidthFixed, 24); + ImGui.TableSetupColumn("Spell", ImGuiTableColumnFlags.WidthStretch); + ImGui.TableSetupColumn("Casts", ImGuiTableColumnFlags.WidthFixed, 130); + ImGui.TableSetupColumn("School", ImGuiTableColumnFlags.WidthFixed, 52); + ImGui.TableSetupColumn("Lvl", ImGuiTableColumnFlags.WidthFixed, 26); + ImGui.TableSetupColumn("Target", ImGuiTableColumnFlags.WidthFixed, 46); + ImGui.TableSetupColumn("##order", ImGuiTableColumnFlags.WidthFixed, 74); + ImGui.TableHeadersRow(); + + var entries = _edit.Entries; + for (int i = 0; i < entries.Count; i++) + { + var entry = entries[i]; + ImGui.TableNextRow(); + ImGui.PushID(i); + + ImGui.TableSetColumnIndex(0); + bool on = entry.Enabled; + if (ImGui.Checkbox("##on", ref on)) + { + entry.Enabled = on; + _dirty = true; + } + + ImGui.TableSetColumnIndex(1); + if (entry.Enabled) ImGui.TextUnformatted(entry.Name); + else ImGui.TextDisabled(entry.Name); + var spell = entry.SpellId != 0 ? SpellCatalog.Get(entry.SpellId) : null; + if (spell != null && ImGui.IsItemHovered()) SpellTooltip(spell, entry.Key); + + ImGui.TableSetColumnIndex(2); + ImGui.TextDisabled(entry.Key); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Buffing casts the highest level of this spell you know."); + ImGui.TableSetColumnIndex(3); + ImGui.TextUnformatted(SpellCatalog.ShortSchool(entry.School)); + ImGui.TableSetColumnIndex(4); + ImGui.TextUnformatted(entry.Level > 0 ? entry.Level.ToString() : "-"); + ImGui.TableSetColumnIndex(5); + ImGui.TextUnformatted(entry.Target); + + ImGui.TableSetColumnIndex(6); + ImGui.BeginDisabled(i == 0); + if (ImGui.ArrowButton("##up", ImGuiDir.Up)) { moveFrom = i; moveTo = i - 1; } + ImGui.EndDisabled(); + ImGui.SameLine(0, 2); + ImGui.BeginDisabled(i == entries.Count - 1); + if (ImGui.ArrowButton("##down", ImGuiDir.Down)) { moveFrom = i; moveTo = i + 1; } + ImGui.EndDisabled(); + ImGui.SameLine(0, 2); + if (ImGui.SmallButton("X")) remove = i; + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Remove"); + + ImGui.PopID(); + } + if (entries.Count == 0) + { + ImGui.TableNextRow(); + ImGui.TableSetColumnIndex(1); + ImGui.TextDisabled("Empty: add buffs from the list on the left."); + } + ImGui.EndTable(); + } + + // Applied after drawing so the loop never sees a list that changed under it. + if (moveFrom >= 0) + { + var list = _edit.Entries; + (list[moveFrom], list[moveTo]) = (list[moveTo], list[moveFrom]); + _dirty = true; + } + if (remove >= 0) + { + _edit.Entries.RemoveAt(remove); + RebuildEditKeys(); + _dirty = true; + } + } + + // ── Profile actions ───────────────────────────────────────────────────── + + private const string BuiltInLabel = "built-in list"; + + private static BuffProfile NewProfile() => new() { Name = "New buff profile" }; + + private void StartNewProfile() + { + _edit = NewProfile(); + _editPath = null; + _dirty = false; + RebuildEditKeys(); + SetStatus("New profile: add buffs from the list on the left, then Save."); + } + + private void LoadProfile(string path) + { + if (!BuffProfileStore.TryLoad(path, out var profile, out string error)) + { + SetStatus($"Could not open {Path.GetFileName(path)}: {error}", warning: true); + return; + } + _edit = profile; + _editPath = path; + _dirty = false; + RebuildEditKeys(); + SetStatus($"Opened {profile.Name} ({profile.Entries.Count} spells)."); + } + + private void AddSpell(SpellCatalogEntry e) + { + if (!e.IsBuff) return; + var entry = BuffProfileStore.EntryFor(e); + if (_editKeys.Contains(entry.Key)) + { + SetStatus($"{entry.Key} is already in the profile."); + return; + } + _edit.Entries.Add(entry); + _editKeys.Add(entry.Key); + _dirty = true; + SetStatus($"Added {e.Name} (casts {entry.Key})."); + } + + private void ClearEntries() + { + _edit.Entries.Clear(); + RebuildEditKeys(); + _dirty = true; + SetStatus("Profile cleared."); + } + + /// Adds buffing's built-in list once the pump thread has produced it. + private void ApplyBuiltInList() + { + List? names = Interlocked.Exchange(ref _builtInList, null); + if (names == null) return; + + int added = 0, notInCatalog = 0; + foreach (string baseName in names) + { + if (string.IsNullOrWhiteSpace(baseName) || _editKeys.Contains(baseName)) continue; + var spell = BuffProfileStore.CatalogSpellForBaseName(baseName); + BuffProfileEntry entry = spell != null ? BuffProfileStore.EntryFor(spell) : new BuffProfileEntry { Name = baseName }; + // Keep the built-in base name: it is exactly what buffing resolves today. + entry.Key = baseName; + if (spell == null) notInCatalog++; + _edit.Entries.Add(entry); + _editKeys.Add(baseName); + added++; + } + if (added > 0) _dirty = true; + SetStatus(notInCatalog > 0 + ? $"Added {added} spells from the built-in list ({notInCatalog} not in the catalog)." + : $"Added {added} spells from the built-in list."); + } + + /// Saves to BuffProfiles\<Name>.json, asking before overwriting another profile. + private void Save(bool thenActivate) + { + string path = BuffProfileStore.PathFor(_edit.Name); + bool otherFile = !path.Equals(_editPath, StringComparison.OrdinalIgnoreCase); + if (otherFile && File.Exists(path)) + Confirm($"Replace the saved profile '{Path.GetFileNameWithoutExtension(path)}'?", () => SaveTo(path, thenActivate)); + else + SaveTo(path, thenActivate); + } + + private void SaveTo(string path, bool thenActivate) + { + if (!RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.TrySave("the buff profile", path, + () => BuffProfileStore.Save(_edit, path), out string why)) + { + SetStatus($"Save failed: {why}", warning: true); + return; + } + _editPath = path; + _dirty = false; + RefreshFiles(); + _refreshProfileList?.Invoke(); + + string active = _settings.CurrentBuffProfilePath ?? ""; + if (thenActivate) + { + _requestActiveProfile?.Invoke(path); + SetStatus(_edit.Entries.Count == 0 + ? $"Saved {_edit.Name}. Buffing uses it, but it has no spells yet." + : $"Saved {_edit.Name}. Buffing uses it now.", warning: _edit.Entries.Count == 0); + } + else if (active.Equals(path, StringComparison.OrdinalIgnoreCase)) + { + SetStatus($"Saved {_edit.Name}. Buffing picks up the change within a few seconds."); + } + else + { + SetStatus($"Saved {_edit.Name}."); + } + } + + private void ConfirmDelete() + { + string? path = _editPath; + if (path == null) return; + Confirm($"Delete the profile '{Path.GetFileNameWithoutExtension(path)}'?", () => + { + if (!BuffProfileStore.Delete(path)) + { + SetStatus("Delete failed (file missing or in use).", warning: true); + return; + } + if ((_settings.CurrentBuffProfilePath ?? "").Equals(path, StringComparison.OrdinalIgnoreCase)) + _requestActiveProfile?.Invoke(""); + RefreshFiles(); + _refreshProfileList?.Invoke(); + StartNewProfile(); + SetStatus($"Deleted {Path.GetFileNameWithoutExtension(path)}."); + }); + } + + private void RefreshFiles() => _files = BuffProfileStore.ListFileNames(); + + private void RebuildEditKeys() + { + _editKeys.Clear(); + foreach (var e in _edit.Entries) _editKeys.Add(e.Key); + } + + private void SetStatus(string text, bool warning = false) + { + _status = text; + _statusIsWarning = warning; + } + + // ── Confirmation popup ────────────────────────────────────────────────── + + private void ConfirmIfDirty(string what, Action action) + { + if (_dirty) Confirm($"Discard unsaved changes and {what}?", action); + else action(); + } + + private void Confirm(string text, Action action) + { + _confirmText = text; + _confirmAction = action; + _openConfirm = true; + } + + private void RenderConfirmPopup() + { + if (_openConfirm) + { + ImGui.OpenPopup(ConfirmPopupId); + _openConfirm = false; + } + + bool keepOpen = true; + if (!ImGui.BeginPopupModal(ConfirmPopupId, ref keepOpen, ImGuiWindowFlags.AlwaysAutoResize)) return; + ImGui.TextUnformatted(_confirmText); + ImGui.Spacing(); + if (ImGui.Button("Yes##spconfirm", new Vector2(90, 0))) + { + Action? action = _confirmAction; + _confirmAction = null; + ImGui.CloseCurrentPopup(); + action?.Invoke(); + } + ImGui.SameLine(); + if (ImGui.Button("No##spconfirm", new Vector2(90, 0))) + { + _confirmAction = null; + ImGui.CloseCurrentPopup(); + } + ImGui.EndPopup(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs index e97cac2..8f5ff23 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs @@ -13,6 +13,8 @@ public static class DashWindows public static bool ShowWeapons; public static bool ShowLua; public static bool ShowDungeonMap; + /// ILT Hub window (persisted in ilt-hub.json, not in the combat profile). + public static bool ShowIltHub; } public sealed class LegacyUiSettings @@ -53,6 +55,20 @@ public sealed class LegacyUiSettings public bool NavRecoveryEnabled = true; public float NavOffTrackYards = 170f; // off track beyond this (never below 160: metas pull the bot up to ~159 yd away) public int NavMaxDetourAttempts = 3; // detours per waypoint before falling back to the escape ladder alone + // Dungeon patrol (/ra dunnav-patrol, Settings > Navigation > Dungeon Patrol; DungeonPatrolOptions). + // The defaults are the patrol as it was before these settings (2026-10-12). A running patrol + // is rebuilt when one changes (RynthAiCommands.TickDunPatrolReroute). + public int DunPatrolCoverage; // PatrolCoverage: 0 whole dungeon, 1 loops only, 2 everything + public int DunPatrolSkipDeadEnds = 10; // whole dungeon: dead-end areas of up to this many cells are skipped (0 = none) + public bool DunPatrolAvoidFloors = true; // lava/acid floor cells (HazardTextures.txt) kept out of the patrol + public float DunPatrolWallDistance = 1.0f; // metres every patrol point keeps from walls where there is room + public float DunPatrolLookInSize = 10.0f; // rooms this big (m) the patrol only skirts get a walk to their middle + // On: macro start, loading a Circular or Linear route, and nav taking over again after a + // pause that moved the character (combat, looting, buffing, doors) all head for the closest + // waypoint on the route. Off: a pause carries on to the waypoint it was heading for, a macro + // start keeps the last waypoint, and a loaded route starts at its first point. Hazard escapes + // and corpse runs always rejoin at the closest waypoint. + public bool NavResumeNearest = true; public float T2Speed = 1.0f; public float T2DistanceTo = 0.5f; public float T2ReissueMs = 2000f; @@ -69,6 +85,14 @@ public sealed class LegacyUiSettings public int LootProfileIdx; public int MetaProfileIdx = 1; + /// Buff profile buffing uses (BuffProfiles\*.json); empty = the built-in buff list. + /// Chosen under Loaded Files (Buffs) or with "Use for buffing" in the Spells window. + public string CurrentBuffProfilePath = string.Empty; + /// Index into the Buffs file list (0 = "Built-in"). + public int BuffProfileIdx; + /// The Spells window (/ra spells) is open. + public bool ShowSpellsWindow; + public bool EnableAutostack = true; public bool EnableAutocram = true; // VTank's ReadUnknownScrolls (default on): loot scrolls of spells the character doesn't @@ -77,9 +101,16 @@ public sealed class LegacyUiSettings public bool ReadUnknownScrolls = true; public bool EnableCombineSalvage = true; public bool CombineBagsDuringSalvage = true; + // Salvage (and combine bags) by sending the 0x027D salvage request straight to the server, no + // salvage panel on screen (engine API v82 SalvageDirect; default on, the panel when unsupported). + public bool SalvageWithoutPanel = true; public bool ShowTargetStaminaMana; + /// Mag-style item info (/ra iteminfo): on-select, per-field visibility, chat type, prefix. + /// Edited in the "RynthAi Item Info" window. + public RynthCore.Plugin.RynthAi.ItemInfo.MagItemInfoSettings ItemInfoSettings = new(); + public bool EnableMissileCrafting = true; public int MissileCraftAmmoThreshold = 1000; @@ -127,6 +158,12 @@ public sealed class LegacyUiSettings public int StaminaToHealthAt = 30; public int StaminaToHealthMinStamina = 20; public bool StopMacroOnDeath = false; + // Recall On Death (RynthAiPlugin.DeathRecall.cs): after a death while the macro ran, once + // respawned: 0 off, 1 cast DeathRecallSpellId, 2 use the inventory item named DeathRecallItem + // (exact name, else the first containing it). Travel Back To My Corpse starts after it. + public int DeathRecallMode = 0; + public int DeathRecallSpellId = 48; // Primary Portal Recall + public string DeathRecallItem = string.Empty; public bool StopMacroOnNoComponents = false; public bool StopLootingWhenPackFull = true; public bool StopMacroWhenPackFull = false; @@ -182,6 +219,8 @@ public sealed class LegacyUiSettings public const float FollowNavMinLowest = 0.5f, FollowNavMinHighest = 20f; public static float ClampFollowNavMin(float yards) => float.IsNaN(yards) ? 1.5f : Math.Clamp(yards, FollowNavMinLowest, FollowNavMinHighest); + /// Marker colours, waypoint HUD / labels, breadcrumb trail and recording options. + public NavOverlaySettings NavOverlay = new(); public float NavRingThickness = 6.0f; public float NavLineThickness = 6.0f; public float NavHeightOffset = 0.05f; @@ -228,12 +267,9 @@ public sealed class LegacyUiSettings /// on the way as usual, recover the corpse, then carry on. Off by default. /// public bool TravelToOwnCorpse; - /// - /// Selecting an item prints its details to chat (/ra iteminfo, Mag-Tools style), - /// identifying it first when needed. Items RynthAi selects itself are skipped. On by default. - /// - public bool ItemInfoOnSelect = true; public bool LootOnlyRareCorpses; + /// Also pick up loose ground items that match the loot profile, within the corpse max range. + public bool EnableGroundLoot; public bool PeaceModeWhenIdle = true; public bool RebuffWhenIdle; /// @@ -260,6 +296,23 @@ public sealed class LegacyUiSettings /// public bool CastBuffsOverItemBuffs = true; /// + /// In a buff pass, send the next buff as soon as the server answers the last one with + /// UseDone(0), without waiting for the client to finish the cast's recoil animation + /// (Combat/BuffCastChain.cs). Every other gate stays, and a refusal turns it off for the + /// rest of the pass. On by default; off = every buff waits for the animation (the + /// behaviour without the chain). A profile saved before this setting existed loads it as on. + /// + public bool FastBuffChain = true; + /// + /// Leave out the weapon enchantments this character has no use for: Blood Drinker / Heart Seeker / + /// Swift Killer without a melee or missile weapon (listed or in hand), Spirit Drinker / Hermetic + /// Link without a wand (listed, in hand, or the pack wand buffing would wield), Defender without + /// either. Also reports, once per run, what was left out. On by default; a profile saved before + /// this setting existed loads it as on. Off = the weapon enchantments are cast regardless of + /// listed weapons. A mastery for an untrained skill is never cast, whatever this says. + /// + public bool SkipUnusableBuffs = true; + /// /// Buff base names the player unticked in Buffing settings (the Protections and Banes grid, /// e.g. "Fire Protection Self", "Flame Bane"): left out of the buff list, so never cast and /// never waited on. Empty = every buff on, which is also what a profile saved before this @@ -297,6 +350,15 @@ public sealed class LegacyUiSettings /// public bool YieldToVTank = true; + /// + /// Server Features (Settings > Misc): world names that turn on the ILT Hub, the Skills + /// panel's Progression planners and the attribute raiser ('*' wildcard, case-insensitive). + /// See IltHub/ServerFeatureGate. A profile saved before this existed loads the defaults. + /// + public List FeatureServerNames { get; set; } = new(IltHub.ServerFeatureGate.DefaultServerNames); + /// Manual override: treat the current world as feature-enabled whatever its name. + public bool ForceServerFeatures; + public int BlacklistAttempts = 3; public int BlacklistTimeoutSec = 30; /// @@ -332,6 +394,30 @@ public sealed class LegacyUiSettings public int SpellCastIntervalMs = 400; + /// + /// Stuck-cast breaker (Plugins/Shared/ActionPacer.cs): the longest a cast may stay unanswered + /// (ms from the send; no result, no UseDone) before it is broken with a jump (a Peace mode + /// request when the engine can't jump). It fires sooner, about 2 s past the spell's normal + /// cycle, when that is shorter. Nothing is cast meanwhile once the server says 'too busy'. + /// 0 = no breaker. + /// + public int StuckCastBreakMs = 8000; + + /// + /// Recovery vitals (Heal Self, Stamina to Health, Revitalize, Stamina to Mana) refused for + /// "not enough mana" are tried again after this many ms, for a better Mana Conversion roll + /// (ACE rolls the cost on every attempt and a refusal costs nothing). Clamped to 200..5000; + /// at most 5 tries a second and 20 refusals in a row, then the old 15 s family rest. + /// + public int RecoveryRetryMs = 200; + + /// + /// HP failsafe: at or under Emergency Heal At with heals failing for a while, the stuck-cast + /// breaker runs and the heal is tried again; when that fails too, recall to the lifestone. + /// Off: the breaker still runs, no recall. + /// + public bool HpFailsafeRecall = true; + /// /// Minimum delay between offensive (war/void) COMBAT spell casts, in ms. /// Combat magic uses this instead of so @@ -484,6 +570,8 @@ public sealed class LegacyUiSettings public List MonsterRules { get; set; } = new(); public List ItemRules { get; set; } = new(); + /// Loose ammo the monster rules can prefer. Edited by the local monsters window. + public List AmmoRules { get; set; } = new(); public List ConsumableRules { get; set; } = new(); public List BuffRules { get; set; } = new(); public List MetaRules { get; set; } = new(); @@ -691,6 +779,8 @@ public sealed class MonsterRule /// 2 Shield, 3 Offhand weapon, 4 None (OffhandRules.Rule*); any other value is a listed /// item to wield there (the old per-rule picker). public int OffhandId { get; set; } + /// Optional loose ammo stack id for missile combat while this rule matches (0 = auto). + public int PreferredAmmoItemId { get; set; } public string PetDamage { get; set; } = "PAuto"; /// Debuffs the player typed in (Damage panel), comma separated: a spell's base /// name ("Corrosion Vulnerability Other") casts its best known tier; a full name casts as is. @@ -706,6 +796,11 @@ public sealed class BuffRule public sealed class ItemRule { + /// Action string for a listed weapon (VirindiTank import and the ILT gear importer). + public const string WeaponAction = "Weapon"; + /// Action string for a listed shield. + public const string ShieldAction = "Shield"; + public int Id { get; set; } public string Name { get; set; } = string.Empty; public string Action { get; set; } = "Loot"; @@ -715,6 +810,18 @@ public sealed class ItemRule /// (not known, or an entry from before sources were kept). public string ElementSource { get; set; } = ""; public bool KeepBuffed { get; set; } = true; + + /// True when this row is a shield (off hand), not a main-hand weapon. + public bool IsShield() => string.Equals(Action, ShieldAction, StringComparison.OrdinalIgnoreCase); +} + +/// Loose ammo the monster rules can prefer (bow, crossbow, atlatl, or Auto). +public sealed class AmmoRule +{ + public int Id { get; set; } + public string Name { get; set; } = string.Empty; + /// Bow, Crossbow, Atlatl, or Auto (match any launcher). + public string Category { get; set; } = "Auto"; } /// JSON wire-format types used by the engine-side Avalonia MonstersPanel. @@ -787,6 +894,20 @@ public sealed class NavBridgePayload public int ActiveNavIndex { get; set; } public List NavFiles { get; set; } = new(); public List Points { get; set; } = new(); + /// Map editing commands understood (NavMapEdit.Version): addPointAt, movePointTo, + /// setActive. The engine's Dungeon Map only offers editing when this is 1 or more. + public int MapEdit { get; set; } + /// NavOverlaySettings.TrackBreadcrumbs (Nav panel "Breadcrumbs" toggle). + public bool TrackBreadcrumbs { get; set; } + /// NavOverlaySettings.ShowRouteMarkers (Nav panel "Route overlay" toggle). + public bool ShowRouteOverlay { get; set; } + /// Route recording is on (/ra navrec). + public bool IsRecording { get; set; } + /// Breadcrumb trail since the last teleport: point count and walked yards. + public int TrailPoints { get; set; } + public double TrailYards { get; set; } + /// Result of the last route edit ("Route reversed."), empty once it is a few seconds old. + public string EditStatus { get; set; } = string.Empty; } /// One-shot command sent from the Avalonia NavPanel to the plugin. @@ -800,6 +921,15 @@ public sealed class NavCommand public int InsertAt { get; set; } = -1; public string NavName { get; set; } = string.Empty; public string Text { get; set; } = string.Empty; // addChat: the command or text + public double NS { get; set; } // addPointAt / movePointTo (nav coords) + public double EW { get; set; } + public double Z { get; set; } // nav Z (world Z / 240) + public bool On { get; set; } // setBreadcrumbs / setRouteOverlay / setRecording + public List Indices { get; set; } = new(); // movePoints / duplicatePoints / deletePoints + public int Delta { get; set; } // movePoints: -1 up, +1 down + public double Seconds { get; set; } // addPause + public double Yards { get; set; } // simplifyRoute tolerance + public bool Reverse { get; set; } // trailToRoute: backtrack (walk the trail in reverse) } /// Bridge payload for the engine-side Avalonia SettingsPanel. @@ -824,8 +954,20 @@ public sealed class SettingsBridgePayload public bool PeaceModeWhenIdle { get; set; } public bool StartMacroOnLogin { get; set; } public bool PatrolOnLogin { get; set; } + // Dungeon patrol. Nullable: an engine that predates them doesn't send them, and its save + // must leave them alone. + public int? DunPatrolCoverage { get; set; } + public int? DunPatrolSkipDeadEnds { get; set; } + public bool? DunPatrolAvoidFloors { get; set; } + public float? DunPatrolWallDistance { get; set; } + public float? DunPatrolLookInSize { get; set; } // Absent from an older engine's payload: must not read as off. public bool YieldToVTank { get; set; } = true; + // Server Features: the list travels as one comma-separated string (the engine's text row). + public string FeatureServerNames { get; set; } = string.Join(", ", IltHub.ServerFeatureGate.DefaultServerNames); + public bool ForceServerFeatures { get; set; } + // Read-only status line for Settings > Misc (ignored when the engine sends it back). + public string ServerFeaturesStatus { get; set; } = string.Empty; public bool EnableRaycasting { get; set; } public bool UseArcs { get; set; } public float BowArcVelocity { get; set; } @@ -856,6 +998,10 @@ public sealed class SettingsBridgePayload public int StaminaToHealthMinStamina { get; set; } = 20; public bool StopMacroOnDeath { get; set; } public bool StopMacroOnNoComponents { get; set; } + // Absent from an older engine: null keeps the plugin's values. + public int? DeathRecallMode { get; set; } + public int? DeathRecallSpellId { get; set; } + public string? DeathRecallItem { get; set; } public bool StopLootingWhenPackFull { get; set; } public bool StopMacroWhenPackFull { get; set; } public int RestamAt { get; set; } @@ -921,6 +1067,7 @@ public sealed class SettingsBridgePayload // Absent from an older engine: -1 / null keep the plugin's value. public int NavLabelMode { get; set; } = -1; public bool? NavGuideLine { get; set; } + public bool? NavResumeNearest { get; set; } public bool OpenDoors { get; set; } public float OpenDoorRange { get; set; } public bool AutoUnlockDoors { get; set; } @@ -949,6 +1096,7 @@ public sealed class SettingsBridgePayload // Nullable: an engine that predates the setting doesn't send it, and a save from its // Settings face must leave the setting alone rather than force it either way. public bool? CastBuffsOverItemBuffs { get; set; } + public bool? SkipUnusableBuffs { get; set; } // Null (absent) likewise leaves the unticked prots/banes alone; an empty list ticks them all. public List? DisabledBuffs { get; set; } public int BuffMinSkillLevelTier1 { get; set; } @@ -978,11 +1126,13 @@ public sealed class SettingsBridgePayload public bool? LootOwnCorpse { get; set; } public bool? EscapeHazards { get; set; } public bool? TravelToOwnCorpse { get; set; } + // Item info: describe an item in chat when it is selected (ItemInfoSettings.OnSelect). public bool? ItemInfoOnSelect { get; set; } public bool EnableAutostack { get; set; } public bool ReadUnknownScrolls { get; set; } = true; // absent from an older engine: keep the default public bool EnableCombineSalvage { get; set; } public bool CombineBagsDuringSalvage { get; set; } + public bool? SalvageWithoutPanel { get; set; } // absent from an older engine: unchanged public int LootInterItemDelayMs { get; set; } public int LootContentSettleMs { get; set; } public int LootEmptyCorpseMs { get; set; } @@ -1012,6 +1162,19 @@ public sealed class SettingsBridgePayload // The off hand (only when the sender includes them; today's engine Settings face doesn't). public string? OffhandDefault { get; set; } public bool? PreferDualWield { get; set; } + + // Ground loot (GroundLootController; also /ra groundloot on|off). + public bool EnableGroundLoot { get; set; } + + // Diagnostics. Stored per PC in Logs\Diagnostics\diagnostics.json (RynthLog), not in + // the character profile; applied only when a value differs, so a save of other + // settings doesn't rewrite that file. + public bool DiagDebugToChat { get; set; } + public bool DiagFileLogAll { get; set; } = true; + /// Every trace category as "Name=Level" joined by ','; Level 0 = Off, 1 = Trace, 2 = Info. + public string DiagCategories { get; set; } = string.Empty; + /// Read-only: the diagnostics folder, shown under the switches. + public string DiagFolder { get; set; } = string.Empty; } public enum MetaConditionType diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyWeaponsUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyWeaponsUi.cs index 0d17fbf..d768450 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyWeaponsUi.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyWeaponsUi.cs @@ -136,27 +136,49 @@ internal sealed class LegacyWeaponsUi } /// - /// Removes weapons and consumables this character has nothing of, by id or by - /// name: entries a profile picked up from another character. Returns their names. + /// Removes weapons and consumables this character has nothing of: entries a profile + /// picked up from another character. Returns their names. See . /// - public List PruneNotOwned(IReadOnlyList inventory) + public List PruneNotOwned(IReadOnlyList inventory) => CleanMissing(inventory).Removed; + + /// + /// Clears out weapons and consumables whose item is no longer in + /// (owned items: main pack, side packs, wielded gear). + /// An entry whose item is gone, but with an unlisted item of the same name in the pack + /// (a new stack of kits, a replacement weapon), is re-pointed at that item instead of + /// removed. Returns the names removed and the names re-pointed. + /// + public (List Removed, List Relinked) CleanMissing(IReadOnlyList inventory) { - var ids = new HashSet(inventory.Select(w => w.Id)); - var names = new HashSet(inventory.Select(w => w.Name), StringComparer.OrdinalIgnoreCase); - var removed = new List(); - _settings.ItemRules.RemoveAll(r => + var removed = new List(); + var relinked = new List(); + CleanList(_settings.ItemRules, r => r.Id, (r, id) => r.Id = id, r => r.Name, inventory, removed, relinked); + CleanList(_settings.ConsumableRules, r => r.Id, (r, id) => r.Id = id, r => r.Name, inventory, removed, relinked); + return (removed, relinked); + } + + private static void CleanList(List rules, Func getId, Action setId, Func getName, + IReadOnlyList inventory, List removed, List relinked) + { + var owned = new HashSet(inventory.Select(w => w.Id)); + // Items already listed by a live entry: a gone entry is never pointed at one of them. + var listed = new HashSet(rules.Select(getId).Where(owned.Contains)); + rules.RemoveAll(r => { - bool gone = !ids.Contains(r.Id) && !names.Contains(r.Name); - if (gone) removed.Add(r.Name); - return gone; + if (owned.Contains(getId(r))) return false; + string name = getName(r); + var spare = inventory.FirstOrDefault(w => !listed.Contains(w.Id) + && string.Equals(w.Name, name, StringComparison.OrdinalIgnoreCase)); + if (spare != null) + { + setId(r, spare.Id); + listed.Add(spare.Id); + relinked.Add(name); + return false; + } + removed.Add(name); + return true; }); - _settings.ConsumableRules.RemoveAll(r => - { - bool gone = !ids.Contains(r.Id) && !names.Contains(r.Name); - if (gone) removed.Add(r.Name); - return gone; - }); - return removed; } internal static string? PackConsumableType(WorldObject wo) diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavCoordinateHelper.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavCoordinateHelper.cs index de89dc3..6c3f27f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavCoordinateHelper.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavCoordinateHelper.cs @@ -5,6 +5,9 @@ namespace RynthCore.Plugin.RynthAi.LegacyUi; internal static class NavCoordinateHelper { + /// World Z from the player pose is divided by this to match nav-file height. + public const double NavZScale = 240.0; + public static bool TryGetNavCoords(RynthCoreHost host, out double northSouth, out double eastWest) { northSouth = 0; @@ -19,6 +22,17 @@ internal static class NavCoordinateHelper return false; } + /// Current position as a waypoint would store it (NS/EW map coords + Z in nav units). + public static bool TryGetNavPosition(RynthCoreHost host, out double northSouth, out double eastWest, out double navZ) + { + navZ = 0; + if (!TryGetNavCoords(host, out northSouth, out eastWest)) + return false; + if (host.HasGetPlayerPose && host.TryGetPlayerPose(out _, out _, out _, out float z, out _, out _, out _, out _)) + navZ = z / NavZScale; + return true; + } + internal static bool TryConvertPoseToCoords(uint objCellId, float x, float y, out double northSouth, out double eastWest) { northSouth = 0; diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavMapEdit.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavMapEdit.cs new file mode 100644 index 0000000..7718ce1 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavMapEdit.cs @@ -0,0 +1,95 @@ +// NavMapEdit.cs - route edits from the engine's Dungeon Map (click on the map to add a point, +// drag a point to move it, "Set as next target"). The map sends coordinates it worked out from +// the floor under the cursor, so these commands carry NS / EW / Z instead of using the player's +// position like addWaypoint does: +// +// addPointAt {NS, EW, Z, AddMode, InsertAt} a Point; AddMode/InsertAt as addWaypoint +// (0 = end; 2 = after InsertAt; 1 = before it) +// movePointTo {Index, NS, EW, Z} moves step Index; its type and every other +// field (spell, pause, chat text, portal) stay +// setActive {Index} the step navigation goes to next +// +// NS / EW are the usual nav coordinates (EW = (worldX / 24 - 1019.5) / 10, worldX = landblock +// X * 192 + local X); Z is nav Z (world Z / 240), as addWaypoint stores it. +// +// Compatibility: the nav JSON says MapEdit = Version, so the engine only offers map editing +// when RynthAi understands these commands. Older RynthAi builds ignore unknown commands. +// The logic is static over the settings so the host tests can run it without a renderer. +using System; + +namespace RynthCore.Plugin.RynthAi.LegacyUi; + +internal static class NavMapEdit +{ + /// What RynthPluginGetNavJson reports as MapEdit (0 / missing = no map editing). + public const int Version = 1; + + /// The nav coordinate range of Dereth (and a little more); anything else is refused. + private const double MaxCoord = 110.0; + + /// Nav Z range accepted (world Z of +-24000, far beyond any real floor). + private const double MaxZ = 100.0; + + public static bool Handles(string? cmd) => cmd is "addPointAt" or "movePointTo" or "setActive"; + + public enum Result { None, RouteChanged, ActiveChanged } + + /// + /// Applies one map command to 's route. RouteChanged: the caller saves + /// the route file (TryAutoSaveNav); ActiveChanged: the caller saves the settings. + /// says what happened (or why nothing did), for the log. + /// + public static Result Apply(LegacyUiSettings s, NavCommand cmd, out string status) + { + var pts = s.CurrentRoute.Points; + switch (cmd.Cmd) + { + case "addPointAt": + { + if (!ValidCoords(cmd.NS, cmd.EW, cmd.Z, out status)) return Result.None; + var pt = new NavPoint { Type = NavPointType.Point, NS = cmd.NS, EW = cmd.EW, Z = cmd.Z }; + int at = InsertIndex(pts.Count, cmd.AddMode, cmd.InsertAt); + pts.Insert(at, pt); + // Keep navigation heading for the same step: a point put in before it shifts it down. + if (at <= s.ActiveNavIndex && pts.Count > 1) s.ActiveNavIndex++; + status = $"Added point {at}."; + return Result.RouteChanged; + } + case "movePointTo": + { + if (cmd.Index < 0 || cmd.Index >= pts.Count) { status = $"No step {cmd.Index}."; return Result.None; } + if (!ValidCoords(cmd.NS, cmd.EW, cmd.Z, out status)) return Result.None; + NavPoint p = pts[cmd.Index]; + p.NS = cmd.NS; p.EW = cmd.EW; p.Z = cmd.Z; + status = $"Moved step {cmd.Index}."; + return Result.RouteChanged; + } + case "setActive": + if (cmd.Index < 0 || cmd.Index >= pts.Count) { status = $"No step {cmd.Index}."; return Result.None; } + s.ActiveNavIndex = cmd.Index; + status = $"Active waypoint: {cmd.Index}."; + return Result.ActiveChanged; + } + status = string.Empty; + return Result.None; + } + + /// Where a new point goes: 0 = the end; 1 = before InsertAt; 2 = after it (end when InsertAt < 0). + internal static int InsertIndex(int count, int addMode, int insertAt) + { + if (addMode == 0 || count == 0 || insertAt < 0) return count; + return addMode == 1 ? Math.Min(insertAt, count) : Math.Min(insertAt + 1, count); + } + + private static bool ValidCoords(double ns, double ew, double z, out string status) + { + if (!double.IsFinite(ns) || !double.IsFinite(ew) || !double.IsFinite(z) + || Math.Abs(ns) > MaxCoord || Math.Abs(ew) > MaxCoord || Math.Abs(z) > MaxZ) + { + status = "Refused: coordinates out of range."; + return false; + } + status = string.Empty; + return true; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavOverlaySettings.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavOverlaySettings.cs new file mode 100644 index 0000000..84c3e8d --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavOverlaySettings.cs @@ -0,0 +1,109 @@ +// NavOverlaySettings.cs — display + recording options for the Navigation window: +// route marker colours, the on-screen waypoint HUD / labels, the guide line to the +// active waypoint, the breadcrumb trail and route recording. +// +// Stored per character inside LegacyUiSettings.NavOverlay (public fields, serialized via +// RynthAiJsonContext IncludeFields). Colours are D3D9 ARGB (0xAARRGGBB). +using System; + +namespace RynthCore.Plugin.RynthAi.LegacyUi; + +/// Persisted Navigation display / breadcrumb / recording options. +public sealed class NavOverlaySettings +{ + // ── Route markers (3D rings + lines) ───────────────────────────────────── + /// + /// Route overlay master switch (Nav panel "Route overlay"): the route's rings and connecting + /// lines, the waypoint labels and the guide line. The waypoint HUD window has its own switch. + /// + public bool ShowRouteMarkers = true; + /// Upper bound on route points drawn around the active waypoint. + public int MaxRouteMarkers = 128; + public uint ColorRing = 0xFF00FFFF; // cyan + public uint ColorActiveRing = 0xFFFF4444; // red + public uint ColorLine = 0xFF0088FF; // blue + + // ── Waypoint HUD + on-screen labels ────────────────────────────────────── + /// Small movable window: active waypoint, distance, direction arrow, next step. + public bool ShowHud = true; + /// Only show the HUD while navigation is enabled (otherwise whenever a route is loaded). + public bool HudOnlyWhileNavigating; + /// "#12 · 34yd" text drawn over the upcoming waypoints in the 3D view. + public bool ShowWaypointLabels = true; + /// How many upcoming waypoints get a label (active included). + public int LabelsAhead = 3; + /// Line from the player to the active waypoint (UB "breadcrumb" line). + public bool ShowGuideLine = true; + public uint ColorGuide = 0xFFFFDC28; // yellow + + // ── Breadcrumb trail ───────────────────────────────────────────────────── + /// + /// Record where the character walks, independent of any route (Nav panel "Breadcrumbs"). + /// While off, the trail is neither extended nor drawn. + /// + public bool TrackBreadcrumbs = true; + /// Draw the recorded trail on the ground. + public bool ShowBreadcrumbs = true; + /// Minimum distance between trail samples, yards. + public float BreadcrumbSpacingYards = 3f; + /// Trail length cap (oldest samples drop off). + public int BreadcrumbMaxPoints = 400; + /// Trail segments farther than this from the player are not drawn, yards. + public float BreadcrumbDrawRangeYards = 150f; + /// Older trail segments fade out. + public bool BreadcrumbFade = true; + public uint ColorBreadcrumb = 0xFFFF9A2E; // orange + + // ── Route recording ────────────────────────────────────────────────────── + /// Distance between auto-added Point waypoints while recording, yards. + public float RecordSpacingYards = 5f; + /// On a teleport while recording, add a Portal step for the portal used just before it. + public bool RecordPortals = true; + /// Pause added after an auto-recorded portal step, ms (0 = none). + public int RecordPauseAfterPortalMs = 1500; + + // Effective visibility (methods, not properties, so the settings JSON doesn't gain fields). + + /// Breadcrumb trail is drawn: tracking on and the trail display on. + public bool TrailVisible() => TrackBreadcrumbs && ShowBreadcrumbs; + + /// Guide line to the active waypoint is drawn (part of the route overlay). + public bool GuideLineVisible() => ShowRouteMarkers && ShowGuideLine; + + /// Waypoint labels are drawn (part of the route overlay). + public bool LabelsVisible() => ShowRouteMarkers && ShowWaypointLabels; + + /// Clamp values a hand-edited or older profile could carry out of range. + public void Sanitize() + { + MaxRouteMarkers = Math.Clamp(MaxRouteMarkers, 8, 128); + LabelsAhead = Math.Clamp(LabelsAhead, 1, 10); + BreadcrumbSpacingYards = Clamp(BreadcrumbSpacingYards, 0.5f, 50f, 3f); + BreadcrumbMaxPoints = Math.Clamp(BreadcrumbMaxPoints, 20, 2000); + BreadcrumbDrawRangeYards = Clamp(BreadcrumbDrawRangeYards, 20f, 500f, 150f); + RecordSpacingYards = Clamp(RecordSpacingYards, 1f, 50f, 5f); + RecordPauseAfterPortalMs = Math.Clamp(RecordPauseAfterPortalMs, 0, 30000); + } + + /// Display defaults (recording / trail options keep their values). + public void ResetColors() + { + var d = new NavOverlaySettings(); + ColorRing = d.ColorRing; ColorActiveRing = d.ColorActiveRing; ColorLine = d.ColorLine; + ColorGuide = d.ColorGuide; ColorBreadcrumb = d.ColorBreadcrumb; + } + + private static float Clamp(float v, float min, float max, float fallback) + => float.IsNaN(v) ? fallback : Math.Clamp(v, min, max); + + /// D3D9 ARGB → ImGui ABGR (swap red and blue). + public static uint ArgbToImGui(uint argb) + => (argb & 0xFF00FF00) | ((argb & 0x00FF0000) >> 16) | ((argb & 0x000000FF) << 16); + + /// Same colour with its alpha scaled by (0..1). + public static uint ScaleAlpha(uint argb, float factor) + { + uint a = (uint)Math.Clamp((argb >> 24) * factor, 0f, 255f); + return (a << 24) | (argb & 0x00FFFFFF); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavRouteEditing.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavRouteEditing.cs new file mode 100644 index 0000000..8e37f83 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavRouteEditing.cs @@ -0,0 +1,229 @@ +// NavRouteEditing.cs — route edit operations for the Navigation window (UB-IT nav builder +// parity plus a few extras): remove / duplicate / move selected, reverse, snap-insert on the +// path, simplify, nearest waypoint, trail → route. +// +// The nav engine reads CurrentRoute.Points on the plugin tick thread while the window edits +// on the render thread, so structural edits never mutate the live list: they build a new +// list and swap the reference (atomic), keeping the active waypoint on the same NavPoint. +using System; +using System.Collections.Generic; + +namespace RynthCore.Plugin.RynthAi.LegacyUi; + +internal static class NavRouteEditing +{ + /// Nav map units → yards (the engine's distance scale). + public const double NavToYards = 240.0; + + public static double DistanceYards(double ns1, double ew1, double ns2, double ew2) + { + double dn = ns2 - ns1, de = ew2 - ew1; + return Math.Sqrt(dn * dn + de * de) * NavToYards; + } + + /// + /// Copy-on-write edit of the current route. receives a private copy + /// and returns the new list; the active waypoint follows its NavPoint (or is clamped when + /// that point was removed). + /// + public static void Apply(LegacyUiSettings s, Func, List> edit) + { + var route = s.CurrentRoute; + var old = route.Points; + int oldActive = s.ActiveNavIndex; + NavPoint? active = oldActive >= 0 && oldActive < old.Count ? old[oldActive] : null; + + var next = edit(new List(old)); + route.Points = next; + + int ai = active != null ? next.IndexOf(active) : -1; + s.ActiveNavIndex = ai >= 0 ? ai : Math.Clamp(oldActive, 0, Math.Max(0, next.Count - 1)); + } + + /// Field-for-field copy (NavPoint is a plain DTO). + public static NavPoint Clone(NavPoint p) => new() + { + Type = p.Type, NS = p.NS, EW = p.EW, Z = p.Z, + SpellId = p.SpellId, PauseTimeMs = p.PauseTimeMs, ChatCommand = p.ChatCommand, + TargetName = p.TargetName, ObjectClass = p.ObjectClass, IsTie = p.IsTie, VendorId = p.VendorId, + PortalExitNS = p.PortalExitNS, PortalExitEW = p.PortalExitEW, PortalExitZ = p.PortalExitZ, + }; + + public static List Remove(List list, HashSet sel) + { + list.RemoveAll(sel.Contains); + return list; + } + + /// Each selected point gets a copy right after it; returns the copies via . + public static List Duplicate(List list, HashSet sel, List copies) + { + var result = new List(list.Count + sel.Count); + foreach (var p in list) + { + result.Add(p); + if (!sel.Contains(p)) continue; + var c = Clone(p); + result.Add(c); + copies.Add(c); + } + return result; + } + + /// Moves every selected point one slot up (delta -1) or down (+1), keeping their order; + /// a selected point already at the edge (or blocked by another selected one there) stays put. + public static List Move(List list, HashSet sel, int delta) + { + if (delta < 0) + { + for (int i = 1; i < list.Count; i++) + if (sel.Contains(list[i]) && !sel.Contains(list[i - 1])) + (list[i - 1], list[i]) = (list[i], list[i - 1]); + } + else + { + for (int i = list.Count - 2; i >= 0; i--) + if (sel.Contains(list[i]) && !sel.Contains(list[i + 1])) + (list[i + 1], list[i]) = (list[i], list[i + 1]); + } + return list; + } + + public static List Reverse(List list) + { + list.Reverse(); + return list; + } + + /// Nearest travel Point to the given position, or -1 when the route has none. + public static int NearestPointIndex(IReadOnlyList list, double ns, double ew) + { + int best = -1; + double bestD = double.MaxValue; + for (int i = 0; i < list.Count; i++) + { + var p = list[i]; + if (p.Type != NavPointType.Point) continue; + double d = DistanceYards(ns, ew, p.NS, p.EW); + if (d < bestD) { bestD = d; best = i; } + } + return best; + } + + /// + /// UB-IT "snap to path": projects the position onto every Point→Point leg (NS/EW plane), + /// and inserts a Point at the closest spot (Z interpolated) before the leg's far end. + /// Refuses when the spot lands within of an existing point. + /// + public static bool TrySnapInsert(List list, double ns, double ew, double minGapYards, + out NavPoint? inserted, out string error) + { + inserted = null; + error = string.Empty; + int bestLeg = -1; + double bestDist = double.MaxValue, bestT = 0; + for (int i = 0; i + 1 < list.Count; i++) + { + NavPoint a = list[i], b = list[i + 1]; + if (a.Type != NavPointType.Point || b.Type != NavPointType.Point) continue; + double vn = b.NS - a.NS, ve = b.EW - a.EW; + double len2 = vn * vn + ve * ve; + double t = len2 < 1e-12 ? 0 : Math.Clamp(((ns - a.NS) * vn + (ew - a.EW) * ve) / len2, 0, 1); + double d = DistanceYards(ns, ew, a.NS + vn * t, a.EW + ve * t); + if (d < bestDist) { bestDist = d; bestLeg = i; bestT = t; } + } + if (bestLeg < 0) { error = "The route has no Point→Point leg to snap onto."; return false; } + + NavPoint pa = list[bestLeg], pb = list[bestLeg + 1]; + var p = new NavPoint + { + Type = NavPointType.Point, + NS = pa.NS + (pb.NS - pa.NS) * bestT, + EW = pa.EW + (pb.EW - pa.EW) * bestT, + Z = pa.Z + (pb.Z - pa.Z) * bestT, + }; + if (DistanceYards(p.NS, p.EW, pa.NS, pa.EW) < minGapYards || DistanceYards(p.NS, p.EW, pb.NS, pb.EW) < minGapYards) + { + error = $"Closest path spot is on waypoint {(bestT < 0.5 ? bestLeg : bestLeg + 1)} already."; + return false; + } + list.Insert(bestLeg + 1, p); + inserted = p; + return true; + } + + /// + /// Douglas–Peucker over each run of consecutive Points (action steps split runs and are + /// never touched; run endpoints are kept). Removes Points that deviate less than + /// from the simplified line. Returns the removed count. + /// + public static int Simplify(List list, double toleranceYards, NavPoint? keep) + { + var drop = new HashSet(); + int runStart = -1; + for (int i = 0; i <= list.Count; i++) + { + bool isPoint = i < list.Count && list[i].Type == NavPointType.Point; + if (isPoint && runStart < 0) runStart = i; + if (!isPoint && runStart >= 0) + { + if (i - 1 - runStart >= 2) + DouglasPeucker(list, runStart, i - 1, toleranceYards, drop); + runStart = -1; + } + } + if (keep != null) drop.Remove(keep); // never remove the active waypoint + list.RemoveAll(drop.Contains); + return drop.Count; + } + + private static void DouglasPeucker(List list, int first, int last, double tol, HashSet drop) + { + // Iterative stack so long recorded runs can't overflow the stack. + var stack = new Stack<(int, int)>(); + stack.Push((first, last)); + while (stack.Count > 0) + { + var (a, b) = stack.Pop(); + if (b - a < 2) continue; + double maxD = -1; + int maxI = -1; + for (int i = a + 1; i < b; i++) + { + double d = SegmentDistanceYards(list[i], list[a], list[b]); + if (d > maxD) { maxD = d; maxI = i; } + } + if (maxD > tol) + { + stack.Push((a, maxI)); + stack.Push((maxI, b)); + } + else + { + for (int i = a + 1; i < b; i++) drop.Add(list[i]); + } + } + } + + /// Horizontal distance from to segment a–b, yards. + private static double SegmentDistanceYards(NavPoint p, NavPoint a, NavPoint b) + { + double vn = b.NS - a.NS, ve = b.EW - a.EW; + double len2 = vn * vn + ve * ve; + double t = len2 < 1e-12 ? 0 : Math.Clamp(((p.NS - a.NS) * vn + (p.EW - a.EW) * ve) / len2, 0, 1); + return DistanceYards(p.NS, p.EW, a.NS + vn * t, a.EW + ve * t); + } + + /// Total walking length of the route's Point→Point legs, yards. + public static double PathLengthYards(IReadOnlyList list) + { + double total = 0; + for (int i = 0; i + 1 < list.Count; i++) + { + NavPoint a = list[i], b = list[i + 1]; + if (a.Type == NavPointType.Point && b.Type == NavPointType.Point) + total += DistanceYards(a.NS, a.EW, b.NS, b.EW); + } + return total; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavRouteParser.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavRouteParser.cs index 26d2c91..2fd75c5 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavRouteParser.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/NavRouteParser.cs @@ -139,6 +139,14 @@ public sealed class NavRouteParser /// A waypoint that is simply walked to (Point, Checkpoint). public static bool IsPlainWaypoint(NavPointType t) => t is NavPointType.Point or NavPointType.Checkpoint; + /// + /// Whether a freshly loaded route starts at [0] rather than at its nearest waypoint. + /// Follow and Once routes always do, so their opening Recall/Portal/Chat steps fire; + /// with NavResumeNearest off every route does. + /// + public static bool StartsAtFirstPoint(NavRouteType type, bool resumeNearest) + => !resumeNearest || type is NavRouteType.Follow or NavRouteType.Once; + /// /// Follow-type nav files (route type 3) name a character to follow instead of /// listing points: "uTank2 NAV 1.2", 3, name, id. Empty for other routes. @@ -277,6 +285,17 @@ public sealed class NavRouteParser public void Save(string filePath) { Directory.CreateDirectory(Path.GetDirectoryName(filePath) ?? "."); + // A .nav marked read-only can't be overwritten: clear that first (no dependencies here: + // this file is linked into RynthNav and test tools; RynthAi reports failures itself). + try + { + if (File.Exists(filePath)) + { + FileAttributes attrs = File.GetAttributes(filePath); + if ((attrs & FileAttributes.ReadOnly) != 0) File.SetAttributes(filePath, attrs & ~FileAttributes.ReadOnly); + } + } + catch { /* the write below fails and the caller reports why */ } using var writer = new StreamWriter(filePath, false); WriteTo(writer); diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/RynthAiJsonContext.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/RynthAiJsonContext.cs index d0289ee..f6ded28 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/RynthAiJsonContext.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/RynthAiJsonContext.cs @@ -17,6 +17,16 @@ namespace RynthCore.Plugin.RynthAi; [JsonSerializable(typeof(MetaRuleDto))] [JsonSerializable(typeof(MetaCommand))] [JsonSerializable(typeof(RynthCore.Plugin.RynthAi.Meta.MetaScheduleConfig))] +// UB seed, translation, diagnostics, ILT Hub, HUD and item info files persist through this +// context (NativeAOT cannot reflect). +[JsonSerializable(typeof(RynthCore.CreatureSeed.UbMobSeedFile))] +[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.Translate.TranslateSettings))] +[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.RynthLogConfig))] +[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.Huds.HudState))] +[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.IltHub.IltHubState))] +[JsonSerializable(typeof(System.Collections.Generic.List), TypeInfoPropertyName = "IltBankTransactionList")] +[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.IltHub.IltAugCostFile))] +[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.BuffProfile))] [JsonSourceGenerationOptions( WriteIndented = true, IncludeFields = true, diff --git a/Plugins/RynthCore.Plugin.RynthAi/Loot/LootEditorBridge.cs b/Plugins/RynthCore.Plugin.RynthAi/Loot/LootEditorBridge.cs index e75a3b3..d9724ee 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Loot/LootEditorBridge.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Loot/LootEditorBridge.cs @@ -133,6 +133,7 @@ internal sealed class LootEditorBridge } if (_session.Apply(cmd) == LootEditSession.Outcome.Saved) saved = _session.Path; + ReportWriteError(_session); } if (saved != null) _onSaved(saved); } @@ -256,12 +257,28 @@ internal sealed class LootEditorBridge d.Ok = true; if (!add) return d; - if (!s.InsertAndSave(draft.Rule, native, at)) return Refuse(d, s.Message); + if (!s.InsertAndSave(draft.Rule, native, at)) + { + ReportWriteError(s); + return Refuse(d, s.Message); + } d.Added = true; d.Message = $"Added loot rule '{draft.Rule.Name}' to {d.TargetFile}"; return d; } + /// + /// A save the disk refused (folder not writable, file in use, ...): the editor shows the + /// session's message; this adds the chat line (once per folder) and the log line with the + /// reason and the fix (Diagnostics/DataWriteGuard, 2026-10-13). + /// + private static void ReportWriteError(LootEditSession session) + { + Exception? error = session.TakeWriteError(); + if (error != null) + RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.Report("the loot profile", session.Path, error); + } + private static LootEditItemDraft Refuse(LootEditItemDraft d, string error) { d.Ok = false; diff --git a/Plugins/RynthCore.Plugin.RynthAi/Loot/SalvageManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Loot/SalvageManager.cs index 3b6c076..e79dbd1 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Loot/SalvageManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Loot/SalvageManager.cs @@ -29,6 +29,17 @@ namespace RynthCore.Plugin.RynthAi.Loot; /// First-open delays (400ms/600ms) let the panel animate open and the gmSalvageUI singleton /// hook fire before we make thiscall instance calls. Fast delays (50ms) apply once the panel /// has been opened at least once. +/// +/// Without the panel (2026-10-12, setting SalvageWithoutPanel, engine API v82 SalvageDirect): +/// the panel's Salvage button only ever sends one game action, 0x027D (UST, count, item ids), +/// and the engine can send it itself. Then a batch (up to +/// items, plus matching under-full bags up to the engine's 100 ids) is one request: +/// Idle → SalvageDirect(UST, items + bags) → poll until the items leave the pack → summary +/// No panel on screen, no open/add delays. A request that changes nothing (no item left the +/// pack) is tried once through the panel, and the log says why; after +/// such batches in a row that the panel then salvaged, the +/// rest of the session uses the panel. The combine sweep sends each bag group the same way +/// (ACE merges salvage bags listed in a salvage request), with the same one panel retry. /// public sealed class SalvageManager { @@ -50,6 +61,17 @@ public sealed class SalvageManager /// Most items added to the panel for one Salvage press. internal const int MaxBatchItems = 20; + /// Most items in one salvage request without the panel. ACE makes new bags per request + /// (it never tops up a bag already in the pack), so bigger batches leave fewer partial bags; the + /// matching under-full bags ride along up to the engine's 100 ids. + internal const int MaxDirectBatchItems = 50; + /// A request without the panel is first checked this long after it was sent... + internal const long DirectSettleMs = 150; + /// ...and polled until its items leave the pack, up to this long. + internal const long DirectResultMaxWaitMs = 3_000; + /// After this many batches in a row where the request without the panel changed nothing + /// and the panel then salvaged, the session goes back to the panel. + internal const int DirectOffAfterFailures = 3; /// A batch starts this long after the last item was queued (or when a full batch is /// waiting), so one corpse's salvage goes in one panel cycle instead of one cycle per item. internal const long GatherMs = 1_000; @@ -86,6 +108,20 @@ public sealed class SalvageManager private int _batchAddFailures; private readonly SkipNotes _batchSkips = new(); + // Salvage without the panel: how the batch in flight went out, the bags sent along, the + // salvage bags in the pack before it, and the server's salvage chat seen meanwhile. + private bool _batchDirect; + private bool _batchPanelFallback; + private string _batchFallbackWhy = string.Empty; + private readonly List _batchBags = new(); + private HashSet? _batchBagsBefore; + private readonly List _salvageChat = new(); + private int _directPanelWorkedStreak; + private bool _directOff; + private string _directOffReason = string.Empty; + private int _directRequests; + private int _directFallbacks; + // Session totals for /ra salvstate. private int _itemsSalvagedThisSession; private int _itemsSkippedThisSession; @@ -107,6 +143,9 @@ public sealed class SalvageManager // Execute. After the result delay, we count how many of these are still in // the cache to decide whether the server actually merged them. private List? _combineGroupSnapshot; + // The current group went out without the panel / is the panel retry of one that did. + private bool _combineGroupDirect; + private bool _combineGroupPanelRetry; // Polling deadline for verification. The salvage delete event from the // server can arrive 500ms-1s after Execute on busy servers; we keep @@ -196,6 +235,55 @@ public sealed class SalvageManager /// Returns true while a salvage operation is in flight. public bool IsBusy => _phase != Phase.Idle || _queue.Count > 0; + private bool PanelAvailable => _host.HasSalvagePanel && _host.HasUseObject; + + /// Salvage requests go out without the panel: the setting is on, the engine has + /// SalvageDirect (API v82) and the session hasn't gone back to the panel. + internal bool UseDirect => _settings.SalvageWithoutPanel && _host.HasSalvageDirect && !_directOff; + + /// + /// Chat from the game (RynthAiPlugin.OnChatWindowText). While a batch or a combine group is in + /// flight, the server's salvage lines are kept for the summary: "You obtain ... using your + /// knowledge of ...", and the refusals ("You do not own that salvage tool!", "That is not a + /// salvaging tool.", "...not suitable for salvaging.", "The list of items you are attempting to + /// salvage is invalid.", "You cannot salvage items that you are trading!"). + /// + public void OnChatWindowText(string? text) + { + // A batch is being sent (_batch filled; the reply can beat the phase change) or is in flight. + if (string.IsNullOrEmpty(text) || (_phase == Phase.Idle && _batch.Count == 0) || _salvageChat.Count >= 8) return; + if (text.Contains("using your knowledge of", StringComparison.OrdinalIgnoreCase) + || text.Contains("salvage tool", StringComparison.OrdinalIgnoreCase) + || text.Contains("salvaging tool", StringComparison.OrdinalIgnoreCase) + || text.Contains("suitable for salvaging", StringComparison.OrdinalIgnoreCase) + || text.Contains("attempting to salvage", StringComparison.OrdinalIgnoreCase) + || text.Contains("cannot salvage", StringComparison.OrdinalIgnoreCase)) + _salvageChat.Add(text.Trim()); + } + + /// The kept salvage chat as a log fragment ("; server said: ..."), or "". + private string ChatNote() + { + if (_salvageChat.Count == 0) return string.Empty; + string first = _salvageChat[0].Length > 160 ? _salvageChat[0][..160] + "..." : _salvageChat[0]; + return $"; server said: \"{first}\"" + (_salvageChat.Count > 1 ? $" (+{_salvageChat.Count - 1} more)" : ""); + } + + /// True when a refusal (not a "You obtain" line) was seen. + private bool ChatSaidRefused() => _salvageChat.Any(l => !l.Contains("using your knowledge of", StringComparison.OrdinalIgnoreCase)); + + /// + /// True from the UST use until the salvage execute has gone out (a batch or a bag combine). + /// Meanwhile the client swallows a door or corpse use: no Use packet, no busy count, and the + /// open waited out its 5 s limit (in one log, 6 of 6 corpse opens sent 0-155 ms after the UST + /// use were lost; 4 of 4 sent after the execute were answered). Narrower than IsBusy, which + /// also covers a queued batch whose panel isn't open yet. + /// + public bool PanelPending => + _phase is Phase.OpeningPanel or Phase.AddingItems or Phase.ReadyToExecute + || (_phase == Phase.CombiningSalvage + && _combinePhase is CombinePhase.OpeningPanel or CombinePhase.AddingBags or CombinePhase.Salvaging); + /// /// Looting sent the pickup of an item whose rule says Salvage. Tracks it without queueing: /// the sweep queues it once it is in the pack, even if the pickup confirm never comes. @@ -266,7 +354,9 @@ public sealed class SalvageManager /// Called every game tick from RynthAiPlugin.OnTick. public void OnTick(int busyCount) { - if (!_host.HasSalvagePanel || !_host.HasUseObject) + // Nothing to salvage with (no panel calls, no SalvageDirect). A batch already in flight + // still finishes: its steps fail cleanly and the items go back in the queue. + if (_phase == Phase.Idle && !PanelAvailable && !UseDirect) return; long now = NowMs; @@ -356,11 +446,13 @@ public sealed class SalvageManager if (now < _idleRetryReadyAt) return; - // Let a corpse's worth of salvage gather so it goes in one panel cycle. - if (_queue.Count < MaxBatchItems && now - _lastEnqueueAt < GatherMs) + // Let a corpse's worth of salvage gather so it goes in one panel cycle (or one request). + bool direct = UseDirect; + int maxBatch = direct ? MaxDirectBatchItems : MaxBatchItems; + if (_queue.Count < maxBatch && now - _lastEnqueueAt < GatherMs) return; - if (!BuildBatch(now)) + if (!BuildBatch(now, maxBatch)) return; uint ustId = FindUst(); @@ -382,6 +474,84 @@ public sealed class SalvageManager _currentUstId = ustId; + if (direct) + { + SendDirectBatch(now); + return; + } + StartPanelCycle(now); + } + + /// + /// Sends the batch (plus matching under-full bags when CombineBagsDuringSalvage is on) as one + /// salvage request without the panel. Not sent at all (the engine refused, or its sender isn't + /// bound) → the panel takes this batch, and an engine that can't send turns the setting's + /// effect off for the session. + /// + private void SendDirectBatch(long now) + { + _batchBags.Clear(); + if (_settings.CombineBagsDuringSalvage) + _batchBags.AddRange(FindMatchingUnderFullBags(_batch, RynthCoreHost.MaxSalvageDirectItems - _batch.Count)); + _batchBagsBefore = SnapshotSalvageBagIds(); + _salvageChat.Clear(); + + var ids = new uint[_batch.Count + _batchBags.Count]; + _batch.CopyTo(ids, 0); + _batchBags.CopyTo(ids, _batch.Count); + int sent = _host.SalvageDirect(_currentUstId, ids); + if (sent <= 0) + { + string why = sent switch + { + -1 => "the engine's salvage sender isn't bound on this client", + -2 => "the engine is older than plugin API v82", + _ => "the engine refused the request", + }; + if (sent is -1 or -2) TurnDirectOff(why); + NoteError($"salvage without the panel not sent ({why})"); + _directFallbacks++; + _batchBags.Clear(); + _batchPanelFallback = true; + _batchFallbackWhy = "the request without the panel wasn't sent: " + why; + Log($"[Salvage] Batch {_batchNumber + 1}: salvage without the panel wasn't sent ({why}) — using the panel for these {_batch.Count} item(s)."); + StartPanelCycle(now); + return; + } + + _directRequests++; + _batchDirect = true; + _batchAdded.AddRange(_batch); + _batchBagsAdded = _batchBags.Count; + _phaseReadyAt = now + DirectSettleMs; + _waitingResultDeadline = now + DirectResultMaxWaitMs; + _phase = Phase.WaitingForResult; + } + + private void TurnDirectOff(string why) + { + if (_directOff) return; + _directOff = true; + _directOffReason = why; + Log($"[Salvage] Salvage without the panel is off for this session: {why}. The salvage panel is used instead."); + } + + /// The panel path: use the UST (opens the panel), then add, execute, verify. + private void StartPanelCycle(long now) + { + if (!PanelAvailable) + { + Log($"[Salvage] No salvage panel on this client — {_batch.Count} item(s) back in the queue."); + NoteError("no salvage panel calls on this client"); + foreach (uint id in _batch) RequeueOrDrop(id, "no salvage panel"); + ClearBatch(); + _currentUstId = 0; + _phase = Phase.Idle; + _idleRetryReadyAt = now + RetryBackoffMs; + return; + } + _salvageChat.Clear(); + // UseObject on the UST mimics a double-click — this is the reliable path to // trigger gmSalvageUI::OpenSalvagePanel (our hook captures the instance there). // SendNotice_OpenSalvagePanel does not reliably call the hooked function. @@ -392,6 +562,7 @@ public sealed class SalvageManager _currentUstId = 0; foreach (uint id in _batch) RequeueOrDrop(id, "UseObject(UST) failed"); ClearBatch(); + _phase = Phase.Idle; _idleRetryReadyAt = now + RetryBackoffMs; return; } @@ -406,7 +577,7 @@ public sealed class SalvageManager /// Items not in the pack yet stay tracked (the sweep queues them on arrival); items that /// can't be salvaged are skipped with a reason. False when nothing is left to salvage. /// - private bool BuildBatch(long now) + private bool BuildBatch(long now, int maxBatch) { ClearBatch(); if (_cache == null) @@ -420,7 +591,7 @@ public sealed class SalvageManager inPack[unchecked((uint)wo.Id)] = wo; int waiting = 0; - while (_queue.Count > 0 && _batch.Count < MaxBatchItems) + while (_queue.Count > 0 && _batch.Count < maxBatch) { uint id = DequeueItem(); _tracked.TryGetValue(id, out TrackedItem? t); @@ -531,6 +702,11 @@ public sealed class SalvageManager _batchAddIdx = 0; _batchBagsAdded = 0; _batchAddFailures = 0; + _batchDirect = false; + _batchPanelFallback = false; + _batchFallbackWhy = string.Empty; + _batchBags.Clear(); + _batchBagsBefore = null; } /// Adds the batch to the open panel one item per step, then matching bags. @@ -609,7 +785,21 @@ public sealed class SalvageManager /// private int AddAllMatchingUnderFullBags(IReadOnlyCollection itemIds) { - if (_cache == null || itemIds.Count == 0) return 0; + int added = 0; + foreach (uint bagId in FindMatchingUnderFullBags(itemIds, int.MaxValue)) + if (_host.SalvagePanelAddItem(bagId)) + added++; + return added; + } + + /// + /// Every under-full salvage bag in the pack whose material (and workmanship band, if + /// configured) matches one of , at most . + /// + private List FindMatchingUnderFullBags(IReadOnlyCollection itemIds, int max) + { + var found = new List(); + if (_cache == null || itemIds.Count == 0 || max <= 0) return found; RynthCore.Loot.SalvageCombineSettings? cfg = CombineConfigProvider?.Invoke(); bool useBands = cfg != null && cfg.Enabled; @@ -635,23 +825,31 @@ public sealed class SalvageManager keys.Add(itemMat.ToString()); } } - if (keys.Count == 0) return 0; + if (keys.Count == 0) return found; var batch = new HashSet(itemIds); - int added = 0; foreach (WorldObject bag in _cache.GetDirectInventory(forceRefresh: true)) { + if (found.Count >= max) break; uint bagId = unchecked((uint)bag.Id); if (batch.Contains(bagId)) continue; if (!IsSalvageBag(bag.Name)) continue; if (!IsBagUnderFull(bagId, bag.Name)) continue; if (!TryGetBagCombineKey(bagId, bag.Name, cfg, useBands, out string bagKey, out _)) continue; if (!keys.Contains(bagKey)) continue; - - if (_host.SalvagePanelAddItem(bagId)) - added++; + found.Add(bagId); } - return added; + return found; + } + + /// The salvage bags in the pack now (a fresh walk). + private HashSet SnapshotSalvageBagIds() + { + var set = new HashSet(); + if (_cache == null) return set; + foreach (WorldObject wo in _cache.GetDirectInventory(forceRefresh: true)) + if (IsSalvageBag(wo.Name)) set.Add(unchecked((uint)wo.Id)); + return set; } private void BeginSalvaging(long now) @@ -690,6 +888,26 @@ public sealed class SalvageManager // of the player's containers — is the ground truth; salvage-consumed items don't // reliably trigger OnDeleteObject in the cache. var live = SnapshotDirectInventoryIds(); + + // A request without the panel that changed nothing (no item left the pack) is tried once + // through the panel, before any retry is counted against the items. + if (_batchDirect && PanelAvailable && !_batchAdded.Any(id => !live.Contains(id))) + { + string reply = _salvageChat.Count > 0 ? ChatNote() : "; no salvage reply from the server"; + _directFallbacks++; + NoteError("salvage without the panel changed nothing — panel retry"); + Log($"[Salvage] Batch {_batchNumber + 1}: salvage without the panel changed nothing ({_batchAdded.Count} item(s) still in the pack{reply}) — trying them once through the panel."); + _batchFallbackWhy = "the request without the panel changed nothing"; + _batchAdded.Clear(); + _batchBags.Clear(); + _batchBagsAdded = 0; + _batchBagsBefore = null; + _batchDirect = false; + _batchPanelFallback = true; + StartPanelCycle(now); + return; + } + var salvagedNames = new List(); int stillThere = 0, requeued = 0; foreach (uint id in _batchAdded) @@ -711,15 +929,52 @@ public sealed class SalvageManager _batchesThisSession++; _itemsSalvagedThisSession += salvagedNames.Count; - string line = $"[Salvage] Batch {_batchNumber}: salvaged {salvagedNames.Count}/{_batchAdded.Count}" + // Bags: what a request without the panel did to them (the panel path keeps its old note). + string bagNote; + if (_batchDirect && _batchBagsBefore != null) + { + var bagsNow = SnapshotSalvageBagIds(); + int newBags = bagsNow.Count(b => !_batchBagsBefore.Contains(b)); + int mergedIn = _batchBags.Count(b => !bagsNow.Contains(b)); + bagNote = (newBags > 0 ? $", {newBags} new salvage bag(s)" : salvagedNames.Count > 0 ? ", no new salvage bag seen yet" : "") + + (_batchBags.Count > 0 ? $", {mergedIn}/{_batchBags.Count} bag(s) merged in" : ""); + } + else + { + bagNote = _batchBagsAdded > 0 ? $", +{_batchBagsAdded} bag(s) combined" : ""; + } + + string how = _batchDirect ? " without the panel" + : _batchPanelFallback ? $" through the panel ({_batchFallbackWhy})" + : ""; + + // The panel salvaged what a request without it couldn't: count it; enough in a row and the + // session goes back to the panel. A request that worked resets the count. + if (_batchDirect && salvagedNames.Count > 0) + _directPanelWorkedStreak = 0; + else if (_batchPanelFallback && salvagedNames.Count > 0 && UseDirect) + { + _directPanelWorkedStreak++; + if (_directPanelWorkedStreak >= DirectOffAfterFailures) + { + TurnDirectOff($"{_directPanelWorkedStreak} batches in a row changed nothing without the panel and were salvaged through it"); + _host.WriteToChat("[RynthAi] Salvage: salvaging without the panel didn't work here; using the salvage panel for the rest of the session.", 2); + } + } + + string line = $"[Salvage] Batch {_batchNumber}{how}: salvaged {salvagedNames.Count}/{_batchAdded.Count}" + (salvagedNames.Count > 0 ? $" ({SkipNotes.NameList(salvagedNames)})" : "") - + (_batchBagsAdded > 0 ? $", +{_batchBagsAdded} bag(s) combined" : "") + + bagNote + (stillThere > 0 ? $"; {stillThere} still in the pack ({requeued} queued again" + (stillThere > requeued ? $", {stillThere - requeued} resting or given up, see above" : "") + ")" : "") + (_batchAddFailures > 0 ? $"; panel refused {_batchAddFailures} (queued again)" : "") + (_batchSkips.Count > 0 ? $"; skipped: {_batchSkips.Describe()}" : "") + + ChatNote() + $". Session: {_itemsSalvagedThisSession} salvaged, {_itemsSkippedThisSession} skipped, {_tracked.Count} still tracked."; Log(line); + if (stillThere > 0 && ChatSaidRefused()) + NoteError($"server refused salvage{ChatNote()}"); + _salvageChat.Clear(); ClearBatch(); _currentUstId = 0; @@ -917,6 +1172,8 @@ public sealed class SalvageManager _combineGroupIdx = 0; _combineAddIdx = 0; + _combineGroupDirect = false; + _combineGroupPanelRetry = false; _combinePhase = CombinePhase.None; _combinePhaseReadyAt = now; _phase = Phase.CombiningSalvage; @@ -949,6 +1206,44 @@ public sealed class SalvageManager _phase = Phase.Idle; return; } + // Without the panel: the group's bags go in one salvage request (ACE merges the + // salvage bags listed in it). Not sent -> the panel takes this group. + if (UseDirect && !_combineGroupPanelRetry) + { + uint[] bagIds = group.Take(RynthCoreHost.MaxSalvageDirectItems).ToArray(); + _salvageChat.Clear(); + int sent = _host.SalvageDirect(ust, bagIds); + if (sent > 0) + { + _directRequests++; + _combineGroupDirect = true; + _combineGroupSnapshot = new List(bagIds); + _combinePhase = CombinePhase.WaitingForResult; + _combinePhaseReadyAt = now + DirectSettleMs; + _waitingResultDeadline = now + DirectResultMaxWaitMs; + break; + } + string why = sent switch + { + -1 => "the engine's salvage sender isn't bound on this client", + -2 => "the engine is older than plugin API v82", + _ => "the engine refused the request", + }; + if (sent is -1 or -2) TurnDirectOff(why); + _directFallbacks++; + Log($"[Salvage] Combine group {_combineGroupIdx + 1}/{_combineGroups.Count}: request without the panel wasn't sent ({why}) — using the panel."); + } + if (!PanelAvailable) + { + Log($"[Salvage] Combine group {_combineGroupIdx + 1}/{_combineGroups.Count}: no salvage panel on this client — skipping the group."); + NoteError("combine: no salvage panel calls on this client"); + _combineGroupIdx++; + _combineAddIdx = 0; + _combineGroupPanelRetry = false; + _combinePhaseReadyAt = now + RetryBackoffMs; + return; + } + _salvageChat.Clear(); if (!_host.UseFor(ust, "Salvage", "combine salvage: open the salvage panel (UST)")) { _combineOpenAttempts++; @@ -963,6 +1258,7 @@ public sealed class SalvageManager _combineOpenAttempts = 0; _combineGroupIdx++; _combineAddIdx = 0; + _combineGroupPanelRetry = false; _combinePhaseReadyAt = now + RetryBackoffMs; return; } @@ -1024,7 +1320,23 @@ public sealed class SalvageManager { break; } - VerifyCombineGroupResult(); + bool merged = VerifyCombineGroupResult(); + if (!merged && _combineGroupDirect && PanelAvailable) + { + // The request without the panel merged nothing: this group once more, through the panel. + _directFallbacks++; + Log($"[Salvage] Combine group {_combineGroupIdx + 1}/{_combineGroups!.Count}: the request without the panel merged nothing" + + (_salvageChat.Count > 0 ? ChatNote() : "; no salvage reply from the server") + " — trying the panel once."); + _combineGroupDirect = false; + _combineGroupPanelRetry = true; + _combineAddIdx = 0; + _combinePhase = CombinePhase.None; + _combinePhaseReadyAt = now; + break; + } + _combineGroupDirect = false; + _combineGroupPanelRetry = false; + _salvageChat.Clear(); _combineGroupIdx++; _combineAddIdx = 0; _combinePhase = CombinePhase.None; @@ -1045,11 +1357,11 @@ public sealed class SalvageManager /// S == 1 → clean merge into a single bag /// 1 < S < M → partial merge (overflow / mixed-band / next sweep can finish it) /// - private void VerifyCombineGroupResult() + private bool VerifyCombineGroupResult() { var snapshot = _combineGroupSnapshot; _combineGroupSnapshot = null; - if (snapshot == null || snapshot.Count == 0 || _cache == null) return; + if (snapshot == null || snapshot.Count == 0 || _cache == null) return true; var liveIds = SnapshotDirectInventoryIds(); int survivors = 0; @@ -1062,13 +1374,14 @@ public sealed class SalvageManager int merged = snapshot.Count - survivors; int groupNum = _combineGroupIdx + 1; int totalGroups = _combineGroups?.Count ?? 0; + string how = _combineGroupDirect ? " (without the panel)" : _combineGroupPanelRetry ? " (panel retry)" : ""; if (survivors == snapshot.Count) { _combineGroupsFailed++; string ids = string.Join(", ", snapshot.ConvertAll(id => $"0x{id:X8}")); - Log($"[Salvage] Combine group {groupNum}/{totalGroups}: NO MERGE — all {snapshot.Count} bag(s) still in inventory. Surviving ids: {ids}. Session: {_combineGroupsSucceeded} ok / {_combineGroupsFailed} failed, {_bagsMergedThisSession} bag(s) merged."); - return; + Log($"[Salvage] Combine group {groupNum}/{totalGroups}{how}: NO MERGE — all {snapshot.Count} bag(s) still in inventory. Surviving ids: {ids}. Session: {_combineGroupsSucceeded} ok / {_combineGroupsFailed} failed, {_bagsMergedThisSession} bag(s) merged."); + return false; } _combineGroupsSucceeded++; @@ -1076,12 +1389,13 @@ public sealed class SalvageManager if (survivors <= 1) { - Log($"[Salvage] Combine group {groupNum}/{totalGroups}: merged {snapshot.Count} bag(s) → {survivors} survivor (+{merged} consumed). Session: {_combineGroupsSucceeded} ok / {_combineGroupsFailed} failed, {_bagsMergedThisSession} bag(s) merged."); + Log($"[Salvage] Combine group {groupNum}/{totalGroups}{how}: merged {snapshot.Count} bag(s) → {survivors} survivor (+{merged} consumed). Session: {_combineGroupsSucceeded} ok / {_combineGroupsFailed} failed, {_bagsMergedThisSession} bag(s) merged."); } else { - Log($"[Salvage] Combine group {groupNum}/{totalGroups}: PARTIAL merge — {snapshot.Count} bag(s) → {survivors} survivors (+{merged} consumed). Remaining bag(s) will be picked up by next sweep. Session: {_combineGroupsSucceeded} ok / {_combineGroupsFailed} failed, {_bagsMergedThisSession} bag(s) merged."); + Log($"[Salvage] Combine group {groupNum}/{totalGroups}{how}: PARTIAL merge — {snapshot.Count} bag(s) → {survivors} survivors (+{merged} consumed). Remaining bag(s) will be picked up by next sweep. Session: {_combineGroupsSucceeded} ok / {_combineGroupsFailed} failed, {_bagsMergedThisSession} bag(s) merged."); } + return true; } /// @@ -1400,7 +1714,7 @@ public sealed class SalvageManager return name.Contains("Salvage (", StringComparison.OrdinalIgnoreCase); } - private void Log(string message) => _host.Log(message); + private void Log(string message) => RynthLog.Write(LogCat.Salvage, message); private void NoteError(string what) { @@ -1419,6 +1733,11 @@ public sealed class SalvageManager return new SalvageStateSnapshot { HasPanelApi = _host.HasSalvagePanel && _host.HasUseObject, + HasDirectApi = _host.HasSalvageDirect, + DirectOn = UseDirect, + DirectOffReason = _directOff ? _directOffReason : (!_settings.SalvageWithoutPanel ? "setting off" : !_host.HasSalvageDirect ? "engine before API v82" : string.Empty), + DirectRequests = _directRequests, + DirectFallbacks = _directFallbacks, EnableCombine = _settings.EnableCombineSalvage, Phase = _phase.ToString(), PhaseReadyInMs = Math.Max(0, _phaseReadyAt - now), @@ -1451,6 +1770,14 @@ public sealed class SalvageManager public struct SalvageStateSnapshot { public bool HasPanelApi; + /// The engine has SalvageDirect (API v82). + public bool HasDirectApi; + /// Requests go out without the panel now. + public bool DirectOn; + /// Why not, when is false ("" when on). + public string DirectOffReason; + public int DirectRequests; + public int DirectFallbacks; public bool EnableCombine; public string Phase; public long PhaseReadyInMs; diff --git a/Plugins/RynthCore.Plugin.RynthAi/Loot/ScrollLearner.cs b/Plugins/RynthCore.Plugin.RynthAi/Loot/ScrollLearner.cs index d2a4ad8..5f85e98 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Loot/ScrollLearner.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Loot/ScrollLearner.cs @@ -84,8 +84,14 @@ internal sealed class ScrollLearner internal const long ArrivalGraceMs = 15_000; /// Read animation + 1 s read + return to ready is ~3-4 s on ACE; give up after this. internal const long ReadTimeoutMs = 8_000; - /// Pause between two reads. + /// + /// Pause between two reads, from the read's end (its chat answer), when the read's UseDone is not + /// seen. ACE sends "The scroll is destroyed." before the return-to-ready animation and the UseDone + /// after it (Scroll.ActOnUse, Player.TryUseItem): about 0.7 s apart in a client log. + /// internal const long ReadGapMs = 1_500; + /// Pause between two reads, from the last read's UseDone (the server is free then). + internal const long ReadGapAfterUseDoneMs = 250; /// How often the pack is looked through for unknown scrolls. internal const long PackSweepMs = 5_000; /// A scroll approved for looting holds its spell this long (one copy per spell). @@ -146,6 +152,11 @@ internal sealed class ScrollLearner private string _chatText = ""; private bool _readItemDeleted; + // The UseDone of the last read sent: the first UseDone after its send. 0 = not seen (yet). + private bool _readUseDoneWatch; + private int _readUseDoneSeqAtSend; + private long _readUseDoneAt; + public ScrollLearner(RynthCoreHost host, LegacyUiSettings settings, WorldObjectCache? cache) { _host = host; @@ -352,12 +363,19 @@ internal sealed class ScrollLearner public bool Tick(bool safe, int busyCount) { long now = NowMs(); + PollReadUseDone(now); if (IsReading) { if (ResolveRead(now)) return false; return safe; } + if (_seriesOpen) + { + if (!_settings.IsMacroRunning) CloseSeries(CurrentMode() == CombatMode.NonCombat ? "the macro stopped" : ""); + else TickRestore(now, safe, busyCount); + } + if (!_settings.IsMacroRunning) return false; if (!_settings.ReadUnknownScrolls && _pending.Count == 0) return false; @@ -370,7 +388,7 @@ internal sealed class ScrollLearner } if (!safe || busyCount > 0 || _pending.Count == 0) return false; - if (now - _lastReadEndedAt < ReadGapMs) return false; + if (!ReadGapOver(now)) return false; if (inv == null) { if (now - _lastStartCheckAt < StartCheckMs) return false; // one pack walk a second at most @@ -380,6 +398,106 @@ internal sealed class ScrollLearner return TryStartRead(inv, now); } + // ── Stance restore ──────────────────────────────────────────────────────── + // Using a scroll puts the character in Peace. The mode it was in before the FIRST read of a + // run of reads is remembered, and requested once after the last one, when it was a combat + // mode and Peace Mode When Idle is off, so the next fight starts in stance. Nothing is sent + // when something else owns the moment (not safe: a fight or buff), when anything else already + // changed the mode, or while the client is busy. + + /// Quiet time after a read before the stance goes back: a next scroll starts within ReadGapMs + StartCheckMs. + internal const long RestoreSettleMs = 3_500; + internal const long RestoreRetryMs = 1_000; + internal const int RestoreMaxRequests = 3; + /// + /// How long after the settle time a restore may still go out. The learner is not ticked during a + /// death hold, a buff hold, vendoring or crafting, and the client can stay busy: a restore that + /// late is a stance from before the interruption (a previous life's Melee after a respawn), so + /// the series is dropped instead. + /// + internal const long RestoreGiveUpMs = 15_000; + + private bool _seriesOpen; + private int _restoreMode; // 0 = nothing to restore + private int _restoreWeapon; // the main-hand weapon at the first read; ACE reverts a mode its weapon doesn't fit + private long _restoreNextAt; + private int _restoreRequests; + + private int CurrentMode() + { + try { return _host.HasGetCurrentCombatMode ? _host.GetCurrentCombatMode() : 0; } + catch { return 0; } + } + + private static string ModeName(int mode) => mode switch + { + CombatMode.NonCombat => "Peace", + CombatMode.Melee => "Melee", + CombatMode.Missile => "Missile", + CombatMode.Magic => "Magic", + _ => mode.ToString(), + }; + + /// The melee/missile weapon or caster in the main hand (0 = none readable); CombatManager.InHandWeaponId's rules. + private int WieldedWeaponId() + { + try + { + foreach (var wo in _cache?.GetDirectInventory(forceRefresh: true) ?? Array.Empty()) + { + if (WorldObjectCache.IsAmmo(wo)) continue; + if ((wo.Values(LongValueKey.CurrentWieldedLocation, 0) & OffhandRules.ShieldSlot) != 0) continue; // the off hand + bool weapon = wo.ObjectClass == AcObjectClass.MeleeWeapon || wo.ObjectClass == AcObjectClass.MissileWeapon || WeaponList.IsWand(wo); + if (weapon && WorldObjectCache.IsWieldedByPlayer(_host, wo)) return wo.Id; + } + } + catch { } + return 0; + } + + private void OpenSeries() + { + if (_seriesOpen) return; // a later scroll of the same run: the first read's mode stands + _seriesOpen = true; + _restoreRequests = 0; + _restoreNextAt = 0; + int m = CurrentMode(); + _restoreMode = !_settings.PeaceModeWhenIdle && (m == CombatMode.Melee || m == CombatMode.Missile || m == CombatMode.Magic) ? m : 0; + _restoreWeapon = _restoreMode != 0 ? WieldedWeaponId() : 0; + } + + private void CloseSeries(string why) + { + if (_restoreMode != 0 && why.Length > 0) LogLine($"[Learn] stance not restored ({why})"); + _seriesOpen = false; + _restoreMode = 0; + } + + private void TickRestore(long now, bool safe, int busyCount) + { + if (_settings.PeaceModeWhenIdle) { CloseSeries(""); return; } // switched on since: Peace is wanted + long age = now - _lastReadEndedAt; + if (_restoreMode == 0) { if (age >= RestoreSettleMs) CloseSeries(""); return; } + // The next scroll may be about to start: wait the settle time, unless the last read's UseDone + // is in and no scroll is pending (nothing left to read, so the stance can go back now). + bool lastReadDone = LastReadUseDoneSeen && _pending.Count == 0; + if (age < RestoreSettleMs && !lastReadDone) return; + if (age > RestoreSettleMs + RestoreGiveUpMs) { CloseSeries("too late"); return; } + int cur = CurrentMode(); + if (cur == _restoreMode) { CloseSeries(""); return; } // back in stance + if (cur != CombatMode.NonCombat) { CloseSeries("something else set the mode"); return; } + if (!safe) { CloseSeries("a fight or another task has the tick"); return; } + if (busyCount > 0 || now < _restoreNextAt) return; + if (_restoreRequests >= RestoreMaxRequests) { CloseSeries("the client did not change mode"); return; } + if (WieldedWeaponId() != _restoreWeapon) { CloseSeries("the weapon changed"); return; } + // Only a request that went out counts: a pacing hold (another action unanswered) is retried next tick. + if (_host.ChangeCombatModeFor(_restoreMode, "Learn", "back to the stance from before the scroll read")) + { + _restoreRequests++; + _restoreNextAt = now + RestoreRetryMs; + LogLine($"[Learn] restoring {ModeName(_restoreMode)} mode after reading"); + } + } /// How often a waiting scroll is looked for in the pack. internal const long StartCheckMs = 1_000; private long _lastStartCheckAt = long.MinValue / 2; @@ -479,6 +597,7 @@ internal sealed class ScrollLearner return false; } + OpenSeries(); pp.Attempts++; _readItemId = pickId; _readSpellId = j.SpellId; @@ -489,6 +608,9 @@ internal sealed class ScrollLearner _chatText = ""; _readItemDeleted = false; + int seqBefore = 0; + bool haveSeq = false; + try { if (_host.HasUseDoneSeq) { seqBefore = _host.GetUseDoneSeq(); haveSeq = true; } } catch { } bool sent = false; try { sent = _host.UseFor(unchecked((uint)pickId), "Learn", $"read the scroll to learn {j.SpellName} ({j.Why})"); } catch { } @@ -499,10 +621,39 @@ internal sealed class ScrollLearner else pp.NotBefore = now + 3_000; return false; } + _readUseDoneWatch = haveSeq; + _readUseDoneSeqAtSend = seqBefore; + _readUseDoneAt = 0; LogLine($"[Learn] reading '{pick.Name}' ({j.SpellName}: {j.Why})"); return true; } + /// Notes the first UseDone after the last read's send (the server's end of that read). + private void PollReadUseDone(long now) + { + if (!_readUseDoneWatch) return; + try + { + if (unchecked(_host.GetUseDoneSeq() - _readUseDoneSeqAtSend) > 0) + { + _readUseDoneWatch = false; + _readUseDoneAt = now; + } + } + catch { _readUseDoneWatch = false; } + } + + /// The last read's UseDone was seen (after its chat answer, or at any time for this read). + private bool LastReadUseDoneSeen => _readUseDoneAt != 0; + + /// + /// May the next read start? ReadGapAfterUseDoneMs after the last read's UseDone, or ReadGapMs + /// after its end when no UseDone is seen (an engine without UseDone, or a lost one). + /// + private bool ReadGapOver(long now) => + (LastReadUseDoneSeen && now - _readUseDoneAt >= ReadGapAfterUseDoneMs) + || now - _lastReadEndedAt >= ReadGapMs; + /// True when the read in flight is over (learned, refused, or timed out). private bool ResolveRead(long now) { @@ -600,6 +751,8 @@ internal sealed class ScrollLearner /// Logout: the session memory goes with the character. public void Reset() { + _seriesOpen = false; + _restoreMode = 0; _failedSpells.Clear(); _approved.Clear(); _pending.Clear(); diff --git a/Plugins/RynthCore.Plugin.RynthAi/Loot/T11ItemSupport.cs b/Plugins/RynthCore.Plugin.RynthAi/Loot/T11ItemSupport.cs index db348fb..c312f2c 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Loot/T11ItemSupport.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Loot/T11ItemSupport.cs @@ -29,9 +29,16 @@ internal static class T11ItemSupport public string Name = string.Empty; public string LongDesc = string.Empty; public string Use = string.Empty; + public T11ServerProps Server = T11ServerProps.None; public T11ItemInfo Info = T11ItemInfo.None; } + /// The tier / quality properties the item's appraisal carried (ACECustom 50109, 9061, 9060). + public static T11ServerProps ServerProps(WorldObject item) => new( + item.Values(T11Catalog.PropZcTier, 0), + item.Values(T11Catalog.PropWeaponAugScaleTier, 0), + item.Values(T11Catalog.PropWeaponAugScaleQuality, -1)); + /// True when carries the server's T11 drop prefix. public static bool HasT11Name(string? name) => !string.IsNullOrEmpty(name) && name.StartsWith(T11Catalog.NamePrefix, StringComparison.Ordinal); @@ -42,21 +49,23 @@ internal static class T11ItemSupport string name = item.Name.Length > 0 ? item.Name : item.Values(StringValueKey.Name, string.Empty); string longDesc = item.Values(StringValueKey.LongDesc, string.Empty); string use = item.Values(StringValueKey.Use, string.Empty); + T11ServerProps server = ServerProps(item); lock (Gate) { if (Parsed.TryGetValue(item.Id, out Entry? e) && string.Equals(e.Name, name, StringComparison.Ordinal) && string.Equals(e.LongDesc, longDesc, StringComparison.Ordinal) - && string.Equals(e.Use, use, StringComparison.Ordinal)) + && string.Equals(e.Use, use, StringComparison.Ordinal) + && e.Server == server) return e.Info; } - T11ItemInfo info = T11ItemInfo.Parse(name, longDesc, use); + T11ItemInfo info = T11ItemInfo.Parse(name, longDesc, use, server); lock (Gate) { if (Parsed.Count >= MaxEntries) Parsed.Clear(); - Parsed[item.Id] = new Entry { Name = name, LongDesc = longDesc, Use = use, Info = info }; + Parsed[item.Id] = new Entry { Name = name, LongDesc = longDesc, Use = use, Server = server, Info = info }; } return info; } @@ -76,8 +85,8 @@ internal static class T11ItemSupport /// /// The value a T11 appraisal stripped for a retail key (158/159/160, 370-379), else - /// . Only T11-named items are parsed, so other items pay a - /// string compare. + /// . Only T11-named or T11-stamped items are parsed, so other + /// items pay a string compare and one property read. /// public static int StrippedValue(WorldObject item, int key, int fallback) { @@ -85,7 +94,7 @@ internal static class T11ItemSupport try { string name = item.Name.Length > 0 ? item.Name : item.Values(StringValueKey.Name, string.Empty); - if (!HasT11Name(name)) return fallback; + if (!HasT11Name(name) && ServerProps(item).Tier < T11Catalog.MinTier) return fallback; return T11Keys.TryGetStrippedValue(Get(item), key, out int value) ? value : fallback; } catch diff --git a/Plugins/RynthCore.Plugin.RynthAi/Maps/DungeonMapTexture.cs b/Plugins/RynthCore.Plugin.RynthAi/Maps/DungeonMapTexture.cs new file mode 100644 index 0000000..f7c0b69 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Maps/DungeonMapTexture.cs @@ -0,0 +1,237 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Install; + +namespace RynthCore.Plugin.RynthAi.Maps; + +/// +/// One D3D9 POOL_MANAGED A8R8G8B8 texture baked from a single Z-layer's floor cells. +/// Each texel covers one GridCell (0.5 AC units). Edge cells (cells bordering empty space) +/// use the bright wall colour; interior cells use the semi-transparent fill colour; +/// empty cells are fully transparent (alpha=0). +/// +/// Displayed via dl.AddImageQuad — O(1) vertices per layer vs O(strips + edges) otherwise. +/// Disk-cached to \RynthAi\Maps\{landblock:X8}_{layerIdx}.bin so +/// re-entering a dungeon skips the rasterise step. +/// +internal sealed class DungeonMapTexture : IDisposable +{ + private const float GridCell = 0.5f; + private static readonly string CacheDir = System.IO.Path.Combine(RynthInstallPaths.RynthAiDir, @"Maps"); + private const uint Magic = 0x524D5458u; // "XTMR" + + // D3D9 vtable indices on IDirect3DDevice9 / IDirect3DTexture9 + private const int VtCreateTexture = 23; + private const int VtLockRect = 19; + private const int VtUnlockRect = 20; + private const int VtRelease = 2; + + private const uint D3DFMT_A8R8G8B8 = 21; + private const uint D3DPOOL_MANAGED = 1; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate int CreateTextureD(IntPtr dev, uint w, uint h, uint levels, uint usage, uint fmt, uint pool, out IntPtr ppTex, IntPtr shared); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate int LockRectD(IntPtr tex, uint level, ref D3DLockedRect locked, IntPtr pRect, uint flags); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate int UnlockRectD(IntPtr tex, uint level); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate uint ReleaseD(IntPtr obj); + + [StructLayout(LayoutKind.Sequential)] + private struct D3DLockedRect { public int Pitch; public IntPtr pBits; } + + // ── D3D9 A8R8G8B8 colour helpers (ARGB uint: A<<24|R<<16|G<<8|B) ───── + private static uint Argb(float r, float g, float b, float a) => + ((uint)(a * 255f) << 24) | ((uint)(r * 255f) << 16) | ((uint)(g * 255f) << 8) | (uint)(b * 255f); + + // Match DungeonMapUi colour definitions + private static readonly uint FillFlat = Argb(0.18f, 0.55f, 0.22f, 0.40f); + private static readonly uint FillSlopeUp = Argb(0.55f, 0.12f, 0.08f, 0.40f); + private static readonly uint FillSlopeDown = Argb(0.10f, 0.50f, 0.15f, 0.40f); + private static readonly uint EdgeFlat = Argb(0.55f, 0.80f, 1.00f, 1.00f); + private static readonly uint EdgeSlopeUp = Argb(1.00f, 0.35f, 0.25f, 1.00f); + private static readonly uint EdgeSlopeDown = Argb(0.25f, 1.00f, 0.35f, 1.00f); + + // World bounds of the baked area + public float WorldX0, WorldY0, WorldX1, WorldY1; + public IntPtr TexId => _tex; + + private IntPtr _tex; + + private DungeonMapTexture() {} + + /// + /// Returns a texture for the given floor-cell grid. Checks the disk cache first; + /// if absent, rasterises, uploads to D3D9, and saves to disk. + /// Returns null if device is invalid or texture upload fails. + /// + public static DungeonMapTexture? GetOrBuild( + IntPtr device, + Dictionary<(int gx, int gy), DungeonMapUi.CellType> cells, + uint landblock, int layerIdx) + { + if (device == IntPtr.Zero || cells.Count == 0) return null; + + // Bounding box + int xMin = int.MaxValue, xMax = int.MinValue; + int yMin = int.MaxValue, yMax = int.MinValue; + foreach (var (gx, gy) in cells.Keys) + { + if (gx < xMin) xMin = gx; if (gx > xMax) xMax = gx; + if (gy < yMin) yMin = gy; if (gy > yMax) yMax = gy; + } + int w = xMax - xMin + 1, h = yMax - yMin + 1; + if (w <= 0 || h <= 0 || w > 8192 || h > 8192) return null; + + // Try disk cache first (only valid when dimensions match the dat-computed bounds) + var cached = TryLoadFromDisk(device, landblock, layerIdx, xMin, yMin, w, h); + if (cached != null) return cached; + + // Rasterise → upload → cache + var pixels = Rasterise(cells, xMin, yMax, w, h); + IntPtr tex = Upload(device, w, h, pixels); + if (tex == IntPtr.Zero) return null; + + SaveToDisk(landblock, layerIdx, xMin, yMin, w, h, pixels); + + return new DungeonMapTexture + { + _tex = tex, + WorldX0 = xMin * GridCell, + WorldY0 = yMin * GridCell, + WorldX1 = (xMax + 1) * GridCell, + WorldY1 = (yMax + 1) * GridCell, + }; + } + + public void Dispose() + { + if (_tex == IntPtr.Zero) return; + try { GetVtFunc(_tex, VtRelease)(_tex); } catch { } + _tex = IntPtr.Zero; + } + + // ── Rasterisation ───────────────────────────────────────────────────── + + private static uint[] Rasterise( + Dictionary<(int gx, int gy), DungeonMapUi.CellType> cells, + int xMin, int yMax, int w, int h) + { + var pixels = new uint[w * h]; // 0 = transparent + foreach (var ((gx, gy), ctype) in cells) + { + bool isEdge = !cells.ContainsKey((gx + 1, gy)) + || !cells.ContainsKey((gx - 1, gy)) + || !cells.ContainsKey((gx, gy + 1)) + || !cells.ContainsKey((gx, gy - 1)); + uint col = isEdge + ? ctype switch + { + DungeonMapUi.CellType.SlopeUp => EdgeSlopeUp, + DungeonMapUi.CellType.SlopeDown => EdgeSlopeDown, + _ => EdgeFlat, + } + : ctype switch + { + DungeonMapUi.CellType.SlopeUp => FillSlopeUp, + DungeonMapUi.CellType.SlopeDown => FillSlopeDown, + _ => FillFlat, + }; + // Row 0 = northernmost cells (highest gy), so flip Y + pixels[(yMax - gy) * w + (gx - xMin)] = col; + } + return pixels; + } + + // ── D3D9 upload ─────────────────────────────────────────────────────── + + private static unsafe IntPtr Upload(IntPtr device, int w, int h, uint[] pixels) + { + try + { + int hr = GetVtFunc(device, VtCreateTexture)( + device, (uint)w, (uint)h, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, out IntPtr tex, IntPtr.Zero); + if (hr < 0 || tex == IntPtr.Zero) return IntPtr.Zero; + + var locked = new D3DLockedRect(); + hr = GetVtFunc(tex, VtLockRect)(tex, 0, ref locked, IntPtr.Zero, 0); + if (hr < 0) { GetVtFunc(tex, VtRelease)(tex); return IntPtr.Zero; } + + // Copy row by row — pitch may be wider than w*4 + for (int row = 0; row < h; row++) + { + IntPtr dst = IntPtr.Add(locked.pBits, row * locked.Pitch); + fixed (uint* src = &pixels[row * w]) + Buffer.MemoryCopy(src, (void*)dst, (nuint)(w * 4), (nuint)(w * 4)); + } + + GetVtFunc(tex, VtUnlockRect)(tex, 0); + return tex; + } + catch { return IntPtr.Zero; } + } + + // ── Disk cache ──────────────────────────────────────────────────────── + + private static DungeonMapTexture? TryLoadFromDisk( + IntPtr device, uint lb, int layerIdx, + int expXMin, int expYMin, int expW, int expH) + { + try + { + string path = Path.Combine(CacheDir, $"{lb:X8}_{layerIdx}.bin"); + if (!File.Exists(path)) return null; + using var br = new BinaryReader(File.OpenRead(path)); + if (br.ReadUInt32() != Magic) return null; + int xMin = br.ReadInt32(), yMin = br.ReadInt32(); + int w = br.ReadInt32(), h = br.ReadInt32(); + // Invalidate if bounds no longer match the dat + if (w != expW || h != expH || xMin != expXMin || yMin != expYMin) return null; + if (br.BaseStream.Length < 20L + (long)w * h * 4) return null; + + var pixels = new uint[w * h]; + for (int i = 0; i < pixels.Length; i++) pixels[i] = br.ReadUInt32(); + + IntPtr tex = Upload(device, w, h, pixels); + if (tex == IntPtr.Zero) return null; + + return new DungeonMapTexture + { + _tex = tex, + WorldX0 = xMin * GridCell, + WorldY0 = yMin * GridCell, + WorldX1 = (xMin + w) * GridCell, + WorldY1 = (yMin + h) * GridCell, + }; + } + catch { return null; } + } + + private static void SaveToDisk(uint lb, int layerIdx, int xMin, int yMin, int w, int h, uint[] pixels) + { + try + { + Directory.CreateDirectory(CacheDir); + string path = Path.Combine(CacheDir, $"{lb:X8}_{layerIdx}.bin"); + using var bw = new BinaryWriter(File.Open(path, FileMode.Create)); + bw.Write(Magic); bw.Write(xMin); bw.Write(yMin); bw.Write(w); bw.Write(h); + foreach (uint px in pixels) bw.Write(px); + } + catch { } + } + + // ── VTable helper ───────────────────────────────────────────────────── + + private static unsafe TDelegate GetVtFunc(IntPtr obj, int idx) where TDelegate : Delegate + { + void** vt = *(void***)obj; + return Marshal.GetDelegateForFunctionPointer((IntPtr)vt[idx]); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Meta/AfFileWriter.cs b/Plugins/RynthCore.Plugin.RynthAi/Meta/AfFileWriter.cs index bc9ed00..a42f61f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Meta/AfFileWriter.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Meta/AfFileWriter.cs @@ -29,6 +29,7 @@ internal static class AfFileWriter IReadOnlyDictionary> embeddedNavs) { Directory.CreateDirectory(Path.GetDirectoryName(filePath) ?? "."); + RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.PrepareOverwrite(filePath); // a read-only .af can't be overwritten using var writer = new StreamWriter(filePath, false); WriteContent(writer, rules, embeddedNavs); } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.cs b/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.cs index 270dc35..e4003ec 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.cs @@ -1241,12 +1241,30 @@ internal sealed class ExpressionEngine finally { _quietUnknownFn--; } } + /// + /// A list function's expression argument: the text inside its backticks, with the two + /// escapes a backtick string has ("\`" and "\\") turned back into what they stand for, so + /// the inner expression can quote text itself. Without that, listfilter[...,`chatbox[\`/t \`+ + /// wobjectgetname[$1]+\`, xp\`]`] evaluated "\`/t \`" with the backslashes still in and + /// sent "0Name`" as a say (2026-10-13, CQ_DragonIsle_Water.met). + /// private static string StripBackticks(string s) { s = s.Trim(); - return s.Length >= 2 && s[0] == '`' && s[s.Length - 1] == '`' - ? s.Substring(1, s.Length - 2) - : s; + if (!(s.Length >= 2 && s[0] == '`' && s[s.Length - 1] == '`')) + return s; + string inner = s.Substring(1, s.Length - 2); + if (inner.IndexOf('\\') < 0) + return inner; + var sb = new System.Text.StringBuilder(inner.Length); + for (int i = 0; i < inner.Length; i++) + { + if (inner[i] == '\\' && i + 1 < inner.Length && inner[i + 1] is '`' or '\\') + sb.Append(inner[++i]); + else + sb.Append(inner[i]); + } + return sb.ToString(); } // ── List function implementations ───────────────────────────────────────── @@ -1841,9 +1859,12 @@ internal sealed class ExpressionEngine var items = new List(); var seen = new System.Collections.Generic.HashSet(); + // Never the character running the meta: "every player around" (class 24) sending + // tells reached the sender too (2026-10-13). + int self = unchecked((int)_host.GetPlayerId()); void Check(WorldObject wo) { - if (!seen.Add(wo.Id)) return; + if (wo.Id == self || !seen.Add(wo.Id)) return; if (ResolveEffectiveObjectClass(wo) == targetClass) items.Add(MakeWobjectHandle(unchecked((uint)wo.Id), wo.Name)); } @@ -2831,8 +2852,9 @@ internal sealed class ExpressionEngine if (_host.HasChangeCombatMode && (now - _castStanceLastFlipAt).TotalMilliseconds > CastStanceFlipGateMs) { - _host.ChangeCombatModeFor(CombatMode.Magic, "Meta", "meta cast: Magic mode", force: true); - _castStanceLastFlipAt = now; + // Only a request that went out arms the flip throttle: a refusal is asked again next pulse. + if (_host.ChangeCombatModeFor(CombatMode.Magic, "Meta", "meta cast: Magic mode", force: true)) + _castStanceLastFlipAt = now; } return false; } @@ -3536,6 +3558,7 @@ internal sealed class ExpressionEngine ["EnableAutocram"] = (() => B(s.EnableAutocram), v => s.EnableAutocram = ToDouble(v) != 0), ["ReadUnknownScrolls"] = (() => B(s.ReadUnknownScrolls), v => s.ReadUnknownScrolls = ToDouble(v) != 0), ["EnableCombineSalvage"]= (() => B(s.EnableCombineSalvage),v => s.EnableCombineSalvage= ToDouble(v) != 0), + ["SalvageWithoutPanel"] = (() => B(s.SalvageWithoutPanel), v => s.SalvageWithoutPanel = ToDouble(v) != 0), ["PeaceModeWhenIdle"] = (() => B(s.PeaceModeWhenIdle), v => s.PeaceModeWhenIdle = ToDouble(v) != 0), ["RebuffWhenIdle"] = (() => B(s.RebuffWhenIdle), v => s.RebuffWhenIdle = ToDouble(v) != 0), ["UsePotions"] = (() => B(s.UsePotions), v => s.UsePotions = ToDouble(v) != 0), @@ -3548,12 +3571,15 @@ internal sealed class ExpressionEngine ["StaminaToHealthAt"] = (() => s.StaminaToHealthAt.ToString(CultureInfo.InvariantCulture), v => s.StaminaToHealthAt = Math.Clamp((int)ToDouble(v), 0, 100)), ["StaminaToHealthMinStamina"] = (() => s.StaminaToHealthMinStamina.ToString(CultureInfo.InvariantCulture), v => s.StaminaToHealthMinStamina = Math.Clamp((int)ToDouble(v), 0, 100)), ["StopMacroOnDeath"] = (() => B(s.StopMacroOnDeath), v => s.StopMacroOnDeath = ToDouble(v) != 0), + ["DeathRecallMode"] = (() => I(s.DeathRecallMode), v => { if (int.TryParse(v, out int i)) s.DeathRecallMode = Math.Clamp(i, 0, 2); }), + ["DeathRecallSpellId"] = (() => I(s.DeathRecallSpellId), v => { if (int.TryParse(v, out int i) && i > 0) s.DeathRecallSpellId = i; }), + ["DeathRecallItem"] = (() => s.DeathRecallItem, v => s.DeathRecallItem = v?.Trim() ?? string.Empty), ["StopMacroOnNoComponents"] = (() => B(s.StopMacroOnNoComponents), v => s.StopMacroOnNoComponents = ToDouble(v) != 0), ["StopLootingWhenPackFull"] = (() => B(s.StopLootingWhenPackFull), v => s.StopLootingWhenPackFull = ToDouble(v) != 0), ["LootOwnCorpse"] = (() => B(s.LootOwnCorpse), v => s.LootOwnCorpse = ToDouble(v) != 0), ["EscapeHazards"] = (() => B(s.EscapeHazards), v => s.EscapeHazards = ToDouble(v) != 0), ["TravelToOwnCorpse"] = (() => B(s.TravelToOwnCorpse), v => s.TravelToOwnCorpse = ToDouble(v) != 0), - ["ItemInfoOnSelect"] = (() => B(s.ItemInfoOnSelect), v => s.ItemInfoOnSelect = ToDouble(v) != 0), + ["ItemInfoOnSelect"] = (() => B(s.ItemInfoSettings.OnSelect), v => s.ItemInfoSettings.OnSelect = ToDouble(v) != 0), ["StopMacroWhenPackFull"] = (() => B(s.StopMacroWhenPackFull), v => s.StopMacroWhenPackFull = ToDouble(v) != 0), ["SummonPets"] = (() => B(s.SummonPets), v => s.SummonPets = ToDouble(v) != 0), ["MineOnly"] = (() => B(s.MineOnly), v => s.MineOnly = ToDouble(v) != 0), @@ -3596,6 +3622,8 @@ internal sealed class ExpressionEngine ["RebuffSecondsRemaining"] = (() => I(s.RebuffSecondsRemaining), v => { if (int.TryParse(v, out int i)) s.RebuffSecondsRemaining = i; }), ["RebuffTopOffSecondsRemaining"] = (() => I(s.RebuffTopOffSecondsRemaining), v => { if (int.TryParse(v, out int i)) s.RebuffTopOffSecondsRemaining = i; }), ["CastBuffsOverItemBuffs"] = (() => B(s.CastBuffsOverItemBuffs), v => s.CastBuffsOverItemBuffs = ToDouble(v) != 0), + ["FastBuffChain"] = (() => B(s.FastBuffChain), v => s.FastBuffChain = ToDouble(v) != 0), + ["SkipUnusableBuffs"] = (() => B(s.SkipUnusableBuffs), v => s.SkipUnusableBuffs = ToDouble(v) != 0), // AutoVendor (UB names map here through /ub opt: AutoVendor.Enabled -> AutoVendorEnabled, ...) ["AutoVendorEnabled"] = (() => B(s.AutoVendorEnabled), v => s.AutoVendorEnabled = ToDouble(v) != 0), ["AutoVendorEnableBuying"] = (() => B(s.AutoVendorEnableBuying), v => s.AutoVendorEnableBuying = ToDouble(v) != 0), @@ -3631,6 +3659,7 @@ internal sealed class ExpressionEngine ["CurrentMetaPath"] = (() => s.CurrentMetaPath, v => s.CurrentMetaPath = v), ["OpenDoors"] = (() => B(s.OpenDoors), v => s.OpenDoors = ToDouble(v) != 0), ["NavRecoveryEnabled"] = (() => B(s.NavRecoveryEnabled), v => s.NavRecoveryEnabled = ToDouble(v) != 0), + ["NavResumeNearest"] = (() => B(s.NavResumeNearest), v => s.NavResumeNearest = ToDouble(v) != 0), ["NavOffTrackYards"] = (() => F(s.NavOffTrackYards), v => { if (float.TryParse(v, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out float f)) s.NavOffTrackYards = Math.Clamp(f, 160f, 1000f); }), ["NavMaxDetourAttempts"] = (() => I(s.NavMaxDetourAttempts), v => { if (int.TryParse(v, out int i)) s.NavMaxDetourAttempts = Math.Clamp(i, 1, 10); }), ["OpenDoorRange"] = (() => F(s.OpenDoorRange), v => { if (float.TryParse(v, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out float f)) s.OpenDoorRange = f; }), diff --git a/Plugins/RynthCore.Plugin.RynthAi/Meta/MetaManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Meta/MetaManager.cs index f8c4689..0365ae2 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Meta/MetaManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Meta/MetaManager.cs @@ -7,6 +7,7 @@ using RynthCore.Plugin.RynthAi; using RynthCore.Plugin.RynthAi.CreatureData; using RynthCore.Plugin.RynthAi.LegacyUi; using RynthCore.PluginSdk; +using RynthCore.Install; namespace RynthCore.Plugin.RynthAi.Meta; @@ -129,7 +130,7 @@ internal sealed class MetaManager // §3.3: surface schema/enum drift once per session instead of letting a // mid-enum insert silently corrupt every saved meta + the JSON bridge. if (MetaSchema.DriftError != null) - _host.Log($"[Meta] SCHEMA DRIFT — fix MetaSchema/enum alignment: {MetaSchema.DriftError}"); + RynthLog.Write(LogCat.Meta, $"[Meta] SCHEMA DRIFT — fix MetaSchema/enum alignment: {MetaSchema.DriftError}"); } public void SetMtCommandHandler(Func handler) => _mtCommandHandler = handler; @@ -211,17 +212,12 @@ internal sealed class MetaManager /// /// Follow and Once routes must run from the first point so opening /// Recall/Portal/Chat actions fire. Circular and Linear routes jump - /// in at the nearest traversable Point. + /// in at the nearest traversable Point (at [0] with NavResumeNearest off). /// private int StartIndexForRoute(NavRouteParser route) - { - return route.RouteType switch - { - NavRouteType.Follow => 0, - NavRouteType.Once => 0, - _ => FindNearestWaypoint(route) - }; - } + => NavRouteParser.StartsAtFirstPoint(route.RouteType, _settings.NavResumeNearest) + ? 0 + : FindNearestWaypoint(route); public ExpressionEngine Expressions => _expressions ??= CreateExpressionEngine(); @@ -430,7 +426,7 @@ internal sealed class MetaManager // A condition/action threw. Localise it to this tick instead of // letting partial state (half-applied SetState, pushed call stack) // persist. ForceStateReset recomputes HasFired cleanly next tick. - _host.Log($"[Meta] Think crashed in '{_settings.CurrentState}': {ex.GetType().Name}: {ex.Message}"); + RynthLog.Write(LogCat.Meta, $"[Meta] Think crashed in '{_settings.CurrentState}': {ex.GetType().Name}: {ex.Message}"); if (_settings.MetaDebug) _host.WriteToChat($"[Meta] Think exception: {ex.Message}", 1); _lastExprError = $"Think: {ex.GetType().Name}: {Truncate(ex.Message, 100)}"; @@ -901,7 +897,7 @@ internal sealed class MetaManager { if (string.IsNullOrWhiteSpace(rule.ActionData)) { - _host.Log("[Meta] EmbedNav: empty ActionData, ignored"); + RynthLog.Write(LogCat.Meta, "[Meta] EmbedNav: empty ActionData, ignored"); break; } string routeName = rule.ActionData.Split(';')[0]; @@ -949,7 +945,7 @@ internal sealed class MetaManager _settings.CurrentRoute = newRoute; _settings.ActiveNavIndex = StartIndexForRoute(newRoute); _settings.EnableNavigation = true; - _host.Log($"[Meta] EmbedNav: loaded '{routeName}' ({newRoute.Points.Count} pts, was {priorPoints})"); + RynthLog.Write(LogCat.Meta, $"[Meta] EmbedNav: loaded '{routeName}' ({newRoute.Points.Count} pts, was {priorPoints})"); _host.WriteToChat($"[RynthAi Meta] Route \u2192 {routeName} ({newRoute.Points.Count} pts)", 1); break; } @@ -964,19 +960,19 @@ internal sealed class MetaManager _settings.CurrentRoute = newRoute; _settings.ActiveNavIndex = StartIndexForRoute(newRoute); _settings.EnableNavigation = true; - _host.Log($"[Meta] EmbedNav: loaded file '{routeName}' ({newRoute.Points.Count} pts, was {priorPoints})"); + RynthLog.Write(LogCat.Meta, $"[Meta] EmbedNav: loaded file '{routeName}' ({newRoute.Points.Count} pts, was {priorPoints})"); _host.WriteToChat($"[RynthAi Meta] Route \u2192 {routeName} ({newRoute.Points.Count} pts)", 1); } else { string keys = string.Join(", ", _settings.EmbeddedNavs.Keys); - _host.Log($"[Meta] EmbedNav: route '{routeName}' not found. Embedded keys: [{keys}]"); + RynthLog.Write(LogCat.Meta, $"[Meta] EmbedNav: route '{routeName}' not found. Embedded keys: [{keys}]"); _host.WriteToChat($"[RynthAi Meta] Route missing: {routeName}", 1); } } catch (Exception ex) { - _host.Log($"[Meta] EmbedNav error: {ex.Message}"); + RynthLog.Write(LogCat.Meta, $"[Meta] EmbedNav error: {ex.Message}"); _host.WriteToChat($"[RynthAi Meta] Load Error: {ex.Message}", 1); } break; @@ -1086,7 +1082,7 @@ internal sealed class MetaManager _lastExprError = $"{rule.Action} ignored — VTank Views are not supported in RynthAi"; _lastExprErrorAt = Clock(); _host.WriteToChat("[RynthAi] Meta uses VTank Views (CreateView/DestroyView) — not supported; those actions are ignored.", 1); - _host.Log($"[Meta] {rule.Action} ignored — VTank Views unsupported"); + RynthLog.Write(LogCat.Meta, $"[Meta] {rule.Action} ignored — VTank Views unsupported"); } break; } @@ -1251,7 +1247,7 @@ internal sealed class MetaManager // /vt aliases → existing /ra handlers (Phase 1.3 VTank-meta migration). // Re-dispatch through the /ra path (_raCommandHandler → HandleRaCommand). - if (sub is "forcebuff" or "cancelforcebuff" or "addnavpt" or "mexec" or "clearbusy") + if (sub is "forcebuff" or "cancelforcebuff" or "addnavpt" or "mexec" or "clearbusy" or "testitem" or "propertydump") { _raCommandHandler?.Invoke("/ra " + string.Join(" ", parts, 1, parts.Length - 1)); return true; diff --git a/Plugins/RynthCore.Plugin.RynthAi/Meta/QuestTracker.cs b/Plugins/RynthCore.Plugin.RynthAi/Meta/QuestTracker.cs index f8189ac..f7abf81 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Meta/QuestTracker.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Meta/QuestTracker.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; using RynthCore.PluginSdk; @@ -8,6 +9,8 @@ namespace RynthCore.Plugin.RynthAi.Meta; internal sealed class QuestRecord { public string Key = ""; + /// Server-supplied description from /myquests (may be empty). + public string Description = ""; public int Solves; public int MaxSolves; public DateTime CompletedOn = DateTime.MinValue; @@ -24,6 +27,13 @@ internal sealed class QuestRecord return false; return !(MaxSolves == 1 && Solves <= 1); } + + /// Time until the flag can be solved again (zero when ready). + public TimeSpan TimeUntilReady() + { + var left = (CompletedOn + RepeatTime) - DateTime.UtcNow; + return left > TimeSpan.Zero ? left : TimeSpan.Zero; + } } /// @@ -44,21 +54,44 @@ internal sealed class QuestTracker private bool _refreshing; private bool _gotFirstQuest; + private bool _quietRefresh; private DateTime _lastLineTime; private DateTime _refreshStarted; public bool IsRefreshing => _refreshing; + /// The server answered that /myquests is not enabled. + public bool Disabled { get; private set; } + + /// UTC time the last refresh finished with data (MinValue = never). + public DateTime LastRefreshUtc { get; private set; } = DateTime.MinValue; + + /// Last refresh outcome text for the ILT Hub ("12 flags", "rate limited", ...). + public string LastStatus { get; private set; } = "not refreshed"; + + /// Number of cached flags. + public int Count => _flags.Count; + + /// Raised on the pump thread when a refresh ends. The ILT Hub reads Disabled and Count. + public event Action? RefreshCompleted; + public QuestTracker(RynthCoreHost host) => _host = host; /// /// Issues /myquests to the server to populate the quest flag cache. /// No-ops if already refreshing or InvokeChatParser is not available. /// - public void Refresh() + public void Refresh() => Refresh(quiet: false); + + /// + /// Issues /myquests. asks to report + /// those lines as eatable so the ILT Hub can hide its own poll. + /// + public void Refresh(bool quiet) { if (_refreshing || !_host.HasInvokeChatParser) return; + _quietRefresh = quiet; ExpectReply(); RefreshSent?.Invoke(); _host.InvokeChatParser("/myquests"); @@ -83,33 +116,43 @@ internal sealed class QuestTracker /// Feed every incoming chat line here. Quest lines are parsed and cached; /// terminal lines (empty list, rate limit, etc.) end the refresh early. /// - public void OnChatLine(string text) + public bool OnChatLine(string text) { if (!_refreshing) - return; + return false; - if (text.Contains("Quest list is empty") || - text.Contains("The command \"myquests\" is not currently enabled")) + if (text.Contains("Quest list is empty")) { - _refreshing = false; - return; + bool quiet = _quietRefresh; + Finish("quest list is empty", gotData: true); + return quiet; + } + + if (text.Contains("The command \"myquests\" is not currently enabled")) + { + Disabled = true; + bool quiet = _quietRefresh; + Finish("/myquests is disabled on this server", gotData: false); + return quiet; } if (text.Contains("This command may only be run once every")) { - _refreshing = false; - return; + bool quiet = _quietRefresh; + Finish("rate limited by the server (try again in a minute)", gotData: false); + return quiet; } var m = QuestLineRegex.Match(text); if (!m.Success) - return; + return false; _gotFirstQuest = true; _lastLineTime = DateTime.UtcNow; var rec = new QuestRecord(); rec.Key = m.Groups["key"].Value.ToLowerInvariant(); + rec.Description = m.Groups["description"].Value.Trim().Trim('"'); int.TryParse(m.Groups["solves"].Value, out rec.Solves); int.TryParse(m.Groups["maxSolves"].Value, out rec.MaxSolves); @@ -126,6 +169,7 @@ internal sealed class QuestTracker rec.RepeatTime = TimeSpan.FromSeconds(rt); _flags[rec.Key] = rec; + return _quietRefresh; } /// @@ -142,15 +186,32 @@ internal sealed class QuestTracker if (_gotFirstQuest) { if ((now - _lastLineTime).TotalSeconds >= 1.0) - _refreshing = false; + Finish($"{Count} flags", gotData: true); } else { if ((now - _refreshStarted).TotalSeconds >= 15.0) - _refreshing = false; + Finish("no reply from server", gotData: false); } } + private void Finish(string status, bool gotData) + { + _refreshing = false; + _quietRefresh = false; + LastStatus = status; + if (gotData) + { + Disabled = false; + LastRefreshUtc = DateTime.UtcNow; + } + try { RefreshCompleted?.Invoke(); } + catch (Exception ex) { _host.Log($"[RynthAi] QuestTracker RefreshCompleted threw: {ex.Message}"); } + } + + /// Copy of every cached record for the ILT Hub quest list. + public QuestRecord[] Snapshot() => _flags.Values.ToArray(); + /// Returns true if the key exists in the cached quest flag list. public bool HasFlag(string key) => _flags.ContainsKey(key.ToLowerInvariant()); diff --git a/Plugins/RynthCore.Plugin.RynthAi/NavBreadcrumbTracker.cs b/Plugins/RynthCore.Plugin.RynthAi/NavBreadcrumbTracker.cs new file mode 100644 index 0000000..98cbc26 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/NavBreadcrumbTracker.cs @@ -0,0 +1,286 @@ +// NavBreadcrumbTracker.cs — position sampling for the Navigation window: +// +// * Breadcrumb trail: where the character has walked (spacing / max points / teleport +// breaks), drawn by NavOverlayRenderer and exportable as a route ("backtrack"). +// * Route recording (UB-IT KeyStoreRecorder style): while LegacyUiSettings.IsRecordingNav +// is on, appends Point waypoints every RecordSpacingYards and, on a teleport, a Portal +// step for the portal selected just before it (plus an optional pause). +// +// Runs on the plugin tick thread. The render thread only reads the published trail array +// (copy-on-write), so no locks are needed. +using System; +using System.Collections.Generic; +using System.Threading; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi; + +/// One trail sample. Z is the raw world height (marker frame = Z, not Z/240). +internal readonly record struct NavCrumb(double NS, double EW, float Z, bool SegmentStart); + +internal sealed class NavBreadcrumbTracker +{ + /// A position jump larger than this between ticks is a teleport (engine uses the same 50 yd). + private const double TeleportYards = 50.0; + /// A portal selected longer ago than this isn't credited for a recorded teleport. + private const long PortalCreditMs = 20_000; + /// Recording autosaves to the route file every this many added waypoints. + private const int RecordAutosaveEvery = 10; + + private readonly RynthCoreHost _host; + private readonly LegacyUiSettings _settings; + /// Object id → (name, Decal object class) when it is a portal, else null. + private readonly Func _describePortal; + private readonly Action _chat; + + // ── Trail (tick thread owns _crumbs; _snapshot is what the renderer reads) ── + private readonly List _crumbs = new(); + private NavCrumb[] _snapshot = Array.Empty(); + private bool _breakNext = true; + private double _trailYards; + + // ── Teleport detection ── + private double _lastNS = double.NaN, _lastEW, _lastZ; + private bool _wasPortaling; + + // ── Recording ── + private bool _recordingActive; + private double _recNS = double.NaN, _recEW; + private int _recAdded, _recSinceSave; + private (string Name, int Cls, double NS, double EW, double NavZ, long At)? _portalCandidate; + + public NavBreadcrumbTracker(RynthCoreHost host, LegacyUiSettings settings, + Func describePortal, Action chat) + { + _host = host; + _settings = settings; + _describePortal = describePortal; + _chat = chat; + } + + /// Current trail, oldest first (safe to read from the render thread). + public NavCrumb[] Trail => Volatile.Read(ref _snapshot); + /// Walked length of the trail (teleport jumps excluded), yards. + public double TrailYards => Volatile.Read(ref _trailYards); + /// Waypoints added by the current recording session. + public int RecordedCount => Volatile.Read(ref _recAdded); + + /// Clear request from the UI thread; applied on the next tick. + public void RequestClear() => Interlocked.Exchange(ref _clearRequested, 1); + private int _clearRequested; + + public void Tick() + { + var o = _settings.NavOverlay; + if (Interlocked.Exchange(ref _clearRequested, 0) == 1) ClearTrail(); + + // Portal space: no position worth recording, but remember we passed through it. + if (_host.HasIsPortaling && _host.IsPortaling()) + { + _wasPortaling = true; + return; + } + if (!NavCoordinateHelper.TryGetNavCoords(_host, out double ns, out double ew)) return; + if (!_host.TryGetPlayerPose(out uint cell, out _, out _, out float z, out _, out _, out _, out _)) return; + if ((cell >> 16) == 0) return; + + bool hadLast = !double.IsNaN(_lastNS); + bool teleported = _wasPortaling + || (hadLast && NavRouteEditing.DistanceYards(_lastNS, _lastEW, ns, ew) > TeleportYards); + _wasPortaling = false; + double preNS = _lastNS, preEW = _lastEW, preZ = _lastZ; + _lastNS = ns; _lastEW = ew; _lastZ = z; + + if (teleported) _breakNext = true; + + // While tracking is off, keep a break pending so the trail resumes as a new segment + // instead of joining across the untracked stretch. + if (o.TrackBreadcrumbs) SampleCrumb(ns, ew, z, o); + else _breakNext = true; + TickRecording(ns, ew, z, o, teleported && hadLast, preNS, preEW, preZ); + } + + // ═══════════════════════════════════════════════════════════════════ + // Breadcrumb trail + // ═══════════════════════════════════════════════════════════════════ + + private void SampleCrumb(double ns, double ew, float z, NavOverlaySettings o) + { + if (_crumbs.Count > 0 && !_breakNext) + { + var last = _crumbs[^1]; + double d = NavRouteEditing.DistanceYards(last.NS, last.EW, ns, ew); + if (d < o.BreadcrumbSpacingYards) return; + _trailYards += d; + } + _crumbs.Add(new NavCrumb(ns, ew, z, _breakNext || _crumbs.Count == 0)); + _breakNext = false; + + int over = _crumbs.Count - o.BreadcrumbMaxPoints; + if (over > 0) + { + _crumbs.RemoveRange(0, over); + if (_crumbs.Count > 0 && !_crumbs[0].SegmentStart) + _crumbs[0] = _crumbs[0] with { SegmentStart = true }; + _trailYards = MeasureTrail(_crumbs); + } + Volatile.Write(ref _snapshot, _crumbs.ToArray()); + } + + private void ClearTrail() + { + _crumbs.Clear(); + _trailYards = 0; + _breakNext = true; + Volatile.Write(ref _snapshot, Array.Empty()); + } + + private static double MeasureTrail(List crumbs) + { + double total = 0; + for (int i = 1; i < crumbs.Count; i++) + if (!crumbs[i].SegmentStart) + total += NavRouteEditing.DistanceYards(crumbs[i - 1].NS, crumbs[i - 1].EW, crumbs[i].NS, crumbs[i].EW); + return total; + } + + /// + /// Trail → waypoints (Z converted to nav units), thinned to . + /// builds a backtrack (newest first). Teleport breaks end the + /// export so the route never asks the bot to walk across a portal jump. + /// + public static List TrailToPoints(NavCrumb[] trail, double spacingYards, bool reverse) + { + var pts = new List(); + if (trail.Length == 0) return pts; + + // Newest unbroken segment only: from the last segment start to the end. + int start = 0; + for (int i = trail.Length - 1; i >= 0; i--) + if (trail[i].SegmentStart) { start = i; break; } + + NavCrumb? lastKept = null; + for (int i = start; i < trail.Length; i++) + { + var c = trail[i]; + bool isLast = i == trail.Length - 1; + if (lastKept is NavCrumb k && !isLast + && NavRouteEditing.DistanceYards(k.NS, k.EW, c.NS, c.EW) < spacingYards) + continue; + pts.Add(new NavPoint { Type = NavPointType.Point, NS = c.NS, EW = c.EW, Z = c.Z / NavCoordinateHelper.NavZScale }); + lastKept = c; + } + if (reverse) pts.Reverse(); + return pts; + } + + // ═══════════════════════════════════════════════════════════════════ + // Route recording + // ═══════════════════════════════════════════════════════════════════ + + private void TickRecording(double ns, double ew, float z, NavOverlaySettings o, + bool teleported, double preNS, double preEW, double preZ) + { + if (!_settings.IsRecordingNav) + { + if (_recordingActive) StopRecordingSession(); + return; + } + if (!_recordingActive) + { + _recordingActive = true; + _recNS = double.NaN; + _recAdded = 0; + _recSinceSave = 0; + _portalCandidate = null; + RynthLog.Write(LogCat.Navigation, "[NavRecord] recording started."); + } + + TrackPortalSelection(); + + if (teleported) + { + // Portal used just before the jump → Portal step (+ pause); the arrival point + // then records immediately because _recNS is reset. + if (o.RecordPortals && _portalCandidate is { } pc && Environment.TickCount64 - pc.At <= PortalCreditMs) + { + AddRecorded(new NavPoint + { + Type = NavPointType.PortalNPC, + NS = preNS, EW = preEW, Z = preZ / NavCoordinateHelper.NavZScale, + TargetName = pc.Name, ObjectClass = pc.Cls, + PortalExitNS = pc.NS, PortalExitEW = pc.EW, PortalExitZ = pc.NavZ, + }); + if (o.RecordPauseAfterPortalMs > 0) + AddRecorded(new NavPoint { Type = NavPointType.Pause, NS = ns, EW = ew, Z = z / NavCoordinateHelper.NavZScale, PauseTimeMs = o.RecordPauseAfterPortalMs }); + _chat($"[RynthAi] Nav record: added Portal step '{pc.Name}'."); + } + else + { + _chat("[RynthAi] Nav record: teleport detected — add a Portal or Recall step for it if the route needs one."); + } + _portalCandidate = null; + _recNS = double.NaN; + } + + if (!double.IsNaN(_recNS) && NavRouteEditing.DistanceYards(_recNS, _recEW, ns, ew) < o.RecordSpacingYards) + return; + + AddRecorded(new NavPoint { Type = NavPointType.Point, NS = ns, EW = ew, Z = z / NavCoordinateHelper.NavZScale }); + _recNS = ns; + _recEW = ew; + } + + /// Remembers the last selected portal (name, class, position) for the teleport step. + private void TrackPortalSelection() + { + if (!_host.HasGetSelectedItemId) return; + uint sel = _host.GetSelectedItemId(); + if (sel == 0) return; + if (_portalCandidate is { } cur && Environment.TickCount64 - cur.At < 1000) return; // refresh ~1/s + if (_describePortal(sel) is not { } info) return; + + double pns = 0, pew = 0, pz = 0; + if (_host.HasGetObjectPosition + && _host.TryGetObjectPosition(sel, out uint pcell, out float ox, out float oy, out float oz) + && NavCoordinateHelper.TryConvertPoseToCoords(pcell, ox, oy, out pns, out pew)) + pz = oz / NavCoordinateHelper.NavZScale; + _portalCandidate = (info.Name, info.ObjectClass, pns, pew, pz, Environment.TickCount64); + } + + private void AddRecorded(NavPoint p) + { + NavRouteEditing.Apply(_settings, list => { list.Add(p); return list; }); + Interlocked.Increment(ref _recAdded); + if (++_recSinceSave >= RecordAutosaveEvery) + { + _recSinceSave = 0; + SaveRouteFile(); + } + } + + /// Session teardown: saves a recording in progress (no chat — the session is ending). + public void Shutdown() + { + if (_recordingActive) StopRecordingSession(announce: false); + } + + private void StopRecordingSession(bool announce = true) + { + _recordingActive = false; + _portalCandidate = null; + SaveRouteFile(); + RynthLog.Write(LogCat.Navigation, $"[NavRecord] recording stopped ({_recAdded} waypoints added)."); + if (announce) + _chat($"[RynthAi] Nav record stopped: {_recAdded} waypoints added" + + (string.IsNullOrEmpty(_settings.CurrentNavPath) ? " (route not saved yet — use Save As)." : " and saved.")); + } + + private void SaveRouteFile() + { + if (string.IsNullOrEmpty(_settings.CurrentNavPath)) return; + try { _settings.CurrentRoute.Save(_settings.CurrentNavPath); } + catch (Exception ex) { RynthLog.Write(LogCat.Navigation, $"[NavRecord] save failed: {ex.Message}"); } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/NavMarkerRenderer.cs b/Plugins/RynthCore.Plugin.RynthAi/NavMarkerRenderer.cs index ecc3b52..0e2151b 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/NavMarkerRenderer.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/NavMarkerRenderer.cs @@ -124,6 +124,10 @@ internal sealed class NavMarkerRenderer playerNS = playerEW = 0.0; ringRadius = 0f; heightOffset = 0f; + // Route overlay switched off (Nav panel / "/ra navoverlay off"): no rings or lines. + if (!_settings.NavOverlay.ShowRouteMarkers) + return false; + var r = _settings.CurrentRoute; if (r?.Points == null || r.Points.Count == 0) return false; diff --git a/Plugins/RynthCore.Plugin.RynthAi/NavOverlayRenderer.cs b/Plugins/RynthCore.Plugin.RynthAi/NavOverlayRenderer.cs new file mode 100644 index 0000000..8b98a0c --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/NavOverlayRenderer.cs @@ -0,0 +1,354 @@ +// NavOverlayRenderer.cs — on-screen navigation aids on top of NavMarkerRenderer's route rings: +// +// * Waypoint HUD: small movable window with the active waypoint, distance, a direction +// arrow relative to the character's facing, the next step, remaining route length, +// breadcrumb / recording status. +// * Waypoint labels: "#12 34yd" over the next N travel points in the 3D view. +// * Guide line: player → active waypoint (UB-IT world-overlay "breadcrumb" line). +// * Breadcrumb trail: NavBreadcrumbTracker samples drawn on the ground, fading with age. +// +// 3D geometry (guide line, trail) is submitted from OnTick through the engine's Nav3D buffer +// (shared budget: 512 lines across all plugins), with an ImGui projected fallback when the +// engine has no Nav3D API. HUD and labels are ImGui and need the overlay. +using System; +using System.IO; +using System.Numerics; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi; + +internal sealed class NavOverlayRenderer +{ + /// Most trail segments submitted per frame (route markers use up to 128 lines). + private const int MaxTrailLines = 200; + /// Label text sits this far above the waypoint ring, world units. + private const float LabelLift = 1.2f; + + private readonly RynthCoreHost _host; + private readonly LegacyUiSettings _settings; + private readonly NavBreadcrumbTracker _trail; + + public NavOverlayRenderer(RynthCoreHost host, LegacyUiSettings settings, NavBreadcrumbTracker trail) + { + _host = host; + _settings = settings; + _trail = trail; + } + + /// Player frame shared by every pass (marker world frame: X=EW, Y=up, Z=NS). + private readonly record struct Frame(double NS, double EW, float Px, float Py, float Pz, float HeadingDeg); + + private bool TryGetFrame(out Frame f) + { + f = default; + if (_host.HasIsPortaling && _host.IsPortaling()) return false; + if (!NavCoordinateHelper.TryGetNavCoords(_host, out double ns, out double ew)) return false; + if (!_host.TryGetPlayerPose(out uint cell, out float px, out float py, out float pz, + out float qw, out _, out _, out float qz)) return false; + if ((cell >> 16) == 0) return false; + // Physics yaw (CCW from north) → compass heading (0 = north, clockwise), as NavigationEngine. + double yaw = 2.0 * Math.Atan2(qz, qw) * (180.0 / Math.PI); + f = new Frame(ns, ew, px, py, pz, (float)((-yaw + 720.0) % 360.0)); + return true; + } + + private Vector3 ToWorld(in Frame f, double ns, double ew, float worldY) + => new(f.Px + (float)((ew - f.EW) * NavRouteEditing.NavToYards), worldY, + f.Py + (float)((ns - f.NS) * NavRouteEditing.NavToYards)); + + private float WaypointWorldY(NavPoint p) => (float)(p.Z * NavCoordinateHelper.NavZScale) + _settings.NavHeightOffset; + + /// Active waypoint when it is a travel Point, else null. + private NavPoint? ActivePoint(out int index) + { + var pts = _settings.CurrentRoute?.Points; + index = _settings.ActiveNavIndex; + if (pts == null || index < 0 || index >= pts.Count) return null; + return pts[index]; + } + + // ═══════════════════════════════════════════════════════════════════ + // 3D (tick thread) + // ═══════════════════════════════════════════════════════════════════ + + /// Guide line + breadcrumb trail into the Nav3D buffer. Call from OnTick. + public void SubmitNav3D() + { + if (!_host.HasNav3D) return; + try + { + if (!TryGetFrame(out var f)) return; + var o = _settings.NavOverlay; + float lineThick = _settings.NavLineThickness * 0.01f; + + if (o.TrailVisible()) + ForEachTrailSegment(f, o, (a, b, fade) => + _host.Nav3DAddLine(a.X, a.Y, a.Z, b.X, b.Y, b.Z, lineThick * 0.7f, + NavOverlaySettings.ScaleAlpha(o.ColorBreadcrumb, fade))); + + if (o.GuideLineVisible() && ActivePoint(out _) is { Type: NavPointType.Point } ap) + { + Vector3 me = new(f.Px, f.Pz + _settings.NavHeightOffset, f.Py); + Vector3 to = ToWorld(f, ap.NS, ap.EW, WaypointWorldY(ap)); + _host.Nav3DAddLine(me.X, me.Y, me.Z, to.X, to.Y, to.Z, lineThick * 0.8f, o.ColorGuide); + } + } + catch (Exception ex) { RynthLog.Write(LogCat.Navigation, $"NavOverlay(3D): {ex.Message}"); } + } + + /// + /// Newest-first walk of the trail within draw range, capped at ; + /// no segment crosses a teleport break. fade is 1 for the newest segment. + /// + private void ForEachTrailSegment(in Frame f, NavOverlaySettings o, Action draw) + { + NavCrumb[] trail = _trail.Trail; + if (trail.Length < 2) return; + float lift = _settings.NavHeightOffset + 0.03f; + int drawn = 0, total = Math.Min(trail.Length - 1, MaxTrailLines); + for (int i = trail.Length - 1; i >= 1 && drawn < MaxTrailLines; i--) + { + NavCrumb b = trail[i], a = trail[i - 1]; + if (b.SegmentStart) continue; + if (NavRouteEditing.DistanceYards(f.NS, f.EW, b.NS, b.EW) > o.BreadcrumbDrawRangeYards) continue; + float fade = o.BreadcrumbFade ? 1f - 0.8f * drawn / Math.Max(1, total) : 1f; + draw(ToWorld(f, a.NS, a.EW, a.Z + lift), ToWorld(f, b.NS, b.EW, b.Z + lift), fade); + drawn++; + } + } + + // ═══════════════════════════════════════════════════════════════════ + // ImGui (render thread) + // ═══════════════════════════════════════════════════════════════════ + + /// HUD window, waypoint labels, and the projected fallback for trail/guide. Call inside an ImGui frame. + public void Render() + { + try + { + var o = _settings.NavOverlay; + var route = _settings.CurrentRoute; + bool hasRoute = route?.Points is { Count: > 0 }; + bool navigating = _settings.IsMacroRunning && _settings.EnableNavigation; + bool wantFallback3D = !_host.HasNav3D && (o.TrailVisible() || o.GuideLineVisible()); + bool wantLabels = o.LabelsVisible() && hasRoute; + bool wantHud = o.ShowHud && (hasRoute || _settings.IsRecordingNav) && (!o.HudOnlyWhileNavigating || navigating); + if (!wantFallback3D && !wantLabels && !wantHud) return; + if (!TryGetFrame(out var f)) return; + + if (wantFallback3D || wantLabels) RenderWorldOverlay(f, o, wantLabels, wantFallback3D); + if (wantHud) RenderHud(f, o); + } + catch (Exception ex) { RynthLog.Write(LogCat.Navigation, $"NavOverlay(ImGui): {ex.Message}"); } + } + + private void RenderWorldOverlay(in Frame f, NavOverlaySettings o, bool labels, bool fallback3D) + { + if (!_host.HasWorldToScreen || !_host.HasGetViewportSize) return; + if (!_host.TryGetViewportSize(out uint vpW, out uint vpH) || vpW == 0 || vpH == 0) return; + + ImGui.SetNextWindowPos(Vector2.Zero); + ImGui.SetNextWindowSize(new Vector2(vpW, vpH)); + ImGui.PushStyleColor(ImGuiCol.WindowBg, 0u); + ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0f); + ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero); + bool open = true; + bool visible = ImGui.Begin("##NavWaypointOverlay", ref open, + ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | + ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.NoCollapse | + ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoBringToFrontOnFocus | + ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoSavedSettings); + try + { + if (!visible) return; + var dl = ImGui.GetWindowDrawList(); + float thick = Math.Max(1f, _settings.NavLineThickness * 0.5f); + var frame = f; + + if (fallback3D && o.TrailVisible()) + { + ForEachTrailSegment(f, o, (a, b, fade) => + { + if (Project(a, out var sa) && Project(b, out var sb)) + dl.AddLine(sa, sb, NavOverlaySettings.ArgbToImGui(NavOverlaySettings.ScaleAlpha(o.ColorBreadcrumb, fade)), thick); + }); + } + if (fallback3D && o.GuideLineVisible() && ActivePoint(out _) is { Type: NavPointType.Point } ap + && Project(new Vector3(f.Px, f.Pz + _settings.NavHeightOffset, f.Py), out var sMe) + && Project(ToWorld(frame, ap.NS, ap.EW, WaypointWorldY(ap)), out var sTo)) + dl.AddLine(sMe, sTo, NavOverlaySettings.ArgbToImGui(o.ColorGuide), thick); + + if (labels) DrawWaypointLabels(dl, f, o); + } + finally + { + ImGui.End(); + ImGui.PopStyleVar(2); + ImGui.PopStyleColor(); + } + } + + private bool Project(Vector3 w, out Vector2 s) + { + bool ok = _host.WorldToScreen(w.X, w.Y, w.Z, out float sx, out float sy); + s = new Vector2(sx, sy); + return ok; + } + + /// "#12 34yd" over the active travel point and the next ones in route order. + private void DrawWaypointLabels(ImDrawListPtr dl, in Frame f, NavOverlaySettings o) + { + var route = _settings.CurrentRoute; + var pts = route.Points; + int n = pts.Count; + int idx = Math.Clamp(_settings.ActiveNavIndex, 0, n - 1); + bool circular = route.RouteType == NavRouteType.Circular; + uint activeCol = NavOverlaySettings.ArgbToImGui(o.ColorActiveRing); + uint nextCol = NavOverlaySettings.ArgbToImGui(o.ColorRing); + uint bg = 0xB0000000; + + int labelled = 0; + for (int step = 0; step < n && labelled < o.LabelsAhead; step++) + { + int i = circular ? (idx + step) % n : idx + step; + if (i >= n) break; + var p = pts[i]; + if (p.Type != NavPointType.Point) continue; + + Vector3 w = ToWorld(f, p.NS, p.EW, WaypointWorldY(p) + LabelLift); + if (!Project(w, out var s)) { labelled++; continue; } + + double yd = NavRouteEditing.DistanceYards(f.NS, f.EW, p.NS, p.EW); + string text = $"#{i} {yd:F0}yd"; + Vector2 size = ImGui.CalcTextSize(text); + Vector2 tl = s - new Vector2(size.X * 0.5f + 4, size.Y + 2); + dl.AddRectFilled(tl, tl + size + new Vector2(8, 4), bg, 3f); + dl.AddText(tl + new Vector2(4, 2), i == _settings.ActiveNavIndex ? activeCol : nextCol, text); + labelled++; + } + } + + private void RenderHud(in Frame f, NavOverlaySettings o) + { + ImGui.SetNextWindowPos(new Vector2(20, 220), ImGuiCond.FirstUseEver); + ImGui.SetNextWindowBgAlpha(0.65f); + if (!ImGui.Begin("Nav HUD##RynthAiNavHud", ref o.ShowHud, + ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse | + ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNav)) + { + ImGui.End(); + return; + } + + var route = _settings.CurrentRoute; + var pts = route.Points; + string name = string.IsNullOrEmpty(_settings.CurrentNavPath) ? "(unsaved)" : Path.GetFileNameWithoutExtension(_settings.CurrentNavPath); + ImGui.TextColored(new Vector4(1f, 0.85f, 0.3f, 1f), $"{name} [{route.RouteType}]"); + if (_settings.IsRecordingNav) + { + ImGui.SameLine(); + ImGui.TextColored(new Vector4(1f, 0.3f, 0.3f, 1f), $"REC +{_trail.RecordedCount}"); + } + + int idx = _settings.ActiveNavIndex; + if (pts.Count > 0 && idx >= 0 && idx < pts.Count) + { + var p = pts[idx]; + bool travel = p.Type == NavPointType.Point; + ImGui.BeginGroup(); + ImGui.Text($"WP {idx}/{pts.Count - 1} {TypeLabel(p)}"); + if (travel) + { + double yd = NavRouteEditing.DistanceYards(f.NS, f.EW, p.NS, p.EW); + double dz = (p.Z * NavCoordinateHelper.NavZScale) - f.Pz; + ImGui.Text(Math.Abs(dz) >= 3 ? $"{yd:F1} yd ({(dz > 0 ? "up" : "down")} {Math.Abs(dz):F0})" : $"{yd:F1} yd"); + } + else + { + ImGui.TextDisabled(p.ToString()); + } + int ni = NextIndex(route, idx); + if (ni >= 0) ImGui.TextDisabled($"Next: [{ni}] {pts[ni]}"); + double remain = RemainingYards(route, idx, f); + if (remain > 0) ImGui.TextDisabled(route.RouteType == NavRouteType.Circular ? $"Loop: {remain:F0} yd" : $"Remaining: ~{remain:F0} yd"); + ImGui.EndGroup(); + + if (travel) + { + ImGui.SameLine(); + double bearing = Math.Atan2(p.EW - f.EW, p.NS - f.NS) * (180.0 / Math.PI); + DrawArrow((float)(bearing - f.HeadingDeg), NavOverlaySettings.ArgbToImGui(o.ColorGuide)); + } + } + else if (pts.Count == 0) + { + ImGui.TextDisabled("Route is empty."); + } + + if (!string.IsNullOrEmpty(_settings.NavStatusLine)) + ImGui.TextColored(_settings.NavIsStuck ? new Vector4(0.91f, 0.70f, 0.20f, 1f) : new Vector4(0.6f, 0.75f, 0.6f, 1f), + _settings.NavStatusLine); + if (o.TrackBreadcrumbs) + ImGui.TextDisabled($"Trail: {_trail.Trail.Length} pts, {_trail.TrailYards:F0} yd"); + ImGui.End(); + } + + /// Direction arrow in a 36 px box; 0 = straight ahead, clockwise. + private static void DrawArrow(float relDeg, uint color) + { + const float Box = 36f; + Vector2 tl = ImGui.GetCursorScreenPos(); + ImGui.Dummy(new Vector2(Box, Box)); + var dl = ImGui.GetWindowDrawList(); + Vector2 c = tl + new Vector2(Box * 0.5f, Box * 0.5f); + dl.AddCircle(c, Box * 0.48f, 0x60FFFFFF, 24, 1.5f); + + double a = relDeg * Math.PI / 180.0; + var dir = new Vector2((float)Math.Sin(a), -(float)Math.Cos(a)); + var perp = new Vector2(-dir.Y, dir.X); + dl.AddTriangleFilled(c + dir * 14f, c - dir * 8f + perp * 7f, c - dir * 8f - perp * 7f, color); + } + + private static string TypeLabel(NavPoint p) => p.Type switch + { + NavPointType.Point => "Point", + NavPointType.Recall => "Recall", + NavPointType.Pause => "Pause", + NavPointType.Chat => "Chat", + NavPointType.OpenVendor => "Vendor", + NavPointType.PortalNPC => "Portal", + NavPointType.Npc => "NPC", + _ => p.Type.ToString(), + }; + + /// Following waypoint in route order (wraps on circular), or -1 at the end. + private static int NextIndex(NavRouteParser route, int idx) + { + int n = route.Points.Count; + if (idx + 1 < n) return idx + 1; + return route.RouteType == NavRouteType.Circular && n > 1 ? 0 : -1; + } + + /// Player → active point → … end of route (one lap for circular), walking legs only. + private static double RemainingYards(NavRouteParser route, int idx, in Frame f) + { + var pts = route.Points; + int n = pts.Count; + if (idx < 0 || idx >= n) return 0; + double total = 0; + NavPoint? prev = null; + int steps = route.RouteType == NavRouteType.Circular ? n : n - idx; + for (int s = 0; s < steps; s++) + { + var p = pts[(idx + s) % n]; + if (p.Type != NavPointType.Point) { prev = null; continue; } + total += prev == null + ? (s == 0 ? NavRouteEditing.DistanceYards(f.NS, f.EW, p.NS, p.EW) : 0) + : NavRouteEditing.DistanceYards(prev.NS, prev.EW, p.NS, p.EW); + prev = p; + } + return total; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/NavigationEngine.cs b/Plugins/RynthCore.Plugin.RynthAi/NavigationEngine.cs index 7b98ee5..1944548 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/NavigationEngine.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/NavigationEngine.cs @@ -71,6 +71,13 @@ internal sealed class NavigationEngine private long _globalSettleStart; // ── Route state ────────────────────────────────────────────────────────── + // Where nav stopped for a pause (combat, loot, buff, door); NaN when not paused. With + // NavResumeNearest on, a pause that moved the character re-picks the closest waypoint. + private double _pauseNs = double.NaN; + private double _pauseEw = double.NaN; + private bool _resumeCheckPending; // nav took over again; check _pauseNs/_pauseEw on the next steer tick + private const double ResumeMovedYards = 10.0; // moved less while paused: carry on to the same waypoint + private const double ResumeTeleportYards = 400.0; // moved more: a teleport, which the portal handling owns private int _linearDir = 1; private bool _inPause; private int _pauseIdx = -1; // the Pause waypoint _pauseUntil belongs to @@ -409,6 +416,7 @@ internal sealed class NavigationEngine _isMovingForward = false; _isTurning = false; _hasStopped = true; + MarkPausePosition(); RememberFiredPortalAction(); ResetPortalState(); } @@ -417,6 +425,7 @@ internal sealed class NavigationEngine } _stopRequestedAt = long.MaxValue; + if (_hasStopped) _resumeCheckPending = true; _hasStopped = false; // Fellowship-follow takes priority over route nav while enabled: steer @@ -456,6 +465,8 @@ internal sealed class NavigationEngine _stuckCount = 0; _inRecovery = false; _hasGoodHeading = false; + // The loader chose the new route's start index; a pause on the old route says nothing. + ClearPausePosition(); ResetPortalState(); ResetRecovery("the route changed"); _host.Log($"Nav: route swap detected, {route.Points.Count} pts, startIdx={_settings.ActiveNavIndex}"); @@ -544,6 +555,13 @@ internal sealed class NavigationEngine } } + // Back from a pause, past any teleport settle: rejoin at the closest waypoint if it moved us. + if (_resumeCheckPending) + { + _resumeCheckPending = false; + ResumeAfterPause(); + } + int idx = _settings.ActiveNavIndex; if (!IndexValid(idx, route)) { HandleRouteEnd(route); return; } @@ -691,21 +709,75 @@ internal sealed class NavigationEngine _isMovingForward = false; _isTurning = false; _hasStopped = true; + MarkPausePosition(); } + /// Remembers where the first stop of a pause happened (later stops in the same pause keep it). + private void MarkPausePosition() + { + if (!double.IsNaN(_pauseNs)) return; + if (!TryGetPos(out double ns, out double ew)) return; + _pauseNs = ns; + _pauseEw = ew; + } + + private void ClearPausePosition() + { + _pauseNs = double.NaN; + _pauseEw = double.NaN; + _resumeCheckPending = false; + } + + /// + /// Nav took over again after a pause. With NavResumeNearest on and the pause having + /// moved the character or more (a chase, a corpse run), the + /// route re-picks its closest waypoint instead of walking back to the one it was heading for. + /// A detour or area hold in progress owns getting back, so it is left alone. + /// + private void ResumeAfterPause() + { + double pNs = _pauseNs, pEw = _pauseEw; + ClearPausePosition(); + if (!_settings.NavResumeNearest || double.IsNaN(pNs)) return; + if (_detour != null || _areaMismatch) return; + if (KeepWaypointAfterPause?.Invoke() == true) return; + if (!TryGetPos(out double ns, out double ew)) return; + + double movedYd = Math.Sqrt(Sq(ns - pNs) + Sq(ew - pEw)) * 240.0; + if (movedYd < ResumeMovedYards || movedYd > ResumeTeleportYards) return; + RepickNearestWaypoint($"back from a pause that moved {movedYd:F0}yd", resetRecovery: false); + } + + /// + /// True while the route must carry on to the waypoint it was heading for after a pause, even + /// with NavResumeNearest on (set by the plugin: the dungeon patrol). A patrol loop comes back + /// past the rooms it started in, so the closest waypoint after a chase is often one near the + /// END of the loop, and everything in between would be skipped. + /// + public Func? KeepWaypointAfterPause; + + /// Sends a Chat waypoint's text as if typed in chat (set by the plugin). + public Action? ChatSubmit; + /// /// Points the route at the waypoint nearest the player (macro start). Circular /// and Linear routes pick from the whole route; a Once route only from the /// current waypoint onward, so finished steps (a recall, a portal) aren't /// repeated. Only plain waypoints are candidates; if the current one is a - /// Recall/Portal/Chat/Pause step it is kept. + /// Recall/Portal/Chat/Pause step it is kept. With NavResumeNearest off the + /// route keeps its last waypoint, unless (hazard escapes + /// and corpse runs, which leave the route behind). /// - /// Sends a Chat waypoint's text as if typed in chat (set by the plugin). - public Action? ChatSubmit; - - public void ResumeFromNearestWaypoint() + public void ResumeFromNearestWaypoint(bool always = false) { - ResetRecovery("macro started"); + ClearPausePosition(); + if (!always && !_settings.NavResumeNearest) return; + RepickNearestWaypoint("macro start", resetRecovery: true); + } + + private void RepickNearestWaypoint(string why, bool resetRecovery) + { + if (resetRecovery) ResetRecovery("macro started"); var route = _settings.CurrentRoute; if (route == null || route.Points.Count == 0) return; if (route.RouteType == NavRouteType.Follow) return; @@ -739,9 +811,16 @@ internal sealed class NavigationEngine string how = "nearest"; int walkBest = PickNearestByWalk(route, from, once, cur, ns, ew, out double walkYd); if (walkBest >= 0) { best = walkBest; how = $"nearest on foot ({walkYd:F0}yd walk)"; } + else + { + // Already walked past the nearest point toward the next one: the closest spot on + // the route lies on the leg ahead, so head for its far end instead of turning back. + int ahead = PassedToward(route, best, ns, ew); + if (ahead >= 0) { best = ahead; how = "next after the nearest"; } + } if (best == cur) return; - _host.Log($"Nav: macro start — {how} waypoint [{best}] ({Math.Sqrt(Sq(route.Points[best].NS - ns) + Sq(route.Points[best].EW - ew)) * 240.0:F0}yd) instead of [{cur}]"); + _host.Log($"Nav: {why} — {how} waypoint [{best}] ({Math.Sqrt(Sq(route.Points[best].NS - ns) + Sq(route.Points[best].EW - ew)) * 240.0:F0}yd) instead of [{cur}]"); _settings.ActiveNavIndex = best; _closestDist = double.MaxValue; _stuckCount = 0; @@ -749,6 +828,41 @@ internal sealed class NavigationEngine _watchdogEw = double.NaN; } + /// + /// The waypoint after in the direction the route runs, when the + /// closest spot on the route is on the leg out of (the player has + /// walked past it) rather than on the leg into it; otherwise -1. The next point must be a + /// plain waypoint (a step is never jumped to), and a Linear route at its end has no leg + /// ahead in its current direction. With no plain point before the + /// leg in is the point itself. + /// + private int PassedToward(NavRouteParser route, int idx, double ns, double ew) + { + int n = route.Points.Count; + int step = route.RouteType == NavRouteType.Linear ? _linearDir : 1; + int next = idx + step, prev = idx - step; + if (route.RouteType == NavRouteType.Circular) { next = (idx + 1) % n; prev = (idx - 1 + n) % n; } + if (!IndexValid(next, route) || next == idx) return -1; + var a = route.Points[idx]; + var b = route.Points[next]; + if (!NavRouteParser.IsPlainWaypoint(b.Type)) return -1; + + double legOut = SegmentDistSq(ns, ew, a, b); + double legIn = IndexValid(prev, route) && prev != idx && NavRouteParser.IsPlainWaypoint(route.Points[prev].Type) + ? SegmentDistSq(ns, ew, route.Points[prev], a) + : Sq(ns - a.NS) + Sq(ew - a.EW); + return legOut < legIn ? next : -1; + } + + /// Squared map distance from (ns, ew) to the leg a→b. + private static double SegmentDistSq(double ns, double ew, NavPoint a, NavPoint b) + { + double vN = b.NS - a.NS, vE = b.EW - a.EW; + double len = vN * vN + vE * vE; + double t = len <= 0 ? 0 : Math.Clamp(((ns - a.NS) * vN + (ew - a.EW) * vE) / len, 0, 1); + return Sq(ns - (a.NS + t * vN)) + Sq(ew - (a.EW + t * vE)); + } + private const int WalkCandidates = 5; private static double Sq(double v) => v * v; @@ -794,6 +908,7 @@ internal sealed class NavigationEngine public void ResetRouteState() { Stop(); + ClearPausePosition(); ResetRecovery("route reset"); _teleportedRoute = null; _firedRoute = null; diff --git a/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs b/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs index b19cdcc..634b418 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs @@ -15,7 +15,8 @@ public static unsafe class PluginExports // Typed interfaces for other plugins (host GetPluginInterface, API v68): "RynthAi.Script" v1 // for RynthLua, "RynthAi.Status" v1 for RynthNet (the bot state it shares with the other clients), - // "RynthAi.Activity" v1 for RynthSort (what the bot is doing, so pack moves stay out of its way). + // "RynthAi.Activity" v1 for RynthSort (what the bot is doing, so pack moves stay out of its way), + // "RynthAi.Combat" v1 for RynthLua (a script choosing attack and heal spells, Shared/RynthAiCombatApi.cs). // Fixed signature: void* (const char* iface, uint version). [UnmanagedCallersOnly(EntryPoint = "RynthPluginQueryInterface", CallConvs = new[] { typeof(CallConvCdecl) })] private static IntPtr QueryInterface(IntPtr ifaceAnsi, uint version) @@ -25,7 +26,8 @@ public static unsafe class PluginExports string iface = ifaceAnsi == IntPtr.Zero ? "" : Marshal.PtrToStringAnsi(ifaceAnsi) ?? ""; IntPtr table = ScriptInterface.Query(iface, version); if (table == IntPtr.Zero) table = StatusInterface.Query(iface, version); - return table != IntPtr.Zero ? table : ActivityInterface.Query(iface, version); + if (table == IntPtr.Zero) table = ActivityInterface.Query(iface, version); + return table != IntPtr.Zero ? table : CombatHookInterface.Query(iface, version); } catch { @@ -39,13 +41,31 @@ public static unsafe class PluginExports [UnmanagedCallersOnly(EntryPoint = "RynthPluginShutdown", CallConvs = new[] { typeof(CallConvCdecl) })] public static void Shutdown() { - Runtime.Shutdown(); - StatusInterface.Release(); - ActivityInterface.Release(); - // The loot editor's state can be a few hundred KB (LootSnobV4): don't leave it behind on a reload. - foreach (IntPtr p in new[] { Interlocked.Exchange(ref _lootStatePtr, IntPtr.Zero), - Interlocked.Exchange(ref _lootRulePtr, IntPtr.Zero), Interlocked.Exchange(ref _lootVocabPtr, IntPtr.Zero) }) - if (p != IntPtr.Zero) Marshal.FreeCoTaskMem(p); + // An exception escaping an UnmanagedCallersOnly export fail-fasts the whole client under + // NativeAOT. Each step is guarded on its own so one failure cannot skip the rest. + RynthAiPlugin? plugin = Runtime.Plugin; // Runtime.Shutdown drops it; the log needs its host + try { Runtime.Shutdown(); } + catch (Exception ex) { LogShutdownError(plugin, "Runtime.Shutdown", ex); } + try { StatusInterface.Release(); } + catch (Exception ex) { LogShutdownError(plugin, "StatusInterface.Release", ex); } + try { ActivityInterface.Release(); } + catch (Exception ex) { LogShutdownError(plugin, "ActivityInterface.Release", ex); } + try { CombatHookInterface.Shutdown(); } // the hook goes native at once (RynthLua re-claims after a reload) + catch (Exception ex) { LogShutdownError(plugin, "CombatHookInterface.Shutdown", ex); } + try + { + // The loot editor's state can be a few hundred KB (LootSnobV4): don't leave it behind on a reload. + foreach (IntPtr p in new[] { Interlocked.Exchange(ref _lootStatePtr, IntPtr.Zero), + Interlocked.Exchange(ref _lootRulePtr, IntPtr.Zero), Interlocked.Exchange(ref _lootVocabPtr, IntPtr.Zero) }) + if (p != IntPtr.Zero) Marshal.FreeCoTaskMem(p); + } + catch (Exception ex) { LogShutdownError(plugin, "loot buffers", ex); } + } + + private static void LogShutdownError(RynthAiPlugin? plugin, string step, Exception ex) + { + try { plugin?.LogFromExport($"[RynthAi] Shutdown: {step} failed: {ex.GetType().Name}: {ex.Message}"); } + catch { /* nothing more to do: never throw out of a native export */ } } [UnmanagedCallersOnly(EntryPoint = "RynthPluginOnUIInitialized", CallConvs = new[] { typeof(CallConvCdecl) })] @@ -61,14 +81,77 @@ public static unsafe class PluginExports public static void OnSelectedTargetChange(uint currentTargetId, uint previousTargetId) => Runtime.OnSelectedTargetChange(currentTargetId, previousTargetId); [UnmanagedCallersOnly(EntryPoint = "RynthPluginName", CallConvs = new[] { typeof(CallConvCdecl) })] - public static IntPtr GetName() => RynthAiPlugin.NamePointer; + public static IntPtr GetName() + { + try { return RynthAiPlugin.NamePointer; } // a static initializer that throws surfaces here (TypeInitializationException) + catch { return IntPtr.Zero; } + } [UnmanagedCallersOnly(EntryPoint = "RynthPluginVersion", CallConvs = new[] { typeof(CallConvCdecl) })] - public static IntPtr GetVersion() => RynthAiPlugin.VersionPointer; + public static IntPtr GetVersion() + { + try { return RynthAiPlugin.VersionPointer; } + catch { return IntPtr.Zero; } + } [UnmanagedCallersOnly(EntryPoint = "RynthPluginTick", CallConvs = new[] { typeof(CallConvCdecl) })] public static void Tick() => Runtime.OnTick(); + // Local ImGui windows (ILT Hub, HUDs, translator, item info, nav overlay). The engine + // calls this when the export exists; the main panels stay on the engine side. + [UnmanagedCallersOnly(EntryPoint = "RynthPluginRender", CallConvs = new[] { typeof(CallConvCdecl) })] + public static void Render() => Runtime.OnRender(); + + /// Engine calls this instead of RynthPluginRender while its ImGui shell is off. + [UnmanagedCallersOnly(EntryPoint = "RynthPluginRenderOverlay", CallConvs = new[] { typeof(CallConvCdecl) })] + public static void RenderOverlay() + { + try { Runtime.Plugin?.OnRenderOverlay(); } + catch { /* an exception crossing UnmanagedCallersOnly would fail-fast the client */ } + } + + /// + /// Engine dashboard drawers (RynthCore 2026.10.5.21+): draws the named UTF-8 surface into the + /// engine's current ImGui window on the render thread and reports the size it wants. + /// Surfaces: "miniremote" (the RynthAi dashboard's Mini Remote drawer), "miniremote-window" + /// (the engine's Mini Remote window, which hosts the remote with its Toggles and ILT tabs) + /// and "guardian" (RynthCore 2026.10.5.29+: the engine's Guardian ILT panel). + /// RynthCore 2026.10.5.30+ adds ":popout" to the name when the panel is popped out into its + /// own window, whose ImGui context is not the one in Host.ImGuiContext; the surfaces draw + /// in the engine's current context either way (RenderEmbedded*). + /// 1 = drawn, 0 = not ready / unknown (nothing drawn). + /// + [UnmanagedCallersOnly(EntryPoint = "RynthPluginRenderEmbed", CallConvs = new[] { typeof(CallConvCdecl) })] + public static int RenderEmbed(byte* surface, float width, float height, float* wantWidth, float* wantHeight) + { + try + { + if (surface == null) return 0; + ReadOnlySpan name = MemoryMarshal.CreateReadOnlySpanFromNullTerminated(surface); + if (name.EndsWith(":popout"u8)) name = name[..^":popout"u8.Length]; + var plugin = Runtime.Plugin; + if (plugin == null) return 0; + System.Numerics.Vector2 want; + if (name.SequenceEqual("guardian"u8)) + { + if (!plugin.RenderEmbeddedGuardian(new System.Numerics.Vector2(width, height), out want)) return 0; + } + else + { + bool window = name.SequenceEqual("miniremote-window"u8); + if (!window && !name.SequenceEqual("miniremote"u8)) return 0; + if (!plugin.RenderEmbeddedMiniRemote(window, out want)) return 0; + } + if (wantWidth != null) *wantWidth = want.X; + if (wantHeight != null) *wantHeight = want.Y; + return 1; + } + catch + { + return 0; // an exception crossing UnmanagedCallersOnly would fail-fast the client + } + } + [UnmanagedCallersOnly(EntryPoint = "RynthPluginOnChatBarEnter", CallConvs = new[] { typeof(CallConvCdecl) })] public static void OnChatBarEnter(IntPtr textUtf16, IntPtr eatFlag) => Runtime.OnChatBarEnter(textUtf16, eatFlag); @@ -604,6 +687,10 @@ public static unsafe class PluginExports case "clearHazardsAll": Runtime.Plugin?.ClearAllDungeonHazards(); break; case "markHazardHere": Runtime.Plugin?.MarkCurrentCellHazardFromUi(); break; case "unmarkHazardHere":Runtime.Plugin?.UnmarkCurrentCellHazardFromUi(); break; + // The Dungeon Map's edits (click to add, drag to move, set next target). + case "addPointAt": + case "movePointTo": + case "setActive": Runtime.Plugin?.DashboardRenderer?.HandleMapNavCommand(cmd); break; default: Runtime.Plugin?.DashboardRenderer?.HandleNavCommand(json); break; } } @@ -630,6 +717,57 @@ public static unsafe class PluginExports } } + private static IntPtr _progressionPtr = IntPtr.Zero; + + /// + /// Skills panel Progression tab (ILT augmentations / enlightenment). Same contract as + /// RynthPluginGetPatrolInfoJson: one static buffer, valid until the next call; the engine + /// polls it from its pump thread only. + /// + [UnmanagedCallersOnly(EntryPoint = "RynthPluginGetProgressionJson", CallConvs = new[] { typeof(CallConvCdecl) })] + public static IntPtr GetProgressionJson() + { + try + { + string json = Runtime.Plugin?.BuildProgressionJson() ?? "{\"available\":false}"; + IntPtr newPtr = Marshal.StringToHGlobalAnsi(json); + IntPtr oldPtr = Interlocked.Exchange(ref _progressionPtr, newPtr); + if (oldPtr != IntPtr.Zero) + Marshal.FreeHGlobal(oldPtr); + return newPtr; + } + catch + { + return IntPtr.Zero; + } + } + + private static IntPtr _charmsPtr = IntPtr.Zero; + + /// + /// ACECustom registry charms (acquired / active / server state) for engines up to 2026.10.5.35, + /// whose Settings panel has a Charms Tracking tab; newer engines leave charms to the Mini + /// Remote's Charms tab. Same contract as RynthPluginGetProgressionJson: one static buffer, + /// valid until the next call; the engine polls it from its pump thread only. + /// + [UnmanagedCallersOnly(EntryPoint = "RynthPluginGetCharmsJson", CallConvs = new[] { typeof(CallConvCdecl) })] + public static IntPtr GetCharmsJson() + { + try + { + string json = Runtime.Plugin?.BuildCharmsJson() ?? "{\"available\":false}"; + IntPtr newPtr = Marshal.StringToHGlobalAnsi(json); + IntPtr oldPtr = Interlocked.Exchange(ref _charmsPtr, newPtr); + if (oldPtr != IntPtr.Zero) + Marshal.FreeHGlobal(oldPtr); + return newPtr; + } + catch + { + return IntPtr.Zero; + } + } + // ── Items bridge (engine-side Avalonia ItemsPanel) ────────────────────── private static IntPtr _itemsPtr = IntPtr.Zero; @@ -782,4 +920,12 @@ public static unsafe class PluginExports try { Runtime.Plugin?.DashboardRenderer?.AddSelectedConsumable(); } catch { } } + + /// Items panel "Remove Missing": drops weapons and consumables no longer in the inventory (reports in chat). + [UnmanagedCallersOnly(EntryPoint = "RynthPluginCleanItems", CallConvs = new[] { typeof(CallConvCdecl) })] + public static void CleanItems() + { + try { Runtime.Plugin?.CleanMissingItems(); } + catch { } + } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankProfileImporter.cs b/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankProfileImporter.cs new file mode 100644 index 0000000..501a800 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankProfileImporter.cs @@ -0,0 +1,329 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.Json; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.ProfileImport; + +/// +/// Copies VirindiTank-style loot files (.utl) and merges Rynth-format monster JSON found under common VT install paths. +/// +public static class VirindiTankProfileImporter +{ + /// Standard VirindiTank install locations (wiki / community bundles). + public static IReadOnlyList DefaultVirindiTankRoots() + { + var list = new List + { + @"C:\Games\VirindiPlugins\VirindiTank", + }; + + try + { + string docs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + if (!string.IsNullOrEmpty(docs)) + { + list.Add(Path.Combine(docs, "VirindiPlugins", "VirindiTank")); + list.Add(Path.Combine(docs, "Decal", "VirindiPlugins", "VirindiTank")); + } + } + catch { } + + try + { + string loc = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + if (!string.IsNullOrEmpty(loc)) + list.Add(Path.Combine(loc, "VirindiPlugins", "VirindiTank")); + } + catch { } + + return list.Distinct(StringComparer.OrdinalIgnoreCase).Where(Directory.Exists).ToList(); + } + + public sealed class Result + { + public int LootFilesCopied; + public int MonsterRulesAdded; + /// Full paths of .utl files copied into the Rynth loot folder this run (for activating loot). + public List CopiedLootDestPaths { get; } = new(); + public List LogLines { get; } = new(); + } + + /// RynthAi LootProfiles folder. + /// When true, deserialized rules are merged into . + public static Result Import(string lootDestDir, LegacyUiSettings settings, bool mergeMonsterRules) + { + var result = new Result(); + if (string.IsNullOrEmpty(lootDestDir)) + { + result.LogLines.Add("Loot destination folder is empty."); + return result; + } + + try { Directory.CreateDirectory(lootDestDir); } + catch (Exception ex) + { + result.LogLines.Add($"Cannot create loot folder: {ex.Message}"); + return result; + } + + var seenSrc = new HashSet(StringComparer.OrdinalIgnoreCase); + foreach (string root in DefaultVirindiTankRoots()) + { + foreach (string utl in EnumerateFilesRecursive(root, "*.utl", maxDepth: 6)) + { + if (!seenSrc.Add(utl)) continue; + string baseName = Path.GetFileName(utl); + string dest = Path.Combine(lootDestDir, baseName); + int suffix = 0; + while (File.Exists(dest)) + { + suffix++; + dest = Path.Combine(lootDestDir, $"VT_{suffix}_{baseName}"); + } + + try + { + File.Copy(utl, dest, overwrite: false); + result.LootFilesCopied++; + result.CopiedLootDestPaths.Add(dest); + result.LogLines.Add($"Loot: {baseName} -> {Path.GetFileName(dest)}"); + } + catch (Exception ex) + { + result.LogLines.Add($"Loot skip {baseName}: {ex.Message}"); + } + } + + if (mergeMonsterRules) + { + foreach (string jsonPath in EnumerateFilesRecursive(root, "monsters.json", maxDepth: 8)) + TryMergeMonsterFile(jsonPath, settings, result); + + foreach (string usdPath in EnumerateFilesRecursive(root, "*.usd", maxDepth: 6)) + TryMergeUsdMyMonstersScf(usdPath, settings, result); + } + } + + if (result.LootFilesCopied == 0 && result.MonsterRulesAdded == 0) + result.LogLines.Add("No .utl loot files, Rynth monsters.json, or text MyMonsters .usd found under VirindiTank paths."); + + return result; + } + + /// SQLite-backed VT profiles are skipped here; use Monster Editor import for those. + private static bool LooksLikeSqliteFile(string path) + { + try + { + using var fs = File.OpenRead(path); + var hdr = new byte[16]; + int n = fs.Read(hdr, 0, hdr.Length); + const string sig = "SQLite format 3\0"; + if (n < sig.Length) + return false; + for (int i = 0; i < sig.Length; i++) + { + if (hdr[i] != sig[i]) + return false; + } + + return true; + } + catch + { + return false; + } + } + + /// Text SCF .usd with MyMonsters — same subset as Monster Editor import for the current character merge. + private static void TryMergeUsdMyMonstersScf(string usdPath, LegacyUiSettings settings, Result result) + { + if (string.IsNullOrWhiteSpace(usdPath) || !File.Exists(usdPath)) + return; + if (LooksLikeSqliteFile(usdPath)) + { + result.LogLines.Add($"Monsters: skip SQLite .usd (use Monster Editor): {Path.GetFileName(usdPath)}"); + return; + } + + string allText; + try + { + allText = File.ReadAllText(usdPath, Encoding.UTF8); + } + catch (Exception ex) + { + result.LogLines.Add($"Monsters: skip .usd read {Path.GetFileName(usdPath)}: {ex.Message}"); + return; + } + + var tmp = new List(); + if (!VirindiTankUsdMyMonstersScfParser.TryParseMyMonsters(allText, tmp, out string? note) || tmp.Count == 0) + return; + + int addedBefore = result.MonsterRulesAdded; + MergeVtMonsterRows(tmp, settings, result); + int newNamed = result.MonsterRulesAdded - addedBefore; + result.LogLines.Add( + $"Monsters: VT MyMonsters from {Path.GetFileName(usdPath)} — parsed {tmp.Count} row(s), +{newNamed} new rule(s).{(string.IsNullOrEmpty(note) ? "" : " " + note)}"); + } + + /// Merges VT-style rows into like Monster Editor external import. + private static void MergeVtMonsterRows(IReadOnlyList src, LegacyUiSettings settings, Result result) + { + settings.EnsureDefaultRule(); + List rules = settings.MonsterRules; + + MonsterRule? srcDefault = src.FirstOrDefault(x => x.Name.Equals("Default", StringComparison.OrdinalIgnoreCase)); + if (srcDefault != null && rules.Count > 0 && rules[0].Name.Equals("Default", StringComparison.OrdinalIgnoreCase)) + CopyCombatOntoDefault(rules[0], srcDefault); + + var nameSet = new HashSet(rules.Select(x => x.Name), StringComparer.OrdinalIgnoreCase); + var exprSet = new HashSet( + rules.Where(x => !string.IsNullOrWhiteSpace(x.MatchExpression)).Select(x => x.MatchExpression), + StringComparer.Ordinal); + + foreach (MonsterRule row in src) + { + if (row.Name.Equals("Default", StringComparison.OrdinalIgnoreCase)) + continue; + + if (!string.IsNullOrEmpty(row.Name)) + { + if (nameSet.Contains(row.Name)) + continue; + } + else if (!string.IsNullOrEmpty(row.MatchExpression)) + { + if (exprSet.Contains(row.MatchExpression)) + continue; + } + else + { + continue; + } + + var c = CloneMonsterRule(row); + if (!string.IsNullOrEmpty(c.Name)) + { + if (!nameSet.Add(c.Name)) + continue; + } + + if (!string.IsNullOrEmpty(c.MatchExpression)) + exprSet.Add(c.MatchExpression); + + rules.Add(c); + result.MonsterRulesAdded++; + } + } + + private static void CopyCombatOntoDefault(MonsterRule dst, MonsterRule src) + { + dst.Category = src.Category; + dst.MatchExpression = src.MatchExpression; + dst.Priority = src.Priority; + dst.DamageType = src.DamageType; + dst.WeaponId = src.WeaponId; + dst.Fester = src.Fester; + dst.Broadside = src.Broadside; + dst.GravityWell = src.GravityWell; + dst.Imperil = src.Imperil; + dst.Yield = src.Yield; + dst.Vuln = src.Vuln; + dst.UseArc = src.UseArc; + dst.UseBolt = src.UseBolt; + dst.UseRing = src.UseRing; + dst.UseStreak = src.UseStreak; + dst.ExVuln = src.ExVuln; + dst.OffhandId = src.OffhandId; + dst.PreferredAmmoItemId = src.PreferredAmmoItemId; + dst.PetDamage = src.PetDamage; + } + + private static MonsterRule CloneMonsterRule(MonsterRule row) => + new() + { + Name = row.Name, + Category = row.Category, + MatchExpression = row.MatchExpression, + Priority = row.Priority, + DamageType = row.DamageType, + WeaponId = row.WeaponId, + Fester = row.Fester, + Broadside = row.Broadside, + GravityWell = row.GravityWell, + Imperil = row.Imperil, + Yield = row.Yield, + Vuln = row.Vuln, + UseArc = row.UseArc, + UseBolt = row.UseBolt, + UseRing = row.UseRing, + UseStreak = row.UseStreak, + ExVuln = row.ExVuln, + OffhandId = row.OffhandId, + PreferredAmmoItemId = row.PreferredAmmoItemId, + PetDamage = row.PetDamage, + }; + + private static void TryMergeMonsterFile(string jsonPath, LegacyUiSettings settings, Result result) + { + try + { + string json = File.ReadAllText(jsonPath); + var imported = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.MonsterRuleList); + if (imported == null || imported.Count == 0) return; + + int added = 0; + foreach (var rule in imported) + { + if (string.IsNullOrWhiteSpace(rule.Name)) continue; + if (rule.Name.Equals("Default", StringComparison.OrdinalIgnoreCase)) continue; + if (settings.MonsterRules.Any(m => m.Name.Equals(rule.Name, StringComparison.OrdinalIgnoreCase))) + continue; + settings.MonsterRules.Add(rule); + added++; + } + + if (added > 0) + { + result.MonsterRulesAdded += added; + result.LogLines.Add($"Monsters: merged {added} rule(s) from {Path.GetFileName(jsonPath)}"); + } + } + catch (Exception ex) + { + result.LogLines.Add($"Monsters skip {jsonPath}: {ex.Message}"); + } + } + + private static IEnumerable EnumerateFilesRecursive(string root, string pattern, int maxDepth) + { + if (string.IsNullOrEmpty(root) || !Directory.Exists(root)) yield break; + var stack = new Stack<(string Path, int Depth)>(); + stack.Push((root, 0)); + while (stack.Count > 0) + { + var (dir, depth) = stack.Pop(); + IEnumerable files; + try { files = Directory.EnumerateFiles(dir, pattern); } + catch { continue; } + + foreach (string f in files) + yield return f; + + if (depth >= maxDepth) continue; + + IEnumerable subdirs; + try { subdirs = Directory.EnumerateDirectories(dir); } + catch { continue; } + + foreach (string sub in subdirs) + stack.Push((sub, depth + 1)); + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankUsdMyMonstersScfParser.cs b/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankUsdMyMonstersScfParser.cs new file mode 100644 index 0000000..cd73ec1 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankUsdMyMonstersScfParser.cs @@ -0,0 +1,339 @@ +// Line-oriented uTank2 SCF .usd MyMonsters table — logic mirrors Tools/RynthCore.MonsterEditor/VirindiTankUsdTextScfParser.cs +// for LegacyUi.MonsterRule. If VT changes the SCF layout, update both files together. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi.ProfileImport; + +/// Parses VirindiTank text-format .usd files that contain a MyMonsters SCF block. +internal static class VirindiTankUsdMyMonstersScfParser +{ + /// Returns false if the file is not SCF MyMonsters (e.g. SQLite binary profile). + public static bool TryParseMyMonsters(string allText, List outList, out string? note) + { + outList.Clear(); + note = null; + if (string.IsNullOrWhiteSpace(allText) || allText.IndexOf("MyMonsters", StringComparison.Ordinal) < 0) + return false; + + string[] L = allText + .Split(new[] { "\r\n", "\n" }, StringSplitOptions.None) + .Select(s => s.Trim()) + .ToArray(); + if (L.Length < 8) + { + note = "File too short."; + return false; + } + + int idx = 0; + for (; idx < L.Length; idx++) + if (L[idx] == "MyMonsters") + break; + if (idx >= L.Length) + { + note = "MyMonsters not found."; + return false; + } + + idx++; + if (!int.TryParse(L[idx], out int colCount) || colCount < 1) + { + note = "MyMonsters: bad column count."; + return false; + } + + idx += 1 + colCount * 2; + if (idx >= L.Length) + { + note = "MyMonsters: truncated after header."; + return false; + } + + if (!int.TryParse(L[idx], out int rowCount) || rowCount < 0) + { + note = "MyMonsters: bad row count."; + return false; + } + + idx++; + if (rowCount == 0) + { + note = "MyMonsters has no rows."; + return false; + } + + if (colCount < 4 + 3) + { + note = "MyMonsters: column count too small."; + return false; + } + + int nBool = colCount - 4 - 3; + + for (int r = 0; r < rowCount; r++) + { + if (idx + 1 >= L.Length) + { + note = $"No data for row {r + 1} (early EOF)."; + return outList.Count > 0; + } + + if (!T(L, "s", ref idx)) + { + note = RowErr(r, "s"); + return outList.Count > 0; + } + + if (!ValStr(L, ref idx, out string raw)) + { + note = RowErr(r, "name"); + return outList.Count > 0; + } + + if (!T(L, "i", ref idx)) + { + note = RowErr(r, "i ap"); + return outList.Count > 0; + } + + if (!ValInt(L, ref idx, out int ap, out int err) || err != 0) + { + note = RowErr(r, "ap int"); + return outList.Count > 0; + } + + if (!T(L, "i", ref idx)) + { + note = RowErr(r, "i dt"); + return outList.Count > 0; + } + + if (!ValInt(L, ref idx, out int vtDmg, out err) || err != 0) + { + note = RowErr(r, "dt int"); + return outList.Count > 0; + } + + if (!T(L, "i", ref idx)) + { + note = RowErr(r, "i wep"); + return outList.Count > 0; + } + + if (!ValInt(L, ref idx, out int wep, out err) || err != 0) + { + note = RowErr(r, "wep int"); + return outList.Count > 0; + } + + if (nBool < 14) + { + note = "Expected at least 14 bool columns in mob row."; + return outList.Count > 0; + } + + if (nBool < 1) + { + note = "nBool<1."; + return false; + } + + var b = new bool[nBool]; + for (int k = 0; k < nBool; k++) + { + if (!T(L, "b", ref idx) || !ValBool(L, ref idx, out b[k])) + { + note = RowErr(r, $"b{k}"); + return outList.Count > 0; + } + } + + if (!T(L, "i", ref idx) || !ValInt(L, ref idx, out int sev, out err) || err != 0) + { + note = RowErr(r, "sec vuln int"); + return outList.Count > 0; + } + + if (!T(L, "i", ref idx) || !ValInt(L, ref idx, out int ofh, out err) || err != 0) + { + note = RowErr(r, "offh int"); + return outList.Count > 0; + } + + if (!T(L, "i", ref idx) || !ValInt(L, ref idx, out int pet, out err) || err != 0) + { + note = RowErr(r, "pet int"); + return outList.Count > 0; + } + + outList.Add(MakeRule(raw, ap, vtDmg, wep, b, sev, ofh, pet)); + } + + if (outList.Count == 0) + { + note = "No rows were parsed from MyMonsters."; + return false; + } + + return true; + } + + private static string RowErr(int r, string what) => $"MyMonsters row {r + 1} ({what})."; + + private static bool T(string[] L, string t, ref int i) + { + if (i >= L.Length || L[i] != t) + return false; + i++; + return true; + } + + private static bool ValStr(string[] L, ref int i, out string s) + { + s = ""; + if (i >= L.Length) + return false; + s = L[i++]; + return true; + } + + private static bool ValInt(string[] L, ref int i, out int v, out int err) + { + err = 0; + v = 0; + if (i >= L.Length) + { + err = 1; + return false; + } + + if (!int.TryParse(L[i], NumberStyles.Integer, CultureInfo.InvariantCulture, out v) && + !int.TryParse(L[i], out v)) + { + err = 1; + return false; + } + + i++; + return true; + } + + private static bool ValBool(string[] L, ref int i, out bool b) + { + b = false; + if (i >= L.Length) + return false; + string t = L[i++]; + if (string.Equals(t, "True", StringComparison.OrdinalIgnoreCase)) + { + b = true; + return true; + } + + if (string.Equals(t, "False", StringComparison.OrdinalIgnoreCase)) + { + b = false; + return true; + } + + return false; + } + + private static MonsterRule MakeRule(string raw, int ap, int vtDmg, int wep, bool[] b, int sev, int ofh, int pet) + { + string n = Nm(raw); + if (b.Length < 14) + b = Pad(b, 14); + bool i = b[0], v = b[1], y = b[2], gW = b[3]; + bool useBolt = b[4], useRing = b[5], broad = b[6], fest = b[7]; + bool strk = b[13]; + + return new MonsterRule + { + Name = n, + Priority = ap, + DamageType = MapDmg(vtDmg), + WeaponId = WepId(wep), + Imperil = i, + Vuln = v, + Yield = y, + GravityWell = gW, + UseBolt = useBolt, + UseRing = useRing, + Broadside = broad, + Fester = fest, + UseStreak = strk, + ExVuln = "None", + OffhandId = WepId(ofh), + PetDamage = MapPet(pet, sev), + }; + } + + private static bool[] Pad(bool[] b, int min) + { + if (b.Length >= min) + return b; + var r = new bool[min]; + for (int i = 0; i < b.Length; i++) + r[i] = b[i]; + return r; + } + + private static string Nm(string s) + { + s = s.Trim(); + if (s.Length > 1 && s[0] == '<' && s[^1] == '>') + { + string t = s.Substring(1, s.Length - 2); + if (t.Equals("DEFAULT", StringComparison.OrdinalIgnoreCase)) + return "Default"; + return t; + } + + return s; + } + + private static int WepId(int w) => w; + + private static string MapDmg(int c) => c switch + { + 8 => "Auto", + 1 => "Slash", + 2 => "Pierce", + 3 => "Bludgeon", + 4 => "Acid", + 5 => "Fire", + 6 => "Cold", + 7 => "Lightning", + 0 => "Nether", + _ => "Auto", + }; + + private static string MapPet(int pdt, int _) + { + if (pdt is 0 or 101) + return "PAuto"; + if (pdt is >= 1 and <= 8) + { + return pdt switch + { + 1 => "Slash", + 2 => "Pierce", + 3 => "Bludgeon", + 4 => "Fire", + 5 => "Cold", + 6 => "Lightning", + 7 => "Acid", + 8 => "Nether", + _ => "PAuto", + }; + } + + return "PAuto"; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/RadarWallRenderer.cs b/Plugins/RynthCore.Plugin.RynthAi/RadarWallRenderer.cs index 448f37f..48fb50f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RadarWallRenderer.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RadarWallRenderer.cs @@ -7,6 +7,7 @@ using ImGuiNET; using RynthCore.Plugin.RynthAi.LegacyUi; using RynthCore.Plugin.RynthAi.Raycasting; using RynthCore.PluginSdk; +using RynthCore.Install; namespace RynthCore.Plugin.RynthAi; @@ -17,7 +18,7 @@ namespace RynthCore.Plugin.RynthAi; /// dungeons stack would be unreadable otherwise. /// /// Explored state is per-EnvCell and persisted per-landblock under -/// C:\Games\RynthSuite\RynthAi\ExploredDungeons\XXYY0000.json. +/// \RynthAi\ExploredDungeons\XXYY0000.json. /// internal sealed class RadarWallRenderer { @@ -62,7 +63,7 @@ internal sealed class RadarWallRenderer public void Render() { try { RenderCore(); } - catch (Exception ex) { _host.Log($"RadarWalls: {ex.Message}"); } + catch (Exception ex) { RynthLog.Write(LogCat.Radar, $"RadarWalls: {ex.Message}"); } } private void RenderCore() @@ -288,7 +289,7 @@ internal sealed class RadarWallRenderer } catch (Exception ex) { - _host.Log($"RadarWalls: load {path} failed: {ex.Message}"); + RynthLog.Write(LogCat.Radar, $"RadarWalls: load {path} failed: {ex.Message}"); } } @@ -309,7 +310,7 @@ internal sealed class RadarWallRenderer } catch (Exception ex) { - _host.Log($"RadarWalls: save failed: {ex.Message}"); + RynthLog.Write(LogCat.Radar, $"RadarWalls: save failed: {ex.Message}"); } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Raycasting/DungeonLOS.cs b/Plugins/RynthCore.Plugin.RynthAi/Raycasting/DungeonLOS.cs index 2f541f4..b0c3a76 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Raycasting/DungeonLOS.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Raycasting/DungeonLOS.cs @@ -1072,6 +1072,7 @@ namespace RynthCore.Plugin.RynthAi.Raycasting private static void Log(string msg) { System.Diagnostics.Debug.WriteLine($"[DungeonLOS] {msg}"); + RynthLog.Trace(LogCat.Raycast, $"[DungeonLOS] {msg}"); // visible via /ra trace raycast } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Raycasting/GeometryLoader.cs b/Plugins/RynthCore.Plugin.RynthAi/Raycasting/GeometryLoader.cs index 6ee10c1..8ceb995 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Raycasting/GeometryLoader.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Raycasting/GeometryLoader.cs @@ -1788,6 +1788,7 @@ namespace RynthCore.Plugin.RynthAi.Raycasting { string line = $"[GeoLoader] {msg}"; System.Diagnostics.Debug.WriteLine(line); + RynthLog.Trace(LogCat.Raycast, line); // visible via /ra trace raycast if (DiagLog.Count < 200) DiagLog.Add(msg); } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Raycasting/LandblockStructs.cs b/Plugins/RynthCore.Plugin.RynthAi/Raycasting/LandblockStructs.cs index 693986f..b58f84e 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Raycasting/LandblockStructs.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Raycasting/LandblockStructs.cs @@ -164,6 +164,7 @@ namespace RynthCore.Plugin.RynthAi.Raycasting private static void Log(string msg) { System.Diagnostics.Debug.WriteLine($"[LandblockInfo] {msg}"); + RynthLog.Trace(LogCat.Raycast, $"[LandblockInfo] {msg}"); // visible via /ra trace raycast } } @@ -282,6 +283,7 @@ namespace RynthCore.Plugin.RynthAi.Raycasting private static void Log(string msg) { System.Diagnostics.Debug.WriteLine($"[EnvCell] {msg}"); + RynthLog.Trace(LogCat.Raycast, $"[EnvCell] {msg}"); // visible via /ra trace raycast } } @@ -585,6 +587,7 @@ namespace RynthCore.Plugin.RynthAi.Raycasting private static void Log(string msg) { System.Diagnostics.Debug.WriteLine($"[Setup] {msg}"); + RynthLog.Trace(LogCat.Raycast, $"[Setup] {msg}"); // visible via /ra trace raycast } } @@ -755,6 +758,7 @@ namespace RynthCore.Plugin.RynthAi.Raycasting private static void Log(string msg) { System.Diagnostics.Debug.WriteLine($"[GfxObj] {msg}"); + RynthLog.Trace(LogCat.Raycast, $"[GfxObj] {msg}"); // visible via /ra trace raycast } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Raycasting/ScatterSystem.cs b/Plugins/RynthCore.Plugin.RynthAi/Raycasting/ScatterSystem.cs index 0dbb17f..58fd761 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Raycasting/ScatterSystem.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Raycasting/ScatterSystem.cs @@ -1027,6 +1027,7 @@ namespace RynthCore.Plugin.RynthAi.Raycasting { string line = $"[Scatter] {msg}"; System.Diagnostics.Debug.WriteLine(line); + RynthLog.Trace(LogCat.Raycast, line); // visible via /ra trace raycast if (DiagLog.Count < 100) DiagLog.Add(msg); } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs index 9a66bc1..8d3ac65 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs @@ -21,6 +21,10 @@ public sealed partial class RynthAiPlugin Host.WriteToChat(text, 1); } + /// /ra items clean and the engine Items panel's Remove Missing button (RynthPluginCleanItems). + internal void CleanMissingItems() + => ChatLine(_dashboard?.CleanMissingItems(_objectCache, _playerId) ?? "[RynthAi] Settings not ready."); + private void HandleHelpCommand() { ChatLine("[RynthAi] === Commands ==="); @@ -94,6 +98,8 @@ public sealed partial class RynthAiPlugin ChatLine("[RynthAi] /ra panic — full AC state reset (cancel attack + peace mode + stop motion + clear busy)"); ChatLine("[RynthAi] /ra forcebuff — force-recast all buffs immediately"); ChatLine("[RynthAi] /ra cancelforcebuff — cancel an in-progress force rebuff"); + ChatLine("[RynthAi] /ra vtkeys — VTank-style commands (targetlock, recharge, lootthis, meleelow/mid/high, navprio...)"); + ChatLine("[RynthAi] /ra buff force|cancel|skipped - force buff, cancel it, or list buffs left out as unusable"); ChatLine("[RynthAi] /ra bufftest — one-shot: snapshot enchant registries pre/post next item-spell cast (logs to RynthCore.log)"); ChatLine("[RynthAi] /ra settings savechar — save current settings to named profile (create if new)"); ChatLine("[RynthAi] /ra settings loadchar — load named settings profile (create from current if new)"); @@ -1519,7 +1525,7 @@ public sealed partial class RynthAiPlugin $"but the file holds {profile.Rules.Count}; all {profile.Rules.Count} are in use. " + "Re-save the profile in the loot editor to correct the header."; ChatLine(countMessage); - Host.Log(countMessage); + RynthLog.Write(LogCat.Looting, countMessage); } var bad = new List(); @@ -1538,7 +1544,7 @@ public sealed partial class RynthAiPlugin string message = $"[RynthAi] Loot profile '{fileName}': {bad.Count} rule(s) use condition types " + $"RynthAi does not support and will never match: {string.Join(", ", bad)}."; ChatLine(message); - Host.Log(message); + RynthLog.Write(LogCat.Looting, message); } // ── Loot Editor (engine ImGui panel) ──────────────────────────────────── @@ -1873,6 +1879,75 @@ public sealed partial class RynthAiPlugin ChatLine($"[RynthAi] likely: {why}"); } + /// + /// /ra ghosts list the ghosts combat found (objects the client draws but the server + /// doesn't have for this character: no swing at them ever starts) + /// /ra ghosts clear remove them from the client (engine API v83), like a server delete + /// /ra ghosts forget make them targetable again + /// /ra ghost mark the selected monster as a ghost and remove it from the client + /// + private void HandleGhostsCommand(string cmd, string[] parts) + { + if (_combatManager == null) { ChatLine("[RynthAi] Combat manager not ready."); return; } + var ghosts = _combatManager.Ghosts; + string sub = parts.Length >= 3 ? parts[2].ToLowerInvariant() : ""; + bool canRemove = Host.HasRemoveClientObject; + + if (cmd.Equals("ghost", StringComparison.OrdinalIgnoreCase) && sub.Length == 0) + { + uint sel = Host.HasGetSelectedItemId ? Host.GetSelectedItemId() : 0; + var wo = sel != 0 ? _objectCache?[(int)sel] : null; + if (wo == null || (int)wo.ObjectClass != (int)AcObjectClass.Monster) + { + ChatLine("[RynthAi] /ra ghost: select the monster that never takes a swing first."); + return; + } + double silent = _combatManager.ServerSilentMs((int)sel, DateTime.Now); + _combatManager.MarkGhost((int)sel, wo.Name, silent, "marked by /ra ghost"); + ChatLine($"[RynthAi] 0x{sel:X8} '{wo.Name}' marked as a ghost" + (canRemove ? " and sent for removal from the client (see the log)." : " (this engine can't remove it from the client; it is skipped).")); + return; + } + + switch (sub) + { + case "clear": + { + if (!canRemove) { ChatLine("[RynthAi] This engine can't remove objects from the client (needs plugin API v83)."); return; } + int sent = 0, refused = 0; + foreach (var g in ghosts.All.ToList()) + { + int r = Host.RemoveClientObject((uint)g.Id); + if (r == 1 || r == 2) sent++; else refused++; + } + ChatLine($"[RynthAi] Ghosts: {sent} removed from the client" + (refused > 0 ? $", {refused} refused (the server talked about them recently, or not a creature - they stay skipped)." : ".")); + return; + } + case "forget": + { + int n = ghosts.Count; + ghosts.Clear(); + ChatLine($"[RynthAi] Ghosts: {n} forgotten; they can be targeted again."); + return; + } + } + + if (ghosts.Count == 0) + { + ChatLine($"[RynthAi] No ghosts found this session ({ghosts.MarkedTotal} marked in all). /ra ghost marks the selected monster."); + return; + } + ChatLine($"[RynthAi] {ghosts.Count} ghost(s) skipped by combat (the client draws them, the server doesn't have them):"); + DateTime now = DateTime.Now; + foreach (var g in ghosts.All) + { + double silent = _combatManager.ServerSilentMs(g.Id, now); + string s = silent < 0 ? "no server update seen" : $"server silent {silent / 1000:0}s"; + ChatLine($" 0x{(uint)g.Id:X8} '{g.Name}' - marked {(now - g.MarkedAt).TotalSeconds:0}s ago, {s}"); + } + ChatLine(canRemove ? "[RynthAi] /ra ghosts clear removes them from the client; /ra ghosts forget makes them targetable again." + : "[RynthAi] /ra ghosts forget makes them targetable again (removing them needs engine API v83)."); + } + private void HandleCombatStateCommand() { if (_combatManager == null) { ChatLine("[RynthAi] Combat manager not ready."); return; } @@ -1905,6 +1980,7 @@ public sealed partial class RynthAiPlugin ChatLine($"[RynthAi] scanned={s.ScannedCount} closest=0x{(uint)s.ClosestScannedId:X8} '{s.ClosestScannedName}' @ {s.ClosestScannedDist:F1}yd"); ChatLine($"[RynthAi] weapon=0x{(uint)s.PickedWeaponId:X8} '{s.PickedWeaponName}' ({s.PickedWeaponWhy}) wieldLoc={s.PickedWeaponWieldLoc} ammoWielded={s.HasWieldedAmmoFlag}"); ChatLine($"[RynthAi] busy={s.BusyCount} sinceAtk={sinceAttackS:F1}s sinceStance={sinceStanceS:F1}s sinceEquip={sinceEquipS:F1}s sinceLost={sinceLostS:F1}s"); + ChatLine($"[RynthAi] script {s.ScriptHook}"); // Dump every cache-known object that's wielded — using Host.TryGetObjectWielderInfo // as the authoritative check, not the cached WieldedLocation/Wielder fields @@ -2050,6 +2126,7 @@ public sealed partial class RynthAiPlugin ChatLine("[RynthAi] === Salvage State ==="); ChatLine($"[RynthAi] panelApi={v.HasPanelApi} combineEnabled={v.EnableCombine}"); + ChatLine($"[RynthAi] withoutPanel={(v.DirectOn ? "on" : "off")}{(v.DirectOffReason.Length > 0 ? $" ({v.DirectOffReason})" : "")} directApi={v.HasDirectApi} requests={v.DirectRequests} panelFallbacks={v.DirectFallbacks}"); ChatLine($"[RynthAi] phase={v.Phase} readyIn={v.PhaseReadyInMs}ms queue={v.QueueCount} panelEverOpened={v.PanelEverOpened}"); ChatLine($"[RynthAi] batch={v.BatchSize} first=0x{v.CurrentItemId:X8} ust=0x{v.CurrentUstId:X8} tracked={v.TrackedItems}"); ChatLine($"[RynthAi] items: {v.ItemsSalvaged} salvaged in {v.Batches} batch(es), {v.ItemsSkipped} skipped (reasons in the log)"); @@ -2061,7 +2138,7 @@ public sealed partial class RynthAiPlugin ? $"[RynthAi] lastError: '{v.LastError}' ({v.MsSinceLastError / 1000}s ago)" : "[RynthAi] lastError: none"); - Host.Log($"[RynthAi salvstate] panelApi={v.HasPanelApi} combine={v.EnableCombine} phase={v.Phase}/{v.PhaseReadyInMs}ms " + Host.Log($"[RynthAi salvstate] panelApi={v.HasPanelApi} directApi={v.HasDirectApi} direct={v.DirectOn}/'{v.DirectOffReason}' req={v.DirectRequests} fb={v.DirectFallbacks} combine={v.EnableCombine} phase={v.Phase}/{v.PhaseReadyInMs}ms " + $"queue={v.QueueCount} batch={v.BatchSize} item=0x{v.CurrentItemId:X8} ust=0x{v.CurrentUstId:X8} tracked={v.TrackedItems} salvaged={v.ItemsSalvaged} skipped={v.ItemsSkipped} " + $"cphase={v.CombinePhase} grp={v.CombineGroupIdx}/{v.CombineGroupCount} add={v.CombineAddIdx} " + $"openAttempts={v.CombineOpenAttempts} pendingScan={v.PendingCombineScan} sinceSweep={v.MsSinceCombineSweep}ms " @@ -2251,6 +2328,32 @@ public sealed partial class RynthAiPlugin _buffManager.RequestForceFullRebuff(); // chat commands run on AC's thread; applied on the pump } + // /ra buff force | cancel | skipped: the same actions as /ra forcebuff, /ra cancelforcebuff + // and the Force Buff button, plus the buffs the "Skip buffs this character can't use" + // setting is leaving out right now. + private void HandleBuffCommand(string[] parts) + { + string sub = parts.Length >= 3 ? parts[2].ToLowerInvariant() : ""; + switch (sub) + { + case "force": HandleForceBuff(); break; + case "cancel": HandleCancelForceBuff(); break; + case "skipped": + if (_buffManager == null) { ChatLine("[RynthAi] Buff manager not ready."); break; } + _buffManager.BuildDynamicBuffList(); // refresh the skip list + string summary = _buffManager.FilterSkipSummary(); + ChatLine(summary.Length == 0 + ? "[RynthAi] Buff filter: nothing is being skipped." + : $"[RynthAi] Buff filter skips: {summary}"); + break; + default: + ChatLine("[RynthAi] /ra buff force - recast every buff now, whatever time is left"); + ChatLine("[RynthAi] /ra buff cancel - cancel an in-progress force buff"); + ChatLine("[RynthAi] /ra buff skipped - buffs left out because this character can't use them"); + break; + } + } + private void HandleCancelForceBuff() { if (_buffManager == null) { ChatLine("[RynthAi] Buff manager not ready."); return; } @@ -2802,12 +2905,23 @@ public sealed partial class RynthAiPlugin /// public void HandleDungeonNavPatrol() => BuildDunPatrol(isRebuild: false); + /// The Dungeon Patrol settings (Settings > Navigation) as patrol options, in range. + internal static DungeonPatrolOptions PatrolOptionsFrom(LegacyUiSettings s) => new DungeonPatrolOptions + { + Coverage = (PatrolCoverage)Math.Clamp(s.DunPatrolCoverage, 0, 2), + MaxDeadEndCells = s.DunPatrolSkipDeadEnds, + AvoidHazardFloors = s.DunPatrolAvoidFloors, + WallClearance = s.DunPatrolWallDistance, + LookInRoomMeters = s.DunPatrolLookInSize, + }.Clamped(); + /// /// Builds (or rebuilds) the circular dungeon patrol route from the player's current /// cell, excluding all currently-known hazard cells, and installs it as the active /// route. When is true this was triggered by OnTick - /// after a new hazard was sighted mid-patrol — it reroutes silently (no fresh - /// "patrol started" chatter, just a one-line note) and never flips IsMacroRunning. + /// after a new hazard was sighted mid-patrol, or a Dungeon Patrol setting changed + /// () — it reroutes silently (no fresh "patrol + /// started" chatter, just a one-line note) and never flips IsMacroRunning. /// // One log line per patrol waypoint and a summary (diagnostics: which rule put each point // where it is, e.g. the patrol walking into small rooms it should only look into). @@ -2828,10 +2942,11 @@ public sealed partial class RynthAiPlugin } } - private void BuildDunPatrol(bool isRebuild) + private void BuildDunPatrol(bool isRebuild, bool settingsChanged = false) { var settings = _dashboard?.Settings; if (settings == null) { if (!isRebuild) ChatLine("[RynthAi] Settings not ready."); return; } + var patrolOptions = PatrolOptionsFrom(settings); if (!Host.TryGetPlayerPose(out uint playerCell, out float playerLocalX, out float playerLocalY, out float patrolWZ, out _, out _, out _, out _)) @@ -2886,13 +3001,18 @@ public sealed partial class RynthAiPlugin // invisible-HotSpot majority the live weenie scan can't see — pure dat reads, cached per // landblock. No-op unless the user has flagged hazard textures (/ra hazard learnhere|texture). var portalDat = _raycast?.GeometryLoader?.PortalDat; + HashSet? surfaceHazards = null; if (portalDat != null) { - var surfaceHazards = DungeonHazardSurfaces.ComputeHazardCells(landblockKey, cellDat, portalDat); + surfaceHazards = DungeonHazardSurfaces.ComputeHazardCells(landblockKey, cellDat, portalDat); if (surfaceHazards.Count > 0) _objectCache?.SeedSurfaceHazards(surfaceHazards); } - var hazards = _objectCache?.GetHazardCells(); + // Settings "Avoid Lava/Acid Floors" off: the floor-texture cells stay walkable for the + // patrol (the live set keeps them for everything else). Pools sighted or marked by hand + // (DungeonHazardStore) are avoided either way. + var hazards = DungeonPathfinder.PatrolHazards(_objectCache?.GetHazardCells(), surfaceHazards, + patrolOptions.AvoidHazardFloors ? null : DungeonHazardStore.Load(landblockKey), patrolOptions); // Start-in-hazard evacuation: if the player is standing on an excluded (acid/lava) cell, build // the patrol from the nearest SAFE cell and prepend a lead-in waypoint so the first move walks @@ -2917,7 +3037,7 @@ public sealed partial class RynthAiPlugin var pointLog = new Dictionary(ReferenceEqualityComparer.Instance); DungeonPathfinder.PointLog = pointLog; NavRouteParser route; - try { route = DungeonPathfinder.BuildPatrolRoute(graph, startCell, hazards, geometry); } + try { route = DungeonPathfinder.BuildPatrolRoute(graph, startCell, hazards, geometry, patrolOptions); } finally { DungeonPathfinder.PointLog = null; } // Lead the bot out of the hazard first. @@ -2972,10 +3092,15 @@ public sealed partial class RynthAiPlugin _dunPatrolActive = true; _dunPatrolLandblock = landblockKey; _dunPatrolHazardVersion = _objectCache?.HazardVersion ?? 0; + _dunPatrolSettings.MarkBuilt(patrolOptions); int hazardCount = hazards?.Count ?? 0; string hazardNote = hazardCount > 0 ? $", {hazardCount} hazard cell(s) avoided" : ""; - if (isRebuild) + if (isRebuild && settingsChanged) + { + ChatLine($"[RynthAi] DunNav-Patrol: patrol settings changed → rebuilt from here, {route.Points.Count} waypoints ({patrolOptions.Describe()})."); + } + else if (isRebuild) { ChatLine($"[RynthAi] DunNav-Patrol: new hazard sighted → rerouted around it ({hazardCount} hazard cell(s) avoided)."); } @@ -2994,7 +3119,9 @@ public sealed partial class RynthAiPlugin /// /// Called once per OnTick while logged in. If a dunnav-patrol is running and a new /// hazard (lava/acid hotspot) has been sighted since the route was built, rebuilds the - /// route so the hotspot is treated as a wall the bot turns around at. No-op otherwise. + /// route so the hotspot is treated as a wall the bot turns around at. Likewise when a + /// Dungeon Patrol setting changed (once it has settled, PatrolSettingsWatch): the patrol + /// is rebuilt from where the character is, the macro keeps running. No-op otherwise. /// private void TickDunPatrolHazardReroute() { @@ -3012,7 +3139,10 @@ public sealed partial class RynthAiPlugin return; } - if (_objectCache.HazardVersion == _dunPatrolHazardVersion) return; // nothing new sighted + var patrolOptions = PatrolOptionsFrom(settings); + bool settingsChanged = _dunPatrolSettings.ShouldRebuild(patrolOptions, Environment.TickCount64); + bool hazardsChanged = _objectCache.HazardVersion != _dunPatrolHazardVersion; + if (!hazardsChanged && !settingsChanged) return; // nothing new sighted, settings as built // Only reroute if still in the dungeon this patrol was built for. A portal to a new // landblock means BuildDunPatrol would (correctly) re-home, but that should happen via @@ -3021,10 +3151,13 @@ public sealed partial class RynthAiPlugin || (playerCell >> 16) != _dunPatrolLandblock) { _dunPatrolHazardVersion = _objectCache.HazardVersion; + _dunPatrolSettings.MarkBuilt(patrolOptions); return; } - BuildDunPatrol(isRebuild: true); + BuildDunPatrol(isRebuild: true, settingsChanged: settingsChanged); + // A rebuild that gave up (graph not loaded, ...) keeps the old route: don't retry every tick. + if (settingsChanged) _dunPatrolSettings.MarkBuilt(patrolOptions); } // ── Patrol-management info / actions (engine-side right-click flyout) ────── @@ -3080,8 +3213,8 @@ public sealed partial class RynthAiPlugin return sb.ToString(); } - // Minimal JSON string escaper for route names (which can contain user-chosen chars). - private static string JsonEscape(string s) + // Minimal JSON string escaper for hand-built export JSON (route names, ILT Hub text). + internal static string JsonEscape(string s) { var sb = new System.Text.StringBuilder(s.Length + 8); foreach (char c in s) diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiItemInfo.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiItemInfo.cs new file mode 100644 index 0000000..21ba353 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiItemInfo.cs @@ -0,0 +1,455 @@ +using System; +using System.Collections.Generic; +using System.Numerics; +using System.Text; +using System.Threading; +using ImGuiNET; +using RynthCore.Loot; +using RynthCore.Plugin.RynthAi.ItemInfo; + +namespace RynthCore.Plugin.RynthAi; + +/// +/// /ra iteminfo — Mag-style item info (ratings, damage, spells, slayer, imbues …) as one line or +/// as pet-roster style lines, printed on demand, on select or on a left/right mouse click; +/// ported from UtilityBelt ub-IT / Mag-Tools ItemInfo. Partial class of RynthAiPlugin. +/// +/// /ra iteminfo describe the selected item (IDs it first when needed) +/// /ra iteminfo <item name> describe an inventory item by name (exact, else partial) +/// /ra iteminfo on|off describe every item you select +/// /ra iteminfo settings open/close the Item Info settings window +/// /ra iteminfo fields list fields and ratings with their on/off state +/// /ra iteminfo field <name> on|off show/hide one field (ratings, slayer, spells, …) +/// /ra iteminfo rating <tag> on|off show/hide one rating (D, CD, CDR, …) +/// /ra iteminfo value on|off append value + burden +/// /ra iteminfo verbose on|off list every spell instead of Mag's filter +/// /ra iteminfo click left|right|off print the selected item after a mouse click +/// /ra iteminfo layout pet|line pet-roster style lines or the Mag one-liner +/// /ra iteminfo reset restore defaults +/// Every option is also editable in the "RynthAi Item Info" window (LegacyItemInfoUi). +/// +public sealed partial class RynthAiPlugin +{ + // One pending describe at a time: the newest request replaces the previous one. + private int _itemInfoPendingId; + private long _itemInfoPendingSince; + + // Automatic triggers (select + click) can both fire for one click; the same item inside + // this window prints once. + private const long AutoDedupeMs = 1500; + private int _itemInfoLastAutoId; + private long _itemInfoLastAutoAt; + + // Click trigger. A press counts as a click only if it started outside every overlay window, + // was released within ClickMaxHoldMs and moved at most ClickMaxMovePx — so item drags and + // right-button mouse-look never print. The client updates the selection after it handles + // the click, so the selection is read ClickSettleMs after the release, on the tick thread. + private const long ClickMaxHoldMs = 600; + private const float ClickMaxMovePx = 6f; + private const long ClickSettleMs = 150; + private bool _iiClickPrevDown; + private bool _iiClickArmed; + private long _iiClickPressAt; + private Vector2 _iiClickPressPos; + private long _iiClickResolveAt; // TickCount64 to read the selection at; 0 = none (Interlocked) + + /// Character settings when loaded, else null (commands then use defaults / refuse edits). + private MagItemInfoSettings? ItemInfoSettings => _dashboard?.Settings.ItemInfoSettings; + + private void HandleItemInfoCommand(string[] parts) + { + var s = ItemInfoSettings; + string sub = parts.Length >= 3 ? parts[2].ToLowerInvariant() : string.Empty; + string arg3 = parts.Length >= 4 ? parts[3] : string.Empty; + string arg4 = parts.Length >= 5 ? parts[4] : string.Empty; + + if (sub.Length == 0) + { + PrintSelectedItemInfo(); + return; + } + if (s == null) { ChatLine("[RynthAi] Settings not ready (log in first)."); return; } + + switch (sub) + { + case "settings": + case "gui": + case "window": + s.ShowWindow = !s.ShowWindow; + ChatLine($"[RynthAi] Item info window {(s.ShowWindow ? "opened" : "closed")}."); + return; + + case "value": + if (ParseOnOff(arg3) is bool v) s.ShowValueAndBurden = v; + ChatLine($"[RynthAi] Item info value/burden: {OnOff(s.ShowValueAndBurden)}"); + return; + + case "verbose": + if (ParseOnOff(arg3) is bool all) + s.SpellMode = all ? MagItemInfoSettings.SpellModeAll : MagItemInfoSettings.SpellModeMag; + ChatLine($"[RynthAi] Item info all spells: {OnOff(s.SpellMode == MagItemInfoSettings.SpellModeAll)}"); + return; + + case "field": + if (!MagItemInfoCatalog.TryFindField(arg3, out MagItemInfoField field)) + { + ChatLine($"[RynthAi] Unknown field '{arg3}'. /ra iteminfo fields lists them."); + return; + } + if (ParseOnOff(arg4) is bool fieldOn) s.SetHidden(field, !fieldOn); + ChatLine($"[RynthAi] Item info field {field}: {OnOff(!s.IsHidden(field))}"); + return; + + case "rating": + int r = MagItemInfoCatalog.FindRating(arg3); + if (r < 0) + { + ChatLine($"[RynthAi] Unknown rating '{arg3}'. /ra iteminfo fields lists them."); + return; + } + if (ParseOnOff(arg4) is bool ratingOn) s.SetRatingHidden(r, !ratingOn); + var rating = MagItemInfoCatalog.Ratings[r]; + ChatLine($"[RynthAi] Item info rating {rating.Tag} ({rating.Name}): {OnOff(!s.IsRatingHidden(r))}"); + return; + + case "fields": + ListItemInfoFields(s); + return; + + case "click": + switch (arg3.ToLowerInvariant()) + { + case "left": case "l": s.ClickTrigger = MagItemInfoSettings.ClickLeft; break; + case "right": case "r": s.ClickTrigger = MagItemInfoSettings.ClickRight; break; + case "off": case "none": s.ClickTrigger = MagItemInfoSettings.ClickOff; break; + case "": break; + default: + ChatLine("[RynthAi] Usage: /ra iteminfo click left|right|off"); + return; + } + ChatLine($"[RynthAi] Item info on click: {MagItemInfoCatalog.ClickTriggers[s.ClickTrigger]}"); + return; + + case "layout": + switch (arg3.ToLowerInvariant()) + { + case "pet": case "pets": case "lines": s.Layout = MagItemInfoSettings.LayoutPetLines; break; + case "line": case "mag": case "one": s.Layout = MagItemInfoSettings.LayoutOneLine; break; + case "": break; + default: + ChatLine("[RynthAi] Usage: /ra iteminfo layout pet|line"); + return; + } + ChatLine($"[RynthAi] Item info layout: {MagItemInfoCatalog.Layouts[s.Layout]}"); + return; + + case "reset": + s.ResetToDefaults(); + ChatLine("[RynthAi] Item info settings reset to defaults."); + return; + } + + if (ParseOnOff(sub) is bool onSelect) + { + s.OnSelect = onSelect; + ChatLine($"[RynthAi] Item info on select: {OnOff(onSelect)}"); + return; + } + if (sub is not ("help" or "?")) + { + // Anything else is an item name: the inventory item called that, else one containing it. + string name = string.Join(" ", parts, 2, parts.Length - 2).Trim(); + uint found = FindInventoryItemByName(name); + if (found != 0) { QueueItemInfo(unchecked((int)found), requestId: true); return; } + ChatLine($"[RynthAi] Item info: no \"{name}\" in your inventory."); + } + ChatLine("[RynthAi] Usage: /ra iteminfo [|on|off|settings|fields|field on|off|rating on|off|value on|off|verbose on|off|click left|right|off|layout pet|line|reset]"); + } + + /// + /// An inventory item (carried or worn) whose name is , ignoring case; + /// else the first whose name contains it. 0 when none. + /// + private uint FindInventoryItemByName(string name) + { + if (_objectCache == null || name.Length == 0) return 0; + uint partial = 0; + foreach (WorldObject wo in _objectCache.GetInventory()) + { + if (wo.Name.Length == 0) continue; + if (wo.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) return unchecked((uint)wo.Id); + if (partial == 0 && wo.Name.Contains(name, StringComparison.OrdinalIgnoreCase)) partial = unchecked((uint)wo.Id); + } + return partial; + } + + /// + /// " | Loot: [Keep] (A) MajorSkill Set": the looter's own verdict on the item, as a preview + /// (nothing recorded), so it says exactly what [LootEval] would. Item info replaces the + /// separate verdict line, so this is the only place it shows. "" when there's no loot + /// profile, or /ra lootcheck off. + /// + private string LootVerdictSuffix(int itemId) + { + try + { + LegacyUi.LegacyUiSettings? settings = _dashboard?.Settings; + WorldObject? wo = _objectCache?[itemId]; + if (!_lootInspectMode || settings == null || wo == null || string.IsNullOrEmpty(settings.CurrentLootPath)) return ""; + if (!ClassifyLootItem(wo, settings, preview: true, out string action, out _, out string rule, out string builtIn)) + // A rule can match and still not take it (its Keep # reached, a Read rule on a non-scroll). + return rule.Length > 0 ? $" | Loot: leave ({rule} matched, not taken)" : " | Loot: no rule matched"; + if (builtIn.Length > 0) return $" | Loot: [{action}] built-in - {builtIn}"; + return $" | Loot: [{action}] {(rule.Length > 0 ? rule : "(unnamed rule)")}"; + } + catch (Exception ex) + { + ItemInfoLog($"0x{(uint)itemId:X8}: loot verdict failed: {ex.GetType().Name}: {ex.Message}"); + return ""; + } + } + + private static string OnOff(bool on) => on ? "ON" : "OFF"; + + /// "/ra iteminfo fields" — current state of every field and rating. + private void ListItemInfoFields(MagItemInfoSettings s) + { + var sb = new StringBuilder("[RynthAi] Fields: "); + bool first = true; + foreach (var f in MagItemInfoCatalog.Fields) + { + if (!first) sb.Append(", "); + sb.Append(f.Field).Append(s.IsHidden(f.Field) ? " off" : " on"); + first = false; + } + ChatLine(sb.ToString()); + + sb.Clear().Append("[RynthAi] Ratings: "); + var ratings = MagItemInfoCatalog.Ratings; + for (int i = 0; i < ratings.Length; i++) + { + if (i > 0) sb.Append(", "); + sb.Append(ratings[i].Tag).Append(s.IsRatingHidden(i) ? " off" : " on"); + } + ChatLine(sb.ToString()); + } + + /// /ra iteminfo and the window's "Print to chat" button. + private void PrintSelectedItemInfo() + { + if (!Host.HasGetSelectedItemId) { ChatLine("[RynthAi] Host does not expose the selected item."); return; } + uint selected = Host.GetSelectedItemId(); + if (selected == 0) { ChatLine("[RynthAi] No item selected. Click an item first."); return; } + QueueItemInfo(unchecked((int)selected), requestId: true); + } + + /// On-select class filters from the Item Info window. + private static bool ItemInfoWantsClass(MagItemInfoSettings s, AcObjectClass cls) => cls switch + { + AcObjectClass.MeleeWeapon or AcObjectClass.MissileWeapon or AcObjectClass.WandStaffOrb => s.OnSelectWeapons, + AcObjectClass.Armor or AcObjectClass.Clothing => s.OnSelectArmor, + AcObjectClass.Jewelry => s.OnSelectJewelry, + _ => s.OnSelectOther, + }; + + /// + /// Describe now if its appraisal is cached, otherwise (optionally) + /// request an ID and print from once it lands or times out. + /// + internal void QueueItemInfo(int itemId, bool requestId) + { + if (itemId == 0) return; + uint uid = unchecked((uint)itemId); + if (!Host.HasHasAppraisalData || Host.HasAppraisalData(uid)) + { + _itemInfoPendingId = 0; + PrintItemInfo(itemId, identified: true); + return; + } + if (requestId && Host.HasRequestId) Host.RequestId(uid); + ItemInfoLog($"0x{uid:X8}: waiting for ID data (requested={requestId && Host.HasRequestId})"); + _itemInfoPendingId = itemId; + _itemInfoPendingSince = Environment.TickCount64; + } + + /// One "[ItemInfo]" line in the engine log and the daily RynthAi file per trigger decision. + private static void ItemInfoLog(string message) => RynthLog.Write(LogCat.UI, "[ItemInfo] " + message); + + /// + /// Select / click triggers: unless the same item was queued + /// automatically within (one click can raise both triggers). + /// + internal void QueueAutoItemInfo(int itemId, bool requestId) + { + long now = Environment.TickCount64; + if (itemId == _itemInfoLastAutoId && now - _itemInfoLastAutoAt < AutoDedupeMs) + { + ItemInfoLog($"0x{(uint)itemId:X8}: already queued by the other trigger"); + return; + } + _itemInfoLastAutoId = itemId; + _itemInfoLastAutoAt = now; + QueueItemInfo(itemId, requestId); + } + + /// + /// Render-thread click watcher (OnRender / OnRenderOverlay, ImGui context current). The ImGui + /// backend sees every mouse message on the game window, including the ones the game handles, + /// so the raw button state is edge-detected here; the selection is resolved in + /// . + /// + private void DetectItemInfoClick() + { + int trigger = ItemInfoSettings?.ClickTrigger ?? MagItemInfoSettings.ClickOff; + int button = trigger switch + { + MagItemInfoSettings.ClickLeft => 0, + MagItemInfoSettings.ClickRight => 1, + _ => -1, + }; + if (button < 0) + { + _iiClickPrevDown = false; + _iiClickArmed = false; + return; + } + + ImGuiIOPtr io = ImGui.GetIO(); + bool down = io.MouseDown[button]; + long now = Environment.TickCount64; + + if (down && !_iiClickPrevDown) + { + // A press on an overlay window belongs to the overlay, not to an item in the game. + _iiClickArmed = !io.WantCaptureMouse; + _iiClickPressAt = now; + _iiClickPressPos = io.MousePos; + } + else if (down && _iiClickArmed) + { + bool held = now - _iiClickPressAt > ClickMaxHoldMs; + bool moved = Vector2.DistanceSquared(io.MousePos, _iiClickPressPos) > ClickMaxMovePx * ClickMaxMovePx; + if (held || moved) _iiClickArmed = false; // drag or mouse-look, not a click + } + else if (!down && _iiClickPrevDown && _iiClickArmed) + { + _iiClickArmed = false; + Interlocked.Exchange(ref _iiClickResolveAt, now + ClickSettleMs); + } + _iiClickPrevDown = down; + } + + /// Tick-thread half of the click trigger: describe whatever item the click selected. + private void ResolveItemInfoClick() + { + long at = Interlocked.Read(ref _iiClickResolveAt); + if (at == 0 || Environment.TickCount64 < at) return; + if (Interlocked.CompareExchange(ref _iiClickResolveAt, 0, at) != at) return; + + var s = ItemInfoSettings; + if (s == null || s.ClickTrigger == MagItemInfoSettings.ClickOff || !Host.HasGetSelectedItemId) return; + string button = MagItemInfoCatalog.ClickTriggers[s.ClickTrigger]; + uint selected = Host.GetSelectedItemId(); + if (selected == 0) { ItemInfoLog($"{button}: nothing selected"); return; } + + int id = unchecked((int)selected); + WorldObject? obj = _objectCache?[id]; + if (obj == null) { ItemInfoLog($"{button}: 0x{selected:X8} not in the object cache"); return; } + if (!IsLootableClass(obj.ObjectClass) || !ItemInfoWantsClass(s, obj.ObjectClass)) + { + ItemInfoLog($"{button}: '{obj.Name}' ({obj.ObjectClass}) skipped by the class filters"); + return; + } + ItemInfoLog($"{button}: 0x{selected:X8} '{obj.Name}': click queue"); + QueueAutoItemInfo(id, requestId: true); + } + + /// Plugin-tick poll for a pending describe (no appraisal-arrived event in the SDK). + private void TickItemInfo() + { + ResolveItemInfoClick(); + + int id = _itemInfoPendingId; + if (id == 0) return; + bool ready = Host.HasAppraisalData(unchecked((uint)id)); + long timeoutMs = (long)((ItemInfoSettings?.IdTimeoutSec ?? 3f) * 1000f); + bool timedOut = Environment.TickCount64 - _itemInfoPendingSince > timeoutMs; + if (!ready && !timedOut) return; + _itemInfoPendingId = 0; + PrintItemInfo(id, identified: ready); + } + + /// + /// Builds the output lines (no prefix / indent) in the configured layout, or returns null + /// with set. The one-line layout returns a single line. + /// + private List? BuildItemInfoLines(int itemId, out string? error) + { + error = null; + WorldObject? wo = _objectCache?[itemId]; + if (wo == null) { error = $"Item 0x{(uint)itemId:X8} is not in the object cache."; return null; } + try + { + var s = ItemInfoSettings; + MagItemDescription d = MagItemDescriber.Build(new CacheItemPropertySource(Host, wo), MagItemInfoOptions.From(s)); + return (s?.Layout ?? MagItemInfoSettings.LayoutPetLines) == MagItemInfoSettings.LayoutOneLine + ? new List { d.ToOneLine() } + : d.ToPetLines(); + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.General, ex, $"item info 0x{(uint)itemId:X8}"); + error = $"Item info failed for {wo.Name}: {ex.Message}"; + return null; + } + } + + /// + /// Chat output. Pet-style: line 1 carries the prefix in , + /// later lines are indented like the pet roster and use . + /// + private void PrintItemInfo(int itemId, bool identified) + { + List? lines = BuildItemInfoLines(itemId, out string? error); + if (lines == null || lines.Count == 0) + { + ItemInfoLog($"0x{(uint)itemId:X8}: not printed: {error}"); + ChatLine("[RynthAi] " + error); + return; + } + if (!identified) lines[0] += " (not identified — stats may be incomplete)"; + lines[0] += LootVerdictSuffix(itemId); + ItemInfoLog($"0x{(uint)itemId:X8}: printed {lines.Count} line(s), identified={identified}: {lines[0]}"); + + var s = ItemInfoSettings; + string prefix = s?.Prefix ?? "[RynthAi Item] "; + int headerType = s?.ChatType ?? 1; + int detailType = s == null || s.DetailChatType == MagItemInfoSettings.SameAsHeader ? headerType : s.DetailChatType; + + Host.WriteToChat(prefix + lines[0], headerType); + for (int i = 1; i < lines.Count; i++) + Host.WriteToChat(prefix + " " + lines[i], detailType); + } + + /// Item Info window preview: the selected item's lines, or null when nothing is selected. + private string? DescribeSelectedItemForPreview() + { + if (!Host.HasGetSelectedItemId) return null; + uint selected = Host.GetSelectedItemId(); + if (selected == 0) return null; + int id = unchecked((int)selected); + List? lines = BuildItemInfoLines(id, out string? error); + if (lines == null || lines.Count == 0) return error; + if (Host.HasHasAppraisalData && !Host.HasAppraisalData(selected)) + lines[0] += " (not identified yet — Print to chat IDs it)"; + // The window adds the prefix to the first line; indent the rest like chat. + return string.Join("\n ", lines); + } + + /// Item Info window "Test" button: sample line in the chosen chat type. + private void TestItemInfoChatType(int chatType) + { + string prefix = ItemInfoSettings?.Prefix ?? "[RynthAi Item] "; + Host.WriteToChat($"{prefix}Item info chat test (type {chatType})", chatType); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ChestLoot.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ChestLoot.cs new file mode 100644 index 0000000..2cd379e --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ChestLoot.cs @@ -0,0 +1,275 @@ +using System; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi; + +// Chest looting (2026-10-12). With Looting on, a chest that is open - the player clicked it, or a +// meta/nav "use" opened it - is looted by the corpse looter: the chest becomes the open loot +// container (_openedContainerId), and TickOpenCorpseLooting does the item work exactly as for a +// corpse (rule matching, ID requests, Keep #, pack space, mana stones, salvage without a UST, +// retries, timeout). Only the approach and the open are skipped (the chest is already open and in +// reach), and nothing marks a chest done for good: chests regenerate, so the next open loots again. +// +// Eligible: an open container lying in the world (no container, no wielder) that is not a corpse +// (the corpse path), a vendor, a player, house storage, or anything you or someone else carries. +// House storage: on ACE every house-linked object (Storage chests, hooks) gets HouseOwner from its +// house (House.SetLinkProperties) and the server sends it in the object's PublicWeenieDesc only +// while the house is owned - and a storage chest only opens for someone the owner allows, so an +// open one always has it. The engine reads it (STypeIID 32, API v73). Without that call, and as a +// second check, a container named like storage or a hook is skipped too. +public sealed partial class RynthAiPlugin +{ + private const uint ChestIidHouseOwner = 32; + private const uint ChestBfPlayer = 0x00000008, ChestBfVendor = 0x00000200, ChestBfCorpse = 0x00002000; + + /// A non-corpse container the client opened, not looted yet (0 = none). + private int _chestCandidateId; + private long _chestCandidateSince; + private long _chestCandidateInvSeenAt; + private int _chestSkipLoggedFor; + private int _chestHeldLoggedFor; + + /// The chest being looted as the open loot container (0 = the open container, if any, is a corpse). + private int _lootChestId; + + /// The log prefix of the loot pipeline: "Chest loot" while a chest is the loot container. + private string LootTag => _lootChestId != 0 && (_openedContainerId == _lootChestId || _targetCorpseId == _lootChestId) + ? "Chest loot" : "Corpse loot"; + + private bool IsChestLoot(int id) => id != 0 && id == _lootChestId; + + internal enum ChestVerdict { Loot, Wait, Skip } + + /// Names AC/ACE give house storage and hooks ("Storage", "Wall Hook", ...). + internal static bool IsHouseStorageName(string? name) + { + if (string.IsNullOrWhiteSpace(name)) return false; + string n = name.Trim(); + return n.Contains("storage", StringComparison.OrdinalIgnoreCase) + || n.Equals("hook", StringComparison.OrdinalIgnoreCase) + || n.EndsWith(" hook", StringComparison.OrdinalIgnoreCase); + } + + /// + /// Whether an open non-corpse container is a chest to loot. Wait: not decidable yet (the + /// engine can't read who holds it yet); Skip: never this open (why says what it is). + /// + private ChestVerdict JudgeChest(int id, out string why) + { + why = string.Empty; + if (id == 0 || _objectCache == null || _playerId == 0) { why = "not ready"; return ChestVerdict.Wait; } + uint uid = unchecked((uint)id); + if (uid == _playerId) { why = "your main pack"; return ChestVerdict.Skip; } + if (IsCorpseLikeObject(id)) { why = "a corpse"; return ChestVerdict.Skip; } + + if (Host.HasGetObjectBitfield && Host.TryGetObjectBitfield(uid, out uint bf)) + { + if ((bf & ChestBfCorpse) != 0) { why = "a corpse"; return ChestVerdict.Skip; } + if ((bf & ChestBfVendor) != 0) { why = "a vendor"; return ChestVerdict.Skip; } + if ((bf & ChestBfPlayer) != 0) { why = "a player"; return ChestVerdict.Skip; } + } + + if (Host.HasGetObjectInstanceIdProperty + && Host.TryGetObjectInstanceIdProperty(uid, ChestIidHouseOwner, out uint houseOwner) && houseOwner != 0) + { + why = $"house storage (house owner 0x{houseOwner:X8})"; + return ChestVerdict.Skip; + } + string name = _objectCache[id]?.Name ?? string.Empty; + if (string.IsNullOrWhiteSpace(name) && Host.TryGetObjectName(uid, out string hostName)) + name = hostName; + if (IsHouseStorageName(name)) { why = $"house storage (named '{name}')"; return ChestVerdict.Skip; } + + if (!Host.HasGetObjectOwnershipInfo) { why = "the engine can't tell who holds it"; return ChestVerdict.Skip; } + if (!Host.TryGetObjectOwnershipInfo(uid, out uint container, out uint wielder, out _)) + { + why = "who holds it isn't readable yet"; + return ChestVerdict.Wait; + } + if (container == _playerId || wielder == _playerId) { why = "in your inventory"; return ChestVerdict.Skip; } + if (container != 0) + { + bool inSidePack = Host.TryGetObjectOwnershipInfo(container, out uint outer, out _, out _) && outer == _playerId; + why = inSidePack ? "in your inventory (inside a side pack)" : $"held by 0x{container:X8}"; + return ChestVerdict.Skip; + } + if (wielder != 0) { why = $"held by 0x{wielder:X8}"; return ChestVerdict.Skip; } + return ChestVerdict.Loot; + } + + /// OnViewObjectContents for a non-corpse container: remember it as a chest to look at. + private void NoteContainerOpened(int id) + { + if (id == 0 || unchecked((uint)id) == _playerId || IsChestLoot(id)) + return; + _chestCandidateId = id; + _chestCandidateSince = CorpseNowMs; + _chestCandidateInvSeenAt = 0; + _chestSkipLoggedFor = 0; + _chestHeldLoggedFor = 0; + } + + /// + /// The pending loot-check of a natively opened container is left out when the looter takes + /// this container (it says per item what it does); everything else keeps it. + /// + private bool ChestLooterTakesContainer(int id) + { + var settings = _dashboard?.Settings; + if (settings == null || !settings.IsMacroRunning || !settings.EnableLooting || id != _chestCandidateId) + return false; + _chestCandidateInvSeenAt = CorpseNowMs; + return JudgeChest(id, out _) == ChestVerdict.Loot; + } + + /// HasLootWork: an open, eligible chest waits to be looted (no state changed). + private bool HasChestLootWork(LegacyUiSettings settings) + { + if (_chestCandidateId == 0 || _targetCorpseId != 0 || _openedContainerId != 0) + return false; + if (JudgeChest(_chestCandidateId, out _) != ChestVerdict.Loot) + return false; + _lootStarved = CorpseNowMs - _chestCandidateSince >= LootStarveMs; + return true; + } + + /// Once per open: an eligible chest waits because combat holds the tick. + private void LogChestHeldByCombat() + { + int id = _chestCandidateId; + if (id == 0 || _chestHeldLoggedFor == id || _openedContainerId != 0 || _targetCorpseId != 0) + return; + if (JudgeChest(id, out _) != ChestVerdict.Loot) + return; + _chestHeldLoggedFor = id; + LootDiag($"[RynthAi] Chest loot: chest 0x{(uint)id:X8} waits for combat (targets in range); it is looted when the fight ends if it is still open."); + } + + /// + /// TickCorpseOpening, nothing claimed or open: takes an open eligible chest as the loot + /// container (no walk, no open: it is open and in reach). True when this tick is spent on it. + /// + private bool TryTakeOpenChest(LegacyUiSettings settings, long now) + { + int id = _chestCandidateId; + if (id == 0 || _targetCorpseId != 0 || _openedContainerId != 0) + return false; + + ChestVerdict verdict = JudgeChest(id, out string why); + if (verdict == ChestVerdict.Skip) + { + if (_chestSkipLoggedFor != id) + { + _chestSkipLoggedFor = id; + string name = _objectCache?[id]?.Name ?? string.Empty; + LootDiag($"[RynthAi] Chest loot: not looting 0x{(uint)id:X8} '{name}' - {why}."); + } + _chestCandidateId = 0; + return false; + } + if (verdict == ChestVerdict.Wait) + return false; + + if (IsLootingBlockedByPack(settings)) + { + LootDiag($"[RynthAi] Chest loot: not looting 0x{(uint)id:X8} - the pack is full (Stop Looting When Pack Full)."); + _chestCandidateId = 0; + return false; + } + + // The arbiter gives Looting the tick (HasChestLootWork) unless something outranks it. + if (_activity != BotActivity.Looting) + return true; + + TakeChestAsLootContainer(id, now); + PauseNavigationForCorpse(); + StopCorpseMovement(); + TickOpenCorpseLooting(settings); + return true; + } + + /// Makes open chest the loot container (no walk, no open: it is open and in reach). + private void TakeChestAsLootContainer(int id, long now) + { + _chestCandidateId = 0; + _lootChestId = id; + _openedContainerId = id; + _openedContainerAt = _chestCandidateSince != 0 ? _chestCandidateSince : now; + _openedContainerInventoryObservedAt = _chestCandidateInvSeenAt; + _lastLootActionAt = 0; + _corpseItemsEvaluated = 0; + _corpseItemsMatched = 0; + _corpseIdsRequested = false; + ResetCurrentLootItem(); + _processedCorpseItems.Clear(); + _corpseItemAttempts.Clear(); + _pendingManaStoneIds.Clear(); _pendingManaTapIds.Clear(); _pendingKeepUpTo.Clear(); + _targetCorpseId = id; + _corpseTargetSince = now; + _lastCorpseOpenAttemptAt = 0; + _corpseHoldFrozenAge = -1; + + string chestName = _objectCache?[id]?.Name ?? string.Empty; + LootDiag($"[RynthAi] Chest loot: looting open chest 0x{(uint)id:X8} '{chestName}' (already open and in reach: no walk, no open)."); + } + + /// + /// Ends the chest session. Unlike a corpse the chest is never put in _completedCorpses (it + /// regenerates; the next open loots again). : close the window, as a + /// finished corpse is (ACE holds an open chest for its viewer, and some chests regenerate on + /// close); false when it was closed already. + /// + private void FinishChestLoot(int chestId, string why, bool close, bool sayNothingMatched) + { + if (close) + CloseCorpseContainer(chestId, why); + + if (sayNothingMatched && _corpseItemsEvaluated > 0 && _corpseItemsMatched == 0) + { + string chestName = _objectCache?[chestId]?.Name ?? $"0x{(uint)chestId:X8}"; + ChatLine($"[RynthAi] Nothing in {chestName} matches the loot profile."); + } + LootDiag($"[RynthAi] Chest loot: done with chest 0x{(uint)chestId:X8} ({why}); not marked, so opening it again loots it again."); + + _processedCorpseItems.Clear(); + _corpseItemAttempts.Clear(); + _pendingManaStoneIds.Clear(); _pendingManaTapIds.Clear(); _pendingKeepUpTo.Clear(); + _corpseIdsRequested = false; + ResetCurrentLootItem(); + if (_openedContainerId == chestId) + { + _openedContainerId = 0; + _openedContainerAt = 0; + _openedContainerInventoryObservedAt = 0; + } + if (_targetCorpseId == chestId) + { + StopCorpseMovement(); + _targetCorpseId = 0; + _corpseTargetSince = 0; + _lastCorpseOpenAttemptAt = 0; + _lastLootActionAt = 0; + } + if (_chestCandidateId == chestId) + _chestCandidateId = 0; + _lootChestId = 0; + } + + /// OnStopViewingObjectContents / DeleteObject for a chest. True when it was the chest being looted. + private bool OnChestGone(int id, string how) + { + if (_chestCandidateId == id) + _chestCandidateId = 0; + if (!IsChestLoot(id)) + return false; + bool active = _openedContainerId == id || _targetCorpseId == id; + if (!active) + { + _lootChestId = 0; + return true; + } + LootDiag($"[RynthAi] Chest loot: chest 0x{(uint)id:X8} {how} before looting finished; not reopening it (open it again to loot the rest)."); + FinishChestLoot(id, how, close: false, sayNothingMatched: false); + return true; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.DataFolders.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.DataFolders.cs new file mode 100644 index 0000000..b65da80 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.DataFolders.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using RynthCore.Install; +using RynthCore.Plugin.RynthAi.Diagnostics; + +namespace RynthCore.Plugin.RynthAi; + +// Players reported metas and navs "not saving" and the plugin folders being "read only" +// (2026-10-13). Every save now reports a failure (Diagnostics/DataWriteGuard.cs); this is the +// startup self-check that finds a folder the client can't write before anything is lost, and +// the tick that posts those lines once the character is in game. +public sealed partial class RynthAiPlugin +{ + /// The folders RynthAi saves metas, navs, loot and settings profiles in. + internal static IEnumerable DataFolders() + { + string root = RynthInstallPaths.RynthAiDir; + yield return root; + yield return Path.Combine(root, "MetaFiles"); + yield return Path.Combine(root, "NavProfiles"); + yield return Path.Combine(root, "LootProfiles"); + yield return Path.Combine(root, "SettingsProfiles"); + } + + private void StartDataFolderCheck() + { + DataWriteGuard.Reset(); + DataWriteGuard.LogSink = msg => Log(msg); + // Off the init thread: a slow disk, antivirus or a network share mustn't hold up the client. + Task.Run(() => + { + try { DataWriteGuard.CheckFolders(DataFolders()); } + catch { } + }); + } + + private void PostDataWriteProblems() + { + if (DataWriteGuard.PendingCount == 0) return; + DataWriteGuard.DrainChat(line => Host.WriteToChat(line, 2)); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.DeathRecall.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.DeathRecall.cs new file mode 100644 index 0000000..8299fb0 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.DeathRecall.cs @@ -0,0 +1,140 @@ +using System; +using System.Linq; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthAi; + +/// +/// Recall On Death (DeathRecallMode): after a death while the macro was running, once respawned +/// and settled (HoldForDeath), cast a recall spell (DeathRecallSpellId) or use a recall item from +/// the pack (DeathRecallItem: a gem, a scroll, a portal token). RynthAi does nothing else until the +/// teleport lands (or the attempt gives up), then picks the closest nav waypoint and, with Travel +/// Back To My Corpse on, walks to the corpse from there. Off by default: most metas handle a death +/// themselves. Runs whatever the macro does after the death, so Stop Macro On Death still recalls +/// first. A new death cancels it. +/// +public sealed partial class RynthAiPlugin +{ + private bool _deathRecallArmed; + private DeathRecallRun? _deathRecall; + private string _deathRecallWhat = string.Empty; + + /// The death edge (CheckPlayerDeath): arm the recall for the respawn when it is on and the macro ran. + private void ArmDeathRecall(LegacyUiSettings s) + { + if (_deathRecall != null) + { + Log("[RynthAi] Death recall: died again - the recall in progress is cancelled."); + _deathRecall = null; + } + _deathRecallArmed = s.DeathRecallMode is 1 or 2 && s.IsMacroRunning; + } + + /// + /// The respawn edge (HoldForDeath): start the armed recall. False when nothing was started + /// (off, not armed, no such item), so the caller goes straight on to the corpse trip. + /// + private bool StartDeathRecall() + { + if (!_deathRecallArmed) return false; + _deathRecallArmed = false; + var s = _dashboard?.Settings; + if (s == null || s.DeathRecallMode is not (1 or 2)) return false; + + bool useItem = s.DeathRecallMode == 2; + if (useItem) + { + string name = (s.DeathRecallItem ?? string.Empty).Trim(); + if (name.Length == 0) { ChatLine("[RynthAi] Recall On Death: no item name set (Settings > On Death)."); return false; } + WorldObject? item = FindRecallItem(name); + if (item == null) { ChatLine($"[RynthAi] Recall On Death: no \"{name}\" in your inventory - not recalling."); return false; } + if (!Host.HasUseObject) { ChatLine("[RynthAi] Recall On Death: this engine can't use items - not recalling."); return false; } + _deathRecallWhat = item.Name; + } + else + { + if (!Host.HasCastSpell) { ChatLine("[RynthAi] Recall On Death: this engine can't cast spells - not recalling."); return false; } + _deathRecallWhat = NavPoint.RecallName(s.DeathRecallSpellId); + } + + _deathRecall = new DeathRecallRun(useItem, Environment.TickCount64, CurrentLandblockForRecall()); + ChatLine($"[RynthAi] Recall On Death: {(useItem ? "using" : "casting")} {_deathRecallWhat}."); + return true; + } + + /// + /// Every tick after HoldForDeath. True while a recall is in progress: the rest of the tick + /// (combat, buffing, looting, nav) waits for it. + /// + private bool TickDeathRecall() + { + var run = _deathRecall; + if (run == null) return false; + var s = _dashboard?.Settings; + bool useItem = s?.DeathRecallMode == 2; + + bool portaling = Host.HasIsPortaling && Host.IsPortaling(); + // A spell needs a wand and magic mode first (the same step a nav Recall waypoint takes). + bool ready = useItem || portaling || (_combatManager?.EnsureMagicReady() ?? true); + switch (run.Tick(Environment.TickCount64, portaling, CurrentLandblockForRecall(), ready)) + { + case DeathRecallRun.Step.Fire: + if (!FireDeathRecall(s, useItem)) EndDeathRecall("the item is gone from your inventory", success: false); + return true; + case DeathRecallRun.Step.Done: + EndDeathRecall("recalled", success: true); + return false; + case DeathRecallRun.Step.Failed: + EndDeathRecall(run.FailReason, success: false); + return false; + default: + return true; + } + } + + private bool FireDeathRecall(LegacyUiSettings? s, bool useItem) + { + if (s == null) return false; + if (useItem) + { + WorldObject? item = FindRecallItem((s.DeathRecallItem ?? string.Empty).Trim()); + if (item == null) return false; + Host.UseFor(unchecked((uint)item.Id), "DeathRecall", $"recall item '{item.Name}' (Recall On Death)"); + Log($"[RynthAi] Death recall: used {item.Name} (0x{(uint)item.Id:X8})."); + return true; + } + uint me = _playerId != 0 ? _playerId : (uint)Host.GetPlayerId(); + if (me == 0) return true; // retried on the next fire + Host.CastSpellFor(me, s.DeathRecallSpellId, "DeathRecall", $"{_deathRecallWhat} (Recall On Death)"); + Log($"[RynthAi] Death recall: cast {_deathRecallWhat} ({s.DeathRecallSpellId})."); + return true; + } + + private void EndDeathRecall(string why, bool success) + { + _deathRecall = null; + ChatLine(success + ? $"[RynthAi] Recall On Death: {why} with {_deathRecallWhat}." + : $"[RynthAi] Recall On Death: {_deathRecallWhat} didn't work ({why}) - carrying on from here."); + // Wherever we are now, nav rejoins its route at the closest waypoint. + _navigationEngine?.ResumeFromNearestWaypoint(always: true); + try { OnRespawnedForOwnCorpse(); } // Travel Back To My Corpse, from the recall's landing spot + catch (Exception ex) { Log($"[RynthAi] Own corpse travel not started: {ex.Message}"); } + } + + /// The carried or worn item named (ignoring case), else the first containing it. + private WorldObject? FindRecallItem(string name) + { + if (_objectCache == null || name.Length == 0) return null; + var inv = _objectCache.GetDirectInventory(forceRefresh: true).Where(w => w.Name.Length > 0).ToList(); + return inv.FirstOrDefault(w => w.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) + ?? inv.FirstOrDefault(w => w.Name.Contains(name, StringComparison.OrdinalIgnoreCase)); + } + + private uint CurrentLandblockForRecall() + { + if (!Host.HasGetPlayerPose) return 0; + return Host.TryGetPlayerPose(out uint cell, out _, out _, out _, out _, out _, out _, out _) ? cell >> 16 : 0; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.HazardEscape.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.HazardEscape.cs index d8ad81a..797f4b4 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.HazardEscape.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.HazardEscape.cs @@ -319,6 +319,6 @@ public sealed partial class RynthAiPlugin _hazardHasTarget = false; _hazardPath.Clear(); _hazardTrailCount = 0; // the old trail runs through the pool - _navigationEngine?.ResumeFromNearestWaypoint(); + _navigationEngine?.ResumeFromNearestWaypoint(always: true); } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ItemInfo.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ItemInfo.cs deleted file mode 100644 index c424a54..0000000 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.ItemInfo.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using RynthCore.Plugin.RynthAi.ItemInfo; -using RynthCore.PluginSdk; - -namespace RynthCore.Plugin.RynthAi; - -/// -/// /ra iteminfo [name]: a selected (or named) item's details on one chat line, Mag-Tools -/// style (ItemInfo/ItemInfoText). An item the client hasn't appraised is identified first -/// and printed when the appraisal arrives, or after with -/// what the client has. Partial class of RynthAiPlugin. -/// -/// Threads: the command only queues its argument; on the plugin -/// tick does every host read, the ID request and the print. Nothing is drawn. -/// -public sealed partial class RynthAiPlugin -{ - internal const long ItemInfoTimeoutMs = 5000; - - /// Test seam: the clock the ID timeout runs on. - internal static Func ItemInfoClock = () => Environment.TickCount64; - - private readonly ConcurrentQueue _itemInfoRequests = new(); - // One item waiting for its appraisal at a time (tick thread only); a newer request replaces it. - private uint _itemInfoPendingId; - private long _itemInfoDeadline; - - /// /ra iteminfo [item name]. Queued for the next tick. - private void HandleItemInfoCommand(string[] parts) - { - string arg = parts.Length > 2 ? string.Join(" ", parts, 2, parts.Length - 2).Trim() : string.Empty; - if (arg.Equals("help", StringComparison.OrdinalIgnoreCase) || arg == "?") - { - ChatLine("[RynthAi] /ra iteminfo - the selected item's details (identifies it first when needed)."); - ChatLine("[RynthAi] /ra iteminfo - the first item in your inventory with that name (else one whose name contains it)."); - return; - } - if (_itemInfoRequests.Count < 8) _itemInfoRequests.Enqueue(arg); - } - - /// Plugin tick: starts queued requests, prints an item once its ID lands or times out. - private void TickItemInfo() - { - while (_itemInfoRequests.TryDequeue(out string? arg)) - StartItemInfo(arg); - - uint selected = System.Threading.Interlocked.Exchange(ref _itemInfoSelectId, 0); - if (selected != 0) - StartItemInfoFor(selected, quiet: true); - - uint pending = _itemInfoPendingId; - if (pending == 0) return; - bool appraised = !Host.HasHasAppraisalData || Host.HasAppraisalData(pending); - if (appraised || ItemInfoClock() >= _itemInfoDeadline) - { - _itemInfoPendingId = 0; - PrintItemInfo(pending, identified: appraised); - } - } - - private void StartItemInfo(string arg) - { - uint id; - if (arg.Length == 0) - { - id = Host.HasGetSelectedItemId ? Host.GetSelectedItemId() : 0; - if (id == 0) - { - ChatLine("[RynthAi] Item info: nothing selected. Select an item, or /ra iteminfo ."); - return; - } - } - else - { - id = FindInventoryItemByName(arg); - if (id == 0) - { - ChatLine($"[RynthAi] Item info: no \"{arg}\" in your inventory."); - return; - } - } - StartItemInfoFor(id, quiet: false); - } - - /// - /// Prints now when it's appraised, else asks for its ID and prints when - /// it lands. (Item Info On Select): no "identifying" chatter. - /// - private void StartItemInfoFor(uint id, bool quiet) - { - if (!Host.HasHasAppraisalData || Host.HasAppraisalData(id)) - { - if (_itemInfoPendingId == id) _itemInfoPendingId = 0; - PrintItemInfo(id, identified: true); - return; - } - - if (!quiet && _itemInfoPendingId != 0 && _itemInfoPendingId != id) - ChatLine($"{ItemPrefix}Item info: stopped waiting for {ObjectNameOr(_itemInfoPendingId)}."); - if (Host.HasRequestId) Host.RequestId(id); - _itemInfoPendingId = id; - _itemInfoDeadline = ItemInfoClock() + ItemInfoTimeoutMs; - if (!quiet) ChatLine($"{ItemPrefix}Item info: identifying {ObjectNameOr(id)}..."); - } - - // Item Info On Select: the item the player just selected, for the next tick (0 = none). - private uint _itemInfoSelectId; - - /// - /// Selection change (OnSelectedTargetChange): queues Item Info for an item the player - /// selected. Skips non-items and RynthAi's own selections (the looter, metas). - /// - /// Queues item info for the player's pick; true when it will print (Item Info On Select). - private bool QueueItemInfoOnSelect(uint id, WorldObject? obj) - { - if (id == 0 || _dashboard?.Settings is not { ItemInfoOnSelect: true }) return false; - if (obj == null || !IsLootableClass(obj.ObjectClass)) return false; - if (SelfSelect.IsOurs(id)) return false; - System.Threading.Interlocked.Exchange(ref _itemInfoSelectId, id); - return true; - } - - /// - /// An inventory item (carried or worn) whose name is , ignoring case; - /// else the first whose name contains it. 0 when none. - /// - private uint FindInventoryItemByName(string name) - { - if (_objectCache == null) return 0; - uint partial = 0; - foreach (WorldObject wo in _objectCache.GetInventory()) - { - if (wo.Name.Length == 0) continue; - if (wo.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) return unchecked((uint)wo.Id); - if (partial == 0 && wo.Name.Contains(name, StringComparison.OrdinalIgnoreCase)) partial = unchecked((uint)wo.Id); - } - return partial; - } - - private string ObjectNameOr(uint id) => - Host.TryGetObjectName(id, out string n) && n.Length > 0 ? n : $"0x{id:X8}"; - - /// - /// Item info lines carry their own prefix so RynthChat files them under its Items tab - /// (ChatClassifier.IsItemInfo, 2026-10-09); it still starts "[Rynth", so other chat - /// windows treat it as RynthAi output. - /// - internal const string ItemPrefix = "[RynthAi Item] "; - - private void PrintItemInfo(uint id, bool identified) - { - var source = new HostItemInfoSource(Host, id); - ChatLine(ItemPrefix + ItemInfoText.Describe(source, SpellDatabase.GetSpellName, identified) + LootVerdictSuffix(id)); - } - - /// - /// " | Loot: [Keep] (A) MajorSkill Set": the looter's own verdict on the item, as a preview - /// (nothing recorded), so it says exactly what [LootEval] would. Item info on select replaced - /// the separate verdict line (95df8ed), which was the only place it showed (Tom, 2026-10-10: - /// lots of Major armor kept and no way to tell which rule). "" when there's no loot profile, - /// or /ra lootcheck off (the toggle that hid the old verdict line too). - /// - private string LootVerdictSuffix(uint id) - { - try - { - LegacyUi.LegacyUiSettings? settings = _dashboard?.Settings; - WorldObject? wo = _objectCache?[unchecked((int)id)]; - if (!_lootInspectMode || settings == null || wo == null || string.IsNullOrEmpty(settings.CurrentLootPath)) return ""; - if (!ClassifyLootItem(wo, settings, preview: true, out string action, out _, out string rule, out string builtIn)) - // A rule can match and still not take it (its Keep # reached, a Read rule on a non-scroll). - return rule.Length > 0 ? $" | Loot: leave ({rule} matched, not taken)" : " | Loot: no rule matched"; - if (builtIn.Length > 0) return $" | Loot: [{action}] built-in - {builtIn}"; - return $" | Loot: [{action}] {(rule.Length > 0 ? rule : "(unnamed rule)")}"; - } - catch (Exception ex) - { - Host.Log($"[RynthAi] Item info: loot verdict failed for 0x{id:X8}: {ex.GetType().Name}: {ex.Message}"); - return ""; - } - } - - /// The live appraisal through the host (tick thread). - private sealed class HostItemInfoSource : IItemInfoSource - { - private readonly RynthCoreHost _host; - private readonly uint _id; - - public HostItemInfoSource(RynthCoreHost host, uint id) - { - _host = host; - _id = id; - Name = host.TryGetObjectName(id, out string n) ? n : string.Empty; - SpellIds = ReadSpells(host, id); - } - - public string Name { get; } - public IReadOnlyList SpellIds { get; } - - public bool TryInt(uint key, out int value) - { - value = 0; - return _host.HasGetObjectIntProperty && _host.TryGetObjectIntProperty(_id, key, out value); - } - - public bool TryFloat(uint key, out double value) - { - value = 0; - return _host.TryGetObjectDoubleProperty(_id, key, out value); - } - - private static IReadOnlyList ReadSpells(RynthCoreHost host, uint id) - { - if (!host.HasGetObjectSpellIds) return Array.Empty(); - var buf = new uint[64]; - int n = host.GetObjectSpellIds(id, buf, buf.Length); - if (n <= 0) return Array.Empty(); - var list = new List(n); - for (int i = 0; i < n && i < buf.Length; i++) list.Add(unchecked((int)buf[i])); - return list; - } - } -} diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.LocalFeatures.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.LocalFeatures.cs new file mode 100644 index 0000000..7a2ddee --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.LocalFeatures.cs @@ -0,0 +1,577 @@ +// RynthAiPlugin.LocalFeatures.cs — ILT Hub, floating HUDs, chat translation, item info, the nav +// overlay and the UB damage seed. +// +// The engine draws the main panels. These features draw their own ImGui windows from +// RynthPluginRender / RynthPluginRenderOverlay. Lifecycle methods on RynthAiPlugin call into +// this file; they add to combat, loot and navigation and never replace them. +using System; +using System.Collections.Generic; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi; + +public sealed partial class RynthAiPlugin +{ + private NavBreadcrumbTracker? _navBreadcrumbs; + private NavOverlayRenderer? _navOverlay; + private IltHub.IltHubController? _iltHub; + private Huds.HudController? _huds; + private Huds.HudIconCache? _hudIcons; + private Translate.ChatTranslator? _translator; + private Translate.TranslateUi? _translateUi; + private LegacyItemInfoUi? _itemInfoUi; + private CreatureData.UbMobSeedStore? _mobSeedStore; + // Mini Remote session stats: RynthTracker's SessionStats (Plugins\Shared), so the Mini Remote and + // the Tracker panel count the same way. Lives for the plugin; starts and ends with each login. + private RynthCore.Plugin.Shared.SessionStatsTracker? _sessionStats; + + // One-time overlay diagnostics (render thread only). + private string? _overlaySkipReasonLogged; + private bool _overlayEnteredLogged; + + /// Daily diagnostics log. Feature code writes through . + private void InitLocalDiagnostics() + { + try { RynthLog.Init(Host); } + catch (Exception ex) { Host.Log($"[RynthAi] diagnostics init failed: {ex.Message}"); } + try { _mobSeedStore = new CreatureData.UbMobSeedStore(); } + catch (Exception ex) { Host.Log($"[RynthAi] mob seed store failed: {ex.Message}"); } + } + + /// Session stats for the Mini Remote, saved in their own folder (never RynthTracker's). + private void InitSessionStats() + { + try + { + _sessionStats = new RynthCore.Plugin.Shared.SessionStatsTracker(Host, "[RynthAi] Mini Remote stats:", + RynthCore.Plugin.Shared.TrackerSessionStore.DirectoryFor("miniremote-stats")); + } + catch (Exception ex) { Host.Log($"[RynthAi] session stats init failed: {ex.Message}"); } + } + + /// + /// CombatManager.MobSeedLookup: the seed's damage types for a monster, best first (highest + /// Score), or null when the seed has nothing for it. Feeds the Auto element ranking only + /// after the server table and the learned element (see CreatureWeakness.Rank). + /// + private IReadOnlyList? LookupMobSeed(uint wcid, string name) + { + var store = _mobSeedStore; + if (store == null || !store.TryGetRanked(wcid, name, out var ranked) || ranked.Count == 0) + return null; + var ordered = new List(ranked); + ordered.Sort((a, b) => b.Score.CompareTo(a.Score)); + var elements = new List(ordered.Count); + foreach (var e in ordered) elements.Add(e.Element); + return elements; + } + + /// Chat translator survives logout; session language resets on each login. + private void EnsureTranslator() + { + try + { + if (_translator == null) + { + _translator = new Translate.ChatTranslator(Host, CurrentCharacterName); + _translateUi = new Translate.TranslateUi(_translator); + } + _translator.ResetSession(); + if (_huds != null) _huds.Translate = _translateUi; + } + catch (Exception ex) { RynthLog.Exception(LogCat.Chat, ex, "translator init"); } + } + + /// The logged-in character's name, or empty before login. + private string CurrentCharacterName() + => _playerId != 0 && Host.HasGetObjectName && Host.TryGetObjectName(_playerId, out string name) ? name ?? string.Empty : string.Empty; + + /// Waypoint HUD, labels, guide line, and the breadcrumb recorder. + private void CreateNavOverlay() + { + if (_dashboard == null) return; + _navBreadcrumbs = new NavBreadcrumbTracker(Host, _dashboard.Settings, DescribeNavPortal, ChatLine); + _navOverlay = new NavOverlayRenderer(Host, _dashboard.Settings, _navBreadcrumbs); + _dashboard.NavBreadcrumbs = _navBreadcrumbs; // Nav panel: trail -> route, trail stats + } + + /// Nav recorder hook: (name, object class) when is a portal. + private (string Name, int ObjectClass)? DescribeNavPortal(uint id) + { + WorldObject? wo = _objectCache?[unchecked((int)id)]; + if (wo == null || wo.ObjectClass != AcObjectClass.Portal || string.IsNullOrEmpty(wo.Name)) return null; + return (wo.Name, (int)AcObjectClass.Portal); + } + + /// + /// ILT Hub and floating HUDs for the loaded character. No-op until the per-character + /// folder exists, so login and the deferred settings load in OnTick both call this. + /// + private void CreateIltHub() + { + if (_dashboard == null || string.IsNullOrEmpty(_dashboard.CharFolder) || _iltHub != null) + return; + + var dash = _dashboard; + // Settings > Misc "Server Features" status line names the current world. + IltHub.ServerFeatureGate.WorldNameProvider ??= + () => Host.HasGetWorldName && Host.TryGetWorldName(out string w) ? w ?? string.Empty : string.Empty; + _iltHub = new IltHub.IltHubController(Host, dash.CharFolder, + () => _objectCache, () => dash.Settings, () => _questTracker, + () => dash.SaveSettings(), _sessionStats); + _hudIcons ??= new Huds.HudIconCache(Host, () => _raycast?.GeometryLoader?.PortalDat); + _huds = new Huds.HudController(Host, dash.CharFolder, () => _objectCache, dash, () => _iltHub, _hudIcons, + () => _combatManager?.activeTargetId ?? 0) + { + SessionStats = _sessionStats, + }; + if (_translateUi != null) _huds.Translate = _translateUi; + + // The ILT sections are Mini Remote tabs: "/ra hub [show|hide|toggle]" drives the remote, + // "/ra hub open
" its tabs, and while it is up the Hub keeps its bank / gear data fresh. + var huds = _huds; + _iltHub.MiniRemoteCommand = mode => "[Mini Remote] " + huds.HandleCommand("remote", mode); + _iltHub.MiniRemoteTabCommand = (tab, mode) => huds.HandleTabCommand(tab, mode); + _iltHub.MiniRemoteVisible = () => huds.MiniRemoteActive; + EnsureItemInfoUi(); + EnsureSpellsUi(); + } + + /// Item Info window, created once settings exist. + private void EnsureItemInfoUi() + { + if (_dashboard == null || _itemInfoUi != null) return; + _itemInfoUi = new LegacyItemInfoUi(_dashboard.Settings); + _itemInfoUi.SetHooks(DescribeSelectedItemForPreview, PrintSelectedItemInfo, TestItemInfoChatType); + } + + /// Pump-thread work for the ported features. Safe before login (each call is null-checked). + private void TickLocalFeatures() + { + try { RynthLog.Pump(); } + catch (Exception ex) { Host.Log($"[RynthAi] diagnostics pump: {ex.Message}"); } + try { _sessionStats?.Tick(); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltRates, ex, "session stats tick"); } + try { _iltHub?.Tick(); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "Tick"); } + try { _huds?.Tick(); } + catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "Tick"); } + try { _translator?.Tick(); } + catch (Exception ex) { RynthLog.Exception(LogCat.Chat, ex, "translator Tick"); } + try { TickItemInfo(); } + catch (Exception ex) { RynthLog.Exception(LogCat.General, ex, "item info tick"); } + try { TickSpellsUi(); } + catch (Exception ex) { RynthLog.Exception(LogCat.General, ex, "spells window tick"); } + try { _navBreadcrumbs?.Tick(); } + catch (Exception ex) { RynthLog.Exception(LogCat.Navigation, ex, "nav breadcrumbs tick"); } + Loot.T11ItemSupport.SyncOverride(_dashboard?.Settings.T11ItemAugsOverride ?? -1); + } + + /// Drop per-character feature objects. The translator is disposed only on plugin shutdown. + private void TeardownLocalFeatures(bool disposeTranslator) + { + try { _navBreadcrumbs?.Shutdown(); } + catch (Exception ex) { RynthLog.Exception(LogCat.Navigation, ex, "nav recorder shutdown"); } + _navBreadcrumbs = null; + if (_dashboard != null) _dashboard.NavBreadcrumbs = null; + _navOverlay = null; + try { _iltHub?.OnLogout(); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "logout"); } + _iltHub = null; + IltHub.ServerFeatureGate.HubForceProvider = null; + try { _huds?.OnLogout(); } + catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "logout"); } + _huds = null; + _itemInfoUi = null; + _spellsUi = null; + ResetGroundLoot(clearCaches: true); + Loot.T11ItemSupport.Reset(); + if (!disposeTranslator) return; + try { _translator?.Dispose(); } + catch (Exception ex) { RynthLog.Exception(LogCat.Chat, ex, "translator dispose"); } + _translator = null; + _translateUi = null; + } + + /// ILT Hub may eat a server reply; the translator records the line either way. + private void OnChatLocalFeatures(string text, int chatType, ref int eat) + { + try + { + if (_iltHub?.OnChat(text) == true) eat = 1; + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "OnChat"); } + try { _translator?.OnChatWindowText(text, chatType); } + catch (Exception ex) { RynthLog.Exception(LogCat.Chat, ex, "translator inbound"); } + } + + /// True when the translator swallowed an outbound chat line (it will resend the translation). + private bool TryEatOutboundTranslation(string trimmed) + { + try + { + return _translator != null && _translator.TryInterceptOutbound(trimmed); + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.Chat, ex, "translator outbound"); + return false; + } + } + + /// ImGui windows the engine panels do not draw. + public override void OnRender() + { + if (!_initialized || !_loginComplete || Host.ImGuiContext == IntPtr.Zero) + return; + + IntPtr previousContext = ImGui.GetCurrentContext(); + ImGui.SetCurrentContext(Host.ImGuiContext); + try + { + DetectItemInfoClick(); + _navOverlay?.Render(); + _itemInfoUi?.Render(); + _spellsUi?.Render(); + _iltHub?.Render(); + _huds?.Render(); + RenderTranslateWindow(); + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.UI, ex, "OnRender"); + } + finally + { + ImGui.SetCurrentContext(previousContext); + } + } + + /// + /// Called when the engine's ImGui shell is off. Same local windows as ; + /// the engine panels are absent in that mode, so these windows are the only UI for them. + /// + public void OnRenderOverlay() + { + if (!_initialized || !_loginComplete || Host.ImGuiContext == IntPtr.Zero) + { + string reason = !_initialized ? "not initialized" : !_loginComplete ? "login not complete" : "no ImGui context"; + if (reason != _overlaySkipReasonLogged) + { + _overlaySkipReasonLogged = reason; + RynthLog.Write(LogCat.UI, $"[Overlay] OnRenderOverlay skipped: {reason}."); + } + return; + } + + if (!_overlayEnteredLogged) + { + _overlayEnteredLogged = true; + RynthLog.Write(LogCat.UI, $"[Overlay] OnRenderOverlay drawing (iltHub={(_iltHub != null ? "ready" : "null")})."); + } + + IntPtr previousContext = ImGui.GetCurrentContext(); + ImGui.SetCurrentContext(Host.ImGuiContext); + try + { + DetectItemInfoClick(); + int pushedColors = LegacyDashboardRenderer.PushDashboardStyle(); + try { _iltHub?.Render(); } + finally { ImGui.PopStyleColor(pushedColors); } + _huds?.Render(); + RenderTranslateWindow(); + _navOverlay?.Render(); + _itemInfoUi?.Render(); + _spellsUi?.Render(); + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.UI, ex, "OnRenderOverlay"); + } + finally + { + ImGui.SetCurrentContext(previousContext); + } + } + + /// + /// The ImGui context an embedded surface draws in: the engine's current one, which is the + /// context of the window it has begun (a popped-out panel has its own, not + /// Host.ImGuiContext; switching to Host.ImGuiContext there drew into a context that wasn't + /// mid-frame and crashed the client, 2026-10-11). Host.ImGuiContext only if none is current. + /// + private IntPtr EmbedContext() + { + IntPtr current = ImGui.GetCurrentContext(); + return current != IntPtr.Zero ? current : Host.ImGuiContext; + } + + /// + /// RynthPluginRenderEmbed "miniremote" / "miniremote-window": the Mini Remote inside the + /// engine's RynthAi dashboard drawer, or () inside the engine's Mini + /// Remote window, docked or popped out, drawn into the engine's current ImGui window (and + /// context, see ). False (nothing drawn) until login and the HUDs + /// exist. Render thread. + /// + public bool RenderEmbeddedMiniRemote(bool window, out System.Numerics.Vector2 want) + { + want = default; + var huds = _huds; + if (!_initialized || !_loginComplete || Host.ImGuiContext == IntPtr.Zero || huds == null) + return false; + + IntPtr previousContext = ImGui.GetCurrentContext(); + ImGui.SetCurrentContext(EmbedContext()); + try + { + want = huds.RenderEmbedded(window); + return true; + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.UI, ex, "RenderEmbeddedMiniRemote"); + return false; + } + finally + { + ImGui.SetCurrentContext(previousContext); + } + } + + /// + /// RynthPluginRenderEmbed "guardian": the Temple guardian tools inside RynthCore's Guardian + /// panel (the bar's ILT button), drawn into the engine's current ImGui window at the size it + /// gives ( echoes that size: the panel is user-sized), docked or popped + /// out (). False (nothing drawn) until login and the ILT features + /// exist. Render thread. + /// + public bool RenderEmbeddedGuardian(System.Numerics.Vector2 size, out System.Numerics.Vector2 want) + { + want = size; + var hub = _iltHub; + if (!_initialized || !_loginComplete || Host.ImGuiContext == IntPtr.Zero || hub == null) + return false; + + IntPtr previousContext = ImGui.GetCurrentContext(); + ImGui.SetCurrentContext(EmbedContext()); + int pushedColors = LegacyDashboardRenderer.PushDashboardStyle(); + try + { + hub.RenderGuardianPanel(); + return true; + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.UI, ex, "RenderEmbeddedGuardian"); + return false; + } + finally + { + ImGui.PopStyleColor(pushedColors); + ImGui.SetCurrentContext(previousContext); + } + } + + /// Chat Translate window in the dashboard colours (no-op while hidden). + private void RenderTranslateWindow() + { + var ui = _translateUi; + if (ui == null || _translator?.Settings.ShowWindow != true) return; + int pushedColors = LegacyDashboardRenderer.PushDashboardStyle(); + try { ui.RenderWindow(); } + finally { ImGui.PopStyleColor(pushedColors); } + } + + /// "/ra huds|itemhud|remote|miniremote [show|hide|toggle]". + private void HandleHudCommand(string which, string mode) + { + if (_huds == null) { ChatLine("[RynthAi] HUDs not ready (log in first)."); return; } + ChatLine("[RynthAi] " + _huds.HandleCommand(which, mode)); + } + + /// Skills panel Progression tab snapshot (RynthPluginGetProgressionJson). Pump thread. + internal string BuildProgressionJson() => _iltHub?.BuildProgressionJson() ?? "{\"available\":false}"; + + /// Settings panel Charms Tracking tab snapshot (RynthPluginGetCharmsJson). Pump thread. + internal string BuildCharmsJson() => _iltHub?.BuildCharmsJson() ?? "{\"available\":false}"; + + /// "prog ..." remote command from the Skills panel's Progression tab. Pump thread. + private void HandleProgressionRemote(string value) + { + if (_iltHub == null) { ChatLine("[RynthAi] ILT features not ready (log in first)."); return; } + _iltHub.Progression.HandleRemote(value.Split(' ', StringSplitOptions.RemoveEmptyEntries)); + } + + /// "/ra itemhud add <name>" and the inventory panel's "Add to item count HUD". Pump thread. + private void HandleItemHudAdd(string name) + { + if (_huds == null) { ChatLine("[RynthAi] HUDs not ready (log in first)."); return; } + if (string.IsNullOrWhiteSpace(name)) { ChatLine("[RynthAi] Usage: /ra itemhud add "); return; } + ChatLine("[RynthAi] " + _huds.AddToItemHudAndShow(name)); + } + + /// /ra translate ... — forwards to the chat translator. + private void HandleTranslateCommand(string[] parts) + { + if (_translator == null) { ChatLine("[RynthAi] Chat translator not ready (log in first)."); return; } + _translator.HandleCommand(parts.Length > 2 ? parts[2..] : Array.Empty(), ChatLine); + } + + /// Parses an on/off word; returns null for anything else (caller treats it as status). + private static bool? ParseOnOff(string? word) => word?.ToLowerInvariant() switch + { + "on" or "true" or "1" or "enable" => true, + "off" or "false" or "0" or "disable" => false, + _ => null, + }; + + /// "/ra debug [on|off|status]" — echoes trace and exception lines to chat. + private void HandleDebugCommand(string[] parts) + { + string arg = parts.Length > 2 ? parts[2] : "status"; + bool? state = arg.Equals("toggle", StringComparison.OrdinalIgnoreCase) ? !RynthLog.DebugToChat : ParseOnOff(arg); + if (state.HasValue) RynthLog.DebugToChat = state.Value; + ChatLine($"[RynthAi] Debug-to-chat is {(RynthLog.DebugToChat ? "ON" : "off")}." + + (RynthLog.DebugToChat && RynthLog.TracedCategories().Count == 0 ? " (no categories traced — see /ra trace list)" : "")); + } + + /// "/ra trace <cat|all|ilt|list> [on|off|status]". + private void HandleTraceCommand(string[] parts) + { + string target = parts.Length > 2 ? parts[2] : "status"; + string? action = parts.Length > 3 ? parts[3] : null; + + if (target.Equals("status", StringComparison.OrdinalIgnoreCase)) + { + foreach (string l in RynthLog.StatusLines()) ChatLine(l); + return; + } + + if (target.Equals("list", StringComparison.OrdinalIgnoreCase)) + { + var names = new System.Collections.Generic.List(); + foreach (LogCat c in Enum.GetValues()) + names.Add(RynthLog.IsTracing(c) ? c + "*" : c.ToString()); + ChatLine("[RynthAi] Trace categories (* = on): " + string.Join(", ", names)); + return; + } + + bool? state = ParseOnOff(action); + bool isAll = target.Equals("all", StringComparison.OrdinalIgnoreCase); + bool isIlt = target.Equals("ilt", StringComparison.OrdinalIgnoreCase); + if (isAll || isIlt) + { + if (!state.HasValue) { foreach (string l in RynthLog.StatusLines()) ChatLine(l); return; } + int n = RynthLog.SetTracingByPrefix(isIlt ? "Ilt" : string.Empty, state.Value); + ChatLine($"[RynthAi] Tracing {(state.Value ? "enabled" : "disabled")} for {n} {(isIlt ? "ILT Hub " : "")}categories."); + return; + } + + if (!RynthLog.TryParseCategory(target, out LogCat cat)) + { + ChatLine($"[RynthAi] Unknown trace category '{target}'. Use /ra trace list."); + return; + } + + if (action != null && action.Equals("status", StringComparison.OrdinalIgnoreCase)) + { + ChatLine($"[RynthAi] Trace {cat}: {(RynthLog.IsTracing(cat) ? "ON" : "off")}"); + return; + } + + bool enable = state ?? !RynthLog.IsTracing(cat); + RynthLog.SetTracing(cat, enable); + ChatLine($"[RynthAi] Trace {cat}: {(enable ? "ON" : "off")} → {RynthLog.TraceDirectory}"); + } + + /// "/ra logs [open|prune|flush|file on|off]". + private void HandleLogsCommand(string[] parts) + { + string sub = parts.Length > 2 ? parts[2].ToLowerInvariant() : "status"; + switch (sub) + { + case "open": + try + { + RynthLog.Flush(); + System.IO.Directory.CreateDirectory(RynthLog.Directory); + System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("explorer.exe", $"\"{RynthLog.Directory}\"") { UseShellExecute = true }); + } + catch (Exception ex) { RynthLog.Exception(LogCat.Commands, ex, "logs open"); ChatLine($"[RynthAi] Could not open {RynthLog.Directory}: {ex.Message}"); } + break; + case "prune": + ChatLine($"[RynthAi] Pruned {RynthLog.Prune()} old diagnostics file(s)."); + break; + case "flush": + RynthLog.Flush(); + ChatLine("[RynthAi] Diagnostics flushed to disk."); + break; + case "file": + bool? state = ParseOnOff(parts.Length > 3 ? parts[3] : null); + if (state.HasValue) RynthLog.FileLogAll = state.Value; + ChatLine($"[RynthAi] Daily RynthAi log file is {(RynthLog.FileLogAll ? "ON" : "off")}."); + break; + default: + foreach (string l in RynthLog.StatusLines()) ChatLine(l); + break; + } + } + + /// /ra navrec [on|off] — toggles route recording. + private void HandleNavRecordCommand(string[] parts) + { + if (_dashboard == null) return; + var s = _dashboard.Settings; + string arg = parts.Length > 2 ? parts[2].ToLowerInvariant() : ""; + s.IsRecordingNav = arg switch { "on" => true, "off" => false, _ => !s.IsRecordingNav }; + ChatLine($"[RynthAi] Nav recording {(s.IsRecordingNav ? "ON — walk the route; portals are captured" : "OFF")}."); + } + + /// /ra navhud [on|off] — shows or hides the navigation HUD window. + private void HandleNavHudCommand(string[] parts) + { + if (_dashboard == null) return; + var o = _dashboard.Settings.NavOverlay; + string arg = parts.Length > 2 ? parts[2].ToLowerInvariant() : ""; + o.ShowHud = arg switch { "on" => true, "off" => false, _ => !o.ShowHud }; + ChatLine($"[RynthAi] Nav HUD {(o.ShowHud ? "shown" : "hidden")}."); + } + + /// /ra navtrail [on|off|toggle|clear] — breadcrumb tracking switch, wipe, or a status report. + private void HandleNavTrailCommand(string[] parts) + { + string arg = parts.Length > 2 ? parts[2].ToLowerInvariant() : ""; + if (arg == "clear") + { + _navBreadcrumbs?.RequestClear(); + ChatLine("[RynthAi] Breadcrumb trail cleared."); + return; + } + if (arg is "on" or "off" or "toggle") + { + if (_dashboard == null) return; + var o = _dashboard.Settings.NavOverlay; + o.TrackBreadcrumbs = arg switch { "on" => true, "off" => false, _ => !o.TrackBreadcrumbs }; + _dashboard.SaveSettings(); + ChatLine($"[RynthAi] Breadcrumb tracking {(o.TrackBreadcrumbs ? "on" : "off")}."); + return; + } + bool tracking = _dashboard?.Settings.NavOverlay.TrackBreadcrumbs ?? false; + int n = _navBreadcrumbs?.Trail.Length ?? 0; + double yd = _navBreadcrumbs?.TrailYards ?? 0; + ChatLine($"[RynthAi] Breadcrumbs {(tracking ? "on" : "off")}: {n} points, {yd:F0} yd. Use /ra navtrail on|off|clear."); + } + + /// /ra navoverlay [on|off] — route overlay (rings / lines, waypoint labels, guide line); no argument toggles. + private void HandleNavOverlayCommand(string[] parts) + { + if (_dashboard == null) return; + var o = _dashboard.Settings.NavOverlay; + string arg = parts.Length > 2 ? parts[2].ToLowerInvariant() : ""; + o.ShowRouteMarkers = arg switch { "on" => true, "off" => false, _ => !o.ShowRouteMarkers }; + _dashboard.SaveSettings(); + ChatLine($"[RynthAi] Route overlay {(o.ShowRouteMarkers ? "on" : "off")}."); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.OwnCorpse.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.OwnCorpse.cs index 04aa4c4..123cd28 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.OwnCorpse.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.OwnCorpse.cs @@ -171,7 +171,7 @@ public sealed partial class RynthAiPlugin { if (items.Count == 0) { - if (openAge < Math.Max(200, settings.LootEmptyCorpseMs)) + if (openAge < Math.Max(200, settings.LootEmptyCorpseMs) || LastPickupSettling(now)) return; if (_ownRecoveryCorpseId != corpseId) BeginOwnCorpseRecovery(corpseId, 0); @@ -197,6 +197,8 @@ public sealed partial class RynthAiPlugin // Every item was tried. Let the last confirmed move leave the corpse's list first. if (_lastLootActionAt != 0 && now - _lastLootActionAt < OwnCorpseSettleMs) return; + if (LastPickupSettling(now)) + return; // the last pickup's Return still plays: close after it FinishOwnCorpseRecovery(corpseId, items); return; } @@ -206,11 +208,24 @@ public sealed partial class RynthAiPlugin if (_busyCount > 0 && _lastLootActionAt != 0 && now - _lastLootActionAt < OwnCorpseBusyWaitMs) return; + // Still animating: right after a pickup's answer that is its Return, and ACE queues one + // move that arrives then (see TickOpenCorpseLooting); anything else, wait. + bool pipelined = false; + if (PickupAnimating(now)) + { + if (!CanPipelinePickup(now)) + return; + pipelined = true; + _pipelinedAfterItemId = _settlingLootItemId; + } + string name = string.IsNullOrWhiteSpace(next.Name) ? $"0x{(uint)next.Id:X8}" : next.Name; _currentLootItemId = next.Id; Host.SelectItem(unchecked((uint)next.Id)); LootDiag($"[RynthAi] Own corpse: taking 0x{(uint)next.Id:X8} '{name}' ({remaining} left on 0x{(uint)corpseId:X8})."); + int errSeqAtSend = LastWeenieErrorSeq(); + bool stackable = IsStackAtSend(next.Id); LootPickupResult pickup = SendLootPickup(next.Id, name, corpseId); if (pickup == LootPickupResult.NoRoom || pickup == LootPickupResult.Refused) return; // SendLootPickup paused the corpse / left the item @@ -228,7 +243,10 @@ public sealed partial class RynthAiPlugin _currentLootItemMovePending = true; _currentLootItemMoveRequestedAt = now; - _currentLootItemMoveAttempts = 1; + _currentLootItemMoveAttempts = pipelined ? 0 : 1; + _currentLootItemPipelined = pipelined; + _currentLootItemStackable = stackable; + _currentLootItemErrSeqAtSend = errSeqAtSend; _currentLootItemActionLabel = "Recover"; _currentLootItemName = name; _currentLootItemIsSalvage = false; // never salvage your own things @@ -662,7 +680,7 @@ public sealed partial class RynthAiPlugin string line = $"[RynthAi] Own corpse: travel back ended: {why}."; if (sayInChat) OwnCorpseSay(line); else Log(line); // RynthAi's own nav carries on from the nearest waypoint, not one from before the death. - _navigationEngine?.ResumeFromNearestWaypoint(); + _navigationEngine?.ResumeFromNearestWaypoint(always: true); } private bool SendRynthNav(string command) diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Pacing.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Pacing.cs index fd7c8bf..a095161 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Pacing.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Pacing.cs @@ -13,6 +13,14 @@ namespace RynthCore.Plugin.RynthAi; // ============================================================================ public sealed partial class RynthAiPlugin { + /// + /// UseAudit.WorldUseHold: an automatic door or corpse use waits while the salvage panel is + /// between the Ust use and the salvage send. A world use in that window is swallowed by the + /// client, and the corpse loop then sat waiting for an open that never came. + /// + private string? SalvagePanelHold() => + _salvageManager?.PanelPending == true ? "the salvage panel is opening; the use waits for the salvage to go out" : null; + /// UseAudit.AfterSend: a use or use-on went out - record it as the action the server is answering. private static void RecordUseForPacing(RynthCoreHost host, UseAudit.SentUse use) { diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Safety.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Safety.cs index 80ed74d..a3c9a09 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Safety.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Safety.cs @@ -31,6 +31,7 @@ public sealed partial class RynthAiPlugin Log("[RynthAi] Death detected (health 0)."); try { RecordDeathSpot(); } // where the corpse will be (RynthAiPlugin.OwnCorpse.cs) catch (Exception ex) { Log($"[RynthAi] Death spot not recorded: {ex.Message}"); } + ArmDeathRecall(s); // before Stop Macro On Death: it reads whether the macro ran if (s.StopMacroOnDeath && s.IsMacroRunning) { HandleMacroRunCommand("stop", Array.Empty()); @@ -55,6 +56,16 @@ public sealed partial class RynthAiPlugin /// reloaded the world) came with the bot still casting and dequipping through /// the death. Reads the vitals every tick (the regular poll is every 30). /// + private bool _wasPortalingForPacer; + + /// Portal space starts: the server dropped what was open (no breaker on a teleport's gap). + private void NotePortalForPacer() + { + bool portaling = Host.HasIsPortaling && Host.IsPortaling(); + if (portaling && !_wasPortalingForPacer) RynthCore.Plugin.Shared.ActionPacer.Forget("portal space"); + _wasPortalingForPacer = portaling; + } + private bool HoldForDeath() { long now = Environment.TickCount64; @@ -82,12 +93,18 @@ public sealed partial class RynthAiPlugin Log("[RynthAi] Died — holding all actions until respawned and out of portal space."); _combatManager?.ReleaseHeldTurn(); _navigationEngine?.Stop(); + RynthCore.Plugin.Shared.ActionPacer.Forget("death"); // the server dropped whatever was open + _buffManager?.CancelPendingRecall("death"); // no /lifestone or macro restart after the respawn } else { Log("[RynthAi] Respawned — resuming."); - try { OnRespawnedForOwnCorpse(); } // Travel Back To My Corpse - catch (Exception ex) { Log($"[RynthAi] Own corpse travel not started: {ex.Message}"); } + try + { + // Recall On Death first; the corpse trip then starts from where it lands (EndDeathRecall). + if (!StartDeathRecall()) OnRespawnedForOwnCorpse(); // Travel Back To My Corpse + } + catch (Exception ex) { Log($"[RynthAi] Death recall / own corpse travel not started: {ex.Message}"); } } } return hold; diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Spells.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Spells.cs new file mode 100644 index 0000000..bce647a --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.Spells.cs @@ -0,0 +1,110 @@ +// RynthAiPlugin.Spells.cs - Spells window (/ra spells) and buff profile selection +// (/ra buffprofile, Loaded Files → Buffs). The window draws on the render thread; this file +// feeds it pump-thread data and applies the profile it picks on the pump thread. +using System; +using System.IO; +using System.Threading; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi; + +public sealed partial class RynthAiPlugin +{ + /// How often the open Spells window gets a fresh copy of the known-spell set. + private const long SpellsKnownPushMs = 2000; + + private LegacySpellsUi? _spellsUi; + private long _spellsKnownPushedAt; + + // Profile path picked in the Spells window ("" = built-in list), applied on the next pump tick. + private string? _pendingBuffProfilePath; + + /// Spells window, created once settings exist. + private void EnsureSpellsUi() + { + if (_dashboard == null || _spellsUi != null) return; + _spellsUi = new LegacySpellsUi(_dashboard.Settings); + _spellsUi.SetHooks( + path => Interlocked.Exchange(ref _pendingBuffProfilePath, path ?? string.Empty), + () => _dashboard?.RefreshBuffProfileFiles()); + } + + /// Pump thread: applies the window's profile choice and feeds the open window. + private void TickSpellsUi() + { + string? pending = Interlocked.Exchange(ref _pendingBuffProfilePath, null); + if (pending != null) _dashboard?.SetActiveBuffProfile(pending); + + var ui = _spellsUi; + if (ui == null || !ui.Visible) return; + + if (ui.TakeBuiltInRequest()) + { + if (_buffManager != null) ui.SetBuiltInList(_buffManager.BuildBuiltInBuffList()); + else ChatLine("[RynthAi] Buffing is not ready yet (log in first)."); + } + + long now = Environment.TickCount64; + if (_spellManager != null && now - _spellsKnownPushedAt >= SpellsKnownPushMs) + { + _spellsKnownPushedAt = now; + ui.SetKnownSpells(_spellManager.CopyKnownSpellIds()); + } + } + + /// /ra spells [show|hide|toggle] (also the dashboard's "spells" remote command). + private void HandleSpellsCommand(string mode) + { + var settings = _dashboard?.Settings; + if (settings == null) { ChatLine("[RynthAi] Settings not ready (log in first)."); return; } + EnsureSpellsUi(); + + settings.ShowSpellsWindow = mode.ToLowerInvariant() switch + { + "show" or "open" or "on" => true, + "hide" or "close" or "off" => false, + _ => !settings.ShowSpellsWindow, + }; + ChatLine($"[RynthAi] Spells window {(settings.ShowSpellsWindow ? "opened" : "closed")}."); + } + + /// + /// /ra buffprofile [list] | none | <name>: shows or picks the buff profile buffing uses + /// ("none" or "builtin" = the built-in list). + /// + private void HandleBuffProfileCommand(string[] parts) + { + var dash = _dashboard; + if (dash == null) { ChatLine("[RynthAi] Settings not ready (log in first)."); return; } + + string arg = parts.Length >= 3 ? string.Join(" ", parts, 2, parts.Length - 2).Trim() : string.Empty; + if (arg.Length == 0 || arg.Equals("list", StringComparison.OrdinalIgnoreCase)) + { + string current = dash.Settings.CurrentBuffProfilePath; + ChatLine("[RynthAi] Buff profile: " + (string.IsNullOrEmpty(current) + ? LegacyDashboardRenderer.BuiltInBuffProfileLabel + : Path.GetFileNameWithoutExtension(current))); + var files = BuffProfileStore.ListFileNames(); + ChatLine(files.Count == 0 + ? "[RynthAi] No saved buff profiles. Build one with /ra spells." + : "[RynthAi] Saved: " + string.Join(", ", files.ConvertAll(Path.GetFileNameWithoutExtension))); + return; + } + + if (arg.Equals("none", StringComparison.OrdinalIgnoreCase) + || arg.Equals("builtin", StringComparison.OrdinalIgnoreCase) + || arg.Equals(LegacyDashboardRenderer.BuiltInBuffProfileLabel, StringComparison.OrdinalIgnoreCase)) + { + dash.SetActiveBuffProfile(string.Empty); + return; // BuffManager posts the "built-in list" chat line + } + + foreach (string file in BuffProfileStore.ListFileNames()) + { + if (!Path.GetFileNameWithoutExtension(file).Equals(arg, StringComparison.OrdinalIgnoreCase)) continue; + dash.SetActiveBuffProfile(Path.Combine(BuffProfileStore.Folder, file)); + return; // BuffManager posts the "profile 'X'" chat line once it loads + } + ChatLine($"[RynthAi] No buff profile named '{arg}'. /ra buffprofile list shows them."); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.VTankHotkeys.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.VTankHotkeys.cs new file mode 100644 index 0000000..0efde81 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.VTankHotkeys.cs @@ -0,0 +1,295 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using RynthCore.Plugin.RynthAi.LegacyUi; + +namespace RynthCore.Plugin.RynthAi; + +// VTank's hotkey actions as /ra commands (2026-10-13), so RynthCore's hotkeys (Settings > Hotkeys, +// "VTank-style" group), "Chat command" hotkeys, RynthNet broadcasts and metas all reach them: +// +// /ra setmetastate Meta: switch the meta state (no state: list them) +// /ra targetlock [off] Target lock attack the selected monster (again / off: release) +// /ra meleelow|meleemid|meleehigh melee attack height +// /ra navaddpt NavAddPt waypoint at your position (same as /ra addnavpt) +// /ra testitem TestItem the selected item against the loot profile +// /ra propertydump [0xId] PropertyDump every property of the selection (/ra dumpprops) +// /ra recharge Recharge one vitals pass with the Top Off lines +// /ra navprio|lootprio|navlootprio [on|off] Boost Nav / Boost Loot Priority (no argument: toggle) +// /ra lootthis LootThisCont loot the open corpse or chest now +// +// Kept in this file with one call from DispatchRaCommand's default branch, so the command +// switch itself barely changes. +public sealed partial class RynthAiPlugin +{ + private static readonly string[] MeleeHeightNames = { "Low", "Medium", "High" }; + + /// The VTank-style /ra commands; false when isn't one of them. + private bool TryHandleVTankHotkeyCommand(string cmd, string[] parts) + { + switch (cmd) + { + case "vtkeys": VTankKeysHelp(); return true; + case "setmetastate": + case "metastate": HandleSetMetaStateCommand(parts); return true; + case "targetlock": HandleTargetLockCommand(parts); return true; + case "meleelow": SetMeleeAttackHeight(0); return true; + case "meleemid": + case "meleemedium": SetMeleeAttackHeight(1); return true; + case "meleehigh": SetMeleeAttackHeight(2); return true; + case "navaddpt": HandleAddNavPointCommand(); return true; + case "testitem": HandleLootCheckSelectedCommand(new[] { "/ra", "lootcheck" }); return true; + case "propertydump": HandleDumpPropsCommand(parts); return true; + case "recharge": HandleRechargeCommand(); return true; + case "navprio": HandlePriorityCommand(parts, nav: true, loot: false); return true; + case "lootprio": HandlePriorityCommand(parts, nav: false, loot: true); return true; + case "navlootprio": HandlePriorityCommand(parts, nav: true, loot: true); return true; + case "lootthis": + case "lootthiscont": RequestLootThisContainer(); return true; + default: return false; + } + } + + private void VTankKeysHelp() + { + ChatLine("[RynthAi] VTank-style commands (also hotkeys: Settings > Hotkeys, VTank-style):"); + ChatLine("[RynthAi] /ra setmetastate - switch the meta state (no state: list the loaded meta's states)"); + ChatLine("[RynthAi] /ra targetlock [off] - attack the selected monster first; the same one again, or off, releases it"); + ChatLine("[RynthAi] /ra meleelow | meleemid | meleehigh - melee attack height"); + ChatLine("[RynthAi] /ra navaddpt - add a waypoint at your position to the loaded route"); + ChatLine("[RynthAi] /ra testitem - check the selected item against the loot profile"); + ChatLine("[RynthAi] /ra propertydump [0xId] - every property of the selected object"); + ChatLine("[RynthAi] /ra recharge - one heal / stamina / mana top-off with the Top Off lines, macro on or off"); + ChatLine("[RynthAi] /ra navprio | lootprio | navlootprio [on|off] - Boost Nav / Boost Loot Priority (toggle)"); + ChatLine("[RynthAi] /ra lootthis - loot the open corpse or chest now (never house storage or your own packs)"); + } + + // ── Meta state ──────────────────────────────────────────────────────────── + + /// The loaded meta's states, in rule order. + internal List LoadedMetaStates() + { + var states = new List(); + var s = _dashboard?.Settings; + if (s == null) return states; + lock (s.MetaRulesLock) + { + foreach (var r in s.MetaRules) + if (!string.IsNullOrEmpty(r.State) && !states.Contains(r.State, StringComparer.OrdinalIgnoreCase)) + states.Add(r.State); + } + return states; + } + + private void HandleSetMetaStateCommand(string[] parts) + { + var s = _dashboard?.Settings; + if (s == null || _metaManager == null) { ChatLine("[RynthAi] Meta not ready (log in first)."); return; } + List states = LoadedMetaStates(); + if (parts.Length < 3) + { + ChatLine($"[RynthAi] Meta state: {s.CurrentState}. States: {(states.Count == 0 ? "(no meta loaded)" : string.Join(", ", states))}."); + ChatLine("[RynthAi] Usage: /ra setmetastate "); + return; + } + string want = string.Join(" ", parts, 2, parts.Length - 2); + // The loaded meta's spelling when only the case differs. + string? known = states.FirstOrDefault(x => x.Equals(want, StringComparison.OrdinalIgnoreCase)); + _metaManager.TryHandleVtCommand("/vt setmetastate " + (known ?? want)); + if (known == null && states.Count > 0) + ChatLine($"[RynthAi] Note: the loaded meta has no state '{want}' (states: {string.Join(", ", states)})."); + } + + // ── Target lock ─────────────────────────────────────────────────────────── + + private void HandleTargetLockCommand(string[] parts) + { + var cm = _combatManager; + if (cm == null) { ChatLine("[RynthAi] Combat not ready (log in first)."); return; } + string arg = parts.Length >= 3 ? parts[2].ToLowerInvariant() : ""; + int current = cm.ForcedTargetId; + if (arg is "off" or "clear" or "release" or "0") + { + cm.ClearForcedTarget(); + ChatLine(current == 0 ? "[RynthAi] Target lock: none set." : "[RynthAi] Target lock released."); + return; + } + + uint selected = Host.HasGetSelectedItemId ? Host.GetSelectedItemId() : _currentTargetId; + int id = unchecked((int)selected); + if (id != 0 && id == current) + { + cm.ClearForcedTarget(); + ChatLine($"[RynthAi] Target lock on {_objectCache?[id]?.Name ?? $"0x{selected:X8}"} released."); + return; + } + string? refusal = cm.ForcedTargetRefusal(id); + if (refusal != null) + { + ChatLine($"[RynthAi] Target lock: {refusal}."); + return; + } + cm.SetForcedTarget(id); + var s = _dashboard?.Settings; + string name = _objectCache?[id]?.Name ?? $"0x{selected:X8}"; + string note = s == null ? "" : !s.IsMacroRunning ? " (the macro is off: it attacks once started)" + : !s.EnableCombat ? " (Combat is off: it attacks once Combat is on)" : ""; + ChatLine($"[RynthAi] Target lock: attacking {name}{note}."); + } + + // ── Melee attack height ────────────────────────────────────────────────── + + private void SetMeleeAttackHeight(int height) + { + var dash = _dashboard; + if (dash?.Settings == null) { ChatLine("[RynthAi] Settings not ready."); return; } + dash.Settings.MeleeAttackHeight = Math.Clamp(height, 0, 2); + dash.SaveSettings(); + ChatLine($"[RynthAi] Melee attack height: {MeleeHeightNames[dash.Settings.MeleeAttackHeight]}."); + } + + // ── Boost Nav / Loot Priority ───────────────────────────────────────────── + + /// + /// The new (nav, loot) boosts for a toggle or "on"/"off". NavLootPrio (both) toggles them + /// together: on unless both are on already. + /// + internal static (bool Nav, bool Loot) NextPriority(bool navNow, bool lootNow, bool nav, bool loot, string arg) + { + bool? set = arg switch + { + "on" or "1" or "true" => true, + "off" or "0" or "false" => false, + _ => null, + }; + bool target = set ?? !((!nav || navNow) && (!loot || lootNow)); + return (nav ? target : navNow, loot ? target : lootNow); + } + + private void HandlePriorityCommand(string[] parts, bool nav, bool loot) + { + var dash = _dashboard; + var s = dash?.Settings; + if (s == null) { ChatLine("[RynthAi] Settings not ready."); return; } + string arg = parts.Length >= 3 ? parts[2].ToLowerInvariant() : ""; + (s.BoostNavPriority, s.BoostLootPriority) = NextPriority(s.BoostNavPriority, s.BoostLootPriority, nav, loot, arg); + dash!.SaveSettings(); + string On(bool b) => b ? "on" : "off"; + ChatLine(nav && loot ? $"[RynthAi] Boost Nav Priority {On(s.BoostNavPriority)}, Boost Loot Priority {On(s.BoostLootPriority)}." + : nav ? $"[RynthAi] Boost Nav Priority {On(s.BoostNavPriority)}." + : $"[RynthAi] Boost Loot Priority {On(s.BoostLootPriority)}."); + } + + // ── Recharge ────────────────────────────────────────────────────────────── + + private void HandleRechargeCommand() + { + if (_buffManager == null) { ChatLine("[RynthAi] Buff manager not ready (log in first)."); return; } + _buffManager.RequestRecharge(); // runs on the pump's next heartbeat, says what it did + } + + // ── LootThisCont ────────────────────────────────────────────────────────── + + private int _lootThisRequested; // set by /ra lootthis (AC's thread), taken on the pump + private int _forcedLootContainerId; // pump thread: the container /ra lootthis flagged + + private void RequestLootThisContainer() => Interlocked.Exchange(ref _lootThisRequested, 1); + + /// + /// The flagged container is still the one being looted: the loot tick runs for it even with + /// the macro off, Looting off or Boost Nav Priority on. Clears the flag once it isn't. + /// + private bool ForcedLootHolds() + { + int id = _forcedLootContainerId; + if (id == 0) return false; + if (_openedContainerId == id || _targetCorpseId == id) return true; + _forcedLootContainerId = 0; + return false; + } + + /// Why the open container is never looted by /ra lootthis, or null. + internal string? LootThisRefusal(int id) + { + if (id == 0) return "no container is open (open a corpse or chest first)"; + uint uid = unchecked((uint)id); + if (uid == _playerId) return "that's your own pack"; + if (Host.HasGetObjectOwnershipInfo && Host.TryGetObjectOwnershipInfo(uid, out uint container, out uint wielder, out _)) + { + if (container == _playerId || wielder == _playerId) return "it's in your inventory"; + if (container != 0 && Host.TryGetObjectOwnershipInfo(container, out uint outer, out _, out _) && outer == _playerId) + return "it's in your inventory"; + } + if (InPlayerInventory(_objectCache?.GetContainerId(id) ?? 0)) return "it's in your inventory"; + if (Host.HasGetObjectBitfield && Host.TryGetObjectBitfield(uid, out uint bf)) + { + if ((bf & ChestBfVendor) != 0) return "it's a vendor"; + if ((bf & ChestBfPlayer) != 0) return "it's a player"; + } + if (Host.HasGetObjectInstanceIdProperty + && Host.TryGetObjectInstanceIdProperty(uid, ChestIidHouseOwner, out uint houseOwner) && houseOwner != 0) + return "house storage is never looted"; + string name = _objectCache?[id]?.Name ?? string.Empty; + if (string.IsNullOrWhiteSpace(name) && Host.TryGetObjectName(uid, out string hostName)) name = hostName; + if (IsHouseStorageName(name)) return "house storage is never looted"; + return null; + } + + /// TickCorpseOpening, every tick: a /ra lootthis request makes the open container the loot container. + private void TakeLootThisRequest(LegacyUiSettings settings) + { + if (Interlocked.Exchange(ref _lootThisRequested, 0) == 0) return; + int id = Host.HasGetGroundContainerId ? unchecked((int)Host.GetGroundContainerId()) : 0; + if (id == 0) id = _openedContainerId != 0 ? _openedContainerId : _chestCandidateId; + + string? refusal = LootThisRefusal(id); + string name = id != 0 ? _objectCache?[id]?.Name ?? $"0x{(uint)id:X8}" : ""; + if (refusal != null) + { + ChatLine($"[RynthAi] LootThisCont: {refusal}."); + return; + } + + bool already = _openedContainerId == id; + _forcedLootContainerId = id; + if (!already) + { + long now = CorpseNowMs; + if (_targetCorpseId != 0 && _targetCorpseId != id) ResetCorpseTarget(); + if (IsCorpseLikeObject(id)) + { + // A corpse finished before (or skipped) loots again: the flag overrides the marks. + _completedCorpses.Remove(id); + _corpseCooldownUntil.Remove(id); + if (_lootChestId != 0 && _lootChestId != id) _lootChestId = 0; + _openedContainerId = id; + _openedContainerAt = now; + _openedContainerInventoryObservedAt = 0; + _lastLootActionAt = 0; + _corpseItemsEvaluated = 0; + _corpseItemsMatched = 0; + _corpseIdsRequested = false; + ResetCurrentLootItem(); + _processedCorpseItems.Clear(); + _corpseItemAttempts.Clear(); + _pendingManaStoneIds.Clear(); _pendingManaTapIds.Clear(); _pendingKeepUpTo.Clear(); + _targetCorpseId = id; + _corpseTargetSince = now; + _lastCorpseOpenAttemptAt = 0; + } + else + { + if (_chestCandidateId != id) { _chestCandidateSince = now; _chestCandidateInvSeenAt = 0; } + TakeChestAsLootContainer(id, now); + } + PauseNavigationForCorpse(); + StopCorpseMovement(); + } + string note = !settings.IsMacroRunning ? " (the macro is off: this container only)" + : !settings.EnableLooting ? " (Looting is off: this container only)" + : settings.BoostNavPriority ? " (Boost Nav Priority is on: this container only)" : ""; + LootDiag($"[RynthAi] LootThisCont: 0x{(uint)id:X8} '{name}' flagged{(already ? " (already open as the loot container)" : "")}."); + ChatLine($"[RynthAi] LootThisCont: looting {name}{note}."); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs index dba556c..90deb60 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs @@ -120,6 +120,9 @@ public sealed partial class RynthAiPlugin : RynthPluginBase private bool _dunPatrolActive; private uint _dunPatrolLandblock; private int _dunPatrolHazardVersion; + // The patrol settings (Settings > Navigation > Dungeon Patrol) the running patrol was built + // with: a change rebuilds it once the settings settle (TickDunPatrolHazardReroute). + private readonly PatrolSettingsWatch _dunPatrolSettings = new(); private DateTime _notInWorldSince = DateTime.MinValue; private int _tickDiag; private int _currentCombatMode = 1; // 1=noncombat @@ -170,6 +173,11 @@ public sealed partial class RynthAiPlugin : RynthPluginBase // constructor does no ImGui work. (RynthAi no longer exports RynthPluginRender // and never reads Host.ImGuiContext.) ComponentDatabase.SetLog(msg => Log(msg)); + InitLocalDiagnostics(); + StartDataFolderCheck(); // RynthAiPlugin.DataFolders.cs: can metas/navs/settings be saved? + InitSessionStats(); + // The overlay windows (OnRenderOverlay) must draw through the engine's cimgui module. + ImGuiNativeBinding.Ensure(); _dashboard = new LegacyDashboardRenderer(Host); _killClock.MacroRunning = () => _dashboard?.Settings.IsMacroRunning == true; _dashboard.KillClock = _killClock; @@ -185,7 +193,10 @@ public sealed partial class RynthAiPlugin : RynthPluginBase // use-on, cast and combat-mode change waits for the server's answer to the last one. RynthCore.Plugin.Shared.ActionPacer.Reset(); RynthCore.Plugin.Shared.ActionPacer.Enabled = true; + var hookHost = Host; + CombatHook.LastUseDone = () => hookHost.HasUseDoneSeq && hookHost.TryGetLastUseDone(out int s, out uint e) ? (s, e) : null; RynthCore.Plugin.Shared.UseAudit.AfterSend = RecordUseForPacing; + RynthCore.Plugin.Shared.UseAudit.WorldUseHold = SalvagePanelHold; _objectCache = new WorldObjectCache(Host); // must exist before CreateObject events fire during login // Items we use (or use something on) get re-identified before a meta reads them. // ObjectUsed is a static event and Shutdown never unsubscribes: when the engine @@ -217,6 +228,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase { long t0 = Environment.TickCount64; try { _dashboard?.SaveSettings(); } catch { } + try { _sessionStats?.Shutdown(); } catch { } // Release the Monster Editor process handle (if the toggle button // launched one) rather than leaking it on plugin unload/hot-reload. try { _dashboard?.ReleaseMonsterEditorHandle(); } catch { } @@ -234,6 +246,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase // Don't let the static audit hold this instance once it's gone (a reused module). RynthCore.Plugin.Shared.UseAudit.MacroOn = static () => false; RynthCore.Plugin.Shared.UseAudit.AfterSend = null; + RynthCore.Plugin.Shared.UseAudit.WorldUseHold = null; RynthCore.Plugin.Shared.ActionPacer.Enabled = false; RynthCore.Plugin.Shared.ActionPacer.Forget("shutdown"); @@ -251,6 +264,10 @@ public sealed partial class RynthAiPlugin : RynthPluginBase } catch { } long tAfterGc = Environment.TickCount64; + try { _translator?.Dispose(); } catch { } + _translator = null; + _translateUi = null; + try { RynthLog.Shutdown(); } catch { } Log($"RynthAi: Shutdown done — SaveSettings={tAfterSettings - t0} ms, TeardownSession={tAfterTeardown - tAfterSettings} ms, SaveCreatureStore={tAfterStore - tAfterTeardown} ms, GC={tAfterGc - tGc} ms (heap now {GC.GetGCMemoryInfo().HeapSizeBytes / (1024 * 1024)} MB), total={tAfterGc - t0} ms"); } @@ -264,6 +281,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase { Log("RynthAi: logout — tearing down session."); try { _dashboard?.SaveSettings(); } catch { } + try { _sessionStats?.OnLogout(); } catch (Exception ex) { RynthLog.Exception(LogCat.IltRates, ex, "session stats logout"); } Loot.T11ItemSupport.Reset(); // A real logout: the next OnLoginComplete is a fresh login, not a hot reload. ClearInGameMarker(); @@ -414,6 +432,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase _autoVendor = null; _autoTrade?.Reset(); _autoTrade = null; + TeardownLocalFeatures(disposeTranslator: false); _playerId = 0; _loginComplete = false; _pendingGives.Clear(); @@ -479,6 +498,9 @@ public sealed partial class RynthAiPlugin : RynthPluginBase _killClock.SessionStarted(); _dashboard.OnLoginComplete(); _dashboard.ChatSubmitHandler = HandleRynthChatSubmit; + EnsureTranslator(); + EnsureItemInfoUi(); + EnsureSpellsUi(); _navigationEngine = new NavigationEngine(Host, _dashboard.Settings) { ChatSubmit = HandleRynthChatSubmit, @@ -495,6 +517,9 @@ public sealed partial class RynthAiPlugin : RynthPluginBase // Route recovery detours: open closed doors on the way back to the route. FindClosedDoorOnLeg = FindClosedDoorOnLeg, RequestDoorOpen = RequestDoorOpen, + // The dungeon patrol keeps its order after a fight (Go To Closest Waypoint is for + // routes; on a patrol loop the closest point can be near the end). + KeepWaypointAfterPause = () => _dunPatrolActive, }; // Plans the detours: the dungeon cell graph indoors, RynthNav's navmesh outdoors. // Reads the raycast geometry and hazards through the fields, so it follows their @@ -505,6 +530,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase { GeometrySource = () => _raycast is { IsInitialized: true } rc ? rc.GeometryLoader : null, }; + CreateNavOverlay(); _radarWallRenderer = new RadarWallRenderer(Host, _dashboard.Settings); _terrainOverlay = new TerrainPassabilityOverlay(Host); Log($"RynthAi: NavMarkerRenderer created, HasNav3D={Host.HasNav3D}, version={Host.Version}"); @@ -563,6 +589,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase // Cache player ID so we can filter self out of creature tracking and update vitals _playerId = Host.GetPlayerId(); + try { _sessionStats?.OnLoginComplete(); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltRates, ex, "session stats login"); } _objectCache?.SetPlayerId(_playerId); _navigationEngine?.SetPlayerId(_playerId); if (_objectCache != null) _dashboard.SetWorldFilter(_objectCache); @@ -597,6 +625,15 @@ public sealed partial class RynthAiPlugin : RynthPluginBase _weaponSwapGate.IsWielded = id => RynthCore.Plugin.Shared.ActionPacer.IsWieldedByPlayer(Host, unchecked((uint)id)); _buffManager = new BuffManager(Host, _dashboard.Settings, _spellManager, _vitals); + // The HP failsafe's recall stops the macro as /ra stop does (the macro-stop edge in OnTick + // then cancels the attack and stops movement): a move during the recall cancels it. + _buffManager.MacroStopForRecall = () => + { + _macroResumeAt = 0; + _navigationEngine?.Stop(); + }; + // The failsafe switching the macro back on after a failed recall is a start like any other. + _buffManager.MayRestartMacro = () => !RefuseMacroStartForVTank(); _inGameMarkerSet = false; if (IsCarriedOverSession(_playerId)) { @@ -621,6 +658,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase // fires on the render thread and the exports on their caller's thread. _dashboard.OnForceRebuffRequested = () => _buffManager?.RequestForceFullRebuff(); _dashboard.OnCancelForceRebuffRequested = () => _buffManager?.RequestCancelBuffing(); + _dashboard.SetBuffActions(() => _buffManager?.RequestForceFullRebuff(), () => _buffManager?.RequestCancelBuffing(), + () => _buffManager?.FilterSkipSummary() ?? ""); // Override disk timers with live client memory — gets accurate remaining times // including login-restored enchantments the event hook missed at startup. @@ -635,8 +674,10 @@ public sealed partial class RynthAiPlugin : RynthPluginBase _combatManager = new CombatManager(Host, _dashboard.Settings, _objectCache!, _spellManager); _combatManager.SetWeaponSwapGate(_weaponSwapGate); + _combatManager.Vitals = _vitals; // the script hook's request carries the player's vitals _combatManager.HoldIdlePeace = LootHoldsIdlePeace; _combatManager.ManaReserveHold = spellId => _buffManager?.OffensiveCastHold(spellId); // the mana reserve + _combatManager.ManaCanEverAfford = spellId => _buffManager?.CanEverAfford(spellId) ?? true; // script hook: never-payable spells _combatManager.SetStaleBusyCallback(OnCombatBusyStale); _buffManager?.SetStaleBusyCallback(OnCombatBusyStale); // a heal ahead of a leftover busy count if (_buffManager != null) @@ -644,6 +685,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase _combatManager.SetCharacterSkills(_charSkills); _combatManager.SetPlayerId(_playerId); _combatManager.SetDamageStores(_creatureStore, _damageStore); + _combatManager.MobSeedLookup = LookupMobSeed; _combatManager.SetAwakenedTier(_tier); // The raycast init thread may already have finished (warm dats): hand it over now. WireRaycastIntoCombat(); @@ -690,6 +732,16 @@ public sealed partial class RynthAiPlugin : RynthPluginBase _combatManager.SummonOut = () => _petManager?.CurrentSummon(); } + CreateIltHub(); + if (_iltHub?.SkipLoginQuestRefresh == true) + Log("RynthAi: ILT Hub says /myquests is off on this server; login quest refresh already ran."); + try + { + string hubChar = CurrentCharacterName(); + _iltHub?.OnLoginComplete(hubChar, _petManager); + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "login"); } + _salvageManager = new SalvageManager(Host, _dashboard.Settings, _objectCache); // Hand the salvage manager a live accessor for the loot profile's // SalvageCombine config so combining respects per-material workmanship @@ -833,6 +885,12 @@ public sealed partial class RynthAiPlugin : RynthPluginBase /// the busy watchdog makes from this thread). Idempotent set-semantics for toggles. private void ApplyRemoteCommand(string action, string value) { + // RynthCore's server sections for the Mini Remote menu: needs no settings, kept across logins. + if (action.Equals("servermenu", StringComparison.OrdinalIgnoreCase)) + { + Huds.ServerMenuModel.Apply(value); + return; + } var dash = _dashboard; if (dash == null) return; bool on = value is "1" or "true" or "on" or "True" or "TRUE" @@ -853,21 +911,75 @@ public sealed partial class RynthAiPlugin : RynthPluginBase case "lootprofile": if (int.TryParse(value, out int li)) dash.SelectProfileAtIndex(1, li); break; case "metaprofile": if (int.TryParse(value, out int mi)) dash.SelectProfileAtIndex(2, mi); break; case "settingsprofile": if (int.TryParse(value, out int si)) dash.SelectProfileAtIndex(3, si); break; + case "buffprofile": if (int.TryParse(value, out int bi)) dash.SelectProfileAtIndex(4, bi); break; + case "spells": HandleSpellsCommand(value); break; // dashboard Spells button: toggle|show|hide case "forcerebuff": dash.RequestForceRebuff(); break; case "cancelrebuff": dash.RequestCancelForceRebuff(); break; case "clearbusy": HandleClearBusyCommand(); break; case "hideui": _hideUi = on; dash.SetUiHidden(on); break; // applied each tick in OnTick case "sendchat": if (!string.IsNullOrEmpty(value)) HandleRynthChatSubmit(value); break; case "setsetting": ApplyRemoteSetting(value); break; // one advanced setting from the phone (clamped + persisted) + case "hub": + case "quests": + case "pets": + case "guardian": + case "bounty": + case "bounties": + case "bountys": + // Dashboard Char launcher and its right-click menu (hub=tab
switches the + // Mini Remote's tab); value carries the "/ra hub|quests|pets|bounty" arguments. + if (_iltHub == null) { ChatLine("[RynthAi] ILT features not ready (log in first)."); break; } + _iltHub.HandleCommand(action.ToLowerInvariant(), value.Split(' ', StringSplitOptions.RemoveEmptyEntries)); + break; + case "huds": + case "itemhud": + case "remote": + case "miniremote": + // Dashboard Hub launcher: left-click remote=toggle, right-click huds=show. + HandleHudCommand(action.ToLowerInvariant(), value); + break; + case "itemhudadd": + // Inventory panel "Add to item count HUD"; value is the item name. + HandleItemHudAdd(value); + break; + case "remoteslot": + // Inventory panel "Add to Mini Remote"; value is " ". + if (_huds == null) { ChatLine("[RynthAi] HUDs not ready (log in first)."); break; } + if (!_huds.HandleRemoteSlot(value)) Host.Log($"[RynthAi] bad remoteslot value: {value}"); + break; + case "prog": + // Skills panel Progression tab (augmentations / enlightenment edits). + HandleProgressionRemote(value); + break; + case "trace": + case "logs": + case "iteminfo": + // Settings panel buttons (Diagnostics tab, Item Info options); value carries the + // same arguments as "/ra trace|logs|iteminfo ...". + { + var args = new List { "/ra", action.ToLowerInvariant() }; + args.AddRange(value.Split(' ', StringSplitOptions.RemoveEmptyEntries)); + string[] parts = args.ToArray(); + switch (parts[1]) + { + case "trace": HandleTraceCommand(parts); break; + case "logs": HandleLogsCommand(parts); break; + case "iteminfo": HandleItemInfoCommand(parts); break; + } + } + break; // movestart/movestop are applied DIRECTLY by the RynthRemote plugin (pure Host.SetAutoRun/ // SetMotion + its own dead-man watchdog) and are never forwarded here. + default: + Host.Log($"[RynthAi] ignored unknown remote command: {action}={value}"); + return; } Host.Log($"[RynthAi] applied remote command: {action}={value}"); } // Settings the phone must never write (engine-populated read-only status). private static readonly HashSet ReadOnlySettingKeys = new(StringComparer.OrdinalIgnoreCase) - { "MissileCraftingState", "MissileCraftingActive", "MissileCraftingStatus" }; + { "MissileCraftingState", "MissileCraftingActive", "MissileCraftingStatus", "DiagFolder" }; // Authoritative server-side clamp (min,max) per numeric setting — a bad/garbage phone value can never // push a setting out of range and brick a client. Ranges mirror the in-AC SettingsPanel rows. Booleans @@ -885,7 +997,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase ["MeleeAttackPower"] = (-1, 100), ["MissileAttackPower"] = (-1, 100), ["MeleeAttackHeight"] = (0, 2), ["MissileAttackHeight"] = (0, 2), ["PetMinMonsters"] = (1, 20), - ["SpellCastIntervalMs"] = (100, 1500), ["AttackSpellIntervalMs"] = (0, 5000), ["MinRingTargets"] = (1, 20), ["MinBlastTargets"] = (1, 20), ["BlastRange"] = (0, 100), ["MinWallTargets"] = (1, 20), ["WallRange"] = (0, 100), + ["SpellCastIntervalMs"] = (100, 1500), ["StuckCastBreakMs"] = (0, 60000), ["RecoveryRetryMs"] = (200, 5000), ["AttackSpellIntervalMs"] = (0, 5000), ["MinRingTargets"] = (1, 20), ["MinBlastTargets"] = (1, 20), ["BlastRange"] = (0, 100), ["MinWallTargets"] = (1, 20), ["WallRange"] = (0, 100), ["MinSkillLevelTier1"] = (1, 500), ["MinSkillLevelTier2"] = (1, 500), ["MinSkillLevelTier3"] = (1, 500), ["MinSkillLevelTier4"] = (1, 500), ["MinSkillLevelTier5"] = (1, 500), ["MinSkillLevelTier6"] = (1, 500), ["MinSkillLevelTier7"] = (1, 500), ["MinSkillLevelTier8"] = (1, 500), ["MonsterRange"] = (1, 200), ["MonsterDisengageRange"] = (0, 200), ["TargetSelection"] = (0, 3), ["RingRange"] = (1, 50), ["ApproachRange"] = (1, 50), @@ -895,6 +1007,9 @@ public sealed partial class RynthAiPlugin : RynthPluginBase ["NavStopTurnAngle"] = (1, 90), ["NavResumeTurnAngle"] = (1, 45), ["NavDeadZone"] = (0.5, 20), ["NavSweepMult"] = (0.5, 10), ["NavLookaheadYards"] = (0, 30), ["NavShortcutYards"] = (0, 10), ["NavTurnRateDegPerSec"] = (30, 720), ["NavTier1TurnSpeed"] = (0.5, 15), ["PostPortalDelaySec"] = (0, 30), ["NavOffTrackYards"] = (160, 1000), ["NavMaxDetourAttempts"] = (1, 10), + ["DunPatrolCoverage"] = (0, 2), ["DunPatrolSkipDeadEnds"] = (DungeonPatrolOptions.MaxDeadEndCellsMin, DungeonPatrolOptions.MaxDeadEndCellsMax), + ["DunPatrolWallDistance"] = (DungeonPatrolOptions.WallClearanceMin, DungeonPatrolOptions.WallClearanceMax), + ["DunPatrolLookInSize"] = (DungeonPatrolOptions.LookInRoomMin, DungeonPatrolOptions.LookInRoomMax), ["T2Speed"] = (0.1, 5), ["T2WalkWithinYd"] = (1, 50), ["T2DistanceTo"] = (0.1, 10), ["T2ReissueMs"] = (100, 10000), ["T2MaxRangeYd"] = (50, 2000), ["T2MaxLandblocks"] = (1, 20), ["RebuffSecondsRemaining"] = (30, 1800), ["RebuffTopOffSecondsRemaining"] = (30, 3600), @@ -1246,6 +1361,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase try { _dashboard?.DrainMetaCommands(); // apply queued meta edits on this (plugin-tick) thread + if (_loginComplete) PostDataWriteProblems(); // a save that failed / folder not writable: say so in chat + CombatHook.ObserveUseDone(); // ctx.last.err: the answer to the hook's last cast TickDelayedCommands(); // /ub delay if (_loginComplete) _dashboard?.TickPackSetup(_objectCache, _playerId); // new/copied profile items @@ -1381,6 +1498,12 @@ public sealed partial class RynthAiPlugin : RynthPluginBase _buffManager?.SetTimerPath(_dashboard.CharFolder); _damageStore?.SetCharacter(_dashboard.CharFolder); _patrolOnLoginPending = _dashboard.Settings.PatrolOnLogin; + if (_iltHub == null) + { + CreateIltHub(); + try { _iltHub?.OnLoginComplete(lateName, _petManager); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "late login"); } + } Log($"RynthAi: per-character settings established late for '{lateName}' (early OnLoginComplete read had failed)."); } } @@ -1410,10 +1533,10 @@ public sealed partial class RynthAiPlugin : RynthPluginBase // A nav saved into NavProfiles from outside (RynthNav's "save as nav route"): list it. _dashboard?.TickNavFolder(); _questTracker?.Tick(); + TickLocalFeatures(); if (diag) Host.Log("[RynthAi] OnTick: after quest tracker"); DrainGiveQueue(); if (diag) Host.Log("[RynthAi] OnTick: after drain give queue"); - if (_loginComplete) TickItemInfo(); Loot.T11ItemSupport.SyncOverride(_dashboard?.Settings.T11ItemAugsOverride ?? -1); _jumper?.Tick(); if (diag) Host.Log("[RynthAi] OnTick: after jumper tick"); @@ -1486,8 +1609,16 @@ public sealed partial class RynthAiPlugin : RynthPluginBase if (_dashboard?.Settings is { } safetySettings) CheckPlayerDeath(safetySettings); // Dead or on the way back from a death: do nothing (HoldForDeath). The // finally below still submits the nav markers. + RynthCore.Plugin.Shared.ActionPacer.NoteFrame(); + // Stuck Cast Break, once per tick: the breaker runs for every subsystem's casts. + if (_dashboard?.Settings is { } paceSettings) + RynthCore.Plugin.Shared.ActionPacer.StuckCastMs = Math.Max(0, paceSettings.StuckCastBreakMs); + NotePortalForPacer(); if (HoldForDeath()) return; + // Recall On Death in progress: nothing else until it lands or gives up. + if (TickDeathRecall()) + return; // Standing in acid or lava: nothing but getting out (RynthAiPlugin.HazardEscape.cs). RecordHazardTrail(); if (HoldForHazardEscape()) @@ -1541,6 +1672,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase } // Macro switched on: carry on from the nearest waypoint, not the one it // was heading to when stopped (after a recall that can be far away). + // NavResumeNearest off keeps the last waypoint. if (!_macroWasRunning && settings.IsMacroRunning) _navigationEngine?.ResumeFromNearestWaypoint(); _macroWasRunning = settings.IsMacroRunning; @@ -1554,7 +1686,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase // Reroute the active dungeon patrol around any lava/acid hotspot sighted // since the route was built — treats the hotspot as a wall instead of - // looping through it. Cheap no-op unless a new hazard cell was registered. + // looping through it — or with the Dungeon Patrol settings changed since. + // Cheap no-op unless a new hazard cell was registered or a setting changed. TickDunPatrolHazardReroute(); // ── Activity arbiter — STEP 5: AUTHORITATIVE, full stop ── @@ -1985,7 +2118,10 @@ public sealed partial class RynthAiPlugin : RynthPluginBase // this fires even when an early return short-circuits the body // (Buffing / missile-crafting / BoostNavPriority branches). if (Host.HasNav3D) + { _navMarkerRenderer?.SubmitNav3D(); + _navOverlay?.SubmitNav3D(); + } } } } @@ -2006,32 +2142,91 @@ public sealed partial class RynthAiPlugin : RynthPluginBase private bool _lootInspectMode = true; // always on; /ra lootcheck off to disable + /// Lets PluginExports log through this plugin's host (the base Log is protected). + internal void LogFromExport(string message) => Log(message); + public override void OnSelectedTargetChange(uint currentTargetId, uint previousTargetId) { _currentTargetId = currentTargetId; _dashboard?.SetSelectedTarget(currentTargetId); - // Appraise the target so the server sends back its vitals (including MaxHealth). - // Follow up with QueryHealth to resolve the ratio → absolute HP values. - if (currentTargetId != 0) - { - if (Host.HasRequestId) Host.RequestId(currentTargetId); - if (Host.HasQueryHealth) Host.QueryHealth(currentTargetId); - } - if (currentTargetId != 0) { int sid = unchecked((int)currentTargetId); WorldObject? obj = _objectCache?[sid]; - // Item info on select replaces the loot verdict line: one line per pick, not two - // (as SilentKelpie's fork does, rynth/RynthSuite PR #3). /ra lootcheck still prints it. - bool itemInfo = QueueItemInfoOnSelect(currentTargetId, obj); + + // Vitals (incl. MaxHealth) only matter for a creature. The engine selects every corpse + // it opens and every item it moves, and AutoId already appraises the selection, so an + // unguarded appraisal + health query here sent 4-6 identifies per corpse. + RequestTargetVitals(currentTargetId, obj); + // Skip non-items (monsters, players, NPCs, doors, corpses, portals, etc.) - if (!itemInfo && _lootInspectMode && obj != null && IsLootableClass(obj.ObjectClass)) - InspectLootRuleForItem(sid, quiet: true); + if (obj != null && IsLootableClass(obj.ObjectClass)) + { + var itemInfo = _dashboard?.Settings.ItemInfoSettings; + // RynthAi's own picks (the looter, a meta's selectitem) are not described. + bool infoWanted = itemInfo != null && ItemInfoWantsClass(itemInfo, obj.ObjectClass) + && !ItemInfo.SelfSelect.IsOurs(currentTargetId); + // Item info (on select or on click) is the answer for this item; the loot + // verdict line would print in its place. /ra lootcheck still prints it on demand. + bool infoHandles = infoWanted && (itemInfo!.OnSelect || itemInfo.ClickTrigger != ItemInfo.MagItemInfoSettings.ClickOff); + if (_lootInspectMode && !infoHandles) + InspectLootRuleForItem(sid, quiet: true); + if (infoWanted && itemInfo!.OnSelect) + { + ItemInfoLog($"select 0x{currentTargetId:X8} '{obj.Name}': on-select queue"); + QueueAutoItemInfo(sid, requestId: false); + } + } } } + /// + /// Selection of a creature: ask for its appraisal only when the client has none cached, then + /// a health query (resolves the ratio to absolute HP). Corpses, items and other non-creatures + /// get neither. The dashboard no longer queries health on its own. + /// + private void RequestTargetVitals(uint id, WorldObject? obj) + { + if (!IsCreatureTarget(id, obj)) return; + if (Host.HasRequestId && !HasCachedAppraisal(id)) Host.RequestId(id); + if (Host.HasQueryHealth) Host.QueryHealth(id); + } + + private static bool IsCreatureClass(AcObjectClass cls) => + cls is AcObjectClass.Monster or AcObjectClass.Player or AcObjectClass.Npc or AcObjectClass.CombatPet; + + private const uint ItemTypeCreatureFlag = 0x10; + + /// + /// Is the selection a creature worth an identify and a health query? A cached class other than + /// Unknown decides. Otherwise (not cached, or cached as Unknown while the item type is still + /// unread, up to ~30 s after login) the name, the engine's type flags and ObjectIsAttackable + /// decide, and a target nothing can classify fails OPEN: a missed health query costs more + /// than one extra identify. + /// + private bool IsCreatureTarget(uint id, WorldObject? obj) + { + if (obj != null && obj.ObjectClass != AcObjectClass.Unknown) + return IsCreatureClass(obj.ObjectClass); + + // Corpses keep the creature flag, so reject them by name before the flag is read. + string name = obj?.Name ?? ""; + if (name.Length == 0) Host.TryGetObjectName(id, out name); + if (name != null && name.StartsWith("Corpse of", StringComparison.Ordinal)) return false; + + if (Host.HasGetItemType && Host.TryGetItemType(id, out uint flags)) + return (flags & ItemTypeCreatureFlag) != 0; // typed: a creature, else an item, door or portal + if (Host.HasObjectIsAttackable) return Host.ObjectIsAttackable(id); + return true; // nothing to go on: fail open + } + + private bool HasCachedAppraisal(uint id) + { + if (Host.HasHasAppraisalData && Host.HasAppraisalData(id)) return true; + return Host.HasGetLastIdTime && Host.GetLastIdTime(id) > 0; + } + private static bool IsLootableClass(AcObjectClass cls) => cls is not ( AcObjectClass.Unknown or AcObjectClass.Monster or AcObjectClass.Player or AcObjectClass.Vendor or AcObjectClass.Door or AcObjectClass.Corpse or @@ -2048,14 +2243,17 @@ public sealed partial class RynthAiPlugin : RynthPluginBase public override void OnChatWindowText(string? text, int chatType, ref int eat) { if (string.IsNullOrEmpty(text)) return; + try { _sessionStats?.OnChatWindowText(text); } catch (Exception ex) { RynthLog.Exception(LogCat.IltRates, ex, "session stats chat"); } // The Meta Manager eats the reply to its own /myquests poll (only that). bool mmEat = false; try { mmEat = MetaScheduleChat(text); } catch { } if (mmEat) eat = 1; else _dashboard?.PushChatLine(text, chatType); + OnChatLocalFeatures(text, chatType, ref eat); try { NoteHotspotChat(text, chatType); } catch (Exception ex) { Host.Log($"[RynthAi] Hazard chat check failed: {ex.Message}"); } _buffManager?.OnChatWindowText(text, chatType); _manaStoneManager?.OnChatWindowText(text); + _salvageManager?.OnChatWindowText(text); _petManager?.OnChatWindowText(text); _combatManager?.TraceCastChat(text, chatType); _combatManager?.HandleChatForDebuffs(text); @@ -2064,9 +2262,9 @@ public sealed partial class RynthAiPlugin : RynthPluginBase _scrollLearner?.OnChat(text); _metaManager?.HandleChat(text, chatType); _questTracker?.OnChatLine(text); - // The "/aug" reply carries the T11 wield counters. + // The "/aug" reply carries the T11 wield counters (ILT Hub requests it at login). try { Loot.T11ItemSupport.OnChat(text); } - catch (Exception ex) { Log("RynthAi: T11 /aug parse failed: " + ex.Message); } + catch (Exception ex) { RynthLog.Exception(LogCat.Looting, ex, "T11 /aug parse"); } CheckChatForSafetyStops(text); try { OnOwnCorpseChat(text); } catch { } } @@ -2077,14 +2275,30 @@ public sealed partial class RynthAiPlugin : RynthPluginBase // it here so combat can drop the dead target before burning another cast. public override void OnKillNotification(string? deathMessage) { + // Mini Remote stats count every notice, as RynthTracker does (an empty message is still a kill). + try { _sessionStats?.OnKillNotification(deathMessage); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltRates, ex, "session stats kill"); } if (string.IsNullOrEmpty(deathMessage)) return; _killClock.RecordKill(); // the only kill source: KillerNotification goes to the killer alone _combatManager?.OnKillNotification(deathMessage); _dashboard?.RecordKill(); // feeds the kills/hour session stat } + /// The server sent motion/state/vector/object updates for : + /// a ghost with that id is real after all (CombatManager.Ghosts). + public override void OnUpdateObject(uint objectId) + { + try { _combatManager?.OnServerObjectUpdate(objectId); } + catch (Exception ex) + { + Host.Log($"[RynthAi] OnUpdateObject EXCEPTION on id=0x{objectId:X8}: {ex.GetType().Name}: {ex.Message}"); + } + } + public override void OnCreateObject(uint objectId) { + try { _combatManager?.OnObjectCreated(objectId); } catch { } + _sessionStats?.OnCreateObject(objectId); try { _objectCache?.OnCreateObject(objectId); } catch (Exception ex) { @@ -2096,6 +2310,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase { try { + _sessionStats?.OnDeleteObject(objectId); _objectCache?.OnDeleteObject(objectId); _combatManager?.OnObjectDeleted(objectId); // D7/D8: free per-id maps + clear cast-wait if it was our target _scrollLearner?.OnObjectDeleted(objectId); // a read scroll is consumed @@ -2111,6 +2326,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase public override void OnUpdateHealth(uint targetId, float healthRatio, uint currentHealth, uint maxHealth) { float prevRatio = _objectCache?.GetHealthRatio(unchecked((int)targetId)) ?? -1f; + _sessionStats?.OnUpdateHealth(targetId, currentHealth, maxHealth); _objectCache?.OnUpdateHealth(targetId, healthRatio); _dashboard?.OnUpdateHealth(targetId, healthRatio, currentHealth, maxHealth); if (_loginComplete && targetId == _playerId && maxHealth > 0) @@ -3033,6 +3249,11 @@ public sealed partial class RynthAiPlugin : RynthPluginBase return; string trimmed = text.Trim(); + if (TryEatOutboundTranslation(trimmed)) + { + eat = 1; + return; + } NoteChatBarLineForMetaSchedule(trimmed); // Mag-Tools /mt command compatibility @@ -3238,21 +3459,58 @@ public sealed partial class RynthAiPlugin : RynthPluginBase case "listpvars": HandleListPvarsCommand(); break; case "listgvars": HandleListGvarsCommand(); break; case "dumpprops": HandleDumpPropsCommand(parts); break; - case "iteminfo": HandleItemInfoCommand(parts); break; case "version": HandleVersionCommand(); break; case "t11": HandleT11Command(parts); break; case "wielded": HandleWieldedCommand(); break; case "scan": HandleScanCommand(); break; case "buildinfo": HandleBuildInfoCommand(); break; case "navdebug": HandleNavDebugCommand(); break; + case "navrec": HandleNavRecordCommand(parts); break; + case "navhud": HandleNavHudCommand(parts); break; + case "navtrail": HandleNavTrailCommand(parts); break; + case "navoverlay": HandleNavOverlayCommand(parts); break; + case "debug": HandleDebugCommand(parts); break; + case "trace": HandleTraceCommand(parts); break; + case "logs": HandleLogsCommand(parts); break; + case "hub": + case "quests": + case "pets": + case "guardian": + case "bounty": + case "bounties": + case "bountys": + if (_iltHub == null) { ChatLine("[RynthAi] ILT features not ready (log in first)."); break; } + _iltHub.HandleCommand(cmd, parts.Length > 2 ? parts[2..] : Array.Empty()); + break; + case "itemhud" when parts.Length > 2 && parts[2].Equals("add", StringComparison.OrdinalIgnoreCase): + HandleItemHudAdd(string.Join(" ", parts, 3, parts.Length - 3)); + break; + case "huds": + case "itemhud": + case "remote": + case "miniremote": HandleHudCommand(cmd, parts.Length > 2 ? parts[2] : string.Empty); break; + case "translate": + case "tr": HandleTranslateCommand(parts); break; + // The relay moved into RynthChat (engine) in 0.5.34; settings were imported from RynthAi\discord.json. + case "discord": ChatLine("[RynthAi] The Discord relay is now in Chat: gear menu > Discord settings, or /rc discord."); break; + case "iteminfo": + case "ii": HandleItemInfoCommand(parts); break; + case "spells": HandleSpellsCommand(parts.Length > 2 ? parts[2] : string.Empty); break; + case "buffprofile": HandleBuffProfileCommand(parts); break; + case "groundloot": HandleGroundLootCommand(parts); break; case "addnavpt": HandleAddNavPointCommand(); break; case "nav": HandleNavCommand(parts); break; case "lua": ForwardLuaCommand(parts); break; case "items": if (parts.Length >= 3 && parts[2].Equals("fill", StringComparison.OrdinalIgnoreCase)) ChatLine(_dashboard?.FillItemsFromPack(_objectCache, _playerId) ?? "[RynthAi] Settings not ready."); + else if (parts.Length >= 3 && parts[2].Equals("clean", StringComparison.OrdinalIgnoreCase)) + CleanMissingItems(); else + { ChatLine("[RynthAi] /ra items fill — add every weapon, healing kit, lockpick and pet essence in your pack that isn't listed yet."); + ChatLine("[RynthAi] /ra items clean — remove weapons and consumables that are no longer in your inventory."); + } break; case "follow": HandleFollowCommand(parts); break; case "myquests": @@ -3277,6 +3535,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase case "dumpinv": HandleDumpInventoryCommand(); break; case "combat": HandleCombatStateCommand(); break; case "why": HandleWhyCommand(); break; + case "ghost": + case "ghosts": HandleGhostsCommand(cmd, parts); break; case "start": case "resume": case "stop": @@ -3289,6 +3549,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase case "panic": HandlePanicCommand(); break; case "forcebuff": HandleForceBuff(); break; case "cancelforcebuff": HandleCancelForceBuff(); break; + case "buff": HandleBuffCommand(parts); break; case "bufftest": if (_buffManager == null) { ChatLine("[RynthAi] BuffManager not ready (not logged in yet)."); break; } _buffManager.EnableCastRegistryDiagnostic = !_buffManager.EnableCastRegistryDiagnostic; @@ -3355,6 +3616,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase case "selectlp": case "selectpl": HandleSelectCommand(parts, inv: false, land: true, partial: true); break; case "selectp": HandleSelectCommand(parts, inv: true, land: true, partial: true); break; default: + if (TryHandleVTankHotkeyCommand(cmd, parts)) break; // RynthAiPlugin.VTankHotkeys.cs if (cmd.StartsWith("jump", StringComparison.Ordinal)) { HandleJumpCommand(cmd, parts); diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiT11Command.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiT11Command.cs index c070bfc..4839824 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiT11Command.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiT11Command.cs @@ -101,14 +101,23 @@ public sealed partial class RynthAiPlugin } ChatLine($"[RynthAi] === T11: {item.Name} (0x{id:X8}) ==="); - ChatLine($"[RynthAi] Tier ~{info.EstimatedTier}" + (info.Grade != null ? $", grade {info.Grade} ({info.DamagePercent}% of max damage)" : string.Empty) + ChatLine($"[RynthAi] Tier {(info.TierIsExact ? info.Tier.ToString(CultureInfo.InvariantCulture) : "~" + info.Tier.ToString(CultureInfo.InvariantCulture))}" + + (info.Grade != null ? $", grade {info.Grade} ({info.DamagePercent}% of max damage)" : string.Empty) + + (info.WeaponQuality >= 0 ? $", quality {info.WeaponQuality}/1000" : string.Empty) + + (info.GearGrade != null ? $", gear grade {info.GearGrade} ({info.GearGradeLines} lines)" : string.Empty) + (info.ZoneLocked ? ", zone locked" : string.Empty)); + if (info.PropertySlots >= 0 || info.Tainted) + ChatLine("[RynthAi] Properties " + + (info.PropertySlots < 0 ? "?" : info.PropertySlotCap > 0 ? $"{info.PropertySlots} of {info.PropertySlotCap}" : info.PropertySlots.ToString(CultureInfo.InvariantCulture)) + + (info.Tainted ? ", tainted (bags no longer work)" : string.Empty)); foreach (T11WieldGate g in info.WieldGates) ChatLine($"[RynthAi] Wield requires {g.Amount:N0} {T11Catalog.CounterName(g.Counter)}"); foreach (T11Modifier m in info.Modifiers) { string band = m.Min.HasValue && m.Max.HasValue ? $" [{m.Min}-{m.Max}] roll {m.RollPercent}%" : string.Empty; - ChatLine($"[RynthAi] Mod {m.Name} {(m.IsSlotSpecial ? "(special)" : "+" + m.Value)}{band}"); + string marks = (m.Tinkered != 0 ? $" ({m.Tinkered:+#;-#} tinkered)" : string.Empty) + + (m.BuiltIn ? " (built-in)" : string.Empty) + (m.Locked ? " (locked)" : string.Empty); + ChatLine($"[RynthAi] Mod {m.Name} {(m.IsSlotSpecial ? "(special)" : "+" + m.Value)}{band}{marks}"); } foreach ((string name, double chance) in info.Procs) ChatLine($"[RynthAi] Cast on strike: {name} ({chance.ToString("0.#", CultureInfo.CurrentCulture)}%)"); diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthCore.Plugin.RynthAi.csproj b/Plugins/RynthCore.Plugin.RynthAi/RynthCore.Plugin.RynthAi.csproj index 5c0a421..d89e222 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthCore.Plugin.RynthAi.csproj +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthCore.Plugin.RynthAi.csproj @@ -29,12 +29,16 @@ + + + + @@ -47,6 +51,11 @@ + + + + + @@ -60,6 +69,8 @@ + + diff --git a/Plugins/RynthCore.Plugin.RynthAi/Translate/AcChatEscapes.cs b/Plugins/RynthCore.Plugin.RynthAi/Translate/AcChatEscapes.cs new file mode 100644 index 0000000..230163c --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Translate/AcChatEscapes.cs @@ -0,0 +1,49 @@ +// AcChatEscapes.cs — AC chat text helpers for the translator. +// +// AC carries characters above Latin-1 (Hangul, CJK, Cyrillic, ...) in chat as "" UTF-16 escapes, +// and the outbound chat path converts each char to one byte, so anything above U+00FF must be escaped +// before sending. Latin-1 letters (ä ö ü ñ é) stay literal; escaping them shows "<00e4>" in chat. +// Speaker names arrive wrapped in "Name<\Tell>" link markup. +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; + +namespace RynthCore.Plugin.RynthAi.Translate; + +internal static class AcChatEscapes +{ + private static readonly Regex RxEscape = new(@"<([0-9a-fA-F]{4})>", RegexOptions.CultureInvariant); + private static readonly Regex RxTellLink = new(@"]*>(?[^<]*)<\\Tell>", RegexOptions.CultureInvariant); + + /// Expands "<c2dc>" escapes into the characters they stand for. + public static string Decode(string text) + { + if (string.IsNullOrEmpty(text) || text.IndexOf('<') < 0) return text ?? string.Empty; + return RxEscape.Replace(text, m => + { + int cp = int.Parse(m.Groups[1].Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture); + return cp is > 0 and <= 0xFFFF ? ((char)cp).ToString() : m.Value; + }); + } + + /// Escapes characters above U+00FF as "<hhhh>"; drops other control characters. + public static string EncodeForSend(string text) + { + if (string.IsNullOrEmpty(text)) return string.Empty; + var sb = new StringBuilder(text.Length + 16); + foreach (char c in text) + { + if (c == '\r' || c == '\n' || c == '\t') { sb.Append(' '); continue; } + if (c < 0x20) continue; + if (c <= 0xFF) { sb.Append(c); continue; } + sb.Append('<').Append(((int)c).ToString("x4", CultureInfo.InvariantCulture)).Append('>'); + } + return sb.ToString().Trim(); + } + + /// Replaces tell-link markup with the plain name it wraps. + public static string StripLinks(string text) + => string.IsNullOrEmpty(text) || text.IndexOf("One line in the Translate window log (immutable once added). +internal sealed record TranslateLogEntry( + DateTime Time, + TranslateDirection Direction, + TranslateChannel? Channel, + string Speaker, + string Original, + string Translated, + string From, + string To, + string Error); + +internal sealed class ChatTranslator : IDisposable +{ + /// Prefix of every line the translator writes, so its own echoes are never re-translated. + public const string EchoPrefix = "[Translate]"; + + private const int EchoSpacingMs = 150; + private const int EchoMaxAttempts = 20; + private const int MaxInboundQueue = 40; + private const int DedupWindowMs = 5000; + private const int ResendGuardMs = 15000; + private const int SaveEveryMs = 2000; + private const int ErrorChatEveryMs = 30000; + private const int ChatTypeSystem = 1; + private const int ChatTypeSpellcasting = 0x11; + + private enum JobKind { Inbound, Outbound, SendRaw, Test } + + private sealed record Job(JobKind Kind, TranslateChannel? Channel, string Speaker, string Text, + string Source, string Target, string Prefix); + + private readonly RynthCoreHost _host; + private readonly Func _myName; + private readonly TranslateStore _store; + private readonly CancellationTokenSource _cts = new(); + + // Any thread → pump. + private readonly ConcurrentQueue _incoming = new(); + private readonly ConcurrentQueue<(Job Job, TranslateResult Result)> _done = new(); + // Translated bodies we are about to resend; OnChatBarEnter lets these through untouched. + private readonly ConcurrentDictionary _resend = new(StringComparer.Ordinal); + + // Pump thread only. + private readonly Queue _outQueue = new(); + private readonly LinkedList _inQueue = new(); + private readonly Dictionary _recent = new(StringComparer.Ordinal); + private readonly Queue<(string Text, int ChatType, int Attempts)> _echo = new(); + private long _lastEchoMs; + private long _lastStartMs; + private long _lastSaveMs; + private long _lastErrorChatMs = -ErrorChatEveryMs; + private int _inFlight; + + private readonly object _logLock = new(); + private readonly List _log = new(); + private TranslateLogEntry[] _logSnapshot = Array.Empty(); + + public TranslateSettings Settings { get; } + + /// Last provider error (empty after a success). Read by the UI. + public string LastError { get; private set; } = string.Empty; + + /// Characters sent to the provider this session (most plans bill per character). + public long CharsSent => Interlocked.Read(ref _charsSent); + private long _charsSent; + + public int Translated => Volatile.Read(ref _translated); + private int _translated; + + /// Requests waiting or in flight (approximate when read off the pump thread). + public int Pending => _inQueue.Count + _outQueue.Count + _incoming.Count + Volatile.Read(ref _inFlight); + + public ChatTranslator(RynthCoreHost host, Func myName, TranslateStore? store = null) + { + _host = host; + _myName = myName; + _store = store ?? new TranslateStore(); + Settings = _store.Load(); + } + + /// Per-login reset: send language back to the default, queues cleared. + public void ResetSession() + { + Settings.CurrentSendLanguage = Settings.DefaultSendLanguage; + while (_incoming.TryDequeue(out _)) { } + _outQueue.Clear(); + _inQueue.Clear(); + _echo.Clear(); + _recent.Clear(); + _resend.Clear(); + } + + // ── Entry points (any thread) ────────────────────────────────────────── + + /// Inbound chat line from the AC chat window. + public void OnChatWindowText(string text, int chatType) + { + var s = Settings; + if (!s.Enabled || !s.EnableInbound || string.IsNullOrEmpty(text)) return; + if (chatType == ChatTypeSpellcasting || text.StartsWith(EchoPrefix, StringComparison.Ordinal)) return; + if (!TryParseInbound(text, chatType, out var ch, out string speaker, out string msg, out bool own)) return; + if (!s.ListensTo(ch) || (own && s.SkipOwn)) return; + if (IsOwnName(speaker) && s.SkipOwn) return; + + msg = AcChatEscapes.Decode(msg).Trim(); + if (msg.Length == 0) return; + _incoming.Enqueue(new Job(JobKind.Inbound, ch, speaker, msg, s.InboundSource, s.MyLanguage, string.Empty)); + } + + /// + /// Typed chat line (OnChatBarEnter). Returns true when the translator took it over and the caller + /// must swallow the original. + /// + public bool TryInterceptOutbound(string text) + { + var s = Settings; + if (!TranslateChannels.TryParseOutbound(text, out var line)) return false; + string body = line.Body.Trim(); + if (_resend.TryRemove(body, out _)) return false; + if (!s.Enabled || !s.EnableOutbound || !s.SendsOn(line.Channel) || body.Length == 0) return false; + + if (s.RawPrefix.Length > 0 && body.StartsWith(s.RawPrefix, StringComparison.Ordinal)) + { + string raw = body.Substring(s.RawPrefix.Length).TrimStart(); + if (raw.Length == 0) return false; + _incoming.Enqueue(new Job(JobKind.SendRaw, line.Channel, string.Empty, raw, string.Empty, string.Empty, line.Prefix)); + return true; + } + + string target = s.CurrentSendLanguage; + if (TranslateLanguages.BaseOf(target) == TranslateLanguages.BaseOf(s.MyLanguage)) return false; + _incoming.Enqueue(new Job(JobKind.Outbound, line.Channel, string.Empty, body, TranslateLanguages.Auto, target, line.Prefix)); + return true; + } + + /// Translate window compose box: translate into the send language and send on . + public void Compose(TranslateChannel ch, string tellTarget, string text) + { + text = (text ?? string.Empty).Trim(); + if (text.Length == 0) return; + var s = Settings; + string prefix = TranslateChannels.SendPrefix(ch, tellTarget); + bool same = TranslateLanguages.BaseOf(s.CurrentSendLanguage) == TranslateLanguages.BaseOf(s.MyLanguage); + _incoming.Enqueue(same + ? new Job(JobKind.SendRaw, ch, string.Empty, text, string.Empty, string.Empty, prefix) + : new Job(JobKind.Outbound, ch, string.Empty, text, TranslateLanguages.Auto, s.CurrentSendLanguage, prefix)); + } + + /// Translates into (send language when null) without sending. + public void Test(string text, string? target = null) + { + text = (text ?? string.Empty).Trim(); + if (text.Length == 0) return; + _incoming.Enqueue(new Job(JobKind.Test, null, string.Empty, text, TranslateLanguages.Auto, + target ?? Settings.CurrentSendLanguage, string.Empty)); + } + + // ── Pump thread ──────────────────────────────────────────────────────── + + public void Tick() + { + long now = Environment.TickCount64; + DrainIncoming(now); + while (_done.TryDequeue(out var d)) ApplyResult(d.Job, d.Result); + StartNextRequest(now); + DrainEcho(now); + + if (now - _lastSaveMs >= SaveEveryMs) + { + _lastSaveMs = now; + PruneGuards(now); + _store.SaveIfDirty(Settings); + } + } + + private void DrainIncoming(long now) + { + while (_incoming.TryDequeue(out var job)) + { + switch (job.Kind) + { + case JobKind.SendRaw: + Send(job.Prefix, job.Text); + AddLog(new TranslateLogEntry(DateTime.Now, TranslateDirection.Out, job.Channel, string.Empty, + job.Text, job.Text, string.Empty, string.Empty, "sent untranslated")); + break; + case JobKind.Inbound: + string key = $"{job.Channel}|{job.Speaker}|{job.Text}"; + if (_recent.TryGetValue(key, out long seen) && now - seen < DedupWindowMs) break; + _recent[key] = now; + while (_inQueue.Count >= MaxInboundQueue) _inQueue.RemoveFirst(); + _inQueue.AddLast(job); + break; + default: + _outQueue.Enqueue(job); + break; + } + } + } + + private void StartNextRequest(long now) + { + if (Volatile.Read(ref _inFlight) != 0) return; + if (now - _lastStartMs < Settings.MinIntervalMs) return; + + Job? job = null; + if (_outQueue.Count > 0) job = _outQueue.Dequeue(); + else if (_inQueue.Count > 0) { job = _inQueue.First!.Value; _inQueue.RemoveFirst(); } + if (job == null) return; + + var s = Settings; + if (!s.Enabled && job.Kind == JobKind.Inbound) return; + + _lastStartMs = now; + Volatile.Write(ref _inFlight, 1); + Interlocked.Add(ref _charsSent, job.Text.Length); + string provider = s.Provider, key = s.ApiKey, url = s.ApiUrl; + var ct = _cts.Token; + _ = Task.Run(async () => + { + TranslateResult r; + try { r = await TranslateClient.TranslateAsync(provider, key, url, job.Text, job.Source, job.Target, ct).ConfigureAwait(false); } + catch (Exception ex) { r = TranslateResult.Fail(ex.Message); } + _done.Enqueue((job, r)); + Volatile.Write(ref _inFlight, 0); + }); + } + + private void ApplyResult(Job job, TranslateResult r) + { + if (r.Ok) LastError = string.Empty; + else + { + LastError = r.Error; + RynthLog.Write(LogCat.Chat, $"[Translate] {job.Kind} failed: {r.Error}"); + } + + switch (job.Kind) + { + case JobKind.Inbound: ApplyInbound(job, r); break; + case JobKind.Outbound: ApplyOutbound(job, r); break; + case JobKind.Test: ApplyTest(job, r); break; + } + } + + private void ApplyInbound(Job job, TranslateResult r) + { + if (!r.Ok) + { + AddLog(new TranslateLogEntry(DateTime.Now, TranslateDirection.In, job.Channel, job.Speaker, job.Text, + string.Empty, job.Source, job.Target, r.Error)); + ChatErrorThrottled(r.Error); + return; + } + + string translated = r.Text.Trim(); + // Already in the receive language, or nothing changed: stay quiet. + if (TranslateLanguages.BaseOf(r.DetectedSource) == TranslateLanguages.BaseOf(job.Target)) return; + if (translated.Length == 0 || string.Equals(translated, job.Text, StringComparison.OrdinalIgnoreCase)) return; + + Interlocked.Increment(ref _translated); + AddLog(new TranslateLogEntry(DateTime.Now, TranslateDirection.In, job.Channel, job.Speaker, job.Text, + translated, r.DetectedSource, job.Target, string.Empty)); + + if (Settings.EchoToChat && job.Channel is { } ch) + { + string from = r.DetectedSource.Length > 0 ? $" ({r.DetectedSource})" : string.Empty; + QueueEcho($"{EchoPrefix} [{TranslateChannels.Name(ch)}] {job.Speaker}{from}: {translated}", TranslateChannels.ChatType(ch)); + } + } + + private void ApplyOutbound(Job job, TranslateResult r) + { + string body; + if (r.Ok && r.Text.Trim().Length > 0) + { + body = r.Text.Trim(); + Interlocked.Increment(ref _translated); + } + else if (Settings.SendOriginalOnError) + { + body = job.Text; + QueueEcho($"{EchoPrefix} Couldn't translate ({(r.Ok ? "empty result" : r.Error)}); sent the original.", ChatTypeSystem); + } + else + { + QueueEcho($"{EchoPrefix} Couldn't translate ({(r.Ok ? "empty result" : r.Error)}); message not sent.", ChatTypeSystem); + AddLog(new TranslateLogEntry(DateTime.Now, TranslateDirection.Out, job.Channel, string.Empty, job.Text, + string.Empty, r.DetectedSource, job.Target, r.Ok ? "empty result" : r.Error)); + return; + } + + string sent = Send(job.Prefix, body); + AddLog(new TranslateLogEntry(DateTime.Now, TranslateDirection.Out, job.Channel, string.Empty, job.Text, + sent, r.DetectedSource, job.Target, r.Ok ? string.Empty : r.Error)); + + if (r.Ok && Settings.EchoOutbound && job.Channel is { } ch) + QueueEcho($"{EchoPrefix} [{TranslateChannels.Name(ch)} -> {job.Target}] you typed: {job.Text}", TranslateChannels.ChatType(ch)); + } + + private void ApplyTest(Job job, TranslateResult r) + { + AddLog(new TranslateLogEntry(DateTime.Now, TranslateDirection.Test, null, string.Empty, job.Text, + r.Ok ? r.Text : string.Empty, r.DetectedSource, job.Target, r.Error)); + QueueEcho(r.Ok + ? $"{EchoPrefix} Test ({(r.DetectedSource.Length > 0 ? r.DetectedSource : "?")} -> {job.Target}): {r.Text}" + : $"{EchoPrefix} Test failed: {r.Error}", ChatTypeSystem); + } + + /// Sends + body through the chat parser; returns the body as sent. + private string Send(string prefix, string body) + { + string encoded = AcChatEscapes.EncodeForSend(body); + if (encoded.Length == 0) return string.Empty; + _resend[encoded] = Environment.TickCount64; + bool ok = _host.HasInvokeChatParser && _host.InvokeChatParser(prefix + encoded); + if (!ok) + { + _resend.TryRemove(encoded, out _); + QueueEcho($"{EchoPrefix} The client refused to send: {prefix}{encoded}", ChatTypeSystem); + } + return encoded; + } + + private void QueueEcho(string text, int chatType) => _echo.Enqueue((text, chatType, 0)); + + private void DrainEcho(long now) + { + if (_echo.Count == 0 || now - _lastEchoMs < EchoSpacingMs) return; + var (text, type, attempts) = _echo.Peek(); + _lastEchoMs = now; + if (_host.WriteToChat(text, type) || attempts + 1 >= EchoMaxAttempts) + { + _echo.Dequeue(); + return; + } + // Dropped by the host's rate limit: retry the same line next time. + _echo.Dequeue(); + var rest = _echo.ToArray(); + _echo.Clear(); + _echo.Enqueue((text, type, attempts + 1)); + foreach (var e in rest) _echo.Enqueue(e); + } + + private void ChatErrorThrottled(string error) + { + long now = Environment.TickCount64; + if (now - _lastErrorChatMs < ErrorChatEveryMs) return; + _lastErrorChatMs = now; + QueueEcho($"{EchoPrefix} Translation error: {error}", ChatTypeSystem); + } + + private void PruneGuards(long now) + { + foreach (var kv in _resend) + if (now - kv.Value > ResendGuardMs) _resend.TryRemove(kv.Key, out _); + if (_recent.Count > 256) + { + var stale = new List(); + foreach (var kv in _recent) if (now - kv.Value > DedupWindowMs) stale.Add(kv.Key); + foreach (var k in stale) _recent.Remove(k); + } + } + + // ── Log (pump writes, render reads) ──────────────────────────────────── + + private void AddLog(TranslateLogEntry e) + { + lock (_logLock) + { + _log.Add(e); + int max = Settings.MaxLog; + if (_log.Count > max) _log.RemoveRange(0, _log.Count - max); + _logSnapshot = _log.ToArray(); + } + } + + public TranslateLogEntry[] LogSnapshot() + { + lock (_logLock) return _logSnapshot; + } + + public void ClearLog() + { + lock (_logLock) + { + _log.Clear(); + _logSnapshot = Array.Empty(); + } + } + + // ── Inbound parsing ──────────────────────────────────────────────────── + + // "[General] " style tab prefix some servers / chat options put in front of channel lines. + private static readonly Regex RxBracket = new(@"^\[(?[A-Za-z ]{1,24})\]\s*", RegexOptions.CultureInvariant); + + // "You say ...", "You tell Bob, ..." — the server echo of your own lines. + private static readonly Regex RxOwn = new(@"^You\s+(?:say|tell)\b(?[^""]*)""(?.*)""\s*$", + RegexOptions.Singleline | RegexOptions.CultureInvariant); + + // "Bob says, "..."" / "Bob says on the General channel, "..."" / "Bob tells you, "..."" + private static readonly Regex RxSpeech = new(@"^(?.+?)\s+(?says|tells)\b(?[^""]*)""(?.*)""\s*$", + RegexOptions.Singleline | RegexOptions.CultureInvariant); + + private static readonly Regex RxOnChannel = new(@"on the (?[A-Za-z ]+?) channel", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + + /// + /// Splits a chat line into channel, speaker and message. Channel comes from (in order) a "[Name]" + /// prefix, "on the X channel", "tells you", the chat colour, then words like "patron" / "vassal". + /// + internal static bool TryParseInbound(string raw, int chatType, out TranslateChannel channel, + out string speaker, out string message, out bool own) + { + channel = TranslateChannel.Local; + speaker = message = string.Empty; + own = false; + + string t = AcChatEscapes.StripLinks(raw).Trim(); + if (t.Length < 6 || t.IndexOf('"') < 0) return false; + + TranslateChannel? hint = null; + var b = RxBracket.Match(t); + if (b.Success && TranslateChannels.TryParse(b.Groups["b"].Value, out var bc)) + { + hint = bc; + t = t.Substring(b.Length); + } + + string mid; + bool tellsYou; + var mo = RxOwn.Match(t); + if (mo.Success) + { + own = true; + speaker = "You"; + mid = mo.Groups["mid"].Value; + message = mo.Groups["msg"].Value; + tellsYou = t.StartsWith("You tell", StringComparison.OrdinalIgnoreCase); + } + else + { + var m = RxSpeech.Match(t); + if (!m.Success) return false; + speaker = m.Groups["name"].Value.Trim().TrimStart('+'); + mid = m.Groups["mid"].Value; + message = m.Groups["msg"].Value; + tellsYou = m.Groups["verb"].Value == "tells" && mid.TrimStart().StartsWith("you", StringComparison.OrdinalIgnoreCase); + if (speaker.Length == 0 || speaker.Length > 40) return false; + } + + TranslateChannel? ch = hint; + if (ch == null) + { + var oc = RxOnChannel.Match(mid); + if (oc.Success && TranslateChannels.TryParse(oc.Groups["ch"].Value, out var named)) ch = named; + } + if (ch == null && tellsYou) ch = TranslateChannel.Tell; + ch ??= TranslateChannels.FromChatType(chatType); + ch ??= FromWords(mid); + if (ch == null) return false; + + channel = ch.Value; + return message.Trim().Length > 0; + } + + private static TranslateChannel? FromWords(string mid) + { + string m = mid.ToLowerInvariant(); + if (m.Contains("covassal")) return TranslateChannel.Covassals; + if (m.Contains("vassal")) return TranslateChannel.Vassals; + if (m.Contains("patron")) return TranslateChannel.Patron; + if (m.Contains("monarch")) return TranslateChannel.Monarch; + if (m.Contains("fellowship")) return TranslateChannel.Fellowship; + if (m.Contains("allegiance")) return TranslateChannel.Allegiance; + return null; + } + + private bool IsOwnName(string speaker) + { + string me; + try { me = _myName() ?? string.Empty; } + catch { return false; } + return me.Length > 0 && string.Equals(me.TrimStart('+'), speaker, StringComparison.OrdinalIgnoreCase); + } + + // ── Language helpers (UI + commands) ─────────────────────────────────── + + /// Swaps the receive and send languages for this session. + public void SwapLanguages() + { + var s = Settings; + string recv = s.MyLanguage; + s.MyLanguage = s.CurrentSendLanguage; + s.CurrentSendLanguage = recv; + } + + // ── /ra translate ────────────────────────────────────────────────────── + + /// + /// /ra translate [on|off|in on|off|out on|off|window|send <lang>|recv <lang>|default <lang>|swap|reset|test <text>|status] + /// + public void HandleCommand(string[] args, Action chat) + { + var s = Settings; + string verb = args.Length > 0 ? args[0].ToLowerInvariant() : "status"; + string arg = args.Length > 1 ? args[1] : string.Empty; + switch (verb) + { + case "on": s.Enabled = true; chat($"{EchoPrefix} On. {StatusLine()}"); break; + case "off": s.Enabled = false; chat($"{EchoPrefix} Off."); break; + case "in": + case "out": + bool? v = arg.Equals("on", StringComparison.OrdinalIgnoreCase) ? true + : arg.Equals("off", StringComparison.OrdinalIgnoreCase) ? false : null; + if (verb == "in") s.EnableInbound = v ?? !s.EnableInbound; + else s.EnableOutbound = v ?? !s.EnableOutbound; + chat($"{EchoPrefix} Inbound {(s.EnableInbound ? "on" : "off")}, outbound {(s.EnableOutbound ? "on" : "off")}."); + break; + case "window": + case "show": + s.ShowWindow = !s.ShowWindow; + break; + case "send": + case "recv": + case "receive": + case "default": + string? code = TranslateLanguages.Normalize(arg); + if (code == null || code == TranslateLanguages.Auto) + { + chat($"{EchoPrefix} Unknown language '{arg}'. Codes: {string.Join(", ", TranslateLanguages.Codes, 1, TranslateLanguages.Codes.Length - 1)}"); + break; + } + if (verb == "send") s.CurrentSendLanguage = code; + else if (verb == "default") s.DefaultSendLanguage = code; + else s.MyLanguage = code; + chat($"{EchoPrefix} {StatusLine()}"); + break; + case "swap": + SwapLanguages(); + chat($"{EchoPrefix} {StatusLine()}"); + break; + case "reset": + s.CurrentSendLanguage = s.DefaultSendLanguage; + chat($"{EchoPrefix} {StatusLine()}"); + break; + case "test": + string text = string.Join(" ", args, 1, Math.Max(0, args.Length - 1)); + if (text.Length == 0) { chat($"{EchoPrefix} Usage: /ra translate test "); break; } + Test(text); + break; + default: + chat($"{EchoPrefix} {(s.Enabled ? "On" : "Off")}. {StatusLine()}" + + (LastError.Length > 0 ? $" Last error: {LastError}" : string.Empty)); + chat($"{EchoPrefix} /ra translate on|off | in|out [on|off] | window | send|recv|default | swap | reset | test "); + break; + } + } + + public string StatusLine() + { + var s = Settings; + return $"Receive {s.MyLanguage}, send {s.CurrentSendLanguage} (default {s.DefaultSendLanguage}), " + + $"inbound {(s.EnableInbound ? "on" : "off")}, outbound {(s.EnableOutbound ? "on" : "off")}, provider {s.Provider}" + + (s.ApiKey.Length == 0 && s.Provider != TranslateSettings.ProviderLibre ? " (no API key set)" : string.Empty) + "."; + } + + public void Dispose() + { + try { _cts.Cancel(); } catch { } + _store.SaveIfDirty(Settings); + _cts.Dispose(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateChannels.cs b/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateChannels.cs new file mode 100644 index 0000000..449c828 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateChannels.cs @@ -0,0 +1,186 @@ +// TranslateChannels.cs — AC chat channels the translator can listen to (inbound) or send on (outbound), +// plus parsing of typed slash commands and the chat colour used for local echoes. +using System; +using System.Text.RegularExpressions; + +namespace RynthCore.Plugin.RynthAi.Translate; + +/// Values are bit positions in / OutboundMask; do not reorder. +internal enum TranslateChannel +{ + Local = 0, + Tell, + Fellowship, + Allegiance, + Patron, + Vassals, + Covassals, + Monarch, + General, + Trade, + Lfg, + Roleplay, + Society, + Olthoi, +} + +/// A typed chat line split into its channel, the text to keep verbatim, and the message body. +internal readonly record struct OutboundLine(TranslateChannel Channel, string Prefix, string Body, string TellTarget); + +internal static class TranslateChannels +{ + public static readonly TranslateChannel[] All = Enum.GetValues(); + + public static uint Bit(TranslateChannel ch) => 1u << (int)ch; + + public static string Name(TranslateChannel ch) => ch switch + { + TranslateChannel.Lfg => "LFG", + _ => ch.ToString(), + }; + + /// Accepts channel names and the usual short forms (case-insensitive). + public static bool TryParse(string? text, out TranslateChannel ch) + { + ch = TranslateChannel.Local; + if (string.IsNullOrWhiteSpace(text)) return false; + switch (text.Trim().ToLowerInvariant()) + { + case "local": case "say": case "area": ch = TranslateChannel.Local; return true; + case "tell": case "tells": case "t": ch = TranslateChannel.Tell; return true; + case "fellowship": case "fellow": case "f": ch = TranslateChannel.Fellowship; return true; + case "allegiance": case "alleg": case "a": ch = TranslateChannel.Allegiance; return true; + case "patron": case "p": ch = TranslateChannel.Patron; return true; + case "vassals": case "vassal": case "v": ch = TranslateChannel.Vassals; return true; + case "covassals": case "covassal": case "c": ch = TranslateChannel.Covassals; return true; + case "monarch": case "m": ch = TranslateChannel.Monarch; return true; + case "general": case "cg": case "g": ch = TranslateChannel.General; return true; + case "trade": case "ct": ch = TranslateChannel.Trade; return true; + case "lfg": case "looking for group": case "clfg": ch = TranslateChannel.Lfg; return true; + case "roleplay": case "rp": case "crp": ch = TranslateChannel.Roleplay; return true; + case "society": case "cs": ch = TranslateChannel.Society; return true; + case "olthoi": case "co": ch = TranslateChannel.Olthoi; return true; + default: return false; + } + } + + /// Chat colour for local echoes, so they land in the same chat tab as the source channel. + public static int ChatType(TranslateChannel ch) => ch switch + { + TranslateChannel.Local => 0x02, + TranslateChannel.Tell => 0x03, + TranslateChannel.Fellowship => 0x13, + TranslateChannel.Allegiance or TranslateChannel.Patron or TranslateChannel.Vassals + or TranslateChannel.Covassals or TranslateChannel.Monarch => 0x12, + TranslateChannel.General => 0x1B, + TranslateChannel.Trade => 0x1C, + TranslateChannel.Lfg => 0x1D, + TranslateChannel.Roleplay => 0x1E, + TranslateChannel.Olthoi => 0x20, + TranslateChannel.Society => 0x21, + _ => 0x01, + }; + + /// Channel implied by an inbound chat colour; null for generic colours (Channels / Social). + public static TranslateChannel? FromChatType(int chatType) => chatType switch + { + 0x02 => TranslateChannel.Local, + 0x03 => TranslateChannel.Tell, + 0x12 => TranslateChannel.Allegiance, + 0x13 => TranslateChannel.Fellowship, + 0x1B => TranslateChannel.General, + 0x1C => TranslateChannel.Trade, + 0x1D => TranslateChannel.Lfg, + 0x1E => TranslateChannel.Roleplay, + 0x20 => TranslateChannel.Olthoi, + 0x21 => TranslateChannel.Society, + _ => null, + }; + + /// + /// Command prefix used when the translator composes a line itself (Translate window). + /// A tell needs ; an empty target replies to the last tell. + /// + public static string SendPrefix(TranslateChannel ch, string? tellTarget) => ch switch + { + TranslateChannel.Local => string.Empty, + TranslateChannel.Tell => string.IsNullOrWhiteSpace(tellTarget) ? "/r " : $"/t {tellTarget.Trim()}, ", + TranslateChannel.Fellowship => "/f ", + TranslateChannel.Allegiance => "/a ", + TranslateChannel.Patron => "/p ", + TranslateChannel.Vassals => "/v ", + TranslateChannel.Covassals => "/c ", + TranslateChannel.Monarch => "/m ", + TranslateChannel.General => "/cg ", + TranslateChannel.Trade => "/ct ", + TranslateChannel.Lfg => "/clfg ", + TranslateChannel.Roleplay => "/crp ", + TranslateChannel.Society => "/cs ", + TranslateChannel.Olthoi => "/co ", + _ => string.Empty, + }; + + // "/cmd rest" or "@cmd rest"; the body keeps everything after the first run of whitespace. + private static readonly Regex RxSlash = new(@"^(?[/@][A-Za-z]+)(?\s+)(?.+)$", + RegexOptions.Singleline | RegexOptions.CultureInvariant); + + // Tell target and body: "Name, message". + private static readonly Regex RxTellArgs = new(@"^(?[^,]+?)\s*,\s*(?.+)$", + RegexOptions.Singleline | RegexOptions.CultureInvariant); + + /// + /// Splits a typed chat line into channel + verbatim prefix + body. Plain text is Local speech. + /// Returns false for slash commands that are not chat (emotes, /ra, /loc, ...). + /// + public static bool TryParseOutbound(string text, out OutboundLine line) + { + line = default; + if (string.IsNullOrWhiteSpace(text)) return false; + string t = text.Trim(); + + if (t[0] != '/' && t[0] != '@') + { + line = new OutboundLine(TranslateChannel.Local, string.Empty, t, string.Empty); + return true; + } + + var m = RxSlash.Match(t); + if (!m.Success) return false; + string cmd = m.Groups["cmd"].Value.Substring(1).ToLowerInvariant(); + string rest = m.Groups["rest"].Value; + string head = m.Groups["cmd"].Value + m.Groups["sp"].Value; + + TranslateChannel ch; + switch (cmd) + { + case "s": case "say": ch = TranslateChannel.Local; break; + case "f": case "fellowship": ch = TranslateChannel.Fellowship; break; + case "a": case "allegiance": ch = TranslateChannel.Allegiance; break; + case "p": case "patron": ch = TranslateChannel.Patron; break; + case "v": case "vassals": ch = TranslateChannel.Vassals; break; + case "c": case "covassals": ch = TranslateChannel.Covassals; break; + case "m": case "monarch": ch = TranslateChannel.Monarch; break; + case "cg": ch = TranslateChannel.General; break; + case "ct": ch = TranslateChannel.Trade; break; + case "clfg": ch = TranslateChannel.Lfg; break; + case "crp": case "rp": ch = TranslateChannel.Roleplay; break; + case "cs": ch = TranslateChannel.Society; break; + case "co": ch = TranslateChannel.Olthoi; break; + case "r": case "reply": + line = new OutboundLine(TranslateChannel.Tell, head, rest, string.Empty); + return true; + case "t": case "tell": + var tm = RxTellArgs.Match(rest); + if (!tm.Success) return false; + string msg = tm.Groups["msg"].Value; + string prefix = t.Substring(0, t.Length - msg.Length); + line = new OutboundLine(TranslateChannel.Tell, prefix, msg, tm.Groups["name"].Value.Trim()); + return true; + default: + return false; + } + + line = new OutboundLine(ch, head, rest, string.Empty); + return true; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateClient.cs b/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateClient.cs new file mode 100644 index 0000000..97eb87b --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateClient.cs @@ -0,0 +1,286 @@ +// TranslateClient.cs — HTTP calls to the translation providers. NativeAOT-safe: request JSON is written +// with Utf8JsonWriter and responses are read with JsonDocument (no reflection serialization). +// +// google Cloud Translation Basic v2 POST .../language/translate/v2?key=KEY {q,target,format,source?} +// deepl DeepL API v2 POST .../v2/translate Authorization: DeepL-Auth-Key KEY +// (keys ending ":fx" are Free-plan keys and must use api-free.deepl.com) +// libre LibreTranslate POST {server}/translate {q,source,target,format,api_key?} +using System; +using System.IO; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; + +namespace RynthCore.Plugin.RynthAi.Translate; + +/// Outcome of one request. is empty when the provider didn't report it. +internal readonly record struct TranslateResult(bool Ok, string Text, string DetectedSource, string Error) +{ + public static TranslateResult Fail(string error) => new(false, string.Empty, string.Empty, error); +} + +internal static class TranslateClient +{ + public const string GoogleUrl = "https://translation.googleapis.com/language/translate/v2"; + public const string DeepLProUrl = "https://api.deepl.com/v2/translate"; + public const string DeepLFreeUrl = "https://api-free.deepl.com/v2/translate"; + public const string LibreUrl = "https://libretranslate.com"; + + private static readonly HttpClient Http = CreateHttp(); + + private static HttpClient CreateHttp() + { + var handler = new SocketsHttpHandler + { + AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate, + PooledConnectionLifetime = TimeSpan.FromMinutes(5), + }; + var http = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(15) }; + http.DefaultRequestHeaders.UserAgent.ParseAdd("RynthAi-Translate/1.0"); + http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + return http; + } + + /// Endpoint shown in the UI when the URL box is blank. + public static string DefaultUrl(string provider, string apiKey) => provider switch + { + TranslateSettings.ProviderDeepL => IsDeepLFreeKey(apiKey) ? DeepLFreeUrl : DeepLProUrl, + TranslateSettings.ProviderLibre => LibreUrl, + _ => GoogleUrl, + }; + + private static bool IsDeepLFreeKey(string apiKey) + => apiKey.Trim().EndsWith(":fx", StringComparison.OrdinalIgnoreCase); + + /// + /// Translates from ("auto" = detect) into + /// . Never throws; failures come back as . + /// + public static async Task TranslateAsync(string provider, string apiKey, string apiUrl, + string text, string source, string target, CancellationToken ct) + { + if (string.IsNullOrWhiteSpace(text)) return TranslateResult.Fail("nothing to translate"); + apiKey = (apiKey ?? string.Empty).Trim(); + apiUrl = (apiUrl ?? string.Empty).Trim(); + bool auto = string.IsNullOrWhiteSpace(source) || source.Equals(TranslateLanguages.Auto, StringComparison.OrdinalIgnoreCase); + + try + { + return provider switch + { + TranslateSettings.ProviderDeepL => await DeepLAsync(apiKey, apiUrl, text, auto ? null : source, target, ct).ConfigureAwait(false), + TranslateSettings.ProviderLibre => await LibreAsync(apiKey, apiUrl, text, auto ? null : source, target, ct).ConfigureAwait(false), + _ => await GoogleAsync(apiKey, apiUrl, text, auto ? null : source, target, ct).ConfigureAwait(false), + }; + } + catch (OperationCanceledException) when (!ct.IsCancellationRequested) + { + return TranslateResult.Fail("request timed out"); + } + catch (OperationCanceledException) + { + return TranslateResult.Fail("cancelled"); + } + catch (HttpRequestException ex) + { + return TranslateResult.Fail("network error: " + ex.Message); + } + catch (Exception ex) + { + return TranslateResult.Fail($"{ex.GetType().Name}: {ex.Message}"); + } + } + + // ── Google Cloud Translation Basic v2 ────────────────────────────────── + + private static async Task GoogleAsync(string key, string url, string text, string? source, string target, CancellationToken ct) + { + if (key.Length == 0) return TranslateResult.Fail("Google needs an API key (Cloud Translation API)."); + string baseUrl = url.Length == 0 ? GoogleUrl : url; + int q = baseUrl.IndexOf('?'); + if (q >= 0) baseUrl = baseUrl.Substring(0, q); + + string body = BuildJson(w => + { + w.WriteString("q", text); + w.WriteString("target", target); + w.WriteString("format", "text"); + if (source != null) w.WriteString("source", source); + }); + + using var req = new HttpRequestMessage(HttpMethod.Post, baseUrl + "?key=" + Uri.EscapeDataString(key)) + { + Content = new StringContent(body, Encoding.UTF8, "application/json"), + }; + var (status, json) = await SendAsync(req, ct).ConfigureAwait(false); + if (status != HttpStatusCode.OK) return TranslateResult.Fail(ErrorText(status, json)); + + using var doc = JsonDocument.Parse(json); + if (doc.RootElement.TryGetProperty("data", out var data) + && data.TryGetProperty("translations", out var arr) + && arr.ValueKind == JsonValueKind.Array && arr.GetArrayLength() > 0) + { + var first = arr[0]; + string translated = first.TryGetProperty("translatedText", out var t) ? t.GetString() ?? string.Empty : string.Empty; + string detected = first.TryGetProperty("detectedSourceLanguage", out var d) ? d.GetString() ?? string.Empty : source ?? string.Empty; + return new TranslateResult(true, WebUtility.HtmlDecode(translated), detected, string.Empty); + } + return TranslateResult.Fail("unexpected Google response: " + Truncate(json, 160)); + } + + // ── DeepL v2 ─────────────────────────────────────────────────────────── + + private static async Task DeepLAsync(string key, string url, string text, string? source, string target, CancellationToken ct) + { + if (key.Length == 0) return TranslateResult.Fail("DeepL needs an API key (Free keys end in :fx)."); + string endpoint = url.Length == 0 ? (IsDeepLFreeKey(key) ? DeepLFreeUrl : DeepLProUrl) : url; + + string body = BuildJson(w => + { + w.WriteStartArray("text"); + w.WriteStringValue(text); + w.WriteEndArray(); + w.WriteString("target_lang", DeepLTarget(target)); + if (source != null) w.WriteString("source_lang", DeepLSource(source)); + }); + + using var req = new HttpRequestMessage(HttpMethod.Post, endpoint) + { + Content = new StringContent(body, Encoding.UTF8, "application/json"), + }; + req.Headers.TryAddWithoutValidation("Authorization", "DeepL-Auth-Key " + key); + var (status, json) = await SendAsync(req, ct).ConfigureAwait(false); + if (status != HttpStatusCode.OK) return TranslateResult.Fail(ErrorText(status, json)); + + using var doc = JsonDocument.Parse(json); + if (doc.RootElement.TryGetProperty("translations", out var arr) + && arr.ValueKind == JsonValueKind.Array && arr.GetArrayLength() > 0) + { + var first = arr[0]; + string translated = first.TryGetProperty("text", out var t) ? t.GetString() ?? string.Empty : string.Empty; + string detected = first.TryGetProperty("detected_source_language", out var d) ? (d.GetString() ?? string.Empty).ToLowerInvariant() : string.Empty; + return new TranslateResult(true, translated, detected, string.Empty); + } + return TranslateResult.Fail("unexpected DeepL response: " + Truncate(json, 160)); + } + + /// DeepL target codes: upper-case, English / Portuguese need a regional variant. + private static string DeepLTarget(string code) => code.ToLowerInvariant() switch + { + "en" => "EN-US", + "pt" => "PT-BR", + "zh-cn" => "ZH-HANS", + "zh-tw" => "ZH-HANT", + "no" => "NB", + var c => c.ToUpperInvariant(), + }; + + /// DeepL source codes: base language only. + private static string DeepLSource(string code) + { + string b = TranslateLanguages.BaseOf(code); + return (b == "no" ? "nb" : b).ToUpperInvariant(); + } + + // ── LibreTranslate ───────────────────────────────────────────────────── + + private static async Task LibreAsync(string key, string url, string text, string? source, string target, CancellationToken ct) + { + string server = (url.Length == 0 ? LibreUrl : url).TrimEnd('/'); + string endpoint = server.EndsWith("/translate", StringComparison.OrdinalIgnoreCase) ? server : server + "/translate"; + + string body = BuildJson(w => + { + w.WriteString("q", text); + w.WriteString("source", source == null ? "auto" : LibreCode(source)); + w.WriteString("target", LibreCode(target)); + w.WriteString("format", "text"); + if (key.Length > 0) w.WriteString("api_key", key); + }); + + using var req = new HttpRequestMessage(HttpMethod.Post, endpoint) + { + Content = new StringContent(body, Encoding.UTF8, "application/json"), + }; + var (status, json) = await SendAsync(req, ct).ConfigureAwait(false); + if (status != HttpStatusCode.OK) return TranslateResult.Fail(ErrorText(status, json)); + + using var doc = JsonDocument.Parse(json); + var root = doc.RootElement; + if (root.TryGetProperty("translatedText", out var t)) + { + string detected = root.TryGetProperty("detectedLanguage", out var d) && d.ValueKind == JsonValueKind.Object + && d.TryGetProperty("language", out var lang) + ? lang.GetString() ?? string.Empty + : source ?? string.Empty; + return new TranslateResult(true, t.GetString() ?? string.Empty, detected, string.Empty); + } + return TranslateResult.Fail("unexpected LibreTranslate response: " + Truncate(json, 160)); + } + + /// LibreTranslate uses "zh" for Simplified and "zt" for Traditional Chinese. + private static string LibreCode(string code) => code.ToLowerInvariant() switch + { + "zh-cn" => "zh", + "zh-tw" => "zt", + "no" => "nb", + var c => c, + }; + + // ── Shared helpers ───────────────────────────────────────────────────── + + private static async Task<(HttpStatusCode Status, string Body)> SendAsync(HttpRequestMessage req, CancellationToken ct) + { + using var resp = await Http.SendAsync(req, ct).ConfigureAwait(false); + string body = await resp.Content.ReadAsStringAsync(ct).ConfigureAwait(false); + return (resp.StatusCode, body); + } + + private static string BuildJson(Action writeProperties) + { + using var ms = new MemoryStream(); + using (var w = new Utf8JsonWriter(ms)) + { + w.WriteStartObject(); + writeProperties(w); + w.WriteEndObject(); + } + return Encoding.UTF8.GetString(ms.ToArray()); + } + + /// Pulls the provider's error message (Google error.message, DeepL message, Libre error). + private static string ErrorText(HttpStatusCode status, string json) + { + string detail = string.Empty; + try + { + using var doc = JsonDocument.Parse(json); + var root = doc.RootElement; + if (root.ValueKind == JsonValueKind.Object) + { + if (root.TryGetProperty("error", out var err)) + detail = err.ValueKind == JsonValueKind.Object && err.TryGetProperty("message", out var m) + ? m.GetString() ?? string.Empty + : err.ValueKind == JsonValueKind.String ? err.GetString() ?? string.Empty : string.Empty; + else if (root.TryGetProperty("message", out var msg)) + detail = msg.GetString() ?? string.Empty; + } + } + catch (JsonException) { detail = Truncate(json, 160); } + string hint = status switch + { + HttpStatusCode.Forbidden or HttpStatusCode.Unauthorized => " (check the API key)", + (HttpStatusCode)429 => " (rate limited, slow down)", + (HttpStatusCode)456 => " (DeepL quota used up)", + _ => string.Empty, + }; + return $"HTTP {(int)status}{hint}" + (detail.Length > 0 ? ": " + Truncate(detail, 200) : string.Empty); + } + + internal static string Truncate(string s, int max) + => string.IsNullOrEmpty(s) || s.Length <= max ? s ?? string.Empty : s.Substring(0, max) + "..."; +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateLanguages.cs b/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateLanguages.cs new file mode 100644 index 0000000..1265c6b --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateLanguages.cs @@ -0,0 +1,92 @@ +// TranslateLanguages.cs — Language codes offered by the chat translator (ISO 639-1 / Google style). +// Providers that use other codes (DeepL upper-case, LibreTranslate "zh") are mapped in TranslateClient. +using System; +using ImGuiNET; + +namespace RynthCore.Plugin.RynthAi.Translate; + +internal static class TranslateLanguages +{ + /// Pseudo-code meaning "let the provider detect the source language". + public const string Auto = "auto"; + + /// Codes in display order; index-aligned with . + public static readonly string[] Codes = + { + Auto, "en", "es", "fr", "de", "it", "pt", "nl", "sv", "no", "da", "fi", "pl", "cs", "hu", + "ro", "el", "tr", "ru", "uk", "ar", "he", "hi", "th", "vi", "id", "ja", "ko", "zh-CN", "zh-TW", + }; + + public static readonly string[] Names = + { + "Auto-detect", "English", "Spanish", "French", "German", "Italian", "Portuguese", "Dutch", "Swedish", + "Norwegian", "Danish", "Finnish", "Polish", "Czech", "Hungarian", "Romanian", "Greek", "Turkish", + "Russian", "Ukrainian", "Arabic", "Hebrew", "Hindi", "Thai", "Vietnamese", "Indonesian", "Japanese", + "Korean", "Chinese (Simplified)", "Chinese (Traditional)", + }; + + public static int IndexOf(string? code) + { + if (string.IsNullOrWhiteSpace(code)) return -1; + for (int i = 0; i < Codes.Length; i++) + if (string.Equals(Codes[i], code.Trim(), StringComparison.OrdinalIgnoreCase)) return i; + return -1; + } + + /// True when the code is in the list (auto only counts when ). + public static bool IsKnown(string? code, bool allowAuto) + { + int i = IndexOf(code); + return i > 0 || (i == 0 && allowAuto); + } + + /// Canonical spelling of a known code (e.g. "ZH-cn" → "zh-CN"); null when unknown. + public static string? Normalize(string? code) + { + int i = IndexOf(code); + return i < 0 ? null : Codes[i]; + } + + /// "Spanish (es)" for UI and chat feedback; unknown codes are shown as-is. + public static string Label(string? code) + { + int i = IndexOf(code); + return i < 0 ? (code ?? string.Empty) : i == 0 ? Names[0] : $"{Names[i]} ({Codes[i]})"; + } + + /// Base language of a code ("zh-CN" → "zh"), lower-case, for same-language checks. + public static string BaseOf(string? code) + { + if (string.IsNullOrWhiteSpace(code)) return string.Empty; + string c = code.Trim().ToLowerInvariant(); + int dash = c.IndexOf('-'); + return dash > 0 ? c.Substring(0, dash) : c; + } + + /// + /// ImGui language picker. Returns true when the selection changed. Render thread only. + /// + public static bool Combo(string label, ref string code, bool allowAuto, float width = 0f) + { + bool changed = false; + if (width > 0f) ImGui.SetNextItemWidth(width); + int current = IndexOf(code); + string preview = current < 0 ? code : current == 0 ? Names[0] : Codes[current]; + if (ImGui.BeginCombo(label, preview, ImGuiComboFlags.HeightLarge)) + { + for (int i = allowAuto ? 0 : 1; i < Codes.Length; i++) + { + bool selected = i == current; + if (ImGui.Selectable(i == 0 ? Names[0] : $"{Codes[i]} {Names[i]}", selected)) + { + code = Codes[i]; + changed = true; + } + if (selected) ImGui.SetItemDefaultFocus(); + } + ImGui.EndCombo(); + } + if (ImGui.IsItemHovered() && current > 0) ImGui.SetTooltip(Names[current]); + return changed; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateSettings.cs b/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateSettings.cs new file mode 100644 index 0000000..f9b9c7e --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateSettings.cs @@ -0,0 +1,180 @@ +// TranslateSettings.cs — Chat translator settings, shared by every character (RynthAi\translate.json). +// Fields are written by the render thread (UI) and read by the pump thread; each one is a single +// reference / 32-bit value so reads never tear. The JSON keeps channels as names; the masks are the +// runtime form. +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using System.Text.Json.Serialization; +using RynthCore.Install; + +namespace RynthCore.Plugin.RynthAi.Translate; + +internal sealed class TranslateSettings +{ + public const string ProviderGoogle = "google"; + public const string ProviderDeepL = "deepl"; + public const string ProviderLibre = "libre"; + public static readonly string[] Providers = { ProviderGoogle, ProviderDeepL, ProviderLibre }; + public static readonly string[] ProviderNames = { "Google Cloud Translation", "DeepL", "LibreTranslate" }; + + /// Master switch; off means no API calls and no chat interception. + public bool Enabled; + + public string Provider = ProviderGoogle; + + /// Stored in plain text in translate.json. + public string ApiKey = string.Empty; + + /// Blank uses the provider's default endpoint (LibreTranslate needs a server URL). + public string ApiUrl = string.Empty; + + /// "Receive" language: inbound chat is translated into this. + public string MyLanguage = "en"; + + /// Source language of inbound chat; "auto" lets the provider detect it. + public string InboundSource = TranslateLanguages.Auto; + + /// Send language each session starts with (Advanced Settings > Translate). + public string DefaultSendLanguage = "es"; + + public bool EnableInbound = true; + public bool EnableOutbound; + + public List? InboundChannels; + public List? OutboundChannels; + + /// Skip your own lines inbound (the server echoes what you send). + public bool SkipOwn = true; + + /// Write inbound translations into chat (AC chat window and RynthChat). + public bool EchoToChat = true; + + /// After an outbound translation, show what you typed locally next to what was sent. + public bool EchoOutbound = true; + + /// When an outbound translation fails, send the original text instead of dropping it. + public bool SendOriginalOnError = true; + + /// Lines starting with this go out untranslated (the prefix is removed). + public string RawPrefix = "\\"; + + /// Minimum spacing between API requests. + public int MinIntervalMs = 750; + + /// Entries kept in the Translate window log. + public int MaxLog = 200; + + public bool ShowWindow; + + // ── Runtime only ──────────────────────────────────────────────────────── + + /// Send language for this session; starts as . + [JsonIgnore] public string CurrentSendLanguage = "es"; + + [JsonIgnore] public uint InboundMask; + [JsonIgnore] public uint OutboundMask; + + public bool ListensTo(TranslateChannel ch) => (InboundMask & TranslateChannels.Bit(ch)) != 0; + public bool SendsOn(TranslateChannel ch) => (OutboundMask & TranslateChannels.Bit(ch)) != 0; + + public static uint DefaultInboundMask() + => Mask(TranslateChannel.Tell, TranslateChannel.Fellowship, TranslateChannel.Allegiance, TranslateChannel.Patron, + TranslateChannel.Vassals, TranslateChannel.Covassals, TranslateChannel.Monarch, TranslateChannel.General, + TranslateChannel.Trade, TranslateChannel.Lfg, TranslateChannel.Roleplay, TranslateChannel.Society, + TranslateChannel.Olthoi); + + public static uint DefaultOutboundMask() + => Mask(TranslateChannel.Tell, TranslateChannel.Fellowship, TranslateChannel.Allegiance, + TranslateChannel.General, TranslateChannel.Roleplay); + + private static uint Mask(params TranslateChannel[] channels) + { + uint m = 0; + foreach (var ch in channels) m |= TranslateChannels.Bit(ch); + return m; + } + + internal static uint MaskFromNames(List? names, uint fallback) + { + if (names == null) return fallback; + uint m = 0; + foreach (var n in names) + if (TranslateChannels.TryParse(n, out var ch)) m |= TranslateChannels.Bit(ch); + return m; + } + + internal static List NamesFromMask(uint mask) + { + var list = new List(); + foreach (var ch in TranslateChannels.All) + if ((mask & TranslateChannels.Bit(ch)) != 0) list.Add(TranslateChannels.Name(ch)); + return list; + } +} + +/// Loads / saves ; writes only when the JSON changed. +internal sealed class TranslateStore +{ + private readonly string _path; + private string _lastJson = string.Empty; + + public TranslateStore(string? path = null) + => _path = path ?? Path.Combine(RynthInstallPaths.RynthAiDir, "translate.json"); + + public string FilePath => _path; + + public TranslateSettings Load() + { + TranslateSettings? s = null; + try + { + if (File.Exists(_path)) + { + string json = File.ReadAllText(_path); + s = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.TranslateSettings); + if (s != null) _lastJson = json; + } + } + catch (Exception ex) { RynthLog.Exception(LogCat.Chat, ex, $"translate load {_path}"); } + s ??= new TranslateSettings(); + Normalize(s); + return s; + } + + public void SaveIfDirty(TranslateSettings s) + { + try + { + s.InboundChannels = TranslateSettings.NamesFromMask(s.InboundMask); + s.OutboundChannels = TranslateSettings.NamesFromMask(s.OutboundMask); + string json = JsonSerializer.Serialize(s, RynthAiJsonContext.Default.TranslateSettings); + if (json == _lastJson) return; + string? dir = Path.GetDirectoryName(_path); + if (!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir); + string tmp = _path + ".tmp"; + File.WriteAllText(tmp, json); + File.Move(tmp, _path, overwrite: true); + _lastJson = json; + } + catch (Exception ex) { RynthLog.Exception(LogCat.Chat, ex, $"translate save {_path}"); } + } + + /// Repairs unknown codes / out-of-range numbers and builds the runtime masks. + private static void Normalize(TranslateSettings s) + { + if (Array.IndexOf(TranslateSettings.Providers, s.Provider ?? string.Empty) < 0) s.Provider = TranslateSettings.ProviderGoogle; + s.ApiKey ??= string.Empty; + s.ApiUrl ??= string.Empty; + s.RawPrefix ??= string.Empty; + s.MyLanguage = TranslateLanguages.Normalize(s.MyLanguage) is { } my && my != TranslateLanguages.Auto ? my : "en"; + s.InboundSource = TranslateLanguages.Normalize(s.InboundSource) ?? TranslateLanguages.Auto; + s.DefaultSendLanguage = TranslateLanguages.Normalize(s.DefaultSendLanguage) is { } send && send != TranslateLanguages.Auto ? send : "es"; + s.CurrentSendLanguage = s.DefaultSendLanguage; + s.MinIntervalMs = Math.Clamp(s.MinIntervalMs, 250, 10000); + s.MaxLog = Math.Clamp(s.MaxLog, 20, 2000); + s.InboundMask = TranslateSettings.MaskFromNames(s.InboundChannels, TranslateSettings.DefaultInboundMask()); + s.OutboundMask = TranslateSettings.MaskFromNames(s.OutboundChannels, TranslateSettings.DefaultOutboundMask()); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateUi.cs b/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateUi.cs new file mode 100644 index 0000000..c2c8e4f --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/Translate/TranslateUi.cs @@ -0,0 +1,348 @@ +// TranslateUi.cs — ImGui views for the chat translator. Render thread only. +// +// RenderWindow "Chat Translate" window: language row, log, compose box, channels, settings +// RenderSettings provider / key / languages / options (also the Advanced Settings > Translate page) +// RenderHubSection compact on/off + receive/send swap row for the Mini Remote +// +// Settings fields are edited in place (single-value writes the pump thread tolerates); anything that +// needs the pump thread goes through ChatTranslator's thread-safe enqueue methods. +using System; +using System.Numerics; +using ImGuiNET; + +namespace RynthCore.Plugin.RynthAi.Translate; + +internal sealed class TranslateUi +{ + private static readonly Vector4 ColIn = new(0.45f, 0.85f, 0.95f, 1f); + private static readonly Vector4 ColOut = new(0.40f, 0.95f, 0.45f, 1f); + private static readonly Vector4 ColTest = new(0.95f, 0.80f, 0.35f, 1f); + private static readonly Vector4 ColError = new(0.95f, 0.45f, 0.40f, 1f); + private static readonly Vector4 ColDim = new(0.60f, 0.64f, 0.70f, 1f); + + private readonly ChatTranslator _tr; + private string _composeText = string.Empty; + private string _tellTarget = string.Empty; + private string _testText = string.Empty; + private TranslateChannel _composeChannel = TranslateChannel.Fellowship; + private bool _showKey; + private bool _refocusCompose; + private int _lastLogCount; + + public TranslateUi(ChatTranslator translator) => _tr = translator; + + private TranslateSettings S => _tr.Settings; + + // ── Window ───────────────────────────────────────────────────────────── + + public void RenderWindow() + { + var s = S; + if (!s.ShowWindow) return; + + ImGui.SetNextWindowSize(new Vector2(520, 420), ImGuiCond.FirstUseEver); + bool open = true; + bool visible = ImGui.Begin("Chat Translate##rynthtranslate", ref open, ImGuiWindowFlags.NoCollapse); + if (!open) s.ShowWindow = false; + if (!visible) { ImGui.End(); return; } + + RenderHeader(); + RenderLanguageRow("##win", 110f); + ImGui.Separator(); + + if (ImGui.BeginTabBar("##translatetabs")) + { + if (ImGui.BeginTabItem("Log")) { RenderLog(); ImGui.EndTabItem(); } + if (ImGui.BeginTabItem("Compose")) { RenderCompose(); ImGui.EndTabItem(); } + if (ImGui.BeginTabItem("Channels")) { RenderChannels(); ImGui.EndTabItem(); } + if (ImGui.BeginTabItem("Settings")) { RenderSettings("##win"); ImGui.EndTabItem(); } + ImGui.EndTabBar(); + } + ImGui.End(); + } + + private void RenderHeader() + { + var s = S; + ImGui.Checkbox("Enabled##trenabled", ref s.Enabled); + ImGui.SameLine(); + ImGui.Checkbox("Incoming##trin", ref s.EnableInbound); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Translate chat you receive into your receive language."); + ImGui.SameLine(); + ImGui.Checkbox("Outgoing##trout", ref s.EnableOutbound); + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Translate what you type on the ticked Send channels before it goes out.\n" + + $"Start a line with '{s.RawPrefix}' to send it untranslated."); + ImGui.SameLine(); + ImGui.TextColored(ColDim, $"| {_tr.Translated} done, {_tr.CharsSent:N0} chars, {_tr.Pending} queued"); + + if (s.ApiKey.Length == 0 && s.Provider != TranslateSettings.ProviderLibre) + ImGui.TextColored(ColError, "No API key: open the Settings tab to add one."); + else if (_tr.LastError.Length > 0) + ImGui.TextColored(ColError, "Last error: " + _tr.LastError); + } + + /// Receive / swap / send / reset-to-default row (window and Advanced page). + public void RenderLanguageRow(string id, float comboWidth) + { + var s = S; + ImGui.AlignTextToFramePadding(); + ImGui.TextUnformatted("Receive"); + ImGui.SameLine(); + string recv = s.MyLanguage; + if (TranslateLanguages.Combo("##recv" + id, ref recv, allowAuto: false, comboWidth)) s.MyLanguage = recv; + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Incoming chat is translated into this language."); + ImGui.SameLine(); + if (ImGui.Button("<->##swap" + id)) _tr.SwapLanguages(); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Swap the receive and send languages."); + ImGui.SameLine(); + ImGui.TextUnformatted("Send"); + ImGui.SameLine(); + string send = s.CurrentSendLanguage; + if (TranslateLanguages.Combo("##send" + id, ref send, allowAuto: false, comboWidth)) s.CurrentSendLanguage = send; + if (ImGui.IsItemHovered()) ImGui.SetTooltip($"What you type is translated into this language.\nDefault: {TranslateLanguages.Label(s.DefaultSendLanguage)}"); + ImGui.SameLine(); + bool atDefault = s.CurrentSendLanguage == s.DefaultSendLanguage; + if (atDefault) ImGui.BeginDisabled(); + if (ImGui.Button("Default##senddef" + id)) s.CurrentSendLanguage = s.DefaultSendLanguage; + if (atDefault) ImGui.EndDisabled(); + if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) + ImGui.SetTooltip($"Reset the send language to the default ({s.DefaultSendLanguage})."); + } + + private void RenderLog() + { + var log = _tr.LogSnapshot(); + if (ImGui.SmallButton("Clear")) _tr.ClearLog(); + ImGui.SameLine(); + ImGui.TextColored(ColDim, $"{log.Length} entries (hover a line for the original)"); + + if (!ImGui.BeginChild("##trlog", new Vector2(0, 0), ImGuiChildFlags.Borders)) { ImGui.EndChild(); return; } + foreach (var e in log) + { + var (tag, col) = e.Direction switch + { + TranslateDirection.In => ("IN ", ColIn), + TranslateDirection.Out => ("OUT", ColOut), + _ => ("TST", ColTest), + }; + ImGui.TextColored(ColDim, e.Time.ToString("HH:mm:ss")); + ImGui.SameLine(); + ImGui.TextColored(e.Error.Length > 0 && e.Translated.Length == 0 ? ColError : col, tag); + ImGui.SameLine(); + string ch = e.Channel is { } c ? $"[{TranslateChannels.Name(c)}] " : string.Empty; + string who = e.Speaker.Length > 0 ? e.Speaker + ": " : string.Empty; + string body = e.Translated.Length > 0 ? e.Translated : e.Original; + ImGui.TextWrapped($"{ch}{who}{body}"); + if (ImGui.IsItemHovered()) + { + string langs = e.From.Length > 0 || e.To.Length > 0 ? $"\n{(e.From.Length > 0 ? e.From : "?")} -> {e.To}" : string.Empty; + ImGui.SetTooltip($"Original: {e.Original}{langs}{(e.Error.Length > 0 ? "\n" + e.Error : string.Empty)}"); + } + } + // Follow new lines unless the user scrolled up. + if (log.Length != _lastLogCount && ImGui.GetScrollY() >= ImGui.GetScrollMaxY() - 20f) + ImGui.SetScrollHereY(1f); + _lastLogCount = log.Length; + ImGui.EndChild(); + } + + private void RenderCompose() + { + var s = S; + ImGui.TextWrapped($"Type in any language; it is translated into {TranslateLanguages.Label(s.CurrentSendLanguage)} and sent on the chosen channel."); + ImGui.Spacing(); + + ImGui.SetNextItemWidth(140f); + if (ImGui.BeginCombo("Channel##trcompose", TranslateChannels.Name(_composeChannel))) + { + foreach (var ch in TranslateChannels.All) + if (ImGui.Selectable(TranslateChannels.Name(ch), ch == _composeChannel)) _composeChannel = ch; + ImGui.EndCombo(); + } + if (_composeChannel == TranslateChannel.Tell) + { + ImGui.SameLine(); + ImGui.SetNextItemWidth(160f); + ImGui.InputTextWithHint("##trtell", "name (blank = reply)", ref _tellTarget, 64u); + } + + ImGui.SetNextItemWidth(-1f); + if (_refocusCompose) + { + ImGui.SetKeyboardFocusHere(); + _refocusCompose = false; + } + bool enter = ImGui.InputTextWithHint("##trcomposetext", "message", ref _composeText, 400u, ImGuiInputTextFlags.EnterReturnsTrue); + if (ImGui.Button("Translate && send") || enter) + { + if (_composeText.Trim().Length > 0) + { + _tr.Compose(_composeChannel, _tellTarget, _composeText); + _composeText = string.Empty; + _refocusCompose = enter; + } + } + ImGui.SameLine(); + if (ImGui.Button("Preview only")) _tr.Test(_composeText); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Translate without sending; the result appears in the Log tab and chat."); + if (!s.Enabled) ImGui.TextColored(ColDim, "The compose box works even while auto-translate is off."); + } + + private void RenderChannels() + { + var s = S; + ImGui.TextWrapped("Listen: incoming lines on these channels are translated into your receive language. " + + "Send: lines you type on these channels are translated into your send language."); + if (ImGui.SmallButton("Listen all")) s.InboundMask = AllMask(); + ImGui.SameLine(); + if (ImGui.SmallButton("Listen none")) s.InboundMask = 0; + ImGui.SameLine(); + if (ImGui.SmallButton("Send all")) s.OutboundMask = AllMask(); + ImGui.SameLine(); + if (ImGui.SmallButton("Send none")) s.OutboundMask = 0; + ImGui.SameLine(); + if (ImGui.SmallButton("Defaults")) + { + s.InboundMask = TranslateSettings.DefaultInboundMask(); + s.OutboundMask = TranslateSettings.DefaultOutboundMask(); + } + + if (!ImGui.BeginTable("##trchannels", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerH | ImGuiTableFlags.SizingStretchProp)) + return; + ImGui.TableSetupColumn("Channel", ImGuiTableColumnFlags.WidthStretch); + ImGui.TableSetupColumn("Listen", ImGuiTableColumnFlags.WidthFixed, 60f); + ImGui.TableSetupColumn("Send", ImGuiTableColumnFlags.WidthFixed, 60f); + ImGui.TableHeadersRow(); + foreach (var ch in TranslateChannels.All) + { + uint bit = TranslateChannels.Bit(ch); + ImGui.TableNextRow(); + ImGui.TableNextColumn(); + ImGui.AlignTextToFramePadding(); + ImGui.TextUnformatted(TranslateChannels.Name(ch)); + if (ch == TranslateChannel.Local && ImGui.IsItemHovered()) + ImGui.SetTooltip("Local speech includes NPCs; listening here uses more of your API quota."); + ImGui.TableNextColumn(); + bool inOn = (s.InboundMask & bit) != 0; + if (ImGui.Checkbox("##in" + (int)ch, ref inOn)) s.InboundMask = inOn ? s.InboundMask | bit : s.InboundMask & ~bit; + ImGui.TableNextColumn(); + bool outOn = (s.OutboundMask & bit) != 0; + if (ImGui.Checkbox("##out" + (int)ch, ref outOn)) s.OutboundMask = outOn ? s.OutboundMask | bit : s.OutboundMask & ~bit; + } + ImGui.EndTable(); + } + + private static uint AllMask() + { + uint m = 0; + foreach (var ch in TranslateChannels.All) m |= TranslateChannels.Bit(ch); + return m; + } + + // ── Settings (window tab + Advanced Settings page) ───────────────────── + + public void RenderSettings(string id) + { + var s = S; + + ImGui.TextColored(ColIn, "Service"); + int provider = Math.Max(0, Array.IndexOf(TranslateSettings.Providers, s.Provider)); + ImGui.SetNextItemWidth(220f); + if (ImGui.Combo("Provider" + id, ref provider, TranslateSettings.ProviderNames, TranslateSettings.ProviderNames.Length)) + s.Provider = TranslateSettings.Providers[provider]; + ImGui.TextColored(ColDim, ProviderHint(s.Provider)); + + var keyFlags = _showKey ? ImGuiInputTextFlags.None : ImGuiInputTextFlags.Password; + ImGui.SetNextItemWidth(300f); + ImGui.InputTextWithHint("API key" + id, s.Provider == TranslateSettings.ProviderLibre ? "optional" : "required", + ref s.ApiKey, 256u, keyFlags); + ImGui.SameLine(); + ImGui.Checkbox("Show" + id + "key", ref _showKey); + + ImGui.SetNextItemWidth(300f); + ImGui.InputTextWithHint("Endpoint" + id, TranslateClient.DefaultUrl(s.Provider, s.ApiKey), ref s.ApiUrl, 256u); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Leave blank for the provider's default.\nLibreTranslate: your server URL, e.g. http://localhost:5000"); + + ImGui.Spacing(); + ImGui.TextColored(ColIn, "Languages"); + string my = s.MyLanguage; + if (TranslateLanguages.Combo("Receive (my language)" + id, ref my, allowAuto: false, 180f)) s.MyLanguage = my; + string src = s.InboundSource; + if (TranslateLanguages.Combo("Incoming chat is in" + id, ref src, allowAuto: true, 180f)) s.InboundSource = src; + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Auto-detect works for mixed channels; pick a language to force it."); + string def = s.DefaultSendLanguage; + if (TranslateLanguages.Combo("Default send language" + id, ref def, allowAuto: false, 180f)) + { + // Following the default keeps the hub in step unless the user picked something else this session. + if (s.CurrentSendLanguage == s.DefaultSendLanguage) s.CurrentSendLanguage = def; + s.DefaultSendLanguage = def; + } + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Each login starts with this send language; swap it any time from the Mini Remote."); + + ImGui.Spacing(); + ImGui.TextColored(ColIn, "Behaviour"); + ImGui.Checkbox("Skip my own lines" + id, ref s.SkipOwn); + ImGui.Checkbox("Write incoming translations to chat" + id, ref s.EchoToChat); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Shown as \"[Translate] [Channel] Name (lang): text\" in AC chat and RynthChat,\nin the same tab as the original. Always kept in the Translate log."); + ImGui.Checkbox("Show what I typed after sending a translation" + id, ref s.EchoOutbound); + ImGui.Checkbox("Send the original if translation fails" + id, ref s.SendOriginalOnError); + ImGui.SetNextItemWidth(60f); + ImGui.InputText("Send-untranslated prefix" + id, ref s.RawPrefix, 4u); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("A typed line starting with this goes out as-is (prefix removed)."); + ImGui.SetNextItemWidth(180f); + if (ImGui.SliderInt("Min ms between requests" + id, ref s.MinIntervalMs, 250, 5000)) s.MinIntervalMs = Math.Clamp(s.MinIntervalMs, 250, 10000); + ImGui.SetNextItemWidth(180f); + if (ImGui.SliderInt("Log size" + id, ref s.MaxLog, 20, 1000)) s.MaxLog = Math.Clamp(s.MaxLog, 20, 2000); + + ImGui.Spacing(); + ImGui.TextColored(ColIn, "Test"); + ImGui.SetNextItemWidth(260f); + bool go = ImGui.InputTextWithHint("##trtest" + id, "text to translate", ref _testText, 400u, ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + if ((ImGui.Button("Test" + id) || go) && _testText.Trim().Length > 0) _tr.Test(_testText); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Translates into the current send language and prints the result in chat."); + + ImGui.Spacing(); + ImGui.TextColored(ColDim, "Shared by all characters. The API key is stored in plain text in RynthAi\\translate.json."); + ImGui.TextColored(ColDim, "AC's chat font can't draw CJK / Thai / Arabic script; those show as boxes."); + } + + private static string ProviderHint(string provider) => provider switch + { + TranslateSettings.ProviderDeepL => "DeepL API key (deepl.com/pro-api). Free plan keys end in :fx, 500k chars/month.", + TranslateSettings.ProviderLibre => "Self-hosted or public LibreTranslate server; libretranslate.com needs a key.", + _ => "Cloud Translation API key (console.cloud.google.com), 500k chars/month free.", + }; + + // ── Mini Remote section ──────────────────────────────────────────────── + + public void RenderHubSection() + { + var s = S; + ImGui.PushID("##mrtranslate"); + ImGui.Checkbox("Translate", ref s.Enabled); + if (ImGui.IsItemHovered()) ImGui.SetTooltip(_tr.StatusLine() + (_tr.LastError.Length > 0 ? "\nLast error: " + _tr.LastError : string.Empty)); + ImGui.SameLine(); + if (ImGui.SmallButton("Window")) s.ShowWindow = !s.ShowWindow; + + string recv = s.MyLanguage; + if (TranslateLanguages.Combo("##mrrecv", ref recv, allowAuto: false, 62f)) s.MyLanguage = recv; + if (ImGui.IsItemHovered()) ImGui.SetTooltip($"Receive: {TranslateLanguages.Label(s.MyLanguage)}"); + ImGui.SameLine(); + if (ImGui.Button("<->")) _tr.SwapLanguages(); + if (ImGui.IsItemHovered()) ImGui.SetTooltip("Swap receive and send languages."); + ImGui.SameLine(); + string send = s.CurrentSendLanguage; + if (TranslateLanguages.Combo("##mrsend", ref send, allowAuto: false, 62f)) s.CurrentSendLanguage = send; + if (ImGui.IsItemHovered()) ImGui.SetTooltip($"Send: {TranslateLanguages.Label(s.CurrentSendLanguage)}"); + // Right-click belongs to the Mini Remote options menu, so the reset is a button. + if (s.CurrentSendLanguage != s.DefaultSendLanguage) + { + ImGui.SameLine(); + if (ImGui.SmallButton("def")) s.CurrentSendLanguage = s.DefaultSendLanguage; + if (ImGui.IsItemHovered()) ImGui.SetTooltip($"Reset the send language to the default ({s.DefaultSendLanguage})."); + } + ImGui.PopID(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/UiPlacement.cs b/Plugins/RynthCore.Plugin.RynthAi/UiPlacement.cs new file mode 100644 index 0000000..fd7dfee --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/UiPlacement.cs @@ -0,0 +1,54 @@ +// UiPlacement.cs - Shared first-use placement and off-screen rescue for RynthAi's floating +// ImGui windows (render thread only). +// +// Windows with no imgui.ini entry open near the middle of the game view instead of ImGui's +// default (60,60), where a popped-out panel above the game frame would hide them. A window +// whose saved position leaves it (almost) off the game view is moved back to the middle. +using System.Numerics; +using ImGuiNET; + +namespace RynthCore.Plugin.RynthAi; + +internal static class UiPlacement +{ + /// Pixels of a window that must stay inside the game view to count as on-screen. + private const float MinVisible = 40f; + + private static readonly Vector2 CenterPivot = new(0.5f, 0.5f); + + /// + /// Before Begin: if the window has no saved position, centre it in the game view, shifted by + /// so windows opened together don't stack exactly. + /// + public static void CenterFirstUse(Vector2 offset = default) + { + Vector2 display = ImGui.GetIO().DisplaySize; + if (display.X <= 1 || display.Y <= 1) return; // no display size yet: ImGui's default spot + ImGui.SetNextWindowPos(display * 0.5f + offset, ImGuiCond.FirstUseEver, CenterPivot); + } + + /// + /// Between Begin and End, once per show ( is cleared by the + /// caller while the window is hidden): moves the window to the middle of the game view if + /// less than 40 px of it is on screen. Returns true when it moved the window. + /// + public static bool RescueOncePerShow(ref bool checkedThisShow) + { + if (checkedThisShow) return false; + checkedThisShow = true; + + Vector2 pos = ImGui.GetWindowPos(); + Vector2 size = ImGui.GetWindowSize(); + Vector2 display = ImGui.GetIO().DisplaySize; + if (display.X <= MinVisible * 2 || display.Y <= MinVisible * 2) return false; + if (IsOnScreen(pos, size, display)) return false; + + ImGui.SetWindowPos(Vector2.Max(Vector2.Zero, (display - size) * 0.5f)); + return true; + } + + /// True when at least 40 px of the window overlaps the game view on each axis. + public static bool IsOnScreen(Vector2 pos, Vector2 size, Vector2 display) => + pos.X + size.X >= MinVisible && pos.Y + size.Y >= MinVisible + && pos.X <= display.X - MinVisible && pos.Y <= display.Y - MinVisible; +} diff --git a/Plugins/RynthCore.Plugin.RynthChat/PluginExports.cs b/Plugins/RynthCore.Plugin.RynthChat/PluginExports.cs index 42113c5..61e049a 100644 --- a/Plugins/RynthCore.Plugin.RynthChat/PluginExports.cs +++ b/Plugins/RynthCore.Plugin.RynthChat/PluginExports.cs @@ -15,7 +15,11 @@ public static unsafe class PluginExports private static int Init(RynthCoreApiNative* api) => Runtime.Init(api); [UnmanagedCallersOnly(EntryPoint = "RynthPluginShutdown", CallConvs = new[] { typeof(CallConvCdecl) })] - public static void Shutdown() => Runtime.Shutdown(); + public static void Shutdown() + { + try { Runtime.Shutdown(); } // an exception out of a native export fail-fasts the client + catch { } + } [UnmanagedCallersOnly(EntryPoint = "RynthPluginOnLoginComplete", CallConvs = new[] { typeof(CallConvCdecl) })] public static void OnLoginComplete() => Runtime.OnLoginComplete(); @@ -24,10 +28,18 @@ public static unsafe class PluginExports public static void OnLogout() => Runtime.OnLogout(); [UnmanagedCallersOnly(EntryPoint = "RynthPluginName", CallConvs = new[] { typeof(CallConvCdecl) })] - public static IntPtr GetName() => RynthChatPlugin.NamePointer; + public static IntPtr GetName() + { + try { return RynthChatPlugin.NamePointer; } + catch { return IntPtr.Zero; } + } [UnmanagedCallersOnly(EntryPoint = "RynthPluginVersion", CallConvs = new[] { typeof(CallConvCdecl) })] - public static IntPtr GetVersion() => RynthChatPlugin.VersionPointer; + public static IntPtr GetVersion() + { + try { return RynthChatPlugin.VersionPointer; } + catch { return IntPtr.Zero; } + } [UnmanagedCallersOnly(EntryPoint = "RynthPluginTick", CallConvs = new[] { typeof(CallConvCdecl) })] public static void Tick() => Runtime.OnTick(); diff --git a/Plugins/RynthCore.Plugin.RynthInventory/PluginExports.cs b/Plugins/RynthCore.Plugin.RynthInventory/PluginExports.cs index 9171b56..e830c0b 100644 --- a/Plugins/RynthCore.Plugin.RynthInventory/PluginExports.cs +++ b/Plugins/RynthCore.Plugin.RynthInventory/PluginExports.cs @@ -20,14 +20,26 @@ public static unsafe class PluginExports private static int Init(RynthCoreApiNative* api) => Runtime.Init(api); [UnmanagedCallersOnly(EntryPoint = "RynthPluginShutdown", CallConvs = new[] { typeof(CallConvCdecl) })] - public static void Shutdown() => Runtime.Shutdown(); + public static void Shutdown() + { + try { Runtime.Shutdown(); } // an exception out of a native export fail-fasts the client + catch { } + } // UTF-8 literals live in the module's read-only data: nothing to allocate or free. [UnmanagedCallersOnly(EntryPoint = "RynthPluginName", CallConvs = new[] { typeof(CallConvCdecl) })] - public static IntPtr GetName() => LiteralPointer("RynthInventory"u8); + public static IntPtr GetName() + { + try { return LiteralPointer("RynthInventory"u8); } + catch { return IntPtr.Zero; } + } [UnmanagedCallersOnly(EntryPoint = "RynthPluginVersion", CallConvs = new[] { typeof(CallConvCdecl) })] - public static IntPtr GetVersion() => LiteralPointer("0.1.0"u8); + public static IntPtr GetVersion() + { + try { return LiteralPointer("0.1.0"u8); } + catch { return IntPtr.Zero; } + } private static IntPtr LiteralPointer(ReadOnlySpan literal) { diff --git a/Plugins/RynthCore.Plugin.RynthLua/CombatHookPump.cs b/Plugins/RynthCore.Plugin.RynthLua/CombatHookPump.cs new file mode 100644 index 0000000..29ed484 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthLua/CombatHookPump.cs @@ -0,0 +1,393 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using MoonSharp.Interpreter; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthLua; + +/// +/// RynthLua's side of RynthAi's combat hook ("RynthAi.Combat", Shared/RynthAiCombatApi.cs): +/// scripts register an attack and/or heal handler (rynth.ai SetAttackHandler / SetHealHandler), +/// and every tick, before the scripts run, this pump renews RynthAi's lease for the kinds that +/// have a handler, polls each kind, and starts the handler as a script thread for a new request. +/// When the thread ends its answer goes back with Decide. The handler never runs inside RynthAi: +/// it is an ordinary script thread (it may yield; auto-yield keeps a runaway one from freezing the +/// client), and RynthAi casts what it answers. RynthAi waits up to the request's deadline, then +/// chooses for itself. +/// +/// One script per kind (the first to register owns it; the same script registering again +/// replaces its handler). A handler error declines that request; three in a row unregister the +/// handler. A stopped script releases its kinds; an unloaded or stalled RynthLua stops renewing +/// and RynthAi goes native when the lease lapses. +/// +public sealed partial class RynthLuaPlugin +{ + /// Consecutive handler errors that unregister a handler. + internal const int CombatHandlerMaxErrors = 3; + + /// + /// How long past its request's deadline a handler thread may run before it is aborted and + /// counted as an error (a handler that never returns would otherwise hold its kind forever). + /// + internal const long CombatHandlerStallMs = 1_000; + + private const string CombatStallError = "the handler did not answer within the deadline"; + private const string CombatLateError = "the handler answered after the deadline (RynthAi had already chosen)"; + + private sealed class CombatHandler + { + public required ScriptContext Ctx; + public required uint Kind; + public DynValue Fn = DynValue.Nil; + public int Errors; + public bool InFlight; + public object? Thread; // the in-flight handler thread (LuaScriptHost.Abort) + public uint InFlightSeq; + public long StartedDeadlineMs; // the in-flight request's deadline (RynthAi's clock) + // The last request started, by seq AND issue time: RynthAi's seq restarts when it reloads. + public uint LastStartedSeq; + public long LastStartedIssuedAtMs; + } + + /// The pump's clock; must match RynthAi's (CombatHook.Clock, Environment.TickCount64). + internal static Func CombatClock = () => Environment.TickCount64; + + private readonly Dictionary _combatHandlers = new(); + // Scripts whose KeepAlive / OnStop hooks are registered: once per run (ScriptContext.Clear + // drops both lists when the script stops, and the OnStop hook takes the script out of here). + private readonly HashSet _combatHooked = new(); + private uint _combatClaimedKinds; + private string _combatClaimOwner = string.Empty; + private bool _combatRefusedLogged; + + internal static string CombatKindName(uint kind) => kind == RynthAiCombat.KindAttack ? "attack" : "heal"; + + /// The script holding , or null. + internal string? CombatOwner(uint kind) => _combatHandlers.TryGetValue(kind, out var h) ? h.Ctx.Name : null; + + /// True when RynthAi granted the kinds last claimed (this tick's claim). + internal bool CombatClaimed => _combatClaimedKinds != 0; + + /// + /// Sets (fn a function) or clears (fn nil) 's handler for . + /// Returns null on success, or why it was refused. + /// + internal string? SetCombatHandler(ScriptContext ctx, uint kind, DynValue fn) + { + if (fn.IsNil()) + { + if (_combatHandlers.TryGetValue(kind, out var mine) && mine.Ctx == ctx) DropCombatHandler(kind, release: true); + return null; + } + if (fn.Type != DataType.Function) return "the handler must be a function (or nil to clear it)"; + if (!_ai.CombatAvailable) return "RynthAi has no combat hook"; + if (_combatHandlers.TryGetValue(kind, out var held) && held.Ctx != ctx) + return $"the {CombatKindName(kind)} handler is already set by {held.Ctx.Name}"; + + // The replaced handler's request: already answered, skip it; still running (aborted here, + // its answer no longer counts), start the new handler on it. + bool restart = held != null && held.InFlight; + _combatHandlers[kind] = new CombatHandler + { + Ctx = ctx, Kind = kind, Fn = fn, + LastStartedSeq = restart ? 0 : held?.LastStartedSeq ?? 0, + LastStartedIssuedAtMs = restart ? 0 : held?.LastStartedIssuedAtMs ?? 0, + }; + if (restart) held!.Ctx.Host.Abort(held.Thread); + if (_combatHooked.Add(ctx)) + { + // A script with only handlers stays running; stopping it releases what it holds. + ctx.KeepAlive.Add(() => _combatHandlers.Values.Count(h => h.Ctx == ctx)); + ctx.OnStop.Add(() => + { + ClearCombatHandlers(ctx); + _combatHooked.Remove(ctx); + }); + } + return null; + } + + /// Drops every handler holds and releases those kinds in RynthAi. + internal void ClearCombatHandlers(ScriptContext ctx) + { + foreach (uint kind in _combatHandlers.Where(kv => kv.Value.Ctx == ctx).Select(kv => kv.Key).ToArray()) + DropCombatHandler(kind, release: true); + } + + /// Test harness only: how many KeepAlive / OnStop hooks a script has registered. + internal (int KeepAlive, int OnStop) ScriptHookCounts(string name) + => _scripts.TryGetValue(name, out var ctx) ? (ctx.KeepAlive.Count, ctx.OnStop.Count) : (0, 0); + + private void DropCombatHandler(uint kind, bool release) + { + if (_combatHandlers.TryGetValue(kind, out var h) && h.InFlight) h.Ctx.Host.Abort(h.Thread); + _combatHandlers.Remove(kind); + if (release) + { + try { _ai.CombatRelease(kind); } catch { } + _combatClaimedKinds &= ~kind; + } + } + + /// Releases every kind (plugin shutdown); RynthAi goes native at once. + private void ReleaseCombatHook() + { + _combatHandlers.Clear(); + _combatHooked.Clear(); + if (_combatClaimedKinds != 0) + { + try { _ai.CombatRelease(RynthAiCombat.KindsAll); } catch { } + _combatClaimedKinds = 0; + } + } + + /// One pump pass (OnTick, before the scripts run). + private void PumpCombatHook() + { + if (_combatHandlers.Count == 0) return; // nothing registered: no per-tick work or allocation + // A handler whose script is gone (stopped without its stop handlers, or never ran). + foreach (var kv in _combatHandlers.Where(kv => !kv.Value.Ctx.Host.Loaded).ToArray()) + DropCombatHandler(kv.Key, release: true); + if (_combatHandlers.Count == 0) return; + if (!_ai.CombatAvailable) { _combatClaimedKinds = 0; return; } // RynthAi not loaded (yet): nothing to renew + + // A handler past its request's deadline plus the stall budget never answered (a loop that + // sleeps forever, an await that never finishes): abort it so the kind isn't held forever. + long now = CombatClock(); + foreach (CombatHandler h in _combatHandlers.Values.ToArray()) + if (h.InFlight && now > h.StartedDeadlineMs + CombatHandlerStallMs) + { + h.Ctx.Host.Abort(h.Thread); + OnCombatHandlerDone(h, h.InFlightSeq, null, CombatStallError); + } + if (_combatHandlers.Count == 0) return; + + uint kinds = 0; + foreach (uint k in _combatHandlers.Keys) kinds |= k; + string owner = CombatOwnerName(); + if (owner != _combatClaimOwner && _combatClaimedKinds != 0) + _ai.CombatRelease(RynthAiCombat.KindsAll); // same plugin, new name: RynthAi refuses a rename while the lease is live + _combatClaimOwner = owner; + uint before = _combatClaimedKinds; + _combatClaimedKinds = _ai.CombatClaim(kinds, RynthAiCombat.DefaultLeaseMs, 0, 0, owner); + // A kind granted again after a gap (a lapse, a refusal, RynthAi reloaded): its seq may have + // restarted, so the last started seq no longer identifies a request already handled. + foreach (CombatHandler h in _combatHandlers.Values) + if ((before & h.Kind) == 0 && (_combatClaimedKinds & h.Kind) != 0) + h.LastStartedSeq = 0; + if (_combatClaimedKinds == 0) + { + if (!_combatRefusedLogged) + { + _combatRefusedLogged = true; + Log($"[RynthLua] combat hook: RynthAi refused the claim for {RynthAiCombat.KindNames(kinds)} (another owner holds it); retrying every tick."); + } + return; + } + _combatRefusedLogged = false; + + foreach (CombatHandler h in _combatHandlers.Values.ToArray()) + { + if ((_combatClaimedKinds & h.Kind) == 0 || h.InFlight) continue; + if (!_ai.CombatPoll(h.Kind, out CombatRequestV1 req)) continue; + if (req.Seq == h.LastStartedSeq && req.IssuedAtMs == h.LastStartedIssuedAtMs) continue; + Script? s = h.Ctx.Host.Lua; + if (s == null) continue; + DynValue ctxTable; + try { ctxTable = BuildCombatContext(s, req); } + catch (Exception ex) { h.Ctx.Host.Print($"error: combat {CombatKindName(h.Kind)} context: {ex.Message}"); continue; } + uint seq = req.Seq; + CombatHandler started = h; + h.LastStartedSeq = seq; + h.LastStartedIssuedAtMs = req.IssuedAtMs; + h.Thread = h.Ctx.Host.Start(h.Fn, new[] { ctxTable }, (result, error) => OnCombatHandlerDone(started, seq, result, error)); + h.InFlight = h.Thread != null; + h.InFlightSeq = seq; + h.StartedDeadlineMs = req.DeadlineMs; + } + } + + private string CombatOwnerName() + { + var names = _combatHandlers.Values.Select(h => h.Ctx.Name).Distinct(StringComparer.OrdinalIgnoreCase).OrderBy(n => n, StringComparer.OrdinalIgnoreCase); + string owner = "RynthLua/" + string.Join("+", names); + return owner.Length > RynthAiCombat.MaxOwnerLength ? owner.Substring(0, RynthAiCombat.MaxOwnerLength) : owner; + } + + /// The handler's thread ended: decide with its answer, or decline on an error. + private void OnCombatHandlerDone(CombatHandler h, uint seq, DynValue? result, string? error) + { + h.InFlight = false; + h.Thread = null; + // A Lua error the script host has already printed ("error: ..."): not printed twice. + bool printed = error != null && error != CombatStallError; + // An answer after the deadline: RynthAi has already chosen for itself, so the answer is + // wasted. It counts as a stall, the same as no answer within the stall budget. + if (error == null && CombatClock() > h.StartedDeadlineMs) + error = CombatLateError; + string? bad = null; + if (error == null && TryReadCombatAnswer(result, out uint spell, out uint target, out uint flags, out bad)) + { + h.Errors = 0; + _ai.CombatDecide(seq, h.Kind, spell, target, flags); // stale (0) when RynthAi moved on: harmless + return; + } + error ??= bad; + + // An error (raised, or an answer that isn't spellId, targetId [, "area"]): decline at once + // rather than make RynthAi wait out the deadline. + _ai.CombatDecide(seq, h.Kind, 0, 0, 0); + bool current = _combatHandlers.TryGetValue(h.Kind, out var now) && ReferenceEquals(now, h); + if (!current) return; // replaced or removed meanwhile: its errors don't count + string kindName = CombatKindName(h.Kind); + h.Errors++; + h.Ctx.Host.Print(printed + ? $"combat {kindName} handler failed (declined; {h.Errors}/{CombatHandlerMaxErrors} in a row)" + : $"combat {kindName} handler: {error} (declined; {h.Errors}/{CombatHandlerMaxErrors} in a row)"); + if (h.Errors >= CombatHandlerMaxErrors) + { + DropCombatHandler(h.Kind, release: true); + string what = error == CombatStallError || error == CombatLateError ? "did not answer within the deadline" : "failed"; + string msg = $"{h.Ctx.Name}: the {kindName} handler {what} {CombatHandlerMaxErrors} times in a row and was removed; RynthAi chooses the {kindName} spells again."; + h.Ctx.Host.Print(msg); + ChatLine(msg); + Log("[RynthLua] combat hook: " + msg); + } + } + /// + /// Reads a handler's return: nil / false / nothing = decline; otherwise spellId (a number), + /// targetId (a number or an object; nil = the request's target) and optional flags: "area" + /// (or true), "nojudge", or a table { area = true, nojudge = true }. + /// + internal static bool TryReadCombatAnswer(DynValue? result, out uint spell, out uint target, out uint flags, out string? error) + { + spell = target = flags = 0; + error = null; + DynValue[] values = result == null ? Array.Empty() + : result.Type == DataType.Tuple ? result.Tuple ?? Array.Empty() + : new[] { result }; + DynValue first = values.Length > 0 ? values[0] : DynValue.Nil; + if (first.IsNil() || first.Type == DataType.Void || (first.Type == DataType.Boolean && !first.Boolean)) return true; // decline + if (first.Type != DataType.Number || first.Number < 0 || first.Number > uint.MaxValue || first.Number != Math.Floor(first.Number)) + { + error = $"returned {first.Type.ToString().ToLowerInvariant()} '{first.ToPrintString()}', expected a spell id (or nil to decline)"; + return false; + } + spell = (uint)first.Number; + DynValue second = values.Length > 1 ? values[1] : DynValue.Nil; + if (!second.IsNil() && second.Type != DataType.Void) + { + target = LuaArgs.Id(second); + if (target == 0 && !(second.Type == DataType.Number && second.Number == 0)) + { + error = $"returned target '{second.ToPrintString()}', expected an object id or object (or nil for the request's target)"; + return false; + } + } + DynValue third = values.Length > 2 ? values[2] : DynValue.Nil; + switch (third.Type) + { + case DataType.Nil: + case DataType.Void: + break; + case DataType.Boolean: // true = "area" (the v1 form); false = no flags + if (third.Boolean) flags |= RynthAiCombat.FlagArea; + break; + case DataType.String: + if (!TryCombatFlag(third.String, out uint f)) + { + error = $"returned flag '{third.String}', expected \"area\", \"nojudge\" or a table {{ area = true, nojudge = true }}"; + return false; + } + flags |= f; + break; + case DataType.Table: + foreach (TablePair p in third.Table.Pairs) + { + if (p.Key.Type != DataType.String || !TryCombatFlag(p.Key.String, out uint tf)) + { + error = $"returned flag '{p.Key.ToPrintString()}', expected the keys area and nojudge"; + return false; + } + if (p.Value.CastToBool()) flags |= tf; + } + break; + default: + error = $"returned {third.Type.ToString().ToLowerInvariant()} flags, expected \"area\", \"nojudge\" or a table {{ area = true, nojudge = true }}"; + return false; + } + return true; + } + + private static bool TryCombatFlag(string name, out uint flag) + { + flag = name.Trim().ToLowerInvariant() switch + { + "area" => RynthAiCombat.FlagArea, + "nojudge" => RynthAiCombat.FlagNoJudge, + _ => 0u, + }; + return flag != 0; + } + + /// The ctx table a handler gets. + private DynValue BuildCombatContext(Script s, in CombatRequestV1 r) + { + var t = new Table(s); + t["seq"] = (double)r.Seq; + t["kind"] = CombatKindName(r.Kind); + t["targetId"] = (double)r.TargetId; + t["targetHealth"] = (double)r.TargetHealth; + t["healthPct"] = (double)r.HealthPct; + t["staminaPct"] = (double)r.StaminaPct; + t["manaPct"] = (double)r.ManaPct; + t["healLine"] = (double)r.HealLine; + t["inCombat"] = r.InCombat != 0; + t["combatMode"] = (double)r.CombatMode; + t["issuedAt"] = (double)r.IssuedAtMs; + t["deadline"] = (double)r.DeadlineMs; + + var monsters = new Table(s); + foreach (var (id, distance) in _ai.CombatScanned()) + { + var m = new Table(s); + m["id"] = (double)id; + m["distance"] = Math.Round(distance, 2); + monsters.Append(DynValue.NewTable(m)); + } + t["monsters"] = monsters; + + // ctx.last: the most recent RESOLVED cast, its err final (nil only when no answer could be + // read); ctx.pending: the cast still in flight, or nil. From a RynthAi that writes the + // appended fields; an older one: ctx.last is its last decision, no err, no pending. + var last = new Table(s); + uint newEnd = (uint)System.Runtime.InteropServices.Marshal.OffsetOf(nameof(CombatRequestV1.PendingAtMs)) + sizeof(long); + if (r.StructSize >= newEnd) + { + last["seq"] = (double)r.ResolvedSeq; + last["spell"] = (double)r.ResolvedSpell; + last["target"] = (double)r.ResolvedTarget; + last["at"] = (double)r.ResolvedAtMs; + if (r.ResolvedSpell != 0 && r.ResolvedErr >= 0) last["err"] = (double)r.ResolvedErr; + if (r.PendingSpell != 0) + { + var pending = new Table(s); + pending["seq"] = (double)r.PendingSeq; + pending["spell"] = (double)r.PendingSpell; + pending["target"] = (double)r.PendingTarget; + pending["at"] = (double)r.PendingAtMs; + t["pending"] = pending; + } + } + else + { + last["seq"] = (double)r.LastSeq; + last["spell"] = (double)r.LastSpell; + last["target"] = (double)r.LastTarget; + last["at"] = (double)r.LastAtMs; + } + t["last"] = last; + return DynValue.NewTable(t); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthLua/Examples/README.md b/Plugins/RynthCore.Plugin.RynthLua/Examples/README.md index bb992cd..915cb74 100644 --- a/Plugins/RynthCore.Plugin.RynthLua/Examples/README.md +++ b/Plugins/RynthCore.Plugin.RynthLua/Examples/README.md @@ -13,6 +13,7 @@ Scripts that listen for events keep running until you stop them (`/lua stop = 0 and ctx.targetHealth < FINISH_BELOW then + return FINISHER_SPELL + end + return nil -- RynthAi casts its own choice +end + +local function onHeal(ctx) + if HEAL_SPELL ~= 0 and ctx.healthPct >= 0 and ctx.healthPct < HEAL_BELOW then + return HEAL_SPELL, 0 -- target 0 = yourself + end + return nil -- kits, Heal Self and potions as usual +end + +local enabled = false + +local function enable() + local okAttack, whyAttack = ai.SetAttackHandler(onAttack) + if not okAttack then print("attack handler refused: " .. tostring(whyAttack)) end + local okHeal, whyHeal = ai.SetHealHandler(onHeal) + if not okHeal then print("heal handler refused: " .. tostring(whyHeal)) end + enabled = okAttack or okHeal + print("combat handlers " .. (enabled and "on" or "off")) +end + +local function disable() + ai.ClearCombatHandlers() + enabled = false + print("combat handlers off: RynthAi chooses every spell") +end + +game.RegisterCommand("/combathook", function() + if enabled then disable() else enable() end +end) + +-- Stopping the script releases the handlers anyway; clearing them here says so explicitly. +game.OnScriptEnd.Add(function() ai.ClearCombatHandlers() end) + +enable() diff --git a/Plugins/RynthCore.Plugin.RynthLua/LibraryRynthAi.cs b/Plugins/RynthCore.Plugin.RynthLua/LibraryRynthAi.cs index 28331b9..a56f7e0 100644 --- a/Plugins/RynthCore.Plugin.RynthLua/LibraryRynthAi.cs +++ b/Plugins/RynthCore.Plugin.RynthLua/LibraryRynthAi.cs @@ -19,6 +19,11 @@ namespace RynthCore.Plugin.RynthLua; /// ai.DistanceTo(objectOrId) metres, -1 when unknown /// ai.IsPathClear(objectOrIdOrName) line of sight /// ai.Command(text) (SubmitCommand) a chat line as if typed (/ra, /vt, ...; AC's parser without RynthAi) +/// ai.SetAttackHandler(fn) this script chooses RynthAi's attack spells (CombatHookPump.cs); +/// ai.SetHealHandler(fn) ... and its heal spells, asked before kits. true, or false and why. +/// fn(ctx) returns spellId, targetId [, "area"], or nil to let RynthAi choose +/// ai.ClearCombatHandlers() drops this script's handlers (stopping the script does too) +/// ai.CombatHook { Supported, AttackOwner, HealOwner, Claimed } /// /// Everything except Available and Command raises "RynthAi isn't loaded ..." when RynthAi /// isn't there, so a script can check ai.Available first or pcall. @@ -144,6 +149,23 @@ public sealed partial class RynthLuaPlugin m.Set("Command", command); m.Set("SubmitCommand", command); + // The combat hook (RynthAi.Combat): handlers run as script threads started by the pump. + DynValue SetHandler(CallbackArguments a, uint kind, string what) + { + DynValue fn = LuaArgs.At(LuaArgs.Of(a, m), 0); + if (!fn.IsNil() && fn.Type != DataType.Function) + throw new ScriptRuntimeException($"rynth.ai.{what}(fn) needs a function (or nil to clear it)"); + string? refused = SetCombatHandler(ctx, kind, fn); + return refused == null ? DynValue.True : DynValue.NewTuple(DynValue.False, DynValue.NewString(refused)); + } + m.Set("SetAttackHandler", DynValue.NewCallback((c, a) => SetHandler(a, RynthCore.Plugin.Shared.RynthAiCombat.KindAttack, "SetAttackHandler"))); + m.Set("SetHealHandler", DynValue.NewCallback((c, a) => SetHandler(a, RynthCore.Plugin.Shared.RynthAiCombat.KindHeal, "SetHealHandler"))); + m.Set("ClearCombatHandlers", DynValue.NewCallback((c, a) => + { + ClearCombatHandlers(ctx); + return DynValue.Nil; + })); + // Live fields: Available / IsLoaded, MacroRunning (read and write). var mt = new Table(s); mt.Set("__index", DynValue.NewCallback((c, a) => @@ -156,6 +178,15 @@ public sealed partial class RynthLuaPlugin return DynValue.NewBoolean(_ai.Available); case "MacroRunning": return DynValue.NewBoolean(_ai.MacroRunning); + case "CombatHook": + { + var h = new Table(s); + h["Supported"] = _ai.CombatAvailable; + h["AttackOwner"] = CombatOwner(RynthCore.Plugin.Shared.RynthAiCombat.KindAttack) is string ao ? DynValue.NewString(ao) : DynValue.Nil; + h["HealOwner"] = CombatOwner(RynthCore.Plugin.Shared.RynthAiCombat.KindHeal) is string ho ? DynValue.NewString(ho) : DynValue.Nil; + h["Claimed"] = CombatClaimed; + return DynValue.NewTable(h); + } default: return DynValue.Nil; } @@ -172,6 +203,7 @@ public sealed partial class RynthLuaPlugin return DynValue.Nil; case "Available": case "IsLoaded": + case "CombatHook": throw new ScriptRuntimeException($"rynth.ai.{key} is read-only"); default: // Script's own fields on the module are fine. diff --git a/Plugins/RynthCore.Plugin.RynthLua/LuaScriptHost.cs b/Plugins/RynthCore.Plugin.RynthLua/LuaScriptHost.cs index 55312a1..00be58c 100644 --- a/Plugins/RynthCore.Plugin.RynthLua/LuaScriptHost.cs +++ b/Plugins/RynthCore.Plugin.RynthLua/LuaScriptHost.cs @@ -34,6 +34,8 @@ internal sealed class LuaScriptHost public Func? WaitFor; // await: resume only once this is true public DynValue[] Args = Array.Empty(); public bool Started; + /// Called once when the thread ends: its return values, or the error message. + public Action? OnDone; } private readonly Action _log; @@ -206,12 +208,42 @@ internal sealed class LuaScriptHost } /// Starts as a new script thread. - public void Start(DynValue fn, DynValue[] args) + public void Start(DynValue fn, DynValue[] args) => Start(fn, args, onDone: null); + + /// + /// Starts as a new script thread and calls once + /// it ends: with its return values (a tuple for several, Nil for none) and a null error, or with + /// a null result and the error message when it raised one. Not called when the script stops + /// first (its stop handlers clean up), nor after . Returns the thread's + /// handle (for Abort), or null when nothing was started. + /// + public object? Start(DynValue fn, DynValue[] args, Action? onDone) { - if (_script == null || fn.Type != DataType.Function) return; + if (_script == null || fn.Type != DataType.Function) return null; DynValue co = _script.CreateCoroutine(fn); co.Coroutine.AutoYieldCounter = AutoYieldCounter; - _threads.Add(new LuaThread { Co = co, Args = args }); + var t = new LuaThread { Co = co, Args = args, OnDone = onDone }; + _threads.Add(t); + return t; + } + + /// + /// Ends the thread (from ) + /// without resuming it again; its onDone is not called. Returns false when it had already ended. + /// + public bool Abort(object? handle) + { + if (handle is not LuaThread t) return false; + t.OnDone = null; + if (ReferenceEquals(_botTickThread, t)) _botTickThread = null; + return _threads.Remove(t); + } + + private static void Done(LuaThread t, DynValue? result, string? error) + { + Action? cb = t.OnDone; + t.OnDone = null; + try { cb?.Invoke(result, error); } catch { } } /// Calls every v1 handler registered for , each on its own thread. @@ -276,11 +308,12 @@ internal sealed class LuaScriptHost } _current = t; + DynValue r = DynValue.Nil; try { while (_script != null) { - DynValue r = t.Started ? t.Co.Coroutine.Resume() : t.Co.Coroutine.Resume(t.Args); + r = t.Started ? t.Co.Coroutine.Resume() : t.Co.Coroutine.Resume(t.Args); t.Started = true; if (t.Co.Coroutine.State == CoroutineState.Dead) break; // Forced (auto) yield: keep going while this tick has budget. @@ -292,18 +325,24 @@ internal sealed class LuaScriptHost { Print("error: " + (ex.DecoratedMessage ?? ex.Message)); _threads.Remove(t); + Done(t, null, ex.DecoratedMessage ?? ex.Message); continue; } catch (Exception ex) { Print("error: " + ex.Message); _threads.Remove(t); + Done(t, null, ex.Message); continue; } finally { _current = null; } if (_script == null) return; - if (t.Co.Coroutine.State == CoroutineState.Dead) _threads.Remove(t); + if (t.Co.Coroutine.State == CoroutineState.Dead) + { + _threads.Remove(t); + Done(t, r, null); + } if (OverBudget()) break; } } diff --git a/Plugins/RynthCore.Plugin.RynthLua/PluginExports.cs b/Plugins/RynthCore.Plugin.RynthLua/PluginExports.cs index c54e58c..f449068 100644 --- a/Plugins/RynthCore.Plugin.RynthLua/PluginExports.cs +++ b/Plugins/RynthCore.Plugin.RynthLua/PluginExports.cs @@ -16,13 +16,25 @@ public static unsafe class PluginExports private static int Init(RynthCoreApiNative* api) => Runtime.Init(api); [UnmanagedCallersOnly(EntryPoint = "RynthPluginShutdown", CallConvs = new[] { typeof(CallConvCdecl) })] - public static void Shutdown() => Runtime.Shutdown(); + public static void Shutdown() + { + try { Runtime.Shutdown(); } // an exception out of a native export fail-fasts the client + catch { } + } [UnmanagedCallersOnly(EntryPoint = "RynthPluginName", CallConvs = new[] { typeof(CallConvCdecl) })] - public static IntPtr GetName() => RynthLuaPlugin.NamePointer; + public static IntPtr GetName() + { + try { return RynthLuaPlugin.NamePointer; } // a static initializer that throws surfaces here (TypeInitializationException) + catch { return IntPtr.Zero; } + } [UnmanagedCallersOnly(EntryPoint = "RynthPluginVersion", CallConvs = new[] { typeof(CallConvCdecl) })] - public static IntPtr GetVersion() => RynthLuaPlugin.VersionPointer; + public static IntPtr GetVersion() + { + try { return RynthLuaPlugin.VersionPointer; } + catch { return IntPtr.Zero; } + } [UnmanagedCallersOnly(EntryPoint = "RynthPluginTick", CallConvs = new[] { typeof(CallConvCdecl) })] public static void Tick() => Runtime.OnTick(); diff --git a/Plugins/RynthCore.Plugin.RynthLua/RynthAiBridge.cs b/Plugins/RynthCore.Plugin.RynthLua/RynthAiBridge.cs index 6531ee6..f1f1752 100644 --- a/Plugins/RynthCore.Plugin.RynthLua/RynthAiBridge.cs +++ b/Plugins/RynthCore.Plugin.RynthLua/RynthAiBridge.cs @@ -42,11 +42,88 @@ internal sealed unsafe class RynthAiBridge } } - /// Forget the table (logout, RynthAi reload); the next call looks it up again. + /// Forget the tables (logout, RynthAi reload); the next call looks them up again. public void Reset() { _t = null; _checked = false; + _c = null; + _cChecked = false; + } + + // -- RynthAi.Combat (Shared/RynthAiCombatApi.cs): the script-provided combat hook -- + + private RynthAiCombatApiV1* _c; + private bool _cChecked; + private long _cCheckedAt; + + private RynthAiCombatApiV1* Combat + { + get + { + long now = Environment.TickCount64; + if (_cChecked && now - _cCheckedAt < RecheckMs) return _c; + _cChecked = true; + _cCheckedAt = now; + IntPtr p = _host.GetPluginInterface("RynthAi", RynthAiCombatApiV1.InterfaceName, RynthAiCombatApiV1.InterfaceVersion); + var t = (RynthAiCombatApiV1*)p; + _c = t != null && t->Version >= 1 && t->StructSize >= (uint)sizeof(RynthAiCombatApiV1) ? t : null; + return _c; + } + } + + /// True when RynthAi serves the combat hook right now. + public bool CombatAvailable => Combat != null; + + /// Takes or renews the hook; the kinds granted (0 = refused or no RynthAi). + public uint CombatClaim(uint kinds, uint leaseMs, uint attackTimeoutMs, uint healTimeoutMs, string owner) + { + var t = Combat; + if (t == null) return 0; + using var o = new Utf8(owner); + return unchecked((uint)t->Claim(kinds, leaseMs, attackTimeoutMs, healTimeoutMs, o.P)); + } + + public void CombatRelease(uint kinds) + { + var t = Combat; + if (t != null) t->Release(kinds); + } + + /// True when a request of is open and unanswered. + public bool CombatPoll(uint kind, out CombatRequestV1 request) + { + request = default; + var t = Combat; + if (t == null) return false; + CombatRequestV1 r = default; + r.StructSize = (uint)sizeof(CombatRequestV1); + if (t->Poll(kind, &r) == 0) return false; + request = r; + return true; + } + + /// The answer to request ; false = stale (or no RynthAi). + public bool CombatDecide(uint seq, uint kind, uint spellId, uint targetId, uint flags) + { + var t = Combat; + return t != null && t->Decide(seq, kind, spellId, targetId, flags) != 0; + } + + /// RynthAi's scanned targets (id, metres), nearest first. + public (uint Id, float Distance)[] CombatScanned() + { + var t = Combat; + if (t == null) return Array.Empty<(uint, float)>(); + const int Cap = 64; + uint* ids = stackalloc uint[Cap]; + float* dist = stackalloc float[Cap]; + int n = t->GetScanned(ids, dist, Cap); + if (n <= 0) return Array.Empty<(uint, float)>(); + n = Math.Min(n, Cap); + var list = new (uint, float)[n]; + for (int i = 0; i < n; i++) list[i] = (ids[i], dist[i]); + return list; } private static string Copy(byte* s) => s == null ? string.Empty : Marshal.PtrToStringUTF8((IntPtr)s) ?? string.Empty; diff --git a/Plugins/RynthCore.Plugin.RynthLua/RynthCore.Plugin.RynthLua.csproj b/Plugins/RynthCore.Plugin.RynthLua/RynthCore.Plugin.RynthLua.csproj index 3d3962d..bac8d36 100644 --- a/Plugins/RynthCore.Plugin.RynthLua/RynthCore.Plugin.RynthLua.csproj +++ b/Plugins/RynthCore.Plugin.RynthLua/RynthCore.Plugin.RynthLua.csproj @@ -40,6 +40,8 @@ + + diff --git a/Plugins/RynthCore.Plugin.RynthLua/RynthLuaPlugin.cs b/Plugins/RynthCore.Plugin.RynthLua/RynthLuaPlugin.cs index 9ba4bcb..9ef3bcb 100644 --- a/Plugins/RynthCore.Plugin.RynthLua/RynthLuaPlugin.cs +++ b/Plugins/RynthCore.Plugin.RynthLua/RynthLuaPlugin.cs @@ -101,10 +101,16 @@ public sealed partial class RynthLuaPlugin : RynthPluginBase public override void Shutdown() { + // Forget RynthAi's cached tables first: stopping the scripts releases their combat + // handlers (ClearCombatHandlers -> CombatRelease), and RynthAi may have been unloaded or + // reloaded since the last tick looked them up, so a cached pointer could be stale. + // (Null when Initialize never ran: nothing is cached and nothing must throw here.) + try { _ai?.Reset(); } catch { } // The resume list is taken while the scripts still run; the file is written last. List resume = new(); try { resume = CaptureResume(); } catch { } try { StopAll("stopped: RynthLua unloaded"); } catch (Exception ex) { Log("[RynthLua] shutdown: " + ex.Message); } + try { ReleaseCombatHook(); } catch { } // RynthAi goes native now, not when the lease lapses try { ShutdownHuds(); } catch { } FlushHudMemory(); SaveEditor(); @@ -134,6 +140,10 @@ public sealed partial class RynthLuaPlugin : RynthPluginBase try { PollHudEvents(); } // script windows: input first, so this tick's passes see it catch (Exception ex) { LogHudFault("events", ex); } TickApi(); + // RynthAi's combat hook: renew the lease, start handlers for new requests (they run in + // TickScripts just below, so a handler that doesn't yield answers in this same tick). + try { PumpCombatHook(); } + catch (Exception ex) { Log("[RynthLua] combat hook: " + ex.Message); } TickScripts(); try { TickHuds(); } // render passes that are due, then submit what changed catch (Exception ex) { LogHudFault("passes", ex); } diff --git a/Plugins/RynthCore.Plugin.RynthLua/ScriptManager.cs b/Plugins/RynthCore.Plugin.RynthLua/ScriptManager.cs index 2546ab7..8da878f 100644 --- a/Plugins/RynthCore.Plugin.RynthLua/ScriptManager.cs +++ b/Plugins/RynthCore.Plugin.RynthLua/ScriptManager.cs @@ -255,11 +255,30 @@ public sealed partial class RynthLuaPlugin // ── /lua commands ─────────────────────────────────────────────────────── + /// + /// Every built-in /lua verb. The one list behind both the dispatch gate in HandleLuaChatCommand + /// (a verb never falls back to a script command) and the usage summary (a script command with + /// one of these names is unreachable through /lua). A new verb goes in the switch AND here. + /// + private static readonly HashSet BuiltInLuaVerbs = new(StringComparer.OrdinalIgnoreCase) + { + "run", "start", "restart", "stop", "exec", "execin", "autostart", "list", "hud", + }; + private void HandleLuaChatCommand(string line) { string[] parts = line.Split(' ', 3, StringSplitOptions.RemoveEmptyEntries); string sub = parts.Length > 1 ? parts[1].ToLowerInvariant() : ""; + if (sub.StartsWith('/')) sub = sub[1..]; // "/lua /demo": the usage lists names with a slash, one is accepted string rest = parts.Length > 2 ? parts[2].Trim() : ""; + // Not a built-in verb (those always win): in a Decal (bridge-mode) client the engine only + // forwards /lua, so "/lua demo status" (or "/lua /demo status", as the usage text lists them) is + // the way to reach a script's game.RegisterCommand("/demo"). Same queue as a typed "/demo status": + // the handler runs once on the tick thread with args "status". + if (!BuiltInLuaVerbs.Contains(sub)) + { + if (sub.Length > 0 && TryQueueScriptCommand("/" + sub + (rest.Length > 0 ? " " + rest : ""))) return; + } switch (sub) { case "run": @@ -322,7 +341,21 @@ public sealed partial class RynthLuaPlugin break; default: ChatLine("/lua list | start