The actual attacking is nothing special at all; the greatness in this script is actually in its positioning function. It chooses the closest route to the back of your target (right or left), and strafes around while facing your target until it gets to the back. The current movebehind script on the boards is jumpy and very noticable. This one is smooth and natural.
Enjoy
Code: Select all
| - melee.mac
| - Autoattack and Movebehind Macro by Lestor and Cronic
| Usage: /macro melee "distance from target"
#turbo
#event AutoOff "Auto attack is off."
#event AutoOn "Auto attack is on."
Sub Main
/declare targdist global
/declare i global
/declare auto global
/declare skillcheck local
/declare abilitykey local
/declare abilityname local
/declare Oc global
/declare Om global
/declare dir global
/declare dist1 global
/declare dist2 global
/declare dir1 global
/declare dir2 global
/varset targdist "@Param0"
/varset abilitykey 4
/varset abilityname "Kick"
/echo - Melee Bot Loaded.
:Mainloop
/doevents
/if (n @auto==1 && "$target()"=="TRUE") {
/call AssumeThePosition
/if $char(hotbutton,@abilitykey)=="TRUE" /doability "@abilityname"
}
/goto :Mainloop
/return
Sub AssumeThePosition
/call MoveToTarget
:CheckStrafe
/varset Oc $if(n,$char(heading)>=180,$calc($char(heading)-180),$calc($char(heading)+180))
/varset Om $if(n,$target(heading)>=180,$calc($target(heading)-180),$calc($target(heading)+180))
/if n $abs(@Om-@Oc)>60 /goto :DoStrafe
:DoStrafe
/varset Oc $if(n,$char(heading)>=180,$calc($char(heading)-180),$calc($char(heading)+180))
/varset Om $if(n,$target(heading)>=180,$calc($target(heading)-180),$calc($target(heading)+180))
/if n $abs(@Om-@Oc)<60 /goto :End
/face fast nolook
/call GetDirection
/sendkey down ctrl
/sendkey down @dir
/call MoveToTarget
/doevents
/goto :DoStrafe
:End
/sendkey up @dir
/sendkey up ctrl
/face fast nolook
/return
Sub MoveToTarget
:MoveLoop
/varadd i 1
/if n @i==3 {
/face fast nolook
/varset i 0
}
/if n $target(distance)>@targdist /sendkey down up
/if n $target(distance)<@targdist /goto :End
/doevents
/goto :MoveLoop
:End
/sendkey up up
/return
Sub GetDirection
/if n @Om<180 {
/varset dir1 "right"
/varset dir2 "left"
/varset dist1 $calc(360-@Oc+@Om)
} else {
/varset dir1 "left"
/varset dir2 "right"
/varset dist1 $calc(360-@Om+@Oc)
}
/varset dist2 $abs(@Oc-@Om)
/varset dir $if(n,@dist1>@dist2,@dir2,@dir1)
/return
Sub Event_AutoOn
/varset auto 1
/if n $char(pet)>0 /pet attack
/return
Sub Event_AutoOff
/varset auto 0
/doevents flush
/sendkey up ctrl
/sendkey up @dir
/sendkey up up
/return



