problem with events in my little rangerbuddy.mac

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

Zazoot
a hill giant
a hill giant
Posts: 163
Joined: Sat Feb 07, 2004 11:02 am

problem with events in my little rangerbuddy.mac

Post by Zazoot » Mon Mar 22, 2004 10:39 pm

I got a few questions about this macro i created from scratch

rangerbuddy.mac

Code: Select all

#turbo 50 
#event toofar "Your target is too far away, get closer!" 
#event cantsee "You cannot see your target." 
#event realfar "Your target is out of range, get closer!"

sub main 
:loop1 
/if n $char(buff,"Protection of the Wild")==0 { 
  /cast "Protection of the Wild" 
  /delay 5.5s 
} 
/if n $char(buff,"Bladecoat")==0 { 
  /cast "Bladecoat" 
  /delay 3.5s 
} 
/if n $char(buff,"Natureskin")==0 { 
  /keypress TARGETME 
  /cast "Natureskin" 
  /delay 5.7s 
} 
/if n $char(buff,"Regrowth")==0 { 
  /keypress TARGETME 
  /cast "Regrowth" 
  /delay 5.7s 
} 
/if n $char(buff,"Mask of the Stalker")==0 { 
  /keypress TARGETME 
  /cast "Mask of the Stalker" 
  /delay 3.6s 
} 
/if n $char(buff,"Cry of Thunder")==0 { 
  /keypress TARGETME 
  /cast "Cry of Thunder" 
  /delay 4s 
} 
/if n $char(hp,pct)<30 { 
  /call maintainhp 
} 
/if n $char(mana,pct)<30 { 
  /call maintainmana 
}
/tar nameofstationaryafkchar
/sit on
/sit off
  :folloop1 
      /if n $target(distance)>20 /sendkey down up
      /if n $target(distance)<15 /sendkey up up
     /face fast 
     /delay 0 
  /if n $target(distance)>20 /goto :folloop1 
/call killthemob 
/delay 1s 
/goto :loop1 
/return 

sub maintainhp 
/keypress TARGETME 
:loop2 
/cast "Sylvan Light" 
/delay 3.6s 
/if n $char(hp,pct)>70 /goto :donehealing
/if n $char(mana,pct)>25 /goto :loop2 
:donehealing
/return 

sub maintainmana 
/sit on 
/delay 3m 
/return 

sub killthemob 
/if $combat==FALSE /target npc range 0 200 
/keypress HOTPAGE1 
/keypress HOT6 
/attack on 
:loop3 
/if n $spawn(hp,pct)>88 /keypress HOT6
/doability taunt 
/doability kick
/cast "Sylvan Burn"
/if n $char(hp,pct)<50 { 
   /call maintainhp 
   /target npc range 0 200 
  } 
/delay 1s 
/doevents 
/if $combat==TRUE /goto :loop3 
/return 

[color=red]sub gotomob
   :killitnow
      /if n $target(distance)>30 /sendkey down up
      /if n $target(distance)<25 /sendkey up up
      /face fast
      /delay 0
      /if n $target(distance)>30 /goto :killitnow
/return

sub Event_toofar
      /face fast
      /if (n $spawn(speed)>0 && n $spawn(hp,pct)<25)  /keypress HOT6
      /if n $spawn(hp,pct)>25 /call gotomob
/return[/color]


sub Event_cantsee
/face fast
/return

sub Event_realfar
/face fast
/press up
/return


ok basically what this macro does is

*keeps buffs up
*targets and runs back to stationary char
*targets and pulls mob to camp
*follows mob around if it moves / push / not snared
*heals self as needed
*meds as needed

the problem im having is with the stuff i put in red
what its doing is spamming me with running around and trying to cast HOT6 (entrap)

is there a way i can make it stop everything and just do one action and follow the /if logic i put in there?
or can i use some sort of $spawn(#.maxrange) stuff in the follow code to keep him within the proper range?

if any of this is rtfm let me know and ill get back to digging through the search, spent all day on it and finally decided to ask for help

hmm should i look at stick.mac really hard or tuna's beastlord mac? hehe those kinda long but i will read em / learn while i wait for comments :D

thanks in advance for anything you can add

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

Post by Falco72 » Tue Mar 23, 2004 2:30 am

For the first I use this piece of code. The syntax is /call GotoBody (mob id as from $target(id)) (distance you want to have your bot from target for example 25) i.e. /call GotoBody $target(id) 25

Code: Select all

Sub GotoBody(BodyID,DistToBody)
   /if $char(state)==SIT /stand
   /if $target(id)!=@BodyID {
      /keypress clear_target
      /delay 3
      /target id @BodyID
      /delay 3
   }
   
   :KeepGoingBody
   /doevents
   /delay 0
   /if n $target(distance)>=@DistToBody{
      /face nolook fast
      /keypress forward hold
   }
   /if n $target(distance)<@DistToBody {
      /keypress forward
      /return
   }
   /call CheckObstacle
   /goto :KeepGoingBody
/return
and then the code of CheckObstacle:

Code: Select all

sub CheckObstacle
   |# Record our current position, wait a moment and then check if its the same
   /declare MyXLOC local
   /declare MyYLOC local
   /varset MyXLOC $char(x)
   /varset MyYLOC $char(y)
   /delay 2
   /if n @MyXLOC==$char(x) /if n @MyYLOC==$char(y) /call Obstacle
/return

|# Uses strafe and randomness to try and get around things
sub Obstacle
   /keypress forward
   /keypress back hold
   /delay 5
   /keypress back
   /if n $rand(99)>50 {
      /keypress strafe_right hold
      /delay 3
      /keypress strafe_right
   } else {
      /keypress strafe_left hold
      /delay 3
      /keypress strafe_left
   }
   /keypress forward
Credits go to author(s) not to me, I just mede some minor adjustments.

For the second, I think you should use a switch, I mean:
First /declare myswitch global in the main sub then

Code: Select all

sub Event_toofar
   /face fast
   /if (n $spawn(speed)>0 && n $spawn(hp,pct)<25)  {
      [color=red]/if n @myswitch!=1 {
         /keypress HOT6
         /varset myswitch 1
      }[/color]
   }
   /if n $spawn(hp,pct)>25 /call gotomob
/return
Finally remember to put myswitch to 0 when you have killed the mob.

Zazoot
a hill giant
a hill giant
Posts: 163
Joined: Sat Feb 07, 2004 11:02 am

Post by Zazoot » Tue Mar 23, 2004 6:20 pm

im going to try that

thanks for the tip

i think that will help me get around the whole event stacking stuff that keeps happening.