a few words about UO time in the Ultima Online demo

a few words about UO time in the Ultima Online demo

Postby Batlin on Sun Mar 14, 2010 8:32 pm

My investigation about the "on time" event in the demo is more-or-less finished. These are my results...

The "on time" event listens to UO time and not our time. You can use the getYear, getMonth, getWeek, getDay, getHour, getMinute, getSeconds script functions to retreive the UO time. OSI's Time Manager object is reponsible for increasing the time and starting new seasons etc. The code that does this is located at EIP 0x004D8A9A.

One UO second equals one tick. This means that 4 UO seconds are equal to one human second.
This is a complete table:
1 UO second = 1 tick = 0.25 human seconds (if no lag)
1 UO minute = 20 UO seconds = 5 human seconds
1 UO hour = 60 UO minutes
1 UO day = 24 UO hours
1 UO week = 7 UO days
1 UO month = 4 UO weeks = 28 UO days
1 UO year = 12 UO months = 336 UO days


The file TIME.MUL.Q is a file containing a single dword and represents the UO hour. The Time Manager loads this on startup. The core does not read the year, month etc. Why this is I do not know, it does not seem logical to start from year 0 every server reboot...

The "on time" event supports the following time identfiers: year, month, week, day, hour, minute. This event does not supports seconds, use the callback mechanism instead.

I've created a sample script that logs the current UO time:
Code: Select all
on creation()
{
  string s = "";
  getCurrentTimeStr(s);
  s = s + " / "+ getTimeSecs(void);
  s = s + " / " + getYear() + "-" + getMonth() + "-" + getDay()
          + " (" + getWeek() + ") "
          + getHour() + ":" + getMinute() + ":" + getSeconds();
  systemMessage(this, "Creation: " + s);

  shortcallback(this, 0x00, 0x90);

  return(0x01);
}
on time<"min:*0">()
{
  string s = "";
  getCurrentTimeStr(s);
  s = s + " / "+ getTimeSecs(void);
  s = s + " / " + getYear() + "-" + getMonth() + "-" + getDay()
          + " (" + getWeek() + ") "
          + getHour() + ":" + getMinute() + ":" + getSeconds();
  systemMessage(this, "Min: " + s);
  return(0x01);
}

on callback<0x90>()
{
  string s = "";
  getCurrentTimeStr(s);
  s = s + " / "+ getTimeSecs(void);
  s = s + " / " + getYear() + "-" + getMonth() + "-" + getDay()
          + " (" + getWeek() + ") "
          + getHour() + ":" + getMinute() + ":" + getSeconds();
  systemMessage(this, "Callback: " + s);

  shortcallback(this, 0x00, 0x90);

  return(0x01);
}


This resulted in the following output:
On Time Output.jpg
On Time Output.jpg (133.1 KiB) Viewed 330 times


NOTE
This means that:
1) on time<"min:*0">() = event thrown every 10 UO minutes or ±50 human seconds
2) on time<"min:**">() = event thrown every UO minute or every 20 ticks or every ±5 human seconds

IMPORTANT
UO time is tick-driven! This means that 1 UO second is atleast 0.25 seconds, but if there is server-side lag, 1 tick can take longer than 0.25 seconds. The duration of a tick is highly influenced by server-load!

To retreive the current server-side tick, you can use the getPulseNum function.
<Derrick> RunUO AI is kind of a functional prototype, which i have hacked into something resembling OSI behavior, but only by complitcating everything
Batlin
Site Admin
 
Posts: 306
Joined: Wed Apr 08, 2009 6:35 am


Re: a few words about UO time in the Ultima Online demo

Postby Derrick on Thu Nov 04, 2010 3:04 pm

The syntax is interesting.
I'm going to ask a question i think I know the answer to, but i've been surprised before.

From dec1_brazier_sum:
is ONEVENT( time , "hour:0" )()
equivalent to ONEVENT( time , "day:*" )() ?

And thanks much for this writeup. Very helpful!
Derrick
Site Admin
 
Posts: 250
Joined: Tue Jun 17, 2008 2:33 pm



Return to UO Demo

Who is online

Users browsing this forum: No registered users and 1 guest