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

RDPidb
a lesser mummy
a lesser mummy
Posts: 69
Joined: Mon Dec 15, 2003 1:14 am

Post by RDPidb » Tue Dec 16, 2003 4:43 pm

hey driftin i got a cool idea check ur PM.

RDPidb
a lesser mummy
a lesser mummy
Posts: 69
Joined: Mon Dec 15, 2003 1:14 am

new macro

Post by RDPidb » Tue Dec 16, 2003 4:47 pm

No, i PMed driftin but he must be busy workign on it bc i haven't heard from him. Im anxious for it too :twisted:

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

Post by driftinsupra » Tue Dec 16, 2003 5:34 pm

OK new version is up at the beginning of the thread...let me know what you guys think about the new moevment portion

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Tue Dec 16, 2003 9:02 pm

Not sure if this is causing problems or not but I noticed this while I was looking at the code. You have an extra closing brace.

Code: Select all

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

Code: Select all

/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 
} 

RDPidb
a lesser mummy
a lesser mummy
Posts: 69
Joined: Mon Dec 15, 2003 1:14 am

Post by RDPidb » Tue Dec 16, 2003 10:26 pm

How would one change the 'home point' ?
The current one is in a very congested spot and my bot goes haywire trying to avoid peopel and get through the crowd.

Thanks
-Ryan

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

Post by driftinsupra » Tue Dec 16, 2003 10:58 pm

Ypu would need to create a new path.ini file for youirself

BillyBumbler_01
orc pawn
orc pawn
Posts: 14
Joined: Wed Dec 17, 2003 5:32 pm

Post by BillyBumbler_01 » Wed Dec 17, 2003 5:38 pm

So I cleaned up and fixed the display stuff and commented out the sellback code. I use this to check for and buy rare items I want to keep rather than mass amounts of sellback crap. If you want the sellback code back in, remove the comment chars.

This will properly display a list of all the items in the .ini separated by a series of dashes. Make sure you re-modify your ini path, as I've changed this one for my setup.

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:\Stuff\MQ2-Latest\Release\ini\bazaar.ini 
/varset counter 1 
:mainloop 

/if "$ini(@file,names,val@counter)"=="NOTFOUND" { 
    /echo Starting search over 
    /varset counter 1 
    /goto :mainloop 
    } 
/echo -------------------------------------------------
/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 found $bazaar(count) $ini(@file,names,val@counter)(s)
|    /echo $ini(@file,names,val@counter) not found, continuing on... 
    /varadd counter 1 
    /varset counter $int(@counter) 
    /goto :mainloop 
    } else { 
    /echo found $bazaar(count) $ini(@file,names,val@counter)(s)
} 

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

/if n $bazaar(count)>0 { 
    /for l1 0 to $calc($bazaar(count)-1) 
        /echo $int($calc(@l1+1)) price $int($calc($bazaar(@l1,price)/1000))
        /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 = @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:\Stuff\MQ2-Latest\Release\ini\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 

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

Post by Elric » Wed Dec 17, 2003 5:53 pm

Billy, you Gunslingin' coder.

Good for you, and if you happen on a "blur" in the code, let us know.
-Elric

BillyBumbler_01
orc pawn
orc pawn
Posts: 14
Joined: Wed Dec 17, 2003 5:32 pm

Post by BillyBumbler_01 » Wed Dec 17, 2003 6:23 pm

Is there a simple way to translate the trader id to a character name?

I can do this:

Code: Select all

/if n $bazaar(count)>0 { 
    /for l1 0 to $calc($bazaar(count)-1) 
        /target id $bazaar(@l1,trader)
        /echo $int($calc(@l1+1)) price $int($calc($bazaar(@l1,price)/1000)) $target(name)
        /if n @price>$bazaar(@l1,price) { 
            /varset price $bazaar(@l1,price) 
            /varset traderid $bazaar(@l1,trader) 
        } 
    /next l1 
} 
to rapidly cycle through targets, but that seems... icky. And probably dangerous.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Wed Dec 17, 2003 8:30 pm

Yep this should work I believe.

Code: Select all

$spawn($bazaar(@l1,trader),name,clean) 

bob_the_builder
a hill giant
a hill giant
Posts: 275
Joined: Tue Jul 22, 2003 1:22 pm

Post by bob_the_builder » Wed Dec 17, 2003 8:47 pm

you should n't need a /movetotarg anymore....I beleiev I completely removed it.
I get Subroutine not found on
Using code from driftinsupra and BillyBumbler_01

Code: Select all

/call movetotarg 10 
/click right target 
/delay 20 
/call buyitem "$ini(@file,names,val@counter)" 
I added:

Code: Select all

#include routines2.mac 


to the bazaar.mac and it found the movetotarg cause its in that file.

Unless routines.mac is a normal include and since I named mine routines2.mac it couldnt find it ?

Bob
Last edited by bob_the_builder on Wed Dec 17, 2003 10:23 pm, edited 1 time in total.

Quadzer
orc pawn
orc pawn
Posts: 15
Joined: Sun Oct 19, 2003 10:12 pm

Post by Quadzer » Wed Dec 17, 2003 9:00 pm

Anyway to not look at the floor while running around the Bazaar. I can't look up, it always looks at the floor while moving.

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

Post by driftinsupra » Wed Dec 17, 2003 9:39 pm

you should n't need a /movetotarg anymore....I beleiev I completely removed it.

MQFan
orc pawn
orc pawn
Posts: 12
Joined: Sat Aug 30, 2003 10:02 pm

Post by MQFan » Tue Dec 30, 2003 5:55 pm

I couldn't be more of a dumbass if I took dumbass pills with a glass of dumbass and water.

*Edited to remove all traces of dumbass.*

MQFan
Last edited by MQFan on Tue Dec 30, 2003 7:35 pm, edited 2 times in total.

RDPidb
a lesser mummy
a lesser mummy
Posts: 69
Joined: Mon Dec 15, 2003 1:14 am

Post by RDPidb » Tue Dec 30, 2003 5:58 pm

works fine for me.