SRL Archive - SRL Archives

FlagChat.scar Fix


Nava2

2009-05-28 03:26:10

This is in the Dev SVN! :)



//-----------------------------------------------------------------//
//-- 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. :)

Blumblebee

2009-05-28 03:31:39

it doesnt compile

unknown identifyer Tx (and Ty) in script. Make it a global or a local?

Nava2

2009-05-28 03:32:15

You got it right before I fixed it! :)

Blumblebee

2009-05-28 03:33:03

From: Nava2
I fixed in the Dev SVN. My apologies.

Fix'd.


you wanna upload it here, im too lazy to download the dev svn… :) nvm you did sorry

edit: Ummm, the flag fix isnt working for me, it worked once then fucked up and kept clicking in random areas? Maybe its my script though i dunno.

Nava2

2009-05-28 03:35:25

From: Blumblebee
you wanna upload it here, im too lazy to download the dev svn… :) nvm you did sorry


Don't be.

Rasta

2009-05-28 03:37:57

Doesn't work

Nava2

2009-05-28 03:48:43

I'll fix i later.

Blumblebee

2009-05-28 05:36:08

Fix it noaw!

Nava2

2009-05-28 05:55:51

What exactly isn't working?

Btw, way to spam Zeph.

Blumblebee

2009-05-28 05:58:01

well it might just be me, but it doesnt wait for the flag or something. Like it clicks the spot then totally fucks up. Mind you I probably have like FFlag(35) or something retarded like that because the old FFlag() was just waiting until the flag went away.

Have you tested FFlag on a script yet?

edit: go on IRC i dont wanna get my post count n e higher lol

Rasta

2009-05-28 06:44:12

It walks to first flag but then clicks where ever the cursor is and completely messes up from there

Blumblebee

2009-05-28 06:46:08

From: Rasta
It walks to first flag but then clicks where ever the cursor is and completely messes up from there


same, i downloaded the dev svn and it works fine.

Rasta

2009-05-28 07:01:28

how do i download dev svn?(i know noob question)

Dark Arcana

2009-05-28 09:03:28

From: Rasta
how do i download dev svn?(i know noob question)


Here you go http://www.villavu.com/repositories/srl-opendev/

Edit: ?? My first Cup! ??

Naike

2009-05-28 09:29:04

What was wrong with mine?

Edit: You have to mention what functions you fix ;P Or you mess up my head xD

Naice work.

Naum

2009-05-28 12:57:06

FindFight in AntiRandoms/Common wasn't working either :)

function FindFight: Boolean;
var
CurTab: Byte;

begin
Result := False;
if not LoggedIn then exit;
if CountColor(198716, 208, 116, 296, 162) >= 50 then
begin
if CheckHpFirst then
begin
CurTab := GetCurrentTab;
Result := (HpPercent < 100);
GameTab(CurTab);
if not Result then exit;
end;

Result := True;
AddToSRLLog('******** FOUND FIGHTING RANDOM ********');
WriteLn('******** FOUND FIGHTING RANDOM ********');
TakeScreen('Found Fight');
Inc(RandSolved[rand_Fight]);
end;
end;

jakeyboy29

2009-05-28 13:40:02

From: NaumanAkhlaQ
FindFight in AntiRandoms/Common wasn't working either :)

function FindFight: Boolean;
var
CurTab: Byte;

begin
Result := False;
if not LoggedIn then exit;
if CountColor(198716, 208, 116, 296, 162) >= 50 then
begin
if CheckHpFirst then
begin
CurTab := GetCurrentTab;
Result := (HpPercent < 100);
GameTab(CurTab);
if not Result then exit;
end;

Result := True;
AddToSRLLog('******** FOUND FIGHTING RANDOM ********');
WriteLn('******** FOUND FIGHTING RANDOM ********');
TakeScreen('Found Fight');
Inc(RandSolved[rand_Fight]);
end;
end;


are there still fighting randoms?

Dark Arcana

2009-05-28 13:41:43

From: jakeyboy29
are there still fighting randoms?


I don't think so, never seen one seens the random event update.

Naum

2009-05-28 14:38:20

Well it's in SRL -_-

belgin fish

2009-05-28 16:30:18

Even if theres no fighting randoms you can still get attacked :D especially level 3's fishing/wc in draynor.

PS: It works 100%

Naum

2009-05-28 16:36:49

From: jakeyboy29
are there still fighting randoms?


From: belgin fish
Even if theres no fighting randoms you can still get attacked :D especially level 3's fishing/wc in draynor.

PS: It works 100%



Told, brother! :p

Nava2

2009-05-28 23:08:08

Which works?

Naum

2009-05-28 23:10:18

AFAIK it does, although the outline may change in which case you need another color.

Nava2

2009-05-29 02:26:31

Does the flag work?

Punkgi

2009-05-29 07:25:08

Thanks for the fix. This works fine.

PriSoner

2009-05-29 14:23:34

Works perfetly for me using the complete OpenDev SRL..

I've tested in numerous fresh sessions and in multiple enviroments. All successfull so far. :)

Thanx, your work is always much appreciated..

hessels92

2009-06-01 11:30:50

i am a n00b can anyway tell me what i am meant to do with this script? i am confused?


thank you.

Dark Arcana

2009-06-01 11:32:22

From: hessels92
i am a n00b can anyway tell me what i am meant to do with this script? i am confused?


thank you.


Just update to the latest revision.

ZephyrsFury

2009-06-01 11:44:51

This bug has been fixed in SRL Public Revision #33. Update your SRL and you will automatically have the updated functions.

Closed.