WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   2.0 Error? Can't do Water Elemental Freeze from code (https://www.wowinterface.com/forums/showthread.php?t=7805)

Cubensis 01-03-07 05:05 AM

2.0 Error? Can't do Water Elemental Freeze from code
 
Hi,

Just to start, i'm not a tool =) and i have done a fair amount of development on WoW.

However, i'm having a problem with something that at first, i thought would be easy, but the more i look into it, the more i think it's not possible, but *should* be, according to blizz definition of what is allowed.

This is what i want to do.

Assign a button to the 'Freeze' skill on my Mage 41 point Water Elemental.

Now, here's the problem - i'm writing an addon for other uses, it has timer bars on the duration, and on it's water bolt skill - and will provide hotkeys to the main actions (attack/freeze). Problem i have, is the only way i can seemingly do the freeze through code, is with a /click PetActionButton2 line. However, on other mages UIs, they might move the FN location. What i wanted, was a simple

for i=1,10 do if getglobal("PetActionButton"..i).tooltipName == "Freeze" then CastPetAction(i); end end

However, that's obviously not allowed, as CastPetAction is protected.

So, my question is, is there *any* way to do this. I can't even figure it out using Secure Templates, as there is *no* way to cast the skill, through a 'Spell' name. It just doesn't work. At all.

*sigh*

I've only written to you, because i'm European, and no-one gives 2 ****s about us on the forums, and therefore, we *never* get any information to help us. *sigh*

Wonder if someone could post this on US forum, and ask Slouken to confirm whether this kind of operation, as simple as it is, is designed to be stopped, or if it's just an oversight that addons can't do it.

-Many thanks for your time

Cubensis
(Andy)


(ps, Iriel, if you are reading this, sorry i messaged you, i came here with the intent to contact you directly, then found this useful forum ^^)

Flickerstreak 01-10-07 06:37 PM

CastSpellByName() works just fine for pet spells. At least, it used to: I haven't looked in awhile. You can easily test this out by targeting an enemy and typing the following in chat with your water elemental out:

Code:

/cast Freeze
(/cast just invokes CastSpellByName)

Of course, CastSpellByName() is now protected,, but you can invoke it indirectly via a button click with a frame derived from SecureActionButton as follows:

Code:

  frame:SetAttribute("type","spell") -- when clicked, cast a spell by name
  frame:SetAttribute("spell1","Freeze") -- spell1 = left button
  frame:SetAttribute("spell2","Water Bolt") -- spell2 = right button

  -- you can even mix and match pet and player spells on the same button:
  frame:SetAttribute("shift-spell1","Frost Nova") -- shift-spell1 = shift-leftbutton

You can bind a key to the button as follows (as long as the frame was created with a name):

Code:

SetBindingClick(key, frame:GetName(),"LeftButton")
SetBindingClick(key, frame:GetName(),"RightButton")

In this case key is the key-press string (think it's just a single UTF-8 character) as passed to and OnKeyDown handler and possibly modified with a prefix, e.g. "1", "a", or "shift-q".

Then again, if you've tested it out, maybe CastSpellByName() isn't working for pet spells (in which case /cast isn't working for pet spells: I think we'd have heard a bit of an outcry from hunter and warlock macroers in that case).

Unless it's just the "Freeze" spell - previously I think it was called "Frost Nova (Water Elemental)" or something, in which case you actually have to use the name "Frost Nova (Water Elemental)()" to avoid it trying to interpret 'Water Elemental' as the rank of the spell and failing.


All times are GMT -6. The time now is 03:46 AM.

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