This is my NPC Attacker. There is a function like that in skill/fighting.scar. It inputs six colors (try grabbing unique NPC-colors, not common green colors for exampe), a tolerance for the colors and a TimeOut (exit elapsetime). Works well for me, its pretty basic; it clicks the colors when it sees 'ttac' in the upperleft corner. Many variations can be created, and every script needs its own unique FightNPC, but this is an ok framework.
SCAR Code:
{*******************************************************************************
function FightNPC(Color1, Color2, Color3, Color4, Color5, Color6, tol, TimeOut: Integer): Boolean;
By: WT-Fakawi
Description: Fights NPC. Inputs 6 NPC Colors. (May be the same colors),
tol = tolerance, TimeOut = amount of time before clicking on next NPC
*******************************************************************************}
Function FightNPC(Color1, Color2, Color3, Color4, Color5, Color6, tol, TimeOut: Integer):
Boolean;
var I, Color: Integer;
begin
for I := 1 to 6 do
begin
case I of
1: Color := Color1;
2: Color := Color2;
3: Color := Color3;
4: Color := Color4;
5: Color := Color5;
6: Color := Color6;
end;
if (Loggedin) then
begin
if (FindObj(x,y,'ttac',Color,tol)) then
begin
Result := True;
if(not (Loggedin) or (WeAreDead)) then break;
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
FFlag(10);
FTWait(8);
MarkTime(Mark);
repeat
if(not (Loggedin) or (WeAreDead)) then break;
if (TimeFromMark(Mark) > TimeOut) then break;
FTWait(5);
until ( (not (inFight) or (WeAreDead) ));
Players[CurrentPlayer].Killed := Players[CurrentPlayer].Killed+1;
end
else
Result := False;
end
end
end;