Import PC character into another module?

Is there a way in NWN2 to import a PC character from another module? I’m working on part 3 of my module series now, as part 2 is currently in beta testing, and each module has different protagonists. So, I had this crazy idea: Would it be possible to import the PC character the player used from part 1 into part 3. They are all just modules and it is not a campaign.

I read in another thread for NWN1 that someone had tried this but that it was difficult…

So, I doubt this is possible since every player has their own PC, but if there was some function or something to look for the character in the localvault of the player’s computer and then import that character into another module, that would be pretty cool. If this doesn’t work then it’s no big deal. I just thought it would be cool for the PC from part 1 to do a cameo in part 3. Of course I’d have to ask the player which choices were made so that dialog would be correct.

1 Like

while a localvault character cannot be imported … a PC can (i believe) be exported to the “campaign database” (in the Docs/Nwn2/database folder) and then imported as an NPC

There are several stock functions that support the database; these two in particular might be of interest

int StoreCampaignObject();
object RetrieveCampaignObject();

and there are other functs that could be used to store things like conversation choices, influences, etc etc. It’s a database …

but, be forewarned it takes a bit of expertise (just a bit) to use correctly,

1 Like

FWIW if this was NWN1 I would save character in the first module. Then When starting the second module, this character would be in the local vault ready to use as the PC. Doesn’t NwN2 have this facility?


1 Like


yes it does … but

I think andgalf wants the PC (from Part 1) to be an NPC (in Part 3).

in which case code would need to be added to Part 1 … to export the PC to a database


Thanks for the replies. Yes, kevL_s got it right. As I said I have different protagonists in each module, and I would want the protagonist from the first module to be an NPC in my third module. As it is now the character used by the player isn’t exported in any way in the first module. I mean I could update the module with this perhaps, but I think it would be a bit unfair to force every player to replay my first module to be able to play the third one when it comes out. That’s why I asked if there’s a way to import a PC without doing that. If I had thought about this back when I made my first one it would have been an entirely different thing…

And I’m afraid I’m no expert at all when it comes to module making and NWN2. It sounds like it will be too hard for me to grasp. A question here: You said a character could be stored in the “campaign database”…Does my module have to be a campaign for that to work perhaps?

not necessarily. if the cameo can be optional, it could be conditioned on whether the “campaign object” is available/valid.

(On the downside, it would leave a database on each player’s hardrive, if he/she played Part 1, the only use for which is playing Part 3)

nop. The descriptor “campaign” is used because for NwN1, there isn’t what nwn2 calls a Campaign. As you know, Nwn2 can link modules together to form a Campaign … but a database can be used in 1 to do something similar (transfer stuff from one module to the next). But the code is still in NwN2, so we can use it to transfer stuff either between modules OR between Campaigns …

1 Like

Ok. Still sounds quite interesting, I must say. Is the database big? Do you think people would be annoyed by my module putting it there? Could you maybe try to teach me the expertise bit…or…

here’s a screenshot of the databases on my hardrive (3 files for each db)

compaisettings - used by TonyK’s Companion and Monster AI (for saving and loading character behaviors on the character sheet)

pia_database - a personal db (based on the Personal Impossibility Adjustment, but not included in the released version – stores the Pia’s settings for use by the Options gui)

universalcompanions - stores characters that were exported by AlanC9’s Universal Companions mod.

sure, but you’d have to prompt me with questions …

Wish that was mentioned a little earlier in the post. Cest la vie.

As NwN 2 uses a version of NWScript, I wonder if the NwN 1 " OHS Henchman System" can be adapted for that purpose. It apparently takes selected local vault characters, turns them to NPCs (and thence to henchies) and stores/retrieves them from a database.


I believe that for any scripted system to access the player’s local vault requires either (a) something like NwNx or (b) direct intervention by the player. The OHS Henchman System appears to rely on the later.

That is, from what I gather, if a player wants to register a particular character in the OHS, player must load the character from his/her localvault and register the PC ingame. While it appears to be a very polished system, the Universal Companion Database uses the same underlying functions – viz. database functions – to achieve a similar result : the difference is that the OHS imports db-characters as Henchmen but the UCD imports them as nwn2-style Companions.

The later are different than Henchmen, ofc … but since Nwn2 still has Henchmen also … but they tend to die a lot since we’re way too preoccupied by our Companions … it looks to me like the OHS Henchmen System could well be adapted to and used in Nwn2 if one wanted their previous PCs as Henchmen

(which could be fun just to watch them /cough die a lot /cough )

but unfortunately neither seems suitable (as is) for an PC->NPC cameo appearance,

Ok, kevL_s. I’ll guess we try and see where it goes…
The database files seem small so maybe it’s no biggie that they end up on a persons computer.

A few questions then: Where do I begin and with what? Do I write a script? Do I download Universal Companion Database?

well, okay, normally the PC will be exported to a database in Part 1 … except that’d be a HUGE hassle to test, so I suggest we try setting this up (both the export and the import) in Part 3 – which i assume you’re working on at present?

first thing is to choose a name for your unique database. Something that a person has a chance of recognizing if they browse into their /database folder … like “andgalf” or “<my_story_arc>” … “thetempest” for example, or “andgalf_tempest”.

(32-chars Max, alphanumeric or underscores only i suggest (strongly suggest))

Universal Companions has a bunch of stuff we don’t need. So, do it from scratch.

Let’s say you’re working in Part 3 at the point you’re ready for the cameo to start. Let’s rig up some temporary way to export the current PC (and use that same PC to star in the cameo … yes, a doppleganger, but only for now).

So, uh, i don’t know it’s your preference: place a trigger to run the PC-export script, or use the OnAreaEnter event, or whatever you choose. It’s just a temporary thing(!)

then try these …

The EXPORT script

// 'db_exportpc'

const string DATABASE = "andgalf";
const string CAMEO = "pcpart3cameo";

void main()
    object oPC = GetFirstPC(TRUE); // get owned character
    SendMessageToPC(GetFirstPC(FALSE), "Export " + GetName(oPC));

    int bSuccess = StoreCampaignObject(DATABASE, CAMEO, oPC);
    if (!bSuccess) SendMessageToPC(GetFirstPC(FALSE), ". failed");

The IMPORT function (set up another trigger and call this in its OnEnter script, or include it as a function in the script above and call it at the end of main())

const string DATABASE = "andgalf";
const string CAMEO = "pcpart3cameo";

object db_GetCameoChar()
    SendMessageToPC(GetFirstPC(FALSE), "Import cameo character");
    location lWP = GetLocation(GetWaypointByTag("wp_cameochar")); // <- CHANGE as req'd.

    object oCameoChar = RetrieveCampaignObject(DATABASE, CAMEO, lWP);

    if (GetIsObjectValid(oCameoChar))
        SendMessageToPC(GetFirstPC(FALSE), ". success");

        SetScriptHidden(oCameoChar, TRUE); // prevent a fade-in/fade-out quickie.

        ChangeToStandardFaction(oCameoChar, STANDARD_FACTION_COMMONER); // <- change as you like.
        SetCreatureScriptsToSet(oCameoChar, SCRIPTSET_NPC_DEFAULT);     // <- give it default AI.

        SetPlotFlag(oCameoChar, FALSE);
        SetImmortal(oCameoChar, FALSE);
        AssignCommand(oCameoChar, SetIsDestroyable(TRUE, FALSE, FALSE));

        // anything else?

        SetFirstName(oCameoChar, GetFirstName(oCameoChar) + " dopple"); // <- just to distinguish it from the TruePC

        DelayCommand(0.f, SetScriptHidden(oCameoChar, FALSE));

        return oCameoChar;
    return OBJECT_INVALID;
1 Like

Really nice kevL_s! I tested your scripts and they worked splendidly! At first I didn’t realize that your import script was just a function (even though you clearly stated this in your post), so I added the void main and called the function and everything worked.

Now that I know it works I’ll see if I can implement this eventually. I’m not there in the module (part 3) I’m working on now by a long shot, it was just an idea I had that I might use later on in the story.

Thanks for all the time you put into this and for teaching me!

1 Like