autoattack script - needs obstacle avoidance

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

autoattack script - needs obstacle avoidance

Post by Mckorr » Sat May 24, 2003 10:17 am

Need some help inserting obstacle avoidance into my autoattack script:

Code: Select all

sub Attack
  /varset a(8,0) "$target(name,clean)"
  /varset a(8,1) $target(level)
  /varset a(8,2) $target(name)
  /varset a(8,3) $target(id)
  /echo Fighting a level $a(8,1) $a(8,0)
  /face
  /sendkey down up

:CloserAF
  /if "$target(id)"!="$a(8,3)" /goto :EndAF
  /if n $target(distance)>10 /sendkey down up
  /if n $target(distance)<6 /sendkey down down
  /if n $target(distance)<11 /sendkey up up
  /if n $target(distance)>5 /sendkey up down
  /if n $target(distance)<11 /attack on
  /if n $target(distance)>15 /attack off
  /face fast nopredict
  /if n $char(ability,"Bash")>0 /doability "Bash" 
  /goto :CloserAF

:EndAF
  /echo The level $a(8,1) $a(8,0) is dead...
  /sendkey up up
  /sendkey up down
  /attack off
  /varset a(8,3) 0
  /target corpse radius 20

/return
I need some way to back up and strafe sideways if I get stuck on a rock or tree or something. I found this code in a different post

Code: Select all

         | Current Loc 
         /varset Xcur $char(x) 
         /varset Ycur $char(y) 

         | Obstacle routine if stuck 
         /delay 1 
         /if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Obstacle 

sub Obstacle 

   | We appear to be stuck so try and backup and strafe sideways 
   /sendkey up up 
   /sendkey down down 
   /delay 2 
   /sendkey up down 
   /sendkey down ctrl 
   /if n $rand(99)>50 { 
      /sendkey down right 
   } else { 
      /sendkey down left 
   } 
   /delay 3 
   /sendkey up right 
   /sendkey up left 
   /sendkey up ctrl 
   /sendkey down up 
/return 
but not sure where to paste it in. Any help would be appreciated.
MQ2: Think of it as Evolution in action.

anOrcPawn00
a lesser mummy
a lesser mummy
Posts: 41
Joined: Sat May 10, 2003 6:15 am

Post by anOrcPawn00 » Sat May 24, 2003 7:25 pm

I have a druid auto-kite script I'm working on, started it based on grimjack's auto-hunter here: http://macroquest2.com/phpBB2/viewtopic ... 674708ae64

Pasting the bits related to movement / obstacle avoidance.

Code: Select all

#define MyXLOC v23
#define MyYLOC v24
#define RunState v26
#define ActualSpeed v30
#define SpdQueueSize v31
#define SpellRadius v71
#define MeleeRadius v72
#define MinSpd v73
#define OkSpd v74
#define RunDesire v90			|0=don't want to run, 1=want to get distance, 2=move now!!
#define SpeedQueue 1			|Remember the last ActualSpeeds
#define SpdQueueMax 3		|Max size of SpeedQueue
#define tHeart t10			|Heartbeat timer
In main:

Code: Select all

/varset MyXLOC $char(x)
   /varset MyYLOC $char(y)
   /varset tHeart 10
   /varset MinSpd 10
	/varset OkSpd 20
/varset RunDesire 0
/varset SpdQueueSize 0
   /varset RunState 0
/varset SpellRadius 60
	/varset MeleeRadius 13
Subs:

Code: Select all

sub StopRun
	/sendkey up up
	/varset RunState 0
/return


sub StartRun
	/sendkey down up
	/varset RunState 1
/return



sub MoveToMob
   /varset l0 $MeleeRadius
   /if $p0=="spell" /varset l0 $SpellRadius
   
   /echo $l0
   
   /delay 1s 
   
   /if n $target(distance)>$l0 /call StartRun
   
   :Movementloop
		/call Debug "Run State: $RunState"
		/doevents
		/face fast nopredict
   
		/if n $target(distance)<$l0 { 
			/face fast
			/call StopRun
			/echo Target in range ($target(distance)<$l0)
			/return
		}
   
		/if $target()=="FALSE" { 
			/call StopRun
			/varset HasTarget 0 
			/return
		}
		
		/call CheckObst
		/if n $RunState==3 {
			/echo Stuck, clearing obstacle.
			/call ClearObst 5
		}
	/goto :Movementloop 
	
   /sendkey up up
/return 



sub CheckObst 
	/call Debug "CheckObst [$RunState,$SpdQueueSize,$OkSpd,$MinSpd,$a(SpeedQueue,2)]"
   /if n $RunState==0 /return		|No obstacle checking if we're not running
   /if n $RunState==3 /return		|No obstacle checking if we're alredy stuck
   /if n $SpdQueueSize<3 /return		|No obstacle checking if we don't have 3 speed samples
   
   /if n $a(SpeedQueue,2)>$OkSpd /return	|If last sample is OK, return
   
   /varcalc l0 $calc($a(SpeedQueue,2)+$a(SpeedQueue,2)+$a(SpeedQueue,2))/3
   /call Debug "Average Spd: $l0"
   /if n $l0<$OkSpd /varset RunState 2
   /if n $l0<$MinSpd	/varset RunState 3
/return



sub ClearObst 
   /sendkey up up 
   /sendkey down down  
   /if n $rand(99)>50 { 
      /delay 3s 
      /sendkey up down 
      /sendkey down Right 
      /delay $p0  
      /sendkey up Right 
      /sendkey down up 
      /delay 3s 
      /sendkey up up 
   } else {
      /delay 3s 
      /sendkey up down 
      /sendkey down left 
      /delay $p0  
      /sendkey up left 
      /sendkey down up 
      /delay 3s 
      /sendkey up up        
   }
   /sendkey up down 
   /sendkey up Right 
   /sendkey up Left 
   /sendkey down up 
   
   /varset RunState 1
/return


sub QueueSpeed
	/echo QueueSpeed($p0,$p1,Size:$SpdQueueSize, Max:SpdQueueMax)
	/if $p0=="ADD" /goto :QSADD
	/return
	
	:QSADD
	/if n $SpdQueueSize<SpdQueueMax {
		/varadd SpdQueueSize 1
	} else {
		/for l0 1 to $calc($SpdQueueSize-1)
			/varcalc l1 $l0-1
			/varset a(SpeedQueue,$l1) $a(SpeedQueue,$l0)
		/next l0
	}
	/varset a(SpeedQueue,$calc($SpdQueueSize-1)) $p1
	
	|/call Debug "varset a(SpeedQueue,$SpdQueueSize) $p1"
	/call Debug SpdQueue: [$a(SpeedQueue,0),$a(SpeedQueue,1),$a(SpeedQueue,2)]
/return


sub Event_Timer
	|/call Debug "Timer ($p0)"
	
	| We're handling a Gem is ready timer
	/if n $p0<=8 {
		/call Debug UnGrey $p0
		/varset a(GemReady,$p0) 1
		/return
	}
	
	| Handling the Casting timer
	/if n $p0==9 {
		/call debug CastReady $CastState $p0
		/if n $CastState==1 /varset CastState 0
		/return
	}
	
	[b]/if n $p0==10 {
		|/call Debug "Speed: ($char(x),$char(y))-($MyXLOC,$MyYLOC)"
		/varset ActualSpeed $distance($MyYLOC,$MyXLOC)
		/call Debug "Heartbeat! Speed: $char(speed)  Speed2:" $ActualSpeed
		
		/varset MyXLOC $char(x)
		/varset MyYLOC $char(y)
		|/call Debug "Newloc:" $MyXLOC $MyYLOC
		
		/call QueueSpeed ADD $ActualSpeed
		
		/varset tHeart 10				|restart myself
		/return
	}[/b]
/return
You'll have to remove the /call Debug lines, and only the bold part in the timers is for movement. The way it works is basically it uses a 1s timer to measure current speed in units/sec storing the last 3 of them. If it's in move mode ($RunState==1) and the last sample is not acceptable speed (<$OkSpd) it checks if the average of last 3 samples is < $MinSpd. if it is it sets RunState to 3 (stuck) and calls ClearObst. MoveToMob will move you within $MeleeRange of the target or within $SpellRange of the target if it's passed "spell" as $p0. $HasTarget is supposed to be 1 if there is a valid target, 0 if not.

Hopefully it helps. Sorry it's messy, I just ripped these bits out from a much bigger script.

Jaerin
Developer
Developer
Posts: 133
Joined: Mon Mar 10, 2003 7:37 pm
Contact:

Post by Jaerin » Sat May 24, 2003 9:38 pm

I would be very interested in seeing your autokiting script OrcPawn. I'm not a very skilled macro writer, but I think something like this would be very valuable.

Most of the macro's that I've seen for druids are support macros for multiplayers. I'm not investing that much money into EQ to have 2 accounts. So I just have a primary druid.

Jaerin

anOrcPawn00
a lesser mummy
a lesser mummy
Posts: 41
Joined: Sat May 10, 2003 6:15 am

Post by anOrcPawn00 » Sat May 24, 2003 9:54 pm

It's still very much in a concept phase, so far the only things iI've got done is basically move to target (see above), part of the KiteRun (runs away from mob till it reaches an optimal distance), an almost tuned routine to keep it still while a spell casts (which recognises fizzles and doesn't wait when you fizzle) and part work on the decision process for what to do next (gain distance, heal self or use damage on mob). I'll post it once I flesh the rest out a bit more.

My goal with it btw is letting it level a druid for me in a minimized window on 2nd acct while I play my main. (So a fairly unattended druid xp-er for levs 5 - 40 or so)

Something I'm not sure how to implement is checking for and avoiding KOS baddies in the kite path (like say in SKar to not kite over the undead cyclops, or through the aviak village if it's kiting an aviak)