Follow by Email

Friday, 2 January 2015

Development Blog #0006 - Raiding Part 1

This week I coded the raiding system.

This week's development blog is going to be a lot more technical, as there's nothing new to film or image.

The raiding system is the game engine code that manages base attacks.  A newman declares that he would like to attack a base, then the game engine handles damage, attacks, and inventory.  This also includes looting a base and claiming ownership.

How it works:
When a newman attacks a base, anyone inside the base has the option to attack from the base -- with a 20% bonus chance to winning combat.  In Rust, the 20% bonus comes from things like shooting / spearing from windows, controlling the doors in the base, and using the base layout to the defender's advantage.  Of course, it's entirely optional to defend your base while you are inside. 
However, once your walls are breached, you have no choice but to defend yourself.  That said, the 20% attack bonus remains while you defend.  After a base has no health left, it can be looted.  Who ever loots a base becomes the new owner.  A damaged base can then be repaired.  The repairs significantly less than building a new base.  A defender can repair a base as it is being attacked, until out of resources, or the enemy has a relatively high tier weapon and does damage faster than repairs.  A base can only be upgraded once it has been fully repaired.  It costs about 50% of a new base in resources to raid someone else's base.

Coding this system was fairly straight forward and did not require must time to write and debug.  I moved on to upgrading the AI to actually do the raids, and that proved to be much more time consuming.

WLNewmanBrainBasic - Raiding AI
The goal is to upgrade the current basic AI to raid enemy bases sometimes. This called for a ton of necessary upgrades.  To raid a base, newman's have to first figure out when to raid.  For this AI, I figured it was reasonable attempt a raid once enough resources had been gathered for a raid, and a target base was in sight.  If there's no base nearby, the newman will continue to upgrade his base.  Second, once a newman has a target, he needs to craft enough tools to breach the walls.  After enough tools are crafted, the newman must head toward the target.  Upon reaching the target, the newman destroys the walls, and then loots the base. 

This much is coded -- but it's too buggy, so I won't show a video this week.

But even more needs to be done in order to make raiding work.  Raiding is pretty pointless if there's never anything inside the base, so I need newmans to consider how much stuff to store in their bases, and code a system for newmans to use their base inventory as well as what is carried in cost calculations and resource gathering. 
Furthermore, I need to code a small system that allows newmans to react to discovering that they have lost a base -- it doesn't work out if they keep thinking their raided base is still their own.

I figure at least this much should be complete by next week.  After raiding, I'll build AI support for multiple bases, then AI for hunting other newmans -- including strategies for fleeing.  After that, I'll build game engine support for newmans to logg on and off, and build the AI for that.  

Then the graphs come out.  I'll be able to say things about how Rust should change with some authority -- backed up by graphs and videos of the simulation.  That will be splendid.

Chances are, the AI is going to need significant refinement before I can claim it represents the average competitive player.  But that's cool with me -- I love working on AI.


No comments:

Post a Comment