SRL Archive - SRL Suggestions

Updated WoodCutting.Simba


NCDS

2010-09-07 22:24:14

SRL's current WoodCutting.Simba:

{*******************************************************************************
function FindAxe: Boolean;
By: Sumilion, edited by Rasta Magician and EvilChicken!
Description: Finds if there is an axe present. Axe can be wielded or unwielded.
Results name of found axe as uncapitalized string.
*******************************************************************************}
function FindAxe: string;
var
Ix, Iy: Integer;
I, InvAxe, WieldAxe, FoundAxe: Byte;
begin
Result := '';
if not LoggedIn then exit;
srl_LoadBitmaps([47, 48, 49, 50, 51, 52, 53, 54, 110]);
I := 0;

repeat
case GetCurrentTab of
tab_Equip: begin
for WieldAxe := 0 to 8 do
if FindTransparentBitmapTolerance(srl_GetBitmap(54-WieldAxe + Integer(WieldAxe = 8) * 64),Ix, Iy, clBlack, 566, 285, 606, 327, 10) then
Break;
if I = 0 then
if not GameTab(tab_Inv) then exit;
Inc(I);
end;

tab_Inv: begin
for InvAxe := 0 to 8 do
if FindTransparentBitmapTolerance(srl_GetBitmap(54 - InvAxe + Integer(InvAxe = 8) * 64), Ix, Iy, clBlack, MIX1, MIY1, MIX2, MIY2, 10) then
Break;
if I = 0 then
if not GameTab(tab_Equip) then exit;
Inc(I);
end;
else
if not GameTab(tab_Equip) then exit;
end;
until I = 2;

if (InvAxe = 9) and (WieldAxe = 9) then
begin
Writeln('No axe was found.');
srl_FreeBitmaps;
Exit;
end;

FoundAxe := Min(WieldAxe, InvAxe);

case FoundAxe of
0: Result := 'dragon';
1: Result := 'rune';
2: Result := 'addy';
3: Result := 'mith';
4: Result := 'black';
5: Result := 'steel';
6: Result := 'iron';
7: Result := 'bronze';
8: Result := 'adze';
end;

WriteLn('Using ' + Capitalize(Result) + ' axe.');
srl_FreeBitmaps;
end;

{*******************************************************************************
function FindBirdsNest: Boolean;
By: Liquid and Starblaster100
Description: If a birds nest is found, it will pick it up
*******************************************************************************}

function FindBirdsNest: Boolean;
var
tries, x, y: Integer;
s: string;
begin
if (not (GetLastChatText(s))) then
LastChatter(s);
if (Pos(s, 'A bird') <> 0) then
begin
repeat
if not (FindObj(x, y, 'Take Bird', 3952984, 10)) or
not (FindObj(x, y, 'Take Bird', 1713706, 10)) or
not (FindObj(x, y, 'Take Bird', 1581604, 10)) then
begin
KeyDown(VK_LEFT);
Wait(700 + Random(500));
KeyUp(VK_LEFT);
Wait(400 + Random(300));
end;
if not (FindObj(x, y, 'Take Bird', 3952984, 10)) or
not (FindObj(x, y, 'Take Bird', 1713706, 10)) or
not (FindObj(x, y, 'Take Bird', 1581604, 10)) then
begin
x := 648;
y := 83;
tries := tries + 1;
FindColorSpiral(x, y, 241, 570, 5, 725, 155);
Mouse(x + 3, y + 3, 2, 2, True);
Flag;
Wait(200 + Random(100));
end;
if (FindObj(x, y, 'Take Bird', 3952984, 10)) or
(FindObj(x, y, 'Take Bird', 1713706, 10)) or
(FindObj(x, y, 'Take Bird', 1581604, 10)) then
begin
WriteLn('Birds Nest Found');
Wait(450 + Random(400));
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
Flag;
Result := True;
Wait(500 + Random(300));
if (Screenshots) then
SaveScreenshot('Birds Nest - SRL - ' + IntToStr(GetTimeRunning) + '.bmp');
tries := tries + 100;
// Birdsnest := Birdsnest + 1;
Mouse(583, 226, 2, 2, False);
Wait(100 + Random(100));
ChooseOption('Examine');
Exit;
end;
until (FindObj(x, y, 'Take Bird', 3952984, 10)) or
(FindObj(x, y, 'Take Bird', 1713706, 10)) or
(FindObj(x, y, 'Take Bird', 1581604, 10)) or (tries > 5)
end;
end;

{*******************************************************************************
function FindEnt(fx, fy: Integer; AvoidWhenFound: Boolean): Boolean;
By: Sumilion
Description: Uses UpText to check if an ent is present at fx, fy.
If AvoidWhenFound is set to True, it will try to avoid the ent.
*******************************************************************************}
function FindEnt(fx, fy: Integer; AvoidWhenFound: Boolean): Boolean;
var
X, Y, EntTime, tcts: Integer;
begin
Result := False;
if not LoggedIn then exit;
GetMousePos(X, Y);
if (X <> fx) or (Y <> fy) then
MMouse(fx, fy, 0, 0);
if IsUpText('Chop') then
begin
tcts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.75);
Result := (CountColorTolerance(118478, 9, 10, 124, 23, 10) > 10);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(tcts);
end;
if Result then
begin
WriteLn('Ent detected!');
if AvoidWhenFound then
begin
Writeln('Waiting for it to go away.');
MFNF(MMCX, MMCY, -1, 1);
MarkTime(EntTime);
while TimeFromMark(EntTime) < 35000 do
if Random(20) > 15 then
IdleTime(500, 500, 0.4)
else
Wait(500 + Random(500));
// Inc(EntsAvoided);
end;
end;
end;


{*******************************************************************************
procedure SetupWoodcutting;
By: SRL
Description: Declares Global Bitmaps.
*******************************************************************************}
procedure SetupWoodcutting;
begin
end;

Now, obviously FindEnt could just be removed, unless it's kept for archiving purposes?

With my updates:

{*******************************************************************************
function FindAxe: Boolean;
By: Sumilion, edited by Rasta Magician and EvilChicken!
Description: Finds if there is an axe present. Axe can be wielded or unwielded.
Results name of found axe as uncapitalized string.
*******************************************************************************}
function FindAxe: string;
var
Ix, Iy, tab: Integer;
I, InvAxe, WieldAxe, FoundAxe: Byte;
begin
Result := '';
if not LoggedIn then exit;
srl_LoadBitmaps([47, 48, 49, 50, 51, 52, 53, 54, 110]);
I := 0;
tab := GetCurrentTab;

repeat
case GetCurrentTab of
tab_Equip: begin
for WieldAxe := 0 to 8 do
if FindTransparentBitmapTolerance(srl_GetBitmap(54-WieldAxe + Integer(WieldAxe = 8) * 64),Ix, Iy, clBlack, 566, 285, 606, 327, 10) then
Break;
if I = 0 then
if not GameTab(tab_Inv) then exit;
Inc(I);
end;

tab_Inv: begin
for InvAxe := 0 to 8 do
if FindTransparentBitmapTolerance(srl_GetBitmap(54 - InvAxe + Integer(InvAxe = 8) * 64), Ix, Iy, clBlack, MIX1, MIY1, MIX2, MIY2, 10) then
Break;
if I = 0 then
if not GameTab(tab_Equip) then exit;
Inc(I);
end;
else
if not GameTab(tab_Equip) then exit;
end;
until I = 2;

Gametab(tab);

if (InvAxe = 9) and (WieldAxe = 9) then
begin
Writeln('No axe was found.');
srl_FreeBitmaps;
Exit;
end;

FoundAxe := Min(WieldAxe, InvAxe);

case FoundAxe of
0: Result := 'dragon';
1: Result := 'rune';
2: Result := 'addy';
3: Result := 'mith';
4: Result := 'black';
5: Result := 'steel';
6: Result := 'iron';
7: Result := 'bronze';
8: Result := 'adze';
end;

WriteLn('Using ' + Capitalize(Result) + ' axe.');
srl_FreeBitmaps;
end;

{*******************************************************************************
function FindBirdsNest: Boolean;
By: NCDS
Description: If a birds nest is found, it will pick it up
*******************************************************************************}
function FindBirdsNest: Boolean;
var
x, y, ic, t: Integer;
begin
if (not(IsChatBoxTextBetween('nest falls out of', 0, 8, 6))) then
Exit;
ic := InvCount;

if FindObjEx(x, y, ['s nest'], [4016204], 3, 25, MSCx - 100, MSCy - 100, MSCx + 100, MSCy + 100) then
begin
Mouse(x, y, 2, 2, False);
WaitOption('ake', 2000);
MarkTime(t);

while (TimeFromMark(t) < 3000) do
if InvCount > ic then
begin
Result := True;
Exit;
end else
Wait(50);
end;
end;

{*******************************************************************************
procedure SetupWoodcutting;
By: SRL
Description: Declares Global Bitmaps.
*******************************************************************************}
procedure SetupWoodcutting;
begin
end;

All I changed in FindAxe, is that I made it go back to the original Gametab it was on when the function was called, after it has been executed.

As you can see, I completely re-wrote FindBirdsNest as the old one looked quite outdated.

I haven't been able to test FindBirdsNest however due to lack of members account (compiled it though of course), but it uses all the same info as the one I made for MSI, which worked for me less than a month ago. So, I would assume it work's, but would appreciate someone testing it.

I've also updated all the Hatchet bitmaps except the Adze, as I don't have one.

bmp_Axe_Bronze: Result := BitmapFromString(2, 5, 'meJxjYmBgYmCQ0rXhFYqU1LaEkDxC' +
'YRAEAC7lA84=');
bmp_Axe_Iron: Result := BitmapFromString(2, 5, 'meJxjYmBgYmCwsbHnFYq0tLSBkDxC' +
'YRAEADlGBGQ=');
bmp_Axe_Steel: Result := BitmapFromString(3, 3, 'meJxjYmBgAqP4+OTY2EReoUggGR0d' +
'D2QAADcHBWM=');
bmp_Axe_Black: Result := BitmapFromString(2, 5, 'meJxjYmBgYmDg5eXjFYqEkzxCYRAE' +
'AB3LAsk=');
bmp_Axe_Mithril: Result := BitmapFromString(3, 3, 'meJxjYmBgAiNvYyNPQ0NeoUgg6aav' +
'D2QAACQhA6E=');
bmp_Axe_Adamant: Result := BitmapFromString(2, 5, 'meJxjYmBgYmAwszfjFYo0sTGBkDxC' +
'YRAEADcjBEQ=');
bmp_Axe_Rune: Result := BitmapFromString(2, 5, 'meJxjYmBgYmDw9bDmFYr0drWCkDxC' +
'YRAEAD7SBLU=');
bmp_Axe_Dragon: Result := BitmapFromString(2, 5, 'meJxzD6hnYmDwCm72DmnlE0n0CW3n' +
'FYnnE03jFY7lE00GAHQiBxQ=');
All were tested and worked with FindAxe.


Have at it.

marpis

2010-09-08 00:36:25

Nice :) Especially nice that you updated the bitmaps, as I believe most of the SRL bitmaps are outdated.
E: But I don't have the time to commit atm, leaving for school in 5 minutes

NCDS

2010-09-08 00:38:23

From: marpis
Nice :) Especially nice that you updated the bitmaps, as I believe most of the SRL bitmaps are outdated.

Thanks, I'll hopefully be getting to most of those over the next few day's.

Naum

2010-09-08 11:47:54

Committed all of it, apart from FindBirdsNest (Apparently Nava or someone was going to add theirs).
If they don't, I'll commit yours.
Thanks for the fixes ;)

EDIT: Bitmaps are outdated, all bitmaps up to Bmp_Rune_Blood are fine along with the axes now.

NCDS

2010-09-08 13:03:56

From: Naum
Committed all of it, apart from FindBirdsNest (Apparently Nava or someone was going to add theirs).
If they don't, I'll commit yours.
Thanks for the fixes ;)

EDIT: Bitmaps are outdated, all bitmaps up to Bmp_Rune_Blood are fine along with the axes now.


My pleasure, thanks for committing :)