View Full Version : Creating Accurate DTMs

04-19-2011, 09:31 PM
This tutorial will teach you how to make and find proper DTMs. By a "Proper DTM", I mean a DTM that is highly accurate. It's difficult to explain, so I'll just show you!

Step 1: Gathering Colors
I'm making 5 DTMs for a script right now. Here's a picture of my inventory:
I need to make a DTM for each of these Items. Instead of just opening up the DTM Editor, I'm going to write a simple script that will gather colors from the same point on each time i run the script, and write them in the debug box. Here's what I came up with:
program Col;
{$i SRL\SRL.scar}

Cols: TIntegerArray;
OutPut: string;

VoW = 0;
Ranarr = 1;
UnfPot = 2;
Snape = 3;
PPot = 4;

SetLength(Cols, 5);
Cols[VoW] := GetColor(580, 234);
Cols[Ranarr] := GetColor(582, 262);
Cols[UnfPot] := GetColor(580, 306);
Cols[Snape] := GetColor(582, 334);
Cols[PPot] := GetColor(579, 379);
OutPut := '[';
OutPut := OutPut + 'VoW: ' + ToStr(Cols[VoW]) + '; ';
OutPut := OutPut + 'Ranarr: ' + ToStr(Cols[Ranarr]) + '; ';
OutPut := OutPut + 'UnfPot: ' + ToStr(Cols[UnfPot]) + '; ';
OutPut := OutPut + 'Snape: ' + ToStr(Cols[Snape]) + '; ';
OutPut := OutPut + 'PPot: ' + ToStr(Cols[PPot]);
OutPut := OutPut + ']';

Now, I'm going to refresh the client and run this script while logged in several times, keeping all of the output in a text file. I do this because of the color randomness that runescape has - every time the client is loaded, all the colors are slightly different. While it's almost unnoticable to the human eye, it can fuss up our bots. While simply picking a point and setting a high tolerance can work, it can be more accurate. For example, the vial of water and Unfinished ranarr potions I'm making DTMs for could be mistaken for eachother if I set the tolerance too high. So, I'll refresh the client several times and note down all of the output in a text file.
Here's what I came up with:

[VoW: 10186344; Ranarr: 807987; UnfPot: 8228988; Snape: 3758861; PPot: 8959544]
[VoW: 10252137; Ranarr: 808244; UnfPot: 8294525; Snape: 3824653; PPot: 9025337]
[VoW: 10186601; Ranarr: 808243; UnfPot: 8228989; Snape: 3824397; PPot: 9025081]
[VoW: 10186601; Ranarr: 808244; UnfPot: 8228989; Snape: 3824653; PPot: 9025337]
[VoW: 10186601; Ranarr: 808244; UnfPot: 8228989; Snape: 3824653; PPot: 9025337]
N.B.: Be sure and press "S" while RS is loading to run RS in Safe Mode!

Step 2: Calculating what color to use
There are 2 ways to calculate what colors we need to use based on our findings: AutoColor Aid, or the functions within color.scar in SRL. I'll go over both of these methods.

Method 1: ACA
AutoColor Aid, a WONDERFUL application written by Nielsie95 and Sumillion, can be found in the SRL Repo - it is not included with the version downloaded by the Simba extension. Get it here - http://villavu.com/repositories/srl-opendev/Scripting%20Tools/

Now that you have ACA, let's show you how to input colors.
First, Go to Colors>Add color
Or press Ctrl+Alt+A

This brings up this window:
Make sure "Color32" is selected as your color type. Copy and paste your color into the "Color" feild, then click Add Color. Do this for each color, and you'll end up with something like this:
The information that I've highlighted with a red box is what you're after. Based on the colors we've given ACA, the best color to find our Vial of Water is 10252137 with a tolerance of 2. Now, do this for each of the DTMs you want to make.

Method 2: color.scar
First off, a big thanks to Nava2 for his work on color.scar - many of those functions have come in handy for me. Now, the primary function we'll be using is GetBestcolor.

{************************************************* ******************************
function GetBestColor(Colors: TIntegerArray; CTS: Integer; var Tol: Integer; var Speed2Modifiers: TExtendedArray): Integer;
by: Nava2
Description: Gets the best colour to find as well as the tolerance and modifiers
based on which CTS you input.
************************************************** *****************************}

Now using this function, we can whip up a quick and simple script.
program new;
{$i SRL\SRL.scar}

Cols: TIntegerArray;
BestColor, Tol: Integer;
S2m: TExtendedArray;

procedure DoIt;
Cols := [];
BestColor := GetBestColor(Cols, 1, Tol, S2M);

Writeln('Best Color: ' + ToStr(BestColor) + '; Tolerance: ' + ToStr(Tol));

Just insert your colors at line 11 as a TIntegerArray, press run, and look at the debug box! Using this, after I gave it the colors for my vial of water, I got a color of 10251880 with a Tolerance of 2.
N.B.: Be sure and delete duplicate colors!!

Step 3: Making the DTMs
Now, we have a set of points, colors, and tolerances to use - I have mine laid out below.

Color, Tolerance - Point
VoW: 10252137, 2 - 580, 234
Ranarr: 807988, 2 - 582, 262
UnfPot: 8294524, 2 - 580, 306
Snape: 3824653, 2 - 582, 334
PPot: 8959544, 2 - 579, 379

Open RS Back up and select it as the client. Run the DTM Editor (Tools > DTM Editor). To start off, pick a center point - it doesn't have to be the exact point you chose earlier. Now, select several BLACK pixels (color 131072) around the object you're making a DTM for. This color does not change, therefore making it great to pick points of.
Protip: Avoid picking points on the top left side of an item. When the item is in your bank, the yellow pixels that tell you how many of the item you have can cover the points you've chosen.
After you've chosen your black points, go back to your central point. Change the properties (X, Y, color, tolerance) to match the numbers we've previously gathered.
Protip: Increase the tolerance by 2 or 3.
Once you've done this, it should look something like this:
Great! We've finally got our DTM!
But wait, isn't that vial of water very similar in shape to that unfinished potion? Let's see if it picks up only the vial of water! Go to Image > Show Matching DTMs, and you can see.
Great! Our super accurate DTM found only the vial of water, not the Unfinished potion!

Now that we've finally got our DTM, go to DTM -> Print DTM, and save the string. TUDAH!

Hope you enjoyed this tutorial. This is just how I do things - you don't necessarily have to do all this work.

04-19-2011, 09:39 PM
Very nice tutorial, I didn't realise that the colours changed that much, I thought that it was just with every update or something :3


04-20-2011, 02:16 PM
Very nice tutorial, I didn't realise that the colours changed that much, I thought that it was just with every update or something :3

Same here, I had no idea that they changed that much. This also gave a very nice explanation of how to use GetBestColor.

04-20-2011, 02:36 PM
Good Tut for the beginners.
Explained accurately. Try implementing [center] to make the tut a little better eye candy. :D

Kinda hopping all SRL Members+ already know this stuff though... :o