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
