SRL Archive - OSR Help

Calculating per hour


King of the Nites

2011-05-09 21:00:59

Hi!
Okay, so my problem is that I can't figure out why my experience/hr and my fish cooked/hr won't report the correct numbers…
Here is what my proggy looks like:

[=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=]
[ King's Al Kharid Cooker ]
[ Version 0.91 ]
[ Progress Report ]
[=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=]
[ Worked for 16 Minutes and 51 Seconds ]
[ Banked 9 loads! ]
[ Cooked 209 total fish! ]
[ Burnt 43 total fish! ]
[ Cooking 896 fish per hour! ]
[ Gained 20900 experience! ]
[ Gaining -2045 cooking experience per hour! ]
[ Gained 3 level(s)! ]
[=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=]
[ Individual Report ]
[=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=]
[ [#] | A | Loads | Cooked | Type of Fish ]
[ [0] | T | 12 | 209 | Tuna ]
[=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=]

This is my progress report function:
  WriteLn('[=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=]');
WriteLn('[ King''s Al Kharid Cooker ]');
WriteLn('[ Version 0.91 ]');
WriteLn('[ Progress Report ]');
WriteLn('[=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=]');
WriteLn('[ ' + PadR('Worked for ' + TimeRunning, 56) + ']');
WriteLn(PadR('[ Banked ' + IntToStr(LoadsDone) + ' loads!', 58) + ']');
WriteLn(PadR('[ Cooked ' + IntToStr(KingCooked) + ' total fish!', 58) + ']');
WriteLn(PadR('[ Burnt ' + IntToStr(KingBurnt) + ' total fish!', 58) + ']');
WriteLn(PadR('[ Cooking ' + IntToStr(Round(((KingCooked + KingBurnt) * 3600000) / (GetTimeRunning - TotBreak))) + ' fish per hour!', 58) + ']');
WriteLn(PadR('[ Gained ' + IntToStr(KingXP) + ' experience!', 58) + ']');
WriteLn(PadR('[ Gaining ' + IntToStr(Round(((KingXP) * 3600000) / (GetTimeRunning - TotBreak))) + ' cooking experience per hour!', 58) + ']');
WriteLn(PadR('[ Gained ' + IntToStr(KingLevels) + ' level(s)!', 58) + ']');
If you need to look at more of my script, click the Al Kharid Cooker link in my sig.
Thanks,
King of the Nites

Method

2011-05-09 21:16:00

I'd guess that KingXP * 3600000 is overflowing and wrapping around to the negative side of the spectrum. Consider using a larger data type or switching the order of operations around, if possible.

Flight

2011-05-09 21:21:39

I think you're gonna have to include break time, so it would be something like this:

Round((KingXP * 3600) / (GetTimeRunning / 1000));

HarryJames

2011-05-09 21:24:15

You could remove a few 0's from the math and just writeln them in. I'm vey tired so you should probably ignore me.

Brandon

2011-05-09 22:18:14

'Exp/hour: ' + ToStr(Round((Exp * 3600) / (GetTimeRunning / 1000),2))

Note instead of using Round, you can use ceil.. I also had this problem it is overflowing.. and even if u did change it to int64 or a larger variable type, it still never worked at all..

Floor66, tomtuff both helped me get that function working

TomTuff

2011-05-09 22:41:19

XPperHR := Round((XP * 60.0)/(PlayerWorked(~) / 60000.0))

trojan

2011-05-10 04:00:34

For xp/h can you do AmountDone / HoursRun? and another question is does anyone know why "HoursRun" always returns as an integer.


var
HoursRun :Extended;
TimeRun :Integer;

begin
for i := 0 to (HowManyPlayers - 1) do
begin
TimeRun := Players[i].Integers[13] - Players[i].Integers[14]
HoursRun := (TimeRun / 3600000)
Writeln('!!!Minutes Run = ' + FloatToStr(TimeRun/60000));
Writeln('!!!Hours Run = ' + FloatToStr(HoursRun));

Integers[13] is Time run and [14] is breaking time. Minutes run returns correctly though.

HarryJames

2011-05-10 08:46:02

Change to declaration of TimesRun to a float and it should fix that problem.