So a huge amount of time has passed since the last update.
The good news is that a ton of stuff has been added to the game, and I’ve been working on it harder than ever…I just haven’t posted any updates because I’ve been focusing on getting a playable version of the game ready for beta testing. I’m also knee deep in reworking the NPC/story AI, and want to hold off on posting any real updates until the NPCs are done….since they’re the biggest hurdle left in the game’s development.
However, here’s some stuff that I’ve done since the last time I posted:
I’ve added a character upgrade that allows you to pick up, carry and throw zombies
there’s a fast-travel subway system you can unlock throughout the world to travel quickly around the map
on-screen indicators alert you to nearby hideouts and landmarks
many buildings now have basements you can explore
there are 4 new hero zombie types, each with special attacks and much higher difficulty
a new achievement system was added with 90+ unlockable achievements
the Zombox world map has been expanded to be nearly twice as big as before, with tons of new areas, islands, etc
crafting system improved: you can build bridges over water, you can build doors into empty doorways, etc
craftable structures must now be constructed from the ground-up, after placing them in the world
the original book-reading system for unlocking new crafts has been improved
structures that require power now indicate visually – through animated electricity textures – whether they are functional
new craftable tesla coil trap zaps nearby enemies with electricity
save data is now much more efficient – save files are 5x smaller than before, on average
items dropped on the ground are now saved to the location they are dropped at, so they won’t disappear when you walk away
bombs/molotovs/etc you throw now have an on-screen indicator showing direction of throw, as well as time until detonation
As you can see, I’ve been busy! Once the NPC/story AI gets closer to completion, I’ll post some images and videos of the things listed above so you can see them all in action.
Some of you might remember the story from a couple of years ago where the creators of Project Zomboid had their laptops stolen, causing a major setback in the game’s development at the time.
Well, yesterday the house I live in was burglarized and (among many other things) 2 of my laptops and my main iOS development testing phone were stolen. I haven’t lost any Zombox code because it’s all backed up off-site…but losing the devices (especially the iPhone 4S) still stings. Had I not been careful to keep the game code backup up elsewhere, the ending to this story might have been much worse.
So this is a reminder to everyone: keep your data backed up off-site!
I hope to have some more substantial Zombox updates to post soon…currently working on fixing some annoying AI bugs that are proving very difficult to solve, so I don’t have much to show for that yet.
So now that the old navgrid pathfinding system has been replaced by the new navmesh system, I’ve gone in and re-written all of the AI code for npcs and zombies.
The old code was messy and relied on too many navgrid functions to simply adapt to the new system, so I started fresh. I’ve now unified all AI-related aspects of the zombies and NPCs (rather than have separate AI code for each), and optimized things like the flocking system and Line-of-Sight checking (using kd-trees and BVH trees, respectively). This allows the game to run faster with more zombies on screen at once.
While the iOS version of the game will typically have around 50 zombies visible at a time max, I benchmarked the new code with 650 zombies at once and it still runs at +30fps. Keep in mind the old code could handle around 200-250 before getting too laggy. So it’s quite an improvement!
Here’s an animated gif showing part of a group of 500 zombies crowing around the player/environment, using the new AI system (keep in mind for illustration purposes, their attacks have been disabled):
So I’ve got all the new zombies integrated into the game now, as well as all of the various different behaviors they can exhibit.
Zombies can now also get their heads crushed and destroyed, their arms ripped off, and their legs removed (forcing them to crawl after you). Depending on the occupation of the zombie, it may also carry a weapon or have extra armor. Zombies that wear helmets have to have their helmet knocked off before they’ll take any bodily damage.
There’s also a new three-tier wellness system I added (which replaces the old hunger system), which keeps track of your hunger, tiredness and blood levels. Beds that are found (or crafted) can now be slept on, and sleeping can also regain some HP depending on how tired you are when you fall asleep. Explosions and zombie attacks can also cause you to bleed out now, and if you do not find medical attention after the bleeding starts you’ll slowly lose HP and eventually die of blood loss.
Other various tweaks to the UI have been made, like popups showing important information and the amount of HP lost/gained after an injury/heal.
I’ve also optimized a lot of the background functions controlling the AI. The A* pathfinding algorithms now use about 40% less memory and are faster as well.
Here’s a youtube video showing most things mentioned above. Only thing to keep in mind is that the zombies in it are just generic neighborhood zombies, so you won’t see any of the ‘special’ ones like animals, clowns, swat members, etc…but don’t worry! They’re still in there!
Posted in AI, Zombox on January 1st, 2012 by Tyson Ibele
So, over the last two weeks I’ve been updating the zombie AI.
The old AI system had many problems, was hard to update, and lacked many important features. So I started from scratch and implemented a behavior hierarchy, similar to the one described in this book.
Here are some key features of the new system:
zombie AI is now sight/sound based. Zombies will tend to wander around aimlessly, until they see/hear something that catches their attention. Things like the sound of the player hitting an object with a blunt weapon, or firing a gun will attract zombies, but they won’t automatically know what caused the sound. This means that zombies can be distracted with sounds while the player heads in the opposite direction. It also means that it’s now possible to sneak up on zombies from behind.
zombies now flock more realistically. No longer will they randomly intersect walls, or the player, or each other. When attacking, they’ll also try to surround their target.
zombies will try to break down the doors of buildings, if they see a human/hear a noise inside.
I’ve also improved several other aspects of gameplay. Items that require ammo now display their ammo counter inside their icon, when assigned to any of the active item slots. Also, zombies and props can no longer be hit through walls or other solid surfaces.
Here are some screens showing the debug info I use to help me visualize the new AI system. White lines show new A* paths that are calculated. Green lines point to the next node on a zombie’s path when the zombies is following a sound. Magenta/Cyan lines point to a zombie’s active target (cyan = close, magenta = far). Red lines show the next node on a zombie’s path when the zombie is chasing a target (although zombies are allowed to veer off their path when the target is directly in range). Yellow lines point to a new sound that a zombie has heard.
This week’s work on Zombox was sporadic and mostly behind-the-scenes.
The biggest changes are the following:
-weapons can now damage the environment. Got a hammer? Smash down a wall. Got an axe? Chop down a street light.
-zombie AI and flocking algorithms have been improved. Zombies no longer intersect one another while crowding around the player
-zombie pathfinding has been improved. The A* algorithm now runs in a co-routine so it can process a path over multiple frames, lessening the load on the CPU and allowing for longer paths to be calculated
-objects and enemies can be pushed in the water now. They’ll splash and drown but so can the player so you shouldn’t go too close to the edge!
This week I had some time to update the weapons and crowd dynamics of Zombox.
There are now different types of zombies…some are smaller/weaker/faster, others are larger/stronger/slower. Some are wearing helmets or protective gear and have more health, others carry simple melee weapons and can deal more damage.
Also, the zombie flocking algorithms have been updated. Zombies now flock around the main player more dynamically, and can be pushed out of the way as you move forward. The zombie physics system has been updated so that certain weapons and attacks can knock zombies back causing them to roll around and knock into nearby scenery.
All weapons have been updated in various ways. Melee weapons will drip drip more blood after hitting a zombie, push the zombies back more and their collision systems are more precise. Firearms do less damage from greater distances, can fling zombies backwards, and sharp projectiles that shoot out of certain firearms (like crossbows and nailguns) will stick into zombies and other hard surfaces. Also, the special taser weapon will electrify zombies, dealing secondary damage over time. Critical hits will cause blue sparks to emanate outwards from the affected zombies, giving subtle visual feedback on the level of damage dealt.
I haven’t posted any new developments for Zombox in a couple of weeks because I’ve mainly been doing code re-writes, optimizations and other things to get the game running faster on iOS.
One of the main hiccups in development has been the zombie AI. Until this week, zombies “saw” their environment with raycasts. While I was pooling raycasts and not doing 1 per frame per zombie, raycast performance with 30-40 zombies and many colliders on the iOS was slow. Also, while zombies don’t require an overly complex AI system, the previous I-won’t-chase-it-unless-I-see-it method left them unnecessarily dumb. Not to mention, the AI system couldn’t really be scaled up to include NPCs that need to be able to find targets.
So, I implemented an A* pathfinding system for all AI instead. The main hurdles I encountered while working on this system were: