the refined autorogue!

Got a cool macro idea? Wanna request a macro? Here is the place for you!

Moderator: MacroQuest Developers

ucfusion
orc pawn
orc pawn
Posts: 24
Joined: Mon Mar 15, 2004 2:14 am

the refined autorogue!

Post by ucfusion » Tue Apr 06, 2004 10:43 am

Ok this is the script im using...
| Modified rogue.mac
| Credits to Jay (rogue.mac) and Lasher et. al. (genbot.mac)
|
| Cleaned up some of the code, tossed the xp stuff and fixed events,
| evade and getbehind.
|
| Usage: /macro rogue.mac <Assist> <AssistHealth>


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

#include routines.mac
#turbo @turboamount

Sub main

/Declare assisthealth global
/Declare turboamount global
/Declare sneakhide global
/Declare engagedistance global
/Declare countdown global
/Declare MyXLoc global
/Declare MyYLoc global
/Declare targetname global
/Declare targetid global
/Declare tankname global
/Declare attacktarget global
/Declare tempvar global
/Declare behindtarget global | 1 = True, 0 = False
/Declare targetenrage global | 1 = True, 0 = False
/Declare mobdetail array2 | Mob details array

/Varset assisthealth @Param1 | Wait until mob is below this health trigger.
/Varset turboamount 380 | Turbo Amount, Change at your own risk, was 380.
/Varset sneakhide 1 | Sneak Hide between kills; 1 = Yes, 0 = No
/Varset engagedistance 400 | How close mob must be to engage
/varset tankname @Param0
/varset tempvar 0

/echo "Auto Rogue Version 1.07 Starting"
/echo "@tankname is assist tank."

/if n @sneakhide==1 {
/doability "Sneak"
/delay 5
/doability "Hide"
}

:Wait
/assist @tankname
/delay 10

/if "$target()"=="FALSE" {
/target @tankname
/face
/goto :Wait
}

/if "$target(type)"!="NPC" {
/face
/goto :Wait
}

/if n @tempvar!="$target(hp,pct)" {
/echo $target(name,clean) targeted at $target(hp,pct)% at distance $target(distance).
}

/varset tempvar "$target(hp,pct)"
/face

/if n "$target(hp,pct)"<=@assisthealth {
/if n "$target(distance,noprodict)<@engagedistance" {
/if n "$target(pet)==0" /goto :Attack
}
}

/Attack off
/DoEvents
/goto :Wait

:Attack
/doability "Sneak"
/echo Fighting $target(name,clean). It is a level $target(level) $target(race).
/varset mobdetail(8,0) "$target(name,clean)"
/varset mobdetail(1,1) $target(level)
/varset mobdetail(1,2) $target(name)
/varset mobdetail(1,3) $target(id)
/varset targetname $target(name)
/varset targetid $target(id)
/varset attacktarget 1
/varset behindtarget 0
/varset targetenrage 0
/face
/sendkey down up

/if n @attacktarget==1 /attack on

:AttackLoop
/assist @tankname
/if "$target()"=="FALSE" /goto :AttackEnd
/if "$target(id)"!="@targetid" /goto :AttackEnd

/doevents

/call GetBehind

/if n @attacktarget==1 {
/attack on

/if n $target(distance)<$target(maxrange) {
/doability backstab
/attack off
/doability hide
/attack on
}
}

/if n @attacktarget==0 /Attack off

/face fast
/if n $target(distance)>25 /sendkey down up |If target is farther then 18 move forward
/if n $target(distance)<8 /sendkey down down |If target is closer then 8 move back
/if n $target(distance)<20 /sendkey up up |If target is closer then 10 stop moving forward
/if n $target(distance)>18 /sendkey up down |If target is farther then 9 stop moving back
/face fast

/doevents

/goto :AttackLoop

:AttackEnd
/echo "@targetname has died"
/sendkey up up
/sendkey up down
/sendkey up ctrl
/varset attacktarget 0
/varset tempvar 0
/attack off
/echo "Waiting for @tankname to select a new target..."

/if n @sneakhide==1 {
/doability "Sneak"
/delay 5
/doability "Hide"
}

/goto :Wait

/return

Sub GetBehind
/varset countdown 0
/varset MyXLoc $char(x)
/varset MyYLoc $char(y)

/if n $distance($calc($target(y)-$cos($target(heading))*10),$calc($target(x)-$sin($target(heading))*10))<3 {
/goto :noneed
}

/if $target()==FALSE /return

/sendkey down up

:gobehindloop

/if $target()==FALSE {
/sendkey up up
/return
}

/if n @countdown>=20 {
/if n @MyXLoc==$char(x) {
/if @MyYLoc==$char(y) {
/sendkey up up
/return
}
}

/varset MyXLoc $char(x)
/varset MyYLoc $char(y)
/varset countdown 0
}

/varadd countdown 1
/doevents

/if "$char(state)"=="SIT" /stand
/face nolook fast loc $calc($target(y)-$cos($target(heading))*10),$calc($target(x)-$sin($target(heading))*10)
/if n $distance($calc($target(y)-$cos($target(heading))*10),$calc($target(x)-$sin($target(heading))*10))>1 /goto :gobehindloop

/sendkey up up
/if "$char(state)"=="SIT" /stand
/face fast

:noneed

/return

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

Sub Event_Enraged
/varset attacktarget 0
/attack off
/return

Sub Event_Offrage
/varset attacktarget 1
/attack on
/return

Sub Event_Slainby
/endmacro
/return
Heres what im wondering ... basically ever time the mob moves the rogue adjusts to get directly behind the mob. Its well known that rogues can make a backstab from *almost* the entire 180 degrees behind the mob.

Is there anyway to program any forgiveness into the code making it more reliable and more realistic. For example... Your start the macro and it postions you directly behind the mob. THe mob is rotated a few degrees clockwise or counter clockwise... because hte back of the mob is still available the macro does not make any adjustments.

The other example is when the tank pushes the back of the mob into a wall ... your rogue will start running into the wall... is there anyway to make a collision check that halts the rogue faces the mob and settles for the best available position... combined with the forgiveness above you would probably be making the backstabs still...

Well thats my request... Im still new so I have very little knowledge on this subject would appreciate comments in any code that is added because i have been sitting here trying to make sense of the move behind part of the code and im lost... Well I hope someone can help here I like the script I just want it to make it betta!

Goofmester1
a hill giant
a hill giant
Posts: 241
Joined: Thu Nov 06, 2003 4:26 am

Post by Goofmester1 » Wed Apr 07, 2004 1:05 am

The first part is yes you can design some broader range into the stay behind.

Look here at the calc. This is what adjust position. I would probly adjust the number highlighted in Orange.

Code: Select all

Sub GetBehind 
/varset countdown 0 
/varset MyXLoc $char(x) 
/varset MyYLoc $char(y) 

/if n $distance($calc($target(y)-$cos($target(heading))*10),$calc($target(x)-$sin($target(heading))*10))<[color=orange]3 [/color]{ 
/goto :noneed 
} 

/if $target()==FALSE /return 

/sendkey down up 

:gobehindloop 

/if $target()==FALSE { 
/sendkey up up 
/return 
} 

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Rotation.

Post by grimjack » Thu Apr 08, 2004 4:32 am

This was the exact reason I ended up switching the auto behind code in genbot to use strafe. You should be able to re-use the subs from genbot with a little tweaking.

The main subs you would need to look at are:

Sub Rangesub - Keeps you in range of the mob.
Sub Fastmove - Called by Rangesub.
Sub Fastback - Called by Rangesub.

Sub Detectobst - Nearly all the movement code ends up calling this at some point.
Sub Hitobst - Called by Detectobst

Sub Do-behind - This is where the script actualy decides to move behind or not.
Sub bsclock - Called by Do-behind.
Sub bscounter - Called by Do-behind.


I had also tried some other options but using strafing seemed to work the best for situations where the mob gets backed into a wall.

Another option is to have the script use the direct method with some obstical checking(give up on obstical) to move in to place when the fight starts then switch to the strafe method.

Thanks
GrimJack
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack