1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Greetings Guest!!

    In order to combat SPAM on the forums, all users are required to have a minimum of 2 posts before they can submit links in any post or thread.

    Dismiss Notice
  3. Greetings Guest, Having Login Issues? Check this thread!
    Dismiss Notice
  4. Hail Guest!,
    Please take a moment to read this post reminding you all of the importance of Account Security.
    Dismiss Notice
  5. Author Wes Locher has teamed up with Stratics for a giveaway of his new book Braving Britannia. This book explores the history and impact of Ultima Online and includes interviews from current and past dev team members as well as many UO and Stratics community members. Click here for more details!
    Dismiss Notice

UO Essay: Falling Trees

Discussion in 'UO Atlantic' started by Cear Dallben Dragon, May 7, 2009.

  1. Cear Dallben Dragon

    Cear Dallben Dragon Babbling Loonie
    Stratics Veteran Stratics Legend

    Feb 17, 2005
    Likes Received:
    If a tree falls in a forest and no one is around to hear it, does it make a sound?

    Ultima Online is a big world, containing a myriad of virtual objects of every type and description. Animals, monsters, people, plants, and yes, trees too, all abound over nearly seventy million square meters of territory that exists merely as a figment of data in some server's RAM, dutifully backed up on a daily basis.

    If UO is a persistent world, does everything keep going, even when players aren't there?

    The short answer is: no, unfortunately not. A somewhat commonly known thing amongst our playerbase, for instance, is that mobiles (any dynamic object that can move: animals, monsters, NPCs) don't move when players aren't nearby. This "sleep" behavior was implemented some time ago in order to combat wasted CPU time that bogged down performance for the rest of the game.

    The behavior itself is very simple to understand. Every mobile has its own basic AI loop that executes, sets a short delay, and starts over again. This allows every mobile to evaluate its current situation and respond to it, and then turn control of the CPU back over to the rest of the game.

    In fact, these loops are very short, and we call them ticks or heartbeats. Rather than give every single object in the game its own individual share of the CPU, we have a main thread that runs as a loop as well, which gives short amounts of time to each object on an as needed basis.

    Now, imagine a normal server, like Atlantic. There are over sixty thousand mobiles up and running, all potentially handling their AI loops at any given time. If every mobile tried to execute all the conditions and possibilities available to it, the game would take a gigantic hit in performance. Even worse, imagine if every mobile wanted to actually move.

    And so, instead, if players aren’t within a certain distance, those mobiles just go to sleep, waiting for their time to shine.

    This became a problem, though, while we were working on the Stygian Abyss expansion.

    We wanted to do something we thought would be relatively simple. One of the newer dungeon levels has a series of tombs, each blocked by a gate, hooked to a lever in another room. When the lever is pulled, it should open the gate, releasing the monsters inside.

    Now, normally, that means we just send a message to each monster saying "move down the corridor and get ready to meet the player in the main hallway."

    So we pulled all the levers, eager to see the suddenly full hallway, and to our surprise, found the hallway quite empty. At least, for a moment! Suddenly the monsters came streaming from left and right, coming out of the tombs, now that someone was there to see them.

    Even though we knew about the "sleep" mode for mobiles, we thought we could override it just by directly sending commands to them. This had worked in many other game systems added for live events, such as Sherry the Mouse, an NPC who had a full daily schedule of running around the castle, eating lunch in the kitchen, popping through mouseholes, and generally being cute.

    It turns out, we were wrong! The only reason Sherry worked at all when players weren't around was because she could teleport when her movement checks failed, a failsafe originally designed to deal with griefers trying to trap her in the corner.

    Ultimately, our resolution is a simple one: we've designed a flag that allows some mobiles to avoid the sleep system, which will be implemented in the new expansion. From here on out, parts of the world will come to life more than ever before, existing and evolving apart from the comings and goings of the average observer.

    And while we may not be able to hear a tree chopped down in the woods, and least we know a horde of undead Gargoyles won't be standing idly by when you raid their tombs!
  2. Ahuaeyjnkxs

    Ahuaeyjnkxs stranger diamond

    Nov 16, 2008
    Likes Received:
    Spoilers alert !!! :p

    Hmph... I wont be around to experience your creativity... :sad3:

    I must be disliked or unlikable or something, this is nothing new, but heh ; it hurt to read this essay.