Author Topic: making quests persistent?  (Read 536 times)

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
making quests persistent?
« on: September 02, 2015, 11:13:48 am »


               

Okay would appreciate some help with making quests persistant....probably a very simple procedure but somehow I have not figured it out :S


 


okay I am using the Persistant Quest & Journal http://neverwinterva...quests-journalsscript and  would like to see it implemented on the quests in my module.


 


So basically I need to add a line or something according to the script but when I do it is no longer working so anyone tell me what I am doing wrong here?


 


So thjis is the script that starts 1 of the quests: 


 




#include "nw_i0_plotwizard"

#include "pqj_inc"

 

void main()

{

    SetLocalInt(OBJECT_SELF, "p000began", 1);

    PWSetMinLocalIntPartyPCSpeaker("p000state_Dela", 1);

    PWSetMinLocalIntPartyPCSpeaker("p000state", 1);

}

 



 



 


 


Checks for item to finish:


 




int StartingConditional()

{

    int nShow = OBJECT_INVALID != GetItemPossessedBy(GetPCSpeaker(), "VillainHead");

    return nShow;

}

 



 



 


To finish


 




#include "nw_i0_plotwizard"

void main()

{

    object oItemToTake = GetItemPossessedBy(GetPCSpeaker(), "VillainHead");

    DestroyObject(oItemToTake);

    GiveGoldToCreature(GetPCSpeaker(), 150);

    PWSetMinLocalIntPartyPCSpeaker("p000state_Dela", 3);

    PWSetMinLocalIntPartyPCSpeaker("p000state", 3);

    PWGiveExperienceParty(GetPCSpeaker(), 200);

}

 

 



 



 




it works like this:

 

   you prepare your journal in the toolbox, assigning proper tags/ids, then you normally use

   AddJournalQuestEntry() and RemoveJournalQuestEntry() to manage them via scripting.

 

   now, you just have to use AddPersistentJournalQuestEntry() and RemovePersistentJournalQuestEntry()

   with exact the same parameters (bAllPlayer, bAllPartyMembers and bAllowOverrideHigher still work like

   in the original bioware functions).  this means no restrictions, it's fully transparent.

 

   now add the following line of code to your Module OnClientEnter script (don't forget to include this script):

      RebuildJournalQuestEntries(GetEnteringObject());

 

   that's all, now you have a persistent journal... you can basically use CTRL-R to find/replace the

   original functions with the persistent ones and add the OnClientEnter code.

 

   furthermore, you can use RetrieveQuestState() to get the current state of a

   quest for the specified player/quest-tag. this means you can manage your conversations with

   this function and control quest-flow. you won't need to store additional LocalInts somewhere, just

   use the DB information.

 

 



 



not entirely sure where to put what where so if anyone can help me that would be grant! '<img'> 



               
               

               
            

Legacy_lluewhyn

  • Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
making quests persistent?
« Reply #1 on: September 03, 2015, 01:47:11 am »


               

Here's an example of one of the quests from my module. It loops through the party, giving them the reward, and adds the journal entry. I then have to tweak the OnClientEnter to give them the journal again if they don't already have it. It looks like your text above is suggesting to have a separate script that fires from the OnClientEnter. That way, the quest state and journal entry will always exist, even if the module reloads.


 


Basically, I have an undroppable item in the PC's inventory that stores all quest states. Some of the script below is using optional checks to increase their rewards based upon successful Persuasion and Intimidate checks as well (rolls 1d20, adds Persuasion & Intimidate, and yes I know Charisma is counted twice). You could get rid of this section, but look at the rest of my logic:



//::///////////////////////////////////////////////
//:: FileName weznor_reward
//:://////////////////////////////////////////////
//:://////////////////////////////////////////////
//:: Created By: Script Wizard
//:: Created On: 6/29/2002 1:00:21 PM
//:://////////////////////////////////////////////
#include "nw_i0_tool"
#include "nw_o2_coninclude"
#include "color"
void main()
{
    object oPC = GetPCSpeaker();
    int nPersuade = d20(1) +GetSkillRank(SKILL_PERSUADE, oPC);
    int nIntimidate =GetSkillRank(SKILL_INTIMIDATE, oPC);
    int nPersuasion = nPersuade+nIntimidate;
    string sPersuasion =IntToString(nPersuasion);
    AssignCommand(oPC, SpeakString(ColorString("Persuade & Intimidate: Rolled a "+sPersuasion, 210, 105, 30)));

    // Give the Party some gold
    object oParty =GetFirstFactionMember(oPC);
    while (GetIsObjectValid(oParty) == TRUE)
        {
        object oQuestLog =GetItemPossessedBy(oParty,"APTS_TOKBOX_NODD");
        if(GetLocalInt(oQuestLog, "Weznor_Done") !=1)
            {
            SetLocalInt(oQuestLog,"Weznor_Done",1);
            GiveGoldToCreature(oParty, 5000);
            GiveXPToCreature(oParty, 2500);
            CreateItemOnObject("baneofthedead", oParty);
            AddJournalQuestEntry("Weznor_Done", 1, oParty, FALSE, FALSE, FALSE);

            //Random Treasure based upon Persuasion & Intimidate
            if (nPersuasion > 30)
                {
                GenerateHighTreasure(oParty, oParty);
                GenerateHighTreasure(oParty, oParty);
                GenerateHighTreasure(oParty, oParty);
                GenerateHighTreasure(oParty, oParty);
                GenerateHighTreasure(oParty, oParty);
                }

            if ( nPersuasion > 25 & nPersuasion <31)
                {
                GenerateHighTreasure(oParty, oParty);
                GenerateHighTreasure(oParty, oParty);
                GenerateHighTreasure(oParty, oParty);
                GenerateHighTreasure(oParty, oParty);
                }

            if (nPersuasion > 18 & nPersuasion <26)
                {
                GenerateHighTreasure(oParty, oParty);
                GenerateHighTreasure(oParty, oParty);
                GenerateHighTreasure(oParty, oParty);
                }

            if (nPersuasion > 12 & nPersuasion <19)
                {
                GenerateHighTreasure(oParty, oParty);
                GenerateHighTreasure(oParty, oParty);
                }

            if (nPersuasion > 8 & nPersuasion <13)
                {
                GenerateHighTreasure(oParty, oParty);
                }

            oParty = GetNextFactionMember(oPC);
            }
        else
        oParty = GetNextFactionMember(oPC);
        }
    // Remove items from the player's inventory
    object oItemToTake;
    oItemToTake = GetItemPossessedBy(oPC, "WeznorNote");
    if(GetIsObjectValid(oItemToTake) != 0)
        DestroyObject(oItemToTake);
}


               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
making quests persistent?
« Reply #2 on: September 04, 2015, 01:36:05 pm »


               Thanks lluewhyn, though it still does not really explain me how to work the pqj system into the module to make it persistent, I did what was written above but for some reason the quest does not appear persistent
               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
making quests persistent?
« Reply #3 on: September 04, 2015, 01:36:53 pm »


               So figured I did something wrong with the implementation hence why I am asking and posted the original code for the quest on here.
               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
making quests persistent?
« Reply #4 on: September 04, 2015, 02:46:07 pm »


               

You're not using things like AddJournalQuestEntry() in your code which is what PQJ is a wrapper for.  I'd guess you are using the built in conversation mechanism to set journal states exclusively.  In that case you need to remove that and set the journal entry in the action taken scripts of your conversations explicitly (e.g. the scripts you show to start and end the quest).  Then replace them with the PQJ wrappers for the same function.


 


if you are tracking all your quest states with your own variables then you'll need to either set those persistently from the get go, or setup a mechanism (periodically or on client leave) to save all the variables to persistence, and then restore them on client enter.


               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
making quests persistent?
« Reply #5 on: September 04, 2015, 03:21:52 pm »


               


You're not using things like AddJournalQuestEntry() in your code which is what PQJ is a wrapper for.  I'd guess you are using the built in conversation mechanism to set journal states exclusively.  In that case you need to remove that and set the journal entry in the action taken scripts of your conversations explicitly (e.g. the scripts you show to start and end the quest).  Then replace them with the PQJ wrappers for the same function.


 


if you are tracking all your quest states with your own variables then you'll need to either set those persistently from the get go, or setup a mechanism (periodically or on client leave) to save all the variables to persistence, and then restore them on client enter.




I am using the quest/plotline wizard to create my quests.


 


okay so if I understand the scripts such as: 


 




#include "nw_i0_plotwizard"

#include "pqj_inc"

 

void main()

{

    SetLocalInt(OBJECT_SELF, "p000began", 1);

    PWSetMinLocalIntPartyPCSpeaker("p000state_Dela", 1);

    PWSetMinLocalIntPartyPCSpeaker("p000state", 1);

}

 

 



 



replace them with: 


 


 




#include "nw_i0_plotwizard"

#include "pqj_inc"

 

void main()

{

AddPersistantJournalQuestEntry( "p000began", 1);

}

 

 



?




 

 

if I do I get this however: 
 


 


4-9-2015 16:20:59: Error. 'p000q001_action' did not compile.

p000q001_action.nss(6): ERROR: UNDEFINED IDENTIFIER (SAddPersistentJournalQuestEntry)


 



 



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
making quests persistent?
« Reply #6 on: September 04, 2015, 03:57:08 pm »


               

I've never used the plotwizard.   But no... you probably don't want to remove the existing code. Just add to it and clear the journal entry section of the conversation node.   Also note that "p000began" is a variable name not the tag of the journal entry (although it could be the same I suppose). That parameter to AddPersistantJournalQuestEntry is the tag of the quest as defined in the journal editor.


 


Also, I was totally serious about converting it to use regular AddJournalQuestEntry first and getting that working in game. Then change it to PQJ. I think you need to walk before you can run...


 


The error you show is not from the code you posted.  The error is complaining about  "SAddPersistentJournalQuestEntry", which is not in the script you posted. One of your scripts has a typo, note the leading "S".


               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
making quests persistent?
« Reply #7 on: September 04, 2015, 10:48:43 pm »


               


I've never used the plotwizard.   But no... you probably don't want to remove the existing code. Just add to it and clear the journal entry section of the conversation node.   Also note that "p000began" is a variable name not the tag of the journal entry (although it could be the same I suppose). That parameter to AddPersistantJournalQuestEntry is the tag of the quest as defined in the journal editor.


Also, I was totally serious about converting it to use regular AddJournalQuestEntry first and getting that working in game. Then change it to PQJ. I think you need to walk before you can run...


The error you show is not from the code you posted.  The error is complaining about  "SAddPersistentJournalQuestEntry", which is not in the script you posted. One of your scripts has a typo, note the leading "S".




I did adjust that later on and it didnt really change that much, will try to get the quest working manually. However the tutorial i found on the lexicon did not cover the entire thing since in my opinion it changed since it made me insert something that was not there in the first place but will see about getting it done '<img'>