Strange, wasn't getting any "The following DTMs were not freed: [2, 3, 4]" message until now :( both functions are causing the message. I have a FreeDTMZ procedure, going to try to add it to the functions utilizing DTMs and see if that fixes it.
From: Runaway
Just another variation:
function NoBow: Boolean;
var
BowDTM: TIntegerArray;
c, i, x, y: Integer;
begin
BowDTM := [Shortbow, Longbow];
for i := 0 to High(BowDTM) do
begin
if FindDTM(BowDTM[i], x, y, MIX1, MIY1, MIX2, MIY2) then
Inc(c);
end;
Result := (c < 1);
end;
Not necessarily very useful for only two variables, but it's usefulness increases exponentially when more variables are needed.
Going to stare at that for a few minutes to see if I can comprehend what is being done there :( :p lol
So i is going to act as the Longbow or Shortbow DTM? (it gets replaced by what is in the brackets [Longbow, Shortbow]?)
I'm just lost at the end. What is the purpose of c exactly? Why increase it but have the result as less than 1?
EDIT: Still getting DTMs not freed. No need to read the full script it's just makes it easier for me to compare what I have to what was suggested.
program RoflmeFletcher;
{$DEFINE SMART}
{$i SRL\SRL.simba}
{$i SRL\SRL\Misc\Debug.simba}
// Thank you for using my script.
// Read thread for instructions and details.
// Also post any issues on the thread.
const
//CASE SENSITIVE (At least for me while testing)
FletchType = 'string';
//'bow' for unfinished bows,
//'string' for complete bows,
//'arrow' for arrows,
//'bolt' for bolts,
//'dart' for darts
//ONLY BOW AND STRING WORK FOR NOW
BowType = '';
//'shortbow' for shortbows,
//'longbow' for longbows
//only fill out if making unfinished bows
var
x, y, Log, Longbow, Shortbow, LogsCut, BowsStrung, t: Integer;
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
With Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
Active := true;
end;
end;
Procedure AntiBan;
begin
Case Random(800) of
1: RandomRClick;
2: RandomMovement;
3..10: BoredHuman;
11..20: PickUpMouse;
21..800: Wait(500);
end;
SetAngle(SRL_ANGLE_HIGH);
Wait(350+Random(200));
end;
Procedure SetDTMs;
begin
Log := DTMFromString('mlwAAAHicY2dgYJjBxMAwAYinA/FCIF4KxLOAeDIQPwXK3wHi21D6BRC/A+IPQGykww8kmbDi/wy4ASMeDAUARmYMBQ==');
Longbow := DTMFromString('mQwAAAHicY2ZgYAhjYmBIAmJXII5iZGDIBmJ/IC5ITQTKMkExAjAiYSAAAJ8NA1s=');
Shortbow := DTMFromString('mQwAAAHicY2ZgYBACYlkGCOCD0uJAXJSWDCSZoBgBGJEwEAAAQj4Bmg==');
end;
procedure FreeDTMZ;
begin
FreeDTM(Log);
FreeDTM(Longbow);
FreeDTM(Shortbow);
end;
Procedure Bank;
begin
begin
repeat
OpenBankChest(SRL_BANK_SW);
until BankSCreen or PinScreen;
end;
if PinScreen then
begin
repeat
InPin(Players[0].Pin);
until BankScreen
end;
if BankScreen then
begin
DepositAll;
Case FletchType of
'bow':
begin
Withdraw(0,0,28);
end;
'string':
begin
Withdraw(0,0,14);
Wait(200+Random(100));
Withdraw(1,0,14);
end;
end;
Wait(100);
Closebank;
repeat
wait(10);
until InvCount > 0;
end;
end;
Function GetDaText(var cx, cy: Integer; TextHere: String): Boolean;
begin
Result := FindText(cx, cy, TextHere, StatChars, MCX1, MCY1, MCX2, MCY2);
end;
Function NoLogs: Boolean;
begin
Result := not FindDTM(Log, x, y, MIX1, MIY1, MIX2, MIY2);
end;
Function NoBow: Boolean;
begin
Result := (not FindDTM(Longbow, x, y, MIX1, MIY1, MIX2, MIY2)) or (not FindDTM(Shortbow, x, y, MIX1, MIY1, MIX2, MIY2));
end;
Function OptionsAppeared: Boolean;
begin
Result := CountColorTolerance(2070783, MCX1, MCY1, MCX2, MCY2, 14) > 50;
end;
Function Cut: Boolean;
begin
MarkTime(t);
if FindDTM(Log, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
MouseItem(RandomRange(1,28), mouse_left);
wait(200+random(50));
repeat
wait(100);
if TimeFromMark(t) > 10000 then
begin
TerminateScript;
end;
until(OptionsAppeared);
Result := True
end else
begin
TerminateScript;
end;
end;
Procedure FletchBow;
begin
if GetDaText(x, y, 'nife') then
begin
Mouse(x, y, 5, 5, mouse_left);
repeat
wait(100);
until GetDaText(x, y, 'bow')
end;
Case BowType of
'longbow':
begin
if GetDaTExt(x, y, 'ongb') then
begin
Mouse(x, y, 5, 5, mouse_left);
end;
end;
'shortbow':
begin
if GetDaTExt(x, y, 'ortb') then
begin
Mouse(x, y, 5, 5, mouse_left);
end;
end;
end;
Repeat
AntiBan;
WaitFunc(@NoLogs, 10, 5000);
Until NoLogs;
LogsCut := LogsCut + InvCount
end;
Function StringBow: Boolean;
begin
MarkTime(t)
if FindDTM(Longbow, x, y, MIX1, MIY1, MIX2, MIY2) or
FindDTM(Shortbow, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('Found unstrung bows, stringing them')
MouseItem(14,mouse_left);
MouseItem(15,mouse_left);
repeat
wait(200);
if TimeFromMark(t) > 10000 then
begin
TerminateScript;
end;
until OptionsAppeared
Result := True
Writeln('Found Option Color');
end else
begin
TerminateScript;
end;
if GetDaText(x, y, 'bow') then
begin
Mouse(x, y, 5, 5, mouse_left);
repeat
AntiBan;
WaitFunc(@NoBow, 10, 5000);
until NoBow;
end else
begin
TerminateScript;
end;
end;
procedure Report;
begin
ClearDebug;
Case FletchType of
'bow':
begin
Writeln('Roflme''s Fletcher');
Writeln('Logs cut:' + IntToStr(LogsCut));
Writeln('Script has run for ' + TimeRunning);
end;
'string':
begin
Writeln('Roflme''s Fletcher');
Writeln('Bows strung:' + IntToStr(BowsStrung));
Writeln('Script has run for ' + TimeRunning);
end;
end;
end;
procedure MainLoop;
begin
Bank;
case FletchType of
'bow':
begin
Cut;
FletchBow;
end;
'string':
begin
StringBow;
end;
end;
Report;
end;
begin
Cleardebug;
DeclarePlayers;
Smart_Server := 1;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SmartSetRefresh(70);
LoginPlayer;
SetAngle(SRL_ANGLE_HIGH);
SetDTMs;
repeat
MainLoop;
until(false);
FreeDTMZ;
end.
Although I'm looking at
Function StringBow: Boolean;
begin
MarkTime(t)
if FindDTM(Longbow, x, y, MIX1, MIY1, MIX2, MIY2) or
FindDTM(Shortbow, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('Found unstrung bows, stringing them')
MouseItem(14,mouse_left);
MouseItem(15,mouse_left);
repeat
wait(200);
if TimeFromMark(t) > 10000 then
begin
TerminateScript;
end;
until OptionsAppeared
Result := True
Writeln('Found Option Color');
end else
begin
TerminateScript;
end;
if GetDaText(x, y, 'bow') then
begin
Mouse(x, y, 5, 5, mouse_left);
repeat
AntiBan;
WaitFunc(@NoBow, 10, 5000);
until NoBow;
end else
begin
TerminateScript;
end;
end;
I'm guessing the first if then is wrong because that's where it gets stuck. It won't write the "found unstrung bows" piece. :(
EDIT: And when I take that out, the NoBow function isn't working properly. As soon as it begins stringing it will go to bank.