WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Finding reactive spells like Overpower or Revenge (https://www.wowinterface.com/forums/showthread.php?t=59065)

Firesong 03-11-22 04:09 AM

Finding reactive spells like Overpower or Revenge
 
I'm making an addon that will have one button and it will show the correct spell to cast.

So far I have this code working:

local inRange, unit = 0, "target"
if UnitExists("target") and UnitIsVisible("target") and IsUsableSpell("Charge") then
inRange = IsSpellInRange("Charge", "target")
end
if inRange == 1 then
CommandExtra.texture:SetColorTexture(0,255,0)
message = "Charge"
else
CommandExtra.texture:SetColorTexture(255,0,0)
message = "Do nothing"
end

My plan is to have a long-ish if else function for my warrior. My question is how to identify from Lua spells like Overpower or Revenge which flash up on screen and should be used first?

All help appreciated.

Dridzt 03-11-22 04:20 AM

I'm not sure what your end goal is precisely but just to save you some trouble let me remind that showing what spell to press next is possible.

Making a button that will "intelligently" decide what to show and let you press it to cast that thing is impossible

Addons cannot make combat decisions outside of what would be possible to do with a macro.

All priority / rotation helpers (like for example Hekili) work under that principle "show not do", you still have to press the buttons.

Firesong 03-11-22 04:29 AM

Thanks for your comment. I'm trying to learn Lua and have some fun.

My question is hwo to identify reactive spells that whose buttons flash when you should use them. TMW does it but I can't make sense of the code in there.

Dridzt 03-11-22 05:00 AM

There is unfortunately no "one size fits all" answer.

If you wanted to piggyback on Blizzard's definition of reactive abilities you could potentially
1. Create a frame and Register for the COMBAT_TEXT_UPDATE event.
2. Use CombatTextSetActiveUnit("player") to set the unit to monitor to yourself.
3. Check for combattextType equals "SPELL_ACTIVE" in your event handler.
4. Get the ability with
Code:

local ability = GetCurrentCombatTextEventInfo()
If you want to be in control of what counts as reactive you'd have to do that on a case by case basis.
Does it give a buff? Check buffs.
Does it always happen after a crit/avoid/other combat event? Parse combatlog.
Etc.

An addon that tries something similar for the Classic client whose code might be easier to follow is ClassicSpellActivations.
Source code on github

Firesong 03-11-22 07:50 AM

That's great - thanks!


All times are GMT -6. The time now is 06:00 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI