Thread Tools Display Modes
06-26-24, 03:40 PM   #1
Heybarbaruiva
A Deviate Faerie Dragon
 
Heybarbaruiva's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2016
Posts: 10
Run/inject macro into action button presses

Hey folks.

Basically, I'm trying to programmatically set whatever my mouseover target is as the active/hard-locked/selected target before casting spells because the mouseover casting option found in the default interface does not work. If I have a target hard-locked, some spells like Fiery Brand refuse to cast on the mouseover unit and instead insist on casting on the hard-locked unit, unless I put it on a macro with the @mouseover decorator.

I basically wanna achieve the functionality of a macro like this one...
Code:
/target [@mouseover,harm,nodead,exists]
/startattack
/cast Fracture
...without having to create similar macros for every spell in my bar.

Based on the SecureActionButtonTemplate docs from WowWiki, I arrived at this bit of code:

Code:
button:SetAttribute("type", "macro")
button:SetAttribute("macrotext", "/target [@mouseover,harm,nodead,exists]\n/startattack")
While this solution works for some spells like Fracture and Soul Cleave, it unfortunately prevents most of the others from being cast at all. I can see that the buttons are indeed executing the macro text attributed to them, as the mouseover unit is being properly selected and the auto-attack is being initiated, but the spells themselves aren't being cast. What is unusual is that it's working for some spells but not for others.

Bartender4 seems to be doing something similar with their mouseover casting assist option without running into the same issue as me, from what I've seen here in their code, but I couldn't quite figure out how to achieve the same result on my own addon.

Code:
	UnregisterStateDriver(self, "target-help")
	self:SetAttribute("state-target-help", "nil")
	UnregisterStateDriver(self, "target-harm")
	self:SetAttribute("state-target-harm", "nil")
	UnregisterStateDriver(self, "target-all")
	self:SetAttribute("state-target-all", "nil")

	local helpDriver, harmDriver, allDriver = "", "", ""
	if self.config.autoassist then
		helpDriver = "[help]nil; [@targettarget, help]targettarget;"
		harmDriver = "[harm]nil; [@targettarget, harm]targettarget;"
		allDriver  = "" -- no autoassist without harm/help distinction
	end

	if self.config.mouseover then
		local moMod = ""
		if Bartender4.db.profile.mouseovermod and Bartender4.db.profile.mouseovermod ~= "NONE" then
			moMod = ",mod:" .. Bartender4.db.profile.mouseovermod
		end
		helpDriver = ("[@mouseover,exists,help%s]mouseover;"):format(moMod) .. helpDriver
		harmDriver = ("[@mouseover,nodead,exists,harm%s]mouseover;"):format(moMod) .. harmDriver
		allDriver  = ("[@mouseover,nodead,exists%s]mouseover;"):format(moMod) .. allDriver
	end

	if helpDriver ~= "" then
		RegisterStateDriver(self, "target-help", ("%s%s%s nil"):format(preSelf, preFocus, helpDriver))
	end

	if harmDriver ~= "" then
		RegisterStateDriver(self, "target-harm", ("%s%s nil"):format(preFocus, harmDriver))
	end

	if allDriver ~= "" then
		RegisterStateDriver(self, "target-all", ("%s%s%s nil"):format(preSelf, preFocus, allDriver))
	end
Any help would be very much appreciated

Last edited by Heybarbaruiva : 06-26-24 at 10:34 PM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Run/inject macro into action button presses


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off