WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   cast and set target (https://www.wowinterface.com/forums/showthread.php?t=21542)

upyursh 03-30-09 05:06 PM

cast and set target
 
hey all, first time poster, first time addon developer :eek:

I am going to buy Wow Programming but for now will ask the community for some help :D

Basically what I'm looking to do is "intercept" a cast of a particular spell and then set the target for the spell.

I will eventually have it so it will cast on mouseover if available, or cast to target, or cast to self

any help would be greater appreciated

upyursh 03-30-09 06:25 PM

i am at work so cant access my wow to test but I have done some ground work.

Am I on the right track here??

Code:


-- Name        : QuickMouseOverCasting
-- Author      : chris.winfieldblum
-- Notes      : Designed to remove the need for multiple macros when you
--              you choose to use Mouse Over Casting
-- Create Date : 3/31/2009 10:05:17 AM

local qmoc_version = "0.1";

function QuickMouseOverCasting:OnInitialize()

        -- Get my own player name
        local playerName = UnitName("player");
        local playerClass = UnitClass("player")
       
        -- Check if playerClass is supported
        if(QMOC_Data[playerClass]) then
       
                -- Check if our Spell is enabled
                if (QMOC_Data[playerClass][SpellName][enabled] = 1) then
       
                        -- Get our Targets with following priority
                        -- mouseover, target, focus, self
                       
                        local MouseoverName = UnitName("mouseover"); -- Do we have a mousover target
                        local MouseoverIsFriend = UnitIsFriend(playerName, MouseoverName) -- is it a friend
                       
                        local TargetName = UnitName("target"); -- do we have a target selected
                        local TargetIsFriend = UnitIsFriend(playerName, TargetName) -- is it a friend
                       
                        local FocusName = UnitName("focus"); -- do we have a focus set
                        local FocusIsFriend = UnitIsFriend(playerName, FocusName) -- is it a friend

                        -- Check out Targets
                        if (MouseoverName and MouseoverIsFriend = 1) then
                       
                                -- Cast Our Spell on Mouseover
                                CastSpellByName("Lifebloom" [, MouseoverName])
                               
                        else if(TargetName and TargetIsFriend = 1)
                       
                                -- Cast Our Spell on Target
                                CastSpellByName("Lifebloom" [, TargetName])
                               
                        else if(FocusName and FocusIsFriend = 1)
                       
                                -- Cast Our Spell on Focus
                                CastSpellByName("Lifebloom" [, FocusName])
                               
                        else
                       
                                -- Cast Our Spell on Ourself
                                CastSpellByName("Lifebloom" [, playerName])
                               
                        end
               
                end

        end
       
end


Aezay 03-31-09 06:20 AM

I am sure someone else can explain this a little better, but basically this is not possible the way you are trying to do it now. Addons are now allowed to cast spells, CastSpellByName is a protected function.


All times are GMT -6. The time now is 05:12 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI