General /if statement command lists?
Reply
/if statement command lists?
Just curious if there is a list of all the possible /if statements anywhere? I know what I want when I am making and editing macros, however I don't know who I should be entering it. It's annoying only because I then have to search though other macros in hopes of finding what I need, or an alternative.

Biggest ones now are discs and if im not behind target type stuff. Looking for something like

/if ${Me.NotBehind.Target} /stick maxengage !front

Or if a disc is available to use I'd like it to be used if conditions are met. Like Rogue Daggerfall. It would be included in a macro with a declared timer and stuff, but idk how to really write the /if statement to include it. It just has to meet a Hide time.

Eitherway, just wondering if there was a command list anywhere?
Thu Nov 17, 2011 10:21 am
Sort of, the possible combinations are effectively infinite so doing a definitive list is out of the question. You just have to learn the different data layouts and how an if statement is structured.

There is a write-up here with a subsection on "Conditionals:" that will outline the function of the /if statement a little.
EDIT: forgot the link, http://mqemulator.net/forum2/viewtopic.php?t=63

For the actual pieces of data, called TLOs or Top-Level-Objects visit
http://macroquest2.com/includes/wassup/manual.php

scroll down that page just a little and you will see a few tables. The first table lists the TLOs. We will use the "Me" as an example. So click the "Me" link.

it will move you down the page to a section describing the Me object. It says the object has access to type character, and spawn. Character and Spawn are the two types of Me. For example if a spawn has the subtype of "PctHPs" then Me.PctHPs would be valid. If Character has the subtype of AAPoints then Me.AAPoints would be valid.

If you go back to the table up top and click the "Target" TLO you will see that it is only of the type "spawn". That means Target.AAPoints would not be valid because Target isn't of the type Character.

Here is the kicker, each TLO has a type (or multiple types), that type identifies what sub-objects the TLO has. The kicker is that each sub-object also has its own types. Sometimes to the point of infinity. For example any object with the type int (integer) has a sub object of .Float. The .Float subobject is of type "float". Any "Float" object has a sub object of "Int" which is of type "int". This means that Me.PctHPs.Float.Int.Float.Int.Float.Int.Float.Int..... would be valid.

There are sometimes multiple ways to get the same data and some of them are faster/slower than others. For example ${NearestSpawn[0]} will return your own spawn property (without the character sub-objects because NearestSpawn is of type "spawn" not "spawn and character"). You will get the same object by doing ${Me.Spawn} however in the case of NearestSpawn[0] the 0 parameter gets passed to a bit of code that searches through (probably very quickly) the spawn linked list for the spawn that is closest to your coordinates. Me.Spawn will directly access your characters pointer to the character class, then offset for the spawn pointer and return that to the data api. This is magnitudes faster even though you won't be able to note the difference.

Learning to write if statements can be confusing at first, sometimes it is best -- early-on -- to try and read them in english. "/if (!${Me.Sitting}&&!${Me.Casting.ID}) /sit" would turn into "If I am not sitting and I am not casting then make me sit."

I'm going to move this topic over to the Public Macro forum after I think you've seen it. So if it vanishes look there.
Last edited by Maudigan on Thu Nov 17, 2011 3:53 pm; edited 1 time in total
Thu Nov 17, 2011 2:03 pm
Project Lead
I almost forgot your request about the behind object. There is probably a better way than what I will describe; it's been a long time since I did this. If there is a simpler way then sorvani will probably chime in.

I can't be sure my math is correct without logging into the game and trying it out but there is a way to test it in game.

This may get confusing and i'm coming up with this on the spot without the game in front of me so I may be dead wrong.

Target.HeadingTo creates a vector from you to the spawn you then compare that heading to to Target.Heading. If they are within a certan number of degrees then you are behind them.

For the vector from you to the mob is 90, and the mob is facing 90. Then you are directly behind them. Your vector to the mob is 110, and the mob is facing 90, then you are 20 degrees from the mobs back. Some testing will tell you how big that number can be and still be behind the mob. There is a good chance using sneak and conning to test this will work. I want to say you need to be within 90 degrees of center.

Macro
More +

Sub Main

|var to hold the difference in heading
/declare HeadingDiff int inner

|calculate the absolute value of the difference
/varset  HeadingDiff ${Math.Abs[${Target.HeadingTo.Degrees}-${Target.Heading.Degrees}]}

|some debug output in case i've got this wrong
/echo Heading to target: ${Target.HeadingTo.Degrees}
/echo Target heading: ${Target.Heading.Degrees}
/echo Heading difference before correction: ${HeadingDiff}

|350 and 0 are only 10 apart not 350, accomidate for that.
/if (${HeadingDiff}>180) /varcalc HeadingDiff 360 - ${HeadingDiff}

|more debugging output
/echo Heading difference after correction: ${HeadingDiff}

|test the idea with some arbitrary debug output
/if (${HeadingDiff}<=90) /echo I'm BEHIND the mob
/if (${HeadingDiff}>90) /echo I'm in FRONT of the mob


/return


One last disclaimer: sorry if this is way off, if it isn't working let me know and next time i'm logged in i'll hash it out.
Thu Nov 17, 2011 3:49 pm
Project Lead
I would suggest making use of the MQ2Melee plugin. It will keep you behind the mob by default, as soon as you engage unless you are a tank class.

If you are using the plugin but not it's built in stick routines, it does provide a TLO
Macro
More +
${Melee.BackAngle}

I find the MQ2 Wiki is a good resource for people getting started.
Main landing page: http://www.macroquest2.com/wiki/index.php
Macro Reference: http://www.macroquest2.com/wiki/index.php/Macro_Reference
TLO: http://www.macroquest2.com/wiki/index.php/Top-Level_Objects
_________________
Sorvani
Fri Nov 18, 2011 11:25 am
Senior Project Member
Im using the gold member version of MQ build here, which includes MQ2Melee. The problem I am having, which thinking about seems like an easy fix, is that my mage command for casting til dead kicks in before he is behind the enemy. I s'pose I could add a delay. Just figured I could try an if condition to make him check that he was behind the enemy first.

Appreciate the help you two. Great stuff here =)
Fri Nov 18, 2011 3:48 pm
Your welcome, sorry I'm so long winded. :)
Sat Nov 19, 2011 9:36 am
Project Lead
If you are wanting your mage to wait so that his pet is behind, yeah you are going to have to add in some kind of position check and delay to hold off on the nuke till dead section of your macro.
_________________
Sorvani
Sat Nov 19, 2011 10:59 pm
Senior Project Member
General /if statement command lists?
Reply