Page 1 of 1

macro to detect vendor price when selling items?

Posted: Fri Apr 27, 2012 11:32 am
by aerandor
Just wondering if there is a way to detect the price an npc vendor offers when selling items to them. I want to use a macro to sell to a vendor using the sell agent when i have crafted at least 5 of a certain item, but I don't want to blindly sell once the vendor starts lowering his price. Any ideas?

Re: macro to detect vendor price when selling items?

Posted: Fri Apr 27, 2012 11:55 am
by the bazookas
"If" conditionals on Sysmessages are very powerful and under-appreciated.

I think it's possible to create this macro using Sysmessages, but it would require several separate "if sysmessage = ##" statments, each one with a different amount of gold in it (but doing the same thing--i.e. cancelling the macro). When you sell with the agent, I believe you get a Sysmessage saying how much you sold the items for. I think you would need to figure out what gold amounts indicate that the vendor has dropped his price (you will need a range... e.g. lets say normally you get anywhere between 200-220 gold from selling at full price, but if it has dropped, then you will get somewhere between 160-180 gold. If 160-180 covers the entire possible range of the first "down-tick" in sell price, then you would need 20 different if statements e.g.
if Sysmessage = 160
Cancel Macro
endif
if Sysmessage = 161
Cancel Macro
endif

etc..
Technically it would be easiest to go and edit the macro by hand (copy and paste the if statements and just change the number). This isn't really that hard although a little intimidating at first. Just record a macro with a single if statement, something like this (don't forget to check the "Loop" box)

say: vendor sell
Pause 0.4 seconds
if Sysmessage = 160
Cancel Macro (NOTE: this is something you set a hotkey for--go to the hotkeys tab, it should be the first one)
endif

Then go find the macro file (for windows 7 located in the AppData folder (WHICH IS A HIDDEN FOLDER, which you can turn hidden folders on (google that if you want to know how) or just type it in), e.g. C:\Users\<your username>\AppData\Roaming\Razor\Macros
for XP its something like
C:\Documents and Settings\<your username>\ApplicationData(??)...???\Razor\Macros

... try to open the macro file--it will ask you what program you want to use to open it. You should select notepad (unless you have notepad++ which is an awesome editor, but unneccesary for this application). you will see something like

Assistant.Macros.IfAction|4|0|160
Assist... Cancel macro (I don't know that command off hand)
Assistant.Macros.EndIfAction

Just copy and paste that block 20 times, and then go and change the number

Assistant.Macros.IfAction|4|0|160
Assist... Cancel macro (I don't know that command off hand)
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|161
Assist... Cancel macro (I don't know that command off hand)
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|162
Assist... Cancel macro (I don't know that command off hand)
Assistant.Macros.EndIfAction
...

NOTE that it's DEFINITELY a good idea to exit out of ALL your UO & Razor clients before making these changes because Razor seems to like to cache it's macros, and then save them when you close it down, which means it probably won't update correctly after you edit it by hand, and then when you close UO down, it will overwrite what you did.

Anyway, after making the appropriate changes, save it, get back into UO, and the macro will be updated with the changes.

Anyway... just one possible solution.

Re: macro to detect vendor price when selling items?

Posted: Fri Apr 27, 2012 1:09 pm
by Border Patrol
I swear; the bazookas are the king of macros

Re: macro to detect vendor price when selling items?

Posted: Fri Apr 27, 2012 1:11 pm
by aerandor
The system message didn't catch the price drop. I set it for the range 155-140 to cancel the macro but it ended up selling the items for a total of 125. Any ideas? Also, is there a way to check if there is a vendor within hearing range so that if there isn't I can just have it bypass the sell attempt? I have it tied in with my crafting macro and it would be nice to have the option of crafting without selling at the same time.

Re: macro to detect vendor price when selling items?

Posted: Fri Apr 27, 2012 1:25 pm
by aerandor
Here's the macro file, if this helps:

!Loop
Assistant.Macros.IfAction|50|1|5|bow
Assistant.Macros.IfAction|4|0|155
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|154
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|153
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|152
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|151
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|150
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|149
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|148
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|147
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|146
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|145
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|144
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|143
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|142
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|141
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.IfAction|4|0|140
Assistant.Macros.HotKeyAction|1083|
Assistant.Macros.EndIfAction
Assistant.Macros.SpeechAction|0|52|3|ENU|4|33|77|23|112|vendor sell
Assistant.Macros.PauseAction|00:00:01.5000000
Assistant.Macros.EndIfAction
Assistant.Macros.DoubleClickTypeAction|3922|True
Assistant.Macros.WaitForTargetAction|30
Assistant.Macros.TargetTypeAction|False|7127
Assistant.Macros.WaitForMenuAction|0|300
Assistant.Macros.MenuResponseAction|2|5042|0
Assistant.Macros.WaitForMenuAction|0|300
Assistant.Macros.MenuResponseAction|1|5042|0
Assistant.Macros.PauseAction|00:00:08


in my particular case, I'm crafting bows :) Also, I ran this again and it sold it for the correct price the second time. Then the third time it cancelled the macro. I checked the price with the macro and sell agent off and it shouldn't have cancelled because the vendor hadn't lowered his prices. Then I re-enabled it to see what it did if I ran it again and it sold the bows again but for too low a price. So I'm now totally confused :( Also, does the sell agent account for exceptional quality items?

After some more observation, I also noticed that the sell window total price doesn't always match the words the vendor says upon completing the sale. I need to check to see which value is actually added to my gold count. (checked it, it's whatever the vendor says, not the window) This might be some kind of glitch in the client. I hope it isn't my macro causing it...

Another problem I just noticed. I set the sell agent to sell only bows out of my backpack, but instead it is also selling my axes and my scorp when it runs :(

Re: macro to detect vendor price when selling items?

Posted: Fri Apr 27, 2012 2:49 pm
by the bazookas
Looks like it's a little bit more complicated than I anticipated :P. I'll see if I can play with it in the near future and figure out what a better solution is.

Something you should be aware of however (and I hope others can confirm or deny this because I'm not 100% sure about it), but I'm about 99% sure that unattended craft + sell (i.e. buy a resource, craft items from it, then sell it back to the vendor) macros are not allowed (i.e. bannable) on this server. However, if you are attending the window (i.e. if a GM were to try to interact with you, and you can and do respond to them), then I believe that it is all right. Again, I hope others will chime in if this is incorrect. For gold-making crafting macros, I think most people just have a buttload of resources, just leave your guy crafting for a long time, and then bring all the crafted stuff to all the different shops that buy that item across britannia (a runebook with all the shops is a good idea), selling until they don't buy anymore (I actually think it's not a big deal to sell at the lower price--still turns a decent profit). This way, you exhaust as many shops as possible as quickly as possible.
aerandor wrote: does the sell agent account for exceptional quality items?
Sell agent does not account for exceptional items; they are treated as normal bows. HOWEVER, they sell for a bit extra gold, so that could throw off your range. I think it might be better to lower the range, perhaps, so that although you will sell bows for a slightly reduced price, you will be less likely to miss the time when you should cancel the macro.

As for your other questions, I think I'd have to test the macro to determine what the problem is. The fact that the Sysmessage might not match what the actual sell price is seems like it could be a problem... and I can't imagine why your sell agent would be selling items that aren't in the list.
aerandor wrote: Also, is there a way to check if there is a vendor within hearing range so that if there isn't I can just have it bypass the sell attempt? I have it tied in with my crafting macro and it would be nice to have the option of crafting without selling at the same time.
There's not a way to do this in a robust manner in Razor (although you COULD do something hacky like

Double click a dagger
Target closest innocent
if sysmessage = "you can't use it on that" // or whatever the message is if they are within 2 tiles... the message is "that is too far away" if they are more than 2 tiles away
say vendor sell
endif

BUT that would fail if some other innocent or shopkeeper came close to you. A better solution would be to trap the vendor into a particular location.

As you can see, Razor is (intentionally) a bit limited in what you can do. "If" statements using Sysmessages and counters can go a long way, however. Razor is certainly something you should play with and try new things with. You'd be surprised what you can accomplish. Occasionally, however, you'll be disappointed b/c it just doesn't quite fit what you were hoping for (sometimes due to strange behavior like the gold amount discrepancy you describe).

Re: macro to detect vendor price when selling items?

Posted: Fri Apr 27, 2012 3:39 pm
by aerandor
the bazookas wrote: Something you should be aware of however (and I hope others can confirm or deny this because I'm not 100% sure about it), but I'm about 99% sure that unattended craft + sell (i.e. buy a resource, craft items from it, then sell it back to the vendor) macros are not allowed (i.e. bannable) on this server. However, if you are attending the window (i.e. if a GM were to try to interact with you, and you can and do respond to them), then I believe that it is all right.
I know about the unattended rule and I never do crafting or resource gathering unattended. I was jsut looking for a way to speed up the process so that I didn't have to click through the sell menu everytime. Thanks though. Let me know if you figure anything out :)

Re: macro to detect vendor price when selling items?

Posted: Sat Apr 28, 2012 12:07 pm
by TheManWithNoName
be careful with the sell agent, it is easy to use but razor is stupid at the same time. if you have added the axe/scrop item types to the sell list and set your main pack as the hotbag, razor will attempt to sell all of the items in that list if it sees them in your pack.

Re: macro to detect vendor price when selling items?

Posted: Sat Apr 28, 2012 9:21 pm
by aerandor
TheManWithNoName wrote:be careful with the sell agent, it is easy to use but razor is stupid at the same time. if you have added the axe/scrop item types to the sell list and set your main pack as the hotbag, razor will attempt to sell all of the items in that list if it sees them in your pack.
I only added the bow type to the list but I'll try switching to selling from a different pack to see what that does. Thanks for the idea.

Re: macro to detect vendor price when selling items?

Posted: Sun Apr 29, 2012 10:15 am
by TheManWithNoName
aerandor wrote:I only added the bow type to the list but I'll try switching to selling from a different pack to see what that does. Thanks for the idea.
hmm that doesn't make sense then why it's selling the other item types. do you have different razor profile setups and accidentally used the wrong one when you were running the macro on your crafter?

Re: macro to detect vendor price when selling items?

Posted: Sun Apr 29, 2012 12:30 pm
by Hicha
I want to say that this probably isnt possible due to the restrictions Derrick had put in place to system chat awhile back to prevent people from using system chat to initiate bot macros (ie: people using a guild chat macro to activate a gate bot for a quick escape.)