SCAR Assistant - By EvilChicken!
Latest version: 0.0.4b, updated 14.01. Status: Working
Hello, fellow community members of SRL.
This is SCAR Assistant, an application I have been working on for quite some time now.
SCAR Assistant is a simple code generator written for use with SCAR Divi and the SRL include library. The application was mainly written for the purpose of significantly reducing the time and effort it takes to create autocoloring and object finding functions when scripting in SCAR.
Found below is a brief intro the the application, for detailed description of it's features, scroll further down.
It works in a very simple three-step way which is roughly explained below.
1. Open up a image from where you want to pick your colors by pressing Ctrl + O or clicking File and then Open bitmap. The image must be a bitmap to avoid color data loss caused by image compression. Alternatively, press F5 to capture a screenshot of your desktop.
Note: As you might notice, all screenshots and new images you open, will open in new tabs.
2. Pick the colors you want to target by clicking at the points of the opened image containing the desired color. To ease this process, there are two small boxes in the application's top-right corner, over the listbox. They are linked together, so they look like one big rectangle. The rightmost of these squares show an enlarged 5*5 box surrounding your cursor, while the left box simply shows the color of the pixel that is positioned under your mouse cursor.
Tip: SCAR Assistant has it's own zooming tool with the ability to zoom in from 50 to 2000% on the area surrounding your cursor. To display this tool, click Help > Zoom Assistant.
The slider bar under the image allows you to change zoom level, and if you right-click the status bar, (located at the very bottom of Zoom Assistant's window) you get the possibility to toggle Zoom Assistant's crosshair on/off and enter a custom zoom level (in percent) if you find the slider bar bothersome to use.
3. Pick desired function type and fill in the parameters needed for generation of the selected function. As you can see, the two functions are split up in two different tabs, Autocoloring and Object finding.
The Autocoloring tab is for generating functions for finding a specific color in RuneScape, most commonly within the minimap boundaries. These could be dynamic roadcolors, watercolors, et cetera. If you haven't already, you might want to take a look at SRL's AutoColor.scar include, to see the functions used to find the dynamic colors on RuneScape's minimap.
In the first group, "colorspaces", you can choose from three; RGB, HSL and XYZ. The preset values of these (the values in the editboxes) should give you a slight idea about the effectiveness range of those three, but they are of course nothing more than preset values, and are meant to be customized.
If you aren't experienced with autocoloring in SCAR, this tutorial is brilliant to start off with before you begin making them. (Ehm, "you".. )
Note: Autocoloring only support one color in the listbox at a time for now.
The checkboxes next to the colorspace tolerance values simply indicate whether the corresponding colorspace will be used.
The second group, "Result" simply changes the result of the function. If the "Return color" button is checked, the generated function will return the found color (if any) as an integer. However, if the "Click color" button is checked, the generated function will click the found color (again, if any) and result True/False depending on if the target color was found.
Finally, the checkbox named "Spiral search?" determines where SCAR starts the search. If the checkbox is ticked, it will start from MMCX, MMCY, which are the RS minimap's center coordinates. If not checked, it will start from the top-left corner and search from there.
If an autocoloring function is what you need, fill in the needed values, pick a template color and press the "Create Function" button. The code will be generated as an entire script ready to be ran and tested in RuneScape. If you only need the function and nothing more, simply highlight the code you want to copy, and press Ctrl + C, then paste it in SCAR. Otherwise, it might be easier to just click the debug box and press Ctrl + A followed by Ctrl + C. This will copy the entire content of the active debug box.
However, if you need to find an object in RuneScape, you need to switch over to the "Object finding" tab. Here, the first group you'll notice is the "Object finding method" group with two options; simple "FindColor" and the more advanced "2D TPA". The main difference between these two is simply that the "2D TPA" function is better. While "FindColor" only will find the first color closest to the search starting point, the twodimensional TPointArray will search for all matching colors within the given coordinates, store the coordinates of those into an array of TPoints, split them into boxes (decided by given "Object width/height" values) and then check for uptext correspondance.
Note: if you want to know more about object finding using almighty TPAs, you might want to check out this tutorial.
So basically, TPointArrays for object finding would be preferred in most cases.
Next, we have the "Uptext" and "Tolerance" boxes, which will be there no matter what object finding technique you pick. "Uptext" is the text that is shown when you hover the target object in RS, and this is the text that the GetUpText; function returns. This text is mainly used to confirm that you're about to click the correct object, as there sometimes might be a lot of different objects on the RuneScape screen that have the same colors, which might confuse SCAR.
So, in the "UpText" box, there should be a small part of this text. The text you enter in this box should preferably be unique for the object you're searching for, and not contain capital letters. Though GetUpText works with capitals in RS, there has been reported issues. So for example if the object you're searching for, has "Take Banana" as uptext, you might want to use "anana" as uptext.
Next thing is the "Tolerance" editbox. This basically decides the tolerance for the color search. If you have picked many unique colors for the object you want to find, you might want to use a low tolerance, maybe 5 - 10, but if you've picked few colors, raising the tolerance to 20+ would be wise. Again, this depends on whether there are a lot of other objects with similar colors on the RS mainscreen where your target object is. Use simple logics and it would work out pretty easily once you get more experienced with SCAR scripting.
If you picked the "2D TPA" object finding method, there will also be two boxes named "Object width" and "Object height". These are used for the previously mentioned sorting of the found colors, where the TPoints containing the coordinates for the found colors get split up into groups with width and height parameters decided by these.
Object width is how many pixels wide your object is, and object height is how many pixels high your target object is.
Tip: if you have trouble seeing how high/wide your object is, use the Zoom Assistant to quickly find out and save time.
ColorToleranceSpeed is .. slightly advanced stuff, if you don't know what it is, it's best to leave it at the default setting, which is 1. If you want to know more about ColorToleranceSpeed and it's modifiers, you might be interested in this nifty tutorial.
Almost finished, but you're probably wondering what that "Use SmartColors?" checkbox does?
Originally created by Tarajunky, SmartColors is a progressive way of finding objects. Simply explained, the function will first search for the colors you picked with 0 tolerance. These colors will be stored in a global variable array. If it finds the objects using zero tolerance, it will move the color which was used to find the object, one place ahead in the previously mentioned color array, if it isn't already in the first place if the array.
If the search with zero tolerance is of no result, a new search, this time with given tolerance, will be executed. If it finds the object this time, it will add the color used to find the object, to previously mentioned global color array.
.. aaand I think that's it? It's not that much, I just elaborated it beyond what was necessary. Furthermoar, you can also:
- Add colors using decimal, RGB, HSL or XYZ color values. (Right-click the color listbox and choose "Add" option in the popupmenu.)
- Save the created function. (Press File, then click "Save function".)
- View Zoom Assistant. (Press Help, then select "Zoom Assistant".)
- Toggle crosshair on/off and enter a custom zoom percentage for Zoom Assistant. (Right-click the status bar and select desired option.)
- Take a screenshot. (Press F5 anytime while having the application activated.)
- Add new tabs to the debug box. (Right-click the debug box and choose "Add Tab".)
- View and print picked color`s RGB, HSL and XYZ values. (Double-click desired color in the color listbox.)
For final words, I'd like to underline that all feedback and bug reports will be greatly appreciated. Please do tell me if I was unclear at any point, and feel fre to ask if you have questions.
Changelog:
14.01: Version 0.4b released, contains an RS account creator, otherwise only small visual changes. Hopefully the "Vista bug" is fixed, needs confirmation.