Jike

[K1] Issues with ending quests and awarding XP

Recommended Posts

Much like the title suggests, I'm having issues with creating a script that's capable of both ending an active quest and awarding the PC some XP as a result.

 

I've been using the two following lines of code to try to achieve this:

//Using this line to end the quest by removing it from the journal.
RemoveJournalQuestEntry(tat_IzizCaptive);

//Using this line to award XP to oPC
GiveXPToCreature(oPC, 250);

However, when compiling so I can take it for a test run, compiling ends as it runs into syntax errors such as "Undeclared identifier 'tat_IzizCaptive' or 'oPC'" in the script. I've never done a script for this before so evidently I'm doing something wrong here I just can't quite figure out what. To be completely fair I likely inputted the quest name incorrectly as I'm unable to find the journal entry name. I have JRL Editor but that won't run even with all the DLLs present.

EDIT: I realised I need to define the oPC identifier with "object oPC = GetFirstPC();" so I've solved that issue. It's mainly just the quest ending and whatnot that's the main issue now. I know I need to create an identifier for the string a string to identify the quest using "GetJournalEntry" but I'm not entirely sure how.

Share this post


Link to post
Share on other sites

Your problems are straightforward. In the first instance, you haven't declared the variables properly. Per nwscript.nss:

void RemoveJournalQuestEntry(string szPlotID);

Since the plot ID is a string it must be inside double quotes, like so:

RemoveJournalQuestEntry("tat_IzizCaptive");

Note that this function removes the quest, as stated - i.e. deletes it entirely. Typically you will want to advance a quest to a closed stage, assuming one is available, so that it is still viewable by the player in the completed quests tab. You can do that with:

void AddJournalQuestEntry(string szPlotID, int nState, int bAllowOverrideHigher=FALSE);

Where you state the state number you want. The final TRUE/FALSE variable allows you to override a high numbered plot state (e.g. 90) with a lower number one (i.e. 20) if that is required. Typically it's not needed, but there are a handful of vanilla quests that have low numbered end states. If you are making your own custom quests, as seems to be the case here given the plot ID, then you can avoid that being a problem by using incrementing state numbers with the ending/s using the highest value/s.

If instead you are trying to deal with the vanilla quest, its plot ID is tat17aa_jawarescue (all the quests are found in global.jrl). Also note that quest states can be set directly via a DLG, as is the case here when talking to the Jawa you free in the Sandpeople Enclave.

For the second instance, as the compiler error stated, you have an undeclared variable, oPC. You either need to declare it in your script, like so:

object oPC = GetFirstPC();

Or simply change your existing line to:

GiveXPToCreature(GetFirstPC(), 250);
  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the information, that makes a lot more sense than what I was trying previously.

9 minutes ago, DarthParametric said:

If instead you are trying to deal with the vanilla quest, its plot ID is tat17aa_jawarescue (all the quests are found in global.jrl).

This in particular is very useful info, however I can't access the contents of global.jrl as my JRL Editor just crashes as soon as I try to launch it.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.