SRL Archive - Reflection Help

Would anyone like to help me make a great orb project script?


Troll

2010-11-05 15:23:13

Well i guesse it should go here as its going to be a reflection one. :)
So anyway would some one like to make one with me, as im not very good and could use help.

Thanks :)

Cstrike

2010-11-05 15:47:59

At the risk of me sounding like a dumbass: Is the great orb project part of runescape? If not you can't use reflection for it.

Troll

2010-11-05 15:49:44

Yeah it the f2p runecarfting minigame silly :p

Cstrike

2010-11-05 15:58:03

In that case: Hell yeah it's possible :)

Though you're going to need to become comfortable with reflection as a whole. If you generally know the guide in the help section, I'd say the only thing limiting you from creating it would be time. If you're stuck I can always help.

I wouldn't be able to help you make it, BUT I could tell you exactly what code you'd need to use for each situation.

Troll

2010-11-05 16:01:44

From: cstrike
In that case: Hell yeah it's possible :)

Though you're going to need to become comfortable with reflection as a whole. If you generally know the guide in the help section, I'd say the only thing limiting you from creating it would be time. If you're stuck I can always help.

I wouldn't be able to help you make it, BUT I could tell you exactly what code you'd need to use for each situation.


Ok thanks :) just one thing, how would i find an alter and then get the title of it as it changes the tile? thanks

Cstrike

2010-11-05 16:03:22

From: Troll Man
Ok thanks :) just one thing, how would i find an alter and then get the title of it as it changes the tile? thanks


You'll need RSBot, or you can do it with SMART's reflection but it will be a pain to ensure you have the right ID and type of ID.

What you do is search for the object. When it changes tile, you just call "FindObjectID" to search for the ID of the object you retrieved from RSBot and it will give you the exact tile in the new position.

Of course if I answered this wrong because of my lack of knowledge from the game I apologize

Troll

2010-11-05 16:05:47

From: cstrike
You'll need RSBot, or you can do it with SMART's reflection but it will be a pain to ensure you have the right ID and type of ID.

What you do is search for the object. When it changes tile, you just call "FindObjectID" to search for the ID of the object you retrieved from RSBot and it will give you the exact tile in the new position.

Of course if I answered this wrong because of my lack of knowledge from the game I apologize


Umm what would i need to do for this?

The scirpt is running
It finds the Object // I have the ID
I need the tile its on while running

Thanks

Cstrike

2010-11-05 16:13:42

You mean what to do 'code' wise?

Troll

2010-11-05 16:15:46

Yeah
Like
Find object ID = alter
Get tile of alter

Cstrike

2010-11-05 17:58:11

Get the Altar ID (best to use RSBot and turn on Debugging)
Is it altar or alter? I forget xD

Then do
var Alter : TRSObject; // Assuming there is only one with one ID
t : Integer;
// ... begin stuff, more crap here
MarkTime(t);
repeat
AlterObj := GetObjectByID(ID: Integer; objType, MaxDist: Integer); // For objType use the constant OBJECT_TYPE_INTERACTABLE, i assume it's that
//Make your distance a number between 1 and 52. I think it's tiles, the smaller then number the faster it gets the location. 52 distance usually takes about... 1-3 seconds. 7 would be pretty instant I think.

// To use the tile... for example:
if TileOnMS (AlterObj.Tile, 0) then Exit;
until (TimeFromMark(t) > 10000)


Therefore,
1) Find the ID
2) Use GetObjectByID, if there is multiple you need to change the code by one letter and change the ID to a TIntArray
3) Do whatever you want with the tile, it will be called AlterObj.Tile

Troll

2010-11-05 18:00:58

From: cstrike
Get the Altar ID (best to use RSBot and turn on Debugging)
Is it altar or alter? I forget xD

Then do
var Alter : TRSObject; // Assuming there is only one with one ID
t : Integer;
// ... begin stuff, more crap here
MarkTime(t);
repeat
AlterObj := GetObjectByID(ID: Integer; objType, MaxDist: Integer); // For objType use the constant OBJECT_TYPE_INTERACTABLE, i assume it's that
//Make your distance a number between 1 and 52. I think it's tiles, the smaller then number the faster it gets the location. 52 distance usually takes about... 1-3 seconds. 7 would be pretty instant I think.

// To use the tile... for example:
if TileOnMS (AlterObj.Tile, 0) then Exit;
until (TimeFromMark(t) > 10000)


Therefore,
1) Find the ID
2) Use GetObjectByID, if there is multiple you need to change the code by one letter and change the ID to a TIntArray
3) Do whatever you want with the tile, it will be called AlterObj.Tile


Ok thanks, i think that will be quite useful

Edit: our the tiles on here the same as Rsbot/powerbot?

Cstrike

2010-11-05 18:02:01

From: Troll Man
Ok thanks, i think that will be quite useful


Crap! I forgot to put a wait in the loop. Make sure you put something like wait(50);

If you need anymore help, feel welcome to post :)

Troll

2010-11-06 12:47:00

From: cstrike
Get the Altar ID (best to use RSBot and turn on Debugging)
Is it altar or alter? I forget xD

Then do
var Alter : TRSObject; // Assuming there is only one with one ID
t : Integer;
// ... begin stuff, more crap here
MarkTime(t);
repeat
AlterObj := GetObjectByID(ID: Integer; objType, MaxDist: Integer); // For objType use the constant OBJECT_TYPE_INTERACTABLE, i assume it's that
//Make your distance a number between 1 and 52. I think it's tiles, the smaller then number the faster it gets the location. 52 distance usually takes about... 1-3 seconds. 7 would be pretty instant I think.

// To use the tile... for example:
if TileOnMS (AlterObj.Tile, 0) then Exit;
until (TimeFromMark(t) > 10000)


Therefore,
1) Find the ID
2) Use GetObjectByID, if there is multiple you need to change the code by one letter and change the ID to a TIntArray
3) Do whatever you want with the tile, it will be called AlterObj.Tile


So i have this.

Function GetWhere:String;
Var
Alters :Array Of Integer;
Alter :TRSObject;
i :Integer;

Begin
If Not LoggedIn Then Exit;
SetArrayLength(Alters,6);
Alters[0] := 2478 //Air
Alters[1] := 2479 //Mind
Alters[2] := 2480 //Water
Alters[3] := 2481 //Earth
Alters[4] := 2482 //Fire
Alters[5] := 2483 //Body

For I:= 0 To 5 Do
Begin
Alter := GetObjectByID(Alters[I],OBJECT_TYPE_INTERACTABLE,25);
End;


End;
What can i do to see if it finds an alter there. Like a
If Alter within 30 tiles Then
Blah Blah

Thanks

Edit: Would this work?

Function GetWhere:Integer;
Var
Alters :Array Of Integer;
Alter :TRSObject;
I,II :Integer;

Begin
If Not LoggedIn Then Exit;
SetArrayLength(Alters,6);
Alters[0] := 2478 //Air
Alters[1] := 2479 //Mind
Alters[2] := 2480 //Water
Alters[3] := 2481 //Earth
Alters[4] := 2482 //Fire
Alters[5] := 2483 //Body

For I:= 0 To 5 Do
Begin
Alter := GetObjectByID(Alters[I],OBJECT_TYPE_INTERACTABLE,25);
If TileOnMS(Alter.Tile,0) Then
Result := I
End;

End;
Thanks again

Edit again
or even this

Function GetWhere:String;
Var
Alters :Array Of Integer;
Alter :TRSObject;
I,II :Integer;

Begin
If Not LoggedIn Then Exit;
SetArrayLength(Alters,6);
Alters[0] := 2478 //Air
Alters[1] := 2479 //Mind
Alters[2] := 2480 //Water
Alters[3] := 2481 //Earth
Alters[4] := 2482 //Fire
Alters[5] := 2483 //Body

For I:= 0 To 5 Do
Begin
Alter := GetObjectByID(Alters[I],OBJECT_TYPE_INTERACTABLE,25);
If TileOnMS(Alter.Tile,0) Then
II := I
End;

Case II Of
0: Result := 'Air';
1: Result := 'Mind';
2: Result := 'Water';
3: Result := 'Earth';
4: Result := 'Fire';
5: Result := 'Body';
End;

End;
Would that do what i want it to?

Cstrike

2010-11-06 13:14:27

So far not to bad, now could they be off the screen? Or will they be on the screen for sure? If not I can whip up some cool code that will be quick and move you near them.

For now, I made the code more efficient:
Function GetWhere : String;
Var
Alters : TIntegerArray;
Alter : TRSObject;
I,II : Integer;
Begin
If Not LoggedIn Then Exit;
Result := ''; // Must have failsafe
Alters := [2478, 2479, 2480, 2481, 2482, 2483]; // Air/mind/water/earth/fire/body
For I:= 0 To 5 Do
Begin
Alter := GetObjectByID(Alters[I],OBJECT_TYPE_INTERACTABLE,25);
If TileOnMS(Alter.Tile,0) Then
Begin
II := I
Break;
End;
End;
Case II Of
0: Result := 'Air';
1: Result := 'Mind';
2: Result := 'Water';
3: Result := 'Earth';
4: Result := 'Fire';
5: Result := 'Body';
End;
End;

Troll

2010-11-06 13:19:25

For the most part yes they will always be on sceen, how ever if you could make something cool for when they are not, that would be a great fail safe. Thanks

Cstrike

2010-11-06 13:39:35

Havent tried this but it compiles:

function CheckIfOnMSIfNotFixLoc (IDs : TIntegerArray) : Boolean;
var
Alters, DistancesToAlter, DistanceQuickSort : TIntegerArray;
AlterUnique : TRSObject;
Alter : TRSObjectArray;
I,II : Integer;
OnMS : Boolean;
begin
If Not LoggedIn Then Exit;
Result := false;
OnMS := False;
For I:= 0 To high(IDs) Do
Begin
AlterUnique := GetObjectByID(IDs[I],OBJECT_TYPE_INTERACTABLE,25);
If TileOnMS(AlterUnique.Tile,0) Then
Begin
Result := True;
Exit;
End;
End;
if not Result then
begin
Alter := GetObjectsByID(IDs,OBJECT_TYPE_INTERACTABLE,25);
Writeln ('Did not find any alters on the mainscreen, now moving to nearest one.');
SetArrayLength (DistancesToAlter, high(IDs)+1);
SetArrayLength (DistanceQuickSort, high(IDs)+1);
For I:= 0 To high(Alter) Do
Begin
DistancesToAlter[I] := DistanceFrom (Alter[I].Tile);
DistanceQuickSort[I] := DistanceFrom (Alter[I].Tile);
End;
QuickSort(DistanceQuickSort);
For II:=0 to high(IDs) do
begin
if DistanceQuickSort[0] = DistancesToAlter[II] then
begin
if TileOnMM (Alter[II].Tile) then
begin
WalkPath ([Alter[II].Tile]);
wait (300+random(300));
Result := True;
Exit;
end else
begin
Writeln ('The closest alter was not on the minimap, something is terribly wrong.');
Exit;
end;
end;
end;
end;
end;

Function GetWhere : String;
Var
Alters : TIntegerArray;
Alter : TRSObject;
I,II : Integer;
Begin
If Not LoggedIn Then Exit;
Result := ''; // Must have failsafe
II := -1; // Failsafe
Alters := [2478, 2479, 2480, 2481, 2482, 2483]; // Air/mind/water/earth/fire/body
If CheckIfOnMSIfNotFixLoc (Alters) then
Begin
For I:= 0 To 5 Do
Begin
Alter := GetObjectByID(Alters[I],OBJECT_TYPE_INTERACTABLE,25);
If TileOnMS(Alter.Tile,0) Then
Begin
II := I
Break;
End;
End;
if II = -1 then Writeln ('Warning, could not find any alters on the mainscreen');
Case II Of
0: Result := 'Air';
1: Result := 'Mind';
2: Result := 'Water';
3: Result := 'Earth';
4: Result := 'Fire';
5: Result := 'Body';
End;
End Else Writeln ('Warning: No alter was on MS');
End;

What I do in that new function is:
1) Check if any of them are on mainscreen, if so return true and exit
2) If not, then get the distances to all the alters
3) Quicksort the distances (makes lowest number first, biggest last)
4) Check the distance array (to see which one is closest) based on Quicksort's first array position (which is our closest)
5) Moves to that one on the minimap, if it can't returns false

Now, if you don't want to move to the closest one, then you can't really use that function.

Sandstorm

2010-11-06 14:13:24

First, it's spelt altar.

Second, cstrike, in the minigame, only one will be on the screen at any given time. It works like this:

You enter the minigame, and it teleports you to the first altar. You finish that 'game', and go to the next one, getting a reward based on performance. The altars go in a certain order, presumably the order of the IDs he has in his chunk of code. So really, all you need to do is check if the tile is on the main screen, and if it isn't, check if it's on the minimap and click it if it is.

Kehmist

2010-11-06 18:57:54

I love this minigame! If you need any help with it I would be glad to pitch in.
Although I am a bit rusty on scripting, I could try to help :p