Foregone_Conclusion wrote...
So I'm having a bit of trouble understanding the IF functions and just exactly what can be done with them. Right now I was trying to come up with a template for doing quests and journal entries, AND conversation options all at the same time.
But I don't even know where to start on something like this. Any advice?
Just about everything can be done with the If statment.
The First part is Probably learning what Kinds of Events exsist in the game and where you can store data at. Then writting your script often becomes as simple as saying what you want to happen. and then writting out exactly that.
example:
lets say you want a Quest that has three states.
- getting the Quest.
- fulfilling the Task.
- and Reporting back for Rewards.
that looks like you can just simply assign a number to each of the states to simply track them and place that number on the PC. To make it more human readable we can give each State a Name (label) that will be constant, something like.
const int QUEST_STARTED =1;
const int QUEST_TASK_DONE=2;
const int QUEST_FINISHED=3;
when we start out with the PC having done nothing the Quest State will not yet be defined therefore its value will be 0.
So lets add that in there as well.
const int QUEST_NOT_STARTED=0;
Hmm, we also need a name for the place we are going to Store the data, so we can find it again. Lets just call it Quest1. We will use this name for the local integer that we place on the PC to track the state of the quest.
Now, what do we want to happen. When the PC talks to the NPC we want him to Give him the Option to start the Quest. This sounds like we need a starting condition for the 'Text appears When' node for the concersation. So we know where. Now when do we want this to appear.
if the quest has not yet started then Ask the PC if he want to do the quest, If not Don't ask dont tell.
if (QuestState== QUEST_NOT_STARTED) return TRUE else return FALSE;
hmm That look good to me we just need to fill in the stuff we missed, like fetching the Quest state from where we have it stored, and making it into a starting condition. so we end up with.
const int QUEST_NOT_STARTED=0;
const int QUEST_STARTED =1;
const int QUEST_TASK_DONE=2;
const int QUEST_FINISHED=3;
int StartingConditional()
{
//Define the PC, so we can get the state off of him.
object oPC GetPCSpeaker();
// Get the current quest state from the PC.
int QuestState = GetLocalInt(oPC,"Quest1");
//Do what we said we want to do.
if (QuestState== QUEST_NOT_STARTED) return TRUE else return FALSE;
}
It would not hurt at this point to think ahead a little bit. It looks like we are going to be using thies states quite a bit. So we can move them off into an include file that we can just add to our scripts as we need them. we will call this file inc_queststates. While we are at it, It also looks like we are gong to be retriving the quest state from the PC quite a bit. So let add a function to our include to get the Quest State from the PC and make Our Script even more Human readable. with this we end up with.
////File Inc_QuestStates////////
const int QUEST_NOT_STARTED=0;
const int QUEST_STARTED =1;
const int QUEST_TASK_DONE=2;
const int QUEST_FINISHED=3;
// This is just a wraper around the GetLocalInt To amke it more readable.
int GetQuestStateFromPC(object oPC, string sQuest)
{
return GetLocalInt(oPC, sQuest)
}
With all that moved into our new include our script can now look like this.
#include "inc_queststates"
int StartingConditional()
{
//Define the PC, so we can get the state off of him.
object oPC GetPCSpeaker();
// Get the current quest state from the PC.
int QuestState = GetQuestStateFromPC(oPC,"Quest1");
//Do what we said we want to do.
if (QuestState== QUEST_NOT_STARTED) return TRUE else return FALSE;
}
Ok so we have our script for when the text is to appear to give the PC to option to start the quest. Now if he selects that option. What do we want to happen. Hmm Besides giving him more instructions in the Dialogue we just want to change the state of the quest. hmm, It would be really nice if that include also had a function to change the quest states, Sounds like that is going to happen a lot also. So lets add it to the include first.
So now our include file looks like this:
////File Inc_QuestStates////////
const int QUEST_NOT_STARTED=0;
const int QUEST_STARTED =1;
const int QUEST_TASK_DONE=2;
const int QUEST_FINISHED=3;
// This is just a wraper around the GetLocalInt To amke it more readable.
int GetQuestStateFromPC(object oPC, string sQuest)
{
return GetLocalInt(oPC, sQuest)
}
//Update the Quest state on the PC; again Just a wrapper.
int SetQuestStateOnPC(object oPC, string sQuest, int sState )
{
SetLocalInt(oPC,sQuest, sState);
}
With That in Place your action taken Script looks like this.
#include "inc_queststates"
void main()
{
object oPC = GetPCSpeaker();
SetQuestStateOnPC( oPC, "Quest1", QUEST_STARTED);
}
That is roughly what goes through my mind when i am building a quest. Righ not I am running short on time. Hope that helps to get you started.
Modifié par Lightfoot8, 23 janvier 2012 - 03:37 .