bazaar.mac - Complete Bazaar Buy and Sell Script

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

User avatar
driftinsupra
Official loudmouth
Official loudmouth
Posts: 212
Joined: Tue Jan 28, 2003 9:25 pm

bazaar.mac - Complete Bazaar Buy and Sell Script

Post by driftinsupra » Fri Dec 12, 2003 2:25 pm

The script is pretty basic as of right now. It reads from an ini file the names of items and the price that I can get from a merchant for them. Then it will search the bazaar for any of those items that are under what you can get for them when selling to a merchant.

Ok this script isnt perfect and at some times it freaks out a little bit but so far its pretty good and I havent run int any problems. For movemtn the home position is set as the bottom left corner of the zone at 132,-840. I used a few things that are still sort of new to me such as the ini files and the bazaar commands so there is probably a better way to do everything in my script but whatever, if it aint broke dont fix it. Although if you do see something that would actually work better then let me know.

To run the script your gonna need three things. Your gonna have to have the bazaar plugin and have it loaded. Also in this script I use two subroutines for movement that I have in my routines.mac files. I will post those at the bottom. Also you will have to create a ini file for yourself. Here is a sample of how to se it up.

v2 changes
-fixed patthing....added the walkmacro subroutine so that movement is natural and changed somethings so that you get to the right isle (a few of the if statements were messed ip. However if you dont want to make you own path.ini file then you will need to get mine and since it is too big to just copy here you can download it from my webspace. http://www.wsu.edu/~ellyson/path.ini
-edited out the .00 in the ini files 2 instead of 2.00 should work now.
-built all the subroutines you will need into the script so that noone will PM asking for more routines.
-Cleaned up the codea little....but I still got some work to do on it.

Code: Select all

[names] /this is where all the names of the items you will be looking for
val1=words of poop
val2=rune of crap
val3=page of diareah

/I could probably make it so you dont have to have the .00 after every item past 1 but...it doesnt bother me so I dont care/

[prices] /this is were you put the sell back value of the items above
val1=1000 /sellback value of words of poo 1pp
val2=3456 /sellback value of rune of crap 3pp 4gp 5sp 5cp
val3=234 /sellback value of  rune of diareah 2gp 3sp 4cp
Ok the only thing you will have to edit in this part of the actuall script is the /varset command at the very beggining which has the location fo your ini file.

Code: Select all

|Driftinsupra's first usefull macro bazarr.mac
|Dumpster diving script. Buy from players and sell to merchants for a profit!

#turbo 

sub main 

/declare file global
/declare isle global
/declare counter local
/declare l1 local 
/declare traderid local 
/declare price local 

/varset file C:\macroquest2\release\macros\newini.ini
/varset counter 1
:mainloop

/if "$ini(@file,names,val@counter)"=="NOTFOUND" {
    /echo Starting search over
    /varset counter 1
    /goto :mainloop
    }
/echo searching for $ini(@file,names,val@counter) 
/bzsrch race any class any $ini(@file,names,val@counter) 

| is request done? 
:loop 
/delay 1  
/if "$bazaar()"=="FALSE" /goto :loop 

/if n $bazaar(count)==0 { 
    /echo $ini(@file,names,val@counter) not found, continuing on...
    /varadd counter 1 
    /varset counter $int(@counter)
    /goto :mainloop
    }
     
} else { 
    /echo found $bazaar(count) items 
} 

/varset price $bazaar(0,price) 
/varset traderid $bazaar(0,trader) 

/if n $bazaar(count)>1 { 
    /for l1 1 to $calc($bazaar(count)-1) 
        /echo @l1 price $bazaar(@l1,price) 
        /if n @price>$bazaar(@l1,price) { 
            /varset price $bazaar(@l1,price) 
            /varset traderid $bazaar(@l1,trader) 
        } 
    /next l1 
} 
/if n @price>=$ini(@file,prices,val@counter) {
    /varadd counter 1
    /varset counter $int(@counter)
    /echo @counter
    /goto :mainloop
    }
/echo targeting @traderid 
/target id @traderid 
/face 
/call traderisle $target(x) $target(y)
/call movetoisle @isle
/face
/call movetotarg 10
/click right target
/delay 20
/call buyitem "$ini(@file,names,val@counter)"
/call moveback @isle
/call walkpath merch 10
/target "Merchant Tekram"
/face
/delay 10
/click right target
/delay 20
/selectitem "$ini(@file,names,val@counter)" self
/sendkey down shift
/click left merchant sell
/sendkey up shift
/delay 20
/click left merchant done
/call walkpath merchb 10
/goto :mainloop
/return


Sub movetoisle(isle)
   /if n @isle==61 /call walkpath 61 10 
   /if n @isle==62 /call walkpath 62 10
   /if n @isle==81 /call walkpath 81 10
   /if n @isle==82 /call walkpath 82 10
   /if n @isle==91 /call walkpath 82 10
   /if n @isle==92 /call walkpath 92 10
   /if n @isle==51 /call walkpath 51 10
   /if n @isle==52 /call walkpath 52 10
   /if n @isle==21 /call walkpath 21 10
   /if n @isle==22 /call walkpath 22 10
   /if n @isle==31 /call walkpath 31 10
   /if n @isle==32 /call walkpath 32 10
   /return

Sub traderisle(xloc,yloc)
   /if n @xloc>95 /if n @xloc<129 /if n @yloc>-770 /if n @yloc<-589 /varset isle 61
   /if n @xloc<95 /if n @xloc>62 /if n @yloc>-770 /if n @yloc<-589 /varset isle 62
   /if n @xloc>-104 /if n @xloc<-72 /if n @yloc>-772 /if n @yloc<-590 /varset isle 81
   /if n @xloc<-104 /if n @xloc>-145 /if n @yloc>-772 /if n @yloc<-590 /varset isle 82
   /if n @xloc>-203 /if n @xloc<-171 /if n @yloc>-713 /if n @yloc<-527 /varset isle 91
   /if n @xloc<-203 /if n @xloc>-250 /if n @yloc>-713 /if n @yloc<-527 /varset isle 92
   /if n @xloc>-118 /if n @xloc<107 /if n @yloc<-541 /if n @yloc>-571 /varset isle 51
   /if n @xloc>-118 /if n @xloc<107 /if n @yloc>-541 /if n @yloc<-514 /varset isle 52
   /if n @xloc>95 /if n @xloc<129 /if n @yloc>-495 /if n @yloc<-296 /varset isle 21
   /if n @xloc<95 /if n @xloc>62 /if n @yloc>-495 /if n @yloc<-296 /varset isle 22
   /if n @xloc>-104 /if n @xloc<-72 /if n @yloc>-495 /if n @yloc<-296 /varset isle 31
   /if n @xloc<-104 /if n @xloc>-145 /if n @yloc>-495 /if n @yloc<-296 /varset isle 32
   
   /return


Sub moveback(isle)
   /if n @isle==61 /call walkpath 61b 10 
   /if n @isle==62 /call walkpath 62b 10
   /if n @isle==81 /call walkpath 81b 10
   /if n @isle==82 /call walkpath 82b 10
   /if n @isle==91 /call walkpath 82b 10
   /if n @isle==92 /call walkpath 92b 10
   /if n @isle==51 /call walkpath 51b 10
   /if n @isle==52 /call walkpath 52b 10
   /if n @isle==21 /call walkpath 21b 10
   /if n @isle==22 /call walkpath 22b 10
   /if n @isle==31 /call walkpath 31b 10
   /if n @isle==32 /call walkpath 32b 10
   /return


sub buyitem(item)
   /sendkey down Ctrl
   /selectitem "@item" merchant
   /click left merchant buy
   /delay 20
   /sendkey up Ctrl
   /click left merchant done
   /return

Sub walkpath 
    |Initialization 
    
    |Note -- Edit the following line to represent the full path where you want your Paths.ini file 
    |        to be stored. Like: "c:\macroquest\macros\data\Paths.ini" 
    /declare gINIFile local 
    /declare gPathNumber local 
    /declare gStartPoint local 
    /declare gEndPoint local 
    /declare gStep local 
    /declare gThreshold local 
    /declare tEchoTimer timer 
    /declare l0 local 
    /declare l1 local 
    /declare l2 local 
    /declare l3 local 
    /declare pointface local

    /declare MyXLOC local 
    /declare MyYLOC local 
    /declare ObstCount local    

    /varset gINIFile "C:\macroquest2\release\macros\path.ini" 
    
    /varset gPathNumber @Param0 
    
    /varset gThreshold @Param1 
    /varset gStartPoint @Param2 
    /varset gEndPoint @Param3 
    /varset pointface 0
    
    /if @gThreshold=="" { 
        /echo No Threshold specified -- using 3. 
        /varset gThreshold 2 
    } 
    
    /if n @gStartPoint==0 { 
        /varset gStartPoint 1 
        /varset gEndPoint $int($ini("@gINIFile","@gPathNumber","numpoints")) 
    } 
    
    /if n @gStartPoint==-1 { 
        /varset gEndPoint 1 
        /varset gStartPoint $int($ini("@gINIFile","@gPathNumber","numpoints")) 
    } 
    
    /varset l0 @gStartPoint 
    
    /if @gStartPoint<@gEndPoint { 
        /varset gStep 1 
    } else /if @gStartPoint>@gEndPoint { 
        /varset gStep -1 
    } 
    
    /varset l1 $int($ini("@gINIFile","@gPathNumber","$int(@l0) Y")) 
    /varset l2 $int($ini("@gINIFile","@gPathNumber","$int(@l0) X")) 

    /face loc @l1, @l2 

    /call AutoRun 1 
    
    :MainLoop 
         /varset l1 $int($ini("@gINIFile","@gPathNumber","$int(@l0) Y")) 
         /varset l2 $int($ini("@gINIFile","@gPathNumber","$int(@l0) X")) 

        
        /varset tEchoTimer 5 
        /if @l0==@gStartPoint /echo $distance(@l1,@l2) 
        /varset MyXLOC $char(x) 
        /varset MyYLOC $char(y) 
        /varset ObstCount 0
        :MainLoop2 
            /doevents 
            
            /if @tEchoTimer==0 { 
                /varset tEchoTimer 1s 
                /echo $distance(@l1,@l2) 
            } 
            
            |The 'fast' paramater of the /face function prevents the command 
            |from smoothing out the turn, and instead immediately turns your 
            |character to face the specified direction. It is commented out here 
            |in favor of the smoothed /face, because it looks more natural and 
            |realistic. However, you will see problems with high-resolution paths 
            |(ie, paths in which the distances in between snapshots is very low) where 
            |your character will run in circles around points. There are two things 
            |you can do about this. The first is to increase the DistanceThreshold 
            |number that you pass when you start the script. The second is to uncomment 
            |the "/face fast nopredict" line, and comment the "/face nopredict" line. 
            |This will look a little less natural, but if you're using a high- 
            |resolution path in the first place, it really shouldn't matter. 
            
            |Another time where you might want to use /face fast is in dungeons or 
            |other tight areas where precision is important. 
            
            /face fast nopredict loc @l1, @l2 
            |/if n pointface<=1 /face loc @l1, @l2 
            /varadd pointface 1
     
            /varadd ObstCount 1 
            /if n @ObstCount>=10 { 
               /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        
                  } 
                 /face loc @l1, @l2    
                 /call autorun 1
                 /sendkey up Right 
                 /sendkey up Left
                       
             }
             /varset MyXLOC $char(x) 
             /varset MyYLOC $char(y) 
             /varset ObstCount 0 
         } 
            /if n $distance(@l1,@l2)>@gThreshold /goto :MainLoop2 
        
        /echo Point @l0 Reached. 
        /varset pointface 0
        /varset l0 $int($calc(@l0+@gStep)) 
        
        /if @l3==1 /goto :MainLoopExit 
        /if @l0==@gEndPoint /varset l3 1 
        
        /goto :MainLoop 
    
    :MainLoopExit 
    
    /call AutoRun 0 
    /echo Destination reached. Exiting. 
/return 

Sub AutoRun 
   /if @Param0==1 /sendkey down up 
   /if @Param0==0 /sendkey up up 
/return 
Last edited by driftinsupra on Tue Dec 16, 2003 5:33 pm, edited 1 time in total.

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

Post by Mckorr » Fri Dec 12, 2003 2:40 pm

Interesting... as for the rest of you, if I see an ini file or discussion of one, the post gets deleted and this thread locked :) Drift gave you the basics, so other than helping to refine his macro you are on your own.

User avatar
driftinsupra
Official loudmouth
Official loudmouth
Posts: 212
Joined: Tue Jan 28, 2003 9:25 pm

Post by driftinsupra » Fri Dec 12, 2003 2:55 pm

It would sort of be dumb for anyone to post their ini file anyway since the sellback value is based on your specific character.

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

Post by Mckorr » Fri Dec 12, 2003 3:03 pm

Yeah, but you must admit we're seeing a lot of dumb here these days. Maybe that will forstall a dozen requests for your ini file.

User avatar
driftinsupra
Official loudmouth
Official loudmouth
Posts: 212
Joined: Tue Jan 28, 2003 9:25 pm

Post by driftinsupra » Fri Dec 12, 2003 3:11 pm

Yea good point...thats why I was kinda hesitant on releasing the macro but I figure it takes some macroquest knowledge to set up so not everyone will be able to use it unless they atleast try to teach themselves something about the program

Lane
a hill giant
a hill giant
Posts: 201
Joined: Fri Dec 06, 2002 11:57 am

Post by Lane » Fri Dec 12, 2003 4:37 pm

With the right CHA value I think everyone gets the same price. Dots 9pp 5gp or something is the value I always check.

Great idea. Now I can have this help automate the process I have been using instead of me doing all the work. I'll try it tonight.

-Lane

User avatar
Elric
Cheese Whore
Cheese Whore
Posts: 466
Joined: Sun Nov 23, 2003 12:31 am
Location: Tampa, Fl
Contact:

Post by Elric » Fri Dec 12, 2003 6:23 pm

Hey, I resemble that remark Mckorr! *drools on his bib*

Time to go eat my Jeezit.. My Cruton oh Christ... Christ Chex!

Sorry, Dane Cook is on my media player right now.

:twisted:
-Elric

a_guest04
decaying skeleton
decaying skeleton
Posts: 6
Joined: Sat Dec 06, 2003 8:05 pm
Location: Ohio

Post by a_guest04 » Sat Dec 13, 2003 12:04 am

Seem to be having issues with movetoloc routine. It does all the faces, etc. I created routines2.mac and put the code from above into it. I also adjusted the path to the .ini file. It is crashing during the "movetoisle" routine. Wish I could debug further, but not getting more than a stopped macro for a debug. :? Any insight? Using Dec 10 (latest as of this post), and VC++ 6.

I am getting searches working though, so that has to be a good sign. Let's see... Getting 10fps in the bazaar atm. Would that affect delays in movetoloc?
a_random_person253 tells you: "a_guest04, why are you naked?"

You tell a_random_person253, "I am spending a day dead for tax reasons. =/ They nerfed me with income tax."

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Sat Dec 13, 2003 5:01 am

Just took a closer look at this macro because the movement just totally does not work.

There are some serious issues with how you are performing your calls, unless you deliberately messed them up.

When you make a call, you do not separate the values with a ,

it should be:

Code: Select all

/call SubName value1 value2
not

Code: Select all

/call SubName value1,value2

User avatar
driftinsupra
Official loudmouth
Official loudmouth
Posts: 212
Joined: Tue Jan 28, 2003 9:25 pm

Post by driftinsupra » Sat Dec 13, 2003 5:23 am

hmmmm....using a comma has worked perfectly for me. found a few bugs in the movement but none like you are saying... I am wokring on implemting the recormmacro an walkmacro scriptx into mine but it has yet to be done....I will work on it when I am sopber....I am too drunbk right now

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Sat Dec 13, 2003 6:59 am

Try this small macro... you will see what I mean:

Code: Select all

Sub Main
/declare one local
/declare two local
/declare three local
/declare four local

/varset one 1
/varset two 2
/varset three 3
/varset four 4

/call TestSub @two @four
/call TestSub @two,@four

Sub TestSub
   /echo Param0: @Param0
   /echo Param1: @Param1
/return

motd2k
a ghoul
a ghoul
Posts: 141
Joined: Fri Oct 25, 2002 9:46 am

Post by motd2k » Sat Dec 13, 2003 7:01 am

Can someone PM me their l33t .ini k plz thx.


MOTD

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Sat Dec 13, 2003 7:52 am

motd2k wrote:Can someone PM me their l33t .ini k plz thx.


MOTD
I'm still going through the process of finding likely items to look for.

You would be amazed at what some people sell things for. I used the macro for awhile and managed to gain 3k in between getting this set up.

I chopped the movement part out and just used the golden path to get to the vendors.

User avatar
driftinsupra
Official loudmouth
Official loudmouth
Posts: 212
Joined: Tue Jan 28, 2003 9:25 pm

Post by driftinsupra » Sat Dec 13, 2003 1:40 pm

Yea that pretty much why I made it...I know in my laziness I have put several items that might be worth about 20pp to a vendor on my bazaar drone for like 2pp just cause I really didnt know what they were worth. Also I will work on movement a little too...I really wanna put the walkpath into here but I keep running into stuff....I am gonna see if I cant get it to work with some obsticle avoidance. Also I appologize for my post last night....went on a 21 run and had one too many shots of tequila and a few drink I had never ever heard before

User avatar
driftinsupra
Official loudmouth
Official loudmouth
Posts: 212
Joined: Tue Jan 28, 2003 9:25 pm

Post by driftinsupra » Sat Dec 13, 2003 1:42 pm

Quick question for a dev...I know you dont want anyone posting their ini files but can I post a macro that makes an ini file for you? This an idea I have been toying around with for a few days since I made the original and I want to know if it would be ok when I am done.