SRL Archive - SRL Archives

Little Fighting.scar observation


Cazax

2008-03-14 17:43:24

Just a little observation:

in fighting,scar, there is a function called 'FightNPC':
{*******************************************************************************
function FightNPC(Color1, Color2, Color3, Color4, Color5, Color6, tol, TimeOut: Integer): Boolean;
By: WT-Fakawi
Description: Fights NPC. Inputs 6 NPC Colors. (May be the same colors),
tol = tolerance, TimeOut = amount of time before clicking on next NPC
*******************************************************************************}

It could be more easier to change, 'Color1, Color2, Color3, Color4, Color,5, Color6 : Integer;' to 'Colors : TIntegerArray' something like:

function FightNPC(Color1, Color2, Color3, Color4, Color5, Color6, tol, TimeOut:
Integer): Boolean;
var
Mark, x, y, I, Color: Integer;
begin
for I := 1 to 6 do
begin
case I of
1: Color := Color1;
2: Color := Color2;
3: Color := Color3;
4: Color := Color4;
5: Color := Color5;
6: Color := Color6;
end;
if (LoggedIn) then
begin
if (FindObj(x, y, 'ttack', Color, tol)) then
begin
Result := True;
GetMousePos(x, y);
if (not (LoggedIn) or (FindDead)) then Break;
Mouse(x, y, 0, 0, True);
if (not (LoggedIn) or (FindDead)) then Break;
Wait(2000);
FFlag(10);
MarkTime(Mark);
repeat
if (not (LoggedIn) or (FindDead)) then Break;
Wait(1000 + Random(500));
FindNormalRandoms;
if (TimeFromMark(Mark) > TimeOut) then Break;
until ((not (FindColorSpiral(x, y, 65280, 240, 140, 290, 175))
or (FindDead)));
end
else
Result := False;
end
end
end;

To:

function FightNPC(Colors : TIntegerArray, tol, TimeOut:
Integer): Boolean;
var
Mark, x, y, I, Color: Integer;
begin
if (LoggedIn) then
begin
for i:=0 to High(Colors) do
begin
if (FindObjCustom(x, y, ['ttack'], Colors, tol)) then
end;
begin
Result := True;
GetMousePos(x, y);
if (not (LoggedIn) or (FindDead)) then Break;
Mouse(x, y, 0, 0, True);
if (not (LoggedIn) or (FindDead)) then Break;
Wait(2000);
FFlag(10);
MarkTime(Mark);
repeat
if (not (LoggedIn) or (FindDead)) then Break;
Wait(1000 + Random(500));
FindNormalRandoms;
if (TimeFromMark(Mark) > TimeOut) then Break;
until ((not (FindColorSpiral(x, y, 65280, 240, 140, 290, 175))
or (FindDead)));
end
else
Result := False;
end
end
end;

Just a little thing.

Negaal

2008-03-14 17:47:38

Agreed, it is quite annoyning if you have to fill 3 or 6 etc color if you want only to put 1.

Cazax

2008-03-14 18:36:42

From: Negaal
Agreed, it is quite annoyning if you have to fill 3 or 6 etc color if you want only to put 1.


Thats the reason why i posted it.

Santa_Clause

2008-03-14 19:31:58

if (FindObjCustom(x, y, ['ttack'], [Colors[i]], tol)) then

Into:

if (FindObjCustom(x, y, ['ttack'], Colors, tol)) then

drizzt

2008-03-14 19:35:39

From: Santa_Clause
if (FindObjCustom(x, y, ['ttack'], [Colors[i]], tol)) then

Into:

if (FindObjCustom(x, y, ['ttack'], Colors, tol)) then


nevermind, found out findobjcustom had tintegerarray in it

Edit: also, forgot to post something useful. yea, i noticed that in other places other than that particular function. would be very nice to have one

Cazax

2008-03-14 19:35:59

From: Santa_Clause
if (FindObjCustom(x, y, ['ttack'], [Colors[i]], tol)) then

Into:

if (FindObjCustom(x, y, ['ttack'], Colors, tol)) then


added thx.

drizzt

2008-03-14 20:39:49

for i:=0 to High(Colors) do
begin
if (FindObjCustom(x, y, ['ttack'], Colors, tol)) then
end;
to
for i:=0 to High(Colors) do
begin
if (TimeFromMark(Mark) > TimeOut) then
begin
Result := false;
Exit;
end;
if (FindObjCustom(x, y, ['ttack'], Colors, tol)) then
end;
?

Santa_Clause

2008-03-14 23:05:05

There should be no for/to/do loop…

Wizzup?

2008-03-15 06:55:33

Changed to:
function FightNPC(Colors : TIntegerArray, tol, TimeOut:
Integer): Boolean;
var
Mark, x, y, I, Color: Integer;
begin
if (LoggedIn) then
begin
for i:=0 to High(Colors) do
begin
if (FindObjCustom(x, y, ['ttack'], Colors, tol)) then
end;
begin
Result := True;
GetMousePos(x, y);
if (not (LoggedIn) or (FindDead)) then Break;
Mouse(x, y, 0, 0, True);
if (not (LoggedIn) or (FindDead)) then Break;
Wait(2000);
FFlag(10);
MarkTime(Mark);
repeat
if (not (LoggedIn) or (FindDead)) then Break;
Wait(1000 + Random(500));
FindNormalRandoms;
if (TimeFromMark(Mark) > TimeOut) then Break;
until ((not (FindColorSpiral(x, y, 65280, 240, 140, 290, 175))
or (FindDead)));
end
else
Result := False;
end
end
end;

Cazax

2008-03-15 11:26:20

From: Santa_Clause
There should be no for/to/do loop…


Ya thats right.

From: Wizzup?
Changed to:
function FightNPC(Colors : TIntegerArray, tol, TimeOut:
Integer): Boolean;
var
Mark, x, y, I, Color: Integer;
begin
if (LoggedIn) then
begin
for i:=0 to High(Colors) do
begin
if (FindObjCustom(x, y, ['ttack'], Colors, tol)) then
end;
begin
Result := True;
GetMousePos(x, y);
if (not (LoggedIn) or (FindDead)) then Break;
Mouse(x, y, 0, 0, True);
if (not (LoggedIn) or (FindDead)) then Break;
Wait(2000);
FFlag(10);
MarkTime(Mark);
repeat
if (not (LoggedIn) or (FindDead)) then Break;
Wait(1000 + Random(500));
FindNormalRandoms;
if (TimeFromMark(Mark) > TimeOut) then Break;
until ((not (FindColorSpiral(x, y, 65280, 240, 140, 290, 175))
or (FindDead)));
end
else
Result := False;
end
end
end;


btw, are you/devs going to change that function in rev #15?

Wizzup?

2008-03-15 11:40:50

From: Cazax
Ya thats right.



btw, are you/devs going to change that function in rev #15?


Do you mean add/change the one you posted, or rewrite it?
I said 'Changed to', which means it is now in de Developers SRL, and whatever is updated in the Developers SRL get's updated in the public SRL. ;)

Cazax

2008-03-15 11:42:56

From: Wizzup?
Do you mean add/change the one you posted, or rewrite it?
I said 'Changed to', which means it is now in de Developers SRL, and whatever is updated in the Developers SRL get's updated in the public SRL. ;)

Im clear now.

Timer

2008-03-15 13:02:34

From: Wizzup?
Changed to:
function FightNPC(Colors : TIntegerArray, tol, TimeOut:
Integer): Boolean;
var
Mark, x, y, I, Color: Integer;
begin
if (LoggedIn) then
begin
for i:=0 to High(Colors) do
begin
if (FindObjCustom(x, y, ['ttack'], Colors, tol)) then
end;
begin
Result := True;
GetMousePos(x, y);
if (not (LoggedIn) or (FindDead)) then Break;
Mouse(x, y, 0, 0, True);
if (not (LoggedIn) or (FindDead)) then Break;
Wait(2000);
FFlag(10);
MarkTime(Mark);
repeat
if (not (LoggedIn) or (FindDead)) then Break;
Wait(1000 + Random(500));
FindNormalRandoms;
if (TimeFromMark(Mark) > TimeOut) then Break;
until ((not (FindColorSpiral(x, y, 65280, 240, 140, 290, 175))
or (FindDead)));
end
else
Result := False;
end
end
end;


Faster, Neater, And Achually Complile Please?

function FightNPC(Colors: TIntegerArray, Tol, TimeOut: Integer): Boolean;
var
Mark, x, y, I, Color, UpTo: Integer;
begin
if (LoggedIn) then
begin
UpTo := High(Colors);
for (i := 0) to (UpTo) do
if (FindObjCustom(x, y, ['ttack'], Colors[i], Tol)) then
begin
Result := True;
GetMousePos(x, y);
if (not LoggedIn) or (FindDead) then
Break;
Mouse(x, y, 0, 0, True);
if (not LoggedIn) or (FindDead) then
Break;
Wait(2000 + Random(100));
FFlag(10);
MarkTime(Mark);
repeat
if (not LoggedIn) or (FindDead) then
Break;
Wait(1000 + Random(500));
FindNormalRandoms;
if (TimeFromMark(Mark) > TimeOut) then
Break;
until((not FindColorSpiral(x, y, 65280, 240, 140, 290, 175)) or (FindDead)));
end
else
Result := False;
end
end
end;

:p