SRL Archive - SRL Archives

"Wireless" ent finder


JuKKa

2007-07-31 18:41:36

Why i call it Wireless ent finder is because it does NOT use the mouse :)

Functions:
Procedure GetTreePoints(Ex,Ey: Integer);
Procedure ZeroTreePoints;
Procedure AvoidEnt(Ex, Ey: Integer);
Procedure PrintPoints;
Function CompareTreePoints(Ex, Ey: Integer): Boolean;
Function FindTreeEnt(Ex, Ey: Integer): Boolean;
Function HandleEnt(Ex, Ey: Integer): Boolean;

How To Use:
When you find your "tree" you want to chop. Call: GetTreePoints(Ex,Ey: Integer); (But you should also call the normal which checks for the yellow tex)
Ex And Ey are the cordinates for the tree THESE ARE NOT ALLOWED TO CHANGE!

When you want to check for the ent. Call: HandleEnt(Ex, Ey: Integer): Boolean; Ex And Ey are the Cordinates for the tree.

Info:
It will take 9 "getcolor" and store them to a "array of array" which it then checks if the colors changed. If the colors has changed 5/9 then it has found a ent and will avoid it. If you use this please let me know how it worked.


Program RelaxingEntFinder;

{.Include SRL/SRL.Scar}

Var
CTree: Array [0..2] of Array [0..2] of Integer;
I, O, P: Integer;
TempCTree: Array [0..2] of Array [0..2] of Integer;

Procedure GetTreePoints(Ex,Ey: Integer);
Begin
For I:= 0 To 2 Do
For O:= 0 To 2 Do
CTree[I][O]:= GetColor(Ex + I, Ey + O);
End;

Procedure ZeroTreePoints;
Begin
For I:= 0 To 2 Do
For O:= 0 To 2 Do
CTree[I][O]:= -1;
End;

Procedure ZeroTempTreePoints;
Begin
For I:= 0 To 2 Do
For O:= 0 To 2 Do
TempCTree[I][O]:= -1;
End;

Function GetaArrayOfBooleans: Array of Boolean;
Begin
For I:= 0 To 2 Do
For O:= 0 To 2 Do
If(TempCTree[O][I] = CTree[O][I])Then
Begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[getarraylength(result)-1]:= True;
End;
End;

Function CompareTreePoints(Ex, Ey: Integer): Boolean;
Var
BoolArray: Array of Boolean;
Begin

For I:= 0 To 2 Do
For O:= 0 To 2 Do
TempCTree[O][I]:= GetColor(Ex + O, Ey + I);

BoolArray:= GetaArrayOfBooleans;
Writeln('Matching: '+Inttostr(GetArrayLength(BoolArray)) + '/9');
If(GetArrayLength(BoolArray)>=(5))Then
Result:= True;

ZeroTempTreePoints;
If(Result)Then
ZeroTreePoints;
End;

Function FindTreeEnt(Ex, Ey: Integer): Boolean;
Begin
If(Not CompareTreePoints(Ex, Ey))Then
Result:= True;
End;

Procedure AvoidEnt(Ex, Ey: Integer);
Var
FailTimer, OldMouseSpeed: Integer;
Begin
Writeln('Ent Avoidment started');
OldMouseSpeed:= MouseSpeed;
MouseSpeed:= 0;
Mouse(MSCX, MSCY, 5,5, True);
Flag;
MarkTime(FailTimer);
Wait(25+Random(25));
Repeat
GetTreePoints(Ex, Ey);
Wait(2000+Random(2000));
If(Not FindTreeEnt(Ex, Ey))Then
Begin
Writeln('Ent Avoided!');
Break;
End;
If(TimeFromMark(FailTimer)>20000)Then
Begin
Writeln('Fail Safe Timer!, Couldnt Get a "Proper" Ent Avoid :/');
Break;
End;
Until(Not Loggedin);
MouseSpeed:= OldMouseSpeed;
End;

Procedure PrintPoints;
Begin
For I:= 0 To 2 Do
For O:= 0 To 2 Do
Writeln(Inttostr(O)+', '+IntToStr(I) + ': ' + IntToStr(CTree[O][I]));
End;

Function HandleEnt(Ex, Ey: Integer): Boolean;
Begin
If(FindTreeEnt(Ex, Ey))Then
Begin
Result:= True;
AvoidEnt(Ex, Ey);
End;
End;

Smartzkid

2007-07-31 18:46:33

Awesome name :D

I think Esteban would be very interested in this, would you mind pm'ing it to him?

JuKKa

2007-07-31 18:48:56

From: Smartzkid
Awesome name :D

I think Esteban would be very interested in this, would you mind pm'ing it to him?


Umm, Who is he? a fan i hope or hes getting nuttin! lall just kiddi'n just gotta find his profile >_<

Esteban

2007-07-31 22:55:22

This is pretty much what I thought of using for ent finding (the idea). Of course, I probably couldn't of done something like it anyways. Mind explaining it more in depth? I will try it when I can.

off topic: posted all of that on my psp! Took about only 10 mins…

Pyro

2007-08-01 02:17:26

I thought about this making this a while ago. In the end i actually used it to detect whether the tree was gone. But when i used htis it was a probelm with the screen shifting ever so slightly. I reccomend looking up fix mouse in the scar help file.

JuKKa

2007-08-01 05:08:50

From: Pyro
I thought about this making this a while ago. In the end i actually used it to detect whether the tree was gone. But when i used htis it was a probelm with the screen shifting ever so slightly. I reccomend looking up fix mouse in the scar help file.


actually the screen shifting is not really a problem since it doesent shift THAT much and often it doesent even shift. Mostly the minimap right? Correct me if im wrong.

Pyro

2007-08-01 18:07:36

From: JuKKa
actually the screen shifting is not really a problem since it doesent shift THAT much and often it doesent even shift. Mostly the minimap right? Correct me if im wrong.


No the main screen shifts aswell. And it doesnt matter if it moves one pixel…. it still shifts and the colors will be wrong with the getcolors.

3Garrett3

2007-08-01 18:22:54

How much does it shift and how often, cause I want to make something, but if it shifts alot, it isnt going to work…

JuKKa

2007-08-01 19:29:16

From: 3garrett3
How much does it shift and how often, cause I want to make something, but if it shifts alot, it isnt going to work…


well it mostly shifts the minimap but i dunno about the screen i think it wont shift when standing still. But please just test and tell me what u got.

Pyro

2007-08-01 22:23:20

…. I made a yew cutter…. Used somethign similar like this to detect ents (didnt work) so i modded it to tell me when the tree had gone. The screen shifts. write something up and see when the colors change. I know with me cutting yews. Before the tree was down the screen had shifted atleast once. Like i said you should look at fixmouse in scar help file. I tried writing everything to align pixels. But obviously it rotates around a point and i couldnt be bothered writing up something to work out how much each pixel shifted.