Moderator: MacroQuest Developers
Code: Select all
/if n $RangeAtk=="1" {
/if $combat()=="False" /press 10 ||||||||||| Change this to be ranged attack hotkey number
}Code: Select all
|ranger.mac
|Generic bot for rangers.
|Make sure you edit this macro.
|Version 2.06
|Grimjack
#turbo 75
#Event Enraged "has become ENRAGED"
#Event Offrage "is no longer enraged"
#event FollowOff "You are no longer auto-following"
#define MasterName v50
#define CmdArrayNum v51
#define CmdArraySize v52
#define ChatInput1 v55
#define ChatInput2 v56
#define ChatInput3 v57
#define MyXLoc v59
#define MyYLoc v60
#define countdown v62
#define CmdList v63
#define RangeMin v70
#define RangeMax v71
#define FastRange v72
#define Combatstatus v73
#define RangeAtk v74
#define Fail v94
#define DoAgain v95
#chat tell
Sub Main
/if n $strlen("$p0")<=0 {
/echo Usage: /macro ranger <Master Name>
/endmacro
}
/varset MasterName $p0
/varset RangeMin 10
/varset RangeMax 12
/varset FastRange 15
/varset Combatstatus 0
/varset RangeAtk 0
/varset a(1,0) afk
/varset a(1,1) accept
/varset a(1,2) reject
/varset a(1,3) invite
/varset a(1,4) follow
/varset a(1,5) stop
/varset a(1,6) moveto
/varset a(1,7) sit
/varset a(1,8) stand
/varset a(1,9) camp
/varset a(1,10) run
/varset a(1,11) cmds
/varset a(1,12) target
/varset a(1,13) notarget
/varset a(1,14) assist
/varset a(1,15) saytarget
/varset a(1,16) attack
/varset a(1,17) ranged
/call CountArraySize 1
/varset CmdArraySize $int($return)
/varset CmdList "$a(1,0), $a(1,1), $a(1,2), $a(1,3), $a(1,4), $a(1,5) $a(1,6), $a(1,7), $a(1,8), $a(1,9), $a(1,10), $a(1,11), $a(1,12), $a(1,13), $a(1,14), $a(1,15), $a(1,16), $a(1,17), $a(1,18), $a(1,19), $a(1,20) $a(1,21), $a(1,22), $a(1,23), $a(1,24), $a(1,25), $a(1,26), $a(1,27), $a(1,28), $a(1,29), $a(1,30), $a(1,31), $a(1,32), $a(1,33), "$a(1,34), $a(1,35), $a(1,36), $a(1,37), $a(1,38), $a(1,39), $a(1,40)"
/varset CmdArrayNum 0
:MainLoop
/call Combatcheck
/if n $Combatstatus=="1" /call RangeSub
/if n $RangeAtk=="1" {
/if $combat()=="False" /press 10 ||||||||||| Change this to be ranged attack hotkey number
}
/doevents
/varset CmdArrayNum 0
/goto :MainLoop
/return
sub CountArraySize
/varset l0 0
:CountArrayLoop
/if n $strlen("$a($p0,$l0)")<=0 {
/goto :CountArrayEnd
}
/varadd l0 1
/goto :CountArrayLoop
:CountArrayEnd
/return $l0
Sub Combatcheck
/if $RangeAtk=="1" {
/if $target()=="FALSE" {
/varset Combatstatus 0
/varset RangeAtk 0
/varset RangeMin 10
/varset RangeMax 12
/varset FastRange 15
:rgwait
/if $combat()=="TRUE" /attack off
/if $combat()=="TRUE" /goto :rgwait
/return
}
/return
}
/if $EnrageVar=="1" {
/if $target()=="TRUE" {
/return
} else {
/varset EnrageVar 0
/varset Combatstatus 0
}
}
/if $target()=="FALSE" {
/varset Combatstatus 0
/if $combat=="TRUE" {
/attack off
}
/return
}
/if $target()=="TRUE" {
/if $combat=="TRUE" {
/varset Combatstatus 1
/return
}
}
/varset Combatstatus 0
/return
Sub Rangesub
/face fast nopredict
/if n $target(distance)>=$FastRange /call Fastmove
/if n $target(distance)>$RangeMax {
/press up
}
/if n $target(distance)<$RangeMin {
/press down
}
/return
Sub Fastmove
:fastmoveloop
/doevents
/if $target()=="FALSE" {
/varset Combatstatus 0
/sendkey up up
/if $combat=="TRUE" {
/attack off
/return
}
}
/face fast nopredict
/if n $target(distance)>$FastRange {
/sendkey down up
}
/if n $target(distance)<=$FastRange {
/if $Combatstatus=="1" {
/if $EnrageVar=="0" {
}
}
/sendkey up up
/return
}
/goto :fastmoveloop
/return
Sub Event_Chat
/varset CmdArrayNum 0
/if "$MasterName"=="$p1" {
:ArrayTime
/if "$arg(1,"$p2")"=="$a(1,$CmdArrayNum)" {
/call Do-$a(1,$CmdArrayNum) $p2
/return
}
/varadd CmdArrayNum 1
/if n $CmdArrayNum>=$CmdArraySize /return
/goto :ArrayTime
} else {
/tell $MasterName $p1 told me: $p2
}
/return
Sub Do-target
/if n $strlen("$p1")<=0 {
/return
} else /if n $strlen("$p2")<=0 {
/target "$p1"
} else /if n $strlen("$p3")<=0 {
/target "$p1 $p2"
} else /if n $strlen("$p4)<=0 {
/target "$p1 $p2 $p3"
} else /target "$p1 $p2 $p3 $p4"
/tell $MasterName my target is %t
/return
Sub Do-saytarget
/tell $MasterName my target is %t
/return
Sub Do-assist
/if n $strlen("$p1")<=0 {
/assist $MasterName
/delay 3
} else /if n $strlen("$p2")<=0 {
/assist "$p1"
} else /if n $strlen("$p3")<=0 {
/assist "$p1 $p2"
} else /if n $strlen("$p4)<=0 {
/assist "$p1 $p2 $p3"
} else /assist "$p1 $p2 $p3 $p4"
/tell $MasterName my target is %t
/return
Sub Do-attack
/varset RangeMin 10
/varset RangeMax 12
/varset FastRange 15
/sit off
/if n $strlen("$p1")<=0 {
/assist $MasterName
/delay 5
} else /if n $strlen("$p2")<=0 {
/target "$p1"
} else /if n $strlen("$p3")<=0 {
/target "$p1 $p2"
} else /if n $strlen("$p4)<=0 {
/target "$p1 $p2 $p3"
} else /target "$p1 $p2 $p3 $p4"
/tell $MasterName Attacking %t
/attack on
/return
Sub Do-ranged
/sit off
/if n $strlen("$p1")<=0 {
/assist $MasterName
/delay 5
} else /if n $strlen("$p2")<=0 {
/target "$p1"
} else /if n $strlen("$p3")<=0 {
/target "$p1 $p2"
} else /if n $strlen("$p4)<=0 {
/target "$p1 $p2 $p3"
} else /target "$p1 $p2 $p3 $p4"
/tell $MasterName Pelting %t with arrows.
/varset RangeAtk 1
/varset Combatstatus 1
/varset RangeMin 30
/varset RangeMax 150
/varset FastRange 155
/return
Sub Do-sit
/sit off
/sit
/return
Sub Do-stand
/sit off
/return
Sub Do-notarget
/press esc
/press esc
/press esc
/return
Sub Do-afk
/varset CmdArrayNum 0
/if n $strlen("$p1")<=0 {
/afk
} else /if n $strlen("$p2")<=0 {
/afk $p1
} else /if n $strlen("$p3")<=0 {
/afk $p1 $p2
} else /if n $strlen("$p4")<=0 {
/afk $p1 $p2 $p3
} else /if n $strlen("$p5")<=0 {
/afk $p1 $p2 $p3 $p4
} else /if n $strlen("$p6")<=0 {
/afk $p1 $p2 $p3 $p4 $p5
} else /if n $strlen("$p7")<=0 {
/afk $p1 $p2 $p3 $p4 $p5 $p6
} else /if n $strlen("$p8")<=0 {
/afk $p1 $p2 $p3 $p4 $p5 $p6 $p7
} else /if n $strlen("$p9")<=0 {
/afk $p1 $p2 $p3 $p4 $p5 $p6 $p7 $p8
} else {
/afk $p1 $p2 $p3 $p4 $p5 $p6 $p7 $p8 $p9
}
/afk
/return
Sub Do-accept
/press esc
/press esc
/invite
/return
Sub Do-reject
/press esc
/press esc
/disband
/return
Sub Do-invite
/if n $strlen("$p1")<=0 {
/assist $MasterName
/delay 3
} else /if n $strlen("$p2")<=0 {
/target "$p1"
} else /if n $strlen("$p3")<=0 {
/target "$p1 $p2"
} else /if n $strlen("$p4)<=0 {
/target "$p1 $p2 $p3"
} else /target "$p1 $p2 $p3 $p4"
/tell $MasterName Inviting %t
/invite
/return
Sub Do-follow
/target $MasterName
/face
/follow
/tell $MasterName Autofollow on %t.
/return
Sub Do-stop
/tell $MasterName Stoping.
/varset RangeMin 10
/varset RangeMax 12
/varset FastRange 15
/sendkey up up
/varset Fail 1
/press d
/press d
/press esc
/press esc
/press esc
/press right
/return
Sub Do-sit
/stand
/sit on
/return
Sub Do-stand
/stand
/return
Sub Do-camp
/tell $MasterName Camping out.
/stand
/sit
/camp
/return
Sub Do-cmds
/tell "$MasterName" Commands: "$CmdList"
/return
Sub Do-moveto
/sit off
/varset countdown 0
/varset MyXLoc $char(x)
/varset MyYLoc $char(y)
/if n $strlen("$p1")<=0 {
/assist $MasterName
/delay 3
} else /if n $strlen("$p2")<=0 {
/target "$p1"
} else /if n $strlen("$p3")<=0 {
/target "$p1 $p2"
} else /if n $strlen("$p4)<=0 {
/target "$p1 $p2 $p3"
} else /target "$p1 $p2 $p3 $p4"
/if $p1=="me" /target $MasterName
/tell $MasterName Moving to %t.
:gotopointloop
/doevents
/if $target()==FALSE {
/sendkey up up
/return
}
/face fast nopredict
/if n $target(distance)>15 /sendkey down up
/if n $target(distance)<=15 {
/sendkey up up
/return
}
/face fast nopredict
/if n $countdown>=3 {
/call Detectobst
/varset countdown 0
}
/varadd countdown 1
/doevents
/goto :gotopointloop
}
/sendkey up up
/face
/return
Sub Detectobst
/if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Hitobst 5
/varset MyXLoc $char(x)
/varset MyYLoc $char(y)
/return
sub Hitobst
/sendkey up up
/sendkey down down
/if n $rand(99)>50 {
/delay 2s
/sendkey up down
/sendkey down Right
/delay $p0
/sendkey up Right
/sendkey down up
/delay 2s
/sendkey up up
} else {
/delay 2s
/sendkey up down
/sendkey down left
/delay $p0
/sendkey up left
/sendkey down up
/delay 2s
/sendkey up up
}
/sendkey up down
/sendkey up Right
/sendkey up Left
/sendkey down up
/return
Sub SpellSub
/sendkey up up
/if n Combatstatus==1 /delay 3s
/varset Fail 0
/varset SpellName "$p0"
/varset SpellSlot "$char(gem,"$SpellName")"
/varset CastTime "$spell("$SpellName",casttime)"
:BeginCast
/varset DoAgain 0
/varset StartCast 0
/call WaitForStart
:TimerLoop
/doevents
/if n $DoAgain==1 /goto :BeginCast
/if n $Fail==1 /return
/doevents
/if n $DoAgain==1 /goto :BeginCast
/if n $Fail==1 /return
/if n $CTimer>0 /goto :TimerLoop
/delay 2
/doevents
/if n $DoAgain==1 /goto :BeginCast
/return
Sub WaitForStart
/cast $SpellSlot
:StartLoop
/doevents
/if n $Fail==1 /return
/if n $DoAgain==1 /return
/if n $StartCast==0 {
/goto :StartLoop
}
/varset CTimer "$CastTime"s
/return
Sub Event_Enraged
/if $RangeAtk=="1" /return
/if $target()=="TRUE" {
/if n $Combatstatus==1 {
/varset EnrageVar 1
/attack off
}
/varset EnrageVar 1
}
/return
Sub Event_Offrage
/if $RangeAtk=="1" /return
/if $target()=="TRUE" {
/if n $Combatstatus==1 {
/varset EnrageVar 0
/attack
}
/varset EnrageVar 0
}
/return
Sub Event_FollowOff
/press esc
/press esc
/delay 5
/tell $MasterName Auto Follow Off.
/returnI just modified my generic caster bot (removed a bunch of code that was not needed and added the ranged attack stuff). If you find any errors let me know and I'll see if I can debug them while I'm bored at work (like I am now).Nanan wrote:Grimjack you rock thanks.
My ranger has endless quiver so running out of arrows is not a prob.
If you cooked this up quick then man you must be a godly coder.
Ill try this out and see how it works.
Thanks
Code: Select all
|Archery Loop
|This Macro Will Trigger You to Stand assist and shoot arrows till the mob is dead
|When your Archer no longer has a target or his target is a PC he will check to see if Eagle Eye is up
|If Eagle Eye is up then it will sit you down and wait for the attack command
|If Eagle Eye is not up it will cast it and then wait for the attack command
|To trigger the attack send the Archer a tell saying "Shoot this thing already"
#Event Archery "Shoot this thing already"
#Event EagleEyeDone "Your eyes sharpen, with an aura of avian presence."
Sub Main
/assist off
/varset v1 1
:Loop
/if $v1==1 /call BuffCheck
/if $v1==2 /call BuffUp
/if $v3==3 /call DeathByArrows
/if $v3==4 /call Wait
/doevents
/goto :Loop
/return
Sub BuffCheck
/if n $char(buff,"Eagle Eye")==0 /varset v1 2
/if n $char(buff,"Eagle Eye")>0 /varset v1 4
/return
Sub BuffUp
/stand
/target myself
|Put Eagle Eye in Spell Slot 1 or change the number after /cast to the number Eagle Eye is in.
/cast 1
/return
Sub DeathByArrows
/stand
/assist BobThePuller
|Change BobThePuller to who you want to assist off of
:Shoot
|Change 4 to be your range attack Hotkey Number
/press 4
/if $target(type)!="NPC" /goto :EndShoot
/if $target()=="FALSE" /goto :EndShoot
/if $target()!="FALSE" /goto :Shoot
:EndShoot
/varset v1 1
/return
Sub Wait
/delay 10
/if $char(state)=="STAND" /sit
/return
Sub Event_Archery
/varset v1 3
/return
Sub Event_EagleEyeDone
/varset v1 4
/return

I may do that in the future. It really wouldn't save me any time though. I have a template. I edit the template when I decide what I want it to do and then save as. I guess I could move all the generic stuff like movement and attacking code to an include.Darkhearted_Wizard wrote:Grimjack: A suggestion.. Build a grim-bot.mac, and #include it... your bots will be much more lean and mean, and that way you don't have to copy paste your code a thousand times into every bot :)
If you don't want the bot to move around automaticly while doing ranged attack, change this.Nanan wrote:Well the macro ended up being way to complex, often times my ranger would back up into other mobs and train me. So I was thinking how about something a bit simpler.
Is it posable to do something that would make the bot stop attacking when target is dead?
Something like this?
/if $target == (null) /endmacro
Code: Select all
/call Combatcheck
/if n $Combatstatus=="1" /call RangeSub
/if n $RangeAtk=="1" { Code: Select all
/call Combatcheck
/if n $Combatstatus=="1" {
/if n $RangeAtk!="1" {
/call RangeSub
}
}
/if n $RangeAtk=="1" {