need some help with /if n please

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

vitaminj
decaying skeleton
decaying skeleton
Posts: 6
Joined: Thu Mar 04, 2004 9:41 pm

need some help with /if n please

Post by vitaminj » Thu Mar 04, 2004 9:51 pm

i'm having some really wierd stuff happen /if and i can't figure it out
here's what i'm trying to run:

#turbo 90

sub Main
/spew On
/declare PullAncX global
/declare PullAncY global
/declare KiteAX global
/declare KiteAY global
/declare KiteBX global
/declare KiteBY global
/declare KiteCX global
/declare KiteCY global
/declare KiteDX global
/declare KiteDY global
/declare KiteEX global
/declare KiteEY global
/declare PetAttackKey global

/varset PetAttackKey 6

/varset PullAncX 2657
/varset PullAncY -1722
/varset KiteAX 2942
/varset KiteAY -1722
/varset KiteBX 2942
/varset KiteBY -1590
/varset KiteCX 2773
/varset KiteCY -1590
/varset KiteDX 2500
/varset KiteDY -1852
/varset KiteEX 2650
/varset KiteEY -1852

/call KiteMob
/endmacro

Sub MoveTo(DestLocX DestLocY)
/mqlog Moving To @DestLocX @DestLocY
/mqlog Distance of $distance(@DestLocX,@DestLocY)
/declare Moving local
/varset Moving 0
:ThereYet
/if n $distance(@DestLocX,@DestLocY)<=10
{
/mqlog Too Close
/varset Moving 0
/return
}
/mqlog Not Too Close
/face fast loc @DestLocX,@DestLocY
if n @Moving=0
{
/press Num_Lock
/varset Moving 1
}
/goto :ThereYet
/return

Sub KiteMob
/mqlog KiteMob up
/call MoveTo @PullAncX @PullAncY
/call MoveTo @KiteAX @KiteAY
/call MoveTo @KiteBX @KiteBY
/call MoveTo @KiteCX @KiteCY
/call MoveTo @KiteDX @KiteDY
/call MoveTo @KiteEX @KiteEY
/return

and here is the log from running that:

[2004/03/04 19:50:59] KiteMob up

[2004/03/04 19:50:59] Moving To 2657 -1722

[2004/03/04 19:50:59] Distance of 320

[2004/03/04 19:50:59] Too Close

[2004/03/04 19:50:59] Moving To 2942 -1722

[2004/03/04 19:50:59] Distance of 127

[2004/03/04 19:50:59] Too Close

[2004/03/04 19:50:59] Moving To 2942 -1590

[2004/03/04 19:50:59] Distance of 259

[2004/03/04 19:50:59] Too Close

[2004/03/04 19:50:59] Moving To 2773 -1590

[2004/03/04 19:50:59] Distance of 314

[2004/03/04 19:50:59] Too Close

[2004/03/04 19:50:59] Moving To 2500 -1852

[2004/03/04 19:50:59] Distance of 450

[2004/03/04 19:50:59] Too Close

[2004/03/04 19:50:59] Moving To 2650 -1852

[2004/03/04 19:50:59] Distance of 300

[2004/03/04 19:50:59] Too Close

so pretty much it keeps telling me that whatever the distance is, it's always <10. even if it's over 300.
if i try:
/if n $distance(@DestLocX,@DestLocY)==10
or:
/if n $distance(@DestLocX,@DestLocY)>=10
just for shits and giggles, i take a parsing error. is this some stupid newbie mistake i'm making? anyone know what i'm doin wrong here?

thanks for reading

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Thu Mar 04, 2004 10:02 pm

X and Y are backwards from /loc.

Don't ask why.

vitaminj
decaying skeleton
decaying skeleton
Posts: 6
Joined: Thu Mar 04, 2004 9:41 pm

still wonderin

Post by vitaminj » Thu Mar 04, 2004 10:26 pm

thanks for the reply, i noticed that whole x/y switch later and just hadnt gotten around to changing it. my real question is why i'm getting:

[2004/03/04 19:50:59] Distance of 320

[2004/03/04 19:50:59] Too Close

from:
/mqlog Distance of $distance(@DestLocX,@DestLocY)
:ThereYet
/if n $distance(@DestLocX,@DestLocY)<=10
{
/mqlog Too Close
/return
}

which i think means that 320 <= 10. my best guess is that i'm typing somehting in wrong and that's causing the parsing errors i mentioned when i try:
/if n $distance(@DestLocX,@DestLocY)==10
or:
/if n $distance(@DestLocX,@DestLocY)>=10

man, i know this has got to be some stupid error that i'm just not seeing

vitaminj
decaying skeleton
decaying skeleton
Posts: 6
Joined: Thu Mar 04, 2004 9:41 pm

new stuff

Post by vitaminj » Thu Mar 04, 2004 11:01 pm

i tried just:
sub Main
/declare testa global
/varset testa 2

/if n @testa<3
{
/echo @testa is < 3
}
/endmacro

and the mq window prints:
Couldn't parse 'ta<3' (in red)
[MQ2] 2 is < 3 (in yellow)

then tried:
sub Main
/declare testa global
/varset testa 4

/if n @testa<3
{
/echo @testa is < 3
}
/endmacro

and got just:
[MQ2] 4 is < 3 (in yellow)
and no parse error

what's going on here?

smelly wang
a lesser mummy
a lesser mummy
Posts: 54
Joined: Mon Jan 19, 2004 6:04 pm

Post by smelly wang » Thu Mar 04, 2004 11:08 pm

put the first curly bracket on the same line as the if.

eg

Code: Select all

sub Main 
/declare testa global 
/varset testa 2 

/if n @testa<3 { 
/echo @testa is < 3 
} 
/endmacro 
and use code brackets!!! :p

vitaminj
decaying skeleton
decaying skeleton
Posts: 6
Joined: Thu Mar 04, 2004 9:41 pm

last post

Post by vitaminj » Thu Mar 04, 2004 11:09 pm

it looks like:
/if n @testa<3 /echo @testa is < 3
works. so i guess you can't use brackets with /if?

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Thu Mar 04, 2004 11:09 pm

Code: Select all

Sub Main 
/declare testa global 
/varset testa 2 

/if n @testa<3 { 
    /echo @testa is < 3 
} 
/endmacro
/return

vitaminj
decaying skeleton
decaying skeleton
Posts: 6
Joined: Thu Mar 04, 2004 9:41 pm

Post by vitaminj » Thu Mar 04, 2004 11:51 pm

thanks, tried yours and still had some trouble with stacking /ifs so i just ended up using:
Sub MoveTo(DestLocX DestLocY)
/face fast loc @DestLocX,@DestLocY
:ThereYet
/if n $distance(@DestLocX,@DestLocY)>10 /goto :TooFar
/press Num_Lock
/varset Moving 0
/return
:TooFar
/if n @Moving==1 /goto :AlreadyMoving
/press Num_Lock
/varset Moving 1
:AlreadyMoving
/goto :ThereYet

thanks for all the help

edit: also turns out that /face and @distance both use x,y instead of y,x like it says in the manual. i'm running the macro right now using x,y and it's working. go figure

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Fri Mar 05, 2004 12:26 am

vitaminj wrote:thanks, tried yours and still had some trouble with stacking /ifs so i just ended up using:
Sub MoveTo(DestLocX DestLocY)
/face fast loc @DestLocX,@DestLocY
:ThereYet
/if n $distance(@DestLocX,@DestLocY)>10 /goto :TooFar
/press Num_Lock
/varset Moving 0
/return
:TooFar
/if n @Moving==1 /goto :AlreadyMoving
/press Num_Lock
/varset Moving 1
:AlreadyMoving
/goto :ThereYet

thanks for all the help

edit: also turns out that /face and @distance both use x,y instead of y,x like it says in the manual. i'm running the macro right now using x,y and it's working. go figure
There is nothing wrong with the code I'd posted above, so I'm not sure what you are talking about.

Also, you are incorrect. Your assumption was probably that in game locs were listed as x,y,z when in fact they are listed as y,x,z.

vitaminj
decaying skeleton
decaying skeleton
Posts: 6
Joined: Thu Mar 04, 2004 9:41 pm

Post by vitaminj » Fri Mar 05, 2004 1:54 am

ohh, never thought to check if the game locs were x,y or y,x. good point.
your test code worked but i had trouble from some reason putting /if statements right after /if statements so just figued i'd stop screwing with the brackets

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Fri Mar 05, 2004 5:18 am

If you mean something like below it should work. I have had some problems with the final result you are trying to do at the end (In the example below the "/echo This Works" part.). So just use the curly braces, like in the second code block.

Code: Select all

/if n @blah==1 /if "@blah2"=="TRUE" /if n @blah3>3 /echo This Works

Code: Select all

/if n @blah==1 /if "@blah2"=="TRUE" /if n @blah3>3 {
    /echo This Works
}
Each of the above basically means the same thing as:

Code: Select all

/if ((n @blah==1 && "@blah2"=="TRUE") && n @blah3>3) /echo This Works
or

Code: Select all

/if ((n @blah==1 && "@blah2"=="TRUE") && n @blah3>3) {
    /echo This Works
}

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Fri Mar 05, 2004 7:39 am

vitaminj wrote: edit: also turns out that /face and @distance both use x,y instead of y,x like it says in the manual. i'm running the macro right now using x,y and it's working. go figure
For $distance(y,x) it shouldn't matter which is x or y simply because of the mathematics.

As far as the /face, order is important and the last I was aware of it was

Code: Select all

 /face loc y,x

OldNecro
a ghoul
a ghoul
Posts: 136
Joined: Thu Dec 19, 2002 3:09 am

Post by OldNecro » Fri Mar 05, 2004 11:24 am

been having some weird problems with /if n myself...

/if n $target(hp,pct)>=25 /cast Neurotoxin

...macro casts when mob is at less than 10% health all the time... /shrug
Saddam Hussein begins to use An Innocent Bystander as a living shield!
An Innocent Bystander ceases protecting Saddam Hussein's corpse.

Falco72
a hill giant
a hill giant
Posts: 215
Joined: Fri Sep 26, 2003 3:24 am

Post by Falco72 » Fri Mar 05, 2004 12:07 pm

Neurotoxin have a 6 secs cast time, maybe your problem is that from the time $target(hp,pct)>=25 kick in and the time you cast the spell, the hp of your target is already down to 10% or less. I dont know the script you are using but I think that in the mean time your pet is attacking and probably you have already casted some dot on the mobs, so the hp of your target is going down quite fast. I had the same problem with my druid casting DD spell with the last one finishing casting when the mob is already dead. I had to calibrate my macro so the last DD spell was cast at the right pct of the target hp, in my case at about 15%.
Bye.