Combat 2: Son of Combat

Last time we wrote about combat, everybody got very excited about entrenching and trenches and gabions and spikes and shooting. Hooray for that. The brief, as I understood it from David “Accurate Simulation of Grain Silo” Baumgart, is the following:


  • Combat should be tactical and positional. Your entrenchments matter, your set up matters, and it is a tactical, positional sort of warfare.
  • Combat should be character-driven. How your soldiers approach a task depends on the relative efficiency of whoever is running the show, and of the soldiers themselves.
  • Combat should be pretty slow, really. Let’s have battles that feel like battles! (Many games have a problem where you send 30 dwarves to attack a Forgotten Beast and it’s all over in a blur of particles or ASCII.) No, let’s give the people what they ask for.
  • Pip pip, what ho, etc.

As the technical director, when some sort of a system comes up, I usually take a first swing at it before it gets passed on to somebody else, or I keep working at it. This sort of tends to be how I contribute to the design – by brute force implementing whatever I think things should be, but knowing that I won’t get any art for it if David doesn’t like it. It is this heady triptych of unresolved creative tension that makes Gaslamp Games into the swirling beehive of … bees… that it is today.

Daniel’s instructions came in the form of three words: “Novyrus. Meat. Turret.” In other words, get a bunch of gabions, fill it with Novyrus’s Weepingest, and get the obstruction and cover stuff working. Also, digging some trenches.

Translating instructions into something that could be considered “code” in a dim light, we are left with the following set of exciting problems:

1. What *is* cover, mathematically speaking, and how is it defined?
2. What happens when I shoot a bullet? (In the current simulation, bullets hit any target automatically.)
3. What do we do about trenches?

After some programming, here are the answers.

1. The notion of cover is that it takes two forms. First, a form you can shoot through, and second, a form that obstructs everything (for instance, being in a building.) If a bullet goes through an obstructed square, that’s it, you’re done. We can optionally (depending on the lunacy of the person slash organism doing the shooting and the size of the bullet slash moon fungus dispenser) choose to shoot the obstruction anyway, in which case it can get a message indicating that “hey, it’s been shot by This Flamethrower Here” and, well, react accordingly by being lit on fire (or not.) Bullets can go through a covered square, with some probability (say, 25% probability assuming that the fishman can actually hold a gun with his grubby little flipper-hands) Otherwise, the bullet goes into the structure and gets the message, “hey, you’ve been shot by This Gun Here.” Note: we record whether or not we passed through a cover point on the way here. This will be explained in part 2.

2. When I shoot a bullet, we do Bresenham’s line algorithm because Tradition.

Since we have to do this over a network, we make sure to use the integerized version of Bresenham because, well, that way we avoid Exciting Floating Point Errors. This is so you can shoot your friends in multiplayer and have the bullet end up in the right place. If the bullet hits an obstruction, we send a message to the obstruction saying “hey, you’re an obstruction, you get the message.” We also have some probability of the bullet going through cover, or not going through cover. Finally, the bullet hits the object. If the object is a soldier, the soldier may be kneeling behind cover, or completely prone. This depends on a number of factors, including the utility of not being shot and the mood of the commander.

I told you before in part 1 that we have to record if a bullet went through cover, and where. If the bullet went through cover, and if I am prone, it had better not hit the soldier at all! In this position the soldier obviously can’t fire, but it might be a good idea to keep your wounds flat on the ground until the barber shows up with the Field Leeches.

Note that this does not apply to certain weapons such as The Eye Laser of Quaggaroth, which has its own rules due to Floating Forty Feet Above The Ground. Melee weaponry also requires that somebody be directly adjacent to it.

Note, also, that cover can be considered a perfectly valid target. It may be more useful, depending on the unblocked targets lying around, to be able to destroy cover than anything else.

3. Trenching is… a bit of a mess. Way back when, Mr. Whitman implemented our terrain engine using marching cubes based on voxels. He was then sealed into a tree by his law professors. The voxels themselves turned out to be a pain, because we were storing a 512x512x64 world or something with a lot of floats, but I converted it to use a sparse voxel representation a few weeks ago and a lot of our memory problems went away. This is Good News for those of you with older computers; we have now gone from 1.6 gigabytes of space in a standard gameplay down to under 700 megabytes, and we have not yet begun to fight.

So, yes. Back to marching cubes. In general, this looks fine – except when you want an exact, sharp hole like a trench. You will notice in our trailer that there are places where this causes Fun (during the Digging of the Idol out of the Ground Scene.) So right now we can make a trench that looks like a trench just fine, but because the Marching Cubes algorithm doesn’t support sharp transitions very well, it has nice soft edges.

Is /your/ trench up to the standards set forth in Lord Boilingham's Illustrated Guidebook Of Infantry Tactics & Vars. Boilings Recipe Collection?

Is your trench up to the standards set forth in Lord Boilingham’s Illustrated Guidebook Of Infantry Tactics & Collection of Various Fine Boiling Recipes, 3rd Edition?

I’m… not sure what to do about this, to be honest. Still thinking this one through. The correct solution is to implement what is called Dual Contouring, but this is a Pain and involves solving some linear equations that I really, really don’t want to have to get solvers for. Plus, there is the ongoing problem of supporting real time updates, and Keeping It All Cached, and all that. So… hmm. Everquest Next does it, though, so it is possible. The other option is to try to detect where the trench is and do either CSG or some kind of hackneyed reprojection step to get perfectly flat edges, or to try one of the other marching-cube-alikes such as, uh, I think it’s called Cubical Marching Squares. Still, for now we will have rounded trenches and we will see if we can survive.

So, yes. Combat! We’re shooting things. For the Empire!

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

17 Responses to “Combat 2: Son of Combat”

  1. Christopher Whitman says:

    Nicholas, you can modify the blur kernel weight (from [0,1]) used when chunks are rebuilt per tile if you need harder edges in some places. There’s probably a number in there that’d work for trenches without changing the skinning algorithm.

    Yours in Quag’garoth,


    P.S. I’m sitting in criminal law right now but I’ll send you a bill afterwards.

    P.P.S. (I won’t really)

    { reply }
    • V says:

      I love how you talk about internal details in the comment thread of a blog post. Can we have more of that?

      P.S.: Yes, that includes more nerd stuff and mathematics. Especially the latter. ♥

      { reply }
    • Selvah says:

      Regina v Secretary of State, Abu Qatada v UK, Entick v Carrington, in Re Pinochet…
      So many cool stuff (ok, that’s UK stuff; but still)
      But hey, what could ever be cooler than “gaussian blur kernet weight” ? Think about that. I don’t want to make you regret your decision. But think about it. There is no Gaussian Blur Kernet Weight in criminal caselaw. There’s only the blur of law reporting, and the weight of gag orders.
      Think about it.

      { reply }
  2. icepick37 says:

    Ah yes. TRADITION. A weighty matter. (if that wasn’t clear from my gratuitous use of the ol caps lock).

    { reply }
  3. Astaldaran says:

    Just a thought, but wouldn’t rounded edges be preferred? In real life trenches don’t end up being perfectly straight (well not normally).

    just google trenches.

    Though I suppose maybe it doesn’t look good in the game, I’d have to see it to know.

    { reply }
  4. Poklamez says:

    “…that makes Gaslamp Games into the swirling beehive of … bees… that it is today.”

    Does that mean that all the communication at Gaslamp is done through dancing? That would actually explain quite a lot.

    { reply }
  5. einacio says:

    well, I for one, think the engulfing forest would be a great and FUN trap

    { reply }
  6. musteline says:

    dont stop making the email come with bugs.
    i love them

    { reply }
  7. Sigma says:

    I have no idea what I just read but it makes me happy.

    { reply }
  8. Edward says:

    You have misspelled the glorious name of Quag’garoth! A terrible death awaits you!
    (Well, I’m guessing a terrible death awaited you anyway, but it’s going to be even more gloriously terrible now!)

    On topic: Every post I read makes me even more hyped of the game than before. So, you’d better release in the really early 2014 for two reasons:
    1) I don’t know if I can stand the wait
    2) If my hype goes much higher, I’m not sure you can meet my expectations for the game.
    Anyways, best of luck in your effort of squaring trenches 🙂

    { reply }
  9. Bropocalypse says:

    Qeynos Mexican Subs and Grill.

    { reply }
  10. petelectro says:

    Speaking purely from a design-standpoint, wouldn’t it make more sense to have slightly sloped / bulky trenches to fit the anatomy of your fellow colonists? Not saying they are sloped and / or bulky on their own, but sharp and straight trenches would look a bit out of place with characters in them, crouching and applying leeches to one another.

    Plus: I think the Digging of the Idol out of the Ground Scene looks kinda neat (the transition is kinda fun though). Anyway, keep up the most entertaining dev blog I’ve ever read.

    { reply }
  11. kikito says:

    I think I would be completely fine with rounded trenches.

    If you really, really want to have sharp borders, can’t you just consider trenches a type of building? One that goes ‘down’ instead of ‘up’. Make the hole of the trench ‘building’ smaller than the curved hole of the ‘terrain’, so that the straight ‘walls’ of the building mask the rounded the terrain slopes. And voila – straight borders in a trench. You might have to require a minimum extension of 2 or 3 tiles. I don’t know if that could be an issue.

    Eagerly awaiting combat 3!

    { reply }
  12. Robert Tseng says:

    question (re: cover): Will enterprising and somewhat less valiant soldiers and/or commanders be able to use more valiant, possibly unaware and/or unwilling soldiers as cover?

    will there be a chance that bullets striking a soldier pass through them as well (particularly if they are not behind cover)?

    Is there a chance of striking through multiple ‘layers’ of cover? E.g.: 2 trees or 3 soldiers or a mushroom a tentacle and a hedgehog walk into a bar, and the bartender gets shot despite being behind the bar and a customer besides.

    { reply }

Leave a Reply

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