Page 1 of 1
Automatic siege merit trading
Posted: Tue Jan 25, 2011 9:46 am
by neveryoumind
I am trying to write a script for siege war, that whenever someone requests a trade, the bot will trade the merits from the first slot in his backpack. This is my code, I haven’t tested it yet, I was hoping you could tell me if I’m close or way off.
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints><onLoad>
</onLoad>
<onTRADE_REQUEST>
RoMScript("AgreeTrade();") --agree to trade
yrest(500)
ItemInfo = RoMScript("GetBagItemInfo(1);") --get item info for item in bag slot 1
RoMScript("PickupBagItem("..tonumber(ItemInfo)..");") --pickup item in bag slot 1
yrest(500)
RoMScript("ClickTradeItem(1);") --place item in tradeing slot 1
yrest(800)
RoMScript("AcceptTrade('');") --accept the trade
yrest(200)
</onTRADE_REQUEST>
</waypoints>
Re: Automatic siege merit trading
Posted: Tue Jan 25, 2011 10:18 am
by rock5
Change this
Code: Select all
ItemInfo = RoMScript("GetBagItemInfo(1);") --get item info for item in bag slot 1
RoMScript("PickupBagItem("..tonumber(ItemInfo)..");") --pickup item in bag slot 1
to this
Code: Select all
RoMScript("PickupBagItem("..inventory.BagSlot[61].BagId..");") --pickup item in bag slot 1
Also isn't there supposed to be a double accept at the end or something?
Re: Automatic siege merit trading
Posted: Tue Jan 25, 2011 10:41 am
by lisa
Well it's kind of a double accept. both chars need to click ok and then after both have clicked ok then both need to click trade.
Re: Automatic siege merit trading
Posted: Tue Jan 25, 2011 10:54 am
by neveryoumind
Thanks! I can't wait until I get home to test this out:)
Re: Automatic siege merit trading
Posted: Tue Jan 25, 2011 11:58 am
by neveryoumind
ok, this is what I have now:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<waypoints>
<onLoad>
changeProfileOption("PATH_TYPE", "wander")
changeProfileOption("WANDER_RADIUS", 0)
</onLoad>
<onTRADE_REQUEST>
RoMScript("AgreeTrade();") --agree to trade
yrest(500)
RoMScript("PickupBagItem("..inventory.BagSlot[61].BagId..");") --pickup item in bag slot 1
yrest(500)
RoMScript("ClickTradeItem(1);") --place item in tradeing slot 1
yrest(800)
RoMScript("AcceptTrade('');") --accept the trade
yrest(200)
RoMScript("AcceptTrade('');") --accept the trade
yrest(200)
</onTRADE_REQUEST>
</waypoints>
however the bot attempts to move to point (0,0)
Re: Automatic siege merit trading
Posted: Tue Jan 25, 2011 12:07 pm
by Giram
Maybe like this? It would constantly check for requests if thats is right command to check trade requests.
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>
while(true) do
<onTRADE_REQUEST>
RoMScript("AgreeTrade();") --agree to trade
yrest(500)
RoMScript("PickupBagItem("..inventory.BagSlot[61].BagId..");") --pickup item in bag slot 1
yrest(500)
RoMScript("ClickTradeItem(1);") --place item in tradeing slot 1
yrest(800)
RoMScript("AcceptTrade('');") --accept the trade
yrest(200)
RoMScript("AcceptTrade('');") --accept the trade
yrest(200)
</onTRADE_REQUEST>
end
</onLoad>
</waypoints>
Re: Automatic siege merit trading
Posted: Tue Jan 25, 2011 1:06 pm
by neveryoumind
I gave that a try it didn't seem to work. back to reading the wiki I think.
Re: Automatic siege merit trading
Posted: Tue Jan 25, 2011 1:42 pm
by neveryoumind
ok, borrowing from matt87, I now have this. it is dirty, but almost works;)
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>
changeProfileOption("ANTI_KS", false)
changeProfileOption("PATH_TYPE", "wander")
changeProfileOption("WANDER_RADIUS", 0)
changeProfileOption("AUTO_TARGET", false)
changeProfileOption("USE_SLEEP_AFTER_RESUME", true)
while (true) do
yrest(200)
RecipientName = RoMScript("GetTradeRecipientName();")
if RecipientName == nil then
else
if RecipientName == "" then
else
RoMScript("AgreeTrade();") --agree to trade
yrest(500)
RoMScript("PickupBagItem("..inventory.BagSlot[61].BagId..");") --pickup item in bag slot 1
yrest(500)
RoMScript("ClickTradeItem(1);") --place item in tradeing slot 1
yrest(800)
while RoMScript("GetTradeTargetItemInfo(1)") ~= nil do
RoMScript("AcceptTrade('..RecipientName..');")
yrest(500)
RoMScript("AcceptTrade('..RecipientName..');")
end
end
end
end
</onLoad>
</waypoints>
however the trade accept loop for slow traders doesn't seem to work, loops the picking up and placing of items
Re: Automatic siege merit trading
Posted: Tue Jan 25, 2011 8:17 pm
by rock5
Firstly you can change this
Code: Select all
if RecipientName == nil then
else
if RecipientName == "" then
else
To this
Code: Select all
if RecipientName ~= nil and RecipientName ~= "" then
neveryoumind wrote:however the trade accept loop for slow traders doesn't seem to work, loops the picking up and placing of items
So what you want to do is wait until they put something in the tradebox after you have placed your item.
Try;
Code: Select all
while RoMScript("GetTradeTargetItemInfo(1)") == nil do
yrest(500) -- waiting
end
RoMScript("AcceptTrade('..RecipientName..');")
yrest(500)
RoMScript("AcceptTrade('..RecipientName..');")
There might need to be a check to see if they quit the trade.
If I understand this correctly, this will trade blindly with anyone. That's a bit risky isn't it? Maybe you should be checking RecipientName against a list of acceptable characters?
eg.
Code: Select all
local authorized = "'char 1','char 2','char 3'"
if RecipientName ~= nil and RecipientName ~= "" and string.find(authorized,"'"..RecipientName.."'") then
Re: Automatic siege merit trading
Posted: Tue Jan 25, 2011 8:42 pm
by lisa
If I'm right I doubt he cares about who is trading, I'm guessing he will load several characters all probably lvl 1 and they are just there to purely farm merits.
Re: Automatic siege merit trading
Posted: Tue Jan 25, 2011 8:47 pm
by rock5
I probably misunderstood the situation, probably because I don't know what 'merits' are.
Re: Automatic siege merit trading
Posted: Tue Jan 25, 2011 10:45 pm
by lisa
with Seige characters farm merits, lower characters click on a tower and collect merit over time. The merits are used to buy and upgrade things in the seige. It's like a special currency just for seiges. You also get them by killing balloons or enemy players.
Re: Automatic siege merit trading
Posted: Wed Jan 26, 2011 10:39 am
by neveryoumind
Thank you again. My goal for this script is to automate the farming of the merits. The reason for this is that I have noticed that a number of small guilds that siege, about 0-5 players, routinely use alt-characters for farming. Also this seem to be a area not covered, so I could contribute something to a community that has saved me $1,000 in carpel tunnel treatments;-)
so indeed, the script must be able to trade with anyone who asks, mutable times in a row, while farming merits. It also must only select the merits.
Anywho, this is the script as it stands after last night.
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>
changeProfileOption("ANTI_KS", false)
changeProfileOption("PATH_TYPE", "wander")
changeProfileOption("WANDER_RADIUS", 0)
changeProfileOption("AUTO_TARGET", false)
changeProfileOption("USE_SLEEP_AFTER_RESUME", true)
while (true) do
yrest(2000)
RecipientName = RoMScript("GetTradeRecipientName();") --checks to see if anyone wants to trade with us
if RecipientName == nil then
elseif RecipientName == "" then
else
RoMScript("AgreeTrade();") --agree to trade
yrest(500)
RoMScript("PickupBagItem("..inventory.BagSlot[61].BagId..");") --pickup item in bag slot 1
yrest(500)
RoMScript("ClickTradeItem(1);") --place item in tradeing slot 1
yrest(800)
RoMScript("AcceptTrade('..RecipientName..');") --click the ok buttion
yrest(500)
while RoMScript("GetTradeRecipientName();") ~= "" do
RoMScript("AcceptTrade('..RecipientName..');") --loops clicking the trade buttion untill the trade is completed
yrest(500)
end
yrest(5000)
keyboardPress(key.VK_ESCAPE); --clears the screen of the so and so wants to trade window
end
end
</onLoad>
</waypoints>
I will implement your suggestion for the next version Rock5, thank you. Also I need to add a check to see if the merits are in slot one or two. What happens if you trade while collecting the merits, the ones being traded, still reserve the slot in the back pack when you pick them up, so the newly collected merits go to the next available slot. so I’m thinking I’ll set it up to see if there is anything in slot one or two and trade that, and if nothing is in either slot to cancel the trade.
Re: Automatic siege merit trading
Posted: Wed Jan 26, 2011 6:11 pm
by rock5
What's stopping you from finding the merits?
Instead of
Code: Select all
RoMScript("PickupBagItem("..inventory.BagSlot[61].BagId..");") --pickup item in bag slot 1
try
Code: Select all
local merit = inventory:findItem(meritnameorId)
if merit then
RoMScript("PickupBagItem("..merit.BagId..");")
-- and the rest
Or maybe you can use
Code: Select all
local merit = inventory:findItem(meritnameorId)
if merit and RecipientName ~= nil and RecipientName ~= "" then
Re: Automatic siege merit trading
Posted: Wed Jan 26, 2011 10:17 pm
by lisa
206685 = Guild War Merit