SRL Archive - OSR Help

DTM (smaller dtm's)


Le Jingle

2012-06-09 23:57:28

Hello, I have a question regarding DTM's and differentiating them when given a small amount of pixels to choose from / use.

Since arrows are generally differentiated by the color in their arrow tips, would a DTM be useful in this case? Especially since the arrow heads are not touching all the time and have such a small amount of pixels within their heads.

What would be a more efficient alternate that would help find specific arrows versus their counterpart types (i.e. iron vs. steel) and being able to count how many arrows (1, 2, 3, 4, or 5+) are in the stack of them self?

E: Also, when poison arrows come into play, would you change your method?

Runaway

2012-06-10 00:04:48

You can still use a DTM. Just grab the main color of the arrow head and then a few of the black outline points. If you don't need to differentiate between iron, steel, etc. check out the FilterTPASegment function in my signature.

As for counting, there's a function for that. Something like CountItems. I'm not entirely sure though, can't check right now.

Edit: I'm assuming that the shape of the arrowhead(s) doesn't change (or at least one of them doesn't) when you go from 1 to 2, 3, etc. I haven't used arrows in a while :p

Hazzah

2012-06-10 00:12:51

Umm, I think I would make a DTM for an arrow (a single arrow only!) by choosing the main color to be its head and then set the rest of the points as the black outline.

I just tested this on rune arrows with the main point in the center of the head and selecting portions of the black outline and it found them from 1-4, and then 36. I have Zammy arrows in my in and the bank and it didnt find either of those. As a note, single arrows seem to be shaped slightly different when they are in the bank than when they are in the inventory.

Le Jingle

2012-06-10 01:39:44

My problem resides with picking a reliable DTM, if I am to use that to count the items in the found DTM slot, for example:


The short DTM I made, when searching across all of the arrows comes up with the 3rd stack of arrows (the 3rd arrow stack, with 3 arrows in it). I am trying to stick to using a DTM, however I'm wary that my DTM, (i.e. the arrow above) will change (it will in color I'm sure, and I've accounted for that with tolerance) however the shape, itself is my concern.

(I suppose I am looking for a different way, because there's no generic DTM for the arrows. - I'm reading over your link suggestion as of right now too, Runaway)

Perhaps my answer lies within picking a unique DTM for each arrowhead on top of each arrow, and lowering my tolerance very very low?

litoris

2012-06-10 02:40:15

Get as many DTMs as needed and search for them all, then use the function in inventory.simba(iirc) to check the amount of arrows.

Le Jingle

2012-06-10 02:57:33

From: litoris
Get as many DTMs as needed and search for them all, then use the function in inventory.simba(iirc) to check the amount of arrows.


I am looking for a best fitting DTM. If one DTM won't work for all of them, or if one DTM won't work for each of them, then I'll probably not use a DTM for this arrow finding (unless it's an equally good/efficient method as Finding multiple DTMs). Ideally I'm trying to create one DTM value/string and store it as an integer. If I can do a begin .. end for a list of DTM's and store that as a value, I suppose this could be a last attempt.

P1ng

2012-06-10 04:46:59

Just a suggestion, have the user select a string of which arrow-type they are using at the beginning of the script and then have the correlate with an appropriate colour you have determined to be whichever type of arrow they are using. If the script then finds that colour within the inventory you can implement something along these lines

function HowManyArrows: integer;
var
x,y,ArrowHead,tolerance: integer;
begin
if FindColorTolerance(x,y,ArrowHead,MIX1,MIY1,MIX2,MIY2,tolerance) then
begin
Result := GetAmountBox(InvBox(CoordsToItem(x,y)));
Exit;
end else
Result := 0;
Exit;
// We have no arrows of that type in inventory
end;

bolshak25

2012-06-10 12:46:41

i would do a dtm with the top color, then part of the brown shaft but it has to be really close, and id suggest it should be almost straight up and down. then use
function FindDTM(item : integer) : boolean;
var
itemBox : TBox;
Text,Text1,Text2,Text3,DTM : integer;
begin
itemBox := InvBox(item);
DTM := DTMFromString('mrAAAAHic42BgYJjKxMAwAYgnA/EMIJ4NxBOBeD4QLwViFkYIZgBiRiibA4jZoPT6mp0ME9JmMBQElDO0xfeC+etmb2KYlj2fYcXUNQz8QK34MCMBDAMAxeMTBw==');
Result := FindDTM(DTM, x, y, ItemBox.x1, itemBox.y1, ItemBox.x2, ItemBox.y2);
FreeDTM(DTM);
end;

for i := 1 to 28 do
begin
if FindDTM(i) then
begin
Text := GetTextAtExWrap(560,210,596,222,0,0,0,65535,5,'StatChars');
If (Text<>'') Then
begin
Text1 := Replace(Text,' ','');
Text2 := Replace(Text1,'?','7');
Text3 := Replace(Text2,'K','000');
end else
begin
Text3 := '0';
end;
break;
end;
end;

the bottom function youd have to find a way to change where that counts, unless the arrows will alwasy be in a certain slot, then you could ignore finding where they are, and just count them

Le Jingle

2012-06-10 19:11:22

From: bolshak25
i would do a dtm with the top color, then part of the brown shaft but it has to be really close, and id suggest it should be almost straight up and down.



Ahh thanks, I kept trying to grab as many points as I could, which just made things messy for me; but I've made 2 simple DTM's that locate the arrows in all sizes (stacked from 1 - 5). And I'll keep in mind of the arrow counting, but for now I'll stick to making more accurate arrow heads, for just a little project I've got going :p