3Garrett3
2010-07-27 15:05:16
{******************************************************************************}
{ Procedure MSI_WaitWhileFishing }
{ By: 3Garrett3 }
{ Date: 25 July 2010 }
{ Description: Waits while fishing }
{******************************************************************************}
procedure MSI_WaitWhileFishing;
var
OldInvCount, WaitTime, InvTimer, cts, CheckTime : Integer;
MyChar : TBox;
script: TScript;
TColour, TTol, TCount, AvCount, i, TWait : Integer;
THue, TSat : Extended;
Tools : TPointArray;
ToolAmount : TIntegerArray;
begin
Flag;
Wait(RandomRange(300, 450));
if InvFull then
Exit;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
MyChar := IntToBox(205, 121, 338, 219);
script := MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript]];
// Have a case to determine what colours/tols/hue/sat to look for and what counts of it
case (script.ObjectConstants[i]) of
FISHSPOT_NET:
begin
TColour:= 2108472;
TTol := 11;
THue := 0.09;
TSat := 0.27;
TCount := 50;
TWait := 1000;
end;
FISHSPOT_BAIT:
begin
TColour:= 727589;
TTol := 4;
THue := 0.17;
TSat := 0.65;
TCount := 50;
TWait := 1000;
end;
FISHSPOT_LURE: // Still not done
begin
TColour:= 2108472;
TTol := 11;
THue := 0.09;
TSat := 0.27;
TCount := 50;
TWait := 1000;
end;
FISHSPOT_CAGE:
begin
TColour:= 4934735;
TTol := 11;
THue := 0.38;
TSat := 0.08;
TCount := 8;
TWait := 3000;
end;
FISHSPOT_HARPOON: // Still not done
begin
TColour:= 2108472;
TTol := 11;
THue := 0.09;
TSat := 0.27;
TCount := 50;
end;
end;
SetToleranceSpeed2Modifiers(THue, TSat); // Set the vars and such
WaitTime := GetSystemTime + 90000;
OldInvCount := InvCount;
MarkTime(InvTimer);
repeat
MSI_FindRandoms;
MSI_AntiBan(RandomRange(0, 3000), ANTI_BAN_CHANCE);
if (TimeFromMark(InvTimer) > 30000) then // If no new fish in inv after 30 seconds, spot probably moved
if (OldInvCount = InvCount) then break
else begin
OldInvCount := InvCount;
MarkTime(InvTimer);
end;
MarkTime(CheckTime);
repeat // Counts the occurance of a tool colour on the MS
FindColorsSpiralTolerance(MMCX, MMCY, Tools, TColour, MyChar.X1, MyChar.Y1, MyChar.X2, MyChar.Y2, TTol);
CombineIntArray(ToolAmount, [Length(Tools)]); // adds the length of the tool array (how many instances found)
Wait(55);
until(TimefromMark(CheckTime) > TWait)
AvCount := AverageTIA(ToolAmount);
if AvCount < TCount then break; // If count of tool on MS is less, it should be done fishing
Wait(RandomRange(200, 500));
until(WaitTime > GetSystemTime)
ColorToleranceSpeed(cts);
end;
So basically, to break it down. Here are the main points of what I am trying to do:
- Set the colours/tols/wait times
- Find the average amount of matching pixels in a box around the player
- Compare to the amount which I have found most accurate
- If it is less, then the tool is no longer on the main screen = fishing is done
So this worked 100% when I tested with nets and bait, and presumably lure (since it is the exact same as bait). But then I went to try it with harpoon and lobster cage, and they disappear under the water while fishing, so it is much more random whether or not you see the tool while checking. To counteract it, I set up a larger wait time, but it is still pretty sketchy. I've tried PixelShift (after Coh3n suggested it) and it was pretty much a failure. The char moves around while just swaying more than he does while fishing. I don't know what else gives off that the fishing spot is gone or not, as they can overlap (and they visually disappear during their animation anyway).
So here are the problems:
- Fishing Spots have dynamic animations - Making it hard to figure out if they are there
- Fishing spots can overlap - If your spot is gone, there may be one below it which means a false positive
- Some fishing tools disappear while others do not during the fishing progress - It is difficult to count the occurrence of lobster pot pixels when it is underwater = invisible
- With all of the above methods, the general search box must accommodate a larger search area, for the possibility of a fishing spot being above/below/left/right of the character - This allows for false positives if someone is fishing on a spot directly below you (almost all fishing locations have this possibility)
- PixleShift has proven mostly useless because the amount of pixels which shift around the character are generally the same (240 and 250 for fishing/standing respectively)
So a list of solutions must be made. I'm willing to incorporate all of the above methods to make it work, I just don't know how yet, there will obviously have to be a case statement inside the wait procedure.
To solve the last problem - I can create 4 boxes; one containing the player and the small area above the fishing spot on the left, one on the right, etc. This allows for it to only be searching in the spot that you are fishing, rather than the large box around your player (all four spots). I would have to create another function to determine which side it is on, most likely through the use of the coordinates that it found the fishing spot in.
I have no general solution for the other problems (obviously), which is why I am posting it here. Anyone who can offer some feedback on what I should do, I will love you forever. This is the one thing that is keeping me from testing Fishing.scar, and then incorporating it into MSI.