Well... This is sort of the by-product of some work I'm dooing to fully automate my tribute finder, make it buy as well
Im gonna call it Run To Bazaar Merchant .mac...
Use like:
Code: Select all
/mac bazaarfind traderjoeCode: Select all
/mac bazaarfindIm going to have to hack it a lil for my tribute macro, I want it to search while it is running to a merchant and back, then stuff any found items in to an array
I'm probably going to tweak this a lil, make it work for barter traders too, and get it to run from anywhere, not just Banker Denton
Could make this an include file, I may finish this, then port it to an include...
But anyway, the code:
Code: Select all
| bazaarFind.mac
|
| v0.1 - 31 May 2007
| by zoobish
|
| DESCRIPTION: Runs to the bazaar player merchant specified in the
| parameters. Then waits for trigger to run back
| to banker...
| Doesn't work for Barter.. maybe later...
|
| USAGE: /macro bazaarFind <merchant-name>
| e.g. /macro bazaarFind Liltrader
|
| If run without an argument, it will look to see if
| you have a target, and find them, random results if
| target is not a trader...
|
| Start in The Bazaar, trader middle section, next
| to Banker Denton. I may tweak this later to run you
| to the merchant from anywhere in bazaar, including
| barter merchant.
|
| REQUIREMENTS: Must have bazaar.loc file in Macro directory.
|
#turbo
#event backToBanker "#*#BF: done with merchant#*#"
Sub main
| Finds a path to a baz player merchant, and runs there...
/declare mRoom int outer
/declare mName string outer
/declare locFileName string outer bazaar.loc
/declare currentRoom string outer 0
/declare merchFoundAt int outer 0
/declare backToBank bool outer FALSE
/declare isFast string outer
| Set target...
/if ( !${Defined[Param0]} ) {
/if ( !${Target.ID} ) {
| EXIT, no target...
/echo BAZAARFIND.MAC(main): Must supply a name to goto, or have the merchant targeted.
/return
}
/varset mName ${Target.CleanName}
} else {
/varset mName ${Param0}
}
/target clear
/target ${mName}
/delay 5 ( ${Target.ID} )
/if ( !${Target.Trader} ) {
/echo BAZAARFIND.MAC(main): Target must be a trader... Aborting.
/return
}
| Determine what room merchant is in.
/call whatRoom
/varset mRoom ${Macro.Return}
| Run to room.
/call runToMerchant
/echo BAZAARFIND.MAC(main): Done, back at banker...
| DONE
/return
|=============================================================================
| Determines which room merchant is in. If unable to find, it
| will return NULL, else the room number.
Sub whatRoom
/declare X int local
/declare Y int local
/declare i int local
/declare minDist int local 10000
/declare minRoom int local 0
| Room information... "name" and mid("Y X")
| Haha, its outer... Does it exist b4 this is called? NO!!!
/declare rooms[8,2] string outer
/varset rooms[1,1] Gold
/varset rooms[2,1] Platinum
/varset rooms[3,1] Ruby
/varset rooms[4,1] Emerald
/varset rooms[5,1] Sapphire
/varset rooms[6,1] Diamond
/varset rooms[7,1] Copper
/varset rooms[8,1] Silver
/varset rooms[1,2] 1052 -1231
/varset rooms[2,2] 895 -1061
/varset rooms[3,2] 784 -779
/varset rooms[4,2] 954 -622
/varset rooms[5,2] 1236 -510
/varset rooms[6,2] 1393 -680
/varset rooms[7,2] 1506 -964
/varset rooms[8,2] 1334 -1118
| Obtain target
/target ${mName}
/delay 5s ( ${Target.ID} )
/if ( !${Target.ID} ) {
/echo BAZAARFIND.MAC(whatRoom): no target obtained.
/return NULL
}
| Get loc
/varset X ${Target.X}
/varset Y ${Target.Y}
| Decide which room...
/for i 1 to 8
/call distCalc ${rooms[${i},2]} ${Y} ${X}
/if ( ${minDist} > ${Macro.Return} ) {
/varset minDist ${Macro.Return}
/varset minRoom ${i}
}
/next i
/echo BAZAARFIND.MAC(whatRoom): Merchant in ${rooms[${minRoom},1]}
/return ${minRoom}
|=============================================================================
| Runs to the specified merchant.
Sub runToMerchant
/declare rName string local room${rooms[${mRoom},1]}
/declare count int local ${Ini[${locFileName},${rName},"index"]}
/declare i int local
/declare j int local 1
/declare X int local
/declare Y int local
/declare locs[${count}] string local
/declare increment int local 1
/declare startLOS int local
/declare orBank bool local FALSE
/varcalc startLOS ${count} - 6
| Load locs...
/for i 1 to ${count}
/varset locs[${i}] ${Ini[${locFileName},${rName},${i}]}
/next i
/varset Y ${locs[${j}].Arg[1]}
/varset X ${locs[${j}].Arg[2]}
| Run to room... then back to banker
/for i 1 to 2
/call amIClose ${Y} ${X}
/if ( ${Macro.Return} ) {
/varcalc j ${j} + ${increment}
/if ( ${j} > ${count} || ${j} < 1 ) {
| We are here =)
/keypress forward
| Decide if at merchant or banker.
/if ( !${orBank} ) {
/echo BAZAARFIND.MAC(runToMerchant): At merchant...
/call waitTillDone
} else {
| Done if here, returned to banker.
/return
}
/varset backToBank FALSE
/varset orBank TRUE
/varset count ${Ini[${locFileName},${rName},"index"]}
/varset increment -1
/varcalc j ${j} - 1
}
| Set the current target loc...
/varset Y ${locs[${j}].Arg[1]}
/varset X ${locs[${j}].Arg[2]}
}
| Check if we see the merchant, if running there...
/varset isFast
/if ( !${orBank} ) {
/if ( ${j} > ${startLOS} ) {
/if ( ${Target.LineOfSight} ) {
/if ( ${Target.Distance} < 60 ) {
| Run to merchant
/varset Y ${Target.Y}
/varset X ${Target.X}
/varset count ${j}
}
}
}
} else {
/if ( ${j} > ${startLOS} ) {
/varset isFast fast
}
}
/face ${isFast} nolook loc ${Y},${X}
/keypress forward hold
/varset i 1
| REMOVE THIS DELAY IF YOU HAVE A SLOW COMPUTER!!
/delay 1
/next i
/return
|=============================================================================
| Waits till trigger for return to banker...
Sub waitTillDone
:BF_START_WAIT
/doevents backToBanker
/if ( ${backToBank} ) /return
/delay 5
/goto :BF_START_WAIT
/return
|=============================================================================
| Resets flag to run back to banker...
Sub Event_backToBanker
/varset backToBank TRUE
/return
|=============================================================================
| Returns TRUE if loc within 5 units...
Sub amIClose(int YY, int XX)
/call distCalc ${YY} ${XX} ${Me.Y} ${Me.X}
/if ( ${Macro.Return} < 5 ) /return TRUE
/return FALSE
|=============================================================================
| Basic distance between 2 points
Sub distCalc(float x1, y1, x2, y2)
/declare xq float local
/declare yq float local
/declare ans float local
/varcalc xq ${x1}-${x2}
/varcalc yq ${y1}-${y2}
/varcalc ans ${Math.Sqrt[((${xq}*${xq})+(${yq}*${yq}))]}
/return ${ans}Code: Select all
# bazaar.loc
# v0.1
#
# locs for navigating the bazaar trader section, barter to come...
#
[roomCopper]
index=9
1=1184.79 -829.87
2=1202.29 -880.75
3=1208.56 -941.19
4=1365.14 -1097.56
5=1454.48 -1014.72
6=1466.89 -930.89
7=1531.49 -930.89
8=1537.26 -998.01
9=1466.70 -1007.58
[roomSilver]
index=10
1=1184.79 -829.87
2=1210.53 -886.28
3=1145.76 -947.92
4=1146.90 -1095.48
5=1213.39 -1123.97
6=1275.49 -1118.61
7=1329.06 -1073.50
8=1372.91 -1117.35
9=1327.65 -1171.11
10=1278.58 -1120.82
[roomGold]
index=10
1=1184.79 -829.87
2=1207.06 -887.64
3=1158.84 -924.32
4=1076.47 -933.41
5=920.36 -1095.21
6=1007.33 -1185.87
7=1078.82 -1189.18
8=1085.72 -1259.26
9=1014.01 -1261.88
10=1010.13 -1190.34
[roomPlatinum]
index=10
1=1184.79 -829.87
2=1123.30 -807.14
3=1054.36 -869.75
4=920.91 -873.87
5=890.75 -928.66
6=895.88 -998.44
7=939.59 -1045.00
8=904.48 -1101.92
9=847.74 -1057.64
10=891.29 -1000.39
[roomRuby]
index=9
1=1184.79 -829.87
2=1147.21 -808.25
3=1081.90 -805.84
4=923.04 -649.02
5=830.11 -733.35
6=830.64 -799.43
7=757.53 -814.96
8=752.69 -739.99
9=823.55 -736.50
[roomEmerald]
index=9
1=1184.79 -829.87
2=1144.91 -782.55
3=1140.59 -648.00
4=1106.73 -620.21
5=1012.49 -620.18
6=965.45 -671.39
7=909.31 -621.75
8=961.46 -573.29
9=1016.85 -616.51
[roomSapphire]
index=7
1=1184.79 -829.87
2=1366.06 -648.58
3=1282.72 -556.70
4=1209.18 -554.22
5=1206.22 -481.13
6=1277.13 -479.38
7=1279.35 -550.74
[roomDiamond]
index=9
1=1184.79 -829.87
2=1235.94 -872.62
3=1374.42 -864.48
4=1395.84 -812.74
5=1394.97 -742.62
6=1342.94 -692.72
7=1390.77 -638.04
8=1444.93 -689.06
9=1394.72 -740.40
If yah got a slow computer, remove the /delay at the end of runToMerchant subroutine...

