Proper IsSpellInRange menu

User Tag List

Results 1 to 1 of 1
  1. #1
    Wopak's Avatar Active Member
    Reputation
    59
    Join Date
    Jul 2008
    Posts
    96
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Proper IsSpellInRange

    PHP Code:
    -- Courtesy of Wopak - [url]http://www.ownedcore.com/forums/members/309249-wopak.html[/url]
    -- This function doesn't require any PLUA unlocker or any other kind of hack
    -- ARGUMENTS
    ---- name - Name of a spell (string)
    ---- unit - A unit to target with the spell (string, [url=http://wowprogramming.com/docs/api_types#unitID]API Meta-Types - World of Warcraft Programming: A Guide and Reference for Creating WoW Addons[/url])
    ---- unit will default to target if left empty
    -- RETURN VALUES
    ---- 1 if the player is near enough to cast the spell on the unit; 0 if not in range; nil if the unit is not a valid target for the spell (1nil)
    function fawIsSpellInRange(spell, unit)
        if spell == nil then return nil; end
        if unit == nil then unit = "target"; end

        -- Using WoW'
    s standard API firstbecause Tricks of the Trade is bugged when passing it's spell index
        -- So only going further down the function the spell'
    s that returns nil
        
    -- I this returns nil is if the unit is not a valid target for the spell (or you have no target selected)
        
    local inRange IsSpellInRange(spellunit);

        -- 
    Collecting the Spell GLOBAL SpellIDnot to be confused with the SpellID
        
    -- Matching the Spell Name and the GLOBAL SpellID will give us the Spellbook index of the Spell
        
    -- With the Spellbook indexwe can then proceed to do a proper IsSpellInRange with the index.
        if 
    inRange == nil then
            local myIndex 
    nil;
            
    local nametextureoffsetnumSpellsisGuild GetSpellTabInfo(2);
            
    local booktype "spell";
            for 
    index offset+1numSpells+offset do
                -- 
    Get the Global Spell ID from the Player's spellbook
                local spellID = select(2, GetSpellBookItemInfo(index, booktype));
                if spellID and spell == GetSpellBookItemName(index, booktype) then
                    myIndex = index;
                    break; -- Breaking out of the for/do loop, because we have a match
                end
            end

            -- If the Spell wasn'
    t foundwe're checking if we have a Pet Spellbook
            -- If a Pet Spellbook is found, do the same as above and try to get an Index on the Spell
            local numPetSpells = HasPetSpells();
            if myIndex == 0 and numPetSpells then
                booktype = "pet";
                for index = 1, numPetSpells do
                    -- Get the Global Spell ID from the Pet'
    s spellbook
                    local spellID 
    select(2GetSpellBookItemInfo(indexbooktype));
                    if 
    spellID and spell == GetSpellBookItemName(indexbooktypethen
                        myIndex 
    index;
                        break; -- 
    Breaking out of the for/do loopbecause we have a match
                    end
                end
            end

            
    if myIndex then
                
    return IsSpellInRange(myIndexbooktypeunit);
            
    end
            
    return inRange;
        
    end
        
    return inRange;
    end 
    Last edited by Wopak; 09-13-2012 at 05:47 AM.

    Proper IsSpellInRange

Similar Threads

  1. How do you fix "The app failed to initialize properly(0xc0150002)"?
    By explode13 in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 08-30-2007, 07:34 PM
  2. How to properly DL model edits?
    By Sykes14 in forum WoW ME Questions and Requests
    Replies: 7
    Last Post: 05-10-2007, 08:05 PM
  3. <inser belt name> .blp, how to edit it properly?
    By Diclonius in forum WoW ME Questions and Requests
    Replies: 0
    Last Post: 04-29-2007, 06:14 PM
  4. New thread not working properly?
    By Linkitch in forum Suggestions
    Replies: 8
    Last Post: 01-06-2007, 12:07 AM
  5. Guide to Proper Scamming
    By Datonking in forum World of Warcraft Guides
    Replies: 1
    Last Post: 10-03-2006, 07:07 PM
All times are GMT -5. The time now is 08:41 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search