Jump to content

Trying to write a Zombie AI mod


Recommended Posts

I had a brief go at this when A19 came out, but now with A20 really want to give it a go.

I want to massively increase the chance that a zombie will go into the Destroy Block behaivour under specific circumstances.


After pathfinding, if the length of the path (sum of the distance between all nodes) is significantly longer than the pythagoras distance to the destination, then have like a 90% chance of just destroying a block.


This is a counter to a large number of bases that abuse pathfinding to put zombies on looping paths. A little bit of this is fine, and I'm happy for it to work, but this extra block destructions should stop you relying on it as a principal defence. We can tweak that 90%, and/or adjust it based on the path lengths, until it balances.


Doesn't seem like it should be too hard to achieve. DestroyArea happens depending on the moveHelper, so adding checks there should be possible - I just want a bit of help if anybody has looked at this code.


Link to comment
Share on other sites

The game uses the A* path package as it base pathfinding, then modifies that and hooks it into the rest of the AI Logic.  Its all in the assembly, but based on what we saw, we didnt want to touch changing it for out Human AI project.  Good luck, you have quite a challenge selected.

Link to comment
Share on other sites

Yeah, its an assembly change. I think the path returns an array of nodes, so I should be able to sum the distance between the nodes and compare it to the worldspace distance to target. I looked at it during A19 but didn't really make any notes. Do you have any info on how the behaviours and tasks work? I just need to use that path result to switch into the destroy block thing instead of following the path.

The A* side of things pretty much works, there is bug with path costs but it doesn't really need fixing because its fine that Zs are dumb so I think that can all be left where it is.

Also, new computer, so I don't have any tools setup. Is there a guide on getting the assembly and DLL patching. Pretty sure there was a simpish thing that extracted and allowed you to build and run the game but I'm basically starting from scratch again.

This shouldn't be the hardest mod to write, but I think it'll nerf most of the bases that exploit stupid pathing - the horde just prefer to destroy rather than be taking on a loop, so I think they will act more like "real" zombies and just improve horde night. We've got a few other balance changes, like a headshot, fire, and explosion damage rebalance but this will be the big behaviour change.

Link to comment
Share on other sites

If you found a code bug in the path costs Id be interested in learning more about that.  Our Human AI use A*, and the less dumb they are the better.


Join Guppy's Discord and the channel on C# coding.  All the tools and references you want are linked there.

Link to comment
Share on other sites

  • 11 months later...

There is a whole lot that goes into "A.I." in a game. The A* pathing is only part of it, and it doesn't have much to do with decision making. Deciding on tasks and targets are done, in vanilla for zombies, by something called EAI (Entity AI).


If you're curious, I took notes on the task and target code, just for my own understanding. I don't have any idea if those notes are useful (and they were taken in A19 so things might have changed somewhat), but if you want them, here they are:



Link to comment
Share on other sites

  • 1 month later...

Sorry if this would be considered necroposting, but I also would love to know if anyone has done something like this or has assembled something from khzmusik's notes.


I much preferred the old 7 Days To Die AI where zombies behaved more like zombies and didn't magically know the shortest route through a path they couldn't see. I've been looking a bit and I hope there's some way to bring back "dumber" zombie AI via modding some day, where zombies will try to come at you in a straight line and if blocked by an obstacle that is not a trap, will only circle around a short while before getting "frustrated" and then trying to destroy that anyways.


I remember the old days of 7 Days To Die when they used to take down whole buildings instead of creating a single (and for zombie brains, abstract) path and then taking that and leaving the rest of the structure untouched. Not saying I hate the modern AI, and it sure did solve some exploits like bedrock bases and other ways to cheese the base building, but if you play the game without trying to cheese it, I found the old AI to be much more fun (since the current AI practically forces you to build a very specific kind of base).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...