I've added a $sqrt(<number>) function call to MQ that people here might want to use. This is useful when you want to calculate things like the distance between two things in the zone other than yourself (very useful for quad-kiting macros). What follows is the formula for calculating the distances between objects and the code for adding the $sqrt function to MQ. Maybe some kind developer will check this into CVS for me :)
example use: Two objects, one at location x1,y1, other at x2,y2:
/varset Distance = $sqrt($abs(($x1-$x2))^2 + $abs(($y1-$y2))^2)
NOTE: The MQ parser can't do the whole chunk in one shot so you have to break the formula down.
Changes:
EQLib_MacroParser.h
-add:
Code: Select all
PARMFUNC(parmSqrt) //around line 76Code: Select all
{"sqrt(", "parmSqrt", NULL}, //around line 160-add (at end of file):
Code: Select all
DWORD parmSqrt(PCHAR szVar, PCHAR szOutput, PSPAWNINFO pChar)
{
DWORD i=0;
// $sqrt(xxx)
if (!strstr(szVar,")"))
{
DebugSpew("PMP - Bad $sqrt() '%s'",szVar);
return 10000;
}
else
{
CHAR Formula[MAX_STRING] = {0};
while (szVar[i]!=')') i++;
strcpy(Formula,szVar+5);
Formula[strstr(Formula,")")-Formula] = 0;
// have to convert argument from deg to rad and result from rad to deg
sprintf(Formula,"%1.2f",(sqrt(Calculate(Formula))));
strcat(szOutput,Formula);
}
return i;
}Alci
edit: Valerian likes code brackets.

