Snapshot for release 2026.10.15.2 (internal 2d4b0af)
This commit is contained in:
parent
a89ae04005
commit
d5e0b50de7
224 changed files with 17914 additions and 1182 deletions
65
Changelog/2026-10-14-boost-loot-one-kill-one-loot-0.5.66.md
Normal file
65
Changelog/2026-10-14-boost-loot-one-kill-one-loot-0.5.66.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# RynthAi 0.5.66-legacy-ui - Boost Loot Priority loots each kill before the next fight
|
||||
|
||||
Previous release: 0.5.65-legacy-ui.
|
||||
|
||||
## Problem
|
||||
|
||||
With Boost Loot Priority on, Silentkelpie still fought two or three monsters before looting
|
||||
their corpses together (2026-10-14, 22:56):
|
||||
|
||||
- 22:56:43.021 Old Growler killed.
|
||||
- 22:56:43.027 the next target (Skitters McGee) locked, 6 ms later.
|
||||
- 22:56:46 Old Growler's corpse found and claimed, but the arbiter kept Combat:
|
||||
`want[cbt=True loot=True] eng=True boost[loot=True]`.
|
||||
- 22:56:54 Skitters McGee killed, then both corpses were looted.
|
||||
|
||||
Boost Loot Priority only lets looting outrank combat when combat is not engaged, and
|
||||
"engaged" includes a locked target at any range. After a kill, combat locked the next target
|
||||
in the same tick, 1-3 s before ACE creates the corpse (the death animation). So with monsters
|
||||
around, the arbiter never saw a gap, and Boost Loot made no difference.
|
||||
|
||||
## Change
|
||||
|
||||
With Boost Loot Priority on, each of our kills is looted before the next fight:
|
||||
|
||||
- A kill (KillerNotification) starts a wait of up to 4 s (`BoostLootKillWaitMs`) for its
|
||||
corpse.
|
||||
- While that wait runs, or while a corpse is claimed, open or lootable in range, combat locks
|
||||
no new target (`CombatManager.HoldNewTarget`, answered by
|
||||
`RynthAiPlugin.BoostLootHoldsNewTarget`). The log says
|
||||
`[CombatTarget] next target waits: Boost Loot Priority loots the kill first` once per wait.
|
||||
- The forming corpse counts as loot work, so the arbiter gives Looting the tick and nav
|
||||
waits.
|
||||
- Looting the kill's corpse ends the wait, so combat goes on right away. A corpse from an
|
||||
earlier kill doesn't end it.
|
||||
- Unchanged safety: a monster within 5 yd is fought at once, and a target already being
|
||||
fought is finished first.
|
||||
- No wait with Boost Loot off, Loot Only Rare Corpses on, looting off, packs full, or while
|
||||
the server is refusing uses. If the corpse never comes, combat goes on after 4 s.
|
||||
|
||||
## Tests
|
||||
|
||||
- RynthCore.RynthAiHostTests: 1005 passed, 1 failed. The failure is the known
|
||||
"map bake 0x6346" check, which needs the game data files. New cases:
|
||||
- `BoostLootOneKillOneLoot`: no target is locked while the corpse forms, the arbiter
|
||||
picks Looting, and the corpse is claimed and opened when it arrives.
|
||||
- `BoostLootHoldLimits`: the wait runs out after 4 s; a monster at 2 m, Boost Loot off, or
|
||||
Loot Only Rare Corpses means no wait.
|
||||
- `BoostLootWaitEndsOnKillCorpse`: the kill's corpse ends the wait, and an older corpse
|
||||
doesn't.
|
||||
- RynthCore.RynthAiTests: 39/39.
|
||||
|
||||
## Install
|
||||
|
||||
Installed locally on 2026-10-14: RynthAi 0.5.66-legacy-ui (RynthSuite e85b49c, clean NativeAOT
|
||||
publish) copied to C:\Games\RynthSuite\RynthAi. 0.5.65-legacy-ui was backed up to
|
||||
PreviousReleases\0.5.65-legacy-ui. Running clients load it on a restart or the overlay's RL
|
||||
(hot reload).
|
||||
|
||||
## Files
|
||||
|
||||
- `Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs`
|
||||
- `Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs`
|
||||
- `Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs`
|
||||
- `Plugins/RynthCore.Plugin.RynthAi/RynthAiVersionCommand.cs`
|
||||
- `Tools/RynthCore.RynthAiHostTests/Tests/LootCorpseTests.cs`
|
||||
102
Changelog/2026-10-14-combat-speed-swaps-stalls-0.5.64.md
Normal file
102
Changelog/2026-10-14-combat-speed-swaps-stalls-0.5.64.md
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
# RynthAi 0.5.64-legacy-ui - fewer weapon swaps, faster point-blank stall recovery
|
||||
|
||||
Previous release: 0.5.63-legacy-ui.
|
||||
|
||||
Goes with RynthCore 2026.10.5.57 (gesture-safe attacks and target selects,
|
||||
`RynthCore/Changelog/2026-10-14-gesture-safe-attacks-2026.10.5.57.md`).
|
||||
|
||||
## Problem
|
||||
|
||||
Silentkelpie (missile, several elemental crossbows) killed slowly in the
|
||||
2026-10-14 logs. Silentstorm (magic) did not: about 1.7 s per cast, limited by
|
||||
spawns. Kelpie's time went to three things:
|
||||
|
||||
- **Weapon swaps.** About 58 swaps an hour, each costing 3-4 s of no attacks,
|
||||
including ping-pong (Fire -> Piercing -> Fire crossbow 2.5 s apart,
|
||||
11:41:06-08). Causes:
|
||||
- A wield that reached the hand after the choice had moved on (a new target
|
||||
wanted another weapon) was timed out as "not seen in hand". The landing was
|
||||
never recorded, so the swap straight back wasn't held.
|
||||
- A swap started on a target that was locked 230 ms earlier, then the
|
||||
target changed and another swap followed.
|
||||
- Swaps for a target that was nearly dead.
|
||||
- Weakness swaps for a small gain (for example 1.1x over 1.0x).
|
||||
- **Attacks waiting behind crossbow gestures** in the engine's action queue
|
||||
(fixed in RynthCore 2026.10.5.57).
|
||||
- **Point-blank missile stalls.** 22 of 40 missile stalls were at 1.5-2.5 m. The
|
||||
watchdog's step 1 (re-issue) usually brought swings back within half a
|
||||
second, so the 6 s wait before it was nearly the whole cost.
|
||||
|
||||
## Change
|
||||
|
||||
- `WeaponSwapTracker`: a wield counts as landed when its weapon reaches the
|
||||
hand, even if the choice moved on while it was in flight. The A -> B landing
|
||||
is recorded, so the existing "just swapped away from it" and swaps-per-minute
|
||||
holds apply.
|
||||
- New swap settings in Advanced Settings > Melee Combat > "Weapon Swaps" (also
|
||||
readable from meta expressions):
|
||||
- `WeaponSwapSettleMs` (default 750, 0-3000): a swap for a target locked
|
||||
less than this long ago waits. Combat holds with the weapon in hand until
|
||||
the target has settled.
|
||||
- `WeaponSwapMinHealthPct` (default 25, 0-100): a target at or under this
|
||||
health is finished with the weapon in hand, when both weapons are the same
|
||||
kind (bow for bow, sword for sword).
|
||||
- `WeaponSwapMinGainPct` (default 20, 0-200): a swap chosen only by
|
||||
weakness must beat the weapon in hand by this much (`WeaponPlanner.KeepInHand`).
|
||||
It applies only when both multipliers are known. A Monsters rule element,
|
||||
order-only (learned) weakness data, or a hand weapon that does nothing to
|
||||
the target always swaps.
|
||||
- Set any of them to 0 to turn it off.
|
||||
- `CombatStallWatchdog`: missile targets within 3 m start the ladder after
|
||||
3.5 s instead of 6 s (`PointBlankStallMs`, `PointBlankMissileM`). The melee
|
||||
"quiet" early start (2.5 s) is unchanged.
|
||||
- Each deferred swap is logged once per 10 s:
|
||||
`[EquipDiag] not swapping 0x.. 'X' for 0x.. 'Y' yet (why)`.
|
||||
|
||||
## Ammo-swap fix kept
|
||||
|
||||
The launcher and ammo fix (ccbbf86: the launcher swap holds the stance, the
|
||||
400 ms ammo-off settle, and the ammo dequip not stamping the equip pacing) is
|
||||
untouched. The new holds and delays never apply while any part of a swap is
|
||||
under way (`SwapHoldsAllowed`):
|
||||
|
||||
- a wield in flight
|
||||
- old ammo or an off-hand item on its way into the pack
|
||||
- the ammo follow-up armed
|
||||
|
||||
A launcher in hand is only kept when the ammo wielded fits it. So a launcher is
|
||||
never kept after its ammo went into the pack.
|
||||
|
||||
## Tests
|
||||
|
||||
- RynthCore.RynthAiTests: 34/34. New `PointBlank`: step 1 at 3.5 s, with
|
||||
the default still 6 s.
|
||||
- RynthCore.RynthAiHostTests: 1002 passed, 1 failed. The failure is the known
|
||||
"map bake 0x6346" baseline (no dats in the worktree). New cases:
|
||||
- `SwapLandsWhenChoiceMoved` (Kelpie's Fire / Piercing case).
|
||||
- `ChoiceMinSwapGain`: threshold off, inside and outside the gain,
|
||||
order-only data, immune hand, rule element.
|
||||
- `LowHealthKeepsLauncher`.
|
||||
- `LowHealthMidSwapFinishes`: a launcher swap already under way finishes even
|
||||
when the target drops low.
|
||||
- The existing `LauncherSwapTests` and `AmmoTests` all pass.
|
||||
- Every other RynthSuite and RynthCore test project passes, except the 4 known
|
||||
RynthLua ScriptWindowsTests failures (docs and icon data missing from the
|
||||
worktree).
|
||||
|
||||
## Files
|
||||
|
||||
- `Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs`, `CombatStallWatchdog.cs`,
|
||||
`WeaponPlanner.cs`, `WeaponSwapTracker.cs`
|
||||
- `Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs`,
|
||||
`LegacyDashboardRenderer.cs`, `LegacyAdvancedSettingsUi.cs`
|
||||
- `Plugins/RynthCore.Plugin.RynthAi/Meta/ExpressionEngine.cs`, `RynthAiPlugin.cs`,
|
||||
`RynthAiVersionCommand.cs`
|
||||
- `Tools/RynthCore.RynthAiHostTests/Tests/WeaponTests.cs`, `LauncherSwapTests.cs`
|
||||
- `Tools/RynthCore.RynthAiTests/Tests/CombatStallWatchdogTests.cs`
|
||||
|
||||
## Install
|
||||
|
||||
Installed locally on 2026-10-14: RynthAi 0.5.64-legacy-ui (RynthSuite 53af975,
|
||||
NativeAOT publish) copied to C:\Games\RynthSuite\RynthAi. 0.5.63-legacy-ui was
|
||||
backed up to PreviousReleases\0.5.63-legacy-ui.
|
||||
87
Changelog/2026-10-14-loot-baseline-0.5.65.md
Normal file
87
Changelog/2026-10-14-loot-baseline-0.5.65.md
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
# RynthAi 0.5.65-legacy-ui - loot timer baseline, logged; unused loot options hidden
|
||||
|
||||
Previous release: 0.5.64-legacy-ui.
|
||||
|
||||
## What the loot logs show
|
||||
|
||||
Silentkelpie on InfiniteLeaftide (ACE), 2026-10-14 12:38-13:53, loot profile `01.utl`:
|
||||
|
||||
- 226 corpses opened, 2191 items judged, 39 pickups, every one confirmed on the first
|
||||
try (no retries, no failed pickups, no corpse timeouts). 199 of 203 timed corpses
|
||||
opened on the first try.
|
||||
- Kept: Thaelaryn Core 33, Necrolytic Extract 18, Coalesced Aetheria 1. Everything else
|
||||
was left by the profile.
|
||||
- No item was misjudged for lack of an appraisal. The 52 items judged without one were all
|
||||
keepers matched by name; every item left had its appraisal.
|
||||
- Appraisal (ID) replies: 127 ms median, 256 ms at the 95th percentile, 350 ms at most.
|
||||
- Every open found its items already in the object cache, so Content Settle and Empty
|
||||
Corpse Wait were never waited on.
|
||||
- Pickups were confirmed 1.7-2.2 s after the send (the pickup animation).
|
||||
- Skipped corpses, both as set: 133 killed by another player (Loot From = My Kills Only),
|
||||
and 42 of his own kills beyond his 40 yd (36.6 m) loot range.
|
||||
- His Approach Range Min is 240 yd with a Max of 40 yd; the loot code uses Max for Min.
|
||||
- Silentstorm has looting off.
|
||||
|
||||
## Baseline
|
||||
|
||||
| Timer | Baseline | Was default | Why |
|
||||
|---|---|---|---|
|
||||
| Content Settle | 100 ms | 100 | never waited on (items already cached) |
|
||||
| Empty Corpse Wait | 300 ms | 300 | no empty corpse or contents probe seen |
|
||||
| Assess Window | 300 ms | 200 | above the 256 ms 95th percentile of appraisal replies |
|
||||
| Loot Retry Timeout | 1000 ms | 500 | 39 of 39 pickups landed without a retry at 1000 ms |
|
||||
| Corpse Open Retry | 1500 ms | 1500 | 199 of 203 opened on the first try |
|
||||
| Corpse Timeout | 12000 ms | 12000 | no corpse timed out |
|
||||
|
||||
`LootBaseline.cs` holds these values; the settings defaults now come from it, so a new
|
||||
settings profile starts at the baseline. Saved profiles keep their own values.
|
||||
|
||||
## Change
|
||||
|
||||
- **Logged.** When looting runs, the log gets a `[LootSettings]` line with each loot timer
|
||||
marked `baseline` or `custom (baseline N)`, a count, `[acts as N]` for a value under the
|
||||
code's minimum, and a note when Approach Range Min is above Max. It is written again only
|
||||
when one of those values changes. Kelpie's current settings would log:
|
||||
`Content Settle 125 ms custom (baseline 100) | Empty Corpse Wait 550 ms custom (baseline 300) |
|
||||
Assess Window 450 ms custom (baseline 300) | Loot Retry Timeout 1000 ms baseline |
|
||||
Corpse Open Retry 1200 ms custom (baseline 1500) | Corpse Timeout 12000 ms baseline --
|
||||
4 of 6 custom | Approach Range Min 240 yd is above Max 40 yd, so Min acts as 40 yd`.
|
||||
- **Advanced Settings > Looting.**
|
||||
- Each loot timer shows `baseline` next to it, or `baseline N` in amber when it differs,
|
||||
and a tooltip saying what it does.
|
||||
- New **Use Baseline** button sets all six timers to the baseline.
|
||||
- **Hidden, not wired.** Nothing in the corpse looting reads these, so they are no longer
|
||||
shown. The settings still load and save, so profiles are unchanged.
|
||||
- Loot Only Rare Corpses (the meta/MagTools option of that name still sets Mine Only)
|
||||
- Inter-Item Delay
|
||||
- Closing Delay
|
||||
|
||||
## Tests
|
||||
|
||||
- RynthCore.RynthAiTests: 39/39, with 5 new baseline tests (the values; the all-baseline
|
||||
line; Kelpie's custom timers and range note; a value under the floor; legacy fractional
|
||||
ranges).
|
||||
- RynthCore.RynthAiHostTests: loot tests 124/124. The pickup-retry pacing test now takes its
|
||||
retry window from the settings instead of assuming 500 ms. The full run has one other
|
||||
failure, `map bake: 0x6346 from the real dats ...` ("made no checks"), which fails the same
|
||||
way on 0.5.64: it depends on the game data files on this machine.
|
||||
- The plugin builds.
|
||||
|
||||
## Install
|
||||
|
||||
- Installed locally on 2026-10-14: RynthAi 0.5.65-legacy-ui (RynthSuite 81205e9, NativeAOT
|
||||
publish) copied to C:\Games\RynthSuite\RynthAi. 0.5.64-legacy-ui (53af975) was backed up
|
||||
to PreviousReleases\0.5.64-legacy-ui. Clients load it when they restart.
|
||||
- Silentkelpie's loot timers set to the baseline with his client closed (Content Settle
|
||||
125 -> 100, Empty Corpse Wait 550 -> 300, Assess Window 450 -> 300, Corpse Open Retry
|
||||
1200 -> 1500). His Approach Range Min (240 yd) is left as it is. The previous file is
|
||||
`SettingsProfiles\InfiniteLeaftide\Silentkelpie\Default.json.pre-loot-baseline-20261014.bak`.
|
||||
|
||||
## Files
|
||||
|
||||
- `Plugins/RynthCore.Plugin.RynthAi/LootBaseline.cs` (new)
|
||||
- `Plugins/RynthCore.Plugin.RynthAi/CorpseOpenController.cs`
|
||||
- `Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs`, `LegacyAdvancedSettingsUi.cs`
|
||||
- `Plugins/RynthCore.Plugin.RynthAi/RynthAiVersionCommand.cs`
|
||||
- `Tools/RynthCore.RynthAiTests/` (csproj, `Program.cs`, `Tests/LootBaselineTests.cs`)
|
||||
- `Tools/RynthCore.RynthAiHostTests/Tests/LootCorpseTests.cs`
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
# RynthAi 0.5.69 - point-blank facing, settle only after a switch, 'too busy' wields
|
||||
|
||||
Date: 2026-10-15
|
||||
Plugin: RynthCore.Plugin.RynthAi 0.5.69-legacy-ui (previous release 0.5.68-legacy-ui)
|
||||
|
||||
Follow-ups from Silentkelpie's combat logs of 2026-10-14/15, after the 0.5.64 swap and stall
|
||||
changes.
|
||||
|
||||
## Point-blank missile stalls: turn to the target once
|
||||
|
||||
7 of Kelpie's 13 missile stalls in one session were at about 1.7 m with the target about 177°
|
||||
behind. In missile and melee modes the server rotates the character, so RynthAi doesn't turn on
|
||||
the client (a client turn there caused spinning, 2026-09-27). At point blank with the target
|
||||
behind, though, the server doesn't rotate, and the stall watchdog's first step (re-issue the
|
||||
attack) didn't fix it.
|
||||
|
||||
Now, in Missile mode only, when the target is within 3 m, more than 90° off, and no shot has
|
||||
gone out for 2.5 s, combat turns to the target's heading once (`TurnToHeadingBy`, the same call
|
||||
the wall-facing hold uses). It then waits 300 ms for the turn to settle. The same target is not
|
||||
turned to again within 3 s. The watchdog's re-issue step also turns first, whatever the last shot.
|
||||
The log line is `[Combat] point blank: turning to ...` with a running count.
|
||||
|
||||
- `Combat/PointBlankFacing.cs` (new): the rule, pure and unit tested.
|
||||
- `Combat/CombatManager.cs`: `HoldForPointBlankFacing`, called from the attack path and the
|
||||
watchdog's re-issue.
|
||||
|
||||
## Settle hold: only after a target switch
|
||||
|
||||
`WeaponSwapSettleMs` (750 ms) held every swap until the target had been locked that long. In
|
||||
Kelpie's logs this put 0.75 s in front of 22 of 25 swaps that went ahead anyway, nearly all on
|
||||
a fresh lock after a kill. Only 2-4% of those were followed by a quick switch.
|
||||
|
||||
The hold now applies only when the lock replaced another live target (a switch). A lock after a
|
||||
kill or a drop swaps at once. The log reason is now "target switched N ms ago". The setting is
|
||||
renamed in the Advanced settings to "Wait After Target Switch (ms)", with an updated tooltip.
|
||||
The value and the settings key are unchanged.
|
||||
|
||||
## Wields answered 'too busy' are not failed tries
|
||||
|
||||
Kelpie's two "didn't wield after 3 tries" give-ups in the last four days both coincided with a
|
||||
teleport: a house recall at 00:44:23 (one second after the wield went out) and a portal at
|
||||
23:22:52. The flight recorder showed the server answering each try with `WeenieError 0x1D
|
||||
(YoureTooBusy)` and then `InventoryServerSaveFailed` with no error. The engine keeps only the
|
||||
last of those records, so RynthAi read "error 0", saw no refusal, and each try timed out as
|
||||
"not seen in hand". After three, the better weapon was benched for 2 minutes, even after the
|
||||
character had landed somewhere new.
|
||||
|
||||
Now:
|
||||
|
||||
- `0x1D` (WeenieError or UseDone), or an `InventoryServerSaveFailed` with no error, reads as
|
||||
"busy". The try is given back and the wield goes again after 1.5 s. After 6 busy answers for
|
||||
one weapon they count as tries, so a weapon the server always refuses is still rested.
|
||||
- Leaving portal space (a portal, recall or teleport) clears every try and rest, for the main
|
||||
hand, ammo and off hand.
|
||||
- A real refusal still counts as a try, as before.
|
||||
- The log line is `[EquipDiag] wield of ... answered 'too busy': not counted, again in 1.5 s`.
|
||||
|
||||
Files:
|
||||
|
||||
- `Combat/WeaponSwapTracker.cs`: `Busy`, `NewPlace`, `BusyRetryMs`, `MaxBusyRefunds`.
|
||||
- `Combat/CombatManager.cs`: `ServerAnswerSinceSend` (was `ServerRefusedSinceSend`),
|
||||
`FoldServerAnswer` for the weapon, ammo and off-hand trackers, and `NoteSwapPortal` on the
|
||||
heartbeat.
|
||||
- `Combat/CombatManager.Ammo.cs`, `Combat/CombatManager.Offhand.cs`: use `FoldServerAnswer`.
|
||||
|
||||
## Tests
|
||||
|
||||
- `Tools\RynthCore.RynthAiTests`: 40 tests, all passed. New: "point blank facing: one snap only
|
||||
for a close target behind, after a full shot cycle".
|
||||
- `Tools\RynthCore.RynthAiHostTests`: 1009 of 1010 passed. New:
|
||||
- "swap holds: a lock after a kill swaps at once; a switch from a live target waits"
|
||||
- "weapon swap: 'too busy' is no try, and a portal or recall ends the rest"
|
||||
- "weapon swap: combat reads ACE's busy answer (0x1D then SaveFailed 0) as busy, a real
|
||||
refusal as a try"
|
||||
|
||||
The one failure is the map bake check, which needs the game dats.
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- RynthAChard: the AChard server plugin (PvP). The build is shared (..\Shared\ServerPack\ServerPlugin.props);
|
||||
ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthAChard</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<RynthPluginServerId>achard</RynthPluginServerId>
|
||||
<RynthPluginServerName>AChard</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>a-chard.ddns.net</RynthPluginServerHosts>
|
||||
<RynthPluginServerWorldNames>AChard|A-Chard</RynthPluginServerWorldNames>
|
||||
<RynthPluginDescription>AChard only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||
|
||||
</Project>
|
||||
23
Plugins/RynthCore.Plugin.RynthAChard/ServerData.cs
Normal file
23
Plugins/RynthCore.Plugin.RynthAChard/ServerData.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// ServerData.cs - What is known about AChard (RynthAChard). Identity (id, hosts, world names) is in the csproj.
|
||||
namespace RynthCore.Plugin.ServerPack;
|
||||
|
||||
internal static class ServerData
|
||||
{
|
||||
public static ServerPackInfo Create() =>
|
||||
new(RynthPluginInfo.ServerId, RynthPluginInfo.ServerName, RynthPluginInfo.ServerHosts, RynthPluginInfo.ServerWorldNames)
|
||||
{
|
||||
Port = 9000,
|
||||
Emulator = "ACE",
|
||||
Ruleset = "PvP",
|
||||
Status = "Stable",
|
||||
Summary = "ACE EOR PVP Server/Custom PK Content/PK Kill Rankings",
|
||||
Facts = new[]
|
||||
{
|
||||
"PvP server: other players can attack you.",
|
||||
"Custom PK content and PK kill rankings.",
|
||||
},
|
||||
Discord = "https://discord.gg/gmHfqt2J2D",
|
||||
Website = "http://a-chard.ddns.net/",
|
||||
Source = "public AC server list (acresources/serverslist), checked 2026-10-13",
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- RynthAelrynth: the Aelrynth server plugin. "aelrynth" is one of RynthCore's built-in server ids, so the
|
||||
engine's own Aelrynth detection decides when it is active (the hosts here only pick it at load).
|
||||
The build is shared (..\Shared\ServerPack\ServerPlugin.props); ServerData.cs holds what is known. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthAelrynth</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<RynthPluginServerId>aelrynth</RynthPluginServerId>
|
||||
<RynthPluginServerName>Aelrynth</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>aelrynth.com</RynthPluginServerHosts>
|
||||
<RynthPluginServerWorldNames>Aelrynth*|Aeshnidae*</RynthPluginServerWorldNames>
|
||||
<RynthPluginDescription>Aelrynth only: the server card (its mods, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||
|
||||
</Project>
|
||||
26
Plugins/RynthCore.Plugin.RynthAelrynth/ServerData.cs
Normal file
26
Plugins/RynthCore.Plugin.RynthAelrynth/ServerData.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// ServerData.cs - What is known about Aelrynth (RynthAelrynth). Identity (id, hosts, world names) is in the csproj.
|
||||
// Aelrynth isn't in the public server list; this comes from RynthCore's own Aelrynth support
|
||||
// (Compatibility/AelrynthWire.cs, Net/AelrynthVaultWire.cs) and RynthOracle's quest pack.
|
||||
namespace RynthCore.Plugin.ServerPack;
|
||||
|
||||
internal static class ServerData
|
||||
{
|
||||
public static ServerPackInfo Create() =>
|
||||
new(RynthPluginInfo.ServerId, RynthPluginInfo.ServerName, RynthPluginInfo.ServerHosts, RynthPluginInfo.ServerWorldNames)
|
||||
{
|
||||
Port = 9020,
|
||||
Emulator = "ACE",
|
||||
Ruleset = "PvE",
|
||||
Summary = "Aelrynth (aelrynth.com), an ACE server with its own mods.",
|
||||
Facts = new[]
|
||||
{
|
||||
"Bank mod: Radiance and Luminance banking (RynthCore reads its totals).",
|
||||
"Skill Mastery mod (RynthCore shows mastery progress).",
|
||||
"Account vault for mules (RynthCore reads its contents).",
|
||||
"RynthOracle has an Aelrynth quest pack (quests.aelrynth.csv).",
|
||||
"The world was named Aeshnidae before; both names count.",
|
||||
},
|
||||
Website = "https://aelrynth.com",
|
||||
Source = "RynthCore's Aelrynth support and RynthOracle, 2026-10-13",
|
||||
};
|
||||
}
|
||||
|
|
@ -39,6 +39,16 @@ public partial class CombatManager
|
|||
private DateTime _ammoDequipAt = DateTime.MinValue, _ammoDequipRestUntil = DateTime.MinValue;
|
||||
private const double AmmoDequipResolveMs = 2500;
|
||||
private const int AmmoDequipMaxTries = 3;
|
||||
// When the old ammo first read out of the ammunition slot (MinValue = not seen yet).
|
||||
private DateTime _ammoOffSeenAt = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// How long the launcher waits once the old ammo reads off (2026-10-12). Before, the dequip
|
||||
/// held the launcher for the swap gate's full 3 s (a pack move) and then the equip pacing's
|
||||
/// 2 s, so a mixed-launcher swap took 5-6 s. Ammo has no unwield motion, and the server's own
|
||||
/// drop to peace mode is waited out by the combat tick's animation gate. Settable for tests.
|
||||
/// </summary>
|
||||
internal double AmmoOffSettleMs { get; set; } = 400;
|
||||
|
||||
private readonly HashSet<int> _noAmmoNoted = new();
|
||||
|
||||
|
|
@ -56,6 +66,7 @@ public partial class CombatManager
|
|||
_ammoFollowUpUntil = DateTime.MinValue;
|
||||
_ammoDequipPendingId = _ammoDequipTries = 0;
|
||||
_ammoDequipRestUntil = DateTime.MinValue;
|
||||
_ammoOffSeenAt = DateTime.MinValue;
|
||||
_noAmmoNoted.Clear();
|
||||
}
|
||||
|
||||
|
|
@ -186,14 +197,22 @@ public partial class CombatManager
|
|||
var wielded = pack.FirstOrDefault(a => a.Wielded);
|
||||
if (wielded != null && MissileAmmo.Fits(lt, wielded.AmmoType))
|
||||
{
|
||||
_ammoDequipPendingId = 0; _ammoDequipTries = 0;
|
||||
_ammoDequipPendingId = 0; _ammoDequipTries = 0; _ammoOffSeenAt = DateTime.MinValue;
|
||||
return AmmoPrep.Ready; // same ammo type: it stays
|
||||
}
|
||||
if (pack.Any(a => !a.Wielded && MissileAmmo.Fits(lt, a.AmmoType)))
|
||||
ArmAmmoFollowUp(launcherId, now);
|
||||
if (wielded == null)
|
||||
{
|
||||
_ammoDequipPendingId = 0; _ammoDequipTries = 0;
|
||||
// Our own dequip just landed: a short settle, then the swap gate is told the move is
|
||||
// done so the launcher goes on the server's answers rather than its full 3 s.
|
||||
if (_ammoDequipPendingId != 0)
|
||||
{
|
||||
if (_ammoOffSeenAt == DateTime.MinValue) _ammoOffSeenAt = now;
|
||||
if ((now - _ammoOffSeenAt).TotalMilliseconds < AmmoOffSettleMs) return AmmoPrep.Busy;
|
||||
_weaponSwapGate?.MoveDone(_ammoDequipPendingId);
|
||||
}
|
||||
_ammoDequipPendingId = 0; _ammoDequipTries = 0; _ammoOffSeenAt = DateTime.MinValue;
|
||||
return AmmoPrep.Ready;
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +243,9 @@ public partial class CombatManager
|
|||
_ammoDequipPendingId = wielded.Id;
|
||||
_ammoDequipAt = now;
|
||||
_ammoDequipTries++;
|
||||
_lastEquipTime = now;
|
||||
_ammoOffSeenAt = DateTime.MinValue;
|
||||
// No _lastEquipTime stamp: its 2 s equip pacing would hold the launcher after the ammo is
|
||||
// already off. Busy above (until it reads off and settles) does the waiting instead.
|
||||
_host.Log($"[EquipDiag] {MissileAmmo.Label(wielded.AmmoType)} 0x{(uint)wielded.Id:X8} '{wielded.Name}' x{amount} -> pack 0x{(uint)packId:X8} before wielding 0x{(uint)launcherId:X8} '{WeaponName(launcherId)}' (try {_ammoDequipTries}/{AmmoDequipMaxTries})");
|
||||
return AmmoPrep.Busy;
|
||||
}
|
||||
|
|
@ -238,6 +259,26 @@ public partial class CombatManager
|
|||
|
||||
private void EndAmmoFollowUp() { _ammoFollowUpFor = 0; _ammoFollowUpUntil = DateTime.MinValue; }
|
||||
|
||||
/// <summary>
|
||||
/// True while ChangeCombatMode(Missile) must wait for <paramref name="launcherId"/> (not yet
|
||||
/// read in hand): combat is swapping to it and it, or its ammo, isn't on yet. Each request in
|
||||
/// that window was bounced by the server (no launcher, or no ammo) and flickered the stance
|
||||
/// Missile/peace/Melee for the whole swap; it also stayed the outstanding server action for
|
||||
/// 2 s, which held the swap gate at its full 3 s per step (2026-10-11 14:45:11-17). Once the
|
||||
/// launcher reads in hand, the wielded branch sends the stance after the ammo is on.
|
||||
/// Thrown weapons and launchers of an unknown type: false (as before).
|
||||
/// </summary>
|
||||
private bool LauncherSwapHoldsStance(int launcherId)
|
||||
{
|
||||
int lt = LauncherTypeOf(_worldFilter[launcherId]);
|
||||
if (lt == 0) return false;
|
||||
if (_ammoDequipPendingId != 0) return true; // old ammo going into the pack
|
||||
if (_ammoFollowUpFor == launcherId && AmmoSwapInProgress) return true; // its ammo goes on once it lands
|
||||
if (SwapTracker.PendingId == launcherId) return true; // its wield is in flight
|
||||
var wielded = PackAmmo().FirstOrDefault(a => a.Wielded);
|
||||
return wielded != null && !MissileAmmo.Fits(lt, wielded.AmmoType); // the wrong ammo is still on
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Step 3, with <paramref name="launcherId"/> confirmed in hand. True while the attack should
|
||||
/// wait for the ammo wield. Only after combat's own launcher swap: an empty quiver otherwise is
|
||||
|
|
@ -253,7 +294,7 @@ public partial class CombatManager
|
|||
if (wo == null || lt == 0) { EndAmmoFollowUp(); return false; }
|
||||
|
||||
SwapTracker.Confirmed(launcherId, now); // the launcher landed
|
||||
if (AmmoTracker.PendingId != 0 && ServerRefusedSinceSend()) AmmoTracker.Refused(now, WeaponName);
|
||||
FoldServerAnswer(AmmoTracker, now);
|
||||
|
||||
var pack = PackAmmo();
|
||||
var wielded = pack.FirstOrDefault(a => a.Wielded);
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ public partial class CombatManager
|
|||
private bool OffhandFollowUp(WorldObject target, MonsterRule? rule, int mainId)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
if (OffhandTracker.PendingId != 0 && ServerRefusedSinceSend()) OffhandTracker.Refused(now, WeaponName);
|
||||
FoldServerAnswer(OffhandTracker, now);
|
||||
var plan = OffhandPlanFor(target, rule, mainId);
|
||||
int off = OffhandInSlot();
|
||||
|
||||
|
|
|
|||
|
|
@ -291,6 +291,14 @@ public partial class CombatManager : IDisposable
|
|||
public Func<bool>? HoldIdlePeace { get; set; }
|
||||
private bool _idlePeaceHeldLogged;
|
||||
|
||||
/// <summary>
|
||||
/// True = don't lock a new target yet. RynthAi answers true with Boost Loot Priority on while
|
||||
/// our kill's corpse forms or is looted (RynthAiPlugin.BoostLootHoldsNewTarget): one kill, one
|
||||
/// loot. A monster within CloseAttackYards is still fought at once. Null = never hold.
|
||||
/// </summary>
|
||||
public Func<bool>? HoldNewTarget { get; set; }
|
||||
private bool _newTargetHeldLogged;
|
||||
|
||||
/// <summary>
|
||||
/// RynthAi's mana reserve (BuffManager.OffensiveCastHold): given the attack or debuff spell
|
||||
/// about to be cast, a reason to hold it (mana under its cost, or under the reserve kept for
|
||||
|
|
@ -397,6 +405,8 @@ public partial class CombatManager : IDisposable
|
|||
private int _pendingJudgeTargetId = 0;
|
||||
private bool _damageSincePendingCast;
|
||||
private DateTime _targetLockedAt = DateTime.MinValue;
|
||||
// The current lock replaced another live target (a switch), not a lock after a kill or drop.
|
||||
private bool _lockWasSwitch;
|
||||
private DateTime _lastDamageDealtAt = DateTime.MinValue;
|
||||
|
||||
// ── Server attack binding (the 2026-09-29 melee stall) ───────────────────
|
||||
|
|
@ -421,6 +431,8 @@ public partial class CombatManager : IDisposable
|
|||
private DateTime _lastMissAt = DateTime.MinValue;
|
||||
private DateTime _lastKillAt = DateTime.MinValue; // stall-watchdog evidence only; metas and the status feed read the plugin's KillClock
|
||||
private string _lastSwingEvidenceKind = "none";
|
||||
// Missile at point blank with the target behind: the server doesn't rotate, so one heading snap.
|
||||
private readonly PointBlankFacing _pointBlankFacing = new();
|
||||
|
||||
private readonly CombatStallWatchdog _stallWatch = new();
|
||||
|
||||
|
|
@ -727,6 +739,28 @@ public partial class CombatManager : IDisposable
|
|||
/// </summary>
|
||||
public bool IsUnderCloseAttack => IsActivelyEngaged || HasCloseThreat(CloseAttackYards);
|
||||
|
||||
/// <summary>
|
||||
/// HoldNewTarget says wait (Boost Loot Priority, a kill's corpse to loot) and no monster is
|
||||
/// within CloseAttackYards. One log line per hold.
|
||||
/// </summary>
|
||||
private bool NewTargetHeldForLoot()
|
||||
{
|
||||
bool held;
|
||||
try { held = HoldNewTarget?.Invoke() == true && !HasCloseThreat(CloseAttackYards); }
|
||||
catch { held = false; }
|
||||
if (!held)
|
||||
{
|
||||
_newTargetHeldLogged = false;
|
||||
return false;
|
||||
}
|
||||
if (!_newTargetHeldLogged)
|
||||
{
|
||||
_newTargetHeldLogged = true;
|
||||
_host.Log("[CombatTarget] next target waits: Boost Loot Priority loots the kill first");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pure predicate for the ActivityArbiter: should Combat claim this tick?
|
||||
/// True iff we're already locked on a target, OR a scanned target (the
|
||||
|
|
@ -1402,9 +1436,13 @@ public partial class CombatManager : IDisposable
|
|||
_damageStore!.RecordTaken(src, name, ElementFromWord(m.Groups["type"].Value), amount);
|
||||
}
|
||||
|
||||
public void HandleChatForDamage(string text)
|
||||
/// <summary>A chat line for the damage meter and the stall watchdog.
|
||||
/// <paramref name="chatType"/> is the line's eChatTypes (-1 = not known).</summary>
|
||||
public void HandleChatForDamage(string text, int chatType = -1)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return;
|
||||
// Combat lines come from the server; one in a player's chat type is someone's imitation.
|
||||
if (RynthCore.Plugin.Shared.ChatSource.IsPlayerAuthored(chatType)) return;
|
||||
// A miss is a swing too (stall watchdog). "You evaded X!" is the monster's miss, not ours.
|
||||
if (text.IndexOf(" evaded your attack", StringComparison.OrdinalIgnoreCase) > 0)
|
||||
NoteSwingEvidence("miss");
|
||||
|
|
@ -3242,6 +3280,15 @@ public partial class CombatManager : IDisposable
|
|||
ClearCombatTurnMotions();
|
||||
}
|
||||
|
||||
// The exception to "missile never turns": a target at point blank with the character's
|
||||
// back to it (PointBlankFacing). One snap, then the attack waits for it to settle.
|
||||
if (HoldForPointBlankFacing(currentDist))
|
||||
{
|
||||
LastCombatSkipReason = "point-blank-face"; // D4 record-only
|
||||
_tickWait = CombatLatencyTracker.Wait.Face;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Don't attack in missile mode without ammo
|
||||
if (CurrentCombatMode == CombatMode.Missile && !HasWieldedAmmo())
|
||||
{
|
||||
|
|
@ -3498,7 +3545,9 @@ public partial class CombatManager : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
var act = _stallWatch.Tick(now, eligible, _lastSwingEvidenceAt, out double stalledMs, quiet);
|
||||
double stallAfter = mode == CombatMode.Missile && currentDist <= CombatStallWatchdog.PointBlankMissileM
|
||||
? CombatStallWatchdog.PointBlankStallMs : CombatStallWatchdog.StallMs;
|
||||
var act = _stallWatch.Tick(now, eligible, _lastSwingEvidenceAt, out double stalledMs, quiet, stallAfter);
|
||||
switch (act)
|
||||
{
|
||||
case CombatStallWatchdog.StallAction.None:
|
||||
|
|
@ -3527,6 +3576,8 @@ public partial class CombatManager : IDisposable
|
|||
{
|
||||
case CombatStallWatchdog.StallAction.Reissue:
|
||||
{
|
||||
// A re-issue alone never fixed a point-blank target behind the character.
|
||||
HoldForPointBlankFacing(currentDist, force: true);
|
||||
ReleaseServerAttack("stall watchdog", log: false);
|
||||
lastAttackCmd = AttackAfterCancel(now); // the attack goes out again once the cancel has landed
|
||||
_ghostCheck.Arm(activeTargetId, now, TargetSpot(activeTargetId));
|
||||
|
|
@ -3866,6 +3917,8 @@ public partial class CombatManager : IDisposable
|
|||
|
||||
public void OnHeartbeat()
|
||||
{
|
||||
NoteSwapPortal();
|
||||
|
||||
if (!_settings.IsMacroRunning)
|
||||
{
|
||||
// Clear turn motions once on the transition from running → stopped,
|
||||
|
|
@ -3962,6 +4015,10 @@ public partial class CombatManager : IDisposable
|
|||
{
|
||||
if (_scannedTargets.Count == 0) return;
|
||||
if (TryLockForcedTarget()) return; // Target lock (/ra targetlock): CombatManager.TargetLock.cs
|
||||
// Boost Loot Priority: the next target waits for the last kill's corpse. Without this the
|
||||
// next lock went out a few ms after each kill, 1-3 s before ACE creates the corpse, so the
|
||||
// arbiter always saw combat engaged and corpses were looted in batches (2026-10-14).
|
||||
if (_lockedTargetId == 0 && NewTargetHeldForLoot()) return;
|
||||
|
||||
DateTime now = TargetClock();
|
||||
double acquireRange = Math.Max(1.0, _settings.MonsterRange);
|
||||
|
|
@ -4057,6 +4114,7 @@ public partial class CombatManager : IDisposable
|
|||
private void LockTarget(ScannedTarget best, int bestPriority, string picked, string? switchWhy)
|
||||
{
|
||||
int bestId = best.Id;
|
||||
_lockWasSwitch = _lockedTargetId != 0 && _lockedTargetId != bestId;
|
||||
if (_lockedTargetId != 0)
|
||||
_host.Log($"[CombatTarget] switch 0x{_lockedTargetId:X8} '{_worldFilter[_lockedTargetId]?.Name}' ({switchWhy}, {DescribeTargetPos(_lockedTargetId)}) " +
|
||||
$"-> 0x{bestId:X8} '{_worldFilter[bestId]?.Name}' ({picked})");
|
||||
|
|
@ -4278,8 +4336,12 @@ public partial class CombatManager : IDisposable
|
|||
if (ctype == 0 && _slayerTypeUnknownNoted.TryAdd(wcid != 0 ? wcid.ToString() : target.Name ?? "", 0))
|
||||
_host.Log($"[EquipDiag] '{target.Name}' (wcid {wcid}): creature type not known yet (not appraised, not in the creature data) - no slayer check until it is");
|
||||
}
|
||||
// A weakness swap must beat the weapon in hand by WeaponSwapMinGainPct, but only while no
|
||||
// swap is under way: a launcher whose ammo already went into the pack is never kept.
|
||||
double minGain = _settings.WeaponSwapMinGainPct > 0 && SwapHoldsAllowed(InHandWeaponId())
|
||||
? _settings.WeaponSwapMinGainPct / 100.0 : 0;
|
||||
return WeaponPlanner.Choose(listed, ruleElement, weak, e => CanCastElement(e, rule),
|
||||
fixedId, fixedSource, learnedId, ctype, fixedIsDefault);
|
||||
fixedId, fixedSource, learnedId, ctype, fixedIsDefault, minGain);
|
||||
}
|
||||
|
||||
// PropertyInt 166 SlayerCreatureType, PropertyFloat 138 SlayerDamageBonus (ACE.Entity).
|
||||
|
|
@ -4506,7 +4568,7 @@ public partial class CombatManager : IDisposable
|
|||
private WeaponSwapTracker.Step SwapStep(int chosenId, int inHandId)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
if (SwapTracker.PendingId != 0 && ServerRefusedSinceSend()) SwapTracker.Refused(now, WeaponName);
|
||||
FoldServerAnswer(SwapTracker, now);
|
||||
var step = SwapTracker.Next(chosenId, inHandId, now, WeaponName, forKey: activeTargetId);
|
||||
if (SwapTracker.Notice != null)
|
||||
{
|
||||
|
|
@ -4523,6 +4585,72 @@ public partial class CombatManager : IDisposable
|
|||
|
||||
private DateTime _lastSwapHoldLogAt = DateTime.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Why a swap the tracker allows should not start now (null = start it). Settling: the
|
||||
/// target was switched to (it replaced another live target) under WeaponSwapSettleMs ago;
|
||||
/// wait (Kelpie 2026-10-14 11:41:06: the crossbow swap sent, then a switch to another monster
|
||||
/// 230 ms later). A lock after a kill or a drop swaps at once: in Kelpie's 2026-10-14/15 logs
|
||||
/// 2-4% of those were followed by a quick switch, and waiting on every one put 0.75 s in front
|
||||
/// of 22 of 25 swaps that went ahead anyway. Not settling: keep the weapon in hand, because
|
||||
/// the target is at or under WeaponSwapMinHealthPct (same kind of weapon only). Never once a
|
||||
/// swap is under way (SwapHoldsAllowed), so a launcher is never kept after its ammo went into
|
||||
/// the pack.
|
||||
/// </summary>
|
||||
private string? SwapDeferReason(WorldObject target, int chosenId, int inHand, out bool settling)
|
||||
{
|
||||
settling = false;
|
||||
if (!SwapHoldsAllowed(inHand)) return null;
|
||||
|
||||
int settleMs = _settings.WeaponSwapSettleMs;
|
||||
if (settleMs > 0 && _lockWasSwitch && _lockedTargetId == target.Id && _targetLockedAt != DateTime.MinValue)
|
||||
{
|
||||
double lockedMs = (DateTime.Now - _targetLockedAt).TotalMilliseconds;
|
||||
if (lockedMs >= 0 && lockedMs < settleMs)
|
||||
{
|
||||
settling = true;
|
||||
return $"target switched {lockedMs:0} ms ago";
|
||||
}
|
||||
}
|
||||
|
||||
int minHealth = _settings.WeaponSwapMinHealthPct;
|
||||
if (minHealth > 0 && WeaponKind(inHand) != 0 && WeaponKind(inHand) == WeaponKind(chosenId))
|
||||
{
|
||||
float ratio = _worldFilter.GetHealthRatio(target.Id);
|
||||
if (ratio >= 0f && ratio * 100f <= minHealth)
|
||||
return $"target at {ratio * 100f:0}% health";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True when a swap rule may keep or delay with <paramref name="inHand"/>: nothing of a swap
|
||||
/// is under way (no wield in flight, no old ammo or off hand on its way into the pack, no
|
||||
/// ammo follow-up armed), and a launcher in hand has fitting ammo on, so it can shoot.
|
||||
/// </summary>
|
||||
private bool SwapHoldsAllowed(int inHand)
|
||||
{
|
||||
if (inHand == 0 || SwapTracker.PendingId != 0) return false;
|
||||
if (_ammoDequipPendingId != 0 || AmmoSwapInProgress || _offDequipPendingId != 0) return false;
|
||||
int lt = LauncherTypeOf(_worldFilter[inHand]);
|
||||
if (lt == 0) return true;
|
||||
var wielded = PackAmmo().FirstOrDefault(a => a.Wielded);
|
||||
return wielded != null && MissileAmmo.Fits(lt, wielded.AmmoType);
|
||||
}
|
||||
|
||||
// Last swap deferral logged: (chosen, in hand, reason kind) and when.
|
||||
private (int Chosen, int Hand, bool Settle) _lastSwapDeferLogged;
|
||||
private DateTime _lastSwapDeferLogAt = DateTime.MinValue;
|
||||
|
||||
private void LogSwapDefer(int chosenId, int inHand, string why)
|
||||
{
|
||||
var key = (chosenId, inHand, why.StartsWith("target switched", StringComparison.Ordinal));
|
||||
DateTime now = DateTime.Now;
|
||||
if (key == _lastSwapDeferLogged && (now - _lastSwapDeferLogAt).TotalSeconds < 10) return;
|
||||
_lastSwapDeferLogged = key;
|
||||
_lastSwapDeferLogAt = now;
|
||||
_host.Log($"[EquipDiag] not swapping 0x{(uint)inHand:X8} '{WeaponName(inHand)}' for 0x{(uint)chosenId:X8} '{WeaponName(chosenId)}' yet ({why})");
|
||||
}
|
||||
|
||||
private string WeaponName(int id) => id == 0 ? "" : (_worldFilter[id]?.Name ?? "");
|
||||
|
||||
/// <summary>Send one combat wield of <paramref name="weaponId"/> and tell the swap tracker.</summary>
|
||||
|
|
@ -4546,21 +4674,71 @@ public partial class CombatManager : IDisposable
|
|||
_lastEquipTime = now;
|
||||
}
|
||||
|
||||
/// <summary>A WeenieError, or a UseDone with an error, arrived after the wield was sent.</summary>
|
||||
private bool ServerRefusedSinceSend()
|
||||
// The character was in portal space at the last heartbeat (a portal, recall or teleport).
|
||||
private bool _swapSawPortal;
|
||||
|
||||
/// <summary>On leaving portal space, the swap tracker forgets tries and rests from the old place.</summary>
|
||||
private void NoteSwapPortal()
|
||||
{
|
||||
if (_host.HasGetLastWeenieError && _host.TryGetLastWeenieError(out int wSeq, out uint wErr, out _, out _)
|
||||
&& wSeq != _swapWeenieSeq && wErr != 0)
|
||||
bool inPortal;
|
||||
try { inPortal = _host.HasIsPortaling && _host.IsPortaling(); }
|
||||
catch { return; } // a failed read must never stop the heartbeat
|
||||
if (inPortal) { _swapSawPortal = true; return; }
|
||||
if (!_swapSawPortal) return;
|
||||
_swapSawPortal = false;
|
||||
SwapTracker.NewPlace();
|
||||
AmmoTracker.NewPlace();
|
||||
OffhandTracker.NewPlace();
|
||||
}
|
||||
|
||||
private enum WieldAnswer { None, Refused, Busy }
|
||||
|
||||
/// <summary>
|
||||
/// Folds the server's answer to the wield <paramref name="tracker"/> has in flight into it: a
|
||||
/// refusal is a failed try, 'too busy' is not (logged).
|
||||
/// </summary>
|
||||
private void FoldServerAnswer(WeaponSwapTracker tracker, DateTime now)
|
||||
{
|
||||
int pending = tracker.PendingId;
|
||||
if (pending == 0) return;
|
||||
switch (ServerAnswerSinceSend())
|
||||
{
|
||||
case WieldAnswer.Refused:
|
||||
tracker.Refused(now, WeaponName);
|
||||
break;
|
||||
case WieldAnswer.Busy:
|
||||
if (tracker.Busy(now, WeaponName))
|
||||
_host.Log($"[EquipDiag] wield of 0x{(uint)pending:X8} '{WeaponName(pending)}' answered 'too busy': not counted, again in {tracker.BusyRetryMs / 1000:0.#} s");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// GameEvent InventoryServerSaveFailed: the server refused an inventory change.
|
||||
private const uint InventorySaveFailedEvent = 0x00A0;
|
||||
|
||||
/// <summary>
|
||||
/// What the server said to the wield since it was sent. Busy: 'too busy' (0x1D), or an
|
||||
/// InventoryServerSaveFailed with no error. ACE answers a wield while busy (a recall, a
|
||||
/// portal, an animation) with a WeenieError 0x1D and then that SaveFailed, and the engine
|
||||
/// keeps only the last record, so the 0x1D is usually read as "error 0" (flight recorder
|
||||
/// 2026-10-15 00:44:23-31: three of these, read as no answer, cost all 3 tries).
|
||||
/// </summary>
|
||||
private WieldAnswer ServerAnswerSinceSend()
|
||||
{
|
||||
if (_host.HasGetLastWeenieError && _host.TryGetLastWeenieError(out int wSeq, out uint wErr, out uint wEvt, out _)
|
||||
&& wSeq != _swapWeenieSeq)
|
||||
{
|
||||
_swapWeenieSeq = wSeq;
|
||||
return true;
|
||||
if (wErr == ActionPacer.TooBusyErr || (wEvt == InventorySaveFailedEvent && wErr == 0)) return WieldAnswer.Busy;
|
||||
if (wErr != 0) return WieldAnswer.Refused;
|
||||
}
|
||||
if (_host.HasGetLastUseDone && _host.TryGetLastUseDone(out int uSeq, out uint uErr) && uSeq != _swapUseDoneSeq)
|
||||
{
|
||||
_swapUseDoneSeq = uSeq;
|
||||
return uErr != 0;
|
||||
if (uErr == ActionPacer.TooBusyErr) return WieldAnswer.Busy;
|
||||
if (uErr != 0) return WieldAnswer.Refused;
|
||||
}
|
||||
return false;
|
||||
return WieldAnswer.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -4704,6 +4882,23 @@ public partial class CombatManager : IDisposable
|
|||
{
|
||||
var step = SwapStep(targetWeaponId, inHand);
|
||||
if (step == WeaponSwapTracker.Step.Wait) { if (inHand != 0) _equippedWeaponId = inHand; return false; }
|
||||
if (step == WeaponSwapTracker.Step.Swap && inHand != 0
|
||||
&& SwapDeferReason(target, targetWeaponId, inHand, out bool settling) is string defer)
|
||||
{
|
||||
LogSwapDefer(targetWeaponId, inHand, defer);
|
||||
if (settling)
|
||||
{
|
||||
_equippedWeaponId = inHand;
|
||||
LastCombatSkipReason = "swap-settle";
|
||||
return false;
|
||||
}
|
||||
if (_worldFilter[inHand] is WorldObject deferKeep)
|
||||
{
|
||||
weaponSource = $"in hand ({defer}); wanted 0x{(uint)targetWeaponId:X8}";
|
||||
targetWeaponId = inHand;
|
||||
weaponObj = deferKeep;
|
||||
}
|
||||
}
|
||||
if (step == WeaponSwapTracker.Step.Hold)
|
||||
{
|
||||
if (inHand != 0 && _worldFilter[inHand] is WorldObject handObj)
|
||||
|
|
@ -5008,12 +5203,20 @@ public partial class CombatManager : IDisposable
|
|||
MarkWieldSent(targetWeaponId, inHand);
|
||||
_lastEquipTime = DateTime.Now;
|
||||
}
|
||||
if ((DateTime.Now - lastStanceAttempt).TotalMilliseconds > StanceRetryDelayMs()
|
||||
&& _host.ChangeCombatModeFor(desiredMode, "Combat", "stance"))
|
||||
if ((DateTime.Now - lastStanceAttempt).TotalMilliseconds > StanceRetryDelayMs())
|
||||
{
|
||||
if (diagNow) { _lastEquipDiagAt = DateTime.Now; _host.Log($"[EquipDiag] wielded=FALSE mode={CurrentCombatMode}→{desiredMode} (weapon=0x{targetWeaponId:X8} '{weaponObj.Name}' src={weaponSource} class={weaponObj.ObjectClass}) — ChangeCombatMode"); }
|
||||
lastStanceAttempt = DateTime.Now;
|
||||
NoteStanceFlipSent();
|
||||
// A launcher swap: no Missile request until the launcher and its ammo are on (the
|
||||
// wielded branch above sends it then). See LauncherSwapHoldsStance.
|
||||
if (desiredMode == CombatMode.Missile && LauncherSwapHoldsStance(targetWeaponId))
|
||||
{
|
||||
if (diagNow) { _lastEquipDiagAt = DateTime.Now; _host.Log($"[EquipDiag] stance held: 0x{targetWeaponId:X8} '{weaponObj.Name}' or its ammo isn't on yet (mode={CurrentCombatMode})"); }
|
||||
}
|
||||
else if (_host.ChangeCombatModeFor(desiredMode, "Combat", "stance"))
|
||||
{
|
||||
if (diagNow) { _lastEquipDiagAt = DateTime.Now; _host.Log($"[EquipDiag] wielded=FALSE mode={CurrentCombatMode}→{desiredMode} (weapon=0x{targetWeaponId:X8} '{weaponObj.Name}' src={weaponSource} class={weaponObj.ObjectClass}) — ChangeCombatMode"); }
|
||||
lastStanceAttempt = DateTime.Now;
|
||||
NoteStanceFlipSent();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -5375,6 +5578,29 @@ public partial class CombatManager : IDisposable
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Missile only: snap the heading to a point-blank target the character faces away from
|
||||
/// (<see cref="PointBlankFacing"/>). <paramref name="force"/> skips the no-shot wait (the
|
||||
/// stall watchdog's re-issue already waited longer). True = a snap was just sent or is still
|
||||
/// settling, so don't attack this tick.
|
||||
/// </summary>
|
||||
private bool HoldForPointBlankFacing(double currentDist, bool force = false)
|
||||
{
|
||||
if (CurrentCombatMode != CombatMode.Missile || !_host.HasTurnToHeading) return false;
|
||||
DateTime now = DateTime.Now;
|
||||
int tid = activeTargetId;
|
||||
if (_pointBlankFacing.Settling(now, tid)) return true;
|
||||
if (!TryGetHeadingTo(tid, out double desiredDeg, out double error)) return false;
|
||||
DateTime evidence = force ? DateTime.MinValue : _lastSwingEvidenceAt;
|
||||
if (!_pointBlankFacing.ShouldSnap(now, tid, currentDist, error, evidence)) return false;
|
||||
if (!_host.TurnToHeadingBy("Combat/PointBlank", (float)desiredDeg)) return false; // held by the pacer: attack as is
|
||||
_pointBlankFacing.Snapped(now, tid);
|
||||
_host.Log($"[Combat] point blank: turning to 0x{(uint)tid:X8} ({error:0} deg off at {currentDist:0.0} m, " +
|
||||
$"last shot {(_lastSwingEvidenceAt == DateTime.MinValue ? "never" : $"{(now - _lastSwingEvidenceAt).TotalSeconds:0.0}s ago")}" +
|
||||
$"{(force ? ", stall re-issue" : "")}; snaps={_pointBlankFacing.Snaps})");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>The heading from the player to <paramref name="targetId"/> (0 = north, clockwise)
|
||||
/// and how far the player's facing is off it (absolute degrees).</summary>
|
||||
private bool TryGetHeadingTo(int targetId, out double desiredDeg, out double absError)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,18 @@ internal sealed class CombatStallWatchdog
|
|||
/// it at once every time, so most of the 7-9 s per stall was the wait).</summary>
|
||||
public const double QuietStallMs = 2500;
|
||||
|
||||
/// <summary>
|
||||
/// The stall time for a missile attack at point blank (target within
|
||||
/// <see cref="PointBlankMissileM"/>). Silentkelpie 2026-10-14: 22 of 40 missile stalls were
|
||||
/// at 1.5-2.5 m, and step 1 (re-issue) brought the swings back within half a second in most
|
||||
/// of them, so the 6 s wait was the whole cost. A bow or crossbow there shows a hit or miss
|
||||
/// every 1.5-2 s.
|
||||
/// </summary>
|
||||
public const double PointBlankStallMs = 3500;
|
||||
|
||||
/// <summary>Missile targets this close (metres) use <see cref="PointBlankStallMs"/>.</summary>
|
||||
public const double PointBlankMissileM = 3.0;
|
||||
|
||||
/// <summary>Time allowed for each step to show a swing before the next one.</summary>
|
||||
public const double StepMs = 3000;
|
||||
|
||||
|
|
@ -70,11 +82,14 @@ internal sealed class CombatStallWatchdog
|
|||
/// Advance the watchdog. <paramref name="eligible"/> is the full precondition set;
|
||||
/// <paramref name="lastEvidenceAt"/> the last hit, miss or kill. <paramref name="quiet"/>:
|
||||
/// the caller sees no swing playing and the character standing still (step 1 after
|
||||
/// <see cref="QuietStallMs"/>). Returns the step to carry out now (or Recovered / GaveUp for
|
||||
/// logging), with the stalled time.
|
||||
/// <see cref="QuietStallMs"/>). <paramref name="stallAfterMs"/>: how long without evidence
|
||||
/// starts an episode otherwise (0 = <see cref="StallMs"/>). Returns the step to carry out now
|
||||
/// (or Recovered / GaveUp for logging), with the stalled time.
|
||||
/// </summary>
|
||||
public StallAction Tick(DateTime now, bool eligible, DateTime lastEvidenceAt, out double stalledMs, bool quiet = false)
|
||||
public StallAction Tick(DateTime now, bool eligible, DateTime lastEvidenceAt, out double stalledMs,
|
||||
bool quiet = false, double stallAfterMs = 0)
|
||||
{
|
||||
if (stallAfterMs <= 0) stallAfterMs = StallMs;
|
||||
stalledMs = 0;
|
||||
bool gap = _lastTick != DateTime.MinValue
|
||||
&& (now - _lastTick).TotalMilliseconds > TickGapResetMs;
|
||||
|
|
@ -108,8 +123,8 @@ internal sealed class CombatStallWatchdog
|
|||
if (_step == 0)
|
||||
{
|
||||
bool early = quiet && stalledMs >= QuietStallMs;
|
||||
if (stalledMs < StallMs && !early) return StallAction.None;
|
||||
LastFireWasEarly = stalledMs < StallMs;
|
||||
if (stalledMs < stallAfterMs && !early) return StallAction.None;
|
||||
LastFireWasEarly = stalledMs < stallAfterMs;
|
||||
Episodes++;
|
||||
_stallRef = refAt;
|
||||
return Fire(now);
|
||||
|
|
|
|||
|
|
@ -102,9 +102,20 @@ public class FellowshipTracker : IDisposable
|
|||
private const int OFF_ENTRY_LEVEL = 0x0C;
|
||||
private const int OFF_ENTRY_NEXT = 0x34;
|
||||
|
||||
/// <summary>
|
||||
/// Most members read. Retail caps a fellowship at 9, but servers raise it: ACECustom
|
||||
/// (Infinite Leaftide) allows 29. A count above this is treated as a torn read.
|
||||
/// </summary>
|
||||
public const int MaxMembers = 64;
|
||||
|
||||
/// <summary>Most hash buckets walked (AC sizes the member table at 16; a larger value is a torn read).</summary>
|
||||
internal const int MaxBuckets = 256;
|
||||
|
||||
// Replaced whole on each refresh, never changed in place: the radar snapshot (engine pump
|
||||
// thread) reads it while RynthAi's own thread may be refreshing it.
|
||||
private volatile Dictionary<int, string> _memberCache = new();
|
||||
// Member levels by id, replaced together with _memberCache.
|
||||
private volatile Dictionary<int, int> _levelCache = new();
|
||||
private DateTime _lastRefresh = DateTime.MinValue;
|
||||
private const double REFRESH_INTERVAL_MS = 2000;
|
||||
|
||||
|
|
@ -263,6 +274,28 @@ public class FellowshipTracker : IDisposable
|
|||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>A member's level from the last read, or 0 when unknown.</summary>
|
||||
public int GetMemberLevel(int characterId)
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
return _levelCache.TryGetValue(characterId, out int level) ? level : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The members from one read: id, name and level, in table order. Use this rather than
|
||||
/// MemberCount with GetMemberId/GetMemberName, which can see two different reads.
|
||||
/// </summary>
|
||||
public List<(int Id, string Name, int Level)> GetMembers()
|
||||
{
|
||||
RefreshIfNeeded();
|
||||
Dictionary<int, string> names = _memberCache;
|
||||
Dictionary<int, int> levels = _levelCache;
|
||||
var list = new List<(int, string, int)>(names.Count);
|
||||
foreach (var kvp in names)
|
||||
list.Add((kvp.Key, kvp.Value, levels.TryGetValue(kvp.Key, out int level) ? level : 0));
|
||||
return list;
|
||||
}
|
||||
|
||||
private IntPtr GetFellowshipPtr()
|
||||
{
|
||||
if (!IsReadablePointer(ADDR_FELLOWSHIP_SYSTEM)) return IntPtr.Zero;
|
||||
|
|
@ -281,6 +314,7 @@ public class FellowshipTracker : IDisposable
|
|||
if ((DateTime.Now - _lastRefresh).TotalMilliseconds < REFRESH_INTERVAL_MS) return;
|
||||
_lastRefresh = DateTime.Now;
|
||||
var members = new Dictionary<int, string>();
|
||||
var levels = new Dictionary<int, int>();
|
||||
try
|
||||
{
|
||||
IntPtr fel = GetFellowshipPtr();
|
||||
|
|
@ -296,15 +330,14 @@ public class FellowshipTracker : IDisposable
|
|||
int tableSize = Marshal.ReadInt32(tableSizeAddr);
|
||||
int currNum = Marshal.ReadInt32(currNumAddr);
|
||||
|
||||
// Fellowship caps at 9 members; a corrupt/mid-mutation table_size
|
||||
// here (bogus large value) would otherwise turn the bucket loop
|
||||
// below into an unbounded scan over garbage addresses.
|
||||
if (bucketsPtr == 0 || tableSize == 0 || tableSize > 64 || currNum == 0 || currNum > 9)
|
||||
// A corrupt/mid-mutation table_size or count here (bogus large value) would
|
||||
// otherwise turn the bucket loop below into an unbounded scan over garbage addresses.
|
||||
if (!IsPlausibleTable(bucketsPtr, tableSize, currNum))
|
||||
return;
|
||||
if (!IsReadablePointer(new IntPtr(bucketsPtr)))
|
||||
return;
|
||||
|
||||
int maxMembers = Math.Min(currNum, 9);
|
||||
int maxMembers = currNum;
|
||||
int found = 0;
|
||||
|
||||
for (int b = 0; b < tableSize && found < maxMembers; b++)
|
||||
|
|
@ -317,13 +350,14 @@ public class FellowshipTracker : IDisposable
|
|||
// read racing AC's main thread) must not spin this pump thread
|
||||
// forever — cap the walk independent of the found-count exit.
|
||||
int chainGuard = 0;
|
||||
while (entryPtr != 0 && found < maxMembers && chainGuard++ < 32)
|
||||
while (entryPtr != 0 && found < maxMembers && chainGuard++ < MaxMembers)
|
||||
{
|
||||
IntPtr entry = new IntPtr(entryPtr);
|
||||
if (!IsReadablePointer(entry)) break;
|
||||
|
||||
IntPtr keyAddr = entry + OFF_ENTRY_KEY;
|
||||
IntPtr nameFieldAddr = entry + OFF_ENTRY_NAME_PTR;
|
||||
IntPtr levelAddr = entry + OFF_ENTRY_LEVEL;
|
||||
IntPtr nextAddr = entry + OFF_ENTRY_NEXT;
|
||||
if (!IsReadablePointer(keyAddr) || !IsReadablePointer(nameFieldAddr) || !IsReadablePointer(nextAddr))
|
||||
break;
|
||||
|
|
@ -331,13 +365,22 @@ public class FellowshipTracker : IDisposable
|
|||
int memberId = Marshal.ReadInt32(keyAddr);
|
||||
string name = ReadPString(nameFieldAddr);
|
||||
if (memberId != 0 && !string.IsNullOrEmpty(name))
|
||||
{ members[memberId] = name; found++; }
|
||||
{
|
||||
members[memberId] = name;
|
||||
if (IsReadablePointer(levelAddr)) levels[memberId] = Marshal.ReadInt32(levelAddr);
|
||||
found++;
|
||||
}
|
||||
entryPtr = Marshal.ReadInt32(nextAddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
finally { _memberCache = members; } // also on the early returns (no fellowship: empty)
|
||||
finally
|
||||
{
|
||||
// Also on the early returns (no fellowship: empty). Levels first: readers take names, then levels.
|
||||
_levelCache = levels;
|
||||
_memberCache = members;
|
||||
}
|
||||
}
|
||||
|
||||
private string ReadPString(IntPtr addr)
|
||||
|
|
@ -355,6 +398,13 @@ public class FellowshipTracker : IDisposable
|
|||
catch { return ""; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether a fellowship hash table's header looks real enough to walk: a bucket array, a bucket
|
||||
/// count and member count in range. Internal for the tests.
|
||||
/// </summary>
|
||||
internal static bool IsPlausibleTable(int bucketsPtr, int tableSize, int currNum) =>
|
||||
bucketsPtr != 0 && tableSize > 0 && tableSize <= MaxBuckets && currNum > 0 && currNum <= MaxMembers;
|
||||
|
||||
/// <summary>A fellowship member's name is at most this long (AC names are under 20).</summary>
|
||||
internal const int MaxNameChars = 64;
|
||||
|
||||
|
|
|
|||
64
Plugins/RynthCore.Plugin.RynthAi/Combat/PointBlankFacing.cs
Normal file
64
Plugins/RynthCore.Plugin.RynthAi/Combat/PointBlankFacing.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
using System;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
/// <summary>
|
||||
/// One heading snap for a missile target the character has its back to at point blank.
|
||||
///
|
||||
/// Missile combat normally never turns the character: the server rotates to the target before
|
||||
/// each shot, and a client turn servo on top of that spun archers in circles (2026-09-27, Lucy).
|
||||
/// But with the target inside <see cref="MaxDistanceM"/> the server's rotate doesn't happen, so
|
||||
/// the character stands facing away and fires nothing. Silentkelpie 2026-10-14/15: 7 of 13
|
||||
/// crossbow stalls were at 1.7 m with the target 177 degrees behind; the stall watchdog's
|
||||
/// re-issue never fixed one of them (only dropping the target did, at step 2 or later).
|
||||
///
|
||||
/// So, only when all of these hold, one instant heading snap (TurnToHeading, as for walls):
|
||||
/// * the target is within <see cref="MaxDistanceM"/>,
|
||||
/// * it is more than <see cref="MinErrorDeg"/> off the character's facing,
|
||||
/// * no hit, miss or kill for <see cref="NoShotMs"/> (a full crossbow cycle: a shot in
|
||||
/// progress is never interrupted),
|
||||
/// * no snap for this target within <see cref="RetryMs"/>.
|
||||
/// Combat then holds the attack for <see cref="SettleMs"/> so the turn reaches the server first.
|
||||
/// Pure: the caller passes the time and readings in.
|
||||
/// </summary>
|
||||
internal sealed class PointBlankFacing
|
||||
{
|
||||
/// <summary>Targets this close (metres) count as point blank (the stall watchdog's distance).</summary>
|
||||
public double MaxDistanceM { get; set; } = CombatStallWatchdog.PointBlankMissileM;
|
||||
/// <summary>Facing error (degrees) above which the character is turned.</summary>
|
||||
public double MinErrorDeg { get; set; } = 90;
|
||||
/// <summary>No swing evidence for this long before a snap.</summary>
|
||||
public double NoShotMs { get; set; } = 2500;
|
||||
/// <summary>At most one snap per target this often.</summary>
|
||||
public double RetryMs { get; set; } = 3000;
|
||||
/// <summary>Attack held this long after a snap.</summary>
|
||||
public double SettleMs { get; set; } = 300;
|
||||
|
||||
private int _target;
|
||||
private DateTime _snapAt = DateTime.MinValue;
|
||||
|
||||
/// <summary>Snaps done (diagnostics).</summary>
|
||||
public int Snaps { get; private set; }
|
||||
|
||||
/// <summary>True when the character should be turned to <paramref name="targetId"/> now.</summary>
|
||||
public bool ShouldSnap(DateTime now, int targetId, double distanceM, double facingErrorDeg, DateTime lastEvidenceAt)
|
||||
{
|
||||
if (targetId == 0 || distanceM < 0 || distanceM > MaxDistanceM) return false;
|
||||
if (facingErrorDeg <= MinErrorDeg) return false;
|
||||
if (lastEvidenceAt != DateTime.MinValue && (now - lastEvidenceAt).TotalMilliseconds < NoShotMs) return false;
|
||||
if (targetId == _target && _snapAt != DateTime.MinValue && (now - _snapAt).TotalMilliseconds < RetryMs) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>The snap for <paramref name="targetId"/> was sent.</summary>
|
||||
public void Snapped(DateTime now, int targetId)
|
||||
{
|
||||
_target = targetId;
|
||||
_snapAt = now;
|
||||
Snaps++;
|
||||
}
|
||||
|
||||
/// <summary>True while the attack should wait for the last snap to settle.</summary>
|
||||
public bool Settling(DateTime now, int targetId)
|
||||
=> targetId == _target && _snapAt != DateTime.MinValue && (now - _snapAt).TotalMilliseconds < SettleMs;
|
||||
}
|
||||
|
|
@ -45,7 +45,9 @@ internal readonly record struct WeaponPlan(int WeaponId, string Element, string
|
|||
/// multiplier) down; the first element a listed weapon of the character's main kind has
|
||||
/// wins, and that weapon is wielded. Elements tied on the multiplier count as one step,
|
||||
/// and within a step the weapon in hand wins, then a rending, then the weakness order.
|
||||
/// A caster only counts for elements the character can cast.
|
||||
/// A caster only counts for elements the character can cast. The weapon in hand is kept
|
||||
/// when the winner is of another element and not at least minSwapGain more damage
|
||||
/// (KeepInHand; both multipliers must be known).
|
||||
/// No listed weapon has any of them: keep the one in hand (else the learned best, else
|
||||
/// the first), and cast the weakest element the character can.
|
||||
/// 6. Weakness unknown: keep the weapon in hand (else the learned best, else the first) and
|
||||
|
|
@ -76,7 +78,8 @@ internal static class WeaponPlanner
|
|||
string fixedSource = "Damage tab",
|
||||
int learnedBestId = 0,
|
||||
int creatureType = 0,
|
||||
bool fixedIsDefault = false)
|
||||
bool fixedIsDefault = false,
|
||||
double minSwapGain = 0)
|
||||
{
|
||||
string rule = WeaponElements.Normalize(ruleElement);
|
||||
bool ruleSet = rule.Length > 0;
|
||||
|
|
@ -156,7 +159,13 @@ internal static class WeaponPlanner
|
|||
if (rank < bestRank) { bestRank = rank; best = c; }
|
||||
}
|
||||
if (best != null)
|
||||
{
|
||||
var held = KeepInHand(pool, best, weak, canCast, minSwapGain);
|
||||
if (held != null)
|
||||
return new WeaponPlan(held.Id, held.Element,
|
||||
$"weak to {best.Element} ({weak.Source}); {held.Element} in hand is within {minSwapGain * 100:0}%");
|
||||
return new WeaponPlan(best.Id, best.Element, $"weak to {best.Element} ({weak.Source})");
|
||||
}
|
||||
}
|
||||
|
||||
// No listed weapon has any element of the ranking: keep what we have.
|
||||
|
|
@ -181,6 +190,34 @@ internal static class WeaponPlanner
|
|||
return new WeaponPlan(pool[0].Id, ElementOrFallback(pool[0], canCast), "ItemRules");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Step 5's swap threshold: the weapon in hand, when <paramref name="best"/> is of another
|
||||
/// element and does less than <paramref name="minSwapGain"/> (0.2 = 20%) more damage to the
|
||||
/// monster than it. A swap costs seconds of not attacking (a launcher with other ammo about
|
||||
/// 4 s), so a small edge isn't worth it. Null (swap) when either multiplier isn't known
|
||||
/// (a learned or seeded ranking has the order only), the hand weapon is immune-resisted (0),
|
||||
/// or the threshold is off.
|
||||
/// </summary>
|
||||
public static WeaponCandidate? KeepInHand(IReadOnlyList<WeaponCandidate> pool, WeaponCandidate best,
|
||||
CreatureWeakness.Ranking weak, Func<string, bool> canCast, double minSwapGain)
|
||||
{
|
||||
if (minSwapGain <= 0) return null;
|
||||
var hand = InHand(pool);
|
||||
if (hand == null || hand.Id == best.Id || hand.Element.Length == 0 || hand.Element == best.Element) return null;
|
||||
if (hand.Kind == CombatMode.Magic && !canCast(hand.Element)) return null;
|
||||
double handMult = MultOf(weak, hand.Element), bestMult = MultOf(weak, best.Element);
|
||||
if (double.IsNaN(handMult) || double.IsNaN(bestMult) || handMult <= 0) return null;
|
||||
return bestMult < handMult * (1 + minSwapGain) - TieEpsilon ? hand : null;
|
||||
}
|
||||
|
||||
/// <summary>The ranking's damage multiplier for <paramref name="element"/>; NaN when not listed or not known.</summary>
|
||||
private static double MultOf(CreatureWeakness.Ranking weak, string element)
|
||||
{
|
||||
foreach (var (e, m) in weak.Order)
|
||||
if (e == element) return m;
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ranking's elements grouped by equal multiplier, weakest group first. A learned
|
||||
/// ranking (NaN multipliers) is one element per group.
|
||||
|
|
|
|||
|
|
@ -85,6 +85,20 @@ public sealed class WeaponSwapGate
|
|||
lock (_lock) _movingId = itemId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The caller saw the noted move of <paramref name="itemId"/> finish and settle: the next swap
|
||||
/// is paced on the server's answers (<see cref="FloorMs"/>) instead of the full MinIntervalMs.
|
||||
/// Only for moves with no unwield motion behind them (ammo out of the ammunition slot); a
|
||||
/// weapon or shield pack move keeps the full wait (see <see cref="NoteMove"/>).
|
||||
/// </summary>
|
||||
public void MoveDone(int itemId)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_movingId == itemId) _movingId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private bool LastSwapDone(long since)
|
||||
{
|
||||
if (since < FloorMs || ServerIdle == null || IsWielded == null) return false;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,13 @@ namespace RynthCore.Plugin.RynthAi;
|
|||
/// 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.
|
||||
/// * A swap counts as landed when its weapon reaches the hand, even if the choice moved on
|
||||
/// while it was in flight.
|
||||
/// * A 'too busy' answer (<see cref="Busy"/>) is not a try: the server never looked at the
|
||||
/// weapon. The wield goes again after <see cref="BusyRetryMs"/>, at most
|
||||
/// <see cref="MaxBusyRefunds"/> times per weapon before they count. A portal or recall
|
||||
/// (<see cref="NewPlace"/>) ends every rest (2026-10-15, Silentkelpie: a house recall and a
|
||||
/// portal each spent all 3 tries on 'too busy' and benched the better weapon for 2 min).
|
||||
/// </summary>
|
||||
internal sealed class WeaponSwapTracker
|
||||
{
|
||||
|
|
@ -41,10 +48,14 @@ internal sealed class WeaponSwapTracker
|
|||
public double MinDwellMs { get; set; } = 20_000;
|
||||
public int MaxSwapsPerWindow { get; set; } = 4;
|
||||
public double SwapWindowMs { get; set; } = 60_000;
|
||||
public double BusyRetryMs { get; set; } = 1500;
|
||||
public int MaxBusyRefunds { get; set; } = 6;
|
||||
|
||||
private int _pendingId, _pendingFrom;
|
||||
private DateTime _pendingAt;
|
||||
private DateTime _busyUntil = DateTime.MinValue;
|
||||
private readonly Dictionary<int, int> _tries = new();
|
||||
private readonly Dictionary<int, int> _busyRefunds = new();
|
||||
private readonly Dictionary<int, DateTime> _restUntil = new();
|
||||
private readonly List<DateTime> _landed = new();
|
||||
private int _lastFrom, _lastTo;
|
||||
|
|
@ -69,12 +80,22 @@ internal sealed class WeaponSwapTracker
|
|||
{
|
||||
HoldReason = "";
|
||||
_askKey = forKey;
|
||||
// The weapon in flight reached the hand although the choice has moved on (a new target
|
||||
// wants another one). It still landed: without this the swap timed out as "not seen in
|
||||
// hand", the A -> B landing was never recorded, and the swap straight back to A wasn't
|
||||
// held (Fire -> Piercing -> Fire crossbow 2.5 s apart, 2026-10-14 11:41:06-08).
|
||||
if (_pendingId != 0 && inHandId == _pendingId && inHandId != chosenId)
|
||||
{
|
||||
_tries.Remove(_pendingId);
|
||||
Land(now);
|
||||
}
|
||||
if (chosenId == 0) return Step.InHand;
|
||||
|
||||
if (inHandId == chosenId)
|
||||
{
|
||||
if (_pendingId == chosenId) Land(now);
|
||||
_tries.Remove(chosenId);
|
||||
_busyRefunds.Remove(chosenId);
|
||||
return Step.InHand;
|
||||
}
|
||||
|
||||
|
|
@ -84,6 +105,8 @@ internal sealed class WeaponSwapTracker
|
|||
Fail(now, "not seen in hand", nameOf);
|
||||
}
|
||||
|
||||
if (now < _busyUntil) return Step.Wait;
|
||||
|
||||
if (_restUntil.TryGetValue(chosenId, out DateTime rest) && now < rest)
|
||||
{
|
||||
HoldReason = "resting after failed tries";
|
||||
|
|
@ -124,6 +147,39 @@ internal sealed class WeaponSwapTracker
|
|||
if (_pendingId != 0) Fail(now, "refused by the server", nameOf);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The server answered the wield in flight 'too busy' (a recall, a portal, an animation):
|
||||
/// it never looked at the weapon, so the try is given back and the wield goes again after
|
||||
/// <see cref="BusyRetryMs"/>. Past <see cref="MaxBusyRefunds"/> for one weapon it counts as
|
||||
/// a refusal, so a weapon the server always answers that way still gets rested.
|
||||
/// True when the try was given back.
|
||||
/// </summary>
|
||||
public bool Busy(DateTime now, Func<int, string>? nameOf = null)
|
||||
{
|
||||
int id = _pendingId;
|
||||
if (id == 0) return false;
|
||||
int refunds = _busyRefunds.TryGetValue(id, out int r) ? r : 0;
|
||||
if (refunds >= MaxBusyRefunds) { Fail(now, "server too busy", nameOf); return false; }
|
||||
_busyRefunds[id] = refunds + 1;
|
||||
if (_tries.TryGetValue(id, out int t) && t > 0) _tries[id] = t - 1;
|
||||
_pendingId = _pendingFrom = 0;
|
||||
_busyUntil = now.AddMilliseconds(BusyRetryMs);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character went through a portal or recalled: tries and rests from the last place no
|
||||
/// longer say anything about the weapon (they were spent while the server was busy moving us).
|
||||
/// </summary>
|
||||
public void NewPlace()
|
||||
{
|
||||
_pendingId = _pendingFrom = 0;
|
||||
_tries.Clear();
|
||||
_busyRefunds.Clear();
|
||||
_restUntil.Clear();
|
||||
_busyUntil = DateTime.MinValue;
|
||||
}
|
||||
|
||||
/// <summary>The chosen weapon was seen in hand some other way (the wield-location read).</summary>
|
||||
public void Confirmed(int id, DateTime now)
|
||||
{
|
||||
|
|
@ -135,6 +191,8 @@ internal sealed class WeaponSwapTracker
|
|||
{
|
||||
_pendingId = _pendingFrom = 0;
|
||||
_tries.Clear();
|
||||
_busyRefunds.Clear();
|
||||
_busyUntil = DateTime.MinValue;
|
||||
_restUntil.Clear();
|
||||
_landed.Clear();
|
||||
_lastFrom = _lastTo = 0;
|
||||
|
|
|
|||
|
|
@ -1572,7 +1572,8 @@ public class WorldObjectCache
|
|||
// Snapshot overload — caller supplies an already-built inventory list (AutoCram
|
||||
// reuses its single per-tick GetDirectInventory snapshot here; do NOT re-refresh).
|
||||
public static int FindPackFor(IReadOnlyList<WorldObject> inv, int playerId,
|
||||
bool includeMainPack, int requireFree, RynthCoreHost? host = null)
|
||||
bool includeMainPack, int requireFree, RynthCoreHost? host = null,
|
||||
Func<int, bool>? skip = null)
|
||||
{
|
||||
if (inv == null || playerId == 0) return 0;
|
||||
if (requireFree < 1) requireFree = 1;
|
||||
|
|
@ -1593,6 +1594,7 @@ public class WorldObjectCache
|
|||
// Skip foci — technically containers but reserved for spell components.
|
||||
if (!string.IsNullOrEmpty(p.Name)
|
||||
&& p.Name.IndexOf("Foci", StringComparison.OrdinalIgnoreCase) >= 0) continue;
|
||||
if (skip != null && skip(p.Id)) continue; // the server refused it lately (PackRefusals)
|
||||
int capacity = p.Values(LongValueKey.ItemsCapacity, 0);
|
||||
if (capacity <= 0) continue; // capacity unknown — don't risk the move
|
||||
int used = 0;
|
||||
|
|
@ -1612,7 +1614,7 @@ public class WorldObjectCache
|
|||
// Dequip fallback: the bow needs ONE free main-pack slot; a dequip into a
|
||||
// non-full main pack is AV-safe (the AV is only on a genuinely FULL target).
|
||||
int mainFree = 102 - mainUsed;
|
||||
return mainFree > 0 ? playerId : 0;
|
||||
return mainFree > 0 && !(skip != null && skip(playerId)) ? playerId : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1623,7 +1625,9 @@ public class WorldObjectCache
|
|||
/// (2026-10-02). A move needs an explicit target, and the engine refuses a move into a
|
||||
/// full pack of ours, so this finds one with room.
|
||||
/// </summary>
|
||||
public static int FindLootDestination(IReadOnlyList<WorldObject> inv, int playerId, RynthCoreHost? host = null)
|
||||
/// <remarks><paramref name="skip"/>: packs (or the player id, for the main pack) the server refused lately.</remarks>
|
||||
public static int FindLootDestination(IReadOnlyList<WorldObject> inv, int playerId, RynthCoreHost? host = null,
|
||||
Func<int, bool>? skip = null)
|
||||
{
|
||||
if (inv == null || playerId == 0) return 0;
|
||||
int mainUsed = 0; // same tally as FindPackFor
|
||||
|
|
@ -1635,8 +1639,8 @@ public class WorldObjectCache
|
|||
if (host.HasValue && IsWieldable(p) && IsWieldedByPlayer(host.Value, p)) continue;
|
||||
mainUsed++;
|
||||
}
|
||||
if (102 - mainUsed > 0) return playerId;
|
||||
return FindPackFor(inv, playerId, includeMainPack: false, requireFree: 1, host);
|
||||
if (102 - mainUsed > 0 && !(skip != null && skip(playerId))) return playerId;
|
||||
return FindPackFor(inv, playerId, includeMainPack: false, requireFree: 1, host, skip);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -107,6 +107,11 @@ public sealed partial class RynthAiPlugin
|
|||
private bool _currentLootItemMovePending;
|
||||
private bool _corpseAutorunActive;
|
||||
private int _currentLootItemMoveAttempts;
|
||||
// Where the current item's last move went, and whether it already got a second pack.
|
||||
private int _currentLootItemDest;
|
||||
private bool _currentLootItemPackRetried;
|
||||
// Packs the server took none of an item's tries into (Loot/PackRefusals.cs).
|
||||
private readonly RynthCore.Plugin.RynthAi.Loot.PackRefusals _packRefusals = new();
|
||||
private long _currentLootItemStillSince;
|
||||
private long _currentLootItemLeftAt;
|
||||
private bool _currentLootItemSawAnim;
|
||||
|
|
@ -145,6 +150,26 @@ public sealed partial class RynthAiPlugin
|
|||
Log(message);
|
||||
}
|
||||
|
||||
// The values behind the last [LootSettings] line; a new line goes out only when one changes.
|
||||
private (LootBaseline.Timers Timers, double Max, double Min)? _lootSettingsLogged;
|
||||
|
||||
/// <summary>
|
||||
/// Logs the loot timers against the measured baseline (LootBaseline.cs), each marked "baseline"
|
||||
/// or "custom (baseline N)", so a loot log says which settings it ran with. Runs every loot tick,
|
||||
/// so it compares the raw values and builds the line only on a change.
|
||||
/// </summary>
|
||||
private void NoteLootSettings(LegacyUiSettings settings)
|
||||
{
|
||||
var timers = new LootBaseline.Timers(
|
||||
settings.LootContentSettleMs, settings.LootEmptyCorpseMs, settings.LootAssessWindowMs,
|
||||
settings.LootRetryTimeoutMs, settings.LootOpenRetryMs, settings.LootCorpseTimeoutMs);
|
||||
var current = (timers, settings.CorpseApproachRangeMax, settings.CorpseApproachRangeMin);
|
||||
if (_lootSettingsLogged == current)
|
||||
return;
|
||||
_lootSettingsLogged = current;
|
||||
LootDiag(LootBaseline.Describe(timers, settings.CorpseApproachRangeMax, settings.CorpseApproachRangeMin));
|
||||
}
|
||||
|
||||
public override void OnBusyCountIncremented()
|
||||
{
|
||||
if (_busyCount == 0)
|
||||
|
|
@ -579,6 +604,7 @@ public sealed partial class RynthAiPlugin
|
|||
ResetCorpseTarget();
|
||||
return;
|
||||
}
|
||||
NoteLootSettings(settings);
|
||||
|
||||
// Wedge halt: AC's item-action state is locked (consecutive open
|
||||
// timeouts). Stop firing opens into a dead client until the halt window
|
||||
|
|
@ -1985,6 +2011,22 @@ public sealed partial class RynthAiPlugin
|
|||
|
||||
if (!freeRetry && _currentLootItemMoveAttempts >= 3)
|
||||
{
|
||||
// None of the tries landed: the pack they went to is likely full (its contents
|
||||
// unknown to the client). Leave that pack out for a while and give the item one
|
||||
// more round into the next one; with no other pack, the item is left as before.
|
||||
if (_currentLootItemDest != 0)
|
||||
{
|
||||
_packRefusals.Refuse(_currentLootItemDest, now);
|
||||
if (!_currentLootItemPackRetried)
|
||||
{
|
||||
LootDiag($"[RynthAi] {LootTag}: {(_currentLootItemDest == _playerId ? "the main pack" : $"pack 0x{(uint)_currentLootItemDest:X8}")} took none of {_currentLootItemMoveAttempts} tries for 0x{(uint)_currentLootItemId:X8}; treating it as full for {RynthCore.Plugin.RynthAi.Loot.PackRefusals.HoldMs / 60_000} min and trying another pack.");
|
||||
_currentLootItemPackRetried = true;
|
||||
_currentLootItemMoveAttempts = 0;
|
||||
_currentLootItemStillSince = 0;
|
||||
_lastLootActionAt = now;
|
||||
return;
|
||||
}
|
||||
}
|
||||
LootDiag($"[RynthAi] {LootTag}: pickup failed for 0x{(uint)_currentLootItemId:X8}; container remained 0x{(uint)_openedContainerId:X8} after {_currentLootItemMoveAttempts} attempt(s).");
|
||||
_processedCorpseItems.Add(_currentLootItemId);
|
||||
ResetCurrentLootItem();
|
||||
|
|
@ -2054,7 +2096,9 @@ public sealed partial class RynthAiPlugin
|
|||
uint dest;
|
||||
LootPickupResult r = ownCorpse
|
||||
? SendOwnCorpsePickup(itemId, out dest)
|
||||
: LootPickup.Send(Host, _objectCache, unchecked((uint)itemId), _playerId, out dest);
|
||||
: LootPickup.Send(Host, _objectCache, unchecked((uint)itemId), _playerId, out dest,
|
||||
id => _packRefusals.IsRefused(id, CorpseNowMs));
|
||||
if (r == LootPickupResult.Moved) _currentLootItemDest = unchecked((int)dest);
|
||||
if (ownCorpse && r == LootPickupResult.NoRoom)
|
||||
{
|
||||
PauseOwnCorpseNoRoom(corpseId, itemName);
|
||||
|
|
@ -2093,6 +2137,7 @@ public sealed partial class RynthAiPlugin
|
|||
return;
|
||||
|
||||
int itemId = _currentLootItemId;
|
||||
if (answered && _currentLootItemDest != 0) _packRefusals.Accepted(_currentLootItemDest);
|
||||
_processedCorpseItems.Add(_currentLootItemId);
|
||||
LootDiag($"[RynthAi] {LootTag}: pickup confirmed for 0x{(uint)_currentLootItemId:X8}; {reason}" +
|
||||
$" ({now - _currentLootItemMoveRequestedAt} ms after the send{(_currentLootItemPipelined ? ", queued" : "")}).");
|
||||
|
|
@ -2183,6 +2228,15 @@ public sealed partial class RynthAiPlugin
|
|||
if (_combatEndedAt != 0 && (nowMs - _combatEndedAt) < LootGraceMs)
|
||||
return true;
|
||||
|
||||
// Boost Loot Priority: our kill's corpse is still forming. Looting holds the tick (combat
|
||||
// holds its next target) so the corpse is looted before the next fight starts.
|
||||
if (BoostLootAwaitsKillCorpse(settings))
|
||||
{
|
||||
double range = GetCorpseApproachRangeMaxMeters(settings);
|
||||
if (range > 0.25) HasUnlootedCorpsesInRange(range); // keeps _lootableInRange current
|
||||
return true;
|
||||
}
|
||||
|
||||
double maxMeters = GetCorpseApproachRangeMaxMeters(settings);
|
||||
if (maxMeters <= 0.25)
|
||||
return false;
|
||||
|
|
@ -2282,6 +2336,62 @@ public sealed partial class RynthAiPlugin
|
|||
=> wantLoot && wantCombat && _lootStarved
|
||||
&& _combatManager?.HasCloseThreat(LootStarveCloseYards) != true;
|
||||
|
||||
// -- Boost Loot Priority: one kill, one loot (2026-10-14) --------------------------------
|
||||
// Combat locked its next target a few ms after each kill, and ACE creates the corpse 1-3 s
|
||||
// later (the death animation), so the arbiter always saw combat engaged and Boost Loot never
|
||||
// won: Kelpie's corpses waited for a lull and were looted two or three at a time. Now our kill
|
||||
// starts a wait of up to BoostLootKillWaitMs for its corpse. While it runs, or while a corpse
|
||||
// is claimed, open or lootable in range, CombatManager locks no new target (HoldNewTarget)
|
||||
// and looting counts as work, so the arbiter gives Looting the tick.
|
||||
internal const long BoostLootKillWaitMs = 4000;
|
||||
private long _boostLootKillAt; // CorpseNowMs of our last kill whose corpse isn't looted yet; 0 = none
|
||||
|
||||
/// <summary>Our kill (KillerNotification): its corpse is on its way.</summary>
|
||||
private void NoteBoostLootKill() => _boostLootKillAt = CorpseNowMs;
|
||||
|
||||
/// <summary>
|
||||
/// A completed corpse first seen after the kill (or never timed) is the kill's corpse: the
|
||||
/// wait is over, so combat doesn't stand idle for the rest of it.
|
||||
/// </summary>
|
||||
private void EndBoostLootKillWait(int corpseId)
|
||||
{
|
||||
if (_boostLootKillAt == 0) return;
|
||||
if (!_corpseWaitingSince.TryGetValue(corpseId, out long seen) || seen >= _boostLootKillAt)
|
||||
_boostLootKillAt = 0;
|
||||
}
|
||||
|
||||
/// <summary>Boost Loot Priority is on and a corpse could be looted now (not with rare-only looting,
|
||||
/// where most kills leave nothing to wait for).</summary>
|
||||
private bool BoostLootCanRun(LegacyUiSettings settings)
|
||||
=> settings.BoostLootPriority && settings.IsMacroRunning && settings.EnableLooting
|
||||
&& !settings.LootOnlyRareCorpses
|
||||
&& !IsLootingBlockedByPack(settings)
|
||||
&& !_useRefusals.HoldsOpens(CorpseNowMs);
|
||||
|
||||
/// <summary>Our last kill was under BoostLootKillWaitMs ago and its corpse isn't looted yet.</summary>
|
||||
private bool BoostLootAwaitsKillCorpse(LegacyUiSettings settings)
|
||||
{
|
||||
if (_boostLootKillAt == 0) return false;
|
||||
if (CorpseNowMs - _boostLootKillAt >= BoostLootKillWaitMs)
|
||||
{
|
||||
_boostLootKillAt = 0;
|
||||
return false;
|
||||
}
|
||||
return BoostLootCanRun(settings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CombatManager.HoldNewTarget: with Boost Loot Priority on, no new target while a corpse is
|
||||
/// claimed, open or lootable in range, or our kill's corpse is still forming.
|
||||
/// </summary>
|
||||
private bool BoostLootHoldsNewTarget()
|
||||
{
|
||||
LegacyUiSettings? settings = _dashboard?.Settings;
|
||||
if (settings == null || !BoostLootCanRun(settings)) return false;
|
||||
return _targetCorpseId != 0 || _openedContainerId != 0 || _lootableInRange.Count > 0
|
||||
|| BoostLootAwaitsKillCorpse(settings);
|
||||
}
|
||||
|
||||
private static bool IsOwnKill(CorpseLootDecision d)
|
||||
=> !string.IsNullOrWhiteSpace(d.KillerName) && !string.IsNullOrWhiteSpace(d.PlayerName)
|
||||
&& NormalizeCharName(d.KillerName).Equals(NormalizeCharName(d.PlayerName), StringComparison.OrdinalIgnoreCase);
|
||||
|
|
@ -2803,6 +2913,7 @@ public sealed partial class RynthAiPlugin
|
|||
}
|
||||
|
||||
_completedCorpses[corpseId] = CorpseNowMs;
|
||||
EndBoostLootKillWait(corpseId);
|
||||
_corpseCooldownUntil.Remove(corpseId);
|
||||
_processedCorpseItems.Clear();
|
||||
_corpseItemAttempts.Clear();
|
||||
|
|
@ -2868,6 +2979,8 @@ public sealed partial class RynthAiPlugin
|
|||
_currentLootItemMovePending = false;
|
||||
_currentLootItemMoveRequestedAt = 0;
|
||||
_currentLootItemMoveAttempts = 0;
|
||||
_currentLootItemDest = 0;
|
||||
_currentLootItemPackRetried = false;
|
||||
_currentLootItemStillSince = 0;
|
||||
_currentLootItemLeftAt = 0;
|
||||
_currentLootItemSawAnim = false;
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ internal static class LogEvents
|
|||
LogCat.Meta => "Meta (VTank-style) state machine and actions.",
|
||||
LogCat.Expressions => "Meta expression evaluation.",
|
||||
LogCat.Quests => "Quest tracking.",
|
||||
LogCat.Crafting => "Missile ammo crafting.",
|
||||
LogCat.Crafting => "Missile ammo crafting and the Mini Remote's Crafting tab.",
|
||||
LogCat.Raycast => "Line-of-sight raycasts and geometry loading.",
|
||||
LogCat.Radar => "Radar window.",
|
||||
LogCat.UI => "RynthAi UI windows and panels.",
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ internal static unsafe class HubInterface
|
|||
t->RenderSection = &RenderSection;
|
||||
t->SessionStats = &SessionStats;
|
||||
t->SessionReset = &SessionReset;
|
||||
t->SessionStatsMore = &SessionStatsMore;
|
||||
t->Version = RynthAiHubApiV1.InterfaceVersion;
|
||||
_table = t;
|
||||
}
|
||||
|
|
@ -230,6 +231,25 @@ internal static unsafe class HubInterface
|
|||
catch { return 0; }
|
||||
}
|
||||
|
||||
/// <summary>The rest of the same session (RynthTracker's panel shows it whole). 0 before login.</summary>
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static int SessionStatsMore(SessionStatsMoreV1* more)
|
||||
{
|
||||
try
|
||||
{
|
||||
var tracker = Plugin?.SessionStatsForIlt;
|
||||
if (tracker == null || more == null) return 0;
|
||||
var v = tracker.View;
|
||||
more->XpPerKill = v.XpPerKill;
|
||||
more->Deaths = v.Deaths;
|
||||
more->MaxLevel = v.MaxLevel ? 1 : 0;
|
||||
more->Rad = v.Rad;
|
||||
more->RadPerHour = v.RadPerHour;
|
||||
return 1;
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static void SessionReset()
|
||||
{
|
||||
|
|
|
|||
144
Plugins/RynthCore.Plugin.RynthAi/Huds/FellowshipSectionUi.cs
Normal file
144
Plugins/RynthCore.Plugin.RynthAi/Huds/FellowshipSectionUi.cs
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
// FellowshipSectionUi.cs - RynthCore's Fellowship section (RynthPluginRenderEmbed
|
||||
// "section:fellowship") and the Mini Remote's Fellowship tab: the fellowship you are in, from
|
||||
// FellowshipTracker. Render thread only.
|
||||
//
|
||||
// Name, leader, open / locked / XP sharing, and the members with their levels (you and the
|
||||
// leader marked). The tracker reads AC's fellowship object, which AC's main thread (the render
|
||||
// thread here) owns, and caches the member list for two seconds; this view re-reads it once a
|
||||
// second. The Mini Remote tab also draws the active server's fellowship commands
|
||||
// (ServerCommandModel, e.g. RynthILT's /fship); RynthCore's section shows the server plugin's
|
||||
// own pane for those, so the embedded view leaves them out.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Huds;
|
||||
|
||||
internal sealed class FellowshipSectionUi
|
||||
{
|
||||
/// <summary>The section id server plugins send fellowship commands for.</summary>
|
||||
public const string CommandSection = "fellowship";
|
||||
|
||||
private const long RefreshMs = 1000;
|
||||
|
||||
private static readonly Vector4 ColLeader = new(0.95f, 0.80f, 0.35f, 1f);
|
||||
private static readonly Vector4 ColMute = new(0.80f, 0.84f, 0.90f, 1f);
|
||||
|
||||
private readonly Func<FellowshipTracker?> _tracker;
|
||||
private readonly Func<uint> _playerId;
|
||||
private readonly Func<string, bool> _sendCommand;
|
||||
private readonly ServerCommandPanel _commands = new("fellow");
|
||||
|
||||
// The last read (render thread only).
|
||||
private long _readAt = long.MinValue / 2;
|
||||
private bool _inFellowship;
|
||||
private string _name = string.Empty;
|
||||
private int _leaderId;
|
||||
private bool _open, _locked, _shareXp;
|
||||
private readonly List<(int Id, string Name, int Level)> _members = new();
|
||||
|
||||
/// <param name="sendCommand">Queues a chat command for the plugin tick; false when it can't.</param>
|
||||
public FellowshipSectionUi(Func<FellowshipTracker?> tracker, Func<uint> playerId, Func<string, bool> sendCommand)
|
||||
{
|
||||
_tracker = tracker;
|
||||
_playerId = playerId;
|
||||
_sendCommand = sendCommand;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the view into the current window. <paramref name="withServerCommands"/> adds the
|
||||
/// active server's fellowship commands above the member list. Render thread.
|
||||
/// </summary>
|
||||
public void Render(bool withServerCommands)
|
||||
{
|
||||
FellowshipTracker? t = _tracker();
|
||||
if (t == null)
|
||||
{
|
||||
ImGui.TextDisabled("Fellowship tracking starts at login.");
|
||||
return;
|
||||
}
|
||||
Refresh(t);
|
||||
|
||||
if (_inFellowship)
|
||||
{
|
||||
SafeImGui.TextColored(ColLeader, _name.Length > 0 ? _name : "(unnamed fellowship)");
|
||||
SafeImGui.TextDisabled($"{_members.Count} member(s) {(_open ? "Open" : "Closed")} {(_locked ? "Locked" : "Unlocked")} XP {(_shareXp ? "shared" : "not shared")}");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextDisabled("Not in a fellowship.");
|
||||
}
|
||||
|
||||
// Shown out of a fellowship too: that's when "create" is wanted.
|
||||
if (withServerCommands) RenderServerCommands();
|
||||
if (!_inFellowship) return;
|
||||
ImGui.Separator();
|
||||
|
||||
uint me = SafePlayerId();
|
||||
if (ImGui.BeginTable("##fellows", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerH | ImGuiTableFlags.ScrollY,
|
||||
new Vector2(0, MathF.Max(60f, ImGui.GetContentRegionAvail().Y))))
|
||||
{
|
||||
ImGui.TableSetupColumn("Member", ImGuiTableColumnFlags.WidthStretch);
|
||||
ImGui.TableSetupColumn("Level", ImGuiTableColumnFlags.WidthFixed, 50f);
|
||||
ImGui.TableSetupColumn("Role", ImGuiTableColumnFlags.WidthFixed, 90f);
|
||||
ImGui.TableSetupScrollFreeze(0, 1);
|
||||
ImGui.TableHeadersRow();
|
||||
foreach ((int id, string name, int level) in _members)
|
||||
{
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
bool leader = id == _leaderId;
|
||||
if (leader) SafeImGui.TextColored(ColLeader, name);
|
||||
else SafeImGui.Text(name);
|
||||
ImGui.TableNextColumn();
|
||||
SafeImGui.TextColored(ColMute, level > 0 ? level.ToString() : string.Empty);
|
||||
ImGui.TableNextColumn();
|
||||
string role = (leader ? "Leader" : string.Empty) + ((uint)id == me && me != 0 ? (leader ? ", you" : "You") : string.Empty);
|
||||
SafeImGui.TextColored(ColMute, role);
|
||||
}
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
// The fellowship commands the active server's plugin sent, if any.
|
||||
private void RenderServerCommands()
|
||||
{
|
||||
ServerCommandSet? set = ServerCommandModel.For(CommandSection);
|
||||
if (set == null || set.Commands.Count == 0) return;
|
||||
ImGui.Separator();
|
||||
SafeImGui.TextColored(ColMute, (set.ServerName.Length > 0 ? set.ServerName : "Server") + " fellowship commands");
|
||||
_commands.Render(set, _sendCommand);
|
||||
}
|
||||
|
||||
private void Refresh(FellowshipTracker t)
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
if (now - _readAt < RefreshMs) return;
|
||||
_readAt = now;
|
||||
_members.Clear();
|
||||
_inFellowship = t.IsInFellowship;
|
||||
if (!_inFellowship) return;
|
||||
_name = t.FellowshipName ?? string.Empty;
|
||||
_leaderId = t.LeaderId;
|
||||
_open = t.IsOpen;
|
||||
_locked = t.IsLocked;
|
||||
_shareXp = t.ShareXP;
|
||||
foreach ((int id, string name, int level) in t.GetMembers())
|
||||
_members.Add((id, name.Length > 0 ? name : $"0x{id:X8}", level));
|
||||
int leaderId = _leaderId;
|
||||
_members.Sort((a, b) =>
|
||||
{
|
||||
// Leader first, then by name.
|
||||
int byLeader = (b.Id == leaderId).CompareTo(a.Id == leaderId);
|
||||
return byLeader != 0 ? byLeader : string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase);
|
||||
});
|
||||
}
|
||||
|
||||
private uint SafePlayerId()
|
||||
{
|
||||
try { return _playerId(); }
|
||||
catch { return 0; }
|
||||
}
|
||||
}
|
||||
|
|
@ -521,8 +521,23 @@ internal sealed class HudController
|
|||
{
|
||||
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();
|
||||
// Character / Charms / Banking left the Mini Remote (2026-10-13): open their new home.
|
||||
if (MovedTabs.CommandFor(tab) is string moved)
|
||||
{
|
||||
if (string.Equals(State.MiniRemoteTab, tab, StringComparison.OrdinalIgnoreCase)) _miniRemote.RequestTab(string.Empty);
|
||||
if (m is "hide" or "off" or "close") return $"{label} isn't a Mini Remote tab any more ({MovedTabs.HomeOf(moved)}, {moved}).";
|
||||
RunEngineCommand(moved);
|
||||
return $"{label} moved to {MovedTabs.HomeOf(moved)} ({moved}).";
|
||||
}
|
||||
bool selected = string.Equals(State.MiniRemoteTab, tab, StringComparison.OrdinalIgnoreCase);
|
||||
// RynthCore shows the tabs as sections: open it there. Not for "select", which is how
|
||||
// RynthCore itself falls back to this tab bar (re-sending would bounce between the two).
|
||||
if (EngineHostsSections && m is not ("select" or "hide" or "off" or "close"))
|
||||
{
|
||||
RunEngineCommand(tab.Length == 0 ? "/rc miniremote section remote" : "/rc miniremote tab " + tab);
|
||||
return $"Mini Remote (RynthCore's window): {label}.";
|
||||
}
|
||||
bool hide = m is "hide" or "off" or "close"
|
||||
|| (m is not ("show" or "on" or "open" or "select") && selected && MiniRemoteActive);
|
||||
if (hide)
|
||||
|
|
@ -540,6 +555,9 @@ internal sealed class HudController
|
|||
|
||||
// ── Render thread ───────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>RynthCore's Mini Remote "Session Stats" section (SectionsManifest.SessionSurface). Render thread.</summary>
|
||||
public void RenderSessionSection() => _miniRemote.RenderSessionSection();
|
||||
|
||||
public void Render()
|
||||
{
|
||||
int pushed = LegacyDashboardRenderer.PushDashboardStyle();
|
||||
|
|
@ -561,7 +579,7 @@ internal sealed class HudController
|
|||
/// Mini Remote drawer, or with <paramref name="window"/> the engine's Mini Remote window)
|
||||
/// and returns the content size it wants. Render thread.
|
||||
/// </summary>
|
||||
public System.Numerics.Vector2 RenderEmbedded(bool window = false)
|
||||
public System.Numerics.Vector2 RenderEmbedded(bool window = false, bool tabs = true)
|
||||
{
|
||||
long now = NowMs;
|
||||
System.Threading.Interlocked.Exchange(ref _embeddedDrawnAt, now);
|
||||
|
|
@ -569,11 +587,25 @@ internal sealed class HudController
|
|||
int pushed = LegacyDashboardRenderer.PushDashboardStyle();
|
||||
try
|
||||
{
|
||||
return _miniRemote.RenderEmbedded(window);
|
||||
return _miniRemote.RenderEmbedded(window, tabs);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.PopStyleColor(pushed);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RynthCore's Mini Remote window is open on one of its sections (not the remote): it is still
|
||||
/// the one Mini Remote, so the floating copy stays hidden and the data keeps polling. Render thread.
|
||||
/// </summary>
|
||||
public void MarkEngineWindow()
|
||||
{
|
||||
long now = NowMs;
|
||||
System.Threading.Interlocked.Exchange(ref _embeddedDrawnAt, now);
|
||||
System.Threading.Interlocked.Exchange(ref _windowDrawnAt, now);
|
||||
}
|
||||
|
||||
/// <summary>RynthCore shows the Mini Remote's tabs as its own sections (it sent their list).</summary>
|
||||
public static bool EngineHostsSections => ServerMenuModel.Sections.Length > 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using System.Linq;
|
|||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Huds;
|
||||
|
||||
|
|
@ -148,7 +149,7 @@ internal sealed class HudSetupUi
|
|||
ImGui.SetCursorPos(start);
|
||||
HudDraw.Icon(_hud.Icons, iconDid, name, ListIcon, dim);
|
||||
ImGui.SameLine();
|
||||
if (dim) ImGui.TextDisabled(label);
|
||||
if (dim) SafeImGui.TextDisabled(label);
|
||||
else ImGui.TextUnformatted(label);
|
||||
return clicked;
|
||||
}
|
||||
|
|
@ -158,7 +159,7 @@ internal sealed class HudSetupUi
|
|||
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). "
|
||||
SafeImGui.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)}";
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Huds;
|
||||
|
||||
|
|
@ -52,16 +53,16 @@ internal sealed class ItemCountHud
|
|||
{
|
||||
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");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.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"));
|
||||
SafeImGui.TextColored(count == 0 ? ColNone : ColCount, count.ToString("N0"));
|
||||
if (s.ItemHudShowNames)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(ColName, e.Name);
|
||||
SafeImGui.TextColored(ColName, e.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
// 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, MiniRemote/), and on Infinite Leaftide the RynthILT plugin's ILT tabs (Character,
|
||||
// Banking, Gear, Charms, Games: RynthILT.Hub GetTabs / RenderTab through IltClient; an ILT tab
|
||||
// One window with tabs: Remote (the sections below), the universal tabs Pets and Crafting (every
|
||||
// world, MiniRemote/; the Quests tab moved to RynthOracle 2026-10-13), and on Infinite Leaftide
|
||||
// the RynthILT plugin's ILT tabs (Banking, Gear, Charms, Games; its Character tab moved to
|
||||
// RynthOracle's Character tab 2026-10-13: RynthILT.Hub GetTabs / RenderTab through IltClient; an ILT tab
|
||||
// shows once the server reports its feature on, and never without RynthILT). The tab bar's
|
||||
// selection is saved (HudState.MiniRemoteTab) and "/ra hub open <section>" or RynthCore's
|
||||
// dashboard switch it (RequestTab). The Guardian and Bounties are RynthILT's 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: <name>", 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.
|
||||
// Right-click on the remote: "Character" (Spells, Pets, Crafting, RynthOracle's Character, Quests,
|
||||
// Quest Timers and Fellowship, Skills, Inventory, Item Count, Inventory HUDs: windows every server
|
||||
// has), then "Server: <name>", i.e. the installed server plugins' windows for the world you're on,
|
||||
// which RynthCore sends (ServerMenuModel), or a link to RynthCore's Options > Diagnostics (where a
|
||||
// server is forced) 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):
|
||||
|
|
@ -30,12 +32,13 @@
|
|||
// 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
|
||||
// (its Mini Remote drawer, opened by 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.
|
||||
// (HudController), so that window is the one Mini Remote. RynthCore 2026.10.5.46+ shows the tabs
|
||||
// as its own sections (RynthPluginGetSectionsJson) and asks for the remote alone (tabs: false).
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -136,7 +139,7 @@ internal sealed class MiniRemoteHud
|
|||
/// 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.
|
||||
/// </summary>
|
||||
public Vector2 RenderEmbedded(bool window = false)
|
||||
public Vector2 RenderEmbedded(bool window = false, bool tabs = true)
|
||||
{
|
||||
var s = _hud.State;
|
||||
_slotMenuIndex = -1;
|
||||
|
|
@ -146,7 +149,8 @@ internal sealed class MiniRemoteHud
|
|||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 3));
|
||||
try
|
||||
{
|
||||
float width = RenderBody(s, _hud.Remote(), allowTabs: !InDrawer);
|
||||
// Without tabs (RynthCore's sections show them instead) the remote alone.
|
||||
float width = RenderBody(s, _hud.Remote(), allowTabs: tabs && !InDrawer);
|
||||
|
||||
if (_onRemoteTab && _slotMenuIndex < 0 && ImGui.IsWindowHovered(ImGuiHoveredFlags.ChildWindows) && ImGui.IsMouseReleased(ImGuiMouseButton.Right))
|
||||
ImGui.OpenPopup(MenuPopup);
|
||||
|
|
@ -214,7 +218,7 @@ internal sealed class MiniRemoteHud
|
|||
// The tab draws into a child of its own size; tables in it scroll inside it.
|
||||
ImGui.BeginChild(TabBodyId(tab.Id), tab.Size, ImGuiChildFlags.None, ImGuiWindowFlags.None);
|
||||
bool drawn = tab.Ilt ? remote!.Ilt.RenderTab(tab.Id) : remote!.RenderTab(tab.Id);
|
||||
if (!drawn) ImGui.TextDisabled(tab.Ilt ? "RynthILT isn't drawing this tab (not loaded, or not ready yet)." : "Not ready.");
|
||||
if (!drawn) SafeImGui.TextDisabled(tab.Ilt ? "RynthILT isn't drawing this tab (not loaded, or not ready yet)." : "Not ready.");
|
||||
ImGui.EndChild();
|
||||
width = Math.Max(width, tab.Size.X);
|
||||
ImGui.EndTabItem();
|
||||
|
|
@ -313,7 +317,7 @@ internal sealed class MiniRemoteHud
|
|||
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.");
|
||||
SafeImGui.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;
|
||||
|
|
@ -418,7 +422,7 @@ internal sealed class MiniRemoteHud
|
|||
|
||||
private static void Stat(string label, string value)
|
||||
{
|
||||
ImGui.TextColored(ColLabel, label);
|
||||
SafeImGui.TextColored(ColLabel, label);
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(value);
|
||||
}
|
||||
|
|
@ -438,7 +442,7 @@ internal sealed class MiniRemoteHud
|
|||
if (v.PassUpTracked)
|
||||
{
|
||||
Stat("Pass-up:", HudDraw.Compact(v.PassUpPerHour) + "/h");
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip($"{v.LumPassUp:N0} this session.\n{PassUpTooltip}");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip($"{v.LumPassUp:N0} this session.\n{PassUpTooltip}");
|
||||
}
|
||||
Stat("Kills:", HudDraw.Compact(v.KillsPerHour) + "/h");
|
||||
if (remote == null || !remote.Ilt.TryGetRates(out double coins, out double pyreals)) return;
|
||||
|
|
@ -446,7 +450,53 @@ internal sealed class MiniRemoteHud
|
|||
Stat("Pyr:", HudDraw.Compact(pyreals) + "/h");
|
||||
}
|
||||
|
||||
/// <summary>What the pass-up figure is (RynthILT's Character tab says the same).</summary>
|
||||
/// <summary>
|
||||
/// RynthCore's Mini Remote "Session Stats" section (surface "section:session"): the one session,
|
||||
/// totals and per-hour rates, with Reset and Report. RynthTracker, RynthOracle and RynthILT read
|
||||
/// these same numbers (RynthAi.Hub SessionStats), so every XP/h and lum/h on screen agrees.
|
||||
/// Render thread.
|
||||
/// </summary>
|
||||
public void RenderSessionSection()
|
||||
{
|
||||
var v = _hud.SessionStats?.View ?? RynthCore.Plugin.Shared.SessionStatsView.Empty;
|
||||
bool running = !ReferenceEquals(v, RynthCore.Plugin.Shared.SessionStatsView.Empty);
|
||||
SafeImGui.TextDisabled(running
|
||||
? "Session " + MiniRemoteText.Duration(TimeSpan.FromSeconds(SessionClock(v)))
|
||||
: "The session starts once you are in the world.");
|
||||
if (ImGui.BeginTable("##mrsession", 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.SizingStretchProp))
|
||||
{
|
||||
ImGui.TableSetupColumn("Stat", ImGuiTableColumnFlags.WidthStretch, 1.2f);
|
||||
ImGui.TableSetupColumn("Session", ImGuiTableColumnFlags.WidthStretch, 1f);
|
||||
ImGui.TableSetupColumn("Per hour", ImGuiTableColumnFlags.WidthStretch, 1f);
|
||||
ImGui.TableHeadersRow();
|
||||
SessionRow("XP", HudDraw.Compact(v.Xp), HudDraw.Compact(v.XpPerHour));
|
||||
SessionRow("Luminance", HudDraw.Compact(v.Lum), HudDraw.Compact(v.LumPerHour));
|
||||
// The last five minutes' luminance, and that pace for an hour.
|
||||
SessionRow(" last 5 min", HudDraw.Compact(v.LumLast5Min), HudDraw.Compact(v.LumLast5Min * 12.0));
|
||||
if (v.PassUpTracked) SessionRow(" pass-up", HudDraw.Compact(v.LumPassUp), HudDraw.Compact(v.PassUpPerHour), PassUpTooltip);
|
||||
if (v.Rad > 0) SessionRow("Radiance", HudDraw.Compact(v.Rad), HudDraw.Compact(v.RadPerHour));
|
||||
SessionRow("Kills", v.Kills.ToString("N0"), HudDraw.Compact(v.KillsPerHour));
|
||||
if (v.XpPerKill > 0) SessionRow(" XP per kill", HudDraw.Compact(v.XpPerKill), string.Empty);
|
||||
if (v.Deaths > 0) SessionRow("Deaths", v.Deaths.ToString("N0"), string.Empty);
|
||||
ImGui.EndTable();
|
||||
}
|
||||
RenderStatButtons(_hud.Remote());
|
||||
}
|
||||
|
||||
/// <summary>One Session Stats row: label, session total, per hour (and an optional tooltip on the label).</summary>
|
||||
private static void SessionRow(string label, string total, string perHour, string tooltip = "")
|
||||
{
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
SafeImGui.TextColored(ColLabel, label);
|
||||
if (tooltip.Length > 0 && ImGui.IsItemHovered()) SafeImGui.SetTooltip(tooltip);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(total);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(perHour);
|
||||
}
|
||||
|
||||
/// <summary>What the pass-up figure is (RynthILT's session rates say the same).</summary>
|
||||
private 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.";
|
||||
|
|
@ -465,7 +515,7 @@ internal sealed class MiniRemoteHud
|
|||
if (c.TargetDistance >= 0)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextDisabled($"{c.TargetDistance:F0}yd");
|
||||
SafeImGui.TextDisabled($"{c.TargetDistance:F0}yd");
|
||||
}
|
||||
HealthBar("##mrtargethp", c.TargetHealth);
|
||||
}
|
||||
|
|
@ -484,7 +534,7 @@ internal sealed class MiniRemoteHud
|
|||
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);
|
||||
SafeImGui.TextColored(col, status);
|
||||
}
|
||||
|
||||
private static void RenderSummon(MiniRemoteController? remote, CombatHudSnapshot c)
|
||||
|
|
@ -513,14 +563,14 @@ internal sealed class MiniRemoteHud
|
|||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextColored(left.TotalSeconds <= 30 ? ColEmpty : ColOut, text);
|
||||
SafeImGui.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)}");
|
||||
SafeImGui.TextDisabled($"Out {FormatClock(up)}");
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("The server hasn't reported this summon's lifespan yet.");
|
||||
}
|
||||
}
|
||||
|
|
@ -556,7 +606,7 @@ internal sealed class MiniRemoteHud
|
|||
_hud.SessionStats?.RequestReset();
|
||||
_hud.Remote()?.Ilt.Command("rates reset"); // RynthILT's coin / pyreal session too
|
||||
});
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Start the session stats over (the Tracker panel keeps its own session).");
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Start the session stats over (RynthTracker, RynthOracle and RynthILT follow this 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).");
|
||||
|
|
@ -604,7 +654,7 @@ internal sealed class MiniRemoteHud
|
|||
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.");
|
||||
SafeImGui.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)
|
||||
{
|
||||
|
|
@ -678,7 +728,7 @@ internal sealed class MiniRemoteHud
|
|||
{
|
||||
if (!ImGui.BeginPopup(SlotPopup)) return;
|
||||
_slotMenuIndex = index;
|
||||
ImGui.TextDisabled(e.IsEmpty ? $"Slot {index + 1:00}" : $"Slot {index + 1:00}: {e.Name}");
|
||||
SafeImGui.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));
|
||||
|
|
@ -805,8 +855,9 @@ internal sealed class MiniRemoteHud
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// "Character": RynthAi's own windows, the universal Mini Remote tabs (Quests, Pets), and
|
||||
/// RynthCore's panels when it runs /rc commands.
|
||||
/// "Character": RynthAi's own windows, the universal Mini Remote tabs (Pets, Crafting), RynthOracle's
|
||||
/// quest and fellowship windows (the Quests and Fellowship tabs moved there 2026-10-13) and
|
||||
/// RynthCore's panels, when chat commands can be run.
|
||||
/// </summary>
|
||||
private void RenderCharacterMenu(HudState s)
|
||||
{
|
||||
|
|
@ -822,6 +873,17 @@ internal sealed class MiniRemoteHud
|
|||
}
|
||||
if (_hud.Host.HasInvokeChatParser)
|
||||
{
|
||||
// RynthOracle's commands (it toggles its own windows; without RynthOracle nothing answers "/ro").
|
||||
// The character overview and its session are RynthOracle's Character tab (2026-10-13);
|
||||
// Infinite Leaftide's charms and bank stay RynthILT's tabs (the server section below).
|
||||
if (ImGui.MenuItem("Character##mrcharacter", MovedTabs.OracleCharacter)) _hud.RunEngineCommand(MovedTabs.OracleCharacter);
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("RynthOracle's Character tab: the character and this session.");
|
||||
if (ImGui.MenuItem("Quests##mrquests", "/ro")) _hud.RunEngineCommand("/ro");
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("RynthOracle: quest timers, tracking and rewards.");
|
||||
if (ImGui.MenuItem("Quest Timers##mrqtimers", "/ro timers")) _hud.RunEngineCommand("/ro timers");
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("RynthOracle's Quest Timers window: your tracked quests and the time left on each.");
|
||||
if (ImGui.MenuItem("Fellowship##mrfellow", "/ro fellowship")) _hud.RunEngineCommand("/ro fellowship");
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("RynthOracle's Fellowship tab: members, levels and XP sharing.");
|
||||
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");
|
||||
|
|
@ -852,17 +914,21 @@ internal sealed class MiniRemoteHud
|
|||
if (!g.Active && !forcedHere) continue;
|
||||
any = true;
|
||||
ImGui.Separator();
|
||||
ImGui.TextDisabled("Server: " + (g.Active ? g.Name : g.Name + " (forced)"));
|
||||
SafeImGui.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 && MiniRemoteTabs.Parse(tab) != null) continue;
|
||||
// Universal tabs are under Character; RynthCore 2026.10.5.30 and older list them here too
|
||||
// (with the retired Quests tab, now RynthOracle's).
|
||||
if (tab != null && (MiniRemoteTabs.Parse(tab) != null || tab.Equals("quests", StringComparison.OrdinalIgnoreCase))) continue;
|
||||
// Character (an older RynthCore still lists it) moved out: it is under Character above
|
||||
// (RynthOracle's Character tab).
|
||||
if (tab != null && MovedTabs.CommandFor(tab) != null) continue;
|
||||
bool enabled = tab == null || TabAvailable(remote, 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.");
|
||||
SafeImGui.SetTooltip(enabled ? item.Tooltip : item.Tooltip + "\nShows once the server reports this feature on.");
|
||||
}
|
||||
if (ilt) remote?.Ilt.RenderSection(RynthIltHub.SectionIltStatus);
|
||||
}
|
||||
|
|
@ -870,14 +936,12 @@ internal sealed class MiniRemoteHud
|
|||
|
||||
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, remote);
|
||||
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.");
|
||||
}
|
||||
// Forcing a server lives in one place since 2026-10-13: RynthCore's Options > Diagnostics.
|
||||
if (_hud.Host.HasInvokeChatParser && ImGui.MenuItem("Force a server... (Options > Diagnostics)##mrforce", MovedTabs.Diagnostics))
|
||||
_hud.RunEngineCommand(MovedTabs.Diagnostics);
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip("RynthCore's server selection (Options > Diagnostics) shows a server's windows here anyway.\n"
|
||||
+ "It only says which world this is: the server still decides which features exist.");
|
||||
}
|
||||
|
||||
/// <summary>A Mini Remote tab switches here and now; anything else is a RynthCore command.</summary>
|
||||
|
|
@ -887,16 +951,6 @@ internal sealed class MiniRemoteHud
|
|||
else if (item.Command.Length > 0) _hud.RunEngineCommand(item.Command);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Forces a server: RynthCore's session override, plus for Infinite Leaftide this character's
|
||||
/// "Treat this world as ILT" (so RynthILT's tabs come too).
|
||||
/// </summary>
|
||||
private void ForceServer(ServerMenuGroup g, MiniRemoteController? remote)
|
||||
{
|
||||
if (g.Id.Equals(IltServerId, StringComparison.OrdinalIgnoreCase) && remote != null) remote.Ilt.ForceIlt = true;
|
||||
_hud.RunEngineCommand(g.ForceCommand);
|
||||
}
|
||||
|
||||
/// <summary>RynthILT reports that ILT tab's feature on (false without RynthILT).</summary>
|
||||
private static bool TabAvailable(MiniRemoteController? remote, string tab)
|
||||
{
|
||||
|
|
|
|||
41
Plugins/RynthCore.Plugin.RynthAi/Huds/MovedTabs.cs
Normal file
41
Plugins/RynthCore.Plugin.RynthAi/Huds/MovedTabs.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// MovedTabs.cs - Mini Remote tabs that moved out of the Mini Remote (2026-10-13), and where to.
|
||||
//
|
||||
// RynthILT's Character tab left the Mini Remote: its character overview and session went to
|
||||
// RynthOracle's Character tab ("/ro character"), its ILT session rates to RynthCore's Mini Remote
|
||||
// "Session Stats" section (RynthILT's own "section:ilt-rates"), and the force-server override to
|
||||
// RynthCore Options > Diagnostics ("/rc diagnostics"). Infinite Leaftide's own screens stay
|
||||
// RynthILT's: Charms and Banking are still Mini Remote ILT tabs (SectionsManifest places them on
|
||||
// the rail), drawn by RynthILT.
|
||||
// Old saved tab ids, links and "/ra hub open|tab <name>" land on the new home through CommandFor.
|
||||
//
|
||||
// Pure: the host tests check the mapping offline.
|
||||
using System;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Huds;
|
||||
|
||||
internal static class MovedTabs
|
||||
{
|
||||
/// <summary>RynthOracle's Character tab (the character overview and this session).</summary>
|
||||
public const string OracleCharacter = "/ro character";
|
||||
|
||||
/// <summary>RynthCore Options > Diagnostics (the server picker; RynthCore 2026.10.5.54+).</summary>
|
||||
public const string Diagnostics = "/rc diagnostics";
|
||||
|
||||
/// <summary>
|
||||
/// The chat command that opens where tab <paramref name="tab"/> lives now, or null when it is
|
||||
/// still a Mini Remote tab (or not a tab at all). Case and padding don't matter.
|
||||
/// </summary>
|
||||
public static string? CommandFor(string? tab) => (tab ?? string.Empty).Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"character" or "char" or "rates" => OracleCharacter,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// <summary>Where <paramref name="command"/> opens, in words, for chat replies and tooltips.</summary>
|
||||
public static string HomeOf(string command) => command switch
|
||||
{
|
||||
OracleCharacter => "RynthOracle's Character tab",
|
||||
Diagnostics => "RynthCore Options > Diagnostics",
|
||||
_ => command,
|
||||
};
|
||||
}
|
||||
184
Plugins/RynthCore.Plugin.RynthAi/Huds/SectionsManifest.cs
Normal file
184
Plugins/RynthCore.Plugin.RynthAi/Huds/SectionsManifest.cs
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
// SectionsManifest.cs - What RynthAi adds to RynthCore's Mini Remote sections.
|
||||
//
|
||||
// RynthCore 2026.10.5.46+ shows the Mini Remote as a rail of sections: its core twelve (Session
|
||||
// Stats - id "char" -, Map, Skills, Combat, Nav, Inventory, Crafting, Spells, Chat, Friends,
|
||||
// Fellowship, Pets) and any a plugin adds. It reads each plugin's optional
|
||||
// RynthPluginGetSectionsJson export every couple of seconds (schema: UI/Sections/SectionManifest.cs
|
||||
// in RynthCore). RynthAi fills:
|
||||
// every world Session Stats (the one session: RynthTracker, RynthOracle and RynthILT read the
|
||||
// same numbers, and RynthCore drops its own overview for it), Pets, Crafting,
|
||||
// Spells and Fellowship (the views of those core sections)
|
||||
// Infinite RynthILT's tabs, hosted here as they are in RynthAi's own Mini Remote (RynthILT.Hub,
|
||||
// Leaftide MiniRemote/IltClient.cs): Gear, Charms and Banking in Inventory, and a Games
|
||||
// section of RynthAi's own
|
||||
// Quests are RynthOracle's (since 2026-10-13), and RynthILT draws its ILT session extras, /fship
|
||||
// and /qb views itself (its own manifest), so neither is listed here. RynthILT's Character tab
|
||||
// moved out on 2026-10-13 (MovedTabs.cs): RynthOracle's Character tab and the ILT session rates in
|
||||
// Session Stats. Charms and Banking stay RynthILT's tabs (Infinite Leaftide's own screens), so the
|
||||
// engine's "/rc miniremote tab charms|banking" finds them here as "section:charms|banking".
|
||||
// Each view is a surface "section:<name>" RynthCore draws through RynthPluginRenderEmbed. An ILT
|
||||
// view whose feature the server hasn't reported is listed but not enabled, with a note.
|
||||
//
|
||||
// Pure: RynthILT's tabs come in as a list, so the host tests build it offline.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Huds;
|
||||
|
||||
internal static class SectionsManifest
|
||||
{
|
||||
/// <summary>Prefix of every RynthAi section surface ("section:pets").</summary>
|
||||
public const string SurfacePrefix = "section:";
|
||||
|
||||
public const string PetsSurface = SurfacePrefix + MiniRemoteTabs.Pets;
|
||||
public const string CraftingSurface = SurfacePrefix + MiniRemoteTabs.Crafting;
|
||||
public const string SpellsSurface = SurfacePrefix + "spells";
|
||||
public const string FellowshipSurface = SurfacePrefix + "fellowship";
|
||||
/// <summary>The session stats (RynthCore's Session Stats section, "char").</summary>
|
||||
public const string SessionSurface = SurfacePrefix + "session";
|
||||
|
||||
/// <summary>RynthCore's id for Infinite Leaftide.</summary>
|
||||
public const string IltServer = "ilt";
|
||||
|
||||
/// <summary>Longest tab id taken from RynthILT (its ids are short ASCII words).</summary>
|
||||
public const int MaxTabIdLength = 32;
|
||||
|
||||
/// <summary>One view RynthAi puts in a section.</summary>
|
||||
internal sealed record View(string Section, string Server, string Label, string Surface, bool Primary,
|
||||
Vector2 Size, bool Enabled, string Note, string Tooltip, int Order);
|
||||
|
||||
/// <summary>A section of RynthAi's own (beyond RynthCore's core twelve).</summary>
|
||||
internal sealed record Section(string Id, string Label, int Order);
|
||||
|
||||
/// <summary>RynthAi's own sections: Games (ILT) after Pets.</summary>
|
||||
public static readonly Section[] OwnSections =
|
||||
{
|
||||
new("games", "Games", 1150),
|
||||
};
|
||||
|
||||
private const string NotReportedNote = "Shows once the server reports this ILT feature on (RynthILT's ILT settings can ask again).";
|
||||
|
||||
/// <summary>Where each of RynthILT's tabs goes: section, label, order, tooltip. Unknown ids aren't listed.</summary>
|
||||
private static readonly Dictionary<string, (string Section, string Label, int Order, string Tooltip)> IltPlacement =
|
||||
new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["gear"] = ("inventory", "Gear", 210, "ILT gear tools (RynthILT)."),
|
||||
["charms"] = ("inventory", "Charms", 220, "ILT charms and Guardian Hands: acquired, status, tier, toggles (RynthILT)."),
|
||||
["banking"] = ("inventory", "Banking", 230, "Your ILT bank: balances, deposits, withdrawals and transfers (RynthILT)."),
|
||||
["games"] = ("games", "Games", 100, "ILT games (RynthILT)."),
|
||||
};
|
||||
|
||||
/// <summary>The surface name of a tab's view ("section:gear").</summary>
|
||||
public static string SurfaceOf(string tabId) => SurfacePrefix + tabId;
|
||||
|
||||
/// <summary>
|
||||
/// Every view, from what is available now: RynthAi's own (every world) and
|
||||
/// <paramref name="iltTabs"/> (RynthILT's tabs with their sizes and whether the server has
|
||||
/// each feature on; empty without RynthILT or off ILT).
|
||||
/// </summary>
|
||||
public static List<View> Views(IReadOnlyList<IltTabInfo> iltTabs)
|
||||
{
|
||||
var views = new List<View>
|
||||
{
|
||||
// Every world. Session Stats first: a universal primary view, so RynthCore drops its own overview.
|
||||
new("char", string.Empty, "Session stats", SessionSurface, true, new Vector2(360, 240), true, string.Empty,
|
||||
"XP, luminance and kills this session, per hour (RynthAi; RynthTracker, RynthOracle and RynthILT show the same session).", 100),
|
||||
new("pets", string.Empty, "Pets", PetsSurface, true, MiniRemoteTabs.Size(MiniRemoteTabs.Pets), true, string.Empty,
|
||||
"Combat pets: the summon out, essences, and the pet picker (RynthAi).", 100),
|
||||
new("crafting", string.Empty, "Crafting", CraftingSurface, true, MiniRemoteTabs.Size(MiniRemoteTabs.Crafting), true, string.Empty,
|
||||
"Tinkering benches, chunking / clap and split arrows (RynthAi).", 100),
|
||||
new("spells", string.Empty, "Spells", SpellsSurface, true, new Vector2(900, 560), true, string.Empty,
|
||||
"The spell catalog and buff profiles (RynthAi).", 100),
|
||||
new("fellowship", string.Empty, "Fellowship", FellowshipSurface, true, new Vector2(380, 360), true, string.Empty,
|
||||
"Your fellowship: members, leader, XP sharing (RynthAi; also RynthOracle's Fellowship tab).", 100),
|
||||
};
|
||||
|
||||
// Infinite Leaftide: RynthILT's tabs that it shows on this world.
|
||||
foreach (IltTabInfo tab in iltTabs)
|
||||
{
|
||||
if (!tab.Shown || !IsTabId(tab.Id) || !IltPlacement.TryGetValue(tab.Id, out var place)) continue;
|
||||
var size = new Vector2(MathF.Max(0f, tab.Width), MathF.Max(0f, tab.Height));
|
||||
views.Add(new View(place.Section, IltServer, place.Label, SurfaceOf(tab.Id.ToLowerInvariant()), true, size,
|
||||
tab.Available, tab.Available ? string.Empty : NotReportedNote, place.Tooltip, place.Order));
|
||||
}
|
||||
return views;
|
||||
}
|
||||
|
||||
/// <summary>The manifest JSON for <paramref name="views"/> (UTF-8 text, schema version 1).</summary>
|
||||
public static string Build(IReadOnlyList<View> views, IReadOnlyList<Section> sections)
|
||||
{
|
||||
using var stream = new MemoryStream(4096);
|
||||
using (var w = new Utf8JsonWriter(stream))
|
||||
{
|
||||
w.WriteStartObject();
|
||||
w.WriteNumber("version", 1);
|
||||
w.WriteStartArray("sections");
|
||||
foreach (Section s in sections)
|
||||
{
|
||||
w.WriteStartObject();
|
||||
w.WriteString("id", s.Id);
|
||||
w.WriteString("label", s.Label);
|
||||
w.WriteNumber("order", s.Order);
|
||||
w.WriteEndObject();
|
||||
}
|
||||
w.WriteEndArray();
|
||||
w.WriteStartArray("contributions");
|
||||
foreach (View v in views)
|
||||
{
|
||||
w.WriteStartObject();
|
||||
w.WriteString("section", v.Section);
|
||||
w.WriteString("server", v.Server);
|
||||
w.WriteString("label", v.Label);
|
||||
w.WriteString("surface", v.Surface);
|
||||
w.WriteBoolean("primary", v.Primary);
|
||||
if (v.Size.X > 0) w.WriteNumber("width", v.Size.X);
|
||||
if (v.Size.Y > 0) w.WriteNumber("height", v.Size.Y);
|
||||
w.WriteBoolean("enabled", v.Enabled);
|
||||
if (v.Note.Length > 0) w.WriteString("note", v.Note);
|
||||
if (v.Tooltip.Length > 0) w.WriteString("tooltip", v.Tooltip);
|
||||
w.WriteNumber("order", v.Order);
|
||||
w.WriteEndObject();
|
||||
}
|
||||
w.WriteEndArray();
|
||||
w.WriteEndObject();
|
||||
}
|
||||
return Encoding.UTF8.GetString(stream.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>The Mini Remote tab of RynthAi's own a surface draws ("pets", "crafting"), if it is one.</summary>
|
||||
public static bool TryOwnTabOf(string surface, out string tabId)
|
||||
{
|
||||
tabId = surface switch
|
||||
{
|
||||
PetsSurface => MiniRemoteTabs.Pets,
|
||||
CraftingSurface => MiniRemoteTabs.Crafting,
|
||||
_ => string.Empty,
|
||||
};
|
||||
return tabId.Length > 0;
|
||||
}
|
||||
|
||||
/// <summary>The RynthILT tab a "section:<tab>" surface draws, if it names one we place.</summary>
|
||||
public static bool TryIltTabOf(string surface, out string tabId)
|
||||
{
|
||||
tabId = string.Empty;
|
||||
if (!surface.StartsWith(SurfacePrefix, StringComparison.Ordinal)) return false;
|
||||
string id = surface.Substring(SurfacePrefix.Length);
|
||||
if (!IsTabId(id) || !IltPlacement.ContainsKey(id)) return false;
|
||||
tabId = id;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>A short lowercase-ASCII id (letters, digits, '-'): nothing else is spliced into a surface name.</summary>
|
||||
private static bool IsTabId(string? id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id) || id.Length > MaxTabIdLength) return false;
|
||||
foreach (char c in id)
|
||||
if (!(c is >= 'a' and <= 'z' or >= 'A' and <= 'Z' or >= '0' and <= '9' or '-')) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
51
Plugins/RynthCore.Plugin.RynthAi/Huds/ServerCommandModel.cs
Normal file
51
Plugins/RynthCore.Plugin.RynthAi/Huds/ServerCommandModel.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// ServerCommandModel.cs - Server commands other plugins hand RynthAi for its section views.
|
||||
//
|
||||
// A server plugin sends the "servercommands" remote command (Plugins/Shared/ServerCommandShare.cs)
|
||||
// while its server is active: RynthILT sends Infinite Leaftide's /fship commands for the
|
||||
// "fellowship" section every 10 s, and an empty list when ILT isn't active. RynthAi keeps the
|
||||
// latest set per section and drops one that hasn't been re-sent for StaleMs (the sender unloaded
|
||||
// or the engine lost it), so the buttons follow the server without RynthAi knowing any of them.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Huds;
|
||||
|
||||
internal static class ServerCommandModel
|
||||
{
|
||||
/// <summary>A set not re-sent within this long is dropped (senders re-send every 10 s).</summary>
|
||||
public const long StaleMs = 35_000;
|
||||
|
||||
private sealed record Entry(ServerCommandSet Set, long ReceivedAt);
|
||||
|
||||
// Replaced whole on each change: the pump thread writes, the render thread reads.
|
||||
private static Dictionary<string, Entry> _sets = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>Pump thread: stores a "servercommands" push. A malformed payload is ignored, never thrown.</summary>
|
||||
public static void Apply(string payload) => Apply(payload, Environment.TickCount64);
|
||||
|
||||
/// <summary>Stores a push received at <paramref name="now"/> (tests pass the clock).</summary>
|
||||
public static void Apply(string payload, long now)
|
||||
{
|
||||
ServerCommandSet? set = ServerCommandShare.Parse(payload);
|
||||
if (set == null) return;
|
||||
var next = new Dictionary<string, Entry>(Volatile.Read(ref _sets), StringComparer.OrdinalIgnoreCase);
|
||||
if (set.Commands.Count == 0) next.Remove(set.Section);
|
||||
else next[set.Section] = new Entry(set, now);
|
||||
Volatile.Write(ref _sets, next);
|
||||
}
|
||||
|
||||
/// <summary>The commands for <paramref name="section"/>, or null when none are current. Any thread.</summary>
|
||||
public static ServerCommandSet? For(string section) => For(section, Environment.TickCount64);
|
||||
|
||||
/// <summary>The commands for <paramref name="section"/> at <paramref name="now"/>, or null.</summary>
|
||||
public static ServerCommandSet? For(string section, long now)
|
||||
{
|
||||
if (!Volatile.Read(ref _sets).TryGetValue(section, out Entry? e)) return null;
|
||||
return now - e.ReceivedAt <= StaleMs ? e.Set : null;
|
||||
}
|
||||
|
||||
/// <summary>Forgets every set (logout: the next character's server sends its own).</summary>
|
||||
public static void Clear() => Volatile.Write(ref _sets, new Dictionary<string, Entry>(StringComparer.OrdinalIgnoreCase));
|
||||
}
|
||||
|
|
@ -1,13 +1,19 @@
|
|||
// ServerMenuModel.cs - The server sections RynthCore pushes for the Mini Remote's right-click menu.
|
||||
// ServerMenuModel.cs - The servers and sections RynthCore pushes for the Mini Remote's menus.
|
||||
//
|
||||
// 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).
|
||||
// RynthCore decides which servers the client is on (one world check for the engine and every
|
||||
// plugin, with a per-character Auto / On / Off override) and what the engine and the installed
|
||||
// plugins add for each (UI/ServerMenus.cs and UI/Sections in RynthCore). It sends that list as
|
||||
// the "servermenu" remote command when it changes, and again every 30 s. Tab-separated lines:
|
||||
// V id name active 0/1 force auto|on|off detected 0/1 every server (RynthCore 2026.10.5.46+)
|
||||
// X id label every Mini Remote section, rail order (.46+)
|
||||
// S id name active 0/1 force command a server with items
|
||||
// I label command tooltip feature its items
|
||||
// A "tab:<id>" feature is one of RynthAi's own Mini Remote tabs (older RynthCore); "section:<id>"
|
||||
// opens that section in RynthCore's Mini Remote (its command does that).
|
||||
//
|
||||
// Groups stays null until the first push: an older RynthCore, or the ImGui shell off. The menu
|
||||
// then falls back to RynthILT's own ILT entries (RynthILT.Hub section "server-menu").
|
||||
// then falls back to RynthILT's own ILT entries (RynthILT.Hub section "server-menu"). Servers stays
|
||||
// empty until a RynthCore that sends V lines: the world check is then RynthILT's own.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
|
@ -20,27 +26,78 @@ internal sealed record ServerMenuEntry(string Label, string Command, string Tool
|
|||
/// <summary>One server's section: shown while <see cref="Active"/> (detected or forced in RynthCore).</summary>
|
||||
internal sealed record ServerMenuGroup(string Id, string Name, bool Active, string ForceCommand, ServerMenuEntry[] Items);
|
||||
|
||||
/// <summary>RynthCore's verdict for one server: active now, its saved override ("auto", "on", "off"), what detection said.</summary>
|
||||
internal sealed record ServerVerdictLine(string Id, string Name, bool Active, string Force, bool Detected);
|
||||
|
||||
/// <summary>One of RynthCore's Mini Remote sections.</summary>
|
||||
internal sealed record SectionLine(string Id, string Label);
|
||||
|
||||
/// <summary>Everything one push carries.</summary>
|
||||
internal sealed record ServerMenuPayload(ServerMenuGroup[] Groups, ServerVerdictLine[] Servers, SectionLine[] Sections);
|
||||
|
||||
internal static class ServerMenuModel
|
||||
{
|
||||
/// <summary>Feature prefix for items that are Mini Remote tabs (drawn by RynthAi itself).</summary>
|
||||
public const string TabFeaturePrefix = "tab:";
|
||||
|
||||
/// <summary>Feature prefix for items that open a section of RynthCore's Mini Remote.</summary>
|
||||
public const string SectionFeaturePrefix = "section:";
|
||||
|
||||
private static ServerMenuGroup[]? _groups;
|
||||
private static ServerVerdictLine[] _servers = Array.Empty<ServerVerdictLine>();
|
||||
private static SectionLine[] _sections = Array.Empty<SectionLine>();
|
||||
|
||||
/// <summary>The latest sections from RynthCore; null until it sends any. Any thread.</summary>
|
||||
public static ServerMenuGroup[]? Groups => Volatile.Read(ref _groups);
|
||||
|
||||
/// <summary>The latest server verdicts (empty from a RynthCore older than 2026.10.5.46). Any thread.</summary>
|
||||
public static ServerVerdictLine[] Servers => Volatile.Read(ref _servers);
|
||||
|
||||
/// <summary>RynthCore's Mini Remote sections, rail order (empty from an older RynthCore). Any thread.</summary>
|
||||
public static SectionLine[] Sections => Volatile.Read(ref _sections);
|
||||
|
||||
/// <summary>Pump thread: stores a "servermenu" push. A malformed line is skipped, never thrown.</summary>
|
||||
public static void Apply(string payload) => Volatile.Write(ref _groups, Parse(payload));
|
||||
public static void Apply(string payload)
|
||||
{
|
||||
ServerMenuPayload p = ParsePayload(payload);
|
||||
Volatile.Write(ref _servers, p.Servers);
|
||||
Volatile.Write(ref _sections, p.Sections);
|
||||
Volatile.Write(ref _groups, p.Groups);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a payload. Items before the first section line, short lines and unknown line kinds
|
||||
/// are skipped.
|
||||
/// RynthCore's verdict for server <paramref name="id"/>: true / false once it sends V lines,
|
||||
/// null before (an older RynthCore, or no push yet). Any thread.
|
||||
/// </summary>
|
||||
public static ServerMenuGroup[] Parse(string? payload)
|
||||
public static bool? ServerActive(string id)
|
||||
{
|
||||
foreach (ServerVerdictLine s in Servers)
|
||||
if (s.Id.Equals(id, StringComparison.OrdinalIgnoreCase)) return s.Active;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>RynthCore's line for server <paramref name="id"/>, or null.</summary>
|
||||
public static ServerVerdictLine? Server(string id)
|
||||
{
|
||||
foreach (ServerVerdictLine s in Servers)
|
||||
if (s.Id.Equals(id, StringComparison.OrdinalIgnoreCase)) return s;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a payload's server groups. Items before the first section line, short lines and
|
||||
/// unknown line kinds are skipped.
|
||||
/// </summary>
|
||||
public static ServerMenuGroup[] Parse(string? payload) => ParsePayload(payload).Groups;
|
||||
|
||||
/// <summary>Parses a whole payload (groups, server verdicts, sections). Never throws.</summary>
|
||||
public static ServerMenuPayload ParsePayload(string? payload)
|
||||
{
|
||||
var groups = new List<ServerMenuGroup>();
|
||||
if (string.IsNullOrEmpty(payload)) return groups.ToArray();
|
||||
var servers = new List<ServerVerdictLine>();
|
||||
var sections = new List<SectionLine>();
|
||||
if (string.IsNullOrEmpty(payload))
|
||||
return new ServerMenuPayload(groups.ToArray(), servers.ToArray(), sections.ToArray());
|
||||
|
||||
string id = "", name = "", force = "";
|
||||
bool active = false, open = false;
|
||||
|
|
@ -71,9 +128,17 @@ internal static class ServerMenuModel
|
|||
{
|
||||
items.Add(new ServerMenuEntry(f[1], f[2], f[3], f[4]));
|
||||
}
|
||||
else if (f[0] == "V" && f.Length >= 6 && f[1].Length > 0)
|
||||
{
|
||||
servers.Add(new ServerVerdictLine(f[1], f[2].Length > 0 ? f[2] : f[1], f[3] == "1", f[4], f[5] == "1"));
|
||||
}
|
||||
else if (f[0] == "X" && f.Length >= 3 && f[1].Length > 0 && f[2].Length > 0)
|
||||
{
|
||||
sections.Add(new SectionLine(f[1], f[2]));
|
||||
}
|
||||
}
|
||||
Close();
|
||||
return groups.ToArray();
|
||||
return new ServerMenuPayload(groups.ToArray(), servers.ToArray(), sections.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>The tab id of a "tab:<id>" feature, else null.</summary>
|
||||
|
|
@ -81,4 +146,10 @@ internal static class ServerMenuModel
|
|||
feature.StartsWith(TabFeaturePrefix, StringComparison.OrdinalIgnoreCase) && feature.Length > TabFeaturePrefix.Length
|
||||
? feature.Substring(TabFeaturePrefix.Length)
|
||||
: null;
|
||||
|
||||
/// <summary>The section id of a "section:<id>" feature, else null.</summary>
|
||||
public static string? SectionOf(string feature) =>
|
||||
feature.StartsWith(SectionFeaturePrefix, StringComparison.OrdinalIgnoreCase) && feature.Length > SectionFeaturePrefix.Length
|
||||
? feature.Substring(SectionFeaturePrefix.Length)
|
||||
: null;
|
||||
}
|
||||
|
|
|
|||
107
Plugins/RynthCore.Plugin.RynthAi/ItemInfo/SelfRatings.cs
Normal file
107
Plugins/RynthCore.Plugin.RynthAi/ItemInfo/SelfRatings.cs
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.ItemInfo;
|
||||
|
||||
/// <summary>
|
||||
/// The character's own ratings for Item Info's "select yourself" output. Pure: every value comes
|
||||
/// in through a reader, so the tests format it without a client.
|
||||
///
|
||||
/// Where the numbers come from (ACE / ACECustom, nothing server-specific):
|
||||
/// * Totals (PropertyInt 307-316, 323, 331, 350, 351, 381, 382) are what the server resolves
|
||||
/// into an identify of a creature (AppraiseInfo.AddRatings): base + gear + augmentations +
|
||||
/// buffs, the same numbers the client's Ratings page shows. They arrive only with an identify,
|
||||
/// so the plugin asks for one on itself first (they are AssessmentProperty, not SendOnLogin).
|
||||
/// * Luminance augmentations (333-338, 341, 342) are SendOnLogin: always on the player.
|
||||
/// Zero or absent ratings are left out (the server omits zeros too). Plain ASCII.
|
||||
/// </summary>
|
||||
internal static class SelfRatings
|
||||
{
|
||||
/// <summary>One rating: the property id, the Item Info tag and a readable name.</summary>
|
||||
internal readonly record struct Rating(uint Stype, string Tag, string Name);
|
||||
|
||||
/// <summary>The combat totals, in Item Info's rating order (D, DR, C, CD, CR, CDR).</summary>
|
||||
internal static readonly Rating[] Combat =
|
||||
{
|
||||
new(307, "D", "Damage"),
|
||||
new(308, "DR", "Damage Resist"),
|
||||
new(313, "C", "Crit"),
|
||||
new(314, "CD", "Crit Damage"),
|
||||
new(315, "CR", "Crit Resist"),
|
||||
new(316, "CDR", "Crit Damage Resist"),
|
||||
};
|
||||
|
||||
/// <summary>Healing and resistance totals.</summary>
|
||||
internal static readonly Rating[] Other =
|
||||
{
|
||||
new(323, "HB", "Healing Boost"),
|
||||
new(331, "NR", "Nether Resist"),
|
||||
new(350, "DoTR", "DoT Resist"),
|
||||
new(351, "LR", "Life Resist"),
|
||||
};
|
||||
|
||||
/// <summary>PK totals (only non-zero on PK characters).</summary>
|
||||
internal static readonly Rating[] Pk =
|
||||
{
|
||||
new(381, "PKD", "PK Damage"),
|
||||
new(382, "PKDR", "PK Damage Resist"),
|
||||
};
|
||||
|
||||
/// <summary>Luminance augmentation ratings (already part of the totals above).</summary>
|
||||
internal static readonly Rating[] LumAugs =
|
||||
{
|
||||
new(333, "D", "Damage"),
|
||||
new(334, "DR", "Damage Reduction"),
|
||||
new(335, "CD", "Crit Damage"),
|
||||
new(336, "CR", "Crit Reduction"),
|
||||
new(337, "SE", "Surge Effect"),
|
||||
new(338, "SC", "Surge Chance"),
|
||||
new(341, "V", "Vitality"),
|
||||
new(342, "HB", "Healing"),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The output lines. <paramref name="readInt"/> returns a property's value (0 when absent);
|
||||
/// <paramref name="identified"/> is false when the self-identify didn't come back in time, so
|
||||
/// the totals may be missing. <paramref name="oneLine"/> joins everything Mag-style.
|
||||
/// </summary>
|
||||
public static List<string> Build(string name, Func<uint, int> readInt, bool identified, bool oneLine)
|
||||
{
|
||||
var lines = new List<string>(4);
|
||||
|
||||
string combat = Join(Combat, readInt, plus: false);
|
||||
string header = (string.IsNullOrWhiteSpace(name) ? "Your" : name.Trim() + "'s") + " ratings: "
|
||||
+ (combat.Length > 0 ? combat : "no combat ratings");
|
||||
if (!identified) header += " (not identified - totals may be incomplete)";
|
||||
lines.Add(header);
|
||||
|
||||
string other = Join(Other, readInt, plus: false);
|
||||
if (other.Length > 0) lines.Add(other);
|
||||
|
||||
string pk = Join(Pk, readInt, plus: false);
|
||||
if (pk.Length > 0) lines.Add("PK: " + pk);
|
||||
|
||||
string lum = Join(LumAugs, readInt, plus: true);
|
||||
if (lum.Length > 0) lines.Add("Lum augs (in the totals): " + lum);
|
||||
|
||||
return oneLine ? new List<string> { string.Join(" | ", lines) } : lines;
|
||||
}
|
||||
|
||||
/// <summary>"D 45, DR 30, ..." for the non-zero ratings in <paramref name="set"/>; "" when none.</summary>
|
||||
private static string Join(Rating[] set, Func<uint, int> readInt, bool plus)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (Rating r in set)
|
||||
{
|
||||
int v = readInt(r.Stype);
|
||||
if (v == 0) continue;
|
||||
if (sb.Length > 0) sb.Append(", ");
|
||||
sb.Append(r.Tag).Append(' ');
|
||||
if (plus && v > 0) sb.Append('+');
|
||||
sb.Append(v.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
|
||||
|
|
@ -90,12 +91,12 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
ImGui.Spacing();
|
||||
|
||||
string status = _autoVendorStatus?.Invoke() ?? "Not logged in";
|
||||
ImGui.TextDisabled($"Status: {status}");
|
||||
SafeImGui.TextDisabled($"Status: {status}");
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.Checkbox("Enabled##AV", ref _settings.AutoVendorEnabled);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Buy and sell by a loot profile when a vendor opens (and allow /ub autovendor).\n" +
|
||||
SafeImGui.SetTooltip("Buy and sell by a loot profile when a vendor opens (and allow /ub autovendor).\n" +
|
||||
"Profiles: <Vendor Name>.utl or default.utl in your character's AutoVendor\n" +
|
||||
"folder, the server folder, or " + Vendor.AutoVendorManager.MainProfileDir + ".");
|
||||
ImGui.Checkbox("Test Mode (only print what it would do)##AV", ref _settings.AutoVendorTestMode);
|
||||
|
|
@ -139,12 +140,12 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
ImGui.Spacing();
|
||||
|
||||
string status = _autoTradeStatus?.Invoke() ?? "Not logged in";
|
||||
ImGui.TextDisabled($"Status: {status}");
|
||||
SafeImGui.TextDisabled($"Status: {status}");
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.Checkbox("Enabled##AT", ref _settings.AutoTradeEnabled);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("When a trade window opens, add the items that match Keep / Keep # rules in\n" +
|
||||
SafeImGui.SetTooltip("When a trade window opens, add the items that match Keep / Keep # rules in\n" +
|
||||
"<Partner Name>.utl or default.utl (your character's AutoTrade folder, the\n" +
|
||||
"server folder, or " + Trade.AutoTradeManager.MainProfileDir + ").");
|
||||
ImGui.Checkbox("Test Mode (only print what it would add)##AT", ref _settings.AutoTradeTestMode);
|
||||
|
|
@ -208,13 +209,42 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
_settings.SetBuffEnabled(toggle.Buff, on);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One loot timer: the input, then "baseline" when it matches LootBaseline, or "baseline N" when
|
||||
/// it doesn't (hover for what the timer does).
|
||||
/// </summary>
|
||||
private static void LootTimerInput(string label, ref int value, int baseline, string tip)
|
||||
{
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.InputInt(label, ref value);
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip(tip);
|
||||
ImGui.SameLine();
|
||||
if (value == baseline)
|
||||
ImGui.TextDisabled("baseline");
|
||||
else
|
||||
SafeImGui.TextColored(new Vector4(0.9f, 0.7f, 0.2f, 1.0f), $"baseline {baseline}");
|
||||
}
|
||||
|
||||
/// <summary>Writes the six loot timers' baseline values (LootBaseline.cs) into the settings.</summary>
|
||||
private void ApplyLootBaseline()
|
||||
{
|
||||
LootBaseline.Timers b = LootBaseline.Values;
|
||||
_settings.LootContentSettleMs = b.ContentSettleMs;
|
||||
_settings.LootEmptyCorpseMs = b.EmptyCorpseMs;
|
||||
_settings.LootAssessWindowMs = b.AssessWindowMs;
|
||||
_settings.LootRetryTimeoutMs = b.RetryTimeoutMs;
|
||||
_settings.LootOpenRetryMs = b.OpenRetryMs;
|
||||
_settings.LootCorpseTimeoutMs = b.CorpseTimeoutMs;
|
||||
}
|
||||
|
||||
private void RenderTabContent(int tabIndex)
|
||||
{
|
||||
if (tabIndex < 0 || tabIndex >= _settings.AdvancedTabs.Length)
|
||||
return;
|
||||
|
||||
string tabName = _settings.AdvancedTabs[tabIndex];
|
||||
ImGui.TextColored(new Vector4(0.4f, 0.7f, 1.0f, 1.0f), $"Advanced Settings > {tabName}");
|
||||
SafeImGui.TextColored(new Vector4(0.4f, 0.7f, 1.0f, 1.0f), $"Advanced Settings > {tabName}");
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
|
||||
|
|
@ -409,28 +439,28 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
break;
|
||||
|
||||
case "Recharge":
|
||||
ImGui.Text("Self Vitals (%)");
|
||||
SafeImGui.Text("Self Vitals (%)");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt("Heal At", ref _settings.HealAt, 0, 100);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt("Emergency Heal At", ref _settings.EmergencyHealAt, 0, 100);
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("At or under this health %, a healing kit goes first out of Magic mode,\nand a kit or potion is used while a cast is pending. 0 = off.");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip("At or under this health %, a healing kit goes first out of Magic mode,\nand a kit or potion is used while a cast is pending. 0 = off.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt("Stamina To Health At", ref _settings.StaminaToHealthAt, 0, 100);
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("At or under this health %, cast Stamina to Health Self ahead of Heal At\n(after a kit out of Magic mode). 0 = never cast it.");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip("At or under this health %, cast Stamina to Health Self ahead of Heal At\n(after a kit out of Magic mode). 0 = never cast it.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt("Stamina To Health Min Stamina", ref _settings.StaminaToHealthMinStamina, 0, 100);
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Don't cast Stamina to Health unless stamina is over this %.");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip("Don't cast Stamina to Health unless stamina is over this %.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt("Re-stam At", ref _settings.RestamAt, 0, 100);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt("Re-stam To", ref _settings.RestamTo, 0, 100);
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Once a recharge starts under Re-stam At, keep recharging until stamina reaches this %.\n0 = one recharge, as before.");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip("Once a recharge starts under Re-stam At, keep recharging until stamina reaches this %.\n0 = one recharge, as before.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt("Get Mana At", ref _settings.GetManaAt, 0, 100);
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Top-Off Vitals (%)");
|
||||
SafeImGui.Text("Top-Off Vitals (%)");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt("Top HP", ref _settings.TopOffHP, 0, 100);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
|
|
@ -439,7 +469,7 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
ImGui.SliderInt("Top Mana", ref _settings.TopOffMana, 0, 100);
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Helper Settings (%)");
|
||||
SafeImGui.Text("Helper Settings (%)");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.SliderInt("Heal Others", ref _settings.HealOthersAt, 0, 100);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
|
|
@ -453,7 +483,7 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
ImGui.Separator();
|
||||
ImGui.Checkbox("Use Recklessness", ref _settings.UseRecklessness);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("When enabled and Recklessness is trained, auto power uses 80% instead of 100%.");
|
||||
SafeImGui.SetTooltip("When enabled and Recklessness is trained, auto power uses 80% instead of 100%.");
|
||||
|
||||
ImGui.Spacing();
|
||||
bool meleeAuto = _settings.MeleeAttackPower < 0;
|
||||
|
|
@ -499,6 +529,26 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.Combo("Missile Attack Height", ref _settings.MissileAttackHeight, AttackHeights, AttackHeights.Length);
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Weapon Swaps");
|
||||
ImGui.SetNextItemWidth(150);
|
||||
ImGui.SliderInt("Wait After Target Switch (ms)", ref _settings.WeaponSwapSettleMs, 0, 3000);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("After switching from one live target to another, wait this long before a weapon\n" +
|
||||
"swap starts, so a target that changes again doesn't cost a wasted swap.\n" +
|
||||
"A new target after a kill swaps at once. 0 = never wait.");
|
||||
ImGui.SetNextItemWidth(150);
|
||||
ImGui.SliderInt("No Swap Under Target Health %", ref _settings.WeaponSwapMinHealthPct, 0, 100);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("A target at or under this health is finished with the weapon in hand\n" +
|
||||
"(same kind of weapon only). A swap under way always completes. 0 = off.");
|
||||
ImGui.SetNextItemWidth(150);
|
||||
ImGui.SliderInt("Weakness Swap Min Gain %", ref _settings.WeaponSwapMinGainPct, 0, 200);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Auto (weakness) picks only: swap to another element only when it does at least this\n" +
|
||||
"much more damage than the weapon in hand. A launcher swap with other ammo costs about 4 s.\n" +
|
||||
"Damage tab, slayer and Monsters rule picks always swap. 0 = off.");
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
ImGui.Checkbox("Use Native Attack", ref _settings.UseNativeAttack);
|
||||
|
|
@ -689,7 +739,7 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
|
||||
ImGui.Checkbox("Go To Closest Waypoint", ref _settings.NavResumeNearest);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(NavResumeNearestTip);
|
||||
SafeImGui.SetTooltip(NavResumeNearestTip);
|
||||
|
||||
ImGui.Checkbox("Find A Way Back When Stuck", ref _settings.NavRecoveryEnabled);
|
||||
if (ImGui.IsItemHovered())
|
||||
|
|
@ -819,7 +869,7 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
"listed weapons.");
|
||||
string skipped = _buffSkips?.Invoke() ?? "";
|
||||
if (_settings.SkipUnusableBuffs && skipped.Length > 0)
|
||||
ImGui.TextWrapped("Skipping: " + skipped);
|
||||
SafeImGui.TextWrapped("Skipping: " + skipped);
|
||||
|
||||
ImGui.Spacing();
|
||||
if (ImGui.Button("Force Buff##forceBuff") && _forceBuff != null) _forceBuff();
|
||||
|
|
@ -887,7 +937,7 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
case "Looting":
|
||||
ImGui.Checkbox("Enable Looting", ref _settings.EnableLooting);
|
||||
ImGui.Checkbox("Boost Loot Priority", ref _settings.BoostLootPriority);
|
||||
ImGui.Checkbox("Loot Only Rare Corpses", ref _settings.LootOnlyRareCorpses);
|
||||
// "Loot Only Rare Corpses" is hidden: nothing reads LootOnlyRareCorpses.
|
||||
ImGui.Checkbox("Learn Unknown Spells", ref _settings.ReadUnknownScrolls);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Loots scrolls of spells you don't know and can learn (magic school trained or\nspecialized, skill high enough), and reads them when it's safe. Scrolls already\nin your pack are read too.");
|
||||
|
|
@ -934,22 +984,26 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
ImGui.Text("Loot Timers (ms)");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.InputInt("Inter-Item Delay", ref _settings.LootInterItemDelayMs);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.InputInt("Content Settle", ref _settings.LootContentSettleMs);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.InputInt("Empty Corpse Wait", ref _settings.LootEmptyCorpseMs);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.InputInt("Closing Delay", ref _settings.LootClosingDelayMs);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.InputInt("Assess Window", ref _settings.LootAssessWindowMs);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.InputInt("Loot Retry Timeout", ref _settings.LootRetryTimeoutMs);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.InputInt("Corpse Open Retry", ref _settings.LootOpenRetryMs);
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.InputInt("Corpse Timeout", ref _settings.LootCorpseTimeoutMs);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("The baseline is measured from live looting on ACE (2026-10-14). The log's\n[LootSettings] line lists each timer as baseline or custom.");
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("Use Baseline##lootTimers"))
|
||||
ApplyLootBaseline();
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Set all six loot timers to the baseline.");
|
||||
// Inter-Item Delay and Closing Delay are hidden: the corpse looting never reads them.
|
||||
LootTimerInput("Content Settle", ref _settings.LootContentSettleMs, LootBaseline.ContentSettleMs,
|
||||
"Wait after an open for the container's items. Only used when the items\naren't already known; on ACE they always were.");
|
||||
LootTimerInput("Empty Corpse Wait", ref _settings.LootEmptyCorpseMs, LootBaseline.EmptyCorpseMs,
|
||||
"Wait for a corpse's contents before probing it or calling it empty.");
|
||||
LootTimerInput("Assess Window", ref _settings.LootAssessWindowMs, LootBaseline.AssessWindowMs,
|
||||
"Hold items for their appraisal. Measured replies: 127 ms typical,\n256 ms at the 95th percentile, 350 ms at most.");
|
||||
LootTimerInput("Loot Retry Timeout", ref _settings.LootRetryTimeoutMs, LootBaseline.RetryTimeoutMs,
|
||||
"Wait, once the character is still, before resending a pickup that hasn't\nlanded. Too short resends pickups the server is still doing.");
|
||||
LootTimerInput("Corpse Open Retry", ref _settings.LootOpenRetryMs, LootBaseline.OpenRetryMs,
|
||||
"Wait before sending another open to a corpse that hasn't opened.");
|
||||
LootTimerInput("Corpse Timeout", ref _settings.LootCorpseTimeoutMs, LootBaseline.CorpseTimeoutMs,
|
||||
"Give up on a claimed corpse after this long. The clock stops during combat\nand buffing.");
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
|
|
@ -995,10 +1049,10 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
: new Vector4(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
ImGui.Text("State:");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(stateColor, stateLabel);
|
||||
SafeImGui.TextColored(stateColor, stateLabel);
|
||||
|
||||
if (!string.IsNullOrEmpty(_missileCraftingManager.StatusMessage))
|
||||
ImGui.TextWrapped(_missileCraftingManager.StatusMessage);
|
||||
SafeImGui.TextWrapped(_missileCraftingManager.StatusMessage);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1007,7 +1061,7 @@ internal sealed class LegacyAdvancedSettingsUi
|
|||
break;
|
||||
|
||||
default:
|
||||
ImGui.Text($"Settings for {tabName} are currently under development.");
|
||||
SafeImGui.Text($"Settings for {tabName} are currently under development.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1056,6 +1056,9 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
SummonPets = s.SummonPets,
|
||||
PetMinMonsters = s.PetMinMonsters,
|
||||
// Spell Combat
|
||||
WeaponSwapSettleMs = s.WeaponSwapSettleMs,
|
||||
WeaponSwapMinHealthPct = s.WeaponSwapMinHealthPct,
|
||||
WeaponSwapMinGainPct = s.WeaponSwapMinGainPct,
|
||||
SpellCastIntervalMs = s.SpellCastIntervalMs,
|
||||
AttackSpellIntervalMs = s.AttackSpellIntervalMs,
|
||||
CastDispelSelf = s.CastDispelSelf,
|
||||
|
|
@ -1292,6 +1295,9 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
s.SummonPets = p.SummonPets;
|
||||
s.PetMinMonsters = p.PetMinMonsters;
|
||||
// Spell Combat
|
||||
if (p.WeaponSwapSettleMs is int wsSettle) s.WeaponSwapSettleMs = Math.Clamp(wsSettle, 0, 3000);
|
||||
if (p.WeaponSwapMinHealthPct is int wsHealth) s.WeaponSwapMinHealthPct = Math.Clamp(wsHealth, 0, 100);
|
||||
if (p.WeaponSwapMinGainPct is int wsGain) s.WeaponSwapMinGainPct = Math.Clamp(wsGain, 0, 200);
|
||||
s.SpellCastIntervalMs = p.SpellCastIntervalMs;
|
||||
if (p.AttackSpellIntervalMs is int attackDelay) s.AttackSpellIntervalMs = attackDelay; // absent = unchanged
|
||||
s.CastDispelSelf = p.CastDispelSelf;
|
||||
|
|
@ -1841,6 +1847,9 @@ internal sealed partial class LegacyDashboardRenderer
|
|||
dst.MeleeAttackPower = tmp.MeleeAttackPower;
|
||||
dst.MissileAttackPower = tmp.MissileAttackPower;
|
||||
dst.UseRecklessness = tmp.UseRecklessness;
|
||||
dst.WeaponSwapSettleMs = Math.Clamp(tmp.WeaponSwapSettleMs, 0, 3000);
|
||||
dst.WeaponSwapMinHealthPct = Math.Clamp(tmp.WeaponSwapMinHealthPct, 0, 100);
|
||||
dst.WeaponSwapMinGainPct = Math.Clamp(tmp.WeaponSwapMinGainPct, 0, 200);
|
||||
dst.UseNativeAttack = tmp.UseNativeAttack;
|
||||
dst.WieldUnlistedWandWhenNoneListed = tmp.WieldUnlistedWandWhenNoneListed;
|
||||
dst.OffhandDefault = OffhandRules.SettingValue(OffhandRules.Parse(tmp.OffhandDefault, OffhandMode.Auto));
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.RynthAi.ItemInfo;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
|
||||
|
|
@ -87,7 +88,7 @@ internal sealed class LegacyItemInfoUi
|
|||
if (string.IsNullOrEmpty(_previewText))
|
||||
ImGui.TextDisabled("Select an item to preview its info line.");
|
||||
else
|
||||
ImGui.TextWrapped(s.Prefix + _previewText);
|
||||
SafeImGui.TextWrapped(s.Prefix + _previewText);
|
||||
ImGui.EndChild();
|
||||
|
||||
if (ImGui.Button("Print to chat##iiPrint")) _printSelected?.Invoke();
|
||||
|
|
@ -155,7 +156,7 @@ internal sealed class LegacyItemInfoUi
|
|||
if (ImGui.Combo("Layout" + idSuffix, ref s.Layout, MagItemInfoCatalog.Layouts, MagItemInfoCatalog.Layouts.Length))
|
||||
s.Sanitize();
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(
|
||||
SafeImGui.SetTooltip(
|
||||
"Pet-style lines (like the Mini Remote's Pets roster):\n" +
|
||||
" 1 Name (type mastery), set, AL, tinks, applied, craft\n" +
|
||||
" 2 imbues, slayer, damage, variance, %a / %md / %mc\n" +
|
||||
|
|
@ -191,7 +192,7 @@ internal sealed class LegacyItemInfoUi
|
|||
if (ImGui.Checkbox($"{f.Label}##iiF{(int)f.Field}", ref shown))
|
||||
s.SetHidden(f.Field, !shown);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextColored(ExampleColor, f.Example);
|
||||
SafeImGui.TextColored(ExampleColor, f.Example);
|
||||
}
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Numerics;
|
|||
using ImGuiNET;
|
||||
using RynthCore.Plugin.RynthAi.Meta;
|
||||
using RynthCore.Install;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
|
||||
|
|
@ -140,7 +141,7 @@ internal sealed class LegacyMetaUi
|
|||
if (!string.IsNullOrEmpty(_sourceApplyMessage) &&
|
||||
(DateTime.Now - _sourceApplyTime).TotalSeconds < 4)
|
||||
{
|
||||
ImGui.TextColored(new Vector4(0, 1, 0.4f, 1f), _sourceApplyMessage);
|
||||
SafeImGui.TextColored(new Vector4(0, 1, 0.4f, 1f), _sourceApplyMessage);
|
||||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
|
|
@ -345,7 +346,7 @@ internal sealed class LegacyMetaUi
|
|||
: rule.Children;
|
||||
int childCount = actionList?.Count ?? 0;
|
||||
bool expanded = _expandedRuleIndices.Contains(globalIdx);
|
||||
ImGui.TextColored(new Vector4(1, 1, 0, 1), $"All: [{childCount} actions] (right-click to expand)");
|
||||
SafeImGui.TextColored(new Vector4(1, 1, 0, 1), $"All: [{childCount} actions] (right-click to expand)");
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
ToggleExpand();
|
||||
|
||||
|
|
@ -356,7 +357,7 @@ internal sealed class LegacyMetaUi
|
|||
var child = actionList[ai];
|
||||
string childText = child.Action.ToString() +
|
||||
(string.IsNullOrEmpty(child.ActionData) ? "" : $": {child.ActionData}");
|
||||
ImGui.TextDisabled($" {ai + 1}. {childText}");
|
||||
SafeImGui.TextDisabled($" {ai + 1}. {childText}");
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
ToggleExpand();
|
||||
}
|
||||
|
|
@ -366,13 +367,13 @@ internal sealed class LegacyMetaUi
|
|||
!string.IsNullOrEmpty(rule.ActionData) && rule.ActionData.Contains(';'))
|
||||
{
|
||||
var parts = rule.ActionData.Split(';');
|
||||
ImGui.Text($"EmbeddedNavRoute: {parts[0]} ({parts[1]} pts)");
|
||||
SafeImGui.Text($"EmbeddedNavRoute: {parts[0]} ({parts[1]} pts)");
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
ToggleExpand();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text(rule.Action.ToString() +
|
||||
SafeImGui.Text(rule.Action.ToString() +
|
||||
(string.IsNullOrEmpty(rule.ActionData) ? "" : $": {rule.ActionData}"));
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||
ToggleExpand();
|
||||
|
|
@ -557,7 +558,7 @@ internal sealed class LegacyMetaUi
|
|||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
ImGui.TextColored(new Vector4(1, 1, 0, 1), $"{rule.Condition} Sub-Conditions");
|
||||
SafeImGui.TextColored(new Vector4(1, 1, 0, 1), $"{rule.Condition} Sub-Conditions");
|
||||
ImGui.Indent(15f);
|
||||
|
||||
for (int i = 0; i < rule.Children.Count; i++)
|
||||
|
|
@ -641,7 +642,7 @@ internal sealed class LegacyMetaUi
|
|||
if (!string.IsNullOrEmpty(sName))
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(new Vector4(0, 1, 1, 1), $"({sName})");
|
||||
SafeImGui.TextColored(new Vector4(0, 1, 1, 1), $"({sName})");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1078,7 +1079,7 @@ internal sealed class LegacyMetaUi
|
|||
|
||||
// Status message
|
||||
if (!string.IsNullOrEmpty(_statusMessage) && (DateTime.Now - _statusTime).TotalSeconds < 5)
|
||||
ImGui.TextColored(new Vector4(0, 1, 0, 1), _statusMessage);
|
||||
SafeImGui.TextColored(new Vector4(0, 1, 0, 1), _statusMessage);
|
||||
|
||||
// Save popup
|
||||
if (_openSavePopup)
|
||||
|
|
|
|||
|
|
@ -35,14 +35,14 @@ internal sealed class LegacyNavigationUi
|
|||
}
|
||||
|
||||
string activeNavName = string.IsNullOrEmpty(_settings.CurrentNavPath) ? "None (Unsaved)" : Path.GetFileName(_settings.CurrentNavPath);
|
||||
ImGui.TextColored(new Vector4(1, 1, 0, 1), $"Active Nav: {activeNavName}");
|
||||
SafeImGui.TextColored(new Vector4(1, 1, 0, 1), $"Active Nav: {activeNavName}");
|
||||
|
||||
if (!string.IsNullOrEmpty(_settings.NavStatusLine))
|
||||
{
|
||||
var statusColor = _settings.NavIsStuck
|
||||
? new Vector4(0.91f, 0.70f, 0.20f, 1.00f) // amber
|
||||
: new Vector4(0.25f, 0.85f, 0.45f, 1.00f); // green
|
||||
ImGui.TextColored(statusColor, _settings.NavStatusLine);
|
||||
SafeImGui.TextColored(statusColor, _settings.NavStatusLine);
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ using System.IO;
|
|||
using System.Numerics;
|
||||
using System.Threading;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
|
||||
|
|
@ -80,8 +81,18 @@ internal sealed unsafe class LegacySpellsUi
|
|||
_refreshProfileList = refreshProfileList;
|
||||
}
|
||||
|
||||
/// <summary>True while the window is open (the plugin only feeds it data then).</summary>
|
||||
public bool Visible => _settings.ShowSpellsWindow;
|
||||
/// <summary>How long after its last embedded frame the body still counts as on screen.</summary>
|
||||
private const long EmbeddedVisibleMs = 1500;
|
||||
|
||||
/// <summary>When RynthCore's Spells section last drew the body (TickCount64); render thread writes.</summary>
|
||||
private long _embeddedDrawnAt = long.MinValue / 2;
|
||||
|
||||
/// <summary>
|
||||
/// True while the window is open or RynthCore's Spells section shows the body (the plugin only
|
||||
/// feeds it data then). Any thread.
|
||||
/// </summary>
|
||||
public bool Visible => _settings.ShowSpellsWindow
|
||||
|| Environment.TickCount64 - Interlocked.Read(ref _embeddedDrawnAt) < EmbeddedVisibleMs;
|
||||
|
||||
// ── Pump-thread side ────────────────────────────────────────────────────
|
||||
|
||||
|
|
@ -115,36 +126,55 @@ internal sealed unsafe class LegacySpellsUi
|
|||
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();
|
||||
RenderBody();
|
||||
}
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RynthCore's Spells section (RynthPluginRenderEmbed "section:spells"): the window's body
|
||||
/// drawn into the engine's current window. Render thread.
|
||||
/// </summary>
|
||||
public void RenderEmbedded()
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
// First frame after a gap: the same refresh as the window's open.
|
||||
if (now - Interlocked.Read(ref _embeddedDrawnAt) >= EmbeddedVisibleMs && !_settings.ShowSpellsWindow) OnShown();
|
||||
Interlocked.Exchange(ref _embeddedDrawnAt, now);
|
||||
RenderBody();
|
||||
}
|
||||
|
||||
/// <summary>The catalog (left, resizable) and the profile editor (right), in the current window.</summary>
|
||||
private void RenderBody()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>Each time the window opens: refresh the file list and open the active profile.</summary>
|
||||
private void OnShown()
|
||||
{
|
||||
|
|
@ -187,7 +217,7 @@ internal sealed unsafe class LegacySpellsUi
|
|||
bool knownReady = Volatile.Read(ref _known) != null;
|
||||
if (ImGui.Checkbox("Known only##spknown", ref _knownOnly)) _rowsDirty = true;
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(knownReady
|
||||
SafeImGui.SetTooltip(knownReady
|
||||
? "Only spells in your spellbook."
|
||||
: "Waiting for your spellbook (it is read a few seconds after login).");
|
||||
|
||||
|
|
@ -225,7 +255,7 @@ internal sealed unsafe class LegacySpellsUi
|
|||
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.");
|
||||
SafeImGui.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
|
||||
|
|
@ -275,7 +305,7 @@ internal sealed unsafe class LegacySpellsUi
|
|||
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."
|
||||
SafeImGui.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);
|
||||
|
|
@ -468,7 +498,7 @@ internal sealed unsafe class LegacySpellsUi
|
|||
// Which list buffing uses.
|
||||
if (editIsActive)
|
||||
{
|
||||
ImGui.TextColored(GoodColor, _dirty ? "Buffing uses this profile (save to apply edits)." : "Buffing uses this profile.");
|
||||
SafeImGui.TextColored(GoodColor, _dirty ? "Buffing uses this profile (save to apply edits)." : "Buffing uses this profile.");
|
||||
}
|
||||
else if (ImGui.Button("Use for buffing##spuse"))
|
||||
{
|
||||
|
|
@ -499,7 +529,7 @@ internal sealed unsafe class LegacySpellsUi
|
|||
ImGui.SameLine();
|
||||
int enabled = 0;
|
||||
foreach (var en in _edit.Entries) if (en.Enabled) enabled++;
|
||||
ImGui.TextDisabled($"{enabled} of {_edit.Entries.Count} on");
|
||||
SafeImGui.TextDisabled($"{enabled} of {_edit.Entries.Count} on");
|
||||
|
||||
float notesH = ImGui.GetTextLineHeightWithSpacing() * 3.2f;
|
||||
float statusH = ImGui.GetTextLineHeightWithSpacing() * 1.4f;
|
||||
|
|
@ -515,8 +545,8 @@ internal sealed unsafe class LegacySpellsUi
|
|||
|
||||
if (_status.Length > 0)
|
||||
{
|
||||
if (_statusIsWarning) ImGui.TextColored(WarnColor, _status);
|
||||
else ImGui.TextDisabled(_status);
|
||||
if (_statusIsWarning) SafeImGui.TextColored(WarnColor, _status);
|
||||
else SafeImGui.TextDisabled(_status);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -555,12 +585,12 @@ internal sealed unsafe class LegacySpellsUi
|
|||
|
||||
ImGui.TableSetColumnIndex(1);
|
||||
if (entry.Enabled) ImGui.TextUnformatted(entry.Name);
|
||||
else ImGui.TextDisabled(entry.Name);
|
||||
else SafeImGui.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);
|
||||
SafeImGui.TextDisabled(entry.Key);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Buffing casts the highest level of this spell you know.");
|
||||
ImGui.TableSetColumnIndex(3);
|
||||
|
|
|
|||
|
|
@ -113,14 +113,19 @@ public sealed class LegacyUiSettings
|
|||
public bool EnableMissileCrafting = true;
|
||||
public int MissileCraftAmmoThreshold = 1000;
|
||||
|
||||
/// <summary>Not read by the corpse looting (pickups are paced by the server's confirmations);
|
||||
/// kept so saved profiles round-trip. Hidden in Advanced Settings.</summary>
|
||||
public int LootInterItemDelayMs = 50;
|
||||
public int LootContentSettleMs = 100;
|
||||
public int LootEmptyCorpseMs = 300;
|
||||
// Loot timer defaults are the measured baseline (LootBaseline.cs).
|
||||
public int LootContentSettleMs = LootBaseline.ContentSettleMs;
|
||||
public int LootEmptyCorpseMs = LootBaseline.EmptyCorpseMs;
|
||||
/// <summary>Not read by the corpse looting (a close is timed by the deferred-close logic); kept
|
||||
/// so saved profiles round-trip. Hidden in Advanced Settings.</summary>
|
||||
public int LootClosingDelayMs = 200;
|
||||
public int LootAssessWindowMs = 200;
|
||||
public int LootRetryTimeoutMs = 500;
|
||||
public int LootOpenRetryMs = 1500;
|
||||
public int LootCorpseTimeoutMs = 12000;
|
||||
public int LootAssessWindowMs = LootBaseline.AssessWindowMs;
|
||||
public int LootRetryTimeoutMs = LootBaseline.RetryTimeoutMs;
|
||||
public int LootOpenRetryMs = LootBaseline.OpenRetryMs;
|
||||
public int LootCorpseTimeoutMs = LootBaseline.CorpseTimeoutMs;
|
||||
public bool LootJumpEnabled = false;
|
||||
public int LootJumpHeight = 10; // 0–100; maps to 0.0–1.0 JumpNonAutonomous extent
|
||||
|
||||
|
|
@ -271,6 +276,8 @@ public sealed class LegacyUiSettings
|
|||
/// on the way as usual, recover the corpse, then carry on. Off by default.
|
||||
/// </summary>
|
||||
public bool TravelToOwnCorpse;
|
||||
/// <summary>Not read by the corpse looting (no rare-corpse check exists); kept so saved profiles
|
||||
/// round-trip. Hidden in Advanced Settings. The meta/MagTools option of that name sets Mine Only.</summary>
|
||||
public bool LootOnlyRareCorpses;
|
||||
/// <summary>Also pick up loose ground items that match the loot profile, within the corpse max range.</summary>
|
||||
public bool EnableGroundLoot;
|
||||
|
|
@ -473,6 +480,18 @@ public sealed class LegacyUiSettings
|
|||
/// <summary>Auto: dual wield rather than a shield when the Dual Wield skill is trained and a
|
||||
/// second one-handed melee weapon is listed. Off by default (the shield).</summary>
|
||||
public bool PreferDualWield;
|
||||
/// <summary>
|
||||
/// Weapon swaps (CombatManager.SwapDeferReason). A switch from one live target to another
|
||||
/// waits this long (ms) before a swap starts, so a target that changes again doesn't cost a
|
||||
/// wasted swap. A lock after a kill or drop swaps at once. 0 = never wait.
|
||||
/// </summary>
|
||||
public int WeaponSwapSettleMs = 750;
|
||||
/// <summary>No new swap (same kind) onto a target at or under this health %: finish it with
|
||||
/// the weapon in hand. 0 = off.</summary>
|
||||
public int WeaponSwapMinHealthPct = 25;
|
||||
/// <summary>A weakness pick (Auto) swaps only for at least this % more damage than the weapon
|
||||
/// in hand (WeaponPlanner.KeepInHand). Damage tab, slayer and Monsters rule picks always swap. 0 = off.</summary>
|
||||
public int WeaponSwapMinGainPct = 20;
|
||||
public int MeleeAttackHeight = 1;
|
||||
public int MissileAttackHeight = 1;
|
||||
|
||||
|
|
@ -1028,6 +1047,11 @@ public sealed class SettingsBridgePayload
|
|||
public bool SummonPets { get; set; }
|
||||
public int PetMinMonsters { get; set; }
|
||||
|
||||
// Weapon swaps (only when the sender includes them).
|
||||
public int? WeaponSwapSettleMs { get; set; }
|
||||
public int? WeaponSwapMinHealthPct { get; set; }
|
||||
public int? WeaponSwapMinGainPct { get; set; }
|
||||
|
||||
// Spell Combat
|
||||
public int SpellCastIntervalMs { get; set; }
|
||||
// Nullable since 0 became a real value (2026-10-08): a file without it keeps the default.
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ internal enum LootPickupResult
|
|||
/// </summary>
|
||||
internal static class LootPickup
|
||||
{
|
||||
/// <remarks><paramref name="skip"/>: destinations the server refused lately (<see cref="PackRefusals"/>).</remarks>
|
||||
public static LootPickupResult Send(RynthCoreHost host, WorldObjectCache? cache, uint itemId, uint playerId,
|
||||
out uint destination)
|
||||
out uint destination, System.Func<int, bool>? skip = null)
|
||||
{
|
||||
destination = 0;
|
||||
if (itemId == 0) return LootPickupResult.Failed;
|
||||
|
|
@ -39,7 +40,7 @@ internal static class LootPickup
|
|||
int pid = unchecked((int)playerId);
|
||||
int dest = cache == null
|
||||
? pid
|
||||
: WorldObjectCache.FindLootDestination(cache.GetDirectInventory(forceRefresh: false), pid, host);
|
||||
: WorldObjectCache.FindLootDestination(cache.GetDirectInventory(forceRefresh: false), pid, host, skip);
|
||||
if (dest == 0) return LootPickupResult.NoRoom;
|
||||
destination = unchecked((uint)dest);
|
||||
return host.MoveItemExternal(itemId, destination, 0) ? LootPickupResult.Moved : LootPickupResult.Failed;
|
||||
|
|
|
|||
39
Plugins/RynthCore.Plugin.RynthAi/Loot/PackRefusals.cs
Normal file
39
Plugins/RynthCore.Plugin.RynthAi/Loot/PackRefusals.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Loot;
|
||||
|
||||
/// <summary>
|
||||
/// Packs the server would not take loot into. The destination comes from the client's own
|
||||
/// item counts, and a side pack whose contents the client never loaded counts as nearly empty
|
||||
/// however full it is: every item went to that one pack, the server refused all 3 tries each
|
||||
/// time, and every item on every corpse was skipped (Drakkon, 2026-10-15, 62 items in a row).
|
||||
/// A pack that takes none of an item's tries counts as full for <see cref="HoldMs"/>; the
|
||||
/// destination search skips it, so the next pack is tried. Pure: the caller passes the time.
|
||||
/// </summary>
|
||||
internal sealed class PackRefusals
|
||||
{
|
||||
/// <summary>How long a refusing pack is left out (time to free some room, or open it).</summary>
|
||||
public const long HoldMs = 5 * 60_000;
|
||||
|
||||
private readonly Dictionary<int, long> _until = new();
|
||||
|
||||
/// <summary>The server took none of the tries into <paramref name="packId"/>.</summary>
|
||||
public void Refuse(int packId, long nowMs)
|
||||
{
|
||||
if (packId != 0) _until[packId] = nowMs + HoldMs;
|
||||
}
|
||||
|
||||
/// <summary>True while <paramref name="packId"/> is left out.</summary>
|
||||
public bool IsRefused(int packId, long nowMs)
|
||||
{
|
||||
if (!_until.TryGetValue(packId, out long until)) return false;
|
||||
if (nowMs < until) return true;
|
||||
_until.Remove(packId);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>An item landed in <paramref name="packId"/>: it has room after all.</summary>
|
||||
public void Accepted(int packId) => _until.Remove(packId);
|
||||
|
||||
public void Clear() => _until.Clear();
|
||||
}
|
||||
114
Plugins/RynthCore.Plugin.RynthAi/LootBaseline.cs
Normal file
114
Plugins/RynthCore.Plugin.RynthAi/LootBaseline.cs
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
/// <summary>
|
||||
/// The baseline loot timers: what the Loot Timers in Advanced Settings should be unless a server or
|
||||
/// connection needs otherwise. Measured from live corpse looting on ACE (Silentkelpie on
|
||||
/// InfiniteLeaftide, 2026-10-14 12:38-13:53: 226 corpses opened, 39 pickups):
|
||||
/// <list type="bullet">
|
||||
/// <item>Every open found its items already in the object cache, so Content Settle and Empty Corpse
|
||||
/// Wait were never waited on.</item>
|
||||
/// <item>Appraisals (ID replies) for a corpse arrived 127 ms after the request at the median, 256 ms
|
||||
/// at the 95th percentile, 350 ms at most.</item>
|
||||
/// <item>No pickup needed a retry with a 1000 ms Loot Retry Timeout (it counts from when the
|
||||
/// character stops animating); every pickup was confirmed 1.7-2.2 s after the send.</item>
|
||||
/// <item>No corpse reached the 12 s Corpse Timeout, and 199 of 203 corpses opened on the first try.</item>
|
||||
/// </list>
|
||||
/// Dependency-free so the RynthAi tests compile it directly.
|
||||
/// </summary>
|
||||
internal static class LootBaseline
|
||||
{
|
||||
/// <summary>Wait after an open for the client to fill the container (used only when the cache is empty).</summary>
|
||||
public const int ContentSettleMs = 100;
|
||||
/// <summary>Wait for the container's contents before probing it, and before calling a corpse empty.</summary>
|
||||
public const int EmptyCorpseMs = 300;
|
||||
/// <summary>Hold items for their appraisal; above the 256 ms 95th percentile of the measured replies.</summary>
|
||||
public const int AssessWindowMs = 300;
|
||||
/// <summary>Wait, once the character is still, before resending a pickup that hasn't landed.</summary>
|
||||
public const int RetryTimeoutMs = 1000;
|
||||
/// <summary>Wait before sending another open to a corpse that hasn't opened.</summary>
|
||||
public const int OpenRetryMs = 1500;
|
||||
/// <summary>Give up on a claimed corpse after this long (the clock stops during combat and buff holds).</summary>
|
||||
public const int CorpseTimeoutMs = 12000;
|
||||
|
||||
/// <summary>The six loot timers that the corpse looting reads.</summary>
|
||||
public readonly record struct Timers(
|
||||
int ContentSettleMs, int EmptyCorpseMs, int AssessWindowMs,
|
||||
int RetryTimeoutMs, int OpenRetryMs, int CorpseTimeoutMs);
|
||||
|
||||
/// <summary>The baseline as a set of timers (what "Use Baseline" writes into the settings).</summary>
|
||||
public static Timers Values => new(ContentSettleMs, EmptyCorpseMs, AssessWindowMs,
|
||||
RetryTimeoutMs, OpenRetryMs, CorpseTimeoutMs);
|
||||
|
||||
/// <summary>
|
||||
/// One timer compared with its baseline. <paramref name="FloorMs"/> is the lowest value the loot
|
||||
/// code honours; a setting below it behaves as the floor.
|
||||
/// </summary>
|
||||
public readonly record struct Entry(string Label, int Value, int Baseline, int FloorMs)
|
||||
{
|
||||
public bool IsBaseline => Value == Baseline;
|
||||
public bool BelowFloor => Value < FloorMs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The timers next to their baselines, in the order the Advanced Settings show them. The floors
|
||||
/// are the Math.Max minimums in CorpseOpenController (Empty Corpse Wait is floored at 200 ms for
|
||||
/// the empty check and at 300 ms for the contents wait; the lower one is reported).
|
||||
/// </summary>
|
||||
public static IReadOnlyList<Entry> Compare(Timers t) => new[]
|
||||
{
|
||||
new Entry("Content Settle", t.ContentSettleMs, ContentSettleMs, 50),
|
||||
new Entry("Empty Corpse Wait", t.EmptyCorpseMs, EmptyCorpseMs, 200),
|
||||
new Entry("Assess Window", t.AssessWindowMs, AssessWindowMs, 100),
|
||||
new Entry("Loot Retry Timeout", t.RetryTimeoutMs, RetryTimeoutMs, 150),
|
||||
new Entry("Corpse Open Retry", t.OpenRetryMs, OpenRetryMs, 500),
|
||||
new Entry("Corpse Timeout", t.CorpseTimeoutMs, CorpseTimeoutMs, 2000),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The log line for a character's loot timers: each one marked "baseline" or "custom (baseline N)",
|
||||
/// plus a count, and a note when the approach range's Min is above its Max (Min is then used as Max).
|
||||
/// Ranges are in yards as stored in the settings.
|
||||
/// </summary>
|
||||
public static string Describe(Timers t, double approachMaxYards, double approachMinYards)
|
||||
{
|
||||
IReadOnlyList<Entry> entries = Compare(t);
|
||||
var sb = new StringBuilder("[LootSettings] ");
|
||||
int custom = 0;
|
||||
for (int i = 0; i < entries.Count; i++)
|
||||
{
|
||||
Entry e = entries[i];
|
||||
if (i > 0) sb.Append(" | ");
|
||||
sb.Append(e.Label).Append(' ').Append(e.Value).Append(" ms ");
|
||||
if (e.IsBaseline)
|
||||
{
|
||||
sb.Append("baseline");
|
||||
}
|
||||
else
|
||||
{
|
||||
custom++;
|
||||
sb.Append("custom (baseline ").Append(e.Baseline).Append(')');
|
||||
}
|
||||
if (e.BelowFloor)
|
||||
sb.Append(" [acts as ").Append(e.FloorMs).Append(']');
|
||||
}
|
||||
sb.Append(custom == 0 ? " -- all baseline" : $" -- {custom} of {entries.Count} custom");
|
||||
double max = RangeYards(approachMaxYards, 10.0), min = RangeYards(approachMinYards, 2.0);
|
||||
if (min > max)
|
||||
sb.Append($" | Approach Range Min {min:0.#} yd is above Max {max:0.#} yd, so Min acts as {max:0.#} yd");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A stored approach range in yards, read the way CorpseOpenController.NormalizeCorpseRangeYards
|
||||
/// reads it: unset falls back, and a value of 1 or less is a legacy fraction of 240 yards.
|
||||
/// </summary>
|
||||
private static double RangeYards(double value, double fallbackYards)
|
||||
{
|
||||
if (double.IsNaN(value) || double.IsInfinity(value) || value <= 0.0)
|
||||
return fallbackYards;
|
||||
return value <= 1.0 ? value * 240.0 : value;
|
||||
}
|
||||
}
|
||||
|
|
@ -99,6 +99,8 @@ internal sealed class ExpressionEngine
|
|||
= new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly Dictionary<string, (RynthCore.Loot.LootProfile Profile, DateTime Mtime)> _giveNativeProfileCache
|
||||
= new(StringComparer.OrdinalIgnoreCase);
|
||||
// actiontrygiveprofile arguments already logged as refused (the meta retries every pulse).
|
||||
private readonly HashSet<string> _giveProfileRefused = new(StringComparer.OrdinalIgnoreCase);
|
||||
// The three data paths are settable only so offline tests can point them at a scratch
|
||||
// folder before anything reads or writes them; the plugin never changes them.
|
||||
internal static string ItemGiverDir { get; set; }
|
||||
|
|
@ -3017,24 +3019,27 @@ internal sealed class ExpressionEngine
|
|||
// The item disappearing from GetInventory() is the confirmation it was accepted.
|
||||
if (_worldObjectCache == null || string.IsNullOrEmpty(profileArg) || string.IsNullOrEmpty(targetNameArg))
|
||||
return "0";
|
||||
// An NPC ignores MoveItemExternal (move-to-container): only AC's give action reaches one.
|
||||
if (!_host.HasGiveObjectTo) return "0";
|
||||
|
||||
// Resolve profile path — bare name → ItemGiverDir.
|
||||
// .utl extension added automatically if no extension and not .json.
|
||||
string profilePath = Path.IsPathRooted(profileArg)
|
||||
? profileArg
|
||||
: Path.Combine(ItemGiverDir, profileArg);
|
||||
|
||||
// The profile stays inside ItemGiverDir: a shared meta can't point the give at another file.
|
||||
string? profilePath = ResolveGiveProfilePath(profileArg, ItemGiverDir);
|
||||
if (profilePath == null)
|
||||
{
|
||||
if (_giveProfileRefused.Add(profileArg)) // once per argument, not every pulse
|
||||
_host.Log($"[RynthAi] actiontrygiveprofile: refused profile '{profileArg}' (only files inside ItemGiver\\).");
|
||||
return "0";
|
||||
}
|
||||
bool isJson = profilePath.EndsWith(".json", StringComparison.OrdinalIgnoreCase);
|
||||
if (!isJson && !profilePath.EndsWith(".utl", StringComparison.OrdinalIgnoreCase))
|
||||
profilePath += ".utl";
|
||||
|
||||
if (!File.Exists(profilePath)) return "0";
|
||||
|
||||
// Find target by exact name (case-insensitive) among landscape objects
|
||||
// Target: an NPC or vendor with that exact name (case-insensitive). Never a player, so a
|
||||
// shared meta can't hand the inventory to someone's character; /ra ig gives to players.
|
||||
uint targetId = 0;
|
||||
foreach (var wo in _worldObjectCache.GetLandscape())
|
||||
{
|
||||
if (string.Equals(wo.Name, targetNameArg, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(wo.Name, targetNameArg, StringComparison.OrdinalIgnoreCase) && IsGiveProfileTarget(wo))
|
||||
{
|
||||
targetId = (uint)wo.Id;
|
||||
break;
|
||||
|
|
@ -3067,8 +3072,7 @@ internal sealed class ExpressionEngine
|
|||
{
|
||||
var (action, _) = RynthCore.Plugin.RynthAi.Loot.LootEvaluator.Classify(nativeProfile, wo, null);
|
||||
if (action != RynthCore.Loot.LootAction.Keep) continue;
|
||||
int amount = Math.Max(1, wo.Values(LongValueKey.StackCount, 1));
|
||||
_host.MoveItemExternal((uint)wo.Id, targetId, amount);
|
||||
_host.GiveObjectTo((uint)wo.Id, targetId, 0);
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
|
@ -3095,8 +3099,7 @@ internal sealed class ExpressionEngine
|
|||
if (VTankLootEvaluator.Match(rule, wo, lootCtx)) { match = rule; break; }
|
||||
|
||||
if (match == null || match.Action != VTankLootAction.Keep) continue;
|
||||
int amount = Math.Max(1, wo.Values(LongValueKey.StackCount, 1));
|
||||
_host.MoveItemExternal((uint)wo.Id, targetId, amount);
|
||||
_host.GiveObjectTo((uint)wo.Id, targetId, 0);
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
|
@ -3104,6 +3107,45 @@ internal sealed class ExpressionEngine
|
|||
return "0"; // No matching items remain
|
||||
}
|
||||
|
||||
/// <summary>An NPC or a vendor (weenie bitfield first, as the meta's ObjectClass): a player never is.</summary>
|
||||
private bool IsGiveProfileTarget(WorldObject wo)
|
||||
{
|
||||
int cls = ResolveEffectiveObjectClass(wo);
|
||||
return cls == (int)AcObjectClass.Npc || cls == (int)AcObjectClass.Vendor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// actiontrygiveprofile's profile file: <paramref name="profileArg"/> relative to
|
||||
/// <paramref name="baseDir"/>, ".utl" added unless it ends in .utl or .json. Null when the
|
||||
/// argument is rooted (C:\..., \\server\..., \x, C:x), names an alternate stream (':'), or
|
||||
/// leaves <paramref name="baseDir"/> ("..\").
|
||||
/// </summary>
|
||||
internal static string? ResolveGiveProfilePath(string profileArg, string baseDir)
|
||||
{
|
||||
string arg = profileArg.Trim();
|
||||
if (arg.Length == 0 || string.IsNullOrWhiteSpace(baseDir) || arg.IndexOf(':') >= 0 || Path.IsPathRooted(arg))
|
||||
return null;
|
||||
|
||||
string root;
|
||||
string full;
|
||||
try
|
||||
{
|
||||
root = Path.GetFullPath(baseDir).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
|
||||
+ Path.DirectorySeparatorChar;
|
||||
full = Path.GetFullPath(Path.Combine(root, arg));
|
||||
}
|
||||
catch (Exception ex) when (ex is ArgumentException or NotSupportedException or PathTooLongException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (!full.StartsWith(root, StringComparison.OrdinalIgnoreCase) || full.Length == root.Length)
|
||||
return null;
|
||||
|
||||
if (!full.EndsWith(".json", StringComparison.OrdinalIgnoreCase) && !full.EndsWith(".utl", StringComparison.OrdinalIgnoreCase))
|
||||
full += ".utl";
|
||||
return full;
|
||||
}
|
||||
|
||||
private string EvalGetCombatState()
|
||||
{
|
||||
if (!_host.HasGetCurrentCombatMode) return "Peace";
|
||||
|
|
@ -3587,6 +3629,9 @@ internal sealed class ExpressionEngine
|
|||
["CastDispelSelf"] = (() => B(s.CastDispelSelf), v => s.CastDispelSelf = ToDouble(v) != 0),
|
||||
["AutoFellowMgmt"] = (() => B(s.AutoFellowMgmt), v => s.AutoFellowMgmt = ToDouble(v) != 0),
|
||||
["UseRecklessness"] = (() => B(s.UseRecklessness), v => s.UseRecklessness = ToDouble(v) != 0),
|
||||
["WeaponSwapSettleMs"] = (() => I(s.WeaponSwapSettleMs), v => { if (int.TryParse(v, out int i)) s.WeaponSwapSettleMs = Math.Clamp(i, 0, 3000); }),
|
||||
["WeaponSwapMinHealthPct"] = (() => I(s.WeaponSwapMinHealthPct), v => { if (int.TryParse(v, out int i)) s.WeaponSwapMinHealthPct = Math.Clamp(i, 0, 100); }),
|
||||
["WeaponSwapMinGainPct"] = (() => I(s.WeaponSwapMinGainPct), v => { if (int.TryParse(v, out int i)) s.WeaponSwapMinGainPct = Math.Clamp(i, 0, 200); }),
|
||||
["UseNativeAttack"] = (() => B(s.UseNativeAttack), v => s.UseNativeAttack = ToDouble(v) != 0),
|
||||
["WieldUnlistedWandWhenNoneListed"] = (() => B(s.WieldUnlistedWandWhenNoneListed), v => s.WieldUnlistedWandWhenNoneListed = ToDouble(v) != 0),
|
||||
// The off hand when a monster rule doesn't choose: Auto, Shield, Weapon or None (or 0-3).
|
||||
|
|
|
|||
|
|
@ -0,0 +1,348 @@
|
|||
// TinkerCatalog.cs - The salvage each Crafting tinker tab can apply.
|
||||
//
|
||||
// Retail: ACE's stock tinkering (RecipeManager Tinkering_ModifyItem): armor protections and
|
||||
// imbues, weapon tinks and imbues, caster tinks, jewelry cantrip gems, item value / burden /
|
||||
// mana / retain. Every retail tinker (imbues too) uses one of the item's 10 tinker slots and the
|
||||
// success chance follows RecipeManager.GetTinkerChance (TinkerMath).
|
||||
//
|
||||
// Server: the connected server's own recipes come from the plugin that owns it (its
|
||||
// "RynthServer.Profile" JSON's "salvage" list, read by FromServerPlugin): a server plugin, or
|
||||
// RynthILT for Infinite Leaftide. Nothing server-specific lives here. Their chances are the
|
||||
// server's: the Crafting runner relies on the confirmation's percent.
|
||||
// The player adds their own rows per world (CraftingTabState.CustomByWorld).
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Loot;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
|
||||
|
||||
/// <summary>A Crafting tinker tab.</summary>
|
||||
internal enum TinkerBench
|
||||
{
|
||||
Armor,
|
||||
Melee,
|
||||
Missile,
|
||||
Caster,
|
||||
Jewelry,
|
||||
Items,
|
||||
/// <summary>Trinkets (compass, goggles, scarab...): server salvage, often tier-prepared.</summary>
|
||||
Trinkets,
|
||||
}
|
||||
|
||||
/// <summary>Where a material's recipe comes from.</summary>
|
||||
internal enum TinkerOrigin
|
||||
{
|
||||
/// <summary>Stock ACE (retail) tinkering.</summary>
|
||||
Retail,
|
||||
/// <summary>A row the player added for this server.</summary>
|
||||
Custom,
|
||||
/// <summary>A row the server's own plugin defines (its profile's "salvage" list, ServerPackInfo.Salvage).</summary>
|
||||
Plugin,
|
||||
}
|
||||
|
||||
/// <summary>How often a material can go on one item.</summary>
|
||||
internal enum TinkerKind
|
||||
{
|
||||
/// <summary>Repeatable stat tink (count = how many times).</summary>
|
||||
Tink,
|
||||
/// <summary>One imbue per item (ImbuedEffect): a second imbue of any kind is refused.</summary>
|
||||
Imbue,
|
||||
/// <summary>One application (retain, heritage, a server's flag recipes...).</summary>
|
||||
Once,
|
||||
}
|
||||
|
||||
/// <summary>One salvage a tab can apply.</summary>
|
||||
/// <param name="Id">MaterialType (131); <see cref="TinkerCatalog.RendId"/> = the weapon's damage-type rend.</param>
|
||||
/// <param name="UsesTinkSlot">Counts toward the 10-tink cap.</param>
|
||||
/// <param name="AppliedInt">An int property of the item: the material is on it when it reads 2 (0 = none).</param>
|
||||
/// <param name="NameMatch">The bag must have this in its name (server bags that share a material id).</param>
|
||||
/// <param name="Order">Apply order (lower first).</param>
|
||||
/// <param name="Prepared">The bag must first be prepared on tier Ammunition: its name then carries the tier.</param>
|
||||
/// <param name="AfterCap">Goes on last, and only once the item's tink slots are full.</param>
|
||||
/// <param name="StackGroup">Rows with the same group share <paramref name="StackCap"/> per item ("" = none).</param>
|
||||
/// <param name="StackCap">The group's combined cap per item.</param>
|
||||
internal sealed record TinkerMaterial(
|
||||
int Id, string Name, TinkerOrigin Origin, TinkerKind Kind, string Effect, int Order,
|
||||
bool UsesTinkSlot = true, int AppliedInt = 0, string NameMatch = "", int Skill = 0, bool Prepared = false,
|
||||
bool AfterCap = false, string StackGroup = "", int StackCap = 0);
|
||||
|
||||
internal static class TinkerCatalog
|
||||
{
|
||||
/// <summary>Pseudo material: the rend gem that matches the weapon's damage type.</summary>
|
||||
public const int RendId = -1;
|
||||
|
||||
// Tinkering skills (Skill enum).
|
||||
public const int SkillItem = 18;
|
||||
public const int SkillWeapon = 28;
|
||||
public const int SkillArmor = 29;
|
||||
public const int SkillMagicItem = 30;
|
||||
|
||||
// Material ids used by the rules below (MaterialType).
|
||||
public const int Ceramic = 1, Porcelain = 2, Linen = 4, Satin = 5, Silk = 6, Velvet = 7, Wool = 8;
|
||||
public const int Agate = 10, Aquamarine = 13, Azurite = 14, BlackGarnet = 15, BlackOpal = 16, Bloodstone = 17,
|
||||
Carnelian = 18, Citrine = 19, Emerald = 21, FireOpal = 22, GreenGarnet = 23, GreenJade = 24, Hematite = 25,
|
||||
ImperialTopaz = 26, Jet = 27, LapisLazuli = 28, LavenderJade = 29, Malachite = 30, Moonstone = 31, Onyx = 32,
|
||||
Opal = 33, Peridot = 34, RedGarnet = 35, RedJade = 36, RoseQuartz = 37, SmokeyQuartz = 40, Sunstone = 41,
|
||||
TigerEye = 42, Tourmaline = 43, Turquoise = 44, WhiteJade = 45, WhiteQuartz = 46, WhiteSapphire = 47,
|
||||
YellowGarnet = 48, YellowTopaz = 49, Zircon = 50;
|
||||
public const int Ivory = 51, Leather = 52, Armoredillo = 53, Reedshark = 55, Brass = 57, Bronze = 58, Copper = 59,
|
||||
Gold = 60, Iron = 61, Silver = 63, Steel = 64, Alabaster = 66, Granite = 67, Marble = 68, Sandstone = 70,
|
||||
Serpentine = 71, Ebony = 73, Mahogany = 74, Oak = 75, Pine = 76, Teak = 77;
|
||||
|
||||
public const int Diamond = 20, Ruby = 38, GromnieHide = 54, Pyreal = 62;
|
||||
|
||||
/// <summary>Prepared salvage tiers: the word in the Ammunition's and the prepared bag's name.</summary>
|
||||
public static readonly string[] TrinketTiers = { "Minor", "Moderate", "Major" };
|
||||
|
||||
/// <summary>The ordinary tinker slots on an item.</summary>
|
||||
public const int MaxTinks = 10;
|
||||
|
||||
private static readonly Dictionary<TinkerBench, TinkerMaterial[]> Retail = new()
|
||||
{
|
||||
[TinkerBench.Armor] = new TinkerMaterial[]
|
||||
{
|
||||
new(Peridot, "Peridot", TinkerOrigin.Retail, TinkerKind.Imbue, "Melee defense imbue", 105, Skill: SkillArmor),
|
||||
new(YellowTopaz, "Yellow Topaz", TinkerOrigin.Retail, TinkerKind.Imbue, "Missile defense imbue", 106, Skill: SkillArmor),
|
||||
new(Zircon, "Zircon", TinkerOrigin.Retail, TinkerKind.Imbue, "Magic defense imbue", 107, Skill: SkillArmor),
|
||||
new(Steel, "Steel", TinkerOrigin.Retail, TinkerKind.Tink, "+20 armor level", 300, Skill: SkillArmor),
|
||||
new(Alabaster, "Alabaster", TinkerOrigin.Retail, TinkerKind.Tink, "+0.2 pierce protection", 310, Skill: SkillArmor),
|
||||
new(Bronze, "Bronze", TinkerOrigin.Retail, TinkerKind.Tink, "+0.2 slash protection", 311, Skill: SkillArmor),
|
||||
new(Marble, "Marble", TinkerOrigin.Retail, TinkerKind.Tink, "+0.2 bludgeon protection", 312, Skill: SkillArmor),
|
||||
new(Armoredillo, "Armoredillo Hide", TinkerOrigin.Retail, TinkerKind.Tink, "+0.4 acid protection", 313, Skill: SkillArmor),
|
||||
new(Ceramic, "Ceramic", TinkerOrigin.Retail, TinkerKind.Tink, "+0.4 fire protection", 314, Skill: SkillArmor),
|
||||
new(Wool, "Wool", TinkerOrigin.Retail, TinkerKind.Tink, "+0.4 cold protection", 315, Skill: SkillArmor),
|
||||
new(Reedshark, "Reedshark Hide", TinkerOrigin.Retail, TinkerKind.Tink, "+0.4 lightning protection", 316, Skill: SkillArmor),
|
||||
new(Copper, "Copper", TinkerOrigin.Retail, TinkerKind.Once, "Activation: missile defense to melee defense", 380, Skill: SkillItem),
|
||||
new(Silver, "Silver", TinkerOrigin.Retail, TinkerKind.Once, "Activation: melee defense to missile defense", 381, Skill: SkillItem),
|
||||
},
|
||||
[TinkerBench.Melee] = new TinkerMaterial[]
|
||||
{
|
||||
new(BlackOpal, "Black Opal", TinkerOrigin.Retail, TinkerKind.Imbue, "Critical Strike imbue", 101, Skill: SkillWeapon),
|
||||
new(FireOpal, "Fire Opal", TinkerOrigin.Retail, TinkerKind.Imbue, "Crippling Blow imbue", 102, Skill: SkillWeapon),
|
||||
new(Sunstone, "Sunstone", TinkerOrigin.Retail, TinkerKind.Imbue, "Armor Rending imbue", 103, Skill: SkillWeapon),
|
||||
new(RendId, "Damage-type rend", TinkerOrigin.Retail, TinkerKind.Imbue, "Rend matching the weapon's damage type", 110, Skill: SkillWeapon),
|
||||
new(Brass, "Brass", TinkerOrigin.Retail, TinkerKind.Tink, "+1% melee defense", 170, Skill: SkillWeapon),
|
||||
new(Granite, "Granite", TinkerOrigin.Retail, TinkerKind.Tink, "-20% damage variance", 180, Skill: SkillWeapon),
|
||||
new(Iron, "Iron", TinkerOrigin.Retail, TinkerKind.Tink, "+1 maximum damage", 190, Skill: SkillWeapon),
|
||||
new(Oak, "Oak", TinkerOrigin.Retail, TinkerKind.Tink, "-50 weapon speed", 200, Skill: SkillWeapon),
|
||||
new(Velvet, "Velvet", TinkerOrigin.Retail, TinkerKind.Tink, "+1% attack", 210, Skill: SkillWeapon),
|
||||
},
|
||||
[TinkerBench.Missile] = new TinkerMaterial[]
|
||||
{
|
||||
new(BlackOpal, "Black Opal", TinkerOrigin.Retail, TinkerKind.Imbue, "Critical Strike imbue", 101, Skill: SkillWeapon),
|
||||
new(FireOpal, "Fire Opal", TinkerOrigin.Retail, TinkerKind.Imbue, "Crippling Blow imbue", 102, Skill: SkillWeapon),
|
||||
new(Sunstone, "Sunstone", TinkerOrigin.Retail, TinkerKind.Imbue, "Armor Rending imbue", 103, Skill: SkillWeapon),
|
||||
new(RendId, "Damage-type rend", TinkerOrigin.Retail, TinkerKind.Imbue, "Rend matching the weapon's damage type", 110, Skill: SkillWeapon),
|
||||
new(Brass, "Brass", TinkerOrigin.Retail, TinkerKind.Tink, "+1% melee defense", 170, Skill: SkillWeapon),
|
||||
new(Oak, "Oak", TinkerOrigin.Retail, TinkerKind.Tink, "-50 weapon speed", 200, Skill: SkillWeapon),
|
||||
new(Mahogany, "Mahogany", TinkerOrigin.Retail, TinkerKind.Tink, "+4% damage modifier", 220, Skill: SkillWeapon),
|
||||
},
|
||||
[TinkerBench.Caster] = new TinkerMaterial[]
|
||||
{
|
||||
new(BlackOpal, "Black Opal", TinkerOrigin.Retail, TinkerKind.Imbue, "Critical Strike imbue", 101, Skill: SkillMagicItem),
|
||||
new(FireOpal, "Fire Opal", TinkerOrigin.Retail, TinkerKind.Imbue, "Crippling Blow imbue", 102, Skill: SkillMagicItem),
|
||||
new(Sunstone, "Sunstone", TinkerOrigin.Retail, TinkerKind.Imbue, "Armor Rending imbue", 103, Skill: SkillMagicItem),
|
||||
new(RendId, "Element rend", TinkerOrigin.Retail, TinkerKind.Imbue, "Rend matching the caster's element", 110, Skill: SkillMagicItem),
|
||||
new(GreenGarnet, "Green Garnet", TinkerOrigin.Retail, TinkerKind.Tink, "+1% elemental damage", 150, Skill: SkillMagicItem),
|
||||
new(Opal, "Opal", TinkerOrigin.Retail, TinkerKind.Tink, "+1% mana conversion", 160, Skill: SkillMagicItem),
|
||||
new(Brass, "Brass", TinkerOrigin.Retail, TinkerKind.Tink, "+1% melee defense", 170, Skill: SkillWeapon),
|
||||
},
|
||||
[TinkerBench.Jewelry] = new TinkerMaterial[]
|
||||
{
|
||||
new(Agate, "Agate", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Focus", 120, Skill: SkillMagicItem),
|
||||
new(Azurite, "Azurite", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Wizard's Intellect", 121, Skill: SkillMagicItem),
|
||||
new(Bloodstone, "Bloodstone", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Endurance", 122, Skill: SkillMagicItem),
|
||||
new(Carnelian, "Carnelian", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Strength", 123, Skill: SkillMagicItem),
|
||||
new(Citrine, "Citrine", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Stamina Gain", 124, Skill: SkillMagicItem),
|
||||
new(Hematite, "Hematite", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Warrior's Vitality", 125, Skill: SkillMagicItem),
|
||||
new(LapisLazuli, "Lapis Lazuli", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Willpower", 126, Skill: SkillMagicItem),
|
||||
new(LavenderJade, "Lavender Jade", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Mana Gain", 127, Skill: SkillMagicItem),
|
||||
new(Malachite, "Malachite", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Warrior's Vigor", 128, Skill: SkillMagicItem),
|
||||
new(RedJade, "Red Jade", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Health Gain", 129, Skill: SkillMagicItem),
|
||||
new(RoseQuartz, "Rose Quartz", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Quickness", 130, Skill: SkillMagicItem),
|
||||
new(SmokeyQuartz, "Smokey Quartz", TinkerOrigin.Retail, TinkerKind.Imbue, "Cantrip: Coordination", 131, Skill: SkillMagicItem),
|
||||
},
|
||||
[TinkerBench.Items] = new TinkerMaterial[]
|
||||
{
|
||||
new(Gold, "Gold", TinkerOrigin.Retail, TinkerKind.Tink, "+25% value", 400, Skill: SkillItem),
|
||||
new(Pine, "Pine", TinkerOrigin.Retail, TinkerKind.Tink, "-25% value", 410, Skill: SkillItem),
|
||||
new(Linen, "Linen", TinkerOrigin.Retail, TinkerKind.Tink, "-25% burden", 420, Skill: SkillItem),
|
||||
new(Moonstone, "Moonstone", TinkerOrigin.Retail, TinkerKind.Tink, "+500 maximum mana", 430, Skill: SkillItem),
|
||||
new(Silk, "Silk", TinkerOrigin.Retail, TinkerKind.Once, "Allegiance rank requirement becomes spellcraft", 440, Skill: SkillItem),
|
||||
new(Teak, "Teak", TinkerOrigin.Retail, TinkerKind.Once, "Heritage requirement: Aluvian", 450, Skill: SkillItem),
|
||||
new(Ebony, "Ebony", TinkerOrigin.Retail, TinkerKind.Once, "Heritage requirement: Gharu'ndim", 451, Skill: SkillItem),
|
||||
new(Porcelain, "Porcelain", TinkerOrigin.Retail, TinkerKind.Once, "Heritage requirement: Sho", 452, Skill: SkillItem),
|
||||
new(Satin, "Satin", TinkerOrigin.Retail, TinkerKind.Once, "Heritage requirement: Viamontian", 453, Skill: SkillItem),
|
||||
new(Ivory, "Ivory", TinkerOrigin.Retail, TinkerKind.Once, "Removes attunement", 490, UsesTinkSlot: false, Skill: SkillItem),
|
||||
new(Leather, "Leather", TinkerOrigin.Retail, TinkerKind.Once, "Retained (can't be salvaged or sold)", 500, UsesTinkSlot: false, Skill: SkillItem),
|
||||
new(Sandstone, "Sandstone", TinkerOrigin.Retail, TinkerKind.Once, "Removes Retained", 510, UsesTinkSlot: false, Skill: SkillItem),
|
||||
},
|
||||
[TinkerBench.Trinkets] = Array.Empty<TinkerMaterial>(),
|
||||
};
|
||||
|
||||
/// <summary>The retail rows of a tab.</summary>
|
||||
public static IReadOnlyList<TinkerMaterial> RetailFor(TinkerBench bench) => Retail[bench];
|
||||
|
||||
/// <summary>
|
||||
/// A server plugin's salvage rows for one tab (its profile's "salvage" list). Rows for other
|
||||
/// tabs, unknown tab names and unknown kinds are left out. A row's own "order" decides where it
|
||||
/// runs; without one, imbues run before tinks and one-application rows after them, each in the
|
||||
/// plugin's list order.
|
||||
/// </summary>
|
||||
public static List<TinkerMaterial> FromServerPlugin(TinkerBench bench, IEnumerable<RynthCore.Plugin.Shared.ServerSalvageView>? salvage)
|
||||
{
|
||||
var rows = new List<TinkerMaterial>();
|
||||
if (salvage == null) return rows;
|
||||
string benchName = bench.ToString().ToLowerInvariant();
|
||||
int i = 0;
|
||||
foreach (var s in salvage)
|
||||
{
|
||||
if (s == null || s.Material <= 0 || !string.Equals(s.Bench, benchName, StringComparison.OrdinalIgnoreCase)) continue;
|
||||
TinkerKind? kind = s.Kind switch
|
||||
{
|
||||
"tink" or "" => TinkerKind.Tink,
|
||||
"imbue" => TinkerKind.Imbue,
|
||||
"once" => TinkerKind.Once,
|
||||
_ => null,
|
||||
};
|
||||
if (kind == null) continue;
|
||||
int order = kind switch
|
||||
{
|
||||
TinkerKind.Imbue => 115,
|
||||
TinkerKind.Once => 600,
|
||||
_ => 400,
|
||||
} + i++;
|
||||
if (s.Order != 0) order = s.Order;
|
||||
string group = s.StackCap > 0 ? (s.StackGroup ?? string.Empty).Trim() : string.Empty;
|
||||
rows.Add(new TinkerMaterial(s.Material, MaterialName(s.Material), TinkerOrigin.Plugin, kind.Value,
|
||||
string.IsNullOrWhiteSpace(s.Effect) ? "server recipe" : s.Effect.Trim(), order,
|
||||
UsesTinkSlot: s.UsesTinkSlot, AppliedInt: s.AppliedInt, NameMatch: s.NameMatch ?? string.Empty,
|
||||
Prepared: s.Prepared, AfterCap: s.AfterCap, StackGroup: group, StackCap: group.Length > 0 ? s.StackCap : 0));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Settings key for a row: retail and server rows of one tab share ids (Wool, Steel...). Keys
|
||||
/// with the old "s" prefix (RynthAi's own Leaftide rows before they moved to RynthILT) match no row.
|
||||
/// </summary>
|
||||
public static string Key(TinkerMaterial m) => m.Origin switch
|
||||
{
|
||||
TinkerOrigin.Retail => "r" + m.Id,
|
||||
TinkerOrigin.Plugin => "p" + m.Id,
|
||||
_ => "c" + m.Id,
|
||||
};
|
||||
|
||||
/// <summary>The object classes a tab scans.</summary>
|
||||
public static bool Targets(TinkerBench bench, AcObjectClass oc) => bench switch
|
||||
{
|
||||
TinkerBench.Armor => oc is AcObjectClass.Armor or AcObjectClass.Clothing,
|
||||
TinkerBench.Melee => oc == AcObjectClass.MeleeWeapon,
|
||||
TinkerBench.Missile => oc == AcObjectClass.MissileWeapon,
|
||||
TinkerBench.Caster => oc == AcObjectClass.WandStaffOrb,
|
||||
TinkerBench.Jewelry or TinkerBench.Trinkets => oc == AcObjectClass.Jewelry,
|
||||
TinkerBench.Items => oc is not (AcObjectClass.Salvage or AcObjectClass.Container or AcObjectClass.Unknown
|
||||
or AcObjectClass.Money or AcObjectClass.TradeNote or AcObjectClass.SpellComponent or AcObjectClass.Food),
|
||||
_ => false,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Trinkets (compass, goggles, scarab, watch, puzzle box, tops) are jewelry the Jewelry tab
|
||||
/// leaves alone: they take the Trinkets tab's recipes instead (UB-IT IsLeaftideTrinketJewelry).
|
||||
/// </summary>
|
||||
public static bool IsTrinket(string name)
|
||||
{
|
||||
string n = (name ?? string.Empty).ToLowerInvariant();
|
||||
if (n.Contains("compass") || n.Contains("goggles") || n.Contains("scarab") || n.Contains("watch") || n.Contains("puzzle box"))
|
||||
return true;
|
||||
return n.Contains("top") && !n.Contains("topaz");
|
||||
}
|
||||
|
||||
public static string Label(TinkerBench bench) => bench switch
|
||||
{
|
||||
TinkerBench.Armor => "Armor",
|
||||
TinkerBench.Melee => "Melee",
|
||||
TinkerBench.Missile => "Missile",
|
||||
TinkerBench.Caster => "Caster",
|
||||
TinkerBench.Jewelry => "Jewelry",
|
||||
TinkerBench.Items => "Items",
|
||||
TinkerBench.Trinkets => "Trinkets",
|
||||
_ => bench.ToString(),
|
||||
};
|
||||
|
||||
/// <summary>The default tinkering skill a tab's custom rows use for the chance.</summary>
|
||||
public static int DefaultSkill(TinkerBench bench) => bench switch
|
||||
{
|
||||
TinkerBench.Armor => SkillArmor,
|
||||
TinkerBench.Melee or TinkerBench.Missile => SkillWeapon,
|
||||
TinkerBench.Caster or TinkerBench.Jewelry => SkillMagicItem,
|
||||
_ => SkillItem,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The rend gem for a weapon's damage type (melee/missile DamageType 45, the caster's element
|
||||
/// the same field): Slash+Pierce takes <paramref name="pierceForCombo"/>; Nether is Onyx.
|
||||
/// 0 when the type has no rend.
|
||||
/// </summary>
|
||||
public static int RendFor(int damageType, bool pierceForCombo)
|
||||
{
|
||||
if (damageType == 3) return pierceForCombo ? BlackGarnet : ImperialTopaz;
|
||||
if ((damageType & 0x400) != 0) return Onyx;
|
||||
return damageType switch
|
||||
{
|
||||
1 => ImperialTopaz,
|
||||
2 => BlackGarnet,
|
||||
4 => WhiteSapphire,
|
||||
8 => Aquamarine,
|
||||
16 => RedGarnet,
|
||||
32 => Emerald,
|
||||
64 => Jet,
|
||||
_ => 0,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The rend gem a Foolproof bag's name advertises (server bags may not set Material), else 0.</summary>
|
||||
public static int RendFromFoolproofName(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name) || name.IndexOf("Foolproof", StringComparison.OrdinalIgnoreCase) < 0) return 0;
|
||||
// Longer names first: "Black Opal" must not read as "Black Garnet", "Onyx" before both.
|
||||
(string Text, int Id)[] map =
|
||||
{
|
||||
("Imperial Topaz", ImperialTopaz), ("White Sapphire", WhiteSapphire), ("Onyx", Onyx),
|
||||
("Black Garnet", BlackGarnet), ("Black Opal", BlackOpal), ("Aquamarine", Aquamarine),
|
||||
("Red Garnet", RedGarnet), ("Emerald", Emerald), ("Jet", Jet),
|
||||
};
|
||||
foreach (var (text, id) in map)
|
||||
if (name.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0) return id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>Material names for the custom-row picker and status text.</summary>
|
||||
public static readonly (int Id, string Name)[] MaterialNames =
|
||||
{
|
||||
(Ceramic, "Ceramic"), (Porcelain, "Porcelain"), (3, "Cloth"), (Linen, "Linen"), (Satin, "Satin"), (Silk, "Silk"),
|
||||
(Velvet, "Velvet"), (Wool, "Wool"), (Agate, "Agate"), (11, "Amber"), (12, "Amethyst"), (Aquamarine, "Aquamarine"),
|
||||
(Azurite, "Azurite"), (BlackGarnet, "Black Garnet"), (BlackOpal, "Black Opal"), (Bloodstone, "Bloodstone"),
|
||||
(Carnelian, "Carnelian"), (Citrine, "Citrine"), (Diamond, "Diamond"), (Emerald, "Emerald"), (FireOpal, "Fire Opal"),
|
||||
(GreenGarnet, "Green Garnet"), (GreenJade, "Green Jade"), (Hematite, "Hematite"), (ImperialTopaz, "Imperial Topaz"),
|
||||
(Jet, "Jet"), (LapisLazuli, "Lapis Lazuli"), (LavenderJade, "Lavender Jade"), (Malachite, "Malachite"),
|
||||
(Moonstone, "Moonstone"), (Onyx, "Onyx"), (Opal, "Opal"), (Peridot, "Peridot"), (RedGarnet, "Red Garnet"),
|
||||
(RedJade, "Red Jade"), (RoseQuartz, "Rose Quartz"), (Ruby, "Ruby"), (39, "Sapphire"), (SmokeyQuartz, "Smokey Quartz"),
|
||||
(Sunstone, "Sunstone"), (TigerEye, "Tiger Eye"), (Tourmaline, "Tourmaline"), (Turquoise, "Turquoise"),
|
||||
(WhiteJade, "White Jade"), (WhiteQuartz, "White Quartz"), (WhiteSapphire, "White Sapphire"),
|
||||
(YellowGarnet, "Yellow Garnet"), (YellowTopaz, "Yellow Topaz"), (Zircon, "Zircon"), (Ivory, "Ivory"),
|
||||
(Leather, "Leather"), (Armoredillo, "Armoredillo Hide"), (GromnieHide, "Gromnie Hide"), (Reedshark, "Reedshark Hide"),
|
||||
(Brass, "Brass"), (Bronze, "Bronze"), (Copper, "Copper"), (Gold, "Gold"), (Iron, "Iron"), (Pyreal, "Pyreal"),
|
||||
(Silver, "Silver"), (Steel, "Steel"), (Alabaster, "Alabaster"), (Granite, "Granite"), (Marble, "Marble"),
|
||||
(Sandstone, "Sandstone"), (Serpentine, "Serpentine"), (Ebony, "Ebony"), (Mahogany, "Mahogany"), (Oak, "Oak"),
|
||||
(Pine, "Pine"), (Teak, "Teak"),
|
||||
};
|
||||
|
||||
/// <summary>A material's display name ("#id" when unknown).</summary>
|
||||
public static string MaterialName(int id)
|
||||
{
|
||||
foreach (var (mid, name) in MaterialNames)
|
||||
if (mid == id) return name;
|
||||
return "#" + id;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
// TinkerMath.cs - Retail tinkering success chance, as ACE computes it
|
||||
// (RecipeManager.GetTinkerChance, GetMaterialMod, TinkeringDifficulty; SkillCheck.GetSkillChance).
|
||||
//
|
||||
// difficulty = floor((salvageMod*5 + itemWork*salvageMod*2 - toolWork*wkMod*salvageMod/5) * attemptMod)
|
||||
// chance = 1 - 1 / (1 + e^(0.03 * (skill - difficulty))) imbue: chance / 3
|
||||
//
|
||||
// toolWork is the bag's average workmanship (ItemWorkmanship / NumItemsInMaterial), wkMod is 2
|
||||
// when the bag is at least as good as the item, attemptMod grows with the item's tinker count.
|
||||
// Foolproof bags always succeed. Server extras (ILT recipes, augmentation, charms) are not
|
||||
// modelled: the server's confirmation percent is the final word (ConfirmationResponder).
|
||||
using System;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
|
||||
|
||||
internal static class TinkerMath
|
||||
{
|
||||
/// <summary>Difficulty multiplier by how many tinks the item already has (index 0-9).</summary>
|
||||
private static readonly double[] AttemptMod = { 1.0, 1.1, 1.3, 1.6, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5 };
|
||||
|
||||
/// <summary>Salvage difficulty factor (GetMaterialMod).</summary>
|
||||
public static double SalvageMod(int material) => material switch
|
||||
{
|
||||
TinkerCatalog.Gold or TinkerCatalog.Oak => 10.0,
|
||||
TinkerCatalog.Alabaster or TinkerCatalog.Armoredillo or TinkerCatalog.Brass or TinkerCatalog.Bronze
|
||||
or TinkerCatalog.Ceramic or TinkerCatalog.Granite or TinkerCatalog.Linen or TinkerCatalog.Marble
|
||||
or TinkerCatalog.Moonstone or TinkerCatalog.Opal or TinkerCatalog.Pine or TinkerCatalog.Reedshark
|
||||
or TinkerCatalog.Velvet or TinkerCatalog.Wool => 11.0,
|
||||
TinkerCatalog.Ebony or TinkerCatalog.GreenGarnet or TinkerCatalog.Iron or TinkerCatalog.Mahogany
|
||||
or TinkerCatalog.Porcelain or TinkerCatalog.Satin or TinkerCatalog.Steel or TinkerCatalog.Teak => 12.0,
|
||||
TinkerCatalog.Bloodstone or TinkerCatalog.Carnelian or TinkerCatalog.Citrine or TinkerCatalog.Hematite
|
||||
or TinkerCatalog.LavenderJade or TinkerCatalog.Malachite or TinkerCatalog.RedJade or TinkerCatalog.RoseQuartz => 25.0,
|
||||
_ => 20.0,
|
||||
};
|
||||
|
||||
/// <summary>The recipe difficulty for one attempt (an item at 10 tinks can't be tinkered: int.MaxValue).</summary>
|
||||
public static int Difficulty(int material, double itemWorkmanship, double toolWorkmanship, int tinks)
|
||||
{
|
||||
if (tinks < 0) tinks = 0;
|
||||
if (tinks >= AttemptMod.Length) return int.MaxValue;
|
||||
double salvageMod = SalvageMod(material);
|
||||
double wkMod = toolWorkmanship >= itemWorkmanship ? 2.0 : 1.0;
|
||||
return (int)Math.Floor(((salvageMod * 5.0) + (itemWorkmanship * salvageMod * 2.0)
|
||||
- (toolWorkmanship * wkMod * salvageMod / 5.0)) * AttemptMod[tinks]);
|
||||
}
|
||||
|
||||
/// <summary>SkillCheck.GetSkillChance: the logistic curve AC uses for every skill check.</summary>
|
||||
public static double SkillChance(int skill, int difficulty)
|
||||
{
|
||||
if (difficulty == int.MaxValue) return 0.0;
|
||||
double chance = 1.0 - (1.0 / (1.0 + Math.Exp(0.03 * (skill - difficulty))));
|
||||
return Math.Clamp(chance, 0.0, 1.0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The retail chance (0-1) of one application: <paramref name="skill"/> is the buffed
|
||||
/// tinkering skill, <paramref name="imbue"/> divides by 3, <paramref name="foolproof"/> is 1.
|
||||
/// </summary>
|
||||
public static double Chance(int material, int skill, double itemWorkmanship, double toolWorkmanship,
|
||||
int tinks, bool imbue, bool foolproof)
|
||||
{
|
||||
if (foolproof) return 1.0;
|
||||
double c = SkillChance(skill, Difficulty(material, itemWorkmanship, toolWorkmanship, tinks));
|
||||
return imbue ? c / 3.0 : c;
|
||||
}
|
||||
|
||||
/// <summary>A bag's average workmanship: ItemWorkmanship over NumItemsInMaterial.</summary>
|
||||
public static double BagWorkmanship(int itemWorkmanship, int numItemsInMaterial)
|
||||
=> numItemsInMaterial > 0 ? itemWorkmanship / (double)numItemsInMaterial : itemWorkmanship;
|
||||
|
||||
/// <summary>Whole percent the way the server's dialog rounds it ("You determine that you have a N percent chance").</summary>
|
||||
public static int Percent(double chance) => (int)Math.Round(Math.Clamp(chance, 0.0, 1.0) * 100.0, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
// TinkerPlanner.cs - What a Crafting tab would apply to one item, and which bag to use.
|
||||
//
|
||||
// Pure: the scan reads the item into TinkerItemFacts and the runner re-plans from fresh facts,
|
||||
// so these rules are the only place the apply order and caps live (and the host tests drive
|
||||
// them directly). Server rows say which rules apply to them (TinkerMaterial, from the server
|
||||
// plugin's profile); nothing here knows a server:
|
||||
// * rows run in TinkerMaterial.Order (imbues and server crit lines before stat tinks; with
|
||||
// "rend last" the rend moves to the end, the way UB-IT's foolproof-rend option does);
|
||||
// * a tink-slot row is cut to the free slots (10 minus the item's tinks); no-slot rows aren't;
|
||||
// * one imbue per item (the item's own, or the first planned one);
|
||||
// * a row with an applied int is skipped once that int reads 2 on the item;
|
||||
// * rows of one stack group stop at the group's cap combined;
|
||||
// * an after-cap row goes on last, once, and only when the tink slots are full;
|
||||
// * a prepared row needs a bag prepared at the chosen tier (its name says Minor, Moderate or
|
||||
// Major); a raw bag becomes one on that tier's Ammunition.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RynthCore.Loot;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
|
||||
|
||||
/// <summary>What the planner needs to know about an item.</summary>
|
||||
internal sealed class TinkerItemFacts
|
||||
{
|
||||
public int Id;
|
||||
public string Name = string.Empty;
|
||||
public AcObjectClass Class;
|
||||
/// <summary>The item's workmanship (ItemWorkmanship 105; 0 = can't be tinkered).</summary>
|
||||
public double Workmanship;
|
||||
/// <summary>NumTimesTinkered (171).</summary>
|
||||
public int Tinks;
|
||||
/// <summary>ImbuedEffect (179) is set.</summary>
|
||||
public bool Imbued;
|
||||
/// <summary>DamageType (45): melee/missile damage, the caster's element.</summary>
|
||||
public int DamageType;
|
||||
/// <summary>Retained (bool 91).</summary>
|
||||
public bool Retained;
|
||||
/// <summary>ItemMaxMana (108).</summary>
|
||||
public int MaxMana;
|
||||
public bool Equipped;
|
||||
/// <summary>Reads an int property of the item (a row's applied int: 2 = that salvage is on).</summary>
|
||||
public Func<int, int> FlagInt = _ => 0;
|
||||
}
|
||||
|
||||
/// <summary>One planned application: the row and the salvage it resolves to (a rend resolves per item).</summary>
|
||||
internal readonly record struct TinkerStep(TinkerMaterial Row, int Material);
|
||||
|
||||
/// <summary>A bag a step could use (for <see cref="TinkerPlanner.SelectBag"/>).</summary>
|
||||
internal readonly record struct TinkerBagChoice(int Id, double Workmanship, double? Chance);
|
||||
|
||||
internal static class TinkerPlanner
|
||||
{
|
||||
/// <summary>
|
||||
/// The rows a tab offers: retail, then <paramref name="server"/> (the connected server's own
|
||||
/// salvage, from the plugin that owns it), then the player's custom rows.
|
||||
/// </summary>
|
||||
public static List<TinkerMaterial> Rows(TinkerBench bench, IEnumerable<TinkerMaterial>? server, IEnumerable<CustomTinker>? custom)
|
||||
{
|
||||
var rows = new List<TinkerMaterial>(TinkerCatalog.RetailFor(bench));
|
||||
if (server != null) rows.AddRange(server);
|
||||
if (custom != null)
|
||||
{
|
||||
foreach (var c in custom)
|
||||
{
|
||||
if (c.Bench != (int)bench || c.Material <= 0) continue;
|
||||
var kind = c.Imbue ? TinkerKind.Imbue : c.Once ? TinkerKind.Once : TinkerKind.Tink;
|
||||
rows.Add(new TinkerMaterial(c.Material, TinkerCatalog.MaterialName(c.Material), TinkerOrigin.Custom, kind,
|
||||
string.IsNullOrWhiteSpace(c.Note) ? "custom" : c.Note, 900 + rows.Count,
|
||||
UsesTinkSlot: c.UsesTinkSlot, NameMatch: c.NameMatch ?? string.Empty));
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/// <summary>The order a row runs in under these settings.</summary>
|
||||
public static int OrderOf(TinkerMaterial row, TinkerBenchSettings s)
|
||||
=> row.Id == TinkerCatalog.RendId && s.RendLast ? 990 : row.Order;
|
||||
|
||||
/// <summary>Why the scan leaves an item out ("" = it's eligible and the plan decides).</summary>
|
||||
public static string Excluded(TinkerItemFacts item, TinkerBenchSettings s)
|
||||
{
|
||||
if (item.Equipped) return "equipped";
|
||||
if (item.Workmanship <= 0) return "no workmanship";
|
||||
if (item.Tinks > Math.Clamp(s.MaxTinks, 0, TinkerCatalog.MaxTinks)) return $"{item.Tinks} tinks (max {s.MaxTinks})";
|
||||
if (s.MinFreeTinks > 0 && TinkerCatalog.MaxTinks - item.Tinks < s.MinFreeTinks) return $"fewer than {s.MinFreeTinks} free tinks";
|
||||
if (s.SkipImbued && item.Imbued) return "imbued";
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ordered steps for one item (empty when nothing ticked applies).
|
||||
/// <paramref name="attempted"/> is how many times this run already tried a row key on the
|
||||
/// item: the item's tinks count failures too, but no-slot server rows and the ticked counts
|
||||
/// don't show on it, so a re-plan would otherwise repeat them.
|
||||
/// </summary>
|
||||
public static List<TinkerStep> Plan(TinkerBench bench, TinkerItemFacts item, TinkerBenchSettings s,
|
||||
IReadOnlyList<TinkerMaterial> rows, Func<string, int>? attempted = null)
|
||||
{
|
||||
var steps = new List<TinkerStep>();
|
||||
int free = Math.Max(0, TinkerCatalog.MaxTinks - item.Tinks);
|
||||
bool imbueTaken = item.Imbued;
|
||||
Dictionary<string, int>? stacked = null;
|
||||
List<TinkerStep>? afterCap = null;
|
||||
|
||||
foreach (var row in rows.OrderBy(r => OrderOf(r, s)))
|
||||
{
|
||||
string key = TinkerCatalog.Key(row);
|
||||
int count = s.Counts.TryGetValue(key, out int c) ? c : 0;
|
||||
int tried = attempted?.Invoke(key) ?? 0;
|
||||
if (row.Kind != TinkerKind.Tink) count = Math.Min(count, 1);
|
||||
count -= tried;
|
||||
if (count <= 0) continue;
|
||||
int material = row.Id == TinkerCatalog.RendId ? TinkerCatalog.RendFor(item.DamageType, s.PierceForCombo) : row.Id;
|
||||
if (material <= 0 || !Applies(row, material, item)) continue;
|
||||
|
||||
int n = row.Kind == TinkerKind.Tink ? count : 1;
|
||||
if (row.Kind == TinkerKind.Imbue)
|
||||
{
|
||||
if (imbueTaken) continue;
|
||||
imbueTaken = true;
|
||||
}
|
||||
if (row.AppliedInt != 0 && item.FlagInt(row.AppliedInt) == 2) continue;
|
||||
if (row.StackGroup.Length > 0 && row.StackCap > 0)
|
||||
{
|
||||
stacked ??= new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
int used = stacked.TryGetValue(row.StackGroup, out int u) ? u : 0;
|
||||
n = Math.Min(n, row.StackCap - used);
|
||||
stacked[row.StackGroup] = used + Math.Max(0, n);
|
||||
}
|
||||
if (row.AfterCap)
|
||||
{
|
||||
(afterCap ??= new List<TinkerStep>()).Add(new TinkerStep(row, material));
|
||||
continue;
|
||||
}
|
||||
if (row.UsesTinkSlot)
|
||||
{
|
||||
n = Math.Min(n, free);
|
||||
free -= Math.Max(0, n);
|
||||
}
|
||||
for (int i = 0; i < n; i++) steps.Add(new TinkerStep(row, material));
|
||||
}
|
||||
if (afterCap != null && free == 0) steps.AddRange(afterCap);
|
||||
return steps;
|
||||
}
|
||||
|
||||
/// <summary>Row-level requirements the item's own properties decide.</summary>
|
||||
private static bool Applies(TinkerMaterial row, int material, TinkerItemFacts item)
|
||||
{
|
||||
if (row.Origin != TinkerOrigin.Retail) return true;
|
||||
return material switch
|
||||
{
|
||||
TinkerCatalog.Moonstone => item.MaxMana > 0,
|
||||
TinkerCatalog.Leather => !item.Retained,
|
||||
TinkerCatalog.Sandstone => item.Retained,
|
||||
_ => true,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether a salvage bag can serve a step: a full bag (100 units) of the material, server bags
|
||||
/// matched by name (Abyssal-Touched Gems share Black Garnet's id, Foolproof rend bags may not
|
||||
/// carry a material at all).
|
||||
/// </summary>
|
||||
public static bool BagMatches(TinkerStep step, string bagName, int bagMaterial, int bagUses, int trinketTier = 0)
|
||||
{
|
||||
if (bagUses < 100) return false;
|
||||
bagName ??= string.Empty;
|
||||
if (step.Row.Prepared)
|
||||
return bagMaterial == step.Material && TierOf(bagName) == Math.Clamp(trinketTier, 0, TinkerCatalog.TrinketTiers.Length - 1);
|
||||
bool abyssal = bagName.IndexOf("Abyssal", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
if (step.Row.NameMatch.Length > 0)
|
||||
return bagName.IndexOf(step.Row.NameMatch, StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
if (abyssal) return false;
|
||||
if (bagMaterial == step.Material) return true;
|
||||
return step.Row.Id == TinkerCatalog.RendId && TinkerCatalog.RendFromFoolproofName(bagName) == step.Material;
|
||||
}
|
||||
|
||||
/// <summary>The prepared tier a name carries (0 Minor, 1 Moderate, 2 Major), else -1.</summary>
|
||||
public static int TierOf(string name)
|
||||
{
|
||||
name ??= string.Empty;
|
||||
for (int i = 0; i < TinkerCatalog.TrinketTiers.Length; i++)
|
||||
if (name.IndexOf(TinkerCatalog.TrinketTiers[i], StringComparison.OrdinalIgnoreCase) >= 0) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>A full, not yet prepared bag of a prepared row's salvage (no tier in its name).</summary>
|
||||
public static bool IsRawTrinketBag(int material, string bagName, int bagMaterial, int bagUses)
|
||||
=> bagUses >= 100 && bagMaterial == material && TierOf(bagName) < 0;
|
||||
|
||||
/// <summary>The Ammunition that prepares a raw bag into a tier bag.</summary>
|
||||
public static bool IsTierAmmunition(string name, int tier)
|
||||
=> (name ?? string.Empty).IndexOf("Ammunition", StringComparison.OrdinalIgnoreCase) >= 0
|
||||
&& TierOf(name!) == Math.Clamp(tier, 0, TinkerCatalog.TrinketTiers.Length - 1);
|
||||
|
||||
/// <summary>True for a bag that can't fail ("Foolproof ...").</summary>
|
||||
public static bool IsFoolproof(string bagName)
|
||||
=> (bagName ?? string.Empty).IndexOf("Foolproof", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
|
||||
/// <summary>
|
||||
/// Picks the bag for a step (-1 = none qualifies). With a minimum percent: the lowest
|
||||
/// workmanship bag that reaches it, so good bags are kept for hard tinks. Without one: the
|
||||
/// best chance (lowest workmanship on a tie). A bag whose chance isn't known (server rows)
|
||||
/// is the best workmanship one; the server's own percent is checked when it asks.
|
||||
/// </summary>
|
||||
public static int SelectBag(IReadOnlyList<TinkerBagChoice> bags, int minPercent)
|
||||
{
|
||||
int best = -1;
|
||||
for (int i = 0; i < bags.Count; i++)
|
||||
{
|
||||
var b = bags[i];
|
||||
if (b.Chance is not double c)
|
||||
{
|
||||
if (best < 0 || (bags[best].Chance == null && b.Workmanship > bags[best].Workmanship)) best = i;
|
||||
continue;
|
||||
}
|
||||
if (minPercent > 0)
|
||||
{
|
||||
if (TinkerMath.Percent(c) < minPercent) continue;
|
||||
if (best < 0 || bags[best].Chance == null || b.Workmanship < bags[best].Workmanship) best = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (best < 0 || bags[best].Chance == null) { best = i; continue; }
|
||||
double bc = bags[best].Chance!.Value;
|
||||
if (c > bc + 1e-9 || (Math.Abs(c - bc) <= 1e-9 && b.Workmanship < bags[best].Workmanship)) best = i;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/// <summary>"Iron x3, Brass x2" for a plan.</summary>
|
||||
public static string Summary(IReadOnlyList<TinkerStep> steps)
|
||||
{
|
||||
if (steps.Count == 0) return "-";
|
||||
var parts = new List<string>();
|
||||
int i = 0;
|
||||
while (i < steps.Count)
|
||||
{
|
||||
int j = i;
|
||||
while (j < steps.Count && steps[j].Material == steps[i].Material && steps[j].Row.Origin == steps[i].Row.Origin) j++;
|
||||
string name = TinkerCatalog.MaterialName(steps[i].Material);
|
||||
parts.Add(j - i > 1 ? $"{name} x{j - i}" : name);
|
||||
i = j;
|
||||
}
|
||||
return string.Join(", ", parts);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,586 @@
|
|||
// TinkerRunner.cs - Scans one Crafting tab's items, plans them and applies the salvage.
|
||||
//
|
||||
// Pump thread only (the tab's Render reads the volatile snapshots and posts Scan/Start/Stop).
|
||||
// One step at a time:
|
||||
// 1. gates: peace mode (unless the server allows combat crafting), not busy, ActionPacer;
|
||||
// 2. re-plan the item from fresh facts (TinkerPlanner) minus what this run already tried;
|
||||
// 3. pick the bag (TinkerPlanner.SelectBag over TinkerMath's retail chance, Foolproof = 100%);
|
||||
// 4. arm the engine's confirmation answer (v81: Yes only at the tab's minimum percent) and
|
||||
// UseObjectOn(bag, item);
|
||||
// 5. wait for the result: the craft chat line, the bag leaving the pack, a declined
|
||||
// confirmation, "cannot be used on", or a WeenieError (YoureTooBusy retries).
|
||||
// Without the v81 engine (or with dialog answering off) AC shows its own dialog and the player
|
||||
// clicks it; the runner waits longer for that.
|
||||
// Prepared rows (a server's trinket salvage): with no bag prepared at the chosen tier, a raw bag
|
||||
// is first used on that tier's Ammunition (UB-IT's "prep salvage") and the step runs once the
|
||||
// prepared bag shows up.
|
||||
// Items a run finished are left out of later scans this session, so server rows that don't show
|
||||
// on the item aren't applied twice and "auto next batch" moves on to the next items.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.PluginSdk;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
|
||||
|
||||
/// <summary>One scanned item as the tab shows it.</summary>
|
||||
internal sealed class TinkerRow
|
||||
{
|
||||
public int Id;
|
||||
public string Name = string.Empty;
|
||||
public int Tinks;
|
||||
public double Workmanship;
|
||||
public bool Imbued;
|
||||
public string Plan = "-";
|
||||
/// <summary>Updated by the runner as it works the item.</summary>
|
||||
public volatile string Status = "planned";
|
||||
}
|
||||
|
||||
internal sealed class TinkerRunner
|
||||
{
|
||||
private const uint IntWorkmanship = 105;
|
||||
private const uint IntNumItemsInMaterial = 170;
|
||||
private const uint IntDamageType = 45;
|
||||
private const uint IntItemMaxMana = 108;
|
||||
private const uint BoolRetained = 91;
|
||||
private const uint ErrorYoureTooBusy = 0x1D;
|
||||
private const long StepTimeoutMs = 15_000;
|
||||
/// <summary>The player answers AC's own dialog: give them time.</summary>
|
||||
private const long ManualTimeoutMs = 60_000;
|
||||
private const long RetryDelayMs = 1_500;
|
||||
private const long StepGapMs = 600;
|
||||
private const int MaxRetries = 3;
|
||||
/// <summary>Appraisal requests one scan may send (the Items tab sees the whole pack).</summary>
|
||||
private const int MaxAppraisalsPerScan = 25;
|
||||
/// <summary>UB-IT polls up to ~30 s for the prepared bag.</summary>
|
||||
private const long PrepTimeoutMs = 30_000;
|
||||
/// <summary>Auto next batch: re-scan while items are still being appraised, this often and this many times.</summary>
|
||||
private const long AutoRescanDelayMs = 3_000;
|
||||
private const int AutoRescanTries = 10;
|
||||
|
||||
private static readonly Regex Applied = new(
|
||||
@"^(?<character>[\w\s]+) successfully applies the (?<salvage>[\w\s\-]+?)(\sSalvage.*)(\s?\(100\))?\s\(workmanship (?<workmanship>\d+\.\d+)\) to the (?<item>[\w\s\'\-]+)\.$",
|
||||
RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
private static readonly Regex Failed = new(
|
||||
@"^(?<character>[\w\s]+) fails to apply the (?<salvage>[\w\s\-]+?)(\sSalvage.*)(\s?\(100\))?\s\(workmanship (?<workmanship>\d+\.\d+)\) to the (?<item>[\w\s\'\-]+)\.",
|
||||
RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
private static readonly Regex Foolproof = new(@"^You apply the (?<salvage>.*)\.$", RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
private static readonly Regex CannotUse = new(@"^The .+ cannot be used on the .+\.$", RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
|
||||
private readonly MiniRemoteContext _ctx;
|
||||
private readonly Func<TinkerBench, IReadOnlyList<TinkerMaterial>> _rows;
|
||||
private readonly Func<TinkerBench, TinkerBenchSettings> _settings;
|
||||
|
||||
// Job (pump thread)
|
||||
private TinkerBench _bench;
|
||||
private readonly Queue<int> _queue = new();
|
||||
private int _itemId;
|
||||
private readonly Dictionary<string, int> _attempted = new();
|
||||
private readonly HashSet<string> _skipped = new();
|
||||
private bool _waiting;
|
||||
private TinkerStep _step;
|
||||
private int _bagId;
|
||||
private string _bagName = string.Empty;
|
||||
private int _confSeq, _errSeq, _retries, _stepPercent;
|
||||
private bool _manual;
|
||||
private long _stepAt, _nextAt;
|
||||
private Dictionary<int, TinkerRow> _byId = new();
|
||||
/// <summary>The wait is for a bag being prepared, not a tinker.</summary>
|
||||
private bool _prep;
|
||||
private int _prepsThisItem;
|
||||
/// <summary>Bags this batch used up (auto next batch stops after a batch that used none).</summary>
|
||||
private int _usedThisBatch;
|
||||
private long _autoRescanAt;
|
||||
private int _autoRescansLeft;
|
||||
/// <summary>Items a run finished this session, per bench (pump thread).</summary>
|
||||
private readonly Dictionary<TinkerBench, HashSet<int>> _done = new();
|
||||
/// <summary>Per-bench copies of the done counts for the tab.</summary>
|
||||
private readonly int[] _doneCounts = new int[Enum.GetValues<TinkerBench>().Length];
|
||||
|
||||
// Render snapshots
|
||||
private volatile TinkerRow[] _scan = Array.Empty<TinkerRow>();
|
||||
private volatile string _status = "idle";
|
||||
private volatile int _scannedBench = -1;
|
||||
|
||||
public TinkerRunner(MiniRemoteContext ctx, Func<TinkerBench, IReadOnlyList<TinkerMaterial>> rows,
|
||||
Func<TinkerBench, TinkerBenchSettings> settings)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_rows = rows;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
/// <summary>A job is on (set by Start, cleared by Stop: the queue empties before the batch-done step runs).</summary>
|
||||
public bool Running => _active;
|
||||
private volatile bool _active;
|
||||
public TinkerBench Bench => _bench;
|
||||
public string Status => _status;
|
||||
/// <summary>The last scan's rows (for <see cref="ScannedBench"/>).</summary>
|
||||
public TinkerRow[] Rows => _scan;
|
||||
public int ScannedBench => _scannedBench;
|
||||
/// <summary>How many of a bench's items this session already finished (render thread safe).</summary>
|
||||
public int DoneCount(TinkerBench bench) => Volatile.Read(ref _doneCounts[(int)bench]);
|
||||
|
||||
private RynthCoreHost Host => _ctx.Host;
|
||||
private MiniRemoteInventory Inv => _ctx.Inventory;
|
||||
private CraftingTabState C => _ctx.State.Crafting;
|
||||
private int Tier => Math.Clamp(C.TrinketTier, 0, TinkerCatalog.TrinketTiers.Length - 1);
|
||||
|
||||
private HashSet<int> DoneSet(TinkerBench bench)
|
||||
{
|
||||
if (!_done.TryGetValue(bench, out var set)) _done[bench] = set = new HashSet<int>();
|
||||
return set;
|
||||
}
|
||||
|
||||
/// <summary>Lets a bench's finished items show in scans again (pump thread).</summary>
|
||||
public void ForgetDone(TinkerBench bench)
|
||||
{
|
||||
DoneSet(bench).Clear();
|
||||
Volatile.Write(ref _doneCounts[(int)bench], 0);
|
||||
_status = $"{TinkerCatalog.Label(bench)}: finished items will show in scans again";
|
||||
}
|
||||
|
||||
private void MarkDone(TinkerBench bench, int id)
|
||||
{
|
||||
var set = DoneSet(bench);
|
||||
if (set.Add(id)) Volatile.Write(ref _doneCounts[(int)bench], set.Count);
|
||||
}
|
||||
|
||||
// ── Scan ────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Reads what the planner needs from an item.</summary>
|
||||
public TinkerItemFacts Facts(WorldObject wo) => new()
|
||||
{
|
||||
Id = wo.Id,
|
||||
Name = wo.Name ?? string.Empty,
|
||||
Class = wo.ObjectClass,
|
||||
Workmanship = Inv.Int(wo, IntWorkmanship),
|
||||
Tinks = Inv.Int(wo, MiniRemoteInventory.IntNumTimesTinkered),
|
||||
Imbued = Inv.Int(wo, MiniRemoteInventory.IntImbuedEffect) != 0,
|
||||
DamageType = Inv.Int(wo, IntDamageType),
|
||||
Retained = Inv.Bool(wo, BoolRetained),
|
||||
MaxMana = Inv.Int(wo, IntItemMaxMana),
|
||||
Equipped = Inv.IsEquipped(wo),
|
||||
FlagInt = k => Inv.Int(wo, unchecked((uint)k)),
|
||||
};
|
||||
|
||||
/// <summary>A thread-safe copy of a bench's settings (the tab edits Counts under its lock).</summary>
|
||||
public static TinkerBenchSettings Snapshot(TinkerBenchSettings s)
|
||||
{
|
||||
lock (s.Counts)
|
||||
{
|
||||
return new TinkerBenchSettings
|
||||
{
|
||||
Counts = new Dictionary<string, int>(s.Counts),
|
||||
MinChancePercent = s.MinChancePercent,
|
||||
MaxTinks = s.MaxTinks,
|
||||
MinFreeTinks = s.MinFreeTinks,
|
||||
SkipImbued = s.SkipImbued,
|
||||
PierceForCombo = s.PierceForCombo,
|
||||
RendLast = s.RendLast,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scans the pack for a tab: up to BatchSize items that have something to apply, leaving out
|
||||
/// the ones this session already finished. Returns how many items are still being appraised.
|
||||
/// </summary>
|
||||
public int Scan(TinkerBench bench)
|
||||
{
|
||||
if (Running) { _status = "stop the running job before scanning"; return 0; }
|
||||
_autoRescanAt = 0;
|
||||
var s = Snapshot(_settings(bench));
|
||||
var rows = _rows(bench);
|
||||
var done = DoneSet(bench);
|
||||
int batch = Math.Clamp(C.BatchSize, 1, 100);
|
||||
var list = new List<TinkerRow>();
|
||||
int appraising = 0, hidden = 0;
|
||||
foreach (var wo in Inv.Items())
|
||||
{
|
||||
if (!TinkerCatalog.Targets(bench, wo.ObjectClass)) continue;
|
||||
bool trinket = TinkerCatalog.IsTrinket(wo.Name);
|
||||
if (bench == TinkerBench.Jewelry && trinket) continue;
|
||||
if (bench == TinkerBench.Trinkets && !trinket) continue;
|
||||
if (done.Contains(wo.Id)) { hidden++; continue; }
|
||||
if (!Inv.HasAppraisal(wo))
|
||||
{
|
||||
if (appraising < MaxAppraisalsPerScan && Inv.RequestAppraisal(wo)) appraising++;
|
||||
continue;
|
||||
}
|
||||
var f = Facts(wo);
|
||||
if (TinkerPlanner.Excluded(f, s).Length > 0) continue;
|
||||
var plan = TinkerPlanner.Plan(bench, f, s, rows);
|
||||
if (plan.Count == 0) continue;
|
||||
list.Add(new TinkerRow
|
||||
{
|
||||
Id = f.Id, Name = f.Name, Tinks = f.Tinks, Workmanship = f.Workmanship, Imbued = f.Imbued,
|
||||
Plan = TinkerPlanner.Summary(plan),
|
||||
});
|
||||
if (list.Count >= batch) break;
|
||||
}
|
||||
_scan = list.OrderBy(r => r.Name, StringComparer.OrdinalIgnoreCase).ToArray();
|
||||
_scannedBench = (int)bench;
|
||||
string hiddenText = hidden > 0 ? $"; {hidden} finished this session left out" : "";
|
||||
_status = (list.Count == 0
|
||||
? (appraising > 0 ? $"nothing to do yet - appraising {appraising} item(s), scan again in a moment" : "nothing to do: no item matches the ticked salvage")
|
||||
: $"{list.Count} item(s) planned" + (appraising > 0 ? $" ({appraising} still being appraised)" : "")) + hiddenText;
|
||||
return appraising;
|
||||
}
|
||||
|
||||
// ── Job control ─────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Starts on the last scan's rows (pump thread, after the tab's confirm).</summary>
|
||||
public void Start(TinkerBench bench)
|
||||
{
|
||||
if (Running) return;
|
||||
if (_scannedBench != (int)bench || _scan.Length == 0) { _status = "scan first"; return; }
|
||||
_bench = bench;
|
||||
_queue.Clear();
|
||||
_byId = _scan.ToDictionary(r => r.Id);
|
||||
foreach (var r in _scan) { _queue.Enqueue(r.Id); r.Status = "queued"; }
|
||||
_itemId = 0;
|
||||
_waiting = false;
|
||||
_prep = false;
|
||||
_nextAt = 0;
|
||||
_usedThisBatch = 0;
|
||||
_autoRescanAt = 0;
|
||||
_active = true;
|
||||
_status = $"working {_queue.Count} item(s)";
|
||||
RynthLog.Write(LogCat.Crafting, $"[Crafting] {TinkerCatalog.Label(bench)}: start, {_queue.Count} item(s)");
|
||||
}
|
||||
|
||||
public void Stop(string why)
|
||||
{
|
||||
if (_waiting && Host.HasConfirmationAnswers) Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, 0);
|
||||
if (_itemId != 0) SetRow(_itemId, "stopped");
|
||||
while (_queue.Count > 0) SetRow(_queue.Dequeue(), "not started");
|
||||
_itemId = 0;
|
||||
_waiting = false;
|
||||
_prep = false;
|
||||
_autoRescanAt = 0;
|
||||
_active = false;
|
||||
_status = why;
|
||||
}
|
||||
|
||||
public void OnLogout()
|
||||
{
|
||||
Stop("idle");
|
||||
_scan = Array.Empty<TinkerRow>();
|
||||
_scannedBench = -1;
|
||||
foreach (var bench in Enum.GetValues<TinkerBench>())
|
||||
{
|
||||
DoneSet(bench).Clear();
|
||||
Volatile.Write(ref _doneCounts[(int)bench], 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The queue ran out. With auto next batch on, scan the next items (the finished ones are left
|
||||
/// out) and start them if asked; a batch that used no bag at all ends it, so a pack of items
|
||||
/// that all lack salvage isn't walked batch after batch.
|
||||
/// </summary>
|
||||
private void BatchDone(long nowMs)
|
||||
{
|
||||
var bench = _bench;
|
||||
int used = _usedThisBatch;
|
||||
Stop($"done - {used} bag(s) used");
|
||||
RynthLog.Write(LogCat.Crafting, $"[Crafting] {TinkerCatalog.Label(bench)}: batch done, {used} bag(s) used");
|
||||
if (!C.AutoNextBatch) return;
|
||||
if (used == 0) { _status = "done - this batch used no bag, auto next batch stopped"; return; }
|
||||
_autoRescansLeft = AutoRescanTries;
|
||||
AutoScan(bench, nowMs);
|
||||
}
|
||||
|
||||
private void AutoScan(TinkerBench bench, long nowMs)
|
||||
{
|
||||
int appraising = Scan(bench);
|
||||
if (_scan.Length == 0)
|
||||
{
|
||||
// The next items may only be waiting for their appraisal.
|
||||
if (appraising > 0 && _autoRescansLeft-- > 0)
|
||||
{
|
||||
_bench = bench;
|
||||
_autoRescanAt = nowMs + AutoRescanDelayMs;
|
||||
}
|
||||
else _status = "auto next batch: nothing left to do";
|
||||
return;
|
||||
}
|
||||
if (C.AutoStartNextBatch) Start(bench);
|
||||
else _status = $"next batch ready: {_scan.Length} item(s) - press Start";
|
||||
}
|
||||
|
||||
private void SetRow(int id, string status)
|
||||
{
|
||||
if (_byId.TryGetValue(id, out var r)) r.Status = status;
|
||||
}
|
||||
|
||||
private string AttemptKey(string rowKey) => _itemId + ":" + rowKey;
|
||||
|
||||
private void NextItem(string doneStatus)
|
||||
{
|
||||
if (_itemId != 0)
|
||||
{
|
||||
SetRow(_itemId, doneStatus);
|
||||
MarkDone(_bench, _itemId);
|
||||
}
|
||||
_itemId = 0;
|
||||
_prepsThisItem = 0;
|
||||
_attempted.Clear();
|
||||
_skipped.Clear();
|
||||
}
|
||||
|
||||
// ── Tick (pump thread) ──────────────────────────────────────────────────
|
||||
|
||||
public void Tick(long nowMs)
|
||||
{
|
||||
if (!Running)
|
||||
{
|
||||
if (_autoRescanAt != 0 && nowMs >= _autoRescanAt)
|
||||
{
|
||||
_autoRescanAt = 0;
|
||||
AutoScan(_bench, nowMs);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (_waiting) { Wait(nowMs); return; }
|
||||
if (nowMs < _nextAt) return;
|
||||
|
||||
if (!C.AllowInCombat && !Inv.InPeaceMode) { _status = "waiting for peace mode"; return; }
|
||||
if (Inv.IsBusy) return;
|
||||
if (!ActionPacer.MayStart(Host, "Crafting", HealNeed.None, out string why)) { _status = "waiting: " + why; return; }
|
||||
|
||||
if (_itemId == 0)
|
||||
{
|
||||
if (_queue.Count == 0) { BatchDone(nowMs); return; }
|
||||
_itemId = _queue.Dequeue();
|
||||
_retries = 0;
|
||||
}
|
||||
|
||||
var wo = Inv.Cache?[_itemId];
|
||||
if (wo == null) { NextItem("gone from the pack"); return; }
|
||||
if (Inv.IsEquipped(wo)) { NextItem("equipped - skipped"); return; }
|
||||
|
||||
var s = Snapshot(_settings(_bench));
|
||||
var facts = Facts(wo);
|
||||
var plan = TinkerPlanner.Plan(_bench, facts, s, _rows(_bench),
|
||||
k => _attempted.TryGetValue(k, out int n) ? n : 0)
|
||||
.Where(st => !_skipped.Contains(TinkerCatalog.Key(st.Row)))
|
||||
.ToList();
|
||||
if (plan.Count == 0) { NextItem($"done ({facts.Tinks} tinks)"); return; }
|
||||
|
||||
var step = plan[0];
|
||||
string key = TinkerCatalog.Key(step.Row);
|
||||
string matName = TinkerCatalog.MaterialName(step.Material);
|
||||
|
||||
var bags = BagsFor(step);
|
||||
if (bags.Count == 0)
|
||||
{
|
||||
if (step.Row.Prepared) Prepare(nowMs, step, key, matName);
|
||||
else Skip(key, $"no full bag of {matName}");
|
||||
return;
|
||||
}
|
||||
|
||||
int skill = Skill(step.Row.Skill > 0 ? step.Row.Skill : TinkerCatalog.DefaultSkill(_bench));
|
||||
var choices = bags.Select(b =>
|
||||
{
|
||||
double bagWork = TinkerMath.BagWorkmanship(Inv.Int(b, IntWorkmanship), Inv.Int(b, IntNumItemsInMaterial, 1));
|
||||
bool fool = TinkerPlanner.IsFoolproof(b.Name);
|
||||
double? chance = fool ? 1.0
|
||||
: step.Row.Origin == TinkerOrigin.Retail && skill > 0
|
||||
? TinkerMath.Chance(step.Material, skill, facts.Workmanship, bagWork, facts.Tinks,
|
||||
step.Row.Kind == TinkerKind.Imbue, false)
|
||||
: null;
|
||||
return new TinkerBagChoice(b.Id, bagWork, chance);
|
||||
}).ToList();
|
||||
|
||||
int min = Math.Clamp(s.MinChancePercent, 0, 100);
|
||||
int pick = TinkerPlanner.SelectBag(choices, min);
|
||||
if (pick < 0)
|
||||
{
|
||||
int best = choices.Max(ch => TinkerMath.Percent(ch.Chance ?? 0));
|
||||
Skip(key, $"{matName}: best chance {best}% is under {min}%");
|
||||
return;
|
||||
}
|
||||
|
||||
var bag = bags[pick];
|
||||
_stepPercent = choices[pick].Chance is double pc ? TinkerMath.Percent(pc) : -1;
|
||||
_manual = !(C.AnswerCraftDialog && Host.HasConfirmationAnswers
|
||||
&& Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, min, (int)StepTimeoutMs) == 1);
|
||||
_confSeq = Host.TryGetLastConfirmation(out int cs, out _, out _, out _, out _) ? cs : 0;
|
||||
_errSeq = Host.TryGetLastWeenieError(out int es, out _, out _, out _) ? es : 0;
|
||||
|
||||
string pctText = _stepPercent >= 0 ? $" ~{_stepPercent}%" : "";
|
||||
if (!Host.UseOnFor(unchecked((uint)bag.Id), unchecked((uint)_itemId), "Crafting",
|
||||
$"{TinkerCatalog.Label(_bench)}: {matName} on {facts.Name}{pctText}", UseKind.Asked))
|
||||
{
|
||||
if (!_manual) Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, 0);
|
||||
Retry(nowMs, "the use request didn't go out");
|
||||
return;
|
||||
}
|
||||
|
||||
_step = step;
|
||||
_bagId = bag.Id;
|
||||
_bagName = bag.Name ?? matName;
|
||||
_waiting = true;
|
||||
_stepAt = nowMs;
|
||||
_attempted[key] = (_attempted.TryGetValue(key, out int n0) ? n0 : 0) + 1;
|
||||
string ask = _manual ? " - click Yes in AC's craft dialog" : "";
|
||||
SetRow(_itemId, $"applying {matName}{pctText}{ask}");
|
||||
_status = $"{facts.Name}: applying {_bagName}{pctText}{ask}";
|
||||
}
|
||||
|
||||
/// <summary>The full bags that can serve a step (prepared rows: prepared at the chosen tier).</summary>
|
||||
private List<WorldObject> BagsFor(TinkerStep step)
|
||||
=> Inv.Items()
|
||||
.Where(b => b.ObjectClass == AcObjectClass.Salvage
|
||||
&& TinkerPlanner.BagMatches(step, b.Name, Inv.Int(b, MiniRemoteInventory.IntMaterialType), Inv.Uses(b), Tier))
|
||||
.ToList();
|
||||
|
||||
/// <summary>
|
||||
/// No prepared bag: use a raw one on the tier's Ammunition (UB-IT's prep). The wait
|
||||
/// ends when a prepared bag shows up; the next tick then applies it.
|
||||
/// </summary>
|
||||
private void Prepare(long nowMs, TinkerStep step, string key, string matName)
|
||||
{
|
||||
string tierName = TinkerCatalog.TrinketTiers[Tier];
|
||||
if (!C.TrinketPrep) { Skip(key, $"no {tierName} {matName} bag (or tick 'prepare on Ammunition')"); return; }
|
||||
if (++_prepsThisItem > MaxRetries) { Skip(key, $"{matName}: no {tierName} bag came out of preparing"); return; }
|
||||
var raw = Inv.Items().FirstOrDefault(b => b.ObjectClass == AcObjectClass.Salvage
|
||||
&& TinkerPlanner.IsRawTrinketBag(step.Material, b.Name, Inv.Int(b, MiniRemoteInventory.IntMaterialType), Inv.Uses(b)));
|
||||
if (raw == null) { Skip(key, $"no full bag of {matName} to prepare"); return; }
|
||||
var ammo = Inv.Items().FirstOrDefault(a => !Inv.IsEquipped(a) && TinkerPlanner.IsTierAmmunition(a.Name, Tier));
|
||||
if (ammo == null) { Skip(key, $"no {tierName} Ammunition to prepare {matName}"); return; }
|
||||
|
||||
// Preparing is the player's choice (the tick box): any craft dialog it raises is a Yes.
|
||||
_manual = !(C.AnswerCraftDialog && Host.HasConfirmationAnswers
|
||||
&& Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, (int)PrepTimeoutMs) == 1);
|
||||
_confSeq = Host.TryGetLastConfirmation(out int cs, out _, out _, out _, out _) ? cs : 0;
|
||||
_errSeq = Host.TryGetLastWeenieError(out int es, out _, out _, out _) ? es : 0;
|
||||
_step = step;
|
||||
_prep = true;
|
||||
if (!Host.UseOnFor(unchecked((uint)raw.Id), unchecked((uint)ammo.Id), "Crafting",
|
||||
$"{TinkerCatalog.Label(_bench)}: prepare {matName} on {ammo.Name}", UseKind.Asked))
|
||||
{
|
||||
if (!_manual) Host.ArmConfirmation(RynthCoreHost.ConfirmationKind.CraftInteraction, 0, 0);
|
||||
Retry(nowMs, "the prepare request didn't go out");
|
||||
return;
|
||||
}
|
||||
_bagId = raw.Id;
|
||||
_bagName = raw.Name ?? matName;
|
||||
_waiting = true;
|
||||
_stepAt = nowMs;
|
||||
SetRow(_itemId, $"preparing {tierName} {matName}");
|
||||
_status = $"preparing {_bagName} on {ammo.Name}";
|
||||
}
|
||||
|
||||
/// <summary>Buffed tinkering skill (0 when the engine can't read it: the server's percent decides).</summary>
|
||||
private int Skill(int skillId)
|
||||
=> Host.HasGetObjectSkill && Host.TryGetObjectSkill(Inv.PlayerId, unchecked((uint)skillId), out int buffed, out _) ? buffed : 0;
|
||||
|
||||
private void Skip(string rowKey, string why)
|
||||
{
|
||||
_skipped.Add(rowKey);
|
||||
SetRow(_itemId, why);
|
||||
_status = why;
|
||||
}
|
||||
|
||||
private void Retry(long nowMs, string why)
|
||||
{
|
||||
_waiting = false;
|
||||
string key = TinkerCatalog.Key(_step.Row);
|
||||
// A preparation never counted as an attempt.
|
||||
if (!_prep && _attempted.TryGetValue(key, out int n) && n > 0) _attempted[key] = n - 1;
|
||||
_prep = false;
|
||||
if (++_retries > MaxRetries) { NextItem("gave up: " + why); _status = why; return; }
|
||||
_nextAt = nowMs + RetryDelayMs;
|
||||
_status = $"{why} - retrying ({_retries}/{MaxRetries})";
|
||||
}
|
||||
|
||||
private void Finish(string outcome)
|
||||
{
|
||||
_waiting = false;
|
||||
_retries = 0;
|
||||
_nextAt = Environment.TickCount64 + StepGapMs;
|
||||
if (!_prep) _usedThisBatch++;
|
||||
_prep = false;
|
||||
SetRow(_itemId, outcome);
|
||||
_status = outcome;
|
||||
}
|
||||
|
||||
/// <summary>The step's row was refused (No, an error, "cannot be used"): drop it for this item.</summary>
|
||||
private void Refuse(string why)
|
||||
{
|
||||
_waiting = false;
|
||||
_prep = false;
|
||||
Skip(TinkerCatalog.Key(_step.Row), why);
|
||||
}
|
||||
|
||||
private void Wait(long nowMs)
|
||||
{
|
||||
// Engine answer (v81): a No ends the step without using the bag.
|
||||
if (Host.TryGetLastConfirmation(out int seq, out uint type, out int pct, out int outcome, out _)
|
||||
&& seq != _confSeq && type == RynthCoreHost.ConfirmationKind.CraftInteraction)
|
||||
{
|
||||
_confSeq = seq;
|
||||
if (outcome == RynthCoreHost.ConfirmationOutcome.Declined)
|
||||
{
|
||||
Refuse($"{TinkerCatalog.MaterialName(_step.Material)}: server chance {pct}% is under the minimum");
|
||||
return;
|
||||
}
|
||||
if (outcome is RynthCoreHost.ConfirmationOutcome.Shown or RynthCoreHost.ConfirmationOutcome.SendFailed)
|
||||
{
|
||||
_manual = true;
|
||||
_status = $"click Yes in AC's craft dialog ({(pct >= 0 ? pct + "%" : "chance not shown")})";
|
||||
}
|
||||
}
|
||||
|
||||
if (Host.TryGetLastWeenieError(out int es, out uint error, out _, out _) && es != _errSeq)
|
||||
{
|
||||
_errSeq = es;
|
||||
if (error == ErrorYoureTooBusy) { Retry(nowMs, "server says busy"); return; }
|
||||
Refuse($"server refused {TinkerCatalog.MaterialName(_step.Material)} (error 0x{error:X})");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_prep)
|
||||
{
|
||||
// Prepared: the tier bag is in the pack (or the raw bag is gone, and the next tick looks again).
|
||||
if (BagsFor(_step).Count > 0 || Inv.Cache?[_bagId] == null)
|
||||
{
|
||||
Finish($"{TinkerCatalog.TrinketTiers[Tier]} {TinkerCatalog.MaterialName(_step.Material)} prepared");
|
||||
return;
|
||||
}
|
||||
if (nowMs - _stepAt > (_manual ? ManualTimeoutMs : PrepTimeoutMs))
|
||||
Retry(nowMs, "the bag wasn't prepared");
|
||||
return;
|
||||
}
|
||||
|
||||
// Every tinker consumes the bag, success or failure: covers server recipes with their own text.
|
||||
if (Inv.Cache?[_bagId] == null) { Finish($"{_bagName} used"); return; }
|
||||
|
||||
if (nowMs - _stepAt > (_manual ? ManualTimeoutMs : StepTimeoutMs))
|
||||
Retry(nowMs, _manual ? "no answer to AC's craft dialog" : "no result from the server");
|
||||
}
|
||||
|
||||
/// <summary>The craft result lines (never hidden).</summary>
|
||||
public void OnChat(string text)
|
||||
{
|
||||
if (!_waiting || string.IsNullOrEmpty(text)) return;
|
||||
string mat = TinkerCatalog.MaterialName(_step.Material);
|
||||
if (CannotUse.IsMatch(text))
|
||||
{
|
||||
Refuse(_prep ? $"{mat} can't be prepared on that Ammunition" : $"{mat} can't be used on this item");
|
||||
return;
|
||||
}
|
||||
// A preparation ends when the prepared bag shows up (Wait), not on a craft line.
|
||||
if (_prep) return;
|
||||
if (Applied.IsMatch(text)) Finish($"{mat} applied");
|
||||
else if (Failed.IsMatch(text)) Finish($"{mat} failed");
|
||||
else if (Foolproof.IsMatch(text)) Finish($"{mat} applied (foolproof)");
|
||||
}
|
||||
}
|
||||
434
Plugins/RynthCore.Plugin.RynthAi/MiniRemote/CraftingTab.cs
Normal file
434
Plugins/RynthCore.Plugin.RynthAi/MiniRemote/CraftingTab.cs
Normal file
|
|
@ -0,0 +1,434 @@
|
|||
// CraftingTab.cs - The Mini Remote's universal "Crafting" tab (every world, like Quests and Pets).
|
||||
//
|
||||
// UB-IT's crafting benches, one sub-tab each: Armor, Weapons (Melee / Missile / Caster),
|
||||
// Jewelry, Trinkets and Items tinkering. (Infinite Leaftide's own crafting - chunking / clap,
|
||||
// split arrows, the Rings inscription chain - belongs in RynthILT.) Every tinker tab has two
|
||||
// sections:
|
||||
// * Retail tinkering - stock ACE salvage (TinkerCatalog.Retail), chance from TinkerMath;
|
||||
// * Server tinkering - the connected server's own salvage, from the plugin that owns it (its
|
||||
// "RynthServer.Profile" JSON's "salvage" list, MiniRemoteContext.ServerSalvage; RynthILT's on
|
||||
// Infinite Leaftide), then the player's own rows for this world (CraftingTabState.CustomByWorld).
|
||||
// With none defined it says so.
|
||||
// One TinkerRunner works one tab's scan at a time.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.RynthAi.MiniRemote.Crafting;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
|
||||
internal sealed class CraftingTab
|
||||
{
|
||||
private readonly MiniRemoteContext _ctx;
|
||||
|
||||
public TinkerRunner Runner { get; }
|
||||
|
||||
// Custom-row editor (render thread only)
|
||||
private int _newMaterial = TinkerCatalog.Steel;
|
||||
private int _newKind;
|
||||
private bool _newSlot = true;
|
||||
private string _newNameMatch = string.Empty;
|
||||
private string _newNote = string.Empty;
|
||||
|
||||
private static readonly string[] KindLabels = { "Tink (repeatable)", "Imbue (one per item)", "Once (flag recipe)" };
|
||||
|
||||
public CraftingTab(MiniRemoteContext ctx)
|
||||
{
|
||||
_ctx = ctx;
|
||||
Runner = new TinkerRunner(ctx, RowsFor, SettingsFor);
|
||||
}
|
||||
|
||||
private CraftingTabState C => _ctx.State.Crafting;
|
||||
|
||||
/// <summary>The bench's settings block (created on first use).</summary>
|
||||
private TinkerBenchSettings SettingsFor(TinkerBench bench)
|
||||
{
|
||||
var all = C.Benches;
|
||||
lock (all)
|
||||
{
|
||||
string key = bench.ToString();
|
||||
if (!all.TryGetValue(key, out var s) || s == null) all[key] = s = new TinkerBenchSettings();
|
||||
s.Counts ??= new Dictionary<string, int>();
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The player's rows for the connected world (a copy).</summary>
|
||||
private List<CustomTinker> CustomRows()
|
||||
{
|
||||
string world = _ctx.WorldName;
|
||||
var map = C.CustomByWorld;
|
||||
lock (map)
|
||||
return map.TryGetValue(world, out var list) && list != null ? new List<CustomTinker>(list) : new List<CustomTinker>();
|
||||
}
|
||||
|
||||
/// <summary>Retail + server + custom rows for a bench on this world.</summary>
|
||||
private IReadOnlyList<TinkerMaterial> RowsFor(TinkerBench bench)
|
||||
=> TinkerPlanner.Rows(bench, ServerRowsFor(bench), CustomRows());
|
||||
|
||||
/// <summary>The connected server's own salvage for a bench: what its plugin's profile defines.</summary>
|
||||
private IReadOnlyList<TinkerMaterial> ServerRowsFor(TinkerBench bench)
|
||||
=> TinkerCatalog.FromServerPlugin(bench, _ctx.ServerSalvage);
|
||||
|
||||
/// <summary>The connected server defines salvage for at least one bench.</summary>
|
||||
private bool ServerHasSalvage => _ctx.ServerSalvage.Count > 0;
|
||||
|
||||
// ── Lifecycle (MiniRemoteController) ─────────────────────────────────────────────────────────
|
||||
|
||||
public void Tick(long nowMs) => Runner.Tick(nowMs);
|
||||
|
||||
public void OnChat(string text) => Runner.OnChat(text);
|
||||
|
||||
public void OnLogout() => Runner.OnLogout();
|
||||
|
||||
// ── UI (render thread) ──────────────────────────────────────────────────
|
||||
|
||||
public void Render()
|
||||
{
|
||||
if (!ImGui.BeginTabBar("##crafting")) return;
|
||||
if (ImGui.BeginTabItem("Armor")) { RenderBench(TinkerBench.Armor); ImGui.EndTabItem(); }
|
||||
if (ImGui.BeginTabItem("Weapons"))
|
||||
{
|
||||
if (ImGui.BeginTabBar("##craftweapons"))
|
||||
{
|
||||
if (ImGui.BeginTabItem("Melee")) { RenderBench(TinkerBench.Melee); ImGui.EndTabItem(); }
|
||||
if (ImGui.BeginTabItem("Missile")) { RenderBench(TinkerBench.Missile); ImGui.EndTabItem(); }
|
||||
if (ImGui.BeginTabItem("Caster")) { RenderBench(TinkerBench.Caster); ImGui.EndTabItem(); }
|
||||
ImGui.EndTabBar();
|
||||
}
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
if (ImGui.BeginTabItem("Jewelry")) { RenderBench(TinkerBench.Jewelry); ImGui.EndTabItem(); }
|
||||
if (ImGui.BeginTabItem("Trinkets")) { RenderBench(TinkerBench.Trinkets); ImGui.EndTabItem(); }
|
||||
if (ImGui.BeginTabItem("Items")) { RenderBench(TinkerBench.Items); ImGui.EndTabItem(); }
|
||||
ImGui.EndTabBar();
|
||||
}
|
||||
|
||||
private void RenderBench(TinkerBench bench)
|
||||
{
|
||||
var s = SettingsFor(bench);
|
||||
string world = _ctx.WorldName;
|
||||
bool weapon = bench is TinkerBench.Melee or TinkerBench.Missile or TinkerBench.Caster;
|
||||
ImGui.PushID((int)bench);
|
||||
|
||||
RenderFilters(s, weapon);
|
||||
if (bench == TinkerBench.Trinkets) RenderTrinketOptions();
|
||||
|
||||
if (ImGui.CollapsingHeader("Retail tinkering", ImGuiTreeNodeFlags.DefaultOpen))
|
||||
{
|
||||
var retail = TinkerCatalog.RetailFor(bench);
|
||||
if (retail.Count == 0) ImGui.TextDisabled("Retail AC has no tinkering for this tab.");
|
||||
else RenderRows(s, retail, "retail");
|
||||
}
|
||||
|
||||
// The server plugin's name when RynthCore has an active server, else the world name.
|
||||
string server = _ctx.ServerName.Length > 0 ? _ctx.ServerName : world.Length > 0 ? world : "this server";
|
||||
string serverTitle = $"Server tinkering - {server}###server";
|
||||
if (ImGui.CollapsingHeader(serverTitle, ImGuiTreeNodeFlags.DefaultOpen))
|
||||
{
|
||||
var serverRows = ServerRowsFor(bench);
|
||||
if (serverRows.Count > 0)
|
||||
{
|
||||
RenderRows(s, serverRows, "server");
|
||||
if (serverRows.Any(r => !r.UsesTinkSlot && r.AppliedInt == 0))
|
||||
ImGui.TextDisabled("Rows without a tink slot don't show on the item: a run applies each once, and items\n"
|
||||
+ "finished this session are left out of later scans (Forget brings them back).");
|
||||
}
|
||||
else if (ServerHasSalvage)
|
||||
ImGui.TextDisabled("This server doesn't have any dynamic salvage defined for this tab.");
|
||||
else
|
||||
ImGui.TextDisabled("This server doesn't have any dynamic salvage defined.");
|
||||
RenderCustom(bench, s, world);
|
||||
}
|
||||
|
||||
RenderRun(bench, s);
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
private static void RenderFilters(TinkerBenchSettings s, bool weapon)
|
||||
{
|
||||
int min = s.MinChancePercent;
|
||||
ImGui.SetNextItemWidth(90);
|
||||
if (ImGui.InputInt("Min chance %", ref min, 5)) s.MinChancePercent = Math.Clamp(min, 0, 100);
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip("Skip a salvage whose chance is under this (0 = any).\nRetail chances are worked out ahead; "
|
||||
+ "the server's own percent is checked when it asks.");
|
||||
ImGui.SameLine();
|
||||
int maxT = s.MaxTinks;
|
||||
ImGui.SetNextItemWidth(90);
|
||||
if (ImGui.SliderInt("Max tinks", ref maxT, 0, TinkerCatalog.MaxTinks)) s.MaxTinks = maxT;
|
||||
ImGui.SameLine();
|
||||
int minFree = s.MinFreeTinks;
|
||||
ImGui.SetNextItemWidth(90);
|
||||
if (ImGui.SliderInt("Min free", ref minFree, 0, TinkerCatalog.MaxTinks)) s.MinFreeTinks = minFree;
|
||||
bool skipImbued = s.SkipImbued;
|
||||
if (ImGui.Checkbox("Skip imbued", ref skipImbued)) s.SkipImbued = skipImbued;
|
||||
if (weapon)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
bool pierce = s.PierceForCombo;
|
||||
if (ImGui.Checkbox("Slash/pierce: pierce rend", ref pierce)) s.PierceForCombo = pierce;
|
||||
ImGui.SameLine();
|
||||
bool rendLast = s.RendLast;
|
||||
if (ImGui.Checkbox("Rend last", ref rendLast)) s.RendLast = rendLast;
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Apply the rend after everything else (a Foolproof rend can't fail).");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Trinkets: the prepared salvage tier and whether to prepare raw bags on the tier's Ammunition.</summary>
|
||||
private void RenderTrinketOptions()
|
||||
{
|
||||
int tier = Math.Clamp(C.TrinketTier, 0, TinkerCatalog.TrinketTiers.Length - 1);
|
||||
ImGui.SetNextItemWidth(110);
|
||||
if (ImGui.Combo("Tier", ref tier, TinkerCatalog.TrinketTiers, TinkerCatalog.TrinketTiers.Length)) C.TrinketTier = tier;
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip("Uses bags whose name has this tier (e.g. \"Major\"), made on that tier's Ammunition.");
|
||||
ImGui.SameLine();
|
||||
bool prep = C.TrinketPrep;
|
||||
if (ImGui.Checkbox("Prepare on Ammunition", ref prep)) C.TrinketPrep = prep;
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip("With no bag of the tier carried, use a full raw bag on the tier's Ammunition first,\n"
|
||||
+ "then apply the prepared bag.");
|
||||
ImGui.TextDisabled("Trinkets: compass, goggles, scarab, watch, puzzle box, top (the Jewelry tab leaves them out).");
|
||||
}
|
||||
|
||||
/// <summary>One ticked count / checkbox per row.</summary>
|
||||
private static void RenderRows(TinkerBenchSettings s, IReadOnlyList<TinkerMaterial> rows, string id)
|
||||
{
|
||||
if (!ImGui.BeginTable("##rows" + id, 3, ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingStretchProp)) return;
|
||||
ImGui.TableSetupColumn("Use", ImGuiTableColumnFlags.WidthFixed, 80);
|
||||
ImGui.TableSetupColumn("Salvage", ImGuiTableColumnFlags.WidthFixed, 150);
|
||||
ImGui.TableSetupColumn("Effect");
|
||||
foreach (var row in rows)
|
||||
{
|
||||
string key = TinkerCatalog.Key(row);
|
||||
ImGui.PushID(key);
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
CountControl(s, key, row.Kind);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(row.Name);
|
||||
ImGui.TableNextColumn();
|
||||
string slot = row.UsesTinkSlot ? "" : " - no tink slot";
|
||||
SafeImGui.TextDisabled(row.Kind == TinkerKind.Imbue ? row.Effect + " (imbue)" : row.Effect + (row.Effect.Contains("tink slot") ? "" : slot));
|
||||
ImGui.PopID();
|
||||
}
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
/// <summary>Tinks: how many (0-10); imbues and one-shot recipes: on/off.</summary>
|
||||
private static void CountControl(TinkerBenchSettings s, string key, TinkerKind kind)
|
||||
{
|
||||
int count;
|
||||
lock (s.Counts) count = s.Counts.TryGetValue(key, out int c) ? c : 0;
|
||||
if (kind == TinkerKind.Tink)
|
||||
{
|
||||
ImGui.SetNextItemWidth(70);
|
||||
if (ImGui.SliderInt("##n", ref count, 0, TinkerCatalog.MaxTinks)) SetCount(s, key, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool on = count > 0;
|
||||
if (ImGui.Checkbox("##on", ref on)) SetCount(s, key, on ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetCount(TinkerBenchSettings s, string key, int count)
|
||||
{
|
||||
lock (s.Counts)
|
||||
{
|
||||
if (count <= 0) s.Counts.Remove(key);
|
||||
else s.Counts[key] = count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The player's own rows for this world and bench, plus the add form.</summary>
|
||||
private void RenderCustom(TinkerBench bench, TinkerBenchSettings s, string world)
|
||||
{
|
||||
ImGui.Spacing();
|
||||
ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Your salvage for this server");
|
||||
if (world.Length == 0) { ImGui.TextDisabled("Log in to add rows for this server."); return; }
|
||||
|
||||
var mine = CustomRows().Where(c => c.Bench == (int)bench).ToList();
|
||||
var rows = TinkerPlanner.Rows(bench, null, mine).Where(r => r.Origin == TinkerOrigin.Custom).ToList();
|
||||
if (rows.Count == 0) ImGui.TextDisabled("None yet.");
|
||||
for (int i = 0; i < rows.Count; i++)
|
||||
{
|
||||
var row = rows[i];
|
||||
var src = mine[i];
|
||||
string key = TinkerCatalog.Key(row);
|
||||
ImGui.PushID("custom" + i);
|
||||
CountControl(s, key, row.Kind);
|
||||
ImGui.SameLine();
|
||||
string kind = row.Kind switch { TinkerKind.Imbue => "imbue", TinkerKind.Once => "once", _ => "tink" };
|
||||
string extra = (row.UsesTinkSlot ? "" : ", no tink slot") + (row.NameMatch.Length > 0 ? $", bag name has \"{row.NameMatch}\"" : "");
|
||||
ImGui.TextUnformatted($"{row.Name} ({kind}{extra}) - {row.Effect}");
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("Remove"))
|
||||
{
|
||||
var victim = src;
|
||||
_ctx.Post(() =>
|
||||
{
|
||||
var map = C.CustomByWorld;
|
||||
lock (map)
|
||||
if (map.TryGetValue(world, out var list) && list != null) list.Remove(victim);
|
||||
});
|
||||
}
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
// Add form
|
||||
ImGui.SetNextItemWidth(150);
|
||||
if (ImGui.BeginCombo("##newmat", TinkerCatalog.MaterialName(_newMaterial)))
|
||||
{
|
||||
foreach (var (mid, name) in TinkerCatalog.MaterialNames.OrderBy(m => m.Name))
|
||||
if (ImGui.Selectable(name, mid == _newMaterial)) _newMaterial = mid;
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(150);
|
||||
ImGui.Combo("##newkind", ref _newKind, KindLabels, KindLabels.Length);
|
||||
ImGui.SameLine();
|
||||
ImGui.Checkbox("Uses a tink slot", ref _newSlot);
|
||||
ImGui.SetNextItemWidth(150);
|
||||
ImGui.InputTextWithHint("##newmatch", "bag name contains (optional)", ref _newNameMatch, 64);
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(200);
|
||||
ImGui.InputTextWithHint("##newnote", "effect note", ref _newNote, 96);
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("Add"))
|
||||
{
|
||||
var add = new CustomTinker
|
||||
{
|
||||
Bench = (int)bench,
|
||||
Material = _newMaterial,
|
||||
Imbue = _newKind == 1,
|
||||
Once = _newKind == 2,
|
||||
UsesTinkSlot = _newSlot,
|
||||
NameMatch = _newNameMatch.Trim(),
|
||||
Note = _newNote.Trim(),
|
||||
};
|
||||
_ctx.Post(() =>
|
||||
{
|
||||
var map = C.CustomByWorld;
|
||||
lock (map)
|
||||
{
|
||||
if (!map.TryGetValue(world, out var list) || list == null) map[world] = list = new List<CustomTinker>();
|
||||
list.Add(add);
|
||||
}
|
||||
});
|
||||
_newNote = string.Empty;
|
||||
}
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip("Adds a row for this server only. Its chance isn't known ahead:\nthe server's own percent decides (Min chance %).");
|
||||
}
|
||||
|
||||
/// <summary>Scan / Start / Stop, the shared run options and the scanned rows.</summary>
|
||||
private void RenderRun(TinkerBench bench, TinkerBenchSettings s)
|
||||
{
|
||||
ImGui.Separator();
|
||||
bool canAnswer = _ctx.Host.HasConfirmationAnswers;
|
||||
bool answer = C.AnswerCraftDialog && canAnswer;
|
||||
ImGui.BeginDisabled(!canAnswer);
|
||||
if (ImGui.Checkbox("Answer AC's craft dialog", ref answer)) C.AnswerCraftDialog = answer;
|
||||
ImGui.EndDisabled();
|
||||
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
|
||||
SafeImGui.SetTooltip(canAnswer
|
||||
? "Says Yes for you only when the server's chance reaches Min chance %, else No."
|
||||
: "Needs RynthCore engine API v81: until then click Yes in AC's dialog yourself.");
|
||||
ImGui.SameLine();
|
||||
int batch = C.BatchSize;
|
||||
ImGui.SetNextItemWidth(90);
|
||||
if (ImGui.InputInt("Batch", ref batch, 5)) C.BatchSize = Math.Clamp(batch, 1, 100);
|
||||
ImGui.SameLine();
|
||||
bool combat = C.AllowInCombat;
|
||||
if (ImGui.Checkbox("Allow in combat mode", ref combat)) C.AllowInCombat = combat;
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Only for servers that allow crafting outside peace mode.");
|
||||
|
||||
bool autoNext = C.AutoNextBatch;
|
||||
if (ImGui.Checkbox("Auto next batch", ref autoNext)) C.AutoNextBatch = autoNext;
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip("When a batch finishes, scan the next items (finished ones are left out).\n"
|
||||
+ "Stops after a batch that used no bag.");
|
||||
ImGui.SameLine();
|
||||
ImGui.BeginDisabled(!autoNext);
|
||||
bool autoStart = C.AutoStartNextBatch;
|
||||
if (ImGui.Checkbox("and start it", ref autoStart)) C.AutoStartNextBatch = autoStart;
|
||||
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
|
||||
ImGui.SetTooltip("Start the next batch without asking again (off: press Start yourself).");
|
||||
ImGui.EndDisabled();
|
||||
int doneCount = Runner.DoneCount(bench);
|
||||
if (doneCount > 0)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
SafeImGui.TextDisabled($"{doneCount} finished this session");
|
||||
ImGui.SameLine();
|
||||
ImGui.BeginDisabled(Runner.Running);
|
||||
if (ImGui.SmallButton("Forget")) _ctx.Post(() => Runner.ForgetDone(bench));
|
||||
ImGui.EndDisabled();
|
||||
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
|
||||
ImGui.SetTooltip("Let finished items show in scans again (server rows that don't show on the item could go on twice).");
|
||||
}
|
||||
|
||||
bool running = Runner.Running;
|
||||
bool mine = Runner.ScannedBench == (int)bench;
|
||||
ImGui.BeginDisabled(running);
|
||||
if (ImGui.Button("Scan")) _ctx.Post(() => Runner.Scan(bench));
|
||||
ImGui.SameLine();
|
||||
ImGui.BeginDisabled(!mine || Runner.Rows.Length == 0);
|
||||
if (ImGui.Button("Start"))
|
||||
{
|
||||
int n = Runner.Rows.Length;
|
||||
string answerText = C.AnswerCraftDialog && canAnswer
|
||||
? (s.MinChancePercent > 0 ? $"RynthAi answers AC's dialog: Yes at {s.MinChancePercent}% or better." : "RynthAi answers Yes to AC's dialog.")
|
||||
: "AC asks you to confirm every craft.";
|
||||
_ctx.Confirm($"{TinkerCatalog.Label(bench)} tinkering",
|
||||
$"Apply the planned salvage to {n} item(s)?\n\nTinkering can fail, and every attempt uses the bag and a tink slot.\n{answerText}",
|
||||
() => Runner.Start(bench), "Start");
|
||||
}
|
||||
ImGui.EndDisabled();
|
||||
ImGui.EndDisabled();
|
||||
ImGui.SameLine();
|
||||
ImGui.BeginDisabled(!running);
|
||||
if (ImGui.Button("Stop")) _ctx.Post(() => Runner.Stop("stopped by player"));
|
||||
ImGui.EndDisabled();
|
||||
ImGui.SameLine();
|
||||
if (running && Runner.Bench != bench)
|
||||
SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, $"{TinkerCatalog.Label(Runner.Bench)} is running");
|
||||
else
|
||||
SafeImGui.TextDisabled(Runner.Status);
|
||||
|
||||
if (!mine) return;
|
||||
var scanned = Runner.Rows;
|
||||
if (scanned.Length == 0) return;
|
||||
if (!ImGui.BeginTable("##scan", 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.Borders | ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.ScrollY,
|
||||
new System.Numerics.Vector2(0, 200)))
|
||||
return;
|
||||
ImGui.TableSetupScrollFreeze(0, 1);
|
||||
ImGui.TableSetupColumn("Item");
|
||||
ImGui.TableSetupColumn("Tinks", ImGuiTableColumnFlags.WidthFixed, 40);
|
||||
ImGui.TableSetupColumn("Work", ImGuiTableColumnFlags.WidthFixed, 40);
|
||||
ImGui.TableSetupColumn("Plan");
|
||||
ImGui.TableSetupColumn("Status");
|
||||
ImGui.TableHeadersRow();
|
||||
foreach (var r in scanned)
|
||||
{
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(r.Imbued ? r.Name + " *" : r.Name);
|
||||
if (r.Imbued && ImGui.IsItemHovered()) ImGui.SetTooltip("Imbued");
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(r.Tinks.ToString());
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextUnformatted(r.Workmanship.ToString("0"));
|
||||
ImGui.TableNextColumn();
|
||||
SafeImGui.TextWrapped(r.Plan);
|
||||
ImGui.TableNextColumn();
|
||||
SafeImGui.TextWrapped(r.Status);
|
||||
}
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,8 @@ internal sealed unsafe class IltClient
|
|||
|
||||
private readonly RynthCoreHost _host;
|
||||
private IntPtr _table; // volatile reads/writes: the render thread uses what the pump found
|
||||
private long _checkedAt = long.MinValue;
|
||||
private long _checkedAt;
|
||||
private bool _checkedOnce; // false: look now (a sentinel time would overflow "now - _checkedAt")
|
||||
private readonly IltTabV1[] _tabBuf = new IltTabV1[MaxTabs];
|
||||
private readonly List<IltTabInfo> _tabs = new();
|
||||
|
||||
|
|
@ -39,8 +40,8 @@ internal sealed unsafe class IltClient
|
|||
{
|
||||
long now = Environment.TickCount64;
|
||||
var t = (RynthIltHubApiV1*)System.Threading.Volatile.Read(ref _table);
|
||||
if (t != null && t->Version >= 1 && now - _checkedAt < RecheckMs) return;
|
||||
if (t == null && now - _checkedAt < RecheckMs) return;
|
||||
if (!LookupDue(_checkedOnce, _checkedAt, now, haveTable: t != null, tableLive: t != null && t->Version >= 1)) return;
|
||||
_checkedOnce = true;
|
||||
_checkedAt = now;
|
||||
IntPtr found = IntPtr.Zero;
|
||||
if (_host.HasGetPluginInterface)
|
||||
|
|
@ -55,7 +56,18 @@ internal sealed unsafe class IltClient
|
|||
public void Reset()
|
||||
{
|
||||
System.Threading.Volatile.Write(ref _table, IntPtr.Zero);
|
||||
_checkedAt = long.MinValue;
|
||||
_checkedOnce = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether Tick looks the table up again. Pure. Always on the first call (and after Reset), at
|
||||
/// once when the table RynthILT gave is shut down (Version 0), else every <see cref="RecheckMs"/>.
|
||||
/// </summary>
|
||||
internal static bool LookupDue(bool checkedOnce, long checkedAt, long now, bool haveTable, bool tableLive)
|
||||
{
|
||||
if (!checkedOnce) return true;
|
||||
if (haveTable && !tableLive) return true;
|
||||
return now - checkedAt >= RecheckMs;
|
||||
}
|
||||
|
||||
private RynthIltHubApiV1* T
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@
|
|||
// confirmed action is then posted).
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.PluginSdk;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
|
|
@ -59,6 +61,47 @@ internal sealed class MiniRemoteContext
|
|||
/// <summary>Logged-in character name (resolved at login).</summary>
|
||||
public string CharName = string.Empty;
|
||||
|
||||
/// <summary>The connected world's name ("" before login or on an engine without it); keys the Crafting tab's custom rows.</summary>
|
||||
public string WorldName
|
||||
=> Host.HasGetWorldName && Host.TryGetWorldName(out string world) ? (world ?? string.Empty).Trim() : string.Empty;
|
||||
|
||||
// ── Active server (RynthCore's verdict and its server plugin's profile) ─────────────────────
|
||||
|
||||
/// <summary>What the render thread reads about the active server: replaced whole, never edited.</summary>
|
||||
private sealed record ServerView(string Name, IReadOnlyList<ServerSalvageView> Salvage)
|
||||
{
|
||||
public static readonly ServerView None = new(string.Empty, Array.Empty<ServerSalvageView>());
|
||||
}
|
||||
|
||||
private readonly ServerStateClient _server = new();
|
||||
private int _serverRevision = -1;
|
||||
private volatile ServerView _serverView = ServerView.None;
|
||||
|
||||
/// <summary>The active server's display name from RynthCore ("" when none is active or the engine is pre-v86).</summary>
|
||||
public string ServerName => _serverView.Name;
|
||||
|
||||
/// <summary>The active server plugin's own tinkering salvage (empty when it defines none). Any thread.</summary>
|
||||
public IReadOnlyList<ServerSalvageView> ServerSalvage => _serverView.Salvage;
|
||||
|
||||
/// <summary>Pump thread: polls RynthCore's server state (cheap until due) and rebuilds the view when it changed.</summary>
|
||||
public void PollServer(long now)
|
||||
{
|
||||
_server.Poll(Host, now);
|
||||
if (_server.Revision == _serverRevision) return;
|
||||
_serverRevision = _server.Revision;
|
||||
EngineServerState? st = _server.State;
|
||||
string name = st != null && st.HasActive ? st.ActiveName : string.Empty;
|
||||
_serverView = new ServerView(name, ServerSalvageView.ParseList(_server.ProfileJson));
|
||||
}
|
||||
|
||||
/// <summary>Logout: forget the server; the next login polls fresh.</summary>
|
||||
public void ClearServer()
|
||||
{
|
||||
_server.Clear();
|
||||
_serverRevision = -1;
|
||||
_serverView = ServerView.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the Mini Remote on one of its tabs (tab id; set by the controller). Any thread: it
|
||||
/// only records the tab and the show request, which the next frame applies.
|
||||
|
|
@ -115,32 +158,35 @@ internal static class MiniRemoteTabs
|
|||
{
|
||||
/// <summary>The Remote tab (the remote itself).</summary>
|
||||
public const string Remote = "";
|
||||
public const string Quests = "quests";
|
||||
public const string Pets = "pets";
|
||||
public const string Crafting = "crafting";
|
||||
|
||||
/// <summary>The universal tabs in tab-bar order (after Remote, before RynthILT's tabs).</summary>
|
||||
public static readonly string[] Universal = { Quests, Pets };
|
||||
/// <summary>
|
||||
/// The universal tabs in tab-bar order (after Remote, before RynthILT's tabs). The Quests tab
|
||||
/// moved to RynthOracle on 2026-10-13 (MiniRemoteController.QuestsMovedText).
|
||||
/// </summary>
|
||||
public static readonly string[] Universal = { Pets, Crafting };
|
||||
|
||||
public static string Label(string id) => id switch
|
||||
{
|
||||
Quests => "Quests",
|
||||
Pets => "Pets",
|
||||
Crafting => "Crafting",
|
||||
_ => "Remote",
|
||||
};
|
||||
|
||||
/// <summary>"quests" / "quest" / "pets" / "pet" → the tab id; null for anything else.</summary>
|
||||
/// <summary>"pets" / "crafting" (and their short forms) to the tab id; null for anything else.</summary>
|
||||
public static string? Parse(string? text) => (text ?? string.Empty).Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"quests" or "quest" => Quests,
|
||||
"pets" or "pet" => Pets,
|
||||
"crafting" or "craft" or "tinker" or "tinkering" => Crafting,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// <summary>Size of a universal tab's body (the old section window's default size).</summary>
|
||||
public static System.Numerics.Vector2 Size(string id) => id switch
|
||||
{
|
||||
Quests => new System.Numerics.Vector2(700, 500),
|
||||
Pets => new System.Numerics.Vector2(560, 580),
|
||||
Crafting => new System.Numerics.Vector2(680, 600),
|
||||
_ => new System.Numerics.Vector2(520, 440),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
// MiniRemoteController.cs — The Mini Remote's universal tabs (Quests, Pets), the VTank .usd
|
||||
// MiniRemoteController.cs — The Mini Remote's universal tabs (Pets, Crafting), the VTank .usd
|
||||
// importer and the "/ra hub|quests|pets" commands. The universal half of the ILT Hub's
|
||||
// IltHubController (SilentKelpie's ILT Hub; its Infinite Leaftide half went to the RynthILT plugin
|
||||
// 2026-10-13).
|
||||
// 2026-10-13). The Quests tab and its favorites HUD moved to RynthOracle (Quests tab, Quest Timers
|
||||
// window) on 2026-10-13; "/ra quests [refresh]" (the meta tracker's quiet /myquests, which
|
||||
// RynthILT's Temple tracker also asks for through RynthAi.Hub QuestRefresh) stays here.
|
||||
//
|
||||
// RynthAiPlugin creates one controller per login session and forwards:
|
||||
// OnTick → Tick() (pump thread)
|
||||
// OnChatWindowText → OnChat() (pump thread)
|
||||
// OnRender → Render() (render thread: quest favorites HUD, confirmations)
|
||||
// OnRender → Render() (render thread: confirmations)
|
||||
// /ra hub ..., /ra quests ..., /ra pets ..., /ra guardian ..., /ra bounty ... → HandleCommand()
|
||||
// OnLogout / teardown → OnLogout()
|
||||
// The Mini Remote's tab bar (MiniRemoteHud) shows Remote, then Quests and Pets (here, every
|
||||
// The Mini Remote's tab bar (MiniRemoteHud) shows Remote, then Pets and Crafting (here, every
|
||||
// world), then RynthILT's Infinite Leaftide tabs (IltClient). The ILT verbs ("/ra hub bank",
|
||||
// "/ra hub attr ...", "/ra guardian ...", "/ra bounty", "/ra hub open banking", ...) are forwarded
|
||||
// to RynthILT (RynthILT.Hub Command); without RynthILT they say so.
|
||||
|
|
@ -28,14 +30,23 @@ internal sealed class MiniRemoteController
|
|||
{
|
||||
private const long SaveIntervalMs = 5000;
|
||||
private const string ConfirmPopupId = "Confirm##mrconfirm";
|
||||
/// <summary>The server answers one /myquests a minute; quiet refreshes keep to that.</summary>
|
||||
private const long QuestRefreshCooldownMs = 60_000;
|
||||
|
||||
/// <summary>Where the quest UI went (chat reply for the retired "/ra quests" verbs and tab names).</summary>
|
||||
public const string QuestsMovedText =
|
||||
"[Mini Remote] Quests moved to RynthOracle: /ro (Quests tab: timers, tracking, rewards), /ro timers (Quest Timers window).";
|
||||
|
||||
private readonly MiniRemoteContext _ctx;
|
||||
private readonly Func<QuestTracker?> _quests;
|
||||
private long _lastSaveAt;
|
||||
private long _lastQuestRefreshAt = -QuestRefreshCooldownMs;
|
||||
private MiniRemoteConfirm? _confirm; // render thread
|
||||
private bool _confirmOpened;
|
||||
|
||||
public QuestsTab Quests { get; }
|
||||
public PetsTab Pets { get; }
|
||||
/// <summary>The Crafting tab (tinker benches and server salvage; any world). SilentKelpie's.</summary>
|
||||
public CraftingTab Crafting { get; }
|
||||
public VTankUsdImporter Usd { get; }
|
||||
|
||||
public MiniRemoteController(RynthCoreHost host, string charFolder, Func<WorldObjectCache?> cache,
|
||||
|
|
@ -45,8 +56,9 @@ internal sealed class MiniRemoteController
|
|||
var state = store.Load();
|
||||
var inventory = new MiniRemoteInventory(host, cache);
|
||||
_ctx = new MiniRemoteContext(host, state, store, inventory, ilt, settings) { SaveCombatSettings = saveCombatSettings };
|
||||
Quests = new QuestsTab(_ctx, quests);
|
||||
_quests = quests;
|
||||
Pets = new PetsTab(_ctx);
|
||||
Crafting = new CraftingTab(_ctx);
|
||||
Usd = new VTankUsdImporter(_ctx);
|
||||
_ctx.ShowTab = tab => MiniRemoteTabCommand?.Invoke(tab, "show");
|
||||
}
|
||||
|
|
@ -88,8 +100,12 @@ internal sealed class MiniRemoteController
|
|||
{
|
||||
long now = MiniRemoteContext.NowMs;
|
||||
_ctx.DrainPosted();
|
||||
try { _ctx.PollServer(now); }
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.Crafting, ex, "MiniRemoteContext.PollServer"); }
|
||||
try { Pets.Tick(now); }
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.Pets, ex, "PetsTab.Tick"); }
|
||||
try { Crafting.Tick(now); }
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.Crafting, ex, "CraftingTab.Tick"); }
|
||||
if (now - _lastSaveAt >= SaveIntervalMs)
|
||||
{
|
||||
_lastSaveAt = now;
|
||||
|
|
@ -103,6 +119,8 @@ internal sealed class MiniRemoteController
|
|||
if (string.IsNullOrEmpty(text)) return;
|
||||
try { Pets.OnChat(text.TrimEnd('\r', '\n')); }
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.Pets, ex, "PetsTab.OnChat"); }
|
||||
try { Crafting.OnChat(text.TrimEnd('\r', '\n')); }
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.Crafting, ex, "CraftingTab.OnChat"); }
|
||||
}
|
||||
|
||||
/// <summary>Logout / teardown: stop the pet automation and flush to disk.</summary>
|
||||
|
|
@ -110,29 +128,47 @@ internal sealed class MiniRemoteController
|
|||
{
|
||||
try { Pets.OnLogout(); }
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.Pets, ex, "PetsTab.OnLogout"); }
|
||||
try { Crafting.OnLogout(); }
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.Crafting, ex, "CraftingTab.OnLogout"); }
|
||||
_ctx.ClearServer();
|
||||
_ctx.Store.SaveIfDirty(_ctx.State);
|
||||
}
|
||||
|
||||
/// <summary>"Refresh /myquests" for RynthILT's Temple tracker (RynthAi.Hub QuestRefresh). Pump thread.</summary>
|
||||
public string RefreshQuests() => Quests.RefreshQuests();
|
||||
/// <summary>
|
||||
/// A quiet /myquests refresh of the meta tracker with a 60 s client-side cooldown (the server's
|
||||
/// throttle): "/ra quests refresh" and RynthILT's Temple tracker (RynthAi.Hub QuestRefresh).
|
||||
/// Pump thread. Returns the chat reply.
|
||||
/// </summary>
|
||||
public string RefreshQuests()
|
||||
{
|
||||
RynthLog.Trace(LogCat.Quests, "RefreshQuests()");
|
||||
QuestTracker? t = _quests();
|
||||
if (t == null) return "Quest tracker not ready.";
|
||||
if (_ctx.Ilt.IsOff(RynthIltHub.FeatureQuests) || t.Disabled) return "/myquests is disabled on this server.";
|
||||
long now = MiniRemoteContext.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...";
|
||||
}
|
||||
|
||||
// ── Rendering (render thread) ───────────────────────────────────────────
|
||||
|
||||
/// <summary>One of the Mini Remote's own tabs ("quests", "pets"); false for anything else.</summary>
|
||||
/// <summary>One of the Mini Remote's own tabs ("pets", "crafting"); false for anything else.</summary>
|
||||
public bool RenderTab(string id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case MiniRemoteTabs.Quests: Quests.RenderTab(); return true;
|
||||
case MiniRemoteTabs.Pets: Pets.Render(); return true;
|
||||
case MiniRemoteTabs.Crafting: Crafting.Render(); return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The floating extras: the quest favorites HUD and the confirmation modal.</summary>
|
||||
/// <summary>The floating extras: the confirmation modal.</summary>
|
||||
public void Render()
|
||||
{
|
||||
Quests.RenderFloatingWindows();
|
||||
RenderConfirm();
|
||||
}
|
||||
|
||||
|
|
@ -154,9 +190,9 @@ internal sealed class MiniRemoteController
|
|||
bool keepOpen = true;
|
||||
if (ImGui.BeginPopupModal(ConfirmPopupId, ref keepOpen, ImGuiWindowFlags.AlwaysAutoResize))
|
||||
{
|
||||
ImGui.TextColored(LegacyDashboardRenderer.ColAmber, _confirm.Title);
|
||||
SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, _confirm.Title);
|
||||
ImGui.Separator();
|
||||
ImGui.TextWrapped(_confirm.Message);
|
||||
SafeImGui.TextWrapped(_confirm.Message);
|
||||
ImGui.Spacing();
|
||||
if (ImGui.Button(_confirm.YesLabel + "##mryes", new Vector2(120, 0)))
|
||||
{
|
||||
|
|
@ -184,35 +220,20 @@ internal sealed class MiniRemoteController
|
|||
// ── Commands ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// "/ra hub [show|hide|toggle|open quests|pets [show|hide|toggle]|tab quests|pets|remote]",
|
||||
/// "/ra quests [refresh|check <regex>|window|favhud]", "/ra pets [show|hide|toggle]"; every
|
||||
/// other "/ra hub ..." verb, "/ra guardian ..." and "/ra bounty|bounties|bountys ..." go to
|
||||
/// RynthILT. Returns false if not handled.
|
||||
/// "/ra hub [show|hide|toggle|open pets|crafting [show|hide|toggle]|open breeding|tab pets|crafting|breeding|remote]",
|
||||
/// "/ra quests [refresh]", "/ra pets [show|hide|toggle]"; every other "/ra hub ..." verb,
|
||||
/// "/ra guardian ..." and "/ra bounty|bounties|bountys ..." go to RynthILT. The retired quest
|
||||
/// verbs and tab names ("/ra quests window", "/ra hub open quests", ...) say where quests went,
|
||||
/// and "/ra hub open|tab character" opens RynthOracle's Character tab (Huds/MovedTabs.cs).
|
||||
/// Returns false if not handled.
|
||||
/// </summary>
|
||||
public bool HandleCommand(string verb, string[] args)
|
||||
{
|
||||
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 qs = _ctx.State.Quests;
|
||||
switch (sub)
|
||||
{
|
||||
case "check" when args.Length > 1:
|
||||
Quests.CheckCommand(string.Join(" ", args.Skip(1)));
|
||||
break;
|
||||
case "window":
|
||||
OpenTab(MiniRemoteTabs.Quests, mode);
|
||||
break;
|
||||
case "favhud":
|
||||
case "favorites":
|
||||
qs.ShowQuestFavoritesHud = ResolveToggle(mode, qs.ShowQuestFavoritesHud);
|
||||
_ctx.Chat(qs.ShowQuestFavoritesHud ? "[Mini Remote] Quest favorites HUD shown." : "[Mini Remote] Quest favorites HUD hidden.");
|
||||
break;
|
||||
default:
|
||||
_ctx.Chat("[Mini Remote] " + Quests.RefreshQuests());
|
||||
break;
|
||||
}
|
||||
if (sub == "refresh") _ctx.Chat("[Mini Remote] " + RefreshQuests());
|
||||
else _ctx.Chat(QuestsMovedText);
|
||||
return true;
|
||||
}
|
||||
if (verb.Equals("pets", StringComparison.OrdinalIgnoreCase))
|
||||
|
|
@ -227,6 +248,20 @@ internal sealed class MiniRemoteController
|
|||
if (!ilt)
|
||||
{
|
||||
string cmd = args.Length > 0 ? args[0].ToLowerInvariant() : "toggle";
|
||||
// "/ra hub open|tab quests": the tab is RynthOracle's window now.
|
||||
if (cmd is "open" or "tab" && args.Length > 1 && IsQuestsName(args[1]))
|
||||
{
|
||||
_ctx.Chat(QuestsMovedText);
|
||||
return true;
|
||||
}
|
||||
// "/ra hub open|tab character": the Character tab left the Mini Remote (2026-10-13);
|
||||
// HudController.HandleTabCommand opens RynthOracle's Character tab.
|
||||
if (cmd is "open" or "tab" && args.Length > 1 && Huds.MovedTabs.CommandFor(args[1]) != null)
|
||||
{
|
||||
string? reply = MiniRemoteTabCommand?.Invoke(args[1].Trim().ToLowerInvariant(), "show");
|
||||
if (cmd == "open" && reply != null) _ctx.Chat("[Mini Remote] " + reply);
|
||||
return true;
|
||||
}
|
||||
switch (cmd)
|
||||
{
|
||||
case "show":
|
||||
|
|
@ -235,6 +270,9 @@ internal sealed class MiniRemoteController
|
|||
// The Mini Remote is the Hub's main window.
|
||||
_ctx.Chat(MiniRemoteCommand != null ? MiniRemoteCommand(cmd) : "[Mini Remote] The Mini Remote is not available yet.");
|
||||
return true;
|
||||
case "open" or "tab" when args.Length > 1 && IsBreedingTabName(args[1]):
|
||||
OpenBreeding(cmd);
|
||||
return true;
|
||||
case "open" when args.Length > 1 && MiniRemoteTabs.Parse(args[1]) is { } openTab:
|
||||
OpenTab(openTab, args.Length > 2 ? args[2] : "toggle");
|
||||
return true;
|
||||
|
|
@ -261,14 +299,46 @@ internal sealed class MiniRemoteController
|
|||
|
||||
private void PrintHelp()
|
||||
{
|
||||
_ctx.Chat("[Mini Remote] /ra hub [show|hide|toggle] (Mini Remote) /ra hub open quests|pets [show|hide|toggle]");
|
||||
_ctx.Chat("[Mini Remote] /ra quests [refresh|check <regex>|window [show|hide]|favhud [show|hide]] /ra pets [show|hide]");
|
||||
_ctx.Chat("[Mini Remote] /ra hub [show|hide|toggle] (Mini Remote) /ra hub open pets|crafting [show|hide|toggle] /ra hub open breeding (ILT)");
|
||||
_ctx.Chat("[Mini Remote] /ra quests refresh (quiet /myquests) /ra pets [show|hide] Quest list, timers and rewards: RynthOracle (/ro).");
|
||||
_ctx.Chat("[Mini Remote] Banking, gear, charms, games, the Guardian, bounties, /ra hub attr ...: Infinite Leaftide, the RynthILT plugin.");
|
||||
_ctx.Chat("[Mini Remote] Character overview and session: RynthOracle (/ro character). Force a server: /rc diagnostics.");
|
||||
}
|
||||
|
||||
/// <summary>"breeding" / "breed": the Pets tab's Breeding sub-tab (RynthILT's tracker, Infinite Leaftide).</summary>
|
||||
private static bool IsBreedingTabName(string text) => text.Trim().ToLowerInvariant() is "breeding" or "breed";
|
||||
|
||||
/// <summary>
|
||||
/// "/ra hub open|tab breeding": the Pets tab on its Breeding sub-tab when RynthILT offers it. "open"
|
||||
/// shows the Mini Remote and says why when there is no Breeding sub-tab; "tab" (the engine's
|
||||
/// dashboard) only switches tabs, to the Pets roster when there is none.
|
||||
/// </summary>
|
||||
private void OpenBreeding(string cmd)
|
||||
{
|
||||
bool offered = Pets.BreedingOffered;
|
||||
if (offered) Pets.SelectBreeding();
|
||||
if (cmd == "tab")
|
||||
{
|
||||
MiniRemoteTabCommand?.Invoke(MiniRemoteTabs.Pets, "select");
|
||||
return;
|
||||
}
|
||||
if (!offered)
|
||||
{
|
||||
_ctx.Chat("[Mini Remote] " + (!_ctx.Ilt.Loaded ? IltClient.NotLoaded
|
||||
: !_ctx.Ilt.IsIltWorld ? "Pet breeding is an Infinite Leaftide feature; this world isn't Infinite Leaftide."
|
||||
: "This server reports pet breeding off."));
|
||||
return;
|
||||
}
|
||||
OpenTab(MiniRemoteTabs.Pets, "show");
|
||||
}
|
||||
|
||||
private static bool IsRemoteTabName(string text)
|
||||
=> text.Equals("remote", StringComparison.OrdinalIgnoreCase) || text.Length == 0;
|
||||
|
||||
/// <summary>"quests" / "quest": the retired Quests tab's names.</summary>
|
||||
private static bool IsQuestsName(string text)
|
||||
=> text.Equals("quests", StringComparison.OrdinalIgnoreCase) || text.Equals("quest", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>"/ra bounty", "/ra bounties" and the "/ra bountys" spelling (RynthILT's Bounties window).</summary>
|
||||
public static bool IsBountyVerb(string verb)
|
||||
=> verb.Equals("bounty", StringComparison.OrdinalIgnoreCase)
|
||||
|
|
@ -281,12 +351,4 @@ internal sealed class MiniRemoteController
|
|||
string reply = MiniRemoteTabCommand?.Invoke(tab, mode) ?? "The Mini Remote is not available yet.";
|
||||
_ctx.Chat("[Mini Remote] " + reply);
|
||||
}
|
||||
|
||||
/// <summary>"show"/"on" → true, "hide"/"off" → false, anything else flips <paramref name="current"/>.</summary>
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ internal sealed class MiniRemoteInventory
|
|||
// ── Property ids ────────────────────────────────────────────────────────
|
||||
public const uint IntStackSize = 12;
|
||||
public const uint IntStructure = 92;
|
||||
// Crafting tab (tinker runs): how often an item was tinkered, its imbue, a salvage bag's material.
|
||||
public const uint IntNumTimesTinkered = 171;
|
||||
public const uint IntImbuedEffect = 179;
|
||||
public const uint IntMaterialType = 131;
|
||||
public const uint StrUse = 14;
|
||||
public const uint BoolPyrealRefillActive = 9049;
|
||||
public const uint BoolUniversalMasteryActive = 50038;
|
||||
|
|
@ -91,6 +95,17 @@ internal sealed class MiniRemoteInventory
|
|||
/// <summary>Remaining uses on a structure item (essences, kits, salvage bags).</summary>
|
||||
public int Uses(WorldObject wo) => Int(wo, IntStructure, 0);
|
||||
|
||||
/// <summary>A bool property of an object (false when unknown or the engine can't read it).</summary>
|
||||
public bool Bool(WorldObject wo, uint stype)
|
||||
=> _host.HasGetObjectBoolProperty && _host.TryGetObjectBoolProperty(unchecked((uint)wo.Id), stype, out bool v) && v;
|
||||
|
||||
/// <summary>Stack size (1 for a non-stack).</summary>
|
||||
public int StackSize(WorldObject wo) => Math.Max(1, Int(wo, IntStackSize, 1));
|
||||
|
||||
/// <summary>Worn or wielded by the player.</summary>
|
||||
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));
|
||||
|
||||
|
|
|
|||
|
|
@ -21,10 +21,70 @@ public sealed class MiniRemoteState
|
|||
public int SchemaVersion = 1;
|
||||
public PetTabState Pet = new();
|
||||
public QuestsTabState Quests = new();
|
||||
/// <summary>The Crafting tab (tinker benches); the ILT Hub's Crafting before.</summary>
|
||||
public CraftingTabState Crafting = new();
|
||||
/// <summary>Last VTank .usd file the importer read (the ILT Hub's Gear.LastUsdPath before).</summary>
|
||||
public string LastUsdPath = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>The Crafting tab: one settings block per tinker bench, plus per-server custom salvage.</summary>
|
||||
public sealed class CraftingTabState
|
||||
{
|
||||
/// <summary>Bench settings keyed by the bench name (TinkerBench: Armor, Melee, Missile, Caster, Jewelry, Items, Trinkets).</summary>
|
||||
public Dictionary<string, TinkerBenchSettings> Benches = new();
|
||||
/// <summary>The player's extra salvage rows, keyed by world name (custom shards' own recipes).</summary>
|
||||
public Dictionary<string, List<CustomTinker>> CustomByWorld = new();
|
||||
/// <summary>Answer the server's craft-chance dialog for the runner (engine API v85).</summary>
|
||||
public bool AnswerCraftDialog = true;
|
||||
/// <summary>Items per scan (UB-IT's 20).</summary>
|
||||
public int BatchSize = 20;
|
||||
/// <summary>Apply even in combat mode (servers with allow_combat_mode_crafting).</summary>
|
||||
public bool AllowInCombat;
|
||||
/// <summary>When a batch finishes, scan the next one (items finished this session are left out).</summary>
|
||||
public bool AutoNextBatch;
|
||||
/// <summary>...and start it without asking again.</summary>
|
||||
public bool AutoStartNextBatch;
|
||||
/// <summary>Prepared salvage tier: 0 Minor, 1 Moderate, 2 Major (TinkerCatalog.TrinketTiers).</summary>
|
||||
public int TrinketTier;
|
||||
/// <summary>Prepare a raw bag on the tier's Ammunition when no prepared bag is carried.</summary>
|
||||
public bool TrinketPrep;
|
||||
// "RingRuns" (the Rings chain, now left to RynthILT) may still be in older files: it is ignored.
|
||||
}
|
||||
|
||||
/// <summary>One tinker bench's choices.</summary>
|
||||
public sealed class TinkerBenchSettings
|
||||
{
|
||||
/// <summary>Row key (TinkerCatalog.Key: r/p/c + material id) to how many times (imbues and flags: 0 or 1).</summary>
|
||||
public Dictionary<string, int> Counts = new();
|
||||
/// <summary>Skip a step whose chance is under this percent (0 = any chance).</summary>
|
||||
public int MinChancePercent;
|
||||
/// <summary>Only items with at most this many tinks.</summary>
|
||||
public int MaxTinks = 9;
|
||||
/// <summary>Only items with at least this many free tink slots (0 = no filter).</summary>
|
||||
public int MinFreeTinks;
|
||||
public bool SkipImbued;
|
||||
/// <summary>Slash/pierce weapons take the pierce rend (Black Garnet) instead of slash (Imperial Topaz).</summary>
|
||||
public bool PierceForCombo;
|
||||
/// <summary>The damage-type rend goes after every other step (UB-IT's "Foolproof rend last").</summary>
|
||||
public bool RendLast;
|
||||
}
|
||||
|
||||
/// <summary>A salvage row the player added for one server.</summary>
|
||||
public sealed class CustomTinker
|
||||
{
|
||||
/// <summary>TinkerBench as an int.</summary>
|
||||
public int Bench;
|
||||
/// <summary>MaterialType of the salvage.</summary>
|
||||
public int Material;
|
||||
public bool Imbue;
|
||||
/// <summary>Once per item (a flag-style recipe) rather than a repeatable tink.</summary>
|
||||
public bool Once;
|
||||
public bool UsesTinkSlot = true;
|
||||
/// <summary>The bag's name must contain this (bags that share another salvage's material id).</summary>
|
||||
public string NameMatch = string.Empty;
|
||||
public string Note = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>The Pets tab's settings (the ILT Hub's IltPetState, without the ILT /pets and /shinies logs).</summary>
|
||||
public sealed class PetTabState
|
||||
{
|
||||
|
|
@ -69,7 +129,11 @@ public sealed class PetAssignment
|
|||
public int Kind;
|
||||
}
|
||||
|
||||
/// <summary>The Quests tab's settings (the quest fields of the ILT Hub's IltCharacterState).</summary>
|
||||
/// <summary>
|
||||
/// The retired Quests tab's settings (the quest fields of the ILT Hub's IltCharacterState). The tab
|
||||
/// moved to RynthOracle on 2026-10-13 (tracking and rewards live in its per-character quest book);
|
||||
/// the fields stay so existing miniremote.json files load and keep what they recorded.
|
||||
/// </summary>
|
||||
public sealed class QuestsTabState
|
||||
{
|
||||
/// <summary>Quest Tracker search box contents.</summary>
|
||||
|
|
@ -90,6 +154,8 @@ public sealed class LegacyIltHubFile
|
|||
/// <summary>The ILT Hub's IltCharacterState: its quest fields have QuestsTabState's names.</summary>
|
||||
public QuestsTabState? Character;
|
||||
public LegacyIltGear? Gear;
|
||||
/// <summary>The ILT Hub's Crafting tab (build-comp-10-11 hosted it in RynthAi): same field names.</summary>
|
||||
public CraftingTabState? Crafting;
|
||||
}
|
||||
|
||||
public sealed class LegacyIltGear
|
||||
|
|
@ -149,6 +215,7 @@ internal sealed class MiniRemoteStore
|
|||
{
|
||||
Pet = old.Pet ?? new PetTabState(),
|
||||
Quests = old.Character ?? new QuestsTabState(),
|
||||
Crafting = old.Crafting ?? new CraftingTabState(),
|
||||
LastUsdPath = old.Gear?.LastUsdPath ?? string.Empty,
|
||||
};
|
||||
Normalize(s);
|
||||
|
|
@ -187,6 +254,11 @@ internal sealed class MiniRemoteStore
|
|||
s.Quests.QuestFilter ??= string.Empty;
|
||||
s.Quests.QuestFavorites ??= new();
|
||||
s.Quests.QuestFavorites.RemoveAll(string.IsNullOrWhiteSpace);
|
||||
s.Crafting ??= new CraftingTabState();
|
||||
s.Crafting.Benches ??= new();
|
||||
s.Crafting.CustomByWorld ??= new();
|
||||
s.Crafting.BatchSize = Math.Clamp(s.Crafting.BatchSize, 1, 200);
|
||||
s.Crafting.TrinketTier = Math.Clamp(s.Crafting.TrinketTier, 0, 2);
|
||||
s.LastUsdPath ??= string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@
|
|||
// * 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 logs: RynthILT's (RynthILT.Hub section "pets-logs", ILT only).
|
||||
// * Breeding sub-tab (Infinite Leaftide only): the tab becomes Roster | Breeding when RynthILT
|
||||
// offers it (an ILT world whose server hasn't reported pet breeding off). Its whole body is
|
||||
// RynthILT's pet breeding tracker (RynthILT.Hub section "pets-breeding"); this tab only hosts it.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -694,11 +697,65 @@ internal sealed class PetsTab
|
|||
|
||||
// ── UI (render thread) ──────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Set from any thread: the next frame opens the Breeding sub-tab ("/ra hub open breeding").</summary>
|
||||
private volatile bool _selectBreeding;
|
||||
|
||||
/// <summary>Shows the Breeding sub-tab on the next frame (any thread).</summary>
|
||||
public void SelectBreeding() => _selectBreeding = true;
|
||||
|
||||
/// <summary>
|
||||
/// RynthILT offers the Breeding sub-tab: it calls this world Infinite Leaftide and the server
|
||||
/// hasn't reported pet breeding off. False without RynthILT. Any thread.
|
||||
/// </summary>
|
||||
public bool BreedingOffered => _ctx.Ilt.IsIltWorld && !_ctx.Ilt.IsOff(RynthIltHub.FeaturePetBreeding);
|
||||
|
||||
/// <summary>
|
||||
/// The Pets tab: the universal roster, and on Infinite Leaftide the Roster | Breeding sub-tabs
|
||||
/// (Breeding is drawn by RynthILT).
|
||||
/// </summary>
|
||||
public void Render()
|
||||
{
|
||||
var settings = _ctx.Settings;
|
||||
if (settings == null) { ImGui.TextDisabled("Not logged in."); return; }
|
||||
|
||||
if (!BreedingOffered)
|
||||
{
|
||||
RenderRoster(settings);
|
||||
return;
|
||||
}
|
||||
if (!ImGui.BeginTabBar("##petsub")) return;
|
||||
if (ImGui.BeginTabItem("Roster##petroster"))
|
||||
{
|
||||
RenderRoster(settings);
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
ImGuiTabItemFlags breedFlags = _selectBreeding ? ImGuiTabItemFlags.SetSelected : ImGuiTabItemFlags.None;
|
||||
_selectBreeding = false;
|
||||
if (BeginTab(BreedingTabLabel, breedFlags))
|
||||
{
|
||||
// RynthILT's tracker; an older RynthILT (before 0.3.1) has no such section and draws nothing.
|
||||
if (!_ctx.Ilt.RenderSection(RynthIltHub.SectionPetBreeding))
|
||||
ImGui.TextDisabled("This RynthILT has no pet breeding tracker; update RynthILT to 0.3.1 or later.");
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
ImGui.EndTabBar();
|
||||
}
|
||||
|
||||
private static readonly byte[] BreedingTabLabel = System.Text.Encoding.UTF8.GetBytes("Breeding##petbreeding\0");
|
||||
|
||||
/// <summary>
|
||||
/// BeginTabItem with flags but no close button (ImGui.NET pairs the flags overload with p_open,
|
||||
/// which draws an X on the tab).
|
||||
/// </summary>
|
||||
private static unsafe bool BeginTab(byte[] labelUtf8Z, ImGuiTabItemFlags flags)
|
||||
{
|
||||
fixed (byte* label = labelUtf8Z)
|
||||
return ImGuiNative.igBeginTabItem(label, null, flags) != 0;
|
||||
}
|
||||
|
||||
/// <summary>The universal roster: types, summons, ILT charms, healing pets and RynthILT's /pets logs.</summary>
|
||||
private void RenderRoster(LegacyUiSettings settings)
|
||||
{
|
||||
RenderRosterHeader(settings);
|
||||
RenderRosterTable();
|
||||
// The tab is universal; the charms and the /pets and /shinies logs are ILT's (the logs RynthILT's).
|
||||
|
|
@ -742,10 +799,10 @@ internal sealed class PetsTab
|
|||
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.");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.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);
|
||||
if (active.Length > 0) SafeImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Active summon: " + active);
|
||||
else ImGui.TextDisabled("Active summon: none");
|
||||
|
||||
switch (kind)
|
||||
|
|
@ -775,7 +832,7 @@ internal sealed class PetsTab
|
|||
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);
|
||||
SafeImGui.TextDisabled("Tick one cosmetic pet. Status: " + _cosmeticStatus);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -806,7 +863,7 @@ internal sealed class PetsTab
|
|||
|
||||
if (rows.Length == 0)
|
||||
{
|
||||
ImGui.TextDisabled(kind == PetKind.Cosmetic
|
||||
SafeImGui.TextDisabled(kind == PetKind.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;
|
||||
|
|
@ -837,10 +894,10 @@ internal sealed class PetsTab
|
|||
_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);
|
||||
SafeImGui.TextColored(DamageColor(r.DamageType), r.Line1);
|
||||
SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, " " + r.Line2);
|
||||
if (r.UsesMax > 0 && r.UsesCur == 0) SafeImGui.TextColored(LegacyDashboardRenderer.ColHp, " " + r.Line3);
|
||||
else SafeImGui.TextDisabled(" " + r.Line3);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (showArrows && r.Selected)
|
||||
|
|
@ -905,7 +962,7 @@ internal sealed class PetsTab
|
|||
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)
|
||||
SafeImGui.TextDisabled("Heal pet: " + (string.IsNullOrWhiteSpace(healPet) ? "auto (Healing Buddy / Dule box)" : healPet)
|
||||
+ " — tick one under Type = Healing.");
|
||||
int thr = S.HealthThresholdPercent;
|
||||
ImGui.SetNextItemWidth(160);
|
||||
|
|
@ -921,6 +978,6 @@ internal sealed class PetsTab
|
|||
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);
|
||||
SafeImGui.TextDisabled("Status: " + _healStatus);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,301 +0,0 @@
|
|||
// QuestsTab.cs — The Mini Remote's Quests tab: the /myquests tracker and the floating favorites HUD.
|
||||
// Originally SilentKelpie's IltQuests (ILT Hub). The tab is universal (every server has /myquests),
|
||||
// so it stayed in RynthAi when the ILT Hub went to the RynthILT plugin (2026-10-13); its Quest bonus
|
||||
// (/qb) list is ACECustom's and moved with RynthILT, which draws it at the top of this tab
|
||||
// (RynthILT.Hub section "quests-qb") on Infinite Leaftide.
|
||||
//
|
||||
// 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 (<SuiteDir>\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).
|
||||
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;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
|
||||
internal sealed class QuestsTab
|
||||
{
|
||||
/// <summary>Optional user quest-name file (UB-style or simple key/name XML).</summary>
|
||||
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 const long QuestRefreshCooldownMs = 60_000;
|
||||
|
||||
private readonly MiniRemoteContext _ctx;
|
||||
private readonly Func<QuestTracker?> _tracker;
|
||||
private Dictionary<string, string> _friendlyNames = new(StringComparer.OrdinalIgnoreCase);
|
||||
private long _lastQuestRefreshAt = -QuestRefreshCooldownMs;
|
||||
// Render-thread UI state.
|
||||
private int _questView; // 0 timed, 1 kill tasks, 2 once, 3 all
|
||||
|
||||
public QuestsTab(MiniRemoteContext ctx, Func<QuestTracker?> 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) ───────────────────────────────────────────────
|
||||
|
||||
/// <summary>Reads any element carrying a key/flag attribute plus a name/description.</summary>
|
||||
public void LoadFriendlyNames()
|
||||
{
|
||||
var map = new Dictionary<string, string>(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.Quests, ex, "quests.xml load"); }
|
||||
_friendlyNames = map;
|
||||
}
|
||||
|
||||
// ── Commands ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Quiet /myquests refresh with a 60 s client-side cooldown (server throttle).</summary>
|
||||
public string RefreshQuests()
|
||||
{
|
||||
RynthLog.Trace(LogCat.Quests, $"RefreshQuests()");
|
||||
var t = _tracker();
|
||||
if (t == null) return "Quest tracker not ready.";
|
||||
if (_ctx.Ilt.IsOff(RynthIltHub.FeatureQuests) || t.Disabled) return "/myquests is disabled on this server.";
|
||||
long now = MiniRemoteContext.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...";
|
||||
}
|
||||
|
||||
/// <summary>"/ra quests check <regex>" — lists up to 5 matching flags in chat.</summary>
|
||||
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 : "")} - {MiniRemoteText.Duration(r.TimeUntilReady())}");
|
||||
if (hits.Count > 5) _ctx.Chat($"[Mini Remote] ...and {hits.Count - 5} more.");
|
||||
}
|
||||
|
||||
// ── UI (render thread) ──────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Quest tracker body, filling the Mini Remote's Quests tab (the table uses the remaining height).</summary>
|
||||
public void RenderQuestTracker()
|
||||
{
|
||||
var t = _tracker();
|
||||
if (t == null) { ImGui.TextDisabled("Quest tracker not ready."); return; }
|
||||
if (_ctx.Ilt.IsOff(RynthIltHub.FeatureQuests) || t.Disabled)
|
||||
{
|
||||
ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "/myquests is disabled on this server.");
|
||||
return;
|
||||
}
|
||||
var cs = _ctx.State.Quests;
|
||||
|
||||
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(MiniRemoteText.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";
|
||||
|
||||
/// <summary>Starred keys as a set (render thread; the list itself is only edited on the pump thread).</summary>
|
||||
private HashSet<string> FavoriteSet()
|
||||
=> new(_ctx.State.Quests.QuestFavorites.ToArray(), StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>Stars / unstars a quest flag (pump thread).</summary>
|
||||
private void ToggleFavorite(string key)
|
||||
{
|
||||
var list = _ctx.State.Quests.QuestFavorites;
|
||||
if (list.RemoveAll(k => k.Equals(key, StringComparison.OrdinalIgnoreCase)) == 0)
|
||||
list.Add(key.ToLowerInvariant());
|
||||
}
|
||||
|
||||
/// <summary>The floating favorites HUD (the tracker itself is the Mini Remote's Quests tab). Called every frame.</summary>
|
||||
public void RenderFloatingWindows()
|
||||
{
|
||||
var cs = _ctx.State.Quests;
|
||||
if (cs.ShowQuestFavoritesHud) RenderFavoritesHud(cs);
|
||||
}
|
||||
|
||||
/// <summary>The Mini Remote's Quests tab: the quest bonus (collapsed; RynthILT's, ILT only), then the tracker filling the rest.</summary>
|
||||
public void RenderTab()
|
||||
{
|
||||
// The tab is universal (/myquests); the quest bonus list (/qb) is ILT's and RynthILT's.
|
||||
_ctx.Ilt.RenderSection(RynthIltHub.SectionQuestBonus);
|
||||
RenderQuestTracker();
|
||||
}
|
||||
|
||||
/// <summary>Compact always-on list of starred quests and when each is ready.</summary>
|
||||
private void RenderFavoritesHud(QuestsTabState 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(MiniRemoteText.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(MiniRemoteTabs.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();
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ using System.Linq;
|
|||
using ImGuiNET;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
|
||||
|
|
@ -338,10 +339,10 @@ internal sealed class VTankUsdImporter
|
|||
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);
|
||||
foreach (var m in plan.Monsters.Take(50)) SafeImGui.BulletText($"Monster {m.Name} [{m.DamageType}] pri {m.Priority}");
|
||||
foreach (var w in plan.Weapons) SafeImGui.BulletText($"Weapon {w.Name} [{w.Element}]");
|
||||
foreach (var c in plan.Consumables) SafeImGui.BulletText($"{c.Type}: {c.Name}");
|
||||
foreach (var n in plan.Notes.Take(30)) SafeImGui.TextColored(LegacyDashboardRenderer.ColAmber, n);
|
||||
ImGui.TreePop();
|
||||
}
|
||||
if (ImGui.Button("Apply import..."))
|
||||
|
|
@ -349,6 +350,6 @@ internal sealed class VTankUsdImporter
|
|||
$"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);
|
||||
if (_status.Length > 0) SafeImGui.TextWrapped(_status);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ using System.Numerics;
|
|||
using ImGuiNET;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.PluginSdk;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
|
|
@ -245,11 +246,11 @@ internal sealed class NavOverlayRenderer
|
|||
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}]");
|
||||
SafeImGui.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}");
|
||||
SafeImGui.TextColored(new Vector4(1f, 0.3f, 0.3f, 1f), $"REC +{_trail.RecordedCount}");
|
||||
}
|
||||
|
||||
int idx = _settings.ActiveNavIndex;
|
||||
|
|
@ -258,21 +259,21 @@ internal sealed class NavOverlayRenderer
|
|||
var p = pts[idx];
|
||||
bool travel = p.Type == NavPointType.Point;
|
||||
ImGui.BeginGroup();
|
||||
ImGui.Text($"WP {idx}/{pts.Count - 1} {TypeLabel(p)}");
|
||||
SafeImGui.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");
|
||||
SafeImGui.Text(Math.Abs(dz) >= 3 ? $"{yd:F1} yd ({(dz > 0 ? "up" : "down")} {Math.Abs(dz):F0})" : $"{yd:F1} yd");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextDisabled(p.ToString());
|
||||
SafeImGui.TextDisabled(p.ToString());
|
||||
}
|
||||
int ni = NextIndex(route, idx);
|
||||
if (ni >= 0) ImGui.TextDisabled($"Next: [{ni}] {pts[ni]}");
|
||||
if (ni >= 0) SafeImGui.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");
|
||||
if (remain > 0) SafeImGui.TextDisabled(route.RouteType == NavRouteType.Circular ? $"Loop: {remain:F0} yd" : $"Remaining: ~{remain:F0} yd");
|
||||
ImGui.EndGroup();
|
||||
|
||||
if (travel)
|
||||
|
|
@ -288,10 +289,10 @@ internal sealed class NavOverlayRenderer
|
|||
}
|
||||
|
||||
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),
|
||||
SafeImGui.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");
|
||||
SafeImGui.TextDisabled($"Trail: {_trail.Trail.Length} pts, {_trail.TrailYards:F0} yd");
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,10 +59,13 @@ public static unsafe class PluginExports
|
|||
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.
|
||||
// The loot editor's state can be a few hundred KB (LootSnobV4): don't leave it behind on a
|
||||
// reload. The sections manifest goes too.
|
||||
foreach (IntPtr p in new[] { Interlocked.Exchange(ref _lootStatePtr, IntPtr.Zero),
|
||||
Interlocked.Exchange(ref _lootRulePtr, IntPtr.Zero), Interlocked.Exchange(ref _lootVocabPtr, IntPtr.Zero) })
|
||||
Interlocked.Exchange(ref _lootRulePtr, IntPtr.Zero), Interlocked.Exchange(ref _lootVocabPtr, IntPtr.Zero),
|
||||
Interlocked.Exchange(ref _sectionsPtr, IntPtr.Zero) })
|
||||
if (p != IntPtr.Zero) Marshal.FreeCoTaskMem(p);
|
||||
_sectionsJson = null;
|
||||
}
|
||||
catch (Exception ex) { LogShutdownError(plugin, "loot buffers", ex); }
|
||||
}
|
||||
|
|
@ -124,6 +127,10 @@ public static unsafe class PluginExports
|
|||
/// 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*).
|
||||
/// RynthCore 2026.10.5.46+ (Mini Remote sections): "miniremote-remote" (the remote without its
|
||||
/// tab bar, the engine's section rail replaces it), "miniremote-host" (the engine's Mini Remote
|
||||
/// is open on another section; draws nothing) and "section:<name>" (the views
|
||||
/// RynthPluginGetSectionsJson lists).
|
||||
/// 1 = drawn, 0 = not ready / unknown (nothing drawn).
|
||||
/// </summary>
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginRenderEmbed", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
|
|
@ -136,9 +143,26 @@ public static unsafe class PluginExports
|
|||
if (name.EndsWith(":popout"u8)) name = name[..^":popout"u8.Length];
|
||||
var plugin = Runtime.Plugin;
|
||||
if (plugin == null) return 0;
|
||||
bool window = name.SequenceEqual("miniremote-window"u8);
|
||||
if (!window && !name.SequenceEqual("miniremote"u8)) return 0;
|
||||
if (!plugin.RenderEmbeddedMiniRemote(window, out System.Numerics.Vector2 want)) return 0;
|
||||
System.Numerics.Vector2 want;
|
||||
var size = new System.Numerics.Vector2(width, height);
|
||||
if (name.SequenceEqual("miniremote-host"u8))
|
||||
{
|
||||
return plugin.MarkEngineMiniRemote() ? 1 : 0;
|
||||
}
|
||||
else if (name.StartsWith("section:"u8))
|
||||
{
|
||||
// Section names are short ASCII ids (Huds/SectionsManifest.cs); anything longer isn't ours.
|
||||
if (name.Length > 64) return 0;
|
||||
if (!plugin.RenderEmbeddedSection(System.Text.Encoding.UTF8.GetString(name), size, out want)) return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// "guardian" is RynthILT's (since 2026-10-13): not answered here.
|
||||
bool remote = name.SequenceEqual("miniremote-remote"u8);
|
||||
bool window = remote || name.SequenceEqual("miniremote-window"u8);
|
||||
if (!window && !name.SequenceEqual("miniremote"u8)) return 0;
|
||||
if (!plugin.RenderEmbeddedMiniRemote(window, out want, tabs: !remote)) return 0;
|
||||
}
|
||||
if (wantWidth != null) *wantWidth = want.X;
|
||||
if (wantHeight != null) *wantHeight = want.Y;
|
||||
return 1;
|
||||
|
|
@ -843,6 +867,29 @@ public static unsafe class PluginExports
|
|||
return newPtr;
|
||||
}
|
||||
|
||||
private static IntPtr _sectionsPtr = IntPtr.Zero;
|
||||
private static string? _sectionsJson;
|
||||
|
||||
/// <summary>
|
||||
/// RynthCore 2026.10.5.46+ (optional): what RynthAi adds to the Mini Remote's sections, as
|
||||
/// UTF-8 JSON (schema 1, Huds/SectionsManifest.cs). Null before login. The engine polls it on
|
||||
/// the render thread every couple of seconds; an unchanged manifest keeps the same buffer, a
|
||||
/// changed one frees the previous buffer (the engine copies the text before its next call).
|
||||
/// </summary>
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginGetSectionsJson", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static IntPtr GetSectionsJson()
|
||||
{
|
||||
try
|
||||
{
|
||||
string? json = Runtime.Plugin?.BuildSectionsJson();
|
||||
if (json == null) return IntPtr.Zero;
|
||||
if (json == _sectionsJson && _sectionsPtr != IntPtr.Zero) return _sectionsPtr;
|
||||
_sectionsJson = json;
|
||||
return Utf8Swap(ref _sectionsPtr, json);
|
||||
}
|
||||
catch { return IntPtr.Zero; }
|
||||
}
|
||||
|
||||
/// <summary>Changes whenever the editor's state does; 0 before RynthAi is ready.</summary>
|
||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginLootEditRevision", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static int LootEditRevision()
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public sealed partial class RynthAiPlugin
|
|||
ChatLine("[RynthAi] /ra fellow — fellowship diagnostics and queries");
|
||||
ChatLine("[RynthAi] /ra help — show this list");
|
||||
ChatLine("[RynthAi] /ra version — RynthAi version and build date, and the engine it runs on");
|
||||
ChatLine("[RynthAi] /ra server - which server RynthCore says this is, its overrides, and the server plugin's settings");
|
||||
ChatLine("[RynthAi] /ra power <0-100|auto> — set attack power (auto = recklessness-aware)");
|
||||
ChatLine("[RynthAi] /ra cast <spellId> — cast spell on current target");
|
||||
ChatLine("[RynthAi] /ra buffs — show active buff timers");
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ namespace RynthCore.Plugin.RynthAi;
|
|||
///
|
||||
/// /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 me your own ratings (also on selecting / clicking yourself)
|
||||
/// /ra iteminfo on|off describe every item you select (yourself: your ratings)
|
||||
/// /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, …)
|
||||
|
|
@ -72,6 +73,12 @@ public sealed partial class RynthAiPlugin
|
|||
|
||||
switch (sub)
|
||||
{
|
||||
case "me":
|
||||
case "self":
|
||||
case "ratings":
|
||||
QueueSelfRatings(auto: false);
|
||||
return;
|
||||
|
||||
case "settings":
|
||||
case "gui":
|
||||
case "window":
|
||||
|
|
@ -163,7 +170,7 @@ public sealed partial class RynthAiPlugin
|
|||
if (found != 0) { QueueItemInfo(unchecked((int)found), requestId: true); return; }
|
||||
ChatLine($"[RynthAi] Item info: no \"{name}\" in your inventory.");
|
||||
}
|
||||
ChatLine("[RynthAi] Usage: /ra iteminfo [<item name>|on|off|settings|fields|field <name> on|off|rating <tag> on|off|value on|off|verbose on|off|click left|right|off|layout pet|line|reset]");
|
||||
ChatLine("[RynthAi] Usage: /ra iteminfo [<item name>|me|on|off|settings|fields|field <name> on|off|rating <tag> on|off|value on|off|verbose on|off|click left|right|off|layout pet|line|reset]");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -240,6 +247,7 @@ public sealed partial class RynthAiPlugin
|
|||
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; }
|
||||
if (IsSelf(selected)) { QueueSelfRatings(auto: false); return; }
|
||||
QueueItemInfo(unchecked((int)selected), requestId: true);
|
||||
}
|
||||
|
||||
|
|
@ -351,6 +359,12 @@ public sealed partial class RynthAiPlugin
|
|||
string button = MagItemInfoCatalog.ClickTriggers[s.ClickTrigger];
|
||||
uint selected = Host.GetSelectedItemId();
|
||||
if (selected == 0) { ItemInfoLog($"{button}: nothing selected"); return; }
|
||||
if (IsSelf(selected))
|
||||
{
|
||||
ItemInfoLog($"{button}: 0x{selected:X8} (yourself): ratings queue");
|
||||
QueueSelfRatings(auto: true);
|
||||
return;
|
||||
}
|
||||
|
||||
int id = unchecked((int)selected);
|
||||
WorldObject? obj = _objectCache?[id];
|
||||
|
|
@ -368,6 +382,7 @@ public sealed partial class RynthAiPlugin
|
|||
private void TickItemInfo()
|
||||
{
|
||||
ResolveItemInfoClick();
|
||||
TickSelfRatings();
|
||||
|
||||
int id = _itemInfoPendingId;
|
||||
if (id == 0) return;
|
||||
|
|
@ -438,6 +453,14 @@ public sealed partial class RynthAiPlugin
|
|||
uint selected = Host.GetSelectedItemId();
|
||||
if (selected == 0) return null;
|
||||
int id = unchecked((int)selected);
|
||||
if (IsSelf(selected))
|
||||
{
|
||||
// Cache only: the window redraws every frame, so it never asks for an identify.
|
||||
bool known = !Host.HasHasAppraisalData || Host.HasAppraisalData(selected);
|
||||
List<string> self = ItemInfo.SelfRatings.Build(_objectCache?[id]?.Name ?? string.Empty,
|
||||
stype => ReadSelfInt(id, stype), known, oneLine: false);
|
||||
return string.Join("\n ", self);
|
||||
}
|
||||
List<string>? lines = BuildItemInfoLines(id, out string? error);
|
||||
if (lines == null || lines.Count == 0) return error;
|
||||
if (Host.HasHasAppraisalData && !Host.HasAppraisalData(selected))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
// RynthAiPlugin.EngineServers.cs - server chat commands from RynthAi's views in RynthCore's sections.
|
||||
//
|
||||
// The Fellowship view RynthCore's Fellowship section draws ("section:fellowship",
|
||||
// Huds/FellowshipSectionUi.cs) has buttons that run a chat command (a server plugin's /fship ...).
|
||||
// They are clicked on the render thread; the command is queued here and run on the plugin tick
|
||||
// through the engine's chat parser.
|
||||
//
|
||||
// The Infinite Leaftide world list and the "Treat this world as ILT" override are RynthILT's
|
||||
// (since 2026-10-13), and RynthCore adds RynthILT's verdict to its own detection, so nothing of
|
||||
// RynthAi's is copied to RynthCore (the feat/dynamic-sections copy of RynthAi's old settings was
|
||||
// dropped in the merge).
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
public sealed partial class RynthAiPlugin
|
||||
{
|
||||
/// <summary>At most this many commands wait for the tick (a stuck button can't flood chat).</summary>
|
||||
private const int MaxQueuedEngineCommands = 32;
|
||||
|
||||
private readonly ConcurrentQueue<string> _engineCommands = new();
|
||||
|
||||
/// <summary>Plugin tick: the queued chat commands, through the engine's chat parser.</summary>
|
||||
private void DrainEngineCommands()
|
||||
{
|
||||
while (_engineCommands.TryDequeue(out string? command))
|
||||
{
|
||||
if (Host.HasInvokeChatParser && Host.InvokeChatParser(command)) continue;
|
||||
Log($"[RynthAi] RynthCore didn't take: {command}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.RynthAi.LegacyUi;
|
||||
using RynthCore.Plugin.RynthAi.MiniRemote;
|
||||
using RynthCore.PluginSdk;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
|
@ -206,6 +207,7 @@ public sealed partial class RynthAiPlugin
|
|||
try { _huds?.OnLogout(); }
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "logout"); }
|
||||
_huds = null;
|
||||
Huds.ServerCommandModel.Clear();
|
||||
_itemInfoUi = null;
|
||||
_spellsUi = null;
|
||||
ResetGroundLoot(clearCaches: true);
|
||||
|
|
@ -334,7 +336,7 @@ public sealed partial class RynthAiPlugin
|
|||
/// context, see <see cref="EmbedContext"/>). False (nothing drawn) until login and the HUDs
|
||||
/// exist. Render thread.
|
||||
/// </summary>
|
||||
public bool RenderEmbeddedMiniRemote(bool window, out System.Numerics.Vector2 want)
|
||||
public bool RenderEmbeddedMiniRemote(bool window, out System.Numerics.Vector2 want, bool tabs = true)
|
||||
{
|
||||
want = default;
|
||||
var huds = _huds;
|
||||
|
|
@ -345,7 +347,7 @@ public sealed partial class RynthAiPlugin
|
|||
ImGui.SetCurrentContext(EmbedContext());
|
||||
try
|
||||
{
|
||||
want = huds.RenderEmbedded(window);
|
||||
want = huds.RenderEmbedded(window, tabs);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -359,6 +361,120 @@ public sealed partial class RynthAiPlugin
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RynthPluginRenderEmbed "miniremote-host": RynthCore's Mini Remote window is open on one of
|
||||
/// its sections, so it is still the one Mini Remote (the floating copy stays hidden). Draws
|
||||
/// nothing. Render thread.
|
||||
/// </summary>
|
||||
public bool MarkEngineMiniRemote()
|
||||
{
|
||||
var huds = _huds;
|
||||
if (!_initialized || !_loginComplete || huds == null) return false;
|
||||
huds.MarkEngineWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
private Huds.FellowshipSectionUi? _fellowshipUi;
|
||||
|
||||
/// <summary>
|
||||
/// The fellowship view RynthCore's Fellowship section draws ("section:fellowship"); the
|
||||
/// player's main fellowship window is RynthOracle's Fellowship tab. Render thread.
|
||||
/// </summary>
|
||||
private Huds.FellowshipSectionUi FellowshipUi() =>
|
||||
_fellowshipUi ??= new Huds.FellowshipSectionUi(() => _fellowshipTracker,
|
||||
() => Host.HasGetPlayerId ? Host.GetPlayerId() : 0,
|
||||
QueueServerCommand);
|
||||
|
||||
/// <summary>Render thread: queues a server chat command (a fellowship button) for the plugin tick.</summary>
|
||||
private bool QueueServerCommand(string command)
|
||||
{
|
||||
if (!Host.HasInvokeChatParser || _engineCommands.Count >= MaxQueuedEngineCommands) return false;
|
||||
_engineCommands.Enqueue(command);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RynthPluginRenderEmbed "section:<name>": one of RynthAi's views in RynthCore's Mini
|
||||
/// Remote sections (Huds/SectionsManifest.cs lists them), drawn into the engine's current
|
||||
/// window (and context, see <see cref="EmbedContext"/>) at <paramref name="size"/>.
|
||||
/// <paramref name="want"/> is the size the view would like. False (nothing drawn) for an
|
||||
/// unknown view, or until login and the view's owner exist (RynthILT for the ILT tabs). Render thread.
|
||||
/// </summary>
|
||||
public bool RenderEmbeddedSection(string surface, System.Numerics.Vector2 size, out System.Numerics.Vector2 want)
|
||||
{
|
||||
want = size;
|
||||
var huds = _huds;
|
||||
var remote = _miniRemote;
|
||||
if (!_initialized || !_loginComplete || Host.ImGuiContext == IntPtr.Zero) return false;
|
||||
|
||||
Func<bool>? draw = null;
|
||||
if (surface == Huds.SectionsManifest.SessionSurface)
|
||||
{
|
||||
// The one session (RynthCore's Session Stats section).
|
||||
if (huds == null) return false;
|
||||
draw = () => { huds.RenderSessionSection(); return true; };
|
||||
}
|
||||
else if (surface == Huds.SectionsManifest.FellowshipSurface)
|
||||
{
|
||||
// RynthILT's own pane carries ILT's /fship commands in RynthCore's section.
|
||||
draw = () => { FellowshipUi().Render(withServerCommands: false); return true; };
|
||||
}
|
||||
else if (Huds.SectionsManifest.TryOwnTabOf(surface, out string ownTab))
|
||||
{
|
||||
if (remote == null) return false;
|
||||
want = MiniRemoteTabs.Size(ownTab);
|
||||
draw = () => remote.RenderTab(ownTab);
|
||||
}
|
||||
else if (Huds.SectionsManifest.TryIltTabOf(surface, out string iltTab))
|
||||
{
|
||||
if (remote == null || !remote.Ilt.Loaded) return false;
|
||||
foreach (IltTabInfo t in remote.Ilt.Tabs())
|
||||
if (string.Equals(t.Id, iltTab, StringComparison.OrdinalIgnoreCase) && t.Width > 0 && t.Height > 0)
|
||||
want = new System.Numerics.Vector2(t.Width, t.Height);
|
||||
draw = () => remote.Ilt.RenderTab(iltTab);
|
||||
}
|
||||
else if (surface == Huds.SectionsManifest.SpellsSurface)
|
||||
{
|
||||
EnsureSpellsUi();
|
||||
var spells = _spellsUi;
|
||||
if (spells == null) return false;
|
||||
draw = () => { spells.RenderEmbedded(); return true; };
|
||||
}
|
||||
if (draw == null) return false;
|
||||
|
||||
// The engine's Mini Remote window shows this section: it is still the one Mini Remote.
|
||||
huds?.MarkEngineWindow();
|
||||
IntPtr previousContext = ImGui.GetCurrentContext();
|
||||
ImGui.SetCurrentContext(EmbedContext());
|
||||
int pushedColors = LegacyDashboardRenderer.PushDashboardStyle();
|
||||
try
|
||||
{
|
||||
return draw();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RynthLog.Exception(LogCat.UI, ex, "RenderEmbeddedSection " + surface);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGui.PopStyleColor(pushedColors);
|
||||
ImGui.SetCurrentContext(previousContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RynthPluginGetSectionsJson: what RynthAi adds to RynthCore's Mini Remote sections, from
|
||||
/// what is available now (Huds/SectionsManifest.cs; RynthILT's tabs through RynthILT.Hub).
|
||||
/// Null before login (RynthCore then shows none of RynthAi's views). Render thread.
|
||||
/// </summary>
|
||||
public string? BuildSectionsJson()
|
||||
{
|
||||
if (!_initialized || !_loginComplete) return null;
|
||||
var remote = _miniRemote;
|
||||
IReadOnlyList<IltTabInfo> iltTabs = remote != null ? remote.Ilt.Tabs() : Array.Empty<IltTabInfo>();
|
||||
return Huds.SectionsManifest.Build(Huds.SectionsManifest.Views(iltTabs), Huds.SectionsManifest.OwnSections);
|
||||
}
|
||||
/// <summary>Chat Translate window in the dashboard colours (no-op while hidden).</summary>
|
||||
private void RenderTranslateWindow()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -395,6 +395,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
private void TeardownSession()
|
||||
{
|
||||
ObjectChangeTracker.Clear();
|
||||
while (_engineCommands.TryDequeue(out _)) { } // a fellowship button's command is for this character only
|
||||
// The server drops whatever it was doing for this character at logout.
|
||||
RynthCore.Plugin.Shared.ActionPacer.Forget("logout");
|
||||
_navigationEngine?.Stop();
|
||||
|
|
@ -689,6 +690,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
_combatManager.SetWeaponSwapGate(_weaponSwapGate);
|
||||
_combatManager.Vitals = _vitals; // the script hook's request carries the player's vitals
|
||||
_combatManager.HoldIdlePeace = LootHoldsIdlePeace;
|
||||
_combatManager.HoldNewTarget = BoostLootHoldsNewTarget; // Boost Loot Priority: one kill, one loot
|
||||
_combatManager.ManaReserveHold = spellId => _buffManager?.OffensiveCastHold(spellId); // the mana reserve
|
||||
_combatManager.ManaCanEverAfford = spellId => _buffManager?.CanEverAfford(spellId) ?? true; // script hook: never-payable spells
|
||||
_combatManager.SetStaleBusyCallback(OnCombatBusyStale);
|
||||
|
|
@ -904,6 +906,12 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
Huds.ServerMenuModel.Apply(value);
|
||||
return;
|
||||
}
|
||||
// A server plugin's commands for one of RynthAi's section views (RynthILT's /fship for Fellowship).
|
||||
if (action.Equals(ServerCommandShare.Action, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Huds.ServerCommandModel.Apply(value);
|
||||
return;
|
||||
}
|
||||
var dash = _dashboard;
|
||||
if (dash == null) return;
|
||||
bool on = value is "1" or "true" or "on" or "True" or "TRUE"
|
||||
|
|
@ -949,7 +957,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
case "itemhud":
|
||||
case "remote":
|
||||
case "miniremote":
|
||||
// Dashboard Hub launcher: left-click remote=toggle, right-click huds=show.
|
||||
// RynthCore's Mini Remote commands ("remote","toggle"; "huds","show").
|
||||
HandleHudCommand(action.ToLowerInvariant(), value);
|
||||
break;
|
||||
case "itemhudadd":
|
||||
|
|
@ -1010,6 +1018,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
["HealOthersAt"] = (0, 100), ["RestamOthersAt"] = (0, 100), ["InfuseOthersAt"] = (0, 100),
|
||||
["MeleeAttackPower"] = (-1, 100), ["MissileAttackPower"] = (-1, 100),
|
||||
["MeleeAttackHeight"] = (0, 2), ["MissileAttackHeight"] = (0, 2),
|
||||
["WeaponSwapSettleMs"] = (0, 3000), ["WeaponSwapMinHealthPct"] = (0, 100), ["WeaponSwapMinGainPct"] = (0, 200),
|
||||
["PetMinMonsters"] = (1, 20),
|
||||
["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),
|
||||
|
|
@ -1379,6 +1388,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
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
|
||||
DrainEngineCommands(); // fellowship command buttons (RynthCore's Fellowship section)
|
||||
TickPropertyDump(); // /ub propertydump: waits for the ID, chat in chunks
|
||||
if (_loginComplete) _dashboard?.TickPackSetup(_objectCache, _playerId); // new/copied profile items
|
||||
|
||||
|
|
@ -2180,6 +2190,18 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
// unguarded appraisal + health query here sent 4-6 identifies per corpse.
|
||||
RequestTargetVitals(currentTargetId, obj);
|
||||
|
||||
// Yourself: with Item Info on select, your ratings (RynthAiSelfRatings).
|
||||
if (IsSelf(currentTargetId))
|
||||
{
|
||||
var selfInfo = _dashboard?.Settings.ItemInfoSettings;
|
||||
if (selfInfo != null && selfInfo.OnSelect && !ItemInfo.SelfSelect.IsOurs(currentTargetId))
|
||||
{
|
||||
ItemInfoLog($"select 0x{currentTargetId:X8} (yourself): ratings queue");
|
||||
QueueSelfRatings(auto: true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip non-items (monsters, players, NPCs, doors, corpses, portals, etc.)
|
||||
if (obj != null && IsLootableClass(obj.ObjectClass))
|
||||
{
|
||||
|
|
@ -2278,7 +2300,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
_petManager?.OnChatWindowText(text);
|
||||
_combatManager?.TraceCastChat(text, chatType);
|
||||
_combatManager?.HandleChatForDebuffs(text);
|
||||
_combatManager?.HandleChatForDamage(text);
|
||||
_combatManager?.HandleChatForDamage(text, chatType);
|
||||
_missileCraftingManager?.HandleChat(text);
|
||||
_scrollLearner?.OnChat(text);
|
||||
_metaManager?.HandleChat(text, chatType);
|
||||
|
|
@ -2301,6 +2323,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "session stats kill"); }
|
||||
if (string.IsNullOrEmpty(deathMessage)) return;
|
||||
_killClock.RecordKill(); // the only kill source: KillerNotification goes to the killer alone
|
||||
NoteBoostLootKill(); // before combat sees the kill: its next target waits for the corpse
|
||||
_combatManager?.OnKillNotification(deathMessage);
|
||||
_dashboard?.RecordKill(); // feeds the kills/hour session stat
|
||||
}
|
||||
|
|
@ -3481,6 +3504,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase
|
|||
case "listgvars": HandleListGvarsCommand(); break;
|
||||
case "dumpprops": HandleDumpPropsCommand(parts); break;
|
||||
case "version": HandleVersionCommand(); break;
|
||||
case "server": HandleServerCommand(); break;
|
||||
case "t11": HandleT11Command(parts); break;
|
||||
case "wielded": HandleWieldedCommand(); break;
|
||||
case "scan": HandleScanCommand(); break;
|
||||
|
|
|
|||
111
Plugins/RynthCore.Plugin.RynthAi/RynthAiSelfRatings.cs
Normal file
111
Plugins/RynthCore.Plugin.RynthAi/RynthAiSelfRatings.cs
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Plugin.RynthAi.ItemInfo;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
/// <summary>
|
||||
/// Item Info on yourself: with "Describe items when selected" (or the click trigger) on, selecting
|
||||
/// your own character prints your ratings (SelfRatings) instead of skipping you as a non-item.
|
||||
/// "/ra iteminfo me" prints them on demand. Client-side only: it identifies the player, whose
|
||||
/// identify reply carries the server's resolved rating totals, and reads them from the property
|
||||
/// cache. Partial class of RynthAiPlugin.
|
||||
/// </summary>
|
||||
public sealed partial class RynthAiPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Wait at least this long after asking for the self-identify. There is no "identify arrived"
|
||||
/// event and the player may already have an older identify cached, so printing at once could
|
||||
/// show stale totals; one round trip is well under this.
|
||||
/// </summary>
|
||||
private const long SelfRatingsSettleMs = 700;
|
||||
|
||||
/// <summary>TickCount64 of the pending self-identify; 0 = nothing pending (tick thread).</summary>
|
||||
private long _selfRatingsRequestedAt;
|
||||
|
||||
/// <summary>The player's object id, or 0 before login / on a host without it.</summary>
|
||||
private uint SelfId() => Host.HasGetPlayerId ? Host.GetPlayerId() : 0;
|
||||
|
||||
/// <summary>True when <paramref name="id"/> is this character.</summary>
|
||||
private bool IsSelf(uint id) => id != 0 && id == SelfId();
|
||||
|
||||
/// <summary>
|
||||
/// Asks the server to identify the player and prints the ratings from <see cref="TickSelfRatings"/>.
|
||||
/// <paramref name="auto"/> (select / click triggers) shares Item Info's de-duplication, so one
|
||||
/// click that raises both triggers prints once.
|
||||
/// </summary>
|
||||
internal void QueueSelfRatings(bool auto)
|
||||
{
|
||||
uint me = SelfId();
|
||||
if (me == 0)
|
||||
{
|
||||
if (!auto) ChatLine("[RynthAi] Ratings: not logged in yet.");
|
||||
return;
|
||||
}
|
||||
int sid = unchecked((int)me);
|
||||
long now = Environment.TickCount64;
|
||||
if (auto)
|
||||
{
|
||||
if (sid == _itemInfoLastAutoId && now - _itemInfoLastAutoAt < AutoDedupeMs)
|
||||
{
|
||||
ItemInfoLog("self: already queued by the other trigger");
|
||||
return;
|
||||
}
|
||||
_itemInfoLastAutoId = sid;
|
||||
_itemInfoLastAutoAt = now;
|
||||
}
|
||||
|
||||
if (!Host.HasRequestId)
|
||||
{
|
||||
// Nothing to ask with: print what the cache has (the lum augs at least).
|
||||
PrintSelfRatings(me, identified: Host.HasHasAppraisalData && Host.HasAppraisalData(me));
|
||||
return;
|
||||
}
|
||||
Host.RequestId(me);
|
||||
_selfRatingsRequestedAt = now;
|
||||
ItemInfoLog($"self 0x{me:X8}: identify requested for the ratings");
|
||||
}
|
||||
|
||||
/// <summary>Plugin-tick half: prints once the identify is in (after the settle time) or timed out.</summary>
|
||||
private void TickSelfRatings()
|
||||
{
|
||||
long at = _selfRatingsRequestedAt;
|
||||
if (at == 0) return;
|
||||
long since = Environment.TickCount64 - at;
|
||||
if (since < SelfRatingsSettleMs) return;
|
||||
|
||||
uint me = SelfId();
|
||||
if (me == 0) { _selfRatingsRequestedAt = 0; return; }
|
||||
bool ready = !Host.HasHasAppraisalData || Host.HasAppraisalData(me);
|
||||
long timeoutMs = (long)((ItemInfoSettings?.IdTimeoutSec ?? 3f) * 1000f);
|
||||
if (!ready && since < timeoutMs) return;
|
||||
|
||||
_selfRatingsRequestedAt = 0;
|
||||
PrintSelfRatings(me, ready);
|
||||
}
|
||||
|
||||
/// <summary>Writes the ratings in Item Info's prefix, layout and chat colours.</summary>
|
||||
private void PrintSelfRatings(uint me, bool identified)
|
||||
{
|
||||
int id = unchecked((int)me);
|
||||
var s = ItemInfoSettings;
|
||||
bool oneLine = (s?.Layout ?? MagItemInfoSettings.LayoutPetLines) == MagItemInfoSettings.LayoutOneLine;
|
||||
string name = _objectCache?[id]?.Name ?? string.Empty;
|
||||
List<string> lines = SelfRatings.Build(name, stype => ReadSelfInt(id, stype), identified, oneLine);
|
||||
ItemInfoLog($"self 0x{me:X8}: printed {lines.Count} line(s), identified={identified}: {lines[0]}");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>One of the player's int properties from the cache (PlayerDescription, else the last identify); 0 when absent.</summary>
|
||||
private int ReadSelfInt(int id, uint stype)
|
||||
{
|
||||
if (_objectCache != null) return _objectCache.GetIntProperty(id, stype, 0);
|
||||
return Host.HasGetObjectIntProperty && Host.TryGetObjectIntProperty(unchecked((uint)id), stype, out int v) ? v : 0;
|
||||
}
|
||||
}
|
||||
52
Plugins/RynthCore.Plugin.RynthAi/RynthAiServerCommand.cs
Normal file
52
Plugins/RynthCore.Plugin.RynthAi/RynthAiServerCommand.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi;
|
||||
|
||||
public sealed partial class RynthAiPlugin
|
||||
{
|
||||
/// <summary>RynthCore's server list and the active server owner's profile, read on demand for /ra server.</summary>
|
||||
private readonly ServerStateClient _serverState = new();
|
||||
|
||||
/// <summary>
|
||||
/// /ra server: which server RynthCore says this is and why, every server it knows with this
|
||||
/// character's override, the plugin that owns the active server and what its settings say,
|
||||
/// and whether the Mini Remote's ILT tabs (RynthILT.Hub) are connected. One check that every
|
||||
/// plugin is reading the same server identity. Plain ASCII (the AC chat can't draw more).
|
||||
/// </summary>
|
||||
private void HandleServerCommand()
|
||||
{
|
||||
_serverState.Poll(Host, Environment.TickCount64, force: true);
|
||||
EngineServerState? st = _serverState.State;
|
||||
string world = Host.HasGetWorldName && Host.TryGetWorldName(out string w) ? w.Trim() : "";
|
||||
if (st == null)
|
||||
{
|
||||
ChatLine(_serverState.Supported
|
||||
? "[RynthAi] Server: RynthCore didn't answer GetServerStateJson."
|
||||
: $"[RynthAi] Server: this engine (plugin API v{Host.Version}) doesn't report its server list (v86 does). World name: '{world}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
ChatLine(st.HasActive
|
||||
? $"[RynthAi] Server: {st.ActiveName} ({st.Active}), {(st.Picked ? "picked by hand" : "detected or per-server override")}; settings from {(st.ActivePlugin.Length > 0 ? st.ActivePlugin : "no loaded plugin")}."
|
||||
: $"[RynthAi] Server: none active (retail features only){(st.Picked ? ", picked by hand" : "")}.");
|
||||
ChatLine($"[RynthAi] Host '{st.Host}', announced world '{st.World}', client world name '{world}', pick '{st.Pick}'.");
|
||||
foreach (EngineServer s in st.Servers)
|
||||
{
|
||||
string flags = (s.Active ? "ACTIVE" : "off") + (s.Detected ? ", detected" : "") + (s.Force != "auto" ? ", forced " + s.Force : "");
|
||||
ChatLine($"[RynthAi] {s.Id} ({s.Name}): {flags}; owner {(s.Plugin.Length > 0 ? s.Plugin : "-")}{(s.Reason.Length > 0 ? "; " + s.Reason : "")}");
|
||||
}
|
||||
|
||||
if (st.ActivePlugin.Length > 0)
|
||||
{
|
||||
ServerProfileView? p = ServerProfileView.Parse(_serverState.ProfileJson);
|
||||
ChatLine(p != null
|
||||
? $"[RynthAi] {_serverState.ProfilePlugin} {RynthServerProfileApiV1.InterfaceName}: {p.Summary()}"
|
||||
: $"[RynthAi] {st.ActivePlugin} sent no server settings ({RynthServerProfileApiV1.InterfaceName} not answered - an older plugin?).");
|
||||
}
|
||||
|
||||
bool iltTabs = _ilt != null && _ilt.Loaded;
|
||||
ChatLine($"[RynthAi] Mini Remote ILT tabs (RynthILT.Hub): {(iltTabs ? "connected" + (_ilt!.IsIltWorld ? ", ILT world" : ", not an ILT world") : "not connected")}.");
|
||||
ChatLine("[RynthAi] Change the server: RynthCore Options > Diagnostics > Server, or /rc server pick <id>|auto.");
|
||||
}
|
||||
}
|
||||
|
|
@ -53,6 +53,11 @@
|
|||
<Compile Include="..\Shared\ActionPacer.cs" Link="Shared\ActionPacer.cs" />
|
||||
<!-- Text in the world on the Nav3D buffer (waypoint labels; RynthNav's path markers use it too). -->
|
||||
<Compile Include="..\Shared\Nav3DText.cs" Link="Shared\Nav3DText.cs" />
|
||||
<!-- Server signal vs a player's copy of it (chat type + line-start anchor). -->
|
||||
<Compile Include="..\Shared\ChatSource.cs" Link="Shared\ChatSource.cs" />
|
||||
<!-- Server commands a server plugin sends for a section (RynthILT's /fship for Fellowship), and their buttons. -->
|
||||
<Compile Include="..\Shared\ServerCommandShare.cs" Link="Shared\ServerCommandShare.cs" />
|
||||
<Compile Include="..\Shared\ServerCommandPanel.cs" Link="Shared\ServerCommandPanel.cs" />
|
||||
<!-- Mini Remote session stats: RynthTracker's code, so the two show the same numbers (2026-10-11). -->
|
||||
<Compile Include="..\Shared\KillCounter.cs" Link="Shared\KillCounter.cs" />
|
||||
<Compile Include="..\Shared\TrackerSessionStore.cs" Link="Shared\TrackerSessionStore.cs" />
|
||||
|
|
@ -60,11 +65,18 @@
|
|||
<Compile Include="..\Shared\SessionStatsTracker.cs" Link="Shared\SessionStatsTracker.cs" />
|
||||
<!-- ImGui.NET bound to the engine's cimgui (RynthILT links the same file). -->
|
||||
<Compile Include="..\Shared\ImGuiNativeBinding.cs" Link="Shared\ImGuiNativeBinding.cs" />
|
||||
<!-- ImGui text calls for non-literal text ('%' escaped; RynthILT links the same file). -->
|
||||
<Compile Include="..\Shared\SafeImGui.cs" Link="Shared\SafeImGui.cs" />
|
||||
<!-- Infinite Leaftide: RynthILT.Hub (its tabs in the Mini Remote) and RynthAi.Hub (what RynthILT borrows). -->
|
||||
<Compile Include="..\Shared\RynthIltHubApi.cs" Link="Shared\RynthIltHubApi.cs" />
|
||||
<Compile Include="..\Shared\RynthAiHubApi.cs" Link="Shared\RynthAiHubApi.cs" />
|
||||
<!-- Save failures said in chat with the reason and the fix (2026-10-13; RynthILT links it too). -->
|
||||
<Compile Include="..\Shared\DataWriteGuard.cs" Link="Shared\DataWriteGuard.cs" />
|
||||
<!-- The active server (plugin API v86 GetServerStateJson) and its owner's "RynthServer.Profile"
|
||||
JSON: the Mini Remote's Crafting tab shows the server's own salvage from it. -->
|
||||
<Compile Include="..\Shared\EngineServerState.cs" Link="Shared\EngineServerState.cs" />
|
||||
<Compile Include="..\Shared\ServerStateClient.cs" Link="Shared\ServerStateClient.cs" />
|
||||
<Compile Include="..\Shared\RynthServerProfileApi.cs" Link="Shared\RynthServerProfileApi.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Providers that use other codes (DeepL upper-case, LibreTranslate "zh") are mapped in TranslateClient.
|
||||
using System;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Translate;
|
||||
|
||||
|
|
@ -86,7 +87,7 @@ internal static class TranslateLanguages
|
|||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
if (ImGui.IsItemHovered() && current > 0) ImGui.SetTooltip(Names[current]);
|
||||
if (ImGui.IsItemHovered() && current > 0) SafeImGui.SetTooltip(Names[current]);
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
using System;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthAi.Translate;
|
||||
|
||||
|
|
@ -71,15 +72,15 @@ internal sealed class TranslateUi
|
|||
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"
|
||||
SafeImGui.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");
|
||||
SafeImGui.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);
|
||||
SafeImGui.TextColored(ColError, "Last error: " + _tr.LastError);
|
||||
}
|
||||
|
||||
/// <summary>Receive / swap / send / reset-to-default row (window and Advanced page).</summary>
|
||||
|
|
@ -100,14 +101,14 @@ internal sealed class TranslateUi
|
|||
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)}");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.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}).");
|
||||
SafeImGui.SetTooltip($"Reset the send language to the default ({s.DefaultSendLanguage}).");
|
||||
}
|
||||
|
||||
private void RenderLog()
|
||||
|
|
@ -115,7 +116,7 @@ internal sealed class TranslateUi
|
|||
var log = _tr.LogSnapshot();
|
||||
if (ImGui.SmallButton("Clear")) _tr.ClearLog();
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(ColDim, $"{log.Length} entries (hover a line for the original)");
|
||||
SafeImGui.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)
|
||||
|
|
@ -126,18 +127,18 @@ internal sealed class TranslateUi
|
|||
TranslateDirection.Out => ("OUT", ColOut),
|
||||
_ => ("TST", ColTest),
|
||||
};
|
||||
ImGui.TextColored(ColDim, e.Time.ToString("HH:mm:ss"));
|
||||
SafeImGui.TextColored(ColDim, e.Time.ToString("HH:mm:ss"));
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(e.Error.Length > 0 && e.Translated.Length == 0 ? ColError : col, tag);
|
||||
SafeImGui.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}");
|
||||
SafeImGui.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)}");
|
||||
SafeImGui.SetTooltip($"Original: {e.Original}{langs}{(e.Error.Length > 0 ? "\n" + e.Error : string.Empty)}");
|
||||
}
|
||||
}
|
||||
// Follow new lines unless the user scrolled up.
|
||||
|
|
@ -150,7 +151,7 @@ internal sealed class TranslateUi
|
|||
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.");
|
||||
SafeImGui.TextWrapped($"Type in any language; it is translated into {TranslateLanguages.Label(s.CurrentSendLanguage)} and sent on the chosen channel.");
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.SetNextItemWidth(140f);
|
||||
|
|
@ -251,7 +252,7 @@ internal sealed class TranslateUi
|
|||
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));
|
||||
SafeImGui.TextColored(ColDim, ProviderHint(s.Provider));
|
||||
|
||||
var keyFlags = _showKey ? ImGuiInputTextFlags.None : ImGuiInputTextFlags.Password;
|
||||
ImGui.SetNextItemWidth(300f);
|
||||
|
|
@ -322,26 +323,26 @@ internal sealed class TranslateUi
|
|||
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));
|
||||
if (ImGui.IsItemHovered()) SafeImGui.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)}");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.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)}");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.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}).");
|
||||
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip($"Reset the send language to the default ({s.DefaultSendLanguage}).");
|
||||
}
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- RynthColdeve: the Coldeve server plugin. The build is shared (..\Shared\ServerPack\ServerPlugin.props);
|
||||
ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthColdeve</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<RynthPluginServerId>coldeve</RynthPluginServerId>
|
||||
<RynthPluginServerName>Coldeve</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>play.coldeve.ac</RynthPluginServerHosts>
|
||||
<RynthPluginServerWorldNames>Coldeve</RynthPluginServerWorldNames>
|
||||
<RynthPluginDescription>Coldeve only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||
|
||||
</Project>
|
||||
18
Plugins/RynthCore.Plugin.RynthColdeve/ServerData.cs
Normal file
18
Plugins/RynthCore.Plugin.RynthColdeve/ServerData.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// ServerData.cs - What is known about Coldeve (RynthColdeve). Identity (id, hosts, world names) is in the csproj.
|
||||
namespace RynthCore.Plugin.ServerPack;
|
||||
|
||||
internal static class ServerData
|
||||
{
|
||||
public static ServerPackInfo Create() =>
|
||||
new(RynthPluginInfo.ServerId, RynthPluginInfo.ServerName, RynthPluginInfo.ServerHosts, RynthPluginInfo.ServerWorldNames)
|
||||
{
|
||||
Port = 9000,
|
||||
Emulator = "ACE",
|
||||
Ruleset = "PvE",
|
||||
Status = "Stable",
|
||||
Summary = "A PVE AC Server evolving to provide a end of retail experience running ACEmulator.",
|
||||
Facts = new[] { "End-of-retail experience on ACEmulator." },
|
||||
Discord = "https://discord.gg/nUR4PHe",
|
||||
Source = "public AC server list (acresources/serverslist), checked 2026-10-13",
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- RynthConquest: the Conquest (ConquestAC) server plugin. The build is shared
|
||||
(..\Shared\ServerPack\ServerPlugin.props); ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthConquest</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<RynthPluginServerId>conquest</RynthPluginServerId>
|
||||
<RynthPluginServerName>Conquest</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>acconquest.ddns.net</RynthPluginServerHosts>
|
||||
<RynthPluginServerWorldNames>Conquest|ConquestAC</RynthPluginServerWorldNames>
|
||||
<RynthPluginDescription>Conquest only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||
|
||||
</Project>
|
||||
24
Plugins/RynthCore.Plugin.RynthConquest/ServerData.cs
Normal file
24
Plugins/RynthCore.Plugin.RynthConquest/ServerData.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// ServerData.cs - What is known about Conquest (RynthConquest). Identity (id, hosts, world names) is in the csproj.
|
||||
namespace RynthCore.Plugin.ServerPack;
|
||||
|
||||
internal static class ServerData
|
||||
{
|
||||
public static ServerPackInfo Create() =>
|
||||
new(RynthPluginInfo.ServerId, RynthPluginInfo.ServerName, RynthPluginInfo.ServerHosts, RynthPluginInfo.ServerWorldNames)
|
||||
{
|
||||
Port = 9000,
|
||||
Emulator = "ACE",
|
||||
Ruleset = "PvE",
|
||||
Status = "Development",
|
||||
Summary = "Custom PvE server with live events, deep crafting, active development, and PK system.",
|
||||
Facts = new[]
|
||||
{
|
||||
"Live events and deep crafting.",
|
||||
"Has a PK system on a PvE server.",
|
||||
"RynthOracle has a Conquest quest pack (quests.conquest.csv).",
|
||||
},
|
||||
Discord = "https://discord.gg/Gsadhhv72S",
|
||||
Website = "https://dsc.gg/conquerac",
|
||||
Source = "public AC server list (acresources/serverslist), checked 2026-10-13",
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- RynthDerptide: the Derptide server plugin. The build is shared (..\Shared\ServerPack\ServerPlugin.props);
|
||||
ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthDerptide</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<RynthPluginServerId>derptide</RynthPluginServerId>
|
||||
<RynthPluginServerName>Derptide</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>ac.derptide.net</RynthPluginServerHosts>
|
||||
<RynthPluginServerWorldNames>Derptide</RynthPluginServerWorldNames>
|
||||
<RynthPluginDescription>Derptide only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||
|
||||
</Project>
|
||||
25
Plugins/RynthCore.Plugin.RynthDerptide/ServerData.cs
Normal file
25
Plugins/RynthCore.Plugin.RynthDerptide/ServerData.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// ServerData.cs - What is known about Derptide (RynthDerptide). Identity (id, hosts, world names) is in the csproj.
|
||||
namespace RynthCore.Plugin.ServerPack;
|
||||
|
||||
internal static class ServerData
|
||||
{
|
||||
public static ServerPackInfo Create() =>
|
||||
new(RynthPluginInfo.ServerId, RynthPluginInfo.ServerName, RynthPluginInfo.ServerHosts, RynthPluginInfo.ServerWorldNames)
|
||||
{
|
||||
Port = 9000,
|
||||
Emulator = "ACE",
|
||||
Ruleset = "PvE",
|
||||
Status = "Stable",
|
||||
Summary = "EOR server that pushes custom content and Qol changes, All quest weapons have been upgraded to be useful, " +
|
||||
"and usable. No quest item will EVER be better than lootgen, Live events, Ongoing story arcs. and TONS of tailoring options.",
|
||||
Facts = new[]
|
||||
{
|
||||
"Quest weapons are upgraded to be useful, but never better than loot-generated items.",
|
||||
"Live events and ongoing story arcs.",
|
||||
"Many tailoring options.",
|
||||
},
|
||||
Discord = "https://discord.gg/3gDTBVtfAg",
|
||||
Website = "https://derptide.net",
|
||||
Source = "public AC server list (acresources/serverslist), checked 2026-10-13",
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- RynthDreamWeave: the DreamWeave server plugin. The build is shared (..\Shared\ServerPack\ServerPlugin.props);
|
||||
ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthDreamWeave</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<RynthPluginServerId>dreamweave</RynthPluginServerId>
|
||||
<RynthPluginServerName>DreamWeave</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>play.acdreamweave.com</RynthPluginServerHosts>
|
||||
<RynthPluginServerWorldNames>DreamWeave|Dream Weave</RynthPluginServerWorldNames>
|
||||
<RynthPluginDescription>DreamWeave only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||
|
||||
</Project>
|
||||
25
Plugins/RynthCore.Plugin.RynthDreamWeave/ServerData.cs
Normal file
25
Plugins/RynthCore.Plugin.RynthDreamWeave/ServerData.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// ServerData.cs - What is known about DreamWeave (RynthDreamWeave). Identity (id, hosts, world names) is in the csproj.
|
||||
namespace RynthCore.Plugin.ServerPack;
|
||||
|
||||
internal static class ServerData
|
||||
{
|
||||
public static ServerPackInfo Create() =>
|
||||
new(RynthPluginInfo.ServerId, RynthPluginInfo.ServerName, RynthPluginInfo.ServerHosts, RynthPluginInfo.ServerWorldNames)
|
||||
{
|
||||
Port = 9000,
|
||||
Emulator = "ACE",
|
||||
Ruleset = "PvE",
|
||||
Status = "Development",
|
||||
Summary = "PvE server pushing unmodified end-of-retail ToD to the limit. Lore driven, new class abilities, " +
|
||||
"new crafting system, tons of QOL, up-to-date wiki.",
|
||||
Facts = new[]
|
||||
{
|
||||
"Lore driven, built on end-of-retail Throne of Destiny.",
|
||||
"New class abilities and a new crafting system.",
|
||||
"Its wiki is kept up to date.",
|
||||
},
|
||||
Discord = "https://discord.gg/p2h3yca4BD",
|
||||
Wiki = "https://wiki.acdreamweave.com",
|
||||
Source = "public AC server list (acresources/serverslist), checked 2026-10-13",
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- RynthEversong: the Eversong server plugin. The build is shared (..\Shared\ServerPack\ServerPlugin.props);
|
||||
ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthEversong</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<RynthPluginServerId>eversong</RynthPluginServerId>
|
||||
<RynthPluginServerName>Eversong</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>eversong.abrdns.com</RynthPluginServerHosts>
|
||||
<RynthPluginServerWorldNames>Eversong</RynthPluginServerWorldNames>
|
||||
<RynthPluginDescription>Eversong only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||
|
||||
</Project>
|
||||
24
Plugins/RynthCore.Plugin.RynthEversong/ServerData.cs
Normal file
24
Plugins/RynthCore.Plugin.RynthEversong/ServerData.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// ServerData.cs - What is known about Eversong (RynthEversong). Identity (id, hosts, world names) is in the csproj.
|
||||
namespace RynthCore.Plugin.ServerPack;
|
||||
|
||||
internal static class ServerData
|
||||
{
|
||||
public static ServerPackInfo Create() =>
|
||||
new(RynthPluginInfo.ServerId, RynthPluginInfo.ServerName, RynthPluginInfo.ServerHosts, RynthPluginInfo.ServerWorldNames)
|
||||
{
|
||||
Port = 9000,
|
||||
Emulator = "ACE",
|
||||
Ruleset = "PvE",
|
||||
Status = "Stable",
|
||||
Summary = "Five difficulty worlds, quest bonuses, enlightenment & milestones, banking & lockboxes, invasions, optional classes.",
|
||||
Facts = new[]
|
||||
{
|
||||
"Five difficulty worlds.",
|
||||
"Quest bonuses, enlightenment and milestones.",
|
||||
"Banking and lockboxes.",
|
||||
"Invasions and optional classes.",
|
||||
},
|
||||
Discord = "https://discord.gg/9eHxTb7p2J",
|
||||
Source = "public AC server list (acresources/serverslist), checked 2026-10-13",
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- RynthFrostACE: the FrostACE server plugin (listed as "FrostfACE" in the public server list). The build
|
||||
is shared (..\Shared\ServerPack\ServerPlugin.props); ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthFrostACE</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<RynthPluginServerId>frostace</RynthPluginServerId>
|
||||
<RynthPluginServerName>FrostACE</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>172.111.230.127</RynthPluginServerHosts>
|
||||
<RynthPluginServerWorldNames>FrostACE|FrostfACE</RynthPluginServerWorldNames>
|
||||
<RynthPluginDescription>FrostACE only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||
|
||||
</Project>
|
||||
22
Plugins/RynthCore.Plugin.RynthFrostACE/ServerData.cs
Normal file
22
Plugins/RynthCore.Plugin.RynthFrostACE/ServerData.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// ServerData.cs - What is known about FrostACE (RynthFrostACE). Identity (id, hosts, world names) is in the csproj.
|
||||
namespace RynthCore.Plugin.ServerPack;
|
||||
|
||||
internal static class ServerData
|
||||
{
|
||||
public static ServerPackInfo Create() =>
|
||||
new(RynthPluginInfo.ServerId, RynthPluginInfo.ServerName, RynthPluginInfo.ServerHosts, RynthPluginInfo.ServerWorldNames)
|
||||
{
|
||||
Port = 9000,
|
||||
Emulator = "ACE",
|
||||
Ruleset = "PvE",
|
||||
Status = "Development",
|
||||
Summary = "New accounts include lvl 275 starter characters. Retail character restoration also supported.",
|
||||
Facts = new[]
|
||||
{
|
||||
"New accounts get level 275 starter characters.",
|
||||
"Retail character restoration is supported.",
|
||||
"Listed as \"FrostfACE\" in the public server list; it connects by IP address.",
|
||||
},
|
||||
Source = "public AC server list (acresources/serverslist), checked 2026-10-13",
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- RynthFrostcull: the Frostcull server plugin. The build is shared (..\Shared\ServerPack\ServerPlugin.props);
|
||||
ServerData.cs holds what is known about the server. -->
|
||||
<PropertyGroup>
|
||||
<AssemblyName>RynthCore.Plugin.RynthFrostcull</AssemblyName>
|
||||
<Version>0.1.0</Version>
|
||||
<RynthPluginServerId>frostcull</RynthPluginServerId>
|
||||
<RynthPluginServerName>Frostcull</RynthPluginServerName>
|
||||
<RynthPluginServerHosts>frostcull.ddns.net</RynthPluginServerHosts>
|
||||
<RynthPluginServerWorldNames>Frostcull</RynthPluginServerWorldNames>
|
||||
<RynthPluginDescription>Frostcull only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||
|
||||
</Project>
|
||||
24
Plugins/RynthCore.Plugin.RynthFrostcull/ServerData.cs
Normal file
24
Plugins/RynthCore.Plugin.RynthFrostcull/ServerData.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// ServerData.cs - What is known about Frostcull (RynthFrostcull). Identity (id, hosts, world names) is in the csproj.
|
||||
namespace RynthCore.Plugin.ServerPack;
|
||||
|
||||
internal static class ServerData
|
||||
{
|
||||
public static ServerPackInfo Create() =>
|
||||
new(RynthPluginInfo.ServerId, RynthPluginInfo.ServerName, RynthPluginInfo.ServerHosts, RynthPluginInfo.ServerWorldNames)
|
||||
{
|
||||
Port = 9000,
|
||||
Emulator = "ACE",
|
||||
Ruleset = "PvE",
|
||||
Status = "Stable",
|
||||
Summary = "NO LEVEL/ATTRIBUTE CAP! 10x XP/Luminance, 25x Drop Rate, Quest Timers Reduced By 90%!",
|
||||
Facts = new[]
|
||||
{
|
||||
"No level or attribute cap.",
|
||||
"10x experience and luminance.",
|
||||
"25x drop rate.",
|
||||
"Quest timers 90% shorter.",
|
||||
},
|
||||
Discord = "https://discord.gg/RQF7HgEZn4",
|
||||
Source = "public AC server list (acresources/serverslist), checked 2026-10-13",
|
||||
};
|
||||
}
|
||||
143
Plugins/RynthCore.Plugin.RynthILT/DataInterface.cs
Normal file
143
Plugins/RynthCore.Plugin.RynthILT/DataInterface.cs
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
// DataInterface.cs - RynthILT's side of the "RynthILT.Data" interface (Plugins/Shared/RynthIltDataApi.cs):
|
||||
// the charms list and the bank balances (every character RynthILT has seen on this server) the
|
||||
// Mini Remote's Charms and Banking tabs show, for other plugins to draw, with the charm Toggle and
|
||||
// the bank verbs they send back; since version 2 also the pet breeding tracker's JSON and verbs.
|
||||
//
|
||||
// The table is allocated once per loaded copy of RynthILT and never freed (a plugin DLL is never
|
||||
// unloaded); after Release() it reports Version 0 and every function answers 0. Before login there
|
||||
// is no controller: the JSON getters answer 0 (nothing to report) and the actions are refused.
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using RynthCore.Plugin.RynthILT.Hub;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT;
|
||||
|
||||
internal static unsafe class DataInterface
|
||||
{
|
||||
/// <summary>Longest bank / breeding verb line taken (a transfer with a long character name fits easily).</summary>
|
||||
private const int MaxVerbBytes = 256;
|
||||
|
||||
private static RynthIltDataApiV1* _table;
|
||||
private static volatile bool _released;
|
||||
|
||||
/// <summary>The table for (<paramref name="iface"/>, <paramref name="version"/>), or 0 when it isn't ours.</summary>
|
||||
public static IntPtr Query(string iface, uint version)
|
||||
{
|
||||
if (iface != RynthIltDataApiV1.InterfaceName || version < 1 || version > RynthIltDataApiV1.InterfaceVersion || _released)
|
||||
return IntPtr.Zero;
|
||||
if (_table == null)
|
||||
{
|
||||
var t = (RynthIltDataApiV1*)NativeMemory.AllocZeroed((nuint)sizeof(RynthIltDataApiV1));
|
||||
t->StructSize = (uint)sizeof(RynthIltDataApiV1);
|
||||
t->GetCharmsJson = &GetCharmsJson;
|
||||
t->GetBankJson = &GetBankJson;
|
||||
t->ToggleCharm = &ToggleCharm;
|
||||
t->BankCommand = &BankCommand;
|
||||
t->GetPetBreedingJson = &GetPetBreedingJson;
|
||||
t->PetBreedingCommand = &PetBreedingCommand;
|
||||
t->Version = RynthIltDataApiV1.InterfaceVersion;
|
||||
_table = t;
|
||||
}
|
||||
return (IntPtr)_table;
|
||||
}
|
||||
|
||||
/// <summary>Plugin shutdown: readers see Version 0 and re-query; every function answers 0.</summary>
|
||||
public static void Release()
|
||||
{
|
||||
_released = true;
|
||||
if (_table != null) _table->Version = 0;
|
||||
}
|
||||
|
||||
private static IltHubController? Hub => _released ? null : PluginExports.Runtime.Plugin?.Hub;
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static int GetCharmsJson(byte* buffer, int capacity)
|
||||
{
|
||||
try
|
||||
{
|
||||
string? json = Hub?.CharmsJson;
|
||||
return string.IsNullOrEmpty(json) ? 0 : ProfileInterface.Write(json, buffer, capacity);
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static int GetBankJson(byte* buffer, int capacity)
|
||||
{
|
||||
try
|
||||
{
|
||||
string? json = Hub?.BankJson;
|
||||
return string.IsNullOrEmpty(json) ? 0 : ProfileInterface.Write(json, buffer, capacity);
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static int ToggleCharm(uint objectId)
|
||||
{
|
||||
try
|
||||
{
|
||||
IltHubController? hub = Hub;
|
||||
if (hub == null || objectId == 0) return 0;
|
||||
hub.RequestCharmToggle(objectId);
|
||||
return 1;
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static int BankCommand(byte* utf8)
|
||||
{
|
||||
try
|
||||
{
|
||||
IltHubController? hub = Hub;
|
||||
if (hub == null) return 0;
|
||||
string? line = ReadVerb(utf8);
|
||||
if (line == null) return 0;
|
||||
hub.RequestBankVerb(line);
|
||||
return 1;
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static int GetPetBreedingJson(byte* buffer, int capacity)
|
||||
{
|
||||
try
|
||||
{
|
||||
string? json = Hub?.PetBreedingJson;
|
||||
return string.IsNullOrEmpty(json) ? 0 : ProfileInterface.Write(json, buffer, capacity);
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
private static int PetBreedingCommand(byte* utf8)
|
||||
{
|
||||
try
|
||||
{
|
||||
IltHubController? hub = Hub;
|
||||
if (hub == null) return 0;
|
||||
string? line = ReadVerb(utf8);
|
||||
if (line == null) return 0;
|
||||
hub.RequestBreedingVerb(line);
|
||||
return 1;
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
/// <summary>A reader's verb line, or null when it is empty, too long or not plain ASCII (no control characters reach a chat command).</summary>
|
||||
private static string? ReadVerb(byte* utf8)
|
||||
{
|
||||
if (utf8 == null) return null;
|
||||
int len = 0;
|
||||
while (len < MaxVerbBytes && utf8[len] != 0) len++;
|
||||
if (len == 0 || len >= MaxVerbBytes) return null;
|
||||
string line = System.Text.Encoding.UTF8.GetString(utf8, len);
|
||||
foreach (char c in line)
|
||||
if (c < 0x20 || c > 0x7E) return null;
|
||||
return line;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +1,69 @@
|
|||
// IltBankCommands.cs — The /bank commands the Banking tab sends, and the reply lines it collects.
|
||||
// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13.
|
||||
//
|
||||
// Server contract (ACECustom PlayerCommands.HandleBank / Player_Bank, upstream 2026-10-11):
|
||||
// Server contract (ACECustom PlayerCommands.HandleBank / Player_Bank, upstream 976606695):
|
||||
// /b d [code] deposit everything (no code) or one kind; "Deposited N <kind>",
|
||||
// "No <kind> found to deposit", "Deposited all <kind>!".
|
||||
// /b lum bank luminance tokens: "Starting Banked Lum", one "Deposited N x <token>"
|
||||
// a kind, "Ending Banked Lum"; "No luminance tokens found to deposit".
|
||||
// /b w <code> <amount> withdraw: "Withdrew ...", "You don't have enough ...", "Failed to create ...".
|
||||
// /b w n <denom> [n] trade notes by denomination (i v x l c d m md mm mmd).
|
||||
// /b t <code> <n> <who> 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.
|
||||
// /b t <code> <n> <who> transfer; "Transferred {N0} {Currency} to {Name}[ (offline)]".
|
||||
// /b t n <denom> <n> <who> trade notes' pyreal value, then "(Equivalent to Nx DENOM notes)".
|
||||
// The recipient is one argument: a name with a space has to be in "quotes".
|
||||
// Prestige Coins are bound to the character: "[BANK] Prestige Coins are bound to you and
|
||||
// cannot be transferred." Pyreal peas and luminance tokens are deposit only.
|
||||
// Items is the one table of what the server allows; the deposit, withdraw and transfer lists
|
||||
// are built from it. 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;
|
||||
using System.Linq;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
internal static class IltBankCommands
|
||||
{
|
||||
/// <summary>
|
||||
/// One bank item: label, server code, and what the server allows for it. For trade notes
|
||||
/// ("n") a withdrawal or transfer is by denomination and note count.
|
||||
/// </summary>
|
||||
internal sealed record BankItem(string Label, string Code, bool Deposit, bool Withdraw, bool Transfer);
|
||||
|
||||
/// <summary>The trade-notes code: withdrawn and transferred by denomination.</summary>
|
||||
public const string NotesCode = "n";
|
||||
|
||||
/// <summary>The luminance-tokens deposit: its own command, "/b lum".</summary>
|
||||
public const string LuminanceTokensCode = "lum";
|
||||
|
||||
/// <summary>Everything the bank holds, in the server's order, with what it allows.</summary>
|
||||
public static readonly BankItem[] Items =
|
||||
{
|
||||
new("Pyreals", "p", Deposit: true, Withdraw: true, Transfer: true),
|
||||
new("Pyreal peas", "ps", Deposit: true, Withdraw: false, Transfer: false),
|
||||
new("Luminance", "l", Deposit: true, Withdraw: true, Transfer: true),
|
||||
new("Luminance tokens", LuminanceTokensCode, Deposit: true, Withdraw: false, Transfer: false),
|
||||
new("Legendary keys", "k", Deposit: true, Withdraw: true, Transfer: true),
|
||||
new("Mythical keys", "mk", Deposit: true, Withdraw: true, Transfer: true),
|
||||
new("Enlightened coins", "e", Deposit: true, Withdraw: true, Transfer: true),
|
||||
new("Weakly enlightened coins", "we", Deposit: true, Withdraw: true, Transfer: true),
|
||||
new("Prestige coins", "pc", Deposit: true, Withdraw: true, Transfer: false),
|
||||
new("Trade notes", NotesCode, Deposit: true, Withdraw: true, Transfer: true),
|
||||
};
|
||||
|
||||
/// <summary>A deposit choice: label, and the command's argument after "/b d" ("" = all).</summary>
|
||||
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"),
|
||||
};
|
||||
new[] { ("Everything", string.Empty) }
|
||||
.Concat(Items.Where(i => i.Deposit).Select(i => (i.Label, i.Code)))
|
||||
.ToArray();
|
||||
|
||||
/// <summary>A withdraw choice: label and the server code; "n" is trade notes (by denomination).</summary>
|
||||
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"),
|
||||
};
|
||||
Items.Where(i => i.Withdraw).Select(i => (i.Label, i.Code)).ToArray();
|
||||
|
||||
/// <summary>A transfer choice: label and the server code; "n" moves trade notes' pyreal value.</summary>
|
||||
public static readonly (string Label, string Code)[] Transfers =
|
||||
Items.Where(i => i.Transfer).Select(i => (i.Label, i.Code)).ToArray();
|
||||
|
||||
/// <summary>Trade note denominations: label and code, in the server's order.</summary>
|
||||
public static readonly (string Label, string Code, long Value)[] NoteDenominations =
|
||||
|
|
@ -54,7 +73,7 @@ internal static class IltBankCommands
|
|||
("MD (150K)", "md", 150_000), ("MM (200K)", "mm", 200_000), ("MMD (250K)", "mmd", 250_000),
|
||||
};
|
||||
|
||||
/// <summary>The server refuses a trade-note withdrawal of more than this many notes.</summary>
|
||||
/// <summary>The server refuses a trade-note withdrawal of more than this many notes; transfers use the same cap.</summary>
|
||||
public const int MaxNoteCount = 50_000;
|
||||
|
||||
/// <summary>"/b d", "/b d p", or "/b lum" for the luminance tokens; empty for an unknown index.</summary>
|
||||
|
|
@ -63,7 +82,7 @@ internal static class IltBankCommands
|
|||
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;
|
||||
return args == LuminanceTokensCode ? "/b lum" : "/b d " + args;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -76,10 +95,47 @@ internal static class IltBankCommands
|
|||
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}";
|
||||
if (code != NotesCode) return $"/b w {code} {amount}";
|
||||
if (!TryNote(denomination, amount, out string denom, out error)) return string.Empty;
|
||||
return $"/b w n {denom} {amount}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "/bank t p 250000 Bob", "/bank t n mmd 4 \"Some Name\"" for trade notes (<paramref name="amount"/>
|
||||
/// is then the note count). <paramref name="target"/> must already be a checked character name
|
||||
/// (IltParse.CharacterName); a name with a space is quoted, as the server reads one argument.
|
||||
/// Empty (with <paramref name="error"/>) when the input can't be sent.
|
||||
/// </summary>
|
||||
public static string Transfer(int index, long amount, int denomination, string target, out string error)
|
||||
{
|
||||
error = string.Empty;
|
||||
if (index < 0 || index >= Transfers.Length) { error = "Pick a currency."; return string.Empty; }
|
||||
if (amount <= 0) { error = "Amount must be positive."; return string.Empty; }
|
||||
target = (target ?? string.Empty).Trim();
|
||||
if (target.Length == 0) { error = "Enter a recipient."; return string.Empty; }
|
||||
if (target.IndexOf('"') >= 0) { error = "Recipient must be a character name."; return string.Empty; }
|
||||
string who = target.IndexOf(' ') >= 0 ? "\"" + target + "\"" : target;
|
||||
string code = Transfers[index].Code;
|
||||
if (code != NotesCode) return $"/bank t {code} {amount} {who}";
|
||||
if (!TryNote(denomination, amount, out string denom, out error)) return string.Empty;
|
||||
return $"/bank t n {denom} {amount} {who}";
|
||||
}
|
||||
|
||||
/// <summary>True when <paramref name="index"/> is the trade-notes transfer (denomination and count).</summary>
|
||||
public static bool IsNoteTransfer(int index) => index >= 0 && index < Transfers.Length && Transfers[index].Code == NotesCode;
|
||||
|
||||
/// <summary>The pyreal value of <paramref name="count"/> notes of <paramref name="denomination"/> (0 if unknown).</summary>
|
||||
public static long NoteValue(int denomination, long count) =>
|
||||
denomination >= 0 && denomination < NoteDenominations.Length && count > 0 ? NoteDenominations[denomination].Value * count : 0;
|
||||
|
||||
private static bool TryNote(int denomination, long count, out string code, out string error)
|
||||
{
|
||||
code = string.Empty;
|
||||
error = string.Empty;
|
||||
if (denomination < 0 || denomination >= NoteDenominations.Length) { error = "Pick a note denomination."; return false; }
|
||||
if (count > MaxNoteCount) { error = $"At most {MaxNoteCount:N0} notes at a time."; return false; }
|
||||
code = NoteDenominations[denomination].Code;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -110,4 +166,23 @@ internal static class IltBankCommands
|
|||
|| line.StartsWith("Count cannot exceed", StringComparison.Ordinal)
|
||||
|| line.StartsWith("You are not permitted to use bank commands", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True for a line the server sends in reply to a transfer: the result, the trade-note
|
||||
/// equivalent, the throttle, or a refusal (unknown player, bound prestige coins, bad input).
|
||||
/// </summary>
|
||||
public static bool IsTransferReply(string line)
|
||||
{
|
||||
if (string.IsNullOrEmpty(line)) return false;
|
||||
return line.StartsWith("Transferred ", StringComparison.Ordinal)
|
||||
|| line.StartsWith("(Equivalent to ", StringComparison.Ordinal)
|
||||
|| line.StartsWith("Character '", StringComparison.Ordinal)
|
||||
|| line.StartsWith("You cannot transfer", StringComparison.Ordinal)
|
||||
|| line.StartsWith("You don't have enough", StringComparison.Ordinal)
|
||||
|| line.StartsWith("[Transfer]", StringComparison.Ordinal)
|
||||
|| line.StartsWith("[BANK] Too many parameters", StringComparison.Ordinal)
|
||||
|| line.StartsWith("[BANK] Prestige Coins are bound", StringComparison.Ordinal)
|
||||
|| line.StartsWith("Invalid count", StringComparison.Ordinal)
|
||||
|| line.StartsWith("Invalid denomination", StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
151
Plugins/RynthCore.Plugin.RynthILT/Hub/IltBankExport.cs
Normal file
151
Plugins/RynthCore.Plugin.RynthILT/Hub/IltBankExport.cs
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
// IltBankExport.cs - The bank JSON of "RynthILT.Data" (Plugins/Shared/RynthIltDataApi.cs): the
|
||||
// Banking tab's balances, form choices and log for another plugin's view (every character here).
|
||||
//
|
||||
// Every character RynthILT has run on this server keeps its balances in its own hub.json
|
||||
// (<RynthILT folder>\<world>\<character>\hub.json, IltHubStore); the export lists them all, the
|
||||
// logged-in character from its live state and the rest from their saved files (read on the pump
|
||||
// at most every SiblingReadMs, so a reader polling every couple of seconds costs one directory
|
||||
// listing now and then). Plus the form choices (IltBankCommands), the last action's reply and
|
||||
// the recent transfers. Build is pure: the tests feed it rows.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
internal static class IltBankExport
|
||||
{
|
||||
/// <summary>How many recent transfers the JSON carries (newest first).</summary>
|
||||
public const int MaxTransactions = 50;
|
||||
|
||||
/// <summary>One character's balances as exported.</summary>
|
||||
internal sealed record Row(string Name, bool Current, IltBankState Bank);
|
||||
|
||||
/// <summary>
|
||||
/// The bank JSON. <paramref name="enabled"/>: 1 the server has /bank, 0 not, -1 not known yet.
|
||||
/// Rows are listed current character first, then by name. Plain ASCII.
|
||||
/// </summary>
|
||||
public static string Build(bool available, int enabled, string world, string character, IReadOnlyList<Row> rows,
|
||||
string result, IReadOnlyList<IltBankTransaction> transactions)
|
||||
{
|
||||
var sb = new StringBuilder(4096);
|
||||
sb.Append("{\"available\":").Append(available ? "true" : "false");
|
||||
sb.Append(",\"enabled\":").Append(Math.Clamp(enabled, -1, 1).ToString(CultureInfo.InvariantCulture));
|
||||
sb.Append(",\"world\":\"").Append(IltStyle.JsonEscape(world ?? string.Empty)).Append('"');
|
||||
sb.Append(",\"character\":\"").Append(IltStyle.JsonEscape(character ?? string.Empty)).Append('"');
|
||||
|
||||
var ordered = new List<Row>(rows);
|
||||
ordered.Sort((a, b) => a.Current != b.Current ? (a.Current ? -1 : 1) : string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
|
||||
sb.Append(",\"characters\":[");
|
||||
for (int i = 0; i < ordered.Count; i++)
|
||||
{
|
||||
Row r = ordered[i];
|
||||
IltBankState b = r.Bank;
|
||||
if (i > 0) sb.Append(',');
|
||||
sb.Append("{\"name\":\"").Append(IltStyle.JsonEscape(r.Name)).Append('"');
|
||||
sb.Append(",\"current\":").Append(r.Current ? "true" : "false");
|
||||
Num(sb, "pyreals", b.Pyreals);
|
||||
Num(sb, "luminance", b.Luminance);
|
||||
Num(sb, "legendaryKeys", b.LegendaryKeys);
|
||||
Num(sb, "mythicalKeys", b.MythicalKeys);
|
||||
Num(sb, "enlightenedCoins", b.EnlightenedCoins);
|
||||
Num(sb, "weaklyEnlightenedCoins", b.WeaklyEnlightenedCoins);
|
||||
Num(sb, "prestigeCoins", b.PrestigeCoins);
|
||||
sb.Append(",\"updated\":\"").Append(Utc(b.LastUpdated)).Append("\"}");
|
||||
}
|
||||
sb.Append(']');
|
||||
|
||||
sb.Append(",\"deposits\":[");
|
||||
for (int i = 0; i < IltBankCommands.Deposits.Length; i++)
|
||||
{
|
||||
if (i > 0) sb.Append(',');
|
||||
sb.Append('"').Append(IltStyle.JsonEscape(IltBankCommands.Deposits[i].Label)).Append('"');
|
||||
}
|
||||
sb.Append(']');
|
||||
Choices(sb, "withdrawals", IltBankCommands.Withdrawals, w => w.Code == IltBankCommands.NotesCode);
|
||||
Choices(sb, "transfers", IltBankCommands.Transfers, t => t.Code == IltBankCommands.NotesCode);
|
||||
sb.Append(",\"notes\":[");
|
||||
for (int i = 0; i < IltBankCommands.NoteDenominations.Length; i++)
|
||||
{
|
||||
var n = IltBankCommands.NoteDenominations[i];
|
||||
if (i > 0) sb.Append(',');
|
||||
sb.Append("{\"label\":\"").Append(IltStyle.JsonEscape(n.Label)).Append('"');
|
||||
Num(sb, "value", n.Value);
|
||||
sb.Append('}');
|
||||
}
|
||||
sb.Append(']');
|
||||
|
||||
sb.Append(",\"result\":\"").Append(IltStyle.JsonEscape(result ?? string.Empty)).Append('"');
|
||||
sb.Append(",\"transactions\":[");
|
||||
int written = 0;
|
||||
for (int i = transactions.Count - 1; i >= 0 && written < MaxTransactions; i--, written++)
|
||||
{
|
||||
IltBankTransaction t = transactions[i];
|
||||
if (written > 0) sb.Append(',');
|
||||
sb.Append("{\"when\":\"").Append(t.Timestamp == default ? "" : t.Timestamp.ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture)).Append('"');
|
||||
sb.Append(",\"type\":\"").Append(IltStyle.JsonEscape(t.Type)).Append('"');
|
||||
Num(sb, "amount", t.Amount);
|
||||
sb.Append(",\"currency\":\"").Append(IltStyle.JsonEscape(t.Currency)).Append('"');
|
||||
sb.Append(",\"player\":\"").Append(IltStyle.JsonEscape(t.OtherPlayer)).Append("\"}");
|
||||
}
|
||||
sb.Append("]}");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static void Num(StringBuilder sb, string name, long value)
|
||||
=> sb.Append(",\"").Append(name).Append("\":").Append(value.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
private static void Choices(StringBuilder sb, string name, (string Label, string Code)[] items, Func<(string Label, string Code), bool> notes)
|
||||
{
|
||||
sb.Append(",\"").Append(name).Append("\":[");
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
if (i > 0) sb.Append(',');
|
||||
sb.Append("{\"label\":\"").Append(IltStyle.JsonEscape(items[i].Label)).Append("\",\"notes\":")
|
||||
.Append(notes(items[i]) ? "true" : "false").Append('}');
|
||||
}
|
||||
sb.Append(']');
|
||||
}
|
||||
|
||||
/// <summary>A local DateTime as ISO UTC ("" = never).</summary>
|
||||
private static string Utc(DateTime local) => local == DateTime.MinValue || local == default
|
||||
? ""
|
||||
: local.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture);
|
||||
|
||||
/// <summary>
|
||||
/// The other characters' saved balances: every <c><world folder>\*\hub.json</c> except
|
||||
/// <paramref name="currentFolder"/>. A file that can't be read is skipped (its character just
|
||||
/// isn't listed). Characters never banked (no LastUpdated) are left out.
|
||||
/// </summary>
|
||||
public static List<Row> ReadSiblings(string currentFolder)
|
||||
{
|
||||
var rows = new List<Row>();
|
||||
if (string.IsNullOrEmpty(currentFolder)) return rows;
|
||||
string? worldDir = Path.GetDirectoryName(currentFolder.TrimEnd('\\', '/'));
|
||||
if (string.IsNullOrEmpty(worldDir) || !Directory.Exists(worldDir)) return rows;
|
||||
string self = Path.GetFullPath(currentFolder).TrimEnd('\\', '/');
|
||||
foreach (string dir in Directory.EnumerateDirectories(worldDir))
|
||||
{
|
||||
if (string.Equals(Path.GetFullPath(dir).TrimEnd('\\', '/'), self, StringComparison.OrdinalIgnoreCase)) continue;
|
||||
string file = Path.Combine(dir, IltHubStore.StateFile);
|
||||
if (!File.Exists(file)) continue;
|
||||
try
|
||||
{
|
||||
using var fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
var state = JsonSerializer.Deserialize(fs, IltHubJsonContext.Default.IltHubState);
|
||||
IltBankState? bank = state?.Bank;
|
||||
if (bank == null || bank.LastUpdated == DateTime.MinValue) continue;
|
||||
rows.Add(new Row(Path.GetFileName(dir), false, bank));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RynthLog.Trace(LogCat.IltBanking, $"bank export: skipped {file} ({ex.Message})");
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
// IltBanking.cs — ILT Hub "Banking" tab: /bank balances, deposits, withdrawals, confirmed
|
||||
// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13.
|
||||
// transfers, transaction log.
|
||||
// IltBanking.cs — ILT banking: /bank balances, deposits, withdrawals, confirmed transfers,
|
||||
// transaction log. Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13.
|
||||
// Render is the Mini Remote's "Banking" tab. The balances and log are also exported to other
|
||||
// plugins through "RynthILT.Data" (IltBankExport; their verbs come back through RunVerb).
|
||||
//
|
||||
// Server contract (ACECustom PlayerCommands bank handler, upstream 2026-10-11):
|
||||
// /bank → "[BANK] Your balances are:" then "[BANK] Pyreals: N", "Luminance:",
|
||||
|
|
@ -9,8 +10,9 @@
|
|||
// /b d, /b lum, /b w → deposits and withdrawals (IltBankCommands has the commands and replies).
|
||||
// /bank t <c> <n> <who> → "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.
|
||||
// /bank t n <d> <n> <who> → trade notes' pyreal value, then "(Equivalent to ...)".
|
||||
// What each item allows is IltBankCommands.Items (the server's table): Prestige Coins (pc)
|
||||
// are bound (deposit and withdraw only); pyreal peas and luminance tokens deposit 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
|
||||
|
|
@ -20,21 +22,14 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
internal sealed class IltBanking : IIltFeature
|
||||
{
|
||||
/// <summary>Transfer currency table: display name, /bank t code.</summary>
|
||||
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"),
|
||||
};
|
||||
/// <summary>Transfer currencies: display name, /bank t code (IltBankCommands.Transfers).</summary>
|
||||
public static readonly (string Name, string Code)[] Currencies = IltBankCommands.Transfers;
|
||||
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();
|
||||
|
|
@ -69,6 +64,23 @@ internal sealed class IltBanking : IIltFeature
|
|||
private string _txFilter = string.Empty;
|
||||
private string _lastResult = string.Empty;
|
||||
private volatile string _actionResult = string.Empty;
|
||||
/// <summary>The newest action reply or error (deposit, withdrawal or transfer), for the bank export.</summary>
|
||||
private volatile string _latestResult = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Another plugin is showing the balances (a "RynthILT.Data" reader):
|
||||
/// the periodic quiet refresh runs as it does while the Mini Remote is open. Pump thread.
|
||||
/// </summary>
|
||||
public bool ReaderWatching;
|
||||
|
||||
/// <summary>The newest action reply or error (any thread).</summary>
|
||||
public string LatestResult => _latestResult;
|
||||
|
||||
/// <summary>The transaction log as last published (any thread; oldest first).</summary>
|
||||
public IReadOnlyList<IltBankTransaction> Transactions => _txSnapshot;
|
||||
|
||||
/// <summary>The bank state (pump thread).</summary>
|
||||
public IltBankState State => Bank;
|
||||
|
||||
/// <summary>Raised (pump thread) after a balance line updates the state; Character rates use the deltas.</summary>
|
||||
public event Action<string, long, long>? BalanceChanged;
|
||||
|
|
@ -128,40 +140,36 @@ internal sealed class IltBanking : IIltFeature
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates and (after the UI confirm) sends a transfer. Pump thread.
|
||||
/// Validates and (after the UI confirm) sends a transfer. For trade notes
|
||||
/// <paramref name="amount"/> is the note count of <paramref name="denomination"/>. Pump thread.
|
||||
/// Returns an error message, or empty when the command was queued.
|
||||
/// </summary>
|
||||
public string SendTransfer(int currencyIndex, long amount, string target)
|
||||
public string SendTransfer(int currencyIndex, long amount, string target, int denomination = -1)
|
||||
{
|
||||
RynthLog.Trace(LogCat.IltBanking, $"SendTransfer(currency={currencyIndex}, amount={amount}, target='{target}')");
|
||||
RynthLog.Trace(LogCat.IltBanking, $"SendTransfer(currency={currencyIndex}, amount={amount}, denom={denomination}, 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).";
|
||||
// allowed: no '/', quotes, control characters or line breaks that could start a second command.
|
||||
if (target.Length > 0 && !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.";
|
||||
string cmd = IltBankCommands.Transfer(currencyIndex, amount, denomination, target, out string error);
|
||||
if (cmd.Length == 0) return error;
|
||||
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),
|
||||
IsResponseLine = IltBankCommands.IsTransferReply,
|
||||
IdleEndMs = 500,
|
||||
FirstLineTimeoutMs = 8000,
|
||||
Eat = false,
|
||||
OnComplete = r =>
|
||||
{
|
||||
_lastResult = r.Lines.Count > 0 ? r.Lines[^1] : (r.TimedOut ? "No reply from server." : string.Empty);
|
||||
_latestResult = _lastResult;
|
||||
// Balances changed: read them again shortly.
|
||||
_refreshDueAt = IltHubContext.NowMs + RefreshAfterActionMs;
|
||||
},
|
||||
|
|
@ -212,19 +220,51 @@ internal sealed class IltBanking : IIltFeature
|
|||
{
|
||||
_actionResult = r.Lines.Count > 0 ? string.Join("\n", r.Lines.TakeLast(6))
|
||||
: r.TimedOut ? "No reply from the server." : string.Empty;
|
||||
_latestResult = _actionResult;
|
||||
_refreshDueAt = IltHubContext.NowMs + RefreshAfterActionMs;
|
||||
},
|
||||
});
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A bank verb line from "RynthILT.Data" BankCommand (Plugins/Shared/RynthIltDataApi.cs):
|
||||
/// "refresh", "deposit i", "withdraw i amount note", "transfer i amount note name". The reader
|
||||
/// has already confirmed a transfer with the player. Pump thread. Returns an error, or empty
|
||||
/// when it was queued; either way the outcome shows in <see cref="LatestResult"/>.
|
||||
/// </summary>
|
||||
public string RunVerb(string line)
|
||||
{
|
||||
string[] p = (line ?? string.Empty).Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
string err;
|
||||
if (p.Length == 0) err = "Empty bank command.";
|
||||
else if (p[0] == "refresh" && p.Length == 1) { RequestRefresh(quiet: true); return string.Empty; }
|
||||
else if (p[0] == "deposit" && p.Length == 2 && int.TryParse(p[1], out int d)) err = SendDeposit(d);
|
||||
else if (p[0] == "withdraw" && p.Length == 4 && int.TryParse(p[1], out int w) && long.TryParse(p[2], out long wa)
|
||||
&& int.TryParse(p[3], out int wn))
|
||||
err = SendWithdraw(w, wa, wn);
|
||||
else if (p[0] == "transfer" && p.Length >= 5 && int.TryParse(p[1], out int c) && long.TryParse(p[2], out long ta)
|
||||
&& int.TryParse(p[3], out int tn))
|
||||
{
|
||||
// The name may hold spaces; SendTransfer checks it is a character name.
|
||||
string who = string.Join(' ', p, 4, p.Length - 4);
|
||||
err = SendTransfer(c, ta, who, IltBankCommands.IsNoteTransfer(c) ? tn : -1);
|
||||
if (err.Length == 0) _latestResult = "Transfer sent...";
|
||||
}
|
||||
else err = "Unknown bank command.";
|
||||
if (err.Length > 0) _latestResult = err;
|
||||
RynthLog.Trace(LogCat.IltBanking, $"reader verb '{line}' -> {(err.Length > 0 ? err : "queued")}");
|
||||
return err;
|
||||
}
|
||||
|
||||
// ── IIltFeature ─────────────────────────────────────────────────────────
|
||||
|
||||
public void Tick(long nowMs)
|
||||
{
|
||||
// Periodic quiet refresh only while the Hub is open and the server has /bank.
|
||||
// Periodic quiet refresh only while the balances are on screen (the Hub, or a reader's
|
||||
// Banking tab) and the server has /bank.
|
||||
int every = Bank.AutoRefreshSeconds;
|
||||
if (Enabled && _ctx.WindowOpen && every > 0 && nowMs - _lastAutoRefreshAt >= every * 1000L
|
||||
if (Enabled && (_ctx.WindowOpen || ReaderWatching) && every > 0 && nowMs - _lastAutoRefreshAt >= every * 1000L
|
||||
&& nowMs - _lastBalanceAt >= BalanceSpacingMs)
|
||||
{
|
||||
_lastAutoRefreshAt = nowMs;
|
||||
|
|
@ -369,7 +409,7 @@ internal sealed class IltBanking : IIltFeature
|
|||
{
|
||||
if (!Enabled)
|
||||
{
|
||||
ImGui.TextColored(IltStyle.ColTextMute,
|
||||
SafeImGui.TextColored(IltStyle.ColTextMute,
|
||||
_ctx.Options.IsOff(IltFeature.Bank) ? "The server reports /bank is not available." : "Waiting for the server options check...");
|
||||
return;
|
||||
}
|
||||
|
|
@ -381,7 +421,7 @@ internal sealed class IltBanking : IIltFeature
|
|||
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"));
|
||||
SafeImGui.TextDisabled(Bank.LastUpdated == DateTime.MinValue ? "never updated" : "updated " + Bank.LastUpdated.ToString("g"));
|
||||
|
||||
if (ImGui.BeginTable("##iltbal", 2, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV))
|
||||
{
|
||||
|
|
@ -432,7 +472,7 @@ internal sealed class IltBanking : IIltFeature
|
|||
_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."
|
||||
SafeImGui.SetTooltip(IltBankCommands.Deposit(dep) + "\nEverything banks all currencies, notes and luminance tokens."
|
||||
+ "\nThe server refuses while you are busy or moving.");
|
||||
|
||||
ImGui.TextColored(IltStyle.ColTeal, "Withdraw");
|
||||
|
|
@ -463,12 +503,12 @@ internal sealed class IltBanking : IIltFeature
|
|||
{
|
||||
ImGui.SameLine();
|
||||
if (!ok) ImGui.TextColored(IltStyle.ColHp, "invalid amount");
|
||||
else if (notes) ImGui.TextDisabled("= " + IltParse.N0(amount * IltBankCommands.NoteDenominations[denom].Value) + " pyreals");
|
||||
else ImGui.TextDisabled("= " + IltParse.N0(amount));
|
||||
else if (notes) SafeImGui.TextDisabled("= " + IltParse.N0(amount * IltBankCommands.NoteDenominations[denom].Value) + " pyreals");
|
||||
else SafeImGui.TextDisabled("= " + IltParse.N0(amount));
|
||||
}
|
||||
|
||||
string result = _actionResult;
|
||||
if (result.Length > 0) ImGui.TextWrapped(result);
|
||||
if (result.Length > 0) SafeImGui.TextWrapped(result);
|
||||
}
|
||||
|
||||
private void RenderTransferForm()
|
||||
|
|
@ -478,9 +518,18 @@ internal sealed class IltBanking : IIltFeature
|
|||
ImGui.SetNextItemWidth(200);
|
||||
if (ImGui.Combo("Currency##xfer", ref idx, CurrencyNames, CurrencyNames.Length))
|
||||
Bank.TransferCurrencyIndex = idx;
|
||||
bool notes = IltBankCommands.IsNoteTransfer(idx);
|
||||
int denom = Math.Clamp(Bank.TransferNoteIndex, 0, NoteNames.Length - 1);
|
||||
if (notes)
|
||||
{
|
||||
ImGui.SetNextItemWidth(200);
|
||||
if (ImGui.Combo("Denomination##xfer", ref denom, NoteNames, NoteNames.Length)) Bank.TransferNoteIndex = denom;
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("The server moves the notes' pyreal value from your bank (/b t n <denomination> <count> <name>).");
|
||||
}
|
||||
|
||||
ImGui.SetNextItemWidth(200);
|
||||
ImGui.InputTextWithHint("Amount##xfer", "e.g. 250000, 1.5m, 2b", ref _amountText, 32u);
|
||||
ImGui.InputTextWithHint("Amount##xfer", notes ? "how many notes" : "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))
|
||||
|
|
@ -490,33 +539,37 @@ internal sealed class IltBanking : IIltFeature
|
|||
if (_amountText.Length > 0)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
if (amountOk) ImGui.TextDisabled("= " + IltParse.N0(amount));
|
||||
else ImGui.TextColored(IltStyle.ColHp, "invalid amount");
|
||||
if (!amountOk) ImGui.TextColored(IltStyle.ColHp, "invalid amount");
|
||||
else if (notes) SafeImGui.TextDisabled("= " + IltParse.N0(IltBankCommands.NoteValue(denom, amount)) + " pyreals");
|
||||
else SafeImGui.TextDisabled("= " + IltParse.N0(amount));
|
||||
}
|
||||
|
||||
ImGui.BeginDisabled(!amountOk || string.IsNullOrWhiteSpace(Bank.TransferTarget));
|
||||
if (ImGui.Button("Send transfer..."))
|
||||
{
|
||||
int cur = idx;
|
||||
int cur = idx, note = notes ? denom : -1;
|
||||
long amt = amount;
|
||||
string who = Bank.TransferTarget.Trim();
|
||||
string what = notes
|
||||
? $"{IltParse.N0(amt)} {IltBankCommands.NoteDenominations[denom].Label} trade notes ({IltParse.N0(IltBankCommands.NoteValue(denom, amt))} pyreals)"
|
||||
: $"{IltParse.N0(amt)} {Currencies[cur].Name}";
|
||||
_ctx.Confirm("Confirm bank transfer",
|
||||
$"Send {IltParse.N0(amt)} {Currencies[cur].Name} to {who}?\n\nThis cannot be undone.",
|
||||
$"Send {what} to {who}?\n\nThis cannot be undone.",
|
||||
() =>
|
||||
{
|
||||
string err = SendTransfer(cur, amt, who);
|
||||
string err = SendTransfer(cur, amt, who, note);
|
||||
_lastResult = err.Length > 0 ? err : "Transfer sent...";
|
||||
},
|
||||
"Send");
|
||||
}
|
||||
ImGui.EndDisabled();
|
||||
if (_lastResult.Length > 0) ImGui.TextWrapped(_lastResult);
|
||||
if (_lastResult.Length > 0) SafeImGui.TextWrapped(_lastResult);
|
||||
}
|
||||
|
||||
private void RenderTransactionLog()
|
||||
{
|
||||
var snap = _txSnapshot;
|
||||
ImGui.TextColored(IltStyle.ColTeal, $"Transactions ({snap.Length})");
|
||||
SafeImGui.TextColored(IltStyle.ColTeal, $"Transactions ({snap.Length})");
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(180);
|
||||
ImGui.InputTextWithHint("##txfilter", "filter player / currency", ref _txFilter, 64u);
|
||||
|
|
@ -543,7 +596,7 @@ internal sealed class IltBanking : IIltFeature
|
|||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn(); ImGui.TextUnformatted(t.Timestamp.ToString("g"));
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.TextColored(t.Type == "Sent" ? IltStyle.ColAmber : IltStyle.ColGreen, t.Type);
|
||||
SafeImGui.TextColored(t.Type == "Sent" ? IltStyle.ColAmber : IltStyle.ColGreen, t.Type);
|
||||
ImGui.TableNextColumn(); ImGui.TextUnformatted(IltParse.N0(t.Amount));
|
||||
ImGui.TableNextColumn(); ImGui.TextUnformatted(t.Currency);
|
||||
ImGui.TableNextColumn(); ImGui.TextUnformatted(t.OtherPlayer);
|
||||
|
|
|
|||
316
Plugins/RynthCore.Plugin.RynthILT/Hub/IltBreedingEssence.cs
Normal file
316
Plugins/RynthCore.Plugin.RynthILT/Hub/IltBreedingEssence.cs
Normal file
|
|
@ -0,0 +1,316 @@
|
|||
// IltBreedingEssence.cs - One carried combat pet essence, as the breeding tracker sees it.
|
||||
//
|
||||
// The facts come from the essence's appraisal (ACECustom [AssessmentProperty] qualities: bond 9053,
|
||||
// male charges 9057, next breeding time float 9056, incense float 9058, neutered bool 9051, the
|
||||
// male override 50053, juvenile 50054, Chromatic Catalyst 50055, the guardian's Offering 50056,
|
||||
// maturity kills 9077, the mutation lines 9070..9075) and its LongDesc breeding block ("Sex: ...",
|
||||
// "Growth: ...", "(shiny - cannot breed)"). Evaluate turns them into what the player needs to know:
|
||||
// stud or dam, every breeding gate that fails, when it clears, growth, and the boosters applied.
|
||||
// The gates are ACE PetDevice_Breeding's, with the thresholds from IltBreedingRules.
|
||||
//
|
||||
// Pure: no host calls (IltPetBreeding reads the host), so RynthILT.Tests checks it offline.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
/// <summary>A gate's outcome for one essence.</summary>
|
||||
internal enum BreedGate { Ready, Resting, NoCharges, Growing, Neutered, Shiny, LowBond, LowTier, NeedsId }
|
||||
|
||||
/// <summary>What was read for one essence (host values; pump thread fills it).</summary>
|
||||
internal sealed class BreedEssenceFacts
|
||||
{
|
||||
public int Id;
|
||||
public string Name = string.Empty;
|
||||
public uint Wcid;
|
||||
public bool HasId;
|
||||
/// <summary>The essence's level requirement (a tier fallback for WCIDs outside the table).</summary>
|
||||
public int UseLevel;
|
||||
public int Bond;
|
||||
/// <summary>The server's explicit sex (Tailoring Kit), or null to derive it from the object id.</summary>
|
||||
public bool? MaleOverride;
|
||||
public bool Neutered;
|
||||
public bool JuvenileFlag;
|
||||
/// <summary>PetMaturityKills: -1 when absent (the essence was never bred).</summary>
|
||||
public int MaturityKills = -1;
|
||||
/// <summary>PetMaleBreedingCharges: -1 when absent (a full stud).</summary>
|
||||
public int MaleCharges = -1;
|
||||
public double MaleRefreshUnix;
|
||||
public double NextBreedUnix;
|
||||
public double Incense;
|
||||
public bool Catalyst;
|
||||
public bool Offering;
|
||||
public double MaturityXpMult;
|
||||
public int MutDamage, MutDamageResist, MutCrit, MutVitality, MutPotency, MutationCount;
|
||||
public int PotencyStored;
|
||||
public bool Attuned;
|
||||
public string LongDesc = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>One essence evaluated for breeding. Immutable; the UI and the reader JSON read it.</summary>
|
||||
internal sealed record BreedEssence(
|
||||
int Id, string Name, uint Wcid, bool HasId, int Tier, int Bond, bool Male, BreedGate Gate, string Status,
|
||||
IReadOnlyList<string> Problems, double ReadyAtUnix, int Charges, int ChargesMax, double RefillAtUnix,
|
||||
bool Bred, bool Juvenile, int Stage, int Stages, string StageName, int Kills, int KillsRequired, int KillsToNext,
|
||||
double Incense, bool Catalyst, bool Offering, bool Draught, IReadOnlyList<string> Boosters,
|
||||
int MutD, int MutDR, int MutC, int MutV, int MutP, bool Shiny, bool Unbound, int Potency)
|
||||
{
|
||||
/// <summary>Every gate passes now.</summary>
|
||||
public bool Ready => Gate == BreedGate.Ready;
|
||||
/// <summary>The stat mutation lines (damage, damage resist, crit, vitality) summed.</summary>
|
||||
public int StatMutations => MutD + MutDR + MutC + MutV;
|
||||
/// <summary>"Stud" or "Dam".</summary>
|
||||
public string Role => Male ? "Stud" : "Dam";
|
||||
}
|
||||
|
||||
internal static class IltBreedingEssence
|
||||
{
|
||||
/// <summary>Essence tiers, in the order of each family row below (ACE PetDeviceWcids petLevelIndexes).</summary>
|
||||
public static readonly int[] Tiers = { 50, 80, 100, 125, 150, 180, 200, 250, 300 };
|
||||
|
||||
// ACECustom PetDeviceWcids: one row per combat pet family, tiers 50 .. 300 in order. "a-b" is a
|
||||
// run of consecutive WCIDs. Rows copied from Source/ACE.Server/Factories/Tables/Wcids/PetDeviceWcids.cs.
|
||||
private static readonly string[] FamilyRows =
|
||||
{
|
||||
"48942,48944,48945,48946,48947,48948,48956,787801001,787801037",
|
||||
"49213-49219,787801002,787801038",
|
||||
"49220-49226,787801003,787801039",
|
||||
"49227-49232,49212,787801004,787801040",
|
||||
"48972,49234-49239,787801005,787801041",
|
||||
"49240-49246,787801006,787801042",
|
||||
"49247-49253,787801007,787801043",
|
||||
"49254-49259,49233,787801008,787801044",
|
||||
"49421-49427,787801009,787801045",
|
||||
"49428-49434,787801010,787801046",
|
||||
"49435-49441,787801011,787801047",
|
||||
"49442-49448,787801012,787801048",
|
||||
"48959,48961,48963,48965,48967,48969,48957,787801013,787801049",
|
||||
"49261-49267,787801014,787801050",
|
||||
"49268-49274,787801015,787801051",
|
||||
"49275-49280,49260,787801016,787801052",
|
||||
"49282-49287,49281,787801017,787801053",
|
||||
"49289-49294,49288,787801018,787801054",
|
||||
"49296-49301,49295,787801019,787801055",
|
||||
"49303-49308,49302,787801020,787801056",
|
||||
"49310-49316,787801021,787801057",
|
||||
"49317-49323,787801022,787801058",
|
||||
"49324-49330,787801023,787801059",
|
||||
"49331-49336,49309,787801024,787801060",
|
||||
"49338-49344,787801025,787801061",
|
||||
"49345-49351,787801026,787801062",
|
||||
"49352-49358,787801027,787801063",
|
||||
"49359-49364,49337,787801028,787801064",
|
||||
"49366-49372,787801029,787801065",
|
||||
"49373-49379,787801030,787801066",
|
||||
"49380-49386,787801031,787801067",
|
||||
"49387-49392,49365,787801032,787801068",
|
||||
"49524-49530,787801033,787801069",
|
||||
"49531-49537,787801034,787801070",
|
||||
"49538-49544,787801035,787801071",
|
||||
"49545-49551,787801036,787801072",
|
||||
};
|
||||
|
||||
/// <summary>Each family row expanded (tests check every row has one WCID per tier).</summary>
|
||||
internal static readonly uint[][] Families = Array.ConvertAll(FamilyRows, ExpandRow);
|
||||
|
||||
private static readonly Dictionary<uint, int> TierByWcid = BuildTiers();
|
||||
|
||||
private static uint[] ExpandRow(string row)
|
||||
{
|
||||
var list = new List<uint>(9);
|
||||
foreach (string token in row.Split(','))
|
||||
{
|
||||
int dash = token.IndexOf('-');
|
||||
if (dash < 0) { list.Add(uint.Parse(token, CultureInfo.InvariantCulture)); continue; }
|
||||
uint a = uint.Parse(token.AsSpan(0, dash), NumberStyles.Integer, CultureInfo.InvariantCulture);
|
||||
uint b = uint.Parse(token.AsSpan(dash + 1), NumberStyles.Integer, CultureInfo.InvariantCulture);
|
||||
for (uint w = a; w <= b; w++) list.Add(w);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static Dictionary<uint, int> BuildTiers()
|
||||
{
|
||||
var d = new Dictionary<uint, int>();
|
||||
foreach (uint[] row in Families)
|
||||
for (int i = 0; i < row.Length && i < Tiers.Length; i++)
|
||||
d[row[i]] = Tiers[i];
|
||||
return d;
|
||||
}
|
||||
|
||||
/// <summary>True for a combat pet essence WCID (the only kind that breeds).</summary>
|
||||
public static bool IsCombatEssence(uint wcid) => TierByWcid.ContainsKey(wcid);
|
||||
|
||||
/// <summary>The essence tier for a WCID, else the level requirement when it is a tier, else 0.</summary>
|
||||
public static int TierOf(uint wcid, int useLevel = 0)
|
||||
{
|
||||
if (TierByWcid.TryGetValue(wcid, out int t)) return t;
|
||||
return Array.IndexOf(Tiers, useLevel) >= 0 ? useLevel : 0;
|
||||
}
|
||||
|
||||
/// <summary>ACE PetDevice.IsMale without an override: murmur3 fmix32 on the object id, even = male.</summary>
|
||||
public 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;
|
||||
}
|
||||
|
||||
/// <summary>"3h 05m", "42m", "20s" (0 or less = "now").</summary>
|
||||
public static string Duration(double seconds)
|
||||
{
|
||||
if (seconds <= 0) return "now";
|
||||
long s = (long)Math.Ceiling(seconds);
|
||||
if (s >= 3600) return $"{s / 3600}h {s % 3600 / 60:00}m";
|
||||
if (s >= 60) return $"{s / 60}m";
|
||||
return $"{s}s";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates one essence: role, every failing gate (the first is the headline), the ready time,
|
||||
/// growth and boosters. <paramref name="nowUnix"/> is unix seconds.
|
||||
/// </summary>
|
||||
public static BreedEssence Evaluate(BreedEssenceFacts f, IltBreedingRules r, double nowUnix)
|
||||
{
|
||||
string desc = f.LongDesc ?? string.Empty;
|
||||
bool male = f.MaleOverride ?? DeriveIsMale(f.Id);
|
||||
int tier = TierOf(f.Wcid, f.UseLevel);
|
||||
int bond = Math.Max(1, f.Bond);
|
||||
bool shiny = desc.Contains("(shiny - cannot breed)", StringComparison.OrdinalIgnoreCase);
|
||||
bool bred = f.MaturityKills >= 0;
|
||||
bool juvenile = f.JuvenileFlag || desc.Contains("cannot breed yet", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// Stud charges refill lazily on the server: full again once the refill time has passed.
|
||||
int max = Math.Max(0, r.GetInt(IltBreedingRules.MaleCharges));
|
||||
int charges = f.MaleCharges < 0 ? max : Math.Min(f.MaleCharges, max);
|
||||
double refillAt = 0;
|
||||
double refillH = r.Get(IltBreedingRules.MaleRefillHours);
|
||||
if (male && f.MaleRefreshUnix > 0 && refillH > 0)
|
||||
{
|
||||
refillAt = f.MaleRefreshUnix + refillH * 3600.0;
|
||||
if (nowUnix >= refillAt) { charges = max; refillAt = 0; }
|
||||
}
|
||||
if (male && charges >= max) refillAt = 0;
|
||||
|
||||
// Growth (bred essences only): stage from credited kills, as ACE PetDevice_Maturity.
|
||||
int required = Math.Max(1, r.GetInt(IltBreedingRules.MaturityKills));
|
||||
int stages = Math.Max(1, r.GetInt(IltBreedingRules.MaturityStages));
|
||||
int kills = Math.Max(0, f.MaturityKills);
|
||||
int perStage = Math.Max(1, (int)Math.Ceiling(required / (double)stages));
|
||||
int stage = juvenile ? Math.Min(stages, kills / perStage + 1) : stages + 1;
|
||||
int toNext = juvenile ? Math.Max(0, Math.Min(required, stage * perStage) - kills) : 0;
|
||||
string stageName = juvenile ? r.StageName(stage) : bred ? "Adult" : string.Empty;
|
||||
if (juvenile && IltBreedingRules.TryParseGrowth(desc, out string seenName, out int seenStage, out _, out int seenNext, out _, out int seenAdult))
|
||||
{
|
||||
// The appraisal line is the server's own math: prefer it when it is there.
|
||||
stage = seenStage;
|
||||
stageName = seenName;
|
||||
toNext = seenNext;
|
||||
kills = Math.Max(kills, required - seenAdult);
|
||||
}
|
||||
|
||||
// Every failing gate, in the order the server checks them.
|
||||
var problems = new List<string>();
|
||||
BreedGate gate = BreedGate.Ready;
|
||||
void Fail(BreedGate g, string text)
|
||||
{
|
||||
if (gate == BreedGate.Ready) gate = g;
|
||||
problems.Add(text);
|
||||
}
|
||||
double readyAt = 0;
|
||||
if (!f.HasId) Fail(BreedGate.NeedsId, "not appraised yet");
|
||||
if (f.Neutered) Fail(BreedGate.Neutered, "neutered (permanent)");
|
||||
if (shiny) Fail(BreedGate.Shiny, "shiny essences can't breed");
|
||||
if (juvenile) Fail(BreedGate.Growing, $"still growing: {stageName} ({Math.Max(0, required - kills)} kills to Adult)");
|
||||
int minTier = r.GetInt(IltBreedingRules.MinTier);
|
||||
if (tier > 0 && tier < minTier) Fail(BreedGate.LowTier, $"tier {tier} (needs {minTier}+)");
|
||||
int minBond = r.GetInt(IltBreedingRules.MinBond);
|
||||
if (f.HasId && bond < minBond) Fail(BreedGate.LowBond, $"bond {bond}/{minBond}");
|
||||
if (male && charges <= 0)
|
||||
{
|
||||
Fail(BreedGate.NoCharges, refillAt > 0 ? $"no charges (refill in {Duration(refillAt - nowUnix)})" : "no charges left");
|
||||
readyAt = Math.Max(readyAt, refillAt);
|
||||
}
|
||||
if (!male && f.NextBreedUnix > nowUnix)
|
||||
{
|
||||
Fail(BreedGate.Resting, $"resting ({Duration(f.NextBreedUnix - nowUnix)})");
|
||||
readyAt = Math.Max(readyAt, f.NextBreedUnix);
|
||||
}
|
||||
|
||||
string status = gate switch
|
||||
{
|
||||
BreedGate.Ready => male ? $"Ready ({charges}/{max})" : "Ready",
|
||||
BreedGate.Resting => "Rest " + Duration(f.NextBreedUnix - nowUnix),
|
||||
BreedGate.NoCharges => refillAt > 0 ? "0/" + max + " refill " + Duration(refillAt - nowUnix) : "0/" + max,
|
||||
BreedGate.Growing => $"{stageName} {Math.Min(stage, stages)}/{stages}",
|
||||
BreedGate.Neutered => "Neutered",
|
||||
BreedGate.Shiny => "Shiny",
|
||||
BreedGate.LowBond => $"Bond {bond}/{minBond}",
|
||||
BreedGate.LowTier => $"Tier {tier}",
|
||||
_ => "ID needed",
|
||||
};
|
||||
|
||||
bool draught = f.MaturityXpMult > 1.0001;
|
||||
var boosters = new List<string>(4);
|
||||
if (f.Incense > 0) boosters.Add(IltBreedingSupplies.IncenseName(f.Incense));
|
||||
if (f.Catalyst) boosters.Add("Chromatic Catalyst");
|
||||
if (f.Offering) boosters.Add("Offering of Subjugation");
|
||||
if (draught) boosters.Add("Nurturing Draught x" + f.MaturityXpMult.ToString("0.#", CultureInfo.InvariantCulture));
|
||||
|
||||
return new BreedEssence(
|
||||
f.Id, f.Name, f.Wcid, f.HasId, tier, bond, male, gate, status, problems, readyAt,
|
||||
male ? charges : 0, male ? max : 0, male ? refillAt : 0,
|
||||
bred, juvenile, juvenile ? stage : 0, stages, stageName, kills, required, toNext,
|
||||
Math.Max(0, f.Incense), f.Catalyst, f.Offering, draught, boosters,
|
||||
Math.Max(0, f.MutDamage), Math.Max(0, f.MutDamageResist), Math.Max(0, f.MutCrit), Math.Max(0, f.MutVitality),
|
||||
Math.Max(0, f.MutPotency), shiny, bred && !f.Attuned && desc.Contains("Bond: Unbound", StringComparison.OrdinalIgnoreCase),
|
||||
Math.Max(0, f.PotencyStored));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>What a stud + dam pairing would do: the gates both must pass, and the baby's odds.</summary>
|
||||
internal sealed record BreedPairPlan(bool CanBreed, IReadOnlyList<string> Blockers, double Incense, double ChanceBest, double ChanceWorst,
|
||||
double PotencyChance, int InheritMin, int InheritMax, IReadOnlyList<string> Notes);
|
||||
|
||||
internal static class IltBreedingPlanner
|
||||
{
|
||||
/// <summary>
|
||||
/// Plans one pairing. Each stat line comes from one parent, so the baby inherits between the
|
||||
/// sum of the lower lines and the sum of the higher lines; more inherited mutations lower the
|
||||
/// stat mutation chance (the decay), so the best case is the fewest.
|
||||
/// </summary>
|
||||
public static BreedPairPlan Plan(BreedEssence stud, BreedEssence dam, IltBreedingRules r)
|
||||
{
|
||||
var blockers = new List<string>();
|
||||
if (!stud.Male) blockers.Add($"{stud.Name} is female: the stud must be male.");
|
||||
if (dam.Male) blockers.Add($"{dam.Name} is male: the dam must be female.");
|
||||
if (stud.Id == dam.Id) blockers.Add("Pick two different essences.");
|
||||
foreach (string p in stud.Problems) blockers.Add($"{stud.Name}: {p}");
|
||||
foreach (string p in dam.Problems) blockers.Add($"{dam.Name}: {p}");
|
||||
|
||||
int lo = Math.Min(stud.MutD, dam.MutD) + Math.Min(stud.MutDR, dam.MutDR) + Math.Min(stud.MutC, dam.MutC) + Math.Min(stud.MutV, dam.MutV);
|
||||
int hi = Math.Max(stud.MutD, dam.MutD) + Math.Max(stud.MutDR, dam.MutDR) + Math.Max(stud.MutC, dam.MutC) + Math.Max(stud.MutV, dam.MutV);
|
||||
double incense = r.CombinedIncense(stud.Incense, dam.Incense);
|
||||
|
||||
var notes = new List<string>
|
||||
{
|
||||
"The baby goes to the dam's owner: they need a free main-pack slot and burden room.",
|
||||
$"Both pets in the same room of the breeding area ({r.RoomText()}); both owners *dance* within {r.Get(IltBreedingRules.DanceWindow):0.#}s.",
|
||||
};
|
||||
if (stud.Catalyst || dam.Catalyst) notes.Add("Chromatic Catalyst: the baby rolls a fresh colour.");
|
||||
if (r.Get(IltBreedingRules.GuardianEnabled) >= 0.5)
|
||||
notes.Add(stud.Offering || dam.Offering
|
||||
? "Offering of Subjugation applied: the mating guardian comes weakened."
|
||||
: $"A mating guardian rises: kill it within {r.Get(IltBreedingRules.GuardianSeconds):0}s for an Awakened Blessing mutation.");
|
||||
if (incense > 0) notes.Add($"Incense +{incense * 100:0.#}% is used up by this breed.");
|
||||
|
||||
return new BreedPairPlan(blockers.Count == 0, blockers, incense,
|
||||
r.StatMutationChance(lo, incense), r.StatMutationChance(hi, incense),
|
||||
Math.Clamp(r.Get(IltBreedingRules.PotencyMutation), 0, 1), lo, hi, notes);
|
||||
}
|
||||
}
|
||||
445
Plugins/RynthCore.Plugin.RynthILT/Hub/IltBreedingRules.cs
Normal file
445
Plugins/RynthCore.Plugin.RynthILT/Hub/IltBreedingRules.cs
Normal file
|
|
@ -0,0 +1,445 @@
|
|||
// IltBreedingRules.cs - Infinite Leaftide's pet breeding rules as RynthILT knows them.
|
||||
//
|
||||
// ACECustom's breeding (Source/ACE.Server/WorldObjects/PetDevice_Breeding.cs, docs/PET_BREEDING_*.md)
|
||||
// is driven by ServerConfig values the client is never sent. Each rule here therefore has three
|
||||
// possible sources, best last:
|
||||
// * ACE default - the ServerConfig default in ACECustom;
|
||||
// * ILT profile - what Infinite Leaftide runs (deploy/PROD_DEPLOY_PLAN.md: decay 0.1, the
|
||||
// mating guardian on, pet bond on, the Seedy Motel room);
|
||||
// * seen on server - read back from this server's own text: the appraisal breeding block
|
||||
// ("Sex: Male (9/10 breeding charges today) - refills in 3h 10m", "Growth: ..."),
|
||||
// "@breed-debug" ("Allowed Target: whole landblock 0x106, Variant=2"), and
|
||||
// breeding chat ("spent a breeding charge: 9/10 left today", "They have 90s ...").
|
||||
// A value seen on the server is saved with the character (IltPetState.Breeding) and wins from then on.
|
||||
//
|
||||
// Pure: no host calls, so RynthILT.Tests checks every parser offline.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
/// <summary>Where a breeding rule's value came from (later = more trusted).</summary>
|
||||
internal enum BreedRuleSource { AceDefault = 0, IltProfile = 1, Server = 2 }
|
||||
|
||||
/// <summary>One rule: stable key, label, unit, the ACE default and the ILT profile value (null = same as ACE).</summary>
|
||||
internal sealed record BreedRuleDef(string Key, string Label, string Unit, double AceDefault, double? IltProfile, string Help);
|
||||
|
||||
/// <summary>A rule's effective value and where it came from.</summary>
|
||||
internal readonly record struct BreedRuleValue(BreedRuleDef Def, double Value, BreedRuleSource Source, DateTime SeenUtc);
|
||||
|
||||
/// <summary>A value this server showed, saved with the character.</summary>
|
||||
public sealed class IltLearnedRule
|
||||
{
|
||||
public string Key = string.Empty;
|
||||
public double Value;
|
||||
public DateTime SeenUtc;
|
||||
}
|
||||
|
||||
/// <summary>One breeding event from chat (ritual, birth, growth, ...), newest last.</summary>
|
||||
public sealed class IltBreedingEvent
|
||||
{
|
||||
public DateTime Utc;
|
||||
/// <summary>ritual, charge, birth, mutation, guardian, growth, adult, imprint, dance, debug.</summary>
|
||||
public string Kind = string.Empty;
|
||||
public string Text = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>The breeding tracker's saved part (IltPetState.Breeding).</summary>
|
||||
public sealed class IltBreedingState
|
||||
{
|
||||
/// <summary>Rules read back from this server (see IltBreedingRules).</summary>
|
||||
public List<IltLearnedRule> Rules = new();
|
||||
/// <summary>Growth stage names this server uses, by stage (index 0 = stage 1); "" = not seen yet.</summary>
|
||||
public List<string> StageNames = new();
|
||||
/// <summary>Recent breeding events (capped at IltBreedingRules.MaxEvents).</summary>
|
||||
public List<IltBreedingEvent> Log = new();
|
||||
/// <summary>The last "@breed-debug" reply's lines and when it came.</summary>
|
||||
public List<string> LastDebug = new();
|
||||
public DateTime LastDebugUtc;
|
||||
}
|
||||
|
||||
/// <summary>What one "@breed-debug" reply said.</summary>
|
||||
internal sealed record BreedDebugInfo(bool? Enabled, string Location, uint AllowedLandblock, int AllowedVariant, string AllowedKind,
|
||||
bool? LocationOk, string ActivePet, string PetSex, int Partners);
|
||||
|
||||
internal sealed class IltBreedingRules
|
||||
{
|
||||
// ── Rule keys ───────────────────────────────────────────────────────────
|
||||
public const string Landblock = "landblock";
|
||||
public const string Variant = "variant";
|
||||
public const string DanceWindow = "dance_window_s";
|
||||
public const string MinTier = "min_tier";
|
||||
public const string MinBond = "min_bond";
|
||||
public const string MaleCharges = "male_charges";
|
||||
public const string MaleRefillHours = "male_refill_h";
|
||||
public const string FemaleRestHours = "female_rest_h";
|
||||
public const string BaseMutation = "base_mutation";
|
||||
public const string MutationDecay = "mutation_decay";
|
||||
public const string MutationFloor = "mutation_floor";
|
||||
public const string PotencyMutation = "potency_mutation";
|
||||
public const string IncenseCap = "incense_cap";
|
||||
public const string Inheritance = "inheritance";
|
||||
public const string GuardianEnabled = "guardian_enabled";
|
||||
public const string GuardianSeconds = "guardian_s";
|
||||
public const string MaturityKills = "maturity_kills";
|
||||
public const string MaturityStages = "maturity_stages";
|
||||
public const string MaturityShare = "maturity_share";
|
||||
|
||||
/// <summary>Breeding events kept with the character.</summary>
|
||||
public const int MaxEvents = 60;
|
||||
|
||||
/// <summary>ACECustom's default growth stage names (pet_maturity_stage_names).</summary>
|
||||
public static readonly string[] DefaultStageNames = { "Newborn", "Whelp", "Juvenile", "Adolescent", "Young Adult" };
|
||||
|
||||
/// <summary>Every rule shown, in display order. Values copied from ACECustom ServerConfig and the ILT deploy plan.</summary>
|
||||
public static readonly BreedRuleDef[] Defs =
|
||||
{
|
||||
new(Landblock, "Breeding room landblock", "hex", 0x0106, null,
|
||||
"pet_breeding_allowed_landblock: the Seedy Motel (Ruggan's Annex, portal by Prof. Ruggan in Lin 54.7S 73.5E)."),
|
||||
new(Variant, "Breeding room variant", "", 2, null, "pet_breeding_allowed_variant: the landblock variant the room is in."),
|
||||
new(DanceWindow, "Dance window", "s", 5, null, "Both owners must *dance* (or @dance) within this many seconds."),
|
||||
new(MinTier, "Minimum essence tier", "", 100, null, "Both parents must be at least this tier (50, 80, 100, ... 300)."),
|
||||
new(MinBond, "Minimum bond", "", 100, null, "Both parents need this bond level (bond grows from kills; pet_bond must be on)."),
|
||||
new(MaleCharges, "Stud charges", "", 10, null, "pet_breeding_male_max_charges: breeds a male can sire per refill."),
|
||||
new(MaleRefillHours, "Stud refill", "h", 24, null, "pet_breeding_male_charge_reset_hours: charges refill this long after the last refill."),
|
||||
new(FemaleRestHours, "Dam rest", "h", 4, null, "A female rests this long after each breed before she can breed again."),
|
||||
new(BaseMutation, "Stat mutation chance", "%", 0.05, null, "pet_breeding_mutation_chance: the base chance of a stat mutation."),
|
||||
new(MutationDecay, "Mutation decay", "", 0.0, 0.1,
|
||||
"pet_breeding_mutation_decay: each stat mutation the baby inherits divides the chance by (1 + decay x mutations)."),
|
||||
new(MutationFloor, "Mutation floor", "%", 0.02, null, "The stat mutation chance never drops below this."),
|
||||
new(PotencyMutation, "Potency mutation chance", "%", 0.03, null, "An independent roll for a potency mutation."),
|
||||
new(IncenseCap, "Incense cap", "%", 0.50, null, "Both parents' incense together adds at most this much."),
|
||||
new(Inheritance, "Dominant line weight", "%", 0.55, null, "Each stat line comes from one parent, 55 / 45."),
|
||||
new(GuardianEnabled, "Mating guardian", "on/off", 0, 1,
|
||||
"pet_breeding_guardian_enabled: a spirit rises after the ritual; killing it in time grants an Awakened Blessing mutation."),
|
||||
new(GuardianSeconds, "Guardian timer", "s", 90, null, "How long the two parents have to kill the guardian."),
|
||||
new(MaturityKills, "Kills to adulthood", "", 300, null, "pet_maturity_kills_required: a bred baby grows up with this many credited kills."),
|
||||
new(MaturityStages, "Growth stages", "", 5, null, "pet_maturity_stages: the growth stages before Adult."),
|
||||
new(MaturityShare, "Kill credit share", "%", 0.10, null,
|
||||
"A kill counts when the pet dealt this share of the victim's health and the victim's level is at least the essence tier."),
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, BreedRuleDef> DefByKey = BuildIndex();
|
||||
|
||||
private static Dictionary<string, BreedRuleDef> BuildIndex()
|
||||
{
|
||||
var d = new Dictionary<string, BreedRuleDef>(StringComparer.Ordinal);
|
||||
foreach (BreedRuleDef def in Defs) d[def.Key] = def;
|
||||
return d;
|
||||
}
|
||||
|
||||
private readonly IltBreedingState _state;
|
||||
|
||||
/// <param name="state">The saved breeding state; learned values are read from and written to it.</param>
|
||||
public IltBreedingRules(IltBreedingState state) => _state = state;
|
||||
|
||||
/// <summary>The saved state these rules read and update.</summary>
|
||||
public IltBreedingState State => _state;
|
||||
|
||||
/// <summary>A copy that never changes (the render thread reads it while the pump learns).</summary>
|
||||
public IltBreedingRules Frozen()
|
||||
{
|
||||
var copy = new IltBreedingState { StageNames = new List<string>(_state.StageNames) };
|
||||
foreach (IltLearnedRule l in _state.Rules)
|
||||
copy.Rules.Add(new IltLearnedRule { Key = l.Key, Value = l.Value, SeenUtc = l.SeenUtc });
|
||||
return new IltBreedingRules(copy);
|
||||
}
|
||||
|
||||
/// <summary>The effective value of rule <paramref name="key"/> (0 for an unknown key).</summary>
|
||||
public double Get(string key) => Value(key).Value;
|
||||
|
||||
/// <summary>A whole-number rule (charges, kills, tiers).</summary>
|
||||
public int GetInt(string key) => (int)Math.Round(Get(key));
|
||||
|
||||
/// <summary>The effective value and its source.</summary>
|
||||
public BreedRuleValue Value(string key)
|
||||
{
|
||||
if (!DefByKey.TryGetValue(key, out BreedRuleDef? def))
|
||||
return new BreedRuleValue(new BreedRuleDef(key, key, "", 0, null, ""), 0, BreedRuleSource.AceDefault, default);
|
||||
foreach (IltLearnedRule l in _state.Rules)
|
||||
if (l.Key == key) return new BreedRuleValue(def, l.Value, BreedRuleSource.Server, l.SeenUtc);
|
||||
return def.IltProfile.HasValue
|
||||
? new BreedRuleValue(def, def.IltProfile.Value, BreedRuleSource.IltProfile, default)
|
||||
: new BreedRuleValue(def, def.AceDefault, BreedRuleSource.AceDefault, default);
|
||||
}
|
||||
|
||||
/// <summary>Every rule's effective value, in display order.</summary>
|
||||
public List<BreedRuleValue> All()
|
||||
{
|
||||
var list = new List<BreedRuleValue>(Defs.Length);
|
||||
foreach (BreedRuleDef d in Defs) list.Add(Value(d.Key));
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>Records a value the server showed. True when it changed what RynthILT knew.</summary>
|
||||
public bool Learn(string key, double value, DateTime utc)
|
||||
{
|
||||
if (!DefByKey.ContainsKey(key) || double.IsNaN(value) || double.IsInfinity(value)) return false;
|
||||
foreach (IltLearnedRule l in _state.Rules)
|
||||
{
|
||||
if (l.Key != key) continue;
|
||||
bool changed = Math.Abs(l.Value - value) > 1e-9;
|
||||
l.Value = value;
|
||||
l.SeenUtc = utc;
|
||||
return changed;
|
||||
}
|
||||
_state.Rules.Add(new IltLearnedRule { Key = key, Value = value, SeenUtc = utc });
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Applies every (key, value) an observer returned. True when anything changed.</summary>
|
||||
public bool LearnAll(IEnumerable<(string Key, double Value)> seen, DateTime utc)
|
||||
{
|
||||
bool changed = false;
|
||||
foreach ((string k, double v) in seen) changed |= Learn(k, v, utc);
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>Records a growth stage's name (1-based) as the server spelled it.</summary>
|
||||
public bool LearnStageName(int stage, string name)
|
||||
{
|
||||
name = (name ?? string.Empty).Trim();
|
||||
if (stage < 1 || stage > 50 || name.Length == 0 || name.Length > 40) return false;
|
||||
while (_state.StageNames.Count < stage) _state.StageNames.Add(string.Empty);
|
||||
if (_state.StageNames[stage - 1] == name) return false;
|
||||
_state.StageNames[stage - 1] = name;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>The name of growth stage <paramref name="stage"/> (1-based): seen on the server, else ACE's default, else "Stage N".</summary>
|
||||
public string StageName(int stage)
|
||||
{
|
||||
if (stage >= 1 && stage <= _state.StageNames.Count && _state.StageNames[stage - 1].Length > 0)
|
||||
return _state.StageNames[stage - 1];
|
||||
if (stage >= 1 && stage <= DefaultStageNames.Length && GetInt(MaturityStages) == DefaultStageNames.Length)
|
||||
return DefaultStageNames[stage - 1];
|
||||
return "Stage " + stage.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>Appends an event, dropping the oldest past <see cref="MaxEvents"/>.</summary>
|
||||
public void AddEvent(string kind, string text, DateTime utc)
|
||||
{
|
||||
_state.Log.Add(new IltBreedingEvent { Utc = utc, Kind = kind, Text = text });
|
||||
if (_state.Log.Count > MaxEvents) _state.Log.RemoveRange(0, _state.Log.Count - MaxEvents);
|
||||
}
|
||||
|
||||
// ── Mutation odds (ACE PetDevice_Breeding) ──────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// The chance of a stat mutation for a baby that inherits <paramref name="babyStatMutations"/>
|
||||
/// stat mutations, with <paramref name="incense"/> from both parents (already capped):
|
||||
/// clamp(max(floor, (base + incense) / (1 + decay x mutations)), 0, 1).
|
||||
/// </summary>
|
||||
public double StatMutationChance(int babyStatMutations, double incense)
|
||||
{
|
||||
double decay = Math.Max(0, Get(MutationDecay));
|
||||
double raw = (Get(BaseMutation) + Math.Max(0, incense)) / (1.0 + decay * Math.Max(0, babyStatMutations));
|
||||
return Math.Clamp(Math.Max(Get(MutationFloor), raw), 0.0, 1.0);
|
||||
}
|
||||
|
||||
/// <summary>Both parents' incense together, capped at the incense cap.</summary>
|
||||
public double CombinedIncense(double a, double b) => Math.Clamp(Math.Max(0, a) + Math.Max(0, b), 0.0, Math.Max(0, Get(IncenseCap)));
|
||||
|
||||
// ── Observers: what the server's own text says about its rules ──────────
|
||||
|
||||
private const RegexOptions Rx = RegexOptions.CultureInvariant | RegexOptions.IgnoreCase;
|
||||
|
||||
private static readonly Regex MaleLine = new(@"Sex:\s*Male\s*\((\d+)\s*/\s*(\d+) breeding charges today\)(?:\s*-\s*refills in (?:(\d+)h\s*)?(?:(\d+)m)?)?", Rx);
|
||||
private static readonly Regex GrowthLine = new(@"Growth:\s*(.+?)\s+(\d+)\s*/\s*(\d+)\s*-\s*(\d+) kills to (.+?)(?:,\s*(\d+) to Adult)?\s*$", Rx | RegexOptions.Multiline);
|
||||
private static readonly Regex ChargeSpent = new(@"spent a breeding charge:\s*(\d+)\s*/\s*(\d+) left today", Rx);
|
||||
private static readonly Regex GuardianRise = new(@"They have (\d+)s to bring it down together", Rx);
|
||||
private static readonly Regex GrownInto = new(@"has grown into an? (.+?)!.*\((\d+)\s*/\s*(\d+)\)", Rx);
|
||||
private static readonly Regex DanceWindowLine = new(@"\*dance\* within (\d+(?:\.\d+)?) seconds", Rx);
|
||||
private static readonly Regex DebugEnabled = new(@"Breeding System Enabled:\s*(True|False)", Rx);
|
||||
private static readonly Regex DebugLocation = new(@"Your Location:\s*(.+)$", Rx);
|
||||
private static readonly Regex DebugAllowed = new(@"Allowed Target:\s*(anywhere|whole landblock|exact cell)\s*0x([0-9A-F]+),\s*Variant=(-?\d+)\s*=>\s*Location Match:\s*(VALID|INVALID)", Rx);
|
||||
private static readonly Regex DebugPet = new(@"Your Active Pet:\s*(.+)$", Rx);
|
||||
private static readonly Regex DebugSex = new(@"^\s*Sex:\s*(.+)$", Rx);
|
||||
private static readonly Regex DebugPartners = new(@"(?:Eligible breeding partners nearby|Valid Partner Candidates within 30m):\s*(\d+)", Rx);
|
||||
|
||||
/// <summary>
|
||||
/// What an essence's appraisal text says: the stud's charge max and refill window (from the
|
||||
/// "refills in" countdown against the essence's last refill time), and the growth stage count.
|
||||
/// </summary>
|
||||
/// <param name="longDesc">The appraisal LongDesc (string 16).</param>
|
||||
/// <param name="maleRefreshUnix">The essence's PetMaleChargesRefreshTime (0 = not sent).</param>
|
||||
/// <param name="nowUnix">Now, unix seconds.</param>
|
||||
public static List<(string Key, double Value)> FromAppraisal(string longDesc, double maleRefreshUnix, double nowUnix)
|
||||
{
|
||||
var seen = new List<(string, double)>();
|
||||
if (string.IsNullOrEmpty(longDesc)) return seen;
|
||||
|
||||
Match m = MaleLine.Match(longDesc);
|
||||
if (m.Success)
|
||||
{
|
||||
if (int.TryParse(m.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int max) && max > 0 && max < 1000)
|
||||
seen.Add((MaleCharges, max));
|
||||
if ((m.Groups[3].Success || m.Groups[4].Success) && maleRefreshUnix > 0)
|
||||
{
|
||||
int h = m.Groups[3].Success ? int.Parse(m.Groups[3].Value, CultureInfo.InvariantCulture) : 0;
|
||||
int min = m.Groups[4].Success ? int.Parse(m.Groups[4].Value, CultureInfo.InvariantCulture) : 0;
|
||||
double refillAt = nowUnix + h * 3600.0 + min * 60.0;
|
||||
double hours = Math.Round((refillAt - maleRefreshUnix) / 3600.0);
|
||||
// The countdown is minute-rounded; only a whole-hour window that makes sense is taken.
|
||||
if (hours >= 1 && hours <= 24 * 14) seen.Add((MaleRefillHours, hours));
|
||||
}
|
||||
}
|
||||
|
||||
Match g = GrowthLine.Match(longDesc);
|
||||
if (g.Success && int.TryParse(g.Groups[3].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int stages) && stages >= 1 && stages <= 50)
|
||||
seen.Add((MaturityStages, stages));
|
||||
return seen;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The growth line of an appraisal: current stage name, stage, stages, kills to the next stage
|
||||
/// and to adulthood (-1 when the line has no "to Adult" part, i.e. the last stage).
|
||||
/// </summary>
|
||||
public static bool TryParseGrowth(string longDesc, out string stageName, out int stage, out int stages, out int toNext, out string nextName, out int toAdult)
|
||||
{
|
||||
stageName = nextName = string.Empty;
|
||||
stage = stages = toNext = toAdult = 0;
|
||||
if (string.IsNullOrEmpty(longDesc)) return false;
|
||||
Match g = GrowthLine.Match(longDesc);
|
||||
if (!g.Success) return false;
|
||||
stageName = g.Groups[1].Value.Trim();
|
||||
int.TryParse(g.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out stage);
|
||||
int.TryParse(g.Groups[3].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out stages);
|
||||
int.TryParse(g.Groups[4].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out toNext);
|
||||
nextName = g.Groups[5].Value.Trim();
|
||||
if (g.Groups[6].Success) int.TryParse(g.Groups[6].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out toAdult);
|
||||
else { toAdult = toNext; nextName = "Adult"; }
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>What one chat line says about the rules (a line can say nothing).</summary>
|
||||
public static List<(string Key, double Value)> FromChat(string line)
|
||||
{
|
||||
var seen = new List<(string, double)>();
|
||||
if (string.IsNullOrEmpty(line)) return seen;
|
||||
|
||||
Match m = ChargeSpent.Match(line);
|
||||
if (m.Success && int.TryParse(m.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int max) && max > 0 && max < 1000)
|
||||
seen.Add((MaleCharges, max));
|
||||
|
||||
m = GuardianRise.Match(line);
|
||||
if (m.Success)
|
||||
{
|
||||
seen.Add((GuardianEnabled, 1));
|
||||
if (int.TryParse(m.Groups[1].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int s) && s > 0 && s < 3600)
|
||||
seen.Add((GuardianSeconds, s));
|
||||
}
|
||||
else if (line.Contains("The union stirs something", StringComparison.OrdinalIgnoreCase))
|
||||
seen.Add((GuardianEnabled, 1));
|
||||
|
||||
m = GrownInto.Match(line);
|
||||
if (m.Success && int.TryParse(m.Groups[3].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int stages) && stages >= 1 && stages <= 50)
|
||||
seen.Add((MaturityStages, stages));
|
||||
|
||||
m = DanceWindowLine.Match(line);
|
||||
if (m.Success && double.TryParse(m.Groups[1].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out double w) && w > 0 && w < 600)
|
||||
seen.Add((DanceWindow, w));
|
||||
|
||||
foreach (string part in line.Split('\n'))
|
||||
{
|
||||
m = DebugAllowed.Match(part);
|
||||
if (!m.Success) continue;
|
||||
if (uint.TryParse(m.Groups[2].Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint lb))
|
||||
seen.Add((Landblock, lb));
|
||||
if (int.TryParse(m.Groups[3].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int v))
|
||||
seen.Add((Variant, v));
|
||||
}
|
||||
return seen;
|
||||
}
|
||||
|
||||
/// <summary>The stage name a "has grown into a Whelp! ... (2/5)" line gives, with its stage number; false for any other line.</summary>
|
||||
public static bool TryParseGrownInto(string line, out int stage, out string name)
|
||||
{
|
||||
stage = 0;
|
||||
name = string.Empty;
|
||||
Match m = GrownInto.Match(line ?? string.Empty);
|
||||
if (!m.Success || !int.TryParse(m.Groups[2].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out stage)) return false;
|
||||
name = m.Groups[1].Value.Trim();
|
||||
return name.Length > 0;
|
||||
}
|
||||
|
||||
/// <summary>True for any line of an "@breed-debug" reply (one multi-line message, or its lines one by one).</summary>
|
||||
public static bool IsDebugLine(string text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return false;
|
||||
return text.Contains("PET BREEDING DIAGNOSTICS", StringComparison.OrdinalIgnoreCase)
|
||||
|| DebugEnabled.IsMatch(text) || DebugLocation.IsMatch(text) || DebugAllowed.IsMatch(text)
|
||||
|| DebugPet.IsMatch(text) || DebugPartners.IsMatch(text)
|
||||
|| text.TrimStart().StartsWith("Sex:", StringComparison.OrdinalIgnoreCase)
|
||||
|| text.Contains("Ensure your partner has their pet summoned", StringComparison.OrdinalIgnoreCase)
|
||||
|| IsDebugEnd(text);
|
||||
}
|
||||
|
||||
/// <summary>The reply's closing rule of '=' (alone, or ending the whole message).</summary>
|
||||
public static bool IsDebugEnd(string text)
|
||||
=> !string.IsNullOrEmpty(text) && text.TrimEnd().EndsWith("================================", StringComparison.Ordinal);
|
||||
|
||||
/// <summary>Parses an "@breed-debug" reply (any mix of whole messages and single lines).</summary>
|
||||
public static BreedDebugInfo ParseDebug(IEnumerable<string> lines)
|
||||
{
|
||||
bool? enabled = null, ok = null;
|
||||
string location = string.Empty, kind = string.Empty, pet = string.Empty, sex = string.Empty;
|
||||
uint lb = 0;
|
||||
int variant = -1, partners = -1;
|
||||
foreach (string text in lines)
|
||||
{
|
||||
foreach (string raw in (text ?? string.Empty).Split('\n'))
|
||||
{
|
||||
string l = raw.TrimEnd('\r');
|
||||
Match m;
|
||||
if ((m = DebugEnabled.Match(l)).Success) enabled = m.Groups[1].Value.Equals("True", StringComparison.OrdinalIgnoreCase);
|
||||
else if ((m = DebugAllowed.Match(l)).Success)
|
||||
{
|
||||
kind = m.Groups[1].Value.ToLowerInvariant();
|
||||
uint.TryParse(m.Groups[2].Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out lb);
|
||||
int.TryParse(m.Groups[3].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out variant);
|
||||
ok = m.Groups[4].Value.Equals("VALID", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
else if ((m = DebugLocation.Match(l)).Success) location = m.Groups[1].Value.Trim();
|
||||
else if ((m = DebugPet.Match(l)).Success) pet = m.Groups[1].Value.Trim();
|
||||
else if ((m = DebugPartners.Match(l)).Success) int.TryParse(m.Groups[1].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out partners);
|
||||
else if ((m = DebugSex.Match(l)).Success) sex = m.Groups[1].Value.Trim();
|
||||
}
|
||||
}
|
||||
return new BreedDebugInfo(enabled, location, lb, variant, kind, ok, pet, sex, partners);
|
||||
}
|
||||
|
||||
/// <summary>"0x0106 variant 2" (or "anywhere") for the rules list.</summary>
|
||||
public string RoomText()
|
||||
{
|
||||
uint lb = (uint)Math.Max(0, Get(Landblock));
|
||||
int variant = GetInt(Variant);
|
||||
if (lb == 0) return "anywhere";
|
||||
string place = lb > 0xFFFF ? "cell 0x" + lb.ToString("X8", CultureInfo.InvariantCulture) : "landblock 0x" + lb.ToString("X4", CultureInfo.InvariantCulture);
|
||||
return variant >= 0 ? place + " variant " + variant.ToString(CultureInfo.InvariantCulture) : place;
|
||||
}
|
||||
|
||||
/// <summary>A rule value for display: "5%", "24h", "0x0106", "on", "10".</summary>
|
||||
public static string Format(BreedRuleValue v)
|
||||
{
|
||||
switch (v.Def.Unit)
|
||||
{
|
||||
case "%": return (v.Value * 100.0).ToString("0.##", CultureInfo.InvariantCulture) + "%";
|
||||
case "h": return v.Value.ToString("0.#", CultureInfo.InvariantCulture) + "h";
|
||||
case "s": return v.Value.ToString("0.#", CultureInfo.InvariantCulture) + "s";
|
||||
case "hex": return "0x" + ((uint)Math.Max(0, v.Value)).ToString("X4", CultureInfo.InvariantCulture);
|
||||
case "on/off": return v.Value >= 0.5 ? "on" : "off";
|
||||
default: return v.Value.ToString("0.##", CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>"ACE default", "ILT profile" or "seen on server".</summary>
|
||||
public static string SourceText(BreedRuleSource s) => s switch
|
||||
{
|
||||
BreedRuleSource.Server => "seen on server",
|
||||
BreedRuleSource.IltProfile => "ILT profile",
|
||||
_ => "ACE default",
|
||||
};
|
||||
}
|
||||
112
Plugins/RynthCore.Plugin.RynthILT/Hub/IltBreedingSupplies.cs
Normal file
112
Plugins/RynthCore.Plugin.RynthILT/Hub/IltBreedingSupplies.cs
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
// IltBreedingSupplies.cs - Ivo's breeding supplies (ACECustom, Seedy Motel vendor) and when each can
|
||||
// be used on an essence.
|
||||
//
|
||||
// WCIDs, prices and refusals copied from ACECustom (Player_Use.cs HandleActionUseOnTarget, the
|
||||
// PetDevice.BreedingMath incense constants, docs/PET_BREEDING_PLAYER_GUIDE.md). RynthILT applies
|
||||
// only the breeding boosters (incense, Nurturing Draught, Chromatic Catalyst, Offering of
|
||||
// Subjugation), and only after the player confirms; the Neutering Kit is permanent and the kits,
|
||||
// serum and tinctures are cosmetic, so those are counted, never used from here.
|
||||
//
|
||||
// Pure: RynthILT.Tests checks the refusals offline.
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
/// <summary>One supply: key, WCID, name, what it does, Ivo's price, and whether the tracker can apply it.</summary>
|
||||
internal sealed record BreedSupplyDef(string Key, uint Wcid, string Name, string Effect, long Price, bool Apply);
|
||||
|
||||
internal static class IltBreedingSupplies
|
||||
{
|
||||
public const string LesserIncense = "incense1";
|
||||
public const string RefinedIncense = "incense2";
|
||||
public const string ExquisiteIncense = "incense3";
|
||||
public const string Draught = "draught";
|
||||
public const string Catalyst = "catalyst";
|
||||
public const string Offering = "offering";
|
||||
public const string NeuteringKit = "neuter";
|
||||
public const string TailoringKit = "tailor";
|
||||
public const string FilledTailoringKit = "tailor_filled";
|
||||
public const string Serum = "serum";
|
||||
public const string Solidifying = "solidify";
|
||||
public const string Fading = "fade";
|
||||
|
||||
/// <summary>Every supply, boosters first.</summary>
|
||||
public static readonly BreedSupplyDef[] All =
|
||||
{
|
||||
new(LesserIncense, 78780250, "Lesser Courtship Incense", "+2.5% stat mutation chance on the next breed.", 1_250_000, true),
|
||||
new(RefinedIncense, 78780251, "Refined Courtship Incense", "+5% stat mutation chance on the next breed.", 2_500_000, true),
|
||||
new(ExquisiteIncense, 78780252, "Exquisite Courtship Incense", "+10% stat mutation chance on the next breed.", 5_000_000, true),
|
||||
new(Draught, 78780253, "Nurturing Draught", "A juvenile earns 2x maturity kill credit until adulthood.", 2_500_000, true),
|
||||
new(Catalyst, 78780254, "Chromatic Catalyst", "The next baby rolls a fresh colour.", 2_500_000, true),
|
||||
new(Offering, 78780255, "Offering of Subjugation", "The next mating guardian comes weakened.", 2_500_000, true),
|
||||
new(NeuteringKit, 78780258, "Neutering Kit", "Permanently stops an essence from breeding.", 2_500_000, false),
|
||||
new(TailoringKit, 78780259, "Tailoring Kit", "Extracts an essence's appearance.", 125_000_000, false),
|
||||
new(FilledTailoringKit, 78780260, "Filled Tailoring Kit", "Applies an extracted appearance.", 0, false),
|
||||
new(Serum, 78780257, "Mutagenic Serum", "Re-rolls an essence's colour.", 25_000_000, false),
|
||||
new(Solidifying, 78780262, "Solidifying Tincture", "Makes the summoned pet less translucent.", 12_500_000, false),
|
||||
new(Fading, 78780263, "Fading Tincture", "Makes the summoned pet more translucent.", 12_500_000, false),
|
||||
};
|
||||
|
||||
/// <summary>The supply with this key, or null.</summary>
|
||||
public static BreedSupplyDef? Find(string key) => Array.Find(All, s => s.Key == key);
|
||||
|
||||
/// <summary>The incense bonus a supply gives (0 for anything else).</summary>
|
||||
public static double IncenseBonus(string key) => key switch
|
||||
{
|
||||
LesserIncense => 0.025,
|
||||
RefinedIncense => 0.05,
|
||||
ExquisiteIncense => 0.10,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
/// <summary>"Refined incense +5%" for an applied bonus.</summary>
|
||||
public static string IncenseName(double bonus)
|
||||
{
|
||||
string grade = bonus >= 0.0999 ? "Exquisite" : bonus >= 0.0499 ? "Refined" : "Lesser";
|
||||
return $"{grade} incense +{(bonus * 100).ToString("0.#", CultureInfo.InvariantCulture)}%";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Why the server would refuse <paramref name="s"/> on <paramref name="e"/> (the server's own
|
||||
/// checks, so nothing is spent on a refusal), or null when it would take it.
|
||||
/// </summary>
|
||||
public static string? RefuseReason(BreedSupplyDef s, BreedEssence e, IltBreedingRules r)
|
||||
{
|
||||
if (!s.Apply) return "Not applied from here.";
|
||||
double incense = IncenseBonus(s.Key);
|
||||
if (incense > 0)
|
||||
{
|
||||
if (e.Gate == BreedGate.Neutered) return "A neutered essence can't take incense.";
|
||||
if (e.Incense >= incense - 1e-6) return $"Already primed with equal or stronger incense (+{e.Incense * 100:0.#}%).";
|
||||
return null;
|
||||
}
|
||||
return s.Key switch
|
||||
{
|
||||
Draught when !e.Juvenile => "Only a juvenile (still growing) can take a Nurturing Draught.",
|
||||
Draught when e.Draught => "Already under a Nurturing Draught.",
|
||||
Catalyst when e.Catalyst => "Already infused with a Chromatic Catalyst.",
|
||||
Offering when r.Get(IltBreedingRules.GuardianEnabled) < 0.5 => "Mating guardians are off on this server.",
|
||||
Offering when e.Offering => "Already under an Offering of Subjugation.",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>A warning to show in the confirmation (a weaker incense being replaced), or "".</summary>
|
||||
public static string Warning(BreedSupplyDef s, BreedEssence e)
|
||||
{
|
||||
double incense = IncenseBonus(s.Key);
|
||||
if (incense > 0 && e.Incense > 0 && e.Incense < incense)
|
||||
return $" It replaces the +{e.Incense * 100:0.#}% incense already on it (that one is lost).";
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>"1.25M", "125M", "-" for a price.</summary>
|
||||
public static string PriceText(long price)
|
||||
{
|
||||
if (price <= 0) return "-";
|
||||
if (price >= 1_000_000) return (price / 1_000_000.0).ToString("0.##", CultureInfo.InvariantCulture) + "M";
|
||||
if (price >= 1_000) return (price / 1_000.0).ToString("0.#", CultureInfo.InvariantCulture) + "k";
|
||||
return price.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
|
|
@ -214,9 +215,9 @@ internal sealed class IltBuffKeepers : IIltFeature
|
|||
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);
|
||||
SafeImGui.TextDisabled("Status: " + _dispelStatus);
|
||||
var harm = _harmfulNow;
|
||||
if (harm.Length > 0) ImGui.TextColored(IltStyle.ColAmber, "Harmful now: " + string.Join(", ", harm));
|
||||
if (harm.Length > 0) SafeImGui.TextColored(IltStyle.ColAmber, "Harmful now: " + string.Join(", ", harm));
|
||||
if (ImGui.TreeNode("Always / never dispel lists"))
|
||||
{
|
||||
EditList("Always dispel (name contains)", G.DispelInclusions, ref _newInclude, "inc");
|
||||
|
|
@ -228,7 +229,7 @@ internal sealed class IltBuffKeepers : IIltFeature
|
|||
ImGui.TextColored(IltStyle.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));
|
||||
SafeImGui.TextDisabled("Status: " + (_surgeActive ? "active" : _surgeStatus));
|
||||
}
|
||||
|
||||
private void EditList(string label, List<string> list, ref string buffer, string id)
|
||||
|
|
@ -237,7 +238,7 @@ internal sealed class IltBuffKeepers : IIltFeature
|
|||
var snap = list.ToArray();
|
||||
for (int i = 0; i < snap.Length; i++)
|
||||
{
|
||||
ImGui.BulletText(snap[i]);
|
||||
SafeImGui.BulletText(snap[i]);
|
||||
ImGui.SameLine();
|
||||
string victim = snap[i];
|
||||
if (ImGui.SmallButton($"x##{id}{i}")) _ctx.Post(() => list.Remove(victim));
|
||||
|
|
|
|||
|
|
@ -132,7 +132,9 @@ internal sealed class IltCharmTracker
|
|||
sb.Append(",\"server\":\"").Append(TriText(r.Server)).Append('"');
|
||||
sb.Append(",\"lastSeen\":\"")
|
||||
.Append(r.LastSeenUtc == default ? string.Empty : r.LastSeenUtc.ToString("yyyy-MM-dd"))
|
||||
.Append("\"}");
|
||||
.Append('"');
|
||||
// The carried copy a reader's Toggle uses ("RynthILT.Data" ToggleCharm); 0 = none carried.
|
||||
sb.Append(",\"toggleId\":").Append(unchecked((uint)r.ToggleId)).Append('}');
|
||||
}
|
||||
sb.Append("]}");
|
||||
return sb.ToString();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
// IltCharms.cs — The Mini Remote's "Charms" ILT tab: every ACECustom registry charm in one table.
|
||||
// IltCharms.cs — The Mini Remote's "Charms" ILT tab: every ACECustom registry charm and the
|
||||
// Guardian Hand, with their toggles. Other plugins read the same list and toggle through
|
||||
// "RynthILT.Data" (BuildReaderJson / ToggleFromReader).
|
||||
// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13.
|
||||
//
|
||||
// Per charm (IltCharmTracker): acquired ("carried" now, "stored" = carried before and remembered
|
||||
|
|
@ -14,6 +16,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
|
|
@ -68,6 +71,52 @@ internal sealed class IltCharms : IIltFeature
|
|||
_lastScan = 0; // re-read the status soon (the appraisal refresh is throttled per item)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A Toggle from another plugin ("RynthILT.Data" ToggleCharm). Only
|
||||
/// a registry charm or Guardian Hand the player carries is used, so a reader can't make the
|
||||
/// client use anything else. Pump thread. True when it was used.
|
||||
/// </summary>
|
||||
public bool ToggleFromReader(uint id)
|
||||
{
|
||||
if (id == 0 || id > int.MaxValue) return false;
|
||||
var inv = _ctx.Inventory;
|
||||
foreach (var wo in inv.Items())
|
||||
{
|
||||
if (wo.Id != (int)id) continue;
|
||||
if (inv.CharmDefFor(wo) == null && !IsGuardianHand(wo)) return false;
|
||||
Toggle(wo.Id);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The "RynthILT.Data" charms JSON: the registry charms
|
||||
/// (IltCharmTracker.BuildJson) plus a "hands" array, every Guardian Hand carried now with its
|
||||
/// object id (the Toggle's id), status and the server's switch. Pump thread.
|
||||
/// </summary>
|
||||
public string BuildReaderJson()
|
||||
{
|
||||
string json = _tracker.BuildJson();
|
||||
if (!_ctx.Options.IsIltLikeWorld || !json.EndsWith("]}", StringComparison.Ordinal)) return json;
|
||||
var inv = _ctx.Inventory;
|
||||
string server = _ctx.Options.Get(IltFeature.Charm("Guardian Hand")) switch { IltTri.On => "on", IltTri.Off => "off", _ => "unknown" };
|
||||
var sb = new System.Text.StringBuilder(json, 0, json.Length - 1, json.Length + 256);
|
||||
sb.Append(",\"hands\":[");
|
||||
bool first = true;
|
||||
foreach (var wo in inv.Items().Where(IsGuardianHand))
|
||||
{
|
||||
if (!first) sb.Append(',');
|
||||
first = false;
|
||||
string active = inv.CharmStatus(wo) switch { IltTri.On => "on", IltTri.Off => "off", _ => "unknown" };
|
||||
sb.Append("{\"id\":").Append(unchecked((uint)wo.Id));
|
||||
sb.Append(",\"name\":\"").Append(IltStyle.JsonEscape(wo.Name)).Append('"');
|
||||
sb.Append(",\"active\":\"").Append(active).Append('"');
|
||||
sb.Append(",\"server\":\"").Append(server).Append("\"}");
|
||||
}
|
||||
return sb.Append("]}").ToString();
|
||||
}
|
||||
|
||||
// ── IIltFeature ─────────────────────────────────────────────────────────
|
||||
|
||||
public void Tick(long nowMs)
|
||||
|
|
@ -93,13 +142,13 @@ internal sealed class IltCharms : IIltFeature
|
|||
var rows = _rows;
|
||||
if (rows.Length == 0)
|
||||
{
|
||||
ImGui.TextDisabled(_ctx.WindowOpen ? "Reading your charms..." : "Open the Mini Remote to read your charms.");
|
||||
SafeImGui.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(IltStyle.ColTeal, $"{acquired} of {rows.Length} acquired, {active} active");
|
||||
SafeImGui.TextColored(IltStyle.ColTeal, $"{acquired} of {rows.Length} acquired, {active} active");
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("Refresh##charms")) _ctx.Post(() => { _lastScan = 0; });
|
||||
|
||||
|
|
@ -133,16 +182,16 @@ internal sealed class IltCharms : IIltFeature
|
|||
ImGui.TableNextColumn();
|
||||
bool carried = r.Acquired == "carried";
|
||||
if (carried) ImGui.TextUnformatted(r.Def.Name);
|
||||
else ImGui.TextColored(IltStyle.ColTextMute, r.Def.Name);
|
||||
if (ImGui.IsItemHovered() && r.Def.Effect.Length > 0) ImGui.SetTooltip(r.Def.Effect);
|
||||
else SafeImGui.TextColored(IltStyle.ColTextMute, r.Def.Name);
|
||||
if (ImGui.IsItemHovered() && r.Def.Effect.Length > 0) SafeImGui.SetTooltip(r.Def.Effect);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (carried) ImGui.TextColored(IltStyle.ColGreen, r.Count > 1 ? $"Carried x{r.Count}" : "Carried");
|
||||
if (carried) SafeImGui.TextColored(IltStyle.ColGreen, r.Count > 1 ? $"Carried x{r.Count}" : "Carried");
|
||||
else if (r.Acquired == "seen")
|
||||
{
|
||||
ImGui.TextColored(IltStyle.ColAmber, "Stored");
|
||||
if (ImGui.IsItemHovered() && r.LastSeenUtc != default)
|
||||
ImGui.SetTooltip("Last carried " + r.LastSeenUtc.ToString("yyyy-MM-dd"));
|
||||
SafeImGui.SetTooltip("Last carried " + r.LastSeenUtc.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
else ImGui.TextDisabled("No");
|
||||
|
||||
|
|
@ -188,12 +237,12 @@ internal sealed class IltCharms : IIltFeature
|
|||
foreach (var h in hands)
|
||||
{
|
||||
ImGui.PushID(h.Id);
|
||||
if (h.ServerDisabled) ImGui.TextDisabled($"{h.Name} - disabled on this server");
|
||||
if (h.ServerDisabled) SafeImGui.TextDisabled($"{h.Name} - disabled on this server");
|
||||
else
|
||||
{
|
||||
var col = h.Status == IltTri.On ? IltStyle.ColGreen
|
||||
: h.Status == IltTri.Off ? IltStyle.ColTextMute : IltStyle.ColAmber;
|
||||
ImGui.TextColored(col, h.Status == IltTri.On ? "ON " : h.Status == IltTri.Off ? "OFF" : " ? ");
|
||||
SafeImGui.TextColored(col, h.Status == IltTri.On ? "ON " : h.Status == IltTri.Off ? "OFF" : " ? ");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(h.Name);
|
||||
ImGui.SameLine();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13.
|
||||
//
|
||||
// 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:
|
||||
// the login probe, /myquests, ...) 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,
|
||||
|
|
@ -21,6 +21,12 @@ internal sealed class IltChatRequest
|
|||
public string Command = string.Empty;
|
||||
/// <summary>True for lines that belong to this reply (captured, refresh the idle timer).</summary>
|
||||
public Func<string, bool> IsResponseLine = _ => false;
|
||||
/// <summary>
|
||||
/// Optional: only these response lines arm / refresh the idle timer. Header / banner lines
|
||||
/// still capture, but idle completion waits until a progress line arrives (UB's /aug fetch:
|
||||
/// dashes and "Advanced Augmentation Levels:" must not start the 2s idle before Creature:).
|
||||
/// </summary>
|
||||
public Func<string, bool>? ArmsIdle;
|
||||
/// <summary>Optional: a line that ends the reply immediately (it is captured too).</summary>
|
||||
public Func<string, bool>? IsTerminator;
|
||||
/// <summary>The reply is complete after this long with no new response line.</summary>
|
||||
|
|
@ -55,6 +61,8 @@ internal sealed class IltChatCapture
|
|||
private IltChatResult? _activeResult;
|
||||
private long _sentAt;
|
||||
private long _lastLineAt;
|
||||
/// <summary>True once a response line that arms idle has arrived (always true when <see cref="IltChatRequest.ArmsIdle"/> is null).</summary>
|
||||
private bool _idleArmed;
|
||||
|
||||
/// <summary>Minimum spacing between two sends so the server's own command throttles aren't tripped.</summary>
|
||||
private const long SendSpacingMs = 400;
|
||||
|
|
@ -102,9 +110,11 @@ internal sealed class IltChatCapture
|
|||
if (_active != null && _activeResult != null)
|
||||
{
|
||||
bool gotAny = _activeResult.Lines.Count > 0;
|
||||
if (gotAny && now - _lastLineAt >= _active.IdleEndMs)
|
||||
// Idle completion only after a progress line when ArmsIdle is set (header alone is not enough).
|
||||
bool idleReady = _active.ArmsIdle == null || _idleArmed;
|
||||
if (gotAny && idleReady && now - _lastLineAt >= _active.IdleEndMs)
|
||||
Finish();
|
||||
else if (!gotAny && now - _sentAt >= _active.FirstLineTimeoutMs)
|
||||
else if ((!gotAny || !idleReady) && now - _sentAt >= _active.FirstLineTimeoutMs)
|
||||
{
|
||||
_activeResult.TimedOut = true;
|
||||
Finish();
|
||||
|
|
@ -147,7 +157,12 @@ internal sealed class IltChatCapture
|
|||
|
||||
if (!_active.IsResponseLine(text)) return false;
|
||||
_activeResult.Lines.Add(text);
|
||||
_lastLineAt = NowMs;
|
||||
// Header-only replies (e.g. /aug dashes + banner) must not start the idle clock.
|
||||
if (_active.ArmsIdle == null || _active.ArmsIdle(text))
|
||||
{
|
||||
_idleArmed = true;
|
||||
_lastLineAt = NowMs;
|
||||
}
|
||||
RynthLog.Trace(LogCat.IltChat, $"line '{_active.Command}'{(_active.Eat ? " [eaten]" : "")}: {text}");
|
||||
return _active.Eat;
|
||||
}
|
||||
|
|
@ -179,6 +194,7 @@ internal sealed class IltChatCapture
|
|||
_activeResult = result;
|
||||
_sentAt = now;
|
||||
_lastLineAt = now;
|
||||
_idleArmed = req.ArmsIdle == null; // no progress gate → idle can finish after any response line
|
||||
_lastSendAt = now;
|
||||
RynthLog.Trace(LogCat.IltChat, $"send '{req.Command}' (idle={req.IdleEndMs} ms, timeout={req.FirstLineTimeoutMs} ms, eat={req.Eat})");
|
||||
_host.InvokeChatParser(req.Command);
|
||||
|
|
@ -190,6 +206,7 @@ internal sealed class IltChatCapture
|
|||
var res = _activeResult;
|
||||
_active = null;
|
||||
_activeResult = null;
|
||||
_idleArmed = false;
|
||||
if (req == null || res == null) return;
|
||||
RynthLog.Trace(LogCat.IltChat,
|
||||
$"complete '{req.Command}' in {NowMs - _sentAt} ms: lines={res.Lines.Count} timedOut={res.TimedOut} " +
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
// IltChunkClap.cs — Lugian-hammer chunking and /clap automation (Gear tab).
|
||||
// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13.
|
||||
//
|
||||
// Chunk: uses a Lugian (Aetheria) Hammer on eligible items, one at a time:
|
||||
// Chunk: uses the 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).
|
||||
// never-chunk (bool 9030), never levelled (ItemTotalXp quad 4 == 0), no kept
|
||||
// C / CD / CDR rating (gear ints 372 / 374 / 375; on by default), and max level
|
||||
// (int 319, up to 10 on ILT) 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).
|
||||
// The tool is the "Lugian Aetheria Hammer" only. The Lugian Hammer weapons (Flaming, Acid, ...)
|
||||
// are loot and chunk nothing: the server answers with no result line, so every item timed out
|
||||
// into the skip list and the status sat on "nothing eligible" (SilentKelpie, 2026-10-15).
|
||||
// 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;
|
||||
|
|
@ -15,6 +19,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
|
|
@ -60,10 +65,14 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
|
||||
// ── Chunk ───────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Infinite Leaftide's chunking tool.</summary>
|
||||
internal const string HammerName = "Lugian Aetheria Hammer";
|
||||
|
||||
/// <summary>True for the chunking tool only, never a Lugian Hammer weapon. Pure: the tests drive it.</summary>
|
||||
internal static bool IsChunkHammer(string name) => name.Equals(HammerName, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
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));
|
||||
=> _ctx.Inventory.Items().FirstOrDefault(wo => IsChunkHammer(wo.Name) && !_ctx.Inventory.IsEquipped(wo));
|
||||
|
||||
/// <summary>True/false when decidable; null when appraisal is still needed.</summary>
|
||||
private bool? IsChunkableAetheria(WorldObject wo)
|
||||
|
|
@ -77,9 +86,24 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
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);
|
||||
if (KeptForRatings(G, inv.Int(wo, IltInventory.IntGearCrit), inv.Int(wo, IltInventory.IntGearCritDamage),
|
||||
inv.Int(wo, IltInventory.IntGearCritDamageResist)))
|
||||
return false;
|
||||
return coalesced || inv.Int(wo, IltInventory.IntItemMaxLevel) < ClampUnderLevel(G.ChunkAetheriaUnderLevel);
|
||||
}
|
||||
|
||||
/// <summary>The chunk cap in range: 1 (chunk nothing by level) to one past the ILT maximum (every level).</summary>
|
||||
internal static int ClampUnderLevel(int under) => Math.Clamp(under, 1, IltInventory.AetheriaMaxLevel + 1);
|
||||
|
||||
/// <summary>
|
||||
/// True when an aetheria's C / CD / CDR rating is one the settings keep (any rating above 0 with
|
||||
/// its keep switch on). Pure: the tests drive it.
|
||||
/// </summary>
|
||||
internal static bool KeptForRatings(IltGearState g, int crit, int critDamage, int critDamageResist)
|
||||
=> (g.KeepAetheriaWithCrit && crit > 0)
|
||||
|| (g.KeepAetheriaWithCritDamage && critDamage > 0)
|
||||
|| (g.KeepAetheriaWithCritDamageResist && critDamageResist > 0);
|
||||
|
||||
private bool? IsChunkableCorrupted(WorldObject wo)
|
||||
{
|
||||
if (wo.ObjectClass is not (AcObjectClass.MeleeWeapon or AcObjectClass.MissileWeapon)) return false;
|
||||
|
|
@ -109,6 +133,7 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
RynthLog.Trace(LogCat.IltGear, $"ChunkNow()");
|
||||
_manualPass = true;
|
||||
_lastChunkAt = 0;
|
||||
_skip.Clear(); // a manual pass gives the items that got no answer another try
|
||||
_chunkStatus = "manual pass started";
|
||||
}
|
||||
|
||||
|
|
@ -120,6 +145,7 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
{
|
||||
if (now - _waitStartedAt < ChunkResultWaitMs) return;
|
||||
_skip.Add(_waitingOn); // no result line — don't hammer the same item forever
|
||||
RynthLog.Write(LogCat.IltGear, $"chunk: no result line for 0x{(uint)_waitingOn:X8} in {ChunkResultWaitMs / 1000} s, skipped until a manual pass");
|
||||
_waitingOn = 0;
|
||||
}
|
||||
if (now - _lastChunkAt < Math.Max(500, G.ChunkIntervalMs)) return;
|
||||
|
|
@ -129,11 +155,12 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
if (_ctx.Inventory.IsBusy) return;
|
||||
|
||||
var hammer = FindHammer();
|
||||
if (hammer == null) { _chunkStatus = "no Lugian Hammer carried"; _manualPass = false; return; }
|
||||
if (hammer == null) { _chunkStatus = $"no {HammerName} carried"; _manualPass = false; return; }
|
||||
var target = NextChunkTarget();
|
||||
if (target == null)
|
||||
{
|
||||
_chunkStatus = _chunked > 0 ? $"nothing left to chunk ({_chunked} this session)" : "nothing eligible";
|
||||
_chunkStatus = (_chunked > 0 ? $"nothing left to chunk ({_chunked} this session)" : "nothing eligible")
|
||||
+ (_skip.Count > 0 ? $"; {_skip.Count} skipped with no answer (Chunk now retries them)" : "");
|
||||
_manualPass = false;
|
||||
return;
|
||||
}
|
||||
|
|
@ -216,23 +243,43 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
TickClap(nowMs);
|
||||
}
|
||||
|
||||
internal enum ChunkResult { None, Busy, Done, Refused }
|
||||
|
||||
/// <summary>
|
||||
/// What a chat line says about the chunk in flight. ILT names the item and the tool ("You
|
||||
/// smash the Corrupted Sword with the Lugian Aetheria Hammer."), so a line naming a corrupted
|
||||
/// item with the hammer, powder or shatter is a result too (combat's "You smash Foo for 147"
|
||||
/// names neither). Pure: the tests drive it.
|
||||
/// </summary>
|
||||
internal static ChunkResult ClassifyChat(string text)
|
||||
{
|
||||
if (text.StartsWith("You're too busy", StringComparison.OrdinalIgnoreCase) || text.StartsWith("You are too busy", StringComparison.OrdinalIgnoreCase))
|
||||
return ChunkResult.Busy;
|
||||
if (ChunkRefusedLines.Any(l => text.Contains(l, StringComparison.OrdinalIgnoreCase))) return ChunkResult.Refused;
|
||||
if (ChunkDoneLines.Any(l => text.Contains(l, StringComparison.OrdinalIgnoreCase))) return ChunkResult.Done;
|
||||
if (text.Contains("corrupted", StringComparison.OrdinalIgnoreCase)
|
||||
&& (text.Contains("hammer", StringComparison.OrdinalIgnoreCase) || text.Contains("powder", StringComparison.OrdinalIgnoreCase)
|
||||
|| text.Contains("shatter", StringComparison.OrdinalIgnoreCase)))
|
||||
return ChunkResult.Done;
|
||||
return ChunkResult.None;
|
||||
}
|
||||
|
||||
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))
|
||||
switch (ClassifyChat(text))
|
||||
{
|
||||
_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;
|
||||
case ChunkResult.Busy:
|
||||
_waitingOn = 0; // retry the same item next interval
|
||||
break;
|
||||
case ChunkResult.Done:
|
||||
_chunked++;
|
||||
_waitingOn = 0;
|
||||
break;
|
||||
case ChunkResult.Refused:
|
||||
_skip.Add(_waitingOn);
|
||||
_waitingOn = 0;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -249,7 +296,7 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
|
||||
public void Render()
|
||||
{
|
||||
ImGui.TextColored(IltStyle.ColTeal, "Chunking (Lugian Hammer)");
|
||||
SafeImGui.TextColored(IltStyle.ColTeal, $"Chunking ({HammerName})");
|
||||
bool a = G.AutoChunkAetheria, c = G.AutoChunkCorrupted, comb = G.ChunkInCombat;
|
||||
if (ImGui.Checkbox("Auto-chunk low aetheria", ref a)) G.AutoChunkAetheria = a;
|
||||
ImGui.SameLine();
|
||||
|
|
@ -257,11 +304,24 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
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.InputInt("Chunk aetheria with max level below", ref under)) G.ChunkAetheriaUnderLevel = ClampUnderLevel(under);
|
||||
if (ImGui.IsItemHovered())
|
||||
SafeImGui.SetTooltip($"Infinite Leaftide aetheria goes up to level {IltInventory.AetheriaMaxLevel}; {IltInventory.AetheriaMaxLevel + 1} chunks every level.");
|
||||
bool kc = G.KeepAetheriaWithCrit, kcd = G.KeepAetheriaWithCritDamage, kcdr = G.KeepAetheriaWithCritDamageResist;
|
||||
ImGui.TextUnformatted("Never chunk aetheria with:");
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Checkbox("C##keepc", ref kc)) G.KeepAetheriaWithCrit = kc;
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("A Crit rating (GearCrit).");
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Checkbox("CD##keepcd", ref kcd)) G.KeepAetheriaWithCritDamage = kcd;
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("A Crit Damage rating (GearCritDamage).");
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Checkbox("CDR##keepcdr", ref kcdr)) G.KeepAetheriaWithCritDamageResist = kcdr;
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("A Crit Damage Resist rating (GearCritDamageResist).");
|
||||
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);
|
||||
SafeImGui.TextDisabled("Status: " + _chunkStatus);
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.TextColored(IltStyle.ColTeal, "Clap (/clap all)");
|
||||
|
|
@ -277,6 +337,6 @@ internal sealed class IltChunkClap : IIltFeature
|
|||
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);
|
||||
SafeImGui.TextDisabled(_clapStatus);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ using System.Linq;
|
|||
using ImGuiNET;
|
||||
using RynthCore.Loot;
|
||||
using RynthCore.Install;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
|
|
@ -238,7 +239,7 @@ internal sealed class IltEquipSuits : IIltFeature
|
|||
var profiles = _profiles;
|
||||
if (profiles.Length == 0)
|
||||
{
|
||||
ImGui.TextDisabled($"No .utl files found ({System.IO.Path.Combine(IltHubStore.SharedRoot, "EquipProfiles")}, the RynthAi folder's EquipProfiles or UtilityBelt equip folders).");
|
||||
SafeImGui.TextDisabled($"No .utl files found ({System.IO.Path.Combine(IltHubStore.SharedRoot, "EquipProfiles")}, the RynthAi folder's EquipProfiles or UtilityBelt equip folders).");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -258,7 +259,7 @@ internal sealed class IltEquipSuits : IIltFeature
|
|||
if (ImGui.SmallButton("Cancel")) _ctx.Post(() => Cancel("cancelled by player"));
|
||||
}
|
||||
}
|
||||
ImGui.TextDisabled("Status: " + _status);
|
||||
foreach (string l in _preview) ImGui.BulletText(l);
|
||||
SafeImGui.TextDisabled("Status: " + _status);
|
||||
foreach (string l in _preview) SafeImGui.BulletText(l);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
273
Plugins/RynthCore.Plugin.RynthILT/Hub/IltFeatureCatalog.cs
Normal file
273
Plugins/RynthCore.Plugin.RynthILT/Hub/IltFeatureCatalog.cs
Normal file
|
|
@ -0,0 +1,273 @@
|
|||
// IltFeatureCatalog.cs — Every Infinite Leaftide feature RynthILT supports, in one list.
|
||||
//
|
||||
// Each entry says what the feature is, where it lives in the Rynth tools, and how its state is
|
||||
// known. Detection is client-side only: the server type comes from the login (the world name,
|
||||
// RynthCore's "ilt" verdict), and the ILT profile below is the known set of what Infinite
|
||||
// Leaftide runs, taken from ACECustom (its ServerConfig defaults and deploy/PROD_DEPLOY_PLAN.md,
|
||||
// e.g. pet bond and potency on in prod, pet strain off since launch). The server is never asked
|
||||
// for a list; what it returns on its own (probe replies, chat) refines the profile:
|
||||
// * Profile (IltKnown.Profile): on in ILT (T11, split arrows, pet breeding, ...). On with the
|
||||
// ILT world; a server refusal seen in chat turns it off.
|
||||
// * Profile off (IltKnown.ProfileOff): an ACECustom option ILT runs with off (pet strain,
|
||||
// defense scaling, the pyreal refill). Off with the ILT world; a chat line only the feature
|
||||
// sends (e.g. a pyreal refill) turns it on.
|
||||
// * Checked (IltKnown.Checked): the login probe answers it (/bank, /aug, /xp, /pets, ...).
|
||||
// "checking" until the reply arrives, then on or off.
|
||||
// * No server bit at all (the Temple guardians, Paragon gear): content, on with the ILT world.
|
||||
// Off an ILT world nothing is claimed: every state is unknown.
|
||||
// The list feeds the ILT settings window ("/ilt settings", IltSettingsView/) and "/ra hub features".
|
||||
// Server facts copied from ACECustom: Fellowship.MaxFellows = 29 (Source/ACE.Server/Entity/
|
||||
// Fellowship.cs), Zone Share (ZoneShareManager) and the fellowship luminance share.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
/// <summary>One Leaftide feature: id, display text, where it lives, and the server bit that says whether it's on.</summary>
|
||||
/// <param name="Key">Stable id.</param>
|
||||
/// <param name="Label">Display name.</param>
|
||||
/// <param name="Group">Character, Items, Fellowship or Activities (the list's sections).</param>
|
||||
/// <param name="Where">Where the Rynth tools handle it.</param>
|
||||
/// <param name="Description">One line on what the server does.</param>
|
||||
/// <param name="ServerBit">The IltServerOptions key probes and chat refusals set; null = content built into ACECustom (on with the world).</param>
|
||||
/// <param name="Known">How the state is known while the bit hasn't been set (see <see cref="IltKnown"/>).</param>
|
||||
internal sealed record IltFeatureInfo(string Key, string Label, string Group, string Where, string Description, string? ServerBit,
|
||||
IltKnown Known = IltKnown.Profile);
|
||||
|
||||
/// <summary>How a feature's state is known on an ILT world before (or without) a server answer.</summary>
|
||||
internal enum IltKnown
|
||||
{
|
||||
/// <summary>On in ILT: on with the ILT world unless chat shows it off.</summary>
|
||||
Profile,
|
||||
/// <summary>The login probe answers it: "checking" until the reply arrives.</summary>
|
||||
Checked,
|
||||
/// <summary>Off in ILT: off with the ILT world unless chat shows it on.</summary>
|
||||
ProfileOff,
|
||||
}
|
||||
|
||||
internal static class IltFeatureCatalog
|
||||
{
|
||||
public const string GroupCharacter = "Character";
|
||||
public const string GroupItems = "Items";
|
||||
public const string GroupPets = "Pets";
|
||||
public const string GroupFellowship = "Fellowship";
|
||||
public const string GroupCombat = "Combat";
|
||||
public const string GroupActivities = "Activities";
|
||||
|
||||
/// <summary>The section order of the list (ACECustom's "/ilt features" uses the same).</summary>
|
||||
public static readonly string[] Groups = { GroupCharacter, GroupItems, GroupPets, GroupFellowship, GroupCombat, GroupActivities };
|
||||
|
||||
/// <summary>ACECustom's fellowship member limit (Fellowship.MaxFellows); retail is 9.</summary>
|
||||
public const int IltFellowshipMax = 29;
|
||||
|
||||
/// <summary>A retail fellowship's member limit.</summary>
|
||||
public const int RetailFellowshipMax = 9;
|
||||
|
||||
/// <summary>Every Leaftide feature RynthILT supports, in display order.</summary>
|
||||
public static readonly IltFeatureInfo[] All =
|
||||
{
|
||||
// Character progression and money.
|
||||
new("bank", "Banking", GroupCharacter, "Mini Remote > Banking tab; Remote tab bank line",
|
||||
"Bank pyreals, luminance, keys and coins; deposit, withdraw and transfer (/bank).", IltFeature.Bank, IltKnown.Checked),
|
||||
new("bank_notes", "Trade note banking", GroupCharacter, "Mini Remote > Banking tab (trade notes)",
|
||||
"Deposit trade notes as pyreals, withdraw any note from I to MMD, transfer note value (/bank d n).", "bank_notes"),
|
||||
new("guardian", "Guardian (infinite base attributes)", GroupCharacter, "Guardian panel (/rc guardian)",
|
||||
"Temple of Enlightenment guardians raise base attributes past the retail cap.", null),
|
||||
new("attributes", "Infinite raised attributes", GroupCharacter, "Skills > Progression > Attributes",
|
||||
"Spend unassigned XP on attributes past the retail max (/xp, /attr).", IltFeature.Xp, IltKnown.Checked),
|
||||
new("augmentations", "Infinite augmentations", GroupCharacter, "Skills > Progression > Augmentations",
|
||||
"Luminance augmentations far past retail: Creature 6000, Item / Life / War / Void 4000 (/aug).", IltFeature.Aug, IltKnown.Checked),
|
||||
new("aug_charms", "Augmentation counter charms", GroupCharacter, "Skills > Progression > Augmentations",
|
||||
"Triune Weave and the school charms add to your aug counts past the purchase cap (/aug).", "aug_charms"),
|
||||
new("enlightenment", "Enlightenment", GroupCharacter, "Skills > Progression > Enlightenment",
|
||||
"Enlightenment tiers past retail, with medallions, sigils and crests (/enl).", IltFeature.Enl, IltKnown.Checked),
|
||||
new("ilt_skills", "Spend XP and train skills in one go", GroupCharacter, "Chat: /ilt xp, /ilt train",
|
||||
"Spends all unspent XP into trained skills, or trains every affordable skill, in priority order.", "ilt_skills"),
|
||||
new("leaderboards", "Leaderboards", GroupCharacter, "Chat: /top",
|
||||
"Server leaderboards: quest bonus, level, enlightenment, augs, bank, pets and more (/top).", "leaderboards"),
|
||||
|
||||
// Items, loot and crafting.
|
||||
new("paragon_armor", "Paragon armor", GroupItems, "Item info (RynthAi): Paragon sets and levels",
|
||||
"Paragon armor progression; the 50th Armor Paragon gates enlightenment past 300.", null),
|
||||
new("paragon_weapons", "Paragon weapons", GroupItems, "Item info (RynthAi): Paragon sets and levels",
|
||||
"Paragon weapon progression (Paragon Missile, Caster and Melee sets).", null),
|
||||
new("paragon_jewelry", "Paragon jewelry", GroupItems, "Item info (RynthAi): Paragon sets and levels",
|
||||
"Paragon jewelry progression; the 50th Paragon gates enlightenment past 150.", null),
|
||||
new("t11", "T11 items", GroupItems, "Item info and loot rules (RynthAi, RynthCore Loot Editor)",
|
||||
"Tier 11 to 25 gear (Zone Control tiers): tiers, gear grades, property slots and modifiers.", "t11"),
|
||||
new("t11_scaling", "T11+ weapon scaling", GroupItems, "Item info (RynthAi)",
|
||||
"T11+ weapons scale with your augs and have aug wield floors; from T16, charm counts too.", "t11_scaling"),
|
||||
new("t11_craft_gate", "T11+ crafting rules (crafting uniqueness)", GroupItems, "Mini Remote > Gear tab",
|
||||
"On T11+ items the server refuses an imbue or tink that would replace a better value, and limits materials per item type.",
|
||||
"t11_craft_gate"),
|
||||
new("split_arrows", "Split arrows", GroupItems, "Mini Remote > Gear > Split arrows",
|
||||
"Missile weapons carry split arrows, added with White Quartz salvage.", "split_arrows"),
|
||||
new("charms", "Charms", GroupItems, "Mini Remote > Charms tab",
|
||||
"Registry charms and the Guardian Hand, with their toggles; each charm is listed in the Charms section.", "charms"),
|
||||
new("clap", "Chunk clap (auto craft)", GroupItems, "Mini Remote > Gear tab",
|
||||
"Turns aetheria, chunks and trinkets into banked enlightened coins (/clap all).", IltFeature.Clap, IltKnown.Checked),
|
||||
|
||||
// Pets.
|
||||
new("pets", "Pet log", GroupPets, "Mini Remote > Pets tab", "Captured pets, registered with Professor Ruggan (/pets).", IltFeature.Pets, IltKnown.Checked),
|
||||
new("shinies", "Shiny log", GroupPets, "Mini Remote > Pets tab", "Rare shiny creature variants you captured (/shinies).", IltFeature.Shinies, IltKnown.Checked),
|
||||
new("monster_capture", "Monster capture", GroupPets, "Mini Remote > Pets tab",
|
||||
"Siphon lenses capture a creature's look into a pet essence (lens drops from kills are a separate server switch).", "monster_capture"),
|
||||
new("pet_breeding", "Pet breeding", GroupPets, "Mini Remote > Pets > Breeding",
|
||||
"Breed two combat pet devices at the Seedy Motel for inherited and mutated offspring (/dance).", "pet_breeding"),
|
||||
new("pet_maturity", "Pet maturity", GroupPets, "Mini Remote > Pets > Breeding",
|
||||
"Bred pets start small and weak and grow up with kills.", "pet_maturity"),
|
||||
new("pet_bond", "Pet bond", GroupPets, "Mini Remote > Pets tab",
|
||||
"Pets gain bond XP from kills, which scales their stats (/top bonds). On in ILT (breeding needs bond 100).", IltFeature.PetBond),
|
||||
new("pet_potency", "Pet potency", GroupPets, "Mini Remote > Pets tab",
|
||||
"Savage Echo residue raises a pet's potency (/echo-notify). On in ILT.", IltFeature.PetPotency),
|
||||
new("pet_strain", "Pet strain", GroupPets, "Mini Remote > Pets tab",
|
||||
"High pet potency lowers the owner's damage rating. Off in ILT since launch.", "pet_strain", IltKnown.ProfileOff),
|
||||
new("pet_refill", "Summon essence refill", GroupPets, "Mini Remote > Pets tab",
|
||||
"Pays pyreals to refill an empty essence when you summon (needs its charm). Off by default; a refill message in chat shows it on.", IltFeature.PetRefill, IltKnown.ProfileOff),
|
||||
new("universal_mastery", "Universal summoning mastery", GroupPets, "Mini Remote > Pets tab",
|
||||
"Use pet essences of any summoning mastery (needs its charm).", IltFeature.UniversalMastery),
|
||||
new("pet_naming", "Pet names", GroupPets, "Chat: /pet-name",
|
||||
"Ask for a name for your pet; staff approve it (/pet-name).", "pet_naming"),
|
||||
|
||||
// Fellowship.
|
||||
new("fellowship_large", "Large fellowships (up to 29)", GroupFellowship, "The game's fellowship panel",
|
||||
"Fellowships hold up to 29 members instead of retail's 9.", "fellowship_size"),
|
||||
new("fship", "Fellowship commands", GroupFellowship, "ILT fellowship window (/ilt fellow)",
|
||||
"Create, invite, invite your landblock, list nearby, leave and disband from chat (/fship).", "fship"),
|
||||
new("zone_share", "Zone Share", GroupFellowship, "Mini Remote > Session Stats (luminance, pass-up)",
|
||||
"XP and luminance shared with everyone in a Zone Share area, capped at a fellowship's size.", "zone_share"),
|
||||
new("fellowship_luminance", "Fellowship luminance share", GroupFellowship, "Mini Remote > Session Stats (luminance, pass-up)",
|
||||
"Luminance splits among fellows the way XP does.", "fellowship_luminance"),
|
||||
new("fellowship_blackjack", "Fellowship Blackjack", GroupFellowship, "Mini Remote > Games tab",
|
||||
"Blackjack played as a fellowship (/fblackjack).", IltFeature.FBlackjack, IltKnown.Checked),
|
||||
|
||||
// Combat.
|
||||
new("smart_ring", "Smart ring spells", GroupCombat, "Chat: /ilt smartring",
|
||||
"Ring spells hit everything in their radius, with double and triple procs (/ilt smartring on|off).", "smart_ring"),
|
||||
new("dmgformat", "Damage number format", GroupCombat, "Chat: /ilt dmgformat",
|
||||
"Damage shown plain, with commas, or short (K/M/B) (/ilt dmgformat).", "dmgformat"),
|
||||
new("overkill", "Overkill on kill messages", GroupCombat, "Chat: /ilt showoverkill",
|
||||
"Kill and death messages show the overkill amount (/ilt showoverkill).", "overkill"),
|
||||
new("missile_power", "Missile power bar damage", GroupCombat, "Combat",
|
||||
"The missile accuracy bar scales damage from 1x to 2.5x.", "missile_power"),
|
||||
new("t11_hit_gate", "T11+ hit gate", GroupCombat, "Combat",
|
||||
"Attacks on v11+ monsters miss unless your aug counts meet that tier's requirement.", "t11_hit_gate"),
|
||||
new("v11_endgame", "v11+ endgame scaling", GroupCombat, "Combat",
|
||||
"Percent-of-max-HP damage, compressed vulnerabilities and tougher v11+ monsters.", "v11_endgame"),
|
||||
new("defense_scaling", "Defense scaling", GroupCombat, "Combat",
|
||||
"Curbs extreme evasion at very high defense skill. Off by default in ACECustom.", "defense_scaling", IltKnown.ProfileOff),
|
||||
|
||||
// Activities.
|
||||
new("quests", "Quest tracker", GroupActivities, "Mini Remote > Quests tab",
|
||||
"Your quest timers from the server (/myquests).", IltFeature.Quests, IltKnown.Checked),
|
||||
new("quest_bonus", "Quest bonus", GroupActivities, "Mini Remote > Quests tab (quest bonus)",
|
||||
"Each quest completed adds to your XP bonus; the list (/qb).", IltFeature.Qb, IltKnown.Checked),
|
||||
new("bounties", "Bounties", GroupActivities, "Bounties window (/rc bounties)", "ACECustom bounties and your progress.", "bounties"),
|
||||
new("rifts", "Greater Rifts", GroupActivities, "Chat: /rift", "Private, timed dungeon runs that scale by tier (/rift).", "rifts"),
|
||||
new("room_assign", "Room Assign dungeons", GroupActivities, "Portals and recalls",
|
||||
"One-player rooms with their own spawns.", "room_assign"),
|
||||
new("portal_requirements", "Aug / ENL / QB portals", GroupActivities, "Portals",
|
||||
"Portals that need augmentations, an enlightenment level or a quest bonus.", "portal_requirements"),
|
||||
new("powerball", "Powerball", GroupActivities, "Mini Remote > Games tab", "The Powerball lottery (/pb).", IltFeature.Powerball, IltKnown.Checked),
|
||||
new("blackjack", "Blackjack", GroupActivities, "Mini Remote > Games tab", "Blackjack against the house (/blackjack).", IltFeature.Blackjack, IltKnown.Checked),
|
||||
new("unstuck", "Unstuck", GroupActivities, "Chat: /unstuck", "Gets you out of a stuck portal or spot (/unstuck).", "unstuck"),
|
||||
};
|
||||
|
||||
/// <summary>The entry with <paramref name="key"/>, or null.</summary>
|
||||
public static IltFeatureInfo? Find(string key)
|
||||
{
|
||||
foreach (IltFeatureInfo f in All)
|
||||
if (f.Key.Equals(key, StringComparison.OrdinalIgnoreCase)) return f;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A feature's state on an ILT world: what the server returned (a probe reply or a refusal in
|
||||
/// chat) when it did; else the ILT profile: On for content and <see cref="IltKnown.Profile"/>,
|
||||
/// Off for <see cref="IltKnown.ProfileOff"/>, Unknown ("checking") for probed features.
|
||||
/// Off ILT nothing is claimed: Unknown.
|
||||
/// </summary>
|
||||
public static IltTri StateOf(IltFeatureInfo f, bool iltWorld, Func<string, IltTri> bit)
|
||||
{
|
||||
if (!iltWorld) return IltTri.Unknown;
|
||||
if (f.ServerBit == null) return IltTri.On;
|
||||
IltTri reported = bit(f.ServerBit);
|
||||
if (reported != IltTri.Unknown) return reported;
|
||||
return f.Known switch
|
||||
{
|
||||
IltKnown.Profile => IltTri.On,
|
||||
IltKnown.ProfileOff => IltTri.Off,
|
||||
_ => IltTri.Unknown,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A charm's state: charms are part of the ILT profile, so on with the ILT world unless the
|
||||
/// server refused one in chat (e.g. "Auto-Rebuff Charm is currently disabled globally").
|
||||
/// </summary>
|
||||
public static IltTri CharmStateOf(bool iltWorld, IltTri reported)
|
||||
=> !iltWorld ? IltTri.Unknown : reported != IltTri.Unknown ? reported : IltTri.On;
|
||||
|
||||
/// <summary>Prefix of a charm's server key (IltFeature.Charm): "charm:manabarrier".</summary>
|
||||
public const string CharmKeyPrefix = "charm:";
|
||||
|
||||
/// <summary>
|
||||
/// Display text for a key the settings view lists: a catalog feature (its label, group and
|
||||
/// description with where it lives and how its state is known), a charm ("charm:..." under
|
||||
/// Charms, named from the charm registry), or any other server bit as itself under "Other".
|
||||
/// </summary>
|
||||
public static (string Label, string Group, string Tooltip) Describe(string key)
|
||||
{
|
||||
IltFeatureInfo? f = Find(key);
|
||||
if (f != null) return (f.Label, f.Group, f.Description + "\nWhere: " + f.Where + "\n" + HowKnown(f));
|
||||
if (key.StartsWith(CharmKeyPrefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
const string charmNote = "Part of ILT: on unless the server refuses it in chat.";
|
||||
foreach (IltCharmDef def in IltInventory.Charms)
|
||||
if (IltFeature.Charm(def.Name).Equals(key, StringComparison.OrdinalIgnoreCase))
|
||||
return (def.Name, GroupCharms, (def.Effect.Length > 0 ? def.Effect + "\n" : string.Empty)
|
||||
+ "Where: Mini Remote > Charms tab\n" + charmNote);
|
||||
return (key.Substring(CharmKeyPrefix.Length), GroupCharms, charmNote);
|
||||
}
|
||||
return (key, GroupOther, "A server switch RynthILT reads from chat.");
|
||||
}
|
||||
|
||||
/// <summary>One line on where a feature's state comes from (tooltips).</summary>
|
||||
private static string HowKnown(IltFeatureInfo f) => f.ServerBit == null
|
||||
? "Built into ILT: on with the world."
|
||||
: f.Known switch
|
||||
{
|
||||
IltKnown.Checked => "Checked at login: the server's reply decides.",
|
||||
IltKnown.ProfileOff => "Off in ILT: on only if the server shows it in chat.",
|
||||
_ => "Part of ILT: on unless the server refuses it in chat.",
|
||||
};
|
||||
|
||||
/// <summary>The settings view's extra sections after <see cref="Groups"/>.</summary>
|
||||
public const string GroupCharms = "Charms";
|
||||
public const string GroupOther = "Other";
|
||||
|
||||
/// <summary>Short state text for the list and chat: "on", "off" or "checking".</summary>
|
||||
public static string StateText(IltTri state) => state switch
|
||||
{
|
||||
IltTri.On => "on",
|
||||
IltTri.Off => "off",
|
||||
_ => "checking",
|
||||
};
|
||||
|
||||
/// <summary>The fellowship member limit: ACECustom's 29 on an ILT world, retail's 9 elsewhere.</summary>
|
||||
public static int FellowshipMax(bool iltWorld) => iltWorld ? IltFellowshipMax : RetailFellowshipMax;
|
||||
|
||||
/// <summary>The chat listing for "/ra hub features": one line per feature, ASCII only.</summary>
|
||||
public static List<string> BuildChatLines(bool iltWorld, Func<string, IltTri> bit)
|
||||
{
|
||||
var lines = new List<string>(All.Length + Groups.Length);
|
||||
foreach (string g in Groups)
|
||||
{
|
||||
var parts = new List<string>();
|
||||
foreach (IltFeatureInfo f in All)
|
||||
if (f.Group == g) parts.Add($"{f.Label} [{StateText(StateOf(f, iltWorld, bit))}]");
|
||||
lines.Add($"{g}: {string.Join(", ", parts)}");
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ using System.Collections.Generic;
|
|||
using System.Numerics;
|
||||
using System.Text.RegularExpressions;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
||||
|
|
@ -179,7 +180,7 @@ internal sealed class IltGames : IIltFeature
|
|||
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");
|
||||
SafeImGui.TextDisabled(ok ? IltParse.N0(bet) : fellowship ? "invalid (max 100B)" : "invalid");
|
||||
|
||||
ImGui.BeginDisabled(!ok || _handActive);
|
||||
if (ImGui.Button($"Deal...##{id}"))
|
||||
|
|
@ -192,7 +193,7 @@ internal sealed class IltGames : IIltFeature
|
|||
ImGui.EndDisabled();
|
||||
|
||||
if (_handActive && _fellowshipHand == fellowship) RenderHandButtons(id);
|
||||
if (_lastResult.Length > 0 && _fellowshipHand == fellowship) ImGui.TextWrapped(_lastResult);
|
||||
if (_lastResult.Length > 0 && _fellowshipHand == fellowship) SafeImGui.TextWrapped(_lastResult);
|
||||
}
|
||||
|
||||
private void RenderHandButtons(string id)
|
||||
|
|
@ -221,7 +222,7 @@ internal sealed class IltGames : IIltFeature
|
|||
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);
|
||||
if (_pbStatus.Length > 0) SafeImGui.TextWrapped(_pbStatus);
|
||||
return;
|
||||
}
|
||||
int qty = S.PowerballQuantity;
|
||||
|
|
@ -234,7 +235,7 @@ internal sealed class IltGames : IIltFeature
|
|||
_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);
|
||||
if (_pbStatus.Length > 0) SafeImGui.TextWrapped(_pbStatus);
|
||||
}
|
||||
|
||||
/// <summary>Small HUD with the current hand; called every frame by the Hub UI.</summary>
|
||||
|
|
@ -245,7 +246,7 @@ internal sealed class IltGames : IIltFeature
|
|||
bool open = true;
|
||||
if (ImGui.Begin("Blackjack HUD##iltbjhud", ref open, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse))
|
||||
{
|
||||
ImGui.TextColored(IltStyle.ColAmber, _fellowshipHand ? "Fellowship Blackjack" : "Blackjack");
|
||||
SafeImGui.TextColored(IltStyle.ColAmber, _fellowshipHand ? "Fellowship Blackjack" : "Blackjack");
|
||||
RenderHandButtons("hud");
|
||||
}
|
||||
ImGui.End();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
// The sections are separate modules (buff keepers, chunk/clap, split arrows, equipment suits)
|
||||
// that this tab just lays out, plus RynthAi's VTank .usd importer (it edits RynthAi's own rules,
|
||||
// so it stayed in RynthAi and is drawn here through RynthAi.Hub RenderSection). The charm strip (registry charms and the Guardian
|
||||
// Hand, with their toggles) is the Charms tab now (IltCharms).
|
||||
// Hand, with their toggles) is the Charms tab now (IltCharms). The Rings inscription chain
|
||||
// (IltRingChainRunner) is SilentKelpie's RynthAi Crafting > Rings, moved here 2026-10-15.
|
||||
using ImGuiNET;
|
||||
|
||||
namespace RynthCore.Plugin.RynthILT.Hub;
|
||||
|
|
@ -15,6 +16,7 @@ internal sealed class IltGear : IIltFeature
|
|||
public IltChunkClap ChunkClap { get; }
|
||||
public IltSplitArrows Split { get; }
|
||||
public IltEquipSuits Suits { get; }
|
||||
public IltRingChainRunner Rings { get; }
|
||||
|
||||
private readonly IltHubContext _ctx;
|
||||
|
||||
|
|
@ -24,6 +26,9 @@ internal sealed class IltGear : IIltFeature
|
|||
ChunkClap = new IltChunkClap(ctx);
|
||||
Split = new IltSplitArrows(ctx);
|
||||
Suits = new IltEquipSuits(ctx);
|
||||
// The two pack jobs that answer craft dialogs never run together.
|
||||
Rings = new IltRingChainRunner(ctx, () => Split.Running);
|
||||
Split.Blocked = () => Rings.Running;
|
||||
_ctx = ctx;
|
||||
}
|
||||
|
||||
|
|
@ -35,6 +40,7 @@ internal sealed class IltGear : IIltFeature
|
|||
ChunkClap.Tick(nowMs);
|
||||
Split.Tick(nowMs);
|
||||
Suits.Tick(nowMs);
|
||||
Rings.Tick(nowMs);
|
||||
}
|
||||
|
||||
public bool OnChat(string text)
|
||||
|
|
@ -43,6 +49,7 @@ internal sealed class IltGear : IIltFeature
|
|||
eat |= ChunkClap.OnChat(text);
|
||||
eat |= Split.OnChat(text);
|
||||
eat |= Suits.OnChat(text);
|
||||
eat |= Rings.OnChat(text);
|
||||
return eat;
|
||||
}
|
||||
|
||||
|
|
@ -52,6 +59,7 @@ internal sealed class IltGear : IIltFeature
|
|||
ChunkClap.OnLogout();
|
||||
Split.OnLogout();
|
||||
Suits.OnLogout();
|
||||
Rings.OnLogout();
|
||||
}
|
||||
|
||||
// ── UI (render thread) ──────────────────────────────────────────────────
|
||||
|
|
@ -62,6 +70,7 @@ internal sealed class IltGear : IIltFeature
|
|||
if (ImGui.CollapsingHeader("Chunking / Clap")) ChunkClap.Render();
|
||||
if (ImGui.CollapsingHeader("Split arrows")) Split.Render();
|
||||
if (ImGui.CollapsingHeader("Equipment suits")) Suits.Render();
|
||||
if (ImGui.CollapsingHeader("Rings (inscription chain)")) Rings.Render();
|
||||
if (ImGui.CollapsingHeader("VirindiTank import") && !_ctx.Ai.RenderSection(RynthCore.Plugin.Shared.RynthAiHub.SectionVTankImport))
|
||||
ImGui.TextDisabled("The VirindiTank .usd import fills RynthAi's rules: it comes with RynthAi, which isn't loaded.");
|
||||
ImGui.TextDisabled("Charms and the Guardian Hand are on the Charms tab.");
|
||||
|
|
|
|||
|
|
@ -465,16 +465,16 @@ internal sealed class IltGuardian : IIltFeature
|
|||
ImGui.TextDisabled("Heard:");
|
||||
ImGui.SameLine();
|
||||
ImGui.PushTextWrapPos(0f);
|
||||
ImGui.TextDisabled(IltGuardianPhrasebook.MessageOf(line));
|
||||
SafeImGui.TextDisabled(IltGuardianPhrasebook.MessageOf(line));
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
|
||||
string answer = _lastAnswer, npc = _lastNpc;
|
||||
if (answer.Length > 0)
|
||||
{
|
||||
ImGui.TextColored(IltStyle.ColTeal, answer);
|
||||
SafeImGui.TextColored(IltStyle.ColTeal, answer);
|
||||
ImGui.SameLine();
|
||||
ImGui.TextDisabled("-> " + npc);
|
||||
SafeImGui.TextDisabled("-> " + npc);
|
||||
if (HandInRunning)
|
||||
{
|
||||
if (ImGui.SmallButton("Stop##grdstop")) _ctx.Post(() => StopHandIn());
|
||||
|
|
@ -485,7 +485,7 @@ internal sealed class IltGuardian : IIltFeature
|
|||
}
|
||||
}
|
||||
else ImGui.TextDisabled("No guardian answer yet.");
|
||||
ImGui.TextDisabled("Hand-in: " + _handInStatus);
|
||||
SafeImGui.TextDisabled("Hand-in: " + _handInStatus);
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.InputTextMultiline("##grdinput", ref _input, 2048u, new Vector2(-1, 54));
|
||||
|
|
@ -506,7 +506,7 @@ internal sealed class IltGuardian : IIltFeature
|
|||
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}");
|
||||
SafeImGui.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.)",
|
||||
|
|
@ -531,9 +531,9 @@ internal sealed class IltGuardian : IIltFeature
|
|||
var col = r.Ready ? IltStyle.ColGreen
|
||||
: r.Status == "Unknown" ? IltStyle.ColTextMute
|
||||
: IltStyle.ColAmber;
|
||||
ImGui.TextColored(col, r.Status);
|
||||
SafeImGui.TextColored(col, r.Status);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(r.FromMyQuests ? "From /myquests (exact)." : "From /qb wait stamps (count and timer are estimates).");
|
||||
SafeImGui.SetTooltip(r.FromMyQuests ? "From /myquests (exact)." : "From /qb wait stamps (count and timer are estimates).");
|
||||
ImGui.TableNextColumn(); ImGui.TextUnformatted(r.Eta);
|
||||
}
|
||||
ImGui.EndTable();
|
||||
|
|
@ -555,8 +555,8 @@ internal sealed class IltGuardian : IIltFeature
|
|||
if (answer.Length == 0 || LastAnswerAge > AnswerShownFor) return;
|
||||
ImGui.TextColored(IltStyle.ColTextMute, "Guardian:");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(IltStyle.ColTeal, answer);
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip($"Give to {npc}\nHand-in: {_handInStatus}");
|
||||
SafeImGui.TextColored(IltStyle.ColTeal, answer);
|
||||
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip($"Give to {npc}\nHand-in: {_handInStatus}");
|
||||
ImGui.SameLine();
|
||||
if (HandInRunning)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,12 +35,26 @@ internal sealed class IltHubController
|
|||
private bool _availabilityAnnounced; // "open the Mini Remote" hint printed this session
|
||||
private volatile int _forceRequest = -1; // SetForceIlt from another thread, applied on the next tick
|
||||
|
||||
// "RynthILT.Data" (Plugins/Shared/RynthIltDataApi.cs): the charms and bank snapshots, rebuilt on
|
||||
// the pump every DataRebuildMs only while a reader has asked within DataWatchMs.
|
||||
private const long DataRebuildMs = 2000;
|
||||
private const long DataWatchMs = 6000;
|
||||
/// <summary>How often the other characters' saved balances are re-read for the bank export.</summary>
|
||||
private const long SiblingReadMs = 15_000;
|
||||
private long _charmsReadAt, _bankReadAt; // set by readers (any thread, Interlocked)
|
||||
private long _charmsBuiltAt, _bankBuiltAt, _siblingsReadAt;
|
||||
private volatile string _charmsJson = string.Empty;
|
||||
private volatile string _bankJson = string.Empty;
|
||||
private List<IltBankExport.Row> _siblings = new();
|
||||
|
||||
public IltBanking Banking { get; }
|
||||
public IltSessionRates Rates { get; }
|
||||
/// <summary>The quest bonus list (/qb): the Quests tab's section and the Temple tracker's stamps.</summary>
|
||||
public IltQuestBonus QuestBonus { get; }
|
||||
/// <summary>The /pets and /shinies logs (the Pets tab's section).</summary>
|
||||
public IltPetLogs PetLogs { get; }
|
||||
/// <summary>The pet breeding tracker (the Pets tab's Breeding sub-tab, and the "RynthILT.Data" breeding JSON).</summary>
|
||||
public IltPetBreeding Breeding { get; }
|
||||
public IltProgression Progression { get; }
|
||||
public IltGear Gear { get; }
|
||||
public IltGames Games { get; }
|
||||
|
|
@ -69,6 +83,7 @@ internal sealed class IltHubController
|
|||
|
||||
Banking = new IltBanking(_ctx);
|
||||
PetLogs = new IltPetLogs(_ctx);
|
||||
Breeding = new IltPetBreeding(_ctx);
|
||||
Rates = new IltSessionRates(_ctx);
|
||||
QuestBonus = new IltQuestBonus(_ctx);
|
||||
Progression = new IltProgression(_ctx);
|
||||
|
|
@ -77,7 +92,7 @@ internal sealed class IltHubController
|
|||
Charms = new IltCharmTracker(_ctx);
|
||||
CharmsTab = new IltCharms(_ctx, Charms);
|
||||
Guardian = new IltGuardian(_ctx, QuestBonus);
|
||||
_features.AddRange(new IIltFeature[] { Banking, PetLogs, Rates, QuestBonus, Progression, Gear, CharmsTab, Games, Guardian });
|
||||
_features.AddRange(new IIltFeature[] { Banking, PetLogs, Breeding, Rates, QuestBonus, Progression, Gear, CharmsTab, Games, Guardian });
|
||||
|
||||
Banking.BalanceChanged += Rates.OnBankBalanceChanged;
|
||||
Rates.MovingMoney = () => Banking.MovingMoney;
|
||||
|
|
@ -86,6 +101,81 @@ internal sealed class IltHubController
|
|||
_ctx.ShowTab = section => _ctx.Ai.MiniRemoteTab(IltSections.TabId(section), "show");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The charms JSON ("RynthILT.Data" GetCharmsJson). Reading it marks the charms as watched, so
|
||||
/// the pump keeps the snapshot fresh while a reader is showing it; "" until the first rebuild
|
||||
/// after that. Any thread.
|
||||
/// </summary>
|
||||
public string CharmsJson
|
||||
{
|
||||
get { System.Threading.Interlocked.Exchange(ref _charmsReadAt, IltHubContext.NowMs); return _charmsJson; }
|
||||
}
|
||||
|
||||
/// <summary>The bank JSON ("RynthILT.Data" GetBankJson), as <see cref="CharmsJson"/>.</summary>
|
||||
public string BankJson
|
||||
{
|
||||
get { System.Threading.Interlocked.Exchange(ref _bankReadAt, IltHubContext.NowMs); return _bankJson; }
|
||||
}
|
||||
|
||||
/// <summary>A reader's charm Toggle, posted to the pump (IltCharms checks the id). Any thread.</summary>
|
||||
public void RequestCharmToggle(uint objectId)
|
||||
=> _ctx.Post(() =>
|
||||
{
|
||||
if (!_ctx.Options.IsIltLikeWorld) return;
|
||||
if (!CharmsTab.ToggleFromReader(objectId))
|
||||
RynthLog.Trace(LogCat.IltGear, $"reader toggle refused: 0x{objectId:X8} isn't a carried charm");
|
||||
_charmsBuiltAt = 0; // show the new state on the next tick
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// The pet breeding JSON ("RynthILT.Data" GetPetBreedingJson).
|
||||
/// Reading it keeps the tracker scanning; "" off an ILT world or before its first scan. Any thread.
|
||||
/// </summary>
|
||||
public string PetBreedingJson => _ctx.Options.IsIltLikeWorld ? Breeding.ReaderJson : string.Empty;
|
||||
|
||||
/// <summary>A reader's breeding verb line, posted to the pump (IltPetBreeding.RunVerb). Any thread.</summary>
|
||||
public void RequestBreedingVerb(string line)
|
||||
=> _ctx.Post(() =>
|
||||
{
|
||||
if (!_ctx.Options.IsIltLikeWorld) return;
|
||||
Breeding.RunVerb(line);
|
||||
});
|
||||
|
||||
/// <summary>A reader's bank verb line, posted to the pump (IltBanking.RunVerb). Any thread.</summary>
|
||||
public void RequestBankVerb(string line)
|
||||
=> _ctx.Post(() =>
|
||||
{
|
||||
if (!_ctx.Options.IsIltLikeWorld) return;
|
||||
Banking.RunVerb(line);
|
||||
_bankBuiltAt = 0;
|
||||
});
|
||||
|
||||
/// <summary>Pump: rebuilds the charms / bank snapshots a reader is watching.</summary>
|
||||
private void RebuildReaderData(long now)
|
||||
{
|
||||
if (now - System.Threading.Interlocked.Read(ref _charmsReadAt) < DataWatchMs && now - _charmsBuiltAt >= DataRebuildMs)
|
||||
{
|
||||
_charmsBuiltAt = now;
|
||||
_charmsJson = CharmsTab.BuildReaderJson();
|
||||
}
|
||||
|
||||
bool bankWatched = now - System.Threading.Interlocked.Read(ref _bankReadAt) < DataWatchMs;
|
||||
Banking.ReaderWatching = bankWatched;
|
||||
if (!bankWatched || now - _bankBuiltAt < DataRebuildMs) return;
|
||||
_bankBuiltAt = now;
|
||||
if (_siblingsReadAt == 0 || now - _siblingsReadAt >= SiblingReadMs)
|
||||
{
|
||||
_siblingsReadAt = now;
|
||||
_siblings = IltBankExport.ReadSiblings(_ctx.Store.CharFolder);
|
||||
}
|
||||
IltServerOptions o = _ctx.Options;
|
||||
string me = _ctx.CharName.Length > 0 ? _ctx.CharName : System.IO.Path.GetFileName(_ctx.Store.CharFolder.TrimEnd('\\', '/'));
|
||||
var rows = new List<IltBankExport.Row>(_siblings.Count + 1) { new(me, true, _ctx.State.Bank) };
|
||||
rows.AddRange(_siblings);
|
||||
int enabled = o.IsOn(IltFeature.Bank) ? 1 : o.IsOff(IltFeature.Bank) ? 0 : -1;
|
||||
_bankJson = IltBankExport.Build(o.IsIltLikeWorld, enabled, o.WorldName, me, rows, Banking.LatestResult, Banking.Transactions);
|
||||
}
|
||||
|
||||
public IltHubState State => _ctx.State;
|
||||
public IltServerOptions Options => _ctx.Options;
|
||||
internal IltHubContext Context => _ctx;
|
||||
|
|
@ -94,8 +184,8 @@ internal sealed class IltHubController
|
|||
public bool Available => _ctx.Options.IsIltLikeWorld && _ctx.Options.AnyFeatureOn;
|
||||
|
||||
/// <summary>
|
||||
/// Whether a section can be shown now. Character always can (it explains why the ILT tabs are
|
||||
/// idle and holds the Force-ILT override); the rest need server features.
|
||||
/// Whether a section can be shown now: the ILT tabs and the Guardian need server features.
|
||||
/// Character (moved to RynthOracle) always answers true so its redirect is never refused.
|
||||
/// </summary>
|
||||
public bool SectionAvailable(IltSection section) => section switch
|
||||
{
|
||||
|
|
@ -107,7 +197,7 @@ internal sealed class IltHubController
|
|||
|
||||
/// <summary>
|
||||
/// 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 <see cref="SectionAvailable"/>.
|
||||
/// override from RynthCore Options > Diagnostics). The tabs then follow <see cref="SectionAvailable"/>.
|
||||
/// </summary>
|
||||
public bool OffersTabs => _ctx.Options.IsIltLikeWorld;
|
||||
|
||||
|
|
@ -117,6 +207,15 @@ internal sealed class IltHubController
|
|||
/// <summary>Render thread: one Mini Remote ILT tab's body (RynthAi's MiniRemoteHud draws the tab bar).</summary>
|
||||
public void RenderTab(IltSection section) => _ui.RenderTab(section);
|
||||
|
||||
/// <summary>
|
||||
/// Render thread: the ILT session extras (coins, pyreals, item conversions) in RynthCore's Mini
|
||||
/// Remote "Session Stats" section, below RynthAi's session stats (surface "section:ilt-rates").
|
||||
/// </summary>
|
||||
public void RenderRatesSection() => _ui.RenderRatesSection();
|
||||
|
||||
/// <summary>Render thread: the /qb list in RynthILT's own Quests section (surface "section:ilt-questbonus").</summary>
|
||||
public void RenderQuestBonusSection() => _ui.RenderQuestBonusSection();
|
||||
|
||||
/// <summary>Render thread: the Guardian panel's body (RynthPluginRenderEmbed "guardian").</summary>
|
||||
public void RenderGuardianPanel() => _ui.RenderGuardianPanel();
|
||||
|
||||
|
|
@ -180,6 +279,10 @@ internal sealed class IltHubController
|
|||
_ctx.Options.Tick();
|
||||
PollQuestOutcome();
|
||||
|
||||
// The charms / bank snapshots other plugins read (RynthILT.Data), only while watched.
|
||||
try { RebuildReaderData(now); }
|
||||
catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "RebuildReaderData"); }
|
||||
|
||||
// "Mini Remote on screen" gates bank auto-refresh and the gear / split-arrow scans.
|
||||
_ctx.State.WindowVisible = _ctx.Ai.MiniRemoteVisible;
|
||||
|
||||
|
|
@ -237,7 +340,7 @@ internal sealed class IltHubController
|
|||
private static LogCat CategoryOf(IIltFeature f) => f switch
|
||||
{
|
||||
IltBanking => LogCat.IltBanking,
|
||||
IltPetLogs => LogCat.IltPets,
|
||||
IltPetLogs or IltPetBreeding => LogCat.IltPets,
|
||||
IltSessionRates => LogCat.IltRates,
|
||||
IltQuestBonus => LogCat.IltQuests,
|
||||
IltProgression => LogCat.IltProgression,
|
||||
|
|
@ -353,24 +456,31 @@ internal sealed class IltHubController
|
|||
{
|
||||
// Quests and Pets are RynthAi's tabs: not ours to open.
|
||||
if (args.Length >= 2 && IltSections.IsUniversalTabName(args[1])) return false;
|
||||
_ctx.Chat("[Mini Remote] Usage: /ra hub open character|quests|pets|banking|gear|charms|games|guardian|bounties [show|hide|toggle]");
|
||||
_ctx.Chat("[Mini Remote] Usage: /ra hub open pets|banking|gear|charms|games|guardian|bounties [show|hide|toggle] (character: /ro character, quests: /ro)");
|
||||
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))
|
||||
if (args.Length > 1 && IltSections.TryParse(args[1], out IltSection tab) && IltSections.MovedCommand(tab) is string moved)
|
||||
OpenMoved(tab, moved);
|
||||
else if (args.Length > 1 && IltSections.TryParse(args[1], out tab) && IltSections.IsTab(tab))
|
||||
_ctx.Ai.MiniRemoteTab(IltSections.TabId(tab), "select");
|
||||
else
|
||||
return false; // the Remote tab or a RynthAi tab: RynthAi's
|
||||
break;
|
||||
case "refresh": _ctx.Options.Refresh(manual: true); break;
|
||||
case "bank": Banking.RequestRefresh(quiet: false); break;
|
||||
// "/ilt qb": reads the /qb list again (the Quests tab's quest bonus section).
|
||||
case "qb": _ctx.Chat("[RynthILT] " + QuestBonus.RefreshQb()); break;
|
||||
case "status": PrintStatus(); break;
|
||||
case "features": PrintFeatures(); 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.");
|
||||
_ctx.Chat(IltServerOptions.EngineDecides
|
||||
? $"[Mini Remote] Force ILT world: {(_ctx.State.ForceLeaftideFeatures ? "on" : "off")} for this character (RynthCore counts it unless /rc server ilt off). Use /ra hub refresh to re-check the server."
|
||||
: $"[Mini Remote] Force ILT world: {(_ctx.State.ForceLeaftideFeatures ? "on" : "off")}. Use /ra hub refresh to re-check the server.");
|
||||
break;
|
||||
case "servers": HandleServers(rest); break;
|
||||
case "profile": HandleProfile(args.Skip(1).ToArray()); break;
|
||||
|
|
@ -383,11 +493,11 @@ internal sealed class IltHubController
|
|||
ClearPending();
|
||||
break;
|
||||
default:
|
||||
_ctx.Chat("[Mini Remote] /ra hub [show|hide|toggle] (Mini Remote)|refresh|bank|status|force on|off|servers [list]|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 [show|hide|toggle] (Mini Remote)|refresh|bank|status|features|force on|off|servers [list]|clap|confirm|cancel");
|
||||
_ctx.Chat("[Mini Remote] /ra hub open pets|banking|gear|charms|games [show|hide|toggle] (Mini Remote tabs; character: /ro character, quests: /ro)");
|
||||
_ctx.Chat("[Mini Remote] /ra hub profile list|save <name> [shared]|load <name> /ra hub suit list|test|load [name]");
|
||||
_ctx.Chat("[Mini Remote] /ra hub attr run|stop|costs|status|auto on|off|every <min>|raise <stat> <n> (Skills panel > Progression)");
|
||||
_ctx.Chat("[Mini Remote] /ra quests [refresh|check <regex>|window [show|hide]|favhud [show|hide]] /ra pets [show|hide]");
|
||||
_ctx.Chat("[Mini Remote] /ra quests refresh (quiet /myquests) /ra pets [show|hide] /ilt qb (the quest bonus list)");
|
||||
_ctx.Chat("[Mini Remote] /ra guardian [window|translate <text>|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)");
|
||||
_ctx.Chat("[Mini Remote] The ILT verbs also work as /ilt hub ..., /ilt guardian ... (RynthILT).");
|
||||
|
|
@ -396,6 +506,17 @@ internal sealed class IltHubController
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>"/ra hub features": every Leaftide feature RynthILT supports, with the server's state for each.</summary>
|
||||
private void PrintFeatures()
|
||||
{
|
||||
IltServerOptions o = _ctx.Options;
|
||||
string world = o.WorldName.Length > 0 ? o.WorldName : "unknown world";
|
||||
_ctx.Chat($"[Mini Remote] Leaftide features on {world} ({(o.IsIltLikeWorld ? "ILT world" : "not an ILT world")}, "
|
||||
+ $"fellowships up to {IltFeatureCatalog.FellowshipMax(o.IsIltLikeWorld)}):");
|
||||
foreach (string line in IltFeatureCatalog.BuildChatLines(o.IsIltLikeWorld, o.Get))
|
||||
_ctx.Chat("[Mini Remote] " + line);
|
||||
}
|
||||
|
||||
/// <summary>"/ra hub servers [list | <names, comma separated> | default]": which world names count as Infinite Leaftide.</summary>
|
||||
private void HandleServers(string rest)
|
||||
{
|
||||
|
|
@ -448,6 +569,12 @@ internal sealed class IltHubController
|
|||
/// </summary>
|
||||
private void OpenSection(IltSection section, string mode)
|
||||
{
|
||||
if (IltSections.MovedCommand(section) is string moved)
|
||||
{
|
||||
// Character left the Mini Remote: open its new home instead.
|
||||
if (!mode.Equals("hide", StringComparison.OrdinalIgnoreCase)) OpenMoved(section, moved);
|
||||
return;
|
||||
}
|
||||
if (!IltSections.IsTab(section))
|
||||
{
|
||||
OpenEnginePanel(IltSections.TabId(section), IltSections.Label(section), mode);
|
||||
|
|
@ -459,6 +586,19 @@ internal sealed class IltHubController
|
|||
_ctx.Chat("[Mini Remote] " + reply);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the new home of a section that moved out of the Mini Remote (RynthOracle's Character
|
||||
/// tab) by running its chat command, or says where it is when the command can't run (an older
|
||||
/// RynthCore, or RynthOracle not loaded). Pump thread.
|
||||
/// </summary>
|
||||
public void OpenMoved(IltSection section, string command)
|
||||
{
|
||||
if (_ctx.Host.HasInvokeChatParser && _ctx.Host.InvokeChatParser(command))
|
||||
return;
|
||||
_ctx.Chat($"[Mini Remote] {IltSections.Label(section)} moved to RynthOracle's Character tab ({command}); "
|
||||
+ "the ILT session rates are in the Mini Remote's Session Stats.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens / closes one of RynthCore's ILT panels ("/rc bounties|guardian [show|hide|toggle]")
|
||||
/// through the engine's chat dispatcher. Pump thread.
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public sealed class IltHubState
|
|||
public sealed class IltServerOptionsSnapshot
|
||||
{
|
||||
public string WorldName = string.Empty;
|
||||
/// <summary>"ilt-features" (structured dump), "probe" (command probing) or "" (never refreshed).</summary>
|
||||
/// <summary>"probe" (the login probe) or "" (never refreshed).</summary>
|
||||
public string Source = string.Empty;
|
||||
public DateTime LastRefreshUtc = DateTime.MinValue;
|
||||
/// <summary>Feature key → -1 unknown, 0 off, 1 on.</summary>
|
||||
|
|
@ -77,6 +77,8 @@ public sealed class IltBankState
|
|||
/// <summary>Last transfer recipient typed into the transfer form.</summary>
|
||||
public string TransferTarget = string.Empty;
|
||||
public int TransferCurrencyIndex;
|
||||
/// <summary>Transfer form's trade-note denomination (IltBankCommands.NoteDenominations; 9 = MMD).</summary>
|
||||
public int TransferNoteIndex = 9;
|
||||
|
||||
/// <summary>Deposit / withdraw form choices (IltBankCommands.Deposits / Withdrawals / NoteDenominations).</summary>
|
||||
public int DepositIndex;
|
||||
|
|
@ -106,6 +108,8 @@ public sealed class IltPetState
|
|||
/// <summary>Last captured /pets and /shinies rosters (display only; the Pets tab's logs).</summary>
|
||||
public List<string> PetLog = new();
|
||||
public List<string> ShinyLog = new();
|
||||
/// <summary>The breeding tracker: rules this server showed, growth stage names, recent events (IltPetBreeding).</summary>
|
||||
public IltBreedingState Breeding = new();
|
||||
// The Pets tab's own settings (roster, healing / cosmetic pets, refill path) are RynthAi's
|
||||
// (its miniremote.json); older ilt-hub.json files still carry them, and they are ignored here.
|
||||
}
|
||||
|
|
@ -199,8 +203,17 @@ public sealed class IltGearState
|
|||
public bool AutoChunkCorrupted;
|
||||
public bool ChunkInCombat;
|
||||
public int ChunkIntervalMs = 2000;
|
||||
/// <summary>Only chunk aetheria whose max level is below this (Coalesced always chunks).</summary>
|
||||
/// <summary>
|
||||
/// Only chunk aetheria whose max level is below this (Coalesced always chunks). Infinite Leaftide
|
||||
/// aetheria goes up to level <see cref="IltInventory.AetheriaMaxLevel"/>, so the cap runs to one past it.
|
||||
/// </summary>
|
||||
public int ChunkAetheriaUnderLevel = 4;
|
||||
/// <summary>Never chunk aetheria carrying a Crit rating (C, GearCrit 372; ILT tier-10 sigils of level 6+).</summary>
|
||||
public bool KeepAetheriaWithCrit = true;
|
||||
/// <summary>Never chunk aetheria carrying a Crit Damage rating (CD, GearCritDamage 374).</summary>
|
||||
public bool KeepAetheriaWithCritDamage = true;
|
||||
/// <summary>Never chunk aetheria carrying a Crit Damage Resist rating (CDR, GearCritDamageResist 375).</summary>
|
||||
public bool KeepAetheriaWithCritDamageResist = true;
|
||||
|
||||
// Auto-clap (/clap all)
|
||||
public bool AutoClap;
|
||||
|
|
@ -216,6 +229,14 @@ public sealed class IltGearState
|
|||
|
||||
// Equipment profiles (.utl suits). (The VTank .usd import path is RynthAi's: the importer stayed there.)
|
||||
public string LastEquipProfile = string.Empty;
|
||||
|
||||
// Rings inscription chain (IltRingChainRunner; SilentKelpie's, moved from RynthAi's Crafting tab)
|
||||
/// <summary>Recipe id (IltRingChain.Recipes) to how many times to craft it. Pump thread only.</summary>
|
||||
public Dictionary<string, int> RingRuns = new(StringComparer.OrdinalIgnoreCase);
|
||||
/// <summary>Answer the server's craft dialog Yes for the queued combines (engine API v85).</summary>
|
||||
public bool RingAnswerCraftDialog = true;
|
||||
/// <summary>Craft and inscribe in combat mode too (servers with combat-mode crafting).</summary>
|
||||
public bool RingAllowInCombat;
|
||||
}
|
||||
|
||||
// ── Games ───────────────────────────────────────────────────────────────────
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue