PDA

View Full Version : RS07_GetStat



KeepBotting
03-21-2013, 10:57 PM
function RS07_GetStat(stat:string; bottom:integer):integer;

Returns the value of the stat specified by string stat and integer bottom.

Skill strings:

attack
strength
defense
ranged
prayer
magic
runecrafting
hitpoints
agility
herblore
thieving
crafting
fletching
mining
smithing
fishing
cooking
firemaking
woodcutting

function RS07_GetStat(stat:string; bottom:integer):integer;
var x, y, ox, oy, ox2, oy2, col, row, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9:integer;
begin
s0 := BitmapFromString(5, 8,
'000000FFFFFFFFFFFFFFFFFF000000FFFFFF0000000000000 00000' +
'FFFFFFFFFFFF000000000000000000FFFFFFFFFFFF0000000 00000' +
'000000FFFFFFFFFFFF000000000000000000FFFFFFFFFFFF0 00000' +
'000000000000FFFFFFFFFFFF000000000000000000FFFFFF0 00000' +
'FFFFFFFFFFFFFFFFFF000000');
s1 := BitmapFromString(3, 8,
'000000FFFFFF000000FFFFFFFFFFFF000000000000FFFFFF0 00000' +
'000000FFFFFF000000000000FFFFFF000000000000FFFFFF0 00000' +
'000000FFFFFF000000FFFFFFFFFFFFFFFFFF');
s2 := BitmapFromString(5, 8,
'000000FFFFFFFFFFFFFFFFFF000000FFFFFF0000000000000 00000' +
'FFFFFF000000000000000000000000FFFFFF0000000000000 00000' +
'FFFFFF000000000000000000FFFFFF000000000000000000F FFFFF' +
'000000000000000000FFFFFF000000000000000000000000F FFFFF' +
'FFFFFFFFFFFFFFFFFFFFFFFF');
s3 := BitmapFromString(4, 8,
'000000FFFFFFFFFFFF000000FFFFFF000000000000FFFFFF0 00000' +
'000000000000FFFFFF000000FFFFFFFFFFFF0000000000000 00000' +
'000000FFFFFF000000000000000000FFFFFFFFFFFF0000000 00000' +
'FFFFFF000000FFFFFFFFFFFF000000');
s4 := BitmapFromString(4, 8,
'FFFFFF000000000000000000FFFFFF000000000000000000F FFFFF' +
'000000000000000000FFFFFF000000FFFFFF000000FFFFFF0 00000' +
'FFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFF000000000000F FFFFF' +
'000000000000000000FFFFFF000000');
s5 := BitmapFromString(4, 8,
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000F FFFFF' +
'000000000000000000FFFFFFFFFFFFFFFFFF0000000000000 00000' +
'000000FFFFFF000000000000000000FFFFFFFFFFFF0000000 00000' +
'FFFFFF000000FFFFFFFFFFFF000000');
s6 := BitmapFromString(5, 8,
'000000000000FFFFFFFFFFFF000000000000FFFFFF0000000 00000' +
'FFFFFFFFFFFF000000000000000000000000FFFFFF000000F FFFFF' +
'FFFFFF000000FFFFFFFFFFFF000000000000FFFFFFFFFFFF0 00000' +
'000000000000FFFFFFFFFFFF000000000000000000FFFFFF0 00000' +
'FFFFFFFFFFFFFFFFFF000000');
s7 := BitmapFromString(4, 8,
'FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000FFFFFF0 00000' +
'000000FFFFFF000000000000000000FFFFFF000000000000F FFFFF' +
'000000000000000000FFFFFF000000000000FFFFFF0000000 00000' +
'000000FFFFFF000000000000000000');
s8 := BitmapFromString(5, 8,
'000000FFFFFFFFFFFFFFFFFF000000FFFFFF0000000000000 00000' +
'FFFFFFFFFFFF000000000000000000FFFFFF000000FFFFFFF FFFFF' +
'FFFFFF000000FFFFFF000000000000000000FFFFFFFFFFFF0 00000' +
'000000000000FFFFFFFFFFFF000000000000000000FFFFFF0 00000' +
'FFFFFFFFFFFFFFFFFF000000');
s9 := BitmapFromString(5, 8,
'000000FFFFFFFFFFFFFFFFFF000000FFFFFF0000000000000 00000' +
'FFFFFFFFFFFF000000000000000000FFFFFF000000FFFFFF0 00000' +
'000000FFFFFF000000000000FFFFFFFFFFFFFFFFFF0000000 00000' +
'000000000000FFFFFF000000000000000000000000FFFFFF0 00000' +
'000000000000000000FFFFFF');
if (not(GetColor(592, 175) = 2763390)) then
begin
Mouse(577, 178, 10, 10, True);
end;
if (stat = 'attack') or (stat = 'strength') or (stat = 'defense') or (stat = 'ranged') or (stat = 'prayer') or (stat = 'magic') or (stat = 'runecrafting') then
col := 1;
if (stat = 'hitpoints') or (stat = 'agility') or (stat = 'herblore') or (stat = 'thieving') or (stat = 'crafting') or (stat = 'fletching') then
col := 2;
if (stat = 'mining') or (stat = 'smithing') or (stat = 'fishing') or (stat = 'cooking') or (stat = 'firemaking') or (stat = 'woodcutting') then
col := 3;
if (stat = 'attack') or (stat = 'hitpoints') or (stat = 'mining') then
row := 1;
if (stat = 'strength') or ( stat = 'agility') or (stat = 'smithing') then
row := 2;
if (stat = 'defense') or (stat = 'herblore') or (stat = 'fishing')then
row := 3;
if (stat = 'ranged') or (stat = 'thieving') or (stat = 'cooking') then
row := 4;
if (stat = 'prayer') or (stat = 'crafting') or (stat = 'firemaking') then
row := 5;
if (stat = 'magic') or (stat = 'fletching') or (stat = 'woodcutting') then
row := 6;
if (stat = 'runecrafting') then
row := 7;
if (bottom = 0) then
begin
ox := 520 + (col*64);
oy := 179 + (row*31);
end;
if (bottom = 1) then
begin
ox := 532 + (col*64);
oy := 191 + (row*31);
end;
ox2 := ox + 9;
oy2 := oy + 9;
if (FindBitmapMaskTolerance(s1, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := 10;
if (FindBitmapMaskTolerance(s2, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := 20;
if (FindBitmapMaskTolerance(s3, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := 30;
if (FindBitmapMaskTolerance(s4, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := 40;
if (FindBitmapMaskTolerance(s5, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := 50;
if (FindBitmapMaskTolerance(s6, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := 60;
if (FindBitmapMaskTolerance(s7, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := 70;
if (FindBitmapMaskTolerance(s8, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := 80;
if (FindBitmapMaskTolerance(s9, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := 90;
ox := ox + 6;
ox2 := ox + 9;
if (FindBitmapMaskTolerance(s0, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := Result+0;
if (FindBitmapMaskTolerance(s1, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := Result+1;
if (FindBitmapMaskTolerance(s2, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := Result+2;
if (FindBitmapMaskTolerance(s3, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := Result+3;
if (FindBitmapMaskTolerance(s4, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := Result+4;
if (FindBitmapMaskTolerance(s5, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := Result+5;
if (FindBitmapMaskTolerance(s6, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := Result+6;
if (FindBitmapMaskTolerance(s7, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := Result+7;
if (FindBitmapMaskTolerance(s8, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := Result+8;
if (FindBitmapMaskTolerance(s9, x, y, ox, oy, ox2, oy2, 10, 240)) then
Result := Result+9;
end;

Can be used like this:


function RS07_GetHitpoints:integer;
var HP1, HP2:integer;
begin
HP1 := (RS07_GetStat('hitpoints', 0));
HP2 := (RS07_GetStat('hitpoints', 1));
if (HP1 > 0) and (HP2 > 0) then
Result := round((HP1 / HP2) * 100);
end;


And then just call it:

if RS07_GetHitpoints < 80 then EatFood;

Le Jingle
03-21-2013, 11:06 PM
... Already in SRL-OSR, no?
https://github.com/SRL/SRL-OSR

Olly
03-21-2013, 11:14 PM
I don't even know what your trying to do in that code, and for one you should learn case statments and arrays and then finally ocr can read numbers perfectly.

Here's something i did awhile back for SRL6, see the difference in code length + mine will either grab the static level or the dynamic level. :)

function TTabStats.getSkillLevel(skill: integer; skillType: integer = SKILL_STATIC): Integer;
var
p: tpoint;
b, tpaB: tbox;
s: string;
tpa: TPointArray;
atpa: T2DPointArray;
begin
result := - 1;

if (not self.open()) then
exit;

getMousePos(p.x, p.y);
b := skillToBox(skill);

// mouse could be already over a skill which would mess up readings.
if pointInBox(p, self.bounds) then
mouse(point(261, 219).rand(50));

// +23 so we dont pick false colors from the skill icons
if (not (findColors(tpa, 36095, b.x1+23, b.y1, b.x2, b.y2))) then
exit;

atpa := splitTPAEx(tpa, 8, 1);
sortATPAFromFirstPoint(atpa, point(b.x1 + 23, b.y1));

if (length(atpa) <> 2) then
begin
subDebug('GetSkillLevel: found to many color points, unable to grab level');
exit(- 1);
end;

tpaB := getTPABounds(atpa[skillType]);

with tpaB do
s := getTextAtEx(x1, y1, x2+1, y2+1, 0, 5, 5, 36095, 5, statChars);

result := strToIntDef(ExtractFromStr(tmpS, Numbers), - 1);

if (result = - 1) then
subDebug('getSkillLevel: Failed acquiring skill level')
else
debug('getSkillLevel returned: ' + intToStr(result));
end;

The Bot
04-12-2013, 09:39 AM
Why was he infracted? He was just trying to help...? D:

Le Jingle
04-12-2013, 09:47 AM
Why was he infracted? He was just trying to help...? D:

It appears Hobbit removed content that violated the rules of these forums.
Note: You can ask however you may please for most anything, but if it violates the rules on these forums, then there is warning/consequence depending on the situation.

~Lj