SRL Archive - SRL Archives

FindPickHeadColor


Naum

2009-10-06 19:54:27

The current FindPickHeadColor in SRL wasn't working, (just for jokes, try removing the 'p' from findpickheadcolor).

Anyways, I had a look at the current function, and it's still as flawless as always. The only things which needed to be updated were the DTM and the Cord addition/subtraction.

Tested with ALL pickaxes:

{*******************************************************************************
function FindPickHeadColor: Boolean;
By: WT-Fakawi fixed by NaumanAkhlaQ
Description: Finds PickHead colors. Returns hc1, 2, 3, 4 & 5 for PickHead finding
of False when No Pick is in either GameTab(tab_Inv) or GameTab(5).
Sets Global variable NoPick.
*******************************************************************************}

function FindPickHeadColor: Boolean;
var Pick, ix, iy, curTab : Integer;
begin
Pick := DTMFromString('78DA63FCC2C4C0F09C910115302291409A899' +
'981E1310135FF8830870368CE4B026A78816A5EE3570300F6B206' +
'B0');

NoPick := True; // Assume we dont have a pickaxe....
curTab := GetCurrentTab;
GameTab(tab_Inv);
if FindDTM(Pick, ix, iy, MIX1, MIY1, MIX2, MIY2) then
begin
NoPick := False;
Wielding := False;
EquipPick := Wielding;
end
else
begin
GameTab(tab_Equip);
if FindDTM(Pick, ix, iy, MIX1, MIY1, MIX2, MIY2) then
begin
NoPick := False;
Wielding := True;
EquipPick := Wielding;
end;
end;

if not NoPick then // Amazing.
begin
Wait(100 + Random(100));
mmouse(ix, iy, 0, 0);
Hc1 := GetColor(ix + 1, iy);
Hc2 := GetColor(ix + 2, iy - 1);
Hc3 := GetColor(ix + 6, iy - 1);
Hc4 := GetColor(ix + 12, iy + 1);
Hc5 := GetColor(ix + 16, iy);
Writeln('PickColors = ['+inttostr(hc1)+', '+inttostr(hc2)+', '
+inttostr(hc3)+', ' +inttostr(hc4)+', ' +inttostr(hc5)+'];');
Result := True;
end
else
Result := False;

FreeDTM(Pick);
GameTab(curTab);
end;



EDIT: To test, I used this crudely constructed script:

program New;
{.Include SRL/SRL.Scar}
{.Include SRL/SRL/Misc/Debug.Scar}

Var x, y, hc1, hc2, hc3, hc4, hc5 : Integer;
nopick, wielding, equippick : boolean;
pickcolors : tintegerarray;
tpa, tpa2 : tpointarray;

function FindPickHeadColor: Boolean;
var Pick, ix, iy, curTab : Integer;
begin
Pick := DTMFromString('78DA63FCC2C4C0F09C910115302291409A899' +
'981E1310135FF8830870368CE4B026A78816A5EE3570300F6B206' +
'B0');

NoPick := True; // Assume we dont have a pickaxe....
curTab := GetCurrentTab;
GameTab(tab_Inv);
if FindDTM(Pick, ix, iy, MIX1, MIY1, MIX2, MIY2) then
begin
NoPick := False;
Wielding := False;
EquipPick := Wielding;
end
else
begin
GameTab(tab_Equip);
if FindDTM(Pick, ix, iy, MIX1, MIY1, MIX2, MIY2) then
begin
NoPick := False;
Wielding := True;
EquipPick := Wielding;
end;
end;

if not NoPick then // Amazing.
begin
Wait(100 + Random(100));
mmouse(ix, iy, 0, 0);
Hc1 := GetColor(ix + 1, iy);
Hc2 := GetColor(ix + 2, iy - 1);
Hc3 := GetColor(ix + 6, iy - 1);
Hc4 := GetColor(ix + 12, iy + 1);
Hc5 := GetColor(ix + 16, iy);
Writeln('PickColors = ['+inttostr(hc1)+', '+inttostr(hc2)+', '
+inttostr(hc3)+', ' +inttostr(hc4)+', ' +inttostr(hc5)+'];');
Result := True;
end
else
Result := False;

FreeDTM(Pick);
GameTab(curTab);
end;


Begin
SetupSRL;
findpickheadcolor;
pickcolors := [hc1, hc2, hc3, hc4, hc5];
for x := 0 to high(pickcolors) do
begin
Findcolorstolerance(TPA, pickcolors[x], MIX1, MIY1, MIX2, MIY2, 0);
TPA2 := CombineTPA(tpa, tpa2);
end;
debugtpa(tpa2, '');
End.

Basically cross-references what is found and stored as the colors by finding the colors then storing them to an array, then debuging it.

Markus

2009-10-06 20:10:17

Small question, is there still the need for one with handles/heads being removed?

senrath

2009-10-06 20:17:42

From: Markus
Small question, is there still the need for one with handles/heads being removed?


Well, I assume it could be used to determine what pick the person was using.

Naum

2009-10-06 20:36:03

From: senrath
Well, I assume it could be used to determine what pick the person was using.


Yeah, I don't know if FindPick is needed anymore, because, i think, that pick axe heads have stop flying off.

However, this function is a great way of using the unique colors to manipulate the pick or w/e. But if you don't find a use for it then it's your decision ;). All I did was to fix it, to an extent.

EvilChicken!

2009-10-08 07:51:21

Are those lowercase bold words I see?

Thanks, dude, you're making committing easier for me.
You still had a few flaws in your standards, mainly indentation.

Fixed and committed, thanks.

Ah, how I love being a mod in this subforum.

Naum

2009-10-08 11:03:09

From: EvilChicken!
Are those lowercase bold words I see?

Thanks, dude, you're making committing easier for me.
You still had a few flaws in your standards, mainly indentation.

Fixed and committed, thanks.

Ah, how I love being a mod in this subforum.



Thanks :). I just got the current function and added the stuffs, didn't bother much with the capitalizing as I knew it would be hassle for you :p

P1nky

2009-10-09 15:03:53

From: NaumanAkhlaQ
Thanks :). I just got the current function and added the stuffs, didn't bother much with the capitalizing as I knew it would be hassle for you :p


Next Dev :) <3