SCAR Code:
program PlantFinder;
{.include srl/srl.scar}
function Find2TPApoints(TPA1, TPA2: TPointArray; w, h: Integer): TPointArray;
var i1, i2, l1, l2, r: LongInt;
begin
l1 := High(TPA1);
l2 := High(TPA2);
r := 0;
for i1 := 0 to l1 do
begin
for i2 := 0 to l2 do
begin
if (ABS(TPA1[i1].x - TPA2[i2].x) <= w) and (ABS(TPA1[i1].y - TPA2[i2].y) <= h) then
begin
Inc(r);
SetLength(Result, r + 1);
result[r].x := ((TPA1[i1].x + TPA2[i2].x) div 2);
result[r].y := ((TPA1[i1].y + TPA2[i2].y) div 2);
end;
end;
end;
end;
function ItemCoordsDtm(area: string; dtm: Integer): TPointArray;
var
startx, starty, rowsize, colsize, colnumber, rownumber, col, row: Integer;
x1, y1, x2, y2: Integer;
itemx, itemy: Integer;
i: Integer;
begin
SetArrayLength(Result, 0);
if (CheckArea(area)) then
begin
AreaInfo(area, startx, starty, rowsize, colsize, colnumber, rownumber);
for row := 0 to rownumber - 1 do
for col := 0 to colnumber - 1 do
begin
x1 := startx + col * colsize;
y1 := starty + row * rowsize;
x2 := x1 + colsize;
y2 := y1 + rowsize;
if (FindDTM(dtm, itemx, itemy, x1, y1, x2, y2)) then
begin
i := GetArrayLength(Result);
SetArrayLength(Result, i + 1);
Result[i].x := x1;
Result[i].y := y1;
end;
end;
end;
end;
function CountItemsDtm(area: string; dtm: Integer): Integer;
var
coords: TPointArray;
begin
coords := ItemCoordsDtm(area, dtm);
Result := GetArrayLength(coords);
end;
function StrangePlantFinder: Boolean;
var
l, spx, spy, StartSPF, FruitCount, FruitDTM: integer;
TPA1, TPA2, TPA3: TPointArray;
Begin
if not LoggedIn then exit;
result := false
spx := MSCX;
spy := MSCY;
if FindColorTolerance(spx, spy, 945749, MSCX - 100, MSCY - 110, MSCX + 100, MSCY + 90, 4) and FindColorTolerance(spx, spy, 743503, MSCX - 100, MSCY - 110, MSCX + 100, MSCY + 90, 4) then
begin
FindColorsSpiralTolerance(spx, spy, TPA1, 945749, MSX1, MSY1, MSX2, MSY2, 4);
FindColorsSpiralTolerance(spx, spy, TPA2, 743503, MSX1, MSY1, MSX2, MSY2, 4);
SetLength(TPA1, High(TPA1) + 1);
SetLength(TPA2, High(TPA2) + 1);
TPA3 := Find2TPApoints(TPA1, TPA2, 18, 18);
l := High(TPA3);
if l >= 0 then
begin
if FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) then
begin
writeln('Found Strange Plant attempting to Pick fruit.');
FruitDTM := DTMFromString('78DA63E4646060E0654001B30A8E30B001694' +
'620FE0F048CDC400633031A60442281B40090E026A08607488812' +
'50C30A244408A861C67433BA1A008467066B');
FruitCount := CountItemsDtm('inv', FruitDTM);
Result := True;
MarkTime(StartSPF);
repeat
if FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) then
begin
MMouse(spx, spy, 1, 1);
wait(250 + Random(250));
if IsUpText('trange') then
begin
wait(250 + Random(250));
Mouse(spx, spy, 1, 1, false);
wait(250 + Random(250));
ChooseOption('ick');
wait(500 + Random(600));
if Pos('ready to', GetBlackChatMessage) > 5 then
wait(2000 + Random(1000)) else //Text: The fruit isn't ready to be picked yet...
if (Pos('fruit from', GetBlackChatMessage) > 5) or (CountItemsDtm('inv', FruitDTM) > FruitCount) then //Text: You pick the fruit from the plant.
begin
result := true;
writeln('Picked Fruit From Strange Plant.. Waiting for plant to die...');
FreeDTM(FruitDTM);
repeat
BoredHuman;
wait(2000 + random(1000));
until not FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) or FindFight;
Plants := Plants + 1;
SRLRandomsReport;
exit;
end else
if Pos('unable', GetBlackChatMessage) > 5 then //Text: You're unable to pick the fruit.
begin
result := false;
writeln('The plant is not after you.. Waiting for plant to go...');
FreeDTM(FruitDTM);
repeat
BoredHuman;
wait(2000 + random(1000));
until not FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) or FindFight;
exit;
end;
end;
end else break;
until (TimeFromMark(StartSPF) > 120000) or FindFight;
writeln('Failed to Pick Fruit From Strange Plant');
FreeDTM(FruitDTM);
end;
end;
end;
end;
begin
SetupSrl;
StrangePlantFinder;
end.
i hope this gets added into srl :D
SCAR Code:
program PlantFinder;
{.include srl/srl.scar}
function Find2TPApoints(TPA1, TPA2: TPointArray; w, h: Integer): TPointArray;
var
i1, i2, l1, l2, r: LongInt;
begin
l1 := High(TPA1);
l2 := High(TPA2);
r := 0;
for i1 := 0 to l1 do
begin
for i2 := 0 to l2 do
begin
if (ABS(TPA1[i1].x - TPA2[i2].x) <= w) and (ABS(TPA1[i1].y - TPA2[i2].y) <= h) then
begin
Inc(r);
SetLength(Result, r + 1);
result[r].x := ((TPA1[i1].x + TPA2[i2].x) div 2);
result[r].y := ((TPA1[i1].y + TPA2[i2].y) div 2);
end;
end;
end;
end;
function StrangePlantFinder: Boolean;
var
l, spx, spy, StartSPF, FruitCount, FruitDTM: integer;
TPA1, TPA2, TPA3: TPointArray;
Begin
if not LoggedIn then exit;
result := false
//spx := MSCX;
//spy := MSCY; //What's the use of this :p?
if FindColorTolerance(spx, spy, 945749, MSCX - 100, MSCY - 110, MSCX + 100, MSCY + 90, 4) and FindColorTolerance(spx, spy, 743503, MSCX - 100, MSCY - 110, MSCX + 100, MSCY + 90, 4) then
begin
FindColorsSpiralTolerance(mscx, mscy, TPA1, 945749, MSX1, MSY1, MSX2, MSY2, 4);
FindColorsSpiralTolerance(mscx, mscy, TPA2, 743503, MSX1, MSY1, MSX2, MSY2, 4);
//SetLength(TPA1, High(TPA1) + 1); Setlength(tpa, length(tpa)) ? -.-
//SetLength(TPA2, High(TPA2) + 1);
TPA3 := Find2TPApoints(TPA1, TPA2, 18, 18);
l := High(TPA3);
if l >= 0 then
begin
if FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) then
begin
writeln('Found Strange Plant attempting to Pick fruit.');
FruitDTM := DTMFromString('78DA63E4646060E0654001B30A8E30B001694' +
'620FE0F048CDC400633031A60442281B40090E026A08607488812' +
'50C30A244408A861C67433BA1A008467066B');
FruitCount := CountItems(FruitDTM, 'dtm', [0]); //:)
Result := True;
MarkTime(StartSPF);
repeat
if FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) then
begin
MMouse(spx, spy, 1, 1);
wait(250 + Random(250));
if IsUpText('trange') then
begin
wait(250 + Random(250));
Mouse(spx, spy, 1, 1, false);
wait(250 + Random(250));
ChooseOption('ick');
wait(500 + Random(600));
if Pos('ready to', GetBlackChatMessage) > 5 then
wait(2000 + Random(1000)) else //Text: The fruit isn't ready to be picked yet...
if (Pos('fruit from', GetBlackChatMessage) > 5) or (CountItems(FruitDTM, 'dtm', [0]) > FruitCount) then //Text: You pick the fruit from the plant.
begin
result := true;
writeln('Picked Fruit From Strange Plant.. Waiting for plant to die...');
FreeDTM(FruitDTM);
repeat
BoredHuman;
wait(2000 + random(1000));
until not FindObjTPA(spx, spy, 945749, 4, -1, 18, 18, 4, ['trange']) or FindFight;
Plants := Plants + 1;
SRLRandomsReport;
exit;
end else
if Pos('unable', GetBlackChatMessage) > 5 then //Text: You're unable to pick the fruit.
begin
result := false;
writeln('The plant is not after you.. Waiting for plant to go...');
FreeDTM(FruitDTM);
repeat
BoredHuman;
wait(2000 + random(1000));
until not FindObjTPA(spx, spy, 945749, 4, 1, 18, 18, 4, ['trange']) or FindFight;
exit;
end;
end;
end else break;
until (TimeFromMark(StartSPF) > 120000) or FindFight;
writeln('Failed to Pick Fruit From Strange Plant');
FreeDTM(FruitDTM);
end;
end;
end;
end;
begin
SetupSrl;
StrangePlantFinder;
end.