Planeshift
psnpcloader.h
Go to the documentation of this file.
1 /*
2  * psnpcloader.h - Author: Ian Donderwinkel
3  *
4  * Copyright (C) 2004 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 
21 #ifndef __PSNPCLOADER_H__
22 #define __PSNPCLOADER_H__
23 
24 //=============================================================================
25 // Crystal Space Includes
26 //=============================================================================
27 #include <csutil/csstring.h>
28 
29 //=============================================================================
30 // Project Includes
31 //=============================================================================
32 
33 //=============================================================================
34 // Local Includes
35 //=============================================================================
36 
37 
38 
39 // adminmessage contains classes that are used to read the
40 // responses, triggers, etc (psDialogManager)
41 class psCharacter;
42 class psDialogManager;
43 struct psTrainerSkill;
44 
50 {
51 public:
52 
53  // loads npc data from a xml file and stores it in the database
54  bool LoadFromFile(csString &filename);
55 
56  // reads npc data from the database and stores it in a xml file
57  bool SaveToFile(int id, csString &filename);
58 
59  // removes a npc from the database
60  bool RemoveFromDatabase(int npcid);
61 
62  // loads npc dialogs from a xml file and stores them in the database
63  bool LoadDialogsFromFile(csString &filename);
64 
65  // reads npc dialogs from the database and stores them in a xml file
66  bool SaveDialogsToFile(csString &area, csString &filename, int questid, bool quest);
67 
68 private:
69 
70  csRef<iDocumentNode> npcRoot;
71 
72  int npcID;
73  csString area;
74  int questID;
75 
76  psCharacter* npc;
77  psDialogManager* dialogManager;
78  csArray<csString> knowledgeAreas;
79  csArray<int> knowledgeAreasPriority;
80  csArray<psTrainerSkill> trainerSkills;
81  csString factionStandings;
82  csArray<int> buys;
83  csArray<int> sells;
84 
85  // will be used to keep track of which triggers are already exported
86  csArray<int> triggers;
87 
88  // functions to read various sections of the npc xml data
89  bool ReadBasicInfo();
90  bool ReadDescription();
91  bool ReadLocation();
92  void ReadSkills();
93  void ReadFactions();
94  void ReadKnowledgeAreas();
95  void ReadSpecificKnowledge(int questID = -1);
96  void ReadSpecialResponses(int questID = -1);
97  void ReadTrainerInfo();
98  void ReadMerchantInfo();
99  void ReadMoney();
100  void ReadStats();
101  void ReadTraits();
102 
103  void SetupEquipment();
104 
105  // writes all data to the database
106  bool WriteToDatabase();
107 
108 
109  // functions to read npc data from the database.
110  // this will be written to a file in the SaveToFile method.
111  void WriteBasicInfo();
112  void WriteDescription();
113  void WriteKnowledgeAreas();
114  bool WriteResponse(csRef<iDocumentNode> attitudeNode, int id, int questID);
115  bool WriteTrigger(csRef<iDocumentNode> specificsNode, csString &trigger, int priorID, int questID = -1);
116  bool WriteSpecificKnowledge(int questid = -1);
117  void WriteFactions();
118  void WriteSkills();
119  void WriteMerchantInfo();
120  void WriteTrainerInfo();
121  void WriteStats();
122  void WriteMoney();
123  void WriteLocation();
124  void WriteEquipment();
125 };
126 
127 
128 #endif
129 
This is a utility class used to load/save NPCs from/to an XML file Was used in the past to load NPCs ...
Definition: psnpcloader.h:49
bool LoadDialogsFromFile(csString &filename)
bool LoadFromFile(csString &filename)
This is used to handle <specificknowledge> and <specialresponse> tags.
Definition: psnpcdialog.h:233
bool SaveDialogsToFile(csString &area, csString &filename, int questid, bool quest)
bool SaveToFile(int id, csString &filename)
bool RemoveFromDatabase(int npcid)