Page 1 of 3

rogue.mac - AutoRogue v. 2.0l 5-1-2004

Posted: Thu Apr 29, 2004 5:45 pm
by Cunning
AutoRogue v. 2.0l
------------------------------------------------------

This macro plays the rogue for you. Great for two-boxing or carpal tunnel sufferers.

Features:

1. Sneak/Hide on load and between fights.
2. Set an anchor to return to between fights or follow a target (or group member).
3. Waits for mob health percentage to reach a value you specify before attacking.
4. Movement/Auto-attack/evade/backstab/discipline usage handled automatically.
5. Uses GenBot's getbehind code for moving behind a mob.
6. Stops discipline usage and refreshes endurance when you get low.
7. Stops attack on enrage, resuming when enrage is over.
8. Clutch nimble/escape based on your health pct.
9. GM detection for combat/movement loops.

Future Plans:
1. Fix collision detection in getbehind code.
2. Clickable item activation (based on buff timers).
3. Smart tank switching (for when group members change).
4. Request buffs from group members based on class/level/expy (lol, fun stuff).

PM me or reply here if you have any questions/comments/suggestions/bug reports/etc.

custom.inc

Code: Select all

| custom.inc
| Example include file for AutoRogue 2.0l

/declare bDiscActive bool outer       | Flag prevents more than 1 offensive disc per fight
/declare bRegenEnd bool outer         | 1 = On (regen endurance to 100%), 0 = off
/declare bSneakHide bool outer        | Sneak Hide between kills; 1 = Yes, 0 = No 
/declare bUseSpecial bool outer       | Use disciplines, 1 = True, 0 = False
/declare bUseStrike bool outer        | Use strike technique, 1 = True, 0 = False
/declare bUseJump bool outer          | Adds a jump when in collision detection loop.  0 = off
/declare iAttackDiscPct int outer    | Use duelist or deadly disc when Target.PctHps < this, 0 = off
/declare iEscapePct int outer        | Use escape ability when Me.PctHps < this, 0 = off
/declare iEngageDistance int outer   | How close the mob must be to engage
/declare iHealPausePct int outer     | If nimble/escape triggered, wait till Me.PctHps > this, 100+ = off
/declare iHideRefresh int outer      | Based on hastened stealth aa, set between 75-105
/declare iNimblePct int outer        | Use nimble disc when Me.PctHps < this, 0 = off
/declare iRegenEndPct int outer      | Regen endurance to full when it gets low via $), 0 = off
/declare sStrikeDisc string outer       | Name of your best "strike" discipline (e.g. Assassin, Kyv, Ancient)

| <<< Custom Vars:  Modify these according to your taste. >>>

/varset bDiscActive 0
/varset bRegenEnd 0
/varset bSneakHide 1            
/varset bUseSpecial 1
/varset bUseStrike 1
/varset bUseJump 1
/varcalc iAttackDiscPct ${iAssistHealthPct}-10
/varset iEscapePct 20
/varset iEngageDistance 300    
/varset iNimblePct 35
/varset iHealPausePct 70
/varset iHideRefresh 75
/varset iRegenEndPct 20
/varset sStrikeDisc ${String[Assass]}
rogue.mac

Code: Select all

|AutoRogue 2.0l 5-1-2004
|---------------------------------------------------------------------- 
| By Cunning.
| Original AutoRogue by Jay. 
| Credits to GrimJack for the getbehind and moveto logic from GenBot. 
| 
| Usage: /macro rogue.mac Assist HpPct AnchorBit Follow 
| 
| Examples: 
|     Assist tank at 95% 
|       /macro rogue.mac Happytank 95 0    (or leave the zero off) 
| 
|     Assist tank at 95%, set anchor at current loc 
|       /macro rogue.mac Happytank 95 1 
| 
|     Same as above but moveto/follow a target between fights 
|       /macro rogue.mac Happytank 95 2 Stationarycleric 
| 
| DON'T FORGET TO VIEW/MODIFY YOUR CUSTOM.INC FILE!!! 
| 
| Version History
|     2.0l -  Changed Target.MaxRange to Target.MaxRangeTo.
|             Removed some unnecessary delay instances from combat loop.
|             Upped turbo to 40 for shits/giggles.
|             Added a new boolean in custom.inc, bUseStrike.
|			  Fixed a logic bug in CheckDefSpecial (was causing a pause in macro if you got hit).			  
|     2.0k -  MQ2DataVars conversion.
|     2.0j -  Getbehind working...again... 
|     2.0i -  Fixed the weird running in circles on anchor. 
|             Fixed the crazy wobble that getbehind would do in certain instances. 
|             Changed all /face nolook fast calls back to /face fast.  Wasn't a good idea. 
|             Tweaked melee distance on chase. 
|     2.0h -  Bugfixes in GetBehind and the zonechange event. 
|     2.0g -  MQ2Data phase 2 conversion. 
|     2.0f -  Added GM detection (script will pause when gm in zone, resume after) 
|     2.0e -  Chase range improved! 
|     2.0d -  Fixed target moveto on engage.  Set sStrikeDisc to 0 also available as option. 
|     2.0c -  Added delays to address crashing issue. 
|     2.0b -  Bugfixes (hopefully).  The iSetAnchor param is changed too (read above). 
|     2.0a -  Added follow distance and replaced depreciated /sendkey's. 
|     2.0  -  Added rogue offensive and defensive discipline usage option. 
|             Lots of code fixes/optimizations.  Options in custom.inc. 
|     1.9  -  Added move to anchor and move to/follow target 
|             options between fights.  Fixed sneak/hide after fight. 
|             Other minor code cleanup. 
|     1.8  -  Cleaned up some of the code, tossed the xp stuff 
|             and fixed events, evade and getbehind. 
|     1.7  -  Base code (Jay's script) 

#turbo 40

#Event Enraged "has become ENRAGED" 
#Event Offrage "is no longer enraged" 
#Event Slainby "You have been slain by" 
#Event Zonechange "You have entered" 

Sub Main    
    /declare bAttackTarget bool outer 
    /declare bStrikeFlag bool outer 
    /declare AnchorX float outer
    /declare AnchorY float outer
    /declare fXLoc float outer
    /declare fYLoc float outer
    /declare iSetAnchor int outer 
    /declare sFollowTarget string outer 

    /declare iAssistHealthPct int local
    /declare iTargetId int local 
    /declare iTargetIdTmp int local    
    /declare sAssistName string local 
    /declare sTargetName string local 
    
    /varset iTargetIdTmp 0 
    /varset bStrikeFlag 0 
    
    /echo AutoRogue v. 2.0l Started. 

    /if (${Defined[Param0]}) {
    	/varset sAssistName ${Param0}             
    } else { 
        /echo Error:  The name of your assist is not optional. 
        /echo Usage:  /macro rogue.mac AssistName <AssistHpPct> <AnchorFlag> <sFollowTarget> 
    } 
        
    /if (${Defined[Param1]}) { 
        /varset iAssistHealthPct ${Param1}        
    } else /varset iAssistHealthPct 90 
    
    /if (${Defined[Param2]}) { 
    	/varset iSetAnchor ${Param2}              
    	/if (${iSetAnchor}==2) { 
        	/if (${Defined[Param3]}) { 
        		/varset sFollowTarget ${Param3}
        	} else /varset sFollowTarget ${sAssistName} 
      	} 
	} else /varset iSetAnchor 0 
    
    #include custom.inc 

    /echo ${sAssistName} is main assist. 
    /echo Will start combat when MA target is at ${iAssistHealthPct}%. 
    
    /assist off 
    /attack off 
        
    /if (${iSetAnchor}==1) { 
        /varset AnchorX ${Me.X} 
        /varset AnchorY ${Me.Y} 
        /echo Created anchor at Loc: ${AnchorY}, ${AnchorX}. 
    } 
    
    /if (${iSetAnchor}==2) { 
        /target ${sFollowTarget}
        /delay 5
        /if (!${Target.ID}) /varset sFollowTarget ${sAssistName} 
        /echo Created MoveToTarget: ${sFollowTarget}. 
    }      

    /if (${bSneakHide}) /echo SneakHide Enabled. 
        
    /if (${bUseSpecial}) { 
        /call CheckRegenEnd 
        /echo Discipline/Escape Usage Enabled. 
        /echo Your current endurance is ${Me.Endurance}/${Me.MaxEndurance}. 
        /echo Regen endurance percent:  ${iRegenEndPct}. 
    } 
    
    /echo Waiting for ${sAssistName} to select a new target... 
    
:Wait 
    /delay 1    

    /doevents 
    
    /call SneakHide 
    /call CheckRegenEnd 
    /call CheckAnchor 

    /assist ${sAssistName} 
    /delay 4 
    
    /if (!${Target.ID}) /goto :Wait 
    /if (!${Target.Type.Equal["NPC"]}) /goto :Wait 
    /if (${Target.CleanName.Equal[${Me.Name}]}) /goto :Wait 
    
    /if (${iTargetIdTmp}!=${Target.PctHPs}) /echo ${Target.CleanName} targeted at ${Target.PctHPs} %hp, distance ${Target.Distance}. 
    
    /varset iTargetIdTmp ${Target.PctHPs} 

    /if (${Target.PctHPs}<=${iAssistHealthPct} && ${Target.Distance}<${iEngageDistance}) /goto :Attack 

    /goto :Wait 

:Attack 
    /echo Fighting ${Target.CleanName} | ${Target.Level} ${Target.Class.Name}. 
    /varset sTargetName ${Target.CleanName} 
    /varset iTargetId ${Target.ID} 
    /varset bAttackTarget 1
    /varset bStrikeFlag 0
    
    /call CheckGM 
    /call MoveTo 
    /call GetBehind 
    
    /face fast 

:AttackLoop 
    /assist ${sAssistName} 
    
    /doevents 

    /if (!${Target.ID}) /goto :AttackEnd 
    /if (${Target.ID}!=${iTargetId}) /goto :AttackEnd 

    /call GetBehind 
    /call CheckMeleeRange

    /if (${bAttackTarget}) { 
        /if (!${bStrikeFlag}) /call CheckStrikeSpecial 
        /if (${Target.Distance}<${Target.MaxRangeTo} && ${Me.AbilityReady["Backstab"]}) /doability "Backstab" 

        /attack on 
        /if (${Me.Sneaking}) /doability "Sneak" 

        /if (${bStrikeFlag}) /call CheckAtkSpecial 
        
        /if (${Me.AbilityReady["Hide"]}) { 
           /attack off 
           /delay 2 
           /doability "Hide" 
        } 
    } 
    
    /doevents        

    /if (!${bAttackTarget}) /Attack off 
    /if (!${bAttackTarget}) /Attack on 

    /call CheckDefSpecial        

    /goto :AttackLoop 

:AttackEnd 
    /echo Combat with ${sTargetName} has ended. 
    /keypress forward 
    /keypress back 
    /varset iTargetIdTmp 0 
    /varset bDiscActive 0 
    /varset bStrikeFlag 0 

    /varset bAttackTarget 0 
    /attack off 

    /echo Waiting for ${sAssistName} to select a new target. 
    
    /call SneakHide 
    /call CheckRegenEnd 
    /call CheckGM 
    
    /goto :Wait 

/endmacro 

Sub CheckMeleeRange 
	/if (!${Target.ID}) /return

    /face fast 
    
    /if (${Target.Distance}>${Target.MaxRangeTo}*2) /call MoveTo
    /if (${Target.Distance}>${Target.MaxRangeTo}) /keypress forward hold |If target is farther then MaxRange move forward 
    /if (${Target.Distance}<8) /keypress back hold |If target is closer then 8 move back 
    /if (${Target.Distance}<10) /keypress forward  |If target is closer then 10 stop moving forward 
    /if (${Target.Distance}>9) /keypress back |If target is farther then 9 stop moving back 

    /face fast 
/return 

Sub SneakHide 
    /delay 4 
    /if (${bSneakHide}) { 
:WaitForSneak 
        /if (${Me.Sneaking}) { 
            /goto :WaitForHide 
        } else { 
            /doability "Sneak" 
            /delay 4 
            /goto :WaitForSneak 
        } 
        
:WaitForHide 
      /delay 4 
      /if (${Me.AbilityReady["Hide"]}) /doability "Hide" 
    }    
/return 

Sub GetBehind 
    /declare iCount int local
    
    /varset iCount 0 
    /varset fXLoc ${Me.X} 
    /varset fYLoc ${Me.Y} 

    /if (!${Target.ID}) /goto :noneed 
    /if (${Math.Distance[${Math.Calc[${Target.Y}-${Math.Cos[${Target.Heading.DegreesCCW}]}*10]},${Math.Calc[${Target.X}-${Math.Sin[${Target.Heading.DegreesCCW}]}*10]}]}<5) /goto :noneed 
    /if (${Target.Distance}>${Target.MaxRangeTo}*2) /call MoveTo

    /keypress forward hold 

:gobehindloop 
    /delay 1 
    /call CheckGM 
    
    /if (!${Target.ID}) { 
       /keypress forward 
       /goto :noneed 
    } 
    
    /if (${iCount}>1) { 
        /if (${fXLoc}==${Me.X} && ${fYLoc}==${Me.Y}) { 
              /keypress forward 
              /goto :noneed 
        } 

        /varset fXLoc ${Me.X} 
        /varset fYLoc ${Me.Y} 
        /varset iCount 0 
    } 
    
    /varcalc iCount ${iCount}+1 
    /doevents 

    /face nolook fast loc ${Math.Calc[${Target.Y}-${Math.Cos[${Target.Heading.DegreesCCW}]}*10]},${Math.Calc[${Target.X}-${Math.Sin[${Target.Heading.DegreesCCW}]}*10]} 
    /if (${Math.Distance[${Math.Calc[${Target.Y}-${Math.Cos[${Target.Heading.DegreesCCW}]}*10]},${Math.Calc[${Target.X}-${Math.Sin[${Target.Heading.DegreesCCW}]}*10]}]}>3) /goto :gobehindloop 

    /keypress forward 
    /face fast 

:noneed 

/return 

Sub CheckDefSpecial 
   /if (${bUseSpecial}) { 
       /if (${Me.PctHPs}<${iNimblePct}) { 
           /if (${Me.PctHPs}<${iEscapePct}) { 
              /echo Escaping. 
              /attack off 
              /varset bAttackTarget 0 
              /delay 2 
              /alt activate 102 | escape aa 
              /call SneakHide 
              /goto :EscapedWaitHeal 
           } else { 
            /echo Nimble. 
               /delay 2 
               /disc nimble 
               /attack off 
               /varset bAttackTarget 0 
               /delay 5 
               /doability "Hide" 
               /goto :NimbleWaitHeal 
           } 
      } 
   } 
   
   /goto :HpOk
   
:EscapedWaitHeal 
    /if (${Me.PctHPs}>${iHealPausePct}) { 
        /varset bAttackTarget 1 
        /return 
    } 
    /delay 10 
    /goto :EscapedWaitHeal 

:NimbleWaitHeal    
    /if (${Me.PctHPs}>${iHealPausePct}) { 
         /varset bAttackTarget 1 
         /return 
    } 

    /delay hiderefresh 
    /doability "Hide"          
    /goto :NimbleWaitHeal 

:HpOk

/return 

Sub CheckAtkSpecial 
   /call CheckRegenEnd 

   /if (${bUseSpecial} && !${bDiscActive} && !${bRegenEnd} && ${Target.PctHPs}<${iAttackDiscPct}) { 
       /disc duelist 
       /delay 4 
       /disc deadly 
       /varset bDiscActive 1 
   } 
/return 

Sub CheckStrikeSpecial 
	/call CheckRegenEnd 
    
	/if (${bUseStrike} && !${bRegenEnd}) { 
		/varset bStrikeFlag 1 
		/call CheckMeleeRange
		/disc ${sStrikeDisc} 

:WaitForBackstabRange 
		/if (${Target.Distance}<${Target.MaxRangeTo}) { 
			/doability "Backstab" 
		} else {
			/call CheckMeleeRange
			/goto :WaitForBackstabRange 
		} 
    } 
/return 
        
Sub CheckRegenEnd 
   /if (!${bRegenEnd} && ${Me.PctEndurance}<${iRegenEndPct}) { 
      /varset bRegenEnd 1 
      /echo Regen endurance to full. 
   } 
    
   /if (${bRegenEnd}) { 
       /if (${Me.Endurance}==${Me.MaxEndurance}) { 
           /varset bRegenEnd 0 
           /echo Endurance regenerated. 
      } 
   } 
    
/return    

Sub CheckAnchor 
   /call CheckGM 
    
    /if (${iSetAnchor}==1) /if (${Math.Distance[${AnchorY},${AnchorX}]}>12) /call MoveToAnchor 
    
    /if (${iSetAnchor}==2) { 
        /target ${sFollowTarget} 
        /delay 4 
        /if (${Target.Distance}>${Target.MaxRangeTo} && ${Target.ID} && ${Target.CleanName.NotEqual[${Me.CleanName}]}) /call MoveTo 
    }      
/return 

Sub CheckGM 
   /if (${Spawn[gm].ID}) { 
		/echo Waiting on GM to leave zone. 
		/keypress forward
		/keypress esc
		/attack off
	    /delay 4
	    /call SneakHide
:gmcheck
		/if (${Spawn[gm].ID}) { 
        	/delay 10 
      		/goto :gmcheck
      	} else /return
   } 
/return 

Sub MoveTo
    /declare iCount int local
    
    /varset iCount 0 
    /varset fXLoc ${Me.X} 
    /varset fYLoc ${Me.Y} 

    /if (!${Target.ID}) {
       /keypress forward 
       /return 
    } 
    
    /if (${Target.Distance}<${Target.MaxRangeTo}) {
    	/keypress forward
    	/return
    }
    
    /echo Moving to Target: ${Target.CleanName}. 

:fastmoveloop 
   /delay 1 
   /doevents 
    
    /if (!${Target.ID}) { 
        /keypress forward 
        /return 
    } 
    
    /face fast 

    /if (${Target.Distance}>${Target.MaxRangeTo}) /keypress forward hold 

    /if (${Target.Distance}<${Target.MaxRangeTo}) {
        /keypress forward 
        /return 
    } 
    
    /if (${iCount}>2) { 
        /call Detectobst 
        /face fast 
        /varset iCount 0 
    } 
    
    /if (${Target.Distance}>${Math.Calc[${Target.MaxRangeTo}*2]}) /varcalc iCount ${iCount}+1 
    /goto :fastmoveloop 
/return 


Sub MoveToAnchor 
    /declare iCount int local

    /varset fXLoc ${Me.X} 
    /varset fYLoc ${Me.Y} 
    /varset iCount 0 

    /echo Moving to Anchor at Loc: ${AnchorY}, ${AnchorX}. 

:AnchorMoveLoop  
    /delay 1 
    /doevents 
    /face nolook loc ${AnchorY},${AnchorX} 
    
    /if (${Math.Distance[${AnchorY},${AnchorX}]}>12) { 
       /keypress forward hold 
   } else { 
       /keypress forward 
        /return 
    } 

    /if (${iCount}>2) { 
        /call Detectobst 
        /face nolook loc ${AnchorY},${AnchorX} 
        /varset iCount 0 
    } 
    
    /varcalc iCount ${iCount}+1 
    /goto :AnchorMoveLoop 
/return 

Sub Detectobst 
    /delay 2 
    /if (${fXLoc}==${Me.X}) /if (${fYLoc}==${Me.Y}) /call Hitobst 
    /varset fXLoc ${Me.X} 
    /varset fYLoc ${Me.Y} 
/return 

Sub Hitobst 
    /keypress forward 
    /keypress back hold 
    
    /if (${Math.Rand[2]}) {    
        /delay 2s    
        /keypress back 
        /keypress right hold 
        /delay 8 
        /keypress right 
        
        /if (${bUseJump}) { 
           /keypress forward hold 
           /delay 8 
           /keypress jump 
        } 
    } else { 
        /delay 2s 
        /keypress back 
        /keypress left hold 
        /delay 8 
        /keypress left 
        
        /if (${bUseJump}) { 
           /keypress forward hold 
           /delay 8 
           /keypress jump 
        } 
    } 
    /delay 10 
    /keypress forward hold 
/return

| ----- Events called by /DoEvents ----- 

Sub Event_Enraged 
    /varset bAttackTarget 0 
    /attack off 
/return 

Sub Event_Offrage 
    /varset bAttackTarget 1 
    /attack on 
/return 

Sub Event_Zonechange 
   /keypress up 
   /endmacro 
/return 

Sub Event_Slainby 
    /keypress up 
    /endmacro 
/return 

Posted: Thu Apr 29, 2004 9:34 pm
by ucfusion
using your k version macro plus latest version of MQ 2 and its not workign ... specifically... its not attacking the target when it goes below a certain health... the old one would switch between the auto follow target and the MA this one just stays on the autofollow ... any ideas ?

found the erro

Posted: Fri Apr 30, 2004 12:17 am
by Wendel
Missing a $ and some curly brackets

Code: Select all

/call SneakHide
/call CheckRegenEnd
/call CheckAnchor

/assist sAssistName
/delay 4 
to

Code: Select all

/assist ${sAssistName}


small changes

Posted: Fri Apr 30, 2004 12:28 am
by Kracken
Id remove this post, if i knew how. :)

Posted: Fri Apr 30, 2004 10:29 am
by crisdan
I would like to adjust this for my warrior like i did on an older version of this script; could someone give me a simple example like adding taunt to this ?

I will then use that example for the rest of the warrior tweaks i would like to do.

Thanks for any help.

Posted: Fri Apr 30, 2004 11:58 am
by Cunning
I figured I had missed some of the variable changes. Thanks for finding those guys. I made the corrections and updated the code (no version change since it was just me not being through).

Posted: Fri Apr 30, 2004 12:09 pm
by Wendel
actually thank you for maintaining this wonderful macro!

add raid support - tank switching

Posted: Fri Apr 30, 2004 5:47 pm
by nerclid
could easily add in raid mode support.. by a simple param check at the start, passing the raid param. this kinda goes along with your smart tank switch idea. pass in a list of tanks into an array when the macro starts, and cycle through the array when an assist call is needed, checking the tank's id. if its true, assist that tank.

Posted: Sat May 01, 2004 1:51 am
by illus1on
Macro after a few fights doesn't return to Anchor, or just stands there and never hide/sneaks after a fight.

Often have to /end and /macro rogue.mac Tank 95 1.

EQ lag? MQ lag? Or is this something that it's doing/not doing correctly?

Posted: Sat May 01, 2004 3:47 am
by Cunning
Thanks illus1on. I believe I've found the problem and fixed it. 2.0l is out.

Posted: Sat May 01, 2004 8:41 pm
by Omiime
I changed

/if (${Target.Distance}<${Target.MaxRangeTo} && ${Me.AbilityReady["Backstab"]}) /doability "Backstab"

/attack on
/if (${Me.Sneaking}) /doability "Sneak"

/if (${bStrikeFlag}) /call CheckAtkSpecial

/if (${Me.AbilityReady["Hide"]}) {
/attack off
/delay 2
/doability "Hide"
}
}
To

/if (${Target.Distance}<${Target.MaxRangeTo} ) {

/attack on
/if (${Me.Sneaking}) /doability "Sneak"

}
}


He runs up to target. melee's , if target moves out of range, he does move up to it. just stands there. Can see why? Changed the same line in other version, didn't affect anything

Posted: Sun May 02, 2004 12:41 am
by Cunning
I forgot to add the /call CheckMeleeRange after the /call GetBehind in the attack loop. I corrected the code.

Posted: Sun May 02, 2004 12:46 am
by Omiime
ah :)

after posting that, I played around and put /call CheckMeleeRange
in , but difference place. I will copy it to same place.

I stole your code for bard :)

I'm using both for bard/rogue. Very nice :)

Posted: Sun May 02, 2004 1:23 am
by Cunning
Good for you. Long live open source!

Posted: Sun May 02, 2004 12:42 pm
by stm69
Cunning,

Thanks for all your work. Does this mac still make the rogue run into walls when a mob is walled? I remember reading back a few revisions ago that it was fixed; but that version never worked for me.

Thanks!