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
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:
TPlayer = record: (constants.Simba)
Add this:
function NULL_PLAYER: (constants.Simba)
Add these two:
Before: No such thing as player levels / experience.
After: Now there is! :spot:
-Frog antirandom-
-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-
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:
Put this:
Bank.Simba
Add this function somewhere near the top of the file:
Function R_OpenBankBooth (Bank.Simba)
Declare this as a local variable:
Underneath this line:
Add this block of code:
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".
-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".