Simple ranger bot idea/request

Macro requests from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

Nanan
orc pawn
orc pawn
Posts: 29
Joined: Wed Jun 25, 2003 6:21 pm

Simple ranger bot idea/request

Post by Nanan » Wed Jun 25, 2003 6:32 pm

Ill start off by saying that yes I am new to MQ and that my programming skills are about 10 years rusty. I do understand alot of the code but lack the knoledge of the dif vars and special code to create my own mac's for now. I have in my posession a ranger that I would like to set up as a simple bot to add dps to my little hydra clan.

All I want the ranger to do is shoot arrows really. Maybe something like me sending him a tell to attack and he will assist me then launch arrows untill the mob is dead or I tell the ranger to stop.

I started trying to get a mac down last night but I dont know how to trigger off the combat /doabilitys such as archery. I did manage to get to work via hotkey slots but the macro tended to jam up.



If any one knows of an already made macro such as this or could help me out in this it would be much a great help.

User avatar
Imperfect
Macro Author
Macro Author
Posts: 319
Joined: Fri Jun 14, 2002 1:52 am

Post by Imperfect » Wed Jun 25, 2003 10:17 pm

There is no doab Archery at this time. Suggestion for having your archer attack and stop attacking at will use #events.

Good luck I think you will find this a good learning experience.

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

ranger macro

Post by grimjack » Thu Jun 26, 2003 2:48 am

I am currently taking a break from EQ but I saw this request and cooked somthing up real fast. It probably has some errors in it since I have not tested it but this will give you a basis to work off of. I would add some #event lines for when you run out of arrows or don't have line of sight but I don't know the exact messages at the moment so you will have to do it.

To run this macro it's /macro ranger <mastername>. As the master doing "/tell botname cmds" will make the bot send a list of commands it can take. The command ranged is the one you are most interested in. It will make the bot assist off of you and shoot arrows at the enemy untill it no longer has a target or until you tell it to stop. Currently I have it set up to keep a range of 30-150 from the target when in ranged attack mode. It also has other commands but I'm sure by looking at the macro you can see what they do.

I have not tested this at all and most likely it won't work as is without some debuging.

You will need to change this line for sure. Also you will want attack on assist to be turned off in your everquest ini file.

Code: Select all

   /if n $RangeAtk=="1" {
      /if $combat()=="False" /press 10  ||||||||||| Change this to be ranged attack hotkey number
   }
With that all said here is the macro.

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.
/return
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

Nanan
orc pawn
orc pawn
Posts: 29
Joined: Wed Jun 25, 2003 6:21 pm

Post by Nanan » Thu Jun 26, 2003 3:15 am

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

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

Post by grimjack » Thu Jun 26, 2003 4:28 am

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
I 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).

Good luck
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

Nanan
orc pawn
orc pawn
Posts: 29
Joined: Wed Jun 25, 2003 6:21 pm

Post by Nanan » Mon Jun 30, 2003 8:36 pm

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

Chamber
orc pawn
orc pawn
Posts: 15
Joined: Sun Jan 05, 2003 4:26 pm

Post by Chamber » Tue Jul 01, 2003 1:47 am

Hey ya go try this, I didn't test it I just assumed I didn't screw it up when i wrote it.

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


Hope this helped :lol:

Chamber

Darkhearted_Wizard
orc pawn
orc pawn
Posts: 22
Joined: Fri Jun 20, 2003 7:14 pm

Post by Darkhearted_Wizard » Tue Jul 01, 2003 5:01 am

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 :)

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

Post by grimjack » Tue Jul 01, 2003 4:21 pm

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 :)
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.

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

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

Movement while in ranged mode.

Post by grimjack » Tue Jul 01, 2003 4:26 pm

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
If you don't want the bot to move around automaticly while doing ranged attack, change this.

Code: Select all

/call Combatcheck
   /if n $Combatstatus=="1" /call RangeSub
   /if n $RangeAtk=="1" { 

to

Code: Select all

/call Combatcheck
   /if n $Combatstatus=="1" {
      /if  n $RangeAtk!="1" {
         /call RangeSub
      }
   }
   /if n $RangeAtk=="1" { 
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