A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot.
Moderator: MacroQuest Developers
-
Mckorr
- Developer

- Posts: 2326
- Joined: Fri Oct 18, 2002 1:16 pm
- Location: Texas
Post
by Mckorr » Mon Jan 26, 2004 3:45 pm
I use this for my melee routines, works very well. To call it, use
Code: Select all
#turbo
#Event Casting "You begin casting"
#Event Enraged "has become ENRAGED"
#Event Offrage "is no longer enraged"
sub Attack
/declare targetarray array
/declare MyXLOC global
/declare MyYLOC global
/declare ObstacleCount global
/declare InCombat global
/varset targetarray(0) "$target(name,clean)"
/varset targetarray(1) $target(level)
/varset targetarray(2) $target(name)
/varset targetarray(3) $target(id)
/varset InCombat 0
/echo Fighting a level @targetarray(1) @targetarray(0)
/face look
/call MovetoMob
:CloserAF
/if "$target(id)"!="@targetarray(3)" /goto :EndAF
/doevents
/if n @InCombat==1 /call AttackRoutine
/goto :CloserAF
:EndAF
/echo The level @targetarray(1) @targetarray(0) is dead...
/sendkey up up
/sendkey up down
/attack off
/varset InCombat 0
/varset targetarray(3) 0
/press Num_5
/endmacro keep keys
sub AttackRoutine
/if n $target(distance,nopredict)>10 /press up
/if n $target(distance,nopredict)<10 /press down
/if n $target(distance,nopredict)<15 /attack on
/if n $target(distance,nopredict)>15 {
/attack off
/call MovetoMob
}
/face fast nopredict look
/if n $target(distance,nopredict)<11 /if n $char(ability,"Bash")>0 /doability "Bash"
/if n $target(distance,nopredict)<11 /if n $char(ability,"Kick")>0 /doability "Kick"
/if n $target(distance,nopredict)<11 /if n $char(ability,"Disarm")>0 /doability "Disarm"
/return
sub MoveToMob
/varset MyXLOC $char(x)
/varset MyYLOC $char(y)
/varset ObstacleCount 0
/if n $target(distance,nopredict)<=15 {
/face look
/varset InCombat 1
/return
}
/doevents
/sendkey down up
:Movementloop
/varadd ObstacleCount 1
/if $target()=="FALSE" /return
/face look
/if n $target(distance,nopredict)<=10 {
/face look
/sendkey up up
/varset InCombat 1
/return
}
/if @ObstacleCount>=3 {
/call CheckObstacle
/goto :Movementloop
}
/if n $target(distance,nopredict)>10 /goto :MovementLoop
/return
sub CheckObstacle
/if n @MyXLOC==$char(x) /if n @MyYLOC==$char(y) /call HitObstacle
/varset MyXLOC $char(x)
/varset MyYLOC $char(y)
/varset ObstacleCount 0
/return
sub HitObstacle
/sendkey up up
/sendkey down down
/delay 3
/sendkey up down
/sendkey down ctrl
/if n $rand(99)>50 {
/sendkey down right
} else {
/sendkey down left
}
/delay 5
/sendkey up right
/sendkey up left
/sendkey up ctrl
/sendkey down up
/return
sub Event_Enraged
/if $target()=="TRUE" {
/attack off
/varset InCombat 0
:EnrageDelay
/if $target()=="TRUE" /if n @InCombat==0 {
/doevents
/goto :EnrageDelay
}
}
/return
sub Event_Offrage
/if $target()=="TRUE" {
/varset InCombat 1
/attack on
}
/return
sub Event_Casting
:checkcast
/delay 3
/if "$char(casting)"=="TRUE" /goto :checkcast
/return
-
Pax
- a lesser mummy

- Posts: 52
- Joined: Fri Dec 19, 2003 11:04 am
- Location: Denmark
Post
by Pax » Sat Apr 24, 2004 5:38 pm
ive tried to fiddle this to work with the new $Parm system, gotten someway, but is currently stuck at the move to mob (i think) sub.
this is what i have so far, anyone wanna throw in a few idears be my guest.
Code: Select all
#turbo
#include anchor.inc
sub Attack
/declare MyXLOC global
/declare MyYLOC global
/declare ObstacleCount global
/declare targetarray array
/varset targetarray(0) ${Target.Name[Clean]}
/varset targetarray(1) ${Target.Level}
/varset targetarray(2) ${Target.Name}
/varset targetarray(3) ${Target.Id}
/echo Fighting a level @targetarray(1) @targetarray(0)
/face
/call MovetoMob
:CloserAF
/if (${Target.NotEqual[@targetarray(3)]}) /goto :EndAF
/if (${Target.Distance}>13) /keypress forward hold
/if (${Target.distance}<8) /keypress back
/if (${Target.distance}<15) /attack on
/if (${Target.distance}>15) /attack off
/if (${Target.distance}>15) /call MovetoMob
/face
/if (${Target.distance}<15) /if (${Me.AbilityReady[Bash]}) /doability "Bash"
/if (${Target.distance}<15) /if (${Me.AbilityReady[Kick]}) /doability "Kick"
/if (${Target.distance}<15) /if (${Me.AbilityReady[Disarm]}) /doability "Disarm"
/doevents
/goto :CloserAF
:EndAF
/echo The level @targetarray(1) @targetarray(0) is dead...
/keypress forward
/keypress up down
/attack off
/varset targetarray(3) 0
/return
sub MoveToMob
/varset MyXLOC ${Me.X}
/varset MyYLOC ${Me.Y}
/varset ObstacleCount 0
/if (${Target.Distance}<=15) {
/face
/return
}
/keypress back
:Movementloop
/varadd ObstacleCount 1
/if (${Target.Type.NotEqual[NPC]}) /return
/face
/if (${Target.distance}<=10) {
/face
/keypress forward
/return
}
/if @ObstacleCount>=3 {
/call CheckObstacle
/goto :Movementloop
}
/if (${Target.distance}>10) /goto :MovementLoop
/return
sub CheckObstacle
/if n @MyXLOC==${Me.X} /if n @MyYLOC==${Me.Y} /call HitObstacle
/varset MyXLOC ${Me.X}
/varset MyYLOC ${Me.Y}
/varset ObstacleCount 0
/return
sub HitObstacle
/keypress forward
/keypress back hold
/delay 3
/keypress forward hold
/keypress ctrl hold
/if (${Rand[100]})>50 {
/keypress down right
} else {
/keypress down left
}
/delay 5
/keypress right
/keypress left
/keypress ctrl
/keypress up hold
/return
else ill try and update it as i go along.
-
Mckorr
- Developer

- Posts: 2326
- Joined: Fri Oct 18, 2002 1:16 pm
- Location: Texas
Post
by Mckorr » Wed Apr 28, 2004 2:55 pm
I've been trying to update this as I go. There's an error someplace though. It will move up to the mob fine, but if the mob turns and runs away it won't give chase. Dunno why.
Code: Select all
#Event Casting "You begin casting"
#Event Enraged "has become ENRAGED"
#Event Offrage "is no longer enraged"
#Event Gate "Gates"
sub Attack
/declare targetarray array
/declare MyXLOC global
/declare MyYLOC global
/declare ObstacleCount global
/declare InCombat global
/varset targetarray(0) ${Target.CleanName}
/varset targetarray(1) ${Target.Level}
/varset targetarray(2) ${Target.Name}
/varset targetarray(3) ${Target.ID}
/varset InCombat 0
/echo Fighting a level @targetarray(1) @targetarray(2)
/face fast nolook
/call MovetoMob
:CloserAF
/if (${Target.ID}!=@targetarray(3)) /goto :EndAF
/doevents
/if (@InCombat) /call AttackRoutine
/goto :CloserAF
:EndAF
/attack off
/echo The level @targetarray(1) @targetarray(2) is dead...
/keypress forward
/keypress back
/varset InCombat 0
/varset targetarray(3) 0
/mqpause chat on
/endmacro
sub AttackRoutine
/doevents
/if (${Target.Distance}>10) {
/keypress forward hold
/timed 1 /keypress forward
}
/if (${Target.Distance}<10) {
/keypress back hold
/timed 1 /keypress back
}
/if (${Target.Distance}<=15) /attack on
/if (${Target.Distance}>15) {
/attack off
/call MovetoMob
}
/face nolook fast
/doevents
/if ((${Target.Distance}<11)&&(${Me.AbilityReady["Bash"]})) /doability "Bash"
/if ((${Target.Distance}<11)&&(${Me.AbilityReady["Kick"]})) /doability "Kick"
/if ((${Target.Distance}<11)&&(${Me.AbilityReady["Disarm"]})) /doability "Disarm"
/return
sub MoveToMob
/varset MyXLOC ${Me.X}
/varset MyYLOC ${Me.Y}
/varset ObstacleCount 0
/if (${Target.Distance}<=15) {
/face nolook
/varset InCombat 1
/return
}
/doevents
/keypress forward hold
:Movementloop
/varadd ObstacleCount 1
/if (${Target.ID}) {
/face nolook
/if (${Target.Distance}<=15) {
/face nolook
/keypress forward
/varset InCombat 1
/return
}
/if (${ObstacleCount}>=10) {
/call CheckObstacle
/goto :Movementloop
}
/if (${Target.Distance}>15) /goto :MovementLoop
}
/return
sub CheckObstacle
/if ((${MyXLOC}==${Me.X})&&(${MyYLOC}==${Me.Y})) /call HitObstacle
/varset MyXLOC ${Me.X}
/varset MyYLOC ${Me.Y}
/varset ObstacleCount 0
/return
sub HitObstacle
/keypress forward
/keypress back hold
/delay 3
/keypress back
/if (${Math.Rand[2]}) {
/keypress strafe_right hold
} else {
/keypress strafe_left hold
}
/delay 5
/keypress strafe_right
/keypress strafe_left
/keypress forward hold
/return
sub Event_Enraged
/if (${Target.ID}) {
/attack off
/varset InCombat 0
:EnrageDelay
/if (${Target.ID})&&(${InCombat}==0) {
/doevents
/goto :EnrageDelay
}
}
/return
sub Event_Offrage
/if (${Target.ID}) {
/varset InCombat 1
/attack on
}
/return
sub Event_Casting
:checkcast
/delay 1
/if (${Me.Casting}) /goto :checkcast
/return
sub Event_Gate
/keypress forward
/keypress back
/attack off
/mqpause chat on
/endmacro
/return
-
wassup
- Official Guardian and Writer of TFM

- Posts: 1487
- Joined: Sat Oct 26, 2002 5:15 pm
Post
by wassup » Wed Apr 28, 2004 4:36 pm
Is it this part McKorr"
Instead of:
Code: Select all
/if (${Target.Distance}<=15) {
/face nolook
/keypress forward
/varset InCombat 1
/return
}
Did you want:
Code: Select all
/if (${Target.Distance}>15) {
/face nolook
/keypress forward
/varset InCombat 1
/return
}
-
Mckorr
- Developer

- Posts: 2326
- Joined: Fri Oct 18, 2002 1:16 pm
- Location: Texas
Post
by Mckorr » Wed Apr 28, 2004 7:08 pm
Nope, that's what it should be. If the distance is less than 15 it needs to exit the movement loop and return to the attack loop. The attack loop handles distances of 15 or less.
-
operat0r
- RTFM, then ask again
- Posts: 61
- Joined: Thu Aug 28, 2003 2:04 am
Post
by operat0r » Fri May 28, 2004 12:06 am
you look at advpath.mac ? I may sound stupid but I just cut and paste and find the core code and go from there
with love moron #6895423686