SRL-Forums  

Welcome to the SRL! ...SRL Repository ... SRL forums have opened up for registration again! ... Make sure you check out Simba

Go Back   SRL-Forums > SRL Public Forum > SRL Public SVN > Suggestions
Suggestions Any suggestions on new additions to SRL or changes to SRL go here.



Reply
 
Thread Tools
(#1)
Old
mariofan12's Avatar
mariofan12 mariofan12 is offline
SRL Member
SRL Old Timer
Chicken
mariofan12 is on a distinguished road
 
Activity Longevity
0/20 10/20
Today Posts
0/5 ssssss141
Default Object.scar and Fighting.scar - 07-30-2010, 01:16 AM

Object.scar-
I've begun to make a simple cow killer/beefy banker, and I noticed that the color finder will spot colors outside the main screen causing my mouse to move all around the border

Fighting.scar-
the InFight function rarely works. Currently I'm putting that through a for loop to repeat 15 times exiting once it is true. I know that method is terrible, but its a quick fix for now.

I am using the newest version of Simba.

EDIT: bad grammer



Last edited by EvilChicken!; 08-05-2010 at 11:29 PM.
Reply With Quote
(#2)
Old
Frement's Avatar
Frement Frement is offline
SRL Member
SRL Old Timer SRL Useful poster
King Black Dragon
Frement has a spectacular aura aboutFrement has a spectacular aura about
 
Activity Longevity
13/20 13/20
Today Posts
2/5 sssss1279
Send a message via MSN to Frement Send a message via Skype™ to Frement
Default 07-30-2010, 01:23 AM

My fix (if it still works):
SCAR Code:
function F_InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
  FindColorsTolerance( GTPA, 49499, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20 );
  FindColorsTolerance( RTPA, 590010, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20 );
  Result := ( ( GetArrayLength( GTPA ) + GetArrayLength( RTPA ) ) >= 20 );
end;


My scripts: Monk of Zamorak Abuser
" There are no classes in life for beginners: right away you are always asked to deal with what is most difficult.
"
My Site: http://www.frement.net/



Reply With Quote
(#3)
Old
mariofan12's Avatar
mariofan12 mariofan12 is offline
SRL Member
SRL Old Timer
Chicken
mariofan12 is on a distinguished road
 
Activity Longevity
0/20 10/20
Today Posts
0/5 ssssss141
Default 07-30-2010, 01:42 AM

Tested your function in a loop of 10 while fighting a cow, all 10 loops came back false


Reply With Quote
(#4)
Old
Frement's Avatar
Frement Frement is offline
SRL Member
SRL Old Timer SRL Useful poster
King Black Dragon
Frement has a spectacular aura aboutFrement has a spectacular aura about
 
Activity Longevity
13/20 13/20
Today Posts
2/5 sssss1279
Send a message via MSN to Frement Send a message via Skype™ to Frement
Default 07-30-2010, 01:45 AM

Oh yeah, maybe the colors need updating.

EDIT: This worked perfectly for me, note that you need to use SetAngle(True); or ClickNorth(True);

SCAR Code:
program Test;
{$I SRL/SRL.scar}

function F_InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
  FindColorsTolerance( GTPA, 49763, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 15 );
  FindColorsTolerance( RTPA, 590010, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 15 );
  Result := ( ( GetArrayLength( GTPA ) + GetArrayLength( RTPA ) ) >= 20 );
end;

begin
SetupSRL;
  repeat
    if (F_InFight) then begin
      ClearDebug;
      Writeln('InFight');
    end else begin
      ClearDebug;
      Writeln('Not InFight');
    end;
    Wait(200);
  until(False);
end.


My scripts: Monk of Zamorak Abuser
" There are no classes in life for beginners: right away you are always asked to deal with what is most difficult.
"
My Site: http://www.frement.net/




Last edited by Frement; 07-30-2010 at 01:53 AM.
Reply With Quote
(#5)
Old
mariofan12's Avatar
mariofan12 mariofan12 is offline
SRL Member
SRL Old Timer
Chicken
mariofan12 is on a distinguished road
 
Activity Longevity
0/20 10/20
Today Posts
0/5 ssssss141
Default 07-30-2010, 02:03 AM

Nice! I did ClickNorth(true) and both functions work now lol. Didn't think it would make that big of a difference thanks!

One solution solved, now just need the object finding borders to be fixed.


Reply With Quote
(#6)
Old
Frement's Avatar
Frement Frement is offline
SRL Member
SRL Old Timer SRL Useful poster
King Black Dragon
Frement has a spectacular aura aboutFrement has a spectacular aura about
 
Activity Longevity
13/20 13/20
Today Posts
2/5 sssss1279
Send a message via MSN to Frement Send a message via Skype™ to Frement
Default 07-30-2010, 02:05 AM

One more thing, I modified it to support hits if they go into the bars way (red hit and blue hit).

SCAR Code:
function F_InFight: Boolean;
var GTPA, RTPA, BTPA, OTPA: TPointArray;
begin
  FindColorsTolerance(GTPA, 49763, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
  FindColorsTolerance(RTPA, 590010, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
  FindColorsTolerance(BTPA, 16097813, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
  FindColorsTolerance(OTPA, 1518036, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
  Result := ((GetArrayLength(GTPA)+GetArrayLength(RTPA)+GetArrayLength(BTPA)+GetArrayLength(OTPA)) >= 35);
end;


My scripts: Monk of Zamorak Abuser
" There are no classes in life for beginners: right away you are always asked to deal with what is most difficult.
"
My Site: http://www.frement.net/



Reply With Quote
(#7)
Old
EvilChicken!'s Avatar
EvilChicken! EvilChicken! is offline
Super Moderator & SRL Dev
SRL Old Timer SRL Valued Voter SRL Useful posterSRL ScripterSRL DeveloperModerator
Tormented Demon
EvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of light
 
Activity Longevity
18/20 14/20
Today Posts
5/5 sssss1485
Send a message via MSN to EvilChicken!
Default 07-30-2010, 04:28 PM

SCAR Code:
const
  MS_HEALTH_GREEN = 49763;
  MS_HEALTH_RED    = 590010;
  MS_HIT_GREEN      = 16097813;
  MS_HIT_RED         = 1518036;

function F_InFight: Boolean;
var
  TPA1, TPA2: TPointArray;
  Colors: TIntegerArray;
  I: Byte;
begin
  Colors := [MS_HEALTH_GREEN, MS_HEALTH_RED, MS_HIT_GREEN, MS_HIT_RED];
  for I := 0 to 4 do
  begin
    FindColorsTolerance(TPA1, Colors[I], MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20);
    TPA2 := CombineTPA(TPA1, TPA2);
  end;

  Result := InRange(TPA2, healthbarwidth * healthbarheight - tol, healthbarwidth * healthbarheight - tol);
end;

Quickly did this in notepad, not sure if it's excessive, but it'll probably do.. I do not have Simba here, nor SVN or anything to commit with.
healthbarwidth and healthbarheight ofcourse need to be replaced with the original values, most likely found in one of N3ss3s' functions in Fighting.scar.. unless they've changed since then? *needs confirmation* The "tol", not sure if even needed.. Does the player's health bar vary in width and height?

Other things; are you sure such a big searchbox is needed? (I wouldn't know, I'm just asking..)

Besides, check if I understood all the color values correctly, Frement. I'll test and commit when I get home.
And do remind me to commit this if I forget it, please.
Reply With Quote
(#8)
Old
Frement's Avatar
Frement Frement is offline
SRL Member
SRL Old Timer SRL Useful poster
King Black Dragon
Frement has a spectacular aura aboutFrement has a spectacular aura about
 
Activity Longevity
13/20 13/20
Today Posts
2/5 sssss1279
Send a message via MSN to Frement Send a message via Skype™ to Frement
Default 07-31-2010, 01:20 AM

Well yes, but its MS_HIT_BLUE not GREEN :P Green is for poison

Anyways, looks good actually. I used such a big box because when you hit, the bar moves a bit down and up and stuff. I don't really know if it needs to be _so_ big. I think I made it smaller in some function, I just had to find this from a thread I had posted it to. Anyways, I'll test your function and fix it up

EDIT: This seems to work just fine, fixed some compile errors etc.
SCAR Code:
const
  MS_HEALTH_GREEN  = 49763;
  MS_HEALTH_RED    = 590010;
  MS_HIT_BLUE      = 16097813;
  MS_HIT_RED       = 1518036;

function F_InFight: Boolean;
var
  TPA1, TPA2: TPointArray;
  Colors: TIntegerArray;
  I: Byte;
begin
  Colors := [MS_HEALTH_GREEN, MS_HEALTH_RED, MS_HIT_BLUE, MS_HIT_RED];
  for I := 0 to 3 do
  begin
    FindColorsTolerance(TPA1, Colors[I], MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 30);
    TPA2 := CombineTPA(TPA1, TPA2);
  end;

  Result := InRange(GetArrayLength(TPA2), 35, 380);
end;


My scripts: Monk of Zamorak Abuser
" There are no classes in life for beginners: right away you are always asked to deal with what is most difficult.
"
My Site: http://www.frement.net/




Last edited by Frement; 07-31-2010 at 01:40 AM.
Reply With Quote
(#9)
Old
Coh3n's Avatar
Coh3n Coh3n is offline
MSI Leader
MSI ContributorSRL Old Timer SRL Valued Voter SRL Useful posterSRL HelperSRL Tutorial WriterSRL ScripterSRL DeveloperModerator
Tormented Demon
Coh3n has disabled reputation
 
Activity Longevity
19/20 11/20
Today Posts
3/5 sssss5004
Default 07-31-2010, 03:35 AM

Committed that version of InFight, Frement.

Mario, what object finding function are you using? They all use the mainscreen coordinates from what I can see. Also, I wouldn't suggest using them anyway. I recommend using SmartColors, they're much, much better (and easier, IMO).


_________________________________________________

T E A M
Together Everyone Achieves More

Reply With Quote
(#10)
Old
Sir R. Magician's Avatar
Sir R. Magician Sir R. Magician is offline
Jah Man
MSI ContributorSRL DonatorSRL MasterSRL DeveloperAdministrator
Corporeal Beast
Sir R. Magician is a name known to allSir R. Magician is a name known to allSir R. Magician is a name known to allSir R. Magician is a name known to allSir R. Magician is a name known to allSir R. Magician is a name known to all
 
Activity Longevity
18/20 14/20
Today Posts
1/5 sssss6235
Default 07-31-2010, 11:04 AM

Good job on the function, EC.
HealthBarWidth and HealthBarHeight could also be constants.
Or just declare them as variables and keep them at the top of the function.

~RM



If knowledge can create problems, it is not through ignorance that we can solve them.
MSI is Everyone, Everyone is MSI
Reply With Quote
(#11)
Old
EvilChicken!'s Avatar
EvilChicken! EvilChicken! is offline
Super Moderator & SRL Dev
SRL Old Timer SRL Valued Voter SRL Useful posterSRL ScripterSRL DeveloperModerator
Tormented Demon
EvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of light
 
Activity Longevity
18/20 14/20
Today Posts
5/5 sssss1485
Send a message via MSN to EvilChicken!
Default 07-31-2010, 05:18 PM

Guys, thanks for your responses. And for committing it, Coh3n -- but I had slightly greater plans in mind for this, considering this function might be more accurate than FindFight in /core/AntiRandoms/AntiRandoms.scar. Any thoughts on that?
Reply With Quote
(#12)
Old
Sir R. Magician's Avatar
Sir R. Magician Sir R. Magician is offline
Jah Man
MSI ContributorSRL DonatorSRL MasterSRL DeveloperAdministrator
Corporeal Beast
Sir R. Magician is a name known to allSir R. Magician is a name known to allSir R. Magician is a name known to allSir R. Magician is a name known to allSir R. Magician is a name known to allSir R. Magician is a name known to all
 
Activity Longevity
18/20 14/20
Today Posts
1/5 sssss6235
Default 07-31-2010, 05:21 PM

Quote:
Originally Posted by EvilChicken! View Post
Guys, thanks for your responses. And for committing it, Coh3n -- but I had slightly greater plans in mind for this, considering this function might be more accurate than FindFight in /core/AntiRandoms/AntiRandoms.scar. Any thoughts on that?
Make it all just one function. The one in Antirandoms is in the core, so make that one good. Then for now, just wrap the one in Fighting.scar. That'll avoid code repetition and it'll ensure that both have a good function to use.

~RM



If knowledge can create problems, it is not through ignorance that we can solve them.
MSI is Everyone, Everyone is MSI
Reply With Quote
(#13)
Old
EvilChicken!'s Avatar
EvilChicken! EvilChicken! is offline
Super Moderator & SRL Dev
SRL Old Timer SRL Valued Voter SRL Useful posterSRL ScripterSRL DeveloperModerator
Tormented Demon
EvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of light
 
Activity Longevity
18/20 14/20
Today Posts
5/5 sssss1485
Send a message via MSN to EvilChicken!
Default 07-31-2010, 05:38 PM

Like this?:

SCAR Code:
const
  MS_HEALTH_GREEN  = 49763;
  MS_HEALTH_RED    = 590010;
  MS_HIT_BLUE      = 16097813;
  MS_HIT_RED       = 1518036;

function InFight: Boolean;
var
  TPA1, TPA2: TPointArray;
  Colors: TIntegerArray;
  I: Byte;
begin
  Colors := [MS_HEALTH_GREEN, MS_HEALTH_RED, MS_HIT_BLUE, MS_HIT_RED];
  for I := 0 to 3 do
  begin
    FindColorsTolerance(TPA1, Colors[I], MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 30);
    TPA2 := CombineTPA(TPA1, TPA2);
  end;

  Result := InRange(GetArrayLength(TPA2), 35, 380); // SEE "NOTE" REGARDING THIS LINE!
end;

function FindFight: Boolean;
begin
  Result := False;
  if (not LoggedIn) then exit;

  if (InFight) then
  begin
    if (CheckHpFirst) and (HpPercent = 100) then exit;

    Result := True;
    AddToSRLLog('******** FOUND FIGHTING RANDOM ********');
    WriteLn('******** FOUND FIGHTING RANDOM ********');
    TakeScreen('Found Fight');
    Inc(RandSolved[rand_Fight]);
  end;
end;
^That would all be placed in /AntiRandoms/AntiRandoms.scar. And, this would also requre removal of InFight from /skill/Fighting.scar.

The problem, if existent, is that I don't know how well it's been tested.

And, Cazax's function FindAllHPBars (quite nifty function, actually) uses constant bar widths and heights, 55 and 7. Someone needs to check whether health bars still have those widths and heights, and whether they still are constant. (Which I believe they most likely will be.)

And, if they really are constant, maximum accuracy would be achieved by altering the "SEE NOTE REGARDING THIS LINE"-line of the mentioned function into comparing lengths of the result TPA with the constant bar width * height, and also adding a little tolerance to the result, since I believe the numbers inside the red/blue damage indicator aren't counted as part of the result in the function?
Reply With Quote
(#14)
Old
Coh3n's Avatar
Coh3n Coh3n is offline
MSI Leader
MSI ContributorSRL Old Timer SRL Valued Voter SRL Useful posterSRL HelperSRL Tutorial WriterSRL ScripterSRL DeveloperModerator
Tormented Demon
Coh3n has disabled reputation
 
Activity Longevity
19/20 11/20
Today Posts
3/5 sssss5004
Default 07-31-2010, 05:38 PM

Quote:
Originally Posted by EvilChicken! View Post
Guys, thanks for your responses. And for committing it, Coh3n -- but I had slightly greater plans in mind for this, considering this function might be more accurate than FindFight in /core/AntiRandoms/AntiRandoms.scar. Any thoughts on that?
Yeah I figured you might. I just committed so there was something that worked until you got the chance to do what you want with it.


_________________________________________________

T E A M
Together Everyone Achieves More

Reply With Quote
(#15)
Old
mariofan12's Avatar
mariofan12 mariofan12 is offline
SRL Member
SRL Old Timer
Chicken
mariofan12 is on a distinguished road
 
Activity Longevity
0/20 10/20
Today Posts
0/5 ssssss141
Default 07-31-2010, 06:08 PM

Quote:
Originally Posted by Coh3n View Post
Committed that version of InFight, Frement.

Mario, what object finding function are you using? They all use the mainscreen coordinates from what I can see. Also, I wouldn't suggest using them anyway. I recommend using SmartColors, they're much, much better (and easier, IMO).
I was using whatever FightNPC used, which was FindObjCustom. And I thought it used them as well, but my mouse would go outside the border by about 10 pixels because I was searching for a similar color on a cow

Maybe make the FightNPC use SmartColors? I may make a modified version of that in my script until otherwise.


Reply With Quote
(#16)
Old
Frement's Avatar
Frement Frement is offline
SRL Member
SRL Old Timer SRL Useful poster
King Black Dragon
Frement has a spectacular aura aboutFrement has a spectacular aura about
 
Activity Longevity
13/20 13/20
Today Posts
2/5 sssss1279
Send a message via MSN to Frement Send a message via Skype™ to Frement
Default 07-31-2010, 06:53 PM

I also had some ideas for the InFight function, but I haven't investigated yet if my idea will work.

EDIT: The height and width btw:
SCAR Code:
HP_BAR_WIDTH = 56;
HP_BAR_HEIGHT = 7;
EDIT2: And thats with the border.


My scripts: Monk of Zamorak Abuser
" There are no classes in life for beginners: right away you are always asked to deal with what is most difficult.
"
My Site: http://www.frement.net/




Last edited by Frement; 07-31-2010 at 07:00 PM.
Reply With Quote
(#17)
Old
EvilChicken!'s Avatar
EvilChicken! EvilChicken! is offline
Super Moderator & SRL Dev
SRL Old Timer SRL Valued Voter SRL Useful posterSRL ScripterSRL DeveloperModerator
Tormented Demon
EvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of light
 
Activity Longevity
18/20 14/20
Today Posts
5/5 sssss1485
Send a message via MSN to EvilChicken!
Default 07-31-2010, 07:24 PM

Quote:
Originally Posted by Frement View Post
I also had some ideas for the InFight function, but I haven't investigated yet if my idea will work.
Post it! I'll wait a bit before committing this, for people to test this and come with more input. I'll add a [FEEDBACK] tag to this thread.

Quote:
Originally Posted by Frement View Post
EDIT: The height and width btw:
SCAR Code:
HP_BAR_WIDTH = 56;
HP_BAR_HEIGHT = 7;
EDIT2: And thats with the border.
So it would be 54 * 5 without the borders? (Assuming the borders are 1px wide..) Only the area containing the colors is needed.
By the way, size is static, right?

EDIT: mariofan12, I'm really sorry to be hijacking your thread. >_<
As mentioned, try SmartColors in /misc/ ..
.. or FindObjTPA in Object.scar.

Last edited by EvilChicken!; 07-31-2010 at 07:26 PM.
Reply With Quote
(#18)
Old
Frement's Avatar
Frement Frement is offline
SRL Member
SRL Old Timer SRL Useful poster
King Black Dragon
Frement has a spectacular aura aboutFrement has a spectacular aura about
 
Activity Longevity
13/20 13/20
Today Posts
2/5 sssss1279
Send a message via MSN to Frement Send a message via Skype™ to Frement
Default 07-31-2010, 07:25 PM

Quote:
Originally Posted by EvilChicken! View Post
So it would be 54 * 5 without the borders? (Assuming the borders are 1px wide..) Only the area containing the colors is needed.
By the way, size is static, right?
Yes.

EDIT: Btw, the actual formula for calculating the min/max would be.

Min: HP_BAR_WIDTH * HP_BAR_HEIGHT / 7 - TOL;
Max: HP_BAR_WIDTH * HP_BAR_HEIGHT + TOL;

Because the function does return like 38+ values everytime, and sometimes just a bit lower then 300.

EDIT2: I edited the function a bit to give more accurate results, however this was not what was in my mind, I haven't gotten into that yet
SCAR Code:
var
  HP_BAR_GREEN, HP_BAR_RED: TIntegerArray;
  HP_BAR_MIN, HP_BAR_MAX: Integer;
  HP_BAR_DECLARED: Boolean;

const
  HP_BAR_TOL = 3;
  HP_BAR_WIDTH = 57;
  HP_BAR_HEIGHT = 7;

procedure DeclareHPBar;
begin
  if not (HP_BAR_DECLARED) then
  begin
    HP_BAR_GREEN := [49499, 52611, 51081, 52641, 47667];
    HP_BAR_RED := [590010, 590002, 131211, 524453, 594402];
    HP_BAR_MIN := HP_BAR_WIDTH * HP_BAR_HEIGHT / 10 - HP_BAR_TOL;
    HP_BAR_MAX := HP_BAR_WIDTH * HP_BAR_HEIGHT * 3 / 2 + HP_BAR_TOL;
    HP_BAR_DECLARED := True;
  end;
end;

function F_InFight: Boolean;
var
  TPA1, TPA2: TPointArray;
  Colors: T2DIntegerArray;
  I, C: Integer;
begin
  DeclareHPBar;
  Colors := [HP_BAR_GREEN, HP_BAR_RED];
  for I := 0 to 1 do
  begin
    for C := 0 to High(Colors[I]) do
    begin
      FindColorsTolerance(TPA1, Colors[I][C], MSCX - 25, MSCY - 40, MSCX + 25, MSCY - 15, 30);
      TPA2 := CombineTPA(TPA1, TPA2);
    end;
  end;
  Result := InRange(GetArrayLength(TPA2), HP_BAR_MIN, HP_BAR_MAX);
end;


My scripts: Monk of Zamorak Abuser
" There are no classes in life for beginners: right away you are always asked to deal with what is most difficult.
"
My Site: http://www.frement.net/




Last edited by Frement; 07-31-2010 at 09:40 PM.
Reply With Quote
(#19)
Old
EvilChicken!'s Avatar
EvilChicken! EvilChicken! is offline
Super Moderator & SRL Dev
SRL Old Timer SRL Valued Voter SRL Useful posterSRL ScripterSRL DeveloperModerator
Tormented Demon
EvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of lightEvilChicken! is a glorious beacon of light
 
Activity Longevity
18/20 14/20
Today Posts
5/5 sssss1485
Send a message via MSN to EvilChicken!
Default 08-05-2010, 11:28 PM

I believe we can call this resolved and committed?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com