Are We the Baddies?

Are We the Baddies?

Remember this guy?

Okay, he’s a little blurry in this screenshot, but he’s really far away…. Okay, wait. Listen. Let me start over.

It’s been a while since I’ve written one of these.

Back in the day – meaning every day until this day – that little red guy was just kinda sitting there at the end of our little walkway.

If you ran up to him, he’d chase you around, but other than that, there wasn’t much you could do with him.

So the next thing on the list is to make it so you can, you know, kick his ass. Unfortunately, he wasn’t really hooked up to the server, so even if you could kick his ass, the server wouldn’t know you kicked his ass. Also the server wouldn’t be able to say you’re allowed to kick his ass. Those things are kind of important.

So how do we kick that guy’s ass?

The first step here was to make it so that the server handled spawning enemies, rather than the enemy just kind of sitting there. This actually opened a whole big can of worms.

Okay, so for example… The server needs to spawn an enemy. Great. Where does the enemy spawn? How many of the enemy should spawn? How frequently should the enemies spawn? Should there be a maximum number of enemies? Should there be a minimum number of enemies? How do we know which enemy is which? How do we let the client know about enemies that spawn? How do we let the client know about enemies that already spawned before they logged in?

The list actually goes on quite a bit longer than that.

How The Big Boys Do It

I’m reminded of the Northshire Vineyards in World of Warcraft. The area has a bunch of Defias bandits which patrol around the outer edge of the farm. It also has a bunch of bandits which spawn randomly inside the farm itself. Some of them wander randomly, some of them follow set paths. When you kill them, they inevitably spawn back in. Those enemies patrolling the fences of the vineyard will always come back.

In WoW, they really define the spawn point and all of the pathing for every single enemy. There are no random spawns in WoW – at least there weren’t in the Wrath days. There’s only subtle variation in the way some enemies wander. Is that how I want to handle it?

Maybe the solution is to use a combination of randomly spawning enemies within an area and hand-placed ones to give some cohesion. Maybe the solution truly is to hand-place every enemy. This game is so heavily inspired by MUDs, and their enemies were all hand-placed too. I remember reveling in the days of “repops” where suddenly all of the slain enemies would come back to life all at once.

Anyway

In the end, I did have to come up with a way to answer those questions – and I needed to make it configurable per area. So now there are big rectangular prisms – spawn zones – that tell the server all sorts of information: What kinds of enemies should spawn, how many enemies should spawn, how frequently they should spawn, when they should stop spawning.

The walkway we had before simply wasn’t enough anymore, so I expanded it a bit…

That’s right, baby. It’s a whole platform now.

For now, my enemies only spawn in and stand there … menacingly. But patrolling, and having specific enemies I want to spawn, like those patrols around the fences that will always come back, is something I’ll be doing in the future.

The most important thing is that the server is handling enemy spawns, and communicating them to the player. It’s also handling enemy behaviours now. Previously, the client was handling the behaviour for when an enemy should lock onto and chase a player around. The server is handling the logic now, and instead only informs the client about where the enemy is and how it’s moving.

That’s right, enemy positions are now being fully handled by the server too. And I used it to test drive a new methodology I want to try on players next. In theory, the new way I’m transmitting position data should let me cut down on the frequency of updates. Of course, I may do that and find out that they really did need to be as frequent as they were.

Enjoy this video of me being an absolute menace to my poor enemies – and remember, all of this is server-driven now.

You can see at the beginning of the video as well that the spawning is happening in the background on the server despite the player not even having connected yet. When the player connects, all of the enemies spawn on their client, and then when the next spawn happens, it happens on both in realtime.

Next thing we need to do is handle some actual combat behaviours. Sorry about the slow update. Things have been busy and stressful and I really need a break.

Alas, no rest for the weary.

Maybe we should do something about this fixed camera angle…