SRL Archive - SRL Archives

Cooking.scar and Magic.scar


Blender

2009-07-09 07:44:18

Here is a function that I find useful, and so do many other cooking noobs sorta like me:

{*******************************************************************************
function FindRangeMS(var x, y: Integer; tol, timeout: Integer): Boolean;
By: xXxBlender3DxXx
Description: Finds the range in the mainscreen and writes the coordinates into
the variables x and y.
*******************************************************************************}

function FindRangeMS(var x, y: Integer; tol, timeout: Integer): Boolean;
var
Mark: Integer;
colors: TIntegerArray;
begin
colors := [6776431, 1976236, 1065359];
Result := False;

if not(FindObjCustom(x, y, ['2'], colors, tol)) then
begin
MarkTime(Mark);

repeat
case Random(2) of
0: MakeCompass(Random(360));
1: SetHighest(RBool);
2: Sleep(500 + Random(1000));
end;

if (FindObjCustom(x, y, ['2'], colors, tol)) then
begin
Result := True;
Break;
end;
until (FindObjCustom(x, y, ['2'], colors, tol)) or (FindNormalRandoms) or (TimeFromMark(Mark) > timeout);
end else Result := True;
end;

Anything to say?

Also, from my *cough* awesome *cough* mager (WIP).
It may be small, but it works!


{*******************************************************************************
function IsCasting: Boolean;
By: xXxBlender3DxXx
Description: Blindly checks to see if you are casting a spell (for those so lazy
they reject reflection's awsomeness).
*******************************************************************************}

function IsCasting: Boolean;
var
XP1, XP2: Integer;

begin
Result := False;

XP1 := GetXP('magic');
Wait(2000 + Random(500));
XP2 := GetXP('magic');

if not(XP1 = XP2) then Result := True;
end;

Any comments on these two (more on their way)?

[JS]

2009-07-09 08:06:11

woot thank you saves me time on my cooker. =]

marpis

2009-07-09 13:13:12

Nice idea for IsCasting! :)
But i'd rather check rune amount, because it's kinda botlike to hover magic skill all the time

i think you should check uptext 'Range' rather than '2'.

Blender

2009-07-10 05:40:04

Lol thanks.

This the original function (IsCasting1), but SCAR had an error every time I used any sort of Bitmap finding.

This is what I use (dies whenever I use IsCasting1 twice, idk why).


function IsCasting1: boolean;
var A1, A2, G1, G2: Integer;
begin
srl_FreeBitmaps;
A1 := RuneAmount('inv', RuneType);
G1 := GetAnimation;
srl_FreeBitmaps;

sleep(RandomRange(2000, 2500));

srl_FreeBitmaps;
A2 := RuneAmount('inv', RuneType);
G2 := GetAnimation;
srl_FreeBitmaps;

if (not(A1 = A2) or (G1 = G2)) then
begin
Result := true;
end else
begin
Result := false;
end;
end;

function IsCasting2: Boolean;
var
XP1, XP2: Integer;

begin
Result := False;

XP1 := GetXP('magic');
Wait(2000 + Random(500));
XP2 := GetXP('magic');

if not(XP1 = XP2) then Result := True;
end;

function IsCasting: Boolean;
begin
case Random(1) of
0: Result := IsCasting1;
1: Result := IsCasting2;
end;
end;

Also, the range has no UpText; just Walk Here / 2 More options.

Awkwardsaw

2009-07-10 05:52:45

it looks a good start, keep up the good work, and commitment.

and for the mage function, i would use getrune or something like that, it would be better and more failsafish

Blumblebee

2009-07-10 05:56:03

try this instead:
Function IsCasting1: boolean;
var A1, A2, G1, G2, t: Integer;
begin
A1 := RuneAmount('inv', RuneType);
G1 := GetAnimation;
t := GetsystemTime;
while GetSystemTime-t > RandomRange(2000, 2500) do
begin
A2 := RuneAmount('inv', RuneType);
G2 := GetAnimation;
Result := (A1 <> A2) or (G1 = G2);
if Result then Break;
end;
srl_FreeBitmaps;
end;

as for the problem with it dying, that might be due to the amount of times your free srl bitmaps (I have never used bitmaps lol but just a thought)

Blender

2009-07-10 05:57:43

I've only had this work if I free it every single time before and after the function.

It's really weird.