logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
making nwnx com-accessible

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development
View previous topic :: View next topic  
Author Message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Thu Apr 05, 2012 12:29    Post subject: making nwnx com-accessible Reply with quote

Is it possible to make nwnx Com-Accessible.
In that another application can interface and control/issue requests to nwnx?


I'd like to have the ability to execute scripts, in nwn, but triggered by an external event.


eg - TCP Client / Server application setup,
My App could receive communications, and then depending on the communication, they could trigger scripts to run in nwn.

I guess a plugin could do this, but I thought it might be good to do COM Accessible nwnx2.exe - as it would encompass all plugins loaded?
Back to top
View user's profile Send private message
addicted2rpg



Joined: 01 Aug 2008
Posts: 106

PostPosted: Thu Apr 05, 2012 13:40    Post subject: Reply with quote

For a person who has coded in it ("got my hands wet"), I haven't actually done much marshalling in it, or made any com objects. Those are basically like .NET function wrappers to some externalized routine, right?

Anyway, my pathetically bad .NET knowledge aside, what you are talking about sounds a lot like Lanthar's Speech System probably called Talus Speech System. I think it was eventually adapted to cover a lot of networking in general. There may be a more modern successor under another name.

I also think the Linux dudes have gone all the way to hell and back with the linux equivalent (whatever it is) of the Speech System. I've seen some mods out there with some pretty killer network hooks.

edit: For picking up externalized events, make a limbo room (it would only be accessible via the DM client; no entranes or exits). Insde it, create an NPC called "master control" and remove all of his script functions and set him to plot/immortal. Then add a single script under heart beat.

You can use it to dequeue events at the HB timed intervals that are going on in the database. The heartbeat event fires every 6 seconds, I think, so you can use it as a poor man's way to poll for input. You have your external tool or source insert into the database your event information, and the master control NPC reads the record out and deletes it, then performs the necessary task.
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Thu Apr 05, 2012 17:49    Post subject: Reply with quote

Quote:

I also think the Linux dudes have gone all the way to hell and back with the linux equivalent (whatever it is) of the Speech System. I've seen some mods out there with some pretty killer network hooks.

edit: For picking up externalized events, make a limbo room (it would only be accessible via the DM client; no entranes or exits). Insde it, create an NPC called "master control" and remove all of his script functions and set him to plot/immortal. Then add a single script under heart beat.

You can use it to dequeue events at the HB timed intervals that are going on in the database. The heartbeat event fires every 6 seconds, I think, so you can use it as a poor man's way to poll for input. You have your external tool or source insert into the database your event information, and the master control NPC reads the record out and deletes it, then performs the necessary task.


The DB Approach is something I did once apon a time.
I hated it.

I had a system that allowed players to delete their characters from a web interface.

Being driven from an ingame heartbeat drains in-game resources, even if it is a very small amount of resources.


Technically, this could be quite easy.


DotNet dll < - > DotNetPlugin dll < - > nwnx.exe

DotNet dll would have whatever functionality desired from the .Net Framework.

It receives and sends commands to the nwnx_dotnet.dll plugin
which then interfaces with nwnx.exe which has the direct connection to nwn.

We already fire scripts from nwnx (technically an external process) - we fire the ExecuteScript function all the time in the nwnx_events plugin.

So duplicating that functionality and putting it into DotNetPlugin.dll would give the ability to trigger in-game scripts to fire from an external event.

The tricky bit is setting up the interface that allows the DotNet Plugin, to receive messages from the DotNet dll.


Calling to a DotNet dll from the c++ looks do-able, (even getting return values)
but receiving requests from the DotNet DLL to the DotNet Plugin is what looks complicated.
These requests would fall outside of the range / scope of a return value, as they would be initiated potentially by the dotNet dll

Im hoping that getting DotNet functionality working, and integrated via plugin, I can get Multiple threads working, and then feeding information back to the nwnx plugin, which then takes action, and executes scripts
Back to top
View user's profile Send private message
addicted2rpg



Joined: 01 Aug 2008
Posts: 106

PostPosted: Mon May 07, 2012 13:47    Post subject: Reply with quote

Baaleos, I created a "live" on-the-fly packet editor for the NWN client and I've been using it to create test cases for things that Bad People <tm> do; I will then proceed to use the test case data to write an anti-cheat/anti-hack module (under the NWNX plugin platform) for Windows' nwserver.exe. That's the *goal* anyway, I've just been coming along at it really really slowly. A lot of this is because of the challenges I have been facing in interpreting the networking protocol.

It seems that Elven fellow has done some work on it, which he documented here: http://jnwserver.swordcoast.net/index.php?title=Category:Protocol

Anyway, what you can do is revamp my code to run on the nwserver.exe instead of the nwmain.exe, the concept is pretty much the same I think, and if you're clever you might even be able to get a C# equivalent of it going. If you want I can send you the code privatley via a forum PM. I'm keeping it all kind of quiet until I can come up with a final product, so I would appreciate your discretion with it =-).

It is written for Visual Studio 2010 using Win32 C++ for use on a Win-7/Vista compatible system, although I think its backwards compat to XP.

It does a lot of hooking, and I'm using my own hooking routines and injector - its been pretty much a ground-up project; I have chosen to forego Madshi's hooking DLL, but the calling conventions are literally the same so you shouldn't have too much problem in making a C# substitute if you use the DLL.

Anyway, in theory you should be able play around with the packets coming in to your server. For some reason, I feel this has already been done before by someone else already..... I kind of want to say that the VaultSTER dude might of done something like that?

Setting up the runscript environment stack (so things like GetLastUsedBy() will actually return a player) and kicking that off might be something of feat though.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows development All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group