Author Topic: A plugin that autocomps?
mav_sc 
Posts: ????
Registered: ????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
Subject: A plugin that autocomps?
I'm writing one but am having trouble with the broken vendor filter for .net code.

Anyone know of any other plugins that will auto comp when you approach a vendor?

I'm looking for a little more than just /fillcomps

I'm thinking something that would buy:
spell comps
mana charges
healing kits

automatically.

Ideas? Recomping is probably one of my biggest annoyances with AC.

 

-----signature-----
Link to this post
Paraduck 
Title: quantum mechanic
Posts: 88,652,030
Registered: Feb 27, '01
Extended Info (if available)
Real Post Cnt: 51,297
User ID: 70,706
Subject: A plugin that autocomps?
Yeah. I'm working on something similar, but a much smaller scope. The hacky way I found it to parse the RawData from EchoFilter. This gives you the names and IID's of all the items in the vendor. I haven't tried to use the VendoyBuy/Sell lists yet, but that's my next step.

 

-----signature-----
We are like dwarfs sitting on the shoulders of giants. We see more and things that are more distant than they did,
not because our sight is superior or because we are taller than they, but because they raise us up and their
great stature adds to ours
Link to this post
mav_sc 
Posts: ????
Registered: ????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
Subject: A plugin that autocomps?
Buy/Sell list? Hmm, where's that?

Here's what I'm doing now:

This will get the item for you. It is currently broken on MOST vendors. sad It does work on the treated healing kit vendor though.
foreach (WorldObject obj in Util.Core.WorldFilter.OpenVendor)
{
if (obj.Name.Contains(ItemName))
{
Item = obj;
break;
}
}


Then, my next bit of code to determine if we need to sell some items so we can purchase it, note that its not completed as vendors are currently broken:


if (Item.Values(LongValueKey.StackCount) == 0)
{
// Item is purchased one at a time
if (Items.Money_Pyreals.Count >= Item.Values(LongValueKey.Value) * Util.Core.WorldFilter.OpenVendor.SellRate)
{
WaitingForApproachMsg = true;

// We have enough money to purchase this item
ActionQueue.Add(new VendorAddBuyList(Item.Id, 1));

ActionQueue.Add(new VendorBuyAll());
}
else
{
// We need to sell some stuff
int CostEach = (int)Math.Ceiling(Item.Values(LongValueKey.Value) * Util.Core.WorldFilter.OpenVendor.SellRate);

int MinPyreals = CostEach;
int MaxPyreals = CostEach * ((ItemsOriginallyHad + count) - ItemsCurrentlyHave);

if (!AddItemsToSell(MinPyreals, MaxPyreals))
{
Stop();
Util.Debug("Unable to BuyItem from vendor. Not enough items to sell to purchase item: " + ItemName + ".");
return;
}

WaitingForApproachMsg = true;

ActionQueue.Add(new VendorSellAll());
}
}
else
{
// Item is purchased in stacks
Stop();
Util.Debug("Unable to BuyItem from vendor. Method not implemented.");
}



To give you an example, my buylist class:


using System;

using Decal.Adapter.Wrappers;

namespace Mag_Tools.Actions
{
public class VendorAddBuyList : Action
{
private int itemId;
private int count;

public VendorAddBuyList(int itemId, int count)
{
this.itemId = itemId;
this.count = count;
}

protected override bool Starting()
{
try
{
if (Util.Core.WorldFilter.OpenVendor == null)
{
Util.Debug("Unable to AddBuyList to vendor. OpenVendor == null");
return false;
}

return true;
}
catch (Exception ex) { Util.LogError(ex); return false; }
}

protected override void ActionThink()
{
try
{
Util.Debug("Trying to AddBuyList to vendor.");

Util.QueueDecalAction(delegate() { Util.Host.Actions.VendorAddBuyList(itemId, count); });

Stop();

Util.Debug("Vendor AddBuyList completed.");
}
catch (Exception ex) { Util.LogError(ex); }
}
}
}



This might help spark some ideas. I'm using a queue system similar to the one found in goarrow.

 

-----signature-----
Link to this post
Paraduck 
Title: quantum mechanic
Posts: 88,652,030
Registered: Feb 27, '01
Extended Info (if available)
Real Post Cnt: 51,297
User ID: 70,706
Subject: A plugin that autocomps?
> Buy/Sell list? Hmm, where's that?

You're using it wink

ActionQueue.Add(new VendorAddBuyList(Item.Id, 1));

 

-----signature-----
We are like dwarfs sitting on the shoulders of giants. We see more and things that are more distant than they did,
not because our sight is superior or because we are taller than they, but because they raise us up and their
great stature adds to ours
Link to this post
mav_sc 
Posts: ????
Registered: ????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
Subject: A plugin that autocomps?
Oh, ok. I thought you were talking about an object that contains a list of items currently in the buylist, and selllist.

 

-----signature-----
Link to this post
mav_sc 
Posts: ????
Registered: ????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
Subject: A plugin that autocomps?
Para, can you please post some sample code on how to parse the vendors items using echofilter?

 

-----signature-----
Link to this post
Paraduck 
Title: quantum mechanic
Posts: 88,652,030
Registered: Feb 27, '01
Extended Info (if available)
Real Post Cnt: 51,297
User ID: 70,706
Subject: A plugin that autocomps?
I ended up scraping it and going with /fillcomps. Comparatively, it's a pain to parse the vendor packet properly. :P

Basically, just take the RawData from the message, convert the bytes to hex, and find the item name you're looking for (in hex). The item ID consists of the 16 (I think?) bytes before that, but there is also a spacer of 4 (I think?) bytes. The problem I was running into was that sometimes, every other pair of bytes would be reversed (but only sometimes.)

 

-----signature-----
We are like dwarfs sitting on the shoulders of giants. We see more and things that are more distant than they did,
not because our sight is superior or because we are taller than they, but because they raise us up and their
great stature adds to ours
Link to this post
mav_sc 
Posts: ????
Registered: ????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
Subject: A plugin that autocomps?
Hmm ok, that sounds pretty easy for me actually.

An idea though to test if the bytes are swapped.

Core.WorldFilter[id] == null
then try the swapped id.

 

-----signature-----
Link to this post
Hazridi 
Posts: 8,386
Registered: Mar 15, '01
Extended Info (if available)
Real Post Cnt: 8,277
User ID: 74,558
Subject: A plugin that autocomps?
Seriously, just wait for us to figure out the vendor packet changes.

 

-----signature-----



Hazridi of WE, VT, HG, SC
Decal Core Dev - http://www.decaldev.com - Beta at http://www.decaldev.com/beta
Link to this post
mav_sc 
Posts: ????
Registered: ????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
Subject: A plugin that autocomps?
Haz, no prob waiting. I just didn't know what your timeline was like.

I know you guys are pretty busy so I didn't want to bug you, that's all.

Plus, with the vendor wrapper code being broken for so long, I figured very few (if any) were actually using it, thus putting it low on the priority list, which is understandable.

 

-----signature-----
Link to this post

Valid XHTML 1.0 Transitional Powered by PHP