Patches and the Depth of Cities

This past week I’ve been polishing a new feature for procedural generation, patches.  This allows me to hand-create a collection of assets (both single-tile and multi-tile) that gets placed down in a singular area by the terrain/city generator.  It can be a solid square or only fill some of the squares within.  I can import any patch by dragging in a group of objects from a sample scene.  The tile system already converts the patches into the tileset currently in use by that map, and mixes in variants as they are available to the tileset.

Autofire_Patch_demoThe patch system has a lot of additional features yet to do.  For example, allowing the definition of patches in a nine-slice style where I can scale them to an arbitrary size with consistent edges.  This would allow me to create arbitrary-sized plazas, but more importantly, I can create a road patch that has signs, lights and various elements on it, that scales according to the length (and width if desired) of the road.

I also want to put in randomized prop points:  object stubs that will randomly place a specific prop in that spot, anything from a trashcan to a stain to an ambient effect.  It also allows me to place variants of an existing entity, such as a destroyed version.  This will be important so that my generated city doesn’t look all pristine the way it does above.

AutoFire_EditorsI didn’t expect to get dragged into city decor so early in AutoFire’s development.  It’s certainly a topic of interest to me, but the push in that direction really came from trying to find props for the game.  My 7DRL city was fine, it was basically a dungeon.  A dungeon can be a twisty maze of passages and hallways don’t necessarily need a specific direction of travel defined.  However, it felt like 90% of modern-day props required placement with some thought…  You can’t just sprinkle in mailboxes, street lights and stop signs via Random.Range(0, size)…  There needs to be established clusters and strips of materials.  I can construct hand-built areas anyway, but to extend everything into procedural town I’m pushing the limit of my limited home-grown tools.

Rolling from all this, I’ve also discovered as my game’s scale gets better established that I’m reaching a point where my single-square building assets are looking weirder and weirder…  I want the cars to be big and bold, and characters in the world to be larger than life also, but right now they are about two stories tall.  I was okay with something more abstract and representational when I was in 2D, but working in 3D makes that scale a bit more important.  Aaaaaand the only way to get my building “walls” closer to the “correct” size is to come up with a system for merging building squares into larger structures.  That will take a whole new post-process that…  I’m going to wait on.

DoomCarI’m quite aware that I’m running the risk of entering a bottomless pit of effort…  Making a city look like a city is hard, and many games make that their only thing, whereas I have
so much more to do.  So, I’m going to finish up this patch functionality and pull back to environments that are a bit easier to generate, such as frontiers, shanty towns, junkyards, and so on.  This way I can push back into mission generation and create some assassination missions and encounters.  This will finally lead me back to the promised land:  the refinement of driving mechanics, combat and its associated UI.

Glad all this is so fun. 🙂

Smoother Sailing

Another slow weekend with not a lot to show yet.  I’ve been digging into my simulation model again and working on some of the halting, awkward motion that both my tactical maps and, surprisingly, my overworld maps have had.  I’ve gotten a few complaints about it, and I couldn’t deny that it was really harming the feeling of speed I wanted to maintain.

A couple weeks ago I revised my input system so the player could queue up movements and move many squares quickly.  However, the player was not able to move that smoothly because the system always gave the rest of the world a chance to move before processing the next player action.  However, this happens even if there is nobody to move (such as when the player is going very fast and executes multiple moves per enemy turn), and even if there were no enemies at all (such as in the overworld)!

This was a useful thing to iron out, and I created a system where the game will stretch out executing any turn based on the longest time given it.  This defaults to 0.2, but with this, the player could execute a full, second-long super attack if he wanted.  Also, if no enemies are on screen, their moves are shorted or eliminated if they are far outside of the player’s awareness.  This gives me a lot more flexibility.

I also have turned into a bit of a Unity Asset Store addict.  I found some great music, vehicle models, terrain textures and even some more dang rocks…  it’s rather shocking how hard it is to find rocks that look good and fit with the rest of your stuff.  Looking forward to the next thing on my list, which is to create “templates”, or groups of objects to use in level generation.  Should be fun!

Auto Fire: Skid Marks

After a couple of evenings over the last couple days, I got skid marks working fairly well.  I had considered it a fluff component, but I also knew in my gut that skid marks could fairly easily show the player where a vehicle came from and whether it is under control or not.

Drawing arbitrary skid marks on the fly!

Generating mesh polygons on the fly in Unity was a new experience, but it wasn’t so bad.  The odd thing is that I spent an unnecessary amount of time trolling the docs and forums for info on supporting quads, and whether I’d have to define things in strips and fans and all that.  Instead Unity just asked for every triangle defined individually, and shared edges were not even an option.  I guess it’s been a long time since I had to deal with individual polygons, and the graphics layer has become just that much more sophisticated.  Does that make me a 90’s Voodoo/TNT relic?

Besides, I’m dealing with maybe 50-100 polygons here, so I’m hardly taxing the system…

Auto Fire: Technical Debt

As I am gainfully employed, my time working on AutoFire is mostly relegated to mornings before work plus weekends.  I don’t have any pretty pictures for you from this past week because I’ve been ripping out the guts of the game, getting it into a smoother-running and more manageable shape.

You wouldn't believe the number of pictures with stick figures holding up the word "debt" there are.
The internet contains precisely 51,245,721 stick figures holding up the word “debt”.

In programming there is a phenomenon commonly referred to as “technical debt”.  In short, it means if you take shortcuts  and the “easy way” for quick results, you usually pay the price down the road.  Those temporary fixes and band-aids that you applied in lieu of carefully planning and documenting your work gets built upon again and again…  Eventually that foundation of toothpicks and dried spit can’t bear the weight, and you realize that your work cannot be maintained.  You throw up your hands and say “This has to be completely redone!” This is the day your technical debt comes due.

In game development technical debt is common…  Early in a project you want to prototype all the gameplay quickly to give everyone a sense of how something works.  You try things, you iterate on an idea to make it better, you try to “fail quickly”…  You do all those things that the best game companies hold up as their credo, which means you have to focus on speed and agility.  Try that crazy new control scheme, add a strategy component to your FPS, see what all the goats look like with hats, or whatever the team comes up with.  This behavior does not encourage proper architecture, and often involves what a programmer calls “a hack”.

BUUUUUT game making also is a business, and there is always pressure to move forward because the last problem is in the rear-view mirror…  This comes from folks like producers and publishers, but isn’t just about the folks in ties and suits:  a lot of people on the team can get antsy if they don’t see new things on a weekly basis, because morale is everything in a creative endeavor.  Programmers get tremendous pressure to move on to the next big issue, and frequently they will warn the powers that be of the technical debt that is being accrued.

Of course, when the day comes that the debt must be paid off, it will involve days and days (sometimes weeks!) of time when nothing changes… in fact, the goal of this cleanup is that everything should work identically as when you started.  It’s very hard for an outsider to understand…  One day long ago I witnessed a manager straight-up ask “But can’t you just hack the entire game?”  No… not if you want something that won’t fall apart when thousands of eyeballs and eager mouse clicks are set upon it.

Nonetheless, “hack the entire game” is precisely what the 7DRL is about…  You need results now and you don’t apologize for it later.  You’ve got 168 hours to get to the finish line and you don’t care if you trample over every “Write Smarter Code” author who ever was.  And I certainly did that.

It's finally time to ditch the last of those 2D pixel art sprites...
Now I finally have time to ditch the last of those 2D pixel art sprites!

For AutoFire my control and world update system was my cross to bear…  I piled my inputs and the control of my entities in Unity’s “Update” system, where each object gets called every frame.  I cobbled together some bullshit traffic-cop system to move things in the right order, except Unity plays it pretty fast and loose…  There isn’t really a great way to guarantee that, say, the function that tells a car where to go would run before the function that actually moves it.  Frankly, I started to not fully understand how the damn thing worked at all.

I knew the debt was coming due…  Players didn’t always feel their commands were registered.  10% of the time the smooth movement of an entity would inexplicably twitch.  The enemy vehicles just spontaneously stopped working.  But I knew fixing it would be a slog, which is why I procrastinated by working on some pretty terrain last weekend instead of doing what I should have been doing.

When you have to rewrite someone else’s code, you can get pretty grumpy about that person.  But when you have to rewrite your own code, you decide that months-ago you was either an idiot or a complete dick.  “What was I thinking?” gets uttered out loud several times, as well as “What the crap is this?” and the classic “How the hell did this ever work?!?”

But a week later and all is well.  The code to control everything is about 25% of its original size.  Everything is carefully managed.  Your input is now queued up and doled out to your vehicle on demand.  Now I can get back to the fun part of making things blow up.

Auto Fire: The Great Outdoors

More progress is being made on the terrain front.   Lately I’ve been battling Unity’s terrain and placing detail objects.  Their system wasn’t particularly well-documented but I’m finally wrasslin’ it into shape.

So the tile system that I use for indoors is still under there, influencing the heightmapped terrain…  The tile type defines what terrain layer(s) I use, which then I apply with some smoothing and variation.  The smaller details like grass and little rocks use Unity’s detail system, which is applied with a density indicated by the tile type as well.  Finally, the larger objects like trees and large rocks are actually the tiles I use for cities, but without a floor component.  These I can spawn and despawn as they come into view, as well as modify due to explosions and so on.

autofire_terrain_details.png

autofire_terrain_details_2

Auto Fire: Making It Happen

So I’m committed now…  Auto Fire is a game I plan to go all the way on.  For starters, it’s “Auto Fire”, not Autofire. You can find the home of the full game (as opposed to the 7DRL version) here.

I’ve been getting enthusiastic, putting regular work in Auto Fire on nights and weekends, and missed plum opportunities for blog posts.  So much I could have talked about!

I took some time to convert the entire game to Isometric 3D and putting in entirely new world assets.

I’ve also completed phase 1 of getting in enemy AI cars to battle.

Then, after some urging by my friend Jim (Dungeonmans) Shepard, I cleaned up my code and started to get things rigged up to cross between multiple maps.  Then I put some effort into learning more about Voronoi regions and Perlin noise to generate a basic overmap.  It’s not gorgeous yet but I’m pretty excited about adding some more structure to the experience.

After that, I’m headed back into combat-land and working on both revising the input scheme and improving combat with enemy vehicles.

Stay tuned for more updates and when I might be able to wrangle my next release to you folks!

AutoFire Small Update

I hate that when you fail to move forward a square you ram things and take damage.  So, I improved the vehicle motion when ramming or colliding with a wall.  I also fixed some issues with trying to ram things diagonally…  that was irritating.  Finally you could previously take a lot of damage when ramming something inconsequential, but now you cannot take more damage than it takes to kill the opponent (and in the current configuration you only take half that damage… this will ultimately be adjustable based on your equipment).

As usual, check out the AutoFire page for the update.

AutoFire page
AutoFire page

AutoFire v0.2 Point Release

I had a few core things I wanted to refine and adjust from the original, particularly in the feedback department…  Since the controls for AutoFire are similar yet different from a typical roguelike, creating an experience that is easy for beginners is a continual work in progress.

In terms of driving, I simplified the grip meter to make it easier to do the “drift racing” style actions that people wanted to do, and then added new cues to help people understand their current speed.  For combat, there was a lack of understanding of when damage was being done, so I improved damage and attack feedback as well as gave users more information on the HUD about the weapons they were using.  World generation got a slight improvement, and the difficulty was increased from the admittedly easy 7DRL release as well.

car_player
AutoFire page

Changelist for v0.2:

  • UI: Grip meter no longer has two halves.
  • UI: Highlight weapon that would be fired when targeting enemy
  • UI: Display stats in the target panel of the weapon that would be fired
  • UI: Display ghost cars in quantity matching speed.  3 moves/second shows 3 ghosts.
  • UI: Improved display quality and sorting of damage text.
  • Graphics: Skids now show smoke where the player was.
  • Graphics: Changed world tiles from crates to buildings.
  • Graphics: Projectiles now visibly move from source to target.
  • Graphics: Dropped loot now slides from source to its resting point.
  • Gameplay: Added line of sight checks for player and enemy weapons.
  • Gameplay: Grip no longer goes below zero, and will start to recharge if the player faces in the move direction.
  • Gameplay: Barrels explode and damage/destroy things nearby.
  • Gameplay: Repair values of wrenches and armor patches were halved.

The Power of Game Design