Planeshift

dictionary.h

Go to the documentation of this file.
00001 /*
00002  * dictionary.h
00003  *
00004  * Copyright (C) 2001 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 #ifndef PS_DICTIONARY_
00020 #define PS_DICTIONARY_
00021 
00022 //=============================================================================
00023 // Crystal Space Includes
00024 //=============================================================================
00025 #include <csutil/csstring.h>
00026 //#include <csutil/ref.h>
00027 #include <csutil/refcount.h>
00028 #include <csutil/parray.h>
00029 #include <csutil/hash.h>
00030 #include <csutil/redblacktree.h>
00031 
00032 //=============================================================================
00033 // Project Includes
00034 //=============================================================================
00035 #include "rpgrules/psmoney.h"
00036 
00037 #include "../tools/wordnet/wn.h"
00038 
00039 //=============================================================================
00040 // Local Includes
00041 //=============================================================================
00042 #include "psquestprereqops.h"
00043 
00044 class NpcTerm;
00045 class NpcTriggerGroupEntry;
00046 class NpcTrigger;
00047 class NpcResponse;
00048 class NpcDialogMenu;
00049 class psSkillInfo;
00050 class gemNPC;
00051 class gemActor;
00052 class Client;
00053 class psQuest;
00054 class psCharacter;
00055 class MathScript;
00056 
00057 struct iDocumentNode;
00058 struct Faction;
00059 
00064 #define MAX_RESP 5
00065 
00066 template<typename K, typename K2> class NpcTriggerOrdering : public CS::Container::RedBlackTreeOrderingTotal<NpcTrigger,NpcTrigger>
00067 {
00068 public:
00069     NpcTriggerOrdering(NpcTrigger* const &a, NpcTrigger* const &b) : CS::Container::RedBlackTreeOrderingTotal<NpcTrigger,NpcTrigger>(*a,*b)
00070     {
00071     }
00072 };
00073 
00074 class NPCDialogDict
00075 {
00076 protected:
00077     typedef csRedBlackTree<NpcTrigger*, CS::Container::DefaultRedBlackTreeAllocator<NpcTrigger*>, NpcTriggerOrdering> NpcTriggerTree;
00078     csHash<NpcTerm*, csString>         phrases;
00079     csHash<NpcTriggerGroupEntry*, csString> trigger_groups;
00080     csHash<NpcTriggerGroupEntry*>      trigger_groups_by_id;
00081     NpcTriggerTree                     triggers;
00082     csHash<NpcTrigger*>                trigger_by_id;
00083     csHash<NpcResponse*>               responses;
00084     csHash<bool, csString>             disallowed_words;
00085     csHash<csString,csString>          knowledgeAreas;  
00086 
00088     csHash<NpcDialogMenu*,csString>    initial_popup_menus;
00089     csHash<NpcDialogMenu*>             initial_popup_menus_by_quest_id;
00090 
00091     int dynamic_id;
00092 
00093     bool LoadSynonyms(iDataConnection* db);
00094     bool LoadTriggerGroups(iDataConnection* db);
00095     bool LoadTriggers(iDataConnection* db);
00096     bool LoadResponses(iDataConnection* db);
00097     bool LoadDisallowedWords(iDataConnection* db);
00098 
00101     void AddWords(csString &trigger);
00102 
00108     NpcTerm* AddTerm(const char* term);
00109 
00110     int AddTriggerGroupEntry(int id,const char* txt, int equivID);
00111     csArray<NpcTrigger*> ParseMultiTrigger(NpcTrigger* parsetrig);
00112 
00113 public:
00114     NPCDialogDict();
00115     virtual ~NPCDialogDict();
00116 
00117     bool Initialize(iDataConnection* db);
00118 
00119     bool FindKnowledgeArea(const csString &name);
00120 
00122     NpcTerm* FindTerm(const char* term);
00123 
00125     NpcTerm* FindTermOrSynonym(const csString &term);
00126 
00127     NpcResponse* FindResponse(gemNPC* npc,
00128                               const char* area,
00129                               const char* trigger,
00130                               int faction,
00131                               int priorresponse,
00132                               Client* client,
00133                               int questID = -1);
00134 
00136     NpcResponse* FindResponse(int responseID);
00137 
00139     bool AddTrigger(iDataConnection* db, int databaseID, int responseID);
00140 
00142     bool CheckForTriggerGroup(csString &trigger);
00143 
00145     void AddResponse(iDataConnection* db, int databaseID);
00146 
00148     NpcResponse* AddResponse(const char* response_text,
00149                              const char* pronoun_him,
00150                              const char* pronoun_her,
00151                              const char* pronoun_it,
00152                              const char* pronoun_them,
00153                              const char* npc_name,
00154                              int &new_id,
00155                              psQuest* quest,
00156                              const char* audio_path);
00157 
00159     NpcResponse* AddResponse(const char* script);
00160 
00161     NpcTrigger* AddTrigger(const char* k_area,
00162                            const char* mytrigger,
00163                            int prior_response,
00164                            int trigger_response);
00165 
00166     void DeleteTriggerResponse(NpcTrigger* trigger, int responseID);
00167 
00169     NpcDialogMenu* FindMenu(const char* name);
00170 
00172     void AddMenu(const char* name, NpcDialogMenu* menu);
00173     
00178     void AddMenu(NpcDialogMenu* menu);
00179     
00188     void DeleteMenusForQuest(psQuest* quest);
00189     
00190     void RemoveEmptyMenu(NpcDialogMenu* menu);
00191 
00195     void Print(const char* area);
00196 };
00197 
00202 class NpcTerm
00203 {
00204     SynsetPtr hypernymSynNet;
00205 
00206     csArray<const char*> hypernyms;
00207 
00208     void BuildHypernymList();
00209 
00210 public:
00211 
00215     csString term;
00216 
00225     NpcTerm* synonym;
00226 
00227 
00231     NpcTerm(const char* term)
00232     {
00233         synonym     = NULL;
00234         hypernymSynNet = NULL;
00235         this->term = term;
00236         this->term.Downcase();
00237     }
00238     ~NpcTerm()
00239     {
00240         if(hypernymSynNet)
00241             free_syns(hypernymSynNet);
00242     }
00243 
00244     const char* GetInterleavedHypernym(size_t which);
00245 
00246     bool IsNoun();
00247 
00251     void Print();
00252 };
00253 
00254 class NpcTriggerGroupEntry
00255 {
00256 public:
00257     int id;
00258     csString text;
00259     NpcTriggerGroupEntry* parent;
00260 
00261     NpcTriggerGroupEntry(int i,const char* txt,NpcTriggerGroupEntry* myParent=0)
00262     {
00263         id = i;
00264         text = txt;
00265         parent = myParent;
00266     }
00267 };
00268 
00269 class NpcTrigger
00270 {
00271 public:
00272     int      id;
00273     csString area;
00274     csString trigger;
00275     int      priorresponseID;
00276     csArray<int> responseIDlist;
00277     //    int      questID;
00278 
00280     bool Load(iResultRow &row);
00281 
00283     bool HaveAvailableResponses(Client* client, gemNPC* npc, NPCDialogDict* dict, csArray<int>* availableResponseList = NULL, int questID = -1);
00284 
00286     int  GetRandomResponse(const csArray<int> &availableResponseList);
00287 
00289     bool operator==(const NpcTrigger &other) const;
00290 
00292     bool operator<=(const NpcTrigger &other) const;
00293 };
00294 
00295 
00300 class ResponseOperation
00301 {
00302 protected:
00303     csString name;
00304 public:
00305     virtual ~ResponseOperation() {};
00306     virtual bool Load(iDocumentNode* node) = 0;
00307     virtual csString GetResponseScript() = 0;
00308     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber) = 0;
00312     const char* GetName()
00313     {
00314         return name;
00315     }
00316     virtual bool IsPublic()
00317     {
00318         return false;
00319     }
00320 };
00321 
00325 class NpcDialogMenu
00326 {
00327 protected:
00328     struct DialogTrigger
00329     {
00330         unsigned int triggerID;         
00331         csString menuText;              
00332         csString trigger;               
00333         psQuest* quest;                 
00334         csRef<psQuestPrereqOp> prerequisite; 
00335         
00336         /* returns the quest title 
00337          * @return the quest title if quest is set, otherwise "unknown"
00338          */
00339         csString GetQuestTitle();
00340         
00341         DialogTrigger() : quest(NULL) {}
00342     };
00343 
00344 public:
00345 
00346     csArray<DialogTrigger> triggers;    
00347 
00351     NpcDialogMenu();
00352 
00361     void AddTrigger(const csString &menuText, const csString &trigger, psQuest* quest, psQuestPrereqOp* script=NULL);
00367     void Add(NpcDialogMenu* add);
00373     void DeleteAllMenusOfQuest(psQuest* quest);
00379     void ShowMenu(Client* client,csTicks delay, gemNPC* npc);
00386     void SetPrerequisiteScript(psQuestPrereqOp* script);
00387 };
00388 
00394 class NpcResponse
00395 {
00396 public:
00397     int      id;                 
00398     csString response[MAX_RESP]; 
00399 
00401     csString him,her,it,them;    
00402     csString triggerText;        
00403     csString voiceAudioPath[MAX_RESP];   
00404     int type;                    
00405     psQuest* quest;              
00406     int active_quest;            
00407     csTicks timeDelay;           
00408     csPDelArray<ResponseOperation> script;  
00409     csRef<psQuestPrereqOp> prerequisite; 
00410     NpcDialogMenu* menu;                
00411 
00412     enum
00413     {
00414         VALID_RESPONSE,
00415         ERROR_RESPONSE
00416     };
00417 
00418     NpcResponse();
00419     virtual ~NpcResponse();
00420 
00421     bool Load(iResultRow &row);
00422 
00423     void SetActiveQuest(int max);
00424     int  GetActiveQuest()
00425     {
00426         return active_quest;
00427     }
00428 
00429     const char* GetResponse(int &number);
00431     const char* GetResponse()
00432     {
00433         int number = 0;
00434         return GetResponse(number);
00435     }
00436 
00438     const char* GetVoiceFile(int &number)
00439     {
00440         return voiceAudioPath[number];
00441     }
00442 
00444     bool HasPublicResponse();
00445     bool ParseResponseScript(const char* xmlstr,bool insertBeginning=false);
00446 
00450     csTicks ExecuteScript(gemActor* player, gemNPC* target);
00451     csString GetResponseScript();
00452 
00453     // This is used so that the popup menu and the subsequent response can share the same filtering criteria
00454     psQuestPrereqOp* GetPrerequisiteScript()
00455     {
00456         return prerequisite;
00457     }
00458 
00464     bool ParsePrerequisiteScript(const char* xmlstr,bool insertBeginning=false);
00465 
00473     bool AddPrerequisite(psQuestPrereqOp* op, bool insertBeginning = false);
00474 
00481     bool CheckPrerequisite(psCharacter* character);
00482 };
00483 
00489 class SayResponseOp : public ResponseOperation
00490 {
00491 public:
00493     bool saypublic;
00495     csString* sayWhat;
00496 
00497     SayResponseOp(const char* name, bool is_public)
00498     {
00499         sayWhat=NULL;
00500         saypublic = is_public;
00501         this->name = name;
00502     }
00503     virtual ~SayResponseOp()
00504     {
00505         if(sayWhat) delete sayWhat;
00506     }
00507     virtual bool Load(iDocumentNode* node);
00508     virtual csString GetResponseScript();
00509     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00510     virtual bool IsPublic()
00511     {
00512         return saypublic;
00513     }
00514 };
00515 
00520 class ActionResponseOp : public ResponseOperation
00521 {
00522 protected:
00523     bool actionMy,actionNarrate;
00525     bool actionpublic;
00526     csString anim;
00527     csString* actWhat;
00528 public:
00529     ActionResponseOp(const char* actionName, bool my,bool narrate, bool is_public)
00530     {
00531         actionMy = my;
00532         actionNarrate=narrate;
00533         name = actionName;
00534         actionpublic = is_public;
00535         actWhat = NULL;
00536     }
00537     virtual ~ActionResponseOp()
00538     {
00539         if(actWhat) delete actWhat;
00540     }
00541     virtual bool Load(iDocumentNode* node);
00542     virtual csString GetResponseScript();
00543     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00544     virtual bool IsPublic()
00545     {
00546         return actionpublic;
00547     }
00548 };
00549 
00556 class NPCCmdResponseOp : public ResponseOperation
00557 {
00558 protected:
00559     csString cmd;
00560 public:
00561     NPCCmdResponseOp()
00562     {
00563         name = "npccmd";
00564     }
00565     virtual ~NPCCmdResponseOp() {};
00566     virtual bool Load(iDocumentNode* node);
00567     virtual csString GetResponseScript();
00568     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00569 };
00570 
00571 class psQuest;
00572 
00578 class VerifyQuestCompletedResponseOp : public ResponseOperation
00579 {
00580 protected:
00581     psQuest* quest;        
00582     csString error_msg;    
00583 
00584 public:
00585     VerifyQuestCompletedResponseOp()
00586     {
00587         name="verifyquestcompleted";
00588         quest=NULL;
00589     }
00590     virtual ~VerifyQuestCompletedResponseOp() {};
00591     virtual bool Load(iDocumentNode* node);
00592     virtual csString GetResponseScript();
00593     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00594 };
00595 
00596 
00602 class SetVariableResponseOp : public ResponseOperation
00603 {
00604 protected:
00605     csString variableName;  
00606     csString variableValue; 
00607 
00608 public:
00610     SetVariableResponseOp()
00611     {
00612         name = "setvariable";
00613     }
00614 
00616     virtual ~SetVariableResponseOp() {};
00617 
00622     virtual bool Load(iDocumentNode* node);
00623 
00628     virtual csString GetResponseScript();
00629 
00639     virtual bool Run(gemNPC* who, gemActor* target, NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00640 
00641 };
00642 
00643 
00649 class UnSetVariableResponseOp : public ResponseOperation
00650 {
00651 protected:
00652     csString variableName; 
00653 
00654 public:
00655 
00657     UnSetVariableResponseOp()
00658     {
00659         name = "unsetvariable";
00660     }
00661 
00663     virtual ~UnSetVariableResponseOp() {};
00664 
00669     virtual bool Load(iDocumentNode* node);
00670 
00675     virtual csString GetResponseScript();
00676 
00686     virtual bool Run(gemNPC* who, gemActor* target, NpcResponse* owner, csTicks &timeDelay, int &voiceNumber);
00687 };
00688 
00689 
00695 class VerifyQuestAssignedResponseOp : public ResponseOperation
00696 {
00697 protected:
00698     psQuest* quest;        
00699     csString error_msg;    
00700 
00701 public:
00702     VerifyQuestAssignedResponseOp()
00703     {
00704         name="verifyquestassigned";
00705         quest=NULL;
00706     }
00707     VerifyQuestAssignedResponseOp(int quest);
00708     virtual ~VerifyQuestAssignedResponseOp() {};
00709     virtual bool Load(iDocumentNode* node);
00710     virtual csString GetResponseScript();
00711     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00712 };
00713 
00714 /*
00715 class FireEventResponseOp : public ResponseOperation
00716 {
00717 protected:
00718     csString event;
00719 public:
00720     FireEventResponseOp() { name="fireevent"; }
00721     virtual ~FireEventResponseOp() {};
00722     virtual bool Load(iDocumentNode *node);
00723     virtual csString GetResponseScript();
00724     virtual bool Run(gemNPC *who, Client *target,NpcResponse *owner,csTicks& timeDelay, int& voiceNumber);
00725 };
00726 */
00727 
00733 class VerifyQuestNotAssignedResponseOp : public ResponseOperation
00734 {
00735 protected:
00736     psQuest* quest;        
00737     csString error_msg;    
00738 
00739 public:
00740     VerifyQuestNotAssignedResponseOp()
00741     {
00742         name="verifyquestnotassigned";
00743         quest=NULL;
00744     }
00745     VerifyQuestNotAssignedResponseOp(int quest);
00746     virtual ~VerifyQuestNotAssignedResponseOp() {};
00747     virtual bool Load(iDocumentNode* node);
00748     virtual csString GetResponseScript();
00749     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00750 };
00751 
00756 class AssignQuestResponseOp : public ResponseOperation
00757 {
00758 protected:
00759     psQuest* quest[MAX_RESP];  
00760     csString timeout_msg;  
00761     int num_quests;        
00762 
00763 public:
00764     AssignQuestResponseOp()
00765     {
00766         name="assign";
00767         quest[0]=NULL;
00768     }
00769     virtual ~AssignQuestResponseOp() {};
00770     virtual bool Load(iDocumentNode* node);
00771     virtual csString GetResponseScript();
00772     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00773     const char* GetTimeoutMsg()
00774     {
00775         return timeout_msg;
00776     }
00777     psQuest* GetQuest(int n)
00778     {
00779         return quest[n];
00780     }
00781     int      GetMaxQuests()
00782     {
00783         return num_quests;
00784     }
00785 };
00786 
00793 class AssignQuestSelectOp : public ResponseOperation
00794 {
00795 protected:
00796     AssignQuestResponseOp* quest_op;
00797 
00798 public:
00799     AssignQuestSelectOp(AssignQuestResponseOp* questop)
00800     {
00801         name = "questselect";
00802         quest_op = questop;
00803     }
00804     virtual ~AssignQuestSelectOp() {};
00805     virtual bool Load(iDocumentNode* node)
00806     {
00807         return true;
00808     }
00809     virtual csString GetResponseScript();
00810     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00811 };
00812 
00813 
00820 class CheckQuestTimeoutOp : public ResponseOperation
00821 {
00822 protected:
00823     AssignQuestResponseOp* quest_op;
00824 
00825 public:
00826     CheckQuestTimeoutOp(AssignQuestResponseOp* questop)
00827     {
00828         name = "checkquesttimeout";
00829         quest_op = questop;
00830     }
00831     virtual ~CheckQuestTimeoutOp() {};
00832     virtual bool Load(iDocumentNode* node)
00833     {
00834         return true;
00835     }
00836     virtual csString GetResponseScript();
00837     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00838 };
00839 
00844 class CompleteQuestResponseOp : public ResponseOperation
00845 {
00846 protected:
00847     psQuest* quest;
00848     csString error_msg;
00849 
00850 public:
00851     CompleteQuestResponseOp()
00852     {
00853         name="complete";
00854         quest=NULL;
00855     }
00856     virtual ~CompleteQuestResponseOp() {};
00857     virtual bool Load(iDocumentNode* node);
00858     virtual csString GetResponseScript();
00859     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00860 };
00861 
00866 class UncompleteQuestResponseOp : public ResponseOperation
00867 {
00868 protected:
00869     psQuest* quest;
00870     csString error_msg;
00871 
00872 public:
00873     UncompleteQuestResponseOp()
00874     {
00875         name="uncomplete";
00876         quest=NULL;
00877     }
00878     virtual ~UncompleteQuestResponseOp() {};
00879     virtual bool Load(iDocumentNode* node);
00880     virtual csString GetResponseScript();
00881     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00882 };
00883 
00884 class psItemStats;
00885 
00890 class GiveItemResponseOp : public ResponseOperation
00891 {
00892 protected:
00893     psItemStats* itemstat;
00894     int count;
00895     float quality;
00896 
00897 public:
00898     GiveItemResponseOp(): itemstat(NULL), count(1), quality(0)
00899     {
00900         name="give";
00901     }
00902     virtual ~GiveItemResponseOp() {};
00903     virtual bool Load(iDocumentNode* node);
00904     virtual csString GetResponseScript();
00905     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00906 };
00907 
00908 
00912 class FactionResponseOp : public ResponseOperation
00913 {
00914 protected:
00915     Faction* faction;
00916     int value;
00917 
00918 public:
00919     FactionResponseOp()
00920     {
00921         name="faction";
00922     }
00923     virtual ~FactionResponseOp() {};
00924     virtual bool Load(iDocumentNode* node);
00925     virtual csString GetResponseScript();
00926     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00927 };
00928 
00935 class RunScriptResponseOp : public ResponseOperation
00936 {
00937 protected:
00938     csString scriptname;
00939     csString bindingsText;
00940     MathScript* bindings;
00941 
00942 public:
00943     RunScriptResponseOp()
00944     {
00945         name = "run";
00946         bindings = NULL;
00947     }
00948     virtual ~RunScriptResponseOp();
00949     virtual bool Load(iDocumentNode* node);
00950     virtual csString GetResponseScript();
00951     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00952 };
00953 
00958 class TrainResponseOp : public ResponseOperation
00959 {
00960 protected:
00961     csString scriptname;
00962     psSkillInfo* skill;
00963 
00964 public:
00965     TrainResponseOp()
00966     {
00967         name="train";
00968     }
00969     virtual ~TrainResponseOp() {};
00970     virtual bool Load(iDocumentNode* node);
00971     virtual csString GetResponseScript();
00972     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00973 };
00974 
00979 class GuildAwardResponseOp : public ResponseOperation
00980 {
00981 protected:
00982     int karma;
00983 public:
00984     GuildAwardResponseOp()
00985     {
00986         name = "guild_award";
00987     }
00988     virtual ~GuildAwardResponseOp() {};
00989     virtual bool Load(iDocumentNode* node);
00990     virtual csString GetResponseScript();
00991     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
00992 };
00993 
00998 class HireResponseOp : public ResponseOperation
00999 {
01000 protected:
01001     typedef enum 
01002     {
01003         HIRE_COMMAND_START,
01004         HIRE_COMMAND_TYPE,
01005         HIRE_COMMAND_MASTER,
01006         HIRE_COMMAND_CONFIRM,
01007         HIRE_COMMAND_SCRIPT,
01008         HIRE_COMMAND_RELEASE
01009     } HireCommand;
01010     
01011     HireCommand hireCommand;
01012     csString typeName;
01013     csString typeNPCType;
01014     PID masterNPCId;
01015 public:
01016     HireResponseOp():
01017         hireCommand(HIRE_COMMAND_START)
01018     {
01019         name = "hire";
01020     }
01021     virtual ~HireResponseOp() {};
01022     virtual bool Load(iDocumentNode* node);
01023     virtual csString GetResponseScript();
01024     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
01025 };
01026 
01027 struct QuestRewardItem
01028 {
01029     psItemStats* itemstat;
01030     int count;
01031     float quality;
01032 };
01033 
01038 class OfferRewardResponseOp : public ResponseOperation
01039 {
01040 protected:
01041     csArray<QuestRewardItem>  offer;
01042 public:
01043     OfferRewardResponseOp()
01044     {
01045         name = "offer";
01046     }
01047     virtual ~OfferRewardResponseOp() {};
01048     virtual bool Load(iDocumentNode* node);
01049     virtual csString GetResponseScript();
01050     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
01051 };
01052 
01057 class MoneyResponseOp : public ResponseOperation
01058 {
01059 protected:
01060     psMoney money;
01061 
01062 public:
01063     MoneyResponseOp()
01064     {
01065         name = "money";
01066     }
01067     virtual ~MoneyResponseOp() {};
01068     virtual bool Load(iDocumentNode* node);
01069     virtual csString GetResponseScript();
01070     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
01071 };
01072 
01076 class IntroduceResponseOp : public ResponseOperation
01077 {
01078 protected:
01079     csString targetName;
01080 public:
01081     IntroduceResponseOp()
01082     {
01083         name = "introduce";
01084     }
01085     virtual ~IntroduceResponseOp() {};
01086     virtual bool Load(iDocumentNode* node);
01087     virtual csString GetResponseScript();
01088     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
01089 };
01090 
01094 class DoAdminCommandResponseOp : public ResponseOperation
01095 {
01096 protected:
01097     csString origCommandString, modifiedCommandString;
01098 public:
01099     DoAdminCommandResponseOp()
01100     {
01101         name = "doadmincmd";
01102     }
01103     virtual ~DoAdminCommandResponseOp() {};
01104     virtual bool Load(iDocumentNode* node);
01105     virtual csString GetResponseScript();
01106     virtual bool Run(gemNPC* who, gemActor* target,NpcResponse* owner,csTicks &timeDelay, int &voiceNumber);
01107 };
01108 
01111 #endif