From 5623fe8d8a256c26dcd788bb2121fdb992779f6d Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 24 Sep 2026 20:01:51 -0600 Subject: [PATCH] Support current WoW client families with verified compatibility adapters --- .github/workflows/test.yml | 4 + AUDIT_2026-09-24.md | 2 + CHANGELOG.md | 8 + CLIENT_COMPATIBILITY.md | 44 +++ CLIENT_RESEARCH_2026-09-24.md | 2 + CURSEFORGE_DESCRIPTION.md | 23 +- ClientDiagnostics.lua | 6 +- ClientDiagnosticsTests.lua | 4 +- Core.lua | 20 ++ Diagnostics.lua | 14 +- HUDWidget.lua | 30 +- LIBCHEV_INTEGRATION.md | 2 + NoPoizen.toc | 15 +- PoisonData.lua | 114 +++++++ PoisonMonitor.lua | 49 ++- PoisonMonitorTests.lua | 17 + WeaponPoisonTests.lua | 232 +++++++++++++ WeaponPoisons.lua | 337 +++++++++++++++++++ scripts/build_poison_catalog.py | 48 +++ scripts/package.py | 2 +- scripts/poison-data-sources.json | 537 +++++++++++++++++++++++++++++++ scripts/smoke.lua | 59 +++- 22 files changed, 1526 insertions(+), 43 deletions(-) create mode 100644 CLIENT_COMPATIBILITY.md create mode 100644 PoisonData.lua create mode 100644 WeaponPoisonTests.lua create mode 100644 WeaponPoisons.lua create mode 100644 scripts/build_poison_catalog.py create mode 100644 scripts/poison-data-sources.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a010bee..7216017 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,10 @@ jobs: - run: lua${{ matrix.lua }} scripts/test.lua . reverse - run: lua${{ matrix.lua }} scripts/smoke.lua . retail - run: lua${{ matrix.lua }} scripts/smoke.lua . forever + - run: lua${{ matrix.lua }} scripts/smoke.lua . era + - run: lua${{ matrix.lua }} scripts/smoke.lua . tbc + - run: lua${{ matrix.lua }} scripts/smoke.lua . mists + - run: lua${{ matrix.lua }} scripts/smoke.lua . titan - run: python3 ../library/scripts/vendor.py . --check - run: python3 scripts/package.py --library-source ../library --output /tmp/NoPoizen.zip - run: python3 -B -m unittest discover -s scripts -p 'test_*.py' diff --git a/AUDIT_2026-09-24.md b/AUDIT_2026-09-24.md index 4684875..999cef4 100644 --- a/AUDIT_2026-09-24.md +++ b/AUDIT_2026-09-24.md @@ -1,5 +1,7 @@ # NoPoizen audit — September 24, 2026 +Historical report: Forever monitoring and Classic adapters have since been implemented. See [CLIENT_COMPATIBILITY.md](CLIENT_COMPATIBILITY.md) for current behavior, evidence and remaining live checks. + Baseline: **1.0.7**, `71412d6`, clean `main` synchronized with `origin/main` before edits. Initial test build: **1.0.8-beta.2** on `fix/retail-forever-audit`. The work is now in PR #1, with **1.1.0-beta.1** prepared for coordinated release. Publication remains gated. Existing save files and original audio sources were not modified. Installed clients rechecked: **Retail 12.1.0.69933**, **Forever beta 1.60.1.69977**. TOC adds interfaces **120100** and **16001**, retaining previous Retail metadata. This is permission to load the test build, not certification of live compatibility. diff --git a/CHANGELOG.md b/CHANGELOG.md index 4eacb2c..3c3058a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # NoPoizen changelog +## 1.2.0 — 2026-09-24 + +Enable real Forever weapon-poison monitoring using verified client spell/enchant data. Add Era/Hardcore/SoD, TBC, Mists and Titan adapters, hand-aware warnings, charge/expiry polling, Classic load metadata and six-client offline coverage. Preserve Retail aura/talent behavior and shared diagnostics. Live validation remains pending. + +Validation: 140 tests pass in both orders on Lua 5.1 and 5.2, with six client profiles, Lua parsing and exact private-library vendor checks. NoPoizen client smoke checks and package verification also pass. Live validation of the new adapters remains pending. + +See [CLIENT_COMPATIBILITY.md](CLIENT_COMPATIBILITY.md) for source evidence, scope and validation limits. + ## 1.1.1 — 2026-09-24 Keep overlapping debug consoles and their controls in one native stacking group through private libchev 1.1.3. Category menus stay with their owning console. diff --git a/CLIENT_COMPATIBILITY.md b/CLIENT_COMPATIBILITY.md new file mode 100644 index 0000000..24d2c83 --- /dev/null +++ b/CLIENT_COMPATIBILITY.md @@ -0,0 +1,44 @@ +# NoPoizen client compatibility + +One source tree supports these current client families. Interface metadata permits loading; API capabilities still decide which adapter can run. PTR/beta builds in the same family use those adapters when their contracts match. This does not claim support for arbitrary historical/private-server clients. + +| Client family | Source snapshot | Interface targets | +| --- | --- | --- | +| Retail | Installed 12.1.0.69933 UI export | 120100 (existing older Retail targets retained) | +| Forever | Installed 1.60.1.69977 UI export; 1.60.1.70009 spell data | 16001 | +| Era / Hardcore / Season of Discovery | [1.15.9.69722](https://github.com/Gethe/wow-ui-source/tree/33e177d9bf38d76d5c6c6e05d5da78db1899659a) | 11509 | +| Anniversary / Burning Crusade | [2.5.6.69795](https://github.com/Gethe/wow-ui-source/tree/1463c686270b6c64e2c5c228f447c4597c0f8ba6) | 20506 | +| Mists Classic | [5.5.4.69934](https://github.com/Gethe/wow-ui-source/tree/cde55d0033e89b246381385b2f063cd6c6047ef8) | 50504 | +| Titan Reforged (China) | [3.80.2.69874](https://github.com/Gethe/wow-ui-source/tree/84ef503f0d2617494db84cc9c7e7b530e976f6e7) | 38001, 38002 | + +The Classic references are mirrored Blizzard UI/API source. Source inspection and offline fixtures establish expected contracts, not engine-level taint safety, rendering or gameplay validation. The user requested source-backed implementation without waiting to level a Forever rogue. Live poison application, expiry, charge exhaustion and audio checks remain pending; no live test result is inferred from these fixtures. No SavedVariables were changed externally. + +## Monitoring behavior + +- Retail retains learned lethal/nonlethal aura checks and Dragon-Tempered Blades requirements. +- Forever uses **all** accessible rows (including sparse or zero-based tables) from `C_Item.GetWeaponEnchantInfo(Enum.WeaponSlot)`, requiring one verified poison on each equipped melee weapon. It recognizes both poison training spells (`2842`, `1298494`), reads time in milliseconds, and checks charges only for poisons whose client data defines charges. Other coatings do not satisfy poison requirements. A valid poison can coexist with another coating. +- Era/Hardcore/SoD and TBC use per-weapon temporary enchants. The exact client catalog controls rank and charge handling. SoD-specific Sebacious, Numbing, Atrophic and Occult poisons are in the Era catalog only. TBC has its additional ranks and Anesthetic Poison, with no charge requirement. +- Titan uses its Wrath-derived weapon poison catalog, including ranks VIII/IX. Vendor poisons become usable at level 20; eligibility does not require the retired crafting skill. `ItemSparse` item `6947` explicitly requires level 20, rogue class mask 8, and no required skill. +- Mists uses its own lethal/nonlethal aura catalog, including Leeching and Paralytic Poison, without Retail's Dragon-Tempered Blades rules. + +Empty hands, shields and holdables do not need poison. A missing item query, inaccessible enchant result or failed restriction check stays **unknown**, with no missing alert. Weapon reads pause during combat/restrictions; recovery establishes a quiet audio baseline. Enchant/equipment events refresh immediately, with a one-second poll covering expiry and charge changes. Disable removes polling; loading/logout prevent further observations. + +HUD hand/category rows, settings, startup grace, transition audio, restriction policy and the private libchev debug console remain shared across clients. `/np edit` works independently of native Edit Mode; the native callback bridge is optional. + +## Poison identity evidence + +The generated `PoisonData.lua` comes from the actual client DB2 records, mirrored by Wago, rather than copying a Classic lookup into Forever: + +- [Forever SpellItemEnchantment](https://wago.tools/db2/SpellItemEnchantment?build=1.60.1.70009), [SpellEffect](https://wago.tools/db2/SpellEffect?build=1.60.1.70009), [SpellName](https://wago.tools/db2/SpellName?build=1.60.1.70009). +- Matching tables for Era `1.15.9.69722`, TBC `2.5.6.69795`, and Titan `3.80.2.69874` are pinned in `scripts/poison-data-sources.json`, including SHA-256 digests and selected spell/enchant pairs. +- Forever's actual application records use effect **360** (for example spell `8679` -> enchant `323`); Era/TBC/Titan use effect **54**. Only explicitly named rogue poison families with matching enchant records enter the catalog. Generic poison, NPC toxin, rune engraving, sharpening stone, oil and shaman imbue records are excluded. This also prevents dormant SoD spell records in Forever's data from being mistaken for active Forever coatings. +- Enchantment `Charges` is positive for charged Forever/Era poisons, zero for Crippling and for TBC/Titan poisons. Presence, icon or enchant type alone never establishes poison identity. +- Forever `Spell`/`SpellEffect` records `2842` and `1298494` describe poison crafting and skill lines 40/2988. Mists `Spell`/`SpellEffect` records `2823`, `8679`, `3408`, `5761`, `108211`, `108215` explicitly describe lethal/nonlethal coatings implemented as player auras. + +To reproduce the catalog, download `https://wago.tools/db2//csv?build=` as `-
.csv`, run `python3 scripts/build_poison_catalog.py /path/to/csv-cache`, then format `PoisonData.lua` with StyLua. Raw CSV files are research inputs, not runtime payloads. The generated Lua and provenance JSON are committed. + +## Validation + +Run `lua scripts/test.lua` and `lua scripts/test.lua . reverse`. Run `lua scripts/smoke.lua . ` for `retail`, `forever`, `era`, `tbc`, `mists`, `titan` under Lua 5.1 and 5.2. The smoke checks load the real TOC and exercise startup, warning/satisfied transitions, restriction recovery, polling, settings/editing, console isolation, loading, disable/re-enable and logout. Private in-game fixtures cover secrets, malformed results, wrong coatings, charge policy, hand swaps, rank catalogs and Mists talent differences. + +Follow up with actual poison application on each relevant client when characters are available. In particular, confirm Forever exposes trained poison abilities through the spell-knowledge API and returns the documented weapon rows. Any unexpected runtime shape fails quietly and appears in `/np diagnostics`; it must not be treated as a successful live observation. diff --git a/CLIENT_RESEARCH_2026-09-24.md b/CLIENT_RESEARCH_2026-09-24.md index b5121e5..1c6e7a8 100644 --- a/CLIENT_RESEARCH_2026-09-24.md +++ b/CLIENT_RESEARCH_2026-09-24.md @@ -1,5 +1,7 @@ # NoPoizen client/API evidence — September 24, 2026 +Historical report: Forever monitoring and Classic adapters have since been implemented. See [CLIENT_COMPATIBILITY.md](CLIENT_COMPATIBILITY.md) for current behavior, evidence and remaining live checks. + Re-read the installed `.build.info`: Retail is **12.1.0.69933** (`wow`), Forever beta is **1.60.1.69977** (`wow_classic_beta`). Interface targets are **120100** and **16001** respectively. Plater's inspected current TOC independently declares `Interface-Mainline: 120100, 120105` and `Interface-Camelot: 16001`; the uninstalled 12.1.5 target does not establish NoPoizen compatibility. Both client exports were read directly, under: diff --git a/CURSEFORGE_DESCRIPTION.md b/CURSEFORGE_DESCRIPTION.md index b10a56e..9fff455 100644 --- a/CURSEFORGE_DESCRIPTION.md +++ b/CURSEFORGE_DESCRIPTION.md @@ -2,24 +2,18 @@ NoPoizen is a focused quality-of-life addon for **Rogues** that helps you avoid fighting without proper poisons active. -On supported Retail clients, it watches your current poison state and warns when you are missing required poisons. Unreadable or restricted observations do not trigger missing-poison warnings. +On Retail and Mists it watches your poison auras; on Forever, Era/Hardcore/SoD, TBC and Titan Reforged it checks poison coverage on your equipped weapons. It warns when required poisons are missing. Unreadable or restricted observations do not trigger missing-poison warnings. ## What It Does -- Monitors **lethal** and **non-lethal** poison categories. -- Shows a center-screen reminder widget when your poison setup is incomplete. -- Supports talent-based poison limits: - - Default: up to `1 lethal + 1 non-lethal`, limited to learned poison categories - - With `Dragon-Tempered Blades`: `2 lethal + 2 non-lethal` -- Uses a two-row display: - - Row 1: Lethal Poisons - - Row 2: Non-Lethal Poisons -- Removes already-applied poisons from each row. -- Hides an entire row once that category is fully satisfied. +- Retail/Mists: monitors learned **lethal** and **non-lethal** poison categories; Retail also accounts for **Dragon-Tempered Blades**. +- Forever and weapon-based Classic clients: checks each equipped melee weapon and labels missing coverage **Main Hand** or **Off Hand**. +- Recognizes actual poison enchants; other weapon coatings do not count. +- Shows a movable reminder while an observable poison requirement is missing and hides satisfied rows. ## Indicator Position and Scale -Open Blizzard **Edit Mode** to see NoPoizen alongside your other HUD elements. Drag its preview or click it to open position and scale controls. `/np edit` also opens those controls directly. +Where available, open Blizzard **Edit Mode** to see NoPoizen alongside your other HUD elements. Drag its preview or click it to open position and scale controls. `/np edit` also opens those controls directly. - Drag the indicator to place it where you want. - Scale the indicator up/down in real time. @@ -83,8 +77,9 @@ All settings are **per-character**, including: ## Compatibility Notes -- Retail WoW: updated for the installed 12.1 client; live validation of this beta is pending. -- Forever beta: experimental loading and diagnostics only. Poison/coating identifiers are not yet verified, so poison warnings remain disabled there. +- Targets Retail, Forever, Era/Hardcore/SoD, Anniversary/TBC, Mists Classic and Titan Reforged. +- Forever monitoring is implemented using client spell/enchant data, including multiple coatings and poison charges. +- Source and offline validation are complete; in-game validation of the new client adapters remains pending. - Rogue-only behavior by design - Indicator logic automatically reacts to spec/talent changes and aura updates diff --git a/ClientDiagnostics.lua b/ClientDiagnostics.lua index 50fd74b..1eab2fc 100644 --- a/ClientDiagnostics.lua +++ b/ClientDiagnostics.lua @@ -205,10 +205,8 @@ local function BuildClientCapabilityLines(api) lines[#lines + 1] = "Weapon samples: modern multi-enchant API unavailable" return lines end - -- Samples are observations only. No row is classified as poison by its type, - -- icon, presence, or charges; Forever poison IDs require client evidence. - lines[#lines + 1] = - "Forever poison spell/enchant mapping: unverified; weapon samples do not establish poison coverage" + -- Raw samples remain separate from the detector's verified enchant catalog. + lines[#lines + 1] = "Forever poison spell/enchant mapping: client data 1.60.1.70009; live validation pending" local safeOK, safe, reason = pcall(api.CanSample) if not safeOK or not api.CanAccessValue(safe) or safe ~= true then lines[#lines + 1] = "Weapon samples: skipped (" diff --git a/ClientDiagnosticsTests.lua b/ClientDiagnosticsTests.lua index 7997b3b..fd2839c 100644 --- a/ClientDiagnosticsTests.lua +++ b/ClientDiagnosticsTests.lua @@ -77,7 +77,7 @@ NoPoizen:RegisterTest("client diagnostics use weapon enums and preserve empty sa Contains(report, "interface=16001") Contains(report, "MainHand: no enchant rows") Contains(report, "OffHand: no enchant rows") - Contains(report, "mapping: unverified") + Contains(report, "mapping: client data 1.60.1.70009") end) NoPoizen:RegisterTest("client diagnostics skip samples under restrictions", function() @@ -144,7 +144,7 @@ NoPoizen:RegisterTest("client diagnostics retain multiple coating rows without p local report = Report(api) Contains(report, "id=100 ms=1000 charges=0") Contains(report, "id=200 ms=2000 charges=40") - Contains(report, "weapon samples do not establish poison coverage") + Contains(report, "live validation pending") end) NoPoizen:RegisterTest("client diagnostics bound oversized enchant observations", function() diff --git a/Core.lua b/Core.lua index 993e072..2fa3c06 100644 --- a/Core.lua +++ b/Core.lua @@ -67,6 +67,8 @@ NoPoizen.runtimeEvents = { "PLAYER_ALIVE", "PLAYER_EQUIPMENT_CHANGED", "UNIT_INVENTORY_CHANGED", + "WEAPON_ENCHANT_CHANGED", + "WEAPON_SLOT_CHANGED", "ADDON_RESTRICTION_STATE_CHANGED", } @@ -571,6 +573,9 @@ function NoPoizen:Enable() self.postLoadRefreshAt = 0 LibChev.Advance(self, "postLoadRefreshToken") self:ResetAudioTransitionArming() + if self.StartWeaponPoisonPolling then + self:StartWeaponPoisonPolling() + end if self.EnsurePoisonIndicatorWidget then self:EnsurePoisonIndicatorWidget() @@ -594,6 +599,9 @@ function NoPoizen:Disable() self.db.enabled = false self.isEnabled = false + if self.StopWeaponPoisonPolling then + self:StopWeaponPoisonPolling() + end if self.UnregisterEditModeCallbacks then self:UnregisterEditModeCallbacks() end @@ -807,6 +815,18 @@ function NoPoizen:UNIT_INVENTORY_CHANGED(_, unit) end end +function NoPoizen:WEAPON_ENCHANT_CHANGED() + if self.isEnabled then + self:RefreshPoisonState("WEAPON_ENCHANT_CHANGED") + end +end + +function NoPoizen:WEAPON_SLOT_CHANGED() + if self.isEnabled then + self:RefreshPoisonState("WEAPON_SLOT_CHANGED") + end +end + function NoPoizen:ADDON_RESTRICTION_STATE_CHANGED() -- Restriction queries report false during event dispatch: defer the observation. if not self.isEnabled then diff --git a/Diagnostics.lua b/Diagnostics.lua index 1aa504a..f5d8e97 100644 --- a/Diagnostics.lua +++ b/Diagnostics.lua @@ -17,6 +17,10 @@ function NoPoizen:RecordPoisonObservation(reason, state) self:SafeToString(state.activeCounts and state.activeCounts.nonLethal), self:SafeToString(state.requiredCounts and state.requiredCounts.lethal), self:SafeToString(state.requiredCounts and state.requiredCounts.nonLethal), + self:SafeToString(state.activeCounts and state.activeCounts.mainHand), + self:SafeToString(state.activeCounts and state.activeCounts.offHand), + self:SafeToString(state.requiredCounts and state.requiredCounts.mainHand), + self:SafeToString(state.requiredCounts and state.requiredCounts.offHand), }, "/") self.observationCount = (self.observationCount or 0) + 1 if signature ~= self.lastObservationSignature then @@ -43,8 +47,10 @@ function NoPoizen:BuildDiagnosticReport() Add("reason", state.reason) Add("mode", state.detectionMode) Add("observable", state.observable) - Add("knownPoisonCount", state.knownPoisonCount) - Add("dragonTemperedBlades", state.hasDragonTemperedBlades) + if not state.activeEnchantIDs then + Add("knownPoisonCount", state.knownPoisonCount) + Add("dragonTemperedBlades", state.hasDragonTemperedBlades) + end local function SpellIDs(ids) local parts = {} for index, spellID in ipairs(ids or {}) do @@ -57,7 +63,9 @@ function NoPoizen:BuildDiagnosticReport() end Add("knownSpellIDs", SpellIDs(state.knownSpellIDs)) Add("activeSpellIDs", SpellIDs(state.activeSpellIDs)) - for _, category in ipairs({ "lethal", "nonLethal" }) do + Add("activeEnchantIDs", SpellIDs(state.activeEnchantIDs)) + Add("trainingSpellIDs", SpellIDs(state.trainingSpellIDs)) + for _, category in ipairs({ "lethal", "nonLethal", "mainHand", "offHand" }) do Add(category .. "Required", state.requiredCounts and state.requiredCounts[category]) Add(category .. "Active", state.activeCounts and state.activeCounts[category]) end diff --git a/HUDWidget.lua b/HUDWidget.lua index a022be6..0a30cf7 100644 --- a/HUDWidget.lua +++ b/HUDWidget.lua @@ -7,13 +7,29 @@ end -- These wrappers belong to the addon. Tests use private fixtures, never client globals. NoPoizen.HUDAPI = { IsRestricted = function() + if not NoPoizen:CanAccessValue(C_RestrictedActions) then + return true + end if type(InCombatLockdown) == "function" then local combat = InCombatLockdown() if not NoPoizen:CanAccessValue(combat) or (combat ~= false and combat ~= nil) then return true end end - if C_RestrictedActions and Enum and Enum.AddOnRestrictionType then + if C_RestrictedActions ~= nil then + if + not NoPoizen:CanAccessTable(C_RestrictedActions) + or not NoPoizen:CanAccessTable(Enum) + or not NoPoizen:CanAccessTable(Enum.AddOnRestrictionType) + then + return true + end + if + type(C_RestrictedActions.GetAddOnRestrictionState) ~= "function" + and type(C_RestrictedActions.IsAddOnRestrictionActive) ~= "function" + then + return true + end for _, name in ipairs({ "Combat", "Encounter", "ChallengeMode", "PvPMatch", "Map" }) do local restrictionType = Enum.AddOnRestrictionType[name] if not NoPoizen:CanAccessValue(restrictionType) then @@ -149,9 +165,19 @@ end local function GetDefaultEditModeRows(owner) local rows = {} + if owner.GetPoisonClient and owner.weaponPoisonCatalogs and owner.weaponPoisonCatalogs[owner:GetPoisonClient()] then + return { + { category = "mainHand", icons = { { icon = 132273 } } }, + { category = "offHand", icons = { { icon = 132273 } } }, + } + end + local catalog = owner.poisonCatalog or {} + if owner.GetPoisonClient and owner:GetPoisonClient() == "mists" then + catalog = owner.mistsPoisonCatalog or catalog + end for _, category in ipairs({ "lethal", "nonLethal" }) do local row = { category = category, icons = {} } - for _, spell in ipairs((owner.poisonCatalog or {})[category] or {}) do + for _, spell in ipairs(catalog[category] or {}) do -- A static preview does not need to read auras or spell APIs. table.insert(row.icons, { icon = spell.icon or 134400 }) end diff --git a/LIBCHEV_INTEGRATION.md b/LIBCHEV_INTEGRATION.md index cd4696e..dd0947d 100644 --- a/LIBCHEV_INTEGRATION.md +++ b/LIBCHEV_INTEGRATION.md @@ -1,5 +1,7 @@ # Shared library integration +Historical report: Forever monitoring and Classic adapters have since been implemented. See [CLIENT_COMPATIBILITY.md](CLIENT_COMPATIBILITY.md) for current behavior, evidence and remaining live checks. + NoPoizen privately embeds **libchev 1.1.3**, pinned to immutable commit [`445c0cf5b3dd40d36461f6e0b9adc2feb8dfb16b`](https://github.com/AlexAllocated/libchev/commit/445c0cf5b3dd40d36461f6e0b9adc2feb8dfb16b). The vendored bytes and SHA-256 manifest live in `Libs/libchev/`; the loader binds `namespace.LibChev`. There is no global library registry or compatibility alias. ## Shared behavior and addon policy diff --git a/NoPoizen.toc b/NoPoizen.toc index bb96f38..38b1f4e 100644 --- a/NoPoizen.toc +++ b/NoPoizen.toc @@ -1,7 +1,13 @@ -## Interface: 120000, 120001, 120100, 16001 +## Interface: 120000, 120001, 120100, 16001, 11509, 20506, 50504, 38001, 38002 +## Interface-Mainline: 120000, 120001, 120100 +## Interface-Camelot: 16001 +## Interface-Vanilla: 11509 +## Interface-TBC: 20506 +## Interface-Mists: 50504 +## Interface-Titan: 38001, 38002 ## Title: NoPoizen -## Version: 1.1.1 -## Notes: Warns Rogues when lethal/non-lethal poisons are missing. +## Version: 1.2.0 +## Notes: Warns Rogues when required aura or weapon poisons are missing. ## SavedVariablesPerCharacter: NoPoizenDBChar ## Author: Chev @@ -13,6 +19,8 @@ Libs/libchev/SelfTests.lua Core.lua ClientDiagnostics.lua Diagnostics.lua +PoisonData.lua +WeaponPoisons.lua PoisonMonitor.lua HUDWidget.lua EditMode.lua @@ -21,5 +29,6 @@ Options.lua Tests.lua CoreTests.lua PoisonMonitorTests.lua +WeaponPoisonTests.lua HUDTests.lua ClientDiagnosticsTests.lua diff --git a/PoisonData.lua b/PoisonData.lua new file mode 100644 index 0000000..69989a1 --- /dev/null +++ b/PoisonData.lua @@ -0,0 +1,114 @@ +-- Generated by scripts/build_poison_catalog.py; see CLIENT_COMPATIBILITY.md. +local addon = _G.NoPoizen +if not addon then + return +end +addon.weaponPoisonCatalogs = { + forever = { + [7] = { spellID = 2823, usesCharges = true }, -- Deadly Poison + [8] = { spellID = 2824, usesCharges = true }, -- Deadly Poison II + [22] = { spellID = 3408, usesCharges = false }, -- Crippling Poison + [23] = { spellID = 8693, usesCharges = true }, -- Mind-numbing Poison II + [35] = { spellID = 5761, usesCharges = true }, -- Mind Numbing Poison + [323] = { spellID = 8679, usesCharges = true }, -- Instant Poison + [324] = { spellID = 8686, usesCharges = true }, -- Instant Poison II + [325] = { spellID = 8688, usesCharges = true }, -- Instant Poison III + [603] = { spellID = 11202, usesCharges = false }, -- Crippling Poison II + [623] = { spellID = 11338, usesCharges = true }, -- Instant Poison IV + [624] = { spellID = 11339, usesCharges = true }, -- Instant Poison V + [625] = { spellID = 11340, usesCharges = true }, -- Instant Poison VI + [626] = { spellID = 11355, usesCharges = true }, -- Deadly Poison III + [627] = { spellID = 11356, usesCharges = true }, -- Deadly Poison IV + [643] = { spellID = 11399, usesCharges = true }, -- Mind-Numbing Poison III + [703] = { spellID = 13219, usesCharges = true }, -- Wound Poison + [704] = { spellID = 13225, usesCharges = true }, -- Wound Poison II + [705] = { spellID = 13226, usesCharges = true }, -- Wound Poison III + [706] = { spellID = 13227, usesCharges = true }, -- Wound Poison IV + [2630] = { spellID = 25351, usesCharges = true }, -- Deadly Poison V + }, + era = { + [7] = { spellID = 2823, usesCharges = true }, -- Deadly Poison + [8] = { spellID = 2824, usesCharges = true }, -- Deadly Poison II + [22] = { spellID = 3408, usesCharges = false }, -- Crippling Poison + [23] = { spellID = 8693, usesCharges = true }, -- Mind-numbing Poison II + [35] = { spellID = 5761, usesCharges = true }, -- Mind Numbing Poison + [323] = { spellID = 8679, usesCharges = true }, -- Instant Poison + [324] = { spellID = 8686, usesCharges = true }, -- Instant Poison II + [325] = { spellID = 8688, usesCharges = true }, -- Instant Poison III + [603] = { spellID = 11202, usesCharges = false }, -- Crippling Poison II + [623] = { spellID = 11338, usesCharges = true }, -- Instant Poison IV + [624] = { spellID = 11339, usesCharges = true }, -- Instant Poison V + [625] = { spellID = 11340, usesCharges = true }, -- Instant Poison VI + [626] = { spellID = 11355, usesCharges = true }, -- Deadly Poison III + [627] = { spellID = 11356, usesCharges = true }, -- Deadly Poison IV + [643] = { spellID = 11399, usesCharges = true }, -- Mind-Numbing Poison III + [703] = { spellID = 13219, usesCharges = true }, -- Wound Poison + [704] = { spellID = 13225, usesCharges = true }, -- Wound Poison II + [705] = { spellID = 13226, usesCharges = true }, -- Wound Poison III + [706] = { spellID = 13227, usesCharges = true }, -- Wound Poison IV + [2630] = { spellID = 25351, usesCharges = true }, -- Deadly Poison V + [7254] = { spellID = 439462, usesCharges = false }, -- Sebacious Poison + [7255] = { spellID = 439464, usesCharges = false }, -- Numbing Poison + [7256] = { spellID = 439465, usesCharges = false }, -- Atrophic Poison + [7542] = { spellID = 458821, usesCharges = false }, -- Occult Poison I + [7651] = { spellID = 1214171, usesCharges = false }, -- Occult Poison II + }, + tbc = { + [7] = { spellID = 2823, usesCharges = false }, -- Deadly Poison + [8] = { spellID = 2824, usesCharges = false }, -- Deadly Poison II + [22] = { spellID = 3408, usesCharges = false }, -- Crippling Poison + [23] = { spellID = 8693, usesCharges = false }, -- Mind-numbing Poison II + [35] = { spellID = 5761, usesCharges = false }, -- Mind Numbing Poison + [323] = { spellID = 8679, usesCharges = false }, -- Instant Poison + [324] = { spellID = 8686, usesCharges = false }, -- Instant Poison II + [325] = { spellID = 8688, usesCharges = false }, -- Instant Poison III + [603] = { spellID = 11202, usesCharges = false }, -- Crippling Poison II + [623] = { spellID = 11338, usesCharges = false }, -- Instant Poison IV + [624] = { spellID = 11339, usesCharges = false }, -- Instant Poison V + [625] = { spellID = 11340, usesCharges = false }, -- Instant Poison VI + [626] = { spellID = 11355, usesCharges = false }, -- Deadly Poison III + [627] = { spellID = 11356, usesCharges = false }, -- Deadly Poison IV + [643] = { spellID = 11399, usesCharges = false }, -- Mind-Numbing Poison III + [703] = { spellID = 13219, usesCharges = false }, -- Wound Poison + [704] = { spellID = 13225, usesCharges = false }, -- Wound Poison II + [705] = { spellID = 13226, usesCharges = false }, -- Wound Poison III + [706] = { spellID = 13227, usesCharges = false }, -- Wound Poison IV + [2630] = { spellID = 25351, usesCharges = false }, -- Deadly Poison V + [2640] = { spellID = 26785, usesCharges = false }, -- Anesthetic Poison + [2641] = { spellID = 26891, usesCharges = false }, -- Instant Poison VII + [2642] = { spellID = 26967, usesCharges = false }, -- Deadly Poison VI + [2643] = { spellID = 27186, usesCharges = false }, -- Deadly Poison VII + [2644] = { spellID = 27188, usesCharges = false }, -- Wound Poison V + }, + titan = { + [7] = { spellID = 2823, usesCharges = false }, -- Deadly Poison + [8] = { spellID = 2824, usesCharges = false }, -- Deadly Poison II + [22] = { spellID = 3408, usesCharges = false }, -- Crippling Poison + [35] = { spellID = 5761, usesCharges = false }, -- Mind Numbing Poison + [323] = { spellID = 8679, usesCharges = false }, -- Instant Poison + [324] = { spellID = 8686, usesCharges = false }, -- Instant Poison II + [325] = { spellID = 8688, usesCharges = false }, -- Instant Poison III + [623] = { spellID = 11338, usesCharges = false }, -- Instant Poison IV + [624] = { spellID = 11339, usesCharges = false }, -- Instant Poison V + [625] = { spellID = 11340, usesCharges = false }, -- Instant Poison VI + [626] = { spellID = 11355, usesCharges = false }, -- Deadly Poison III + [627] = { spellID = 11356, usesCharges = false }, -- Deadly Poison IV + [703] = { spellID = 13219, usesCharges = false }, -- Wound Poison + [704] = { spellID = 13225, usesCharges = false }, -- Wound Poison II + [705] = { spellID = 13226, usesCharges = false }, -- Wound Poison III + [706] = { spellID = 13227, usesCharges = false }, -- Wound Poison IV + [2630] = { spellID = 25351, usesCharges = false }, -- Deadly Poison V + [2640] = { spellID = 26785, usesCharges = false }, -- Anesthetic Poison + [2641] = { spellID = 26891, usesCharges = false }, -- Instant Poison VII + [2642] = { spellID = 26967, usesCharges = false }, -- Deadly Poison VI + [2643] = { spellID = 27186, usesCharges = false }, -- Deadly Poison VII + [2644] = { spellID = 27188, usesCharges = false }, -- Wound Poison V + [3768] = { spellID = 57967, usesCharges = false }, -- Instant Poison VIII + [3769] = { spellID = 57968, usesCharges = false }, -- Instant Poison IX + [3770] = { spellID = 57972, usesCharges = false }, -- Deadly Poison VIII + [3771] = { spellID = 57973, usesCharges = false }, -- Deadly Poison IX + [3772] = { spellID = 57977, usesCharges = false }, -- Wound Poison VI + [3773] = { spellID = 57978, usesCharges = false }, -- Wound Poison VII + [3774] = { spellID = 57982, usesCharges = false }, -- Anesthetic Poison II + }, +} diff --git a/PoisonMonitor.lua b/PoisonMonitor.lua index e4dd775..0e22554 100644 --- a/PoisonMonitor.lua +++ b/PoisonMonitor.lua @@ -20,11 +20,13 @@ NoPoizen.PoisonAPI = { return NoPoizen:GetPlayerClassFile() end, GetDetectionMode = function() - if WOW_PROJECT_MAINLINE ~= nil and WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then - return "retail-aura" + local client = NoPoizen:GetPoisonClient() + if client == "retail" or client == "mists" then + return client .. "-aura" + end + if NoPoizen.weaponPoisonCatalogs[client] then + return client .. "-weapon" end - -- Forever exposes modern aura APIs, but its weapon coating semantics and - -- poison enchant identifiers are not established by those capabilities. return "unsupported" end, IsSpellKnown = C_SpellBook and C_SpellBook.IsSpellKnown, @@ -40,6 +42,19 @@ NoPoizen.PoisonAPI = { ShouldUnitAuraIndexBeSecret = C_Secrets and C_Secrets.ShouldUnitAuraIndexBeSecret, } +NoPoizen.mistsPoisonCatalog = { + lethal = { + { spellID = 2823, fallbackName = "Deadly Poison" }, + { spellID = 8679, fallbackName = "Wound Poison" }, + }, + nonLethal = { + { spellID = 3408, fallbackName = "Crippling Poison" }, + { spellID = 5761, fallbackName = "Mind-numbing Poison" }, + { spellID = 108211, fallbackName = "Leeching Poison" }, + { spellID = 108215, fallbackName = "Paralytic Poison" }, + }, +} + NoPoizen.poisonCatalog = { lethal = { { spellID = 2823, fallbackName = "Deadly Poison" }, @@ -155,7 +170,7 @@ NoPoizen.Testables.ShouldPlaySatisfiedAudio = ShouldPlaySatisfiedAudio NoPoizen.Testables.ResolveAudioArmingState = ResolveAudioArmingState NoPoizen.Testables.BuildIndicatorRows = BuildIndicatorRows -local function CreatePoisonDetector(api, catalog) +local function CreatePoisonDetector(api, catalog, weaponAPI) catalog = catalog or NoPoizen.poisonCatalog local detector = {} @@ -406,7 +421,18 @@ local function CreatePoisonDetector(api, catalog) return state end local modeOK, mode = pcall(api.GetDetectionMode) - if not modeOK or not CanRead(mode) or mode ~= "retail-aura" then + if not modeOK or not CanRead(mode) or type(mode) ~= "string" then + state.status, state.reason = "unsupported", "unverified-poison-mechanics" + return state + end + local weaponClient = mode:match("^(%a+)%-weapon$") + local weaponCatalog = weaponClient and NoPoizen.weaponPoisonCatalogs[weaponClient] + if weaponCatalog and weaponAPI then + return NoPoizen.Testables + .CreateWeaponPoisonDetector(weaponAPI, weaponClient, weaponCatalog, IsSpellKnownSafe) + :Evaluate(state) + end + if mode ~= "retail-aura" and mode ~= "mists-aura" then state.status, state.reason = "unsupported", "unverified-poison-mechanics" return state end @@ -427,7 +453,10 @@ local function CreatePoisonDetector(api, catalog) return state end state.eligible = true - local dragonTempered = self:HasDragonTemperedBladesSelected() + local dragonTempered = false + if mode == "retail-aura" then + dragonTempered = self:HasDragonTemperedBladesSelected() + end if dragonTempered == nil then state.reason = "talent-knowledge-unavailable" return state @@ -466,7 +495,11 @@ local function CreatePoisonDetector(api, catalog) end NoPoizen.Testables.CreatePoisonDetector = CreatePoisonDetector -local liveDetector = CreatePoisonDetector(NoPoizen.PoisonAPI) +local liveDetector = CreatePoisonDetector( + NoPoizen.PoisonAPI, + NoPoizen:GetPoisonClient() == "mists" and NoPoizen.mistsPoisonCatalog or NoPoizen.poisonCatalog, + NoPoizen.WeaponPoisonAPI +) function NoPoizen:HasDragonTemperedBladesSelected() return liveDetector:HasDragonTemperedBladesSelected() diff --git a/PoisonMonitorTests.lua b/PoisonMonitorTests.lua index 324125b..8e15b3c 100644 --- a/PoisonMonitorTests.lua +++ b/PoisonMonitorTests.lua @@ -72,6 +72,23 @@ Register("ordinary rogue sees missing categories", function() AssertEqual(#state.indicatorRows, 2) end) +Register("Mists uses its own aura choices without Retail talent requirements", function() + local f = Fixture() + f.api.GetDetectionMode = function() + return "mists-aura" + end + f.known = { [2823] = true, [108211] = true, [381801] = true } + f.auras = { [2823] = {}, [108211] = {} } + f.detector = NoPoizen.Testables.CreatePoisonDetector(f.api, NoPoizen.mistsPoisonCatalog) + local state = f.detector:Evaluate() + AssertEqual(state.status, "satisfied") + AssertEqual(state.requiredCounts.lethal, 1) + AssertEqual(state.requiredCounts.nonLethal, 1) + AssertEqual(state.hasDragonTemperedBlades, false) + f.auras[108211] = nil + AssertEqual(f.detector:Evaluate().status, "missing") +end) + Register("one lethal and one nonlethal satisfy baseline", function() local f = Fixture() f.auras[2823], f.auras[3408] = {}, {} diff --git a/WeaponPoisonTests.lua b/WeaponPoisonTests.lua new file mode 100644 index 0000000..f0879bb --- /dev/null +++ b/WeaponPoisonTests.lua @@ -0,0 +1,232 @@ +local addon = _G.NoPoizen +if not addon then + return +end +local Equal = addon.LibChev.AssertEqual + +local function Fixture(client) + local f = { items = { [16] = 1, [17] = 2 }, rows = { [0] = {}, [1] = {} }, known = true } + f.secret = {} + f.inaccessible = setmetatable({}, { + __index = function() + error("inaccessible row read") + end, + }) + f.api = { + CanAccessValue = function(value) + return value ~= f.secret + end, + CanAccessTable = function(value) + return value ~= f.inaccessible + end, + CanObserve = function() + return not f.restricted + end, + GetPlayerLevel = function() + return f.level or 20 + end, + GetInventoryItemID = function(_, slot) + return f.items[slot] + end, + GetItemInfoInstant = function(id) + return id, "", "", id == 3 and "INVTYPE_SHIELD" or "INVTYPE_WEAPON", 1, id == 3 and 4 or 2 + end, + GetWeaponSlot = function(hand) + return hand == "mainHand" and 0 or 1 + end, + GetWeaponEnchants = function(slot) + return f.rows[slot] + end, + GetLegacyWeaponEnchants = function() + local m, o = f.rows[0][1] or {}, f.rows[1][1] or {} + return m.hasEnchant, m.timeLeft, m.charges, m.enchantID, o.hasEnchant, o.timeLeft, o.charges, o.enchantID + end, + } + f.detector = addon.Testables.CreateWeaponPoisonDetector( + f.api, + client or "forever", + addon.weaponPoisonCatalogs[client or "forever"], + function(id) + if id == 1298494 then + return f.foreverTraining == true + end + return f.known + end + ) + function f:Apply(hand, id, charges, remaining) + self.rows[hand] = + { { hasEnchant = true, enchantID = id or 323, charges = charges or 60, timeLeft = remaining or 1800000 } } + end + function f:Evaluate() + return self.detector:Evaluate({ + status = "unknown", + eligible = false, + observable = false, + hasMissing = false, + knownSpellIDs = {}, + indicatorRows = {}, + }) + end + return f +end + +for _, client in ipairs({ "forever", "era", "tbc", "titan" }) do + addon:RegisterTest("weapon poisons: " .. client .. " hand identity, expiry and swaps", function() + local f = Fixture(client) + local state = f:Evaluate() + Equal(state.status, "missing") + Equal(state.missingCounts.total, 2) + Equal(state.indicatorRows[1].category, "mainHand") + f:Apply(0) + Equal(f:Evaluate().missingCounts.total, 1) + f:Apply(1, 22, 0) + Equal(f:Evaluate().status, "satisfied") + f.rows[0][1].timeLeft = 0 + Equal(f:Evaluate().status, "missing") + f.items[16] = nil + Equal(f:Evaluate().status, "satisfied") + f.items[17] = 3 + Equal(f:Evaluate().reason, "no-equipped-weapons") + end) +end + +addon:RegisterTest("weapon poisons: Forever training and multiple coatings", function() + local f = Fixture() + f.known, f.foreverTraining = false, true + f:Apply(0) + f.rows[0][2] = { hasEnchant = true, enchantID = 1, charges = 0, timeLeft = 30000 } + f:Apply(1, 22, 0) + Equal(f:Evaluate().status, "satisfied") + Equal(f:Evaluate().trainingSpellIDs[1], 1298494) + f.rows[0][1].enchantID = 283 -- Windfury is not a rogue poison. + Equal(f:Evaluate().status, "missing") +end) + +addon:RegisterTest("weapon poisons: charges follow client data", function() + for _, client in ipairs({ "forever", "era", "tbc", "titan" }) do + local f = Fixture(client) + f:Apply(0, 323, 0) + f:Apply(1, 22, 0) + Equal(f:Evaluate().status, (client == "tbc" or client == "titan") and "satisfied" or "missing") + end +end) + +addon:RegisterTest("weapon poisons: Forever rows may be zero based or sparse", function() + local f = Fixture() + f:Apply(0) + f:Apply(1, 22, 0) + f.rows[0] = { [0] = f.rows[0][1] } + f.rows[1] = { [3] = f.rows[1][1] } + Equal(f:Evaluate().status, "satisfied") + f.rows[0][f.secret] = { hasEnchant = false } + Equal(f:Evaluate().status, "unknown") +end) + +addon:RegisterTest("weapon poisons: SoD and TBC ranks stay in their own catalogs", function() + Equal(addon.weaponPoisonCatalogs.forever[7254], nil) + Equal(addon.weaponPoisonCatalogs.era[7254].spellID, 439462) + Equal(addon.weaponPoisonCatalogs.tbc[2641].spellID, 26891) + Equal(addon.weaponPoisonCatalogs.era[2641], nil) + local f = Fixture("era") + f:Apply(0, 7542, 0) + f:Apply(1, 7651, 0) + Equal(f:Evaluate().status, "satisfied") +end) + +addon:RegisterTest("weapon poisons: unknown never becomes missing", function() + local f = Fixture() + f.rows[0] = f.inaccessible + Equal(f:Evaluate().status, "unknown") + f.rows[0] = { f.inaccessible } + Equal(f:Evaluate().observable, false) + f:Apply(0) + f.rows[0][1].enchantID = f.secret + Equal(f:Evaluate().hasMissing, false) + f:Apply(0) + f.rows[0][1].charges = f.secret + Equal(f:Evaluate().status, "unknown") + f.api.GetWeaponEnchants = function() + error("private query error") + end + Equal(f:Evaluate().status, "unknown") +end) + +addon:RegisterTest("weapon poisons: restrictions prevent inventory reads", function() + local f = Fixture() + f.restricted = true + f.api.GetInventoryItemID = function() + error("must not query restricted inventory") + end + Equal(f:Evaluate().reason, "weapon-observation-restricted") + f.api.CanObserve = function() + return f.secret + end + Equal(f:Evaluate().status, "unknown") +end) + +addon:RegisterTest("weapon poisons: untrained and unknown training stay quiet", function() + local f = Fixture() + f.known = false + Equal(f:Evaluate().status, "ineligible") + f.known = nil + Equal(f:Evaluate().status, "unknown") +end) + +addon:RegisterTest("weapon poisons: multi enchant queries cannot fall back to single coatings", function() + local f = Fixture() + f.api.GetWeaponEnchants = nil + f:Apply(0) + f:Apply(1) + Equal(f:Evaluate().status, "unknown") +end) + +addon:RegisterTest("weapon poisons: temporary enchant structure uses milliseconds and charges", function() + local f = Fixture("era") + f.api.GetTemporaryEnchantmentInfo = function(slot) + Equal(slot == 16 or slot == 17, true) + return { enchantID = 323, remainingTimeMs = 5000, chargesRemaining = 3, hasExpirationTime = true } + end + Equal(f:Evaluate().status, "satisfied") + f.api.GetTemporaryEnchantmentInfo = function() + return nil + end + Equal(f:Evaluate().status, "missing") +end) + +addon:RegisterTest("weapon poisons: foreign equipment and overlong samples stay unknown", function() + local f = Fixture() + f.items[16] = f.secret + Equal(f:Evaluate().status, "unknown") + f.items[16] = 1 + for index = 1, 9 do + f.rows[0][index] = { hasEnchant = false } + end + Equal(f:Evaluate().status, "unknown") +end) + +addon:RegisterTest("poison clients: mechanics distinguish Forever from Era", function() + for version, client in pairs({ + ["1.60.1"] = "forever", + ["1.15.9"] = "era", + ["2.5.6"] = "tbc", + ["5.5.4"] = "mists", + ["3.80.2"] = "titan", + ["1.12.1"] = "unsupported", + }) do + Equal(addon.Testables.ResolvePoisonClient(version), client) + end +end) + +addon:RegisterTest("weapon poisons: Titan vendor poisons require level rather than crafting", function() + local f = Fixture("titan") + f.known = false + f.level = 19 + Equal(f:Evaluate().status, "ineligible") + f.level = 20 + Equal(f:Evaluate().status, "missing") + f:Apply(0, 3769, 0) + f:Apply(1, 3771, 0) + Equal(f:Evaluate().status, "satisfied") + f.level = f.secret + Equal(f:Evaluate().status, "unknown") +end) diff --git a/WeaponPoisons.lua b/WeaponPoisons.lua new file mode 100644 index 0000000..70a2291 --- /dev/null +++ b/WeaponPoisons.lua @@ -0,0 +1,337 @@ +local addon = _G.NoPoizen +if not addon then + return +end + +addon.Testables = addon.Testables or {} + +-- Client family selects mechanics, never permission/restriction policy. The +-- adapter separately tests API availability and every foreign result. +local function ResolvePoisonClient(version) + if type(version) ~= "string" then + return "unsupported" + end + if version:match("^1%.60%.") then + return "forever" + end + if version:match("^1%.15%.") then + return "era" + end + if version:match("^2%.5%.") then + return "tbc" + end + if version:match("^5%.5%.") then + return "mists" + end + if version:match("^3%.80%.") then + return "titan" + end + return "unsupported" +end +addon.Testables.ResolvePoisonClient = ResolvePoisonClient + +function addon:GetPoisonClient() + local ok, version = pcall(self.API.GetBuildInfo) + if ok and self:CanAccessValue(version) then + local client = ResolvePoisonClient(version) + if client ~= "unsupported" then + return client + end + end + if + self:CanAccessValue(WOW_PROJECT_ID) + and WOW_PROJECT_MAINLINE ~= nil + and WOW_PROJECT_ID == WOW_PROJECT_MAINLINE + then + return "retail" + end + return "unsupported" +end + +addon.WeaponPoisonAPI = { + CanAccessValue = function(value) + return addon:CanAccessValue(value) + end, + CanAccessTable = function(value) + return addon:CanAccessTable(value) + end, + CanObserve = function() + return not addon:IsHUDRestricted() + end, + GetPlayerLevel = function() + return UnitLevel("player") + end, + GetInventoryItemID = GetInventoryItemID, + GetItemInfoInstant = C_Item and C_Item.GetItemInfoInstant or GetItemInfoInstant, + GetWeaponEnchants = C_Item and C_Item.GetWeaponEnchantInfo, + GetTemporaryEnchantmentInfo = C_PaperDollInfo and C_PaperDollInfo.GetTemporaryEnchantmentInfo, + GetLegacyWeaponEnchants = GetWeaponEnchantInfo, + GetWeaponSlot = function(hand) + if not addon:CanAccessTable(Enum) or not addon:CanAccessTable(Enum.WeaponSlot) then + return nil + end + return Enum.WeaponSlot[hand == "mainHand" and "MainHand" or "OffHand"] + end, +} + +local function CreateWeaponPoisonDetector(api, client, catalog, isKnown) + local detector = {} + local function Read(value) + local ok, readable = pcall(api.CanAccessValue, value) + return ok and readable == true + end + local function Table(value) + if not Read(value) or type(value) ~= "table" then + return false + end + local ok, readable = pcall(api.CanAccessTable, value) + return ok and readable == true + end + local function Number(value) + return Read(value) and type(value) == "number" and value == value and value > -math.huge and value < math.huge + end + local function Query(fn, ...) + if type(fn) ~= "function" then + return false + end + return pcall(fn, ...) + end + local function IsWeapon(slot) + local ok, item = Query(api.GetInventoryItemID, "player", slot) + if not ok or not Read(item) then + return nil + end + if item == nil then + return false + end + if not Number(item) or item <= 0 then + return nil + end + local infoOK, _, _, _, equipLoc, _, class = Query(api.GetItemInfoInstant, item) + if not infoOK or not Number(class) or not Read(equipLoc) or type(equipLoc) ~= "string" then + return nil + end + -- Shields, holdables and unequipped slots do not require a coating. + return class == 2 + and ( + equipLoc == "INVTYPE_WEAPON" + or equipLoc == "INVTYPE_WEAPONMAINHAND" + or equipLoc == "INVTYPE_WEAPONOFFHAND" + or equipLoc == "INVTYPE_2HWEAPON" + ) + end + local function Classify(hasEnchant, id, remaining, charges) + if not Read(hasEnchant) then + return nil + end + if hasEnchant == false or hasEnchant == nil then + return false + end + if hasEnchant ~= true or not Number(id) then + return nil + end + local poison = catalog[id] + if not poison then + return false + end + if not Number(remaining) or remaining < 0 then + return nil + end + if remaining == 0 then + return false + end + if poison.usesCharges then + if not Number(charges) or charges < 0 then + return nil + end + if charges == 0 then + return false + end + end + return true, id + end + local function ObserveHand(hand, slot) + if client == "forever" then + local slotOK, weaponSlot = Query(api.GetWeaponSlot, hand) + if not slotOK or not Number(weaponSlot) or weaponSlot < 0 or weaponSlot ~= math.floor(weaponSlot) then + return nil + end + local ok, rows = Query(api.GetWeaponEnchants, weaponSlot) + if not ok or not Table(rows) then + return nil + end + local found, foundID, unknown = false, nil, false + -- Blizzard iterates these rows with pairs: they need not be a dense + -- one-based array. Gate the container and every key before advancing; + -- next avoids invoking a foreign __pairs metamethod. + local key + for index = 1, 9 do + local nextOK, nextKey, row = Query(next, rows, key) + if not nextOK or not Read(nextKey) then + return nil + end + if nextKey == nil then + if found then + return true, foundID + end + if unknown then + return nil + end + return false + end + if type(nextKey) ~= "string" and not Number(nextKey) then + return nil + end + key = nextKey + if index == 9 or not Table(row) then + return nil + end + if not Read(row.hasEnchant) or type(row.hasEnchant) ~= "boolean" then + return nil + end + local active, id = Classify(row.hasEnchant, row.enchantID, row.timeLeft, row.charges) + if active then + found, foundID = true, id + elseif active == nil then + unknown = true + end + end + return nil + end + if type(api.GetTemporaryEnchantmentInfo) == "function" then + local ok, row = Query(api.GetTemporaryEnchantmentInfo, slot) + if not ok or not Read(row) then + return nil + end + if row == nil then + return false + end + if not Table(row) then + return nil + end + return Classify(true, row.enchantID, row.remainingTimeMs, row.chargesRemaining) + end + local ok, mh, mt, mc, mi, oh, ot, oc, oi = Query(api.GetLegacyWeaponEnchants) + if not ok then + return nil + end + if hand == "mainHand" then + return Classify(mh, mi, mt, mc) + end + return Classify(oh, oi, ot, oc) + end + + function detector:Evaluate(state) + state.detectionMode = client .. "-weapon" + state.requiredCounts = { mainHand = 0, offHand = 0 } + state.activeCounts = { mainHand = 0, offHand = 0 } + state.missingCounts = { mainHand = 0, offHand = 0, total = 0 } + state.activeEnchantIDs = {} + state.trainingSpellIDs = {} + local safeOK, safe = Query(api.CanObserve) + if not safeOK or not Read(safe) or safe ~= true then + state.reason = "weapon-observation-restricted" + return state + end + local trained, knowledgeUnknown = false, false + -- Wrath-derived Titan poisons are purchased rather than crafted. The + -- first usable coating (Instant Poison) requires level 20 in its data. + if client == "titan" then + local levelOK, level = Query(api.GetPlayerLevel) + if not levelOK or not Number(level) then + state.reason = "level-unavailable" + return state + end + if level < 20 then + state.status, state.reason = "ineligible", "poisons-not-available" + return state + end + trained = true + end + local training = client == "forever" and { 2842, 1298494 } or { 2842 } + for _, spellID in ipairs(training) do + local known = isKnown(spellID) + if known then + trained = true + state.trainingSpellIDs[#state.trainingSpellIDs + 1] = spellID + elseif known == nil then + knowledgeUnknown = true + end + end + if not trained then + state.status = knowledgeUnknown and "unknown" or "ineligible" + state.reason = knowledgeUnknown and "spell-knowledge-unavailable" or "poisons-not-learned" + return state + end + state.eligible = true + local unknown, weapons = false, 0 + for index, hand in ipairs({ "mainHand", "offHand" }) do + local slot = index + 15 + local equipped = IsWeapon(slot) + if equipped == nil then + unknown = true + end + if equipped then + weapons = weapons + 1 + state.requiredCounts[hand] = 1 + local active, id = ObserveHand(hand, slot) + if active == nil then + unknown = true + end + if active then + state.activeCounts[hand] = 1 + state.activeEnchantIDs[#state.activeEnchantIDs + 1] = id + elseif active == false then + state.missingCounts[hand] = 1 + state.missingCounts.total = state.missingCounts.total + 1 + state.indicatorRows[#state.indicatorRows + 1] = + { category = hand, icons = { { icon = 132273, name = "Weapon poison" } } } + end + end + end + if unknown then + state.reason, state.indicatorRows = "weapon-observation-unavailable", {} + return state + end + if weapons == 0 then + state.status, state.reason, state.eligible = "ineligible", "no-equipped-weapons", false + return state + end + state.observable = true + state.hasMissing = state.missingCounts.total > 0 + state.status = state.hasMissing and "missing" or "satisfied" + state.reason = state.hasMissing and "weapon-poison-missing" or "weapons-poisoned" + return state + end + return detector +end +addon.Testables.CreateWeaponPoisonDetector = CreateWeaponPoisonDetector + +function addon:StartWeaponPoisonPolling() + if not self.weaponPoisonCatalogs or not self.weaponPoisonCatalogs[self:GetPoisonClient()] then + return + end + self.weaponPollElapsed = 0 + self.eventFrame:SetScript("OnUpdate", function(_, elapsed) + if + not self.isEnabled + or self.isLoggingOut + or self.isLoadingScreenActive + or not self:IsFiniteNumber(elapsed) + then + return + end + self.weaponPollElapsed = self.weaponPollElapsed + math.max(0, elapsed) + if self.weaponPollElapsed >= 1 then + self.weaponPollElapsed = 0 + self:RefreshPoisonState("WEAPON_POLL") + end + end) +end + +function addon:StopWeaponPoisonPolling() + if self.eventFrame and self.eventFrame.SetScript then + self.eventFrame:SetScript("OnUpdate", nil) + end + self.weaponPollElapsed = 0 +end diff --git a/scripts/build_poison_catalog.py b/scripts/build_poison_catalog.py new file mode 100644 index 0000000..90d2c37 --- /dev/null +++ b/scripts/build_poison_catalog.py @@ -0,0 +1,48 @@ +"""Regenerate reviewed weapon poison IDs from exact Wago DB2 CSV exports. +Usage: python3 scripts/build_poison_catalog.py /path/to/csv-cache +See CLIENT_COMPATIBILITY.md for source builds and selection rules. +""" +import csv +import hashlib +import json +import pathlib +import re +import sys + +root = pathlib.Path(__file__).resolve().parents[1] +cache = pathlib.Path(sys.argv[1]) +profiles = {"forever": "1.60.1.70009", "era": "1.15.9.69722", "tbc": "2.5.6.69795", "titan": "3.80.2.69874"} +family = re.compile(r"^(Deadly|Instant|Wound|Crippling|Mind[ -][Nn]umbing|Sebacious|Numbing|Atrophic|Occult|Anesthetic) Poison(?: [IVX]+)?$", re.I) +lua = ["-- Generated by scripts/build_poison_catalog.py; see CLIENT_COMPATIBILITY.md.", "local addon = _G.NoPoizen", "if not addon then return end", "addon.weaponPoisonCatalogs = {"] +evidence = {} +for profile, build in profiles.items(): + tables = {} + hashes = {} + for table in ["SpellName", "SpellEffect", "SpellItemEnchantment"]: + path = cache / (build + "-" + table + ".csv") + data = path.read_bytes() + hashes[table] = hashlib.sha256(data).hexdigest() + tables[table] = list(csv.DictReader(data.decode("utf-8-sig").splitlines())) + names = {r["ID"]: r["Name_lang"] for r in tables["SpellName"]} + enchants = {r["ID"]: r for r in tables["SpellItemEnchantment"]} + found = {} + for effect in tables["SpellEffect"]: + spell = effect["SpellID"] + enchant = effect["EffectMiscValue_0"] + if effect["Effect"] not in (["360"] if profile == "forever" else ["54"]): + continue + if not family.fullmatch(names.get(spell, "")) or enchant not in enchants: + continue + row = enchants[enchant] + if not family.fullmatch(row["Name_lang"]): + continue + found[int(enchant)] = {"spellID": int(spell), "name": row["Name_lang"], "usesCharges": int(row["Charges"]) > 0} + assert len(found) >= 20, (profile, len(found)) + lua.append("\t" + profile + " = {") + for enchant, row in sorted(found.items()): + lua.append("\t\t[%d] = { spellID = %d, usesCharges = %s }, -- %s" % (enchant, row["spellID"], str(row["usesCharges"]).lower(), row["name"])) + lua.append("\t},") + evidence[profile] = {"build": build, "sha256": hashes, "enchants": found} +lua.append("}") +(root / "PoisonData.lua").write_text("\n".join(lua) + "\n") +(root / "scripts/poison-data-sources.json").write_text(json.dumps(evidence, indent=2, sort_keys=True) + "\n") diff --git a/scripts/package.py b/scripts/package.py index a5f1c7f..6906b0b 100644 --- a/scripts/package.py +++ b/scripts/package.py @@ -24,7 +24,7 @@ def payloads(root, library_source=None): raise ValueError('Invalid TOC load order or duplicate entries') if any(not line.endswith('.lua') or line.startswith('scripts/') for line in files): raise ValueError('Only runtime Lua files may appear in the TOC') - files += ['NoPoizen.toc', 'CHANGELOG.md', 'CURSEFORGE_DESCRIPTION.md', + files += ['NoPoizen.toc', 'CHANGELOG.md', 'CURSEFORGE_DESCRIPTION.md', 'CLIENT_COMPATIBILITY.md', 'Libs/libchev/manifest.json', 'Libs/libchev/LICENSE'] files += [f'sounds/{stem}-{percent:03d}.ogg' for stem in ('nopoizen', 'hahaha') for percent in range(5, 101, 5)] diff --git a/scripts/poison-data-sources.json b/scripts/poison-data-sources.json new file mode 100644 index 0000000..da76afa --- /dev/null +++ b/scripts/poison-data-sources.json @@ -0,0 +1,537 @@ +{ + "era": { + "build": "1.15.9.69722", + "enchants": { + "7": { + "name": "Deadly Poison", + "spellID": 2823, + "usesCharges": true + }, + "8": { + "name": "Deadly Poison II", + "spellID": 2824, + "usesCharges": true + }, + "22": { + "name": "Crippling Poison", + "spellID": 3408, + "usesCharges": false + }, + "23": { + "name": "Mind-numbing Poison II", + "spellID": 8693, + "usesCharges": true + }, + "35": { + "name": "Mind Numbing Poison", + "spellID": 5761, + "usesCharges": true + }, + "323": { + "name": "Instant Poison", + "spellID": 8679, + "usesCharges": true + }, + "324": { + "name": "Instant Poison II", + "spellID": 8686, + "usesCharges": true + }, + "325": { + "name": "Instant Poison III", + "spellID": 8688, + "usesCharges": true + }, + "603": { + "name": "Crippling Poison II", + "spellID": 11202, + "usesCharges": false + }, + "623": { + "name": "Instant Poison IV", + "spellID": 11338, + "usesCharges": true + }, + "624": { + "name": "Instant Poison V", + "spellID": 11339, + "usesCharges": true + }, + "625": { + "name": "Instant Poison VI", + "spellID": 11340, + "usesCharges": true + }, + "626": { + "name": "Deadly Poison III", + "spellID": 11355, + "usesCharges": true + }, + "627": { + "name": "Deadly Poison IV", + "spellID": 11356, + "usesCharges": true + }, + "643": { + "name": "Mind-Numbing Poison III", + "spellID": 11399, + "usesCharges": true + }, + "703": { + "name": "Wound Poison", + "spellID": 13219, + "usesCharges": true + }, + "704": { + "name": "Wound Poison II", + "spellID": 13225, + "usesCharges": true + }, + "705": { + "name": "Wound Poison III", + "spellID": 13226, + "usesCharges": true + }, + "706": { + "name": "Wound Poison IV", + "spellID": 13227, + "usesCharges": true + }, + "2630": { + "name": "Deadly Poison V", + "spellID": 25351, + "usesCharges": true + }, + "7254": { + "name": "Sebacious Poison", + "spellID": 439462, + "usesCharges": false + }, + "7255": { + "name": "Numbing Poison", + "spellID": 439464, + "usesCharges": false + }, + "7256": { + "name": "Atrophic Poison", + "spellID": 439465, + "usesCharges": false + }, + "7542": { + "name": "Occult Poison I", + "spellID": 458821, + "usesCharges": false + }, + "7651": { + "name": "Occult Poison II", + "spellID": 1214171, + "usesCharges": false + } + }, + "sha256": { + "SpellEffect": "846e1a43c1371ce33e1037a132d5cf6d15b2809d9205205488f263484a935e74", + "SpellItemEnchantment": "285c67db58fbe4838bc3ac329a480d0f8218917a22ddd5817f4ae2acd1acb8fe", + "SpellName": "5ac8f81bc9b8aae4838c40cceb2e97bf5ca461838d9133eb2dd602cc7b0ebdd8" + } + }, + "forever": { + "build": "1.60.1.70009", + "enchants": { + "7": { + "name": "Deadly Poison", + "spellID": 2823, + "usesCharges": true + }, + "8": { + "name": "Deadly Poison II", + "spellID": 2824, + "usesCharges": true + }, + "22": { + "name": "Crippling Poison", + "spellID": 3408, + "usesCharges": false + }, + "23": { + "name": "Mind-numbing Poison II", + "spellID": 8693, + "usesCharges": true + }, + "35": { + "name": "Mind Numbing Poison", + "spellID": 5761, + "usesCharges": true + }, + "323": { + "name": "Instant Poison", + "spellID": 8679, + "usesCharges": true + }, + "324": { + "name": "Instant Poison II", + "spellID": 8686, + "usesCharges": true + }, + "325": { + "name": "Instant Poison III", + "spellID": 8688, + "usesCharges": true + }, + "603": { + "name": "Crippling Poison II", + "spellID": 11202, + "usesCharges": false + }, + "623": { + "name": "Instant Poison IV", + "spellID": 11338, + "usesCharges": true + }, + "624": { + "name": "Instant Poison V", + "spellID": 11339, + "usesCharges": true + }, + "625": { + "name": "Instant Poison VI", + "spellID": 11340, + "usesCharges": true + }, + "626": { + "name": "Deadly Poison III", + "spellID": 11355, + "usesCharges": true + }, + "627": { + "name": "Deadly Poison IV", + "spellID": 11356, + "usesCharges": true + }, + "643": { + "name": "Mind-Numbing Poison III", + "spellID": 11399, + "usesCharges": true + }, + "703": { + "name": "Wound Poison", + "spellID": 13219, + "usesCharges": true + }, + "704": { + "name": "Wound Poison II", + "spellID": 13225, + "usesCharges": true + }, + "705": { + "name": "Wound Poison III", + "spellID": 13226, + "usesCharges": true + }, + "706": { + "name": "Wound Poison IV", + "spellID": 13227, + "usesCharges": true + }, + "2630": { + "name": "Deadly Poison V", + "spellID": 25351, + "usesCharges": true + } + }, + "sha256": { + "SpellEffect": "fdecddfd93a3c27b48d7bbbebc8cc733a502fa8d58de623646550f9a5cffeb00", + "SpellItemEnchantment": "3873a636bb85865a40db774aefe6ec69562efdd6935ed27a7156288d246210d6", + "SpellName": "b9a0d125fd47e02c13790504e2f10c4e67a3e5d5c4a91295bd96514ba36610a6" + } + }, + "tbc": { + "build": "2.5.6.69795", + "enchants": { + "7": { + "name": "Deadly Poison", + "spellID": 2823, + "usesCharges": false + }, + "8": { + "name": "Deadly Poison II", + "spellID": 2824, + "usesCharges": false + }, + "22": { + "name": "Crippling Poison", + "spellID": 3408, + "usesCharges": false + }, + "23": { + "name": "Mind-numbing Poison II", + "spellID": 8693, + "usesCharges": false + }, + "35": { + "name": "Mind Numbing Poison", + "spellID": 5761, + "usesCharges": false + }, + "323": { + "name": "Instant Poison", + "spellID": 8679, + "usesCharges": false + }, + "324": { + "name": "Instant Poison II", + "spellID": 8686, + "usesCharges": false + }, + "325": { + "name": "Instant Poison III", + "spellID": 8688, + "usesCharges": false + }, + "603": { + "name": "Crippling Poison II", + "spellID": 11202, + "usesCharges": false + }, + "623": { + "name": "Instant Poison IV", + "spellID": 11338, + "usesCharges": false + }, + "624": { + "name": "Instant Poison V", + "spellID": 11339, + "usesCharges": false + }, + "625": { + "name": "Instant Poison VI", + "spellID": 11340, + "usesCharges": false + }, + "626": { + "name": "Deadly Poison III", + "spellID": 11355, + "usesCharges": false + }, + "627": { + "name": "Deadly Poison IV", + "spellID": 11356, + "usesCharges": false + }, + "643": { + "name": "Mind-Numbing Poison III", + "spellID": 11399, + "usesCharges": false + }, + "703": { + "name": "Wound Poison", + "spellID": 13219, + "usesCharges": false + }, + "704": { + "name": "Wound Poison II", + "spellID": 13225, + "usesCharges": false + }, + "705": { + "name": "Wound Poison III", + "spellID": 13226, + "usesCharges": false + }, + "706": { + "name": "Wound Poison IV", + "spellID": 13227, + "usesCharges": false + }, + "2630": { + "name": "Deadly Poison V", + "spellID": 25351, + "usesCharges": false + }, + "2640": { + "name": "Anesthetic Poison", + "spellID": 26785, + "usesCharges": false + }, + "2641": { + "name": "Instant Poison VII", + "spellID": 26891, + "usesCharges": false + }, + "2642": { + "name": "Deadly Poison VI", + "spellID": 26967, + "usesCharges": false + }, + "2643": { + "name": "Deadly Poison VII", + "spellID": 27186, + "usesCharges": false + }, + "2644": { + "name": "Wound Poison V", + "spellID": 27188, + "usesCharges": false + } + }, + "sha256": { + "SpellEffect": "ad2309425c31dd979e3a8682e794178ddd3540f6090c774a12e1bb8432a8e1d7", + "SpellItemEnchantment": "cf9b19ba7679e467f5193bdedfe0c8586fca068f9f7a231ea7c5d87331ee9b5a", + "SpellName": "c897c51b9811c0d457c8bc34813e976d8768f378347ffcac892159f1ce89447c" + } + }, + "titan": { + "build": "3.80.2.69874", + "enchants": { + "7": { + "name": "Deadly Poison", + "spellID": 2823, + "usesCharges": false + }, + "8": { + "name": "Deadly Poison II", + "spellID": 2824, + "usesCharges": false + }, + "22": { + "name": "Crippling Poison", + "spellID": 3408, + "usesCharges": false + }, + "35": { + "name": "Mind Numbing Poison", + "spellID": 5761, + "usesCharges": false + }, + "323": { + "name": "Instant Poison", + "spellID": 8679, + "usesCharges": false + }, + "324": { + "name": "Instant Poison II", + "spellID": 8686, + "usesCharges": false + }, + "325": { + "name": "Instant Poison III", + "spellID": 8688, + "usesCharges": false + }, + "623": { + "name": "Instant Poison IV", + "spellID": 11338, + "usesCharges": false + }, + "624": { + "name": "Instant Poison V", + "spellID": 11339, + "usesCharges": false + }, + "625": { + "name": "Instant Poison VI", + "spellID": 11340, + "usesCharges": false + }, + "626": { + "name": "Deadly Poison III", + "spellID": 11355, + "usesCharges": false + }, + "627": { + "name": "Deadly Poison IV", + "spellID": 11356, + "usesCharges": false + }, + "703": { + "name": "Wound Poison", + "spellID": 13219, + "usesCharges": false + }, + "704": { + "name": "Wound Poison II", + "spellID": 13225, + "usesCharges": false + }, + "705": { + "name": "Wound Poison III", + "spellID": 13226, + "usesCharges": false + }, + "706": { + "name": "Wound Poison IV", + "spellID": 13227, + "usesCharges": false + }, + "2630": { + "name": "Deadly Poison V", + "spellID": 25351, + "usesCharges": false + }, + "2640": { + "name": "Anesthetic Poison", + "spellID": 26785, + "usesCharges": false + }, + "2641": { + "name": "Instant Poison VII", + "spellID": 26891, + "usesCharges": false + }, + "2642": { + "name": "Deadly Poison VI", + "spellID": 26967, + "usesCharges": false + }, + "2643": { + "name": "Deadly Poison VII", + "spellID": 27186, + "usesCharges": false + }, + "2644": { + "name": "Wound Poison V", + "spellID": 27188, + "usesCharges": false + }, + "3768": { + "name": "Instant Poison VIII", + "spellID": 57967, + "usesCharges": false + }, + "3769": { + "name": "Instant Poison IX", + "spellID": 57968, + "usesCharges": false + }, + "3770": { + "name": "Deadly Poison VIII", + "spellID": 57972, + "usesCharges": false + }, + "3771": { + "name": "Deadly Poison IX", + "spellID": 57973, + "usesCharges": false + }, + "3772": { + "name": "Wound Poison VI", + "spellID": 57977, + "usesCharges": false + }, + "3773": { + "name": "Wound Poison VII", + "spellID": 57978, + "usesCharges": false + }, + "3774": { + "name": "Anesthetic Poison II", + "spellID": 57982, + "usesCharges": false + } + }, + "sha256": { + "SpellEffect": "c61828f3442b9e80d87d727ab9762243eb7049b90270be57a861da5a16ad9797", + "SpellItemEnchantment": "cb1dc7a04e0d02b4386fd2616cec8a76e144bdb745a559ccf507223c7030ee3e", + "SpellName": "f60aca8ff1c4308c0ce18e689acd70f19aa0b116945565caf760a45da04e60e9" + } + } +} diff --git a/scripts/smoke.lua b/scripts/smoke.lua index c5d71f5..57cd889 100644 --- a/scripts/smoke.lua +++ b/scripts/smoke.lua @@ -1,5 +1,13 @@ -- Offline integration only: never load this file into a live WoW client. local root, client = arg[1] or ".", arg[2] or "retail" +local versions = + { retail = "12.1.0", forever = "1.60.1", era = "1.15.9", tbc = "2.5.6", mists = "5.5.4", titan = "3.80.2" } +assert(versions[client], "unknown smoke client") +local weaponClient = client == "forever" or client == "era" or client == "tbc" or client == "titan" +local coatings = { + [0] = { { hasEnchant = true, enchantID = 323, charges = 60, timeLeft = 1800000 } }, + [1] = { { hasEnchant = true, enchantID = 22, charges = 0, timeLeft = 1800000 } }, +} local unpack = table.unpack or unpack local now, timers, sounds, restricted = 0, {}, {}, false local frameCount, chat = 0, {} @@ -202,7 +210,10 @@ function GetSpecializationInfo() return 259, "Assassination" end function GetBuildInfo() - return client == "retail" and "12.1.0" or "1.60.1", "test", "date", client == "retail" and 120100 or 16001 + return versions[client], + "test", + "date", + ({ retail = 120100, forever = 16001, era = 11509, tbc = 20506, mists = 50504, titan = 38002 })[client] end function InCombatLockdown() return restricted @@ -242,7 +253,8 @@ Enum = { } C_SpellBook = { IsSpellKnown = function(id) - return id == 2823 or id == 3408 + return weaponClient and id == (client == "forever" and 1298494 or 2842) + or (not weaponClient and (id == 2823 or id == 3408)) end, } C_Spell = { @@ -269,10 +281,23 @@ C_AddOns = { end, } C_Item = { - GetWeaponEnchantInfo = function() - return {} + GetWeaponEnchantInfo = client == "forever" and function(slot) + return coatings[slot] + end or nil, + GetItemInfoInstant = function(id) + return id, "Weapon", "Dagger", "INVTYPE_WEAPON", 1, 2 end, } +function UnitLevel() + return 20 +end +function GetInventoryItemID(_, slot) + return slot +end +function GetWeaponEnchantInfo() + local m, o = coatings[0][1] or {}, coatings[1][1] or {} + return m.hasEnchant, m.timeLeft, m.charges, m.enchantID, o.hasEnchant, o.timeLeft, o.charges, o.enchantID +end Settings = { RegisterCanvasLayoutCategory = function() return { @@ -342,7 +367,7 @@ NoPoizen:PLAYER_LOGIN() assert(NoPoizen.isEnabled and NoPoizen.optionsCategory) Advance(5) assert(#sounds == 0, "initial state must be quiet") -if client == "retail" then +if not weaponClient then assert(NoPoizen.currentPoisonState.status == "satisfied") auras[2823] = nil NoPoizen:UNIT_AURA("UNIT_AURA", "player") @@ -361,7 +386,29 @@ if client == "retail" then NoPoizen:UNIT_AURA("UNIT_AURA", "player") assert(NoPoizen.currentPoisonState.status == "satisfied" and #sounds == 2) else - assert(NoPoizen.currentPoisonState.status == "unsupported") + assert(NoPoizen.currentPoisonState.status == "satisfied") + assert(NoPoizen.eventFrame.scripts.OnUpdate, "weapon clients must poll expiry and charge changes") + coatings[0] = {} + NoPoizen:WEAPON_ENCHANT_CHANGED() + assert(NoPoizen.currentPoisonState.status == "missing" and #sounds == 1) + assert(NoPoizen.poisonIndicatorHostFrame:IsShown()) + restricted = true + NoPoizen:ADDON_RESTRICTION_STATE_CHANGED() + Advance(0) + assert(NoPoizen.currentPoisonState.status == "unknown" and #sounds == 1) + restricted = false + NoPoizen:ADDON_RESTRICTION_STATE_CHANGED() + Advance(0) + assert(NoPoizen.currentPoisonState.status == "missing" and #sounds == 1) + coatings[0] = { { hasEnchant = true, enchantID = 323, timeLeft = 1000, charges = 10 } } + NoPoizen:WEAPON_SLOT_CHANGED() + assert(NoPoizen.currentPoisonState.status == "satisfied" and #sounds == 2) + coatings[0][1].timeLeft = 0 + NoPoizen.eventFrame.scripts.OnUpdate(NoPoizen.eventFrame, 1) + assert(NoPoizen.currentPoisonState.status == "missing" and #sounds == 3) + coatings[0][1].timeLeft = 1000 + NoPoizen.eventFrame.scripts.OnUpdate(NoPoizen.eventFrame, 1) + assert(NoPoizen.currentPoisonState.status == "satisfied" and #sounds == 4) end assert(NoPoizen:OpenHudEditMode()) NoPoizen:SetOption("widgetScale", 1.5)