SRL Archive - OpenGL Tutorials

OpenGL - A Beginner's Scripting Tutorial


Clarity

2015-03-28 03:45:52



by @Clarity and @Obscurity

Last updated on November 30th, 2015

GLX v3.7 | ogLib v1.0a | ogLib Development | Beginner's Tutorial | ID Highlight Tool


What is OpenGL Scripting?

[INDENT]
Like injection, reflection, and color, OpenGL scripting is yet another alternative method of creating RS3 macro programs. After reading this tutorial, you will be able to create powerful and flawless scripts, capable of complex tasks usually discarded as too difficult for color only. Pending an ogLib update to support SRL-6, You will also learn how to incorporate both color and OpenGL methods into your scripts, combining the two scripting approaches to get the best of both worlds.

Without going into unnecessary detail, OpenGL allows us to examine the information being sent to your computer's graphics card, giving information on models, textures, chars, and more. We can script in resizable mode, easily interact with environments regardless of camera angle, and even get perfectly accurate player minimap and 3D world locations. It is not without its flaws, however, when used correctly and cleverly, OpenGL can accomplish some awesome things!

It is highly recommended to first familiarize yourself with SRL-6 scripting before learning OpenGL, as the combined information will give you many more creative options. This tutorial assumes basic understanding of Lape and beginner SRL-6 scripting concepts. If you have any questions, feel free to post.
[/INDENT]

Table of Contents

  • Part 1: [jumpto=01]Setting up OpenGL[/jumpto]
  • Part 2: [jumpto=2]OpenGL Data Types[/jumpto]
  • Part 3: [jumpto=3]Spawning and Saving SMART with OpenGL[/jumpto]
    • [jumpto=31]Script 3.1[/jumpto] - Setup
  • Part 4: [jumpto=4]Retrieving Chars, Textures, and Models[/jumpto]
    • [jumpto=41]Script 4.1[/jumpto] - Retrieval methods
    • [jumpto=42]Script 4.2[/jumpto] - Visual client debugging
  • Part 5: [jumpto=5]Basic Scripting with OpenGL[/jumpto]
    • [jumpto=51]Script 5.1[/jumpto] - Setup
    • [jumpto=52]Script 5.2[/jumpto] - Debugging models (basic)
    • [jumpto=53]Script 5.3[/jumpto] - Locating models
    • [jumpto=54]Script 5.4[/jumpto] - Interacting with models
    • [jumpto=55]Script 5.5[/jumpto] - Debugging models (advanced)
    • [jumpto=56]Script 5.6[/jumpto] - Extracting models
    • [jumpto=57]Script 5.7[/jumpto] - Delaying reactions
    • [jumpto=58]Script 5.8[/jumpto] - Using multiple reactions
    • [jumpto=59]Script 5.9[/jumpto] - Debugging textures
    • [jumpto=510]Script 5.10[/jumpto] - Interacting with textures
  • Part 6: [jumpto=6]ogLib Development Thread[/jumpto]
  • Part 7: [jumpto=7]Conclusion[/jumpto]



[anchor=01]Part 1 :: Setting up OpenGL[/anchor]
[INDENT]
OpenGL scripting and program execution requires some modified dynamic link libraries (.DLLs) for RS3 and Simba to use. Additionally, we use a different set of includes (ogLib) to develop OpenGL scripts. This library currently supports RS3 - EoC only.

Automatic Installation
Download ProSocks.dll and place it into Simba\Plugins\
Download [ATTACH]27083[/ATTACH] and place it into Simba\Scripts\. Open and run the script.

Manual Installation
Download the OpenGL32.dll and GLX.dll plugins, developed by @Brandon, here: GLX v3.7
Download the ogLib includes, a library designed and developed by @Clarity and @Obscurity, here: ogLib v1.0a

Note that ogLib is an ongoing project, and contributions are welcomed! Some elements have yet to be added, such as in-depth mouse movement and SRL-6 compatibility. We are tackling the priority elements first, such as interfaces, mapping, and combat.

Once you have extracted the contents, copy OpenGL32.dll and GLX.dll into your C:\…\Simba\Plugins\ directory. Next, copy the ogLib\ folder into your C:\…\Simba\Includes\ directory. It's that simple!
[/INDENT]



[anchor=2]Part 2 :: OpenGL Data Types[/anchor]
[INDENT]
Before we go any further, you've got to know the basics of OpenGL and the various data types. Unique to OpenGL, these types are:

  • glChar / glCharArray - {TEXTUREID = 0, COLOUR = 0, X = 0, Y = 0, LETTER = , SHADOW = False, TRANSLATE = [0, 0, 0], BOUNDS = {X1 = 0, Y1 = 0, X2 = 0, Y2 = 0}}
  • Description: Each and every character on screen, be it a letter, number, or special character, may be viewed as a glChar. The glChar record contains vital information regarding each character; Things like color, font, and location on screen. Record:
    • TextureID:
    • Think of a character's texture ID as its font. Much like Comic Sans MS, for example, a right click menu typically uses the fonts 17 and 91.
    • Colour:
    • This property simply contains the colour of the character. The orange colour from hovering over a chat option, for example, is 37083.
    • X / Y:
    • The position at which a character can be found on screen can be viewed in its X and Y properties. This coordinate is to the center-point of the character.
    • Letter:
    • This is likely the most important property of a glChar. Letter contains the character which was found. This will always be a single character and could consist of any alphanumeric or special character.
    • Shadow:
    • The shadow property, which is very rarely true, is quite simply whether or not the text contains a shadow. Although some text appears to have a shadow, it may not. Take the following image for example: Surely each one of those characters has a black shadow? This is incorrect. While they appear to have shadows, it's simply a 200 drawn ontop of a slightly offset, black 200. Therefore, the total number of characters in the image is 6.
    • Bounds:
    • The bounds of a glChar simply contain the coordinates of each corner. Calculating the center-point of them would result in the glChar's X / Y, as mentioned earlier.
  • glModel / glModelArray - {ID = 0, TID = 0, X = 0, Y = 0}
  • Description: For the most part, it's fairly safe to assume that any 3D object or any item that appears in the 3D plane of RuneScape is a glModel; From players, to monsters, to target reticles, to the animated flag shown on screen while waiting for a Pest Control game to start. They're all models. Record:
    • ID:
    • Each model in RuneScape has an ID. These typically tend to remain constant. For example, it's fairly safe to assume that if you check and see that a Rorarius has an ID of 3227299924, it'll always have that ID.
    • TID:
    • A model's triangle count. Essentially, it should "technically" be "almost" as accurate as the ID.
    • X / Y:
    • The position at which a model can be found on screen can be viewed in its X and Y properties. Keep in mind that if drawn on the 3D plane, the model's X and Y will be located at the base of the model. Take the following image for example: In this case, the model's X and Y is positioned at the base of the player near the feet.
  • glTexture / glTextureArray - {ID = 0, ColourID = 0, FullColourID = 0, X = 0, Y = 0, BOUNDS = {X1 = 0, Y1 = 0, X2 = 0, Y2 = 0}}
  • Description: Almost everything that seems 2D in RuneScape can be retrieved as a glTexture. These are most often used for buttons, icons, interfaces, inventory items, equipped items, abilities, and anything in-between. Record:
    • ID:
    • glTextures, like glModels, always have an ID. However, this ID is rarely unique, making relying on solely this property for locating items and objects unreliable. For example, different potion flasks, summoning pouches, runes, tend to share a texture ID. Take the following GIF for example: Here we can see that a Super restore (6) shares a texture ID with an Overload flask (1).
    • ColourID:
    • As mentioned before, textures can share a TextureID. To distinguish between these textures, we often use the ColourID. For now, lets just call it a summary of all colours within the texture.
    • X / Y:
    • The position at which a texture can be found on screen can be viewed in its X and Y properties. This is coordinate is the center-point of the texture.
    • Bounds:
    • The bounds of a glTexture simply contain the coordinates of each corner. Calculating the center-point of them would result in the glTexture's X / Y, as mentioned earlier.
[/INDENT]


[anchor=3]Part 3 :: Spawning and Saving SMART with ogLib[/anchor]
[INDENT]
Before we do anything requiring OpenGL, you need to spawn a SMART client with the OpenGL plugin. To do this, you have to setup ogLib using ogl.setup(). See the sample [anchor=31]Script 3.1[/anchor] below:

program ogLib;
{$i ogLib\lib\core\core.simba}

begin
ogl.setup([800, 600], [0, 0, 800, 600]);
end.
ogl.setup() requires two sets of parameters. The first set, consisting of two integers, sets the dimensions of the client. The second set, consisting of four integers, sets the bounding coordinates of your viewport.

Client Size vs. Viewport Size
The client size is the size of the entire RuneScape game within the SMART client. This is commonly 800x600. The viewport is the size of the 3D world within RuneScape, usually referred to in SRL-6 terms as the mainscreen. For accurate model positioning to work, you need to ensure your viewport is correctly set with ogLib. If you do not do this, debugged model IDs will be vastly offset from their actual positions. If using resizable mode without any special alterations, your viewport will match the client size. The following images demonstrate this concept:

[SPOILER=Understanding Viewport Sizes][/spoiler]
By default, ogLib assumes 800x600 client dimensions, and a viewport of the same size (resizable mode). These default values can be more easily called by simply writing ogl.setup() without any parameters. The default values can be changed using ogl.setDefaultClientHeight() and ogl.setDefaultClientWidth(). When ogLib is set up, it loads the default cache time, color tolerance, controls - auto-retaliate, familiar action, quick heal, quick prayer, and size, if needed. These can be changed with ogl.setDefaultCacheTime(), ogl.setDefaultControlAutoRetaliate(), et cetera.

To save all of the current SMART's parameters, mentioned above, as defaults, use ogl.save().
[/INDENT]


[anchor=4]Part 4 :: Retrieving Chars, Models, and Textures[/anchor]
[INDENT]
What makes OpenGL and ogLib so powerful is their ability to instantly locate chars, models, and textures on the screen. Or, equally important, it can be used to tell you if something is not present on the screen. To do this, we have the vital methods ogl.getChars(), ogl.getModels(), and ogl.getTextures().

Each of the above methods can be used to find their respective types on the screen. See the sample [anchor=41]Script 4.1[/anchor] below.

program ogLib;
{$i ogLib\lib\core\core.simba}

procedure mainLoop;
var
textureArray: glTextureArray;
begin
textureArray := ogl.getTextures(1275);
writeln(textureArray);
end;

begin
ogl.setup([800, 600], [0, 0, 800, 600]);
repeat
mainLoop;
until false;
end.

In the example above, 1275 is the texture ID of the red flag that appears whenever a player is moving or beginning an interaction with a game object. You can also get every char, model, or texture currently on the screen by not using any limiting search parameter. A returned texture array might look something like this:

[{ID = 33556, COLOURID = 2432529, FULLCOLOURID = 2630421, X = 912, Y = 528, BOUNDS = {X1 = 0, Y1 = 0, X2 = 1824, Y2 = 1057}},
{ID = 57120, COLOURID = 2894355, FULLCOLOURID = 2631441, X = 912, Y = 457, BOUNDS = {X1 = 884, Y1 = 455, X2 = 940, Y2 = 460}}]

To visually debug texture and model IDs, you can use the ID Highlighting Tool. Or, you can use ogLib's debug functions, shown in the sample [anchor=42]Script 4.2[/anchor] below:

program ogLib;
{$i ogLib\lib\core\core.simba}

begin
ogl.setup([800, 600], [0, 0, 800, 600]);

ogl.setDebugMode('none');
ogl.setDebugMode('texture');
ogl.setDebugMode('model');
ogl.setDebugMode('font');

ogl.setDebugMode('nones');
ogl.setDebugMode('textures');
ogl.setDebugMode('models');
ogl.setDebugMode('fonts');

ogl.setDebugMode('N');
ogl.setDebugMode('T');
ogl.setDebugMode('M');
ogl.setDebugMode('F');

ogl.setDebugMode(0);
ogl.setDebugMode(1);
ogl.setDebugMode(2);
ogl.setDebugMode(3);
end.

ogl.setDebugMode() is very flexible in what it accepts: if you want to debug onscreen models, you can use ogl.setDebugMode('models'), ogl.setDebugMode('M'), or ogl.setDebugMode(2), whichever you find more convenient! Doing so will cause these IDs to appear on SMART's debug:



Depending on your screen resolution, the green ID numbers may appear differently. Use ingame zooming and camera movement to see the numbers more clearly if needed. If too many models are stacked on top of each other, you will need to use text debugging methods such as writeln(ogl.getModels()).
[/INDENT]


[anchor=5]Part 5 :: Basic Scripting with OpenGL[/anchor]
[INDENT=1]
To start off with, scripting with OpenGL can be much different then using colour. Before continuing, we highly recommend reading @Kevin's thread on Function Pointers, as we'll be touching on it a lot throughout this tutorial. His methods are fantastic when used with OpenGL.

So, let's make our first very basic auto-fighter. For learning's sake, head to the Troll Brutes in Burthorpe.

  • Step 1 - Starting the OpenGL plugin
  • To start using the OpenGL plugin, we need to create a basic script, beginning with our basic setup call mentioned earlier. [anchor=51][/anchor][SPOILER=Script 5.1]
    program ogLib;
    {$i ogLib\lib\core\core.simba}

    begin
    ogl.setup([800, 600], [0, 0, 800, 600]);
    end.
    [/SPOILER]
  • Step 2 - Setting graphics settings
  • To use the OpenGL plugin, our client must be also be using OpenGL. You'll need to make your graphics settings match the following image: [SPOILER=Figure 5.1][/SPOILER]
  • Step 3 - Debugging models
  • Now that we've correctly loaded the client, we need to debug some models in order to locate the Troll brutes. [anchor=52][/anchor][SPOILER=Script 5.2]
    program ogLib;
    {$i ogLib\lib\core\core.simba}

    begin
    ogl.setup([800, 600], [0, 0, 800, 600]);
    ogl.setDebugMode('models');
    end.
    [/SPOILER] Using this, we can then locate the correct model IDs. These have been highlighted in the image below: [SPOILER=Figure 5.2][/SPOILER]
  • Step 4 - Locating models
  • Now it's time to find the trolls using ogl.getModels() and their model ID of 403123861. [anchor=53][/anchor][SPOILER=Script 5.3]
    program ogLib;
    {$i ogLib\lib\core\core.simba}

    procedure mainLoop;
    var
    trollBrutes: glModelArray;
    begin
    trollBrutes := ogl.getModels(403123861);
    clearDebug;
    if trollBrutes.isEmpty() then
    writeln('No troll brutes were found.')
    else
    begin
    writeln(trollBrutes.indexes(),' troll brutes were found:');
    writeln(trollBrutes);
    end;
    wait(150);
    end;

    begin
    ogl.setup([800, 600], [0, 0, 800, 600]);
    ogl.setDebugMode('models');
    repeat
    mainLoop;
    until false;
    end.
    [/SPOILER] This script should print something along the lines of: [SPOILER=Figure 5.3]
    8 Troll brutes found:
    [{ID = 403123861, TID = 706, X = 658, Y = 670}, {ID = 403123861, TID = 706, X = -20, Y = 414}, {ID = 403123861, TID = 706, X = 352, Y = 348}, {ID = 403123861, TID = 706, X = 629, Y = 364}, {ID = 403123861, TID = 706, X = 367, Y = 207}, {ID = 403123861, TID = 706, X = 261, Y = 184}, {ID = 403123861, TID = 706, X = 301, Y = 151}, {ID = 403123861, TID = 706, X = 278, Y = 133}]
    [/SPOILER]
  • Step 5 - Interacting with models
  • Now that we know how to locate the trolls, let's start attacking the closest to the center. [anchor=54][/anchor][SPOILER=Script 5.4]
    program ogLib;
    {$i ogLib\lib\core\core.simba}

    procedure mainLoop;
    var
    trollBrutes: glModelArray;
    begin
    trollBrutes := ogl.getModels(403123861);
    clearDebug;
    if trollBrutes.isEmpty() then
    writeln('No troll brutes were found.')
    else
    mouse.click(clientCenter.closest(trollBrutes)[0].randomizePointEllipse(15));
    wait(random(1000, 2000));
    end;

    begin
    ogl.setup([800, 600], [0, 0, 800, 600]);
    clientCenter := ogl.getClientMidPoint();
    repeat
    mainLoop;
    until false;
    end.
    [/SPOILER]
  • Step 6 - Debugging advanced models
  • While Script 5.4 attacks the Troll brutes, it doesn't stop once in combat. To fix this, we need to also detect the target reticule models. There are two indicating that we are in combat:
    • Red: Target.
    • Red and Yellow: Retaliating target.
    • Yellow: Aggressive monster.
    The image below shows that visually debugging models isn't always easy: [SPOILER=Figure 5.4][/SPOILER] Therefore, we need to resort to the debug window and use ogl.getModels() to its full potential - retrieving all models on screen. As you can see from Figure 2.3, there can be thousands of models on screen, so attempt to zoom in to narrow the search as much as possible and edit the script. [anchor=55][/anchor][SPOILER=Script 5.5]
    program ogLib;
    {$i ogLib\lib\core\core.simba}

    var
    clientCenter: TPoint;

    procedure mainLoop;
    var
    allModels, trollBrutes: glModelArray;
    begin
    allModels := ogl.getModels();
    clearDebug;
    writeln(allModels);
    wait(250);
    {
    trollBrutes := ogl.getModels(403123861);
    if trollBrutes.isEmpty() then
    writeln('No Troll brutes found.')
    else
    mouse.click(clientCenter.closest(trollBrutes)[0].randomizePointEllipse(15));
    wait(random(1000, 2000));
    }
    end;

    begin
    ogl.setup([800, 600], [0, 0, 800, 600]);
    clientCenter := ogl.getClientMidPoint();
    repeat
    mainLoop;
    until false;
    end.
    [/SPOILER] [anchor=55][/anchor][SPOILER=Figure 5.5][/SPOILER] If done correctly, your debug window should contain something similar to the following figure. Copy the contents into Notepad or any text editor. [SPOILER=Figure 5.5]
    [{ID = 487932993, TID = 107, X = -197, Y = 669}, {ID = 208265157, TID = 84, X = -28, Y = 591}, {ID = 528332493, TID = 195, X = 780, Y = 695}, {ID = 2410841246, TID = 121, X = 539, Y = 603}, {ID = 3258171939, TID = 53, X = 249, Y = 597}, {ID = 3587280739, TID = 248, X = 798, Y = 462}, {ID = 4105139511, TID = 59, X = 265, Y = 452}, {ID = 545440014, TID = 60, X = 277, Y = 326}, {ID = 403123861, TID = 706, X = -87, Y = 141}, {ID = 3097012422, TID = 135, X = 239, Y = 173}, {ID = 545440014, TID = 45, X = 93, Y = 135}, {ID = 4105139511, TID = 59, X = -1, Y = 143}, {ID = 2477500689, TID = 49, X = -68, Y = 66}, {ID = 427589626, TID = 80, X = 687, Y = 90}, {ID = 1580736461, TID = 57, X = 4, Y = -1}, {ID = 4105139511, TID = 29, X = 853, Y = 20}, {ID = 2297058922, TID = 62, X = 323, Y = -58}, {ID = 528332493, TID = 130, X = 450, Y = -72}, {ID = 1279548371, TID = 49, X = 827, Y = -36}, {ID = 0, TID = 0, X = 0, Y = 0}, {ID = 0, TID = 0, X = 2821, Y = -1545}, {ID = 403123861, TID = 706, X = 520, Y = 336}, {ID = 1452224228, TID = 21, X = 520, Y = 336}, {ID = 1212609603, TID = 1444, X = 400, Y = 331}, {ID = 2209194569, TID = 18, X = 45, Y = -122}, {ID = 0, TID = 0, X = -2278, Y = -5033}]
    [/SPOILER] We know the model ID of the troll and it appears to share the exact coordinate of the reticule, so first find the glModel entry belonging to the troll. In this case, you'll see that its coordinates are (520, 336). You can quite literally copy the "X = 520, Y = 336" and search the record for an exact match, belonging to the ID 1452224228.
  • Step 7 - Extracting models
  • Now that we have the ID for the target reticule, we need to detect when it exists and only attack if it does not. [anchor=56][/anchor][SPOILER=Script 5.6]
    program ogLib;
    {$i ogLib\lib\core\core.simba}

    var
    allModels, targetReticules, trollBrutes: glModelArray;
    canAttack: tCountDown;
    clientCenter: TPoint;

    procedure mainLoop;
    begin
    allModels := ogl.getModels([1452224228,403123861]);
    targetReticules := allModels.getModels(1452224228);
    trollBrutes := allModels.getModels(403123861);

    if trollBrutes.isEmpty() then
    writeln('No Troll brutes found.')
    else if targetReticules.isEmpty() then
    mouse.click(clientCenter.closest(trollBrutes)[0].randomizePointEllipse(15));
    end;

    begin
    ogl.setup([800, 600], [0, 0, 800, 600]);
    clientCenter := ogl.getClientMidPoint();
    repeat
    mainLoop;
    until false;
    end.
    [/SPOILER]
  • Step 8 - Delaying reactions
  • The script will now correctly only attack if you are currently not in combat. However, it still tends to rapidly click until the reticule appears. So lets split the attacking into a reaction procedure and only call it if a given time has passed. To do this, we're going to use a procedure pointer and a tCountDown. A countDown is a custom type in ogLib, similar to the countDown in SRL-6, keeping track of time for various activities. This allows the script to continue functioning without static waits like wait(random(5000)); [anchor=57][/anchor][SPOILER=Script 5.7]
    program ogLib;
    {$i ogLib\lib\core\core.simba}

    var
    allModels, targetReticules, trollBrutes: glModelArray;
    canAttack: tCountDown;
    clientCenter: TPoint;

    procedure attackTrollBrute;
    begin
    mouse.click(clientCenter.closest(trollBrutes)[0].randomizePointEllipse(15));
    canAttack.setTime(random(250, 1500));
    end;

    procedure doNothing;
    begin
    writeln('We did nothing!');
    end;

    procedure mainLoop;
    var
    reaction: procedure() = @doNothing;
    begin
    allModels := ogl.getModels([1452224228, 403123861]);
    targetReticules := allModels.getModels(1452224228);
    trollBrutes := allModels.getModels(403123861);

    if trollBrutes.isEmpty() then
    writeln('No Troll brutes found.')
    else if targetReticules.isEmpty() and canAttack.isFinished() then
    reaction := @attackTrollBrute;

    reaction();
    end;

    begin
    ogl.setup([800, 600], [0, 0, 800, 600]);
    clientCenter := ogl.getClientMidPoint();
    repeat
    mainLoop;
    until false;
    end.
    [/SPOILER]
  • Step 9 - Using multiple reactions
  • Script 5.7 works very well. However, what happens when there are no troll brutes visible, or the closest one happens to be behind an interface such as the inventory? We need to find more by rotating the compass and changing the camera angle. For this, we need to add a new reaction. [anchor=58][/anchor][SPOILER=Script 5.8]
    program ogLib;
    {$i ogLib\lib\core\core.simba}

    var
    allModels, targetReticules, trollBrutes: glModelArray;
    canAttack: tCountDown;
    clientCenter: TPoint;

    procedure attackTrollBrute;
    begin
    mouse.click(clientCenter.closest(trollBrutes)[0].randomizePointEllipse(15));
    canAttack.setTime(random(250, 1500));
    end;

    procedure doNothing;
    begin
    writeln('We did nothing!');
    end;

    procedure rotateCamera;
    begin
    minimap.setDegrees(random(45, 90));
    end;

    procedure mainLoop;
    var
    reaction: procedure() = @doNothing;
    begin
    allModels := ogl.getModels([1452224228,403123861]);
    targetReticules := allModels.getModels(1452224228);
    trollBrutes := allModels.getModels(403123861);

    if trollBrutes.isEmpty() or clientCenter.closest(trollBrutes)[0].isVisible() then
    reaction := @rotateCamera
    else if targetReticules.isEmpty() and canAttack.isFinished() then
    reaction := @attackTrollBrute;

    reaction();
    end;

    begin
    ogl.setup([800, 600], [0, 0, 800, 600]);
    clientCenter := ogl.getClientMidPoint();
    repeat
    mainLoop;
    until false;
    end.
    [/SPOILER]
  • Step 10 - Debugging textures
  • Now that our bot fights and correctly searches for trolls, we need to start picking up and interacting with drops. For now, we'll pick up and bury bones. To do so, you'd get the model ID of bones in the same way you got the Troll brute ID. To save some time, their model ID is 2406257549. It's time to start debugging some textures. Tip: When debugging inventory items, it's much easier to temporarily switch to Legacy mode. [anchor=59][/anchor][SPOILER=Script 5.9]
    program ogLib;
    {$i ogLib\lib\core\core.simba}

    var
    allModels, targetReticules, trollBrutes: glModelArray;
    canAttack: tCountDown;
    clientCenter: TPoint;

    procedure attackTrollBrute;
    begin
    mouse.click(clientCenter.closest(trollBrutes)[0].randomizePointEllipse(15));
    canAttack.setTime(random(250, 1500));
    end;

    procedure doNothing;
    begin
    writeln('We did nothing!');
    end;

    procedure rotateCamera;
    begin
    minimap.setDegrees(random(45, 90));
    end;

    procedure mainLoop;
    var
    reaction: procedure() = @doNothing;
    begin
    allModels := ogl.getModels([1452224228,403123861]);
    targetReticules := allModels.getModels(1452224228);
    trollBrutes := allModels.getModels(403123861);

    if trollBrutes.isEmpty() or not clientCenter.closest(trollBrutes)[0].isVisible() then
    reaction := @rotateCamera
    else if targetReticules.isEmpty() and canAttack.isFinished() then
    reaction := @attackTrollBrute;

    reaction();
    end;

    begin
    ogl.setup(800, 600);
    clientCenter := ogl.getClientMidPoint();

    ogl.setDebugMode('textures');

    {
    repeat
    mainLoop;
    until false;
    }
    end.
    [/SPOILER] Script 5.9 will change your debug mode from models to textures, changing our client to look like the following image: [SPOILER=Figure 2.6][/SPOILER] From this, we can see that Bones, while in the inventory, have a texture ID of 52275.
  • Step 11 - Interacting with textures
  • Now that we've got the texture ID of Bones, let's have it take and bury bones while fighting Troll brutes. [anchor=510][/anchor][SPOILER=Script 5.10]
    program ogLib;
    {$i ogLib\lib\core\core.simba}

    var
    allModels, bonesModels, targetReticules, trollBrutes: glModelArray;
    bonesTextures: glTextureArray;
    canAttackTrollBrute, canBuryBones, canTakeBones: tCountDown;
    clientCenter: TPoint;

    procedure attackTrollBrute;
    var
    clickPoint: TPoint;
    begin
    clickPoint := clientCenter.closest(trollBrutes)[0].randomizePointEllipse(15);
    if random(2) then
    mouse.click(clickPoint)
    else
    mouse.rightClickOption(clickPoint, 'Attack');
    canAttackTrollBrute.setTime(random(1000, 5000));
    canTakeBones.setTime(random(1000, 5000));
    end;

    procedure buryBones;
    var
    clickPoint: TPoint;
    begin
    clickPoint := mouse.getPoint().closest(bonesTextures)[0].randomizePointEllipse(36);
    if random(2) then
    mouse.click(clickPoint)
    else
    mouse.rightClickOption(clickPoint, 'Bury');
    canBuryBones.setTime(random(250, 1500));
    end;

    procedure doNothing;
    begin
    writeln('We did nothing!');
    end;

    procedure rotateCamera;
    begin
    minimap.setDegrees(random(45, 90));
    end;

    procedure takeBones;
    var
    clickPoint: TPoint;
    begin
    clickPoint := clientCenter.closest(bonesModels)[0].randomizePointEllipse(15);
    mouse.rightClickOption(clickPoint, 'Take Bones');
    canTakeBones.setTime(random(1000, 5000));
    canAttackTrollBrute.setTime(random(1000, 5000));
    end;

    procedure mainLoop;
    var
    reaction: procedure() = @doNothing;
    begin
    allModels := ogl.getModels([1452224228, 2406257549, 403123861]);
    bonesModels := allModels.getModels(2406257549);
    targetReticules := allModels.getModels(1452224228);
    trollBrutes := allModels.getModels(403123861);

    bonesTextures := ogl.getTextures(52275);

    if (not bonesTextures.isEmpty()) and canBuryBones.isFinished() then
    reaction := @buryBones
    else if (not bonesModels.isEmpty()) and canTakeBones.isFinished() then
    reaction := @takeBones
    else if trollBrutes.isEmpty() or not clientCenter.closest(trollBrutes)[0].isVisible() then
    reaction := @rotateCamera
    else if targetReticules.isEmpty() and canAttackTrollBrute.isFinished() then
    reaction := @attackTrollBrute;

    reaction();
    end;

    begin
    ogl.setup(800, 600);
    clientCenter := ogl.getClientMidPoint();
    repeat
    mainLoop;
    until false;
    end.
    [/SPOILER]
If you followed along correctly, your bot should function like this YouTube video.[/INDENT]


[anchor=6]Part 6 :: ogLib Development Thread[/anchor]
[INDENT]The official development thread for ogLib can be found here: ogLib Development. This thread will serve as a reference for the continuing improvement and development of ogLib. Any questions or suggestions regarding development should be posted there - any educational questions related to using the library should be posted on this tutorial thread!

[/INDENT]


[anchor=7]Part 7 :: Conclusion[/anchor]
[INDENT]
We hope that you have as much fun trying your hand at OpenGL as we have! As said before, the ogLib project is a work in progress. Updates to the plugins themselves, as well as to ogLib, are under way to allow even more capabilities within the 3D world. This tutorial's function list will be maintained with the latest changes. Eventually, we plan to have an include library as comprehensive and complete as SRL-6. Feel free to offer your thoughts on the thread!

ogLib GitHub: https://github.com/ObscuritySRL/ogLib
[/INDENT]


Best of luck with your botting endeavors!
Clarity & Obscurity

Hoodz

2015-03-28 04:14:49

Very helpful, nice tut!

Justin

2015-03-28 06:36:15

Fantastic work @Clarity; and @Obscurity; Will be using this in the future to make some complex scripts!

Brandon

2015-03-28 09:31:17

Just a correction for glModel:

TID:
A model's TID, although rarely used, points to its texture ID.


Should be:
is a model's TriangleCount (Not Texture ID). Essentially, it should "technically" be "almost" as accurate as the ID.

Other than that, this is amazing! Nice massive library too. +1 to both of you.

Taric

2015-03-28 12:39:31

I do believe something is missing… Because the example scripts do not compile… Regardless, THANK YOU. THANK YOU THANK YOU THANK YOU THANK YOU.

I wuv you. So hard.

Example of the types of errors I have been getting:

Error: Unknown declaration "clientWidth"...
Error: No default value for parameter 3 found (This is an error with the clickMouse function)...

3Garrett3

2015-03-28 12:39:49

WOOO Great tutorial. I read through it and started trying to use the sample scripts so I could see what went down. Unfortunately none of the sample scripts appear to compile with the version of the include linked in the top of the tutorial. So I have to do a little fiddling to figure out the best way to click, since the clicking stuff is what doesn't compile. Also client.Height doesn't appear to be a thing so I'm going to resort to smart.height or something for now.

Obscurity

2015-03-28 13:15:16

The scripts were just copied from our obscurityLibrary tutorial, so he may have just forgot one or two things. I'll work on it when I finally manage to get out of bed. :-P.

Obscurity

2015-03-28 13:56:14

K. Pushed an update to the library with the functions required.

The working script is:
program ogLib;
{$i ogl\lib\core\core.simba}

var
allModels, bonesModels, targetReticules, trollBrutes: glModelArray;
bonesTextures: glTextureArray;
canAttackTrollBrute, canBuryBones, canTakeBones: countDown = [0];
clientCenter: TPoint;
clientHeight, clientWidth: int32;

procedure attackTrollBrute;
var
clickPoint:tPoint;
begin
clickPoint:=clientCenter.closest(trollBrutes)[0].randomizePointEllipse(15);
if random(2) then
clickMouse(clickPoint.x, clickPoint.y, 1)
else
mouse.rightClickOption(clickPoint, 'Attack');
canAttackTrollBrute.setTime(random(1000,5000));
canTakeBones.setTime(random(1000, 5000));
end;

procedure buryBones;
var
clickPoint:tPoint;
begin
clickPoint:=mouse.getPoint().closest(bonesTextures)[0].randomizePoint(36, 32);
if random(2) then
clickMouse(clickPoint.x, clickPoint.y, 1)
else
mouse.rightClickOption(clickPoint, 'Bury');
canBuryBones.setTime(random(250, 1500));
end;

procedure doNothing;
begin
writeln('We did nothing!');
end;

procedure rotateCamera;
begin
minimap.setDegrees(random(45, 90));
end;

procedure takeBones;
var
clickPoint:tPoint;
begin
clickPoint:=clientCenter.closest(bonesModels)[0].randomizePointEllipse(15);
mouse.rightClickOption(clickPoint, 'Take Bones');
canTakeBones.setTime(random(1000, 5000));
canAttackTrollBrute.setTime(random(1000, 5000));
end;

procedure mainLoop;
var
reaction: procedure() = @doNothing;
begin
allModels := ogl.getModels(tCardinalArray([1452224228, 2406257549, 403123861]));
bonesModels := allModels.getModels(2406257549);
targetReticules := allModels.getModels(1452224228);
trollBrutes := allModels.getModels(403123861);

bonesTextures := ogl.getTextures(52275);

if (not bonesTextures.isEmpty()) and canBuryBones.isFinished() then
reaction := @buryBones
else if (not bonesModels.isEmpty()) and canTakeBones.isFinished() then
reaction := @takeBones
else if trollBrutes.isEmpty() or clientCenter.closest(trollBrutes)[0].isBehindInterface() then
reaction := @rotateCamera
else if targetReticules.isEmpty() and canAttackTrollBrute.isFinished() then
reaction := @attackTrollBrute;

reaction();
end;

begin
clientWidth:=800;
clientHeight:=600;
ogl.setup(clientWidth,clientHeight);
clientCenter := [round(clientWidth / 2), round(clientHeight / 2)];
repeat
mainLoop;
until false;
end.

Clarity

2015-03-28 15:30:59

Sorry about the confusion guys! Updating the scripts so they should all work fine :) Obscurity added ogl.getClientMidPoint() for convenience, as well as mouse.click(). Please update your ogLib!

From: Brandon
Just a correction for glModel:

TID:
A model's TID, although rarely used, points to its texture ID.


Should be:
is a model's TriangleCount (Not Texture ID). Essentially, it should "technically" be "almost" as accurate as the ID.

Other than that, this is amazing! Nice massive library too. +1 to both of you.

Fooled us both, learning something new every day. Fixed!

Obscurity

2015-03-28 19:00:25

As a heads up… ogl library was renamed to ogLib. This affects the DIR, but all includes have been fixed to take this into account.

Kopa

2015-03-29 06:23:27

This is a great guide, thank you so much!
It will make creating bots so much easier.

HKbotz

2015-03-31 12:39:15

Awesome tut! Been waiting for this for a while. Gonna try it out as soon as I get the chance :)

Clarity

2015-03-31 16:01:43

If there are any other topics you would like covered, please let us know!
We will soon be moving the function list to a new development progress thread in the Unofficial Development forum.

Citrus

2015-03-31 16:27:13

From: Clarity
If there are any other topics you would like covered, please let us know!


How would you handle walking to different locations? e.g. pest control: walking from the lander to a portal.
Also, is there any way to include ogLib AND SRL 6?

Clarity

2015-03-31 17:05:52

From: evilcitrus
How would you handle walking to different locations? e.g. pest control: walking from the lander to a portal.
Also, is there any way to include ogLib AND SRL 6?


@Obscurity created a pest control script awhile ago, he may want to weigh in on that specifically if you are looking for PC help. Currently, minimap.simba offers:

function minimap.clickDegrees(funcDegrees: int32): boolean;
function minimap.clickRadians(funcRadians: double): boolean;


We will be porting over the easier movement functions from obscurityLibrary soon! @the bank also developed a version of SPS for use with ogLib. I'm not sure if he is going to share that or not.

I will be adding SRL-6 Compatibility when ogLib is mostly finished. As we haven't had a personal need for it yet, we haven't added it. You should be able to accomplish pretty much anything right now, but in the interest of being flexible and compatible, I will be happy to add this in soon!

This will be achievable, like in Brandon's old include, by adding {$DEFINE SRLCompatibility} to the top of any script.

Obscurity

2015-03-31 18:21:08

From: Clarity
@Obscurity created a pest control script awhile ago, he may want to weigh in on that specifically if you are looking for PC help. Currently, minimap.simba offers:

function minimap.clickDegrees(funcDegrees: int32): boolean;
function minimap.clickRadians(funcRadians: double): boolean;



obscurityLibrary was able to get your position on the loaded map tile. ogLib will soon be able to as well.

But with obscurityLibrary, you could specify a point on the minimap. Say the 400x400th tile. It would return where that would be on your screen (since the minimap is rotated). You could then get the angle of that to your player and click that direction on the minimap.

But for my PC script, I just had it follow the masses of people. Blend in, right? ;). To do this:
//~ Stuff here...
dotArray:=textureArray.extractID(3570);
if (not dotArray.isEmpty()) then
for index to (maxIndex:=dotArray.maxIndex()) do
begin
dotPosition:=dotArray[maxIndex-index].obsLocalMap(true);
if dotPosition.y<75 then
dotArray.delete(maxIndex-index);
end;
//~ Stuff here...
mapBounds:=obsGetMiniMapBounds(textureArray);
mapMiddle.x:=round(mapBounds.x1+mapBounds.width()/2);
mapMiddle.y:=round(mapBounds.y1+mapBounds.height()/2);
furthestMapDot:=mapMiddle.furthest(dotArray)[0];
furthestAngle:=360-round(arcTan2(furthestMapDot.y-mapMiddle.y,furthestMapDot.x-mapMiddle.x)*180/pi)-90;
furthestAngle:=(furthestAngle-floor(furthestAngle/360)*360);
obsMiniMapClickAngle(furthestAngle,15,false,textureArray);

Citrus

2015-03-31 19:18:27

Thanks! You guys are both awesome.

In regards to SRL-6 compatibility, I just need to stop being lazy and learn new things :)

Clarity

2015-03-31 21:03:40

From: evilcitrus
In regards to SRL-6 compatibility, I just need to stop being lazy and learn new things :)

SRL-6 has a lot of useful math functions in math.simba. We might copy those over. Apart from those, ogLib should have everything you need to make what you want! Nevertheless I will work on SRLCompatibility when I have time.

Thomas

2015-04-01 14:51:04

Can't wait for all of this to be finalised!
Being able to loot items on ID is going to be awesome.

No more searching for colors on fighters, less chance of messing up if colors match.

And the ogLib seems great so far! Will be using the banking functions to finalise my farm.


function mouse.rightClickOption(funcPoint:tPoint;funcOption :ansiString):boolean;
ansiString is the text from the option we want to click? Whats the funcPoint?

HKbotz

2015-04-01 15:09:06

I noticed the mouse functions are quite basic, for example the mouse.click() just uses clickMouse(), and I was wondering how safe do you think this is? Have you had any bans on any ogl scripts you've written or should it be safe enough to use for extended periods of time?

Clarity

2015-04-01 15:38:53

From: lovebotter
Can't wait for all of this to be finalised!
Being able to loot items on ID is going to be awesome.

No more searching for colors on fighters, less chance of messing up if colors match.

And the ogLib seems great so far! Will be using the banking functions to finalise my farm.


function mouse.rightClickOption(funcPoint:tPoint;funcOption :ansiString):boolean;
ansiString is the text from the option we want to click? Whats the funcPoint?

ansiString is the option, funcPoint is the TPoint to right click on. Glad you are enjoying the library :)

From: HKbotz
I noticed the mouse functions are quite basic, for example the mouse.click() just uses clickMouse(), and I was wondering how safe do you think this is? Have you had any bans on any ogl scripts you've written or should it be safe enough to use for extended periods of time?
0. We have run scripts for months with absolutely no mouse movement. However, we take great care to randomize timing, since mouse movements = time. I often add in mouse movements not to have movement, but to create realistic timing between clicks.

Thomas

2015-04-01 19:29:01

From: Clarity
ansiString is the option, funcPoint is the TPoint to right click on. Glad you are enjoying the library :)

0. We have run scripts for months with absolutely no mouse movement. However, we take great care to randomize timing, since mouse movements = time. I often add in mouse movements not to have movement, but to create realistic timing between clicks.


What do you mean no mouse movement? Would your mouse just hop between clicking locations?
Might try and implement some ogl fuctions in bonsai's basic fighter (npc detection and looting) to get familiar with all of this.

also would spawning a smaller client lower resources needed?

HKbotz

2015-04-01 19:57:04

From: Clarity
0. We have run scripts for months with absolutely no mouse movement. However, we take great care to randomize timing, since mouse movements = time. I often add in mouse movements not to have movement, but to create realistic timing between clicks.


Alright I won't worry about it too much then. I'll follow your advice and focus on the timing. Thanks :)

Clarity

2015-04-01 20:10:26

I don't mean to encourage simplifying/cutting back on your scripts' unique randomizations/mouse styles. We've just found that Jagex doesn't detect whether the mouse is moving, only the time/location (and respective trends) associated with clicks. Perhaps if your account is flagged, they start tracking mouse movement as well in a biometric analysis manner. No way to say for sure. If it is easiest for you, continue using mouse movements. They will be added to ogLib for consistency with SRL-6 when the priority things are complete :)

From: lovebotter
What do you mean no mouse movement? Would your mouse just hop between clicking locations?
Might try and implement some ogl fuctions in bonsai's basic fighter (npc detection and looting) to get familiar with all of this.

also would spawning a smaller client lower resources needed?


Yes, the red dot would jump around the screen. Although if you do this with no time in between jumps you will likely be flagged immediately.

Yes, smaller client sizes improve FPS and lessen the load on your computer :)

HKbotz

2015-04-01 20:59:39

Having an issue where the model IDs and actual models don't line up, and the ID is way off centered from the model, so when I click it clicks where the ID is, which is nowhere close to the model.

Any ideas why this is and how to fix it?

The model for the chicken I want is circled along with the ID and as you can see it's way off.

[ATTACH=CONFIG]25457[/ATTACH]

Clarity

2015-04-01 21:02:33

From: HKbotz
Having an issue where the model IDs and actual models don't line up, and the ID is way off centered from the model, so when I click it clicks where the ID is, which is nowhere close to the model.

Any ideas why this is and how to fix it?

The model for the chicken I want is circled along with the ID and as you can see it's way off.

[ATTACH=CONFIG]25457[/ATTACH]

You should not be using SRL-6 settings/old school layout. Use Resizeable graphics mode. If you really want to use SRL-6, you will have to call GLXViewport(); after setting up OGL, but this limits your capabilities a lot imo.

HKbotz

2015-04-01 21:07:40

From: Clarity
You should not be using SRL-6 settings/old school layout. Use Resizeable graphics mode. If you really want to use SRL-6, you will have to call GLXViewport(); after setting up OGL, but this limits your capabilities a lot imo.


Thanks, changing it to RS3 default and resizable seems to have fixed it.

falloutboy12

2015-04-02 08:33:13

From: Clarity
0. We have run scripts for months with absolutely no mouse movement. However, we take great care to randomize timing, since mouse movements = time. I often add in mouse movements not to have movement, but to create realistic timing between clicks.


I think this sort-of makes sense, if they banned based on not having mouse movements then anyone who played rs from a tablet to a desktop via teamviewer would be on the chopping block. I would imagine that being a somewhat common practice…

Thomas

2015-04-02 09:03:40

From: falloutboy12
I think this sort-of makes sense, if they banned based on not having mouse movements then anyone who played rs from a tablet to a desktop via teamviewer would be on the chopping block. I would imagine that being a somewhat common practice…


It's what I assumed aswell.
When new functions will be added, will they be added to this guide? Or shall I just explore the includes?

Scripting seems rather weird for now though, the reactions are completely new to me!

Justin

2015-04-02 09:05:31

From: Clarity
0. We have run scripts for months with absolutely no mouse movement. However, we take great care to randomize timing, since mouse movements = time. I often add in mouse movements not to have movement, but to create realistic timing between clicks.


If you're adding time between clicks, why not just replace that with mouse movements?

Obscurity

2015-04-02 09:42:13

Quite simply put… Because I don't want to. Jumping the mouse is more accurate, don't have to worry about the model having changed positions, etc. And adding a:
if canMoveMouse.isFinished() then
Beats adding a mouse movement.

I'm sure eventually I'll have the functions "follow" the models, but until then.

@love, you're making drastic changes (if you can call that drastic) for minimal improvement. I keep all mine zoomed all the way out and 1024x768, making the 3D world 100%.

Thomas

2015-04-02 10:49:46

From: Obscurity

@love, you're making drastic changes (if you can call that drastic) for minimal improvement. I keep all mine zoomed all the way out and 1024x768, making the 3D world 100%.

I'm unsure if it would be minimal improvement? If 3D world is scaled to about 500v350, thats 4x less area I would have to render. I'm mainly going to use this for a gold farm, so I do care about resources needed.

bg5

2015-04-02 11:28:23

From: Clarity
We've just found that Jagex doesn't detect whether the mouse is moving, only the time/location (and respective trends) associated with clicks.


Hey, that's very interesting. How did you find it out? :)

From: Obscurity

I'm sure eventually I'll have the functions "follow" the models, but until then.


I have already a function following models using TrackingMouse ,it's pretty accurate (I'v never noticed missclick). The only problem I have (not just with this function, with everything) is static model's point adjustment. glModel starts near the ground, so you adjust y position to not click everytime on legs of NPC, but in the middle. But if you zoom out/increase camera angle, this point may be off,usually above the head of NPC. Is there any way to get current zoom and vertical angle of camera with OGL ?

@edit
for camera angle I see the function from you lib :)

Obscurity

2015-04-02 11:37:06

Current camera night isn't in the ogLib yet. It's obscurityLibrary.

But Jagex, some time ago, actually mentioned and discussed logs they had had on a player. No movements were mentioned. And on top of that, there are too many legit means of jumping the mouse (I play on a touch screen for example) now-a-days.

Clarity

2015-04-04 20:18:57

Updated tutorial with link to new development thread: https://villavu.com/forum/showthread.php?t=112599

HKbotz

2015-04-05 03:49:23

mouse.rightClickOption() is not working for me. It just right clicks then moves mouse to close the options. I made sure the text is spelled right, including upper/lower case, and reduced the text so it was just part of the word and it still wasn't working. Any ideas why?

All I did was use a tpoint and text when calling it.
mouse.rightClickOption(p, 'Take Feather'); //p is a TPoint

Clarity

2015-04-05 04:38:30

From: HKbotz
mouse.rightClickOption() is not working for me. It just right clicks then moves mouse to close the options. I made sure the text is spelled right, including upper/lower case, and reduced the text so it was just part of the word and it still wasn't working. Any ideas why?

All I did was use a tpoint and text when calling it.
mouse.rightClickOption(p, 'Take Feather'); //p is a TPoint

On the phone, so I can't check this, but try (p, ['Take Feather']) instead.

HKbotz

2015-04-06 01:00:05

From: Clarity
On the phone, so I can't check this, but try (p, ['Take Feather']) instead.


It still doesn't work. Same result. I think it has something to do with how ogl is reading the characters, because when I get all the characters with ogl.getChars() I see the majority of them repeated.
For example this is a chunk of all the text ogl grabs from the screen.

[[PPrreessssEEnntteerrttooCChhaatt]]YYoouuhhaavveeggaaiinneedd8833bboonnuusseexxppeerriieenncceeppooiinnttssiinntthheeSSllaayyeerrsskkiillll..YYoouurrpprriizzeehhaassbbeeeennppllaacceeddiinnyyoouurriinnvveennttoorryy

That is the bit of text from the chatbox, and as you can see all of the letters are repeated.

Clarity

2015-04-06 01:01:47

From: HKbotz
It still doesn't work. Same result. I think it has something to do with how ogl is reading the characters, because when I get all the characters with ogl.getChars() I see the majority of them repeated.
For example this is a chunk of all the text ogl grabs from the screen.

[[PPrreessssEEnntteerrttooCChhaatt]]YYoouuhhaavveeggaaiinneedd8833bboonnuusseexxppeerriieenncceeppooiinnttssiinntthheeSSllaayyeerrsskkiillll..YYoouurrpprriizzeehhaassbbeeeennppllaacceeddiinnyyoouurriinnvveennttoorryy

That is the bit of text from the chatbox, and as you can see all of the letters are repeated.


That shouldn't be the problem. ogLib already parses through those. The doubled characters you are seeing are the real characters and their shadow characters (black equivalents), which are automatically filtered. One second, I'm going to test whether it works for me.

E: Just tested a Jadinkos script with the following code:


mouse.rightClickOption(ogl.getClientMidPoint().closest(ogl.getTextures(INVENTORY_TRAP_ID))[i].randomizePoint(36, 32), 'Lay Marasamaw plant');

Worked for me. Could you post some screenshots, and more contextual code, please?

ignorant

2015-04-06 01:37:22

From: HKbotz
mouse.rightClickOption() is not working for me. It just right clicks then moves mouse to close the options. I made sure the text is spelled right, including upper/lower case, and reduced the text so it was just part of the word and it still wasn't working. Any ideas why?

All I did was use a tpoint and text when calling it.
mouse.rightClickOption(p, 'Take Feather'); //p is a TPoint


Just wondering, is your mainscreen fully stretched?

E: nvm misread as 'close to the options'

HKbotz

2015-04-06 03:20:35

From: Clarity
That shouldn't be the problem. ogLib already parses through those. The doubled characters you are seeing are the real characters and their shadow characters (black equivalents), which are automatically filtered. One second, I'm going to test whether it works for me.

E: Just tested a Jadinkos script with the following code:


mouse.rightClickOption(ogl.getClientMidPoint().closest(ogl.getTextures(INVENTORY_TRAP_ID))[i].randomizePoint(36, 32), 'Lay Marasamaw plant');

Worked for me. Could you post some screenshots, and more contextual code, please?



Yeah I had a feeling it had something to do with that, although I didn't realize it automatically parsed everything.

Here is the function:

function getLoot(): boolean;
var
featherOGM: glModelArray; //ID: 2194333806
p: TPoint;
begin
result := false;
repeat
featherOGM := ogl.getModels(2194333806);
if (featherOGM.isEmpty()) then
begin
writeln('No feathers found.');
break;
end;
p := ogl.getClientMidPoint().closest(featherOGM)[0].randomizePoint(10, 10);
if (mouse.rightClickOption(p, ['Take Feather']) and (not result)) then
result := true;
//wait(gaussRangeInt(200, 500));
until (featherOGM.isEmpty());
end;

It just right clicks over and over on the feather without ever selecting an option.

Here is a screenshot with it right clicking.
[ATTACH=CONFIG]25512[/ATTACH]

Obscurity

2015-04-06 08:53:35

That is very strange. I have a few ideas of what it could be but I'm at work until 2:45. You said it's succesfully closing the menu when it doesn't find it? Is it doing it by moving the mouse up?

If it's not moving the mouse slightly up to close it, and seems like it's just moving it randomly, try adjusting your color tolerance with OGl.setColourTolerance(). I think it's 4 by default - try lowering and raising it.

Are a few other things to try but those will be when I'm home.

Putting the string into an array won't change it.

HKbotz

2015-04-07 02:54:44

From: Obscurity
That is very strange. I have a few ideas of what it could be but I'm at work until 2:45. You said it's succesfully closing the menu when it doesn't find it? Is it doing it by moving the mouse up?

If it's not moving the mouse slightly up to close it, and seems like it's just moving it randomly, try adjusting your color tolerance with OGl.setColourTolerance(). I think it's 4 by default - try lowering and raising it.

Are a few other things to try but those will be when I'm home.

Putting the string into an array won't change it.


It seems to move the mouse up and to either side, with a range of around 60-70 pixels maybe?(just glanced at it, didn't measure) So it's random, but always up and off to either side and within a certain distance. I will try the color thing when I have more free time. Term started last week so I've been busy with school.

Clarity suggested trying it in an array to see if there was any change and I just didn't bother changing it back, so that's why it's in an array :p

E: Tried changing the color tolerance and still no difference.

Lucidity

2015-04-09 02:35:03

Thanks for this, going to try converting some over to this since Jagex is breaking down on color bots.

Edit : Sweet got it working

Lucidity

2015-04-09 16:50:58

Decided to mess around, got a fletcher going but it's not the best. Definitely could use some work lol

Thanks for this, it's more easy and actually quite fun:p

program fletchVarrockBigBank;
{$i ogLib\lib\core\core.simba}

var
clientCenter: TPoint;


procedure rotateCamera;
begin
minimap.setDegrees(random(245, 270));
writeln('Rotated camera West');
wait(1000);
end;

procedure mainLoop;
var
allModels, bankerModels: glModelArray;
clickPoint, clickPoint2: TPoint;
LogTextures: glTextureArray;
begin
LogTextures := ogl.getTextures(116280);
bankerModels := allModels.getModels(192931521);
allModels := ogl.getModels(192931521);
clickPoint := clientCenter.closest(allModels)[0];
clickPoint2 := clientCenter.closest(LogTextures)[0];
if allModels.isEmpty() then
writeln('No banker exists.');
if clientCenter.closest(allModels)[0].isBehindInterface() then
rotateCamera
else
mouse.rightClickOption(clickPoint, 'Bank');
writeln('Opened bank');
wait(random(1000, 2000));
writeln('Clicked preset 2');
bank.clickPreset(2);
mouse.rightClickOption(clickPoint2, 'Craft');
wait(random(500, 700));
if production.hasChooseATool() then
production.setProduct(2);
wait(random(100, 300));
production.clickMake();
wait(random(51000, 55000));
end;

begin
ogl.setup(1067, 667);
ogl.setDebugMode('models');
clientCenter := ogl.getClientMidPoint();
repeat
mainLoop();
until false;
end.

Clutch

2015-04-10 02:30:29

Still delving into this, heard you made a PC script off it, I can see how much easier this likely made it!
BTW, I can't seem to get it to debug…I grabbed the folders mentioned and ensured I had everything setup exactly as shown. Ideas on what I'm doing wrong?

Obscurity

2015-04-10 06:47:54

Make sure your graphics are set to OpenGL and 3D world is 100% sized.

Also, I finished the PC bot yesterday. Picks a random portal and camps it for a good 10-is just games before picking another. 150 lines exact.

Clarity

2015-04-10 08:07:46

From: Clutch
Still delving into this, heard you made a PC script off it, I can see how much easier this likely made it!
BTW, I can't seem to get it to debug…I grabbed the folders mentioned and ensured I had everything setup exactly as shown. Ideas on what I'm doing wrong?


If you're having problems, please post screenshots!

Clutch

2015-04-10 10:32:38

From: Obscurity
Make sure your graphics are set to OpenGL and 3D world is 100% sized.

Also, I finished the PC bot yesterday. Picks a random portal and camps it for a good 10-is just games before picking another. 150 lines exact.


First time ever hearing about this 3D world thing, that wasn't enabled/setup right. Tried to enable it via teamviewer into my machine…horrid connection so won't be able to find out til tonight.
150 lines…that must be nice. I think mine was around 500 and didn't even complete it!

Okay, still not working. @Clarity @Obscurity
[ATTACH=CONFIG]25572[/ATTACH]
[ATTACH=CONFIG]25573[/ATTACH]

Clarity

2015-04-10 21:37:37

From: Clutch
First time ever hearing about this 3D world thing, that wasn't enabled/setup right. Tried to enable it via teamviewer into my machine…horrid connection so won't be able to find out til tonight.
150 lines…that must be nice. I think mine was around 500 and didn't even complete it!

Okay, still not working. @Clarity @Obscurity
[ATTACH=CONFIG]25572[/ATTACH]
[ATTACH=CONFIG]25573[/ATTACH]


PM me your TeamViewer information.

Edit: Problem solved over TV :)

Clutch

2015-04-11 02:45:05

So I have noticed when doing

mouse.click(ogl.getClientMidPoint().closest(example)[0].randomizePointEllipse(15));
It does in fact find objects, it DOES NOT find the closest and on occassion it will try clicking through interfaces to do so resulting in it getting hung up. Is there something to do about this outside of adding in something to detect the multiple different interfaces it "might" open and then adding a rotatecamera so it can hopefully successfully click?

Also I get Error: Access violation
Execution failed.
The following bitmaps were not freed: [0]
fairly frequently know what that's all about? Sometimes it crashes simba, sometimes I just need to hit play 3-4 times til it goes through.

Clarity

2015-04-11 03:10:53

From: Clutch
So I have noticed when doing

mouse.click(ogl.getClientMidPoint().closest(example)[0].randomizePointEllipse(15));
It does in fact find objects, it DOES NOT find the closest and on occassion it will try clicking through interfaces to do so resulting in it getting hung up. Is there something to do about this outside of adding in something to detect the multiple different interfaces it "might" open and then adding a rotatecamera so it can hopefully successfully click?

Also I get Error: Access violation
Execution failed.
The following bitmaps were not freed: [0]
fairly frequently know what that's all about? Sometimes it crashes simba, sometimes I just need to hit play 3-4 times til it goes through.

TPoint.isBehindInterface()

Clutch

2015-04-11 13:39:25

writeLn(example.Indexes()' ');
I know myself and @renzanity; are having issues with this, we've tested trees, birds, fishing locations and more and even though there are clearly multiple models, it is only printing out that there is 1. Anyone know why this is?

Obscurity

2015-04-11 18:24:13

4 indexes: [{ID = 1731643360, TID = 180, X = 383, Y = 175}, {ID = 1731643360, TID = 180, X = 708, Y = 139}, {ID = 547053328, TID = 175, X = 554, Y = 102}, {ID = 617765920, TID = 186, X = 839, Y = 186}]

Mine is working fine.

What happens if you try:
writeLN(example.indexes(),' indexes: ',example);

Keep in mind that while trees and monsters might look identical, some can have different IDs.

Clutch

2015-04-11 18:37:30

From: Obscurity
Mine is working fine.

What happens if you try:
writeLN(example.indexes(),' indexes: ',example);

Keep in mind that while trees and monsters might look identical, some can have different IDs.


Will try that out when I get home from work, Now that you mention having different IDs that could just be it…It's hard to find the IDs on trees as it puts the Tree and stump model on top of each other so you have to decipher through the debug lines and hope you get it right..

Also I've been looking through the library and saw there was a SRL compatibility, is this what we should use to login? I was seeing some code regarding login but not quite sure how/if to use that. Yes, I saw you guys didn't want to spoonfeed so if needed just ignore this last part.

Obscurity

2015-04-11 18:48:48

Zoom in as far as you can, so that they're some of the only few models on screen. It's easy to tell if it's the correct ID by copying a writeLN(ogl.getModels()) and comparing coordinates. ;).

Clutch

2015-04-11 18:52:41

From: Obscurity
Zoom in as far as you can, so that they're some of the only few models on screen. It's easy to tell if it's the correct ID by copying a writeLN(ogl.getModels()) and comparing coordinates. ;).


Yeah, I do zoom in, they're still literally on top of eachother, I'll do a search for the coordinates though! Thanks!

Obscurity

2015-04-11 19:51:24

Well yeah, they'll be ontop of each other, but it narrows the amount of results returned by ogl.getModels() by like 10000000%. :P.

Clutch

2015-04-12 00:50:30

From: Obscurity
Mine is working fine.

What happens if you try:
writeLN(example.indexes(),' indexes: ',example);

Keep in mind that while trees and monsters might look identical, some can have different IDs.


[ATTACH=CONFIG]25576[/ATTACH]
Tested on all the locations I had mentioned earlier as well and they still only show 1. Although, I did check out troll brutes and those showed up perfectly. Not sure why…

Obscurity

2015-04-12 00:53:03

Well, that's rather curious - mind adding me on Skype?

Edit: Figured it out over TeamViewer - I'm retarded. Will have a fix out soon. Is only the ogl.getModels(uInt32) function and some texture functions.

falloutboy12

2015-04-13 11:59:07

From: Obscurity
Well, that's rather curious - mind adding me on Skype?

Edit: Figured it out over TeamViewer - I'm retarded. Will have a fix out soon. Is only the ogl.getModels(uInt32) function and some texture functions.


Can you expand on this a bit? I'm having a similar issue and I'm not sure I understand what you did to resolve your issue…

Obscurity

2015-04-13 12:17:49

Update. I had OGL.getModels(uInt32) break after the first result because it was originally OGL.getModel(uInt32)… And forgot to change it back.

Y'all gotta keep an eye on the development thread - we post every update and fix.

Clarity

2015-04-14 23:05:01

Hi everyone, some people have pointed out compiling errors - they are due to ogLib being updated after this tutorial post - I'll edit the first post shortly with the appropriate changes.

For example, .isBehindInterface() was replaced with the more helpful, superior getVisible(), amongst other changes.

Sorry for the inconvenience. If you take a look at the development thread, you will see we post every small change or addition promptly after pushing.

Brotein

2015-04-16 10:20:40

From: Clutch
So I have noticed when doing

mouse.click(ogl.getClientMidPoint().closest(example)[0].randomizePointEllipse(15));
It does in fact find objects, it DOES NOT find the closest….

Also I get Error: Access violation
Execution failed.
The following bitmaps were not freed: [0]
fairly frequently know what that's all about? Sometimes it crashes simba, sometimes I just need to hit play 3-4 times til it goes through.


I'm having the same issues as you, sometimes I will get access violations when just trying to compile but they will go away after hitting F9 a bunch or if I quickly target the simba window after enabling and disabling smart. But I am also having problems where closest function is not clicking on the closest object in the array.

Clutch

2015-04-16 10:26:18

From: Brotein
I'm having the same issues as you, sometimes I will get access violations when just trying to compile but they will go away after hitting F9 a bunch or if I quickly target the simba window after enabling and disabling smart. But I am also having problems where closest function is not clicking on the closest object in the array.


If you look back at this check the date, I'm gonna edit it as soon as I can (at work)

Ultimately though the access violation is out of our control. Simba will crash sometimes in which case relaunching the script will solve it, sometimes though you will HAVE to close out of SMART then run the script again, login and then go from there. Annoying, but you'll get used to it and get in the habit of correcting it quickly.

As for finding the closest object ensure you have the latest ogLib.

var
funcModelArray:glModelArray;
funcPointArray:tPointArray;
funcPointArrayIndex:uInt32=0;
begin
if length(funcModelArray:=ogl.getModels(NPC)) then
begin
funcPointArray:=ogl.getClientMidPoint().closest(funcModelArray);
for funcPointArrayIndex to high(funcPointArray) do
begin
if not funcPointArray[funcPointArrayIndex].isVisible() then
begin
//(0,-40)the offset of clicking opposed to clicking at the base of the model Pickpocket is your right-click option mouse.rightClickOption(funcPointArray[funcPointArrayIndex].adjustPosition(0,-40).randomizePointEllipse(20),'Pickpocket');
break;
end
else if funcPointArrayIndex=high(funcPointArray) then
mainScreen.setDegrees(normalRandom(0,360),normalRandom(0,50));
end;
end;
end;

falloutboy12

2015-04-16 10:31:57

From: Brotein
I'm having the same issues as you, sometimes I will get access violations when just trying to compile but they will go away after hitting F9 a bunch or if I quickly target the simba window after enabling and disabling smart.

Another vote for constantly battling access violations - is this happening for everybody or is there something specific to my setup that's causing this?

Clutch

2015-04-16 10:57:50

From: falloutboy12
Another vote for constantly battling access violations - is this happening for everybody or is there something specific to my setup that's causing this?


See my post above, it's out of everyone's control at this point and time, I posted some of the fixes though.

falloutboy12

2015-04-16 11:12:27

From: Clutch
See my post above, it's out of everyone's control at this point and time, I posted some of the fixes though.

OK, I can just sit it out for a while but I just want to make sure you understand where I am right now.

I have the easiest of scripts written to simply find an openGL model and writeln that model. I can see the model ID there on the smart debug but I've never gotten it to output anything. It will either write an empty array or just crash with access violation. This seems worse than what others are experiencing but I've recently replaced some components in my system and reinstalled the OS so I'm trying to make sure that what I'm experiencing is right - it doesn't seem right to me…

Clutch

2015-04-16 11:23:17

From: falloutboy12
OK, I can just sit it out for a while but I just want to make sure you understand where I am right now.

I have the easiest of scripts written to simply find an openGL model and writeln that model. I can see the model ID there on the smart debug but I've never gotten it to output anything. It will either write an empty array or just crash with access violation. This seems worse than what others are experiencing but I've recently replaced some components in my system and reinstalled the OS so I'm trying to make sure that what I'm experiencing is right - it doesn't seem right to me…


I can TV in and take a look when I get home if you'd like. Just shoot me a PM and we'll discuss further.

Otherwise, could you clarify on it writing an empty array? Are you talking when you do writeln(ogl.getDebug(); ?
Although again, the access violation is..to my understanding specific to OGL, I wouldn't hold your breath on a fix for that like I mentioned though, it's easily corrected and will be second nature on quickly fixing it.

falloutboy12

2015-04-16 11:43:56

From: Clutch
I can TV in and take a look when I get home if you'd like. Just shoot me a PM and we'll discuss further.

Otherwise, could you clarify on it writing an empty array? Are you talking when you do writeln(ogl.getDebug(); ?
Although again, the access violation is..to my understanding specific to OGL, I wouldn't hold your breath on a fix for that like I mentioned though, it's easily corrected and will be second nature on quickly fixing it.

Thanks for the offer - I'll be offline for about 9 hours then I'll try catch you. I can't even get it to output an empty array anymore it's just all access violations but when it was working before it was the result of writeln(ogl.getModels(12…67)) that was never returning anything…

Clutch

2015-04-16 11:46:12

From: falloutboy12
Thanks for the offer - I'll be offline for about 9 hours then I'll try catch you. I can't even get it to output an empty array anymore it's just all access violations but when it was working before it was the result of writeln(ogl.getModels(12…67)) that was never returning anything…


I'll be home from work then, will be awaiting a PM!

Fr3akNL

2015-05-05 17:59:11

Hey are there some examples to use sps in some sort of way with opengl? Or is there another walking method for this?

henryuscola

2015-05-05 22:55:54

this happens all too often

Compiled successfully in 7004 ms.
Paired with SMART[2388]
Error: Access violation
Execution failed.
The following bitmaps were not freed: [0]

Obscurity

2015-05-05 23:43:23

After running the script once, hooking a SMART window, ccomment out glxMapHooks() in core.simba.

You will see a fix for this - as it drives me freaking insane whe writing ogLib.

destinyxx

2015-05-09 17:52:11

Im trying out OGL right now.
Finally got it working, except for the insanely fast mouse movements. It doesnt seem to be fighting the trolls. I had to comment out Camera rotation since it was rotating 45 degree in opposite directions spontaneously. Also had to comment out the fighting troll part since its not exactly working.

Will work more on it update:P

destinyxx

2015-05-09 18:19:35

I am getting access violations regarding regarding obtaining the coordinates of the player in calling(self.x). This happens in both RandomizePoint as well as RandomizePointEllipse.

Fr3akNL

2015-05-10 13:49:12

Any explanation for this?

Compiled successfully in 1872 ms.
Paired with SMART[3924]
Successfully executed.
Exception TLPThread.Destroy: Access violation
Compiled successfully in 2543 ms.
Paired with SMART[3924]
Error: Access violation
Execution failed.
The following bitmaps were not freed: [0]

destinyxx

2015-05-10 22:52:54

From: Fr3akNL
Any explanation for this?

Compiled successfully in 1872 ms.
Paired with SMART[3924]
Successfully executed.
Exception TLPThread.Destroy: Access violation
Compiled successfully in 2543 ms.
Paired with SMART[3924]
Error: Access violation
Execution failed.
The following bitmaps were not freed: [0]


Just try to disable/re-enable smart and try recompiling. About 5-10 times shld make it work.

Fr3akNL

2015-05-11 06:21:29

Yea well I just restart simba and smart and then its workin again. Never had this problem when my ran 32bit version of windows now im on 64. But java 32bit version

Thomas

2015-05-11 09:37:02

From: Clarity
SRL-6 has a lot of useful math functions in math.simba. We might copy those over. Apart from those, ogLib should have everything you need to make what you want! Nevertheless I will work on SRLCompatibility when I have time.


Have you been able to work on SRL compatibility lately?

Obscurity

2015-05-11 11:58:00

The Access Violation has been explained before.

As for SRL compatibility, that might be more in Clarity's court.

Thomas

2015-05-15 09:55:27

Posted this in the JR help section, as it isn't using the ogLib, but someone might be able to help me with it:
https://villavu.com/forum/showthread.php?t=113116

Fr3akNL

2015-05-18 06:40:08

Hey im running into some problems.. For some reason the debug shows the models, but not on the correct position, its like everything is off by 100px to right and 100px down. This makes my bot ALWAYS misclick.. what to do about this?

Clarity

2015-05-18 08:07:37

From: Fr3akNL
Hey im running into some problems.. For some reason the debug shows the models, but not on the correct position, its like everything is off by 100px to right and 100px down. This makes my bot ALWAYS misclick.. what to do about this?


You should not be using the old school layout. Make sure the 3D game world is taking up the entire client width and height.

Thomas

2015-05-19 02:43:57

Hey,

Lets say I have 4 models to chose to attack.
I want to attack the first one random out of the 4.
Then store that one globally.
After that fight I want to chose out of the other 3, and store the new one model it picks globally, replacing the previous.
Then chose out of the new 3 again, and so forth.

This would prevent the script from attacking a monster it just killed a little better.

How should I do this best? Does anyone have any suggestions?

I Always end up with way more code then needed.

PheteyGee

2015-05-19 03:38:11

First of all, great tutorial! really appreciate the time you've put into it. Secondly, my SIMBA works perfectly with SRL6 but as soon as I try and load up with OGL it likes to tell me that it cannot find my java path.

I've reset my Java PATH to where it is multiple times… Any ideas?

Edit: It seems SIMBA/OPENGLPLUGIN only searches for C:\Program Files (x86)\Java\jre7\bin. I had Java 8 Installed; I un installed 8 and just ran Java 7. Works fine now.

Fr3akNL

2015-05-19 06:22:19

From: Clarity
You should not be using the old school layout. Make sure the 3D game world is taking up the entire client width and height.


Hey man thanks it is working now, I also changed the width of the client and working like a charm.

Another question:

In this tutorial, there is shown how to attack a single model ID, if I'm correct.
Now I was trying to make some openGL mining script, but the model of the rocks are the same for every kind of ore. How should I do this? And how to add multiple ID's instead of one?

Thxn in advance!

Fr3akNL

2015-05-19 06:23:30

From: PheteyGee
First of all, great tutorial! really appreciate the time you've put into it. Secondly, my SIMBA works perfectly with SRL6 but as soon as I try and load up with OGL it likes to tell me that it cannot find my java path.

I've reset my Java PATH to where it is multiple times… Any ideas?

Edit: It seems SIMBA/OPENGLPLUGIN only searches for C:\Program Files (x86)\Java\jre7\bin. I had Java 8 Installed; I un installed 8 and just ran Java 7. Works fine now.


I have java 8 and 7 installed and both openGL and smart/srl are working great :)

Obscurity

2015-05-19 12:35:33

From: lovebotter
Hey,

Lets say I have 4 models to chose to attack.
I want to attack the first one random out of the 4.
Then store that one globally.
After that fight I want to chose out of the other 3, and store the new one model it picks globally, replacing the previous.
Then chose out of the new 3 again, and so forth.

This would prevent the script from attacking a monster it just killed a little better.

How should I do this best? Does anyone have any suggestions?

I Always end up with way more code then needed.


Check my profile/recent posts. I explained this recently.

As for the Java posts, you could just copy/duplicate your current Java folder and rename it JRE7.

Thomas

2015-05-19 13:00:18

From: Obscurity
Check my profile/recent posts. I explained this recently.

As for the Java posts, you could just copy/duplicate your current Java folder and rename it JRE7.

I'm pretty sure you mean something different. I dont want to get a tpoint where my last model/fight was and filter that location. I want it to attack a different model entirely.

PheteyGee

2015-05-20 19:24:09

From: Fr3akNL
I have java 8 and 7 installed and both openGL and smart/srl are working great :)


Hmm, next time you load up a SMART client can you tell me if it runs jre7 or 8.1 please. I didn't have 7 installed at all, which was my problem. Would be interesting to see if yours utilises 8 :).

Clarity

2015-05-20 19:32:58

Apologies to everyone, ogLib has changed a lot since the publishing of this tutorial. Now that I have graduated I finally have time to update! Check the first post in the next day or so :)

Clutch

2015-05-21 00:44:54

From: Clarity
Apologies to everyone, ogLib has changed a lot since the publishing of this tutorial. Now that I have graduated I finally have time to update! Check the first post in the next day or so :)


Congratulations!

Renzanity

2015-05-21 01:07:06

From: Clarity
Apologies to everyone, ogLib has changed a lot since the publishing of this tutorial. Now that I have graduated I finally have time to update! Check the first post in the next day or so :)


Congratulations! :D

Fr3akNL

2015-05-23 16:58:19

From: PheteyGee
Hmm, next time you load up a SMART client can you tell me if it runs jre7 or 8.1 please. I didn't have 7 installed at all, which was my problem. Would be interesting to see if yours utilises 8 :).


Hey I run x64 version of Windows 7 and smart is running fine with Java 8(Use the x86 version because x64 somehow spawns "My documents" for me..
Everything is working with 8 except openGL (its throwing an exception) because this requires java 7 for some reason.

Hope this helped

note: All java versions are I use are x86 because I think simba doesn't like x64 java.

edit:

Proof of working: [ATTACH=CONFIG]26014[/ATTACH]

Thomas

2015-05-23 17:27:26

Btw haven't you changed the isbehindinterface name a while ago?
I'm unsure if the guide has been updated aswell, but I remember it wasnt a couple of days ago :)

Yush Dragon

2015-05-30 12:49:36

I'd suggest to make another debugmode for map stuff like Fishing Spots or teleporters and all that.

Ross

2015-05-30 13:59:04

From: Yush Dragon
I'd suggest to make another debugmode for map stuff like Fishing Spots or teleporters and all that.


you mean the icons? those are textures.

Yush Dragon

2015-05-31 02:47:10

No, I mean like the actual fishing spots on the mainscreen. :)

Clarity

2015-05-31 03:00:53

From: Yush Dragon
No, I mean like the actual fishing spots on the mainscreen. :)


Models?


ogl.setDebugMode('models');

Yush Dragon

2015-05-31 15:37:12

I've tried the models but it didn't show me any model id's.

Clarity

2015-05-31 16:03:33

From: Yush Dragon
I've tried the models but it didn't show me any model id's.


Could you explain your issue a bit more, perhaps with screenshots? I don't understand how that would happen if textures worked for you.

Taric

2015-05-31 16:44:20

From: Yush Dragon
I've tried the models but it didn't show me any model id's.


Have you enabled the oglDebug in teh SMART window?

Yush Dragon

2015-05-31 18:38:35

I do. When I used the models debugmode, it didn't show me the fishing spots. It showed me players and when I wanted to let it kill some chickens, it showed me the chicken id's aswell. Fishing spots = the bubbling water that you can click on.

Ross

2015-05-31 19:50:09

From: Yush Dragon
I do. When I used the models debugmode, it didn't show me the fishing spots. It showed me players and when I wanted to let it kill some chickens, it showed me the chicken id's aswell. Fishing spots = the bubbling water that you can click on.


Which, again, are models. Please show screenshots.

Clarity

2015-05-31 20:24:51

I'm happy to announce that code hints and the function list are fully supported now in the latest ogLib update. This should be make starting out with the include a lot easier and lead to faster, more fun scripting!

Enjoy :)

I'll be right back with the guide update now.


Lucidity

2015-05-31 23:19:17

Nvm i'll just send over skype

Clarity

2015-05-31 23:33:52

Updated tutorial to work with latest ogLib. Thanks @Bly for saving me some time! :)

Yush Dragon

2015-06-01 11:46:28

What's up with the access violation?

Yush Dragon

2015-06-01 12:01:09

And here's the picture:

Yush Dragon

2015-06-01 12:04:43

Ok, I found the right modelid.

For people that wonder what the fishingspot modelid is:
fishSpot := ogl.getModels(3122259503);

Yush Dragon

2015-06-01 12:08:11

But still, I don't know why I keep getting this access violation :S

Obscurity

2015-06-01 12:17:32

In computing, a segmentation fault (often shortened to segfault) or access violation is a fault raised by hardware with memory protection, notifying an operating system (OS) about a memory access violation; on x86 computers this is a form of general protection fault.

An operating system, as defined by Google, is the software that supports a computer's basic functions, such as scheduling tasks, executing applications, and controlling peripherals.

If you're still confused, I saved you a further Google, and will define a peripheral device. A peripheral device is generally defined as any auxiliary device such as a computer mouse or keyboard, that connects to and works with the computer in some way. Other examples of peripherals are image scanners, tape drives, microphones, loudspeakers, webcams, and digital cameras.

Yush Dragon

2015-06-01 16:55:02

Ahha.. ok. And now in English? Why does it give me the access violation error?

Lucidity

2015-06-01 18:25:02

Make sure your ogLib is updated to the latest version. An access violation is failure to access.

Clarity

2015-06-01 18:49:36

An access violation is a broad error that can happen in many situations, you'll need to post the code that led to the error in order for us to best help you :)

For instance, you may be trying to work with an empty array of models due to lack of length checking.

Lucidity

2015-06-03 06:29:42

Yush dragon are you still having problems?

edit : removed something i originally posted, forgot something :P

Obscurity

2015-06-03 09:56:32

@Bly

countDown.setTime(0) will reset a countDown.

Krzysztof

2015-06-04 10:31:02

It's alternative to color, yes? Is it like Reflection in Simba style? How is it different from reflection, because I sure as hell I'm interested :D So hard for me to pick colors no matter CTS0/2, this is such a tempting perspective.

I found out sometimes I have to restart the Simba client after running the ogLib script once, as I get Access Violation otherwise.

Also, since it finds a model/texture, and clicks based on it, does similar TPA-randomized clicking occur? I saw randomizePointEllipse in Clarity's example script, does it function well enough, anti-ban-measure speaking?

Also curious. If RS's NXT client get's developed, and perhaps OpenGL support get's dropped (will it?), this method could no longer be viable then?

Other than that, looking forward to try it out. My color-finding is horrible.
Would be nice if somebody could answer a few of my questions.

Cheers and thanks a lot for good work!

EDIT:
I found out you can't have setDebugMode and ogl.getModels going on at the same time. Well, you can, but it's buggy, as in sometimes the setDebugMode blocks the getModels, and vice versa. Managed to workaround this by setDebugMode, wait(X), getmodels, wait(Y), until false.

Obscurity

2015-06-05 06:20:46

If you get AV, hold F9.

Anti-ban is up to the script writers to add. This includes randomizePoint*() which works great.

NXT will drop DX and run on Open/webGL.

setDebumode() should only be called once, soon after setup(). Even still, it shouldn't affect getModels().

Krzysztof

2015-06-05 06:33:30

From: Obscurity
If you get AV, hold F9.

Anti-ban is up to the script writers to add. This includes randomizePoint*() which works great.

NXT will drop DX and run on Open/webGL.

setDebumode() should only be called once, soon after setup(). Even still, it shouldn't affect getModels().


Thanks for replying!
setDebugMode certainly affected getModels. Couldn't get both of them to run, unless I did the mainloop with wait(X) periods between them, for some reason. I could've made a mistake, however.

Will drop DX? I have a pretty old computer, DX works more smoothly, hitches less, and also the game looks quite better. How come it's the one that could get dropped? It's because of the cross-platform and progressively improving driver support?

Obscurity

2015-06-05 06:45:57

OpenGL is cross-platform. DirectX is for Windows. One of the focuses of NXT is to make it cross platform.

Krzysztof

2015-06-05 12:04:59

Thanks for answering, Obscurity.

Now, can somebody tell me what is wrong?

That's the current script. It worked once already, and now for some reason I can't get it to work:
program ogLib;
{$i ogLib\lib\core\core.simba}

var
clientCenter: TPoint;

procedure mainLoop;
var
willowTrees: glModelArray;
clickPoint:tPoint;
begin
willowTrees := ogl.getModels(892814592);
clickPoint:= clientCenter.closest(willowTrees)[0].randomizePointEllipse(15);
clearDebug;
if willowTrees.isEmpty() then
writeln('No trees were found.')
else
clickMouse(clickPoint.x, clickPoint.y, 1);
wait(random(5000, 10000));
end;

begin
ogl.setup();
clientCenter := ogl.getClientMidPoint();
//ogl.setDebugMode('models');

repeat
// clearDebug();
mainLoop;
// writeLn(ogl.getModels(897174394));
// wait(100000)
until false;



end.

Because I'm not getting any compilling errors, however i do get this:
Error: Access violation at line 1369
>>method.simba gets opened<<
line 1369: result:=[self.x+round((funcRadius:=funcDiameter div 2)*(funcRandom:=random())*cos(funcAngle:=random()*(pi*2))),self.y+round((funcRadius*funcRandom)*sin(funcAngle))];

When I replaced randomizePointEllipse(15); with randomizePoint(36, 32)
core.simba gets opened instead, and the error line is 779 because of
Error: "0.26179938779915" is an invalid float at line 779
line 779: oglAngleTolerance:=strToFloat(replaceRegExpr('^$',readINI('Default','oglAngleTolerance','includes/ogLib/lib/core/core.ini'),'0.26179938779914943653855361527335',false));

Obscurity

2015-06-05 14:45:28

You should always do a length check (or .isEmpty()) before trying to access an index in a gl*Array, In case none are visible.

In other words:
if length(willowTrees) then
ClickPoint:=…

We also have mouse.click(tPoint). :-P.

Clarity

2015-06-05 15:17:43

Yeah, you're likely trying to work with arrays that have no contents, hence the access violation error. You will need to make sure you actually find things with the length check in order to proceed, else continue and skip.

Krzysztof

2015-06-05 15:28:00

Thank for replies.

And indeed, I turned the code into:
program ogLib;
{$i ogLib\lib\core\core.simba}

var
clientCenter: TPoint;

procedure mainLoop;
var
willowTrees: glModelArray;
clickPoint:tPoint;
begin
willowTrees := ogl.getModels(892814592);
if willowTrees.isEmpty() then
writeln('No trees were found.')
else
begin
clickPoint:= clientCenter.closest(willowTrees)[0].randomizePoint(36, 32);
clickMouse(clickPoint.x, clickPoint.y, 1);
end;
wait(random(5000, 10000));
end;

begin
ogl.setup();
clientCenter := ogl.getClientMidPoint();
//ogl.setDebugMode('models');

repeat
// clearDebug();
mainLoop;
// writeLn(ogl.getModels(897174394));
// wait(100000)
until false;



end.

And it worked :) Now to find that willowTree model, ugh.

Also, I'm in fixed mode, and it seems model IDs (with setDebugMode(); ) are pretty far off from where the model actually is. My character stands in the middle, but the model id for it is quite far, somewhere on my Quick Prayers/Adrenaline bar. Does that interfere with the script? I checked several IDs but the script keeps clicking somewhere in the middle of the screen, not paying attention to models imo, that's why i'm asking.

EDIT: Yeah, it seems so. The same script, that wasn't clicking properly in Fixed, switched right away to correct in Resizeable RS3 Default view. Sorry if it's included in the tutorial and I hadn't noticed.

I still have a question:
How do I enable the gaussRangeInt(); ? I'm not a fan of randomRange();.

Ross

2015-06-05 16:39:09

From: Krzysztof
…


use @Clarity's OGL highlight tool in Unofficial Development to get models and textures easier. Also, you can just do mouse.click(), see below:

program ogLib;
{$i ogLib\lib\core\core.simba}

var
clientCenter: TPoint;

procedure mainLoop;
var
willowTrees: glModelArray;
begin
willowTrees := ogl.getModels(892814592);
if willowTrees.isEmpty() then
writeln('No trees were found.')
else
mouse.click(clientCenter.closest(willowTrees)[0].randomizePointEllipse(36, 32));
wait(random(5000, 10000));
end;

begin
ogl.setup();
clientCenter := ogl.getClientMidPoint();
//ogl.setDebugMode('models');

repeat
mainLoop;
until false;

end.

Krzysztof

2015-06-05 16:45:26

No, no, don't worry, I have already everything up and running. I found 4(!) IDs for willow trees in draynor village, so I'll gladly use that highlight tool you mentioned.
This method is amazing improvement over color :D

My current remaining questions
1. How do I enable the gaussRangeInt(); ? I'm not a fan of randomRange();.
2. Isn't this ogLib quite better than reflection?

Clarity

2015-06-05 17:17:00

You can port the gaussian code from math in SRL-6, although in a few days I will be releasing SRL compatibility which will allow you to use SRL-6 math, color, and some other functions not available in ogLib by merely putting {DEFINE SRL-6} at the top of your script.

Reflection is much better than OGL, but nobody has released it for RS3 in our public forums, only for OSRS.

Obscurity

2015-06-05 17:21:05

From: Clarity
You can port the gaussian code from math in SRL-6, although in a few days I will be releasing SRL compatibility which will allow you to use SRL-6 math, color, and some other functions not available in ogLib by merely putting {DEFINE SRL-6} at the top of your script.

Reflection is much better than OGL, but nobody has released it for RS3 in our public forums, only for OSRS.


normalRandom(x,y);

Clarity

2015-06-05 17:29:26

From: Obscurity
normalRandom(x,y);

Sure, that works too :)

Krzysztof

2015-06-06 06:34:15

From: Clarity
You can port the gaussian code from math in SRL-6, although in a few days I will be releasing SRL compatibility which will allow you to use SRL-6 math, color, and some other functions not available in ogLib by merely putting {DEFINE SRL-6} at the top of your script.


Awesome! I'm looking forward to it :)

I'll try that normalRandom too, then.

Sir Ducksworthy

2015-06-06 17:21:43

[Error] (2:1): Unable to register function Function GLXMap(var Width, Height: Integer; var X, Y: array[0..3] of Single): Pointer; at line 3
Compiling failed.

:/ lol

Olly

2015-06-06 17:40:59

From: Sir Ducksworthy
[Error] (2:1): Unable to register function Function GLXMap(var Width, Height: Integer; var X, Y: array[0..3] of Single): Pointer; at line 3
Compiling failed.

:/ lol


snip

Justin

2015-06-06 20:48:55

From: Olly
snip


This information was posted in the SRL Members section. I strongly suggest you discuss this in the original thread or make a new thread in the correct location as Sir Ducksworthy might not want this information public.

https://villavu.com/forum/showthread.php?t=85170

Brandon

2015-06-06 20:49:08

From: Sir Ducksworthy
[Error] (2:1): Unable to register function Function GLXMap(var Width, Height: Integer; var X, Y: array[0..3] of Single): Pointer; at line 3
Compiling failed.

:/ lol


You're using pascal script and not Lape.

Krzysztof

2015-06-08 10:48:36

Can you add multiple models to ogl.getModels()? The reason I'm asking is e.g. 3 iron ore rocks with different models. I workarounded it by preparing a if then else statement to use second or third model if first is unavailable/has changed.
I figured if getModels gives an array to do something like [getModels(X) + getModels(Y)] and [getModels(X), getModels(Y)]

What's more, can you ask for the script not to look beyond 4 tiles away from the player's character's model? In one mine there are many rocks, and some copper rocks share the same model id with copper rocks, so the character starts running away crazily in my script when the camera is zoomed out sufficiently.

Cheers and thanks for all the good work!

Clarity

2015-06-08 11:03:39

From: Krzysztof
Can you add multiple models to ogl.getModels()? The reason I'm asking is e.g. 3 iron ore rocks with different models. I workarounded it by preparing a if then else statement to use second or third model if first is unavailable/has changed.
I figured if getModels gives an array to do something like [getModels(X) + getModels(Y)] and [getModels(X), getModels(Y)]

What's more, can you ask for the script not to look beyond 4 tiles away from the player's character's model? In one mine there are many rocks, and some copper rocks share the same model id with copper rocks, so the character starts running away crazily in my script when the camera is zoomed out sufficiently.

Cheers and thanks for all the good work!



procedure clickRock();
var
rockModels: glModelArray;
modelsTPA: TPointArray;
begin
rockModels := ogl.getModels(TCardinalArray([ID1, ID2, ID3 ID4...]));
if (length(rockModels) > 0) then
begin
modelsTPA := ogl.getClientMidPoint().closest(rockModels);
mouse.click(modelsTPA[random(min(3, length(rockModels)))].adjustPosition(0, -15).randomizePointEllipse(14));
end;
end;

Would randomly click the nearest three rocks, or less if there are less than three, with a -15 Y offset and 14 px ellipse randomization.

Obscurity

2015-06-08 12:14:07

Edit: Nvm, my alter-ego was right.

Sir Ducksworthy

2015-06-08 19:02:18

I just got back I havent touched simba in ages

Krzysztof

2015-06-09 09:04:40

From: Clarity
…
Would randomly click the nearest three rocks, or less if there are less than three, with a -15 Y offset and 14 px ellipse randomization.


Wow, that's awesome. Thanks for showing this one :)

Obscurity

2016-07-05 12:23:34

From: Solar
The ProSocks link in the OP needs updating. Still links to v0.3.


Fixed! Thanks. :).

From: Aufi
The issue I'm running into with combat.hasTarget is that it will try to click on dying monsters.


You could store your current target's coordinates. If combat.hasTarget() changes, find make sure the new monster has a new X,Y.