| Author |
Sticky: Post
Working Scripts Here |
| thadeus
|
Posted: Monday, 29 July 06:05PM |
1. Name: include_questing
2. What it does:
This include file makes designing quests easier.
3. Notes:
When you want to remember a certain point in the quest, you have to set
a variable to a certain value so that you can check it later. If you
want to set the journal to an entry that corresponds to the state of the
quest, you have to do it manually. Giving out questxp has to be done by
getting the xp associated by the quest and then giving it out.
I've made a number of functions that can be used to set the state of a
quest along with the journal entry. When you complete a quest, you can
choose the journal entry to be used and the xp associated with the quest
will be handed out. I've also made a number of functions to check the
state of a quest (assigned, unassigned, completed or a specific state).
Before you can use these functions, you must use a certain naming
convention for quests and journal categories. A quest is identified with
his quest_id (a string like "undead") while the corresponding journal
category must have the name JOURNAL_ + quest_id.
This is nothing fancy, but it'll make the life of a designer a bit
easier. I've added a lot of comment in the beginning of the file to
explain this.
4. The file itself:
NWScript:
int QUEST_UNASSIGNED = 0;
int QUEST_COMPLETED = 1000;
int GetQuestState(string QUEST_ID);
int GetQuestAssigned(string QUEST_ID);
int GetQuestUnassigned(string QUEST_ID);
int GetQuestCompleted(string QUEST_ID);
void GiveQuestXP(object oPlayer, string QUEST_ID);
void SetQuestState(object oPlayer, int QUEST_STATE, string QUEST_ID);
void SetQuestNextState(object oPlayer, string QUEST_ID);
void SetQuestCompleted(object oPlayer, int JOURNAL_NUMBER, string QUEST_ID);
int GetQuestState(string QUEST_ID)
{
string QUEST_STRING = "QUEST_" + QUEST_ID;
return (GetLocalInt(GetModule(),QUEST_STRING));
}
int GetQuestAssigned(string QUEST_ID)
{
int CURRENT_STATE = GetQuestState(QUEST_ID);
if ((CURRENT_STATE == QUEST_UNASSIGNED) || (CURRENT_STATE == QUEST_COMPLETED))
{
return FALSE;
}
return TRUE;
}
int GetQuestUnassigned(string QUEST_ID)
{
int CURRENT_STATE = GetQuestState(QUEST_ID);
if (CURRENT_STATE != QUEST_UNASSIGNED)
{
return FALSE;
}
return TRUE;
}
int GetQuestCompleted(string QUEST_ID)
{
int CURRENT_STATE = GetQuestState(QUEST_ID);
if (CURRENT_STATE != QUEST_COMPLETED)
{
return FALSE;
}
return TRUE;
}
void GiveQuestXP(object oPlayer, string QUEST_ID)
{
string JOURNAL_STRING = "JOURNAL_" + QUEST_ID;
int QUEST_XP = GetJournalQuestExperience(JOURNAL_STRING);
GiveXPToCreature(oPlayer,QUEST_XP);
}
void SetQuestState(object oPlayer, int QUEST_STATE, string QUEST_ID)
{
string QUEST_STRING = "QUEST_" + QUEST_ID;
string JOURNAL_STRING = "JOURNAL_" + QUEST_ID;
int CURRENT_QUEST_STATE = GetQuestState(QUEST_ID);
if (!(GetQuestCompleted(QUEST_ID)) && !(CURRENT_QUEST_STATE >= QUEST_STATE))
{
SetLocalInt(GetModule(),QUEST_STRING,QUEST_STATE);
AddJournalQuestEntry(JOURNAL_STRING,QUEST_STATE,oPlayer);
}
}
void SetQuestNextState(object oPlayer, string QUEST_ID)
{
string QUEST_STRING = "QUEST_" + QUEST_ID;
string JOURNAL_STRING = "JOURNAL_" + QUEST_ID;
if (!(GetQuestCompleted(QUEST_ID)))
{
int QUEST_STATE = GetLocalInt(GetModule(),QUEST_STRING);
QUEST_STATE++;
SetLocalInt(GetModule(),QUEST_STRING,QUEST_STATE);
AddJournalQuestEntry(JOURNAL_STRING,QUEST_STATE,oPlayer);
}
}
void SetQuestCompleted(object oPlayer, int JOURNAL_NUMBER, string QUEST_ID)
{
string QUEST_STRING = "QUEST_" + QUEST_ID;
string JOURNAL_STRING = "JOURNAL_" + QUEST_ID;
if (!(GetQuestCompleted(QUEST_ID)))
{
SetLocalInt(GetModule(),QUEST_STRING,QUEST_COMPLETED);
AddJournalQuestEntry(JOURNAL_STRING,JOURNAL_NUMBER,oPlayer);
GiveQuestXP(oPlayer,QUEST_ID);
}
}
|
|