Nava2
2009-05-28 03:26:10
This is in the Dev SVN! :)
Thanks to N1ke and xCanadaManx :)
Please stop posting about this.
I am locking all threads related. :)
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Mouse Flag & Chat Routines --//
//-----------------------------------------------------------------//
// * function IsMoving(WaitTime: Integer): Boolean; // * by Bullzeye95 & Nava2
// * 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
// * function FFlag(Dist: Integer): Boolean; // * by Wizzup? / WT-Fakawi / ZephyrsFury
// * function Flag: Boolean; // * by Nava2
// * 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 IsMoving(WaitTime: Integer): Boolean;
By: Bullzeye95; Edits by Nava2
Description: Checks if the currently loaded player is moving. Uses Minimap,
ignoring all dots which can move without the player moving.
Nava2 edit: Added try..finally, also changed to work with SMART,
as well added WaitTime Parameter.
*******************************************************************************}
function IsMoving(WaitTime: Integer): Boolean;
var
BMP, BMP2, I, H, x, y: Integer;
ReplaceCols: TIntegerArray;
P: TPointArray;
DC: HDC;
begin
WaitTime := Max(50, WaitTime);
try
DC := GetTargetDC;
ReplaceCols:= [65536, 16711422, 12961221, 14869218, 16777215, 15527148, 195836, 56797, 60909, 52428,
13816530, 982782, 1310462, 62965, 2105598, 395004, 789758, 3553023, 217, 188, 241,
206, 233, 64768, 58880, 51456, 49152, 44800, 61440, 16215571, 9716750, 13129742];
BMP:= BitmapFromString(100, 100, '');
BMP2:= BitmapFromString(100, 100, '');
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP), MMCX - 50, MMCY - 50, MMCX + 50, MMCY + 50, 0, 0, 100, 100);
H := High(ReplaceCols);
for I:= 0 to H do
FastReplaceColor(BMP, ReplaceCols[i], 0);
wait(WaitTime);
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP2), MMCX - 50, MMCY - 50, MMCX + 50, MMCY + 50, 0, 0, 100, 100);
SetTargetDC(GetBitmapDC(BMP2));
for I:= 0 to H do
begin
FindColorsTolerance(P, ReplaceCols[i], 0, 0, 99, 99, 0);
y:= High(P);
for x:= 0 to y do
FastSetPixel(BMP2, P[x].x, P[x].y, FastGetPixel(BMP, P[x].x, P[x].y));
end;
Result:= not FindBitmapIn(BMP, x, y, 0, 0, 99, 99);
finally
SetTargetDC(DC);
FreeBitmap(BMP);
FreeBitmap(BMP2);
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, 3026478, 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, 3026478, 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, 3026478, MMx1, MMy1, MMx2, MMy2) then
begin
Result := True
Exit;
end;
Wait(Random(100));
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, 3026478, MMx1, MMy1, MMx2, MMy2) then
begin
Result := True;
Exit;
end;
Wait(Random(100));
until TimeFromMark(TT) > 3000;
end;
end;
{*******************************************************************************
function FFlag(Dist: Integer): Boolean;
By: Wizzup? / WT-Fakawi / ZephyrsFury
Description: Waits until Flag is within "Distance" distance.
*******************************************************************************}
function FFlag(Dist: Integer): Boolean;
var
Tx, Ty, M, D1, D2: Integer;
begin
Result := False;
M := GetSystemTime;
while (FindColor(Tx, Ty, 3026478, MMX1, MMY1, MMX2, MMY2)) do
begin
D1 := Distance(Tx, Ty + 14, MMCX, MMCY);
if (D1 <= Dist) then
begin
Result := True;
Exit;
end;
Wait(100);
if (GetColor(6, 6) <> clWhite) then
if (GetSystemTime - M > 5000) then
begin
if (D1 = D2) then Exit;
D2 := D1;
M := GetSystemTime;
end;
if (Random(20) = 0) then IdleTime(500, 1000, 0.01);
if SRL_Procs[SRL_AntiBan] <> nil then
SRL_Procs[SRL_AntiBan]();
end;
Wait(RandomRange(200, 400));
end;
{*******************************************************************************
function Flag: Boolean;
By: Nava2
Description: Waits while flag exists.
*******************************************************************************}
function Flag: Boolean;
begin
Result := FFlag(0);
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?, WT-Fakawi, and Starblaster100
Description: Sets Chat to desired state
*******************************************************************************}
procedure SetChat(state: string; chat: Integer);
var
x, y, mx, Color: Integer;
begin
case chat of
1: mx := 90;
2: mx := 145;
3: mx := 200;
4: mx := 260;
5: mx := 320;
6: mx := 373;
else
begin
srl_Warn('SetChat', 'chat(' + IntToStr(chat) + ') does not exist.', warn_AllVersions);
Exit;
end;
end;
State := LowerCase(State);
case State of
'on', 'all': Color := 65280;
'off': Color := 255;
'hide': Color := 16776960;
'friends', 'filter': Color := 65535;
else srl_Warn('SetChat', state + ' does not exist.', warn_AllVersions);
end;
State := Capitalize(State);
if not FindColor(x, y, Color, mx - 10, 486, mx + 10, 506) then
begin
Mouse(mx, 496, 8, 8, False);
Wait(450 + Random(175));
ChooseOption(State);
end;
end;
{*******************************************************************************
procedure SetAllChats(Game, 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:
*******************************************************************************}
procedure SetAllChats(Game, Pub, Priv, Clan, Trade, Assist: string);
var
States: TStringArray;
II: Integer;
begin
if (not(LoggedIn)) then Exit;
States := ['', Game, Pub, Priv, Clan, Trade, Assist];
for II := 1 to 6 do
begin
if (States[II] = '') then Continue;
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 6 do
SetChat('off', i);
end;Thanks to N1ke and xCanadaManx :)
Please stop posting about this.
I am locking all threads related. :)