Page 1 of 1

What am i doing wrong ?

Posted: Mon Aug 02, 2004 10:17 pm
by DumbStruck
Hey there guys . I have borrowed peices of other macros to try and patch together one that would suit my enc needs i have been trying to add a follow command but for the life of me cant get it to work have tried many variations and nothing any help i can get will be great thank you in advance.

Code: Select all

#chat tell

#include spell_routines.inc
 
#event Slowdown "#*#Your feet slow down#*#"
  


sub main 

   /echo Enc Mac started 
   :mainloop 
   /doevents 
   /goto :mainloop 
   /return 

sub Follow

   :follow
      /if (${Target.Distance}>30) /keypress up hold
      /if (${Target.Distance}<20) /keypress up 
      /face fast
      /delay 2
   /if (${Target.ID}) /goto :follow
/return

Sub Event_Chat(ChatType,Sender,ChatText)

   /if (${ChatText.Equal[slow]}) { 
      /assist ${Sender} 
      /delay 1s 
      /g slowing %t ..		
      /delay 1s 
      /call cast "Forlorn Deeds" 
       } 

  /if (${ChatText.Equal[follow]}) /goto :follow

   /if (${ChatText.Equal[nuke]}) { 
      /assist ${Sender} 
      /delay 1s 
      /g Nuking %t .. 
      /call cast "Insanity" 
       } 

   /if (${ChatText.Equal[mana]}) { 
      /tell ${Sender} mana = ${Me.PctMana}%..
       } 

   /if (${ChatText.Equal[mezz]}) { 
      /assist ${Sender} 
      /delay 1s 
      /g Atempting to Mezz %t ..
      /call cast "Bliss" 
      /tell ${Sender} mana = ${Me.PctMana}%..
       } 

   /if (${ChatText.Equal[Aemezz]}) { 
      /assist ${Sender} 
      /delay 1s 
      /g Mezzing Area ..
      /call cast "Word of morell" 
      /tell ${Sender} mana = ${Me.PctMana}%..
       } 

   /if (${ChatText.Equal[kill]}) { 
      /assist ${Sender} 
      /delay 1s 
      /g Assisting on %t ..
       /pet attack
      /delay 1s 
      /call cast "Forlorn Deeds" 
      /tell ${Sender} mana = ${Me.PctMana}%..
       }

   /if (${ChatText.Equal[Tash]}) { 
      /assist ${Sender} 
      /delay 1s 
      /g Attempting to Tash %t ..
      /delay 1s 
      /call cast "Howl of Tashan" 
      /tell ${Sender} mana = ${Me.PctMana}%..
       }


/return

sub event_slowdown

   /cast item "Journeyman's Boots" 
   /delay 4s 
   /Return


Posted: Mon Aug 02, 2004 10:57 pm
by wassup
This might get you stuck since if the character has a target it never exits the Sub and therefore /doevents is never executed:

Code: Select all

sub Follow 
   :follow 
      /if (${Target.Distance}>30) /keypress up hold 
      /if (${Target.Distance}<20) /keypress up 
      /face fast 
      /delay 2 
   /if (${Target.ID}) /goto :follow 
/return 

Posted: Mon Aug 02, 2004 11:52 pm
by DumbStruck
Wassup wrote:This might get you stuck since if the character has a target it never exits the Sub and therefore /doevents is never executed:

Code: Select all

sub Follow 
   :follow 
      /if (${Target.Distance}>30) /keypress up hold 
      /if (${Target.Distance}<20) /keypress up 
      /face fast 
      /delay 2 
   /if (${Target.ID}) /goto :follow 
/return 
one error i got while trying that way was cant find lable any suggestions on how to get it to work ?

Posted: Tue Aug 03, 2004 12:11 am
by wassup
What do you mean?

Posted: Tue Aug 03, 2004 12:38 am
by DumbStruck
ok i changed the follow subroutine to :

Code: Select all

   :follow 

      /if (${Target.Distance}>25) { 
      /keypress forward hold  
      } 
      /if (${Target.Distance}<10) { 
      /keypress back hold 
      /timed 1 /keypress back 
      } 
      /face nolook fast 
      /delay 0 
   /if (!${Target.ID}) { 
      /goto :mainloop 
      } else { 
      /goto :follow 
      } 
      /return 

   :End 
          /keypress forward 
          /keypress back 

/return
The error i got now is couldn't find label :follow Enc.mac@142 (event_chat(chattype,sender,chattext)): /goto :follow
Enc.mac@26 (main):
:mainloop

macro has ended

Posted: Tue Aug 03, 2004 2:15 am
by Cr4zyb4rd
one error i got while trying that way was cant find lable any suggestions on how to get it to work ?
yeah, easy one :)

Code: Select all

/if (${ChatText.Equal[follow]}) /goto :follow 
Won't work. The label "follow" is defined inside of another subroutine.

Code: Select all

/call Follow
instead will probably do what you want. Also, as another poster said, the Follow subroutine will never exit as long as you have a target, but I'll let you work on that one yourself. :) Post again if you need any more help.

Posted: Tue Aug 03, 2004 7:34 am
by wassup
One thing I like to do so it isn't too hard to trace the macro:

Instead of using /goto in a Sub that goes to some other Sub or back to a label in Sub Main:

Code: Select all

Sub Follow
   :follow 
   /if (${Target.Distance}>25) /keypress forward hold  
   /if (${Target.Distance}<10) { 
      /keypress back hold 
      /timed 1 /keypress back 
   } 
   /face nolook fast 
   /delay 0 
   /docommand ${If[!${Target.ID},/goto :Done,/goto :follow]}
   :Done
   /keypress forward 
   /keypress back
/return 
This way when the Sub finishes it goes back to the line immediately following the /call Follow and can be traced much easier.

Posted: Tue Aug 03, 2004 9:55 am
by Cr4zyb4rd
Using gotos is discouraged in just about any language I've ever dealt with. They're hard to follow, and lead to poor optimization the way most people use them. MQ doesn't give you a whole lot of choice since it lacks any kind of while loop, but I'd still shy away from them for any other use. I've seen a lot of the "big" macros use them as a kind of half-assed attempt at case statements, and it just comes out as an unreadable mess where subroutines could have done the same job. To each his own, though.

Code: Select all

   /docommand ${If[!${Target.ID},/goto :Done,/goto :follow]} 
   :Done 
What is the point of this? It's going to go to the next line (in this case :Done) anyway, so you could have just done:

Code: Select all

/if (${Target.ID}) /goto :follow
If you wanted something to visually mark the end of your loop, |follow or something like that would work just as well, and not cost the extra code.
This way when the Sub finishes it goes back to the line immediately following the /call Follow
Yeah...that's the entire point of subroutines... I don't see what you've done here that's any different except adding extra "do nothing" code. As for using a /goto that goes to some other Sub, it just isn't possible. Subroutines have their own local namespace, and leaping around in and out of them at random just isn't something you can do.

Posted: Tue Aug 03, 2004 10:47 am
by wassup
Cr4zyb4rd wrote:

Code: Select all

   /docommand ${If[!${Target.ID},/goto :Done,/goto :follow]} 
   :Done 
What is the point of this? It's going to go to the next line (in this case :Done) anyway, so you could have just done:

Code: Select all

/if (${Target.ID}) /goto :follow
This way when the Sub finishes it goes back to the line immediately following the /call Follow
Yeah...that's the entire point of subroutines... I don't see what you've done here that's any different except adding extra "do nothing" code. As for using a /goto that goes to some other Sub, it just isn't possible. Subroutines have their own local namespace, and leaping around in and out of them at random just isn't something you can do.
Heh, I was shortening his code and was tired and didn't notice that.

He had some other stuff under that at the :End label that I cut out and forgot to change that line to what you suggested.

Posted: Fri Aug 06, 2004 7:57 pm
by DumbStruck
Thank you guys for all your help .. And thanx fantum for your help ..

Posted: Fri Aug 06, 2004 11:27 pm
by Chill
If you still having trouble with it, try changing the names up. I notice you have a Sub named Follow, a :Follow label, and Follow might be a reserved word or used by other plugins, etc.

I would suggest renaming one or both. Something like :FollowLoop and Sub FollowTarget or whatever you want.