SRL Archive - Outdated / Broken

[Base]Oak larder constructor


Flight

2011-08-02 03:18:16

I'm tired of screwing with it… The servant finding/calling is the only problem. If you run it next the larder with the servant near you it'll run great (until logged out or a random event is triggered).

I'm not asking for help, so just do whatever you want with it. I've better scripts I can be putting my time into…



program Lardermatic;

{$define SMART}
{$i srl/srl.scar}
{$i SRL/SRL/Misc/stats.simba}
{$i Reflection/Reflection.simba}


//////////////////////////////-Begin setup-/////////////////////////////////////

Const

//SRL Stats
SRLStats_Username = '';
SRLStats_Password = '';

//Script settings
ChangeWorlds = True;

//Break settings
BreakIn = 65; //How long before we take a break? (minutes)
BreakFor = 13; //How long will we break for? (minutes)
Bir = 12; //Random minutes to add/subtract from how long until we break
Bfr = 5; //Random minutes to add/subjtract from break duraction

//////////////////////////////-End of setup-////////////////////////////////////

Var
NewXP,OldXP,StartXP,
CommitTime,LarderCount,
OldCount,NewCount: Integer;

procedure DeclarePlayers;
begin
HowManyPlayers :=1;
CurrentPlayer :=0;
NumberOfPlayers (HowManyPlayers);
with Players [0] do
begin
Name := '';
Pass := '';
Pin := '';
Member := true;
Active := true;
end;
end;

Procedure LoadVars;
begin
MarkTime(CommitTime);
LarderCount := 0;
OldCount := 0;
MouseSpeed := RandomRange(11,13);
OldXP := R_GetSkillExp(SKILL_CONSTRUCTION);
StartXP := R_GetSkillExp(SKILL_CONSTRUCTION);
end;

Procedure CheckStats;
begin
if ((SRLStats_Username = '') And (SRLStats_Password = '')) then
begin
case MessageBox('No Stats account entered, would you like to set one up?','SRL Stats',mbYesNoCancel) of
mrYes:
begin
OpenWebPage('http://stats.villavu.com/register');
TerminateScript;
end;
mrNo:
begin
SetupSRLStats(159,'Anonymous','anon1337');
Exit;
end;
mrCancel: TerminateScript;
end;
end else
SetupSRLStats(159,SRLStats_Username,SRLStats_Password);
end;

Procedure PrintOnSmart(TP: TStringArray; Placement: TPoint; Colour: integer);
var
mx, my, Pic, I, B, H, TPH, Numb: Integer;
TTP: TPointArray;
Canvas: TCanvas;
begin
SmartSetDebug(True);
GetClientDimensions(mx, my);
Pic := BitmapFromString(mx, my, '');
TPH := High(TP);
for I := 0 to TPH do
begin
TTP := LoadTextTPA(TP[i], SmallChars, H);
for B := 0 to High(TTP) do
begin
Numb := ((I + 1) * 13);
FastSetPixel(Pic, TTP[b].x + 1, TTP[b].y + Numb + 1,131072);
FastSetPixel(Pic, TTP[b].x, TTP[b].y + Numb, Colour);
end;
end;
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
DrawBitmap(Pic, Canvas, Placement.x, Placement.y);
FreeBitmap(Pic);
end;

Procedure OnScreen;
Var
Exp,XPH,LPH: Integer;
begin
Exp := R_GetSkillExp(SKILL_CONSTRUCTION) - StartXP;

XPH := Round((Exp * 3600) / (GetTimeRunning / 1000));
LPH := Round((LarderCount * 3600) / (GetTimeRunning / 1000));

PrintOnSmart(['~Lardermatic (by Flight)~'],Point(15,30),15790587);
PrintOnSmart([''+TimeRunning,'Construction XP: '+IntToStr(Exp)+' ('+IntToStr(XPH)+' XP/Hour)',
'Made '+IntToStr(LarderCount)+' larders ('+IntToStr(LPH)+'/Hour)'],Point(20,60),15856381);

end;

Procedure Commit;
begin

NewXP := R_GetSkillExp(SKILL_CONSTRUCTION);
NewCount := LarderCount;

stats_IncVariable('Construction EXP (Gained)',(NewXP-OldXP));
stats_IncVariable('Oak Larders (Constructed)',NewCount);
Stats_Commit;

OldXP := NewXP;
OldCount := NewCount;

MarkTime(CommitTime);

end;

Procedure BuildMode;
Var
X,Y,BMP,T,TT: Integer;
begin
BMP := BitmapFromString(12, 10, 'meJxlkEEKwzAMBP2TfCXgHHzwIc' +
'WBpIfmXfltO3RgCcQIsVqtVrbHsffXmli3jdx6B5CNtKbrS4xjlzT' +
'PdQGMv4/dUgoAvW4xRCmPwNbdTYelNUgF6B2hnGvN0mieI4BsicZB' +
'S7CveJ8fsSSRXeE5Mc8/WAawCCtLMhiA+K7hDj+v5HJN');
setbitmapname(BMP,'ConButton');

if TabExists(tab_Options) then
if GameTab(tab_Options) then
begin
MMouse(695,430,15,15);
Wait(Random(100));
if WaitUpTextMulti(['pen','ouse','ptions'], 500) then
begin
ClickMouse2(True);
MarkTime(T);

repeat
if (TimeFromMark(T) > 5000) then
Exit;
if FindBitmapToleranceIn(BMP,X,Y,560,260,595,295,10) then
break;
Wait(10);
until(false)

MMouse(X,Y,15,15);
Wait(Random(100));
if WaitUpTextMulti(['uilding','ode','on'], 500) then
begin
ClickMouse2(True);
Wait(RandomRange(150,250));

MarkTime(TT);
Repeat
if(TimeFromMark(TT) > 5000)then
Break;

if(R_PinScreen)then
begin
if(Length(Players) > 0)then
if Players[CurrentPlayer].Pin <> '' then
begin
R_InPin(Players[CurrentPlayer].Pin);
MarkTime(TT);
end else
begin
R_Debug('PinScreen found, but no pin to enter.', 'R_OpenBankBooth');
Exit;
end
else begin
R_Debug('PinScreen found, but no pin to enter.', 'R_OpenBankBooth');
Exit;
end;
end;
if FindBlackChatMessage('mode is now on') then
Break;
Wait(1);
Until(False)

FreeBitmap(BMP);
Exit;
end;
end;

end;
FreeBitmap(BMP);
end;

Procedure ScriptSetup(Term:String;World:Integer;Memb,Signed,Clear,SetCam:Boolean);
Begin

if (Not (Term = '')) then
AddOnTerminate(Term);

Smart_Server := World;
Smart_Members := Memb;
Smart_Signed := Signed;
Smart_SuperDetail := False;

SetupSRL;
DeclarePlayers;
R_UpdateHooks;
CheckStats;

if Clear then
ClearDebug;
LoginPlayer;
if SetCam then
SetAngle(true);

LoadVars;
OnScreen;
BuildMode;

End;

Function ServantNear: Boolean;
Var
Servant: TNPC;
begin

Servant := R_GetNPCMulti(['Rick','Maid','Cook','Butler','Demon'],True);
if (Servant = NULL_NPC) then
Exit;

Result := R_TileOnMS(Servant.Tile,0);

end;

Function NeedPlanks: Boolean;
begin
Result := (R_CountItem(8778) < 8);
end;

Function LarderScreen: Boolean;
begin
Result := R_ValidInterface(394);
end;

Function AreaCheck(Where: String): Boolean;
Var
OPortal,IPortal,Larder: TRSObject;
begin
Result := False;

OPortal := R_GetObject(15482, OBJ_INTERACTABLE, 5);
IPortal := R_GetObject(13405, OBJ_INTERACTABLE, 5);
Larder := R_GetObject(15403, OBJ_INTERACTABLE, 5);

Case LowerCase(Where) of

'outside' : Result := Not (OPortal = NULL_RSOBJECT);

'inside': Result := Not (IPortal = NULL_RSOBJECT);

'larder': Result := Not (Larder = NULL_RSOBJECT);

end;
end;

Function MorePlanks: Boolean;
Var
N: TPoint;
Servant: TNPC;
SentText: Boolean;
T,T2,T3,T4,B: Integer;
begin
OnScreen;

MarkTime(B);
repeat

if (TimeFromMark(B) > 3000) then
Exit;
Servant := R_GetNPCMulti(['Rick','Maid','Cook','Butler','Demon'],True);
N := R_TileToMSEx(Servant.Tile, 0.5, 0.5, 100);

MMouse(N.X,N.Y,15,15);
//if WaitUpText('Talk-to', RandomRange(500,800)) then
if Not WaitUpText('Walk here', RandomRange(500,800)) then
begin
ClickMouse2(False);
break;
end;

Wait(RandomRange(150,300));

until(false)

if ChooseOption('Fetch') then
begin

MarkTime(T);
repeat
if (TimeFromMark(T) > 3000) then
Exit;
if FindNPCChatText('coins',Nothing) then //Servant's payday
begin
if ClickToContinue then
begin
Wait(RandomRange(850,1250));

if FindNPCChatText('your bank',ClickLeft) then
ClickToContinue;
end;
Exit;
end;

if FindNPCChatText('would you',Nothing) then
break;

Wait(1);
until(False)

if FindNPCChatText('another',ClickLeft) then
SentText := True
else
SentText := False;

if Not SentText then
begin

MarkTime(T2);
repeat
if (TimeFromMark(T2) > 3000) then
Exit;
if FindNPCChatText('Oak plan',ClickLeft) then
break;
Wait(1);
until(False)

MarkTime(T3);
repeat
if (TimeFromMark(T3) > 3000) then
Exit;
if (R_GetInterfaceText(752, 4) = 'Enter amount:') then
break;
Wait(1);
until(False)

if (R_GetInterfaceText(752, 4) = 'Enter amount:') then
begin
Wait(RandomRange(850,1250));
TypeSend(IntToStr(24));
end;

end;
end;

MarkTime(T4);
repeat
if (TimeFromMark(T4) > 60000) then
Exit;
if Not NeedPlanks then
break;
Wait(1);
until(False)

if Not NeedPlanks then
Exit;
//Result := True;

end;

{Function FindServant: Boolean;
Var
N: TPoint;
Servant: TNPC;
SentText: Boolean;
Larder: TRSObject;
T,T2,T3: Integer;
begin
OnScreen;
Larder := R_GetObjectEx([15403,13566], OBJ_INTERACTABLE, 75)
if (Larder = NULL_RSOBJECT) then
Exit;
//L := R_TileToMSEx(Point(Larder.Tile.X1, Larder.Tile.Y1), 0.5, 0.5, 0); //TileArea, 1,1,0

//MarkTime(T);
repeat

//if (TimeFromMark(T) > 3000) then
//Exit;
R_FindRandoms;
Servant := R_GetNPCMulti(['Rick','Maid','Cook','Butler','Demon'],True);
N := R_TileToMSEx(Servant.Tile, 0.5, 0.5, 100);

if (Not R_TileOnMS(Servant.Tile,0)) then
begin
While Not R_TileOnMM(Servant.Tile) do
begin
Writeln('Waiting...');
R_WindWalk(Point(Servant.Tile.X,Servant.Tile.Y));
//R_FindRandoms
//Wait(500);
end;
Writeln('Found!');
R_WindWalk(Point(Servant.Tile.X,Servant.Tile.Y));
While R_Moving do
Wait(1);
end;

MMouse(N.X,N.Y,15,15);
if WaitUpText('Talk-to', RandomRange(500,800)) then
begin
ClickMouse2(False);
break;
end;
Wait(1);

until(false)

if ChooseOption('Fetch') then
begin

MarkTime(T);
repeat
if (TimeFromMark(T) > 3000) then
Exit;
{if FindNPCChatText('coins',Nothing) then //Servant's payday
begin
if ClickToContinue then
begin
Wait(RandomRange(850,1250));

if FindNPCChatText('your bank',ClickLeft) then
ClickToContinue;
end;
Exit;
end;}

{if FindNPCChatText('would you',Nothing) then
break;

Wait(1);
until(False)

if FindNPCChatText('another',ClickLeft) then
SentText := True
else
SentText := False;

if Not SentText then
begin

MarkTime(T2);
repeat
if (TimeFromMark(T2) > 3000) then
Exit;
if FindNPCChatText('Oak plan',ClickLeft) then
break;
Wait(1);
until(False)

MarkTime(T3);
repeat
if (TimeFromMark(T3) > 3000) then
Exit;
if FindNPCChatText('amount', Nothing) then
break;
Wait(1);
until(False)

if FindNPCChatText('amount', Nothing) then
begin
TypeSend(IntToStr(24));
R_WindWalk(Point(Larder.Tile.X+1,Larder.Tile.Y-1));
While R_Moving do
Wait(1);
end;

end;
end;
end;}

Function CallServant: Boolean;
Var
N,P,wTile: TPoint;
Servant: TNPC;
SentText: Boolean;
Bell,Larder: TRSObject;
T,T2,T3,T4,B: Integer;
begin
OnScreen;

Bell := R_GetObject(13308, OBJ_INTERACTABLE, 75);
Larder := R_GetObjectEx([15403,13566], OBJ_INTERACTABLE, 75);
wTile := R_TileToMM(Larder.Tile);
if (Bell = NULL_RSOBJECT) then
Exit;

Wait(RandomRange(2000,2500));
R_WindWalk(Bell.Tile);
While R_Moving do
Wait(1);

MarkTime(B);
repeat
if (TimeFromMark(B) > 10000) then
Exit;
P := R_TileToMSEx(Point(Bell.Tile.X, Bell.Tile.Y+1), 0.5, 0.5, 150);

MMouse(P.X, P.Y, 25, 25);
if WaitUpTextMulti(['Ring','Bell','Pull'], RandomRange(500,800)) then
begin
ClickMouse2(True);
if DidRedClick then
begin
Wait(RandomRange(2000,2500));
break;
end;
end;
until(False);

MarkTime(T);
repeat
if (TimeFromMark(T) > 5000) then
Exit;

Servant := R_GetNPCMulti(['Rick','Maid','Cook','Butler','Demon'],True);
N := R_TileToMSEx(Servant.Tile, 0.5, 0.5, 100);

MMouse(N.X,N.Y,15,15);
if WaitUpText('Talk-to', RandomRange(500,800)) then
begin
ClickMouse2(False);
if ChooseOption('Fetch') then
begin
Wait(RandomRange(2000,2500));
break;
end;
end;
Wait(1);

until(false)

MarkTime(T2);
repeat
if (TimeFromMark(T2) > 3000) then
Exit;
if FindNPCChatText('coins',Nothing) then //Servant's payday
begin
if ClickToContinue then
begin
Wait(RandomRange(850,1250));

if FindNPCChatText('your bank',ClickLeft) then
ClickToContinue;
end;
Exit;
end;

if FindNPCChatText('would you',Nothing) then
break;

Wait(1);
until(False)

if FindNPCChatText('another',ClickLeft) then
SentText := True
else
SentText := False;

if Not SentText then
begin
MarkTime(T3);
repeat
if (TimeFromMark(T3) > 3000) then
Exit;
if FindNPCChatText('Oak plan',ClickLeft) then
break;
Wait(1);
until(False)

MarkTime(T4);
repeat
if (TimeFromMark(T4) > 3000) then
Exit;
if (R_GetInterfaceText(752, 4) = 'Enter amount:') then
break;
Wait(1);
until(False)

if (R_GetInterfaceText(752, 4) = 'Enter amount:') then
begin
Wait(RandomRange(850,1250));
TypeSend(IntToStr(24));
end;
end;

R_WindWalk(Point(Larder.Tile.X+1,Larder.Tile.Y-1));
While R_Moving do
Wait(1);
While Not ServantNear do //Inifite loop, needs to be properly coded
Wait(1);
//R_WalkToTile(Point(Larder.Tile.X+1,Larder.Tile.Y-1),0,1); //Put us in the optimum placement to our larder
//Mouse(wTile.X+1,wTile.Y-1,0,0,True);
//Wait(RandomRange(850,1250));
//While R_Moving do
//Wait(1);
end;

Function BuildLarder: Boolean;
Var
T,TT: Integer;
MP,LP: TPoint;
Larder: TRSObject;
begin
Result := False;
MP := Point(115,140);
MouseSpeed := RandomRange(11,13);

Larder := R_GetObject(15403, OBJ_INTERACTABLE, 5)
if (Larder = NULL_RSOBJECT) then
Exit;
LP := R_TileToMSEx(Point(Larder.Tile.X, Larder.Tile.Y), 0.6, 0.6, 0);

MMouse(LP.X, LP.Y, 10, 10);
ClickMouse2(False);

if ChooseOption('Build') then
begin

MarkTime(T);
repeat

if (TimeFromMark(T) > 5000) then
Exit;
if LarderScreen then
Break;
Wait(1);

until(False)

end;

if LarderScreen then
begin

MMouse(MP.X,MP.Y,10,10);
if WaitUptextMulti(['Build','Oak','larder'], RandomRange(500,800)) then
begin
ClickMouse2(True);
MarkTime(TT);

repeat

if (TimeFromMark(TT) > 5000) then
Exit;
if Not (R_GetObject(13566, OBJ_INTERACTABLE, 5) = NULL_RSOBJECT) then
Break;
Wait(1);

until(False)

Inc(LarderCount);

end;
end;

if Not (R_GetObject(13566, OBJ_INTERACTABLE, 5) = NULL_RSOBJECT) then
begin
Wait(RandomRange(1100,1300));
Result := True;
Inc(LarderCount);
end;

end;

Function DestroyLarder: Boolean;
Var
T: Integer;
MP,LP: TPoint;
Larder: TRSObject;
begin
Result := False;
MP := Point(115,140);
MouseSpeed := RandomRange(11,13);

Larder := R_GetObject(13566, OBJ_INTERACTABLE, 5)
if (Larder = NULL_RSOBJECT) then
Exit;
LP := R_TileToMSEx(Point(Larder.Tile.X, Larder.Tile.Y), 0.6, 0.6, 0);

MMouse(LP.X, LP.Y, 10, 10);
ClickMouse2(False);

if ChooseOption('Remove') then
begin

MarkTime(T);
repeat

if (TimeFromMark(T) > 5000) then
Exit;
if FindNPCChatText('Yes',ClickLeft) then
Break;
Wait(1);

until(False)

end;

Wait(RandomRange(1100,1300));
if Not (R_GetObject(15403, OBJ_INTERACTABLE, 5) = NULL_RSOBJECT) then
Result := True;

end;

Function EnterHouse: Boolean;
Var
T,T2: Integer;
TP: TPoint;
Portal: TRSObject;
begin
Result := False;
MouseSpeed := RandomRange(14,17);

Portal := R_GetObject(15482, OBJ_INTERACTABLE, 5)
if (Portal = NULL_RSOBJECT) then
Exit;
TP := R_TileToMSEx(Point(Portal.Tile.X, Portal.Tile.Y), 0.5, 0.5, 0);

MarkTime(T);
repeat
if (TimeFromMark(T) > 10000) then
Exit;
MMouse(TP.X, TP.Y, 15, 15);
if WaitUpTextMulti(['Enter','Portal'], RandomRange(500,800)) then
begin
ClickMouse2(True);
Wait(RandomRange(1700,2100));
if FindNPCChatText('mode',Nothing) then
break;
end;

until(false)

if FindNPCChatText('mode',ClickLeft) then
begin

MarkTime(T2);
repeat

if (TimeFromMark(T2) > 10000) then
Exit;
if AreaCheck('Inside') then
Break;
Wait(1);

until(False)

end;

if AreaCheck('Inside') then
Result := True;

end;

{Function BreakHandler(BreakIn, BreakFor, randBreakIn, randBreakFor: Integer): Boolean;
Var
w,x,y,z,h,m,s,
RealBTime,
CurrentBTime: integer;
begin
if not LoggedIn then Exit;

w := (BreakIn * 60000);
x := (BreakFor * 60000);
y := RandomRange(-randBreakIn * 60000, randBreakIn * 60000);
z := RandomRange(-randBreakFor * 60000, randBreakFor * 60000);

if (HowManyPlayers = 1) then
begin
if (GetTimeRunning < ((w) + (y) + BreakRounds)) then Exit
else
if (GetTimeRunning > ((w) + (y) + BreakRounds)) then
begin
if AreaCheck('bank') then
begin
RealBTime := ((x+z)/60000);
Writeln('Taking a break for about ' + IntToStr(RealBTime) + ' minutes.');
Logout;
BreakScreen;
MarkTime(CurrentBTime);
repeat
Wait(21000);
ConvertTime((x+z)-TimeFromMark(CurrentBTime), h, m, s);
ClearDebug;
Writeln('Breaktime left: '+IntToStr(h)+':'+IntToStr(m)+':'+IntToStr(s));
until(TimeFromMark(CurrentBTime)>(x+z));
Writeln('Logging in.');
OnScreen;
if ChangeWorlds then
if LoginPlayerToLob then
ChangeWorld(RandomWorld(True, False))
else
LoginPlayer;
Wait(4000);
Result := LoggedIn;
BuildMode; //Required to re-activate build mode
R_FindRandoms;
IncEx(BreakRounds, (w) + (x));
Inc(TotalBreaks);
Writeln('The next break will occur in about ' + IntToStr(BreakIn) + ' minutes.');
end;
end;
end;
end; }

Begin

ScriptSetup('',86,True,True,True,True);

Repeat

//if (TimeFromMark(CommitTime)>=30000) then //Report every 30 seconds
//Commit;

if not LoggedIn then LoginPlayer;
R_FindRandoms;

if AreaCheck('Larder') then
begin
if NeedPlanks then
if ServantNear then
MorePlanks
else begin
BuildLarder;
DestroyLarder;
end;
end else if AreaCheck('Outside') then
EnterHouse
else if AreaCheck('Inside') then
CallServant;
//FindServant;

Wait(1);

Until(False);

End.