PDA

View Full Version : StrangePlant handler



Flight
06-09-2013, 06:09 AM
Hey there! So I wrote this up a while back to work my private cooking script; it will detect when a strange plant is near to your player and will handle it accordingly. Because of the way this works it's best to have this included in the script itself as opposed to the SRL-OSR include. This is just my way of going about handling this random event, it's not official but if you'd like that extra security in your script I'd recommend it.

Here's what you'll need:

The detection:

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(MiddleTPA(tpa).x, MiddleTPA(tpa).y);
end;

^ That will tell you if there's a Strange Plant within a 100 radius of your player, hopefully avoiding strange plants in the distance.

The handling:

Function HandleStrangePlant: Boolean;
var
t: Integer;
Pnt: TPoint;
begin
if not foundStrangePlant(Pnt) then
Exit;

t := getTimeRunning;
repeat
if not LoggedIn then
Exit;

FindNormalRandoms;
if not foundStrangePlant(Pnt) then
break;

if (FindBlackChatMessage('ou pick') or FindBlackChatMessage('unable to')) then
begin
Inc(SPCount);
Result := True;
break;
end else
Wait(RandomRange(1500,2400));

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(300,450));
end else if waitUptextMulti(['ttack','ack Str'], 200) then
begin
Result := True;
break;
end;
until((getTimeRunning-t) > 10000)
end;


Now you'll want a cool-down timer to prevent you from continually trying to pick fruit from the plant. So wherever you call 'FindNormalRandoms' make something like this:

{You'll want to define a global timer, here I name it as "SP_coolDownTimer"}
if (GetTimeRunning-SP_coolDownTimer) > 20000 then // If it's been longer than 20 seconds since our last plant encounter...
if handleStrangePlant then
SP_coolDownTimer := GetTimeRunning; // Mark the current time as the last plant encounter time

The above is explained well enough that you should understand it.


It's worked for me all of the time and I've never gotten attacked by the Strange Plant any more, not to mention the stack of fruits in my bank. So there ya go, if you have any questions or comments post away.

Edit:
Forgot to change a couple functions back to the standard SRL. :p

Justin
06-09-2013, 07:48 AM
Nice work Flight :)

Olly
06-09-2013, 03:53 PM
Hmmm, I think you should split the tpa up and remove ones that are small, there could possibly be people around you (radius 1 of one tile) wearing bits of green that could throw a false positive.

Flight
06-10-2013, 12:10 AM
Hmmm, I think you should split the tpa up and remove ones that are small, there could possibly be people around you (radius 1 of one tile) wearing bits of green that could throw a false positive.

Yeah I could do that but I've yet to come across any other green to match these colors. Perhaps today I'll go around some trees and green-colored players/NPCs to see how it does then.

mohsinj677
08-31-2013, 11:46 AM
{{{{{ This post is so great and nice }}}}}

Yeah I could do that but I've yet to come across any other green to match these colors. Perhaps today I'll go around some trees and green-colored players/NPCs to see how it does then.