Tags and Events

Gin mad engineer

Simulation of Nicholas’s ravings in-engine.

The IGF has announced today that they are removing the Technical Excellence category from their awards because of, quote, “widespread, affordable middleware”. Since I am a shattered pinion of a man, barely holding together and clutching a bottle of gin in the wake of this decision, I… I…

I don’t know what to write about any more.

I lurched into the office this morning. “What do we do?!” I asked nobody in particular. “Let’s… let’s… stop everything! Let’s license Unity! Let’s make a platformer with a lovable quirky twist!” Then David slapped me about a bit.

“You’ve got to blog!” he yelled. “Do it for the children. DO IT SO THEY MAY ONE DAY ENJOY TECHNICAL EXCELLENCE. ”

And so, one day late, we shall blog about technology – because I still believe in a world of Technical Excellence.

machines of Clockwork Empires

Try not to touch the technical excellence, it may explode if touched incorrectly.

The CE engine has a few basic mechanisms for creating content – game objects (.go files, not to be confused with Google Go), jobs, FSMs for jobs, and now events. Jobs, you may recall, operate using XML:

  <job name="Homicidal Rampage (melee weaponry)" 
     display_name="Going on a Rampage" mandatory_eval="1">
    <require_character_personal_stat_geq name="madness" amount="100"/>
    <require_wield_tool tag="melee_improvised_weapon" />
    <require_gameobject input="enemy" tag="human" range="20" must_lock="0"/>
      <base_job_utility weight="1000"/>
      <character_personal_stat name="madness" weight="1"/>
      <distance_from input="enemy" weight="-1" require_eval="1"/>
      <attack_melee input="enemy"/>
    <history importance="100" />

They take a collection of inputs that satisfy some requirements (an improvised weapon and a human target), and pass it to a sequence of FSMs to execute the job. Events operate in much the same format:

  <event name="Fishman Attack!">
    <require_timer name="Fishman Attack Timer" value="48000"/>
    <script name="fishman_attack"/>    

Here, however, we have a sequence of requirements (which can include any of the requirements from the jobs system that make sense – they use the same code). Requirements generate inputs, which are passed to the event script which has a number of stages – like an FSM – and can move from one stage to the other. End result: when the timer goes off in 48,000 game ticks (8 minutes), fishmen arrive and everybody dies. This is, of course, not a real event but simply one created for testing purposes and there are no such thing as fishmen.

When filling requirements, we look for tags on objects. This is just a list of strings on an object that they have, which indicate if they can be used for some sort of a purpose. Dwarf Fortress, I believe, does something similar. For instance, an axe has the following:

Entity {
    name = "Axe",
    type = "tool",    
    ground_model = "models\\props\\axeG.upm",
    hand_model = "models\\props\\axeH.upm",
    use_animation = "chop",
    tags = {"axe", "tool", "melee_improvised_weapon"}
The Axe: your domestic friend or revolutionist plot?

The Axe: your domestic friend or revolutionist plot?

As a result, the engine knows that an axe is a tool (used for various picking-up-and-putting-down behaviours), an axe (used for the actual behaviour of axes), and a melee improvised weapon (useable for self-defense or homicidal rampages) Tags are also mutable – when a monster dies, for instance, it loses the “combat target” and “horror” tags (meaning that it can no longer satisfy those requirements, used for military targeting and fleeing from things) and gains the “corpse” tag (meaning it can be used for THOSE things.)

When a workshop or building module is built, we look for building materials with a tag that corresponds to the material type (“logs”, “bricks”, “flesh”) Similarly, a workshop job (making a bed, for instance) simply looks for something with the right tag as an input (“planks”):

  <job name="Make Bed" display_name="Make Bed" mandatory_eval="0">
    <require_empty_hands />
    <require_gameobject input="bed_in_progress" range="500" tag="plank" />
    <require_building_module input="saw" name="Workshop Power Saw" />
    <require_item_drop_location input="drop_location" />
      <base_job_utility weight="1000"/>
      <distance_from input="bed_in_progress" weight="-1" />
      <distance_from input="saw" weight="-1" />
      <distance_from_owner input="drop_location" weight="-1" />
      <walk_to_adjacent_position input="bed_in_progress"/>
      <pickup_item input="bed_in_progress"/>
      <walk_to_module input="saw"/>
      <building_transform_item input="workshop"/>
      <complete_workshop_order input="workshop"/>
      <walk_to_adjacent_position input="drop_location" />
      <drop_item input="drop_location" />
    <history importance="10" />

Note that we key some things by name, such as the Workshop Power Saw module. Note, also, that the entire game has a concept of a “Name” and a “Display Name”, which should make life easier for people wanting to do translations of CE in the future.

Commodities, therefore, are simply collections of things that you own (meaning you created them, touched them, or otherwise claimed them – we’re a bit fuzzy on this still, especially when it involves multiplayer); your “logs” commodity is all the things with the “logs” tag. David sent me a lovely “commodities” UI mockup which I need to convert into something that is code:


Needs more scrawling.

and a selection of tiny filler icons:


So filling!

and, well, I’ll hook that up later this week I guess.

In conclusion: please, always remember, when the world is a blasted hellscape of games running on Unity and the Unreal Engine, that once upon a time we had Technical Excellence. And think fondly of this blog post.

Posted in Clockwork Empires | Tagged , , , , , , , , , ,

14 Responses to “Tags and Events”

  1. icepick37 says:

    “You bastards! You blew it up! You crazy bastards!!”
    RIP Technical Excellence. :`(

    Love the the example of homicidal rampage, haha.

    { reply }
  2. FaxCelestis says:

    I, for one, am impressed at how lovingly Nicholas has been recreated in the game’s engine.

    There’s some real care taken there.

    { reply }
  3. rydash says:

    If this whole Technicall Excellent Game Creation and Distribution endeavor doesn’t work out, I’d be interested in a wireframing program infused with David’s artistic style.

    because i think it looks fancy and pretty and subjectivity is a great way to decide new software engineering

    (Next up: Me, one day changing all the “animation” tags to whatever one makes heads fall off.)

    { reply }
  4. Chainlinc3 says:

    Somewhat curious about how things are getting classified… The way things are set up, it sounds like people might drop an actual weapon to acquire an improvised one. Which would be kind of awkward if, for example, your militia commander decided he wanted to go on a rampage.

    { reply }
    • mailersmate says:

      Presumably actaul weapons also have the improvised weapon tag, as grammatically incorrect as that is.

      { reply }
    • We’re thinking about implementing a system where tags can actually cause something to inherit other tags (such as wood inheriting flammable). In this case, all weapons would inherit “improvised_weapon” and all hand tools would inherit “melee_improvised_weapon”, et cetera.

      The trick is making sure that we can still keep track of all of the tags that an object gets if these are nested, because the behavior will start to get quite complex.

      { reply }
      • mailersmate says:

        Looking at how browsers handle css might help you, css is all about elements inheriting behaviour from multiple tags. Css3 features animation, which I’d think is fairly close to your needs at least in terms of implementation complexity.

        { reply }
  5. Robert Tseng says:

    this post is, technically, excellent. 😉


    { reply }
  6. Krentz says:

    The post is an elaborate attempt to assuage fears pertaining to the existence of fishmen. Do not be misled! The fishmen are real!

    { reply }
  7. AMJH says:

    I wonder if it would be possible to have part of the scripts somehow encrypted or otherwise scrambled and then deciphered at run time in a system like that? That way, part of the scripts could be exposed for modders while others could be kept a secret.

    { reply }
  8. Zero says:

    Are those last tags from the Many in System Shock 2? If so… awesome.
    Game looks great so far.

    { reply }
  9. No more technical excellence makes for sad programmers. 🙁

    { reply }

Leave a Reply

Your email address will not be published. Required fields are marked *