View Single Post
Old 02-16-2012, 12:09 PM   #9
camlorn
Member
 
Join Date: Aug 2011
Posts: 144
camlorn is on a distinguished road
Re: High volume scripting question

Hi, so I do have some more...

First, what exactly are you working on? I'd be curious to see. I mean, the game in general.

Second, there are a few things you can do to help the scripting problem. I really think, given the time you're siting, that you should implement a scheduler of which two approaches present themselves: dedicating a certain amount of time to each script before pausing or allowing scripts to run more often.

So basically, the first of these is what windows does: your application gets so many microseconds to process before windows allows the next and the next, going around forever...This is oversimplified. I don't begin to understand the windows scheduler beyond the basics, but it is an interesting idea. Again, lua coroutines, or some other pausing mechanism. Depending on your situation, you could allow the mud to use 100% of cpu, so...

The second approach is a bit different. I'm making a few assumptions here, however. Given a main loop and some delay to prevent full cpu usage, remove the delay and reprogram it so that it's only idle when no scripts are left. Each time through, check the scripting queue and run, say, 5 or 500 or whatever of the scripts waiting to execute; if other things need delay, it becomes a bit tricky (I can see what you'd have to do in that case, but can't seem to express it).

Finally, do consider other solutions. If you need dialog trees, build a dialog tree editor in c++, save the tree with the mob, and have the leaves set flags or not. Basically, this is what most of the major games with dialog on like ps3 are doing; I've never heard of another approach. Given some initial response, and 3 responses, and 3 responses off each of those, you've got nine leaves; either assign each leaf a script or give each leaf the ability to flag the player somehow.

Just my thoughts; again, I've done none of this in practice (yet).

And, you probably don't need nor will you ever have thousands of scripts per second...if you do, consider reimplementing scripts that load everywhere in c++. Circlemud, for instance, has mob behaviors, where a heal script becomes a flag that says this mob heals people periodically, or there's one for this mob casts spells...basically, if builders are writing a bunch of scripts to do the same thing, try moving it to the engine.
camlorn is offline   Reply With Quote