So I worked off of that idea and I came up with this. Seems to work pretty well. It also checks to see if the flag went off the map and acts accordingly—that was another problem I was having.
{Credits to the creaters/updaters of FlagEx
(Wizzup? / WT-Fakawi / ZephyrsFury modified by N1ke!)
Used some of FlagEx}
Procedure BBFlag(Dist: integer);
var
TimeFS1, TimeFS2, Distance1, a, b: integer;
begin
Wait(500 + random(250));
MarkTime(TimeFS1);
While IsMoving do
begin
if(FindColor(a, b, 3026478, mmx1, mmy1, mmx2, mmy2))then
begin
Wait(50);
Distance1 := Distance(a, b + 14, MMCX, MMCY);
if(Distance1 <= Dist)then
Exit;
end else
if(not(IsMoving))then
Exit
else
if(not(OffMapFlag))then
Exit;
Wait(200);
MarkTime(TimeFS2);
if((TimeFS2 - TimeFS1) > 6000)then
if(Distance1 = Distance(a, b + 14, MMCX, MMCY))then
Exit;
if (Random(20) = 0)then
IdleTime(500, 1000, 0.01);
end;
end;