Repository navigation
Addon: [1.13.0] - Weapon specific durability requirements - #844
Merged
Merged
Conversation
Weapons wear out several times faster than armour, but the only durability
figure the addon transmitted was the average over all 18 equipped slots. Fifteen
of those slots are armour, so the average is effectively an armour gauge: a main
hand at 12% still reads 91% overall, and a repair gate written against it either
fires far too late or, once the threshold is raised enough to catch the weapon,
fires constantly.
Cell 116 now carries the three weapon slots individually, packed the way the
other multi-value cells are:
mainHand * 10000 + offHand * 100 + ranged each 0-99, max 999999
There was no free index left - 0..115 were all written, 116 was GLOBAL_TIME_CELL
and 117 the validation cell - so NUMBER_OF_FRAMES goes 118 -> 119, which frees
116 for data and shifts global time to 117 and validation to 118. Both of those
are derived on the Lua side and on the C# side (AddonReader takes
frames.Length - 2, the hosts load frames from FrameConfig), so nothing else moves.
The bump costs users nothing extra either: FrameConfig.IsValid already discards a
saved config whenever the addon version changes, and any *.lua edit requires that
bump anyway.
Each slot reuses the existing (current + 1) * 100 / (max + 1) - 1 formula rather
than inventing a sentinel for "nothing there". The +1 bias means an empty slot -
or an equipped item with no durability at all, such as a thrown weapon, an off
hand tome or a relic - already computes 99, while a genuinely broken item
computes 0. Because the not-applicable value is the *maximum*, the minimum across
the three slots stays meaningful for every spec: a caster with an empty off hand
and no ranged weapon gets its main hand back, a dual wielder the worse of two, a
hunter the worst of three. A sentinel of 0 or -1 would have poisoned that.
The per-slot values are folded into the existing 1..18 loop, so the recompute
costs no additional GetInventoryItemDurability calls, and both figures share the
one dirty flag - whichever accessor is read first fills both.
UPDATE_INVENTORY_DURABILITY does not fire when gear is swapped, which would leave
a freshly equipped weapon reporting the old one's percentage - precisely the case
this change exists to catch. PLAYER_EQUIPMENT_CHANGED already drives the
equipment queue behind cells 23/24, so the cache is invalidated from there.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017sTUjLpcWDFC5dhbHRrMy3
A new data cell is a wire format change, so this is a minor bump rather than a patch. It is also what forces every user to re-run frame configuration: FrameConfig.IsValid compares the saved AddonVersion, and a stale config would otherwise be missing cell 116 entirely. All four TOCs, since they drift silently if one is missed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017sTUjLpcWDFC5dhbHRrMy3
Closes #842. A profile can now gate on the weapon slots instead of settling for the all-slot average: "Requirement": "Durability% < 35 || WeaponDurability% < 30" Four new int variables - MainHandDurability%, OffHandDurability%, RangedDurability% and WeaponDurability%, the last being the lowest of the three and the one a repair gate actually wants. They decode cell 116, which the addon fills per weapon slot. Registering them as plain intVariables means the comparison and arithmetic operators come from ExpressionParser for free, with no handler code and no exposure to the substring dispatch that parameterized keywords go through. Durability% is untouched: still the average across all 18 slots, so the ~40 shipped profiles that gate on it keep behaving exactly as before. Opting into the weapon figure is a profile edit, not a migration. All four decoders are public zero-arg int methods, so TableOfComponent's reflection lists them on the raw PlayerReader page without a Razor change. The README gains the four table rows plus a note on the one thing that is not self-evident: 99 means "fully repaired" *and* "nothing there that can break", and that is deliberate, because it is what keeps WeaponDurability% meaningful for a spec that leaves a weapon slot empty. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017sTUjLpcWDFC5dhbHRrMy3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #842.
The problem
Durability%is the average across all 18 equipped slots. Fifteen of those are armour, so the figure is effectively an armour gauge — and weapons wear out several times faster than armour. By the time a full armour set has dragged the average under a repair threshold, the weapon has already broken; raise the threshold enough to catch the weapon and the bot repairs constantly.Numbers from a harness over the real formula, showing what a profile writing
Durability% < 35actually sees:Durability%WeaponDurability%Durability% < 35fires in none of the first four rows.What this adds
Four requirement keywords, all
0-99:MainHandDurability%OffHandDurability%RangedDurability%WeaponDurability%{ "Name": "Repair", "Key": "C", "Requirement": "Durability% < 35 || WeaponDurability% < 30" }Durability%is unchanged, so the ~40 shipped profiles gating on it keep behaving exactly as before. Opting in is a profile edit, not a migration.How it works
Wire format — new cell 116
No index was free:
0..115were all written,116wasGLOBAL_TIME_CELLand117the validation cell.NUMBER_OF_FRAMESgoes 118 → 119, freeing 116 for data and shifting global time to 117, validation to 118. Both are derived on each side — Lua computes them fromNUMBER_OF_FRAMES,AddonReadertakesframes.Length - 2, and both hosts load their frames fromFrameConfig.LoadFrames()— so nothing else moves. Grepped: no.csor.razorhardcodes 116/117/118 as a cell index, andDependencyInjection'sframeCount = 120buffer still covers 119.Packed the way the other multi-value cells are (cf. cell 55, cell 75):
The frame bump costs users nothing extra:
FrameConfig.IsValidalready discards a saved config whenever the addon version changes, andAddons/DataToColor/CLAUDE.mdrequires that bump for any*.luaedit anyway. Precedent: 26f8c82 took 117 → 118.Why 99 means both "full" and "not applicable"
Each slot reuses the formula already behind
Durability%:The
+1bias makes an empty slot — or an equipped item with no durability at all, such as a thrown weapon, an off hand tome or a Wrath relic — compute 99, while a genuinely broken item computes 0. No sentinel, no presence bitmask.That the not-applicable value is the maximum is the load-bearing part: it is what keeps
min(main, off, ranged)meaningful for every spec. A caster with an empty off hand and no ranged weapon gets its main hand back, a dual wielder the worse of two, a hunter the worst of three. A sentinel of0or-1would have poisoned the minimum for anyone not wearing all three.Cost and cache invalidation
The per-slot values are folded into the existing
1..18loop, so a recompute costs no additionalGetInventoryItemDurabilitycalls, and both figures share the one dirty flag — whichever accessor is read first fills both.UPDATE_INVENTORY_DURABILITYdoes not fire when gear is swapped, which would leave a freshly equipped weapon reporting the old one's percentage — precisely the case this feature exists to catch.PLAYER_EQUIPMENT_CHANGEDalready drives the equipment queue behind cells 23/24, so the cache is invalidated from there.Commits
feat(Addon)NUMBER_OF_FRAMES118 → 119, invalidate on equipchore(Addon)feat(Core)Verification
The repo has no test framework, so this was checked by hand on a live client:
dotnet build MasterOfPuppets.sln— 0 errors, no new warningsluac -pon all three modified Lua filesDataFrameMeta and FrameConfig dosen't matchwarningNo Razor change was needed: the four decoders are public zero-arg
intmethods, soTableOfComponent's reflection lists them on the rawPlayerReaderpage automatically.🤖 Generated with Claude Code
https://claude.ai/code/session_017sTUjLpcWDFC5dhbHRrMy3