ModMove.inc BETA revB - Record Playback with MQ2MoveUtils

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

toomanynames
a grimling bloodguard
a grimling bloodguard
Posts: 1844
Joined: Mon Apr 11, 2005 11:10 am

ModMove.inc BETA revB - Record Playback with MQ2MoveUtils

Post by toomanynames » Thu May 25, 2006 9:00 am

At this time it requires mq2moveutils however it can be adapted to using whatever "moveto" code you use.
Syntax of Use & Example .mac code:

Code: Select all

MBWayPnt must be declared and defined as an INI type <filename.ini> (e.g. MBWayPnt.INI)

Sub MBRecordWay <section heading> (e.g. PoKtoGH)
<section heading> - Name of INI section
Notes: Duck to create a waypoint, sit to exit the loop

Sub MBMoveWay <section heading> <direction> <WIP Zone> (e.g. PoKtoGH b f)
<section heading> - Name of INI section
<direction>:
D = Enter at closest loc and move towards the end
U = Enter at closest loc and move towards the begining
B = Enter at the begining loc and move towards the end
E = Enter at the end loc and move towards the begining
<WIP Zone> - Will be t for true f for false but it is not in yet
Notes: Plays back a previously recorded path
Sample Macro

Code: Select all

Sub Main
 /declare MBWayPnt string outer MBWayPnt.INI
 /call MBRecordWay PoKGH
 /call MBMoveWay PoKGH d F
/return

[color=red]It can NOT take longer then 2mins to get between two waypoints or the move to code will EJECT.[/color]
Once entering the MBRecordWay sub, you can only exit by sitting or /endmacro. At every point you "duck", you create a waypoint and this waypoint loc will be /echo'd to the MQ2 window. You do NOT need to "unduck".
Example: press "duck", move to your next spot, press "duck", move to your next spot, press "duck", etc etc. when done, sit down, and the path is complete.
Typical Use: Create waypoints across a zone (say PoK), have your last waypoint in front of the Guild Halls (lets say). It could even be used to create pathing from any point in PoK to jump on a "rail" and move to the guild hall.

Code: Select all

|MoveMove.inc BETA revB
Sub MBMoveTo(MBy,MBx)
  /declare tDistThen float local ${Math.Distance[${Me.Y},${Me.X}:${MBy},${MBx}]} 
  /declare tMoveCheck timer local 15
  /declare tMoveTimer timer local 2m
  /declare tMB bool local FALSE
| Testing this still to round off corners
|  /keypress forward hold
|  /squelch /face loc ${MBy} ${MBx}
|  /delay 1s
|  /keypress forward
  /squelch /moveto loc ${MBy} ${MBx}
  /delay 1s
  /declare tDistNow float local ${Math.Distance[${Me.Y},${Me.X}:${MBy},${MBx}]} 
:tMoveTop
  /if (!${tMoveCheck}) {
    /varset tDistNow ${Math.Distance[${Me.Y},${Me.X}:${MBy},${MBx}]};
    /if (${tDistThen}-${tDistNow}<2) {
      /keypress forward
      /keypress back hold 
      /delay 5 
      /keypress back 
      /if (${Math.Rand[99]}>50) { 
        /keypress strafe_right hold 
       } else { 
        /keypress strafe_left hold 
      } 
      /delay 1s 
      /keypress strafe_right 
      /keypress strafe_left 
    }
    /squelch /moveto loc ${MBy} ${MBx}
    /delay 1s
    /varset tMoveCheck 15 
    /varset tDistThen ${Math.Distance[${Me.Y},${Me.X}:${MBy},${MBx}]}    
  }
  /if (${Select[${MoveTo},off]}) {
    /if (${Math.Distance[${Me.Y},${Me.X}:${MBy},${MBx}]}<10) /varset tMB TRUE
    /goto :tEnd
  }
  /if (${tMoveTimer}) /goto :tMoveTop
:tEnd
/return ${tMB}

Sub MBRecordWay(MBRName)
  /declare tMBIniFile string local ${MBWayPnt}  
  /declare WPCount int local 0
 :tMBRTop
  /if (${Me.State.Equal[duck]}) {
    /varcalc WPCount ${WPCount}+1
    /ini "${MBWayPnt}" "${MBRName}" "WPCount" "${WPCount}"
    /ini "${MBWayPnt}" "${MBRName}" "WP${WPCount}" "${Me.Y} ${Me.X}" 
    /echo WayPoint[${WPCount}] ${Me.Y} ${Me.X}
    /keypress duck
  } 
  /if (${Me.State.Equal[sit]}) {
    /return
  }
  /goto :tMBRTop
/return

Sub MBMoveWay(Section,DirectionUD,ZoneTF)
  /declare tMBIniFile string local ${MBWayPnt}
  /declare WPCount ${Ini[${MBWayPnt},${Section},WPCount]}
  /declare WP[${WPCount}] string local
  /declare a int local
  /declare x int local
  /declare y int local
  /declare Sx int local
  /declare Sy int local
  /declare WPStart int local
  /for a 1 to ${WPCount}
    /varset WP[${a}] ${Ini[${MBWayPnt},${Section},WP${a}]}
    /varset y ${WP[${a}].Arg[1]};/varset x ${WP[${a}].Arg[2]}
    /if (${Math.Distance[${Me.Y},${Me.X}:${y},${x}]}<${Math.Distance[${Me.Y},${Me.X}:${Sy},${Sx}]}) /multiline ; /varset Sy ${y};/varset Sx ${x};/varset WPStart ${a}
  /next a
  /if (${DirectionUD.Equal[u]}) {
    /for a ${WPStart} downto 1
      /call MBMoveTo ${WP[${a}].Arg[1]} ${WP[${a}].Arg[2]}
      /if (!${Macro.Return}) /goto :tMWAbort
    /next a
  } 
  /if (${DirectionUD.Equal[d]}) {
    /for a ${WPStart} to ${WPCount}
      /call MBMoveTo ${WP[${a}].Arg[1]} ${WP[${a}].Arg[2]}
      /if (!${Macro.Return}) /goto :tMWAbort
    /next a
  }
  /if (${DirectionUD.Equal[b]}) {
    /for a 1 to ${WPCount}
      /call MBMoveTo ${WP[${a}].Arg[1]} ${WP[${a}].Arg[2]}
      /if (!${Macro.Return}) /goto :tMWAbort
    /next a
  } 
  /if (${DirectionUD.Equal[e]}) {
    /for a ${WPCount} downto 1
      /call MBMoveTo ${WP[${a}].Arg[1]} ${WP[${a}].Arg[2]}
      /if (!${Macro.Return}) /goto :tMWAbort
    /next a
  }
  /return
 :tMWAbort
  /echo Problem aborting
/return

toomanynames
a grimling bloodguard
a grimling bloodguard
Posts: 1844
Joined: Mon Apr 11, 2005 11:10 am

Post by toomanynames » Wed Jun 07, 2006 11:31 am

Wanted to add the VIP version allows chaining of paths from zone to zone, porting via magus, PoK stones, clicky portals, etc. Plan to add door opening and such in the next VIP release.