I was scowering merchants all over PoK and PoTranquility for Blue Diamonds tonight and got tired of scrolling through the window manually, so I wrote a little macro. When you start it, you specify an Item Name to look for and you can also define an optional limit to stop at. If no limit is defined, it will continue buying the item until the merchant has no more.
Tell me what you think.
- Update: 1/25/04 -
-----------------------
The macro now has an option to make it search through all of the merchants in the zone. However, if merchants are inside buildings it will propably not work at all, so if anyone would volunteer to fix up the code to account for this that would be great.
Code: Select all
| - merch_check.mac -
| By: Onezero
| Version: 0.0.2
|
| This macro goes through the list of merchants in the zone and checks
| them all for a user-specified item. If Search = 1 the macro will
| check all merchants in the zone once, then end. If Search = 0 the
| macro will only check the nearest merchant. User can also specify a
| limit to tell the macro when to stop buying the item.
|
| NOTE: This macro does NOT work well right now unless the zone you are
| in has very few buildings/obstructions. If anyone could fix that
| part up for me I would be most grateful, until then, it sucks :)
|
| Usage: /mac merch_check.mac <item name> <search (Default=1)> <limit>
|
| Example: /mac merch_check.mac "Blue Diamond" 1 5
| (Goes to all merchants and buys up to 5 Blue Diamond from each)
|
| /mac merch_check.mac "Water Flask" 0 20
| (Goes to nearest merchant and buys 20 Water Flask)
#turbo
#event nocash "You cannot afford "
Sub Main(ItemName,Search,Limit)
/zapvars
/declare count local
/varset count 0
/declare counter local
/declare curID local
/varset curID 0
/declare retry local
/varset retry -1
/declare ids array2
/declare idcount local
/varset idcount 0
/echo Looking for @ItemName
/if $defined(ItemName)==FALSE /endmacro
/if $defined(Search)==FALSE {
/echo Searching all merchants.
} else {
/if n @Search==1 /echo Searching all merchants.
/if n @Search!=1 /echo Only checking nearest merchant.
}
/if $defined(Limit)==TRUE {
/echo Buy Limit: @Limit
} else {
/echo No buy limit defined!
}
:MainLoop
/if n @retry>=@idcount {
/echo All merchants have been searched. Ending macro.
/endmacro
}
/if n @Search==1 {
/if n @curID==0 {
/varset curID $searchspawn(npc,class:merchant)
/varadd idcount 1
} else {
/varset curID $searchspawn(npc,id:@curID,class:merchant,next)
/varadd idcount 1
}
} else {
/target npc class merchant
/varset curID $target(id)
}
/echo Heading to $spawn(@curID,name,clean)
/for counter 0 to @idcount
/if n @curID==@ids(0,@counter) {
/varadd retry 1
/if n @Search==1 {
/goto :MainLoop
} else {
/goto :MacDone
}
}
/next counter
/varset ids(0,@idcount) @curID
/target npc id @curID
/call movetoloc $target(y),$target(x)
/click right target
/delay 15
/if $merchant(open)==FALSE {
/echo Could not open merchant window for $spawn(@curID,name,clean).
/if n @Search==1 {
/echo Moving on...
/goto :MainLoop
} else {
/goto :MacDone
}
}
/if $merchant(has,"@ItemName")==FALSE {
/echo Couldn't find @ItemName on $spawn(@curID,name,clean).
/click left merchant done
/if n @Search==1 {
/echo Moving on...
/goto :MainLoop
} else {
/goto :MacDone
}
} else {
:BuyLoop
/doevents
/if $merchant(has,"@ItemName")==TRUE {
/selectitem "@ItemName" merchant
/if $defined(Limit)==TRUE {
/if n @count<@Limit {
/call BuyItem @ItemName @Limit
/varadd count 1
/goto :BuyLoop
}
} else {
/call BuyItem @ItemName @Limit
/varadd count 1
/goto :BuyLoop
}
}
/click left merchant done
/echo Bought $int(@count) @ItemName from $spawn(@curID,name,clean).
/if n @Search==1 {
/echo Moving on...
/goto :MainLoop
} else {
/goto :MacDone
}
}
:MacDone
/sendkey up ctrl
/sendkey up shift
/sendkey up alt
/return
Sub BuyItem(ItemName,Limit)
/sendkey down ctrl
/click left merchant buy
/delay 1s
/sendkey up ctrl
/return
Sub Event_nocash
/echo Not enough money. Ending macro.
/click left merchant done
/endmacro
/return
Sub movetoloc(xloc,yloc)
/declare MyXLOC local
/declare MyYLOC local
/declare ObstCount local
/varset MyXLOC $char(x)
/varset MyYLOC $char(y)
/varset ObstCount 0
:locloop
/face nolook loc @xloc
/if "@yloc"=="u" /Press u
/call AutoRun 1
/varadd ObstCount 1
/if n @ObstCount>=3 {
/if n @MyXLOC==$char(x) /if n @MyYLOC==$char(y) {
/sendkey up up
/sendkey down down
/if n $rand(99)>50 {
/delay 1s
/sendkey up down
/sendkey down Right
/delay 5
/sendkey up Right
/sendkey down up
/delay 1s
/sendkey up up
} else {
/delay 1s
/sendkey up down
/sendkey down left
/delay 5
/sendkey up left
/sendkey down up
/delay 1s
/sendkey up up
}
/sendkey up down
/sendkey up Right
/sendkey up Left
}
/varset MyXLOC $char(x)
/varset MyYLOC $char(y)
/varset ObstCount 0
}
/if n $distance(@xloc)>10 /goto :locloop
}
/call autorun 0
/return
Sub AutoRun
/if @Param0==1 /sendkey down up
/if @Param0==0 /sendkey up up
/return
