PDA

View Full Version : Find ENT and fixing axe head flying off functions



JAD
07-01-2007, 11:15 PM
Well, if you want to use these, feel free to use/modify them in any way you want, as long as proper credits are given!

Heres my axe head finding/fixing procedure. It also gets the axe head colors.. (needed for picking it up).


procedure LoadDTMs;
begin
Status('Loading all DTMs');

AxeDTM := DTMFromString('78DA633CCEC4C0D0CBC800021012C2E247E 23' +
'39E02AA994840CD11A09A7904D45C07AAE926A0E602504D2B 0135' +
'97F1ABF90F04002C1A0CA1');

BrokenAxeDTM := DTMFromString('78DA637CC7C4C0308F910104202484C58FC 46' +
'7FC0854D34340CD0FA09A2E026AFE03D5F41250C3C0CCC0D0 4E40' +
'CD6FA039AD04D47C05AA69C1ADE63F100000CD040E2F');

AxeHandleDTM := DTMFromString('78DA63D46162601066640001080961F123F 11' +
'915816AF408A8D100AA5124A0469508357A40352204D42800 D568' +
'E256F31F08000D2D0629');

AxeHeadDTM := DTMFromString('78DA637CC2C0C050C5C800021012C2E241E 23' +
'3BE02127504D480CCA927A0E62590A824A0E60190A825A0E6 3590' +
'A8C6ADE63F10000036F00CB1');

end;

procedure DeclareJADVars;
begin

JadX1[1] := 167; //Box 5
JadY1[1] := 113;
JadX2[1] := 334;
JadY2[1] := 226;

JADX1[2] := 0; //Box 4
JADY1[2] := 113;
JADX2[2] := 167;
JADY2[2] := 226;

JADX1[3] := 0; //Box 7
JADY1[3] := 226;
JADX2[3] := 167;
JADY2[3] := 339;

JADX1[4] := 167; //Box 8
JADY1[4] := 226;
JADX2[4] := 334;
JADY2[4] := 339;

JADX1[5] := 334; //Box 9
JADY1[5] := 226;
JADX2[5] := 501;
JADY2[5] := 339;

JADX1[6] := 334; //Box 6
JADY1[6] := 113;
JADX2[6] := 501;
JADY2[6] := 226;

JADX1[7] := 167; //Box 2
JADY1[7] := 0;
JADX2[7] := 334;
JADY2[7] := 113;

JADX1[8] := 334; //Box 3
JADY1[8] := 0;
JADX2[8] := 501;
JADY2[8] := 113;

JADX1[9] := 0; //Box 1
JADY1[9] := 0;
JADX2[9] := 167;
JADY2[9] := 113;

end;

{************************************************* *************************

------> All functions related to the axe/axe head here <------

************************************************** ************************}


{************************************************* *******
function GetOnAxeHead(Ax,Ay: Integer): Boolean;
By: JAD
Description: Gets the mouse on the axe head. Used in the
PickUpAxeHead function below.
************************************************** ******}

function GetOnAxeHead(Ax,Ay: Integer): Boolean;
var
I, Q:Integer;
Found: Boolean;

begin
for I:= 1 to 9 do
begin
for Q := Q to 10 do
begin
if(FindColorSpiralTolerance(Ax,Ay,AxeHeadColor[1],JadX1[i],JadY1[i],JadX2[i],JadY2[i],Q))or
(FindColorSpiralTolerance(Ax,Ay,AxeHeadColor[2],JadX1[i],JadY1[i],JadX2[i],JadY2[i],Q))or
(FindColorSpiralTolerance(Ax,Ax,AxeHeadColor[3],JadX1[i],JadY1[i],JadX2[i],JadY2[i],Q))then
begin
Found := True;
Break;
end;
end;
if(Found)then
begin
MMouse(Ax,Ay,0,0);
wait(200+random(200));
if(IsUpText('ead'))then
begin
Result := True;
GetMousePos(Ax,Ay);
Exit;
end;
end;
wait(300+random(300));
end;
end;

///////////////////////////////////////////////////
////// Gets the axe head coords. Used for //////
////// auto coloring the axe below //////
////////////////////////////////////////////////

function GetAxeHeadCoords: TPoint;
var Jx,Jy: Integer;
begin
Status('Getting axe head coordinates');
if(Players[CurrentPlayer].Boolean2)then
GameTab(5) else
GameTab(4);
wait(200+random(200));
if(FindDTM(AxeDTM,Jx,Jy,MIX1,MIY1,MIX2,MIY2))then
begin
Result.x := Jx + 10;
Result.y := Jy - 5;
Status('Found axe head coordinates');
Exit;
end else
begin
Writeln('Did NOT find axe. Please make sure player ');
Writeln(IntToStr(CurrentPlayer) + '''s Boolean2 is set correctly!');
Writeln('Or make sure you have an axe with you, not in bank.');
LogOut;
end;
end;

///////////////////////////////////////////////////
////// Gets the axe head colors and saves //////
////// them to the AxeHeadColor array //////
////////////////////////////////////////////////

function GetAxeHeadColors: Boolean;
var AxeHeadCoords: TPoint;
begin
if(not(LoggedIn))then
Exit;
if(Players[CurrentPlayer].Boolean2) = true then
GameTab(5) else
GameTab(4);
AxeHeadCoords := GetAxeHeadCoords;
Result := True;
AxeHeadColor[1] := GetColor(AxeHeadCoords.x,AxeHeadCoords.y);
AxeHeadColor[2] := GetColor(AxeHeadCoords.x-2,AxeHeadCoords.y-1);
AxeHeadColor[3] := GetColor(AxeHeadCoords.x+3,AxeHeadCoords.y+2);
Writeln('Axe head colors are ' + IntToStr(AxeHeadColor[1]) + ', ' +
IntToStr(AxeHeadColor[2]) + ' and ' + IntToStr(AxeHeadColor[3]) + '.');
end;

///////////////////////////////////////////////////
////// results true if we don't have an //////
////// axe (or one in good condition) //////
////////////////////////////////////////////////

function AxeExists: Boolean;
begin
if(Players[CurrentPlayer].Boolean2) = true then
GameTab(5) else
GameTab(4);
if(FindDTM(AxeDTM,x,y,MIX1,MIY1,MIX2,MIY2))then
begin
Result := True;
Status('We still have an axe');
Exit;
end else
begin
Result := False;
Writeln('We may have broken an axe/lost the axe head. Trying to solve now..');
end;
end;

///////////////////////////////////////////////////
////// Picks up the axe head. Used in the //////
////// function below //////
////////////////////////////////////////////////

function PickUpHead: Boolean;
var Jx,Jy, I: Integer;
begin
for I := 1 to 5 do
begin
if(GetOnAxeHead(Jx,Jy))then
begin
Result := True;
GetMousePos(Jx,Jy);
Mouse(Jx,Jy,0,0,true);
wait(1000+random(500));
Exit;
end;
wait(2000+random(1000));
end;
end;

///////////////////////////////////////////////////
////// Does everything to handle the axe //////
////// head flying off random //////
////////////////////////////////////////////////

function GetAxeBackTogether: Boolean;
begin
if(not(LoggedIn))then
Exit;
if(FindDTM(AxeHandleDTM,x,y,MIX1,MIY1,MIX2,MIY2))t hen
begin
if(Players[CurrentPlayer].Boolean2) = true then
begin
Mouse(x,y,1,1,true);
wait(500+random(500));
GameTab(4);
end;
if(PickUpHead)then
begin
if(FindDTM(AxeHandleDTM,x,y,MIX1,MIY1,MIX2,MIY2))t hen
begin
Mouse(x,y,1,1,false);
ChooseOption(x,y,'se');
wait(1000+random(500));
if(FindDTM(AxeHeadDTM,x,y,MIX1,MIY1,MIX2,MIY2))the n
begin
Mouse(x,y,1,1,true);
wait(1000+random(1000));
if(FindDTM(AxeDTM,x,y,MIX1,MIY1,MIX2,MIY2))then
begin
Result := True;
Writeln('put together the axe');
AxesAttached := AxesAttached + 1;
end else
begin
Result := False;
Writeln('Didnt successfully put together the axe :( Switching players..');
LogOut;
Exit;
end;
end;
end;
end;
end;
Result := False;
end;

function CheckAndSolveAxe: Boolean;
begin
if(not(AxeExists))then
begin
if(FindDTM(BrokenAxeDTM,x,y,MIX1,MIY1,MIX2,MIY2))t hen
begin
Writeln('we broke an axe. Going to check if we have extra ones in the bank');
BrokenAxe := True;
Result := True;
Exit;
end;
if(FindDTM(AxeHandleDTM,x,y,MIX1,MIY1,MIX2,MIY2))t hen
begin
if(not(GetAxeBackTogether))then
begin
Result := True;
Writeln('We lost the axe head :( Going to check if we have extra axes in the bank');
BrokenAxe := True;
Exit;
end;
end;
end;
end;



Put these in your global variables:


var
AxeHeadColor: array[1..3] of Integer;
JadX1: array[1..9] of Integer;
JadY1: array[1..9] of Integer;
JadX2: array[1..9] of Integer;
JadY2: array[1..9] of Integer;
BrokenAxeDTM, AxeHandleDTM, AxeHeadDTM, AxesAttached: Integer;
BrokenAxe: Boolean;


NOTE: Put Players.Boolean2 in your DeclarePlayers procedure. It just asks if the axe is weilded or not. So just add that to all your player arrays :)


You can take everything out with the BrokenAxe variable if you want... I use that so when chopping, it exits out of the chopping procedure if BrokenAxe ='s true, goes to the bank and withdraws and axe. You can take that out or try to use it if you want ;)

Then, all you need to do is call for CheckAndSolveAxe and you should be good :)







Here's my ent finding/handling function:


///////////////////////////////////////////////////
////// My Ent checker/handler //////
/////////////////////////////////////////////////

function CheckForEnt: Boolean;
var TPA: TPointArray;
begin
if(not(LoggedIn))then
Exit;
if(FindColorTolerance(x,y,55255,6,6,117,27,10))or
(FindColorTolerance(x,y,976101,6,6,117,27,10))then
begin
if(not(IsUpText('op'))) and (not(IsUpText('own')))then
Exit;
wait(1);
FindColorsSpiralTolerance(x,y,TPA,55255,6,6,117,27 ,10);
if(GetArrayLength(TPA) - 1 > 4)then
begin
Result := True;
Writeln('We found an ent!! Trying to avoid now..');
Mouse(648,84,3,3,true);
JadFlag(0,15);
FTWait(60+random(5));
if(Players[CurrentPlayer].Boolean2)then
GameTab(5) else
GameTab(4);
Result := FindDTM(x,y,AxeDTM,MIX1,MIY1,MIX2,MIY2);
if(Result)then
begin
Writeln('Whew! We avoided the ent.. Carrying on with chopping');
Ents := Ents + 1;
Exit;
end else
begin
if(FindDTM(x,y,BrokenAxeDTM,MIX1,MIY1,MIX2,MIY2))t hen
begin
Writeln('Oh darn.. We broke an axe :( going to check if you have extras in the bank');
BrokenAxe := True;
Exit;
end;
end;
end;
Result := False;
end;
end;


Same thing for this.. Your going to need the variables declared above and the DTM's for this to compile/work ;)


I just posted these because I had already made them in my script.. And SRL's FindEnt function doesn't work, and I don't think there axe head finding works (at least too well) so I thought I'd post it for my fellow scripters who need either/both of these :)

Enjoy!

~JAD

Esteban
07-01-2007, 11:51 PM
Thanks much JAD for these wonderful procedures an Functions. It's very grateful of you to allow these to be used by others. Maybe I'll use these someday when i have the scripting knowledge to use them.

Ilikepie1995
07-02-2007, 12:25 AM
Nice Jad very nice!Iam going to use those in my woodcutting scripts!!!

Harry
07-02-2007, 01:12 AM
Nice :D 3rd post! Maybe we can dump YoHoJo's finction now :)

TravisV10
07-02-2007, 01:19 AM
Nice :D 3rd post! Maybe we can dump YoHoJo's finction now :)

Wow. Harsh on YoHoJo dude. lol.

I liked the functions. Used them in my new script.:spot:


Check out my sig if you want to see my script

Mjordan
07-02-2007, 01:24 AM
Very nice JAD, I'm making a powerchopper and was gonna have to make my own ent and axe stuff(cause SRL's doesn't work all to well). But I'll just use these now :D

JAD
07-02-2007, 03:05 AM
Very nice JAD, I'm making a powerchopper and was gonna have to make my own ent and axe stuff(cause SRL's doesn't work all to well). But I'll just use these now :D

Awesome! You can also use that DropAllDTMsFast instead of the DropToFast you said you were going to use before in that script to :p

Thanks everybody for the comments! I really do hope to see these used in a few scripts... ;)

nielsie95
07-02-2007, 08:26 AM
Nice :)

But why don't you use 1 TBoxArray instead of 4 TIntegerArrays? :p

Santa_Clause
07-02-2007, 11:16 AM
English? Ehh, I hope these work...;)

Tim0suprem0
07-02-2007, 04:08 PM
These look really good! I'll definitely use if I make a powerchopper :D

Sumilion
07-02-2007, 04:13 PM
Nice :)

Buy why don't you use 1 TBoxArray Instead of 4 TIntegerArrays? :p

Owned :)

What was wrong with my FindAxeHeadColors ?

Stevee
07-02-2007, 06:28 PM
Find ENT and fixing axe head flying off functions

i see no findent procedures =)

JAD
07-02-2007, 10:11 PM
i see no findent procedures =)

It's called CheckForEnt, it's the only function ;)

And I didn't know you made FindAxeColors Sum, sorry :p


@Nielsie, sorry, I don't get 100% of what you mean :p

YoHoJo
07-02-2007, 11:39 PM
ROFL AT JAD>
Sorry but every time you use arrays/make an array tut, you end up getting owned =).
Here: http://www.villavu.com/forum/showthread.php?t=7590?t=8699&highlight=tboxarray
Learn!

JAD
07-02-2007, 11:47 PM
ROFL AT JAD>
Sorry but every time you use arrays/make an array tut, you end up getting owned =).
Here: http://www.villavu.com/forum/showthread.php?t=7590?t=8699&highlight=tboxarray
Learn!

............

My weakest point in scripting is arrays.. And I really don't appreciate everybody being a complete jerk to me about it. And every time I make an array tut? That was once... Every time I make a script with arrays? I don't recall getting owned when I do make scripts with arrays...

All I'm saying is you don't have to be rude to me about it. There are a LOT of less experienced scripters having problems with much simpler things then I do that aren't getting "Owned"..

So I'll read that tutorial and see if I learn anything. I don't believe I did anything wrong in these functions/procedures though..


And BTW YoHoJo, you were the one that told me with TPoint you can use .anything... Not just .x and .y. I didn't say anything bad about that either...

Sorry if I'm coming off a little mad/rude, but I've been being picked on on this much to much, and I'm just asking people to stop..

YoHoJo
07-02-2007, 11:55 PM
wow calm down, dont you know me?
I diss everyone but im not serious about it -.-
Calm down! IDC if you dont know arrays =)
We can all still be friends.
I just like messin w/ people

Take it like a man. Flaming is a fun part of forums! =) (if done nicely) rofl

JAD
07-03-2007, 12:03 AM
wow calm down, dont you know me?
I diss everyone but im not serious about it -.-
Calm down! IDC if you dont know arrays =)
We can all still be friends.
I just like messin w/ people

Take it like a man. Flaming is a fun part of forums! =) (if done nicely) rofl

If you were the first person to make fun of me for it.. It wouldn't have been such a bit deal.

Anyways, I'm sorry.. I was just a little mad because I've gotten "Owned" 50 times in the last hour..

Anyways, it wouldn't have shortened the script in any way if I used TBoxArray. I just would have had to do:

Jad[1].x1 := thiscoord;
Jad[1].y1 := thiscoord;

....etc.

Jad[2].x1 := thiscoord;

...etc.

And then I would have used them just about the same way.

So I don't think it would have shortened my code, but you are right, I could have done it that way, and I may next time ;)

nielsie95
07-03-2007, 06:33 AM
Jad[0] := IntToBox(x1, y1, x2, y2);

Could shrink some things :)
And I'm just giving you tips, don't take this as an 'owned'.. ;)

Santa_Clause
07-03-2007, 11:03 AM
Nielsie! I swear if you say anything more complicated than Wait(3000); the next time you post my head is gonna burst open.


............

My weakest point in scripting is arrays.. And I really don't appreciate everybody being a complete jerk to me about it. And every time I make an array tut? That was once... Every time I make a script with arrays? I don't recall getting owned when I do make scripts with arrays...

All I'm saying is you don't have to be rude to me about it. There are a LOT of less experienced scripters having problems with much simpler things then I do that aren't getting "Owned"..

So I'll read that tutorial and see if I learn anything. I don't believe I did anything wrong in these functions/procedures though..


And BTW YoHoJo, you were the one that told me with TPoint you can use .anything... Not just .x and .y. I didn't say anything bad about that either...

Sorry if I'm coming off a little mad/rude, but I've been being picked on on this much to much, and I'm just asking people to stop..

I'm one of those less experienced scripters that have trouble with much simpler things ;)

TravisV10
07-07-2007, 04:46 PM
I have used this function and now all that I get is:


We may have broken an axe/lost the axe head. Trying to solve now..
We may have broken an axe/lost the axe head. Trying to solve now..

Any ideas? I have the axe.

JAD
07-07-2007, 07:03 PM
I have used this function and now all that I get is:



Any ideas? I have the axe.

Hmm.. That happens when you actually lost the head/broke an axe? That is the function that writeln's that if it finds the axe handle or the broken axe head.

But it didn't take any further action after that?

TravisV10
07-08-2007, 01:07 PM
Hmm.. That happens when you actually lost the head/broke an axe? That is the function that writeln's that if it finds the axe handle or the broken axe head.

But it didn't take any further action after that?

I have the CheckandSolve function and my axe is fine. Nothing happened to my axe and everytime the function runs, it says the error.

JAD
07-08-2007, 02:22 PM
I have the CheckandSolve function and my axe is fine. Nothing happened to my axe and everytime the function runs, it says the error.

Oh yeah.. I forgot, my DTMs were pretty bad so I made new DTM's for everything, didn't post them though :p

I will do that in a little bit. The new DTMs fixed my problem with that though.

TravisV10
07-08-2007, 03:02 PM
k. i need them. I am working on a Varrock Yew chopper and I would like thoes finctions.

JAD
07-08-2007, 03:15 PM
k. i need them. I am working on a Varrock Yew chopper and I would like thoes finctions.

Lol.. I'm working on adding varrock yew cutting to my Varrock Lumberjack :p

And I'll put it out soon =)

TravisV10
07-08-2007, 03:42 PM
Lol.. I'm working on adding varrock yew cutting to my Varrock Lumberjack :p

And I'll put it out soon =)

Nice, nice. Funny name. :D

Alright, well, can you private message me when you are finished? (DTM and Script)


Ill test it for you if you would like. :)

JAD
07-08-2007, 05:56 PM
Nice, nice. Funny name. :D

Alright, well, can you private message me when you are finished? (DTM and Script)


Ill test it for you if you would like. :)

I'm going to put the new DTM's in here, and my script has been released since yesterday :p

TravisV10
07-08-2007, 06:12 PM
Oh, SRY. I looked over the script. It seems pretty nice! Long too. :)

Good luck with it!

JAD
07-08-2007, 06:28 PM
Oh, SRY. I looked over the script. It seems pretty nice! Long too. :)

Good luck with it!

Thanks =)

TravisV10
07-08-2007, 07:36 PM
Thanks =)

Im going to be testing my script.

BobboHobbo
07-09-2007, 08:16 AM
I would use this but i need to use more of my procedures so i can be a member :)

TravisV10
07-09-2007, 02:27 PM
I would use this but i need to use more of my procedures so i can be a member :)

I hear ya....

Timothegreat
07-09-2007, 05:08 PM
thanks JAD

very useful, you will see this in many scripts.

With proper credit of course :)

Johura
07-12-2007, 09:28 AM
Thanks. I needed these.

Santa_Clause
07-12-2007, 03:08 PM
Lol Jahuro...I thought you don't script anymore..