realrune
2006-06-23 16:40:38
Features :
Uses 2 bitmap masks to replace 3 large bitmaps that are in mining.scar.
Only loads the pickaxe and pickhandle bitmaps when looking for pickhead, and free's them later.
Support for equipped picks and non-equipped picks.
Findpickheadcolor auto detects whether pick is equipped or not.
Better pick finder, uses findobj first, if findobj fails it reverts to stupid3000's pickfinder.
Here it is :
Uses 2 bitmap masks to replace 3 large bitmaps that are in mining.scar.
Only loads the pickaxe and pickhandle bitmaps when looking for pickhead, and free's them later.
Support for equipped picks and non-equipped picks.
Findpickheadcolor auto detects whether pick is equipped or not.
Better pick finder, uses findobj first, if findobj fails it reverts to stupid3000's pickfinder.
Here it is :
program PickFinder;
{.include srl/srl.scar}
var EquipPick, NoPick, PickUpItems : boolean;
var PickHeadBmp, PickHandleBmp, PickaxeMaskBmp, OreMaskBmp : integer;
var PicksFound, PicksBroke : integer;
var PickHeadColors : array[1..5] of integer;
function FindPickHeadColor: Boolean; // By Stupid3000, edit by RealRune
begin
GameTab(4);
if(FindBitMapMaskTolerance(PickaxeMaskBmp,x,y,MIX1,MIY1,MIX2,MIY2,20,25))then
begin
EquipPick := False;
Result:=True;
end
Else
begin
GameTab(5);
Wait(200 + random(200));
if(FindBitMapMaskTolerance(PickaxeMaskBmp,x,y,MIX1,MIY1,MIX2,MIY2,20,25))then
begin
EquipPick := True;
Result:=True;
end;
end;
if(Result=false)then
begin
writeln('');
writeln('ERROR! cannot find pick in screen, please put pick in inventory or your equip page and restart the script!');
writeln('');
Result:=False;
end else
begin
PickHeadColors[1]:=GetColor(x + 1, y + 3);
PickHeadColors[2]:=GetColor(x + 11, y + 7);
PickHeadColors[3]:=GetColor(x + 8, y + 5);
PickHeadColors[4]:=GetColor(x + 11, y + 6);
PickHeadColors[5]:=GetColor(x + 6, y + 3);
writeln('Pick head colors... '+inttostr(PickHeadColors[1])+' '+inttostr(PickHeadColors[2])+' '+inttostr(PickHeadColors[3])+' '+inttostr(PickHeadColors[4])+' '+inttostr(PickHeadColors[5]));
end;
end;
procedure LoadPickFinderBitmaps;
begin
PickHeadBmp := BitmapFromString(6, 5,
'2E1F002E1F00352400000001483E33483E331D1400261A002E1F00' +
'352400000001483E331D14001D1400261A002E1F00000001302020' +
'000001000001000001000001302020302020302020302020302020' +
'302020302020483E33');
PickHandleBmp := BitmapFromString(15, 27,
'564D41595145564D41544A3C544A3C595145564D41564D41564D41' +
'564D41595145000001000001544A3C4F4538544A3C595145564D41' +
'544A3C544A3C544A3C5951455951455951455951450000012F2000' +
'362400000001544A3C564D41544A3C544A3C564D41564D41564D41' +
'5951455951455951450000012F20002F2000362400000001302020' +
'564D41544A3C544A3C595145564D41595145564D41595145595145' +
'0000012F2000362400362400000001302020564D41564D41564D41' +
'564D41564D41544A3C544A3C544A3C0000012F20002F2000362400' +
'362400000001302020544A3C544A3C544A3C544A3C544A3C544A3C' +
'544A3C544A3C0000012F2000362400362400362400000001302020' +
'544A3C564D41564D41564D41544A3C564D41564D410000012F2000' +
'2F2000362400362400000001302020302020564D41564D41564D41' +
'595145564D41564D41564D410000012F2000362400362400000001' +
'302020302020544A3C544A3C544A3C544A3C595145544A3C544A3C' +
'0000012F2000362400362400362400000001302020564D41564D41' +
'544A3C544A3C544A3C564D41544A3C4F45380000012F2000362400' +
'362400000001302020302020564D41564D41544A3C544A3C595145' +
'595145564D410000012F2000362400362400362400000001302020' +
'564D41564D41544A3C544A3C564D41564D41595145595145000001' +
'2F20002F20002F2000000001302020302020564D41564D41544A3C' +
'564D41564D41544A3C564D410000012F20002F20002F2000362400' +
'000001302020564D41544A3C544A3C544A3C595145544A3C544A3C' +
'564D410000012F20002F20002F2000000001302020302020544A3C' +
'544A3C564D41564D41595145544A3C544A3C0000012F20002F2000' +
'2F2000000001302020302020595145544A3C564D41595145595145' +
'595145564D41564D410000012F20002F20002F2000000001302020' +
'595145595145564D41564D41595145595145595145595145000001' +
'2F20002F20002F2000000001302020302020595145595145595145' +
'595145564D41564D41564D41564D410000012F20002F20002F2000' +
'000001302020564D41595145595145595145595145564D41564D41' +
'544A3C0000012F20002F20002F2000000001302020302020564D41' +
'595145595145544A3C544A3C564D41595145564D410000012F2000' +
'2F20002F2000000001302020544A3C564D41595145595145544A3C' +
'544A3C564D41564D41564D410000012F20002F2000000001302020' +
'302020544A3C564D41595145595145564D41544A3C544A3C4F4538' +
'000001271B002F20002F2000000001302020595145544A3C564D41' +
'595145595145595145544A3C544A3C544A3C0000011D1500271B00' +
'000001302020302020595145544A3C564D41595145595145595145' +
'564D41564D41564D410000011D15001D1500000001302020595145' +
'544A3C544A3C564D41595145595145595145595145595145544A3C' +
'0000011D15001D1500000001302020564D41595145595145595145' +
'595145564D41595145595145564D41544A3C564D41000001000001' +
'302020302020595145595145595145595145544A3C564D41595145' +
'544A3C544A3C4F4538564D41595145302020302020564D41595145' +
'564D41564D41564D41544A3C544A3C564D41544A3C544A3C544A3C' +
'');
end;
procedure FreePickFinderBitmaps;
begin
FreeBitmap(PickHeadBMP);
FreeBitmap(PickHandleBMP);
end;
function PickBroke : boolean;
begin
if(EquipPick)then
begin
GameTab(5);
Result := (GetColor(581,295)=5067346);
end
Else
begin
GameTab(4);
Result := (GetColor(591,220)=4345174);
end;
end;
procedure PickFinderItemGrab; // By Stupid3000
begin
GameTab(4);
if(FindColor(x,y,241,565,5,725,160))then
begin
Mouse(x,y,1,1,true);
Flag;
Wait(100+random(100));
FindTextSpiral('Take',258,169,50,5,10+random(10));
GetMousePos(x,y);
Mouse(x,y,0,0,true);
Wait(1000+random(100));
end;
end;
function AttachPickaxeHead : boolean;
begin
if(InvFull)then
begin
if(FindBitMapMaskTolerance(OreMaskBmp,x,y,MIX1,MIY1,MIX2,MIY2,20,25))then
begin
Mouse(x, y, 3, 3, false);
ChooseOption(x, y, 'Drop');
wait(750 + random(200));
end;
end;
If EquipPick then
begin
GameTab(5);
Wait(250 + random(50));
if FindBitmapSpiralTolerance(PickHandleBmp,X,Y,560,280,615,322,50) then
begin
Mouse(X,Y,3,3,True);
wait(250 + random(250));
end;
end;
GameTab(4);
Wait(250 + random(200));
if(FindItemBmpTol(PickHeadBmp,50))and(FindItemBmpTol(PickHandleBmp,50))then
begin
ClickItemBmpTol(PickHead,50,true);
wait(1000 + random(250));
ClickItemBmpTol(PickHandle,50,true);
writeln('Attached Head & Handle');
Result:=True;
If EquipPick then
begin
wait(3000 + random(250));
ClickItemColor(hc1,True);
end;
end;
end;
function FindPick : Boolean; // By Stupid3000 / WT-Fakawi, edit by RealRune.
var BR : integer;
begin
Result := true;
if(GetColor(472,380)=0)and(GetColor(482,383)=0)then
begin
NoPick := true;
If PickBroke Then
begin
PicksBroke := PicksBroke + 1;
result := false;
writeln('Broken Pick :(');
BR:=1 + Random(6);
case BR of
1: begin TypeSend('arg'); end;
2: begin TypeSend('aarg'); end;
3: begin TypeSend('arghh'); end;
4: begin TypeSend('dam'); end;
5: begin TypeSend('sjee.'); end;
6: begin TypeSend('darnit'); end;
end;
exit;
end
Else
begin
LoadPickFinderBitmaps;
Wait(1250 + random(500));
if(FindObjMultiText(x, y, 'pic', 'ick', 'head', PickHeadColors[1], 5)) or
(FindObjMultiText(x, y, 'pic', 'ick', 'head', PickHeadColors[2], 5)) or
(FindObjMultiText(x, y, 'pic', 'ick', 'head', PickHeadColors[3], 5)) or
(FindObjMultiText(x, y, 'pic', 'ick', 'head', PickHeadColors[4], 5)) or
(FindObjMultiText(x, y, 'pic', 'ick', 'head', PickHeadColors[5], 5))then
begin
Mouse(x, y, 0, 0, true);
Flag;
end;
BR := 0;
repeat
if(LoggedIn = false)then Exit;
if(InvFull)then
begin
if(FindBitMapMaskTolerance(OreMaskBmp,x,y,MIX1,MIY1,MIX2,MIY2,20,25))then
begin
Mouse(x, y, 3, 3, false);
ChooseOption(x, y, 'Drop');
wait(750 + random(200));
end;
end;
x := random(510) + 5;
y := random(330) + 5;
if(FindColorSpiral(x, y, PickHeadColors[1], 3, 3, 515, 338))or
(FindColorSpiral(x, y, PickHeadColors[2], 3, 3, 515, 338))or
(FindColorSpiral(x, y, PickHeadColors[3], 3, 3, 515, 338))or
(FindColorSpiral(x, y, PickHeadColors[4], 3, 3, 515, 338))or
(FindColorSpiral(x, y, PickHeadColors[5], 3, 3, 515, 338))then
begin
MMouse(x,y,2,2);
if IsUpText('Take') then begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end;
Flag;
wait(1000 + random(100));
end else
if(PickUpItems)then
PickFinderItemGrab;
BR := BR + 1;
until(BR >= 10) or (FindItemBmpTol(PickHeadBmp, 50));
result := AttachPickaxeHead;
if(Result = true)then
begin
NoPick := false;
PicksFound := PicksFound + 1;
end;
FreePickFinderBitmaps;
end;
end;
end;
procedure LoadMiningBitMaps; // BMP Masks, from Wizzups powerminer.
begin
PickaxeMaskBMP := BitmapFromString(18, 12, 'z78DA3330400037' +
'3030C001F0CB1203DC3000EDEC22D555F4B48B9E3652622FE5AE2' +
'5DE04EA86097E7B89497B948418252AA99B472889714CBDF42C1F' +
'7099498BBC836C26005E85072C');
OreMaskBMP := BitmapFromString(11, 11, 'z78DA73730301033070436' +
'2238B60024C35B84CC0A5923C13F0BB937813F0EB22DE04CC5022' +
'CF04CADD404CC890EA0BFCE2F85D4E4C6A212FF470998FCC0600F' +
'B599CC1');
end;
procedure SetupSRLMining;
begin
LoadMiningBitmaps;
PickUpItems := false;
end;