simple: "if" staement syntax

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

WalkAmongUs
decaying skeleton
decaying skeleton
Posts: 3
Joined: Tue Oct 21, 2003 10:43 am

simple: "if" staement syntax

Post by WalkAmongUs » Tue Oct 21, 2003 10:53 am

Forst Post:
Hello, nice piece of programming here. Im just beginning to work my way into this language, my previous experience being with a simplified form of C used to program NPC AIs for Neverwinter Nights. Luckily I keep two videogame addictions for when I burn out on one of them ;)

Anyways, my point:
Ive hit a wall in my initial script attempts here with what seems like a simple thing; my if statements are not being parsed. Ive compared them to other statements in the Hunter.bot I am modifying, but my syntax looks like existing syntax, so I don't understand why I am getting the "Unable to Parse" error at my own code.

The following is what Ive tried to write. It is just a modification in the hunter.mac in the part that chooses the target. Instead of a random one by name, I want to choose the nearest target of a calculated level range based off of my own toon's level:

Code: Select all

|Check max level of mob
|Compare to own level
   /varset OwnHp $char(level)
/echo @OwnHp
   /varset MobHp $target(level)
/echo @MobHp
   /varset MaxMob $calc(@OwnHp-2)
/echo @MaxMob
   /varset MinMob $calc(@OwnHp-6)
/echo @MinMob
   
   if n $int($calc(@OwnHp-2))<@MobHp /goto :Aquire
   if n $int($calc(@OwnHp-6))>@MobHp /goto :Aquire
The variables seem to be declared correctly and echo back just fine. Its the if statements where I am getting the error. Thanks in advance for any help.

WalkAmongUs
decaying skeleton
decaying skeleton
Posts: 3
Joined: Tue Oct 21, 2003 10:43 am

Post by WalkAmongUs » Tue Oct 21, 2003 11:30 am

um, nevermind, I am a goob :P It might help if I put a slash at the beginning of the line. Thats ok, I also always forget the simicolons when im writing in C.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Tue Oct 21, 2003 11:39 am

Seems to me you are doing this the hard way. You want to target mobs between 6 levels and 2 levels lower than you.

Code: Select all

/target npc range ($char(level)-6) ($char(level)-2)
That should target the nearest npc within those level ranges, without all the extra variables and calculations.

Code: Select all

:Acquire
/delay 1s
/target npc range ($char(level)-6) ($char(level-2) radius 250
/if $target()==FALSE /goto :Acquire
That loop should check every second for mobs between 6 and 2 levels lower than you, within a radius of 250 from your present location. If no target is found it loops and keeps looking. If a target meeting the criteria is found it targets the mob and continues on, presumably to your attack functions.

Better values btw, in terms of exp, are 4 and 1.
MQ2: Think of it as Evolution in action.

WalkAmongUs
decaying skeleton
decaying skeleton
Posts: 3
Joined: Tue Oct 21, 2003 10:43 am

Post by WalkAmongUs » Tue Oct 21, 2003 8:29 pm

ooh thank you. Still getting used to what I can get away with in my coding and did not realize I could use a calculation in a target statement. :D