GrimJack's Hunter.mac v2.1 modification

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

crisdan
a ghoul
a ghoul
Posts: 126
Joined: Mon Mar 24, 2003 1:56 pm

GrimJack's Hunter.mac v2.1 modification

Post by crisdan » Thu Oct 30, 2003 10:25 am

First off the below code belongs to the one and only Grimjack. My quick question is I choose the code to use as my template for a melee script I want to modify for my lowbie toon; Does the below code represent MQ version 2 code?

I just want to make sure as I am trying to learn and create at the same time via by example. If it is then I will continue this thread with my coding attempts. If not can someone name a *.mac that is in the depot that is an example of a melee type script the is designed with mq version 2 in mind?

Thank you


| hunter.mac
| v2.1
| 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 MainArray(1,0) "silk" and /varset MainArray(1,1) "skin"
| Also edit /varset MainArray(2,0) "widow" and /varset MainArray(2,1) "wolf"
| You can also make these arrays bigger. If you want to search for
| wolfs, widows and orcs you would have this
| /varset MainArray(2,0) "widow"
| /varset MainArray(2,1) "wolf"
| /varset MainArray(2,2) "orc"
| /varset MobArraySize 3
| This picks a random number based on MobArraySize to pick which
| Type of mob it will chose from the array.
|
| What type of loot you want can be expanded in a similar way to
| the mobs you want to hunt. Just add your array entry and update
| /varset LootTotal 2 to be /varset LootTotal [# of loot entries]
|
| Another thing, for the code to actualy destroy items you don't want to
| keep you must have fast item destroy turned on in the game. I would
| test the script for a while on your machine before doing this. It would
| really suck if it picks up your Eyepatch of Plunder and destroies it
| due to a bug.


Sub Main
/declare MobToHunt global
/declare MainArray array2
/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 AttackRange global
/declare MobArraySize global
/declare WaitForAdds global
/press esc
/press esc
/press esc
/press esc
/press alt
/press shift
/press ctrl
/varset RangeMax 12
/varset RangeMin 10
/varset AttackRange 15
/varset LootSlot 0
/varset CheckLoot 0
/varset KSRadius 60
/varset HasTarget 0
/varset ObstCount 0
/varset WaitForAdds 1
| Add as many of these as you want but make sure you increase LootTotal
/varset LootTotal 2
/varset MainArray(1,0) "silk"
/varset MainArray(1,1) "quality"
| Add as many of these as you want but make sure you increase MobArraySize
/varset MobArraySize 12
/varset MainArray(2,0) "griffawn"
/varset MainArray(2,1) "wolf"
/varset MainArray(2,2) "lioness"
/varset MainArray(2,3) "stalker"
/varset MainArray(2,4) "lion"
/varset MainArray(2,5) "hound"
/varset MainArray(2,6) "gnoll"
/varset MainArray(2,7) "reaver"
/varset MainArray(2, "werewolf"
/varset MainArray(2,9) "spiderling"
/varset MainArray(2,10) "bear"
/varset MainArray(2,11) "kodiak"

:Start
/call GetTarget
/if @HasTarget==1 /call MoveToMob
/if @HasTarget=="1" /call CombatSub
/if @HasTarget=="1" /call MoveToMob
/if @HasTarget=="1" /call LootMob
/call ResetSub
/goto :Start
/return

Sub GetTarget
/declare MobNumber local
/declare NumberOfMobsFound local
/declare CurrentMobToCheck local
/declare ClosestMob local

/varset TargetDead 0

:Aquire

|Wait 3 seconds to see if you have an add on you
/if @WaitForAdds==1 {
/delay 3s
/if n $target(id)!=0 /goto :HaveMob
/if $target()!="False" /goto :HaveMob
}

|Check if your pet is attacking anything
/if $char(pet)!=0 {
/target id $char(pet)
/assist %t
/if n $target(id)==$char(pet) /goto :PetDoesntHaveTarget
/if n $target(hp,cur)<1 /goto :PetDoesntHaveTarget
}

|Loop through the mob list and get the distance of every mob
:PetDoesntHaveTarget

/varset MobNumber "0"
/varset NumberOfMobsFound 0

:MobListCycle
/target nopcnear @KSRadius npc "@MainArray(2,@MobNumber)"
/if $target()!="False" {
/varset MainArray(3,@NumberOfMobsFound) $target(id)
/varadd NumberOfMobsFound 1
}
/varadd MobNumber 1
/if n @MobNumber==@MobArraySize /goto :DoneMobListCycle
/goto :MobListCycle
:DoneMobListCycle

|Do a check to see which mob in the mobs list is the closest
/varset CurrentMobToCheck 0
/varset ClosestMob 0

:MobListClosest
/if n $spawn(@MainArray(3,@CurrentMobToCheck),distance)<$spawn(@MainArray(3,@ClosestMob),distance) {
/varset ClosestMob @CurrentMobToCheck
}
/varadd CurrentMobToCheck 1
/if n @CurrentMobToCheck==@NumberOfMobsFound /goto :DoneMobListClosest
/goto :MobListClosest
:DoneMobListClosest

/target id @MainArray(3,@ClosestMob)
/varset MyTarget $target(id)

/if n $target(id)==0 /goto :Aquire
/if $target()=="False" /goto :Aquire

:HaveMob
/varset HasTarget 1
/varset MobToHunt $target(name)
/return

sub MoveToMob
/if n $target(distance)<=@AttackRange {
/face fast look nopredict
/return
}
/sendkey down up
:Movementloop
/delay .5s
/varset MyXLoc $char(x)
/varset MyYLoc $char(y)
/varadd ObstCount 1
/if $target()=="FALSE" {
/varset HasTarget 0
/return
}
/face fast look nopredict
/if n $target(distance)<=@AttackRange {
/face fast look nopredict
/sendkey up up
/return
}
/if @ObstCount>=3 {
/call CheckObst
/goto :Movementloop
}
/if n $target(distance)>@AttackRange /goto :MovementLoop
/doability "sneak"
/return

Sub CombatSub
/if $target()=="FALSE" {
/varset HasTarget 0
/return
}
:CombatLoop
/attack on
:CombatMove
/delay .5s
/varset MyXLoc $char(x)
/varset MyYLoc $char(y)
|Check if we still have target to chase
/if n $target(id)==0 /goto :WeKilledIt
|Check if we are in range
/if n $target(distance)>=@AttackRange {
/face fast look nopredict
/sendkey down up
/goto :CombatMove
}

/varadd ObstCount 1

/face fast look nopredict
/if n $target(distance)<=@AttackRange {
/face fast look nopredict
/sendkey up up
/goto :InAttackRange
}
/if @ObstCount>=3 {
/call CheckObst
/goto :CombatMove
}
/if n $target(distance)>@AttackRange /goto :CombatMove
:InAttackRange
/if n @TargetDead!=1 /goto :CombatLoop

:WeKilledIt
/sendkey up up
/return

Sub LootMob
/varset LootSlot 0
/delay 1s
/target corpse
/delay 1s
/loot
|Wait for loot window to come up
/delay 2s

:lootloop
/lootn never
/if n @LootSlot>=9 /goto :doneloot
/click left corpse @LootSlot
/delay 1s
/if "$cursor()"!="TRUE" /goto :doneloot

:lootChecker
/if "$cursor(name)"~~"@MainArray(1,@CheckLoot)" {
/delay 1s
/click left auto
/delay 1s
/varadd LootSlot 1
/goto :lootloop
}
/varadd CheckLoot 1
/if "$cursor()"=="TRUE" {
/if n @CheckLoot<@LootTotal /goto :lootchecker
}
/if "$cursor()"=="TRUE" {
/delay 1s
/click left destroy
/delay 1s
}
/varadd LootSlot 1
/varset CheckLoot 0
/goto :lootloop
:doneloot
/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
/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 3s
/sendkey up down
/sendkey down Right
/delay @Param0
/sendkey up Right
/sendkey down up
/delay 3s
/sendkey up up
} else {
/delay 3s
/sendkey up down
/sendkey down left
/delay @Param0
/sendkey up left
/sendkey down up
/delay 3s
/sendkey up up
}
/sendkey up down
/sendkey up Right
/sendkey up Left
/sendkey down up
/return

Sub BackstabIt
/if n $char(ability,"Backstab")!=-2 {
/if $target()=="TRUE" {
/face fast nopredict
/doability "Backstab"
}
}
/return

boredom
a lesser mummy
a lesser mummy
Posts: 49
Joined: Thu Jun 19, 2003 3:45 pm

Post by boredom » Thu Oct 30, 2003 3:31 pm

This appears to be an up-to-date macro, I'm asuming by version 2 you mean the variable changes. Good luck on learning, and don't get discouraged (except maybe by a GM).

/bored

P.S. A helpful hint is to place code in code brackets so that it stands out

Code: Select all

 like this
just press the code button below your subject line when posting to find out how.

crisdan
a ghoul
a ghoul
Posts: 126
Joined: Mon Mar 24, 2003 1:56 pm

Post by crisdan » Fri Oct 31, 2003 12:07 am

Thanks boredom. Every little bit helps :>

Guest

Post by Guest » Fri Oct 31, 2003 11:08 am

/face fast look nopredict will bite you in the ass. I think the devs defaulted /face to no predict so it is no longer and option. Find all the /face fast look nopredict lines and change them to /face fast look

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

Post by Mckorr » Fri Oct 31, 2003 11:13 am

nopredict is the default. Use /face fast look. If you want prediction specify "predict".
MQ2: Think of it as Evolution in action.