Author Topic: NPCs remember PC from first module to second module  (Read 316 times)

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
NPCs remember PC from first module to second module
« on: June 23, 2013, 09:01:19 pm »


               Okay, I have asked this question before but I think I wasn't very clear on what I was looking for, so I am trying again.

Here's the situation: NPC gives PC a quest that cannot be completed in the first module, but still has bearing on events in the first module. The PC completes the first module and the second one starts. The PC visits the NPC who gave him the quest. This particular NPC remembers that they gave the PC the quest and says "Hey, what gives? I gave you a quest in the first module. It's now the second module. Why haven't you completed it yet?"

 I would like to accomplish this using varivables, and not items. I feel I would have greater control with variables and would not have to worry about the PC dropping the item and then he/she is just screwed.

I know that this is doable using the campaign database. Since I am not that proficient in scripting and really do not have the time to learn I would like to shamelessly (with permission) rip off someone else's work. I know this means someone has done all of the work and I get to reap the benefits from it but I am hoping someone will have mercy on me.

Thanks guys.
               
               

               


                     Modifié par UnrealJedi, 23 juin 2013 - 08:02 .
                     
                  


            

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
NPCs remember PC from first module to second module
« Reply #1 on: June 23, 2013, 11:21:19 pm »


               The logic will be that the NPC always checks a variable on the PC giving the illusion that it remembers.  For example. When oPC finishes a quest, the Quest Giver will (when giving the reward) will add a variable to an object on the player (I use a player book that is given to every player when they enter and gives info about the server etc). It will look something like this.

int QuestNumber = 2679;
SetLocalInt(oPCItem, QuestNumber, 1);

Then during the next conversation, the NPC will check if QuestNumber is = 1, and if it is, it will not offer the quest.

You can store information on the player directly, but that variable will not (or isn't reliable) to roll over to a new build or new module.

GetLocal and SetLocal are wicked fun/powerful and really helps slim down the number of scripts in the module.

Hope that helps get you in the right direction.

*Edit* Sorry, I didn't get to the part about you not desiring to learn the scripting, so not sure if the above will do you any good.
               
               

               


                     Modifié par Buddywarrior, 23 juin 2013 - 10:23 .
                     
                  


            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
NPCs remember PC from first module to second module
« Reply #2 on: June 26, 2013, 03:46:02 am »


               SetCampaignInt and GetCampaignInt will store a variable to a database file on the player's local \\Database directory with the desired name you give it.

It's good to clear the database at the start of your first module, in the event the player replays it, so particular quests like these aren't stored from a previous play through.

For checking in the second module from the NPC via a conversation, you'd use something like this -

int StartingConditional()
{

   // Inspect local variables
   if(!(GetCampaignInt("Database_Name_here", "variable_stored_name_here") == 25))
       return FALSE;

   return TRUE;
}


So if the variable you've set in your first module, read from the database file it created, is equal to 25 - meaning they took the quest and advanced it - the NPC in the second module will know this and can react accordingly.

In your first module, you'll want to store the variable at the last stage of the uncompleted quest to the database file at the very end of the module (* see below for an explination as to why*) -

SetCampaignInt("Database_Name_here", "variable_stored_name_here", 25);


That's pretty much it.

A word of note as well. Only save the variable to the database at the very end of your module. If you store the variable to the database when the quest has reached its end in the first module before the player is finished the module, and they suddenly decide to reload a saved game for whatever reason, and then not bother with said quest, the variable in the database will be stored as if they HAD completed the quest and HAD NOT reloaded.

I suggest storing and checking a local variable set on the PC or the MODULE for the quest, then at the end of your module, before you load up the second module for the player, it checks the stored variable for a match. If it matches, you save it to the database.

if (GetLocalInt(GetModule(), "quest_variable_here") == 25)
{
SetCampaignInt("Database_Name_here", "variable_stored_name_here", 25);
}


Here's a detailed example.

Our quest takes the player along to a few places, killing and finding a few things. This quest we'll name "wander_q" and will be the variable name used to advance this quest through each stage.

SetLocalInt(GetModule(), "wander_q", 5);


The player has accepted the quest and the variable is updated to 5.

Slashing, dashing, cutting and slicing their way along, the quest in the first module comes to an end, due to the next location the player has to travel being in the second module, and the variable is finally updated to reflect that.

SetLocalInt(GetModule(), "wander_q", 25);


So far, the "wander_q" variable is only being stored to the MODULE.

Another four hours of game time pass and the player completes the first module, arriving or speaking with an NPC. It is here the particular quest variable is checked and stored to the DATABASE.

if (GetLocalInt(GetModule(), "wander_q") == 25)
{
SetCampaignInt("UnrealJ", "wander_q", 25);
}


FP!
               
               

               


                     Modifié par Fester Pot, 26 juin 2013 - 02:55 .
                     
                  


            

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
NPCs remember PC from first module to second module
« Reply #3 on: June 28, 2013, 10:22:18 pm »


               FP, this is the CLEAREST explanation of how to use the campaign database that I have seen so far.

Do you know of any links to online articles (e.g. the Lexicon) that give other details about the campaign database? I have seen some posted but they appear to be broken.

Thanks again!