SRL Archive - Bugs

New Pinball.simba


mormonman

2011-01-13 13:51:17

Exiting didn't always work, so I added some stuff plus changed things to constants. I also fixed some of the problems with script code: 8…it won't get it as often anymore.

const
PINBALL_TOWER1 = 15000;
PINBALL_TOWER2 = 15002;
PINBALL_TOWER3 = 15004;
PINBALL_TOWER4 = 15006;
PINBALL_TOWER5 = 15008;

PINBALL_EXIT = 15010;
PINBALL_TILT = 'Tilt';

{*******************************************************************************
function R_InPinball : Boolean;
by: Drags111
Description: Checks if player is in Pinball Random.
*******************************************************************************}
function R_InPinball : Boolean;
begin
Result := ValidNPC(PINBALL_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;
by: ???
Description: Returns valid pinball tower ID's.
*******************************************************************************}
function Pinball_GetPillar: TRSObject;
begin
Result := GetObjectByIDEx([PINBALL_TOWER1, PINBALL_TOWER2, PINBALL_TOWER3,
PINBALL_TOWER4, PINBALL_TOWER5],
OBJECT_TYPE_INTERACTABLE, 20);
end;

{*******************************************************************************
function R_Pinball_WalkToTileMS(Tile:TTile): boolean;
by: mormonman
Description: Walks to a tile using the MS.
Returns false if the tile isn't on MS.
*******************************************************************************}
function R_Pinball_WalkToTileMS(Tile:TTile): boolean;
var
P: TPoint;
x, y, t: Integer;
begin
if not LoggedIn then
Exit;

if not TileOnMS(Tile, 100) then
Exit;

P := TileToMS(Tile, 50);
MMouse(P.x, P.y, 5, 5);
GetMousePos(x, y);
if WaitUptext('alk here', 300) then
Mouse(x, y, 0, 0, True) else
R_ChooseOption('Walk here');
Wait(RandomRange(120, 180));
t := getsystemtime;
R_Flag;
Result := (GetSystemTime - t) < 60000;
end;


{*******************************************************************************
function Pinball_Leave: boolean;
by: ???
Description: Leaves random.
*******************************************************************************}
function Pinball_Leave: boolean;
var
TheExit: TRSObject;
P, MidP, MeP: TPoint;
T, NewT: TTile;
time, i: integer;
begin
TheExit := GetObjectByID(PINBALL_EXIT, OBJECT_TYPE_INTERACTABLE, 20);
if (TheExit = NULL_RSOBJECT)then Exit;
MakeCompass('s');
SetAngle(false);
T := TheExit.Tile;
MarkTime(time);
if not TileOnMS(T, 100)then
begin
MidP := TileToPoint(t);
repeat
if TileOnMS(T, 100) then
Break;
MeP := TileToPoint(GetMyPos);
MidP := MiddleTPA([MidP, MeP]);
NewT := PointToTile(MidP);
if TileOnMs(NewT, 100)then R_Pinball_WalkToTileMS(NewT);
Inc(i);
until (i > 4) or (TimeFromMark(time) > 20000);
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;
Result := (iAbs(x - xnew) > xMax) or (iAbs(y - ynew) > yMax);
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
R_Debug('Done tagging pillars! Score is 10!', 'Pinball');
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);
wait (5+random(15));
until not R_PinballAngleDrasticChange(X, Y, 100, 100);
if R_ChooseOption('tag')then
begin
R_Debug('Tagged!', 'Pinball');
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;
SetAngle(True);
end;

kitchenrange

2011-01-13 13:54:11

You're the shit morman.

Gu3st...

2011-01-14 17:02:36

From: kitchenrange
You're the man morman.
Fixed :thumbsup:

I'm not sure if it's good or bad to be the shit :p

Sgt Soul

2011-01-14 18:43:42

great job mormonman, keep up the good work :)

pyroryan

2011-01-15 19:53:41

Committed.

3Garrett3

2011-01-16 01:31:33

From: Zyt3x
Fixed :thumbsup:

I'm not sure if it's good or bad to be the shit :p


It's good to be the shit ;)

Bad Boy JH

2011-01-19 23:49:23

"the shit" is good
"shit" is (obviously) bad