This commit is contained in:
DuvelCorp
2026-04-04 23:38:34 +02:00
parent 51d4c785fa
commit c4911ef9fe
14 changed files with 2283 additions and 6 deletions
+81
View File
@@ -91,6 +91,13 @@ local CELL_DEF = {
icon = "Interface\\Icons\\Ability_TheBlackArrow" },
}
-- ── Creature-type immunity rules ──────────────────────────────
-- Maps UnitCreatureType("target") → set of ammo states the target resists.
-- Used by PLAYER_TARGET_CHANGED to proactively flag blocked states.
local CREATURE_TYPE_IMMUNITIES = {
["Elemental"] = { [POISONOUS] = true }, -- Elementals are Nature-immune
}
-- ── Talent gate ──────────────────────────────────────────────
-- The module only shows if the player has the talent.
-- Checked on login and whenever MTH_HT_OnScanComplete fires.
@@ -304,11 +311,28 @@ local function MTH_EA_EnsureConfigDefaults()
if cfg.bigCD == nil then cfg.bigCD = false end
if cfg.hideOOC == nil then cfg.hideOOC = false end
if cfg.useQuiverNoClip == nil then cfg.useQuiverNoClip = false end
if cfg.blockExplosive == nil then cfg.blockExplosive = false end
if cfg.blockPoisonous == nil then cfg.blockPoisonous = false end
if cfg.blockEnchanted == nil then cfg.blockEnchanted = false end
end
-- Combat state flag (avoids needing InCombatLockdown, which doesn't exist in 1.12)
local inCombat = false
-- ── Runtime immunity / block tracking ─────────────────────────
-- Volatile: refreshed on PLAYER_TARGET_CHANGED and combat-log "immune" messages.
local MTH_EA_BlockedStates = {} -- [state] = true if creature-type or reactive immunity
function MTH_EA_IsStateBlocked(state)
if not state or state == IDLE then return false end
local cfg = MTH_EA_GetConfig()
if state == EXPLOSIVE and cfg.blockExplosive then return true end
if state == POISONOUS and cfg.blockPoisonous then return true end
if state == ENCHANTED and cfg.blockEnchanted then return true end
if MTH_EA_BlockedStates[state] then return true end
return false
end
-- Throttle for PLAYER_AURAS_CHANGED: even with the fast texture path this event
-- fires 10-50+/sec in combat, so cap processing at ~6/sec.
local MTH_EA_AurasChangedLastTime = 0
@@ -493,6 +517,13 @@ end
-- Action button: what spell to show and what spell to cast right now.
-- Returns displaySpell, icon, r, g, b, cooldownRemaining, castSpell
local function MTH_EA_GetActionSpell()
-- If current ammo state is blocked (creature immune or rotation toggle),
-- skip the consume-spell and fall through to Aimed/Steady instead.
if rt.state ~= IDLE and MTH_EA_IsStateBlocked(rt.state) then
local cd = MTH_EA_GetSpellCD(SPELL_AIMED)
return SPELL_AIMED, ICON_AIMED, 1.00, 0.85, 0.00, cd, (cd > 0 and SPELL_STEADY or SPELL_AIMED)
end
if rt.state == EXPLOSIVE then
local cd = MTH_EA_GetSpellCD(SPELL_MULTI)
return SPELL_MULTI, ICON_MULTI, 1.00, 0.60, 0.05, cd, (cd > 0 and SPELL_STEADY or SPELL_MULTI)
@@ -654,6 +685,11 @@ MTH_EA_UpdateUI = function()
end
cdTexts[i]:SetText("")
end
-- Red border override for blocked (immune / rotation-disabled) states
if MTH_EA_IsStateBlocked(def.state) then
c:SetBackdropBorderColor(1, 0, 0, 0.85)
end
end
-- ── TOP cell: Lock and Load ───────────────────────────────
@@ -1158,6 +1194,8 @@ frame:RegisterEvent("SPELLCAST_STOP")
frame:RegisterEvent("SPELLCAST_FAILED")
frame:RegisterEvent("SPELLCAST_INTERRUPTED")
frame:RegisterEvent("ACTIONBAR_SLOT_CHANGED") -- invalidate Aimed Shot slot cache
frame:RegisterEvent("PLAYER_TARGET_CHANGED") -- proactive creature-type immunity
frame:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE") -- reactive "immune" detection
frame:SetScript("OnUpdate", function()
if not MTH_EA_IsEnabled() then return end
@@ -1304,6 +1342,34 @@ frame:SetScript("OnEvent", function()
return
end
if event == "PLAYER_TARGET_CHANGED" then
MTH_EA_BlockedStates = {}
if UnitExists("target") then
local creatureType = UnitCreatureType("target")
if creatureType and CREATURE_TYPE_IMMUNITIES[creatureType] then
for st, _ in pairs(CREATURE_TYPE_IMMUNITIES[creatureType]) do
MTH_EA_BlockedStates[st] = true
end
end
end
MTH_EA_UpdateUI()
return
end
if event == "CHAT_MSG_SPELL_SELF_DAMAGE" then
local msg = arg1 or ""
if string.find(msg, "immune", 1, true) then
for state, spell in pairs(CONSUME_SPELL) do
if string.find(msg, spell, 1, true) then
MTH_EA_BlockedStates[state] = true
MTH_EA_UpdateUI()
break
end
end
end
return
end
if event == "PLAYER_REGEN_DISABLED" then
-- Entering combat
inCombat = true
@@ -1537,5 +1603,20 @@ MTH_ExpAmmo = {
local cfg = MTH_EA_GetConfig()
cfg.useQuiverNoClip = v and true or false
end,
SetBlockExplosive = function(v)
local cfg = MTH_EA_GetConfig()
cfg.blockExplosive = v and true or false
MTH_EA_UpdateUI()
end,
SetBlockPoisonous = function(v)
local cfg = MTH_EA_GetConfig()
cfg.blockPoisonous = v and true or false
MTH_EA_UpdateUI()
end,
SetBlockEnchanted = function(v)
local cfg = MTH_EA_GetConfig()
cfg.blockEnchanted = v and true or false
MTH_EA_UpdateUI()
end,
ToggleAnchor = MTH_EA_ToggleAnchor,
}
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
<!--
MetaHunt: SmartPet Module Loader
-->
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Include file="engine.lua"/>
</Ui>
+1 -1
View File
@@ -219,7 +219,7 @@ function ZSpellButton_SetSize(parent, size, setChildren)
local cdscale = 0.75 / 36
if setChildren then
local button
for i=1, parent.count do
for i=1, (parent.count or 0) do
button = getglobal(parent.name..i)
if button then
button:SetHeight(size)
+4 -5
View File
@@ -38,7 +38,6 @@ local zButtonAmmo_LastFullScanAt = 0
local zButtonAmmo_MinUnknownBagScanInterval = 5.0
local zButtonAmmo_EmptyScanStreak = 0
local zButtonAmmo_LastEquippedAmmoSeen = nil
local zButtonAmmo_GetKnownAmmoTypes
local function zButtonAmmo_BagHasAmmoNow(bagId)
local bag = tonumber(bagId)
@@ -117,7 +116,7 @@ zButtonAmmo_GetKnownAmmoTypes = function()
return knownAmmo
end
local zButtonAmmo_ShortArrowLabels = {
zButtonAmmo_ShortArrowLabels = {
[ARROWS_ROUGH] = "Rough",
[ARROWS_SHARP] = "Sharp",
[ARROWS_RAZOR] = "Razor",
@@ -131,7 +130,7 @@ local zButtonAmmo_ShortArrowLabels = {
[ARROWS_DOOMSHOT] = "Doom",
}
local zButtonAmmo_ShortBulletLabels = {
zButtonAmmo_ShortBulletLabels = {
[BULLETS_LIGHT] = "Light",
[BULLETS_CRAFTLIGHT] = "C.Light",
[BULLETS_FLASH] = "Flash",
@@ -151,7 +150,7 @@ local zButtonAmmo_ShortBulletLabels = {
[BULLETS_ICETHREADED] = "Ice",
}
local function zButtonAmmo_GetColorGradient(perc)
function zButtonAmmo_GetColorGradient(perc)
perc = perc > 1 and 1 or perc
perc = perc < 0 and 0 or perc
local r1, g1, b1, r2, g2, b2
@@ -188,7 +187,7 @@ local function zButtonAmmo_EnsureShortLabelText(button)
return button and button.ammoShortLabelText
end
local function zButtonAmmo_GetQualityColor(quality)
function zButtonAmmo_GetQualityColor(quality)
local tableRef = MTH_ITEM_QUALITY_COLORS or ITEM_QUALITY_COLORS
if tableRef then
local q = tonumber(quality)