Results 1 to 9 of 9

Thread: OGL Progress Reports

  1. #1
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Thumbs up OGL Progress Reports

    Hi, just sharing what I use for progress reports. You can put this into any OGL script and it tracks XP extremely well, plus has the benefits of being really pretty.


    Simba Code:
    program progressReport;

    var
      startXp: integer;
      xpIcon: glTextureArray;
      xpBox: TBox;

    procedure setupScript;
    begin
      xpIcon:= ogl.getTextures({put the skill texture ID here});
      if (not xpIcon.isEmpty()) then
      begin
        xpBox:=intToBox(xpIcon[0].bounds.x1 - 150, xpIcon[0].bounds.y1, xpIcon[0].bounds.x2, xpIcon[0].bounds.y2);
        startXp := explode('+', ogl.getChars(xpBox).toString())[0].parseInt();
      end
      else
      begin
        writeln('Enable your XP counter!');
        terminateScript;
      end;
    end;

    procedure progressReport();
    var
      currentXp: uint32;
      paintXp, xpHour :integer;
    begin
      currentXp := explode('+', ogl.getChars(xpBox).toString())[0].parseInt();
      paintXp := currentXp - startXp;
      xpHour := round(paintXp * (3600.0 / (getTimeRunning / 1000.0)));
      smart.__graphics.clear;
      smart.__graphics.DrawText(toStr(paintXp) + ' xp gained', 'smallChars', point(11, 11), 1);
      smart.__graphics.DrawText(toStr(paintXp) + ' xp gained', 'smallChars', point(10, 10), clWhite);
      smart.__graphics.DrawText(toStr(xpHour) + ' xp/hr', 'smallChars', point(11, 29), 1);
      smart.__graphics.DrawText(toStr(xpHour) + ' xp/hr', 'smallChars', point(10, 28), clWhite);
    end;

    IDs (thank you @Justin):
    • Attack: 16918
    • Strength: 39319
    • Defence: 41952
    • Range: 20999
    • Magic: 51211
    • Hitpoints: 38262
    • Thieving: 25506
    • Crafting: 33559
    • Fletching: 19315
    • Mining: 16653
    • Smithing: 31773
    • Fishing: 54626
    • Runecrafting: 33877
    • Slayer: 54733
    • Farming: 34536
    • Construction: 54189
    • Hunter: 30306
    • Summoning: 37582
    • Prayer: 23912
    • Agility: 29580
    • Herblore: 54427
    • Cooking: 47376
    • Firemaking: 46008
    • Woodcutting: 44243
    • Dungeoneering: 58390
    • Divination: 22933
    • All Combat: 31110
    • Overall: 48705
    Last edited by Justin; 05-04-2015 at 09:40 AM.

  2. #2
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    You should add a length check in your procedure setupScript; procedure

    Forum account issues? Please send me a PM

  3. #3
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by Justin View Post
    You should add a length check in your procedure setupScript; procedure
    Good call, I usually just let the access violations speak for themselves in situations like that
    I'll add one.

  4. #4
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    I would make your setup procedure a function that just returns current XP. Or better yet, there should be something like a getXP(skill: int): integer; function added to the include.

    currentXP := getXP(123456);

  5. #5
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Attack: 16918
    Strength: 39319
    Defence: 41952
    Range: 20999
    Magic: 51211
    Hitpoints: 38262
    Thieving: 25506
    Crafting: 33559
    Fletching: 19315
    Mining: 16653
    Smithing: 31773
    Fishing: 54626
    Runecrafting: 33877
    Slayer: 64733
    Farming: 34536
    Construction: 54189
    Hunter: 30306
    Summoning: 37582
    Prayer: 23912
    Agility: 29580
    Herblore: 54427
    Cooking: 47376
    Firemaking: 46008
    Woodcutting: 44243
    Dungeoneering: 58390
    Divination: 22933
    All Combat: 31110
    Overall: 48705

    Forum account issues? Please send me a PM

  6. #6
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by Justin View Post
    Attack: 16918
    Strength: 39319
    Defence: 41952
    Range: 20999
    Magic: 51211
    Hitpoints: 38262
    Thieving: 25506
    Crafting: 33559
    Fletching: 19315
    Mining: 16653
    Smithing: 31773
    Fishing: 54626
    Runecrafting: 33877
    Slayer: 64733
    Farming: 34536
    Construction: 54189
    Hunter: 30306
    Summoning: 37582
    Prayer: 23912
    Agility: 29580
    Herblore: 54427
    Cooking: 47376
    Firemaking: 46008
    Woodcutting: 44243
    Dungeoneering: 58390
    Divination: 22933
    All Combat: 31110
    Overall: 48705
    Thank you, will edit top post. Can you move this to another section in public that's appropriate? I wasn't sure if SRL snippets was a good place for it.

  7. #7
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Quote Originally Posted by Ross View Post
    Thank you, will edit top post. Can you move this to another section in public that's appropriate? I wasn't sure if SRL snippets was a good place for it.
    No problem.

    Thread moved

    Forum account issues? Please send me a PM

  8. #8
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    @Justin, your slayer texture is incorrect. See below.

    A quick note - those textures share with the skills tab and sometimes monster weakness. The ranged weakness icon is the same as the ranged XP, for example. However, the XP tracker is drawn last and therefore will appear last in the array. So, you're better off using:
    Simba Code:
    xpIcon[high(xpIcon)].bounds.x1

    Edit: However, I got bored...
    Simba Code:
    function getSkillTexture(funcString:string):int32;
      begin
        case funcString:=lowercase(funcString) of
          'agility':result:=29580;
          'attack':result:=16918;
          'combat':result:=31110;
          'constitution','hitpoints':result:=38262;
          'construction':result:=54189;
          'cooking':result:=47376;
          'crafting':result:=33559;
          'defence':result:=41952;
          'divination':result:=22933;
          'dungeoneering':result:=58390;
          'farming':result:=34536;
          'firemaking':result:=46008;
          'fishing':result:=54626;
          'fletching':result:=19315;
          'herblore':result:=54427;
          'hunter':result:=30306;
          'magic':result:=51211;
          'mining':result:=16653;
          'overall':result:=48705;
          'prayer':result:=23912;
          'ranged':result:=20999;
          'runecrafting':result:=33877;
          'slayer':result:=54733;
          'strength':result:=39319;
          'smithing':result:=31773;
          'summoning':result:=37582;
          'thieving':result:=25506;
          'woodcutting':result:=44243;
        end;
      end;


    function getXPTracker(funcString:string):int32;
      var
        funcBounds:tBox;
        funcID:int32;
        funcPointer:pointer;
        funcPointerIndex,
          funcPointerSize:uInt32=0;
        funcText:string;
      begin
        if funcID:=getSkillTexture(funcString) then
          begin
            {
              Because we know that the skill icon we're looking for is one of the
              last drawn textures, we set the pointer to the end and work backward
              to save time.
            }

            funcPointer:=glTextures(funcPointerSize)+(36*(funcPointerSize-1));
            if funcPointer<>nil then
              begin
                {
                  Again, because we know that the texture we're looking for will
                  appear very close to the end, it should be safe to only need to
                  search one fifth of the textures.
                }

                for funcPointerIndex to funcPointerSize div 5 do
                  begin
                    {
                      funcPointer^ contains the ID of the current texture. Because
                      glTextures are 36 bytes, (funcPointer-36)^ contains the ID of
                      the previous texture.

                      The 0+ tells it ahead of time that we're dealing with an
                      integer. Without it, we'd get an access violation.

                      (funcPointer+28)^ and (funcPointer+20)^ contain the X2 and X1
                      of the current texture.
                    }


                    if (funcPointer^=funcID) and ((0+(funcPointer+28)^-(funcPointer+20)^=25)) then
                      begin
                        {
                          (funcPointer+20)^, (funcPointer+24)^, (funcPointer+28)^,
                          and (funcPointer+32)^ contain the bounds of the current
                          texture.
                        }

                        funcBounds:=[0+(funcPointer+20)^-200,(funcPointer+24)^,(funcPointer+28)^,(funcPointer+32)^];
                        break;
                      end;
                    {
                      Because glTextures are 36 bytes, and we're working backward,
                      we subtract 36 from the current pointer to reach the previous
                      one.
                    }

                    funcPointer:=funcPointer-36;
                  end;
                {
                  If funcPointerIndex were to be greater then one fifth of the
                  funcPointerSize, odds are we didn't find the texture we were
                  looking for.
                }

                if funcPointerIndex<=funcPointerSize div 5 then
                  begin
                    {
                      Again, because we know that the XP tracker is one of the last
                      drawn interfaces, we can start at the end of the pointer and
                      work backward to save time.
                    }

                    funcPointer:=glFonts(funcPointerSize)+(48*(funcPointerSize-1));
                    if funcPointer<>nil then
                      begin
                        {
                          See two notes below for why we should only need to search
                          half of the chars.
                        }

                        for funcPointerIndex:=0 to funcPointerSize div 2 do
                          begin
                            {
                              (funcPointer+8)^ and (funcPointer+12)^ contain the X
                              and Y of the current texture.
                            }

                            if pointInBox([(funcPointer+8)^,(funcPointer+12)^],funcBounds) then
                              begin
                                funcText:=char((funcPointer+16)^)+funcText;
                              end
                            {
                              If we found text within the area, but the next char
                              isn't in the desired bounds, we've no reason to
                              proceed.
                            }

                            else if (funcText<>'') and (funcText[1]<>'+') then
                              begin
                                result:=explode('+',funcText)[0].parseInt();
                                break;
                              end;
                            {
                              Although glChars are 48 bytes, we know that the text
                              drawn by the XP tracker has a shadow, and we can
                              therefore skip every other char.
                            }

                            funcPointer:=funcPointer-96;
                          end;
                      end;
                  end;
              end;
          end;
        exit(result);
      end;

    Simba Code:
    writeLN(getXPTracker('slayer'));

    I might just add something like this into ogLib, if you don't mind? Not the progress report, but getting the XP tracker.




    Skype: obscuritySRL@outlook.com

  9. #9
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Absolutely, go for it! Awesome work

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •