Help with auto attack macro..

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

loadingpleasewait
a snow griffon
a snow griffon
Posts: 332
Joined: Sat Sep 14, 2002 8:46 am

Help with auto attack macro..

Post by loadingpleasewait » Wed Oct 08, 2003 12:46 pm

Ok, I have my autofight macro put together, and most everything works..

BUT, I cant seem to get my Parameters to work (never really did understand how to get them to)

I want to be able to toggle autofollow and/or taunt.. but neither is working at all.. here is the code in its current state.

Code: Select all

#Event exp "experience!"
#Event Casting "You begin casting"
#Event Enraged "has become ENRAGED" 
#Event Offrage "is no longer enraged" 

Sub Main
   /echo Auto-Attack Macro has begun. 
   /declare startexp global
   /declare startaaxp global
   /declare EnrageVar global 
   /declare Combatstatus global
   /declare currentxp global
   /declare xpgain global
   /declare currentaa global
   /declare aagain global 
   /declare targetarray array 

      /varset startexp $char(exp)
      /varset startaaxp $char(aa,exp)
/if "@Param0"=="Follow" /echo "Auto following enabled"
/if "@Param0"=="taunt" /echo "Auto-Taunt enabled"

      :mainloop
         /if "$combat"=="TRUE" /call melee
         /delay 3
         /doevents
      /goto :mainloop
/return

Sub melee
  
  /varset targetarray(0) "$target(name,clean)" 
  /varset targetarray(1) $target(level) 
  /varset targetarray(2) $target(name) 
  /varset targetarray(3) $target(id) 
  
  /if "@targetarray(3)"=="0" /return

  /echo Fighting a level @targetarray(1) @targetarray(0) 
  /face look 

  :CloserAF 
    /if "$target(id)"!=@targetarray(3) /goto :EndAF 
    /doevents
    /call Combatcheck
    /if "@Param0"=="Follow" /if n $target(distance,nopredict)>10 /press up 
    /if "@Param0"=="Follow" /if n $target(distance,nopredict)<10 /press down 
    /face fast nopredict look 
    /if n $target(distance,nopredict)<11 /if n $char(ability,"Kick")>0 /doability "Kick" 
    /if n $target(distance,nopredict)<11 /if n $char(ability,"Disarm")>0 /doability "Disarm" 
    /if "@Param0"=="taunt" /if n $target(distance,nopredict)<11 /if n $char(ability,"Taunt")>0 /doability "Taunt"
    /delay 4
    /goto :CloserAF 
/return

:EndAF 
    /echo The level @targetarray(1) @targetarray(0) is dead... 
    /sendkey up up 
    /sendkey up down 
    /attack off 
    /varset targetarray(3) 0 
    /press Num_5 
    /delay 4
/return 

     /if "Param0"=="follow" /if n $target(distance,nopredict)>10 /sendkey down up 
     /if "Param0"=="follow" /if n $target(distance,nopredict)<10 /sendkey up up 
     /if "Param0"=="follow" /if n $target(distance,nopredict)<15 /attack on 
     /if "Param0"=="follow" /if n $target(distance,nopredict)>15 /attack off 

Sub Combatcheck 
   /if @EnrageVar=="1" { 
      /if $target()=="TRUE" { 
         /return 
      } else { 
         /varset EnrageVar 0 
         /varset Combatstatus 0 
      } 
   } 
   /if $target()=="FALSE" { 
      /varset Combatstatus 0 
      /if $combat=="TRUE" { 
         /attack off 
      } 
      /return 
   } 
/return 

Sub Event_Enraged 
   /if $target()=="TRUE" { 
      /if n @Combatstatus==1 { 
         /varset EnrageVar 1 
         /attack off 
      } 
      /varset EnrageVar 1 
   } 
/return 

Sub Event_Offrage 
   /if $target()=="TRUE" { 
      /if n @Combatstatus==1 { 
         /varset EnrageVar 0 
         /attack 
      
      } 
      /varset EnrageVar 0 
   } 
/return 

Sub Event_exp
   /varset currentxp $char(exp)
   /varcalc xpgain @currentxp-@startexp
   /varset currentaa $char(aa,exp)
   /varcalc aagain @currentaa-@startaaxp
      /echo "You've gained @xpgain% xp and @currentaa% aaxp."
   /varset @startexp $char(exp)
   /varset startaaxp $char(aa,exp)
/return

Sub Casting
   :checkcast 
    /delay 3 
    /if "$char(casting)"=="TRUE" goto :checkcast 
/return 


any help would be appreciated..

Also, is there any way to get archery NOT to turn on $combat ?? every time I pluck an arrow, it starts my combat sub..
LOADING PLEASE WAIT...

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 » Wed Oct 08, 2003 1:14 pm

Change your Sub Main to this and it should work. Both of these examples will work. First one is the way I would use, the second one is with McKorr's idea.

Code: Select all

Sub Main[color=cyan](FirstArg,SecondArg)[/color]
   /echo Auto-Attack Macro has begun. 
   [color=cyan]/declare Toggle local[/color]
   [color=cyan]/declare Toggle2 local[/color]
   /declare startexp global 
   /declare startaaxp global 
   /declare EnrageVar global 
   /declare Combatstatus global 
   /declare currentxp global 
   /declare xpgain global 
   /declare currentaa global 
   /declare aagain global 
   /declare targetarray array 

   [color=cyan]/varset Toggle @FirstArg[/color]
   [color=cyan]/varset Toggle2 @SecondArg[/color]
   /varset startexp $char(exp) 
   /varset startaaxp $char(aa,exp) 
   /if "[color=cyan]@Toggle[/color]"=="Follow" /echo "Auto following enabled" 
   /if "[color=cyan]@Toggle2[/color]"==taunt" /echo "Auto-Taunt enabled" 

   :mainloop 
   /if "$combat"=="TRUE" /call melee 
   /delay 3 
   /doevents 
   /goto :mainloop 
/return 
Or

Code: Select all

Sub Main
   /echo Auto-Attack Macro has begun.
   [color=cyan]/declare Toggle local[/color]
   [color=cyan]/declare Toggle2 local[/color]
   /declare startexp global 
   /declare startaaxp global 
   /declare EnrageVar global 
   /declare Combatstatus global 
   /declare currentxp global 
   /declare xpgain global 
   /declare currentaa global 
   /declare aagain global 
   /declare targetarray array 

   [color=cyan]/varset Toggle @Param0[/color]
   [color=cyan]/varset Toggle2 @Param1[/color]
   /varset startexp $char(exp) 
   /varset startaaxp $char(aa,exp) 
   /if "[color=cyan]@Toggle[/color]"=="Follow" /echo "Auto following enabled" 
   /if "[color=cyan]@Toggle2[/color]"==taunt" /echo "Auto-Taunt enabled" 

   :mainloop 
   /if "$combat"=="TRUE" /call melee 
   /delay 3 
   /doevents 
   /goto :mainloop 
/return
As far as making Archery not making $combat TRUE, that is impossible. You might have to come up with a creative way of avoiding that.
Last edited by wassup on Wed Oct 08, 2003 1:57 pm, edited 2 times in total.

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

Post by Mckorr » Wed Oct 08, 2003 1:28 pm

Couldn't you just leave it at "sub Main" and do your varsets as

/varset Toggle @Param0
/varset Toggle2 @Param1
MQ2: Think of it as Evolution in action.

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 » Wed Oct 08, 2003 1:40 pm

I didn't think of trying that McKorr, but yes, that works too. I just tried it.

Myself, I would like to read the code and see that Sub Main expects two variables to be passed in, versus haveing to read thru the code and try to figure it out.

Either way works though.

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

Post by Mckorr » Wed Oct 08, 2003 2:11 pm

Ah, I see what you are doing... didn't read closely enough.

I only brought up using @Param because I was rewriting a macro with a variable number of parameters, and delineating them all would have been a pain. For a fixed number of parameters I agree that naming them would make things easier. Even easier:

sub Main(Toggle1,Toggle2)

Eliminate the varsets, and just use @Toggle1 and @Toggle2. Save a few lines.

Also, I think

/if "@Toggle"=="Follow" /echo "Auto following enabled"

should be

/if @Toggle=="Follow" /echo "Auto following enabled"

Don't think you need the quotes anymore for string comparisons.
MQ2: Think of it as Evolution in action.