SRL Archive - Reflection Development

Reflection Fixes


vilon

2009-07-22 15:03:51

GameTab.scar

R_GetMMLevels('hp') got broken with the latest runescape changes. Fixed:
{*******************************************************************************
function R_GetMMLevels(Which: string): Integer;
By: lordsaturn, fixed by vilon
Description: Returns the current value at the designated MM spot.
*******************************************************************************}
function R_GetMMLevels(Which: string): Integer;
begin
Result := -1;
case LowerCase(Which) of
'hitpoints', 'hp': Result := 748;
'prayer', 'pp' : Result := 749;
'run', 'energy' : Result := 750;
else SRL_Warn('R_GetMMLevels', 'Invaild string.', -3);
end;
Result := StrToIntDef(GetInterfaceText(Result, 4 + 1 * Integer(Result <> 749)), -1);
end;

Timing.scar

Renamed:

WaitAnimation -> WaitForAnim
WaitAnimationBool -> WaitForAnimBool

Also fixed some errors and credits/function-list. Full Timing.scar:
//------------------------------------------------------------------\\
//-- Scar Non-Standard Resource Library --||
//-- ยป Reflection Routines - Timing --||
//------------------------------------------------------------------//
// * function R_WaitOptionMulti(S: TStringArray; Time: Integer): Boolean; // * by Marpis, N1ke! & vilon
// * function R_WaitOption(S: string; Time: Integer): Boolean; // * by Marpis, N1ke! & vilon
// * function R_WaitActionMulti(S: TStringArray; Time: Integer): Boolean; // * by vilon
// * function R_WaitAction(S: string; Time: Integer): Boolean; // * by vilon
// * function R_WaitUpTextMulti(S: TStringArray; Time: Integer): Boolean; // * by Marpis, N1ke! & vilon
// * function R_WaitUpText(S: string; Time: Integer): Boolean; // * by Marpis, N1ke! & vilon
// * function WaitForAnim(Time: Integer): Integer; // * by lordsaturn & vilon
// * function WaitForAnimBool(Time: Integer): Boolean; // * by vilon
// * function WaitForOption(Option: string; Timeout: Integer): Boolean; // * by Drags111
// * function WaitForMenu(Time: Integer): Boolean; // * by Drags111 & vilon

{*******************************************************************************
function R_WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
By: Marpis, N1ke! & vilon
Description: Waits for a TStringArray of Options and selects one of them.
*******************************************************************************}
function R_WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
var
T: Integer;
begin
Result := False;
T := GetSystemTime + Time;
repeat
Result := R_ChooseOptionMulti(S);
Wait(20 + Random(10));
until(Result or (GetSystemTime > T));
end;

{*******************************************************************************
function R_WaitOption(S: string; Time: Integer): Boolean;
By: Marpis, N1ke! & vilon
Description: Waits for an Option and selects it.
*******************************************************************************}
function R_WaitOption(S: string; Time: Integer): Boolean;
begin
Result := R_WaitOptionMulti([S], Time);
end;

{*******************************************************************************
function R_WaitActionMulti(S: TStringArray; Time: Integer): Boolean;
By: vilon
Description: Waits for a TStringArray of Actions and selects one of them.
*******************************************************************************}
function R_WaitActionMulti(S: TStringArray; Time: Integer): Boolean;
var
T: Integer;
begin
Result := False;
T := GetSystemTime + Time;
repeat
Result := R_ChooseActionMulti(S);
Wait(10 + Random(20));
until(Result or (GetSystemTime > T));
end;

{*******************************************************************************
function R_WaitAction(S: string; Time: Integer): Boolean;
By: vilon
Description: Waits for an Action and selects it.
*******************************************************************************}
function R_WaitAction(S: string; Time: Integer): Boolean;
begin
Result := R_WaitActionMulti([S], Time);
end;

{*******************************************************************************
function R_WaitUpTextMulti(S: TStringArray; Time: Integer): Boolean;
By: Marpis, N1ke! & vilon
Description: Waits for a TStringArray of UpText, returns true if found.
*******************************************************************************}
function R_WaitUpTextMulti(S: TStringArray; Time: Integer): Boolean;
var
T: Integer;
begin
Result := False;
T := GetSystemTime + Time;
repeat
Result := R_IsUpTextMulti(S);
Wait(20 + Random(20));
until(Result or (GetSystemTime > T));
end;

{*******************************************************************************
function R_WaitUpText(S: string; Time: Integer): Boolean;
By: Marpis, N1ke! & vilon
Description: Waits for an UpText, returns true if found.
*******************************************************************************}
function R_WaitUpText(S: string; Time: Integer): Boolean;
var
T: Integer;
begin
Result := False;
T := GetSystemTime + Time;
repeat
Result := R_IsUpText(S);
Wait(20 + Random(20));
until(Result or (GetSystemTime > T));
end;

{*******************************************************************************
function WaitForAnim(Time: Integer): Integer;
By: lordsaturn & vilon
Description: Waits for an animation with a timeout. If an animation occurs, the
value will be returned, else returns -1.
*******************************************************************************}
function WaitForAnim(Time: Integer): Integer;
var
T: Integer;
begin
Result := -1;
T := GetSystemTime + Time;
repeat
Result := GetAnimation;
Wait(100);
until((Result <> -1) or (GetSystemTime > T));
end;

{*******************************************************************************
function WaitForAnimBool(Time: Integer): Boolean;
By: vilon
Description: Waits for an animation with a timeout. Returns true on animation.
*******************************************************************************}
function WaitForAnimBool(Time: Integer): Boolean;
begin
Result := (WaitForAnim(Time) <> -1);
end;

{*******************************************************************************
function WaitForOption(Option: string; Timeout: Integer): Boolean;
By: Drags111
Description: Waits till the option exists or times out.
*******************************************************************************}
function WaitForOption(Option: string; Timeout: Integer): Boolean;
var
a: Integer;
begin
while not OptionExists(Option) do
begin
if GetSystemTime - a > Timeout then Exit;
Wait(100+Random(50));
end;
Result := True;
end;

{*******************************************************************************
function WaitForMenu(Time: Integer): Boolean;
By: Drags111 & vilon
Description: Waits until the menu is open or times out.
*******************************************************************************}
function WaitForMenu(Time: Integer): Boolean;
var
T: Integer;
begin
Result := False;
T := GetSystemTime + Time;
repeat
Result := IsOptionMenuOpen;
Wait(10 + Random(20));
until(Result or (GetSystemTime > T));
end;

Characters.scar

WaitForAnim -> Is now in Timing.scar
CharAnimBool -> Is now WaitForAnimBool in Timing.scar

mormonman

2009-07-23 01:59:10

I do believe we already did all of these.

vilon

2009-07-23 12:26:26

From: mormonman
I do believe we already did all of these.


Yes, but these are new fixes.

vilon

2009-07-30 01:02:02

I noticed that R_GetMMLevels() have been comitted, but the rest still needs to. Could somebody do this, please?
Especially since some functions in Timing.scar doesn't function properly in the current revision.

mormonman

2009-07-30 01:03:42

i got it… but im not taking those other ones out.

vilon

2009-07-30 01:08:03

From: mormonman
i got it… but im not taking those other ones out.


Great. If you're talking about the changes to Characters.scar then either do as suggested in #1, or remove these two from the posted Timing.scar:

// * function WaitForAnim(Time: Integer): Integer;
// * function WaitForAnimBool(Time: Integer): Boolean;

mormonman

2009-07-30 01:18:12

meh, i will just change all of my scripts to WaitForAnimBool…

vilon

2009-07-30 01:33:50

While you're at it, FindGroundItem() in GroundItems.scar, gives a type mismatch error, as it tries to return the TGroundItem instead of a Boolean.
I think it should look like this (fixed):

{*******************************************************************************
function FindGroundItem(var Item : TGroundItem; ID: Integer; maxSL) : Boolean;
By: mormonman
Description: Just looks for the closest item with the ID.
*******************************************************************************}
function FindGroundItem(var Item : TGroundItem; ID, maxSL: Integer) : Boolean;
var
I : TGroundItemArray;
begin
Result := FindGroundItems(I, [ID], maxSL);
end;

mormonman

2009-07-30 02:07:57

I fixed it(yours won't work)… committing now.

vilon

2009-07-30 13:17:39

From: mormonman
I fixed it(yours won't work)… committing now.


Nice, I never looked into those recent functions. At least works now, great :p

mormonman

2009-07-30 20:05:52

yeah, i added like 4 functions(one was rm's) these past 2 days, and i need to be able to explain them…