SRL Archive - Research & Development Lounge

What axe


NiCbaZ

2008-11-20 02:01:30

Just a simple axe detector..


function N_WhatAxe: String;
var
cts,I,Z : Integer;
TPA: TPointArray;
T : Integer;
H : TBox;
Col: TIntegerArray;

begin
T := GetCurrentTab;
If T <> 4 then
GameTab(4);
H := InvBox(1);
Col := [791905,6313793,4478276,5914173];
For I:= 0 to High(col) do
begin
if FindColorsTolerance(TPA,Col[I], h.X1, h.Y1, h.X2, h.Y2 , 15) then
if Length(TPA) > 20 then
begin
Z:= I + 1;
Break;
end;
end;
case z of
1: Result:= 'dragon';
2: Result:= 'rune';
3: Result:= 'addy';
4: Result:= 'mith';
end;
end;

TViYH

2008-11-22 19:21:19

Very nice.

Make it return a boolean if it finds an axe, and you could use this to replace FindAxe;

senrath

2008-11-23 01:53:05

From: TViYH
Very nice.

Make it return a boolean if it finds an axe, and you could use this to replace FindAxe;


It already returns a string. I don't think you can return more than one type of value. I might be wrong, though.

Also, what happens if no axe is detected?

NiCbaZ

2008-11-23 02:05:24

If no Axe is detected It wont return anthing.

Frt

2009-02-05 18:50:15

This should store the type in WhatType and return True if axe found.
Haven't tested though.

function N_WhatAxe(WhatType: String): Boolean;
var
cts,I,Z : Integer;
TPA: TPointArray;
T : Integer;
H : TBox;
Col: TIntegerArray;

begin
T := GetCurrentTab;
If T <> 4 then
GameTab(4);
H := InvBox(1);
Col := [791905,6313793,4478276,5914173];
For I:= 0 to High(col) do
begin
if FindColorsTolerance(TPA,Col[i], h.X1, h.Y1, h.X2, h.Y2 , 15) then
if Length(TPA) > 20 then
begin
Result := True;
Z:= I + 1;
Break;
end else Result := False;
end;
case z of
1: WhatType:= 'dragon';
2: WhatType:= 'rune';
3: WhatType:= 'addy';
4: WhatType:= 'mith';
end;
end;

mormonman

2009-02-05 19:37:41

if you want it to store something you need to do this…
function N_WhatAxe(var WhatType: String): Boolean;

Da 0wner

2009-02-05 19:48:33

You need to add Var to the beginning if you want user to input a var into the parameters and it will store it in that global, otherwise if you don't put var it will store it in a local var in the procedure only.

Frt

2009-02-05 19:50:51

From: mormonman
if you want it to store something you need to do this…
function N_WhatAxe(var WhatType: String): Boolean;


Oh yea, forgot that. I guess I'm to sleepy atm to think clear :P

mormonman

2009-02-05 19:55:22

From: Da 0wner
You need to add Var to the beginning if you want user to input a var into the parameters and it will store it in that global, otherwise if you don't put var it will store it in a local var in the procedure only.


sorry but… duh… im pretty sure we all knew that…

Da 0wner

2009-02-05 20:10:00

Morman, yea I didn't see your post sorry :p.

mormonman

2009-02-05 20:13:16

Its all good man!

NiCbaZ

2009-02-06 15:06:17

Hmm if i wanted to store it into a varable i would do that, it proablly would be batter, ive been using it like.

Axe := WhatAxe;

Da 0wner

2009-02-07 01:30:51

If you stored it in variable its shorter :p

WhatAxe(axe);

NiCbaZ

2009-02-07 01:34:09

Yes, that is true.

Da 0wner

2009-02-07 02:00:49

[offtopic] NiCbaZ go on msn??

NiCbaZ

2009-02-07 07:19:27

Tommorro its like 11:16 pm here not that late but im getting like burnt here lots of bush fires… btw i made this function a while back thats why its so noobie..

il try and update in this post here..

Theese may not work as im writting them in the post as no scar on this computer

SearchForAxeInAllInv


function N_WhatAxe(var Axe: String):Boolean;
var
I,IIAxeNum : Integer;
ColorsTPA: TPointArray;
ColorsArray: TIntegerArray;
HaveAxe: Boolean;

begin
If GetCurrentTab <> 4 then
GameTab(4);
ColorsArray := [791905,6313793,4478276,5914173];
for I:= 1 to 28 do
begin
H := InvBox(I);
for II:= 0 to High(col) do
begin
if FindColorsTolerance(ColorsTPA,Col[II], h.X1, h.Y1, h.X2, h.Y2 , 15) then
if Length(ColorsTPA) <> 0 then
begin
AxeNum:= II + 1;
HaveAxe:= True;
Break;
end;
end;
if HaveAxe then
Break;
end;
Axe:= ' ';
case z of
1: Axe:= 'dragon';
2: Axe:= 'rune';
3: Axe:= 'addy';
4: Axe:= 'mith';
end;
Result := Axe <> ' ';
end;

UserDefinedInvSearch

You Also Need an InArray Function for this to work please keep in mind that i am writing all thing in this post and i do not have scar


function N_InArr(III: Integer;II: TIntergerArr): Boolean;
var
I: Integer;
begin
for I:= 0 to High(II) do
if III = II[I] then
Result:= true;
if Result then
Break;
end;

function N_WhatAxe(var Axe: String;InvBoxs: TIntergerArray):Boolean;
var
I,IIAxeNum : Integer;
ColorsTPA: TPointArray;
ColorsArray: TIntegerArray;
HaveAxe: Boolean;

begin
If GetCurrentTab <> 4 then
GameTab(4);
ColorsArray := [791905,6313793,4478276,5914173];
for I:= 1 to 28 do
begin
if not N_InArray(I,InvBoxes) then
Continue;
H := InvBox(I);
for II:= 0 to High(col) do
begin
if FindColorsTolerance(ColorsTPA,Col[II], h.X1, h.Y1, h.X2, h.Y2 , 15) then
if Length(ColorsTPA) <> 0 then
begin
AxeNum:= II + 1;
HaveAxe:= True;
Break;
end;
end;
if HaveAxe then
Break;
end;
Axe:= ' ';
case z of
1: Axe:= 'dragon';
2: Axe:= 'rune';
3: Axe:= 'addy';
4: Axe:= 'mith';
end;
Result := Axe <> ' ';
end;

I wrote theese function ( off my old one) in the HTML editor of this forum, they mostliky wont compile but should all work in thoery.

mormonman

2009-02-07 08:25:08

is there such thing as a tboxarray… because you could add that to your functions… for the inv boxes(instead of TIntegerArray, but i know that you just did it in scar tags…)

Da 0wner

2009-02-07 16:16:52

Yes, there is such thing as a TBoxArray.