Moderator: MacroQuest Developers

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 "AFK Message:"
#event InvFull "no room to put that!"
#event Died "you have entered"
#event Hostile "scowls at you, ready to attack"
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 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 2
/varset FastRange 11
/varset LootSlot 0
/varset CheckLoot 0
| Items to Loot
/varset Loot(0) "silk"
/varset Loot(1) "quality"
/varset Loot(2) "snake egg"
| /varset Loot(3) ""
| /varset Loot(4) ""
| /varset Loot(5) ""
| /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) "widow"
/varset Mob(1) "wolf"
/varset Mob(2) "spider"
/varset Mob(3) "moccasin"
/varset Mob(4) "tiger"
/varset Mob(5) "leopard"
/varset Mob(6) "snake"
/varset Mob(7) "hopper"
/varset Mob(8) "lion"
| /varset Mob(9) ""
| /varset Mob(10) ""
/varset KSRadius 60
/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
/doevents
/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
/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 2
/doevents
/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 CombatSub
/if $target()=="FALSE" {
/varset HasTarget 0
/return
}
/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)" putting into inventory
/autoinventory
}
}
/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 /delay 1s /beep
/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
