Syntax problems

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

Sadistic
orc pawn
orc pawn
Posts: 11
Joined: Mon Jan 19, 2004 1:33 am

Syntax problems

Post by Sadistic » Mon Jan 19, 2004 1:39 am

I spent the better part of today trolling the boards trying to learn the syntax for macroquest. Read through the readme as well. I am having problems getting this snippet of code working

Code: Select all

   :Mainloop 
      /doevents 
      /if n @auto==1 { 
	/if $target()==TRUE{ 
	  /call AssumeThePosition 
	  /call Epickick } 
	}
      /goto :Mainloop 
/return 
The problem is that I cant find any clear explanation on the syntax used for if statements. I figured ok, thats cool, Ill hit the thread for posted code and just read over what others have done. What I came up with is the following:

/if n "@auto"=="1"
/if n @auto==1
/if n $target()==TRUE
/if n "$target()==TRUE"
/if n "target()"=="TRUE"

Ive seen this many variants for what seems like the same statement. So which is used for what? Whats incorrect and whats correct? The help files ive hit dont have examples of all the ones ive seen employed by other players in thier code. Obviously its not. I do have prior knowledge of coding with a few different languages but this just has me plain baffled. Right now Im currently modifying someone elses code for my own use. If the rest of the code is required id be more than happy to post that as well. Thanks in advance

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

Post by ml2517 » Mon Jan 19, 2004 1:43 am

Code: Select all

:Mainloop 
/doevents 
/if n @auto==1 { 
    /if $target()==TRUE { 
        /call AssumeThePosition 
        /call Epickick
    } 
} 
/goto :Mainloop 
/return 

User avatar
wilso132
Contributing Member
Contributing Member
Posts: 106
Joined: Thu Oct 17, 2002 11:53 am

Post by wilso132 » Mon Jan 19, 2004 1:45 am

A few quick tips

n represents numerical comparison:

Code: Select all

/if n @num==4

"" are used when comparing strings (you can also use the ~~ operator to see if it contains the string or !~ for does not contain):

Code: Select all

/if @spawn_name=="Lodizal"
or

Code: Select all

/if @spawn_name~~"Lodizal"

TRUE/FALSE are usually left without ""'s (I think because it works as a boolean value).

Check the readme in your Release folder as well as the readme found on the homepage for more info... I'm sure some of the other guys around here can answer your question a lot better than me also :).

Sadistic
orc pawn
orc pawn
Posts: 11
Joined: Mon Jan 19, 2004 1:33 am

keeping track

Post by Sadistic » Mon Jan 19, 2004 10:25 am

Other than using the boolean function im trying to use is there a more clean cut way of knowing when a button is ready to be pushed? I could try using a timer or some sort of delay to stop the button from being used but then a problem arises.

The other peice of the code not included here is a repositioning script done by Lestor and Cronic. This code is called continuously via an infinite loop that runs when autoattack is on. If I were put put a delay in there to make sure the button was pressed at just the right time the rest of this code wouldnt be executed for a brief period of time (5-6 seconds).

To illustrate this:

Code: Select all


:Mainloop 
      /doevents 
      /if n @auto==1 { 
	/if $target()==TRUE { 
	  /call Reposition 
	  /call Epickick 
	} 
}
      /goto :Mainloop 
/return 

Sub Reposition

blah blah blah
/return

Sub Epickick
 	/doability "@abilitykey"  | executes initial kick
	/if n "@noepic"!="1" { /press 9 } else { /press 0 } |noepic changes should I have vallons/wonder rapidity
/return

There has to be some sort of artificial delay someplace in there otherwise I become spammed with "You cannot do that now" from MQ trying to click my epic 2.7 billion times per second :P . But as you can see any delay I put in there will cause MQ to stay in this Sub section and disregard the reposition code.

A friend of mine told me this no longer works:

Code: Select all

 /if $char(hotbutton,@flyingkick)=="TRUE" 
Which would make me very sad since I could do a nested IF using this line and solve pretty much all my problems. Essentially in the end what I want is a script to reposition me at all times (should the mob move) click my epic and flying kick at the correct times, and not spam me in the process. Thanks again for the quick replys and I look forward to hearing from you all.

Sadistic
orc pawn
orc pawn
Posts: 11
Joined: Mon Jan 19, 2004 1:33 am

this is what i have so far

Post by Sadistic » Mon Jan 19, 2004 6:27 pm

Enclosed is a full copy of the code im working on. right now its super buggy. After fights it remains stuck in lock on mode. The MQ window is spammed the whole fight with the line "Cannot parse else {" and the mend feature doesnt seem to work. I still cant figure out whats going on.

Code: Select all

|** 	- lazy.mac
| 	- Autoattack and Movebehind Macro by Lestor and Cronic
| 	-Usage: /macro lazy "distance from target"
| 	-Macro includes a check for wonderous rapidity or Vallons Quickening and only clicks epic when needed.
| 	-Macro includes an automatic flying kick and epic click tied to it.
| 	-Macro includes an automatic mend at 75% hp or less.
|	-If you are sitting or FD, you will stand to engage when autoattack is pressed. Ducking and hitting 
|	-Autoattack will turn off Autoattack
**|

#turbo
#event YouMustBe "You must be standing to attack!"
#event AutoOff "Auto attack is off."
#event AutoOn "Auto attack is on."
#event Vallon "You feel drawn to battle."
#event Wonderrap "You begin o move with wonderous rapidity."
#event VallonFade "Your restless nature fades."
#event WonderFade "Your speed returns to normal."
#event Solo "echo Solo"


Sub Main
   /declare targdist global
   /declare i global
   /declare auto global
   /declare Oc global
   /declare Om global
   /declare dir global
   /declare dist1 global
   /declare dist2 global
   /declare dir1 global
   /declare dir2 global
   /declare noepic global |Var controls weather or not epic is clicked
   /declare Solo global
   /varset targdist "@Param0"

|** Should I be attacking the mend function is called. If I am solo
Only the kick function is called since the mob is going to autoface me 
resulting in a strange dance. If I am not solo the autoreposition
and kick script are called. After which the program repeats the entire process
**|

:Mainloop 
/doevents 
/if n @auto==1 {
	/call Mend
	/if n @Solo==1 {
		/if $target()==TRUE {
			/call Epickick
		}
	}
	else {
        	/call AssumeThePosition 
	        /call Epickick 
    	}
} |end if statement
/goto :Mainloop 
/return 

|------------------------------------------------------------------------------------------------------

Sub AssumeThePosition 
   /call MoveToTarget 
   :CheckStrafe 
      /varset Oc $if(n,$char(heading)>=180,$calc($char(heading)-180),$calc($char(heading)+180)) 
      /varset Om $if(n,$target(heading)>=180,$calc($target(heading)-180),$calc($target(heading)+180)) 
      /if n $abs(@Om-@Oc)>60 /goto :DoStrafe 
   :DoStrafe 
      /varset Oc $if(n,$char(heading)>=180,$calc($char(heading)-180),$calc($char(heading)+180)) 
      /varset Om $if(n,$target(heading)>=180,$calc($target(heading)-180),$calc($target(heading)+180)) 
      /if n $abs(@Om-@Oc)<60 /goto :End 
      /face fast nolook 
      /call GetDirection 
      /sendkey down ctrl 
      /sendkey down @dir 
      /call MoveToTarget 
      /doevents 
      /goto :DoStrafe 
   :End 
      /sendkey up @dir 
      /sendkey up ctrl 
      /face fast nolook 
/return 
|------------------------------------------------------
Sub MoveToTarget 
   :MoveLoop 
      /varadd i 1 
      /if n @i==3 { 
            /face fast nolook 
            /varset i 0 
             } 
      /if n $target(distance)>@targdist /sendkey down up 
      /if n $target(distance)<@targdist /goto :End 
      /doevents 
      /goto :MoveLoop 
   :End 
      /sendkey up up 
/return 

|----------------------------------------------------
Sub GetDirection 
   /if n @Om<180 { 
           /varset dir1 "right" 
         /varset dir2 "left" 
         /varset dist1 $calc(360-@Oc+@Om) 
         } else { 
         /varset dir1 "left" 
         /varset dir2 "right" 
         /varset dist1 $calc(360-@Om+@Oc) 
         } 
   /varset dist2 $abs(@Oc-@Om) 
   /varset dir $if(n,@dist1>@dist2,@dir2,@dir1) 
/return    

|----------------------------------------------------
Sub Mend
/if n $char(hp,pct)<=75 { 
	/if n $char(ability,"Mend")==-2 {
		/echo MEND NOT READY ***ALTER FIGHTING DAMAGE****
	} else {
		/doability "Mend"
		/g Mend Burned 6 Minutes Till Repop
		/1 Mend Burned 6 Minutes Till Repop
	}
} 
/return

|---------------------------------------------------
|** This section checks to see if flying kick is a button and the button is ready to
be pressed. If it is not it checks to see if MQ should click my epic. If haste
are currently on this section returns back into the main program. If no haste is on
click the epic. (Else; if flying kick is GTG) activate the flying kick. Then check to 
see if the epic needs to be clicked. Then return back into the main program.
**|

Sub Epickick
	/if n $char(ability,"Flying Kick")==-2 {
		/if @noepic==1 {
			/goto :Mainloop
		} else {
			/press 9
			/goto :leave
		}
	} else {
		/doability "Flying Kick"
		/if @noepic==1 {
			/goto :Mainloop
		} else {
			/press 9
		}
	} |end middle else
} |end topmost IF
:leave
/return

|---------------------------------------
Sub Event_YouMustBe
	/if "$char(state)"=="SIT" /stand
	/if "$char(state)"=="FEIGN" /stand
	/if "$char(state)"=="DUCK" {
		/echo YOU ARE DUCKING NO ATTACK FOR JOO
		/attack off
		/varset auto 0
	}
	/attack on
	/varset auto 1
/return

|----------------------------------------
Sub Event_AutoOn
	/varset auto 1
/return 
|-----------------------------------------
Sub Event_AutoOff 
	/varset auto 0 
	/doevents flush
	/press F1
/return 
|---------------------------
Sub Event_Solo
	/varset Solo 1
/return
|---------------------------
Sub Event_Vallon
	/varset noepic 1
/return
|---------------------------
Sub Event_Wonderrap
	/varset noepic 1
/return
|---------------------------
Sub Event_VallonFade
	/varset noepic 0
/return
|---------------------------
Sub Event_WonderFade
	/varset noepic 0
/return
|---------------------------


|** 
 /if n @DoFlyingKick==1 { 
      /if n $char(ability,"Flying Kick")>0 { 
         /if "$char(state)"=="SIT" /stand 
         /face fast 
         /doability "Flying Kick" 
      } 
**|
**edit
The only solution ive been able to find to stop they keyboard from being rendered in operable is to hit the control key a few times then turn auto attack on and off. Otherwise its as if the control key is being permanently held down.

*edit
After testing it some more (on players) the script seems to be able to stop gracefully. I think the problem arises when im useing npcs and they die in the process of exp'ing

daerck
a ghoul
a ghoul
Posts: 134
Joined: Mon Jan 12, 2004 8:44 pm

Post by daerck » Mon Jan 19, 2004 9:47 pm

Code: Select all

:Mainloop 
/doevents 
/if n @auto==1 { 
   /call Mend 
   /if n @Solo==1 { 
      /if $target()==TRUE { 
         /call Epickick 
      } 
   } 
   else { 
      [color=red]/if $target()==TRUE { [/color]
           /call AssumeThePosition 
           /call Epickick 
      [color=red]}[/color]
    } 
} |end if statement 
/goto :Mainloop 
/return 
Not sure if it is related to your keyboard lockup but you probably want the /if $target()==TRUE to be included in the else statement as well.

Sadistic
orc pawn
orc pawn
Posts: 11
Joined: Mon Jan 19, 2004 1:33 am

hey!

Post by Sadistic » Tue Jan 20, 2004 2:41 am

good catch on that one ill go ahead and test how it works with the addition of that line and get back to you.