Mystery Conquest Project (PART 1)

Follow me on the twatters.
Subscribe on youtube for vidya.

Hello! It’s time for miscellaneous Wednesday. I recently started the development of a new project that I think is pretty interesting. I can’t think of any roguelikes (or modern games in general) that go for this kind of thing anymore. I’m going to start documenting its progress before I get too far ahead. What is it, though? It’s a horrifying combination of my favorite elements from a million different games all shoved into one.

The core of the game is largely based on two games. I’ll focus on those. There’s galactic conquest mode from the Star Wars Battlefront line of games and Warfare mode from Arma 2. There’s a bunch of other Arma modes (and mods) that provide additional inspiration but talking about them is beyond the introductory scope of this post.

So, let’s start with galactic conquest. The name is pretty self explanatory!

Your goal is to conquer all the planets. To do this you move your fleet to worlds you don’t own yet. You can have more than one fleet but you can only move one of them per turn.

The neutral worlds are instantly claimed when your fleet arrives while enemy worlds require a fight. This is where the fun begins! Each planet can be thought of as a collection of maps.

To capture the planet you have to take control of all the maps by defeating the enemy on every single one of them. Each planet is a tug of war battle for total control.

Here is my attempt to peel back the layers a little bit more to help further explain things. This diagram was made in a free program called Dia. The red and blue planets represent the two different factions while the black one is neutral. The orange planet is contested which means they’re fighting over it. The rectangles connected to the contested planet are its maps. You can see how some of the maps belong to different factions. The orange one is where the current fight on the planet is located. If all those maps are captured by one of the factions then they capture the whole planet!

The maps are your standard control point based affair. If you’ve played any multiplayer FPS game before then you know what I mean. Even if you haven’t then you probably still know what I mean since it’s such a common mechanic. There’s also a ticket system. Tickets are basically respawn points. Every time a team member respawns one of those tickets gets taken away. This means that there are two ways to win. Either capture all the control points or kill so many of your enemies that they run out of tickets.

This is where my project begins to take on a form of its own. First, I plan to make planets and the maps on said planets more important. They’re going to be a source of bonuses instead of just territory. This will add a little more strategy to what you decide to attack and defend. Battlefront has bonuses but you just buy them with the credits you earn from fighting. It’s a pretty underdeveloped system that I forget to use most of the time. It’s unbalanced, too, since some bonuses are overwhelmingly better than others! I’ll always choose increased weapon damage over that stupid control point defense turret, for example. This is what a galaxy map in my game might instead look like.

I left faction ownership out of this example to avoid over-complicating things. You can see that planets and their maps now have bonuses tied to them. If you control a map then your faction gets the related bonus. If you control all the maps on a planet then you also get the planetary bonus. The bonuses hint at some of the fun stuff I plan to add later. I’m not going to talk about those yet, though!

I’m getting antsy with excitement and want to start working on the project so its time to move on! I’m going to start by making a map with control points. There’s also going to be two factions on the map that will be fighting over said control points. I’m not going to do any planet or galaxy stuff yet. There’s no point without the maps working.

To help keep things balanced for more sustainable testing purposes I’m also going to give each faction a headquarters. That’s a special type of control point that can’t be captured. This way, if one faction captures all the control points then the other faction will still have a place to spawn. This is an idea I got from Battlefield 2142. I forget what they’re called but that game has a few maps with the same mechanic.

The green base with the red crossed out circle cannot be captured. I don’t remember what the in game term is for these places but I’m going to continue calling them headquarters. Enough talk, though. Let’s go! I’m going to use the paint image to game map conversion method I’ve previously talked about in my super project series.

There’s not much to look at since everything is so simple right now. The red and green dots are each factions respective headquarters while the grey dots are neutral control points. The AI are finite state machines with two interests: capture control points and attack any enemies they come across. That’s it! I’m going to have each faction spawn an agent per turn at their HQ until a maximum of 100. Let’s see what happens.

Ah, yes. Truly flawless programming. There’s a ton of things going wrong! The agents aren’t attacking one another which probably means field of vision calculations are broken. They’re spawning near the top left corner instead of at their headquarters and for some inexplicable they’re pathfinding to their own headquarters? Mysteries abound.

Okay, I did some fixing! They’re now spawning at the proper location and targeting control points. The targeting system is still broken though so they’re not shooting each other yet. I’ve also now given them the code necessary to capture multiple control points whereas previously they would stop after getting the first one.

It looks weird. They move like flocks of birds. The agents tend to get all stacked up since they’re allowed to occupy the same tile. I need to get combat working.

I ripped my poor targeting code out since its not working and replaced it with a scummy brute force method. It’s slow but it works! Unfortunately, a problem I predicted might happen is actually happening. The pathfinder, due to being so efficient, is causing agents to move around the map in massive streams. This is due to the whole straight line between two points being the shortest path principle. I don’t like this because it means the player would be up against a never-ending line of enemies. The player needs to be capable of capturing points on their own and otherwise standing a chance in combat. That’s not going to be possible with how things currently are!

I need to spread the AI out a little bit more to reduce this wall of death phenomenon. First, I’ve randomized each agents sight radius. This helped a little bit when it comes to agents clumping up during combat since they detect each other at different ranges. The next thing I did was slow down the agent spawn rate. There’s now a spawn delay of 10.

It helped a little bit but also introduced a new problem: unbalance. If I let the simulation run for long enough then one of the factions always becomes the dominant force. This is because the units have a tendency to slowly form into groups and as a result they steamroll anyone they come across. This causes a scenario where the other faction cant replace their losses fast enough. It’s a death blow that can’t be recovered from. I guess that’s technically fine, though? If this was a full game rather than a prototype for testing then the faction being dominated would eventually run out of tickets and lose.

Let’s get back onto the pathfinding topic. I booted up Battlefront 2 classic and entered a random skirmish with the AI. The goal here was to just watch how things played out. Even though I can’t see the actual code I can sort of figure out what’s going on behind the scenes just by watching how things play out. I don’t know if this is a unique ability of mine or all developers in general but here’s a clip of what I was watching.

If you can set aside the obvious graphical differences between this game and mine then they look very similar! In regards to agent behavior, at-least. The agents go from control point to control point and attack any enemies they come across. I noticed a few major behavior differences in agents between my game and Battlefront while watching.

First, the agents seem a little more efficient when it comes to control point selection. In my game, the agents choose one at random whereas in Battlefront the agents seem to individually pick the one nearest to them. I’m going to go ahead and give my agents a targeting upgrade by implementing this feature in my game. This is what it looks like.

I think its better as a result. It’s kind of weird how similar my agents are to the Battlefront agents now. I turned my map into a crude representation of the Endor map so the similarities are a little more obvious. The majority of combat is focused on the center of the map while the occasional guy slips through and captures a rear point. Unfortunately, I didn’t capture a good video on this update and I’m too far ahead to make a better one.

The other thing I noticed is that Battlefronts agents, while going from control point to control point, aren’t doing so in perfectly straight lines. I’m not sure why but they seem to spread out a little bit more. I originally thought its because they were getting thrown off course due to combat but then I saw some AI spawn and take an inefficient path to a nearby control-point without them getting involved in combat.

I think instead of pathing directly to a control point they’re pathing to a random coord near said control point. This makes sense on further examination. The control points in Battlefront don’t work like mine do. To capture them you just need to be near them instead of directly on them. I’m going to make that change in my game. The control points will now have a radius and agents will path to a random coordinate within said radius instead of directly to the point itself.

It looks more like Battlefront but it didn’t do much to solve the snowball affect. In fact, the red faction really spirals out of control near the end. I’ll have to find a better fix.

I’ve now made some major performance improvements behind the scenes. The game now rarely goes below 50fps whereas previously it was struggling to stay above 20. I’ve increased the maximum amount of agents per faction to 200 to take advantage of the improved performance. I’m not sure why but 200 seems to be the sweet spot balance wise. The ball of death phenomenon seldom seems to happen at that specific number. I also turned off the respawn delay to more quickly test mass agent behavior. I’m pretty happy with the results now. The blob, while not properly fixed, now only shows up on occasion. I’m going to move onto other things until it becomes an issue again.

The next difference I noticed is how spawning works. In my game agents spawn one at a time. In Battlefront, though, multiple agents seem able to respawn simultaneously. That makes sense since its a multiplayer game. It would suck if players had to wait in a long que to respawn! I think theres a separate respawn counter for each agent rather than a single shared one. I’m going to implement that next!

I’m pretty happy with the result. It actually increased the pace of things since multiple agents can now respawn simultaneously and get right back into the action. I didn’t see anything even close to a wall of death form, either! What else can I do? I think the next thing I should add is the ability for agents to spawn at owned control points.

Looking good. I think I’ve reached the limit of what I can accomplish on this map, though. It’s so small that more advanced testing is out of the question. The agents are constantly in such close proximity that its hard to see any real patterns anymore.

Unfortunately, the game is already at the limit of what my 1920×1080 monitor can handle. I could increase the map size but then portions of it would be off screen. The game is setup for map scrolling but in order to properly test things I need to be able to see it all at once. It’s time to switch over to pixel scale rather than ascii representation.

This is the new map. The previous one was 101×101 or 10201 tiles and was being drawn with 8×8 ascii. This one is 301×301 which is 90601 tiles. I’m now drawing things at a 4×4 scale using boxes. I still have a good amount of wiggle room if I need to reduce the size further! I’ve come to realize, though, that enormous maps like this probably wont be very fun to play on due to all the traveling involved. I could add automated pathfinding for the player or transport options such as vehicles and teleporters but it would nevertheless be best to keep things small. For testing, though, this is just fine!

I’m going to go ahead and give the agents a new routine now. It’s a short range patrol that causes agents to occasionally path to a random nearby location. I’m doing this to help further spread agents out for the same reason I’ve done it previously.

I’m pretty happy with the result! Each agent has a patrol counter and once it hits a certain threshold they patrol to a random nearby location. They still prioritize combat above patrolling but patrolling comes before capturing control points. This should make combat a less frustrating scenario once the player finally gets involved. I didn’t record a video for it, unfortunately. I was on a programming binge and forgot. You can see it in the following videos, though!

What’s next? I’m going to make the map a little more interesting by adding obstacles. Then I’m going to finally add the player! Creating obstacles will make the map actually look like a map finally. There’s going to be corridors to navigate and all sorts of stuff.

Okay, I’ve added buildings. I was originally going to make it symmetrical but decided not to. In fact, I went haywire doing the exact opposite! I removed the corner control points and instead added a new ones near the top and middle bottom. The design is inspired by planetside 1 and 2 with all its interesting building layouts.

I think that’s enough for today, though. Come back next time for player gameplay!