View Full Version : Waiting for a DTM to appear?
cause
01-05-2012, 02:55 AM
Hi guys, I'm making a smelter for my gold and silver miner, and I need some help with how long to wait for it to smelt. Because I'm coming straight from the mine, the number of gold and silver ore in my inventory vary so my plan was to check with a DTM what the last item in my inv was:
http://clip2net.com/clip/m109326/thumb640/1325731902-clip-28kb.png (http://clip2net.com/s/1smhy)
then have it loop and continually search for the DTM of a gold bar. (As you can tell I have already smelted the gold in this load, but I would end up doing the same thing for silver, I'd have it start smelting then search the bottom-est silver (bottom right) inv spot until it finds the silverbar DTM I have, anybody have any idea how to do this? I think a do while loop would do it but I don't really know how to do it, and also I was thinking it would search for about 50 seconds before failing.
[Nathan]
01-05-2012, 03:00 AM
//Counts the number of DTMs found in an inventory that match the input "DTM"
Function CountInvDTM(DTM:longint):integer;
var items:TPointArray;
begin
if(GetCurrentTab=tab_Inv) then
begin
FindDTMs(DTM,items,556,210,733,465);
result:=(Length(items)/9);
end else
result:=-1;
end;
while(CountInvDTM(ourDTM) > 0) do
begin
sleep(100);
//failsafe
end;
cause
01-05-2012, 03:08 AM
Ah thank you Nathan and Silent_Spy via IRC.
Kyle Undefined
01-05-2012, 03:10 AM
Why DTM's? Why not TPA's of the items, or even a black list? Would be much more efficient.
cause
01-05-2012, 03:16 AM
lol because I haven't learned TPA's yet and I don't know what a black list is.
EDIT: Also, instead of just searching the bottomest ore, I'm just going to search the whole inv for the DTM until it returns false or my incrementer reaches 50 (seconds).
Brandon
01-05-2012, 03:28 AM
lol because I haven't learned TPA's yet and I don't know what a black list is.
EDIT: Also, instead of just searching the bottomest ore, I'm just going to search the whole inv for the DTM until it returns false or my incrementer reaches 50 (seconds).
You can actually search the last inventory slot:
Procedure LastSlotItem;
var
Box: TBox;
I, GoldBarDTM, X, Y: Integer;
begin
//Starts smelting ores..
For I:= 0 To 27 do
begin
Box:= InvBox(I);
if (Not FindDTM(GoldBarDTM, X, Y, Box.X1, Box.Y1, Box.X2, Box.Y2)) then
Repeat
wait(1);
//do other checks.. etc..
Until(FindDTM(GoldBarDTM, X, Y, Box.X1, Box.Y1, Box.X2, Box.Y2));
end;
end;
[Nathan]
01-05-2012, 03:37 AM
You can actually search the last inventory slot:
Procedure LastSlotItem;
var
Box: TBox;
I, GoldBarDTM, X, Y: Integer;
begin
//Starts smelting ores..
For I:= 0 To 27 do
begin
Box:= InvBox(I);
if (Not FindDTM(GoldBarDTM, X, Y, Box.X1, Box.Y1, Box.X2, Box.Y2)) then
Repeat
wait(1);
//do other checks.. etc..
Until(FindDTM(GoldBarDTM, X, Y, Box.X1, Box.Y1, Box.X2, Box.Y2));
end;
end;
The problem with that is you don't know if the last inventory spot is going to be gold or silver :/
cause
01-05-2012, 03:41 AM
@ggzz as nathan said you don't know whether or not it will be gold or silver, however thanks for that code I didn't know about searching each inv spot like that! very helpful.
I'm just finishing up the function maybe tell me if you spot anything obvious lol
Function Smelt: boolean;
var
x, y, counter: integer;
begin
counter := 0;
if FindObjCustom(x, y, ['ace'], [3815997], 5) then //'furnace'
begin
wait(100 + random(250));
Mouse(x, y, 1, 1, true);
if FindDTM(goldoreDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
if FindDTM(goldbarDTM, x, y, MCX1, MCY1, MCX2, MCY2) then
begin
Mouse(x, y, 1, 1, true);
while ((counter<50) and not (FindNormalRandoms)) do
begin
if not FindDTM(goldoreDTM, x, y, MIX1, MIY1, MIX2, MIY2) then break;
wait(1000);
counter := counter + 1;
end
end
if FindObjCustom(x, y, ['ace'], [3815997], 5) then
begin
if FindDTM(silverbarDTM, x, y, MCX1, MCY1, MCX2, MCY2) then
begin
Mouse(x, y, 1, 1, true);
while ((counter<50) and not (FindNormalRandoms)) do
begin
if not FindDTM(silveroreDTM, x, y, MIX1, MIY1, MIX2, MIY2) then break;
wait(1000);
counter := counter + 1;
end
Result := true;
end
end
else
begin
WriteLn('Couldn''t find initial goldoreDTM');
TerminateScript;
end
end
else
begin
WriteLn('Couldn''t find furnace');
TerminateScript;
end
end;
Brandon
01-05-2012, 03:47 AM
I like that code above.. but I'm no so sure what you guys mean by if it's silver or gold..
an or operator would fix that..
Simba Code:
if (Not FindDTM(GoldBarDTM, X, Y, Box.X1, Box.Y1, Box.X2, Box.Y2) or NotFindDTM(SilverBar....)) then
But your method seems pretty solid though I have to ask.. what happens when you get a strange rock or another object appears in your invent such as the MysteryBox or that purple box from randoms.. Then wouldn't your code constantly be stuck waiting for the bar to be found?
Edit: LOL forget what I said.. I just read it over.. it breaks out :D NICE!
[Nathan]
01-05-2012, 03:50 AM
I like that code above.. but I'm no so sure what you guys mean by if it's silver or gold..
He said that he is coming straight from the mine mining both silver and gold ore, so the inventory is going to contain both, and where in the inventory each is is then unknown, so you can't just search for one of the ore types. If that made any sense.
cause
01-05-2012, 03:52 AM
That operator is a good idea, the thing is, I have to click the furnace again after smelting all the gold ores to smelt all the silver ores.
[Nathan]
01-05-2012, 03:55 AM
That operator is a good idea, the thing is, I have to click the furnace again after smelting all the gold ores to smelt all the silver ores.
Another thought that I have used before, that is probably simpler and likely more accurate (and will fix the possible problem about other items) is just to check the xp bar for xp gains. Do something like if it has been more than 5 seconds since xp was gained, all the ores are probably smelted.
Here is a method I have used for that:
procedure sleepWhileGainingXP(var sleepTime:integer);
var xp1:Integer;
var finished:boolean;
begin
finished:=false;
while not(finished) do
begin
xp1:= GetXPBarTotal;
sleep(sleepTime+random( (sleepTime * (15 / 100))) );
AntiBan;
if not(GetXPBarTotal > xp1) then
finished:=true;
end;
end;
And its worked perfectly for me!
cause
01-05-2012, 04:23 AM
Oh hey that's a great idea!! Except my function works now with a couple waits thrown in there but good idea dude I'll probably use that instead of this in the future.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.