While it's not easy to determine if a strange plant is ours or not (this can actually be accomplished in the script but not universally) we can still make a detection & handling system if one comes within distance of our player. So here's a basic Strangeplant finder & handler that will work in all scripts.
-Global declaration-
Declare this as a global variable:
Simba Code:
Var
SP_coolDownTimer: Integer;
-Finding the plant-
Simba Code:
Function foundStrangePlant(out Pnt: TPoint): Boolean;
var
cts: Integer;
tpa: TPointArray;
begin
cts := getToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.34, 1.17);
FindColorsSpiralTolerance(MSCX, MSCY, tpa, 612431, MSCx-100, MSCy-100, MSCx+100, MSCy+100, 4);
SetColorSpeed2Modifiers(0.02, 0.02);
ColorToleranceSpeed(CTS);
result := (length(tpa) > 50);
if Result then
Pnt := Point(MedianTPA(tpa).x, MedianTPA(tpa).y);
end;
As you can tell it's pretty primitive, searching just within a 200x200 size box of the middle of the screen (presumed where our player is located) for a unique color to the strange plant. Then simply the amount of color is counted, if the size is high enough it's considered a strange plant.
-Handling the plant-
Simba Code:
Function HandleStrangePlant: Boolean;
var
t: Integer;
Pnt: TPoint;
begin
// To prevent spam-clicking a strange plant
if (GetTimeRunning-SP_coolDownTimer) < 20000 then // 20 seconds
Exit;
if not foundStrangePlant(Pnt) then
Exit;
t := getTimeRunning;
repeat
if not LoggedIn then
Exit;
//FindCustomRandoms;
FindNormalRandoms;
if not foundStrangePlant(Pnt) then
break;
if (FindBlackChatMessage('ou pick') or FindBlackChatMessage('unable to')) then
begin
Result := True;
break;
end;
MMouse(Pnt.X, Pnt.Y, 5, 5);
if waitUptextMulti(['Pick','ick St'], 200) then
begin
Clickmouse2(mouse_right);
chooseOptionMulti(['Pick','ck St']);
Flag;
Wait(RandomRange(1500,2400));
end else if waitUptextMulti(['ttack','ack Str'], 200) then
begin
Result := True;
break;
end;
until((getTimeRunning-t) > 15000)
if Result then
SP_coolDownTimer := GetTimeRunning;
end;
If we successfully interacted with the plant (either pick the fruit or determine it's not after our player) then the global "SP_coolDownTimer" is, once again, reset, so we won't start looking for a strange plant until 20 seconds after the previous one.