Giter Site home page Giter Site logo

ascott18 / libspellrange-1.0 Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 3.0 22 KB

WoW Addon Lib that provides more robust spell range checking functionality.

Home Page: https://wow.curseforge.com/projects/libspellrange-1-0

Lua 100.00%
world-of-warcraft world-of-warcraft-addon library

libspellrange-1.0's Introduction

LibSpellRange-1.0

Background

Blizzard's IsSpellInRange API has always been very limited - you either must have the name of the spell, or its spell book ID. Checking directly by spellID is simply not possible. Now, since Mists of Pandaria, Blizzard changed the way that many talents and specialization spells work - instead of giving you a new spell when leaned, they replace existing spells. These replacement spells do not work with Blizzard's IsSpellInRange function whatsoever; this limitation is what prompted the creation of this lib.

Usage

LibSpellRange-1.0 exposes an enhanced version of IsSpellInRange that:

  • Allows ranged checking based on both spell name and spellID.
  • Works correctly with replacement spells that will not work using Blizzard's IsSpellInRange method alone.
  • Attempts to works with pet spells via the action bar API, which as of some indeterminate recent WoW version no longer work with IsSpellInRange.

SpellRange.IsSpellInRange(spell, unit) - Improved IsSpellInRange

Parameters

  • spell - Name or spellID of a spell that you wish to check the range of. The spell must be a spell that you have in your spellbook or your pet's spellbook.
  • unit - UnitID of the spell that you wish to check the range on.

Return value

Exact same returns as the built-in IsSpellInRange

Usage

-- Check spell range by spell name on unit "target"
local SpellRange = LibStub("SpellRange-1.0")
local inRange = SpellRange.IsSpellInRange("Stormstrike", "target")

-- Check spell range by spellID on unit "mouseover"
local SpellRange = LibStub("SpellRange-1.0")
local inRange = SpellRange.IsSpellInRange(17364, "mouseover")

SpellRange.SpellHasRange(spell) - Improved SpellHasRange

Parameters

  • spell - Name or spellID of a spell that you wish to check for a range. The spell must be a spell that you have in your spellbook or your pet's spellbook.

Return value

Exact same returns as the built-in SpellHasRange

Usage

-- Check if a spell has a range by spell name
local SpellRange = LibStub("SpellRange-1.0")
local hasRange = SpellRange.SpellHasRange("Stormstrike")

-- Check if a spell has a range by spellID
local SpellRange = LibStub("SpellRange-1.0")
local hasRange = SpellRange.SpellHasRange(17364)

libspellrange-1.0's People

Contributors

ascott18 avatar infusonwow avatar mrbuds avatar

Stargazers

 avatar

Watchers

 avatar

libspellrange-1.0's Issues

[Bug] LibSpellRange-1.0 need to fix these lines

**What version of TellMeWhen are you using? **

v9.0.2

Happen error on v15 LibSpellRange
8707x ...llMeWhen\Lib\LibSpellRange-1.0\LibSpellRange-1.0.lua:40: table index is nil
[string "@TellMEwhen\Lib\LibSpellRange-1.0\LibSpellRange-1.0.lua"]:40: in function <...llMeWhen\Lib\LibSpellRange-1.0\LibSpellRange-1.0.lua:38>
[string "@TellMEwhen\Lib\LibSpellRange-1.0\LibSpellRange-1.0.lua"]:206: in function <...llMeWhen\Lib\LibSpellRange-1.0\LibSpellRange-1.0.lua:205>

Fix
It's lines 77-85 of the LibSpellRange v15

-- Updates spellsByName and spellsByID
local function UpdateBook(bookType)
local _, _, offs, numspells = GetSpellTabInfo(4)
local max = offs -- The offset of the next tab is the max ID of the previous tab.
if numspells == 0 then
-- New characters pre level 10 only have 2 tabs.
local _, _, offs, numspells = GetSpellTabInfo(2)
max = offs + numspells
end

Original code
-- Updates spellsByName and spellsByID
local function UpdateBook(bookType)
local max = 0
for i = 1, GetNumSpellTabs() do
local _, _, offs, numspells, _, specId = GetSpellTabInfo(i)
if specId == 0 then
max = offs + numspells
end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.