SRL Archive - OSR Help

in fight (tpa)


Hoodz

2013-05-04 16:56:39

so im trying to write a yak fighter with tpa's (instead of FindColorsEx like my aio fighter)

but i got a question: is it possible to check if a yak is in combat already?
i thought if a hpbar dtm or something is close to the tpa (the yak) then it wont attack the yak. else if the tpa (yak) doesnt have a hpbar dtm in their area then it will attack them.

but i have no idea how to script it like that.

it is also possible to draw boxes around the tpa's right?
program yakkiller;
{$DEFINE SMART8}
{$I SRL-OSR/SRL.Simba}
{$i SRL-OSR\SRL\misc\debug.simba}
{$i SRL-OSR\SRL\misc\SmartGraphics.simba}

var
x, y: integer;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
nick := '';
Active := True;
end;
end;

function AttackYakCheck: Boolean;
var
TPAA: T2DPointArray;
TPA: TPointArray;
CTS, I, Retry, x, y: Integer;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 3619909, MSX1, MSY1, MSX2, MSY2, 7);
ColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(TPA, 15, 13);
SortATPASize(TPAA, True);
for I := 0 to High(TPAA) do
if GetArraylength(TPAA[i]) > 5 then
begin
repeat
inc(Retry);
MiddleTPAEx(TPAA[i], x, y);
MMouse(X, Y, 3, 3);
if (IsUpTextMultiCustom(['ak'])) then
begin
Result := True;
case random(6) of
0..4:
begin
MouseBox(X + 2, Y + 2, X + 2, Y + 2, mouse_left);
wait(3000 + random(250))
end;
5:
begin
MouseBox(X + 2, Y + 2, X + 2, Y + 2, mouse_right);
wait(200 + random(100));
ChooseOptionMulti(['tta']);
wait(3000 + random(250))
end;
end
end;
until (Retry = 15);
Break;
end;
end;

procedure IsInCombat;
begin
if FindColor(X, Y, 255, 223, 127, 295, 175) or FindColor(X, Y, 65280, 223, 127, 295, 175) then
sleep(500)
else
attackyakcheck;
end;

begin
DeclarePlayers;
SetupSRL();
disguise('HoodzYakz Beta v1');
SRL_CombatRandoms := False;
ActivateClient;
ClearDebug;
writeln('HoodzYakz Beta v1')
repeat
if (not LoggedIn) then
begin
LogInPlayer;
setangle(0)
end;
if (LoggedIn) then
IsInCombat;
until (false);
end.

thanks

Haxz

2013-05-04 16:59:20

Mine finds the monster with tpa, and draw a box of the monster so I know where I'm searching. Then it search in a box for the green and red color of hp bar above the tpa, if it is found, then it will search for the next monster. I've tried using HP bar DTM for this, but I find it not very efficient since I will need to search in a bigger box to find the whole DTM.

I usually draw the box according to my ATPA size(width and height). So I usually use even numbers.

        MP := MiddleTPA(ATPA[i]);
Box := IntToBox(MP.x-12, MP.y-17, MP.x+12, MP.y+17); //That means width 24, height 34
SMART_DrawBox(box);

EngageTheRage

2013-05-04 17:03:57

so this is my code for checking if they are in combat it draws a box slightly above where the monster was found and searches for the red of the hp bar, i am literally about to change it to check for splats as well. oh and there is a check so if its at the top of the screen it doesn't draw the box as it would give a negative y co-ord.



procedure AttackMonster;
var
bounds: TBox;
i, cx, cy: Integer;
theUpText: String;
begin
MyDeBug('started AttackMonster');
i := 0;
FindMonster;
while (i < length(monsterATPA)) do
begin
bounds := getTPABounds(monsterATPA[i]);
if(bounds.Y1 > 10) then
begin // need add in check for hit splats as well
if(FindColor(cx, cy, 255, bounds.X1, bounds.y1-10, bounds.X2, bounds.Y1 + 30)) then
begin
MyDeBug('that monster in combat');
AreNoobsTalking;
wait(randomrange(200,500));
inc(i);
continue;
end else
begin
MMouse((bounds.X1 +bounds.X2) /2, (bounds.Y1 +bounds.Y2) / 2, 5, 5);
theUpText := GetTextAtExWrap(55, 2, 94, 21, 0, 6, 2, 122074, 40, 'UpChars07');
MyDeBug('up text over monster is: ' + theUpText);
if (ExecRegExpr('.*'+monsterName+'.*', theUpText)) then
begin
clickmouse2(true);
MyDeBug('just clicked on a monster');
wait(randomrange(2000, 6000));
AreNoobsTalking;
break;
end;
end;
end;
inc(i);
end;
// SMART_ClearCanvas;
wait(randomrange(1000, 3000));
end;

hope thats helpful :) oh and still new to pascal so my code my not be great :)

Hoodz

2013-05-04 17:28:42

From: Haxz
Mine finds the monster with tpa, and draw a box of the monster so I know where I'm searching. Then it search in a box for the green and red color of hp bar above the tpa, if it is found, then it will search for the next monster. I've tried using HP bar DTM for this, but I find it not very efficient since I will need to search in a bigger box to find the whole DTM.

I usually draw the box according to my ATPA size(width and height). So I usually use even numbers.

        MP := MiddleTPA(ATPA[i]);
Box := IntToBox(MP.x-12, MP.y-17, MP.x+12, MP.y+17); //That means width 24, height 34
SMART_DrawBox(box);


From: EngageTheRage
so this is my code for checking if they are in combat it draws a box slightly above where the monster was found and searches for the red of the hp bar, i am literally about to change it to check for splats as well. oh and there is a check so if its at the top of the screen it doesn't draw the box as it would give a negative y co-ord.



procedure AttackMonster;
var
bounds: TBox;
i, cx, cy: Integer;
theUpText: String;
begin
MyDeBug('started AttackMonster');
i := 0;
FindMonster;
while (i < length(monsterATPA)) do
begin
bounds := getTPABounds(monsterATPA[i]);
if(bounds.Y1 > 10) then
begin // need add in check for hit splats as well
if(FindColor(cx, cy, 255, bounds.X1, bounds.y1-10, bounds.X2, bounds.Y1 + 30)) then
begin
MyDeBug('that monster in combat');
AreNoobsTalking;
wait(randomrange(200,500));
inc(i);
continue;
end else
begin
MMouse((bounds.X1 +bounds.X2) /2, (bounds.Y1 +bounds.Y2) / 2, 5, 5);
theUpText := GetTextAtExWrap(55, 2, 94, 21, 0, 6, 2, 122074, 40, 'UpChars07');
MyDeBug('up text over monster is: ' + theUpText);
if (ExecRegExpr('.*'+monsterName+'.*', theUpText)) then
begin
clickmouse2(true);
MyDeBug('just clicked on a monster');
wait(randomrange(2000, 6000));
AreNoobsTalking;
break;
end;
end;
end;
inc(i);
end;
// SMART_ClearCanvas;
wait(randomrange(1000, 3000));
end;

hope thats helpful :) oh and still new to pascal so my code my not be great :)


Thanks for the fast responses! I wil look into it tomorrow because i cant acces a pc at the moment.

More examples (with explainations) are welcome :)

Wu-Tang Clan

2013-05-04 21:19:47

I have a TPA Tester in my sig. You can test your colors in it.

Sk1nyNerd

2013-05-05 02:52:29

something like this?

FindAllHPBars

if you check out the skills folder in OSR and open the fighting.simba it will give a few options about being in fights, ive found this a lot easier and more useful when detecting in a fight. theres functions to detect how much damage has been delt on you, if others are fighting, and there are a couple to find the percent of Hp you or others have left (what i thought was the most useful so i can determine when i want to check my Hp in the skills tab and then eat, that way i dont have to spam back and forth between skills and inv to see if i have to eat or not or if im even the person taking damage). to use the functions in your script you will have to add this include

{$I SRL-OSR/SRL/skill/fighting.Simba}


if you want an example of how to write the eatfood function i can pm you mine
hope this helps, cheers :)

Hoodz

2013-05-06 10:12:26

From: Haxz
Mine finds the monster with tpa, and draw a box of the monster so I know where I'm searching. Then it search in a box for the green and red color of hp bar above the tpa, if it is found, then it will search for the next monster. I've tried using HP bar DTM for this, but I find it not very efficient since I will need to search in a bigger box to find the whole DTM.

I usually draw the box according to my ATPA size(width and height). So I usually use even numbers.

        MP := MiddleTPA(ATPA[i]);
Box := IntToBox(MP.x-12, MP.y-17, MP.x+12, MP.y+17); //That means width 24, height 34
SMART_DrawBox(box);


i get a unknown identifie: mp error :S

Haxz

2013-05-06 12:46:54

From: hoodz
i get a unknown identifie: mp error :S


Declare MP as TPoint. And Box as TBox.

Hoodz

2013-05-06 15:17:20

From: Haxz
Declare MP as TPoint. And Box as TBox.


Mmh i knew that :p what was i thinking…
Anyways thanks again!

Sk1nyNerd

2013-05-06 16:03:47

whats better exp, yaks or rock crabs?

King

2013-05-06 16:21:13

From: hoodz
Thanks for the fast responses! I wil look into it tomorrow because i cant acces a pc at the moment.

More examples (with explainations) are welcome :)


I like this, I use something similar to this in my Waterfiend killer, but you dont need to draw the box slightly above the yak, you can just draw it around the monster and then use a TPA to find the HP bar, or a DTM. I find it works better for me that way, either way, code looks good!

E* How I find monsters/people accurately

function TalkToMarrow: Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, L, X, Y: Integer;
Marrow: TPoint; //Point we found
MarrowBox: TBox; // Define the box we search for
begin
result := false;
SMART_ClearCanvas; //Always clear before re writing ( I believe it wont auto clear, not sure)
WriteDebug('Talking To Marrow'); //Always debug plenty
NPCDots := GetMMDotsOnMS('Yellow'); // This gathers all dots on the MM that are Yellow (NPC's)
WriteDebug('Got NPC dots');
SortTPAFrom(NPCDots, point( MSCX, MSCY) ); // Sorts the NPCs found from MM center (Closest to me)
if Length(NPCDots) = 0 then // Failsafe to detect if there are no NPC's, increases the failcount
begin
Inc(Tries);
exit;
end;
L := High(NPCDots) for i := 0 to L do // For all NPC dots found do the following
begin
WriteDebug('Finding marrow');
Marrow := MMToMSEx(0, - 20, NPCDots[i]); // Changes the MM dot found to a MS point, fairly accurate, not perfect
Marrowbox := IntToBox(Marrow.x - 50, Marrow.y - 50, Marrow.x + 50, Marrow.y + 50); //Create a 2500 pixel box around him (not as big as you think :P)
SMART_DrawBox(MarrowBox); //Draw the box on the MS
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.09); //Set my Hue and Sat mod for searching for Marrow (NPC)
if FindColorsSpiralTolerance(x, y, TPA, 5072242, MarrowBox.x1, MarrowBox.y1, MarrowBox.x2, MarrowBox.Y2, 11) then // Searches the box created above, creates a TPA of it
begin
WriteDebug('Clicking Marrow');
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 0.02); // Reset my Hue and Sat mods
ATPA := TPAtoATPAEx(TPA, 2, 2); Make an ATPA in 2 x 2 Boxes
SortATPAFrom(ATPA, MiddleBox(MarrowBox)); // Sorts the Points from the Middle of the box
if debug then
DebugATPA(ATPA, ''); //Shows the TPA found
L := High(ATPA) for i := 0 to L do
if GetArrayLength(ATPA[i]) >= 1 then // Makes sure the array has a length
begin
MiddleTPAEx(ATPA[i], x, y); // Finds the middle of that TPA
MMouse(x, y, 0, 0);
ClickMouse2(False);
if WaitOption('Fly', 250) then
begin
while IsMoving do
wait(RandomRange(25, 50));
FFlag(0); // Waits until the MM flag is gone
result := true;
SMART_ClearCanvas; //Clear the canvas
exit;
end
else
begin
Inc(Tries);
exit;
end;
end
else
begin
WriteDebug(' Could not find marrow');
ColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.02, 0.02);
end;
end
else
begin
Inc(Tries);
WriteDebug('Could not find marrow on MS');
exit;
end;
end;
end;

Hoodz

2013-05-06 16:41:35

From: King
I like this, I use something similar to this in my Waterfiend killer, but you dont need to draw the box slightly above the yak, you can just draw it around the monster and then use a TPA to find the HP bar, or a DTM. I find it works better for me that way, either way, code looks good!

E* How I find monsters/people accurately

function TalkToMarrow: Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, L, X, Y: Integer;
Marrow: TPoint; //Point we found
MarrowBox: TBox; // Define the box we search for
begin
result := false;
SMART_ClearCanvas; //Always clear before re writing ( I believe it wont auto clear, not sure)
WriteDebug('Talking To Marrow'); //Always debug plenty
NPCDots := GetMMDotsOnMS('Yellow'); // This gathers all dots on the MM that are Yellow (NPC's)
WriteDebug('Got NPC dots');
SortTPAFrom(NPCDots, point( MSCX, MSCY) ); // Sorts the NPCs found from MM center (Closest to me)
if Length(NPCDots) = 0 then // Failsafe to detect if there are no NPC's, increases the failcount
begin
Inc(Tries);
exit;
end;
L := High(NPCDots) for i := 0 to L do // For all NPC dots found do the following
begin
WriteDebug('Finding marrow');
Marrow := MMToMSEx(0, - 20, NPCDots[i]); // Changes the MM dot found to a MS point, fairly accurate, not perfect
Marrowbox := IntToBox(Marrow.x - 50, Marrow.y - 50, Marrow.x + 50, Marrow.y + 50); //Create a 2500 pixel box around him (not as big as you think :P)
SMART_DrawBox(MarrowBox); //Draw the box on the MS
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.09); //Set my Hue and Sat mod for searching for Marrow (NPC)
if FindColorsSpiralTolerance(x, y, TPA, 5072242, MarrowBox.x1, MarrowBox.y1, MarrowBox.x2, MarrowBox.Y2, 11) then // Searches the box created above, creates a TPA of it
begin
WriteDebug('Clicking Marrow');
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 0.02); // Reset my Hue and Sat mods
ATPA := TPAtoATPAEx(TPA, 2, 2); Make an ATPA in 2 x 2 Boxes
SortATPAFrom(ATPA, MiddleBox(MarrowBox)); // Sorts the Points from the Middle of the box
if debug then
DebugATPA(ATPA, ''); //Shows the TPA found
L := High(ATPA) for i := 0 to L do
if GetArrayLength(ATPA[i]) >= 1 then // Makes sure the array has a length
begin
MiddleTPAEx(ATPA[i], x, y); // Finds the middle of that TPA
MMouse(x, y, 0, 0);
ClickMouse2(False);
if WaitOption('Fly', 250) then
begin
while IsMoving do
wait(RandomRange(25, 50));
FFlag(0); // Waits until the MM flag is gone
result := true;
SMART_ClearCanvas; //Clear the canvas
exit;
end
else
begin
Inc(Tries);
exit;
end;
end
else
begin
WriteDebug(' Could not find marrow');
ColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.02, 0.02);
end;
end
else
begin
Inc(Tries);
WriteDebug('Could not find marrow on MS');
exit;
end;
end;
end;

Thank you so much :)
From: ibot_dung11
whats better exp, yaks or rock crabs?


Yaks but i noticed they are really crowded. So i think im going to make a ghoul fighter (with banking ofcourse) or a bandit fighter (guthan support+unnoting support)

Haxz

2013-05-06 17:03:53

From: King
I like this, I use something similar to this in my Waterfiend killer, but you dont need to draw the box slightly above the yak, you can just draw it around the monster and then use a TPA to find the HP bar, or a DTM. I find it works better for me that way, either way, code looks good!

E* How I find monsters/people accurately

function TalkToMarrow: Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i, L, X, Y: Integer;
Marrow: TPoint; //Point we found
MarrowBox: TBox; // Define the box we search for
begin
result := false;
SMART_ClearCanvas; //Always clear before re writing ( I believe it wont auto clear, not sure)
WriteDebug('Talking To Marrow'); //Always debug plenty
NPCDots := GetMMDotsOnMS('Yellow'); // This gathers all dots on the MM that are Yellow (NPC's)
WriteDebug('Got NPC dots');
SortTPAFrom(NPCDots, point( MSCX, MSCY) ); // Sorts the NPCs found from MM center (Closest to me)
if Length(NPCDots) = 0 then // Failsafe to detect if there are no NPC's, increases the failcount
begin
Inc(Tries);
exit;
end;
L := High(NPCDots) for i := 0 to L do // For all NPC dots found do the following
begin
WriteDebug('Finding marrow');
Marrow := MMToMSEx(0, - 20, NPCDots[i]); // Changes the MM dot found to a MS point, fairly accurate, not perfect
Marrowbox := IntToBox(Marrow.x - 50, Marrow.y - 50, Marrow.x + 50, Marrow.y + 50); //Create a 2500 pixel box around him (not as big as you think :P)
SMART_DrawBox(MarrowBox); //Draw the box on the MS
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.09); //Set my Hue and Sat mod for searching for Marrow (NPC)
if FindColorsSpiralTolerance(x, y, TPA, 5072242, MarrowBox.x1, MarrowBox.y1, MarrowBox.x2, MarrowBox.Y2, 11) then // Searches the box created above, creates a TPA of it
begin
WriteDebug('Clicking Marrow');
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 0.02); // Reset my Hue and Sat mods
ATPA := TPAtoATPAEx(TPA, 2, 2); Make an ATPA in 2 x 2 Boxes
SortATPAFrom(ATPA, MiddleBox(MarrowBox)); // Sorts the Points from the Middle of the box
if debug then
DebugATPA(ATPA, ''); //Shows the TPA found
L := High(ATPA) for i := 0 to L do
if GetArrayLength(ATPA[i]) >= 1 then // Makes sure the array has a length
begin
MiddleTPAEx(ATPA[i], x, y); // Finds the middle of that TPA
MMouse(x, y, 0, 0);
ClickMouse2(False);
if WaitOption('Fly', 250) then
begin
while IsMoving do
wait(RandomRange(25, 50));
FFlag(0); // Waits until the MM flag is gone
result := true;
SMART_ClearCanvas; //Clear the canvas
exit;
end
else
begin
Inc(Tries);
exit;
end;
end
else
begin
WriteDebug(' Could not find marrow');
ColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.02, 0.02);
end;
end
else
begin
Inc(Tries);
WriteDebug('Could not find marrow on MS');
exit;
end;
end;
end;


Would this work accurately on OSRS? I've tried using MMtoMS functions and I find it very inaccurate in OSRS.

King

2013-05-06 17:58:29

From: Haxz
Would this work accurately on OSRS? I've tried using MMtoMS functions and I find it very inaccurate in OSRS.


That is what this function is made for, the script searches a 50*50 box around the point it finds, making TPA searching much much simpler :P

Not the most accurate, but easily my favorite way of finding NPCs

Haxz

2013-05-06 18:04:41

From: King
That is what this function is made for, the script searches a 50*50 box around the point it finds, making TPA searching much much simpler :P

Not the most accurate, but easily my favorite way of finding NPCs


I see, now that makes sense :p
Gave me an idea on finding gates and ladders in game now :D

Sk1nyNerd

2013-05-06 22:27:27

From: King
I like this, I use something similar to this in my Waterfiend killer, but you dont need to draw the box slightly above the yak, you can just draw it around the monster and then use a TPA to find the HP bar, or a DTM. I find it works better for me that way, either way, code looks good!

E* How I find monsters/people accurately

Marrowbox := IntToBox(Marrow.x - 50, Marrow.y - 50, Marrow.x + 50, Marrow.y + 50);  


can u explain what this line does? whats it doing and what are the .x .y? also how do you determine what a good length is when sorting your tpas? two things i havent found an answer to :P thanks
From: hoodz
Thank you so much :)


Yaks but i noticed they are really crowded. So i think im going to make a ghoul fighter (with banking ofcourse) or a bandit fighter (guthan support+unnoting support)

a bandit one would be sick but idk how crowded that is, ghouls would be good too (i made one to afk when doing hw, not crowded at all)

King

2013-05-06 22:36:36

From: ibot_dung11
can u explain what this line does? whats it doing and what are the .x .y? also how do you determine what a good length is when sorting your tpas? two things i havent found an answer to :P thanks


This line makes a box out of the the Point called " Marrow " earlier in the script, it uses Marrow.x to know to take the First Marrow point, then subtract 50 from it to get a new point and so on, this will then make a Box around the character. A way to find a good TPA length depends on the object you are looking for, I split the points into boxes that are 2 x 2 pixels, I am looking for small amounts of color in the box ( His hair) so I picked a small number for the splitting and sorting functions. Also remember to sort your points from either the MM center or a distinct point on the MM (Such as my script sorts them later from the Transport symbol.)

King

2013-05-06 23:49:23

http://villavu.com/forum/showthread.php?t=102740&p=1234953#post1234953

Guide is posted

Sk1nyNerd

2013-05-07 04:23:31

From: King
This line makes a box out of the the Point called " Marrow " earlier in the script, it uses Marrow.x to know to take the First Marrow point, then subtract 50 from it to get a new point and so on, this will then make a Box around the character. A way to find a good TPA length depends on the object you are looking for, I split the points into boxes that are 2 x 2 pixels, I am looking for small amounts of color in the box ( His hair) so I picked a small number for the splitting and sorting functions. Also remember to sort your points from either the MM center or a distinct point on the MM (Such as my script sorts them later from the Transport symbol.)


cool! thankyou! ill check out the guide tomorrow, thanks for doin that :)

one last question, my updated p07 script is to large to upload because i have an insanly large bitmap for my paint [3k lines lol], is there a way to upload it or do i have to edit it? :/

King

2013-05-07 08:13:00

From: ibot_dung11
cool! thankyou! ill check out the guide tomorrow, thanks for doin that :)

one last question, my updated p07 script is to large to upload because i have an insanly large bitmap for my paint [3k lines lol], is there a way to upload it or do i have to edit it? :/


You can make it a .zip file.

Sk1nyNerd

2013-05-07 11:59:07

From: King
You can make it a .zip file.


how I do that? dont have winzip and it says I have to buy it

got it to work. thanks +1! :D

Shatterhand

2013-05-07 12:21:27

Im working on a fighter script too. The monster finding part is already ready and working. I search for all the hpbars on the screen and exclude those areas when finding colors for monster.

Finder function. Colors are set for ghouls. You will need two global variables.
MarkTime(FailTime); //call this before the searching loop
SortPoint := IntToPoint(MSCX,MSCY); //call this before the searching loop

function FindMonster: Boolean;
var
TPA, TempTPA, GreenTPA, RedTPA : TPointArray;
ATPA : Array of TPointArray;
X,Y, i,j, CTS, BoxWidth,BoxHeight, MinPoints : Integer;
Colors, Tolerances : Array of Integer;
HueMods, SatMods : Array of Extended;
a : TPoint;
TempBox : TBox;
ExcludeBoxes : Array of TBox;
begin
Result := False;

//EXCLUDING
FindColorsTolerance(GreenTPA,65280,MSX1,MSY1,MSX2,MSY2,0);
FindColorsTolerance(RedTPA,255,MSX1,MSY1,MSX2,MSY2,0);

TPA := CombineTPA(GreenTPA,RedTPA);

if (High(TPA) > 0) then
begin

SplitTPAWrap(TPA,1,ATPA);

SetLength(ExcludeBoxes,Length(ATPA));
for i:=0 to High(ATPA) do
begin
TempBox := GetTPABounds(ATPA[i]);
BoxWidth := TempBox.x2-TempBox.x1;
BoxHeight := TempBox.y2-TempBox.y1;
if (BoxWidth = 29) and (BoxHeight = 4) then
begin
TempBox.x1 := TempBox.x1-20; //the bigger the monster is, the bigger you make this box
TempBox.y1 := TempBox.y1-20;
TempBox.x2 := TempBox.x2+20;
TempBox.y2 := TempBox.y2+40;
ExcludeBoxes[j] := TempBox;
Inc(j);
end;
end;
SetArrayLength(ExcludeBoxes,j);
end;

//MONSTER
Colors := [8364964];
Tolerances := [24];
HueMods := [0.02];
SatMods := [0.23];
MinPoints := 50;


CTS := GetToleranceSpeed;
ColorToleranceSpeed(2);
for i:=0 to High(Colors) do
begin
SetToleranceSpeed2Modifiers(Huemods[i],SatMods[i]);
FindColorsTolerance(TempTPA,Colors[i],MSX1,MSY1,MSX2,MSY2,Tolerances[i]);
AppendTPA(TPA,TempTPA);
end;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

//Excluding - boxes
for i:=0 to High(TPA) do
begin
for j:=0 to High(ExcludeBoxes) do
begin
if PointInBox(TPA[i],ExcludeBoxes[j]) then
begin
a := IntToPoint(MSCX,MSCY);
tSwap(TPA[i],a);
Break;
end;
end;
end;

//Excluding - middle
SortTPAFrom(TPA,Point(MSCX,MSCY));
InvertTPA(TPA);
for i:=0 to High(TPA) do
if (Abs(TPA[i].x - MSCX) < 20) and (Abs(TPA[i].y - MSCY) < 30) then
Break;
SetArrayLength(TPA,i);



if (High(TPA)> 0) then
begin

ATPA := SplitTPA(TPA,10);

SortATPASize(ATPA,True);
for i:=0 to High(ATPA) do
begin
if High(ATPA[i]) < MinPoints then
Break;
end;
if (i = 0) then Exit;
SetArrayLength(ATPA,i);


SortATPAFromFirstPoint(ATPA,IntToPoint(MSCX,MSCY));

DebugAll(TPA,ATPA,0,ExcludeBoxes);
{$IFDEF SMART}
//SMART_DebugAll(TPA,ATPA,0,ExcludeBoxes);
{$ENDIF}


MiddleTPAEx(ATPA[0],X,Y);
if (TimeFromMark(FailTime) < 5000) then
begin
Mouse(X,Y,0,0,mouse_move);
if IsUpText('Attack') then
begin
ClickMouse2(mouse_left);
if DidClick(True,2000) then
begin
Result := True;
Exit;
end;
end else
begin
SortPoint := IntToPoint(X,Y);
end;
end else
begin
Mouse(X,Y,0,0,mouse_right);
if ChooseOption('Attack') then
begin
Result := True;
Exit;
end else
begin
SortPoint := IntToPoint(X,Y);
end;
end;
end;
end;

Debug functions:

procedure SetBoxToBounds(var Box : TBox; X1,Y1,X2,Y2 : Integer);
begin
if (Box.x1 < X1) then Box.x1 := X1;
if (Box.x2 > X2) then Box.x2 := X2;
if (Box.y1 < Y1) then Box.y1 := Y1;
if (Box.y2 > Y2) then Box.y2 := Y2;
end;

procedure DebugAll(TPA: TPointArray; ATPA: Array of TPointArray; First: Integer; Boxes: Array of TBox);
var
BMP, Col, x, y, i, width, height: Integer;
TPABox : TBox;
begin
//if not DebugWindow then Exit;

GetClientDimensions(width,height);
BMP := BitmapFromClient(0,0,width-1,height-1);
DrawTPABitmap(BMP,TPA,ClWhite);

for i:=0 to High(ATPA) do
begin
if i = First then
Col := ClRed
else
Col := ClYellow;

TPABox := GetTPABounds(ATPA[i]);
SetBoxToBounds(TPABox,0,0,width-1,height-1);

for x := TPABox.x1 to TPABox.x2 do
begin
FastSetPixel(BMP,x,TPABox.y1,Col)
FastSetPixel(BMP,x,TPABox.y2,Col)
end;
for y := TPABox.y1 to TPABox.y2 do
begin
FastSetPixel(BMP,TPABox.x1,y,Col)
FastSetPixel(BMP,TPABox.x2,y,Col)
end;
end;

for i:=Low(Boxes) to High(Boxes) do
begin
SetBoxToBounds(Boxes[i],MSX1,MSY1,MSX2,MSY2);
for x := Boxes[i].x1 to Boxes[i].x2 do
begin
FastSetPixel(BMP,x,Boxes[i].y1,ClBlack)
FastSetPixel(BMP,x,Boxes[i].y2,ClBlack)
end;
for y := Boxes[i].y1 to Boxes[i].y2 do
begin
FastSetPixel(BMP,Boxes[i].x1,y,ClBlack)
FastSetPixel(BMP,Boxes[i].x2,y,ClBlack)
end;
end;

DebugBitmap(BMP);
FreeBitmap(BMP);
end;

King

2013-05-07 14:11:45

From: Shatterhand
Im working on a fighter script too. The monster finding part is already ready and working. I search for all the hpbars on the screen and exclude those areas when finding colors for monster.

Finder function. Colors are set for ghouls. You will need two global variables.
MarkTime(FailTime); //call this before the searching loop
SortPoint := IntToPoint(MSCX,MSCY); //call this before the searching loop

function FindMonster: Boolean;
var
TPA, TempTPA, GreenTPA, RedTPA : TPointArray;
ATPA : Array of TPointArray;
X,Y, i,j, CTS, BoxWidth,BoxHeight, MinPoints : Integer;
Colors, Tolerances : Array of Integer;
HueMods, SatMods : Array of Extended;
a : TPoint;
TempBox : TBox;
ExcludeBoxes : Array of TBox;
begin
Result := False;

//EXCLUDING
FindColorsTolerance(GreenTPA,65280,MSX1,MSY1,MSX2,MSY2,0);
FindColorsTolerance(RedTPA,255,MSX1,MSY1,MSX2,MSY2,0);

TPA := CombineTPA(GreenTPA,RedTPA);

if (High(TPA) > 0) then
begin

SplitTPAWrap(TPA,1,ATPA);

SetLength(ExcludeBoxes,Length(ATPA));
for i:=0 to High(ATPA) do
begin
TempBox := GetTPABounds(ATPA[i]);
BoxWidth := TempBox.x2-TempBox.x1;
BoxHeight := TempBox.y2-TempBox.y1;
if (BoxWidth = 29) and (BoxHeight = 4) then
begin
TempBox.x1 := TempBox.x1-20; //the bigger the monster is, the bigger you make this box
TempBox.y1 := TempBox.y1-20;
TempBox.x2 := TempBox.x2+20;
TempBox.y2 := TempBox.y2+40;
ExcludeBoxes[j] := TempBox;
Inc(j);
end;
end;
SetArrayLength(ExcludeBoxes,j);
end;

//MONSTER
Colors := [8364964];
Tolerances := [24];
HueMods := [0.02];
SatMods := [0.23];
MinPoints := 50;


CTS := GetToleranceSpeed;
ColorToleranceSpeed(2);
for i:=0 to High(Colors) do
begin
SetToleranceSpeed2Modifiers(Huemods[i],SatMods[i]);
FindColorsTolerance(TempTPA,Colors[i],MSX1,MSY1,MSX2,MSY2,Tolerances[i]);
AppendTPA(TPA,TempTPA);
end;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

//Excluding - boxes
for i:=0 to High(TPA) do
begin
for j:=0 to High(ExcludeBoxes) do
begin
if PointInBox(TPA[i],ExcludeBoxes[j]) then
begin
a := IntToPoint(MSCX,MSCY);
tSwap(TPA[i],a);
Break;
end;
end;
end;

//Excluding - middle
SortTPAFrom(TPA,Point(MSCX,MSCY));
InvertTPA(TPA);
for i:=0 to High(TPA) do
if (Abs(TPA[i].x - MSCX) < 20) and (Abs(TPA[i].y - MSCY) < 30) then
Break;
SetArrayLength(TPA,i);



if (High(TPA)> 0) then
begin

ATPA := SplitTPA(TPA,10);

SortATPASize(ATPA,True);
for i:=0 to High(ATPA) do
begin
if High(ATPA[i]) < MinPoints then
Break;
end;
if (i = 0) then Exit;
SetArrayLength(ATPA,i);


SortATPAFromFirstPoint(ATPA,IntToPoint(MSCX,MSCY));

DebugAll(TPA,ATPA,0,ExcludeBoxes);
{$IFDEF SMART}
//SMART_DebugAll(TPA,ATPA,0,ExcludeBoxes);
{$ENDIF}


MiddleTPAEx(ATPA[0],X,Y);
if (TimeFromMark(FailTime) < 5000) then
begin
Mouse(X,Y,0,0,mouse_move);
if IsUpText('Attack') then
begin
ClickMouse2(mouse_left);
if DidClick(True,2000) then
begin
Result := True;
Exit;
end;
end else
begin
SortPoint := IntToPoint(X,Y);
end;
end else
begin
Mouse(X,Y,0,0,mouse_right);
if ChooseOption('Attack') then
begin
Result := True;
Exit;
end else
begin
SortPoint := IntToPoint(X,Y);
end;
end;
end;
end;

Debug functions:

procedure SetBoxToBounds(var Box : TBox; X1,Y1,X2,Y2 : Integer);
begin
if (Box.x1 < X1) then Box.x1 := X1;
if (Box.x2 > X2) then Box.x2 := X2;
if (Box.y1 < Y1) then Box.y1 := Y1;
if (Box.y2 > Y2) then Box.y2 := Y2;
end;

procedure DebugAll(TPA: TPointArray; ATPA: Array of TPointArray; First: Integer; Boxes: Array of TBox);
var
BMP, Col, x, y, i, width, height: Integer;
TPABox : TBox;
begin
//if not DebugWindow then Exit;

GetClientDimensions(width,height);
BMP := BitmapFromClient(0,0,width-1,height-1);
DrawTPABitmap(BMP,TPA,ClWhite);

for i:=0 to High(ATPA) do
begin
if i = First then
Col := ClRed
else
Col := ClYellow;

TPABox := GetTPABounds(ATPA[i]);
SetBoxToBounds(TPABox,0,0,width-1,height-1);

for x := TPABox.x1 to TPABox.x2 do
begin
FastSetPixel(BMP,x,TPABox.y1,Col)
FastSetPixel(BMP,x,TPABox.y2,Col)
end;
for y := TPABox.y1 to TPABox.y2 do
begin
FastSetPixel(BMP,TPABox.x1,y,Col)
FastSetPixel(BMP,TPABox.x2,y,Col)
end;
end;

for i:=Low(Boxes) to High(Boxes) do
begin
SetBoxToBounds(Boxes[i],MSX1,MSY1,MSX2,MSY2);
for x := Boxes[i].x1 to Boxes[i].x2 do
begin
FastSetPixel(BMP,x,Boxes[i].y1,ClBlack)
FastSetPixel(BMP,x,Boxes[i].y2,ClBlack)
end;
for y := Boxes[i].y1 to Boxes[i].y2 do
begin
FastSetPixel(BMP,Boxes[i].x1,y,ClBlack)
FastSetPixel(BMP,Boxes[i].x2,y,ClBlack)
end;
end;

DebugBitmap(BMP);
FreeBitmap(BMP);
end;


Looks nice :p

Hoodz

2013-05-07 18:35:32

From: Shatterhand
Im working on a fighter script too. The monster finding part is already ready and working. I search for all the hpbars on the screen and exclude those areas when finding colors for monster.

Finder function. Colors are set for ghouls. You will need two global variables.
MarkTime(FailTime); //call this before the searching loop
SortPoint := IntToPoint(MSCX,MSCY); //call this before the searching loop

function FindMonster: Boolean;
var
TPA, TempTPA, GreenTPA, RedTPA : TPointArray;
ATPA : Array of TPointArray;
X,Y, i,j, CTS, BoxWidth,BoxHeight, MinPoints : Integer;
Colors, Tolerances : Array of Integer;
HueMods, SatMods : Array of Extended;
a : TPoint;
TempBox : TBox;
ExcludeBoxes : Array of TBox;
begin
Result := False;

//EXCLUDING
FindColorsTolerance(GreenTPA,65280,MSX1,MSY1,MSX2,MSY2,0);
FindColorsTolerance(RedTPA,255,MSX1,MSY1,MSX2,MSY2,0);

TPA := CombineTPA(GreenTPA,RedTPA);

if (High(TPA) > 0) then
begin

SplitTPAWrap(TPA,1,ATPA);

SetLength(ExcludeBoxes,Length(ATPA));
for i:=0 to High(ATPA) do
begin
TempBox := GetTPABounds(ATPA[i]);
BoxWidth := TempBox.x2-TempBox.x1;
BoxHeight := TempBox.y2-TempBox.y1;
if (BoxWidth = 29) and (BoxHeight = 4) then
begin
TempBox.x1 := TempBox.x1-20; //the bigger the monster is, the bigger you make this box
TempBox.y1 := TempBox.y1-20;
TempBox.x2 := TempBox.x2+20;
TempBox.y2 := TempBox.y2+40;
ExcludeBoxes[j] := TempBox;
Inc(j);
end;
end;
SetArrayLength(ExcludeBoxes,j);
end;

//MONSTER
Colors := [8364964];
Tolerances := [24];
HueMods := [0.02];
SatMods := [0.23];
MinPoints := 50;


CTS := GetToleranceSpeed;
ColorToleranceSpeed(2);
for i:=0 to High(Colors) do
begin
SetToleranceSpeed2Modifiers(Huemods[i],SatMods[i]);
FindColorsTolerance(TempTPA,Colors[i],MSX1,MSY1,MSX2,MSY2,Tolerances[i]);
AppendTPA(TPA,TempTPA);
end;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

//Excluding - boxes
for i:=0 to High(TPA) do
begin
for j:=0 to High(ExcludeBoxes) do
begin
if PointInBox(TPA[i],ExcludeBoxes[j]) then
begin
a := IntToPoint(MSCX,MSCY);
tSwap(TPA[i],a);
Break;
end;
end;
end;

//Excluding - middle
SortTPAFrom(TPA,Point(MSCX,MSCY));
InvertTPA(TPA);
for i:=0 to High(TPA) do
if (Abs(TPA[i].x - MSCX) < 20) and (Abs(TPA[i].y - MSCY) < 30) then
Break;
SetArrayLength(TPA,i);



if (High(TPA)> 0) then
begin

ATPA := SplitTPA(TPA,10);

SortATPASize(ATPA,True);
for i:=0 to High(ATPA) do
begin
if High(ATPA[i]) < MinPoints then
Break;
end;
if (i = 0) then Exit;
SetArrayLength(ATPA,i);


SortATPAFromFirstPoint(ATPA,IntToPoint(MSCX,MSCY));

DebugAll(TPA,ATPA,0,ExcludeBoxes);
{$IFDEF SMART}
//SMART_DebugAll(TPA,ATPA,0,ExcludeBoxes);
{$ENDIF}


MiddleTPAEx(ATPA[0],X,Y);
if (TimeFromMark(FailTime) < 5000) then
begin
Mouse(X,Y,0,0,mouse_move);
if IsUpText('Attack') then
begin
ClickMouse2(mouse_left);
if DidClick(True,2000) then
begin
Result := True;
Exit;
end;
end else
begin
SortPoint := IntToPoint(X,Y);
end;
end else
begin
Mouse(X,Y,0,0,mouse_right);
if ChooseOption('Attack') then
begin
Result := True;
Exit;
end else
begin
SortPoint := IntToPoint(X,Y);
end;
end;
end;
end;

Debug functions:

procedure SetBoxToBounds(var Box : TBox; X1,Y1,X2,Y2 : Integer);
begin
if (Box.x1 < X1) then Box.x1 := X1;
if (Box.x2 > X2) then Box.x2 := X2;
if (Box.y1 < Y1) then Box.y1 := Y1;
if (Box.y2 > Y2) then Box.y2 := Y2;
end;

procedure DebugAll(TPA: TPointArray; ATPA: Array of TPointArray; First: Integer; Boxes: Array of TBox);
var
BMP, Col, x, y, i, width, height: Integer;
TPABox : TBox;
begin
//if not DebugWindow then Exit;

GetClientDimensions(width,height);
BMP := BitmapFromClient(0,0,width-1,height-1);
DrawTPABitmap(BMP,TPA,ClWhite);

for i:=0 to High(ATPA) do
begin
if i = First then
Col := ClRed
else
Col := ClYellow;

TPABox := GetTPABounds(ATPA[i]);
SetBoxToBounds(TPABox,0,0,width-1,height-1);

for x := TPABox.x1 to TPABox.x2 do
begin
FastSetPixel(BMP,x,TPABox.y1,Col)
FastSetPixel(BMP,x,TPABox.y2,Col)
end;
for y := TPABox.y1 to TPABox.y2 do
begin
FastSetPixel(BMP,TPABox.x1,y,Col)
FastSetPixel(BMP,TPABox.x2,y,Col)
end;
end;

for i:=Low(Boxes) to High(Boxes) do
begin
SetBoxToBounds(Boxes[i],MSX1,MSY1,MSX2,MSY2);
for x := Boxes[i].x1 to Boxes[i].x2 do
begin
FastSetPixel(BMP,x,Boxes[i].y1,ClBlack)
FastSetPixel(BMP,x,Boxes[i].y2,ClBlack)
end;
for y := Boxes[i].y1 to Boxes[i].y2 do
begin
FastSetPixel(BMP,Boxes[i].x1,y,ClBlack)
FastSetPixel(BMP,Boxes[i].x2,y,ClBlack)
end;
end;

DebugBitmap(BMP);
FreeBitmap(BMP);
end;


Thanks, looking great! Ill check it tomorrow

samerdl

2013-05-08 05:30:56

From: hoodz
Thank you so much :)


Yaks but i noticed they are really crowded. So i think im going to make a ghoul fighter (with banking ofcourse) or a bandit fighter (guthan support+unnoting support)


if you post something like, your really going to hurt legit players on slayer task(the fact you just said that publicly probably caught the eye of some injection bot scripter) personally i made my own ghoul fighter and have been using it for a while.

Hoodz

2013-05-08 06:04:36

From: samerdl
if you post something like, your really going to hurt legit players on slayer task(the fact you just said that publicly probably caught the eye of some injection bot scripter) personally i made my own ghoul fighter and have been using it for a while.


Its going to be a paid script and free to srl members :)

samerdl

2013-05-08 07:29:43

From: hoodz
Its going to be a paid script and free to srl members :)


Scripts can not be sold on SRL forums, you plan to sell on sythe?

Hoodz

2013-05-08 07:52:58

From: samerdl
Scripts can not be sold on SRL forums, you plan to sell on sythe?


ill make a video of the bot working on a thread. if a srl member wants the script he needs to pm me. if a non srl member wants the script he needs to contact me via another way. (not sure how)

King

2013-05-08 10:38:51

From: samerdl
if you post something like, your really going to hurt legit players on slayer task(the fact you just said that publicly probably caught the eye of some injection bot scripter) personally i made my own ghoul fighter and have been using it for a while.


There use to be a ghoul fighter. It was fine there. If the legit player has an issue, he/ she can log onto a different language server. Laakerrules was pretty darn flawless and had banking. It wasn't an issue then? Also as for the injection bot scripter comment, some of us can here can script Java. There is already a fighter that will kill ghouls. There are several actually.

So at OP please go ahead and release it, don't worry about this comment. Hope all goes well :D


From: hoodz
ill make a video of the bot working on a thread. if a srl member wants the script he needs to pm me. if a non srl member wants the script he needs to contact me via another way. (not sure how)


One of us ( members ) can post it in the members section for you. You won't be able to see it, but you can make an update link to a git and update it that way. If you want to sell on sythe feel free to PM me about it. Id be more than happy to help out(:

Hoodz

2013-05-08 12:08:40

From: King

One of us ( members ) can post it in the members section for you. You won't be able to see it, but you can make an update link to a git and update it that way. If you want to sell on sythe feel free to PM me about it. Id be more than happy to help out(:


i cant see/edit the thread.

maybe i can apply for members soon if my script is completed.

King

2013-05-08 13:43:42

From: hoodz
i cant see/edit the thread.

maybe i can apply for members soon if my script is completed.


I know. Sounds good!

Sk1nyNerd

2013-05-08 14:15:09

is syth a good site? ive never used it and have been pondering the same question as hoodz for a bit now. also how can you let non members know about it without breaking the rules? perhaps pm me? thanks :)

Ian

2013-05-08 14:54:07

From: ibot_dung11
is syth a good site? ive never used it and have been pondering the same question as hoodz for a bit now. also how can you let non members know about it without breaking the rules? perhaps pm me? thanks :)


Sythe is full of scammers, but besides them it's probably not bad.

Hoodz

2013-05-08 15:29:03

From: BMWxi
Sythe is full of scammers, but besides them it's probably not bad.


yes but they need to pay first. and i dont scam so people are here are safe :)

Hoodz

2013-05-08 15:32:39

From: hoodz
Mmh i knew that :p what was i thinking…
Anyways thanks again!


i can see the paint above the npc the bots tries to attack. how do i make it so that if there is a color (hpbar colors) then it wont attack them)

EngageTheRage

2013-05-08 16:15:20

From: hoodz
i can see the paint above the npc the bots tries to attack. how do i make it so that if there is a color (hpbar colors) then it wont attack them)


i thought you had that sorted? did you get my pm?

Hoodz

2013-05-08 18:36:59

From: EngageTheRage
i thought you had that sorted? did you get my pm?


Oh yes! Totally forgot that! Got it:)

Haxz

2013-05-08 20:08:09

If not HPBarColor then
AttackMonster
else
writeln('Monster in fight');

Hoodz

2013-05-11 09:15:14

mmh so i got bad rep for a post in this thread: no selling scripts!
if that person could say where im selling scripts that would be great.

edit: someone balanced the bad rep (THANKS) but barbrady fucked it up anyways: http://villavu.com/forum/showthread.php?t=102801&p
he gave me multipe bad reps. i can never get it positive again.

rj

2013-05-11 15:21:46

From: hoodz
mmh so i got bad rep for a post in this thread: no selling scripts!
if that person could say where im selling scripts that would be great.

edit: someone balanced the bad rep (THANKS) but barbrady fucked it up anyways: http://villavu.com/forum/showthread.php?t=102801&p
he gave me multipe bad reps. i can never get it positive again.

Gave you 2. Quit whining someone will feel sorry for you and + rep you and - rep me.

Hoodz

2013-05-11 17:36:10

From: Officer Barbrady
Gave you 2. Quit whining someone will feel sorry for you and + rep you and - rep me.


I didnt - rep you? And if i did it was a missclick. And your reps count for like 4 so thats -8 points. I didnt mean anything i just asked why you didnt paint it on smart because i like that :)