Naike
2009-05-26 20:29:48
Yet again another skill.scar to be updated, this time it's Prayer.scar ;D
Added
Added
- QPrayersOpen
- QPrayConfirm
- OpenQPrayersMenu
- QPrayerSelected
- AllQPrayersOff
- TurnQPrayersOn
- And modified GetPrayerCoords to work inside quick prayer setup.
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- Prayer routines --//
//-----------------------------------------------------------------//
// * function GetPrayerCoords(Name: string; var Box: TBox; var Color: Integer; QPrayerSetup: Boolean): Boolean; | by Nielsie95 modified by N1ke!
// * function PrayerExists(Name: string): Boolean; | by Nielsie95
// * function PrayerActivated(Name: string): Boolean; | by Nielsie95
// * function ClickPrayer(Name: string; Activate: Boolean): Boolean; | by Nielsie95
// * procedure AllPrayersOff; | by phantombmx - Fixed by Freddy1990
// * Function QPrayersOpen: Boolean; | by N1ke!
// * Function QPrayConfirm: Boolean; | by N1ke!
// * Function OpenQPrayersMenu: Boolean; | by N1ke!
// * Function QPrayerSelected(i: String): Boolean; | by N1ke!
// * Procedure AllQPrayersOff; | by N1ke!
// * Procedure TurnQPrayersOn(Names: TStringArray; UnCheckOthers: Boolean); | by N1ke!
{*******************************************************************************
function GetPrayerCoords(Name: string; var Box: TBox; var Color: Integer; QPrayerSetup: Boolean): Boolean;
By: Nielsie95 Modified by N1ke!
Description: Returns a box and color from a certain prayerbutton.
Returns true if the name exists.
QPrayerSetup means if you want the cords for Quick prayers setup.
Name is the number or name of the prayer.
Numbers:
1 2 3 4 5
6 7 8 9 10
etc.
*******************************************************************************}
function GetPrayerCoords(Name: string; var Box: TBox; var Color: Integer; QPrayerSetup: Boolean): Boolean;
var
RowCol: TIntegerArray;
begin
Result := True;
case Capitalize(LowerCase(Name)) of
'Thick Skin', '1': RowCol := [0, 0, 7443688];
'Burst Of Strength', '2': RowCol := [0, 1, 9743322];
'Clarity Of Thought', '3': RowCol := [0, 2, 8690894];
'Sharp Eye', '4': RowCol := [0, 3, 212659];
'Mystic Will', '5': RowCol := [0, 4, 2621201];
'Rock Skin', '6': RowCol := [1, 0, 251];
'Superhuman Strength', '7': RowCol := [1, 1, 251];
'Improved Reflexes', '8': RowCol := [1, 2, 251];
'Rapid Restore', '9': RowCol := [1, 3, 85724];
'Rapid Heal', '10': RowCol := [1, 4, 15533737];
'Protect Items', '11': RowCol := [2, 0, 15533737];
'Hawk Eye', '12': RowCol := [2, 1, 251];
'Mystic Lore', '13': RowCol := [2, 2, 251];
'Steel Skin', '14': RowCol := [2, 3, 15533737];
'Ultimate Strength', '15': RowCol := [2, 4, 15533737];
'Incredible Reflexes', '16': RowCol := [3, 0, 15533737];
'Protect From Summoning', '17':RowCol := [3, 1, 14732165];
'Protect From Magic', '18': RowCol := [3, 2, 15533737];
'Protect From Missiles', '19': RowCol := [3, 3, 15533737];
'Protect From Melee', '20': RowCol := [3, 4, 15533737];
'Eagle Eye', '21': RowCol := [4, 0, 15533737];
'Mystic Might', '22': RowCol := [4, 1, 15533737];
'Retribution', '23': RowCol := [4, 2, 251];
'Redemption', '24': RowCol := [4, 3, 15039768];
'Smite', '25': RowCol := [4, 4, 15039768];
'Chivalry', '26': RowCol := [5, 0, 15533737];
'Piety', '27': RowCol := [5, 1, 14915455];
else
begin
srl_Warn('GetPrayerCoords', 'Invalid Prayer Name', warn_Warning);
Result := False;
Exit;
end;
end;
If QPrayerSetup then
begin
Box.x1 := 555 + (RowCol[1] * 37);
Box.x2 := Box.x1 + 10;
Box.y1 := 235 + (RowCol[0] * 35);
Box.y2 := Box.y1 + 10;
Exit;
end;
Box.x1 := 565 + (RowCol[1] * 37);
Box.x2 := Box.x1 + 14;
Box.y1 := 222 + (RowCol[0] * 37);
Box.y2 := Box.y1 + 10;
Color := RowCol[2];
end;
{*******************************************************************************
function PrayerExists(Name: string): Boolean;
By: Nielsie95
Description: Returns true if the players' level is high enough to use the prayer.
*******************************************************************************}
function PrayerExists(Name: string): Boolean;
var
p: TBox;
c, x, y: Integer;
begin
if (not GetPrayerCoords(Name, p, c, False)) or (not LoggedIn) then Exit;
GameTab(6);
Result := FindColorTolerance(x, y, c, p.x1 -7, p.y1 -5, p.x2 +7, p.y2 +5, 5);
end;
{*******************************************************************************
function PrayerActivated(Name: string): Boolean;
By: Nielsie95
Description: Returns true if the prayer is activated.
*******************************************************************************}
function PrayerActivated(Name: string): Boolean;
var
p: TBox;
c, x, y: Integer;
begin
if (not GetPrayerCoords(Name, p, c, False)) or (not PrayerExists(Name)) or (not LoggedIn) then
Exit;
Result := FindColorTolerance(x, y, 7451338, p.x1 -10, p.y1 -5, p.x2 +7, p.y2 +5, 10);
end;
{*******************************************************************************
function ClickPrayer(Name: string; Activate: Boolean): Boolean;
By: Nielsie95
Description: Turns a certain prayer on or off. Returns true if done succesfully.
Name is the number or name of the prayer.
Numbers:
1 2 3 4 5
6 7 8 9 10
etc.
*******************************************************************************}
function ClickPrayer(Name: string; Activate: Boolean): Boolean;
var
p: TBox;
t, c: Integer;
begin
if (not GetPrayerCoords(Name, p, c, False)) or (not PrayerExists(Name)) or (not LoggedIn) then
Exit;
if (Activate) then
begin
if (not PrayerActivated(Name)) then
Mouse(RandomRange(p.x1, p.x2), RandomRange(p.y1, p.y2), 3, 3, True);
end else
if (PrayerActivated(Name)) then
Mouse(RandomRange(p.x1, p.x2), RandomRange(p.y1, p.y2), 3, 3, True);
Result := True;
MarkTime(t);
c := 0;
repeat
if (Activate) then
begin
if (PrayerActivated(Name)) then
Exit;
end else
if (not PrayerActivated(Name)) then
Exit;
Wait(50);
c := c +1;
if ((c mod 10) = 0) then
if (Activate) then
begin
if (not PrayerActivated(Name)) then
Mouse(RandomRange(p.x1, p.x2), RandomRange(p.y1, p.y2), 3, 3, True);
end else
if (PrayerActivated(Name)) then
Mouse(RandomRange(p.x1, p.x2), RandomRange(p.y1, p.y2), 3, 3, True);
until (TimeFromMark(t) > 3000);
Result := False;
end;
{*****************************************************************************
procedure AllPrayersOff;
By: phantombmx - Fixed by Freddy1990
Description: Will turn off any prayers that may be on
*****************************************************************************}
procedure AllPrayersOff;
var
i: Integer;
begin
for i := 1 to 27 do
ClickPrayer(IntToStr(i), False);
end;
{*******************************************************************************
Function QPrayersOpen: Boolean;
By: N1ke!
Description: Checks if the Quick prayer setup is enabled.
*******************************************************************************}
Function QPrayersOpen: Boolean;
begin
GameTab(6);
Result := (GetColor(680, 219) = 2070783);
end;
{*******************************************************************************
Function QPrayersOpen: Boolean;
By: N1ke!
Description: Confirms the quick prayer setup.
*******************************************************************************}
Procedure QPrayConfirm;
begin
If QPrayersOpen then
MouseBox(617, 454, 672, 459, 1);
end;
{*******************************************************************************
Function OpenQPrayersMenu: Boolean;
By: N1ke!
Description: Opens the quick prayer setup.
*******************************************************************************}
Function OpenQPrayersMenu: Boolean;
begin
If QPrayersOpen then Exit;
MouseBox(713, 62, 758, 77, 2);
Wait(150+Random(100));
Result := ChooseOption('elect');
end;
{*******************************************************************************
Function QPrayerSelected(i: String): Boolean;
By: N1ke!
Description: Results true if the selected prayer is enabled
in quick prayer setup.
*******************************************************************************}
Function QPrayerSelected(i: String): Boolean;
var
QBox: TBox;
WX, WY: Integer;
begin
If not QPrayersOpen then
OpenQPrayersMenu;
GetPrayerCoords(i, QBox, WX, True);
Result := FindColorTolerance(WX, WY, 192, QBox.x1, QBox.y1, QBox.x2, QBox.y2, 3);
end;
{*******************************************************************************
Procedure AllQPrayersOff;
By: N1ke!
Description: Turns off all quick prayers. (Disables them).
*******************************************************************************}
Procedure AllQPrayersOff;
var
I, CW: Integer;
QBox: TBox;
begin
If Not QPrayersOpen then
OpenQPrayersMenu;
For I:=1 to 22 do
If QPrayerSelected(IntToStr(I)) then
begin
GetPrayerCoords(IntToStr(I), QBox, CW, True);
MouseBox(QBox.x1, QBox.y1, QBox.x2, QBox.y2, 1);
end;
end;
{*******************************************************************************
Procedure TurnQPrayersOn(Names: TStringArray; UnCheckOthers: Boolean);
By: N1ke!
Description: Turns on the selected prayers.
UnCheckOthers = True will disable the current ones.
*******************************************************************************}
Procedure TurnQPrayersOn(Names: TStringArray; UnCheckOthers: Boolean);
var
I, CW: Integer;
QBox: TBox;
begin
If Not QPrayersOpen then OpenQPrayersMenu;
If UnCheckOthers then AllQPrayersOff;
For i:=0 to High(Names)do
begin
Wait(300+Random(600));
Writeln(Names[i]);
GetPrayerCoords(Names[i], QBox, CW, True);
MouseBox(QBox.x1, QBox.y1, QBox.x2, QBox.y2, 1);
end;
QPrayConfirm;
end;