Planeshift
|
This class handles quest management for the player, tracking who has what quests assigned, etc. More...
#include <questmanager.h>
Classes | |
class | TaskEntry |
This class is only for internal use for HandleQuestInfo and it's used to allow ordered population of the quest notes data. | |
Public Member Functions | |
void | Assign (psQuest *quest, Client *who, gemNPC *assigner, csTicks timeDelay=0) |
bool | Complete (psQuest *quest, Client *who, csTicks timeDelay=0) |
bool | GiveRewardToPlayer (Client *who, QuestRewardItem &reward) |
bool | Initialize () |
const char * | LastError () |
bool | LoadQuestScript (int id) |
void | OfferRewardsToPlayer (Client *who, csArray< QuestRewardItem > &offer, csTicks &timeDelay) |
int | ParseCustomScript (int id, const csString ¤t_npc, const char *script) |
Parase a new custom script. | |
int | ParseQuestScript (int id, const char *script) |
Parase a new quest script. | |
QuestManager (CacheManager *cachemanager) | |
bool | Uncomplete (psQuest *quest, Client *who, csTicks timeDelay=0) |
Discards the requested step this is used by dictionary. | |
virtual | ~QuestManager () |
Protected Member Functions | |
NpcResponse * | AddResponse (const csString ¤t_npc, const char *response_text, int &last_response_id, psQuest *quest, csString &him, csString &her, csString &it, csString &them, csString &file_path) |
Adds a NpcResponse to the dict (global var) | |
bool | AddTrigger (const csString ¤t_npc, const char *trigger, int prior_response_id, NpcResponse *trig_response, psQuest *quest, const psString &postfix) |
Adds a Trigger for a NpcResponse to the dict (global var) | |
void | AutocompleteQuestName (csString &questname, psQuest *mainQuest) |
Checks if the quest name is existant, if it isn't it attemps to complete it with the name of the passed quest but only if the autocompleted version is found. | |
bool | BuildTriggerList (csString &block, csStringArray &list) const |
void | CutOutParenthesis (csString &response, csString &within, char start_char, char end_char) const |
void | GetNextScriptLine (psString &scr, csString &block, size_t &start, int &line_number) |
int | GetNPCFromBlock (WordArray words, csString ¤t_npc) |
bool | GetResponseText (csString &block, csString &response, csString &file_path, csString &him, csString &her, csString &it, csString &them) const |
bool | HandlePlayerAction (csString &block, size_t &which_trigger, csString ¤t_npc, csStringArray &pending_triggers) |
void | HandleQuestInfo (MsgEntry *pMsg, Client *client) |
void | HandleQuestReward (MsgEntry *pMsg, Client *client) |
bool | HandleRequireCommand (csString &block, csString &response_requireop, psQuest *mainQuest) |
Parses a require command. | |
bool | HandleScriptCommand (csString &block, csString &response_requireop, csString &substep_requireop, NpcResponse *last_response, psQuest *mainQuest, bool &quest_assigned_already, psQuest *quest) |
bool | LoadQuestScripts () |
Load all scripts from db. | |
void | MergeTriggerMenus (NpcDialogMenu *pending_menu, const csString ¤t_npc) |
bool | ParseItem (const char *text, psStringArray &xmlItems, psMoney &money) |
bool | ParseItemList (const csString &input, csString &parsedItemList) |
bool | ParseQuestScriptMenu (const csString &block, const csStringArray &triggers, psQuest *quest, NpcDialogMenu *menu) const |
Parse QuestScript entries from a string. | |
csString | ParseRequireCommand (csString &block, bool &result, psQuest *mainQuest) |
Parses a require command inner part. | |
int | PreParseQuestScript (psQuest *mainQuest, const char *script) |
Does a first parsing of the script. | |
bool | PrependPrerequisites (csString &substep_requireop, csString &response_requireop, bool quest_assigned_already, NpcResponse *last_response, psQuest *mainQuest) |
Protected Attributes | |
CacheManager * | cacheManager |
csString | lastError |
Last error message to send to client on loadquest. | |
csPDelArray< QuestRewardOffer > | offers |
This class handles quest management for the player, tracking who has what quests assigned, etc.
Definition at line 52 of file questmanager.h.
QuestManager::QuestManager | ( | CacheManager * | cachemanager | ) |
virtual QuestManager::~QuestManager | ( | ) | [virtual] |
NpcResponse* QuestManager::AddResponse | ( | const csString & | current_npc, |
const char * | response_text, | ||
int & | last_response_id, | ||
psQuest * | quest, | ||
csString & | him, | ||
csString & | her, | ||
csString & | it, | ||
csString & | them, | ||
csString & | file_path | ||
) | [protected] |
Adds a NpcResponse to the dict (global var)
Creates a new NpcResponse object for the given npc with the given trigger and data.
current_npc | the npc that the response is for. |
response_text | is the text. |
last_response_id | is just an output variable, and will contain the id of the new response |
quest | is the quest generating the response |
him | |
her | |
it | |
them | |
file_path | to the voice file (if any) |
bool QuestManager::AddTrigger | ( | const csString & | current_npc, |
const char * | trigger, | ||
int | prior_response_id, | ||
NpcResponse * | trig_response, | ||
psQuest * | quest, | ||
const psString & | postfix | ||
) | [protected] |
Adds a Trigger for a NpcResponse to the dict (global var)
Creates and registeres a trigger with the dict.
current_npc | the npc that the response is for. |
trigger | contains the text that evokes the trigger |
prior_response_id | is the preceeding response id |
trig_response | is the response that was already created and registered with dict. |
quest | is the quest generating the trigger |
postfix |
void QuestManager::Assign | ( | psQuest * | quest, |
Client * | who, | ||
gemNPC * | assigner, | ||
csTicks | timeDelay = 0 |
||
) |
void QuestManager::AutocompleteQuestName | ( | csString & | questname, |
psQuest * | mainQuest | ||
) | [protected] |
Checks if the quest name is existant, if it isn't it attemps to complete it with the name of the passed quest but only if the autocompleted version is found.
questname | Name of the quest we have to check for. Output is written directly in the passed variable. |
mainQuest | The quest where this questname was found to check for in quest completion. |
bool QuestManager::BuildTriggerList | ( | csString & | block, |
csStringArray & | list | ||
) | const [protected] |
void QuestManager::CutOutParenthesis | ( | csString & | response, |
csString & | within, | ||
char | start_char, | ||
char | end_char | ||
) | const [protected] |
void QuestManager::GetNextScriptLine | ( | psString & | scr, |
csString & | block, | ||
size_t & | start, | ||
int & | line_number | ||
) | [protected] |
bool QuestManager::GetResponseText | ( | csString & | block, |
csString & | response, | ||
csString & | file_path, | ||
csString & | him, | ||
csString & | her, | ||
csString & | it, | ||
csString & | them | ||
) | const [protected] |
bool QuestManager::GiveRewardToPlayer | ( | Client * | who, |
QuestRewardItem & | reward | ||
) |
bool QuestManager::HandlePlayerAction | ( | csString & | block, |
size_t & | which_trigger, | ||
csString & | current_npc, | ||
csStringArray & | pending_triggers | ||
) | [protected] |
bool QuestManager::HandleRequireCommand | ( | csString & | block, |
csString & | response_requireop, | ||
psQuest * | mainQuest | ||
) | [protected] |
Parses a require command.
block | A csString which is the block to be parsed stripped of "require". |
response_requireop | A csString where to append the response prerequisites. |
mainQuest | A pointer to the main quest, used for quest name autocompletion |
bool QuestManager::HandleScriptCommand | ( | csString & | block, |
csString & | response_requireop, | ||
csString & | substep_requireop, | ||
NpcResponse * | last_response, | ||
psQuest * | mainQuest, | ||
bool & | quest_assigned_already, | ||
psQuest * | quest | ||
) | [protected] |
bool QuestManager::Initialize | ( | ) |
const char* QuestManager::LastError | ( | ) | [inline] |
Definition at line 252 of file questmanager.h.
bool QuestManager::LoadQuestScript | ( | int | id | ) |
bool QuestManager::LoadQuestScripts | ( | ) | [protected] |
Load all scripts from db.
void QuestManager::MergeTriggerMenus | ( | NpcDialogMenu * | pending_menu, |
const csString & | current_npc | ||
) | [protected] |
void QuestManager::OfferRewardsToPlayer | ( | Client * | who, |
csArray< QuestRewardItem > & | offer, | ||
csTicks & | timeDelay | ||
) |
Parase a new custom script.
This is the same as ParseQuestScript, but with all the limitaiton that is needed to allow players to script this.
bool QuestManager::ParseItem | ( | const char * | text, |
psStringArray & | xmlItems, | ||
psMoney & | money | ||
) | [protected] |
bool QuestManager::ParseItemList | ( | const csString & | input, |
csString & | parsedItemList | ||
) | [protected] |
bool QuestManager::ParseQuestScriptMenu | ( | const csString & | block, |
const csStringArray & | triggers, | ||
psQuest * | quest, | ||
NpcDialogMenu * | menu | ||
) | const [protected] |
Parse QuestScript entries from a string.
Parse all Menu: entries from a string
block | is the string to parse. |
triggers | is a list of trigger strings, for each menu entry one |
quest | that this menu is attached to |
menu | to add the triggers to |
csString QuestManager::ParseRequireCommand | ( | csString & | block, |
bool & | result, | ||
psQuest * | mainQuest | ||
) | [protected] |
Parses a require command inner part.
block | A csString which is the block to be parsed stripped of "require" and the leading no, if any. |
result | A bool which will store if it was possible to parse the passed string |
mainQuest | A pointer to the main quest, used for quest name autocompletion |
Does a first parsing of the script.
mainQuest | A pointer to the main psQuest. This can't be null it must be valid! |
script | The entire quest script. |
bool QuestManager::PrependPrerequisites | ( | csString & | substep_requireop, |
csString & | response_requireop, | ||
bool | quest_assigned_already, | ||
NpcResponse * | last_response, | ||
psQuest * | mainQuest | ||
) | [protected] |
Discards the requested step this is used by dictionary.
quest | The quest we are discarding. |
who | The client which is discarding the quest. |
timeDelay | The delay for messages. |
CacheManager* QuestManager::cacheManager [protected] |
Definition at line 59 of file questmanager.h.
csString QuestManager::lastError [protected] |
Last error message to send to client on loadquest.
Definition at line 57 of file questmanager.h.
csPDelArray<QuestRewardOffer> QuestManager::offers [protected] |
Definition at line 55 of file questmanager.h.