|
|
| Suggestions Any suggestions on new additions to SRL or changes to SRL go here. |
 |
SRL Member
Chicken
|
|
Posts: 141
Join Date: Jul 2008
|
|
|
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.
|
 |
SRL Member
King Black Dragon
|
|
Posts: 1,279
Join Date: Nov 2007
Location: 46696E6C616E64
|
|
|

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;
|
 |
SRL Member
Chicken
|
|
Posts: 141
Join Date: Jul 2008
|
|
|

07-30-2010, 01:42 AM
Tested your function in a loop of 10 while fighting a cow, all 10 loops came back false
|
 |
SRL Member
King Black Dragon
|
|
Posts: 1,279
Join Date: Nov 2007
Location: 46696E6C616E64
|
|
|

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.
Last edited by Frement; 07-30-2010 at 01:53 AM.
|
 |
SRL Member
Chicken
|
|
Posts: 141
Join Date: Jul 2008
|
|
|

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.
|
 |
SRL Member
King Black Dragon
|
|
Posts: 1,279
Join Date: Nov 2007
Location: 46696E6C616E64
|
|
|

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;
|
 |
Super Moderator & SRL Dev
Tormented Demon
|
|
Posts: 1,485
Join Date: Jul 2007
Location: Norway.
|
|
|

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.
|
 |
SRL Member
King Black Dragon
|
|
Posts: 1,279
Join Date: Nov 2007
Location: 46696E6C616E64
|
|
|

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;
Last edited by Frement; 07-31-2010 at 01:40 AM.
|
 |
MSI Leader
Tormented Demon
|
|
Posts: 5,004
Join Date: Apr 2008
Location: Ontario, Canada
|
|
|

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
|
 |
Jah Man
Corporeal Beast
|
|
Posts: 6,235
Join Date: Jul 2007
Location: Right now? Chair.
|
|
|

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
|
 |
Super Moderator & SRL Dev
Tormented Demon
|
|
Posts: 1,485
Join Date: Jul 2007
Location: Norway.
|
|
|

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?
|
 |
Jah Man
Corporeal Beast
|
|
Posts: 6,235
Join Date: Jul 2007
Location: Right now? Chair.
|
|
|

07-31-2010, 05:21 PM
Quote:
Originally Posted by EvilChicken!
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
|
 |
Super Moderator & SRL Dev
Tormented Demon
|
|
Posts: 1,485
Join Date: Jul 2007
Location: Norway.
|
|
|

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?
|
 |
MSI Leader
Tormented Demon
|
|
Posts: 5,004
Join Date: Apr 2008
Location: Ontario, Canada
|
|
|

07-31-2010, 05:38 PM
Quote:
Originally Posted by EvilChicken!
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
|
 |
SRL Member
Chicken
|
|
Posts: 141
Join Date: Jul 2008
|
|
|

07-31-2010, 06:08 PM
Quote:
Originally Posted by Coh3n
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.
|
 |
SRL Member
King Black Dragon
|
|
Posts: 1,279
Join Date: Nov 2007
Location: 46696E6C616E64
|
|
|

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.
Last edited by Frement; 07-31-2010 at 07:00 PM.
|
 |
Super Moderator & SRL Dev
Tormented Demon
|
|
Posts: 1,485
Join Date: Jul 2007
Location: Norway.
|
|
|

07-31-2010, 07:24 PM
Quote:
Originally Posted by Frement
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
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.
|
 |
SRL Member
King Black Dragon
|
|
Posts: 1,279
Join Date: Nov 2007
Location: 46696E6C616E64
|
|
|

07-31-2010, 07:25 PM
Quote:
Originally Posted by EvilChicken!
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;
Last edited by Frement; 07-31-2010 at 09:40 PM.
|
 |
Super Moderator & SRL Dev
Tormented Demon
|
|
Posts: 1,485
Join Date: Jul 2007
Location: Norway.
|
|
|

08-05-2010, 11:28 PM
I believe we can call this resolved and committed?
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Powered by vBulletin® Version 3.8.4 Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com
|