Author Topic: Campaign Database  (Read 673 times)

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Campaign Database
« on: April 14, 2012, 01:24:48 pm »


               Hello all:

I have seen bits here and there about the campaign database. From what I understand, it is used to store any information that needs to follow the PC from one module to the next, such as henchmen, journal entries, variables, etc. I cannot seem to find any solid information on the campaign database, however.

Do you all use the campaign database? If so, can you point me to some good information on it? If not, do you mind telling me how you accomplish moving the PC from one module to the next with all needed information intact?

Thanks!
               
               

               
            

Legacy_SHOVA

  • Hero Member
  • *****
  • Posts: 893
  • Karma: +0/-0
Campaign Database
« Reply #1 on: April 14, 2012, 02:51:34 pm »


               I use the database all the time. It is most usefull for making sure something only happens once, even if the module is reset.
the following script snip its are what i use, though there may be better writen code out there.

First to check if the database has been set:
#include "nw_i0_tool"

int StartingConditional()
{

   // Make sure the PC speaker has these items in their inventory
   if(GetCampaignInt("NAMEOFDATA","whattocheckfor",GetPCSpeaker()) == 84001)
       return TRUE;

   return FALSE;

And to set the database:
#include "nw_i0_tool"
void main()
{

object oPC = GetPCSpeaker();


SetCampaignInt("NAMEOFDATA","whattocheckfor",84001,oPC);
}

Enter what you want for "whattocheckfor" it could be done this, or read that.
Enter a database name in all caps for "NAMEOFDATA"

The examples I gave are done/used from a conversation, though you could have  the database checked for on enter, or other events, but on exit tends to not work right.

Good luck!
               
               

               
            

Legacy_Melkior_King

  • Full Member
  • ***
  • Posts: 234
  • Karma: +0/-0
Campaign Database
« Reply #2 on: April 14, 2012, 03:21:05 pm »


               Just some general information from me.  Deleting something from a database doesn't actually remove it.  The entry is just marked as unused and that storage space never gets re-used.

If you keep on deleting and adding items in a database, it can quickly grow out of control.

To get around this, you need to periodically delete the entire database and re-write it.  Unless you have somehing which plugs in to nwnx2 or similar and can compact the database for you.  I don't so I use the first method.  It works, but you do need to be careful about what you're deleting.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Campaign Database
« Reply #3 on: April 14, 2012, 03:45:52 pm »


                I think a better method for attaching data to a character that you wish to follow from module to module, is to use PC Properties AKA PC Skin.
In order to keep the database bloat problem under control, and because I like to divide data into relevant "tables", I typically restrict a campaign database to a "campaign". 
For character specific data that I will access in different campaigns I use PC Skin.

Check the links for more information. The Lexicon is your friend.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Campaign Database
« Reply #4 on: April 14, 2012, 03:51:05 pm »


               

UnrealJedi wrote...

Hello all:

I have seen bits here and there about the campaign database. From what I understand, it is used to store any information that needs to follow the PC from one module to the next, such as henchmen, journal entries, variables, etc. I cannot seem to find any solid information on the campaign database, however.

Do you all use the campaign database? If so, can you point me to some good information on it? If not, do you mind telling me how you accomplish moving the PC from one module to the next with all needed information intact?

Thanks!


First it sounds like you have a major misunderstanding, From what you posted it sondls like you think that the information is already in a DB for you.  That is totaly untrue.  Anything in the DB has to be placed there by the builder. It is up to the builder to decide what information he needs placed into the DB for the next/current module and put it there for the next/current module to use.

The database functions are listed in the lexicon under Database (22)
There is also a tutorial in the lexcon: Introduction To Databases
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Campaign Database
« Reply #5 on: April 14, 2012, 03:59:43 pm »


               

Melkior_King wrote...

Just some general information from me. Deleting something from a database doesn't actually remove it. The entry is just marked as unused and that storage space never gets re-used.

If you keep on deleting and adding items in a database, it can quickly grow out of control.

To get around this, you need to periodically delete the entire database and re-write it. Unless you have somehing which plugs in to nwnx2 or similar and can compact the database for you. I don't so I use the first method. It works, but you do need to be careful about what you're deleting.


Boiware did provide a program to compress the database  and remove the unused entries.  it is located:    %NWNInstallPath%\\utils\\DataPack.exe

 
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Campaign Database
« Reply #6 on: April 15, 2012, 12:59:45 am »


               Thanks all, for the replies and links. Lightfoot8...nope, I understand that the specific information has to be placed by the builder. I've just never used the database so I had no clue as to what it was for.

I think it might have helped if I had stated in my original post that my module is single player, not a PW. I am not sure if that was intuitively understood and wanted to clarify just in case.

Thanks again, all!
               
               

               
            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Campaign Database
« Reply #7 on: March 18, 2013, 12:15:05 am »


               Hello NWN community,
I am coming back to this topic after a few months away. I have learned how to apply variables to a campaign database so that conversations can logically continue from one module to the next.
Here is a sample of a script I am using to do this:

void main(){    // Set the variables    SetLocalInt(GetPCSpeaker(), "thorgrimopinesshal", 1);
// 10.12.12 Added campaign database variable so PC can continue interacting with Shal in future modules
    object oPC = GetPCSpeaker();    SetLocalInt(oPC,"campaignshal",1);    SetCampaignInt("RedemptionCampaign","campaignshal",1,oPC);}

I am still puzzling out how to retrieve the various variables from the campaign database and apply them to the PC when he/she starts the next module. I found an entry on the NWN Wiki that gives this script:

void main(){    object oPC = GetEnteringObject();    if(!GetIsPC(oPC))return;    int i,iQuest;    for(i=1; i<6; i++)        {        iQuest = GetCampaignInt("QUEST_STATUS","QUEST_"+IntToString(i),oPC);        SetLocalInt(oPC,"QUEST_"+IntToString(i),iQuest);        }}
This is a bit over my head. It would appear that the author (apologies, I didn't see an author's name) is using variables that follow the format QUEST_1, QUEST_2, QUEST_3 and so on, and then can retrieve all of the variables by only using QUEST_. I am not familiar at all with strings so perhaps that is limiting my understanding.

The variables I am using all follow a format like my script above..."campaignshal", "campaignlionel", and so on.

If someone can get me started on a script that will go in the OnClientEnter of my 2nd module I will finish the script out. I just need some pointers on how to get started.

Thanks in advance for the help!


EDIT: Apologies for the way the scripts are spacing. I tried to correct to no avail.
               
               

               


                     Modifié par UnrealJedi, 18 mars 2013 - 12:18 .
                     
                  


            

Legacy_Highv Priest

  • Full Member
  • ***
  • Posts: 170
  • Karma: +0/-0
Campaign Database
« Reply #8 on: March 22, 2013, 01:28:56 am »


               

Lightfoot8 wrote...

Melkior_King wrote...

Just some general information from me. Deleting something from a database doesn't actually remove it. The entry is just marked as unused and that storage space never gets re-used.

If you keep on deleting and adding items in a database, it can quickly grow out of control.

To get around this, you need to periodically delete the entire database and re-write it. Unless you have somehing which plugs in to nwnx2 or similar and can compact the database for you. I don't so I use the first method. It works, but you do need to be careful about what you're deleting.


Boiware did provide a program to compress the database  and remove the unused entries.  it is located:    %NWNInstallPath%utilsDataPack.exe

 


This is actually really fascinating and I have no idea what clcompile.exe or debugserver.exe do lol, do you happen to know?
               
               

               
            

Legacy_simomate2

  • Full Member
  • ***
  • Posts: 133
  • Karma: +0/-0
Campaign Database
« Reply #9 on: March 22, 2013, 07:39:38 am »


               

Lightfoot8 wrote...

UnrealJedi wrote...

Hello all:

I have seen bits here and there about the campaign database. From what I understand, it is used to store any information that needs to follow the PC from one module to the next, such as henchmen, journal entries, variables, etc. I cannot seem to find any solid information on the campaign database, however.

Do you all use the campaign database? If so, can you point me to some good information on it? If not, do you mind telling me how you accomplish moving the PC from one module to the next with all needed information intact?

Thanks!


First it sounds like you have a major misunderstanding, From what you posted it sondls like you think that the information is already in a DB for you.  That is totaly untrue.  Anything in the DB has to be placed there by the builder. It is up to the builder to decide what information he needs placed into the DB for the next/current module and put it there for the next/current module to use.

The database functions are listed in the lexicon under Database (22)
There is also a tutorial in the lexcon: Introduction To Databases


 Bottom Link leads an empty page. 

Oh, wait this post was 11 months ago! 
               
               

               


                     Modifié par simomate2, 22 mars 2013 - 07:40 .
                     
                  


            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
Campaign Database
« Reply #10 on: March 22, 2013, 11:10:00 am »


               The introduction to databases tutorial is included in the downloadable version of the 1.69 lexicon on the vault. 

TR
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Campaign Database
« Reply #11 on: March 22, 2013, 04:35:18 pm »


               Or you could go to the current lexicon to get that intro to databases.

I like how the NWN community has this level of redundancy. Many places to get stuff, and so if something fails we can keep going.