(6 Kb)
Updated: 08-14-06 03:48 AM
Updated:08-14-06 03:48 AM
Version: 1.7
by: Miravlix [More]
Introduction to the WoW Spellbook cache

Scanning the spellbook is a slow operation, so when many addons all trigger at the same time to read the spellbook, it makes WoW stutter.

This library is created to fix that problem, it handles all reads of the spellbook and provides a table (cache) to addons.

To Do

The goal for version 2.0 is to create an API for accesing the table.


Update for WoW 1.11 patch login error, restructuring and simplifying due to Cosmos way of including the code was made simpler.

SeaSpellbook.GetSpellIDByName( name, [booktype[, rank]] )
name = localized spell name. ie. "Wrath".
booktype = BOOKTYPE_SPELL or BOOKTYPE_PET (SPELL is default).
rank = Spell Rank number. 0 is default (alias for highest rank).
returns id when everything is kayO

returns nill if there is anything wrong with the parameters.

An alias for SeaSpellbook[booktype][name][rank].ID with error checking.

Fixed missing notification of spellbook change when training.

Some optimization.

Cleaned up Embedding/Stand alone design. (New file names and directory structure.)
Fixed a bug that could popup when Sea was also on the system.


The library works in 3 modes.

As an intergrated part of Sea in Cosmos. (In Cosmos Alpha)
Cosmos Download

Standalone addon.
Extract the directory in Interface/AddOns

Embedded into an addon.
Add the following to your addons .toc file. (Changed significantly in 1.1)
## OptionalDeps: Sea, SeaSpellbook

Load on Demand
It's not at this time supported to be embedded in a "Load On Demand" addon and my research into this area doesn't look promising. It's suggested you include it in StandAlone mode, since the library is completely inactive until someone calls RegisterScholar.

All 3 modes can be on the same system, the Embedder handles cleaning up, so only one version is in memory after the next Garbage Collector run.

How to use the library

SeaSpellbook.RegisterScholar( { 
id = "MyId", 
callback = function(bookType) if bookType = BOOKTYPE_SPELL then main spellbook was updated elseif bookType = BOOKTYPE_PET then pet spellbook was updated end,
feedback = { [BOOKTYPE_SPELL] = true, [BOOKTYPE_PET] = true },
description = "SomeAddons scholar"
} )
id - Unique ID for your addon
callback - SeaSpellbook calls this function to tell your addon of changes to it's table.
feedback - What book types do you want information on.
description - Short description, for use in reporting errors.

After registering SeaSpellbook will now update it's tables.

SeaSpellbook[BOOKTYPE_SPELL] - The Player Spellbook table
SeaSpellbook[BOOKTYPE_PET] - For pet spellbook data.
		["Battle Shout"] = {
			[2] = {
				["rageCost"] = 10,
				["description"] = "The warrior shouts, increasing the attack power of all party members within 20 yards by 36.  Lasts 2 min.",
				["ID"] = 21,
				["castTime"] = -2,
				["debug"] = {
					["L2"] = "10 Rage",
					["L1"] = "Battle Shout",
					["L3"] = "Instant",
					["L4"] = "The warrior shouts, increasing the attack power of all party members within 20 yards by 36.  Lasts 2 min.",
				["rank"] = "Rank 2",
			[0] = {
				["rageCost"] = 10,
				["description"] = "The warrior shouts, increasing the attack power of all party members within 20 yards by 36.  Lasts 2 min.",
				["ID"] = 21,
				["castTime"] = -2,
				["debug"] = {
					["L2"] = "10 Rage",
					["L1"] = "Battle Shout",
					["L3"] = "Instant",
					["L4"] = "The warrior shouts, increasing the attack power of all party members within 20 yards by 36.  Lasts 2 min.",
				["rank"] = "Rank 2",
			["spellTexture"] = "Interface\\Icons\\Ability_Warrior_BattleShout",
[0] is always a copy of the highest rank availble.
To get ["debug"] you have to set SeaSpellbook_debug = true

ID - SpellID for the spell in the spellbook
castTime - positive secs of cast time
- 0 Channeled
- -1 Instant Cast
- -2 Instant
- -3 Next melee / Next Ranged

manaCost - Mana cost
energyCost - Energy cost
rageCost - Rage cost
minRange - Casting min range to target
maxRange - Casting max range to target
cooldown - cooldown between casts in seconds

Do not depend on crit, dodge, parry, block. To save CPU, we don't update the table everytime these change. All other values should be up to date always.
crit - x.x% crit chance
dodge - x.x% dodge chance
parry - x.x% parry chance
block - x.x% block chance

These variables is local dependent.
requires - What is required before the spell can be cast?
tools - Tools required to cast the spell
reagents - Reagents required to cast the spell
description - Description

Quick search to translate texture name to spell name.
SeaSpellbook = {
	["textures"] = {
		["spell"] = {
			["Interface\\Icons\\Racial_Orc_BerserkerStrength"] = {
				[1] = "Blood Fury",
Backwards compatibility is alpha and omega in a library, so you don't need to check for never versions, a program written for version 1.0 will work with version 100.0 of the library. If you don't embed the library, checking for min version is perhaps a good idea.

The addon optionally needs and for it to print error and debug information. You can either get the Sea library while developing or write your own functions.
Optional Files (0)

There have been no comments posted to this file.
Be the first to add one.

Category Jump: