• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Not your normal IF statement - Embedded Conditional Structure Explained

Joined
Jan 14, 2016
RedCents
1,418¢
IdiotsIfThenElse.jpg
I'm going to break down the incredibly powerful embedded IF/Then/Else structure as well as show how to nest them. I was familiar with this concept not only from various programming languages but also MQ2Hud code. This particular structure can streamline your SHITs, HUD and even Macro code. This comes up enough I thought I'd break it down into its simplest terms and show the variations that make it so powerful.

The basic structure is:
Rich (BB code):
${If[SomeCondition,True,False]}

To use a real MQ2 test:
Rich (BB code):
${If[${Me.FeetWet},True,False]}

Obviously we want to do something in the TRUE branch:
Rich (BB code):
${If[${Me.FeetWet},/shout ARGH I WET Myself!!!,False]}

And the FALSE branch:
Rich (BB code):
${If[${Me.FeetWet},True,/shout Its OK, I'm wearing a DIAPER!!!]}

Putting them together:
Rich (BB code):
${If[${Me.FeetWet},/shout ARGH I WET Myself!!!,/shout Its OK, I'm wearing a DIAPER!!!]}

The basic structure for NESTING the structure in the TRUE branch of the outer condition:
Rich (BB code):
${If[SomeCondition,${If[SomeCondition,True,False]},False]}
That would only evoke the embedded condition if the outer condition was true.

The basic structure for NESTING the structure in the FALSE branch of the outer condition:
Rich (BB code):
${If[SomeCondition,True,${If[SomeCondition,True,False]}]}
That would only evoke the embedded condition if the outer condition was false.

Now you might be thinking, but Incog you hairy long bearded sillimon, I can put multiple tests using AND and OR in the original test! Yes, you can. But upon the FALSE branch you don't know which of multiple possible test conditions caused the FALSE to fire. When using nested conditions you have total control of what failed and what passed without having to do additional tests (which is unfortunately pretty common).

The basic structure for NESTING the structure in the FALSE AND the TRUE branch of the outer condition:
Rich (BB code):
${If[SomeCondition,${If[SomeCondition,True,False]},${If[SomeCondition,True,False]}]}
That would only evoke the embedded conditions when either the TRUE or the FALSE conditions of the outer condition applied. I see some power here.

Now it's important to note that you don't have to do something in any of the resultant branches. You could do:
Rich (BB code):
${If[SomeCondition,,]}
Granted it wouldn't be useful, but from a syntax perspective it is perfectly allowable.

So if you want to 'do something' only on the TRUE branch you could do:
Rich (BB code):
${If[SomeCondition,True,]}
As long as you included the comma for the FALSE branch it wouldn't have to actually do anything.

Now you might be thinking of how you might use some of these variations (or even why). I would point out that understanding the structure and its intricacies allow you a broader range of options when you DO come up with something you are trying to solve. Lets not let our understanding be the limiting factor in the solutions we are trying to discover.

The first thing that comes to mind is that most if not all shits only do something IF the condition is true (even if its proceeded by the negative ! it is still regarded as "true" from a syntax perspective). So using this structure gives us an alternate firing branch without having to create another shit to test the opposite condition. To reiterate, we usually write shits that test this and do that. With this structure we are afforded a full if/then/else solution.

To use a real-world example; most ppl put some text (say ${Zone}) in their HUD. They might put a test/condition. However I've seen a lot of HUD code that simply adds another test and either overwrites the first text, or given enough white space adds to a given line whereas we could put the whole line in an if/then/else custom tailoring the output under our control rather than having to blndly space out more text in hopes it fits. If that doesn't make sense, ok, you haven't done it. But it is common to blindly put the result of a condition in the HUD and then trying to add to it blindly where we could have utilized the if/then/else structure to avoid that.

Rich (BB code):
Time=3,4,450,85,0,255,0,Time: ${Time} GameTime: ${GameTime.Hour}:${GameTime.Minute} - ${If[${Bool[${GameTime.Night}]},Night,Day]}
That is the most elegant way to do the Night/Day HUD text. I have seen some crazy things were ppl overwrite Night with Day (and spaces) upon testing the hour. The above example takes total control and simply outputs the appropriate text, once. Another reason this approach is useful is that you don't have to guess where to put a piece of additional text if the previous text had variable length, we have total control.

Another HUD example:
Rich (BB code):
Macro1=3,4,600,100,0,255,0,${If[${Macro.Name.NotEqual["NULL"]} && ${Macro.Paused},${Macro.Name} PAUSED,${If[${Macro.Name.NotEqual["NULL"]}, ${Macro.Name},]}]}
Again, no overwriting, and no guessing where to put the word PAUSED. Total control. Notice I used the blank FALSE branch (comma but no command). If a macro isn't running, it doesn't write anything. If it is running, and paused, it writes MacroName and PAUSED. Again I have seen HUD code where ppl put the macro name and after some conditional test try to add the word PAUSED to it without knowing how long the macro name was.

Now in Holy/Down shits, it is customary to have a test of some kind and then do something. I have seen shits code that then tests for the opposite condition in its own shit. Utilizing the if/then/else conditional structure allows us to do all that in one shit, one line, all at the same time. Here is an example of double duty where the coder is trying to fire Blast of Anger when Phantom Aggressor is not ready, and Phantom Aggressor if it is:

Rich (BB code):
holyshit1=/if (!${Me.CombatAbilityReady[Phantom Aggressor]} && !${Me.ActiveDisc.ID} && ${Target.PctHPs}<100) /alt act 3646
holyshit2=/if (${Me.CombatAbilityReady[Phantom Aggressor]} && !${Me.ActiveDisc.ID} && ${Target.PctHPs}<100) /disc 40012

Here is a better way to code it:
Rich (BB code):
holyshit1=/if (${If[${Me.CombatAbilityReady[Phantom Aggressor]},/disc 40012,/alt act 3646]})

Holys and Downs fire multiple times a second. Now that we have the capacity to code 60 shits, that can create noticable lag. Why incur the load of multiple tests when it can be done in one.

Now since macro code allows us to do else branches, and elseif branches, this particular structure doesn't offer us anything we otherwise didn't have. It can however come in handy if you want a single line to accomplish if/then/else in tidy fashion. I did a quick glance thru some macs to see if I could find an example but nothing came up quickly. So I did a test in the MQ2Window command line:

Rich (BB code):
/echo ${If[${Zone.ID}==151,/say YAY I found the Bazaar!,/say Goddamnit Where the hell is the BAZ man?]}
/echo ${If[${Zone.ID}==152,/say YAY I found the Bazaar!,/say Goddamnit Where the hell is the BAZ man?]}

And it did work so I assumed you could use /docommand ${If[SomeCondition,True,False]} to fire something in a social. I tested that approach in a macro:

Rich (BB code):
sub main
	/docommand ${If[${Zone.ID}==151,/say YAY I found the Bazaar!,/say Goddamnit Where the hell is the BAZ man?]}
/return

And that worked as well. When I set the test to 151, it fired the TRUE branch. When I set it to 152 it fired the FALSE branch. I will continue to try and find examples of how some of the heavy-duty macro writers have used this structure in their code. I did a quick scan thru KissAssist but nothing jumped out at me (and there are some 7k+ lines of code, and hundreds of IFs, I coulda missed it).
 
Last edited:
how convoluted can this get btw? As in, can it be combined with traditional coding, IE

Rich (BB code):
holyshit1=/if (!${Me.Inv} && ${If[${Me.CombatAbilityReady[Phantom Aggressor]},/disc 40012,/alt act 3646]})

I wouldn't think so, but possibly

Rich (BB code):
holyshit1=/if (${If[${Me.CombatAbilityReady[Phantom Aggressor]} && !${Me.Inv},/disc 40012,/alt act 3646]})

doesn't seem likely either. It seems like this is a sort of "one trick pony" at first glance thus
Rich (BB code):
holyshit1=/if (${If[${Me.CombatAbilityReady[Phantom Aggressor]},/disc 40012,/alt act 3646]})

will this activate the disc... and then because it is now not ready... spam trying to activate the alt over and over and over, since we don't have the addition "!${Me.ActiveDisc.ID}" ? or a check on if the AA is ready
(I am assuming you cam simply put another if statement there to do the trick, but wanting to make sure I understand this)

Rich (BB code):
holyshit1=/if (${If[(${Me.CombatAbilityReady[Phantom Aggressor]} && !${Me.Inv}),/disc 40012,/alt act 3646]})

Seems possible.


Next, is there some sort of limit.. as in

Rich (BB code):
holyshit1=/if (${if[${Window[CombatAbilityWnd].Child[CAW_CombatEffectLabel].Text.Equal[No Effect]},${if[${Me.CombatAbilityReady[${Spell[Unholy Guardian Discipline].RankName}]},/disc ${Spell[Unholy Guardian Discipline].RankName},${if[${Me.CombatAbilityReady[${Spell[Doomscale Mantle].RankName}]},/disc ${Spell[${Spell[Doomscale Mantle].RankName}].ID},${if[${Me.CombatAbilityReady[${Spell[Vizat's Carapace].RankName}]},/disc ${Spell[${Spell[Grelleth's Carapace].RankName}].ID},]}]}]},]})
This ought to (if I understood and did it correctly) if there is no disc running, check each of 3 lines of discs, in order, and activate them if they are ready, all in one holy.
 
Last edited:
messing around with this...
copy and pasted
Rich (BB code):
${If[${Me.FeetWet},True,/shout Its OK, I'm wearing a DIAPER!!!]}

added "/if" to the front and enclosed it in () and its not working...says failed to parse /if command
 
messing around with this...
copy and pasted
Rich (BB code):
${If[${Me.FeetWet},True,/shout Its OK, I'm wearing a DIAPER!!!]}

added "/if" to the front and enclosed it in () and its not working...says failed to parse /if command

You either need to remove the word TRUE (leaving the comma as a placeholder) or actually embed a valid command to parse for the TRUE branch of the condition. That example was done to show Condition/True/False placement and that particular one was not meant to be usable in its current state.

- - - Updated - - -

Warl0ck45, I am working on your questions.
 
Oops, I copy and pasted the wrong one into my post... This is the one I used in game and it didn't work
Rich (BB code):
${If[${Me.FeetWet},/shout ARGH I WET Myself!!!,/shout Its OK, I'm wearing a DIAPER!!!]}

And I embedded it in an if ()
 
im just typing it in chat window...thats usually how i test random shit.
Rich (BB code):
/if (${If[${Me.FeetWet},/say yay,/say nay]})

not trying to shout to the zone, lol

says failed to parse /if command

usage: /if (<condition>) <command>
 
I imagine if you put a /docommand in front of the statement (with out () around it) it will work, IE

Rich (BB code):
/docommand ${If[${Me.FeetWet},/bc ARGH I WET Myself!!!,/bc Its OK, I'm wearing a DIAPER!!!]}

as the if statement will resolve into the true or false statement.

Or even just put it in a chat window with out "/if ()" or the do command. The ${if[ will resolve into the command all by itself

sort of like when he posted the echo

Rich (BB code):
/echo ${If[${Zone.ID}==151,/say YAY I found the Bazaar!,/say Goddamnit Where the hell is the BAZ man?]}

it was essentially saying "/echo statement" where the ${if[ was resolving which statement to make.
 
ahh, gotcha. that makes alot more sense, heh

however in this example
Rich (BB code):
holyshit1=/if (${If[${Me.CombatAbilityReady[Phantom Aggressor]},/disc 40012,/alt act 3646]})

incog has an /if in front of it..so i assumed that was correct
 
aye, not sure on that one either. That is basically saying "/if (command)" or "/if (/disc 40012)" I would think. Or at least that is how I am taking it. But then my "programming" training is some 20 odd years old so (involving learning AND/OR/NOR logic gates) --shrugs-- I ask a lot of questions =)

I would think this would be better suited in the command part of the if statement. Taking for example

Rich (BB code):
holyshit1=/if (!${Me.CombatAbilityReady[Phantom Aggressor]} && !${Me.ActiveDisc.ID} && ${Target.PctHPs}<100) /alt act 3646
holyshit2=/if (${Me.CombatAbilityReady[Phantom Aggressor]} && !${Me.ActiveDisc.ID} && ${Target.PctHPs}<100) /disc 40012

and making it into 1 line like
Rich (BB code):
holyshit1=/if (!${Me.ActiveDisc.ID} && ${Target.PctHPs}<100) ${if[${Me.CombatAbilityReady[Phantom Aggressor]},/disc 40012,${if[${Me.AltAbilityReady[Blast of Anger]},/alt act 3646,]}]}

which is to say "if I have no disc up... and the target is below 100%... then do command. Command being (if disc "Phantom Agressor" is ready, set to "/disc 4012", if not (if AA Blast of Anger is ready, set to "/alt activate 3646", if not do nothing))

This makes sense to me. But I will freely admit my coding experience is way outdated, I just tinker with stuff now and again cause I like puzzles. Not trying to nitpick, just clarify for my understanding =)

- - - Updated - - -

Played around with this some today using 105 SK aggro abilities

Rich (BB code):
holyshit11=/if ((${Me.TargetOfTarget.ID}!=${Me.ID} || ${Me.SecondaryPctAggro}>80) && ${Group.MainTank.ID}==${Me.ID} && ${Target.Distance}<50) ${If[${Me.AbilityReady[Taunt]},/doability taunt,${If[${Me.CombatAbilityReady[${Spell[Unflinching Acrimony].RankName}]},/disc ${Spell[Unflinching Acrimony].RankName},${If[${Me.AltAbilityReady[Hate's Attraction]},/casting "Hate's Attraction" ALT,${If[${Me.AltAbilityReady[Mindless Hatred]},/alt activate 732,${If[${Me.AltAbilityReady[Ageless Enmity]},/casting "Ageless Enmity" ALT,${If[${Me.AltAbilityReady[Veil of Darkness]},/casting "Veil of Darkness" ALT,/bc OUT OF AGRO STUFF!!]}]}]}]}]}]}
This is basically saying " (if I am not the target's target, or the secondary aggro person's aggro percentage is over 80) , I am the groups main tank, and the target is with in 50', then do command"
Command is:
if taunt is ready, then taunt, if not:
if disc Unflinching Acrimony is ready, /disc Unflinching Acrimony, if not:
if AA Hate's Attraction, activate AA, if not:
if AA Mindless Hatred, activate AA, if not:
if AA Ageless Emnity, activate AA, if not:
if AA Veil of Darkness, , activate AA, if not, /bc OUT OF AGRGRO STUFF!

I loaded a mage pet with taunt swords so it kept pulling aggro off the SK, lined up all the aggro hotbuttons in one bar to watch and let it rip. It seemed to have no issue punching buttons on each cycle, though the order was occasionally off. (it skipped taunt sometimes)

How ever this reduced 6 holyshits down to 1, and enabled me to put an announce message when out. Awesome possum!

This definitely opens some possibilities Incog, though it is a little mind bending getting things set up that deep.

I ended up doing the basic ${If[,,]}

then placing the cursor at the false section of the if and pressing enter, so I can keep them divided, and just basically made a blank like:
Rich (BB code):
${If[,,
${If[,,
${If[,,
${If[,,
${If[,,
${If[,,
]}]}]}]}]}]}
Then going back and filling in the conditions, and true commands. Then condensing the lines down to 1. Otherwise... thats one long ass statement that could easily go awry with 1 syntax error! =)

- - - Updated - - -

Test running this today , 105 SK defensive discs/AA/chest
Rich (BB code):
holyshit1=/if (!${Me.ActiveDisc.ID} && ${Target.Distance}<75 && ${Me.PctEndurance}>5 && (${Target.Named} || ${Me.XTarget}>2 || ${Spawn[id ${MATarget}].Level}>=${Math.Calc[${Me.Level}+3]} || ${Me.PctHPs}<75)) ${If[${Me.CombatAbilityReady[${Spell[Unholy Guardian Discipline].RankName}]},/disc ${Spell[Unholy Guardian Discipline].RankName},${If[${Me.CombatAbilityReady[${Spell[Doomscale Mantle].RankName}]},/disc ${Spell[${Spell[Doomscale Mantle].RankName}].ID},${If[${Me.CombatAbilityReady[${Spell[Vizat's Carapace].RankName}]},/disc ${Spell[${Spell[Vizat's Carapace].RankName}].ID},${If[${Me.CombatAbilityReady[${Spell[Reflexive Rancor].RankName}]},/disc ${Spell[${Spell[Reflexive Rancor].RankName}].ID},${If[${Me.AltAbilityReady[Armor of Experience]},/casting "Armor of Experience" ALT,${If[${Me.AltAbilityReady[Fundament: Third Spire of the Reaver]},/casting "Fundament: Third Spire of the Reaver" ALT,${If[${Cast.Ready[${Me.Inventory[chest]}]},/casting "${Me.Inventory[chest]}" Item,]}]}]}]}]}]}]}

What it is basically doing
Conditions:
No disc running
Target is closer then 75'
My endurance percentage is over 5%
( Target is named or
I have more then 2 mobs on extended target or
Target level is 3+ levels higher then me or
My hit point percentage is below 75%)

Then it checks for ready status of a damage mitigation disc, if true it activates, if false it goes to the next disc/AA/Item, sequence is

Unholy Guardian Discipline
Doomscale Mantle
Vizat's Carapace
Reflexive Rancor
Armor of Experience
Fundament: Third Spire of the Reaver
${Me.Inventory[chest]}

letting this run on my SK to see if it works, and works with the macro.

So far after running for a few hours I have found.... I need to tweak the heal routines on my macro since the cleric is a little slow at the start of a fight, and letting the tank get to 60 or so before healing! heh.

Otherwise it appears to be working smoothly. It has condensed potentially 13 lines of holyshits into 2.

(Demmit Incognito.. I am going to be up all night tinkering with this! =P)

- - - Updated - - -

hehe okay. I tried condensing down a section of my Defense.inc file, for the most part is is going well.

The section I have concerning paladin BPs though, lists out some 13 BP. I did a long series of ${If[,,]} with each BP listed, and put that inside a ${FindItem[].ID} to check if I made any errors. Apparently I maxed out the clipboard... it wont cut&paste into the ingame chat window... heh.

And yes.. I have been giggling about this for 5m now =P
 
Here are a few I am playing with

Defensive Tree
Rich (BB code):
holyshit5=/if (${Me.Combat} && ${Target.Distance}<75 && ${Me.PctEndurance}>5 && (${Target.Named} || ${Me.XTarget}>2)) ${If[${Me.CombatAbilityReady[Dichotomic Shield]}, /doability "Dichotomic Shield", ${If[${Me.CombatAbilityReady[${Spell[Stout Defense].RankName}]},/disc ${Spell[${Spell[Stout Defense].RankName}].ID},${If[${Me.CombatAbilityReady[${Spell[Last Stand Discipline].RankName}]},/disc ${Spell[${Spell[Last Stand Discipline].RankName}].ID},${If[${Me.CombatAbilityReady[${Spell[Pain Doesn't Hurt].RankName}]},/disc ${Spell[${Spell[Pain Doesn't Hurt].RankName}].ID},${If[${Cast.Ready[Armor of Darkened Runes]},/disc ${Spell[${Spell[Armor of Darkened Runes].RankName}].ID},]}]}]}]}]}

Aggro generation tree
Rich (BB code):
holyshit6=/if (${Me.Combat} && (${Me.PctAggro}<100 || ${Me.SecondaryPctAggro}>80) && ${Group.MainTank.ID}==${Me.ID} && ${Target.Distance}<50) ${If[${Me.AbilityReady[Taunt]}, /doability taunt, ${If[${Me.AbilityReady[Blast of Anger]}, /alt act 3646,${If[${Me.CombatAbilityReady[${Spell[Insult].RankName}]}, /disc ${Spell[Insult].RankName},${If[${Me.AbilityReady[Call of Challenge]}, /alt act 552,${If[${Me.AbilityReady[Gut Punch]}, /alt act 3732,${If[${Me.AltAbilityReady[Rage of forsaken]}, /alt act 688,${If[${Me.AltAbilityReady[Warlord's Fury]}, /alt act 912,${If[${Me.AltAbilityReady[Projection of Fury]}, /alt act 3213,${Me.CombatAbilityReady[${Spell[Phantom Aggressor].RankName}]}, /disc ${Spell[Phantom Aggressor].RankName},${Me.CombatAbilityReady[${Spell[Tormenting Shout].RankName}]}, /disc ${Spell[Tormenting Shout].RankName},${Me.CombatAbilityReady[${Spell[Warrior's Auspice].RankName}]}, /disc ${Spell[Warrior's Auspice].RankName},${Me.CombatAbilityReady[${Spell[Cyclone Roar].RankName}]}, /disc ${Spell[Cyclone Roar].RankName},${If[${Me.CombatAbilityReady[${Spell[Roar of Challenge].RankName}]}, /disc ${Spell[Roar of Challenge].RankName},/g AGRO GONE]}]}]}]}]}]}]}]}]}]}]}]}]}

Grab Agro
Rich (BB code):
holyshit7=/if (${Me.TargetOfTarget.ID}!=${Me.ID}) ${If[${Me.CombatAbilityReady[Unflinching Attention]},/disc ${Spell[Unflinching Attention].RankName} ,/alt act 2002]}
 
Just in case this has not been mentioned. Take into consideration the /if () statement requires something to do at the end. The error Janktron is getting is because MQ2 is expecting to find a command at the end of the statement. /if (${someevaluation}) /dosomethinghere. Even though the /dosomethinghere may not be executed, the MQ2 Interpreter is still looking for it.
 
What it is basically doing
Conditions:
No disc running
Target is closer then 75'
My endurance percentage is over 5%
( Target is named or
I have more then 2 mobs on extended target or
Target level is 3+ levels higher then me or
My hit point percentage is below 75%)

Then it checks for ready status of a damage mitigation disc, if true it activates, if false it goes to the next disc/AA/Item, sequence is

Unholy Guardian Discipline
Doomscale Mantle
Vizat's Carapace
Reflexive Rancor
Armor of Experience
Fundament: Third Spire of the Reaver
${Me.Inventory[chest]}

This shit is awesome!

One suggestion about the above holyshit... I would also add a check (if possible) to check to see if you've got one of the TBM zonewide debuffs on, and if so, check heals against that percentage instead of the normal 75%. For example, my toons are sitting at 70% in one of the zones, so I'd have to check against 60% or something to keep the discs from constantly firing as soon as a mob is targeted.
 
heh, nice idea. and plays into the theme of the post. The server is crashing out got me tonight so can't check if the debuff goes to song or buff window, but your suggestion plays perfect for the post!

Since as I understand it the buff can be eliminated through questing (and thus you don't want to tie it to zone)

Something like:

Rich (BB code):
${If[${Me.Buff[Blight of Sul].ID},75,50]}
 
heh, nice idea. and plays into the theme of the post. The server is crashing out got me tonight so can't check if the debuff goes to song or buff window, but your suggestion plays perfect for the post!

Since as I understand it the buff can be eliminated through questing (and thus you don't want to tie it to zone)

Something like:

Rich (BB code):
${If[${Me.Buff[Blight of Sul].ID},75,50]}

The debuff goes to the song window on me!
 
This shit is awesome!

One suggestion about the above holyshit... I would also add a check (if possible) to check to see if you've got one of the TBM zonewide debuffs on, and if so, check heals against that percentage instead of the normal 75%. For example, my toons are sitting at 70% in one of the zones, so I'd have to check against 60% or something to keep the discs from constantly firing as soon as a mob is targeted.

Is there a TLO for checking to see if a target on the xtarget window is a named? I think I would reserve the best mitigation disc for real named mobs and gross overpulls (like 5+) while reserving the other mitigation discs to smaller pulls (2+ or 3+). Exception being if the best mitigation disc is down and a named is pulled... then I'd want those to fire.

Man, playing with these is fun! I'll have to try to make the above work.
 
The Changes.txt says that the XTarget inherits Spawn TLO.

Rich (BB code):
27 Jan 2014 by eqmule
-New Feature: /useitem "item name here"
-New Feature: /itemnotify "item name here" left/rightmouseup
 This means no more need to figure out which slot an item is in, as long as its in our inventory
 it will be "clicked".
 For obvious reasons, rightmouseup only works on clicky items...

-NOTE! MACRO AUTHORS:
Keeping with my modus operandi of "breaking things that are'nt fixed" (properly)
I have made changes to the following:
Macro breaking changes: (please dont panic, its easy to adjust)
1. TLO ${Me.XTarget[x].Type} is now ${Me.XTarget[x].TargetType}
 Reason: XTarget inherits Spawn and since that already contains a .Type member, it was necasary to change it.

So ${Me.XTarget[#].Named} should return True or False. You would have to have a way to loop through all the XTargets though.
 
Rich (BB code):
	/if (${Me.XTarget}>0 && ${SpawnCount[npc named targetable radius ${NPCRadius} zradius ${NPCZRadius} noalert 1]}) {
		/for k 1 to ${Me.XTarget}
			/if (${Me.XTarget[${k}].Named}) {
				/target ID ${Me.XTarget[${k}].ID}
				/if (${Target.ID} && ${Target.ID}==${Me.XTarget[${k}].ID} && ${Me.XTarget[${k}].PctHPs}<${EngageHPs}) {
					/varset MATarget ${Me.XTarget[${k}].ID}
					/if (!${Me.Standing} && ${Me.State.NotEqual[FEIGN]}) /stand
					/if (${Group.MainTank.ID}==${Me.ID} && ${Target.Named} && ${Select[${Me.Class.ShortName},WAR,PAL,SHD]}) /call defense
					/if (${Target.ID} && ${DoRanged} && !${Me.AutoFire} && ${Target.Distance}>${RangeDist}) {
						/face fast
						/autofire on
						/delay 1s
						} else /if (${Target.ID} && ${Target.Distance}<${RangeDist}) {
						/killthis
						/call DoMelee
						}
					/popup Killing ${Target.CleanName}
					/if (${ReportEvents}) /call AnnounceMessage "${ChatChannel}" "2" "y" "Named!!" "r" "/varset MATarget" "${Me.XTarget[${k}].ID}"
					/call CreateTimer GuardTimer 50
					/return
					}
				}
		/next k
		}

This is what I dreamed up a while ago to use in AutoBot. It is part of the Guard function I added, and obviously woks with the various functions already in place for RD, but it does work, to give you an idea/starting point =)

PS, I found the autofire in MQ2Melee was not engaging correctly, and could not find any help for it, so I scripted engaging autofire into RD, hence the check.

- - - Updated - - -

Will the if statement handle complex condition checks?

as in ${If[(${XCondition} || ${YCondition}),/echo reponse1,/echo response2]}
 
Rich (BB code):
	/if (${Me.XTarget}>0 && ${SpawnCount[npc named targetable radius ${NPCRadius} zradius ${NPCZRadius} noalert 1]}) {
		/for k 1 to ${Me.XTarget}
			/if (${Me.XTarget[${k}].Named}) {
				/target ID ${Me.XTarget[${k}].ID}
				/if (${Target.ID} && ${Target.ID}==${Me.XTarget[${k}].ID} && ${Me.XTarget[${k}].PctHPs}<${EngageHPs}) {
					/varset MATarget ${Me.XTarget[${k}].ID}
					/if (!${Me.Standing} && ${Me.State.NotEqual[FEIGN]}) /stand
					/if (${Group.MainTank.ID}==${Me.ID} && ${Target.Named} && ${Select[${Me.Class.ShortName},WAR,PAL,SHD]}) /call defense
					/if (${Target.ID} && ${DoRanged} && !${Me.AutoFire} && ${Target.Distance}>${RangeDist}) {
						/face fast
						/autofire on
						/delay 1s
						} else /if (${Target.ID} && ${Target.Distance}<${RangeDist}) {
						/killthis
						/call DoMelee
						}
					/popup Killing ${Target.CleanName}
					/if (${ReportEvents}) /call AnnounceMessage "${ChatChannel}" "2" "y" "Named!!" "r" "/varset MATarget" "${Me.XTarget[${k}].ID}"
					/call CreateTimer GuardTimer 50
					/return
					}
				}
		/next k
		}

This is what I dreamed up a while ago to use in AutoBot. It is part of the Guard function I added, and obviously woks with the various functions already in place for RD, but it does work, to give you an idea/starting point =)

PS, I found the autofire in MQ2Melee was not engaging correctly, and could not find any help for it, so I scripted engaging autofire into RD, hence the check.

- - - Updated - - -

Will the if statement handle complex condition checks?

as in ${If[(${XCondition} || ${YCondition}),/echo reponse1,/echo response2]}

What is the "defense" sub that you're calling? I think we may have discussed this before in PMs... it's a macro sub/include file that handles all your defensive discs and stuff, right?
 
not to derail this thread:

http://www.redguides.com/community/showthread.php/39686-Defense-INC?highlight=defense.inc

updated top post with latest Edition. (I removed the BP checks, just had it click the worn BP. Has not cause me issue but be aware... the newest BP's proc a sword that is suppose to hit stuff near you... have not tested with mezzed mobs yet... fights haven't lasted that long, heh)

------------------

Thanks ctaylor22. This let me put in some INI checks for RD ( been meaning to do that for a while, thinking about this finally prompted me to do it) No more guessing why the macro is paused ( I hope!) thanks to botched INI =)
 
/setwintitle - distinguishing the group's MA

When running a shit-tonne of toons, and Windows stacks the client icons (which I like btw - so I leave it), sometimes its hard for me to find the group leaders quickly and easily. I wanted a way to distinguish the MA at a glance as I have each MA on its own monitor, so if I switched to another toon I wanted to quickly be able to ID the MA's and reset the forefront windows.

After much experimentation, and various iterations on the theme, I came up with this for use inside the ZONE.CFG file:
Rich (BB code):
/docommand ${If[!${MA.Find[null]},${If[${Group.MainAssist.ID}==${Me.ID},/setwintitle * ${Me.DisplayName},/setwintitle ${Me.DisplayName}]},False]}

Now, in the icon stack, I can readily see the MA's (now marked with *) and easily switch them back to the forefront. Just another example of the usefulness of the Embedded Conditional Statement.

I am embarrassed by how long this took me... MQ2 is just so damned ... picky ...

[UPDATE] Fixed - no longer marks each member with * if MA present
 
Last edited:
OK, just an FYI, This allowed me to go from 35 holys on my SK down to 16...LOVE IT!!!
 
Well THESE
Rich (BB code):
holyshit1=/if (${Target.Named} && ${Me.CombatAbilityReady[Vizat's Carapace Rk. II]} && ${Me.CurrentEndurance}>3000 && ${Window[CombatAbilityWnd].Child[CAW_CombatEffectLabel].Text.Equal[No Effect]}) /disc "Vizat's Carapace Rk. II"
holyshit2=/if (${Target.Named} && ${Me.CombatAbilityReady[Doomscale Mantle Rk. II]} && !${Me.CombatAbilityReady[Vizat's Carapace Rk. II]} && ${Me.CurrentEndurance}>8000 && ${Window[CombatAbilityWnd].Child[CAW_CombatEffectLabel].Text.Equal[No Effect]}) /disc "Doomscale Mantle Rk. II"
holyshit3=/if (${Target.Named} && ${Me.CombatAbilityReady[Unholy Guardian Discipline]} && !${Me.CombatAbilityReady[Doomscale Mantle Rk. II]} && !${Me.CombatAbilityReady[Vizat's Carapace Rk. II]} && ${Me.CurrentEndurance}>5000 && ${Window[CombatAbilityWnd].Child[CAW_CombatEffectLabel].Text.Equal[No Effect]}) /disc "Unholy Guardian Discipline Rk. II"
holyshit4=/if (${Target.Named} && ${Me.CombatAbilityReady[Deflection Discipline]} && !${Me.CombatAbilityReady[Unholy Guardian Discipline]} && !${Me.CombatAbilityReady[Doomscale Mantle Rk. II]} && !${Me.CombatAbilityReady[Vizat's Carapace Rk. II]} && ${Me.CurrentEndurance}>500 && ${Window[CombatAbilityWnd].Child[CAW_CombatEffectLabel].Text.Equal[No Effect]}) /disc "Deflection Discipline"
holyshit5=/if (${Target.Named} && ${Me.CombatAbilityReady[Leechcurse Discipline]} && !${Me.CombatAbilityReady[Deflection Discipline]} && !${Me.CombatAbilityReady[Unholy Guardian Discipline]} && !${Me.CombatAbilityReady[Doomscale Mantle Rk. II]} && !${Me.CombatAbilityReady[Vizat's Carapace Rk. II]} && ${Me.CurrentEndurance}>500 && ${Window[CombatAbilityWnd].Child[CAW_CombatEffectLabel].Text.Equal[No Effect]}) /disc "Leechcurse Discipline"
holyshit6=/if (${Target.Named} && ${Me.CombatAbilityReady[Spite of Ronak Rk. II]} && !${Me.CombatAbilityReady[Leechcurse Discipline]} && !${Me.CombatAbilityReady[Deflection Discipline]} && !${Me.CombatAbilityReady[Unholy Guardian Discipline]} && !${Me.CombatAbilityReady[Doomscale Mantle Rk. II]} && !${Me.CombatAbilityReady[Vizat's Carapace Rk. II]} && ${Me.CurrentEndurance}>500 && ${Window[CombatAbilityWnd].Child[CAW_CombatEffectLabel].Text.Equal[No Effect]}) /disc "Spite of Ronak Rk. II"
Went to this
Rich (BB code):
holyshit1=/if ((${Target.Named} || ${Me.PctHPs}<50 || ${Me.XTarget}>2 || ${Spawn[id ${MATarget}].Level}>=${Math.Calc[${Me.Level}+3]}) && ${Me.TargetOfTarget.CleanName.Equal[${Me.CleanName}]} && ${Window[CombatAbilityWnd].Child[CAW_CombatEffectLabel].Text.Equal[No Effect]}) /docommand ${If[${Me.CombatAbilityReady[${Spell[Unholy Guardian Discipline].RankName}]} && ${Me.CurrentEndurance}>5000,/disc ${Spell[Unholy Guardian Discipline].RankName},${If[${Me.CombatAbilityReady[${Spell[Doomscale Mantle].RankName}]} && ${Me.CurrentEndurance}>8000,/disc ${Spell[Doomscale Mantle].RankName},${If[${Me.CombatAbilityReady[${Spell[Vizat's Carapace].RankName}]} && ${Me.CurrentEndurance}>3000,/disc ${Spell[Vizat's Carapace].RankName},${If[${Me.CombatAbilityReady[${Spell[Deflection Discipline].RankName}]} && ${Me.CurrentEndurance}>500,/disc ${Spell[Deflection Discipline].RankName},${If[${Me.CombatAbilityReady[${Spell[Leechcurse Discipline].RankName}]} && ${Me.CurrentEndurance}>500,/disc ${Spell[Leechcurse Discipline].RankName},${If[${Me.CombatAbilityReady[${Spell[Spite of Ronak].RankName}]} && ${Me.CurrentEndurance}>500,/disc ${Spell[Spite of Ronak].RankName},${If[${Me.CombatAbilityReady[${Spell[Unholy Aura Discipline].RankName}]} && ${Me.CurrentEndurance}>1000,/disc ${Spell[Unholy Aura Discipline].RankName},/multiline ; /echo NO COMBAT ABILITIES AVAILABLE!!!!! ; /melee downflag7=1 ; /melee holyflag1=0]}]}]}]}]}]}]}
This has been tested some, not extensively, but shows GREAT promise for me, and reduced my Holys by 6.....

This activates IF:
(Target is a named OR My HP is less than 50% OR I have 3+ Mobs on Xtarget OR Mob is 3+ levels higher than me)
AND I am the Target of Mob
AND I have no Disc running.
then it fires of my "defensive" discs in this order (as ready)
1) Unholy Guardian Discipline(Disc)
2) Doomscale Mantle(Disc)
3) Vizat's Carapace(Disc)
4) Deflection Discipline(Disc)
5) Leechcurse Discipline(Disc)
6) Spite of Ronak(Disc)
7) Unholy Aura Discipline(Disc)
If none are up, it will tell me in MQ window none are available and tun holy off (and I have a Down set to turn it back on once combat ends).
 
Ok This was 7 shits to into 1 (-6) (defensive discs)
Rich (BB code):
holyshit1=/if ((${Target.Named} || ${Me.PctHPs}<50 || ${Me.XTarget}>7 || ${Spawn[id ${MATarget}].Level}>=${Math.Calc[${Me.Level}+3]}) && ${Me.TargetOfTarget.CleanName.Equal[${Me.CleanName}]} && ${Window[CombatAbilityWnd].Child[CAW_CombatEffectLabel].Text.Equal[No Effect]}) /docommand ${If[${Me.CombatAbilityReady[${Spell[Unholy Guardian Discipline].RankName}]} && ${Me.CurrentEndurance}>5000,/disc ${Spell[Unholy Guardian Discipline].RankName},${If[${Me.CombatAbilityReady[${Spell[Doomscale Mantle].RankName}]} && ${Me.CurrentEndurance}>8000,/disc ${Spell[Doomscale Mantle].RankName},${If[${Me.CombatAbilityReady[${Spell[Vizat's Carapace].RankName}]} && ${Me.CurrentEndurance}>3000,/disc ${Spell[Vizat's Carapace].RankName},${If[${Me.CombatAbilityReady[${Spell[Deflection Discipline].RankName}]} && ${Me.CurrentEndurance}>500,/disc ${Spell[Deflection Discipline].RankName},${If[${Me.CombatAbilityReady[${Spell[Leechcurse Discipline].RankName}]} && ${Me.CurrentEndurance}>500,/disc ${Spell[Leechcurse Discipline].RankName},${If[${Me.CombatAbilityReady[${Spell[Spite of Ronak].RankName}]} && ${Me.CurrentEndurance}>500,/disc ${Spell[Spite of Ronak].RankName},${If[${Me.CombatAbilityReady[${Spell[Unholy Aura Discipline].RankName}]} && ${Me.CurrentEndurance}>1000,/disc ${Spell[Unholy Aura Discipline].RankName},/multiline ; /echo NO COMBAT ABILITIES AVAILABLE!!!!! ; /melee downflag7=1 ; /melee holyflag1=0]}]}]}]}]}]}]}
This was 3 down to 1 (-2) (Single Target aggro)
Rich (BB code):
holyshit13=/if (${Target.Type.Equal[NPC]} && ${SpawnCount[npc radius 50 zradius 10]}==1 && !${Me.TargetOfTarget.CleanName.Equal[${Me.CleanName}]} && ${Melee.AggroMode}) /docommand ${If[${Cast.Ready[${Spell[Terror of Narus].RankName}]},/casting "${Spell[Terror of Narus].Rankname}",${If[${Me.AltAbilityReady[Mindless Hatred]},/alt act 732,${If[${Me.CombatAbilityReady[${Spell[Unflinching Acrimony].RankName}]},/disc "${Spell[Unflinching Acrimony].RankName}",/echo SINGLE TARGET AGGRO IS OUT!!!!!]}]}]}
This was 3 down to 1 (-2) (AE aggro)
Rich (BB code):
holyshit14=/if (${Target.Type.Equal[NPC]} && ${SpawnCount[npc radius 50 zradius 10]}>1 && !${Me.TargetOfTarget.CleanName.Equal[${Me.CleanName}]} && ${Melee.AggroMode}) /docommand ${If[${Cast.Ready[${Spell[Disgust].RankName}],/casting "${Spell[Disgust].Rankname}",${If[${Me.AltAbilityReady[Explosion of Hatred]},/alt act 822,${If[${Me.AltAbilityReady[Explosion of Spite]},/alt act 749,/echo AE AGGRO ABILITIES ARE OUT!!!!!!]}]}]}
These next 2 are kindof personal use
This was 5 down to 1 (-4) (Fires of 1 clicky / combat)
Rich (BB code):
holyshit8=/if (${Target.Type.Equal[NPC]} && ${Target.PctHPs}<96) /docommand ${If[${Cast.Ready[Vicious Rabbit]},/multiline ; /casting "Vicious Rabbit"|Item ; /melee downflag7=1 ; /melee holyflag8=0,${If[${Cast.Ready[Amulet of the Drowned Mariner]},/multiline ; /casting "Amulet of the Drowned Mariner"|Item ; /melee downflag7=1 ; /melee holyflag8=0,${If[${Cast.Ready[Necromantic Dragon Bone]},/multiline ; /casting "Necromantic Dragon Bone"|Item ; melee downflag7=1 ; /melee holyflag8=0,${If[${Cast.Ready[Combat Spellbook]},multiline ; /casting "Combat Spellbook"|Item ; melee downflag7=1 ; /melee holyflag8=0,${If[${Cast.Ready[Cloth Cap]},multiline ; /casting "Cloth Cap"|Item ; melee downflag7=1 ; /melee holyflag8=0,/multiline ; /echo Clicky Items are Out!!!!! ; /melee downflag7=1 ; /melee holyflag8=0]}]}]}]}]}
This was 6 down to 1 (-5) (Fires DD/Taps)
Rich (BB code):
holyshit9=/if (${Target.Type.Equal[NPC]} && ${Target.PctHPs}<98 && ${Me.PctMana}>20) /docommand ${If[${Cast.Ready[${Spell[Spear of Vizat].RankName}]},/casting "${Spell[Spear of Vizat].RankName}" gem1,${If[${Cast.Ready[${Spell[Dichotomic Fang].RankName}]},/casting "${Spell[Dichotomic Fang].RankName}" gem2,${If[${Cast.Ready[${Spell[Dire Declaration].RankName}]},/casting "${Spell[Dire Declaration].RankName}" gem3,${If[${Cast.Ready[${Spell[Touch of Lutzen].RankName}]},/casting "${Spell[Touch of Lutzen].RankName}" gem4,${If[${Cast.Ready[${Spell[Touch of Holmein].RankName}]},/casting "${Spell[Touch of Holmein].RankName}" gem5,/casting "${Spell[Bonemaw's Bite].RankName}" gem6]}]}]}]}]}
For a total reduction of 19 holys (35-19=16). Couple are kind-of specific to my play style.
My "other" holys
Rich (BB code):
holyshit0=/if (${Target.Named} && ${Target.PctHPs}<98 && ${Me.AltAbilityReady[Fundament: Third Spire of the Reavers]}) /multiline ; /alt act 1452 ; /alt act 9403 ; /alt act 7755 ; /alt act 742 ; /alt act 2034 ; /disc "Carmine Blade"

holyshit2=/if (${Target.Named} && ${Target.PctHPs}<95 && ${Me.AltAbilityReady[Harm Touch]}) /alt act 6000

holyshit3=/if (${Target.Named} && ${Target.PctHPs}<95 && ${Me.AltAbilityReady[Projection of Doom]}) /alt act 3215

holyshit4=/if (${Target.Named} && ${Target.PctHPs}<94 && ${Me.AltAbilityReady[Chattering Bones]}) /alt act 3822

holyshit5=/if (${Target.Named} && ${Target.PctHPs}<97 && ${Cast.Ready[Rune of Healing]}) /casting "Rune of Healing"|Item

holyshit6=/if (${Target.Named} && ${Target.PctHPs}<97 && !${Me.Song[Vampiric Aura].ID}) /docommand ${If[${Cast.Ready[Blood Drinker's Coating]},/casting "Blood Drinker's Coating"|Item, ${If[${Cast.Ready[Apocryphal Soulrender Breastplate]},/casting "Apocryphal Soulrender Breastplate"|Item,/multiline ; /echo Tap Items Down ; /melee downflag7=1 ; /melee holyflag6-0]}]}

holyshit7=/if (${Target.Named} && ${Target.PctHPs}<98 && !${Me.Song[Blessing of Unity].ID} && ${Cast.Ready[Miniature Horn of Unity]}) /casting "Miniature Horn of Unity"|Item

holyshit10=/if (${Target.Type.Equal[NPC]} && ${Target.PctHPs}<98 && ${Me.AltAbilityReady[Encroaching Darkness]} && !${BOOL{Target.Snared}}) /alt act 826

holyshit11=/if (${Target.Type.Equal[NPC]} && ${Target.PctHPs}<98 && ${Me.AltAbilityReady[Banestrike]}) /alt act 15073

holyshit12=/if (${Target.Type.Equal[NPC]} && ${Me.AltAbilityReady[Leech Touch]} && ${Me.PctHPs}<40) /multiline ; /alt act 87 ; /disc "Reflexive Rancor"
and the down that turns the holies that get turned off back on
Rich (BB code):
downshit7=/if (!${Me.CombatState.Equal[COMBAT]}) /multiline ; /melee holyflag1=1 ; /melee holyflag6=1 ; /melee holyflag8=1 ; /melee downflag6=0
Some of these are very specific to me and my play style, but I hope this helps others.

NOTE: These have successful worked in tests, but not extensively tested in "REAL" situations.
 
Us NecroGnomies love to raise the dead!!

That said, I thought some folks might get a use out of this. I happen to be using a Ranger for Main Tank in a group, but I had his macro INI and MQ2Melee set up to watch his aggro and back him off if he gets to much (cut down on all the ressing =P) Instead of constantly re-editing his stuff when I am using him to level lowbies, I added this to his Mq2Melee and macro INI entries

Rich (BB code):
${If[${Group.MainTank.ID}==${Me.ID},TRUE,${Me.PctAggro}<50]}

Thus if he is the groups main tank... it shows TRUE... if not, then it compares his percentage of aggro to the limit I set (50 in this case) and if his aggro is too high, wont cast the nukes/DoTs/other aggro inducing stuff I have set up.

Not sure if anyone else has non-tank toons monitoring their aggro like I do, but thought someone might find some use for this nugget (plus the thread is to awesome to not bump it now and again =p)
 
Last edited:
I'm trying to setup a few complex socials and was wondering if anyone has had any success with these if statements.
I've been trying to setup some class type specific socials. I've tested a few versions on the social shown below, but I can't get it to evaluate correctly.
Rich (BB code):
/bcg //docommand ${If[${Select[${Me.Class.ShortName},WAR, PAL, SHD,  ROG, MNK, BRD, BER]}>=1, /echo True,/echo False]}

Does anyone have a working version of something like this they would be willing to share?
 
Your if TLO looks like it ought to work (Thought I don't think you need the ">=1" part, as any number should be processed as TRUE)

What you need is a way to transmit over EQBC with out parsing the command on your client.

Using noparse to get MQData with bca & bcaa (one day this will be fixed):

/noparse /bcaa //bc I am ${Me.PctExp} into ${Me.Level}


Taking advantage of escape characters instead of noparse (only works with /bct at this time):

/bct Mycleric //bc I am level $\{Me.Level}

which is from the source boards description of the plugin
http://www.redguides.com/docs/projects/mq2eqbc/
 
Thanks. This command worked, but it didn't work with /bcg. Good enough. I was mostly going to be using it for /bca commands anyways.

/noparse /bca //docommand ${If[${Select[${Me.Class.ShortName},WAR, WIZ, NEC, SHD, MAG, ROG, MNK, BRD, BER]}>=1,/echo True,/echo False]}
 
Bumping this because it's an insanely great. I also want to go back and make sure all the abilities are still legit and work. I've been having mq2melee problems and these super huge nested holies seem to be the ones most prone to stupid errors.
 
Not your normal IF statement - Embedded Conditional Structure Explained

Users who are viewing this thread

Back
Top
Cart