Choose Your Language

Thursday, 26 March 2009

Multi-Player Plot Item System

I have been concentrating on a couple of things this week. First, I have been giving some time to help beta-test Amraphael's Zork module. This is one of three modules I have been trying to spend some time with. The other two, which I have started (but only just) and need to do more with (if and when I get the time) are: Fate Of A City and Price of Honour. I am prioritising the Zork adventure for now, as I did say I would try to help with the testing.

The second thing I have been concentrating on this week turned out to be quite a difficult thing to do, but eventually I succeeded: Design a system to ensure plot items would remain in play in any/most combinations of a game. While this is more important for MP games, it also has some benefits for a SP game. E.g. If a player drops a companion or decides to leave them behind (and they happened to be carrying a plot item), then the item will automatically be given to the main PC. In a MP game, this process becomes somewhat more complicated, as we have to consider other players coming into or leaving the game, who also may or may not have companions and be carrying plot items. In this situation, if a player leaves and they were carrying plot items, then they are passed over to a player still on the server so that the game can continue if they need to. If the same player should return to a later saved game (and still has plot items on them), then they are removed in favour of the player who is currently running the module.

The whole procedure of trying to keep a database of plot items (stored as resrefs on the module that are preserved between game saves - storing objects failed to work), which could also be duplicated or even have tag-based scripting was quite a coding headache. However, after a few days of trial and error, I believe I have a solution. I even had to update the barter.xml code, because if a player cancelled bartering plot items, then the code that updated the plot state was not updated. It was a complicated affair with adding code to the On Mod Leave, On Area Enter, On Acquire, On Unacquire and some specific scripts that I use when handling companions. Now that the job is done, however, I can happily (hopefully) add plot items with alb_plot_ at the start of their resref and the code will take care of the rest. That's the plan at least, and the system is capable of checking 100 items per module as it currently stands, which should be ample. Remember, these are plot items and not just any item: Items that must be acquired and used to complete a quest.

Maybe I can get back to working on the story again now. ;)

No comments: