I have a coding question about my new addon.
I have a coding question about my new addon.
Basically, i'm trying to write an addon that tells you about your interrupt spells. these three are what this addon supposed to do. It pops up a message whenever you actually interrupt enemy's spells. If you fail to interrupt enemy's spells (immune,absorb,etc), it pops up a failure message with cooldown duration of the spell you failed with. If you cast an interrupt spell than is still on its cooldown, it pops up a message to show you the remaining cooldown duration of the spell. and here is my code. Lua Code:
I noticed that when you are supposed to only get a message for either spell_aura_applied or spell_interrupt, you also get a spell_cast_success message like, [Kick] has failed to interrupt !!! 15s CD [Kick] > Mage's [Frost Bolt] I want to know if you can ignore the cast_success message whenever you get either aura_applied or cast_interrupt message. Also, if there is a way to fix this addon to make it work better, please help me to do so. I am a newb and this is my very first addon :o |
Quote:
|
Quote:
This is the actual code that gives me double message, Lua Code:
Is there a way to stop print CAST_SUCCESS message when you print either AURA_APPLIED or INTERRUPT message? |
In that case, just remove that entire SPELL_CAST_SUCCESS block. That event fires when the spell finishes casting, no matter if it took effect on the target or not. I would also suggest havint the spell check before the other conditionals since no matter what event type is triggered, you'd want to exit if it's a spell you want to exclude.
This is what I have in mind: Lua Code:
Note, I shortened the code a bit, renamed the variables receiving GetSpellCooldown()'s returns to conform with Blizzard's Add-On Development Policy regarding obfuscation, and cleaned up the event handler's parameters. The unused handler parameters have been renamed to the variable _ , which even though it's considered in Lua as just another variable, it's commonly used for this and is easier to distinguish as a value that isn't important. EDIT: Removed the condition for SPELL_AURA_APPLIED since in some cases, it may cause spaming when using an AoE ability like Arcane Torrent. This will also fix some cases of success messages sending twice. Note, SPELL_CAST_FAILED should also be considered for possible spam as some players may "mash" the ability when trying to cast it. |
I noticed that when you cast spells like rogue's Kick to a non-casting target, it only returns SPELL_CAST_SUCCESS to the combatlog.
It is a success casting but it didn't actually interrupt spells so it should be considered as a failure in this addon and should print the message. Also I had to put AURA_APPLIED part because spells like Silencing Shot and Strangulate apply silence aura before or instead of the interrupt. I should just remove arcane torrent from the spell list if the spamming is gonna be the issue :D and thank you very much for all these help :) |
I'll have to look again, but last I saw, silence effects do trigger an interrupt if the target is in the process of casting. This may fire another event like UNIT_SPELLCAST_INTERRUPTED. If you insist on sending a message on SPELL_CAST_SUCCESS, I'd suggest using a different message saying along the lines of "X used on Y, CD in Z seconds." This would at least make the message more relevant to the event firing. It's also good practice to limit how much you send through public chat channels as messages being sent too often is frowned upon by the player base and Blizzard themselves.
|
Quote:
|
Whitespace is just a minor inconvenience, but variable names that offer no information as to what values are put in them is the real meaning of obfuscation.
The code block in question was this. Code:
local xt,yt,zt = GetSpellCooldown(spellID) If speed is your concern, it would be quicker to type and more meaningful to use local s,d,e. References on the word obfuscation: http://dictionary.reference.com/browse/obfuscation http://wiki.answers.com/Q/What_is_ob...fuscation_used http://sawaal.ibibo.com/computers-an...on-140331.html |
All times are GMT -6. The time now is 01:24 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI