PDA

View Full Version : Some functions...



Negaal
02-15-2008, 10:26 PM
Some functions by me, have fun...

Finds gas near x & y
function GasIn(X, Y : integer) : Boolean;
var
CTS, i, a : integer;
PCount : TIntegerArray;
begin
SetLength(PCount, 2);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.08, 0.25);
if FindColorTolerance(a, a, 7835543, X - 25, Y - 25, X + 25, Y + 25, 15) then
begin
for i:=0 to 1 do
begin
PCount[i]:= CountColorTolerance(7835543, X - 25, Y - 25, X + 25, Y + 25, 15);
if i = 0 then wait(250);
end;
if PCount[0] <> PCount[1] then
begin
Result := True;
Writeln('Gas found, Pixelcount change: '+FloatToStr((Abs(PCount[0] - PCount[1]) * PCount[0]) / 100)+'%');
end;
end;
SetColorspeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
end;


Makes <Array of Array of Integer> to <Array of integer>
Function TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
var
New : TIntegerArray;
L, K, i, j, g, d, add, ddl : integer;
begin
g := length(dd);
d := high(dd)
for g := 0 to d do
ddl := ddl + Length(dd[g]);
SetLength(New, ddl)
L := High(dd);
For i := 0 to L do
begin
K := High(dd[i])
For j := 0 to K do
begin
New[add] := dd[i][j];
Inc(Add);
end;
end;
Result := New;
end;

Finds a dummy! :p
function FindDummy(var a, b : integer) : Boolean;
var
TPA : TPointArray;
ATPA : TPointArrayArray;
I, CTS, L : integer;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.2, 0.8);
FindColorsTolerance(TPA, 8429238, MSX1, MSY1, MSX2, MSY2, 12);
SetColorspeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
ATPA := SplitTPAEx(TPA, 10, 10);
SortATPAFrom(ATPA, IntToPoint(MSCX, MSCY));
L := High(ATPA)
For i := 0 to L do
if Length(ATPA[i]) >= 100 then
begin
MiddleTPAEx(ATPA[i], a, b);
MMouse(a - 5, b - 8, 3, 17);
Wait(50 + random(50));
if (pos('mmo', rs_GetUpText) > 0) then
begin
Getmousepos(a, b);
Result := True;
status('Dummy found!');
Exit;
end;
end;
end;

Find all items execpt colors given, and does what uptext says
procedure DoItemsExceptColors(colorz : TIntegerArray; todo : string);
var
IC : TPoint;
I, J, x, y : integer;
begin
if (GetCurrentTab <> 4) then
begin
Gametab(4);
Wait(1000 + random(1000));
end;
for i := 1 to 28 do
begin
if ExistsItem(i) then
begin
Wait(1000);
if not ExistsItem(i) then Continue;
IC := ItemCoords(i)
For j := 0 to High(Colorz) do
begin
if FindColorSpiralTolerance(x, y, colorz[j],ic.x - 20, ic.y - 20, ic.x + 20, ic.y + 20, 5) then Continue;
if j = High(Colorz) then
begin
MMouseItem(i);
Getmousepos(x, y);
if pos(todo, Rs_GetUpText) > 0 then
Mouse(x, y, 0, 0, true)
else
begin
Mouse(x, y, 0, 0, false)
ChooseOption(ToDo);
end;
end;
end;
end;
end;
end;

Finds an object, Mincount is integer, that how much pixels should that object have
function FindObjTPA(var x, y, Color, MinPoints : integer; Text : String) : Boolean;
var
TPA : TPointArray;
ATPA : TPointArrayArray;
I, L : integer;
begin
FindColorsTolerance(TPA, Color, MSX1, MSY1, MSX2, MSY2, 12);
ATPA := SplitTPAEx(TPA, 10, 10);
SortATPAFrom(ATPA, IntToPoint(MSCX, MSCY));
L := High(ATPA)
For i := 0 to L do
if Length(ATPA[i]) >= MinPoints then
begin
MiddleTPAEx(ATPA[i], a, b);
MMouse(x - 5, y - 5, 11, 11);
Wait(50 + random(50));
if (pos(text, rs_GetUpText) > 0) then
begin
Getmousepos(x, y);
Result := True;
status('Object found!');
Exit;
end;
end;
end;

rostaryms
02-15-2008, 11:26 PM
oh nice, i'll be sure to use these, thanks !

MylesMadness
02-16-2008, 01:20 AM
Function TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
var
New : TIntegerArray;
L, K, i, j, g, d, add, ddl : integer;
begin
g := length(dd);
d := high(dd)
for g := 0 to d do
ddl := ddl + Length(dd[g]);
SetLength(New, ddl)
L := High(dd);
For i := 0 to L do
begin
K := High(dd[i])
For j := 0 to K do
begin
New[add] := dd[i][j];
Inc(Add);
end;
end;
Result := New;
end; This Could be shorterFunction TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
var
I:integer;
begin
For I:=0 to GetArrayLength(dd)-1 do
Result:=CombineIntArray(Result, dd[I])
end;

Timer
02-16-2008, 01:23 AM
Nice, Maybe I Could Make Some Of These

Negaal
02-16-2008, 10:51 AM
@Myles, yours doesnt work...

Edit: if <Array of array> has total like 10 components then yours makes <array of> to have 10000 components

ShowerThoughts
02-16-2008, 11:03 AM
meh, he couldn't even fix my script he sucks...

xD :p ;)

n3ss3s
02-16-2008, 11:15 AM
Hermpie, couldn't you just stop the spamming?



Edit: if <Array of array> has total like 10 components then yours makes <array of> to have 10000 components

Overruled, run the script below.


Program New;

Function TIAAToTIA(TIAA: Array of TIntegerArray): TIntegerArray;
Var
I: Integer;
Begin
For I := 0 To High(TIAA) Do
Result := CombineIntArray(Result, TIAA[i]);
End;

Var
Arr: Array of TIntegerArray;
Ar: TIntegerArray;
I: Integer;

Begin
SetArrayLength(Arr, 3);
Arr[0] := [1, 2, 3];
Arr[1] := [4, 5, 6];
Arr[2] := [7, 8, 9];
Ar := TIAAToTIA(Arr);
For I := 0 To High(Ar) Do
Writeln(IntToStr(Ar[i]));
End.

Negaal
02-16-2008, 11:24 AM
meh, he couldn't even fix my script he sucks...

xD :p ;)

First, learn some standards, second, I fixed the banking, third, you will not say do I suck or not...next time don't request help if you assist someone to fix your procedure(not remake like I did, when you said "omg you wasted a hour in my life!") so you don't have to give credits.

He had

Procedure Bank;
Begin
If Not (LoggedIn) Then Exit;
LoadDTMs;
If DTMRotated(OpenFWBank, X, Y, MSX1, MSY1, MSX2, MSY2) Then
Begin
Mouse(X,Y,3,3,False);
Wait(50 + Random (25));
If ChooseOption('quickly') Then if WaitUntil(2000,PinScreen) then if Inpin(IntToStr(Players[CurrentPlayer].Integers[1])) then if WaitUntil(2000,BankScreen) then
begin
If Players[CurrentPlayer].Booleans[2] Then
Begin
If FindDTM(BigBone, X, Y, MSX1, MSY1, MSX2, MSY2) then
Begin
WaitUntil(5000,ChooseOption('ll'));
CloseBank;
GameTab(4);
End Else
If FindDTM(Bone, X, Y, MSX1, MSY1, MSX2, MSY2) Then
WaitUntil(5000,ChooseOption('ll'));
CloseBank;
GameTab(4);
End Else
If FindDTM(Bone, X, Y, MSX1, MSY1, MSX2, MSY2) then
WaitUntil(5000,ChooseOption('ll'));
CloseBank;
GameTab(4);
End Else
Begin
CloseBank;
logout;
End;
End Else
OpenBankQuiet('FWB');
End;


I made it to:

Procedure Bank;
var
t : longint;
Begin
If Not (LoggedIn) or bankscreen Then Exit;
If DTMRotated(OpenFWBank, X, Y, MSX1, MSY1, MSX2, MSY2) Then
Begin
Mouse(X,Y,3,3,False);
Wait(50 + Random (25));
If ChooseOption('quickly') Then
begin
marktime(t);
repeat
wait(100);
if pinscreen then
Inpin(IntToStr(Players[CurrentPlayer].Integers[1]));
if timefrommark(t) > 30000 then exit;
until bankscreen;
end;
end else
if not Findbank('fwb') then
begin
logout;
exit;
end;
Wait(1500 + random(500));
fixbank;
writeln('Bank opened');

writeln(booltostr(Players[CurrentPlayer].Booleans[2]));
If Players[CurrentPlayer].Booleans[2] Then
Begin
If FindDTM(BigBone, X, Y, MSX1, MSY1, MSX2, MSY2) then
Mouse(x,y,5,5,false)
Else
If FindDTM(Bone, X, Y, MSX1, MSY1, MSX2, MSY2) Then
Mouse(x,y,5,5,false);
end Else
If FindDTM(Bone, X, Y, MSX1, MSY1, MSX2, MSY2) then
Mouse(x,y,5,5,false);

WaitUntil(5000,ChooseOption('ll'));
CloseBank;
GameTab(4);
end;

And he pointed out that I ruined hes procedure, though i fixed it...he wanted that waituntil will stay, since I removed, and sayd him to repeat standards learning, he started to swear on me in msn, etc, so block, and have fun

Edit:
have to say it back,
Fuck you too hermpie!

Edit:
Too bad I don't got conv records, deleted him on msn and blocked.

Edit:
http://www.srl-forums.com/forum/omgzzz-script-errorzzzz-p345680.html#post345680
Thread about WaitUntil what I kinda removed and he wanted so much that it will stay! oh noes!

edit:
Back on topic
Run this and see...no idea

program New;

Function TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
var
New : TIntegerArray;
L, K, i, j, g, d, add, ddl : integer;
begin
g := length(dd);
d := high(dd)
for g := 0 to d do
ddl := ddl + Length(dd[g]);
SetLength(New, ddl)
L := High(dd);
For i := 0 to L do
begin
K := High(dd[i])
For j := 0 to K do
begin
New[add] := dd[i][j];
Inc(Add);
end;
end;
Result := New;
end;

Function TIAAtoTIAMyles(dd :Array of TIntegerArray) : TIntegerArray;
var
I:integer;
begin
For I:=0 to GetArrayLength(dd)-1 do
Result:=CombineIntArray(Result, dd[i]);
end;

var
tiaa : array of tintegerarray;
tia : tintegerarray;
t, i, L : longint;

begin
setarraylength(tiaa, 10);
for i := 0 to 9 do
setarraylength(tiaa[i], 1);
TIAA[0][0] := 1111;
TIAA[1][0] := 2222;
TIAA[2][0] := 3333;
TIAA[3][0] := 4444;
TIAA[4][0] := 5555;
TIAA[5][0] := 6666;
TIAA[6][0] := 7777;
TIAA[7][0] := 8888;
TIAA[8][0] := 9999;
TIAA[9][0] := 0;

t := getsystemtime;
for i := 0 to 999 do
tia := TIAAtoTIAMyles(tiaa);
writeln('Myles took '+inttostr(getsystemtime -t));

writeln(inttostr(length(tia)));
L := high(tia);
for i := 0 to L do
writeln(inttostr(tia[i]));
writeln('');

t := getsystemtime;
for i := 0 to 999 do
tia := TIAAtoTIA(tiaa);
writeln('Mine took '+inttostr(getsystemtime -t));

L := high(tia);
for i := 0 to L do
writeln(inttostr(tia[i]));
writeln('');

end.

No idea.

n3ss3s
02-16-2008, 11:43 AM
program New;

Function TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
var
New : TIntegerArray;
L, K, i, j, g, d, add, ddl : integer;
begin
g := length(dd);
d := high(dd)
for g := 0 to d do
ddl := ddl + Length(dd[g]);
SetLength(New, ddl)
L := High(dd);
For i := 0 to L do
begin
K := High(dd[i])
For j := 0 to K do
begin
New[add] := dd[i][j];
Inc(Add);
end;
end;
Result := New;
end;

Function TIAAtoTIAMyles(dd :Array of TIntegerArray) : TIntegerArray;
var
I:integer;
begin
For I:=0 to High(dd) do
Result:=CombineIntArray(Result, dd[i]);
end;

var
tiaa : array of tintegerarray;
tia : tintegerarray;
t, i, L : longint;

begin
setarraylength(tiaa, 10);
for i := 0 to 9 do
setarraylength(tiaa[i], 1);
TIAA[0][0] := 1111;
TIAA[1][0] := 2222;
TIAA[2][0] := 3333;
TIAA[3][0] := 4444;
TIAA[4][0] := 5555;
TIAA[5][0] := 6666;
TIAA[6][0] := 7777;
TIAA[7][0] := 8888;
TIAA[8][0] := 9999;
TIAA[9][0] := 0;

t := getsystemtime;
for i := 0 to 999 do
Begin
SetArrayLength(Tia, 0);
tia := TIAAtoTIAMyles(tiaa);
End;
writeln('Myles took '+inttostr(getsystemtime -t));

writeln(inttostr(length(tia)));
L := high(tia);
for i := 0 to L do
writeln(inttostr(tia[i]));
writeln('');

t := getsystemtime;
for i := 0 to 999 do
Begin
SetArrayLength(Tia, 0);
tia := TIAAtoTIA(tiaa);
End;
writeln('Mine took '+inttostr(getsystemtime -t));

L := high(tia);
for i := 0 to L do
writeln(inttostr(tia[i]));
writeln('');

end.



-.- you yourself made them 1000 indexes big...

run that, works.

Negaal
02-16-2008, 11:48 AM
Ow...my bad...so I have always to set length to 0?

Embarrising? :confused:

dow!

Edit: sorry Myles

Edit: Myles made is still faster :(

n3ss3s
02-16-2008, 12:13 PM
The TIAAToTIA that uses CombineIntArray, combines the TIAA to the result, so you did that 1000 times :p

Negaal
02-16-2008, 12:29 PM
The TIAAToTIA that uses CombineIntArray, combines the TIAA to the result, so you did that 1000 times :p

Now i got it

In combinearray it just add and adds...but mine repeat adding values to same spot -.-