itch.io is community of indie game creators and players

Devlogs

Week 3 - Enemies & More Interactions

Grave Mistakes
A browser game made in HTML5

Week 3 - Enemies & More Interactions

Biig week this week. I knew there was going to be a lot to add, but to no-ones surprise, it took more time than I hoped it would. But here we are, at the end of the week, and with lots to show. Unfortunately I had a doctors appointment on Friday, and wasn't able to share my game progress then. I will be posting my game into the game feedback channel on the KIT109 discord soon to hopefully get some feedback on peoples interactions with everything I have added this week. Speaking of which, the things that have been added are: four enemy types, proper shooting with raycasts and object instantiation, damage for both enemies and the player, several rounds of enemy waves, custom wave creation, and weapon upgrades. Lets get into it!

Enemies

So as mentioned before, I added the four (technically five) enemies I had planned for the game. These enemies are:

  • Zombie: The standard enemy type in the game, and the first enemy type I created, which all other enemy types are based off of. It is slower than the player, has an average amount of health, and does a low-medium amount of damage. They are not a big threat alone, but can be dangerous if the pack grows. Zombies will path towards the player's house, unless the encounter the player, where they will then switch aggression to them. Zombies cannot climb or jump, just walk, so the player can use trees to escape them temporarily. If the player makes it far enough away, the zombie will switch it's attention back towards the house. If they do reach the house, they will start attacking it, ignoring the player completely from then on.
  • Zombie Hulk: A stronger and larger variant of the zombie. The second enemy the player faces in the game, and behaves very similarly to the normal zombie. They are are slower than the normal zombie, and rarer. They can do significant damage to the player if they are hit. Aside from this, they behave the same as the normal zombie.
  • Skeleton: A fast but weak enemy, these skeletons will ignore the player entirely in pursuit of the player's house, sprinting past and damaging the player in the process if they are not dealt with. They are weak however, and should be easy enough to kill unless the player is particularly overwhelmed. They do make for an annoying distraction from the main pack though.
  • Vampire Bat: An enemy that has two forms, their initial form as a flying bat, and their fighting form as a humanoid vampire. Vampire Bats will fly towards the player's house at various heights, and upon encountering the player will attempt to fly past them, transform into their humanoid form and ambush them from behind. Vampires are weak in their bat form, so it is important to try and deal with them before they transform.

Hopefully these four enemies will provide some nice variance over the course of the game. All of their stats and behaviour are subject to change upon feedback, and most definitely need balancing on many fronts, like their speed, damage, resource drops, and more. Really, all the numbers currently are just rough estimates for a vague idea of what each enemy should specialise as. This will be a theme throughout pretty much all of this devlog, as balance is really minimal right now on all fronts. Anyway, Moving on, enemy waves!

Waves

The thing that generates all the action, waves of enemies making their way to your house. There was a decent amount of technical work to get this all done, but its mostly boring. The highlights are that each wave is an object, and the main part of each wave object is a list of group objects that it steps through one by one, spawning the listed enemies in each group by their given interval time. A group also has a property that is used once the final enemy in that group is spawned, "endInterval", where a different, often longer, interval can be set for in between groups in a wave. This setup provides a lot of flexibility and specificity in how a wave can generate enemies, the possibilities are pretty much endless. Large waves do get a little clunky, and I might look into a more elegant way of doing that. Oh, I was entering all of this information into those lists in the inspector, and I just kept getting terrified about the thought of all the information I had entered into the inspector getting erased if I changed something in the code too drastically. So I learned about Unity's JSONUtility class, and created a JSON file that holds all of the data for each wave inside it! Neat!

"waves":[
{
    "groups":[
    {
        "enemies":[0,0,0,0,0],
        "interval":1.0,
        "endInterval":10.0
    },
    {
        "enemies":[0,0,0,0,0],
        "interval":0.5,
        "endInterval":10.0
    },
    {
        "enemies":[0,0,0,0,0,0,0,0,0,0],
        "interval":1.0,
        "endInterval":0.0
    }
    ]
},
Riveting display of what the first wave looks like in JSON

And in action this looks like:

All the waves created so far are, again, subject to change. My vague idea is to, within the 20 waves I have set for myself to make, introduce a new enemy every five waves. With four enemies, and the first being introduced as the basic zombie on round one, the final enemy will be introduced around wave 15-16. The waves prior to each introduction of a new enemy should be progressively harder, with a pause in intensity upon introducing a new enemy, before ramping up again. The final wave (wave 20) should also be the most challenging by far, and be a test of stats and skill. Achieving all of this may be difficult as there is an incredible amount of work to go into balancing everything. Moving on...


Damage

I finally implemented damage for the player, and the enemies follow a very similar behaviour. Basically, upon taking damage, the entity is knocked back based on the direction of the incoming attack, and they lose some health. Upon reaching zero health, they die, and either the enemy entity despawns or the game is over. The house also can take damage, but unfortunately doesn't get knocked back. The player deals damage to enemies by shooting, which occurs differently depending on the weapon. For example, the player's shotgun fires multiple "projectiles" (raycasts) in a cone, the rifle fires singular rays in a straight line repeatedly, and the launcher instantiates a physical "rocket" that explodes on impact or after a certain distance.

Weapon Upgrades

Next up on the list of things added is the weapon upgrade system that shows after a wave has been defeated. The player is presented a choice of three upgrades. Each upgrade improves a certain stat on a certain weapon, and costs an amount of scrap. If the player doesn't have enough scrap to afford an upgrade, the upgrade will not be interactable. Similarly, there is a button that allows the player to refresh all of their upgrades for the price of 12 scrap. Multiple upgrades can be purchased at a time, as long as the player has enough scrap. An upgrade will be regenerated upon purchase.

The numbers aren't final, as per usual. 5% is probably too little an increase to stats, and costs need to be adjusted. I also wonder if some upgrades should be rarer than others.

So, as you can see, a lot was added this week, and there is now an actual game to play. It is a very unbalanced game, and there is much to be done in terms of visuals, audio, and game feel (the goals of next weeks work), but the gameplay is essentially all there, and it just needs a lot of polish. I know I went a good bit over the word count for this devlog, but there was just a lot of stuff to cover. Heaps of fun to work on as usual, and the end is in sight! I wonder how much polish I will be able to achieve in these last two weeks.

Files

  • Buildv0.6.zip 7.2 MB
    May 11, 2024
Leave a comment