The Spell Engine

I finally got the spell ‘plugin’ system to work as intended for the first externally-coded spell.

Each spell is stored in an XML file outside the MUD engine, i.e “Fireball.xml”.  The file has a bunch of settings for the spell like casting time, target type, modifers, etc.  It also has an optional code section for more complex spells.

Yesterday I got the simple case working, that of a single-effect spell with no custom code like detect magic.  It just sets the ‘can detect magic’ ability on the target for a number of game hours.

Today I got the more complex case working — that of a spell that uses compiled custom code.  The example spell is ‘minor creation’.  It has a lot of custom code to process keywords and select predefined objects based on those.

The code I put together a year ago almost half-worked.  It could load the spell code from the file and compile it, but when it came time to execute it failed.  Turns out that most of the issue was how namespaces were being referenced and how types were being created — lots of detailed C# reflection stuff.

Now that I’ve worked that out there are no more roadblocks to ‘modernizing’ spells.  Sure, only 2 are converted so far and there are 419 to go, but now that the groundwork is in place it shouldn’t be too difficult.

So far this is only on my local machine – not up on the server yet, but will be within a day or two.