Run to nearest PoK Portal

Post your completed (working) macros here. Only for macros using MQ2Data syntax!

Moderator: MacroQuest Developers

bertbert
orc pawn
orc pawn
Posts: 19
Joined: Thu May 26, 2005 5:56 pm

Run to nearest PoK Portal

Post by bertbert » Sun Apr 30, 2006 7:48 am

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 
Last edited by bertbert on Sun Apr 30, 2006 2:14 pm, edited 2 times in total.

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 » Sun Apr 30, 2006 10:10 am

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
}

bertbert
orc pawn
orc pawn
Posts: 19
Joined: Thu May 26, 2005 5:56 pm

Post by bertbert » Sun Apr 30, 2006 10:32 am

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