SRL Archive - General

DTM from this?


mr. pali

2012-12-12 01:23:38

[RESOLVED]
Hey so I think I have the general idea of DTMs down…
I'm trying to make an InCombat():Boolean; function for my fighter script.

I have it so it looks for the last sliver of the health bar on the combat tab, but sometimes the monster still has some health left when it appears there is no green.

I need a DTM that would match up with this and only this. keep in mind sometimes it will still have the text saying 'no target' although it is attacking something, has a green health bar, and a logo in the circle etc.

so the DTM needs to specifically identify with the following image ONLY:

http://imgur.com/Cfc6H

what would be an efficient way to create this DTM? Can someone give me an example of a working DTM for this?

thanks


edit: here's what it looks like in combat http://imgur.com/lmANE. It needs to differentiate from something like this.

P1ng

2012-12-12 01:30:44

I would recommend trying the text OCR in simba rather than a DTM for this particular case and just have something like -

function InCombat: Boolean;
var
x, y: Integer;
begin
Result := not(FindText(x, y, 'arget', 'UpCharsEx', MIx1, MIy1, MIx2, MIy2));
end;

That way it is "InCombat" when it doesn't find the text 'arget' which is just shorter and more reliable than searching for 'No Target'. The font is just a guess, I have no idea you would need to check it out to find which font that actually is. But the co-ords are correct

mr. pali

2012-12-12 01:34:42

From: P1ng
I would recommend trying the text OCR in simba rather than a DTM for this particular case and just have something like -

function InCombat: Boolean;
var
x, y: Integer;
begin
Result := not(FindText(x, y, 'arget', 'UpCharsEx', MIx1, MIy1, MIx2, MIy2));
end;

That way it is "InCombat" when it doesn't find the text 'arget' which is just shorter and more reliable than searching for 'No Target'. The font is just a guess, I have no idea you would need to check it out to find which font that actually is. But the co-ords are correct


What are the MI coords constants for? What does MI stand for? MenuInterface? I assume its refering to the menu in the bottom right.

Thanks

P1ng

2012-12-12 01:41:16

Main Inventory, I guess? Idk, either way they are the co-ords for the inventory

mr. pali

2012-12-12 01:42:34

From: P1ng
Main Inventory, I guess? Idk, either way they are the co-ords for the inventory



Cool, thanks.


Does anyone know which font it is in the pictures i posted?

Thanks!!

-pali


Edited:
So, I tested it with every font included in my fonts folder. Am I missing any somewhere else in my folders that I didn't see?

Also, isn't DTM searching more efficient computationally than looking for text? Wouldn't a DTM be better here??

thanks

pali

P1ng

2012-12-12 02:16:04

Well then you could make a DTM of the text given the colours of the writing wouldn't change much if at all so you would need minimal tolerance. Your function would then look like this -

function InCombat: Boolean;
var
No_Target, x, y: Integer;
begin
No_Target := DTMFromString('mVAEAAHicE2BgYLjCCMF3gPg5EL8C4s9A/AWIvwPxLyD+B8SMTBDMBsSsQMwDxfFAMyKAOAZKx0NxNBDHAnEUlJ8AZcP4ILVxQLy5So8izAo0gxLMSCFGBwBXxiVK');
Result := not(FindDTM(No_Target, x, y, MIx1, MIy1, MIx2, MIy2));
FreeDTM(No_Target);
end;

DTM used is actually made from the text that you showed in the picture, so this should even work

mr. pali

2012-12-12 02:37:36

From: P1ng
Well then you could make a DTM of the text given the colours of the writing wouldn't change much if at all so you would need minimal tolerance. Your function would then look like this -

function InCombat: Boolean;
var
No_Target, x, y: Integer;
begin
No_Target := DTMFromString('mVAEAAHicE2BgYLjCCMF3gPg5EL8C4s9A/AWIvwPxLyD+B8SMTBDMBsSsQMwDxfFAMyKAOAZKx0NxNBDHAnEUlJ8AZcP4ILVxQLy5So8izAo0gxLMSCFGBwBXxiVK');
Result := not(FindDTM(No_Target, x, y, MIx1, MIy1, MIx2, MIy2));
FreeDTM(No_Target);
end;

DTM used is actually made from the text that you showed in the picture, so this should even work




Thanks, that worked. Here's a complete working function.

Function InCombat() : boolean;
var x,y, No_Target : integer;
begin;
if not (GetCurrentTab = tab_Combat) then
begin
GameTab(tab_Combat);
end;
No_Target := DTMFromString('mVAEAAHicE2BgYLjCCMF3gPg5EL8C4s9A/AWIvwPxLyD+B8SMTBDMBsSsQMwDxfFAMyKAOAZKx0NxNBDHAnEUlJ8AZcP4ILVxQLy5So8izAo0gxLMSCFGBwBXxiVK');
Result := not(FindDTM(No_Target, x, y, MIx1, MIy1, MIx2, MIy2));
FreeDTM(No_Target);
end;

DannyRS

2012-12-12 02:52:01

Just a tip, in any final use of this, be sure to declare and free the DTM outside that function and only once, speeds things up alot, and also use AddOnTerminate to free the DTM :)

mr. pali

2012-12-12 02:53:32

From: DannyRS
Just a tip, in any final use of this, be sure to declare and free the DTM outside that function and only once, speeds things up alot, and also use AddOnTerminate to free the DTM :)




Can you post an example? I understand declaring it in the public variables, and then once on startup.

But how do I make sure it is freed when the script is terminated?

Thanks

DannyRS

2012-12-12 02:55:58

From: mr. pali
Can you post an example? I understand declaring it in the public variables, and then once on startup.

But how do I make sure it is freed when the script is terminated?

Thanks


On phone, but something like this,



//global integer
Var MyDTM: Integer;

//add all dtms that you use in a free function
Procedure FreeMyDTM;
Begin

FreeDTM(MyDTM);

End;

//call setup as your first things in script at the bottom
Procedure Setup;
Begin

MyDTM:= whatever;
AddonTerminate("FreeMyDTM");

End;


Im sure its addonterminate, but might be something simular, does that compile?

mr. pali

2012-12-12 15:51:32

Yea it works, thanks Danny!

It calls for a string. so you just put the name of the method you want to call in the paramaters and that procedure will be called when the script terminates.

program example1;
var
DTM_VAR : integer;

procedure FreeDTMS();
begin
FreeDtm(DTM_VAR);
end;

begin
DTM_VAR := DTMFromString('sdfsdfsdf');
AddOnTerminate('FreeDTMS');
end.

euphemism

2012-12-12 20:02:06

Correct me if I'm wrong, but could you not just use GetColor on a point in that last column of pixels where the green shows up and see if there is any green there?

P1ng

2012-12-13 02:43:42

@euph - He stated in the OP that sometimes when the NPC has really low health points there will be no green displayed in the bar while you are still in combat with them. Thus your method not working

euphemism

2012-12-13 10:56:59

From: P1ng
@euph - He stated in the OP that sometimes when the NPC has really low health points there will be no green displayed in the bar while you are still in combat with them. Thus your method not working


Okay, then grab the colors at the two or three points you would otherwise use for a DTM. You don't have to worry about where to load a DTM, and it should be faster.

Google

2012-12-13 11:03:47

I haven't gone on in a few days but when the target dies doesn't it take around 7 seconds for no target to appear?

mr. pali

2012-12-15 18:28:01

From: Google
I haven't gone on in a few days but when the target dies doesn't it take around 7 seconds for no target to appear?


no, it's instant.