Tniffoc
2009-03-23 10:00:49
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Mouse Flag & Chat Routines --//
//-----------------------------------------------------------------//
// * function Flag: Boolean; // * by PPLSUQBAWLZ/Odie533
// * function FlagPresent: Boolean; // * by Mutant Squirrle
// * function FlagDistance: Integer; // * by PPLSUQBAWLZ/Odie533
// * Function MFF(ax, ay, xmod, ymod: Integer):Boolean; // * by WT-Fakawi
// * Function MFNF(ax, ay, xmod, ymod: Integer):Boolean; // * by WT-Fakawi
// * procedure FFlag(Distance: Integer); // * by Wizzup? / WT-Fakawi.
// * procedure MouseFlag(cx, cy, rx, ry, FlagDist: Integer); // * by RsN edit by EvilChicken!
// * procedure SetChat(state: String; chat: Integer); // * by Wizzup? modded by WT-Fakawi and Starblaster100
// * procedure SetAllChats(Pub, Priv, Clan, Trade, Assist: string); // * by ZephyrsFury
// * procedure ChatsOff; // * by Starblaster100
{*******************************************************************************
function Flag: Boolean;
By: PPLSUQBAWLZ/Odie533
Description: Waits while flag exists.
*******************************************************************************}
function Flag: Boolean;
var
timeout, x, y: Integer;
begin
if (FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2)) then
begin
Result := True;
repeat
Wait(100);
if (SRL_Procs[srl_AntiBan] <> nil) then
SRL_Procs[srl_AntiBan]();
timeout := timeout + 1;
until (not FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2)) or (timeout > 300);
end;
end;
{*******************************************************************************
function FlagPresent: Boolean;
By: Mutant Squirrle
Description: T/F depending on flag exist.
*******************************************************************************}
function FlagPresent: Boolean;
var
x, y: integer;
begin
Result := FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2);
end;
{*******************************************************************************
function FlagDistance: Integer;
By: PPLSUQBAWLZ/Odie533
Description: Returns distance in pixels your char dot is from flag on mini-map
*******************************************************************************}
function FlagDistance: Integer;
var
x, y: Integer;
begin
If findcolor(x, y, 255, MMX1, MMy1, MMX2, MMY2) Then
Result := Distance(MMCX, MMCY, x + 1, y + 14);
end;
{*******************************************************************************
Function MFF(ax, ay, xmod, ymod: Integer):Boolean;
By: WT-Fakawi
Description: If the flag is not present it will click at (ax, ay) increasing by
(xmod, ymod) 5 times or until the flag appears.
*******************************************************************************}
Function MFF(ax, ay, xmod, ymod: Integer):Boolean;
var
TT, i, xx, yy, x, y, BreakOutTime: Integer;
begin
if (not LoggedIn) then Exit;
if (not (FlagPresent)) then
begin
xx := ax - xmod;
yy := ay - ymod;
MarkTime(BreakOutTime);
for i := 0 to 4 do
begin
xx := xx + xmod;
yy := yy + ymod;
if rs_OnMiniMap(xx, yy) then
Mouse(xx, yy, 2, 2, True)
else
Continue;
Wait(50);
MarkTime(TT);
repeat
Wait(10);
if FindColor(x, y, 255, MMx1, MMy1, MMx2, MMy2) then
begin
Result := True
Exit;
end;
until TimeFromMark(TT) > 3000;
end;
Result := False;
end;
end;
{*******************************************************************************
Function MFNF(ax, ay, xmod, ymod: Integer):Boolean;
By: WT-Fakawi
Description: Like MFF except it will click even if the flag is present when the
function is called.
*******************************************************************************}
Function MFNF(ax, ay, xmod, ymod: Integer):Boolean;
var
TT, i, xx, yy, x, y: Integer;
begin
Result := False;
if (not LoggedIn) then Exit;
xx := ax - xmod;
yy := ay - ymod;
for i := 0 to 4 do
begin
xx := xx + xmod;
yy := yy + ymod;
if rs_OnMiniMap(xx, yy) then
Mouse(xx, yy, 2, 2, True)
else
Continue;
Wait(50);
MarkTime(TT);
repeat
Wait(100);
if FindColor(x, y, 255, MMx1, MMy1, MMx2, MMy2) then
begin
Result := True;
Exit;
end;
until TimeFromMark(TT) > 3000;
end;
end;
{*******************************************************************************
procedure FFlag(Distance: Integer);
By: Wizzup? / WT-Fakawi.
Description: Waits until Flag is within "Distance" distance.
*******************************************************************************}
function FFlag(Dist: Integer): boolean;
var
XK, YK, XL, YL, x, y: Integer;
var
T1, T2: Extended;
timeout: Integer;
begin
Result := False;
T1 := GetTickCount;
MarkTime(timeout);
repeat
if (not LoggedIn) then Exit;
T2 := GetTickCount;
Wait(100);
if FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2) Then
if (Dist > Distance(MMCX, MMCY, x + 1, y + 14)) then
begin
Result := True;
Break;
end;
Wait(100);
if T2 - T1 > 30000 then
begin
Result := False;
if FindColor(XL, YL, 255, MMX1, MMY1, MMX2, MMY2) then
MFNF(XL, YL, 1, 1)
else
begin
Mouse(MMCX, MMCY, 0, 0, True);
end;
Exit;
end;
if Random(20) = 1 Then IdleTime(500, 1000, 0.01);
if (SRL_Procs[srl_AntiBan] <> nil) then
SRL_Procs[srl_AntiBan]();
if(TimeFromMark(timeout) > 20000) then
begin
Exit;
end;
until (not FindColor(XK, YK, 255, MMX1, MMY1, MMX2, MMY2));
end;
{*******************************************************************************
procedure MouseFlag(cx, cy, rx, ry, FlagDist: Integer);
By: RsN edit by EvilChicken!
Description: Mouse and Flag combined into one easy procedure.
*******************************************************************************}
procedure MouseFlag(cx, cy, rx, ry, FlagDist: Integer);
var
i: Integer;
begin
if (not LoggedIn) then Exit;
Mouse(cx, cy, rx, ry, True);
while (not FlagPresent) and (i < 10) do
begin
Wait(100);
Inc(i);
end;
FFlag(FlagDist);
Wait(300 + Random(200));
end;
{*******************************************************************************
procedure SetChat(state: String; chat: Integer);
By: Wizzup? modded by WT-Fakawi and Starblaster100
Description: Sets Chat to desired state
*******************************************************************************}
procedure SetChat(state: string; chat: Integer);
var
x, y, mx, my, Color: Integer;
begin
case chat of
1: mx := 145;
2: mx := 200;
3: mx := 260;
4: mx := 320;
5: mx := 373;
else
begin
srl_Warn('SetChat', 'chat(' + IntToStr(chat) + ') does not exist.', warn_AllVersions);
Exit;
end;
end;
my := 496;
case LowerCase(State) of
'on': begin Color := 65280; State :='On'; end;
'off': begin Color := 255; State :='Off'; end;
'hide': begin Color := 16776960; State :='Hide'; end;
'friends': begin Color := 65535; State :='Friends'; end;
else srl_Warn('SetChat', state + ' does not exist.', warn_AllVersions);
end;
if not FindColor(x, y, Color, mx - 10, my - 10, mx + 10, my + 10) then
begin
Mouse(mx, my, 8, 8, False);
Wait(450 + Random(175));
ChooseOption(State);
end;
end;
{*******************************************************************************
procedure SetAllChats(Pub, Priv, Clan, Trade, Assist: string);
By: ZephyrsFury
Description: Sets all the chats to a particular state in one simple procedure.
Leave the parameter as '' if you wish to leave the chat as it is:
Example: SetAllChats('on', 'friends', '', 'off', '');
*******************************************************************************}
procedure SetAllChats(Pub, Priv, Clan, Trade, Assist: string);
var
States: TStringArray;
II: Integer;
begin
if (not(LoggedIn)) then Exit;
States := ['', Pub, Priv, Clan, Trade, Assist];
for II := 1 to 5 do
begin
if (States[II] = '') then Continue;
States[II] := Lowercase(States[II]);
if ((II <> 1) and (States[II] = 'hide')) or ((States[II] <> 'on') and
(States[II] <> 'friends') and (States[II] <> 'off') and (States[II] <> 'hide')) then
begin
srl_Warn('SetAllChats', 'ChatState ''' + States[II] + ''' does not exist for chat ''' + IntToStr(II) + ''' ', warn_AllVersions);
Continue;
end;
SetChat(States[II], II);
end
end;
{*******************************************************************************
procedure ChatsOff;
By: Starblaster100
Description: Sets all Chats to off.
*******************************************************************************}
Procedure ChatsOff;
var
i: Integer;
Begin
For i := 1 to 5 do
SetChat('off', i);
end;