How to store running effects?

Posted by Serenity on Wed 09 Dec 2009 12:16 PM — 2 posts, 13,798 views.

#0
Hi,

I'm trying to store running effects (spells, buffs...) to
persistant storage (disk, sql), so that when a player logs out after having drunk an expensive potion that should last an hour, he/she still gets the remaining time after relogging.

My system uses lua to implement effects and stores them under a runtime ID at runtime. Since some effects have scripts (with pauses in them), i'm at a loss on how to store this.

How does Aardwolf mud do this?

The same would hold for quests (kill x/x mobs, etc)
#1
Well, the best way (taking a page from large-scale MMOs) would be to create the effects and quests as templates, each with their own ID. And then only store that ID and any relevant non-persistent data.

So, for example, a spell effect that buffs the character's strength by +10 and lasts for 600 seconds might be created as effect #105. When you store it on the player you would only need to store two bits of data (ID=105, TimeLeft=N). The rest wouldn't change from login to login.

Same goes for quests. The only data you need to store is data relevant to the particular character, such as what quest step they are on, how many mobs they killed on that step, etc. You don't need to store the full quest itself since it doesn't change.

As for the format, you might consider storing it in pseudo-xml.


<effect>
<id value=105/>
<timeLeft value=119/>
</effect>