SRL Archive - Reflection Development

Reflection stuff


Shuttleu

2010-12-08 18:05:03

well i made a few changes to improve things
and instead of releasing a new thread for the new functions or updating each thread i though i could have one thread for all of my banking stuff

Bank:
  BANK_TAB_ACTIVE                                       = 1419;
BANK_TAB_ADD_TEXTURE = 1435;

{*******************************************************************************
function NumberOfBankTabs: Integer;
By: Shuttleu
Description: Returns how many bank tabs you have.
*******************************************************************************}
function R_NumberOfBankTabs: Integer;
var
AddExists: Boolean;
i, x: Integer;
begin
AddExists:= False;
for i:=63 downto 47 do
begin
x:= GetInterfaceComponentTextureID(INTERFACE_BANK, i);
AddExists:= (x = BANK_TAB_ADD_TEXTURE);
if AddExists then Break;
end;
if (not(AddExists)) then
Result:= 9
else
begin
InIntArrayEx([61, 59, 57, 55, 53, 51, 49, 47], x, i);
Result:= (x+1)
end;
end;

{*******************************************************************************
function R_BankTabExists(TabNum: Integer): Boolean;
By: Shuttleu
Description: Checks if the bank tab exists.
*******************************************************************************}
function R_BankTabExists(TabNum: Integer): Boolean;
begin
Result:= (TabNum<=R_NumberOfBankTabs);
end;

{*******************************************************************************
function R_BankTabID(TabNum: Integer): Integer;
By: Shuttleu
Description: Returns the interface component id for the tab number.
*******************************************************************************}
function R_BankTabID(TabNum: Integer): Integer;
begin
case TabNum of
1: Result:= 63;
2: Result:= 61;
3: Result:= 59;
4: Result:= 57;
5: Result:= 55;
6: Result:= 53;
7: Result:= 51;
8: Result:= 49;
9: Result:= 47;
end;
end;

{*******************************************************************************
function R_BankTab(TabNum: Integer): Boolean;
By: Shuttleu
Description: Clicks on the bank tab if it exists.
*******************************************************************************}
function R_BankTab(TabNum: Integer): Boolean;
var
x, ID: Integer;
Position: TBox;
begin
ID:= R_BankTabID(TabNum);
x:= GetInterfaceComponentTextureID(INTERFACE_BANK, ID);
if ((not(x=BANK_TAB_ADD_TEXTURE)) and (TabNum<=R_NumberOfBankTabs)) then
begin
Position:= GetInterfaceComponentRelativePosition(INTERFACE_BANK, ID);
Mouse(RandomRange(Position.x1, Position.x2), RandomRange(Position.y1, Position.y2)
, 0, 0, True);
Result:= True;
end;
end;

{*******************************************************************************
function R_CurrentBankTab: Integer;
By: Shuttleu
Description: Returns which tab you are currntly on.
*******************************************************************************}
function R_CurrentBankTab: Integer;
var
i, x: Integer;
begin
for i:= 62 downto 45 do
begin
x:= GetInterfaceComponentTextureID(INTERFACE_BANK, i);
if (x = BANK_TAB_ACTIVE) then break;
end;
if InIntArrayEx([62, 60, 58, 56, 54, 52, 50, 48, 46], x, i) then
Result:= (x+1) else Result:= -1;
end;

{*******************************************************************************
Function ReadyToTypeBank: Boolean;
By: Shuttleu
Description: Returns true if it is on the item search screen.
*******************************************************************************}
function ReadyToTypeBank: Boolean;
begin
Result:= ((Pos('ter the name of the item', GetInterfaceComponentText(752, 4))>0) and (GetInterfaceComponentText(752, 5)=''));
end;

{*******************************************************************************
function R_ItemExistsInBank(ID: Integer; var Slot: Integer): Boolean;
By: Shuttleu
Description: Returns true if the item ID exists in bank also returns slot.
*******************************************************************************}
function R_ItemExistsInBank(ID: Integer; var Slot: Integer): Boolean;
var
i: Integer;
begin
for i:=0 to 515 do
if (GetChildComponentID(INTERFACE_BANK, 93, i)=ID) then
begin
Slot:= i;
Result:= True;
Exit;
end;
end;

{*******************************************************************************
function R_WithdrawItemIDSearch(ID, HowMany: Integer): Boolean;
By: Shuttleu
Description: Withdraws item ID using the search button.
*******************************************************************************}
function R_WithdrawItemIDSearch(ID, HowMany: Integer): Boolean;
var
i, Slot, : Integer;
SearchLoc, ItemPos: TBox;
begin
if (not(R_BankScreen)) then Exit;
if (not(R_ItemExistsInBank(ID, Slot))) then Exit;
SearchLoc:= GetInterfaceComponentRelativePosition(INTERFACE_BANK, 17);
Mouse(RandomRange(SearchLoc.x1, SearchLoc.x2), RandomRange(SearchLoc.y1, SearchLoc.y2),
0, 0, True);
repeat
Wait(100+Random(50));
Inc(i);
until ((i>4) or ReadyToTypeBank);
if ReadyToTypeBank then
begin
TypeSend(R_ReturnItemName(ID));
Wait(300+Random(300));
R_ItemExistsInBank(ID, Slot);
ItemPos:= GetChildComponentScreenPosition(INTERFACE_BANK, 93, Slot);
if (HowMany = 1) then
begin
Mouse(RandomRange(ItemPos.x1, ItemPos.x2), RandomRange(ItemPos.y1, ItemPos.y2),
0, 0, True);
Result:= True;
Exit;
end else
begin
Mouse(RandomRange(ItemPos.x1, ItemPos.x2), RandomRange(ItemPos.y1, ItemPos.y2),
0, 0, False);
Wait(100+Random(200));
case HowMany of
5, 10: if R_ChooseOption('Withdraw-'+IntToStr(HowMany)) then
begin
Result:= True;
Exit;
end;
0: if R_ChooseOption('Withdraw-All') then
begin
Result:= True;
Exit;
end;
else
if R_ChooseOption('Withdraw-X') then
begin
Wait(100+Random(200));
if ReadyToTypeBank then
begin
TypeSend(IntToStr(HowMany));
Result:= True;
Exit;
end;
end;
end;
end;
end;
end;

Interfaces:
{*******************************************************************************
function GetInterfaceComponentRelativePosition (ParentI, ChildI : Integer): TBox;
By: Shuttleu
Description: Returns relative box position.
*******************************************************************************}
function GetInterfaceComponentRelativePosition (ParentI, ChildI : Integer): TBox;
begin
Result.x1 := GetInterfaceComponentRelativeX(ParentI, ChildI);
Result.y1 := GetInterfaceComponentRelativeY(ParentI, ChildI);
Result.x2 := Result.x1+GetInterfaceComponentWidth(ParentI, ChildI);
Result.y2 := Result.y1+GetInterfaceComponentHeight(ParentI, ChildI);
end;

{*******************************************************************************
function GetChildComponentRelativePosition (ParentI, ChildI, CompI: Integer): TBox;
By: Shuttleu
Description: Returns relative TBox.
*******************************************************************************}
function GetChildComponentRelativePosition (ParentI, ChildI, CompI: Integer): TBox;
begin
Result.x1 := GetChildComponentRelativeX(ParentI, ChildI, CompI);
Result.y1 := GetChildComponentRelativeY(ParentI, ChildI, CompI);
Result.x2 := Result.x1+GetChildComponentWidth(ParentI, ChildI, CompI);
Result.y2 := Result.y1+GetChildComponentHeight(ParentI, ChildI, CompI);
end;

{*******************************************************************************
function GetChildComponentScreenPosition (ParentI, ChildI, CompI: Integer): TBox;
By: Shuttleu
Description: Returns Screen TBox.
*******************************************************************************}
function GetChildComponentScreenPosition (ParentI, ChildI, CompI: Integer): TBox;
begin
Result.x1 := GetChildComponentRelativeX(ParentI, ChildI, CompI)
+GetInterfaceComponentRelativeX(ParentI, ChildI);
Result.y1 := GetChildComponentRelativeY(ParentI, ChildI, CompI);
+GetInterfaceComponentRelativeY(ParentI, ChildI);
Result.x2 := Result.x1+GetChildComponentWidth(ParentI, ChildI, CompI);
Result.y2 := Result.y1+GetChildComponentHeight(ParentI, ChildI, CompI);
end;

Players:

{*******************************************************************************
function GetLocation: TPoint;
By: Shuttleu
Description: Returns your players tile.
*******************************************************************************}
function GetLocation: TPoint;
begin
Result.X := (SmartGetFieldInt(0, hook_static_BaseX) + (SmartGetFieldInt(Player, hook_animable_PixelX) / 512));
Result.Y := (SmartGetFieldInt(0, hook_static_BaseY) + (SmartGetFieldInt(Player, hook_animable_PixelY) / 512));
end;

NPCs:
function TileToMM(tile: TTile): TPoint; forward;

{*******************************************************************************
function ClickNPC(ID: Integer; Option: string; Left: Boolean): Boolean;
By: Shuttleu
Description: Clicks on the npc and chooses the Option
*******************************************************************************}
function ClickNPC(theVar: Variant; Option: string; Left: Boolean): Boolean;
var
NPC: TNPC;
NPCLoc: TPoint;
begin
if (not(LoggedIn)) then Exit;
if FindNPC(TheVar, NPC) then
begin
if (not(TileonMS(NPC.Tile, 10))) then
begin
NPCLoc:= TileToMM(NPC.Tile);
Mouse(NPCLoc.x, NPCLoc.y, 5, 5, True);
Wait(500+Random(500));
Flag;
Wait(500+Random(500));
end;
NPCLoc:= TileToMS(NPC.Tile, 10);
Mouse(NPCLoc.x, NPCLoc.y, 5, 5, Left);
if (not (Left)) then R_ChooseOption(Option);
Wait(500+Random(500));
Flag;
Wait(1000+Random(1000));
end
end;

Gametab:
{*******************************************************************************
function R_ExpToNextLevel(skill: variant): Integer;
By: Shuttleu
Description: Gets the Experience needed to get to the next level
*******************************************************************************}
function R_ExpToNextLevel(Skill: variant): Integer;
var
Level, i, Index: Integer;
begin
case VarType(skill) of
varString: Index := _SkillStringToInt(skill);
varInteger: Index := skill;
else
SRL_Warn('GetSkillLevel', 'Invalid var type passed.', warn_AllVersions);
end;
Level:= SmartGetFieldArrayInt(0, hook_static_GetSkillLevels, Index);
Result:= 0;
for i := 1 to Level do
Result := Result + floor(i + 300 * Pow(2.0, i / 7.0));
Result:= (Result/4) - SmartGetFieldArrayInt(0, hook_static_GetSkillExperiences, Index);
end;

~shut

Bad Boy JH

2010-12-08 18:49:30

A withdrawer has been posted, If I can borrow your procedures, I can improve its readability

Shuttleu

2010-12-08 18:50:42

sure go ahead, thats what they're for ;)

~shut

EDIT: added more interface stuff, also can a mod change the title to 'Reflection stuff'

Shuttleu

2010-12-08 19:48:14

added more stuff to the bank section

also can a mod change the title to 'Reflection stuff'

~shut

Sir R. M8gic1an

2010-12-08 22:42:18

From: Shuttleu
added more stuff to the bank section

also can a mod change the title to 'Reflection stuff'

~shut


please and thank you.

~RM

Shuttleu

2010-12-09 04:35:24

Oh crap, sorry,
Please
Thank you Sir Rasta Magician :D

~shut

Shuttleu

2010-12-11 10:22:20

double post?
meh, its the only way to let people know that i updated the first post

updated first post

~shut

Cstrike

2010-12-11 12:01:45

I'll try and check these out today, stupid RL has kept my plate near full. Finals = bitch

Shuttleu

2010-12-11 14:21:27

added something for NPCs ;)

~shut

Shuttleu

2010-12-12 10:21:38

added one for gametab

~shut

mormonman

2010-12-12 10:55:22

From: Shuttleu
added something for NPCs ;)

~shut


Will never be added to reflection, that should be done by the scripter.