Thread Tools Display Modes
12-03-05, 01:49 AM   #1
Inokis
EQInterface Staff
 
Inokis's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 156
Verifying Spell Existence...

I'm trying to come up with a good and solid method for verifying if a spell exists for macro purposes. I can do this method:

Code:
function Spellname()
	GetSpellName(1, BOOKTYPE_SPELL);
	if GetSpellName(1, BOOKTYPE_SPELL) == "Attack" then
		return true;
	else
		return false;
	end
end
I want to use the Spellname function to check each spellname at specific casting steps per character class/level.

For Example, a level 1-9 Hunter would be able to cast level appropriate spells, and if they leveled up without attaining new spells they would then still be able to use the spells that existed, rather than using a spellcheck step that relies solely on the character level alone.

The only problem with this is that depending on the build and talents, some spellbooks may vary in what spells lie in what slots. Is there a more reliable way to check to see if a specific spell exists?

The ultimate purpose is never having to edit your macros when you attain a new spell and level. At the moment I am using purely character class/level based checks, but they are lacking due to the fact when I hit the next Spell Upgrade level, I'm unable to cast the spells I've not yet bought and have to edit the macro to the current spells that are actually in the spellbook. The macros I use are scripted as functions in an addon and only the function name is then used as the cast in the Macro UI button.
__________________
If not yourself, who can you count on...
  Reply With Quote
12-03-05, 03:08 AM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
You can drop the rank now in spells and it will cast the highest rank that the player knows.

Alternately you can get the spell id of the highest rank of a spell by using the method you mentioned above and looping through the spellbook to find the highest:

Code:
function GetSpellID(spellname)
	local i,done,name,id=1,false;
	_,_,spellrank = string.find(spellname,"%((Rank %d+)%)");
	spellname = string.gsub(spellname,"%(Rank %d+%)","");
	while not done do
		name,rank = GetSpellName(i,BOOKTYPE_SPELL);
		if not name then
			done=true;
		elseif (name==spellname and not spellrank) or (name==spellname and rank==spellrank) then
			id = i;
		end
		i = i+1;
	end
	return id
end
It will return the spellid of the highest rank of the spell if it's known, or nil if no ranks of the spell is known. If you declare a rank it will return the spellid of that rank of the spell. ie:

GetSpellID("Renew") -- returns id of highest rank of renew
GetSpellID("Renew(Rank 7)") -- returns id of rank 7 of renew
GetSpellID("Spirit of the Wolf") -- returns nil, wrong game!
  Reply With Quote
12-03-05, 10:42 AM   #3
Inokis
EQInterface Staff
 
Inokis's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 156
You definitely have me beat at coding variables. Thank you for this snippet.
__________________
If not yourself, who can you count on...
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Verifying Spell Existence...


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