6 - Updated spell_functions.lua Functionality
I have significantly reworked the spell_functions.lua file. The following is the new code, I hope you find it useful. I am also posting a ticket for an updated dk.lua I made using this updated spell_functions.lua.
if not Watcher then return end local L = LibStub("AceLocale-3.0"):GetLocale("Watcher") local C = Watcher.constants function Watcher:addicon(spellname, spellID) C[spellname], _, C[spellname.." Icon"] = GetSpellInfo(spellID) C[spellname.." SID"] = spellID end function Watcher:Debuff(name, casttime, stack, combocost, powercost, powerreverse, healthcost, healthreverse) -- basically, dots -- powerreverse (true) means less then -- healthreverse (true) means greater then local def = Watcher.defaults.char.spell k = C[name].." w/ Debuff" def.spellname[k] = C[name] def.name[k] = k def.icon[k] = C[name.." Icon"] def.trackspell[k] = C[name] def.typedot[k] = true -- true if looking for an aura (on caster or target) def.stockspell[k] = true def.dotthreshold[k] = casttime or 0 def.countreq[k] = stack or 0 def.caster[k] = true -- ignore other player's debuffs def.combocost[k] = combocost or 0 def.powerthresh[k] = powercost or 0 def.negthreshold[k] = powerreverse or false def.healthThreshold[k] = healthcost or 100 def.negHealthThreshold[k] = healthreverse or false def.spellID[k] = C[name.. " SID"] end function Watcher:Buff(buff, name, combocost, powercost, powerreverse, healthcost, healthreverse) -- buff that can be maintained 100% up -- powerreverse (true) means less then -- healthreverse (true) means greater then local def = Watcher.defaults.char.spell k = C[name].." w/ Buff" def.spellname[k] = C[name] def.name[k] = k def.icon[k] = C[name.." Icon"] def.trackspell[k] = C[buff] def.typedot[k] = true -- true if looking for an aura (on caster or target) def.isbuff[k] = true -- true if %trackspell is an aura on the caster def.stockspell[k] = true def.combocost[k] = combocost or 0 def.powerthresh[k] = powercost or 0 def.negthreshold[k] = powerreverse or false def.healthThreshold[k] = healthcost or 100 def.negHealthThreshold[k] = healthreverse or false def.spellID[k] = C[name.. " SID"] end function Watcher:BuffPerm(name, combocost, powercost, powerreverse, healthcost, healthreverse) -- buff that doesn't fade -- powerreverse (true) means less then -- healthreverse (true) means greater then local def = Watcher.defaults.char.spell k = C[name].." w/ Permanent Buff" def.spellname[k] = C[name] def.name[k] = k def.icon[k] = C[name.." Icon"] def.trackspell[k] = C[name] def.typedot[k] = true -- true if looking for an aura (on caster or target) def.isbuff[k] = true -- true if %trackspell is an aura on the caster def.nocd[k] = true -- true if the buff will not fade def.stockspell[k] = true def.combocost[k] = combocost or 0 def.powerthresh[k] = powercost or 0 def.negthreshold[k] = powerreverse or false def.healthThreshold[k] = healthcost or 100 def.negHealthThreshold[k] = healthreverse or false def.spellID[k] = C[name.. " SID"] end function Watcher:Direct(name, combocost, powercost, powerreverse, healthcost, healthreverse) -- direct damage and the sort -- powerreverse (true) means less then -- healthreverse (true) means greater then local def = Watcher.defaults.char.spell k = C[name] def.spellname[k] = C[name] def.name[k] = k def.icon[k] = C[name.." Icon"] def.stockspell[k] = true -- no idea def.combocost[k] = combocost or 0 def.powerthresh[k] = powercost or 0 def.negthreshold[k] = powerreverse or false def.healthThreshold[k] = healthcost or 100 def.negHealthThreshold[k] = healthreverse or false def.spellID[k] = C[name.. " SID"] end function Watcher:Capitalize(debuff, name, cooldown, combocost, powercost, powerreverse, healthcost, healthreverse) -- while %debuff is applied, cast %name -- cooldown not used yet, determines minimum time must wait before casting the spell again -- powerreverse (true) means less then -- healthreverse (true) means greater then local def = Watcher.defaults.char.spell k = C[name].." w/ "..debuff def.spellname[k] = C[name] def.name[k] = k def.icon[k] = C[name.." Icon"] def.typedot[k] = true -- true if looking for an aura (on caster or target) def.trackspell[k] = C[debuff] def.stockspell[k] = true def.caster[k] = true -- ignore other player's debuffs def.combocost[k] = combocost or 0 def.powerthresh[k] = powercost or 0 def.negthreshold[k] = powerreverse or false def.healthThreshold[k] = healthcost or 100 def.negHealthThreshold[k] = healthreverse or false def.spellID[k] = C[name.. " SID"] end function Watcher:Proc(buff, name, combocost, powercost, powerreverse, healthcost, healthreverse) -- when %buff is triggered on self, cast %name -- powerreverse (true) means less then -- healthreverse (true) means greater then local def = Watcher.defaults.char.spell k = C[name].." w/ "..buff def.spellname[k] = C[name] def.name[k] = k -- sets definition names def.icon[k] = C[name.." Icon"] def.trackspell[k] = buff -- which spell to look for def.typedot[k] = true -- true if looking for an aura (on caster or target) def.isproc[k] = true -- true if %trackspell is something that should be shown only when it's there def.isbuff[k] = true -- true if %trackspell is an aura on the caster def.stockspell[k] = true def.combocost[k] = combocost or 0 def.powerthresh[k] = powercost or 0 def.negthreshold[k] = powerreverse or false def.healthThreshold[k] = healthcost or 100 def.negHealthThreshold[k] = healthreverse or false def.spellID[k] = C[name.. " SID"] end function Watcher:Apply(debuff, name, casttime, stack, playercast, combocost, powercost, powerreverse, healthcost, healthreverse) -- when %debuff is desired, cast %name -- powerreverse (true) means less then -- healthreverse (true) means greater then local def = Watcher.defaults.char.spell k = C[name].." a/ "..debuff def.spellname[k] = C[name] def.name[k] = k def.icon[k] = C[name.." Icon"] def.typedot[k] = true -- true if looking for an aura (on caster or target) def.trackspell[k] = debuff -- which spell to look for --def.isproc[k] = true -- true if %trackspell is something that should be shown only when it's there def.stockspell[k] = true -- no idea def.dotthreshold[k] = casttime or 0 def.countreq[k] = stack or 0 def.caster[k] = playercast or true -- false, if you want to count other players' debuffs; true to require player's casts def.combocost[k] = combocost or 0 def.powerthresh[k] = powercost or 0 def.negthreshold[k] = powerreverse or false def.healthThreshold[k] = healthcost or 100 def.negHealthThreshold[k] = healthreverse or false def.spellID[k] = C[name.. " SID"] end function Watcher:ComboCost(combo, reverse, name) -- reverse (true) means less then local def = Watcher.defaults.char.spell if reverse then k = C[name].." w/ Combo less then "..combo else k = C[name].." w/ Combo more then "..combo end def.spellname[k] = C[name] def.name[k] = k def.icon[k] = C[name.." Icon"] def.stockspell[k] = true -- no idea def.combocost[k] = combo def.negthreshold[k] = reverse def.spellID[k] = C[name.. " SID"] end function Watcher:PowerThreshold(power, reverse, name) -- reverse (true) means less then local def = Watcher.defaults.char.spell if reverse then k = C[name].." w/ Power less then "..power else k = C[name].." w/ Power more then "..power end def.spellname[k] = C[name] def.name[k] = k def.icon[k] = C[name.." Icon"] def.stockspell[k] = true -- no idea def.powerthresh[k] = power def.negthreshold[k] = reverse def.spellID[k] = C[name.. " SID"] end function Watcher:HealthThreshold(health, reverse, name) -- reverse (true) means greater then local def = Watcher.defaults.char.spell if reverse then k = C[name].." w/ Health more then "..health else k = C[name].." w/ Health less then "..health end def.spellname[k] = C[name] def.name[k] = k def.icon[k] = C[name.." Icon"] def.stockspell[k] = true -- no idea def.healthThreshold[k] = health def.negHealthThreshold[k] = reverse def.spellID[k] = C[name.. " SID"] end
| Name | Size | MD5 |
|---|---|---|
| spell_functions.lua | 7.9 KiB | 0ec6a854cc7a... |
| User | When | Change |
|---|---|---|
| LunaEclipse | Oct 31, 2010 at 20:43 UTC | Added attachment spell_functions.lua |
| LunaEclipse | Oct 31, 2010 at 20:43 UTC | Deleted attachment spell_functions.lua: Updated file contents |
| LunaEclipse | Oct 31, 2010 at 20:42 UTC | Changed description:def.spellID[k] = C[name.. " SID"] end - function Watcher:Capitalize(debuff, name, combocost, powercost, powerreverse, healthcost, healthreverse) -- while %debuff is applied, cast %name + function Watcher:Capitalize(debuff, name, cooldown, combocost, powercost, powerreverse, healthcost, healthreverse) -- while %debuff is applied, cast %name + -- cooldown not used yet, determines minimum time must wait before casting the spell again -- powerreverse (true) means less then -- healthreverse (true) means greater then local def = Watcher.defaults.char.spell ---------------------------------------- def.spellID[k] = C[name.. " SID"] end - function Watcher:Apply(debuff, name, casttime, stack, playercast, cooldown, combocost, powercost, powerreverse, healthcost, healthreverse) -- when %debuff is desired, cast %name + function Watcher:Apply(debuff, name, casttime, stack, playercast, combocost, powercost, powerreverse, healthcost, healthreverse) -- when %debuff is desired, cast %name - -- powerreverse (true) means less then - -- healthreverse (true) means greater then + -- powerreverse (true) means less then - -- cooldown not used yet, determines minimum time must wait before casting the spell again + -- healthreverse (true) means greater then local def = Watcher.defaults.char.spell k = C[name].." a/ "..debuff def.spellname[k] = C[name] |
| LunaEclipse | Oct 31, 2010 at 06:54 UTC | Changed type from Enhancement to Patch |
| LunaEclipse | Oct 31, 2010 at 06:48 UTC | Added attachment spell_functions.lua |
| LunaEclipse | Oct 31, 2010 at 06:47 UTC | Create |
- 6 comments
- 6 comments
Facts
- Last updated
- Oct 31, 2010
- Reported
- Oct 31, 2010
- Status
- New - Issue has not had initial review yet.
- Type
- Patch - Source code patch for review
- Priority
- Medium - Normal priority.
- Votes
- 0
- Reply
- #6
LunaEclipse Nov 01, 2010 at 03:18 UTC - 0 likesHmm, had a look at your implementation. Calling the function and using the return value for, combo/holy power, mana/focus/energy/runic power and health, does save some coding. Still leaves you with the long list of parameters for the functions though. I am a little upset I didn't think of doing something similar.
I don't know if you saw it, I did add an updated gcds.lua with all the classes in the lua file, instead of some classes having their function in the class lua. Am I assuming something incorrect, and do those classes like Druids, need the GCD function in the respective class LUA such as druids.lua?
- Reply
- #5
Gellin Nov 01, 2010 at 02:35 UTC - 0 likesOriginally I had tried doing that but didn't like how it worked. I want the key used to link all the tables together to have a value equal to the name used in the dialogues (e.g. k = "Soul FIre @ >= 80% health"). Unfortunately, this doesn't seem to want to behave nicely due to how the functions are called with lua.
- Reply
- #4
LunaEclipse Oct 31, 2010 at 22:33 UTC - 0 likesCool, I am just glad to be able to help. I guess I will wait on updating the other classes spells until you release your spell_functions.lua.
Hey, I just thought of a way you could simplify the functions, would be a lot less parameters if you could nest them.
For example, Elitist Jerks website, for Destruction Warlocks, first spell in their priority list, is cast Soul Fire if the Target has more then 80% Health and you do not have the Improved Soul Fire Buff.
With nested functions, it would look something like this:
Watcher:HealthThreshold(80, true, Watcher:Buff(C["Improved Soul Fire"], "Soul Fire"))
Not sure if its possible to do, but it would mean the functions would require a lot less parameters as basically you would be telling it to set the settings over two functions.
- Reply
- #3
Gellin Oct 31, 2010 at 20:49 UTC - 0 likesMy gripe is more along the lines that if I want to create a direct spell with a health threshold I have to use a function like this:
Personally, I don't find it very aesthetically pleasing and a bit unintuitive for someone new reading the files. I'm probably just being a bit overly picky.
I have decided on a fixed implementation anyway. It's a bit different to yours but the function calls like Direct above will be identical.
- Reply
- #2
LunaEclipse Oct 31, 2010 at 20:41 UTC - 0 likesThe functions don't need the full parameter list, most of the parameters are optional, just check out my dk.lua for an example, the functions in it use only the first 1 or 2 parameters and leave the rest out.
The extra parameters just give extra utility by specifying only cast a debuff if the boss is over 80% health for example.
Also, I just made a minor change to the file, so I am updating the code and the attached lua. If you decide to use it, please make sure you get the new version.
- Reply
- #1
Gellin Oct 31, 2010 at 18:36 UTC - 0 likesActually, I've been implementing these already but not sure if I like how the functions require such long parameter lists. I'm going to see if I can come up with something cleaner to use tonight else these will be implemented fully.