Planeshift
|
00001 /* 00002 * psnpcloader.h - Author: Ian Donderwinkel 00003 * 00004 * Copyright (C) 2004 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 00020 00021 #ifndef __PSNPCLOADER_H__ 00022 #define __PSNPCLOADER_H__ 00023 00024 //============================================================================= 00025 // Crystal Space Includes 00026 //============================================================================= 00027 #include <csutil/csstring.h> 00028 00029 //============================================================================= 00030 // Project Includes 00031 //============================================================================= 00032 00033 //============================================================================= 00034 // Local Includes 00035 //============================================================================= 00036 00037 00038 00039 // adminmessage contains classes that are used to read the 00040 // responses, triggers, etc (psDialogManager) 00041 class psCharacter; 00042 class psDialogManager; 00043 struct psTrainerSkill; 00044 00045 class psNPCLoader 00046 { 00047 public: 00048 00049 // loads npc data from a xml file and stores it in the database 00050 bool LoadFromFile(csString &filename); 00051 00052 // reads npc data from the database and stores it in a xml file 00053 bool SaveToFile(int id, csString &filename); 00054 00055 // removes a npc from the database 00056 bool RemoveFromDatabase(int npcid); 00057 00058 // loads npc dialogs from a xml file and stores them in the database 00059 bool LoadDialogsFromFile(csString &filename); 00060 00061 // reads npc dialogs from the database and stores them in a xml file 00062 bool SaveDialogsToFile(csString &area, csString &filename, int questid, bool quest); 00063 00064 private: 00065 00066 csRef<iDocumentNode> npcRoot; 00067 00068 int npcID; 00069 csString area; 00070 int questID; 00071 00072 psCharacter* npc; 00073 psDialogManager* dialogManager; 00074 csArray<csString> knowledgeAreas; 00075 csArray<int> knowledgeAreasPriority; 00076 csArray<psTrainerSkill> trainerSkills; 00077 csString factionStandings; 00078 csArray<int> buys; 00079 csArray<int> sells; 00080 00081 // will be used to keep track of which triggers are already exported 00082 csArray<int> triggers; 00083 00084 // functions to read various sections of the npc xml data 00085 bool ReadBasicInfo(); 00086 bool ReadDescription(); 00087 bool ReadLocation(); 00088 void ReadSkills(); 00089 void ReadFactions(); 00090 void ReadKnowledgeAreas(); 00091 void ReadSpecificKnowledge(int questID = -1); 00092 void ReadSpecialResponses(int questID = -1); 00093 void ReadTrainerInfo(); 00094 void ReadMerchantInfo(); 00095 void ReadMoney(); 00096 void ReadStats(); 00097 void ReadTraits(); 00098 00099 void SetupEquipment(); 00100 00101 // writes all data to the database 00102 bool WriteToDatabase(); 00103 00104 00105 // functions to read npc data from the database. 00106 // this will be written to a file in the SaveToFile method. 00107 void WriteBasicInfo(); 00108 void WriteDescription(); 00109 void WriteKnowledgeAreas(); 00110 bool WriteResponse(csRef<iDocumentNode> attitudeNode, int id, int questID); 00111 bool WriteTrigger(csRef<iDocumentNode> specificsNode, csString &trigger, int priorID, int questID = -1); 00112 bool WriteSpecificKnowledge(int questid = -1); 00113 void WriteFactions(); 00114 void WriteSkills(); 00115 void WriteMerchantInfo(); 00116 void WriteTrainerInfo(); 00117 void WriteStats(); 00118 void WriteMoney(); 00119 void WriteLocation(); 00120 void WriteEquipment(); 00121 }; 00122 00123 00124 #endif 00125