makeini.mac - Partner to bazaar.mac makes bazaar ini's

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

makeini.mac - Partner to bazaar.mac makes bazaar ini's

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

OK this I built for use with the bazaar macro file and it woroks very well I think. You will need to give it 2 parameters. the first being what you intend to search for or the group of things you would like to add to the ini. For example I use words and then I will do a search for all the words in the bazaar and start adding them to the script. The next parameter you will need is the max you will pay for an item. You could call the macro like this:

/macro makeini words 5

You will then go arounmd the bazaar and start purchasing all the words you can find for under 5pp and then sell them back to a merchant to find out how much you can make on that particular item. You will need to edit the location of the ini you would like to make in the /varset line in the beggining of the script. Please let me know what you all think.

P.S. This also requires my path.ini file for movement. You can get that here
http://www.wsu.edu/~ellyson/path.ini

Code: Select all

|Driftinsupra second usefull macro makeinir.mac
|Makes ini files for use in bazaar.mac

#include routines2.mac
#turbo 

sub main 

/declare file global
/declare isle global
/declare counter local
/declare l1 local 
/declare traderid local 
/declare price local 
/declare curmoney local
/declare newmoney local
/declare profit local
/declare item local
/declare theitem global
/declare Token global 
/declare check local
/declare donecheck local


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


/echo searching for @Param0 
/bzsrch race any class any price 0 @Param1 "@Param0" 

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

/if n $bazaar(count)==0 { 
    /echo @Param0 not found, exiting
    /return
    }
     
} else { 
    /echo found $bazaar(count) items 
} 


/varset theitem "$bazaar(0,name)" 
/varset Token $instr("(","@theitem")
/varset item "$left(@Token,"@theitem")"
/echo "$bazaar(0,name)"
:checkloop
/if "@item"=="$ini(@file,names,val@counter)" /varset donecheck 1 
/varadd counter 1
/echo @donecheck
/varset counter $int(@counter)
/echo "$ini(@file,names,val@counter)"
/if "$ini(@file,names,val@counter)"!="NOTFOUND" /goto :checkloop
/if n @donecheck==1 {
   /varset donecheck 0
   /varadd check 1
   /varset counter 1
   /varset check $int(@check)
   /varset theitem "$bazaar(@check,name)"
   /if "$left(6,"@item")=="$bazaar /endmacro
   /varset Token $instr("(","@theitem")
   /varset item "$left(@Token,"@theitem")"
   /goto :checkloop
   }



/varset price $bazaar(@check,price) 
/varset traderid $bazaar(@check,trader)
/echo @theitem
/varset Token $instr("(","@theitem")
/varset item "$left(@Token,"@theitem")"
/echo is @item 
/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 "@item"
/call moveback @isle
/call walkpath merch 10
/varset curmoney $char(cash)
/target "Merchant Tekram"
/face
/click right target
/delay 20
/selectitem "@item" self
/sendkey down shift
/click left merchant sell
/sendkey up shift
/delay 20
/click left merchant done
/varset newmoney $char(cash)
/call walkpath merchb 10
/varsub newmoney @curmoney

   /ini "@file" "names" "val$int(@counter)" "@item"
   /ini "@file" "prices" "val$int(@counter)" "$int(@newmoney)"
/varset counter 0
/varset check 0
/varset donecheck 0  
/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 

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

Post by RDPidb » Tue Dec 16, 2003 7:42 pm

This is awsome driftin, thanks so much.
Is there any way to get around this tho :

/echo targeting @traderid
/target id @traderid
/face
/call traderisle $target(x) $target(y)

..
targeting somethign from across a zone seems dicy to me. especialy when you dont have a line-of-sight.

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

Post by RDPidb » Tue Dec 16, 2003 7:58 pm

Seems to be choking on the sell part. merchant is tellign me I dont have any room left..when tryign to sell an item to him. looks like its trying to buy a traders sachel off him for some reason.

Mixy
a lesser mummy
a lesser mummy
Posts: 46
Joined: Tue Jul 09, 2002 5:00 pm

Post by Mixy » Tue Dec 16, 2003 8:39 pm

Dont flame me if this question is stupid. :lol:

Isnt these a way to create an ini file without actually buying / selling items? MQ2 seems to put the price you could sell the item to a vendor for in the link window. Where does that information come from? Is there an existing generic ini in MQ2 with that info logged, or is it calculating that value based on your current charictor?

Im not sure if that should be released because it would make it pretty easy to resell things, but im just wondering so i can look into it myself.

-Mixy!

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

Post by RDPidb » Tue Dec 16, 2003 8:42 pm

grr . u beat me to it. i was just noticing that

also as a side note. ur home point is the worst possible LOC ever its in front of the bank at the zone in... always congested.

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

Post by driftinsupra » Tue Dec 16, 2003 9:19 pm

those arent actually values in the check item windows...I dont know where they come from but they are not accurate. On the question of buying the satchl bug....when you are selling the item you bought cant be in a bag or /selectitem wont target it. I will work on making it so you can select it if it is in a bag but right now it needs to be in a main inventoryslot.

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

Post by RDPidb » Tue Dec 16, 2003 9:30 pm

the workaround i found if u want to use a bag for some reason is to leave the bag open whiel the macro runs.


Im getting some strange bugs tho, it will work fine for about 20 items then all of a sudden it will decide to buy whatever is in the first inv slot.
I *think* this happens if what u actualy want to buy is hiden from view : i.e. you woudl have to scroll down in the trader window to see the item.

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

Post by driftinsupra » Tue Dec 16, 2003 9:32 pm

As far as targetting I really dont have a way of getting around targeting across zone. The macro needs to know the loc of the merchant to move to the correct isle and the only way of doing it is to target the merchant.

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

Post by driftinsupra » Tue Dec 16, 2003 9:36 pm

I found that similar problem....the issue I had when was looking for an item such as

Word of Sentient (Azia)

the macro is made to find '(' and cut off all the test after that since when you do a $bazaar(n,name) it will return something like:

Words of Sentient (Azia)(1)

I needed to cut off the (1) to target norma items but when I am looking for an item like this it cuts of the Azia and everything past it..I am looking to find a work around but for now it will continue to buy the first item when it comes to things like this.

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:05 pm

yep thats what my problem was also. thanks.

what sucks tho is if they have somethign very very expensive in slot 1, alot of traders put a pod of water in first slot with price 99,999 in the hopes u will click buy instead of done.

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

Post by ml2517 » Tue Dec 16, 2003 10:07 pm

drift,
Use this routine. It should work properly regardless if there are parenthesis earlier in the item name. I put in an example in the beginning to see how to call and get the results.

Code: Select all

#turbo

Sub Main
/call ParseString "Words of Sentient (Azia)(1)"
/echo $return
/return


Sub ParseString(itemnm)
/declare a local
/declare length local
/declare partial local
/varset length $strlen("@itemnm")
/for a @length downto 1
    /varset partial $mid(@a,1,"@itemnm")
    /if "@partial"=="(" /return $left(@a,"@itemnm")
/next a
/return
Last edited by ml2517 on Tue Dec 16, 2003 10:26 pm, edited 1 time in total.

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

Post by ml2517 » Tue Dec 16, 2003 10:24 pm

I'm guessing anywhere you have this:

Code: Select all

/varset Token $instr("(","@theitem") 
/varset item "$left(@Token,"@theitem")" 
Replace with this:

Code: Select all

/call ParseString "@theitem" 
/varset item $return 
or you might have to surround $return with quotes

Code: Select all

/call ParseString "@theitem" 
/varset item "$return" 
and of course add this Sub into your script:

Code: Select all

Sub ParseString(itemnm) 
/declare a local 
/declare length local 
/declare partial local 
/varset length $strlen("@itemnm") 
/for a @length downto 1 
    /varset partial $mid(@a,1,"@itemnm") 
    /if "@partial"=="(" /return $left(@a,"@itemnm") 
/next a 
/return 

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:48 pm

awsome that works great ( with the quotes)

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

Post by ml2517 » Tue Dec 16, 2003 10:56 pm

I was also just assuming that there is a (1) type quantity number at the end of every item name that you get from the bazaar plugin. Is that a good assumption? If not let me know and I'll work on the sub.

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

Post by RDPidb » Tue Dec 16, 2003 11:29 pm

actualy now its storing "0" as the price for everything.