Beastlord attack and movebehind

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

cronic
a grimling bloodguard
a grimling bloodguard
Posts: 536
Joined: Wed Nov 26, 2003 11:01 pm

Beastlord attack and movebehind

Post by cronic » Wed Jan 07, 2004 3:12 am

This script waits for you to turn on auto attack, then positions you behind your target, sends your pet, and kicks until you're done attacking.

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

BlackTooth
a lesser mummy
a lesser mummy
Posts: 50
Joined: Mon Dec 08, 2003 10:32 am

Nice!

Post by BlackTooth » Fri Jan 09, 2004 12:36 am

Haha I was just gettin ready to look for some new macros and i saw this one..
I got a BST and there arnt really alot of macros designed for em. This one looks good and the uses of it are tempting =)
I have the ISHI macroquest UI so the distance comes up automatically.
I am lookin forward to using this tonight soon as update is done.
Thanks man!

BlackTooth
a lesser mummy
a lesser mummy
Posts: 50
Joined: Mon Dec 08, 2003 10:32 am

test results are in

Post by BlackTooth » Fri Jan 09, 2004 1:03 am

Okay ladies and gents the test results are in!
LOL funniest damn thing i ever seen.
There is a big problem with this mod =)
It needs to end when autoattack is off, you sit, you die, you respawn, you loot your own corpse, you stand up, SOMETIME lol.
Ya everything i clicked on after the first kill.. i ran towards and began to beat it. Including myself when i hit tab.
it never ended even when i unloaded macroquest =)
So all ya need is a stop for as soon as autoattack is turned off

Another thing is that the distance from target is the distance you want to be from the target. Not how far you currently are from the target. Which was just a my bad.

But the pivot and everything else works like a charm. It aint choppy either. I zoomed out and checked it out and it looked nice and smooth.

Maybe i am just dumb but the only prob i found was that it didnt stop. Otherwise this is a nice mod. Just clik n kill.

Soon as i learn how to code n stuff i am gonna expand on this one and make it so that it will back off and autoheal the pet n stuff. Which could be nice and helpful fer me lazy self =)



:twisted:

BlackTooth
a lesser mummy
a lesser mummy
Posts: 50
Joined: Mon Dec 08, 2003 10:32 am

??

Post by BlackTooth » Fri Jan 09, 2004 7:16 pm

anyone know how to add a stop thing in there?
Like i was thinking that maybe you could do a "do while" statement
like you can in C++ but i dunno if something like that would work... Like if you did a do(while) that would loop and check to see if autoattack still == TRUE

w00tz0r
orc pawn
orc pawn
Posts: 18
Joined: Sun Dec 14, 2003 2:37 am

Hmm

Post by w00tz0r » Sat Jan 10, 2004 12:29 am

Since im still leraning all this , how would i incorporate this into genbot.mac's combat.mac and or personal for autobehind?

Id like to try it for my rog, since the genbot one is a lil "ticky"

lestor
orc pawn
orc pawn
Posts: 16
Joined: Sat Jan 10, 2004 6:31 am

Post by lestor » Sat Jan 10, 2004 6:43 am

The macro is designed to be sort of a 'lazy gouping assist macro'. The only time the macro will run up to a mob is if a) you have a target, and b) your autoattack is on. The macro never ends.. otherwise you'd just have to run it for each mob you attacked. Run the macro, and target something. Hit your autoattack and watch the bot do its thing.

The "distance to mob" parameter refers to how far away from the mob you wish to position yourself, if there was any confusion in that. 10 is pretty good for most mobs, 20 or so is good for giant-type mobs.

If your problem persists, I'll see if I can find a fix for ya.

Cheers,

Lestor

BlackTooth
a lesser mummy
a lesser mummy
Posts: 50
Joined: Mon Dec 08, 2003 10:32 am

Post by BlackTooth » Sat Jan 10, 2004 9:53 am

lestor wrote:The macro is designed to be sort of a 'lazy gouping assist macro'. The only time the macro will run up to a mob is if a) you have a target, and b) your autoattack is on.
Lestor
Thats what it is supposed to do but it reall NEVER ends it never turns itself off
When i used this macro i died and when i respawned it was still on. You dont have autoattack on when you come back from the dead.
It wouldnt attack them i dont think cuz i never let it get close enough,
but it would run towards them and i could only look towards the targeted thing.

If it had a "do until" checker or somethin in it i think it would fix it
But i dont know how to code really =P

wardave
a ghoul
a ghoul
Posts: 120
Joined: Sun Jan 25, 2004 4:38 am

Post by wardave » Tue Jan 27, 2004 3:54 am

I tried this last night and my charter would hit the mob once and run past him circle back and start over, was the weird. Has anyone else tested it recentlu?

rzmonk76
a hill giant
a hill giant
Posts: 165
Joined: Sat Jan 31, 2004 1:37 pm
Contact:

anyone wana fix this?

Post by rzmonk76 » Sun Feb 01, 2004 10:56 am

has anyhone debugged this one yet? i realy love the positioning functionality. but it just wont shut off period. i've tried to myself but i just dont know too much about coding.

a problem it has is if your tanking the script tries to keep pivoting around it. all this time turning off autoattack is futiile, i cant even hit any keys. the whole interface refuses to repsond.

BlackTooth
a lesser mummy
a lesser mummy
Posts: 50
Joined: Mon Dec 08, 2003 10:32 am

Post by BlackTooth » Sun Feb 01, 2004 2:43 pm

ya we have had this prob before ( as posted in the testing posts things) but no one has debugged it as pf yet
I am not that great a coder either so i havent really worked on it

rzmonk76
a hill giant
a hill giant
Posts: 165
Joined: Sat Jan 31, 2004 1:37 pm
Contact:

Post by rzmonk76 » Sun Feb 01, 2004 2:53 pm

http://macroquest2.com/phpBB2/viewtopic.php?t=3482

here is a link to a bard flavored one I had just found on the last page. perhaps if the Beastlord one is unrecoverable we can edit this one to our needs. im shiny new to this all so its gona take some time to get to understand this all. I'm learnng slowly but surely.

notetaker
orc pawn
orc pawn
Posts: 12
Joined: Tue Feb 03, 2004 11:50 am
Location: colorado

how do i make my text into a code box??

Post by notetaker » Thu Feb 05, 2004 8:57 pm

how do i make the text that i add to the post have a code box around it ?

how would i change this so instead of attacking it woud do this macro with an auto assist "assist player" would like to run this in the back ground when im running 2 accounts on one pc???
it is better to do something wrong
then to do nothing at all
the only way to not make mistakes
is to do nothing
I MUST BE DOING A LOT !

TheAFKBard
a ghoul
a ghoul
Posts: 133
Joined: Tue Dec 30, 2003 9:48 pm

Post by TheAFKBard » Thu Feb 05, 2004 9:49 pm

A fun addition to this script would be to have it equip some dumb disposable item to get looted, like a cloth cap

gnomegod
decaying skeleton
decaying skeleton
Posts: 6
Joined: Wed Feb 11, 2004 11:11 pm

hmmm

Post by gnomegod » Tue Feb 17, 2004 1:59 pm

double post :(

Figured I would post a few reasons why i changed it(there are only like 2 very small changes btw). When i was first using it, after i attacked the first mob it wouldnt shut off properly. This is because sometimes you dont get the message "auto attack off" when you are done killing a mob. So the code wasn't stopping. If I targeted another mob it would go to that mob even if i wasnt attacking. Sometimes the control and @Direction keys were stuck down after fights too. All i did was add two if statements that would jump to the end if you didnt have a target inside the strafe and movetomob functions. And at the top I have something that up presses all keys used by this macro whenever you dont have a target, it only does this once(using the keyflag var) so that you arent rooted in place :)
Last edited by gnomegod on Tue Feb 17, 2004 2:08 pm, edited 2 times in total.

gnomegod
decaying skeleton
decaying skeleton
Posts: 6
Joined: Wed Feb 11, 2004 11:11 pm

hmmm

Post by gnomegod » Tue Feb 17, 2004 2:01 pm

Loved this macro, but also had problems with it. Changing to this seemed to make it work. The distance in this one is hardcoded at 15, and the ability was changed to backstacb, but as far as ive been able to tell its working. Btw, Lestor and Cronic, i really like how the code works as far as the strafing and moving behind etc, really good work. Also im very new here, i hope its ok to post edits of people's code like this ?

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 
/declare keyFlag global

/varset targdist "15" 
/varset abilitykey 4 
/varset abilityname "Backstab" 
/varset keyFlag 1

/echo - Melee Bot Loaded. 

:Mainloop 
/doevents 

/if (n $target(id)==0 && @keyFlag==1) {
/varset auto 0
/sendkey up ctrl 
/sendkey up up 
/sendkey up left 
/sendkey up right
/varset keyFlag 0
}

/if (n @auto==1 && "$target()"=="TRUE") { 
/varset keyFlag 1
/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 
/if n $target(id)==0 /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 
/if n $target(id)==0 /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 
/sendkey up left 
/sendkey up right
/return 
[/code]