Planeshift
pscharquestmgr.h
Go to the documentation of this file.
1 /*
2  * pscharquestmgr.h
3  *
4  * Copyright (C) 2011 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 #ifndef __PSCHARQUESTMGR_H__
21 #define __PSCHARQUESTMGR_H__
22 
23 //=============================================================================
24 // Crystal Space Includes
25 //=============================================================================
26 #include <csutil/weakref.h>
27 
28 //=============================================================================
29 // Project Includes
30 //=============================================================================
31 #include "net/charmessages.h"
32 
33 //=============================================================================
34 // Local Includes
35 //=============================================================================
36 #include "psquest.h"
37 
38 
39 class gemObject;
40 
41 #define PSQUEST_DELETE 'D'
42 #define PSQUEST_ASSIGNED 'A'
43 #define PSQUEST_COMPLETE 'C'
44 
49 {
53  char status;
55  bool dirty;
57  unsigned long lockout_end;
62 
64  unsigned int completionOrder;
65 
67  csWeakRef<psQuest> &GetQuest();
68 
74  bool IsCompleted();
75 
76  void SetQuest(psQuest* q);
77 protected:
78 
80  int quest_id;
81 
83  csWeakRef<psQuest> quest;
84 };
85 
86 
87 //-----------------------------------------------------------------------------
91 {
92 public:
96 
101  void Initialize(psCharacter* owner);
102 
107  bool LoadQuestAssignments();
108 
116  QuestAssignment* IsQuestAssigned(int id);
117 
128  QuestAssignment* AssignQuest(psQuest* quest, PID assignerId);
129 
136  bool CompleteQuest(psQuest* quest);
137 
143  void DiscardQuest(QuestAssignment* q, bool force = false);
144 
151  bool DiscardQuest(psQuest* quest, bool force = false);
152 
161  bool SetAssignedQuestLastResponse(psQuest* quest, int response, gemObject* npc);
162 
168  {
169  return assignedQuests.GetSize();
170  }
171 
178  int GetAssignedQuestLastResponse(size_t i);
179 
190  bool UpdateQuestAssignments(bool forceUpdate = false);
191 
199  size_t GetAssignedQuests(psQuestListMessage &quests, int cNum);
200 
205  csArray<QuestAssignment*> &GetAssignedQuests()
206  {
207  return assignedQuests;
208  }
209 
216  bool CheckQuestAssigned(psQuest* quest);
217 
224  bool CheckQuestCompleted(psQuest* quest);
225 
234  bool CheckQuestAvailable(psQuest* quest, PID assignerId);
235 
242  int NumberOfQuestsCompleted(csString category);
243 
244 
245 
246 private:
247  csArray<QuestAssignment*> assignedQuests;
248 
249  psCharacter* owner;
250 };
251 //-----------------------------------------------------------------------------
252 
253 #endif
unsigned int completionOrder
In case this questassignment was completed it will contain the order of completion.
int quest_id
Quest ID saved in case quest gets nulled out from us.
PID assigner_id
Character id of player who assigned quest to this player. This is used to make sure you cannot get tw...
This class holds all information for one quest with its reference to parent quest, list of steps, lockoutime, sub quests, ...
Definition: psquest.h:67
csWeakRef< psQuest > & GetQuest()
Since "quest" member can be nulled without notice, this accessor function attempts to refresh it if N...
void SetQuest(psQuest *q)
int last_response
To avoid losing a chain of responses in a quest, last responses are stored per assigned quest...
char status
This status determines whether the quest was assigned, completed, or is marked for deletion...
size_t GetNumAssignedQuests()
Gets the number of currently assigned quests.
Class to manager a characters quest details.
Sends messages to the client listing the assigned quests for the player.
Definition: messages.h:1869
csWeakRef< psQuest > quest
Weak pointer to the underlying quest relevant here.
unsigned long lockout_end
When a quest is completed, often it cannot immediately be repeated. This indicate the time when it ca...
void void Initialize(iObjectRegistry *object_reg)
bool IsCompleted()
Checks if the quest(/step) assignment is marked as complete.
A gemObject is any solid, graphical object visible in PS with normal physics and normal collision det...
Definition: gem.h:314
bool dirty
Dirty flag determines minimal save on exit.
This structure tracks assigned quests.
csArray< QuestAssignment * > & GetAssignedQuests()
Get a list of quests.
PID last_response_from_npc_pid
To avoid losing a chain of responses in a quest, last responses are stored per assigned quest...