SRL's F.A.Q. (Error fixes) | How to Convert SRL-5 Scripts to SRL-6 | Draynor Chop N' Bank (RS3)| AIO Superheater (RS3)
T - E - A - MTogether Everyone Achieves More
What temporary time?
That's pretty much what I've always used, just with all the MSI stuff removed (obviously) :PSimba Code:procedure MSI_HandleBreaking;
var
t, _avg: Integer;
begin
if (not LoggedIn) then
Exit;
if not MSI_SetupVars[SETUP_HUMAN_BREAK] then
if MSI_Players[CurrentPlayer].BreakTime = 0 then
if MSI_SetupVars[SETUP_BREAK_TIME] = 0 then
Exit;
if (BankScreen) then
CloseBank;
MSI_AddHeader('MSI_HandleBreaking');
if (HowManyPlayers = 1) or (PlayersActive = 1) then
begin
MSI_Debug('Taking a short break');
if MSI_SetupVars[SETUP_HUMAN_BREAK] then
case Random(10) of
0, 2: Logout;
1: while LoggedIn do
MSI_FindRandoms(False);
3..6: begin
t := (GetSystemTime + RandomRange(60000, 60000 * 3));
while (t > GetSystemTime) and LoggedIn do
MSI_FindRandoms(False);
if LoggedIn then
if InRange(Random(10), 1, 5) then
Logout
else
ExitToLobby;
end;
7..9: ExitToLobby;
end
else
if InRange(Random(10), 2, 9) then
ExitToLobby;
_avg := Round(SETUP_BREAK_TIME * RANDOM_TIME_PERCENT);
t := (GetSystemTime + ((MSI_SetupVars[SETUP_BREAK_TIME] * 60000) + RandomRange(-_avg * 60000, _avg * 60000)));
while GetSystemTime < t do
begin
Status('MSI_SetupVars[SETUP_BREAK_TIME] remaining: '+MsToTime(t - GetSystemTime, Time_Formal)+';');
Wait(RandomRange(2000, 25000));
if LoggedIn then
MSI_FindRandoms(True);
end;
MSI_Debug('Break over, continuing to play');
if (LobbyScreen) then
MouseBox(80, 450, 560, 470, 1);
end else
begin
MSI_Debug('Switching players');
NextPlayer(True);
end;
WaitFunc(@LoggedIn, 100, 15000);
stats_IncVariable('Total Logins', 1);
MSI_CloseHeader('MSI_HandleBreaking: ' + BoolToStr(LoggedIn));
end;
That's actually what I' m adding right now. I had an idea, but I need some feedback. Should I have the time left for each break displayed on the SMART canvas or in the debug box? I can do it either way, I just need some opinions. I'm also testing my multiplayer implementation right now, I will post it if it works.
SRL's F.A.Q. (Error fixes) | How to Convert SRL-5 Scripts to SRL-6 | Draynor Chop N' Bank (RS3)| AIO Superheater (RS3)
T - E - A - MTogether Everyone Achieves More
I got the breakhandler to work with 2 players now It now reads how many players are active, and if there are 2 players active, the script will break then log into players[1]. After players[0]' s break has finished, it will then log out of players[1] and log back into players[0]. I also added a total breaks variable for progress reports. I'm still working on adding a continuous breaking timer for the debug box and multiplayer support for up to 5 players Here's the code if you want to look it over or test it.
global vars:
Simba Code:var
BreakRounds, TotalBreaks: Integer
Break handler:
Simba Code:{*******************************************************************************
procedure BreakHandler(BreakIn, BreakFor, randBreakIn, randBreakFor: Integer);
By: Echo_
Description: Takes brakes according to the minute values entered
*******************************************************************************}
function BreakHandler(BreakIn, BreakFor, randBreakIn, randBreakFor: Integer): Boolean;
var
w, x, y, z: 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
Writeln('Taking a break for about ' + IntToStr(BreakFor) + ' minutes.');
Logout;
Wait((x) + (z));
Writeln('Logging in.');
LoginPlayer;
Result := LoggedIn;
FindNormalRandoms;
IncEx(BreakRounds, (w) + (x));
IncEx(TotalBreaks, 1);
Writeln('The next break will occur in about ' + IntToStr(BreakIn) + ' minutes.');
end;
end;
if (HowManyPlayers = 2) then
begin
if (GetTimeRunning < ((w) + (y) + BreakRounds)) then Exit
else
if (GetTimeRunning > ((w) + (y) + BreakRounds)) then
begin
Writeln('Taking a break for about ' + IntToStr(BreakFor) + ' minutes.');
Logout;
IncEx(BreakRounds, (w) + (x));
IncEx(TotalBreaks, 1);
Writeln('Logging in to ' + Capitalize(Players[1].Nick) + '.');
NextPlayer(True);
Exit;
while (CurrentPlayer = 1) do Wait((x) + (z));
Writeln('Switching back to ' + Capitalize(Players[0].Nick) + '.');
SwitchToPlayer(0, True);
end;
end;
end;
Couldn't you just do if HowManyPlayers >= 2 then?
There used to be something meaningful here.
I was planning on doing one for each amount of players, not just 1, 2, and 5.
So something kind of like this then?
Simba Code:if (HowManyPlayers > 1) then
begin
if (GetTimeRunning < ((w) + (y) + BreakRounds)) then Exit
else
if (GetTimeRunning > ((w) + (y) + BreakRounds)) then
begin
Writeln('Taking a break for about ' + IntToStr(BreakFor) + ' minutes.');
Logout;
IncEx(BreakRounds, (w) + (x));
IncEx(TotalBreaks, 1);
Writeln('Logging in to ' + Capitalize(Players[CurrentPlayer + 1].Nick) + '.');
NextPlayer(True);
Exit;
while (LoggedIn) do Wait((x) + (z));
Writeln('Switching back to ' + Capitalize(Players[CurrentPlayer - 1].Nick) + '.');
SwitchToPlayer(CurrentPlayer - 1, True);
end;
end;
It eventually has to switch back to the first player in a loop.
NextPlayer should take care of that.
There used to be something meaningful here.
Thanks Frement, you saved me a lot of unneeded work I updated my OP, all I have left to add is the debug box timer.
I still have to add a debug box timer.
Simba Code:const
BREAK_EVERY = 0;
BREAK_RAND = 1;
BREAK_PREV = 2;
BREAK_NEXT = 3;
type
TBreakProc = procedure;
var
BreakHandler: array[BREAK_EVERY..BREAK_NEXT] of extended;
BreakProc: TBreakProc;
procedure ResetBreak;
begin
BreakHandler[BREAK_NEXT] := GetSystemTime + (BreakHandler[BREAK_EVERY] + Random(BreakHandler[BREAK_RAND]));
end;
procedure FBreak;
begin
BreakHandler[BREAK_PREV] := GetSystemTime;
if (BreakProc <> nil) then
BreakProc();
ResetBreak;
end;
procedure Break;
begin
if (GetSystemTime > BreakHandler[BREAK_NEXT]) then
FBreak;
end;
function TimeToBreak: extended;
begin
Result := BreakHandler[BREAK_NEXT];
end;
function TimeFromBreak: extended;
begin
Result := BreakHandler[BREAK_PREV];
end;
procedure SetupBreaks(Break: TBreakProc; BreakEvery, Randomness: extended);
begin
BreakProc := @Break;
BreakHandler[BREAK_EVERY] := BreakEvery;
BreakHandler[BREAK_RAND] := Randomness;
end;
- Include BreakHandler above.
- SetupBreaks(@YourBreakProc, BreakEveryMS, RandomNess);
- ResetBreaks; (Do this every time you switch players);
- Add Break; to a location in your main loop where the player can break!
- Add FBreak; to locations you want to force a break even if the timer hasn't expired!
Last edited by Dgby714; 04-29-2011 at 11:13 PM.
Bump.
This seems good to implement.
Do you mind me using/changing it in one of my scripts?
"Logic never changes, just the syntax" - Kyle Undefined?
Remember, The Edit Button Is There For A Reason!!!
I've used it in all of my scripts, very stable, very reliable.
I did, however modify a few things here and there in relevance to my script, but there was one small fix I had for you.
Where you have this:
It actually writes how much initial break time it will spend, not counting the random +/- minutes it has added to the break time. For example, if you had an initial break time set for 10 minutes with a 5 minute randomness, it'll say, every time, that the break will last for 10 minutes.Simba Code:Writeln('Taking a break for about ' + IntToStr(BreakFor) + ' minutes.');
So I declared this within the function:
And changed this:Simba Code:RealBTime: integer;
To this:Simba Code:Writeln('Taking a break for about ' + IntToStr(BreakFor) + ' minutes.');
Simba Code:RealBTime := ((x+z)/60000);
Writeln('Taking a break for about ' + IntToStr(RealBTime) + ' minutes.');
Works like a charm.
Current projects:
[ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]
"I won't fall in your gravity. Open your eyes,
you're the Earth and I'm the sky..."
"Logic never changes, just the syntax" - Kyle Undefined?
Remember, The Edit Button Is There For A Reason!!!
What system are you guys using? The one Dgby posted or the one Echo_ posted?
SRL's F.A.Q. (Error fixes) | How to Convert SRL-5 Scripts to SRL-6 | Draynor Chop N' Bank (RS3)| AIO Superheater (RS3)
T - E - A - MTogether Everyone Achieves More
Echo_'s. I don't see why we should use anything differently.
Current projects:
[ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]
"I won't fall in your gravity. Open your eyes,
you're the Earth and I'm the sky..."
SRL's F.A.Q. (Error fixes) | How to Convert SRL-5 Scripts to SRL-6 | Draynor Chop N' Bank (RS3)| AIO Superheater (RS3)
T - E - A - MTogether Everyone Achieves More
There are currently 1 users browsing this thread. (0 members and 1 guests)