Thursday, March 25, 2021

Project Breach #3 - "Audio, Walls, and Doors"

 Project Breach #3
"Audio, Walls, and Doors"

Welcome to the third update for Project Breach! I'm very glad to be making these, one of the more enjoyable parts of game development for me has been writing blog posts for years, so the fact that I can do it again after a year of not & make videos alongside them is awesome.


Audio
Starting on the games audio was something I had actually intended to be in the last update but I didn't have time to get to. I even created a joke video to spoil that it would be in this update but I forgot to post it lol:




But audio is now in the game for real! The first thing I did was add audio to weapons and not only that but ensure that each gun uses completely unique sounds so that they might be identified by sound alone. This includes both a sound for when the weapon is firing but also one for when it's reloading.

Next, I added sound to pawns which would be a sound for when they're idle, a sound for when they're idle & damaged, and a sound for when they take damage.

And finally, I added sound to UI buttons across the project.

After taking several insults from friends regarding the sounds in their early stages, I slowly got them better & better until where they are now.


Walls:
The first and biggest thing I wanted to do this update was change how walls behaved visually in their entirety.

Taking inspiration from RimWorld & Prison Architect the walls adjust based off of the walls around them:

(Old)


(New)


As you can see, a massive visual improvement that makes walls feel like they have depth.

Because the games visual style was entirely inspired by RimWorld, my first thought was to see if there was any public information on how RimWorld achieved their style. As luck would have it only about 15 minutes into looking I stumbled on a forum post from 2018 with no comments. All it had was a picture of a texture atlas from RimWorld but it was exactly the image I needed to see in order to give me an idea.


https://ludeon.com/forums/index.php?topic=47328.0


For those who don't know, a texture atlas is a method where you store multiple textures on a single image. This is done in games like MineCraft to improve performance.


https://www.reddit.com/r/Minecraft/comments/aa29tm/throw_back_from_2011_for_you_all/


It perfectly displayed the 16 different configurations a wall could have based off of what was around them. So I wrote a system which would split the atlas into individual textures. Once I had done that, I created my own atlas and made each texture have a number representing its position in the atlas (Starting at 0):




Now I just needed to figure out how to write code that would know which of these textures in the atlas a wall should use based off of its surroundings.

And that's when it hit me - I could represent it with 4 digit binary. In the 4 directions around the wall, I could represent each direction as a 1 or 0. 1 if there is a wall there, and 0 if there isn't. Here's an example:



If we look back to the atlas, you can see that a wall like this should be represented by texture position 11. So how do we get this code to equal 11?

Well it's all about ordering.

If we make the top neighbor be the first digit, and go clockwise, that example would give us the binary 1 1 0 1.



So to make it short, the first number represents if there's a wall above us, the second number if there's a wall to the right of us, the third number if there's a wall below us, and the fourth number if there's a wall to the left of us.

So using that system if we read it left-to-right then 1101 becomes 11. And just like that, the game can almost immediately determine which of the wall configurations it should use based off of the walls around it.



Visuals
With this new wall system the first new visuals I worked on were for the concrete wall & wood wall:


I also worked on block textures, such as the grass, sand, dirt, stone, and redid the wood texture to be thicker:


And, I also created a texture atlas for pawns so that I could make so they change which way they're facing based off of the direction they're moving (which they now do):




Gameplay
Walls (and all mod objects for that matter) can now be damaged by setting "HasHealth" to true in the mod file. I've also made so penetrable surfaces (ones which bullets pass through) you can also allow to be damaged by those bullets, even though they're passing through.

With that in place, glass walls are now able to shatter/destroy when shot through:


The shatter effect they create is actually another mod object, a prop called "Glass Shatter". This is because in a mod object you can now add the property "OnDestroy_SpawnModObject" which allows you to configure the object to spawn another one when it's destroyed.

Pawns now also have a very small delay between when they acquire a new target and when they'll start firing. This helped me to accomplish two things:
1) Frame-perfect firing no longer occurs (When they fire the same frame they see an enemy) which makes the pawns feel a little more organic.
2) Helps to avoid stalemates. The delay has a small bit of randomness to it. This is because originally if two enemies at an equal distance with equal equipment started firing on each other, they'd both die simultaneously which felt jarring and resulted in many fights where both combatants were dead and felt like no progression had occurred. This still happens sometimes but more frequently one of the combatants will have a slight edge (by around 0.1 seconds depending) and that's enough to make sure one usually survives.

Although, they still can just end up killing each other, because that's a realistic possibility too:


And finally for gameplay, if a pawn is told to move somewhere and there's a closed door blocking them, instead of having to order the pawn to open it first, they will now automatically path to it & open it themselves:


UI & map editor:
You may have noticed in the combat GIF's that pawns are sporting some new bars. There's now a blue bar which represents the weapons cooldown, a purple bar which represents time left reloading, and a yellow bar which represents how much ammo the pawn has left.

I've also changed in the map editor "World Lighting" to "Environment". Because something I didn't have time to get to this update, but which will likely be in the next, are map effects such as fog, clouds, rain, etc.

You can now also adjust the max players that can play on your map as well as what team each slot gets assigned to. Potentially in the future, I'll make a checkbox that just says "Players can pick their own team" so that maps can be designed that don't force teams. We'll see.

Noteworthy extras:
  • I made so pawns won't try to attack something if it's outside of their weapons range. Before, they would try to attack anything within view.
  • Made so pawns get an exclamation mark above their head when they've acquired a new target
  • Made projectile penetration damage penalty to damage multiplier. Now penetrating a surface could result in *more* damage if you chose to do so. I don't know why you would, maybe some sort of sci-fi game where walls boost the damage to your gun. But it's there now.
  • Modified the voxel engine so that the first redraw of a chunk is done using the fastest algorithm. This makes so chunks can quickly be modified, and then an optimization system can later go to chunks that haven't been changed in a little bit and re-render them using a less GPU intensive but slower algorithm.
Summary
I loved doing the livestream on YouTube Monday, it was some of the most fan interaction I've had which was really great. I hope to do more in the future! Thanks for reading, feel free to leave a comment or some feedback, and I'll see you in the next one!

-Blake Gillman

Friday, March 19, 2021

Project Breach #2 - "Combat, New visuals & Pawn UI"

 Project Breach #2
"Combat, New visuals, Pawn UI"


Combat
The new combat system has been one of the more detailed & complex of any I've written before, and it's all fully adjustable by mods.

Combat/Ranged
I added ranged combat which includes anything that uses projectiles. This is guns sure but also with mods you could make it anything. Crossbow, Taser, Magic staff, anything that uses a projectile.

To make sure the combat was all working correctly, I made multiple gun types.
(GIF playback is slightly slow so actual gameplay is approximately 10~20% faster)

AK47 (Assault Rifle)


FN Minimi (LMG)


M4A1 (Assault Rifle)


M1911 (Pistol)


MAC-11 (SMG)


Mossberg 590 (Shotgun)


For fully automatic weapons I found that burst fire (Where the pawn shoots X times, waits, then does it again) has been the best for balancing. For example, with an AK47 pawns will shoot 3 times, wait, then do it again. Along with this system is a "Continued shots" accuracy variable, which lets me make so the first shot of a burst is more accurate than all the shots afterward. I think this is more realistic and simulates how one might react with a continuously fired weapon.

Along with this, pawns have ammo and they can run out. In the mod file it is adjustable if the weapon uses ammo whatsoever. How much a pawn can hold of each ammo type is adjustable in the ammo file. How much a weapon can hold per mag is adjustable in the weapon file.

Here's what a weapon file looks like:




Here's what an ammo file looks like:




As a side note, pawns also receive an accuracy penalty for moving & for running (although you can't order pawns to run just yet). Here's what a pawn file looks like:




Combat/Surfaces
Game surfaces can now be defined (things like if a wall is wood, metal, etc.). In the future this will great for things like special impact & sound effects when a surface is hit by a projectile. But right now it's helpful because on projectile file you can define surface penetration. This means you can say that certain projectiles go through certain surfaces. You can even define the chance of the projectile going through, as well as if the projectile should get a damage penalty for doing so.

Here's what it looks like when I place a pawn in front of a wood wall, watch how all their bullets pass through it:


Now here's what it looks like to have a pawn behind that wood wall, watch how he takes less damage from the shots because they've passed through the wall:


Certain surfaces can also define if pawns can see through them or not. So for example this window is a wall with a surface type of 'glass'. Watch how when I order a pawn to walk past it, the two pawns see each other and begin to fire:


(Note that in the future, glass will shatter lol)

Here's what a game surface file looks like:




And here's how easy it is to change what surface type a wall is:




So with all of these systems in place, you can see combat can be pretty interesting!

New Visuals
You probably already noticed that this is a new map layout and that the map looks much nicer.




This is because I'd hired an artist to help create a few textures for me as a good starting place. I likely won't be able to afford to have an artist do most of the art in the project, so having a good place for me to start to do it myself is nice. The grass is just a placeholder.

You've also already seen in multiple screenshots that there's new pawn textures. A terrorist texture & a SWAT texture. These also aren't final, just something I made real fast for testing, but a good starting place.




The game is also now using some basic post processing which does nice things like slightly increase contrast & saturation as well as add bloom. It's not meant to completely change how things work, just add a nice layer of polish on top.

There's also a slight 'glow' to projectiles. This can be turned on & off in the projectile file with a variable called "Use Tracer Lighting". Here's what a projectile file looks like:




And finally, I've added blood to pawns. This system is meant to serve more of a gameplay purpose than a visual one. For the first 15 seconds that a pawn has taken damage they will leave blood whenever they move. This means that if you run away from a fight, you have to keep in mind that you'll leave a blood trail for the first 15 seconds. I can't wait to see what strategies develop as a result of this mechanic!


Pawn UI
Friendly pawns (Those you own & those on your team) now display how much health they have below them. This on its own is a nice touch but the system I'm more excited for is pawn dialogue.

Pawn dialogue is one of those ideas I just had randomly and was immediately excited to implement. It's text above the pawns head but I think it adds to the game overall. What I like about it is that it changes depending on the pawns circumstances.

So, if your pawn has been sitting around for awhile doing nothing he might give off a random bit of dialogue:




But if he's been injured, that dialogue might not be so friendly:




He'll also let you know that he's taken hits:




And when he's doing important actions:




(If you're wondering why you didn't see this in any of the previous GIFs/Screenshots, it's because I had it disabled for all of those so that you would see it here)

It's one of those mechanics you don't even think about when playing a game, but that can be great to communicate things to the player. I enjoyed working on it & coming up with things for the pawn to say. These dialogues only show for friendly pawns so that enemy pawns don't give away their position.

Other noteworthy changes
-Fixed bug where you could see an enemy pawn's orders if you have them selected
-Made so the interact menu shows the display name of whatever it is you're interacting with
-Converted entire project to use new ID system (unsigned integers instead of strings)
-Made new map because the new ID system broke old saves

Summary
Wow, this was a lot to cover! 22 images/gifs in total. But when you're adding such major systems like combat for the first time, it's to be expected. With combat now in place and especially with these new textures, the game is feeling a lot better than it did last week.

Right from the beginning of the project I've been working toward a list I call "Demo Essentials" which are the minimum number of things I want in the game in order to have a proper demo / beta test. From now on every update will include this list and how far I am into it.

And also for fun, I'm going to have a "Lines of code written" counter in every update so you can track how much programming has been done as the game goes on.

 Thanks for reading, feel free to leave a comment or some feedback, and I'll see you in the next one!

-Blake Gillman

(Join the Discord: https://discord.gg/ArEbAut)

Thursday, March 11, 2021

Project Breach #1 - "Multiplayer, Pawn Interactions & Anti-Cheat"

Project Breach #1
"Multiplayer, Pawn Interactions & Anti-Cheat"


Multiplayer

I present to you, a pawn which you can order to move & which syncs over the network!


Before I knew I was making Project Breach, I started on my latest voxel engine. This is because I love making voxel engines and I knew I'd want to do something with it. This meant that when I decided the game would be Project Breach I began programming the game with multiplayer in mind, but I had to later go back and redo some of the engine to support multiplayer. It went a lot smoother than expected and this week I did the first real test and all the bugs related were able to be fixed in less than a day.

Interaction menu
You can now right click on interactable objects to get a list of any interactions that can be done. And in order to test this system, I made so pawns can be ordered to open & close doors:


Pawn spawners
The map editor now supports creating pawn spawners which allow you to place down spawn points for both friendly & enemy pawns:


Anti-cheat
They Can't Stop All Of Us, and all my previous multiplayer games have been very easy to cheat at since they've been client-side. But because I want to be able to use the Project Breach engine (called Perlinia 3) for other games, I wanted to do things proper this time. So the entire game has been programmed to be server-side authoritative. But this week specifically I also added another security measure to prevent cheating by modifying mod files. This system is called a checksum (excellent video on the topic). The short version is that if you do so much as change a pixel on a single texture, the game will know that you've modified the mod files and that yours are different from other players. So, this game is starting off with excellent security right out of the gate!

Test menu
Every time I wanted to use the map editor, or test the actual game, I had to change 4 lines of code in the game manager which became quite annoying when constantly switching between the two. So for my own sanity, I finally got around to adding a test menu to make things easier:


Texture support for pawns & doors
The entire game is meant to be made for mod support. Most custom objects so far (Walls, Props, Vegetation, and Blocks) had texture support but I've gotten around to adding it to both pawns and doors. The cool thing about doors is I made so the left door, right door, and frame are all separate textures so you're free to really customize them! I also included a screenshot of what a pawn file looks like so you can see how easy the game is to mod:




(And if you're wondering, yes an "Error" texture is currently required in every textures folder)

Summary
I would like to note that all of the games graphics right now are placeholders that I quickly made for testing. I'm not completely sure what the games final art style will look like, but the choice is between Rimworld-style and pixel and I'm leaning toward pixel. There are of course, many other smaller changes but those are the major for this week! Thanks for reading, feel free to leave a comment or some feedback, and I'll see you in the next one!

-Blake Gillman

(Join the Discord: https://discord.gg/ArEbAut)

Tuesday, March 9, 2021

Project Breach

(Copied from a Discord announcement on March 7th, 2021, put here for archival purposes)

What is Project Breach?
Project Breach is a 2D top-down tactical game where you control a squad in a destructible environment.

How far are you?
The game is already over 13,000 lines of code. For reference, They Can't Stop All Of Us when last I worked on it had ~14,000 lines. That doesn't mean I'm almost done, far from it, it just shows you how much work has already been put into it.

How are things visually?
Visually the game is intended to look similar to Rimworld & Prison Architect. Right now the game is just using test textures I made, so nothing fancy.

Any cool features so far?
The first 11,000 lines of code written weren't even for gameplay yet. It was all the backbone required to start on that:
1) Epic Map Editor
2) 100% mod support. The game's default content like maps, enemies, etc. are all written as a mod called "Default". That means you can not only see how the game was made, but every tool I have access to, you do as well!
3) Biome Editor (Design biomes so when you start a new map, you have things already in the map to start with).
4) The most powerful voxel engine I've written to date. Chunks can be quickly rendered & modified.

Unlike King & Country, these aren't "Future features", these are here now!

Is it multiplayer?
Yes! The game's main focus is PvE & the campaign. But there'll also be a PvP mode.

Post-release content?
I don't like making any promises but I would like to fit in a co-op campaign. I don't think I'll have time/resources to do it for the initial release so that's something I could see adding after the game releases.

Will it cost money?
Yes. I'm not sure how much but I'm planning on it being inexpensive.

Can I pre-order?
No. I've never been comfortable with pre-ordering since I sometimes switch projects. So maybe once the game is actually done & like a month from release, then I'll consider it.

When can I expect updates?
I plan on posting to my blog again, not only to keep you guys updated but so that I can have an archive of progress as I move along.

How far is the gameplay?
Most of the work so far has been on the map editor, voxel engine, etc. Gameplay right now is that you can connect to a server, spawn units, and order them to move around as well as queue orders. So when I start giving out updates, you'll be able to see gameplay being developed since I've already done all the boring back-end work like mod support, map editor, and the voxel engine!

Copy of Discord announcement

(Copied from a Discord announcement on March 1st, 2021, put here for archival purposes)

I'd like to do an important announcement. I know you guys haven't heard from me regarding the game I'm working on in awhile, and that's somewhat been intentional. If you've followed my work for any length of time, you know I end up switching projects a lot before landing on one that I actually end up finishing. So to some of you this may be a shock, but to some of you not: King and Country has been cancelled. I lost my job in October and had to fire the level designer & artist who was helping me with the project. And when I could no longer afford help, the project became too large to do on my own. The project was put on hold then. So why are you just now hearing about it? Because I wanted to have something else in the works before announcing the shutdown. Because when I start taking up new projects, it's possible for me to start & stop a few before I land on a really good one and I didn't want to get a "Hey I cancelled the last, here's the next" announcement every other week because I thought people might leave & think I'd never finish a project, even though starting & stopping until I find a good project is normal behavior for me. So I'm sorry there's been a lack of updates, but I hope you guys can understand my concern & why I wanted to wait to announce it.
3:53 PM
@everyone So now that that's out of the way - I went back to the drawing board and decided I wanted to start on a new project. One that if I were to run out of my money or not be able to get help on, that I could still complete on my own. So I've worked on a few different ideas since then, but I think I've really landed on one that's going to stay - which is why I'm ready to make this announcement. It's called "Project Breach" and it already has many great features. It's 2D, its using a voxel engine I wrote in Unity, it already has a map editor & mod support. I'm really excited about it, and I'll be sharing more later. I know that you guys were really excited about K&C but I'm hoping to make it up to you with this new project. Now that you all know about it, you can expect regular updates & more details very soon! Believe me, no one is more sad for K&C to be over than me. I spent over $6,000 working on it. But I just can't do it on my own, and I can't risk so much of my income on big projects like that anymore. I think this is for the best, and I think this is going to be a great new project moving forward. I also think you guys will be excited once I start sharing all of the details :heart:. Thanks for sticking with me! -Blake