SRL Archive - Reflection Development

PinBall Random Fix


Bad Boy JH

2010-11-24 01:43:19

I hit the pinball random, and when I found Reflections solver didn't work, I have fixing it a shot, and here it is. I just ran it, got me out of the random beautifully.
There are only minor fixes to R_SolvePinball, it would detect the new pinball post before it had changed, causing it tag the same post twice, this has now been fixed. The only other change is to comment out those four lines at the end, which are commented out of almost all randoms that I checked. This random should now work A-OK.

Just call me the exterminator, cause I get rid of bugs.. :D

function R_SolvePinball : Boolean;
var
LastPole, CurrPole: TRSObject;
P: TPoint;
t, lastscore, currscore: integer;
begin
if not R_InPinball then Exit;
while R_InPinball do
begin
lastscore := Pinball_GetScore;
currscore := Pinball_GetScore;
if(currscore >= 10)then
begin
Writeln('Done tagging pillars! Score is 10!');
Result := True;
Pinball_Leave;
Break;
end;
while R_ClickToContinue do
wait(900+Random(900));
LastPole := CurrPole;
MarkTime(t);
while ((LastPole = CurrPole) and (TimeFromMark(t) < 10000)) do
CurrPole := Pinball_GetPillar;
if (CurrPole <> NULL_RSOBJECT)then
begin
P := TileToMS(CurrPole.Tile, 400);
Mouse(P.x, P.y, 3, 3, false);
if R_ChooseOption('tag')then
begin
Writeln('Tagged!');
MarkTime(t);
while((currscore = lastscore) and (TimeFromMark(t) < 10000)) do
begin
if CharacterMoving then
MarkTime(t);
currscore := Pinball_GetScore;
end;
end;
end;
end;
R_ClickToContinue;
Result := not R_InPinball;
{ if Result then
Inc(RSolved[RPinballs])
else
Inc(RFailed[RPinballs]); }
end;

Cstrike

2010-11-24 10:47:11

Another thing that I swear I added somewhere was detection if the camera angle changed too much, which prevented accidental clicking of the wrong pillar.

Maybe I could fuse that with your fixes and have an uber solver :D

Bad Boy JH

2010-11-24 20:23:32

Yes, camera rotation could be an issue, how about……..

We calculate the position, move the mouse half way, recalculate the position, move mouse, could repeat once more.
Could make it a range thing, if the mouse position is in a certain area, then it just goes to the pillar, outside that range it moves half then recalculates.

Cstrike

2010-11-24 20:30:42

I uploaded an old one here, if the camera check coudl be merged:
http://villavu.com/forum/showthread.php?t=59737

That would solve any random errors.

Bad Boy JH

2010-11-24 23:11:11

{*******************************************************************************
function R_PinballAngleDrasticChange (x, y, xMax, yMax : Integer) : Boolean;
By: Cstrike
Description: You input x and y as your current camera angle, and xMax, ymax is
the max value you will accept as the camera not having moved too far away to
cause a misclick. Returns true if the camera changes too drastically. Using 100
for x/yMax is good.
*******************************************************************************}
function R_PinballAngleDrasticChange (x, y, xMax, yMax : Integer) : Boolean;
var xnew, ynew : Integer;
begin
xnew := GetCamPosX;
ynew := GetCamPosY;
if (iAbs(x - xnew) > xMax) or (iAbs(y - ynew) > yMax) then result := true else result := false;
end;


function R_SolvePinball : Boolean;
var
LastPole, CurrPole: TRSObject;
P: TPoint;
x, y, t, lastscore, currscore: integer;
begin
if not R_InPinball then Exit;
while R_InPinball do
begin
lastscore := Pinball_GetScore;
currscore := Pinball_GetScore;
if(currscore >= 10)then
begin
Writeln('Done tagging pillars! Score is 10!');
Result := True;
Pinball_Leave;
Break;
end;
while R_ClickToContinue do
wait(900+Random(900));
LastPole := CurrPole;
MarkTime(t);
while ((LastPole = CurrPole) and (TimeFromMark(t) < 10000)) do
CurrPole := Pinball_GetPillar;
if (CurrPole <> NULL_RSOBJECT)then
begin
x := GetCamPosX;
y := GetCamPosY;
repeat
P := TileToMS(CurrPole.Tile, 400);
Mouse(P.x, P.y, 3, 3, false);
until not R_PinballAngleDrasticChange(X, Y, 100, 100);
if R_ChooseOption('tag')then
begin
Writeln('Tagged!');
MarkTime(t);
while((currscore = lastscore) and (TimeFromMark(t) < 10000)) do
begin
if CharacterMoving then
MarkTime(t);
currscore := Pinball_GetScore;
end;
end;
end;
end;
R_ClickToContinue;
Result := not R_InPinball;
{ if Result then
Inc(RSolved[RPinballs])
else
Inc(RFailed[RPinballs]); }
end;

I think that should work.

Cstrike

2010-11-28 13:27:03

Here is the total version, I moved the X and Y inside the camera angle finder since it would always think it never worked.
This code solved it perfectly. No questions asked :)

{*******************************************************************************
function R_InPinball : Boolean;
by: Drags111
Description: Checks if player is in Pinball Random.
*******************************************************************************}
function R_InPinball : Boolean;
begin
Result := ValidNPC('Tilt');
end;

{*******************************************************************************
function Pinball_GetScore : Integer;
by: lordsaturn
Description: Returns the current score of the player.
*******************************************************************************}
function Pinball_GetScore : Integer;
var
S : string;
begin
S := GetInterfaceText(263, 1);
Delete(S, 1, 7); //+3, +4
Result := StrToIntDef(S, 11);
end;

function Pinball_GetPillar: TRSObject;
begin
Result := GetObjectByIDEx([15000, 15002, 15004, 15006, 15008], 0, 52);
end;

function Pinball_Leave: boolean;
var
TheExit: TRSObject;
P: TPoint;
T: TTile;
time: integer;
begin
TheExit := GetObjectByID(15010, 0, 52);
if (TheExit = NULL_RSOBJECT)then Exit;
MakeCompass('s');
SetAngle(false);
T := TheExit.Tile;
if not TileOnMS(T, 100)then
begin
if not WalkToTile(t, 0, 0)then
Exit;
if not TileOnMs(t, 100)then Exit;
end;
P := TileToMS(T, 100);
Mouse(P.x, P.y, 3, 3, false);
Result := R_ChooseOption('exit cave exit');
if Result then
begin
MarkTime(time);
while(R_InPinball and (TimeFromMark(time) < 10000))do
begin
if(charactermoving)then
MarkTime(time);
Wait(100+Random(500));
end;
end;
end;

{*******************************************************************************
function R_PinballAngleDrasticChange (x, y, xMax, yMax : Integer) : Boolean;
By: Cstrike
Description: You input x and y as your current camera angle, and xMax, ymax is
the max value you will accept as the camera not having moved too far away to
cause a misclick. Returns true if the camera changes too drastically. Using 100
for x/yMax is good.
*******************************************************************************}
function R_PinballAngleDrasticChange (x, y, xMax, yMax : Integer) : Boolean;
var xnew, ynew : Integer;
begin
xnew := GetCamPosX;
ynew := GetCamPosY;
if (iAbs(x - xnew) > xMax) or (iAbs(y - ynew) > yMax) then result := true else result := false;
end;

{*******************************************************************************
function R_SolvePinball : Boolean;
by: lordsaturn, modification added by Bad Boy JH
Description: Solves Pinball Random.
*******************************************************************************}
function R_SolvePinball : Boolean;
var
LastPole, CurrPole: TRSObject;
P: TPoint;
x, y, t, lastscore, currscore: integer;
begin
if not R_InPinball then Exit;
while R_InPinball do
begin
lastscore := Pinball_GetScore;
currscore := Pinball_GetScore;
if(currscore >= 10)then
begin
Writeln('Done tagging pillars! Score is 10!');
Result := True;
Pinball_Leave;
Break;
end;
while R_ClickToContinue do
wait(900+Random(900));
LastPole := CurrPole;
MarkTime(t);
while ((LastPole = CurrPole) and (TimeFromMark(t) < 10000)) do
CurrPole := Pinball_GetPillar;
if (CurrPole <> NULL_RSOBJECT)then
begin
repeat
x := GetCamPosX;
y := GetCamPosY;
P := TileToMS(CurrPole.Tile, 400);
Mouse(P.x, P.y, 3, 3, false);
until not R_PinballAngleDrasticChange(X, Y, 100, 100);
if R_ChooseOption('tag')then
begin
Writeln('Tagged!');
MarkTime(t);
while((currscore = lastscore) and (TimeFromMark(t) < 10000)) do
begin
if CharacterMoving then
MarkTime(t);
currscore := Pinball_GetScore;
end;
end;
end;
end;
R_ClickToContinue;
Result := not R_InPinball;
{ if Result then
Inc(RSolved[RPinballs])
else
Inc(RFailed[RPinballs]); }
end;

Bad Boy JH, I added you as a credit in there. If you don't like it you can remove it, but it's for your work if you so please :)



Committed, should be solved :)
EDIT: Sorry for double post, merging