Thread Tools Display Modes
03-30-09, 05:06 PM   #1
upyursh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 32
cast and set target

hey all, first time poster, first time addon developer

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

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
  Reply With Quote
03-30-09, 06:25 PM   #2
upyursh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 32
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

Last edited by upyursh : 03-30-09 at 07:23 PM.
  Reply With Quote
03-31-09, 06:20 AM   #3
Aezay
A Theradrim Guardian
 
Aezay's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 66
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » cast and set target

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off