I'm working on a .Net interop for quest support. So far it's going really well. I will be using it to develop my server Damoria. After all is hashed out, if anyone else is interested I will release it.
It works by parsing the dbg output file and generates the primary delegates/functions/classes that the quest system revolves around.
Currently Entity, Mob, Client, Npc, EntityList, Inventory, ItemInst, Spells, and Zone are supported.
It loads your assembly into it's own appdomain and can unload it at will, so testing changes is as simple as #unload, copy assembly over, #reload.
All of the events that are passed through EventCommon are passed to the interop's EventManager class for potential interception. You can access the EventManager and subscribe to the events there and then handle it how you'd like to.
This is an example of my SpellHandler class that handles Spell events.
http://pastebin.com/4DeHbfeh
This is the SpellEventArgs class.
http://pastebin.com/dmLv4xav
As you can see here, it contains all the necessary information to handle a spell event properly, including access to the spdatstruct of the spell that was cast as well as the x, y, and z location it might have been targeting using the FreeSpell targeting type.
Here is an example class of one of the test spells I've created, that works using the api of the inerop.
http://pastebin.com/ZB2pH3f7
All of these methods are calling the respective native functions in the processes' memory, the classes are just wrappers that organize things well. I've added extensive support for custom marshal requirements for strings, structs, etc.
For instance this was generated by my interop builder inside of the Mob class:
public StatBonuses GetSpellBonuses()
{
var constStatBonusesPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(StatBon uses)));
var ret = (StatBonuses)Marshal.PtrToStructure((Functions.f_M obGetSpellBonuses((IntPtr)this, constStatBonusesPtr)), typeof(StatBonuses));
Marshal.FreeHGlobal(constStatBonusesPtr);
return ret;
}
the C++ version:
inline StatBonuses GetSpellBonuses() const { return spellbonuses; }
I hope to be able to make this as portable as possible, but I also have a lot of stuff going on in real life. So bare with me!