Hey guys, been digging into the include and learning quite a bit. I have ran into this one roadblock though. I am trying to do combat but it attacks monsters already in combat. I think the best way to avoid this is to check if the HP Bar is present prior to clicking it.
Is there a function to check for 2 colors at a time or a way to return the tbox params that I can adjust to fit another TBox that would search for the HP bar? My code is below.
Edit: This is for OSRS if that makes a difference.
Simba Code:
{Custom clickObject function. Given I would rather do a record and then load the data in rather than type it out potentially multiple times. Nothing special just gets params for
color finding, filtering, and doWait boolean. I added this because there are some objects that you can immediately interact with upon clicking and there is no animation (interfaces)
so you will put doWait = false opposed to true where you need to be looking for animation and not spam clicking.}
function clickObject(objectColor: TCTS2Color = [1, 1, 1, 1]; bounds: TBox; objectCluster: Int32; sizeFilter1: Int32; sizeFilter2: Int32; objectText: string; doWait: boolean = true; location: TPoint): boolean;
var
TPA, objectArray : TPointArray;
ATPA : T2DPointArray;
currentXP : Integer;
HPCheckBox : TBox;
begin
currentXP := XPBar.Read; //Grabs current xp for comparison to see if we successfully gained xp
if SRL.FindColors(TPA, objectColor, bounds) > 0 then
begin
HPCheckBox:= IntToBox(TPA.Bounds.X1 - 5, TPA.Bounds.Y1 + 5, TPA.Bounds.X2 + 20, TPA.Bounds.Y2 + 20);
if SRL.FindColors(objectArray, $00FF00, HPCheckBox) then
writeln('Found HP Bars');
ATPA:= TPA.Cluster(objectCluster);
ATPA.FilterSize(sizeFilter1, sizeFilter2);
ATPA.SortByIndex(Mainscreen.GetMiddle);
{$IFDEF SMART}
//Smart.Image.DrawATPA(ATPA);
{$ENDIF}
for objectArray in ATPA do
begin
if Fail >= 5 then
begin
RSW.WebWalk(Location);
Fail:= 1;
end;
Mouse.Move(objectArray[Random(Length(objectArray))]);
if MainScreen.IsUpText(objectText) then
begin
if Mouse.Click(ctRed) then
begin
Minimap.WaitPlayerMoving();
if doWait = true then //Added this to allow for clicking objects which will open an interface.
begin
while SRL.IsAnimating(Mainscreen.GetPlayerBox, 160, 650, 1) do
begin
ChatBox.ClickContinue(); //previously had this in the while statement but half the time it didn't catch it
wait(100);
end;
end;
Fail:= 1;
exit(true);
end;
exit(false);
end;
end;
end;
WriteLn('Unable to find object, rotating camera');
Inc(Fail);
Minimap.RandomCompass(10, 200, false);
end;
Edit: wrapped Simba tags