Trollcrank
2014-11-05 17:36:26
I could also use some help making the finished product
Edit: The combat part is done I just need some help deciding the finding object method and then someone to revise it after I make it.
2014-11-05 17:36:26
2014-11-05 17:53:59
From: Trollcrank
I need a good way to determine when my character is in combat in the most optimized, fewer lines the better, way possible. I've thought of using player animation, limiting the search range and using color to determine if the opposition is still alive with a repeat, and I'm not sure what would be the best way to execute such a task.
2014-11-05 17:58:04
From: 3Garrett3
You could lock the combat bar (health bar whatever) in the top left corner of the screen and then only search for a given colour of the box in the top corner. That would take one line "Result := GetColor(blah)". It's way more efficient and fool-proof than searching all over the screen (or if magic/range, off screen) for the box.
2014-11-05 18:08:38
///////////////////////////////////
///////////////////////////////////
/////// Combat detection ///////
///////////////////////////////////
///////////////////////////////////
function hasTargeted():boolean;
var
tpa:TPointArray;
i:integer;
begin
result := findColorsTolerance(tpa, redCircle.col, redCircle.area, redCircle.tol, redCircle.cts);
//smartImage.debugTpa(tpa);
end;
function hasBeenTargeted():boolean;
var
tpa:TPointArray;
begin
result := findColorsTolerance(tpa, yellowCircle.col, yellowCircle.area, yellowCircle.tol, yellowCircle.cts);
end;
function waitForTarget():boolean;
var
t:TTimeMarker
begin
result := false;
minimap.waitPlayerMoving();
t.start();
repeat
wait(randomRange(250, 500));
until (hasTargeted()) or (t.getTime() > maxWait);
t.pause();
if (hasTargeted()) then
result := true;
if (result) then
writeDebug('Target acquired in ' + toStr(t.getTime()) + ' ms');
end; function getFightLocation():TBox;
var
tpa:TPointArray;
begin
if not (hasTargeted()) then
exit;
if findColorsTolerance(tpa, redCircle.col, mainScreen.getBounds(), redCircle.tol, redCircle.cts) then
result := getTpaBounds(tpa);
if not (disableDrawing) then
smartImage.drawBox(result, false, clYellow); //draw it
writeDebug('Player is in combat with NPC at ' + toStr(result));
end; 2014-11-05 18:26:02
From: KeepBotting
E: Just remembered I have a video of it working: https://www.youtube.com/watch?v=ugTypL48hYM
Ignore how slow and inaccurate it is in that video lol it's only meant to show combat detection
function Fighting: boolean;
begin
result := (getColor(61, 43) = 379903);
end; //x, y? //Color?
EDIT: So apperanlty there is a ring around enemies that I somehow managed to ignore…Still, the getColors seems like a better option.
2014-11-05 18:35:46
From: Trollcrank
Your INSTA-KILLED & BANNED BY A JMOD! was an amazing video, it made me a little sad on the inside though. Also, the red crosshairs seems to be a less accurate and more line consuming process then the Result:= Getcolor..blah
So what exactly do the numbers mean in Getcolor?EDIT: So apperanlty there is a ring around enemies that I somehow managed to ignore…Still, the getColors seems like a better option.
function Fighting: boolean;
begin
result := (getColor(61, 43) = 379903);
end; //x, y? //Color?
2014-11-05 18:43:36
From: KeepBotting
Thanks :P
Yeah you've got the getColor params right.
If you plan on looting you'll still need to scrape the mainscreen anyway, to get the location of the fight
2014-11-05 18:52:05
From: Trollcrank
No looting, I'm participating in the competition of the 250 line script and there simply won't be enough lines to add all the good stuff like looting. I could have chosen an easier script to make but I wanted one that I would use afterwards, in case I lose, and I feel like I have a better shot with a harder script.
function hasTargeted():boolean;
var
tpa:TPointArray;
i:integer;
begin
result := findColorsTolerance(tpa, hardcode the other params);
end;2014-11-05 18:59:05
From: KeepBotting
Ohhh I see.
In that case, still using the mainscreen method:function hasTargeted():boolean;
var
tpa:TPointArray;
i:integer;
begin
result := findColorsTolerance(tpa, hardcode the other params);
end;
should do the trick
function Fighting: boolean; //Determines if fighting.
begin
result := (getColor(33, 12) = 1675987);
end;
2014-11-05 19:06:33
From: KeepBotting
Thanks :P
Yeah you've got the getColor params right. First two are the x,y of the pixel you want, last one is the color.
personally I haven't the faintest idea what Garrett was talking about with health bars and such. I'm sure his advice was sound but I just don't know enough about EoC combat to understand.
If you plan on looting you'll still need to scrape the mainscreen anyway, to get the location of the fight
2014-11-05 20:24:33
From: Incurable
So OP, just use the SRL function to detect fighting if there is one, then if not you can use that target info thing that Garrett is talking about.
2014-11-05 21:26:47
function ObjectFinder(bounds: string; col, tol: integer; hue, sat: extended; incSpeed, filter: boolean; mouseTxt: Array of string): boolean;
var //Custom object locater.
x, y: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
case bounds of
'ms': mainscreen.getbounds();
'tb': tabBackpack.getbounds();
'mm': minimap.getBounds();
'cb': chatbox.getBounds();
end;
findColorsSpiralTolerance(x, y, TPA, col, bounds, tol, colorSetting(2, hue, sat));
if incSpeed then
mouseSpeed := 27 + random(15);
if filter then
filterTPAsBetween(ATPA, 0, 50);
if isMouseOverText(mouseTxt) then
fastClick(MOUSE_LEFT);
end;
2014-11-05 21:29:26
From: Trollcrank
I am unaware of any in built SRL function.
Anyone wanna help me make a custom object finder? I was thinking of locating two different colors and then using the x's and y's to make a box around the object. The more I think about it, would that actually work with multiple objects though? Is the idea actually sound or should I just make a basic generic one that I've seen in a few scripts.
SetColorSpeed2Modifiers(0.05, 0.06);
FindColorsSpiralTolerance(mscx, mscy, TPA, 6255480, msx1, msy1, msx2, msy2, 9);
SetColorSpeed2Modifiers(0.06, 0.64);
FindColorsSpiralTolerance(mscx, mscy, TPA2, 4152166, msx1, msy1, msx2, msy2, 19);
TPA := CombineTPA(TPA,TPA2);
ATPA := ClusterTPA(TPA, 25);
2014-11-05 21:41:32
function isInCombat() : boolean;
var
x, y : integer;
begin
result := findDTM(weaknessDTM, x, y, intToBox(mainScreen.x1, mainscreen.y1, minimap.x2, actionBar.y2));
end;
2014-11-05 22:20:28
From: The Mayor
For the combat detection, I use a DTM of the weakness symbol (varies depending on NPC though - you might be better with the gold lock);
function isInCombat() : boolean;
var
x, y : integer;
begin
result := findDTM(weaknessDTM, x, y, intToBox(mainScreen.x1, mainscreen.y1, minimap.x2, actionBar.y2));
end;
Your object finder doesn't do what you think it does. You are still passing a string (bounds) into the findColorsSpiralTolerance function. You'd be better off passing in a TBox as a function parameter and using that directly.
function ObjectFinder(bounds: TBox; col, tol …
findColorsSpiralTolerance(x, y, TPA, col, bounds,
2014-11-05 22:41:26
var
fightDTM, endFightDTM, kills, XP, startingXP, compassMax: integer;
XPH, KPH: extended;
timeout, timeout2, compass, notification: TTimeMarker;
procedure loadDTM;
begin
fightDTM:= DTMFromString('mlwAAAHicY2dgYMhjZGBoBuJNQBwKxBZAbALEu4H4EFB+OxDvB+LDQHwciPcA8XogllBQZRAQk2YQV9YAs0WkFRn4RCTBfHyAEQ+GAgCMMAqs');;
endFightDTM := DTMFromString('mggAAAHicY2NgYAhmZGCYAsRiQNwGxPpArAHEN4Fy14D4BhA/BuJnQPwUiAXEpBnElTUYRKQVGUwFhRhshIUZZLm4GHABRhwYAgA81wkA');
end;
procedure freeData;
begin
freeDTM(fightDTM);
freeDTM(endFightDTM);
end;
function inFight: boolean;
var
x, y: integer;
begin
if not isLoggedIn then
exit;
result := (findDTM(fightDTM, x, y, mainscreen.getBounds)) and (not findDTM(endFightDTM, x, y, mainscreen.getBounds));
end;
2014-11-06 10:09:59
From: Ashaman88
procedure freeData;
begin
freeDTM(fightDTM);
freeDTM(endFightDTM);
end;
2014-11-06 10:16:10
From: Trollcrank
I saw you looking at the thread but I wasn't sure why you didn't reply. Even Justin looked at the thread O.o
What are the dtms of, what object?
2014-11-06 11:11:39
From: Ashaman88
hmm I can't remember… but i know it's the popup over the monsters head. Works regardless of what weakness they have or w/e. Granted your mouse can't be hovering over another monster while this is going on or it will think you are always in fight. I had originally based them off of bonsai's script many many many months ago
2014-11-06 11:31:05
From: 3Garrett3
Part that I bolded can be solved (I think) by having the user lock the combat box in the top left corner, which I've seen done in public scripts. It's much less unreasonable than some script setups, and it makes the script more reliable (probably). I doesn't even require any rewriting of the function itself, except if you wanted to change the searchbox from mainscreen to just the top corner area.
2014-11-07 23:54:58
From: 3Garrett3
It's much less unreasonable than some script setups
From: Ashaman88
Hmm I didn't even know about that haha! I just always have the mouse go off and stay off client after attacking (private script so i don't care if it seems bot-like hehe)
ATPA.sortFromMidPoint(mainscreen.playerPoint); 2014-11-07 23:57:21
From: Trollcrank
Either one of you want to help me improve my script before submitting it for the competition?(Not against the rules btw.) I'll send a copy to you in pm if you want to help.
I can't think of anything to move the mouse if the mouse over text is wrong. The place the script is based has a lot of similar colors and npcs with the exact same colors, so this occurs at points. It is only resolved when another npc moves close enough to be targeted instead cuz I use:ATPA.sortFromMidPoint(mainscreen.playerPoint);
For some reason it gives this error and kills the script sometimes:
Error: Access violation at line 441
Execution failed.
SRL code it's mentioning. I'm guessing it's a tbox problem with my object finder.
function TPointArray.getBounds() : TBox;
begin
result := getTPABounds(self); //line 441
end;
2014-11-08 09:50:56
From: The Mayor
Why not just loop through the ATPA until you hit a TPA with matching overText? for i := 0 to high(ATPA) do …
2014-11-08 11:14:13
From: Trollcrank
So that's what that does… I knew you could repeat like that, with an integer, but I didn't know what high(ATPA) did.
Would that fix the crashing problem? Or should I just test it?
2014-11-08 11:49:12
From: 3Garrett3
Do you have a check for the TPA length in your function? It sounds like it's trying to access an index ([0, 1 etc]) that doesn't exist. If your TPA returns 0 points, then your ATPA will have no points, and you can't do anything with it.