For the past few weeks I've been working on combat-related behaviors and improvements to the Simulation Server, and I'm now starting to polish things up a bit for a video update near the end of the year.
Work on Antilia's NPC behaviors and combat systems have continued progressing along for the past month. There have been some fairly frustrating days working on the new behaviors, but also some really awesome days where things went from doom to "whoa, it's working, look at them go!" It's really neat seeing the NPCs come to life and start to act out their roles. I have heard stories of other games in development where NPC behaviors were notoriously chaotic, and having gotten just my toes a little wet it's easy to see why.
Server Architecture Improvements
Something that surprised me this month was how quickly my server architecture bogged down by creatures and NPCs. Nests across the Isle of Kasau are regularly spawning eggs, which hatch into jidou and iichii. Those jidou and iichii grow old and eventually die, and the current rates result in a population of about 1500 iichii and 800 jidou. I think 25% or less of that amount would feel more natural. I intend to dial down the spawn rates for both creatures, but considering the goal is to eventually include Antilia in Antilia I really need to see the server successfully handling higher numbers, not lower numbers.
It really shouldn't have been a surprise, as many game engines have either a practical (or in some cases a hard upper) limit on the number of active NPCs. I will sometimes optimize a function, get it running at what I initially would consider "fast" when some complex function clocks in under 1/1000 of a second, and then be disappointed when having 2000 NPCs in the world runs at less than one update per second - but that's just the math.
|Warning:||Technical/programming stuff! |
A solution that many games use is to have a "sleep" state that creatures and NPCs can go into when players aren't around. I knew when designing the server that I would eventually need such as system and had implemented a solution for this in "update priority pools". The piece I was missing was a means for a game object to change it's update priority dynamically. Up to this point game objects were in these pools, but had to be assigned to just one at load-time, with all creatures and npcs being in the same pool.
After adding some functionality so that objects could dynamically manage their update frequency there was a dramatic improvement in performance. I could keep the Isle of Kasau over-populated with 2300 creatures, and only the creatures in a range around the player(s) get constant updates. The other NPCs don't fully go to sleep either - they just receive their updates less frequently "as time permits" by the CPU.
|Info:||Updates-per-second on the Antilia server are not related to rendered frames-per-second on the client. It's common in testing right now to run the server at 15 or 30 UPS while the client |runs at targets 30 or 60 FPS.
With the new changes in place, game objects like NPCs on the Antilia Server can request they be placed into one of several pools to receive updates. These pools include:
- No Update Pool - Objects like rocks that don't actually change unless they are being mined can place themselves in the "no update" pool.
- Low Priority Pools - Objects that slowly change over time like plants that grow can place themselves in the low priority pools. These pools might only receive one update every few minutes.
- High Priority Pools - This pool is used mostly by NPCs that aren't being observed by a player. These pools might only see an update every few minutes up to every few seconds. In this pool NPCs can still walk around and perform tasks, but don't put much load on the server because they are only updated once minute or so.
- Critical Pool - Objects in the critical pool receive an update every time the server thread cycles. Typically 15-30 times per second. This pool is for NPCs around players.
I've added some logic so that characters controlled by players automatically tell objects around them to "wake up" and those objects can move to a higher priority pool if warranted, and so far the result has been great. CPU load on the server is down, while the responsiveness of NPCs in combat is way up. And NPCs still go about their business fishing and cooking and such - just a little slower if nobody is actually watching (slackers).
|Info:||The total number of players a server can support will likely be closely tied to the number of NPCs that the player characters "wake up" |
The server administration tool now displays detailed performance metrics for each simulation thread, including the number of active NPCs which have a large impact on performance. At the time of this shot I was standing in the middle of a jidou iichii "war" with about 100 creatures in active (critical pool) state.
The Current State of Combat
The current state of combat in Antilia is that of a partially complete first pass. We've gone from "nothing" to "something" with regards to the basic mechanics of enemies moving and attacking, skills and projectiles, weapons and damage types, aggro and factions, equipment, etc. I've built most of the bigger parts and figured out how to roughly fit them together. But there isn't really good use of any those things yet, and there isn't nearly enough content or polish for it to be any fun. As you can likely tell from the images combat still looks and feels very robotic. I will need to give combat more attention after the video update.
The Tangled Lands region is starting to feel quite different with Swamp Iichii and Swamp Jidou frequently at war with one another. With the damage they are currently capable of a group of iichii with medium to high levels are now a considerable threat - more than I really want in what will likely be the first hostile area players venture into.
Like other gameplay systems after this pass I'll take a break from it and start thinking about what I got right vs. wrong in this first pass and start planning the next round.
A short time-lapse of the current work-in-progress "Defender's Guild" behavior. Iichii in large groups are nearly impossible to deal with right now. I had to give the character "Hero" here 5000 HP to clear them out.
There are currently many of these chaotic wars where the Iichii and Swamp Jidou fight. The Isle of Kasau in my current save game has far too many creatures (800 jidou, 1500 iichii), but it's encouraging to see the server able to do this. There are still a lot of noticeable glitches, timing, and tuning issues.
Inventory and Equipment Behavior Nodes
Last week I spend a bit of time refactoring some of the older NPC behaviors that I had working last year but were broken when I changed the behavior system to use nodes. I'd like to have as much of what we've built so far in good working order for the update.
With those two behaviors plus the "Light Firepit" behavior I have our chef in Taipii Base Camp keeping the fire pit fueled and lit, and soon I hope to have the character grilling while other NPCs resume their fishing behaviors. Combat skills require a lot of energy, and our "defender" NPCs will need plenty of food available to fuel their service.
The updated "Take From Container" behavior node.
Before sending Hero into combat he needed to be able to equip a sword, and for that matter some clothes. This behavior test demonstrates the character detecting missing equipment, and running over to these crates to take the items they need.
That's all for this week, thanks for reading!