SRL Archive - Reflection Development

My Reflection 2 modifications


Flight

2011-07-06 07:13:46

First of all, I'm sorry I didn't use Git or anything of such. Maybe one of these days I'll get around to setting that up for myself. So until then, I'll just continue updating this thread with my modifications for Reflection 2. Note that I do test these personally to make sure they work, but you don't have to take my word for it.

-Fixing 'WithdrawX' function-
Function WithdrawX: (Bank.Simba)

Replace

Result := R_WaitOption('Withdraw-X', 3000);
with:

if R_OptionExists('Withdraw-' + IntToStr(Amount)) then
begin
Result := R_WaitOption('Withdraw-' + IntToStr(Amount) + ' ' + Item.Name, 3000);
Exit;
end else
Result := R_WaitOption('Withdraw-X', 3000);
Before: Clicks "Withdraw X" every time and types in amount, every time.
After: If we've already set the "X" to our amount, we'll withdraw that amount without typing in the amount for every cycle.

-Adding player levels/experience-
Function R_GetMe: (MyPlayer.Simba)

Add this:

for i := 0 to 24 do
begin
Experience[i] := SmartGetFieldArrayInt(0, hook_static_GetSkillExperiences, i);
Levels[i] := SmartGetFieldArrayInt(0, hook_static_GetSkillLevels, i);
end;
Almost forgot, declare "i" as an integer variable within the function.

TPlayer = record: (constants.Simba)

Add this:

Experience, Levels: array[0..24] of Integer;

function NULL_PLAYER: (constants.Simba)

Add these two:

Levels := [];
Experience := [];

Before: No such thing as player levels / experience.
After: Now there is! :spot:

-Frog antirandom-

var
RFrogVars_NPC: TNPC;

function RFrog_InRandom: Boolean;
begin
Result := R_FindNPC('Frog Herald', True, RFrogVars_NPC);
end;

function R_FrogChattingInterfaceOpen : Boolean;
var
ValidFrogInterfaces : TIntegerArray;
i : Integer;
begin
ValidFrogInterfaces := [64, 65, 66, 67, 68, 241, 242, 243, 244, 245];
for i:=0 to high (ValidFrogInterfaces) do
begin
if (R_ValidInterface(ValidFrogInterfaces[i])) then
begin
Result := True;
Exit;
end;
end;
end;

procedure RFrog_TalkToHerald;
var
NPCs : TNPCArray;
i : Integer;
TP : TPoint;
begin
if R_FrogChattingInterfaceOpen then
begin
Writeln ('[Reflection] Already talking to frog herald.');
While r_ClickToContinue do
Wait(2000+Random(2000));
r_ClickToContinue; // One last time :)
end else
begin
NPCs := R_GetAllNPCs(True);
if high (NPCs) < 0 then
begin
Writeln ('[Reflection] No frog herald found...')
Exit;
end;
for i:=0 to high (NPCs) do
begin
if NPCs[i].ID = 2472 then
begin
TP := R_TileToMS(NPCs[i].Tile, 0);
Mouse (TP.X, TP.Y, 0, 0, false);
wait (250+random(250));
if R_ChooseOptionMulti (['eral']) then
Exit;
end;
end;
end;
end;

function R_FrogFindClickPrincess : Boolean;
var
NPCs: TNPCArray;
I, iTime, NPCTime : Integer;
TP : TPoint;
begin
Result := False;
MarkTime(iTime);
SetAngle(True);
repeat
NPCs := R_GetAllNPCs(True);
for I:=0 to high(NPCs) do
if (NPCs[I].Height = 278) then
begin
Writeln('[Reflection] Found correct frog!');
if R_TileOnMS(NPCs[I].Tile, 0) then
begin
writeln('[Reflection] Frog tile on mainscreen');
TP := R_TileToMS (NPCs[I].Tile, 0);
Mouse(TP.x, TP.y, 0, 0, false);
if WaitOption('alk-', 250+Random(100)) then
begin
Wait(400+Random(200));
Flag;
MarkTime(NPCTime);
repeat
wait (100+random(100));
if (R_GetInterfaceText (243,3) = 'Frog Princess')or(R_GetInterfaceText (243,3) = 'Frog Prince') then
begin
result := true;
writeln ('[Reflection] Interacting with frog..');
Exit;
end;
until (TimeFromMark(NPCTime) > 10000)
Writeln('[Reflection] Took too long interact with the frog');
end;
end else
begin
R_WalkToTile(NPCs[I].Tile, 0, 0);
Continue;
end;
end;
until (TimeFromMark(iTime) > 60000)
writeln ('[Reflection] Error finding frog! Time > 1 min');
end;

function R_FrogPrincessChat: Boolean;
begin
Writeln('[Reflection] Finishing off talking..');
If (R_GetInterfaceText(243, 7) = 'Click here to continue')then
While Not (Pos('you so much', (R_GetInterfaceText(243, 4))) > 0) do
begin
ClickToContinue;
Wait(600+Random(300));
end;
Writeln('[Reflection] Last click!');
ClickToContinue;
Wait(4000+Random(1500));
Result := Not RFrog_InRandom;
end;

function RFrog_Solve: Boolean;
var
T,TimedCount: Integer;
begin
Result := False;

MarkTime(T);
while(RFrog_InRandom and (TimeFromMark(T) < 600000)) do
begin

RFrog_TalkToHerald;
wait (1000+random(2500));

While (R_GetInterfaceText(242, 6) = 'Click here to continue')do
begin
Wait(600+Random(300));
ClickToContinue;
end;

While (R_FrogChattingInterfaceOpen)do
begin
Wait(600+Random(300));
ClickToContinue;
end;

end;

MarkTime (TimedCount);
repeat
if R_FrogFindClickPrincess then
Result := R_FrogPrincessChat;
until (TimeFromMark(TimedCount) > 120000)or(Result)

end;

-This is the mostly the same as the old Frog Antirandom for reflection but with a couple things changed and all converted to R2. This is currently untested.

-Extended Object-finding-


Function R_GetObjectEx_F(IDs: TIntegerArray; SearchType: String; ObjType, MaxDist: Integer): TRSObject;
Var
F, BX, BY, Plane, Ground: Integer;
MyPos: TTile;
Tiles: TTileArray;
Temp: TRSObject;
ObjFunction: function(GroundObj, BaseX, BaseY: Integer): TRSObject;
begin
Result := NULL_RSOBJECT;
case ObjType of
OBJ_INTERACTABLE: ObjFunction := @R_GetInteractableObject;
OBJ_WALLOBJECT: ObjFunction := @R_GetWallObject;
OBJ_WALLDECORATION: ObjFunction := @R_GetWallDecorationObject;
OBJ_FLOORDECORATION: ObjFunction := @R_GetFloorDecorationObject;
else begin
R_Debug('Not a valid ObjType!', 'R_GetObjectAt');
Exit;
end;
end;

BX := SmartGetFieldInt(0, hook_static_BaseX);
BY := SmartGetFieldInt(0, hook_static_BaseY);
MyPos := R_GetMyPos;
MyPos.X := MyPos.X - BX;
MyPos.Y := MyPos.Y - BY;
Tiles := R_SortedCircleTPA(MyPos, MaxDist);
Plane := SmartGetFieldInt(0, hook_static_LoadedPlane);

if Length(Tiles) < 1 then
Exit;

for F := 0 to High(Tiles) do
begin
Ground := SmartGetFieldArray3DObject(0, hook_static_GroundTiles, Plane, Tiles[F].X, Tiles[F].Y);
Temp := ObjFunction(Ground, BX, BY);
SmartFreeObject(Ground);

if (Temp = NULL_RSOBJECT) then
Continue;

Case LowerCase(SearchType) of

'id','ids':
begin
if InIntArray(IDs, Temp.ID)then
begin
Result := Temp;
Exit;
end;
end;

'modelid','modelids':
begin
if InIntArray(IDs, Temp.ModelID)then
begin
Result := Temp;
Exit;
end;
end;

end;

end;
end;

Before: Searches for objects based on ID array.
After: Search for objects based on ID array or ModelID array.


-PIN Confirmation interface-
Constants.Simba

Underneath this:


INTERFACE_PINSCREEN = 13;

Put this:


INTERFACE_PINCONFIRMATION = 14;

Bank.Simba

Add this function somewhere near the top of the file:


function R_PinConfirmation: Boolean;
begin
Result := R_ValidInterface(INTERFACE_PINCONFIRMATION);
end;

Function R_OpenBankBooth (Bank.Simba)

Declare this as a local variable:


B: TInterfaceChild;

Underneath this line:


R_Flag;

Add this block of code:


if R_PinConfirmation then
begin
B := R_GetInterfaceChild(INTERFACE_PINCONFIRMATION, 34);
R_ClickInterface(B, 1);
MarkTime(T);
end;

Before: If the player had a PIN pending at the time, the script would not recognize this confirmation screen.
After: The PIN confirmation page is detected and handle accordingly, also resets our loop timer upon clicking "Proceed".

Jakkle

2011-07-06 07:42:08

Very nice, getting this commited to git and pushed, would be good ?
Levels := SmartGetFieldArrayInt(0, hook_static_GetSkillLevels, i); Had to use getskilllevel rather than R_GetSkillLevel witch worked in ref 1.
:thumbsup: Rep+

KingKong

2011-07-06 07:53:34

@Flight, this is a good tut for learning the bare basics of git(not much actually):
http://villavu.com/forum/showthread.php?t=62542


From: whacko999
Very nice, getting this commited to git and pushed, would be good ?
Levels := SmartGetFieldArrayInt(0, hook_static_GetSkillLevels, i); Had to use getskilllevel rather than R_GetSkillLevel witch worked in ref 1.
:thumbsup: Rep+


yeah i noticed ref2 doesn't have r_getskillLevel, and i already fixed it and am in the process of sending a pull request.

HyperSecret

2011-07-06 08:14:05

The 'Withdraw-X' doesn't need that extra stuff, imo. The function is to 'Withdraw-X', the other code can be added in the script by the scripter.

Gu3st...

2011-07-06 08:31:16

From: HyperSecret
The 'Withdraw-X' doesn't need that extra stuff, imo. The function is to 'Withdraw-X', the other code can be added in the script by the scripter.
I agree

Flight

2011-07-06 11:45:30

Amount detection was in Reflection 1, why would it be a problem to put it in Reflection 2?

pyroryan

2011-07-06 14:05:38

I agree with Flight on this one. It makes no sense to reenter the number. Its much slower and no intelligent human would do it (unless intelligence led them to think doing things in a slower fashion is better).

Dgby714

2011-07-06 14:24:01

https://github.com/Drags111/Reflection_Dev/pull/4
https://github.com/Drags111/Reflection_Dev/pull/5

Echo_

2011-07-06 14:42:46

Nice work Flight, we'll see what Drags111 thinks when he gets on :thumbsup:

Flight

2011-07-21 01:25:48

Updated:
Added the Frog Anti-random (untested) and "Extended Object-finding" which allows us to find objects based on both ID and ModelID.

mormonman

2011-07-21 03:07:40

We are re-writing the randoms, not just copying them over. There are many things that could be optimized from the old one. I'll do it and show you tomorrow so that you know what I mean if you plan on working on other random solvers. Also, we will have to integrate composite searching properly, and not just one function(even though yours does the job stupendously). Thank you for bringing these things to our attention. :D (rep+)

Flight

2011-07-21 03:17:38

I'm more than happy to help. I know from what Drags was telling me (and I couldn't agree more) that the old reflection randoms are quite unreliable, but the reason I did this one is from what I've seen on the Stats page, the Frog random event (R1) has never failed, so I figured it wouldn't be too big of a deal to just convert it to R2 and see how it works out. I think I might look at how TriBot handles Random Events and, if TRileZ doesn't mind, see about converting some of them to our R2 library. From what he said earlier, his antirandoms are stable.

The extended object finding I wouldn't think would be a very big priority, but in certain scripts it would be very much required. ;) If you decide not to put it in that's fine with me, I don't mind having the function within my scripts.

Goobs

2011-07-21 03:59:21

[slightly offtopic] Does anyone need an account stuck in the maze? It tried walking him a little and made it through a few doors before failing. I will let you borrow, drags, flight, or whoever is in charge of developing the new antirandoms :)[/…nuff said]

KingKong

2011-07-21 04:24:47

Can't you guys(mods/admins) make a subforum or something where people can post their random accounts info, but only the devs can access something like that? It would make it a lot easier for everyone.

mormonman

2011-07-21 04:41:28

We have plenty of accounts in randoms, but thank you for being willing.

Nava2

2011-07-21 11:49:02

From: KingKong
Can't you guys(mods/admins) make a subforum or something where people can post their random accounts info, but only the devs can access something like that? It would make it a lot easier for everyone.


Thats a good idea actually, something along the lines of the Members Application or Reporting a post. :O

Goobs

2011-07-22 00:13:17

I agree, that would be the best way to go about it. We need an admin!


Nava2

2011-07-22 11:20:07

From: ProphesyOfWolf
I agree, that would be the best way to go about it. We need an admin!



Haha, nice. I reported the post, hopefully it will get some attention.

Goobs

2011-07-22 23:39:18

I hope so too :)

Harry

2011-07-22 23:52:29

That won't work out well, even in a trustworthy community. Sorry to burst the bubble.

I have an army dedicated to getting randoms (50 accounts I think, last time I checked?)

Drags, Mormon, Pyro, and some others have a copy of my PSWC with it.

Gets tons of randoms, I think they have enough.

mormonman

2011-07-23 00:25:48

From: Harry
That won't work out well, even in a trustworthy community. Sorry to burst the bubble.

I have an army dedicated to getting randoms (50 accounts I think, last time I checked?)

Drags, Mormon, Pyro, and some others have a copy of my PSWC with it.

Gets tons of randoms, I think they have enough.


They are all in randoms now.

Harry

2011-07-23 00:37:42

Cool, maybe I should run a few more through tut and get more? Or is the current count sufficient?

mormonman

2011-07-23 00:40:58

From: Harry
Cool, maybe I should run a few more through tut and get more? Or is the current count sufficient?


If you could get 10 more that would be perfect.

Harry

2011-07-23 01:10:19

for I := 19 to 50 do
^ set that, r32 is now the highest one made. I think I made 12 or so? And HowManyPlayers := 51;.. have fun.

Flight

2011-08-05 12:26:33

Added PIN confirmation detection and handling for banking procedures. :garfield:

mormonman

2011-08-05 16:15:02

Change it to click the message with interfaces and not hard-coded coordinates.

Flight

2011-08-05 22:05:40

From: mormonman
Change it to click the message with interfaces and not hard-coded coordinates.


Updated. Finds the childinterface and clicks it accordingly now.

Edit:
By the way, I tested it multiple times, it seems to work just fine, incase you're wondering.

Bixby Sayz

2011-08-05 23:07:19

From: HyperSecret
The 'Withdraw-X' doesn't need that extra stuff, imo. The function is to 'Withdraw-X', the other code can be added in the script by the scripter.

This attitude (very prevalent on here) confuzzles me. A few lines of code could make it act more human like, and actually behave the way you expect it to behave.

Someone has noticed an area where the includes could be improved and even took the time to write the code, and it just gets shrugged off. I see this attitude again and again from the senior members, as if they are going out of their way to discourage anyone from trying to improve their code. To say it bothers me is a huge understatement. :fiery:

Drakan

2011-08-06 00:24:38

From: Bixby Sayz
This attitude (very prevalent on here) confuzzles me. A few lines of code could make it act more human like, and actually behave the way you expect it to behave.

Someone has noticed an area where the includes could be improved and even took the time to write the code, and it just gets shrugged off. I see this attitude again and again from the senior members, as if they are going out of their way to discourage anyone from trying to improve their code. To say it bothers me is a huge understatement. :fiery:


It's not even that. We want to try to stay away from

MineRocksInVarrock();
BankInVarrockEastBank();
end.

We want users to be more dependent, because thats the way we were "raised" here at SRL. In our time we made most of our detailed functions. There are a lot of features handed to us. We want coding to be fun but also a challenge to help the scripter grow in his abilities.

Flight

2011-08-06 00:52:01

From: drags111

We want users to be more dependent, because thats the way we were "raised" here at SRL. In our time we made most of our detailed functions. There are a lot of features handed to us. We want coding to be fun but also a challenge to help the scripter grow in his abilities.


From: pyroryan

I agree with Flight on this one. It makes no sense to reenter the number. Its much slower and no intelligent human would do it (unless intelligence led them to think doing things in a slower fashion is better).


Yes, but look at those 'detailed' functions that were, at the time, specific to a script. They've been added to the SRL library, for the purpose of making scripting easier and, without a doubt, more organized. Leaving out important fixes in the library, like the Withdraw X, is very stupid, there's absolutely no reason for that/

What do you prefer, having every user who uses reflection banking, at all, individually make their own withdraw functions within their script that detects if our 'amount' already exists as an option, or putting this within Reflection's banking procedures? There's no reason for this, at all. You're taking away the the key feature, of making our scripts human-like, that's kept SRL at it's record low ban-rate, because why? Because you personally want everyone to make these procedures on their own? Then what's the purpose of the Reflection library in the first place?

Drakan

2011-08-06 01:11:35

No, we give u good base functions. It's not hard to add a checker (If OptionExists(Blah))then click it. You get upset so quickly, I'm just answering his question about why ssrl acts the way they do sometimes. Chillax, its a game.

Bobarkinator

2011-08-06 01:25:48

drags111: You're against high-level functions? I mean, I'm all for training people up from scratch and all. But honestly, if someone doesn't need to deal with low-level things why should they have to?

mormonman

2011-08-06 02:25:08

From: Bobarkinator
drags111: You're against high-level functions? I mean, I'm all for training people up from scratch and all. But honestly, if someone doesn't need to deal with low-level things why should they have to?


The answer is copy-pasta. I do it with random events.

Flight

2011-08-06 03:03:30

From: drags111
No, we give u good base functions. It's not hard to add a checker (If OptionExists(Blah))then click it. You get upset so quickly, I'm just answering his question about why ssrl acts the way they do sometimes. Chillax, its a game.


The 'checker' will have to exist within the Withdraw function itself, so whoever wishes to check if the amount is already entered, they must make their own "WithdrawX" function, thus making yours absolutely useless. Might as well take it out.

Drakan

2011-08-06 08:26:16

And I never even said I'm against it, I was answering someone's question. What I am against is people asking for it instead of doing it themselves and submitting it, thats all. No sense arguing about it.