SRL Archive - OSR Help

Main Loop Help?


YoHoJo

2010-03-19 17:22:33

Hey guys, working on the next version of PMS. Going to make a big? change to the main loop, but not sure about how to go about doing it…

Currently, I have something like this (Shortened)

If (TimeFromMark(WeMined) > 90000) Then
Begin
Players[CurrentPlayer].Loc:='Cant Find Rock :(';
StatsGuise('NP:Cnt.Fnd.Rock');
Logout;
Break;
End;

So, If the time between mining rocks is over 1 minute and 30 seconds, then Log Out.

And then later in the loop I have

Players[CurrentPlayer].Active := LoggedIn;
PlayerCurTime := GetSystemTime;
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked + (PlayerCurTime - PlayerStartTime);
Logout;

This sets the current players true/false status to true if logged in, false if logged out.

The problem is, sometimes the script gives the "can't find rock for 1 minute 30 seconds" error, and sets a character to false, yet the character is just fine, outside of a random, and near rocks (weird huh?)

So what I want to do instead is allow a character to get the "can't find rock for 1 minute 30 seconds" error THREE TIMES before setting it to false.

I was thinking of something like, if the error occurs, log out (BUT KEEP THE PLAYER STATUS TRUE), and continue on looping the characters like normal, if the error happens again (and totals 3 times eventually) THEN set the character to false.

That's the best I can explain it for now :) hopefully you all understand, ask for clarification if needed!

Thanks A Bunch!
YoHoJo


Edit:
Hmm Maybe something like
Players[CurrentPlayer].Integers[84] Can be the error counter
Each time the problem happens Inc Integer84
And do something like

If Players[CurrentPlayer].Integers[84] < 3 Then 
Players[CurrentPlayer].Active := True;
else
Players[CurrentPlayer].Active := LoggedIn;

Would that do it? :D!

Bionicle

2010-03-19 17:29:31

@ the edit, i was going to suggest something like this, from what i got from what you explained i think it would work.
But 84 player integers? What the hell? O_o

Sabzi

2010-03-19 17:32:23

I thinks that the time counter is still going while you are in the random. Well I just said that but it's obvious :p.
So what I would try is something like this:

if FindNormalRandoms then
ResetPlayerCounters ...
so that after the player solved the random successfully the counter restarts so that error doesn't come up.
I think you can implement counting the failures too but I think you shouldn't increment it after solved randoms.
However when a player can't find the rock can mean you moved to a weird place somehow(you never know) and then logging in, standing there for 1,5 minutes then logout is maybe suspicious.

YoHoJo

2010-03-19 17:35:19

Nice notice Sabzi, but like I said I shortened the procedure before posting it just so you guys could see the main concept, before/after randoms I have:

      RT:=GetSystemTime;
If FindNormalRandoms Then
IncEx(WeMined, GetSystemTime - RT);

And Bionicle, I started integers at 80 for some reason :]
I have 1, 80,81,82,83 I think? :p

Sabzi

2010-03-19 17:38:05

From: YoHoJo
Nice notice Sabzi, but like I said I shortened the procedure before posting it just so you guys could see the main concept, before/after randoms I have:

      RT:=GetSystemTime;
If FindNormalRandoms Then
IncEx(WeMined, GetSystemTime - RT);


Oh, yes that pretty much solves the problem(not the original I mean).
But that should be DecEx, no? That would make sense why the problem still occurs.

YoHoJo

2010-03-19 17:42:40

I thought that too, and so did TONS of other people, but Icefire said to do it that way, and I even made a test script to see if the concept worked, and it did, still doesn't make sense to me either though!

Edit:
The concept test script:

program New;
{.include SRL\SRL.scar}
var Time,DontWorry:Integer;


begin
MarkTime(Time);
Wait(2000);
DontWorry:=GetSystemTime;
Wait(1000);
IncEx(Time,GetSystemTime - DontWorry);
Writeln(IntToStr(TimeFromMark(Time)))
end.

Sabzi

2010-03-19 17:50:17

I understand now. Thanks for the concept script. The timer is a variable that holds the previous SystemTime and when you call TimeFromMark it just do:
GetSystemTime - PreviousSystemTime
So if you increment the previous system time the end result will be smaller.
It's hard to think about that first. I first thought that "WeMined" is already in milisecs took to mine after TimeFromMark(I don't know why I thought that)
On-topic: Best idea is still yours to make a player variable counting the failures :).

Nava2

2010-03-19 18:45:37

tl;dr: Check out my abyssal crafters main loop. It was t3h sex.

YoHoJo

2010-03-20 14:47:54

More suggestions?
Or more conformation that my idea (on first post) will work?