Detecting buffs/debuffs: Is this still possible from an addon?
Hello!
I've never written anything in Lua before so obviously nothing for WoW but I have a pretty solid background in C (I study mathematics but I do a lot of programming for simulations) so I thought I'd give writing my own "addon" a shot. Basically what I want to do is lay the groundwork for a system to detect events and react depending on what it is. The basic idea would be something like this: [Action] happens to [Something] with [Some Parameters] then do [Something] An obvious one would be to detect if Player gets a debuff, check which one it is, and if it's breakable with Hand of Freedom, alert the player. Obviously there's a way to detect buffs and debuffs (a lot of addons do it) but is there a event-way to handle them? I'm probably phrasing this really badly, but I feel like Blizzard might've added some kind of restriction to stop people from automating the game process too much. Looking through WoWWiki I found some basic documentation for the UnitAura API which lets me grab my buffs. There is also the UNIT_AURA event which returns a UnitAura ID. I'm assuming this would work? Listening for a UNIT_AURA even, grab the UnitAura ID, check what it is and react accordingly? First time doing this so any tip welcomed. Just wondering if this was a good way to go. Thanks! |
You can be alerted, but it can't do anything automatically for you, and it's limited to not being able to automatically rebind a specific button to change what that button does while being in combat, based on data like auras.
|
Add-ons can alert you based on aura gain/loss , however they can not perform actions for you.
Using your own example: Add-on will be able to check what debuff player gets; you can make a list of such debuffs that are breakable with freedom and the add-on will check if the debuff you got is on that list; and finally it can warn you in any shape or form... e.g. screen turning red, shaking, flying ponies, dancing strippers etc.. |
In addition to what the above posters said, I point you to this thread of resources for your beginning adventure in coding addons. :)
http://www.wowinterface.com/forums/s...ad.php?t=43699 |
Thanks for the replies everybody. I got some of it to work using pure Lua (not sure I want to get into the xml just yet and I really don't need an interface). Thanks for the links!
|
Even if you do decide to add an interface, you do not need to use XML. There is only one reason to use XML in WoW, and that is to create secure templates for inheritance; everything else can be done in pure Lua.
|
Also, I suggest using WowPedia over WoWWiki as it's more up-to-date: the admins and most editors left WoWWiki in 2010 to form WoWPedia.
|
Welcome to the fold Steve.
I myself use wowprogramming.com, WoWWiki, WoWInterface, Curseforge and of corse google. Yes there are limitations of what you can do in the game. For example events can not make the player automatically cast spells etc. These can only be done by actions initiated by the player (keyboard or mouseclick). If you are simply interested in finding someting that is already created then you should look at my addon called IfThen: http://www.wowinterface.com/download...11-IfThen.html It has a IDE and fully documented API to write simple IF-statements to react to events ingame, just like you mentioned in your example. A quick example of the addon's syntax. Code:
OnEvent("Buff") AND HasBuff("Heroism") OR HasBuff("Time Warp") THEN Print("!!!==Heroism || Time Warp==!!!"); |
Welcome to our nightmare, Steve. I think you're gonna like it. I think you're gonna feel you belong.
Most of what I could say has been said (WoWPedia > WoWWikki, check out WoWProgramming), but I'd also recommend popping into IRC if you need questions answered. Even with a solid background in other languages, I recommend to start with something small, if only to get accustomed to Lua, and WoW's API. |
Quote:
Quote:
Quote:
Code:
OnEvent("DeBuff") AND DebuffTarget("focus") AND HasDebuff("Chains of Ice") THEN Print("Someone needs a Freedom!") Code:
OnEVent("SpellCast") AND SpellTarget("player") and SpellIs("Polymorph") THEN Print("You should probably cast Hand of Sacrifice right about now") Quote:
|
Quote:
Code:
local Druid_Data = { Code:
for i=1,40 do -- collect active buffs Code:
local MyAddon = CreateFrame('frame') Code:
function OnEvent(self, event, arg1, arg2, ...) |
1) If you're going to post code, post the entire code. Your snippets are obviously incomplete, as they refer to variables -- such as self and buffs -- that are not defined in anything you posted, and appear to be responding to events that are not registered. Especially when you're trying to help someone who says they've never written Lua before, posting only random snippets is more confusing than helpful.
2) You shouldn't use UNIT_AURA to detect shapeshift forms on the player. There is a dedicated event for that -- UPDATE_SHAPESHIFT_FORM. 3) Things like "ex" are not good choices for variable names. Addons are not macros; you don't need to condense everything to save space. Use a descriptive variable name like "expirationTime" that clearly describes its contents without needing to read the whole function to figure it out. 4) You should never call RunScript in an addon. Just write the code you want to run. 5) You should never specify a specific language with SendChatMessage -- like "Common" -- unless you have a specific purpose for doing so (such as in a role-playing addon) and you are checking the player's faction to pass the appropriate language. Your code, for example, will fail for Horde players, since they cannot speak Common. Instead, you should pass nil, which will cause the message to be sent in the player's default language. |
Quote:
2) UNIT_AURA is a constant thing my add-on looks for, so figured why not use it there. Maybe one the less understood changes. Though it'll be examining many different druid related types. It just picks out form types from buffs. And compares it against the stored. If they are not the same, to updating it with the new seen form. Maybe a bit backwards. Then if humanoid checks are the only thing passed into UPDATE_SHAPESHIFT_FORM. 3) I usually use simple names mainly for myself. I have used myriads of shorthand, used to in the military and college. Its my own shorthand that I understand. Though if I want others to understand maybe should write it out. 4) Saw that error, thanks. 5) Thanks for the information on Common. It is a RP add-on. Will use nil as suggested. |
All times are GMT -6. The time now is 09:15 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI