Unofficial World of Warcraft Forums  
Please respect other members. Please do not post links or information about hacking/warez/cheats.
Read the rules of these forums as we rarely warn before banning. Lost or need RSS check the forum map.

Quick Site Nav
Navigation
Worldofwar.Net
WoW Forums
WoWDigger WoW Database
Articles
Community Blogs
WoW Info
Wrath of the Lich King Info
Primary Professions
Secondary Professions
Maps
Classes
PvP
A-Z Index
Guides
Submit Guides
List Guides
UI/Mods
Latest Mods
Submit Mod
List Macros
Submit Macro
Media Gallery
Gallery Home
Upload Pics
Community WoW Shots
Community BC Shots
Player Pics
Official WoW Shots
Official BC Shots


Donate and get extra forum perks
Support WoW:IncGamers

Go Back   Unofficial World of Warcraft Forums > WoW Community Forums > UI Customisation

Reply
 
Thread Tools Display Modes
Old 11-05-2007, 09:05 PM   #1
justalookin
WoW: IncGamers Member
 
Join Date: Mar 2007
Posts: 34
Do macro if an enemy is selected?

I just can't figure out how to put this if statement into a macro - I have a macro which does what i want, but i only wish to be able to cast it if an enemy is selected.

Any clues?
justalookin is offline   Reply With Quote
Old 11-05-2007, 09:17 PM   #2
Tunga
WorldofWar.Net Member
 
Tunga's Avatar
 
Join Date: Jul 2005
Location: London
Posts: 3,902
Depends on the macro. To cast a spell:

/cast [exists] SpellName

I think that should work.
Tunga is offline   Reply With Quote
Old 12-05-2007, 12:46 AM   #3
justalookin
WoW: IncGamers Member
 
Join Date: Mar 2007
Posts: 34
Thanks for the help - i should really explain what I'm trying to do and give code for my work so far :)

I have this so far:

/script SetRaidTarget("target", 1)
/cast Polymorph(Rank 3)
/script SendChatMessage("SHEEPING Level " .. UnitLevel("target") .. " %t", "party");

Basically what I want to happen is I set the raid icon (done), cast to a sheep (can do), and announce the victim to the party chat (done).

What i'd also like to happen is ONLY output that info to the party chat if the cast has been a sucess. At the moment if I have no enemy selected and accidently click the macro button, it outputs "SHEEPING Level 0 <no target>" to the party chat.

I don't wish to annoy anyone with this macro, so only want to announce if I've selected the target and then sheeped.

Any further help? Sorry I didn't post this much info before, i was still working on it :)
justalookin is offline   Reply With Quote
Old 12-05-2007, 02:10 AM   #4
Tunga
WorldofWar.Net Member
 
Tunga's Avatar
 
Join Date: Jul 2005
Location: London
Posts: 3,902
Try this:

/cast [exists] Polymorph
/script if(UnitExists("target")) then SetRaidTarget("target", 1); SendChatMessage("SHEEPING Level " .. UnitLevel("target") .. " %t", "party"); end

I changed the line order to try to save characters since then you only need one if statement. But basically you should be able to see what I'm doing here, it's a simple if...then...else with the UnitExists function, and you can adjust it however you like. Hope that helps.
Tunga is offline   Reply With Quote
Old 12-05-2007, 04:49 PM   #5
justalookin
WoW: IncGamers Member
 
Join Date: Mar 2007
Posts: 34
Tunga, that's exactly what i was after - it works perfectly :)

Much neater and more compact than what I was doing to boot!
justalookin is offline   Reply With Quote
Old 13-05-2007, 12:23 AM   #6
Tunga
WorldofWar.Net Member
 
Tunga's Avatar
 
Join Date: Jul 2005
Location: London
Posts: 3,902
Was expecting there to be a typo in there somewhere, glad it works :) .
Tunga is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

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

Forum Jump


All times are GMT +1. The time now is 07:36 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Advertisement System V2.5 By   Branden