Page 1 of 1

Run to nearest PoK Portal

Posted: Sun Apr 30, 2006 7:48 am
by bertbert
This is a small macro, largely based on Hunter.mac, which I use to run my toon to the nearest PoK book and zone. Very lazy, I know, but I find it useful.

I'd advise against using it anywhere with uncertain terrain, e.g. lava, large drops etc. It uses the Hunter avoid obstacle routine to get around rocks, trees etc.

You may want to remove the GM check at the start if you don't care about a GM seeing you running this.

Hope someone likes it.

Code: Select all

| RunToPoK Macro 
| RunToPoK.mac 
| Author      : bertbert 
| Version     : v1.0 2006-30-04
| Useage      : /macro RunToPoK 
| Description : Makes your toon run to the nearest PoK portal (if there
|               is one in the zone) and go through it.
| Credits     : robdawg for the Hunter mac this is based on
|------------------------------------------------------------------------------------ 

#turbo 10 

Sub Main 

   /declare RV_Range            int outer 10 
   /declare RV_FastRange        int outer 
   /declare RV_RangeMax         int outer 
   /declare RV_RangeMin         int outer 
   /varcalc RV_FastRange        ${RV_Range}+3 
   /varcalc RV_RangeMax         ${RV_Range}+2 
   /varcalc RV_RangeMin         ${RV_Range}-4 

   :Start 
   /call GMCheck
   /squelch /DoorTarget POK
   /if (${DoorTarget.Name.Find[POK]}) {
      /call MoveToPortal
   } else {
      /echo No Portal found.
   }
    
/return 

|-------------------------------------------------------------------------------- 
|SUB: Moving 
|-------------------------------------------------------------------------------- 
Sub MoveToPortal 

   /declare RV_MyXLOC           int outer  0 
   /declare RV_MyYLOC           int outer  0 
   /declare RV_DistanceTimer timer 15 

   /varset RV_MyXLOC ${Int[${Me.X}]} 
   /varset RV_MyYLOC ${Int[${Me.Y}]} 
    
   /doevents 
    
   :MovementLoop 

   /squelch /face door 
    
   /if (${Int[${DoorTarget.Distance}]}>${RV_FastRange}) { 
      /keypress forward hold 
   } 
   /if (${Int[${DoorTarget.Distance}]}<${RV_FastRange}&&${Int[${DoorTarget.Distance}]}>${RV_RangeMax}) { 
      /keypress forward 
   } 
   /if (${Int[${DoorTarget.Distance}]}<${RV_RangeMin}) { 
      /keypress back 
   } 
   /if (!${RV_DistanceTimer}) { 
      /if ((${RV_MyXLOC}==${Int[${Me.X}]})&&(${RV_MyYLOC}==${Int[${Me.Y}]})) /call HitObstacle 
      /varset RV_MyXLOC ${Int[${Me.X}]} 
      /varset RV_MyYLOC ${Int[${Me.Y}]} 
      /varset RV_DistanceTimer 15 
      /goto :Movementloop 
   } 
   /if (${Int[${DoorTarget.Distance}]}>${RV_Range}) /goto :MovementLoop
   
   /squelch /doortarget 
   /squelch /face fast nolook door 
   /keypress USE hold 
   /keypress USE 
   /delay 1 
   /keypress USE hold 
   /keypress USE 

/return 

|-------------------------------------------------------------------------------- 
|SUB: Obstacle Avoidance 
|-------------------------------------------------------------------------------- 
Sub HitObstacle 
   /echo Obstacle hit, moving around it... 
   /keypress forward 
   /keypress back hold 
   /delay ${Math.Calc[${Math.Rand[5]}+5]} 
   /keypress back 
   /if (${Math.Rand[2]}) { 
     /keypress strafe_right hold 
   } else { 
     /keypress strafe_left hold 
   } 
   /delay ${Math.Calc[${Math.Rand[15]}+5]} 
   /keypress strafe_right 
   /keypress strafe_left 
/return 

|-------------------------------------------------------------------------------- 
|SUB: GM Check 
|-------------------------------------------------------------------------------- 
Sub GMCheck 

   /if (${Spawn[gm].ID}) { 
      /beep 
      /beep 
      /beep 
      
      /echo GM is in the zone! 
      /echo Ending the macro... 

      /keypress forward 
      /keypress back 

      /endmacro 
   } 
    
/return 

Posted: Sun Apr 30, 2006 10:10 am
by wassup
Huh???

Code: Select all

/if (${DoorTarget.Name.Equal[${DoorTarget.Name}]}==NULL) {

Why not use this instead:

Code: Select all

/if (!${DoorTarget.Name.Find[POK]}) {
   /echo No PoK portal found.
} else {
   /call MoveToPortal
}

Posted: Sun Apr 30, 2006 10:32 am
by bertbert
The only reason is that is was about 4am when I knocked this up and my brain wasn't working. If you don't have a door selected the DoorTarget.Name returns "" rather than NULL, which I couldn't work out how to test for. Doh!

Anyway, updated now. :D