Sunday, May 24, 2009

World building - Avoid loose coupling

I'm currently working on a system that will be able to get directions from point A to point B wherever you are in Golemizer. Well, almost...

When I first started building the MMO framework, I had no real idea of what game I would build with it so I made some decisions that would give me more freedom. An example is that at first, zones reached through a "portal" had no idea to which portal they were attached.

I figured that I'd have many types of non-open-world zones like buildings, mines, dungeons but had no clear idea (maybe besides buildings). I wanted to keep my system as generic as possible to be able to create different type of zones without having to do specific coding for each. It all went well at first.

Then came the question what if I want to specify access rights to a building. I have no way to link the zones to the building.

Then dungeons came in. I had multiple zones with the same coordinates and no way to tell which one was the zone on the same current "level" when players were expanding their dungeons (because I need to detect if a zone already exists in X direction to link zones together).

So my initial plan wasn't that smart. I had to add a notion of link between zones and buildings and the same for zones and levels of dungeons. I guess that if I would have been even smarter, I would have built some generic system to track that so I wouldn't had to code 2 different things that do in the end quite the same thing...

One thing I haven't covered is mines... There's 3 mines in Golemizer and they were built before the dungeon system so they are just an item in the world leading to a zone linked to other zones. I can't tell which zones are part of a given mine.

Now of course I'll be able to fix that later as I still know the entrance zone so from there I can walk in each zones and link them back to the mine but that just create extra work. That shows that loose coupling was really a bad idea to begin with.