Planeshift
psquestprereqops.h
Go to the documentation of this file.
1 /*
2  * psquest.h
3  *
4  * Copyright (C) 2005 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  * Contains all prerequisites for a quest to be active, example completion of another quest,
20  * or certain skills/ranks
21  */
22 
23 #ifndef __PSQUESTPREREQOPS_H__
24 #define __PSQUESTPREREQOPS_H__
25 
26 //=============================================================================
27 // Crystal Space Includes
28 //=============================================================================
29 #include <csutil/refarr.h>
30 #include <csutil/refcount.h>
31 
32 //=============================================================================
33 // Project Includes
34 //=============================================================================
35 
36 #include "pstrait.h"
37 
38 //=============================================================================
39 // Local Includes
40 //=============================================================================
41 #include "psattack.h"
42 
43 class psCharacter;
44 class psQuest;
45 class psSkillInfo;
46 struct Faction;
47 
59 {
60 public:
65  virtual ~psQuestPrereqOp() {};
66 
76  virtual bool Check(psCharacter* character) = 0;
77 
85  virtual csString GetScript();
86 
95  virtual csString GetScriptOp() = 0;
96 
105  virtual csPtr<psQuestPrereqOp> Copy() = 0;
106 };
107 
116 {
117 protected:
121  csRefArray<psQuestPrereqOp> prereqlist;
122 public:
123 
130  virtual ~psQuestPrereqOpList() {}
131 
140  virtual void Push(csRef<psQuestPrereqOp> prereqOp);
141 
151  virtual void Insert(size_t n, csRef<psQuestPrereqOp> prereqOp);
152 
153 };
154 
162 {
163 public:
164 
168  virtual ~psQuestPrereqOpAnd() {}
169 
178  virtual bool Check(psCharacter* character);
179 
188  virtual csString GetScriptOp();
189 
198  virtual csPtr<psQuestPrereqOp> Copy();
199 };
200 
201 
209 {
210 public:
211 
215  virtual ~psQuestPrereqOpOr() {}
216 
225  virtual bool Check(psCharacter* character);
226 
235  virtual csString GetScriptOp();
236 
245  virtual csPtr<psQuestPrereqOp> Copy();
246 };
247 
255 {
256  int min,max;
257 public:
258 
267  psQuestPrereqOpRequire(int min_required,int max_required);
268 
273 
285  virtual bool Check(psCharacter* character);
286 
295  virtual csString GetScriptOp();
296 
305  virtual csPtr<psQuestPrereqOp> Copy();
306 };
307 
314 {
315 public:
316 
320  virtual ~psQuestPrereqOpNot() {}
321 
330  virtual bool Check(psCharacter* character);
331 
340  virtual csString GetScriptOp();
341 
350  virtual csPtr<psQuestPrereqOp> Copy();
351 };
352 
360 {
361 protected:
365  csWeakRef<psQuest> quest;
366  csString name;
367 
368 public:
369 
375  psQuestPrereqOpQuestCompleted(psQuest* quest):quest(quest) { GetQuestName(); };
376 
382  psQuestPrereqOpQuestCompleted(csString questName);
383 
388 
397  virtual bool Check(psCharacter* character);
398 
407  virtual csString GetScriptOp();
408 
417  virtual csPtr<psQuestPrereqOp> Copy();
418 
425  virtual psQuest* GetQuest();
426 
433  virtual csString GetQuestName();
434 };
435 
443 {
444 protected:
448  csWeakRef<psQuest> quest;
449  csString questName;
450 public:
451 
457  psQuestPrereqOpQuestAssigned(psQuest* quest):quest(quest) { GetQuestName(); };
458 
462 
471  virtual bool Check(psCharacter* character);
472 
481  virtual csString GetScriptOp();
482 
491  virtual csPtr<psQuestPrereqOp> Copy();
492 
499  virtual psQuest* GetQuest();
500 
507  virtual csString GetQuestName();
508 };
509 
516 {
517 protected:
518 
522  int min;
523 
527  int max;
528 
532  csString category;
533 public:
534 
544  psQuestPrereqOpQuestCompletedCategory(csString quest_category,
545  int min_required,int max_required)
546  : min(min_required),max(max_required),category(quest_category) {};
547 
552 
562  virtual bool Check(psCharacter* character);
563 
571  virtual csString GetScriptOp();
572 
581  virtual csPtr<psQuestPrereqOp> Copy();
582 };
583 
591 {
592 protected:
597 
601  int value;
602  bool max;
603 public:
604 
612  psQuestPrereqOpFaction(Faction* faction, int value, bool max):faction(faction),value(value),max(max) {};
613 
618 
627  virtual bool Check(psCharacter* character);
628 
637  virtual csString GetScriptOp();
638 
647  virtual csPtr<psQuestPrereqOp> Copy();
648 };
649 
657 {
658 protected:
659  csString itemName;
660  csString categoryName;
662  int amountMin;
663  int amountMax;
664  float qualityMin;
665  float qualityMax;
666 
667 public:
668 
681  psQuestPrereqOpItem(const char* itemName, const char* categoryName, bool includeInventory, int amountMin, int amountMax, float qualityMin, float qualityMax):
682  itemName(itemName), categoryName(categoryName), includeInventory(includeInventory),
683  amountMin(amountMin), amountMax(amountMax), qualityMin(qualityMin), qualityMax(qualityMax) {};
684 
688  virtual ~psQuestPrereqOpItem() {}
689 
696  virtual bool Check(psCharacter* character);
697 
706  virtual csString GetScriptOp();
707 
716  virtual csPtr<psQuestPrereqOp> Copy();
717 };
718 
725 {
726 protected:
727  csString activeMagic;
728 
729 public:
730 
736  psQuestPrereqOpActiveMagic(const char* activeMagic):activeMagic(activeMagic) {};
737 
739 
746  virtual bool Check(psCharacter* character);
747 
756  virtual csString GetScriptOp();
757 
766  virtual csPtr<psQuestPrereqOp> Copy();
767 };
768 
775 {
776 protected:
777  csString traitName;
779 
780 public:
781 
786  psQuestPrereqOpTrait(const char* traitName, csString traitLocationString):traitName(traitName)
787  {
788  for(int position = PSTRAIT_LOCATION_NONE; position < PSTRAIT_LOCATION_COUNT; position++)
789  {
790  if((csString)psTrait::locationString[position] == traitLocationString)
791  {
792  traitLocation = (PSTRAIT_LOCATION) position;
793  break;
794  }
795  }
796  // TraitLocation = (PSTRAIT_LOCATION)1;
797 
798  };
799 
801 
808  virtual bool Check(psCharacter* character);
809 
818  virtual csString GetScriptOp();
819 
828  virtual csPtr<psQuestPrereqOp> Copy();
829 };
830 
837 {
838 protected:
839  csString race;
840 
841 public:
842 
848  psQuestPrereqOpRace(const char* race):race(race) {};
849 
850  virtual ~psQuestPrereqOpRace() {}
851 
858  virtual bool Check(psCharacter* character);
859 
868  virtual csString GetScriptOp();
869 
878  virtual csPtr<psQuestPrereqOp> Copy();
879 };
880 
887 {
888 protected:
889  csString gender;
890 
891 public:
892 
898  psQuestPrereqOpGender(const char* gender):gender(gender) {};
899 
901 
908  virtual bool Check(psCharacter* character);
909 
918  virtual csString GetScriptOp();
919 
928  virtual csPtr<psQuestPrereqOp> Copy();
929 };
930 
937 {
938 protected:
939  csString spell;
940 
941 public:
942 
948  psQuestPrereqOpKnownSpell(const char* spell):spell(spell) {};
949 
951 
958  virtual bool Check(psCharacter* character);
959 
968  virtual csString GetScriptOp();
969 
978  virtual csPtr<psQuestPrereqOp> Copy();
979 };
980 
987 {
988 protected:
989  csString guildtype;
990  csString guildName;
991 
992 public:
993 
1000  psQuestPrereqOpGuild(const char* guildtype, const char* guildName):guildtype(guildtype),guildName(guildName) {};
1001 
1003 
1010  virtual bool Check(psCharacter* character);
1011 
1020  virtual csString GetScriptOp();
1021 
1030  virtual csPtr<psQuestPrereqOp> Copy();
1031 };
1032 
1039 {
1040 public:
1041 
1046 
1048 
1055  virtual bool Check(psCharacter* character);
1056 
1065  virtual csString GetScriptOp();
1066 
1075  virtual csPtr<psQuestPrereqOp> Copy();
1076 };
1077 
1084 {
1085 protected:
1086  int minPoints, maxPoints;
1087  csString type;
1088 
1089 public:
1090 
1098  psQuestPrereqOpAdvisorPoints(int minPoints, int maxPoints, csString type):minPoints(minPoints),maxPoints(maxPoints),type(type) {};
1099 
1101 
1108  virtual bool Check(psCharacter* character);
1109 
1118  virtual csString GetScriptOp();
1119 
1128  virtual csPtr<psQuestPrereqOp> Copy();
1129 };
1130 
1137 {
1138 protected:
1139  unsigned int minTime, maxTime;
1140 
1141 public:
1142 
1149  psQuestPrereqOpTimeOnline(int minTime, int maxTime):minTime(minTime),maxTime(maxTime) {};
1150 
1152 
1159  virtual bool Check(psCharacter* character);
1160 
1169  virtual csString GetScriptOp();
1170 
1179  virtual csPtr<psQuestPrereqOp> Copy();
1180 };
1181 
1188 {
1189 protected:
1190  int minTime, maxTime;
1191 
1192 public:
1193 
1200  psQuestPrereqOpTimeOfDay(int minTime, int maxTime):minTime(minTime),maxTime(maxTime) {};
1201 
1203 
1210  virtual bool Check(psCharacter* character);
1211 
1220  virtual csString GetScriptOp();
1221 
1230  virtual csPtr<psQuestPrereqOp> Copy();
1231 };
1232 
1239 {
1240 protected:
1241  csString variableName;
1242  csString variableValue;
1243  double min, max;
1244 
1245 public:
1246 
1252  psQuestPrereqOpVariable(const char* name)
1253  : variableName(name), min(0), max(0)
1254  {
1255  }
1256  psQuestPrereqOpVariable(const char* name, const char* value)
1257  : variableName(name), variableValue(value), min(0), max(0)
1258  {
1259  }
1260  psQuestPrereqOpVariable(const char* name, double minv, double maxv)
1261  : variableName(name), min(minv), max(maxv)
1262  {
1263  }
1265  : variableName(other.variableName), variableValue(other.variableValue),
1266  min(other.min), max(other.max)
1267  {
1268  }
1269 
1271 
1278  virtual bool Check(psCharacter* character);
1279 
1288  virtual csString GetScriptOp();
1289 
1298  virtual csPtr<psQuestPrereqOp> Copy();
1299 };
1300 
1308 {
1309 public:
1310 
1314  virtual ~psQuestPrereqOpXor() {}
1315 
1324  virtual bool Check(psCharacter* character);
1325 
1334  virtual csString GetScriptOp();
1335 
1344  virtual csPtr<psQuestPrereqOp> Copy();
1345 };
1346 
1354 {
1355 protected:
1360 
1361  int min;
1362  int max;
1364 public:
1365 
1374  psQuestPrereqOpSkill(psSkillInfo* skill, unsigned int min, unsigned int max, bool allowBuffed):skill(skill),min(min),max(max),allowBuffed(allowBuffed) {};
1375 
1380 
1387  virtual bool Check(psCharacter* character);
1388 
1397  virtual csString GetScriptOp();
1398 
1407  virtual csPtr<psQuestPrereqOp> Copy();
1408 };
1409 
1417 {
1418  protected:
1420 
1421  public:
1422 
1427  psPrereqOpAttackType(psAttackType* attackType) : attackType(attackType) {}
1428 
1433 
1440  virtual bool Check(psCharacter* character);
1441 
1450  virtual csString GetScriptOp();
1451 
1452 
1461  virtual csPtr<psQuestPrereqOp> Copy();
1462 
1463 private:
1468  bool checkWeapon(psCharacter* character, int slot);
1469 
1470 
1475  bool checkWType(psCharacter* character, psItem* weapon);
1476 };
1477 
1478 
1485 {
1486  protected:
1487  csString stance;
1488 
1489  public:
1490 
1496  psPrereqOpStance(csString stance):stance(stance){};
1497 
1501  virtual ~psPrereqOpStance() {}
1502 
1503 
1510  virtual bool Check(psCharacter * character);
1511 
1512 
1521  virtual csString GetScriptOp();
1522 
1523 
1524 
1533  virtual csPtr<psQuestPrereqOp> Copy();
1534 
1535 };
1536 
1540 #endif
bool includeInventory
category of the item (if empty, itemname must be set)
Guild prerequisite operator.
Skill prerequisite operator.
psQuestPrereqOpActiveMagic(const char *activeMagic)
Construct an active magic operator.
Pure virtual base quest prerequisite operator class.
psQuestPrereqOpItem(const char *itemName, const char *categoryName, bool includeInventory, int amountMin, int amountMax, float qualityMin, float qualityMax)
maximum quality of the required item
psPrereqOpAttackType(psAttackType *attackType)
Construct an attack type.
virtual ~psQuestPrereqOpItem()
Destructor.
psQuestPrereqOpRace(const char *race)
Construct a race operator.
virtual csPtr< psQuestPrereqOp > Copy()=0
Copy the prerequisite operator.
Time of day prerequisite operator.
Quest assigned prerequisite operator.
bool allowBuffed
Stores if we should allow buff to be taken in consideration.
Represents a skill an NPC, player or pet can learn.
Definition: psskills.h:72
Xor prerequisite operator.
csString categoryName
itemname of the item (if empty, category must be set)
#define min(x, y)
Definition: xdelta3.h:317
psQuestPrereqOpVariable(const char *name, double minv, double maxv)
This struct holds data for generic attack types This could be for example an assassin attack which wo...
Definition: psattack.h:60
virtual ~psPrereqOpStance()
Destructor.
int value
The faction level needed.
csString category
The category that will be tested for.
This class holds all information for one quest with its reference to parent quest, list of steps, lockoutime, sub quests, ...
Definition: psquest.h:67
virtual csString GetScript()
Convert the prerequisite script to a xml string.
virtual bool Check(psCharacter *character)=0
Check for valid prerequisite.
int min
The minimum of quest in the given category that need to be completed.
Trait prerequisite operator.
int min
The minimum skill level.
Basis list prerequisite operator.
psQuestPrereqOpMarriage()
Construct a marriage operator.
Faction * faction
The faction that is to be checked.
Spell knownledge prerequisite operator.
static const char * locationString[]
Definition: pstrait.h:45
Inventory prerequisite operator.
Time online time prerequisite operator.
PSTRAIT_LOCATION
Define the player controled base customization that their model can have.
Definition: charmessages.h:24
psQuestPrereqOpQuestCompletedCategory(csString quest_category, int min_required, int max_required)
Construct a quest completed category opererator.
Or prerequisite operator.
psQuestPrereqOpKnownSpell(const char *spell)
Construct a Spell Known operator.
psQuestPrereqOpGender(const char *gender)
Construct a gender operator.
Gender prerequisite operator.
virtual ~psQuestPrereqOpNot()
Destructor for the not prerequisite operator.
Not prerequisite operator.
Variable set prerequisite operator.
PSTRAIT_LOCATION traitLocation
And Prerequisite operator.
psSkillInfo * skill
The skill name that is to be checked.
int amountMax
minimum amount of this sort of item
virtual ~psQuestPrereqOpAnd()
Destructor for the and prerequisite operator.
virtual ~psQuestPrereqOpQuestCompletedCategory()
Destructor for the quest completed category prerequisite operator.
psQuestPrereqOpVariable(const char *name, const char *value)
int max
The maximum skill level.
virtual ~psQuestPrereqOpRequire()
Destructor for the require prerequisite operator.
psQuestPrereqOpAdvisorPoints(int minPoints, int maxPoints, csString type)
Construct an advisor points operator.
Quest Completed prerequisite operator.
psQuestPrereqOpQuestAssigned(psQuest *quest)
name of the quest (for weakref if invalid)
psQuestPrereqOpTimeOnline(int minTime, int maxTime)
Construct an online time operator.
virtual ~psQuestPrereqOp()
Destructor for the prerequisite operator.
race prerequisite operator.
advisor points prerequisite operator.
Marriage prerequisite operator.
virtual ~psQuestPrereqOpXor()
Destructor for the or prerequisite operator.
psQuestPrereqOpFaction(Faction *faction, int value, bool max)
Construct a faction operator.
csWeakRef< psQuest > quest
The quest that need to be assigned.
psQuestPrereqOpGuild(const char *guildtype, const char *guildName)
Construct a guild operator.
#define max(x, y)
Definition: xdelta3.h:314
Faction prerequisite operator.
csRefArray< psQuestPrereqOp > prereqlist
The list of child prerequisite operators for this list operator.
virtual ~psQuestPrereqOpSkill()
Destructor.
Active magic prerequisite operator.
psQuestPrereqOpSkill(psSkillInfo *skill, unsigned int min, unsigned int max, bool allowBuffed)
Construct a skill operator.
psQuestPrereqOpTimeOfDay(int minTime, int maxTime)
Construct a time of the day operator.
psQuestPrereqOpQuestCompleted(psQuest *quest)
Construct a quest completed operator.
float qualityMax
minimum quality of the required item
virtual ~psQuestPrereqOpList()
Destructor for the list prerequisite operator.
virtual ~psPrereqOpAttackType()
Destructor.
Quest Completed Category operator.
virtual ~psQuestPrereqOpFaction()
Destructor.
float qualityMin
maximum amount of this sort of item
virtual ~psQuestPrereqOpRace()
Weapon requirement operator.
psPrereqOpStance(csString stance)
Construct a stance operator.
psAttackType * attackType
The required attack Type.
virtual ~psQuestPrereqOpOr()
Destructor for the or prerequisite operator.
int amountMin
whether equiped or inventory is included in searches
virtual ~psQuestPrereqOpQuestCompleted()
Destructor for the quest completed prerequisite operator.
virtual csString GetScriptOp()=0
Convert the prerequisite operator to a xml string.
Require prerequisite operator.
psQuestPrereqOpVariable(const psQuestPrereqOpVariable &other)
An ingame faction group.
Definition: factions.h:41
Stance requirement operator.
int max
The maximum of quest in the given category that need to be completed.
psQuestPrereqOpVariable(const char *name)
Construct a variable operator.
psQuestPrereqOpTrait(const char *traitName, csString traitLocationString)
Construct a Trait operator.
This class embodies item instances in the game.
Definition: psitem.h:238
csWeakRef< psQuest > quest
The quest that need to be completed.