Jan 29 2012

A long-expected party

Tag: Full Games,MMORPG Tycoontrevor @ 6:18 pm

So here’s something I’ve been waiting an awful long time to see; I’ve finally reached the end of the massive AI refactoring job that has been consuming so much of my spare time over the past few months (that’s overstating it; I’ve really only been feeling up to outside-of-work coding for a few hours per week, so this hasn’t actually taken up all that much of my time), and have merged it back into the main development trunk of MMORPG Tycoon 2.

What does this mean? Well.. not a lot, immediately; mostly it’s doing the same things that it was doing before, just with much more well-organised code. There are probably a few new bugs in the AI which weren’t there before (as this new implementation hasn’t been as extensively tested as the old one). But the architecture of the system is much, much better now.

For example, the handling of human-controlled PCs and AI-controlled PCs move through almost identical code paths. This means that human-controlled PCs now receive experience points and level up and get quest completion credit, the same way that AI-controlled ones do. The Bartle type of a PC is now stored on the subscriber, not on the individual character.. which means that no matter how many alts a subscriber makes, they’ll all have the same Bartle type, as you’d expect (which wasn’t the case, before). Similarly, the various desires (“socialise” vs “gain level”, etc) are now on the subscriber instead of on the PC, so a subscriber could now theoretically meet a desire to socialise by logging in with a different character, which was not previously possible.

But more important than that, all of the AI logic has been pulled apart into clean(er) modules, so it should now be much, much easier for me to insert new AI behaviours, such as adventuring as a party or as a guild.

I have also begun work on supporting different xp allocation mechanisms. Previously, MMORPG Tycoon 2 allocated experience points to every PC who thought they were attacking a monster when it died, whether or not they actually ever hit it (and similarly, any PC who chose to run away after damaging the monster would receive no XP if it was killed immediately afterward). Now, monsters keep track of who has damaged them, and award XP to those PCs. This also will be important for supporting party-based adventuring.

So what’s up next? Well, I’m really wanting to push ahead with some world editing interface work, and I’m thinking really hard about whether the MMORPG Tycoon 1-style spline roads are really a good choice, here, or whether a more traditional “tile grid”-based road system would make more sense for a game that’s played from this close up. The problem with spline roads is that a slight movement to a long road can require huge amounts of terrain modification — often I have to rebuild almost a quarter of the visible terrain in order to cope with a path that’s now taking a slightly different direction. Maybe the simple tile grid layout would help localise changes more. Although I really do like the freeform paths, I must confess.

Anyhow, moving on! There’ll be some general life news later in the week, as well. Further details then!


Oct 09 2011

Profiling is fun

Tag: Engine,Full Games,MMORPG Tycoon,VectorStormtrevor @ 6:02 pm

Actually, that’s a dirty lie.

Profiling is fun when it shows you something big that’s easy to fix.  Profiling is a lot less fun when everything is equally slow.  But luckily in my case, there was something big to fix.  :)

I noticed the other day that editing roads in MMORPG Tycoon 2 had become extremely slow.  (Well.. actually I noticed that roads didn’t draw at all.  It was only after I fixed them not drawing that I noticed that they were slow to edit).   This was odd, because I have videos of early road editing, where it hardly touched the frame rate at all on a system much slower than the one I’m using now.  So after some profiling, I found that creating their procedural geometry was taking up about 75% of the whole processing time for the frame when they were created.  This was extremely bad when editing them, especially (because they’re regenerated every frame, when they’re being edited, or when the ground under them is being edited).

Those of you who were at Freeplay will remember the part of my talk where I discussed optimising games, and when to do it (or rather, when not to do it).

For those who weren’t there, the tl;dr version is this:  don’t optimise anything unless you have timing numbers that proves it’s slow relative to the rest of your program, and against which you’ll be able to judge your progress.  Ideally, you get these numbers by using a profiler of some sort.  (Visual Studio has one built in, modern Xcode uses Instruments while old Xcode used Shark, under Linux you have gperf, etc)

What I didn’t say in that talk (and which I’ve regretted ever since), is that there’s a second criteria which can make it acceptable to optimise some code, even if you don’t have performance numbers.  Here is that other criteria:

Continue reading “Profiling is fun”


Sep 19 2011

Some little updates

Tag: Full Games,MMORPG Tycoontrevor @ 10:47 pm

 

So work has been busy, and I haven’t had nearly as much time to code on things here as I would have liked, but I’ve made some interesting progress over the past week or two.

The first thing to mention is that I believe I’ve finally cracked the nut of making the game’s height map look good;  no more weird diagonal diamond patterns visible across changes of surface facing!  (this involves re-triangulating the surface to try to minimise artefacts)  This was especially bad before at sharp creases, such as you can see at the bottom of this extreme hill, or around the edges of darker areas, at the crest of the hill.  It was also often very visible on the mountains at the region boundaries.  But now, it’s pretty much bang on every time.  I’ve been doing this “re-triangulate the mesh to try to hide those diamond patterns” thing for an awfully long time, but it was only today that I finally found the right combination of heuristics to actually make it work reliably.

I’ve also moved from a simple directional-lighting light model to a wrap-around lighting model, which gives the game a much softer look, which also helps with the smoothness.  And is just a nicer look overall, in my opinion.

I’ve also started implementing more ground shaping tools.  Most notably is the ground leveller.  Basically, it tries to flatten out the terrain under your cursor.  There are versions which will only raise terrain, only lower terrain, and which will go in both directions.  This is great for setting up flat surfaces to place buildings upon.  (Since buildings only place their centre point on the ground, it’s common for their corners to be floating, or for the ground to be embedded through the building geometry.  Still TODO is to have buildings automatically flatten the ground under them, when placed.

Oh, and incidentally, grass now flows downhill, instead of always east-west.  I don’t think you can make it out in this screenshot (I’m too far away), but trust me.  :)

I still need to do thinking about how to set up the overall ground editing interface.  The “paint on” interface is nice, but even with the work being farmed out to background threads, it’s hitting the frame rate too hard, when the user paints with a large brush.  I’ve been thinking about having the terrain editing tools work with a grid lattice, which I could easily update in real-time.  When the user is happy with his changes, he could click an “Accept” button, to assign the terrain rebuilding to a game developer.  This would make it work similarly to how placing buildings works;  giving commands to actually be executed by minions.  And it would also solve the problem of needing to rebuild the terrain every frame;  instead, it could just happen in the background, when the developer is actually performing the task.  Need to think about this more;  I’m not sure how the user would specify terrain types on a grid lattice, for example.

I took a stab at continuing with player AI, but rapidly banged my head against the current code setup.  I think I’m going to have to heavily refactor the code, before I can add anything more to it.  It works right now, but it was written in the fastest possible way, way back for my self-induced “Milestone 1″, and at this stage, I’m stumped as to how to add parties to the system, without breaking the quest-following behaviours that are already in there.


Sep 01 2011

Minor update

Tag: Full Games,MMORPG Tycoontrevor @ 11:00 pm

Very minor update today, since I didn’t have much time to code, but got a few things implemented.

First, VectorStorm materials now have an optional “layer” value.  This value defaults to zero.  Within a scene, material batches are drawn in order, according to increasing “layer” values.  This allows us to force transparent geometry, such as the extending arrow effect, to draw later than opaque geometry, such as the ground surface.  Note that this only works when rendering is performed via the material batching interface on the vsRenderQueue;  materials applied by directly setting them within a vsDisplayList will render exactly as requested within the vsDisplayList.

Second, I’ve been removing lots of old, dead code.  Most notably, I’ve now removed the carcass of the old combat system.  Now that players and monsters are attacking each other using via configurable attacks, the fake old system really isn’t necessary any longer.  The Player AI really needs some serious refactoring;  I’m probably going to spend the weekend trying to massage the code into a simpler and more extensible state.


Sep 01 2011

The last multithreading post (for now)

Tag: Full Games,MMORPG Tycoontrevor @ 12:12 am

Setting up multithreading code is complicated!

Here’s what’s new:

  • Set up a generic “task management” system for MMORPG Tycoon 2.  Systems generate “tasks”, and tasks are assigned out to worker threads, which work on those tasks, and then let the main game know when the tasks finish.  Heightmap building now uses these generic worker threads, instead of having their own threads.  Right now, there are eight worker threads.  But in theory, it’s probably best to have the same number of threads as the user’s CPU has cores, potentially plus one.
  • Clutter generation stuff occurs using dedicated threads.  I need to convert these over to use the new generic worker threads.
  • The game now waits for all queued up tasks to complete, before rendering the next frame.  This fixes some problems I was having before, where different blocks of terrain were updating at different times and not matching each other, just due to how long they took to calculate in the background threads.
  • Fixed some issues with my OS X semaphore implementation (since OS X doesn’t support unnamed semaphores, for unknowable reasons).
  • Worked around a renderer bug, where anything which had no texture was being drawn opaque, regardless of its material settings.  This affects the live trunk, too;  I’ll bring the fix across at the same time as the various threading fixes I’ve mentioned in the past week or so.  (If anyone needs a quick workaround in the meantime, just remove the line “m_state_SetBool( vsRendererState::Bool_Blend, false );” from vsRendererSimple::SetMaterial() on VS_RendererSimple.cpp, line 958.)

And now, I’m completely sick of dealing with the complexity of threads, and so the next thing on my list will be more player AI.  I think I’m going to work on making players assemble into parties that do quests together.  That ought to be entertaining.

And it raises some interesting questions, which actually come up in the development of real MMORPGs; how to handle characters who are of differing levels, but who want to team up — ignore it?  Boost the level of the lower character?  Lower the level of the higher player?  Not allow teaming between those characters?  And worse, what do we do when a character completes a quest multiple times, accompanying different party members.  Do they get the reward multiple times?

My understanding is that most modern MMORPGs now give credit for completing a quest again in this sort of situation, but older MMORPGs often will not give repeated completion XP.  I wonder whether I need to make this configurable for players, or whether I should just take the modern approach and assume that that’s what everyone will want.

Lots of stuff to think about!


Next Page »