SinglePull.mac

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

Blazza
a lesser mummy
a lesser mummy
Posts: 60
Joined: Thu Mar 11, 2004 4:27 am

SinglePull.mac

Post by Blazza » Sun Mar 21, 2004 9:39 am

This is my 2nd attempt at a single pull script. On my 2nd day of macroing. I have tested it very little. But this is what I have so far. Most of the single pull logic is in the nested if statements which by the time I was done writing, I didnt feel like making notes. Anyways, here it is, and I should have the mob avoidance code in by tommarow. It will basicly do the same thing it is doing durring the gotomob sub, but will take the add's location and your current location into account, and attempt to detour the general aera.

Code: Select all

|SinglePull.mac
|SHOULD Pull a single mob for you
|Still a work in progress. This is my 2nd day of macroing.
|TODO: Add Mob Avoidance in GoHome and Shoot Subs.

Sub Main

/declare Xcur global
/declare Ycur global
/declare ThereYet global
/declare MobID array
/declare CountID global
/declare Count global
/declare ForInc global
/declare XLoc global
/declare YLoc global
/declare Mob Global
/declare AnchorY Global
/declare AnchorX Global
/declare Radi Global
/declare LowLvl Global
/declare HighLvl Global

/varset AnchorX 663
/varset AnchorY 565
/varset LowLvl 1
/varset HighLvl 2


:searchloop
/echo Finding a nearby level 1 - 2 mob.
/varset Mob $Searchspawn(npc,range:@LowLvl:@HighLvl,radius:1000)
/if n @Mob>0 {
	/echo Found ID @Mob
	/echo $spawn(@Mob,name,clean) at $spawn(@Mob,y) $spawn(@Mob,x)
	/echo Searching for possible adds.
	/call Check $spawn(@Mob,y) $spawn(@Mob,x) 100
	/if n @Count==1 {
		/echo $spawn(@Mob,name,clean) at $spawn(@Mob,y) $spawn(@Mob,x) RFP!
		/call gotomob @Mob
		        } else {
		/echo Possible adds. Searching Again.
		/delay 50
		/goto :searchloop
			       }
	     		}


/return




Sub Check

/varset XLoc @Param1
/varset YLoc @Param0
/varset Radi @Param3

/varset Count 0

/alert clear 1

| Prime the Alert with a known target location or use $target(x)
| and $target(y) to get them from your current target.
| I used static numbers in this example to just simplify for now.
/varset CountID $searchspawn(npc,loc:@XLoc:@YLoc,radius:100)
/if n @CountID>0 {
   /varset MobID(@Count) @CountID
   /varadd Count 1
   /alert add 1 id @CountID
}

| Fucking brilliant code here thanks to Gumby
:CheckMore
/varset CountID $searchspawn(npc,loc:@XLoc:@YLoc,radius:100,noalert:1)
/if n @CountID>0 {
   /varset MobID(@Count) @CountID
   /varadd Count 1
   /alert add 1 id @CountID
   /goto :CheckMore
}

| Stuff you can do:
| If the array count comes back 1 then it is single pull!
| If the array has a number of MOB IDs, pull the one you want,
| search for a specific spawn or select the monster that is
| closest to all other monsters for AE grouping...and what else?
/echo @Count number of mobs total

| Spit out all entries in array, again, do as you wish with them
/for ForInc 0 to $calc(@Count-1)
   /echo Mob number @ForInc has ID @MobID(@ForInc)
/next ForInc
/alert clear 1
/return 



Sub gotomob


  :GoToPoint
   /varset ThereYet 0
   /face id @Mob

         | If we are not within melee range then make sure we are on autorun
         /if n $distance(@Param1,@Param0)>15 /sendkey down up

         | Current Loc
         /varset Xcur $char(x)
         /varset Ycur $char(y)
	
	 /call Check @Ycur @Xcur 100


	 /if n @Count>0 {


	 	/if n @Count>1 {
			/echo Possible Adds, Retreating.
			/call GetHome
			/return
			      }


		/if n @MobID(0)==@Mob {
			/echo We are in range. Pulling.
			/sendkey up up
			/call Shoot
			/return
				     } else {
				/echo Checking New Mob for pull.
				/if n ($spawn(@MobID(0),level)>=@LowLvl && $spawn(@MobID(0),level)<=@HighLvl) {
					/echo Pulling New Mob ID @MobID(0)
					/varset @Mob @MobID(0)
					/sendkey up up
					/call Check $spawn(@Mob,y) $spawn(@Mob,x) 100
					/if @Count<2 {
						/echo Calling Shoot
						/sendkey up up
						/call Shoot
						/return
						    } else {
							/sendkey up up
							/echo Aborting
							/call GetHome
							/return
							   }
													     } else {
						/echo New Mob out of level range, aborting.
						/sendkey up up
						/call GetHome
						/return
														    }
					    }
				}
				

         | Obstacle routine if stuck
         /delay 1
         /if @Xcur==$char(x) /if @Ycur==$char(y) /call Obstacle

         | End movement when near to point.
         /if n $spawn(@Mob,distance)<10 {
            /sendkey up up
            /varset ThereYet 1
         }

          /delay 0
   /if @ThereYet!=1 /goto :GoToPoint
   /echo Here we are.
/return


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
 


Sub GetHome


  :GoToHomePoint
   /varset ThereYet 0
   /face loc @AnchorY,@AnchorX

         | If we are not within melee range then make sure we are on autorun
         /if n $distance(@AnchorY,@AnchorX)>15 /sendkey down up

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

         | Obstacle routine if stuck
         /delay 1
         /if @Xcur==$char(x) /if @Ycur==$char(y) /call Obstacle

         | End movement when near to point.
         /if n $distance(@AnchorY,@AnchorX)<15 {
            /sendkey up up
            /varset ThereYet 1
         }

          /delay 0
   /if @ThereYet!=1 /goto :GoToHomePoint
   /echo Here we are.
   /zapvars
/return 



Sub Shoot

/target id @Mob
/ranged

  :GoToHomePointPulling
   /varset ThereYet 0
   /face loc @AnchorY,@AnchorX

         | If we are not within melee range then make sure we are on autorun
         /if n $distance(@AnchorY,@AnchorX)>15 /sendkey down up

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

         | Obstacle routine if stuck
         /delay 1
         /if @Xcur==$char(x) /if @Ycur==$char(y) /call Obstacle

         | End movement when near to point.
         /if n $distance(@AnchorY,@AnchorX)<15 {
            /sendkey up up
            /varset ThereYet 1
         }

          /delay 0
   /if @ThereYet!=1 /goto :GoToHomePointPulling
   /echo Here we are.
   /face id @Mob
   /zapvars
/return 

bonehand
a lesser mummy
a lesser mummy
Posts: 48
Joined: Tue Feb 17, 2004 5:16 pm

Post by bonehand » Sun Mar 21, 2004 10:22 am

I was just writing a little script to single pull, but here is what mine looks like thus far. You Might want to get rid of your For loop that just spits the array out since you do not have to do that. That is in there just to show what can be done.

Totally untested as of yet, since the Elven Codesmiths worked on this late last night:

Code: Select all

Sub Find_Target
    /declare MobID array 
    /declare CountID local
    /declare CountIDClosest local
    /declare Count local
    /declare ForInc local 

    :CheckForTarget
    /varset CountID 0
    /varset Count 0
    /alert clear 1 

| check to make sure target is dead if one is passed
    /if (n $target(id)!=0 && n $target(animation)!=16) {
        /echo In Find_Target we found $target(name) here!
        /return
    } else if n $target(animation)==16 (
    	/echo Dead Target
        /press esc
        /delay 1s
    }
| Check for a MOB in camp
    /if n $searchspawn(npc,radius:@Danger_Radius)!=0 (
        /varset Targeted_MOB $searchspawn(npc,radius:@Danger_Radius)
        /return
    }
    /varset CountIDClosest $searchspawn(npc,loc:@AnchorX:@AnchorY,radius:@Pull_Radius)
    /if n @CountIDClosest>0 { 
        /varadd Count 1 
        /alert add 1 id @CountIDClosest 
    } 

    :CheckMore 
    /varset CountID $searchspawn(npc,loc:@AnchorX:@AnchorY,radius:@Aggro_Radius,noalert:1) 

    /if n @CountID>0 { 
       /varadd Count 1 
       /alert add 1 id @CountID 
       /goto :CheckMore 
    }
| Check total of MOBs for single pulls
    /if n @Count!=1 {
        /echo @Count number of mobs total. Waiting ...
        /delay 10s
        /goto :CheckForTarget
    }
    /echo @CountIDClosest is next!
    /varset Target_MOB @CountIDClosest
/return
Actually, there is much more, so there is the Find_Target subroutine cleaned up a bit.

Blazza
a lesser mummy
a lesser mummy
Posts: 60
Joined: Thu Mar 11, 2004 4:27 am

Post by Blazza » Sun Mar 21, 2004 5:34 pm

Thanks bonehand, I took the loop that spits the array.. Going to work on my GoHome and Shoot sub add avoidance tonight.