SCAR Code:
{*******************************************************************************
Function SetAttackStyle(Style: Integer, Staff: Boolean): Boolean;
By: Richard
Description: Sets the attack style (1 = top left, 2 = top right, 3 = bottom left
4 = bottom right)(for staffs its vertically down). Also has support for staffs
if Staff is set to true.
*******************************************************************************}
Function SetAttackStyle(Style: Integer; Staff: Boolean): Boolean;
Var
Info: TIntegerArray;
x, y: Integer;
Begin
GameTab(1);
If not(Staff) then
Begin
Case Style of
1: Info := [571, 254, 632, 290];
2: Info := [655, 254, 717, 290];
3: Info := [571, 306, 632, 343];
4: Info := [655, 306, 717, 343];
else
srl_Warn('SetAttackStyle', IntToStr(Style) + 'is not a valid attack style', warn_AllVersions);
end;
end else
Begin
Case Style of
1: Info := [571, 255, 633, 280];
2: Info := [571, 290, 633, 315];
3: Info := [571, 326, 633, 349];
else
srl_Warn('SetAttackStyle', IntToStr(Style) + 'is not a valid attack style', warn_AllVersions);
end;
end;
If FindColorTolerance(x, y, 2106256, Info[0], Info[1], Info[2], Info[3], 50) then
Begin
Result := True;
Exit;
end;
MouseBox(Info[0], Info[1], Info[2], Info[3], 1);
Result := True;
end;
SCAR Code:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- Fighting routines --//
//-----------------------------------------------------------------//
// * Function Damage:Integer; // * By WT-Fakawi
// * function FightNPC(Colors : TIntegerArray, tol, TimeOut: Integer): Boolean;; // *By WT-Fakawi
// * function InFight: Boolean; // *By XxKanexX
// * function IsFightAt(x, y: Integer): Boolean; // *By RealRune
// * Function FindAllHPBars(Sx, Sy, x1, y1, x2, y2: Integer): Array of TPointArray; // By n3ss3s
// * Function GetHitsIn(Sx, Sy, x1, y1, x2, y2: Integer): TIntegerArray; // By n3ss3s
// * Function FindMainScreenHits(Bar: Integer): Integer; // by n3ss3s
// * Function IsAutoRetaliateOn: Boolean; // By Richard
// * Function SetAutoRetaliate(On: Boolean): Boolean; // By Richard
// * Procedure SpecialAttack(MinPercent: Integer); // By Richard
// * Function SetAttackStyle(Style: Integer, Staff: Boolean): Boolean; // By Richard
{*******************************************************************************
Function Damage:Integer;
By: WT-Fakawi
Description: Returns the amount of damage.
*******************************************************************************}
Function Damage:Integer;
begin
Result := (GetSkillInfo('hitpoints',False) - GetSkillInfo('hitpoints',True));
end;
{*******************************************************************************
function FightNPC(Colors : TIntegerArray, tol, TimeOut:
Integer): Boolean;
By: WT-Fakawi & Cazax
Description: Fights NPC. Input an array of colors. (May be the same colors),
tol = tolerance, TimeOut = amount of time before clicking on next NPC
*******************************************************************************}
function FightNPC(Colors : TIntegerArray; tol, TimeOut:
Integer): Boolean;
var
Mark, x, y: Integer;
begin
if (not LoggedIn) then Exit;
if (FindObjCustom(x, y, ['ttack'], Colors, tol)) then
begin
Result := True;
GetMousePos(x, y);
if (not (LoggedIn)) or (FindDead) then
begin
Result := False;
Exit;
end;
Mouse(x, y, 0, 0, True);
Wait(1000 + Random(500));
FFlag(10);
MarkTime(Mark);
repeat
if (not (LoggedIn) or (FindDead) or (FindNormalRandoms)) then Break;
Wait(1000 + Random(500));
if (TimeFromMark(Mark) > TimeOut) then Break;
until ((not FindColorSpiral(x, y, 65280, 240, 140, 290, 175))
or (FindDead)
or (TimeFromMark(Mark) > TimeOut));
end;
end;
{*****************************************************************************
function InFight: Boolean;
By: WT-Fakawi
Description: Returns as True if in fight.
*****************************************************************************}
function InFight: Boolean;
var
x, y : Integer;
begin
Result := (FindColor(x, y, 65280, 230, 130, 280, 180) or
FindColor(x, y, 255, 230, 130, 280, 180));
end;
{*****************************************************************************
function IsFightAt(x, y: Integer): Boolean;
By: realrune
Description: results true if it finds a fight near x,y.
*****************************************************************************}
function IsFightAt(x, y: Integer): Boolean;
var
xx, yy: Integer;
begin
Result := FindColor(xx, yy, 65280, x - 20, y - 20, x + 20, y + 20);
end;
{*******************************************************************************
Function FindAllHPBars(Sx, Sy, x1, y1, x2, y2: Integer): Array of TPointArray;
By: n3ss3s
Description: Finds all the HP bars (the TPAs of them) in the box formed by
x1, y1, x2, y2. Recommended to set Sx and Sy to MSCX and MSCY, so Result[0]
is your own Bar or the closest one to you.
*******************************************************************************}
Function FindAllHPBars(Sx, Sy, x1, y1, x2, y2: Integer): Array of TPointArray;
Var
g, r: TPointArray;
Begin
FindColorsSpiralTolerance(Sx, Sy, g, 65280, x1, y1, x2, y2, 0);
FindColorsSpiralTolerance(Sx, Sy, r, 255, x1, y1, x2, y2, 0);
Result := TPAToATPAEx(CombineTPA(g, r), 31, 5);
End;
{*******************************************************************************
Function GetHits(Sx, Sy, x1, y1, x2, y2: Integer): TIntegerArray;
By: n3ss3s
Description: Finds all HP percents of the HP bars in x1, y1, x2, y2.
READ THE DESCRIPTION OF FindAllHPBars!
*******************************************************************************}
Function GetHitsIn(Sx, Sy, x1, y1, x2, y2: Integer): TIntegerArray;
Var
E: Extended;
TB: TBox;
I: Integer;
TPAA: T2DPointArray;
Begin
TPAA := FindAllHPBars(Sx, Sy, x1, y1, x2, y2);
SetArrayLength(Result, GetArrayLength(TPAA));
For I := 0 To High(TPAA) Do
Begin
TB := GetTPABounds(TPAA[i]);
E := CountColor(65280, TB.x1, TB.y1, TB.x2, TB.y2) / 150;
Result[i] := Round(100 * E);
End;
End;
{*******************************************************************************
Function FindMainScreenHits(Bar: Integer): Integer;
By: n3ss3s
Description: Returns the rounded HP percent of the hp bar Bar counting out from
main screen centre, if Bar is 0, it's your own bar or the closest one to you.
If could not find the bar Bar, returns -1 so you can't confuse it to 0 HP%.
*******************************************************************************}
Function FindMainScreenHits(Bar: Integer): Integer;
Var
TIA: TIntegerArray;
Begin
TIA := GetHitsIn(MSCX, MSCY, MSX1, MSY1, MSX2, MSY2);
Try
Result := TIA[bar];
Except
Result := -1;
End;
End;
{*******************************************************************************
Function IsAutoRetaliateOn: Boolean;
By: Richard
Description: Returns true if auto retaliate is on
*******************************************************************************}
Function IsAutoRetaliateOn: Boolean;
Begin
GameTab(1);
Result := (GetColor(692, 391) = 1711220);
end;
{*******************************************************************************
Function SetAutoRetaliate(On : Boolean): Boolean;
By: Richard
Description: Set auto retaliate to on if true, off if false. Returns the result
false if it is unable to execute the function.
*******************************************************************************}
Function SetAutoRetaliate(SetOn : Boolean): Boolean;
Var
c: Integer;
Begin
If (IsAutoRetaliateOn = SetOn) then
Begin
Result := True;
Exit;
end;
c := (GetColor(692, 391));
MouseBox(571, 361, 713, 396, 1);
If (GetColor(692, 391) <> c) then
Result := True;
end;
{*******************************************************************************
Procedure SpecialAttack(MinPercent: Integer);
By: Richard
Description: Use the special attack button if it is present, and presses it if
the percent of the bar filled is >= MinPercent
*******************************************************************************}
Procedure SpecialAttack(MinPercent: Integer);
Begin
GameTab(1);
If (GetColor(623,424) = 65535) then
Begin
WriteLN('Special attack is already active');
Exit;
end;
If (GetColor(623,424) <> 1048576) then
Begin
WriteLN('Current weapon doesn'#39't have a special attack');
Exit;
end;
If (MinPercent <= Round((((CountColorTolerance(3700023, 572, 417, 713, 428, 120))/1634)*100))) then
MouseBox(570, 413, 714, 431, 1);
end;
{*******************************************************************************
Function SetAttackStyle(Style: Integer, Staff: Boolean): Boolean;
By: Richard
Description: Sets the attack style (1 = top left, 2 = top right, 3 = bottom left
4 = bottom right)(for staffs its vertically down). Also has support for staffs
if Staff is set to true.
*******************************************************************************}
Function SetAttackStyle(Style: Integer; Staff: Boolean): Boolean;
Var
Info: TIntegerArray;
x, y: Integer;
Begin
GameTab(1);
If not(Staff) then
Begin
Case Style of
1: Info := [571, 254, 632, 290];
2: Info := [655, 254, 717, 290];
3: Info := [571, 306, 632, 343];
4: Info := [655, 306, 717, 343];
else
srl_Warn('SetAttackStyle', IntToStr(Style) + 'is not a valid attack style', warn_AllVersions);
end;
end else
Begin
Case Style of
1: Info := [571, 255, 633, 280];
2: Info := [571, 290, 633, 315];
3: Info := [571, 326, 633, 349];
else
srl_Warn('SetAttackStyle', IntToStr(Style) + 'is not a valid attack style', warn_AllVersions);
end;
end;
If FindColorTolerance(x, y, 2106256, Info[0], Info[1], Info[2], Info[3], 50) then
Begin
Result := True;
Exit;
end;
MouseBox(Info[0], Info[1], Info[2], Info[3], 1);
Result := True;
end;