Code: Select all
| hunter.mac
| v3.1.c4f (adapted from grimjack's)
| Hunt script with loot for new loot parser.
| As always much of this script is inspired or taken directly from
| pieces of macro's found at macroquest2.com's macro depot
| Thank you to all the people who have donated their scripts which
| made this possible. And thank you to the MQ developers.
|
| Edit /varset Loot(0) "silk" and /varset Loot(1) "skin"
| Also edit /varset Mob(0) "widow" and /varset Mob(1) "wolf"
| You can also make these arrays bigger. If you want to search for
| wolfs, widows and orcs you would have this
| /varset Mob(0) "widow"
| /varset Mob(1) "wolf"
| /varset Mob(2) "orc"
|
| What type of loot you want can be expanded in a similar way to
| the mobs you want to hunt.
|
| C4F Modifications:
| -tweaked search pattern (and as a bonus has 'priority' as a side effect) to
| look in ever increasing radius til it finds a suitable target
| -changed/added special attacks during combat sub
| -added respawn timeout wait timer, so if nothings found, it'll wait a bit
| before searching again
| -paranoia random delay after each kill
| -automatic array size calculation
| -kill nearby, hostile "adds" (seems to work, let me know)
| -/autoinventory for keepers, and drops items on the ground otherwise.
| -NOTE: cause i'm paranoid about my hard earned gear, this script won't farm
| NO-DROP items for ya (yet, i might get around to tweaking the code to do so)
#turbo 90
#event AFKTell "tells you"
#event InvFull "no room to put that!"
#event Died "you have entered"
#event Hostile "scowls at you, ready to attack"
#event SkinBuffs "Your skin returns to normal"
#event SoW "The spirit of wolf leaves you"
#event Regen "You have stopped regenerating"
#event MedTime "Insufficient Mana to cast this spell"
#event Fizzle "Your spell fizzles"
Sub Main
/echo $time() Starting $macro
/declare MobToHunt global
/declare Loot array
/declare Mob array
/declare MyXLOC global
/declare MyYLOC global
/declare KSRadius global
/declare NotSee global
/declare TooFar global
/declare MyTarget global
/declare TargetDead global
/declare HasTarget global
/declare ObstCount global
/declare LootSlot global
/declare CheckLoot global
/declare LootTotal global
/declare MobArraySize global
/declare RangeMax global
/declare RangeMin global
/declare FastRange global
/declare SnareRange global
/declare SpellCast global
/declare NeedBuff global
/declare RandomSpin global
/declare FailMax global
/declare FailCounter global
/declare RandomDelay global
/declare CurrentTarget global
/declare TargetSub global
/declare CurrentRadius global
/declare MaxRadius global
/declare CombatClickie global
/declare HostileNPC global
/press esc
/press esc
/press esc
/press esc
/press alt
/press shift
/press ctrl
/alert add 1 npc radius 20
/varset FailMax 3
/varset FailCounter 0
|set the max radius to hunt per cycle
/varset MaxRadius 3000
| if you have a combat clickie you'd like to use, put the item name here
| /varset CombatClickie "Celestial Fists"
/varset RangeMax 9
/varset RangeMin 3
/varset FastRange 11
/varset LootSlot 0
/varset CheckLoot 0
/varset NeedBuff FALSE
/varset SpellCast 0
| Items to Loot
/varset Loot(0) "silk"
/varset Loot(1) "quality"
/varset Loot(2) "egg"
/varset Loot(3) "zombie skin"
/varset Loot(4) "bear skin"
/varset Loot(5) "puma skin"
| /varset Loot(6) ""
| /varset Loot(7) ""
| /varset Loot(8) ""
| /varset Loot(9) ""
| /varset Loot(10) ""
|
| Targets to hunt - the lower subscript, the higher priority
/varset Mob(0) "kodiak"
/varset Mob(1) "bear"
/varset Mob(2) "spider"
/varset Mob(3) "lion"
/varset Mob(4) "plains"
/varset Mob(5) "wolf"
| /varset Mob(6) "rattle"
/varset Mob(7) "giant"
/varset Mob(8) "mocassin"
| /varset Mob(9) "widow"
| /varset Mob(10) "zombie"
/varset SnareRange 125
/varset KSRadius 200
/varset HasTarget 0
/varset ObstCount 0
| finding size of Loot array
/call ArraySize Loot
/varset LootTotal $return
/if LootTotal<0 {
/echo Nothing specified to loot! Just hunting specified mobs.
}
/echo Loot pool size $calc(@LootTotal+1)
| finding size of mob array
/call ArraySize Mob
/varset MobArraySize $return
/if MobArraySize<0 {
/echo Nothing specified to hunt! (you do know what this script is supposed to do,
right?)
/endmacro
}
/echo Mob list has $calc(@MobArraySize+1) entries
:Start
/if $gm==TRUE /endmacro
/doevents
/if @NeedBuff=="TRUE" /call BuffMe
/varset RandomSpin $rand(2)
/varcat RandomSpin "s"
/sendkey down left
/delay @RandomSpin
/sendkey up left
/delay 1s
/doability forage
/delay 1s
/if "$cursor(name)"~~"grubs" /destroy
/autoinventory
/call GetTarget
:KillAdds
/if @HasTarget=="1" /call MoveToMob
/if @HasTarget=="1" /call CombatSub
/if @HasTarget=="1" /call MoveToMob
/if (@HasTarget=="1" && @LootTotal>=0) /call LootMob
/if n $char(hp,pct)<=85 /call HealMe
/call ResetSub
/if $alert(1)==TRUE {
/echo Looks like we have adds...
/target npc radius 20
/if $target(type)=="npc" {
/varset MyTarget $target(id)
/varset TargetDead 0
/varset HasTarget 1
/varset MobToHunt $target(name)
/consider
/delay 1s
/doevents Hostile
/if @HostileNPC=="TRUE" {
/echo time to die $target(name,clean)
/goto :KillAdds
} else {
/echo False Alarm
/call ResetSub
}
}
}
| Random wait after kill (up to 5 seconds)
/varset RandomDelay $rand(5)
/varcat RandomDelay "s"
/echo Paranoia - Waiting @RandomDelay before resuming
/delay @RandomDelay
/goto :Start
/return
sub GetTarget
:Acquire
/for CurrentRadius 100 to @MaxRadius step 100 {
/for TargetSub 0 to @MobArraySize {
/target radius @CurrentRadius nopcnear @KSRadius npc "@Mob(@TargetSub)"
/varset MyTarget $target(id)
/varset TargetDead 0
/if n $target(id)!=0 {
/varset HasTarget 1
/varset MobToHunt $target(name)
/echo Acquired $target(name,clean) at range $target(distance) heading
$target(direction)
/return
}
/next TargetSub
}
/delay 2
/next CurrentRadius
}
/if n $target(id)==0 {
/delay 2s
/varadd FailCounter 1
/echo Failed to Acquire Target in range @MaxRadius @FailCounter times
/if n @FailCounter>=@FailMax {
/echo waiting for respawns, resetting failure count.
/delay 60s
/varset FailCounter 0
}
/goto :Acquire
}
/varset HasTarget 1
/varset MobToHunt $target(name)
/return
Sub MoveToMob
/face fast
/if n $target(distance)>=@FastRange /call Fastmove
/if n $target(distance)>@RangeMax {
/press up
}
/if n $target(distance)<@RangeMin {
/press down
}
/return
Sub Fastmove
/varset MyXLOC $char(x)
/varset MyYLOC $char(y)
/varset ObstCount 0
:fastmoveloop
/if $target()=="FALSE" {
/sendkey up up
/if $combat=="TRUE" {
/attack off
/return
}
}
/face fast
/if n $target(distance)>@FastRange {
/sendkey down up
}
/if n $target(distance)<=@FastRange {
/sendkey up up
/return
}
/varadd ObstCount 1
/if n @ObstCount>=3 {
/call CheckObst
}
/goto :fastmoveloop
/return
Sub SnareMob
:snare
/if n $target(distance)>@SnareRange {
/face fast
/sendkey down up
/goto :snare
}
/sendkey up up
/delay 1s
/cast 6
/varset SpellCast 6
/delay 3s
/doevents Fizzle
/return
sub CombatSub
/if $target()=="FALSE" {
/varset HasTarget 0
/return
}
/if $target(name)!~"skel" {
/sendkey up up
/delay 1s
/cast 6
/varset SpellCast 6
/delay 3s
/doevents Fizzle
}
/attack on
:combatloop
/face fast
| /call SpecialIt
/call MoveToMob
/face fast
/if n $target(id)==0 /varset TargetDead 1
/if n @TargetDead!=1 /goto :combatloop
/sendkey up up
/delay 1s
/target corpse
/return
sub LootMob
/fastdrop on
/lootn always
/delay 2s
/loot
/look 128
/delay 2s
| check and see if corpse is empty
/if $corpse(empty)=="TRUE" { /echo empty corpse /goto :doneloot }
:lootloop
/if n @LootSlot>=9 /goto :doneloot
/click left corpse @LootSlot
/delay 1s
/if "$cursor()"!="TRUE" /goto :doneloot
:lootChecker
/if "$cursor(name)"~~"@Loot(@CheckLoot)" {
/delay 1s
/echo Saving "$cursor(name)"
/autoinventory
/delay 1s
/varadd LootSlot 1
/goto :lootloop
}
/varadd CheckLoot 1
/if "$cursor()"=="TRUE" {
/if n @CheckLoot<=@LootTotal /goto :lootchecker
}
/if "$cursor()"=="TRUE" {
/delay 1s
/echo Attempting to Drop "$cursor(name)"
/click left 0 0
/delay 1s
/if "$cursor()"=="TRUE" {
/beep
/echo could not drop "$cursor(name)" Destoying
/destroy
}
}
/varadd LootSlot 1
/varset CheckLoot 0
/goto :lootloop
:doneloot
/fastdrop off
/look 0
/varset LootSlot 0
| check for adds
/target npc radius 10
/if $target(type)=="npc" :goto KillAdds
/return
sub ResetSub
/sendkey up up
/press esc
/press esc
/press esc
/press esc
/press alt
/press shift
/press ctrl
/varset CheckLoot 0
/varset HasTarget 0
/varset ObstCount 0
/varset HostileNPC FALSE
/delay 1s
/return
sub CheckObst
/if n @MyXLOC==$char(x) /if n @MyYLOC==$char(y) /call HitObst 5
/varset MyXLOC $char(x)
/varset MyYLOC $char(y)
/varset ObstCount 0
/return
sub HitObst
/sendkey up up
/sendkey down down
/if n $rand(99)>50 {
/delay 1s
/sendkey up down
/sendkey down Right
/delay @Param0
/sendkey up Right
/sendkey down up
/delay 2s
/sendkey up up
} else {
/delay 1s
/sendkey up down
/sendkey down left
/delay @Param0
/sendkey up left
/sendkey down up
/delay 2s
/sendkey up up
}
/sendkey up down
/sendkey up Right
/sendkey up Left
/sendkey down up
/return
Sub SpecialIt
/if ($char(class)==Rogue && n $char(ability,"Backstab")>0) {
/if $target()=="TRUE" {
/face fast
/doability "Backstab"
}
}
/if ($char(class)==Monk && n $char(ability,"Flying Kick")>0) {
/if $target()=="TRUE" {
/face fast
/doability "Flying Kick"
}
}
/if "@CombatClickie"!="" {
/cast item "@CombatClickie"
}
/return
| returns the last valid subscript of an array, returns -1 for failure or no size
Sub ArraySize(IncArray)
/declare ArrSize local
/declare ArrayCounter local
/if $defined(IncArray)!=FALSE {
/varset ArrSize 0
/for ArrayCounter 0 to 1 step 0 {
/if "@@IncArray(@ArrSize)"=="UNDEFINED-ARRAY-ELEMENT" {
/return $calc(@ArrSize-1)
}
/varadd ArrSize 1
/next ArrayCounter
}
}
/return -1
Sub Event_AFKTell
/beep /beep /beep /delay 1s /beep /beep /beep
/return
Sub Event_SkinBuffs
/varset NeedBuff TRUE
/return
Sub Event_SoW
/if n $char(speed)!=0 /press down
/press f1
/delay 1s
/cast 8
/varset SpellCast 8
/delay 6s
/doevents Fizzle
/press esc
/return
Sub Event_Regen
/if n $char(speed)!=0 /press down
/press f1
/delay 1s
/cast 1
/varset SpellCast 1
/delay 8s
/doevents Fizzle
/press esc
/return
Sub BuffMe
/if n $char(speed)!=0 /press down
/press f1
/delay 1s
/cast 2
/varset SpellCast 2
/delay 10s
/doevents Fizzle
/cast 3
/varset SpellCast 3
/delay 10s
/dovents Fizzle
/cast 5
/varset SpellCast 5
/delay 6s
/dovents Fizzle
/varset NeedBuff FALSE
/press esc
/return
Sub HealMe
/press f1
:heal
/if n $char(speed)!=0 /press down
/if n $char(hp,pct)<=85
{
/delay 1s
/cast 4
/delay 5s
/goto :heal
} /press esc
/return
Sub Event_MedTime
:med
/if n $char(mana,pct)<=85
{
/sit
/goto :med
}
/return
Sub Event_Fizzle
/if n @SpellCast==1 {
/press f1
/delay 1s
/cast 1
/varset SpellCast 1
/delay 8s
/doevents Fizzle
/press esc
}
/if n @SpellCast==2 {
/press f1
/delay 1s
/cast 2
/varset SpellCast 2
/delay 10s
/doevents Fizzle
/press esc
}
/if n @SpellCast==3 {
/press f1
/delay 1s
/cast 3
/varset SpellCast 3
/delay 10s
/doevents Fizzle
/press esc
}
/if n @SpellCast==5 {
/press f1
/delay 1s
/cast 5
/varset SpellCast 5
/delay 6s
/doevents Fizzle
/press esc
}
/if n @SpellCast==6 {
/delay 1s
/cast 6
/varset SpellCast 6
/delay 3s
/doevents Fizzle
}
/if n @SpellCast==8 {
/press f1
/delay 1s
/cast 8
/varset SpellCast 8
/delay 6s
/doevents Fizzle
/press esc
}
/return
Sub Event_InvFull
/beep /delay 1s
/beep /delay 2s
/beep /delay 1s
/beep
/endmacro
/return
Sub Event_Hostile
/varset HostileNPC "TRUE"
/return
Sub Event_Died
/declare BeepCounter local
/for BeepCounter 0 to 10 {
/beep /delay 3
/next BeepCounter
}
/endmacro
/return

