diff --git a/Plater.lua b/Plater.lua index fa0dc8ea..1d57cf1d 100644 --- a/Plater.lua +++ b/Plater.lua @@ -806,17 +806,6 @@ Plater.AnchorNamesByPhraseId = { Plater.GetSpellForRangeCheck() end - --------------------------------- - if (false and IS_WOW_PROJECT_MAINLINE and InCombatLockdown()) then --emergency fix for range check 2023.11.16 - rangeChecker = function(unit) - local min, max = LibRangeCheck:GetRange(unit, false, true) - if (max or rangeCheckRange + 1) <= (rangeCheckRange or 40) then - return true - end - end - end - --------------------------------- - --this unit is target local unitIsTarget = unitFrame.isSoftInteract -- default to softinteract local notTheTarget = false @@ -1014,6 +1003,46 @@ Plater.AnchorNamesByPhraseId = { if (specIndex) then local specID = (IS_WOW_PROJECT_MAINLINE) and GetSpecializationInfo (specIndex) or select (3, UnitClass ("player")) if (specID and specID ~= 0) then + --range check spells fallback update + local harmCheckers = {} + local maxHarm = 0 + for range, func in LibRangeCheck:GetHarmCheckers(true) do + harmCheckers[range] = func + if maxHarm < range then maxHarm = range end + end + local friendCheckers = {} + local maxFriend = 0 + for range, func in LibRangeCheck:GetFriendCheckers(true) do + friendCheckers[range] = func + if maxFriend < range then maxFriend = range end + end + if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then + for specID, _ in pairs (Plater.SpecList [select (2, UnitClass ("player"))]) do + if harmCheckers then + if (PlaterDBChr.spellRangeCheckRangeEnemy [specID] == nil or not harmCheckers[PlaterDBChr.spellRangeCheckRangeEnemy [specID]]) then + PlaterDBChr.spellRangeCheckRangeEnemy [specID] = maxHarm --Plater.DefaultSpellRangeList [specID] + end + end + if friendCheckers then + if (PlaterDBChr.spellRangeCheckRangeFriendly [specID] == nil or not friendCheckers[PlaterDBChr.spellRangeCheckRangeFriendly [specID]]) then + PlaterDBChr.spellRangeCheckRangeFriendly [specID] = maxFriend --Plater.DefaultSpellRangeListF [specID] + end + end + end + else + local playerClass = select (3, UnitClass ("player")) + if harmCheckers then + if (PlaterDBChr.spellRangeCheckRangeEnemy [playerClass] == nil or not harmCheckers[PlaterDBChr.spellRangeCheckRangeEnemy [playerClass]]) then + PlaterDBChr.spellRangeCheckRangeEnemy [playerClass] = maxHarm --Plater.DefaultSpellRangeList [playerClass] + end + end + if friendCheckers then + if (PlaterDBChr.spellRangeCheckRangeFriendly [playerClass] == nil or not friendCheckers[PlaterDBChr.spellRangeCheckRangeFriendly [playerClass]]) then + PlaterDBChr.spellRangeCheckRangeFriendly [playerClass] = maxFriend --Plater.DefaultSpellRangeListF [playerClass] + end + end + end + --the local character saved variable hold the spell name used for the range check Plater.RangeCheckRangeFriendly = PlaterDBChr.spellRangeCheckRangeFriendly [specID] or Plater.DefaultSpellRangeListF [specID] or 40 Plater.RangeCheckRangeEnemy = PlaterDBChr.spellRangeCheckRangeEnemy [specID] or Plater.DefaultSpellRangeList [specID] or 40 @@ -4814,7 +4843,7 @@ function Plater.OnInit() --private --~oninit ~init end -- in some occasions channeled casts don't have a CLEU entry... check this here - if (event == "UNIT_SPELLCAST_CHANNEL_START" and (not DB_CAPTURED_SPELLS[self.spellID] or DB_CAPTURED_SPELLS[self.spellID].isChanneled == nil)) then + if (unitFrame.ActorType == "enemynpc" and event == "UNIT_SPELLCAST_CHANNEL_START" and (not DB_CAPTURED_SPELLS[self.spellID] or DB_CAPTURED_SPELLS[self.spellID].isChanneled == nil)) then parserFunctions.SPELL_CAST_SUCCESS (nil, "SPELL_CAST_SUCCESS", nil, unitFrame[MEMBER_GUID], unitFrame.unitNameInternal, 0x00000000, nil, nil, nil, nil, nil, self.spellID, nil, nil, nil, nil, nil, nil, nil, nil, nil) end diff --git a/Plater_Data.lua b/Plater_Data.lua index e31a789c..1bfdb1dd 100644 --- a/Plater_Data.lua +++ b/Plater_Data.lua @@ -551,7 +551,7 @@ function platerInternal.CreateDataTables(Plater) [1] = 30, --Warrior [2] = 40, --Paladin [3] = 40, --Hunter - [4] = 30, --Rogue + [4] = 10, --Rogue [5] = 40, --Priest [6] = 30, --DeathKnight [7] = 40, --Shaman @@ -593,9 +593,9 @@ function platerInternal.CreateDataTables(Plater) [257] = 40, --> priest holy [258] = 40, --> priest shadow - [259] = 30, --> rogue assassination - [260] = 20, --> rogue outlaw - [261] = 30, --> rogue sub + [259] = 10, --> rogue assassination + [260] = 10, --> rogue outlaw + [261] = 10, --> rogue sub [262] = 40, --> shaman elemental [263] = 40, --> shaman enhancement diff --git a/libs/LibRangeCheck-3.0/LibRangeCheck-3.0.lua b/libs/LibRangeCheck-3.0/LibRangeCheck-3.0.lua index 441df1e7..306cea76 100644 --- a/libs/LibRangeCheck-3.0/LibRangeCheck-3.0.lua +++ b/libs/LibRangeCheck-3.0/LibRangeCheck-3.0.lua @@ -40,7 +40,7 @@ License: MIT -- @class file -- @name LibRangeCheck-3.0 local MAJOR_VERSION = "LibRangeCheck-3.0" -local MINOR_VERSION = 3 +local MINOR_VERSION = 5 local lib, oldminor = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION) if not lib then @@ -246,9 +246,11 @@ tinsert(ResSpells.PRIEST, 2006) -- Resurrection (40 yards, level 10) if isRetail then tinsert(FriendSpells.ROGUE, 36554) -- Shadowstep (Assassination, Subtlety) (25 yards, level 18) -- works on friendly in retail tinsert(FriendSpells.ROGUE, 921) -- Pick Pocket (10 yards, level 24) -- this works for range, keep it in friendly as well for retail but on classic this is melee range and will return min 0 range 0 +else + tinsert(HarmSpells.ROGUE, 2764) -- Throw (30 yards) end -tinsert(HarmSpells.ROGUE, 2764) -- Throw (30 yards) +tinsert(HarmSpells.ROGUE, 185565) -- Poisoned Knife (Assassination) (30 yards, level 29) tinsert(HarmSpells.ROGUE, 36554) -- Shadowstep (Assassination, Subtlety) (25 yards, level 18) tinsert(HarmSpells.ROGUE, 185763) -- Pistol Shot (Outlaw) (20 yards) tinsert(HarmSpells.ROGUE, 2094) -- Blind (15 yards) @@ -540,25 +542,7 @@ local checkers_Spell = setmetatable({}, { return func end, }) -local function createCheckers_SpellWithMin(fallbackSpell) - local checkers_SpellWithMin = setmetatable({}, { - __index = function(t, spellIdx) - local func = function(unit) - if IsSpellInRange(spellIdx, BOOKTYPE_SPELL, unit) == 1 then - return true - elseif fallbackSpell and IsSpellInRange(fallbackSpell, BOOKTYPE_SPELL, unit) == 1 then - return true, true - else - return false - end - end - t[spellIdx] = func - return func - end, - }) - return checkers_SpellWithMin -end - +local checkers_SpellWithMin = {} -- see getCheckerForSpellWithMinRange() local checkers_Item = setmetatable({}, { __index = function(t, item) local func = function(unit) @@ -628,6 +612,46 @@ local function findSpellIdx(spellName) return nil end +local function fixRange(range) + if range then + return math_floor(range + 0.5) + end +end + +local function getSpellData(sid) + local name, _, _, _, minRange, range = GetSpellInfo(sid) + return name, fixRange(minRange), fixRange(range), findSpellIdx(name) +end + +local function findMinRangeChecker(origMinRange, origRange, spellList) + for i = 1, #spellList do + local sid = spellList[i] + local name, minRange, range, spellIdx = getSpellData(sid) + if range and spellIdx and origMinRange <= range and range <= origRange and minRange == 0 then + return checkers_Spell[findSpellIdx] + end + end +end + +local function getCheckerForSpellWithMinRange(spellIdx, minRange, range, spellList) + local checker = checkers_SpellWithMin[spellIdx] + if checker then + return checker + end + local minRangeChecker = findMinRangeChecker(minRange, range, spellList) + if minRangeChecker then + checker = function(unit) + if IsSpellInRange(spellIdx, BOOKTYPE_SPELL, unit) == 1 then + return true + elseif minRangeChecker(unit) then + return true, true + end + end + checkers_SpellWithMin[spellIdx] = checker + return checker + end +end + -- minRange should be nil if there's no minRange, not 0 local function addChecker(t, range, minRange, checker, info) local rc = { ["range"] = range, ["minRange"] = minRange, ["checker"] = checker, ["info"] = info } @@ -659,33 +683,10 @@ local function createCheckerList(spellList, itemList, interactList) end if spellList then - local spellIdWithOutMinRange - -- Some spells have a minimum range, IsSpellInRange returns false for both being - -- too near and too far. To distinguish between those two cases, we determine a spell - -- without a min range and use that as a fallback - for i = 1, #spellList do - local sid = spellList[i] - local name, _, _, _, minRange, range = GetSpellInfo(sid) - local spellIdx = findSpellIdx(name) - if spellIdx and range then - minRange = math_floor(minRange + 0.5) - if minRange == 0 then - spellIdWithOutMinRange = spellIdx - break; - end - end - end - - local checkers_SpellWithMin = createCheckers_SpellWithMin(spellIdWithOutMinRange) - for i = 1, #spellList do local sid = spellList[i] - local name, _, _, _, minRange, range = GetSpellInfo(sid) - local spellIdx = findSpellIdx(name) + local name, minRange, range, spellIdx = getSpellData(sid) if spellIdx and range then - minRange = math_floor(minRange + 0.5) - range = math_floor(range + 0.5) - -- print("### spell: " .. tostring(name) .. ", " .. tostring(minRange) .. " - " .. tostring(range)) if minRange == 0 then -- getRange() expects minRange to be nil in this case @@ -697,8 +698,11 @@ local function createCheckerList(spellList, itemList, interactList) end if minRange then - addChecker(res, range, minRange, checkers_SpellWithMin[spellIdx], "spell:" .. sid .. ":" .. tostring(name)) - addChecker(resInCombat, range, minRange, checkers_SpellWithMin[spellIdx], "spell:" .. sid .. ":" .. tostring(name)) + local checker = getCheckerForSpellWithMinRange(spellIdx, minRange, range, spellList) + if checker then + addChecker(res, range, minRange, checker, "spell:" .. sid .. ":" .. tostring(name)) + addChecker(resInCombat, range, minRange, checker, "spell:" .. sid .. ":" .. tostring(name)) + end else addChecker(res, range, minRange, checkers_Spell[spellIdx], "spell:" .. sid .. ":" .. tostring(name)) addChecker(resInCombat, range, minRange, checkers_Spell[spellIdx], "spell:" .. sid .. ":" .. tostring(name))